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.
- package/LICENSE.md +19 -0
- package/README.md +68 -0
- package/dist/credentials/ShopifyCustomAdminApi.credentials.d.ts +10 -0
- package/dist/credentials/ShopifyCustomAdminApi.credentials.js +65 -0
- package/dist/credentials/ShopifyCustomAdminApi.credentials.js.map +1 -0
- package/dist/icons/shopify.dark.svg +12 -0
- package/dist/icons/shopify.svg +12 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.d.ts +15 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.js +358 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.js.map +1 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.json +18 -0
- package/dist/nodes/ShopifyCustom/config/operations/collection.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/collection.js +306 -0
- package/dist/nodes/ShopifyCustom/config/operations/collection.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/common.d.ts +13 -0
- package/dist/nodes/ShopifyCustom/config/operations/common.js +222 -0
- package/dist/nodes/ShopifyCustom/config/operations/common.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/customer.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/customer.js +107 -0
- package/dist/nodes/ShopifyCustom/config/operations/customer.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/draftOrder.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/draftOrder.js +118 -0
- package/dist/nodes/ShopifyCustom/config/operations/draftOrder.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/index.d.ts +7 -0
- package/dist/nodes/ShopifyCustom/config/operations/index.js +48 -0
- package/dist/nodes/ShopifyCustom/config/operations/index.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.js +192 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.js +125 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/metaobject.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/metaobject.js +198 -0
- package/dist/nodes/ShopifyCustom/config/operations/metaobject.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/order.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/order.js +111 -0
- package/dist/nodes/ShopifyCustom/config/operations/order.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/product.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/product.js +118 -0
- package/dist/nodes/ShopifyCustom/config/operations/product.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.js +109 -0
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/service.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/service.js +14 -0
- package/dist/nodes/ShopifyCustom/config/operations/service.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/types.d.ts +13 -0
- package/dist/nodes/ShopifyCustom/config/operations/types.js +3 -0
- package/dist/nodes/ShopifyCustom/config/operations/types.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/resources.d.ts +9 -0
- package/dist/nodes/ShopifyCustom/config/resources.js +62 -0
- package/dist/nodes/ShopifyCustom/config/resources.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.d.ts +17 -0
- package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.js +281 -0
- package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/errors.d.ts +8 -0
- package/dist/nodes/ShopifyCustom/shared/errors.js +37 -0
- package/dist/nodes/ShopifyCustom/shared/errors.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/client.d.ts +26 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/client.js +73 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/client.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.d.ts +17 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.js +962 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.js +99 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.d.ts +7 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.js +69 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.js +94 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.js +91 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.d.ts +10 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.js +223 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.js +92 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.js +95 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.js +107 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js +99 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/definitions.d.ts +24 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/definitions.js +65 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/definitions.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.js +19 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.js +122 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/types.d.ts +17 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/types.js +57 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/types.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.js +395 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.d.ts +20 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.js +61 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.js +43 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.js +103 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.js +80 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.js +110 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.js +64 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.js +89 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/output/outputMapper.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/output/outputMapper.js +82 -0
- package/dist/nodes/ShopifyCustom/shared/output/outputMapper.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.js +83 -0
- package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shopify.dark.svg +12 -0
- package/dist/nodes/ShopifyCustom/shopify.svg +12 -0
- package/dist/package.json +62 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
import type { ShopifyMetafieldOwnerType } from '../../config/resources';
|
|
3
|
+
interface IMetafieldDefinition {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
namespace: string;
|
|
7
|
+
key: string;
|
|
8
|
+
type: {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
description?: string | null;
|
|
12
|
+
ownerType: ShopifyMetafieldOwnerType;
|
|
13
|
+
}
|
|
14
|
+
export declare function encodeDefinitionOptionValue(definition: IMetafieldDefinition): string;
|
|
15
|
+
export declare function decodeDefinitionOptionValue(value: string): {
|
|
16
|
+
id: string;
|
|
17
|
+
namespace: string;
|
|
18
|
+
key: string;
|
|
19
|
+
type: string;
|
|
20
|
+
ownerType: ShopifyMetafieldOwnerType;
|
|
21
|
+
};
|
|
22
|
+
export declare function listMetafieldDefinitions(context: ILoadOptionsFunctions, ownerType: ShopifyMetafieldOwnerType, query?: string): Promise<IMetafieldDefinition[]>;
|
|
23
|
+
export declare function getMetafieldDefinitionOptions(context: ILoadOptionsFunctions, ownerType: ShopifyMetafieldOwnerType, query?: string): Promise<INodePropertyOptions[]>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeDefinitionOptionValue = encodeDefinitionOptionValue;
|
|
4
|
+
exports.decodeDefinitionOptionValue = decodeDefinitionOptionValue;
|
|
5
|
+
exports.listMetafieldDefinitions = listMetafieldDefinitions;
|
|
6
|
+
exports.getMetafieldDefinitionOptions = getMetafieldDefinitionOptions;
|
|
7
|
+
const client_1 = require("../graphql/client");
|
|
8
|
+
const metafields_1 = require("../graphql/templates/metafields");
|
|
9
|
+
const DEFINITIONS_CACHE = new Map();
|
|
10
|
+
const TTL_MS = 2 * 60 * 1000;
|
|
11
|
+
function makeCacheKey(ownerType, query) {
|
|
12
|
+
return `${ownerType}::${query !== null && query !== void 0 ? query : ''}`;
|
|
13
|
+
}
|
|
14
|
+
function encodeDefinitionOptionValue(definition) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
return JSON.stringify({
|
|
17
|
+
id: definition.id,
|
|
18
|
+
namespace: definition.namespace,
|
|
19
|
+
key: definition.key,
|
|
20
|
+
type: (_b = (_a = definition.type) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
21
|
+
ownerType: definition.ownerType,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function decodeDefinitionOptionValue(value) {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(value);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
throw new Error(`Unable to parse metafield definition option value: ${String(error)}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function listMetafieldDefinitions(context, ownerType, query = '') {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
const cacheKey = makeCacheKey(ownerType, query);
|
|
35
|
+
const cacheEntry = DEFINITIONS_CACHE.get(cacheKey);
|
|
36
|
+
if (cacheEntry && cacheEntry.expiresAt > Date.now()) {
|
|
37
|
+
return cacheEntry.data;
|
|
38
|
+
}
|
|
39
|
+
const response = await (0, client_1.executeShopifyGraphql)(context, metafields_1.METAFIELD_DEFINITION_LIST_QUERY, {
|
|
40
|
+
ownerType,
|
|
41
|
+
first: 100,
|
|
42
|
+
query: query || null,
|
|
43
|
+
}, 0);
|
|
44
|
+
(0, client_1.assertNoGraphQLErrors)(context, response, 0);
|
|
45
|
+
const definitions = (_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.metafieldDefinitions) === null || _b === void 0 ? void 0 : _b.nodes) !== null && _c !== void 0 ? _c : [];
|
|
46
|
+
DEFINITIONS_CACHE.set(cacheKey, {
|
|
47
|
+
expiresAt: Date.now() + TTL_MS,
|
|
48
|
+
data: definitions,
|
|
49
|
+
});
|
|
50
|
+
return definitions;
|
|
51
|
+
}
|
|
52
|
+
async function getMetafieldDefinitionOptions(context, ownerType, query = '') {
|
|
53
|
+
const definitions = await listMetafieldDefinitions(context, ownerType, query);
|
|
54
|
+
return definitions
|
|
55
|
+
.map((definition) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return ({
|
|
58
|
+
name: `${definition.namespace}.${definition.key} (${(_b = (_a = definition.type) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'unknown'})`,
|
|
59
|
+
value: encodeDefinitionOptionValue(definition),
|
|
60
|
+
description: definition.name,
|
|
61
|
+
});
|
|
62
|
+
})
|
|
63
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/metafields/definitions.ts"],"names":[],"mappings":";;AAkCA,kEAQC;AAED,kEAkBC;AAED,4DA8BC;AAED,sEAaC;AA5GD,8CAAiF;AACjF,gEAAkF;AAyBlF,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA+D,CAAC;AACjG,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7B,SAAS,YAAY,CAAC,SAAo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AC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAE5C,MAAM,WAAW,GAAG,MAAA,MAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,oBAAoB,0CAAE,KAAK,mCAAI,EAAE,CAAC;IACrE,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE;QAC/B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM;QAC9B,IAAI,EAAE,WAAW;KACjB,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC;AAEM,KAAK,UAAU,6BAA6B,CAClD,OAA8B,EAC9B,SAAoC,EACpC,KAAK,GAAG,EAAE;IAEV,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC9E,OAAO,WAAW;SAChB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;;QAAC,OAAA,CAAC;YACrB,IAAI,EAAE,GAAG,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,MAAA,MAAA,UAAU,CAAC,IAAI,0CAAE,IAAI,mCAAI,SAAS,GAAG;YACzF,KAAK,EAAE,2BAA2B,CAAC,UAAU,CAAC;YAC9C,WAAW,EAAE,UAAU,CAAC,IAAI;SAC5B,CAAC,CAAA;KAAA,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,3 @@
|
|
|
1
|
+
import type { ShopifyMetafieldOwnerType, ShopifyResourceValue } from '../../config/resources';
|
|
2
|
+
export declare function getOwnerTypeFromResource(resource: ShopifyResourceValue): ShopifyMetafieldOwnerType | undefined;
|
|
3
|
+
export declare function isResourceWithMetafields(resource: ShopifyResourceValue): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOwnerTypeFromResource = getOwnerTypeFromResource;
|
|
4
|
+
exports.isResourceWithMetafields = isResourceWithMetafields;
|
|
5
|
+
const OWNER_TYPE_BY_RESOURCE = {
|
|
6
|
+
product: 'PRODUCT',
|
|
7
|
+
productVariant: 'PRODUCTVARIANT',
|
|
8
|
+
collection: 'COLLECTION',
|
|
9
|
+
customer: 'CUSTOMER',
|
|
10
|
+
order: 'ORDER',
|
|
11
|
+
draftOrder: 'DRAFTORDER',
|
|
12
|
+
};
|
|
13
|
+
function getOwnerTypeFromResource(resource) {
|
|
14
|
+
return OWNER_TYPE_BY_RESOURCE[resource];
|
|
15
|
+
}
|
|
16
|
+
function isResourceWithMetafields(resource) {
|
|
17
|
+
return OWNER_TYPE_BY_RESOURCE[resource] !== undefined;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ownerTypeMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownerTypeMap.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/metafields/ownerTypeMap.ts"],"names":[],"mappings":";;AAWA,4DAIC;AAED,4DAEC;AAjBD,MAAM,sBAAsB,GAAqE;IAChG,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,gBAAgB;IAChC,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;CACxB,CAAC;AAEF,SAAgB,wBAAwB,CACvC,QAA8B;IAE9B,OAAO,sBAAsB,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,wBAAwB,CAAC,QAA8B;IACtE,OAAO,sBAAsB,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReferenceOptions = getReferenceOptions;
|
|
4
|
+
const client_1 = require("../graphql/client");
|
|
5
|
+
const REFERENCE_QUERY_MAP = {
|
|
6
|
+
product: `
|
|
7
|
+
query ProductReferences($first: Int!) {
|
|
8
|
+
products(first: $first, sortKey: UPDATED_AT, reverse: true) {
|
|
9
|
+
nodes {
|
|
10
|
+
id
|
|
11
|
+
title
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`,
|
|
16
|
+
productVariant: `
|
|
17
|
+
query ProductVariantReferences($first: Int!) {
|
|
18
|
+
productVariants(first: $first, sortKey: UPDATED_AT, reverse: true) {
|
|
19
|
+
nodes {
|
|
20
|
+
id
|
|
21
|
+
title
|
|
22
|
+
sku
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`,
|
|
27
|
+
collection: `
|
|
28
|
+
query CollectionReferences($first: Int!) {
|
|
29
|
+
collections(first: $first, sortKey: UPDATED_AT, reverse: true) {
|
|
30
|
+
nodes {
|
|
31
|
+
id
|
|
32
|
+
title
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
customer: `
|
|
38
|
+
query CustomerReferences($first: Int!) {
|
|
39
|
+
customers(first: $first, sortKey: UPDATED_AT, reverse: true) {
|
|
40
|
+
nodes {
|
|
41
|
+
id
|
|
42
|
+
displayName
|
|
43
|
+
email
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
order: `
|
|
49
|
+
query OrderReferences($first: Int!) {
|
|
50
|
+
orders(first: $first, sortKey: UPDATED_AT, reverse: true) {
|
|
51
|
+
nodes {
|
|
52
|
+
id
|
|
53
|
+
name
|
|
54
|
+
email
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`,
|
|
59
|
+
draftOrder: `
|
|
60
|
+
query DraftOrderReferences($first: Int!) {
|
|
61
|
+
draftOrders(first: $first, sortKey: UPDATED_AT, reverse: true) {
|
|
62
|
+
nodes {
|
|
63
|
+
id
|
|
64
|
+
name
|
|
65
|
+
email
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`,
|
|
70
|
+
};
|
|
71
|
+
function normalizeReferenceResource(rawValue) {
|
|
72
|
+
const parsed = String(rawValue !== null && rawValue !== void 0 ? rawValue : '').trim();
|
|
73
|
+
if (parsed === 'product' ||
|
|
74
|
+
parsed === 'productVariant' ||
|
|
75
|
+
parsed === 'collection' ||
|
|
76
|
+
parsed === 'customer' ||
|
|
77
|
+
parsed === 'order' ||
|
|
78
|
+
parsed === 'draftOrder') {
|
|
79
|
+
return parsed;
|
|
80
|
+
}
|
|
81
|
+
return 'product';
|
|
82
|
+
}
|
|
83
|
+
function getNodeDisplayName(node, resource) {
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
85
|
+
switch (resource) {
|
|
86
|
+
case 'product':
|
|
87
|
+
case 'collection':
|
|
88
|
+
return String((_a = node.title) !== null && _a !== void 0 ? _a : node.id);
|
|
89
|
+
case 'productVariant':
|
|
90
|
+
return `${String((_b = node.title) !== null && _b !== void 0 ? _b : 'Variant')} (${String((_c = node.sku) !== null && _c !== void 0 ? _c : 'no sku')})`;
|
|
91
|
+
case 'customer':
|
|
92
|
+
return `${String((_d = node.displayName) !== null && _d !== void 0 ? _d : 'Customer')} (${String((_e = node.email) !== null && _e !== void 0 ? _e : 'no email')})`;
|
|
93
|
+
case 'order':
|
|
94
|
+
case 'draftOrder':
|
|
95
|
+
return `${String((_f = node.name) !== null && _f !== void 0 ? _f : 'Order')} (${String((_g = node.email) !== null && _g !== void 0 ? _g : 'no email')})`;
|
|
96
|
+
default:
|
|
97
|
+
return String(node.id);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function getReferenceOptions(context) {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
let referenceResource = 'product';
|
|
103
|
+
try {
|
|
104
|
+
referenceResource = normalizeReferenceResource(context.getCurrentNodeParameter('referenceResource'));
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
referenceResource = 'product';
|
|
108
|
+
}
|
|
109
|
+
const response = await (0, client_1.executeShopifyGraphql)(context, REFERENCE_QUERY_MAP[referenceResource], {
|
|
110
|
+
first: 50,
|
|
111
|
+
}, 0);
|
|
112
|
+
(0, client_1.assertNoGraphQLErrors)(context, response, 0);
|
|
113
|
+
const rootValue = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a[`${referenceResource}s`]) !== null && _b !== void 0 ? _b : (_c = response.data) === null || _c === void 0 ? void 0 : _c[referenceResource];
|
|
114
|
+
const nodes = (_d = rootValue === null || rootValue === void 0 ? void 0 : rootValue.nodes) !== null && _d !== void 0 ? _d : [];
|
|
115
|
+
return nodes
|
|
116
|
+
.map((node) => ({
|
|
117
|
+
name: getNodeDisplayName(node, referenceResource),
|
|
118
|
+
value: String(node.id),
|
|
119
|
+
}))
|
|
120
|
+
.filter((item) => item.value.length > 0);
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=referenceLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referenceLoaders.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/metafields/referenceLoaders.ts"],"names":[],"mappings":";;AAwGA,kDA6BC;AApID,8CAAiF;AAIjF,MAAM,mBAAmB,GAAsC;IAC9D,OAAO,EAAE;;;;;;;;;EASR;IACD,cAAc,EAAE;;;;;;;;;;EAUf;IACD,UAAU,EAAE;;;;;;;;;EASX;IACD,QAAQ,EAAE;;;;;;;;;;EAUT;IACD,KAAK,EAAE;;;;;;;;;;EAUN;IACD,UAAU,EAAE;;;;;;;;;;EAUX;CACD,CAAC;AAEF,SAAS,0BAA0B,CAAC,QAAiB;IACpD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,aAAR,QAAQ,cAAR,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AO,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CACpD,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACR,iBAAiB,GAAG,SAAS,CAAC;IAC/B,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,IAAA,8BAAqB,EAC3C,OAAO,EACP,mBAAmB,CAAC,iBAAiB,CAAC,EACtC;QACC,KAAK,EAAE,EAAE;KACT,EACD,CAAC,CACD,CAAC;IACF,IAAA,8BAAqB,EAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAE5C,MAAM,SAAS,GAAG,MAAA,MAAA,QAAQ,CAAC,IAAI,0CAAG,GAAG,iBAAiB,GAAG,CAAC,mCAAI,MAAA,QAAQ,CAAC,IAAI,0CAAG,iBAAiB,CAAC,CAAC;IACjG,MAAM,KAAK,GAAG,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK,mCAAI,EAAE,CAAC;IACrC,OAAO,KAAK;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACf,IAAI,EAAE,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,CAAC;QACjD,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;KACtB,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IExecuteFunctions, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
type ShopifyFunctionContext = IExecuteFunctions | ILoadOptionsFunctions;
|
|
3
|
+
interface IMetafieldDefinitionTypeValidation {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
valueType: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IMetafieldDefinitionType {
|
|
9
|
+
name: string;
|
|
10
|
+
category?: string | null;
|
|
11
|
+
description?: string | null;
|
|
12
|
+
supportedValidations?: IMetafieldDefinitionTypeValidation[] | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function getMetafieldDefinitionTypes(context: ShopifyFunctionContext): Promise<IMetafieldDefinitionType[]>;
|
|
15
|
+
export declare function getMetafieldDefinitionTypeOptions(context: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
16
|
+
export declare function getDefinitionTypeByName(context: ShopifyFunctionContext, typeName: string): Promise<IMetafieldDefinitionType | undefined>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetafieldDefinitionTypes = getMetafieldDefinitionTypes;
|
|
4
|
+
exports.getMetafieldDefinitionTypeOptions = getMetafieldDefinitionTypeOptions;
|
|
5
|
+
exports.getDefinitionTypeByName = getDefinitionTypeByName;
|
|
6
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
7
|
+
const client_1 = require("../graphql/client");
|
|
8
|
+
const metafields_1 = require("../graphql/templates/metafields");
|
|
9
|
+
const TYPE_CACHE = new Map();
|
|
10
|
+
const TTL_MS = 5 * 60 * 1000;
|
|
11
|
+
function getCacheKey(credentials) {
|
|
12
|
+
var _a;
|
|
13
|
+
return `${String(credentials.shopSubdomain)}::${String((_a = credentials.apiVersion) !== null && _a !== void 0 ? _a : '2025-10')}`;
|
|
14
|
+
}
|
|
15
|
+
async function getMetafieldDefinitionTypes(context) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const credentials = (await context.getCredentials('shopifyCustomAdminApi'));
|
|
18
|
+
const cacheKey = getCacheKey(credentials);
|
|
19
|
+
const now = Date.now();
|
|
20
|
+
const cacheEntry = TYPE_CACHE.get(cacheKey);
|
|
21
|
+
if (cacheEntry && cacheEntry.expiresAt > now) {
|
|
22
|
+
return cacheEntry.data;
|
|
23
|
+
}
|
|
24
|
+
const response = await (0, client_1.executeShopifyGraphql)(context, metafields_1.METAFIELD_DEFINITION_TYPES_QUERY, {}, 0);
|
|
25
|
+
(0, client_1.assertNoGraphQLErrors)(context, response, 0);
|
|
26
|
+
const definitionTypes = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.metafieldDefinitionTypes) !== null && _b !== void 0 ? _b : [];
|
|
27
|
+
TYPE_CACHE.set(cacheKey, {
|
|
28
|
+
expiresAt: now + TTL_MS,
|
|
29
|
+
data: definitionTypes,
|
|
30
|
+
});
|
|
31
|
+
return definitionTypes;
|
|
32
|
+
}
|
|
33
|
+
async function getMetafieldDefinitionTypeOptions(context) {
|
|
34
|
+
const definitionTypes = await getMetafieldDefinitionTypes(context);
|
|
35
|
+
return definitionTypes
|
|
36
|
+
.map((definitionType) => {
|
|
37
|
+
var _a;
|
|
38
|
+
return ({
|
|
39
|
+
name: definitionType.name,
|
|
40
|
+
value: definitionType.name,
|
|
41
|
+
description: (_a = definitionType.description) !== null && _a !== void 0 ? _a : undefined,
|
|
42
|
+
});
|
|
43
|
+
})
|
|
44
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
45
|
+
}
|
|
46
|
+
async function getDefinitionTypeByName(context, typeName) {
|
|
47
|
+
if (!typeName) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const types = await getMetafieldDefinitionTypes(context);
|
|
51
|
+
const match = types.find((definitionType) => definitionType.name === typeName);
|
|
52
|
+
if (!match) {
|
|
53
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Unknown metafield type "${typeName}"`);
|
|
54
|
+
}
|
|
55
|
+
return match;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../nodes/ShopifyCustom/shared/metafields/types.ts"],"names":[],"mappings":";;AA+BA,kEAyBC;AAED,8EAWC;AAED,0DAcC;AApFD,+CAAkD;AAClD,8CA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