-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathletters.ts
More file actions
72 lines (63 loc) · 2.12 KB
/
letters.ts
File metadata and controls
72 lines (63 loc) · 2.12 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { z } from 'zod';
import { makeCollectionSchema, makeDocumentSchema } from './json-api';
export type LetterDto = {
id: string,
status: LetterStatus,
supplierId: string,
specificationId?: string,
groupId?: string,
reasonCode?: number,
reasonText?: string
};
export const LetterStatusSchema = z.enum([
'PENDING',
'ACCEPTED',
'REJECTED',
'PRINTED',
'ENCLOSED',
'CANCELLED',
'DISPATCHED',
'FAILED',
'RETURNED',
'FORWARDED',
'DELIVERED'
]);
export const PatchLetterRequestResourceSchema = z.object({
id: z.string(),
type: z.literal('Letter'),
attributes: z.object({
status: LetterStatusSchema,
reasonCode: z.number().optional(),
reasonText: z.string().optional(),
}).strict()
}).strict();
export const GetLetterResponseResourceSchema = z.object({
id: z.string(),
type: z.literal('Letter'),
attributes: z.object({
status: LetterStatusSchema,
specificationId: z.string(),
groupId: z.string().optional(),
reasonCode: z.number().optional(),
reasonText: z.string().optional(),
}).strict()
}).strict();
export const GetLettersResponseResourceSchema = z.object({
id: z.string(),
type: z.literal('Letter'),
attributes: z.object({
status: LetterStatusSchema,
specificationId: z.string(),
groupId: z.string().optional(),
}).strict()
}).strict();
export const PatchLetterResponseResourceSchema = GetLetterResponseResourceSchema;
export type LetterStatus = z.infer<typeof LetterStatusSchema>;
export const PatchLetterRequestSchema = makeDocumentSchema(PatchLetterRequestResourceSchema);
export const GetLetterResponseSchema = makeDocumentSchema(GetLetterResponseResourceSchema);
export const GetLettersResponseSchema = makeCollectionSchema(GetLettersResponseResourceSchema);
export const PatchLetterResponseSchema = makeDocumentSchema(PatchLetterResponseResourceSchema);
export type PatchLetterRequest = z.infer<typeof PatchLetterRequestSchema>;
export type GetLetterResponse = z.infer<typeof GetLetterResponseSchema>;
export type GetLettersResponse = z.infer<typeof GetLettersResponseSchema>;
export type PatchLetterResponse = z.infer<typeof PatchLetterResponseSchema>;