-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update workflow version struct (#6716)
We want to avoid the nested structure of active pieces. Steps to execute will now be separated from the trigger. It will be an array executed sequentially. For now a step can only be an action. But at some point it will also be a branch or a loop
- Loading branch information
Showing
18 changed files
with
131 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
packages/twenty-server/src/modules/workflow/common/types/workflow-action.type.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/twenty-server/src/modules/workflow/common/types/workflow-step.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { WorkflowCodeSettings } from 'src/modules/workflow/common/types/workflow-settings.type'; | ||
|
||
export enum WorkflowStepType { | ||
CODE_ACTION = 'CODE_ACTION', | ||
} | ||
|
||
type BaseWorkflowStep = { | ||
id: string; | ||
name: string; | ||
valid: boolean; | ||
}; | ||
|
||
export type WorkflowCodeStep = BaseWorkflowStep & { | ||
type: WorkflowStepType.CODE_ACTION; | ||
settings: WorkflowCodeSettings; | ||
}; | ||
|
||
export type WorkflowStep = WorkflowCodeStep; |
5 changes: 1 addition & 4 deletions
5
packages/twenty-server/src/modules/workflow/common/types/workflow-trigger.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...erver/src/modules/workflow/workflow-action-executor/workflow-action-executor.exception.ts
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...-server/src/modules/workflow/workflow-action-executor/workflow-action-executor.factory.ts
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
...y-server/src/modules/workflow/workflow-action-executor/workflow-action-executor.module.ts
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-executor.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...ty-server/src/modules/workflow/workflow-step-executor/workflow-step-executor.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CustomException } from 'src/utils/custom-exception'; | ||
|
||
export class WorkflowStepExecutorException extends CustomException { | ||
code: WorkflowStepExecutorExceptionCode; | ||
constructor(message: string, code: WorkflowStepExecutorExceptionCode) { | ||
super(message, code); | ||
} | ||
} | ||
|
||
export enum WorkflowStepExecutorExceptionCode { | ||
SCOPED_WORKSPACE_NOT_FOUND = 'SCOPED_WORKSPACE_NOT_FOUND', | ||
INVALID_STEP_TYPE = 'INVALID_STEP_TYPE', | ||
} |
26 changes: 26 additions & 0 deletions
26
...enty-server/src/modules/workflow/workflow-step-executor/workflow-step-executor.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
import { WorkflowStepType } from 'src/modules/workflow/common/types/workflow-step.type'; | ||
import { | ||
WorkflowStepExecutorException, | ||
WorkflowStepExecutorExceptionCode, | ||
} from 'src/modules/workflow/workflow-step-executor/workflow-step-executor.exception'; | ||
import { WorkflowStepExecutor } from 'src/modules/workflow/workflow-step-executor/workflow-step-executor.interface'; | ||
import { CodeActionExecutor } from 'src/modules/workflow/workflow-step-executor/workflow-step-executors/code-action-executor'; | ||
|
||
@Injectable() | ||
export class WorkflowStepExecutorFactory { | ||
constructor(private readonly codeActionExecutor: CodeActionExecutor) {} | ||
|
||
get(stepType: WorkflowStepType): WorkflowStepExecutor { | ||
switch (stepType) { | ||
case WorkflowStepType.CODE_ACTION: | ||
return this.codeActionExecutor; | ||
default: | ||
throw new WorkflowStepExecutorException( | ||
`Workflow step executor not found for step type '${stepType}'`, | ||
WorkflowStepExecutorExceptionCode.INVALID_STEP_TYPE, | ||
); | ||
} | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
...tor/workflow-action-executor.interface.ts → ...cutor/workflow-step-executor.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { WorkflowAction } from 'src/modules/workflow/common/types/workflow-action.type'; | ||
import { WorkflowResult } from 'src/modules/workflow/common/types/workflow-result.type'; | ||
import { WorkflowStep } from 'src/modules/workflow/common/types/workflow-step.type'; | ||
|
||
export interface WorkflowActionExecutor { | ||
export interface WorkflowStepExecutor { | ||
execute({ | ||
action, | ||
step, | ||
payload, | ||
}: { | ||
action: WorkflowAction; | ||
step: WorkflowStep; | ||
payload?: object; | ||
}): Promise<WorkflowResult>; | ||
} |
17 changes: 17 additions & 0 deletions
17
...wenty-server/src/modules/workflow/workflow-step-executor/workflow-step-executor.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { ServerlessFunctionModule } from 'src/engine/metadata-modules/serverless-function/serverless-function.module'; | ||
import { ScopedWorkspaceContextFactory } from 'src/engine/twenty-orm/factories/scoped-workspace-context.factory'; | ||
import { WorkflowStepExecutorFactory } from 'src/modules/workflow/workflow-step-executor/workflow-step-executor.factory'; | ||
import { CodeActionExecutor } from 'src/modules/workflow/workflow-step-executor/workflow-step-executors/code-action-executor'; | ||
|
||
@Module({ | ||
imports: [ServerlessFunctionModule], | ||
providers: [ | ||
WorkflowStepExecutorFactory, | ||
CodeActionExecutor, | ||
ScopedWorkspaceContextFactory, | ||
], | ||
exports: [WorkflowStepExecutorFactory], | ||
}) | ||
export class WorkflowStepExecutorModule {} |
Oops, something went wrong.