n8n-nodes-shopify-custom 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE.md +19 -0
  2. package/README.md +68 -0
  3. package/dist/credentials/ShopifyCustomAdminApi.credentials.d.ts +10 -0
  4. package/dist/credentials/ShopifyCustomAdminApi.credentials.js +65 -0
  5. package/dist/credentials/ShopifyCustomAdminApi.credentials.js.map +1 -0
  6. package/dist/icons/shopify.dark.svg +12 -0
  7. package/dist/icons/shopify.svg +12 -0
  8. package/dist/nodes/ShopifyCustom/ShopifyCustom.node.d.ts +15 -0
  9. package/dist/nodes/ShopifyCustom/ShopifyCustom.node.js +358 -0
  10. package/dist/nodes/ShopifyCustom/ShopifyCustom.node.js.map +1 -0
  11. package/dist/nodes/ShopifyCustom/ShopifyCustom.node.json +18 -0
  12. package/dist/nodes/ShopifyCustom/config/operations/collection.d.ts +2 -0
  13. package/dist/nodes/ShopifyCustom/config/operations/collection.js +306 -0
  14. package/dist/nodes/ShopifyCustom/config/operations/collection.js.map +1 -0
  15. package/dist/nodes/ShopifyCustom/config/operations/common.d.ts +13 -0
  16. package/dist/nodes/ShopifyCustom/config/operations/common.js +222 -0
  17. package/dist/nodes/ShopifyCustom/config/operations/common.js.map +1 -0
  18. package/dist/nodes/ShopifyCustom/config/operations/customer.d.ts +2 -0
  19. package/dist/nodes/ShopifyCustom/config/operations/customer.js +107 -0
  20. package/dist/nodes/ShopifyCustom/config/operations/customer.js.map +1 -0
  21. package/dist/nodes/ShopifyCustom/config/operations/draftOrder.d.ts +2 -0
  22. package/dist/nodes/ShopifyCustom/config/operations/draftOrder.js +118 -0
  23. package/dist/nodes/ShopifyCustom/config/operations/draftOrder.js.map +1 -0
  24. package/dist/nodes/ShopifyCustom/config/operations/index.d.ts +7 -0
  25. package/dist/nodes/ShopifyCustom/config/operations/index.js +48 -0
  26. package/dist/nodes/ShopifyCustom/config/operations/index.js.map +1 -0
  27. package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.d.ts +2 -0
  28. package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.js +192 -0
  29. package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.js.map +1 -0
  30. package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.d.ts +2 -0
  31. package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.js +125 -0
  32. package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.js.map +1 -0
  33. package/dist/nodes/ShopifyCustom/config/operations/metaobject.d.ts +2 -0
  34. package/dist/nodes/ShopifyCustom/config/operations/metaobject.js +198 -0
  35. package/dist/nodes/ShopifyCustom/config/operations/metaobject.js.map +1 -0
  36. package/dist/nodes/ShopifyCustom/config/operations/order.d.ts +2 -0
  37. package/dist/nodes/ShopifyCustom/config/operations/order.js +111 -0
  38. package/dist/nodes/ShopifyCustom/config/operations/order.js.map +1 -0
  39. package/dist/nodes/ShopifyCustom/config/operations/product.d.ts +2 -0
  40. package/dist/nodes/ShopifyCustom/config/operations/product.js +118 -0
  41. package/dist/nodes/ShopifyCustom/config/operations/product.js.map +1 -0
  42. package/dist/nodes/ShopifyCustom/config/operations/productVariant.d.ts +2 -0
  43. package/dist/nodes/ShopifyCustom/config/operations/productVariant.js +109 -0
  44. package/dist/nodes/ShopifyCustom/config/operations/productVariant.js.map +1 -0
  45. package/dist/nodes/ShopifyCustom/config/operations/service.d.ts +2 -0
  46. package/dist/nodes/ShopifyCustom/config/operations/service.js +14 -0
  47. package/dist/nodes/ShopifyCustom/config/operations/service.js.map +1 -0
  48. package/dist/nodes/ShopifyCustom/config/operations/types.d.ts +13 -0
  49. package/dist/nodes/ShopifyCustom/config/operations/types.js +3 -0
  50. package/dist/nodes/ShopifyCustom/config/operations/types.js.map +1 -0
  51. package/dist/nodes/ShopifyCustom/config/resources.d.ts +9 -0
  52. package/dist/nodes/ShopifyCustom/config/resources.js +62 -0
  53. package/dist/nodes/ShopifyCustom/config/resources.js.map +1 -0
  54. package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.d.ts +17 -0
  55. package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.js +281 -0
  56. package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.js.map +1 -0
  57. package/dist/nodes/ShopifyCustom/shared/errors.d.ts +8 -0
  58. package/dist/nodes/ShopifyCustom/shared/errors.js +37 -0
  59. package/dist/nodes/ShopifyCustom/shared/errors.js.map +1 -0
  60. package/dist/nodes/ShopifyCustom/shared/graphql/client.d.ts +26 -0
  61. package/dist/nodes/ShopifyCustom/shared/graphql/client.js +73 -0
  62. package/dist/nodes/ShopifyCustom/shared/graphql/client.js.map +1 -0
  63. package/dist/nodes/ShopifyCustom/shared/graphql/registry.d.ts +17 -0
  64. package/dist/nodes/ShopifyCustom/shared/graphql/registry.js +962 -0
  65. package/dist/nodes/ShopifyCustom/shared/graphql/registry.js.map +1 -0
  66. package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.d.ts +5 -0
  67. package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.js +99 -0
  68. package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.js.map +1 -0
  69. package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.d.ts +7 -0
  70. package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.js +69 -0
  71. package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.js.map +1 -0
  72. package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.d.ts +5 -0
  73. package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.js +94 -0
  74. package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.js.map +1 -0
  75. package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.d.ts +5 -0
  76. package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.js +91 -0
  77. package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.js.map +1 -0
  78. package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.d.ts +10 -0
  79. package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.js +223 -0
  80. package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.js.map +1 -0
  81. package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.d.ts +5 -0
  82. package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.js +92 -0
  83. package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.js.map +1 -0
  84. package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.d.ts +5 -0
  85. package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.js +95 -0
  86. package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.js.map +1 -0
  87. package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.d.ts +5 -0
  88. package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.js +107 -0
  89. package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.js.map +1 -0
  90. package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.d.ts +5 -0
  91. package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js +99 -0
  92. package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js.map +1 -0
  93. package/dist/nodes/ShopifyCustom/shared/metafields/definitions.d.ts +24 -0
  94. package/dist/nodes/ShopifyCustom/shared/metafields/definitions.js +65 -0
  95. package/dist/nodes/ShopifyCustom/shared/metafields/definitions.js.map +1 -0
  96. package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.d.ts +3 -0
  97. package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.js +19 -0
  98. package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.js.map +1 -0
  99. package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.d.ts +2 -0
  100. package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.js +122 -0
  101. package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.js.map +1 -0
  102. package/dist/nodes/ShopifyCustom/shared/metafields/types.d.ts +17 -0
  103. package/dist/nodes/ShopifyCustom/shared/metafields/types.js +57 -0
  104. package/dist/nodes/ShopifyCustom/shared/metafields/types.js.map +1 -0
  105. package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.d.ts +2 -0
  106. package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.js +395 -0
  107. package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.js.map +1 -0
  108. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.d.ts +20 -0
  109. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.js +61 -0
  110. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.js.map +1 -0
  111. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.d.ts +3 -0
  112. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.js +43 -0
  113. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.js.map +1 -0
  114. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.d.ts +2 -0
  115. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.js +103 -0
  116. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.js.map +1 -0
  117. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.d.ts +2 -0
  118. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.js +80 -0
  119. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.js.map +1 -0
  120. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.d.ts +2 -0
  121. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.js +110 -0
  122. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.js.map +1 -0
  123. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.d.ts +2 -0
  124. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.js +64 -0
  125. package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.js.map +1 -0
  126. package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.d.ts +3 -0
  127. package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.js +89 -0
  128. package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.js.map +1 -0
  129. package/dist/nodes/ShopifyCustom/shared/output/outputMapper.d.ts +3 -0
  130. package/dist/nodes/ShopifyCustom/shared/output/outputMapper.js +82 -0
  131. package/dist/nodes/ShopifyCustom/shared/output/outputMapper.js.map +1 -0
  132. package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.d.ts +2 -0
  133. package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.js +83 -0
  134. package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.js.map +1 -0
  135. package/dist/nodes/ShopifyCustom/shopify.dark.svg +12 -0
  136. package/dist/nodes/ShopifyCustom/shopify.svg +12 -0
  137. package/dist/package.json +62 -0
  138. package/dist/tsconfig.tsbuildinfo +1 -0
  139. package/package.json +62 -0
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SHOPIFY_RESOURCE_DEFINITIONS = void 0;
4
+ exports.SHOPIFY_RESOURCE_DEFINITIONS = [
5
+ {
6
+ value: 'product',
7
+ name: 'Product',
8
+ description: 'Create, read, update and delete products',
9
+ ownerType: 'PRODUCT',
10
+ },
11
+ {
12
+ value: 'productVariant',
13
+ name: 'Product Variant',
14
+ description: 'Create, read, update and delete product variants',
15
+ ownerType: 'PRODUCTVARIANT',
16
+ },
17
+ {
18
+ value: 'collection',
19
+ name: 'Collection',
20
+ description: 'Manage Shopify collections',
21
+ ownerType: 'COLLECTION',
22
+ },
23
+ {
24
+ value: 'customer',
25
+ name: 'Customer',
26
+ description: 'Manage customer records',
27
+ ownerType: 'CUSTOMER',
28
+ },
29
+ {
30
+ value: 'order',
31
+ name: 'Order',
32
+ description: 'Create and manage orders',
33
+ ownerType: 'ORDER',
34
+ },
35
+ {
36
+ value: 'draftOrder',
37
+ name: 'Draft Order',
38
+ description: 'Manage draft orders',
39
+ ownerType: 'DRAFTORDER',
40
+ },
41
+ {
42
+ value: 'metaobject',
43
+ name: 'Metaobject',
44
+ description: 'Manage Shopify metaobjects',
45
+ },
46
+ {
47
+ value: 'metafieldValue',
48
+ name: 'Metafield Value',
49
+ description: 'Set, read and delete metafield values',
50
+ },
51
+ {
52
+ value: 'metafieldDefinition',
53
+ name: 'Metafield Definition',
54
+ description: 'Create, read, update and delete metafield definitions',
55
+ },
56
+ {
57
+ value: 'service',
58
+ name: 'Service',
59
+ description: 'Service utilities',
60
+ },
61
+ ];
62
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../../nodes/ShopifyCustom/config/resources.ts"],"names":[],"mappings":";;;AA2Ba,QAAA,4BAA4B,GAAiC;IACzE;QACC,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,0CAA0C;QACvD,SAAS,EAAE,SAAS;KACpB;IACD;QACC,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,kDAAkD;QAC/D,SAAS,EAAE,gBAAgB;KAC3B;IACD;QACC,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,4BAA4B;QACzC,SAAS,EAAE,YAAY;KACvB;IACD;QACC,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,yBAAyB;QACtC,SAAS,EAAE,UAAU;KACrB;IACD;QACC,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,0BAA0B;QACvC,SAAS,EAAE,OAAO;KAClB;IACD;QACC,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,qBAAqB;QAClC,SAAS,EAAE,YAAY;KACvB;IACD;QACC,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,4BAA4B;KACzC;IACD;QACC,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,uCAAuC;KACpD;IACD;QACC,KAAK,EAAE,qBAAqB;QAC5B,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,uDAAuD;KACpE;IACD;QACC,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,mBAAmB;KAChC;CACD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
2
+ export type CollectionRuleValueType = 'text' | 'number' | 'boolean' | 'metaobject_reference';
3
+ export interface IEncodedMetafieldRuleOption {
4
+ ruleType: string;
5
+ defaultRelation: string;
6
+ allowedRelations: string[];
7
+ definitionId: string;
8
+ namespace: string;
9
+ key: string;
10
+ name: string;
11
+ typeName: string;
12
+ valueType: CollectionRuleValueType;
13
+ }
14
+ export declare function decodeMetafieldRuleOptionValue(value: string): IEncodedMetafieldRuleOption | undefined;
15
+ export declare function getCollectionNativeRuleTypeOptions(context: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
16
+ export declare function getCollectionMetafieldRuleOptions(context: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
17
+ export declare function getCollectionRuleRelationOptions(context: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeMetafieldRuleOptionValue = decodeMetafieldRuleOptionValue;
4
+ exports.getCollectionNativeRuleTypeOptions = getCollectionNativeRuleTypeOptions;
5
+ exports.getCollectionMetafieldRuleOptions = getCollectionMetafieldRuleOptions;
6
+ exports.getCollectionRuleRelationOptions = getCollectionRuleRelationOptions;
7
+ const client_1 = require("../graphql/client");
8
+ const COLLECTION_RULE_CONDITIONS_QUERY = `
9
+ query CollectionRuleConditions {
10
+ collectionRulesConditions {
11
+ ruleType
12
+ defaultRelation
13
+ allowedRelations
14
+ ruleObject {
15
+ __typename
16
+ ... on CollectionRuleMetafieldCondition {
17
+ metafieldDefinition {
18
+ id
19
+ name
20
+ namespace
21
+ key
22
+ type {
23
+ name
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ `;
31
+ const CACHE_TTL_MS = 2 * 60 * 1000;
32
+ let ruleConditionsCache;
33
+ function asString(value) {
34
+ return String(value !== null && value !== void 0 ? value : '').trim();
35
+ }
36
+ function isObject(value) {
37
+ return !!value && typeof value === 'object' && !Array.isArray(value);
38
+ }
39
+ function toLabel(value) {
40
+ return value
41
+ .toLowerCase()
42
+ .split('_')
43
+ .filter((chunk) => chunk.length > 0)
44
+ .map((chunk) => chunk[0].toUpperCase() + chunk.slice(1))
45
+ .join(' ');
46
+ }
47
+ function inferMetafieldValueType(typeName) {
48
+ const normalizedType = typeName.toLowerCase();
49
+ if (normalizedType === 'boolean') {
50
+ return 'boolean';
51
+ }
52
+ if (normalizedType === 'number_integer' ||
53
+ normalizedType === 'number_decimal' ||
54
+ normalizedType === 'rating') {
55
+ return 'number';
56
+ }
57
+ if (normalizedType === 'metaobject_reference') {
58
+ return 'metaobject_reference';
59
+ }
60
+ return 'text';
61
+ }
62
+ function normalizeRuleConditions(value) {
63
+ if (!Array.isArray(value)) {
64
+ return { nativeRules: [], metafieldRules: [] };
65
+ }
66
+ const nativeRulesMap = new Map();
67
+ const metafieldRules = [];
68
+ for (const item of value) {
69
+ if (!item || typeof item !== 'object') {
70
+ continue;
71
+ }
72
+ const typedItem = item;
73
+ const ruleType = asString(typedItem.ruleType);
74
+ if (!ruleType) {
75
+ continue;
76
+ }
77
+ const defaultRelation = asString(typedItem.defaultRelation);
78
+ const allowedRelations = Array.isArray(typedItem.allowedRelations)
79
+ ? typedItem.allowedRelations
80
+ .map((relation) => asString(relation))
81
+ .filter((relation) => relation.length > 0)
82
+ : [];
83
+ const ruleObject = typedItem.ruleObject && typeof typedItem.ruleObject === 'object'
84
+ ? typedItem.ruleObject
85
+ : undefined;
86
+ const typename = asString(ruleObject === null || ruleObject === void 0 ? void 0 : ruleObject.__typename);
87
+ if (typename === 'CollectionRuleMetafieldCondition') {
88
+ const definitionRaw = (ruleObject === null || ruleObject === void 0 ? void 0 : ruleObject.metafieldDefinition) && typeof ruleObject.metafieldDefinition === 'object'
89
+ ? ruleObject.metafieldDefinition
90
+ : undefined;
91
+ const definitionId = asString(definitionRaw === null || definitionRaw === void 0 ? void 0 : definitionRaw.id);
92
+ const namespace = asString(definitionRaw === null || definitionRaw === void 0 ? void 0 : definitionRaw.namespace);
93
+ const key = asString(definitionRaw === null || definitionRaw === void 0 ? void 0 : definitionRaw.key);
94
+ const name = asString(definitionRaw === null || definitionRaw === void 0 ? void 0 : definitionRaw.name);
95
+ const typeObject = (definitionRaw === null || definitionRaw === void 0 ? void 0 : definitionRaw.type) && typeof definitionRaw.type === 'object'
96
+ ? definitionRaw.type
97
+ : undefined;
98
+ const typeName = asString(typeObject === null || typeObject === void 0 ? void 0 : typeObject.name);
99
+ if (!definitionId || !namespace || !key || !typeName) {
100
+ continue;
101
+ }
102
+ metafieldRules.push({
103
+ ruleType,
104
+ defaultRelation,
105
+ allowedRelations,
106
+ definitionId,
107
+ name: name || `${namespace}.${key}`,
108
+ namespace,
109
+ key,
110
+ typeName,
111
+ valueType: inferMetafieldValueType(typeName),
112
+ });
113
+ continue;
114
+ }
115
+ if (!nativeRulesMap.has(ruleType)) {
116
+ nativeRulesMap.set(ruleType, {
117
+ ruleType,
118
+ defaultRelation,
119
+ allowedRelations,
120
+ });
121
+ }
122
+ }
123
+ return {
124
+ nativeRules: Array.from(nativeRulesMap.values()),
125
+ metafieldRules,
126
+ };
127
+ }
128
+ async function listCollectionRuleConditions(context) {
129
+ var _a;
130
+ if (ruleConditionsCache && ruleConditionsCache.expiresAt > Date.now()) {
131
+ return ruleConditionsCache.data;
132
+ }
133
+ const response = await (0, client_1.executeShopifyGraphql)(context, COLLECTION_RULE_CONDITIONS_QUERY, {}, 0);
134
+ (0, client_1.assertNoGraphQLErrors)(context, response, 0);
135
+ const data = normalizeRuleConditions((_a = response.data) === null || _a === void 0 ? void 0 : _a.collectionRulesConditions);
136
+ ruleConditionsCache = {
137
+ expiresAt: Date.now() + CACHE_TTL_MS,
138
+ data,
139
+ };
140
+ return data;
141
+ }
142
+ function getCurrentStringParameter(context, parameterName) {
143
+ try {
144
+ const value = asString(context.getCurrentNodeParameter(parameterName));
145
+ return value.length > 0 ? value : undefined;
146
+ }
147
+ catch {
148
+ return undefined;
149
+ }
150
+ }
151
+ function getCurrentRuleValues(context) {
152
+ const values = {
153
+ ruleSource: getCurrentStringParameter(context, 'ruleSource'),
154
+ nativeRuleType: getCurrentStringParameter(context, 'nativeRuleType'),
155
+ metafieldRule: getCurrentStringParameter(context, 'metafieldRule'),
156
+ };
157
+ if (values.ruleSource && (values.nativeRuleType || values.metafieldRule)) {
158
+ return values;
159
+ }
160
+ const currentParameters = context.getCurrentNodeParameters();
161
+ if (!isObject(currentParameters)) {
162
+ return values;
163
+ }
164
+ const collectionRules = currentParameters.collectionRules;
165
+ if (!isObject(collectionRules)) {
166
+ return values;
167
+ }
168
+ const ruleItemsRaw = collectionRules.items;
169
+ if (!Array.isArray(ruleItemsRaw) || ruleItemsRaw.length === 0) {
170
+ return values;
171
+ }
172
+ const currentRule = ruleItemsRaw[ruleItemsRaw.length - 1];
173
+ if (!isObject(currentRule)) {
174
+ return values;
175
+ }
176
+ if (!values.ruleSource) {
177
+ const source = asString(currentRule.ruleSource);
178
+ if (source) {
179
+ values.ruleSource = source;
180
+ }
181
+ }
182
+ if (!values.nativeRuleType) {
183
+ const nativeRuleType = asString(currentRule.nativeRuleType);
184
+ if (nativeRuleType) {
185
+ values.nativeRuleType = nativeRuleType;
186
+ }
187
+ }
188
+ if (!values.metafieldRule) {
189
+ const metafieldRule = asString(currentRule.metafieldRule);
190
+ if (metafieldRule) {
191
+ values.metafieldRule = metafieldRule;
192
+ }
193
+ }
194
+ return values;
195
+ }
196
+ function encodeMetafieldRuleOptionValue(rule) {
197
+ const encoded = {
198
+ ruleType: rule.ruleType,
199
+ defaultRelation: rule.defaultRelation,
200
+ allowedRelations: rule.allowedRelations,
201
+ definitionId: rule.definitionId,
202
+ namespace: rule.namespace,
203
+ key: rule.key,
204
+ name: rule.name,
205
+ typeName: rule.typeName,
206
+ valueType: rule.valueType,
207
+ };
208
+ return JSON.stringify(encoded);
209
+ }
210
+ function decodeMetafieldRuleOptionValue(value) {
211
+ try {
212
+ const parsed = JSON.parse(value);
213
+ if (!parsed ||
214
+ typeof parsed !== 'object' ||
215
+ !parsed.ruleType ||
216
+ !parsed.definitionId ||
217
+ !parsed.namespace ||
218
+ !parsed.key ||
219
+ !parsed.typeName ||
220
+ !parsed.valueType) {
221
+ return undefined;
222
+ }
223
+ return parsed;
224
+ }
225
+ catch {
226
+ return undefined;
227
+ }
228
+ }
229
+ async function getCollectionNativeRuleTypeOptions(context) {
230
+ const conditions = await listCollectionRuleConditions(context);
231
+ return conditions.nativeRules
232
+ .map((rule) => ({
233
+ name: toLabel(rule.ruleType),
234
+ value: rule.ruleType,
235
+ }))
236
+ .sort((a, b) => a.name.localeCompare(b.name));
237
+ }
238
+ async function getCollectionMetafieldRuleOptions(context) {
239
+ const conditions = await listCollectionRuleConditions(context);
240
+ return conditions.metafieldRules
241
+ .map((rule) => ({
242
+ name: `${rule.namespace}.${rule.key} (${rule.typeName})`,
243
+ value: encodeMetafieldRuleOptionValue(rule),
244
+ description: rule.name,
245
+ }))
246
+ .sort((a, b) => a.name.localeCompare(b.name));
247
+ }
248
+ async function getCollectionRuleRelationOptions(context) {
249
+ var _a, _b, _c, _d;
250
+ const conditions = await listCollectionRuleConditions(context);
251
+ const currentRuleValues = getCurrentRuleValues(context);
252
+ const ruleSource = (_a = currentRuleValues.ruleSource) !== null && _a !== void 0 ? _a : 'native';
253
+ let allowedRelations = [];
254
+ if (ruleSource === 'metafield') {
255
+ const encoded = currentRuleValues.metafieldRule;
256
+ if (encoded) {
257
+ const decoded = decodeMetafieldRuleOptionValue(encoded);
258
+ allowedRelations = (_b = decoded === null || decoded === void 0 ? void 0 : decoded.allowedRelations) !== null && _b !== void 0 ? _b : [];
259
+ }
260
+ }
261
+ else {
262
+ const selectedRuleType = currentRuleValues.nativeRuleType;
263
+ if (selectedRuleType) {
264
+ allowedRelations =
265
+ (_d = (_c = conditions.nativeRules.find((rule) => rule.ruleType === selectedRuleType)) === null || _c === void 0 ? void 0 : _c.allowedRelations) !== null && _d !== void 0 ? _d : [];
266
+ }
267
+ else {
268
+ allowedRelations = conditions.nativeRules.flatMap((rule) => rule.allowedRelations);
269
+ }
270
+ }
271
+ if (allowedRelations.length === 0) {
272
+ return [];
273
+ }
274
+ return Array.from(new Set(allowedRelations))
275
+ .map((relation) => ({
276
+ name: toLabel(relation),
277
+ value: relation,
278
+ }))
279
+ .sort((a, b) => a.name.localeCompare(b.name));
280
+ }
281
+ //# sourceMappingURL=ruleConditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ruleConditions.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/collections/ruleConditions.ts"],"names":[],"mappings":";;AA4TA,wEAmBC;AAED,gFAUC;AAED,8EAWC;AAED,4EAmCC;AA5YD,8CAAiF;AA+DjF,MAAM,gCAAgC,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBxC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,IAAI,mBAAiF,CAAC;AAEtF,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,MAAM,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC;AAED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AAC,aAAa,CAAC;QAChD,IAAI,OAAO,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,8BAA8B,CAAC,OAAO,CAAC,CAAC;YACxD,gBAAgB,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,mCAAI,EAAE,CAAC;QACpD,CAAC;IACF,CAAC;SAAM,CAAC;QACP,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,cAAc,CAAC;QAC1D,IAAI,gBAAgB,EAAE,CAAC;YACtB,gBAAgB;gBACf,MAAA,MAAA,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,gBAAgB,CAAC,0CAAE,gBAAgB,mCAC3F,EAAE,CAAC;QACL,CAAC;aAAM,CAAC;YACP,gBAAgB,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACpF,CAAC;IACF,CAAC;IAED,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC;IACX,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;SAC1C,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;QACvB,KAAK,EAAE,QAAQ;KACf,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { IDataObject, IExecuteFunctions } from 'n8n-workflow';
2
+ export interface IShopifyUserError {
3
+ field?: string[] | null;
4
+ message: string;
5
+ code?: string | null;
6
+ }
7
+ export declare function throwIfUserErrors(executeFunctions: IExecuteFunctions, userErrors: IShopifyUserError[] | null | undefined, itemIndex: number): void;
8
+ export declare function getErrorData(error: unknown): IDataObject;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.throwIfUserErrors = throwIfUserErrors;
4
+ exports.getErrorData = getErrorData;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ function renderFieldPath(field) {
7
+ if (!field || field.length === 0) {
8
+ return '';
9
+ }
10
+ return field.join('.');
11
+ }
12
+ function throwIfUserErrors(executeFunctions, userErrors, itemIndex) {
13
+ if (!userErrors || userErrors.length === 0) {
14
+ return;
15
+ }
16
+ const messages = userErrors.map((userError) => {
17
+ const fieldPath = renderFieldPath(userError.field);
18
+ const code = userError.code ? ` [${userError.code}]` : '';
19
+ return fieldPath
20
+ ? `${userError.message}${code} (field: ${fieldPath})`
21
+ : `${userError.message}${code}`;
22
+ });
23
+ throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), `Shopify user error: ${messages.join('; ')}`, { itemIndex });
24
+ }
25
+ function getErrorData(error) {
26
+ if (error instanceof Error) {
27
+ return {
28
+ message: error.message,
29
+ name: error.name,
30
+ stack: error.stack,
31
+ };
32
+ }
33
+ return {
34
+ message: String(error),
35
+ };
36
+ }
37
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../nodes/ShopifyCustom/shared/errors.ts"],"names":[],"mappings":";;AAgBA,8CAsBC;AAED,oCAYC;AAnDD,+CAAkD;AAQlD,SAAS,eAAe,CAAC,KAAkC;IAC1D,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAgB,iBAAiB,CAChC,gBAAmC,EACnC,UAAkD,EAClD,SAAiB;IAEjB,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO;IACR,CAAC;IAED,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAC7C,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,OAAO,SAAS;YACf,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,GAAG,IAAI,YAAY,SAAS,GAAG;YACrD,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,iCAAkB,CAC3B,gBAAgB,CAAC,OAAO,EAAE,EAC1B,uBAAuB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAC5C,EAAE,SAAS,EAAE,CACb,CAAC;AACH,CAAC;AAED,SAAgB,YAAY,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC5B,OAAO;YACN,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SAClB,CAAC;IACH,CAAC;IAED,OAAO;QACN,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;KACtB,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-workflow';
2
+ export declare const SHOPIFY_CUSTOM_CREDENTIAL_NAME = "shopifyCustomAdminApi";
3
+ type ShopifyFunctionContext = IExecuteFunctions | ILoadOptionsFunctions;
4
+ interface IShopifyGraphQLError {
5
+ message: string;
6
+ locations?: Array<{
7
+ line: number;
8
+ column: number;
9
+ }>;
10
+ path?: string[];
11
+ extensions?: IDataObject;
12
+ }
13
+ interface IShopifyGraphQLResponse<TData = IDataObject> {
14
+ data?: TData;
15
+ errors?: IShopifyGraphQLError[];
16
+ extensions?: IDataObject;
17
+ }
18
+ interface IShopifyCredentialData extends IDataObject {
19
+ shopSubdomain: string;
20
+ apiVersion?: string;
21
+ }
22
+ export declare function normalizeShopSubdomain(input: string): string;
23
+ export declare function buildGraphqlUrl(credentials: IShopifyCredentialData): string;
24
+ export declare function executeShopifyGraphql<TData = IDataObject>(context: ShopifyFunctionContext, query: string, variables?: IDataObject, itemIndex?: number): Promise<IShopifyGraphQLResponse<TData>>;
25
+ export declare function assertNoGraphQLErrors(context: ShopifyFunctionContext, response: IShopifyGraphQLResponse<unknown>, itemIndex?: number): void;
26
+ export {};
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME = void 0;
4
+ exports.normalizeShopSubdomain = normalizeShopSubdomain;
5
+ exports.buildGraphqlUrl = buildGraphqlUrl;
6
+ exports.executeShopifyGraphql = executeShopifyGraphql;
7
+ exports.assertNoGraphQLErrors = assertNoGraphQLErrors;
8
+ const n8n_workflow_1 = require("n8n-workflow");
9
+ exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME = 'shopifyCustomAdminApi';
10
+ function normalizeShopSubdomain(input) {
11
+ return input.trim().replace(/^https?:\/\//, '').replace(/\.myshopify\.com\/?$/, '');
12
+ }
13
+ function buildGraphqlUrl(credentials) {
14
+ const subdomain = normalizeShopSubdomain(credentials.shopSubdomain);
15
+ const apiVersion = typeof credentials.apiVersion === 'string' && credentials.apiVersion.trim().length > 0
16
+ ? credentials.apiVersion.trim()
17
+ : '2025-10';
18
+ return `https://${subdomain}.myshopify.com/admin/api/${apiVersion}/graphql.json`;
19
+ }
20
+ function shouldRetry(error) {
21
+ var _a, _b;
22
+ if (!error || typeof error !== 'object') {
23
+ return false;
24
+ }
25
+ const typedError = error;
26
+ const statusCode = (_b = (_a = typedError.statusCode) !== null && _a !== void 0 ? _a : typedError.httpCode) !== null && _b !== void 0 ? _b : typedError.responseCode;
27
+ if (typeof statusCode === 'number') {
28
+ return statusCode === 429 || statusCode >= 500;
29
+ }
30
+ return false;
31
+ }
32
+ async function executeShopifyGraphql(context, query, variables = {}, itemIndex = 0) {
33
+ const credentials = (await context.getCredentials(exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME));
34
+ const url = buildGraphqlUrl(credentials);
35
+ const requestOptions = {
36
+ url,
37
+ method: 'POST',
38
+ headers: {
39
+ 'Content-Type': 'application/json',
40
+ Accept: 'application/json',
41
+ },
42
+ body: {
43
+ query,
44
+ variables,
45
+ },
46
+ json: true,
47
+ };
48
+ let lastError;
49
+ const maxAttempts = 3;
50
+ for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
51
+ try {
52
+ const response = (await context.helpers.httpRequestWithAuthentication.call(context, exports.SHOPIFY_CUSTOM_CREDENTIAL_NAME, requestOptions));
53
+ return response;
54
+ }
55
+ catch (error) {
56
+ lastError = error;
57
+ if (!shouldRetry(error) || attempt === maxAttempts - 1) {
58
+ break;
59
+ }
60
+ }
61
+ }
62
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), lastError, { itemIndex });
63
+ }
64
+ function assertNoGraphQLErrors(context, response, itemIndex = 0) {
65
+ if (!response.errors || response.errors.length === 0) {
66
+ return;
67
+ }
68
+ const messages = response.errors.map((error) => error.message).join('; ');
69
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Shopify GraphQL error: ${messages}`, {
70
+ itemIndex,
71
+ });
72
+ }
73
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/graphql/client.ts"],"names":[],"mappings":";;;AA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AAG,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"}
@@ -0,0 +1,17 @@
1
+ import type { IDataObject } from 'n8n-workflow';
2
+ import type { IShopifyUserError } from '../errors';
3
+ import type { ShopifyOperationKey } from '../../config/operations/types';
4
+ interface IRegistryPaginationConfig {
5
+ connectionPath: string[];
6
+ firstVariableName?: string;
7
+ afterVariableName?: string;
8
+ }
9
+ export interface IRegistryOperation {
10
+ document: string;
11
+ buildVariables(parameters: IDataObject): IDataObject;
12
+ mapSimplified(data: IDataObject): unknown;
13
+ getUserErrors?(data: IDataObject): IShopifyUserError[] | undefined;
14
+ pagination?: IRegistryPaginationConfig;
15
+ }
16
+ export declare function getRegistryOperation(operationKey: ShopifyOperationKey): IRegistryOperation;
17
+ export {};