n8n-core 1.10.0 → 1.11.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/dist/BinaryData/BinaryData.service.js +14 -7
- package/dist/BinaryData/BinaryData.service.js.map +1 -1
- package/dist/BinaryData/FileSystem.manager.d.ts +6 -7
- package/dist/BinaryData/FileSystem.manager.js +50 -39
- package/dist/BinaryData/FileSystem.manager.js.map +1 -1
- package/dist/BinaryData/ObjectStore.manager.d.ts +27 -0
- package/dist/BinaryData/ObjectStore.manager.js +90 -0
- package/dist/BinaryData/ObjectStore.manager.js.map +1 -0
- package/dist/BinaryData/errors.d.ts +3 -3
- package/dist/BinaryData/errors.js +7 -6
- package/dist/BinaryData/errors.js.map +1 -1
- package/dist/BinaryData/types.d.ts +16 -13
- package/dist/BinaryData/utils.d.ts +4 -3
- package/dist/BinaryData/utils.js +12 -7
- package/dist/BinaryData/utils.js.map +1 -1
- package/dist/NodeExecuteFunctions.d.ts +1 -0
- package/dist/NodeExecuteFunctions.js +17 -1
- package/dist/NodeExecuteFunctions.js.map +1 -1
- package/dist/ObjectStore/ObjectStore.service.ee.d.ts +18 -17
- package/dist/ObjectStore/ObjectStore.service.ee.js +53 -23
- package/dist/ObjectStore/ObjectStore.service.ee.js.map +1 -1
- package/dist/ObjectStore/types.d.ts +14 -8
- package/dist/ObjectStore/utils.d.ts +1 -0
- package/dist/ObjectStore/utils.js +5 -1
- package/dist/ObjectStore/utils.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/ObjectStore/errors.d.ts +0 -4
- package/dist/ObjectStore/errors.js +0 -11
- package/dist/ObjectStore/errors.js.map +0 -1
|
@@ -36,27 +36,34 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.BinaryDataService = void 0;
|
|
39
|
-
const promises_1 = require("fs/promises");
|
|
39
|
+
const promises_1 = require("node:fs/promises");
|
|
40
40
|
const pretty_bytes_1 = __importDefault(require("pretty-bytes"));
|
|
41
|
-
const typedi_1 = require("typedi");
|
|
41
|
+
const typedi_1 = __importStar(require("typedi"));
|
|
42
42
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
43
43
|
const errors_1 = require("./errors");
|
|
44
|
-
const LogCatch_decorator_1 = require("../decorators/LogCatch.decorator");
|
|
45
44
|
const utils_1 = require("./utils");
|
|
45
|
+
const LogCatch_decorator_1 = require("../decorators/LogCatch.decorator");
|
|
46
46
|
let BinaryDataService = class BinaryDataService {
|
|
47
47
|
constructor() {
|
|
48
48
|
this.mode = 'default';
|
|
49
49
|
this.managers = {};
|
|
50
50
|
}
|
|
51
51
|
async init(config) {
|
|
52
|
-
if (!(0, utils_1.
|
|
53
|
-
throw new errors_1.
|
|
54
|
-
this.mode = config.mode;
|
|
52
|
+
if (!(0, utils_1.areConfigModes)(config.availableModes))
|
|
53
|
+
throw new errors_1.InvalidModeError();
|
|
54
|
+
this.mode = config.mode === 'filesystem' ? 'filesystem-v2' : config.mode;
|
|
55
55
|
if (config.availableModes.includes('filesystem')) {
|
|
56
56
|
const { FileSystemManager } = await Promise.resolve().then(() => __importStar(require('./FileSystem.manager')));
|
|
57
57
|
this.managers.filesystem = new FileSystemManager(config.localStoragePath);
|
|
58
|
+
this.managers['filesystem-v2'] = this.managers.filesystem;
|
|
58
59
|
await this.managers.filesystem.init();
|
|
59
60
|
}
|
|
61
|
+
if (config.availableModes.includes('s3')) {
|
|
62
|
+
const { ObjectStoreManager } = await Promise.resolve().then(() => __importStar(require('./ObjectStore.manager')));
|
|
63
|
+
const { ObjectStoreService } = await Promise.resolve().then(() => __importStar(require('../ObjectStore/ObjectStore.service.ee')));
|
|
64
|
+
this.managers.s3 = new ObjectStoreManager(typedi_1.default.get(ObjectStoreService));
|
|
65
|
+
await this.managers.s3.init();
|
|
66
|
+
}
|
|
60
67
|
}
|
|
61
68
|
async copyBinaryFile(workflowId, executionId, binaryData, filePath) {
|
|
62
69
|
const manager = this.managers[this.mode];
|
|
@@ -181,7 +188,7 @@ let BinaryDataService = class BinaryDataService {
|
|
|
181
188
|
const manager = this.managers[mode];
|
|
182
189
|
if (manager)
|
|
183
190
|
return manager;
|
|
184
|
-
throw new errors_1.
|
|
191
|
+
throw new errors_1.UnknownManagerError(mode);
|
|
185
192
|
}
|
|
186
193
|
};
|
|
187
194
|
exports.BinaryDataService = BinaryDataService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BinaryData.service.js","sourceRoot":"","sources":["../../src/BinaryData/BinaryData.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA
|
|
1
|
+
{"version":3,"file":"BinaryData.service.js","sourceRoot":"","sources":["../../src/BinaryData/BinaryData.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,+CAAkD;AAClD,gEAAuC;AACvC,iDAA4C;AAC5C,+CAAmF;AACnF,qCAAiE;AACjE,mCAAmD;AACnD,yEAA4D;AAOrD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QACE,SAAI,GAA2B,SAAS,CAAC;QAEzC,aAAQ,GAAuC,EAAE,CAAC;IA2O3D,CAAC;IAzOA,KAAK,CAAC,IAAI,CAAC,MAAyB;QACnC,IAAI,CAAC,IAAA,sBAAc,EAAC,MAAM,CAAC,cAAc,CAAC;YAAE,MAAM,IAAI,yBAAgB,EAAE,CAAC;QAEzE,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAEzE,IAAI,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YACjD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G,EAAE,IAAI,EAAE,EAAE;oBAC7B,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE;wBACvB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;qBACrC;oBAED,OAAO,GAAG,CAAC;gBACZ,CAAC,EAAE,aAAa,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;SACH;QAED,OAAO,aAAa,CAAC;IACtB,CAAC;IAEO,UAAU,CAAC,IAAY;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;QAE5B,MAAM,IAAI,4BAAmB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACD,CAAA;AA9OY,8CAAiB;AA8BvB;IADL,IAAA,6BAAQ,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,0BAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;;;;uDAkC/E;AAGK;IADL,IAAA,6BAAQ,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,0BAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;;;;8CAkChF;AA6CK;IAHL,IAAA,6BAAQ,EAAC,CAAC,KAAK,EAAE,EAAE,CACnB,0BAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,EAAE,KAAK,EAAE,CAAC,CAC7E;;qDAIW,KAAK;;4DAyBhB;4BA5KW,iBAAiB;IAD7B,IAAA,gBAAO,GAAE;GACG,iBAAiB,CA8O7B"}
|
|
@@ -7,21 +7,20 @@ export declare class FileSystemManager implements BinaryData.Manager {
|
|
|
7
7
|
private storagePath;
|
|
8
8
|
constructor(storagePath: string);
|
|
9
9
|
init(): Promise<void>;
|
|
10
|
+
store(workflowId: string, executionId: string, bufferOrStream: Buffer | Readable, { mimeType, fileName }: BinaryData.PreWriteMetadata): Promise<{
|
|
11
|
+
fileId: string;
|
|
12
|
+
fileSize: number;
|
|
13
|
+
}>;
|
|
10
14
|
getPath(fileId: string): string;
|
|
11
15
|
getAsStream(fileId: string, chunkSize?: number): Promise<import("fs").ReadStream>;
|
|
12
16
|
getAsBuffer(fileId: string): Promise<Buffer>;
|
|
13
17
|
getMetadata(fileId: string): Promise<BinaryData.Metadata>;
|
|
14
|
-
store(_workflowId: string, executionId: string, bufferOrStream: Buffer | Readable, { mimeType, fileName }: BinaryData.PreWriteMetadata): Promise<{
|
|
15
|
-
fileId: string;
|
|
16
|
-
fileSize: number;
|
|
17
|
-
}>;
|
|
18
|
-
deleteOne(fileId: string): Promise<void>;
|
|
19
18
|
deleteMany(ids: BinaryData.IdsForDeletion): Promise<void>;
|
|
20
|
-
copyByFilePath(
|
|
19
|
+
copyByFilePath(workflowId: string, executionId: string, sourcePath: string, { mimeType, fileName }: BinaryData.PreWriteMetadata): Promise<{
|
|
21
20
|
fileId: string;
|
|
22
21
|
fileSize: number;
|
|
23
22
|
}>;
|
|
24
|
-
copyByFileId(
|
|
23
|
+
copyByFileId(workflowId: string, executionId: string, sourceFileId: string): Promise<string>;
|
|
25
24
|
rename(oldFileId: string, newFileId: string): Promise<void>;
|
|
26
25
|
private toFileId;
|
|
27
26
|
private resolvePath;
|
|
@@ -4,31 +4,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FileSystemManager = void 0;
|
|
7
|
-
const
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
-
const
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
11
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
12
|
-
const promises_2 = require("node:fs/promises");
|
|
13
|
-
const errors_1 = require("../errors");
|
|
14
12
|
const utils_1 = require("./utils");
|
|
13
|
+
const errors_1 = require("../errors");
|
|
15
14
|
const EXECUTION_ID_EXTRACTOR = /^(\w+)(?:[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})$/;
|
|
16
15
|
class FileSystemManager {
|
|
17
16
|
constructor(storagePath) {
|
|
18
17
|
this.storagePath = storagePath;
|
|
19
18
|
}
|
|
20
19
|
async init() {
|
|
21
|
-
await (0, utils_1.
|
|
20
|
+
await (0, utils_1.assertDir)(this.storagePath);
|
|
21
|
+
}
|
|
22
|
+
async store(workflowId, executionId, bufferOrStream, { mimeType, fileName }) {
|
|
23
|
+
const fileId = this.toFileId(workflowId, executionId);
|
|
24
|
+
const filePath = this.resolvePath(fileId);
|
|
25
|
+
await (0, utils_1.assertDir)(node_path_1.default.dirname(filePath));
|
|
26
|
+
await promises_1.default.writeFile(filePath, bufferOrStream);
|
|
27
|
+
const fileSize = await this.getSize(fileId);
|
|
28
|
+
await this.storeMetadata(fileId, { mimeType, fileName, fileSize });
|
|
29
|
+
return { fileId, fileSize };
|
|
22
30
|
}
|
|
23
31
|
getPath(fileId) {
|
|
24
32
|
return this.resolvePath(fileId);
|
|
25
33
|
}
|
|
26
34
|
async getAsStream(fileId, chunkSize) {
|
|
27
|
-
const filePath = this.
|
|
28
|
-
return (0,
|
|
35
|
+
const filePath = this.resolvePath(fileId);
|
|
36
|
+
return (0, node_fs_1.createReadStream)(filePath, { highWaterMark: chunkSize });
|
|
29
37
|
}
|
|
30
38
|
async getAsBuffer(fileId) {
|
|
31
|
-
const filePath = this.
|
|
39
|
+
const filePath = this.resolvePath(fileId);
|
|
32
40
|
try {
|
|
33
41
|
return await promises_1.default.readFile(filePath);
|
|
34
42
|
}
|
|
@@ -40,20 +48,10 @@ class FileSystemManager {
|
|
|
40
48
|
const filePath = this.resolvePath(`${fileId}.metadata`);
|
|
41
49
|
return (0, n8n_workflow_1.jsonParse)(await promises_1.default.readFile(filePath, { encoding: 'utf-8' }));
|
|
42
50
|
}
|
|
43
|
-
async store(_workflowId, executionId, bufferOrStream, { mimeType, fileName }) {
|
|
44
|
-
const fileId = this.toFileId(executionId);
|
|
45
|
-
const filePath = this.getPath(fileId);
|
|
46
|
-
await promises_1.default.writeFile(filePath, bufferOrStream);
|
|
47
|
-
const fileSize = await this.getSize(fileId);
|
|
48
|
-
await this.storeMetadata(fileId, { mimeType, fileName, fileSize });
|
|
49
|
-
return { fileId, fileSize };
|
|
50
|
-
}
|
|
51
|
-
async deleteOne(fileId) {
|
|
52
|
-
const filePath = this.getPath(fileId);
|
|
53
|
-
return promises_1.default.rm(filePath);
|
|
54
|
-
}
|
|
55
51
|
async deleteMany(ids) {
|
|
56
52
|
var _a;
|
|
53
|
+
if (ids.length === 0)
|
|
54
|
+
return;
|
|
57
55
|
const executionIds = ids.map((o) => o.executionId);
|
|
58
56
|
const set = new Set(executionIds);
|
|
59
57
|
const fileNames = await promises_1.default.readdir(this.storagePath);
|
|
@@ -64,35 +62,48 @@ class FileSystemManager {
|
|
|
64
62
|
await Promise.all([promises_1.default.rm(filePath), promises_1.default.rm(`${filePath}.metadata`)]);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
65
|
+
const binaryDataDirs = ids.map(({ workflowId, executionId }) => this.resolvePath(`workflows/${workflowId}/executions/${executionId}/binary_data/`));
|
|
66
|
+
await Promise.all(binaryDataDirs.map(async (dir) => {
|
|
67
|
+
await promises_1.default.rm(dir, { recursive: true, force: true });
|
|
68
|
+
}));
|
|
67
69
|
}
|
|
68
|
-
async copyByFilePath(
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
async copyByFilePath(workflowId, executionId, sourcePath, { mimeType, fileName }) {
|
|
71
|
+
const targetFileId = this.toFileId(workflowId, executionId);
|
|
72
|
+
const targetPath = this.resolvePath(targetFileId);
|
|
73
|
+
await (0, utils_1.assertDir)(node_path_1.default.dirname(targetPath));
|
|
74
|
+
await promises_1.default.cp(sourcePath, targetPath);
|
|
75
|
+
const fileSize = await this.getSize(targetFileId);
|
|
76
|
+
await this.storeMetadata(targetFileId, { mimeType, fileName, fileSize });
|
|
77
|
+
return { fileId: targetFileId, fileSize };
|
|
78
|
+
}
|
|
79
|
+
async copyByFileId(workflowId, executionId, sourceFileId) {
|
|
80
|
+
const targetFileId = this.toFileId(workflowId, executionId);
|
|
77
81
|
const sourcePath = this.resolvePath(sourceFileId);
|
|
78
82
|
const targetPath = this.resolvePath(targetFileId);
|
|
83
|
+
await (0, utils_1.assertDir)(node_path_1.default.dirname(targetPath));
|
|
79
84
|
await promises_1.default.copyFile(sourcePath, targetPath);
|
|
80
85
|
return targetFileId;
|
|
81
86
|
}
|
|
82
87
|
async rename(oldFileId, newFileId) {
|
|
83
|
-
const oldPath = this.
|
|
84
|
-
const newPath = this.
|
|
88
|
+
const oldPath = this.resolvePath(oldFileId);
|
|
89
|
+
const newPath = this.resolvePath(newFileId);
|
|
90
|
+
await (0, utils_1.assertDir)(node_path_1.default.dirname(newPath));
|
|
85
91
|
await Promise.all([
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
promises_1.default.rename(oldPath, newPath),
|
|
93
|
+
promises_1.default.rename(`${oldPath}.metadata`, `${newPath}.metadata`),
|
|
88
94
|
]);
|
|
95
|
+
const [tempDirParent] = oldPath.split('/temp/');
|
|
96
|
+
const tempDir = node_path_1.default.join(tempDirParent, 'temp');
|
|
97
|
+
await promises_1.default.rm(tempDir, { recursive: true });
|
|
89
98
|
}
|
|
90
|
-
toFileId(executionId) {
|
|
91
|
-
|
|
99
|
+
toFileId(workflowId, executionId) {
|
|
100
|
+
if (!executionId)
|
|
101
|
+
executionId = 'temp';
|
|
102
|
+
return `workflows/${workflowId}/executions/${executionId}/binary_data/${(0, uuid_1.v4)()}`;
|
|
92
103
|
}
|
|
93
104
|
resolvePath(...args) {
|
|
94
|
-
const returnPath =
|
|
95
|
-
if (
|
|
105
|
+
const returnPath = node_path_1.default.join(this.storagePath, ...args);
|
|
106
|
+
if (node_path_1.default.relative(this.storagePath, returnPath).startsWith('..')) {
|
|
96
107
|
throw new errors_1.FileNotFoundError('Invalid path detected');
|
|
97
108
|
}
|
|
98
109
|
return returnPath;
|
|
@@ -102,7 +113,7 @@ class FileSystemManager {
|
|
|
102
113
|
await promises_1.default.writeFile(filePath, JSON.stringify(metadata), { encoding: 'utf-8' });
|
|
103
114
|
}
|
|
104
115
|
async getSize(fileId) {
|
|
105
|
-
const filePath = this.
|
|
116
|
+
const filePath = this.resolvePath(fileId);
|
|
106
117
|
try {
|
|
107
118
|
const stats = await promises_1.default.stat(filePath);
|
|
108
119
|
return stats.size;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.manager.js","sourceRoot":"","sources":["../../src/BinaryData/FileSystem.manager.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"FileSystem.manager.js","sourceRoot":"","sources":["../../src/BinaryData/FileSystem.manager.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA2C;AAC3C,gEAAkC;AAClC,0DAA6B;AAC7B,+BAAkC;AAClC,+CAAyC;AACzC,mCAAoC;AACpC,sCAA8C;AAK9C,MAAM,sBAAsB,GAC3B,gGAAgG,CAAC;AAElG,MAAa,iBAAiB;IAC7B,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;IAE3C,KAAK,CAAC,IAAI;QACT,MAAM,IAAA,iBAAS,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,KAAK,CACV,UAAkB,EAClB,WAAmB,EACnB,cAAiC,EACjC,EAAE,QAAQ,EAAE,QAAQ,EAA+B;QAEn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AC;IACnB,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,MAAc,EAAE,QAA6B;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC;QAExD,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,MAAc;QACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI;YACH,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC,IAAI,CAAC;SAClB;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,+CAA+C,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;SACnF;IACF,CAAC;CACD;AAjLD,8CAiLC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { ObjectStoreService } from '../ObjectStore/ObjectStore.service.ee';
|
|
4
|
+
import type { Readable } from 'node:stream';
|
|
5
|
+
import type { BinaryData } from './types';
|
|
6
|
+
export declare class ObjectStoreManager implements BinaryData.Manager {
|
|
7
|
+
private readonly objectStoreService;
|
|
8
|
+
constructor(objectStoreService: ObjectStoreService);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
store(workflowId: string, executionId: string, bufferOrStream: Buffer | Readable, metadata: BinaryData.PreWriteMetadata): Promise<{
|
|
11
|
+
fileId: string;
|
|
12
|
+
fileSize: number;
|
|
13
|
+
}>;
|
|
14
|
+
getPath(fileId: string): string;
|
|
15
|
+
getAsBuffer(fileId: string): Promise<Buffer>;
|
|
16
|
+
getAsStream(fileId: string): Promise<Readable>;
|
|
17
|
+
getMetadata(fileId: string): Promise<BinaryData.Metadata>;
|
|
18
|
+
copyByFileId(workflowId: string, executionId: string, sourceFileId: string): Promise<string>;
|
|
19
|
+
copyByFilePath(workflowId: string, executionId: string, sourcePath: string, metadata: BinaryData.PreWriteMetadata): Promise<{
|
|
20
|
+
fileId: string;
|
|
21
|
+
fileSize: number;
|
|
22
|
+
}>;
|
|
23
|
+
deleteMany(ids: BinaryData.IdsForDeletion): Promise<void>;
|
|
24
|
+
rename(oldFileId: string, newFileId: string): Promise<void>;
|
|
25
|
+
private toFileId;
|
|
26
|
+
private toBuffer;
|
|
27
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ObjectStoreManager = void 0;
|
|
16
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
17
|
+
const typedi_1 = require("typedi");
|
|
18
|
+
const uuid_1 = require("uuid");
|
|
19
|
+
const utils_1 = require("./utils");
|
|
20
|
+
const ObjectStore_service_ee_1 = require("../ObjectStore/ObjectStore.service.ee");
|
|
21
|
+
let ObjectStoreManager = class ObjectStoreManager {
|
|
22
|
+
constructor(objectStoreService) {
|
|
23
|
+
this.objectStoreService = objectStoreService;
|
|
24
|
+
}
|
|
25
|
+
async init() {
|
|
26
|
+
await this.objectStoreService.checkConnection();
|
|
27
|
+
}
|
|
28
|
+
async store(workflowId, executionId, bufferOrStream, metadata) {
|
|
29
|
+
const fileId = this.toFileId(workflowId, executionId);
|
|
30
|
+
const buffer = await this.toBuffer(bufferOrStream);
|
|
31
|
+
await this.objectStoreService.put(fileId, buffer, metadata);
|
|
32
|
+
return { fileId, fileSize: buffer.length };
|
|
33
|
+
}
|
|
34
|
+
getPath(fileId) {
|
|
35
|
+
return fileId;
|
|
36
|
+
}
|
|
37
|
+
async getAsBuffer(fileId) {
|
|
38
|
+
return this.objectStoreService.get(fileId, { mode: 'buffer' });
|
|
39
|
+
}
|
|
40
|
+
async getAsStream(fileId) {
|
|
41
|
+
return this.objectStoreService.get(fileId, { mode: 'stream' });
|
|
42
|
+
}
|
|
43
|
+
async getMetadata(fileId) {
|
|
44
|
+
const { 'content-length': contentLength, 'content-type': contentType, 'x-amz-meta-filename': fileName, } = await this.objectStoreService.getMetadata(fileId);
|
|
45
|
+
const metadata = { fileSize: Number(contentLength) };
|
|
46
|
+
if (contentType)
|
|
47
|
+
metadata.mimeType = contentType;
|
|
48
|
+
if (fileName)
|
|
49
|
+
metadata.fileName = fileName;
|
|
50
|
+
return metadata;
|
|
51
|
+
}
|
|
52
|
+
async copyByFileId(workflowId, executionId, sourceFileId) {
|
|
53
|
+
const targetFileId = this.toFileId(workflowId, executionId);
|
|
54
|
+
const sourceFile = await this.objectStoreService.get(sourceFileId, { mode: 'buffer' });
|
|
55
|
+
await this.objectStoreService.put(targetFileId, sourceFile);
|
|
56
|
+
return targetFileId;
|
|
57
|
+
}
|
|
58
|
+
async copyByFilePath(workflowId, executionId, sourcePath, metadata) {
|
|
59
|
+
const targetFileId = this.toFileId(workflowId, executionId);
|
|
60
|
+
const sourceFile = await promises_1.default.readFile(sourcePath);
|
|
61
|
+
await this.objectStoreService.put(targetFileId, sourceFile, metadata);
|
|
62
|
+
return { fileId: targetFileId, fileSize: sourceFile.length };
|
|
63
|
+
}
|
|
64
|
+
async deleteMany(ids) {
|
|
65
|
+
const prefixes = ids.map(({ workflowId, executionId }) => `workflows/${workflowId}/executions/${executionId}/binary_data/`);
|
|
66
|
+
await Promise.all(prefixes.map(async (prefix) => {
|
|
67
|
+
await this.objectStoreService.deleteMany(prefix);
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
async rename(oldFileId, newFileId) {
|
|
71
|
+
const oldFile = await this.objectStoreService.get(oldFileId, { mode: 'buffer' });
|
|
72
|
+
const oldFileMetadata = await this.objectStoreService.getMetadata(oldFileId);
|
|
73
|
+
await this.objectStoreService.put(newFileId, oldFile, oldFileMetadata);
|
|
74
|
+
await this.objectStoreService.deleteOne(oldFileId);
|
|
75
|
+
}
|
|
76
|
+
toFileId(workflowId, executionId) {
|
|
77
|
+
if (!executionId)
|
|
78
|
+
executionId = 'temp';
|
|
79
|
+
return `workflows/${workflowId}/executions/${executionId}/binary_data/${(0, uuid_1.v4)()}`;
|
|
80
|
+
}
|
|
81
|
+
async toBuffer(bufferOrStream) {
|
|
82
|
+
return (0, utils_1.toBuffer)(bufferOrStream);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.ObjectStoreManager = ObjectStoreManager;
|
|
86
|
+
exports.ObjectStoreManager = ObjectStoreManager = __decorate([
|
|
87
|
+
(0, typedi_1.Service)(),
|
|
88
|
+
__metadata("design:paramtypes", [ObjectStore_service_ee_1.ObjectStoreService])
|
|
89
|
+
], ObjectStoreManager);
|
|
90
|
+
//# sourceMappingURL=ObjectStore.manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectStore.manager.js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Error extends Error {
|
|
2
|
+
message: string;
|
|
3
3
|
}
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class UnknownManagerError extends Error {
|
|
5
5
|
constructor(mode: string);
|
|
6
6
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.UnknownManagerError = exports.InvalidModeError = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
|
-
class
|
|
5
|
+
class InvalidModeError extends Error {
|
|
6
6
|
constructor() {
|
|
7
|
-
super(
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.message = `Invalid binary data mode. Valid modes: ${utils_1.CONFIG_MODES.join(', ')}`;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
exports.
|
|
11
|
-
class
|
|
11
|
+
exports.InvalidModeError = InvalidModeError;
|
|
12
|
+
class UnknownManagerError extends Error {
|
|
12
13
|
constructor(mode) {
|
|
13
14
|
super(`No binary data manager found for: ${mode}`);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
exports.
|
|
17
|
+
exports.UnknownManagerError = UnknownManagerError;
|
|
17
18
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/BinaryData/errors.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/BinaryData/errors.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC,MAAa,gBAAiB,SAAQ,KAAK;IAA3C;;QACC,YAAO,GAAG,0CAA0C,oBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/E,CAAC;CAAA;AAFD,4CAEC;AAED,MAAa,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,IAAY;QACvB,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;CACD;AAJD,kDAIC"}
|
|
@@ -1,39 +1,42 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { Readable } from 'stream';
|
|
4
|
-
import type { BINARY_DATA_MODES } from './utils';
|
|
5
4
|
export declare namespace BinaryData {
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
type LegacyMode = 'filesystem';
|
|
6
|
+
type UpgradedMode = 'filesystem-v2';
|
|
7
|
+
export type ConfigMode = 'default' | 'filesystem' | 's3';
|
|
8
|
+
export type ServiceMode = Exclude<ConfigMode, LegacyMode> | UpgradedMode;
|
|
9
|
+
export type StoredMode = Exclude<ConfigMode | UpgradedMode, 'default'>;
|
|
10
|
+
export type Config = {
|
|
11
|
+
mode: ConfigMode;
|
|
12
|
+
availableModes: ConfigMode[];
|
|
10
13
|
localStoragePath: string;
|
|
11
14
|
};
|
|
12
|
-
type Metadata = {
|
|
15
|
+
export type Metadata = {
|
|
13
16
|
fileName?: string;
|
|
14
17
|
mimeType?: string;
|
|
15
18
|
fileSize: number;
|
|
16
19
|
};
|
|
17
|
-
type WriteResult = {
|
|
20
|
+
export type WriteResult = {
|
|
18
21
|
fileId: string;
|
|
19
22
|
fileSize: number;
|
|
20
23
|
};
|
|
21
|
-
type PreWriteMetadata = Omit<Metadata, 'fileSize'>;
|
|
22
|
-
type IdsForDeletion = Array<{
|
|
24
|
+
export type PreWriteMetadata = Omit<Metadata, 'fileSize'>;
|
|
25
|
+
export type IdsForDeletion = Array<{
|
|
23
26
|
workflowId: string;
|
|
24
27
|
executionId: string;
|
|
25
28
|
}>;
|
|
26
|
-
interface Manager {
|
|
29
|
+
export interface Manager {
|
|
27
30
|
init(): Promise<void>;
|
|
28
31
|
store(workflowId: string, executionId: string, bufferOrStream: Buffer | Readable, metadata: PreWriteMetadata): Promise<WriteResult>;
|
|
29
32
|
getPath(fileId: string): string;
|
|
30
33
|
getAsBuffer(fileId: string): Promise<Buffer>;
|
|
31
34
|
getAsStream(fileId: string, chunkSize?: number): Promise<Readable>;
|
|
32
35
|
getMetadata(fileId: string): Promise<Metadata>;
|
|
33
|
-
copyByFileId(workflowId: string, executionId: string, sourceFileId: string): Promise<string>;
|
|
34
|
-
copyByFilePath(workflowId: string, executionId: string, filePath: string, metadata: PreWriteMetadata): Promise<WriteResult>;
|
|
35
|
-
deleteOne(fileId: string): Promise<void>;
|
|
36
36
|
deleteMany(ids: IdsForDeletion): Promise<void>;
|
|
37
|
+
copyByFileId(workflowId: string, executionId: string, sourceFileId: string): Promise<string>;
|
|
38
|
+
copyByFilePath(workflowId: string, executionId: string, sourcePath: string, metadata: PreWriteMetadata): Promise<WriteResult>;
|
|
37
39
|
rename(oldFileId: string, newFileId: string): Promise<void>;
|
|
38
40
|
}
|
|
41
|
+
export {};
|
|
39
42
|
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { Readable } from 'node:stream';
|
|
4
4
|
import type { BinaryData } from './types';
|
|
5
|
-
export declare const
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
5
|
+
export declare const CONFIG_MODES: readonly ["default", "filesystem", "s3"];
|
|
6
|
+
export declare function areConfigModes(modes: string[]): modes is BinaryData.ConfigMode[];
|
|
7
|
+
export declare function isStoredMode(mode: string): mode is BinaryData.StoredMode;
|
|
8
|
+
export declare function assertDir(dir: string): Promise<void>;
|
|
8
9
|
export declare function toBuffer(body: Buffer | Readable): Promise<Buffer>;
|
package/dist/BinaryData/utils.js
CHANGED
|
@@ -3,15 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.toBuffer = exports.
|
|
6
|
+
exports.toBuffer = exports.assertDir = exports.isStoredMode = exports.areConfigModes = exports.CONFIG_MODES = void 0;
|
|
7
7
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
8
8
|
const concat_stream_1 = __importDefault(require("concat-stream"));
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
exports.CONFIG_MODES = ['default', 'filesystem', 's3'];
|
|
10
|
+
const STORED_MODES = ['filesystem', 'filesystem-v2', 's3'];
|
|
11
|
+
function areConfigModes(modes) {
|
|
12
|
+
return modes.every((m) => exports.CONFIG_MODES.includes(m));
|
|
12
13
|
}
|
|
13
|
-
exports.
|
|
14
|
-
|
|
14
|
+
exports.areConfigModes = areConfigModes;
|
|
15
|
+
function isStoredMode(mode) {
|
|
16
|
+
return STORED_MODES.includes(mode);
|
|
17
|
+
}
|
|
18
|
+
exports.isStoredMode = isStoredMode;
|
|
19
|
+
async function assertDir(dir) {
|
|
15
20
|
try {
|
|
16
21
|
await promises_1.default.access(dir);
|
|
17
22
|
}
|
|
@@ -19,7 +24,7 @@ async function ensureDirExists(dir) {
|
|
|
19
24
|
await promises_1.default.mkdir(dir, { recursive: true });
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
|
-
exports.
|
|
27
|
+
exports.assertDir = assertDir;
|
|
23
28
|
async function toBuffer(body) {
|
|
24
29
|
return new Promise((resolve) => {
|
|
25
30
|
if (Buffer.isBuffer(body))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/BinaryData/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkC;AAGlC,kEAAyC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/BinaryData/utils.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAkC;AAGlC,kEAAyC;AAE5B,QAAA,YAAY,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,IAAI,CAAU,CAAC;AAErE,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,eAAe,EAAE,IAAI,CAAU,CAAC;AAEpE,SAAgB,cAAc,CAAC,KAAe;IAC7C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,oBAAY,CAAC,QAAQ,CAAC,CAA0B,CAAC,CAAC,CAAC;AAC9E,CAAC;AAFD,wCAEC;AAED,SAAgB,YAAY,CAAC,IAAY;IACxC,OAAO,YAAY,CAAC,QAAQ,CAAC,IAA6B,CAAC,CAAC;AAC7D,CAAC;AAFD,oCAEC;AAEM,KAAK,UAAU,SAAS,CAAC,GAAW;IAC1C,IAAI;QACH,MAAM,kBAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KACrB;IAAC,MAAM;QACP,MAAM,kBAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACzC;AACF,CAAC;AAND,8BAMC;AAEM,KAAK,UAAU,QAAQ,CAAC,IAAuB;IACrD,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;QACtC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC;;YACpC,IAAI,CAAC,IAAI,CAAC,IAAA,uBAAY,EAAC,OAAO,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACJ,CAAC;AALD,4BAKC"}
|
|
@@ -34,6 +34,7 @@ export declare function continueOnFail(node: INode): boolean;
|
|
|
34
34
|
export declare function getNodeWebhookUrl(name: string, workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, timezone: string, additionalKeys: IWorkflowDataProxyAdditionalKeys, isTest?: boolean): string | undefined;
|
|
35
35
|
export declare function getTimezone(workflow: Workflow, additionalData: IWorkflowExecuteAdditionalData): string;
|
|
36
36
|
export declare function getWebhookDescription(name: string, workflow: Workflow, node: INode): IWebhookDescription | undefined;
|
|
37
|
+
export declare function copyInputItems(items: INodeExecutionData[], properties: string[]): IDataObject[];
|
|
37
38
|
export declare function getExecutePollFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): IPollFunctions;
|
|
38
39
|
export declare function getExecuteTriggerFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode): ITriggerFunctions;
|
|
39
40
|
export declare function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunExecutionData, runIndex: number, connectionInputData: INodeExecutionData[], inputData: ITaskDataConnections, node: INode, additionalData: IWorkflowExecuteAdditionalData, executeData: IExecuteData, mode: WorkflowExecuteMode): IExecuteFunctions;
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getExecuteWebhookFunctions = exports.getExecuteHookFunctions = exports.getLoadOptionsFunctions = exports.getCredentialTestFunctions = exports.getExecuteSingleFunctions = exports.getExecuteFunctions = exports.getExecuteTriggerFunctions = exports.getExecutePollFunctions = exports.getWebhookDescription = exports.getTimezone = exports.getNodeWebhookUrl = exports.continueOnFail = exports.getNodeParameter = exports.validateValueAgainstSchema = exports.getCredentials = exports.getAdditionalKeys = exports.requestWithAuthentication = exports.normalizeItems = exports.constructExecutionMetaData = exports.returnJsonArray = exports.httpRequestWithAuthentication = exports.requestOAuth1 = exports.requestOAuth2 = exports.copyBinaryFile = exports.setBinaryDataBuffer = exports.getBinaryDataBuffer = exports.assertBinaryData = exports.getBinaryStream = exports.getBinaryMetadata = exports.getBinaryPath = exports.proxyRequestToAxios = exports.parseIncomingMessage = void 0;
|
|
29
|
+
exports.getExecuteWebhookFunctions = exports.getExecuteHookFunctions = exports.getLoadOptionsFunctions = exports.getCredentialTestFunctions = exports.getExecuteSingleFunctions = exports.getExecuteFunctions = exports.getExecuteTriggerFunctions = exports.getExecutePollFunctions = exports.copyInputItems = exports.getWebhookDescription = exports.getTimezone = exports.getNodeWebhookUrl = exports.continueOnFail = exports.getNodeParameter = exports.validateValueAgainstSchema = exports.getCredentials = exports.getAdditionalKeys = exports.requestWithAuthentication = exports.normalizeItems = exports.constructExecutionMetaData = exports.returnJsonArray = exports.httpRequestWithAuthentication = exports.requestOAuth1 = exports.requestOAuth2 = exports.copyBinaryFile = exports.setBinaryDataBuffer = exports.getBinaryDataBuffer = exports.assertBinaryData = exports.getBinaryStream = exports.getBinaryMetadata = exports.getBinaryPath = exports.proxyRequestToAxios = exports.parseIncomingMessage = void 0;
|
|
30
30
|
const client_oauth2_1 = require("@n8n/client-oauth2");
|
|
31
31
|
const axios_1 = __importDefault(require("axios"));
|
|
32
32
|
const crypto_1 = __importStar(require("crypto"));
|
|
@@ -1683,6 +1683,21 @@ const getBinaryHelperFunctions = ({ executionId }, workflowId) => ({
|
|
|
1683
1683
|
throw new Error('copyBinaryFile has been removed. Please upgrade this node');
|
|
1684
1684
|
},
|
|
1685
1685
|
});
|
|
1686
|
+
function copyInputItems(items, properties) {
|
|
1687
|
+
return items.map((item) => {
|
|
1688
|
+
const newItem = {};
|
|
1689
|
+
for (const property of properties) {
|
|
1690
|
+
if (item.json[property] === undefined) {
|
|
1691
|
+
newItem[property] = null;
|
|
1692
|
+
}
|
|
1693
|
+
else {
|
|
1694
|
+
newItem[property] = (0, n8n_workflow_1.deepCopy)(item.json[property]);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
return newItem;
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
exports.copyInputItems = copyInputItems;
|
|
1686
1701
|
function getExecutePollFunctions(workflow, node, additionalData, mode, activation) {
|
|
1687
1702
|
return ((workflow, node) => {
|
|
1688
1703
|
return {
|
|
@@ -1941,6 +1956,7 @@ function getExecuteFunctions(workflow, runExecutionData, runIndex, connectionInp
|
|
|
1941
1956
|
},
|
|
1942
1957
|
helpers: {
|
|
1943
1958
|
createDeferredPromise: n8n_workflow_1.createDeferredPromise,
|
|
1959
|
+
copyInputItems,
|
|
1944
1960
|
...getRequestHelperFunctions(workflow, node, additionalData),
|
|
1945
1961
|
...getFileSystemHelperFunctions(node),
|
|
1946
1962
|
...getBinaryHelperFunctions(additionalData, workflow.id),
|