(state: WorkflowState)
| 579 | * Users need positions to restore the visual layout when importing |
| 580 | */ |
| 581 | export function sanitizeForExport(state: WorkflowState): ExportWorkflowState { |
| 582 | const canonicalLoops = generateLoopBlocks(state.blocks || {}) |
| 583 | const canonicalParallels = generateParallelBlocks(state.blocks || {}) |
| 584 | |
| 585 | // Preserve edges, loops, parallels, metadata, and variables |
| 586 | const fullState = { |
| 587 | blocks: state.blocks, |
| 588 | edges: state.edges, |
| 589 | loops: canonicalLoops, |
| 590 | parallels: canonicalParallels, |
| 591 | metadata: state.metadata, |
| 592 | variables: state.variables, |
| 593 | } |
| 594 | |
| 595 | // Use unified sanitization with env var preservation for export |
| 596 | const sanitizedState = sanitizeWorkflowForSharing(fullState, { |
| 597 | preserveEnvVars: true, // Keep {{ENV_VAR}} references in exported workflows |
| 598 | }) as ExportWorkflowState['state'] |
| 599 | |
| 600 | return { |
| 601 | version: '1.0', |
| 602 | exportedAt: new Date().toISOString(), |
| 603 | state: sanitizedState, |
| 604 | } |
| 605 | } |
no test coverage detected