@@ -40,7 +40,7 @@ export async function GET(
|
||||
task: {
|
||||
include: {
|
||||
project: { select: { id: true, name: true, code: true } },
|
||||
shot: { select: { shotCode: true } },
|
||||
shot: { select: { id: true, shotCode: true, highResKey: true, highResFilename: true } },
|
||||
asset: { select: { assetCode: true, name: true } },
|
||||
},
|
||||
},
|
||||
@@ -78,10 +78,17 @@ export async function GET(
|
||||
},
|
||||
});
|
||||
|
||||
// Resolve the shot that has the high-res file (comes from version.shot OR version.task.shot)
|
||||
const highResShot = version.shot ?? (version.task as any)?.shot ?? null;
|
||||
|
||||
const serializedVersion = {
|
||||
...version,
|
||||
fileSize: version.fileSize?.toString() ?? null,
|
||||
// Expose only whether a high-res file exists, never the storage key
|
||||
// Top-level high-res fields so the client works for both shot and task versions
|
||||
hasHighRes: !!(highResShot?.highResKey),
|
||||
highResShotId: highResShot?.highResKey ? (highResShot.id ?? null) : null,
|
||||
highResFilename: highResShot?.highResFilename ?? null,
|
||||
// Expose only whether a high-res file exists on the shot relation, never the storage key
|
||||
shot: version.shot
|
||||
? {
|
||||
...version.shot,
|
||||
@@ -90,6 +97,17 @@ export async function GET(
|
||||
highResKey: undefined,
|
||||
}
|
||||
: null,
|
||||
task: version.task
|
||||
? {
|
||||
...version.task,
|
||||
shot: (version.task as any)?.shot
|
||||
? {
|
||||
...((version.task as any).shot),
|
||||
highResKey: undefined, // strip storage key
|
||||
}
|
||||
: null,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
|
||||
return NextResponse.json({ version: serializedVersion, comments });
|
||||
|
||||
Reference in New Issue
Block a user