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

* PairedItem for N8n training

* Add paired item to ftp node

* Add paired item to rocketChat

* Add pairedItem to pushOver

* Add paired item to Matrix

* Add pairedItem to theHive

* Add paired item to Snowflake

* Add paired item to PhilipsHue

* Add pairedItem to supabase

* Add paired item to Odoo

* fix odoo & add paired item to grist

* add pairedItem to Linkedin

* add pairedItem Zulip

* add pairedItem PhatomBuster

* add pairedItem to TodoistV2

* Add pairedItem HomeAssistant

* Add pairedItem to DropContact

* Add pairedItem to Aws SES

* Add pairedItem to microsoftOutlook

* Add pairedItem to AwsS3

* Add pairedItem to Aws DynamoDB

* 🐛 fix Dropcontact enrich operation paired item support

* 🐛 fix Dropcontact insert/update operation paired items

* 🐛 fix Supabase paired item support

* 🐛 fix Supabase paired item support

* 🐛 fix N8nTrainingCustomerDatastore paired item support

* 🎨 remove unused imports

* 🐛 fix MicrosoftOutlook paired item support

* 🐛 fix AwsS3 paired item support

---------

Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
agobrech 2023-01-31 20:39:20 +01:00 committed by GitHub
parent d87ff130a4
commit 409a9ea357
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 661 additions and 253 deletions

View file

@ -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 {
@ -391,14 +391,19 @@ 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;
}
@ -406,6 +411,6 @@ export class AwsDynamoDB implements INodeType {
}
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -12,7 +12,6 @@ import type {
INodeExecutionData,
INodeType,
INodeTypeDescription,
JsonObject,
} from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';
@ -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);
@ -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
@ -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
@ -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
@ -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') {
@ -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') {
@ -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') {
@ -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);
}
}
}
@ -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') {
@ -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') {
@ -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
@ -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;
@ -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);
}
}
}

View file

@ -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);
@ -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);
}
}

View file

@ -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 = {
@ -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') {
@ -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',
@ -300,7 +306,13 @@ 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,
@ -308,10 +320,22 @@ export class Dropcontact implements INodeType {
});
}
} 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);
}
}
@ -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);
}
}

View file

@ -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';
@ -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,
};
});
}

View file

