MCPcopy
hub / github.com/FlowiseAI/Flowise / createVariable

Function createVariable

packages/server/src/services/variables/index.ts:11–33  ·  view source on GitHub ↗
(newVariable: Variable, orgId: string)

Source from the content-addressed store, hash-verified

9import { Platform } from '../../Interface'
10
11const createVariable = async (newVariable: Variable, orgId: string) => {
12 const appServer = getRunningExpressApp()
13 if (appServer.identityManager.getPlatformType() === Platform.CLOUD && newVariable.type === 'runtime')
14 throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Cloud platform does not support runtime variables!')
15 try {
16 const variable = await appServer.AppDataSource.getRepository(Variable).create(newVariable)
17 const dbResponse = await appServer.AppDataSource.getRepository(Variable).save(variable)
18 await appServer.telemetry.sendTelemetry(
19 'variable_created',
20 {
21 version: await getAppVersion(),
22 variableType: variable.type
23 },
24 orgId
25 )
26 return dbResponse
27 } catch (error) {
28 throw new InternalFlowiseError(
29 StatusCodes.INTERNAL_SERVER_ERROR,
30 `Error: variablesServices.createVariable - ${getErrorMessage(error)}`
31 )
32 }
33}
34
35const deleteVariable = async (variableId: string, workspaceId: string): Promise<any> => {
36 try {

Callers

nothing calls this directly

Calls 5

getRunningExpressAppFunction · 0.90
getAppVersionFunction · 0.90
getErrorMessageFunction · 0.90
sendTelemetryMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected