attestationLexicons
The lexicons of the three: each its own document, with the subject (the code it's about) a definition in it.
import { ATTESTATION_KINDS, SEVERITIES } from "#codebase/tcmts/records"; import type { AttestationKind } from "#codebase/tcmts/records"; export const attestationLexicons = Object.fromEntries( (Object.entries(ATTESTATION_KINDS) as [AttestationKind, string][]).map(([kind, id]) => [ kind, { lexicon: 1, id, description: { review: "A review of some tcm code.", advisory: "An advisory about some tcm code.", yank: "A release's author's word that it shouldn't be used.", }[kind], defs: { main: { type: "record", description: { review: "A review of some tcm code, by its namespace hash: what its writer checked, and what they found.", advisory: "An advisory about some tcm code, by its namespace hash: a vulnerability or a bad bug, how bad, and what fixes it.", yank: "Its author's word that a release shouldn't be used, by its namespace hash, and why. Counted only from the release's author.", }[kind], key: "tid", record: { type: "object", required: kind === "advisory" ? ["subject", "body", "severity", "createdAt"] : ["subject", "body", "createdAt"], properties: { subject: { type: "ref", ref: "#subject" }, body: { type: "string", maxLength: 30000, description: { review: "What the reviewer checked, and what they found, as markdown.", advisory: "What's wrong, and what to do about it, as markdown.", yank: "Why it shouldn't be used, as markdown.", }[kind], }, ...(kind === "advisory" ? { severity: { type: "string", knownValues: [...SEVERITIES], maxLength: 32, description: "How bad it is.", }, fixedIn: { type: "string", maxLength: 64, description: "The version that fixes it.", }, } : {}), createdAt: { type: "string", format: "datetime", description: "When it was written.", }, }, }, }, subject: { type: "object", description: "The code it's about, by its namespace's whole hash; the release it is, and its author, for showing.", required: ["namespace"], properties: { namespace: { type: "string", maxLength: 128, description: "The namespace's whole hash.", }, release: { type: "string", maxLength: 300, description: "The release it is: package@version.", }, author: { type: "string", format: "did", description: "The release's author, if it was announced.", }, }, }, }, }, ]), ) as unknown as Record<AttestationKind, Record<string, unknown>>