mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +00:00
⚡ Add hook which gets called after a workflow execution
This commit is contained in:
@@ -64,6 +64,10 @@ class ExternalHooksClass implements IExternalHooksClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exists(hookName: string): boolean {
|
||||||
|
return !!this.externalHooks[hookName];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { get } from 'lodash';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ActiveExecutions,
|
ActiveExecutions,
|
||||||
|
ExternalHooks,
|
||||||
GenericHelpers,
|
GenericHelpers,
|
||||||
IExecutionDb,
|
IExecutionDb,
|
||||||
IResponseCallbackData,
|
IResponseCallbackData,
|
||||||
|
|||||||
@@ -406,6 +406,8 @@ export async function executeWorkflow(workflowInfo: IExecuteWorkflowInfo, additi
|
|||||||
const workflowExecute = new WorkflowExecute(additionalDataIntegrated, mode, runExecutionData);
|
const workflowExecute = new WorkflowExecute(additionalDataIntegrated, mode, runExecutionData);
|
||||||
const data = await workflowExecute.processRunExecutionData(workflow);
|
const data = await workflowExecute.processRunExecutionData(workflow);
|
||||||
|
|
||||||
|
await externalHooks.run('workflow.postExecute', [data, workflowData]);
|
||||||
|
|
||||||
if (data.finished === true) {
|
if (data.finished === true) {
|
||||||
// Workflow did finish successfully
|
// Workflow did finish successfully
|
||||||
const returnData = WorkflowHelpers.getDataLastExecutedNodeData(data);
|
const returnData = WorkflowHelpers.getDataLastExecutedNodeData(data);
|
||||||
|
|||||||
@@ -104,11 +104,25 @@ export class WorkflowRunner {
|
|||||||
await externalHooks.run('workflow.execute', [data.workflowData, data.executionMode]);
|
await externalHooks.run('workflow.execute', [data.workflowData, data.executionMode]);
|
||||||
|
|
||||||
const executionsProcess = config.get('executions.process') as string;
|
const executionsProcess = config.get('executions.process') as string;
|
||||||
|
|
||||||
|
let executionId: string;
|
||||||
if (executionsProcess === 'main') {
|
if (executionsProcess === 'main') {
|
||||||
return this.runMainProcess(data, loadStaticData);
|
executionId = await this.runMainProcess(data, loadStaticData);
|
||||||
|
} else {
|
||||||
|
executionId = await this.runSubprocess(data, loadStaticData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.runSubprocess(data, loadStaticData);
|
if (externalHooks.exists('workflow.postExecute')) {
|
||||||
|
this.activeExecutions.getPostExecutePromise(executionId)
|
||||||
|
.then(async (executionData) => {
|
||||||
|
await externalHooks.run('workflow.postExecute', [executionData, data.workflowData]);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem running hook "workflow.postExecute"', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return executionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user