@brytdesigns/shopify-ajax-cart-api 1.0.43 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effect/api/CartAdd.js +36 -9
- package/dist/effect/api/CartAdd.js.map +1 -1
- package/dist/effect/api/CartChange.js +32 -9
- package/dist/effect/api/CartChange.js.map +1 -1
- package/dist/effect/api/CartClear.js +26 -9
- package/dist/effect/api/CartClear.js.map +1 -1
- package/dist/effect/api/CartGet.js +35 -9
- package/dist/effect/api/CartGet.js.map +1 -1
- package/dist/effect/api/CartUpdate.js +31 -9
- package/dist/effect/api/CartUpdate.js.map +1 -1
- package/dist/effect/index.d.ts +1746 -899
- package/dist/effect/index.js +13 -13
- package/dist/effect/index.js.map +1 -1
- package/dist/effect/schema.js +970 -1059
- package/dist/effect/schema.js.map +1 -1
- package/dist/main/effect/api/CartAdd.js +36 -9
- package/dist/main/effect/api/CartAdd.js.map +1 -1
- package/dist/main/effect/api/CartChange.js +32 -9
- package/dist/main/effect/api/CartChange.js.map +1 -1
- package/dist/main/effect/api/CartClear.js +26 -9
- package/dist/main/effect/api/CartClear.js.map +1 -1
- package/dist/main/effect/api/CartGet.js +35 -9
- package/dist/main/effect/api/CartGet.js.map +1 -1
- package/dist/main/effect/api/CartUpdate.js +31 -9
- package/dist/main/effect/api/CartUpdate.js.map +1 -1
- package/dist/main/effect/index.js +13 -13
- package/dist/main/effect/index.js.map +1 -1
- package/dist/main/effect/schema.js +970 -1059
- package/dist/main/effect/schema.js.map +1 -1
- package/dist/main/index.d.ts +586 -1808
- package/dist/main/index.js +123 -235
- package/dist/main/index.js.map +1 -1
- package/package.json +11 -13
- package/dist/esm/index.js +0 -19525
- package/dist/esm/index.js.map +0 -1
|
@@ -1,1062 +1,973 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
})
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
currency: "USD",
|
|
768
|
-
items_subtotal_price: 99.99,
|
|
769
|
-
cart_level_discount_applications: []
|
|
770
|
-
}
|
|
771
|
-
]
|
|
772
|
-
});
|
|
773
|
-
const makeCartTransformSchema = (schema) => Schema.transform(schema, Cart, {
|
|
774
|
-
decode: (cart) => ({
|
|
775
|
-
...cart,
|
|
776
|
-
attributes_array: cart.attributes,
|
|
777
|
-
private_attributes: cart.attributes,
|
|
778
|
-
private_attributes_array: cart.attributes,
|
|
779
|
-
public_attributes: cart.attributes,
|
|
780
|
-
public_attributes_array: cart.attributes
|
|
781
|
-
}),
|
|
782
|
-
encode: (cart) => pipe(
|
|
783
|
-
Record.remove("attributes_array")(cart),
|
|
784
|
-
Record.remove("private_attributes"),
|
|
785
|
-
Record.remove("private_attributes_array"),
|
|
786
|
-
Record.remove("public_attributes"),
|
|
787
|
-
Record.remove("public_attributes_array")
|
|
788
|
-
)
|
|
789
|
-
});
|
|
790
|
-
const CartOutput = makeCartTransformSchema(BaseCart);
|
|
791
|
-
const makeCartSchema = (sections) => {
|
|
792
|
-
if (sections) {
|
|
793
|
-
return makeCartTransformSchema(
|
|
794
|
-
Schema.extend(
|
|
795
|
-
BaseCart,
|
|
796
|
-
Schema.Struct({
|
|
797
|
-
sections: Schema.optionalWith(
|
|
798
|
-
Schema.NullOr(Ajax.Sections.makeResponseSchema(sections)),
|
|
799
|
-
{ default: () => null }
|
|
800
|
-
)
|
|
801
|
-
})
|
|
802
|
-
)
|
|
803
|
-
);
|
|
804
|
-
}
|
|
805
|
-
return makeCartTransformSchema(
|
|
806
|
-
Schema.extend(
|
|
807
|
-
BaseCart,
|
|
808
|
-
Schema.Struct({
|
|
809
|
-
sections: Schema.optionalWith(Schema.Null, { default: () => null })
|
|
810
|
-
})
|
|
811
|
-
)
|
|
812
|
-
);
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import { Ajax, Resource } from "@brytdesigns/shopify-utils/effect";
|
|
4
|
+
import { identity, pipe } from "effect";
|
|
5
|
+
import * as Arr from "effect/Array";
|
|
6
|
+
import * as Rec from "effect/Record";
|
|
7
|
+
import * as SchemaGetter from "effect/SchemaGetter";
|
|
8
|
+
//#region src/effect/schema.ts
|
|
9
|
+
var BaseAttributeValue = Schema.Union([
|
|
10
|
+
Schema.Null,
|
|
11
|
+
Schema.String,
|
|
12
|
+
Schema.Boolean,
|
|
13
|
+
Schema.Number
|
|
14
|
+
]).annotate({
|
|
15
|
+
title: "base_attribute_value",
|
|
16
|
+
identifier: "BaseAttributeValue",
|
|
17
|
+
description: "An attribute value that can be either a string, a boolean, or a number",
|
|
18
|
+
examples: [
|
|
19
|
+
null,
|
|
20
|
+
"hello",
|
|
21
|
+
true,
|
|
22
|
+
123131
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
var AttributesArray = Schema.Array(Schema.Struct({
|
|
26
|
+
key: Schema.String,
|
|
27
|
+
value: BaseAttributeValue
|
|
28
|
+
})).annotate({
|
|
29
|
+
title: "base_attributes_array",
|
|
30
|
+
identifier: "BaseAttributesArray",
|
|
31
|
+
description: "An array of attribute key-value pairs",
|
|
32
|
+
examples: [[{
|
|
33
|
+
key: "size",
|
|
34
|
+
value: "medium"
|
|
35
|
+
}], [{
|
|
36
|
+
key: "color",
|
|
37
|
+
value: "red"
|
|
38
|
+
}]]
|
|
39
|
+
});
|
|
40
|
+
var BaseAttributes = Schema.Record(Schema.String, BaseAttributeValue).annotate({
|
|
41
|
+
title: "base_attributes",
|
|
42
|
+
identifier: "BaseAttributes",
|
|
43
|
+
description: "An object containing attribute key-value pairs",
|
|
44
|
+
examples: [{
|
|
45
|
+
key: "size",
|
|
46
|
+
value: "medium"
|
|
47
|
+
}, {
|
|
48
|
+
key: "color",
|
|
49
|
+
value: "red"
|
|
50
|
+
}]
|
|
51
|
+
});
|
|
52
|
+
var BaseAttributesArray = BaseAttributes.pipe(Schema.decodeTo(AttributesArray, {
|
|
53
|
+
decode: SchemaGetter.transform((record) => Rec.toEntries(record).map(([key, value]) => ({
|
|
54
|
+
key,
|
|
55
|
+
value
|
|
56
|
+
}))),
|
|
57
|
+
encode: SchemaGetter.transform((array) => Rec.fromEntries(pipe(array, Arr.map(({ key, value }) => [key, value]))))
|
|
58
|
+
})).annotate({
|
|
59
|
+
title: "base_attributes_array",
|
|
60
|
+
identifier: "BaseAttributesArray",
|
|
61
|
+
description: "An array of attribute key-value pairs",
|
|
62
|
+
examples: [[{
|
|
63
|
+
key: "size",
|
|
64
|
+
value: "medium"
|
|
65
|
+
}], [{
|
|
66
|
+
key: "color",
|
|
67
|
+
value: "red"
|
|
68
|
+
}]]
|
|
69
|
+
});
|
|
70
|
+
var BasePrivateAttributes = BaseAttributes.pipe(Schema.decodeTo(BaseAttributes, {
|
|
71
|
+
decode: SchemaGetter.transform(Rec.filter((_, key) => key.startsWith("_"))),
|
|
72
|
+
encode: SchemaGetter.transform(identity)
|
|
73
|
+
})).annotate({
|
|
74
|
+
title: "base_private_attributes",
|
|
75
|
+
identifier: "BasePrivateAttributes",
|
|
76
|
+
description: "An object containing private(_) attribute key-value pairs",
|
|
77
|
+
examples: [{ _key: "private_attribute" }]
|
|
78
|
+
});
|
|
79
|
+
var BasePublicAttributes = BaseAttributes.pipe(Schema.decodeTo(BaseAttributes, {
|
|
80
|
+
decode: SchemaGetter.transform(Rec.filter((_, key) => !key.startsWith("_"))),
|
|
81
|
+
encode: SchemaGetter.transform(identity)
|
|
82
|
+
})).annotate({
|
|
83
|
+
title: "base_public_attributes",
|
|
84
|
+
identifier: "BasePublicAttributes",
|
|
85
|
+
description: "An object containing public attribute key-value pairs",
|
|
86
|
+
examples: [{ key: "public_attribute" }]
|
|
87
|
+
});
|
|
88
|
+
var BasePrivateAttributesArray = BasePrivateAttributes.pipe(Schema.decodeTo(AttributesArray, {
|
|
89
|
+
decode: SchemaGetter.transform((record) => Rec.toEntries(record).map(([key, value]) => ({
|
|
90
|
+
key,
|
|
91
|
+
value
|
|
92
|
+
}))),
|
|
93
|
+
encode: SchemaGetter.transform((array) => Rec.fromEntries(pipe(array, Arr.map(({ key, value }) => [key, value]))))
|
|
94
|
+
})).annotate({
|
|
95
|
+
title: "base_private_attributes_array",
|
|
96
|
+
identifier: "BasePrivateAttributesArray",
|
|
97
|
+
description: "An array of private(_)_attribute key-value pairs",
|
|
98
|
+
examples: [[{
|
|
99
|
+
key: "_private_key",
|
|
100
|
+
value: "private_value"
|
|
101
|
+
}]]
|
|
102
|
+
});
|
|
103
|
+
var BasePublicAttributesArray = BasePublicAttributes.pipe(Schema.decodeTo(AttributesArray, {
|
|
104
|
+
decode: SchemaGetter.transform((record) => Rec.toEntries(record).map(([key, value]) => ({
|
|
105
|
+
key,
|
|
106
|
+
value
|
|
107
|
+
}))),
|
|
108
|
+
encode: SchemaGetter.transform((array) => Rec.fromEntries(pipe(array, Arr.map(({ key, value }) => [key, value]))))
|
|
109
|
+
})).annotate({
|
|
110
|
+
title: "base_public_attributes_array",
|
|
111
|
+
identifier: "BasePublicAttributesArray",
|
|
112
|
+
description: "An array of public attribute key-value pairs",
|
|
113
|
+
examples: [[{
|
|
114
|
+
key: "public_key",
|
|
115
|
+
value: "public_value"
|
|
116
|
+
}]]
|
|
117
|
+
});
|
|
118
|
+
BaseAttributes.pipe(Schema.decodeTo(Schema.Struct({
|
|
119
|
+
private: Schema.Struct({
|
|
120
|
+
array: BasePrivateAttributesArray,
|
|
121
|
+
record: BasePrivateAttributes
|
|
122
|
+
}),
|
|
123
|
+
public: Schema.Struct({
|
|
124
|
+
array: BasePublicAttributesArray,
|
|
125
|
+
record: BasePublicAttributes
|
|
126
|
+
})
|
|
127
|
+
}), {
|
|
128
|
+
decode: SchemaGetter.transform((attributes) => ({
|
|
129
|
+
private: {
|
|
130
|
+
array: attributes,
|
|
131
|
+
record: attributes
|
|
132
|
+
},
|
|
133
|
+
public: {
|
|
134
|
+
array: attributes,
|
|
135
|
+
record: attributes
|
|
136
|
+
}
|
|
137
|
+
})),
|
|
138
|
+
encode: SchemaGetter.transform((attributes) => ({
|
|
139
|
+
...attributes.private.record,
|
|
140
|
+
...attributes.public.record
|
|
141
|
+
}))
|
|
142
|
+
})).annotate({
|
|
143
|
+
title: "attributes",
|
|
144
|
+
identifier: "Attributes",
|
|
145
|
+
description: "An object containing private and public properties which contain the array and record of private and public attribute key-value pairs",
|
|
146
|
+
examples: [{
|
|
147
|
+
private: {
|
|
148
|
+
array: [{
|
|
149
|
+
key: "_size",
|
|
150
|
+
value: "medium"
|
|
151
|
+
}],
|
|
152
|
+
record: { _size: "medium" }
|
|
153
|
+
},
|
|
154
|
+
public: {
|
|
155
|
+
array: [{
|
|
156
|
+
key: "public_size",
|
|
157
|
+
value: "large"
|
|
158
|
+
}],
|
|
159
|
+
record: { public_size: "large" }
|
|
160
|
+
}
|
|
161
|
+
}]
|
|
162
|
+
});
|
|
163
|
+
var DiscountApplication = Schema.Struct({
|
|
164
|
+
target_selection: Schema.Literals([
|
|
165
|
+
"all",
|
|
166
|
+
"entitled",
|
|
167
|
+
"explicit"
|
|
168
|
+
]),
|
|
169
|
+
target_type: Schema.Literals(["line_item", "shipping_line"]),
|
|
170
|
+
title: Schema.NonEmptyString,
|
|
171
|
+
total_allocated_amount: Schema.Number,
|
|
172
|
+
type: Schema.Literals([
|
|
173
|
+
"",
|
|
174
|
+
"automatic",
|
|
175
|
+
"discount_code",
|
|
176
|
+
"manual",
|
|
177
|
+
"script"
|
|
178
|
+
]),
|
|
179
|
+
value: Schema.Union([Schema.Number, Schema.NumberFromString]),
|
|
180
|
+
value_type: Schema.Literals(["fixed_amount", "percentage"]),
|
|
181
|
+
description: Schema.NullOr(Schema.String)
|
|
182
|
+
}).annotate({
|
|
183
|
+
title: "discount_application",
|
|
184
|
+
identifier: "DiscountApplication",
|
|
185
|
+
description: "An object representing a discount application",
|
|
186
|
+
examples: [{
|
|
187
|
+
target_selection: "all",
|
|
188
|
+
target_type: "line_item",
|
|
189
|
+
title: "10% off all line items",
|
|
190
|
+
total_allocated_amount: 10,
|
|
191
|
+
type: "automatic",
|
|
192
|
+
value_type: "percentage",
|
|
193
|
+
value: 10,
|
|
194
|
+
description: null
|
|
195
|
+
}]
|
|
196
|
+
});
|
|
197
|
+
var Discount = Schema.Struct({
|
|
198
|
+
amount: Schema.Number,
|
|
199
|
+
title: Schema.String
|
|
200
|
+
}).annotate({
|
|
201
|
+
title: "discount",
|
|
202
|
+
identifier: "Discount",
|
|
203
|
+
description: "An object representing a discount",
|
|
204
|
+
examples: [{
|
|
205
|
+
amount: 10,
|
|
206
|
+
title: "10% off"
|
|
207
|
+
}]
|
|
208
|
+
});
|
|
209
|
+
var CurrencyCode = Schema.String.annotate({
|
|
210
|
+
title: "currency_code",
|
|
211
|
+
identifier: "CurrencyCode",
|
|
212
|
+
description: "An ISO 4217 currency code",
|
|
213
|
+
examples: [
|
|
214
|
+
"USD",
|
|
215
|
+
"EUR",
|
|
216
|
+
"GBP"
|
|
217
|
+
]
|
|
218
|
+
});
|
|
219
|
+
var Image = Schema.Struct({
|
|
220
|
+
aspect_ratio: Schema.NullOr(Schema.Number),
|
|
221
|
+
alt: Schema.NullOr(Schema.String),
|
|
222
|
+
height: Schema.NullOr(Schema.Number),
|
|
223
|
+
url: Schema.NullOr(Schema.String),
|
|
224
|
+
width: Schema.NullOr(Schema.Number)
|
|
225
|
+
}).annotate({
|
|
226
|
+
title: "image",
|
|
227
|
+
identifier: "Image",
|
|
228
|
+
description: "An object representing an image",
|
|
229
|
+
examples: [{
|
|
230
|
+
url: "https://example.com/image.jpg",
|
|
231
|
+
alt: "Example image",
|
|
232
|
+
height: 100,
|
|
233
|
+
width: 100,
|
|
234
|
+
aspect_ratio: 1
|
|
235
|
+
}, {
|
|
236
|
+
url: null,
|
|
237
|
+
alt: null,
|
|
238
|
+
height: null,
|
|
239
|
+
width: null,
|
|
240
|
+
aspect_ratio: null
|
|
241
|
+
}]
|
|
242
|
+
});
|
|
243
|
+
var OptionWithValue = Schema.Struct({
|
|
244
|
+
name: Schema.String,
|
|
245
|
+
value: Schema.String
|
|
246
|
+
}).annotate({
|
|
247
|
+
title: "option_with_value",
|
|
248
|
+
identifier: "OptionWithValue",
|
|
249
|
+
description: "An object representing an option with a value",
|
|
250
|
+
examples: [{
|
|
251
|
+
name: "Size",
|
|
252
|
+
value: "Large"
|
|
253
|
+
}]
|
|
254
|
+
});
|
|
255
|
+
var QuantityRule = Schema.Struct({
|
|
256
|
+
min: Schema.Number,
|
|
257
|
+
max: Schema.NullOr(Schema.Number),
|
|
258
|
+
increment: Schema.Number
|
|
259
|
+
}).annotate({
|
|
260
|
+
title: "quantity_rule",
|
|
261
|
+
identifier: "QuantityRule",
|
|
262
|
+
description: "An object representing a quantity rule",
|
|
263
|
+
examples: [{
|
|
264
|
+
min: 1,
|
|
265
|
+
max: 5,
|
|
266
|
+
increment: 1
|
|
267
|
+
}]
|
|
268
|
+
});
|
|
269
|
+
var SellingPlanAllocationPriceAdjustment = Schema.Struct({
|
|
270
|
+
position: Schema.Number,
|
|
271
|
+
price: Schema.Number
|
|
272
|
+
}).annotate({
|
|
273
|
+
title: "selling_plan_allocation_price_adjustment",
|
|
274
|
+
identifier: "SellingPlanAllocationPriceAdjustment",
|
|
275
|
+
description: "An object representing a selling plan allocation price adjustment",
|
|
276
|
+
examples: [{
|
|
277
|
+
position: 1,
|
|
278
|
+
price: 10
|
|
279
|
+
}]
|
|
280
|
+
});
|
|
281
|
+
var SellingPlanPriceAdjustment = Schema.Struct({
|
|
282
|
+
order_count: Schema.NullOr(Schema.Number),
|
|
283
|
+
position: Schema.Number,
|
|
284
|
+
value: Schema.Union([Schema.Number, Schema.String]),
|
|
285
|
+
value_type: Schema.Literals([
|
|
286
|
+
"percentage",
|
|
287
|
+
"fixed_amount",
|
|
288
|
+
"price"
|
|
289
|
+
])
|
|
290
|
+
}).annotate({
|
|
291
|
+
title: "selling_plan_price_adjustment",
|
|
292
|
+
identifier: "SellingPlanPriceAdjustment",
|
|
293
|
+
description: "An object representing a selling plan price adjustment",
|
|
294
|
+
examples: [{
|
|
295
|
+
order_count: null,
|
|
296
|
+
position: 1,
|
|
297
|
+
value: 10,
|
|
298
|
+
value_type: "percentage"
|
|
299
|
+
}]
|
|
300
|
+
});
|
|
301
|
+
var SellingPlanOption = Schema.Struct({
|
|
302
|
+
name: Schema.String,
|
|
303
|
+
position: Schema.Number,
|
|
304
|
+
value: Schema.String
|
|
305
|
+
}).annotate({
|
|
306
|
+
title: "selling_plan_option",
|
|
307
|
+
identifier: "SellingPlanOption",
|
|
308
|
+
description: "An object representing a selling plan option",
|
|
309
|
+
examples: [{
|
|
310
|
+
name: "Size",
|
|
311
|
+
position: 1,
|
|
312
|
+
value: "Large"
|
|
313
|
+
}]
|
|
314
|
+
});
|
|
315
|
+
var SellingPlan = Schema.Struct({
|
|
316
|
+
id: Resource.ID,
|
|
317
|
+
name: Schema.String,
|
|
318
|
+
description: Schema.NullOr(Schema.String),
|
|
319
|
+
options: Schema.Array(SellingPlanOption),
|
|
320
|
+
recurring_deliveries: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(false))),
|
|
321
|
+
fixed_selling_plan: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(false))),
|
|
322
|
+
price_adjustments: Schema.Array(SellingPlanPriceAdjustment)
|
|
323
|
+
}).annotate({
|
|
324
|
+
title: "selling_plan",
|
|
325
|
+
identifier: "SellingPlan",
|
|
326
|
+
description: "An object representing a selling plan",
|
|
327
|
+
examples: [{
|
|
328
|
+
id: "sp-123",
|
|
329
|
+
name: "Standard Plan",
|
|
330
|
+
description: "A basic selling plan",
|
|
331
|
+
options: [{
|
|
332
|
+
name: "Size",
|
|
333
|
+
position: 1,
|
|
334
|
+
value: "Large"
|
|
335
|
+
}],
|
|
336
|
+
recurring_deliveries: false,
|
|
337
|
+
fixed_selling_plan: false,
|
|
338
|
+
price_adjustments: []
|
|
339
|
+
}]
|
|
340
|
+
});
|
|
341
|
+
var SellingPlanAllocation = Schema.Struct({
|
|
342
|
+
price_adjustments: Schema.Array(SellingPlanAllocationPriceAdjustment),
|
|
343
|
+
price: Schema.Number,
|
|
344
|
+
compare_at_price: Schema.Number,
|
|
345
|
+
per_delivery_price: Schema.Number,
|
|
346
|
+
selling_plan: SellingPlan
|
|
347
|
+
}).annotate({
|
|
348
|
+
title: "selling_plan_allocation",
|
|
349
|
+
identifier: "SellingPlanAllocation",
|
|
350
|
+
description: "An object representing a selling plan allocation",
|
|
351
|
+
examples: [{
|
|
352
|
+
price_adjustments: [],
|
|
353
|
+
price: 10,
|
|
354
|
+
compare_at_price: 15,
|
|
355
|
+
per_delivery_price: 10,
|
|
356
|
+
selling_plan: {
|
|
357
|
+
id: "sp-123",
|
|
358
|
+
name: "Standard Plan",
|
|
359
|
+
description: "A basic selling plan",
|
|
360
|
+
options: [{
|
|
361
|
+
name: "Size",
|
|
362
|
+
position: 1,
|
|
363
|
+
value: "Large"
|
|
364
|
+
}],
|
|
365
|
+
recurring_deliveries: false,
|
|
366
|
+
fixed_selling_plan: false,
|
|
367
|
+
price_adjustments: []
|
|
368
|
+
}
|
|
369
|
+
}]
|
|
370
|
+
});
|
|
371
|
+
var LineLevelDiscountAllocation = Schema.Struct({
|
|
372
|
+
amount: Schema.Number,
|
|
373
|
+
discount_application: DiscountApplication
|
|
374
|
+
}).annotate({
|
|
375
|
+
title: "line_level_discount_allocation",
|
|
376
|
+
identifier: "LineLevelDiscountAllocation",
|
|
377
|
+
description: "An object representing a line level discount allocation",
|
|
378
|
+
examples: [{
|
|
379
|
+
amount: 10,
|
|
380
|
+
discount_application: {
|
|
381
|
+
target_selection: "all",
|
|
382
|
+
target_type: "line_item",
|
|
383
|
+
title: "10% off all line items",
|
|
384
|
+
total_allocated_amount: 10,
|
|
385
|
+
type: "automatic",
|
|
386
|
+
value_type: "percentage",
|
|
387
|
+
value: 10,
|
|
388
|
+
description: null
|
|
389
|
+
}
|
|
390
|
+
}]
|
|
391
|
+
});
|
|
392
|
+
var CartLevelDiscountApplicationUpdate = Schema.Struct({ discount_application: DiscountApplication }).pipe(Schema.decodeTo(DiscountApplication, {
|
|
393
|
+
decode: SchemaGetter.transform((application) => application.discount_application),
|
|
394
|
+
encode: SchemaGetter.transform((discountApplication) => ({ discount_application: discountApplication }))
|
|
395
|
+
})).annotate({
|
|
396
|
+
title: "cart_level_discount_application",
|
|
397
|
+
identifier: "CartLevelDiscountApplication",
|
|
398
|
+
description: "An object representing a cart level discount application",
|
|
399
|
+
examples: [{
|
|
400
|
+
target_selection: "all",
|
|
401
|
+
target_type: "line_item",
|
|
402
|
+
title: "10% off all line items",
|
|
403
|
+
total_allocated_amount: 10,
|
|
404
|
+
type: "automatic",
|
|
405
|
+
value_type: "percentage",
|
|
406
|
+
value: 10,
|
|
407
|
+
description: null
|
|
408
|
+
}]
|
|
409
|
+
});
|
|
410
|
+
var CartLevelDiscountApplication = Schema.Union([DiscountApplication, CartLevelDiscountApplicationUpdate]).annotate({
|
|
411
|
+
title: "cart_level_discount_application",
|
|
412
|
+
identifier: "CartLevelDiscountApplication",
|
|
413
|
+
description: "An object representing a cart level discount application",
|
|
414
|
+
examples: [{
|
|
415
|
+
target_selection: "all",
|
|
416
|
+
target_type: "line_item",
|
|
417
|
+
title: "10% off all line items",
|
|
418
|
+
total_allocated_amount: 10,
|
|
419
|
+
type: "automatic",
|
|
420
|
+
value_type: "percentage",
|
|
421
|
+
value: 10,
|
|
422
|
+
description: null
|
|
423
|
+
}]
|
|
424
|
+
});
|
|
425
|
+
var UnitPriceMeasurement = Schema.Struct({
|
|
426
|
+
measured_type: Schema.Literals([
|
|
427
|
+
"volume",
|
|
428
|
+
"weight",
|
|
429
|
+
"dimension"
|
|
430
|
+
]),
|
|
431
|
+
quantity_unit: Schema.String,
|
|
432
|
+
quantity_value: Schema.Number,
|
|
433
|
+
reference_unit: Schema.String,
|
|
434
|
+
reference_value: Schema.Number
|
|
435
|
+
}).annotate({
|
|
436
|
+
title: "unit_price_measurement",
|
|
437
|
+
identifier: "UnitPriceMeasurement",
|
|
438
|
+
description: "An object representing a unit price measurement",
|
|
439
|
+
examples: [{
|
|
440
|
+
measured_type: "volume",
|
|
441
|
+
quantity_unit: "gallons",
|
|
442
|
+
quantity_value: 1,
|
|
443
|
+
reference_unit: "ounces",
|
|
444
|
+
reference_value: 128
|
|
445
|
+
}]
|
|
446
|
+
});
|
|
447
|
+
var VariantOptions = Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultType(Effect.succeed([]))).annotate({
|
|
448
|
+
title: "variant_options",
|
|
449
|
+
identifier: "VariantOptions",
|
|
450
|
+
description: "An array of strings representing variant options",
|
|
451
|
+
examples: [["Red", "Size 10"]]
|
|
452
|
+
});
|
|
453
|
+
var BaseLineItem = Schema.Struct({
|
|
454
|
+
id: Resource.ID,
|
|
455
|
+
properties: BaseAttributes,
|
|
456
|
+
quantity: Schema.Number,
|
|
457
|
+
variant_id: Resource.ID,
|
|
458
|
+
key: Schema.String,
|
|
459
|
+
title: Schema.String,
|
|
460
|
+
price: Schema.Number,
|
|
461
|
+
original_price: Schema.Number,
|
|
462
|
+
discounted_price: Schema.Number,
|
|
463
|
+
line_price: Schema.Number,
|
|
464
|
+
original_line_price: Schema.Number,
|
|
465
|
+
total_discount: Schema.Number,
|
|
466
|
+
discounts: Schema.Array(Discount).pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
467
|
+
sku: Schema.NullOr(Schema.String),
|
|
468
|
+
grams: Schema.Number,
|
|
469
|
+
vendor: Schema.String,
|
|
470
|
+
taxable: Schema.Boolean,
|
|
471
|
+
product_id: Resource.ID,
|
|
472
|
+
product_has_only_default_variant: Schema.Boolean,
|
|
473
|
+
gift_card: Schema.Boolean,
|
|
474
|
+
final_line_price: Schema.Number,
|
|
475
|
+
final_price: Schema.Number,
|
|
476
|
+
url: Schema.String,
|
|
477
|
+
featured_image: Image,
|
|
478
|
+
image: Schema.NullOr(Schema.String),
|
|
479
|
+
handle: Schema.String,
|
|
480
|
+
requires_shipping: Schema.Boolean,
|
|
481
|
+
product_type: Schema.NullOr(Schema.String),
|
|
482
|
+
product_title: Schema.String,
|
|
483
|
+
product_description: Schema.NullOr(Schema.String),
|
|
484
|
+
variant_title: Schema.NullOr(Schema.String),
|
|
485
|
+
variant_options: VariantOptions,
|
|
486
|
+
options_with_values: Schema.Array(OptionWithValue),
|
|
487
|
+
line_level_discount_allocations: Schema.Array(LineLevelDiscountAllocation),
|
|
488
|
+
line_level_total_discount: Schema.Number,
|
|
489
|
+
quantity_rule: Schema.optional(QuantityRule),
|
|
490
|
+
has_components: Schema.Boolean.pipe(Schema.withDecodingDefaultType(Effect.succeed(false))),
|
|
491
|
+
unit_price: Schema.optional(Schema.Number),
|
|
492
|
+
unit_price_measurement: Schema.optional(UnitPriceMeasurement),
|
|
493
|
+
selling_plan_allocation: Schema.NullOr(SellingPlanAllocation).pipe(Schema.withDecodingDefaultType(Effect.succeed(null)))
|
|
494
|
+
}).annotate({
|
|
495
|
+
identifier: "BaseLineItem",
|
|
496
|
+
title: "base_line_item",
|
|
497
|
+
description: "An object representing the base cart line item",
|
|
498
|
+
examples: [{
|
|
499
|
+
id: 103424255,
|
|
500
|
+
properties: {
|
|
501
|
+
Size: "Large",
|
|
502
|
+
_hidden: "value"
|
|
503
|
+
},
|
|
504
|
+
quantity: 1,
|
|
505
|
+
variant_id: 103424256,
|
|
506
|
+
key: "2klj234ljlkjsdlf:103424255",
|
|
507
|
+
title: "Black T-Shirt",
|
|
508
|
+
price: 29.99,
|
|
509
|
+
original_price: 39.99,
|
|
510
|
+
discounted_price: 29.99,
|
|
511
|
+
line_price: 29.99,
|
|
512
|
+
original_line_price: 39.99,
|
|
513
|
+
total_discount: 0,
|
|
514
|
+
discounts: [],
|
|
515
|
+
sku: "SKU-12345",
|
|
516
|
+
grams: 100,
|
|
517
|
+
vendor: "Vendor Name",
|
|
518
|
+
taxable: true,
|
|
519
|
+
product_id: 12345,
|
|
520
|
+
product_has_only_default_variant: true,
|
|
521
|
+
gift_card: false,
|
|
522
|
+
final_line_price: 29.99,
|
|
523
|
+
final_price: 29.99,
|
|
524
|
+
url: "https://example.com/products/black-t-shirt?variant=103424256",
|
|
525
|
+
featured_image: {
|
|
526
|
+
alt: "Black T-Shirt",
|
|
527
|
+
url: "https://example.com/black-t-shirt.jpg",
|
|
528
|
+
width: 600,
|
|
529
|
+
height: 400,
|
|
530
|
+
aspect_ratio: 1.5
|
|
531
|
+
},
|
|
532
|
+
image: "https://example.com/black-t-shirt.jpg",
|
|
533
|
+
handle: "black-t-shirt",
|
|
534
|
+
requires_shipping: true,
|
|
535
|
+
product_type: "t-shirt",
|
|
536
|
+
product_title: "Black T-Shirt",
|
|
537
|
+
product_description: "A stylish and comfortable t-shirt.",
|
|
538
|
+
variant_title: "Large",
|
|
539
|
+
variant_options: ["Large"],
|
|
540
|
+
options_with_values: [],
|
|
541
|
+
line_level_discount_allocations: [],
|
|
542
|
+
line_level_total_discount: 0,
|
|
543
|
+
quantity_rule: {
|
|
544
|
+
min: 1,
|
|
545
|
+
max: null,
|
|
546
|
+
increment: 1
|
|
547
|
+
},
|
|
548
|
+
has_components: false,
|
|
549
|
+
unit_price: 29.99,
|
|
550
|
+
unit_price_measurement: {
|
|
551
|
+
measured_type: "volume",
|
|
552
|
+
quantity_unit: "gallons",
|
|
553
|
+
quantity_value: 1,
|
|
554
|
+
reference_unit: "ounces",
|
|
555
|
+
reference_value: 128
|
|
556
|
+
},
|
|
557
|
+
selling_plan_allocation: null
|
|
558
|
+
}]
|
|
559
|
+
});
|
|
560
|
+
var LineItem = BaseLineItem.pipe(Schema.decodeTo(BaseLineItem.pipe(Schema.fieldsAssign({
|
|
561
|
+
properties_array: BaseAttributesArray.pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
562
|
+
private_properties: BasePrivateAttributes.pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),
|
|
563
|
+
private_properties_array: BasePrivateAttributesArray.pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
564
|
+
public_properties: BasePublicAttributes.pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),
|
|
565
|
+
public_properties_array: BasePublicAttributesArray.pipe(Schema.withDecodingDefaultType(Effect.succeed([])))
|
|
566
|
+
})), {
|
|
567
|
+
decode: SchemaGetter.transform((lineItem) => ({
|
|
568
|
+
...lineItem,
|
|
569
|
+
product: lineItem.handle,
|
|
570
|
+
properties_array: lineItem.properties,
|
|
571
|
+
private_properties: lineItem.properties,
|
|
572
|
+
private_properties_array: lineItem.properties,
|
|
573
|
+
public_properties: lineItem.properties,
|
|
574
|
+
public_properties_array: lineItem.properties
|
|
575
|
+
})),
|
|
576
|
+
encode: SchemaGetter.transform((lineItem) => pipe(Rec.remove("properties_array")(lineItem), Rec.remove("private_properties"), Rec.remove("private_properties_array"), Rec.remove("public_properties"), Rec.remove("public_properties_array")))
|
|
577
|
+
})).annotate({
|
|
578
|
+
identifier: "LineItem",
|
|
579
|
+
title: "line_item",
|
|
580
|
+
description: "An object representing a cart line item",
|
|
581
|
+
examples: [{
|
|
582
|
+
id: 103424255,
|
|
583
|
+
properties: {
|
|
584
|
+
Size: "Large",
|
|
585
|
+
_hidden: "value"
|
|
586
|
+
},
|
|
587
|
+
properties_array: [{
|
|
588
|
+
key: "Size",
|
|
589
|
+
value: "Large"
|
|
590
|
+
}, {
|
|
591
|
+
key: "_hidden",
|
|
592
|
+
value: "value"
|
|
593
|
+
}],
|
|
594
|
+
private_properties: { _hidden: "value" },
|
|
595
|
+
private_properties_array: [{
|
|
596
|
+
key: "_hidden",
|
|
597
|
+
value: "value"
|
|
598
|
+
}],
|
|
599
|
+
public_properties: { Size: "Large" },
|
|
600
|
+
public_properties_array: [{
|
|
601
|
+
key: "Size",
|
|
602
|
+
value: "Large"
|
|
603
|
+
}],
|
|
604
|
+
quantity: 1,
|
|
605
|
+
variant_id: 103424256,
|
|
606
|
+
key: "2klj234ljlkjsdlf:103424255",
|
|
607
|
+
title: "Black T-Shirt",
|
|
608
|
+
price: 29.99,
|
|
609
|
+
original_price: 39.99,
|
|
610
|
+
discounted_price: 29.99,
|
|
611
|
+
line_price: 29.99,
|
|
612
|
+
original_line_price: 39.99,
|
|
613
|
+
total_discount: 0,
|
|
614
|
+
discounts: [],
|
|
615
|
+
sku: "SKU-12345",
|
|
616
|
+
grams: 100,
|
|
617
|
+
vendor: "Vendor Name",
|
|
618
|
+
taxable: true,
|
|
619
|
+
product_id: 12345,
|
|
620
|
+
product_has_only_default_variant: true,
|
|
621
|
+
gift_card: false,
|
|
622
|
+
final_line_price: 29.99,
|
|
623
|
+
final_price: 29.99,
|
|
624
|
+
url: "https://example.com/products/black-t-shirt?variant=103424256",
|
|
625
|
+
featured_image: {
|
|
626
|
+
alt: "Black T-Shirt",
|
|
627
|
+
url: "https://example.com/black-t-shirt.jpg",
|
|
628
|
+
width: 600,
|
|
629
|
+
height: 400,
|
|
630
|
+
aspect_ratio: 1.5
|
|
631
|
+
},
|
|
632
|
+
image: "https://example.com/black-t-shirt.jpg",
|
|
633
|
+
handle: "black-t-shirt",
|
|
634
|
+
requires_shipping: true,
|
|
635
|
+
product_type: "t-shirt",
|
|
636
|
+
product_title: "Black T-Shirt",
|
|
637
|
+
product_description: "A stylish and comfortable t-shirt.",
|
|
638
|
+
variant_title: "Large",
|
|
639
|
+
variant_options: ["Large"],
|
|
640
|
+
options_with_values: [],
|
|
641
|
+
line_level_discount_allocations: [],
|
|
642
|
+
line_level_total_discount: 0,
|
|
643
|
+
quantity_rule: {
|
|
644
|
+
min: 1,
|
|
645
|
+
max: null,
|
|
646
|
+
increment: 1
|
|
647
|
+
},
|
|
648
|
+
has_components: false,
|
|
649
|
+
unit_price: 29.99,
|
|
650
|
+
unit_price_measurement: {
|
|
651
|
+
measured_type: "volume",
|
|
652
|
+
quantity_unit: "gallons",
|
|
653
|
+
quantity_value: 1,
|
|
654
|
+
reference_unit: "ounces",
|
|
655
|
+
reference_value: 128
|
|
656
|
+
},
|
|
657
|
+
selling_plan_allocation: null
|
|
658
|
+
}]
|
|
659
|
+
});
|
|
660
|
+
var BaseCart = Schema.Struct({
|
|
661
|
+
token: Schema.String,
|
|
662
|
+
note: Schema.NullOr(Schema.String),
|
|
663
|
+
attributes: BaseAttributes,
|
|
664
|
+
discounts: Schema.Array(Discount).pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
665
|
+
discount_codes: Schema.Array(Schema.Struct({
|
|
666
|
+
code: Schema.String,
|
|
667
|
+
applicable: Schema.Boolean
|
|
668
|
+
})).pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
669
|
+
original_total_price: Schema.Number,
|
|
670
|
+
total_price: Schema.Number,
|
|
671
|
+
total_discount: Schema.Number,
|
|
672
|
+
total_weight: Schema.Number,
|
|
673
|
+
item_count: Schema.Number,
|
|
674
|
+
items: Schema.Array(LineItem).annotate({ concurrency: "unbounded" }),
|
|
675
|
+
requires_shipping: Schema.Boolean,
|
|
676
|
+
currency: CurrencyCode,
|
|
677
|
+
items_subtotal_price: Schema.Number,
|
|
678
|
+
cart_level_discount_applications: Schema.Array(CartLevelDiscountApplication)
|
|
679
|
+
}).annotate({
|
|
680
|
+
identifier: "BaseCart",
|
|
681
|
+
title: "base_cart",
|
|
682
|
+
description: "An object representing the base cart",
|
|
683
|
+
examples: [{
|
|
684
|
+
token: "2lk34j2lk34kljl09sdfksldfk",
|
|
685
|
+
note: "This is a note",
|
|
686
|
+
attributes: {
|
|
687
|
+
public: "value",
|
|
688
|
+
_private: "value2"
|
|
689
|
+
},
|
|
690
|
+
discounts: [],
|
|
691
|
+
discount_codes: [],
|
|
692
|
+
original_total_price: 99.99,
|
|
693
|
+
total_price: 99.99,
|
|
694
|
+
total_discount: 0,
|
|
695
|
+
total_weight: 100,
|
|
696
|
+
item_count: 1,
|
|
697
|
+
items: [],
|
|
698
|
+
requires_shipping: true,
|
|
699
|
+
currency: "USD",
|
|
700
|
+
items_subtotal_price: 99.99,
|
|
701
|
+
cart_level_discount_applications: []
|
|
702
|
+
}]
|
|
703
|
+
});
|
|
704
|
+
var Cart = BaseCart.pipe(Schema.fieldsAssign({
|
|
705
|
+
attributes_array: BaseAttributesArray.pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
706
|
+
private_attributes: BasePrivateAttributes.pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),
|
|
707
|
+
private_attributes_array: BasePrivateAttributesArray.pipe(Schema.withDecodingDefaultType(Effect.succeed([]))),
|
|
708
|
+
public_attributes: BasePublicAttributes.pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),
|
|
709
|
+
public_attributes_array: BasePublicAttributesArray.pipe(Schema.withDecodingDefaultType(Effect.succeed([])))
|
|
710
|
+
})).annotate({
|
|
711
|
+
identifier: "Cart",
|
|
712
|
+
title: "cart",
|
|
713
|
+
description: "An object representing a cart",
|
|
714
|
+
examples: [{
|
|
715
|
+
token: "2lk34j2lk34kljl09sdfksldfk",
|
|
716
|
+
note: "This is a note",
|
|
717
|
+
attributes: {
|
|
718
|
+
public: "value",
|
|
719
|
+
_private: "value2"
|
|
720
|
+
},
|
|
721
|
+
attributes_array: [{
|
|
722
|
+
key: "public",
|
|
723
|
+
value: "value"
|
|
724
|
+
}, {
|
|
725
|
+
key: "_private",
|
|
726
|
+
value: "value2"
|
|
727
|
+
}],
|
|
728
|
+
private_attributes: { _private: "value2" },
|
|
729
|
+
private_attributes_array: [{
|
|
730
|
+
key: "_private",
|
|
731
|
+
value: "value2"
|
|
732
|
+
}],
|
|
733
|
+
public_attributes: { public: "value" },
|
|
734
|
+
public_attributes_array: [{
|
|
735
|
+
key: "public",
|
|
736
|
+
value: "value"
|
|
737
|
+
}],
|
|
738
|
+
discounts: [],
|
|
739
|
+
discount_codes: [],
|
|
740
|
+
original_total_price: 99.99,
|
|
741
|
+
total_price: 99.99,
|
|
742
|
+
total_discount: 0,
|
|
743
|
+
total_weight: 100,
|
|
744
|
+
item_count: 1,
|
|
745
|
+
items: [],
|
|
746
|
+
requires_shipping: true,
|
|
747
|
+
currency: "USD",
|
|
748
|
+
items_subtotal_price: 99.99,
|
|
749
|
+
cart_level_discount_applications: []
|
|
750
|
+
}]
|
|
751
|
+
});
|
|
752
|
+
var makeCartTransformSchema = (schema) => schema.pipe(Schema.decodeTo(Cart, {
|
|
753
|
+
decode: SchemaGetter.transform((cart) => ({
|
|
754
|
+
...cart,
|
|
755
|
+
attributes_array: cart.attributes,
|
|
756
|
+
private_attributes: cart.attributes,
|
|
757
|
+
private_attributes_array: cart.attributes,
|
|
758
|
+
public_attributes: cart.attributes,
|
|
759
|
+
public_attributes_array: cart.attributes
|
|
760
|
+
})),
|
|
761
|
+
encode: SchemaGetter.transform((cart) => pipe(Rec.remove("attributes_array")(cart), Rec.remove("private_attributes"), Rec.remove("private_attributes_array"), Rec.remove("public_attributes"), Rec.remove("public_attributes_array")))
|
|
762
|
+
}));
|
|
763
|
+
var CartOutput = makeCartTransformSchema(BaseCart);
|
|
764
|
+
var makeCartSchema = (sections) => {
|
|
765
|
+
if (sections) return makeCartTransformSchema(BaseCart.pipe(Schema.fieldsAssign({ sections: Schema.NullOr(Ajax.Sections.makeResponseSchema(sections)).pipe(Schema.withDecodingDefaultType(Effect.succeed(null))) })));
|
|
766
|
+
return makeCartTransformSchema(BaseCart.pipe(Schema.fieldsAssign({ sections: Schema.Null.pipe(Schema.withDecodingDefaultType(Effect.succeed(null))) })));
|
|
813
767
|
};
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
}).
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
})
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
})
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}).
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
})
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
)
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
selling_plan: "sp1234567890"
|
|
1019
|
-
},
|
|
1020
|
-
{
|
|
1021
|
-
line: 1,
|
|
1022
|
-
quantity: 1,
|
|
1023
|
-
properties: {
|
|
1024
|
-
key: "property_key",
|
|
1025
|
-
value: "property_value"
|
|
1026
|
-
},
|
|
1027
|
-
selling_plan: "sp1234567890"
|
|
1028
|
-
}
|
|
1029
|
-
]
|
|
1030
|
-
});
|
|
1031
|
-
const CartChangeOutput = makeCartTransformSchema(
|
|
1032
|
-
Schema.extend(
|
|
1033
|
-
BaseCart,
|
|
1034
|
-
Schema.Struct({
|
|
1035
|
-
items_added: Schema.Array(LineItemChange),
|
|
1036
|
-
items_removed: Schema.Array(LineItemChange)
|
|
1037
|
-
})
|
|
1038
|
-
)
|
|
1039
|
-
).annotations({
|
|
1040
|
-
identifier: "CartChangeOutput",
|
|
1041
|
-
title: "cart_change_output",
|
|
1042
|
-
description: "An object representing the output for changing an item in the cart"
|
|
1043
|
-
});
|
|
1044
|
-
const CartClearInput = Ajax.Sections.Input.annotations({
|
|
1045
|
-
identifier: "CartClearInput",
|
|
1046
|
-
title: "cart_clear_input",
|
|
1047
|
-
description: "An object representing the input for clearing the cart",
|
|
1048
|
-
examples: [{}, { sections: "cart_drawer,cart_section" }]
|
|
1049
|
-
});
|
|
1050
|
-
const CartGetInput = Ajax.Sections.Input.annotations({
|
|
1051
|
-
identifier: "CartGetInput",
|
|
1052
|
-
title: "cart_get_input",
|
|
1053
|
-
description: "An object representing the input for getting the cart",
|
|
1054
|
-
examples: [{}, { sections: "cart_drawer,cart_section" }]
|
|
1055
|
-
});
|
|
1056
|
-
const CartUpdateDiscountsInput = Schema.mutable(
|
|
1057
|
-
Schema.Array(Schema.NonEmptyString)
|
|
1058
|
-
);
|
|
768
|
+
var AddItemInput = Schema.Struct({
|
|
769
|
+
id: Resource.ID,
|
|
770
|
+
quantity: Schema.Number.pipe(Schema.withDecodingDefaultType(Effect.succeed(1))),
|
|
771
|
+
properties: BaseAttributes.pipe(Schema.withDecodingDefaultType(Effect.succeed({}))),
|
|
772
|
+
selling_plan: Schema.optional(Resource.ID)
|
|
773
|
+
}).annotate({
|
|
774
|
+
identifier: "AddItemInput",
|
|
775
|
+
title: "add_item_input",
|
|
776
|
+
description: "An object representing the input for adding an item to the cart",
|
|
777
|
+
examples: [{
|
|
778
|
+
id: "1234567890",
|
|
779
|
+
quantity: 1,
|
|
780
|
+
properties: {
|
|
781
|
+
public: "value",
|
|
782
|
+
_private: "value2"
|
|
783
|
+
},
|
|
784
|
+
selling_plan: "sp1234567890"
|
|
785
|
+
}]
|
|
786
|
+
});
|
|
787
|
+
var BaseInput = Schema.fieldsAssign(Ajax.Sections.Input.fields);
|
|
788
|
+
var CartAddInput = Schema.Struct({ items: Schema.Array(AddItemInput) }).pipe(BaseInput).annotate({
|
|
789
|
+
identifier: "CartAddInput",
|
|
790
|
+
title: "cart_add_input",
|
|
791
|
+
description: "An object representing the input for adding items to the cart",
|
|
792
|
+
examples: [{ items: [{
|
|
793
|
+
id: "1234567890",
|
|
794
|
+
quantity: 1,
|
|
795
|
+
properties: {
|
|
796
|
+
public: "value",
|
|
797
|
+
_private: "value2"
|
|
798
|
+
},
|
|
799
|
+
selling_plan: "sp1234567890"
|
|
800
|
+
}] }]
|
|
801
|
+
});
|
|
802
|
+
var CartAddOutput = Schema.Struct({ items: Schema.Array(LineItem) }).annotate({
|
|
803
|
+
identifier: "CartAddOutput",
|
|
804
|
+
title: "cart_add_output",
|
|
805
|
+
description: "An object representing the output for adding items to the cart"
|
|
806
|
+
});
|
|
807
|
+
var UpdateItemRecordInput = Schema.Record(Schema.String, Schema.Number).annotate({
|
|
808
|
+
identifier: "UpdateItemRecordInput",
|
|
809
|
+
title: "update_item_record_input",
|
|
810
|
+
description: "An object representing the input for updating an item record",
|
|
811
|
+
examples: [{
|
|
812
|
+
11231233132: 2,
|
|
813
|
+
1115235234242: 0
|
|
814
|
+
}]
|
|
815
|
+
});
|
|
816
|
+
var DiscountCodeInput = Schema.Array(Schema.String);
|
|
817
|
+
var DiscountCodeTransformed = Schema.String;
|
|
818
|
+
var CartUpdateInput = Schema.Struct({
|
|
819
|
+
updates: Schema.optional(Schema.Union([UpdateItemRecordInput, Schema.Array(Schema.Number)])),
|
|
820
|
+
note: Schema.optional(Schema.NullOr(Schema.String)),
|
|
821
|
+
attributes: Schema.optional(BaseAttributes),
|
|
822
|
+
discount: Schema.optional(DiscountCodeInput.pipe(Schema.decodeTo(DiscountCodeTransformed, {
|
|
823
|
+
decode: SchemaGetter.transform((input) => input.join(",")),
|
|
824
|
+
encode: SchemaGetter.transform((input) => input.split(","))
|
|
825
|
+
})))
|
|
826
|
+
}).pipe(BaseInput).annotate({
|
|
827
|
+
identifier: "CartUpdateInput",
|
|
828
|
+
title: "cart_update_input",
|
|
829
|
+
description: "An object representing the input for updating the cart",
|
|
830
|
+
examples: [{
|
|
831
|
+
updates: {
|
|
832
|
+
11231233132: 2,
|
|
833
|
+
1115235234242: 0
|
|
834
|
+
},
|
|
835
|
+
note: "Updated note",
|
|
836
|
+
attributes: {
|
|
837
|
+
public: "updated",
|
|
838
|
+
_private: "updated2"
|
|
839
|
+
},
|
|
840
|
+
discount: "code1,code2"
|
|
841
|
+
}]
|
|
842
|
+
});
|
|
843
|
+
var ItemAddedChangelog = Schema.Struct({
|
|
844
|
+
variant_id: Schema.Number,
|
|
845
|
+
quantity: Schema.Number
|
|
846
|
+
}).annotate({
|
|
847
|
+
identifier: "ItemAddedChangelog",
|
|
848
|
+
title: "item_added_changelog",
|
|
849
|
+
description: "An object representing the item added to the cart",
|
|
850
|
+
examples: [{
|
|
851
|
+
variant_id: 123,
|
|
852
|
+
quantity: 1
|
|
853
|
+
}]
|
|
854
|
+
});
|
|
855
|
+
var cartUpdateFields = { items_changelog: Schema.Struct({ added: Schema.Array(ItemAddedChangelog) }) };
|
|
856
|
+
var CartUpdateOutput = makeCartTransformSchema(BaseCart.pipe(Schema.fieldsAssign(cartUpdateFields))).annotate({
|
|
857
|
+
identifier: "CartUpdateOutput",
|
|
858
|
+
title: "cart_update_output",
|
|
859
|
+
description: "An object representing the output for updating the cart"
|
|
860
|
+
});
|
|
861
|
+
var CartChangeItemOptionalInput = Schema.Struct({
|
|
862
|
+
quantity: Schema.optional(Schema.Number),
|
|
863
|
+
properties: Schema.optional(Schema.Record(Schema.String, Schema.NullOr(Schema.String))),
|
|
864
|
+
selling_plan: Schema.optional(Schema.NullOr(Resource.ID))
|
|
865
|
+
}).pipe(BaseInput).annotate({
|
|
866
|
+
identifier: "CartChangeItemOptionalInput",
|
|
867
|
+
title: "cart_change_item_optional_input",
|
|
868
|
+
description: "An object representing optional input for changing an item in the cart",
|
|
869
|
+
examples: [{
|
|
870
|
+
quantity: 1,
|
|
871
|
+
properties: {
|
|
872
|
+
key: "property_key",
|
|
873
|
+
value: "property_value"
|
|
874
|
+
},
|
|
875
|
+
selling_plan: "sp1234567890"
|
|
876
|
+
}, {
|
|
877
|
+
quantity: 1,
|
|
878
|
+
properties: {
|
|
879
|
+
key: "property_key",
|
|
880
|
+
value: "property_value"
|
|
881
|
+
},
|
|
882
|
+
selling_plan: "sp1234567890"
|
|
883
|
+
}]
|
|
884
|
+
});
|
|
885
|
+
var LineItemChange = Schema.Struct({
|
|
886
|
+
product_id: Schema.Number,
|
|
887
|
+
variant_id: Schema.Number,
|
|
888
|
+
id: Schema.String,
|
|
889
|
+
image: Schema.NullOr(Schema.String),
|
|
890
|
+
price: Schema.String,
|
|
891
|
+
presentment_price: Schema.Number,
|
|
892
|
+
quantity: Schema.Number,
|
|
893
|
+
title: Schema.String,
|
|
894
|
+
product_title: Schema.String,
|
|
895
|
+
variant_title: Schema.String,
|
|
896
|
+
vendor: Schema.String,
|
|
897
|
+
product_type: Schema.String,
|
|
898
|
+
sku: Schema.NullOr(Schema.String),
|
|
899
|
+
url: Schema.String,
|
|
900
|
+
untranslated_product_title: Schema.String,
|
|
901
|
+
untranslated_variant_title: Schema.String,
|
|
902
|
+
view_key: Schema.String
|
|
903
|
+
}).annotate({
|
|
904
|
+
identifier: "LineItemChange",
|
|
905
|
+
title: "line_item_change",
|
|
906
|
+
description: "An object representing a change in a line item in the cart"
|
|
907
|
+
});
|
|
908
|
+
var CartChangeInput = Schema.Union([Schema.Struct({ id: Schema.String }).pipe(Schema.fieldsAssign(CartChangeItemOptionalInput.fields)), Schema.Struct({ line: Schema.Number }).pipe(Schema.fieldsAssign(CartChangeItemOptionalInput.fields))]).annotate({
|
|
909
|
+
identifier: "CartChangeInput",
|
|
910
|
+
title: "cart_change_input",
|
|
911
|
+
description: "An object representing the input for changing an item in the cart",
|
|
912
|
+
examples: [{
|
|
913
|
+
id: "1234567890",
|
|
914
|
+
quantity: 1,
|
|
915
|
+
properties: {
|
|
916
|
+
key: "property_key",
|
|
917
|
+
value: "property_value"
|
|
918
|
+
},
|
|
919
|
+
selling_plan: "sp1234567890"
|
|
920
|
+
}, {
|
|
921
|
+
line: 1,
|
|
922
|
+
quantity: 1,
|
|
923
|
+
properties: {
|
|
924
|
+
key: "property_key",
|
|
925
|
+
value: "property_value"
|
|
926
|
+
},
|
|
927
|
+
selling_plan: "sp1234567890"
|
|
928
|
+
}]
|
|
929
|
+
});
|
|
930
|
+
var cartChangeFields = {
|
|
931
|
+
items_added: Schema.Array(LineItemChange),
|
|
932
|
+
items_removed: Schema.Array(LineItemChange)
|
|
933
|
+
};
|
|
934
|
+
var CartChangeOutput = makeCartTransformSchema(BaseCart.pipe(Schema.fieldsAssign(cartChangeFields))).annotate({
|
|
935
|
+
identifier: "CartChangeOutput",
|
|
936
|
+
title: "cart_change_output",
|
|
937
|
+
description: "An object representing the output for changing an item in the cart"
|
|
938
|
+
});
|
|
939
|
+
var CartClearInput = Ajax.Sections.Input.annotate({
|
|
940
|
+
identifier: "CartClearInput",
|
|
941
|
+
title: "cart_clear_input",
|
|
942
|
+
description: "An object representing the input for clearing the cart",
|
|
943
|
+
examples: [{}, { sections: "cart_drawer,cart_section" }]
|
|
944
|
+
});
|
|
945
|
+
var CartGetInput = Ajax.Sections.Input.annotate({
|
|
946
|
+
identifier: "CartGetInput",
|
|
947
|
+
title: "cart_get_input",
|
|
948
|
+
description: "An object representing the input for getting the cart",
|
|
949
|
+
examples: [{}, { sections: "cart_drawer,cart_section" }]
|
|
950
|
+
});
|
|
951
|
+
Schema.mutable(Schema.Array(Schema.NonEmptyString));
|
|
952
|
+
/**
|
|
953
|
+
* Per-route output factories for `makeRoute`.
|
|
954
|
+
*
|
|
955
|
+
* v4 can only extend a `Struct`, and these outputs are transforms, so the
|
|
956
|
+
* sections field is composed into the pre-transform `BaseCart` here rather
|
|
957
|
+
* than bolted onto the finished schema inside the ajax client.
|
|
958
|
+
*/
|
|
959
|
+
var sectionsField = (sections) => ({ sections: Schema.NullOr(Ajax.Sections.makeResponseSchema(sections)) });
|
|
960
|
+
var makeCartOutput = (sections) => sections === void 0 ? CartOutput : makeCartSchema(sections);
|
|
961
|
+
var makeCartUpdateOutput = (sections) => sections === void 0 ? CartUpdateOutput : makeCartTransformSchema(BaseCart.pipe(Schema.fieldsAssign({
|
|
962
|
+
...cartUpdateFields,
|
|
963
|
+
...sectionsField(sections)
|
|
964
|
+
})));
|
|
965
|
+
var makeCartChangeOutput = (sections) => sections === void 0 ? CartChangeOutput : makeCartTransformSchema(BaseCart.pipe(Schema.fieldsAssign({
|
|
966
|
+
...cartChangeFields,
|
|
967
|
+
...sectionsField(sections)
|
|
968
|
+
})));
|
|
969
|
+
var makeCartAddOutput = (sections) => sections === void 0 ? CartAddOutput : CartAddOutput.pipe(Schema.fieldsAssign(sectionsField(sections)));
|
|
970
|
+
//#endregion
|
|
971
|
+
export { AddItemInput, BaseAttributes, BaseAttributesArray, BaseCart, Cart, CartAddInput, CartAddOutput, CartChangeInput, CartChangeItemOptionalInput, CartChangeOutput, CartClearInput, CartGetInput, CartLevelDiscountApplication, CartOutput, CartUpdateInput, CartUpdateOutput, CurrencyCode, Discount, DiscountApplication, Image, ItemAddedChangelog, LineItem, LineItemChange, LineLevelDiscountAllocation, OptionWithValue, QuantityRule, SellingPlan, SellingPlanAllocation, SellingPlanAllocationPriceAdjustment, SellingPlanOption, SellingPlanPriceAdjustment, UnitPriceMeasurement, UpdateItemRecordInput, makeCartAddOutput, makeCartChangeOutput, makeCartOutput, makeCartSchema, makeCartTransformSchema, makeCartUpdateOutput };
|
|
1059
972
|
|
|
1060
|
-
export { AddItemInput, Attributes, BaseAttributes, BaseAttributesArray, BaseCart, BaseInput, Cart, CartAddInput, CartAddOutput, CartChangeInput, CartChangeItemOptionalInput, CartChangeOutput, CartClearInput, CartGetInput, CartLevelDiscountApplication, CartOutput, CartUpdateDiscountsInput, CartUpdateInput, CartUpdateOutput, CurrencyCode, Discount, DiscountApplication, Image, ItemAddedChangelog, LineItem, LineItemChange, LineLevelDiscountAllocation, OptionWithValue, QuantityRule, SellingPlan, SellingPlanAllocation, SellingPlanAllocationPriceAdjustment, SellingPlanOption, SellingPlanPriceAdjustment, UnitPriceMeasurement, UpdateItemRecordInput, makeCartSchema, makeCartTransformSchema };
|
|
1061
|
-
//# sourceMappingURL=schema.js.map
|
|
1062
973
|
//# sourceMappingURL=schema.js.map
|