1- import { cloneDeep , omit } from 'lodash'
2- import { StatusCodes } from 'http-status-codes'
3- import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
4- import { INodeData , MODE } from '../../Interface'
51import { ClientType , INodeOptionsValue } from 'flowise-components'
6- import { databaseEntities } from '../../utils '
7- import logger from '../../utils/logger '
2+ import { StatusCodes } from 'http-status-codes '
3+ import { cloneDeep , omit } from 'lodash '
84import { InternalFlowiseError } from '../../errors/internalFlowiseError'
95import { getErrorMessage } from '../../errors/utils'
6+ import { INodeData , MODE } from '../../Interface'
7+ import { databaseEntities } from '../../utils'
108import { OMIT_QUEUE_JOB_DATA } from '../../utils/constants'
119import { executeCustomNodeFunction } from '../../utils/executeCustomNodeFunction'
10+ import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
11+ import logger from '../../utils/logger'
12+ import credentialsService from '../credentials'
1213import { filterNodeByClient } from './filterNodeByClient'
1314
1415export { filterNodeByClient }
@@ -91,11 +92,15 @@ const getSingleNodeIcon = async (nodeName: string) => {
9192 }
9293}
9394
94- const getSingleNodeAsyncOptions = async ( nodeName : string , requestBody : any ) : Promise < any > => {
95+ const getSingleNodeAsyncOptions = async ( nodeName : string , requestBody : any , workspaceId ?: string ) : Promise < any > => {
9596 try {
9697 const appServer = getRunningExpressApp ( )
9798 const nodeData : INodeData = requestBody
9899 if ( Object . prototype . hasOwnProperty . call ( appServer . nodesPool . componentNodes , nodeName ) ) {
100+ if ( nodeData . credential ) {
101+ await credentialsService . assertCredentialInWorkspace ( nodeData . credential , workspaceId )
102+ }
103+
99104 try {
100105 const nodeInstance = appServer . nodesPool . componentNodes [ nodeName ]
101106 const methodName = nodeData . loadMethod || ''
@@ -118,6 +123,9 @@ const getSingleNodeAsyncOptions = async (nodeName: string, requestBody: any): Pr
118123 throw new InternalFlowiseError ( StatusCodes . NOT_FOUND , `Node ${ nodeName } not found` )
119124 }
120125 } catch ( error ) {
126+ if ( error instanceof InternalFlowiseError ) {
127+ throw error
128+ }
121129 throw new InternalFlowiseError (
122130 StatusCodes . INTERNAL_SERVER_ERROR ,
123131 `Error: nodesService.getSingleNodeAsyncOptions - ${ getErrorMessage ( error ) } `
0 commit comments