feat(Item Lists Node): Table tranformation

This commit is contained in:
Michael Kret
2023-01-17 18:40:28 +02:00
committed by GitHub
parent b7aa45536b
commit 5426690791
3 changed files with 601 additions and 5 deletions

View File

@@ -49,6 +49,8 @@ const shuffleArray = (array: any[]) => {
}
};
import * as summarize from './summarize.operation';
export class ItemLists implements INodeType {
description: INodeTypeDescription = {
displayName: 'Item Lists',
@@ -84,10 +86,10 @@ export class ItemLists implements INodeType {
noDataExpression: true,
options: [
{
name: 'Aggregate Items',
name: 'Concatenate Items',
value: 'aggregateItems',
description: 'Combine fields into a single new item',
action: 'Combine fields into a single new item',
description: 'Combine fields into a list in a single new item',
action: 'Combine fields into a list in a single new item',
},
{
name: 'Limit',
@@ -113,11 +115,16 @@ export class ItemLists implements INodeType {
description: 'Turn a list inside item(s) into separate items',
action: 'Turn a list inside item(s) into separate items',
},
{
name: 'Summarize',
value: 'summarize',
description: 'Aggregate items together (pivot table)',
action: 'Aggregate items together (pivot table)',
},
],
default: 'splitOutItems',
},
// Split out items - Fields
{
displayName: 'Field To Split Out',
name: 'fieldToSplitOut',
@@ -765,6 +772,8 @@ return 0;`,
},
],
},
// Remove duplicates - Fields
...summarize.description,
],
};
@@ -1388,6 +1397,8 @@ return 0;`,
newItems = items.slice(items.length - maxItems, items.length);
}
return this.prepareOutputData(newItems);
} else if (operation === 'summarize') {
return summarize.execute.call(this, items);
} else {
throw new NodeOperationError(this.getNode(), `Operation '${operation}' is not recognized`);
}