Skip to content

Commit

Permalink
feat(Item Lists Node): Table tranformation
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency authored Jan 17, 2023
1 parent b7aa455 commit 5426690
Show file tree
Hide file tree
Showing 3 changed files with 601 additions and 5 deletions.
10 changes: 9 additions & 1 deletion packages/nodes-base/nodes/ItemLists/ItemLists.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@
"Map",
"Format",
"Nested",
"Iterate"
"Iterate",
"Summarise",
"Summarize",
"Group",
"Pivot",
"Sum",
"Count",
"Min",
"Max"
],
"subcategories": {
"Core Nodes": ["Helpers", "Data Transformation"]
Expand Down
19 changes: 15 additions & 4 deletions packages/nodes-base/nodes/ItemLists/ItemLists.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const shuffleArray = (array: any[]) => {
}
};

import * as summarize from './summarize.operation';

export class ItemLists implements INodeType {
description: INodeTypeDescription = {
displayName: 'Item Lists',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -765,6 +772,8 @@ return 0;`,
},
],
},
// Remove duplicates - Fields
...summarize.description,
],
};

Expand Down Expand Up @@ -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`);
}
Expand Down
Loading

0 comments on commit 5426690

Please sign in to comment.