mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor: Remove executeSingle
(no-changelog) (#4853)
This commit is contained in:
parent
3db2707b8e
commit
9194d8bb0e
|
@ -109,9 +109,8 @@ export abstract class DirectoryLoader {
|
||||||
nodeVersion = tempNode.currentVersion;
|
nodeVersion = tempNode.currentVersion;
|
||||||
|
|
||||||
if (currentVersionNode.hasOwnProperty('executeSingle')) {
|
if (currentVersionNode.hasOwnProperty('executeSingle')) {
|
||||||
Logger.warn(
|
throw new Error(
|
||||||
`"executeSingle" will get deprecated soon. Please update the code of node "${this.packageName}.${nodeName}" to use "execute" instead!`,
|
`"executeSingle" has been removed. Please update the code of node "${this.packageName}.${nodeName}" to use "execute" instead!`,
|
||||||
{ filePath },
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||

|

|
||||||
|
|
||||||
# n8n-node-dev
|
# n8n-node-dev
|
||||||
|
|
||||||
Currently very simple and not very sophisticated CLI which makes it easier
|
Currently very simple and not very sophisticated CLI which makes it easier
|
||||||
to create credentials and nodes in TypeScript for n8n.
|
to create credentials and nodes in TypeScript for n8n.
|
||||||
|
@ -129,7 +129,6 @@ following methods defined which contains the actual logic:
|
||||||
Method get called when the workflow gets executed
|
Method get called when the workflow gets executed
|
||||||
|
|
||||||
- `execute`: Executed once no matter how many items
|
- `execute`: Executed once no matter how many items
|
||||||
- `executeSingle`: Executed once for every item
|
|
||||||
|
|
||||||
By default always `execute` should be used especially when creating a
|
By default always `execute` should be used especially when creating a
|
||||||
third-party integration. The reason for that is that it is way more flexible
|
third-party integration. The reason for that is that it is way more flexible
|
||||||
|
@ -158,7 +157,6 @@ Property overview
|
||||||
|
|
||||||
- **description** [required]: Describes the node like its name, properties, hooks, ... see `Node Type Description` bellow.
|
- **description** [required]: Describes the node like its name, properties, hooks, ... see `Node Type Description` bellow.
|
||||||
- **execute** [optional]: Method get called when the workflow gets executed (once).
|
- **execute** [optional]: Method get called when the workflow gets executed (once).
|
||||||
- **executeSingle** [optional]: Method get called when the workflow gets executed (once for every item).
|
|
||||||
- **hooks** [optional]: The hook methods.
|
- **hooks** [optional]: The hook methods.
|
||||||
- **methods** [optional]: Additional methods. Currently only "loadOptions" exists which allows loading options for parameters from external services
|
- **methods** [optional]: Additional methods. Currently only "loadOptions" exists which allows loading options for parameters from external services
|
||||||
- **trigger** [optional]: Method gets called once when the workflow gets activated.
|
- **trigger** [optional]: Method gets called once when the workflow gets activated.
|
||||||
|
|
|
@ -1228,7 +1228,6 @@ export interface INodeType {
|
||||||
execute?(
|
execute?(
|
||||||
this: IExecuteFunctions,
|
this: IExecuteFunctions,
|
||||||
): Promise<INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null>;
|
): Promise<INodeExecutionData[][] | NodeExecutionWithMetadata[][] | null>;
|
||||||
executeSingle?(this: IExecuteSingleFunctions): Promise<INodeExecutionData>;
|
|
||||||
poll?(this: IPollFunctions): Promise<INodeExecutionData[][] | null>;
|
poll?(this: IPollFunctions): Promise<INodeExecutionData[][] | null>;
|
||||||
trigger?(this: ITriggerFunctions): Promise<ITriggerResponse | undefined>;
|
trigger?(this: ITriggerFunctions): Promise<ITriggerResponse | undefined>;
|
||||||
webhook?(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
webhook?(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
||||||
|
|
|
@ -1181,17 +1181,13 @@ export class Workflow {
|
||||||
}
|
}
|
||||||
|
|
||||||
let connectionInputData: INodeExecutionData[] = [];
|
let connectionInputData: INodeExecutionData[] = [];
|
||||||
if (
|
if (nodeType.execute || (!nodeType.poll && !nodeType.trigger && !nodeType.webhook)) {
|
||||||
nodeType.execute ||
|
// Only stop if first input is empty for execute runs. For all others run anyways
|
||||||
nodeType.executeSingle ||
|
|
||||||
(!nodeType.poll && !nodeType.trigger && !nodeType.webhook)
|
|
||||||
) {
|
|
||||||
// Only stop if first input is empty for execute & executeSingle runs. For all others run anyways
|
|
||||||
// because then it is a trigger node. As they only pass data through and so the input-data
|
// because then it is a trigger node. As they only pass data through and so the input-data
|
||||||
// becomes output-data it has to be possible.
|
// becomes output-data it has to be possible.
|
||||||
|
|
||||||
if (inputData.hasOwnProperty('main') && inputData.main.length > 0) {
|
if (inputData.hasOwnProperty('main') && inputData.main.length > 0) {
|
||||||
// We always use the data of main input and the first input for executeSingle
|
// We always use the data of main input and the first input for execute
|
||||||
connectionInputData = inputData.main[0] as INodeExecutionData[];
|
connectionInputData = inputData.main[0] as INodeExecutionData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,35 +1222,7 @@ export class Workflow {
|
||||||
inputData = newInputData;
|
inputData = newInputData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeType.executeSingle) {
|
if (nodeType.execute) {
|
||||||
const returnPromises: Array<Promise<INodeExecutionData>> = [];
|
|
||||||
|
|
||||||
for (let itemIndex = 0; itemIndex < connectionInputData.length; itemIndex++) {
|
|
||||||
const thisArgs = nodeExecuteFunctions.getExecuteSingleFunctions(
|
|
||||||
this,
|
|
||||||
runExecutionData,
|
|
||||||
runIndex,
|
|
||||||
connectionInputData,
|
|
||||||
inputData,
|
|
||||||
node,
|
|
||||||
itemIndex,
|
|
||||||
additionalData,
|
|
||||||
executionData,
|
|
||||||
mode,
|
|
||||||
);
|
|
||||||
|
|
||||||
returnPromises.push(nodeType.executeSingle.call(thisArgs));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (returnPromises.length === 0) {
|
|
||||||
return { data: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
const promiseResults = await Promise.all(returnPromises);
|
|
||||||
if (promiseResults) {
|
|
||||||
return { data: [promiseResults] };
|
|
||||||
}
|
|
||||||
} else if (nodeType.execute) {
|
|
||||||
const thisArgs = nodeExecuteFunctions.getExecuteFunctions(
|
const thisArgs = nodeExecuteFunctions.getExecuteFunctions(
|
||||||
this,
|
this,
|
||||||
runExecutionData,
|
runExecutionData,
|
||||||
|
|
Loading…
Reference in a new issue