@01.software/sdk 0.48.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 +157 -1
  2. package/MIGRATION.md +56 -0
  3. package/README.md +276 -49
  4. package/dist/client.cjs +375 -161
  5. package/dist/client.cjs.map +1 -1
  6. package/dist/client.d.cts +7 -6
  7. package/dist/client.d.ts +7 -6
  8. package/dist/client.js +375 -161
  9. package/dist/client.js.map +1 -1
  10. package/dist/{collection-client-CBup9yOx.d.cts → collection-client-CWAeuzV4.d.cts} +6 -4
  11. package/dist/{collection-client-D3ExJU-7.d.ts → collection-client-hYvVfHIm.d.ts} +6 -4
  12. package/dist/{const-k9gHylYa.d.ts → const-D8LixhAJ.d.cts} +5 -5
  13. package/dist/{const-BXEi1Kix.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 +64 -15
  27. package/dist/errors.cjs.map +1 -1
  28. package/dist/errors.d.cts +13 -4
  29. package/dist/errors.d.ts +13 -4
  30. package/dist/errors.js +64 -15
  31. package/dist/errors.js.map +1 -1
  32. package/dist/{index-BCM9CTL7.d.cts → index-B0Hjh3Ey.d.ts} +72 -10
  33. package/dist/{index-CHGGkcLj.d.ts → index-Bu0kCc6o.d.cts} +72 -10
  34. package/dist/index.cjs +470 -429
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +9 -67
  37. package/dist/index.d.ts +9 -67
  38. package/dist/index.js +470 -429
  39. package/dist/index.js.map +1 -1
  40. package/dist/{payload-types-B6AZQcB7.d.cts → payload-types-BOsckg8B.d.cts} +396 -57
  41. package/dist/{payload-types-B6AZQcB7.d.ts → payload-types-BOsckg8B.d.ts} +396 -57
  42. package/dist/query.cjs +115 -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 +115 -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 +591 -186
  51. package/dist/server.cjs.map +1 -1
  52. package/dist/server.d.cts +8 -7
  53. package/dist/server.d.ts +8 -7
  54. package/dist/server.js +591 -186
  55. package/dist/server.js.map +1 -1
  56. package/dist/storefront-cache.cjs +22 -0
  57. package/dist/storefront-cache.cjs.map +1 -1
  58. package/dist/storefront-cache.js +22 -0
  59. package/dist/storefront-cache.js.map +1 -1
  60. package/dist/{types-ByD2zii1.d.ts → types-5ZlcAFuU.d.ts} +2 -2
  61. package/dist/{types-8us-_C-Q.d.cts → types-B14sEt1z.d.cts} +2 -2
  62. package/dist/{types-CM2je9Kw.d.cts → types-Bj8j7VHU.d.ts} +107 -26
  63. package/dist/{types-DbA5V3mt.d.ts → types-CM5qiR2k.d.cts} +107 -26
  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 +27 -5
package/dist/server.cjs CHANGED
@@ -28,8 +28,24 @@ __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
- createServerClient: () => createServerClient
33
+ createServerClient: () => createServerClient,
34
+ isApiError: () => isApiError,
35
+ isAuthError: () => isAuthError,
36
+ isCommerceSDKError: () => isCommerceSDKError,
37
+ isConfigError: () => isConfigError,
38
+ isConflictError: () => isConflictError,
39
+ isGoneError: () => isGoneError,
40
+ isNetworkError: () => isNetworkError,
41
+ isNotFoundError: () => isNotFoundError,
42
+ isPermissionError: () => isPermissionError,
43
+ isRateLimitError: () => isRateLimitError,
44
+ isSDKError: () => isSDKError,
45
+ isServiceUnavailableError: () => isServiceUnavailableError,
46
+ isTimeoutError: () => isTimeoutError,
47
+ isUsageLimitError: () => isUsageLimitError,
48
+ isValidationError: () => isValidationError
33
49
  });
34
50
  module.exports = __toCommonJS(server_exports);
35
51
 
@@ -37,6 +53,24 @@ module.exports = __toCommonJS(server_exports);
37
53
  var import_qs_esm = require("qs-esm");
38
54
 
39
55
  // src/core/errors.ts
56
+ var SDK_ERROR_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError");
57
+ var SDK_ERROR_TYPE_BRAND = /* @__PURE__ */ Symbol.for("@01.software/sdk/SDKError.type");
58
+ function defineSDKErrorBrand(error) {
59
+ Object.defineProperty(error, SDK_ERROR_BRAND, {
60
+ value: true,
61
+ enumerable: false,
62
+ configurable: false,
63
+ writable: false
64
+ });
65
+ }
66
+ function defineSDKErrorType(error, type) {
67
+ Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {
68
+ value: type,
69
+ enumerable: false,
70
+ configurable: false,
71
+ writable: false
72
+ });
73
+ }
40
74
  var SDKError = class extends Error {
41
75
  constructor(code, message, status, details, userMessage, suggestion, requestId) {
42
76
  super(message);
@@ -47,6 +81,7 @@ var SDKError = class extends Error {
47
81
  this.userMessage = userMessage;
48
82
  this.suggestion = suggestion;
49
83
  this.requestId = requestId;
84
+ defineSDKErrorBrand(this);
50
85
  if (Error.captureStackTrace) {
51
86
  Error.captureStackTrace(this, new.target);
52
87
  }
@@ -67,6 +102,7 @@ var SDKError = class extends Error {
67
102
  ...this.kind !== void 0 && { kind: this.kind },
68
103
  ...this.reason !== void 0 && { reason: this.reason },
69
104
  ...this.rawReason !== void 0 && { rawReason: this.rawReason },
105
+ ...this.apiReason !== void 0 && { apiReason: this.apiReason },
70
106
  ...this.retryable !== void 0 && { retryable: this.retryable },
71
107
  ...this.retryAfter !== void 0 && { retryAfter: this.retryAfter }
72
108
  };
@@ -112,6 +148,7 @@ var COMMERCE_ERROR_CODES = [
112
148
  "payment_session_not_cancelable",
113
149
  "payment_session_conflict",
114
150
  "provider_identity_mismatch",
151
+ "managed_refund_attestation_forbidden",
115
152
  "payment_method_unavailable",
116
153
  "provider_unavailable",
117
154
  "lock_timeout",
@@ -240,8 +277,16 @@ function enhanceCommerceError(error, body, headerRequestId) {
240
277
  });
241
278
  return error;
242
279
  }
280
+ function enhanceNonCommerceError(error, reason) {
281
+ if (typeof reason === "string") Object.assign(error, { apiReason: reason });
282
+ return error;
283
+ }
284
+ function getSDKErrorReason(error) {
285
+ if (error.kind !== "commerce") return error.apiReason;
286
+ return error.reason === "unknown_commerce_error" ? error.rawReason : error.reason;
287
+ }
243
288
  function isCommerceSDKError(error) {
244
- if (!(error instanceof SDKError) || error.kind !== "commerce") return false;
289
+ if (!isSDKError(error) || error.kind !== "commerce") return false;
245
290
  if (typeof error.requestId !== "string" || typeof error.retryable !== "boolean" || error.retryAfter !== void 0 && (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0) || typeof error.reason !== "string") {
246
291
  return false;
247
292
  }
@@ -251,12 +296,14 @@ var NetworkError = class extends SDKError {
251
296
  constructor(message, status, details, userMessage, suggestion) {
252
297
  super("NETWORK_ERROR", message, status, details, userMessage, suggestion);
253
298
  this.name = "NetworkError";
299
+ defineSDKErrorType(this, "NetworkError");
254
300
  }
255
301
  };
256
302
  var ValidationError = class extends SDKError {
257
303
  constructor(message, details, userMessage, suggestion, status = 400) {
258
304
  super("VALIDATION_ERROR", message, status, details, userMessage, suggestion);
259
305
  this.name = "ValidationError";
306
+ defineSDKErrorType(this, "ValidationError");
260
307
  }
261
308
  };
262
309
  var ApiError = class extends SDKError {
@@ -271,24 +318,28 @@ var ApiError = class extends SDKError {
271
318
  requestId
272
319
  );
273
320
  this.name = "ApiError";
321
+ defineSDKErrorType(this, "ApiError");
274
322
  }
275
323
  };
276
324
  var ConfigError = class extends SDKError {
277
325
  constructor(message, details, userMessage, suggestion) {
278
326
  super("CONFIG_ERROR", message, void 0, details, userMessage, suggestion);
279
327
  this.name = "ConfigError";
328
+ defineSDKErrorType(this, "ConfigError");
280
329
  }
281
330
  };
282
331
  var TimeoutError = class extends SDKError {
283
332
  constructor(message = "Request timed out.", details, userMessage, suggestion) {
284
333
  super("TIMEOUT_ERROR", message, 408, details, userMessage, suggestion);
285
334
  this.name = "TimeoutError";
335
+ defineSDKErrorType(this, "TimeoutError");
286
336
  }
287
337
  };
288
338
  var GoneError = class extends SDKError {
289
339
  constructor(message = "The requested resource is no longer available.", details, userMessage, suggestion) {
290
340
  super("GONE_ERROR", message, 410, details, userMessage, suggestion);
291
341
  this.name = "GoneError";
342
+ defineSDKErrorType(this, "GoneError");
292
343
  }
293
344
  };
294
345
  var ServiceUnavailableError = class extends SDKError {
@@ -303,6 +354,7 @@ var ServiceUnavailableError = class extends SDKError {
303
354
  );
304
355
  this.name = "ServiceUnavailableError";
305
356
  this.retryAfter = retryAfter;
357
+ defineSDKErrorType(this, "ServiceUnavailableError");
306
358
  }
307
359
  };
308
360
  var UsageLimitError = class extends SDKError {
@@ -310,6 +362,7 @@ var UsageLimitError = class extends SDKError {
310
362
  super("USAGE_LIMIT_ERROR", message, 429, details, userMessage, suggestion);
311
363
  this.name = "UsageLimitError";
312
364
  this.usage = usage;
365
+ defineSDKErrorType(this, "UsageLimitError");
313
366
  }
314
367
  toJSON() {
315
368
  return {
@@ -330,6 +383,7 @@ var AuthError = class extends SDKError {
330
383
  requestId
331
384
  );
332
385
  this.name = "AuthError";
386
+ defineSDKErrorType(this, "AuthError");
333
387
  }
334
388
  };
335
389
  var PermissionError = class extends SDKError {
@@ -344,6 +398,7 @@ var PermissionError = class extends SDKError {
344
398
  requestId
345
399
  );
346
400
  this.name = "PermissionError";
401
+ defineSDKErrorType(this, "PermissionError");
347
402
  }
348
403
  };
349
404
  var NotFoundError = class extends SDKError {
@@ -358,12 +413,14 @@ var NotFoundError = class extends SDKError {
358
413
  requestId
359
414
  );
360
415
  this.name = "NotFoundError";
416
+ defineSDKErrorType(this, "NotFoundError");
361
417
  }
362
418
  };
