|
1 | 1 | import { z } from 'zod'; |
2 | 2 | import { colorSchema } from './colorSchema'; |
3 | 3 | import { hexColorSchema } from './hexColorSchema'; |
| 4 | +import { backgroundScaledImageSchema } from '~/schemas/common/backgroundScaledImageSchema'; |
| 5 | +import { trelloIdSchema } from '~/schemas/common/trelloIdSchema'; |
4 | 6 |
|
5 | | -export const prefsSchema = z.object({ |
6 | | - permissionLevel: z.enum(['private']), |
7 | | - hideVotes: z.boolean(), |
8 | | - voting: z.enum(['disabled']), |
9 | | - comments: z.enum(['members']), |
10 | | - invitations: z.enum(['members']), |
11 | | - selfJoin: z.boolean(), |
12 | | - cardCovers: z.boolean(), |
13 | | - showCompleteStatus: z.boolean(), |
14 | | - cardCounts: z.boolean(), |
15 | | - isTemplate: z.boolean(), |
16 | | - cardAging: z.enum(['regular']), |
17 | | - calendarFeedEnabled: z.boolean(), |
18 | | - hiddenPluginBoardButtons: z.array(z.unknown()), |
19 | | - switcherViews: z.array(z.object({ |
20 | | - viewType: z.enum(['Board', 'Table', 'Calendar', 'Dashboard', 'Timeline', 'Map']), |
21 | | - enabled: z.boolean(), |
22 | | - }).strict()), |
23 | | - background: colorSchema, |
24 | | - backgroundColor: hexColorSchema, |
25 | | - backgroundDarkColor: hexColorSchema.nullable(), |
26 | | - backgroundImage: z.unknown().nullable(), |
27 | | - backgroundDarkImage: z.unknown().nullable(), |
28 | | - backgroundImageScaled: z.unknown().nullable(), |
29 | | - backgroundTile: z.boolean(), |
30 | | - backgroundBrightness: z.enum(['dark']), |
31 | | - sharedSourceUrl: z.string().url().nullable(), |
32 | | - backgroundBottomColor: hexColorSchema, |
33 | | - backgroundTopColor: hexColorSchema, |
34 | | - canBePublic: z.boolean(), |
35 | | - canBeEnterprise: z.boolean(), |
36 | | - canBeOrg: z.boolean(), |
37 | | - canBePrivate: z.boolean(), |
38 | | - canInvite: z.boolean(), |
39 | | -}).strict(); |
| 7 | +export const prefsSchema = z |
| 8 | + .object({ |
| 9 | + background: z.union([colorSchema, trelloIdSchema]), // todo use discriminatedUnion |
| 10 | + backgroundBottomColor: hexColorSchema, |
| 11 | + backgroundBrightness: z.enum(['light', 'dark']), |
| 12 | + backgroundColor: hexColorSchema.nullable(), |
| 13 | + backgroundDarkColor: hexColorSchema.nullable(), |
| 14 | + backgroundDarkImage: z.unknown().nullable(), |
| 15 | + backgroundImage: z.string().url().nullable(), |
| 16 | + backgroundImageScaled: z.array(backgroundScaledImageSchema).nullable(), |
| 17 | + backgroundTile: z.boolean(), |
| 18 | + backgroundTopColor: hexColorSchema, |
| 19 | + calendarFeedEnabled: z.boolean(), |
| 20 | + canBeEnterprise: z.boolean(), |
| 21 | + canBeOrg: z.boolean(), |
| 22 | + canBePrivate: z.boolean(), |
| 23 | + canBePublic: z.boolean(), |
| 24 | + canInvite: z.boolean(), |
| 25 | + cardAging: z.enum(['regular']), |
| 26 | + cardCounts: z.boolean(), |
| 27 | + cardCovers: z.boolean(), |
| 28 | + comments: z.enum(['members']), |
| 29 | + hiddenPluginBoardButtons: z.array(z.unknown()), |
| 30 | + hideVotes: z.boolean(), |
| 31 | + invitations: z.enum(['members']), |
| 32 | + isTemplate: z.boolean(), |
| 33 | + permissionLevel: z.enum(['private', 'org', 'board']), |
| 34 | + selfJoin: z.boolean(), |
| 35 | + sharedSourceUrl: z.string().url().nullable(), |
| 36 | + showCompleteStatus: z.boolean(), |
| 37 | + switcherViews: z.array( |
| 38 | + z |
| 39 | + .object({ |
| 40 | + viewType: z.enum(['Board', 'Table', 'Calendar', 'Dashboard', 'Timeline', 'Map']), |
| 41 | + enabled: z.boolean(), |
| 42 | + }) |
| 43 | + .strict(), |
| 44 | + ), |
| 45 | + voting: z.enum(['disabled', 'members']), |
| 46 | + }) |
| 47 | + .strict(); |
40 | 48 |
|
41 | 49 | export type Prefs = z.infer<typeof prefsSchema>; |
0 commit comments