@usethrottle/cart 3.1.0 → 3.3.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.
package/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ <p align="left">
2
+ <img src="https://raw.githubusercontent.com/Epic-Design-Labs/app-throttle/main/packages/brand/assets/throttle-logo.png" alt="Throttle" height="56" />
3
+ </p>
4
+
5
+
1
6
  # @usethrottle/cart
2
7
 
3
8
  Typed Node.js REST client for the Throttle Cart API.
@@ -19,7 +24,7 @@ const client = new CartClient({ apiKey: process.env.THROTTLE_API_KEY! });
19
24
 
20
25
  // 1. Create a cart
21
26
  const cart = await client.carts.create({
22
- storeId: 'store_abc',
27
+ applicationId: '7f9d4c8a-5b2e-4f16-9a73-2d1e5c8b6f40',
23
28
  currency: 'USD',
24
29
  netN: 45,
25
30
  });
@@ -52,8 +57,8 @@ const order = await client.carts.checkout(cart.id, { paymentMethod: 'card' });
52
57
  console.log(order.id, order.status);
53
58
  ```
54
59
 
55
- `applicationId` is accepted as an alias for `storeId` when your integration
56
- already uses the newer application naming.
60
+ Use applicationId for every public request body. Deprecated store identifiers
61
+ are rejected by the API.
57
62
 
58
63
  All monetary values are integers in the smallest currency unit (cents for USD).
59
64
 
@@ -95,7 +100,7 @@ External stores can also request read-only storefront quotes with a publishable
95
100
  import { StorefrontQuoteClient } from '@usethrottle/cart';
96
101
 
97
102
  const quotes = new StorefrontQuoteClient({
98
- applicationId: 'application_uuid',
103
+ applicationId: '7f9d4c8a-5b2e-4f16-9a73-2d1e5c8b6f40',
99
104
  quoteToken: 'pk_publishable_quote_token',
100
105
  });
101
106
 
@@ -123,7 +128,7 @@ when at least one axis is in `byo` mode:
123
128
 
124
129
  ```ts
