feat(render-pipeline): validation, QC and delivery builder
Completes RenderPipeline2 phases 3-5. Additive throughout: with validation.enabled=false the pipeline behaves exactly as before. Validation (§8) runs on the worker straight after a render, while it still holds the job and the files are local. Everything is read from the EXR header — one 64 KB read per sampled frame, no pixel decode — so the engine needs no oiiotool. The render job deliberately stays open through the stage, so a worker that dies there is reaped and retried instead of stranding the export in VALIDATING. Timecode is the primary check and is anchored on the plate, never the API: measured on the live show, Shot.timecodeStart is the editorial in-point and sits one handle-length (8f) ahead of the plate, so checking against it would pass the defective exports and fail the correct ones. Reference precedence is manifest timing plate -> plate found on disk -> API value, and the API rank is WARN-only. The panel now resolves plate provenance by walking the comp's own footage layers, so the worker never guesses which element carries the comp's timing. Verified against real studio renders via the new --validate mode: it catches both defect classes seen in shipped work — the +8 handle offset and frame-derived timecode (00:00:41:17 = frame 1001 at 24fps). QC (§10) is one service behind two front doors, API-key for the panel and session for the web. PASS means ready to upload and nothing else; FAIL sets the comp task to CHANGES. The panel gains a QC section that imports the real EXR sequence at full res rather than the H.264. Delivery (§11) rides the existing queue as a DELIVERY_BUILD job: hard links with a copy fallback, verification by re-hashing delivered bytes against the validation-time digest, manifest.json and the CSV report. fsutil hardlink list is unavailable over SMB, so link identity is never queried — reading the bytes back covers links and copies alike. Also fixes ApiClient.ProgressAsync throwing on transport failure, which would have aborted work in flight during a brief server outage; progress reporting is best-effort by contract. Removes the stale RenderWorker/ rule from the root .gitignore. The worker's source is tracked like the rest of the repo and its own .gitignore already covers bin/, obj/ and publish/; the rule silently excluded new files while the existing 20 stayed tracked. Not yet applied: migration 20260813000000 was hand-written because the dev database was unavailable — run prisma migrate deploy and verify before relying on it. None of this has run against a live server. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { RefreshCw, RotateCcw, XCircle, CheckCircle2, Server } from "lucide-react";
|
||||
import { RefreshCw, RotateCcw, XCircle, CheckCircle2, Server, Package } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Progress } from "@/components/ui/progress";
|
||||
import {
|
||||
@@ -112,6 +112,12 @@ export function PipelineQueueClient({ projects }: Props) {
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Link href="/pipeline/deliveries">
|
||||
<Button variant="outline" size="sm">
|
||||
<Package className="h-4 w-4 mr-2" />
|
||||
Deliveries
|
||||
</Button>
|
||||
</Link>
|
||||
<Link href="/pipeline/machines">
|
||||
<Button variant="outline" size="sm">
|
||||
<Server className="h-4 w-4 mr-2" />
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { ArrowLeft, Package, CheckCircle2, XCircle, RefreshCw } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { DELIVERY_STATUS_STYLES, statusLabel } from "../status-colors";
|
||||
|
||||
interface ReadyExport {
|
||||
exportId: string;
|
||||
shotCode: string;
|
||||
episode: string;
|
||||
versionString: string;
|
||||
fileCount: number | null;
|
||||
totalBytes: number | null;
|
||||
deliveryMovPath: string | null;
|
||||
hasChecksum: boolean;
|
||||
qc: { result: string; reviewer: string | null; at: string } | null;
|
||||
}
|
||||
|
||||
interface ReadyResponse {
|
||||
episodes: { episode: string; count: number; exports: ReadyExport[] }[];
|
||||
}
|
||||
|
||||
interface PackageRow {
|
||||
id: string;
|
||||
packageNumber: number;
|
||||
name: string;
|
||||
episode: string;
|
||||
status: string;
|
||||
rootPath: string | null;
|
||||
errorMessage: string | null;
|
||||
projectName: string;
|
||||
createdAt: string;
|
||||
builtAt: string | null;
|
||||
deliveredAt: string | null;
|
||||
itemCount: number;
|
||||
verifiedCount: number;
|
||||
items: {
|
||||
id: string;
|
||||
shotCode: string;
|
||||
versionString: string;
|
||||
status: string;
|
||||
fileCount: number | null;
|
||||
linkMode: string | null;
|
||||
errorMessage: string | null;
|
||||
}[];
|
||||
}
|
||||
|
||||
interface ProjectOption {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number | null): string {
|
||||
if (bytes == null) return "—";
|
||||
const gb = bytes / 1_073_741_824;
|
||||
return gb >= 1 ? `${gb.toFixed(1)} GB` : `${(bytes / 1_048_576).toFixed(0)} MB`;
|
||||
}
|
||||
|
||||
export function DeliveriesClient({ canBuild }: { canBuild: boolean }) {
|
||||
const { toast } = useToast();
|
||||
const queryClient = useQueryClient();
|
||||
const [projectId, setProjectId] = useState<string>("");
|
||||
const [episode, setEpisode] = useState<string>("");
|
||||
const [building, setBuilding] = useState(false);
|
||||
|
||||
const { data: projects } = useQuery({
|
||||
queryKey: ["pipeline-projects"],
|
||||
queryFn: async () => {
|
||||
const res = await fetch("/api/projects");
|
||||
if (!res.ok) throw new Error("Failed to load projects");
|
||||
const body = await res.json();
|
||||
return (body.projects ?? body) as ProjectOption[];
|
||||
},
|
||||
});
|
||||
|
||||
const { data: ready, isLoading: readyLoading } = useQuery({
|
||||
queryKey: ["delivery-ready", projectId],
|
||||
queryFn: async () => {
|
||||
const res = await fetch(`/api/deliveries/ready?projectId=${encodeURIComponent(projectId)}`);
|
||||
if (!res.ok) throw new Error((await res.json().catch(() => ({})))?.error ?? "Failed to load ready exports");
|
||||
return res.json() as Promise<ReadyResponse>;
|
||||
},
|
||||
enabled: Boolean(projectId),
|
||||
});
|
||||
|
||||
const { data: packages } = useQuery({
|
||||
queryKey: ["delivery-packages", projectId],
|
||||
queryFn: async () => {
|
||||
const res = await fetch(`/api/deliveries${projectId ? `?projectId=${encodeURIComponent(projectId)}` : ""}`);
|
||||
if (!res.ok) throw new Error("Failed to load packages");
|
||||
return res.json() as Promise<{ packages: PackageRow[] }>;
|
||||
},
|
||||
// A build is a queued job like any other — poll while one is in flight.
|
||||
refetchInterval: 5000,
|
||||
});
|
||||
|
||||
async function build(ep: string) {
|
||||
if (!projectId) return;
|
||||
setBuilding(true);
|
||||
try {
|
||||
const res = await fetch("/api/deliveries", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ projectId, episode: ep || null }),
|
||||
});
|
||||
const body = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
toast({ title: "Build failed", description: body.error ?? res.statusText, variant: "destructive" });
|
||||
} else {
|
||||
toast({
|
||||
title: `Package #${body.package.packageNumber} queued`,
|
||||
description: `${body.package.itemCount} shots → ${body.package.rootPath}`,
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: ["delivery-packages"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["delivery-ready"] });
|
||||
}
|
||||
} finally {
|
||||
setBuilding(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function packageAction(id: string, verb: "delivered" | "cancel") {
|
||||
const res = await fetch(`/api/deliveries/${id}/${verb}`, { method: "POST" });
|
||||
const body = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
toast({ title: `${verb} failed`, description: body.error ?? res.statusText, variant: "destructive" });
|
||||
}
|
||||
queryClient.invalidateQueries({ queryKey: ["delivery-packages"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["delivery-ready"] });
|
||||
}
|
||||
|
||||
const episodes = ready?.episodes ?? [];
|
||||
const shown = episode ? episodes.filter((e) => e.episode === episode) : episodes;
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6 max-w-6xl">
|
||||
<div className="flex items-center gap-3">
|
||||
<Link href="/pipeline">
|
||||
<Button variant="ghost" size="icon-sm">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
<h1 className="text-xl font-semibold text-white">Delivery packages</h1>
|
||||
</div>
|
||||
|
||||
{/* Picker */}
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<select
|
||||
value={projectId}
|
||||
onChange={(e) => {
|
||||
setProjectId(e.target.value);
|
||||
setEpisode("");
|
||||
}}
|
||||
className="rounded-md border border-zinc-800 bg-zinc-900 px-3 py-1.5 text-sm text-zinc-200"
|
||||
>
|
||||
<option value="">Select a project…</option>
|
||||
{(projects ?? []).map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name} ({p.code})
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{episodes.length > 0 && (
|
||||
<select
|
||||
value={episode}
|
||||
onChange={(e) => setEpisode(e.target.value)}
|
||||
className="rounded-md border border-zinc-800 bg-zinc-900 px-3 py-1.5 text-sm text-zinc-200"
|
||||
>
|
||||
<option value="">All episodes</option>
|
||||
{episodes.map((e) => (
|
||||
<option key={e.episode} value={e.episode}>
|
||||
{e.episode || "(no episode)"} — {e.count} ready
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Ready to build */}
|
||||
{projectId && (
|
||||
<div className="rounded-lg border border-zinc-800 bg-zinc-900/40">
|
||||
<div className="px-4 py-2.5 border-b border-zinc-800 text-sm font-medium text-white">
|
||||
Ready for delivery
|
||||
</div>
|
||||
{readyLoading && <div className="p-4 text-sm text-zinc-500">Loading…</div>}
|
||||
{!readyLoading && shown.length === 0 && (
|
||||
<div className="p-4 text-sm text-zinc-500">
|
||||
Nothing has passed QC yet. Exports appear here once QC passes them.
|
||||
</div>
|
||||
)}
|
||||
{shown.map((ep) => (
|
||||
<div key={ep.episode} className="border-b border-zinc-800/60 last:border-0">
|
||||
<div className="flex items-center justify-between gap-4 px-4 py-3 flex-wrap">
|
||||
<div>
|
||||
<span className="text-white text-sm font-medium">
|
||||
{ep.episode ? `Episode ${ep.episode}` : "No episode"}
|
||||
</span>
|
||||
<span className="ml-3 text-sm text-zinc-400">Ready: {ep.count} shots</span>
|
||||
{ep.exports.some((x) => !x.hasChecksum) && (
|
||||
<span className="ml-3 text-xs text-amber-400">
|
||||
{ep.exports.filter((x) => !x.hasChecksum).length} without a validation checksum
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{canBuild && (
|
||||
<Button size="sm" onClick={() => build(ep.episode)} disabled={building}>
|
||||
<Package className="h-4 w-4 mr-2" />
|
||||
Build delivery
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<div className="px-4 pb-3 grid sm:grid-cols-2 lg:grid-cols-3 gap-x-6 gap-y-1">
|
||||
{ep.exports.map((x) => (
|
||||
<div key={x.exportId} className="flex items-center gap-2 text-xs">
|
||||
<Link href={`/pipeline/exports/${x.exportId}`} className="text-zinc-300 hover:text-white">
|
||||
{x.shotCode}
|
||||
</Link>
|
||||
<span className="text-zinc-500">{x.versionString}</span>
|
||||
<span className="text-zinc-600">{x.fileCount ?? "?"} frames</span>
|
||||
<span className="text-zinc-600">{formatBytes(x.totalBytes)}</span>
|
||||
{!x.deliveryMovPath && <span className="text-amber-500/80">no MOV</span>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* History — packages are permanent (§11.5) */}
|
||||
<div className="rounded-lg border border-zinc-800 bg-zinc-900/40">
|
||||
<div className="px-4 py-2.5 border-b border-zinc-800 text-sm font-medium text-white">Packages</div>
|
||||
<div className="divide-y divide-zinc-800/60">
|
||||
{(packages?.packages ?? []).map((p) => (
|
||||
<details key={p.id} className="group">
|
||||
<summary className="flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-zinc-900/60 flex-wrap">
|
||||
<span className="text-sm text-white font-medium">#{p.packageNumber}</span>
|
||||
<span className="text-sm text-zinc-300">{p.name}</span>
|
||||
<span
|
||||
className={cn(
|
||||
"rounded-full border px-2 py-0.5 text-xs",
|
||||
DELIVERY_STATUS_STYLES[p.status] ?? ""
|
||||
)}
|
||||
>
|
||||
{statusLabel(p.status)}
|
||||
</span>
|
||||
<span className="text-xs text-zinc-500">
|
||||
{p.episode ? `episode ${p.episode} · ` : ""}
|
||||
{p.verifiedCount}/{p.itemCount} shots
|
||||
</span>
|
||||
<span className="text-xs text-zinc-600">{new Date(p.createdAt).toLocaleDateString()}</span>
|
||||
{p.status === "BUILDING" && <RefreshCw className="h-3.5 w-3.5 text-blue-400 animate-spin" />}
|
||||
<span className="ml-auto flex items-center gap-2">
|
||||
{canBuild && p.status === "READY" && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
packageAction(p.id, "delivered");
|
||||
}}
|
||||
>
|
||||
<CheckCircle2 className="h-4 w-4 mr-2 text-emerald-400" />
|
||||
Mark delivered
|
||||
</Button>
|
||||
)}
|
||||
{canBuild && ["QUEUED", "FAILED", "DRAFT"].includes(p.status) && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
packageAction(p.id, "cancel");
|
||||
}}
|
||||
>
|
||||
<XCircle className="h-4 w-4 mr-2 text-red-400" />
|
||||
Cancel
|
||||
</Button>
|
||||
)}
|
||||
</span>
|
||||
</summary>
|
||||
<div className="px-4 pb-4 space-y-2">
|
||||
{p.rootPath && <div className="text-xs text-zinc-500 break-all">{p.rootPath}</div>}
|
||||
{p.errorMessage && <div className="text-xs text-red-400">{p.errorMessage}</div>}
|
||||
{p.deliveredAt && (
|
||||
<div className="text-xs text-emerald-400">
|
||||
Delivered {new Date(p.deliveredAt).toLocaleString()}
|
||||
</div>
|
||||
)}
|
||||
<div className="grid sm:grid-cols-2 lg:grid-cols-3 gap-x-6 gap-y-1">
|
||||
{p.items.map((item) => (
|
||||
<div key={item.id} className="flex items-center gap-2 text-xs">
|
||||
<span
|
||||
className={cn(
|
||||
item.status === "VERIFIED"
|
||||
? "text-emerald-400"
|
||||
: item.status === "FAILED"
|
||||
? "text-red-400"
|
||||
: "text-zinc-500"
|
||||
)}
|
||||
>
|
||||
{item.status === "VERIFIED" ? "✓" : item.status === "FAILED" ? "✕" : "·"}
|
||||
</span>
|
||||
<span className="text-zinc-300">{item.shotCode}</span>
|
||||
<span className="text-zinc-500">{item.versionString}</span>
|
||||
{item.fileCount != null && <span className="text-zinc-600">{item.fileCount}f</span>}
|
||||
{item.linkMode && <span className="text-zinc-600">{item.linkMode}</span>}
|
||||
{item.errorMessage && <span className="text-red-400">{item.errorMessage}</span>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
{(packages?.packages ?? []).length === 0 && (
|
||||
<div className="p-4 text-sm text-zinc-500">No packages built yet</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { auth } from "@/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { DeliveriesClient } from "./DeliveriesClient";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function DeliveriesPage() {
|
||||
const session = await auth();
|
||||
if (!session?.user) redirect("/login");
|
||||
if (session.user.role === "CLIENT") redirect("/dashboard");
|
||||
return <DeliveriesClient canBuild={["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role as string)} />;
|
||||
}
|
||||
@@ -66,9 +66,42 @@ interface ExportDetail {
|
||||
note: string | null;
|
||||
createdAt: string;
|
||||
}[];
|
||||
validations: {
|
||||
id: string;
|
||||
renderJobId: string;
|
||||
checkName: string;
|
||||
status: string;
|
||||
expected: string | null;
|
||||
actual: string | null;
|
||||
message: string | null;
|
||||
details: unknown;
|
||||
createdAt: string;
|
||||
}[];
|
||||
qcReviews: {
|
||||
id: string;
|
||||
result: string;
|
||||
notes: string | null;
|
||||
reviewerName: string | null;
|
||||
source: string;
|
||||
createdAt: string;
|
||||
}[];
|
||||
deliveryItems: {
|
||||
id: string;
|
||||
status: string;
|
||||
exrPath: string | null;
|
||||
linkMode: string | null;
|
||||
package: { id: string; name: string; episode: string; status: string; packageNumber: number };
|
||||
}[];
|
||||
};
|
||||
}
|
||||
|
||||
const CHECK_STYLES: Record<string, string> = {
|
||||
PASS: "text-emerald-400",
|
||||
FAIL: "text-red-400",
|
||||
WARN: "text-amber-400",
|
||||
SKIPPED: "text-zinc-500",
|
||||
};
|
||||
|
||||
export function ExportDetailClient({ exportId }: { exportId: string }) {
|
||||
const { toast } = useToast();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -189,6 +222,93 @@ export function ExportDetailClient({ exportId }: { exportId: string }) {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Validation results — newest run first */}
|
||||
{e.validations.length > 0 && (
|
||||
<div className="rounded-lg border border-zinc-800 bg-zinc-900/40">
|
||||
<div className="px-4 py-2.5 border-b border-zinc-800 text-sm font-medium text-white flex items-center gap-3">
|
||||
Validation
|
||||
{(() => {
|
||||
const latestRun = e.validations[e.validations.length - 1].renderJobId;
|
||||
const rows = e.validations.filter((v) => v.renderJobId === latestRun);
|
||||
const failed = rows.filter((v) => v.status === "FAIL").length;
|
||||
const warned = rows.filter((v) => v.status === "WARN").length;
|
||||
return (
|
||||
<span className={cn("text-xs", failed ? "text-red-400" : warned ? "text-amber-400" : "text-emerald-400")}>
|
||||
{failed ? `${failed} failed` : warned ? `${warned} warning${warned > 1 ? "s" : ""}` : "all checks passed"}
|
||||
</span>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
<div className="divide-y divide-zinc-800/60">
|
||||
{(() => {
|
||||
const latestRun = e.validations[e.validations.length - 1].renderJobId;
|
||||
// Failures first: the reason the export stopped should not need scrolling for.
|
||||
const order = { FAIL: 0, WARN: 1, PASS: 2, SKIPPED: 3 } as Record<string, number>;
|
||||
return e.validations
|
||||
.filter((v) => v.renderJobId === latestRun)
|
||||
.slice()
|
||||
.sort((a, b) => (order[a.status] ?? 9) - (order[b.status] ?? 9))
|
||||
.map((v) => (
|
||||
<div key={v.id} className="px-4 py-2 text-sm flex items-start gap-3">
|
||||
<span className={cn("w-16 shrink-0 text-xs font-medium", CHECK_STYLES[v.status] ?? "")}>
|
||||
{v.status}
|
||||
</span>
|
||||
<span className="w-48 shrink-0 text-zinc-300 font-mono text-xs pt-0.5">{v.checkName}</span>
|
||||
<span className="text-zinc-400 text-xs pt-0.5">
|
||||
{v.message ??
|
||||
(v.expected === v.actual ? v.actual : `expected ${v.expected ?? "—"}, got ${v.actual ?? "—"}`)}
|
||||
</span>
|
||||
</div>
|
||||
));
|
||||
})()}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* QC history — latest decision is the authoritative one */}
|
||||
{e.qcReviews.length > 0 && (
|
||||
<div className="rounded-lg border border-zinc-800 bg-zinc-900/40">
|
||||
<div className="px-4 py-2.5 border-b border-zinc-800 text-sm font-medium text-white">QC</div>
|
||||
<div className="divide-y divide-zinc-800/60">
|
||||
{e.qcReviews.map((q) => (
|
||||
<div key={q.id} className="px-4 py-2.5 text-sm">
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<span className={cn("text-xs font-medium", q.result === "PASS" ? "text-emerald-400" : "text-red-400")}>
|
||||
QC {q.result}
|
||||
</span>
|
||||
<span className="text-xs text-zinc-400">{q.reviewerName ?? "unknown reviewer"}</span>
|
||||
<span className="text-xs text-zinc-500">{q.source === "AE_PANEL" ? "AE panel" : "web"}</span>
|
||||
<span className="text-xs text-zinc-500">{new Date(q.createdAt).toLocaleString()}</span>
|
||||
</div>
|
||||
{q.notes && <div className="mt-1 text-xs text-zinc-400 whitespace-pre-wrap">{q.notes}</div>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Delivery membership */}
|
||||
{e.deliveryItems.length > 0 && (
|
||||
<div className="rounded-lg border border-zinc-800 bg-zinc-900/40">
|
||||
<div className="px-4 py-2.5 border-b border-zinc-800 text-sm font-medium text-white">Deliveries</div>
|
||||
<div className="divide-y divide-zinc-800/60">
|
||||
{e.deliveryItems.map((d) => (
|
||||
<div key={d.id} className="px-4 py-2.5 text-sm flex items-center gap-3 flex-wrap">
|
||||
<Link href="/pipeline/deliveries" className="text-zinc-200 hover:text-white">
|
||||
#{d.package.packageNumber} · {d.package.name}
|
||||
</Link>
|
||||
<span className="text-xs text-zinc-500">episode {d.package.episode || "—"}</span>
|
||||
<span className="text-xs text-zinc-400">{d.package.status}</span>
|
||||
<span className="text-xs text-zinc-500">
|
||||
item {d.status.toLowerCase()}
|
||||
{d.linkMode ? ` · ${d.linkMode}` : ""}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Render attempts */}
|
||||
<div className="rounded-lg border border-zinc-800 bg-zinc-900/40">
|
||||
<div className="px-4 py-2.5 border-b border-zinc-800 text-sm font-medium text-white">
|
||||
|
||||
@@ -18,6 +18,16 @@ export const EXPORT_STATUS_STYLES: Record<string, string> = {
|
||||
CANCELLED: "bg-zinc-500/10 text-zinc-500 border-zinc-600/30",
|
||||
};
|
||||
|
||||
export const DELIVERY_STATUS_STYLES: Record<string, string> = {
|
||||
DRAFT: "bg-zinc-500/15 text-zinc-300 border-zinc-500/30",
|
||||
QUEUED: "bg-zinc-500/15 text-zinc-300 border-zinc-500/30",
|
||||
BUILDING: "bg-blue-500/15 text-blue-400 border-blue-500/30",
|
||||
READY: "bg-green-500/15 text-green-400 border-green-500/30",
|
||||
DELIVERED: "bg-emerald-500/15 text-emerald-300 border-emerald-500/30",
|
||||
FAILED: "bg-red-500/15 text-red-400 border-red-500/30",
|
||||
CANCELLED: "bg-zinc-500/10 text-zinc-500 border-zinc-600/30",
|
||||
};
|
||||
|
||||
export const FAILED_STATUSES = ["RENDER_FAILED", "VALIDATION_FAILED", "PREVIEW_FAILED", "QC_FAILED"];
|
||||
export const ACTIVE_STATUSES = ["QUEUED", "RENDERING", "VALIDATING", "GENERATING_PREVIEW"];
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { requirePipelineAdmin } from "@/lib/render-pipeline/session-auth";
|
||||
import { cancelDeliveryPackage } from "@/lib/render-pipeline/deliveries";
|
||||
|
||||
// ── POST /api/deliveries/{id}/cancel ─────────────────────────────────────────
|
||||
//
|
||||
// Packages are never deleted (§11.5); a mistaken one is cancelled.
|
||||
|
||||
export async function POST(
|
||||
_req: NextRequest,
|
||||
{ params }: { params: Promise<{ packageId: string }> }
|
||||
) {
|
||||
try {
|
||||
const user = await requirePipelineAdmin();
|
||||
const { packageId } = await params;
|
||||
const result = await cancelDeliveryPackage(packageId, user.id);
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { requirePipelineAdmin } from "@/lib/render-pipeline/session-auth";
|
||||
import { markDelivered } from "@/lib/render-pipeline/deliveries";
|
||||
|
||||
// ── POST /api/deliveries/{id}/delivered (E19) ────────────────────────────────
|
||||
//
|
||||
// The folder has been uploaded to the client. Moves every packaged export to
|
||||
// DELIVERED — the end of the pipeline.
|
||||
|
||||
export async function POST(
|
||||
_req: NextRequest,
|
||||
{ params }: { params: Promise<{ packageId: string }> }
|
||||
) {
|
||||
try {
|
||||
const user = await requirePipelineAdmin();
|
||||
const { packageId } = await params;
|
||||
const result = await markDelivered(packageId, user.id);
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
|
||||
import { getReadyForDelivery } from "@/lib/render-pipeline/deliveries";
|
||||
|
||||
// ── GET /api/deliveries/ready?projectId=&episode= (E18) ──────────────────────
|
||||
//
|
||||
// READY_FOR_DELIVERY exports grouped by episode — "Episode 101 — Ready: 18 shots".
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
await requirePipelineUser();
|
||||
const { searchParams } = new URL(req.url);
|
||||
const projectId = searchParams.get("projectId");
|
||||
if (!projectId) {
|
||||
return NextResponse.json({ error: "projectId is required" }, { status: 400 });
|
||||
}
|
||||
const result = await getReadyForDelivery(projectId, searchParams.get("episode"));
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { DeliveryStatus } from "@prisma/client";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { requirePipelineUser, requirePipelineAdmin } from "@/lib/render-pipeline/session-auth";
|
||||
import {
|
||||
createDeliveryPackage,
|
||||
createDeliverySchema,
|
||||
listDeliveryPackages,
|
||||
} from "@/lib/render-pipeline/deliveries";
|
||||
|
||||
// ── GET /api/deliveries (E17) · POST /api/deliveries (E16) ───────────────────
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
await requirePipelineUser();
|
||||
const { searchParams } = new URL(req.url);
|
||||
const status = searchParams.get("status");
|
||||
const result = await listDeliveryPackages({
|
||||
projectId: searchParams.get("projectId") ?? undefined,
|
||||
episode: searchParams.get("episode") ?? undefined,
|
||||
status: status ? (status as DeliveryStatus) : undefined,
|
||||
});
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
// Building a package writes to the delivery volume and locks versions —
|
||||
// producer/supervisor territory, not any signed-in user.
|
||||
const user = await requirePipelineAdmin();
|
||||
|
||||
let raw: unknown;
|
||||
try {
|
||||
raw = await req.json();
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsed = createDeliverySchema.safeParse(raw);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "Invalid delivery request", details: parsed.error.issues }, { status: 422 });
|
||||
}
|
||||
|
||||
const result = await createDeliveryPackage(parsed.data, user.id);
|
||||
return NextResponse.json(result, { status: 201 });
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { qcSubmitSchema, submitQCReview } from "@/lib/render-pipeline/qc";
|
||||
|
||||
// ── POST /api/ext/exports/{exportId}/qc (E4) ─────────────────────────────────
|
||||
//
|
||||
// QC Pass / QC Fail from the AE panel. PASS → READY_FOR_DELIVERY and nothing
|
||||
// else; FAIL → QC_FAILED and the comp task back to CHANGES (§10.2).
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ exportId: string }> }
|
||||
) {
|
||||
if (!isExtAuthorized(req)) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
const { exportId } = await params;
|
||||
|
||||
let raw: unknown;
|
||||
try {
|
||||
raw = await req.json();
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsed = qcSubmitSchema.safeParse(raw);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "Invalid QC submission", details: parsed.error.issues }, { status: 422 });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await submitQCReview(exportId, parsed.data, { source: "AE_PANEL" });
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { getQCQueue } from "@/lib/render-pipeline/qc";
|
||||
|
||||
// ── GET /api/ext/qc/queue?projectCode=&episode= (E5) ─────────────────────────
|
||||
//
|
||||
// Exports sitting in READY_FOR_QC, oldest first, with everything the panel
|
||||
// needs to import the real EXR sequence for full-res QC.
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
if (!isExtAuthorized(req)) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(req.url);
|
||||
try {
|
||||
const result = await getQCQueue({
|
||||
projectCode: searchParams.get("projectCode"),
|
||||
episode: searchParams.get("episode"),
|
||||
limit: searchParams.get("limit") ? Number(searchParams.get("limit")) : undefined,
|
||||
});
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ import { completeRender } from "@/lib/render-pipeline/jobs";
|
||||
|
||||
// ── POST /api/ext/render/jobs/{jobId}/complete-render (E11) ──────────────────
|
||||
//
|
||||
// aerender finished with exit 0. Phase 2 interim: Export goes to a provisional
|
||||
// READY_FOR_QC; Phase 3 inserts VALIDATING between (§17.3).
|
||||
// aerender finished with exit 0 → Export goes to VALIDATING and the worker
|
||||
// keeps the job to run the checks (E12). With validation disabled the preview
|
||||
// stage is queued directly. `validationRequired` in the response tells the
|
||||
// worker which of the two happened.
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { deliveryReportSchema, reportDeliveryBuild } from "@/lib/render-pipeline/deliveries";
|
||||
|
||||
// ── POST /api/ext/render/jobs/{jobId}/delivery ───────────────────────────────
|
||||
//
|
||||
// The worker finished (or gave up on) a DELIVERY_BUILD job: per-item results,
|
||||
// the manifest it wrote, and whether the package as a whole is good.
|
||||
|
||||
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 raw: unknown;
|
||||
try {
|
||||
raw = await req.json();
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsed = deliveryReportSchema.safeParse(raw);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "Delivery report is malformed", details: parsed.error.issues }, { status: 422 });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await reportDeliveryBuild(jobId, parsed.data);
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { reportValidation, validationReportSchema } from "@/lib/render-pipeline/validation";
|
||||
|
||||
// ── POST /api/ext/render/jobs/{jobId}/validation (E12) ───────────────────────
|
||||
//
|
||||
// The worker reports every check from one validation run in a single call.
|
||||
// Any FAIL stops the pipeline (Export → VALIDATION_FAILED); otherwise the
|
||||
// preview stage is queued.
|
||||
|
||||
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 raw: unknown;
|
||||
try {
|
||||
raw = await req.json();
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsed = validationReportSchema.safeParse(raw);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json(
|
||||
{ error: "Validation report is malformed", details: parsed.error.issues },
|
||||
{ status: 422 }
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await reportValidation(jobId, parsed.data);
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
|
||||
import { qcSubmitSchema, submitQCReview } from "@/lib/render-pipeline/qc";
|
||||
|
||||
// ── POST /api/render/exports/{exportId}/qc ───────────────────────────────────
|
||||
//
|
||||
// Web twin of E4 — same service, session auth. QC is not locked to AE (§10.2).
|
||||
|
||||
export async function POST(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ exportId: string }> }
|
||||
) {
|
||||
try {
|
||||
const user = await requirePipelineUser();
|
||||
const { exportId } = await params;
|
||||
|
||||
let raw: unknown;
|
||||
try {
|
||||
raw = await req.json();
|
||||
} catch {
|
||||
return NextResponse.json({ error: "Invalid JSON" }, { status: 400 });
|
||||
}
|
||||
|
||||
const parsed = qcSubmitSchema.safeParse(raw);
|
||||
if (!parsed.success) {
|
||||
return NextResponse.json({ error: "Invalid QC submission", details: parsed.error.issues }, { status: 422 });
|
||||
}
|
||||
|
||||
const result = await submitQCReview(exportId, parsed.data, {
|
||||
source: "WEB",
|
||||
userId: user.id,
|
||||
name: user.name ?? user.email ?? null,
|
||||
});
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||
import { requirePipelineUser } from "@/lib/render-pipeline/session-auth";
|
||||
import { getQCQueue } from "@/lib/render-pipeline/qc";
|
||||
|
||||
// ── GET /api/render/qc/queue?projectId=&episode= ─────────────────────────────
|
||||
//
|
||||
// Web twin of E5 for the QC page.
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
await requirePipelineUser();
|
||||
const { searchParams } = new URL(req.url);
|
||||
const result = await getQCQueue({
|
||||
projectId: searchParams.get("projectId"),
|
||||
episode: searchParams.get("episode"),
|
||||
limit: searchParams.get("limit") ? Number(searchParams.get("limit")) : undefined,
|
||||
});
|
||||
return NextResponse.json(result);
|
||||
} catch (err) {
|
||||
const { body, status } = toErrorResponse(err);
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user