MCPcopy Index your code
hub / github.com/simstudioai/sim / parseWorkflowStateJson

Function parseWorkflowStateJson

apps/sim/lib/workflows/diff/diff-engine.ts:14–36  ·  view source on GitHub ↗
(jsonContent: string)

Source from the content-addressed store, hash-verified

12const logger = createLogger('WorkflowDiffEngine')
13
14function parseWorkflowStateJson(jsonContent: string): WorkflowState {
15 const parsed = JSON.parse(jsonContent) as unknown
16 if (!parsed || typeof parsed !== 'object') {
17 throw new Error('Diff content must be a workflow state object')
18 }
19
20 const candidate = parsed as Partial<WorkflowState>
21 if (
22 !candidate.blocks ||
23 typeof candidate.blocks !== 'object' ||
24 Array.isArray(candidate.blocks) ||
25 !Array.isArray(candidate.edges)
26 ) {
27 throw new Error('Diff content is missing workflow blocks or edges')
28 }
29
30 return {
31 blocks: candidate.blocks,
32 edges: candidate.edges,
33 loops: candidate.loops ?? {},
34 parallels: candidate.parallels ?? {},
35 }
36}
37
38// Helper function to check if a block has changed
39function hasBlockChanged(currentBlock: BlockState, proposedBlock: BlockState): boolean {

Callers 2

createDiffMethod · 0.85
mergeDiffMethod · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected