@@ -15,6 +15,8 @@ const end_nodes: Array<string> = [
1515 WorkflowType . TextToVideoGenerateNode ,
1616 WorkflowType . ImageGenerateNode ,
1717 WorkflowType . LoopBodyNode ,
18+ WorkflowType . LoopNode ,
19+ WorkflowType . LoopBreakNode ,
1820]
1921export class WorkFlowInstance {
2022 nodes
@@ -29,7 +31,9 @@ export class WorkFlowInstance {
2931 * 校验开始节点
3032 */
3133 private is_valid_start_node ( ) {
32- const start_node_list = this . nodes . filter ( ( item ) => item . id === WorkflowType . Start )
34+ const start_node_list = this . nodes . filter ( ( item ) =>
35+ [ WorkflowType . Start , WorkflowType . LoopStartNode ] . includes ( item . id ) ,
36+ )
3337 if ( start_node_list . length == 0 ) {
3438 throw t ( 'views.applicationWorkflow.validate.startNodeRequired' )
3539 } else if ( start_node_list . length > 1 ) {
@@ -57,12 +61,20 @@ export class WorkFlowInstance {
5761 this . is_valid_nodes ( )
5862 }
5963
64+ is_loop_valid ( ) {
65+ this . is_valid_start_node ( )
66+ this . is_valid_work_flow ( )
67+ this . is_valid_nodes ( )
68+ }
69+
6070 /**
6171 * 获取开始节点
6272 * @returns
6373 */
6474 get_start_node ( ) {
65- const start_node_list = this . nodes . filter ( ( item ) => item . id === WorkflowType . Start )
75+ const start_node_list = this . nodes . filter ( ( item ) =>
76+ [ WorkflowType . Start , WorkflowType . LoopStartNode ] . includes ( item . id ) ,
77+ )
6678 return start_node_list [ 0 ]
6779 }
6880 /**
@@ -73,7 +85,9 @@ export class WorkFlowInstance {
7385 const base_node_list = this . nodes . filter ( ( item ) => item . id === WorkflowType . Base )
7486 return base_node_list [ 0 ]
7587 }
76-
88+ extis_break_node ( ) {
89+ return this . nodes . some ( ( item ) => item . id === WorkflowType . LoopBreakNode )
90+ }
7791 /**
7892 * 校验工作流
7993 * @param up_node 上一个节点
@@ -117,7 +131,11 @@ export class WorkFlowInstance {
117131 }
118132 private is_valid_nodes ( ) {
119133 for ( const node of this . nodes ) {
120- if ( node . type !== WorkflowType . Base && node . type !== WorkflowType . Start ) {
134+ if (
135+ node . type !== WorkflowType . Base &&
136+ node . type !== WorkflowType . Start &&
137+ node . type !== WorkflowType . LoopStartNode
138+ ) {
121139 if ( ! this . edges . some ( ( edge ) => edge . targetNodeId === node . id ) ) {
122140 throw `${ t ( 'views.applicationWorkflow.validate.notInWorkFlowNode' ) } :${ node . properties . stepName } `
123141 }
0 commit comments