125
130
  await client.shippingTax.pushExternalSnapshot({
126
- storeId: 'store_uuid',
131
+ applicationId: '7f9d4c8a-5b2e-4f16-9a73-2d1e5c8b6f40',
127
132
  cartId: cart.id,
128
133
  currency: 'USD',
129
134
  totals: {
@@ -189,6 +194,33 @@ try {
189
194
  }
190
195
  ```
191
196
 
197
+ `ThrottleApiError` extends the shared **`ThrottleError`** from
198
+ [`@usethrottle/errors`](https://www.npmjs.com/package/@usethrottle/errors),
199
+ re-exported here. If you use more than one Throttle SDK you can catch all of
200
+ their errors with a single check — `instanceof ThrottleApiError` keeps working:
201
+
202
+ ```ts
203
+ import { ThrottleError } from '@usethrottle/cart'; // same class across every SDK
204
+
205
+ try {
206
+ await cart.items.add(cartId, item);
207
+ await checkout.completeSession(sessionId, payment);
208
+ } catch (e) {
209
+ if (e instanceof ThrottleError) {
210
+ console.error(e.statusCode, e.code, e.message);
211
+ }
212
+ }
213
+ ```
214
+
215
+ ### Line item `imageUrl`
216
+
217
+ `imageUrl` accepts an absolute `http(s)` URL **or** a relative path like
218
+ `/images/x.png`. Relative paths are resolved to an absolute URL against your
219
+ application's storefront base URL so the image renders on the hosted checkout —
220
+ set it with `PUT /v1/embed-config { "storefrontBaseUrl": "https://yourstore.com" }`
221
+ (the first `allowedOrigin` is used as a fallback). A relative path with no
222
+ resolvable base returns `400 image_url_unresolvable`.
223
+
192
224
  ## Client options
193
225
 
194
226
  | Option | Default | Description |
package/dist/index.cjs CHANGED
@@ -22,25 +22,26 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  CartClient: () => CartClient,
24
24
  StorefrontQuoteClient: () => StorefrontQuoteClient,
25
- ThrottleApiError: () => ThrottleApiError
25
+ ThrottleApiError: () => ThrottleApiError,
26
+ ThrottleError: () => import_errors2.ThrottleError,
27
+ isThrottleError: () => import_errors2.isThrottleError
26
28
  });
27
29
  module.exports = __toCommonJS(index_exports);
28
30
 
29
31
  // src/errors.ts
30
- var ThrottleApiError = class extends Error {
31
- code;
32
- statusCode;
33
- details;
32
+ var import_errors = require("@usethrottle/errors");
33
+ var import_errors2 = require("@usethrottle/errors");
34
+ var ThrottleApiError = class extends import_errors.ThrottleError {
34
35
  constructor(args) {
35
- super(args.message);
36
+ super(args);
36
37
  this.name = "ThrottleApiError";
37
- this.code = args.code;
38
- this.statusCode = args.statusCode;
39
- this.details = args.details;
40
38
  }
41
39
  };
42
40
 
43
41
  // src/client.ts
42
+ function segment(value) {
43
+ return encodeURIComponent(value);
44
+ }
44
45
  var CartClient = class {
45
46
  apiKey;
46
47
  baseUrl;
@@ -81,40 +82,44 @@ var CartClient = class {
81
82
  get carts() {
82
83
  return {
83
84
  create: (input) => this.request("POST", "/api/v1/carts", input),
84
- get: (id) => this.request("GET", `/api/v1/carts/${id}`),
85
- update: (id, input) => this.request("PATCH", `/api/v1/carts/${id}`, input),
86
- checkout: (id, input) => this.request("POST", `/api/v1/carts/${id}/checkout`, input ?? {}),
87
- merge: (id, customerId) => this.request("POST", `/api/v1/carts/${id}/merge`, { customerId })
85
+ get: (id) => this.request("GET", `/api/v1/carts/${segment(id)}`),
86
+ update: (id, input) => this.request("PATCH", `/api/v1/carts/${segment(id)}`, input),
87
+ checkout: (id, input) => this.request("POST", `/api/v1/carts/${segment(id)}/checkout`, input ?? {}),
88
+ merge: (id, customerId) => this.request("POST", `/api/v1/carts/${segment(id)}/merge`, { customerId })
88
89
  };
89
90
  }
90
91
  get items() {
91
92
  return {
92
- add: (cartId, input) => this.request("POST", `/api/v1/carts/${cartId}/items`, input),
93
- update: (cartId, itemId, input) => this.request("PATCH", `/api/v1/carts/${cartId}/items/${itemId}`, input),
94
- remove: (cartId, itemId) => this.request("DELETE", `/api/v1/carts/${cartId}/items/${itemId}`)
93
+ add: (cartId, input) => this.request("POST", `/api/v1/carts/${segment(cartId)}/items`, input),
94
+ update: (cartId, itemId, input) => this.request("PATCH", `/api/v1/carts/${segment(cartId)}/items/${segment(itemId)}`, input),
95
+ remove: (cartId, itemId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/items/${segment(itemId)}`)
95
96
  };
96
97
  }
97
98
  get shipping() {
98
99
  return {
99
- select: (cartId, input) => this.request("POST", `/api/v1/carts/${cartId}/shipping`, input),
100
- clear: (cartId) => this.request("DELETE", `/api/v1/carts/${cartId}/shipping`)
100
+ select: (cartId, input) => this.request("POST", `/api/v1/carts/${segment(cartId)}/shipping`, input),
101
+ clear: (cartId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/shipping`)
101
102
  };
102
103
  }
103
104
  get discounts() {
104
105
  return {
105
- apply: (cartId, code) => this.request("POST", `/api/v1/carts/${cartId}/apply-discount`, { code }),
106
- remove: (cartId) => this.request("DELETE", `/api/v1/carts/${cartId}/discount`)
106
+ apply: (cartId, code) => this.request("POST", `/api/v1/carts/${segment(cartId)}/apply-discount`, { code }),
107
+ remove: (cartId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/discount`)
107
108
  };
108
109
  }
