@adtrackify/at-service-common 3.1.20 → 3.1.22
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/dist/cjs/clients/third-party/shopify/graphql-product-queries.d.ts +1 -1
- package/dist/cjs/clients/third-party/shopify/graphql-product-queries.js +17 -0
- package/dist/cjs/clients/third-party/shopify/graphql-product-queries.js.map +1 -1
- package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.d.ts +3 -3
- package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js +18 -19
- package/dist/cjs/clients/third-party/shopify/shopify-graphql-client.js.map +1 -1
- package/dist/cjs/services/shopify/products/shopify-products-serviceV2.d.ts +6 -1
- package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js +24 -15
- package/dist/cjs/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
- package/dist/cjs/services/shopify/shopify-graphql-transformer.js +12 -0
- package/dist/cjs/services/shopify/shopify-graphql-transformer.js.map +1 -1
- package/dist/cjs/services/shopify/types/product.d.ts +4 -0
- package/dist/cjs/types/shopify-graphql-types/admin.generated.d.ts +8 -2
- package/dist/esm/clients/third-party/shopify/graphql-product-queries.d.ts +1 -1
- package/dist/esm/clients/third-party/shopify/graphql-product-queries.js +17 -0
- package/dist/esm/clients/third-party/shopify/graphql-product-queries.js.map +1 -1
- package/dist/esm/clients/third-party/shopify/shopify-graphql-client.d.ts +3 -3
- package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js +18 -19
- package/dist/esm/clients/third-party/shopify/shopify-graphql-client.js.map +1 -1
- package/dist/esm/services/shopify/products/shopify-products-serviceV2.d.ts +6 -1
- package/dist/esm/services/shopify/products/shopify-products-serviceV2.js +24 -15
- package/dist/esm/services/shopify/products/shopify-products-serviceV2.js.map +1 -1
- package/dist/esm/services/shopify/shopify-graphql-transformer.js +12 -0
- package/dist/esm/services/shopify/shopify-graphql-transformer.js.map +1 -1
- package/dist/esm/services/shopify/types/product.d.ts +4 -0
- package/dist/esm/types/shopify-graphql-types/admin.generated.d.ts +8 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const MediaSnippet = "\n... on MediaImage {\n createdAt\n fileErrors {\n code\n details\n message\n }\n fileStatus\n id\n image {\n altText\n height\n id\n originalSrc\n src\n transformedSrc\n width\n }\n mimeType\n}\n";
|
|
2
|
-
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 category {\n id\n name\n fullName\n parentId\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n";
|
|
2
|
+
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 hasOutOfStockVariants\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n onlineStorePreviewUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n category {\n id\n name\n fullName\n parentId\n }\n collections (first: 250) {\n nodes {\n handle\n id\n image {\n url\n }\n legacyResourceId\n productsCount {\n count\n precision\n }\n title\n }\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n";
|
|
@@ -31,9 +31,11 @@ query GetProduct($id: ID!, $first: Int!, $after: String) {
|
|
|
31
31
|
handle
|
|
32
32
|
productType
|
|
33
33
|
hasOnlyDefaultVariant
|
|
34
|
+
hasOutOfStockVariants
|
|
34
35
|
isGiftCard
|
|
35
36
|
legacyResourceId
|
|
36
37
|
onlineStoreUrl
|
|
38
|
+
onlineStorePreviewUrl
|
|
37
39
|
productType
|
|
38
40
|
publishedAt
|
|
39
41
|
requiresSellingPlan
|
|
@@ -51,6 +53,21 @@ query GetProduct($id: ID!, $first: Int!, $after: String) {
|
|
|
51
53
|
fullName
|
|
52
54
|
parentId
|
|
53
55
|
}
|
|
56
|
+
collections (first: 250) {
|
|
57
|
+
nodes {
|
|
58
|
+
handle
|
|
59
|
+
id
|
|
60
|
+
image {
|
|
61
|
+
url
|
|
62
|
+
}
|
|
63
|
+
legacyResourceId
|
|
64
|
+
productsCount {
|
|
65
|
+
count
|
|
66
|
+
precision
|
|
67
|
+
}
|
|
68
|
+
title
|
|
69
|
+
}
|
|
70
|
+
}
|
|
54
71
|
priceRangeV2 {
|
|
55
72
|
maxVariantPrice {
|
|
56
73
|
amount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-product-queries.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/graphql-product-queries.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEW,QAAA,8BAA8B,GAAG
|
|
1
|
+
{"version":3,"file":"graphql-product-queries.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/graphql-product-queries.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEW,QAAA,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8J7C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AdminApiClient } from '@shopify/admin-api-client';
|
|
2
|
-
import {
|
|
1
|
+
import { AdminApiClient, ClientResponse } from '@shopify/admin-api-client';
|
|
2
|
+
import { GetProductQuery } from '../../../types';
|
|
3
3
|
export declare class ShopifyGraphQLClient {
|
|
4
4
|
static _shopify_api_version: string;
|
|
5
5
|
static getClient: (shop: string, accessToken: string) => AdminApiClient;
|
|
6
|
-
static getProductWithVariantsGraphQL: (shop: string, accessToken: string, productId: string, pageSize?: number) => Promise<
|
|
6
|
+
static getProductWithVariantsGraphQL: (shop: string, accessToken: string, productId: string, pageSize?: number) => Promise<ClientResponse<GetProductQuery>>;
|
|
7
7
|
private static executePagedProductQuery;
|
|
8
8
|
private static executeProductQuery;
|
|
9
9
|
}
|
|
@@ -18,8 +18,8 @@ class ShopifyGraphQLClient {
|
|
|
18
18
|
static getProductWithVariantsGraphQL = async (shop, accessToken, productId, pageSize = 100) => {
|
|
19
19
|
try {
|
|
20
20
|
const client = this.getClient(shop, accessToken);
|
|
21
|
-
const
|
|
22
|
-
return
|
|
21
|
+
const result = await this.executePagedProductQuery(client, productId, pageSize, null);
|
|
22
|
+
return result;
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
25
25
|
helpers_1.Logger.error('Failed getProductWithVariantsGraphQL', {
|
|
@@ -28,32 +28,38 @@ class ShopifyGraphQLClient {
|
|
|
28
28
|
accessToken,
|
|
29
29
|
productId
|
|
30
30
|
});
|
|
31
|
-
|
|
31
|
+
throw error;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
static executePagedProductQuery = async (client, productId, pageSize, cursor) => {
|
|
35
35
|
try {
|
|
36
|
+
let result = {};
|
|
36
37
|
let product = null;
|
|
37
38
|
const allVariants = [];
|
|
38
39
|
let hasNextPage = true;
|
|
39
40
|
while (hasNextPage) {
|
|
40
41
|
helpers_1.Logger.debug('executePagedProductQuery', { productId, pageSize, cursor });
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
helpers_1.Logger.error('executePagedProductQuery:
|
|
42
|
+
result = await this.executeProductQuery(client, productId, pageSize, cursor ?? null);
|
|
43
|
+
if (result?.errors) {
|
|
44
|
+
helpers_1.Logger.error('executePagedProductQuery: Failed to execute product query', { result, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
44
45
|
break;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
else if (result?.data?.product) {
|
|
48
|
+
product = result.data.product;
|
|
49
|
+
allVariants.push(...(product?.variants?.nodes ?? []));
|
|
50
|
+
hasNextPage = product?.variants?.pageInfo?.hasNextPage;
|
|
51
|
+
cursor = product?.variants?.pageInfo?.endCursor;
|
|
52
|
+
}
|
|
49
53
|
if (hasNextPage) {
|
|
50
54
|
helpers_1.Logger.info('executePagedProductQuery: hasNextPage product variants', { hasNextPage, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
if (product) {
|
|
54
58
|
product.variants.nodes = allVariants;
|
|
59
|
+
result.data = result?.data ?? {};
|
|
60
|
+
result.data.product = product;
|
|
55
61
|
}
|
|
56
|
-
return
|
|
62
|
+
return result;
|
|
57
63
|
}
|
|
58
64
|
catch (error) {
|
|
59
65
|
helpers_1.Logger.error('executePagedProductQuery:Failed to execute paged product query', { error, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
@@ -62,7 +68,6 @@ class ShopifyGraphQLClient {
|
|
|
62
68
|
};
|
|
63
69
|
static executeProductQuery = async (client, productId, pageSize, cursor) => {
|
|
64
70
|
try {
|
|
65
|
-
let product = null;
|
|
66
71
|
const result = await client.request(graphql_product_queries_1.graphqlProductQueryByProductId, {
|
|
67
72
|
variables: {
|
|
68
73
|
id: `gid://shopify/Product/${productId}`,
|
|
@@ -78,18 +83,12 @@ class ShopifyGraphQLClient {
|
|
|
78
83
|
productId,
|
|
79
84
|
cursor
|
|
80
85
|
});
|
|
81
|
-
throw result.errors;
|
|
82
86
|
}
|
|
83
|
-
|
|
84
|
-
if (!product) {
|
|
85
|
-
helpers_1.Logger.error('Failed to get product', { result, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
86
|
-
throw new Error('Failed to get product - No product found');
|
|
87
|
-
}
|
|
88
|
-
return product;
|
|
87
|
+
return result;
|
|
89
88
|
}
|
|
90
89
|
catch (error) {
|
|
91
90
|
helpers_1.Logger.error('Failed to executeProductQuery -- exception', { error, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
92
|
-
|
|
91
|
+
return {};
|
|
93
92
|
}
|
|
94
93
|
};
|
|
95
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-graphql-client.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/shopify-graphql-client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"shopify-graphql-client.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/shopify-graphql-client.ts"],"names":[],"mappings":";;;AAAA,gEAAiG;AACjG,8CAA0C;AAE1C,uEAA2E;AAE3E,MAAa,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,IAAA,uCAAoB,EAAC;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,EAA4C,EAAE;QAC9J,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,MAAM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AAC,kDAAkD,EAAE;oBAC/D,MAAM;oBACN,cAAc,EAAE,MAAM,CAAC,MAAM;oBAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;oBAC/B,SAAS;oBACT,MAAM;iBACP,CAAC,CAAC;aACJ;YACD,OAAO,MAAM,CAAC;SACf;QAAC,OAAO,KAAU,EAAE;YACnB,gBAAM,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,OAAO,EAAE,CAAC;SACX;IACH,CAAC,CAAC;;AAvFJ,oDAwFC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { InternalProduct } from '../types/product';
|
|
2
|
+
import { GetProductQuery } from '../../../types';
|
|
3
|
+
import { ClientResponse } from '@shopify/admin-api-client';
|
|
4
|
+
export interface GetShopifyProductResponse extends ClientResponse<GetProductQuery> {
|
|
5
|
+
transformedProduct?: InternalProduct;
|
|
6
|
+
}
|
|
2
7
|
export declare class ShopifyProductsServiceV2 {
|
|
3
8
|
private productCacheService;
|
|
4
9
|
constructor(cacheLambdaFunctionArn: string);
|
|
5
|
-
getShopifyProduct: (pixelId: string, shop: string, accessToken: string, productId: string, useCache?: boolean, updateCache?: boolean) => Promise<
|
|
10
|
+
getShopifyProduct: (pixelId: string, shop: string, accessToken: string, productId: string, useCache?: boolean, updateCache?: boolean) => Promise<GetShopifyProductResponse | null>;
|
|
6
11
|
private getShopifyProductFromAPI;
|
|
7
12
|
}
|
|
@@ -12,24 +12,26 @@ class ShopifyProductsServiceV2 {
|
|
|
12
12
|
}
|
|
13
13
|
getShopifyProduct = async (pixelId, shop, accessToken, productId, useCache = true, updateCache = true) => {
|
|
14
14
|
try {
|
|
15
|
-
let
|
|
15
|
+
let getShopifyProductResponse = {};
|
|
16
16
|
if (useCache) {
|
|
17
|
-
product = await this.productCacheService.getProductFromCache(pixelId, productId);
|
|
17
|
+
const product = await this.productCacheService.getProductFromCache(pixelId, productId);
|
|
18
18
|
if (product) {
|
|
19
19
|
helpers_1.Logger.debug('getShopifyProduct: Product found in cache', { pixelId, shop, productId, product });
|
|
20
|
-
|
|
20
|
+
getShopifyProductResponse.transformedProduct = product;
|
|
21
|
+
return getShopifyProductResponse;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
if (
|
|
24
|
+
getShopifyProductResponse = await this.getShopifyProductFromAPI(pixelId, shop, accessToken, productId, true);
|
|
25
|
+
if (getShopifyProductResponse?.transformedProduct && updateCache) {
|
|
26
|
+
const product = getShopifyProductResponse.transformedProduct;
|
|
25
27
|
helpers_1.Logger.debug('getShopifyProduct: Product found in ShopifyAPI, putting in cache', { pixelId, productId, product });
|
|
26
28
|
await this.productCacheService.putProductInCache(pixelId, productId, product);
|
|
27
29
|
}
|
|
28
|
-
if (!
|
|
30
|
+
if (!getShopifyProductResponse?.transformedProduct) {
|
|
29
31
|
helpers_1.Logger.error('getShopifyProduct: Product not found in ShopifyAPI or cache', { pixelId, shop, productId });
|
|
30
32
|
}
|
|
31
|
-
helpers_1.Logger.debug('getShopifyProduct: Returning product', { pixelId, shop, productId, product });
|
|
32
|
-
return
|
|
33
|
+
helpers_1.Logger.debug('getShopifyProduct: Returning product', { pixelId, shop, productId, product: getShopifyProductResponse?.transformedProduct });
|
|
34
|
+
return getShopifyProductResponse;
|
|
33
35
|
}
|
|
34
36
|
catch (error) {
|
|
35
37
|
helpers_1.Logger.error('getShopifyProduct: Failed getShopifyProductWithCachingGraphQL', { error });
|
|
@@ -38,15 +40,22 @@ class ShopifyProductsServiceV2 {
|
|
|
38
40
|
};
|
|
39
41
|
getShopifyProductFromAPI = async (pixelId, shop, accessToken, productId, useTransformer = true) => {
|
|
40
42
|
try {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
+
const response = await shopify_graphql_client_1.ShopifyGraphQLClient.getProductWithVariantsGraphQL(shop, accessToken, productId, 100);
|
|
44
|
+
const getShopifyProductResponse = response;
|
|
45
|
+
if (response?.data?.product) {
|
|
46
|
+
const product = response.data.product;
|
|
43
47
|
helpers_1.Logger.debug('getShopifyProductFromAPI: Product found in ShopifyAPI', { pixelId, shop, productId, product });
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
if (useTransformer) {
|
|
49
|
+
const transformedProduct = shopify_graphql_transformer_1.ShopifyGraphQLTransformer.transformToInternalProduct(product);
|
|
50
|
+
getShopifyProductResponse.transformedProduct = transformedProduct;
|
|
51
|
+
helpers_1.Logger.info('getShopifyProductFromAPI: Product transformed', { pixelId, shop, productId, transformedProduct: getShopifyProductResponse.transformedProduct });
|
|
52
|
+
}
|
|
53
|
+
return getShopifyProductResponse;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
helpers_1.Logger.error('getShopifyProductFromAPI: Product not found in ShopifyAPI', { pixelId, shop, productId });
|
|
57
|
+
return getShopifyProductResponse;
|
|
47
58
|
}
|
|
48
|
-
helpers_1.Logger.error('getShopifyProductFromAPI: Product not found in ShopifyAPI', { pixelId, shop, productId });
|
|
49
|
-
return null;
|
|
50
59
|
}
|
|
51
60
|
catch (error) {
|
|
52
61
|
helpers_1.Logger.error('getShopifyProductFromAPI: Failed getShopifyProductFromAPI', { e: error, pixelId, shop, accessToken, productId, useTransformer, error });
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"shopify-products-serviceV2.js","sourceRoot":"","sources":["../../../../../src/services/shopify/products/shopify-products-serviceV2.ts"],"names":[],"mappings":";;;AAAA,8CAA0C;AAG1C,6EAAwE;AACx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;aAClC;iBAAM;gBACL,gBAAM,CAAC,KAAK,CAAC,2DAA2D,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;gBACxG,OAAO,yBAAyB,CAAC;aAClC;SACF;QAAC,OAAO,KAAK,EAAE;YACd,gBAAM,CAAC,KAAK,CAAC,2DAA2D,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;YACtJ,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAA;CACF;AA3DD,4DA2DC"}
|
|
@@ -22,6 +22,7 @@ exports.ShopifyGraphQLTransformer = {
|
|
|
22
22
|
hasVariantsThatRequiresComponents: product?.hasVariantsThatRequiresComponents ?? false,
|
|
23
23
|
isGiftCard: product?.isGiftCard ?? false,
|
|
24
24
|
onlineStoreUrl: product.onlineStoreUrl,
|
|
25
|
+
onlineStorePreviewUrl: product.onlineStorePreviewUrl,
|
|
25
26
|
tags: product.tags || [],
|
|
26
27
|
totalInventory: product.totalInventory || 0,
|
|
27
28
|
tracksInventory: product.tracksInventory || false,
|
|
@@ -32,6 +33,7 @@ exports.ShopifyGraphQLTransformer = {
|
|
|
32
33
|
minVariantCompareAtPrice: Number(product.compareAtPriceRange?.minVariantCompareAtPrice?.amount || 0),
|
|
33
34
|
maxVariantPrice: Number(product.priceRangeV2?.maxVariantPrice?.amount || 0),
|
|
34
35
|
minVariantPrice: Number(product.priceRangeV2?.minVariantPrice?.amount || 0),
|
|
36
|
+
currency: product.priceRangeV2?.minVariantPrice?.currencyCode || product.priceRangeV2?.maxVariantPrice?.currencyCode,
|
|
35
37
|
media: product?.media?.nodes?.map(media => ({
|
|
36
38
|
id: media.id,
|
|
37
39
|
mediaContentType: media.mediaContentType,
|
|
@@ -41,6 +43,14 @@ exports.ShopifyGraphQLTransformer = {
|
|
|
41
43
|
variants: product?.variants?.nodes
|
|
42
44
|
?.map(variant => exports.ShopifyGraphQLTransformer.transformToInternalProductVariant(variant))
|
|
43
45
|
.filter(variant => variant !== undefined) || [],
|
|
46
|
+
collections: product.collections?.nodes?.map(collection => ({
|
|
47
|
+
id: collection.id,
|
|
48
|
+
legacyResourceId: Number(collection.legacyResourceId),
|
|
49
|
+
title: collection.title,
|
|
50
|
+
handle: collection.handle,
|
|
51
|
+
imageUrl: collection.image?.url,
|
|
52
|
+
productsCount: collection.productsCount
|
|
53
|
+
})) || [],
|
|
44
54
|
category: product.category ? {
|
|
45
55
|
id: product.category.id,
|
|
46
56
|
name: product.category.name,
|
|
@@ -48,6 +58,8 @@ exports.ShopifyGraphQLTransformer = {
|
|
|
48
58
|
ancestorIds: product.category.ancestorIds,
|
|
49
59
|
childrenIds: product.category.childrenIds,
|
|
50
60
|
} : undefined,
|
|
61
|
+
seoTitle: product.seo?.title,
|
|
62
|
+
seoDescription: product.seo?.description,
|
|
51
63
|
};
|
|
52
64
|
return internalProduct;
|
|
53
65
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-graphql-transformer.js","sourceRoot":"","sources":["../../../../src/services/shopify/shopify-graphql-transformer.ts"],"names":[],"mappings":";;;AAKa,QAAA,yBAAyB,GAAG;
|
|
1
|
+
{"version":3,"file":"shopify-graphql-transformer.js","sourceRoot":"","sources":["../../../../src/services/shopify/shopify-graphql-transformer.ts"],"names":[],"mappings":";;;AAKa,QAAA,yBAAyB,GAAG;IACvC,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,EA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57
|
isGiftCard?: boolean;
|
|
58
58
|
onlineStoreUrl?: string;
|
|
59
|
+
onlineStorePreviewUrl?: string;
|
|
59
60
|
minVariantPrice?: number;
|
|
60
61
|
maxVariantPrice?: number;
|
|
62
|
+
currency?: string;
|
|
61
63
|
productType?: string;
|
|
62
64
|
publishedAt?: string;
|
|
63
65
|
status?: InternalProductStatus;
|
|
@@ -68,6 +70,8 @@ export interface InternalProduct {
|
|
|
68
70
|
updatedAt?: string;
|
|
69
71
|
variantsCount?: number;
|
|
70
72
|
vendor?: string;
|
|
73
|
+
seoTitle?: string;
|
|
74
|
+
seoDescription?: string;
|
|
71
75
|
variants?: InternalProductVariant[];
|
|
72
76
|
}
|
|
73
77
|
export interface InternalProductVariant {
|
|
@@ -5,8 +5,14 @@ export type GetProductQueryVariables = AdminTypes.Exact<{
|
|
|
5
5
|
after?: AdminTypes.InputMaybe<AdminTypes.Scalars['String']['input']>;
|
|
6
6
|
}>;
|
|
7
7
|
export type GetProductQuery = {
|
|
8
|
-
product?: AdminTypes.Maybe<(Pick<AdminTypes.Product, 'id' | 'handle' | 'productType' | 'hasOnlyDefaultVariant' | 'isGiftCard' | 'legacyResourceId' | 'onlineStoreUrl' | 'publishedAt' | 'requiresSellingPlan' | 'status' | 'tags' | 'title' | 'totalInventory' | 'tracksInventory' | 'vendor' | 'createdAt' | 'updatedAt'> & {
|
|
8
|
+
product?: AdminTypes.Maybe<(Pick<AdminTypes.Product, 'id' | 'handle' | 'productType' | 'hasOnlyDefaultVariant' | 'hasOutOfStockVariants' | 'isGiftCard' | 'legacyResourceId' | 'onlineStoreUrl' | 'onlineStorePreviewUrl' | 'publishedAt' | 'requiresSellingPlan' | 'status' | 'tags' | 'title' | 'totalInventory' | 'tracksInventory' | 'vendor' | 'createdAt' | 'updatedAt'> & {
|
|
9
9
|
category?: AdminTypes.Maybe<Pick<AdminTypes.TaxonomyCategory, 'id' | 'name' | 'fullName' | 'parentId'>>;
|
|
10
|
+
collections: {
|
|
11
|
+
nodes: Array<(Pick<AdminTypes.Collection, 'handle' | 'id' | 'legacyResourceId' | 'title'> & {
|
|
12
|
+
image?: AdminTypes.Maybe<Pick<AdminTypes.Image, 'url'>>;
|
|
13
|
+
productsCount?: AdminTypes.Maybe<Pick<AdminTypes.Count, 'count' | 'precision'>>;
|
|
14
|
+
})>;
|
|
15
|
+
};
|
|
10
16
|
priceRangeV2: {
|
|
11
17
|
maxVariantPrice: Pick<AdminTypes.MoneyV2, 'amount' | 'currencyCode'>;
|
|
12
18
|
minVariantPrice: Pick<AdminTypes.MoneyV2, 'amount' | 'currencyCode'>;
|
|
@@ -83,7 +89,7 @@ export type GetProductQuery = {
|
|
|
83
89
|
})>;
|
|
84
90
|
};
|
|
85
91
|
interface GeneratedQueryTypes {
|
|
86
|
-
"\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 category {\n id\n name\n fullName\n parentId\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n": {
|
|
92
|
+
"\n#graphql\nquery GetProduct($id: ID!, $first: Int!, $after: String) {\n product(id: $id) {\n id\n handle\n productType\n hasOnlyDefaultVariant\n hasOutOfStockVariants\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n onlineStorePreviewUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n category {\n id\n name\n fullName\n parentId\n }\n collections (first: 250) {\n nodes {\n handle\n id\n image {\n url\n }\n legacyResourceId\n productsCount {\n count\n precision\n }\n title\n }\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n": {
|
|
87
93
|
return: GetProductQuery;
|
|
88
94
|
variables: GetProductQueryVariables;
|
|
89
95
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const MediaSnippet = "\n... on MediaImage {\n createdAt\n fileErrors {\n code\n details\n message\n }\n fileStatus\n id\n image {\n altText\n height\n id\n originalSrc\n src\n transformedSrc\n width\n }\n mimeType\n}\n";
|
|
2
|
-
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 category {\n id\n name\n fullName\n parentId\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n";
|
|
2
|
+
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 hasOutOfStockVariants\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n onlineStorePreviewUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n category {\n id\n name\n fullName\n parentId\n }\n collections (first: 250) {\n nodes {\n handle\n id\n image {\n url\n }\n legacyResourceId\n productsCount {\n count\n precision\n }\n title\n }\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n";
|
|
@@ -28,9 +28,11 @@ query GetProduct($id: ID!, $first: Int!, $after: String) {
|
|
|
28
28
|
handle
|
|
29
29
|
productType
|
|
30
30
|
hasOnlyDefaultVariant
|
|
31
|
+
hasOutOfStockVariants
|
|
31
32
|
isGiftCard
|
|
32
33
|
legacyResourceId
|
|
33
34
|
onlineStoreUrl
|
|
35
|
+
onlineStorePreviewUrl
|
|
34
36
|
productType
|
|
35
37
|
publishedAt
|
|
36
38
|
requiresSellingPlan
|
|
@@ -48,6 +50,21 @@ query GetProduct($id: ID!, $first: Int!, $after: String) {
|
|
|
48
50
|
fullName
|
|
49
51
|
parentId
|
|
50
52
|
}
|
|
53
|
+
collections (first: 250) {
|
|
54
|
+
nodes {
|
|
55
|
+
handle
|
|
56
|
+
id
|
|
57
|
+
image {
|
|
58
|
+
url
|
|
59
|
+
}
|
|
60
|
+
legacyResourceId
|
|
61
|
+
productsCount {
|
|
62
|
+
count
|
|
63
|
+
precision
|
|
64
|
+
}
|
|
65
|
+
title
|
|
66
|
+
}
|
|
67
|
+
}
|
|
51
68
|
priceRangeV2 {
|
|
52
69
|
maxVariantPrice {
|
|
53
70
|
amount
|
|
@@ -1 +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,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG
|
|
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,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB3B,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8J7C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AdminApiClient } from '@shopify/admin-api-client';
|
|
2
|
-
import {
|
|
1
|
+
import { AdminApiClient, ClientResponse } from '@shopify/admin-api-client';
|
|
2
|
+
import { GetProductQuery } from '../../../types';
|
|
3
3
|
export declare class ShopifyGraphQLClient {
|
|
4
4
|
static _shopify_api_version: string;
|
|
5
5
|
static getClient: (shop: string, accessToken: string) => AdminApiClient;
|
|
6
|
-
static getProductWithVariantsGraphQL: (shop: string, accessToken: string, productId: string, pageSize?: number) => Promise<
|
|
6
|
+
static getProductWithVariantsGraphQL: (shop: string, accessToken: string, productId: string, pageSize?: number) => Promise<ClientResponse<GetProductQuery>>;
|
|
7
7
|
private static executePagedProductQuery;
|
|
8
8
|
private static executeProductQuery;
|
|
9
9
|
}
|
|
@@ -15,8 +15,8 @@ export class ShopifyGraphQLClient {
|
|
|
15
15
|
static getProductWithVariantsGraphQL = async (shop, accessToken, productId, pageSize = 100) => {
|
|
16
16
|
try {
|
|
17
17
|
const client = this.getClient(shop, accessToken);
|
|
18
|
-
const
|
|
19
|
-
return
|
|
18
|
+
const result = await this.executePagedProductQuery(client, productId, pageSize, null);
|
|
19
|
+
return result;
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
22
|
Logger.error('Failed getProductWithVariantsGraphQL', {
|
|
@@ -25,32 +25,38 @@ export class ShopifyGraphQLClient {
|
|
|
25
25
|
accessToken,
|
|
26
26
|
productId
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
throw error;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
static executePagedProductQuery = async (client, productId, pageSize, cursor) => {
|
|
32
32
|
try {
|
|
33
|
+
let result = {};
|
|
33
34
|
let product = null;
|
|
34
35
|
const allVariants = [];
|
|
35
36
|
let hasNextPage = true;
|
|
36
37
|
while (hasNextPage) {
|
|
37
38
|
Logger.debug('executePagedProductQuery', { productId, pageSize, cursor });
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
Logger.error('executePagedProductQuery:
|
|
39
|
+
result = await this.executeProductQuery(client, productId, pageSize, cursor ?? null);
|
|
40
|
+
if (result?.errors) {
|
|
41
|
+
Logger.error('executePagedProductQuery: Failed to execute product query', { result, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
41
42
|
break;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
else if (result?.data?.product) {
|
|
45
|
+
product = result.data.product;
|
|
46
|
+
allVariants.push(...(product?.variants?.nodes ?? []));
|
|
47
|
+
hasNextPage = product?.variants?.pageInfo?.hasNextPage;
|
|
48
|
+
cursor = product?.variants?.pageInfo?.endCursor;
|
|
49
|
+
}
|
|
46
50
|
if (hasNextPage) {
|
|
47
51
|
Logger.info('executePagedProductQuery: hasNextPage product variants', { hasNextPage, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
if (product) {
|
|
51
55
|
product.variants.nodes = allVariants;
|
|
56
|
+
result.data = result?.data ?? {};
|
|
57
|
+
result.data.product = product;
|
|
52
58
|
}
|
|
53
|
-
return
|
|
59
|
+
return result;
|
|
54
60
|
}
|
|
55
61
|
catch (error) {
|
|
56
62
|
Logger.error('executePagedProductQuery:Failed to execute paged product query', { error, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
@@ -59,7 +65,6 @@ export class ShopifyGraphQLClient {
|
|
|
59
65
|
};
|
|
60
66
|
static executeProductQuery = async (client, productId, pageSize, cursor) => {
|
|
61
67
|
try {
|
|
62
|
-
let product = null;
|
|
63
68
|
const result = await client.request(graphqlProductQueryByProductId, {
|
|
64
69
|
variables: {
|
|
65
70
|
id: `gid://shopify/Product/${productId}`,
|
|
@@ -75,18 +80,12 @@ export class ShopifyGraphQLClient {
|
|
|
75
80
|
productId,
|
|
76
81
|
cursor
|
|
77
82
|
});
|
|
78
|
-
throw result.errors;
|
|
79
83
|
}
|
|
80
|
-
|
|
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;
|
|
84
|
+
return result;
|
|
86
85
|
}
|
|
87
86
|
catch (error) {
|
|
88
87
|
Logger.error('Failed to executeProductQuery -- exception', { error, shop: client.config.storeDomain, productId, accessToken: client.config.accessToken });
|
|
89
|
-
|
|
88
|
+
return {};
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-graphql-client.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/shopify-graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"shopify-graphql-client.js","sourceRoot":"","sources":["../../../../../src/clients/third-party/shopify/shopify-graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjG,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,EAA4C,EAAE;QAC9J,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EA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F,CAAC,CAAC;YACH,IAAI,MAAM,EAAE,MAAM,EAAE;gBAClB,MAAM,CAAC,KAAK,CAAC,kDAAkD,EAAE;oBAC/D,MAAM;oBACN,cAAc,EAAE,MAAM,CAAC,MAAM;oBAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;oBAC/B,SAAS;oBACT,MAAM;iBACP,CAAC,CAAC;aACJ;YACD,OAAO,MAAM,CAAC;SACf;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,OAAO,EAAE,CAAC;SACX;IACH,CAAC,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { InternalProduct } from '../types/product';
|
|
2
|
+
import { GetProductQuery } from '../../../types';
|
|
3
|
+
import { ClientResponse } from '@shopify/admin-api-client';
|
|
4
|
+
export interface GetShopifyProductResponse extends ClientResponse<GetProductQuery> {
|
|
5
|
+
transformedProduct?: InternalProduct;
|
|
6
|
+
}
|
|
2
7
|
export declare class ShopifyProductsServiceV2 {
|
|
3
8
|
private productCacheService;
|
|
4
9
|
constructor(cacheLambdaFunctionArn: string);
|
|
5
|
-
getShopifyProduct: (pixelId: string, shop: string, accessToken: string, productId: string, useCache?: boolean, updateCache?: boolean) => Promise<
|
|
10
|
+
getShopifyProduct: (pixelId: string, shop: string, accessToken: string, productId: string, useCache?: boolean, updateCache?: boolean) => Promise<GetShopifyProductResponse | null>;
|
|
6
11
|
private getShopifyProductFromAPI;
|
|
7
12
|
}
|
|
@@ -9,24 +9,26 @@ export class ShopifyProductsServiceV2 {
|
|
|
9
9
|
}
|
|
10
10
|
getShopifyProduct = async (pixelId, shop, accessToken, productId, useCache = true, updateCache = true) => {
|
|
11
11
|
try {
|
|
12
|
-
let
|
|
12
|
+
let getShopifyProductResponse = {};
|
|
13
13
|
if (useCache) {
|
|
14
|
-
product = await this.productCacheService.getProductFromCache(pixelId, productId);
|
|
14
|
+
const product = await this.productCacheService.getProductFromCache(pixelId, productId);
|
|
15
15
|
if (product) {
|
|
16
16
|
Logger.debug('getShopifyProduct: Product found in cache', { pixelId, shop, productId, product });
|
|
17
|
-
|
|
17
|
+
getShopifyProductResponse.transformedProduct = product;
|
|
18
|
+
return getShopifyProductResponse;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
if (
|
|
21
|
+
getShopifyProductResponse = await this.getShopifyProductFromAPI(pixelId, shop, accessToken, productId, true);
|
|
22
|
+
if (getShopifyProductResponse?.transformedProduct && updateCache) {
|
|
23
|
+
const product = getShopifyProductResponse.transformedProduct;
|
|
22
24
|
Logger.debug('getShopifyProduct: Product found in ShopifyAPI, putting in cache', { pixelId, productId, product });
|
|
23
25
|
await this.productCacheService.putProductInCache(pixelId, productId, product);
|
|
24
26
|
}
|
|
25
|
-
if (!
|
|
27
|
+
if (!getShopifyProductResponse?.transformedProduct) {
|
|
26
28
|
Logger.error('getShopifyProduct: Product not found in ShopifyAPI or cache', { pixelId, shop, productId });
|
|
27
29
|
}
|
|
28
|
-
Logger.debug('getShopifyProduct: Returning product', { pixelId, shop, productId, product });
|
|
29
|
-
return
|
|
30
|
+
Logger.debug('getShopifyProduct: Returning product', { pixelId, shop, productId, product: getShopifyProductResponse?.transformedProduct });
|
|
31
|
+
return getShopifyProductResponse;
|
|
30
32
|
}
|
|
31
33
|
catch (error) {
|
|
32
34
|
Logger.error('getShopifyProduct: Failed getShopifyProductWithCachingGraphQL', { error });
|
|
@@ -35,15 +37,22 @@ export class ShopifyProductsServiceV2 {
|
|
|
35
37
|
};
|
|
36
38
|
getShopifyProductFromAPI = async (pixelId, shop, accessToken, productId, useTransformer = true) => {
|
|
37
39
|
try {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
+
const response = await ShopifyGraphQLClient.getProductWithVariantsGraphQL(shop, accessToken, productId, 100);
|
|
41
|
+
const getShopifyProductResponse = response;
|
|
42
|
+
if (response?.data?.product) {
|
|
43
|
+
const product = response.data.product;
|
|
40
44
|
Logger.debug('getShopifyProductFromAPI: Product found in ShopifyAPI', { pixelId, shop, productId, product });
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
if (useTransformer) {
|
|
46
|
+
const transformedProduct = ShopifyGraphQLTransformer.transformToInternalProduct(product);
|
|
47
|
+
getShopifyProductResponse.transformedProduct = transformedProduct;
|
|
48
|
+
Logger.info('getShopifyProductFromAPI: Product transformed', { pixelId, shop, productId, transformedProduct: getShopifyProductResponse.transformedProduct });
|
|
49
|
+
}
|
|
50
|
+
return getShopifyProductResponse;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
Logger.error('getShopifyProductFromAPI: Product not found in ShopifyAPI', { pixelId, shop, productId });
|
|
54
|
+
return getShopifyProductResponse;
|
|
44
55
|
}
|
|
45
|
-
Logger.error('getShopifyProductFromAPI: Product not found in ShopifyAPI', { pixelId, shop, productId });
|
|
46
|
-
return null;
|
|
47
56
|
}
|
|
48
57
|
catch (error) {
|
|
49
58
|
Logger.error('getShopifyProductFromAPI: Failed getShopifyProductFromAPI', { e: error, pixelId, shop, accessToken, productId, useTransformer, error });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-products-serviceV2.js","sourceRoot":"","sources":["../../../../../src/services/shopify/products/shopify-products-serviceV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;
|
|
1
|
+
{"version":3,"file":"shopify-products-serviceV2.js","sourceR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AAO,CAAC,CAAC;oBACzF,yBAAyB,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;oBAClE,MAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,kBAAkB,EAAE,yBAAyB,CAAC,kBAAkB,EAAE,CAAC,CAAC;iBAC9J;gBACD,OAAO,yBAAyB,CAAC;aAClC;iBAAM;gBACL,MAAM,CAAC,KAAK,CAAC,2DAA2D,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;gBACxG,OAAO,yBAAyB,CAAC;aAClC;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,KAAK,CAAC,2DAA2D,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC;YACtJ,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAA;CACF"}
|
|
@@ -19,6 +19,7 @@ export const ShopifyGraphQLTransformer = {
|
|
|
19
19
|
hasVariantsThatRequiresComponents: product?.hasVariantsThatRequiresComponents ?? false,
|
|
20
20
|
isGiftCard: product?.isGiftCard ?? false,
|
|
21
21
|
onlineStoreUrl: product.onlineStoreUrl,
|
|
22
|
+
onlineStorePreviewUrl: product.onlineStorePreviewUrl,
|
|
22
23
|
tags: product.tags || [],
|
|
23
24
|
totalInventory: product.totalInventory || 0,
|
|
24
25
|
tracksInventory: product.tracksInventory || false,
|
|
@@ -29,6 +30,7 @@ export const ShopifyGraphQLTransformer = {
|
|
|
29
30
|
minVariantCompareAtPrice: Number(product.compareAtPriceRange?.minVariantCompareAtPrice?.amount || 0),
|
|
30
31
|
maxVariantPrice: Number(product.priceRangeV2?.maxVariantPrice?.amount || 0),
|
|
31
32
|
minVariantPrice: Number(product.priceRangeV2?.minVariantPrice?.amount || 0),
|
|
33
|
+
currency: product.priceRangeV2?.minVariantPrice?.currencyCode || product.priceRangeV2?.maxVariantPrice?.currencyCode,
|
|
32
34
|
media: product?.media?.nodes?.map(media => ({
|
|
33
35
|
id: media.id,
|
|
34
36
|
mediaContentType: media.mediaContentType,
|
|
@@ -38,6 +40,14 @@ export const ShopifyGraphQLTransformer = {
|
|
|
38
40
|
variants: product?.variants?.nodes
|
|
39
41
|
?.map(variant => ShopifyGraphQLTransformer.transformToInternalProductVariant(variant))
|
|
40
42
|
.filter(variant => variant !== undefined) || [],
|
|
43
|
+
collections: product.collections?.nodes?.map(collection => ({
|
|
44
|
+
id: collection.id,
|
|
45
|
+
legacyResourceId: Number(collection.legacyResourceId),
|
|
46
|
+
title: collection.title,
|
|
47
|
+
handle: collection.handle,
|
|
48
|
+
imageUrl: collection.image?.url,
|
|
49
|
+
productsCount: collection.productsCount
|
|
50
|
+
})) || [],
|
|
41
51
|
category: product.category ? {
|
|
42
52
|
id: product.category.id,
|
|
43
53
|
name: product.category.name,
|
|
@@ -45,6 +55,8 @@ export const ShopifyGraphQLTransformer = {
|
|
|
45
55
|
ancestorIds: product.category.ancestorIds,
|
|
46
56
|
childrenIds: product.category.childrenIds,
|
|
47
57
|
} : undefined,
|
|
58
|
+
seoTitle: product.seo?.title,
|
|
59
|
+
seoDescription: product.seo?.description,
|
|
48
60
|
};
|
|
49
61
|
return internalProduct;
|
|
50
62
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify-graphql-transformer.js","sourceRoot":"","sources":["../../../../src/services/shopify/shopify-graphql-transformer.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,yBAAyB,GAAG;
|
|
1
|
+
{"version":3,"file":"shopify-graphql-transformer.js","sourceRoot":"","sources":["../../../../src/services/shopify/shopify-graphql-transformer.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,0BAA0B,EAAE,CAAC,OAAyB,EAA+B,EAAE;QACrF,IAAI,CAAC,OAAO;YAAE,O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,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC;YAC/C,SAAS,EAAE,aAAa,CAAC,SAAS;SACnC,CAAC;QACF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF,CAAA"}
|
|
@@ -56,8 +56,10 @@ export interface InternalProduct {
|
|
|
56
56
|
inCollection?: boolean;
|
|
57
57
|
isGiftCard?: boolean;
|
|
58
58
|
onlineStoreUrl?: string;
|
|
59
|
+
onlineStorePreviewUrl?: string;
|
|
59
60
|
minVariantPrice?: number;
|
|
60
61
|
maxVariantPrice?: number;
|
|
62
|
+
currency?: string;
|
|
61
63
|
productType?: string;
|
|
62
64
|
publishedAt?: string;
|
|
63
65
|
status?: InternalProductStatus;
|
|
@@ -68,6 +70,8 @@ export interface InternalProduct {
|
|
|
68
70
|
updatedAt?: string;
|
|
69
71
|
variantsCount?: number;
|
|
70
72
|
vendor?: string;
|
|
73
|
+
seoTitle?: string;
|
|
74
|
+
seoDescription?: string;
|
|
71
75
|
variants?: InternalProductVariant[];
|
|
72
76
|
}
|
|
73
77
|
export interface InternalProductVariant {
|
|
@@ -5,8 +5,14 @@ export type GetProductQueryVariables = AdminTypes.Exact<{
|
|
|
5
5
|
after?: AdminTypes.InputMaybe<AdminTypes.Scalars['String']['input']>;
|
|
6
6
|
}>;
|
|
7
7
|
export type GetProductQuery = {
|
|
8
|
-
product?: AdminTypes.Maybe<(Pick<AdminTypes.Product, 'id' | 'handle' | 'productType' | 'hasOnlyDefaultVariant' | 'isGiftCard' | 'legacyResourceId' | 'onlineStoreUrl' | 'publishedAt' | 'requiresSellingPlan' | 'status' | 'tags' | 'title' | 'totalInventory' | 'tracksInventory' | 'vendor' | 'createdAt' | 'updatedAt'> & {
|
|
8
|
+
product?: AdminTypes.Maybe<(Pick<AdminTypes.Product, 'id' | 'handle' | 'productType' | 'hasOnlyDefaultVariant' | 'hasOutOfStockVariants' | 'isGiftCard' | 'legacyResourceId' | 'onlineStoreUrl' | 'onlineStorePreviewUrl' | 'publishedAt' | 'requiresSellingPlan' | 'status' | 'tags' | 'title' | 'totalInventory' | 'tracksInventory' | 'vendor' | 'createdAt' | 'updatedAt'> & {
|
|
9
9
|
category?: AdminTypes.Maybe<Pick<AdminTypes.TaxonomyCategory, 'id' | 'name' | 'fullName' | 'parentId'>>;
|
|
10
|
+
collections: {
|
|
11
|
+
nodes: Array<(Pick<AdminTypes.Collection, 'handle' | 'id' | 'legacyResourceId' | 'title'> & {
|
|
12
|
+
image?: AdminTypes.Maybe<Pick<AdminTypes.Image, 'url'>>;
|
|
13
|
+
productsCount?: AdminTypes.Maybe<Pick<AdminTypes.Count, 'count' | 'precision'>>;
|
|
14
|
+
})>;
|
|
15
|
+
};
|
|
10
16
|
priceRangeV2: {
|
|
11
17
|
maxVariantPrice: Pick<AdminTypes.MoneyV2, 'amount' | 'currencyCode'>;
|
|
12
18
|
minVariantPrice: Pick<AdminTypes.MoneyV2, 'amount' | 'currencyCode'>;
|
|
@@ -83,7 +89,7 @@ export type GetProductQuery = {
|
|
|
83
89
|
})>;
|
|
84
90
|
};
|
|
85
91
|
interface GeneratedQueryTypes {
|
|
86
|
-
"\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 category {\n id\n name\n fullName\n parentId\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n": {
|
|
92
|
+
"\n#graphql\nquery GetProduct($id: ID!, $first: Int!, $after: String) {\n product(id: $id) {\n id\n handle\n productType\n hasOnlyDefaultVariant\n hasOutOfStockVariants\n isGiftCard\n legacyResourceId\n onlineStoreUrl\n onlineStorePreviewUrl\n productType\n publishedAt\n requiresSellingPlan\n status\n tags\n title\n totalInventory\n tracksInventory\n vendor\n createdAt\n updatedAt\n category {\n id\n name\n fullName\n parentId\n }\n collections (first: 250) {\n nodes {\n handle\n id\n image {\n url\n }\n legacyResourceId\n productsCount {\n count\n precision\n }\n title\n }\n }\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 featuredMedia {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n }\n media (first: 3) {\n nodes {\n id\n mediaContentType\n status\n preview {\n image {\n id\n url\n }\n status\n }\n\n }\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 legacyResourceId\n product {\n id\n handle\n legacyResourceId\n }\n image {\n id\n url\n }\n inventoryItem {\n createdAt\n id\n legacyResourceId\n locationsCount {\n count\n precision\n }\n requiresShipping\n sku\n tracked\n unitCost {\n amount\n currencyCode\n }\n updatedAt\n }\n inventoryPolicy\n inventoryQuantity\n price\n media (first: 3) {\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 }\n}\n": {
|
|
87
93
|
return: GetProductQuery;
|
|
88
94
|
variables: GetProductQueryVariables;
|
|
89
95
|
};
|