mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Make it possible to read sibling parameter
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeParameters,
|
||||
IRunExecutionData,
|
||||
IWorkflowDataProxyData,
|
||||
NodeHelpers,
|
||||
NodeParameterValue,
|
||||
Workflow,
|
||||
WorkflowExecuteMode,
|
||||
} from './';
|
||||
@@ -18,12 +20,13 @@ export class WorkflowDataProxy {
|
||||
private itemIndex: number;
|
||||
private activeNodeName: string;
|
||||
private connectionInputData: INodeExecutionData[];
|
||||
private siblingParameters: INodeParameters;
|
||||
private mode: WorkflowExecuteMode;
|
||||
private selfData: IDataObject;
|
||||
|
||||
|
||||
|
||||
constructor(workflow: Workflow, runExecutionData: IRunExecutionData | null, runIndex: number, itemIndex: number, activeNodeName: string, connectionInputData: INodeExecutionData[], mode: WorkflowExecuteMode, defaultReturnRunIndex = -1, selfData = {}) {
|
||||
constructor(workflow: Workflow, runExecutionData: IRunExecutionData | null, runIndex: number, itemIndex: number, activeNodeName: string, connectionInputData: INodeExecutionData[], siblingParameters: INodeParameters, mode: WorkflowExecuteMode, defaultReturnRunIndex = -1, selfData = {}) {
|
||||
this.workflow = workflow;
|
||||
this.runExecutionData = runExecutionData;
|
||||
this.defaultReturnRunIndex = defaultReturnRunIndex;
|
||||
@@ -31,6 +34,7 @@ export class WorkflowDataProxy {
|
||||
this.itemIndex = itemIndex;
|
||||
this.activeNodeName = activeNodeName;
|
||||
this.connectionInputData = connectionInputData;
|
||||
this.siblingParameters = siblingParameters;
|
||||
this.mode = mode;
|
||||
this.selfData = selfData;
|
||||
}
|
||||
@@ -108,12 +112,22 @@ export class WorkflowDataProxy {
|
||||
get(target, name, receiver) {
|
||||
name = name.toString();
|
||||
|
||||
if (!node.parameters.hasOwnProperty(name)) {
|
||||
// Parameter does not exist on node
|
||||
throw new Error(`Could not find parameter "${name}" on node "${nodeName}"`);
|
||||
}
|
||||
let returnValue: INodeParameters | NodeParameterValue | NodeParameterValue[] | INodeParameters[];
|
||||
if (name[0] === '/') {
|
||||
const key = name.slice(1);
|
||||
if (!that.siblingParameters.hasOwnProperty(key)) {
|
||||
throw new Error(`Could not find sibling parameter "${key}" on node "${nodeName}"`);
|
||||
|
||||
const returnValue = node.parameters[name];
|
||||
}
|
||||
returnValue = that.siblingParameters[key];
|
||||
} else {
|
||||
if (!node.parameters.hasOwnProperty(name)) {
|
||||
// Parameter does not exist on node
|
||||
throw new Error(`Could not find parameter "${name}" on node "${nodeName}"`);
|
||||
}
|
||||
|
||||
returnValue = node.parameters[name];
|
||||
}
|
||||
|
||||
if (typeof returnValue === 'string' && returnValue.charAt(0) === '=') {
|
||||
// The found value is an expression so resolve it
|
||||
@@ -361,7 +375,7 @@ export class WorkflowDataProxy {
|
||||
},
|
||||
$item: (itemIndex: number, runIndex?: number) => {
|
||||
const defaultReturnRunIndex = runIndex === undefined ? -1 : runIndex;
|
||||
const dataProxy = new WorkflowDataProxy(this.workflow, this.runExecutionData, this.runIndex, itemIndex, this.activeNodeName, this.connectionInputData, that.mode, defaultReturnRunIndex);
|
||||
const dataProxy = new WorkflowDataProxy(this.workflow, this.runExecutionData, this.runIndex, itemIndex, this.activeNodeName, this.connectionInputData, that.siblingParameters, that.mode, defaultReturnRunIndex);
|
||||
return dataProxy.getDataProxy();
|
||||
},
|
||||
$items: (nodeName?: string, outputIndex?: number, runIndex?: number) => {
|
||||
|
||||
Reference in New Issue
Block a user