@anchrd/gate-contract
v0.12.0
Published
The shared wire formats of **gate**, as [Zod](https://zod.dev) schemas — consumed by [`@anchrd/gate-api`](https://www.npmjs.com/package/@anchrd/gate-api) (which builds the responses) and [`@anchrd/gate-sdk`](https://www.npmjs.com/package/@anchrd/gate-sdk)
Readme
@anchrd/gate-contract
The shared wire formats of gate, as Zod schemas — consumed by
@anchrd/gate-api (which builds the responses) and
@anchrd/gate-sdk (which parses them).
You usually don't install this directly — it comes in with
@anchrd/gate-sdk. It's public so you can share the same types in your own code.
Install
npm i @anchrd/gate-contractContents
Formats only, no behavior (no fetch, no logic) — the sole dependency is zod.
Semver-sacred: a breaking change here hits every customer edge at once.
import { AuthorizationResponse, type Identity, type Rules } from "@anchrd/gate-contract";
const { identity, rules } = AuthorizationResponse.parse(await res.json());
// ^ Identity ^ Rules = Record<interface, function[]>| Schema | |
|---|---|
| Identity | Who the authenticated user is: { id, email, name? }. |
| Rules | Record<interface, function[]> — the flattened can() set. |
| AuthorizationResponse | Response of POST /api/v1/authorization: { identity, rules }. |
| SchemaResponse | Response of GET /api/v1/schema — the basis for codegen (gate init). |
| SchemaInterface · ServiceInterfaceRemoveResponse | Service-scoped interface self-management. |
| ProblemDetails | The single outward error shape (RFC 9457, application/problem+json). |
Related
@anchrd/gate-sdk— the client and CLI (uses these schemas).@anchrd/gate-api— gate itself (the Worker).
