mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Add support for pairedItem (beta) (#3012)
* ✨ Add pairedItem support * 👕 Fix lint issue * 🐛 Fix resolution in frontend * 🐛 Fix resolution issue * 🐛 Fix resolution in frontend * 🐛 Fix another resolution issue in frontend * ⚡ Try to automatically add pairedItem data if possible * ⚡ Cleanup * ⚡ Display expression errors in editor UI * 🐛 Fix issue that it did not display errors in production * 🐛 Fix auto-fix of missing pairedItem data * 🐛 Fix frontend resolution for not executed nodes * ⚡ Fail execution on pairedItem resolve issue and display information about itemIndex and runIndex * ⚡ Allow that pairedItem is only set to number if runIndex is 0 * ✨ Improve Expression Errors * ⚡ Remove no longer needed code * ⚡ Make errors more helpful * ⚡ Add additional errors * 👕 Fix lint issue * ⚡ Add pairedItem support to core nodes * ⚡ Improve support in Merge-Node * ⚡ Fix issue with not correctly converted incoming pairedItem data * 🐛 Fix frontend resolve issue * 🐛 Fix frontend parameter name display issue * ⚡ Improve errors * 👕 Fix lint issue * ⚡ Improve errors * ⚡ Make it possible to display parameter name in error messages * ⚡ Improve error messages * ⚡ Fix error message * ⚡ Improve error messages * ⚡ Add another error message * ⚡ Simplify
This commit is contained in:
@@ -752,7 +752,12 @@ return 0;`,
|
||||
newItem = { ...newItem, [destinationFieldName as string || fieldToSplitOut as string]: element };
|
||||
}
|
||||
|
||||
returnData.push({ json: newItem });
|
||||
returnData.push({
|
||||
json: newItem,
|
||||
pairedItem: {
|
||||
item: i,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -790,8 +795,17 @@ return 0;`,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let newItem: INodeExecutionData;
|
||||
newItem = { json: {} };
|
||||
newItem = {
|
||||
json: {},
|
||||
pairedItem: Array.from({length}, (_, i) => i).map(index => {
|
||||
return {
|
||||
item: index,
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
// tslint:disable-next-line: no-any
|
||||
const values: { [key: string]: any } = {};
|
||||
const outputFields: string[] = [];
|
||||
@@ -899,9 +913,10 @@ return 0;`,
|
||||
}
|
||||
keys = fieldsToCompare.map(key => (key.trim()));
|
||||
}
|
||||
|
||||
// This solution is O(nlogn)
|
||||
// add original index to the items
|
||||
const newItems = items.map((item, index) => ({ json: { ...item['json'], __INDEX: index, }, } as INodeExecutionData));
|
||||
const newItems = items.map((item, index) => ({ json: { ...item['json'], __INDEX: index, }, pairedItem: { item: index, } } as INodeExecutionData));
|
||||
//sort items using the compare keys
|
||||
newItems.sort((a, b) => {
|
||||
let result = 0;
|
||||
@@ -962,7 +977,7 @@ return 0;`,
|
||||
let data = items.filter((_, index) => !removedIndexes.includes(index));
|
||||
|
||||
if (removeOtherFields) {
|
||||
data = data.map(item => ({ json: pick(item.json, ...keys) }));
|
||||
data = data.map((item, index) => ({ json: pick(item.json, ...keys), pairedItem: { item: index, } }));
|
||||
}
|
||||
|
||||
// return the filtered items
|
||||
|
||||
Reference in New Issue
Block a user