-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to workspace services #6628
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,26 +4,22 @@ import { Args, Mutation, Resolver } from '@nestjs/graphql'; | |
import { RunWorkflowVersionInput } from 'src/engine/core-modules/workflow/dtos/run-workflow-version-input.dto'; | ||
import { WorkflowTriggerResultDTO } from 'src/engine/core-modules/workflow/dtos/workflow-trigger-result.dto'; | ||
import { workflowTriggerGraphqlApiExceptionHandler } from 'src/engine/core-modules/workflow/utils/workflow-trigger-graphql-api-exception-handler.util'; | ||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator'; | ||
import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard'; | ||
import { WorkflowTriggerService } from 'src/modules/workflow/workflow-trigger/workflow-trigger.service'; | ||
import { WorkflowTriggerWorkspaceService } from 'src/modules/workflow/workflow-trigger/workflow-trigger.workspace-service'; | ||
|
||
@UseGuards(JwtAuthGuard) | ||
@Resolver() | ||
export class WorkflowTriggerResolver { | ||
constructor( | ||
private readonly workflowTriggerService: WorkflowTriggerService, | ||
private readonly workflowTriggerWorkspaceService: WorkflowTriggerWorkspaceService, | ||
) {} | ||
|
||
@Mutation(() => Boolean) | ||
async enableWorkflowTrigger( | ||
@AuthWorkspace() { id: workspaceId }: Workspace, | ||
@Args('workflowVersionId') workflowVersionId: string, | ||
) { | ||
try { | ||
return await this.workflowTriggerService.enableWorkflowTrigger( | ||
workspaceId, | ||
return await this.workflowTriggerWorkspaceService.enableWorkflowTrigger( | ||
workflowVersionId, | ||
); | ||
} catch (error) { | ||
|
@@ -33,13 +29,11 @@ export class WorkflowTriggerResolver { | |
|
||
@Mutation(() => WorkflowTriggerResultDTO) | ||
async runWorkflowVersion( | ||
@AuthWorkspace() { id: workspaceId }: Workspace, | ||
@Args('input') { workflowVersionId, payload }: RunWorkflowVersionInput, | ||
) { | ||
Comment on lines
31
to
33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: workspaceId parameter removed here as well. Verify that WorkflowTriggerWorkspaceService correctly identifies the workspace context |
||
try { | ||
return { | ||
result: await this.workflowTriggerService.runWorkflowVersion( | ||
workspaceId, | ||
result: await this.workflowTriggerWorkspaceService.runWorkflowVersion( | ||
workflowVersionId, | ||
payload ?? {}, | ||
), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { WorkflowCommonService } from 'src/modules/workflow/common/workflow-common.services'; | ||
import { WorkflowCommonWorkspaceService } from 'src/modules/workflow/common/workflow-common.workspace-service'; | ||
|
||
@Module({ | ||
providers: [WorkflowCommonService], | ||
exports: [WorkflowCommonService], | ||
providers: [WorkflowCommonWorkspaceService], | ||
exports: [WorkflowCommonWorkspaceService], | ||
}) | ||
export class WorkflowCommonModule {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { CustomException } from 'src/utils/custom-exception'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider using a relative import path for better maintainability |
||
|
||
export class WorkflowActionRunnerException extends CustomException { | ||
code: WorkflowActionRunnerExceptionCode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: The |
||
constructor(message: string, code: WorkflowActionRunnerExceptionCode) { | ||
super(message, code); | ||
} | ||
} | ||
|
||
export enum WorkflowActionRunnerExceptionCode { | ||
SCOPED_WORKSPACE_NOT_FOUND = 'SCOPED_WORKSPACE_NOT_FOUND', | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { WorkflowResult } from 'src/modules/workflow/common/types/workflow-result.type'; | ||
import { WorkflowAction } from 'src/modules/workflow/common/types/workflow-action.type'; | ||
import { WorkflowResult } from 'src/modules/workflow/common/types/workflow-result.type'; | ||
|
||
export interface WorkflowActionRunner { | ||
execute({ | ||
action, | ||
workspaceId, | ||
payload, | ||
}: { | ||
action: WorkflowAction; | ||
workspaceId: string; | ||
payload?: object; | ||
}): Promise<WorkflowResult>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +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 { WorkflowActionRunnerFactory } from 'src/modules/workflow/workflow-action-runner/workflow-action-runner.factory'; | ||
import { CodeWorkflowActionRunner } from 'src/modules/workflow/workflow-action-runner/workflow-action-runners/code-workflow-action-runner'; | ||
import { ServerlessFunctionModule } from 'src/engine/metadata-modules/serverless-function/serverless-function.module'; | ||
|
||
@Module({ | ||
imports: [ServerlessFunctionModule], | ||
providers: [WorkflowActionRunnerFactory, CodeWorkflowActionRunner], | ||
providers: [ | ||
WorkflowActionRunnerFactory, | ||
CodeWorkflowActionRunner, | ||
ScopedWorkspaceContextFactory, | ||
], | ||
exports: [WorkflowActionRunnerFactory], | ||
}) | ||
export class WorkflowActionRunnerModule {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: workspaceId parameter removed. Ensure workspace context is correctly handled by WorkflowTriggerWorkspaceService