MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getVars

Function getVars

packages/components/src/utils.ts:976–1007  ·  view source on GitHub ↗
(
    appDataSource: DataSource,
    databaseEntities: IDatabaseEntity,
    nodeData: INodeData,
    options: ICommonObject
)

Source from the content-addressed store, hash-verified

974 * @param {INodeData} nodeData
975 */
976export const getVars = async (
977 appDataSource: DataSource,
978 databaseEntities: IDatabaseEntity,
979 nodeData: INodeData,
980 options: ICommonObject
981) => {
982 if (!options.workspaceId || options.skipVariables) {
983 return []
984 }
985 const variables =
986 ((await appDataSource
987 .getRepository(databaseEntities['Variable'])
988 .findBy({ workspaceId: Equal(options.workspaceId) })) as IVariable[]) ?? []
989
990 // override variables defined in overrideConfig
991 // nodeData.inputs.vars is an Object, check each property and override the variable
992 if (nodeData?.inputs?.vars) {
993 for (const propertyName of Object.getOwnPropertyNames(nodeData.inputs.vars)) {
994 const foundVar = variables.find((v) => v.name === propertyName)
995 if (foundVar) {
996 // even if the variable was defined as runtime, we override it with static value
997 foundVar.type = 'static'
998 foundVar.value = nodeData.inputs.vars[propertyName]
999 } else {
1000 // add it the variables, if not found locally in the db
1001 variables.push({ name: propertyName, type: 'static', value: nodeData.inputs.vars[propertyName] })
1002 }
1003 }
1004 }
1005
1006 return variables
1007}
1008
1009/**
1010 * Prepare sandbox variables

Callers 15

initMethod · 0.90
initMethod · 0.90
resolveVarsInStringMethod · 0.90
getToolsMethod · 0.90
checkMessageHistoryFunction · 0.90
executeFuncMethod · 0.90
runConditionFunction · 0.90
getReturnOutputFunction · 0.90
getReturnOutputFunction · 0.90
initMethod · 0.90
runConditionFunction · 0.90
executeFuncMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected