What problem does it solve?
It prevents the recurring classes of API contract bugs on the Sim v2 surface: inconsistent response envelopes, caller-reachable 500s, silently dropped query parameters, and pagination cursors that skip or repeat rows.
Core Features & Use Cases
- Envelope and status-code rules: Mandates the exact
{data} / {data, nextCursor} / {error:{code,message,details?}} shapes and defines precise semantics for 400, 403, 404, 409, 413, 429, and 500 responses.
- Pagination contract: Requires every collection returning
nextCursor to accept and apply limit + cursor, with keyset or offset cursor codecs bound to sort and filter stamps.
- Strict validation: Enforces
.strict() query and body schemas, mandatory query declarations, and shared v2PaginationFields helpers so no caller input can reach SQL untyped.
- Use Case: When adding a new route under
apps/sim/app/api/v2/, follow the contract-first workflow (contract, use case, route, OpenAPI description) and run the built-in checklist to ship a conformant endpoint.
Quick Start
Audit the route at apps/sim/app/api/v2/workspaces against the v2 API conventions and list every contract violation you find.