@01.software/sdk 0.49.0 → 0.51.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 (74) hide show
  1. package/CHANGELOG.md +130 -1
  2. package/MIGRATION.md +56 -0
  3. package/README.md +215 -45
  4. package/dist/client.cjs +188 -137
  5. package/dist/client.cjs.map +1 -1
  6. package/dist/client.d.cts +6 -6
  7. package/dist/client.d.ts +6 -6
  8. package/dist/client.js +188 -137
  9. package/dist/client.js.map +1 -1
  10. package/dist/{collection-client-XfGLPuTf.d.cts → collection-client-CWAeuzV4.d.cts} +6 -4
  11. package/dist/{collection-client-DnDt6EQz.d.ts → collection-client-hYvVfHIm.d.ts} +6 -4
  12. package/dist/{const-DCNV5Kq7.d.ts → const-D8LixhAJ.d.cts} +5 -5
  13. package/dist/{const-CBba4lDo.d.cts → const-JD8obaKg.d.ts} +5 -5
  14. package/dist/embedded-admin/server.cjs +306 -0
  15. package/dist/embedded-admin/server.cjs.map +1 -0
  16. package/dist/embedded-admin/server.d.cts +33 -0
  17. package/dist/embedded-admin/server.d.ts +33 -0
  18. package/dist/embedded-admin/server.js +288 -0
  19. package/dist/embedded-admin/server.js.map +1 -0
  20. package/dist/embedded-admin.cjs +400 -0
  21. package/dist/embedded-admin.cjs.map +1 -0
  22. package/dist/embedded-admin.d.cts +61 -0
  23. package/dist/embedded-admin.d.ts +61 -0
  24. package/dist/embedded-admin.js +377 -0
  25. package/dist/embedded-admin.js.map +1 -0
  26. package/dist/errors.cjs +1 -0
  27. package/dist/errors.cjs.map +1 -1
  28. package/dist/errors.d.cts +3 -3
  29. package/dist/errors.d.ts +3 -3
  30. package/dist/errors.js +1 -0
  31. package/dist/errors.js.map +1 -1
  32. package/dist/{index-CbKyoEzy.d.cts → index-B0Hjh3Ey.d.ts} +72 -10
  33. package/dist/{index-DUuIqUS8.d.ts → index-Bu0kCc6o.d.cts} +72 -10
  34. package/dist/index.cjs +320 -383
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -66
  37. package/dist/index.d.ts +8 -66
  38. package/dist/index.js +320 -383
  39. package/dist/index.js.map +1 -1
  40. package/dist/{payload-types-MKbx5MuJ.d.cts → payload-types-BOsckg8B.d.cts} +263 -54
  41. package/dist/{payload-types-MKbx5MuJ.d.ts → payload-types-BOsckg8B.d.ts} +263 -54
  42. package/dist/query.cjs +94 -70
  43. package/dist/query.cjs.map +1 -1
  44. package/dist/query.d.cts +5 -5
  45. package/dist/query.d.ts +5 -5
  46. package/dist/query.js +94 -70
  47. package/dist/query.js.map +1 -1
  48. package/dist/realtime.d.cts +2 -2
  49. package/dist/realtime.d.ts +2 -2
  50. package/dist/server.cjs +404 -162
  51. package/dist/server.cjs.map +1 -1
  52. package/dist/server.d.cts +7 -7
  53. package/dist/server.d.ts +7 -7
  54. package/dist/server.js +404 -162
  55. package/dist/server.js.map +1 -1
  56. package/dist/storefront-cache.cjs +1 -0
  57. package/dist/storefront-cache.cjs.map +1 -1
  58. package/dist/storefront-cache.js +1 -0
  59. package/dist/storefront-cache.js.map +1 -1
  60. package/dist/{types-L_nh-ED7.d.ts → types-5ZlcAFuU.d.ts} +2 -2
  61. package/dist/{types-BKr_2avj.d.cts → types-B14sEt1z.d.cts} +2 -2
  62. package/dist/{types-1UeOk1Uy.d.cts → types-Bj8j7VHU.d.ts} +79 -23
  63. package/dist/{types-Du4s5anw.d.ts → types-CM5qiR2k.d.cts} +79 -23
  64. package/dist/ui/form.d.cts +1 -1
  65. package/dist/ui/form.d.ts +1 -1
  66. package/dist/ui/video.d.cts +1 -1
  67. package/dist/ui/video.d.ts +1 -1
  68. package/dist/webhook.cjs +124 -80
  69. package/dist/webhook.cjs.map +1 -1
  70. package/dist/webhook.d.cts +21 -5
  71. package/dist/webhook.d.ts +21 -5
  72. package/dist/webhook.js +124 -80
  73. package/dist/webhook.js.map +1 -1
  74. package/package.json +23 -2
