File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import z from "zod" ;
22import { makeDocumentSchema } from "./json-api" ;
33
4- export const GetMIResponseResourceSchema = z
5- . object ( {
6- id : z . string ( ) ,
7- type : z . literal ( "ManagementInformation" ) ,
8- attributes : z
9- . object ( {
10- lineItem : z . string ( ) ,
11- timestamp : z . string ( ) ,
12- quantity : z . string ( ) ,
13- specificationId : z . string ( ) . optional ( ) ,
14- groupId : z . string ( ) . optional ( ) ,
15- stockRemaining : z . number ( ) . optional ( ) ,
16- } )
17- . strict ( ) ,
18- } )
19- . strict ( ) ;
20-
21- export const GetMIResponseSchema = makeDocumentSchema (
22- GetMIResponseResourceSchema ,
23- ) ;
24-
25- export type GetMIResponse = z . infer < typeof GetMIResponseSchema > ;
26-
274export const PostMIRequestResourceSchema = z
285 . object ( {
296 type : z . literal ( "ManagementInformation" ) ,
@@ -60,3 +37,16 @@ export type PostMIResponse = z.infer<typeof PostMIResponseSchema>;
6037export type IncomingMI = PostMIRequest [ "data" ] [ "attributes" ] & {
6138 supplierId : string ;
6239} ;
40+
41+ export const GetMIResponseResourceSchema = z
42+ . object ( {
43+ id : z . string ( ) ,
44+ ...PostMIRequestResourceSchema . shape ,
45+ } )
46+ . strict ( ) ;
47+
48+ export const GetMIResponseSchema = makeDocumentSchema (
49+ GetMIResponseResourceSchema ,
50+ ) ;
51+
52+ export type GetMIResponse = z . infer < typeof GetMIResponseSchema > ;
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ export function mapToPostMIResponse(mi: MIBase): PostMIResponse {
3838export function mapToGetMIResponse ( mi : MIBase ) : GetMIResponse {
3939 return GetMIResponseResourceSchema . parse ( {
4040 data : {
41- id : mi . id ,
4241 type : "ManagementInformation" ,
4342 attributes : {
4443 lineItem : mi . lineItem ,
@@ -48,6 +47,7 @@ export function mapToGetMIResponse(mi: MIBase): GetMIResponse {
4847 groupId : mi . groupId ,
4948 stockRemaining : mi . stockRemaining ,
5049 } ,
50+ id : mi . id ,
5151 } ,
5252 } ) ;
5353}
You can’t perform that action at this time.
0 commit comments