@01.software/sdk 0.41.0 → 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.
Files changed (61) hide show
  1. package/CHANGELOG.md +222 -0
  2. package/README.md +81 -18
  3. package/dist/analytics/react.cjs +71 -3
  4. package/dist/analytics/react.cjs.map +1 -1
  5. package/dist/analytics/react.d.cts +18 -2
  6. package/dist/analytics/react.d.ts +18 -2
  7. package/dist/analytics/react.js +67 -3
  8. package/dist/analytics/react.js.map +1 -1
  9. package/dist/analytics.cjs +6 -2
  10. package/dist/analytics.cjs.map +1 -1
  11. package/dist/analytics.d.cts +17 -4
  12. package/dist/analytics.d.ts +17 -4
  13. package/dist/analytics.js +6 -2
  14. package/dist/analytics.js.map +1 -1
  15. package/dist/client.cjs +176 -32
  16. package/dist/client.cjs.map +1 -1
  17. package/dist/client.d.cts +6 -6
  18. package/dist/client.d.ts +6 -6
  19. package/dist/client.js +176 -32
  20. package/dist/client.js.map +1 -1
  21. package/dist/{collection-client-Bymfni8u.d.cts → collection-client-B-qVIBnJ.d.cts} +5 -5
  22. package/dist/{collection-client-CN4lj6gi.d.ts → collection-client-BhCMwIus.d.ts} +5 -5
  23. package/dist/{const-4BUtUdGU.d.cts → const-BiDujixF.d.cts} +1 -1
  24. package/dist/{const-ymprfiPf.d.ts → const-pmHlwm3E.d.ts} +1 -1
  25. package/dist/{index-w36lpSkU.d.ts → index-B1UBDaKz.d.ts} +3 -3
  26. package/dist/{index-Dquv4xTL.d.cts → index-D78ki6Ij.d.cts} +3 -3
  27. package/dist/index.cjs +156 -339
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +7 -7
  30. package/dist/index.d.ts +7 -7
  31. package/dist/index.js +156 -339
  32. package/dist/index.js.map +1 -1
  33. package/dist/{payload-types-DC0xzR9i.d.cts → payload-types-C7Ul4ElL.d.cts} +181 -118
  34. package/dist/{payload-types-DC0xzR9i.d.ts → payload-types-C7Ul4ElL.d.ts} +181 -118
  35. package/dist/query.d.cts +5 -5
  36. package/dist/query.d.ts +5 -5
  37. package/dist/realtime.cjs +1 -1
  38. package/dist/realtime.cjs.map +1 -1
  39. package/dist/realtime.d.cts +2 -2
  40. package/dist/realtime.d.ts +2 -2
  41. package/dist/realtime.js +1 -1
  42. package/dist/realtime.js.map +1 -1
  43. package/dist/server.cjs +236 -50
  44. package/dist/server.cjs.map +1 -1
  45. package/dist/server.d.cts +7 -7
  46. package/dist/server.d.ts +7 -7
  47. package/dist/server.js +236 -50
  48. package/dist/server.js.map +1 -1
  49. package/dist/{types-CHrzs2GB.d.ts → types-BL7M-EUV.d.cts} +140 -14
  50. package/dist/{types-Bh2p-EMc.d.ts → types-Bf2iCjy8.d.ts} +1 -1
  51. package/dist/{types-BvpjooU-.d.cts → types-ChV1t4ei.d.cts} +1 -1
  52. package/dist/{types-Bl-m9ttd.d.cts → types-D5dSNIGs.d.ts} +140 -14
  53. package/dist/ui/canvas.cjs.map +1 -1
  54. package/dist/ui/canvas.js.map +1 -1
  55. package/dist/ui/form.d.cts +1 -1
  56. package/dist/ui/form.d.ts +1 -1
  57. package/dist/ui/video.d.cts +1 -1
  58. package/dist/ui/video.d.ts +1 -1
  59. package/dist/webhook.d.cts +4 -4
  60. package/dist/webhook.d.ts +4 -4
  61. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -216,6 +216,14 @@ var createValidationError = (message, details, userMessage, suggestion, status)
216
216
  var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
217
217
  var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
218
218
  var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
219
+ var createGoneError = (message, details, userMessage, suggestion) => new GoneError(message, details, userMessage, suggestion);
220
+ var createServiceUnavailableError = (message, retryAfter, details, userMessage, suggestion) => new ServiceUnavailableError(
221
+ message,
222
+ retryAfter,
223
+ details,
224
+ userMessage,
225
+ suggestion
226
+ );
219
227
  var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
