mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
🔀 Merge branch 'Remove-executeSingle' of https://github.com/MedAliMarz/n8n into MedAliMarz-Remove-executeSingle
This commit is contained in:
commit
e48f555f07
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
BINARY_ENCODING,
|
||||
IExecuteSingleFunctions,
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
|
@ -948,14 +948,21 @@ export class EditImage implements INodeType {
|
|||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const item = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName') as string;
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
item = items[itemIndex];
|
||||
|
||||
const options = this.getNodeParameter('options', {}) as IDataObject;
|
||||
|
||||
const operation = this.getNodeParameter('operation', itemIndex) as string;
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string;
|
||||
|
||||
const options = this.getNodeParameter('options', itemIndex,{}) as IDataObject;
|
||||
|
||||
const cleanupFunctions: Array<() => void> = [];
|
||||
|
||||
|
@ -1026,14 +1033,14 @@ export class EditImage implements INodeType {
|
|||
let operations: IDataObject[] = [];
|
||||
if (operation === 'multiStep') {
|
||||
// Operation parameters are already in the correct format
|
||||
const operationsData = this.getNodeParameter('operations', { operations: [] }) as IDataObject;
|
||||
const operationsData = this.getNodeParameter('operations', itemIndex ,{ operations: [] }) as IDataObject;
|
||||
operations = operationsData.operations as IDataObject[];
|
||||
} else {
|
||||
// Operation parameters have to first get collected
|
||||
const operationParameters: IDataObject = {};
|
||||
requiredOperationParameters[operation].forEach(parameterName => {
|
||||
try {
|
||||
operationParameters[parameterName] = this.getNodeParameter(parameterName);
|
||||
operationParameters[parameterName] = this.getNodeParameter(parameterName, itemIndex);
|
||||
} catch (e) {}
|
||||
});
|
||||
|
||||
|
@ -1062,7 +1069,7 @@ export class EditImage implements INodeType {
|
|||
if (operation === 'information') {
|
||||
// Just return the information
|
||||
const imageData = await new Promise<IDataObject>((resolve, reject) => {
|
||||
gmInstance = gmInstance.identify((error, imageData) => {
|
||||
gmInstance = gmInstance.identify((error:any, imageData:any) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
|
@ -1072,7 +1079,7 @@ export class EditImage implements INodeType {
|
|||
});
|
||||
|
||||
item.json = imageData;
|
||||
return item;
|
||||
returnData.push(item);
|
||||
}
|
||||
|
||||
for (let i = 0; i < operations.length; i++) {
|
||||
|
@ -1220,7 +1227,7 @@ export class EditImage implements INodeType {
|
|||
newItem.binary![dataPropertyName as string].fileName = options.fileName as string;
|
||||
}
|
||||
|
||||
return new Promise<INodeExecutionData>((resolve, reject) => {
|
||||
returnData.push(await (new Promise<INodeExecutionData>((resolve, reject) => {
|
||||
gmInstance
|
||||
.toBuffer((error: Error | null, buffer: Buffer) => {
|
||||
cleanupFunctions.forEach(async cleanup => await cleanup());
|
||||
|
@ -1233,6 +1240,9 @@ export class EditImage implements INodeType {
|
|||
|
||||
return resolve(newItem);
|
||||
});
|
||||
});
|
||||
})));
|
||||
|
||||
}
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
BINARY_ENCODING,
|
||||
IExecuteSingleFunctions,
|
||||
IExecuteFunctions
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
|
@ -124,18 +124,26 @@ export class EmailSend implements INodeType {
|
|||
};
|
||||
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const item = this.getInputData();
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const fromEmail = this.getNodeParameter('fromEmail') as string;
|
||||
const toEmail = this.getNodeParameter('toEmail') as string;
|
||||
const ccEmail = this.getNodeParameter('ccEmail') as string;
|
||||
const bccEmail = this.getNodeParameter('bccEmail') as string;
|
||||
const subject = this.getNodeParameter('subject') as string;
|
||||
const text = this.getNodeParameter('text') as string;
|
||||
const html = this.getNodeParameter('html') as string;
|
||||
const attachmentPropertyString = this.getNodeParameter('attachments') as string;
|
||||
const options = this.getNodeParameter('options', {}) as IDataObject;
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
|
||||
item = items[itemIndex];
|
||||
|
||||
const fromEmail = this.getNodeParameter('fromEmail', itemIndex) as string;
|
||||
const toEmail = this.getNodeParameter('toEmail', itemIndex) as string;
|
||||
const ccEmail = this.getNodeParameter('ccEmail', itemIndex) as string;
|
||||
const bccEmail = this.getNodeParameter('bccEmail', itemIndex) as string;
|
||||
const subject = this.getNodeParameter('subject', itemIndex) as string;
|
||||
const text = this.getNodeParameter('text', itemIndex) as string;
|
||||
const html = this.getNodeParameter('html', itemIndex) as string;
|
||||
const attachmentPropertyString = this.getNodeParameter('attachments', itemIndex) as string;
|
||||
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||
|
||||
const credentials = this.getCredentials('smtp');
|
||||
|
||||
|
@ -201,7 +209,10 @@ export class EmailSend implements INodeType {
|
|||
// Send the email
|
||||
const info = await transporter.sendMail(mailOptions);
|
||||
|
||||
return { json: info };
|
||||
returnData.push({ json: info });
|
||||
}
|
||||
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IExecuteSingleFunctions } from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IBinaryKeyData,
|
||||
IDataObject,
|
||||
|
@ -40,8 +40,16 @@ export class FunctionItem implements INodeType {
|
|||
],
|
||||
};
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
let item = this.getInputData();
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
|
||||
item = items[itemIndex];
|
||||
|
||||
// Copy the items as they may get changed in the functions
|
||||
item = JSON.parse(JSON.stringify(item));
|
||||
|
@ -61,7 +69,7 @@ export class FunctionItem implements INodeType {
|
|||
};
|
||||
|
||||
// Make it possible to access data via $node, $parameter, ...
|
||||
const dataProxy = this.getWorkflowDataProxy();
|
||||
const dataProxy = this.getWorkflowDataProxy(itemIndex);
|
||||
Object.assign(sandbox, dataProxy);
|
||||
|
||||
const options = {
|
||||
|
@ -84,7 +92,7 @@ export class FunctionItem implements INodeType {
|
|||
const vm = new NodeVM(options);
|
||||
|
||||
// Get the code to execute
|
||||
const functionCode = this.getNodeParameter('functionCode') as string;
|
||||
const functionCode = this.getNodeParameter('functionCode', itemIndex) as string;
|
||||
|
||||
|
||||
let jsonData: IDataObject;
|
||||
|
@ -108,6 +116,8 @@ export class FunctionItem implements INodeType {
|
|||
returnItem.binary = item.binary;
|
||||
}
|
||||
|
||||
return returnItem;
|
||||
returnData.push(returnItem);
|
||||
}
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
BINARY_ENCODING,
|
||||
IExecuteSingleFunctions,
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
|
@ -105,17 +105,24 @@ export class Mailgun implements INodeType {
|
|||
};
|
||||
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const item = this.getInputData();
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const fromEmail = this.getNodeParameter('fromEmail') as string;
|
||||
const toEmail = this.getNodeParameter('toEmail') as string;
|
||||
const ccEmail = this.getNodeParameter('ccEmail') as string;
|
||||
const bccEmail = this.getNodeParameter('bccEmail') as string;
|
||||
const subject = this.getNodeParameter('subject') as string;
|
||||
const text = this.getNodeParameter('text') as string;
|
||||
const html = this.getNodeParameter('html') as string;
|
||||
const attachmentPropertyString = this.getNodeParameter('attachments') as string;
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
item = items[itemIndex];
|
||||
|
||||
const fromEmail = this.getNodeParameter('fromEmail', itemIndex) as string;
|
||||
const toEmail = this.getNodeParameter('toEmail', itemIndex) as string;
|
||||
const ccEmail = this.getNodeParameter('ccEmail', itemIndex) as string;
|
||||
const bccEmail = this.getNodeParameter('bccEmail', itemIndex) as string;
|
||||
const subject = this.getNodeParameter('subject', itemIndex) as string;
|
||||
const text = this.getNodeParameter('text', itemIndex) as string;
|
||||
const html = this.getNodeParameter('html', itemIndex) as string;
|
||||
const attachmentPropertyString = this.getNodeParameter('attachments', itemIndex) as string;
|
||||
|
||||
const credentials = this.getCredentials('mailgunApi');
|
||||
|
||||
|
@ -177,8 +184,10 @@ export class Mailgun implements INodeType {
|
|||
|
||||
const responseData = await this.helpers.request(options);
|
||||
|
||||
return {
|
||||
returnData.push({
|
||||
json: responseData,
|
||||
};
|
||||
});
|
||||
}
|
||||
return this.prepareOutputData(returnData)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IExecuteSingleFunctions } from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
|
@ -49,11 +49,17 @@ export class ReadBinaryFile implements INodeType {
|
|||
};
|
||||
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const item = this.getInputData();
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName') as string;
|
||||
const filePath = this.getNodeParameter('filePath') as string;
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
item = items[itemIndex];
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string;
|
||||
const filePath = this.getNodeParameter('filePath', itemIndex) as string;
|
||||
|
||||
let data;
|
||||
try {
|
||||
|
@ -79,8 +85,10 @@ export class ReadBinaryFile implements INodeType {
|
|||
}
|
||||
|
||||
newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(data, filePath);
|
||||
returnData.push(newItem);
|
||||
}
|
||||
|
||||
return newItem;
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {
|
||||
BINARY_ENCODING,
|
||||
IExecuteSingleFunctions,
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
|
@ -37,22 +37,30 @@ export class ReadPdf implements INodeType {
|
|||
],
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName') as string;
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
|
||||
const item = this.getInputData();
|
||||
item = items[itemIndex];
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex) as string;
|
||||
|
||||
if (item.binary === undefined) {
|
||||
item.binary = {};
|
||||
}
|
||||
|
||||
const binaryData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
|
||||
|
||||
return {
|
||||
returnData.push({
|
||||
binary: item.binary,
|
||||
json: await pdf(binaryData),
|
||||
};
|
||||
});
|
||||
|
||||
}
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
BINARY_ENCODING,
|
||||
IExecuteSingleFunctions,
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
|
@ -53,11 +54,21 @@ export class WriteBinaryFile implements INodeType {
|
|||
};
|
||||
|
||||
|
||||
async executeSingle(this: IExecuteSingleFunctions): Promise<INodeExecutionData> {
|
||||
const item = this.getInputData();
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName') as string;
|
||||
const fileName = this.getNodeParameter('fileName') as string;
|
||||
const items = this.getInputData();
|
||||
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length as unknown as number;
|
||||
let item: INodeExecutionData;
|
||||
|
||||
for (let itemIndex = 0; itemIndex < length; itemIndex++) {
|
||||
|
||||
const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string;
|
||||
|
||||
const fileName = this.getNodeParameter('fileName', itemIndex) as string;
|
||||
|
||||
item = items[itemIndex];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new Error('No binary data set. So file can not be written!');
|
||||
|
@ -84,8 +95,12 @@ export class WriteBinaryFile implements INodeType {
|
|||
}
|
||||
|
||||
// Add the file name to data
|
||||
|
||||
(newItem.json as IDataObject).fileName = fileName;
|
||||
|
||||
return newItem;
|
||||
returnData.push(newItem);
|
||||
}
|
||||
return this.prepareOutputData(returnData);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue