Fix workflow sub objects updates validation (#12169)

Fixes https://github.com/twentyhq/core-team-issues/issues/983

- Enabling workflow version name update, even if not in draft status
- Assert draft when updating steps
- Enabling workflow run name update
This commit is contained in:
Thomas Trompette
2025-05-21 15:11:32 +02:00
committed by GitHub
parent 23ebd69541
commit 5c16b2752d
3 changed files with 22 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import {
} from 'src/modules/workflow/common/exceptions/workflow-version-step.exception';
import { StepOutput } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
import { WorkflowVersionWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-version.workspace-entity';
import { assertWorkflowVersionIsDraft } from 'src/modules/workflow/common/utils/assert-workflow-version-is-draft.util';
import { WorkflowSchemaWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service';
import { insertStep } from 'src/modules/workflow/workflow-builder/workflow-step/utils/insert-step';
import { removeStep } from 'src/modules/workflow/workflow-builder/workflow-step/utils/remove-step';
@ -91,6 +92,8 @@ export class WorkflowVersionStepWorkspaceService {
);
}
assertWorkflowVersionIsDraft(workflowVersion);
const existingSteps = workflowVersion.steps || [];
const updatedSteps = insertStep({
existingSteps,
@ -133,6 +136,8 @@ export class WorkflowVersionStepWorkspaceService {
);
}
assertWorkflowVersionIsDraft(workflowVersion);
if (!isDefined(workflowVersion.steps)) {
throw new WorkflowVersionStepException(
"Can't update step from undefined steps",
@ -187,6 +192,8 @@ export class WorkflowVersionStepWorkspaceService {
);
}
assertWorkflowVersionIsDraft(workflowVersion);
if (!isDefined(workflowVersion.steps)) {
throw new WorkflowVersionStepException(
"Can't delete step from undefined steps",