-
Notifications
You must be signed in to change notification settings - Fork 80
/
schemas.ts
78 lines (71 loc) · 1.67 KB
/
schemas.ts
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
73
74
75
76
77
78
import { z } from "zod";
export const configSchema = z.object({
shopifyShop: z.string(),
publicShopifyAccessToken: z.string(),
privateShopifyAccessToken: z.string(),
apiVersion: z.string(),
});
export const MoneyV2Result = z.object({
amount: z.string(),
currencyCode: z.string(),
});
export const ImageResult = z
.object({
altText: z.string().nullable().optional(),
url: z.string(),
width: z.number().positive().int(),
height: z.number().positive().int(),
})
.nullable();
export const CartItemResult = z.object({
id: z.string(),
cost: z.object({
amountPerQuantity: MoneyV2Result,
subtotalAmount: MoneyV2Result,
totalAmount: MoneyV2Result,
}),
merchandise: z.object({
id: z.string(),
title: z.string(),
product: z.object({
title: z.string(),
handle: z.string(),
}),
image: ImageResult.nullable(),
}),
quantity: z.number().positive().int(),
});
export const CartResult = z
.object({
id: z.string(),
cost: z.object({
subtotalAmount: MoneyV2Result,
}),
checkoutUrl: z.string(),
totalQuantity: z.number().int(),
lines: z.object({
nodes: z.array(CartItemResult),
}),
})
.nullable();
export const VariantResult = z.object({
id: z.string(),
title: z.string(),
availableForSale: z.boolean(),
quantityAvailable: z.number().int(),
price: MoneyV2Result,
});
export const ProductResult = z
.object({
id: z.string(),
title: z.string(),
handle: z.string(),
images: z.object({
nodes: z.array(ImageResult),
}),
variants: z.object({
nodes: z.array(VariantResult),
}),
featuredImage: ImageResult.nullable(),
})
.nullable();