Merge branch 'main' into feature/Allow-ExecuteFlow-Variables

This commit is contained in:
Henry 2025-07-25 15:34:50 +01:00
commit 3daa6736c4
3 changed files with 18 additions and 7 deletions

View File

@ -25,6 +25,7 @@ import executionService, { ExecutionFilters } from '../executions'
import marketplacesService from '../marketplaces' import marketplacesService from '../marketplaces'
import toolsService from '../tools' import toolsService from '../tools'
import variableService from '../variables' import variableService from '../variables'
import { Platform } from '../../Interface'
type ExportInput = { type ExportInput = {
agentflow: boolean agentflow: boolean
@ -547,6 +548,8 @@ async function replaceDuplicateIdsForVariable(queryRunner: QueryRunner, original
const records = await queryRunner.manager.find(Variable, { const records = await queryRunner.manager.find(Variable, {
where: { id: In(ids) } where: { id: In(ids) }
}) })
if (getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD)
originalData.Variable = originalData.Variable.filter((variable) => variable.type !== 'runtime')
if (records.length < 0) return originalData if (records.length < 0) return originalData
for (let record of records) { for (let record of records) {
const oldId = record.id const oldId = record.id

View File

@ -6,11 +6,13 @@ import { getErrorMessage } from '../../errors/utils'
import { getAppVersion } from '../../utils' import { getAppVersion } from '../../utils'
import { QueryRunner } from 'typeorm' import { QueryRunner } from 'typeorm'
import { validate } from 'uuid' import { validate } from 'uuid'
import { Platform } from '../../Interface'
const createVariable = async (newVariable: Variable, orgId: string) => { const createVariable = async (newVariable: Variable, orgId: string) => {
const appServer = getRunningExpressApp()
if (appServer.identityManager.getPlatformType() === Platform.CLOUD && newVariable.type === 'runtime')
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Cloud platform does not support runtime variables!')
try { try {
const appServer = getRunningExpressApp()
const variable = await appServer.AppDataSource.getRepository(Variable).create(newVariable) const variable = await appServer.AppDataSource.getRepository(Variable).create(newVariable)
const dbResponse = await appServer.AppDataSource.getRepository(Variable).save(variable) const dbResponse = await appServer.AppDataSource.getRepository(Variable).save(variable)
await appServer.telemetry.sendTelemetry( await appServer.telemetry.sendTelemetry(
@ -87,8 +89,10 @@ const getVariableById = async (variableId: string) => {
} }
const updateVariable = async (variable: Variable, updatedVariable: Variable) => { const updateVariable = async (variable: Variable, updatedVariable: Variable) => {
const appServer = getRunningExpressApp()
if (appServer.identityManager.getPlatformType() === Platform.CLOUD && updatedVariable.type === 'runtime')
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'Cloud platform does not support runtime variables!')
try { try {
const appServer = getRunningExpressApp()
const tmpUpdatedVariable = await appServer.AppDataSource.getRepository(Variable).merge(variable, updatedVariable) const tmpUpdatedVariable = await appServer.AppDataSource.getRepository(Variable).merge(variable, updatedVariable)
const dbResponse = await appServer.AppDataSource.getRepository(Variable).save(tmpUpdatedVariable) const dbResponse = await appServer.AppDataSource.getRepository(Variable).save(tmpUpdatedVariable)
return dbResponse return dbResponse
@ -131,7 +135,7 @@ const importVariables = async (newVariables: Partial<Variable>[], queryRunner?:
}) })
// step 3 - remove ids that are only duplicate // step 3 - remove ids that are only duplicate
const prepVariables: Partial<Variable>[] = newVariables.map((newVariable) => { let prepVariables: Partial<Variable>[] = newVariables.map((newVariable) => {
let id: string = '' let id: string = ''
if (newVariable.id) id = newVariable.id if (newVariable.id) id = newVariable.id
if (foundIds.includes(id)) { if (foundIds.includes(id)) {
@ -141,6 +145,10 @@ const importVariables = async (newVariables: Partial<Variable>[], queryRunner?:
return newVariable return newVariable
}) })
// Filter out variables with type "runtime"
if (appServer.identityManager.getPlatformType() === Platform.CLOUD)
prepVariables = prepVariables.filter((variable) => variable.type !== 'runtime')
// step 4 - transactional insert array of entities // step 4 - transactional insert array of entities
const insertResponse = await repository.insert(prepVariables) const insertResponse = await repository.insert(prepVariables)

View File

@ -114,7 +114,7 @@ const AddEditVariableDialog = ({ show, dialogProps, onCancel, onConfirm, setErro
if (setError) setError(err) if (setError) setError(err)
enqueueSnackbar({ enqueueSnackbar({
message: `Failed to add new Variable: ${ message: `Failed to add new Variable: ${
typeof error.response.data === 'object' ? error.response.data.message : error.response.data typeof err.response.data === 'object' ? err.response.data.message : err.response.data
}`, }`,
options: { options: {
key: new Date().getTime() + Math.random(), key: new Date().getTime() + Math.random(),
@ -155,11 +155,11 @@ const AddEditVariableDialog = ({ show, dialogProps, onCancel, onConfirm, setErro
}) })
onConfirm(saveResp.data.id) onConfirm(saveResp.data.id)
} }
} catch (error) { } catch (err) {
if (setError) setError(err) if (setError) setError(err)
enqueueSnackbar({ enqueueSnackbar({
message: `Failed to save Variable: ${ message: `Failed to save Variable: ${
typeof error.response.data === 'object' ? error.response.data.message : error.response.data typeof err.response.data === 'object' ? err.response.data.message : err.response.data
}`, }`,
options: { options: {
key: new Date().getTime() + Math.random(), key: new Date().getTime() + Math.random(),