/**
 * Shared types for QM handler
 */

export interface QMSession {
  uuid: string; // Unique identifier for the session
  proxy: string;
  headers: Record<string, string>; // Headers to use for requests
  successfulCalls: number;
  failedCalls: number;
  lastUsed: Date;
  createdAt: Date;
}

export interface SymbolSpiderJob {
  prefix: string | null; // null = root job (A-Z)
  depth: number; // 1=A, 2=AA, 3=AAA, etc.
  source: string; // 'qm'
  maxDepth?: number; // optional max depth limit
}

export interface Exchange {
  exchange: string;
  exchangeName: string;
  countryCode: string;
  source: string;
}

export interface SpiderResult {
  success: boolean;
  symbolsFound: number;
  jobsCreated: number;
}

export interface QMSessionStats {
  sessionType: string;
  total: number;
  valid: number;
  failed: number;
  lastUpdate: Date;
}

export interface QMAuthResponse {
  success: boolean;
  cookies?: string[];
  error?: string;
}

export interface CachedSession {
  uuid: string;
  proxy: string;
  headers: Record<string, string>;
  successfulCalls: number;
  failedCalls: number;
  lastUsed: string; // ISO string for Redis storage
  createdAt: string; // ISO string for Redis storage
  id: string;
  sessionType: string;
}

export interface ExchangeStats {
  symbolCount: number;
  totalMarketCap: number;
  avgMarketCap: number;
}