(
appDataSource: DataSource,
databaseEntities: IDatabaseEntity,
nodeData: INodeData,
options: ICommonObject
)
| 974 | * @param {INodeData} nodeData |
| 975 | */ |
| 976 | export 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 |
no outgoing calls
no test coverage detected