0ce41123c5
Deploy / deploy (push) Successful in 5m58s
A slate or burn-in mistake is usually caught after a preview has already
succeeded, and there was no way back: retryPreview required PREVIEW_FAILED, and
READY_FOR_QC only led on to QC_FAILED/READY_FOR_DELIVERY/SUPERSEDED. The only
recourse was a whole new export, re-rendering every EXR and burning a version
number to fix a typo.
- transitions: READY_FOR_QC and QC_FAILED can now go back to GENERATING_PREVIEW.
- regeneratePreview() rebuilds the manifest from scratch rather than patching
anything, so shot code, episode/scene, frame count, slate date and burn-ins
are all re-derived exactly as on a first-time preview. Validated EXRs are
reused and the version number is untouched -- this re-delivers the same
version, it does not make a new one.
- vfxScope and submissionNote are frozen onto the Export at submission time, so
regenerating refreshes that snapshot from the shot's slate fields (explicit
override wins, same precedence as createExport). Slate text edited on the web
app's Slate tab is therefore picked up.
- finalizePreview replaces the media on the export's existing Version instead of
stacking a second row, so the version number stays put and reviewer notes and
annotations survive the reslate. First-time previews are unaffected.
- POST /api/ext/exports/{id}/regenerate-preview exposes it to the panel.
- Panel: Regenerate Previews button, gated on the same statuses as the server,
with a confirm covering what is and is not reused.
Also fixes the slate description source: the Slate tab authors
shot.slateDescription (falling back to shot.description) but the preview
manifest only ever read shot.description, so edits made there never reached the
rendered slate.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
81 lines
2.9 KiB
TypeScript
81 lines
2.9 KiB
TypeScript
import { ExportStatus, Prisma } from "@prisma/client";
|
|
import { PipelineError } from "./errors";
|
|
|
|
/**
|
|
* Export lifecycle state machine (RenderPipeline2 §4).
|
|
* The server is the sole authority on state; workers *request* transitions.
|
|
*
|
|
* NOTE (Phase 2 interim): RENDERING → READY_FOR_QC is temporarily legal.
|
|
* Phase 3 inserts VALIDATING between them (§17.3) — remove READY_FOR_QC from
|
|
* RENDERING's list when the validation engine ships.
|
|
*/
|
|
export const EXPORT_TRANSITIONS: Record<ExportStatus, ExportStatus[]> = {
|
|
QUEUED: ["RENDERING", "CANCELLED", "SUPERSEDED", "READY_FOR_QC"], // READY_FOR_QC: manual mark-done only
|
|
RENDERING: [
|
|
"VALIDATING",
|
|
"GENERATING_PREVIEW", // interim: preview stage runs before validation exists
|
|
"RENDER_FAILED",
|
|
"QUEUED", // lease expiry / retryable fail with attempts remaining (T5)
|
|
"CANCELLED",
|
|
"READY_FOR_QC", // preview disabled / manual mark-done
|
|
],
|
|
RENDER_FAILED: ["QUEUED", "SUPERSEDED"],
|
|
VALIDATING: ["VALIDATION_FAILED", "GENERATING_PREVIEW"],
|
|
VALIDATION_FAILED: ["QUEUED", "SUPERSEDED"],
|
|
GENERATING_PREVIEW: ["PREVIEW_FAILED", "READY_FOR_QC"],
|
|
PREVIEW_FAILED: ["GENERATING_PREVIEW", "SUPERSEDED"],
|
|
// GENERATING_PREVIEW: a slate/burn-in mistake is caught *after* a successful
|
|
// preview, so the preview stage must be re-runnable without re-rendering the
|
|
// validated EXRs or burning a version number (T11b).
|
|
READY_FOR_QC: ["GENERATING_PREVIEW", "QC_FAILED", "READY_FOR_DELIVERY", "SUPERSEDED"],
|
|
QC_FAILED: ["GENERATING_PREVIEW", "SUPERSEDED"],
|
|
READY_FOR_DELIVERY: ["PACKAGED", "SUPERSEDED"],
|
|
PACKAGED: ["DELIVERED"],
|
|
DELIVERED: ["ARCHIVED"],
|
|
SUPERSEDED: [],
|
|
ARCHIVED: [],
|
|
CANCELLED: [],
|
|
};
|
|
|
|
export type TransitionActor = {
|
|
type: "WORKER" | "USER" | "SYSTEM";
|
|
id?: string | null;
|
|
note?: string | null;
|
|
};
|
|
|
|
export function isTransitionAllowed(from: ExportStatus, to: ExportStatus): boolean {
|
|
return EXPORT_TRANSITIONS[from]?.includes(to) ?? false;
|
|
}
|
|
|
|
/**
|
|
* Applies a state transition inside an existing transaction: validates
|
|
* legality, stamps statusChangedAt, appends the ExportEvent audit row.
|
|
* Throws PipelineError(409) on an illegal transition (§4.2 rules).
|
|
*/
|
|
export async function applyTransition(
|
|
tx: Prisma.TransactionClient,
|
|
exportRow: { id: string; status: ExportStatus },
|
|
to: ExportStatus,
|
|
actor: TransitionActor,
|
|
extraData: Prisma.ExportUpdateInput = {}
|
|
) {
|
|
if (!isTransitionAllowed(exportRow.status, to)) {
|
|
throw new PipelineError(409, `Invalid transition ${exportRow.status} → ${to}`);
|
|
}
|
|
const updated = await tx.export.update({
|
|
where: { id: exportRow.id },
|
|
data: { status: to, statusChangedAt: new Date(), ...extraData },
|
|
});
|
|
await tx.exportEvent.create({
|
|
data: {
|
|
exportId: exportRow.id,
|
|
fromStatus: exportRow.status,
|
|
toStatus: to,
|
|
actorType: actor.type,
|
|
actorId: actor.id ?? null,
|
|
note: actor.note ?? null,
|
|
},
|
|
});
|
|
return updated;
|
|
}
|