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

Function updateValueReferences

apps/sim/stores/workflows/utils.ts:285–305  ·  view source on GitHub ↗
(value: unknown, nameMap: Map<string, string>)

Source from the content-addressed store, hash-verified

283}
284
285function updateValueReferences(value: unknown, nameMap: Map<string, string>): unknown {
286 if (typeof value === 'string') {
287 let updatedValue = value
288 nameMap.forEach((newName, oldName) => {
289 const regex = new RegExp(`<${oldName}\\.`, 'g')
290 updatedValue = updatedValue.replace(regex, `<${newName}.`)
291 })
292 return updatedValue
293 }
294 if (Array.isArray(value)) {
295 return value.map((item) => updateValueReferences(item, nameMap))
296 }
297 if (value && typeof value === 'object') {
298 const result: Record<string, unknown> = {}
299 for (const [key, val] of Object.entries(value)) {
300 result[key] = updateValueReferences(val, nameMap)
301 }
302 return result
303 }
304 return value
305}
306
307function updateBlockReferences(
308 blocks: Record<string, BlockState>,

Callers 2

updateBlockReferencesFunction · 0.85
regenerateBlockIdsFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected