@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.
Files changed (61) hide show
  1. package/CHANGELOG.md +208 -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-Bk--pNzW.d.cts → collection-client-B-qVIBnJ.d.cts} +3 -3
  22. package/dist/{collection-client-BdcxkW7l.d.ts → collection-client-BhCMwIus.d.ts} +3 -3
  23. package/dist/{const-qGGI7Uii.d.cts → const-BiDujixF.d.cts} +1 -1
  24. package/dist/{const-HwdntWtG.d.ts → const-pmHlwm3E.d.ts} +1 -1
  25. package/dist/{index-B1oW50RY.d.ts → index-B1UBDaKz.d.ts} +3 -3
  26. package/dist/{index-DiXtjVab.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-CqJOgON7.d.cts → payload-types-C7Ul4ElL.d.cts} +181 -115
  34. package/dist/{payload-types-CqJOgON7.d.ts → payload-types-C7Ul4ElL.d.ts} +181 -115
  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 +230 -46
  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 +230 -46
  48. package/dist/server.js.map +1 -1
  49. package/dist/{types-DgfXb7iV.d.ts → types-BL7M-EUV.d.cts} +138 -13
  50. package/dist/{types-BMI3M0nb.d.ts → types-Bf2iCjy8.d.ts} +1 -1
  51. package/dist/{types-ByLSG-O3.d.cts → types-ChV1t4ei.d.cts} +1 -1
  52. package/dist/{types-BKa9z9s2.d.cts → types-D5dSNIGs.d.ts} +138 -13
  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 +1 -1
package/dist/server.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { S as ServerCollectionClient } from './collection-client-Bk--pNzW.cjs';
2
- export { C as CollectionClient } from './collection-client-Bk--pNzW.cjs';
3
- import { N as BaseApi, O as ServerApiOptions, Q as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, V as BanCustomerParams, X as CommunityBan, Y as UnbanCustomerParams, d as ClientState, Z as ClientServerConfig, E as EventsClient, _ as RootServerClientWithEvents } from './types-BKa9z9s2.cjs';
4
- export { A as AddItemParams, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, $ as CollectionFieldSchema, a0 as CollectionSchemaResponse, a1 as EventGuestCancelParams, a2 as EventGuestRegistration, a3 as EventGuestRegistrationResponse, a4 as EventRegistrationAnswerInput, a5 as EventRegistrationAttendeeInput, a6 as EventRegistrationPublic, a7 as EventRegistrationRegisterParams, a8 as EventRegistrationRegisterResponse, a9 as EventsCalendarItem, aa as EventsClientOptions, ab as EventsDateParam, ac as EventsExternalSource, ad as EventsLocation, ae as EventsOccurrenceLocation, af as EventsRangeEvent, ag as EventsRangeOccurrence, ah as EventsRangeParams, ai as EventsRangeResponse, aj as EventsTaxonomyItem, ak as ModerationApi, 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, al as RootServerClient, am as TenantFeatureProgressEvidenceValue, an as TenantFeatureProgressFeature, ao as TenantFeatureProgressGroup, ap as TenantFeatureProgressInput, aq as TenantFeatureProgressItem, ar as TenantFeatureProgressItemState, as as TenantFeatureProgressResponse, at as TenantFeatureProgressSeverity, au as TenantFeatureProgressStatus, av as TenantIntrospectionApi, aw as TenantIntrospectionApiOptions, U as UpdateItemParams } from './types-BKa9z9s2.cjs';
5
- import './payload-types-CqJOgON7.cjs';
1
+ import { S as ServerCollectionClient } from './collection-client-B-qVIBnJ.cjs';
2
+ export { C as CollectionClient } from './collection-client-B-qVIBnJ.cjs';
3
+ import { N as BaseApi, O as ServerApiOptions, Q as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, V as BanCustomerParams, X as CommunityBan, Y as UnbanCustomerParams, d as ClientState, Z as ClientServerConfig, E as EventsClient, _ as RootServerClientWithEvents } from './types-BL7M-EUV.cjs';
4
+ export { A as AddItemParams, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, $ as CollectionFieldSchema, a0 as CollectionSchemaResponse, a1 as EventGuestCancelParams, a2 as EventGuestRegistration, a3 as EventGuestRegistrationResponse, a4 as EventRegistrationAnswerInput, a5 as EventRegistrationAttendeeInput, a6 as EventRegistrationPublic, a7 as EventRegistrationRegisterParams, a8 as EventRegistrationRegisterResponse, a9 as EventsCalendarItem, aa as EventsClientOptions, ab as EventsDateParam, ac as EventsExternalSource, ad as EventsLocation, ae as EventsOccurrenceLocation, af as EventsRangeEvent, ag as EventsRangeOccurrence, ah as EventsRangeParams, ai as EventsRangeResponse, aj as EventsTaxonomyItem, ak as ModerationApi, 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, al as RootServerClient, am as TenantFeatureProgressEvidenceValue, an as TenantFeatureProgressFeature, ao as TenantFeatureProgressGroup, ap as TenantFeatureProgressInput, aq as TenantFeatureProgressItem, ar as TenantFeatureProgressItemState, as as TenantFeatureProgressResponse, at as TenantFeatureProgressSeverity, au as TenantFeatureProgressStatus, av as TenantIntrospectionApi, aw as TenantIntrospectionApiOptions, U as UpdateItemParams } from './types-BL7M-EUV.cjs';
5
+ import './payload-types-C7Ul4ElL.cjs';
6
6
  import './metadata.cjs';