363
419
  var ConflictError = class extends SDKError {
364
420
  constructor(message, details, userMessage, suggestion, requestId) {
365
421
  super("conflict", message, 409, details, userMessage, suggestion, requestId);
366
422
  this.name = "ConflictError";
423
+ defineSDKErrorType(this, "ConflictError");
367
424
  }
368
425
  };
369
426
  var RateLimitError = class extends SDKError {
@@ -379,8 +436,64 @@ var RateLimitError = class extends SDKError {
379
436
  );
380
437
  this.name = "RateLimitError";
381
438
  this.retryAfter = retryAfter;
439
+ defineSDKErrorType(this, "RateLimitError");
382
440
  }
383
441
  };
442
+ function hasBrandedSDKErrorShape(error) {
443
+ if (error === null || typeof error !== "object") return false;
444
+ const candidate = error;
445
+ return candidate[SDK_ERROR_BRAND] === true && typeof candidate.name === "string" && typeof candidate.code === "string" && typeof candidate.message === "string" && (candidate.status === void 0 || typeof candidate.status === "number") && (candidate.userMessage === void 0 || typeof candidate.userMessage === "string") && (candidate.suggestion === void 0 || typeof candidate.suggestion === "string") && (candidate.requestId === void 0 || typeof candidate.requestId === "string") && (candidate.kind === void 0 || candidate.kind === "commerce") && (candidate.reason === void 0 || typeof candidate.reason === "string") && (candidate.rawReason === void 0 || typeof candidate.rawReason === "string") && (candidate.apiReason === void 0 || typeof candidate.apiReason === "string") && (candidate.retryable === void 0 || typeof candidate.retryable === "boolean") && (candidate.retryAfter === void 0 || typeof candidate.retryAfter === "number") && typeof candidate.getUserMessage === "function" && typeof candidate.toJSON === "function";
446
+ }
447
+ function hasSDKErrorType(error, type) {
448
+ return hasBrandedSDKErrorShape(error) && error[SDK_ERROR_TYPE_BRAND] === type;
449
+ }
450
+ function isSDKError(error) {
451
+ return error instanceof SDKError || hasBrandedSDKErrorShape(error);
452
+ }
453
+ function isNetworkError(error) {
454
+ return error instanceof NetworkError || hasSDKErrorType(error, "NetworkError");
455
+ }
456
+ function isValidationError(error) {
457
+ if (error instanceof ValidationError || hasSDKErrorType(error, "ValidationError")) {
458
+ return true;
459
+ }
460
+ if (error == null || typeof error !== "object") return false;
461
+ const candidate = error;
462
+ return candidate.name === "ValidationError" && candidate.code === "VALIDATION_ERROR" && typeof candidate.message === "string" && typeof candidate.getUserMessage === "function" && typeof candidate.toJSON === "function";
463
+ }
464
+ function isApiError(error) {
465
+ return error instanceof ApiError || hasSDKErrorType(error, "ApiError");
466
+ }
467
+ function isConfigError(error) {
468
+ return error instanceof ConfigError || hasSDKErrorType(error, "ConfigError");
469
+ }
470
+ function isTimeoutError(error) {
471
+ return error instanceof TimeoutError || hasSDKErrorType(error, "TimeoutError");
472
+ }
473
+ function isGoneError(error) {
474
+ return error instanceof GoneError || hasSDKErrorType(error, "GoneError");
475
+ }
476
+ function isServiceUnavailableError(error) {
477
+ return error instanceof ServiceUnavailableError || hasSDKErrorType(error, "ServiceUnavailableError");
478
+ }
479
+ function isUsageLimitError(error) {
480
+ return error instanceof UsageLimitError || hasSDKErrorType(error, "UsageLimitError");
481
+ }
482
+ function isAuthError(error) {
483
+ return error instanceof AuthError || hasSDKErrorType(error, "AuthError");
484
+ }
485
+ function isPermissionError(error) {
486
+ return error instanceof PermissionError || hasSDKErrorType(error, "PermissionError");
487
+ }
488
+ function isNotFoundError(error) {
489
+ return error instanceof NotFoundError || hasSDKErrorType(error, "NotFoundError");
490
+ }
491
+ function isConflictError(error) {
492
+ return error instanceof ConflictError || hasSDKErrorType(error, "ConflictError");
493
+ }
494
+ function isRateLimitError(error) {
495
+ return error instanceof RateLimitError || hasSDKErrorType(error, "RateLimitError");
496
+ }
384
497
  var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
385
498
  var createValidationError = (message, details, userMessage, suggestion, status) => new ValidationError(message, details, userMessage, suggestion, status);
