@mywallpaper/addon-schema
v0.1.1
Published
JSON Schema and Ajv validator for MyWallpaper addon manifests. Source of truth generated from the Rust api-contracts crate.
Maintainers
Readme
@mywallpaper/addon-schema
JSON Schema (Draft 2019-09) for the MyWallpaper addon manifest, plus a pre-configured Ajv validator and a CLI.
The schema is the single source of truth for the shape of a manifest.
Business rules (entry path safety, semver parsing, network domain allowlists,
addon-bus key regex) live server-side in
libs/infra/src/validation/addon_manifest.rs and are not covered here.
Source of truth
The schema is generated from the Rust struct AddonManifestSpec in
libs/api-contracts/src/dtos/addon_manifest.rs. Do not edit schema.json
by hand — regenerate it:
pnpm -C packages/addon-schema build:schemaCI runs pnpm -C packages/addon-schema check:schema to guard against drift.
Using the schema in an addon project
Add $schema to your manifest for IDE autocomplete and live validation:
{
"$schema": "./node_modules/@mywallpaper/addon-schema/schema.json",
"name": "my-addon",
"version": "0.1.0",
"entry": "index.js"
}Programmatic validation
import { validateManifest } from '@mywallpaper/addon-schema'
const result = validateManifest(JSON.parse(raw))
if (!result.valid) {
for (const err of result.errors) {
console.error(err.instancePath, err.message)
}
}CLI
npx mywallpaper-validate-manifest path/to/manifest.jsonExits 0 on success, 1 on validation failure, 2 on usage error.
Versioning
Package version tracks the backend api-contracts crate. Breaking manifest
changes bump the major version. Consumers can pin:
"@mywallpaper/addon-schema": "^0.1.0"