(blockCount: number, spacing = 200)
| 48 | * ``` |
| 49 | */ |
| 50 | export function createLinearWorkflow(blockCount: number, spacing = 200): any { |
| 51 | if (blockCount < 1) { |
| 52 | return createWorkflowState() |
| 53 | } |
| 54 | |
| 55 | const blocks: Record<string, any> = {} |
| 56 | const blockIds: string[] = [] |
| 57 | |
| 58 | for (let i = 0; i < blockCount; i++) { |
| 59 | const id = `block-${i}` |
| 60 | blockIds.push(id) |
| 61 | |
| 62 | if (i === 0) { |
| 63 | blocks[id] = createStarterBlock({ |
| 64 | id, |
| 65 | position: { x: i * spacing, y: 0 }, |
| 66 | }) |
| 67 | } else { |
| 68 | blocks[id] = createFunctionBlock({ |
| 69 | id, |
| 70 | name: `Step ${i}`, |
| 71 | position: { x: i * spacing, y: 0 }, |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return createWorkflowState({ |
| 77 | blocks, |
| 78 | edges: createLinearEdges(blockIds), |
| 79 | }) |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Creates a workflow with a branching condition. |
no test coverage detected