diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 44a694de8f..b95b05bebd 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -49,6 +49,7 @@ import type { IPairedItemData, ICredentialTestFunctions, BinaryHelperFunctions, + NodeHelperFunctions, RequestHelperFunctions, FunctionsBase, IExecuteFunctions, @@ -2054,6 +2055,13 @@ const getFileSystemHelperFunctions = (node: INode): FileSystemHelperFunctions => }, }); +const getNodeHelperFunctions = ({ + executionId, +}: IWorkflowExecuteAdditionalData): NodeHelperFunctions => ({ + copyBinaryFile: async (filePath, fileName, mimeType) => + copyBinaryFile(executionId!, filePath, fileName, mimeType), +}); + const getBinaryHelperFunctions = ({ executionId, }: IWorkflowExecuteAdditionalData): BinaryHelperFunctions => ({ @@ -2064,8 +2072,9 @@ const getBinaryHelperFunctions = ({ prepareBinaryData(binaryData, executionId!, filePath, mimeType), setBinaryDataBuffer: async (data, binaryData) => setBinaryDataBuffer(data, binaryData, executionId!), - copyBinaryFile: async (filePath, fileName, mimeType) => - copyBinaryFile(executionId!, filePath, fileName, mimeType), + copyBinaryFile: async () => { + throw new Error('copyBinaryFile has been removed. Please upgrade this node'); + }, }); /** @@ -2368,6 +2377,7 @@ export function getExecuteFunctions( normalizeItems, constructExecutionMetaData, }, + nodeHelpers: getNodeHelperFunctions(additionalData), }; })(workflow, runExecutionData, connectionInputData, inputData, node) as IExecuteFunctions; } @@ -2758,6 +2768,7 @@ export function getExecuteWebhookFunctions( ...getBinaryHelperFunctions(additionalData), returnJsonArray, }, + nodeHelpers: getNodeHelperFunctions(additionalData), }; })(workflow, node); } diff --git a/packages/nodes-base/nodes/Ftp/Ftp.node.ts b/packages/nodes-base/nodes/Ftp/Ftp.node.ts index 66575b454b..a50b15f538 100644 --- a/packages/nodes-base/nodes/Ftp/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp/Ftp.node.ts @@ -603,7 +603,7 @@ export class Ftp implements INodeType { const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i); const filePathDownload = this.getNodeParameter('path', i) as string; - items[i].binary![dataPropertyNameDownload] = await this.helpers.copyBinaryFile( + items[i].binary![dataPropertyNameDownload] = await this.nodeHelpers.copyBinaryFile( binaryFile.path, filePathDownload, ); @@ -699,7 +699,7 @@ export class Ftp implements INodeType { const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i); const filePathDownload = this.getNodeParameter('path', i) as string; - items[i].binary![dataPropertyNameDownload] = await this.helpers.copyBinaryFile( + items[i].binary![dataPropertyNameDownload] = await this.nodeHelpers.copyBinaryFile( binaryFile.path, filePathDownload, ); diff --git a/packages/nodes-base/nodes/Ssh/Ssh.node.ts b/packages/nodes-base/nodes/Ssh/Ssh.node.ts index 04fb96fcc1..b39d429374 100644 --- a/packages/nodes-base/nodes/Ssh/Ssh.node.ts +++ b/packages/nodes-base/nodes/Ssh/Ssh.node.ts @@ -329,7 +329,7 @@ export class Ssh implements INodeType { items[i] = newItem; - items[i].binary![dataPropertyNameDownload] = await this.helpers.copyBinaryFile( + items[i].binary![dataPropertyNameDownload] = await this.nodeHelpers.copyBinaryFile( path, parameterPath, ); diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index 72a60bbbcf..a6eff82ad7 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -714,7 +714,7 @@ export class Wait implements INodeType { } const fileJson = file.toJSON(); - returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( + returnItem.binary![binaryPropertyName] = await this.nodeHelpers.copyBinaryFile( file.path, fileJson.name || fileJson.filename, fileJson.type as string, @@ -747,7 +747,7 @@ export class Wait implements INodeType { }; const binaryPropertyName = (options.binaryPropertyName || 'data') as string; - returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( + returnItem.binary![binaryPropertyName] = await this.nodeHelpers.copyBinaryFile( binaryFile.path, mimeType, ); diff --git a/packages/nodes-base/nodes/Webhook/Webhook.node.ts b/packages/nodes-base/nodes/Webhook/Webhook.node.ts index 716fa35b85..f2fa74f7b6 100644 --- a/packages/nodes-base/nodes/Webhook/Webhook.node.ts +++ b/packages/nodes-base/nodes/Webhook/Webhook.node.ts @@ -526,7 +526,7 @@ export class Webhook implements INodeType { } const fileJson = file.toJSON(); - returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( + returnItem.binary![binaryPropertyName] = await this.nodeHelpers.copyBinaryFile( file.path, fileJson.name || fileJson.filename, fileJson.type as string, @@ -559,7 +559,7 @@ export class Webhook implements INodeType { }; const binaryPropertyName = (options.binaryPropertyName || 'data') as string; - returnItem.binary![binaryPropertyName] = await this.helpers.copyBinaryFile( + returnItem.binary![binaryPropertyName] = await this.nodeHelpers.copyBinaryFile( binaryFile.path, mimeType, ); diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index b0faaa05ce..6770237c5f 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -676,12 +676,16 @@ export interface BinaryHelperFunctions { mimeType?: string, ): Promise; setBinaryDataBuffer(data: IBinaryData, binaryData: Buffer): Promise; - copyBinaryFile(filePath: string, fileName: string, mimeType?: string): Promise; + copyBinaryFile(): Promise; binaryToBuffer(body: Buffer | Readable): Promise; getBinaryStream(binaryDataId: string, chunkSize?: number): Readable; getBinaryMetadata(binaryDataId: string): Promise; } +export interface NodeHelperFunctions { + copyBinaryFile(filePath: string, fileName: string, mimeType?: string): Promise; +} + export interface RequestHelperFunctions { request(uriOrObject: string | IDataObject | any, options?: IDataObject): Promise; requestWithAuthentication( @@ -753,6 +757,7 @@ export type IExecuteFunctions = ExecuteFunctions.GetNodeParameterFn & sendMessageToUI(message: any): void; sendResponse(response: IExecuteResponsePromiseData): void; + nodeHelpers: NodeHelperFunctions; helpers: RequestHelperFunctions & BaseHelperFunctions & BinaryHelperFunctions & @@ -875,6 +880,7 @@ export interface IWebhookFunctions extends FunctionsBaseWithRequiredKeys<'getMod outputData: INodeExecutionData[], outputIndex?: number, ): Promise; + nodeHelpers: NodeHelperFunctions; helpers: RequestHelperFunctions & BaseHelperFunctions & BinaryHelperFunctions &