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