MCPcopy Index your code
hub / github.com/simstudioai/sim / normalizeWorkflowVariables

Function normalizeWorkflowVariables

apps/sim/lib/core/utils/records.ts:54–80  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

52 * legacy and imported snapshots can carry an array of variable objects.
53 */
54export function normalizeWorkflowVariables(value: unknown): UnknownRecord {
55 if (isPlainRecord(value)) {
56 return value
57 }
58
59 if (!Array.isArray(value)) {
60 return {}
61 }
62
63 const normalized: UnknownRecord = {}
64 for (const variable of value) {
65 if (!isPlainRecord(variable)) {
66 continue
67 }
68
69 const id = typeof variable.id === 'string' && variable.id.trim() ? variable.id : undefined
70 const name =
71 typeof variable.name === 'string' && variable.name.trim() ? variable.name : undefined
72 const key = id ?? name
73
74 if (key) {
75 normalized[key] = variable
76 }
77 }
78
79 return normalized
80}

Callers 10

execute.tsFile · 0.90
prepareToolExecutionFunction · 0.90
records.test.tsFile · 0.90
executeMethod · 0.90
buildProviderRequestMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90

Calls 1

isPlainRecordFunction · 0.90

Tested by

no test coverage detected