MCPcopy Index your code
hub / github.com/simstudioai/sim / getBlocksByParent

Function getBlocksByParent

apps/sim/lib/workflows/autolayout/utils.ts:473–494  ·  view source on GitHub ↗
(blocks: Record<string, BlockState>)

Source from the content-addressed store, hash-verified

471 * Groups blocks by their parent container
472 */
473export function getBlocksByParent(blocks: Record<string, BlockState>): {
474 root: string[]
475 children: Map<string, string[]>
476} {
477 const root: string[] = []
478 const children = new Map<string, string[]>()
479
480 for (const [id, block] of Object.entries(blocks)) {
481 const parentId = block.data?.parentId
482
483 if (!parentId) {
484 root.push(id)
485 } else {
486 if (!children.has(parentId)) {
487 children.set(parentId, [])
488 }
489 children.get(parentId)!.push(id)
490 }
491 }
492
493 return { root, children }
494}
495
496/**
497 * Normalizes node positions to start from a given padding offset.

Callers 6

applyTargetedLayoutFunction · 0.90
applyAutoLayoutFunction · 0.90
layoutContainersFunction · 0.90
resolveNoteOverlapsFunction · 0.85
calculateSubflowDepthsFunction · 0.85

Calls 3

setMethod · 0.65
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected