Skip to content

Commit

Permalink
Add preferences and description
Browse files Browse the repository at this point in the history
  • Loading branch information
Exidex committed Mar 9, 2024
1 parent a739d69 commit 949a373
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,71 @@ import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import { readFileSync, writeFileSync } from "node:fs";

const preferences = z.discriminatedUnion("type", [
z.strictObject({
type: z.literal("number"),
name: z.string(),
default: z.optional(z.number()),
description: z.string(),
}),
z.strictObject({
type: z.literal("string"),
name: z.string(),
default: z.optional(z.string()),
description: z.string(),
}),
z.strictObject({
type: z.literal("enum"),
name: z.string(),
default: z.optional(z.string()),
description: z.string(),
enum_values: z.array(z.strictObject({
label: z.string(),
value: z.string()
})),
}),
z.strictObject({
type: z.literal("bool"),
name: z.string(),
default: z.optional(z.boolean()),
description: z.string(),
}),
z.strictObject({
type: z.literal("list_of_strings"),
name: z.string(),
default: z.optional(z.array(z.string())),
description: z.string(),
}),
z.strictObject({
type: z.literal("list_of_numbers"),
name: z.string(),
default: z.optional(z.array(z.number())),
description: z.string(),
}),
z.strictObject({
type: z.literal("list_of_enums"),
name: z.string(),
default: z.optional(z.array(z.string())),
description: z.string(),
enum_values: z.array(z.strictObject({
label: z.string(),
value: z.string()
})),
})
]);

const Manifest = z.strictObject({
gauntlet: z.strictObject({
name: z.string()
name: z.string(),
description: z.string()
}),
preferences: z.optional(z.array(preferences)),
entrypoint: z.array(z.strictObject({
id: z.string(),
name: z.string(),
path: z.string(),
type: z.enum(["command", "view", "inline-view"])
type: z.enum(["command", "view", "inline-view"]),
preferences: z.optional(z.array(preferences)),
})).refine(
entrypoints => entrypoints.filter(value => value.type === "inline-view").length <= 1,
{ message: "Only single 'inline-view' entrypoint is allowed" }
Expand Down

0 comments on commit 949a373

Please sign in to comment.