diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 878152de40..3a85221388 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -538,7 +538,7 @@ class App { const workflowData = loadDataInstance.getWorkflowData() as IWorkflowBase; const workflowCredentials = await WorkflowCredentials(workflowData.nodes); - const additionalData = await WorkflowExecuteAdditionalData.getBase(executionMode, workflowCredentials,currentNodeParameters); + const additionalData = await WorkflowExecuteAdditionalData.getBase(executionMode, workflowCredentials, currentNodeParameters); return loadDataInstance.getOptions(methodName, additionalData); })); diff --git a/packages/cli/src/WorkflowExecuteAdditionalData.ts b/packages/cli/src/WorkflowExecuteAdditionalData.ts index a5e79de075..91821e607b 100644 --- a/packages/cli/src/WorkflowExecuteAdditionalData.ts +++ b/packages/cli/src/WorkflowExecuteAdditionalData.ts @@ -17,13 +17,13 @@ import { import { IDataObject, + INodeParameters, IRun, ITaskData, IWorkflowCredentials, IWorkflowExecuteAdditionalData, IWorkflowExecuteHooks, WorkflowExecuteMode, - INodeParameters, } from 'n8n-workflow'; import * as config from '../config'; @@ -246,7 +246,7 @@ const hooks = (mode: WorkflowExecuteMode, workflowData: IWorkflowBase, execution * @param {IWorkflowCredentials} credentials * @returns {Promise} */ -export async function getBase(mode: WorkflowExecuteMode, credentials: IWorkflowCredentials,currentNodeParameters: INodeParameters[] = []): Promise { +export async function getBase(mode: WorkflowExecuteMode, credentials: IWorkflowCredentials, currentNodeParameters: INodeParameters[] = []): Promise { const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl(); const timezone = config.get('generic.timezone') as string; @@ -264,7 +264,7 @@ export async function getBase(mode: WorkflowExecuteMode, credentials: IWorkflowC timezone, webhookBaseUrl, webhookTestBaseUrl, - currentNodeParameters + currentNodeParameters, }; } diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 1cf832952f..58e1e320d8 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -513,12 +513,15 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, additio getCredentials(type: string): ICredentialDataDecryptedObject | undefined { return getCredentials(workflow, node, type, additionalData); }, - getCurrentNodeParameters : (parameterName : string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { - const nodeParameters = JSON.parse(''+additionalData.currentNodeParameters); - if(nodeParameters && nodeParameters[parameterName] ){ + getCurrentNodeParameter: (parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined => { + const nodeParameters = JSON.parse('' + additionalData.currentNodeParameters); + if (nodeParameters && nodeParameters[parameterName]) { return nodeParameters[parameterName]; } - return false; + return undefined; + }, + getCurrentNodeParameters: (): INodeParameters | undefined => { + return JSON.parse('' + additionalData.currentNodeParameters); }, getNodeParameter: (parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object => { //tslint:disable-line:no-any const runExecutionData: IRunExecutionData | null = null; diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 77afadf4a7..f0c821c35a 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -181,7 +181,8 @@ export interface IExecuteSingleFunctions { export interface ILoadOptionsFunctions { getCredentials(type: string): ICredentialDataDecryptedObject | undefined; getNodeParameter(parameterName: string, fallbackValue?: any): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; //tslint:disable-line:no-any - getCurrentNodeParameters(parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object; + getCurrentNodeParameter(parameterName: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined; + getCurrentNodeParameters(): INodeParameters | undefined; getTimezone(): string; helpers: { [key: string]: ((...args: any[]) => any) | undefined; //tslint:disable-line:no-any @@ -291,7 +292,7 @@ export type NodeParameterValue = string | number | boolean; export interface INodeParameters { // TODO: Later also has to be possible to add multiple ones with the name name. So array has to be possible - [key: string]: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] ; + [key: string]: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[]; }