8726 workflow add a test button in workflow code step (#9016)
- add test button to workflow code step - add test tab to workflow code step https://github.com/user-attachments/assets/e180a827-7321-49a2-8026-88490c557da2  
This commit is contained in:
@ -9,7 +9,6 @@ import { WorkflowVersionStepWorkspaceService } from 'src/modules/workflow/common
|
||||
import { WorkflowBuilderModule } from 'src/modules/workflow/workflow-builder/workflow-builder.module';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ServerlessFunctionModule } from 'src/engine/metadata-modules/serverless-function/serverless-function.module';
|
||||
import { CodeIntrospectionModule } from 'src/modules/code-introspection/code-introspection.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@ -17,7 +16,6 @@ import { CodeIntrospectionModule } from 'src/modules/code-introspection/code-int
|
||||
WorkflowCommandModule,
|
||||
WorkflowBuilderModule,
|
||||
ServerlessFunctionModule,
|
||||
CodeIntrospectionModule,
|
||||
NestjsQueryTypeOrmModule.forFeature([ObjectMetadataEntity], 'metadata'),
|
||||
],
|
||||
providers: [
|
||||
|
||||
@ -1,17 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { join } from 'path';
|
||||
|
||||
import { Repository } from 'typeorm';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { INDEX_FILE_NAME } from 'src/engine/core-modules/serverless/drivers/constants/index-file-name';
|
||||
import { WorkflowActionDTO } from 'src/engine/core-modules/workflow/dtos/workflow-step.dto';
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { ServerlessFunctionService } from 'src/engine/metadata-modules/serverless-function/serverless-function.service';
|
||||
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
|
||||
import { CodeIntrospectionService } from 'src/modules/code-introspection/code-introspection.service';
|
||||
import {
|
||||
WorkflowVersionStepException,
|
||||
WorkflowVersionStepExceptionCode,
|
||||
@ -24,6 +20,7 @@ import {
|
||||
WorkflowActionType,
|
||||
} from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type';
|
||||
import { isDefined } from 'src/utils/is-defined';
|
||||
import { BASE_TYPESCRIPT_PROJECT_INPUT_SCHEMA } from 'src/engine/core-modules/serverless/drivers/constants/base-typescript-project-input-schema';
|
||||
|
||||
const TRIGGER_STEP_ID = 'trigger';
|
||||
|
||||
@ -46,7 +43,6 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
private readonly twentyORMManager: TwentyORMManager,
|
||||
private readonly workflowBuilderWorkspaceService: WorkflowBuilderWorkspaceService,
|
||||
private readonly serverlessFunctionService: ServerlessFunctionService,
|
||||
private readonly codeIntrospectionService: CodeIntrospectionService,
|
||||
@InjectRepository(ObjectMetadataEntity, 'metadata')
|
||||
private readonly objectMetadataRepository: Repository<ObjectMetadataEntity>,
|
||||
) {}
|
||||
@ -78,21 +74,6 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
);
|
||||
}
|
||||
|
||||
const sourceCode = (
|
||||
await this.serverlessFunctionService.getServerlessFunctionSourceCode(
|
||||
workspaceId,
|
||||
newServerlessFunction.id,
|
||||
'draft',
|
||||
)
|
||||
)?.[join('src', INDEX_FILE_NAME)];
|
||||
|
||||
const inputSchema = isDefined(sourceCode)
|
||||
? this.codeIntrospectionService.getFunctionInputSchema(sourceCode)
|
||||
: {};
|
||||
|
||||
const serverlessFunctionInput =
|
||||
this.codeIntrospectionService.generateInputData(inputSchema, true);
|
||||
|
||||
return {
|
||||
id: newStepId,
|
||||
name: 'Code - Serverless Function',
|
||||
@ -103,7 +84,7 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
input: {
|
||||
serverlessFunctionId: newServerlessFunction.id,
|
||||
serverlessFunctionVersion: 'draft',
|
||||
serverlessFunctionInput,
|
||||
serverlessFunctionInput: BASE_TYPESCRIPT_PROJECT_INPUT_SCHEMA,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -201,6 +182,11 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
step: WorkflowAction;
|
||||
workspaceId: string;
|
||||
}): Promise<WorkflowAction> {
|
||||
// We don't enrich on the fly for code workflow action. OutputSchema is computed and updated when testing the serverless function
|
||||
if (step.type === WorkflowActionType.CODE) {
|
||||
return step;
|
||||
}
|
||||
|
||||
const result = { ...step };
|
||||
const outputSchema =
|
||||
await this.workflowBuilderWorkspaceService.computeStepOutputSchema({
|
||||
@ -262,12 +248,10 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
workspaceId,
|
||||
workflowVersionId,
|
||||
step,
|
||||
shouldUpdateStepOutput,
|
||||
}: {
|
||||
workspaceId: string;
|
||||
workflowVersionId: string;
|
||||
step: WorkflowAction;
|
||||
shouldUpdateStepOutput: boolean;
|
||||
}): Promise<WorkflowAction> {
|
||||
const workflowVersionRepository =
|
||||
await this.twentyORMManager.getRepository<WorkflowVersionWorkspaceEntity>(
|
||||
@ -294,12 +278,10 @@ export class WorkflowVersionStepWorkspaceService {
|
||||
);
|
||||
}
|
||||
|
||||
const enrichedNewStep = shouldUpdateStepOutput
|
||||
? await this.enrichOutputSchema({
|
||||
step,
|
||||
workspaceId,
|
||||
})
|
||||
: step;
|
||||
const enrichedNewStep = await this.enrichOutputSchema({
|
||||
step,
|
||||
workspaceId,
|
||||
});
|
||||
|
||||
const updatedSteps = workflowVersion.steps.map((existingStep) => {
|
||||
if (existingStep.id === step.id) {
|
||||
|
||||
Reference in New Issue
Block a user