Contracts 1.0.0: generated JSON Schema for every contract

- schemas/: JSON Schema (draft 2020-12) generated from the zod schemas by
  npm run build (scripts/json-schemas.cjs), exported as
  @crosscode/contracts/schemas/*
- Test: files match the zod schemas, every sample passes them (Ajv)
- Version 1.0.0, CHANGELOG and README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 14:30:37 +02:00
co-authored by Claude Opus 5.5
parent ea1575f716
commit 9e94c82502
35 changed files with 4330 additions and 5 deletions
+10 -1
View File
@@ -1,7 +1,7 @@
# @crosscode/contracts
Everything that crosses between Cross Code products is defined once, here (ROADMAP-v3 §2):
zod schemas, TypeScript types and sample payloads (`samples/`). Every product, including Cross
zod schemas, JSON Schema (`schemas/`), TypeScript types and sample payloads (`samples/`). Every product, including Cross
Events and the Hub, uses it, so the key fields are the same in every product's JSON.
| Contract | Schema name | Used for | Source |
@@ -62,6 +62,15 @@ for install → Hub; `LINK_HEADERS` (`X-Crosscode-Sender`, `-Timestamp`, `-Signa
`event.changed` webhooks and Accounts back-channel calls, with the secret set up by **Connect**.
Verify the raw bytes before parsing the JSON.
### JSON Schema
`schemas/` has a JSON Schema (draft 2020-12) for every contract, for consumers that don't use
TypeScript or zod (e.g. `@crosscode/contracts/schemas/event.json`). They are generated from the
zod schemas by `npm run build`; commit them with the change (a test fails when they're out of
date). They allow unknown fields, like the zod schemas. The zod schemas stay the source of truth:
a few checks can't be written in JSON Schema (e.g. `startsAt` / `endsAt` matching the sessions,
only Cross Events using `registration.mode: "origin"`), so use the zod schemas where you can.
## Versioning
- Every payload carries its `schema` name: `crosscode.<name>/<major>` (`parseSchemaName`, `isSchema`).