first refactor

This commit is contained in:
Boki 2026-10-20 12:39:38 -04:00
parent 1f5dac28c7
commit 588f666943
84 changed files with 996 additions and 1062 deletions

View file

@ -0,0 +1,61 @@
import type { Browser as BrowserImplementation } from '@stock-bot/browser';
import type { MongoDBClient as MongoDBImplementation } from '@stock-bot/mongodb';
import type { PostgreSQLClient as PostgresImplementation } from '@stock-bot/postgres';
import type { ProxyManager as ProxyImplementation } from '@stock-bot/proxy';
import type { QuestDBClient as QuestDBImplementation } from '@stock-bot/questdb';
import type {
Queue as QueueImplementation,
QueueManager as QueueManagerImplementation,
} from '@stock-bot/queue';
import type {
Browser,
IServiceContainer,
MongoDBClient,
PostgresClient,
ProxyManager,
QuestDBClient,
Queue,
QueueManager,
} from '../src';
// Implementations must remain assignable to the capabilities injected into consumers.
declare const implementations: {
browser: BrowserImplementation;
mongodb: MongoDBImplementation;
postgres: PostgresImplementation;
proxy: ProxyImplementation;
questdb: QuestDBImplementation;
queue: QueueImplementation;
queueManager: QueueManagerImplementation;
};
implementations satisfies {
browser: Browser;
mongodb: MongoDBClient;
postgres: PostgresClient;
proxy: ProxyManager;
questdb: QuestDBClient;
queue: Queue;
queueManager: QueueManager;
};
declare const services: IServiceContainer;
services.queueManager?.getQueue('symbols').add('sync', {
handler: 'symbols',
operation: 'sync',
payload: {},
});
services.postgres?.connected;
services.mongodb?.collection<{ symbol: string }>('symbols').findOne({ symbol: 'AAPL' });
services.browser?.createPageWithProxy('https://example.com');
// These obsolete APIs must not silently return through a copied service interface.
// @ts-expect-error An individual queue is not a queue manager.
services.queue?.getQueue('symbols');
// @ts-expect-error The queue adapter exposes add(), not addJob().
services.queue?.addJob('sync', {});
// @ts-expect-error PostgreSQL exposes connected as a property.
services.postgres?.isConnected();
// @ts-expect-error The browser capability is the managed adapter, not a Playwright Browser.
services.browser?.newPage();
// @ts-expect-error A typed collection retains its document fields.
services.mongodb?.collection<{ symbol: string }>('symbols').findOne({ symbol: 123 });