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
631 B
TypeScript
Raw Normal View History

import { z } from "zod";
import zodToJsonSchema from "zod-to-json-schema";
2024-01-27 14:23:13 +02:00
import { guildPlugins } from "./plugins/availablePlugins";
import { zZeppelinGuildConfig } from "./types";
const pluginSchemaMap = guildPlugins.reduce((map, plugin) => {
2024-01-27 14:23:13 +02:00
if (!plugin.info) {
return map;
}
map[plugin.name] = plugin.info.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);