fixed some lint issues

This commit is contained in:
Boki 2025-06-23 22:58:42 -04:00
parent 566f5dac92
commit 969cbad7ac
14 changed files with 99 additions and 29 deletions

View file

@ -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;

View file

@ -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<string, unknown>;
}
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',

View file

@ -3,7 +3,7 @@ import type { CeoHandler } from '../ceo.handler';
export async function updateUniqueSymbols(
this: CeoHandler,
_payload: unknown,
_context: any
_context: unknown
): Promise<unknown> {
this.logger.info('Starting update to get unique CEO symbols by ceoId');

View file

@ -47,7 +47,7 @@ export async function initializeAllHandlers(serviceContainer: IServiceContainer)
/**
* Manual fallback registration
*/
async function manualHandlerRegistration(_serviceContainer: any): Promise<void> {
async function manualHandlerRegistration(_serviceContainer: IServiceContainer): Promise<void> {
logger.warn('Falling back to manual handler registration');
try {

View file

@ -4,16 +4,25 @@
import type { IServiceContainer } from '@stock-bot/handlers';
export async function fetchExchanges(services: IServiceContainer): Promise<any[]> {
interface QMExchange {
_id?: string;
code: string;
name: string;
country: string;
currency: string;
timezone?: string;
}
export async function fetchExchanges(services: IServiceContainer): Promise<QMExchange[]> {
// Get exchanges from MongoDB
const exchanges = await services.mongodb.collection('qm_exchanges').find({}).toArray();
const exchanges = await services.mongodb.collection<QMExchange>('qm_exchanges').find({}).toArray();
return exchanges;
}
export async function getExchangeByCode(services: IServiceContainer, code: string): Promise<any> {
export async function getExchangeByCode(services: IServiceContainer, code: string): Promise<QMExchange | null> {
// Get specific exchange by code
const exchange = await services.mongodb.collection('qm_exchanges').findOne({ code });
const exchange = await services.mongodb.collection<QMExchange>('qm_exchanges').findOne({ code });
return exchange;
}

View file

@ -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();

View file

@ -4,16 +4,26 @@
import type { IServiceContainer } from '@stock-bot/handlers';
export async function searchSymbols(services: IServiceContainer): Promise<any[]> {
interface QMSymbol {
_id?: string;
symbol: string;
name: string;
exchange: string;
type?: string;
sector?: string;
industry?: string;
}
export async function searchSymbols(services: IServiceContainer): Promise<QMSymbol[]> {
// Get symbols from MongoDB
const symbols = await services.mongodb.collection('qm_symbols').find({}).limit(50).toArray();
const symbols = await services.mongodb.collection<QMSymbol>('qm_symbols').find({}).limit(50).toArray();
return symbols;
}
export async function fetchSymbolData(services: IServiceContainer, symbol: string): Promise<any> {
export async function fetchSymbolData(services: IServiceContainer, symbol: string): Promise<QMSymbol | null> {
// Fetch data for a specific symbol
const symbolData = await services.mongodb.collection('qm_symbols').findOne({ symbol });
const symbolData = await services.mongodb.collection<QMSymbol>('qm_symbols').findOne({ symbol });
return symbolData;
}

View file

@ -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()

View file

@ -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<any> {
): Promise<ExchangeStats> {
logger.info('Getting exchange statistics...');
try {

View file

@ -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<any> {
): Promise<ProviderMappingStats[]> {
logger.info('Getting provider mapping statistics...');
try {

View file

@ -53,13 +53,30 @@ export async function syncQMExchanges(
}
// Helper functions
async function findExchange(exchangeCode: string, postgresClient: any): Promise<any> {
interface Exchange {
id: string;
code: string;
name: string;
country: string;
currency: string;
visible: boolean;
}
async function findExchange(exchangeCode: string, postgresClient: IServiceContainer['postgres']): Promise<Exchange | null> {
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<void> {
interface QMExchange {
exchangeCode?: string;
exchange?: string;
exchangeShortName?: string;
name?: string;
countryCode?: string;
}
async function createExchange(qmExchange: QMExchange, postgresClient: IServiceContainer['postgres']): Promise<void> {
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<voi
async function updateExchange(
exchangeId: string,
qmExchange: any,
postgresClient: any
qmExchange: QMExchange,
postgresClient: IServiceContainer['postgres']
): Promise<void> {
const query = `
UPDATE exchanges
@ -99,7 +116,7 @@ async function updateSyncStatus(
provider: string,
dataType: string,
count: number,
postgresClient: any
postgresClient: IServiceContainer['postgres']
): Promise<void> {
const query = `
UPDATE sync_status

View file

@ -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';

View file

@ -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 = {}
) {

View file

@ -8,7 +8,6 @@ import type {
QueueOptions,
QueueStats,
RateLimitRule,
RedisConfig,
} from './types';
import { getRedisConnection } from './utils';