// Mirrors internal/api/types.go. Kept minimal — only the shapes the SPA
// actually reads today (no LoginRequest/LoginResponse here; those live in
// client.ts alongside the auth plumbing).

export type Page<T> = {
  items: T[];
  total: number;
  limit: number;
  offset: number;
};

export type ArtistRef = {
  id: string;
  name: string;
  album_count: number;
};

export type AlbumRef = {
  id: string;
  title: string;
  artist_id: string;
  artist_name: string;
  year?: number;
  track_count: number;
  duration_sec: number;
  cover_url: string;
};

export type TrackRef = {
  id: string;
  title: string;
  album_id: string;
  album_title: string;
  artist_id: string;
  artist_name: string;
  track_number?: number;
  disc_number?: number;
  duration_sec: number;
  stream_url: string;
};

export type ArtistDetail = ArtistRef & {
  albums: AlbumRef[];
};

export type AlbumDetail = AlbumRef & {
  tracks: TrackRef[];
};

export type SearchResponse = {
  artists: Page<ArtistRef>;
  albums:  Page<AlbumRef>;
  tracks:  Page<TrackRef>;
};

export type RadioResponse = {
  tracks: TrackRef[];
};

export type LikedIdsResponse = {
  track_ids: string[];
  album_ids: string[];
  artist_ids: string[];
};

export type EventRequest =
  | { type: 'play_started';  track_id: string; client_id?: string }
  | { type: 'play_ended';    play_event_id: string; duration_played_ms: number }
  | { type: 'play_skipped';  play_event_id: string; position_ms: number };

export type PlayStartedResponse = { play_event_id: string; session_id: string };
export type EventOkResponse = { ok: true };
