@brytdesigns/shopify-ajax-cart-api 1.0.37 → 1.0.39
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.map +1 -1
- package/dist/effect/api/CartChange.js.map +1 -1
- package/dist/effect/api/CartClear.js.map +1 -1
- package/dist/effect/api/CartGet.js.map +1 -1
- package/dist/effect/api/CartUpdate.js.map +1 -1
- package/dist/effect/index.d.ts +247 -247
- package/dist/effect/schema.js +612 -19
- package/dist/effect/schema.js.map +1 -1
- package/dist/esm/index.js +1312 -515
- package/dist/esm/index.js.map +1 -1
- package/dist/main/effect/api/CartAdd.js.map +1 -1
- package/dist/main/effect/api/CartChange.js.map +1 -1
- package/dist/main/effect/api/CartClear.js.map +1 -1
- package/dist/main/effect/api/CartGet.js.map +1 -1
- package/dist/main/effect/api/CartUpdate.js.map +1 -1
- package/dist/main/effect/schema.js +612 -19
- package/dist/main/effect/schema.js.map +1 -1
- package/dist/main/index.d.ts +743 -547
- package/dist/main/index.js +137 -0
- package/dist/main/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -9,13 +9,34 @@ const BaseAttributeValue = Schema.Union(
|
|
|
9
9
|
Schema.String,
|
|
10
10
|
Schema.Boolean,
|
|
11
11
|
Schema.Number
|
|
12
|
-
)
|
|
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
|
+
});
|
|
13
18
|
const AttributesArray = Schema.Array(
|
|
14
19
|
Schema.Struct({ key: Schema.String, value: BaseAttributeValue })
|
|
15
|
-
)
|
|
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
|
+
});
|
|
16
29
|
const BaseAttributes = Schema.Record({
|
|
17
30
|
key: Schema.String,
|
|
18
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
|
+
]
|
|
19
40
|
});
|
|
20
41
|
const BaseAttributesArray = Schema.transform(
|
|
21
42
|
BaseAttributes,
|
|
@@ -29,14 +50,32 @@ const BaseAttributesArray = Schema.transform(
|
|
|
29
50
|
)
|
|
30
51
|
)
|
|
31
52
|
}
|
|
32
|
-
)
|
|
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
|
+
});
|
|
33
62
|
const BasePrivateAttributes = Schema.transform(BaseAttributes, BaseAttributes, {
|
|
34
63
|
decode: Record.filter((_, key) => key.startsWith("_")),
|
|
35
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" }]
|
|
36
70
|
});
|
|
37
71
|
const BasePublicAttributes = Schema.transform(BaseAttributes, BaseAttributes, {
|
|
38
72
|
decode: Record.filter((_, key) => !key.startsWith("_")),
|
|
39
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" }]
|
|
40
79
|
});
|
|
41
80
|
const BasePrivateAttributesArray = Schema.transform(
|
|
42
81
|
BasePrivateAttributes,
|
|
@@ -50,7 +89,12 @@ const BasePrivateAttributesArray = Schema.transform(
|
|
|
50
89
|
)
|
|
51
90
|
)
|
|
52
91
|
}
|
|
53
|
-
)
|
|
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
|
+
});
|
|
54
98
|
const BasePublicAttributesArray = Schema.transform(
|
|
55
99
|
BasePublicAttributes,
|
|
56
100
|
AttributesArray,
|
|
@@ -63,7 +107,12 @@ const BasePublicAttributesArray = Schema.transform(
|
|
|
63
107
|
)
|
|
64
108
|
)
|
|
65
109
|
}
|
|
66
|
-
)
|
|
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
|
+
});
|
|
67
116
|
const Attributes = Schema.transform(
|
|
68
117
|
BaseAttributes,
|
|
69
118
|
Schema.Struct({
|
|
@@ -92,7 +141,23 @@ const Attributes = Schema.transform(
|
|
|
92
141
|
...attributes.public.record
|
|
93
142
|
})
|
|
94
143
|
}
|
|
95
|
-
)
|
|
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
|
+
});
|
|
96
161
|
const DiscountApplication = Schema.Struct({
|
|
97
162
|
target_selection: Schema.Literal("all", "entitled", "explicit"),
|
|
98
163
|
target_type: Schema.Literal("line_item", "shipping_line"),
|
|
@@ -102,42 +167,115 @@ const DiscountApplication = Schema.Struct({
|
|
|
102
167
|
value: Schema.Union(Schema.Number, Schema.NumberFromString),
|
|
103
168
|
value_type: Schema.Literal("fixed_amount", "percentage"),
|
|
104
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
|
+
]
|
|
105
186
|
});
|
|
106
187
|
const Discount = Schema.Struct({
|
|
107
188
|
amount: Schema.Number,
|
|
108
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"]
|
|
109
201
|
});
|
|
110
|
-
const CurrencyCode = Schema.String;
|
|
111
202
|
const Image = Schema.Struct({
|
|
112
203
|
aspect_ratio: Schema.NullOr(Schema.Number),
|
|
113
204
|
alt: Schema.NullOr(Schema.String),
|
|
114
205
|
height: Schema.NullOr(Schema.Number),
|
|
115
206
|
url: Schema.NullOr(Schema.String),
|
|
116
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
|
+
]
|
|
117
228
|
});
|
|
118
229
|
const OptionWithValue = Schema.Struct({
|
|
119
230
|
name: Schema.String,
|
|
120
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" }]
|
|
121
237
|
});
|
|
122
238
|
const QuantityRule = Schema.Struct({
|
|
123
239
|
min: Schema.Number,
|
|
124
240
|
max: Schema.NullOr(Schema.Number),
|
|
125
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 }]
|
|
126
247
|
});
|
|
127
248
|
const SellingPlanAllocationPriceAdjustment = Schema.Struct({
|
|
128
249
|
position: Schema.Number,
|
|
129
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 }]
|
|
130
256
|
});
|
|
131
257
|
const SellingPlanPriceAdjustment = Schema.Struct({
|
|
132
258
|
order_count: Schema.NullOr(Schema.Number),
|
|
133
259
|
position: Schema.Number,
|
|
134
260
|
value: Schema.Union(Schema.Number, Schema.String),
|
|
135
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
|
+
]
|
|
136
269
|
});
|
|
137
270
|
const SellingPlanOption = Schema.Struct({
|
|
138
271
|
name: Schema.String,
|
|
139
272
|
position: Schema.Number,
|
|
140
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" }]
|
|
141
279
|
});
|
|
142
280
|
const SellingPlan = Schema.Struct({
|
|
143
281
|
id: Resource.ID,
|
|
@@ -151,6 +289,21 @@ const SellingPlan = Schema.Struct({
|
|
|
151
289
|
default: () => false
|
|
152
290
|
}),
|
|
153
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
|
+
]
|
|
154
307
|
});
|
|
155
308
|
const SellingPlanAllocation = Schema.Struct({
|
|
156
309
|
price_adjustments: Schema.Array(SellingPlanAllocationPriceAdjustment),
|
|
@@ -158,10 +311,50 @@ const SellingPlanAllocation = Schema.Struct({
|
|
|
158
311
|
compare_at_price: Schema.Number,
|
|
159
312
|
per_delivery_price: Schema.Number,
|
|
160
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
|
+
]
|
|
161
335
|
});
|
|
162
336
|
const LineLevelDiscountAllocation = Schema.Struct({
|
|
163
337
|
amount: Schema.Number,
|
|
164
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
|
+
]
|
|
165
358
|
});
|
|
166
359
|
const CartLevelDiscountApplicationUpdate = Schema.transform(
|
|
167
360
|
Schema.Struct({
|
|
@@ -175,20 +368,70 @@ const CartLevelDiscountApplicationUpdate = Schema.transform(
|
|
|
175
368
|
}),
|
|
176
369
|
strict: false
|
|
177
370
|
}
|
|
178
|
-
)
|
|
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
|
+
});
|
|
179
388
|
const CartLevelDiscountApplication = Schema.Union(
|
|
180
389
|
DiscountApplication,
|
|
181
390
|
CartLevelDiscountApplicationUpdate
|
|
182
|
-
)
|
|
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
|
+
});
|
|
183
408
|
const UnitPriceMeasurement = Schema.Struct({
|
|
184
409
|
measured_type: Schema.Literal("volume", "weight", "dimension"),
|
|
185
410
|
quantity_unit: Schema.String,
|
|
186
411
|
quantity_value: Schema.Number,
|
|
187
412
|
reference_unit: Schema.String,
|
|
188
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
|
+
]
|
|
189
427
|
});
|
|
190
428
|
const VariantOptions = Schema.optionalWith(Schema.Array(Schema.String), {
|
|
191
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"]]
|
|
192
435
|
});
|
|
193
436
|
const BaseLineItem = Schema.Struct({
|
|
194
437
|
id: Resource.ID,
|
|
@@ -234,6 +477,73 @@ const BaseLineItem = Schema.Struct({
|
|
|
234
477
|
Schema.NullOr(SellingPlanAllocation),
|
|
235
478
|
{ default: () => null }
|
|
236
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
|
+
]
|
|
237
547
|
});
|
|
238
548
|
const LineItem = Schema.transform(
|
|
239
549
|
BaseLineItem,
|
|
@@ -278,7 +588,86 @@ const LineItem = Schema.transform(
|
|
|
278
588
|
Record.remove("public_properties_array")
|
|
279
589
|
)
|
|
280
590
|
}
|
|
281
|
-
)
|
|
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
|
+
});
|
|
282
671
|
const BaseCart = Schema.Struct({
|
|
283
672
|
token: Schema.String,
|
|
284
673
|
note: Schema.NullOr(Schema.String),
|
|
@@ -300,6 +689,32 @@ const BaseCart = Schema.Struct({
|
|
|
300
689
|
currency: CurrencyCode,
|
|
301
690
|
items_subtotal_price: Schema.Number,
|
|
302
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
|
+
]
|
|
303
718
|
});
|
|
304
719
|
const Cart = Schema.extend(
|
|
305
720
|
BaseCart,
|
|
@@ -320,7 +735,41 @@ const Cart = Schema.extend(
|
|
|
320
735
|
default: () => []
|
|
321
736
|
})
|
|
322
737
|
})
|
|
323
|
-
)
|
|
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
|
+
});
|
|
324
773
|
const makeCartTransformSchema = (schema) => Schema.transform(schema, Cart, {
|
|
325
774
|
decode: (cart) => ({
|
|
326
775
|
...cart,
|
|
@@ -367,17 +816,65 @@ const AddItemInput = Schema.Struct({
|
|
|
367
816
|
quantity: Schema.optionalWith(Schema.Number, { default: () => 1 }),
|
|
368
817
|
properties: Schema.optionalWith(BaseAttributes, { default: () => ({}) }),
|
|
369
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
|
+
]
|
|
370
834
|
});
|
|
371
835
|
const BaseInput = Schema.extend(Ajax.Sections.Input);
|
|
372
836
|
const CartAddInput = Schema.Struct({
|
|
373
837
|
items: Schema.Array(AddItemInput)
|
|
374
|
-
}).pipe(BaseInput)
|
|
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
|
+
});
|
|
375
858
|
const CartAddOutput = Schema.Struct({
|
|
376
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"
|
|
377
864
|
});
|
|
378
865
|
const UpdateItemRecordInput = Schema.Record({
|
|
379
866
|
key: Schema.String,
|
|
380
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
|
+
]
|
|
381
878
|
});
|
|
382
879
|
const DiscountCodeInput = Schema.Array(Schema.String);
|
|
383
880
|
const DiscountCodeTransformed = Schema.String;
|
|
@@ -393,10 +890,38 @@ const CartUpdateInput = Schema.Struct({
|
|
|
393
890
|
encode: (input) => input.split(",")
|
|
394
891
|
})
|
|
395
892
|
)
|
|
396
|
-
}).pipe(BaseInput)
|
|
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
|
+
});
|
|
397
912
|
const ItemAddedChangelog = Schema.Struct({
|
|
398
913
|
variant_id: Schema.Number,
|
|
399
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
|
+
]
|
|
400
925
|
});
|
|
401
926
|
const CartUpdateOutput = makeCartTransformSchema(
|
|
402
927
|
Schema.extend(
|
|
@@ -407,7 +932,11 @@ const CartUpdateOutput = makeCartTransformSchema(
|
|
|
407
932
|
})
|
|
408
933
|
})
|
|
409
934
|
)
|
|
410
|
-
)
|
|
935
|
+
).annotations({
|
|
936
|
+
identifier: "CartUpdateOutput",
|
|
937
|
+
title: "cart_update_output",
|
|
938
|
+
description: "An object representing the output for updating the cart"
|
|
939
|
+
});
|
|
411
940
|
const CartChangeItemOptionalInput = Schema.Struct({
|
|
412
941
|
quantity: Schema.optional(Schema.Number),
|
|
413
942
|
properties: Schema.optional(
|
|
@@ -417,7 +946,29 @@ const CartChangeItemOptionalInput = Schema.Struct({
|
|
|
417
946
|
})
|
|
418
947
|
),
|
|
419
948
|
selling_plan: Schema.optional(Schema.NullOr(Resource.ID))
|
|
420
|
-
}).pipe(BaseInput)
|
|
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
|
+
});
|
|
421
972
|
const LineItemChange = Schema.Struct({
|
|
422
973
|
product_id: Schema.Number,
|
|
423
974
|
variant_id: Schema.Number,
|
|
@@ -436,6 +987,10 @@ const LineItemChange = Schema.Struct({
|
|
|
436
987
|
untranslated_product_title: Schema.String,
|
|
437
988
|
untranslated_variant_title: Schema.String,
|
|
438
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"
|
|
439
994
|
});
|
|
440
995
|
const CartChangeInput = Schema.Union(
|
|
441
996
|
Schema.extend(CartChangeItemOptionalInput)(
|
|
@@ -448,7 +1003,31 @@ const CartChangeInput = Schema.Union(
|
|
|
448
1003
|
line: Schema.Number
|
|
449
1004
|
})
|
|
450
1005
|
)
|
|
451
|
-
)
|
|
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
|
+
});
|
|
452
1031
|
const CartChangeOutput = makeCartTransformSchema(
|
|
453
1032
|
Schema.extend(
|
|
454
1033
|
BaseCart,
|
|
@@ -457,9 +1036,23 @@ const CartChangeOutput = makeCartTransformSchema(
|
|
|
457
1036
|
items_removed: Schema.Array(LineItemChange)
|
|
458
1037
|
})
|
|
459
1038
|
)
|
|
460
|
-
)
|
|
461
|
-
|
|
462
|
-
|
|
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
|
+
});
|
|
463
1056
|
const CartUpdateDiscountsInput = Schema.mutable(
|
|
464
1057
|
Schema.Array(Schema.NonEmptyString)
|
|
465
1058
|
);
|