@chartguard/schema-generator
v0.1.1
Published
Generates ChartGuard schema artifacts from a chart library's own declarations and runtime, in your project
Readme
@chartguard/schema-generator
Generates ChartGuard schema artifacts from a chart library's own published TypeScript declarations and runtime code. Every fact in an artifact cites the line of the installed package it was read from, and a build fails if a fact does not trace to that line; nothing from the package is executed. An artifact names everything it was built from: the library (exact version and integrity), the TypeScript compiler that read it (its lib files give the members of DOM and built-in types; the generator depends on one exact TypeScript and refuses another), and the generator's version, so the same inputs build the same bytes.
Status: pre-release (0.x). Coverage is partial, and the API and settings may still change between minor versions.
npm install --save-dev @chartguard/schema-generatorChartGuard's Chart.js and ECharts adapters ship their schemas. The Highcharts schema cannot ship: the Highcharts license does not clear redistributing option metadata derived from it. Build it on your machine, from your own installed highcharts, under your own license:
npx chartguard schema build --library highchartsThe schema is written to node_modules/.cache/chartguard/highcharts-<version>.json and used by chartguard validate --library highcharts for that installed version. A version of the same major as the one the generator was verified against (see upstream-sources.json) is read the same way; if any declaration shape or runtime fact the generator relies on is missing, the build fails and names it rather than writing a different schema.
import { buildLocalSchema } from "@chartguard/schema-generator";
const { path, version, digest } = buildLocalSchema(process.cwd(), "highcharts");