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