mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-08-04 19:08:36 +02:00
35 lines
987 B
TypeScript
35 lines
987 B
TypeScript
import type { INodeExecutionData, IRunData, NodeConnectionType } from 'n8n-workflow';
|
|
|
|
export function getIncomingData(
|
|
runData: IRunData,
|
|
nodeName: string,
|
|
runIndex: number,
|
|
connectionType: NodeConnectionType,
|
|
outputIndex: number,
|
|
): INodeExecutionData[] | null {
|
|
return runData[nodeName]?.at(runIndex)?.data?.[connectionType].at(outputIndex) ?? null;
|
|
}
|
|
|
|
function getRunIndexLength(runData: IRunData, nodeName: string) {
|
|
return runData[nodeName]?.length ?? 0;
|
|
}
|
|
|
|
export function getIncomingDataFromAnyRun(
|
|
runData: IRunData,
|
|
nodeName: string,
|
|
connectionType: NodeConnectionType,
|
|
outputIndex: number,
|
|
): { data: INodeExecutionData[]; runIndex: number } | undefined {
|
|
const maxRunIndexes = getRunIndexLength(runData, nodeName);
|
|
|
|
for (let runIndex = 0; runIndex < maxRunIndexes; runIndex++) {
|
|
const data = getIncomingData(runData, nodeName, runIndex, connectionType, outputIndex);
|
|
|
|
if (data && data.length > 0) {
|
|
return { data, runIndex };
|
|
}
|
|
}
|
|
|
|
return undefined;
|
|
}
|