Thomas Trompette
2025-09-10 17:25:40 +02:00
committed by GitHub
parent bcf1bba302
commit 3bfb5bbd86
34 changed files with 642 additions and 118 deletions
@@ -0,0 +1,10 @@
import { Field, InputType } from '@nestjs/graphql';
@InputType()
export class DuplicateWorkflowVersionStepInput {
@Field(() => String)
stepId: string;
@Field(() => String)
workflowVersionId: string;
}
@@ -7,6 +7,7 @@ import { PreventNestToAutoLogGraphqlErrorsFilter } from 'src/engine/core-modules
import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';
import { CreateWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/create-workflow-version-step-input.dto';
import { DeleteWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/delete-workflow-version-step-input.dto';
import { DuplicateWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/duplicate-workflow-version-step-input.dto';
import { SubmitFormStepInput } from 'src/engine/core-modules/workflow/dtos/submit-form-step-input.dto';
import { UpdateWorkflowRunStepInput } from 'src/engine/core-modules/workflow/dtos/update-workflow-run-step-input.dto';
import { UpdateWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/update-workflow-version-step-input.dto';
@@ -124,4 +125,19 @@ export class WorkflowVersionStepResolver {
return step;
}
@Mutation(() => WorkflowVersionStepChangesDTO)
async duplicateWorkflowVersionStep(
@AuthWorkspace() { id: workspaceId }: Workspace,
@Args('input')
{ stepId, workflowVersionId }: DuplicateWorkflowVersionStepInput,
): Promise<WorkflowVersionStepChangesDTO> {
return this.workflowVersionStepWorkspaceService.duplicateWorkflowVersionStep(
{
workspaceId,
workflowVersionId,
stepId,
},
);
}
}
@@ -10,4 +10,5 @@ export enum ServerlessFunctionExceptionCode {
SERVERLESS_FUNCTION_BUILDING = 'SERVERLESS_FUNCTION_BUILDING',
SERVERLESS_FUNCTION_CODE_UNCHANGED = 'SERVERLESS_FUNCTION_CODE_UNCHANGED',
SERVERLESS_FUNCTION_EXECUTION_LIMIT_REACHED = 'SERVERLESS_FUNCTION_EXECUTION_LIMIT_REACHED',
SERVERLESS_FUNCTION_CREATE_FAILED = 'SERVERLESS_FUNCTION_CREATE_FAILED',
}
@@ -363,7 +363,7 @@ export class ServerlessFunctionService {
});
}
async usePublishedVersionAsDraft({
async createDraftFromPublishedVersion({
id,
version,
workspaceId,
@@ -400,6 +400,57 @@ export class ServerlessFunctionService {
});
}
async duplicateServerlessFunction({
id,
version,
workspaceId,
}: {
id: string;
version: string;
workspaceId: string;
}) {
const serverlessFunctionToDuplicate =
await this.serverlessFunctionRepository.findOneOrFail({
where: {
id,
workspaceId,
},
});
const newServerlessFunction = await this.createOneServerlessFunction(
{
name: serverlessFunctionToDuplicate.name,
description: serverlessFunctionToDuplicate.description,
timeoutSeconds: serverlessFunctionToDuplicate.timeoutSeconds,
},
workspaceId,
);
if (!isDefined(newServerlessFunction)) {
throw new ServerlessFunctionException(
'Failed to create new serverless function',
ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_CREATE_FAILED,
);
}
await this.fileStorageService.copy({
from: {
folderPath: getServerlessFolder({
serverlessFunction: serverlessFunctionToDuplicate,
version,
}),
},
to: {
folderPath: getServerlessFolder({
serverlessFunction: newServerlessFunction,
version: 'draft',
}),
},
});
return newServerlessFunction;
}
private async throttleExecution(workspaceId: string) {
try {
await this.throttlerService.throttle(
@@ -24,6 +24,7 @@ export const serverlessFunctionGraphQLApiExceptionHandler = (error: any) => {
case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_EXECUTION_LIMIT_REACHED:
throw new ForbiddenError(error);
case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_CODE_UNCHANGED:
case ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_CREATE_FAILED:
throw error;
default: {
return assertUnreachable(error.code);