From f11ea303250dae33fb9912837734d0445620c095 Mon Sep 17 00:00:00 2001 From: Akshay Sasidharan Date: Thu, 3 Jul 2025 14:06:15 +0530 Subject: [PATCH] feat: migrate workflow-in-workflow capabilities and enhanced node preview (PR #3735) Migrate hotfix for workflow blockers including: - Feature: Ability to call workflow within a workflow - Feature: Preview query node with other previewed node results - Fix: startTrigger input accepts string values instead of code/JSON Frontend changes: - Add workflow-in-workflow support in FlowBuilder and QueryNodeConfiguration - Enhance query node preview with upstream node state management - Implement preview state cleanup with deleteNodePreviewState calls - Replace TestParameter input with CodeHinter for better JSON editing - Add workflow node type support and error styling - Update WorkflowEditor components for nested workflow handling Backend changes: - Update workflow execution controller to handle state parameter - Enhance PreviewWorkflowNodeDto with optional state field - Modify workflow services for state-aware query execution - Update triggers listener and webhooks service Migration follows composition pattern for frontend EE modules and inheritance pattern for backend services. Co-authored-by: Akshay Sasidharan Co-authored-by: Shah Co-authored-by: Devanshu --- frontend/ee | 2 +- frontend/src/_services/workflow_executions.service.js | 4 ++-- server/ee | 2 +- server/src/dto/preview-workflow-node.dto.ts | 6 +++++- server/src/modules/data-queries/repository.ts | 2 +- .../interfaces/IWorkflowExecutionsService.ts | 11 ++++++++++- .../workflows/services/workflow-executions.service.ts | 11 ++++++++++- 7 files changed, 30 insertions(+), 8 deletions(-) diff --git a/frontend/ee b/frontend/ee index 5ab476909c..9cfaf2261b 160000 --- a/frontend/ee +++ b/frontend/ee @@ -1 +1 @@ -Subproject commit 5ab476909c9859a4a029185c2c8b922ca6ea0d23 +Subproject commit 9cfaf2261b1801eea1c78beb2c2a9508a39638ff diff --git a/frontend/src/_services/workflow_executions.service.js b/frontend/src/_services/workflow_executions.service.js index 7d39e9b835..ecaa810733 100644 --- a/frontend/src/_services/workflow_executions.service.js +++ b/frontend/src/_services/workflow_executions.service.js @@ -14,9 +14,9 @@ export const workflowExecutionsService = { streamSSE, }; -function previewQueryNode(queryId, appVersionId, nodeId) { +function previewQueryNode(queryId, appVersionId, nodeId, state = {}) { const currentSession = authenticationService.currentSessionValue; - const body = { appVersionId, userId: currentSession.current_user?.id, queryId, nodeId }; + const body = { appVersionId, userId: currentSession.current_user?.id, queryId, nodeId, state }; const requestOptions = { method: 'POST', headers: authHeader(), body: JSON.stringify(body), credentials: 'include' }; return fetch(`${config.apiUrl}/workflow_executions/previewQueryNode`, requestOptions).then(handleResponse); } diff --git a/server/ee b/server/ee index 15013b41ac..5ce75fab06 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit 15013b41acee6f951195a7ba37031c38f4c297af +Subproject commit 5ce75fab06b309f2e02c9c30f4ceee222113affb diff --git a/server/src/dto/preview-workflow-node.dto.ts b/server/src/dto/preview-workflow-node.dto.ts index 0268f9652c..63c367fba0 100644 --- a/server/src/dto/preview-workflow-node.dto.ts +++ b/server/src/dto/preview-workflow-node.dto.ts @@ -1,4 +1,4 @@ -import { IsString, IsNotEmpty, IsOptional } from 'class-validator'; +import { IsString, IsNotEmpty, IsOptional, IsObject } from 'class-validator'; export class PreviewWorkflowNodeDto { @IsString() @@ -20,4 +20,8 @@ export class PreviewWorkflowNodeDto { @IsString() @IsOptional() appEnvId?: string; + + @IsObject() + @IsOptional() + state?: Record; } diff --git a/server/src/modules/data-queries/repository.ts b/server/src/modules/data-queries/repository.ts index 8caf25ed1f..dc72577126 100644 --- a/server/src/modules/data-queries/repository.ts +++ b/server/src/modules/data-queries/repository.ts @@ -95,7 +95,7 @@ export class DataQueryRepository extends Repository { findOptions: FindOptionsWhere, relations?: string[], manager?: EntityManager - ): Promise { + ): Promise { return dbTransactionWrap(async (manager: EntityManager) => { return manager.find(DataQuery, { where: { ...(findOptions ? findOptions : {}) }, diff --git a/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts b/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts index 7eeb057902..eac01abd58 100644 --- a/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts +++ b/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts @@ -6,7 +6,16 @@ export interface IWorkflowExecutionsService { execute(workflowExecution: WorkflowExecution, params: any, envId: string, response: Response): Promise; - getStatus(id: string): Promise<{ logs: string[]; status: boolean; nodes: any[] }>; + getStatus(id: string): Promise<{ + logs: unknown; + status: boolean; + nodes: Array<{ + id: string; + idOnDefinition: string; + executed: boolean; + result: unknown; + }>; + }>; getWorkflowExecution(id: string): Promise; diff --git a/server/src/modules/workflows/services/workflow-executions.service.ts b/server/src/modules/workflows/services/workflow-executions.service.ts index b63056816d..7abf8e42c3 100644 --- a/server/src/modules/workflows/services/workflow-executions.service.ts +++ b/server/src/modules/workflows/services/workflow-executions.service.ts @@ -18,7 +18,16 @@ export class WorkflowExecutionsService implements IWorkflowExecutionsService { throw new Error('Method not implemented.'); } - async getStatus(workflowExecutionId: string): Promise<{ logs: string[]; status: boolean; nodes: any[] }> { + async getStatus(workflowExecutionId: string): Promise<{ + logs: unknown; + status: boolean; + nodes: Array<{ + id: string; + idOnDefinition: string; + executed: boolean; + result: unknown; + }>; + }> { throw new Error('Method not implemented.'); }