@ -543,17 +543,19 @@ export class Ftp implements INodeType {
if (recursive) {
responseData = await callRecursiveList(path, sftp!, normalizeSFtpItem);
returnItems.push.apply(
returnItems,
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
{ itemData: { item: i } },
);
returnItems.push.apply(returnItems, executionData);
} else {
responseData = await sftp!.list(path);
responseData.forEach((item) => normalizeSFtpItem(item, path));
returnItems.push.apply(
returnItems,
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
{ itemData: { item: i } },
);
returnItems.push.apply(returnItems, executionData);
}
}
@ -566,8 +568,11 @@ export class Ftp implements INodeType {
} else {
responseData = await sftp!.delete(path);
}
returnItems.push({ json: { success: true } });
const executionData = this.helpers.constructExecutionMetaData(
[{ json: { success: true } }],
{ itemData: { item: i } },
);
returnItems.push(...executionData);
}
if (operation === 'rename') {
@ -582,8 +587,11 @@ export class Ftp implements INodeType {
}
responseData = await sftp!.rename(oldPath, newPath);
returnItems.push({ json: { success: true } });
const executionData = this.helpers.constructExecutionMetaData(
[{ json: { success: true } }],
{ itemData: { item: i } },
);
returnItems.push(...executionData);
}
if (operation === 'download') {
@ -600,7 +608,11 @@ export class Ftp implements INodeType {
filePathDownload,
);
returnItems.push(items[i]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(items[i]),
{ itemData: { item: i } },
);
returnItems.push(...executionData);
} finally {
await binaryFile.cleanup();
}
@ -643,7 +655,11 @@ export class Ftp implements INodeType {
await sftp!.put(buffer, remotePath);
}
returnItems.push(items[i]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(items[i]),
{ itemData: { item: i } },
);
returnItems.push(...executionData);
}
}
@ -655,19 +671,21 @@ export class Ftp implements INodeType {
if (recursive) {
responseData = await callRecursiveList(path, ftp!, normalizeFtpItem);
returnItems.push.apply(
returnItems,
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
{ itemData: { item: i } },
);
returnItems.push.apply(returnItems, executionData);
} else {
responseData = await ftp!.list(path);
responseData.forEach((item) =>
normalizeFtpItem(item as ftpClient.ListingElement, path),
);
returnItems.push.apply(
returnItems,
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as unknown as IDataObject[]),
{ itemData: { item: i } },
);
returnItems.push.apply(returnItems, executionData);
}
}
@ -680,8 +698,11 @@ export class Ftp implements INodeType {
} else {
responseData = await ftp!.delete(path);
}
returnItems.push({ json: { success: true } });
const executionData = this.helpers.constructExecutionMetaData(
[{ json: { success: true } }],
{ itemData: { item: i } },
);
returnItems.push(...executionData);
}
if (operation === 'download') {
@ -699,7 +720,11 @@ export class Ftp implements INodeType {
filePathDownload,
);
returnItems.push(items[i]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(items[i]),
{ itemData: { item: i } },
);
returnItems.push(...executionData);
} finally {
await binaryFile.cleanup();
}
@ -711,8 +736,11 @@ export class Ftp implements INodeType {
const newPath = this.getNodeParameter('newPath', i) as string;
responseData = await ftp!.rename(oldPath, newPath);
returnItems.push({ json: { success: true } });
const executionData = this.helpers.constructExecutionMetaData(
[{ json: { success: true } }],
{ itemData: { item: i } },
);
returnItems.push(...executionData);
}
if (operation === 'upload') {
@ -773,7 +801,11 @@ export class Ftp implements INodeType {
}
}
}
returnItems.push(items[i]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(items[i]),
{ itemData: { item: i } },
);
returnItems.push(...executionData);
}
}
}

View file

@ -116,7 +116,7 @@ export class Grist implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
let responseData;
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const operation = this.getNodeParameter('operation', 0);
@ -247,17 +247,23 @@ export class Grist implements INodeType {
}
} 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;
}
Array.isArray(responseData)
? returnData.push(...responseData)
: returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -180,7 +180,7 @@ export class HomeAssistant implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
@ -442,22 +442,27 @@ export class HomeAssistant implements INodeType {
if (resource === 'cameraProxy' && operation === 'get') {
items[i].json = { error: error.message };
} else {
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;
}
Array.isArray(responseData)
? returnData.push(...responseData)
: returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
if (resource === 'cameraProxy' && operation === 'getScreenshot') {
return this.prepareOutputData(items);
} else {
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}
}

View file

@ -1,6 +1,5 @@
import type { IExecuteFunctions } from 'n8n-core';
import type {
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
@ -70,7 +69,7 @@ export class LinkedIn 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);
@ -256,21 +255,24 @@ export class LinkedIn implements INodeType {
responseData = await linkedInApiRequest.call(this, 'POST', endpoint, body);
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
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);
}
}

View file

@ -138,27 +138,30 @@ export class Matrix implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData() as IDataObject[];
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < items.length; i++) {
try {
const responseData = await handleMatrixCall.call(this, items[i], i, resource, operation);
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
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);
}
}

View file

