@ -3,48 +3,51 @@ const { sleep } = require('./util'); 
			
		
	
		
		
			
				
					
					const  {  getAllWorkflows  }  =  require ( './workflow' ) ; const  {  getAllWorkflows  }  =  require ( './workflow' ) ;  
			
		
	
		
		
			
				
					
					const  {  getAllProcesses ,  getProcessPaths  }  =  require ( './process' ) ; const  {  getAllProcesses ,  getProcessPaths  }  =  require ( './process' ) ;  
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					require ( path . join ( process . cwd ( ) , ".." , "server" , "dist" , "database.js" ) ) ; require ( path . join ( process . cwd ( ) ,   ".." ,   "server" ,   "dist" ,   "database.js" ) ) ;  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					( async  function ( ) { ( async  function   ( )   {  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					    await  sleep ( 5e3 ) ;      await  sleep ( 5e3 ) ;   
			
		
	
		
		
			
				
					
					    console . time ( "WorkflowTester" )      console . time ( "WorkflowTester" )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    console . log ( "initilizing begin.." ) ;      console . log ( "initilizing begin.." ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    const  workflows  =  await  getAllWorkflows ( {      const  workflows  =  await  getAllWorkflows ( {   
			
		
	
		
		
			
				
					
					        id : {          id :   {   
			
				
				
			
		
	
		
		
			
				
					
					            [ Op . gt ]   :  0              [ Op . gt ] :  0   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					        }          }   
			
		
	
		
		
			
				
					
					    } ) ;      } ) ;   
			
		
	
		
		
			
				
					
					    if ( workflows . length == 0 )  throw  "There is not any workflow" ;      if   ( workflows . length   ==   0 )  throw  "There is not any workflow" ;   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    const  allWorkf lowInfo  =  { } ;      const  allWorkF lowInfo  =  { } ;   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    workflowsFor :      workflowsFor :   
			
		
	
		
		
			
				
					
					    for  await ( const  workflow  of  workflows ) {      for  await   ( const  workflow  of  workflows )   {   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        if ( + workflow . id  <  0 )  continue ;          if   ( + workflow . id  <  0 )  continue ;   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        const  processes  =  await  getAllProcesses ( workflow ) ;          const  processes  =  await  getAllProcesses ( workflow ,  {   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					            subFlowId :  null ,   
			
		
	
		
		
			
				
					
					        } ) ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        if ( processes . length  ==  0 ) {          if   ( processes . length  ==  0 )   {   
			
				
				
			
		
	
		
		
			
				
					
					            allWorkf lowInfo [ workflow . id ]  =  {              allWorkF lowInfo [ workflow . id ]  =  {   
			
				
				
			
		
	
		
		
			
				
					
					                isValid : false ,                  isValid :   false ,   
			
				
				
			
		
	
		
		
			
				
					
					                root : {                  root :   {   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					                    valid :  0 ,                      valid :  0 ,   
			
		
	
		
		
			
				
					
					                    invalid :  0 ,                      invalid :  0 ,   
			
		
	
		
		
			
				
					
					                    subFlowList :  [ ]                      subFlowList :  [ ]   
			
		
	
		
		
			
				
					
					                } ,                  } ,   
			
		
	
		
		
			
				
					
					                subFlow : { }                  subFlow :   { }   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					            }              }   
			
		
	
		
		
			
				
					
					            continue  workflowsFor ;              continue  workflowsFor ;   
			
		
	
		
		
			
				
					
					        }          }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        const  {  allPaths :  tree ,  subFlowParentIds ,  invalidPathsWithoutEnding  }  =  await  getProcessPaths ( processes ,  workflow ) ;          const  {  allPaths :  tree ,  subFlowParentIds ,  invalidPathsWithoutEnding  }  =  await  getProcessPaths ( processes ,  workflow ) ;   
			
		
	
		
		
			
				
					
					        allWorkFlowInfo [ workflow . id ]  =  {          allWorkFlowInfo [ workflow . id ]  =  {   
			
		
	
		
		
			
				
					
					            isValid :  invalidPathsWithoutEnding . length  ==  0  ?  true  :  false ,   
			
		
	
		
		
			
				
					
					            root :  {              root :  {   
			
		
	
		
		
			
				
					
					                validPaths : tree ,                  validPaths :   tree ,   
			
				
				
			
		
	
		
		
			
				
					
					                invalidPaths : invalidPathsWithoutEnding ,                  invalidPaths :   invalidPathsWithoutEnding ,   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					                valid :  tree . length ,                  valid :  tree . length ,   
			
		
	
		
		
			
				
					
					                invalid :  invalidPathsWithoutEnding . length ,                  invalid :  invalidPathsWithoutEnding . length ,   
			
		
	
		
		
			
				
					
					                subFlowList :  subFlowParentIds                  subFlowList :  subFlowParentIds   
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -52,6 +55,36 @@ require(path.join(process.cwd(),"..","server","dist","database.js")); 
			
		
	
		
		
			
				
					
					            subFlow :  { }              subFlow :  { }   
			
		
	
		
		
			
				
					
					        }          }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        const  subFlowInfo  =  { }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        subFlowFor :   
			
		
	
		
		
			
				
					
					        for  await  ( const  subFlowId  of  subFlowParentIds )  {   
			
		
	
		
		
			
				
					
					            const  processesSubFlow  =  await  getAllProcesses ( workflow ,  {   
			
		
	
		
		
			
				
					
					                [ Op . or ] :  [   
			
		
	
		
		
			
				
					
					                    {   
			
		
	
		
		
			
				
					
					                        subFlowId :  subFlowId ,   
			
		
	
		
		
			
				
					
					                    } ,   
			
		
	
		
		
			
				
					
					                    {   
			
		
	
		
		
			
				
					
					                        subFlowPid :  subFlowId   
			
		
	
		
		
			
				
					
					                    }   
			
		
	
		
		
			
				
					
					                ]   
			
		
	
		
		
			
				
					
					            } )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					            if  ( processesSubFlow . length  ==  0 )  {   
			
		
	
		
		
			
				
					
					                allWorkFlowInfo [ workflow . id ] . isValid  =  false ;   
			
		
	
		
		
			
				
					
					                subFlowInfo [ subFlowId ]  =  {   
			
		
	
		
		
			
				
					
					                    valid :  subTreePath . length ,   
			
		
	
		
		
			
				
					
					                    invalid :  invalidSubPathsWithoutEnding . length ,   
			
		
	
		
		
			
				
					
					                    validSubTreePath : subTreePath ,   
			
		
	
		
		
			
				
					
					                    invalidSubTreePath :  invalidSubPathsWithoutEnding   
			
		
	
		
		
			
				
					
					                }   
			
		
	
		
		
			
				
					
					                continue  subFlowFor ;   
			
		
	
		
		
			
				
					
					            }   
			
		
	
		
		
			
				
					
					        }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        allWorkFlowInfo [ workflow . id ] [ "subFlow" ]  =  subFlowInfo ;   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					        console . log ( "allWorkFlowInfo" , JSON . stringify ( allWorkFlowInfo , null , 2 ) ) ;   
			
		
	
		
		
			
				
					
					    }      }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    console . timeEnd ( "WorkflowTester" )      console . timeEnd ( "WorkflowTester" )