aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/language-web/src/main/js/xtext/xtextMessages.ts
blob: c4305fcf3c58b3bdaca1167f5375f8ba7823b339 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { z } from 'zod';

export const xtextWebRequest = z.object({
  id: z.string().nonempty(),
  request: z.unknown(),
});

export type XtextWebRequest = z.infer<typeof xtextWebRequest>;

export const xtextWebOkResponse = z.object({
  id: z.string().nonempty(),
  response: z.unknown(),
});

export type XtextWebOkResponse = z.infer<typeof xtextWebOkResponse>;

export const xtextWebErrorKind = z.enum(['request', 'server']);

export type XtextWebErrorKind = z.infer<typeof xtextWebErrorKind>;

export const xtextWebErrorResponse = z.object({
  id: z.string().nonempty(),
  error: xtextWebErrorKind,
  message: z.string(),
});

export type XtextWebErrorResponse = z.infer<typeof xtextWebErrorResponse>;

export const xtextWebPushService = z.enum(['highlight', 'validate']);

export type XtextWebPushService = z.infer<typeof xtextWebPushService>;

export const xtextWebPushMessage = z.object({
  resource: z.string().nonempty(),
  stateId: z.string().nonempty(),
  service: xtextWebPushService,
  push: z.unknown(),
});

export type XtextWebPushMessage = z.infer<typeof xtextWebPushMessage>;