mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(core)!: $(...).[last,first,all]() defaulting to the first output instead of the output that connects the nodes (#9760)
This commit is contained in:
@@ -619,18 +619,9 @@ export class WorkflowDataProxy {
|
||||
getDataProxy(): IWorkflowDataProxyData {
|
||||
const that = this;
|
||||
|
||||
const getNodeOutput = (nodeName?: string, branchIndex?: number, runIndex?: number) => {
|
||||
let executionData: INodeExecutionData[];
|
||||
|
||||
if (nodeName === undefined) {
|
||||
executionData = that.connectionInputData;
|
||||
} else {
|
||||
branchIndex = branchIndex || 0;
|
||||
runIndex = runIndex === undefined ? -1 : runIndex;
|
||||
executionData = that.getNodeExecutionData(nodeName, false, branchIndex, runIndex);
|
||||
}
|
||||
|
||||
return executionData;
|
||||
const getNodeOutput = (nodeName: string, branchIndex: number, runIndex?: number) => {
|
||||
runIndex = runIndex === undefined ? -1 : runIndex;
|
||||
return that.getNodeExecutionData(nodeName, false, branchIndex, runIndex);
|
||||
};
|
||||
|
||||
// replacing proxies with the actual data.
|
||||
@@ -1073,6 +1064,12 @@ export class WorkflowDataProxy {
|
||||
if (property === 'first') {
|
||||
ensureNodeExecutionData();
|
||||
return (branchIndex?: number, runIndex?: number) => {
|
||||
branchIndex =
|
||||
branchIndex ??
|
||||
// default to the output the active node is connected to
|
||||
that.workflow.getNodeConnectionIndexes(that.activeNodeName, nodeName)
|
||||
?.sourceIndex ??
|
||||
0;
|
||||
const executionData = getNodeOutput(nodeName, branchIndex, runIndex);
|
||||
if (executionData[0]) return executionData[0];
|
||||
return undefined;
|
||||
@@ -1081,6 +1078,12 @@ export class WorkflowDataProxy {
|
||||
if (property === 'last') {
|
||||
ensureNodeExecutionData();
|
||||
return (branchIndex?: number, runIndex?: number) => {
|
||||
branchIndex =
|
||||
branchIndex ??
|
||||
// default to the output the active node is connected to
|
||||
that.workflow.getNodeConnectionIndexes(that.activeNodeName, nodeName)
|
||||
?.sourceIndex ??
|
||||
0;
|
||||
const executionData = getNodeOutput(nodeName, branchIndex, runIndex);
|
||||
if (!executionData.length) return undefined;
|
||||
if (executionData[executionData.length - 1]) {
|
||||
@@ -1091,8 +1094,15 @@ export class WorkflowDataProxy {
|
||||
}
|
||||
if (property === 'all') {
|
||||
ensureNodeExecutionData();
|
||||
return (branchIndex?: number, runIndex?: number) =>
|
||||
getNodeOutput(nodeName, branchIndex, runIndex);
|
||||
return (branchIndex?: number, runIndex?: number) => {
|
||||
branchIndex =
|
||||
branchIndex ??
|
||||
// default to the output the active node is connected to
|
||||
that.workflow.getNodeConnectionIndexes(that.activeNodeName, nodeName)
|
||||
?.sourceIndex ??
|
||||
0;
|
||||
return getNodeOutput(nodeName, branchIndex, runIndex);
|
||||
};
|
||||
}
|
||||
if (property === 'context') {
|
||||
return that.nodeContextGetter(nodeName);
|
||||
|
||||
Reference in New Issue
Block a user