components/elements/schemas.jsjavascript
/**
* @module components/elements/schemas
* @description Node-importable aggregation of every element's block contract
* (the schema.js files) - deliberately without touching the index.js files,
* which import components and styles that plain node cannot load. Used by
* scripts/validate-content.mjs to compose the full content JSON schema; the
* app itself uses elements/registry.js instead.
*
* Keep this list in sync with ELEMENT_REGISTRY in registry.js.
*/
import storyTitle from "./StoryTitle/schema.js";
import headline from "./Headline/schema.js";
import disclaimer from "./Disclaimer/schema.js";
import buttonList from "./ButtonList/schema.js";
import buttonGrid from "./ButtonGrid/schema.js";
import selectWidget from "./SelectWidget/schema.js";
import quoteList from "./QuoteList/schema.js";
import cardGrid from "./CardGrid/schema.js";
import institutionBadge from "./InstitutionBadge/schema.js";
import imageCardGrid from "./ImageCardGrid/schema.js";
import textMediaWidget from "./TextMediaWidget/schema.js";
import circleInfographic from "./CircleInfographic/schema.js";
import bodyText from "./BodyText/schema.js";
import stepTracker from "./StepTracker/schema.js";
import chartGrid from "./ChartGrid/schema.js";
import iconWheel from "./IconWheel/schema.js";
import circleChain from "./CircleChain/schema.js";
import processFlow from "./ProcessFlow/schema.js";
/** All element block contracts: `{ type, region, required, properties }`. */
export const ELEMENT_SCHEMAS = [
storyTitle,
headline,
disclaimer,
buttonList,
buttonGrid,
selectWidget,
quoteList,
cardGrid,
institutionBadge,
imageCardGrid,
textMediaWidget,
circleInfographic,
bodyText,
stepTracker,
chartGrid,
iconWheel,
circleChain,
processFlow,
];
/**
* JSON-schema for one content block of the given element: its declared
* properties plus the shared `type` and `region` keywords, everything else
* rejected.
*
* @param {Object} elementSchema - An entry of {@link ELEMENT_SCHEMAS}.
* @returns {Object} A JSON-schema object.
*/
export const toBlockSchema = ({ type, required, properties }) => ({
type: "object",
additionalProperties: false,
required: ["type", ...(required || [])],
properties: {
type: { const: type },
region: { enum: ["storyTitle", "headline", "content"] },
...properties,
},
});