// The build's own validators, for a media task's code checks (release 28). // // A drafted teaser must pass `validateTeaser` (the frame's fit per role), and // a drafted cut must leave the manifest as valid as it found it (posts that // ride on a clip, flips and threads that name clips). Those rules live in // umtool's report-to-video (`deck.mjs`, `lint.mjs` `validatorErrors`: what a // build runs before it renders) — plain `.mjs` that common does not depend on // (it depends on common). So they are loaded at run time from the checkout, // natively (the editor is never a standalone bundle: AGENTS.md, "The runtime // container"), and handed to a task as `TaskDeps.deckChecks`. import path from "node:path"; import { pathToFileURL } from "node:url"; export type DeckChecks = { // umtool/report-to-video/deck.mjs: a teaser entry's problems ([] = it builds). validateTeaser(entry: unknown, where?: string): string[]; // umtool/report-to-video/lint.mjs: every validator a build runs on the whole // manifest, as sentences. validatorErrors(manifest: unknown): string[]; }; // The checkout's report-to-video directory. export const deckDirOf = (repoRoot: string) => path.join(/* turbopackIgnore: true */ repoRoot, "umtool", "report-to-video"); const load = (file: string) => import(/* webpackIgnore: true */ /* turbopackIgnore: true */ pathToFileURL(file).href); /** The validators, from the checkout at `repoRoot` (throws when it has no umtool). */ export async function loadDeckChecks(repoRoot: string): Promise { const dir = deckDirOf(repoRoot); const [deck, lint] = await Promise.all([load(path.join(dir, "deck.mjs")), load(path.join(dir, "lint.mjs"))]); if (typeof deck.validateTeaser !== "function" || typeof lint.validatorErrors !== "function") { throw new Error(`${dir}: no validateTeaser / validatorErrors (an older checkout?)`); } return { validateTeaser: (entry, where) => deck.validateTeaser(entry, where), validatorErrors: (manifest) => { try { return lint.validatorErrors(manifest); } catch (e) { return [(e as Error).message]; } }, }; }