refactor(core): Move copyInputItems to node helpers (no-changelog) (#7299)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-10-06 16:25:58 +02:00
committed by GitHub
parent 34bda535e6
commit 597669aa62
9 changed files with 84 additions and 95 deletions

View File

@@ -2709,6 +2709,24 @@ const getBinaryHelperFunctions = (
},
});
/**
* Returns a copy of the items which only contains the json data and
* of that only the defined properties
*/
export function copyInputItems(items: INodeExecutionData[], properties: string[]): IDataObject[] {
return items.map((item) => {
const newItem: IDataObject = {};
for (const property of properties) {
if (item.json[property] === undefined) {
newItem[property] = null;
} else {
newItem[property] = deepCopy(item.json[property]);
}
}
return newItem;
});
}
/**
* Returns the execute functions the poll nodes have access to.
*/
@@ -3239,6 +3257,7 @@ export function getExecuteFunctions(
},
helpers: {
createDeferredPromise,
copyInputItems,
...getRequestHelperFunctions(workflow, node, additionalData),
...getFileSystemHelperFunctions(node),
...getBinaryHelperFunctions(additionalData, workflow.id),