@adtrackify/at-service-common 3.1.4 → 3.1.5

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.
Files changed (57) hide show
  1. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.d.ts +1 -0
  2. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.js +109 -0
  3. package/dist/cjs/clients/third-party/shopify/graphql-product-queries.js.map +1 -0
  4. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.d.ts +9 -0
  5. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js +97 -0
  6. package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js.map +1 -0
  7. package/dist/cjs/clients/third-party/shopify-client.d.ts +0 -2
  8. package/dist/cjs/clients/third-party/shopify-client.js +0 -127
  9. package/dist/cjs/clients/third-party/shopify-client.js.map +1 -1
  10. package/dist/cjs/services/cache/product-cache-service.d.ts +9 -0
  11. package/dist/cjs/services/cache/product-cache-service.js +32 -0
  12. package/dist/cjs/services/cache/product-cache-service.js.map +1 -0
  13. package/dist/cjs/services/db/shopify-products-cache-db-service.d.ts +0 -11
  14. package/dist/cjs/services/db/shopify-products-cache-db-service.js +0 -43
  15. package/dist/cjs/services/db/shopify-products-cache-db-service.js.map +1 -1
  16. package/dist/cjs/services/generic-cache-service.d.ts +8 -0
  17. package/dist/cjs/services/generic-cache-service.js +31 -0
  18. package/dist/cjs/services/generic-cache-service.js.map +1 -0
  19. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.d.ts +7 -0
  20. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js +48 -0
  21. package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js.map +1 -0
  22. package/dist/cjs/services/shopify/shopify-graphql-transformer.d.ts +6 -0
  23. package/dist/cjs/services/shopify/shopify-graphql-transformer.js +80 -0
  24. package/dist/cjs/services/shopify/shopify-graphql-transformer.js.map +1 -0
  25. package/dist/cjs/services/shopify/types/product.d.ts +83 -0
  26. package/dist/cjs/services/shopify/types/product.js +10 -0
  27. package/dist/cjs/services/shopify/types/product.js.map +1 -0
  28. package/dist/cjs/types/shopify-graphql-types/admin.generated.d.ts +4 -1
  29. package/dist/esm/clients/third-party/shopify/graphql-product-queries.d.ts +1 -0
  30. package/dist/esm/clients/third-party/shopify/graphql-product-queries.js +106 -0
  31. package/dist/esm/clients/third-party/shopify/graphql-product-queries.js.map +1 -0
  32. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.d.ts +9 -0
  33. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js +93 -0
  34. package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js.map +1 -0
  35. package/dist/esm/clients/third-party/shopify-client.d.ts +0 -2
  36. package/dist/esm/clients/third-party/shopify-client.js +0 -127
  37. package/dist/esm/clients/third-party/shopify-client.js.map +1 -1
  38. package/dist/esm/services/cache/product-cache-service.d.ts +9 -0
  39. package/dist/esm/services/cache/product-cache-service.js +28 -0
  40. package/dist/esm/services/cache/product-cache-service.js.map +1 -0
  41. package/dist/esm/services/db/shopify-products-cache-db-service.d.ts +0 -11
  42. package/dist/esm/services/db/shopify-products-cache-db-service.js +0 -43
  43. package/dist/esm/services/db/shopify-products-cache-db-service.js.map +1 -1
  44. package/dist/esm/services/generic-cache-service.d.ts +8 -0
  45. package/dist/esm/services/generic-cache-service.js +27 -0
  46. package/dist/esm/services/generic-cache-service.js.map +1 -0
  47. package/dist/esm/services/shopify/products/shopify-products-serviceV2.d.ts +7 -0
  48. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js +44 -0
  49. package/dist/esm/services/shopify/products/shopify-products-serviceV2.js.map +1 -0
  50. package/dist/esm/services/shopify/shopify-graphql-transformer.d.ts +6 -0
  51. package/dist/esm/services/shopify/shopify-graphql-transformer.js +77 -0
  52. package/dist/esm/services/shopify/shopify-graphql-transformer.js.map +1 -0
  53. package/dist/esm/services/shopify/types/product.d.ts +83 -0
  54. package/dist/esm/services/shopify/types/product.js +7 -0
  55. package/dist/esm/services/shopify/types/product.js.map +1 -0
  56. package/dist/esm/types/shopify-graphql-types/admin.generated.d.ts +4 -1
  57. package/package.json +1 -1
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShopifyProductsServiceV2 = void 0;
4
+ const helpers_1 = require("../../../helpers");
5
+ const product_cache_service_1 = require("../../cache/product-cache-service");
6
+ const shopify_graphql_transformer_1 = require("../shopify-graphql-transformer");
7
+ const shopify_graphql_client_1 = require("../../../clients/third-party/shopify/shopify-graphql-client");
8
+ class ShopifyProductsServiceV2 {
9
+ productCacheService;
10
+ constructor(cacheLambdaFunctionArn) {
11
+ this.productCacheService = new product_cache_service_1.ProductCacheService(cacheLambdaFunctionArn);
12
+ }
13
+ getShopifyProduct = async (pixelId, shop, accessToken, productId, useCache = true, updateCache = true) => {
14
+ try {
15
+ let product = null;
16
+ if (useCache) {
17
+ product = await this.productCacheService.getProductFromCache(pixelId, productId);
18
+ if (product) {
19
+ return product;
20
+ }
21
+ }
22
+ product = await this.getShopifyProductFromAPI(pixelId, shop, accessToken, productId, true);
23
+ if (product && updateCache) {
24
+ await this.productCacheService.putProductInCache(pixelId, productId, product);
25
+ }
26
+ return product;
27
+ }
28
+ catch (error) {
29
+ helpers_1.Logger.error('Failed getShopifyProductWithCachingGraphQL', { error });
30
+ return null;
31
+ }
32
+ };
33
+ getShopifyProductFromAPI = async (pixelId, shop, accessToken, productId, useTransformer = true) => {
34
+ try {
35
+ const product = await shopify_graphql_client_1.ShopifyGraphQLClient.getProductWithVariantsGraphQL(shop, accessToken, productId, 100);
36
+ if (product) {
37
+ return useTransformer ? shopify_graphql_transformer_1.ShopifyGraphQLTransformer.transformToInternalProduct(product) : product;
38
+ }
39
+ return null;
40
+ }
41
+ catch (error) {
42
+ helpers_1.Logger.error('Failed getShopifyProductFromAPI', { e: error, pixelId, shop, accessToken, productId, useTransformer, error });
43
+ return null;
44
+ }
45
+ };
46
+ }
47
+ exports.ShopifyProductsServiceV2 = ShopifyProductsServiceV2;
48
+ //# sourceMappingURL=shopify-products-serviceV2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopify-products-serviceV2.js","sourceRoot":"","sources":["../../../../../src/services/shopify/products/shopify-products-serviceV2.ts"],"names":[],"mappings":";;;AAAA,8CAA0C;AAG1C,6EAAwE;AACxE,gFAA2E;AAC3E,wGAAmG;AAEnG,MAAa,wBAAwB;IAE3B,mBAAmB,CAAsB;IACjD,YAAY,sBAA8B;QACxC,IAAI,CAAC,mBAAmB,GAAG,IAAI,2CAAmB,CAAC,sBAAsB,CAAC,CAAC;IAC7E,CAAC;IAEM,iBAAiB,GAAG,KAAK,EAAE,OAAe,EAAE,IAAY,EAAE,WAAmB,EAAE,SAAiB,EAAE,QAAQ,GAAG,IAAI,EAAE,WAAW,GAAG,IAAI,EAA+C,EAAE;QAC3L,IAAI;YACF,IAAI,OAAO,GAAuC,IAAI,CAAC;YACvD,IAAI,QAAQ,EAAE;gBACZ,OAAO,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;gBACjF,IAAI,OAAO,EAAE;oBACX,OAAO,OAAO,CAAC;iBAChB;aACF;YAED,OAAO,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,CAAoB,CAAC;YAC9G,IAAI,OAAO,IAAI,WAAW,EAAE;gBAC1B,MAAM,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;aAC/E;YACD,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,KAAK,EAAE;YACd,gBAAM,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC;IAEM,wBAAwB,GAAG,KAAK,EAAE,OAAe,EAAE,IAAY,EAAE,WAAmB,EAAE,SAAiB,EAAE,cAAc,GAAG,IAAI,EAAkE,EAAE;QACxM,IAAI;YACF,MAAM,OAAO,GAAG,MAAM,6CAAoB,CAAC,6BAA6B,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;YAC5G,IAAI,OAAO,EAAE;gBACX,OAAO,cAAc,CAAC,CAAC,CAAC,uDAAyB,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;aACjG;YACD,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAK,EAAE;YACd,gBAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;YAC5H,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAA;CAGF;AA1CD,4DA0CC"}
@@ -0,0 +1,6 @@
1
+ import { Product, ProductVariant } from '../../types/shopify-graphql-types/admin.types';
2
+ import { InternalProduct, InternalProductVariant } from './types/product';
3
+ export declare const ShopifyGraphQLTransformer: {
4
+ transformToInternalProduct: (product: Partial<Product>) => InternalProduct | undefined;
5
+ transformToInternalProductVariant: (variant: Partial<ProductVariant>) => InternalProductVariant | undefined;
6
+ };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ShopifyGraphQLTransformer = void 0;
4
+ exports.ShopifyGraphQLTransformer = {
5
+ transformToInternalProduct: (product) => {
6
+ if (!product)
7
+ return undefined;
8
+ const internalProduct = {
9
+ id: product?.id,
10
+ legacyResourceId: Number(product.legacyResourceId),
11
+ title: product.title,
12
+ description: product.description,
13
+ handle: product?.handle,
14
+ productType: product?.productType,
15
+ vendor: product.vendor,
16
+ status: product.status,
17
+ createdAt: product.createdAt,
18
+ updatedAt: product.updatedAt,
19
+ publishedAt: product.publishedAt,
20
+ hasOnlyDefaultVariant: product?.hasOnlyDefaultVariant ?? false,
21
+ hasOutOfStockVariants: product?.hasOutOfStockVariants ?? false,
22
+ hasVariantsThatRequiresComponents: product?.hasVariantsThatRequiresComponents ?? false,
23
+ isGiftCard: product?.isGiftCard ?? false,
24
+ onlineStoreUrl: product.onlineStoreUrl,
25
+ tags: product.tags || [],
26
+ totalInventory: product.totalInventory || 0,
27
+ tracksInventory: product.tracksInventory || false,
28
+ featuredImageUrl: product.featuredImage?.url,
29
+ images: product.images?.nodes?.map(image => image.url) || [],
30
+ variantsCount: product?.variantsCount?.count,
31
+ maxVariantCompareAtPrice: Number(product.compareAtPriceRange?.maxVariantCompareAtPrice?.amount || 0),
32
+ minVariantCompareAtPrice: Number(product.compareAtPriceRange?.minVariantCompareAtPrice?.amount || 0),
33
+ maxVariantPrice: Number(product.priceRangeV2?.maxVariantPrice?.amount || 0),
34
+ minVariantPrice: Number(product.priceRangeV2?.minVariantPrice?.amount || 0),
35
+ variants: product?.variants?.nodes
36
+ ?.map(variant => exports.ShopifyGraphQLTransformer.transformToInternalProductVariant(variant))
37
+ .filter(variant => variant !== undefined) || [],
38
+ category: product.category ? {
39
+ id: product.category.id,
40
+ name: product.category.name,
41
+ fullName: product.category.fullName,
42
+ ancestorIds: product.category.ancestorIds,
43
+ childrenIds: product.category.childrenIds,
44
+ } : undefined,
45
+ };
46
+ return internalProduct;
47
+ },
48
+ transformToInternalProductVariant: (variant) => {
49
+ if (!variant)
50
+ return undefined;
51
+ const internalVariant = {
52
+ availableForSale: variant.availableForSale || false,
53
+ id: variant.id,
54
+ legacyResourceId: variant?.legacyResourceId,
55
+ title: variant.title,
56
+ displayName: variant.displayName,
57
+ sku: variant?.sku,
58
+ barcode: variant?.barcode,
59
+ price: variant.price,
60
+ amount: Number(variant.price || 0),
61
+ compareAtPrice: variant.compareAtPrice,
62
+ createdAt: variant.createdAt,
63
+ updatedAt: variant.updatedAt,
64
+ position: variant.position || 0,
65
+ inventoryQuantity: variant?.inventoryQuantity,
66
+ sellableOnlineQuantity: variant.sellableOnlineQuantity || 0,
67
+ taxable: variant.taxable || false,
68
+ taxCode: variant?.taxCode,
69
+ productId: variant.product?.id || '',
70
+ legacyProductResourceId: Number(variant.product?.legacyResourceId || 0),
71
+ featuredImageUrl: variant.image?.url,
72
+ selectedOptions: variant.selectedOptions?.map(option => ({
73
+ name: option.name,
74
+ value: option.value
75
+ })) || [],
76
+ };
77
+ return internalVariant;
78
+ },
79
+ };
80
+ //# sourceMappingURL=shopify-graphql-transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopify-graphql-transformer.js","sourceRoot":"","sources":["../../../../src/services/shopify/shopify-graphql-transformer.ts"],"names":[],"mappings":";;;AAKa,QAAA,yBAAyB,GAAG;IAEvC,0BAA0B,EAAE,CAAC,OAAyB,EAA+B,EAAE;QACrF,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAE/B,MAAM,eAAe,GAAoB;YACvC,EAAE,EAAE,OAAO,EAAE,EAAY;YACzB,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC;YAClD,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM,EAAE,OAAO,EAAE,MAAgB;YACjC,WAAW,EAAE,OAAO,EAAE,WAAqB;YAC3C,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM,EAAE,OAAO,CAAC,MAAyC;YACzD,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,qBAAqB,EAAE,OAAO,EAAE,qBAAqB,IAAI,KAAK;YAC9D,qBAAqB,EAAE,OAAO,EAAE,qBAAqB,IAAI,KAAK;YAC9D,iCAAiC,EAAE,OAAO,EAAE,iCAAiC,IAAI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EAAE,OAAO,CAAC,KAAK,EAAE,GAAG;YACpC,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBACvD,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAC,IAAI,EAAE;SACV,CAAC;QACF,OAAO,eAAe,CAAC;IACzB,CAAC;CACF,CAAA"}
@@ -0,0 +1,83 @@
1
+ export interface InternalProductOption {
2
+ name: string;
3
+ value: string;
4
+ }
5
+ export interface InternalProductCollection {
6
+ id: string;
7
+ legacyResourceId: number;
8
+ title: string;
9
+ handle: string;
10
+ imageUrl?: string;
11
+ productsCount?: number;
12
+ }
13
+ export interface InteralProductCategory {
14
+ id: string;
15
+ name: string;
16
+ fullName: string;
17
+ ancestorIds?: string[];
18
+ childrenIds?: string[];
19
+ productsCount?: number;
20
+ }
21
+ export declare enum InternalProductStatus {
22
+ Active = "ACTIVE",
23
+ Archived = "ARCHIVED",
24
+ Draft = "DRAFT"
25
+ }
26
+ export interface InternalProduct {
27
+ __typename?: 'Product';
28
+ category?: InteralProductCategory;
29
+ collections?: InternalProductCollection[];
30
+ maxVariantCompareAtPrice?: number;
31
+ minVariantCompareAtPrice?: number;
32
+ createdAt?: string;
33
+ description?: string;
34
+ featuredImageUrl?: string;
35
+ handle?: string;
36
+ hasOnlyDefaultVariant?: boolean;
37
+ hasOutOfStockVariants?: boolean;
38
+ hasVariantsThatRequiresComponents?: boolean;
39
+ id?: string;
40
+ legacyResourceId: number;
41
+ images?: string[];
42
+ inCollection?: boolean;
43
+ isGiftCard?: boolean;
44
+ onlineStoreUrl?: string;
45
+ minVariantPrice?: number;
46
+ maxVariantPrice?: number;
47
+ productType?: string;
48
+ publishedAt?: string;
49
+ status?: InternalProductStatus;
50
+ tags?: Array<string>;
51
+ title?: string;
52
+ totalInventory?: number;
53
+ tracksInventory?: boolean;
54
+ updatedAt?: string;
55
+ variantsCount?: number;
56
+ vendor?: string;
57
+ variants?: InternalProductVariant[];
58
+ }
59
+ export interface InternalProductVariant {
60
+ availableForSale: boolean;
61
+ barcode?: string;
62
+ compareAtPrice?: string;
63
+ createdAt: string;
64
+ displayName?: string;
65
+ id?: string;
66
+ featuredImageUrl?: string;
67
+ inventoryQuantity?: number;
68
+ legacyResourceId: number;
69
+ position: number;
70
+ price: string;
71
+ currency?: string;
72
+ amount: number;
73
+ productId?: string;
74
+ legacyProductResourceId: number;
75
+ selectedOptions?: InternalProductOption[];
76
+ sellableOnlineQuantity: number;
77
+ sellingPlanGroupsCount?: number;
78
+ sku?: string;
79
+ taxCode?: string;
80
+ taxable?: boolean;
81
+ title?: string;
82
+ updatedAt?: string;
83
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalProductStatus = void 0;
4
+ var InternalProductStatus;
5
+ (function (InternalProductStatus) {
6
+ InternalProductStatus["Active"] = "ACTIVE";
7
+ InternalProductStatus["Archived"] = "ARCHIVED";
8
+ InternalProductStatus["Draft"] = "DRAFT";
9
+ })(InternalProductStatus = exports.InternalProductStatus || (exports.InternalProductStatus = {}));
10
+ //# sourceMappingURL=product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../../../../src/services/shopify/types/product.ts"],"names":[],"mappings":";;;AAuBA,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAE/B,0CAAiB,CAAA;IAEjB,8CAAqB,CAAA;IAErB,wCAAe,CAAA;AACjB,CAAC,EAPW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAOhC"}
@@ -1,6 +1,8 @@
1
1
  import * as AdminTypes from './admin.types';
2
2
  export type GetProductQueryVariables = AdminTypes.Exact<{
3
3
  id: AdminTypes.Scalars['ID']['input'];
4
+ first: AdminTypes.Scalars['Int']['input'];
5
+ after?: AdminTypes.InputMaybe<AdminTypes.Scalars['String']['input']>;
4
6
  }>;
5
7
  export type GetProductQuery = {
6
8
  product?: AdminTypes.Maybe<(Pick<AdminTypes.Product, 'id' | 'handle' | 'productType' | 'hasOnlyDefaultVariant' | 'isGiftCard' | 'legacyResourceId' | 'onlineStoreUrl' | 'publishedAt' | 'requiresSellingPlan' | 'status' | 'tags' | 'title' | 'totalInventory' | 'tracksInventory' | 'vendor' | 'createdAt' | 'updatedAt'> & {
@@ -11,6 +13,7 @@ export type GetProductQuery = {
11
13
  variantsCount?: AdminTypes.Maybe<Pick<AdminTypes.Count, 'count'>>;
12
14
  seo: Pick<AdminTypes.Seo, 'title' | 'description'>;
13
15
  variants: {
16
+ pageInfo: Pick<AdminTypes.PageInfo, 'hasNextPage' | 'endCursor'>;
14
17
  nodes: Array<(Pick<AdminTypes.ProductVariant, 'availableForSale' | 'barcode' | 'compareAtPrice' | 'createdAt' | 'displayName' | 'id' | 'inventoryQuantity' | 'price' | 'sellableOnlineQuantity' | 'sku' | 'taxable' | 'title' | 'updatedAt'> & {
15
18
  image?: AdminTypes.Maybe<Pick<AdminTypes.Image, 'id' | 'url'>>;
16
19
  media: {
@@ -58,7 +61,7 @@ export type GetProductQuery = {
58
61
  })>;
59
62
  };
60
63
  interface GeneratedQueryTypes {
61
- "\n #graphql\n query GetProduct($id: ID!) {\n product(id: $id) {\n \n id\n handle\n productType\n hasOnlyDefaultVariant\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n priceRangeV2 {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variantsCount {\n count\n }\n seo {\n title\n description\n }\n variants (first: 100) {\n nodes {\n availableForSale\n barcode\n compareAtPrice\n createdAt\n displayName\n id\n image {\n id\n url \n }\n inventoryQuantity\n price \n media (first: 10) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n }\n selectedOptions {\n name\n value\n }\n sellableOnlineQuantity\n sku\n taxable\n title\n updatedAt\n }\n }\n media (first: 10) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n }\n category {\n id\n name\n fullName\n parentId\n }\n }\n }\n ": {
64
+ "\n#graphql\nquery GetProduct($id: ID!, $first: Int!, $after: String) {\n product(id: $id) { \n id\n handle\n productType\n hasOnlyDefaultVariant\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n priceRangeV2 {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variantsCount {\n count\n }\n seo {\n title\n description\n }\n variants (first: $first, after: $after) { \n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n availableForSale\n barcode\n compareAtPrice\n createdAt\n displayName\n id\n image {\n id\n url \n }\n inventoryQuantity\n price \n media (first: 10) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n }\n selectedOptions {\n name\n value\n }\n sellableOnlineQuantity\n sku\n taxable\n title\n updatedAt\n }\n }\n media (first: 10) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n }\n category {\n id\n name\n fullName\n parentId\n }\n }\n}\n": {
62
65
  return: GetProductQuery;
63
66
  variables: GetProductQueryVariables;
64
67
  };
@@ -0,0 +1 @@
1
+ export declare const graphqlProductQueryByProductId = "\n#graphql\nquery GetProduct($id: ID!, $first: Int!, $after: String) {\n product(id: $id) { \n id\n handle\n productType\n hasOnlyDefaultVariant\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n priceRangeV2 {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variantsCount {\n count\n }\n seo {\n title\n description\n }\n variants (first: $first, after: $after) { \n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n availableForSale\n barcode\n compareAtPrice\n createdAt\n displayName\n id\n image {\n id\n url \n }\n inventoryQuantity\n price \n media (first: 10) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n }\n selectedOptions {\n name\n value\n }\n sellableOnlineQuantity\n sku\n taxable\n title\n updatedAt\n }\n }\n media (first: 10) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n }\n category {\n id\n name\n fullName\n parentId\n }\n }\n}\n";
@@ -0,0 +1,106 @@
1
+ export const graphqlProductQueryByProductId = `
2
+ #graphql
3
+ query GetProduct($id: ID!, $first: Int!, $after: String) {
4
+ product(id: $id) {
5
+ id
6
+ handle
7
+ productType
8
+ hasOnlyDefaultVariant
9
+ isGiftCard
10
+ legacyResourceId
11
+ onlineStoreUrl
12
+ productType
13
+ publishedAt
14
+ requiresSellingPlan
15
+ status
16
+ tags
17
+ title
18
+ totalInventory
19
+ tracksInventory
20
+ vendor
21
+ createdAt
22
+ updatedAt
23
+ priceRangeV2 {
24
+ maxVariantPrice {
25
+ amount
26
+ currencyCode
27
+ }
28
+ minVariantPrice {
29
+ amount
30
+ currencyCode
31
+ }
32
+ }
33
+ variantsCount {
34
+ count
35
+ }
36
+ seo {
37
+ title
38
+ description
39
+ }
40
+ variants (first: $first, after: $after) {
41
+ pageInfo {
42
+ hasNextPage
43
+ endCursor
44
+ }
45
+ nodes {
46
+ availableForSale
47
+ barcode
48
+ compareAtPrice
49
+ createdAt
50
+ displayName
51
+ id
52
+ image {
53
+ id
54
+ url
55
+ }
56
+ inventoryQuantity
57
+ price
58
+ media (first: 10) {
59
+ nodes {
60
+ id
61
+ mediaContentType
62
+ status
63
+ preview {
64
+ image {
65
+ id
66
+ url
67
+ }
68
+ status
69
+ }
70
+ }
71
+ }
72
+ selectedOptions {
73
+ name
74
+ value
75
+ }
76
+ sellableOnlineQuantity
77
+ sku
78
+ taxable
79
+ title
80
+ updatedAt
81
+ }
82
+ }
83
+ media (first: 10) {
84
+ nodes {
85
+ id
86
+ mediaContentType
87
+ status
88
+ preview {
89
+ image {
90
+ id
91
+ url
92
+ }
93
+ status
94
+ }
95
+ }
96
+ }
97
+ category {
98
+ id
99
+ name
100
+ fullName
101
+ parentId
102
+ }
103
+ }
104
+ }
105
+ `;
106
+ //# sourceMappingURL=graphql-product-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-product-queries.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/graphql-product-queries.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwG7C,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AdminApiClient } from '@shopify/admin-api-client';
2
+ import { Product } from '../../../types';
3
+ export declare class ShopifyGraphQLClient {
4
+ static _shopify_api_version: string;
5
+ static getClient: (shop: string, accessToken: string) => AdminApiClient;
6
+ static getProductWithVariantsGraphQL: (shop: string, accessToken: string, productId: string, pageSize?: number) => Promise<Product | undefined>;
7
+ private static executePagedProductQuery;
8
+ private static executeProductQuery;
9
+ }
@@ -0,0 +1,93 @@
1
+ import { createAdminApiClient } from '@shopify/admin-api-client';
2
+ import { Logger } from '../../../helpers';
3
+ import { graphqlProductQueryByProductId } from './graphql-product-queries';
4
+ export class ShopifyGraphQLClient {
5
+ static _shopify_api_version = process.env.SHOPIFY_API_VERSION;
6
+ static getClient = (shop, accessToken) => {
7
+ const client = createAdminApiClient({
8
+ storeDomain: shop,
9
+ accessToken: accessToken,
10
+ apiVersion: '2024-10',
11
+ retries: 1
12
+ });
13
+ return client;
14
+ };
15
+ static getProductWithVariantsGraphQL = async (shop, accessToken, productId, pageSize = 100) => {
16
+ try {
17
+ const client = this.getClient(shop, accessToken);
18
+ const product = await this.executePagedProductQuery(client, productId, pageSize, null);
19
+ return product ?? undefined;
20
+ }
21
+ catch (error) {
22
+ Logger.error('Failed getProductWithVariantsGraphQL', {
23
+ error,
24
+ shop,
25
+ accessToken,
26
+ productId
27
+ });
28
+ return undefined;
29
+ }
30
+ };
31
+ static executePagedProductQuery = async (client, productId, pageSize, cursor) => {
32
+ try {
33
+ let product = null;
34
+ const allVariants = [];
35
+ let hasNextPage = true;
36
+ while (hasNextPage) {
37
+ Logger.info('executePagedProductQuery', { productId, pageSize, cursor });
38
+ product = await this.executeProductQuery(client, productId, pageSize, cursor ?? null);
39
+ if (!product) {
40
+ Logger.error('Product not found', { product, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
41
+ break;
42
+ }
43
+ allVariants.push(...(product?.variants?.nodes ?? []));
44
+ hasNextPage = product?.variants?.pageInfo?.hasNextPage;
45
+ cursor = product?.variants?.pageInfo?.endCursor;
46
+ if (hasNextPage) {
47
+ Logger.info('hasNextPage product variants', { hasNextPage, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
48
+ }
49
+ }
50
+ if (product) {
51
+ product.variants.nodes = allVariants;
52
+ }
53
+ return product ?? undefined;
54
+ }
55
+ catch (error) {
56
+ Logger.error('Failed to execute paged product query', { error, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
57
+ throw error;
58
+ }
59
+ };
60
+ static executeProductQuery = async (client, productId, pageSize, cursor) => {
61
+ try {
62
+ let product = null;
63
+ const result = await client.request(graphqlProductQueryByProductId, {
64
+ variables: {
65
+ id: `gid://shopify/Product/${productId}`,
66
+ first: pageSize,
67
+ after: cursor
68
+ }
69
+ });
70
+ if (result?.errors) {
71
+ Logger.error('Failed to executeProductQuery -- response errors', {
72
+ result,
73
+ responseErrors: result.errors,
74
+ shop: client.config.storeDomain,
75
+ productId,
76
+ cursor
77
+ });
78
+ throw result.errors;
79
+ }
80
+ product = result?.data?.product;
81
+ if (!product) {
82
+ Logger.error('Failed to get product', { result, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
83
+ throw new Error('Failed to get product - No product found');
84
+ }
85
+ return product;
86
+ }
87
+ catch (error) {
88
+ Logger.error('Failed to executeProductQuery -- exception', { error, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
89
+ throw error;
90
+ }
91
+ };
92
+ }
93
+ //# sourceMappingURL=shopify-graphql-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopify-graphql-client.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/shopify-graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAE3E,MAAM,OAAO,oBAAoB;IAC/B,MAAM,CAAC,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAA6B,CAAC;IAExE,MAAM,CAAC,SAAS,GAAG,CAAC,IAAY,EAAE,WAAmB,EAAE,EAAE;QACvD,MAAM,MAAM,GAAG,oBAAoB,CAAC;YAClC,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,WAAW;YACxB,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,CAAC,6BAA6B,GAAG,KAAK,EAAE,IAAY,EAAE,WAAmB,EAAE,SAAiB,EAAE,QAAQ,GAAG,GAAG,EAAgC,EAAE;QAClJ,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAEjD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,MAAM,EA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,MAAM,EAAE,IAAI,EAAE,OAAkB,CAAC;YAC3C,IAAI,CAAC,OAAO,EAAE;gBACZ,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;gBACtI,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;aAC7D;YACD,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,KAAU,EAAE;YACnB,MAAM,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;YAC1J,MAAM,KAAK,CAAC;SACb;IACH,CAAC,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { GenericHttpClient } from '../generic/http-client.js';
2
2
  import { IOrder, IProduct } from 'shopify-api-node';
3
3
  import { ApiResponse } from '../../types/api-response.js';
4
- import { GetProductQuery } from '../../types/shopify-graphql-types/admin.generated.js';
5
4
  export declare class ShopifyClient {
6
5
  static _shopify_api_version: string;
7
6
  static client: GenericHttpClient;
@@ -196,5 +195,4 @@ export declare class ShopifyClient {
196
195
  };
197
196
  headers?: undefined;
198
197
  }>;
199
- static getProductGraphQL: (shop: string, accessToken: string, productId: string) => Promise<GetProductQuery | undefined>;
200
198
  }
@@ -1,6 +1,5 @@
1
1
  import { axiosHttpService } from '../generic/http-client.js';
2
2
  import { Logger } from '../../index.js';
3
- import { createAdminApiClient } from '@shopify/admin-api-client';
4
3
  export class ShopifyClient {
5
4
  static _shopify_api_version = process.env.SHOPIFY_API_VERSION;
6
5
  static client;
@@ -144,131 +143,5 @@ export class ShopifyClient {
144
143
  Logger.debug('Shopify Client Response', { res });
145
144
  return res;
146
145
  };
147
- static getProductGraphQL = async (shop, accessToken, productId) => {
148
- try {
149
- const client = createAdminApiClient({
150
- storeDomain: shop,
151
- accessToken: accessToken,
152
- apiVersion: '2024-10'
153
- });
154
- const query = `
155
- #graphql
156
- query GetProduct($id: ID!) {
157
- product(id: $id) {
158
-
159
- id
160
- handle
161
- productType
162
- hasOnlyDefaultVariant
163
- isGiftCard
164
- legacyResourceId
165
- onlineStoreUrl
166
- productType
167
- publishedAt
168
- requiresSellingPlan
169
- status
170
- tags
171
- title
172
- totalInventory
173
- tracksInventory
174
- vendor
175
- createdAt
176
- updatedAt
177
- priceRangeV2 {
178
- maxVariantPrice {
179
- amount
180
- currencyCode
181
- }
182
- minVariantPrice {
183
- amount
184
- currencyCode
185
- }
186
- }
187
- variantsCount {
188
- count
189
- }
190
- seo {
191
- title
192
- description
193
- }
194
- variants (first: 100) {
195
- nodes {
196
- availableForSale
197
- barcode
198
- compareAtPrice
199
- createdAt
200
- displayName
201
- id
202
- image {
203
- id
204
- url
205
- }
206
- inventoryQuantity
207
- price
208
- media (first: 10) {
209
- nodes {
210
- id
211
- mediaContentType
212
- status
213
- preview {
214
- image {
215
- id
216
- url
217
- }
218
- status
219
- }
220
- }
221
- }
222
- selectedOptions {
223
- name
224
- value
225
- }
226
- sellableOnlineQuantity
227
- sku
228
- taxable
229
- title
230
- updatedAt
231
- }
232
- }
233
- media (first: 10) {
234
- nodes {
235
- id
236
- mediaContentType
237
- status
238
- preview {
239
- image {
240
- id
241
- url
242
- }
243
- status
244
- }
245
- }
246
- }
247
- category {
248
- id
249
- name
250
- fullName
251
- parentId
252
- }
253
- }
254
- }
255
- `;
256
- const result = await client.request(query, {
257
- variables: {
258
- id: `gid://shopify/Product/${productId}`
259
- }
260
- });
261
- Logger.info('getProductGraphQL - result', { result });
262
- if (result?.errors) {
263
- Logger.error('Failed to get Product', { result, errors: result.errors, shop, accessToken, productId, query, data: result?.data });
264
- throw result.errors;
265
- }
266
- return result.data;
267
- }
268
- catch (error) {
269
- Logger.error('Failed to getProductGraphQL', { error, e: error, shop, accessToken, productId });
270
- throw error;
271
- }
272
- };
273
146
  }
274
147
  //# sourceMappingURL=shopify-client.js.map