@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/client.cjs CHANGED
@@ -140,6 +140,7 @@ var COMMERCE_ERROR_CODES = [
140
140
  "payment_session_not_cancelable",
141
141
  "payment_session_conflict",
142
142
  "provider_identity_mismatch",
143
+ "managed_refund_attestation_forbidden",
143
144
  "payment_method_unavailable",
144
145
  "provider_unavailable",
145
146
  "lock_timeout",
@@ -682,11 +683,11 @@ function parseRetryAfter(response) {
682
683
  permitsAutomaticRetry: seconds <= MAX_AUTOMATIC_RETRY_AFTER_SECONDS
683
684
  };
684
685
  }
685
- function mapResponseToError(status, parsed, details, requestId, retryAfter, errorFamily) {
686
+ function mapResponseToError(status, parsed, details, requestId, retryAfter, canonicalCommerceError) {
686
687
  const errorDetails = {
687
688
  ...details,
688
689
  ...parsed.errors && { errors: parsed.errors },
689
- ...errorFamily !== "commerce" && parsed.body && { body: parsed.body }
690
+ ...!canonicalCommerceError && parsed.body && { body: parsed.body }
690
691
  };
691
692
  const suggestion = getParsedErrorSuggestion(status, parsed);
692
693
  const finalize = (error) => {
@@ -694,7 +695,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
694
695
  if (retryAfter !== void 0) {
695
696
  Object.assign(withRequestId, { retryAfter });
696
697
  }
697
- return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
698
+ return canonicalCommerceError ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
698
699
  };
699
700
  if (status === 400 || status === 422) {
700
701
  return finalize(
@@ -800,6 +801,7 @@ async function httpFetch(url, options) {
800
801
  retry,
801
802
  onUnauthorized,
802
803
  errorFamily,
804
+ typedCommerceErrorReasons,
803
805
  ...requestInit
804
806
  } = options || {};
805
807
  const baseUrl = resolveApiUrl(apiUrl);
@@ -853,7 +855,8 @@ async function httpFetch(url, options) {
853
855
  });
854
856
  if (!response.ok) {
855
857
  const parsed = await parseErrorBody(response);
856
- const commerceEnvelope = errorFamily === "commerce" ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
858
+ const canonicalCommerceError = errorFamily === "commerce" || typeof parsed.reason === "string" && typedCommerceErrorReasons?.includes(parsed.reason) === true;
859
+ const commerceEnvelope = canonicalCommerceError ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
857
860
  if (isUsageLimitExceededResponse(response)) {
858
861
  const limit = parseInt(
859
862
  response.headers.get("X-Usage-Limit") || "0",
@@ -881,7 +884,7 @@ async function httpFetch(url, options) {
881
884
  ),
882
885
  requestId
883
886
  );
884
- throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
887
+ throw canonicalCommerceError ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
885
888
  }
886
889
  if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
887
890
  hasRetried401 = true;
@@ -906,7 +909,7 @@ async function httpFetch(url, options) {
906
909
  details,
907
910
  requestId,
908
911
  retryAfter.seconds,
909
- errorFamily
912
+ canonicalCommerceError
910
913
  );
911
914
  const method2 = (requestInit.method || "GET").toUpperCase();
912
915
  const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
@@ -1084,15 +1087,15 @@ var HttpClient = class {
1084
1087
  throw err;
1085
1088
  }
1086
1089
  }
1087
- buildUrl(endpoint2, options) {
1088
- if (!options) return endpoint2;
1090
+ buildUrl(endpoint, options) {
1091
+ if (!options) return endpoint;
1089
1092
  const { fallbackLocale, ...rest } = options;
1090
1093
  const queryOptions = fallbackLocale === void 0 ? rest : {
1091
1094
  ...rest,
1092
1095
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1093
1096
  };
1094
1097
  const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
1095
- return queryString ? `${endpoint2}${queryString}` : endpoint2;
1098
+ return queryString ? `${endpoint}${queryString}` : endpoint;
1096
1099
  }
1097
1100
  assertJsonResponse(response) {
1098
1101
  const contentType = response.headers.get("content-type");
@@ -1234,39 +1237,39 @@ var ReadOnlyCollectionClient = class extends HttpClient {
1234
1237
  from(collection) {
1235
1238
  return new ReadOnlyCollectionQueryBuilder(this, collection);
1236
1239
  }
1237
- async requestFind(endpoint2, options) {
1238
- const url = this.buildUrl(endpoint2, options);
1240
+ async requestFind(endpoint, options) {
1241
+ const url = this.buildUrl(endpoint, options);
1239
1242
  const response = await this.fetchWithTracking(url, {
1240
1243
  ...this.defaultOptions,
1241
1244
  method: "GET"
1242
1245
  });
1243
1246
  return this.parseFindResponse(response);
1244
1247
  }
1245
- async requestFindEndpoint(endpoint2, data) {
1246
- const response = await this.fetchWithTracking(endpoint2, {
1248
+ async requestFindEndpoint(endpoint, data) {
1249
+ const response = await this.fetchWithTracking(endpoint, {
1247
1250
  ...this.defaultOptions,
1248
1251
  method: "POST",
1249
1252
  body: data ? JSON.stringify(data) : void 0
1250
1253
  });
1251
1254
  return this.parseFindResponse(response);
1252
1255
  }
1253
- async requestFindEndpointGet(endpoint2) {
1254
- const response = await this.fetchWithTracking(endpoint2, {
1256
+ async requestFindEndpointGet(endpoint) {
1257
+ const response = await this.fetchWithTracking(endpoint, {
1255
1258
  ...this.defaultOptions,
1256
1259
  method: "GET"
1257
1260
  });
1258
1261
  return this.parseFindResponse(response);
1259
1262
  }
1260
- async requestFindById(endpoint2, options) {
1261
- const url = this.buildUrl(endpoint2, options);
1263
+ async requestFindById(endpoint, options) {
1264
+ const url = this.buildUrl(endpoint, options);
1262
1265
  const response = await this.fetchWithTracking(url, {
1263
1266
  ...this.defaultOptions,
1264
1267
  method: "GET"
1265
1268
  });
1266
1269
  return this.parseDocumentResponse(response);
1267
1270
  }
1268
- async requestCount(endpoint2, options) {
1269
- const url = this.buildUrl(endpoint2, options);
1271
+ async requestCount(endpoint, options) {
1272
+ const url = this.buildUrl(endpoint, options);
1270
1273
  const response = await this.fetchWithTracking(url, {
1271
1274
  ...this.defaultOptions,
1272
1275
  method: "GET"
@@ -1276,7 +1279,7 @@ var ReadOnlyCollectionClient = class extends HttpClient {
1276
1279
  };
1277
1280
 
1278
1281
  // src/core/api/parse-response.ts
1279
- async function parseApiResponse(response, endpoint2, options = {}) {
1282
+ async function parseApiResponse(response, endpoint, options = {}) {
1280
1283
  if (response.status === 204 || response.headers.get("content-length") === "0") {
1281
1284
  return void 0;
1282
1285
  }
@@ -1285,7 +1288,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1285
1288
  parsed = await response.json();
1286
1289
  } catch {
1287
1290
  throw createApiError(
1288
- `Invalid JSON response from ${endpoint2}`,
1291
+ `Invalid JSON response from ${endpoint}`,
1289
1292
  response.status,
1290
1293
  void 0,
1291
1294
  "Server returned an invalid response.",
@@ -1335,6 +1338,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1335
1338
 
1336
1339
  // ../../internal/http-contracts/src/index.ts
1337
1340
  var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
1341
+ var PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE = "application/vnd.01software.portone-action-capabilities.v1+json";
1338
1342
  var operation = (collection, method, path, errorFamily) => Object.freeze({
1339
1343
  [operationBrand]: true,
1340
1344
  collection,
@@ -1343,6 +1347,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
1343
1347
  ...errorFamily && { errorFamily }
1344
1348
  });
1345
1349
  var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
1350
+ var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
1351
+ ...operation(collection, method, path),
1352
+ typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
1353
+ });
1346
1354
  var COMMERCE_ENDPOINT_OPERATIONS = {
1347
1355
  products: {
1348
1356
  detail: operation("products", "get", "/detail"),
@@ -1374,7 +1382,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1374
1382
  confirmPayment: operation("orders", "post", "/confirm-payment"),
1375
1383
  byPayment: operation("orders", "get", "/by-payment"),
1376
1384
  cancel: operation("orders", "post", "/cancel"),
1377
- resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
1385
+ resolveCancelRefund: selectiveCommerceOperation(
1386
+ "orders",
1387
+ "post",
1388
+ "/resolve-cancel-refund",
1389
+ ["managed_refund_attestation_forbidden"]
1390
+ ),
1378
1391
  checkout: strictCommerceOperation("orders", "post", "/checkout"),
1379
1392
  createFulfillment: operation("orders", "post", "/create-fulfillment"),
1380
1393
  updateFulfillment: operation("orders", "post", "/update-fulfillment")
@@ -1445,6 +1458,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1445
1458
  "payment-sessions",
1446
1459
  "post",
1447
1460
  "/server/confirm"
1461
+ ),
1462
+ findPortOne: strictCommerceOperation(
1463
+ "payment-sessions",
1464
+ "post",
1465
+ "/server/portone/find"
1466
+ ),
1467
+ reconcilePortOne: strictCommerceOperation(
1468
+ "payment-sessions",
1469
+ "post",
1470
+ "/server/portone/reconcile"
1448
1471
  )
1449
1472
  },
1450
1473
  custom: {
@@ -1464,12 +1487,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1464
1487
  validate: operation("discounts", "post", "/validate")
1465
1488
  }
1466
1489
  };
1490
+ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1491
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
1492
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
1493
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
1494
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
1495
+ ]);
1467
1496
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1468
1497
  subscribe: operation(null, "post", "/memberships/subscribe"),
1469
1498
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1470
1499
  me: operation(null, "get", "/memberships/me")
1471
1500
  };
1501
+ var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1502
+ show: operation("tenants", "get", "/embedded-admin-app"),
1503
+ configure: operation("tenants", "patch", "/embedded-admin-app"),
1504
+ disable: operation("tenants", "delete", "/embedded-admin-app")
1505
+ };
1472
1506
  var EVENTS_ENDPOINT_OPERATIONS = {
1507
+ events: {
1508
+ convertSchedule: operation("events", "post", "/:id/schedule")
1509
+ },
1473
1510
  occurrences: {
1474
1511
  range: operation("event-occurrences", "get", "/range"),
1475
1512
  admissionAvailability: operation(
@@ -1510,46 +1547,51 @@ function resolveOperationMethod(descriptor) {
1510
1547
  }
1511
1548
 
1512
1549
  // src/core/api/endpoints.ts
1513
- var endpoint = (method, path) => ({ method, path });
1514
1550
  var sharedEndpoint = (descriptor) => descriptor;
1515
- function resolveOperationMethod2(descriptor) {
1516
- return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
1517
- }
1518
1551
  function resolveOperationErrorFamily(descriptor) {
1519
- return "collection" in descriptor ? descriptor.errorFamily : void 0;
1520
- }
1521
- function resolveOperationPath2(descriptor, options) {
1522
- if ("collection" in descriptor) {
1523
- return resolveOperationPath(descriptor, options);
1524
- }
1525
- const query = options?.query?.toString().replace(/^\?/, "");
1526
- return query ? `${descriptor.path}?${query}` : descriptor.path;
1552
+ return descriptor.errorFamily;
1527
1553
  }
1528
1554
  var COMMERCE_ENDPOINTS = {
1529
1555
  products: {
1530
- detail: endpoint("GET", "/api/products/detail"),
1531
- detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
1532
- listingGroups: endpoint("GET", "/api/products/listing-groups"),
1533
- listingGroupsCatalog: endpoint(
1534
- "GET",
1535
- "/api/products/listing-groups/catalog"
1556
+ detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
1557
+ detailCatalog: sharedEndpoint(
1558
+ COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
1559
+ ),
1560
+ listingGroups: sharedEndpoint(
1561
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
1562
+ ),
1563
+ listingGroupsCatalog: sharedEndpoint(
1564
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
1536
1565
  ),
1537
- listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
1538
- listingGroupsQueryCatalog: endpoint(
1539
- "GET",
1540
- "/api/products/listing-groups/query/catalog"
1566
+ // The manifest keeps the GET read and the POST body-query apart; this
1567
+ // semantic name has always resolved to the GET one.
1568
+ listingGroupsQuery: sharedEndpoint(
1569
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
1541
1570
  ),
1542
- stockCheck: endpoint("POST", "/api/products/stock-check"),
1543
- stockSnapshot: endpoint("GET", "/api/products/stock"),
1544
- upsert: endpoint("POST", "/api/products/upsert")
1571
+ listingGroupsQueryCatalog: sharedEndpoint(
1572
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
1573
+ ),
1574
+ stockCheck: sharedEndpoint(
1575
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
1576
+ ),
1577
+ stockSnapshot: sharedEndpoint(
1578
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
1579
+ ),
1580
+ upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
1545
1581
  },
1546
1582
  orders: {
1547
- update: endpoint("POST", "/api/orders/update"),
1548
- byPayment: endpoint("GET", "/api/orders/by-payment"),
1549
- cancel: endpoint("POST", "/api/orders/cancel"),
1550
- resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
1551
- createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
1552
- updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
1583
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
1584
+ byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
1585
+ cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
1586
+ resolveCancelRefund: sharedEndpoint(
1587
+ COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
1588
+ ),
1589
+ createFulfillment: sharedEndpoint(
1590
+ COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
1591
+ ),
1592
+ updateFulfillment: sharedEndpoint(
1593
+ COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
1594
+ )
1553
1595
  },
1554
1596
  checkouts: {
1555
1597
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
@@ -1561,18 +1603,21 @@ var COMMERCE_ENDPOINTS = {
1561
1603
  }
1562
1604
  },
1563
1605
  returns: {
1564
- create: endpoint("POST", "/api/returns/create"),
1565
- update: endpoint("POST", "/api/returns/update"),
1566
- returnRefund: endpoint("POST", "/api/returns/return-refund")
1606
+ create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
1607
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
1608
+ returnRefund: sharedEndpoint(
1609
+ COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
1610
+ )
1567
1611
  },
1568
1612
  fulfillmentOrders: {
1569
- prepare: endpoint(
1570
- "POST",
1571
- "/api/fulfillment-orders/prepare-fulfillment-order"
1613
+ prepare: sharedEndpoint(
1614
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
1572
1615
  )
1573
1616
  },
1574
1617
  fulfillments: {
1575
- bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
1618
+ bulkImport: sharedEndpoint(
1619
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
1620
+ )
1576
1621
  },
1577
1622
  carts: {
1578
1623
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
@@ -1637,42 +1682,21 @@ var COMMERCE_ENDPOINTS = {
1637
1682
  ),
1638
1683
  confirm: sharedEndpoint(
1639
1684
  COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
1685
+ ),
1686
+ findPortOne: sharedEndpoint(
1687
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
1688
+ ),
1689
+ reconcilePortOne: sharedEndpoint(
1690
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
1640
1691
  )
1641
1692
  }
1642
1693
  },
1643
1694
  shippingPolicies: {
1644
- calculate: endpoint("POST", "/api/shipping-policies/calculate")
1695
+ calculate: sharedEndpoint(
1696
+ COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
1697
+ )
1645
1698
  }
1646
1699
  };
1647
- function isCommerceEndpointDescriptor(value) {
1648
- if (!value || typeof value !== "object") return false;
1649
- const candidate = value;
1650
- return typeof candidate.method === "string" && typeof candidate.path === "string";
1651
- }
1652
- function flattenEndpointPaths(value) {
1653
- if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
1654
- if (!value || typeof value !== "object") return [];
1655
- return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
1656
- }
1657
- function flattenEndpointDescriptors(value) {
1658
- if (isCommerceEndpointDescriptor(value)) return [value];
1659
- if (!value || typeof value !== "object") return [];
1660
- return Object.values(value).flatMap(
1661
- (entry) => flattenEndpointDescriptors(entry)
1662
- );
1663
- }
1664
- var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
1665
- var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
1666
- var MEMBERSHIP_ENDPOINTS = {
1667
- subscribe: "/api/memberships/subscribe",
1668
- cancel: (id) => `/api/memberships/${id}/cancel`,
1669
- me: "/api/memberships/me"
1670
- };
1671
- var MEMBERSHIP_ENDPOINT_PATHS = [
1672
- MEMBERSHIP_ENDPOINTS.subscribe,
1673
- MEMBERSHIP_ENDPOINTS.cancel(":id"),
1674
- MEMBERSHIP_ENDPOINTS.me
1675
- ];
1676
1700
 
1677
1701
  // src/core/api/customer-scoped-api.ts
1678
1702
  var CustomerScopedTransport = class {
@@ -1693,10 +1717,10 @@ var CustomerScopedTransport = class {
1693
1717
  this.onUnauthorized = options.onUnauthorized;
1694
1718
  this.onRequestId = options.onRequestId;
1695
1719
  }
1696
- async request(endpoint2, options) {
1720
+ async request(endpoint, options) {
1697
1721
  const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1698
1722
  try {
1699
- const response = await httpFetch(endpoint2, {
1723
+ const response = await httpFetch(endpoint, {
1700
1724
  method: options.method,
1701
1725
  apiUrl: this.apiUrl,
1702
1726
  publishableKey: this.publishableKey,
@@ -1710,7 +1734,7 @@ var CustomerScopedTransport = class {
1710
1734
  ...options.errorFamily && { errorFamily: options.errorFamily }
1711
1735
  });
1712
1736
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1713
- return parseApiResponse(response, endpoint2, {
1737
+ return parseApiResponse(response, endpoint, {
1714
1738
  errorFamily: options.errorFamily
1715
1739
  });
1716
1740
  } catch (err) {
@@ -1724,12 +1748,12 @@ var CustomerScopedApi = class {
1724
1748
  constructor(apiName, options) {
1725
1749
  this.transport = new CustomerScopedTransport(apiName, options);
1726
1750
  }
1727
- requestEndpoint(endpoint2, body, options) {
1728
- return this.transport.request(resolveOperationPath2(endpoint2, options), {
1729
- method: resolveOperationMethod2(endpoint2),
1751
+ requestEndpoint(endpoint, body, options) {
1752
+ return this.transport.request(resolveOperationPath(endpoint, options), {
1753
+ method: resolveOperationMethod(endpoint),
1730
1754
  body,
1731
1755
  headers: options?.headers,
1732
- errorFamily: resolveOperationErrorFamily(endpoint2)
1756
+ errorFamily: resolveOperationErrorFamily(endpoint)
1733
1757
  });
1734
1758
  }
1735
1759
  };
@@ -1737,8 +1761,8 @@ var RawCustomerScopedApi = class {
1737
1761
  constructor(apiName, options) {
1738
1762
  this.transport = new CustomerScopedTransport(apiName, options);
1739
1763
  }
1740
- request(endpoint2, options) {
1741
- return this.transport.request(endpoint2, options);
1764
+ request(endpoint, options) {
1765
+ return this.transport.request(endpoint, options);
1742
1766
  }
1743
1767
  };
1744
1768
 
@@ -1813,11 +1837,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
1813
1837
  if (params.page !== void 0) urlParams.set("page", String(params.page));
1814
1838
  return `/api/comments/public?${urlParams.toString()}`;
1815
1839
  }
1816
- async execute(endpoint2, method, body) {
1817
- return this.request(endpoint2, { method, body });
1840
+ async execute(endpoint, method, body) {
1841
+ return this.request(endpoint, { method, body });
1818
1842
  }
1819
- async executeDoc(endpoint2, method, body) {
1820
- const response = await this.execute(endpoint2, method, body);
1843
+ async executeDoc(endpoint, method, body) {
1844
+ const response = await this.execute(endpoint, method, body);
1821
1845
  return unwrapPayloadDoc(response);
1822
1846
  }
1823
1847
  createPost(params) {
@@ -2083,8 +2107,8 @@ var CommunityClient = class extends RawCustomerScopedApi {
2083
2107
 
2084
2108
  // src/core/content/content-client.ts
2085
2109
  var PublicContentApi = class extends RawCustomerScopedApi {
2086
- get(endpoint2) {
2087
- return this.request(endpoint2, { method: "GET" });
2110
+ get(endpoint) {
2111
+ return this.request(endpoint, { method: "GET" });
2088
2112
  }
2089
2113
  };
2090
2114
  function appendCommonParams(search, options, defaultSort) {
@@ -2265,6 +2289,9 @@ function nullableString(value, resource, path) {
2265
2289
  fail(resource, path, "string or null");
2266
2290
  }
2267
2291
  }
2292
+ function nullableNonEmptyString(value, resource, path) {
2293
+ if (value !== null) string(value, resource, path);
2294
+ }
2268
2295
  function cartLineQuantity(value, resource, path) {
2269
2296
  const quantity = positiveInteger(value, resource, path);
2270
2297
  if (quantity > MAX_CART_LINE_QUANTITY) {
@@ -2774,8 +2801,8 @@ function validatePublicOrderItem(value, resource, path) {
2774
2801
  validateReference(item.variant, resource, `${path}.variant`);
2775
2802
  }
2776
2803
  string(item.productTitle, resource, `${path}.productTitle`);
2777
- nullableString(item.variantTitle, resource, `${path}.variantTitle`);
2778
- nullableString(item.sku, resource, `${path}.sku`);
2804
+ nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
2805
+ nullableNonEmptyString(item.sku, resource, `${path}.sku`);
2779
2806
  validateAdmissions(item.admissions, resource, `${path}.admissions`);
2780
2807
  const quantity = positiveInteger(item.quantity, resource, `${path}.quantity`);
2781
2808
  const unitPrice = safeMinor(
@@ -3026,8 +3053,8 @@ function validateCheckoutItem(value, resource, path) {
3026
3053
  validateReference(item.product, resource, `${path}.product`);
3027
3054
  validateReference(item.variant, resource, `${path}.variant`);
3028
3055
  string(item.productTitle, resource, `${path}.productTitle`);
3029
- nullableString(item.variantTitle, resource, `${path}.variantTitle`);
3030
- nullableString(item.sku, resource, `${path}.sku`);
3056
+ nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
3057
+ nullableNonEmptyString(item.sku, resource, `${path}.sku`);
3031
3058
  validateAdmissions(item.admissions, resource, `${path}.admissions`);
3032
3059
  cartLineQuantity(item.quantity, resource, `${path}.quantity`);
3033
3060
  const unitPrice = safeMinor(
@@ -3359,11 +3386,21 @@ function validateNextAction(value, provider, resource, path) {
3359
3386
  const action = record(value, resource, path);
3360
3387
  if (provider === "portone") {
3361
3388
  if (action.type === "portone_sdk") {
3389
+ const hasCancelable = "cancelable" in action;
3390
+ const hasRetryPolicy = "retryPolicy" in action;
3391
+ if (hasCancelable !== hasRetryPolicy) {
3392
+ fail(
3393
+ resource,
3394
+ path,
3395
+ "exact released action or exact negotiated capability action"
3396
+ );
3397
+ }
3362
3398
  exact(
3363
3399
  action,
3364
3400
  [
3365
3401
  "type",
3366
3402
  "version",
3403
+ ...hasCancelable ? ["cancelable", "retryPolicy"] : [],
3367
3404
  "storeId",
3368
3405
  "channelKey",
3369
3406
  "paymentId",
@@ -3378,6 +3415,11 @@ function validateNextAction(value, provider, resource, path) {
3378
3415
  path
3379
3416
  );
3380
3417
  if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
3418
+ if (hasCancelable && action.cancelable !== false)
3419
+ fail(resource, `${path}.cancelable`, "false");
3420
+ if (hasRetryPolicy && action.retryPolicy !== "same_action_only") {
3421
+ fail(resource, `${path}.retryPolicy`, "same_action_only");
3422
+ }
3381
3423
  for (const key of ["storeId", "channelKey"]) {
3382
3424
  boundedString(action[key], 255, resource, `${path}.${key}`);
3383
3425
  }
@@ -3424,6 +3466,10 @@ function validateNextAction(value, provider, resource, path) {
3424
3466
  "HTTPS or loopback URL without embedded credentials"
3425
3467
  );
3426
3468
  }
3469
+ if (!hasCancelable) {
3470
+ action.cancelable = false;
3471
+ action.retryPolicy = "same_action_only";
3472
+ }
3427
3473
  return;
3428
3474
  }
3429
3475
  exact(action, ["type", "checkoutUrl"], [], resource, path);
@@ -4154,8 +4200,8 @@ var CartApi = class extends CustomerScopedApi {
4154
4200
  endpoint(key) {
4155
4201
  return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
4156
4202
  }
4157
- execute(endpoint2, body, idempotencyKey) {
4158
- return this.requestEndpoint(endpoint2, body, {
4203
+ execute(endpoint, body, idempotencyKey) {
4204
+ return this.requestEndpoint(endpoint, body, {
4159
4205
  ...idempotencyKey && {
4160
4206
  headers: { "X-Idempotency-Key": idempotencyKey }
4161
4207
  }
@@ -4172,26 +4218,26 @@ var CartApi = class extends CustomerScopedApi {
4172
4218
  );
4173
4219
  }
4174
4220
  mine(params = {}) {
4175
- const endpoint2 = this.endpoint("mine");
4176
- return this.execute(endpoint2, params).then(
4221
+ const endpoint = this.endpoint("mine");
4222
+ return this.execute(endpoint, params).then(
4177
4223
  (value) => validateCartMineResult(value)
4178
4224
  );
4179
4225
  }
4180
4226
  merge(params) {
4181
4227
  const { idempotencyKey, ...body } = params;
4182
4228
  assertCommerceIdempotencyKey(idempotencyKey);
4183
- const endpoint2 = this.endpoint("merge");
4184
- return this.execute(endpoint2, body, idempotencyKey).then(
4229
+ const endpoint = this.endpoint("merge");
4230
+ return this.execute(endpoint, body, idempotencyKey).then(
4185
4231
  (value) => validateCartMergeResult(value)
4186
4232
  );
4187
4233
  }
4188
4234
  addItem(params) {
4189
4235
  return this.mutate(this.endpoint("addItem"), params);
4190
4236
  }
4191
- mutate(endpoint2, params) {
4237
+ mutate(endpoint, params) {
4192
4238
  const { idempotencyKey, ...body } = params;
4193
4239
  assertCommerceIdempotencyKey(idempotencyKey);
4194
- return this.execute(endpoint2, body, idempotencyKey).then(
4240
+ return this.execute(endpoint, body, idempotencyKey).then(
4195
4241
  (value) => validateCartMutationResult(value)
4196
4242
  );
4197
4243
  }
@@ -4217,8 +4263,8 @@ var CheckoutApi = class extends CustomerScopedApi {
4217
4263
  constructor(options) {
4218
4264
  super("CheckoutApi", { ...options, requiresCredential: false });
4219
4265
  }
4220
- post(endpoint2, body, idempotencyKey) {
4221
- return this.requestEndpoint(endpoint2, body, {
4266
+ post(endpoint, body, idempotencyKey) {
4267
+ return this.requestEndpoint(endpoint, body, {
4222
4268
  ...idempotencyKey && {
4223
4269
  headers: { "X-Idempotency-Key": idempotencyKey }
4224
4270
  }
@@ -4285,11 +4331,15 @@ var PaymentSessionApi = class extends CustomerScopedApi {
4285
4331
  super("PaymentSessionApi", { ...options, requiresCredential: false });
4286
4332
  this.serverTransport = Boolean(options.secretKey);
4287
4333
  }
4288
- post(endpoint2, body, idempotencyKey) {
4289
- return this.requestEndpoint(endpoint2, body, {
4290
- ...idempotencyKey && {
4291
- headers: { "X-Idempotency-Key": idempotencyKey }
4334
+ post(endpoint, body, idempotencyKey, negotiateStandardActionCapabilities = false) {
4335
+ const headers = {
4336
+ ...idempotencyKey && { "X-Idempotency-Key": idempotencyKey },
4337
+ ...negotiateStandardActionCapabilities && {
4338
+ Accept: PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE
4292
4339
  }
4340
+ };
4341
+ return this.requestEndpoint(endpoint, body, {
4342
+ ...Object.keys(headers).length > 0 && { headers }
4293
4343
  });
4294
4344
  }
4295
4345
  async paymentSession(result, expectedProvider) {
@@ -4314,40 +4364,41 @@ var PaymentSessionApi = class extends CustomerScopedApi {
4314
4364
  this.post(
4315
4365
  this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
4316
4366
  body,
4317
- idempotencyKey
4367
+ idempotencyKey,
4368
+ body.providerOptions.profile === "standard_v2"
4318
4369
  ),
4319
4370
  "portone"
4320
4371
  );
4321
4372
  }
4322
4373
  retrieve(params) {
4323
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4374
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4324
4375
  return this.paymentSession(
4325
- this.post(endpoint2, params),
4376
+ this.post(endpoint, params),
4326
4377
  "toss"
4327
4378
  );
4328
4379
  }
4329
4380
  retrievePortOne(params) {
4330
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4381
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4331
4382
  return this.paymentSession(
4332
- this.post(endpoint2, params),
4383
+ this.post(endpoint, params, void 0, true),
4333
4384
  "portone"
4334
4385
  );
4335
4386
  }
4336
4387
  cancel(params) {
4337
4388
  const { idempotencyKey, ...body } = params;
4338
4389
  assertCommerceIdempotencyKey(idempotencyKey);
4339
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4390
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4340
4391
  return this.paymentSession(
4341
- this.post(endpoint2, body, idempotencyKey),
4392
+ this.post(endpoint, body, idempotencyKey),
4342
4393
  "toss"
4343
4394
  );
4344
4395
  }
4345
4396
  cancelPortOne(params) {
4346
4397
  const { idempotencyKey, ...body } = params;
4347
4398
  assertCommerceIdempotencyKey(idempotencyKey);
4348
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4399
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4349
4400
  return this.paymentSession(
4350
- this.post(endpoint2, body, idempotencyKey),
4401
+ this.post(endpoint, body, idempotencyKey),
4351
4402
  "portone"
4352
4403
  );
4353
4404
  }
@@ -5488,8 +5539,8 @@ function withProductListingCards(response, options) {
5488
5539
 
5489
5540
  // src/core/commerce/commerce-client.ts
5490
5541
  var BrowserCommerceApi = class extends CustomerScopedApi {
5491
- requestEndpoint(endpoint2, body, options) {
5492
- return super.requestEndpoint(endpoint2, body, options);
5542
+ requestEndpoint(endpoint, body, options) {
5543
+ return super.requestEndpoint(endpoint, body, options);
5493
5544
  }
5494
5545
  };
5495
5546
  var CommerceClient = class {
@@ -5689,11 +5740,11 @@ var EventsClient = class {
5689
5740
  { useCustomerAuth: false }
5690
5741
  );
5691
5742
  }
5692
- async execute(endpoint2, method, body, options = {}) {
5743
+ async execute(endpoint, method, body, options = {}) {
5693
5744
  const useCustomerAuth = options.useCustomerAuth === true;
5694
5745
  const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
5695
5746
  try {
5696
- const response = await httpFetch(endpoint2, {
5747
+ const response = await httpFetch(endpoint, {
5697
5748
  method,
5698
5749
  apiUrl: this.apiUrl,
5699
5750
  publishableKey: this.publishableKey,
@@ -5702,7 +5753,7 @@ var EventsClient = class {
5702
5753
  ...body !== void 0 && { body: JSON.stringify(body) }
5703
5754
  });
5704
5755
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
5705
- return parseApiResponse(response, endpoint2);
5756
+ return parseApiResponse(response, endpoint);
5706
5757
  } catch (err) {
5707
5758
  const id = err instanceof SDKError ? err.requestId ?? null : null;
5708
5759
  this.onRequestId?.(id);