import superjson from "superjson"; export type OutputType = { status: "running" | "ready" | "failed"; done: number; total: number; failed: number; currentTitle?: string; error?: string; fileName?: string; savedPath?: string; }; export async function getSpotifyDownloadStatus(jobId: string): Promise { const response = await fetch(`/_api/spotify-download-status?jobId=${encodeURIComponent(jobId)}`, { cache: "no-store", }); if (!response.ok) { const parsed = (await response.json().catch(() => ({}))) as { error?: string }; throw new Error(parsed.error || "Unable to check the download."); } return superjson.parse(await response.text()); } export function spotifyDownloadFileUrl(jobId: string) { return `/_api/spotify-download-file?jobId=${encodeURIComponent(jobId)}`; }