fixed up more type issues

This commit is contained in:
Boki 2025-06-20 09:51:32 -04:00
parent 3a10560de4
commit 87037e013f
9 changed files with 210 additions and 52 deletions

View file

@ -2,8 +2,11 @@
* Interactive Brokers Provider for new queue system
*/
import { getLogger } from '@stock-bot/logger';
import type { HandlerConfigWithSchedule } from '@stock-bot/queue';
import { handlerRegistry } from '@stock-bot/queue';
import {
createJobHandler,
handlerRegistry,
type HandlerConfigWithSchedule,
} from '@stock-bot/queue';
const logger = getLogger('ib-provider');
@ -14,14 +17,14 @@ export function initializeIBProvider() {
const ibProviderConfig: HandlerConfigWithSchedule = {
name: 'ib',
operations: {
'fetch-session': async _payload => {
'fetch-session': createJobHandler(async () => {
// payload contains session configuration (not used in current implementation)
logger.debug('Processing session fetch request');
const { fetchSession } = await import('./ib.tasks');
return fetchSession();
},
}),
'fetch-exchanges': async _payload => {
'fetch-exchanges': createJobHandler(async () => {
// payload should contain session headers
logger.debug('Processing exchanges fetch request');
const { fetchSession, fetchExchanges } = await import('./ib.tasks');
@ -30,9 +33,9 @@ export function initializeIBProvider() {
return fetchExchanges(sessionHeaders);
}
throw new Error('Failed to get session headers');
},
}),
'fetch-symbols': async _payload => {
'fetch-symbols': createJobHandler(async () => {
// payload should contain session headers
logger.debug('Processing symbols fetch request');
const { fetchSession, fetchSymbols } = await import('./ib.tasks');
@ -41,9 +44,9 @@ export function initializeIBProvider() {
return fetchSymbols(sessionHeaders);
}
throw new Error('Failed to get session headers');
},
}),
'ib-exchanges-and-symbols': async _payload => {
'ib-exchanges-and-symbols': createJobHandler(async () => {
// Legacy operation for scheduled jobs
logger.info('Fetching symbol summary from IB');
const { fetchSession, fetchExchanges, fetchSymbols } = await import('./ib.tasks');
@ -62,7 +65,8 @@ export function initializeIBProvider() {
return { exchangesCount: exchanges?.length, symbolsCount: symbols?.length };
}
},
return null;
}),
},
scheduledJobs: [
{