8723 workflow add editor in serverless function code step (#8805)
- create a serverless function when creating a new workflow code step - add code editor in workflow code step - move workflowVersion steps management from frontend to backend - add a custom resolver for workflow-version management - fix optimistic rendering on frontend - fix css - delete serverless function when deleting workflow code step TODO - Don't update serverlessFunction if no code change - Factorize what can be between crud trigger and crud step - Publish serverless version when activating workflow - delete serverless functions when deleting workflow or workflowVersion - fix optimistic rendering for code updates - Unify CRUD types <img width="1279" alt="image" src="https://github.com/user-attachments/assets/3d97ee9f-4b96-4abc-9d36-5c0280058be4">
This commit is contained in:
@ -17,4 +17,5 @@ export enum MessageQueue {
|
||||
entityEventsToDbQueue = 'entity-events-to-db-queue',
|
||||
testQueue = 'test-queue',
|
||||
workflowQueue = 'workflow-queue',
|
||||
serverlessFunctionQueue = 'serverless-function-queue',
|
||||
}
|
||||
|
||||
@ -8,17 +8,18 @@ export type LayerDependencies = {
|
||||
yarnLock: string;
|
||||
};
|
||||
|
||||
export const getLastLayerDependencies =
|
||||
async (): Promise<LayerDependencies> => {
|
||||
const lastVersionLayerDirName = getLayerDependenciesDirName('latest');
|
||||
const packageJson = await fs.readFile(
|
||||
join(lastVersionLayerDirName, 'package.json'),
|
||||
'utf8',
|
||||
);
|
||||
const yarnLock = await fs.readFile(
|
||||
join(lastVersionLayerDirName, 'yarn.lock'),
|
||||
'utf8',
|
||||
);
|
||||
export const getLayerDependencies = async (
|
||||
layerVersion: number | 'latest',
|
||||
): Promise<LayerDependencies> => {
|
||||
const lastVersionLayerDirName = getLayerDependenciesDirName(layerVersion);
|
||||
const packageJson = await fs.readFile(
|
||||
join(lastVersionLayerDirName, 'package.json'),
|
||||
'utf8',
|
||||
);
|
||||
const yarnLock = await fs.readFile(
|
||||
join(lastVersionLayerDirName, 'yarn.lock'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
return { packageJson: JSON.parse(packageJson), yarnLock };
|
||||
};
|
||||
return { packageJson: JSON.parse(packageJson), yarnLock };
|
||||
};
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
import { Field, InputType } from '@nestjs/graphql';
|
||||
|
||||
import { WorkflowActionType } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
|
||||
|
||||
@InputType()
|
||||
export class CreateWorkflowVersionStepInput {
|
||||
@Field(() => String, {
|
||||
description: 'Workflow version ID',
|
||||
nullable: false,
|
||||
})
|
||||
workflowVersionId: string;
|
||||
|
||||
@Field(() => String, {
|
||||
description: 'New step type',
|
||||
nullable: false,
|
||||
})
|
||||
stepType: WorkflowActionType;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
import { Field, InputType } from '@nestjs/graphql';
|
||||
|
||||
@InputType()
|
||||
export class DeleteWorkflowVersionStepInput {
|
||||
@Field(() => String, {
|
||||
description: 'Workflow version ID',
|
||||
nullable: false,
|
||||
})
|
||||
workflowVersionId: string;
|
||||
|
||||
@Field(() => String, {
|
||||
description: 'Step to delete ID',
|
||||
nullable: false,
|
||||
})
|
||||
stepId: string;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
import { Field, InputType } from '@nestjs/graphql';
|
||||
|
||||
import graphqlTypeJson from 'graphql-type-json';
|
||||
|
||||
import { WorkflowAction } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
|
||||
|
||||
@InputType()
|
||||
export class UpdateWorkflowVersionStepInput {
|
||||
@Field(() => String, {
|
||||
description: 'Workflow version ID',
|
||||
nullable: false,
|
||||
})
|
||||
workflowVersionId: string;
|
||||
|
||||
@Field(() => graphqlTypeJson, {
|
||||
description: 'Step to update in JSON format',
|
||||
nullable: false,
|
||||
})
|
||||
step: WorkflowAction;
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import graphqlTypeJson from 'graphql-type-json';
|
||||
|
||||
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
||||
import { WorkflowActionType } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
|
||||
|
||||
@ObjectType('WorkflowAction')
|
||||
export class WorkflowActionDTO {
|
||||
@Field(() => UUIDScalarType)
|
||||
id: string;
|
||||
|
||||
@Field(() => String)
|
||||
name: string;
|
||||
|
||||
@Field(() => String)
|
||||
type: WorkflowActionType;
|
||||
|
||||
@Field(() => graphqlTypeJson)
|
||||
settings: object;
|
||||
|
||||
@Field(() => Boolean)
|
||||
valid: boolean;
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
import { UseFilters, UseGuards } from '@nestjs/common';
|
||||
import { Args, Mutation, Resolver } from '@nestjs/graphql';
|
||||
|
||||
import { WorkflowTriggerGraphqlApiExceptionFilter } from 'src/engine/core-modules/workflow/filters/workflow-trigger-graphql-api-exception.filter';
|
||||
import { UserAuthGuard } from 'src/engine/guards/user-auth.guard';
|
||||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
||||
import { CreateWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/create-workflow-version-step-input.dto';
|
||||
import { UpdateWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/update-workflow-version-step-input.dto';
|
||||
import { DeleteWorkflowVersionStepInput } from 'src/engine/core-modules/workflow/dtos/delete-workflow-version-step-input.dto';
|
||||
import { WorkflowVersionStepWorkspaceService } from 'src/modules/workflow/common/workspace-services/workflow-version-step.workspace-service';
|
||||
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { WorkflowActionDTO } from 'src/engine/core-modules/workflow/dtos/workflow-step.dto';
|
||||
|
||||
@Resolver()
|
||||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard)
|
||||
@UseFilters(WorkflowTriggerGraphqlApiExceptionFilter)
|
||||
export class WorkflowVersionStepResolver {
|
||||
constructor(
|
||||
private readonly workflowVersionStepWorkspaceService: WorkflowVersionStepWorkspaceService,
|
||||
) {}
|
||||
|
||||
@Mutation(() => WorkflowActionDTO)
|
||||
async createWorkflowVersionStep(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('input')
|
||||
{ stepType, workflowVersionId }: CreateWorkflowVersionStepInput,
|
||||
): Promise<WorkflowActionDTO> {
|
||||
return this.workflowVersionStepWorkspaceService.createWorkflowVersionStep({
|
||||
workspaceId,
|
||||
workflowVersionId,
|
||||
stepType,
|
||||
});
|
||||
}
|
||||
|
||||
@Mutation(() => WorkflowActionDTO)
|
||||
async updateWorkflowVersionStep(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('input') { step, workflowVersionId }: UpdateWorkflowVersionStepInput,
|
||||
): Promise<WorkflowActionDTO> {
|
||||
return this.workflowVersionStepWorkspaceService.updateWorkflowVersionStep({
|
||||
workspaceId,
|
||||
workflowVersionId,
|
||||
step,
|
||||
});
|
||||
}
|
||||
|
||||
@Mutation(() => WorkflowActionDTO)
|
||||
async deleteWorkflowVersionStep(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('input')
|
||||
{ stepId, workflowVersionId }: DeleteWorkflowVersionStepInput,
|
||||
): Promise<WorkflowActionDTO> {
|
||||
return this.workflowVersionStepWorkspaceService.deleteWorkflowVersionStep({
|
||||
workspaceId,
|
||||
workflowVersionId,
|
||||
stepId,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,17 @@ import { Module } from '@nestjs/common';
|
||||
|
||||
import { WorkflowTriggerResolver } from 'src/engine/core-modules/workflow/resolvers/workflow-trigger.resolver';
|
||||
import { WorkflowBuilderResolver } from 'src/engine/core-modules/workflow/resolvers/workflow-builder.resolver';
|
||||
import { WorkflowBuilderModule } from 'src/modules/workflow/workflow-builder/workflow-builder.module';
|
||||
import { WorkflowTriggerModule } from 'src/modules/workflow/workflow-trigger/workflow-trigger.module';
|
||||
import { WorkflowVersionStepResolver } from 'src/engine/core-modules/workflow/resolvers/workflow-version-step.resolver';
|
||||
import { WorkflowBuilderModule } from 'src/modules/workflow/workflow-builder/workflow-builder.module';
|
||||
import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';
|
||||
|
||||
@Module({
|
||||
imports: [WorkflowTriggerModule, WorkflowBuilderModule],
|
||||
providers: [WorkflowTriggerResolver, WorkflowBuilderResolver],
|
||||
imports: [WorkflowTriggerModule, WorkflowBuilderModule, WorkflowCommonModule],
|
||||
providers: [
|
||||
WorkflowTriggerResolver,
|
||||
WorkflowBuilderResolver,
|
||||
WorkflowVersionStepResolver,
|
||||
],
|
||||
})
|
||||
export class WorkflowApiModule {}
|
||||
|
||||
Reference in New Issue
Block a user