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

Function sanitizeForExport

apps/sim/lib/workflows/sanitization/json-sanitizer.ts:581–605  ·  view source on GitHub ↗
(state: WorkflowState)

Source from the content-addressed store, hash-verified

579 * Users need positions to restore the visual layout when importing
580 */
581export 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}

Callers 6

exportWorkflowToJsonFunction · 0.90
exportWorkspaceToZipFunction · 0.90
exportFolderToZipFunction · 0.90
generateWorkflowJsonFunction · 0.90
route.tsFile · 0.90
exportWorkflowFunction · 0.90

Calls 3

generateLoopBlocksFunction · 0.90
generateParallelBlocksFunction · 0.90

Tested by

no test coverage detected