parent
9839009823
commit
8a6b95ef0e
|
|
@ -943,10 +943,13 @@ export const getVars = async (
|
||||||
nodeData: INodeData,
|
nodeData: INodeData,
|
||||||
options: ICommonObject
|
options: ICommonObject
|
||||||
) => {
|
) => {
|
||||||
|
if (!options.workspaceId) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
const variables =
|
const variables =
|
||||||
((await appDataSource
|
((await appDataSource
|
||||||
.getRepository(databaseEntities['Variable'])
|
.getRepository(databaseEntities['Variable'])
|
||||||
.findBy(options.workspaceId ? { workspaceId: Equal(options.workspaceId) } : {})) as IVariable[]) ?? []
|
.findBy({ workspaceId: Equal(options.workspaceId) })) as IVariable[]) ?? []
|
||||||
|
|
||||||
// override variables defined in overrideConfig
|
// override variables defined in overrideConfig
|
||||||
// nodeData.inputs.vars is an Object, check each property and override the variable
|
// nodeData.inputs.vars is an Object, check each property and override the variable
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@ const executeCustomFunction = async (req: Request, res: Response, next: NextFunc
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const orgId = req.user?.activeOrganizationId
|
const orgId = req.user?.activeOrganizationId
|
||||||
const apiResponse = await nodesService.executeCustomFunction(req.body, orgId)
|
const workspaceId = req.user?.activeWorkspaceId
|
||||||
|
const apiResponse = await nodesService.executeCustomFunction(req.body, workspaceId, orgId)
|
||||||
return res.json(apiResponse)
|
return res.json(apiResponse)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error)
|
next(error)
|
||||||
|
|
|
||||||
|
|
@ -122,14 +122,15 @@ const getSingleNodeAsyncOptions = async (nodeName: string, requestBody: any): Pr
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute custom function node
|
// execute custom function node
|
||||||
const executeCustomFunction = async (requestBody: any, orgId?: string) => {
|
const executeCustomFunction = async (requestBody: any, workspaceId?: string, orgId?: string) => {
|
||||||
const appServer = getRunningExpressApp()
|
const appServer = getRunningExpressApp()
|
||||||
const executeData = {
|
const executeData = {
|
||||||
appDataSource: appServer.AppDataSource,
|
appDataSource: appServer.AppDataSource,
|
||||||
componentNodes: appServer.nodesPool.componentNodes,
|
componentNodes: appServer.nodesPool.componentNodes,
|
||||||
data: requestBody,
|
data: requestBody,
|
||||||
isExecuteCustomFunction: true,
|
isExecuteCustomFunction: true,
|
||||||
orgId
|
orgId,
|
||||||
|
workspaceId
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.MODE === MODE.QUEUE) {
|
if (process.env.MODE === MODE.QUEUE) {
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,7 @@ const buildAndInitTool = async (chatflowid: string, _chatId?: string, _apiMessag
|
||||||
chatflowid,
|
chatflowid,
|
||||||
chatId,
|
chatId,
|
||||||
orgId,
|
orgId,
|
||||||
|
workspaceId,
|
||||||
appDataSource: appServer.AppDataSource,
|
appDataSource: appServer.AppDataSource,
|
||||||
databaseEntities,
|
databaseEntities,
|
||||||
analytic: chatflow.analytic
|
analytic: chatflow.analytic
|
||||||
|
|
|
||||||
|
|
@ -750,6 +750,8 @@ export const executeFlow = async ({
|
||||||
rawOutput: resultText,
|
rawOutput: resultText,
|
||||||
appDataSource,
|
appDataSource,
|
||||||
databaseEntities,
|
databaseEntities,
|
||||||
|
workspaceId,
|
||||||
|
orgId,
|
||||||
logger
|
logger
|
||||||
}
|
}
|
||||||
const customFuncNodeInstance = new nodeModule.nodeClass()
|
const customFuncNodeInstance = new nodeModule.nodeClass()
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ export const createFileAttachment = async (req: Request) => {
|
||||||
const options = {
|
const options = {
|
||||||
retrieveAttachmentChatId: true,
|
retrieveAttachmentChatId: true,
|
||||||
orgId,
|
orgId,
|
||||||
|
workspaceId,
|
||||||
chatflowid,
|
chatflowid,
|
||||||
chatId
|
chatId
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,15 @@ import { IComponentNodes } from '../Interface'
|
||||||
export const executeCustomNodeFunction = async ({
|
export const executeCustomNodeFunction = async ({
|
||||||
appDataSource,
|
appDataSource,
|
||||||
componentNodes,
|
componentNodes,
|
||||||
data
|
data,
|
||||||
|
workspaceId,
|
||||||
|
orgId
|
||||||
}: {
|
}: {
|
||||||
appDataSource: DataSource
|
appDataSource: DataSource
|
||||||
componentNodes: IComponentNodes
|
componentNodes: IComponentNodes
|
||||||
data: any
|
data: any
|
||||||
|
workspaceId?: string
|
||||||
|
orgId?: string
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
const body = data
|
const body = data
|
||||||
|
|
@ -37,7 +41,9 @@ export const executeCustomNodeFunction = async ({
|
||||||
|
|
||||||
const options: ICommonObject = {
|
const options: ICommonObject = {
|
||||||
appDataSource,
|
appDataSource,
|
||||||
databaseEntities
|
databaseEntities,
|
||||||
|
workspaceId,
|
||||||
|
orgId
|
||||||
}
|
}
|
||||||
|
|
||||||
const returnData = await newNodeInstance.init(nodeData, '', options)
|
const returnData = await newNodeInstance.init(nodeData, '', options)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue