export interface Provider {
  id: string
  name: string
  apiKey: string
  baseUrl: string
  protocol: 'openai' | 'anthropic'
  enabled: boolean
  createdAt: string
  updatedAt: string
}

export interface Model {
  id: string
  providerId: string
  modelName: string
  enabled: boolean
  createdAt: string
  unifiedId?: string
}

export interface UsageStats {
  id: number
  providerId: string
  modelName: string
  requestCount: number
  date: string
}

export interface CreateProviderInput {
  id: string
  name: string
  apiKey: string
  baseUrl: string
  protocol: 'openai' | 'anthropic'
  enabled: boolean
}

export interface UpdateProviderInput {
  name?: string
  apiKey?: string
  baseUrl?: string
  protocol?: 'openai' | 'anthropic'
  enabled?: boolean
}

export interface CreateModelInput {
  providerId: string
  modelName: string
  enabled: boolean
}

export interface UpdateModelInput {
  providerId?: string
  modelName?: string
  enabled?: boolean
}

export interface StatsQueryParams {
  providerId?: string
  modelName?: string
  startDate?: string
  endDate?: string
}

export class ApiError extends Error {
  status: number
  code?: string

  constructor(status: number, message: string, code?: string) {
    super(message)
    this.name = 'ApiError'
    this.status = status
    this.code = code
  }
}

export interface ApiErrorResponse {
  error: string
  code?: string
}
