3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 15:00:00 +00:00
zeppelin/backend/src/exportSchemas.ts

24 lines
660 B
TypeScript
Raw Normal View History

import { z } from "zod";
import zodToJsonSchema from "zod-to-json-schema";
import { guildPluginInfo } from "./plugins/pluginInfo";
import { zZeppelinGuildConfig } from "./types";
const pluginSchemaMap = Object.entries(guildPluginInfo).reduce((map, [pluginName, pluginInfo]) => {
if (pluginInfo.configSchema) {
map[pluginName] = pluginInfo.configSchema;
}
return map;
}, {});
2024-01-27 14:23:13 +02:00
const fullSchema = zZeppelinGuildConfig.omit({ plugins: true }).merge(
z.strictObject({
plugins: z.strictObject(pluginSchemaMap).partial(),
2024-01-27 14:23:13 +02:00
}),
);
const jsonSchema = zodToJsonSchema(fullSchema);
console.log(JSON.stringify(jsonSchema, null, 2));
process.exit(0);