( subBlocks: Record<string, unknown> | undefined, values: Record<string, unknown> | undefined )
| 10 | * @returns Merged subblock structures with updated values |
| 11 | */ |
| 12 | export function mergeSubBlockValues( |
| 13 | subBlocks: Record<string, unknown> | undefined, |
| 14 | values: Record<string, unknown> | undefined |
| 15 | ): Record<string, unknown> { |
| 16 | const merged = { ...(subBlocks || {}) } as Record<string, any> |
| 17 | |
| 18 | if (!values) return merged |
| 19 | |
| 20 | Object.entries(values).forEach(([subBlockId, value]) => { |
| 21 | if (merged[subBlockId] && typeof merged[subBlockId] === 'object') { |
| 22 | merged[subBlockId] = { |
| 23 | ...(merged[subBlockId] as Record<string, unknown>), |
| 24 | value, |
| 25 | } |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | merged[subBlockId] = { |
| 30 | id: subBlockId, |
| 31 | type: DEFAULT_SUBBLOCK_TYPE, |
| 32 | value, |
| 33 | } |
| 34 | }) |
| 35 | |
| 36 | return merged |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Merges workflow block states with explicit subblock values while maintaining block structure. |
no outgoing calls
no test coverage detected