MCPcopy
hub / github.com/simstudioai/sim / validateEdges

Function validateEdges

apps/sim/stores/workflows/workflow/edge-validation.ts:50–86  ·  view source on GitHub ↗
(
  edges: Edge[],
  blocks: Record<string, BlockState>
)

Source from the content-addressed store, hash-verified

48}
49
50export function validateEdges(
51 edges: Edge[],
52 blocks: Record<string, BlockState>
53): EdgeValidationResult {
54 const valid: Edge[] = []
55 const dropped: DroppedEdge[] = []
56
57 for (const edge of edges) {
58 const sourceBlock = blocks[edge.source]
59 const targetBlock = blocks[edge.target]
60
61 if (!sourceBlock || !targetBlock) {
62 dropped.push({ edge, reason: 'edge references a missing block' })
63 continue
64 }
65
66 if (isAnnotationOnlyBlock(sourceBlock.type) || isAnnotationOnlyBlock(targetBlock.type)) {
67 dropped.push({ edge, reason: 'edge references an annotation-only block' })
68 continue
69 }
70
71 if (TriggerUtils.isTriggerBlock(targetBlock)) {
72 dropped.push({ edge, reason: 'trigger blocks cannot be edge targets' })
73 continue
74 }
75
76 const scopeDropReason = getScopeDropReason(edge, blocks)
77 if (scopeDropReason) {
78 dropped.push({ edge, reason: scopeDropReason })
79 continue
80 }
81
82 valid.push(edge)
83 }
84
85 return { valid, dropped }
86}

Callers 4

filterValidEdgesFunction · 0.90
normalizeWorkflowStateFunction · 0.90
removeInvalidScopeEdgesFunction · 0.90
route.tsFile · 0.90

Calls 4

isAnnotationOnlyBlockFunction · 0.90
getScopeDropReasonFunction · 0.85
pushMethod · 0.45
isTriggerBlockMethod · 0.45

Tested by

no test coverage detected