@@ -57,6 +57,7 @@ export async function GET(
|
||||
exrOutput: true,
|
||||
seqTimecodeStart: true,
|
||||
seqTimecodeEnd: true,
|
||||
shotVersion: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
project: {
|
||||
@@ -102,3 +103,51 @@ export async function GET(
|
||||
|
||||
return NextResponse.json({ shot });
|
||||
}
|
||||
|
||||
// ── PATCH /api/ext/shots/[shotId] ─────────────────────────────────────────────
|
||||
//
|
||||
// Update mutable shot fields from pipeline tools.
|
||||
// Currently supports: shotVersion (format v###)
|
||||
//
|
||||
// Body (JSON): { shotVersion?: string }
|
||||
// Returns: { success: true, shot: { id, shotVersion } }
|
||||
|
||||
export async function PATCH(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ shotId: string }> }
|
||||
) {
|
||||
if (!isAuthorized(req)) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { shotId } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const { shotVersion } = body as { shotVersion?: string };
|
||||
|
||||
if (shotVersion !== undefined) {
|
||||
if (!/^v\d{3}$/.test(shotVersion)) {
|
||||
return NextResponse.json(
|
||||
{ error: "shotVersion must match format v### (e.g. v001)" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return NextResponse.json({ error: "No updatable fields provided" }, { status: 400 });
|
||||
}
|
||||
|
||||
const shot = await db.shot.findUnique({
|
||||
where: { id: shotId },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!shot) {
|
||||
return NextResponse.json({ error: "Shot not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const updated = await db.shot.update({
|
||||
where: { id: shotId },
|
||||
data: { ...(shotVersion !== undefined && { shotVersion }) },
|
||||
select: { id: true, shotVersion: true },
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true, shot: updated });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user