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

Function findAllDescendantNodes

apps/sim/stores/workflows/workflow/utils.ts:157–176  ·  view source on GitHub ↗
(
  containerId: string,
  blocks: Record<string, BlockState>
)

Source from the content-addressed store, hash-verified

155 * @returns Array of node IDs that are descendants of this container
156 */
157export function findAllDescendantNodes(
158 containerId: string,
159 blocks: Record<string, BlockState>
160): string[] {
161 const descendants: string[] = []
162 const visited = new Set<string>()
163 const stack = [containerId]
164 while (stack.length > 0) {
165 const current = stack.pop()!
166 if (visited.has(current)) continue
167 visited.add(current)
168 for (const block of Object.values(blocks)) {
169 if (block.data?.parentId === current) {
170 descendants.push(block.id)
171 stack.push(block.id)
172 }
173 }
174 }
175 return descendants
176}
177
178/**
179 * Checks if any ancestor container of a block is locked.

Callers 2

store.tsFile · 0.90
useCollaborativeWorkflowFunction · 0.90

Calls 2

addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected