n8n-nodes-shopify-custom 2.0.28 → 2.0.30
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/credentials/ShopifyCustomAdminApi.credentials.js +59 -5
- package/dist/credentials/ShopifyCustomAdminApi.credentials.js.map +1 -1
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.js +48 -2
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.js.map +1 -1
- package/dist/nodes/ShopifyCustom/shared/graphql/client.d.ts +9 -1
- package/dist/nodes/ShopifyCustom/shared/graphql/client.js +132 -12
- package/dist/nodes/ShopifyCustom/shared/graphql/client.js.map +1 -1
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.js +21 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.js.map +1 -1
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.d.ts +2 -2
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js +68 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js.map +1 -1
- package/dist/nodes/ShopifyCustom/shared/translations/options.js +1 -7
- package/dist/nodes/ShopifyCustom/shared/translations/options.js.map +1 -1
- package/dist/nodes/ShopifyCustomTrigger/ShopifyCustomTrigger.node.js +2 -1
- package/dist/nodes/ShopifyCustomTrigger/ShopifyCustomTrigger.node.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -20,6 +20,24 @@ class ShopifyCustomAdminApi {
|
|
|
20
20
|
required: true,
|
|
21
21
|
description: 'Only subdomain without .myshopify.com suffix',
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
displayName: 'Authentication Method',
|
|
25
|
+
name: 'authenticationMethod',
|
|
26
|
+
type: 'options',
|
|
27
|
+
default: 'accessToken',
|
|
28
|
+
options: [
|
|
29
|
+
{
|
|
30
|
+
name: 'Client Credentials (Dev Dashboard)',
|
|
31
|
+
value: 'clientCredentials',
|
|
32
|
+
description: 'Exchange Client ID and Client Secret for a short-lived Admin API access token.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'Admin Access Token (Legacy)',
|
|
36
|
+
value: 'accessToken',
|
|
37
|
+
description: 'Use a static Admin API access token from an admin-created legacy custom app.',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
23
41
|
{
|
|
24
42
|
displayName: 'Admin API Version',
|
|
25
43
|
name: 'apiVersion',
|
|
@@ -36,6 +54,38 @@ class ShopifyCustomAdminApi {
|
|
|
36
54
|
},
|
|
37
55
|
default: '',
|
|
38
56
|
required: true,
|
|
57
|
+
displayOptions: {
|
|
58
|
+
show: {
|
|
59
|
+
authenticationMethod: ['accessToken'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
displayName: 'Client ID',
|
|
65
|
+
name: 'clientId',
|
|
66
|
+
type: 'string',
|
|
67
|
+
default: '',
|
|
68
|
+
required: true,
|
|
69
|
+
displayOptions: {
|
|
70
|
+
show: {
|
|
71
|
+
authenticationMethod: ['clientCredentials'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Client Secret',
|
|
77
|
+
name: 'clientSecret',
|
|
78
|
+
type: 'string',
|
|
79
|
+
typeOptions: {
|
|
80
|
+
password: true,
|
|
81
|
+
},
|
|
82
|
+
default: '',
|
|
83
|
+
required: true,
|
|
84
|
+
displayOptions: {
|
|
85
|
+
show: {
|
|
86
|
+
authenticationMethod: ['clientCredentials'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
39
89
|
},
|
|
40
90
|
{
|
|
41
91
|
displayName: 'Webhook Secret',
|
|
@@ -46,27 +96,31 @@ class ShopifyCustomAdminApi {
|
|
|
46
96
|
},
|
|
47
97
|
default: '',
|
|
48
98
|
required: false,
|
|
49
|
-
description: '
|
|
99
|
+
description: 'Used to verify Shopify webhook signatures for trigger nodes. Leave empty to reuse Client Secret in Dev Dashboard mode.',
|
|
50
100
|
},
|
|
51
101
|
];
|
|
52
102
|
this.authenticate = {
|
|
53
103
|
type: 'generic',
|
|
54
104
|
properties: {
|
|
55
105
|
headers: {
|
|
56
|
-
'X-Shopify-Access-Token': '={{$credentials.accessToken.trim()}}',
|
|
106
|
+
'X-Shopify-Access-Token': '={{$credentials.authenticationMethod === "accessToken" ? $credentials.accessToken.trim() : ""}}',
|
|
57
107
|
},
|
|
58
108
|
},
|
|
59
109
|
};
|
|
60
110
|
this.test = {
|
|
61
111
|
request: {
|
|
62
112
|
baseURL: '={{"https://" + $credentials.shopSubdomain.trim().replace(".myshopify.com", "") + ".myshopify.com"}}',
|
|
63
|
-
url: '
|
|
113
|
+
url: '={{$credentials.authenticationMethod === "clientCredentials" ? "/admin/oauth/access_token" : "/admin/api/" + ($credentials.apiVersion || "2025-10") + "/graphql.json"}}',
|
|
64
114
|
method: 'POST',
|
|
65
115
|
headers: {
|
|
66
|
-
'Content-Type': 'application/json',
|
|
116
|
+
'Content-Type': '={{$credentials.authenticationMethod === "clientCredentials" ? "application/x-www-form-urlencoded" : "application/json"}}',
|
|
117
|
+
'X-Shopify-Access-Token': '={{$credentials.authenticationMethod === "accessToken" ? $credentials.accessToken.trim() : ""}}',
|
|
67
118
|
},
|
|
68
119
|
body: {
|
|
69
|
-
|
|
120
|
+
grant_type: '={{$credentials.authenticationMethod === "clientCredentials" ? "client_credentials" : ""}}',
|
|
121
|
+
client_id: '={{$credentials.authenticationMethod === "clientCredentials" ? $credentials.clientId.trim() : ""}}',
|
|
122
|
+
client_secret: '={{$credentials.authenticationMethod === "clientCredentials" ? $credentials.clientSecret.trim() : ""}}',
|
|
123
|
+
query: '={{$credentials.authenticationMethod === "accessToken" ? "query { shop { id name } }" : ""}}',
|
|
70
124
|
},
|
|
71
125
|
},
|
|
72
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopifyCustomAdminApi.credentials.js","sourceRoot":"","sources":["../../credentials/ShopifyCustomAdminApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,qBAAqB;IAAlC;QACC,SAAI,GAAG,uBAAuB,CAAC;QAE/B,gBAAW,GAAG,0BAA0B,CAAC;QAEzC,SAAI,GAAS;YACZ,KAAK,EAAE,yCAAyC;YAChD,IAAI,EAAE,8CAA8C;SACpD,CAAC;QAEF,qBAAgB,GAAG,4CAA4C,CAAC;QAEhE,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,UAAU;gBACvB,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,8CAA8C;aAC3D;YACD;gBACC,WAAW,EAAE,mBAAmB;gBAChC,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,WAAW,EAAE,oBAAoB;gBACjC,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;
|
|
1
|
+
{"version":3,"file":"ShopifyCustomAdminApi.credentials.js","sourceRoot":"","sources":["../../credentials/ShopifyCustomAdminApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,qBAAqB;IAAlC;QACC,SAAI,GAAG,uBAAuB,CAAC;QAE/B,gBAAW,GAAG,0BAA0B,CAAC;QAEzC,SAAI,GAAS;YACZ,KAAK,EAAE,yCAAyC;YAChD,IAAI,EAAE,8CAA8C;SACpD,CAAC;QAEF,qBAAgB,GAAG,4CAA4C,CAAC;QAEhE,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,gBAAgB;gBAC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Z,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,cAAc,EAAE;oBACf,IAAI,EAAE;wBACL,oBAAoB,EAAE,CAAC,mBAAmB,CAAC;qBAC3C;iBACD;aACD;YACD;gBACC,WAAW,EAAE,gBAAgB;gBAC7B,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,KAAK;gBACf,WAAW,EACV,wHAAwH;aACzH;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,wBAAwB,EACvB,iGAAiG;iBAClG;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC7B,OAAO,EAAE;gBACR,OAAO,EACN,sGAAsG;gBACvG,GAAG,EAAE,yKAAyK;gBAC9K,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACR,cAAc,EACb,2HAA2H;oBAC5H,wBAAwB,EACvB,iGAAiG;iBAClG;gBACD,IAAI,EAAE;oBACL,UAAU,EACT,4FAA4F;oBAC7F,SAAS,EACR,oGAAoG;oBACrG,aAAa,EACZ,wGAAwG;oBACzG,KAAK,EACJ,8FAA8F;iBAC/F;aACD;SACD,CAAC;IACH,CAAC;CAAA;AAzIF,sDAyIE"}
|
|
@@ -9,6 +9,45 @@ const PRODUCT_VARIANT_SORT_OPTIONS = [
|
|
|
9
9
|
{ name: 'Updated At', value: 'UPDATED_AT' },
|
|
10
10
|
{ name: 'Inventory Quantity', value: 'INVENTORY_QUANTITY' },
|
|
11
11
|
];
|
|
12
|
+
function productVariantAdditionalFields() {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
displayName: 'Additional Fields',
|
|
16
|
+
name: 'additionalFields',
|
|
17
|
+
type: 'multiOptions',
|
|
18
|
+
default: [],
|
|
19
|
+
description: 'Additional Product Variant fields to include in the response',
|
|
20
|
+
options: [
|
|
21
|
+
{
|
|
22
|
+
name: 'Available For Sale',
|
|
23
|
+
value: 'availableForSale',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Image (Deprecated)',
|
|
27
|
+
value: 'image',
|
|
28
|
+
description: 'Legacy variant image field. Prefer Media for new workflows.',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'Inventory Item',
|
|
32
|
+
value: 'inventoryItem',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'Inventory Quantity',
|
|
36
|
+
value: 'inventoryQuantity',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Media',
|
|
40
|
+
value: 'media',
|
|
41
|
+
description: 'Variant media connection. Preferred over the deprecated image field.',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Product Handle',
|
|
45
|
+
value: 'productHandle',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}
|
|
12
51
|
function productVariantBaseFields() {
|
|
13
52
|
return [
|
|
14
53
|
{
|
|
@@ -71,7 +110,11 @@ exports.PRODUCT_VARIANT_OPERATION_CONFIGS = [
|
|
|
71
110
|
name: 'Get',
|
|
72
111
|
description: 'Get a product variant by ID',
|
|
73
112
|
registryKey: 'productVariant.get',
|
|
74
|
-
fields: [
|
|
113
|
+
fields: [
|
|
114
|
+
(0, common_1.gidField)('variantId', 'Variant ID', 'Global variant ID in Shopify'),
|
|
115
|
+
...(0, common_1.readMetafieldsFields)(),
|
|
116
|
+
...productVariantAdditionalFields(),
|
|
117
|
+
],
|
|
75
118
|
},
|
|
76
119
|
{
|
|
77
120
|
resource: 'productVariant',
|
|
@@ -79,7 +122,10 @@ exports.PRODUCT_VARIANT_OPERATION_CONFIGS = [
|
|
|
79
122
|
name: 'Get Many',
|
|
80
123
|
description: 'Get many variants',
|
|
81
124
|
registryKey: 'productVariant.getMany',
|
|
82
|
-
fields:
|
|
125
|
+
fields: [
|
|
126
|
+
...(0, common_1.paginationFields)(PRODUCT_VARIANT_SORT_OPTIONS),
|
|
127
|
+
...productVariantAdditionalFields(),
|
|
128
|
+
],
|
|
83
129
|
},
|
|
84
130
|
{
|
|
85
131
|
resource: 'productVariant',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"productVariant.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/config/operations/productVariant.ts"],"names":[],"mappings":";;;AACA,qCAA4E;AAG5E,MAAM,4BAA4B,GAAG;IACpC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IAC3B,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACvC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC7B,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC3C,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,EAAE;CAC3D,CAAC;AAEF,SAAS,wBAAwB;IAChC,OAAO;QACN;YACC,WAAW,EAAE,OAAO;YACpB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;SACX;QACD;YACC,WAAW,EAAE,KAAK;YAClB,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;SACX;QACD;YACC,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;SACX;QACD;YACC,WAAW,EAAE,OAAO;YACpB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAC;YACV,WAAW,EAAE;gBACZ,eAAe,EAAE,CAAC;aAClB;SACD;QACD;YACC,WAAW,EAAE,kBAAkB;YAC/B,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAC;YACV,WAAW,EAAE;gBACZ,eAAe,EAAE,CAAC;aAClB;SACD;QACD;YACC,WAAW,EAAE,SAAS;YACtB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACb;KACD,CAAC;AACH,CAAC;AAEY,QAAA,iCAAiC,GAA8B;IAC3E;QACC,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0BAA0B;QACvC,WAAW,EAAE,uBAAuB;QACpC,MAAM,EAAE,CAAC,IAAA,iBAAQ,EAAC,WAAW,EAAE,YAAY,EAAE,8BAA8B,CAAC,EAAE,GAAG,wBAAwB,EAAE,CAAC;QAC5G,kBAAkB,EAAE,IAAI;KACxB;IACD;QACC,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,6BAA6B;QAC1C,WAAW,EAAE,oBAAoB;QACjC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"productVariant.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/config/operations/productVariant.ts"],"names":[],"mappings":";;;AACA,qCAA4E;AAG5E,MAAM,4BAA4B,GAAG;IACpC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IAC3B,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACvC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;IAC7B,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE;IAC3C,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,EAAE;CAC3D,CAAC;AAEF,SAAS,8BAA8B;IACtC,OAAO;QAC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iBAAQ,EAAC,WAAW,EAAE,YAAY,EAAE,8BAA8B,CAAC;YACnE,GAAG,wBAAwB,EAAE;SAC7B;QACD,kBAAkB,EAAE,IAAI;KACxB;IACD;QACC,QAAQ,EAAE,gBAAgB;QAC1B,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0BAA0B;QACvC,WAAW,EAAE,uBAAuB;QACpC,MAAM,EAAE;YACP,IAAA,iBAAQ,EAAC,WAAW,EAAE,YAAY,EAAE,8BAA8B,CAAC;YACnE,IAAA,iBAAQ,EAAC,WAAW,EAAE,YAAY,EAAE,8BAA8B,CAAC;SACnE;KACD;CACD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IDataObject, IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, ITriggerFunctions, IWebhookFunctions } from 'n8n-workflow';
|
|
2
2
|
export declare const SHOPIFY_CUSTOM_CREDENTIAL_NAME = "shopifyCustomAdminApi";
|
|
3
3
|
type ShopifyFunctionContext = IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | ITriggerFunctions | IWebhookFunctions;
|
|
4
|
+
type ShopifyAuthenticationMethod = 'accessToken' | 'clientCredentials';
|
|
4
5
|
interface IShopifyGraphQLError {
|
|
5
6
|
message: string;
|
|
6
7
|
locations?: Array<{
|
|
@@ -15,11 +16,18 @@ interface IShopifyGraphQLResponse<TData = IDataObject> {
|
|
|
15
16
|
errors?: IShopifyGraphQLError[];
|
|
16
17
|
extensions?: IDataObject;
|
|
17
18
|
}
|
|
18
|
-
interface IShopifyCredentialData extends IDataObject {
|
|
19
|
+
export interface IShopifyCredentialData extends IDataObject {
|
|
19
20
|
shopSubdomain: string;
|
|
20
21
|
apiVersion?: string;
|
|
22
|
+
authenticationMethod?: string;
|
|
23
|
+
accessToken?: string;
|
|
24
|
+
clientId?: string;
|
|
25
|
+
clientSecret?: string;
|
|
26
|
+
webhookSecret?: string;
|
|
21
27
|
}
|
|
22
28
|
export declare function normalizeShopSubdomain(input: string): string;
|
|
29
|
+
export declare function resolveAuthenticationMethod(credentials: IShopifyCredentialData): ShopifyAuthenticationMethod;
|
|
30
|
+
export declare function hasUsableShopifyCredentials(credentials: IDataObject): boolean;
|
|
23
31
|
export declare function buildGraphqlUrl(credentials: IShopifyCredentialData): string;
|
|
24
32
|
export declare function executeShopifyGraphql<TData = IDataObject>(context: ShopifyFunctionContext, query: string, variables?: IDataObject, itemIndex?: number): Promise<IShopifyGraphQLResponse<TData>>;
|
|
25
33
|
export declare function assertNoGraphQLErrors(context: ShopifyFunctionContext, response: IShopifyGraphQLResponse<unknown>, itemIndex?: number): void;
|
|
@@ -2,14 +2,50 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME = void 0;
|
|
4
4
|
exports.normalizeShopSubdomain = normalizeShopSubdomain;
|
|
5
|
+
exports.resolveAuthenticationMethod = resolveAuthenticationMethod;
|
|
6
|
+
exports.hasUsableShopifyCredentials = hasUsableShopifyCredentials;
|
|
5
7
|
exports.buildGraphqlUrl = buildGraphqlUrl;
|
|
6
8
|
exports.executeShopifyGraphql = executeShopifyGraphql;
|
|
7
9
|
exports.assertNoGraphQLErrors = assertNoGraphQLErrors;
|
|
8
10
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
9
11
|
exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME = 'shopifyCustomAdminApi';
|
|
12
|
+
const ACCESS_TOKEN_TTL_SAFETY_MS = 60 * 1000;
|
|
13
|
+
const CLIENT_CREDENTIALS_TOKEN_CACHE = new Map();
|
|
10
14
|
function normalizeShopSubdomain(input) {
|
|
11
15
|
return input.trim().replace(/^https?:\/\//, '').replace(/\.myshopify\.com\/?$/, '');
|
|
12
16
|
}
|
|
17
|
+
function toOptionalString(value) {
|
|
18
|
+
if (typeof value !== 'string') {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const normalized = value.trim();
|
|
22
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
23
|
+
}
|
|
24
|
+
function resolveAuthenticationMethod(credentials) {
|
|
25
|
+
if (credentials.authenticationMethod === 'clientCredentials') {
|
|
26
|
+
return 'clientCredentials';
|
|
27
|
+
}
|
|
28
|
+
if (credentials.authenticationMethod === 'accessToken') {
|
|
29
|
+
return 'accessToken';
|
|
30
|
+
}
|
|
31
|
+
if (toOptionalString(credentials.accessToken)) {
|
|
32
|
+
return 'accessToken';
|
|
33
|
+
}
|
|
34
|
+
return 'clientCredentials';
|
|
35
|
+
}
|
|
36
|
+
function hasUsableShopifyCredentials(credentials) {
|
|
37
|
+
const typedCredentials = credentials;
|
|
38
|
+
const shopSubdomain = toOptionalString(typedCredentials.shopSubdomain);
|
|
39
|
+
if (!shopSubdomain) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const authenticationMethod = resolveAuthenticationMethod(typedCredentials);
|
|
43
|
+
if (authenticationMethod === 'accessToken') {
|
|
44
|
+
return Boolean(toOptionalString(typedCredentials.accessToken));
|
|
45
|
+
}
|
|
46
|
+
return (Boolean(toOptionalString(typedCredentials.clientId)) &&
|
|
47
|
+
Boolean(toOptionalString(typedCredentials.clientSecret)));
|
|
48
|
+
}
|
|
13
49
|
function buildGraphqlUrl(credentials) {
|
|
14
50
|
const subdomain = normalizeShopSubdomain(credentials.shopSubdomain);
|
|
15
51
|
const apiVersion = typeof credentials.apiVersion === 'string' && credentials.apiVersion.trim().length > 0
|
|
@@ -17,6 +53,20 @@ function buildGraphqlUrl(credentials) {
|
|
|
17
53
|
: '2025-10';
|
|
18
54
|
return `https://${subdomain}.myshopify.com/admin/api/${apiVersion}/graphql.json`;
|
|
19
55
|
}
|
|
56
|
+
function buildAccessTokenUrl(credentials) {
|
|
57
|
+
const subdomain = normalizeShopSubdomain(credentials.shopSubdomain);
|
|
58
|
+
return `https://${subdomain}.myshopify.com/admin/oauth/access_token`;
|
|
59
|
+
}
|
|
60
|
+
function getClientCredentialsCacheKey(credentials) {
|
|
61
|
+
return JSON.stringify({
|
|
62
|
+
shop: normalizeShopSubdomain(credentials.shopSubdomain),
|
|
63
|
+
clientId: toOptionalString(credentials.clientId),
|
|
64
|
+
clientSecret: toOptionalString(credentials.clientSecret),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function clearCachedClientCredentialsAccessToken(credentials) {
|
|
68
|
+
CLIENT_CREDENTIALS_TOKEN_CACHE.delete(getClientCredentialsCacheKey(credentials));
|
|
69
|
+
}
|
|
20
70
|
function shouldRetry(error) {
|
|
21
71
|
var _a, _b;
|
|
22
72
|
if (!error || typeof error !== 'object') {
|
|
@@ -29,31 +79,101 @@ function shouldRetry(error) {
|
|
|
29
79
|
}
|
|
30
80
|
return false;
|
|
31
81
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
82
|
+
function isAuthenticationError(error) {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
if (!error || typeof error !== 'object') {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const typedError = error;
|
|
88
|
+
const statusCode = (_b = (_a = typedError.statusCode) !== null && _a !== void 0 ? _a : typedError.httpCode) !== null && _b !== void 0 ? _b : typedError.responseCode;
|
|
89
|
+
return statusCode === 401 || statusCode === 403;
|
|
90
|
+
}
|
|
91
|
+
async function requestClientCredentialsAccessToken(context, credentials, itemIndex, forceRefresh = false) {
|
|
92
|
+
const clientId = toOptionalString(credentials.clientId);
|
|
93
|
+
const clientSecret = toOptionalString(credentials.clientSecret);
|
|
94
|
+
if (!clientId || !clientSecret) {
|
|
95
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Client ID and Client Secret are required for Dev Dashboard client credentials authentication.', { itemIndex });
|
|
96
|
+
}
|
|
97
|
+
const cacheKey = getClientCredentialsCacheKey(credentials);
|
|
98
|
+
const cachedEntry = CLIENT_CREDENTIALS_TOKEN_CACHE.get(cacheKey);
|
|
99
|
+
if (!forceRefresh &&
|
|
100
|
+
cachedEntry &&
|
|
101
|
+
Date.now() < cachedEntry.expiresAt - ACCESS_TOKEN_TTL_SAFETY_MS) {
|
|
102
|
+
return cachedEntry.token;
|
|
103
|
+
}
|
|
104
|
+
const response = (await context.helpers.httpRequest({
|
|
105
|
+
url: buildAccessTokenUrl(credentials),
|
|
37
106
|
method: 'POST',
|
|
38
107
|
headers: {
|
|
39
|
-
'Content-Type': 'application/
|
|
108
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
40
109
|
Accept: 'application/json',
|
|
41
110
|
},
|
|
42
|
-
body: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
111
|
+
body: new URLSearchParams({
|
|
112
|
+
grant_type: 'client_credentials',
|
|
113
|
+
client_id: clientId,
|
|
114
|
+
client_secret: clientSecret,
|
|
115
|
+
}),
|
|
46
116
|
json: true,
|
|
47
|
-
};
|
|
117
|
+
}));
|
|
118
|
+
const accessToken = toOptionalString(response.access_token);
|
|
119
|
+
if (!accessToken) {
|
|
120
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Shopify did not return an access token for the provided client credentials.', { itemIndex });
|
|
121
|
+
}
|
|
122
|
+
const expiresIn = typeof response.expires_in === 'number' && response.expires_in > 0
|
|
123
|
+
? response.expires_in
|
|
124
|
+
: 86399;
|
|
125
|
+
CLIENT_CREDENTIALS_TOKEN_CACHE.set(cacheKey, {
|
|
126
|
+
token: accessToken,
|
|
127
|
+
expiresAt: Date.now() + expiresIn * 1000,
|
|
128
|
+
});
|
|
129
|
+
return accessToken;
|
|
130
|
+
}
|
|
131
|
+
async function resolveAdminAccessToken(context, credentials, itemIndex, forceRefresh = false) {
|
|
132
|
+
const authenticationMethod = resolveAuthenticationMethod(credentials);
|
|
133
|
+
if (authenticationMethod === 'accessToken') {
|
|
134
|
+
const accessToken = toOptionalString(credentials.accessToken);
|
|
135
|
+
if (!accessToken) {
|
|
136
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Admin Access Token is required when using legacy token authentication.', { itemIndex });
|
|
137
|
+
}
|
|
138
|
+
return accessToken;
|
|
139
|
+
}
|
|
140
|
+
return requestClientCredentialsAccessToken(context, credentials, itemIndex, forceRefresh);
|
|
141
|
+
}
|
|
142
|
+
async function executeShopifyGraphql(context, query, variables = {}, itemIndex = 0) {
|
|
143
|
+
const credentials = (await context.getCredentials(exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME));
|
|
144
|
+
const url = buildGraphqlUrl(credentials);
|
|
48
145
|
let lastError;
|
|
146
|
+
let refreshedClientCredentialsToken = false;
|
|
49
147
|
const maxAttempts = 3;
|
|
50
148
|
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
51
149
|
try {
|
|
52
|
-
const
|
|
150
|
+
const accessToken = await resolveAdminAccessToken(context, credentials, itemIndex, refreshedClientCredentialsToken);
|
|
151
|
+
const requestOptions = {
|
|
152
|
+
url,
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: {
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
Accept: 'application/json',
|
|
157
|
+
'X-Shopify-Access-Token': accessToken,
|
|
158
|
+
},
|
|
159
|
+
body: {
|
|
160
|
+
query,
|
|
161
|
+
variables,
|
|
162
|
+
},
|
|
163
|
+
json: true,
|
|
164
|
+
};
|
|
165
|
+
const response = (await context.helpers.httpRequest(requestOptions));
|
|
53
166
|
return response;
|
|
54
167
|
}
|
|
55
168
|
catch (error) {
|
|
56
169
|
lastError = error;
|
|
170
|
+
if (resolveAuthenticationMethod(credentials) === 'clientCredentials' &&
|
|
171
|
+
isAuthenticationError(error) &&
|
|
172
|
+
!refreshedClientCredentialsToken) {
|
|
173
|
+
clearCachedClientCredentialsAccessToken(credentials);
|
|
174
|
+
refreshedClientCredentialsToken = true;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
57
177
|
if (!shouldRetry(error) || attempt === maxAttempts - 1) {
|
|
58
178
|
break;
|
|
59
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/graphql/client.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/graphql/client.ts"],"names":[],"mappings":";;;AAsDA,wDAEC;AAWD,kEAgBC;AAED,kEAgBC;AAED,0CAOC;AAgID,sDA+DC;AAED,sDAaC;AAnTD,+CAAkD;AAErC,QAAA,8BAA8B,GAAG,uBAAuB,CAAC;AAwCtE,MAAM,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC;AAC7C,MAAM,8BAA8B,GAAG,IAAI,GAAG,EAAgD,CAAC;AAE/F,SAAgB,sBAAsB,CAAC,KAAa;IACnD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,SAAgB,2BAA2B,CAC1C,WAAmC;IAEnC,IAAI,WAAW,CAAC,oBAAoB,KAAK,mBAAmB,EAAE,CAAC;QAC9D,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IAED,IAAI,WAAW,CAAC,oBAAoB,KAAK,aAAa,EAAE,CAAC;QACxD,OAAO,aAAa,CAAC;IACtB,CAAC;IAED,IAAI,gBAAgB,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;QAC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I,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,OAAO;IACR,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,0BAA0B,QAAQ,EAAE,EAAE;QACrF,SAAS;KACT,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -39,6 +39,25 @@ function asNumber(value) {
|
|
|
39
39
|
const parsed = Number(value);
|
|
40
40
|
return Number.isNaN(parsed) ? undefined : parsed;
|
|
41
41
|
}
|
|
42
|
+
function asStringArray(value) {
|
|
43
|
+
if (!Array.isArray(value)) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return value
|
|
47
|
+
.map((item) => asString(item))
|
|
48
|
+
.filter((item) => !!item);
|
|
49
|
+
}
|
|
50
|
+
function getProductVariantReadVariables(parameters) {
|
|
51
|
+
const additionalFields = new Set(asStringArray(parameters.additionalFields));
|
|
52
|
+
return {
|
|
53
|
+
includeAvailableForSale: additionalFields.has('availableForSale'),
|
|
54
|
+
includeImage: additionalFields.has('image'),
|
|
55
|
+
includeInventoryItem: additionalFields.has('inventoryItem'),
|
|
56
|
+
includeInventoryQuantity: additionalFields.has('inventoryQuantity'),
|
|
57
|
+
includeMedia: additionalFields.has('media'),
|
|
58
|
+
includeProductHandle: additionalFields.has('productHandle'),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
42
61
|
function parseTags(value) {
|
|
43
62
|
const raw = asString(value);
|
|
44
63
|
if (!raw) {
|
|
@@ -994,6 +1013,7 @@ const operationRegistry = {
|
|
|
994
1013
|
buildVariables: (parameters) => ({
|
|
995
1014
|
id: asString(parameters.variantId),
|
|
996
1015
|
...getMetafieldReadVariables(parameters),
|
|
1016
|
+
...getProductVariantReadVariables(parameters),
|
|
997
1017
|
}),
|
|
998
1018
|
mapSimplified: (data) => mapSingleNode(data, ['productVariant']),
|
|
999
1019
|
},
|
|
@@ -1002,6 +1022,7 @@ const operationRegistry = {
|
|
|
1002
1022
|
buildVariables: (parameters) => ({
|
|
1003
1023
|
...getConnectionVariables(parameters),
|
|
1004
1024
|
...getMetafieldReadVariables(parameters),
|
|
1025
|
+
...getProductVariantReadVariables(parameters),
|
|
1005
1026
|
}),
|
|
1006
1027
|
mapSimplified: (data) => mapNodesFromConnection(data, ['productVariants']),
|
|
1007
1028
|
pagination: {
|