refactor: added type generation from schema for sdk with comments
This commit is contained in:
parent
2683d46b16
commit
04e332d91e
7 changed files with 65 additions and 20 deletions
|
|
@ -9,8 +9,8 @@ export const PluginContextSchema = z.object({
|
|||
|
||||
export const PluginLoadingContextSchema = z.object({
|
||||
setProgress: z.function().input([z.number(), z.string()]).output(z.void()),
|
||||
config: z.instanceof(Conf),
|
||||
zodRegistry: z.instanceof($ZodRegistry)
|
||||
config: z.instanceof(Conf).describe("Per plugin config. It will use the settings schema defined in the plugin class"),
|
||||
zodRegistry: z.instanceof($ZodRegistry).describe("Used by the settings to register metadata for the UI")
|
||||
}).extend(PluginContextSchema.shape);
|
||||
|
||||
export const PluginDescriptionSchema = z.object({
|
||||
|
|
@ -18,24 +18,24 @@ export const PluginDescriptionSchema = z.object({
|
|||
displayName: z.string(),
|
||||
version: z.string(),
|
||||
description: z.string(),
|
||||
icon: z.url().optional(),
|
||||
icon: z.url().optional().describe("Can be an external URL to an image or a data url"),
|
||||
keywords: z.array(z.string()).optional(),
|
||||
category: z.string().default("other"),
|
||||
main: z.string(),
|
||||
canDisable: z.boolean().default(true).optional()
|
||||
main: z.string().describe("The main entry. It must export a default class implementing PluginType"),
|
||||
canDisable: z.boolean().default(true).optional().describe("Can the plugin be disabled or enabled by the user")
|
||||
});
|
||||
|
||||
export const PluginSchema = z.object({
|
||||
load: z.function().input([PluginLoadingContextSchema]).output(z.promise(z.void())),
|
||||
cleanup: z.function().output(z.promise(z.void())).optional(),
|
||||
settingsSchema: z.instanceof(z.ZodObject).optional(),
|
||||
load: z.function().input([PluginLoadingContextSchema]).output(z.promise(z.void())).describe("Called when the plugin is loaded or reloaded"),
|
||||
cleanup: z.function().output(z.promise(z.void())).optional().describe("Called when the plugin is unloaded or before it's reloaded"),
|
||||
settingsSchema: z.instanceof(z.ZodObject).optional().describe("The settings schema. Gameflow will show settings in the UI."),
|
||||
settingsMigrations: z.record(z.string(), z.function().input([z.instanceof(Conf)]).output(z.void())).optional(),
|
||||
eventsNames: z.object({
|
||||
id: z.string(),
|
||||
title: z.string().optional(),
|
||||
description: z.string().optional(),
|
||||
action: z.string()
|
||||
}).array().optional(),
|
||||
}).array().optional().describe("Events will be called when the user presses the button in plugin settings. Each event creates a button."),
|
||||
onEvent: z.function().input([z.string()]).output(z.object({
|
||||
openTab: z.string().optional(),
|
||||
reload: z.boolean().optional()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue