diff options
author | 2022-08-12 19:54:46 +0200 | |
---|---|---|
committer | 2022-08-12 19:54:46 +0200 | |
commit | d22c3b0c257f5daf5b401988a35ab9ce981a2341 (patch) | |
tree | 0a661c927c37b52197326d1c05e211daf9bd19e5 /subprojects/frontend/src/xtext/xtextServiceResults.ts | |
parent | fix(language): rule parsing test (diff) | |
download | refinery-d22c3b0c257f5daf5b401988a35ab9ce981a2341.tar.gz refinery-d22c3b0c257f5daf5b401988a35ab9ce981a2341.tar.zst refinery-d22c3b0c257f5daf5b401988a35ab9ce981a2341.zip |
refactor(frontend): move from Webpack to Vite
Also overhaulds the building and linting for frontend assets.
Diffstat (limited to 'subprojects/frontend/src/xtext/xtextServiceResults.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/xtextServiceResults.ts | 92 |
1 files changed, 50 insertions, 42 deletions
diff --git a/subprojects/frontend/src/xtext/xtextServiceResults.ts b/subprojects/frontend/src/xtext/xtextServiceResults.ts index 8b0dbbfb..4cfb9c33 100644 --- a/subprojects/frontend/src/xtext/xtextServiceResults.ts +++ b/subprojects/frontend/src/xtext/xtextServiceResults.ts | |||
@@ -1,112 +1,120 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-redeclare -- Declare types with their companion objects */ | ||
2 | |||
1 | import { z } from 'zod'; | 3 | import { z } from 'zod'; |
2 | 4 | ||
3 | export const pongResult = z.object({ | 5 | export const PongResult = z.object({ |
4 | pong: z.string().min(1), | 6 | pong: z.string().min(1), |
5 | }); | 7 | }); |
6 | 8 | ||
7 | export type PongResult = z.infer<typeof pongResult>; | 9 | export type PongResult = z.infer<typeof PongResult>; |
8 | 10 | ||
9 | export const documentStateResult = z.object({ | 11 | export const DocumentStateResult = z.object({ |
10 | stateId: z.string().min(1), | 12 | stateId: z.string().min(1), |
11 | }); | 13 | }); |
12 | 14 | ||
13 | export type DocumentStateResult = z.infer<typeof documentStateResult>; | 15 | export type DocumentStateResult = z.infer<typeof DocumentStateResult>; |
14 | 16 | ||
15 | export const conflict = z.enum(['invalidStateId', 'canceled']); | 17 | export const Conflict = z.enum(['invalidStateId', 'canceled']); |
16 | 18 | ||
17 | export type Conflict = z.infer<typeof conflict>; | 19 | export type Conflict = z.infer<typeof Conflict>; |
18 | 20 | ||
19 | export const serviceConflictResult = z.object({ | 21 | export const ServiceConflictResult = z.object({ |
20 | conflict, | 22 | conflict: Conflict, |
21 | }); | 23 | }); |
22 | 24 | ||
23 | export type ServiceConflictResult = z.infer<typeof serviceConflictResult>; | 25 | export type ServiceConflictResult = z.infer<typeof ServiceConflictResult>; |
24 | 26 | ||
25 | export function isConflictResult(result: unknown, conflictType: Conflict): boolean { | 27 | export function isConflictResult( |
26 | const parsedConflictResult = serviceConflictResult.safeParse(result); | 28 | result: unknown, |
27 | return parsedConflictResult.success && parsedConflictResult.data.conflict === conflictType; | 29 | conflictType: Conflict, |
30 | ): boolean { | ||
31 | const parsedConflictResult = ServiceConflictResult.safeParse(result); | ||
32 | return ( | ||
33 | parsedConflictResult.success && | ||
34 | parsedConflictResult.data.conflict === conflictType | ||
35 | ); | ||
28 | } | 36 | } |
29 | 37 | ||
30 | export const severity = z.enum(['error', 'warning', 'info', 'ignore']); | 38 | export const Severity = z.enum(['error', 'warning', 'info', 'ignore']); |
31 | 39 | ||
32 | export type Severity = z.infer<typeof severity>; | 40 | export type Severity = z.infer<typeof Severity>; |
33 | 41 | ||
34 | export const issue = z.object({ | 42 | export const Issue = z.object({ |
35 | description: z.string().min(1), | 43 | description: z.string().min(1), |
36 | severity, | 44 | severity: Severity, |
37 | line: z.number().int(), | 45 | line: z.number().int(), |
38 | column: z.number().int().nonnegative(), | 46 | column: z.number().int().nonnegative(), |
39 | offset: z.number().int().nonnegative(), | 47 | offset: z.number().int().nonnegative(), |
40 | length: z.number().int().nonnegative(), | 48 | length: z.number().int().nonnegative(), |
41 | }); | 49 | }); |
42 | 50 | ||
43 | export type Issue = z.infer<typeof issue>; | 51 | export type Issue = z.infer<typeof Issue>; |
44 | 52 | ||
45 | export const validationResult = z.object({ | 53 | export const ValidationResult = z.object({ |
46 | issues: issue.array(), | 54 | issues: Issue.array(), |
47 | }); | 55 | }); |
48 | 56 | ||
49 | export type ValidationResult = z.infer<typeof validationResult>; | 57 | export type ValidationResult = z.infer<typeof ValidationResult>; |
50 | 58 | ||
51 | export const replaceRegion = z.object({ | 59 | export const ReplaceRegion = z.object({ |
52 | offset: z.number().int().nonnegative(), | 60 | offset: z.number().int().nonnegative(), |
53 | length: z.number().int().nonnegative(), | 61 | length: z.number().int().nonnegative(), |
54 | text: z.string(), | 62 | text: z.string(), |
55 | }); | 63 | }); |
56 | 64 | ||
57 | export type ReplaceRegion = z.infer<typeof replaceRegion>; | 65 | export type ReplaceRegion = z.infer<typeof ReplaceRegion>; |
58 | 66 | ||
59 | export const textRegion = z.object({ | 67 | export const TextRegion = z.object({ |
60 | offset: z.number().int().nonnegative(), | 68 | offset: z.number().int().nonnegative(), |
61 | length: z.number().int().nonnegative(), | 69 | length: z.number().int().nonnegative(), |
62 | }); | 70 | }); |
63 | 71 | ||
64 | export type TextRegion = z.infer<typeof textRegion>; | 72 | export type TextRegion = z.infer<typeof TextRegion>; |
65 | 73 | ||
66 | export const contentAssistEntry = z.object({ | 74 | export const ContentAssistEntry = z.object({ |
67 | prefix: z.string(), | 75 | prefix: z.string(), |
68 | proposal: z.string().min(1), | 76 | proposal: z.string().min(1), |
69 | label: z.string().optional(), | 77 | label: z.string().optional(), |
70 | description: z.string().min(1).optional(), | 78 | description: z.string().min(1).optional(), |
71 | documentation: z.string().min(1).optional(), | 79 | documentation: z.string().min(1).optional(), |
72 | escapePosition: z.number().int().nonnegative().optional(), | 80 | escapePosition: z.number().int().nonnegative().optional(), |
73 | textReplacements: replaceRegion.array(), | 81 | textReplacements: ReplaceRegion.array(), |
74 | editPositions: textRegion.array(), | 82 | editPositions: TextRegion.array(), |
75 | kind: z.string().min(1), | 83 | kind: z.string().min(1), |
76 | }); | 84 | }); |
77 | 85 | ||
78 | export type ContentAssistEntry = z.infer<typeof contentAssistEntry>; | 86 | export type ContentAssistEntry = z.infer<typeof ContentAssistEntry>; |
79 | 87 | ||
80 | export const contentAssistResult = documentStateResult.extend({ | 88 | export const ContentAssistResult = DocumentStateResult.extend({ |
81 | entries: contentAssistEntry.array(), | 89 | entries: ContentAssistEntry.array(), |
82 | }); | 90 | }); |
83 | 91 | ||
84 | export type ContentAssistResult = z.infer<typeof contentAssistResult>; | 92 | export type ContentAssistResult = z.infer<typeof ContentAssistResult>; |
85 | 93 | ||
86 | export const highlightingRegion = z.object({ | 94 | export const HighlightingRegion = z.object({ |
87 | offset: z.number().int().nonnegative(), | 95 | offset: z.number().int().nonnegative(), |
88 | length: z.number().int().nonnegative(), | 96 | length: z.number().int().nonnegative(), |
89 | styleClasses: z.string().min(1).array(), | 97 | styleClasses: z.string().min(1).array(), |
90 | }); | 98 | }); |
91 | 99 | ||
92 | export type HighlightingRegion = z.infer<typeof highlightingRegion>; | 100 | export type HighlightingRegion = z.infer<typeof HighlightingRegion>; |
93 | 101 | ||
94 | export const highlightingResult = z.object({ | 102 | export const highlightingResult = z.object({ |
95 | regions: highlightingRegion.array(), | 103 | regions: HighlightingRegion.array(), |
96 | }); | 104 | }); |
97 | 105 | ||
98 | export type HighlightingResult = z.infer<typeof highlightingResult>; | 106 | export type HighlightingResult = z.infer<typeof highlightingResult>; |
99 | 107 | ||
100 | export const occurrencesResult = documentStateResult.extend({ | 108 | export const OccurrencesResult = DocumentStateResult.extend({ |
101 | writeRegions: textRegion.array(), | 109 | writeRegions: TextRegion.array(), |
102 | readRegions: textRegion.array(), | 110 | readRegions: TextRegion.array(), |
103 | }); | 111 | }); |
104 | 112 | ||
105 | export type OccurrencesResult = z.infer<typeof occurrencesResult>; | 113 | export type OccurrencesResult = z.infer<typeof OccurrencesResult>; |
106 | 114 | ||
107 | export const formattingResult = documentStateResult.extend({ | 115 | export const FormattingResult = DocumentStateResult.extend({ |
108 | formattedText: z.string(), | 116 | formattedText: z.string(), |
109 | replaceRegion: textRegion, | 117 | replaceRegion: TextRegion, |
110 | }); | 118 | }); |
111 | 119 | ||
112 | export type FormattingResult = z.infer<typeof formattingResult>; | 120 | export type FormattingResult = z.infer<typeof FormattingResult>; |