import { resolveClip } from "@/lib/report/serve.mjs"; import { cuesInWindow } from "@/lib/projects/report.mjs"; export const dynamic = "force-dynamic"; // The cues around a clip, so "what am I cutting off" is READ rather than // inferred from a waveform. Each carries whether it closes a sentence, computed // with the same regex resolve-windows.mjs uses -- imported, not re-written, so // the rail and the widener can never disagree about where a sentence ends. export async function GET(request: Request) { const url = new URL(request.url); const projectId = url.searchParams.get("project") ?? ""; const clipId = url.searchParams.get("clip") ?? ""; const from = Number(url.searchParams.get("from")); const to = Number(url.searchParams.get("to")); if (!Number.isFinite(from) || !Number.isFinite(to) || to <= from) { return Response.json({ error: "bad window" }, { status: 400 }); } const r = await resolveClip(projectId, clipId); if ("error" in r) return Response.json({ error: r.error }, { status: r.status }); const cues = await cuesInWindow(r.project.dir, clipId, from, to); if (!cues) return Response.json({ error: "no cue file for this source" }, { status: 404 }); return Response.json(cues, { headers: { "cache-control": "no-store" } }); }