@shopkit/data-layer 1.0.0 → 1.1.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.
@@ -1,4 +1,4 @@
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.mjs';
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
2
 
3
3
  /**
4
4
  * Core interface that all platform adapters will implement
@@ -21,11 +21,19 @@ interface ICommerceClient {
21
21
  getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
22
22
  /**
23
23
  * Retrieve multiple products by their handles
24
- * @param handles - Array of product handles
24
+ * @param params - Object containing array of product handles
25
25
  * @param options - Request options (headers, timeout, etc.)
26
26
  * @returns Promise resolving to array of products
27
27
  */
28
- getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
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>;
29
37
  /**
30
38
  * Retrieve a single collection by ID or handle
31
39
  * @param params - Collection identifier (id or handle)
@@ -58,13 +66,13 @@ interface ICommerceClient {
58
66
  * @returns Promise resolving to collections data with individual query results
59
67
  * @example
60
68
  * ```typescript
61
- * const result = await client.getCollectionsByHandels([
69
+ * const result = await client.getCollectionsByHandles([
62
70
  * { handle: 'featured', first: 10, sortKey: 'UPDATED_AT' },
63
71
  * { handle: 'sale', productLimit: 5, filters: [{ available: true }] }
64
72
  * ]);
65
73
  * ```
66
74
  */
67
- getCollectionsByHandels(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
75
+ getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
68
76
  /**
69
77
  * Retrieve available filters for collections
70
78
  * @param params - Collection identifier (id or handle) to get filters for
@@ -88,11 +96,11 @@ interface ICommerceClient {
88
96
  getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
89
97
  /**
90
98
  * Create a new order
91
- * @param data - Order data to create
99
+ * @param params - Order data to create
92
100
  * @param options - Request options (headers, timeout, etc.)
93
101
  * @returns Promise resolving to created order
94
102
  */
95
- createOrder(data: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
103
+ createOrder(params: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
96
104
  /**
97
105
  * Update an existing order
98
106
  * @param params - Object containing id and data to update
@@ -130,11 +138,11 @@ interface ICommerceClient {
130
138
  getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
131
139
  /**
132
140
  * Create a new customer account
133
- * @param data - Customer data to create
141
+ * @param params - Customer data to create
134
142
  * @param options - Request options (headers, timeout, etc.)
135
143
  * @returns Promise resolving to created customer
136
144
  */
137
- createCustomer(data: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
145
+ createCustomer(params: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
138
146
  /**
139
147
  * Update an existing customer account
140
148
  * @param params - Object containing id and data to update
@@ -213,24 +221,16 @@ interface ICommerceClient {
213
221
  getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
214
222
  /**
215
223
  * Utility method to make GraphQL requests
216
- * @param query - GraphQL query string
217
- * @param variables - GraphQL variables
218
- * @param options - Request options
224
+ * @param params - Object containing query string and optional variables
219
225
  * @returns Promise resolving to standardized response
220
226
  */
221
- graphqlRequest(query: string, variables?: Record<string, any>): Promise<IResponse>;
227
+ graphqlRequest(params: IGraphqlRequest): Promise<IResponse>;
222
228
  /**
223
229
  * Utility method to make custom fetch requests to any endpoint
224
- * @param url - Target URL for the request
225
- * @param options - Request options
230
+ * @param params - Object containing url and optional fetch options
226
231
  * @returns Promise resolving to standardized response
227
232
  */
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>;
233
+ fetchRequest(params: IFetchRequest): Promise<IResponse>;
234
234
  }
235
235
 
236
236
  /**
@@ -320,12 +320,21 @@ declare abstract class BaseCommerceClient implements ICommerceClient {
320
320
  getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
321
321
  /**
322
322
  * Retrieve multiple products by their handles
323
- * @param handles - Array of product handles
323
+ * @param params - Object containing array of product handles
324
324
  * @param options - Request options (headers, timeout, etc.)
325
325
  * @returns Promise resolving to array of products
326
326
  * @throws NotImplementedError if not implemented in adapter
327
327
  */
328
- getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
328
+ getProductsByHandles(params: IProductsByHandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
329
+ /**
330
+ * Retrieve product recommendations for a given product
331
+ * Uses platform-specific recommendation algorithms (e.g., Shopify's productRecommendations)
332
+ * @param productId - Product ID or handle to get recommendations for
333
+ * @param options - Request options (headers, timeout, etc.)
334
+ * @returns Promise resolving to array of recommended products
335
+ * @throws NotImplementedError if not implemented in adapter
336
+ */
337
+ getProductRecommendations(params: IProductRecommendationsRequest, options?: IOptionsRequest): Promise<IResponse>;
329
338
  /**
330
339
  * Retrieve a single collection by ID or handle
331
340
  * @param params - Collection identifier (id or handle)
@@ -360,7 +369,7 @@ declare abstract class BaseCommerceClient implements ICommerceClient {
360
369
  * @returns Promise resolving to collections data with individual query results
361
370
  * @throws NotImplementedError if not implemented in adapter
362
371
  */
363
- getCollectionsByHandels(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
372
+ getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
364
373
  /**
365
374
  * Retrieve available filters for collections
366
375
  * @param params - Collection identifier (id or handle) to get filters for
@@ -387,12 +396,12 @@ declare abstract class BaseCommerceClient implements ICommerceClient {
387
396
  getOrders(params: IOrderQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
388
397
  /**
389
398
  * Create a new order
390
- * @param data - Order data to create
399
+ * @param params - Order data to create
391
400
  * @param options - Request options (headers, timeout, etc.)
392
401
  * @returns Promise resolving to created order
393
402
  * @throws NotImplementedError if not implemented in adapter
394
403
  */
395
- createOrder(data: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
404
+ createOrder(params: IOrderRequest, options?: IOptionsRequest): Promise<IResponse>;
396
405
  /**
397
406
  * Update an existing order
398
407
  * @param params - Object containing id and data to update
@@ -435,12 +444,12 @@ declare abstract class BaseCommerceClient implements ICommerceClient {
435
444
  getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
436
445
  /**
437
446
  * Create a new customer account
438
- * @param data - Customer data to create
447
+ * @param params - Customer data to create
439
448
  * @param options - Request options (headers, timeout, etc.)
440
449
  * @returns Promise resolving to created customer
441
450
  * @throws NotImplementedError if not implemented in adapter
442
451
  */
443
- createCustomer(data: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
452
+ createCustomer(params: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
444
453
  /**
445
454
  * Update an existing customer account
446
455
  * @param params - Object containing id and data to update
@@ -496,24 +505,6 @@ declare abstract class BaseCommerceClient implements ICommerceClient {
496
505
  * @throws NotImplementedError if not implemented in adapter
497
506
  */
498
507
  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
508
  /**
518
509
  * Retrieve a single article
519
510
  * @param params - Query parameters for filtering articles
@@ -548,19 +539,17 @@ declare abstract class BaseCommerceClient implements ICommerceClient {
548
539
  getArticleByHandle(params: IArticleByHandleRequest, options?: IOptionsRequest): Promise<IResponse>;
549
540
  /**
550
541
  * Utility method to make GraphQL requests
551
- * @param query - GraphQL query string
552
- * @param variables - GraphQL variables
542
+ * @param params - Object containing query string and optional variables
553
543
  * @returns Promise resolving to standardized response
554
544
  * @throws NotImplementedError if not implemented in adapter
555
545
  */
556
- graphqlRequest(query: string, variables?: Record<string, any>): Promise<IResponse>;
546
+ graphqlRequest(params: IGraphqlRequest): Promise<IResponse>;
557
547
  /**
558
548
  * Utility method to make custom fetch requests to any endpoint
559
- * @param url - Target URL for the request
560
- * @param options - Request options
549
+ * @param params - Object containing url and optional fetch options
561
550
  * @returns Promise resolving to standardized response
562
551
  */
563
- fetchRequest(url: string, fetchOptions?: IFetchOptionsRequest): Promise<IResponse>;
552
+ fetchRequest(params: IFetchRequest): Promise<IResponse>;
564
553
  }
565
554
 
566
555
  /**
@@ -592,7 +581,12 @@ declare class ShopifyCommerceClient extends BaseCommerceClient {
592
581
  /**
593
582
  * Get multiple products by their handles using batch query
594
583
  */
595
- getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
584
+ getProductsByHandles(params: IProductsByHandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
585
+ /**
586
+ * Get product recommendations for a given product
587
+ * Uses Shopify's productRecommendations API
588
+ */
589
+ getProductRecommendations(params: IProductRecommendationsRequest, options?: IOptionsRequest): Promise<IResponse>;
596
590
  /**
597
591
  * Get collections based on query parameters
598
592
  */
@@ -601,17 +595,16 @@ declare class ShopifyCommerceClient extends BaseCommerceClient {
601
595
  * Get a collection by ID
602
596
  */
603
597
  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
598
  /**
612
599
  * Get multiple collections by their handles (preferred method name)
613
600
  */
614
601
  getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
602
+ /**
603
+ * Get collection filters (available filter options for a collection)
604
+ */
605
+ getCollectionFilters(params: {
606
+ handle: string;
607
+ }, options?: IOptionsRequest): Promise<IResponse>;
615
608
  /**
616
609
  * Create a new cart
617
610
  */
@@ -663,7 +656,7 @@ declare class ShopifyCommerceClient extends BaseCommerceClient {
663
656
  /**
664
657
  * Utility method to make GraphQL requests using Shopify client
665
658
  */
666
- graphqlRequest(query: string, variables?: Record<string, any>): Promise<IResponse>;
659
+ graphqlRequest(params: IGraphqlRequest): Promise<IResponse>;
667
660
  }
668
661
 
669
662
  /**
@@ -709,7 +702,7 @@ declare class CustomBackendClient extends BaseCommerceClient {
709
702
  constructor(config: ICustomConfig, logging?: LoggerConfig);
710
703
  getProduct(params: ISingleProductRequest, options?: IOptionsRequest): Promise<IResponse>;
711
704
  getProducts(params: IProductQueryReqest, options?: IOptionsRequest): Promise<IResponse>;
712
- getProductsByHandles(handles: string[], options?: IOptionsRequest): Promise<IResponse>;
705
+ getProductsByHandles(params: IProductsByHandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
713
706
  /**
714
707
  * Get collections based on query parameters
715
708
  */
@@ -725,7 +718,7 @@ declare class CustomBackendClient extends BaseCommerceClient {
725
718
  * @param options - Request options (headers, timeout, etc.)
726
719
  * @returns Promise resolving to collections data with individual query results
727
720
  */
728
- getCollectionsByHandels(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
721
+ getCollectionsByHandles(params: ICollectionsByhandlesRequest, options?: IOptionsRequest): Promise<IResponse>;
729
722
  getCollectionFilters(params: ICollectionFilterRequest, options?: IOptionsRequest): Promise<IResponse>;
730
723
  getCart(params: ISingleCartRequest, options?: IOptionsRequest): Promise<IResponse>;
731
724
  createCart(options?: IOptionsRequest): Promise<IResponse>;
@@ -733,8 +726,6 @@ declare class CustomBackendClient extends BaseCommerceClient {
733
726
  addToCart(params: IAddToCartRequest, options?: IOptionsRequest): Promise<IResponse>;
734
727
  removeFromCart(params: IRemoveFromCartRequest, options?: IOptionsRequest): Promise<IResponse>;
735
728
  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
729
  getCustomer(params: ISingleCustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
739
730
  getCustomers(params: ICustomerQueryRequest, options?: IOptionsRequest): Promise<IResponse>;
740
731
  createCustomer(params: ICustomerRequest, options?: IOptionsRequest): Promise<IResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopkit/data-layer",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Enterprise data abstraction layer providing unified API for e-commerce platforms including Shopify and custom backends",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",