@affordant/contract
The shared wire-contract types. Zero runtime, zero dependencies — it ships only .d.ts. Every other package depends on it, so the producer (@affordant/server) and the consumers (affordant, @affordant/react) can never drift apart.
npm install @affordant/contractYou rarely import it directly: the client and server packages re-export these same types. Reach for it when you write code that sits between both sides (a shared model package, a test helper).
import type { HateoasAction, HateoasMethod, HateoasResource } from '@affordant/contract'HateoasMethod
type HateoasMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'The HTTP verbs an action can carry.
HateoasAction
interface HateoasAction {
href: string
method: HateoasMethod
accepts?: string
}A hypermedia action descriptor: where (href), how (method), and optionally what request body it accepts (accepts, a media type — defaults to application/json when omitted).
HateoasResource<T>
type HateoasResource<T> = T & {
_self?: HateoasAction
_actions: Record<string, HateoasAction>
}Your resource T, enriched with hypermedia controls. _actions maps a link relation (rel) to the action the server is currently offering. An absent rel means the action is not available to the caller right now.
See the wire contract for the design behind these types.