| 18 | } |
| 19 | |
| 20 | function createTestWorkflow( |
| 21 | loops: Record<string, LoopDef> = {}, |
| 22 | blockDefs: BlockDef[] = [], |
| 23 | parallels: Record<string, { id?: string; nodes: string[] }> = {} |
| 24 | ) { |
| 25 | const normalizedLoops: Record<string, { id: string; nodes: string[]; iterations: number }> = {} |
| 26 | for (const [key, loop] of Object.entries(loops)) { |
| 27 | normalizedLoops[key] = { |
| 28 | id: loop.id ?? key, |
| 29 | nodes: loop.nodes, |
| 30 | iterations: loop.iterations ?? 1, |
| 31 | ...(loop.loopType && { loopType: loop.loopType }), |
| 32 | } |
| 33 | } |
| 34 | const blocks = blockDefs.map((b) => ({ |
| 35 | id: b.id, |
| 36 | position: { x: 0, y: 0 }, |
| 37 | config: { tool: 'test', params: {} }, |
| 38 | inputs: {}, |
| 39 | outputs: {}, |
| 40 | metadata: { id: 'function', name: b.name }, |
| 41 | enabled: true, |
| 42 | })) |
| 43 | return { |
| 44 | version: '1.0', |
| 45 | blocks, |
| 46 | connections: [], |
| 47 | loops: normalizedLoops, |
| 48 | parallels, |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | function createLoopScope(overrides: Partial<LoopScope> = {}): LoopScope { |
| 53 | return { |