@usethrottle/cart 2.0.0 → 3.0.1

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
@@ -74,7 +74,7 @@ External stores can also request read-only storefront quotes with a publishable
74
74
  import { StorefrontQuoteClient } from '@usethrottle/cart';
75
75
 
76
76
  const quotes = new StorefrontQuoteClient({
77
- storeId: 'store_uuid',
77
+ applicationId: 'application_uuid',
78
78
  quoteToken: 'pk_publishable_quote_token',
79
79
  });
80
80
 
@@ -170,14 +170,14 @@ try {
170
170
 
171
171
  ## Client options
172
172
 
173
- | Option | Default | Description |
174
- |---|---|---|
175
- | `apiKey` | — | **Required.** Your Throttle secret key (`sk_…`). |
176
- | `baseUrl` | `https://throttle-api-gff1.onrender.com` | Override for local dev or staging. |
177
- | `timeoutMs` | `30000` | Per-request abort timeout in ms. |
178
- | `fetch` | `globalThis.fetch` | Custom fetch implementation (e.g. `node-fetch`). |
173
+ | Option | Default | Description |
174
+ | ----------- | ----------------------------- | ----------------------------------------------------------- |
175
+ | `apiKey` | — | **Required.** Your Throttle secret key (`sk_…`). |
176
+ | `baseUrl` | `https://api.usethrottle.dev` | Optional override for a dedicated Throttle API environment. |
177
+ | `timeoutMs` | `30000` | Per-request abort timeout in ms. |
178
+ | `fetch` | `globalThis.fetch` | Custom fetch implementation (e.g. `node-fetch`). |
179
179
 
180
180
  ## See also
181
181
 
182
- - [API client (auto-generated): `@usethrottle/api-client`](https://www.npmjs.com/package/@usethrottle/api-client)
182
+ - [Checkout SDK: `@usethrottle/checkout-sdk`](https://www.npmjs.com/package/@usethrottle/checkout-sdk)
183
183
  - [React embed components: `@usethrottle/checkout-react`](https://www.npmjs.com/package/@usethrottle/checkout-react)
package/dist/index.cjs CHANGED
@@ -133,18 +133,19 @@ var CartClient = class {
133
133
 
134
134
  // src/storefront.ts
135
135
  var StorefrontQuoteClient = class {
136
- storeId;
136
+ applicationId;
137
137
  quoteToken;
138
138
  baseUrl;
139
139
  fetchImpl;
140
140
  timeoutMs;
141
141
  origin;
142
142
  constructor(opts) {
143
- if (!opts.storeId) throw new Error("StorefrontQuoteClient: storeId is required");
143
+ const applicationId = opts.applicationId ?? opts.storeId;
144
+ if (!applicationId) throw new Error("StorefrontQuoteClient: applicationId is required");
144
145
  if (!opts.quoteToken?.startsWith("pk_")) {
145
146
  throw new Error("StorefrontQuoteClient: quoteToken must be a publishable pk_ token");
146
147
  }
147
- this.storeId = opts.storeId;
148
+ this.applicationId = applicationId;
148
149
  this.quoteToken = opts.quoteToken;
149
150
  this.baseUrl = (opts.baseUrl ?? "https://api.usethrottle.dev").replace(/\/+$/, "");
150
151
  this.fetchImpl = opts.fetch ?? globalThis.fetch;
@@ -161,7 +162,7 @@ var StorefrontQuoteClient = class {
161
162
  method: "POST",
162
163
  headers,
163
164
  body: JSON.stringify({
164
- storeId: this.storeId,
165
+ applicationId: this.applicationId,
165
166
  quoteToken: this.quoteToken,
166
167
  ...input
167
168
  }),
package/dist/index.d.cts CHANGED
@@ -338,7 +338,10 @@ declare class CartClient {
338
338
  }
339
339
 
340
340
  interface StorefrontQuoteClientOptions {
341
- storeId: string;
341
+ /** Current API contract: the application/store UUID that owns the quote config. */
342
+ applicationId?: string;
343
+ /** @deprecated Use applicationId. Kept as an alias for older storefronts. */
344
+ storeId?: string;
342
345
  quoteToken: string;
343
346
  baseUrl?: string;
344
347
  fetch?: typeof globalThis.fetch;
@@ -346,7 +349,7 @@ interface StorefrontQuoteClientOptions {
346
349
  origin?: string;
347
350
  }
348
351
  declare class StorefrontQuoteClient {
349
- private readonly storeId;
352
+ private readonly applicationId;
350
353
  private readonly quoteToken;
351
354
  private readonly baseUrl;
352
355
  private readonly fetchImpl;
package/dist/index.d.ts CHANGED
@@ -338,7 +338,10 @@ declare class CartClient {
338
338
  }
339
339
 
340
340
  interface StorefrontQuoteClientOptions {
341
- storeId: string;
341
+ /** Current API contract: the application/store UUID that owns the quote config. */
342
+ applicationId?: string;
343
+ /** @deprecated Use applicationId. Kept as an alias for older storefronts. */
344
+ storeId?: string;
342
345
  quoteToken: string;
343
346
  baseUrl?: string;
344
347
  fetch?: typeof globalThis.fetch;
@@ -346,7 +349,7 @@ interface StorefrontQuoteClientOptions {
346
349
  origin?: string;
347
350
  }
348
351
  declare class StorefrontQuoteClient {
349
- private readonly storeId;
352
+ private readonly applicationId;
350
353
  private readonly quoteToken;
351
354
  private readonly baseUrl;
352
355
  private readonly fetchImpl;
package/dist/index.js CHANGED
@@ -105,18 +105,19 @@ var CartClient = class {
105
105
 
106
106
  // src/storefront.ts
107
107
  var StorefrontQuoteClient = class {
108
- storeId;
108
+ applicationId;
109
109
  quoteToken;
110
110
  baseUrl;
111
111
  fetchImpl;
112
112
  timeoutMs;
113
113
  origin;
114
114
  constructor(opts) {
115
- if (!opts.storeId) throw new Error("StorefrontQuoteClient: storeId is required");
115
+ const applicationId = opts.applicationId ?? opts.storeId;
116
+ if (!applicationId) throw new Error("StorefrontQuoteClient: applicationId is required");
116
117
  if (!opts.quoteToken?.startsWith("pk_")) {
117
118
  throw new Error("StorefrontQuoteClient: quoteToken must be a publishable pk_ token");
118
119
  }
119
- this.storeId = opts.storeId;
120
+ this.applicationId = applicationId;
120
121
  this.quoteToken = opts.quoteToken;
121
122
  this.baseUrl = (opts.baseUrl ?? "https://api.usethrottle.dev").replace(/\/+$/, "");
122
123
  this.fetchImpl = opts.fetch ?? globalThis.fetch;
@@ -133,7 +134,7 @@ var StorefrontQuoteClient = class {
133
134
  method: "POST",
134
135
  headers,
135
136
  body: JSON.stringify({
136
- storeId: this.storeId,
137
+ applicationId: this.applicationId,
137
138
  quoteToken: this.quoteToken,
138
139
  ...input
139
140
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/cart",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Typed REST client for the Throttle Cart API.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -13,12 +13,10 @@
13
13
  "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
- "files": ["dist", "README.md"],
17
- "scripts": {
18
- "build": "tsup",
19
- "test": "vitest run",
20
- "typecheck": "tsc --noEmit"
21
- },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
22
20
  "devDependencies": {
23
21
  "tsup": "^8.0.0",
24
22
  "vitest": "^2.1.9",
@@ -26,5 +24,10 @@
26
24
  },
27
25
  "publishConfig": {
28
26
  "access": "public"
27
+ },
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "test": "vitest run",
31
+ "typecheck": "tsc --noEmit"
29
32
  }
30
- }
33
+ }