Skip to content

Commit a82221d

Browse files
committed
fix: more config type fixes
1 parent 951092d commit a82221d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

backend/src/plugins/Cases/types.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@ import { zColor } from "../../utils/zColor.js";
1010

1111
const caseKeys = keys(CaseNameToType) as U.ListOf<keyof typeof CaseNameToType>;
1212

13+
const caseColorsTypeMap = caseKeys.reduce((map, key) => {
14+
map[key] = zColor;
15+
return map;
16+
}, {} as Record<typeof caseKeys[number], typeof zColor>);
17+
18+
const caseIconsTypeMap = caseKeys.reduce((map, key) => {
19+
map[key] = zBoundedCharacters(0, 100);
20+
return map;
21+
}, {} as Record<typeof caseKeys[number], z.ZodString>);
22+
1323
export const zCasesConfig = z.strictObject({
1424
log_automatic_actions: z.boolean().default(true),
1525
case_log_channel: zSnowflake.nullable().default(null),
1626
show_relative_times: z.boolean().default(true),
1727
relative_time_cutoff: zDelayString.default("1w"),
18-
case_colors: z.record(z.enum(caseKeys), zColor).nullable().default(null),
19-
case_icons: z.record(z.enum(caseKeys), zBoundedCharacters(0, 100)).nullable().default(null),
28+
case_colors: z.strictObject(caseColorsTypeMap).partial().nullable().default(null),
29+
case_icons: z.strictObject(caseIconsTypeMap).partial().nullable().default(null),
2030
});
2131

2232
export interface CasesPluginType extends BasePluginType {

backend/src/plugins/TimeAndDate/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ import { defaultDateFormats } from "./defaultDateFormats.js";
99

1010
const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf<keyof typeof defaultDateFormats>);
1111

12+
const dateFormatTypeMap = keys(defaultDateFormats).reduce((map, key) => {
13+
map[key] = z.string().default(defaultDateFormats[key]);
14+
return map;
15+
}, {} as Record<keyof typeof defaultDateFormats, z.ZodDefault<z.ZodString>>);
16+
1217
export const zTimeAndDateConfig = z.strictObject({
1318
timezone: zValidTimezone(z.string()).default("Etc/UTC"),
14-
date_formats: z.record(zDateFormatKeys, z.string()).nullable().default(defaultDateFormats),
19+
date_formats: z.strictObject(dateFormatTypeMap).default(defaultDateFormats),
1520
can_set_timezone: z.boolean().default(false),
1621
});
1722

0 commit comments

Comments
 (0)