-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmi.ts
More file actions
52 lines (44 loc) · 1.29 KB
/
mi.ts
File metadata and controls
52 lines (44 loc) · 1.29 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
import z from "zod";
import { makeDocumentSchema } from "./json-api";
export const PostMIRequestResourceSchema = z
.object({
type: z.literal("ManagementInformation"),
attributes: z
.object({
lineItem: z.string(),
timestamp: z.string(),
quantity: z.number(),
specificationId: z.string().optional(),
groupId: z.string().optional(),
stockRemaining: z.number().optional(),
})
.strict(),
})
.strict();
export const PostMIResponseResourceSchema = z
.object({
id: z.string(),
...PostMIRequestResourceSchema.shape,
})
.strict();
export const PostMIRequestSchema = makeDocumentSchema(
PostMIRequestResourceSchema,
);
export const PostMIResponseSchema = makeDocumentSchema(
PostMIResponseResourceSchema,
);
export type PostMIRequest = z.infer<typeof PostMIRequestSchema>;
export type PostMIResponse = z.infer<typeof PostMIResponseSchema>;
export type IncomingMI = PostMIRequest["data"]["attributes"] & {
supplierId: string;
};
export const GetMIResponseResourceSchema = z
.object({
id: z.string(),
...PostMIRequestResourceSchema.shape,
})
.strict();
export const GetMIResponseSchema = makeDocumentSchema(
GetMIResponseResourceSchema,
);
export type GetMIResponse = z.infer<typeof GetMIResponseSchema>;