Add ExecuteWorkflow-Node

This commit is contained in:
Jan Oberhauser
2019-12-19 16:07:55 -06:00
parent 403c52ddf8
commit 8acc3c5931
15 changed files with 525 additions and 197 deletions

View File

@@ -1,6 +1,5 @@
import {
IProcessMessageDataHook,
IWorkflowExecutionDataProcessWithExecution,
NodeTypes,
WorkflowExecuteAdditionalData,
@@ -18,10 +17,9 @@ import {
INodeTypeData,
IRun,
ITaskData,
IWorkflowExecuteHooks,
Workflow,
WorkflowHooks,
} from 'n8n-workflow';
import { ChildProcess } from 'child_process';
export class WorkflowRunnerProcess {
data: IWorkflowExecutionDataProcessWithExecution | undefined;
@@ -61,10 +59,9 @@ export class WorkflowRunnerProcess {
await nodeTypes.init(nodeTypesData);
this.workflow = new Workflow(this.data.workflowData.id as string | undefined, this.data.workflowData!.nodes, this.data.workflowData!.connections, this.data.workflowData!.active, nodeTypes, this.data.workflowData!.staticData);
const additionalData = await WorkflowExecuteAdditionalData.getBase(this.data.executionMode, this.data.credentials);
const additionalData = await WorkflowExecuteAdditionalData.getBase(this.data.credentials);
additionalData.hooks = this.getProcessForwardHooks();
if (this.data.executionData !== undefined) {
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode, this.data.executionData);
return this.workflowExecute.processRunExecutionData(this.workflow);
@@ -111,11 +108,10 @@ export class WorkflowRunnerProcess {
* the parent process where they then can be executed with access
* to database and to PushService
*
* @param {ChildProcess} process
* @returns
*/
getProcessForwardHooks(): IWorkflowExecuteHooks {
return {
getProcessForwardHooks(): WorkflowHooks {
const hookFunctions = {
nodeExecuteBefore: [
async (nodeName: string): Promise<void> => {
this.sendHookToParentProcess('nodeExecuteBefore', [nodeName]);
@@ -137,6 +133,8 @@ export class WorkflowRunnerProcess {
},
]
};
return new WorkflowHooks(hookFunctions, this.data!.executionMode, this.data!.executionId, this.data!.workflowData, { sessionId: this.data!.sessionId, retryOf: this.data!.retryOf as string });
}
}