@spree/sdk 0.6.9 → 0.7.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 +118 -120
- package/dist/index-CgJG4R8P.d.cts +989 -0
- package/dist/index-CgJG4R8P.d.ts +989 -0
- package/dist/index.cjs +43 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -124
- package/dist/index.d.ts +78 -124
- package/dist/index.js +43 -80
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +1 -1181
- package/dist/types/index.d.ts +1 -1181
- package/dist/zod/index.cjs +310 -551
- package/dist/zod/index.cjs.map +1 -1
- package/dist/zod/index.d.cts +119 -713
- package/dist/zod/index.d.ts +119 -713
- package/dist/zod/index.js +256 -490
- package/dist/zod/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,45 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
interface RetryConfig {
|
|
5
|
-
/** Maximum number of retries (default: 2) */
|
|
6
|
-
maxRetries?: number;
|
|
7
|
-
/** HTTP status codes to retry on (default: [429, 500, 502, 503, 504]) */
|
|
8
|
-
retryOnStatus?: number[];
|
|
9
|
-
/** Base delay in ms for exponential backoff (default: 300) */
|
|
10
|
-
baseDelay?: number;
|
|
11
|
-
/** Maximum delay in ms (default: 10000) */
|
|
12
|
-
maxDelay?: number;
|
|
13
|
-
/** Whether to retry on network errors (default: true) */
|
|
14
|
-
retryOnNetworkError?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface RequestOptions {
|
|
17
|
-
/** Bearer token for authenticated requests */
|
|
18
|
-
token?: string;
|
|
19
|
-
/** Order token for guest checkout */
|
|
20
|
-
orderToken?: string;
|
|
21
|
-
/** Locale for translated content (e.g., 'en', 'fr') */
|
|
22
|
-
locale?: string;
|
|
23
|
-
/** Currency for prices (e.g., 'USD', 'EUR') */
|
|
24
|
-
currency?: string;
|
|
25
|
-
/** Country ISO code for market resolution (e.g., 'US', 'DE') */
|
|
26
|
-
country?: string;
|
|
27
|
-
/** Idempotency key for safe retries of mutating requests (max 255 characters) */
|
|
28
|
-
idempotencyKey?: string;
|
|
29
|
-
/** Custom headers */
|
|
30
|
-
headers?: Record<string, string>;
|
|
31
|
-
}
|
|
32
|
-
interface InternalRequestOptions extends RequestOptions {
|
|
33
|
-
body?: unknown;
|
|
34
|
-
params?: Record<string, string | number | boolean | (string | number)[] | undefined>;
|
|
35
|
-
}
|
|
36
|
-
declare class SpreeError extends Error {
|
|
37
|
-
readonly code: string;
|
|
38
|
-
readonly status: number;
|
|
39
|
-
readonly details?: Record<string, string[]>;
|
|
40
|
-
constructor(response: ErrorResponse, status: number);
|
|
41
|
-
}
|
|
42
|
-
type RequestFn = <T>(method: string, path: string, options?: InternalRequestOptions) => Promise<T>;
|
|
1
|
+
import { R as RequestFn, L as LoginCredentials, A as AuthTokens, a as RegisterParams, b as RequestOptions, P as ProductListParams, c as PaginatedResponse, d as Product, e as ProductFiltersParams, f as ProductFiltersResponse, g as ListParams, T as Taxonomy, h as TaxonListParams, i as Taxon, j as ListResponse, C as Country, k as Currency, l as Locale, M as Market, O as Order, m as CreateCartParams, U as UpdateOrderParams, n as AddLineItemParams, o as UpdateLineItemParams, p as Payment, q as PaymentMethod, r as CreatePaymentSessionParams, s as PaymentSession, t as UpdatePaymentSessionParams, u as CompletePaymentSessionParams, S as Shipment, v as Customer, w as Address, x as AddressParams, y as CreditCard, G as GiftCard, z as OrderListParams, B as CreatePaymentSetupSessionParams, D as PaymentSetupSession, E as CompletePaymentSetupSessionParams, W as Wishlist, F as WishedItem, H as RetryConfig } from './index-CgJG4R8P.cjs';
|
|
2
|
+
export { I as Asset, J as AvailabilityFilter, K as Base, N as CustomerReturn, Q as Digital, V as DigitalLink, X as ErrorResponse, Y as Export, Z as FilterOption, _ as GiftCardBatch, $ as Image, a0 as Import, a1 as ImportRow, a2 as Invitation, a3 as LineItem, a4 as LineItemInput, a5 as LocaleDefaults, a6 as Metafield, a7 as NewsletterSubscriber, a8 as OptionFilter, a9 as OptionFilterOption, aa as OptionType, ab as OptionValue, ac as OrderPromotion, ad as PaginationMeta, ae as PaymentSource, af as Price, ag as PriceRangeFilter, ah as ProductFilter, ai as Promotion, aj as Refund, ak as Reimbursement, al as Report, am as ReturnAuthorization, an as ReturnItem, ao as ShippingCategory, ap as ShippingMethod, aq as ShippingRate, ar as SortOption, as as SpreeError, at as State, au as StockItem, av as StockLocation, aw as StockMovement, ax as StockTransfer, I as StoreAsset, ay as StoreCredit, N as StoreCustomerReturn, Q as StoreDigital, V as StoreDigitalLink, _ as StoreGiftCardBatch, $ as StoreImage, a3 as StoreLineItem, a6 as StoreMetafield, aa as StoreOptionType, ab as StoreOptionValue, ac as StoreOrderPromotion, ae as StorePaymentSource, af as StorePrice, ai as StorePromotion, aj as StoreRefund, ak as StoreReimbursement, am as StoreReturnAuthorization, an as StoreReturnItem, ao as StoreShippingCategory, ap as StoreShippingMethod, aq as StoreShippingRate, at as StoreState, au as StoreStockItem, av as StoreStockLocation, ay as StoreStoreCredit, az as StoreTaxCategory, aA as StoreVariant, az as TaxCategory, aB as TaxonFilter, aC as TaxonFilterOption, aA as Variant } from './index-CgJG4R8P.cjs';
|
|
43
3
|
|
|
44
4
|
declare class StoreClient {
|
|
45
5
|
private readonly request;
|
|
@@ -62,14 +22,14 @@ declare class StoreClient {
|
|
|
62
22
|
/**
|
|
63
23
|
* List products
|
|
64
24
|
*/
|
|
65
|
-
list: (params?: ProductListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
25
|
+
list: (params?: ProductListParams, options?: RequestOptions) => Promise<PaginatedResponse<Product>>;
|
|
66
26
|
/**
|
|
67
27
|
* Get a product by ID or slug
|
|
68
28
|
*/
|
|
69
29
|
get: (idOrSlug: string, params?: {
|
|
70
30
|
expand?: string[];
|
|
71
31
|
fields?: string[];
|
|
72
|
-
}, options?: RequestOptions) => Promise<
|
|
32
|
+
}, options?: RequestOptions) => Promise<Product>;
|
|
73
33
|
/**
|
|
74
34
|
* Get available filters for products
|
|
75
35
|
* Returns filter options (price range, availability, option types, taxons) with counts
|
|
@@ -80,27 +40,27 @@ declare class StoreClient {
|
|
|
80
40
|
/**
|
|
81
41
|
* List taxonomies
|
|
82
42
|
*/
|
|
83
|
-
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
43
|
+
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<Taxonomy>>;
|
|
84
44
|
/**
|
|
85
45
|
* Get a taxonomy by ID
|
|
86
46
|
*/
|
|
87
47
|
get: (id: string, params?: {
|
|
88
48
|
expand?: string[];
|
|
89
49
|
fields?: string[];
|
|
90
|
-
}, options?: RequestOptions) => Promise<
|
|
50
|
+
}, options?: RequestOptions) => Promise<Taxonomy>;
|
|
91
51
|
};
|
|
92
52
|
readonly taxons: {
|
|
93
53
|
/**
|
|
94
54
|
* List taxons
|
|
95
55
|
*/
|
|
96
|
-
list: (params?: TaxonListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
56
|
+
list: (params?: TaxonListParams, options?: RequestOptions) => Promise<PaginatedResponse<Taxon>>;
|
|
97
57
|
/**
|
|
98
58
|
* Get a taxon by ID or permalink
|
|
99
59
|
*/
|
|
100
60
|
get: (idOrPermalink: string, params?: {
|
|
101
61
|
expand?: string[];
|
|
102
62
|
fields?: string[];
|
|
103
|
-
}, options?: RequestOptions) => Promise<
|
|
63
|
+
}, options?: RequestOptions) => Promise<Taxon>;
|
|
104
64
|
/**
|
|
105
65
|
* Nested resource: Products in a taxon
|
|
106
66
|
*/
|
|
@@ -109,7 +69,7 @@ declare class StoreClient {
|
|
|
109
69
|
* List products in a taxon
|
|
110
70
|
* @param taxonId - Taxon ID (prefix_id) or permalink
|
|
111
71
|
*/
|
|
112
|
-
list: (taxonId: string, params?: ProductListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
72
|
+
list: (taxonId: string, params?: ProductListParams, options?: RequestOptions) => Promise<PaginatedResponse<Product>>;
|
|
113
73
|
};
|
|
114
74
|
};
|
|
115
75
|
readonly countries: {
|
|
@@ -117,7 +77,7 @@ declare class StoreClient {
|
|
|
117
77
|
* List countries available in the store
|
|
118
78
|
* Each country includes currency and default_locale derived from its market
|
|
119
79
|
*/
|
|
120
|
-
list: (options?: RequestOptions) => Promise<ListResponse<
|
|
80
|
+
list: (options?: RequestOptions) => Promise<ListResponse<Country>>;
|
|
121
81
|
/**
|
|
122
82
|
* Get a country by ISO code
|
|
123
83
|
* Use `?expand=states` to expand states for address forms
|
|
@@ -126,35 +86,35 @@ declare class StoreClient {
|
|
|
126
86
|
get: (iso: string, params?: {
|
|
127
87
|
expand?: string[];
|
|
128
88
|
fields?: string[];
|
|
129
|
-
}, options?: RequestOptions) => Promise<
|
|
89
|
+
}, options?: RequestOptions) => Promise<Country>;
|
|
130
90
|
};
|
|
131
91
|
readonly currencies: {
|
|
132
92
|
/**
|
|
133
93
|
* List currencies supported by the store (derived from markets)
|
|
134
94
|
*/
|
|
135
|
-
list: (options?: RequestOptions) => Promise<ListResponse<
|
|
95
|
+
list: (options?: RequestOptions) => Promise<ListResponse<Currency>>;
|
|
136
96
|
};
|
|
137
97
|
readonly locales: {
|
|
138
98
|
/**
|
|
139
99
|
* List locales supported by the store (derived from markets)
|
|
140
100
|
*/
|
|
141
|
-
list: (options?: RequestOptions) => Promise<ListResponse<
|
|
101
|
+
list: (options?: RequestOptions) => Promise<ListResponse<Locale>>;
|
|
142
102
|
};
|
|
143
103
|
readonly markets: {
|
|
144
104
|
/**
|
|
145
105
|
* List all markets for the current store
|
|
146
106
|
*/
|
|
147
|
-
list: (options?: RequestOptions) => Promise<ListResponse<
|
|
107
|
+
list: (options?: RequestOptions) => Promise<ListResponse<Market>>;
|
|
148
108
|
/**
|
|
149
109
|
* Get a market by prefixed ID
|
|
150
110
|
* @param id - Market prefixed ID (e.g., "mkt_k5nR8xLq")
|
|
151
111
|
*/
|
|
152
|
-
get: (id: string, options?: RequestOptions) => Promise<
|
|
112
|
+
get: (id: string, options?: RequestOptions) => Promise<Market>;
|
|
153
113
|
/**
|
|
154
114
|
* Resolve which market applies for a given country
|
|
155
115
|
* @param country - ISO 3166-1 alpha-2 code (e.g., "DE", "US")
|
|
156
116
|
*/
|
|
157
|
-
resolve: (country: string, options?: RequestOptions) => Promise<
|
|
117
|
+
resolve: (country: string, options?: RequestOptions) => Promise<Market>;
|
|
158
118
|
/**
|
|
159
119
|
* Nested resource: Countries in a market
|
|
160
120
|
*/
|
|
@@ -163,7 +123,7 @@ declare class StoreClient {
|
|
|
163
123
|
* List countries belonging to a market
|
|
164
124
|
* @param marketId - Market prefixed ID
|
|
165
125
|
*/
|
|
166
|
-
list: (marketId: string, options?: RequestOptions) => Promise<ListResponse<
|
|
126
|
+
list: (marketId: string, options?: RequestOptions) => Promise<ListResponse<Country>>;
|
|
167
127
|
/**
|
|
168
128
|
* Get a country by ISO code within a market
|
|
169
129
|
* @param marketId - Market prefixed ID
|
|
@@ -172,7 +132,7 @@ declare class StoreClient {
|
|
|
172
132
|
get: (marketId: string, iso: string, params?: {
|
|
173
133
|
expand?: string[];
|
|
174
134
|
fields?: string[];
|
|
175
|
-
}, options?: RequestOptions) => Promise<
|
|
135
|
+
}, options?: RequestOptions) => Promise<Country>;
|
|
176
136
|
};
|
|
177
137
|
};
|
|
178
138
|
readonly cart: {
|
|
@@ -180,14 +140,14 @@ declare class StoreClient {
|
|
|
180
140
|
* Get current cart (returns null if none exists)
|
|
181
141
|
* Pass orderToken for guest checkout, or use JWT for authenticated users
|
|
182
142
|
*/
|
|
183
|
-
get: (options?: RequestOptions) => Promise<
|
|
143
|
+
get: (options?: RequestOptions) => Promise<Order & {
|
|
184
144
|
token: string;
|
|
185
145
|
}>;
|
|
186
146
|
/**
|
|
187
147
|
* Create a new cart
|
|
188
148
|
* @param params - Optional cart parameters (e.g., metadata)
|
|
189
149
|
*/
|
|
190
|
-
create: (params?: CreateCartParams, options?: RequestOptions) => Promise<
|
|
150
|
+
create: (params?: CreateCartParams, options?: RequestOptions) => Promise<Order & {
|
|
191
151
|
token: string;
|
|
192
152
|
}>;
|
|
193
153
|
/**
|
|
@@ -195,7 +155,7 @@ declare class StoreClient {
|
|
|
195
155
|
* Requires both JWT token (for authentication) and orderToken (to identify the cart)
|
|
196
156
|
* @param options - Must include both `token` (JWT) and `orderToken` (guest cart token)
|
|
197
157
|
*/
|
|
198
|
-
associate: (options: RequestOptions) => Promise<
|
|
158
|
+
associate: (options: RequestOptions) => Promise<Order & {
|
|
199
159
|
token: string;
|
|
200
160
|
}>;
|
|
201
161
|
};
|
|
@@ -206,31 +166,31 @@ declare class StoreClient {
|
|
|
206
166
|
get: (idOrNumber: string, params?: {
|
|
207
167
|
expand?: string[];
|
|
208
168
|
fields?: string[];
|
|
209
|
-
}, options?: RequestOptions) => Promise<
|
|
169
|
+
}, options?: RequestOptions) => Promise<Order>;
|
|
210
170
|
/**
|
|
211
171
|
* Update an order
|
|
212
172
|
*/
|
|
213
|
-
update: (idOrNumber: string, params: UpdateOrderParams, options?: RequestOptions) => Promise<
|
|
173
|
+
update: (idOrNumber: string, params: UpdateOrderParams, options?: RequestOptions) => Promise<Order>;
|
|
214
174
|
/**
|
|
215
175
|
* Advance order to next checkout step
|
|
216
176
|
*/
|
|
217
|
-
next: (idOrNumber: string, options?: RequestOptions) => Promise<
|
|
177
|
+
next: (idOrNumber: string, options?: RequestOptions) => Promise<Order>;
|
|
218
178
|
/**
|
|
219
179
|
* Advance through all checkout steps
|
|
220
180
|
*/
|
|
221
|
-
advance: (idOrNumber: string, options?: RequestOptions) => Promise<
|
|
181
|
+
advance: (idOrNumber: string, options?: RequestOptions) => Promise<Order>;
|
|
222
182
|
/**
|
|
223
183
|
* Complete the order
|
|
224
184
|
*/
|
|
225
|
-
complete: (idOrNumber: string, options?: RequestOptions) => Promise<
|
|
185
|
+
complete: (idOrNumber: string, options?: RequestOptions) => Promise<Order>;
|
|
226
186
|
/**
|
|
227
187
|
* Add store credit to order
|
|
228
188
|
*/
|
|
229
|
-
addStoreCredit: (idOrNumber: string, amount?: number, options?: RequestOptions) => Promise<
|
|
189
|
+
addStoreCredit: (idOrNumber: string, amount?: number, options?: RequestOptions) => Promise<Order>;
|
|
230
190
|
/**
|
|
231
191
|
* Remove store credit from order
|
|
232
192
|
*/
|
|
233
|
-
removeStoreCredit: (idOrNumber: string, options?: RequestOptions) => Promise<
|
|
193
|
+
removeStoreCredit: (idOrNumber: string, options?: RequestOptions) => Promise<Order>;
|
|
234
194
|
/**
|
|
235
195
|
* Nested resource: Line items
|
|
236
196
|
*/
|
|
@@ -239,17 +199,17 @@ declare class StoreClient {
|
|
|
239
199
|
* Add a line item to an order.
|
|
240
200
|
* Returns the updated order with recalculated totals.
|
|
241
201
|
*/
|
|
242
|
-
create: (orderId: string, params: AddLineItemParams, options?: RequestOptions) => Promise<
|
|
202
|
+
create: (orderId: string, params: AddLineItemParams, options?: RequestOptions) => Promise<Order>;
|
|
243
203
|
/**
|
|
244
204
|
* Update a line item quantity.
|
|
245
205
|
* Returns the updated order with recalculated totals.
|
|
246
206
|
*/
|
|
247
|
-
update: (orderId: string, lineItemId: string, params: UpdateLineItemParams, options?: RequestOptions) => Promise<
|
|
207
|
+
update: (orderId: string, lineItemId: string, params: UpdateLineItemParams, options?: RequestOptions) => Promise<Order>;
|
|
248
208
|
/**
|
|
249
209
|
* Remove a line item from an order.
|
|
250
210
|
* Returns the updated order with recalculated totals.
|
|
251
211
|
*/
|
|
252
|
-
delete: (orderId: string, lineItemId: string, options?: RequestOptions) => Promise<
|
|
212
|
+
delete: (orderId: string, lineItemId: string, options?: RequestOptions) => Promise<Order>;
|
|
253
213
|
};
|
|
254
214
|
/**
|
|
255
215
|
* Nested resource: Payments
|
|
@@ -258,11 +218,11 @@ declare class StoreClient {
|
|
|
258
218
|
/**
|
|
259
219
|
* List payments for an order
|
|
260
220
|
*/
|
|
261
|
-
list: (orderId: string, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
221
|
+
list: (orderId: string, options?: RequestOptions) => Promise<PaginatedResponse<Payment>>;
|
|
262
222
|
/**
|
|
263
223
|
* Get a payment by ID
|
|
264
224
|
*/
|
|
265
|
-
get: (orderId: string, paymentId: string, options?: RequestOptions) => Promise<
|
|
225
|
+
get: (orderId: string, paymentId: string, options?: RequestOptions) => Promise<Payment>;
|
|
266
226
|
};
|
|
267
227
|
/**
|
|
268
228
|
* Nested resource: Payment methods
|
|
@@ -271,7 +231,7 @@ declare class StoreClient {
|
|
|
271
231
|
/**
|
|
272
232
|
* List available payment methods for an order
|
|
273
233
|
*/
|
|
274
|
-
list: (orderId: string, options?: RequestOptions) => Promise<ListResponse<
|
|
234
|
+
list: (orderId: string, options?: RequestOptions) => Promise<ListResponse<PaymentMethod>>;
|
|
275
235
|
};
|
|
276
236
|
/**
|
|
277
237
|
* Nested resource: Payment sessions
|
|
@@ -281,21 +241,21 @@ declare class StoreClient {
|
|
|
281
241
|
* Create a payment session for an order
|
|
282
242
|
* Delegates to the payment gateway to initialize a provider-specific session
|
|
283
243
|
*/
|
|
284
|
-
create: (orderId: string, params: CreatePaymentSessionParams, options?: RequestOptions) => Promise<
|
|
244
|
+
create: (orderId: string, params: CreatePaymentSessionParams, options?: RequestOptions) => Promise<PaymentSession>;
|
|
285
245
|
/**
|
|
286
246
|
* Get a payment session by ID
|
|
287
247
|
*/
|
|
288
|
-
get: (orderId: string, sessionId: string, options?: RequestOptions) => Promise<
|
|
248
|
+
get: (orderId: string, sessionId: string, options?: RequestOptions) => Promise<PaymentSession>;
|
|
289
249
|
/**
|
|
290
250
|
* Update a payment session
|
|
291
251
|
* Delegates to the payment gateway to sync changes with the provider
|
|
292
252
|
*/
|
|
293
|
-
update: (orderId: string, sessionId: string, params: UpdatePaymentSessionParams, options?: RequestOptions) => Promise<
|
|
253
|
+
update: (orderId: string, sessionId: string, params: UpdatePaymentSessionParams, options?: RequestOptions) => Promise<PaymentSession>;
|
|
294
254
|
/**
|
|
295
255
|
* Complete a payment session
|
|
296
256
|
* Confirms the payment with the provider, triggering capture/authorization
|
|
297
257
|
*/
|
|
298
|
-
complete: (orderId: string, sessionId: string, params?: CompletePaymentSessionParams, options?: RequestOptions) => Promise<
|
|
258
|
+
complete: (orderId: string, sessionId: string, params?: CompletePaymentSessionParams, options?: RequestOptions) => Promise<PaymentSession>;
|
|
299
259
|
};
|
|
300
260
|
/**
|
|
301
261
|
* Nested resource: Coupon codes
|
|
@@ -304,12 +264,12 @@ declare class StoreClient {
|
|
|
304
264
|
/**
|
|
305
265
|
* Apply a coupon code to an order
|
|
306
266
|
*/
|
|
307
|
-
apply: (orderId: string, code: string, options?: RequestOptions) => Promise<
|
|
267
|
+
apply: (orderId: string, code: string, options?: RequestOptions) => Promise<Order>;
|
|
308
268
|
/**
|
|
309
269
|
* Remove a coupon code from an order
|
|
310
270
|
* @param promotionId - The promotion prefix_id (e.g., 'promo_xxx')
|
|
311
271
|
*/
|
|
312
|
-
remove: (orderId: string, promotionId: string, options?: RequestOptions) => Promise<
|
|
272
|
+
remove: (orderId: string, promotionId: string, options?: RequestOptions) => Promise<Order>;
|
|
313
273
|
};
|
|
314
274
|
/**
|
|
315
275
|
* Nested resource: Shipments
|
|
@@ -318,21 +278,21 @@ declare class StoreClient {
|
|
|
318
278
|
/**
|
|
319
279
|
* List shipments for an order
|
|
320
280
|
*/
|
|
321
|
-
list: (orderId: string, options?: RequestOptions) => Promise<ListResponse<
|
|
281
|
+
list: (orderId: string, options?: RequestOptions) => Promise<ListResponse<Shipment>>;
|
|
322
282
|
/**
|
|
323
283
|
* Select a shipping rate for a shipment.
|
|
324
284
|
* Returns the updated order with recalculated totals.
|
|
325
285
|
*/
|
|
326
286
|
update: (orderId: string, shipmentId: string, params: {
|
|
327
287
|
selected_shipping_rate_id: string;
|
|
328
|
-
}, options?: RequestOptions) => Promise<
|
|
288
|
+
}, options?: RequestOptions) => Promise<Order>;
|
|
329
289
|
};
|
|
330
290
|
};
|
|
331
291
|
readonly customer: {
|
|
332
292
|
/**
|
|
333
293
|
* Get current customer profile
|
|
334
294
|
*/
|
|
335
|
-
get: (options?: RequestOptions) => Promise<
|
|
295
|
+
get: (options?: RequestOptions) => Promise<Customer>;
|
|
336
296
|
/**
|
|
337
297
|
* Update current customer profile
|
|
338
298
|
*/
|
|
@@ -344,7 +304,7 @@ declare class StoreClient {
|
|
|
344
304
|
password_confirmation?: string;
|
|
345
305
|
accepts_email_marketing?: boolean;
|
|
346
306
|
phone?: string;
|
|
347
|
-
}, options?: RequestOptions) => Promise<
|
|
307
|
+
}, options?: RequestOptions) => Promise<Customer>;
|
|
348
308
|
/**
|
|
349
309
|
* Nested resource: Addresses
|
|
350
310
|
*/
|
|
@@ -352,19 +312,19 @@ declare class StoreClient {
|
|
|
352
312
|
/**
|
|
353
313
|
* List customer addresses
|
|
354
314
|
*/
|
|
355
|
-
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
315
|
+
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<Address>>;
|
|
356
316
|
/**
|
|
357
317
|
* Get an address by ID
|
|
358
318
|
*/
|
|
359
|
-
get: (id: string, options?: RequestOptions) => Promise<
|
|
319
|
+
get: (id: string, options?: RequestOptions) => Promise<Address>;
|
|
360
320
|
/**
|
|
361
321
|
* Create an address
|
|
362
322
|
*/
|
|
363
|
-
create: (params: AddressParams, options?: RequestOptions) => Promise<
|
|
323
|
+
create: (params: AddressParams, options?: RequestOptions) => Promise<Address>;
|
|
364
324
|
/**
|
|
365
325
|
* Update an address
|
|
366
326
|
*/
|
|
367
|
-
update: (id: string, params: Partial<AddressParams>, options?: RequestOptions) => Promise<
|
|
327
|
+
update: (id: string, params: Partial<AddressParams>, options?: RequestOptions) => Promise<Address>;
|
|
368
328
|
/**
|
|
369
329
|
* Delete an address
|
|
370
330
|
*/
|
|
@@ -372,7 +332,7 @@ declare class StoreClient {
|
|
|
372
332
|
/**
|
|
373
333
|
* Mark an address as default billing or shipping
|
|
374
334
|
*/
|
|
375
|
-
markAsDefault: (id: string, kind: "billing" | "shipping", options?: RequestOptions) => Promise<
|
|
335
|
+
markAsDefault: (id: string, kind: "billing" | "shipping", options?: RequestOptions) => Promise<Address>;
|
|
376
336
|
};
|
|
377
337
|
/**
|
|
378
338
|
* Nested resource: Credit Cards
|
|
@@ -381,11 +341,11 @@ declare class StoreClient {
|
|
|
381
341
|
/**
|
|
382
342
|
* List customer credit cards
|
|
383
343
|
*/
|
|
384
|
-
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
344
|
+
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<CreditCard>>;
|
|
385
345
|
/**
|
|
386
346
|
* Get a credit card by ID
|
|
387
347
|
*/
|
|
388
|
-
get: (id: string, options?: RequestOptions) => Promise<
|
|
348
|
+
get: (id: string, options?: RequestOptions) => Promise<CreditCard>;
|
|
389
349
|
/**
|
|
390
350
|
* Delete a credit card
|
|
391
351
|
*/
|
|
@@ -399,11 +359,11 @@ declare class StoreClient {
|
|
|
399
359
|
* List customer gift cards
|
|
400
360
|
* Returns gift cards associated with the current user, ordered by newest first
|
|
401
361
|
*/
|
|
402
|
-
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
362
|
+
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<GiftCard>>;
|
|
403
363
|
/**
|
|
404
364
|
* Get a gift card by ID
|
|
405
365
|
*/
|
|
406
|
-
get: (id: string, options?: RequestOptions) => Promise<
|
|
366
|
+
get: (id: string, options?: RequestOptions) => Promise<GiftCard>;
|
|
407
367
|
};
|
|
408
368
|
/**
|
|
409
369
|
* Nested resource: Orders (customer order history)
|
|
@@ -412,7 +372,7 @@ declare class StoreClient {
|
|
|
412
372
|
/**
|
|
413
373
|
* List orders for the authenticated customer
|
|
414
374
|
*/
|
|
415
|
-
list: (params?: OrderListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
375
|
+
list: (params?: OrderListParams, options?: RequestOptions) => Promise<PaginatedResponse<Order>>;
|
|
416
376
|
};
|
|
417
377
|
/**
|
|
418
378
|
* Nested resource: Payment Setup Sessions (save payment methods for future use)
|
|
@@ -422,30 +382,30 @@ declare class StoreClient {
|
|
|
422
382
|
* Create a payment setup session
|
|
423
383
|
* Delegates to the payment gateway to initialize a setup flow for saving a payment method
|
|
424
384
|
*/
|
|
425
|
-
create: (params: CreatePaymentSetupSessionParams, options?: RequestOptions) => Promise<
|
|
385
|
+
create: (params: CreatePaymentSetupSessionParams, options?: RequestOptions) => Promise<PaymentSetupSession>;
|
|
426
386
|
/**
|
|
427
387
|
* Get a payment setup session by ID
|
|
428
388
|
*/
|
|
429
|
-
get: (id: string, options?: RequestOptions) => Promise<
|
|
389
|
+
get: (id: string, options?: RequestOptions) => Promise<PaymentSetupSession>;
|
|
430
390
|
/**
|
|
431
391
|
* Complete a payment setup session
|
|
432
392
|
* Confirms the setup with the provider, resulting in a saved payment method
|
|
433
393
|
*/
|
|
434
|
-
complete: (id: string, params?: CompletePaymentSetupSessionParams, options?: RequestOptions) => Promise<
|
|
394
|
+
complete: (id: string, params?: CompletePaymentSetupSessionParams, options?: RequestOptions) => Promise<PaymentSetupSession>;
|
|
435
395
|
};
|
|
436
396
|
};
|
|
437
397
|
readonly wishlists: {
|
|
438
398
|
/**
|
|
439
399
|
* List wishlists
|
|
440
400
|
*/
|
|
441
|
-
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<
|
|
401
|
+
list: (params?: ListParams, options?: RequestOptions) => Promise<PaginatedResponse<Wishlist>>;
|
|
442
402
|
/**
|
|
443
403
|
* Get a wishlist by ID
|
|
444
404
|
*/
|
|
445
405
|
get: (id: string, params?: {
|
|
446
406
|
expand?: string[];
|
|
447
407
|
fields?: string[];
|
|
448
|
-
}, options?: RequestOptions) => Promise<
|
|
408
|
+
}, options?: RequestOptions) => Promise<Wishlist>;
|
|
449
409
|
/**
|
|
450
410
|
* Create a wishlist
|
|
451
411
|
*/
|
|
@@ -453,7 +413,7 @@ declare class StoreClient {
|
|
|
453
413
|
name: string;
|
|
454
414
|
is_private?: boolean;
|
|
455
415
|
is_default?: boolean;
|
|
456
|
-
}, options?: RequestOptions) => Promise<
|
|
416
|
+
}, options?: RequestOptions) => Promise<Wishlist>;
|
|
457
417
|
/**
|
|
458
418
|
* Update a wishlist
|
|
459
419
|
*/
|
|
@@ -461,7 +421,7 @@ declare class StoreClient {
|
|
|
461
421
|
name?: string;
|
|
462
422
|
is_private?: boolean;
|
|
463
423
|
is_default?: boolean;
|
|
464
|
-
}, options?: RequestOptions) => Promise<
|
|
424
|
+
}, options?: RequestOptions) => Promise<Wishlist>;
|
|
465
425
|
/**
|
|
466
426
|
* Delete a wishlist
|
|
467
427
|
*/
|
|
@@ -476,13 +436,13 @@ declare class StoreClient {
|
|
|
476
436
|
create: (wishlistId: string, params: {
|
|
477
437
|
variant_id: string;
|
|
478
438
|
quantity?: number;
|
|
479
|
-
}, options?: RequestOptions) => Promise<
|
|
439
|
+
}, options?: RequestOptions) => Promise<WishedItem>;
|
|
480
440
|
/**
|
|
481
441
|
* Update a wishlist item
|
|
482
442
|
*/
|
|
483
443
|
update: (wishlistId: string, itemId: string, params: {
|
|
484
444
|
quantity: number;
|
|
485
|
-
}, options?: RequestOptions) => Promise<
|
|
445
|
+
}, options?: RequestOptions) => Promise<WishedItem>;
|
|
486
446
|
/**
|
|
487
447
|
* Remove an item from a wishlist
|
|
488
448
|
*/
|
|
@@ -491,19 +451,11 @@ declare class StoreClient {
|
|
|
491
451
|
};
|
|
492
452
|
}
|
|
493
453
|
|
|
494
|
-
|
|
495
|
-
/** @internal */
|
|
496
|
-
private readonly request;
|
|
497
|
-
constructor(request: RequestFn);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
interface SpreeClientConfig {
|
|
454
|
+
interface ClientConfig {
|
|
501
455
|
/** Base URL of the Spree API (e.g., 'https://api.mystore.com') */
|
|
502
456
|
baseUrl: string;
|
|
503
|
-
/** Publishable API key for Store API access
|
|
504
|
-
publishableKey
|
|
505
|
-
/** Secret API key for Admin API access (optional) */
|
|
506
|
-
secretKey?: string;
|
|
457
|
+
/** Publishable API key for Store API access */
|
|
458
|
+
publishableKey: string;
|
|
507
459
|
/** Custom fetch implementation (optional, defaults to global fetch) */
|
|
508
460
|
fetch?: typeof fetch;
|
|
509
461
|
/** Retry configuration. Enabled by default. Pass false to disable. */
|
|
@@ -515,13 +467,7 @@ interface SpreeClientConfig {
|
|
|
515
467
|
/** Default country ISO code for market resolution (e.g., 'FR') */
|
|
516
468
|
country?: string;
|
|
517
469
|
}
|
|
518
|
-
|
|
519
|
-
/** Store API — customer-facing endpoints (products, cart, checkout, account) */
|
|
520
|
-
readonly store: StoreClient;
|
|
521
|
-
/** Admin API — administrative endpoints (manage orders, products, settings) */
|
|
522
|
-
readonly admin: AdminClient;
|
|
523
|
-
private readonly _defaults;
|
|
524
|
-
constructor(config: SpreeClientConfig);
|
|
470
|
+
interface Client extends StoreClient {
|
|
525
471
|
/** Set default locale for all subsequent requests */
|
|
526
472
|
setLocale(locale: string): void;
|
|
527
473
|
/** Set default currency for all subsequent requests */
|
|
@@ -530,8 +476,16 @@ declare class SpreeClient {
|
|
|
530
476
|
setCountry(country: string): void;
|
|
531
477
|
}
|
|
532
478
|
/**
|
|
533
|
-
* Create a new Spree SDK client
|
|
479
|
+
* Create a new Spree Store SDK client.
|
|
480
|
+
*
|
|
481
|
+
* Returns a flat client with all store resources directly accessible:
|
|
482
|
+
* ```ts
|
|
483
|
+
* const client = createClient({ baseUrl: '...', publishableKey: '...' })
|
|
484
|
+
* client.products.list()
|
|
485
|
+
* client.cart.create()
|
|
486
|
+
* client.orders.get('order_1')
|
|
487
|
+
* ```
|
|
534
488
|
*/
|
|
535
|
-
declare function
|
|
489
|
+
declare function createClient(config: ClientConfig): Client;
|
|
536
490
|
|
|
537
|
-
export { AddLineItemParams,
|
|
491
|
+
export { AddLineItemParams, Address, AddressParams, AuthTokens, type Client, type ClientConfig, CompletePaymentSessionParams, CompletePaymentSetupSessionParams, Country, CreateCartParams, CreatePaymentSessionParams, CreatePaymentSetupSessionParams, CreditCard, Currency, Customer, GiftCard, ListParams, ListResponse, Locale, LoginCredentials, Market, Order, OrderListParams, PaginatedResponse, Payment, PaymentMethod, PaymentSession, PaymentSetupSession, Product, ProductFiltersParams, ProductFiltersResponse, ProductListParams, RegisterParams, RequestOptions, RetryConfig, Shipment, Address as StoreAddress, StoreClient, Country as StoreCountry, CreditCard as StoreCreditCard, Currency as StoreCurrency, Customer as StoreCustomer, GiftCard as StoreGiftCard, Locale as StoreLocale, Market as StoreMarket, Order as StoreOrder, Payment as StorePayment, PaymentMethod as StorePaymentMethod, PaymentSession as StorePaymentSession, PaymentSetupSession as StorePaymentSetupSession, Product as StoreProduct, Shipment as StoreShipment, Taxon as StoreTaxon, Taxonomy as StoreTaxonomy, WishedItem as StoreWishedItem, Wishlist as StoreWishlist, Taxon, TaxonListParams, Taxonomy, UpdateLineItemParams, UpdateOrderParams, UpdatePaymentSessionParams, WishedItem, Wishlist, createClient };
|