n8n-nodes-labelzoom 0.0.1
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 +21 -0
- package/README.md +158 -0
- package/dist/credentials/LabelZoomApi.credentials.d.ts +10 -0
- package/dist/credentials/LabelZoomApi.credentials.js +54 -0
- package/dist/credentials/LabelZoomApi.credentials.js.map +1 -0
- package/dist/icons/labelzoom.dark.svg +1 -0
- package/dist/icons/labelzoom.svg +1 -0
- package/dist/nodes/LabelZoom/LabelZoom.node.d.ts +13 -0
- package/dist/nodes/LabelZoom/LabelZoom.node.js +118 -0
- package/dist/nodes/LabelZoom/LabelZoom.node.js.map +1 -0
- package/dist/nodes/LabelZoom/LabelZoom.node.json +12 -0
- package/dist/nodes/LabelZoom/listSearch/getPrinters.d.ts +2 -0
- package/dist/nodes/LabelZoom/listSearch/getPrinters.js +24 -0
- package/dist/nodes/LabelZoom/listSearch/getPrinters.js.map +1 -0
- package/dist/nodes/LabelZoom/listSearch/getTemplates.d.ts +2 -0
- package/dist/nodes/LabelZoom/listSearch/getTemplates.js +25 -0
- package/dist/nodes/LabelZoom/listSearch/getTemplates.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/label/convert.d.ts +3 -0
- package/dist/nodes/LabelZoom/resources/label/convert.js +79 -0
- package/dist/nodes/LabelZoom/resources/label/convert.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/label/convertTemplate.d.ts +3 -0
- package/dist/nodes/LabelZoom/resources/label/convertTemplate.js +95 -0
- package/dist/nodes/LabelZoom/resources/label/convertTemplate.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/label/index.d.ts +4 -0
- package/dist/nodes/LabelZoom/resources/label/index.js +36 -0
- package/dist/nodes/LabelZoom/resources/label/index.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/printer/index.d.ts +5 -0
- package/dist/nodes/LabelZoom/resources/printer/index.js +60 -0
- package/dist/nodes/LabelZoom/resources/printer/index.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/printer/print.d.ts +3 -0
- package/dist/nodes/LabelZoom/resources/printer/print.js +117 -0
- package/dist/nodes/LabelZoom/resources/printer/print.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/printer/printTemplate.d.ts +3 -0
- package/dist/nodes/LabelZoom/resources/printer/printTemplate.js +65 -0
- package/dist/nodes/LabelZoom/resources/printer/printTemplate.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/printer/reads.d.ts +5 -0
- package/dist/nodes/LabelZoom/resources/printer/reads.js +39 -0
- package/dist/nodes/LabelZoom/resources/printer/reads.js.map +1 -0
- package/dist/nodes/LabelZoom/resources/printer/shared.d.ts +10 -0
- package/dist/nodes/LabelZoom/resources/printer/shared.js +68 -0
- package/dist/nodes/LabelZoom/resources/printer/shared.js.map +1 -0
- package/dist/nodes/LabelZoom/shared/descriptions.d.ts +9 -0
- package/dist/nodes/LabelZoom/shared/descriptions.js +214 -0
- package/dist/nodes/LabelZoom/shared/descriptions.js.map +1 -0
- package/dist/nodes/LabelZoom/shared/formats.d.ts +13 -0
- package/dist/nodes/LabelZoom/shared/formats.js +114 -0
- package/dist/nodes/LabelZoom/shared/formats.js.map +1 -0
- package/dist/nodes/LabelZoom/shared/options.d.ts +22 -0
- package/dist/nodes/LabelZoom/shared/options.js +98 -0
- package/dist/nodes/LabelZoom/shared/options.js.map +1 -0
- package/dist/nodes/LabelZoom/shared/transport.d.ts +33 -0
- package/dist/nodes/LabelZoom/shared/transport.js +216 -0
- package/dist/nodes/LabelZoom/shared/transport.js.map +1 -0
- package/dist/nodes/LabelZoom/shared/utils.d.ts +3 -0
- package/dist/nodes/LabelZoom/shared/utils.js +35 -0
- package/dist/nodes/LabelZoom/shared/utils.js.map +1 -0
- package/dist/nodes/LabelZoom/shared/validation.d.ts +9 -0
- package/dist/nodes/LabelZoom/shared/validation.js +12 -0
- package/dist/nodes/LabelZoom/shared/validation.js.map +1 -0
- package/dist/package.json +70 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertTemplateDescription = void 0;
|
|
4
|
+
exports.convertTemplate = convertTemplate;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const formats_1 = require("../../shared/formats");
|
|
7
|
+
const transport_1 = require("../../shared/transport");
|
|
8
|
+
const utils_1 = require("../../shared/utils");
|
|
9
|
+
const shared_1 = require("../printer/shared");
|
|
10
|
+
const showFor = { resource: ['label'], operation: ['convertTemplate'] };
|
|
11
|
+
exports.convertTemplateDescription = [
|
|
12
|
+
(0, shared_1.templateLocator)(showFor),
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Merge Data (JSON)',
|
|
15
|
+
name: 'mergeData',
|
|
16
|
+
type: 'json',
|
|
17
|
+
default: '{}',
|
|
18
|
+
required: true,
|
|
19
|
+
description: 'Values for the template\'s merge fields, keyed by field name. Use the Get Template operation, or the LabelZoom dashboard, to see which fields a template exposes.',
|
|
20
|
+
displayOptions: { show: showFor },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Target Format',
|
|
24
|
+
name: 'targetFormat',
|
|
25
|
+
type: 'options',
|
|
26
|
+
options: [
|
|
27
|
+
{ name: 'Template Default', value: '' },
|
|
28
|
+
...(0, formats_1.formatOptions)(formats_1.TARGET_FORMATS),
|
|
29
|
+
],
|
|
30
|
+
default: '',
|
|
31
|
+
description: "Override the template's own default output format",
|
|
32
|
+
displayOptions: { show: showFor },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
displayName: 'Output Binary Field',
|
|
36
|
+
name: 'outputBinaryPropertyName',
|
|
37
|
+
type: 'string',
|
|
38
|
+
default: 'data',
|
|
39
|
+
required: true,
|
|
40
|
+
hint: 'The name of the output field to put the rendered label in',
|
|
41
|
+
displayOptions: { show: showFor },
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
async function convertTemplate(itemIndex) {
|
|
45
|
+
const templateId = utils_1.resourceId.call(this, 'templateId', itemIndex);
|
|
46
|
+
const targetFormat = this.getNodeParameter('targetFormat', itemIndex, '');
|
|
47
|
+
const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', itemIndex);
|
|
48
|
+
const rawMergeData = this.getNodeParameter('mergeData', itemIndex, '{}');
|
|
49
|
+
let mergeData;
|
|
50
|
+
if (typeof rawMergeData === 'string') {
|
|
51
|
+
try {
|
|
52
|
+
mergeData = JSON.parse(rawMergeData);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Merge Data is not valid JSON: ${error.message}`, { itemIndex });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
mergeData = rawMergeData;
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(mergeData)) {
|
|
62
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Merge Data must be a single JSON object, not an array', {
|
|
63
|
+
itemIndex,
|
|
64
|
+
description: 'Send one item per label — n8n runs this operation once per input item, and each run produces one label.',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const response = await transport_1.labelZoomRequest.call(this, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
path: `/api/v3/templates/${encodeURIComponent(templateId)}/convert`,
|
|
70
|
+
query: targetFormat === '' ? undefined : { target: targetFormat },
|
|
71
|
+
body: JSON.stringify(mergeData),
|
|
72
|
+
contentType: 'application/json',
|
|
73
|
+
});
|
|
74
|
+
const actualFormat = Object.entries(response.headers).find(([key]) => key.toLowerCase() === 'x-lz-format')?.[1] ??
|
|
75
|
+
(targetFormat === '' ? 'zpl' : targetFormat);
|
|
76
|
+
const mimeType = (0, transport_1.contentTypeOf)(response)?.split(';')[0].trim() ?? (0, formats_1.targetMediaType)(actualFormat);
|
|
77
|
+
const json = {
|
|
78
|
+
templateId,
|
|
79
|
+
targetFormat: actualFormat,
|
|
80
|
+
contentType: (0, transport_1.contentTypeOf)(response),
|
|
81
|
+
byteLength: response.body.length,
|
|
82
|
+
requestId: (0, transport_1.requestIdOf)(response),
|
|
83
|
+
};
|
|
84
|
+
if ((0, formats_1.isTextualTarget)(actualFormat)) {
|
|
85
|
+
json.text = (0, transport_1.decodeText)(response);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
json,
|
|
89
|
+
binary: {
|
|
90
|
+
[outputBinaryPropertyName]: await this.helpers.prepareBinaryData(response.body, `label.${(0, formats_1.targetExtension)(actualFormat)}`, mimeType),
|
|
91
|
+
},
|
|
92
|
+
pairedItem: { item: itemIndex },
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=convertTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertTemplate.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/label/convertTemplate.ts"],"names":[],"mappings":";;;AAwDA,0CAkFC;AApID,+CAAkD;AAElD,kDAM8B;AAC9B,sDAAkG;AAClG,8CAAgD;AAChD,8CAAoD;AAEpD,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;AAE3D,QAAA,0BAA0B,GAAsB;IAC5D,IAAA,wBAAe,EAAC,OAAO,CAAC;IACxB;QACC,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,WAAW,EACV,mKAAmK;QACpK,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KACjC;IACD;QACC,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACR,EA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KAChC,CAAC;IACF,IAAI,IAAA,yBAAe,EAAC,YAAY,CAAC,EAAE,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAA,sBAAU,EAAC,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACN,IAAI;QACJ,MAAM,EAAE;YACP,CAAC,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAC/D,QAAQ,CAAC,IAAI,EACb,SAAS,IAAA,yBAAe,EAAC,YAAY,CAAC,EAAE,EACxC,QAAQ,CACR;SACD;QACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.labelDescription = exports.convertTemplate = exports.convert = void 0;
|
|
4
|
+
const convert_1 = require("./convert");
|
|
5
|
+
const convertTemplate_1 = require("./convertTemplate");
|
|
6
|
+
var convert_2 = require("./convert");
|
|
7
|
+
Object.defineProperty(exports, "convert", { enumerable: true, get: function () { return convert_2.convert; } });
|
|
8
|
+
var convertTemplate_2 = require("./convertTemplate");
|
|
9
|
+
Object.defineProperty(exports, "convertTemplate", { enumerable: true, get: function () { return convertTemplate_2.convertTemplate; } });
|
|
10
|
+
exports.labelDescription = [
|
|
11
|
+
{
|
|
12
|
+
displayName: 'Operation',
|
|
13
|
+
name: 'operation',
|
|
14
|
+
type: 'options',
|
|
15
|
+
noDataExpression: true,
|
|
16
|
+
displayOptions: { show: { resource: ['label'] } },
|
|
17
|
+
options: [
|
|
18
|
+
{
|
|
19
|
+
name: 'Convert',
|
|
20
|
+
value: 'convert',
|
|
21
|
+
description: 'Convert a label between ZPL, EPL, TSPL, DPL, PDF, images and XML/JSON',
|
|
22
|
+
action: 'Convert a label',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Convert Template',
|
|
26
|
+
value: 'convertTemplate',
|
|
27
|
+
description: 'Fill a Print Template with data and render it, without printing',
|
|
28
|
+
action: 'Convert a print template',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
default: 'convert',
|
|
32
|
+
},
|
|
33
|
+
...convert_1.convertDescription,
|
|
34
|
+
...convertTemplate_1.convertTemplateDescription,
|
|
35
|
+
];
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/label/index.ts"],"names":[],"mappings":";;;AAEA,uCAA+C;AAC/C,uDAA+D;AAE/D,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AAEX,QAAA,gBAAgB,GAAsB;IAClD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;QACjD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,uEAAuE;gBACpF,MAAM,EAAE,iBAAiB;aACzB;YACD;gBACC,IAAI,EAAE,kBAAkB;gBACxB,KAAK,EAAE,iBAAiB;gBACxB,WAAW,EAAE,iEAAiE;gBAC9E,MAAM,EAAE,0BAA0B;aAClC;SACD;QACD,OAAO,EAAE,SAAS;KAClB;IACD,GAAG,4BAAkB;IACrB,GAAG,4CAA0B;CAC7B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printerDescription = exports.getStatus = exports.getMany = exports.getJob = exports.printTemplate = exports.print = void 0;
|
|
4
|
+
const print_1 = require("./print");
|
|
5
|
+
const printTemplate_1 = require("./printTemplate");
|
|
6
|
+
const reads_1 = require("./reads");
|
|
7
|
+
var print_2 = require("./print");
|
|
8
|
+
Object.defineProperty(exports, "print", { enumerable: true, get: function () { return print_2.print; } });
|
|
9
|
+
var printTemplate_2 = require("./printTemplate");
|
|
10
|
+
Object.defineProperty(exports, "printTemplate", { enumerable: true, get: function () { return printTemplate_2.printTemplate; } });
|
|
11
|
+
var reads_2 = require("./reads");
|
|
12
|
+
Object.defineProperty(exports, "getJob", { enumerable: true, get: function () { return reads_2.getJob; } });
|
|
13
|
+
Object.defineProperty(exports, "getMany", { enumerable: true, get: function () { return reads_2.getMany; } });
|
|
14
|
+
Object.defineProperty(exports, "getStatus", { enumerable: true, get: function () { return reads_2.getStatus; } });
|
|
15
|
+
exports.printerDescription = [
|
|
16
|
+
{
|
|
17
|
+
displayName: 'Operation',
|
|
18
|
+
name: 'operation',
|
|
19
|
+
type: 'options',
|
|
20
|
+
noDataExpression: true,
|
|
21
|
+
displayOptions: { show: { resource: ['printer'] } },
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
name: 'Get Job',
|
|
25
|
+
value: 'getJob',
|
|
26
|
+
description: 'Look up a print job by ID to see whether it printed',
|
|
27
|
+
action: 'Get a print job',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Get Many',
|
|
31
|
+
value: 'getMany',
|
|
32
|
+
description: 'List the printers on your account',
|
|
33
|
+
action: 'Get many printers',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Get Status',
|
|
37
|
+
value: 'getStatus',
|
|
38
|
+
description: 'Get one printer\'s live status and bound agents',
|
|
39
|
+
action: 'Get a printer status',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Print',
|
|
43
|
+
value: 'print',
|
|
44
|
+
description: 'Send a label to a cloud-connected printer, converting it in transit',
|
|
45
|
+
action: 'Print a label',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Print Template',
|
|
49
|
+
value: 'printTemplate',
|
|
50
|
+
description: 'Fill a Print Template with data and print it',
|
|
51
|
+
action: 'Print a print template',
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
default: 'print',
|
|
55
|
+
},
|
|
56
|
+
...print_1.printDescription,
|
|
57
|
+
...printTemplate_1.printTemplateDescription,
|
|
58
|
+
...reads_1.readsDescription,
|
|
59
|
+
];
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/printer/index.ts"],"names":[],"mappings":";;;AAEA,mCAA2C;AAC3C,mDAA2D;AAC3D,mCAA2C;AAE3C,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,iCAAqD;AAA5C,+FAAA,MAAM,OAAA;AAAE,gGAAA,OAAO,OAAA;AAAE,kGAAA,SAAS,OAAA;AAEtB,QAAA,kBAAkB,GAAsB;IACpD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE;QACnD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,QAAQ;gBACf,WAAW,EAAE,qDAAqD;gBAClE,MAAM,EAAE,iBAAiB;aACzB;YACD;gBACC,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,mCAAmC;gBAChD,MAAM,EAAE,mBAAmB;aAC3B;YACD;gBACC,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,WAAW;gBAClB,WAAW,EAAE,iDAAiD;gBAC9D,MAAM,EAAE,sBAAsB;aAC9B;YACD;gBACC,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,OAAO;gBACd,WAAW,EAAE,qEAAqE;gBAClF,MAAM,EAAE,eAAe;aACvB;YACD;gBACC,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,eAAe;gBACtB,WAAW,EAAE,8CAA8C;gBAC3D,MAAM,EAAE,wBAAwB;aAChC;SACD;QACD,OAAO,EAAE,OAAO;KAChB;IACD,GAAG,wBAAgB;IACnB,GAAG,wCAAwB;IAC3B,GAAG,wBAAgB;CACnB,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printDescription = void 0;
|
|
4
|
+
exports.print = print;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const descriptions_1 = require("../../shared/descriptions");
|
|
7
|
+
const formats_1 = require("../../shared/formats");
|
|
8
|
+
const options_1 = require("../../shared/options");
|
|
9
|
+
const transport_1 = require("../../shared/transport");
|
|
10
|
+
const utils_1 = require("../../shared/utils");
|
|
11
|
+
const shared_1 = require("./shared");
|
|
12
|
+
const showFor = { resource: ['printer'], operation: ['print'] };
|
|
13
|
+
function resolveContentType(inputType, sourceFormat) {
|
|
14
|
+
if (inputType === 'base64')
|
|
15
|
+
return 'text/plain';
|
|
16
|
+
if (sourceFormat === '')
|
|
17
|
+
return 'application/octet-stream';
|
|
18
|
+
return (0, formats_1.sourceMediaType)((0, formats_1.sourceWireToken)(sourceFormat));
|
|
19
|
+
}
|
|
20
|
+
exports.printDescription = [
|
|
21
|
+
(0, shared_1.printerLocator)(showFor),
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Source Format',
|
|
24
|
+
name: 'sourceFormat',
|
|
25
|
+
type: 'options',
|
|
26
|
+
noDataExpression: true,
|
|
27
|
+
options: [
|
|
28
|
+
{
|
|
29
|
+
name: 'Auto-Detect',
|
|
30
|
+
value: '',
|
|
31
|
+
description: 'Let LabelZoom identify the format from the file contents',
|
|
32
|
+
},
|
|
33
|
+
...(0, formats_1.formatOptions)(formats_1.SOURCE_FORMATS.filter((format) => format !== 'url')),
|
|
34
|
+
],
|
|
35
|
+
default: '',
|
|
36
|
+
description: 'The format of the document you are sending. LabelZoom converts it to the printer\'s native format on the way — a PDF sent to a ZPL printer becomes ZPL automatically.',
|
|
37
|
+
displayOptions: { show: showFor },
|
|
38
|
+
},
|
|
39
|
+
...(0, descriptions_1.documentInputFields)(showFor),
|
|
40
|
+
(0, shared_1.idempotencyKeyField)(showFor),
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Wait for Completion',
|
|
43
|
+
name: 'waitForCompletion',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
default: false,
|
|
46
|
+
description: 'Whether to poll the job until it finishes printing. Without this the node returns as soon as the job is accepted, which is not the same as printed.',
|
|
47
|
+
displayOptions: { show: showFor },
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Timeout (Seconds)',
|
|
51
|
+
name: 'waitTimeout',
|
|
52
|
+
type: 'number',
|
|
53
|
+
default: 120,
|
|
54
|
+
description: 'How long to wait for the job to reach a terminal state before giving up',
|
|
55
|
+
displayOptions: { show: { ...showFor, waitForCompletion: [true] } },
|
|
56
|
+
},
|
|
57
|
+
(0, descriptions_1.conversionOptionsField)(showFor, 'Transform Options'),
|
|
58
|
+
];
|
|
59
|
+
async function waitForJob(jobId, timeoutSeconds, itemIndex) {
|
|
60
|
+
const deadline = Date.now() + timeoutSeconds * 1000;
|
|
61
|
+
let delayMs = 1000;
|
|
62
|
+
let job = {};
|
|
63
|
+
while (Date.now() < deadline) {
|
|
64
|
+
await (0, n8n_workflow_1.sleep)(delayMs);
|
|
65
|
+
job = await transport_1.labelZoomJsonRequest.call(this, 'GET', `/api/v3/jobs/${encodeURIComponent(jobId)}`);
|
|
66
|
+
if (shared_1.TERMINAL_JOB_STATUSES.includes(job.status)) {
|
|
67
|
+
return job;
|
|
68
|
+
}
|
|
69
|
+
delayMs = Math.min(delayMs * 1.5, 10000);
|
|
70
|
+
}
|
|
71
|
+
this.logger.warn(`LabelZoom print job ${jobId} did not reach a terminal state within ${timeoutSeconds}s (item ${itemIndex})`);
|
|
72
|
+
return { ...job, timedOut: true };
|
|
73
|
+
}
|
|
74
|
+
async function print(itemIndex) {
|
|
75
|
+
const printerId = utils_1.resourceId.call(this, 'printerId', itemIndex);
|
|
76
|
+
const sourceFormat = this.getNodeParameter('sourceFormat', itemIndex, '');
|
|
77
|
+
const idempotencyKey = this.getNodeParameter('idempotencyKey', itemIndex, '');
|
|
78
|
+
const waitForCompletion = this.getNodeParameter('waitForCompletion', itemIndex, false);
|
|
79
|
+
const options = this.getNodeParameter('options', itemIndex, {});
|
|
80
|
+
const document = await utils_1.readDocument.call(this, itemIndex);
|
|
81
|
+
const inputType = this.getNodeParameter('inputType', itemIndex);
|
|
82
|
+
const query = {};
|
|
83
|
+
if (sourceFormat !== '')
|
|
84
|
+
query.sourceFormat = sourceFormat;
|
|
85
|
+
const headers = {};
|
|
86
|
+
if (idempotencyKey !== '')
|
|
87
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
88
|
+
const response = await transport_1.labelZoomRequest.call(this, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
path: `/api/v3/printers/${encodeURIComponent(printerId)}/print`,
|
|
91
|
+
query: Object.keys(query).length > 0 ? query : undefined,
|
|
92
|
+
params: (0, options_1.serializeConversionParams)(this.getNode(), options),
|
|
93
|
+
body: document,
|
|
94
|
+
contentType: resolveContentType(inputType, sourceFormat),
|
|
95
|
+
headers,
|
|
96
|
+
});
|
|
97
|
+
const text = response.body.toString('utf8');
|
|
98
|
+
let job;
|
|
99
|
+
try {
|
|
100
|
+
job = JSON.parse(text);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Expected a print job from LabelZoom but got: ${text.slice(0, 200)}`, { itemIndex });
|
|
104
|
+
}
|
|
105
|
+
const json = {
|
|
106
|
+
...job,
|
|
107
|
+
printerId,
|
|
108
|
+
requestId: (0, transport_1.requestIdOf)(response),
|
|
109
|
+
};
|
|
110
|
+
if (waitForCompletion && typeof job.jobId === 'string') {
|
|
111
|
+
const timeout = this.getNodeParameter('waitTimeout', itemIndex, 120);
|
|
112
|
+
const finished = await waitForJob.call(this, job.jobId, timeout, itemIndex);
|
|
113
|
+
Object.assign(json, { job: finished, status: finished.status ?? json.status });
|
|
114
|
+
}
|
|
115
|
+
return { json, pairedItem: { item: itemIndex } };
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/printer/print.ts"],"names":[],"mappings":";;;AAqGA,sBAiEC;AA/JD,+CAAyD;AAEzD,4DAAwF;AACxF,kDAAuG;AAEvG,kDAAiE;AACjE,sDAA6F;AAC7F,8CAA8D;AAC9D,qCAAsF;AAEtF,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;AAEhE,SAAS,kBAAkB,CAAC,SAAiB,EAAE,YAAoB;IAClE,IAAI,SAAS,KAAK,QAAQ;QAAE,OAAO,YAAY,CAAC;IAChD,IAAI,YAAY,KAAK,EAAE;QAAE,OAAO,0BAA0B,CAAC;IAC3D,OAAO,IAAA,yBAAe,EAAC,IAAA,yBAAe,EAAC,YAAY,CAAC,CAAC,CAAC;AACvD,CAAC;AAEY,QAAA,gBAAgB,GAAsB;IAClD,IAAA,uBAAc,EAAC,OAAO,CAAC;IACvB;QACC,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,aAAa;gBACnB,KAAK,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EAAE,SAAS,EAAE,GAAG,CAAW,CAAC;QAC/E,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAC5E,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printTemplateDescription = void 0;
|
|
4
|
+
exports.printTemplate = printTemplate;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const transport_1 = require("../../shared/transport");
|
|
7
|
+
const utils_1 = require("../../shared/utils");
|
|
8
|
+
const shared_1 = require("./shared");
|
|
9
|
+
const showFor = { resource: ['printer'], operation: ['printTemplate'] };
|
|
10
|
+
exports.printTemplateDescription = [
|
|
11
|
+
(0, shared_1.printerLocator)(showFor),
|
|
12
|
+
(0, shared_1.templateLocator)(showFor),
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Merge Data (JSON)',
|
|
15
|
+
name: 'mergeData',
|
|
16
|
+
type: 'json',
|
|
17
|
+
default: '{}',
|
|
18
|
+
required: true,
|
|
19
|
+
description: "Values for the template's merge fields, keyed by field name. Map them from the incoming item.",
|
|
20
|
+
displayOptions: { show: showFor },
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Validate Merge Fields',
|
|
24
|
+
name: 'validate',
|
|
25
|
+
type: 'boolean',
|
|
26
|
+
default: true,
|
|
27
|
+
description: 'Whether to reject the job when a required merge field is missing, instead of printing a label with a blank in it',
|
|
28
|
+
displayOptions: { show: showFor },
|
|
29
|
+
},
|
|
30
|
+
(0, shared_1.idempotencyKeyField)(showFor),
|
|
31
|
+
];
|
|
32
|
+
async function printTemplate(itemIndex) {
|
|
33
|
+
const printerId = utils_1.resourceId.call(this, 'printerId', itemIndex);
|
|
34
|
+
const templateId = utils_1.resourceId.call(this, 'templateId', itemIndex);
|
|
35
|
+
const validate = this.getNodeParameter('validate', itemIndex, true);
|
|
36
|
+
const idempotencyKey = this.getNodeParameter('idempotencyKey', itemIndex, '');
|
|
37
|
+
const rawMergeData = this.getNodeParameter('mergeData', itemIndex, '{}');
|
|
38
|
+
let mergeData;
|
|
39
|
+
if (typeof rawMergeData === 'string') {
|
|
40
|
+
try {
|
|
41
|
+
mergeData = JSON.parse(rawMergeData);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Merge Data is not valid JSON: ${error.message}`, { itemIndex });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
mergeData = rawMergeData;
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(mergeData)) {
|
|
51
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Merge Data must be a single JSON object, not an array', {
|
|
52
|
+
itemIndex,
|
|
53
|
+
description: 'Send one item per label — this operation runs once per input item and each run produces one print job.',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const headers = {};
|
|
57
|
+
if (idempotencyKey !== '')
|
|
58
|
+
headers['Idempotency-Key'] = idempotencyKey;
|
|
59
|
+
const job = await transport_1.labelZoomJsonRequest.call(this, 'POST', `/api/v3/printers/${encodeURIComponent(printerId)}/templates/${encodeURIComponent(templateId)}/print`, mergeData, validate ? { validate: 'true' } : undefined, headers);
|
|
60
|
+
return {
|
|
61
|
+
json: { ...job, printerId, templateId },
|
|
62
|
+
pairedItem: { item: itemIndex },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=printTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printTemplate.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/printer/printTemplate.ts"],"names":[],"mappings":";;;AAkCA,sCAyDC;AA1FD,+CAAkD;AAElD,sDAA8D;AAC9D,8CAAgD;AAChD,qCAAgF;AAEhF,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;AAE3D,QAAA,wBAAwB,GAAsB;IAC1D,IAAA,uBAAc,EAAC,OAAO,CAAC;IACvB,IAAA,wBAAe,EAAC,OAAO,CAAC;IACxB;QACC,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,WAAW,EACV,+FAA+F;QAChG,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KACjC;IACD;QACC,WAAW,EAAE,uBAAuB;QACpC,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,IAAI;QACb,WAAW,EACV,kHAAkH;QACnH,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KACjC;IACD,IAAA,4BAAmB,EAAC,OAAO,CAAC;CAC5B,CAAC;AAEK,KAAK,UAAU,aAAa,CAElC,SAAiB;IAEjB,MAAM,SAAS,GAAG,kBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,kBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,EAAE,IAAI,CAAY,CAAC;IAC/E,MAAM,cAA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,EAAE,UAAU,EAAE;QACvC,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare const readsDescription: INodeProperties[];
|
|
3
|
+
export declare function getMany(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
4
|
+
export declare function getJob(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData>;
|
|
5
|
+
export declare function getStatus(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readsDescription = void 0;
|
|
4
|
+
exports.getMany = getMany;
|
|
5
|
+
exports.getJob = getJob;
|
|
6
|
+
exports.getStatus = getStatus;
|
|
7
|
+
const transport_1 = require("../../shared/transport");
|
|
8
|
+
const utils_1 = require("../../shared/utils");
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const getJobShowFor = { resource: ['printer'], operation: ['getJob'] };
|
|
11
|
+
const getStatusShowFor = { resource: ['printer'], operation: ['getStatus'] };
|
|
12
|
+
exports.readsDescription = [
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Job ID',
|
|
15
|
+
name: 'jobId',
|
|
16
|
+
type: 'string',
|
|
17
|
+
default: '',
|
|
18
|
+
required: true,
|
|
19
|
+
description: 'The jobId returned by a Print operation',
|
|
20
|
+
displayOptions: { show: getJobShowFor },
|
|
21
|
+
},
|
|
22
|
+
(0, shared_1.printerLocator)(getStatusShowFor),
|
|
23
|
+
];
|
|
24
|
+
async function getMany(itemIndex) {
|
|
25
|
+
const response = await transport_1.labelZoomJsonRequest.call(this, 'GET', '/api/v3/printers');
|
|
26
|
+
const printers = Array.isArray(response.printers) ? response.printers : [];
|
|
27
|
+
return printers.map((printer) => ({ json: printer, pairedItem: { item: itemIndex } }));
|
|
28
|
+
}
|
|
29
|
+
async function getJob(itemIndex) {
|
|
30
|
+
const jobId = this.getNodeParameter('jobId', itemIndex);
|
|
31
|
+
const job = await transport_1.labelZoomJsonRequest.call(this, 'GET', `/api/v3/jobs/${encodeURIComponent(jobId.trim())}`);
|
|
32
|
+
return { json: job, pairedItem: { item: itemIndex } };
|
|
33
|
+
}
|
|
34
|
+
async function getStatus(itemIndex) {
|
|
35
|
+
const printerId = utils_1.resourceId.call(this, 'printerId', itemIndex);
|
|
36
|
+
const status = await transport_1.labelZoomJsonRequest.call(this, 'GET', `/api/v3/printers/${encodeURIComponent(printerId)}/status`);
|
|
37
|
+
return { json: status, pairedItem: { item: itemIndex } };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/printer/reads.ts"],"names":[],"mappings":";;;AAuBA,0BAOC;AAGD,wBAWC;AAGD,8BAWC;AAxDD,sDAA8D;AAC9D,8CAAgD;AAChD,qCAA0C;AAE1C,MAAM,aAAa,GAAG,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;AACvE,MAAM,gBAAgB,GAAG,EAAE,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;AAEhE,QAAA,gBAAgB,GAAsB;IAClD;QACC,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,yCAAyC;QACtD,cAAc,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;KACvC;IACD,IAAA,uBAAc,EAAC,gBAAgB,CAAC;CA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}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
type ShowFor = {
|
|
3
|
+
resource: string[];
|
|
4
|
+
operation: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function printerLocator(showFor: ShowFor): INodeProperties;
|
|
7
|
+
export declare function templateLocator(showFor: ShowFor): INodeProperties;
|
|
8
|
+
export declare function idempotencyKeyField(showFor: ShowFor): INodeProperties;
|
|
9
|
+
export declare const TERMINAL_JOB_STATUSES: readonly ["completed", "failed"];
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TERMINAL_JOB_STATUSES = void 0;
|
|
4
|
+
exports.printerLocator = printerLocator;
|
|
5
|
+
exports.templateLocator = templateLocator;
|
|
6
|
+
exports.idempotencyKeyField = idempotencyKeyField;
|
|
7
|
+
function printerLocator(showFor) {
|
|
8
|
+
return {
|
|
9
|
+
displayName: 'Printer',
|
|
10
|
+
name: 'printerId',
|
|
11
|
+
type: 'resourceLocator',
|
|
12
|
+
default: { mode: 'list', value: '' },
|
|
13
|
+
required: true,
|
|
14
|
+
description: 'The cloud-connected printer to send the job to',
|
|
15
|
+
displayOptions: { show: showFor },
|
|
16
|
+
modes: [
|
|
17
|
+
{
|
|
18
|
+
displayName: 'From List',
|
|
19
|
+
name: 'list',
|
|
20
|
+
type: 'list',
|
|
21
|
+
typeOptions: { searchListMethod: 'getPrinters', searchable: true },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
displayName: 'By ID',
|
|
25
|
+
name: 'id',
|
|
26
|
+
type: 'string',
|
|
27
|
+
placeholder: 'b2c3d4e5-...',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function templateLocator(showFor) {
|
|
33
|
+
return {
|
|
34
|
+
displayName: 'Template',
|
|
35
|
+
name: 'templateId',
|
|
36
|
+
type: 'resourceLocator',
|
|
37
|
+
default: { mode: 'list', value: '' },
|
|
38
|
+
required: true,
|
|
39
|
+
description: 'A Print Template published from LabelZoom Studio',
|
|
40
|
+
displayOptions: { show: showFor },
|
|
41
|
+
modes: [
|
|
42
|
+
{
|
|
43
|
+
displayName: 'From List',
|
|
44
|
+
name: 'list',
|
|
45
|
+
type: 'list',
|
|
46
|
+
typeOptions: { searchListMethod: 'getTemplates', searchable: true },
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
displayName: 'By ID',
|
|
50
|
+
name: 'id',
|
|
51
|
+
type: 'string',
|
|
52
|
+
placeholder: 'a1b2c3d4-...',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function idempotencyKeyField(showFor) {
|
|
58
|
+
return {
|
|
59
|
+
displayName: 'Idempotency Key',
|
|
60
|
+
name: 'idempotencyKey',
|
|
61
|
+
type: 'string',
|
|
62
|
+
default: '={{ $execution.id }}-{{ $itemIndex }}',
|
|
63
|
+
description: 'Repeating a key returns the original job instead of printing again. Set it from a stable business value (an order number) to make a whole workflow re-run safe.',
|
|
64
|
+
displayOptions: { show: showFor },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
exports.TERMINAL_JOB_STATUSES = ['completed', 'failed'];
|
|
68
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../nodes/LabelZoom/resources/printer/shared.ts"],"names":[],"mappings":";;;AAUA,wCAwBC;AAED,0CAwBC;AAWD,kDAUC;AAvED,SAAgB,cAAc,CAAC,OAAgB;IAC9C,OAAO;QACN,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QACp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AAO,EAAE;KACjC,CAAC;AACH,CAAC;AAGY,QAAA,qBAAqB,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare function documentInputFields(showFor: {
|
|
3
|
+
resource: string[];
|
|
4
|
+
operation: string[];
|
|
5
|
+
}): INodeProperties[];
|
|
6
|
+
export declare function conversionOptionsField(showFor: {
|
|
7
|
+
resource: string[];
|
|
8
|
+
operation: string[];
|
|
9
|
+
}, displayName?: string): INodeProperties;
|