|  | @ -1,9 +1,9 @@ | 
			
		
	
		
		
			
				
					|  |  | import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; |  |  | import { ConfigurationService } from '@ghostfolio/api/services/configuration/configuration.service'; | 
			
		
	
		
		
			
				
					|  |  | import { DataEnhancerInterface } from '@ghostfolio/api/services/data-provider/interfaces/data-enhancer.interface'; |  |  | import { DataEnhancerInterface } from '@ghostfolio/api/services/data-provider/interfaces/data-enhancer.interface'; | 
			
		
	
		
		
			
				
					|  |  | import { parseSymbol } from '@ghostfolio/common/helper'; |  |  | import { parseSymbol } from '@ghostfolio/common/helper'; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import { Injectable } from '@nestjs/common'; |  |  | import { Injectable } from '@nestjs/common'; | 
			
		
	
		
		
			
				
					|  |  | import { SymbolProfile } from '@prisma/client'; |  |  | import { SymbolProfile } from '@prisma/client'; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import OpenFIGI from 'openfigi'; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | @Injectable() |  |  | @Injectable() | 
			
		
	
		
		
			
				
					|  |  | export class OpenFigiDataEnhancerService implements DataEnhancerInterface { |  |  | export class OpenFigiDataEnhancerService implements DataEnhancerInterface { | 
			
		
	
	
		
		
			
				
					|  | @ -31,46 +31,40 @@ export class OpenFigiDataEnhancerService implements DataEnhancerInterface { | 
			
		
	
		
		
			
				
					|  |  |       return response; |  |  |       return response; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     const headers: HeadersInit = {}; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |     const { exchange, ticker } = parseSymbol({ |  |  |     const { exchange, ticker } = parseSymbol({ | 
			
		
	
		
		
			
				
					|  |  |       symbol, |  |  |       symbol, | 
			
		
	
		
		
			
				
					|  |  |       dataSource: response.dataSource |  |  |       dataSource: response.dataSource | 
			
		
	
		
		
			
				
					|  |  |     }); |  |  |     }); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     if (this.configurationService.get('API_KEY_OPEN_FIGI')) { |  |  |     const openfigi = new OpenFIGI({ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       headers['X-OPENFIGI-APIKEY'] = |  |  |       apiKey: this.configurationService.get('API_KEY_OPEN_FIGI') || undefined | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         this.configurationService.get('API_KEY_OPEN_FIGI'); |  |  |     }); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |     } |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     const mappings = (await fetch( |  |  |     try { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       `${OpenFigiDataEnhancerService.baseUrl}/v3/mapping`, |  |  |       const mappings = await openfigi.mapping( | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         [ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             idType: 'TICKER', | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             idValue: ticker, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             exchCode: exchange | 
			
		
	
		
		
			
				
					|  |  |  |  |  |           } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ], | 
			
		
	
		
		
			
				
					|  |  |         { |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |         body: JSON.stringify([ |  |  |           fetchOptions: { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |           { exchCode: exchange, idType: 'TICKER', idValue: ticker } |  |  |             signal: AbortSignal.timeout(requestTimeout ?? 5000) | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         ]), |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         headers: { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           'Content-Type': 'application/json', |  |  |  | 
			
		
	
		
		
			
				
					|  |  |           ...headers |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         }, |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         method: 'POST', |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         signal: AbortSignal.timeout(requestTimeout) |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |           } |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |     ).then((res) => res.json())) as any[]; |  |  |         } | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |       ); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |       if (mappings?.length === 1 && mappings[0].data?.length === 1) { |  |  |       if (mappings?.length === 1 && mappings[0].data?.length === 1) { | 
			
		
	
		
		
			
				
					|  |  |         const { compositeFIGI, figi, shareClassFIGI } = mappings[0].data[0]; |  |  |         const { compositeFIGI, figi, shareClassFIGI } = mappings[0].data[0]; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |       if (figi) { |  |  |         if (figi) response.figi = figi; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         response.figi = figi; |  |  |         if (compositeFIGI) response.figiComposite = compositeFIGI; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |       } |  |  |         if (shareClassFIGI) response.figiShareClass = shareClassFIGI; | 
			
				
				
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       if (compositeFIGI) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         response.figiComposite = compositeFIGI; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |       if (shareClassFIGI) { |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         response.figiShareClass = shareClassFIGI; |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |       } |  |  |       } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } catch (error) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |       console.error('OpenFIGI mapping failed:', error); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     return response; |  |  |     return response; | 
			
		
	
	
		
		
			
				
					|  | 
 |