7
- import './const-qGGI7Uii.cjs';
8
- import './types-ByLSG-O3.cjs';
7
+ import './const-BiDujixF.cjs';
8
+ import './types-ChV1t4ei.cjs';
9
9
 
10
10
  type PreviewDetailParams = {
11
11
  collection: string;
package/dist/server.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { S as ServerCollectionClient } from './collection-client-BdcxkW7l.js';
2
- export { C as CollectionClient } from './collection-client-BdcxkW7l.js';
3
- import { N as BaseApi, O as ServerApiOptions, Q as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, V as BanCustomerParams, X as CommunityBan, Y as UnbanCustomerParams, d as ClientState, Z as ClientServerConfig, E as EventsClient, _ as RootServerClientWithEvents } from './types-DgfXb7iV.js';
4
- export { A as AddItemParams, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, $ as CollectionFieldSchema, a0 as CollectionSchemaResponse, a1 as EventGuestCancelParams, a2 as EventGuestRegistration, a3 as EventGuestRegistrationResponse, a4 as EventRegistrationAnswerInput, a5 as EventRegistrationAttendeeInput, a6 as EventRegistrationPublic, a7 as EventRegistrationRegisterParams, a8 as EventRegistrationRegisterResponse, a9 as EventsCalendarItem, aa as EventsClientOptions, ab as EventsDateParam, ac as EventsExternalSource, ad as EventsLocation, ae as EventsOccurrenceLocation, af as EventsRangeEvent, ag as EventsRangeOccurrence, ah as EventsRangeParams, ai as EventsRangeResponse, aj as EventsTaxonomyItem, ak as ModerationApi, 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, al as RootServerClient, am as TenantFeatureProgressEvidenceValue, an as TenantFeatureProgressFeature, ao as TenantFeatureProgressGroup, ap as TenantFeatureProgressInput, aq as TenantFeatureProgressItem, ar as TenantFeatureProgressItemState, as as TenantFeatureProgressResponse, at as TenantFeatureProgressSeverity, au as TenantFeatureProgressStatus, av as TenantIntrospectionApi, aw as TenantIntrospectionApiOptions, U as UpdateItemParams } from './types-DgfXb7iV.js';
5
- import './payload-types-CqJOgON7.js';
1
+ import { S as ServerCollectionClient } from './collection-client-BhCMwIus.js';
2
+ export { C as CollectionClient } from './collection-client-BhCMwIus.js';
3
+ import { N as BaseApi, O as ServerApiOptions, Q as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, V as BanCustomerParams, X as CommunityBan, Y as UnbanCustomerParams, d as ClientState, Z as ClientServerConfig, E as EventsClient, _ as RootServerClientWithEvents } from './types-D5dSNIGs.js';
4
+ export { A as AddItemParams, g as ApplyDiscountParams, h as CheckoutParams, i as ClearCartParams, $ as CollectionFieldSchema, a0 as CollectionSchemaResponse, a1 as EventGuestCancelParams, a2 as EventGuestRegistration, a3 as EventGuestRegistrationResponse, a4 as EventRegistrationAnswerInput, a5 as EventRegistrationAttendeeInput, a6 as EventRegistrationPublic, a7 as EventRegistrationRegisterParams, a8 as EventRegistrationRegisterResponse, a9 as EventsCalendarItem, aa as EventsClientOptions, ab as EventsDateParam, ac as EventsExternalSource, ad as EventsLocation, ae as EventsOccurrenceLocation, af as EventsRangeEvent, ag as EventsRangeOccurrence, ah as EventsRangeParams, ai as EventsRangeResponse, aj as EventsTaxonomyItem, ak as ModerationApi, 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, al as RootServerClient, am as TenantFeatureProgressEvidenceValue, an as TenantFeatureProgressFeature, ao as TenantFeatureProgressGroup, ap as TenantFeatureProgressInput, aq as TenantFeatureProgressItem, ar as TenantFeatureProgressItemState, as as TenantFeatureProgressResponse, at as TenantFeatureProgressSeverity, au as TenantFeatureProgressStatus, av as TenantIntrospectionApi, aw as TenantIntrospectionApiOptions, U as UpdateItemParams } from './types-D5dSNIGs.js';
5
+ import './payload-types-C7Ul4ElL.js';
6
6
  import './metadata.js';
7
- import './const-HwdntWtG.js';
8
- import './types-BMI3M0nb.js';
7
+ import './const-pmHlwm3E.js';
8
+ import './types-Bf2iCjy8.js';
9
9
 
10
10
  type PreviewDetailParams = {
11
11
  collection: string;
package/dist/server.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/client/types.ts
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, 429, 500, 502, 503, 504];
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 createHttpStatusError(status, parsed, details, requestId) {
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
- if (NON_RETRYABLE_STATUSES.includes(response.status)) {
494
- throw createHttpStatusError(
495
- response.status,
496
- parsed,
497
- details,
498
- requestId
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
- if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && retryConfig.retryableStatuses.includes(response.status)) {
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);
@@ -1579,42 +1638,123 @@ var ModerationApi = class extends BaseApi {
1579
1638
  }
1580
1639
  };
1581
1640
 
1641
+ // src/core/api/endpoints.ts
1642
+ var COMMERCE_ENDPOINTS = {
1643
+ orders: {
1644
+ create: "/api/orders/create",
1645
+ update: "/api/orders/update",
1646
+ confirmPayment: "/api/orders/confirm-payment",
1647
+ byPayment: "/api/orders/by-payment",
1648
+ cancel: "/api/orders/cancel",
1649
+ resolveCancelRefund: "/api/orders/resolve-cancel-refund",
1650
+ checkout: "/api/orders/checkout",
1651
+ createFulfillment: "/api/orders/create-fulfillment",
1652
+ updateFulfillment: "/api/orders/update-fulfillment"
1653
+ },
1654
+ transactions: {
1655
+ update: "/api/transactions/update"
1656
+ },
1657
+ returns: {
1658
+ create: "/api/returns/create",
1659
+ update: "/api/returns/update",
1660
+ returnRefund: "/api/returns/return-refund"
1661
+ },
1662
+ fulfillmentOrders: {
1663
+ prepare: "/api/fulfillment-orders/prepare-fulfillment-order"
1664
+ },
1665
+ fulfillments: {
1666
+ bulkImport: "/api/fulfillments/bulk-import"
1667
+ },
1668
+ carts: {
1669
+ mine: "/api/carts/mine",
1670
+ merge: "/api/carts/merge",
1671
+ addItem: "/api/carts/add-item",
1672
+ updateItem: "/api/carts/update-item",
1673
+ removeItem: "/api/carts/remove-item",
1674
+ applyDiscount: "/api/carts/apply-discount",
1675
+ removeDiscount: "/api/carts/remove-discount",
1676
+ clear: "/api/carts/clear"
1677
+ }
1678
+ };
1679
+ var COMMERCE_ENDPOINT_PATHS = Object.values(
1680
+ COMMERCE_ENDPOINTS
1681
+ ).flatMap((group) => Object.values(group));
1682
+
1582
1683
  // src/core/api/cart-api.ts
1583
1684
  var CartApi = class extends CustomerScopedApi {
1584
1685
  constructor(options) {
1585
- super("CartApi", options);
1686
+ super("CartApi", { ...options, requiresCredential: false });
1586
1687
  }
1587
1688
  async execute(endpoint, method, body) {
1588
1689
  return this.request(endpoint, { method, body });
1589
1690
  }
1590
- getCart(cartId) {
1691
+ /**
1692
+ * Create a cart and receive its `cartToken`. Store the token and pass it to
1693
+ * every subsequent cart operation.
1694
+ */
1695
+ createCart(params = {}) {
1696
+ return this.execute("/api/carts/create", "POST", params);
1697
+ }
1698
+ getCart(cartToken) {
1699
+ return this.execute("/api/carts/get", "POST", { cartToken });
1700
+ }
1701
+ merge(params) {
1591
1702
  return this.execute(
1592
- `/api/carts/${cartId}?depth=0&joins=false`,
1593
- "GET"
1703
+ COMMERCE_ENDPOINTS.carts.merge,
1704
+ "POST",
1705
+ params
1706
+ );
1707
+ }
1708
+ /**
1709
+ * Resolve the authenticated customer's active cart by JWT (no `cartToken`
1710
+ * required). Returns the cart and its capability handle, or both `null` when
1711
+ * the customer has no active cart. Requires a customer token.
1712
+ */
1713
+ mine() {
1714
+ return this.execute(
1715
+ COMMERCE_ENDPOINTS.carts.mine,
1716
+ "POST",
1717
+ {}
1594
1718
  );
1595
1719
  }
1596
1720
  addItem(params) {
1597
- return this.execute("/api/carts/add-item", "POST", params);
1721
+ return this.execute(
1722
+ COMMERCE_ENDPOINTS.carts.addItem,
1723
+ "POST",
1724
+ params
1725
+ );
1598
1726
  }
1599
1727
  updateItem(params) {
1600
- return this.execute("/api/carts/update-item", "POST", params);
1728
+ return this.execute(
1729
+ COMMERCE_ENDPOINTS.carts.updateItem,
1730
+ "POST",
1731
+ params
1732
+ );
1601
1733
  }
1602
1734
  removeItem(params) {
1603
1735
  return this.execute(
1604
- "/api/carts/remove-item",
1736
+ COMMERCE_ENDPOINTS.carts.removeItem,
1605
1737
  "POST",
1606
1738
  params
1607
1739
  );
1608
1740
  }
1609
1741
  applyDiscount(params) {
1610
- return this.execute("/api/carts/apply-discount", "POST", params);
1742
+ return this.execute(
1743
+ COMMERCE_ENDPOINTS.carts.applyDiscount,
1744
+ "POST",
1745
+ params
1746
+ );
1611
1747
  }
1612
1748
  removeDiscount(params) {
1613
- return this.execute("/api/carts/remove-discount", "POST", params);
1749
+ return this.execute(
1750
+ COMMERCE_ENDPOINTS.carts.removeDiscount,
1751
+ "POST",
1752
+ params
1753
+ );
1614
1754
  }
1615
1755
  clearCart(params) {
1616
1756
  return this.execute(
1617
- "/api/carts/clear",
1757
+ COMMERCE_ENDPOINTS.carts.clear,
1618
1758
  "POST",
1619
1759
  params
1620
1760
  );
@@ -2425,6 +2565,7 @@ function compareVariantOrder(a, b) {
2425
2565
  function getVariantAvailableForSale(variant) {
2426
2566
  if (variant.isActive === false) return false;
2427
2567
  if (variant.isUnlimited) return true;
2568
+ if (variant.inventoryPolicy === "continue") return true;
2428
2569
  return (variant.stock ?? 0) - (variant.reservedStock ?? 0) > 0;
2429
2570
  }
2430
2571
  function isVariantAvailableForSale(variant) {
@@ -2890,26 +3031,61 @@ var OrderApi = class extends BaseApi {
2890
3031
  const { idempotencyKey } = params;
2891
3032
  const normalizedBody = normalizeCreateOrderBody(params);
2892
3033
  return this.request(
2893
- "/api/orders/create",
3034
+ COMMERCE_ENDPOINTS.orders.create,
2894
3035
  normalizedBody,
2895
3036
  idempotencyRequestOptions(idempotencyKey)
2896
3037
  );
2897
3038
  }
2898
3039
  updateOrder(params) {
2899
- return this.request("/api/orders/update", params);
3040
+ return this.request(COMMERCE_ENDPOINTS.orders.update, params);
2900
3041
  }
2901
3042
  updateTransaction(params) {
2902
- return this.request("/api/transactions/update", params);
3043
+ return this.request(
3044
+ COMMERCE_ENDPOINTS.transactions.update,
3045
+ params
3046
+ );
2903
3047
  }
2904
3048
  confirmPayment(params) {
2905
3049
  const { body, idempotencyKey } = splitIdempotencyKey(params);
2906
3050
  const headerKey = idempotencyKey ?? params.providerEventId;
2907
3051
  return this.request(
2908
- "/api/orders/confirm-payment",
3052
+ COMMERCE_ENDPOINTS.orders.confirmPayment,
2909
3053
  body,
2910
3054
  idempotencyRequestOptions(headerKey)
2911
3055
  );
2912
3056
  }
3057
+ /**
3058
+ * Resolve an order + its payment transaction by PG payment id. Replaces raw
3059
+ * `transactions.find({ where: { pgPaymentId } })` + a local file index in
3060
+ * storefronts. Server-only (sk01_) read of the full populated Order.
3061
+ */
3062
+ getByPaymentId(params) {
3063
+ const query = new URLSearchParams({
3064
+ pgProvider: params.pgProvider,
3065
+ pgPaymentId: params.pgPaymentId
3066
+ }).toString();
3067
+ return this.request(
3068
+ `${COMMERCE_ENDPOINTS.orders.byPayment}?${query}`,
3069
+ void 0,
3070
+ { method: "GET" }
3071
+ );
3072
+ }
3073
+ /**
3074
+ * Composed facade: confirm a provider payment, then resolve the
3075
+ * depth-populated order/transaction by the same payment id. `confirmPayment`'s
3076
+ * wire response carries only IDs (its contract is `.strict()`); this returns
3077
+ * the populated `Order` so storefronts stop reconstructing order state
3078
+ * locally. Two round trips by design — the alternative (widening the strict
3079
+ * confirm-payment wire contract to embed a full Order) is rejected.
3080
+ */
3081
+ async confirmPaymentReturningOrder(params) {
3082
+ const confirmation = await this.confirmPayment(params);
3083
+ const { order, transaction } = await this.getByPaymentId({
3084
+ pgProvider: params.pgProvider,
3085
+ pgPaymentId: params.pgPaymentId
3086
+ });
3087
+ return { ...confirmation, order, transaction };
3088
+ }
2913
3089
  cancelOrder(params) {
2914
3090
  const { idempotencyKey } = params;
2915
3091
  const body = {
@@ -2918,14 +3094,14 @@ var OrderApi = class extends BaseApi {
2918
3094
  reasonDetail: params.reasonDetail
2919
3095
  };
2920
3096
  return this.request(
2921
- "/api/orders/cancel",
3097
+ COMMERCE_ENDPOINTS.orders.cancel,
2922
3098
  body,
2923
3099
  idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
2924
3100
  );
2925
3101
  }
2926
3102
  resolveCancelRefund(params) {
2927
3103
  return this.request(
2928
- "/api/orders/resolve-cancel-refund",
3104
+ COMMERCE_ENDPOINTS.orders.resolveCancelRefund,
2929
3105
  {
2930
3106
  orderNumber: params.orderNumber,
2931
3107
  idempotencyKey: params.idempotencyKey,
@@ -2946,7 +3122,7 @@ var OrderApi = class extends BaseApi {
2946
3122
  checkout(params) {
2947
3123
  const { body, idempotencyKey } = splitIdempotencyKey(params);
2948
3124
  return this.request(
2949
- "/api/orders/checkout",
3125
+ COMMERCE_ENDPOINTS.orders.checkout,
2950
3126
  body,
2951
3127
  idempotencyRequestOptions(idempotencyKey)
2952
3128
  );
@@ -2954,30 +3130,33 @@ var OrderApi = class extends BaseApi {
2954
3130
  createFulfillment(params) {
2955
3131
  const { body, idempotencyKey } = splitIdempotencyKey(params);
2956
3132
  return this.request(
2957
- "/api/orders/create-fulfillment",
3133
+ COMMERCE_ENDPOINTS.orders.createFulfillment,
2958
3134
  body,
2959
3135
  idempotencyRequestOptions(idempotencyKey)
2960
3136
  );
2961
3137
  }
2962
3138
  prepareFulfillmentOrder(params) {
2963
3139
  return this.request(
2964
- "/api/fulfillment-orders/prepare-fulfillment-order",
3140
+ COMMERCE_ENDPOINTS.fulfillmentOrders.prepare,
2965
3141
  params
2966
3142
  );
2967
3143
  }
2968
3144
  updateFulfillment(params) {
2969
- return this.request("/api/orders/update-fulfillment", params);
3145
+ return this.request(
3146
+ COMMERCE_ENDPOINTS.orders.updateFulfillment,
3147
+ params
3148
+ );
2970
3149
  }
2971
3150
  bulkImportFulfillments(params) {
2972
3151
  return this.request(
2973
- "/api/fulfillments/bulk-import",
3152
+ COMMERCE_ENDPOINTS.fulfillments.bulkImport,
2974
3153
  params
2975
3154
  );
2976
3155
  }
2977
3156
  returnWithRefund(params) {
2978
3157
  const { body, idempotencyKey } = splitIdempotencyKey(params);
2979
3158
  return this.request(
2980
- "/api/returns/return-refund",
3159
+ COMMERCE_ENDPOINTS.returns.returnRefund,
2981
3160
  body,
2982
3161
  idempotencyRequestOptions(idempotencyKey)
2983
3162
  );
@@ -2985,13 +3164,13 @@ var OrderApi = class extends BaseApi {
2985
3164
  createReturn(params) {
2986
3165
  const { body, idempotencyKey } = splitIdempotencyKey(params);
2987
3166
  return this.request(
2988
- "/api/returns/create",
3167
+ COMMERCE_ENDPOINTS.returns.create,
2989
3168
  body,
2990
3169
  idempotencyRequestOptions(idempotencyKey)
2991
3170
  );
2992
3171
  }
2993
3172
  updateReturn(params) {
2994
- return this.request("/api/returns/update", params);
3173
+ return this.request(COMMERCE_ENDPOINTS.returns.update, params);
2995
3174
  }
2996
3175
  };
2997
3176
 
@@ -3077,13 +3256,16 @@ var ServerCommerceClient = class {
3077
3256
  upsert: productApi.upsert.bind(productApi)
3078
3257
  };
3079
3258
  this.cart = {
3259
+ create: cartApi.createCart.bind(cartApi),
3080
3260
  get: cartApi.getCart.bind(cartApi),
3081
3261
  addItem: cartApi.addItem.bind(cartApi),
3082
3262
  updateItem: cartApi.updateItem.bind(cartApi),
3083
3263
  removeItem: cartApi.removeItem.bind(cartApi),
3084
3264
  applyDiscount: cartApi.applyDiscount.bind(cartApi),
3085
3265
  removeDiscount: cartApi.removeDiscount.bind(cartApi),
3086
- clear: cartApi.clearCart.bind(cartApi)
3266
+ clear: cartApi.clearCart.bind(cartApi),
3267
+ merge: cartApi.merge.bind(cartApi),
3268
+ mine: cartApi.mine.bind(cartApi)
3087
3269
  };
3088
3270
  this.orders = {
3089
3271
  checkout: orderApi.checkout.bind(orderApi),
@@ -3091,6 +3273,8 @@ var ServerCommerceClient = class {
3091
3273
  update: orderApi.updateOrder.bind(orderApi),
3092
3274
  updateTransaction: orderApi.updateTransaction.bind(orderApi),
3093
3275
  confirmPayment: orderApi.confirmPayment.bind(orderApi),
3276
+ confirmPaymentReturningOrder: orderApi.confirmPaymentReturningOrder.bind(orderApi),
3277
+ getByPaymentId: orderApi.getByPaymentId.bind(orderApi),
3094
3278
  cancelOrder: orderApi.cancelOrder.bind(orderApi),
3095
3279
  resolveCancelRefund: orderApi.resolveCancelRefund.bind(orderApi),
3096
3280
  createFulfillment: orderApi.createFulfillment.bind(orderApi),