386
499
  var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
@@ -578,11 +691,11 @@ function parseRetryAfter(response) {
578
691
  permitsAutomaticRetry: seconds <= MAX_AUTOMATIC_RETRY_AFTER_SECONDS
579
692
  };
580
693
  }
581
- function mapResponseToError(status, parsed, details, requestId, retryAfter, errorFamily) {
694
+ function mapResponseToError(status, parsed, details, requestId, retryAfter, canonicalCommerceError) {
582
695
  const errorDetails = {
583
696
  ...details,
584
697
  ...parsed.errors && { errors: parsed.errors },
585
- ...errorFamily !== "commerce" && parsed.body && { body: parsed.body }
698
+ ...!canonicalCommerceError && parsed.body && { body: parsed.body }
586
699
  };
587
700
  const suggestion = getParsedErrorSuggestion(status, parsed);
588
701
  const finalize = (error) => {
@@ -590,7 +703,7 @@ function mapResponseToError(status, parsed, details, requestId, retryAfter, erro
590
703
  if (retryAfter !== void 0) {
591
704
  Object.assign(withRequestId, { retryAfter });
592
705
  }
593
- return errorFamily === "commerce" ? enhanceCommerceError(withRequestId, parsed.body, requestId) : withRequestId;
706
+ return canonicalCommerceError ? enhanceCommerceError(withRequestId, parsed.body, requestId) : enhanceNonCommerceError(withRequestId, parsed.reason);
594
707
  };
595
708
  if (status === 400 || status === 422) {
596
709
  return finalize(
@@ -696,6 +809,7 @@ async function httpFetch(url, options) {
696
809
  retry,
697
810
  onUnauthorized,
698
811
  errorFamily,
812
+ typedCommerceErrorReasons,
699
813
  ...requestInit
700
814
  } = options || {};
701
815
  const baseUrl = resolveApiUrl(apiUrl);
@@ -749,7 +863,8 @@ async function httpFetch(url, options) {
749
863
  });
750
864
  if (!response.ok) {
751
865
  const parsed = await parseErrorBody(response);
752
- 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;
753
868
  if (isUsageLimitExceededResponse(response)) {
754
869
  const limit = parseInt(
755
870
  response.headers.get("X-Usage-Limit") || "0",
@@ -777,7 +892,7 @@ async function httpFetch(url, options) {
777
892
  ),
778
893
  requestId
779
894
  );
780
- throw errorFamily === "commerce" ? enhanceCommerceError(usageError, parsed.body, requestId) : usageError;
895
+ throw canonicalCommerceError ? enhanceCommerceError(usageError, parsed.body, requestId) : enhanceNonCommerceError(usageError, parsed.reason);
781
896
  }
782
897
  if (response.status === 401 && onUnauthorized && customerToken && !hasRetried401 && (commerceEnvelope?.reason ?? parsed.reason) === "token_expired") {
783
898
  hasRetried401 = true;
@@ -802,7 +917,7 @@ async function httpFetch(url, options) {
802
917
  details,
803
918
  requestId,
804
919
  retryAfter.seconds,
805
- errorFamily
920
+ canonicalCommerceError
806
921
  );
807
922
  const method2 = (requestInit.method || "GET").toUpperCase();
808
923
  const isTerminal = error instanceof RateLimitError || error instanceof UsageLimitError;
@@ -980,15 +1095,15 @@ var HttpClient = class {
980
1095
  throw err;
981
1096
  }
982
1097
  }
983
- buildUrl(endpoint2, options) {
984
- if (!options) return endpoint2;
1098
+ buildUrl(endpoint, options) {
1099
+ if (!options) return endpoint;
985
1100
  const { fallbackLocale, ...rest } = options;
986
1101
  const queryOptions = fallbackLocale === void 0 ? rest : {
987
1102
  ...rest,
988
1103
  "fallback-locale": fallbackLocale === false ? "none" : fallbackLocale
989
1104
  };
990
1105
  const queryString = (0, import_qs_esm.stringify)(queryOptions, { addQueryPrefix: true });
991
- return queryString ? `${endpoint2}${queryString}` : endpoint2;
1106
+ return queryString ? `${endpoint}${queryString}` : endpoint;
992
1107
  }
993
1108
  assertJsonResponse(response) {
994
1109
  const contentType = response.headers.get("content-type");
@@ -1179,16 +1294,16 @@ var CollectionQueryBuilder = class {
1179
1294
  * @returns Payload CMS mutation response with doc and message
1180
1295
  */
1181
1296
  async create(data, options) {
1182
- const endpoint2 = `/api/${String(this.collection)}`;
1297
+ const endpoint = `/api/${String(this.collection)}`;
1183
1298
  if (options?.file) {
1184
1299
  return this.api.requestCreateWithFile(
1185
- endpoint2,
1300
+ endpoint,
1186
1301
  data,
1187
1302
  options.file,
1188
1303
  options.filename
1189
1304
  );
1190
1305
  }
1191
- return this.api.requestCreate(endpoint2, data);
1306
+ return this.api.requestCreate(endpoint, data);
1192
1307
  }
1193
1308
  /**
1194
1309
  * Update a document by ID
@@ -1196,16 +1311,16 @@ var CollectionQueryBuilder = class {
1196
1311
  * @returns Payload CMS mutation response with doc and message
1197
1312
  */
1198
1313
  async update(id, data, options) {
1199
- const endpoint2 = `/api/${String(this.collection)}/${String(id)}`;
1314
+ const endpoint = `/api/${String(this.collection)}/${String(id)}`;
1200
1315
  if (options?.file) {
1201
1316
  return this.api.requestUpdateWithFile(
1202
- endpoint2,
1317
+ endpoint,
1203
1318
  data,
1204
1319
  options.file,
1205
1320
  options.filename
1206
1321
  );
1207
1322
  }
1208
- return this.api.requestUpdate(endpoint2, data);
1323
+ return this.api.requestUpdate(endpoint, data);
1209
1324
  }
1210
1325
  /**
1211
1326
  * Count documents
@@ -1301,8 +1416,8 @@ var CollectionClient = class extends HttpClient {
1301
1416
  * Find documents (list query)
1302
1417
  * GET /api/{collection}
1303
1418
  */
1304
- async requestFind(endpoint2, options) {
1305
- const url = this.buildUrl(endpoint2, options);
1419
+ async requestFind(endpoint, options) {
1420
+ const url = this.buildUrl(endpoint, options);
1306
1421
  const response = await this.fetchWithTracking(url, {
1307
1422
  ...this.defaultOptions,
1308
1423
  method: "GET"
@@ -1313,8 +1428,8 @@ var CollectionClient = class extends HttpClient {
1313
1428
  * Find-like response from a custom endpoint
1314
1429
  * POST /api/...custom-endpoint
1315
1430
  */
1316
- async requestFindEndpoint(endpoint2, data) {
1317
- const response = await this.fetchWithTracking(endpoint2, {
1431
+ async requestFindEndpoint(endpoint, data) {
1432
+ const response = await this.fetchWithTracking(endpoint, {
1318
1433
  ...this.defaultOptions,
1319
1434
  method: "POST",
1320
1435
  body: data ? JSON.stringify(data) : void 0
@@ -1324,8 +1439,8 @@ var CollectionClient = class extends HttpClient {
1324
1439
  /**
1325
1440
  * Find-like response from a cacheable GET custom endpoint.
1326
1441
  */
1327
- async requestFindEndpointGet(endpoint2) {
1328
- const response = await this.fetchWithTracking(endpoint2, {
1442
+ async requestFindEndpointGet(endpoint) {
1443
+ const response = await this.fetchWithTracking(endpoint, {
1329
1444
  ...this.defaultOptions,
1330
1445
  method: "GET"
1331
1446
  });
@@ -1335,8 +1450,8 @@ var CollectionClient = class extends HttpClient {
1335
1450
  * Find document by ID
1336
1451
  * GET /api/{collection}/{id}
1337
1452
  */
1338
- async requestFindById(endpoint2, options) {
1339
- const url = this.buildUrl(endpoint2, options);
1453
+ async requestFindById(endpoint, options) {
1454
+ const url = this.buildUrl(endpoint, options);
1340
1455
  const response = await this.fetchWithTracking(url, {
1341
1456
  ...this.defaultOptions,
1342
1457
  method: "GET"
@@ -1347,8 +1462,8 @@ var CollectionClient = class extends HttpClient {
1347
1462
  * Create document
1348
1463
  * POST /api/{collection}
1349
1464
  */
1350
- async requestCreate(endpoint2, data) {
1351
- const response = await this.fetchWithTracking(endpoint2, {
1465
+ async requestCreate(endpoint, data) {
1466
+ const response = await this.fetchWithTracking(endpoint, {
1352
1467
  ...this.defaultOptions,
1353
1468
  method: "POST",
1354
1469
  body: data ? JSON.stringify(data) : void 0
@@ -1359,8 +1474,8 @@ var CollectionClient = class extends HttpClient {
1359
1474
  * Update document
1360
1475
  * PATCH /api/{collection}/{id}
1361
1476
  */
1362
- async requestUpdate(endpoint2, data) {
1363
- const response = await this.fetchWithTracking(endpoint2, {
1477
+ async requestUpdate(endpoint, data) {
1478
+ const response = await this.fetchWithTracking(endpoint, {
1364
1479
  ...this.defaultOptions,
1365
1480
  method: "PATCH",
1366
1481
  body: data ? JSON.stringify(data) : void 0
@@ -1371,8 +1486,8 @@ var CollectionClient = class extends HttpClient {
1371
1486
  * Count documents
1372
1487
  * GET /api/{collection}/count
1373
1488
  */
1374
- async requestCount(endpoint2, options) {
1375
- const url = this.buildUrl(endpoint2, options);
1489
+ async requestCount(endpoint, options) {
1490
+ const url = this.buildUrl(endpoint, options);
1376
1491
  const response = await this.fetchWithTracking(url, {
1377
1492
  ...this.defaultOptions,
1378
1493
  method: "GET"
@@ -1383,8 +1498,8 @@ var CollectionClient = class extends HttpClient {
1383
1498
  * Update multiple documents (bulk update)
1384
1499
  * PATCH /api/{collection}
1385
1500
  */
1386
- async requestUpdateMany(endpoint2, data) {
1387
- const response = await this.fetchWithTracking(endpoint2, {
1501
+ async requestUpdateMany(endpoint, data) {
1502
+ const response = await this.fetchWithTracking(endpoint, {
1388
1503
  ...this.defaultOptions,
1389
1504
  method: "PATCH",
1390
1505
  body: JSON.stringify(data)
@@ -1395,8 +1510,8 @@ var CollectionClient = class extends HttpClient {
1395
1510
  * Delete document
1396
1511
  * DELETE /api/{collection}/{id}
1397
1512
  */
1398
- async requestDelete(endpoint2, options) {
1399
- const url = this.buildUrl(endpoint2, options);
1513
+ async requestDelete(endpoint, options) {
1514
+ const url = this.buildUrl(endpoint, options);
1400
1515
  const response = await this.fetchWithTracking(url, {
1401
1516
  ...this.defaultOptions,
1402
1517
  method: "DELETE"
@@ -1407,8 +1522,8 @@ var CollectionClient = class extends HttpClient {
1407
1522
  * Delete multiple documents (bulk delete)
1408
1523
  * DELETE /api/{collection}
1409
1524
  */
1410
- async requestDeleteMany(endpoint2, data) {
1411
- const response = await this.fetchWithTracking(endpoint2, {
1525
+ async requestDeleteMany(endpoint, data) {
1526
+ const response = await this.fetchWithTracking(endpoint, {
1412
1527
  ...this.defaultOptions,
1413
1528
  method: "DELETE",
1414
1529
  body: JSON.stringify(data)
@@ -1419,8 +1534,8 @@ var CollectionClient = class extends HttpClient {
1419
1534
  * Create document with file upload
1420
1535
  * POST /api/{collection} (multipart/form-data)
1421
1536
  */
1422
- async requestCreateWithFile(endpoint2, data, file, filename) {
1423
- const response = await this.fetchWithTracking(endpoint2, {
1537
+ async requestCreateWithFile(endpoint, data, file, filename) {
1538
+ const response = await this.fetchWithTracking(endpoint, {
1424
1539
  ...this.defaultOptions,
1425
1540
  method: "POST",
1426
1541
  body: buildPayloadFormData(data, file, filename)
@@ -1431,8 +1546,8 @@ var CollectionClient = class extends HttpClient {
1431
1546
  * Update document with file upload
1432
1547
  * PATCH /api/{collection}/{id} (multipart/form-data)
1433
1548
  */
1434
- async requestUpdateWithFile(endpoint2, data, file, filename) {
1435
- const response = await this.fetchWithTracking(endpoint2, {
1549
+ async requestUpdateWithFile(endpoint, data, file, filename) {
1550
+ const response = await this.fetchWithTracking(endpoint, {
1436
1551
  ...this.defaultOptions,
1437
1552
  method: "PATCH",
1438
1553
  body: buildPayloadFormData(data, file, filename)
@@ -1447,7 +1562,7 @@ var ServerCollectionClient = class extends CollectionClient {
1447
1562
  };
1448
1563
 
1449
1564
  // src/core/api/parse-response.ts
1450
- async function parseApiResponse(response, endpoint2, options = {}) {
1565
+ async function parseApiResponse(response, endpoint, options = {}) {
1451
1566
  if (response.status === 204 || response.headers.get("content-length") === "0") {
1452
1567
  return void 0;
1453
1568
  }
@@ -1456,7 +1571,7 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1456
1571
  parsed = await response.json();
1457
1572
  } catch {
1458
1573
  throw createApiError(
1459
- `Invalid JSON response from ${endpoint2}`,
1574
+ `Invalid JSON response from ${endpoint}`,
1460
1575
  response.status,
1461
1576
  void 0,
1462
1577
  "Server returned an invalid response.",
@@ -1499,13 +1614,14 @@ async function parseApiResponse(response, endpoint2, options = {}) {
1499
1614
  }
1500
1615
  const withRequestId = attachRequestId(error, requestId);
1501
1616
  if (retryAfter !== void 0) Object.assign(withRequestId, { retryAfter });
1502
- throw options.errorFamily === "commerce" ? enhanceCommerceError(withRequestId, data, requestId) : withRequestId;
1617
+ throw options.errorFamily === "commerce" ? enhanceCommerceError(withRequestId, data, requestId) : enhanceNonCommerceError(withRequestId, reason);
1503
1618
  }
1504
1619
  return data;
1505
1620
  }
1506
1621
 
1507
1622
  // ../../internal/http-contracts/src/index.ts
1508
1623
  var operationBrand = /* @__PURE__ */ Symbol("sdk-http-operation");
1624
+ var PORTONE_STANDARD_ACTION_CAPABILITIES_MEDIA_TYPE = "application/vnd.01software.portone-action-capabilities.v1+json";
1509
1625
  var operation = (collection, method, path, errorFamily) => Object.freeze({
1510
1626
  [operationBrand]: true,
1511
1627
  collection,
@@ -1514,6 +1630,10 @@ var operation = (collection, method, path, errorFamily) => Object.freeze({
1514
1630
  ...errorFamily && { errorFamily }
1515
1631
  });
1516
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
+ });
1517
1637
  var COMMERCE_ENDPOINT_OPERATIONS = {
1518
1638
  products: {
1519
1639
  detail: operation("products", "get", "/detail"),
@@ -1545,7 +1665,12 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1545
1665
  confirmPayment: operation("orders", "post", "/confirm-payment"),
1546
1666
  byPayment: operation("orders", "get", "/by-payment"),
1547
1667
  cancel: operation("orders", "post", "/cancel"),
1548
- resolveCancelRefund: operation("orders", "post", "/resolve-cancel-refund"),
1668
+ resolveCancelRefund: selectiveCommerceOperation(
1669
+ "orders",
1670
+ "post",
1671
+ "/resolve-cancel-refund",
1672
+ ["managed_refund_attestation_forbidden"]
1673
+ ),
1549
1674
  checkout: strictCommerceOperation("orders", "post", "/checkout"),
1550
1675
  createFulfillment: operation("orders", "post", "/create-fulfillment"),
1551
1676
  updateFulfillment: operation("orders", "post", "/update-fulfillment")
@@ -1616,6 +1741,16 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1616
1741
  "payment-sessions",
1617
1742
  "post",
1618
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"
1619
1754
  )
1620
1755
  },
1621
1756
  custom: {
@@ -1635,12 +1770,26 @@ var COMMERCE_ENDPOINT_OPERATIONS = {
1635
1770
  validate: operation("discounts", "post", "/validate")
1636
1771
  }
1637
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
+ ]);
1638
1779
  var MEMBERSHIP_ENDPOINT_OPERATIONS = {
1639
1780
  subscribe: operation(null, "post", "/memberships/subscribe"),
1640
1781
  cancel: operation(null, "post", "/memberships/:id/cancel"),
1641
1782
  me: operation(null, "get", "/memberships/me")
1642
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
+ };
1643
1789
  var EVENTS_ENDPOINT_OPERATIONS = {
1790
+ events: {
1791
+ convertSchedule: operation("events", "post", "/:id/schedule")
1792
+ },
1644
1793
  occurrences: {
1645
1794
  range: operation("event-occurrences", "get", "/range"),
1646
1795
  admissionAvailability: operation(
@@ -1681,46 +1830,54 @@ function resolveOperationMethod(descriptor) {
1681
1830
  }
1682
1831
 
1683
1832
  // src/core/api/endpoints.ts
1684
- var endpoint = (method, path) => ({ method, path });
1685
1833
  var sharedEndpoint = (descriptor) => descriptor;
1686
- function resolveOperationMethod2(descriptor) {
1687
- return "collection" in descriptor ? resolveOperationMethod(descriptor) : descriptor.method;
1688
- }
1689
1834
  function resolveOperationErrorFamily(descriptor) {
1690
- return "collection" in descriptor ? descriptor.errorFamily : void 0;
1835
+ return descriptor.errorFamily;
1691
1836
  }
1692
- function resolveOperationPath2(descriptor, options) {
1693
- if ("collection" in descriptor) {
1694
- return resolveOperationPath(descriptor, options);
1695
- }
1696
- const query = options?.query?.toString().replace(/^\?/, "");
1697
- return query ? `${descriptor.path}?${query}` : descriptor.path;
1837
+ function resolveOperationTypedCommerceErrorReasons(descriptor) {
1838
+ return descriptor.typedCommerceErrorReasons;
1698
1839
  }
1699
1840
  var COMMERCE_ENDPOINTS = {
1700
1841
  products: {
1701
- detail: endpoint("GET", "/api/products/detail"),
1702
- detailCatalog: endpoint("GET", "/api/products/detail/catalog"),
1703
- listingGroups: endpoint("GET", "/api/products/listing-groups"),
1704
- listingGroupsCatalog: endpoint(
1705
- "GET",
1706
- "/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
1707
1851
  ),
1708
- listingGroupsQuery: endpoint("GET", "/api/products/listing-groups/query"),
1709
- listingGroupsQueryCatalog: endpoint(
1710
- "GET",
1711
- "/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
1712
1856
  ),
1713
- stockCheck: endpoint("POST", "/api/products/stock-check"),
1714
- stockSnapshot: endpoint("GET", "/api/products/stock"),
1715
- 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)
1716
1867
  },
1717
1868
  orders: {
1718
- update: endpoint("POST", "/api/orders/update"),
1719
- byPayment: endpoint("GET", "/api/orders/by-payment"),
1720
- cancel: endpoint("POST", "/api/orders/cancel"),
1721
- resolveCancelRefund: endpoint("POST", "/api/orders/resolve-cancel-refund"),
1722
- createFulfillment: endpoint("POST", "/api/orders/create-fulfillment"),
1723
- 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
+ )
1724
1881
  },
1725
1882
  checkouts: {
1726
1883
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),
@@ -1732,18 +1889,21 @@ var COMMERCE_ENDPOINTS = {
1732
1889
  }
1733
1890
  },
1734
1891
  returns: {
1735
- create: endpoint("POST", "/api/returns/create"),
1736
- update: endpoint("POST", "/api/returns/update"),
1737
- 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
+ )
1738
1897
  },
1739
1898
  fulfillmentOrders: {
1740
- prepare: endpoint(
1741
- "POST",
1742
- "/api/fulfillment-orders/prepare-fulfillment-order"
1899
+ prepare: sharedEndpoint(
1900
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillmentOrders.prepare
1743
1901
  )
1744
1902
  },
1745
1903
  fulfillments: {
1746
- bulkImport: endpoint("POST", "/api/fulfillments/bulk-import")
1904
+ bulkImport: sharedEndpoint(
1905
+ COMMERCE_ENDPOINT_OPERATIONS.fulfillments.bulkImport
1906
+ )
1747
1907
  },
1748
1908
  carts: {
1749
1909
  create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),
@@ -1808,42 +1968,21 @@ var COMMERCE_ENDPOINTS = {
1808
1968
  ),
1809
1969
  confirm: sharedEndpoint(
1810
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
1811
1977
  )
1812
1978
  }
1813
1979
  },
1814
1980
  shippingPolicies: {
1815
- calculate: endpoint("POST", "/api/shipping-policies/calculate")
1981
+ calculate: sharedEndpoint(
1982
+ COMMERCE_ENDPOINT_OPERATIONS.shippingPolicies.calculate
1983
+ )
1816
1984
  }
1817
1985
  };
1818
- function isCommerceEndpointDescriptor(value) {
1819
- if (!value || typeof value !== "object") return false;
1820
- const candidate = value;
1821
- return typeof candidate.method === "string" && typeof candidate.path === "string";
1822
- }
1823
- function flattenEndpointPaths(value) {
1824
- if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath2(value)];
1825
- if (!value || typeof value !== "object") return [];
1826
- return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry));
1827
- }
1828
- function flattenEndpointDescriptors(value) {
1829
- if (isCommerceEndpointDescriptor(value)) return [value];
1830
- if (!value || typeof value !== "object") return [];
1831
- return Object.values(value).flatMap(
1832
- (entry) => flattenEndpointDescriptors(entry)
1833
- );
1834
- }
1835
- var COMMERCE_ENDPOINT_PATHS = flattenEndpointPaths(COMMERCE_ENDPOINTS);
1836
- var COMMERCE_ENDPOINT_DESCRIPTORS = flattenEndpointDescriptors(COMMERCE_ENDPOINTS);
1837
- var MEMBERSHIP_ENDPOINTS = {
1838
- subscribe: "/api/memberships/subscribe",
1839
- cancel: (id) => `/api/memberships/${id}/cancel`,
1840
- me: "/api/memberships/me"
1841
- };
1842
- var MEMBERSHIP_ENDPOINT_PATHS = [
1843
- MEMBERSHIP_ENDPOINTS.subscribe,
1844
- MEMBERSHIP_ENDPOINTS.cancel(":id"),
1845
- MEMBERSHIP_ENDPOINTS.me
1846
- ];
1847
1986
 
1848
1987
  // src/core/api/customer-scoped-api.ts
1849
1988
  var CustomerScopedTransport = class {
@@ -1864,10 +2003,10 @@ var CustomerScopedTransport = class {
1864
2003
  this.onUnauthorized = options.onUnauthorized;
1865
2004
  this.onRequestId = options.onRequestId;
1866
2005
  }
1867
- async request(endpoint2, options) {
2006
+ async request(endpoint, options) {
1868
2007
  const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
1869
2008
  try {
1870
- const response = await httpFetch(endpoint2, {
2009
+ const response = await httpFetch(endpoint, {
1871
2010
  method: options.method,
1872
2011
  apiUrl: this.apiUrl,
1873
2012
  publishableKey: this.publishableKey,
@@ -1881,7 +2020,7 @@ var CustomerScopedTransport = class {
1881
2020
  ...options.errorFamily && { errorFamily: options.errorFamily }
1882
2021
  });
1883
2022
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
1884
- return parseApiResponse(response, endpoint2, {
2023
+ return parseApiResponse(response, endpoint, {
1885
2024
  errorFamily: options.errorFamily
1886
2025
  });
1887
2026
  } catch (err) {
@@ -1895,12 +2034,12 @@ var CustomerScopedApi = class {
1895
2034
  constructor(apiName, options) {
1896
2035
  this.transport = new CustomerScopedTransport(apiName, options);
1897
2036
  }
1898
- requestEndpoint(endpoint2, body, options) {
1899
- return this.transport.request(resolveOperationPath2(endpoint2, options), {
1900
- method: resolveOperationMethod2(endpoint2),
2037
+ requestEndpoint(endpoint, body, options) {
2038
+ return this.transport.request(resolveOperationPath(endpoint, options), {
2039
+ method: resolveOperationMethod(endpoint),
1901
2040
  body,
1902
2041
  headers: options?.headers,
1903
- errorFamily: resolveOperationErrorFamily(endpoint2)
2042
+ errorFamily: resolveOperationErrorFamily(endpoint)
1904
2043
  });
1905
2044
  }
1906
2045
  };
@@ -1908,8 +2047,8 @@ var RawCustomerScopedApi = class {
1908
2047
  constructor(apiName, options) {
1909
2048
  this.transport = new CustomerScopedTransport(apiName, options);
1910
2049
  }
1911
- request(endpoint2, options) {
1912
- return this.transport.request(endpoint2, options);
2050
+ request(endpoint, options) {
2051
+ return this.transport.request(endpoint, options);
1913
2052
  }
1914
2053
  };
1915
2054
 
@@ -1923,13 +2062,7 @@ function unwrapPayloadDoc(value) {
1923
2062
  return value;
1924
2063
  }
1925
2064
  function hasCanonicalNotFoundReason(error) {
1926
- const details = error.details;
1927
- if (typeof details !== "object" || details === null) return false;
1928
- if ("reason" in details && details.reason === "not_found") return true;
1929
- if (!("body" in details) || typeof details.body !== "object" || details.body === null) {
1930
- return false;
1931
- }
1932
- return "reason" in details.body && details.body.reason === "not_found";
2065
+ return getSDKErrorReason(error) === "not_found";
1933
2066
  }
1934
2067
  var CommunityClient = class extends RawCustomerScopedApi {
1935
2068
  constructor(options) {
@@ -1990,11 +2123,11 @@ var CommunityClient = class extends RawCustomerScopedApi {
1990
2123
  if (params.page !== void 0) urlParams.set("page", String(params.page));
1991
2124
  return `/api/comments/public?${urlParams.toString()}`;
1992
2125
  }
1993
- async execute(endpoint2, method, body) {
1994
- return this.request(endpoint2, { method, body });
2126
+ async execute(endpoint, method, body) {
2127
+ return this.request(endpoint, { method, body });
1995
2128
  }
1996
- async executeDoc(endpoint2, method, body) {
1997
- const response = await this.execute(endpoint2, method, body);
2129
+ async executeDoc(endpoint, method, body) {
2130
+ const response = await this.execute(endpoint, method, body);
1998
2131
  return unwrapPayloadDoc(response);
1999
2132
  }
2000
2133
  createPost(params) {
@@ -2273,20 +2406,23 @@ var ServerApiTransport = class {
2273
2406
  this.apiUrl = options.apiUrl;
2274
2407
  this.onRequestId = options.onRequestId;
2275
2408
  }
2276
- async request(endpoint2, body, options) {
2409
+ async request(endpoint, body, options) {
2277
2410
  const method = options?.method ?? "POST";
2278
2411
  try {
2279
- const response = await httpFetch(endpoint2, {
2412
+ const response = await httpFetch(endpoint, {
2280
2413
  method,
2281
2414
  apiUrl: this.apiUrl,
2282
2415
  publishableKey: this.publishableKey,
2283
2416
  secretKey: this.secretKey,
2284
2417
  ...body !== void 0 && { body: JSON.stringify(body) },
2285
2418
  ...options?.headers && { headers: options.headers },
2286
- ...options?.errorFamily && { errorFamily: options.errorFamily }
2419
+ ...options?.errorFamily && { errorFamily: options.errorFamily },
2420
+ ...options?.typedCommerceErrorReasons && {
2421
+ typedCommerceErrorReasons: options.typedCommerceErrorReasons
2422
+ }
2287
2423
  });
2288
2424
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
2289
- return parseApiResponse(response, endpoint2, {
2425
+ return parseApiResponse(response, endpoint, {
2290
2426
  errorFamily: options?.errorFamily
2291
2427
  });
2292
2428
  } catch (err) {
@@ -2300,14 +2436,15 @@ var BaseApi = class {
2300
2436
  constructor(apiName, options) {
2301
2437
  this.transport = new ServerApiTransport(apiName, options);
2302
2438
  }
2303
- requestEndpoint(endpoint2, body, options) {
2439
+ requestEndpoint(endpoint, body, options) {
2304
2440
  return this.transport.request(
2305
- resolveOperationPath2(endpoint2, options),
2441
+ resolveOperationPath(endpoint, options),
2306
2442
  body,
2307
2443
  {
2308
- method: resolveOperationMethod2(endpoint2),
2444
+ method: resolveOperationMethod(endpoint),
2309
2445
  headers: options?.headers,
2310
- errorFamily: resolveOperationErrorFamily(endpoint2)
2446
+ errorFamily: resolveOperationErrorFamily(endpoint),
2447
+ typedCommerceErrorReasons: resolveOperationTypedCommerceErrorReasons(endpoint)
2311
2448
  }
2312
2449
  );
2313
2450
  }
@@ -2324,8 +2461,8 @@ var RawBaseApi = class {
2324
2461
  this.apiUrl = options.apiUrl;
2325
2462
  this.onRequestId = options.onRequestId;
2326
2463
  }
2327
- request(endpoint2, body, options) {
2328
- return this.transport.request(endpoint2, body, options);
2464
+ request(endpoint, body, options) {
2465
+ return this.transport.request(endpoint, body, options);
2329
2466
  }
2330
2467
  };
2331
2468
 
@@ -2386,6 +2523,18 @@ var PAYMENT_FAILURE_REASONS = [
2386
2523
  "provider_terminal_failure",
2387
2524
  "unknown_provider_terminal_failure"
2388
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
+ ];
2389
2538
  var CART_WARNING_CODES = [
2390
2539
  "DISCOUNT_CODE_NOT_HONOURED",
2391
2540
  "DISCOUNT_CURRENTLY_INACTIVE",
@@ -2447,6 +2596,9 @@ function nullableString(value, resource, path) {
2447
2596
  fail(resource, path, "string or null");
2448
2597
  }
2449
2598
  }
2599
+ function nullableNonEmptyString(value, resource, path) {
2600
+ if (value !== null) string(value, resource, path);
2601
+ }
2450
2602
  function nonBlankString(value, resource, path) {
2451
2603
  const parsed = string(value, resource, path);
2452
2604
  if (parsed.trim().length === 0) {
@@ -2967,8 +3119,8 @@ function validateCheckoutItem(value, resource, path) {
2967
3119
  validateReference(item.product, resource, `${path}.product`);
2968
3120
  validateReference(item.variant, resource, `${path}.variant`);
2969
3121
  string(item.productTitle, resource, `${path}.productTitle`);
2970
- nullableString(item.variantTitle, resource, `${path}.variantTitle`);
2971
- nullableString(item.sku, resource, `${path}.sku`);
3122
+ nullableNonEmptyString(item.variantTitle, resource, `${path}.variantTitle`);
3123
+ nullableNonEmptyString(item.sku, resource, `${path}.sku`);
2972
3124
  validateAdmissions(item.admissions, resource, `${path}.admissions`);
2973
3125
  cartLineQuantity(item.quantity, resource, `${path}.quantity`);
2974
3126
  const unitPrice = safeMinor(
@@ -3336,6 +3488,141 @@ function validateRetrievedCustomPaymentSession(value) {
3336
3488
  nullableResourceId(session.orderId, resource, "$.orderId");
3337
3489
  return value;
3338
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
+ }
3339
3626
  function validateConfirmCustomPaymentSessionResponse(value) {
3340
3627
  const resource = "custom PaymentSession confirmation";
3341
3628
  const result = record(value, resource, "$");
@@ -3389,9 +3676,96 @@ function validateRequiredReconciliation(value, allowed, resource, path) {
3389
3676
  function validateNextAction(value, provider, resource, path) {
3390
3677
  const action = record(value, resource, path);
3391
3678
  if (provider === "portone") {
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
+ }
3689
+ exact(
3690
+ action,
3691
+ [
3692
+ "type",
3693
+ "version",
3694
+ ...hasCancelable ? ["cancelable", "retryPolicy"] : [],
3695
+ "storeId",
3696
+ "channelKey",
3697
+ "paymentId",
3698
+ "orderName",
3699
+ "totalAmount",
3700
+ "currency",
3701
+ "payMethod",
3702
+ "redirectUrl"
3703
+ ],
3704
+ [],
3705
+ resource,
3706
+ path
3707
+ );
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
+ }
3714
+ for (const key of ["storeId", "channelKey"]) {
3715
+ boundedString(action[key], 255, resource, `${path}.${key}`);
3716
+ }
3717
+ const paymentId = boundedString(
3718
+ action.paymentId,
3719
+ 40,
3720
+ resource,
3721
+ `${path}.paymentId`
3722
+ );
3723
+ if (!/^[A-Za-z0-9]{6,40}$/.test(paymentId)) {
3724
+ fail(
3725
+ resource,
3726
+ `${path}.paymentId`,
3727
+ "6-40 ASCII alphanumeric characters"
3728
+ );
3729
+ }
3730
+ boundedString(
3731
+ action.orderName,
3732
+ MAX_COMMERCE_SHORT_TEXT_LENGTH,
3733
+ resource,
3734
+ `${path}.orderName`
3735
+ );
3736
+ positiveInteger(action.totalAmount, resource, `${path}.totalAmount`);
3737
+ if (action.currency !== "CURRENCY_KRW") {
3738
+ fail(resource, `${path}.currency`, "CURRENCY_KRW");
3739
+ }
3740
+ if (action.payMethod !== "CARD")
3741
+ fail(resource, `${path}.payMethod`, "CARD");
3742
+ const redirectUrl = boundedString(
3743
+ action.redirectUrl,
3744
+ 2048,
3745
+ resource,
3746
+ `${path}.redirectUrl`
3747
+ );
3748
+ try {
3749
+ const parsed = new URL(redirectUrl);
3750
+ const loopback = parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
3751
+ if (!loopback && parsed.protocol !== "https:" || parsed.username || parsed.password)
3752
+ throw new Error("unsafe redirect URL");
3753
+ } catch {
3754
+ fail(
3755
+ resource,
3756
+ `${path}.redirectUrl`,
3757
+ "HTTPS or loopback URL without embedded credentials"
3758
+ );
3759
+ }
3760
+ if (!hasCancelable) {
3761
+ action.cancelable = false;
3762
+ action.retryPolicy = "same_action_only";
3763
+ }
3764
+ return;
3765
+ }
3392
3766
  exact(action, ["type", "checkoutUrl"], [], resource, path);
3393
3767
  if (action.type !== "portone_checkout") {
3394
- fail(resource, `${path}.type`, "portone_checkout");
3768
+ fail(resource, `${path}.type`, "portone_checkout | portone_sdk");
3395
3769
  }
3396
3770
  const checkoutUrl = boundedString(
3397
3771
  action.checkoutUrl,
@@ -3704,8 +4078,8 @@ var CartApi = class extends CustomerScopedApi {
3704
4078
  endpoint(key) {
3705
4079
  return this.serverTransport ? COMMERCE_ENDPOINTS.carts.server[key] : COMMERCE_ENDPOINTS.carts[key];
3706
4080
  }
3707
- execute(endpoint2, body, idempotencyKey) {
3708
- return this.requestEndpoint(endpoint2, body, {
4081
+ execute(endpoint, body, idempotencyKey) {
4082
+ return this.requestEndpoint(endpoint, body, {
3709
4083
  ...idempotencyKey && {
3710
4084
  headers: { "X-Idempotency-Key": idempotencyKey }
3711
4085
  }
@@ -3722,26 +4096,26 @@ var CartApi = class extends CustomerScopedApi {
3722
4096
  );
3723
4097
  }
3724
4098
  mine(params = {}) {
3725
- const endpoint2 = this.endpoint("mine");
3726
- return this.execute(endpoint2, params).then(
4099
+ const endpoint = this.endpoint("mine");
4100
+ return this.execute(endpoint, params).then(
3727
4101
  (value) => validateCartMineResult(value)
3728
4102
  );
3729
4103
  }
3730
4104
  merge(params) {
3731
4105
  const { idempotencyKey, ...body } = params;
3732
4106
  assertCommerceIdempotencyKey(idempotencyKey);
3733
- const endpoint2 = this.endpoint("merge");
3734
- return this.execute(endpoint2, body, idempotencyKey).then(
4107
+ const endpoint = this.endpoint("merge");
4108
+ return this.execute(endpoint, body, idempotencyKey).then(
3735
4109
  (value) => validateCartMergeResult(value)
3736
4110
  );
3737
4111
  }
3738
4112
  addItem(params) {
3739
4113
  return this.mutate(this.endpoint("addItem"), params);
3740
4114
  }
3741
- mutate(endpoint2, params) {
4115
+ mutate(endpoint, params) {
3742
4116
  const { idempotencyKey, ...body } = params;
3743
4117
  assertCommerceIdempotencyKey(idempotencyKey);
3744
- return this.execute(endpoint2, body, idempotencyKey).then(
4118
+ return this.execute(endpoint, body, idempotencyKey).then(
3745
4119
  (value) => validateCartMutationResult(value)
3746
4120
  );
3747
4121
  }
@@ -4788,21 +5162,11 @@ var PRODUCT_DETAIL_UNAVAILABLE_REASONS = /* @__PURE__ */ new Set([
4788
5162
  "not_published",
4789
5163
  "feature_disabled"
4790
5164
  ]);
4791
- function isRecord(value) {
4792
- return typeof value === "object" && value !== null;
4793
- }
4794
- function readProductDetailUnavailableReason(value) {
4795
- if (!isRecord(value)) return void 0;
4796
- const directReason = value.reason ?? value.code;
4797
- if (typeof directReason === "string" && PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(directReason)) {
4798
- return directReason;
4799
- }
4800
- return readProductDetailUnavailableReason(value.body);
4801
- }
4802
5165
  function productDetailResultFromError(error) {
4803
5166
  if (!(error instanceof SDKError) || error.status !== 404) return void 0;
4804
- const reason = readProductDetailUnavailableReason(error.details);
4805
- if (!reason) return void 0;
5167
+ const reason = getSDKErrorReason(error);
5168
+ if (!reason || !PRODUCT_DETAIL_UNAVAILABLE_REASONS.has(reason))
5169
+ return void 0;
4806
5170
  return { found: false, reason };
4807
5171
  }
4808
5172
  var MARKET_PRICE_QUERY_UNSUPPORTED_MESSAGE = "Market listing pages do not support base price filters or price sorts.";
@@ -5160,8 +5524,8 @@ var CheckoutApi = class extends CustomerScopedApi {
5160
5524
  constructor(options) {
5161
5525
  super("CheckoutApi", { ...options, requiresCredential: false });
5162
5526
  }
5163
- post(endpoint2, body, idempotencyKey) {
5164
- return this.requestEndpoint(endpoint2, body, {
5527
+ post(endpoint, body, idempotencyKey) {
5528
+ return this.requestEndpoint(endpoint, body, {
5165
5529
  ...idempotencyKey && {
5166
5530
  headers: { "X-Idempotency-Key": idempotencyKey }
5167
5531
  }
@@ -5228,11 +5592,15 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5228
5592
  super("PaymentSessionApi", { ...options, requiresCredential: false });
5229
5593
  this.serverTransport = Boolean(options.secretKey);
5230
5594
  }
5231
- post(endpoint2, body, idempotencyKey) {
5232
- return this.requestEndpoint(endpoint2, body, {
5233
- ...idempotencyKey && {
5234
- 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
5235
5600
  }
5601
+ };
5602
+ return this.requestEndpoint(endpoint, body, {
5603
+ ...Object.keys(headers).length > 0 && { headers }
5236
5604
  });
5237
5605
  }
5238
5606
  async paymentSession(result, expectedProvider) {
@@ -5257,40 +5625,41 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5257
5625
  this.post(
5258
5626
  this.serverTransport ? COMMERCE_ENDPOINTS.paymentSessions.server.create : COMMERCE_ENDPOINTS.paymentSessions.create,
5259
5627
  body,
5260
- idempotencyKey
5628
+ idempotencyKey,
5629
+ body.providerOptions.profile === "standard_v2"
5261
5630
  ),
5262
5631
  "portone"
5263
5632
  );
5264
5633
  }
5265
5634
  retrieve(params) {
5266
- 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;
5267
5636
  return this.paymentSession(
5268
- this.post(endpoint2, params),
5637
+ this.post(endpoint, params),
5269
5638
  "toss"
5270
5639
  );
5271
5640
  }
5272
5641
  retrievePortOne(params) {
5273
- 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;
5274
5643
  return this.paymentSession(
5275
- this.post(endpoint2, params),
5644
+ this.post(endpoint, params, void 0, true),
5276
5645
  "portone"
5277
5646
  );
5278
5647
  }
5279
5648
  cancel(params) {
5280
5649
  const { idempotencyKey, ...body } = params;
5281
5650
  assertCommerceIdempotencyKey(idempotencyKey);
5282
- 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;
5283
5652
  return this.paymentSession(
5284
- this.post(endpoint2, body, idempotencyKey),
5653
+ this.post(endpoint, body, idempotencyKey),
5285
5654
  "toss"
5286
5655
  );
5287
5656
  }
5288
5657
  cancelPortOne(params) {
5289
5658
  const { idempotencyKey, ...body } = params;
5290
5659
  assertCommerceIdempotencyKey(idempotencyKey);
5291
- 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;
5292
5661
  return this.paymentSession(
5293
- this.post(endpoint2, body, idempotencyKey),
5662
+ this.post(endpoint, body, idempotencyKey),
5294
5663
  "portone"
5295
5664
  );
5296
5665
  }
@@ -5307,6 +5676,34 @@ var PaymentSessionApi = class extends CustomerScopedApi {
5307
5676
  );
5308
5677
  }
5309
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
+ };
5310
5707
  var CustomPaymentSessionApi = class extends BaseApi {
5311
5708
  constructor(options) {
5312
5709
  super("CustomPaymentSessionApi", options);
@@ -5436,6 +5833,9 @@ var ServerCommerceClient = class {
5436
5833
  const orderApi = new OrderApi(serverOptions);
5437
5834
  const checkoutApi = new CheckoutApi(serverOptions);
5438
5835
  const paymentSessionApi = new PaymentSessionApi(serverOptions);
5836
+ const portOneReconciliationApi = new PortOnePaymentReconciliationApi(
5837
+ serverOptions
5838
+ );
5439
5839
  const customPaymentSessionApi = new CustomPaymentSessionApi(serverOptions);
5440
5840
  this.product = {
5441
5841
  stockCheck: productApi.stockCheck.bind(productApi),
@@ -5486,6 +5886,10 @@ var ServerCommerceClient = class {
5486
5886
  cancel: (params) => paymentSessionApi.cancel(params),
5487
5887
  cancelPortOne: (params) => paymentSessionApi.cancelPortOne(params),
5488
5888
  confirm: paymentSessionApi.confirm.bind(paymentSessionApi),
5889
+ findPortOne: portOneReconciliationApi.find.bind(portOneReconciliationApi),
5890
+ reconcilePortOne: portOneReconciliationApi.reconcile.bind(
5891
+ portOneReconciliationApi
5892
+ ),
5489
5893
  custom: {
5490
5894
  create: customPaymentSessionApi.create.bind(customPaymentSessionApi),
5491
5895
  retrieve: customPaymentSessionApi.retrieve.bind(
@@ -5567,11 +5971,11 @@ var EventsClient = class {
5567
5971
  { useCustomerAuth: false }
5568
5972
  );
5569
5973
  }
5570
- async execute(endpoint2, method, body, options = {}) {
5974
+ async execute(endpoint, method, body, options = {}) {
5571
5975
  const useCustomerAuth = options.useCustomerAuth === true;
5572
5976
  const token = useCustomerAuth ? typeof this.customerToken === "function" ? this.customerToken() : this.customerToken : void 0;
5573
5977
  try {
5574
- const response = await httpFetch(endpoint2, {
5978
+ const response = await httpFetch(endpoint, {
5575
5979
  method,
5576
5980
  apiUrl: this.apiUrl,
5577
5981
  publishableKey: this.publishableKey,
@@ -5580,7 +5984,7 @@ var EventsClient = class {
5580
5984
  ...body !== void 0 && { body: JSON.stringify(body) }
5581
5985
  });
5582
5986
  this.onRequestId?.(response.headers.get("x-request-id") ?? null);
5583
- return parseApiResponse(response, endpoint2);
5987
+ return parseApiResponse(response, endpoint);
5584
5988
  } catch (err) {
5585
5989
  const id = err instanceof SDKError ? err.requestId ?? null : null;
5586
5990
  this.onRequestId?.(id);
@@ -5682,13 +6086,14 @@ var MarketDiscovery = class {
5682
6086
  };
5683
6087
 
5684
6088
  // src/core/api/tenant-introspection-api.ts
6089
+ var TENANT_CONTEXT_PATH = "/api/tenants/context";
5685
6090
  var TenantIntrospectionApi = class extends RawBaseApi {
5686
6091
  constructor(options) {
5687
6092
  super("TenantIntrospectionApi", options);
5688
6093
  }
5689
6094
  context(params = {}) {
5690
- const endpoint2 = params.includeCounts ? "/api/tenants/context?counts=true" : "/api/tenants/context";
5691
- 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, {
5692
6097
  method: "GET"
5693
6098
  });
5694
6099
  }