(edge: Edge, blocks: Record<string, BlockState>)
| 22 | } |
| 23 | |
| 24 | function getScopeDropReason(edge: Edge, blocks: Record<string, BlockState>): string | null { |
| 25 | const sourceBlock = blocks[edge.source] |
| 26 | const targetBlock = blocks[edge.target] |
| 27 | |
| 28 | if (!sourceBlock || !targetBlock) { |
| 29 | return 'edge references a missing block' |
| 30 | } |
| 31 | |
| 32 | const sourceParent = getParentId(sourceBlock) |
| 33 | const targetParent = getParentId(targetBlock) |
| 34 | |
| 35 | if (sourceParent === targetParent) { |
| 36 | return null |
| 37 | } |
| 38 | |
| 39 | if (targetParent === edge.source && isContainerBlock(sourceBlock)) { |
| 40 | return null |
| 41 | } |
| 42 | |
| 43 | if (sourceParent === edge.target && isContainerBlock(targetBlock)) { |
| 44 | return null |
| 45 | } |
| 46 | |
| 47 | return `blocks are in different scopes (${sourceParent ?? 'root'} -> ${targetParent ?? 'root'})` |
| 48 | } |
| 49 | |
| 50 | export function validateEdges( |
| 51 | edges: Edge[], |
no test coverage detected