aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/src/schemas/ServiceAction.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-02-27 01:52:55 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-03-06 18:56:47 +0100
commit098d6f9bb1fd26f2d192db497992ab95b258ce55 (patch)
tree22905f87e6ad53032b6ff39bb3af274df2f6287c /packages/shared/src/schemas/ServiceAction.ts
parentrefactor: Shared model type factories (diff)
downloadsophie-098d6f9bb1fd26f2d192db497992ab95b258ce55.tar.gz
sophie-098d6f9bb1fd26f2d192db497992ab95b258ce55.tar.zst
sophie-098d6f9bb1fd26f2d192db497992ab95b258ce55.zip
feat: Location bar actions
The buttons and the text field in the location bar shall now affect the BrowserView of the loaded service. Some error handling is still needed, e.g., when loading a web page fails due to a DNS error. Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/shared/src/schemas/ServiceAction.ts')
-rw-r--r--packages/shared/src/schemas/ServiceAction.ts51
1 files changed, 51 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..a4a7049
--- /dev/null
+++ b/packages/shared/src/schemas/ServiceAction.ts
@@ -0,0 +1,51 @@
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
21import { z } from 'zod';
22
23export const ServiceAction = /* @__PURE__ */ (() =>
24 z.union([
25 z.object({
26 action: z.literal('back'),
27 }),
28 z.object({
29 action: z.literal('forward'),
30 }),
31 z.object({
32 action: z.literal('reload'),
33 ignoreCache: z.boolean(),
34 }),
35 z.object({
36 action: z.literal('stop'),
37 }),
38 z.object({
39 action: z.literal('go-home'),
40 }),
41 z.object({
42 action: z.literal('go'),
43 url: z.string(),
44 }),
45 ]))();
46
47/*
48 eslint-disable-next-line @typescript-eslint/no-redeclare --
49 Intentionally naming the type the same as the schema definition.
50*/
51export type ServiceAction = z.infer<typeof ServiceAction>;