( blockId: string, dag: DAG, executedBlocks: Set<string> )
| 154 | * @returns Validation result with error message if invalid |
| 155 | */ |
| 156 | export function validateRunFromBlock( |
| 157 | blockId: string, |
| 158 | dag: DAG, |
| 159 | executedBlocks: Set<string> |
| 160 | ): RunFromBlockValidation { |
| 161 | const node = dag.nodes.get(blockId) |
| 162 | const isLoopContainer = dag.loopConfigs.has(blockId) |
| 163 | const isParallelContainer = dag.parallelConfigs.has(blockId) |
| 164 | const isContainer = isLoopContainer || isParallelContainer |
| 165 | let validationNode = node |
| 166 | |
| 167 | if (!node && !isContainer) { |
| 168 | return { valid: false, error: `Block not found in workflow: ${blockId}` } |
| 169 | } |
| 170 | |
| 171 | if (isContainer) { |
| 172 | const parentLoopId = findParentLoop(blockId, dag) |
| 173 | if (parentLoopId) { |
| 174 | return { |
| 175 | valid: false, |
| 176 | error: `Cannot run from block inside loop: ${parentLoopId}`, |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | const parentParallelId = findParentParallel(blockId, dag) |
| 181 | if (parentParallelId) { |
| 182 | return { |
| 183 | valid: false, |
| 184 | error: `Cannot run from block inside parallel: ${parentParallelId}`, |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | const sentinelStartId = resolveContainerToSentinelStart(blockId, dag) |
| 189 | if (!sentinelStartId || !dag.nodes.has(sentinelStartId)) { |
| 190 | return { |
| 191 | valid: false, |
| 192 | error: `Container sentinel not found for: ${blockId}`, |
| 193 | } |
| 194 | } |
| 195 | validationNode = dag.nodes.get(sentinelStartId) |
| 196 | } |
| 197 | |
| 198 | if (node) { |
| 199 | if (node.metadata.isLoopNode) { |
| 200 | return { |
| 201 | valid: false, |
| 202 | error: `Cannot run from block inside loop: ${node.metadata.subflowId}`, |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | if (node.metadata.isParallelBranch) { |
| 207 | return { |
| 208 | valid: false, |
| 209 | error: `Cannot run from block inside parallel: ${node.metadata.subflowId}`, |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | if (node.metadata.isSentinel) { |
no test coverage detected