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

Function createLoopWorkflow

packages/testing/src/factories/workflow.factory.ts:133–167  ·  view source on GitHub ↗
(iterations = 3)

Source from the content-addressed store, hash-verified

131 * ```
132 */
133export function createLoopWorkflow(iterations = 3): any {
134 const blocks: Record<string, any> = {
135 start: createStarterBlock({ id: 'start', position: { x: 0, y: 0 } }),
136 loop: createBlock({
137 id: 'loop',
138 type: 'loop',
139 name: 'Loop',
140 position: { x: 200, y: 0 },
141 data: { loopType: 'for', count: iterations, type: 'loop' },
142 }),
143 'loop-body': createFunctionBlock({
144 id: 'loop-body',
145 name: 'Loop Body',
146 position: { x: 50, y: 50 },
147 parentId: 'loop',
148 }),
149 end: createFunctionBlock({ id: 'end', name: 'End', position: { x: 500, y: 0 } }),
150 }
151
152 const edges: any[] = [
153 { id: 'e1', source: 'start', target: 'loop' },
154 { id: 'e2', source: 'loop', target: 'end' },
155 ]
156
157 const loops: Record<string, any> = {
158 loop: {
159 id: 'loop',
160 nodes: ['loop-body'],
161 iterations,
162 loopType: 'for',
163 },
164 }
165
166 return createWorkflowState({ blocks, edges, loops })
167}
168
169/**
170 * Creates a workflow with a parallel container.

Callers 1

Calls 4

createStarterBlockFunction · 0.90
createBlockFunction · 0.90
createFunctionBlockFunction · 0.90
createWorkflowStateFunction · 0.70

Tested by

no test coverage detected