import type { Browser } from '@stock-bot/browser';
import type { CacheProvider } from '@stock-bot/cache';
import type { HandlerRegistry } from '@stock-bot/handler-registry';
import type { Logger } from '@stock-bot/logger';
import type { MongoDBClient } from '@stock-bot/mongodb';
import type { PostgreSQLClient } from '@stock-bot/postgres';
import type { ProxyManager } from '@stock-bot/proxy';
import type { QuestDBClient } from '@stock-bot/questdb';
import type { QueueManager } from '@stock-bot/queue';
import type { IServiceContainer } from '@stock-bot/types';
import type { AppConfig } from '../config/schemas';
import type { HandlerScanner } from '../scanner';

export interface ServiceDefinitions {
  // Configuration
  config: AppConfig;
  logger: Logger;

  // Handler infrastructure
  handlerRegistry: HandlerRegistry;
  handlerScanner: HandlerScanner;

  // Core services
  cache: CacheProvider | null;
  globalCache: CacheProvider | null;
  proxyManager: ProxyManager | null;
  browser: Browser;
  queueManager: QueueManager | null;

  // Database clients
  mongoClient: MongoDBClient | null;
  postgresClient: PostgreSQLClient | null;
  questdbClient: QuestDBClient | null;

  // Aggregate service container
  serviceContainer: IServiceContainer;
}

export type ServiceCradle = ServiceDefinitions;

export interface ServiceContainerOptions {
  enableQuestDB?: boolean;
  enableMongoDB?: boolean;
  enablePostgres?: boolean;
  enableCache?: boolean;
  enableQueue?: boolean;
  enableBrowser?: boolean;
  enableProxy?: boolean;
}

export interface ContainerBuildOptions extends ServiceContainerOptions {
  skipInitialization?: boolean;
  initializationTimeout?: number;
}
