diff options
Diffstat (limited to 'packages/shared/src/schemas.ts')
-rw-r--r-- | packages/shared/src/schemas.ts | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/packages/shared/src/schemas.ts b/packages/shared/src/schemas.ts index 7fb9717..edf3741 100644 --- a/packages/shared/src/schemas.ts +++ b/packages/shared/src/schemas.ts | |||
@@ -20,43 +20,55 @@ | |||
20 | 20 | ||
21 | import { z } from 'zod'; | 21 | import { z } from 'zod'; |
22 | 22 | ||
23 | const setSelectedServiceId = z.object({ | 23 | const SetSelectedServiceId = z.object({ |
24 | action: z.literal('set-selected-service-id'), | 24 | action: z.literal('set-selected-service-id'), |
25 | serviceId: z.string(), | 25 | serviceId: z.string(), |
26 | }); | 26 | }); |
27 | 27 | ||
28 | export const browserViewBounds = z.object({ | 28 | export const BrowserViewBounds = z.object({ |
29 | x: z.number().int().nonnegative(), | 29 | x: z.number().int().nonnegative(), |
30 | y: z.number().int().nonnegative(), | 30 | y: z.number().int().nonnegative(), |
31 | width: z.number().int().nonnegative(), | 31 | width: z.number().int().nonnegative(), |
32 | height: z.number().int().nonnegative(), | 32 | height: z.number().int().nonnegative(), |
33 | }); | 33 | }); |
34 | 34 | ||
35 | export type BrowserViewBounds = z.infer<typeof browserViewBounds>; | 35 | /* |
36 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
37 | Intentionally naming the type the same as the schema definition. | ||
38 | */ | ||
39 | export type BrowserViewBounds = z.infer<typeof BrowserViewBounds>; | ||
36 | 40 | ||
37 | const setBrowserViewBoundsAction = z.object({ | 41 | const SetBrowserViewBoundsAction = z.object({ |
38 | action: z.literal('set-browser-view-bounds'), | 42 | action: z.literal('set-browser-view-bounds'), |
39 | browserViewBounds, | 43 | browserViewBounds: BrowserViewBounds, |
40 | }); | 44 | }); |
41 | 45 | ||
42 | export const themeSource = z.enum(['system', 'light', 'dark']); | 46 | export const ThemeSource = z.enum(['system', 'light', 'dark']); |
43 | 47 | ||
44 | export type ThemeSource = z.infer<typeof themeSource>; | 48 | /* |
49 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
50 | Intentionally naming the type the same as the schema definition. | ||
51 | */ | ||
52 | export type ThemeSource = z.infer<typeof ThemeSource>; | ||
45 | 53 | ||
46 | const setThemeSourceAction = z.object({ | 54 | const SetThemeSourceAction = z.object({ |
47 | action: z.literal('set-theme-source'), | 55 | action: z.literal('set-theme-source'), |
48 | themeSource, | 56 | themeSource: ThemeSource, |
49 | }); | 57 | }); |
50 | 58 | ||
51 | const reloadAllServicesAction = z.object({ | 59 | const ReloadAllServicesAction = z.object({ |
52 | action: z.literal('reload-all-services'), | 60 | action: z.literal('reload-all-services'), |
53 | }); | 61 | }); |
54 | 62 | ||
55 | export const action = z.union([ | 63 | export const Action = z.union([ |
56 | setSelectedServiceId, | 64 | SetSelectedServiceId, |
57 | setBrowserViewBoundsAction, | 65 | SetBrowserViewBoundsAction, |
58 | setThemeSourceAction, | 66 | SetThemeSourceAction, |
59 | reloadAllServicesAction, | 67 | ReloadAllServicesAction, |
60 | ]); | 68 | ]); |
61 | 69 | ||
62 | export type Action = z.infer<typeof action>; | 70 | /* |
71 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
72 | Intentionally naming the type the same as the schema definition. | ||
73 | */ | ||
74 | export type Action = z.infer<typeof Action>; | ||