(newVariable: Variable, orgId: string)
| 9 | import { Platform } from '../../Interface' |
| 10 | |
| 11 | const 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 | |
| 35 | const deleteVariable = async (variableId: string, workspaceId: string): Promise<any> => { |
| 36 | try { |
nothing calls this directly
no test coverage detected