109
110
  get taxLines() {
110
111
  return {
111
- set: (cartId, lines) => this.request("PUT", `/api/v1/carts/${cartId}/tax-lines`, { lines }),
112
- clear: (cartId) => this.request("DELETE", `/api/v1/carts/${cartId}/tax-lines`)
112
+ set: (cartId, lines) => this.request("PUT", `/api/v1/carts/${segment(cartId)}/tax-lines`, { lines }),
113
+ clear: (cartId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/tax-lines`)
113
114
  };
114
115
  }
115
116
  get shippingTax() {
116
117
  return {
117
- calculateCart: (cartId, input = {}) => this.request("POST", `/api/v1/shipping-tax/carts/${cartId}/calculate`, input),
118
+ calculateCart: (cartId, input = {}) => this.request(
119
+ "POST",
120
+ `/api/v1/shipping-tax/carts/${segment(cartId)}/calculate`,
121
+ input
122
+ ),
118
123
  pushExternalSnapshot: (input) => this.request("POST", "/api/v1/shipping-tax/external-snapshots", input)
119
124
  };
120
125
  }
@@ -125,7 +130,7 @@ var CartClient = class {
125
130
  if (opts?.sinceSequence !== void 0) params.set("sinceSequence", String(opts.sinceSequence));
126
131
  if (opts?.limit !== void 0) params.set("limit", String(opts.limit));
127
132
  const qs = params.toString();
128
- return this.request("GET", `/api/v1/carts/${cartId}/events${qs ? "?" + qs : ""}`);
133
+ return this.request("GET", `/api/v1/carts/${segment(cartId)}/events${qs ? "?" + qs : ""}`);
129
134
  }
130
135
  };
131
136
  }
@@ -140,12 +145,11 @@ var StorefrontQuoteClient = class {
140
145
  timeoutMs;
141
146
  origin;
142
147
  constructor(opts) {
143
- const applicationId = opts.applicationId ?? opts.storeId;
144
- if (!applicationId) throw new Error("StorefrontQuoteClient: applicationId is required");
148
+ if (!opts.applicationId) throw new Error("StorefrontQuoteClient: applicationId is required");
145
149
  if (!opts.quoteToken?.startsWith("pk_")) {
146
150
  throw new Error("StorefrontQuoteClient: quoteToken must be a publishable pk_ token");
147
151
  }
148
- this.applicationId = applicationId;
152
+ this.applicationId = opts.applicationId;
149
153
  this.quoteToken = opts.quoteToken;
150
154
  this.baseUrl = (opts.baseUrl ?? "https://api.usethrottle.dev").replace(/\/+$/, "");
151
155
  this.fetchImpl = opts.fetch ?? globalThis.fetch;
@@ -162,9 +166,9 @@ var StorefrontQuoteClient = class {
162
166
  method: "POST",
163
167
  headers,
164
168
  body: JSON.stringify({
169
+ ...input,
165
170
  applicationId: this.applicationId,
166
- quoteToken: this.quoteToken,
167
- ...input
171
+ quoteToken: this.quoteToken
168
172
  }),
169
173
  signal: ctrl.signal
170
174
  });
@@ -187,5 +191,7 @@ var StorefrontQuoteClient = class {
187
191
  0 && (module.exports = {
188
192
  CartClient,
189
193
  StorefrontQuoteClient,
190
- ThrottleApiError
194
+ ThrottleApiError,
195
+ ThrottleError,
196
+ isThrottleError
191
197
  });
package/dist/index.d.cts CHANGED
@@ -1,8 +1,10 @@
1
+ import { ThrottleError } from '@usethrottle/errors';
2
+ export { ThrottleError, isThrottleError } from '@usethrottle/errors';
3
+
1
4
  interface Cart {
2
5
  id: string;
3
- merchantId: string;
6
+ workspaceId: string;
4
7
  applicationId: string;
5
- storeId: string | null;
6
8
  customerId: string | null;
7
9
  status: 'open' | 'checkout' | 'converted' | 'abandoned';
8
10
  currency: string;
@@ -88,19 +90,13 @@ interface CartEvent {
88
90
  actorId: string | null;
89
91
  createdAt: string;
90
92
  }
91
- type CartApplicationRef = {
92
- storeId: string;
93
- applicationId?: string;
94
- } | {
93
+ interface CreateCartInput {
95
94
  applicationId: string;
96
- storeId?: string;
97
- };
98
- type CreateCartInput = CartApplicationRef & {
99
95
  customerId?: string;
100
96
  currency?: string;
101
97
  netN?: number | null;
102
98
  metadata?: Record<string, unknown>;
103
- };
99
+ }
104
100
  interface UpdateCartInput {
105
101
  customerId?: string;
106
102
  billingAddress?: Record<string, unknown>;
@@ -224,8 +220,8 @@ interface ShippingTaxCalculationResponse {
224
220
  kind: 'quote' | 'cart_estimate' | 'checkout_final' | 'external_snapshot';
225
221
  status: 'estimated' | 'final' | 'failed';
226
222
  source: 'off' | 'byo' | 'calculated' | 'app_based' | 'external_push';
227
- storeId: string;
228
- merchantId?: string;
223
+ applicationId: string;
224
+ workspaceId?: string;
229
225
  currency: string;
230
226
  configId?: string;
231
227
  configVersion?: number;
@@ -287,7 +283,7 @@ interface ShippingTaxCalculationResponse {
287
283
  }>;
288
284
  }
289
285
  interface ExternalShippingTaxSnapshotInput {
290
- storeId: string;
286
+ applicationId: string;
291
287
  cartId?: string | null;
292
288
  checkoutSessionId?: string | null;
293
289
  orderId?: string | null;
@@ -348,10 +344,7 @@ declare class CartClient {
348
344
  }
349
345
 
350
346
  interface StorefrontQuoteClientOptions {
351
- /** Current API contract: the application/store UUID that owns the quote config. */
352
- applicationId?: string;
353
- /** @deprecated Use applicationId. Kept as an alias for older storefronts. */
354
- storeId?: string;
347
+ applicationId: string;
355
348
  quoteToken: string;
356
349
  baseUrl?: string;
357
350
  fetch?: typeof globalThis.fetch;
@@ -369,9 +362,14 @@ declare class StorefrontQuoteClient {
369
362
  quote(input: ShippingTaxQuoteInput): Promise<ShippingTaxCalculationResponse>;
370
363
  }
371
364
 
372
- declare class ThrottleApiError extends Error {
373
- readonly code: string;
374
- readonly statusCode: number;
365
+ /**
366
+ * Thrown on a non-2xx response from the Throttle Cart API.
367
+ *
368
+ * Extends the shared {@link ThrottleError} so a single
369
+ * `catch (e) { if (e instanceof ThrottleError) … }` covers errors from every
370
+ * Throttle SDK. `instanceof ThrottleApiError` keeps working for existing code.
371
+ */
372
+ declare class ThrottleApiError extends ThrottleError {
375
373
  readonly details?: Record<string, unknown>;
376
374
  constructor(args: {
377
375
  code: string;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import { ThrottleError } from '@usethrottle/errors';
2
+ export { ThrottleError, isThrottleError } from '@usethrottle/errors';
3
+
1
4
  interface Cart {
2
5
  id: string;
3
- merchantId: string;
6
+ workspaceId: string;
4
7
  applicationId: string;
5
- storeId: string | null;
6
8
  customerId: string | null;
7
9
  status: 'open' | 'checkout' | 'converted' | 'abandoned';
8
10
  currency: string;
@@ -88,19 +90,13 @@ interface CartEvent {
88
90
  actorId: string | null;
89
91
  createdAt: string;
90
92
  }
91
- type CartApplicationRef = {
92
- storeId: string;
93
- applicationId?: string;
94
- } | {
93
+ interface CreateCartInput {
95
94
  applicationId: string;
96
- storeId?: string;
97
- };
98
- type CreateCartInput = CartApplicationRef & {
99
95
  customerId?: string;
100
96
  currency?: string;
101
97
  netN?: number | null;
102
98
  metadata?: Record<string, unknown>;
103
- };
99
+ }
104
100
  interface UpdateCartInput {
105
101
  customerId?: string;
106
102
  billingAddress?: Record<string, unknown>;
@@ -224,8 +220,8 @@ interface ShippingTaxCalculationResponse {
224
220
  kind: 'quote' | 'cart_estimate' | 'checkout_final' | 'external_snapshot';
225
221
  status: 'estimated' | 'final' | 'failed';
226
222
  source: 'off' | 'byo' | 'calculated' | 'app_based' | 'external_push';
227
- storeId: string;
228
- merchantId?: string;
223
+ applicationId: string;
224
+ workspaceId?: string;
229
225
  currency: string;
230
226
  configId?: string;
231
227
  configVersion?: number;
@@ -287,7 +283,7 @@ interface ShippingTaxCalculationResponse {
287
283
  }>;
288
284
  }
289
285
  interface ExternalShippingTaxSnapshotInput {
290
- storeId: string;
286
+ applicationId: string;
291
287
  cartId?: string | null;
292
288
  checkoutSessionId?: string | null;
293
289
  orderId?: string | null;
@@ -348,10 +344,7 @@ declare class CartClient {
348
344
  }
349
345
 
350
346
  interface StorefrontQuoteClientOptions {
351
- /** Current API contract: the application/store UUID that owns the quote config. */
352
- applicationId?: string;
353
- /** @deprecated Use applicationId. Kept as an alias for older storefronts. */
354
- storeId?: string;
347
+ applicationId: string;
355
348
  quoteToken: string;
356
349
  baseUrl?: string;
357
350
  fetch?: typeof globalThis.fetch;
@@ -369,9 +362,14 @@ declare class StorefrontQuoteClient {
369
362
  quote(input: ShippingTaxQuoteInput): Promise<ShippingTaxCalculationResponse>;
370
363
  }
371
364
 
372
- declare class ThrottleApiError extends Error {
373
- readonly code: string;
374
- readonly statusCode: number;
365
+ /**
366
+ * Thrown on a non-2xx response from the Throttle Cart API.
367
+ *
368
+ * Extends the shared {@link ThrottleError} so a single
369
+ * `catch (e) { if (e instanceof ThrottleError) … }` covers errors from every
370
+ * Throttle SDK. `instanceof ThrottleApiError` keeps working for existing code.
371
+ */
372
+ declare class ThrottleApiError extends ThrottleError {
375
373
  readonly details?: Record<string, unknown>;
376
374
  constructor(args: {
377
375
  code: string;
package/dist/index.js CHANGED
@@ -1,18 +1,17 @@
1
1
  // src/errors.ts
2
- var ThrottleApiError = class extends Error {
3
- code;
4
- statusCode;
5
- details;
2
+ import { ThrottleError } from "@usethrottle/errors";
3
+ import { ThrottleError as ThrottleError2, isThrottleError } from "@usethrottle/errors";
4
+ var ThrottleApiError = class extends ThrottleError {
6
5
  constructor(args) {
7
- super(args.message);
6
+ super(args);
8
7
  this.name = "ThrottleApiError";
9
- this.code = args.code;
10
- this.statusCode = args.statusCode;
11
- this.details = args.details;
12
8
  }
13
9
  };
14
10
 
15
11
  // src/client.ts
12
+ function segment(value) {
13
+ return encodeURIComponent(value);
14
+ }
16
15
  var CartClient = class {
17
16
  apiKey;
18
17
  baseUrl;
@@ -53,40 +52,44 @@ var CartClient = class {
53
52
  get carts() {
54
53
  return {
55
54
  create: (input) => this.request("POST", "/api/v1/carts", input),
56
- get: (id) => this.request("GET", `/api/v1/carts/${id}`),
57
- update: (id, input) => this.request("PATCH", `/api/v1/carts/${id}`, input),
58
- checkout: (id, input) => this.request("POST", `/api/v1/carts/${id}/checkout`, input ?? {}),
59
- merge: (id, customerId) => this.request("POST", `/api/v1/carts/${id}/merge`, { customerId })
55
+ get: (id) => this.request("GET", `/api/v1/carts/${segment(id)}`),
56
+ update: (id, input) => this.request("PATCH", `/api/v1/carts/${segment(id)}`, input),
57
+ checkout: (id, input) => this.request("POST", `/api/v1/carts/${segment(id)}/checkout`, input ?? {}),
58
+ merge: (id, customerId) => this.request("POST", `/api/v1/carts/${segment(id)}/merge`, { customerId })
60
59
  };
61
60
  }
62
61
  get items() {
63
62
  return {
64
- add: (cartId, input) => this.request("POST", `/api/v1/carts/${cartId}/items`, input),
65
- update: (cartId, itemId, input) => this.request("PATCH", `/api/v1/carts/${cartId}/items/${itemId}`, input),
66
- remove: (cartId, itemId) => this.request("DELETE", `/api/v1/carts/${cartId}/items/${itemId}`)
63
+ add: (cartId, input) => this.request("POST", `/api/v1/carts/${segment(cartId)}/items`, input),
64
+ update: (cartId, itemId, input) => this.request("PATCH", `/api/v1/carts/${segment(cartId)}/items/${segment(itemId)}`, input),
65
+ remove: (cartId, itemId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/items/${segment(itemId)}`)
67
66
  };
68
67
  }
