@01.software/sdk 0.41.1 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +208 -0
- package/README.md +81 -18
- package/dist/analytics/react.cjs +71 -3
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.d.cts +18 -2
- package/dist/analytics/react.d.ts +18 -2
- package/dist/analytics/react.js +67 -3
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs +6 -2
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +17 -4
- package/dist/analytics.d.ts +17 -4
- package/dist/analytics.js +6 -2
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +176 -32
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +176 -32
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-Bk--pNzW.d.cts → collection-client-B-qVIBnJ.d.cts} +3 -3
- package/dist/{collection-client-BdcxkW7l.d.ts → collection-client-BhCMwIus.d.ts} +3 -3
- package/dist/{const-qGGI7Uii.d.cts → const-BiDujixF.d.cts} +1 -1
- package/dist/{const-HwdntWtG.d.ts → const-pmHlwm3E.d.ts} +1 -1
- package/dist/{index-B1oW50RY.d.ts → index-B1UBDaKz.d.ts} +3 -3
- package/dist/{index-DiXtjVab.d.cts → index-D78ki6Ij.d.cts} +3 -3
- package/dist/index.cjs +156 -339
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +156 -339
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-CqJOgON7.d.cts → payload-types-C7Ul4ElL.d.cts} +181 -115
- package/dist/{payload-types-CqJOgON7.d.ts → payload-types-C7Ul4ElL.d.ts} +181 -115
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/realtime.cjs +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +1 -1
- package/dist/realtime.js.map +1 -1
- package/dist/server.cjs +230 -46
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +230 -46
- package/dist/server.js.map +1 -1
- package/dist/{types-DgfXb7iV.d.ts → types-BL7M-EUV.d.cts} +138 -13
- package/dist/{types-BMI3M0nb.d.ts → types-Bf2iCjy8.d.ts} +1 -1
- package/dist/{types-ByLSG-O3.d.cts → types-ChV1t4ei.d.cts} +1 -1
- package/dist/{types-BKa9z9s2.d.cts → types-D5dSNIGs.d.ts} +138 -13
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/package.json +1 -1
package/dist/client.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-
|
|
3
|
-
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-
|
|
4
|
-
import './payload-types-
|
|
5
|
-
export { C as Collection, P as PublicCollection } from './const-
|
|
1
|
+
import { R as ReadOnlyCollectionClient } from './collection-client-B-qVIBnJ.cjs';
|
|
2
|
+
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-BL7M-EUV.cjs';
|
|
3
|
+
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-BL7M-EUV.cjs';
|
|
4
|
+
import './payload-types-C7Ul4ElL.cjs';
|
|
5
|
+
export { C as Collection, P as PublicCollection } from './const-BiDujixF.cjs';
|
|
6
6
|
import './metadata.cjs';
|
|
7
|
-
import './types-
|
|
7
|
+
import './types-ChV1t4ei.cjs';
|
|
8
8
|
|
|
9
9
|
declare class Client {
|
|
10
10
|
commerce: CommerceClient;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { R as ReadOnlyCollectionClient } from './collection-client-
|
|
2
|
-
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-
|
|
3
|
-
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-
|
|
4
|
-
import './payload-types-
|
|
5
|
-
export { C as Collection, P as PublicCollection } from './const-
|
|
1
|
+
import { R as ReadOnlyCollectionClient } from './collection-client-BhCMwIus.js';
|
|
2
|
+
import { C as CommerceClient, a as CommunityClient, b as ContentClient, E as EventsClient, c as CustomerNamespace, d as ClientState, e as ClientConfig } from './types-D5dSNIGs.js';
|
|
3
|
+
export { A as AddItemParams, f as ApiQueryOptions, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, j as ClientMetadata, k as ContentClientOptions, D as DebugConfig, l as DeepPartial, m as ExtractArrayType, P as PayloadFindResponse, n as PayloadMutationResponse, o as PublicCart, p as PublicCartItem, q as PublicCartReference, r as PublicMediaAsset, s as PublicMediaSize, t as PublicOrder, u as PublicOrderItem, v as PublicOrderReference, R as RemoveDiscountParams, w as RemoveItemParams, x as RetryConfig, y as RootClient, y as RootClientType, z as RootCollectionClient, B as RootReadOnlyQueryBuilder, S as Sort, F as StorefrontContentListOptions, G as StorefrontContentReference, H as StorefrontGalleryItem, I as StorefrontGalleryItemsListOptions, J as StorefrontGalleryItemsSort, K as StorefrontLink, L as StorefrontLinksListOptions, M as StorefrontLinksSort, U as UpdateItemParams, W as Where } from './types-D5dSNIGs.js';
|
|
4
|
+
import './payload-types-C7Ul4ElL.js';
|
|
5
|
+
export { C as Collection, P as PublicCollection } from './const-pmHlwm3E.js';
|
|
6
6
|
import './metadata.js';
|
|
7
|
-
import './types-
|
|
7
|
+
import './types-Bf2iCjy8.js';
|
|
8
8
|
|
|
9
9
|
declare class Client {
|
|
10
10
|
commerce: CommerceClient;
|
package/dist/client.js
CHANGED
|
@@ -70,6 +70,26 @@ var TimeoutError = class extends SDKError {
|
|
|
70
70
|
this.name = "TimeoutError";
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
+
var GoneError = class extends SDKError {
|
|
74
|
+
constructor(message = "The requested resource is no longer available.", details, userMessage, suggestion) {
|
|
75
|
+
super("GONE_ERROR", message, 410, details, userMessage, suggestion);
|
|
76
|
+
this.name = "GoneError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var ServiceUnavailableError = class extends SDKError {
|
|
80
|
+
constructor(message = "Service temporarily unavailable.", retryAfter, details, userMessage, suggestion) {
|
|
81
|
+
super(
|
|
82
|
+
"SERVICE_UNAVAILABLE_ERROR",
|
|
83
|
+
message,
|
|
84
|
+
503,
|
|
85
|
+
details,
|
|
86
|
+
userMessage,
|
|
87
|
+
suggestion
|
|
88
|
+
);
|
|
89
|
+
this.name = "ServiceUnavailableError";
|
|
90
|
+
this.retryAfter = retryAfter;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
73
93
|
var UsageLimitError = class extends SDKError {
|
|
74
94
|
constructor(message, usage, details, userMessage, suggestion) {
|
|
75
95
|
super("USAGE_LIMIT_ERROR", message, 429, details, userMessage, suggestion);
|
|
@@ -151,6 +171,14 @@ var createValidationError = (message, details, userMessage, suggestion, status)
|
|
|
151
171
|
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
152
172
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
153
173
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
174
|
+
var createGoneError = (message, details, userMessage, suggestion) => new GoneError(message, details, userMessage, suggestion);
|
|
175
|
+
var createServiceUnavailableError = (message, retryAfter, details, userMessage, suggestion) => new ServiceUnavailableError(
|
|
176
|
+
message,
|
|
177
|
+
retryAfter,
|
|
178
|
+
details,
|
|
179
|
+
userMessage,
|
|
180
|
+
suggestion
|
|
181
|
+
);
|
|
154
182
|
var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
|
|
155
183
|
var createAuthError = (message, details, userMessage, suggestion, requestId) => new AuthError(message, details, userMessage, suggestion, requestId);
|
|
156
184
|
var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
|
|
@@ -175,7 +203,7 @@ function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
|
|
|
175
203
|
return publishableKey ?? "";
|
|
176
204
|
}
|
|
177
205
|
|
|
178
|
-
// src/core/
|
|
206
|
+
// src/core/internal/utils/api-url.ts
|
|
179
207
|
function resolveApiUrl(apiUrl) {
|
|
180
208
|
if (apiUrl) {
|
|
181
209
|
return apiUrl.replace(/\/$/, "");
|
|
@@ -192,7 +220,7 @@ function resolveApiUrl(apiUrl) {
|
|
|
192
220
|
// src/core/internal/utils/http.ts
|
|
193
221
|
var DEFAULT_TIMEOUT = 3e4;
|
|
194
222
|
var STOREFRONT_BROWSER_TIMEOUT = 15e3;
|
|
195
|
-
var DEFAULT_RETRYABLE_STATUSES = [408,
|
|
223
|
+
var DEFAULT_RETRYABLE_STATUSES = [408, 500, 502, 503, 504];
|
|
196
224
|
var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 409, 422];
|
|
197
225
|
var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
|
|
198
226
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -309,7 +337,12 @@ function attachRequestId(err, id) {
|
|
|
309
337
|
if (id) err.requestId = id;
|
|
310
338
|
return err;
|
|
311
339
|
}
|
|
312
|
-
function
|
|
340
|
+
function parseRetryAfter(response) {
|
|
341
|
+
const raw = response.headers.get("Retry-After");
|
|
342
|
+
if (!raw) return void 0;
|
|
343
|
+
return parseInt(raw, 10) || void 0;
|
|
344
|
+
}
|
|
345
|
+
function mapResponseToError(status, parsed, details, requestId, retryAfter) {
|
|
313
346
|
const errorDetails = {
|
|
314
347
|
...details,
|
|
315
348
|
...parsed.errors && { errors: parsed.errors },
|
|
@@ -372,6 +405,41 @@ function createHttpStatusError(status, parsed, details, requestId) {
|
|
|
372
405
|
requestId
|
|
373
406
|
);
|
|
374
407
|
}
|
|
408
|
+
if (status === 410) {
|
|
409
|
+
return attachRequestId(
|
|
410
|
+
createGoneError(
|
|
411
|
+
parsed.errorMessage,
|
|
412
|
+
errorDetails,
|
|
413
|
+
parsed.userMessage,
|
|
414
|
+
suggestion
|
|
415
|
+
),
|
|
416
|
+
requestId
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
if (status === 429) {
|
|
420
|
+
return attachRequestId(
|
|
421
|
+
createRateLimitError(
|
|
422
|
+
parsed.errorMessage,
|
|
423
|
+
retryAfter,
|
|
424
|
+
errorDetails,
|
|
425
|
+
parsed.userMessage,
|
|
426
|
+
suggestion
|
|
427
|
+
),
|
|
428
|
+
requestId
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
if (status === 503) {
|
|
432
|
+
return attachRequestId(
|
|
433
|
+
createServiceUnavailableError(
|
|
434
|
+
parsed.errorMessage,
|
|
435
|
+
retryAfter,
|
|
436
|
+
errorDetails,
|
|
437
|
+
parsed.userMessage,
|
|
438
|
+
suggestion
|
|
439
|
+
),
|
|
440
|
+
requestId
|
|
441
|
+
);
|
|
442
|
+
}
|
|
375
443
|
return attachRequestId(
|
|
376
444
|
createNetworkError(
|
|
377
445
|
parsed.errorMessage,
|
|
@@ -490,26 +558,17 @@ async function httpFetch(url, options) {
|
|
|
490
558
|
method: requestInit.method || "GET",
|
|
491
559
|
attempt: attempt + 1
|
|
492
560
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
const error = attachRequestId(
|
|
502
|
-
createNetworkError(
|
|
503
|
-
parsed.errorMessage,
|
|
504
|
-
response.status,
|
|
505
|
-
details,
|
|
506
|
-
parsed.userMessage,
|
|
507
|
-
getErrorSuggestion(response.status)
|
|
508
|
-
),
|
|
509
|
-
requestId
|
|
561
|
+
const retryAfter = parseRetryAfter(response);
|
|
562
|
+
const error = mapResponseToError(
|
|
563
|
+
response.status,
|
|
564
|
+
parsed,
|
|
565
|
+
details,
|
|
566
|
+
requestId,
|
|
567
|
+
retryAfter
|
|
510
568
|
);
|
|
511
569
|
const method2 = (requestInit.method || "GET").toUpperCase();
|
|
512
|
-
|
|
570
|
+
const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
|
|
571
|
+
if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && !isTerminal && !NON_RETRYABLE_STATUSES.includes(response.status) && retryConfig.retryableStatuses.includes(response.status)) {
|
|
513
572
|
lastError = error;
|
|
514
573
|
const retryDelay = retryConfig.retryDelay(attempt);
|
|
515
574
|
debugLog(debug, "error", `Retrying in ${retryDelay}ms...`, error);
|
|
@@ -1519,42 +1578,123 @@ var CustomerNamespace = class {
|
|
|
1519
1578
|
}
|
|
1520
1579
|
};
|
|
1521
1580
|
|
|
1581
|
+
// src/core/api/endpoints.ts
|
|
1582
|
+
var COMMERCE_ENDPOINTS = {
|
|
1583
|
+
orders: {
|
|
1584
|
+
create: "/api/orders/create",
|
|
1585
|
+
update: "/api/orders/update",
|
|
1586
|
+
confirmPayment: "/api/orders/confirm-payment",
|
|
1587
|
+
byPayment: "/api/orders/by-payment",
|
|
1588
|
+
cancel: "/api/orders/cancel",
|
|
1589
|
+
resolveCancelRefund: "/api/orders/resolve-cancel-refund",
|
|
1590
|
+
checkout: "/api/orders/checkout",
|
|
1591
|
+
createFulfillment: "/api/orders/create-fulfillment",
|
|
1592
|
+
updateFulfillment: "/api/orders/update-fulfillment"
|
|
1593
|
+
},
|
|
1594
|
+
transactions: {
|
|
1595
|
+
update: "/api/transactions/update"
|
|
1596
|
+
},
|
|
1597
|
+
returns: {
|
|
1598
|
+
create: "/api/returns/create",
|
|
1599
|
+
update: "/api/returns/update",
|
|
1600
|
+
returnRefund: "/api/returns/return-refund"
|
|
1601
|
+
},
|
|
1602
|
+
fulfillmentOrders: {
|
|
1603
|
+
prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
|
|
1604
|
+
},
|
|
1605
|
+
fulfillments: {
|
|
1606
|
+
bulkImport: "/api/fulfillments/bulk-import"
|
|
1607
|
+
},
|
|
1608
|
+
carts: {
|
|
1609
|
+
mine: "/api/carts/mine",
|
|
1610
|
+
merge: "/api/carts/merge",
|
|
1611
|
+
addItem: "/api/carts/add-item",
|
|
1612
|
+
updateItem: "/api/carts/update-item",
|
|
1613
|
+
removeItem: "/api/carts/remove-item",
|
|
1614
|
+
applyDiscount: "/api/carts/apply-discount",
|
|
1615
|
+
removeDiscount: "/api/carts/remove-discount",
|
|
1616
|
+
clear: "/api/carts/clear"
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
var COMMERCE_ENDPOINT_PATHS = Object.values(
|
|
1620
|
+
COMMERCE_ENDPOINTS
|
|
1621
|
+
).flatMap((group) => Object.values(group));
|
|
1622
|
+
|
|
1522
1623
|
// src/core/api/cart-api.ts
|
|
1523
1624
|
var CartApi = class extends CustomerScopedApi {
|
|
1524
1625
|
constructor(options) {
|
|
1525
|
-
super("CartApi", options);
|
|
1626
|
+
super("CartApi", { ...options, requiresCredential: false });
|
|
1526
1627
|
}
|
|
1527
1628
|
async execute(endpoint, method, body) {
|
|
1528
1629
|
return this.request(endpoint, { method, body });
|
|
1529
1630
|
}
|
|
1530
|
-
|
|
1631
|
+
/**
|
|
1632
|
+
* Create a cart and receive its `cartToken`. Store the token and pass it to
|
|
1633
|
+
* every subsequent cart operation.
|
|
1634
|
+
*/
|
|
1635
|
+
createCart(params = {}) {
|
|
1636
|
+
return this.execute("/api/carts/create", "POST", params);
|
|
1637
|
+
}
|
|
1638
|
+
getCart(cartToken) {
|
|
1639
|
+
return this.execute("/api/carts/get", "POST", { cartToken });
|
|
1640
|
+
}
|
|
1641
|
+
merge(params) {
|
|
1531
1642
|
return this.execute(
|
|
1532
|
-
|
|
1533
|
-
"
|
|
1643
|
+
COMMERCE_ENDPOINTS.carts.merge,
|
|
1644
|
+
"POST",
|
|
1645
|
+
params
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Resolve the authenticated customer's active cart by JWT (no `cartToken`
|
|
1650
|
+
* required). Returns the cart and its capability handle, or both `null` when
|
|
1651
|
+
* the customer has no active cart. Requires a customer token.
|
|
1652
|
+
*/
|
|
1653
|
+
mine() {
|
|
1654
|
+
return this.execute(
|
|
1655
|
+
COMMERCE_ENDPOINTS.carts.mine,
|
|
1656
|
+
"POST",
|
|
1657
|
+
{}
|
|
1534
1658
|
);
|
|
1535
1659
|
}
|
|
1536
1660
|
addItem(params) {
|
|
1537
|
-
return this.execute(
|
|
1661
|
+
return this.execute(
|
|
1662
|
+
COMMERCE_ENDPOINTS.carts.addItem,
|
|
1663
|
+
"POST",
|
|
1664
|
+
params
|
|
1665
|
+
);
|
|
1538
1666
|
}
|
|
1539
1667
|
updateItem(params) {
|
|
1540
|
-
return this.execute(
|
|
1668
|
+
return this.execute(
|
|
1669
|
+
COMMERCE_ENDPOINTS.carts.updateItem,
|
|
1670
|
+
"POST",
|
|
1671
|
+
params
|
|
1672
|
+
);
|
|
1541
1673
|
}
|
|
1542
1674
|
removeItem(params) {
|
|
1543
1675
|
return this.execute(
|
|
1544
|
-
|
|
1676
|
+
COMMERCE_ENDPOINTS.carts.removeItem,
|
|
1545
1677
|
"POST",
|
|
1546
1678
|
params
|
|
1547
1679
|
);
|
|
1548
1680
|
}
|
|
1549
1681
|
applyDiscount(params) {
|
|
1550
|
-
return this.execute(
|
|
1682
|
+
return this.execute(
|
|
1683
|
+
COMMERCE_ENDPOINTS.carts.applyDiscount,
|
|
1684
|
+
"POST",
|
|
1685
|
+
params
|
|
1686
|
+
);
|
|
1551
1687
|
}
|
|
1552
1688
|
removeDiscount(params) {
|
|
1553
|
-
return this.execute(
|
|
1689
|
+
return this.execute(
|
|
1690
|
+
COMMERCE_ENDPOINTS.carts.removeDiscount,
|
|
1691
|
+
"POST",
|
|
1692
|
+
params
|
|
1693
|
+
);
|
|
1554
1694
|
}
|
|
1555
1695
|
clearCart(params) {
|
|
1556
1696
|
return this.execute(
|
|
1557
|
-
|
|
1697
|
+
COMMERCE_ENDPOINTS.carts.clear,
|
|
1558
1698
|
"POST",
|
|
1559
1699
|
params
|
|
1560
1700
|
);
|
|
@@ -2365,6 +2505,7 @@ function compareVariantOrder(a, b) {
|
|
|
2365
2505
|
function getVariantAvailableForSale(variant) {
|
|
2366
2506
|
if (variant.isActive === false) return false;
|
|
2367
2507
|
if (variant.isUnlimited) return true;
|
|
2508
|
+
if (variant.inventoryPolicy === "continue") return true;
|
|
2368
2509
|
return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
|
|
2369
2510
|
}
|
|
2370
2511
|
function isVariantAvailableForSale(variant) {
|
|
@@ -2742,13 +2883,16 @@ var CommerceClient = class {
|
|
|
2742
2883
|
}
|
|
2743
2884
|
};
|
|
2744
2885
|
this.cart = {
|
|
2886
|
+
create: cartApi.createCart.bind(cartApi),
|
|
2745
2887
|
get: cartApi.getCart.bind(cartApi),
|
|
2746
2888
|
addItem: cartApi.addItem.bind(cartApi),
|
|
2747
2889
|
updateItem: cartApi.updateItem.bind(cartApi),
|
|
2748
2890
|
removeItem: cartApi.removeItem.bind(cartApi),
|
|
2749
2891
|
applyDiscount: cartApi.applyDiscount.bind(cartApi),
|
|
2750
2892
|
removeDiscount: cartApi.removeDiscount.bind(cartApi),
|
|
2751
|
-
clear: cartApi.clearCart.bind(cartApi)
|
|
2893
|
+
clear: cartApi.clearCart.bind(cartApi),
|
|
2894
|
+
merge: cartApi.merge.bind(cartApi),
|
|
2895
|
+
mine: cartApi.mine.bind(cartApi)
|
|
2752
2896
|
};
|
|
2753
2897
|
this.orders = {
|
|
2754
2898
|
checkout: (params) => {
|