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

25 lines
633 B
TypeScript
Raw Normal View History

import { z } from "zod";
import { guildPlugins } from "./plugins/availablePlugins";
import zodToJsonSchema from "zod-to-json-schema";
import { zZeppelinGuildConfig } from "./types";
const pluginSchemaMap = guildPlugins.reduce((map, plugin) => {
if (! plugin.info) {
return map;
}
map[plugin.name] = plugin.info.configSchema;
return map;
}, {});
const fullSchema = zZeppelinGuildConfig
.omit({ plugins: true })
.merge(z.strictObject({
plugins: z.strictObject(pluginSchemaMap).partial(),
}));
const jsonSchema = zodToJsonSchema(fullSchema);
console.log(JSON.stringify(jsonSchema, null, 2));
process.exit(0);