69
68
  get shipping() {
70
69
  return {
71
- select: (cartId, input) => this.request("POST", `/api/v1/carts/${cartId}/shipping`, input),
72
- clear: (cartId) => this.request("DELETE", `/api/v1/carts/${cartId}/shipping`)
70
+ select: (cartId, input) => this.request("POST", `/api/v1/carts/${segment(cartId)}/shipping`, input),
71
+ clear: (cartId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/shipping`)
73
72
  };
74
73
  }
75
74
  get discounts() {
76
75
  return {
77
- apply: (cartId, code) => this.request("POST", `/api/v1/carts/${cartId}/apply-discount`, { code }),
78
- remove: (cartId) => this.request("DELETE", `/api/v1/carts/${cartId}/discount`)
76
+ apply: (cartId, code) => this.request("POST", `/api/v1/carts/${segment(cartId)}/apply-discount`, { code }),
77
+ remove: (cartId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/discount`)
79
78
  };
80
79
  }
81
80
  get taxLines() {
82
81
  return {
83
- set: (cartId, lines) => this.request("PUT", `/api/v1/carts/${cartId}/tax-lines`, { lines }),
84
- clear: (cartId) => this.request("DELETE", `/api/v1/carts/${cartId}/tax-lines`)
82
+ set: (cartId, lines) => this.request("PUT", `/api/v1/carts/${segment(cartId)}/tax-lines`, { lines }),
83
+ clear: (cartId) => this.request("DELETE", `/api/v1/carts/${segment(cartId)}/tax-lines`)
85
84
  };
86
85
  }
