import type { Browser } from '@stock-bot/browser';
import type { CacheProvider } from '@stock-bot/cache';
import type { IServiceContainer } from '@stock-bot/types';
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 { SmartQueueManager } from '@stock-bot/queue';
import type { AppConfig } from '../config/schemas';

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

  // Core services
  cache: CacheProvider | null;
  globalCache: CacheProvider | null;
  proxyManager: ProxyManager | null;
  browser: Browser;
  queueManager: SmartQueueManager | 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;
}