mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-24 23:00:55 +03:00
5a37227d14
* markdown files and env examples cleanup * components update * update jsonlines description * server refractor * update telemetry * add execute custom node * add ui refractor * add username and password authenticate * correctly retrieve past images in agentflowv2 * disable e2e temporarily * add existing username and password authenticate * update migration to default workspace * update todo * blob storage migrating * throw error on agent tool call error * add missing execution import * add referral * chore: add error message when importData is undefined * migrate api keys to db * fix: data too long for column executionData * migrate api keys from json to db at init * add info on account setup * update docstore missing fields --------- Co-authored-by: chungyau97 <chungyau97@gmail.com>
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { StatusCodes } from 'http-status-codes'
|
|
import { ChatFlow } from '../database/entities/ChatFlow'
|
|
import { InternalFlowiseError } from '../errors/internalFlowiseError'
|
|
import { getRunningExpressApp } from '../utils/getRunningExpressApp'
|
|
import { getErrorMessage } from '../errors/utils'
|
|
|
|
export const addChatflowsCount = async (keys: any) => {
|
|
try {
|
|
const appServer = getRunningExpressApp()
|
|
let tmpResult = keys
|
|
if (typeof keys !== 'undefined' && keys.length > 0) {
|
|
const updatedKeys: any[] = []
|
|
//iterate through keys and get chatflows
|
|
for (const key of keys) {
|
|
const chatflows = await appServer.AppDataSource.getRepository(ChatFlow)
|
|
.createQueryBuilder('cf')
|
|
.where('cf.apikeyid = :apikeyid', { apikeyid: key.id })
|
|
.andWhere('cf.workspaceId = :workspaceId', { workspaceId: key.workspaceId })
|
|
.getMany()
|
|
const linkedChatFlows: any[] = []
|
|
chatflows.map((cf) => {
|
|
linkedChatFlows.push({
|
|
flowName: cf.name,
|
|
category: cf.category,
|
|
updatedDate: cf.updatedDate
|
|
})
|
|
})
|
|
key.chatFlows = linkedChatFlows
|
|
updatedKeys.push(key)
|
|
}
|
|
tmpResult = updatedKeys
|
|
}
|
|
return tmpResult
|
|
} catch (error) {
|
|
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error: addChatflowsCount - ${getErrorMessage(error)}`)
|
|
}
|
|
}
|