@shopkit/data-layer 1.0.0 → 1.2.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.
@@ -0,0 +1,236 @@
1
+ import { ISingleProductRequest, IOptionsRequest, IResponse, IProductQueryReqest, IProductsByHandlesRequest, IProductRecommendationsRequest, ISingleCollectionRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICollectionFilterRequest, ISingleOrderRequest, IOrderQueryRequest, IOrderRequest, IUpdateOrderRequest, IOrderHistoryRequest, IOrderByIdRequest, ISingleCustomerRequest, ICustomerQueryRequest, ICustomerRequest, IUpdateCustomerRequest, ISingleCartRequest, IUpdateCartRequest, IAddToCartRequest, IRemoveFromCartRequest, ICreateCheckoutRequest, IGetArticleRequest, IBlogArticleRequest, ITrendingArticleRequest, IArticleByHandleRequest, IGraphqlRequest, IFetchRequest } from './models/index.mjs';
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 params - Object containing array of product handles
25
+ * @param options - Request options (headers, timeout, etc.)
26
+ * @returns Promise resolving to array of products
27
+ */
28
+ getProductsByHandles(params: IProductsByHandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
29
+ /**
30
+ * Retrieve product recommendations for a given product
31
+ * Uses platform-specific recommendation algorithms (e.g., Shopify's productRecommendations)
32
+ * @param params - Object containing productId to get recommendations for
33
+ * @param options - Request options (headers, timeout, etc.)
34
+ * @returns Promise resolving to array of recommended products
35
+ */
36
+ getProductRecommendations(params: IProductRecommendationsRequest, options?: IOptionsRequest): Promise<IResponse>;
37
+ /**
38
+ * Retrieve a single collection by ID or handle
39
+ * @param params - Collection identifier (id or handle)
40
+ * @param options - Request options (headers, timeout, etc.)
41
+ * @returns Promise resolving to collection data
42
+ */
43
+ getCollection(params: ISingleCollectionRequest, options?: IOptionsRequest): Promise<IResponse>;
44
+ /**
45
+ * Retrieve multiple collections with filtering and pagination
46
+ * @param params - Query parameters for filtering, sorting, and pagination
47
+ * @param options - Request options (headers, timeout, etc.)
48
+ * @returns Promise resolving to paginated collections response
49
+ */
50
+ getCollections(params: ICollectionQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
51
+ /**
52
+ * Retrieve multiple collections by their handles with individual query parameters
53
+ * Each collection can have its own specific filtering, pagination, and sorting options
54
+ * @param params - Array of collection objects, each containing:
55
+ * - handle: Collection handle (required)
56
+ * - query: Search query string (optional)
57
+ * - after/before: Pagination cursors (optional)
58
+ * - first/last: Number of items to return (optional)
59
+ * - reverse: Sort order reversal (optional)
60
+ * - sortKey: Collection sorting key (optional)
61
+ * - productLimit: Max products per collection (optional)
62
+ * - productSortKey: Product sorting within collection (optional)
63
+ * - productReverse: Product sort order reversal (optional)
64
+ * - filters: Product filtering options including price, availability, type, vendor, tags (optional)
65
+ * @param options - Request options (headers, timeout, etc.)
66
+ * @returns Promise resolving to collections data with individual query results
67
+ * @example
68
+ * ```typescript
69
+ * const result = await client.getCollectionsByHandles([
70
+ * { handle: 'featured', first: 10, sortKey: 'UPDATED_AT' },
71
+ * { handle: 'sale', productLimit: 5, filters: [{ available: true }] }
72
+ * ]);
73
+ * ```
74
+ */
75
+ getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
76
+ /**
77
+ * Retrieve available filters for collections
78
+ * @param params - Collection identifier (id or handle) to get filters for
79
+ * @param options - Request options (headers, timeout, etc.)
80
+ * @returns Promise resolving to available filter options (price ranges, brands, categories, etc.)
81
+ */
82
+ getCollectionFilters(params: ICollectionFilterRequest, options?: IOptionsRequest): Promise<IResponse>;
83
+ /**
84
+ * Retrieve a single order by ID
85
+ * @param params - Order identifier
86
+ * @param options - Request options (headers, timeout, etc.)
87
+ * @returns Promise resolving to order data
88
+ */
89
+ getOrder(params: ISingleOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
90
+ /**
91
+ * Retrieve multiple orders with filtering and pagination
92
+ * @param params - Query parameters for filtering, sorting, and pagination
93
+ * @param options - Request options (headers, timeout, etc.)
94
+ * @returns Promise resolving to paginated orders response
95
+ */
96
+ getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
97
+ /**
98
+ * Create a new order
99
+ * @param params - Order data to create
100
+ * @param options - Request options (headers, timeout, etc.)
101
+ * @returns Promise resolving to created order
102
+ */
103
+ createOrder(params: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
104
+ /**
105
+ * Update an existing order
106
+ * @param params - Object containing id and data to update
107
+ * @param options - Request options (headers, timeout, etc.)
108
+ * @returns Promise resolving to updated order
109
+ */
110
+ updateOrder(params: IUpdateOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
111
+ /**
112
+ * Retrieve order history for a customer
113
+ * @param params - Object containing customerAccessToken, page, and limit
114
+ * @param options - Request options (headers, timeout, etc.)
115
+ * @returns Promise resolving to order history
116
+ */
117
+ getOrderHistory(params: IOrderHistoryRequest, options?: IOptionsRequest): Promise<IResponse>;
118
+ /**
119
+ * Retrieve a specific order for a customer
120
+ * @param params - Object containing customerAccessToken and orderId
121
+ * @param options - Request options (headers, timeout, etc.)
122
+ * @returns Promise resolving to order data
123
+ */
124
+ getOrderById(params: IOrderByIdRequest, options?: IOptionsRequest): Promise<IResponse>;
125
+ /**
126
+ * Retrieve a single customer by ID
127
+ * @param params - Customer identifier
128
+ * @param options - Request options (headers, timeout, etc.)
129
+ * @returns Promise resolving to customer data
130
+ */
131
+ getCustomer(params: ISingleCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
132
+ /**
133
+ * Retrieve multiple customers with filtering and pagination
134
+ * @param params - Query parameters for filtering, sorting, and pagination
135
+ * @param options - Request options (headers, timeout, etc.)
136
+ * @returns Promise resolving to paginated customers response
137
+ */
138
+ getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
139
+ /**
140
+ * Create a new customer account
141
+ * @param params - Customer data to create
142
+ * @param options - Request options (headers, timeout, etc.)
143
+ * @returns Promise resolving to created customer
144
+ */
145
+ createCustomer(params: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
146
+ /**
147
+ * Update an existing customer account
148
+ * @param params - Object containing id and data to update
149
+ * @param options - Request options (headers, timeout, etc.)
150
+ * @returns Promise resolving to updated customer
151
+ */
152
+ updateCustomer(params: IUpdateCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
153
+ /**
154
+ * Retrieve a shopping cart by ID
155
+ * @param params - Cart identifier
156
+ * @param options - Request options (headers, timeout, etc.)
157
+ * @returns Promise resolving to standardized response with cart data
158
+ */
159
+ getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
160
+ /**
161
+ * Create a new shopping cart
162
+ * @param options - Request options (headers, timeout, etc.)
163
+ * @returns Promise resolving to standardized response with created cart
164
+ */
165
+ createCart(options?: IOptionsRequest): Promise<IResponse>;
166
+ /**
167
+ * Update an existing shopping cart
168
+ * @param params - Object containing id and data to update
169
+ * @param options - Request options (headers, timeout, etc.)
170
+ * @returns Promise resolving to standardized response with updated cart
171
+ */
172
+ updateCart(params: IUpdateCartRequest, options?: IOptionsRequest): Promise<IResponse>;
173
+ /**
174
+ * Add items to a shopping cart
175
+ * @param params - Object containing cart id and items to add
176
+ * @param options - Request options (headers, timeout, etc.)
177
+ * @returns Promise resolving to standardized response with updated cart
178
+ */
179
+ addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
180
+ /**
181
+ * Remove items from a shopping cart
182
+ * @param params - Object containing cart id and item IDs to remove
183
+ * @param options - Request options (headers, timeout, etc.)
184
+ * @returns Promise resolving to standardized response with updated cart
185
+ */
186
+ removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
187
+ /**
188
+ * Create a new checkout session
189
+ * @param params - Checkout data
190
+ * @param options - Request options (headers, timeout, etc.)
191
+ * @returns Promise resolving to checkout session
192
+ */
193
+ createCheckout(params: ICreateCheckoutRequest, options?: IOptionsRequest): Promise<IResponse>;
194
+ /**
195
+ * Retrieve a single article
196
+ * @param params - Query parameters for filtering articles
197
+ * @param options - Request options (headers, timeout, etc.)
198
+ * @returns Promise resolving to article data
199
+ */
200
+ getArticle(params?: IGetArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
201
+ /**
202
+ * Retrieve blog articles with optional filtering
203
+ * @param params - Query parameters for category and limit
204
+ * @param options - Request options (headers, timeout, etc.)
205
+ * @returns Promise resolving to articles array
206
+ */
207
+ getBlogArticles(params: IBlogArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
208
+ /**
209
+ * Retrieve trending articles with optional filtering
210
+ * @param params - Query parameters for category
211
+ * @param options - Request options (headers, timeout, etc.)
212
+ * @returns Promise resolving to trending articles
213
+ */
214
+ getTrendingArticles(params: ITrendingArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
215
+ /**
216
+ * Retrieve a specific article by handle
217
+ * @param params - Article parameters including category and handle
218
+ * @param options - Request options (headers, timeout, etc.)
219
+ * @returns Promise resolving to article data
220
+ */
221
+ getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
222
+ /**
223
+ * Utility method to make GraphQL requests
224
+ * @param params - Object containing query string and optional variables
225
+ * @returns Promise resolving to standardized response
226
+ */
227
+ graphqlRequest(params: IGraphqlRequest): Promise<IResponse>;
228
+ /**
229
+ * Utility method to make custom fetch requests to any endpoint
230
+ * @param params - Object containing url and optional fetch options
231
+ * @returns Promise resolving to standardized response
232
+ */
233
+ fetchRequest(params: IFetchRequest): Promise<IResponse>;
234
+ }
235
+
236
+ export type { ICommerceClient as I };
@@ -0,0 +1,236 @@
1
+ import { ISingleProductRequest, IOptionsRequest, IResponse, IProductQueryReqest, IProductsByHandlesRequest, IProductRecommendationsRequest, ISingleCollectionRequest, ICollectionQueryRequest, ICollectionsByhandlesRequest, ICollectionFilterRequest, ISingleOrderRequest, IOrderQueryRequest, IOrderRequest, IUpdateOrderRequest, IOrderHistoryRequest, IOrderByIdRequest, ISingleCustomerRequest, ICustomerQueryRequest, ICustomerRequest, IUpdateCustomerRequest, ISingleCartRequest, IUpdateCartRequest, IAddToCartRequest, IRemoveFromCartRequest, ICreateCheckoutRequest, IGetArticleRequest, IBlogArticleRequest, ITrendingArticleRequest, IArticleByHandleRequest, IGraphqlRequest, IFetchRequest } 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 params - Object containing array of product handles
25
+ * @param options - Request options (headers, timeout, etc.)
26
+ * @returns Promise resolving to array of products
27
+ */
28
+ getProductsByHandles(params: IProductsByHandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
29
+ /**
30
+ * Retrieve product recommendations for a given product
31
+ * Uses platform-specific recommendation algorithms (e.g., Shopify's productRecommendations)
32
+ * @param params - Object containing productId to get recommendations for
33
+ * @param options - Request options (headers, timeout, etc.)
34
+ * @returns Promise resolving to array of recommended products
35
+ */
36
+ getProductRecommendations(params: IProductRecommendationsRequest, options?: IOptionsRequest): Promise<IResponse>;
37
+ /**
38
+ * Retrieve a single collection by ID or handle
39
+ * @param params - Collection identifier (id or handle)
40
+ * @param options - Request options (headers, timeout, etc.)
41
+ * @returns Promise resolving to collection data
42
+ */
43
+ getCollection(params: ISingleCollectionRequest, options?: IOptionsRequest): Promise<IResponse>;
44
+ /**
45
+ * Retrieve multiple collections with filtering and pagination
46
+ * @param params - Query parameters for filtering, sorting, and pagination
47
+ * @param options - Request options (headers, timeout, etc.)
48
+ * @returns Promise resolving to paginated collections response
49
+ */
50
+ getCollections(params: ICollectionQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
51
+ /**
52
+ * Retrieve multiple collections by their handles with individual query parameters
53
+ * Each collection can have its own specific filtering, pagination, and sorting options
54
+ * @param params - Array of collection objects, each containing:
55
+ * - handle: Collection handle (required)
56
+ * - query: Search query string (optional)
57
+ * - after/before: Pagination cursors (optional)
58
+ * - first/last: Number of items to return (optional)
59
+ * - reverse: Sort order reversal (optional)
60
+ * - sortKey: Collection sorting key (optional)
61
+ * - productLimit: Max products per collection (optional)
62
+ * - productSortKey: Product sorting within collection (optional)
63
+ * - productReverse: Product sort order reversal (optional)
64
+ * - filters: Product filtering options including price, availability, type, vendor, tags (optional)
65
+ * @param options - Request options (headers, timeout, etc.)
66
+ * @returns Promise resolving to collections data with individual query results
67
+ * @example
68
+ * ```typescript
69
+ * const result = await client.getCollectionsByHandles([
70
+ * { handle: 'featured', first: 10, sortKey: 'UPDATED_AT' },
71
+ * { handle: 'sale', productLimit: 5, filters: [{ available: true }] }
72
+ * ]);
73
+ * ```
74
+ */
75
+ getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
76
+ /**
77
+ * Retrieve available filters for collections
78
+ * @param params - Collection identifier (id or handle) to get filters for
79
+ * @param options - Request options (headers, timeout, etc.)
80
+ * @returns Promise resolving to available filter options (price ranges, brands, categories, etc.)
81
+ */
82
+ getCollectionFilters(params: ICollectionFilterRequest, options?: IOptionsRequest): Promise<IResponse>;
83
+ /**
84
+ * Retrieve a single order by ID
85
+ * @param params - Order identifier
86
+ * @param options - Request options (headers, timeout, etc.)
87
+ * @returns Promise resolving to order data
88
+ */
89
+ getOrder(params: ISingleOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
90
+ /**
91
+ * Retrieve multiple orders with filtering and pagination
92
+ * @param params - Query parameters for filtering, sorting, and pagination
93
+ * @param options - Request options (headers, timeout, etc.)
94
+ * @returns Promise resolving to paginated orders response
95
+ */
96
+ getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
97
+ /**
98
+ * Create a new order
99
+ * @param params - Order data to create
100
+ * @param options - Request options (headers, timeout, etc.)
101
+ * @returns Promise resolving to created order
102
+ */
103
+ createOrder(params: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
104
+ /**
105
+ * Update an existing order
106
+ * @param params - Object containing id and data to update
107
+ * @param options - Request options (headers, timeout, etc.)
108
+ * @returns Promise resolving to updated order
109
+ */
110
+ updateOrder(params: IUpdateOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
111
+ /**
112
+ * Retrieve order history for a customer
113
+ * @param params - Object containing customerAccessToken, page, and limit
114
+ * @param options - Request options (headers, timeout, etc.)
115
+ * @returns Promise resolving to order history
116
+ */
117
+ getOrderHistory(params: IOrderHistoryRequest, options?: IOptionsRequest): Promise<IResponse>;
118
+ /**
119
+ * Retrieve a specific order for a customer
120
+ * @param params - Object containing customerAccessToken and orderId
121
+ * @param options - Request options (headers, timeout, etc.)
122
+ * @returns Promise resolving to order data
123
+ */
124
+ getOrderById(params: IOrderByIdRequest, options?: IOptionsRequest): Promise<IResponse>;
125
+ /**
126
+ * Retrieve a single customer by ID
127
+ * @param params - Customer identifier
128
+ * @param options - Request options (headers, timeout, etc.)
129
+ * @returns Promise resolving to customer data
130
+ */
131
+ getCustomer(params: ISingleCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
132
+ /**
133
+ * Retrieve multiple customers with filtering and pagination
134
+ * @param params - Query parameters for filtering, sorting, and pagination
135
+ * @param options - Request options (headers, timeout, etc.)
136
+ * @returns Promise resolving to paginated customers response
137
+ */
138
+ getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
139
+ /**
140
+ * Create a new customer account
141
+ * @param params - Customer data to create
142
+ * @param options - Request options (headers, timeout, etc.)
143
+ * @returns Promise resolving to created customer
144
+ */
145
+ createCustomer(params: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
146
+ /**
147
+ * Update an existing customer account
148
+ * @param params - Object containing id and data to update
149
+ * @param options - Request options (headers, timeout, etc.)
150
+ * @returns Promise resolving to updated customer
151
+ */
152
+ updateCustomer(params: IUpdateCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
153
+ /**
154
+ * Retrieve a shopping cart by ID
155
+ * @param params - Cart identifier
156
+ * @param options - Request options (headers, timeout, etc.)
157
+ * @returns Promise resolving to standardized response with cart data
158
+ */
159
+ getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
160
+ /**
161
+ * Create a new shopping cart
162
+ * @param options - Request options (headers, timeout, etc.)
163
+ * @returns Promise resolving to standardized response with created cart
164
+ */
165
+ createCart(options?: IOptionsRequest): Promise<IResponse>;
166
+ /**
167
+ * Update an existing shopping cart
168
+ * @param params - Object containing id and data to update
169
+ * @param options - Request options (headers, timeout, etc.)
170
+ * @returns Promise resolving to standardized response with updated cart
171
+ */
172
+ updateCart(params: IUpdateCartRequest, options?: IOptionsRequest): Promise<IResponse>;
173
+ /**
174
+ * Add items to a shopping cart
175
+ * @param params - Object containing cart id and items to add
176
+ * @param options - Request options (headers, timeout, etc.)
177
+ * @returns Promise resolving to standardized response with updated cart
178
+ */
179
+ addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
180
+ /**
181
+ * Remove items from a shopping cart
182
+ * @param params - Object containing cart id and item IDs to remove
183
+ * @param options - Request options (headers, timeout, etc.)
184
+ * @returns Promise resolving to standardized response with updated cart
185
+ */
186
+ removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
187
+ /**
188
+ * Create a new checkout session
189
+ * @param params - Checkout data
190
+ * @param options - Request options (headers, timeout, etc.)
191
+ * @returns Promise resolving to checkout session
192
+ */
193
+ createCheckout(params: ICreateCheckoutRequest, options?: IOptionsRequest): Promise<IResponse>;
194
+ /**
195
+ * Retrieve a single article
196
+ * @param params - Query parameters for filtering articles
197
+ * @param options - Request options (headers, timeout, etc.)
198
+ * @returns Promise resolving to article data
199
+ */
200
+ getArticle(params?: IGetArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
201
+ /**
202
+ * Retrieve blog articles with optional filtering
203
+ * @param params - Query parameters for category and limit
204
+ * @param options - Request options (headers, timeout, etc.)
205
+ * @returns Promise resolving to articles array
206
+ */
207
+ getBlogArticles(params: IBlogArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
208
+ /**
209
+ * Retrieve trending articles with optional filtering
210
+ * @param params - Query parameters for category
211
+ * @param options - Request options (headers, timeout, etc.)
212
+ * @returns Promise resolving to trending articles
213
+ */
214
+ getTrendingArticles(params: ITrendingArticleRequest, options?: IOptionsRequest): Promise<IResponse>;
215
+ /**
216
+ * Retrieve a specific article by handle
217
+ * @param params - Article parameters including category and handle
218
+ * @param options - Request options (headers, timeout, etc.)
219
+ * @returns Promise resolving to article data
220
+ */
221
+ getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
222
+ /**
223
+ * Utility method to make GraphQL requests
224
+ * @param params - Object containing query string and optional variables
225
+ * @returns Promise resolving to standardized response
226
+ */
227
+ graphqlRequest(params: IGraphqlRequest): Promise<IResponse>;
228
+ /**
229
+ * Utility method to make custom fetch requests to any endpoint
230
+ * @param params - Object containing url and optional fetch options
231
+ * @returns Promise resolving to standardized response
232
+ */
233
+ fetchRequest(params: IFetchRequest): Promise<IResponse>;
234
+ }
235
+
236
+ export type { ICommerceClient as I };
@@ -156,15 +156,29 @@ interface IOptionsRequest {
156
156
  */
157
157
  signal?: AbortSignal;
158
158
  }
159
- interface IFetchOptionsRequest {
159
+ /**
160
+ * Request for GraphQL operations
161
+ */
162
+ interface IGraphqlRequest {
163
+ /** GraphQL query string */
164
+ query: string;
165
+ /** GraphQL variables */
166
+ variables?: Record<string, any>;
167
+ }
168
+ /**
169
+ * Request for custom fetch operations
170
+ */
171
+ interface IFetchRequest {
172
+ /** Target URL for the request */
173
+ url: string;
174
+ /** HTTP method */
160
175
  method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
161
- headers?: HeadersInit;
162
- body?: BodyInit | null;
176
+ /** Request headers */
177
+ headers?: Record<string, string>;
178
+ /** Request body */
179
+ body?: any;
180
+ /** AbortSignal for request cancellation */
163
181
  signal?: AbortSignal;
164
- credentials?: "omit" | "same-origin" | "include";
165
- mode?: RequestMode;
166
- cache?: RequestCache;
167
- keepalive?: boolean;
168
182
  [key: string]: any;
169
183
  }
170
184
 
@@ -268,6 +282,29 @@ interface ISingleProductRequest {
268
282
  id?: string | number;
269
283
  handle?: string;
270
284
  }
285
+ /**
286
+ * Common interface for batch product requests by handles
287
+ * Supports retrieving multiple products by their handles
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * {
292
+ * "handles": ["product-a", "product-b"],
293
+ * "first": 10
294
+ * }
295
+ * ```
296
+ */
297
+ interface IProductsByHandlesRequest extends IProductQueryReqest {
298
+ /** Array of product handles to retrieve */
299
+ handles: string[];
300
+ }
301
+ /**
302
+ * Request for product recommendations
303
+ */
304
+ interface IProductRecommendationsRequest {
305
+ /** Product ID or handle to get recommendations for */
306
+ productId: string;
307
+ }
271
308
  /**
272
309
  * Parameters for querying collections
273
310
  *
@@ -490,60 +527,6 @@ interface IUpdateCartRequest {
490
527
  /**
491
528
  * Checkout data models for the commerce library
492
529
  */
493
-
494
- /**
495
- * Request to update a checkout
496
- */
497
- interface ICheckoutUpdateRequest {
498
- email?: string;
499
- phone?: string;
500
- shippingAddress?: IAddress;
501
- billingAddress?: IAddress;
502
- shippingMethodId?: string;
503
- paymentMethodId?: string;
504
- discountCodes?: string[];
505
- note?: string;
506
- customAttributes?: Array<{
507
- key: string;
508
- value: string;
509
- }>;
510
- }
511
- /**
512
- * Payment data for different payment methods
513
- */
514
- interface IPaymentRequest {
515
- creditCard?: {
516
- number: string;
517
- expiryMonth: string;
518
- expiryYear: string;
519
- cvv: string;
520
- holderName: string;
521
- };
522
- paypal?: {
523
- payerId: string;
524
- paymentId: string;
525
- };
526
- applePay?: {
527
- token: string;
528
- };
529
- googlePay?: {
530
- token: string;
531
- };
532
- bankTransfer?: {
533
- accountNumber: string;
534
- routingNumber: string;
535
- accountHolderName: string;
536
- };
537
- }
538
- /**
539
- * Request to process a payment
540
- */
541
- interface IPaymentRequest {
542
- paymentMethodId: string;
543
- paymentData?: IPaymentRequest;
544
- billingAddress?: IAddress;
545
- savePaymentMethod?: boolean;
546
- }
547
530
  /**
548
531
  * Request to create a checkout
549
532
  */
@@ -595,4 +578,4 @@ interface IGetArticleRequest {
595
578
  reverse?: boolean;
596
579
  }
597
580
 
598
- export { EAvailability, ECollectionSortKey, EFulfillmentStatus, EOrderSortKey, EOrderStatus, EPaymentStatus, EProductSortKey, type IAddToCartRequest, type IAddress, type IArticleByHandleRequest, type IBaseQueryParams, type IBlogArticleRequest, type ICartItemRequest, type ICheckoutUpdateRequest, type ICollectionFilterRequest, type ICollectionQueryRequest, type ICollectionsByhandlesRequest, type ICreateCheckoutRequest, type ICustomerQueryRequest, type ICustomerRequest, type IFetchOptionsRequest, type IGetArticleRequest, type IImage, type IMetafield, type IMoney, type IOptionsRequest, type IOrderByIdRequest, type IOrderHistoryRequest, type IOrderQueryRequest, type IOrderRequest, type IPaginationParams, type IPaymentRequest, type IProductFilters, type IProductQueryReqest, type IRemoveFromCartRequest, type IResponse, type IResponseMeta, type ISeo, type ISingleCartRequest, type ISingleCollectionRequest, type ISingleCustomerRequest, type ISingleOrderRequest, type ISingleProductRequest, type ITrendingArticleRequest, type IUpdateCartRequest, type IUpdateCustomerRequest, type IUpdateOrderRequest };
581
+ export { EAvailability, ECollectionSortKey, EFulfillmentStatus, EOrderSortKey, EOrderStatus, EPaymentStatus, EProductSortKey, type IAddToCartRequest, type IAddress, type IArticleByHandleRequest, type IBaseQueryParams, type IBlogArticleRequest, type ICartItemRequest, type ICollectionFilterRequest, type ICollectionQueryRequest, type ICollectionsByhandlesRequest, type ICreateCheckoutRequest, type ICustomerQueryRequest, type ICustomerRequest, type IFetchRequest, type IGetArticleRequest, type IGraphqlRequest, type IImage, type IMetafield, type IMoney, type IOptionsRequest, type IOrderByIdRequest, type IOrderHistoryRequest, type IOrderQueryRequest, type IOrderRequest, type IPaginationParams, type IProductFilters, type IProductQueryReqest, type IProductRecommendationsRequest, type IProductsByHandlesRequest, type IRemoveFromCartRequest, type IResponse, type IResponseMeta, type ISeo, type ISingleCartRequest, type ISingleCollectionRequest, type ISingleCustomerRequest, type ISingleOrderRequest, type ISingleProductRequest, type ITrendingArticleRequest, type IUpdateCartRequest, type IUpdateCustomerRequest, type IUpdateOrderRequest };