refactor: replace io-ts with zod

This commit is contained in:
Dragory 2024-01-14 14:25:42 +00:00
parent fafaefa1fb
commit 28692962bc
No known key found for this signature in database
161 changed files with 1450 additions and 2105 deletions

View file

@ -1,5 +1,5 @@
import { GuildRoleQueue } from "../../data/GuildRoleQueue";
import { makeIoTsConfigParser, mapToPublicFn } from "../../pluginUtils";
import { mapToPublicFn } from "../../pluginUtils";
import { LogsPlugin } from "../Logs/LogsPlugin";
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
import { addPriorityRole } from "./functions/addPriorityRole";
@ -7,14 +7,14 @@ import { addRole } from "./functions/addRole";
import { removePriorityRole } from "./functions/removePriorityRole";
import { removeRole } from "./functions/removeRole";
import { runRoleAssignmentLoop } from "./functions/runRoleAssignmentLoop";
import { ConfigSchema, RoleManagerPluginType } from "./types";
import { RoleManagerPluginType, zRoleManagerConfig } from "./types";
export const RoleManagerPlugin = zeppelinGuildPlugin<RoleManagerPluginType>()({
name: "role_manager",
showInDocs: false,
dependencies: () => [LogsPlugin],
configParser: makeIoTsConfigParser(ConfigSchema),
configParser: (input) => zRoleManagerConfig.parse(input),
public: {
addRole: mapToPublicFn(addRole),

View file

@ -1,12 +1,11 @@
import * as t from "io-ts";
import { BasePluginType } from "knub";
import z from "zod";
import { GuildRoleQueue } from "../../data/GuildRoleQueue";
export const ConfigSchema = t.type({});
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
export const zRoleManagerConfig = z.strictObject({});
export interface RoleManagerPluginType extends BasePluginType {
config: TConfigSchema;
config: z.infer<typeof zRoleManagerConfig>;
state: {
roleQueue: GuildRoleQueue;
roleAssignmentLoopRunning: boolean;