220
228
  var createAuthError = (message, details, userMessage, suggestion, requestId) => new AuthError(message, details, userMessage, suggestion, requestId);
221
229
  var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
@@ -240,7 +248,7 @@ function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
240
248
  return publishableKey ?? "";
241
249
  }
242
250
 
243
- // src/core/client/types.ts
251
+ // src/core/internal/utils/api-url.ts
244
252
  function resolveApiUrl(apiUrl) {
245
253
  if (apiUrl) {
246
254
  return apiUrl.replace(/\/$/, "");
@@ -257,7 +265,7 @@ function resolveApiUrl(apiUrl) {
257
265
  // src/core/internal/utils/http.ts
258
266
  var DEFAULT_TIMEOUT = 3e4;
259
267
  var STOREFRONT_BROWSER_TIMEOUT = 15e3;
260
- var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
268
+ var DEFAULT_RETRYABLE_STATUSES = [408, 500, 502, 503, 504];
261
269
  var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 409, 422];
262
270
  var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
263
271
  var DEFAULT_MAX_RETRIES = 3;
@@ -374,7 +382,12 @@ function attachRequestId(err, id) {
374
382
  if (id) err.requestId = id;
375
383
  return err;
376
384
  }
377
- function createHttpStatusError(status, parsed, details, requestId) {
385
+ function parseRetryAfter(response) {
386
+ const raw = response.headers.get("Retry-After");
387
+ if (!raw) return void 0;
388
+ return parseInt(raw, 10) || void 0;
389
+ }
390
+ function mapResponseToError(status, parsed, details, requestId, retryAfter) {
378
391
  const errorDetails = {
379
392
  ...details,
380
393
  ...parsed.errors && { errors: parsed.errors },
@@ -437,6 +450,41 @@ function createHttpStatusError(status, parsed, details, requestId) {
437
450
  requestId
438
451
  );
439
452
  }
453
+ if (status === 410) {
454
+ return attachRequestId(
455
+ createGoneError(
456
+ parsed.errorMessage,
457
+ errorDetails,
458
+ parsed.userMessage,
459
+ suggestion
460
+ ),
461
+ requestId
462
+ );
463
+ }
464
+ if (status === 429) {
465
+ return attachRequestId(
466
+ createRateLimitError(
467
+ parsed.errorMessage,
468
+ retryAfter,
469
+ errorDetails,
470
+ parsed.userMessage,
471
+ suggestion
472
+ ),
473
+ requestId
474
+ );
475
+ }
476
+ if (status === 503) {
477
+ return attachRequestId(
478
+ createServiceUnavailableError(
479
+ parsed.errorMessage,
480
+ retryAfter,
481
+ errorDetails,
482
+ parsed.userMessage,
483
+ suggestion
484
+ ),
485
+ requestId
486
+ );
487
+ }
440
488
  return attachRequestId(
441
489
  createNetworkError(
442
490
  parsed.errorMessage,
@@ -555,26 +603,17 @@ async function httpFetch(url, options) {
555
603
  method: requestInit.method || "GET",
556
604
  attempt: attempt + 1
557
605
  };
558
- if (NON_RETRYABLE_STATUSES.includes(response.status)) {
559
- throw createHttpStatusError(
560
- response.status,
561
- parsed,
562
- details,
563
- requestId
564
- );
565
- }
566
- const error = attachRequestId(
567
- createNetworkError(
568
- parsed.errorMessage,
569
- response.status,
570
- details,
571
- parsed.userMessage,
572
- getErrorSuggestion(response.status)
573
- ),
574
- requestId
606
+ const retryAfter = parseRetryAfter(response);
607
+ const error = mapResponseToError(
608
+ response.status,
609
+ parsed,
610
+ details,
611
+ requestId,
612
+ retryAfter
575
613
  );
576
614
  const method2 = (requestInit.method || "GET").toUpperCase();
577
- if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && retryConfig.retryableStatuses.includes(response.status)) {
615
+ const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
616
+ if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && !isTerminal && !NON_RETRYABLE_STATUSES.includes(response.status) && retryConfig.retryableStatuses.includes(response.status)) {
578
617
  lastError = error;
579
618
  const retryDelay = retryConfig.retryDelay(attempt);
580
619
  debugLog(debug, "error", `Retrying in ${retryDelay}ms...`, error);
@@ -665,9 +704,6 @@ function productDetailCatalogQuery(params) {
665
704
  }
666
705
  return `/api/products/detail/catalog?${search}`;
667
706
  }
668
- function listingGroupsQuery(params) {
669
- return `/api/products/listing-groups?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
670
- }
671
707
  function listingGroupsCatalogQuery(params) {
672
708
  return `/api/products/listing-groups/catalog?ids=${params.productIds.map(encodeURIComponent).join(",")}`;
673
709
  }
@@ -1594,81 +1630,126 @@ var CustomerNamespace = class {
1594
1630
  }
1595
1631
  };
1596
1632
 
1633
+ // src/core/api/endpoints.ts
1634
+ var COMMERCE_ENDPOINTS = {
1635
+ orders: {
1636
+ create: "/api/orders/create",
1637
+ update: "/api/orders/update",
1638
+ confirmPayment: "/api/orders/confirm-payment",
1639
+ byPayment: "/api/orders/by-payment",
1640
+ cancel: "/api/orders/cancel",
1641
+ resolveCancelRefund: "/api/orders/resolve-cancel-refund",
1642
+ checkout: "/api/orders/checkout",
1643
+ createFulfillment: "/api/orders/create-fulfillment",
1644
+ updateFulfillment: "/api/orders/update-fulfillment"
1645
+ },
1646
+ transactions: {
1647
+ update: "/api/transactions/update"
1648
+ },
1649
+ returns: {
1650
+ create: "/api/returns/create",
1651
+ update: "/api/returns/update",
1652
+ returnRefund: "/api/returns/return-refund"
1653
+ },
1654
+ fulfillmentOrders: {
1655
+ prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
1656
+ },
1657
+ fulfillments: {
1658
+ bulkImport: "/api/fulfillments/bulk-import"
1659
+ },
1660
+ carts: {
1661
+ mine: "/api/carts/mine",
1662
+ merge: "/api/carts/merge",
1663
+ addItem: "/api/carts/add-item",
1664
+ updateItem: "/api/carts/update-item",
1665
+ removeItem: "/api/carts/remove-item",
1666
+ applyDiscount: "/api/carts/apply-discount",
1667
+ removeDiscount: "/api/carts/remove-discount",
1668
+ clear: "/api/carts/clear"
1669
+ }
1670
+ };
1671
+ var COMMERCE_ENDPOINT_PATHS = Object.values(
1672
+ COMMERCE_ENDPOINTS
1673
+ ).flatMap((group) => Object.values(group));
1674
+
1597
1675
  // src/core/api/cart-api.ts
1598
1676
  var CartApi = class extends CustomerScopedApi {
1599
1677
  constructor(options) {
1600
- super("CartApi", options);
1678
+ super("CartApi", { ...options, requiresCredential: false });
1601
1679
  }
1602
1680
  async execute(endpoint, method, body) {
1603
1681
  return this.request(endpoint, { method, body });
1604
1682
  }
1605
- getCart(cartId) {
1683
+ /**
1684
+ * Create a cart and receive its `cartToken`. Store the token and pass it to
1685
+ * every subsequent cart operation.
1686
+ */
1687
+ createCart(params = {}) {
1688
+ return this.execute("/api/carts/create", "POST", params);
1689
+ }
1690
+ getCart(cartToken) {
1691
+ return this.execute("/api/carts/get", "POST", { cartToken });
1692
+ }
1693
+ merge(params) {
1606
1694
  return this.execute(
1607
- `/api/carts/${cartId}?depth=0&joins=false`,
1608
- "GET"
1695
+ COMMERCE_ENDPOINTS.carts.merge,
1696
+ "POST",
1697
+ params
1698
+ );
1699
+ }
1700
+ /**
1701
+ * Resolve the authenticated customer's active cart by JWT (no `cartToken`
1702
+ * required). Returns the cart and its capability handle, or both `null` when
1703
+ * the customer has no active cart. Requires a customer token.
1704
+ */
1705
+ mine() {
1706
+ return this.execute(
1707
+ COMMERCE_ENDPOINTS.carts.mine,
1708
+ "POST",
1709
+ {}
1609
1710
  );
1610
1711
  }
1611
1712
  addItem(params) {
1612
- return this.execute("/api/carts/add-item", "POST", params);
1713
+ return this.execute(
1714
+ COMMERCE_ENDPOINTS.carts.addItem,
1715
+ "POST",
1716
+ params
1717
+ );
1613
1718
  }
1614
1719
  updateItem(params) {
1615
- return this.execute("/api/carts/update-item", "POST", params);
1720
+ return this.execute(
1721
+ COMMERCE_ENDPOINTS.carts.updateItem,
1722
+ "POST",
1723
+ params
1724
+ );
1616
1725
  }
1617
1726
  removeItem(params) {
1618
1727
  return this.execute(
1619
- "/api/carts/remove-item",
1728
+ COMMERCE_ENDPOINTS.carts.removeItem,
1620
1729
  "POST",
1621
1730
  params
1622
1731
  );
1623
1732
  }
1624
1733
  applyDiscount(params) {
1625
- return this.execute("/api/carts/apply-discount", "POST", params);
1734
+ return this.execute(
1735
+ COMMERCE_ENDPOINTS.carts.applyDiscount,
1736
+ "POST",
1737
+ params
1738
+ );
1626
1739
  }
1627
1740
  removeDiscount(params) {
1628
- return this.execute("/api/carts/remove-discount", "POST", params);
1629
- }
1630
- clearCart(params) {
1631
1741
  return this.execute(
1632
- "/api/carts/clear",
1742
+ COMMERCE_ENDPOINTS.carts.removeDiscount,
1633
1743
  "POST",
1634
1744
  params
1635
1745
  );
1636
1746
  }
1637
- };
1638
-
1639
- // src/core/api/base-api.ts
1640
- var BaseApi = class {
1641
- constructor(apiName, options) {
1642
- if (!options.secretKey) {
1643
- throw createConfigError(`secretKey is required for ${apiName}.`);
1644
- }
1645
- this.publishableKey = requirePublishableKeyForSecret(
1646
- apiName,
1647
- options.publishableKey,
1648
- options.secretKey
1747
+ clearCart(params) {
1748
+ return this.execute(
1749
+ COMMERCE_ENDPOINTS.carts.clear,
1750
+ "POST",
1751
+ params
1649
1752
  );
1650
- this.secretKey = options.secretKey;
1651
- this.apiUrl = options.apiUrl;
1652
- this.onRequestId = options.onRequestId;
1653
- }
1654
- async request(endpoint, body, options) {
1655
- const method = options?.method ?? "POST";
1656
- try {
1657
- const response = await httpFetch(endpoint, {
1658
- method,
1659
- apiUrl: this.apiUrl,
1660
- publishableKey: this.publishableKey,
1661
- secretKey: this.secretKey,
1662
- ...body !== void 0 && { body: JSON.stringify(body) },
1663
- ...options?.headers && { headers: options.headers }
1664
- });
1665
- this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1666
- return parseApiResponse(response, endpoint);
1667
- } catch (err) {
1668
- const id = err instanceof SDKError ? err.requestId ?? null : null;
1669
- this.onRequestId?.(id);
1670
- throw err;
1671
- }
1672
1753
  }
1673
1754
  };
1674
1755
 
@@ -3117,6 +3198,7 @@ function compareVariantOrder(a, b) {
3117
3198
  function getVariantAvailableForSale(variant) {
3118
3199
  if (variant.isActive === false) return false;
3119
3200
  if (variant.isUnlimited) return true;
3201
+ if (variant.inventoryPolicy === "continue") return true;
3120
3202
  return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
3121
3203
  }
3122
3204
  function getVariantAvailableStock(variant) {
@@ -3477,37 +3559,6 @@ function withProductListingCards(response, options) {
3477
3559
  cards: response.docs.map((item) => buildProductListingCard(item, options))
3478
3560
  };
3479
3561
  }
3480
- function rejectLegacyOptionValueSwatchColor(value) {
3481
- if (Object.prototype.hasOwnProperty.call(
3482
- value,
3483
- "swatchColor"
3484
- )) {
3485
- throw new TypeError(
3486
- 'Product upsert option values no longer accept removed flat "swatchColor"; use nested "swatch" instead.'
3487
- );
3488
- }
3489
- }
3490
- function normalizeProductUpsertOptionValue(value) {
3491
- rejectLegacyOptionValueSwatchColor(value);
3492
- return value;
3493
- }
3494
- function normalizeProductUpsertParams(params) {
3495
- const options = params.options ?? [];
3496
- const variants = params.variants ?? [];
3497
- if (!options.length) {
3498
- return { ...params, options, variants };
3499
- }
3500
- return {
3501
- ...params,
3502
- options: options.map((option) => ({
3503
- ...option,
3504
- values: option.values.map(
3505
- (value) => normalizeProductUpsertOptionValue(value)
3506
- )
3507
- })),
3508
- variants
3509
- };
3510
- }
3511
3562
  var PRODUCT_UPSERT_UNKNOWN_FIELD_REASON = "unknown_field";
3512
3563
  var PRODUCT_UPSERT_READONLY_FIELD_REASON = "product_field_readonly";
3513
3564
  function isProductUpsertFieldValidationErrorBody(value) {
@@ -3516,98 +3567,6 @@ function isProductUpsertFieldValidationErrorBody(value) {
3516
3567
  const reason = body.reason;
3517
3568
  return typeof body.error === "string" && typeof body.field === "string" && (reason === PRODUCT_UPSERT_UNKNOWN_FIELD_REASON || reason === PRODUCT_UPSERT_READONLY_FIELD_REASON);
3518
3569
  }
3519
- var ProductApi = class extends BaseApi {
3520
- constructor(options) {
3521
- super("ProductApi", options);
3522
- }
3523
- /**
3524
- * Check point-in-time stock availability for one or more product variants.
3525
- * Results reflect available stock at the moment of the call and are not guaranteed
3526
- * to remain available by the time an order is placed.
3527
- */
3528
- stockCheck(params) {
3529
- return this.request("/api/products/stock-check", params);
3530
- }
3531
- stockSnapshot(params) {
3532
- return this.request(
3533
- stockSnapshotQuery(params),
3534
- void 0,
3535
- { method: "GET" }
3536
- );
3537
- }
3538
- listingGroups(params) {
3539
- return this.request(
3540
- listingGroupsQuery(params),
3541
- void 0,
3542
- { method: "GET" }
3543
- );
3544
- }
3545
- listingGroupsCatalog(params) {
3546
- return this.request(
3547
- listingGroupsCatalogQuery(params),
3548
- void 0,
3549
- { method: "GET" }
3550
- );
3551
- }
3552
- async listingPage(params = {}) {
3553
- if (params.mode === "full") {
3554
- const response2 = await this.request(buildProductListingPageUrl(params), void 0, { method: "GET" });
3555
- return withProductListingCards(response2, params);
3556
- }
3557
- const response = await this.request(buildProductListingPageUrl(params), void 0, { method: "GET" });
3558
- return withProductListingCards(response, params);
3559
- }
3560
- /**
3561
- * Fetch full product detail by slug or id.
3562
- * Returns a discriminated result so storefronts can distinguish missing,
3563
- * unpublished, and feature-disabled products.
3564
- *
3565
- * Only product-detail 404 responses carrying one of those allowlisted reasons
3566
- * are mapped to `{ found: false, reason }`. Unknown or uncoded 404s, plus
3567
- * permission/auth errors such as tenant mismatch, continue to throw typed SDK
3568
- * errors instead of being collapsed into a storefront absence result.
3569
- */
3570
- async detail(params) {
3571
- try {
3572
- const product = await this.request(
3573
- productDetailQuery(params),
3574
- void 0,
3575
- { method: "GET" }
3576
- );
3577
- return { found: true, product };
3578
- } catch (err) {
3579
- const notFoundResult = productDetailResultFromError(err);
3580
- if (notFoundResult) return notFoundResult;
3581
- throw err;
3582
- }
3583
- }
3584
- async detailCatalog(params) {
3585
- try {
3586
- const product = await this.request(
3587
- productDetailCatalogQuery(params),
3588
- void 0,
3589
- { method: "GET" }
3590
- );
3591
- return { found: true, product };
3592
- } catch (err) {
3593
- const notFoundResult = productDetailResultFromError(err);
3594
- if (notFoundResult?.found === false) return notFoundResult;
3595
- throw err;
3596
- }
3597
- }
3598
- /**
3599
- * Atomically create or update a product together with its options,
3600
- * option-values, and variants in a single transaction. Mirrors Shopify's
3601
- * `productSet` shape and is the canonical write path for the MCP
3602
- * `product-upsert` tool.
3603
- */
3604
- upsert(params) {
3605
- return this.request(
3606
- "/api/products/upsert",
3607
- normalizeProductUpsertParams(params)
3608
- );
3609
- }
3610
- };
3611
3570
 
3612
3571
  // src/core/api/order-api.ts
3613
3572
  function idempotencyRequestOptions(idempotencyKey) {
@@ -3617,126 +3576,6 @@ function splitIdempotencyKey(params) {
3617
3576
  const { idempotencyKey, ...body } = params;
3618
3577
  return { body, idempotencyKey };
3619
3578
  }
3620
- function normalizeCreateOrderBody(params) {
3621
- if (params.items !== void 0) {
3622
- const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
3623
- return { ...rest, orderItems: items };
3624
- }
3625
- const { idempotencyKey: _idempotencyKey, ...body } = params;
3626
- return body;
3627
- }
3628
- var OrderApi = class extends BaseApi {
3629
- constructor(options) {
3630
- super("OrderApi", options);
3631
- }
3632
- createOrder(params) {
3633
- const { idempotencyKey } = params;
3634
- const normalizedBody = normalizeCreateOrderBody(params);
3635
- return this.request(
3636
- "/api/orders/create",
3637
- normalizedBody,
3638
- idempotencyRequestOptions(idempotencyKey)
3639
- );
3640
- }
3641
- updateOrder(params) {
3642
- return this.request("/api/orders/update", params);
3643
- }
3644
- updateTransaction(params) {
3645
- return this.request("/api/transactions/update", params);
3646
- }
3647
- confirmPayment(params) {
3648
- const { body, idempotencyKey } = splitIdempotencyKey(params);
3649
- const headerKey = idempotencyKey ?? params.providerEventId;
3650
- return this.request(
3651
- "/api/orders/confirm-payment",
3652
- body,
3653
- idempotencyRequestOptions(headerKey)
3654
- );
3655
- }
3656
- cancelOrder(params) {
3657
- const { idempotencyKey } = params;
3658
- const body = {
3659
- orderNumber: params.orderNumber,
3660
- reasonCode: params.reasonCode,
3661
- reasonDetail: params.reasonDetail
3662
- };
3663
- return this.request(
3664
- "/api/orders/cancel",
3665
- body,
3666
- idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
3667
- );
3668
- }
3669
- resolveCancelRefund(params) {
3670
- return this.request(
3671
- "/api/orders/resolve-cancel-refund",
3672
- {
3673
- orderNumber: params.orderNumber,
3674
- idempotencyKey: params.idempotencyKey,
3675
- outcome: params.outcome,
3676
- refundedAmount: params.refundedAmount,
3677
- pgProvider: params.pgProvider,
3678
- ...params.pgRefundId ? { pgRefundId: params.pgRefundId } : {}
3679
- },
3680
- idempotencyRequestOptions(params.idempotencyKey)
3681
- );
3682
- }
3683
- /**
3684
- * Returns a `PublicOrder`-compatible shape even when the server backs the
3685
- * response with a Checkout (checkout/order separation, #1285). `orderNumber`
3686
- * stays the stable cross-window key. A breaking `PublicCheckout` split is a
3687
- * deferred follow-up (design D10 / Q3-b); do not change this return type here.
3688
- */
3689
- checkout(params) {
3690
- const { body, idempotencyKey } = splitIdempotencyKey(params);
3691
- return this.request(
3692
- "/api/orders/checkout",
3693
- body,
3694
- idempotencyRequestOptions(idempotencyKey)
3695
- );
3696
- }
3697
- createFulfillment(params) {
3698
- const { body, idempotencyKey } = splitIdempotencyKey(params);
3699
- return this.request(
3700
- "/api/orders/create-fulfillment",
3701
- body,
3702
- idempotencyRequestOptions(idempotencyKey)
3703
- );
3704
- }
3705
- prepareFulfillmentOrder(params) {
3706
- return this.request(
3707
- "/api/fulfillment-orders/prepare-fulfillment-order",
3708
- params
3709
- );
3710
- }
3711
- updateFulfillment(params) {
3712
- return this.request("/api/orders/update-fulfillment", params);
3713
- }
3714
- bulkImportFulfillments(params) {
3715
- return this.request(
3716
- "/api/fulfillments/bulk-import",
3717
- params
3718
- );
3719
- }
3720
- returnWithRefund(params) {
3721
- const { body, idempotencyKey } = splitIdempotencyKey(params);
3722
- return this.request(
3723
- "/api/returns/return-refund",
3724
- body,
3725
- idempotencyRequestOptions(idempotencyKey)
3726
- );
3727
- }
3728
- createReturn(params) {
3729
- const { body, idempotencyKey } = splitIdempotencyKey(params);
3730
- return this.request(
3731
- "/api/returns/create",
3732
- body,
3733
- idempotencyRequestOptions(idempotencyKey)
3734
- );
3735
- }
3736
- updateReturn(params) {
3737
- return this.request("/api/returns/update", params);
3738
- }
3739
- };
3740
3579
 
3741
3580
  // src/core/commerce/commerce-client.ts
3742
3581
  var BrowserCommerceApi = class extends CustomerScopedApi {
@@ -3808,13 +3647,16 @@ var CommerceClient = class {
3808
3647
  }
3809
3648
  };
3810
3649
  this.cart = {
3650
+ create: cartApi.createCart.bind(cartApi),
3811
3651
  get: cartApi.getCart.bind(cartApi),
3812
3652
  addItem: cartApi.addItem.bind(cartApi),
3813
3653
  updateItem: cartApi.updateItem.bind(cartApi),
3814
3654
  removeItem: cartApi.removeItem.bind(cartApi),
3815
3655
  applyDiscount: cartApi.applyDiscount.bind(cartApi),
3816
3656
  removeDiscount: cartApi.removeDiscount.bind(cartApi),
3817
- clear: cartApi.clearCart.bind(cartApi)
3657
+ clear: cartApi.clearCart.bind(cartApi),
3658
+ merge: cartApi.merge.bind(cartApi),
3659
+ mine: cartApi.mine.bind(cartApi)
3818
3660
  };
3819
3661
  this.orders = {
3820
3662
  checkout: (params) => {
@@ -4020,26 +3862,6 @@ function createClient(options) {
4020
3862
  return new Client(options);
4021
3863
  }
4022
3864
 
4023
- // src/core/api/discount-api.ts
4024
- var DiscountApi = class extends BaseApi {
4025
- constructor(options) {
4026
- super("DiscountApi", options);
4027
- }
4028
- validate(params) {
4029
- return this.request("/api/discounts/validate", params);
4030
- }
4031
- };
4032
-
4033
- // src/core/api/shipping-api.ts
4034
- var ShippingApi = class extends BaseApi {
4035
- constructor(options) {
4036
- super("ShippingApi", options);
4037
- }
4038
- calculate(params) {
4039
- return this.request("/api/shipping-policies/calculate", params);
4040
- }
4041
- };
4042
-
4043
3865
  // src/core/commerce/merge-catalog-stock.ts
4044
3866
  function mergeProductDetailWithStock(catalog, snapshot) {
4045
3867
  const snapshotByVariantId = new Map(
@@ -5085,7 +4907,6 @@ function createClient2(options) {
5085
4907
  export {
5086
4908
  ApiError,
5087
4909
  AuthError,
5088
- BaseApi,
5089
4910
  COLLECTIONS,
5090
4911
  COMMERCE_NOTIFICATION_EVENTS,
5091
4912
  COMMERCE_NOTIFICATION_EVENT_TYPE,
@@ -5099,7 +4920,6 @@ export {
5099
4920
  ContentClient,
5100
4921
  CustomerAuth,
5101
4922
  CustomerNamespace,
5102
- DiscountApi,
5103
4923
  EventsClient,
5104
4924
  GoneError,
5105
4925
  IMAGE_SIZES,
@@ -5107,12 +4927,10 @@ export {
5107
4927
  NetworkError,
5108
4928
  NotFoundError,
5109
4929
  ORDER_CHANGED_EVENT_TYPE,
5110
- OrderApi,
5111
4930
  PRODUCT_PLP_FIND_OPTIONS,
5112
4931
  PRODUCT_UPSERT_READONLY_FIELD_REASON,
5113
4932
  PRODUCT_UPSERT_UNKNOWN_FIELD_REASON,
5114
4933
  PermissionError,
5115
- ProductApi,
5116
4934
  ProductSelectionCodecError,
5117
4935
  RateLimitError,
5118
4936
  RealtimeConnection,
@@ -5120,7 +4938,6 @@ export {
5120
4938
  SERVER_COLLECTIONS,
5121
4939
  SERVER_ONLY_COLLECTIONS,
5122
4940
  ServiceUnavailableError,
5123
- ShippingApi,
5124
4941
  TimeoutError,
5125
4942
  UsageLimitError,
5126
4943
  ValidationError,