2828import { OBP_API_VERSION , get , isServerUp } from '../obp'
2929import { updateLoadingInfoMessage } from './common-functions'
3030
31- export const connectors = [
31+ // Connectors to exclude from message docs display
32+ const excludedConnectors = [ 'mapped' , 'star' , 'proxy' , 'internal' , 'cardano' , 'ethereum' ]
33+
34+ // Fallback list in case the API endpoint is unavailable
35+ const fallbackConnectors = [
3236 'akka_vDec2018' ,
3337 'rest_vMar2019' ,
3438 'stored_procedure_vDec2019' ,
3539 'rabbitmq_vOct2024'
3640]
3741
42+ // Fetch available connectors dynamically from the API
43+ export async function getConnectors ( ) : Promise < string [ ] > {
44+ try {
45+ const data = await get ( 'obp/v6.0.0/system/connectors' )
46+ if ( data && data . connectors && Array . isArray ( data . connectors ) ) {
47+ const connectorNames = data . connectors
48+ . map ( ( c : any ) => c . connector_name )
49+ . filter ( ( name : string ) => ! excludedConnectors . some ( exc => name === exc || name . startsWith ( exc + '_' ) ) )
50+ console . log ( 'Fetched connectors from API:' , connectorNames )
51+ return connectorNames
52+ }
53+ } catch ( error ) {
54+ console . warn ( 'Failed to fetch connectors from API, using fallback list:' , error )
55+ }
56+ return fallbackConnectors
57+ }
58+
3859// Get Message Docs
3960export async function getOBPMessageDocs ( item : string ) : Promise < any > {
4061 const logMessage = `Loading message docs { connector: ${ item } }`
@@ -131,6 +152,7 @@ export function getGroupedMessageDocsJsonSchema(docs: any): any {
131152}
132153
133154export async function cacheDoc ( cacheStorageOfMessageDocs : any ) : Promise < any > {
155+ const connectors = await getConnectors ( )
134156 const messageDocs = await connectors . reduce ( async ( agroup : any , connector : any ) => {
135157 const logMessage = `Caching message docs { connector: ${ connector } }`
136158 console . log ( logMessage )
@@ -151,6 +173,7 @@ async function getCacheDoc(cacheStorageOfMessageDocs: any): Promise<any> {
151173}
152174
153175export async function cacheDocJsonSchema ( cacheStorageOfMessageDocsJsonSchema : any ) : Promise < any > {
176+ const connectors = await getConnectors ( )
154177 const messageDocsJsonSchema = await connectors . reduce ( async ( agroup : any , connector : any ) => {
155178 const logMessage = `Caching message docs JSON schema { connector: ${ connector } }`
156179 console . log ( logMessage )
0 commit comments