Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add paired item to the most used nodes #5220

Merged
merged 30 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f9c4d83
PairedItem for N8n training
agobrech Jan 11, 2023
ef2f9f3
Add paired item to ftp node
agobrech Jan 16, 2023
aee1279
Add paired item to rocketChat
agobrech Jan 17, 2023
f8bf943
Add pairedItem to pushOver
agobrech Jan 17, 2023
aed31e6
Add paired item to Matrix
agobrech Jan 17, 2023
37381d3
Add pairedItem to theHive
agobrech Jan 17, 2023
280fb4a
Add paired item to Snowflake
agobrech Jan 17, 2023
30b6365
Add paired item to PhilipsHue
agobrech Jan 17, 2023
181b588
Add pairedItem to supabase
agobrech Jan 17, 2023
e339193
Add paired item to Odoo
agobrech Jan 18, 2023
70d85f5
fix odoo & add paired item to grist
agobrech Jan 18, 2023
8a98f87
add pairedItem to Linkedin
agobrech Jan 18, 2023
63abc62
add pairedItem Zulip
agobrech Jan 18, 2023
c3ca93a
add pairedItem PhatomBuster
agobrech Jan 18, 2023
97e1c53
add pairedItem to TodoistV2
agobrech Jan 18, 2023
624c78a
Add pairedItem HomeAssistant
agobrech Jan 18, 2023
61a1460
Add pairedItem to DropContact
agobrech Jan 18, 2023
b23856e
Add pairedItem to Aws SES
agobrech Jan 18, 2023
c6f49a2
Add pairedItem to microsoftOutlook
agobrech Jan 18, 2023
7f3019b
Add pairedItem to AwsS3
agobrech Jan 18, 2023
886a0a4
Add pairedItem to Aws DynamoDB
agobrech Jan 18, 2023
25b2e45
🐛 fix Dropcontact enrich operation paired item support
maspio Jan 30, 2023
3521738
🐛 fix Dropcontact insert/update operation paired items
maspio Jan 30, 2023
75b5280
🐛 fix Supabase paired item support
maspio Jan 30, 2023
f183a4c
🐛 fix Supabase paired item support
maspio Jan 31, 2023
fd40ea7
🐛 fix N8nTrainingCustomerDatastore paired item support
maspio Jan 31, 2023
0b62db0
🎨 remove unused imports
maspio Jan 31, 2023
780588c
🐛 fix MicrosoftOutlook paired item support
maspio Jan 31, 2023
a323d0b
🐛 fix AwsS3 paired item support
maspio Jan 31, 2023
60f1b1b
Merge branch 'master' into node-88-add-paired-item-to-special-nodes
maspio Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class AwsDynamoDB implements INodeType {
const operation = this.getNodeParameter('operation', 0);

let responseData;
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];

for (let i = 0; i < items.length; i++) {
try {
Expand Down Expand Up @@ -391,21 +391,26 @@ export class AwsDynamoDB implements INodeType {
responseData = responseData.map(simplify);
}
}

Array.isArray(responseData)
? returnData.push(...responseData)
: returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}

throw error;
}
}

return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}
83 changes: 62 additions & 21 deletions packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type {
INodeExecutionData,
INodeType,
INodeTypeDescription,
JsonObject,
} from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';

Expand Down Expand Up @@ -84,7 +83,7 @@ export class AwsS3 implements INodeType {

async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const qs: IDataObject = {};
let responseData;
const resource = this.getNodeParameter('resource', 0);
Expand Down Expand Up @@ -150,8 +149,11 @@ export class AwsS3 implements INodeType {
qs,
headers,
);

returnData.push({ success: true });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ success: true }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}

// https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteBucket.html
Expand All @@ -167,7 +169,11 @@ export class AwsS3 implements INodeType {
{},
headers,
);
returnData.push({ success: true });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ success: true }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}

//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
Expand All @@ -194,7 +200,11 @@ export class AwsS3 implements INodeType {
);
responseData = responseData.slice(0, qs.limit);
}
returnData.push.apply(returnData, responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}

