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

Function mergeSubBlockValues

packages/workflow-persistence/src/subblocks.ts:12–37  ·  view source on GitHub ↗
(
  subBlocks: Record<string, unknown> | undefined,
  values: Record<string, unknown> | undefined
)

Source from the content-addressed store, hash-verified

10 * @returns Merged subblock structures with updated values
11 */
12export 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.

Callers 2

handleBlocksOperationTxFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected