@01.software/sdk 0.46.1 → 0.48.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 (57) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +81 -7
  3. package/dist/client.cjs +304 -63
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +6 -6
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +304 -63
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-L2rEgBaR.d.cts → collection-client-CBup9yOx.d.cts} +4 -4
  10. package/dist/{collection-client-BEGXnfQe.d.ts → collection-client-D3ExJU-7.d.ts} +4 -4
  11. package/dist/{const-y0eipvnQ.d.cts → const-BXEi1Kix.d.cts} +4 -4
  12. package/dist/{const-GYVwlXLr.d.ts → const-k9gHylYa.d.ts} +4 -4
  13. package/dist/errors.cjs +49 -1
  14. package/dist/errors.cjs.map +1 -1
  15. package/dist/errors.d.cts +3 -3
  16. package/dist/errors.d.ts +3 -3
  17. package/dist/errors.js +49 -1
  18. package/dist/errors.js.map +1 -1
  19. package/dist/{index-BfYL6Qb1.d.cts → index-BCM9CTL7.d.cts} +3 -3
  20. package/dist/{index-Bei4WlVw.d.ts → index-CHGGkcLj.d.ts} +3 -3
  21. package/dist/index.cjs +308 -64
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +7 -7
  24. package/dist/index.d.ts +7 -7
  25. package/dist/index.js +308 -64
  26. package/dist/index.js.map +1 -1
  27. package/dist/{payload-types-3WNyC0gk.d.cts → payload-types-B6AZQcB7.d.cts} +177 -15
  28. package/dist/{payload-types-3WNyC0gk.d.ts → payload-types-B6AZQcB7.d.ts} +177 -15
  29. package/dist/query.cjs +144 -43
  30. package/dist/query.cjs.map +1 -1
  31. package/dist/query.d.cts +5 -5
  32. package/dist/query.d.ts +5 -5
  33. package/dist/query.js +144 -43
  34. package/dist/query.js.map +1 -1
  35. package/dist/realtime.d.cts +2 -2
  36. package/dist/realtime.d.ts +2 -2
  37. package/dist/server.cjs +385 -63
  38. package/dist/server.cjs.map +1 -1
  39. package/dist/server.d.cts +7 -7
  40. package/dist/server.d.ts +7 -7
  41. package/dist/server.js +385 -63
  42. package/dist/server.js.map +1 -1
  43. package/dist/storefront-cache.cjs +49 -1
  44. package/dist/storefront-cache.cjs.map +1 -1
  45. package/dist/storefront-cache.js +49 -1
  46. package/dist/storefront-cache.js.map +1 -1
  47. package/dist/{types-CAicTn-o.d.cts → types-8us-_C-Q.d.cts} +2 -2
  48. package/dist/{types-DpSyNTxy.d.ts → types-ByD2zii1.d.ts} +2 -2
  49. package/dist/{types-mIROvhhP.d.ts → types-CM2je9Kw.d.cts} +84 -7
  50. package/dist/{types-CDJ2M-MJ.d.cts → types-DbA5V3mt.d.ts} +84 -7
  51. package/dist/ui/form.d.cts +1 -1
  52. package/dist/ui/form.d.ts +1 -1
  53. package/dist/ui/video.d.cts +1 -1
  54. package/dist/ui/video.d.ts +1 -1
  55. package/dist/webhook.d.cts +4 -4
  56. package/dist/webhook.d.ts +4 -4
  57. package/package.json +6 -6
@@ -1,8 +1,8 @@
1
- import { F as DebugConfig, ag as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, K as PayloadMutationResponse, bN as ApiDeleteOptions, bO as PublicReadQueryOptions } from './types-CDJ2M-MJ.cjs';
2
- import './payload-types-3WNyC0gk.cjs';
1
+ import { G as DebugConfig, ak as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, L as PayloadMutationResponse, bW as ApiDeleteOptions, bX as PublicReadQueryOptions } from './types-CM2je9Kw.cjs';
2
+ import './payload-types-B6AZQcB7.cjs';
3
3
  import { GenerateMetadataOptions, Metadata } from './metadata.cjs';
4
- import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-y0eipvnQ.cjs';
5
- import { C as CollectionType } from './types-CAicTn-o.cjs';
4
+ import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-BXEi1Kix.cjs';
5
+ import { C as CollectionType } from './types-8us-_C-Q.cjs';
6
6
 
7
7
  interface FetchOptions extends RequestInit {
8
8
  apiUrl?: string;
@@ -1,8 +1,8 @@
1
- import { F as DebugConfig, ag as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, K as PayloadMutationResponse, bN as ApiDeleteOptions, bO as PublicReadQueryOptions } from './types-mIROvhhP.js';
2
- import './payload-types-3WNyC0gk.js';
1
+ import { G as DebugConfig, ak as RetryConfig, i as ApiQueryOptions, P as PayloadFindResponse, L as PayloadMutationResponse, bW as ApiDeleteOptions, bX as PublicReadQueryOptions } from './types-DbA5V3mt.js';
2
+ import './payload-types-B6AZQcB7.js';
3
3
  import { GenerateMetadataOptions, Metadata } from './metadata.js';
4
- import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-GYVwlXLr.js';
5
- import { C as CollectionType } from './types-DpSyNTxy.js';
4
+ import { C as Collection, S as ServerCollection, P as PublicCollection } from './const-k9gHylYa.js';
5
+ import { C as CollectionType } from './types-ByD2zii1.js';
6
6
 
7
7
  interface FetchOptions extends RequestInit {
8
8
  apiUrl?: string;
@@ -1,4 +1,4 @@
1
- import './payload-types-3WNyC0gk.cjs';
1
+ import './payload-types-B6AZQcB7.cjs';
2
2
 
3
3
  /**
4
4
  * Internal collections that should not be exposed via SDK.
@@ -10,20 +10,20 @@ type InternalCollection = (typeof INTERNAL_COLLECTIONS)[number];
10
10
  * Array of browser-public collection names for runtime use (e.g., Zod enum validation).
11
11
  * This is the single source of truth for publishable-key collection discovery.
12
12
  */
13
- declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships"];
13
+ declare const COLLECTIONS: readonly ["tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships"];
14
14
  /**
15
15
  * Server-auth collection names for runtime use. These collections are safe for
16
16
  * secret-key/PAT SDK and MCP server tools, but must not appear in browser or
17
17
  * publishable-key collection discovery.
18
18
  */
19
- declare const SERVER_ONLY_COLLECTIONS: readonly ["tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
19
+ declare const SERVER_ONLY_COLLECTIONS: readonly ["tenants", "tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
20
20
  /**
21
21
  * Browser-public collections available for publishable-key SDK access.
22
22
  * Derived from the COLLECTIONS array (single source of truth).
23
23
  */
24
24
  type PublicCollection = (typeof COLLECTIONS)[number];
25
25
  type ServerOnlyCollection = (typeof SERVER_ONLY_COLLECTIONS)[number];
26
- declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships", "tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
26
+ declare const SERVER_COLLECTIONS: readonly ["tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships", "tenants", "tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
27
27
  type ServerCollection = (typeof SERVER_COLLECTIONS)[number];
28
28
  /**
29
29
  * The published SDK collection universe is exactly the union of its three
@@ -1,4 +1,4 @@
1
- import './payload-types-3WNyC0gk.js';
1
+ import './payload-types-B6AZQcB7.js';
2
2
 
3
3
  /**
4
4
  * Internal collections that should not be exposed via SDK.
@@ -10,20 +10,20 @@ type InternalCollection = (typeof INTERNAL_COLLECTIONS)[number];
10
10
  * Array of browser-public collection names for runtime use (e.g., Zod enum validation).
11
11
  * This is the single source of truth for publishable-key collection discovery.
12
12
  */
13
- declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships"];
13
+ declare const COLLECTIONS: readonly ["tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships"];
14
14
  /**
15
15
  * Server-auth collection names for runtime use. These collections are safe for
16
16
  * secret-key/PAT SDK and MCP server tools, but must not appear in browser or
17
17
  * publishable-key collection discovery.
18
18
  */
19
- declare const SERVER_ONLY_COLLECTIONS: readonly ["tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
19
+ declare const SERVER_ONLY_COLLECTIONS: readonly ["tenants", "tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
20
20
  /**
21
21
  * Browser-public collections available for publishable-key SDK access.
22
22
  * Derived from the COLLECTIONS array (single source of truth).
23
23
  */
24
24
  type PublicCollection = (typeof COLLECTIONS)[number];
25
25
  type ServerOnlyCollection = (typeof SERVER_ONLY_COLLECTIONS)[number];
26
- declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships", "tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
26
+ declare const SERVER_COLLECTIONS: readonly ["tenant-metadata", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "markets", "brands", "customer-profiles", "customer-profile-stats", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "video-categories", "video-tags", "forms", "reaction-types", "post-categories", "post-tags", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "membership-plans", "membership-plan-prices", "customer-memberships", "tenants", "tenant-logos", "brand-logos", "images", "videos", "orders", "order-tags", "order-items", "returns", "return-items", "refunds", "refund-line-items", "order-edit-sessions", "order-staged-changes", "fulfillment-orders", "fulfillment-order-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-addresses", "form-submissions", "carts", "cart-items", "checkouts", "checkout-items", "draft-orders", "draft-order-items", "posts", "comments", "reactions", "bookmarks", "live-streams", "canvas-nodes", "canvas-edges", "customer-groups", "reports", "community-bans", "order-export-profiles", "membership-charges"];
27
27
  type ServerCollection = (typeof SERVER_COLLECTIONS)[number];
28
28
  /**
29
29
  * The published SDK collection universe is exactly the union of its three
package/dist/errors.cjs CHANGED
@@ -104,34 +104,78 @@ var SDKError = class extends Error {
104
104
  };
105
105
  var COMMERCE_ERROR_CODES = [
106
106
  "validation_failed",
107
+ "bad_request",
107
108
  "unauthorized",
108
109
  "forbidden",
110
+ "account_suspended",
111
+ "key_invalid",
112
+ "pat_tenant_header_forbidden",
113
+ "tenant_mismatch",
114
+ "test_tenant_expired",
115
+ "token_invalid",
109
116
  "token_expired",
110
117
  "origin_not_allowed",
111
118
  "server_credentials_required",
119
+ "role_denied",
120
+ "scope_denied",
121
+ "feature_disabled",
112
122
  "not_found",
113
123
  "conflict",
124
+ "locked",
114
125
  "cart_revision_conflict",
115
126
  "rate_limit_exceeded",
116
127
  "usage_limit_exceeded",
117
128
  "service_unavailable",
118
129
  "idempotency_conflict",
119
130
  "idempotency_in_progress",
131
+ "idempotency_key_required",
132
+ "invalid_idempotency_key",
120
133
  "cart_not_active",
121
134
  "cart_locked",
122
135
  "cart_empty",
123
136
  "cart_market_unavailable",
124
137
  "cart_market_mismatch",
125
138
  "checkout_not_open",
139
+ "checkout_already_open",
126
140
  "payment_slot_held",
127
141
  "reservation_expired",
128
142
  "payment_session_not_cancelable",
143
+ "payment_session_conflict",
129
144
  "provider_identity_mismatch",
145
+ "payment_method_unavailable",
130
146
  "provider_unavailable",
131
147
  "lock_timeout",
132
148
  "price_changed",
133
149
  "pricing_fact_in_use",
134
150
  "insufficient_stock",
151
+ "reservation_conflict",
152
+ "stock_lock_unavailable",
153
+ "variant_not_found",
154
+ "variant_stock_write_failed",
155
+ "stock_invariant_violation",
156
+ "payment_confirmation_in_flight",
157
+ "checkout_reservation_release_requires_transaction",
158
+ "admission_metadata_invalid",
159
+ "admission_metadata_required",
160
+ "capacity_exceeded",
161
+ "occurrence_lock_unavailable",
162
+ "occurrence_not_open",
163
+ "admission_type_capacity_exceeded",
164
+ "admission_type_occurrence_mismatch",
165
+ "admission_hold_expired",
166
+ "admission_hold_checkout_item_conflict",
167
+ "admission_hold_checkout_conflict",
168
+ "admission_hold_quantity_mismatch",
169
+ "admission_hold_unbound",
170
+ "admission_hold_missing",
171
+ "admission_hold_checkout_item_missing",
172
+ "admission_hold_expiry_failed",
173
+ "admission_hold_expiry_requires_transaction",
174
+ "admission_hold_line_item_mismatch",
175
+ "admission_materialization_failed",
176
+ "variant_inactive",
177
+ "variant_product_mismatch",
178
+ "product_not_public",
135
179
  "market_not_found",
136
180
  "market_shipping_currency_unsupported",
137
181
  "missing_market_rate",
@@ -156,7 +200,11 @@ var COMMERCE_ERROR_CODES = [
156
200
  "discount_min_order_amount",
157
201
  "discount_currency_scope_required",
158
202
  "discount_allocation_method_unsupported",
159
- "currency_mismatch"
203
+ "currency_mismatch",
204
+ "customer_token_required",
205
+ "market_required",
206
+ "server_derived",
207
+ "internal_error"
160
208
  ];
161
209
  var COMMERCE_ERROR_CODE_SET = new Set(
162
210
  COMMERCE_ERROR_CODES
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/core/errors.ts"],"sourcesContent":["export {\n SDKError,\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 COMMERCE_ERROR_CODES,\n type CommerceErrorCode,\n type CommerceSDKError,\n isSDKError,\n isNetworkError,\n isValidationError,\n isApiError,\n isConfigError,\n isTimeoutError,\n isGoneError,\n isServiceUnavailableError,\n isUsageLimitError,\n isAuthError,\n isPermissionError,\n isNotFoundError,\n isConflictError,\n isRateLimitError,\n isCommerceSDKError,\n createNetworkError,\n createValidationError,\n createApiError,\n createConfigError,\n createTimeoutError,\n createGoneError,\n createServiceUnavailableError,\n createUsageLimitError,\n createAuthError,\n createPermissionError,\n createNotFoundError,\n createConflictError,\n createRateLimitError,\n} from './core/errors'\n","export 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 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\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.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 'unauthorized',\n 'forbidden',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'not_found',\n 'conflict',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'provider_identity_mismatch',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\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] 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 (!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 && 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\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!(error instanceof SDKError) || 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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (error instanceof ValidationError) return true\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\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return error instanceof ServiceUnavailableError\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return error instanceof UsageLimitError\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return error instanceof PermissionError\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return error instanceof NotFoundError\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return error instanceof ConflictError\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return error instanceof RateLimitError\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAalC,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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,IAAM,sBAAsB,CACjC,SACA,SACA,aACA,YACA,cACG,IAAI,cAAc,SAAS,SAAS,aAAa,YAAY,SAAS;AAEpE,IAAM,sBAAsB,CACjC,SACA,SACA,aACA,YACA,cACG,IAAI,cAAc,SAAS,SAAS,aAAa,YAAY,SAAS;AAEpE,IAAM,uBAAuB,CAClC,SACA,YACA,SACA,aACA,YACA,cAEA,IAAI;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/core/errors.ts"],"sourcesContent":["export {\n SDKError,\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 COMMERCE_ERROR_CODES,\n type CommerceErrorCode,\n type CommerceSDKError,\n isSDKError,\n isNetworkError,\n isValidationError,\n isApiError,\n isConfigError,\n isTimeoutError,\n isGoneError,\n isServiceUnavailableError,\n isUsageLimitError,\n isAuthError,\n isPermissionError,\n isNotFoundError,\n isConflictError,\n isRateLimitError,\n isCommerceSDKError,\n createNetworkError,\n createValidationError,\n createApiError,\n createConfigError,\n createTimeoutError,\n createGoneError,\n createServiceUnavailableError,\n createUsageLimitError,\n createAuthError,\n createPermissionError,\n createNotFoundError,\n createConflictError,\n createRateLimitError,\n} from './core/errors'\n","export 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 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\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.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\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!(error instanceof SDKError) || 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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\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 }\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (error instanceof ValidationError) return true\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\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return error instanceof ServiceUnavailableError\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return error instanceof UsageLimitError\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return error instanceof PermissionError\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return error instanceof NotFoundError\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return error instanceof ConflictError\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return error instanceof RateLimitError\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAalC,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;AAEjB,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,iBAAyB;AACvB,WAAO,KAAK,eAAe,KAAK;AAAA,EAClC;A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;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEK,IAAM,wBAAwB,CACnC,SACA,OACA,SACA,aACA,eACG,IAAI,gBAAgB,SAAS,OAAO,SAAS,aAAa,UAAU;AAElE,IAAM,kBAAkB,CAC7B,SACA,SACA,aACA,YACA,cACG,IAAI,UAAU,SAAS,SAAS,aAAa,YAAY,SAAS;AAEhE,IAAM,wBAAwB,CACnC,SACA,SACA,aACA,YACA,cACG,IAAI,gBAAgB,SAAS,SAAS,aAAa,YAAY,SAAS;AAEtE,IAAM,sBAAsB,CACjC,SACA,SACA,aACA,YACA,cACG,IAAI,cAAc,SAAS,SAAS,aAAa,YAAY,SAAS;AAEpE,IAAM,sBAAsB,CACjC,SACA,SACA,aACA,YACA,cACG,IAAI,cAAc,SAAS,SAAS,aAAa,YAAY,SAAS;AAEpE,IAAM,uBAAuB,CAClC,SACA,YACA,SACA,aACA,YACA,cAEA,IAAI;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
package/dist/errors.d.cts CHANGED
@@ -16,7 +16,7 @@ declare class SDKError extends Error {
16
16
  retryAfter?: number | undefined;
17
17
  retryable?: boolean | undefined;
18
18
  rawReason?: string | undefined;
19
- reason?: "currency_mismatch" | "validation_failed" | "unauthorized" | "forbidden" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "not_found" | "conflict" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "provider_identity_mismatch" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "unknown_commerce_error" | undefined;
19
+ reason?: "currency_mismatch" | "validation_failed" | "bad_request" | "unauthorized" | "forbidden" | "account_suspended" | "key_invalid" | "pat_tenant_header_forbidden" | "tenant_mismatch" | "test_tenant_expired" | "token_invalid" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "role_denied" | "scope_denied" | "feature_disabled" | "not_found" | "conflict" | "locked" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "idempotency_key_required" | "invalid_idempotency_key" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "checkout_already_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "payment_session_conflict" | "provider_identity_mismatch" | "payment_method_unavailable" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "reservation_conflict" | "stock_lock_unavailable" | "variant_not_found" | "variant_stock_write_failed" | "stock_invariant_violation" | "payment_confirmation_in_flight" | "checkout_reservation_release_requires_transaction" | "admission_metadata_invalid" | "admission_metadata_required" | "capacity_exceeded" | "occurrence_lock_unavailable" | "occurrence_not_open" | "admission_type_capacity_exceeded" | "admission_type_occurrence_mismatch" | "admission_hold_expired" | "admission_hold_checkout_item_conflict" | "admission_hold_checkout_conflict" | "admission_hold_quantity_mismatch" | "admission_hold_unbound" | "admission_hold_missing" | "admission_hold_checkout_item_missing" | "admission_hold_expiry_failed" | "admission_hold_expiry_requires_transaction" | "admission_hold_line_item_mismatch" | "admission_materialization_failed" | "variant_inactive" | "variant_product_mismatch" | "product_not_public" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "customer_token_required" | "market_required" | "server_derived" | "internal_error" | "unknown_commerce_error" | undefined;
20
20
  kind?: "commerce" | undefined;
21
21
  requestId?: string | undefined;
22
22
  name: string;
@@ -33,7 +33,7 @@ declare class SDKError extends Error {
33
33
  * intentionally does not import the private contracts package; parity is
34
34
  * enforced by a type test.
35
35
  */
36
- declare const COMMERCE_ERROR_CODES: readonly ["validation_failed", "unauthorized", "forbidden", "token_expired", "origin_not_allowed", "server_credentials_required", "not_found", "conflict", "cart_revision_conflict", "rate_limit_exceeded", "usage_limit_exceeded", "service_unavailable", "idempotency_conflict", "idempotency_in_progress", "cart_not_active", "cart_locked", "cart_empty", "cart_market_unavailable", "cart_market_mismatch", "checkout_not_open", "payment_slot_held", "reservation_expired", "payment_session_not_cancelable", "provider_identity_mismatch", "provider_unavailable", "lock_timeout", "price_changed", "pricing_fact_in_use", "insufficient_stock", "market_not_found", "market_shipping_currency_unsupported", "missing_market_rate", "missing_shipping_amount", "no_enabled_payment_provider", "product_market_unavailable", "unsupported_currency", "missing_price_row", "payment_provider_currency_unsupported", "discount_code_not_found", "discount_not_started", "discount_expired", "discount_usage_limit", "discount_per_customer_limit", "discount_customer_required", "discount_first_order_only", "discount_customer_not_eligible", "discount_customer_excluded", "discount_items_required", "discount_product_not_eligible", "discount_product_excluded", "discount_min_order_amount", "discount_currency_scope_required", "discount_allocation_method_unsupported", "currency_mismatch"];
36
+ declare const COMMERCE_ERROR_CODES: readonly ["validation_failed", "bad_request", "unauthorized", "forbidden", "account_suspended", "key_invalid", "pat_tenant_header_forbidden", "tenant_mismatch", "test_tenant_expired", "token_invalid", "token_expired", "origin_not_allowed", "server_credentials_required", "role_denied", "scope_denied", "feature_disabled", "not_found", "conflict", "locked", "cart_revision_conflict", "rate_limit_exceeded", "usage_limit_exceeded", "service_unavailable", "idempotency_conflict", "idempotency_in_progress", "idempotency_key_required", "invalid_idempotency_key", "cart_not_active", "cart_locked", "cart_empty", "cart_market_unavailable", "cart_market_mismatch", "checkout_not_open", "checkout_already_open", "payment_slot_held", "reservation_expired", "payment_session_not_cancelable", "payment_session_conflict", "provider_identity_mismatch", "payment_method_unavailable", "provider_unavailable", "lock_timeout", "price_changed", "pricing_fact_in_use", "insufficient_stock", "reservation_conflict", "stock_lock_unavailable", "variant_not_found", "variant_stock_write_failed", "stock_invariant_violation", "payment_confirmation_in_flight", "checkout_reservation_release_requires_transaction", "admission_metadata_invalid", "admission_metadata_required", "capacity_exceeded", "occurrence_lock_unavailable", "occurrence_not_open", "admission_type_capacity_exceeded", "admission_type_occurrence_mismatch", "admission_hold_expired", "admission_hold_checkout_item_conflict", "admission_hold_checkout_conflict", "admission_hold_quantity_mismatch", "admission_hold_unbound", "admission_hold_missing", "admission_hold_checkout_item_missing", "admission_hold_expiry_failed", "admission_hold_expiry_requires_transaction", "admission_hold_line_item_mismatch", "admission_materialization_failed", "variant_inactive", "variant_product_mismatch", "product_not_public", "market_not_found", "market_shipping_currency_unsupported", "missing_market_rate", "missing_shipping_amount", "no_enabled_payment_provider", "product_market_unavailable", "unsupported_currency", "missing_price_row", "payment_provider_currency_unsupported", "discount_code_not_found", "discount_not_started", "discount_expired", "discount_usage_limit", "discount_per_customer_limit", "discount_customer_required", "discount_first_order_only", "discount_customer_not_eligible", "discount_customer_excluded", "discount_items_required", "discount_product_not_eligible", "discount_product_excluded", "discount_min_order_amount", "discount_currency_scope_required", "discount_allocation_method_unsupported", "currency_mismatch", "customer_token_required", "market_required", "server_derived", "internal_error"];
37
37
  type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number];
38
38
  type CommerceSDKErrorBase = SDKError & {
39
39
  readonly kind: 'commerce';
@@ -92,7 +92,7 @@ declare class UsageLimitError extends SDKError {
92
92
  retryAfter?: number | undefined;
93
93
  retryable?: boolean | undefined;
94
94
  rawReason?: string | undefined;
95
- reason?: "currency_mismatch" | "validation_failed" | "unauthorized" | "forbidden" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "not_found" | "conflict" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "provider_identity_mismatch" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "unknown_commerce_error" | undefined;
95
+ reason?: "currency_mismatch" | "validation_failed" | "bad_request" | "unauthorized" | "forbidden" | "account_suspended" | "key_invalid" | "pat_tenant_header_forbidden" | "tenant_mismatch" | "test_tenant_expired" | "token_invalid" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "role_denied" | "scope_denied" | "feature_disabled" | "not_found" | "conflict" | "locked" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "idempotency_key_required" | "invalid_idempotency_key" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "checkout_already_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "payment_session_conflict" | "provider_identity_mismatch" | "payment_method_unavailable" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "reservation_conflict" | "stock_lock_unavailable" | "variant_not_found" | "variant_stock_write_failed" | "stock_invariant_violation" | "payment_confirmation_in_flight" | "checkout_reservation_release_requires_transaction" | "admission_metadata_invalid" | "admission_metadata_required" | "capacity_exceeded" | "occurrence_lock_unavailable" | "occurrence_not_open" | "admission_type_capacity_exceeded" | "admission_type_occurrence_mismatch" | "admission_hold_expired" | "admission_hold_checkout_item_conflict" | "admission_hold_checkout_conflict" | "admission_hold_quantity_mismatch" | "admission_hold_unbound" | "admission_hold_missing" | "admission_hold_checkout_item_missing" | "admission_hold_expiry_failed" | "admission_hold_expiry_requires_transaction" | "admission_hold_line_item_mismatch" | "admission_materialization_failed" | "variant_inactive" | "variant_product_mismatch" | "product_not_public" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "customer_token_required" | "market_required" | "server_derived" | "internal_error" | "unknown_commerce_error" | undefined;
96
96
  kind?: "commerce" | undefined;
97
97
  requestId?: string | undefined;
98
98
  name: string;
package/dist/errors.d.ts CHANGED
@@ -16,7 +16,7 @@ declare class SDKError extends Error {
16
16
  retryAfter?: number | undefined;
17
17
  retryable?: boolean | undefined;
18
18
  rawReason?: string | undefined;
19
- reason?: "currency_mismatch" | "validation_failed" | "unauthorized" | "forbidden" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "not_found" | "conflict" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "provider_identity_mismatch" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "unknown_commerce_error" | undefined;
19
+ reason?: "currency_mismatch" | "validation_failed" | "bad_request" | "unauthorized" | "forbidden" | "account_suspended" | "key_invalid" | "pat_tenant_header_forbidden" | "tenant_mismatch" | "test_tenant_expired" | "token_invalid" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "role_denied" | "scope_denied" | "feature_disabled" | "not_found" | "conflict" | "locked" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "idempotency_key_required" | "invalid_idempotency_key" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "checkout_already_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "payment_session_conflict" | "provider_identity_mismatch" | "payment_method_unavailable" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "reservation_conflict" | "stock_lock_unavailable" | "variant_not_found" | "variant_stock_write_failed" | "stock_invariant_violation" | "payment_confirmation_in_flight" | "checkout_reservation_release_requires_transaction" | "admission_metadata_invalid" | "admission_metadata_required" | "capacity_exceeded" | "occurrence_lock_unavailable" | "occurrence_not_open" | "admission_type_capacity_exceeded" | "admission_type_occurrence_mismatch" | "admission_hold_expired" | "admission_hold_checkout_item_conflict" | "admission_hold_checkout_conflict" | "admission_hold_quantity_mismatch" | "admission_hold_unbound" | "admission_hold_missing" | "admission_hold_checkout_item_missing" | "admission_hold_expiry_failed" | "admission_hold_expiry_requires_transaction" | "admission_hold_line_item_mismatch" | "admission_materialization_failed" | "variant_inactive" | "variant_product_mismatch" | "product_not_public" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "customer_token_required" | "market_required" | "server_derived" | "internal_error" | "unknown_commerce_error" | undefined;
20
20
  kind?: "commerce" | undefined;
21
21
  requestId?: string | undefined;
22
22
  name: string;
@@ -33,7 +33,7 @@ declare class SDKError extends Error {
33
33
  * intentionally does not import the private contracts package; parity is
34
34
  * enforced by a type test.
35
35
  */
36
- declare const COMMERCE_ERROR_CODES: readonly ["validation_failed", "unauthorized", "forbidden", "token_expired", "origin_not_allowed", "server_credentials_required", "not_found", "conflict", "cart_revision_conflict", "rate_limit_exceeded", "usage_limit_exceeded", "service_unavailable", "idempotency_conflict", "idempotency_in_progress", "cart_not_active", "cart_locked", "cart_empty", "cart_market_unavailable", "cart_market_mismatch", "checkout_not_open", "payment_slot_held", "reservation_expired", "payment_session_not_cancelable", "provider_identity_mismatch", "provider_unavailable", "lock_timeout", "price_changed", "pricing_fact_in_use", "insufficient_stock", "market_not_found", "market_shipping_currency_unsupported", "missing_market_rate", "missing_shipping_amount", "no_enabled_payment_provider", "product_market_unavailable", "unsupported_currency", "missing_price_row", "payment_provider_currency_unsupported", "discount_code_not_found", "discount_not_started", "discount_expired", "discount_usage_limit", "discount_per_customer_limit", "discount_customer_required", "discount_first_order_only", "discount_customer_not_eligible", "discount_customer_excluded", "discount_items_required", "discount_product_not_eligible", "discount_product_excluded", "discount_min_order_amount", "discount_currency_scope_required", "discount_allocation_method_unsupported", "currency_mismatch"];
36
+ declare const COMMERCE_ERROR_CODES: readonly ["validation_failed", "bad_request", "unauthorized", "forbidden", "account_suspended", "key_invalid", "pat_tenant_header_forbidden", "tenant_mismatch", "test_tenant_expired", "token_invalid", "token_expired", "origin_not_allowed", "server_credentials_required", "role_denied", "scope_denied", "feature_disabled", "not_found", "conflict", "locked", "cart_revision_conflict", "rate_limit_exceeded", "usage_limit_exceeded", "service_unavailable", "idempotency_conflict", "idempotency_in_progress", "idempotency_key_required", "invalid_idempotency_key", "cart_not_active", "cart_locked", "cart_empty", "cart_market_unavailable", "cart_market_mismatch", "checkout_not_open", "checkout_already_open", "payment_slot_held", "reservation_expired", "payment_session_not_cancelable", "payment_session_conflict", "provider_identity_mismatch", "payment_method_unavailable", "provider_unavailable", "lock_timeout", "price_changed", "pricing_fact_in_use", "insufficient_stock", "reservation_conflict", "stock_lock_unavailable", "variant_not_found", "variant_stock_write_failed", "stock_invariant_violation", "payment_confirmation_in_flight", "checkout_reservation_release_requires_transaction", "admission_metadata_invalid", "admission_metadata_required", "capacity_exceeded", "occurrence_lock_unavailable", "occurrence_not_open", "admission_type_capacity_exceeded", "admission_type_occurrence_mismatch", "admission_hold_expired", "admission_hold_checkout_item_conflict", "admission_hold_checkout_conflict", "admission_hold_quantity_mismatch", "admission_hold_unbound", "admission_hold_missing", "admission_hold_checkout_item_missing", "admission_hold_expiry_failed", "admission_hold_expiry_requires_transaction", "admission_hold_line_item_mismatch", "admission_materialization_failed", "variant_inactive", "variant_product_mismatch", "product_not_public", "market_not_found", "market_shipping_currency_unsupported", "missing_market_rate", "missing_shipping_amount", "no_enabled_payment_provider", "product_market_unavailable", "unsupported_currency", "missing_price_row", "payment_provider_currency_unsupported", "discount_code_not_found", "discount_not_started", "discount_expired", "discount_usage_limit", "discount_per_customer_limit", "discount_customer_required", "discount_first_order_only", "discount_customer_not_eligible", "discount_customer_excluded", "discount_items_required", "discount_product_not_eligible", "discount_product_excluded", "discount_min_order_amount", "discount_currency_scope_required", "discount_allocation_method_unsupported", "currency_mismatch", "customer_token_required", "market_required", "server_derived", "internal_error"];
37
37
  type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number];
38
38
  type CommerceSDKErrorBase = SDKError & {
39
39
  readonly kind: 'commerce';
@@ -92,7 +92,7 @@ declare class UsageLimitError extends SDKError {
92
92
  retryAfter?: number | undefined;
93
93
  retryable?: boolean | undefined;
94
94
  rawReason?: string | undefined;
95
- reason?: "currency_mismatch" | "validation_failed" | "unauthorized" | "forbidden" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "not_found" | "conflict" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "provider_identity_mismatch" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "unknown_commerce_error" | undefined;
95
+ reason?: "currency_mismatch" | "validation_failed" | "bad_request" | "unauthorized" | "forbidden" | "account_suspended" | "key_invalid" | "pat_tenant_header_forbidden" | "tenant_mismatch" | "test_tenant_expired" | "token_invalid" | "token_expired" | "origin_not_allowed" | "server_credentials_required" | "role_denied" | "scope_denied" | "feature_disabled" | "not_found" | "conflict" | "locked" | "cart_revision_conflict" | "rate_limit_exceeded" | "usage_limit_exceeded" | "service_unavailable" | "idempotency_conflict" | "idempotency_in_progress" | "idempotency_key_required" | "invalid_idempotency_key" | "cart_not_active" | "cart_locked" | "cart_empty" | "cart_market_unavailable" | "cart_market_mismatch" | "checkout_not_open" | "checkout_already_open" | "payment_slot_held" | "reservation_expired" | "payment_session_not_cancelable" | "payment_session_conflict" | "provider_identity_mismatch" | "payment_method_unavailable" | "provider_unavailable" | "lock_timeout" | "price_changed" | "pricing_fact_in_use" | "insufficient_stock" | "reservation_conflict" | "stock_lock_unavailable" | "variant_not_found" | "variant_stock_write_failed" | "stock_invariant_violation" | "payment_confirmation_in_flight" | "checkout_reservation_release_requires_transaction" | "admission_metadata_invalid" | "admission_metadata_required" | "capacity_exceeded" | "occurrence_lock_unavailable" | "occurrence_not_open" | "admission_type_capacity_exceeded" | "admission_type_occurrence_mismatch" | "admission_hold_expired" | "admission_hold_checkout_item_conflict" | "admission_hold_checkout_conflict" | "admission_hold_quantity_mismatch" | "admission_hold_unbound" | "admission_hold_missing" | "admission_hold_checkout_item_missing" | "admission_hold_expiry_failed" | "admission_hold_expiry_requires_transaction" | "admission_hold_line_item_mismatch" | "admission_materialization_failed" | "variant_inactive" | "variant_product_mismatch" | "product_not_public" | "market_not_found" | "market_shipping_currency_unsupported" | "missing_market_rate" | "missing_shipping_amount" | "no_enabled_payment_provider" | "product_market_unavailable" | "unsupported_currency" | "missing_price_row" | "payment_provider_currency_unsupported" | "discount_code_not_found" | "discount_not_started" | "discount_expired" | "discount_usage_limit" | "discount_per_customer_limit" | "discount_customer_required" | "discount_first_order_only" | "discount_customer_not_eligible" | "discount_customer_excluded" | "discount_items_required" | "discount_product_not_eligible" | "discount_product_excluded" | "discount_min_order_amount" | "discount_currency_scope_required" | "discount_allocation_method_unsupported" | "customer_token_required" | "market_required" | "server_derived" | "internal_error" | "unknown_commerce_error" | undefined;
96
96
  kind?: "commerce" | undefined;
97
97
  requestId?: string | undefined;
98
98
  name: string;
package/dist/errors.js CHANGED
@@ -36,34 +36,78 @@ var SDKError = class extends Error {
36
36
  };
37
37
  var COMMERCE_ERROR_CODES = [
38
38
  "validation_failed",
39
+ "bad_request",
39
40
  "unauthorized",
40
41
  "forbidden",
42
+ "account_suspended",
43
+ "key_invalid",
44
+ "pat_tenant_header_forbidden",
45
+ "tenant_mismatch",
46
+ "test_tenant_expired",
47
+ "token_invalid",
41
48
  "token_expired",
42
49
  "origin_not_allowed",
43
50
  "server_credentials_required",
51
+ "role_denied",
52
+ "scope_denied",
53
+ "feature_disabled",
44
54
  "not_found",
45
55
  "conflict",
56
+ "locked",
46
57
  "cart_revision_conflict",
47
58
  "rate_limit_exceeded",
48
59
  "usage_limit_exceeded",
49
60
  "service_unavailable",
50
61
  "idempotency_conflict",
51
62
  "idempotency_in_progress",
63
+ "idempotency_key_required",
64
+ "invalid_idempotency_key",
52
65
  "cart_not_active",
53
66
  "cart_locked",
54
67
  "cart_empty",
55
68
  "cart_market_unavailable",
56
69
  "cart_market_mismatch",
57
70
  "checkout_not_open",
71
+ "checkout_already_open",
58
72
  "payment_slot_held",
59
73
  "reservation_expired",
60
74
  "payment_session_not_cancelable",
75
+ "payment_session_conflict",
61
76
  "provider_identity_mismatch",
77
+ "payment_method_unavailable",
62
78
  "provider_unavailable",
63
79
  "lock_timeout",
64
80
  "price_changed",
65
81
  "pricing_fact_in_use",
66
82
  "insufficient_stock",
83
+ "reservation_conflict",
84
+ "stock_lock_unavailable",
85
+ "variant_not_found",
86
+ "variant_stock_write_failed",
87
+ "stock_invariant_violation",
88
+ "payment_confirmation_in_flight",
89
+ "checkout_reservation_release_requires_transaction",
90
+ "admission_metadata_invalid",
91
+ "admission_metadata_required",
92
+ "capacity_exceeded",
93
+ "occurrence_lock_unavailable",
94
+ "occurrence_not_open",
95
+ "admission_type_capacity_exceeded",
96
+ "admission_type_occurrence_mismatch",
97
+ "admission_hold_expired",
98
+ "admission_hold_checkout_item_conflict",
99
+ "admission_hold_checkout_conflict",
100
+ "admission_hold_quantity_mismatch",
101
+ "admission_hold_unbound",
102
+ "admission_hold_missing",
103
+ "admission_hold_checkout_item_missing",
104
+ "admission_hold_expiry_failed",
105
+ "admission_hold_expiry_requires_transaction",
106
+ "admission_hold_line_item_mismatch",
107
+ "admission_materialization_failed",
108
+ "variant_inactive",
109
+ "variant_product_mismatch",
110
+ "product_not_public",
67
111
  "market_not_found",
68
112
  "market_shipping_currency_unsupported",
69
113
  "missing_market_rate",
@@ -88,7 +132,11 @@ var COMMERCE_ERROR_CODES = [
88
132
  "discount_min_order_amount",
89
133
  "discount_currency_scope_required",
90
134
  "discount_allocation_method_unsupported",
91
- "currency_mismatch"
135
+ "currency_mismatch",
136
+ "customer_token_required",
137
+ "market_required",
138
+ "server_derived",
139
+ "internal_error"
92
140
  ];
93
141
  var COMMERCE_ERROR_CODE_SET = new Set(
94
142
  COMMERCE_ERROR_CODES