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

Function resolveCodeVariables

apps/sim/app/api/function/execute/route.ts:653–678  ·  view source on GitHub ↗

* Resolves environment variables and tags in code * @param code - Code with variables * @param params - Parameters that may contain variable values * @param envVars - Environment variables from the workflow * @returns Resolved code

(
  code: string,
  params: Record<string, unknown>,
  envVars: Record<string, string> = {},
  blockData: Record<string, unknown> = {},
  blockNameMapping: Record<string, string> = {},
  blockOutputSchemas: Record<string, OutputSchema> = {},
  workflowVariables: Record<string, unknown> = {},
  language = 'javascript'
)

Source from the content-addressed store, hash-verified

651 * @returns Resolved code
652 */
653function resolveCodeVariables(
654 code: string,
655 params: Record<string, unknown>,
656 envVars: Record<string, string> = {},
657 blockData: Record<string, unknown> = {},
658 blockNameMapping: Record<string, string> = {},
659 blockOutputSchemas: Record<string, OutputSchema> = {},
660 workflowVariables: Record<string, unknown> = {},
661 language = 'javascript'
662): { resolvedCode: string; contextVariables: Record<string, unknown> } {
663 let resolvedCode = code
664 const contextVariables: Record<string, unknown> = {}
665
666 resolvedCode = resolveWorkflowVariables(resolvedCode, workflowVariables, contextVariables)
667 resolvedCode = resolveEnvironmentVariables(resolvedCode, params, envVars, contextVariables)
668 resolvedCode = resolveTagVariables(
669 resolvedCode,
670 blockData,
671 blockNameMapping,
672 blockOutputSchemas,
673 contextVariables,
674 language
675 )
676
677 return { resolvedCode, contextVariables }
678}
679
680/**
681 * Remove one trailing newline from stdout

Callers 1

route.tsFile · 0.85

Calls 3

resolveWorkflowVariablesFunction · 0.85
resolveTagVariablesFunction · 0.85

Tested by

no test coverage detected