aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/src/schemas.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared/src/schemas.ts')
-rw-r--r--packages/shared/src/schemas.ts44
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
21import { z } from 'zod'; 21import { z } from 'zod';
22 22
23const setSelectedServiceId = z.object({ 23const 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
28export const browserViewBounds = z.object({ 28export 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
35export 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*/
39export type BrowserViewBounds = z.infer<typeof BrowserViewBounds>;
36 40
37const setBrowserViewBoundsAction = z.object({ 41const 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
42export const themeSource = z.enum(['system', 'light', 'dark']); 46export const ThemeSource = z.enum(['system', 'light', 'dark']);
43 47
44export 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*/
52export type ThemeSource = z.infer<typeof ThemeSource>;
45 53
46const setThemeSourceAction = z.object({ 54const 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
51const reloadAllServicesAction = z.object({ 59const ReloadAllServicesAction = z.object({
52 action: z.literal('reload-all-services'), 60 action: z.literal('reload-all-services'),
53}); 61});
54 62
55export const action = z.union([ 63export const Action = z.union([
56 setSelectedServiceId, 64 SetSelectedServiceId,
57 setBrowserViewBoundsAction, 65 SetBrowserViewBoundsAction,
58 setThemeSourceAction, 66 SetThemeSourceAction,
59 reloadAllServicesAction, 67 ReloadAllServicesAction,
60]); 68]);
61 69
62export 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*/
74export type Action = z.infer<typeof Action>;