mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-16 02:55:03 +00:00
fix: more config type fixes
This commit is contained in:
parent
951092d6c0
commit
a82221d42a
2 changed files with 18 additions and 3 deletions
|
@ -10,13 +10,23 @@ import { zColor } from "../../utils/zColor.js";
|
|||
|
||||
const caseKeys = keys(CaseNameToType) as U.ListOf<keyof typeof CaseNameToType>;
|
||||
|
||||
const caseColorsTypeMap = caseKeys.reduce((map, key) => {
|
||||
map[key] = zColor;
|
||||
return map;
|
||||
}, {} as Record<typeof caseKeys[number], typeof zColor>);
|
||||
|
||||
const caseIconsTypeMap = caseKeys.reduce((map, key) => {
|
||||
map[key] = zBoundedCharacters(0, 100);
|
||||
return map;
|
||||
}, {} as Record<typeof caseKeys[number], z.ZodString>);
|
||||
|
||||
export const zCasesConfig = z.strictObject({
|
||||
log_automatic_actions: z.boolean().default(true),
|
||||
case_log_channel: zSnowflake.nullable().default(null),
|
||||
show_relative_times: z.boolean().default(true),
|
||||
relative_time_cutoff: zDelayString.default("1w"),
|
||||
case_colors: z.record(z.enum(caseKeys), zColor).nullable().default(null),
|
||||
case_icons: z.record(z.enum(caseKeys), zBoundedCharacters(0, 100)).nullable().default(null),
|
||||
case_colors: z.strictObject(caseColorsTypeMap).partial().nullable().default(null),
|
||||
case_icons: z.strictObject(caseIconsTypeMap).partial().nullable().default(null),
|
||||
});
|
||||
|
||||
export interface CasesPluginType extends BasePluginType {
|
||||
|
|
|
@ -9,9 +9,14 @@ import { defaultDateFormats } from "./defaultDateFormats.js";
|
|||
|
||||
const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf<keyof typeof defaultDateFormats>);
|
||||
|
||||
const dateFormatTypeMap = keys(defaultDateFormats).reduce((map, key) => {
|
||||
map[key] = z.string().default(defaultDateFormats[key]);
|
||||
return map;
|
||||
}, {} as Record<keyof typeof defaultDateFormats, z.ZodDefault<z.ZodString>>);
|
||||
|
||||
export const zTimeAndDateConfig = z.strictObject({
|
||||
timezone: zValidTimezone(z.string()).default("Etc/UTC"),
|
||||
date_formats: z.record(zDateFormatKeys, z.string()).nullable().default(defaultDateFormats),
|
||||
date_formats: z.strictObject(dateFormatTypeMap).default(defaultDateFormats),
|
||||
can_set_timezone: z.boolean().default(false),
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue