@shopkit/data-layer 1.0.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 +857 -0
- package/dist/adapters/index.d.mts +22 -0
- package/dist/adapters/index.d.ts +22 -0
- package/dist/adapters/index.js +5315 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/index.mjs +5312 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/index.d.mts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +5387 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5376 -0
- package/dist/index.mjs.map +1 -0
- package/dist/models/index.d.mts +598 -0
- package/dist/models/index.d.ts +598 -0
- package/dist/models/index.js +67 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/index.mjs +59 -0
- package/dist/models/index.mjs.map +1 -0
- package/dist/service-NPmqCNGb.d.mts +750 -0
- package/dist/service-Q7zlmyFk.d.ts +750 -0
- package/package.json +120 -0
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { ISingleProductRequest, IOptionsRequest, IResponse, IProductQueryReqest, ISingleCollectionRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICollectionFilterRequest, ISingleOrderRequest, IOrderQueryRequest, IOrderRequest, IUpdateOrderRequest, IOrderHistoryRequest, IOrderByIdRequest, ISingleCustomerRequest, ICustomerQueryRequest, ICustomerRequest, IUpdateCustomerRequest, ISingleCartRequest, IUpdateCartRequest, IAddToCartRequest, IRemoveFromCartRequest, ICreateCheckoutRequest, IGetArticleRequest, IBlogArticleRequest, ITrendingArticleRequest, IArticleByHandleRequest, ICheckoutUpdateRequest, IPaymentRequest, IFetchOptionsRequest } from './models/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Core interface that all platform adapters will implement
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
interface ICommerceClient {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve a single product by ID or handle
|
|
10
|
+
* @param params - Product identifier (id or handle)
|
|
11
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
12
|
+
* @returns Promise resolving to product data
|
|
13
|
+
*/
|
|
14
|
+
getProduct(params: ISingleProductRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieve multiple products with filtering and pagination
|
|
17
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
18
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
19
|
+
* @returns Promise resolving to paginated products response
|
|
20
|
+
*/
|
|
21
|
+
getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieve multiple products by their handles
|
|
24
|
+
* @param handles - Array of product handles
|
|
25
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
26
|
+
* @returns Promise resolving to array of products
|
|
27
|
+
*/
|
|
28
|
+
getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Retrieve a single collection by ID or handle
|
|
31
|
+
* @param params - Collection identifier (id or handle)
|
|
32
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
33
|
+
* @returns Promise resolving to collection data
|
|
34
|
+
*/
|
|
35
|
+
getCollection(params: ISingleCollectionRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieve multiple collections with filtering and pagination
|
|
38
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
39
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
40
|
+
* @returns Promise resolving to paginated collections response
|
|
41
|
+
*/
|
|
42
|
+
getCollections(params: ICollectionQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve multiple collections by their handles with individual query parameters
|
|
45
|
+
* Each collection can have its own specific filtering, pagination, and sorting options
|
|
46
|
+
* @param params - Array of collection objects, each containing:
|
|
47
|
+
* - handle: Collection handle (required)
|
|
48
|
+
* - query: Search query string (optional)
|
|
49
|
+
* - after/before: Pagination cursors (optional)
|
|
50
|
+
* - first/last: Number of items to return (optional)
|
|
51
|
+
* - reverse: Sort order reversal (optional)
|
|
52
|
+
* - sortKey: Collection sorting key (optional)
|
|
53
|
+
* - productLimit: Max products per collection (optional)
|
|
54
|
+
* - productSortKey: Product sorting within collection (optional)
|
|
55
|
+
* - productReverse: Product sort order reversal (optional)
|
|
56
|
+
* - filters: Product filtering options including price, availability, type, vendor, tags (optional)
|
|
57
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
58
|
+
* @returns Promise resolving to collections data with individual query results
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const result = await client.getCollectionsByHandels([
|
|
62
|
+
* { handle: 'featured', first: 10, sortKey: 'UPDATED_AT' },
|
|
63
|
+
* { handle: 'sale', productLimit: 5, filters: [{ available: true }] }
|
|
64
|
+
* ]);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
getCollectionsByHandels(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Retrieve available filters for collections
|
|
70
|
+
* @param params - Collection identifier (id or handle) to get filters for
|
|
71
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
72
|
+
* @returns Promise resolving to available filter options (price ranges, brands, categories, etc.)
|
|
73
|
+
*/
|
|
74
|
+
getCollectionFilters(params: ICollectionFilterRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Retrieve a single order by ID
|
|
77
|
+
* @param params - Order identifier
|
|
78
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
79
|
+
* @returns Promise resolving to order data
|
|
80
|
+
*/
|
|
81
|
+
getOrder(params: ISingleOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieve multiple orders with filtering and pagination
|
|
84
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
85
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
86
|
+
* @returns Promise resolving to paginated orders response
|
|
87
|
+
*/
|
|
88
|
+
getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
89
|
+
/**
|
|
90
|
+
* Create a new order
|
|
91
|
+
* @param data - Order data to create
|
|
92
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
93
|
+
* @returns Promise resolving to created order
|
|
94
|
+
*/
|
|
95
|
+
createOrder(data: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Update an existing order
|
|
98
|
+
* @param params - Object containing id and data to update
|
|
99
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
100
|
+
* @returns Promise resolving to updated order
|
|
101
|
+
*/
|
|
102
|
+
updateOrder(params: IUpdateOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
103
|
+
/**
|
|
104
|
+
* Retrieve order history for a customer
|
|
105
|
+
* @param params - Object containing customerAccessToken, page, and limit
|
|
106
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
107
|
+
* @returns Promise resolving to order history
|
|
108
|
+
*/
|
|
109
|
+
getOrderHistory(params: IOrderHistoryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Retrieve a specific order for a customer
|
|
112
|
+
* @param params - Object containing customerAccessToken and orderId
|
|
113
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
114
|
+
* @returns Promise resolving to order data
|
|
115
|
+
*/
|
|
116
|
+
getOrderById(params: IOrderByIdRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Retrieve a single customer by ID
|
|
119
|
+
* @param params - Customer identifier
|
|
120
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
121
|
+
* @returns Promise resolving to customer data
|
|
122
|
+
*/
|
|
123
|
+
getCustomer(params: ISingleCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieve multiple customers with filtering and pagination
|
|
126
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
127
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
128
|
+
* @returns Promise resolving to paginated customers response
|
|
129
|
+
*/
|
|
130
|
+
getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
131
|
+
/**
|
|
132
|
+
* Create a new customer account
|
|
133
|
+
* @param data - Customer data to create
|
|
134
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
135
|
+
* @returns Promise resolving to created customer
|
|
136
|
+
*/
|
|
137
|
+
createCustomer(data: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
138
|
+
/**
|
|
139
|
+
* Update an existing customer account
|
|
140
|
+
* @param params - Object containing id and data to update
|
|
141
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
142
|
+
* @returns Promise resolving to updated customer
|
|
143
|
+
*/
|
|
144
|
+
updateCustomer(params: IUpdateCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
145
|
+
/**
|
|
146
|
+
* Retrieve a shopping cart by ID
|
|
147
|
+
* @param params - Cart identifier
|
|
148
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
149
|
+
* @returns Promise resolving to standardized response with cart data
|
|
150
|
+
*/
|
|
151
|
+
getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
152
|
+
/**
|
|
153
|
+
* Create a new shopping cart
|
|
154
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
155
|
+
* @returns Promise resolving to standardized response with created cart
|
|
156
|
+
*/
|
|
157
|
+
createCart(options?: IOptionsRequest): Promise<IResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Update an existing shopping cart
|
|
160
|
+
* @param params - Object containing id and data to update
|
|
161
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
162
|
+
* @returns Promise resolving to standardized response with updated cart
|
|
163
|
+
*/
|
|
164
|
+
updateCart(params: IUpdateCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
165
|
+
/**
|
|
166
|
+
* Add items to a shopping cart
|
|
167
|
+
* @param params - Object containing cart id and items to add
|
|
168
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
169
|
+
* @returns Promise resolving to standardized response with updated cart
|
|
170
|
+
*/
|
|
171
|
+
addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
172
|
+
/**
|
|
173
|
+
* Remove items from a shopping cart
|
|
174
|
+
* @param params - Object containing cart id and item IDs to remove
|
|
175
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
176
|
+
* @returns Promise resolving to standardized response with updated cart
|
|
177
|
+
*/
|
|
178
|
+
removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
179
|
+
/**
|
|
180
|
+
* Create a new checkout session
|
|
181
|
+
* @param params - Checkout data
|
|
182
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
183
|
+
* @returns Promise resolving to checkout session
|
|
184
|
+
*/
|
|
185
|
+
createCheckout(params: ICreateCheckoutRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
186
|
+
/**
|
|
187
|
+
* Retrieve a single article
|
|
188
|
+
* @param params - Query parameters for filtering articles
|
|
189
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
190
|
+
* @returns Promise resolving to article data
|
|
191
|
+
*/
|
|
192
|
+
getArticle(params?: IGetArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
193
|
+
/**
|
|
194
|
+
* Retrieve blog articles with optional filtering
|
|
195
|
+
* @param params - Query parameters for category and limit
|
|
196
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
197
|
+
* @returns Promise resolving to articles array
|
|
198
|
+
*/
|
|
199
|
+
getBlogArticles(params: IBlogArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
200
|
+
/**
|
|
201
|
+
* Retrieve trending articles with optional filtering
|
|
202
|
+
* @param params - Query parameters for category
|
|
203
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
204
|
+
* @returns Promise resolving to trending articles
|
|
205
|
+
*/
|
|
206
|
+
getTrendingArticles(params: ITrendingArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
207
|
+
/**
|
|
208
|
+
* Retrieve a specific article by handle
|
|
209
|
+
* @param params - Article parameters including category and handle
|
|
210
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
211
|
+
* @returns Promise resolving to article data
|
|
212
|
+
*/
|
|
213
|
+
getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
214
|
+
/**
|
|
215
|
+
* Utility method to make GraphQL requests
|
|
216
|
+
* @param query - GraphQL query string
|
|
217
|
+
* @param variables - GraphQL variables
|
|
218
|
+
* @param options - Request options
|
|
219
|
+
* @returns Promise resolving to standardized response
|
|
220
|
+
*/
|
|
221
|
+
graphqlRequest(query: string, variables?: Record<string, any>): Promise<IResponse>;
|
|
222
|
+
/**
|
|
223
|
+
* Utility method to make custom fetch requests to any endpoint
|
|
224
|
+
* @param url - Target URL for the request
|
|
225
|
+
* @param options - Request options
|
|
226
|
+
* @returns Promise resolving to standardized response
|
|
227
|
+
*/
|
|
228
|
+
fetchRequest(url: string, options?: {
|
|
229
|
+
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
230
|
+
headers?: Record<string, string>;
|
|
231
|
+
body?: any;
|
|
232
|
+
signal?: AbortSignal;
|
|
233
|
+
}): Promise<IResponse>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Shopify-specific types for the commerce library
|
|
238
|
+
*/
|
|
239
|
+
/**
|
|
240
|
+
* Configuration for the Shopify adapter
|
|
241
|
+
*/
|
|
242
|
+
interface IShopifyConfig {
|
|
243
|
+
/**
|
|
244
|
+
* Shopify store domain (e.g., 'your-store.myshopify.com')
|
|
245
|
+
*/
|
|
246
|
+
domain: string;
|
|
247
|
+
/**
|
|
248
|
+
* Shopify Storefront API access token
|
|
249
|
+
*/
|
|
250
|
+
storefrontAccessToken: string;
|
|
251
|
+
/**
|
|
252
|
+
* API version to use (e.g., '2023-07')
|
|
253
|
+
*/
|
|
254
|
+
apiVersion?: string;
|
|
255
|
+
/**
|
|
256
|
+
* Whether to use the Shopify Storefront API (true) or Admin API (false)
|
|
257
|
+
* Default: true
|
|
258
|
+
*/
|
|
259
|
+
useStorefrontApi?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Optional Admin API access token (required if useStorefrontApi is false)
|
|
262
|
+
*/
|
|
263
|
+
adminAccessToken?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Optional language code for localized content
|
|
266
|
+
*/
|
|
267
|
+
language?: string;
|
|
268
|
+
/**
|
|
269
|
+
* Optional country code for pricing and availability
|
|
270
|
+
*/
|
|
271
|
+
country?: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Logger configuration options
|
|
276
|
+
*/
|
|
277
|
+
interface LoggerConfig {
|
|
278
|
+
level?: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
279
|
+
enabled?: boolean;
|
|
280
|
+
name?: string;
|
|
281
|
+
prettyPrint?: boolean;
|
|
282
|
+
redact?: string[];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Base implementation class that all platform adapters will extend
|
|
287
|
+
* Provides default implementations with informative error messages
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Abstract base class that implements all methods with informative error messages
|
|
292
|
+
* Platform adapters should extend this class and override the methods they support
|
|
293
|
+
*/
|
|
294
|
+
declare abstract class BaseCommerceClient implements ICommerceClient {
|
|
295
|
+
/**
|
|
296
|
+
* The name of the adapter (e.g., "Shopify", "Custom Backend")
|
|
297
|
+
* Used in error messages for better debugging
|
|
298
|
+
*/
|
|
299
|
+
protected abstract readonly adapterName: string;
|
|
300
|
+
/**
|
|
301
|
+
* Helper method to throw informative "not implemented" errors
|
|
302
|
+
* @param methodName - The method name that's not implemented
|
|
303
|
+
*/
|
|
304
|
+
protected throwNotImplemented(methodName: string): never;
|
|
305
|
+
/**
|
|
306
|
+
* Retrieve a single product by ID or handle
|
|
307
|
+
* @param params - Product identifier (id or handle)
|
|
308
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
309
|
+
* @returns Promise resolving to product data
|
|
310
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
311
|
+
*/
|
|
312
|
+
getProduct(params: ISingleProductRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
313
|
+
/**
|
|
314
|
+
* Retrieve multiple products with filtering and pagination
|
|
315
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
316
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
317
|
+
* @returns Promise resolving to paginated products response
|
|
318
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
319
|
+
*/
|
|
320
|
+
getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
|
|
321
|
+
/**
|
|
322
|
+
* Retrieve multiple products by their handles
|
|
323
|
+
* @param handles - Array of product handles
|
|
324
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
325
|
+
* @returns Promise resolving to array of products
|
|
326
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
327
|
+
*/
|
|
328
|
+
getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
|
|
329
|
+
/**
|
|
330
|
+
* Retrieve a single collection by ID or handle
|
|
331
|
+
* @param params - Collection identifier (id or handle)
|
|
332
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
333
|
+
* @returns Promise resolving to collection data
|
|
334
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
335
|
+
*/
|
|
336
|
+
getCollection(params: ISingleCollectionRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
337
|
+
/**
|
|
338
|
+
* Retrieve multiple collections with filtering and pagination
|
|
339
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
340
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
341
|
+
* @returns Promise resolving to paginated collections response
|
|
342
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
343
|
+
*/
|
|
344
|
+
getCollections(params: ICollectionQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
345
|
+
/**
|
|
346
|
+
* Retrieve multiple collections by their handles with individual query parameters
|
|
347
|
+
* Each collection can have its own specific filtering, pagination, and sorting options
|
|
348
|
+
* @param params - Array of collection objects, each containing:
|
|
349
|
+
* - handle: Collection handle (required)
|
|
350
|
+
* - query: Search query string (optional)
|
|
351
|
+
* - after/before: Pagination cursors (optional)
|
|
352
|
+
* - first/last: Number of items to return (optional)
|
|
353
|
+
* - reverse: Sort order reversal (optional)
|
|
354
|
+
* - sortKey: Collection sorting key (optional)
|
|
355
|
+
* - productLimit: Max products per collection (optional)
|
|
356
|
+
* - productSortKey: Product sorting within collection (optional)
|
|
357
|
+
* - productReverse: Product sort order reversal (optional)
|
|
358
|
+
* - filters: Product filtering options including price, availability, type, vendor, tags (optional)
|
|
359
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
360
|
+
* @returns Promise resolving to collections data with individual query results
|
|
361
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
362
|
+
*/
|
|
363
|
+
getCollectionsByHandels(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
364
|
+
/**
|
|
365
|
+
* Retrieve available filters for collections
|
|
366
|
+
* @param params - Collection identifier (id or handle) to get filters for
|
|
367
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
368
|
+
* @returns Promise resolving to available filter options (price ranges, brands, categories, etc.)
|
|
369
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
370
|
+
*/
|
|
371
|
+
getCollectionFilters(params: ICollectionFilterRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
372
|
+
/**
|
|
373
|
+
* Retrieve a single order by ID
|
|
374
|
+
* @param params - Order identifier
|
|
375
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
376
|
+
* @returns Promise resolving to order data
|
|
377
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
378
|
+
*/
|
|
379
|
+
getOrder(params: ISingleOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
380
|
+
/**
|
|
381
|
+
* Retrieve multiple orders with filtering and pagination
|
|
382
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
383
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
384
|
+
* @returns Promise resolving to paginated orders response
|
|
385
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
386
|
+
*/
|
|
387
|
+
getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
388
|
+
/**
|
|
389
|
+
* Create a new order
|
|
390
|
+
* @param data - Order data to create
|
|
391
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
392
|
+
* @returns Promise resolving to created order
|
|
393
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
394
|
+
*/
|
|
395
|
+
createOrder(data: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
396
|
+
/**
|
|
397
|
+
* Update an existing order
|
|
398
|
+
* @param params - Object containing id and data to update
|
|
399
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
400
|
+
* @returns Promise resolving to updated order
|
|
401
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
402
|
+
*/
|
|
403
|
+
updateOrder(params: IUpdateOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
404
|
+
/**
|
|
405
|
+
* Retrieve order history for a customer
|
|
406
|
+
* @param params - Object containing customerAccessToken, page, and limit
|
|
407
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
408
|
+
* @returns Promise resolving to order history
|
|
409
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
410
|
+
*/
|
|
411
|
+
getOrderHistory(params: IOrderHistoryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
412
|
+
/**
|
|
413
|
+
* Retrieve a specific order for a customer
|
|
414
|
+
* @param params - Object containing customerAccessToken and orderId
|
|
415
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
416
|
+
* @returns Promise resolving to order data
|
|
417
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
418
|
+
*/
|
|
419
|
+
getOrderById(params: IOrderByIdRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
420
|
+
/**
|
|
421
|
+
* Retrieve a single customer by ID
|
|
422
|
+
* @param params - Customer identifier
|
|
423
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
424
|
+
* @returns Promise resolving to customer data
|
|
425
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
426
|
+
*/
|
|
427
|
+
getCustomer(params: ISingleCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
428
|
+
/**
|
|
429
|
+
* Retrieve multiple customers with filtering and pagination
|
|
430
|
+
* @param params - Query parameters for filtering, sorting, and pagination
|
|
431
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
432
|
+
* @returns Promise resolving to paginated customers response
|
|
433
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
434
|
+
*/
|
|
435
|
+
getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
436
|
+
/**
|
|
437
|
+
* Create a new customer account
|
|
438
|
+
* @param data - Customer data to create
|
|
439
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
440
|
+
* @returns Promise resolving to created customer
|
|
441
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
442
|
+
*/
|
|
443
|
+
createCustomer(data: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
444
|
+
/**
|
|
445
|
+
* Update an existing customer account
|
|
446
|
+
* @param params - Object containing id and data to update
|
|
447
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
448
|
+
* @returns Promise resolving to updated customer
|
|
449
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
450
|
+
*/
|
|
451
|
+
updateCustomer(params: IUpdateCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
452
|
+
/**
|
|
453
|
+
* Retrieve a shopping cart by ID
|
|
454
|
+
* @param params - Cart identifier
|
|
455
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
456
|
+
* @returns Promise resolving to standardized response with cart data
|
|
457
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
458
|
+
*/
|
|
459
|
+
getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
460
|
+
/**
|
|
461
|
+
* Create a new shopping cart
|
|
462
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
463
|
+
* @returns Promise resolving to standardized response with created cart
|
|
464
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
465
|
+
*/
|
|
466
|
+
createCart(options?: IOptionsRequest): Promise<IResponse>;
|
|
467
|
+
/**
|
|
468
|
+
* Update an existing shopping cart
|
|
469
|
+
* @param params - Object containing id and data to update
|
|
470
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
471
|
+
* @returns Promise resolving to standardized response with updated cart
|
|
472
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
473
|
+
*/
|
|
474
|
+
updateCart(params: IUpdateCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
475
|
+
/**
|
|
476
|
+
* Add items to a shopping cart
|
|
477
|
+
* @param params - Object containing cart id and items to add
|
|
478
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
479
|
+
* @returns Promise resolving to standardized response with updated cart
|
|
480
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
481
|
+
*/
|
|
482
|
+
addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
483
|
+
/**
|
|
484
|
+
* Remove items from a shopping cart
|
|
485
|
+
* @param params - Object containing cart id and item IDs to remove
|
|
486
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
487
|
+
* @returns Promise resolving to standardized response with updated cart
|
|
488
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
489
|
+
*/
|
|
490
|
+
removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
491
|
+
/**
|
|
492
|
+
* Create a new checkout session
|
|
493
|
+
* @param params - Checkout data
|
|
494
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
495
|
+
* @returns Promise resolving to checkout session
|
|
496
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
497
|
+
*/
|
|
498
|
+
createCheckout(params: ICreateCheckoutRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
499
|
+
/**
|
|
500
|
+
* Update an existing checkout session
|
|
501
|
+
* @param id - Checkout identifier
|
|
502
|
+
* @param data - Checkout update data
|
|
503
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
504
|
+
* @returns Promise resolving to updated checkout
|
|
505
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
506
|
+
*/
|
|
507
|
+
updateCheckout(id: string, data: ICheckoutUpdateRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
508
|
+
/**
|
|
509
|
+
* Complete a checkout and create an order
|
|
510
|
+
* @param id - Checkout identifier
|
|
511
|
+
* @param paymentData - Payment information
|
|
512
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
513
|
+
* @returns Promise resolving to created order
|
|
514
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
515
|
+
*/
|
|
516
|
+
completeCheckout(id: string, paymentData: IPaymentRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
517
|
+
/**
|
|
518
|
+
* Retrieve a single article
|
|
519
|
+
* @param params - Query parameters for filtering articles
|
|
520
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
521
|
+
* @returns Promise resolving to article data
|
|
522
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
523
|
+
*/
|
|
524
|
+
getArticle(params?: IGetArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
525
|
+
/**
|
|
526
|
+
* Retrieve blog articles with optional filtering
|
|
527
|
+
* @param params - Query parameters for category and limit
|
|
528
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
529
|
+
* @returns Promise resolving to articles array
|
|
530
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
531
|
+
*/
|
|
532
|
+
getBlogArticles(params: IBlogArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
533
|
+
/**
|
|
534
|
+
* Retrieve trending articles with optional filtering
|
|
535
|
+
* @param params - Query parameters for category
|
|
536
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
537
|
+
* @returns Promise resolving to trending articles
|
|
538
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
539
|
+
*/
|
|
540
|
+
getTrendingArticles(params: ITrendingArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
541
|
+
/**
|
|
542
|
+
* Retrieve a specific article by handle
|
|
543
|
+
* @param params - Article parameters including category and handle
|
|
544
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
545
|
+
* @returns Promise resolving to article data
|
|
546
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
547
|
+
*/
|
|
548
|
+
getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
549
|
+
/**
|
|
550
|
+
* Utility method to make GraphQL requests
|
|
551
|
+
* @param query - GraphQL query string
|
|
552
|
+
* @param variables - GraphQL variables
|
|
553
|
+
* @returns Promise resolving to standardized response
|
|
554
|
+
* @throws NotImplementedError if not implemented in adapter
|
|
555
|
+
*/
|
|
556
|
+
graphqlRequest(query: string, variables?: Record<string, any>): Promise<IResponse>;
|
|
557
|
+
/**
|
|
558
|
+
* Utility method to make custom fetch requests to any endpoint
|
|
559
|
+
* @param url - Target URL for the request
|
|
560
|
+
* @param options - Request options
|
|
561
|
+
* @returns Promise resolving to standardized response
|
|
562
|
+
*/
|
|
563
|
+
fetchRequest(url: string, fetchOptions?: IFetchOptionsRequest): Promise<IResponse>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Shopify adapter implementation of the CommerceClient interface
|
|
568
|
+
* Uses composition pattern with specialized services
|
|
569
|
+
*/
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Shopify adapter implementation of the CommerceClient interface
|
|
573
|
+
* Uses composition pattern with specialized services for better maintainability
|
|
574
|
+
*/
|
|
575
|
+
declare class ShopifyCommerceClient extends BaseCommerceClient {
|
|
576
|
+
protected readonly adapterName = "Shopify";
|
|
577
|
+
private client;
|
|
578
|
+
private logger;
|
|
579
|
+
private productService;
|
|
580
|
+
private cartService;
|
|
581
|
+
private blogService;
|
|
582
|
+
private customerOrderService;
|
|
583
|
+
constructor(config: IShopifyConfig, logging?: LoggerConfig);
|
|
584
|
+
/**
|
|
585
|
+
* Get products based on query parameters
|
|
586
|
+
*/
|
|
587
|
+
getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
|
|
588
|
+
/**
|
|
589
|
+
* Get a product by ID
|
|
590
|
+
*/
|
|
591
|
+
getProduct(params: ISingleProductRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
592
|
+
/**
|
|
593
|
+
* Get multiple products by their handles using batch query
|
|
594
|
+
*/
|
|
595
|
+
getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
|
|
596
|
+
/**
|
|
597
|
+
* Get collections based on query parameters
|
|
598
|
+
*/
|
|
599
|
+
getCollections(params: ICollectionQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
600
|
+
/**
|
|
601
|
+
* Get a collection by ID
|
|
602
|
+
*/
|
|
603
|
+
getCollection(params: ISingleCollectionRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
604
|
+
/**
|
|
605
|
+
* Retrieve multiple collections by their handles with individual query parameters
|
|
606
|
+
* Each collection can have its own specific filtering, pagination, and sorting options
|
|
607
|
+
* @param params - Array of collection objects with handles and their respective query parameters
|
|
608
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
609
|
+
* @returns Promise resolving to collections data with individual query results
|
|
610
|
+
*/
|
|
611
|
+
/**
|
|
612
|
+
* Get multiple collections by their handles (preferred method name)
|
|
613
|
+
*/
|
|
614
|
+
getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
615
|
+
/**
|
|
616
|
+
* Create a new cart
|
|
617
|
+
*/
|
|
618
|
+
createCart(options?: IOptionsRequest): Promise<IResponse>;
|
|
619
|
+
/**
|
|
620
|
+
* Get a cart by ID
|
|
621
|
+
*/
|
|
622
|
+
getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
623
|
+
/**
|
|
624
|
+
* Update a cart
|
|
625
|
+
*/
|
|
626
|
+
updateCart(params: IUpdateCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
627
|
+
/**
|
|
628
|
+
* Add items to a cart
|
|
629
|
+
*/
|
|
630
|
+
addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
631
|
+
/**
|
|
632
|
+
* Remove items from a cart
|
|
633
|
+
*/
|
|
634
|
+
removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
635
|
+
/**
|
|
636
|
+
* Get articles
|
|
637
|
+
*/
|
|
638
|
+
getArticle(params?: IGetArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
639
|
+
/**
|
|
640
|
+
* Get blog articles
|
|
641
|
+
*/
|
|
642
|
+
getBlogArticles(params: IBlogArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
643
|
+
/**
|
|
644
|
+
* Get trending articles
|
|
645
|
+
*/
|
|
646
|
+
getTrendingArticles(params: ITrendingArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
647
|
+
/**
|
|
648
|
+
* Get article by handle
|
|
649
|
+
*/
|
|
650
|
+
getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
651
|
+
/**
|
|
652
|
+
* Get order history for a customer
|
|
653
|
+
*/
|
|
654
|
+
getOrderHistory(params: IOrderHistoryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
655
|
+
/**
|
|
656
|
+
* Get a single order by ID
|
|
657
|
+
*/
|
|
658
|
+
getOrderById(params: IOrderByIdRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
659
|
+
/**
|
|
660
|
+
* Get customer profile
|
|
661
|
+
*/
|
|
662
|
+
getCustomerProfile(customerAccessToken: string, options?: IOptionsRequest): Promise<IResponse>;
|
|
663
|
+
/**
|
|
664
|
+
* Utility method to make GraphQL requests using Shopify client
|
|
665
|
+
*/
|
|
666
|
+
graphqlRequest(query: string, variables?: Record<string, any>): Promise<IResponse>;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Custom Backend adapter interfaces
|
|
671
|
+
* This file contains the interfaces for the custom backend adapter
|
|
672
|
+
*/
|
|
673
|
+
/**
|
|
674
|
+
* Custom Backend configuration
|
|
675
|
+
*/
|
|
676
|
+
interface ICustomConfig {
|
|
677
|
+
merchantId: string;
|
|
678
|
+
storeId: string;
|
|
679
|
+
commonHeaders?: Record<string, string>;
|
|
680
|
+
timeout?: number;
|
|
681
|
+
services: {
|
|
682
|
+
cart: {
|
|
683
|
+
apiBaseUrl: string;
|
|
684
|
+
};
|
|
685
|
+
order: {
|
|
686
|
+
apiBaseUrl: string;
|
|
687
|
+
};
|
|
688
|
+
product: {
|
|
689
|
+
apiBaseUrl: string;
|
|
690
|
+
};
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Custom Backend adapter for the commerce library
|
|
696
|
+
* This adapter connects to a custom backend with multiple microservices built on top of Shopify
|
|
697
|
+
*/
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Custom Backend client implementation
|
|
701
|
+
* This client uses microservices for different domains (product, customer, user, etc.)
|
|
702
|
+
*/
|
|
703
|
+
declare class CustomBackendClient extends BaseCommerceClient {
|
|
704
|
+
protected readonly adapterName = "Custom Backend";
|
|
705
|
+
private productService;
|
|
706
|
+
private orderService;
|
|
707
|
+
private cartService;
|
|
708
|
+
private logger;
|
|
709
|
+
constructor(config: ICustomConfig, logging?: LoggerConfig);
|
|
710
|
+
getProduct(params: ISingleProductRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
711
|
+
getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
|
|
712
|
+
getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
|
|
713
|
+
/**
|
|
714
|
+
* Get collections based on query parameters
|
|
715
|
+
*/
|
|
716
|
+
getCollections(params: ICollectionQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
717
|
+
/**
|
|
718
|
+
* Get a collection by ID
|
|
719
|
+
*/
|
|
720
|
+
getCollection(params: ISingleCollectionRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
721
|
+
/**
|
|
722
|
+
* Retrieve multiple collections by their handles with individual query parameters
|
|
723
|
+
* Each collection can have its own specific filtering, pagination, and sorting options
|
|
724
|
+
* @param params - Array of collection objects with handles and their respective query parameters
|
|
725
|
+
* @param options - Request options (headers, timeout, etc.)
|
|
726
|
+
* @returns Promise resolving to collections data with individual query results
|
|
727
|
+
*/
|
|
728
|
+
getCollectionsByHandels(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
729
|
+
getCollectionFilters(params: ICollectionFilterRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
730
|
+
getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
731
|
+
createCart(options?: IOptionsRequest): Promise<IResponse>;
|
|
732
|
+
updateCart(params: IUpdateCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
733
|
+
addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
734
|
+
removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
735
|
+
createCheckout(params: ICreateCheckoutRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
736
|
+
updateCheckout(id: string, data: ICheckoutUpdateRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
737
|
+
completeCheckout(id: string, paymentData: IPaymentRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
738
|
+
getCustomer(params: ISingleCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
739
|
+
getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
740
|
+
createCustomer(params: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
741
|
+
updateCustomer(params: IUpdateCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
742
|
+
getOrder(params: ISingleOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
743
|
+
getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
744
|
+
createOrder(params: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
745
|
+
updateOrder(params: IUpdateOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
746
|
+
getOrderHistory(params: IOrderHistoryRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
747
|
+
getOrderById(params: IOrderByIdRequest, options?: IOptionsRequest): Promise<IResponse>;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
export { CustomBackendClient as C, type IShopifyConfig as I, type LoggerConfig as L, ShopifyCommerceClient as S, type ICustomConfig as a, type ICommerceClient as b };
|