@spree/sdk 0.1.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/dist/index.js ADDED
@@ -0,0 +1,530 @@
1
+ // src/client.ts
2
+ var SpreeError = class extends Error {
3
+ code;
4
+ status;
5
+ details;
6
+ constructor(response, status) {
7
+ super(response.error.message);
8
+ this.name = "SpreeError";
9
+ this.code = response.error.code;
10
+ this.status = status;
11
+ this.details = response.error.details;
12
+ }
13
+ };
14
+ var SpreeClient = class {
15
+ baseUrl;
16
+ apiKey;
17
+ fetchFn;
18
+ constructor(config) {
19
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
20
+ this.apiKey = config.apiKey;
21
+ this.fetchFn = config.fetch || fetch.bind(globalThis);
22
+ }
23
+ async request(method, path, options = {}) {
24
+ const { token, orderToken, locale, currency, headers = {}, body, params } = options;
25
+ const url = new URL(`${this.baseUrl}/api/v3/store${path}`);
26
+ if (params) {
27
+ Object.entries(params).forEach(([key, value]) => {
28
+ if (value !== void 0) {
29
+ if (Array.isArray(value)) {
30
+ value.forEach((v) => url.searchParams.append(key, String(v)));
31
+ } else {
32
+ url.searchParams.set(key, String(value));
33
+ }
34
+ }
35
+ });
36
+ }
37
+ if (orderToken) {
38
+ url.searchParams.set("order_token", orderToken);
39
+ }
40
+ const requestHeaders = {
41
+ "Content-Type": "application/json",
42
+ "x-spree-api-key": this.apiKey,
43
+ ...headers
44
+ };
45
+ if (token) {
46
+ requestHeaders["Authorization"] = `Bearer ${token}`;
47
+ }
48
+ if (orderToken) {
49
+ requestHeaders["x-spree-order-token"] = orderToken;
50
+ }
51
+ if (locale) {
52
+ requestHeaders["x-spree-locale"] = locale;
53
+ }
54
+ if (currency) {
55
+ requestHeaders["x-spree-currency"] = currency;
56
+ }
57
+ const response = await this.fetchFn(url.toString(), {
58
+ method,
59
+ headers: requestHeaders,
60
+ body: body ? JSON.stringify(body) : void 0
61
+ });
62
+ if (!response.ok) {
63
+ const errorBody = await response.json();
64
+ throw new SpreeError(errorBody, response.status);
65
+ }
66
+ if (response.status === 204) {
67
+ return void 0;
68
+ }
69
+ return response.json();
70
+ }
71
+ // ============================================
72
+ // Authentication
73
+ // ============================================
74
+ auth = {
75
+ /**
76
+ * Login with email and password
77
+ */
78
+ login: (credentials) => this.request("POST", "/auth/login", { body: credentials }),
79
+ /**
80
+ * Register a new customer account
81
+ */
82
+ register: (params) => this.request("POST", "/auth/register", { body: params }),
83
+ /**
84
+ * Refresh access token (requires valid Bearer token)
85
+ */
86
+ refresh: (options) => this.request("POST", "/auth/refresh", options)
87
+ };
88
+ // ============================================
89
+ // Store
90
+ // ============================================
91
+ store = {
92
+ /**
93
+ * Get current store information
94
+ */
95
+ get: (options) => this.request("GET", "/store", options)
96
+ };
97
+ // ============================================
98
+ // Products
99
+ // ============================================
100
+ products = {
101
+ /**
102
+ * List products
103
+ */
104
+ list: (params, options) => this.request("GET", "/products", {
105
+ ...options,
106
+ params
107
+ }),
108
+ /**
109
+ * Get a product by ID or slug
110
+ */
111
+ get: (idOrSlug, params, options) => this.request("GET", `/products/${idOrSlug}`, {
112
+ ...options,
113
+ params
114
+ }),
115
+ /**
116
+ * Get available filters for products
117
+ * Returns filter options (price range, availability, option types, taxons) with counts
118
+ */
119
+ filters: (params, options) => this.request("GET", "/products/filters", {
120
+ ...options,
121
+ params
122
+ })
123
+ };
124
+ // ============================================
125
+ // Taxonomies & Taxons
126
+ // ============================================
127
+ taxonomies = {
128
+ /**
129
+ * List taxonomies
130
+ */
131
+ list: (params, options) => this.request("GET", "/taxonomies", {
132
+ ...options,
133
+ params
134
+ }),
135
+ /**
136
+ * Get a taxonomy by ID
137
+ */
138
+ get: (id, params, options) => this.request("GET", `/taxonomies/${id}`, {
139
+ ...options,
140
+ params
141
+ })
142
+ };
143
+ taxons = {
144
+ /**
145
+ * List taxons
146
+ */
147
+ list: (params, options) => this.request("GET", "/taxons", {
148
+ ...options,
149
+ params
150
+ }),
151
+ /**
152
+ * Get a taxon by ID or permalink
153
+ */
154
+ get: (idOrPermalink, params, options) => this.request("GET", `/taxons/${idOrPermalink}`, {
155
+ ...options,
156
+ params
157
+ }),
158
+ /**
159
+ * Nested resource: Products in a taxon
160
+ */
161
+ products: {
162
+ /**
163
+ * List products in a taxon
164
+ * @param taxonId - Taxon ID (prefix_id) or permalink
165
+ */
166
+ list: (taxonId, params, options) => this.request(
167
+ "GET",
168
+ `/taxons/${taxonId}/products`,
169
+ {
170
+ ...options,
171
+ params
172
+ }
173
+ )
174
+ }
175
+ };
176
+ // ============================================
177
+ // Geography
178
+ // ============================================
179
+ countries = {
180
+ /**
181
+ * List countries available for checkout
182
+ * Returns countries from the store's checkout zone without states
183
+ */
184
+ list: (options) => this.request("GET", "/countries", options),
185
+ /**
186
+ * Get a country by ISO code with states
187
+ * @param iso - ISO 3166-1 alpha-2 code (e.g., "US", "DE")
188
+ */
189
+ get: (iso, options) => this.request("GET", `/countries/${iso}`, options)
190
+ };
191
+ // ============================================
192
+ // Cart (convenience wrapper for current incomplete order)
193
+ // ============================================
194
+ cart = {
195
+ /**
196
+ * Get current cart (returns null if none exists)
197
+ * Pass orderToken for guest checkout, or use JWT for authenticated users
198
+ */
199
+ get: (options) => this.request("GET", "/cart", options),
200
+ /**
201
+ * Create a new cart (alias for orders.create)
202
+ */
203
+ create: (options) => this.request("POST", "/orders", options),
204
+ /**
205
+ * Associate a guest cart with the currently authenticated user
206
+ * Requires both JWT token (for authentication) and orderToken (to identify the cart)
207
+ * @param options - Must include both `token` (JWT) and `orderToken` (guest cart token)
208
+ */
209
+ associate: (options) => this.request("PATCH", "/cart/associate", options)
210
+ };
211
+ // ============================================
212
+ // Orders (all orders - complete and incomplete)
213
+ // ============================================
214
+ orders = {
215
+ /**
216
+ * List orders for the authenticated customer
217
+ */
218
+ list: (params, options) => this.request("GET", "/orders", {
219
+ ...options,
220
+ params
221
+ }),
222
+ /**
223
+ * Create a new order (cart)
224
+ */
225
+ create: (options) => this.request("POST", "/orders", options),
226
+ /**
227
+ * Get an order by ID or number
228
+ */
229
+ get: (idOrNumber, params, options) => this.request("GET", `/orders/${idOrNumber}`, {
230
+ ...options,
231
+ params
232
+ }),
233
+ /**
234
+ * Update an order
235
+ */
236
+ update: (idOrNumber, params, options) => this.request("PATCH", `/orders/${idOrNumber}`, {
237
+ ...options,
238
+ body: params
239
+ }),
240
+ /**
241
+ * Advance order to next checkout step
242
+ */
243
+ next: (idOrNumber, options) => this.request("PATCH", `/orders/${idOrNumber}/next`, options),
244
+ /**
245
+ * Advance through all checkout steps
246
+ */
247
+ advance: (idOrNumber, options) => this.request("PATCH", `/orders/${idOrNumber}/advance`, options),
248
+ /**
249
+ * Complete the order
250
+ */
251
+ complete: (idOrNumber, options) => this.request("PATCH", `/orders/${idOrNumber}/complete`, options),
252
+ /**
253
+ * Add store credit to order
254
+ */
255
+ addStoreCredit: (idOrNumber, amount, options) => this.request("POST", `/orders/${idOrNumber}/store_credits`, {
256
+ ...options,
257
+ body: amount ? { amount } : void 0
258
+ }),
259
+ /**
260
+ * Remove store credit from order
261
+ */
262
+ removeStoreCredit: (idOrNumber, options) => this.request("DELETE", `/orders/${idOrNumber}/store_credits`, options),
263
+ /**
264
+ * Nested resource: Line items
265
+ */
266
+ lineItems: {
267
+ /**
268
+ * Add a line item to an order
269
+ */
270
+ create: (orderId, params, options) => this.request("POST", `/orders/${orderId}/line_items`, {
271
+ ...options,
272
+ body: params
273
+ }),
274
+ /**
275
+ * Update a line item
276
+ */
277
+ update: (orderId, lineItemId, params, options) => this.request(
278
+ "PATCH",
279
+ `/orders/${orderId}/line_items/${lineItemId}`,
280
+ { ...options, body: params }
281
+ ),
282
+ /**
283
+ * Remove a line item from an order
284
+ */
285
+ delete: (orderId, lineItemId, options) => this.request(
286
+ "DELETE",
287
+ `/orders/${orderId}/line_items/${lineItemId}`,
288
+ options
289
+ )
290
+ },
291
+ /**
292
+ * Nested resource: Payments
293
+ */
294
+ payments: {
295
+ /**
296
+ * List payments for an order
297
+ */
298
+ list: (orderId, options) => this.request(
299
+ "GET",
300
+ `/orders/${orderId}/payments`,
301
+ options
302
+ ),
303
+ /**
304
+ * Get a payment by ID
305
+ */
306
+ get: (orderId, paymentId, options) => this.request(
307
+ "GET",
308
+ `/orders/${orderId}/payments/${paymentId}`,
309
+ options
310
+ )
311
+ },
312
+ /**
313
+ * Nested resource: Payment methods
314
+ */
315
+ paymentMethods: {
316
+ /**
317
+ * List available payment methods for an order
318
+ */
319
+ list: (orderId, options) => this.request(
320
+ "GET",
321
+ `/orders/${orderId}/payment_methods`,
322
+ options
323
+ )
324
+ },
325
+ /**
326
+ * Nested resource: Coupon codes
327
+ */
328
+ couponCodes: {
329
+ /**
330
+ * Apply a coupon code to an order
331
+ */
332
+ apply: (orderId, code, options) => this.request("POST", `/orders/${orderId}/coupon_codes`, {
333
+ ...options,
334
+ body: { code }
335
+ }),
336
+ /**
337
+ * Remove a coupon code from an order
338
+ * @param promotionId - The promotion prefix_id (e.g., 'promo_xxx')
339
+ */
340
+ remove: (orderId, promotionId, options) => this.request(
341
+ "DELETE",
342
+ `/orders/${orderId}/coupon_codes/${promotionId}`,
343
+ options
344
+ )
345
+ },
346
+ /**
347
+ * Nested resource: Shipments
348
+ */
349
+ shipments: {
350
+ /**
351
+ * List shipments for an order
352
+ */
353
+ list: (orderId, options) => this.request(
354
+ "GET",
355
+ `/orders/${orderId}/shipments`,
356
+ options
357
+ ),
358
+ /**
359
+ * Update a shipment (e.g., select shipping rate)
360
+ */
361
+ update: (orderId, shipmentId, params, options) => this.request(
362
+ "PATCH",
363
+ `/orders/${orderId}/shipments/${shipmentId}`,
364
+ { ...options, body: params }
365
+ )
366
+ }
367
+ };
368
+ // ============================================
369
+ // Customer
370
+ // ============================================
371
+ customer = {
372
+ /**
373
+ * Get current customer profile
374
+ */
375
+ get: (options) => this.request("GET", "/customer", options),
376
+ /**
377
+ * Update current customer profile
378
+ */
379
+ update: (params, options) => this.request("PATCH", "/customer", {
380
+ ...options,
381
+ body: params
382
+ }),
383
+ /**
384
+ * Nested resource: Addresses
385
+ */
386
+ addresses: {
387
+ /**
388
+ * List customer addresses
389
+ */
390
+ list: (params, options) => this.request(
391
+ "GET",
392
+ "/customer/addresses",
393
+ { ...options, params }
394
+ ),
395
+ /**
396
+ * Get an address by ID
397
+ */
398
+ get: (id, options) => this.request("GET", `/customer/addresses/${id}`, options),
399
+ /**
400
+ * Create an address
401
+ */
402
+ create: (params, options) => this.request("POST", "/customer/addresses", {
403
+ ...options,
404
+ body: params
405
+ }),
406
+ /**
407
+ * Update an address
408
+ */
409
+ update: (id, params, options) => this.request("PATCH", `/customer/addresses/${id}`, {
410
+ ...options,
411
+ body: params
412
+ }),
413
+ /**
414
+ * Delete an address
415
+ */
416
+ delete: (id, options) => this.request("DELETE", `/customer/addresses/${id}`, options)
417
+ },
418
+ /**
419
+ * Nested resource: Credit Cards
420
+ */
421
+ creditCards: {
422
+ /**
423
+ * List customer credit cards
424
+ */
425
+ list: (params, options) => this.request(
426
+ "GET",
427
+ "/customer/credit_cards",
428
+ { ...options, params }
429
+ ),
430
+ /**
431
+ * Get a credit card by ID
432
+ */
433
+ get: (id, options) => this.request("GET", `/customer/credit_cards/${id}`, options),
434
+ /**
435
+ * Delete a credit card
436
+ */
437
+ delete: (id, options) => this.request("DELETE", `/customer/credit_cards/${id}`, options)
438
+ },
439
+ /**
440
+ * Nested resource: Gift Cards
441
+ */
442
+ giftCards: {
443
+ /**
444
+ * List customer gift cards
445
+ * Returns gift cards associated with the current user, ordered by newest first
446
+ */
447
+ list: (params, options) => this.request(
448
+ "GET",
449
+ "/customer/gift_cards",
450
+ { ...options, params }
451
+ ),
452
+ /**
453
+ * Get a gift card by ID
454
+ */
455
+ get: (id, options) => this.request("GET", `/customer/gift_cards/${id}`, options)
456
+ }
457
+ };
458
+ // ============================================
459
+ // Wishlists
460
+ // ============================================
461
+ wishlists = {
462
+ /**
463
+ * List wishlists
464
+ */
465
+ list: (params, options) => this.request("GET", "/wishlists", {
466
+ ...options,
467
+ params
468
+ }),
469
+ /**
470
+ * Get a wishlist by ID
471
+ */
472
+ get: (id, params, options) => this.request("GET", `/wishlists/${id}`, {
473
+ ...options,
474
+ params
475
+ }),
476
+ /**
477
+ * Create a wishlist
478
+ */
479
+ create: (params, options) => this.request("POST", "/wishlists", {
480
+ ...options,
481
+ body: params
482
+ }),
483
+ /**
484
+ * Update a wishlist
485
+ */
486
+ update: (id, params, options) => this.request("PATCH", `/wishlists/${id}`, {
487
+ ...options,
488
+ body: params
489
+ }),
490
+ /**
491
+ * Delete a wishlist
492
+ */
493
+ delete: (id, options) => this.request("DELETE", `/wishlists/${id}`, options),
494
+ /**
495
+ * Nested resource: Wishlist items
496
+ */
497
+ items: {
498
+ /**
499
+ * Add an item to a wishlist
500
+ */
501
+ create: (wishlistId, params, options) => this.request("POST", `/wishlists/${wishlistId}/items`, {
502
+ ...options,
503
+ body: params
504
+ }),
505
+ /**
506
+ * Update a wishlist item
507
+ */
508
+ update: (wishlistId, itemId, params, options) => this.request(
509
+ "PATCH",
510
+ `/wishlists/${wishlistId}/items/${itemId}`,
511
+ { ...options, body: params }
512
+ ),
513
+ /**
514
+ * Remove an item from a wishlist
515
+ */
516
+ delete: (wishlistId, itemId, options) => this.request(
517
+ "DELETE",
518
+ `/wishlists/${wishlistId}/items/${itemId}`,
519
+ options
520
+ )
521
+ }
522
+ };
523
+ };
524
+ function createSpreeClient(config) {
525
+ return new SpreeClient(config);
526
+ }
527
+
528
+ export { SpreeClient, SpreeError, createSpreeClient };
529
+ //# sourceMappingURL=index.js.map
530
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";AA2DO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpB,IAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EAEhB,WAAA,CAAY,UAAyB,MAAA,EAAgB;AACnD,IAAA,KAAA,CAAM,QAAA,CA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CAAA;AAC/B","file":"index.js","sourcesContent":["import type {\n AuthTokens,\n LoginCredentials,\n RegisterParams,\n ErrorResponse,\n PaginatedResponse,\n ListParams,\n ProductListParams,\n ProductFiltersParams,\n ProductFiltersResponse,\n TaxonListParams,\n OrderListParams,\n AddLineItemParams,\n UpdateLineItemParams,\n UpdateOrderParams,\n AddressParams,\n StoreCreditCard,\n StoreGiftCard,\n StoreProduct,\n StoreOrder,\n StoreLineItem,\n StoreCountry,\n StoreTaxonomy,\n StoreTaxon,\n StorePayment,\n StorePaymentMethod,\n StoreShipment,\n StoreStore,\n StoreWishlist,\n StoreWishedItem,\n StoreAddress,\n StoreUser,\n} from './types';\n\n// Re-export types for convenience\nexport type { AddressParams, StoreCreditCard };\n\nexport interface SpreeClientConfig {\n /** Base URL of the Spree API (e.g., 'https://api.mystore.com') */\n baseUrl: string;\n /** Publishable API key for store access */\n apiKey: string;\n /** Custom fetch implementation (optional, defaults to global fetch) */\n fetch?: typeof fetch;\n}\n\nexport interface RequestOptions {\n /** Bearer token for authenticated requests */\n token?: string;\n /** Order token for guest checkout */\n orderToken?: string;\n /** Locale for translated content (e.g., 'en', 'fr') */\n locale?: string;\n /** Currency for prices (e.g., 'USD', 'EUR') */\n currency?: string;\n /** Custom headers */\n headers?: Record<string, string>;\n}\n\nexport class SpreeError extends Error {\n public readonly code: string;\n public readonly status: number;\n public readonly details?: Record<string, string[]>;\n\n constructor(response: ErrorResponse, status: number) {\n super(response.error.message);\n this.name = 'SpreeError';\n this.code = response.error.code;\n this.status = status;\n this.details = response.error.details;\n }\n}\n\nexport class SpreeClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly fetchFn: typeof fetch;\n\n constructor(config: SpreeClientConfig) {\n this.baseUrl = config.baseUrl.replace(/\\/$/, '');\n this.apiKey = config.apiKey;\n // Bind fetch to globalThis to avoid \"Illegal invocation\" errors in browsers\n this.fetchFn = config.fetch || fetch.bind(globalThis);\n }\n\n private async request<T>(\n method: string,\n path: string,\n options: RequestOptions & {\n body?: unknown;\n params?: Record<string, string | number | undefined>;\n } = {}\n ): Promise<T> {\n const { token, orderToken, locale, currency, headers = {}, body, params } = options;\n\n // Build URL with query params\n const url = new URL(`${this.baseUrl}/api/v3/store${path}`);\n if (params) {\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n // Handle arrays by appending each value with the same key (Rails-style)\n if (Array.isArray(value)) {\n value.forEach((v) => url.searchParams.append(key, String(v)));\n } else {\n url.searchParams.set(key, String(value));\n }\n }\n });\n }\n if (orderToken) {\n url.searchParams.set('order_token', orderToken);\n }\n\n // Build headers\n const requestHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'x-spree-api-key': this.apiKey,\n ...headers,\n };\n\n if (token) {\n requestHeaders['Authorization'] = `Bearer ${token}`;\n }\n\n if (orderToken) {\n requestHeaders['x-spree-order-token'] = orderToken;\n }\n\n if (locale) {\n requestHeaders['x-spree-locale'] = locale;\n }\n\n if (currency) {\n requestHeaders['x-spree-currency'] = currency;\n }\n\n const response = await this.fetchFn(url.toString(), {\n method,\n headers: requestHeaders,\n body: body ? JSON.stringify(body) : undefined,\n });\n\n if (!response.ok) {\n const errorBody = await response.json() as ErrorResponse;\n throw new SpreeError(errorBody, response.status);\n }\n\n // Handle 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n return response.json() as Promise<T>;\n }\n\n // ============================================\n // Authentication\n // ============================================\n\n readonly auth = {\n /**\n * Login with email and password\n */\n login: (credentials: LoginCredentials): Promise<AuthTokens> =>\n this.request<AuthTokens>('POST', '/auth/login', { body: credentials }),\n\n /**\n * Register a new customer account\n */\n register: (params: RegisterParams): Promise<AuthTokens> =>\n this.request<AuthTokens>('POST', '/auth/register', { body: params }),\n\n /**\n * Refresh access token (requires valid Bearer token)\n */\n refresh: (options: RequestOptions): Promise<AuthTokens> =>\n this.request<AuthTokens>('POST', '/auth/refresh', options),\n };\n\n // ============================================\n // Store\n // ============================================\n\n readonly store = {\n /**\n * Get current store information\n */\n get: (options?: RequestOptions): Promise<StoreStore> =>\n this.request<StoreStore>('GET', '/store', options),\n };\n\n // ============================================\n // Products\n // ============================================\n\n readonly products = {\n /**\n * List products\n */\n list: (\n params?: ProductListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreProduct>> =>\n this.request<PaginatedResponse<StoreProduct>>('GET', '/products', {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }),\n\n /**\n * Get a product by ID or slug\n */\n get: (\n idOrSlug: string,\n params?: { includes?: string },\n options?: RequestOptions\n ): Promise<StoreProduct> =>\n this.request<StoreProduct>('GET', `/products/${idOrSlug}`, {\n ...options,\n params,\n }),\n\n /**\n * Get available filters for products\n * Returns filter options (price range, availability, option types, taxons) with counts\n */\n filters: (\n params?: ProductFiltersParams,\n options?: RequestOptions\n ): Promise<ProductFiltersResponse> =>\n this.request<ProductFiltersResponse>('GET', '/products/filters', {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }),\n };\n\n // ============================================\n // Taxonomies & Taxons\n // ============================================\n\n readonly taxonomies = {\n /**\n * List taxonomies\n */\n list: (\n params?: ListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreTaxonomy>> =>\n this.request<PaginatedResponse<StoreTaxonomy>>('GET', '/taxonomies', {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }),\n\n /**\n * Get a taxonomy by ID\n */\n get: (\n id: string,\n params?: { includes?: string },\n options?: RequestOptions\n ): Promise<StoreTaxonomy> =>\n this.request<StoreTaxonomy>('GET', `/taxonomies/${id}`, {\n ...options,\n params,\n }),\n };\n\n readonly taxons = {\n /**\n * List taxons\n */\n list: (\n params?: TaxonListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreTaxon>> =>\n this.request<PaginatedResponse<StoreTaxon>>('GET', '/taxons', {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }),\n\n /**\n * Get a taxon by ID or permalink\n */\n get: (\n idOrPermalink: string,\n params?: { includes?: string },\n options?: RequestOptions\n ): Promise<StoreTaxon> =>\n this.request<StoreTaxon>('GET', `/taxons/${idOrPermalink}`, {\n ...options,\n params,\n }),\n\n /**\n * Nested resource: Products in a taxon\n */\n products: {\n /**\n * List products in a taxon\n * @param taxonId - Taxon ID (prefix_id) or permalink\n */\n list: (\n taxonId: string,\n params?: ProductListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreProduct>> =>\n this.request<PaginatedResponse<StoreProduct>>(\n 'GET',\n `/taxons/${taxonId}/products`,\n {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }\n ),\n },\n };\n\n // ============================================\n // Geography\n // ============================================\n\n readonly countries = {\n /**\n * List countries available for checkout\n * Returns countries from the store's checkout zone without states\n */\n list: (options?: RequestOptions): Promise<{ data: StoreCountry[] }> =>\n this.request<{ data: StoreCountry[] }>('GET', '/countries', options),\n\n /**\n * Get a country by ISO code with states\n * @param iso - ISO 3166-1 alpha-2 code (e.g., \"US\", \"DE\")\n */\n get: (iso: string, options?: RequestOptions): Promise<StoreCountry> =>\n this.request<StoreCountry>('GET', `/countries/${iso}`, options),\n };\n\n // ============================================\n // Cart (convenience wrapper for current incomplete order)\n // ============================================\n\n readonly cart = {\n /**\n * Get current cart (returns null if none exists)\n * Pass orderToken for guest checkout, or use JWT for authenticated users\n */\n get: (options?: RequestOptions): Promise<StoreOrder & { token: string }> =>\n this.request<StoreOrder & { token: string }>('GET', '/cart', options),\n\n /**\n * Create a new cart (alias for orders.create)\n */\n create: (options?: RequestOptions): Promise<StoreOrder & { token: string }> =>\n this.request<StoreOrder & { token: string }>('POST', '/orders', options),\n\n /**\n * Associate a guest cart with the currently authenticated user\n * Requires both JWT token (for authentication) and orderToken (to identify the cart)\n * @param options - Must include both `token` (JWT) and `orderToken` (guest cart token)\n */\n associate: (options: RequestOptions): Promise<StoreOrder & { token: string }> =>\n this.request<StoreOrder & { token: string }>('PATCH', '/cart/associate', options),\n };\n\n // ============================================\n // Orders (all orders - complete and incomplete)\n // ============================================\n\n readonly orders = {\n /**\n * List orders for the authenticated customer\n */\n list: (\n params?: OrderListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreOrder>> =>\n this.request<PaginatedResponse<StoreOrder>>('GET', '/orders', {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }),\n\n /**\n * Create a new order (cart)\n */\n create: (options?: RequestOptions): Promise<StoreOrder & { order_token: string }> =>\n this.request<StoreOrder & { order_token: string }>('POST', '/orders', options),\n\n /**\n * Get an order by ID or number\n */\n get: (\n idOrNumber: string,\n params?: { includes?: string },\n options?: RequestOptions\n ): Promise<StoreOrder> =>\n this.request<StoreOrder>('GET', `/orders/${idOrNumber}`, {\n ...options,\n params,\n }),\n\n /**\n * Update an order\n */\n update: (\n idOrNumber: string,\n params: UpdateOrderParams,\n options?: RequestOptions\n ): Promise<StoreOrder> =>\n this.request<StoreOrder>('PATCH', `/orders/${idOrNumber}`, {\n ...options,\n body: params,\n }),\n\n /**\n * Advance order to next checkout step\n */\n next: (idOrNumber: string, options?: RequestOptions): Promise<StoreOrder> =>\n this.request<StoreOrder>('PATCH', `/orders/${idOrNumber}/next`, options),\n\n /**\n * Advance through all checkout steps\n */\n advance: (idOrNumber: string, options?: RequestOptions): Promise<StoreOrder> =>\n this.request<StoreOrder>('PATCH', `/orders/${idOrNumber}/advance`, options),\n\n /**\n * Complete the order\n */\n complete: (idOrNumber: string, options?: RequestOptions): Promise<StoreOrder> =>\n this.request<StoreOrder>('PATCH', `/orders/${idOrNumber}/complete`, options),\n\n /**\n * Add store credit to order\n */\n addStoreCredit: (\n idOrNumber: string,\n amount?: number,\n options?: RequestOptions\n ): Promise<StoreOrder> =>\n this.request<StoreOrder>('POST', `/orders/${idOrNumber}/store_credits`, {\n ...options,\n body: amount ? { amount } : undefined,\n }),\n\n /**\n * Remove store credit from order\n */\n removeStoreCredit: (\n idOrNumber: string,\n options?: RequestOptions\n ): Promise<StoreOrder> =>\n this.request<StoreOrder>('DELETE', `/orders/${idOrNumber}/store_credits`, options),\n\n /**\n * Nested resource: Line items\n */\n lineItems: {\n /**\n * Add a line item to an order\n */\n create: (\n orderId: string,\n params: AddLineItemParams,\n options?: RequestOptions\n ): Promise<StoreLineItem> =>\n this.request<StoreLineItem>('POST', `/orders/${orderId}/line_items`, {\n ...options,\n body: params,\n }),\n\n /**\n * Update a line item\n */\n update: (\n orderId: string,\n lineItemId: string,\n params: UpdateLineItemParams,\n options?: RequestOptions\n ): Promise<StoreLineItem> =>\n this.request<StoreLineItem>(\n 'PATCH',\n `/orders/${orderId}/line_items/${lineItemId}`,\n { ...options, body: params }\n ),\n\n /**\n * Remove a line item from an order\n */\n delete: (\n orderId: string,\n lineItemId: string,\n options?: RequestOptions\n ): Promise<void> =>\n this.request<void>(\n 'DELETE',\n `/orders/${orderId}/line_items/${lineItemId}`,\n options\n ),\n },\n\n /**\n * Nested resource: Payments\n */\n payments: {\n /**\n * List payments for an order\n */\n list: (\n orderId: string,\n options?: RequestOptions\n ): Promise<{ data: StorePayment[]; meta: object }> =>\n this.request<{ data: StorePayment[]; meta: object }>(\n 'GET',\n `/orders/${orderId}/payments`,\n options\n ),\n\n /**\n * Get a payment by ID\n */\n get: (\n orderId: string,\n paymentId: string,\n options?: RequestOptions\n ): Promise<StorePayment> =>\n this.request<StorePayment>(\n 'GET',\n `/orders/${orderId}/payments/${paymentId}`,\n options\n ),\n },\n\n /**\n * Nested resource: Payment methods\n */\n paymentMethods: {\n /**\n * List available payment methods for an order\n */\n list: (\n orderId: string,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StorePaymentMethod>> =>\n this.request<PaginatedResponse<StorePaymentMethod>>(\n 'GET',\n `/orders/${orderId}/payment_methods`,\n options\n ),\n },\n\n /**\n * Nested resource: Coupon codes\n */\n couponCodes: {\n /**\n * Apply a coupon code to an order\n */\n apply: (\n orderId: string,\n code: string,\n options?: RequestOptions\n ): Promise<StoreOrder> =>\n this.request<StoreOrder>('POST', `/orders/${orderId}/coupon_codes`, {\n ...options,\n body: { code },\n }),\n\n /**\n * Remove a coupon code from an order\n * @param promotionId - The promotion prefix_id (e.g., 'promo_xxx')\n */\n remove: (\n orderId: string,\n promotionId: string,\n options?: RequestOptions\n ): Promise<StoreOrder> =>\n this.request<StoreOrder>(\n 'DELETE',\n `/orders/${orderId}/coupon_codes/${promotionId}`,\n options\n ),\n },\n\n /**\n * Nested resource: Shipments\n */\n shipments: {\n /**\n * List shipments for an order\n */\n list: (\n orderId: string,\n options?: RequestOptions\n ): Promise<{ data: StoreShipment[] }> =>\n this.request<{ data: StoreShipment[] }>(\n 'GET',\n `/orders/${orderId}/shipments`,\n options\n ),\n\n /**\n * Update a shipment (e.g., select shipping rate)\n */\n update: (\n orderId: string,\n shipmentId: string,\n params: { selected_shipping_rate_id: string },\n options?: RequestOptions\n ): Promise<StoreShipment> =>\n this.request<StoreShipment>(\n 'PATCH',\n `/orders/${orderId}/shipments/${shipmentId}`,\n { ...options, body: params }\n ),\n },\n };\n\n // ============================================\n // Customer\n // ============================================\n\n readonly customer = {\n /**\n * Get current customer profile\n */\n get: (options?: RequestOptions): Promise<StoreUser> =>\n this.request<StoreUser>('GET', '/customer', options),\n\n /**\n * Update current customer profile\n */\n update: (\n params: { first_name?: string; last_name?: string; email?: string },\n options?: RequestOptions\n ): Promise<StoreUser> =>\n this.request<StoreUser>('PATCH', '/customer', {\n ...options,\n body: params,\n }),\n\n /**\n * Nested resource: Addresses\n */\n addresses: {\n /**\n * List customer addresses\n */\n list: (\n params?: ListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreAddress>> =>\n this.request<PaginatedResponse<StoreAddress>>(\n 'GET',\n '/customer/addresses',\n { ...options, params: params as Record<string, string | number | undefined> }\n ),\n\n /**\n * Get an address by ID\n */\n get: (id: string, options?: RequestOptions): Promise<StoreAddress> =>\n this.request<StoreAddress>('GET', `/customer/addresses/${id}`, options),\n\n /**\n * Create an address\n */\n create: (\n params: AddressParams,\n options?: RequestOptions\n ): Promise<StoreAddress> =>\n this.request<StoreAddress>('POST', '/customer/addresses', {\n ...options,\n body: params,\n }),\n\n /**\n * Update an address\n */\n update: (\n id: string,\n params: Partial<AddressParams>,\n options?: RequestOptions\n ): Promise<StoreAddress> =>\n this.request<StoreAddress>('PATCH', `/customer/addresses/${id}`, {\n ...options,\n body: params,\n }),\n\n /**\n * Delete an address\n */\n delete: (id: string, options?: RequestOptions): Promise<void> =>\n this.request<void>('DELETE', `/customer/addresses/${id}`, options),\n },\n\n /**\n * Nested resource: Credit Cards\n */\n creditCards: {\n /**\n * List customer credit cards\n */\n list: (\n params?: ListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreCreditCard>> =>\n this.request<PaginatedResponse<StoreCreditCard>>(\n 'GET',\n '/customer/credit_cards',\n { ...options, params: params as Record<string, string | number | undefined> }\n ),\n\n /**\n * Get a credit card by ID\n */\n get: (id: string, options?: RequestOptions): Promise<StoreCreditCard> =>\n this.request<StoreCreditCard>('GET', `/customer/credit_cards/${id}`, options),\n\n /**\n * Delete a credit card\n */\n delete: (id: string, options?: RequestOptions): Promise<void> =>\n this.request<void>('DELETE', `/customer/credit_cards/${id}`, options),\n },\n\n /**\n * Nested resource: Gift Cards\n */\n giftCards: {\n /**\n * List customer gift cards\n * Returns gift cards associated with the current user, ordered by newest first\n */\n list: (\n params?: ListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreGiftCard>> =>\n this.request<PaginatedResponse<StoreGiftCard>>(\n 'GET',\n '/customer/gift_cards',\n { ...options, params: params as Record<string, string | number | undefined> }\n ),\n\n /**\n * Get a gift card by ID\n */\n get: (id: string, options?: RequestOptions): Promise<StoreGiftCard> =>\n this.request<StoreGiftCard>('GET', `/customer/gift_cards/${id}`, options),\n },\n };\n\n // ============================================\n // Wishlists\n // ============================================\n\n readonly wishlists = {\n /**\n * List wishlists\n */\n list: (\n params?: ListParams,\n options?: RequestOptions\n ): Promise<PaginatedResponse<StoreWishlist>> =>\n this.request<PaginatedResponse<StoreWishlist>>('GET', '/wishlists', {\n ...options,\n params: params as Record<string, string | number | undefined>,\n }),\n\n /**\n * Get a wishlist by ID\n */\n get: (\n id: string,\n params?: { includes?: string },\n options?: RequestOptions\n ): Promise<StoreWishlist> =>\n this.request<StoreWishlist>('GET', `/wishlists/${id}`, {\n ...options,\n params,\n }),\n\n /**\n * Create a wishlist\n */\n create: (\n params: { name: string; is_private?: boolean; is_default?: boolean },\n options?: RequestOptions\n ): Promise<StoreWishlist> =>\n this.request<StoreWishlist>('POST', '/wishlists', {\n ...options,\n body: params,\n }),\n\n /**\n * Update a wishlist\n */\n update: (\n id: string,\n params: { name?: string; is_private?: boolean; is_default?: boolean },\n options?: RequestOptions\n ): Promise<StoreWishlist> =>\n this.request<StoreWishlist>('PATCH', `/wishlists/${id}`, {\n ...options,\n body: params,\n }),\n\n /**\n * Delete a wishlist\n */\n delete: (id: string, options?: RequestOptions): Promise<void> =>\n this.request<void>('DELETE', `/wishlists/${id}`, options),\n\n /**\n * Nested resource: Wishlist items\n */\n items: {\n /**\n * Add an item to a wishlist\n */\n create: (\n wishlistId: string,\n params: { variant_id: string; quantity?: number },\n options?: RequestOptions\n ): Promise<StoreWishedItem> =>\n this.request<StoreWishedItem>('POST', `/wishlists/${wishlistId}/items`, {\n ...options,\n body: params,\n }),\n\n /**\n * Update a wishlist item\n */\n update: (\n wishlistId: string,\n itemId: string,\n params: { quantity: number },\n options?: RequestOptions\n ): Promise<StoreWishedItem> =>\n this.request<StoreWishedItem>(\n 'PATCH',\n `/wishlists/${wishlistId}/items/${itemId}`,\n { ...options, body: params }\n ),\n\n /**\n * Remove an item from a wishlist\n */\n delete: (\n wishlistId: string,\n itemId: string,\n options?: RequestOptions\n ): Promise<void> =>\n this.request<void>(\n 'DELETE',\n `/wishlists/${wishlistId}/items/${itemId}`,\n options\n ),\n },\n };\n}\n\n/**\n * Create a new Spree SDK client\n */\nexport function createSpreeClient(config: SpreeClientConfig): SpreeClient {\n return new SpreeClient(config);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}