(workflow: SerializedWorkflow)
| 310 | } |
| 311 | |
| 312 | deserializeWorkflow(workflow: SerializedWorkflow): { |
| 313 | blocks: Record<string, BlockState> |
| 314 | edges: Edge[] |
| 315 | } { |
| 316 | const blocks: Record<string, BlockState> = {} |
| 317 | const edges: Edge[] = [] |
| 318 | |
| 319 | // Deserialize blocks |
| 320 | workflow.blocks.forEach((serializedBlock) => { |
| 321 | const block = this.deserializeBlock(serializedBlock) |
| 322 | blocks[block.id] = block |
| 323 | }) |
| 324 | |
| 325 | // Deserialize connections |
| 326 | workflow.connections.forEach((connection) => { |
| 327 | edges.push({ |
| 328 | id: generateId(), |
| 329 | source: connection.source, |
| 330 | target: connection.target, |
| 331 | sourceHandle: connection.sourceHandle, |
| 332 | targetHandle: connection.targetHandle, |
| 333 | }) |
| 334 | }) |
| 335 | |
| 336 | return { blocks, edges } |
| 337 | } |
| 338 | |
| 339 | private deserializeBlock(serializedBlock: SerializedBlock): BlockState { |
| 340 | const blockType = serializedBlock.metadata?.id |
no test coverage detected