// Define types and interfaces for the TE handler here

export interface TeData {
  id: string;
  name: string;
  // Add more fields as needed
}

export interface TeResponse {
  data: TeData[];
  status: string;
  timestamp: Date;
}

export interface TeCountry {
  name: string;
  code?: string;
  region?: string;
  url?: string;
  updated_at: Date;
  created_at?: Date;
}

export interface TeDataFetchPayload {
  teSymbol: string;
  url: string;
  isInitialFetch: boolean;
}

export interface TeMarketDataFetchPayload {
  teSymbol: string;
  symbolType: string;
  url: string;
  isInitialFetch: boolean;
}

/** MK/TV CDN series structure (flat, no nested serie wrapper) */
export interface TeMkCdnSerie {
  symbol: string;
  name: string;
  shortname: string;
  full_name: string;
  unit: string;
  type: string;
  ticker: string;
  description: string;
  sector: string;
  industry: string;
  frequency: string;
  /** Each point: [epoch, value, pctChange, absChange] */
  data: Array<[number, number, number | null, number | null]>;
}

/** Decoded CDN response wrapper */
export interface TeCdnResponse {
  series: Array<{
    serie: TeCdnSerie;
  }>;
  span: string;
  agr: string;
  frequency: string;
}

/** Serie metadata + data from CDN */
export interface TeCdnSerie {
  s: string;
  name: string;
  shortname: string;
  unit: string;
  type: string;
  source: string;
  frequency: string;
  country: string;
  category: string;
  /** Each point: [value, unix_epoch, null, "YYYY-MM-DD"] */
  data: Array<[number, number, null, string]>;
  forecast?: Array<[number, number, null, string]>;
  projection?: Array<[number, number, null, string]>;
}