mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
refactor: replace io-ts with zod
This commit is contained in:
parent
fafaefa1fb
commit
28692962bc
161 changed files with 1450 additions and 2105 deletions
|
@ -3,7 +3,7 @@ import { AllowedGuilds } from "../../data/AllowedGuilds";
|
|||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { makeIoTsConfigParser, sendSuccessMessage } from "../../pluginUtils";
|
||||
import { sendSuccessMessage } from "../../pluginUtils";
|
||||
import { zeppelinGlobalPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { getActiveReload, resetActiveReload } from "./activeReload";
|
||||
import { AddDashboardUserCmd } from "./commands/AddDashboardUserCmd";
|
||||
|
@ -22,7 +22,7 @@ import { ReloadServerCmd } from "./commands/ReloadServerCmd";
|
|||
import { RemoveDashboardUserCmd } from "./commands/RemoveDashboardUserCmd";
|
||||
import { RestPerformanceCmd } from "./commands/RestPerformanceCmd";
|
||||
import { ServersCmd } from "./commands/ServersCmd";
|
||||
import { BotControlPluginType, ConfigSchema } from "./types";
|
||||
import { BotControlPluginType, zBotControlConfig } from "./types";
|
||||
|
||||
const defaultOptions = {
|
||||
config: {
|
||||
|
@ -37,7 +37,7 @@ const defaultOptions = {
|
|||
|
||||
export const BotControlPlugin = zeppelinGlobalPlugin<BotControlPluginType>()({
|
||||
name: "bot_control",
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zBotControlConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, globalPluginEventListener, globalPluginMessageCommand } from "knub";
|
||||
import z from "zod";
|
||||
import { AllowedGuilds } from "../../data/AllowedGuilds";
|
||||
import { ApiPermissionAssignments } from "../../data/ApiPermissionAssignments";
|
||||
import { Configs } from "../../data/Configs";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { tNullable } from "../../utils";
|
||||
import { zBoundedCharacters } from "../../utils";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
can_use: t.boolean,
|
||||
can_eligible: t.boolean,
|
||||
can_performance: t.boolean,
|
||||
can_add_server_from_invite: t.boolean,
|
||||
can_list_dashboard_perms: t.boolean,
|
||||
update_cmd: tNullable(t.string),
|
||||
export const zBotControlConfig = z.strictObject({
|
||||
can_use: z.boolean(),
|
||||
can_eligible: z.boolean(),
|
||||
can_performance: z.boolean(),
|
||||
can_add_server_from_invite: z.boolean(),
|
||||
can_list_dashboard_perms: z.boolean(),
|
||||
update_cmd: zBoundedCharacters(0, 2000).nullable(),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface BotControlPluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.output<typeof zBotControlConfig>;
|
||||
state: {
|
||||
archives: GuildArchives;
|
||||
allowedGuilds: AllowedGuilds;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue