(jsonContent: string)
| 12 | const logger = createLogger('WorkflowDiffEngine') |
| 13 | |
| 14 | function 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 |
| 39 | function hasBlockChanged(currentBlock: BlockState, proposedBlock: BlockState): boolean { |
no test coverage detected