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

Function convertLoopBlockToLoop

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

Source from the content-addressed store, hash-verified

73 * @returns Loop object for execution engine or undefined if not a valid loop
74 */
75export function convertLoopBlockToLoop(
76 loopBlockId: string,
77 blocks: Record<string, BlockState>
78): Loop | undefined {
79 const loopBlock = blocks[loopBlockId]
80 if (!loopBlock || loopBlock.type !== 'loop') return undefined
81
82 const loopType = loopBlock.data?.loopType || 'for'
83
84 const loop: Loop = {
85 id: loopBlockId,
86 nodes: findChildNodes(loopBlockId, blocks),
87 iterations: loopBlock.data?.count || DEFAULT_LOOP_ITERATIONS,
88 loopType,
89 enabled: loopBlock.enabled,
90 }
91
92 loop.forEachItems = loopBlock.data?.collection || ''
93 loop.whileCondition = loopBlock.data?.whileCondition || ''
94 loop.doWhileCondition = loopBlock.data?.doWhileCondition || ''
95
96 return loop
97}
98
99/**
100 * Convert UI parallel block to executor Parallel format

Callers 2

utils.test.tsFile · 0.90
generateLoopBlocksFunction · 0.70

Calls 1

findChildNodesFunction · 0.70

Tested by

no test coverage detected