@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
@@ -120,6 +120,7 @@ var COMMERCE_ERROR_CODES = [
120
120
  "payment_session_not_cancelable",
121
121
  "payment_session_conflict",
122
122
  "provider_identity_mismatch",
123
+ "managed_refund_attestation_forbidden",
123
124
  "payment_method_unavailable",
124
125
  "provider_unavailable",
125
126
  "lock_timeout",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/storefront-cache.ts","../src/core/errors.ts","../src/utils/storefront-cache.ts"],"sourcesContent":["export * from './utils/storefront-cache'\n","const SDK_ERROR_BRAND = Symbol.for('@01.software/sdk/SDKError')\nconst SDK_ERROR_TYPE_BRAND = Symbol.for('@01.software/sdk/SDKError.type')\n\ntype SDKErrorType =\n | 'NetworkError'\n | 'ValidationError'\n | 'ApiError'\n | 'ConfigError'\n | 'TimeoutError'\n | 'GoneError'\n | 'ServiceUnavailableError'\n | 'UsageLimitError'\n | 'AuthError'\n | 'PermissionError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'RateLimitError'\n\nfunction defineSDKErrorBrand(error: SDKError): void {\n Object.defineProperty(error, SDK_ERROR_BRAND, {\n value: true,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nfunction defineSDKErrorType(error: SDKError, type: SDKErrorType): void {\n Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nexport class SDKError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n readonly userMessage?: string\n readonly suggestion?: string\n readonly requestId?: string\n readonly kind?: 'commerce'\n readonly reason?: CommerceErrorCode | 'unknown_commerce_error'\n readonly rawReason?: string\n /** Machine-readable reason from a non-commerce API response. */\n readonly apiReason?: string\n readonly retryable?: boolean\n readonly retryAfter?: number\n\n constructor(\n code: string,\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(message)\n this.name = 'SDKError'\n this.code = code\n this.status = status\n this.details = details\n this.userMessage = userMessage\n this.suggestion = suggestion\n this.requestId = requestId\n defineSDKErrorBrand(this)\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, new.target)\n }\n }\n\n getUserMessage(): string {\n return this.userMessage || this.message\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n userMessage: this.userMessage,\n suggestion: this.suggestion,\n ...(this.requestId !== undefined && { requestId: this.requestId }),\n ...(this.kind !== undefined && { kind: this.kind }),\n ...(this.reason !== undefined && { reason: this.reason }),\n ...(this.rawReason !== undefined && { rawReason: this.rawReason }),\n ...(this.apiReason !== undefined && { apiReason: this.apiReason }),\n ...(this.retryable !== undefined && { retryable: this.retryable }),\n ...(this.retryAfter !== undefined && { retryAfter: this.retryAfter }),\n }\n }\n}\n\n/**\n * Canonical Cart/Checkout/PaymentSession error reasons. This public SDK mirror\n * intentionally does not import the private contracts package; parity is\n * enforced by a type test.\n */\nexport const COMMERCE_ERROR_CODES = [\n 'validation_failed',\n 'bad_request',\n 'unauthorized',\n 'forbidden',\n 'account_suspended',\n 'key_invalid',\n 'pat_tenant_header_forbidden',\n 'tenant_mismatch',\n 'test_tenant_expired',\n 'token_invalid',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'role_denied',\n 'scope_denied',\n 'feature_disabled',\n 'not_found',\n 'conflict',\n 'locked',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'idempotency_key_required',\n 'invalid_idempotency_key',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'checkout_already_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'payment_session_conflict',\n 'provider_identity_mismatch',\n 'payment_method_unavailable',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\n 'reservation_conflict',\n 'stock_lock_unavailable',\n 'variant_not_found',\n 'variant_stock_write_failed',\n 'stock_invariant_violation',\n 'payment_confirmation_in_flight',\n 'checkout_reservation_release_requires_transaction',\n 'admission_metadata_invalid',\n 'admission_metadata_required',\n 'capacity_exceeded',\n 'occurrence_lock_unavailable',\n 'occurrence_not_open',\n 'admission_type_capacity_exceeded',\n 'admission_type_occurrence_mismatch',\n 'admission_hold_expired',\n 'admission_hold_checkout_item_conflict',\n 'admission_hold_checkout_conflict',\n 'admission_hold_quantity_mismatch',\n 'admission_hold_unbound',\n 'admission_hold_missing',\n 'admission_hold_checkout_item_missing',\n 'admission_hold_expiry_failed',\n 'admission_hold_expiry_requires_transaction',\n 'admission_hold_line_item_mismatch',\n 'admission_materialization_failed',\n 'variant_inactive',\n 'variant_product_mismatch',\n 'product_not_public',\n 'market_not_found',\n 'market_shipping_currency_unsupported',\n 'missing_market_rate',\n 'missing_shipping_amount',\n 'no_enabled_payment_provider',\n 'product_market_unavailable',\n 'unsupported_currency',\n 'missing_price_row',\n 'payment_provider_currency_unsupported',\n 'discount_code_not_found',\n 'discount_not_started',\n 'discount_expired',\n 'discount_usage_limit',\n 'discount_per_customer_limit',\n 'discount_customer_required',\n 'discount_first_order_only',\n 'discount_customer_not_eligible',\n 'discount_customer_excluded',\n 'discount_items_required',\n 'discount_product_not_eligible',\n 'discount_product_excluded',\n 'discount_min_order_amount',\n 'discount_currency_scope_required',\n 'discount_allocation_method_unsupported',\n 'currency_mismatch',\n 'customer_token_required',\n 'market_required',\n 'server_derived',\n 'internal_error',\n] as const\n\nexport type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number]\n\ntype CommerceSDKErrorBase = SDKError & {\n readonly kind: 'commerce'\n readonly requestId: string\n readonly retryable: boolean\n readonly retryAfter?: number\n readonly details?: Record<string, unknown>\n}\n\nexport type CommerceSDKError = CommerceSDKErrorBase &\n (\n | { readonly reason: CommerceErrorCode; readonly rawReason?: never }\n | {\n readonly reason: 'unknown_commerce_error'\n readonly rawReason: string\n }\n )\n\nconst COMMERCE_ERROR_CODE_SET: ReadonlySet<string> = new Set(\n COMMERCE_ERROR_CODES,\n)\nconst COMMERCE_ERROR_ENVELOPE_KEYS = new Set([\n 'error',\n 'reason',\n 'requestId',\n 'retryable',\n 'details',\n])\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport type CommerceErrorEnvelope = {\n error: string\n reason: string\n requestId: string\n retryable: boolean\n details?: Record<string, unknown>\n}\n\nfunction commerceProtocolError(\n issue: string,\n trustedRequestId?: string,\n): SDKError {\n return createApiError(\n 'Invalid canonical commerce error response.',\n 502,\n { protocol: 'commerce-error-envelope', issue },\n 'The server returned an incompatible commerce error response.',\n 'Verify that the Console commerce contract is deployed before using this SDK version.',\n trustedRequestId,\n )\n}\n\n/** @internal Strictly parse a canonical commerce error without retaining its raw body. */\nexport function parseCommerceErrorEnvelope(\n body: unknown,\n headerRequestId?: string,\n): CommerceErrorEnvelope {\n if (headerRequestId === undefined) {\n throw commerceProtocolError('missing_request_id_header')\n }\n if (headerRequestId.length === 0) {\n throw commerceProtocolError('empty_request_id_header')\n }\n if (!isPlainRecord(body)) {\n throw commerceProtocolError('expected_object', headerRequestId)\n }\n if (Object.keys(body).some((key) => !COMMERCE_ERROR_ENVELOPE_KEYS.has(key))) {\n throw commerceProtocolError('unexpected_field', headerRequestId)\n }\n if (\n typeof body.error !== 'string' ||\n body.error.length === 0 ||\n typeof body.reason !== 'string' ||\n body.reason.length === 0 ||\n typeof body.requestId !== 'string' ||\n body.requestId.length === 0 ||\n (body.retryable !== undefined && typeof body.retryable !== 'boolean') ||\n (body.details !== undefined && !isPlainRecord(body.details))\n ) {\n throw commerceProtocolError('invalid_field', headerRequestId)\n }\n\n if (headerRequestId !== undefined && headerRequestId !== body.requestId) {\n throw commerceProtocolError('request_id_mismatch', headerRequestId)\n }\n\n return {\n error: body.error,\n reason: body.reason,\n requestId: body.requestId,\n retryable: body.retryable === true,\n ...(body.details === undefined ? {} : { details: body.details }),\n }\n}\n\n/** @internal Validate and apply the canonical commerce error envelope. */\nexport function enhanceCommerceError(\n error: SDKError,\n body: unknown,\n headerRequestId?: string,\n): SDKError {\n const envelope = parseCommerceErrorEnvelope(body, headerRequestId)\n\n const known = COMMERCE_ERROR_CODE_SET.has(envelope.reason)\n Object.assign(error, {\n code: envelope.reason,\n kind: 'commerce' as const,\n reason: known\n ? (envelope.reason as CommerceErrorCode)\n : 'unknown_commerce_error',\n ...(known ? {} : { rawReason: envelope.reason }),\n requestId: envelope.requestId,\n retryable: envelope.retryable,\n details: envelope.details,\n })\n return error\n}\n\n/** @internal Apply a non-commerce reason without canonical-commerce validation. */\nexport function enhanceNonCommerceError(\n error: SDKError,\n reason: unknown,\n): SDKError {\n if (typeof reason === 'string') Object.assign(error, { apiReason: reason })\n return error\n}\n\n/**\n * Read the server-provided machine reason across strict commerce and\n * non-commerce SDK errors. Unknown commerce reasons are returned verbatim.\n */\nexport function getSDKErrorReason(error: SDKError): string | undefined {\n if (error.kind !== 'commerce') return error.apiReason\n return error.reason === 'unknown_commerce_error'\n ? error.rawReason\n : error.reason\n}\n\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!isSDKError(error) || error.kind !== 'commerce') return false\n if (\n typeof error.requestId !== 'string' ||\n typeof error.retryable !== 'boolean' ||\n (error.retryAfter !== undefined &&\n (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0)) ||\n typeof error.reason !== 'string'\n ) {\n return false\n }\n return error.reason === 'unknown_commerce_error'\n ? typeof error.rawReason === 'string'\n : COMMERCE_ERROR_CODE_SET.has(error.reason) && error.rawReason === undefined\n}\n\nexport class NetworkError extends SDKError {\n constructor(\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('NETWORK_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'NetworkError'\n defineSDKErrorType(this, 'NetworkError')\n }\n}\n\nexport class ValidationError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status = 400,\n ) {\n super('VALIDATION_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'ValidationError'\n defineSDKErrorType(this, 'ValidationError')\n }\n}\n\nexport class ApiError extends SDKError {\n constructor(\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'API_ERROR',\n message,\n status,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'ApiError'\n defineSDKErrorType(this, 'ApiError')\n }\n}\n\nexport class ConfigError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('CONFIG_ERROR', message, undefined, details, userMessage, suggestion)\n this.name = 'ConfigError'\n defineSDKErrorType(this, 'ConfigError')\n }\n}\n\nexport class TimeoutError extends SDKError {\n constructor(\n message = 'Request timed out.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('TIMEOUT_ERROR', message, 408, details, userMessage, suggestion)\n this.name = 'TimeoutError'\n defineSDKErrorType(this, 'TimeoutError')\n }\n}\n\nexport class GoneError extends SDKError {\n constructor(\n message = 'The requested resource is no longer available.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('GONE_ERROR', message, 410, details, userMessage, suggestion)\n this.name = 'GoneError'\n defineSDKErrorType(this, 'GoneError')\n }\n}\n\nexport class ServiceUnavailableError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message = 'Service temporarily unavailable.',\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super(\n 'SERVICE_UNAVAILABLE_ERROR',\n message,\n 503,\n details,\n userMessage,\n suggestion,\n )\n this.name = 'ServiceUnavailableError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'ServiceUnavailableError')\n }\n}\n\nexport class UsageLimitError extends SDKError {\n readonly usage: { limit: number; current: number; remaining: number }\n\n constructor(\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('USAGE_LIMIT_ERROR', message, 429, details, userMessage, suggestion)\n this.name = 'UsageLimitError'\n this.usage = usage\n defineSDKErrorType(this, 'UsageLimitError')\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n usage: this.usage,\n }\n }\n}\n\nexport class AuthError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'auth_error',\n message,\n 401,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'AuthError'\n defineSDKErrorType(this, 'AuthError')\n }\n}\n\nexport class PermissionError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'permission_error',\n message,\n 403,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'PermissionError'\n defineSDKErrorType(this, 'PermissionError')\n }\n}\n\nexport class NotFoundError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'not_found',\n message,\n 404,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'NotFoundError'\n defineSDKErrorType(this, 'NotFoundError')\n }\n}\n\nexport class ConflictError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super('conflict', message, 409, details, userMessage, suggestion, requestId)\n this.name = 'ConflictError'\n defineSDKErrorType(this, 'ConflictError')\n }\n}\n\nexport class RateLimitError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'rate_limit_exceeded',\n message,\n 429,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'RateLimitError')\n }\n}\n\nfunction hasBrandedSDKErrorShape(error: unknown): error is SDKError {\n if (error === null || typeof error !== 'object') return false\n\n const candidate = error as Record<PropertyKey, unknown>\n return (\n candidate[SDK_ERROR_BRAND] === true &&\n typeof candidate.name === 'string' &&\n typeof candidate.code === 'string' &&\n typeof candidate.message === 'string' &&\n (candidate.status === undefined || typeof candidate.status === 'number') &&\n (candidate.userMessage === undefined ||\n typeof candidate.userMessage === 'string') &&\n (candidate.suggestion === undefined ||\n typeof candidate.suggestion === 'string') &&\n (candidate.requestId === undefined ||\n typeof candidate.requestId === 'string') &&\n (candidate.kind === undefined || candidate.kind === 'commerce') &&\n (candidate.reason === undefined || typeof candidate.reason === 'string') &&\n (candidate.rawReason === undefined ||\n typeof candidate.rawReason === 'string') &&\n (candidate.apiReason === undefined ||\n typeof candidate.apiReason === 'string') &&\n (candidate.retryable === undefined ||\n typeof candidate.retryable === 'boolean') &&\n (candidate.retryAfter === undefined ||\n typeof candidate.retryAfter === 'number') &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nfunction hasSDKErrorType(error: unknown, type: SDKErrorType): boolean {\n return (\n hasBrandedSDKErrorShape(error) &&\n (error as unknown as Record<PropertyKey, unknown>)[SDK_ERROR_TYPE_BRAND] ===\n type\n )\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError || hasBrandedSDKErrorShape(error)\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError || hasSDKErrorType(error, 'NetworkError')\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (\n error instanceof ValidationError ||\n hasSDKErrorType(error, 'ValidationError')\n ) {\n return true\n }\n if (error == null || typeof error !== 'object') return false\n\n const candidate = error as {\n code?: unknown\n name?: unknown\n message?: unknown\n getUserMessage?: unknown\n toJSON?: unknown\n }\n return (\n candidate.name === 'ValidationError' &&\n candidate.code === 'VALIDATION_ERROR' &&\n typeof candidate.message === 'string' &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nexport function isApiError(error: unknown): error is ApiError {\n return error instanceof ApiError || hasSDKErrorType(error, 'ApiError')\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError || hasSDKErrorType(error, 'ConfigError')\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError || hasSDKErrorType(error, 'TimeoutError')\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError || hasSDKErrorType(error, 'GoneError')\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return (\n error instanceof ServiceUnavailableError ||\n hasSDKErrorType(error, 'ServiceUnavailableError')\n )\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return (\n error instanceof UsageLimitError ||\n hasSDKErrorType(error, 'UsageLimitError')\n )\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError || hasSDKErrorType(error, 'AuthError')\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return (\n error instanceof PermissionError ||\n hasSDKErrorType(error, 'PermissionError')\n )\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return (\n error instanceof NotFoundError || hasSDKErrorType(error, 'NotFoundError')\n )\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return (\n error instanceof ConflictError || hasSDKErrorType(error, 'ConflictError')\n )\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return (\n error instanceof RateLimitError || hasSDKErrorType(error, 'RateLimitError')\n )\n}\n\nexport const createNetworkError = (\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new NetworkError(message, status, details, userMessage, suggestion)\n\nexport const createValidationError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status?: number,\n) => new ValidationError(message, details, userMessage, suggestion, status)\n\nexport const createApiError = (\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ApiError(message, status, details, userMessage, suggestion, requestId)\n\nexport const createConfigError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new ConfigError(message, details, userMessage, suggestion)\n\nexport const createTimeoutError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new TimeoutError(message, details, userMessage, suggestion)\n\nexport const createGoneError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new GoneError(message, details, userMessage, suggestion)\n\nexport const createServiceUnavailableError = (\n message?: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) =>\n new ServiceUnavailableError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n )\n\nexport const createUsageLimitError = (\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new UsageLimitError(message, usage, details, userMessage, suggestion)\n\nexport const createAuthError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new AuthError(message, details, userMessage, suggestion, requestId)\n\nexport const createPermissionError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new PermissionError(message, details, userMessage, suggestion, requestId)\n\nexport const createNotFoundError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new NotFoundError(message, details, userMessage, suggestion, requestId)\n\nexport const createConflictError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ConflictError(message, details, userMessage, suggestion, requestId)\n\nexport const createRateLimitError = (\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) =>\n new RateLimitError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n","import { createValidationError } from '../errors'\n\nconst CACHE_RESOURCE_VERSION = 'storefront:v1'\n\nexport type StorefrontCacheScope = {\n /**\n * Tenant identifier for the public storefront read.\n */\n tenantId: string | number\n /**\n * Stable, non-secret scope for publishable-key variance. Use a short key id,\n * key fingerprint, or \"default\" when a tenant has one public cache view.\n */\n publishableKeyScope?: string | number\n}\n\nexport type StorefrontCacheProductDetailIdentity =\n | { id: string | number; slug?: never }\n | { id?: never; slug: string }\n\nfunction invalidResourceInput(message: string) {\n return createValidationError(message)\n}\n\nfunction encodeResourceSegment(value: unknown, label: string): string {\n if (typeof value !== 'string' && typeof value !== 'number') {\n throw invalidResourceInput(`${label} must be a string or number`)\n }\n if (typeof value === 'number' && !Number.isFinite(value)) {\n throw invalidResourceInput(`${label} must be a finite number`)\n }\n const segment = String(value).trim()\n if (!segment) {\n throw invalidResourceInput(`${label} must not be empty`)\n }\n return encodeURIComponent(segment)\n}\n\nfunction scopedResource(scope: StorefrontCacheScope, resource: string): string {\n if (scope == null || typeof scope !== 'object') {\n throw invalidResourceInput('cache scope must be an object')\n }\n const candidate = scope as {\n tenantId?: unknown\n publishableKeyScope?: unknown\n }\n const tenantId = encodeResourceSegment(candidate.tenantId, 'tenantId')\n const publishableKeyScopeValue =\n candidate.publishableKeyScope === undefined\n ? 'default'\n : candidate.publishableKeyScope\n const publishableKeyScope = encodeResourceSegment(\n publishableKeyScopeValue,\n 'publishableKeyScope',\n )\n\n return `${CACHE_RESOURCE_VERSION}:tenant:${tenantId}:key:${publishableKeyScope}:resource:${resource}`\n}\n\nfunction listResource(scope: StorefrontCacheScope, collection: string): string {\n return scopedResource(scope, `${collection}:list`)\n}\n\nfunction idDetailResource(\n scope: StorefrontCacheScope,\n collection: string,\n id: string | number,\n): string {\n return scopedResource(\n scope,\n `${collection}:detail:id:${encodeResourceSegment(id, 'resource id')}`,\n )\n}\n\nfunction productDetailResource(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n): string {\n const candidate = (identity ?? {}) as {\n id?: unknown\n slug?: unknown\n }\n const hasIdField = candidate.id !== undefined\n const hasSlugField = candidate.slug !== undefined\n\n if (hasIdField === hasSlugField) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n\n if (hasIdField) {\n if (\n (typeof candidate.id !== 'string' && typeof candidate.id !== 'number') ||\n String(candidate.id).trim() === ''\n ) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return idDetailResource(scope, 'products', candidate.id as string | number)\n }\n if (typeof candidate.slug !== 'string' || candidate.slug.trim() === '') {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return scopedResource(\n scope,\n `products:detail:slug:${encodeResourceSegment(\n candidate.slug as string,\n 'resource slug',\n )}`,\n )\n}\n\nexport const storefrontCacheResources = {\n productListing(scope: StorefrontCacheScope): string {\n return listResource(scope, 'products')\n },\n productDetail(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n ): string {\n return productDetailResource(scope, identity)\n },\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,kBAAkB,uBAAO,IAAI,2BAA2B;AAC9D,IAAM,uBAAuB,uBAAO,IAAI,gCAAgC;AAiBxE,SAAS,oBAAoB,OAAuB;AAClD,SAAO,eAAe,OAAO,iBAAiB;AAAA,IAC5C,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,EACZ,CAAC;AACH;AAEA,SAAS,mBAAmB,OAAiB,MAA0B;AACrE,SAAO,eAAe,OAAO,sBAAsB;AAAA,IACjD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,EACZ,CAAC;AACH;AAEO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAelC,YACE,MACA,SACA,QACA,SACA,aACA,YACA,WACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AAC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AU,OAAO,YAC7D,OAAO,UAAU,EAAE,EAAE,KAAK,MAAM,IAChC;AACA,YAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,WAAO,iBAAiB,OAAO,YAAY,UAAU,EAAqB;AAAA,EAC5E;AACA,MAAI,OAAO,UAAU,SAAS,YAAY,UAAU,KAAK,KAAK,MAAM,IAAI;AACtE,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,wBAAwB;AAAA,MACtB,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,2BAA2B;AAAA,EACtC,eAAe,OAAqC;AAClD,WAAO,aAAa,OAAO,UAAU;AAAA,EACvC;AAAA,EACA,cACE,OACA,UACQ;AACR,WAAO,sBAAsB,OAAO,QAAQ;AAAA,EAC9C;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/storefront-cache.ts","../src/core/errors.ts","../src/utils/storefront-cache.ts"],"sourcesContent":["export * from './utils/storefront-cache'\n","const SDK_ERROR_BRAND = Symbol.for('@01.software/sdk/SDKError')\nconst SDK_ERROR_TYPE_BRAND = Symbol.for('@01.software/sdk/SDKError.type')\n\ntype SDKErrorType =\n | 'NetworkError'\n | 'ValidationError'\n | 'ApiError'\n | 'ConfigError'\n | 'TimeoutError'\n | 'GoneError'\n | 'ServiceUnavailableError'\n | 'UsageLimitError'\n | 'AuthError'\n | 'PermissionError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'RateLimitError'\n\nfunction defineSDKErrorBrand(error: SDKError): void {\n Object.defineProperty(error, SDK_ERROR_BRAND, {\n value: true,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nfunction defineSDKErrorType(error: SDKError, type: SDKErrorType): void {\n Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nexport class SDKError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n readonly userMessage?: string\n readonly suggestion?: string\n readonly requestId?: string\n readonly kind?: 'commerce'\n readonly reason?: CommerceErrorCode | 'unknown_commerce_error'\n readonly rawReason?: string\n /** Machine-readable reason from a non-commerce API response. */\n readonly apiReason?: string\n readonly retryable?: boolean\n readonly retryAfter?: number\n\n constructor(\n code: string,\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(message)\n this.name = 'SDKError'\n this.code = code\n this.status = status\n this.details = details\n this.userMessage = userMessage\n this.suggestion = suggestion\n this.requestId = requestId\n defineSDKErrorBrand(this)\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, new.target)\n }\n }\n\n getUserMessage(): string {\n return this.userMessage || this.message\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n userMessage: this.userMessage,\n suggestion: this.suggestion,\n ...(this.requestId !== undefined && { requestId: this.requestId }),\n ...(this.kind !== undefined && { kind: this.kind }),\n ...(this.reason !== undefined && { reason: this.reason }),\n ...(this.rawReason !== undefined && { rawReason: this.rawReason }),\n ...(this.apiReason !== undefined && { apiReason: this.apiReason }),\n ...(this.retryable !== undefined && { retryable: this.retryable }),\n ...(this.retryAfter !== undefined && { retryAfter: this.retryAfter }),\n }\n }\n}\n\n/**\n * Canonical Cart/Checkout/PaymentSession error reasons. This public SDK mirror\n * intentionally does not import the private contracts package; parity is\n * enforced by a type test.\n */\nexport const COMMERCE_ERROR_CODES = [\n 'validation_failed',\n 'bad_request',\n 'unauthorized',\n 'forbidden',\n 'account_suspended',\n 'key_invalid',\n 'pat_tenant_header_forbidden',\n 'tenant_mismatch',\n 'test_tenant_expired',\n 'token_invalid',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'role_denied',\n 'scope_denied',\n 'feature_disabled',\n 'not_found',\n 'conflict',\n 'locked',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'idempotency_key_required',\n 'invalid_idempotency_key',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'checkout_already_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'payment_session_conflict',\n 'provider_identity_mismatch',\n 'managed_refund_attestation_forbidden',\n 'payment_method_unavailable',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\n 'reservation_conflict',\n 'stock_lock_unavailable',\n 'variant_not_found',\n 'variant_stock_write_failed',\n 'stock_invariant_violation',\n 'payment_confirmation_in_flight',\n 'checkout_reservation_release_requires_transaction',\n 'admission_metadata_invalid',\n 'admission_metadata_required',\n 'capacity_exceeded',\n 'occurrence_lock_unavailable',\n 'occurrence_not_open',\n 'admission_type_capacity_exceeded',\n 'admission_type_occurrence_mismatch',\n 'admission_hold_expired',\n 'admission_hold_checkout_item_conflict',\n 'admission_hold_checkout_conflict',\n 'admission_hold_quantity_mismatch',\n 'admission_hold_unbound',\n 'admission_hold_missing',\n 'admission_hold_checkout_item_missing',\n 'admission_hold_expiry_failed',\n 'admission_hold_expiry_requires_transaction',\n 'admission_hold_line_item_mismatch',\n 'admission_materialization_failed',\n 'variant_inactive',\n 'variant_product_mismatch',\n 'product_not_public',\n 'market_not_found',\n 'market_shipping_currency_unsupported',\n 'missing_market_rate',\n 'missing_shipping_amount',\n 'no_enabled_payment_provider',\n 'product_market_unavailable',\n 'unsupported_currency',\n 'missing_price_row',\n 'payment_provider_currency_unsupported',\n 'discount_code_not_found',\n 'discount_not_started',\n 'discount_expired',\n 'discount_usage_limit',\n 'discount_per_customer_limit',\n 'discount_customer_required',\n 'discount_first_order_only',\n 'discount_customer_not_eligible',\n 'discount_customer_excluded',\n 'discount_items_required',\n 'discount_product_not_eligible',\n 'discount_product_excluded',\n 'discount_min_order_amount',\n 'discount_currency_scope_required',\n 'discount_allocation_method_unsupported',\n 'currency_mismatch',\n 'customer_token_required',\n 'market_required',\n 'server_derived',\n 'internal_error',\n] as const\n\nexport type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number]\n\ntype CommerceSDKErrorBase = SDKError & {\n readonly kind: 'commerce'\n readonly requestId: string\n readonly retryable: boolean\n readonly retryAfter?: number\n readonly details?: Record<string, unknown>\n}\n\nexport type CommerceSDKError = CommerceSDKErrorBase &\n (\n | { readonly reason: CommerceErrorCode; readonly rawReason?: never }\n | {\n readonly reason: 'unknown_commerce_error'\n readonly rawReason: string\n }\n )\n\nconst COMMERCE_ERROR_CODE_SET: ReadonlySet<string> = new Set(\n COMMERCE_ERROR_CODES,\n)\nconst COMMERCE_ERROR_ENVELOPE_KEYS = new Set([\n 'error',\n 'reason',\n 'requestId',\n 'retryable',\n 'details',\n])\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport type CommerceErrorEnvelope = {\n error: string\n reason: string\n requestId: string\n retryable: boolean\n details?: Record<string, unknown>\n}\n\nfunction commerceProtocolError(\n issue: string,\n trustedRequestId?: string,\n): SDKError {\n return createApiError(\n 'Invalid canonical commerce error response.',\n 502,\n { protocol: 'commerce-error-envelope', issue },\n 'The server returned an incompatible commerce error response.',\n 'Verify that the Console commerce contract is deployed before using this SDK version.',\n trustedRequestId,\n )\n}\n\n/** @internal Strictly parse a canonical commerce error without retaining its raw body. */\nexport function parseCommerceErrorEnvelope(\n body: unknown,\n headerRequestId?: string,\n): CommerceErrorEnvelope {\n if (headerRequestId === undefined) {\n throw commerceProtocolError('missing_request_id_header')\n }\n if (headerRequestId.length === 0) {\n throw commerceProtocolError('empty_request_id_header')\n }\n if (!isPlainRecord(body)) {\n throw commerceProtocolError('expected_object', headerRequestId)\n }\n if (Object.keys(body).some((key) => !COMMERCE_ERROR_ENVELOPE_KEYS.has(key))) {\n throw commerceProtocolError('unexpected_field', headerRequestId)\n }\n if (\n typeof body.error !== 'string' ||\n body.error.length === 0 ||\n typeof body.reason !== 'string' ||\n body.reason.length === 0 ||\n typeof body.requestId !== 'string' ||\n body.requestId.length === 0 ||\n (body.retryable !== undefined && typeof body.retryable !== 'boolean') ||\n (body.details !== undefined && !isPlainRecord(body.details))\n ) {\n throw commerceProtocolError('invalid_field', headerRequestId)\n }\n\n if (headerRequestId !== undefined && headerRequestId !== body.requestId) {\n throw commerceProtocolError('request_id_mismatch', headerRequestId)\n }\n\n return {\n error: body.error,\n reason: body.reason,\n requestId: body.requestId,\n retryable: body.retryable === true,\n ...(body.details === undefined ? {} : { details: body.details }),\n }\n}\n\n/** @internal Validate and apply the canonical commerce error envelope. */\nexport function enhanceCommerceError(\n error: SDKError,\n body: unknown,\n headerRequestId?: string,\n): SDKError {\n const envelope = parseCommerceErrorEnvelope(body, headerRequestId)\n\n const known = COMMERCE_ERROR_CODE_SET.has(envelope.reason)\n Object.assign(error, {\n code: envelope.reason,\n kind: 'commerce' as const,\n reason: known\n ? (envelope.reason as CommerceErrorCode)\n : 'unknown_commerce_error',\n ...(known ? {} : { rawReason: envelope.reason }),\n requestId: envelope.requestId,\n retryable: envelope.retryable,\n details: envelope.details,\n })\n return error\n}\n\n/** @internal Apply a non-commerce reason without canonical-commerce validation. */\nexport function enhanceNonCommerceError(\n error: SDKError,\n reason: unknown,\n): SDKError {\n if (typeof reason === 'string') Object.assign(error, { apiReason: reason })\n return error\n}\n\n/**\n * Read the server-provided machine reason across strict commerce and\n * non-commerce SDK errors. Unknown commerce reasons are returned verbatim.\n */\nexport function getSDKErrorReason(error: SDKError): string | undefined {\n if (error.kind !== 'commerce') return error.apiReason\n return error.reason === 'unknown_commerce_error'\n ? error.rawReason\n : error.reason\n}\n\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!isSDKError(error) || error.kind !== 'commerce') return false\n if (\n typeof error.requestId !== 'string' ||\n typeof error.retryable !== 'boolean' ||\n (error.retryAfter !== undefined &&\n (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0)) ||\n typeof error.reason !== 'string'\n ) {\n return false\n }\n return error.reason === 'unknown_commerce_error'\n ? typeof error.rawReason === 'string'\n : COMMERCE_ERROR_CODE_SET.has(error.reason) && error.rawReason === undefined\n}\n\nexport class NetworkError extends SDKError {\n constructor(\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('NETWORK_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'NetworkError'\n defineSDKErrorType(this, 'NetworkError')\n }\n}\n\nexport class ValidationError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status = 400,\n ) {\n super('VALIDATION_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'ValidationError'\n defineSDKErrorType(this, 'ValidationError')\n }\n}\n\nexport class ApiError extends SDKError {\n constructor(\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'API_ERROR',\n message,\n status,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'ApiError'\n defineSDKErrorType(this, 'ApiError')\n }\n}\n\nexport class ConfigError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('CONFIG_ERROR', message, undefined, details, userMessage, suggestion)\n this.name = 'ConfigError'\n defineSDKErrorType(this, 'ConfigError')\n }\n}\n\nexport class TimeoutError extends SDKError {\n constructor(\n message = 'Request timed out.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('TIMEOUT_ERROR', message, 408, details, userMessage, suggestion)\n this.name = 'TimeoutError'\n defineSDKErrorType(this, 'TimeoutError')\n }\n}\n\nexport class GoneError extends SDKError {\n constructor(\n message = 'The requested resource is no longer available.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('GONE_ERROR', message, 410, details, userMessage, suggestion)\n this.name = 'GoneError'\n defineSDKErrorType(this, 'GoneError')\n }\n}\n\nexport class ServiceUnavailableError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message = 'Service temporarily unavailable.',\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super(\n 'SERVICE_UNAVAILABLE_ERROR',\n message,\n 503,\n details,\n userMessage,\n suggestion,\n )\n this.name = 'ServiceUnavailableError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'ServiceUnavailableError')\n }\n}\n\nexport class UsageLimitError extends SDKError {\n readonly usage: { limit: number; current: number; remaining: number }\n\n constructor(\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('USAGE_LIMIT_ERROR', message, 429, details, userMessage, suggestion)\n this.name = 'UsageLimitError'\n this.usage = usage\n defineSDKErrorType(this, 'UsageLimitError')\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n usage: this.usage,\n }\n }\n}\n\nexport class AuthError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'auth_error',\n message,\n 401,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'AuthError'\n defineSDKErrorType(this, 'AuthError')\n }\n}\n\nexport class PermissionError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'permission_error',\n message,\n 403,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'PermissionError'\n defineSDKErrorType(this, 'PermissionError')\n }\n}\n\nexport class NotFoundError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'not_found',\n message,\n 404,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'NotFoundError'\n defineSDKErrorType(this, 'NotFoundError')\n }\n}\n\nexport class ConflictError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super('conflict', message, 409, details, userMessage, suggestion, requestId)\n this.name = 'ConflictError'\n defineSDKErrorType(this, 'ConflictError')\n }\n}\n\nexport class RateLimitError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'rate_limit_exceeded',\n message,\n 429,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'RateLimitError')\n }\n}\n\nfunction hasBrandedSDKErrorShape(error: unknown): error is SDKError {\n if (error === null || typeof error !== 'object') return false\n\n const candidate = error as Record<PropertyKey, unknown>\n return (\n candidate[SDK_ERROR_BRAND] === true &&\n typeof candidate.name === 'string' &&\n typeof candidate.code === 'string' &&\n typeof candidate.message === 'string' &&\n (candidate.status === undefined || typeof candidate.status === 'number') &&\n (candidate.userMessage === undefined ||\n typeof candidate.userMessage === 'string') &&\n (candidate.suggestion === undefined ||\n typeof candidate.suggestion === 'string') &&\n (candidate.requestId === undefined ||\n typeof candidate.requestId === 'string') &&\n (candidate.kind === undefined || candidate.kind === 'commerce') &&\n (candidate.reason === undefined || typeof candidate.reason === 'string') &&\n (candidate.rawReason === undefined ||\n typeof candidate.rawReason === 'string') &&\n (candidate.apiReason === undefined ||\n typeof candidate.apiReason === 'string') &&\n (candidate.retryable === undefined ||\n typeof candidate.retryable === 'boolean') &&\n (candidate.retryAfter === undefined ||\n typeof candidate.retryAfter === 'number') &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nfunction hasSDKErrorType(error: unknown, type: SDKErrorType): boolean {\n return (\n hasBrandedSDKErrorShape(error) &&\n (error as unknown as Record<PropertyKey, unknown>)[SDK_ERROR_TYPE_BRAND] ===\n type\n )\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError || hasBrandedSDKErrorShape(error)\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError || hasSDKErrorType(error, 'NetworkError')\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (\n error instanceof ValidationError ||\n hasSDKErrorType(error, 'ValidationError')\n ) {\n return true\n }\n if (error == null || typeof error !== 'object') return false\n\n const candidate = error as {\n code?: unknown\n name?: unknown\n message?: unknown\n getUserMessage?: unknown\n toJSON?: unknown\n }\n return (\n candidate.name === 'ValidationError' &&\n candidate.code === 'VALIDATION_ERROR' &&\n typeof candidate.message === 'string' &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nexport function isApiError(error: unknown): error is ApiError {\n return error instanceof ApiError || hasSDKErrorType(error, 'ApiError')\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError || hasSDKErrorType(error, 'ConfigError')\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError || hasSDKErrorType(error, 'TimeoutError')\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError || hasSDKErrorType(error, 'GoneError')\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return (\n error instanceof ServiceUnavailableError ||\n hasSDKErrorType(error, 'ServiceUnavailableError')\n )\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return (\n error instanceof UsageLimitError ||\n hasSDKErrorType(error, 'UsageLimitError')\n )\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError || hasSDKErrorType(error, 'AuthError')\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return (\n error instanceof PermissionError ||\n hasSDKErrorType(error, 'PermissionError')\n )\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return (\n error instanceof NotFoundError || hasSDKErrorType(error, 'NotFoundError')\n )\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return (\n error instanceof ConflictError || hasSDKErrorType(error, 'ConflictError')\n )\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return (\n error instanceof RateLimitError || hasSDKErrorType(error, 'RateLimitError')\n )\n}\n\nexport const createNetworkError = (\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new NetworkError(message, status, details, userMessage, suggestion)\n\nexport const createValidationError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status?: number,\n) => new ValidationError(message, details, userMessage, suggestion, status)\n\nexport const createApiError = (\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ApiError(message, status, details, userMessage, suggestion, requestId)\n\nexport const createConfigError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new ConfigError(message, details, userMessage, suggestion)\n\nexport const createTimeoutError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new TimeoutError(message, details, userMessage, suggestion)\n\nexport const createGoneError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new GoneError(message, details, userMessage, suggestion)\n\nexport const createServiceUnavailableError = (\n message?: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) =>\n new ServiceUnavailableError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n )\n\nexport const createUsageLimitError = (\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new UsageLimitError(message, usage, details, userMessage, suggestion)\n\nexport const createAuthError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new AuthError(message, details, userMessage, suggestion, requestId)\n\nexport const createPermissionError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new PermissionError(message, details, userMessage, suggestion, requestId)\n\nexport const createNotFoundError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new NotFoundError(message, details, userMessage, suggestion, requestId)\n\nexport const createConflictError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ConflictError(message, details, userMessage, suggestion, requestId)\n\nexport const createRateLimitError = (\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) =>\n new RateLimitError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n","import { createValidationError } from '../errors'\n\nconst CACHE_RESOURCE_VERSION = 'storefront:v1'\n\nexport type StorefrontCacheScope = {\n /**\n * Tenant identifier for the public storefront read.\n */\n tenantId: string | number\n /**\n * Stable, non-secret scope for publishable-key variance. Use a short key id,\n * key fingerprint, or \"default\" when a tenant has one public cache view.\n */\n publishableKeyScope?: string | number\n}\n\nexport type StorefrontCacheProductDetailIdentity =\n | { id: string | number; slug?: never }\n | { id?: never; slug: string }\n\nfunction invalidResourceInput(message: string) {\n return createValidationError(message)\n}\n\nfunction encodeResourceSegment(value: unknown, label: string): string {\n if (typeof value !== 'string' && typeof value !== 'number') {\n throw invalidResourceInput(`${label} must be a string or number`)\n }\n if (typeof value === 'number' && !Number.isFinite(value)) {\n throw invalidResourceInput(`${label} must be a finite number`)\n }\n const segment = String(value).trim()\n if (!segment) {\n throw invalidResourceInput(`${label} must not be empty`)\n }\n return encodeURIComponent(segment)\n}\n\nfunction scopedResource(scope: StorefrontCacheScope, resource: string): string {\n if (scope == null || typeof scope !== 'object') {\n throw invalidResourceInput('cache scope must be an object')\n }\n const candidate = scope as {\n tenantId?: unknown\n publishableKeyScope?: unknown\n }\n const tenantId = encodeResourceSegment(candidate.tenantId, 'tenantId')\n const publishableKeyScopeValue =\n candidate.publishableKeyScope === undefined\n ? 'default'\n : candidate.publishableKeyScope\n const publishableKeyScope = encodeResourceSegment(\n publishableKeyScopeValue,\n 'publishableKeyScope',\n )\n\n return `${CACHE_RESOURCE_VERSION}:tenant:${tenantId}:key:${publishableKeyScope}:resource:${resource}`\n}\n\nfunction listResource(scope: StorefrontCacheScope, collection: string): string {\n return scopedResource(scope, `${collection}:list`)\n}\n\nfunction idDetailResource(\n scope: StorefrontCacheScope,\n collection: string,\n id: string | number,\n): string {\n return scopedResource(\n scope,\n `${collection}:detail:id:${encodeResourceSegment(id, 'resource id')}`,\n )\n}\n\nfunction productDetailResource(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n): string {\n const candidate = (identity ?? {}) as {\n id?: unknown\n slug?: unknown\n }\n const hasIdField = candidate.id !== undefined\n const hasSlugField = candidate.slug !== undefined\n\n if (hasIdField === hasSlugField) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n\n if (hasIdField) {\n if (\n (typeof candidate.id !== 'string' && typeof candidate.id !== 'number') ||\n String(candidate.id).trim() === ''\n ) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return idDetailResource(scope, 'products', candidate.id as string | number)\n }\n if (typeof candidate.slug !== 'string' || candidate.slug.trim() === '') {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return scopedResource(\n scope,\n `products:detail:slug:${encodeResourceSegment(\n candidate.slug as string,\n 'resource slug',\n )}`,\n )\n}\n\nexport const storefrontCacheResources = {\n productListing(scope: StorefrontCacheScope): string {\n return listResource(scope, 'products')\n },\n productDetail(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n ): string {\n return productDetailResource(scope, identity)\n },\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,kBAAkB,uBAAO,IAAI,2BAA2B;AAC9D,IAAM,uBAAuB,uBAAO,IAAI,gCAAgC;AAiBxE,SAAS,oBA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K,UAAU;AAAA,MAChE,GAAI,KAAK,eAAe,UAAa,EAAE,YAAY,KAAK,WAAW;AAAA,IACrE;AAAA,EACF;AACF;AAOO,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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AAC7E,SAAO,eAAe,OAAO,GAAG,UAAU,OAAO;AACnD;AAEA,SAAS,iBACP,OACA,YACA,IACQ;AACR,SAAO;AAAA,IACL;AAAA,IACA,GAAG,UAAU,cAAc,sBAAsB,IAAI,aAAa,CAAC;AAAA,EACrE;AACF;AAEA,SAAS,sBACP,OACA,UACQ;AACR,QAAM,YAAa,YAAY,CAAC;AAIhC,QAAM,aAAa,UAAU,OAAO;AACpC,QAAM,eAAe,UAAU,SAAS;AAExC,MAAI,eAAe,cAAc;AAC/B,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AAEA,MAAI,YAAY;AACd,QACG,OAAO,UAAU,OAAO,YAAY,OAAO,UAAU,OAAO,YAC7D,OAAO,UAAU,EAAE,EAAE,KAAK,MAAM,IAChC;AACA,YAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,WAAO,iBAAiB,OAAO,YAAY,UAAU,EAAqB;AAAA,EAC5E;AACA,MAAI,OAAO,UAAU,SAAS,YAAY,UAAU,KAAK,KAAK,MAAM,IAAI;AACtE,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,wBAAwB;AAAA,MACtB,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,2BAA2B;AAAA,EACtC,eAAe,OAAqC;AAClD,WAAO,aAAa,OAAO,UAAU;AAAA,EACvC;AAAA,EACA,cACE,OACA,UACQ;AACR,WAAO,sBAAsB,OAAO,QAAQ;AAAA,EAC9C;AACF;","names":[]}
@@ -94,6 +94,7 @@ var COMMERCE_ERROR_CODES = [
94
94
  "payment_session_not_cancelable",
95
95
  "payment_session_conflict",
96
96
  "provider_identity_mismatch",
97
+ "managed_refund_attestation_forbidden",
97
98
  "payment_method_unavailable",
98
99
  "provider_unavailable",
99
100
  "lock_timeout",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/errors.ts","../src/utils/storefront-cache.ts"],"sourcesContent":["const SDK_ERROR_BRAND = Symbol.for('@01.software/sdk/SDKError')\nconst SDK_ERROR_TYPE_BRAND = Symbol.for('@01.software/sdk/SDKError.type')\n\ntype SDKErrorType =\n | 'NetworkError'\n | 'ValidationError'\n | 'ApiError'\n | 'ConfigError'\n | 'TimeoutError'\n | 'GoneError'\n | 'ServiceUnavailableError'\n | 'UsageLimitError'\n | 'AuthError'\n | 'PermissionError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'RateLimitError'\n\nfunction defineSDKErrorBrand(error: SDKError): void {\n Object.defineProperty(error, SDK_ERROR_BRAND, {\n value: true,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nfunction defineSDKErrorType(error: SDKError, type: SDKErrorType): void {\n Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nexport class SDKError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n readonly userMessage?: string\n readonly suggestion?: string\n readonly requestId?: string\n readonly kind?: 'commerce'\n readonly reason?: CommerceErrorCode | 'unknown_commerce_error'\n readonly rawReason?: string\n /** Machine-readable reason from a non-commerce API response. */\n readonly apiReason?: string\n readonly retryable?: boolean\n readonly retryAfter?: number\n\n constructor(\n code: string,\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(message)\n this.name = 'SDKError'\n this.code = code\n this.status = status\n this.details = details\n this.userMessage = userMessage\n this.suggestion = suggestion\n this.requestId = requestId\n defineSDKErrorBrand(this)\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, new.target)\n }\n }\n\n getUserMessage(): string {\n return this.userMessage || this.message\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n userMessage: this.userMessage,\n suggestion: this.suggestion,\n ...(this.requestId !== undefined && { requestId: this.requestId }),\n ...(this.kind !== undefined && { kind: this.kind }),\n ...(this.reason !== undefined && { reason: this.reason }),\n ...(this.rawReason !== undefined && { rawReason: this.rawReason }),\n ...(this.apiReason !== undefined && { apiReason: this.apiReason }),\n ...(this.retryable !== undefined && { retryable: this.retryable }),\n ...(this.retryAfter !== undefined && { retryAfter: this.retryAfter }),\n }\n }\n}\n\n/**\n * Canonical Cart/Checkout/PaymentSession error reasons. This public SDK mirror\n * intentionally does not import the private contracts package; parity is\n * enforced by a type test.\n */\nexport const COMMERCE_ERROR_CODES = [\n 'validation_failed',\n 'bad_request',\n 'unauthorized',\n 'forbidden',\n 'account_suspended',\n 'key_invalid',\n 'pat_tenant_header_forbidden',\n 'tenant_mismatch',\n 'test_tenant_expired',\n 'token_invalid',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'role_denied',\n 'scope_denied',\n 'feature_disabled',\n 'not_found',\n 'conflict',\n 'locked',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'idempotency_key_required',\n 'invalid_idempotency_key',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'checkout_already_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'payment_session_conflict',\n 'provider_identity_mismatch',\n 'payment_method_unavailable',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\n 'reservation_conflict',\n 'stock_lock_unavailable',\n 'variant_not_found',\n 'variant_stock_write_failed',\n 'stock_invariant_violation',\n 'payment_confirmation_in_flight',\n 'checkout_reservation_release_requires_transaction',\n 'admission_metadata_invalid',\n 'admission_metadata_required',\n 'capacity_exceeded',\n 'occurrence_lock_unavailable',\n 'occurrence_not_open',\n 'admission_type_capacity_exceeded',\n 'admission_type_occurrence_mismatch',\n 'admission_hold_expired',\n 'admission_hold_checkout_item_conflict',\n 'admission_hold_checkout_conflict',\n 'admission_hold_quantity_mismatch',\n 'admission_hold_unbound',\n 'admission_hold_missing',\n 'admission_hold_checkout_item_missing',\n 'admission_hold_expiry_failed',\n 'admission_hold_expiry_requires_transaction',\n 'admission_hold_line_item_mismatch',\n 'admission_materialization_failed',\n 'variant_inactive',\n 'variant_product_mismatch',\n 'product_not_public',\n 'market_not_found',\n 'market_shipping_currency_unsupported',\n 'missing_market_rate',\n 'missing_shipping_amount',\n 'no_enabled_payment_provider',\n 'product_market_unavailable',\n 'unsupported_currency',\n 'missing_price_row',\n 'payment_provider_currency_unsupported',\n 'discount_code_not_found',\n 'discount_not_started',\n 'discount_expired',\n 'discount_usage_limit',\n 'discount_per_customer_limit',\n 'discount_customer_required',\n 'discount_first_order_only',\n 'discount_customer_not_eligible',\n 'discount_customer_excluded',\n 'discount_items_required',\n 'discount_product_not_eligible',\n 'discount_product_excluded',\n 'discount_min_order_amount',\n 'discount_currency_scope_required',\n 'discount_allocation_method_unsupported',\n 'currency_mismatch',\n 'customer_token_required',\n 'market_required',\n 'server_derived',\n 'internal_error',\n] as const\n\nexport type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number]\n\ntype CommerceSDKErrorBase = SDKError & {\n readonly kind: 'commerce'\n readonly requestId: string\n readonly retryable: boolean\n readonly retryAfter?: number\n readonly details?: Record<string, unknown>\n}\n\nexport type CommerceSDKError = CommerceSDKErrorBase &\n (\n | { readonly reason: CommerceErrorCode; readonly rawReason?: never }\n | {\n readonly reason: 'unknown_commerce_error'\n readonly rawReason: string\n }\n )\n\nconst COMMERCE_ERROR_CODE_SET: ReadonlySet<string> = new Set(\n COMMERCE_ERROR_CODES,\n)\nconst COMMERCE_ERROR_ENVELOPE_KEYS = new Set([\n 'error',\n 'reason',\n 'requestId',\n 'retryable',\n 'details',\n])\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport type CommerceErrorEnvelope = {\n error: string\n reason: string\n requestId: string\n retryable: boolean\n details?: Record<string, unknown>\n}\n\nfunction commerceProtocolError(\n issue: string,\n trustedRequestId?: string,\n): SDKError {\n return createApiError(\n 'Invalid canonical commerce error response.',\n 502,\n { protocol: 'commerce-error-envelope', issue },\n 'The server returned an incompatible commerce error response.',\n 'Verify that the Console commerce contract is deployed before using this SDK version.',\n trustedRequestId,\n )\n}\n\n/** @internal Strictly parse a canonical commerce error without retaining its raw body. */\nexport function parseCommerceErrorEnvelope(\n body: unknown,\n headerRequestId?: string,\n): CommerceErrorEnvelope {\n if (headerRequestId === undefined) {\n throw commerceProtocolError('missing_request_id_header')\n }\n if (headerRequestId.length === 0) {\n throw commerceProtocolError('empty_request_id_header')\n }\n if (!isPlainRecord(body)) {\n throw commerceProtocolError('expected_object', headerRequestId)\n }\n if (Object.keys(body).some((key) => !COMMERCE_ERROR_ENVELOPE_KEYS.has(key))) {\n throw commerceProtocolError('unexpected_field', headerRequestId)\n }\n if (\n typeof body.error !== 'string' ||\n body.error.length === 0 ||\n typeof body.reason !== 'string' ||\n body.reason.length === 0 ||\n typeof body.requestId !== 'string' ||\n body.requestId.length === 0 ||\n (body.retryable !== undefined && typeof body.retryable !== 'boolean') ||\n (body.details !== undefined && !isPlainRecord(body.details))\n ) {\n throw commerceProtocolError('invalid_field', headerRequestId)\n }\n\n if (headerRequestId !== undefined && headerRequestId !== body.requestId) {\n throw commerceProtocolError('request_id_mismatch', headerRequestId)\n }\n\n return {\n error: body.error,\n reason: body.reason,\n requestId: body.requestId,\n retryable: body.retryable === true,\n ...(body.details === undefined ? {} : { details: body.details }),\n }\n}\n\n/** @internal Validate and apply the canonical commerce error envelope. */\nexport function enhanceCommerceError(\n error: SDKError,\n body: unknown,\n headerRequestId?: string,\n): SDKError {\n const envelope = parseCommerceErrorEnvelope(body, headerRequestId)\n\n const known = COMMERCE_ERROR_CODE_SET.has(envelope.reason)\n Object.assign(error, {\n code: envelope.reason,\n kind: 'commerce' as const,\n reason: known\n ? (envelope.reason as CommerceErrorCode)\n : 'unknown_commerce_error',\n ...(known ? {} : { rawReason: envelope.reason }),\n requestId: envelope.requestId,\n retryable: envelope.retryable,\n details: envelope.details,\n })\n return error\n}\n\n/** @internal Apply a non-commerce reason without canonical-commerce validation. */\nexport function enhanceNonCommerceError(\n error: SDKError,\n reason: unknown,\n): SDKError {\n if (typeof reason === 'string') Object.assign(error, { apiReason: reason })\n return error\n}\n\n/**\n * Read the server-provided machine reason across strict commerce and\n * non-commerce SDK errors. Unknown commerce reasons are returned verbatim.\n */\nexport function getSDKErrorReason(error: SDKError): string | undefined {\n if (error.kind !== 'commerce') return error.apiReason\n return error.reason === 'unknown_commerce_error'\n ? error.rawReason\n : error.reason\n}\n\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!isSDKError(error) || error.kind !== 'commerce') return false\n if (\n typeof error.requestId !== 'string' ||\n typeof error.retryable !== 'boolean' ||\n (error.retryAfter !== undefined &&\n (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0)) ||\n typeof error.reason !== 'string'\n ) {\n return false\n }\n return error.reason === 'unknown_commerce_error'\n ? typeof error.rawReason === 'string'\n : COMMERCE_ERROR_CODE_SET.has(error.reason) && error.rawReason === undefined\n}\n\nexport class NetworkError extends SDKError {\n constructor(\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('NETWORK_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'NetworkError'\n defineSDKErrorType(this, 'NetworkError')\n }\n}\n\nexport class ValidationError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status = 400,\n ) {\n super('VALIDATION_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'ValidationError'\n defineSDKErrorType(this, 'ValidationError')\n }\n}\n\nexport class ApiError extends SDKError {\n constructor(\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'API_ERROR',\n message,\n status,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'ApiError'\n defineSDKErrorType(this, 'ApiError')\n }\n}\n\nexport class ConfigError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('CONFIG_ERROR', message, undefined, details, userMessage, suggestion)\n this.name = 'ConfigError'\n defineSDKErrorType(this, 'ConfigError')\n }\n}\n\nexport class TimeoutError extends SDKError {\n constructor(\n message = 'Request timed out.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('TIMEOUT_ERROR', message, 408, details, userMessage, suggestion)\n this.name = 'TimeoutError'\n defineSDKErrorType(this, 'TimeoutError')\n }\n}\n\nexport class GoneError extends SDKError {\n constructor(\n message = 'The requested resource is no longer available.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('GONE_ERROR', message, 410, details, userMessage, suggestion)\n this.name = 'GoneError'\n defineSDKErrorType(this, 'GoneError')\n }\n}\n\nexport class ServiceUnavailableError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message = 'Service temporarily unavailable.',\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super(\n 'SERVICE_UNAVAILABLE_ERROR',\n message,\n 503,\n details,\n userMessage,\n suggestion,\n )\n this.name = 'ServiceUnavailableError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'ServiceUnavailableError')\n }\n}\n\nexport class UsageLimitError extends SDKError {\n readonly usage: { limit: number; current: number; remaining: number }\n\n constructor(\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('USAGE_LIMIT_ERROR', message, 429, details, userMessage, suggestion)\n this.name = 'UsageLimitError'\n this.usage = usage\n defineSDKErrorType(this, 'UsageLimitError')\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n usage: this.usage,\n }\n }\n}\n\nexport class AuthError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'auth_error',\n message,\n 401,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'AuthError'\n defineSDKErrorType(this, 'AuthError')\n }\n}\n\nexport class PermissionError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'permission_error',\n message,\n 403,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'PermissionError'\n defineSDKErrorType(this, 'PermissionError')\n }\n}\n\nexport class NotFoundError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'not_found',\n message,\n 404,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'NotFoundError'\n defineSDKErrorType(this, 'NotFoundError')\n }\n}\n\nexport class ConflictError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super('conflict', message, 409, details, userMessage, suggestion, requestId)\n this.name = 'ConflictError'\n defineSDKErrorType(this, 'ConflictError')\n }\n}\n\nexport class RateLimitError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'rate_limit_exceeded',\n message,\n 429,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'RateLimitError')\n }\n}\n\nfunction hasBrandedSDKErrorShape(error: unknown): error is SDKError {\n if (error === null || typeof error !== 'object') return false\n\n const candidate = error as Record<PropertyKey, unknown>\n return (\n candidate[SDK_ERROR_BRAND] === true &&\n typeof candidate.name === 'string' &&\n typeof candidate.code === 'string' &&\n typeof candidate.message === 'string' &&\n (candidate.status === undefined || typeof candidate.status === 'number') &&\n (candidate.userMessage === undefined ||\n typeof candidate.userMessage === 'string') &&\n (candidate.suggestion === undefined ||\n typeof candidate.suggestion === 'string') &&\n (candidate.requestId === undefined ||\n typeof candidate.requestId === 'string') &&\n (candidate.kind === undefined || candidate.kind === 'commerce') &&\n (candidate.reason === undefined || typeof candidate.reason === 'string') &&\n (candidate.rawReason === undefined ||\n typeof candidate.rawReason === 'string') &&\n (candidate.apiReason === undefined ||\n typeof candidate.apiReason === 'string') &&\n (candidate.retryable === undefined ||\n typeof candidate.retryable === 'boolean') &&\n (candidate.retryAfter === undefined ||\n typeof candidate.retryAfter === 'number') &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nfunction hasSDKErrorType(error: unknown, type: SDKErrorType): boolean {\n return (\n hasBrandedSDKErrorShape(error) &&\n (error as unknown as Record<PropertyKey, unknown>)[SDK_ERROR_TYPE_BRAND] ===\n type\n )\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError || hasBrandedSDKErrorShape(error)\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError || hasSDKErrorType(error, 'NetworkError')\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (\n error instanceof ValidationError ||\n hasSDKErrorType(error, 'ValidationError')\n ) {\n return true\n }\n if (error == null || typeof error !== 'object') return false\n\n const candidate = error as {\n code?: unknown\n name?: unknown\n message?: unknown\n getUserMessage?: unknown\n toJSON?: unknown\n }\n return (\n candidate.name === 'ValidationError' &&\n candidate.code === 'VALIDATION_ERROR' &&\n typeof candidate.message === 'string' &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nexport function isApiError(error: unknown): error is ApiError {\n return error instanceof ApiError || hasSDKErrorType(error, 'ApiError')\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError || hasSDKErrorType(error, 'ConfigError')\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError || hasSDKErrorType(error, 'TimeoutError')\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError || hasSDKErrorType(error, 'GoneError')\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return (\n error instanceof ServiceUnavailableError ||\n hasSDKErrorType(error, 'ServiceUnavailableError')\n )\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return (\n error instanceof UsageLimitError ||\n hasSDKErrorType(error, 'UsageLimitError')\n )\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError || hasSDKErrorType(error, 'AuthError')\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return (\n error instanceof PermissionError ||\n hasSDKErrorType(error, 'PermissionError')\n )\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return (\n error instanceof NotFoundError || hasSDKErrorType(error, 'NotFoundError')\n )\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return (\n error instanceof ConflictError || hasSDKErrorType(error, 'ConflictError')\n )\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return (\n error instanceof RateLimitError || hasSDKErrorType(error, 'RateLimitError')\n )\n}\n\nexport const createNetworkError = (\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new NetworkError(message, status, details, userMessage, suggestion)\n\nexport const createValidationError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status?: number,\n) => new ValidationError(message, details, userMessage, suggestion, status)\n\nexport const createApiError = (\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ApiError(message, status, details, userMessage, suggestion, requestId)\n\nexport const createConfigError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new ConfigError(message, details, userMessage, suggestion)\n\nexport const createTimeoutError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new TimeoutError(message, details, userMessage, suggestion)\n\nexport const createGoneError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new GoneError(message, details, userMessage, suggestion)\n\nexport const createServiceUnavailableError = (\n message?: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) =>\n new ServiceUnavailableError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n )\n\nexport const createUsageLimitError = (\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new UsageLimitError(message, usage, details, userMessage, suggestion)\n\nexport const createAuthError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new AuthError(message, details, userMessage, suggestion, requestId)\n\nexport const createPermissionError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new PermissionError(message, details, userMessage, suggestion, requestId)\n\nexport const createNotFoundError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new NotFoundError(message, details, userMessage, suggestion, requestId)\n\nexport const createConflictError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ConflictError(message, details, userMessage, suggestion, requestId)\n\nexport const createRateLimitError = (\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) =>\n new RateLimitError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n","import { createValidationError } from '../errors'\n\nconst CACHE_RESOURCE_VERSION = 'storefront:v1'\n\nexport type StorefrontCacheScope = {\n /**\n * Tenant identifier for the public storefront read.\n */\n tenantId: string | number\n /**\n * Stable, non-secret scope for publishable-key variance. Use a short key id,\n * key fingerprint, or \"default\" when a tenant has one public cache view.\n */\n publishableKeyScope?: string | number\n}\n\nexport type StorefrontCacheProductDetailIdentity =\n | { id: string | number; slug?: never }\n | { id?: never; slug: string }\n\nfunction invalidResourceInput(message: string) {\n return createValidationError(message)\n}\n\nfunction encodeResourceSegment(value: unknown, label: string): string {\n if (typeof value !== 'string' && typeof value !== 'number') {\n throw invalidResourceInput(`${label} must be a string or number`)\n }\n if (typeof value === 'number' && !Number.isFinite(value)) {\n throw invalidResourceInput(`${label} must be a finite number`)\n }\n const segment = String(value).trim()\n if (!segment) {\n throw invalidResourceInput(`${label} must not be empty`)\n }\n return encodeURIComponent(segment)\n}\n\nfunction scopedResource(scope: StorefrontCacheScope, resource: string): string {\n if (scope == null || typeof scope !== 'object') {\n throw invalidResourceInput('cache scope must be an object')\n }\n const candidate = scope as {\n tenantId?: unknown\n publishableKeyScope?: unknown\n }\n const tenantId = encodeResourceSegment(candidate.tenantId, 'tenantId')\n const publishableKeyScopeValue =\n candidate.publishableKeyScope === undefined\n ? 'default'\n : candidate.publishableKeyScope\n const publishableKeyScope = encodeResourceSegment(\n publishableKeyScopeValue,\n 'publishableKeyScope',\n )\n\n return `${CACHE_RESOURCE_VERSION}:tenant:${tenantId}:key:${publishableKeyScope}:resource:${resource}`\n}\n\nfunction listResource(scope: StorefrontCacheScope, collection: string): string {\n return scopedResource(scope, `${collection}:list`)\n}\n\nfunction idDetailResource(\n scope: StorefrontCacheScope,\n collection: string,\n id: string | number,\n): string {\n return scopedResource(\n scope,\n `${collection}:detail:id:${encodeResourceSegment(id, 'resource id')}`,\n )\n}\n\nfunction productDetailResource(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n): string {\n const candidate = (identity ?? {}) as {\n id?: unknown\n slug?: unknown\n }\n const hasIdField = candidate.id !== undefined\n const hasSlugField = candidate.slug !== undefined\n\n if (hasIdField === hasSlugField) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n\n if (hasIdField) {\n if (\n (typeof candidate.id !== 'string' && typeof candidate.id !== 'number') ||\n String(candidate.id).trim() === ''\n ) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return idDetailResource(scope, 'products', candidate.id as string | number)\n }\n if (typeof candidate.slug !== 'string' || candidate.slug.trim() === '') {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return scopedResource(\n scope,\n `products:detail:slug:${encodeResourceSegment(\n candidate.slug as string,\n 'resource slug',\n )}`,\n )\n}\n\nexport const storefrontCacheResources = {\n productListing(scope: StorefrontCacheScope): string {\n return listResource(scope, 'products')\n },\n productDetail(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n ): string {\n return productDetailResource(scope, identity)\n },\n} as const\n"],"mappings":";AAAA,IAAM,kBAAkB,uBAAO,IAAI,2BAA2B;AAC9D,IAAM,uBAAuB,uBAAO,IAAI,gCAAgC;AAiBxE,SAAS,oBAAoB,OAAuB;AAClD,SAAO,eAAe,OAAO,iBAAiB;AAAA,IAC5C,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,EACZ,CAAC;AACH;AAEA,SAAS,mBAAmB,OAAiB,MAA0B;AACrE,SAAO,eAAe,OAAO,sBAAsB;AAAA,IACjD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,EACZ,CAAC;AACH;AAEO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAelC,YACE,MACA,SACA,QACA,SACA,aACA,YACA,WACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,cAAc;AACnB,SAAK,aAAa;AAClB,SAAK,YAAY;AACjB,wBAAoB,IAAI;AAExB,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,iBAAyB;AACvB,WAAO,KAAK,eAAe,KAAK;AAAA,EAClC;AAAA,EAEA,SAAS;AACP,WAAO;AAA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,wBAAwB;AAAA,MACtB,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,2BAA2B;AAAA,EACtC,eAAe,OAAqC;AAClD,WAAO,aAAa,OAAO,UAAU;AAAA,EACvC;AAAA,EACA,cACE,OACA,UACQ;AACR,WAAO,sBAAsB,OAAO,QAAQ;AAAA,EAC9C;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/core/errors.ts","../src/utils/storefront-cache.ts"],"sourcesContent":["const SDK_ERROR_BRAND = Symbol.for('@01.software/sdk/SDKError')\nconst SDK_ERROR_TYPE_BRAND = Symbol.for('@01.software/sdk/SDKError.type')\n\ntype SDKErrorType =\n | 'NetworkError'\n | 'ValidationError'\n | 'ApiError'\n | 'ConfigError'\n | 'TimeoutError'\n | 'GoneError'\n | 'ServiceUnavailableError'\n | 'UsageLimitError'\n | 'AuthError'\n | 'PermissionError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'RateLimitError'\n\nfunction defineSDKErrorBrand(error: SDKError): void {\n Object.defineProperty(error, SDK_ERROR_BRAND, {\n value: true,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nfunction defineSDKErrorType(error: SDKError, type: SDKErrorType): void {\n Object.defineProperty(error, SDK_ERROR_TYPE_BRAND, {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false,\n })\n}\n\nexport class SDKError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n readonly userMessage?: string\n readonly suggestion?: string\n readonly requestId?: string\n readonly kind?: 'commerce'\n readonly reason?: CommerceErrorCode | 'unknown_commerce_error'\n readonly rawReason?: string\n /** Machine-readable reason from a non-commerce API response. */\n readonly apiReason?: string\n readonly retryable?: boolean\n readonly retryAfter?: number\n\n constructor(\n code: string,\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(message)\n this.name = 'SDKError'\n this.code = code\n this.status = status\n this.details = details\n this.userMessage = userMessage\n this.suggestion = suggestion\n this.requestId = requestId\n defineSDKErrorBrand(this)\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, new.target)\n }\n }\n\n getUserMessage(): string {\n return this.userMessage || this.message\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n userMessage: this.userMessage,\n suggestion: this.suggestion,\n ...(this.requestId !== undefined && { requestId: this.requestId }),\n ...(this.kind !== undefined && { kind: this.kind }),\n ...(this.reason !== undefined && { reason: this.reason }),\n ...(this.rawReason !== undefined && { rawReason: this.rawReason }),\n ...(this.apiReason !== undefined && { apiReason: this.apiReason }),\n ...(this.retryable !== undefined && { retryable: this.retryable }),\n ...(this.retryAfter !== undefined && { retryAfter: this.retryAfter }),\n }\n }\n}\n\n/**\n * Canonical Cart/Checkout/PaymentSession error reasons. This public SDK mirror\n * intentionally does not import the private contracts package; parity is\n * enforced by a type test.\n */\nexport const COMMERCE_ERROR_CODES = [\n 'validation_failed',\n 'bad_request',\n 'unauthorized',\n 'forbidden',\n 'account_suspended',\n 'key_invalid',\n 'pat_tenant_header_forbidden',\n 'tenant_mismatch',\n 'test_tenant_expired',\n 'token_invalid',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'role_denied',\n 'scope_denied',\n 'feature_disabled',\n 'not_found',\n 'conflict',\n 'locked',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'idempotency_key_required',\n 'invalid_idempotency_key',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'checkout_already_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'payment_session_conflict',\n 'provider_identity_mismatch',\n 'managed_refund_attestation_forbidden',\n 'payment_method_unavailable',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\n 'reservation_conflict',\n 'stock_lock_unavailable',\n 'variant_not_found',\n 'variant_stock_write_failed',\n 'stock_invariant_violation',\n 'payment_confirmation_in_flight',\n 'checkout_reservation_release_requires_transaction',\n 'admission_metadata_invalid',\n 'admission_metadata_required',\n 'capacity_exceeded',\n 'occurrence_lock_unavailable',\n 'occurrence_not_open',\n 'admission_type_capacity_exceeded',\n 'admission_type_occurrence_mismatch',\n 'admission_hold_expired',\n 'admission_hold_checkout_item_conflict',\n 'admission_hold_checkout_conflict',\n 'admission_hold_quantity_mismatch',\n 'admission_hold_unbound',\n 'admission_hold_missing',\n 'admission_hold_checkout_item_missing',\n 'admission_hold_expiry_failed',\n 'admission_hold_expiry_requires_transaction',\n 'admission_hold_line_item_mismatch',\n 'admission_materialization_failed',\n 'variant_inactive',\n 'variant_product_mismatch',\n 'product_not_public',\n 'market_not_found',\n 'market_shipping_currency_unsupported',\n 'missing_market_rate',\n 'missing_shipping_amount',\n 'no_enabled_payment_provider',\n 'product_market_unavailable',\n 'unsupported_currency',\n 'missing_price_row',\n 'payment_provider_currency_unsupported',\n 'discount_code_not_found',\n 'discount_not_started',\n 'discount_expired',\n 'discount_usage_limit',\n 'discount_per_customer_limit',\n 'discount_customer_required',\n 'discount_first_order_only',\n 'discount_customer_not_eligible',\n 'discount_customer_excluded',\n 'discount_items_required',\n 'discount_product_not_eligible',\n 'discount_product_excluded',\n 'discount_min_order_amount',\n 'discount_currency_scope_required',\n 'discount_allocation_method_unsupported',\n 'currency_mismatch',\n 'customer_token_required',\n 'market_required',\n 'server_derived',\n 'internal_error',\n] as const\n\nexport type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number]\n\ntype CommerceSDKErrorBase = SDKError & {\n readonly kind: 'commerce'\n readonly requestId: string\n readonly retryable: boolean\n readonly retryAfter?: number\n readonly details?: Record<string, unknown>\n}\n\nexport type CommerceSDKError = CommerceSDKErrorBase &\n (\n | { readonly reason: CommerceErrorCode; readonly rawReason?: never }\n | {\n readonly reason: 'unknown_commerce_error'\n readonly rawReason: string\n }\n )\n\nconst COMMERCE_ERROR_CODE_SET: ReadonlySet<string> = new Set(\n COMMERCE_ERROR_CODES,\n)\nconst COMMERCE_ERROR_ENVELOPE_KEYS = new Set([\n 'error',\n 'reason',\n 'requestId',\n 'retryable',\n 'details',\n])\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport type CommerceErrorEnvelope = {\n error: string\n reason: string\n requestId: string\n retryable: boolean\n details?: Record<string, unknown>\n}\n\nfunction commerceProtocolError(\n issue: string,\n trustedRequestId?: string,\n): SDKError {\n return createApiError(\n 'Invalid canonical commerce error response.',\n 502,\n { protocol: 'commerce-error-envelope', issue },\n 'The server returned an incompatible commerce error response.',\n 'Verify that the Console commerce contract is deployed before using this SDK version.',\n trustedRequestId,\n )\n}\n\n/** @internal Strictly parse a canonical commerce error without retaining its raw body. */\nexport function parseCommerceErrorEnvelope(\n body: unknown,\n headerRequestId?: string,\n): CommerceErrorEnvelope {\n if (headerRequestId === undefined) {\n throw commerceProtocolError('missing_request_id_header')\n }\n if (headerRequestId.length === 0) {\n throw commerceProtocolError('empty_request_id_header')\n }\n if (!isPlainRecord(body)) {\n throw commerceProtocolError('expected_object', headerRequestId)\n }\n if (Object.keys(body).some((key) => !COMMERCE_ERROR_ENVELOPE_KEYS.has(key))) {\n throw commerceProtocolError('unexpected_field', headerRequestId)\n }\n if (\n typeof body.error !== 'string' ||\n body.error.length === 0 ||\n typeof body.reason !== 'string' ||\n body.reason.length === 0 ||\n typeof body.requestId !== 'string' ||\n body.requestId.length === 0 ||\n (body.retryable !== undefined && typeof body.retryable !== 'boolean') ||\n (body.details !== undefined && !isPlainRecord(body.details))\n ) {\n throw commerceProtocolError('invalid_field', headerRequestId)\n }\n\n if (headerRequestId !== undefined && headerRequestId !== body.requestId) {\n throw commerceProtocolError('request_id_mismatch', headerRequestId)\n }\n\n return {\n error: body.error,\n reason: body.reason,\n requestId: body.requestId,\n retryable: body.retryable === true,\n ...(body.details === undefined ? {} : { details: body.details }),\n }\n}\n\n/** @internal Validate and apply the canonical commerce error envelope. */\nexport function enhanceCommerceError(\n error: SDKError,\n body: unknown,\n headerRequestId?: string,\n): SDKError {\n const envelope = parseCommerceErrorEnvelope(body, headerRequestId)\n\n const known = COMMERCE_ERROR_CODE_SET.has(envelope.reason)\n Object.assign(error, {\n code: envelope.reason,\n kind: 'commerce' as const,\n reason: known\n ? (envelope.reason as CommerceErrorCode)\n : 'unknown_commerce_error',\n ...(known ? {} : { rawReason: envelope.reason }),\n requestId: envelope.requestId,\n retryable: envelope.retryable,\n details: envelope.details,\n })\n return error\n}\n\n/** @internal Apply a non-commerce reason without canonical-commerce validation. */\nexport function enhanceNonCommerceError(\n error: SDKError,\n reason: unknown,\n): SDKError {\n if (typeof reason === 'string') Object.assign(error, { apiReason: reason })\n return error\n}\n\n/**\n * Read the server-provided machine reason across strict commerce and\n * non-commerce SDK errors. Unknown commerce reasons are returned verbatim.\n */\nexport function getSDKErrorReason(error: SDKError): string | undefined {\n if (error.kind !== 'commerce') return error.apiReason\n return error.reason === 'unknown_commerce_error'\n ? error.rawReason\n : error.reason\n}\n\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!isSDKError(error) || error.kind !== 'commerce') return false\n if (\n typeof error.requestId !== 'string' ||\n typeof error.retryable !== 'boolean' ||\n (error.retryAfter !== undefined &&\n (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0)) ||\n typeof error.reason !== 'string'\n ) {\n return false\n }\n return error.reason === 'unknown_commerce_error'\n ? typeof error.rawReason === 'string'\n : COMMERCE_ERROR_CODE_SET.has(error.reason) && error.rawReason === undefined\n}\n\nexport class NetworkError extends SDKError {\n constructor(\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('NETWORK_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'NetworkError'\n defineSDKErrorType(this, 'NetworkError')\n }\n}\n\nexport class ValidationError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status = 400,\n ) {\n super('VALIDATION_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'ValidationError'\n defineSDKErrorType(this, 'ValidationError')\n }\n}\n\nexport class ApiError extends SDKError {\n constructor(\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'API_ERROR',\n message,\n status,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'ApiError'\n defineSDKErrorType(this, 'ApiError')\n }\n}\n\nexport class ConfigError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('CONFIG_ERROR', message, undefined, details, userMessage, suggestion)\n this.name = 'ConfigError'\n defineSDKErrorType(this, 'ConfigError')\n }\n}\n\nexport class TimeoutError extends SDKError {\n constructor(\n message = 'Request timed out.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('TIMEOUT_ERROR', message, 408, details, userMessage, suggestion)\n this.name = 'TimeoutError'\n defineSDKErrorType(this, 'TimeoutError')\n }\n}\n\nexport class GoneError extends SDKError {\n constructor(\n message = 'The requested resource is no longer available.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('GONE_ERROR', message, 410, details, userMessage, suggestion)\n this.name = 'GoneError'\n defineSDKErrorType(this, 'GoneError')\n }\n}\n\nexport class ServiceUnavailableError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message = 'Service temporarily unavailable.',\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super(\n 'SERVICE_UNAVAILABLE_ERROR',\n message,\n 503,\n details,\n userMessage,\n suggestion,\n )\n this.name = 'ServiceUnavailableError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'ServiceUnavailableError')\n }\n}\n\nexport class UsageLimitError extends SDKError {\n readonly usage: { limit: number; current: number; remaining: number }\n\n constructor(\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('USAGE_LIMIT_ERROR', message, 429, details, userMessage, suggestion)\n this.name = 'UsageLimitError'\n this.usage = usage\n defineSDKErrorType(this, 'UsageLimitError')\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n usage: this.usage,\n }\n }\n}\n\nexport class AuthError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'auth_error',\n message,\n 401,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'AuthError'\n defineSDKErrorType(this, 'AuthError')\n }\n}\n\nexport class PermissionError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'permission_error',\n message,\n 403,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'PermissionError'\n defineSDKErrorType(this, 'PermissionError')\n }\n}\n\nexport class NotFoundError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'not_found',\n message,\n 404,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'NotFoundError'\n defineSDKErrorType(this, 'NotFoundError')\n }\n}\n\nexport class ConflictError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super('conflict', message, 409, details, userMessage, suggestion, requestId)\n this.name = 'ConflictError'\n defineSDKErrorType(this, 'ConflictError')\n }\n}\n\nexport class RateLimitError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'rate_limit_exceeded',\n message,\n 429,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n defineSDKErrorType(this, 'RateLimitError')\n }\n}\n\nfunction hasBrandedSDKErrorShape(error: unknown): error is SDKError {\n if (error === null || typeof error !== 'object') return false\n\n const candidate = error as Record<PropertyKey, unknown>\n return (\n candidate[SDK_ERROR_BRAND] === true &&\n typeof candidate.name === 'string' &&\n typeof candidate.code === 'string' &&\n typeof candidate.message === 'string' &&\n (candidate.status === undefined || typeof candidate.status === 'number') &&\n (candidate.userMessage === undefined ||\n typeof candidate.userMessage === 'string') &&\n (candidate.suggestion === undefined ||\n typeof candidate.suggestion === 'string') &&\n (candidate.requestId === undefined ||\n typeof candidate.requestId === 'string') &&\n (candidate.kind === undefined || candidate.kind === 'commerce') &&\n (candidate.reason === undefined || typeof candidate.reason === 'string') &&\n (candidate.rawReason === undefined ||\n typeof candidate.rawReason === 'string') &&\n (candidate.apiReason === undefined ||\n typeof candidate.apiReason === 'string') &&\n (candidate.retryable === undefined ||\n typeof candidate.retryable === 'boolean') &&\n (candidate.retryAfter === undefined ||\n typeof candidate.retryAfter === 'number') &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nfunction hasSDKErrorType(error: unknown, type: SDKErrorType): boolean {\n return (\n hasBrandedSDKErrorShape(error) &&\n (error as unknown as Record<PropertyKey, unknown>)[SDK_ERROR_TYPE_BRAND] ===\n type\n )\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError || hasBrandedSDKErrorShape(error)\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError || hasSDKErrorType(error, 'NetworkError')\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (\n error instanceof ValidationError ||\n hasSDKErrorType(error, 'ValidationError')\n ) {\n return true\n }\n if (error == null || typeof error !== 'object') return false\n\n const candidate = error as {\n code?: unknown\n name?: unknown\n message?: unknown\n getUserMessage?: unknown\n toJSON?: unknown\n }\n return (\n candidate.name === 'ValidationError' &&\n candidate.code === 'VALIDATION_ERROR' &&\n typeof candidate.message === 'string' &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nexport function isApiError(error: unknown): error is ApiError {\n return error instanceof ApiError || hasSDKErrorType(error, 'ApiError')\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError || hasSDKErrorType(error, 'ConfigError')\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError || hasSDKErrorType(error, 'TimeoutError')\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError || hasSDKErrorType(error, 'GoneError')\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return (\n error instanceof ServiceUnavailableError ||\n hasSDKErrorType(error, 'ServiceUnavailableError')\n )\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return (\n error instanceof UsageLimitError ||\n hasSDKErrorType(error, 'UsageLimitError')\n )\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError || hasSDKErrorType(error, 'AuthError')\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return (\n error instanceof PermissionError ||\n hasSDKErrorType(error, 'PermissionError')\n )\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return (\n error instanceof NotFoundError || hasSDKErrorType(error, 'NotFoundError')\n )\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return (\n error instanceof ConflictError || hasSDKErrorType(error, 'ConflictError')\n )\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return (\n error instanceof RateLimitError || hasSDKErrorType(error, 'RateLimitError')\n )\n}\n\nexport const createNetworkError = (\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new NetworkError(message, status, details, userMessage, suggestion)\n\nexport const createValidationError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status?: number,\n) => new ValidationError(message, details, userMessage, suggestion, status)\n\nexport const createApiError = (\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ApiError(message, status, details, userMessage, suggestion, requestId)\n\nexport const createConfigError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new ConfigError(message, details, userMessage, suggestion)\n\nexport const createTimeoutError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new TimeoutError(message, details, userMessage, suggestion)\n\nexport const createGoneError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new GoneError(message, details, userMessage, suggestion)\n\nexport const createServiceUnavailableError = (\n message?: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) =>\n new ServiceUnavailableError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n )\n\nexport const createUsageLimitError = (\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new UsageLimitError(message, usage, details, userMessage, suggestion)\n\nexport const createAuthError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new AuthError(message, details, userMessage, suggestion, requestId)\n\nexport const createPermissionError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new PermissionError(message, details, userMessage, suggestion, requestId)\n\nexport const createNotFoundError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new NotFoundError(message, details, userMessage, suggestion, requestId)\n\nexport const createConflictError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ConflictError(message, details, userMessage, suggestion, requestId)\n\nexport const createRateLimitError = (\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) =>\n new RateLimitError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n","import { createValidationError } from '../errors'\n\nconst CACHE_RESOURCE_VERSION = 'storefront:v1'\n\nexport type StorefrontCacheScope = {\n /**\n * Tenant identifier for the public storefront read.\n */\n tenantId: string | number\n /**\n * Stable, non-secret scope for publishable-key variance. Use a short key id,\n * key fingerprint, or \"default\" when a tenant has one public cache view.\n */\n publishableKeyScope?: string | number\n}\n\nexport type StorefrontCacheProductDetailIdentity =\n | { id: string | number; slug?: never }\n | { id?: never; slug: string }\n\nfunction invalidResourceInput(message: string) {\n return createValidationError(message)\n}\n\nfunction encodeResourceSegment(value: unknown, label: string): string {\n if (typeof value !== 'string' && typeof value !== 'number') {\n throw invalidResourceInput(`${label} must be a string or number`)\n }\n if (typeof value === 'number' && !Number.isFinite(value)) {\n throw invalidResourceInput(`${label} must be a finite number`)\n }\n const segment = String(value).trim()\n if (!segment) {\n throw invalidResourceInput(`${label} must not be empty`)\n }\n return encodeURIComponent(segment)\n}\n\nfunction scopedResource(scope: StorefrontCacheScope, resource: string): string {\n if (scope == null || typeof scope !== 'object') {\n throw invalidResourceInput('cache scope must be an object')\n }\n const candidate = scope as {\n tenantId?: unknown\n publishableKeyScope?: unknown\n }\n const tenantId = encodeResourceSegment(candidate.tenantId, 'tenantId')\n const publishableKeyScopeValue =\n candidate.publishableKeyScope === undefined\n ? 'default'\n : candidate.publishableKeyScope\n const publishableKeyScope = encodeResourceSegment(\n publishableKeyScopeValue,\n 'publishableKeyScope',\n )\n\n return `${CACHE_RESOURCE_VERSION}:tenant:${tenantId}:key:${publishableKeyScope}:resource:${resource}`\n}\n\nfunction listResource(scope: StorefrontCacheScope, collection: string): string {\n return scopedResource(scope, `${collection}:list`)\n}\n\nfunction idDetailResource(\n scope: StorefrontCacheScope,\n collection: string,\n id: string | number,\n): string {\n return scopedResource(\n scope,\n `${collection}:detail:id:${encodeResourceSegment(id, 'resource id')}`,\n )\n}\n\nfunction productDetailResource(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n): string {\n const candidate = (identity ?? {}) as {\n id?: unknown\n slug?: unknown\n }\n const hasIdField = candidate.id !== undefined\n const hasSlugField = candidate.slug !== undefined\n\n if (hasIdField === hasSlugField) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n\n if (hasIdField) {\n if (\n (typeof candidate.id !== 'string' && typeof candidate.id !== 'number') ||\n String(candidate.id).trim() === ''\n ) {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return idDetailResource(scope, 'products', candidate.id as string | number)\n }\n if (typeof candidate.slug !== 'string' || candidate.slug.trim() === '') {\n throw invalidResourceInput(\n 'product detail identity must include exactly one non-empty id or slug',\n )\n }\n return scopedResource(\n scope,\n `products:detail:slug:${encodeResourceSegment(\n candidate.slug as string,\n 'resource slug',\n )}`,\n )\n}\n\nexport const storefrontCacheResources = {\n productListing(scope: StorefrontCacheScope): string {\n return listResource(scope, 'products')\n },\n productDetail(\n scope: StorefrontCacheScope,\n identity: StorefrontCacheProductDetailIdentity,\n ): string {\n return productDetailResource(scope, identity)\n },\n} as const\n"],"mappings":";AAAA,IAAM,kBAAkB,uBAAO,IAAI,2BAA2B;AAC9D,IAAM,uBAAuB,uBAAO,IAAI,gCAAgC;AAiBxE,SAAS,oBAAoB,OAAuB;AAClD,SAAO,eAAe,OAAO,iBAAiB;AAAA,IAC5C,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,EACZ,CAAC;AACH;AAEA,SAAS,mBAAmB,OAAiB,MAA0B;AACrE,SAAO,eAAe,OAAO,sBAAsB;AAAA,IACjD,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,UAAU;AAAA,EACZ,CAAC;AACH;AAEO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAelC,YACE,MACA,SACA,QACA,SACA,aACA,YACA,WACA;AACA,UAAM,OAA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OAAO,UAAU,OAAO,YAAY,OAAO,UAAU,OAAO,YAC7D,OAAO,UAAU,EAAE,EAAE,KAAK,MAAM,IAChC;AACA,YAAM;AAAA,QACJ;AAAA,MACF;AAAA,IACF;AACA,WAAO,iBAAiB,OAAO,YAAY,UAAU,EAAqB;AAAA,EAC5E;AACA,MAAI,OAAO,UAAU,SAAS,YAAY,UAAU,KAAK,KAAK,MAAM,IAAI;AACtE,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA,wBAAwB;AAAA,MACtB,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,IAAM,2BAA2B;AAAA,EACtC,eAAe,OAAqC;AAClD,WAAO,aAAa,OAAO,UAAU;AAAA,EACvC;AAAA,EACA,cACE,OACA,UACQ;AACR,WAAO,sBAAsB,OAAO,QAAQ;AAAA,EAC9C;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
- import { P as Product, a as ProductVariant, M as Market, C as CustomerProfile, b as CustomerProfileStat, c as CustomerProfileList, d as ProductCollection, e as Config } from './payload-types-MKbx5MuJ.js';
2
- import { C as Collection } from './const-DCNV5Kq7.js';
1
+ import { P as Product, a as ProductVariant, M as Market, C as CustomerProfile, b as CustomerProfileStat, c as CustomerProfileList, d as ProductCollection, e as Config } from './payload-types-BOsckg8B.js';
2
+ import { C as Collection } from './const-JD8obaKg.js';
3
3
 
4
4
  type PublicCustomerProfile = Omit<CustomerProfile, 'tenant' | 'customer' | 'isPublic' | 'anonymizedAt' | 'metadata'>;
5
5
  type PublicCustomerProfileListEntry = {
@@ -1,5 +1,5 @@
1
- import { P as Product, a as ProductVariant, M as Market, C as CustomerProfile, b as CustomerProfileStat, c as CustomerProfileList, d as ProductCollection, e as Config } from './payload-types-MKbx5MuJ.cjs';
2
- import { C as Collection } from './const-CBba4lDo.cjs';
1
+ import { P as Product, a as ProductVariant, M as Market, C as CustomerProfile, b as CustomerProfileStat, c as CustomerProfileList, d as ProductCollection, e as Config } from './payload-types-BOsckg8B.cjs';
2
+ import { C as Collection } from './const-D8LixhAJ.cjs';
3
3
 
4
4
  type PublicCustomerProfile = Omit<CustomerProfile, 'tenant' | 'customer' | 'isPublic' | 'anonymizedAt' | 'metadata'>;
5
5
  type PublicCustomerProfileListEntry = {
@@ -1,6 +1,6 @@
1
- import { P as PublicCollection, C as Collection, S as ServerCollection } from './const-CBba4lDo.cjs';
2
- import { C as CollectionType, a as PublicProduct, P as PublicMarket } from './types-BKr_2avj.cjs';
3
- import { O as Order, k as Transaction, l as Fulfillment, R as Return } from './payload-types-MKbx5MuJ.cjs';
1
+ import { P as PublicCollection, C as Collection, S as ServerCollection } from './const-JD8obaKg.js';
2
+ import { C as CollectionType, a as PublicProduct, P as PublicMarket } from './types-5ZlcAFuU.js';
3
+ import { O as Order, k as Transaction, l as Fulfillment, R as Return } from './payload-types-BOsckg8B.js';
4
4
 
5
5
  declare const operationBrand: unique symbol;
6
6
  type HttpOperation = {
@@ -9,27 +9,15 @@ type HttpOperation = {
9
9
  readonly method: 'get' | 'post' | 'patch' | 'delete';
10
10
  readonly path: `/${string}`;
11
11
  readonly errorFamily?: 'commerce';
12
+ /**
13
+ * Canonical commerce reasons emitted by an otherwise legacy-compatible
14
+ * endpoint. Only these responses may be normalized and parsed as the strict
15
+ * commerce envelope; every other response retains its established shape.
16
+ */
17
+ readonly typedCommerceErrorReasons?: readonly string[];
12
18
  };
13
19
 
14
- /**
15
- * Single source of truth for the commerce HTTP paths the SDK calls.
16
- *
17
- * Console exposes these as `slug + Endpoint.path` on collection configs; the SDK
18
- * has to hardcode the joined `/api/<slug>/<path>` because it cannot import the
19
- * Console at build time. To stop a Console path change from silently turning into
20
- * a runtime 404, non-quarantined values are cross-checked against live Console
21
- * endpoint registration by `apps/console/tests/unit/sdk/endpoint-parity.test.ts`.
22
- * That test also records canonical Phase 1 operations whose route is absent or
23
- * whose same-path legacy handler is not yet contract-compatible; registration
24
- * alone must never be interpreted as transport parity.
25
- *
26
- * Keep this internal — it is the transport contract, not public SDK surface.
27
- */
28
- type CanonicalCommerceEndpointDescriptor = {
29
- readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE';
30
- readonly path: string;
31
- };
32
- type CommerceEndpointDescriptor = CanonicalCommerceEndpointDescriptor | HttpOperation;
20
+ type CommerceEndpointDescriptor = HttpOperation;
33
21
 
34
22
  interface CustomerScopedApiOptions {
35
23
  publishableKey?: string;
@@ -380,6 +368,7 @@ interface RequestOptions {
380
368
  method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
381
369
  headers?: Record<string, string>;
382
370
  errorFamily?: 'commerce';
371
+ typedCommerceErrorReasons?: readonly string[];
383
372
  }
384
373
  type EndpointRequestOptions = {
385
374
  headers?: Record<string, string>;
@@ -816,6 +805,7 @@ type ReturnWithRefundParams = WithIdempotencyKey<{
816
805
  initialShippingRefundOverrideNote?: string;
817
806
  pgPaymentId: string;
818
807
  paymentKey?: string;
808
+ /** Canonical trimmed receipt URL; the server rejects values over 2048 characters. */
819
809
  refundReceiptUrl?: string;
820
810
  }>;
821
811
  type CreateFulfillmentParams = WithIdempotencyKey<{
@@ -2359,6 +2349,16 @@ type RetrieveBrowserPaymentSessionParams = {
2359
2349
  type RetrieveServerPaymentSessionParams = {
2360
2350
  paymentSessionId: string;
2361
2351
  };
2352
+ type PortOnePaymentSelector = {
2353
+ provider: 'portone';
2354
+ providerAccountKey: string;
2355
+ environment: 'test' | 'live';
2356
+ providerPaymentId: string;
2357
+ };
2358
+ type FindPortOnePaymentParams = PortOnePaymentSelector;
2359
+ type ReconcilePortOnePaymentParams = PortOnePaymentSelector & {
2360
+ idempotencyKey: string;
2361
+ };
2362
2362
  type CancelBrowserPaymentSessionParams = RetrieveBrowserPaymentSessionParams & {
2363
2363
  idempotencyKey: string;
2364
2364
  };
@@ -2404,6 +2404,44 @@ type RetrievedCustomPaymentSession = {
2404
2404
  money: Money;
2405
2405
  orderId: string | null;
2406
2406
  };
2407
+ type PortOnePaymentCurrentState = {
2408
+ paymentSession: {
2409
+ id: string;
2410
+ provider: 'portone';
2411
+ providerStatus: PaymentProviderStatus;
2412
+ finalizationStatus: 'not_ready' | 'pending' | 'committed';
2413
+ sessionRole: PaymentSessionRole;
2414
+ reconciliation: {
2415
+ status: 'none';
2416
+ } | {
2417
+ status: 'required';
2418
+ reasons: readonly PaymentReconciliationReason[];
2419
+ };
2420
+ };
2421
+ checkout: {
2422
+ id: string;
2423
+ };
2424
+ order: {
2425
+ id: string;
2426
+ orderNumber: string;
2427
+ } | null;
2428
+ money: Money;
2429
+ };
2430
+ type FindPortOnePaymentResult = {
2431
+ found: false;
2432
+ } | {
2433
+ found: true;
2434
+ current: PortOnePaymentCurrentState;
2435
+ };
2436
+ type PortOneReconciliationDisposition = 'applied' | 'observed' | 'recovered_after_ambiguous_result' | 'requires_attention';
2437
+ type ReconcilePortOnePaymentResult = {
2438
+ found: false;
2439
+ disposition: 'requires_attention';
2440
+ } | {
2441
+ found: true;
2442
+ disposition: PortOneReconciliationDisposition;
2443
+ current: PortOnePaymentCurrentState;
2444
+ };
2407
2445
  type ConfirmCustomPaymentSessionParams = {
2408
2446
  provider: string;
2409
2447
  providerSessionId: string;
@@ -2453,6 +2491,10 @@ type PortOnePaymentNextAction = {
2453
2491
  type PortOneSdkPaymentNextAction = {
2454
2492
  type: 'portone_sdk';
2455
2493
  version: 'v2';
2494
+ /** Standard V2 actions cannot release their Checkout payment slot. */
2495
+ cancelable: false;
2496
+ /** Retry only this exact action and payment ID; never start a sibling session. */
2497
+ retryPolicy: 'same_action_only';
2456
2498
  storeId: string;
2457
2499
  channelKey: string;
2458
2500
  paymentId: string;
@@ -2634,6 +2676,12 @@ declare class PaymentSessionApi extends CustomerScopedApi {
2634
2676
  cancelPortOne(params: CancelBrowserPaymentSessionParams | CancelServerPaymentSessionParams): Promise<PortOnePublicPaymentSession>;
2635
2677
  confirm(params: ConfirmTossPaymentSessionParams): Promise<PublicPaymentSession>;
2636
2678
  }
2679
+ /** Server-only facade over the managed PortOne local/convergence engine. */
2680
+ declare class PortOnePaymentReconciliationApi extends BaseApi {
2681
+ constructor(options: ServerApiOptions);
2682
+ find(params: FindPortOnePaymentParams): Promise<FindPortOnePaymentResult>;
2683
+ reconcile(params: ReconcilePortOnePaymentParams): Promise<ReconcilePortOnePaymentResult>;
2684
+ }
2637
2685
 
2638
2686
  interface CommerceClientOptions {
2639
2687
  publishableKey: string;
@@ -2846,6 +2894,8 @@ declare class ServerCommerceClient {
2846
2894
  cancel: (params: CancelServerPaymentSessionParams) => Promise<PublicPaymentSession>;
2847
2895
  cancelPortOne: (params: CancelServerPaymentSessionParams) => Promise<PortOnePublicPaymentSession>;
2848
2896
  confirm: (params: ConfirmTossPaymentSessionParams) => Promise<PublicPaymentSession>;
2897
+ findPortOne: (params: FindPortOnePaymentParams) => Promise<FindPortOnePaymentResult>;
2898
+ reconcilePortOne: (params: ReconcilePortOnePaymentParams) => Promise<ReconcilePortOnePaymentResult>;
2849
2899
  custom: {
2850
2900
  create: (params: CreateCustomPaymentSessionParams) => Promise<CustomPaymentSession>;
2851
2901
  retrieve: (params: RetrieveCustomPaymentSessionParams) => Promise<RetrievedCustomPaymentSession>;
@@ -2930,6 +2980,8 @@ interface EventsRangeEvent {
2930
2980
  endsAt?: string | null;
2931
2981
  timezone?: string | null;
2932
2982
  isAllDay: boolean;
2983
+ allDayStartDate?: string | null;
2984
+ allDayEndDateExclusive?: string | null;
2933
2985
  visibility?: string | null;
2934
2986
  sourceType?: string | null;
2935
2987
  registrationPolicy?: string | null;
@@ -2947,6 +2999,8 @@ interface EventsRangeOccurrence {
2947
2999
  endsAt?: string | null;
2948
3000
  timezone?: string | null;
2949
3001
  isAllDay: boolean;
3002
+ allDayStartDate?: string | null;
3003
+ allDayEndDateExclusive?: string | null;
2950
3004
  status?: string | null;
2951
3005
  capacity?: number;
2952
3006
  registrationCount?: number;
@@ -3233,6 +3287,8 @@ interface TenantIntrospectionClient {
3233
3287
  collectionSchema: (collection: string) => Promise<CollectionSchemaResponse>;
3234
3288
  featureProgress: (params: TenantFeatureProgressInput) => Promise<TenantFeatureProgressResponse>;
3235
3289
  }
3290
+ /** Canonical tenant-context transport identity shared by SDK-backed callers. */
3291
+ declare const TENANT_CONTEXT_PATH = "/api/tenants/context";
3236
3292
  declare class TenantIntrospectionApi extends RawBaseApi implements TenantIntrospectionClient {
3237
3293
  constructor(options: TenantIntrospectionApiOptions);
3238
3294
  context(params?: TenantContextInput): Promise<TenantContextResponse>;
@@ -3554,4 +3610,4 @@ type DeepPartial<T> = {
3554
3610
  };
3555
3611
  type ExtractArrayType<T> = T extends (infer U)[] ? U : never;
3556
3612
 
3557
- export { type PublicAttribute as $, type AddItemParams as A, type CreatePaymentSessionParams as B, CommerceClient as C, type CreatePortOnePaymentSessionParams as D, EventsClient as E, type CustomerSnapshot as F, type DebugConfig as G, type DeepPartial as H, type ExtractArrayType as I, type MembershipStatus as J, type Money as K, type PayloadMutationResponse as L, MarketDiscovery as M, type PaymentFailureReason as N, type OpenCheckoutPaymentState as O, type PayloadFindResponse as P, type PaymentNextAction as Q, type PaymentProviderStatus as R, type PaymentReconciliationReason as S, type PaymentSessionRole as T, type PortOneHostedPaymentMethod as U, type PortOnePaymentNextAction as V, type PortOnePublicPaymentSession as W, type ProductUpsertInput as X, type ProductUpsertParams as Y, type ProductUpsertResponse as Z, type ProductUpsertVariantInput as _, CommunityClient as a, type CollectionSchemaResponse as a$, type PublicCaptureEvidence as a0, type PublicCart as a1, type PublicCartItem as a2, type PublicCartItemAdmission as a3, type PublicCartMarket as a4, type PublicCartReference as a5, type PublicCheckout as a6, type PublicCheckoutItem as a7, type PublicMediaAsset as a8, type PublicMediaSize as a9, type UpdateDiscountCodesParams as aA, type UpdateItemParams as aB, type VariantInput as aC, type Where as aD, RawBaseApi as aE, type ServerApiOptions as aF, ServerCommerceClient as aG, type TenantIntrospectionClient as aH, type SubscribeMembershipParams as aI, type SubscribeMembershipResponse as aJ, type BanCustomerParams as aK, type CommunityBan as aL, type UnbanCustomerParams as aM, type ClientServerConfig as aN, type RootServerClientWithEvents as aO, type CancelServerPaymentSessionParams as aP, CartApi as aQ, type CartApiOptions as aR, CheckoutApi as aS, type CheckoutApiOptions as aT, type CheckoutListItem as aU, type CheckoutQueryParams as aV, type CheckoutQueryResult as aW, type CheckoutStatus as aX, type CollectionCustomFieldDefinition as aY, type CollectionCustomFields as aZ, type CollectionFieldSchema as a_, type PublicOrder as aa, type PublicOrderAmounts as ab, type PublicOrderItem as ac, type PublicOrderReference as ad, type PublicPaymentSession as ae, type ReconciliationRequired as af, type RemoveItemParams as ag, type RetrieveBrowserPaymentSessionParams as ah, type RetrieveCartParams as ai, type RetrieveCheckoutParams as aj, type RetryConfig as ak, type RootClient as al, type RootCollectionClient as am, type RootReadOnlyQueryBuilder as an, type ShippingLine as ao, type Sort as ap, type SpentCheckoutPaymentState as aq, type StorefrontContentListOptions as ar, type StorefrontContentReference as as, type StorefrontGalleryItem as at, type StorefrontGalleryItemsListOptions as au, type StorefrontGalleryItemsSort as av, type StorefrontLink as aw, type StorefrontLinksListOptions as ax, type StorefrontLinksSort as ay, type UpdateCartAttributesParams as az, ContentClient as b, type CustomerLoginData as b$, type ConfirmCustomPaymentSessionOptions as b0, type ConfirmCustomPaymentSessionParams as b1, type ConfirmCustomPaymentSessionResponse as b2, type ConfirmTossPaymentSessionParams as b3, type CreateCustomPaymentSessionParams as b4, type CreateServerCheckoutParams as b5, type CreateServerCheckoutResult as b6, type CustomPaymentSession as b7, type CustomPaymentSessionProof as b8, type EventAdmissionAvailabilityParams as b9, type RetrieveServerCheckoutParams as bA, type RetrieveServerPaymentSessionParams as bB, type RetrievedCustomPaymentSession as bC, type RootServerClient as bD, type ServerCartMergeParams as bE, type ServerCartMineParams as bF, type ServerCheckout as bG, type TenantContextInput as bH, type TenantContextResponse as bI, type TenantCustomFieldType as bJ, type TenantFeatureProgressEvidenceValue as bK, type TenantFeatureProgressFeature as bL, type TenantFeatureProgressGroup as bM, type TenantFeatureProgressInput as bN, type TenantFeatureProgressItem as bO, type TenantFeatureProgressItemState as bP, type TenantFeatureProgressResponse as bQ, type TenantFeatureProgressSeverity as bR, type TenantFeatureProgressStatus as bS, type TenantFieldConfigState as bT, TenantIntrospectionApi as bU, type TenantIntrospectionApiOptions as bV, type ApiDeleteOptions as bW, type PublicReadQueryOptions as bX, CustomerAuth as bY, type CustomerProfile as bZ, type CustomerAuthResponse as b_, type EventAdmissionAvailabilityResponse as ba, type EventAdmissionAvailabilityType as bb, type EventAdmissionPricePresentment as bc, type EventGuestCancelParams as bd, type EventGuestRegistration as be, type EventGuestRegistrationResponse as bf, type EventRegistrationAnswerInput as bg, type EventRegistrationAttendeeInput as bh, type EventRegistrationPublic as bi, type EventRegistrationRegisterParams as bj, type EventRegistrationRegisterResponse as bk, type EventsCalendarItem as bl, type EventsClientOptions as bm, type EventsDateParam as bn, type EventsExternalSource as bo, type EventsLocation as bp, type EventsOccurrenceLocation as bq, type EventsRangeEvent as br, type EventsRangeOccurrence as bs, type EventsRangeParams as bt, type EventsRangeResponse as bu, type EventsTaxonomyItem as bv, ModerationApi as bw, PaymentSessionApi as bx, type PaymentSessionApiOptions as by, type RetrieveCustomPaymentSessionParams as bz, CustomerNamespace as c, MAX_CART_LINE_ADMISSIONS as c$, type CustomerRegisterResponse as c0, type CustomerRegisterData as c1, type CustomerRefreshResponse as c2, type UpdateProfileData as c3, type ProductListingPageParams as c4, type ProductListingPageBaseParams as c5, type ProductDetailParams as c6, type ProductDetailCatalogResult as c7, type ProductListingPageCatalogParams as c8, type ProductListingPageResult as c9, type CommunityComment as cA, type CommunityCommentListSort as cB, type CommunityPost as cC, type CommunityPostCategory as cD, type CommunityPostListSort as cE, type CommunityPostTag as cF, type CommunityPublicAuthorSnapshot as cG, type CommunityPublicMediaAsset as cH, type CommunityPublicReference as cI, type CompatibilityProductSelectionParamEvent as cJ, type CreateFulfillmentParams as cK, type CreateReturnParams as cL, type CustomerAuthOptions as cM, type CustomerAuthorizationUrlInput as cN, type CustomerAuthorizationUrlResult as cO, CustomerOAuth as cP, type CustomerOAuthCallbackResult as cQ, type CustomerOAuthConfig as cR, type CustomerOAuthTokenSet as cS, type CustomerOrderListOptions as cT, DiscountApi as cU, type DiscountApiOptions as cV, type DiscountErrorReasonCode as cW, type FeaturedImagePointerInput as cX, type GetOrderByPaymentIdParams as cY, type LegacyProductSelectionParamEvent as cZ, type ListingGroupsParams as c_, type ProductListingGroupsCatalogItem as ca, type ProductListingPageFullParams as cb, type ProductListingGroupsItem as cc, BaseApi as cd, type ProductDetail as ce, type ProductDetailCatalog as cf, type StockSnapshotResponse as cg, type ProductSelectionMediaSource as ch, type ProductDisplayMediaSource as ci, type ResolveProductSelectionMediaInput as cj, type ResolveProductSelectionMediaResult as ck, type ProductSelectionMediaPointer as cl, type RootClientWithEvents as cm, type BulkImportFulfillmentsParams as cn, type BulkImportFulfillmentsResponse as co, type CalculateShippingParams as cp, type CalculateShippingResult as cq, type CancelOrderParams as cr, type CancelOrderResponse as cs, type CancelReasonCode as ct, type CartDiscountCode as cu, type CartWarning as cv, type CartWarningCode as cw, type Comment as cx, type CommerceClientOptions as cy, type CommunityClientOptions as cz, type CustomerMembershipView as d, type ProductOptionShape as d$, type ManagedPaymentNextAction as d0, type ManagedPublicPaymentSession as d1, type MarketDTO as d2, type MediaValue as d3, type NormalizedOptionSwatch as d4, type NormalizedProductSelection as d5, OrderApi as d6, type OrderApiOptions as d7, type OrderByPaymentResult as d8, PRODUCT_PLP_FIND_OPTIONS as d9, type ProductListingCardOptions as dA, type ProductListingCardPriceRange as dB, type ProductListingCardRepresentativeVariant as dC, type ProductListingGroup as dD, type ProductListingGroupCatalogSummary as dE, type ProductListingGroupCatalogVariant as dF, type ProductListingGroupProjection as dG, type ProductListingGroupSummary as dH, type ProductListingGroupVariant as dI, type ProductListingGroupsCatalogProduct as dJ, type ProductListingGroupsCatalogResponse as dK, type ProductListingGroupsProduct as dL, type ProductListingGroupsResponse as dM, type ProductListingPageFilters as dN, type ProductListingPageSort as dO, type ProductListingProductShape as dP, type ProductListingSwatch as dQ, type ProductLocaleOption as dR, type ProductLocaleReadParams as dS, type ProductLocalizedText as dT, type ProductLocalizedValue as dU, type ProductMediaResolutionSource as dV, type ProductMoneyRange as dW, type ProductOptionMatrix as dX, type ProductOptionMatrixOption as dY, type ProductOptionMatrixValue as dZ, type ProductOptionMatrixVariant as d_, PRODUCT_UPSERT_READONLY_FIELD_REASON as da, PRODUCT_UPSERT_UNKNOWN_FIELD_REASON as db, type PrepareFulfillmentOrderParams as dc, type PrepareFulfillmentOrderResponse as dd, ProductApi as de, type ProductApiOptions as df, type ProductDetailBrand as dg, type ProductDetailCatalogVariant as dh, type ProductDetailCategory as di, type ProductDetailImage as dj, type ProductDetailImageMedia as dk, type ProductDetailMedia as dl, type ProductDetailOption as dm, type ProductDetailOptionValue as dn, type ProductDetailResult as dp, type ProductDetailTag as dq, type ProductDetailUnavailableReason as dr, type ProductDetailVariant as ds, type ProductDetailVariantOptionValue as dt, type ProductDetailVideo as du, type ProductFallbackLocaleOption as dv, type ProductHrefGroup as dw, type ProductHrefOptions as dx, type ProductHrefProduct as dy, type ProductListingCard as dz, type CancelMembershipParams as e, projectProductToListingShape as e$, type ProductOptionValueShape as e0, type ProductOptionValueSwatch as e1, type ProductOptionValueSwatchInput as e2, type ProductPriceRange as e3, type ProductSelectionAvailableSwatch as e4, type ProductSelectionAvailableValue as e5, type ProductSelectionByOptionValue as e6, ProductSelectionCodecError as e7, type ProductSelectionCodecOptions as e8, type ProductSelectionInput as e9, type StockCheckResponse as eA, type StockCheckResult as eB, type StockSnapshotItem as eC, type StockSnapshotParams as eD, type UpdateFulfillmentParams as eE, type UpdateOrderParams as eF, type UpdateReturnParams as eG, type ValidateDiscountParams as eH, type ValidateDiscountResult as eI, type WithIdempotencyKey as eJ, buildProductHref as eK, buildProductListingCard as eL, buildProductListingGroupProjection as eM, buildProductListingGroupsByOption as eN, buildProductOptionMatrix as eO, buildProductOptionMatrixFromDetail as eP, createProductSelectionCodec as eQ, getAvailableOptionValues as eR, getProductSelectionImages as eS, getSelectedValueByOptionId as eT, getVariantAvailableForSale as eU, getVariantAvailableStock as eV, isProductUpsertFieldValidationErrorBody as eW, normalizeProductSelection as eX, normalizeProductSelectionFromMatrix as eY, normalizeSelectedValueIds as eZ, parseProductSelection as e_, type ProductSelectionOptionValue as ea, type ProductSelectionResolution as eb, type ProductSelectionResolutionContext as ec, type ProductSelectionUrlEmit as ed, type ProductSelectionVariant$1 as ee, type ProductUpsertFieldValidationErrorBody as ef, type ProductUpsertFieldValidationErrorReason as eg, type ProductVariantShape as eh, type PublicCheckoutBase as ei, type RequestOptions as ej, type ResolveCancelRefundFailedResponse as ek, type ResolveCancelRefundOutcome as el, type ResolveCancelRefundParams as em, type ResolveCancelRefundResponse as en, type ResolveCancelRefundSucceededResponse as eo, type ResolveProductDisplayMediaInput as ep, type ResolveProductDisplayMediaResult as eq, type ResolvedCatalogPrice as er, type ReturnCancellationReasonCode as es, type ReturnItem as et, type ReturnReason as eu, type ReturnWithRefundItem as ev, type ReturnWithRefundParams as ew, ShippingApi as ex, type ShippingApiOptions as ey, type StockCheckParams as ez, type CancelMembershipResponse as f, resolveFeaturedImagePointer as f0, resolveProductDisplayMedia as f1, resolveProductSelection as f2, resolveProductSelectionFromMatrix as f3, resolveProductSelectionMedia as f4, resolveVariantForSelection as f5, selectNext as f6, selectedSwatchMediaItemId as f7, stringifyProductSelection as f8, toShopifyPriceRangeV2 as f9, type ClientState as g, type ClientConfig as h, type ApiQueryOptions as i, type CancelBrowserPaymentSessionParams as j, type CartMergeParams as k, type CartMergeResult as l, type CartMineResult as m, type CartMutationResult as n, type CheckoutAbandonedReason as o, type CheckoutAmounts as p, type CheckoutOrderReference as q, type CheckoutPaymentSessionRef as r, type CheckoutShippingAddress as s, type ClearCartParams as t, type ClientMetadata as u, type ContentClientOptions as v, type CreateCartParams as w, type CreateCartResult as x, type CreateCheckoutParams as y, type CreateCheckoutResult as z };
3613
+ export { type PublicAttribute as $, type AddItemParams as A, type CreatePaymentSessionParams as B, CommerceClient as C, type CreatePortOnePaymentSessionParams as D, EventsClient as E, type CustomerSnapshot as F, type DebugConfig as G, type DeepPartial as H, type ExtractArrayType as I, type MembershipStatus as J, type Money as K, type PayloadMutationResponse as L, MarketDiscovery as M, type PaymentFailureReason as N, type OpenCheckoutPaymentState as O, type PayloadFindResponse as P, type PaymentNextAction as Q, type PaymentProviderStatus as R, type PaymentReconciliationReason as S, type PaymentSessionRole as T, type PortOneHostedPaymentMethod as U, type PortOnePaymentNextAction as V, type PortOnePublicPaymentSession as W, type ProductUpsertInput as X, type ProductUpsertParams as Y, type ProductUpsertResponse as Z, type ProductUpsertVariantInput as _, CommunityClient as a, type CollectionSchemaResponse as a$, type PublicCaptureEvidence as a0, type PublicCart as a1, type PublicCartItem as a2, type PublicCartItemAdmission as a3, type PublicCartMarket as a4, type PublicCartReference as a5, type PublicCheckout as a6, type PublicCheckoutItem as a7, type PublicMediaAsset as a8, type PublicMediaSize as a9, type UpdateDiscountCodesParams as aA, type UpdateItemParams as aB, type VariantInput as aC, type Where as aD, RawBaseApi as aE, type ServerApiOptions as aF, ServerCommerceClient as aG, type TenantIntrospectionClient as aH, type SubscribeMembershipParams as aI, type SubscribeMembershipResponse as aJ, type BanCustomerParams as aK, type CommunityBan as aL, type UnbanCustomerParams as aM, type ClientServerConfig as aN, type RootServerClientWithEvents as aO, type CancelServerPaymentSessionParams as aP, CartApi as aQ, type CartApiOptions as aR, CheckoutApi as aS, type CheckoutApiOptions as aT, type CheckoutListItem as aU, type CheckoutQueryParams as aV, type CheckoutQueryResult as aW, type CheckoutStatus as aX, type CollectionCustomFieldDefinition as aY, type CollectionCustomFields as aZ, type CollectionFieldSchema as a_, type PublicOrder as aa, type PublicOrderAmounts as ab, type PublicOrderItem as ac, type PublicOrderReference as ad, type PublicPaymentSession as ae, type ReconciliationRequired as af, type RemoveItemParams as ag, type RetrieveBrowserPaymentSessionParams as ah, type RetrieveCartParams as ai, type RetrieveCheckoutParams as aj, type RetryConfig as ak, type RootClient as al, type RootCollectionClient as am, type RootReadOnlyQueryBuilder as an, type ShippingLine as ao, type Sort as ap, type SpentCheckoutPaymentState as aq, type StorefrontContentListOptions as ar, type StorefrontContentReference as as, type StorefrontGalleryItem as at, type StorefrontGalleryItemsListOptions as au, type StorefrontGalleryItemsSort as av, type StorefrontLink as aw, type StorefrontLinksListOptions as ax, type StorefrontLinksSort as ay, type UpdateCartAttributesParams as az, ContentClient as b, type TenantFeatureProgressStatus as b$, type ConfirmCustomPaymentSessionOptions as b0, type ConfirmCustomPaymentSessionParams as b1, type ConfirmCustomPaymentSessionResponse as b2, type ConfirmTossPaymentSessionParams as b3, type CreateCustomPaymentSessionParams as b4, type CreateServerCheckoutParams as b5, type CreateServerCheckoutResult as b6, type CustomPaymentSession as b7, type CustomPaymentSessionProof as b8, type EventAdmissionAvailabilityParams as b9, type PaymentSessionApiOptions as bA, type PortOnePaymentCurrentState as bB, PortOnePaymentReconciliationApi as bC, type PortOnePaymentSelector as bD, type PortOneReconciliationDisposition as bE, type ReconcilePortOnePaymentParams as bF, type ReconcilePortOnePaymentResult as bG, type RetrieveCustomPaymentSessionParams as bH, type RetrieveServerCheckoutParams as bI, type RetrieveServerPaymentSessionParams as bJ, type RetrievedCustomPaymentSession as bK, type RootServerClient as bL, type ServerCartMergeParams as bM, type ServerCartMineParams as bN, type ServerCheckout as bO, TENANT_CONTEXT_PATH as bP, type TenantContextInput as bQ, type TenantContextResponse as bR, type TenantCustomFieldType as bS, type TenantFeatureProgressEvidenceValue as bT, type TenantFeatureProgressFeature as bU, type TenantFeatureProgressGroup as bV, type TenantFeatureProgressInput as bW, type TenantFeatureProgressItem as bX, type TenantFeatureProgressItemState as bY, type TenantFeatureProgressResponse as bZ, type TenantFeatureProgressSeverity as b_, type EventAdmissionAvailabilityResponse as ba, type EventAdmissionAvailabilityType as bb, type EventAdmissionPricePresentment as bc, type EventGuestCancelParams as bd, type EventGuestRegistration as be, type EventGuestRegistrationResponse as bf, type EventRegistrationAnswerInput as bg, type EventRegistrationAttendeeInput as bh, type EventRegistrationPublic as bi, type EventRegistrationRegisterParams as bj, type EventRegistrationRegisterResponse as bk, type EventsCalendarItem as bl, type EventsClientOptions as bm, type EventsDateParam as bn, type EventsExternalSource as bo, type EventsLocation as bp, type EventsOccurrenceLocation as bq, type EventsRangeEvent as br, type EventsRangeOccurrence as bs, type EventsRangeParams as bt, type EventsRangeResponse as bu, type EventsTaxonomyItem as bv, type FindPortOnePaymentParams as bw, type FindPortOnePaymentResult as bx, ModerationApi as by, PaymentSessionApi as bz, CustomerNamespace as c, type FeaturedImagePointerInput as c$, type TenantFieldConfigState as c0, TenantIntrospectionApi as c1, type TenantIntrospectionApiOptions as c2, type ApiDeleteOptions as c3, type PublicReadQueryOptions as c4, CustomerAuth as c5, type CustomerProfile as c6, type CustomerAuthResponse as c7, type CustomerLoginData as c8, type CustomerRegisterResponse as c9, type CartWarningCode as cA, type Comment as cB, type CommerceClientOptions as cC, type CommunityClientOptions as cD, type CommunityComment as cE, type CommunityCommentListSort as cF, type CommunityPost as cG, type CommunityPostCategory as cH, type CommunityPostListSort as cI, type CommunityPostTag as cJ, type CommunityPublicAuthorSnapshot as cK, type CommunityPublicMediaAsset as cL, type CommunityPublicReference as cM, type CompatibilityProductSelectionParamEvent as cN, type CreateFulfillmentParams as cO, type CreateReturnParams as cP, type CustomerAuthOptions as cQ, type CustomerAuthorizationUrlInput as cR, type CustomerAuthorizationUrlResult as cS, CustomerOAuth as cT, type CustomerOAuthCallbackResult as cU, type CustomerOAuthConfig as cV, type CustomerOAuthTokenSet as cW, type CustomerOrderListOptions as cX, DiscountApi as cY, type DiscountApiOptions as cZ, type DiscountErrorReasonCode as c_, type CustomerRegisterData as ca, type CustomerRefreshResponse as cb, type UpdateProfileData as cc, type ProductListingPageParams as cd, type ProductListingPageBaseParams as ce, type ProductDetailParams as cf, type ProductDetailCatalogResult as cg, type ProductListingPageCatalogParams as ch, type ProductListingPageResult as ci, type ProductListingGroupsCatalogItem as cj, type ProductListingPageFullParams as ck, type ProductListingGroupsItem as cl, BaseApi as cm, type ProductDetail as cn, type ProductDetailCatalog as co, type StockSnapshotResponse as cp, type RootClientWithEvents as cq, type BulkImportFulfillmentsParams as cr, type BulkImportFulfillmentsResponse as cs, type CalculateShippingParams as ct, type CalculateShippingResult as cu, type CancelOrderParams as cv, type CancelOrderResponse as cw, type CancelReasonCode as cx, type CartDiscountCode as cy, type CartWarning as cz, type CustomerMembershipView as d, type ProductMoneyRange as d$, type GetOrderByPaymentIdParams as d0, type LegacyProductSelectionParamEvent as d1, type ListingGroupsParams as d2, MAX_CART_LINE_ADMISSIONS as d3, type ManagedPaymentNextAction as d4, type ManagedPublicPaymentSession as d5, type MarketDTO as d6, type MediaValue as d7, type NormalizedOptionSwatch as d8, type NormalizedProductSelection as d9, type ProductFallbackLocaleOption as dA, type ProductHrefGroup as dB, type ProductHrefOptions as dC, type ProductHrefProduct as dD, type ProductListingCard as dE, type ProductListingCardOptions as dF, type ProductListingCardPriceRange as dG, type ProductListingCardRepresentativeVariant as dH, type ProductListingGroup as dI, type ProductListingGroupCatalogSummary as dJ, type ProductListingGroupCatalogVariant as dK, type ProductListingGroupProjection as dL, type ProductListingGroupSummary as dM, type ProductListingGroupVariant as dN, type ProductListingGroupsCatalogProduct as dO, type ProductListingGroupsCatalogResponse as dP, type ProductListingGroupsProduct as dQ, type ProductListingGroupsResponse as dR, type ProductListingPageFilters as dS, type ProductListingPageSort as dT, type ProductListingProductShape as dU, type ProductListingSwatch as dV, type ProductLocaleOption as dW, type ProductLocaleReadParams as dX, type ProductLocalizedText as dY, type ProductLocalizedValue as dZ, type ProductMediaResolutionSource as d_, OrderApi as da, type OrderApiOptions as db, type OrderByPaymentResult as dc, PRODUCT_PLP_FIND_OPTIONS as dd, PRODUCT_UPSERT_READONLY_FIELD_REASON as de, PRODUCT_UPSERT_UNKNOWN_FIELD_REASON as df, type PrepareFulfillmentOrderParams as dg, type PrepareFulfillmentOrderResponse as dh, ProductApi as di, type ProductApiOptions as dj, type ProductDetailBrand as dk, type ProductDetailCatalogVariant as dl, type ProductDetailCategory as dm, type ProductDetailImage as dn, type ProductDetailImageMedia as dp, type ProductDetailMedia as dq, type ProductDetailOption as dr, type ProductDetailOptionValue as ds, type ProductDetailResult as dt, type ProductDetailTag as du, type ProductDetailUnavailableReason as dv, type ProductDetailVariant as dw, type ProductDetailVariantOptionValue as dx, type ProductDetailVideo as dy, type ProductDisplayMediaSource as dz, type CancelMembershipParams as e, getProductSelectionImages as e$, type ProductOptionMatrix as e0, type ProductOptionMatrixOption as e1, type ProductOptionMatrixValue as e2, type ProductOptionMatrixVariant as e3, type ProductOptionShape as e4, type ProductOptionValueShape as e5, type ProductOptionValueSwatch as e6, type ProductOptionValueSwatchInput as e7, type ProductPriceRange as e8, type ProductSelectionAvailableSwatch as e9, type ResolvedCatalogPrice as eA, type ReturnCancellationReasonCode as eB, type ReturnItem as eC, type ReturnReason as eD, type ReturnWithRefundItem as eE, type ReturnWithRefundParams as eF, ShippingApi as eG, type ShippingApiOptions as eH, type StockCheckParams as eI, type StockCheckResponse as eJ, type StockCheckResult as eK, type StockSnapshotItem as eL, type StockSnapshotParams as eM, type UpdateFulfillmentParams as eN, type UpdateOrderParams as eO, type UpdateReturnParams as eP, type ValidateDiscountParams as eQ, type ValidateDiscountResult as eR, type WithIdempotencyKey as eS, buildProductHref as eT, buildProductListingCard as eU, buildProductListingGroupProjection as eV, buildProductListingGroupsByOption as eW, buildProductOptionMatrix as eX, buildProductOptionMatrixFromDetail as eY, createProductSelectionCodec as eZ, getAvailableOptionValues as e_, type ProductSelectionAvailableValue as ea, type ProductSelectionByOptionValue as eb, ProductSelectionCodecError as ec, type ProductSelectionCodecOptions as ed, type ProductSelectionInput as ee, type ProductSelectionMediaPointer as ef, type ProductSelectionMediaSource as eg, type ProductSelectionOptionValue as eh, type ProductSelectionResolution as ei, type ProductSelectionResolutionContext as ej, type ProductSelectionUrlEmit as ek, type ProductSelectionVariant$1 as el, type ProductUpsertFieldValidationErrorBody as em, type ProductUpsertFieldValidationErrorReason as en, type ProductVariantShape as eo, type PublicCheckoutBase as ep, type RequestOptions as eq, type ResolveCancelRefundFailedResponse as er, type ResolveCancelRefundOutcome as es, type ResolveCancelRefundParams as et, type ResolveCancelRefundResponse as eu, type ResolveCancelRefundSucceededResponse as ev, type ResolveProductDisplayMediaInput as ew, type ResolveProductDisplayMediaResult as ex, type ResolveProductSelectionMediaInput as ey, type ResolveProductSelectionMediaResult as ez, type CancelMembershipResponse as f, getSelectedValueByOptionId as f0, getVariantAvailableForSale as f1, getVariantAvailableStock as f2, isProductUpsertFieldValidationErrorBody as f3, normalizeProductSelection as f4, normalizeProductSelectionFromMatrix as f5, normalizeSelectedValueIds as f6, parseProductSelection as f7, projectProductToListingShape as f8, resolveFeaturedImagePointer as f9, resolveProductDisplayMedia as fa, resolveProductSelection as fb, resolveProductSelectionFromMatrix as fc, resolveProductSelectionMedia as fd, resolveVariantForSelection as fe, selectNext as ff, selectedSwatchMediaItemId as fg, stringifyProductSelection as fh, toShopifyPriceRangeV2 as fi, type ClientState as g, type ClientConfig as h, type ApiQueryOptions as i, type CancelBrowserPaymentSessionParams as j, type CartMergeParams as k, type CartMergeResult as l, type CartMineResult as m, type CartMutationResult as n, type CheckoutAbandonedReason as o, type CheckoutAmounts as p, type CheckoutOrderReference as q, type CheckoutPaymentSessionRef as r, type CheckoutShippingAddress as s, type ClearCartParams as t, type ClientMetadata as u, type ContentClientOptions as v, type CreateCartParams as w, type CreateCartResult as x, type CreateCheckoutParams as y, type CreateCheckoutResult as z };