@ -131,7 +131,7 @@ export class MicrosoftOutlook implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
@ -145,11 +145,18 @@ export class MicrosoftOutlook implements INodeType {
try {
const messageId = this.getNodeParameter('messageId', i) as string;
responseData = await microsoftApiRequest.call(this, 'DELETE', `/messages/${messageId}`);
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.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
@ -182,17 +189,29 @@ export class MicrosoftOutlook implements INodeType {
if (additionalFields.dataPropertyAttachmentsPrefixName) {
const prefix = additionalFields.dataPropertyAttachmentsPrefixName as string;
const data = await downloadAttachments.call(this, responseData, prefix);
returnData.push.apply(returnData, data as unknown as IDataObject[]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(data),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} else {
returnData.push(responseData);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
if (additionalFields.dataPropertyAttachmentsPrefixName) {
return [returnData as INodeExecutionData[]];
return [returnData];
}
} 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;
@ -217,10 +236,18 @@ export class MicrosoftOutlook implements INodeType {
body,
{},
);
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;
@ -256,10 +283,18 @@ export class MicrosoftOutlook implements INodeType {
responseData = await microsoftApiRequest.call(this, 'POST', '/messages', body, {});
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;
@ -289,11 +324,18 @@ export class MicrosoftOutlook implements INodeType {
'POST',
`/messages/${messageId}/send`,
);
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.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
@ -354,10 +396,18 @@ export class MicrosoftOutlook implements INodeType {
await microsoftApiRequest.call(this, 'POST', `/messages/${responseData.id}/send`);
}
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;
@ -452,13 +502,25 @@ export class MicrosoftOutlook implements INodeType {
if (additionalFields.dataPropertyAttachmentsPrefixName) {
const prefix = additionalFields.dataPropertyAttachmentsPrefixName as string;
const data = await downloadAttachments.call(this, responseData, prefix);
returnData.push.apply(returnData, data as unknown as IDataObject[]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(data),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} else {
returnData.push.apply(returnData, 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;
@ -466,7 +528,7 @@ export class MicrosoftOutlook implements INodeType {
}
if (additionalFields.dataPropertyAttachmentsPrefixName) {
return [returnData as INodeExecutionData[]];
return [returnData];
}
}
@ -485,10 +547,18 @@ export class MicrosoftOutlook implements INodeType {
`/messages/${messageId}/move`,
body,
);
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.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
@ -536,10 +606,18 @@ export class MicrosoftOutlook implements INodeType {
};
responseData = await microsoftApiRequest.call(this, 'POST', '/sendMail', body, {});
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.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
@ -647,10 +725,18 @@ export class MicrosoftOutlook implements INodeType {
{},
);
}
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.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
@ -740,10 +826,18 @@ export class MicrosoftOutlook implements INodeType {
undefined,
qs,
);
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;
@ -783,10 +877,18 @@ export class MicrosoftOutlook implements INodeType {
responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs);
responseData = responseData.value;
}
returnData.push.apply(returnData, 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;
@ -821,10 +923,18 @@ export class MicrosoftOutlook implements INodeType {
}
responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body);
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;
@ -841,10 +951,18 @@ export class MicrosoftOutlook implements INodeType {
'DELETE',
`/mailFolders/${folderId}`,
);
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.message });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
@ -872,10 +990,18 @@ export class MicrosoftOutlook implements INodeType {
{},
qs,
);
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;
@ -911,10 +1037,18 @@ export class MicrosoftOutlook implements INodeType {
responseData = await microsoftApiRequest.call(this, 'GET', '/mailFolders', {}, qs);
responseData = responseData.value;
}
returnData.push.apply(returnData, 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;
@ -956,10 +1090,18 @@ export class MicrosoftOutlook implements INodeType {
);
responseData = responseData.value;
}
returnData.push.apply(returnData, 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;
@ -983,10 +1125,18 @@ export class MicrosoftOutlook implements INodeType {
`/mailFolders/${folderId}`,
body,
);
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;
@ -1025,11 +1175,19 @@ export class MicrosoftOutlook implements INodeType {
responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs);
responseData = responseData.value;
}
returnData.push.apply(returnData, 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;
@ -1043,7 +1201,7 @@ export class MicrosoftOutlook implements INodeType {
) {
return this.prepareOutputData(items);
} else {
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}
}

View file

@ -1,11 +1,6 @@
import type { IExecuteFunctions } from 'n8n-core';
import type {
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import type { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
const data = [
{
@ -116,7 +111,7 @@ export class N8nTrainingCustomerDatastore implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const operation = this.getNodeParameter('operation', 0);
let responseData;
@ -138,11 +133,15 @@ export class N8nTrainingCustomerDatastore implements INodeType {
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push.apply(returnData, executionData);
} else if (responseData !== undefined) {
returnData.push(responseData as IDataObject);
returnData.push({ json: responseData });
}
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -1,11 +1,6 @@
import type { IExecuteFunctions } from 'n8n-core';
import type {
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import type { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
export class N8nTrainingCustomerMessenger implements INodeType {
description: INodeTypeDescription = {
@ -43,7 +38,7 @@ export class N8nTrainingCustomerMessenger implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
let responseData;
@ -53,9 +48,13 @@ export class N8nTrainingCustomerMessenger implements INodeType {
const message = this.getNodeParameter('message', i) as string;
responseData = { output: `Sent message to customer ${customerId}: ${message}` };
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(responseData);
returnData.push(...executionData);
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -11,7 +11,6 @@ import type {
INodePropertyOptions,
INodeType,
INodeTypeDescription,
JsonObject,
} from 'n8n-workflow';
import { deepCopy } from 'n8n-workflow';
@ -298,7 +297,7 @@ export class Odoo implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
let items = this.getInputData();
items = deepCopy(items);
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
let responseData;
const resource = this.getNodeParameter('resource', 0);
@ -745,21 +744,27 @@ export class Odoo implements INodeType {
);
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData);
} else if (responseData !== undefined) {
returnData.push(responseData);
if (responseData !== undefined) {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ 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;
}
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -102,7 +102,7 @@ export class Phantombuster implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
@ -247,20 +247,23 @@ export class Phantombuster implements INodeType {
}
}
}
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);
}
}

View file

@ -1,7 +1,6 @@
import type { IExecuteFunctions } from 'n8n-core';
import type {
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
@ -88,7 +87,7 @@ export class PhilipsHue implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
let responseData;
const resource = this.getNodeParameter('resource', 0);
@ -176,12 +175,12 @@ export class PhilipsHue implements INodeType {
);
}
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else if (responseData !== undefined) {
returnData.push(responseData as IDataObject);
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -298,7 +298,7 @@ export class Pushover implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
let responseData;
const resource = this.getNodeParameter('resource', 0);
@ -372,21 +372,25 @@ export class Pushover implements INodeType {
}
responseData = await pushoverApiRequest.call(this, 'POST', '/messages.json', body);
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;
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else if (responseData !== undefined) {
returnData.push(responseData as IDataObject);
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -372,7 +372,7 @@ export class Rocketchat implements INodeType {
const items = this.getInputData();
const length = items.length;
let responseData;
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
@ -478,20 +478,24 @@ export class Rocketchat implements INodeType {
);
}
}
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);
}
}

View file

@ -160,7 +160,7 @@ export class Snowflake implements INodeType {
const credentials = (await this.getCredentials(
'snowflake',
)) as unknown as snowflake.ConnectionOptions;
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
let responseData;
const connection = snowflake.createConnection(credentials);
@ -178,7 +178,11 @@ export class Snowflake implements INodeType {
for (let i = 0; i < items.length; i++) {
const query = this.getNodeParameter('query', i) as string;
responseData = await execute(connection, query, []);
returnData.push.apply(returnData, responseData as IDataObject[]);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
@ -196,7 +200,13 @@ export class Snowflake implements INodeType {
const data = copyInputItems(items, columns);
const binds = data.map((element) => Object.values(element));
await execute(connection, query, binds as unknown as snowflake.InsertBinds);
returnData.push.apply(returnData, data);
data.forEach((d, i) => {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(d),
{ itemData: { item: i } },
);
returnData.push(...executionData);
});
}
if (operation === 'update') {
@ -221,11 +231,16 @@ export class Snowflake implements INodeType {
for (let i = 0; i < binds.length; i++) {
await execute(connection, query, binds[i] as unknown as snowflake.InsertBinds);
}
returnData.push.apply(returnData, data);
data.forEach((d, i) => {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(d),
{ itemData: { item: i } },
);
returnData.push(...executionData);
});
}
await destroy(connection);
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -13,6 +13,7 @@ import type {
ICredentialTestFunctions,
IDataObject,
INodeProperties,
IPairedItemData,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
@ -322,3 +323,11 @@ export async function validateCredentials(
return this.helpers.request(options);
}
export function mapPairedItemsFrom<T>(iterable: Iterable<T> | ArrayLike<T>): IPairedItemData[] {
return Array.from(iterable, (_, i) => i).map((index) => {
return {
item: index,
};
});
}

View file

@ -18,6 +18,7 @@ import {
buildGetQuery,
buildOrQuery,
buildQuery,
mapPairedItemsFrom,
supabaseApiRequest,
validateCredentials,
} from './GenericFunctions';
@ -121,7 +122,7 @@ export class Supabase implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
const resource = this.getNodeParameter('resource', 0);
@ -155,14 +156,28 @@ export class Supabase implements INodeType {
records.push(record);
}
const endpoint = `/${tableId}`;
let createdRow;
try {
createdRow = await supabaseApiRequest.call(this, 'POST', endpoint, records);
returnData.push(...createdRow);
const createdRows: IDataObject[] = await supabaseApiRequest.call(
this,
'POST',
endpoint,
records,
);
createdRows.forEach((row, i) => {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(row),
{ itemData: { item: i } },
);
returnData.push(...executionData);
});
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.description });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.description }),
{ itemData: mapPairedItemsFrom(records) },
);
returnData.push(...executionData);
} else {
throw error;
}
@ -207,11 +222,21 @@ export class Supabase implements INodeType {
rows = await supabaseApiRequest.call(this, 'DELETE', endpoint, {}, qs);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.description });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.description }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
}
returnData.push(...rows);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(rows),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
@ -237,11 +262,21 @@ export class Supabase implements INodeType {
rows = await supabaseApiRequest.call(this, 'GET', endpoint, {}, qs);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.description });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.message }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
}
returnData.push(...rows);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(rows),
{ itemData: { item: i } },
);
returnData.push(...executionData);
}
}
@ -280,13 +315,23 @@ export class Supabase implements INodeType {
try {
rows = await supabaseApiRequest.call(this, 'GET', endpoint, {}, qs);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(rows),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.description });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.description }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
}
returnData.push(...rows);
}
}
@ -346,16 +391,25 @@ export class Supabase implements INodeType {
try {
updatedRow = await supabaseApiRequest.call(this, 'PATCH', endpoint, record, qs);
returnData.push(...updatedRow);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(updatedRow),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.description });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ error: error.description }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
continue;
}
throw error;
}
}
}
}
return [this.helpers.returnJsonArray(returnData)];
return this.prepareOutputData(returnData);
}
}

View file

@ -313,7 +313,7 @@ export class TheHive implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
@ -1954,19 +1954,23 @@ export class TheHive implements INodeType {
}
}
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);
}
}

View file

@ -697,7 +697,7 @@ export class TodoistV2 implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
const service = new TodoistService();
let responseData;
@ -712,23 +712,40 @@ export class TodoistV2 implements INodeType {
i,
);
}
if (Array.isArray(responseData?.data)) {
returnData.push.apply(returnData, responseData?.data as IDataObject[]);
if (responseData !== undefined && Array.isArray(responseData?.data)) {
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData.data as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} else {
if (responseData?.hasOwnProperty('success')) {
returnData.push({ success: responseData.success });
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray({ success: responseData.success }),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} else {
returnData.push(responseData?.data as IDataObject);
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData?.data as IDataObject),
{ 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);
}
}

View file

@ -126,7 +126,7 @@ export class Zulip implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const returnData: INodeExecutionData[] = [];
const length = items.length;
let responseData;
const resource = this.getNodeParameter('resource', 0);
@ -464,20 +464,23 @@ export class Zulip implements INodeType {
responseData = await zulipApiRequest.call(this, 'DELETE', `/users/${userId}`, body);
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
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);
}
}