@spree/sdk 0.6.7 → 0.6.9

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ErrorResponse, LoginCredentials, AuthTokens, RegisterParams, StoreStore, ProductListParams, PaginatedResponse, StoreProduct, ProductFiltersParams, ProductFiltersResponse, ListParams, StoreTaxonomy, TaxonListParams, StoreTaxon, StoreCountry, StoreCurrency, StoreLocale, StoreMarket, StoreOrder, CreateCartParams, UpdateOrderParams, AddLineItemParams, UpdateLineItemParams, StorePayment, StorePaymentMethod, CreatePaymentSessionParams, StorePaymentSession, UpdatePaymentSessionParams, CompletePaymentSessionParams, StoreShipment, StoreCustomer, StoreAddress, AddressParams, StoreCreditCard, StoreGiftCard, OrderListParams, CreatePaymentSetupSessionParams, StorePaymentSetupSession, CompletePaymentSetupSessionParams, StoreWishlist, StoreWishedItem } from './types/index.js';
2
- export { AdminCustomer, AdminLineItem, AdminMetafield, AdminOrder, AdminPrice, AdminProduct, AdminTaxon, AdminTaxonomy, AdminVariant, AvailabilityFilter, FilterOption, LocaleDefaults, OptionFilter, OptionFilterOption, PaginationMeta, PriceRangeFilter, ProductFilter, SortOption, StoreAsset, StoreBase, StoreCustomerReturn, StoreDigital, StoreDigitalLink, StoreExport, StoreGiftCardBatch, StoreImage, StoreImport, StoreImportRow, StoreInvitation, StoreLineItem, StoreMetafield, StoreNewsletterSubscriber, StoreOptionType, StoreOptionValue, StoreOrderPromotion, StorePaymentSource, StorePrice, StorePromotion, StoreRefund, StoreReimbursement, StoreReport, StoreReturnAuthorization, StoreReturnItem, StoreShippingMethod, StoreShippingRate, StoreState, StoreStockItem, StoreStockLocation, StoreStockMovement, StoreStockTransfer, StoreStoreCredit, StoreVariant, TaxonFilter, TaxonFilterOption } from './types/index.js';
1
+ import { ErrorResponse, LoginCredentials, AuthTokens, RegisterParams, ProductListParams, PaginatedResponse, StoreProduct, ProductFiltersParams, ProductFiltersResponse, ListParams, StoreTaxonomy, TaxonListParams, StoreTaxon, ListResponse, StoreCountry, StoreCurrency, StoreLocale, StoreMarket, StoreOrder, CreateCartParams, UpdateOrderParams, AddLineItemParams, UpdateLineItemParams, StorePayment, StorePaymentMethod, CreatePaymentSessionParams, StorePaymentSession, UpdatePaymentSessionParams, CompletePaymentSessionParams, StoreShipment, StoreCustomer, StoreAddress, AddressParams, StoreCreditCard, StoreGiftCard, OrderListParams, CreatePaymentSetupSessionParams, StorePaymentSetupSession, CompletePaymentSetupSessionParams, StoreWishlist, StoreWishedItem } from './types/index.js';
2
+ export { AdminCustomer, AdminLineItem, AdminMetafield, AdminOrder, AdminPrice, AdminProduct, AdminTaxon, AdminTaxonomy, AdminVariant, AvailabilityFilter, FilterOption, LineItemInput, LocaleDefaults, OptionFilter, OptionFilterOption, PaginationMeta, PriceRangeFilter, ProductFilter, SortOption, StoreAsset, StoreBase, StoreCustomerReturn, StoreDigital, StoreDigitalLink, StoreExport, StoreGiftCardBatch, StoreImage, StoreImport, StoreImportRow, StoreInvitation, StoreLineItem, StoreMetafield, StoreNewsletterSubscriber, StoreOptionType, StoreOptionValue, StoreOrderPromotion, StorePaymentSource, StorePrice, StorePromotion, StoreRefund, StoreReimbursement, StoreReport, StoreReturnAuthorization, StoreReturnItem, StoreShippingMethod, StoreShippingRate, StoreState, StoreStockItem, StoreStockLocation, StoreStockMovement, StoreStockTransfer, StoreStoreCredit, StoreVariant, TaxonFilter, TaxonFilterOption } from './types/index.js';
3
3
 
4
4
  interface RetryConfig {
5
5
  /** Maximum number of retries (default: 2) */
@@ -24,6 +24,8 @@ interface RequestOptions {
24
24
  currency?: string;
25
25
  /** Country ISO code for market resolution (e.g., 'US', 'DE') */
26
26
  country?: string;
27
+ /** Idempotency key for safe retries of mutating requests (max 255 characters) */
28
+ idempotencyKey?: string;
27
29
  /** Custom headers */
28
30
  headers?: Record<string, string>;
29
31
  }
@@ -56,12 +58,6 @@ declare class StoreClient {
56
58
  */
57
59
  refresh: (options: RequestOptions) => Promise<AuthTokens>;
58
60
  };
59
- readonly store: {
60
- /**
61
- * Get current store information
62
- */
63
- get: (options?: RequestOptions) => Promise<StoreStore>;
64
- };
65
61
  readonly products: {
66
62
  /**
67
63
  * List products
@@ -72,6 +68,7 @@ declare class StoreClient {
72
68
  */
73
69
  get: (idOrSlug: string, params?: {
74
70
  expand?: string[];
71
+ fields?: string[];
75
72
  }, options?: RequestOptions) => Promise<StoreProduct>;
76
73
  /**
77
74
  * Get available filters for products
@@ -89,6 +86,7 @@ declare class StoreClient {
89
86
  */
90
87
  get: (id: string, params?: {
91
88
  expand?: string[];
89
+ fields?: string[];
92
90
  }, options?: RequestOptions) => Promise<StoreTaxonomy>;
93
91
  };
94
92
  readonly taxons: {
@@ -101,6 +99,7 @@ declare class StoreClient {
101
99
  */
102
100
  get: (idOrPermalink: string, params?: {
103
101
  expand?: string[];
102
+ fields?: string[];
104
103
  }, options?: RequestOptions) => Promise<StoreTaxon>;
105
104
  /**
106
105
  * Nested resource: Products in a taxon
@@ -118,9 +117,7 @@ declare class StoreClient {
118
117
  * List countries available in the store
119
118
  * Each country includes currency and default_locale derived from its market
120
119
  */
121
- list: (options?: RequestOptions) => Promise<{
122
- data: StoreCountry[];
123
- }>;
120
+ list: (options?: RequestOptions) => Promise<ListResponse<StoreCountry>>;
124
121
  /**
125
122
  * Get a country by ISO code
126
123
  * Use `?expand=states` to expand states for address forms
@@ -128,31 +125,26 @@ declare class StoreClient {
128
125
  */
129
126
  get: (iso: string, params?: {
130
127
  expand?: string[];
128
+ fields?: string[];
131
129
  }, options?: RequestOptions) => Promise<StoreCountry>;
132
130
  };
133
131
  readonly currencies: {
134
132
  /**
135
133
  * List currencies supported by the store (derived from markets)
136
134
  */
137
- list: (options?: RequestOptions) => Promise<{
138
- data: StoreCurrency[];
139
- }>;
135
+ list: (options?: RequestOptions) => Promise<ListResponse<StoreCurrency>>;
140
136
  };
141
137
  readonly locales: {
142
138
  /**
143
139
  * List locales supported by the store (derived from markets)
144
140
  */
145
- list: (options?: RequestOptions) => Promise<{
146
- data: StoreLocale[];
147
- }>;
141
+ list: (options?: RequestOptions) => Promise<ListResponse<StoreLocale>>;
148
142
  };
149
143
  readonly markets: {
150
144
  /**
151
145
  * List all markets for the current store
152
146
  */
153
- list: (options?: RequestOptions) => Promise<{
154
- data: StoreMarket[];
155
- }>;
147
+ list: (options?: RequestOptions) => Promise<ListResponse<StoreMarket>>;
156
148
  /**
157
149
  * Get a market by prefixed ID
158
150
  * @param id - Market prefixed ID (e.g., "mkt_k5nR8xLq")
@@ -171,9 +163,7 @@ declare class StoreClient {
171
163
  * List countries belonging to a market
172
164
  * @param marketId - Market prefixed ID
173
165
  */
174
- list: (marketId: string, options?: RequestOptions) => Promise<{
175
- data: StoreCountry[];
176
- }>;
166
+ list: (marketId: string, options?: RequestOptions) => Promise<ListResponse<StoreCountry>>;
177
167
  /**
178
168
  * Get a country by ISO code within a market
179
169
  * @param marketId - Market prefixed ID
@@ -181,6 +171,7 @@ declare class StoreClient {
181
171
  */
182
172
  get: (marketId: string, iso: string, params?: {
183
173
  expand?: string[];
174
+ fields?: string[];
184
175
  }, options?: RequestOptions) => Promise<StoreCountry>;
185
176
  };
186
177
  };
@@ -214,6 +205,7 @@ declare class StoreClient {
214
205
  */
215
206
  get: (idOrNumber: string, params?: {
216
207
  expand?: string[];
208
+ fields?: string[];
217
209
  }, options?: RequestOptions) => Promise<StoreOrder>;
218
210
  /**
219
211
  * Update an order
@@ -266,10 +258,7 @@ declare class StoreClient {
266
258
  /**
267
259
  * List payments for an order
268
260
  */
269
- list: (orderId: string, options?: RequestOptions) => Promise<{
270
- data: StorePayment[];
271
- meta: object;
272
- }>;
261
+ list: (orderId: string, options?: RequestOptions) => Promise<PaginatedResponse<StorePayment>>;
273
262
  /**
274
263
  * Get a payment by ID
275
264
  */
@@ -282,7 +271,7 @@ declare class StoreClient {
282
271
  /**
283
272
  * List available payment methods for an order
284
273
  */
285
- list: (orderId: string, options?: RequestOptions) => Promise<PaginatedResponse<StorePaymentMethod>>;
274
+ list: (orderId: string, options?: RequestOptions) => Promise<ListResponse<StorePaymentMethod>>;
286
275
  };
287
276
  /**
288
277
  * Nested resource: Payment sessions
@@ -329,9 +318,7 @@ declare class StoreClient {
329
318
  /**
330
319
  * List shipments for an order
331
320
  */
332
- list: (orderId: string, options?: RequestOptions) => Promise<{
333
- data: StoreShipment[];
334
- }>;
321
+ list: (orderId: string, options?: RequestOptions) => Promise<ListResponse<StoreShipment>>;
335
322
  /**
336
323
  * Select a shipping rate for a shipment.
337
324
  * Returns the updated order with recalculated totals.
@@ -457,6 +444,7 @@ declare class StoreClient {
457
444
  */
458
445
  get: (id: string, params?: {
459
446
  expand?: string[];
447
+ fields?: string[];
460
448
  }, options?: RequestOptions) => Promise<StoreWishlist>;
461
449
  /**
462
450
  * Create a wishlist
@@ -512,8 +500,8 @@ declare class AdminClient {
512
500
  interface SpreeClientConfig {
513
501
  /** Base URL of the Spree API (e.g., 'https://api.mystore.com') */
514
502
  baseUrl: string;
515
- /** Publishable API key for Store API access */
516
- publishableKey: string;
503
+ /** Publishable API key for Store API access (required for Store API) */
504
+ publishableKey?: string;
517
505
  /** Secret API key for Admin API access (optional) */
518
506
  secretKey?: string;
519
507
  /** Custom fetch implementation (optional, defaults to global fetch) */
@@ -546,4 +534,4 @@ declare class SpreeClient {
546
534
  */
547
535
  declare function createSpreeClient(config: SpreeClientConfig): SpreeClient;
548
536
 
549
- export { AddLineItemParams, AddressParams, AdminClient, AuthTokens, CompletePaymentSessionParams, CompletePaymentSetupSessionParams, CreateCartParams, CreatePaymentSessionParams, CreatePaymentSetupSessionParams, ErrorResponse, ListParams, LoginCredentials, OrderListParams, PaginatedResponse, ProductFiltersParams, ProductFiltersResponse, ProductListParams, RegisterParams, type RequestOptions, type RetryConfig, SpreeClient, type SpreeClientConfig, SpreeError, StoreAddress, StoreClient, StoreCountry, StoreCreditCard, StoreCurrency, StoreCustomer, StoreGiftCard, StoreLocale, StoreMarket, StoreOrder, StorePayment, StorePaymentMethod, StorePaymentSession, StorePaymentSetupSession, StoreProduct, StoreShipment, StoreStore, StoreTaxon, StoreTaxonomy, StoreWishedItem, StoreWishlist, TaxonListParams, UpdateLineItemParams, UpdateOrderParams, UpdatePaymentSessionParams, createSpreeClient };
537
+ export { AddLineItemParams, AddressParams, AdminClient, AuthTokens, CompletePaymentSessionParams, CompletePaymentSetupSessionParams, CreateCartParams, CreatePaymentSessionParams, CreatePaymentSetupSessionParams, ErrorResponse, ListParams, ListResponse, LoginCredentials, OrderListParams, PaginatedResponse, ProductFiltersParams, ProductFiltersResponse, ProductListParams, RegisterParams, type RequestOptions, type RetryConfig, SpreeClient, type SpreeClientConfig, SpreeError, StoreAddress, StoreClient, StoreCountry, StoreCreditCard, StoreCurrency, StoreCustomer, StoreGiftCard, StoreLocale, StoreMarket, StoreOrder, StorePayment, StorePaymentMethod, StorePaymentSession, StorePaymentSetupSession, StoreProduct, StoreShipment, StoreTaxon, StoreTaxonomy, StoreWishedItem, StoreWishlist, TaxonListParams, UpdateLineItemParams, UpdateOrderParams, UpdatePaymentSessionParams, createSpreeClient };
package/dist/index.js CHANGED
@@ -19,20 +19,23 @@ function calculateDelay(attempt, config) {
19
19
  function sleep(ms) {
20
20
  return new Promise((resolve) => setTimeout(resolve, ms));
21
21
  }
22
- function shouldRetryOnStatus(method, status, config) {
23
- const isIdempotent = method === "GET" || method === "HEAD";
22
+ function generateIdempotencyKey() {
23
+ return `spree-sdk-retry-${crypto.randomUUID()}`;
24
+ }
25
+ function shouldRetryOnStatus(method, status, config, hasIdempotencyKey) {
26
+ const isIdempotent = method === "GET" || method === "HEAD" || hasIdempotencyKey;
24
27
  if (isIdempotent) {
25
28
  return config.retryOnStatus.includes(status);
26
29
  }
27
30
  return status === 429;
28
31
  }
29
- function shouldRetryOnNetworkError(method, config) {
32
+ function shouldRetryOnNetworkError(method, config, hasIdempotencyKey) {
30
33
  if (!config.retryOnNetworkError) return false;
31
- return method === "GET" || method === "HEAD";
34
+ return method === "GET" || method === "HEAD" || hasIdempotencyKey;
32
35
  }
33
36
  function createRequestFn(config, basePath, auth, defaults) {
34
37
  return async function request(method, path, options = {}) {
35
- const { token, orderToken, headers = {}, body, params } = options;
38
+ const { token, orderToken, idempotencyKey, headers = {}, body, params } = options;
36
39
  const locale = options.locale ?? defaults?.locale;
37
40
  const currency = options.currency ?? defaults?.currency;
38
41
  const country = options.country ?? defaults?.country;
@@ -48,14 +51,13 @@ function createRequestFn(config, basePath, auth, defaults) {
48
51
  }
49
52
  });
50
53
  }
51
- if (orderToken) {
52
- url.searchParams.set("order_token", orderToken);
53
- }
54
54
  const requestHeaders = {
55
55
  "Content-Type": "application/json",
56
- [auth.headerName]: auth.headerValue,
57
56
  ...headers
58
57
  };
58
+ if (auth.headerName && auth.headerValue) {
59
+ requestHeaders[auth.headerName] = auth.headerValue;
60
+ }
59
61
  if (token) {
60
62
  requestHeaders["Authorization"] = `Bearer ${token}`;
61
63
  }
@@ -71,6 +73,12 @@ function createRequestFn(config, basePath, auth, defaults) {
71
73
  if (country) {
72
74
  requestHeaders["x-spree-country"] = country;
73
75
  }
76
+ const isMutating = method !== "GET" && method !== "HEAD";
77
+ const effectiveIdempotencyKey = idempotencyKey ?? (isMutating && config.retryConfig ? generateIdempotencyKey() : void 0);
78
+ if (effectiveIdempotencyKey) {
79
+ requestHeaders["Idempotency-Key"] = effectiveIdempotencyKey;
80
+ }
81
+ const hasIdempotencyKey = !!effectiveIdempotencyKey;
74
82
  const maxAttempts = config.retryConfig ? config.retryConfig.maxRetries + 1 : 1;
75
83
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
76
84
  try {
@@ -81,7 +89,7 @@ function createRequestFn(config, basePath, auth, defaults) {
81
89
  });
82
90
  if (!response.ok) {
83
91
  const isLastAttempt = attempt >= maxAttempts - 1;
84
- if (!isLastAttempt && config.retryConfig && shouldRetryOnStatus(method, response.status, config.retryConfig)) {
92
+ if (!isLastAttempt && config.retryConfig && shouldRetryOnStatus(method, response.status, config.retryConfig, hasIdempotencyKey)) {
85
93
  const retryAfter = response.headers.get("Retry-After");
86
94
  const delay = retryAfter ? Math.min(parseInt(retryAfter, 10) * 1e3, config.retryConfig.maxDelay) : calculateDelay(attempt, config.retryConfig);
87
95
  await sleep(delay);
@@ -99,7 +107,7 @@ function createRequestFn(config, basePath, auth, defaults) {
99
107
  throw error;
100
108
  }
101
109
  const isLastAttempt = attempt >= maxAttempts - 1;
102
- if (!isLastAttempt && config.retryConfig && shouldRetryOnNetworkError(method, config.retryConfig)) {
110
+ if (!isLastAttempt && config.retryConfig && shouldRetryOnNetworkError(method, config.retryConfig, hasIdempotencyKey)) {
103
111
  const delay = calculateDelay(attempt, config.retryConfig);
104
112
  await sleep(delay);
105
113
  continue;
@@ -112,7 +120,7 @@ function createRequestFn(config, basePath, auth, defaults) {
112
120
  }
113
121
 
114
122
  // src/params.ts
115
- var PASSTHROUGH_KEYS = /* @__PURE__ */ new Set(["page", "limit", "expand", "sort"]);
123
+ var PASSTHROUGH_KEYS = /* @__PURE__ */ new Set(["page", "limit", "expand", "sort", "fields"]);
116
124
  function transformListParams(params) {
117
125
  const result = {};
118
126
  for (const [key, value] of Object.entries(params)) {
@@ -136,9 +144,12 @@ function transformListParams(params) {
136
144
  }
137
145
 
138
146
  // src/store-client.ts
139
- function expandParams(params) {
140
- if (!params?.expand?.length) return void 0;
141
- return { expand: params.expand.join(",") };
147
+ function getParams(params) {
148
+ if (!params) return void 0;
149
+ const result = {};
150
+ if (params.expand?.length) result.expand = params.expand.join(",");
151
+ if (params.fields?.length) result.fields = params.fields.join(",");
152
+ return Object.keys(result).length > 0 ? result : void 0;
142
153
  }
143
154
  var StoreClient = class {
144
155
  request;
@@ -163,15 +174,6 @@ var StoreClient = class {
163
174
  refresh: (options) => this.request("POST", "/auth/refresh", options)
164
175
  };
165
176
  // ============================================
166
- // Store
167
- // ============================================
168
- store = {
169
- /**
170
- * Get current store information
171
- */
172
- get: (options) => this.request("GET", "/store", options)
173
- };
174
- // ============================================
175
177
  // Products
176
178
  // ============================================
177
179
  products = {
@@ -180,14 +182,14 @@ var StoreClient = class {
180
182
  */
181
183
  list: (params, options) => this.request("GET", "/products", {
182
184
  ...options,
183
- params: params ? transformListParams(params) : void 0
185
+ params: transformListParams({ ...params })
184
186
  }),
185
187
  /**
186
188
  * Get a product by ID or slug
187
189
  */
188
190
  get: (idOrSlug, params, options) => this.request("GET", `/products/${idOrSlug}`, {
189
191
  ...options,
190
- params: expandParams(params)
192
+ params: getParams(params)
191
193
  }),
192
194
  /**
193
195
  * Get available filters for products
@@ -207,14 +209,14 @@ var StoreClient = class {
207
209
  */
208
210
  list: (params, options) => this.request("GET", "/taxonomies", {
209
211
  ...options,
210
- params
212
+ params: transformListParams({ ...params })
211
213
  }),
212
214
  /**
213
215
  * Get a taxonomy by ID
214
216
  */
215
217
  get: (id, params, options) => this.request("GET", `/taxonomies/${id}`, {
216
218
  ...options,
217
- params: expandParams(params)
219
+ params: getParams(params)
218
220
  })
219
221
  };
220
222
  taxons = {
@@ -223,14 +225,14 @@ var StoreClient = class {
223
225
  */
224
226
  list: (params, options) => this.request("GET", "/taxons", {
225
227
  ...options,
226
- params: params ? transformListParams(params) : void 0
228
+ params: transformListParams({ ...params })
227
229
  }),
228
230
  /**
229
231
  * Get a taxon by ID or permalink
230
232
  */
231
233
  get: (idOrPermalink, params, options) => this.request("GET", `/taxons/${idOrPermalink}`, {
232
234
  ...options,
233
- params: expandParams(params)
235
+ params: getParams(params)
234
236
  }),
235
237
  /**
236
238
  * Nested resource: Products in a taxon
@@ -245,7 +247,7 @@ var StoreClient = class {
245
247
  `/taxons/${taxonId}/products`,
246
248
  {
247
249
  ...options,
248
- params: params ? transformListParams(params) : void 0
250
+ params: transformListParams({ ...params })
249
251
  }
250
252
  )
251
253
  }
@@ -266,7 +268,7 @@ var StoreClient = class {
266
268
  */
267
269
  get: (iso, params, options) => this.request("GET", `/countries/${iso}`, {
268
270
  ...options,
269
- params: expandParams(params)
271
+ params: getParams(params)
270
272
  })
271
273
  };
272
274
  currencies = {
@@ -323,7 +325,7 @@ var StoreClient = class {
323
325
  get: (marketId, iso, params, options) => this.request(
324
326
  "GET",
325
327
  `/markets/${marketId}/countries/${iso}`,
326
- { ...options, params: expandParams(params) }
328
+ { ...options, params: getParams(params) }
327
329
  )
328
330
  }
329
331
  };
@@ -360,7 +362,7 @@ var StoreClient = class {
360
362
  */
361
363
  get: (idOrNumber, params, options) => this.request("GET", `/orders/${idOrNumber}`, {
362
364
  ...options,
363
- params: expandParams(params)
365
+ params: getParams(params)
364
366
  }),
365
367
  /**
366
368
  * Update an order
@@ -578,7 +580,7 @@ var StoreClient = class {
578
580
  list: (params, options) => this.request(
579
581
  "GET",
580
582
  "/customer/addresses",
581
- { ...options, params }
583
+ { ...options, params: transformListParams({ ...params }) }
582
584
  ),
583
585
  /**
584
586
  * Get an address by ID
@@ -620,7 +622,7 @@ var StoreClient = class {
620
622
  list: (params, options) => this.request(
621
623
  "GET",
622
624
  "/customer/credit_cards",
623
- { ...options, params }
625
+ { ...options, params: transformListParams({ ...params }) }
624
626
  ),
625
627
  /**
626
628
  * Get a credit card by ID
@@ -642,7 +644,7 @@ var StoreClient = class {
642
644
  list: (params, options) => this.request(
643
645
  "GET",
644
646
  "/customer/gift_cards",
645
- { ...options, params }
647
+ { ...options, params: transformListParams({ ...params }) }
646
648
  ),
647
649
  /**
648
650
  * Get a gift card by ID
@@ -658,7 +660,7 @@ var StoreClient = class {
658
660
  */
659
661
  list: (params, options) => this.request("GET", "/customer/orders", {
660
662
  ...options,
661
- params: params ? transformListParams(params) : void 0
663
+ params: transformListParams({ ...params })
662
664
  })
663
665
  },
664
666
  /**
@@ -698,14 +700,14 @@ var StoreClient = class {
698
700
  */
699
701
  list: (params, options) => this.request("GET", "/wishlists", {
700
702
  ...options,
701
- params
703
+ params: transformListParams({ ...params })
702
704
  }),
703
705
  /**
704
706
  * Get a wishlist by ID
705
707
  */
706
708
  get: (id, params, options) => this.request("GET", `/wishlists/${id}`, {
707
709
  ...options,
708
- params: expandParams(params)
710
+ params: getParams(params)
709
711
  }),
710
712
  /**
711
713
  * Create a wishlist
@@ -774,6 +776,9 @@ var SpreeClient = class {
774
776
  admin;
775
777
  _defaults;
776
778
  constructor(config) {
779
+ if (!config.publishableKey && !config.secretKey) {
780
+ throw new Error("SpreeClient requires at least one of publishableKey or secretKey");
781
+ }
777
782
  const baseUrl = config.baseUrl.replace(/\/$/, "");
778
783
  const fetchFn = config.fetch || fetch.bind(globalThis);
779
784
  this._defaults = {
@@ -797,7 +802,7 @@ var SpreeClient = class {
797
802
  const storeRequestFn = createRequestFn(
798
803
  requestConfig,
799
804
  "/api/v3/store",
800
- { headerName: "x-spree-api-key", headerValue: config.publishableKey },
805
+ config.publishableKey ? { headerName: "x-spree-api-key", headerValue: config.publishableKey } : { headerName: "", headerValue: "" },
801
806
  this._defaults
802
807
  );
803
808
  const adminRequestFn = createRequestFn(