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