diff options
Diffstat (limited to 'packages/shared/src/schemas/ServiceAction.ts')
-rw-r--r-- | packages/shared/src/schemas/ServiceAction.ts | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/packages/shared/src/schemas/ServiceAction.ts b/packages/shared/src/schemas/ServiceAction.ts new file mode 100644 index 0000000..744c7cf --- /dev/null +++ b/packages/shared/src/schemas/ServiceAction.ts | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2021-2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | import { z } from 'zod'; | ||
22 | |||
23 | import { BrowserViewBounds } from './BrowserViewBounds.js'; | ||
24 | |||
25 | export const ServiceAction = /* @__PURE__ */ (() => | ||
26 | z.union([ | ||
27 | z.object({ | ||
28 | action: z.literal('set-browser-view-bounds'), | ||
29 | browserViewBounds: BrowserViewBounds, | ||
30 | }), | ||
31 | z.object({ | ||
32 | action: z.literal('back'), | ||
33 | }), | ||
34 | z.object({ | ||
35 | action: z.literal('forward'), | ||
36 | }), | ||
37 | z.object({ | ||
38 | action: z.literal('reload'), | ||
39 | ignoreCache: z.boolean(), | ||
40 | }), | ||
41 | z.object({ | ||
42 | action: z.literal('stop'), | ||
43 | }), | ||
44 | z.object({ | ||
45 | action: z.literal('go-home'), | ||
46 | }), | ||
47 | z.object({ | ||
48 | action: z.literal('go'), | ||
49 | url: z.string(), | ||
50 | }), | ||
51 | z.object({ | ||
52 | action: z.literal('temporarily-trust-current-certificate'), | ||
53 | fingerprint: z.string(), | ||
54 | }), | ||
55 | z.object({ | ||
56 | action: z.literal('open-current-url-in-external-browser'), | ||
57 | }), | ||
58 | z.object({ | ||
59 | action: z.literal('follow-popup'), | ||
60 | url: z.string(), | ||
61 | }), | ||
62 | z.object({ | ||
63 | action: z.literal('open-popup-in-external-browser'), | ||
64 | url: z.string(), | ||
65 | }), | ||
66 | z.object({ | ||
67 | action: z.literal('open-all-popups-in-external-browser'), | ||
68 | }), | ||
69 | z.object({ | ||
70 | action: z.literal('dismiss-popup'), | ||
71 | url: z.string(), | ||
72 | }), | ||
73 | z.object({ | ||
74 | action: z.literal('dismiss-all-popups'), | ||
75 | }), | ||
76 | z.object({ | ||
77 | action: z.literal('download-certificate'), | ||
78 | fingerprint: z.string().nonempty(), | ||
79 | }), | ||
80 | ]))(); | ||
81 | |||
82 | /* | ||
83 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | ||
84 | Intentionally naming the type the same as the schema definition. | ||
85 | */ | ||
86 | export type ServiceAction = z.infer<typeof ServiceAction>; | ||