diff options
Diffstat (limited to 'subprojects/frontend/src/persistence/compressionMessages.tsx')
-rw-r--r-- | subprojects/frontend/src/persistence/compressionMessages.tsx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/subprojects/frontend/src/persistence/compressionMessages.tsx b/subprojects/frontend/src/persistence/compressionMessages.tsx new file mode 100644 index 00000000..37c6e8cd --- /dev/null +++ b/subprojects/frontend/src/persistence/compressionMessages.tsx | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | |||
7 | import { z } from 'zod'; | ||
8 | |||
9 | /* eslint-disable @typescript-eslint/no-redeclare -- Declare types with their companion objects */ | ||
10 | |||
11 | export const CompressRequest = z.object({ | ||
12 | request: z.literal('compress'), | ||
13 | text: z.string(), | ||
14 | }); | ||
15 | |||
16 | export type CompressRequest = z.infer<typeof CompressRequest>; | ||
17 | |||
18 | export const DecompressRequest = z.object({ | ||
19 | request: z.literal('decompress'), | ||
20 | compressedText: z.string(), | ||
21 | }); | ||
22 | |||
23 | export type DecompressRequest = z.infer<typeof DecompressRequest>; | ||
24 | |||
25 | export const CompressorRequest = z.union([CompressRequest, DecompressRequest]); | ||
26 | |||
27 | export type CompressorRequest = z.infer<typeof CompressorRequest>; | ||
28 | |||
29 | export const CompressResponse = z.object({ | ||
30 | response: z.literal('compressed'), | ||
31 | compressedText: z.string(), | ||
32 | }); | ||
33 | |||
34 | export type CompressResponse = z.infer<typeof CompressResponse>; | ||
35 | |||
36 | export const DecompressResponse = z.object({ | ||
37 | response: z.literal('decompressed'), | ||
38 | text: z.string(), | ||
39 | }); | ||
40 | |||
41 | export type DecompressResponse = z.infer<typeof DecompressResponse>; | ||
42 | |||
43 | export const ErrorResponse = z.object({ | ||
44 | response: z.literal('error'), | ||
45 | message: z.string(), | ||
46 | }); | ||
47 | |||
48 | export type ErrorResponse = z.infer<typeof ErrorResponse>; | ||
49 | |||
50 | export const CompressorResponse = z.union([ | ||
51 | CompressResponse, | ||
52 | DecompressResponse, | ||
53 | ErrorResponse, | ||
54 | ]); | ||
55 | |||
56 | export type CompressorResponse = z.infer<typeof CompressorResponse>; | ||