diff --git a/apps/stock/config/src/config-instance.ts b/apps/stock/config/src/config-instance.ts index 5c33725..ddbe6f8 100644 --- a/apps/stock/config/src/config-instance.ts +++ b/apps/stock/config/src/config-instance.ts @@ -34,10 +34,11 @@ export function initializeStockConfig(serviceName?: 'dataIngestion' | 'dataPipel } return config; - } catch (error: any) { + } catch (error) { const logger = getLogger('stock-config'); - logger.error('Failed to initialize stock configuration:', error.message); - if (error.errors) { + const errorMessage = error instanceof Error ? error.message : String(error); + logger.error('Failed to initialize stock configuration:', errorMessage); + if (error && typeof error === 'object' && 'errors' in error) { logger.error('Validation errors:', error.errors); } throw error; diff --git a/apps/stock/data-ingestion/src/handlers/ceo/actions/update-ceo-channels.action.ts b/apps/stock/data-ingestion/src/handlers/ceo/actions/update-ceo-channels.action.ts index d0be435..0da74ee 100644 --- a/apps/stock/data-ingestion/src/handlers/ceo/actions/update-ceo-channels.action.ts +++ b/apps/stock/data-ingestion/src/handlers/ceo/actions/update-ceo-channels.action.ts @@ -32,9 +32,23 @@ export async function updateCeoChannels( const totalChannels = results.channel_categories[0].total_channels; const totalPages = Math.ceil(totalChannels / channels.length); const exchanges: { exchange: string; countryCode: string }[] = []; - const symbols = channels.map((channel: any) => { + interface Channel { + symbol: string; + exchange: string; + title: string; + type: string; + channel: string; + spiel_count: number; + unread_count: number; + is_following: boolean; + last_viewed_timestamp: string; + last_timestamp: string; + company_details?: Record; + } + + const symbols = channels.map((channel: Channel) => { // check if exchange is in the exchanges array object - if (!exchanges.find((e: any) => e.exchange === channel.exchange)) { + if (!exchanges.find((e) => e.exchange === channel.exchange)) { exchanges.push({ exchange: channel.exchange, countryCode: 'CA', diff --git a/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts b/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts index 024e104..1a6ff82 100644 --- a/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts +++ b/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts @@ -3,7 +3,7 @@ import type { CeoHandler } from '../ceo.handler'; export async function updateUniqueSymbols( this: CeoHandler, _payload: unknown, - _context: any + _context: unknown ): Promise { this.logger.info('Starting update to get unique CEO symbols by ceoId'); diff --git a/apps/stock/data-ingestion/src/handlers/index.ts b/apps/stock/data-ingestion/src/handlers/index.ts index c0b97be..24686af 100644 --- a/apps/stock/data-ingestion/src/handlers/index.ts +++ b/apps/stock/data-ingestion/src/handlers/index.ts @@ -47,7 +47,7 @@ export async function initializeAllHandlers(serviceContainer: IServiceContainer) /** * Manual fallback registration */ -async function manualHandlerRegistration(_serviceContainer: any): Promise { +async function manualHandlerRegistration(_serviceContainer: IServiceContainer): Promise { logger.warn('Falling back to manual handler registration'); try { diff --git a/apps/stock/data-ingestion/src/handlers/qm/actions/exchanges.action.ts b/apps/stock/data-ingestion/src/handlers/qm/actions/exchanges.action.ts index 8e7a04b..dcc0018 100644 --- a/apps/stock/data-ingestion/src/handlers/qm/actions/exchanges.action.ts +++ b/apps/stock/data-ingestion/src/handlers/qm/actions/exchanges.action.ts @@ -4,16 +4,25 @@ import type { IServiceContainer } from '@stock-bot/handlers'; -export async function fetchExchanges(services: IServiceContainer): Promise { +interface QMExchange { + _id?: string; + code: string; + name: string; + country: string; + currency: string; + timezone?: string; +} + +export async function fetchExchanges(services: IServiceContainer): Promise { // Get exchanges from MongoDB - const exchanges = await services.mongodb.collection('qm_exchanges').find({}).toArray(); + const exchanges = await services.mongodb.collection('qm_exchanges').find({}).toArray(); return exchanges; } -export async function getExchangeByCode(services: IServiceContainer, code: string): Promise { +export async function getExchangeByCode(services: IServiceContainer, code: string): Promise { // Get specific exchange by code - const exchange = await services.mongodb.collection('qm_exchanges').findOne({ code }); + const exchange = await services.mongodb.collection('qm_exchanges').findOne({ code }); return exchange; } diff --git a/apps/stock/data-ingestion/src/handlers/qm/actions/session.action.ts b/apps/stock/data-ingestion/src/handlers/qm/actions/session.action.ts index 99fc9e7..58eef50 100644 --- a/apps/stock/data-ingestion/src/handlers/qm/actions/session.action.ts +++ b/apps/stock/data-ingestion/src/handlers/qm/actions/session.action.ts @@ -41,9 +41,14 @@ export async function checkSessions(handler: BaseHandler): Promise<{ /** * Create a single session for a specific session ID */ +interface CreateSessionInput { + sessionId?: string; + sessionType?: string; +} + export async function createSingleSession( handler: BaseHandler, - input: any + input: CreateSessionInput ): Promise<{ sessionId: string; status: string; sessionType: string }> { const { sessionId: _sessionId, sessionType } = input || {}; const _sessionManager = QMSessionManager.getInstance(); diff --git a/apps/stock/data-ingestion/src/handlers/qm/actions/symbols.action.ts b/apps/stock/data-ingestion/src/handlers/qm/actions/symbols.action.ts index 54f004c..493b402 100644 --- a/apps/stock/data-ingestion/src/handlers/qm/actions/symbols.action.ts +++ b/apps/stock/data-ingestion/src/handlers/qm/actions/symbols.action.ts @@ -4,16 +4,26 @@ import type { IServiceContainer } from '@stock-bot/handlers'; -export async function searchSymbols(services: IServiceContainer): Promise { +interface QMSymbol { + _id?: string; + symbol: string; + name: string; + exchange: string; + type?: string; + sector?: string; + industry?: string; +} + +export async function searchSymbols(services: IServiceContainer): Promise { // Get symbols from MongoDB - const symbols = await services.mongodb.collection('qm_symbols').find({}).limit(50).toArray(); + const symbols = await services.mongodb.collection('qm_symbols').find({}).limit(50).toArray(); return symbols; } -export async function fetchSymbolData(services: IServiceContainer, symbol: string): Promise { +export async function fetchSymbolData(services: IServiceContainer, symbol: string): Promise { // Fetch data for a specific symbol - const symbolData = await services.mongodb.collection('qm_symbols').findOne({ symbol }); + const symbolData = await services.mongodb.collection('qm_symbols').findOne({ symbol }); return symbolData; } diff --git a/apps/stock/data-ingestion/src/index.ts b/apps/stock/data-ingestion/src/index.ts index c43f97a..a42ca94 100644 --- a/apps/stock/data-ingestion/src/index.ts +++ b/apps/stock/data-ingestion/src/index.ts @@ -3,7 +3,7 @@ * Simplified entry point using ServiceApplication framework */ -import { initializeStockConfig } from '@stock-bot/stock-config'; +import { initializeStockConfig, type StockAppConfig } from '@stock-bot/stock-config'; import { ServiceApplication, } from '@stock-bot/di'; @@ -52,7 +52,7 @@ const app = new ServiceApplication( ); // Container factory function -async function createContainer(config: any) { +async function createContainer(config: StockAppConfig) { const { ServiceContainerBuilder } = await import('@stock-bot/di'); const container = await new ServiceContainerBuilder() diff --git a/apps/stock/data-pipeline/src/handlers/exchanges/operations/exchange-stats.operations.ts b/apps/stock/data-pipeline/src/handlers/exchanges/operations/exchange-stats.operations.ts index eeb6c59..9745090 100644 --- a/apps/stock/data-pipeline/src/handlers/exchanges/operations/exchange-stats.operations.ts +++ b/apps/stock/data-pipeline/src/handlers/exchanges/operations/exchange-stats.operations.ts @@ -4,10 +4,17 @@ import type { JobPayload } from '../../../types/job-payloads'; const logger = getLogger('enhanced-sync-exchange-stats'); +interface ExchangeStats { + total_exchanges: string; + active_exchanges: string; + countries: string; + currencies: string; +} + export async function getExchangeStats( payload: JobPayload, container: IServiceContainer -): Promise { +): Promise { logger.info('Getting exchange statistics...'); try { diff --git a/apps/stock/data-pipeline/src/handlers/exchanges/operations/provider-mapping-stats.operations.ts b/apps/stock/data-pipeline/src/handlers/exchanges/operations/provider-mapping-stats.operations.ts index 3a1381a..394ddd8 100644 --- a/apps/stock/data-pipeline/src/handlers/exchanges/operations/provider-mapping-stats.operations.ts +++ b/apps/stock/data-pipeline/src/handlers/exchanges/operations/provider-mapping-stats.operations.ts @@ -4,10 +4,19 @@ import type { JobPayload } from '../../../types/job-payloads'; const logger = getLogger('enhanced-sync-provider-mapping-stats'); +interface ProviderMappingStats { + provider: string; + total_mappings: string; + active_mappings: string; + verified_mappings: string; + auto_mapped: string; + avg_confidence: string; +} + export async function getProviderMappingStats( payload: JobPayload, container: IServiceContainer -): Promise { +): Promise { logger.info('Getting provider mapping statistics...'); try { diff --git a/apps/stock/data-pipeline/src/handlers/exchanges/operations/qm-exchanges.operations.ts b/apps/stock/data-pipeline/src/handlers/exchanges/operations/qm-exchanges.operations.ts index 0715ab5..80963fd 100644 --- a/apps/stock/data-pipeline/src/handlers/exchanges/operations/qm-exchanges.operations.ts +++ b/apps/stock/data-pipeline/src/handlers/exchanges/operations/qm-exchanges.operations.ts @@ -53,13 +53,30 @@ export async function syncQMExchanges( } // Helper functions -async function findExchange(exchangeCode: string, postgresClient: any): Promise { +interface Exchange { + id: string; + code: string; + name: string; + country: string; + currency: string; + visible: boolean; +} + +async function findExchange(exchangeCode: string, postgresClient: IServiceContainer['postgres']): Promise { const query = 'SELECT * FROM exchanges WHERE code = $1'; const result = await postgresClient.query(query, [exchangeCode]); return result.rows[0] || null; } -async function createExchange(qmExchange: any, postgresClient: any): Promise { +interface QMExchange { + exchangeCode?: string; + exchange?: string; + exchangeShortName?: string; + name?: string; + countryCode?: string; +} + +async function createExchange(qmExchange: QMExchange, postgresClient: IServiceContainer['postgres']): Promise { const query = ` INSERT INTO exchanges (code, name, country, currency, visible) VALUES ($1, $2, $3, $4, $5) @@ -77,8 +94,8 @@ async function createExchange(qmExchange: any, postgresClient: any): Promise { const query = ` UPDATE exchanges @@ -99,7 +116,7 @@ async function updateSyncStatus( provider: string, dataType: string, count: number, - postgresClient: any + postgresClient: IServiceContainer['postgres'] ): Promise { const query = ` UPDATE sync_status diff --git a/libs/core/di/src/registrations/service.registration.ts b/libs/core/di/src/registrations/service.registration.ts index 6fe294f..a450395 100644 --- a/libs/core/di/src/registrations/service.registration.ts +++ b/libs/core/di/src/registrations/service.registration.ts @@ -1,7 +1,6 @@ import { asClass, asFunction, asValue, type AwilixContainer } from 'awilix'; import { Browser } from '@stock-bot/browser'; import { ProxyManager } from '@stock-bot/proxy'; -import { NamespacedCache } from '@stock-bot/cache'; import type { AppConfig } from '../config/schemas'; import type { ServiceDefinitions } from '../container/types'; diff --git a/libs/core/di/src/service-application.ts b/libs/core/di/src/service-application.ts index 1b2ce3c..e10c2a2 100644 --- a/libs/core/di/src/service-application.ts +++ b/libs/core/di/src/service-application.ts @@ -7,7 +7,7 @@ import { Hono } from 'hono'; import { cors } from 'hono/cors'; import { getLogger, setLoggerConfig, shutdownLoggers, type Logger } from '@stock-bot/logger'; import { Shutdown } from '@stock-bot/shutdown'; -import type { BaseAppConfig as StockBotAppConfig, UnifiedAppConfig } from '@stock-bot/config'; +import type { BaseAppConfig, UnifiedAppConfig } from '@stock-bot/config'; import { toUnifiedConfig } from '@stock-bot/config'; import type { IServiceContainer } from '@stock-bot/types'; import type { ServiceContainer } from './awilix-container'; @@ -78,7 +78,7 @@ export class ServiceApplication { private shutdown: Shutdown; constructor( - config: StockBotAppConfig | UnifiedAppConfig, + config: BaseAppConfig | UnifiedAppConfig, serviceConfig: ServiceApplicationConfig, hooks: ServiceLifecycleHooks = {} ) { diff --git a/libs/core/queue/src/queue-manager.ts b/libs/core/queue/src/queue-manager.ts index ad18385..2e46d1e 100644 --- a/libs/core/queue/src/queue-manager.ts +++ b/libs/core/queue/src/queue-manager.ts @@ -8,7 +8,6 @@ import type { QueueOptions, QueueStats, RateLimitRule, - RedisConfig, } from './types'; import { getRedisConnection } from './utils';