/**
 * Track Types
 * T0260: Types TypeScript pour les tracks et l'upload
 * INT-TYPE-004: TrackStatus enum aligned with backend (models/track_status.go)
 * Action 1.1.3.3: Using generated type as base
 */

import type { VezaBackendApiInternalModelsTrack, VezaBackendApiInternalModelsTrackStatus } from '@/types/generated/api';

/**
 * TrackStatus enum - aligned with backend TrackStatus constants
 * Backend values: uploading, processing, completed, failed
 * Maps to VezaBackendApiInternalModelsTrackStatus
 */
export enum TrackStatus {
  Uploading = 'uploading',
  Processing = 'processing',
  Completed = 'completed',
  Failed = 'failed',
}

/**
 * Track type - extends generated type from OpenAPI
 * Action 1.1.3.3: Base type from generated API types
 * Preserves required fields and adds type safety
 */
export type Track = VezaBackendApiInternalModelsTrack & {
  // Required fields (generated type has them as optional, but backend always provides them)
  id: string;
  creator_id: string;
  title: string;
  artist: string;
  file_path: string;
  file_size: number;
  format: string;
  is_public: boolean;
  play_count: number;
  like_count: number;
  created_at: string;
  updated_at: string;
  // Duration is number in seconds (generated type matches)
  duration: number;
  // Status uses TrackStatus enum for type safety
  status?: TrackStatus | VezaBackendApiInternalModelsTrackStatus;
  // Stream status with specific union type
  stream_status?: 'pending' | 'processing' | 'ready' | 'error';
};

export interface UploadProgress {
  track_id: string;
  status: TrackStatus;
  progress: number;
  message?: string;
  stream_status?: string;
  stream_manifest_url?: string;
}