package/dist/server.cjs CHANGED
@@ -28,6 +28,7 @@ __export(server_exports, {
28
28
  ServerCollectionClient: () => ServerCollectionClient,
29
29
  ServerCommerceClient: () => ServerCommerceClient,
30
30
  ServerPreviewClient: () => ServerPreviewClient,
31
+ TENANT_CONTEXT_PATH: () => TENANT_CONTEXT_PATH,
31
32
  TenantIntrospectionApi: () => TenantIntrospectionApi,
32
33
  createServerClient: () => createServerClient,
33
34
  isApiError: () => isApiError,
@@ -147,6 +148,7 @@ var COMMERCE_ERROR_CODES = [
147
148
  "payment_session_not_cancelable",
148
149
  "payment_session_conflict",
149
150
  "provider_identity_mismatch",
151
+ "managed_refund_attestation_forbidden",
150
152
  "payment_method_unavailable",
151
153
  "provider_unavailable",
152
154
  "lock_timeout",
@@ -689,11 +691,11 @@ function parseRetryAfter(response) {
689
691
  permitsAutomaticRetry: seconds <= MAX_AUTOMATIC_RETRY_AFTER_SECONDS
690
692
  };
691
693
  }
692
- function mapResponseToError(status, parsed, details, requestId, retryAfter, errorFamily) {
694
+ function mapResponseToError(status, parsed, details, requestId, retryAfter, canonicalCommerceError) {
693
695
  const errorDetails = {
694
696
  ...details,
695
697
  ...parsed.errors && { errors: parsed.errors },
696
- ...errorFamily !== "commerce" && parsed.body && { body: parsed.body }
698
+ ...!canonicalCommerceError && parsed.body && { body: parsed.body }
697
699
  };
698
700
  const suggestion = getParsedErrorSuggestion(status, parsed);
699
701
  const finalize = (error) => {
@@ -701,7 +703,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
701
703
  if (retryAfter !== void 0) {
702
704
  Object.assign(withRequestId, { retryAfter });
703
705
  }
704
- return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
706
+ return canonicalCommerceError ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
705
707
  };
706
708
  if (status === 400 || status === 422) {
707
709
  return finalize(
@@ -807,6 +809,7 @@ async function httpFetch(url, options) {
807
809
  retry,
808
810
  onUnauthorized,
809
811
  errorFamily,
812
+ typedCommerceErrorReasons,
810
813
  ...requestInit
811
814
  } = options || {};
812
815
  const baseUrl = resolveApiUrl(apiUrl);
@@ -860,7 +863,8 @@ async function httpFetch(url, options) {
860
863
  });
861
864
  if (!response.ok) {
862
865
  const parsed = await parseErrorBody(response);
863
- const commerceEnvelope = errorFamily === "commerce" ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
866
+ const canonicalCommerceError = errorFamily === "commerce" || typeof parsed.reason === "string" && typedCommerceErrorReasons?.includes(parsed.reason) === true;
867
+ const commerceEnvelope = canonicalCommerceError ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
864
868
  if (isUsageLimitExceededResponse(response)) {
865
869
  const limit = parseInt(
866
870
  response.headers.get("X-Usage-Limit") || "0",
@@ -888,7 +892,7 @@ async function httpFetch(url, options) {
888
892
  ),
889
893
  requestId
890
894
  );
891
- throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
895
+ throw canonicalCommerceError ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
892
896
  }
893
897
  if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
894
898
  hasRetried401 = true;
@@ -913,7 +917,7 @@ async function httpFetch(url, options) {
913
917
  details,
914
918
  requestId,
915
919
  retryAfter.seconds,
916
- errorFamily
920
+ canonicalCommerceError
917
921
  );
918
922
  const method2 = (requestInit.method || "GET").toUpperCase();
919
923
  const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
@@ -1091,15 +1095,15 @@ var HttpClient = class {
1091
1095
  throw err;
1092
1096
  }
1093
1097
  }
1094
- buildUrl(endpoint2, options) {
1095
- if (!options) return endpoint2;
1098
+ buildUrl(endpoint, options) {
1099
+ if (!options) return endpoint;
1096
1100
  const { fallbackLocale, ...rest } = options;
1097
1101
  const queryOptions = fallbackLocale === void 0 ? rest : {
1098
1102
  ...rest,
1099
1103
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1100
1104
  };
1101
1105
  const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
1102
- return queryString ? `${endpoint2}${queryString}` : endpoint2;
1106
+ return queryString ? `${endpoint}${queryString}` : endpoint;
1103
1107
  }
1104
1108
  assertJsonResponse(response) {
1105
1109
  const contentType = response.headers.get("content-type");
@@ -1290,16 +1294,16 @@ var CollectionQueryBuilder = class {
1290
1294
  * @returns Payload CMS mutation response with doc and message
1291
1295
  */
1292
1296
  async create(data, options) {
1293
- const endpoint2 = `/api/${String(this.collection)}`;
1297
+ const endpoint = `/api/${String(this.collection)}`;
1294
1298
  if (options?.file) {
1295
1299
  return this.api.requestCreateWithFile(
1296
- endpoint2,
1300
+ endpoint,
1297
1301
  data,
1298
1302
  options.file,
1299
1303
  options.filename
1300
1304
  );
1301
1305
  }
1302
- return this.api.requestCreate(endpoint2, data);
1306
+ return this.api.requestCreate(endpoint, data);
1303
1307
  }
1304
1308
  /**
1305
1309
  * Update a document by ID
@@ -1307,16 +1311,16 @@ var CollectionQueryBuilder = class {
1307
1311
  * @returns Payload CMS mutation response with doc and message
1308
1312
  */
1309
1313
  async update(id, data, options) {
1310
- const endpoint2 = `/api/${String(this.collection)}/${String(id)}`;
1314
+ const endpoint = `/api/${String(this.collection)}/${String(id)}`;
1311
1315
  if (options?.file) {
1312
1316
  return this.api.requestUpdateWithFile(
1313
- endpoint2,
1317
+ endpoint,
1314
1318
  data,
1315
1319
  options.file,
1316
1320
  options.filename
1317
1321
  );
1318
1322
  }
1319
- return this.api.requestUpdate(endpoint2, data);
1323
+ return this.api.requestUpdate(endpoint, data);
1320
1324
  }
1321
1325
  /**
1322
1326
  * Count documents
@@ -1412,8 +1416,8 @@ var CollectionClient = class extends HttpClient {
1412
1416
  * Find documents (list query)
1413
1417
  * GET /api/{collection}
1414
1418
  */
1415
- async requestFind(endpoint2, options) {
1416
- const url = this.buildUrl(endpoint2, options);
1419
+ async requestFind(endpoint, options) {
1420
+ const url = this.buildUrl(endpoint, options);
1417
1421
  const response = await this.fetchWithTracking(url, {
1418
1422
  ...this.defaultOptions,
1419
1423
  method: "GET"
@@ -1424,8 +1428,8 @@ var CollectionClient = class extends HttpClient {
1424
1428
  * Find-like response from a custom endpoint
1425
1429
  * POST /api/...custom-endpoint
1426
1430
  */
1427
- async requestFindEndpoint(endpoint2, data) {
1428
- const response = await this.fetchWithTracking(endpoint2, {
1431
+ async requestFindEndpoint(endpoint, data) {
1432
+ const response = await this.fetchWithTracking(endpoint, {
1429
1433
  ...this.defaultOptions,
1430
1434
  method: "POST",
1431
1435
  body: data ? JSON.stringify(data) : void 0
@@ -1435,8 +1439,8 @@ var CollectionClient = class extends HttpClient {
1435
1439
  /**
1436
1440
  * Find-like response from a cacheable GET custom endpoint.
1437
1441
  */
1438
- async requestFindEndpointGet(endpoint2) {
1439
- const response = await this.fetchWithTracking(endpoint2, {
1442
+ async requestFindEndpointGet(endpoint) {
1443
+ const response = await this.fetchWithTracking(endpoint, {
1440
1444
  ...this.defaultOptions,
1441
1445
  method: "GET"
1442
1446
  });
@@ -1446,8 +1450,8 @@ var CollectionClient = class extends HttpClient {
1446
1450
  * Find document by ID
1447
1451
  * GET /api/{collection}/{id}
1448
1452
  */
1449
- async requestFindById(endpoint2, options) {
1450
- const url = this.buildUrl(endpoint2, options);
1453
+ async requestFindById(endpoint, options) {
1454
+ const url = this.buildUrl(endpoint, options);
1451
1455
  const response = await this.fetchWithTracking(url, {
1452
1456
  ...this.defaultOptions,
1453
1457
  method: "GET"
@@ -1458,8 +1462,8 @@ var CollectionClient = class extends HttpClient {
1458
1462
  * Create document
1459
1463
  * POST /api/{collection}
1460
1464
  */
1461
- async requestCreate(endpoint2, data) {
1462
- const response = await this.fetchWithTracking(endpoint2, {
1465
+ async requestCreate(endpoint, data) {
1466
+ const response = await this.fetchWithTracking(endpoint, {
1463
1467
  ...this.defaultOptions,
1464
1468
  method: "POST",
1465
1469
  body: data ? JSON.stringify(data) : void 0
@@ -1470,8 +1474,8 @@ var CollectionClient = class extends HttpClient {
1470
1474
  * Update document
1471
1475
  * PATCH /api/{collection}/{id}
1472
1476
  */
1473
- async requestUpdate(endpoint2, data) {
1474
- const response = await this.fetchWithTracking(endpoint2, {
1477
+ async requestUpdate(endpoint, data) {
1478
+ const response = await this.fetchWithTracking(endpoint, {
1475
1479
  ...this.defaultOptions,
1476
1480
  method: "PATCH",
1477
1481
  body: data ? JSON.stringify(data) : void 0
@@ -1482,8 +1486,8 @@ var CollectionClient = class extends HttpClient {
1482
1486
  * Count documents
1483
1487
  * GET /api/{collection}/count
1484
1488
  */
1485
- async requestCount(endpoint2, options) {
1486
- const url = this.buildUrl(endpoint2, options);
1489
+ async requestCount(endpoint, options) {
1490
+ const url = this.buildUrl(endpoint, options);
1487
1491
  const response = await this.fetchWithTracking(url, {
1488
1492
  ...this.defaultOptions,
1489
1493
  method: "GET"
@@ -1494,8 +1498,8 @@ var CollectionClient = class extends HttpClient {
1494
1498
  * Update multiple documents (bulk update)
1495
1499
  * PATCH /api/{collection}
1496
1500
  */
1497
- async requestUpdateMany(endpoint2, data) {
1498
- const response = await this.fetchWithTracking(endpoint2, {
1501
+ async requestUpdateMany(endpoint, data) {
1502
+ const response = await this.fetchWithTracking(endpoint, {
1499
1503
  ...this.defaultOptions,
1500
1504
  method: "PATCH",
1501
1505
  body: JSON.stringify(data)
@@ -1506,8 +1510,8 @@ var CollectionClient = class extends HttpClient {
1506
1510
  * Delete document
1507
1511
  * DELETE /api/{collection}/{id}
1508
1512
  */
1509
- async requestDelete(endpoint2, options) {
1510
- const url = this.buildUrl(endpoint2, options);
1513
+ async requestDelete(endpoint, options) {
1514
+ const url = this.buildUrl(endpoint, options);
1511
1515
  const response = await this.fetchWithTracking(url, {
1512
1516
  ...this.defaultOptions,
1513
1517
  method: "DELETE"
@@ -1518,8 +1522,8 @@ var CollectionClient = class extends HttpClient {
1518
1522
  * Delete multiple documents (bulk delete)
1519
1523
  * DELETE /api/{collection}
1520
1524
  */
1521
- async requestDeleteMany(endpoint2, data) {
1522
- const response = await this.fetchWithTracking(endpoint2, {
1525
+ async requestDeleteMany(endpoint, data) {
1526
+ const response = await this.fetchWithTracking(endpoint, {
1523
1527
  ...this.defaultOptions,
1524
1528
  method: "DELETE",
1525
1529
  body: JSON.stringify(data)
@@ -1530,8 +1534,8 @@ var CollectionClient = class extends HttpClient {
1530
1534
  * Create document with file upload
1531
1535
  * POST /api/{collection} (multipart/form-data)
1532
1536
  */
1533
- async requestCreateWithFile(endpoint2, data, file, filename) {
1534
- const response = await this.fetchWithTracking(endpoint2, {
1537
+ async requestCreateWithFile(endpoint, data, file, filename) {
1538
+ const response = await this.fetchWithTracking(endpoint, {
1535
1539
  ...this.defaultOptions,
1536
1540
  method: "POST",
1537
1541
  body: buildPayloadFormData(data, file, filename)
@@ -1542,8 +1546,8 @@ var CollectionClient = class extends HttpClient {
1542
1546
  * Update document with file upload
1543
1547
  * PATCH /api/{collection}/{id} (multipart/form-data)
1544
1548
  */
1545
- async requestUpdateWithFile(endpoint2, data, file, filename) {
1546
- const response = await this.fetchWithTracking(endpoint2, {
1549
+ async requestUpdateWithFile(endpoint, data, file, filename) {
1550
+ const response = await this.fetchWithTracking(endpoint, {
1547
1551
  ...this.defaultOptions,
1548
1552
  method: "PATCH",
1549
1553
  body: buildPayloadFormData(data, file, filename)
@@ -1558,7 +1562,7 @@ var ServerCollectionClient = class extends CollectionClient {
1558
1562
  };
1559
1563
 
1560
1564
  // src/core/api/parse-response.ts
1561
- async function parseApiResponse(response, endpoint2, options = {}) {
1565
+ async function parseApiResponse(response, endpoint, options = {}) {
1562
1566
  if (response.status === 204 || response.headers.get("content-length") === "0") {
1563
1567
  return void 0;
1564
1568
  }
@@ -1567,7 +1571,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1567
1571
  parsed = await response.json();
1568
1572
  } catch {
1569
1573
  throw createApiError(
1570
- `Invalid JSON response from ${endpoint2}`,
1574
+ `Invalid JSON response from ${endpoint}`,
1571
1575
  response.status,
1572
1576
  void 0,
1573
1577
  "Server returned an invalid response.",
@@ -1617,6 +1621,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1617
1621
 
1618
1622
  // ../../internal/http-contracts/src/index.ts
1619
1623
  var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
1624
+ var PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE = "application/vnd.01software.portone-action-capabilities.v1+json";
1620
1625
  var operation = (collection, method, path, errorFamily) => Object.freeze({
1621
1626
  [operationBrand]: true,
1622
1627
  collection,
@@ -1625,6 +1630,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
1625
1630
  ...errorFamily && { errorFamily }
1626
1631
  });
1627
1632
  var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
1633
+ var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
1634
+ ...operation(collection, method, path),
1635
+ typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
1636
+ });
1628
1637
  var COMMERCE_ENDPOINT_OPERATIONS = {
1629
1638
  products: {
1630
1639
  detail: operation("products", "get", "/detail"),
@@ -1656,7 +1665,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1656
1665
  confirmPayment: operation("orders", "post", "/confirm-payment"),
1657
1666
  byPayment: operation("orders", "get", "/by-payment"),
1658
1667
  cancel: operation("orders", "post", "/cancel"),
1659
- resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
1668
+ resolveCancelRefund: selectiveCommerceOperation(
1669
+ "orders",
1670
+ "post",
1671
+ "/resolve-cancel-refund",
1672
+ ["managed_refund_attestation_forbidden"]
1673
+ ),
1660
1674
  checkout: strictCommerceOperation("orders", "post", "/checkout"),
1661
1675
  createFulfillment: operation("orders", "post", "/create-fulfillment"),
1662
1676
  updateFulfillment: operation("orders", "post", "/update-fulfillment")
@@ -1727,6 +1741,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1727
1741
  "payment-sessions",
1728
1742
  "post",
1729
1743
  "/server/confirm"
1744
+ ),
1745
+ findPortOne: strictCommerceOperation(
1746
+ "payment-sessions",
1747
+ "post",
1748
+ "/server/portone/find"
1749
+ ),
1750
+ reconcilePortOne: strictCommerceOperation(
1751
+ "payment-sessions",
1752
+ "post",
1753
+ "/server/portone/reconcile"
1730
1754
  )
1731
1755
  },
1732
1756
  custom: {
@@ -1746,12 +1770,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1746
1770
  validate: operation("discounts", "post", "/validate")
1747
1771
  }
1748
1772
  };
1773
+ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1774
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
1775
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
1776
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
1777
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
1778
+ ]);
1749
1779
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1750
1780
  subscribe: operation(null, "post", "/memberships/subscribe"),
1751
1781
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1752
1782
  me: operation(null, "get", "/memberships/me")
1753
1783
  };
1784
+ var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1785
+ show: operation("tenants", "get", "/embedded-admin-app"),
1786
+ configure: operation("tenants", "patch", "/embedded-admin-app"),
1787
+ disable: operation("tenants", "delete", "/embedded-admin-app")
1788
+ };
1754
1789
  var EVENTS_ENDPOINT_OPERATIONS = {
1790
+ events: {
1791
+ convertSchedule: operation("events", "post", "/:id/schedule")
1792
+ },
1755
1793
  occurrences: {
1756
1794
  range: operation("event-occurrences", "get", "/range"),
1757
1795
  admissionAvailability: operation(
@@ -1792,46 +1830,54 @@ function resolveOperationMethod(descriptor) {
1792
1830
  }
1793
1831
 
1794
1832
  // src/core/api/endpoints.ts
1795
- var endpoint = (method, path) => ({ method, path });
1796
1833
  var sharedEndpoint = (descriptor) => descriptor;
1797
- function resolveOperationMethod2(descriptor) {
1798
- return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
1799
- }
1800
1834
  function resolveOperationErrorFamily(descriptor) {
1801
- return "collection" in descriptor ? descriptor.errorFamily : void 0;
1835
+ return descriptor.errorFamily;
1802
1836
  }
1803
- function resolveOperationPath2(descriptor, options) {
1804
- if ("collection" in descriptor) {
1805
- return resolveOperationPath(descriptor, options);
1806
- }
1807
- const query = options?.query?.toString().replace(/^\?/, "");
1808
- return query ? `${descriptor.path}?${query}` : descriptor.path;
1837
+ function resolveOperationTypedCommerceErrorReasons(descriptor) {
1838
+ return descriptor.typedCommerceErrorReasons;
1809
1839
  }
1810
1840
  var COMMERCE_ENDPOINTS = {
1811
1841
  products: {
1812
- detail: endpoint("GET", "/api/products/detail"),
1813
- detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
1814
- listingGroups: endpoint("GET", "/api/products/listing-groups"),
1815
- listingGroupsCatalog: endpoint(
1816
- "GET",
1817
- "/api/products/listing-groups/catalog"
1842
+ detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
1843
+ detailCatalog: sharedEndpoint(
1844
+ COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
1845
+ ),
1846
+ listingGroups: sharedEndpoint(
1847
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
1848
+ ),
1849
+ listingGroupsCatalog: sharedEndpoint(
1850
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
1818
1851
  ),
1819
- listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
1820
- listingGroupsQueryCatalog: endpoint(
1821
- "GET",
1822
- "/api/products/listing-groups/query/catalog"
1852
+ // The manifest keeps the GET read and the POST body-query apart; this
1853
+ // semantic name has always resolved to the GET one.
1854
+ listingGroupsQuery: sharedEndpoint(
1855
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
1823
1856
  ),
1824
- stockCheck: endpoint("POST", "/api/products/stock-check"),
1825
- stockSnapshot: endpoint("GET", "/api/products/stock"),
1826
- upsert: endpoint("POST", "/api/products/upsert")
1857
+ listingGroupsQueryCatalog: sharedEndpoint(
1858
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
1859
+ ),
1860
+ stockCheck: sharedEndpoint(
1861
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
1862
+ ),
1863
+ stockSnapshot: sharedEndpoint(
1864
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
1865
+ ),
1866
+ upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
1827
1867
  },
1828
1868
  orders: {
1829
- update: endpoint("POST", "/api/orders/update"),
1830
- byPayment: endpoint("GET", "/api/orders/by-payment"),
1831
- cancel: endpoint("POST", "/api/orders/cancel"),
1832
- resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
1833
- createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
1834
- updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
1869
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
1870
+ byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
1871
+ cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
1872
+ resolveCancelRefund: sharedEndpoint(
1873
+ COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
1874
+ ),
1875
+ createFulfillment: sharedEndpoint(
1876
+ COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
1877
+ ),
1878
+ updateFulfillment: sharedEndpoint(
1879
+ COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
1880
+ )
1835
1881
  },
1836
1882
  checkouts: {
1837
1883
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
@@ -1843,18 +1889,21 @@ var COMMERCE_ENDPOINTS = {
1843
1889
  }
1844
1890
  },
1845
1891
  returns: {
1846
- create: endpoint("POST", "/api/returns/create"),
1847
- update: endpoint("POST", "/api/returns/update"),
1848
- returnRefund: endpoint("POST", "/api/returns/return-refund")
1892
+ create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
1893
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
1894
+ returnRefund: sharedEndpoint(
1895
+ COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
1896
+ )
1849
1897
  },
1850
1898
  fulfillmentOrders: {
1851
- prepare: endpoint(
1852
- "POST",
1853
- "/api/fulfillment-orders/prepare-fulfillment-order"
1899
+ prepare: sharedEndpoint(
1900
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
1854
1901
  )
1855
1902
  },
1856
1903
  fulfillments: {
1857
- bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
1904
+ bulkImport: sharedEndpoint(
1905
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
1906
+ )
1858
1907
  },
1859
1908
  carts: {
1860
1909
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
@@ -1919,42 +1968,21 @@ var COMMERCE_ENDPOINTS = {
1919
1968
  ),
1920
1969
  confirm: sharedEndpoint(
1921
1970
  COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
1971
+ ),
1972
+ findPortOne: sharedEndpoint(
1973
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
1974
+ ),
1975
+ reconcilePortOne: sharedEndpoint(
1976
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
1922
1977
  )
1923
1978
  }
1924
1979
  },
1925
1980
  shippingPolicies: {
1926
- calculate: endpoint("POST", "/api/shipping-policies/calculate")
1981
+ calculate: sharedEndpoint(
1982
+ COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
1983
+ )
1927
1984
  }
1928
1985
  };
1929
- function isCommerceEndpointDescriptor(value) {
1930
- if (!value || typeof value !== "object") return false;
1931
- const candidate = value;
1932
- return typeof candidate.method === "string" && typeof candidate.path === "string";
1933
- }
1934
- function flattenEndpointPaths(value) {
1935
- if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
1936
- if (!value || typeof value !== "object") return [];
1937
- return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
1938
- }
1939
- function flattenEndpointDescriptors(value) {
1940
- if (isCommerceEndpointDescriptor(value)) return [value];
1941
- if (!value || typeof value !== "object") return [];
1942
- return Object.values(value).flatMap(
1943
- (entry) => flattenEndpointDescriptors(entry)
1944
- );
1945
- }
1946
- var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
1947
- var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
1948
- var MEMBERSHIP_ENDPOINTS = {
1949
- subscribe: "/api/memberships/subscribe",
1950
- cancel: (id) => `/api/memberships/${id}/cancel`,
1951
- me: "/api/memberships/me"
1952
- };
1953
- var MEMBERSHIP_ENDPOINT_PATHS = [
1954
- MEMBERSHIP_ENDPOINTS.subscribe,
1955
- MEMBERSHIP_ENDPOINTS.cancel(":id"),
1956
- MEMBERSHIP_ENDPOINTS.me
1957
- ];
1958
1986
 
1959
1987
  // src/core/api/customer-scoped-api.ts
1960
1988
  var CustomerScopedTransport = class {
@@ -1975,10 +2003,10 @@ var CustomerScopedTransport = class {
1975
2003
  this.onUnauthorized = options.onUnauthorized;
1976
2004
  this.onRequestId = options.onRequestId;
1977
2005
  }
1978
- async request(endpoint2, options) {
2006
+ async request(endpoint, options) {
1979
2007
  const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1980
2008
  try {
1981
- const response = await httpFetch(endpoint2, {
2009
+ const response = await httpFetch(endpoint, {
1982
2010
  method: options.method,
1983
2011
  apiUrl: this.apiUrl,
1984
2012
  publishableKey: this.publishableKey,
@@ -1992,7 +2020,7 @@ var CustomerScopedTransport = class {
1992
2020
  ...options.errorFamily && { errorFamily: options.errorFamily }
1993
2021
  });
1994
2022
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1995
- return parseApiResponse(response, endpoint2, {
2023
+ return parseApiResponse(response, endpoint, {
1996
2024
  errorFamily: options.errorFamily
1997
2025
  });
1998
2026
  } catch (err) {
@@ -2006,12 +2034,12 @@ var CustomerScopedApi = class {
2006
2034
  constructor(apiName, options) {
2007
2035
  this.transport = new CustomerScopedTransport(apiName, options);
2008
2036
  }
2009
- requestEndpoint(endpoint2, body, options) {
2010
- return this.transport.request(resolveOperationPath2(endpoint2, options), {
2011
- method: resolveOperationMethod2(endpoint2),
2037
+ requestEndpoint(endpoint, body, options) {
2038
+ return this.transport.request(resolveOperationPath(endpoint, options), {
2039
+ method: resolveOperationMethod(endpoint),
2012
2040
  body,
2013
2041
  headers: options?.headers,
2014
- errorFamily: resolveOperationErrorFamily(endpoint2)
2042
+ errorFamily: resolveOperationErrorFamily(endpoint)
2015
2043
  });
2016
2044
  }
2017
2045
  };
@@ -2019,8 +2047,8 @@ var RawCustomerScopedApi = class {
2019
2047
  constructor(apiName, options) {
2020
2048
  this.transport = new CustomerScopedTransport(apiName, options);
2021
2049
  }
2022
- request(endpoint2, options) {
2023
- return this.transport.request(endpoint2, options);
2050
+ request(endpoint, options) {
2051
+ return this.transport.request(endpoint, options);
2024
2052
  }
2025
2053
  };
2026
2054
 
@@ -2095,11 +2123,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
2095
2123
  if (params.page !== void 0) urlParams.set("page", String(params.page));
2096
2124
  return `/api/comments/public?${urlParams.toString()}`;
2097
2125
  }
2098
- async execute(endpoint2, method, body) {
2099
- return this.request(endpoint2, { method, body });
2126
+ async execute(endpoint, method, body) {
2127
+ return this.request(endpoint, { method, body });
2100
2128
  }
2101
- async executeDoc(endpoint2, method, body) {
2102
- const response = await this.execute(endpoint2, method, body);
2129
+ async executeDoc(endpoint, method, body) {
2130
+ const response = await this.execute(endpoint, method, body);
2103
2131
  return unwrapPayloadDoc(response);
2104
2132
  }
2105
2133
  createPost(params) {
@@ -2378,20 +2406,23 @@ var ServerApiTransport = class {
2378
2406
  this.apiUrl = options.apiUrl;
2379
2407
  this.onRequestId = options.onRequestId;
2380
2408
  }
2381
- async request(endpoint2, body, options) {
2409
+ async request(endpoint, body, options) {
2382
2410
  const method = options?.method ?? "POST";
2383
2411
  try {
2384
- const response = await httpFetch(endpoint2, {
2412
+ const response = await httpFetch(endpoint, {
2385
2413
  method,
2386
2414
  apiUrl: this.apiUrl,
2387
2415
  publishableKey: this.publishableKey,
2388
2416
  secretKey: this.secretKey,
2389
2417
  ...body !== void 0 && { body: JSON.stringify(body) },
2390
2418
  ...options?.headers && { headers: options.headers },
2391
- ...options?.errorFamily && { errorFamily: options.errorFamily }
2419
+ ...options?.errorFamily && { errorFamily: options.errorFamily },
2420
+ ...options?.typedCommerceErrorReasons && {
2421
+ typedCommerceErrorReasons: options.typedCommerceErrorReasons
2422
+ }
2392
2423
  });
2393
2424
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
2394
- return parseApiResponse(response, endpoint2, {
2425
+ return parseApiResponse(response, endpoint, {
2395
2426
  errorFamily: options?.errorFamily
2396
2427
  });
2397
2428
  } catch (err) {
@@ -2405,14 +2436,15 @@ var BaseApi = class {
2405
2436
  constructor(apiName, options) {
2406
2437
  this.transport = new ServerApiTransport(apiName, options);
2407
2438
  }
2408
- requestEndpoint(endpoint2, body, options) {
2439
+ requestEndpoint(endpoint, body, options) {
2409
2440
  return this.transport.request(
2410
- resolveOperationPath2(endpoint2, options),
2441
+ resolveOperationPath(endpoint, options),
2411
2442
  body,
2412
2443
  {
2413
- method: resolveOperationMethod2(endpoint2),
2444
+ method: resolveOperationMethod(endpoint),
2414
2445
  headers: options?.headers,
2415
- errorFamily: resolveOperationErrorFamily(endpoint2)
2446
+ errorFamily: resolveOperationErrorFamily(endpoint),
2447
+ typedCommerceErrorReasons: resolveOperationTypedCommerceErrorReasons(endpoint)
2416
2448
  }
2417
2449
  );
2418
2450
  }
@@ -2429,8 +2461,8 @@ var RawBaseApi = class {
2429
2461
  this.apiUrl = options.apiUrl;
2430
2462
  this.onRequestId = options.onRequestId;
2431
2463
  }
2432
- request(endpoint2, body, options) {
2433
- return this.transport.request(endpoint2, body, options);
2464
+ request(endpoint, body, options) {
2465
+ return this.transport.request(endpoint, body, options);
2434
2466
  }
2435
2467
  };
2436
2468
 
@@ -2491,6 +2523,18 @@ var PAYMENT_FAILURE_REASONS = [
2491
2523
  "provider_terminal_failure",
2492
2524
  "unknown_provider_terminal_failure"
2493
2525
  ];
2526
+ var PAYMENT_RECONCILIATION_REASONS = [
2527
+ "provider_outcome_unknown",
2528
+ "local_commit_ambiguous",
2529
+ "amount_mismatch",
2530
+ "currency_mismatch",
2531
+ "excess_capture_pending_order",
2532
+ "inventory_unavailable",
2533
+ "admission_unavailable",
2534
+ "excess_capture",
2535
+ "late_capture",
2536
+ "cross_checkout_duplicate"
2537
+ ];
2494
2538
  var CART_WARNING_CODES = [
2495
2539
  "DISCOUNT_CODE_NOT_HONOURED",
2496
2540
  "DISCOUNT_CURRENTLY_INACTIVE",
@@ -2552,6 +2596,9 @@ function nullableString(value, resource, path) {
2552
2596
  fail(resource, path, "string or null");
2553
2597
  }
2554
2598
  }
2599
+ function nullableNonEmptyString(value, resource, path) {
2600
+ if (value !== null) string(value, resource, path);
2601
+ }
2555
2602
  function nonBlankString(value, resource, path) {
2556
2603
  const parsed = string(value, resource, path);
2557
2604
  if (parsed.trim().length === 0) {
@@ -3072,8 +3119,8 @@ function validateCheckoutItem(value, resource, path) {
3072
3119
  validateReference(item.product, resource, `${path}.product`);
3073
3120
  validateReference(item.variant, resource, `${path}.variant`);
3074
3121
  string(item.productTitle, resource, `${path}.productTitle`);
3075
- nullableString(item.variantTitle, resource, `${path}.variantTitle`);
3076
- nullableString(item.sku, resource, `${path}.sku`);
3122
+ nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
3123
+ nullableNonEmptyString(item.sku, resource, `${path}.sku`);
3077
3124
  validateAdmissions(item.admissions, resource, `${path}.admissions`);
3078
3125
  cartLineQuantity(item.quantity, resource, `${path}.quantity`);
3079
3126
  const unitPrice = safeMinor(
@@ -3441,6 +3488,141 @@ function validateRetrievedCustomPaymentSession(value) {
3441
3488
  nullableResourceId(session.orderId, resource, "$.orderId");
3442
3489
  return value;
3443
3490
  }
3491
+ function validatePortOnePaymentCurrentState(value, resource, path) {
3492
+ const current = record(value, resource, path);
3493
+ exact(
3494
+ current,
3495
+ ["paymentSession", "checkout", "order", "money"],
3496
+ [],
3497
+ resource,
3498
+ path
3499
+ );
3500
+ const session = record(
3501
+ current.paymentSession,
3502
+ resource,
3503
+ `${path}.paymentSession`
3504
+ );
3505
+ exact(
3506
+ session,
3507
+ [
3508
+ "id",
3509
+ "provider",
3510
+ "providerStatus",
3511
+ "finalizationStatus",
3512
+ "sessionRole",
3513
+ "reconciliation"
3514
+ ],
3515
+ [],
3516
+ resource,
3517
+ `${path}.paymentSession`
3518
+ );
3519
+ boundedString(
3520
+ session.id,
3521
+ MAX_COMMERCE_RESOURCE_ID_LENGTH,
3522
+ resource,
3523
+ `${path}.paymentSession.id`
3524
+ );
3525
+ if (session.provider !== "portone") {
3526
+ fail(resource, `${path}.paymentSession.provider`, "portone");
3527
+ }
3528
+ enumValue(
3529
+ session.providerStatus,
3530
+ PAYMENT_PROVIDER_STATUSES,
3531
+ resource,
3532
+ `${path}.paymentSession.providerStatus`
3533
+ );
3534
+ enumValue(
3535
+ session.finalizationStatus,
3536
+ ["not_ready", "pending", "committed"],
3537
+ resource,
3538
+ `${path}.paymentSession.finalizationStatus`
3539
+ );
3540
+ enumValue(
3541
+ session.sessionRole,
3542
+ ["active", "canonical_candidate", "canonical", "residual", "historical"],
3543
+ resource,
3544
+ `${path}.paymentSession.sessionRole`
3545
+ );
3546
+ const reconciliation = record(
3547
+ session.reconciliation,
3548
+ resource,
3549
+ `${path}.paymentSession.reconciliation`
3550
+ );
3551
+ if (reconciliation.status === "none") {
3552
+ validateNoReconciliation(
3553
+ reconciliation,
3554
+ resource,
3555
+ `${path}.paymentSession.reconciliation`
3556
+ );
3557
+ } else {
3558
+ validateRequiredReconciliation(
3559
+ reconciliation,
3560
+ PAYMENT_RECONCILIATION_REASONS,
3561
+ resource,
3562
+ `${path}.paymentSession.reconciliation`
3563
+ );
3564
+ }
3565
+ const checkout = record(current.checkout, resource, `${path}.checkout`);
3566
+ exact(checkout, ["id"], [], resource, `${path}.checkout`);
3567
+ boundedString(
3568
+ checkout.id,
3569
+ MAX_COMMERCE_RESOURCE_ID_LENGTH,
3570
+ resource,
3571
+ `${path}.checkout.id`
3572
+ );
3573
+ if (current.order !== null) {
3574
+ const order = record(current.order, resource, `${path}.order`);
3575
+ exact(order, ["id", "orderNumber"], [], resource, `${path}.order`);
3576
+ boundedString(
3577
+ order.id,
3578
+ MAX_COMMERCE_RESOURCE_ID_LENGTH,
3579
+ resource,
3580
+ `${path}.order.id`
3581
+ );
3582
+ nonBlankString(order.orderNumber, resource, `${path}.order.orderNumber`);
3583
+ }
3584
+ validateMoney(current.money, resource, `${path}.money`);
3585
+ }
3586
+ function validatePortOnePaymentFacadeResult(value, mutating) {
3587
+ const resource = mutating ? "PortOne payment reconciliation result" : "PortOne payment find result";
3588
+ const result = record(value, resource, "$");
3589
+ boolean(result.found, resource, "$.found");
3590
+ if (result.found === false) {
3591
+ exact(
3592
+ result,
3593
+ mutating ? ["found", "disposition"] : ["found"],
3594
+ [],
3595
+ resource,
3596
+ "$"
3597
+ );
3598
+ if (mutating && result.disposition !== "requires_attention") {
3599
+ fail(resource, "$.disposition", "requires_attention");
3600
+ }
3601
+ return value;
3602
+ }
3603
+ exact(
3604
+ result,
3605
+ mutating ? ["found", "disposition", "current"] : ["found", "current"],
3606
+ [],
3607
+ resource,
3608
+ "$"
3609
+ );
3610
+ if (mutating) {
3611
+ enumValue(
3612
+ result.disposition,
3613
+ [
3614
+ "applied",
3615
+ "observed",
3616
+ "recovered_after_ambiguous_result",
3617
+ "requires_attention"
3618
+ ],
3619
+ resource,
3620
+ "$.disposition"
3621
+ );
3622
+ }
3623
+ validatePortOnePaymentCurrentState(result.current, resource, "$.current");
3624
+ return value;
3625
+ }
3444
3626
  function validateConfirmCustomPaymentSessionResponse(value) {
3445
3627
  const resource = "custom PaymentSession confirmation";
3446
3628
  const result = record(value, resource, "$");
@@ -3495,11 +3677,21 @@ function validateNextAction(value, provider, resource, path) {
3495
3677
  const action = record(value, resource, path);
3496
3678
  if (provider === "portone") {
3497
3679
  if (action.type === "portone_sdk") {
3680
+ const hasCancelable = "cancelable" in action;
3681
+ const hasRetryPolicy = "retryPolicy" in action;
3682
+ if (hasCancelable !== hasRetryPolicy) {
3683
+ fail(
3684
+ resource,
3685
+ path,
3686
+ "exact released action or exact negotiated capability action"
3687
+ );
3688
+ }
3498
3689
  exact(
3499
3690
  action,
3500
3691
  [
3501
3692
  "type",
3502
3693
  "version",
3694
+ ...hasCancelable ? ["cancelable", "retryPolicy"] : [],
3503
3695
  "storeId",
3504
3696
  "channelKey",
3505
3697
  "paymentId",
@@ -3514,6 +3706,11 @@ function validateNextAction(value, provider, resource, path) {
3514
3706
  path
3515
3707
  );
3516
3708
  if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
3709
+ if (hasCancelable && action.cancelable !== false)
3710
+ fail(resource, `${path}.cancelable`, "false");
3711
+ if (hasRetryPolicy && action.retryPolicy !== "same_action_only") {
3712
+ fail(resource, `${path}.retryPolicy`, "same_action_only");
3713
+ }
3517
3714
  for (const key of ["storeId", "channelKey"]) {
3518
3715
  boundedString(action[key], 255, resource, `${path}.${key}`);
3519
3716
  }
@@ -3560,6 +3757,10 @@ function validateNextAction(value, provider, resource, path) {
3560
3757
  "HTTPS or loopback URL without embedded credentials"
3561
3758
  );
3562
3759
  }
3760
+ if (!hasCancelable) {
3761
+ action.cancelable = false;
3762
+ action.retryPolicy = "same_action_only";
3763
+ }
3563
3764
  return;
3564
3765
  }
3565
3766
  exact(action, ["type", "checkoutUrl"], [], resource, path);
@@ -3877,8 +4078,8 @@ var CartApi = class extends CustomerScopedApi {
3877
4078
  endpoint(key) {
3878
4079
  return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
3879
4080
  }
3880
- execute(endpoint2, body, idempotencyKey) {
3881
- return this.requestEndpoint(endpoint2, body, {
4081
+ execute(endpoint, body, idempotencyKey) {
4082
+ return this.requestEndpoint(endpoint, body, {
3882
4083
  ...idempotencyKey && {
3883
4084
  headers: { "X-Idempotency-Key": idempotencyKey }
3884
4085
  }
@@ -3895,26 +4096,26 @@ var CartApi = class extends CustomerScopedApi {
3895
4096
  );
3896
4097
  }
3897
4098
  mine(params = {}) {
3898
- const endpoint2 = this.endpoint("mine");
3899
- return this.execute(endpoint2, params).then(
4099
+ const endpoint = this.endpoint("mine");
4100
+ return this.execute(endpoint, params).then(
3900
4101
  (value) => validateCartMineResult(value)
3901
4102
  );
3902
4103
  }
3903
4104
  merge(params) {
3904
4105
  const { idempotencyKey, ...body } = params;
3905
4106
  assertCommerceIdempotencyKey(idempotencyKey);
3906
- const endpoint2 = this.endpoint("merge");
3907
- return this.execute(endpoint2, body, idempotencyKey).then(
4107
+ const endpoint = this.endpoint("merge");
4108
+ return this.execute(endpoint, body, idempotencyKey).then(
3908
4109
  (value) => validateCartMergeResult(value)
3909
4110
  );
3910
4111
  }
3911
4112
  addItem(params) {
3912
4113
  return this.mutate(this.endpoint("addItem"), params);
3913
4114
  }
3914
- mutate(endpoint2, params) {
4115
+ mutate(endpoint, params) {
3915
4116
  const { idempotencyKey, ...body } = params;
3916
4117
  assertCommerceIdempotencyKey(idempotencyKey);
3917
- return this.execute(endpoint2, body, idempotencyKey).then(
4118
+ return this.execute(endpoint, body, idempotencyKey).then(
3918
4119
  (value) => validateCartMutationResult(value)
3919
4120
  );
3920
4121
  }
@@ -5323,8 +5524,8 @@ var CheckoutApi = class extends CustomerScopedApi {
5323
5524
  constructor(options) {
5324
5525
  super("CheckoutApi", { ...options, requiresCredential: false });
5325
5526
  }
5326
- post(endpoint2, body, idempotencyKey) {
5327
- return this.requestEndpoint(endpoint2, body, {
5527
+ post(endpoint, body, idempotencyKey) {
5528
+ return this.requestEndpoint(endpoint, body, {
5328
5529
  ...idempotencyKey && {
5329
5530
  headers: { "X-Idempotency-Key": idempotencyKey }
5330
5531
  }
@@ -5391,11 +5592,15 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5391
5592
  super("PaymentSessionApi", { ...options, requiresCredential: false });
5392
5593
  this.serverTransport = Boolean(options.secretKey);
5393
5594
  }
5394
- post(endpoint2, body, idempotencyKey) {
5395
- return this.requestEndpoint(endpoint2, body, {
5396
- ...idempotencyKey && {
5397
- headers: { "X-Idempotency-Key": idempotencyKey }
5595
+ post(endpoint, body, idempotencyKey, negotiateStandardActionCapabilities = false) {
5596
+ const headers = {
5597
+ ...idempotencyKey && { "X-Idempotency-Key": idempotencyKey },
5598
+ ...negotiateStandardActionCapabilities && {
5599
+ Accept: PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE
5398
5600
  }
5601
+ };
5602
+ return this.requestEndpoint(endpoint, body, {
5603
+ ...Object.keys(headers).length > 0 && { headers }
5399
5604
  });
5400
5605
  }
5401
5606
  async paymentSession(result, expectedProvider) {
@@ -5420,40 +5625,41 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5420
5625
  this.post(
5421
5626
  this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
5422
5627
  body,
5423
- idempotencyKey
5628
+ idempotencyKey,
5629
+ body.providerOptions.profile === "standard_v2"
5424
5630
  ),
5425
5631
  "portone"
5426
5632
  );
5427
5633
  }
5428
5634
  retrieve(params) {
5429
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
5635
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
5430
5636
  return this.paymentSession(
5431
- this.post(endpoint2, params),
5637
+ this.post(endpoint, params),
5432
5638
  "toss"
5433
5639
  );
5434
5640
  }
5435
5641
  retrievePortOne(params) {
5436
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
5642
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
5437
5643
  return this.paymentSession(
5438
- this.post(endpoint2, params),
5644
+ this.post(endpoint, params, void 0, true),
5439
5645
  "portone"
5440
5646
  );
5441
5647
  }
5442
5648
  cancel(params) {
5443
5649
  const { idempotencyKey, ...body } = params;
5444
5650
  assertCommerceIdempotencyKey(idempotencyKey);
5445
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5651
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5446
5652
  return this.paymentSession(
5447
- this.post(endpoint2, body, idempotencyKey),
5653
+ this.post(endpoint, body, idempotencyKey),
5448
5654
  "toss"
5449
5655
  );
5450
5656
  }
5451
5657
  cancelPortOne(params) {
5452
5658
  const { idempotencyKey, ...body } = params;
5453
5659
  assertCommerceIdempotencyKey(idempotencyKey);
5454
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5660
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
5455
5661
  return this.paymentSession(
5456
- this.post(endpoint2, body, idempotencyKey),
5662
+ this.post(endpoint, body, idempotencyKey),
5457
5663
  "portone"
5458
5664
  );
5459
5665
  }
@@ -5470,6 +5676,34 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5470
5676
  );
5471
5677
  }
5472
5678
  };
5679
+ var PortOnePaymentReconciliationApi = class extends BaseApi {
5680
+ constructor(options) {
5681
+ super("PortOnePaymentReconciliationApi", options);
5682
+ }
5683
+ async find(params) {
5684
+ const result = await this.requestEndpoint(
5685
+ COMMERCE_ENDPOINTS.paymentSessions.server.findPortOne,
5686
+ params
5687
+ );
5688
+ return validatePortOnePaymentFacadeResult(
5689
+ result,
5690
+ false
5691
+ );
5692
+ }
5693
+ async reconcile(params) {
5694
+ const { idempotencyKey, ...body } = params;
5695
+ assertCommerceIdempotencyKey(idempotencyKey);
5696
+ const result = await this.requestEndpoint(
5697
+ COMMERCE_ENDPOINTS.paymentSessions.server.reconcilePortOne,
5698
+ body,
5699
+ { headers: { "X-Idempotency-Key": idempotencyKey } }
5700
+ );
5701
+ return validatePortOnePaymentFacadeResult(
5702
+ result,
5703
+ true
5704
+ );
5705
+ }
5706
+ };
5473
5707
  var CustomPaymentSessionApi = class extends BaseApi {
5474
5708
  constructor(options) {
5475
5709
  super("CustomPaymentSessionApi", options);
@@ -5599,6 +5833,9 @@ var ServerCommerceClient = class {
5599
5833
  const orderApi = new OrderApi(serverOptions);
5600
5834
  const checkoutApi = new CheckoutApi(serverOptions);
5601
5835
  const paymentSessionApi = new PaymentSessionApi(serverOptions);
5836
+ const portOneReconciliationApi = new PortOnePaymentReconciliationApi(
5837
+ serverOptions
5838
+ );
5602
5839
  const customPaymentSessionApi = new CustomPaymentSessionApi(serverOptions);
5603
5840
  this.product = {
5604
5841
  stockCheck: productApi.stockCheck.bind(productApi),
@@ -5649,6 +5886,10 @@ var ServerCommerceClient = class {
5649
5886
  cancel: (params) => paymentSessionApi.cancel(params),
5650
5887
  cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params),
5651
5888
  confirm: paymentSessionApi.confirm.bind(paymentSessionApi),
5889
+ findPortOne: portOneReconciliationApi.find.bind(portOneReconciliationApi),
5890
+ reconcilePortOne: portOneReconciliationApi.reconcile.bind(
5891
+ portOneReconciliationApi
5892
+ ),
5652
5893
  custom: {
5653
5894
  create: customPaymentSessionApi.create.bind(customPaymentSessionApi),
5654
5895
  retrieve: customPaymentSessionApi.retrieve.bind(
@@ -5730,11 +5971,11 @@ var EventsClient = class {
5730
5971
  { useCustomerAuth: false }
5731
5972
  );
5732
5973
  }
5733
- async execute(endpoint2, method, body, options = {}) {
5974
+ async execute(endpoint, method, body, options = {}) {
5734
5975
  const useCustomerAuth = options.useCustomerAuth === true;
5735
5976
  const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
5736
5977
  try {
5737
- const response = await httpFetch(endpoint2, {
5978
+ const response = await httpFetch(endpoint, {
5738
5979
  method,
5739
5980
  apiUrl: this.apiUrl,
5740
5981
  publishableKey: this.publishableKey,
@@ -5743,7 +5984,7 @@ var EventsClient = class {
5743
5984
  ...body !== void 0 && { body: JSON.stringify(body) }
5744
5985
  });
5745
5986
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
5746
- return parseApiResponse(response, endpoint2);
5987
+ return parseApiResponse(response, endpoint);
5747
5988
  } catch (err) {
5748
5989
  const id = err instanceof SDKError ? err.requestId ?? null : null;
5749
5990
  this.onRequestId?.(id);
@@ -5845,13 +6086,14 @@ var MarketDiscovery = class {
5845
6086
  };
5846
6087
 
5847
6088
  // src/core/api/tenant-introspection-api.ts
6089
+ var TENANT_CONTEXT_PATH = "/api/tenants/context";
5848
6090
  var TenantIntrospectionApi = class extends RawBaseApi {
5849
6091
  constructor(options) {
5850
6092
  super("TenantIntrospectionApi", options);
5851
6093
  }
5852
6094
  context(params = {}) {
5853
- const endpoint2 = params.includeCounts ? "/api/tenants/context?counts=true" : "/api/tenants/context";
5854
- return this.request(endpoint2, void 0, {
6095
+ const endpoint = params.includeCounts ? `${TENANT_CONTEXT_PATH}?counts=true` : TENANT_CONTEXT_PATH;
6096
+ return this.request(endpoint, void 0, {
5855
6097
  method: "GET"
5856
6098
  });
5857
6099
  }