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

Function add

apps/sim/lib/workflows/blocks/flatten-outputs.ts:90–118  ·  view source on GitHub ↗
(path: string, outputObj: unknown, prefix = '')

Source from the content-addressed store, hash-verified

88
89 const blockName = block.name || `Block ${block.id}`
90 const add = (path: string, outputObj: unknown, prefix = ''): void => {
91 const fullPath = prefix ? `${prefix}.${path}` : path
92 const declaredType =
93 outputObj &&
94 typeof outputObj === 'object' &&
95 !Array.isArray(outputObj) &&
96 'type' in (outputObj as object) &&
97 typeof (outputObj as { type: unknown }).type === 'string'
98 ? (outputObj as { type: string }).type
99 : undefined
100 const isLeaf =
101 typeof outputObj !== 'object' ||
102 outputObj === null ||
103 declaredType !== undefined ||
104 Array.isArray(outputObj)
105 if (isLeaf) {
106 results.push({
107 blockId: block.id,
108 blockName,
109 blockType: block.type,
110 path: fullPath,
111 leafType: declaredType,
112 })
113 return
114 }
115 for (const [key, value] of Object.entries(outputObj as Record<string, unknown>)) {
116 add(key, value, fullPath)
117 }
118 }
119
120 for (const [key, value] of Object.entries(outs)) add(key, value)
121 }

Callers 1

flattenWorkflowOutputsFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected