@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.js CHANGED
@@ -97,6 +97,7 @@ var COMMERCE_ERROR_CODES = [
97
97
  "payment_session_not_cancelable",
98
98
  "payment_session_conflict",
99
99
  "provider_identity_mismatch",
100
+ "managed_refund_attestation_forbidden",
100
101
  "payment_method_unavailable",
101
102
  "provider_unavailable",
102
103
  "lock_timeout",
@@ -639,11 +640,11 @@ function parseRetryAfter(response) {
639
640
  permitsAutomaticRetry: seconds <= MAX_AUTOMATIC_RETRY_AFTER_SECONDS
640
641
  };
641
642
  }
642
- function mapResponseToError(status, parsed, details, requestId, retryAfter, errorFamily) {
643
+ function mapResponseToError(status, parsed, details, requestId, retryAfter, canonicalCommerceError) {
643
644
  const errorDetails = {
644
645
  ...details,
645
646
  ...parsed.errors && { errors: parsed.errors },
646
- ...errorFamily !== "commerce" && parsed.body && { body: parsed.body }
647
+ ...!canonicalCommerceError && parsed.body && { body: parsed.body }
647
648
  };
648
649
  const suggestion = getParsedErrorSuggestion(status, parsed);
649
650
  const finalize = (error) => {
@@ -651,7 +652,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
651
652
  if (retryAfter !== void 0) {
652
653
  Object.assign(withRequestId, { retryAfter });
653
654
  }
654
- return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
655
+ return canonicalCommerceError ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
655
656
  };
656
657
  if (status === 400 || status === 422) {
657
658
  return finalize(
@@ -757,6 +758,7 @@ async function httpFetch(url, options) {
757
758
  retry,
758
759
  onUnauthorized,
759
760
  errorFamily,
761
+ typedCommerceErrorReasons,
760
762
  ...requestInit
761
763
  } = options || {};
762
764
  const baseUrl = resolveApiUrl(apiUrl);
@@ -810,7 +812,8 @@ async function httpFetch(url, options) {
810
812
  });
811
813
  if (!response.ok) {
812
814
  const parsed = await parseErrorBody(response);
813
- const commerceEnvelope = errorFamily === "commerce" ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
815
+ const canonicalCommerceError = errorFamily === "commerce" || typeof parsed.reason === "string" && typedCommerceErrorReasons?.includes(parsed.reason) === true;
816
+ const commerceEnvelope = canonicalCommerceError ? parseCommerceErrorEnvelope(parsed.body, requestId) : void 0;
814
817
  if (isUsageLimitExceededResponse(response)) {
815
818
  const limit = parseInt(
816
819
  response.headers.get("X-Usage-Limit") || "0",
@@ -838,7 +841,7 @@ async function httpFetch(url, options) {
838
841
  ),
839
842
  requestId
840
843
  );
841
- throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
844
+ throw canonicalCommerceError ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
842
845
  }
843
846
  if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
844
847
  hasRetried401 = true;
@@ -863,7 +866,7 @@ async function httpFetch(url, options) {
863
866
  details,
864
867
  requestId,
865
868
  retryAfter.seconds,
866
- errorFamily
869
+ canonicalCommerceError
867
870
  );
868
871
  const method2 = (requestInit.method || "GET").toUpperCase();
869
872
  const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
@@ -1041,15 +1044,15 @@ var HttpClient = class {
1041
1044
  throw err;
1042
1045
  }
1043
1046
  }
1044
- buildUrl(endpoint2, options) {
1045
- if (!options) return endpoint2;
1047
+ buildUrl(endpoint, options) {
1048
+ if (!options) return endpoint;
1046
1049
  const { fallbackLocale, ...rest } = options;
1047
1050
  const queryOptions = fallbackLocale === void 0 ? rest : {
1048
1051
  ...rest,
1049
1052
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
1050
1053
  };
1051
1054
  const queryString = stringify(queryOptions, { addQueryPrefix: true });
1052
- return queryString ? `${endpoint2}${queryString}` : endpoint2;
1055
+ return queryString ? `${endpoint}${queryString}` : endpoint;
1053
1056
  }
1054
1057
  assertJsonResponse(response) {
1055
1058
  const contentType = response.headers.get("content-type");
@@ -1191,39 +1194,39 @@ var ReadOnlyCollectionClient = class extends HttpClient {
1191
1194
  from(collection) {
1192
1195
  return new ReadOnlyCollectionQueryBuilder(this, collection);
1193
1196
  }
1194
- async requestFind(endpoint2, options) {
1195
- const url = this.buildUrl(endpoint2, options);
1197
+ async requestFind(endpoint, options) {
1198
+ const url = this.buildUrl(endpoint, options);
1196
1199
  const response = await this.fetchWithTracking(url, {
1197
1200
  ...this.defaultOptions,
1198
1201
  method: "GET"
1199
1202
  });
1200
1203
  return this.parseFindResponse(response);
1201
1204
  }
1202
- async requestFindEndpoint(endpoint2, data) {
1203
- const response = await this.fetchWithTracking(endpoint2, {
1205
+ async requestFindEndpoint(endpoint, data) {
1206
+ const response = await this.fetchWithTracking(endpoint, {
1204
1207
  ...this.defaultOptions,
1205
1208
  method: "POST",
1206
1209
  body: data ? JSON.stringify(data) : void 0
1207
1210
  });
1208
1211
  return this.parseFindResponse(response);
1209
1212
  }
1210
- async requestFindEndpointGet(endpoint2) {
1211
- const response = await this.fetchWithTracking(endpoint2, {
1213
+ async requestFindEndpointGet(endpoint) {
1214
+ const response = await this.fetchWithTracking(endpoint, {
1212
1215
  ...this.defaultOptions,
1213
1216
  method: "GET"
1214
1217
  });
1215
1218
  return this.parseFindResponse(response);
1216
1219
  }
1217
- async requestFindById(endpoint2, options) {
1218
- const url = this.buildUrl(endpoint2, options);
1220
+ async requestFindById(endpoint, options) {
1221
+ const url = this.buildUrl(endpoint, options);
1219
1222
  const response = await this.fetchWithTracking(url, {
1220
1223
  ...this.defaultOptions,
1221
1224
  method: "GET"
1222
1225
  });
1223
1226
  return this.parseDocumentResponse(response);
1224
1227
  }
1225
- async requestCount(endpoint2, options) {
1226
- const url = this.buildUrl(endpoint2, options);
1228
+ async requestCount(endpoint, options) {
1229
+ const url = this.buildUrl(endpoint, options);
1227
1230
  const response = await this.fetchWithTracking(url, {
1228
1231
  ...this.defaultOptions,
1229
1232
  method: "GET"
@@ -1233,7 +1236,7 @@ var ReadOnlyCollectionClient = class extends HttpClient {
1233
1236
  };
1234
1237
 
1235
1238
  // src/core/api/parse-response.ts
1236
- async function parseApiResponse(response, endpoint2, options = {}) {
1239
+ async function parseApiResponse(response, endpoint, options = {}) {
1237
1240
  if (response.status === 204 || response.headers.get("content-length") === "0") {
1238
1241
  return void 0;
1239
1242
  }
@@ -1242,7 +1245,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1242
1245
  parsed = await response.json();
1243
1246
  } catch {
1244
1247
  throw createApiError(
1245
- `Invalid JSON response from ${endpoint2}`,
1248
+ `Invalid JSON response from ${endpoint}`,
1246
1249
  response.status,
1247
1250
  void 0,
1248
1251
  "Server returned an invalid response.",
@@ -1292,6 +1295,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1292
1295
 
1293
1296
  // ../../internal/http-contracts/src/index.ts
1294
1297
  var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
1298
+ var PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE = "application/vnd.01software.portone-action-capabilities.v1+json";
1295
1299
  var operation = (collection, method, path, errorFamily) => Object.freeze({
1296
1300
  [operationBrand]: true,
1297
1301
  collection,
@@ -1300,6 +1304,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
1300
1304
  ...errorFamily && { errorFamily }
1301
1305
  });
1302
1306
  var strictCommerceOperation = (collection, method, path) => operation(collection, method, path, "commerce");
1307
+ var selectiveCommerceOperation = (collection, method, path, typedCommerceErrorReasons) => Object.freeze({
1308
+ ...operation(collection, method, path),
1309
+ typedCommerceErrorReasons: Object.freeze([...typedCommerceErrorReasons])
1310
+ });
1303
1311
  var COMMERCE_ENDPOINT_OPERATIONS = {
1304
1312
  products: {
1305
1313
  detail: operation("products", "get", "/detail"),
@@ -1331,7 +1339,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1331
1339
  confirmPayment: operation("orders", "post", "/confirm-payment"),
1332
1340
  byPayment: operation("orders", "get", "/by-payment"),
1333
1341
  cancel: operation("orders", "post", "/cancel"),
1334
- resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
1342
+ resolveCancelRefund: selectiveCommerceOperation(
1343
+ "orders",
1344
+ "post",
1345
+ "/resolve-cancel-refund",
1346
+ ["managed_refund_attestation_forbidden"]
1347
+ ),
1335
1348
  checkout: strictCommerceOperation("orders", "post", "/checkout"),
1336
1349
  createFulfillment: operation("orders", "post", "/create-fulfillment"),
1337
1350
  updateFulfillment: operation("orders", "post", "/update-fulfillment")
@@ -1402,6 +1415,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1402
1415
  "payment-sessions",
1403
1416
  "post",
1404
1417
  "/server/confirm"
1418
+ ),
1419
+ findPortOne: strictCommerceOperation(
1420
+ "payment-sessions",
1421
+ "post",
1422
+ "/server/portone/find"
1423
+ ),
1424
+ reconcilePortOne: strictCommerceOperation(
1425
+ "payment-sessions",
1426
+ "post",
1427
+ "/server/portone/reconcile"
1405
1428
  )
1406
1429
  },
1407
1430
  custom: {
@@ -1421,12 +1444,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1421
1444
  validate: operation("discounts", "post", "/validate")
1422
1445
  }
1423
1446
  };
1447
+ var portOneStandardActionCapabilityOperations = /* @__PURE__ */ new Set([
1448
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create,
1449
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,
1450
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,
1451
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve
1452
+ ]);
1424
1453
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1425
1454
  subscribe: operation(null, "post", "/memberships/subscribe"),
1426
1455
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1427
1456
  me: operation(null, "get", "/memberships/me")
1428
1457
  };
1458
+ var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1459
+ show: operation("tenants", "get", "/embedded-admin-app"),
1460
+ configure: operation("tenants", "patch", "/embedded-admin-app"),
1461
+ disable: operation("tenants", "delete", "/embedded-admin-app")
1462
+ };
1429
1463
  var EVENTS_ENDPOINT_OPERATIONS = {
1464
+ events: {
1465
+ convertSchedule: operation("events", "post", "/:id/schedule")
1466
+ },
1430
1467
  occurrences: {
1431
1468
  range: operation("event-occurrences", "get", "/range"),
1432
1469
  admissionAvailability: operation(
@@ -1467,46 +1504,51 @@ function resolveOperationMethod(descriptor) {
1467
1504
  }
1468
1505
 
1469
1506
  // src/core/api/endpoints.ts
1470
- var endpoint = (method, path) => ({ method, path });
1471
1507
  var sharedEndpoint = (descriptor) => descriptor;
1472
- function resolveOperationMethod2(descriptor) {
1473
- return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
1474
- }
1475
1508
  function resolveOperationErrorFamily(descriptor) {
1476
- return "collection" in descriptor ? descriptor.errorFamily : void 0;
1477
- }
1478
- function resolveOperationPath2(descriptor, options) {
1479
- if ("collection" in descriptor) {
1480
- return resolveOperationPath(descriptor, options);
1481
- }
1482
- const query = options?.query?.toString().replace(/^\?/, "");
1483
- return query ? `${descriptor.path}?${query}` : descriptor.path;
1509
+ return descriptor.errorFamily;
1484
1510
  }
1485
1511
  var COMMERCE_ENDPOINTS = {
1486
1512
  products: {
1487
- detail: endpoint("GET", "/api/products/detail"),
1488
- detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
1489
- listingGroups: endpoint("GET", "/api/products/listing-groups"),
1490
- listingGroupsCatalog: endpoint(
1491
- "GET",
1492
- "/api/products/listing-groups/catalog"
1513
+ detail: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.detail),
1514
+ detailCatalog: sharedEndpoint(
1515
+ COMMERCE_ENDPOINT_OPERATIONS.products.detailCatalog
1516
+ ),
1517
+ listingGroups: sharedEndpoint(
1518
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroups
1519
+ ),
1520
+ listingGroupsCatalog: sharedEndpoint(
1521
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsCatalog
1493
1522
  ),
1494
- listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
1495
- listingGroupsQueryCatalog: endpoint(
1496
- "GET",
1497
- "/api/products/listing-groups/query/catalog"
1523
+ // The manifest keeps the GET read and the POST body-query apart; this
1524
+ // semantic name has always resolved to the GET one.
1525
+ listingGroupsQuery: sharedEndpoint(
1526
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryGet
1498
1527
  ),
1499
- stockCheck: endpoint("POST", "/api/products/stock-check"),
1500
- stockSnapshot: endpoint("GET", "/api/products/stock"),
1501
- upsert: endpoint("POST", "/api/products/upsert")
1528
+ listingGroupsQueryCatalog: sharedEndpoint(
1529
+ COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog
1530
+ ),
1531
+ stockCheck: sharedEndpoint(
1532
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockCheck
1533
+ ),
1534
+ stockSnapshot: sharedEndpoint(
1535
+ COMMERCE_ENDPOINT_OPERATIONS.products.stockSnapshot
1536
+ ),
1537
+ upsert: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.products.upsert)
1502
1538
  },
1503
1539
  orders: {
1504
- update: endpoint("POST", "/api/orders/update"),
1505
- byPayment: endpoint("GET", "/api/orders/by-payment"),
1506
- cancel: endpoint("POST", "/api/orders/cancel"),
1507
- resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
1508
- createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
1509
- updateFulfillment: endpoint("POST", "/api/orders/update-fulfillment")
1540
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.update),
1541
+ byPayment: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.byPayment),
1542
+ cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.cancel),
1543
+ resolveCancelRefund: sharedEndpoint(
1544
+ COMMERCE_ENDPOINT_OPERATIONS.orders.resolveCancelRefund
1545
+ ),
1546
+ createFulfillment: sharedEndpoint(
1547
+ COMMERCE_ENDPOINT_OPERATIONS.orders.createFulfillment
1548
+ ),
1549
+ updateFulfillment: sharedEndpoint(
1550
+ COMMERCE_ENDPOINT_OPERATIONS.orders.updateFulfillment
1551
+ )
1510
1552
  },
1511
1553
  checkouts: {
1512
1554
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
@@ -1518,18 +1560,21 @@ var COMMERCE_ENDPOINTS = {
1518
1560
  }
1519
1561
  },
1520
1562
  returns: {
1521
- create: endpoint("POST", "/api/returns/create"),
1522
- update: endpoint("POST", "/api/returns/update"),
1523
- returnRefund: endpoint("POST", "/api/returns/return-refund")
1563
+ create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.create),
1564
+ update: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.returns.update),
1565
+ returnRefund: sharedEndpoint(
1566
+ COMMERCE_ENDPOINT_OPERATIONS.returns.returnRefund
1567
+ )
1524
1568
  },
1525
1569
  fulfillmentOrders: {
1526
- prepare: endpoint(
1527
- "POST",
1528
- "/api/fulfillment-orders/prepare-fulfillment-order"
1570
+ prepare: sharedEndpoint(
1571
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
1529
1572
  )
1530
1573
  },
1531
1574
  fulfillments: {
1532
- bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
1575
+ bulkImport: sharedEndpoint(
1576
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
1577
+ )
1533
1578
  },
1534
1579
  carts: {
1535
1580
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
@@ -1594,42 +1639,21 @@ var COMMERCE_ENDPOINTS = {
1594
1639
  ),
1595
1640
  confirm: sharedEndpoint(
1596
1641
  COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm
1642
+ ),
1643
+ findPortOne: sharedEndpoint(
1644
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.findPortOne
1645
+ ),
1646
+ reconcilePortOne: sharedEndpoint(
1647
+ COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.reconcilePortOne
1597
1648
  )
1598
1649
  }
1599
1650
  },
1600
1651
  shippingPolicies: {
1601
- calculate: endpoint("POST", "/api/shipping-policies/calculate")
1652
+ calculate: sharedEndpoint(
1653
+ COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
1654
+ )
1602
1655
  }
1603
1656
  };
1604
- function isCommerceEndpointDescriptor(value) {
1605
- if (!value || typeof value !== "object") return false;
1606
- const candidate = value;
1607
- return typeof candidate.method === "string" && typeof candidate.path === "string";
1608
- }
1609
- function flattenEndpointPaths(value) {
1610
- if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
1611
- if (!value || typeof value !== "object") return [];
1612
- return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
1613
- }
1614
- function flattenEndpointDescriptors(value) {
1615
- if (isCommerceEndpointDescriptor(value)) return [value];
1616
- if (!value || typeof value !== "object") return [];
1617
- return Object.values(value).flatMap(
1618
- (entry) => flattenEndpointDescriptors(entry)
1619
- );
1620
- }
1621
- var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
1622
- var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
1623
- var MEMBERSHIP_ENDPOINTS = {
1624
- subscribe: "/api/memberships/subscribe",
1625
- cancel: (id) => `/api/memberships/${id}/cancel`,
1626
- me: "/api/memberships/me"
1627
- };
1628
- var MEMBERSHIP_ENDPOINT_PATHS = [
1629
- MEMBERSHIP_ENDPOINTS.subscribe,
1630
- MEMBERSHIP_ENDPOINTS.cancel(":id"),
1631
- MEMBERSHIP_ENDPOINTS.me
1632
- ];
1633
1657
 
1634
1658
  // src/core/api/customer-scoped-api.ts
1635
1659
  var CustomerScopedTransport = class {
@@ -1650,10 +1674,10 @@ var CustomerScopedTransport = class {
1650
1674
  this.onUnauthorized = options.onUnauthorized;
1651
1675
  this.onRequestId = options.onRequestId;
1652
1676
  }
1653
- async request(endpoint2, options) {
1677
+ async request(endpoint, options) {
1654
1678
  const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1655
1679
  try {
1656
- const response = await httpFetch(endpoint2, {
1680
+ const response = await httpFetch(endpoint, {
1657
1681
  method: options.method,
1658
1682
  apiUrl: this.apiUrl,
1659
1683
  publishableKey: this.publishableKey,
@@ -1667,7 +1691,7 @@ var CustomerScopedTransport = class {
1667
1691
  ...options.errorFamily && { errorFamily: options.errorFamily }
1668
1692
  });
1669
1693
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1670
- return parseApiResponse(response, endpoint2, {
1694
+ return parseApiResponse(response, endpoint, {
1671
1695
  errorFamily: options.errorFamily
1672
1696
  });
1673
1697
  } catch (err) {
@@ -1681,12 +1705,12 @@ var CustomerScopedApi = class {
1681
1705
  constructor(apiName, options) {
1682
1706
  this.transport = new CustomerScopedTransport(apiName, options);
1683
1707
  }
1684
- requestEndpoint(endpoint2, body, options) {
1685
- return this.transport.request(resolveOperationPath2(endpoint2, options), {
1686
- method: resolveOperationMethod2(endpoint2),
1708
+ requestEndpoint(endpoint, body, options) {
1709
+ return this.transport.request(resolveOperationPath(endpoint, options), {
1710
+ method: resolveOperationMethod(endpoint),
1687
1711
  body,
1688
1712
  headers: options?.headers,
1689
- errorFamily: resolveOperationErrorFamily(endpoint2)
1713
+ errorFamily: resolveOperationErrorFamily(endpoint)
1690
1714
  });
1691
1715
  }
1692
1716
  };
@@ -1694,8 +1718,8 @@ var RawCustomerScopedApi = class {
1694
1718
  constructor(apiName, options) {
1695
1719
  this.transport = new CustomerScopedTransport(apiName, options);
1696
1720
  }
1697
- request(endpoint2, options) {
1698
- return this.transport.request(endpoint2, options);
1721
+ request(endpoint, options) {
1722
+ return this.transport.request(endpoint, options);
1699
1723
  }
1700
1724
  };
1701
1725
 
@@ -1770,11 +1794,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
1770
1794
  if (params.page !== void 0) urlParams.set("page", String(params.page));
1771
1795
  return `/api/comments/public?${urlParams.toString()}`;
1772
1796
  }
1773
- async execute(endpoint2, method, body) {
1774
- return this.request(endpoint2, { method, body });
1797
+ async execute(endpoint, method, body) {
1798
+ return this.request(endpoint, { method, body });
1775
1799
  }
1776
- async executeDoc(endpoint2, method, body) {
1777
- const response = await this.execute(endpoint2, method, body);
1800
+ async executeDoc(endpoint, method, body) {
1801
+ const response = await this.execute(endpoint, method, body);
1778
1802
  return unwrapPayloadDoc(response);
1779
1803
  }
1780
1804
  createPost(params) {
@@ -2040,8 +2064,8 @@ var CommunityClient = class extends RawCustomerScopedApi {
2040
2064
 
2041
2065
  // src/core/content/content-client.ts
2042
2066
  var PublicContentApi = class extends RawCustomerScopedApi {
2043
- get(endpoint2) {
2044
- return this.request(endpoint2, { method: "GET" });
2067
+ get(endpoint) {
2068
+ return this.request(endpoint, { method: "GET" });
2045
2069
  }
2046
2070
  };
2047
2071
  function appendCommonParams(search, options, defaultSort) {
@@ -2222,6 +2246,9 @@ function nullableString(value, resource, path) {
2222
2246
  fail(resource, path, "string or null");
2223
2247
  }
2224
2248
  }
2249
+ function nullableNonEmptyString(value, resource, path) {
2250
+ if (value !== null) string(value, resource, path);
2251
+ }
2225
2252
  function cartLineQuantity(value, resource, path) {
2226
2253
  const quantity = positiveInteger(value, resource, path);
2227
2254
  if (quantity > MAX_CART_LINE_QUANTITY) {
@@ -2731,8 +2758,8 @@ function validatePublicOrderItem(value, resource, path) {
2731
2758
  validateReference(item.variant, resource, `${path}.variant`);
2732
2759
  }
2733
2760
  string(item.productTitle, resource, `${path}.productTitle`);
2734
- nullableString(item.variantTitle, resource, `${path}.variantTitle`);
2735
- nullableString(item.sku, resource, `${path}.sku`);
2761
+ nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
2762
+ nullableNonEmptyString(item.sku, resource, `${path}.sku`);
2736
2763
  validateAdmissions(item.admissions, resource, `${path}.admissions`);
2737
2764
  const quantity = positiveInteger(item.quantity, resource, `${path}.quantity`);
2738
2765
  const unitPrice = safeMinor(
@@ -2983,8 +3010,8 @@ function validateCheckoutItem(value, resource, path) {
2983
3010
  validateReference(item.product, resource, `${path}.product`);
2984
3011
  validateReference(item.variant, resource, `${path}.variant`);
2985
3012
  string(item.productTitle, resource, `${path}.productTitle`);
2986
- nullableString(item.variantTitle, resource, `${path}.variantTitle`);
2987
- nullableString(item.sku, resource, `${path}.sku`);
3013
+ nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
3014
+ nullableNonEmptyString(item.sku, resource, `${path}.sku`);
2988
3015
  validateAdmissions(item.admissions, resource, `${path}.admissions`);
2989
3016
  cartLineQuantity(item.quantity, resource, `${path}.quantity`);
2990
3017
  const unitPrice = safeMinor(
@@ -3316,11 +3343,21 @@ function validateNextAction(value, provider, resource, path) {
3316
3343
  const action = record(value, resource, path);
3317
3344
  if (provider === "portone") {
3318
3345
  if (action.type === "portone_sdk") {
3346
+ const hasCancelable = "cancelable" in action;
3347
+ const hasRetryPolicy = "retryPolicy" in action;
3348
+ if (hasCancelable !== hasRetryPolicy) {
3349
+ fail(
3350
+ resource,
3351
+ path,
3352
+ "exact released action or exact negotiated capability action"
3353
+ );
3354
+ }
3319
3355
  exact(
3320
3356
  action,
3321
3357
  [
3322
3358
  "type",
3323
3359
  "version",
3360
+ ...hasCancelable ? ["cancelable", "retryPolicy"] : [],
3324
3361
  "storeId",
3325
3362
  "channelKey",
3326
3363
  "paymentId",
@@ -3335,6 +3372,11 @@ function validateNextAction(value, provider, resource, path) {
3335
3372
  path
3336
3373
  );
3337
3374
  if (action.version !== "v2") fail(resource, `${path}.version`, "v2");
3375
+ if (hasCancelable && action.cancelable !== false)
3376
+ fail(resource, `${path}.cancelable`, "false");
3377
+ if (hasRetryPolicy && action.retryPolicy !== "same_action_only") {
3378
+ fail(resource, `${path}.retryPolicy`, "same_action_only");
3379
+ }
3338
3380
  for (const key of ["storeId", "channelKey"]) {
3339
3381
  boundedString(action[key], 255, resource, `${path}.${key}`);
3340
3382
  }
@@ -3381,6 +3423,10 @@ function validateNextAction(value, provider, resource, path) {
3381
3423
  "HTTPS or loopback URL without embedded credentials"
3382
3424
  );
3383
3425
  }
3426
+ if (!hasCancelable) {
3427
+ action.cancelable = false;
3428
+ action.retryPolicy = "same_action_only";
3429
+ }
3384
3430
  return;
3385
3431
  }
3386
3432
  exact(action, ["type", "checkoutUrl"], [], resource, path);
@@ -4111,8 +4157,8 @@ var CartApi = class extends CustomerScopedApi {
4111
4157
  endpoint(key) {
4112
4158
  return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
4113
4159
  }
4114
- execute(endpoint2, body, idempotencyKey) {
4115
- return this.requestEndpoint(endpoint2, body, {
4160
+ execute(endpoint, body, idempotencyKey) {
4161
+ return this.requestEndpoint(endpoint, body, {
4116
4162
  ...idempotencyKey && {
4117
4163
  headers: { "X-Idempotency-Key": idempotencyKey }
4118
4164
  }
@@ -4129,26 +4175,26 @@ var CartApi = class extends CustomerScopedApi {
4129
4175
  );
4130
4176
  }
4131
4177
  mine(params = {}) {
4132
- const endpoint2 = this.endpoint("mine");
4133
- return this.execute(endpoint2, params).then(
4178
+ const endpoint = this.endpoint("mine");
4179
+ return this.execute(endpoint, params).then(
4134
4180
  (value) => validateCartMineResult(value)
4135
4181
  );
4136
4182
  }
4137
4183
  merge(params) {
4138
4184
  const { idempotencyKey, ...body } = params;
4139
4185
  assertCommerceIdempotencyKey(idempotencyKey);
4140
- const endpoint2 = this.endpoint("merge");
4141
- return this.execute(endpoint2, body, idempotencyKey).then(
4186
+ const endpoint = this.endpoint("merge");
4187
+ return this.execute(endpoint, body, idempotencyKey).then(
4142
4188
  (value) => validateCartMergeResult(value)
4143
4189
  );
4144
4190
  }
4145
4191
  addItem(params) {
4146
4192
  return this.mutate(this.endpoint("addItem"), params);
4147
4193
  }
4148
- mutate(endpoint2, params) {
4194
+ mutate(endpoint, params) {
4149
4195
  const { idempotencyKey, ...body } = params;
4150
4196
  assertCommerceIdempotencyKey(idempotencyKey);
4151
- return this.execute(endpoint2, body, idempotencyKey).then(
4197
+ return this.execute(endpoint, body, idempotencyKey).then(
4152
4198
  (value) => validateCartMutationResult(value)
4153
4199
  );
4154
4200
  }
@@ -4174,8 +4220,8 @@ var CheckoutApi = class extends CustomerScopedApi {
4174
4220
  constructor(options) {
4175
4221
  super("CheckoutApi", { ...options, requiresCredential: false });
4176
4222
  }
4177
- post(endpoint2, body, idempotencyKey) {
4178
- return this.requestEndpoint(endpoint2, body, {
4223
+ post(endpoint, body, idempotencyKey) {
4224
+ return this.requestEndpoint(endpoint, body, {
4179
4225
  ...idempotencyKey && {
4180
4226
  headers: { "X-Idempotency-Key": idempotencyKey }
4181
4227
  }
@@ -4242,11 +4288,15 @@ var PaymentSessionApi = class extends CustomerScopedApi {
4242
4288
  super("PaymentSessionApi", { ...options, requiresCredential: false });
4243
4289
  this.serverTransport = Boolean(options.secretKey);
4244
4290
  }
4245
- post(endpoint2, body, idempotencyKey) {
4246
- return this.requestEndpoint(endpoint2, body, {
4247
- ...idempotencyKey && {
4248
- headers: { "X-Idempotency-Key": idempotencyKey }
4291
+ post(endpoint, body, idempotencyKey, negotiateStandardActionCapabilities = false) {
4292
+ const headers = {
4293
+ ...idempotencyKey && { "X-Idempotency-Key": idempotencyKey },
4294
+ ...negotiateStandardActionCapabilities && {
4295
+ Accept: PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE
4249
4296
  }
4297
+ };
4298
+ return this.requestEndpoint(endpoint, body, {
4299
+ ...Object.keys(headers).length > 0 && { headers }
4250
4300
  });
4251
4301
  }
4252
4302
  async paymentSession(result, expectedProvider) {
@@ -4271,40 +4321,41 @@ var PaymentSessionApi = class extends CustomerScopedApi {
4271
4321
  this.post(
4272
4322
  this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
4273
4323
  body,
4274
- idempotencyKey
4324
+ idempotencyKey,
4325
+ body.providerOptions.profile === "standard_v2"
4275
4326
  ),
4276
4327
  "portone"
4277
4328
  );
4278
4329
  }
4279
4330
  retrieve(params) {
4280
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4331
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4281
4332
  return this.paymentSession(
4282
- this.post(endpoint2, params),
4333
+ this.post(endpoint, params),
4283
4334
  "toss"
4284
4335
  );
4285
4336
  }
4286
4337
  retrievePortOne(params) {
4287
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4338
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.retrieve : COMMERCE_ENDPOINTS.paymentSessions.retrieve;
4288
4339
  return this.paymentSession(
4289
- this.post(endpoint2, params),
4340
+ this.post(endpoint, params, void 0, true),
4290
4341
  "portone"
4291
4342
  );
4292
4343
  }
4293
4344
  cancel(params) {
4294
4345
  const { idempotencyKey, ...body } = params;
4295
4346
  assertCommerceIdempotencyKey(idempotencyKey);
4296
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4347
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4297
4348
  return this.paymentSession(
4298
- this.post(endpoint2, body, idempotencyKey),
4349
+ this.post(endpoint, body, idempotencyKey),
4299
4350
  "toss"
4300
4351
  );
4301
4352
  }
4302
4353
  cancelPortOne(params) {
4303
4354
  const { idempotencyKey, ...body } = params;
4304
4355
  assertCommerceIdempotencyKey(idempotencyKey);
4305
- const endpoint2 = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4356
+ const endpoint = this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.cancel : COMMERCE_ENDPOINTS.paymentSessions.cancel;
4306
4357
  return this.paymentSession(
4307
- this.post(endpoint2, body, idempotencyKey),
4358
+ this.post(endpoint, body, idempotencyKey),
4308
4359
  "portone"
4309
4360
  );
4310
4361
  }
@@ -5445,8 +5496,8 @@ function withProductListingCards(response, options) {
5445
5496
 
5446
5497
  // src/core/commerce/commerce-client.ts
5447
5498
  var BrowserCommerceApi = class extends CustomerScopedApi {
5448
- requestEndpoint(endpoint2, body, options) {
5449
- return super.requestEndpoint(endpoint2, body, options);
5499
+ requestEndpoint(endpoint, body, options) {
5500
+ return super.requestEndpoint(endpoint, body, options);
5450
5501
  }
5451
5502
  };
5452
5503
  var CommerceClient = class {
@@ -5646,11 +5697,11 @@ var EventsClient = class {
5646
5697
  { useCustomerAuth: false }
5647
5698
  );
5648
5699
  }
5649
- async execute(endpoint2, method, body, options = {}) {
5700
+ async execute(endpoint, method, body, options = {}) {
5650
5701
  const useCustomerAuth = options.useCustomerAuth === true;
5651
5702
  const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
5652
5703
  try {
5653
- const response = await httpFetch(endpoint2, {
5704
+ const response = await httpFetch(endpoint, {
5654
5705
  method,
5655
5706
  apiUrl: this.apiUrl,
5656
5707
  publishableKey: this.publishableKey,
@@ -5659,7 +5710,7 @@ var EventsClient = class {
5659
5710
  ...body !== void 0 && { body: JSON.stringify(body) }
5660
5711
  });
5661
5712
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
5662
- return parseApiResponse(response, endpoint2);
5713
+ return parseApiResponse(response, endpoint);
5663
5714
  } catch (err) {
5664
5715
  const id = err instanceof SDKError ? err.requestId ?? null : null;
5665
5716
  this.onRequestId?.(id);