|
| 1 | +# @objectstack/downstream-contract |
| 2 | + |
| 3 | +A **frozen, representative third-party consumer** of `@objectstack/spec`, used as a |
| 4 | +backward-compatibility gate. |
| 5 | + |
| 6 | +## Why this exists |
| 7 | + |
| 8 | +Every other consumer the framework tests — the example apps, `@objectstack/dogfood` — |
| 9 | +lives in this monorepo and **co-evolves with the spec in the same commit**. When a spec |
| 10 | +change would break them, the same PR just fixes them. So they can never catch a change |
| 11 | +that breaks a *real* third party (e.g. [hotcrm](https://github.com/objectstack-ai/hotcrm)) |
| 12 | +that is pinned to a **published** release and authors metadata independently. |
| 13 | + |
| 14 | +This package closes that gap. It is authored exactly the way an external project does — |
| 15 | +importing from the package entry points, mixing the builder (`ObjectSchema.create`), |
| 16 | +the `defineX` factories, and **bare metadata literals** (the pattern third parties on |
| 17 | +older releases used, see #2035) — and then validates that metadata against the spec. |
| 18 | + |
| 19 | +## The contract (read before editing) |
| 20 | + |
| 21 | +These fixtures are **frozen**. The gate is: |
| 22 | + |
| 23 | +> A spec change that requires editing the fixtures to stay green is, by definition, a |
| 24 | +> **breaking change** for third parties. |
| 25 | +
|
| 26 | +So if a change here turns red: |
| 27 | + |
| 28 | +- **Do not** edit the fixtures to make it pass. That hides the very break this package |
| 29 | + exists to surface. |
| 30 | +- Treat it as a deliberate decision: either revert/adjust the spec change to stay |
| 31 | + backward compatible, or — if the break is intended — bump `@objectstack/spec` to a new |
| 32 | + **major** and document the migration, *then* update the fixtures in the same PR. |
| 33 | + |
| 34 | +## What it checks |
| 35 | + |
| 36 | +- `pnpm --filter @objectstack/downstream-contract typecheck` — the fixtures are typed |
| 37 | + with real spec types (`ActionInput`, `ReportInput`, `PageInput`, …). A removed or |
| 38 | + narrowed export fails here (the #2023 class of break). |
| 39 | +- `pnpm --filter @objectstack/downstream-contract test` — runs each bare-literal fixture |
| 40 | + through its schema's `.parse()` and assembles everything via `defineStack` (schema + |
| 41 | + cross-reference validation — the heart of `objectstack validate`). |
| 42 | + |
| 43 | +For the live counterpart, the release pipeline can additionally run hotcrm's own |
| 44 | +`validate && typecheck && build` against the unreleased spec; this package is the fast, |
| 45 | +deterministic, in-CI floor. |
0 commit comments