import { projectRef } from "@/lib/projects"; import { isTakeId } from "@/lib/report/takes.mjs"; import { walkJson, walkOf } from "@/lib/report/walkData.mjs"; export const dynamic = "force-dynamic"; // THE WALK, as data (lib/report/walkData.mjs -- what the bench page and // `umtool walk` read): every clip in walk order with its verdict, whether a // fetched file holds it, and which ones the walk visits. // // GET ?project=[&take=][&all=1] // take: walk a take -- the project's manifest with the take's patch applied // (a draft too); `token` is then the take's (its saves go into take.json) // all: the walk visits every fetched clip, judged or not export async function GET(request: Request) { const url = new URL(request.url); const project = await projectRef(url.searchParams.get("project") ?? ""); if (!project) return Response.json({ error: "no such project" }, { status: 404 }); const take = url.searchParams.get("take") || null; if (take !== null && !isTakeId(take)) return Response.json({ error: "take must be a take id" }, { status: 400 }); try { const w = await walkOf(project, { take, all: url.searchParams.get("all") === "1" }); return Response.json(walkJson(w), { headers: { "cache-control": "no-store" } }); } catch (e) { const message = e instanceof Error ? e.message : String(e); return Response.json({ error: message }, { status: /^no take |no video\.manifest/.test(message) ? 404 : 400 }); } }