All files / src/lib/pluginManager types.ts

88.89% Statements 8/9
100% Branches 0/0
0% Functions 0/1
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 641x 1x   1x                           1x                               1x                       1x               1x                    
import { Type, Static } from "@sinclair/typebox";
import { Value } from "@sinclair/typebox/value";
 
export const PluginType = Type.Union(
  [
    Type.Literal("assetPack"),
    Type.Literal("enginePlugin"),
    Type.Literal("eventsPlugin"),
    Type.Literal("theme"),
    Type.Literal("lang"),
    Type.Literal("template"),
  ],
  { default: "assetPack" }
);
 
export type PluginType = Static<typeof PluginType>;
 
export const PluginMetadata = Type.Object({
  id: Type.String(),
  type: PluginType,
  version: Type.String(),
  gbsVersion: Type.String(),
  name: Type.String(),
  author: Type.String(),
  description: Type.String(),
  license: Type.Optional(Type.String()),
  url: Type.Optional(Type.String()),
  images: Type.Optional(Type.Array(Type.String())),
  filename: Type.String(),
});
 
export type PluginMetadata = Static<typeof PluginMetadata>;
 
export const PluginRepositoryMetadata = Type.Object({
  id: Type.String(),
  name: Type.String(),
  shortName: Type.String(),
  author: Type.String(),
  description: Type.String(),
  url: Type.Optional(Type.String()),
  plugins: Type.Array(PluginMetadata),
});
 
export type PluginRepositoryMetadata = Static<typeof PluginRepositoryMetadata>;
 
export const PluginRepositoryEntry = Type.Object({
  id: Type.String(),
  name: Type.String(),
  url: Type.String(),
});
 
export type PluginRepositoryEntry = Static<typeof PluginRepositoryEntry>;
 
export const isPluginRepositoryEntry = (
  value: unknown
): value is PluginRepositoryEntry => {
  return Value.Check(PluginRepositoryEntry, value);
};
 
export type InstalledPluginData = {
  path: string;
  version: string;
};