mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
docs(editor): Nodes icons, Merge node descriptions (#8517)
Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com> Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
@@ -9,7 +9,7 @@ export class Merge extends VersionedNodeType {
|
||||
const baseDescription: INodeTypeBaseDescription = {
|
||||
displayName: 'Merge',
|
||||
name: 'merge',
|
||||
icon: 'fa:code-branch',
|
||||
icon: 'file:merge.svg',
|
||||
group: ['transform'],
|
||||
subtitle: '={{$parameter["mode"]}}',
|
||||
description: 'Merges data of multiple streams once data from both is available',
|
||||
@@ -20,7 +20,6 @@ export class Merge extends VersionedNodeType {
|
||||
1: new MergeV1(baseDescription),
|
||||
2: new MergeV2(baseDescription),
|
||||
2.1: new MergeV2(baseDescription),
|
||||
2.2: new MergeV2(baseDescription),
|
||||
};
|
||||
|
||||
super(nodeVersions, baseDescription);
|
||||
|
||||
10
packages/nodes-base/nodes/Merge/merge.svg
Normal file
10
packages/nodes-base/nodes/Merge/merge.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_1177_518)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 48C0 21.4903 21.4903 0 48 0H112C138.51 0 160 21.4903 160 48V56H196.252C240.435 56 276.252 91.8172 276.252 136V192C276.252 214.091 294.161 232 316.252 232H352V224C352 197.49 373.49 176 400 176H464C490.51 176 512 197.49 512 224V288C512 314.51 490.51 336 464 336H400C373.49 336 352 314.51 352 288V280H316.252C294.161 280 276.252 297.909 276.252 320V376C276.252 420.183 240.435 456 196.252 456H160V464C160 490.51 138.51 512 112 512H48C21.4903 512 0 490.51 0 464V400C0 373.49 21.4903 352 48 352H112C138.51 352 160 373.49 160 400V408H196.252C213.925 408 228.252 393.673 228.252 376V320C228.252 294.784 238.859 272.044 255.853 256C238.859 239.956 228.252 217.216 228.252 192V136C228.252 118.327 213.925 104 196.252 104H160V112C160 138.51 138.51 160 112 160H48C21.4903 160 0 138.51 0 112V48ZM104 48C108.418 48 112 51.5817 112 56V104C112 108.418 108.418 112 104 112H56C51.5817 112 48 108.418 48 104V56C48 51.5817 51.5817 48 56 48H104ZM456 224C460.418 224 464 227.582 464 232V280C464 284.418 460.418 288 456 288H408C403.582 288 400 284.418 400 280V232C400 227.582 403.582 224 408 224H456ZM112 408C112 403.582 108.418 400 104 400H56C51.5817 400 48 403.582 48 408V456C48 460.418 51.5817 464 56 464H104C108.418 464 112 460.418 112 456V408Z" fill="#54B8C9"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_1177_518">
|
||||
<rect width="512" height="512" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -31,7 +31,7 @@
|
||||
"id": "0cc8ce9e-6c16-4fc9-a1b4-589a33dca5e8",
|
||||
"name": "Merge",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 100]
|
||||
},
|
||||
{
|
||||
@@ -39,7 +39,7 @@
|
||||
"id": "5ba18ff2-a5b4-4515-a055-1c26fe7e5c02",
|
||||
"name": "Merge1",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 100]
|
||||
},
|
||||
{
|
||||
@@ -51,7 +51,7 @@
|
||||
"id": "cba07480-4ad6-4238-b786-61bacf7660f4",
|
||||
"name": "Merge3",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, -60]
|
||||
},
|
||||
{
|
||||
@@ -63,7 +63,7 @@
|
||||
"id": "6f6b87fa-2c63-46ab-9f50-d26a376fc4b4",
|
||||
"name": "Merge4",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, -60]
|
||||
},
|
||||
{
|
||||
@@ -83,7 +83,7 @@
|
||||
"id": "e4aef8cb-3733-43c5-a615-0d1e64393316",
|
||||
"name": "Merge2",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 280]
|
||||
},
|
||||
{
|
||||
@@ -93,7 +93,7 @@
|
||||
"id": "10c4f897-503b-4fdc-93c8-577bad12d8f0",
|
||||
"name": "Merge5",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 280]
|
||||
},
|
||||
{
|
||||
@@ -149,7 +149,7 @@
|
||||
"id": "aafbba65-a18d-43b8-8150-88c300992f1d",
|
||||
"name": "Merge6",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, -220]
|
||||
},
|
||||
{
|
||||
@@ -169,7 +169,7 @@
|
||||
"id": "9098d926-6006-4aed-ad5d-8128128ce6dc",
|
||||
"name": "Merge8",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, -220]
|
||||
},
|
||||
{
|
||||
@@ -181,7 +181,7 @@
|
||||
"id": "eeece670-291f-4c50-977a-6f3608e8b815",
|
||||
"name": "Merge9",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, -380]
|
||||
},
|
||||
{
|
||||
@@ -193,7 +193,7 @@
|
||||
"id": "c5ddf991-a05f-441d-9fdf-d4ba0db55894",
|
||||
"name": "Merge10",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, -380]
|
||||
},
|
||||
{
|
||||
@@ -204,7 +204,7 @@
|
||||
"id": "2bbdfe57-5541-4634-922b-230b03394ee7",
|
||||
"name": "Merge7",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 460]
|
||||
},
|
||||
{
|
||||
@@ -215,7 +215,7 @@
|
||||
"id": "fbf20a2d-4d08-4302-8289-c0149d5d804f",
|
||||
"name": "Merge11",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 460]
|
||||
},
|
||||
{
|
||||
@@ -223,7 +223,7 @@
|
||||
"id": "9729a369-5bc7-49c7-9156-1cef519c2744",
|
||||
"name": "Merge12",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 1200]
|
||||
},
|
||||
{
|
||||
@@ -231,7 +231,7 @@
|
||||
"id": "068c9d3c-f186-4b00-9d96-1de60ce7a92a",
|
||||
"name": "Merge13",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 1200]
|
||||
},
|
||||
{
|
||||
@@ -243,7 +243,7 @@
|
||||
"id": "6d2de385-9e01-416b-b9b9-948c1ba77e4f",
|
||||
"name": "Merge14",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 1040]
|
||||
},
|
||||
{
|
||||
@@ -255,7 +255,7 @@
|
||||
"id": "d4b34831-3757-42b7-93e0-53630a46b734",
|
||||
"name": "Merge15",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 1040]
|
||||
},
|
||||
{
|
||||
@@ -265,7 +265,7 @@
|
||||
"id": "c51a1ec8-d104-4803-9eb1-83630166c749",
|
||||
"name": "Merge16",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 1380]
|
||||
},
|
||||
{
|
||||
@@ -275,7 +275,7 @@
|
||||
"id": "af935dce-fc44-4075-b3c6-4629fe796f16",
|
||||
"name": "Merge17",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 1380]
|
||||
},
|
||||
{
|
||||
@@ -295,7 +295,7 @@
|
||||
"id": "bf586064-63aa-4f0e-9fad-c5e97fa23fb8",
|
||||
"name": "Merge18",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 880]
|
||||
},
|
||||
{
|
||||
@@ -315,7 +315,7 @@
|
||||
"id": "9908bca5-067a-4184-8333-2e48f74f34a1",
|
||||
"name": "Merge19",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 880]
|
||||
},
|
||||
{
|
||||
@@ -327,7 +327,7 @@
|
||||
"id": "5fcdc9b3-a0c6-424e-a325-d0e83e27e4f1",
|
||||
"name": "Merge20",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 720]
|
||||
},
|
||||
{
|
||||
@@ -339,7 +339,7 @@
|
||||
"id": "5a8d7598-e88b-4e81-ac57-5c3b6eadfe5a",
|
||||
"name": "Merge21",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 720]
|
||||
},
|
||||
{
|
||||
@@ -350,7 +350,7 @@
|
||||
"id": "32797fb4-ed6d-4127-823f-982c72d859a8",
|
||||
"name": "Merge22",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [820, 1560]
|
||||
},
|
||||
{
|
||||
@@ -361,7 +361,7 @@
|
||||
"id": "5299797d-2aa8-4f6b-a5d8-2a3c2bb0295d",
|
||||
"name": "Merge23",
|
||||
"type": "n8n-nodes-base.merge",
|
||||
"typeVersion": 2.2,
|
||||
"typeVersion": 2.1,
|
||||
"position": [1080, 1560]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -15,201 +15,192 @@ import { deepCopy } from 'n8n-workflow';
|
||||
import { oldVersionNotice } from '@utils/descriptions';
|
||||
import { generatePairedItemData } from '../../../utils/utilities';
|
||||
|
||||
const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Merge',
|
||||
name: 'merge',
|
||||
icon: 'fa:code-branch',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["mode"]}}',
|
||||
description: 'Merges data of multiple streams once data from both is available',
|
||||
defaults: {
|
||||
name: 'Merge',
|
||||
color: '#00bbcc',
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
||||
inputs: ['main', 'main'],
|
||||
outputs: ['main'],
|
||||
inputNames: ['Input 1', 'Input 2'],
|
||||
properties: [
|
||||
oldVersionNotice,
|
||||
{
|
||||
displayName: 'Mode',
|
||||
name: 'mode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Append',
|
||||
value: 'append',
|
||||
description:
|
||||
'Combines data of both inputs. The output will contain items of input 1 and input 2.',
|
||||
},
|
||||
{
|
||||
name: 'Keep Key Matches',
|
||||
value: 'keepKeyMatches',
|
||||
description: 'Keeps data of input 1 if it does find a match with data of input 2',
|
||||
},
|
||||
{
|
||||
name: 'Merge By Index',
|
||||
value: 'mergeByIndex',
|
||||
description:
|
||||
'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on the index of the items. So first item of input 1 will be merged with first item of input 2 and so on.',
|
||||
},
|
||||
{
|
||||
name: 'Merge By Key',
|
||||
value: 'mergeByKey',
|
||||
description:
|
||||
'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on a defined key.',
|
||||
},
|
||||
{
|
||||
name: 'Multiplex',
|
||||
value: 'multiplex',
|
||||
description:
|
||||
'Merges each value of one input with each value of the other input. The output will contain (m * n) items where (m) and (n) are lengths of the inputs.',
|
||||
},
|
||||
{
|
||||
name: 'Pass-Through',
|
||||
value: 'passThrough',
|
||||
description:
|
||||
'Passes through data of one input. The output will contain only items of the defined input.',
|
||||
},
|
||||
{
|
||||
name: 'Remove Key Matches',
|
||||
value: 'removeKeyMatches',
|
||||
description: 'Keeps data of input 1 if it does NOT find match with data of input 2',
|
||||
},
|
||||
{
|
||||
name: 'Wait',
|
||||
value: 'wait',
|
||||
description:
|
||||
'Waits till data of both inputs is available and will then output a single empty item. Source Nodes must connect to both Input 1 and 2. This node only supports 2 Sources, if you need more Sources, connect multiple Merge nodes in series. This node will not output any data.',
|
||||
},
|
||||
],
|
||||
default: 'append',
|
||||
description: 'How data of branches should be merged',
|
||||
},
|
||||
{
|
||||
displayName: 'Join',
|
||||
name: 'join',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['mergeByIndex'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Inner Join',
|
||||
value: 'inner',
|
||||
description:
|
||||
'Merges as many items as both inputs contain. (Example: Input1 = 5 items, Input2 = 3 items | Output will contain 3 items).',
|
||||
},
|
||||
{
|
||||
name: 'Left Join',
|
||||
value: 'left',
|
||||
description:
|
||||
'Merges as many items as first input contains. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 3 items).',
|
||||
},
|
||||
{
|
||||
name: 'Outer Join',
|
||||
value: 'outer',
|
||||
description:
|
||||
'Merges as many items as input contains with most items. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 5 items).',
|
||||
},
|
||||
],
|
||||
default: 'left',
|
||||
description:
|
||||
'How many items the output will contain if inputs contain different amount of items',
|
||||
},
|
||||
{
|
||||
displayName: 'Property Input 1',
|
||||
name: 'propertyName1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
hint: 'The name of the field as text (e.g. “id”)',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'],
|
||||
},
|
||||
},
|
||||
description: 'Name of property which decides which items to merge of input 1',
|
||||
},
|
||||
{
|
||||
displayName: 'Property Input 2',
|
||||
name: 'propertyName2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
hint: 'The name of the field as text (e.g. “id”)',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'],
|
||||
},
|
||||
},
|
||||
description: 'Name of property which decides which items to merge of input 2',
|
||||
},
|
||||
{
|
||||
displayName: 'Output Data',
|
||||
name: 'output',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['passThrough'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Input 1',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2',
|
||||
value: 'input2',
|
||||
},
|
||||
],
|
||||
default: 'input1',
|
||||
description: 'Defines of which input the data should be used as output of node',
|
||||
},
|
||||
{
|
||||
displayName: 'Overwrite',
|
||||
name: 'overwrite',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['mergeByKey'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Always',
|
||||
value: 'always',
|
||||
description: 'Always overwrites everything',
|
||||
},
|
||||
{
|
||||
name: 'If Blank',
|
||||
value: 'blank',
|
||||
description: 'Overwrites only values of "null", "undefined" or empty string',
|
||||
},
|
||||
{
|
||||
name: 'If Missing',
|
||||
value: 'undefined',
|
||||
description: 'Only adds values which do not exist yet',
|
||||
},
|
||||
],
|
||||
default: 'always',
|
||||
description: 'Select when to overwrite the values from Input1 with values from Input 2',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export class MergeV1 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
...versionDescription,
|
||||
icon: 'fa:code-branch',
|
||||
version: 1,
|
||||
defaults: {
|
||||
name: 'Merge',
|
||||
color: '#00bbcc',
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
||||
inputs: ['main', 'main'],
|
||||
outputs: ['main'],
|
||||
inputNames: ['Input 1', 'Input 2'],
|
||||
properties: [
|
||||
oldVersionNotice,
|
||||
{
|
||||
displayName: 'Mode',
|
||||
name: 'mode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Append',
|
||||
value: 'append',
|
||||
description:
|
||||
'Combines data of both inputs. The output will contain items of input 1 and input 2.',
|
||||
},
|
||||
{
|
||||
name: 'Keep Key Matches',
|
||||
value: 'keepKeyMatches',
|
||||
description: 'Keeps data of input 1 if it does find a match with data of input 2',
|
||||
},
|
||||
{
|
||||
name: 'Merge By Index',
|
||||
value: 'mergeByIndex',
|
||||
description:
|
||||
'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on the index of the items. So first item of input 1 will be merged with first item of input 2 and so on.',
|
||||
},
|
||||
{
|
||||
name: 'Merge By Key',
|
||||
value: 'mergeByKey',
|
||||
description:
|
||||
'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on a defined key.',
|
||||
},
|
||||
{
|
||||
name: 'Multiplex',
|
||||
value: 'multiplex',
|
||||
description:
|
||||
'Merges each value of one input with each value of the other input. The output will contain (m * n) items where (m) and (n) are lengths of the inputs.',
|
||||
},
|
||||
{
|
||||
name: 'Pass-Through',
|
||||
value: 'passThrough',
|
||||
description:
|
||||
'Passes through data of one input. The output will contain only items of the defined input.',
|
||||
},
|
||||
{
|
||||
name: 'Remove Key Matches',
|
||||
value: 'removeKeyMatches',
|
||||
description: 'Keeps data of input 1 if it does NOT find match with data of input 2',
|
||||
},
|
||||
{
|
||||
name: 'Wait',
|
||||
value: 'wait',
|
||||
description:
|
||||
'Waits till data of both inputs is available and will then output a single empty item. Source Nodes must connect to both Input 1 and 2. This node only supports 2 Sources, if you need more Sources, connect multiple Merge nodes in series. This node will not output any data.',
|
||||
},
|
||||
],
|
||||
default: 'append',
|
||||
description: 'How data of branches should be merged',
|
||||
},
|
||||
{
|
||||
displayName: 'Join',
|
||||
name: 'join',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['mergeByIndex'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Inner Join',
|
||||
value: 'inner',
|
||||
description:
|
||||
'Merges as many items as both inputs contain. (Example: Input1 = 5 items, Input2 = 3 items | Output will contain 3 items).',
|
||||
},
|
||||
{
|
||||
name: 'Left Join',
|
||||
value: 'left',
|
||||
description:
|
||||
'Merges as many items as first input contains. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 3 items).',
|
||||
},
|
||||
{
|
||||
name: 'Outer Join',
|
||||
value: 'outer',
|
||||
description:
|
||||
'Merges as many items as input contains with most items. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 5 items).',
|
||||
},
|
||||
],
|
||||
default: 'left',
|
||||
description:
|
||||
'How many items the output will contain if inputs contain different amount of items',
|
||||
},
|
||||
{
|
||||
displayName: 'Property Input 1',
|
||||
name: 'propertyName1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
hint: 'The name of the field as text (e.g. “id”)',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'],
|
||||
},
|
||||
},
|
||||
description: 'Name of property which decides which items to merge of input 1',
|
||||
},
|
||||
{
|
||||
displayName: 'Property Input 2',
|
||||
name: 'propertyName2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
hint: 'The name of the field as text (e.g. “id”)',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'],
|
||||
},
|
||||
},
|
||||
description: 'Name of property which decides which items to merge of input 2',
|
||||
},
|
||||
{
|
||||
displayName: 'Output Data',
|
||||
name: 'output',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['passThrough'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Input 1',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2',
|
||||
value: 'input2',
|
||||
},
|
||||
],
|
||||
default: 'input1',
|
||||
description: 'Defines of which input the data should be used as output of node',
|
||||
},
|
||||
{
|
||||
displayName: 'Overwrite',
|
||||
name: 'overwrite',
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['mergeByKey'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Always',
|
||||
value: 'always',
|
||||
description: 'Always overwrites everything',
|
||||
},
|
||||
{
|
||||
name: 'If Blank',
|
||||
value: 'blank',
|
||||
description: 'Overwrites only values of "null", "undefined" or empty string',
|
||||
},
|
||||
{
|
||||
name: 'If Missing',
|
||||
value: 'undefined',
|
||||
description: 'Only adds values which do not exist yet',
|
||||
},
|
||||
],
|
||||
default: 'always',
|
||||
description: 'Select when to overwrite the values from Input1 with values from Input 2',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -31,274 +31,264 @@ import {
|
||||
import { optionsDescription } from './OptionsDescription';
|
||||
import { preparePairedItemDataArray } from '@utils/utilities';
|
||||
|
||||
const versionDescription: INodeTypeDescription = {
|
||||
displayName: 'Merge',
|
||||
name: 'merge',
|
||||
icon: 'fa:code-branch',
|
||||
group: ['transform'],
|
||||
version: [2, 2.1, 2.2],
|
||||
subtitle: '={{$parameter["mode"]}}',
|
||||
description: 'Merge data of two inputs once data from both is available',
|
||||
defaults: {
|
||||
name: 'Merge',
|
||||
color: '#00bbcc',
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
||||
inputs: ['main', 'main'],
|
||||
outputs: ['main'],
|
||||
inputNames: ['Input 1', 'Input 2'],
|
||||
// If the node is of version 2.2 or if mode is chooseBranch data from both branches is required
|
||||
// to continue, else data from any input suffices
|
||||
requiredInputs: '={{ $parameter["mode"] === "chooseBranch" ? [0, 1] : 1 }}',
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Mode',
|
||||
name: 'mode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Append',
|
||||
value: 'append',
|
||||
description: 'All items of input 1, then all items of input 2',
|
||||
},
|
||||
{
|
||||
name: 'Combine',
|
||||
value: 'combine',
|
||||
description: 'Merge matching items together',
|
||||
},
|
||||
{
|
||||
name: 'Choose Branch',
|
||||
value: 'chooseBranch',
|
||||
description: 'Output input data, without modifying it',
|
||||
},
|
||||
],
|
||||
default: 'append',
|
||||
description: 'How data of branches should be merged',
|
||||
},
|
||||
{
|
||||
displayName: 'Combination Mode',
|
||||
name: 'combinationMode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Merge By Fields',
|
||||
value: 'mergeByFields',
|
||||
description: 'Combine items with the same field values',
|
||||
},
|
||||
{
|
||||
name: 'Merge By Position',
|
||||
value: 'mergeByPosition',
|
||||
description: 'Combine items based on their order',
|
||||
},
|
||||
{
|
||||
name: 'Multiplex',
|
||||
value: 'multiplex',
|
||||
description: 'All possible item combinations (cross join)',
|
||||
},
|
||||
],
|
||||
default: 'mergeByFields',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
},
|
||||
},
|
||||
},
|
||||
// mergeByFields ------------------------------------------------------------------
|
||||
{
|
||||
displayName: 'Fields to Match',
|
||||
name: 'mergeByFields',
|
||||
type: 'fixedCollection',
|
||||
placeholder: 'Add Fields to Match',
|
||||
default: { values: [{ field1: '', field2: '' }] },
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Values',
|
||||
name: 'values',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Input 1 Field',
|
||||
name: 'field1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'e.g. id',
|
||||
hint: ' Enter the field name as text',
|
||||
requiresDataPath: 'single',
|
||||
},
|
||||
{
|
||||
displayName: 'Input 2 Field',
|
||||
name: 'field2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'e.g. id',
|
||||
hint: ' Enter the field name as text',
|
||||
requiresDataPath: 'single',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Type',
|
||||
name: 'joinMode',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Keep Matches',
|
||||
value: 'keepMatches',
|
||||
description: 'Items that match, merged together (inner join)',
|
||||
},
|
||||
{
|
||||
name: 'Keep Non-Matches',
|
||||
value: 'keepNonMatches',
|
||||
description: "Items that don't match",
|
||||
},
|
||||
{
|
||||
name: 'Keep Everything',
|
||||
value: 'keepEverything',
|
||||
description: "Items that match merged together, plus items that don't match (outer join)",
|
||||
},
|
||||
{
|
||||
name: 'Enrich Input 1',
|
||||
value: 'enrichInput1',
|
||||
description: 'All of input 1, with data from input 2 added in (left join)',
|
||||
},
|
||||
{
|
||||
name: 'Enrich Input 2',
|
||||
value: 'enrichInput2',
|
||||
description: 'All of input 2, with data from input 1 added in (right join)',
|
||||
},
|
||||
],
|
||||
default: 'keepMatches',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Data From',
|
||||
name: 'outputDataFrom',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Both Inputs Merged Together',
|
||||
value: 'both',
|
||||
},
|
||||
{
|
||||
name: 'Input 1',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2',
|
||||
value: 'input2',
|
||||
},
|
||||
],
|
||||
default: 'both',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
joinMode: ['keepMatches'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Data From',
|
||||
name: 'outputDataFrom',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Both Inputs Appended Together',
|
||||
value: 'both',
|
||||
},
|
||||
{
|
||||
name: 'Input 1',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2',
|
||||
value: 'input2',
|
||||
},
|
||||
],
|
||||
default: 'both',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
joinMode: ['keepNonMatches'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// chooseBranch -----------------------------------------------------------------
|
||||
{
|
||||
displayName: 'Output Type',
|
||||
name: 'chooseBranchMode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Wait for Both Inputs to Arrive',
|
||||
value: 'waitForBoth',
|
||||
},
|
||||
],
|
||||
default: 'waitForBoth',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['chooseBranch'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output',
|
||||
name: 'output',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Input 1 Data',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2 Data',
|
||||
value: 'input2',
|
||||
},
|
||||
{
|
||||
name: 'A Single, Empty Item',
|
||||
value: 'empty',
|
||||
},
|
||||
],
|
||||
default: 'input1',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['chooseBranch'],
|
||||
chooseBranchMode: ['waitForBoth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
...optionsDescription,
|
||||
],
|
||||
};
|
||||
|
||||
export class MergeV2 implements INodeType {
|
||||
description: INodeTypeDescription;
|
||||
|
||||
constructor(baseDescription: INodeTypeBaseDescription) {
|
||||
this.description = {
|
||||
...baseDescription,
|
||||
...versionDescription,
|
||||
version: [2, 2.1],
|
||||
defaults: {
|
||||
name: 'Merge',
|
||||
},
|
||||
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
|
||||
inputs: ['main', 'main'],
|
||||
outputs: ['main'],
|
||||
inputNames: ['Input 1', 'Input 2'],
|
||||
// If mode is chooseBranch data from both branches is required
|
||||
// to continue, else data from any input suffices
|
||||
requiredInputs: '={{ $parameter["mode"] === "chooseBranch" ? [0, 1] : 1 }}',
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Mode',
|
||||
name: 'mode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Append',
|
||||
value: 'append',
|
||||
description: 'All items of input 1, then all items of input 2',
|
||||
},
|
||||
{
|
||||
name: 'Combine',
|
||||
value: 'combine',
|
||||
description: 'Merge matching items together',
|
||||
},
|
||||
{
|
||||
name: 'Choose Branch',
|
||||
value: 'chooseBranch',
|
||||
description: 'Output input data, without modifying it',
|
||||
},
|
||||
],
|
||||
default: 'append',
|
||||
description: 'How data of branches should be merged',
|
||||
},
|
||||
{
|
||||
displayName: 'Combination Mode',
|
||||
name: 'combinationMode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Merge By Fields',
|
||||
value: 'mergeByFields',
|
||||
description: 'Combine items with the same field values',
|
||||
},
|
||||
{
|
||||
name: 'Merge By Position',
|
||||
value: 'mergeByPosition',
|
||||
description: 'Combine items based on their order',
|
||||
},
|
||||
{
|
||||
name: 'Multiplex',
|
||||
value: 'multiplex',
|
||||
description: 'All possible item combinations (cross join)',
|
||||
},
|
||||
],
|
||||
default: 'mergeByFields',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
},
|
||||
},
|
||||
},
|
||||
// mergeByFields ------------------------------------------------------------------
|
||||
{
|
||||
displayName: 'Fields to Match',
|
||||
name: 'mergeByFields',
|
||||
type: 'fixedCollection',
|
||||
placeholder: 'Add Fields to Match',
|
||||
default: { values: [{ field1: '', field2: '' }] },
|
||||
typeOptions: {
|
||||
multipleValues: true,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Values',
|
||||
name: 'values',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Input 1 Field',
|
||||
name: 'field1',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'e.g. id',
|
||||
hint: ' Enter the field name as text',
|
||||
requiresDataPath: 'single',
|
||||
},
|
||||
{
|
||||
displayName: 'Input 2 Field',
|
||||
name: 'field2',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
|
||||
placeholder: 'e.g. id',
|
||||
hint: ' Enter the field name as text',
|
||||
requiresDataPath: 'single',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Type',
|
||||
name: 'joinMode',
|
||||
type: 'options',
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
|
||||
options: [
|
||||
{
|
||||
name: 'Keep Matches',
|
||||
value: 'keepMatches',
|
||||
description: 'Items that match, merged together (inner join)',
|
||||
},
|
||||
{
|
||||
name: 'Keep Non-Matches',
|
||||
value: 'keepNonMatches',
|
||||
description: "Items that don't match",
|
||||
},
|
||||
{
|
||||
name: 'Keep Everything',
|
||||
value: 'keepEverything',
|
||||
description:
|
||||
"Items that match merged together, plus items that don't match (outer join)",
|
||||
},
|
||||
{
|
||||
name: 'Enrich Input 1',
|
||||
value: 'enrichInput1',
|
||||
description: 'All of input 1, with data from input 2 added in (left join)',
|
||||
},
|
||||
{
|
||||
name: 'Enrich Input 2',
|
||||
value: 'enrichInput2',
|
||||
description: 'All of input 2, with data from input 1 added in (right join)',
|
||||
},
|
||||
],
|
||||
default: 'keepMatches',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Data From',
|
||||
name: 'outputDataFrom',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Both Inputs Merged Together',
|
||||
value: 'both',
|
||||
},
|
||||
{
|
||||
name: 'Input 1',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2',
|
||||
value: 'input2',
|
||||
},
|
||||
],
|
||||
default: 'both',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
joinMode: ['keepMatches'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output Data From',
|
||||
name: 'outputDataFrom',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Both Inputs Appended Together',
|
||||
value: 'both',
|
||||
},
|
||||
{
|
||||
name: 'Input 1',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2',
|
||||
value: 'input2',
|
||||
},
|
||||
],
|
||||
default: 'both',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['combine'],
|
||||
combinationMode: ['mergeByFields'],
|
||||
joinMode: ['keepNonMatches'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// chooseBranch -----------------------------------------------------------------
|
||||
{
|
||||
displayName: 'Output Type',
|
||||
name: 'chooseBranchMode',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Wait for Both Inputs to Arrive',
|
||||
value: 'waitForBoth',
|
||||
},
|
||||
],
|
||||
default: 'waitForBoth',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['chooseBranch'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Output',
|
||||
name: 'output',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Input 1 Data',
|
||||
value: 'input1',
|
||||
},
|
||||
{
|
||||
name: 'Input 2 Data',
|
||||
value: 'input2',
|
||||
},
|
||||
{
|
||||
name: 'A Single, Empty Item',
|
||||
value: 'empty',
|
||||
},
|
||||
],
|
||||
default: 'input1',
|
||||
displayOptions: {
|
||||
show: {
|
||||
mode: ['chooseBranch'],
|
||||
chooseBranchMode: ['waitForBoth'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
...optionsDescription,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user