//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
Expand Down Expand Up @@ -263,11 +273,11 @@ export class AwsS3 implements INodeType {
);
responseData = responseData.ListBucketResult.Contents;
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData);
} else {
returnData.push(responseData);
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
if (resource === 'folder') {
Expand Down Expand Up @@ -306,7 +316,11 @@ export class AwsS3 implements INodeType {
{},
region,
);
returnData.push({ success: true });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ success: true }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
if (operation === 'delete') {
Expand Down Expand Up @@ -386,7 +400,11 @@ export class AwsS3 implements INodeType {

responseData = { deleted: responseData.DeleteResult.Deleted };
}
returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if (operation === 'getAll') {
Expand Down Expand Up @@ -446,7 +464,11 @@ export class AwsS3 implements INodeType {
if (qs.limit) {
responseData = responseData.splice(0, qs.limit as number);
}
returnData.push.apply(returnData, responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
}
Expand Down Expand Up @@ -554,7 +576,11 @@ export class AwsS3 implements INodeType {
{},
region,
);
returnData.push(responseData.CopyObjectResult);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData.CopyObjectResult),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
if (operation === 'download') {
Expand Down Expand Up @@ -647,8 +673,11 @@ export class AwsS3 implements INodeType {
{},
region,
);

returnData.push({ success: true });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ success: true }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
if (operation === 'getAll') {
Expand Down Expand Up @@ -710,7 +739,11 @@ export class AwsS3 implements INodeType {
if (qs.limit) {
responseData = responseData.splice(0, qs.limit as number);
}
returnData.push.apply(returnData, responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
Expand Down Expand Up @@ -863,12 +896,20 @@ export class AwsS3 implements INodeType {
region,
);
}
returnData.push({ success: true });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ success: true }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: (error as JsonObject).message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
Expand All @@ -878,7 +919,7 @@ export class AwsS3 implements INodeType {
// For file downloads the files get attached to the existing items
return this.prepareOutputData(items);
} else {
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}
}
23 changes: 12 additions & 11 deletions packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export class AwsSes implements INodeType {

async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
Expand Down Expand Up @@ -1281,23 +1281,24 @@ export class AwsSes implements INodeType {
responseData = responseData.UpdateTemplateResponse;
}
}

if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
if (responseData !== undefined) {
returnData.push(responseData as IDataObject);
}
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
}
}

return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}
50 changes: 41 additions & 9 deletions packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';

import { dropcontactApiRequest } from './GenericFunction';
import { dropcontactApiRequest, mapPairedItemsFrom } from './GenericFunction';

export class Dropcontact implements INodeType {
description: INodeTypeDescription = {
Expand Down Expand Up @@ -246,7 +246,7 @@ export class Dropcontact implements INodeType {
const operation = this.getNodeParameter('operation', 0);

let responseData: any;
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];

if (resource === 'contact') {
if (operation === 'enrich') {
Expand Down Expand Up @@ -278,7 +278,13 @@ export class Dropcontact implements INodeType {

if (!responseData.success) {
if (this.continueOnFail()) {
returnData.push({ error: responseData.reason || 'invalid request' });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: responseData.reason || 'invalid request' }),
{
itemData: mapPairedItemsFrom(entryData),
},
);
returnData.push(...executionData);
} else {
throw new NodeApiError(this.getNode(), {
error: responseData.reason || 'invalid request',
Expand All @@ -300,18 +306,36 @@ export class Dropcontact implements INodeType {
);
if (!responseData.success) {
if (this.continueOnFail()) {
responseData.push({ error: responseData.reason });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: responseData.reason }),
{
itemData: mapPairedItemsFrom(entryData),
},
);
returnData.push(...executionData);
} else {
throw new NodeApiError(this.getNode(), {
error: responseData.reason,
description: 'Hint: Increase the Wait Time to avoid this error',
});
}
} else {
returnData.push(...responseData.data);
responseData.data.forEach((d: IDataObject, index: number) => {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(d),
{ itemData: { item: index } },
);
returnData.push(...executionData);
});
}
} else {
returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{
itemData: mapPairedItemsFrom(entryData),
},
);
returnData.push(...executionData);
}
}

Expand All @@ -327,18 +351,26 @@ export class Dropcontact implements INodeType {
)) as { request_id: string; error: string; success: boolean };
if (!responseData.success) {
if (this.continueOnFail()) {
responseData.push({ error: responseData.reason || 'invalid request' });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: responseData.reason || 'invalid request' }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} else {
throw new NodeApiError(this.getNode(), {
error: responseData.reason || 'invalid request',
});
}
}
returnData.push(...responseData.data);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData.data),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
}

return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}
10 changes: 9 additions & 1 deletion packages/nodes-base/nodes/Dropcontact/GenericFunction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IExecuteFunctions, IHookFunctions } from 'n8n-core';

import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow';
import type { IDataObject, ILoadOptionsFunctions, IPairedItemData } from 'n8n-workflow';

import type { OptionsWithUri } from 'request';

Expand Down Expand Up @@ -32,3 +32,11 @@ export async function dropcontactApiRequest(

return this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options);
}

export function mapPairedItemsFrom<T>(iterable: Iterable<T> | ArrayLike<T>): IPairedItemData[] {
return Array.from(iterable, (_, i) => i).map((index) => {
return {
item: index,
};
});
}
Loading