Fail the suite when a source enum member has no label

The four raw values in the sources ladder shipped because nothing checks
the catalogues against the enum they render. The new guard reads
MeasurementSource and IntakeSource out of prisma/schema.prisma, not out
of a copy, and fails naming every member no catalogue labels; it also
asserts the key each entry names resolves in all seven bundles, since a
key that resolves nowhere renders no better than the enum value. Run red
against the tree before the labels landed, it reported seven unlabelled
measurement sources per catalogue and one unlabelled intake source.

The schema reader now carries each enum's declared members so the guard
can read them.
This commit is contained in:
Marc-André Bombeck committed 2026-09-02 12:08:38 +02:00
1 parent 0548c0265e
commit 7ee8bc8134
2 files changed
+179 -1

No files matched your search

+15 -1
View File
@@ -29,6 +29,8 @@ export interface DeclaredEnum {
mappedName: string | null;
/** The name Prisma puts in the SQL — `@@map` when present, else `name`. */
physicalName: string;
/** The declared members, in declaration order. */
values: string[];
}
export interface DeclaredField {
@@ -87,7 +89,19 @@ export function readDeclaredSchema(
const clean = stripComments(body);
const mappedName = BLOCK_MAP.exec(clean)?.[1] ?? null;
if (kind === "enum") {
enums.push({ name, mappedName, physicalName: mappedName ?? name });
// A member is a bare identifier on its own line; `@@map` and any
// trailing comment are already gone (block attributes start with `@`,
// comment lines were stripped above).
const values = clean
.split("\n")
.map((line) => line.replace(/\/\/.*$/, "").trim())
.filter((line) => /^\w+$/.test(line));
enums.push({
name,
mappedName,
physicalName: mappedName ?? name,
values,
});
} else {
rawModels.push({ name, body: clean });
}