Feature/paired item support (#3869)

* Add paired item helper and implement it in some nodes
This commit is contained in:
Omar Ajoue
2022-08-30 17:55:33 +02:00
committed by GitHub
parent 087d3f99f1
commit b2c674591c
150 changed files with 4027 additions and 1625 deletions

View File

@@ -59,6 +59,8 @@ import {
LoggerProxy as Logger,
IExecuteData,
OAuth2GrantType,
NodeExecutionWithMetadata,
IPairedItemData,
} from 'n8n-workflow';
import { Agent } from 'https';
@@ -1307,13 +1309,31 @@ export function returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExe
jsonData = [jsonData];
}
jsonData.forEach((data) => {
jsonData.forEach((data: IDataObject) => {
returnData.push({ json: data });
});
return returnData;
}
/**
* Takes generic input data and brings it into the new json, pairedItem format n8n uses.
* @export
* @param {(IPairedItemData)} itemData
* @param {(INodeExecutionData[])} inputData
* @returns {(NodeExecutionWithMetadata[])}
*/
export function constructExecutionMetaData(
inputData: INodeExecutionData[],
options: { itemData: IPairedItemData | IPairedItemData[] },
): NodeExecutionWithMetadata[] {
const { itemData } = options;
return inputData.map((data: INodeExecutionData) => {
const { json, ...rest } = data;
return { json, pairedItem: itemData, ...rest } as NodeExecutionWithMetadata;
});
}
/**
* Automatically put the objects under a 'json' key and don't error,
* if some objects contain json/binary keys and others don't, throws error 'Inconsistent item format'
@@ -2417,6 +2437,7 @@ export function getExecuteFunctions(
},
returnJsonArray,
normalizeItems,
constructExecutionMetaData,
},
};
})(workflow, runExecutionData, connectionInputData, inputData, node);