Migrate workflow actions to executors (#10432)
Actions will now: - receive the complete input - get the step they want to execute by themself - check that the type is the right one - resolve variables These all share a common executor interface. It will allow for actions with a special execution process (forms, loop, router) to have all required informations. Main workflow executor should: - find the right executor to call for current step - store the output and context from step execution - call next step index
This commit is contained in:
+4
-7
@@ -67,20 +67,17 @@ export class RunWorkflowJob {
|
||||
|
||||
await this.throttleExecution(workflowVersion.workflowId);
|
||||
|
||||
const { status } = await this.workflowExecutorWorkspaceService.execute({
|
||||
const { error } = await this.workflowExecutorWorkspaceService.execute({
|
||||
workflowRunId,
|
||||
currentStepIndex: 0,
|
||||
steps: workflowVersion.steps ?? [],
|
||||
steps: workflowVersion.steps,
|
||||
context,
|
||||
workflowExecutorState: {
|
||||
stepsOutput: {},
|
||||
status: WorkflowRunStatus.RUNNING,
|
||||
},
|
||||
});
|
||||
|
||||
await this.workflowRunWorkspaceService.endWorkflowRun({
|
||||
workflowRunId,
|
||||
status,
|
||||
status: error ? WorkflowRunStatus.FAILED : WorkflowRunStatus.COMPLETED,
|
||||
error,
|
||||
});
|
||||
} catch (error) {
|
||||
await this.workflowRunWorkspaceService.endWorkflowRun({
|
||||
|
||||
+7
-3
@@ -3,6 +3,7 @@ import { Injectable } from '@nestjs/common';
|
||||
import { ActorMetadata } from 'src/engine/metadata-modules/field-metadata/composite-types/actor.composite-type';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import {
|
||||
StepOutput,
|
||||
WorkflowRunOutput,
|
||||
WorkflowRunStatus,
|
||||
WorkflowRunWorkspaceEntity,
|
||||
@@ -125,11 +126,11 @@ export class WorkflowRunWorkspaceService {
|
||||
|
||||
async saveWorkflowRunState({
|
||||
workflowRunId,
|
||||
output,
|
||||
stepOutput,
|
||||
context,
|
||||
}: {
|
||||
workflowRunId: string;
|
||||
output: Pick<WorkflowRunOutput, 'error' | 'stepsOutput'>;
|
||||
stepOutput: StepOutput;
|
||||
context: Record<string, any>;
|
||||
}) {
|
||||
const workflowRunRepository =
|
||||
@@ -154,7 +155,10 @@ export class WorkflowRunWorkspaceService {
|
||||
trigger: undefined,
|
||||
steps: [],
|
||||
},
|
||||
...output,
|
||||
stepsOutput: {
|
||||
...(workflowRunToUpdate.output?.stepsOutput ?? {}),
|
||||
[stepOutput.id]: stepOutput.output,
|
||||
},
|
||||
},
|
||||
context,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user