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,6 @@ import { onGuildEvent } from "../../data/GuildEvents";
|
|||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildScheduledPosts } from "../../data/GuildScheduledPosts";
|
||||
import { makeIoTsConfigParser } from "../../pluginUtils";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
import { TimeAndDatePlugin } from "../TimeAndDate/TimeAndDatePlugin";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
|
@ -14,7 +13,7 @@ import { PostEmbedCmd } from "./commands/PostEmbedCmd";
|
|||
import { ScheduledPostsDeleteCmd } from "./commands/ScheduledPostsDeleteCmd";
|
||||
import { ScheduledPostsListCmd } from "./commands/ScheduledPostsListCmd";
|
||||
import { ScheduledPostsShowCmd } from "./commands/ScheduledPostsShowCmd";
|
||||
import { ConfigSchema, PostPluginType } from "./types";
|
||||
import { PostPluginType, zPostConfig } from "./types";
|
||||
import { postScheduledPost } from "./util/postScheduledPost";
|
||||
|
||||
const defaultOptions: PluginOptions<PostPluginType> = {
|
||||
|
@ -36,11 +35,11 @@ export const PostPlugin = zeppelinGuildPlugin<PostPluginType>()({
|
|||
showInDocs: true,
|
||||
info: {
|
||||
prettyName: "Post",
|
||||
configSchema: ConfigSchema,
|
||||
configSchema: zPostConfig,
|
||||
},
|
||||
|
||||
dependencies: () => [TimeAndDatePlugin, LogsPlugin],
|
||||
configParser: makeIoTsConfigParser(ConfigSchema),
|
||||
configParser: (input) => zPostConfig.parse(input),
|
||||
defaultOptions,
|
||||
|
||||
// prettier-ignore
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import * as t from "io-ts";
|
||||
import { BasePluginType, guildPluginMessageCommand } from "knub";
|
||||
import z from "zod";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildScheduledPosts } from "../../data/GuildScheduledPosts";
|
||||
|
||||
export const ConfigSchema = t.type({
|
||||
can_post: t.boolean,
|
||||
export const zPostConfig = z.strictObject({
|
||||
can_post: z.boolean(),
|
||||
});
|
||||
export type TConfigSchema = t.TypeOf<typeof ConfigSchema>;
|
||||
|
||||
export interface PostPluginType extends BasePluginType {
|
||||
config: TConfigSchema;
|
||||
config: z.infer<typeof zPostConfig>;
|
||||
state: {
|
||||
savedMessages: GuildSavedMessages;
|
||||
scheduledPosts: GuildScheduledPosts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue