// Wire types mirrored against backend/app/api/schemas.py.
// Field names match the JSON payloads exactly, so they stay snake_case.

export interface HistoryTurn {
  role: 'user' | 'assistant'
  content: string
}

export interface PriorRecommendation {
  rank: number
  track_id: string
  title: string
  artists: string[]
}

export interface RecommendationRequest {
  schema_version: 1
  query: string
  history: HistoryTurn[]
  prior_recommendations: PriorRecommendation[]
}

export interface TrackCard {
  id: string
  uri: string
  title: string
  artists: string[]
  album_name: string
  album_art_url: string | null
  external_url: string | null
}

export interface MetadataEvent {
  type: 'metadata'
  request_id: string
  intent_summary: string
  candidate_count: number
}

export interface TrackEvent {
  type: 'track'
  rank: number
  track: TrackCard
  justification: string
}

export interface WarningEvent {
  type: 'warning'
  code: string
  message: string
}

export interface ErrorEvent {
  type: 'error'
  code: string
  message: string
}

export interface DoneEvent {
  type: 'done'
  track_count: number
  total_ms: number
}

export type StreamEvent = MetadataEvent | TrackEvent | WarningEvent | ErrorEvent | DoneEvent

export interface PlaylistCreateRequest {
  schema_version: 1
  name: string
  track_uris: string[]
}

export interface PlaylistCreateResponse {
  url: string
}

export interface CurrentUser {
  display_name: string
}