87
86
  get shippingTax() {
88
87
  return {
89
- calculateCart: (cartId, input = {}) => this.request("POST", `/api/v1/shipping-tax/carts/${cartId}/calculate`, input),
88
+ calculateCart: (cartId, input = {}) => this.request(
89
+ "POST",
90
+ `/api/v1/shipping-tax/carts/${segment(cartId)}/calculate`,
91
+ input
92
+ ),
90
93
  pushExternalSnapshot: (input) => this.request("POST", "/api/v1/shipping-tax/external-snapshots", input)
91
94
  };
92
95
  }
@@ -97,7 +100,7 @@ var CartClient = class {
97
100
  if (opts?.sinceSequence !== void 0) params.set("sinceSequence", String(opts.sinceSequence));
98
101
  if (opts?.limit !== void 0) params.set("limit", String(opts.limit));
99
102
  const qs = params.toString();
100
- return this.request("GET", `/api/v1/carts/${cartId}/events${qs ? "?" + qs : ""}`);
103
+ return this.request("GET", `/api/v1/carts/${segment(cartId)}/events${qs ? "?" + qs : ""}`);
101
104
  }
102
105
  };
103
106
  }
@@ -112,12 +115,11 @@ var StorefrontQuoteClient = class {
112
115
  timeoutMs;
113
116
  origin;
114
117
  constructor(opts) {
115
- const applicationId = opts.applicationId ?? opts.storeId;
116
- if (!applicationId) throw new Error("StorefrontQuoteClient: applicationId is required");
118
+ if (!opts.applicationId) throw new Error("StorefrontQuoteClient: applicationId is required");
117
119
  if (!opts.quoteToken?.startsWith("pk_")) {
118
120
  throw new Error("StorefrontQuoteClient: quoteToken must be a publishable pk_ token");
119
121
  }
120
- this.applicationId = applicationId;
122
+ this.applicationId = opts.applicationId;
121
123
  this.quoteToken = opts.quoteToken;
122
124
  this.baseUrl = (opts.baseUrl ?? "https://api.usethrottle.dev").replace(/\/+$/, "");
123
125
  this.fetchImpl = opts.fetch ?? globalThis.fetch;
@@ -134,9 +136,9 @@ var StorefrontQuoteClient = class {
134
136
  method: "POST",
135
137
  headers,
136
138
  body: JSON.stringify({
139
+ ...input,
137
140
  applicationId: this.applicationId,
138
- quoteToken: this.quoteToken,
139
- ...input
141
+ quoteToken: this.quoteToken
140
142
  }),
141
143
  signal: ctrl.signal
142
144
  });
@@ -158,5 +160,7 @@ var StorefrontQuoteClient = class {
158
160
  export {
159
161
  CartClient,
160
162
  StorefrontQuoteClient,
161
- ThrottleApiError
163
+ ThrottleApiError,
164
+ ThrottleError2 as ThrottleError,
165
+ isThrottleError
162
166
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/cart",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Typed REST client for the Throttle Cart API.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -17,6 +17,9 @@
17
17
  "dist",
18
18
  "README.md"
19
19
  ],
20
+ "dependencies": {
21
+ "@usethrottle/errors": "^1.0.0"
22
+ },
20
23
  "devDependencies": {
21
24
  "tsup": "^8.0.0",
22
25
  "vitest": "^2.1.9",