import { NextRequest, NextResponse } from "next/server"; import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth"; import { toErrorResponse } from "@/lib/render-pipeline/errors"; import { attachHighRes, type AttachHighResInput } from "@/lib/render-pipeline/preview"; // ── POST /api/ext/render/jobs/{jobId}/attach-highres (E13b) ────────────────── // // The preview's ProRes MOV, uploaded in the background after finalize (worker // ≥ 1.7.1). Attaches it to the version as its High Res download, or records on // the export timeline that the upload failed. export async function POST( req: NextRequest, { params }: { params: Promise<{ jobId: string }> } ) { if (!isExtAuthorized(req)) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } const { jobId } = await params; let body: AttachHighResInput & { machineId?: string }; try { body = await req.json(); } catch { return NextResponse.json({ error: "Invalid JSON" }, { status: 400 }); } if (!body.machineId) { return NextResponse.json({ error: "machineId is required" }, { status: 400 }); } try { const result = await attachHighRes(jobId, body.machineId, body); return NextResponse.json(result); } catch (err) { const { body: errBody, status } = toErrorResponse(err); return NextResponse.json(errBody, { status }); } }