@ventori/contracts
v1.2.3
Published
Shared contracts for Ventori ERP — ts-rest routers, Zod schemas, and inferred types
Readme
@ventori/contracts
Shared contracts for Ventori ERP — ts-rest routers, Zod schemas, and inferred types.
Stack
- ts-rest v3 — contract-first HTTP routing
- Zod — validation + type inference
- TypeScript 5.x
- tsup — build (esbuild)
Commands
| Command | Action |
|----------------|------------------------------|
| pnpm install | Install dependencies |
| pnpm build | Build ESM + DTS |
| pnpm lint | Type check (tsc --noEmit) |
| pnpm clean | Remove dist/ and .turbo/ |
Project structure
src/
├── common/ Shared utilities (pagination, CRUD factory, error schemas, handlers, HTTP methods)
├── contracts/ Domain contracts
│ ├── user/ User schema + contract
│ └── product/ Product schema + contract
└── index.ts Package entry pointEach domain follows the same pattern: a *.schema.ts with Zod definitions and a *.contract.ts with the ts-rest router.
Usage
import { userContract } from "@ventori/contracts";
// Types are inferred from the contract
type User = typeof userContract.findById.responses[200];Adding a new entity
- Create
src/{entity}/with*.schema.tsand*.contract.ts - Export from
src/{entity}/index.ts - Add re-export to
src/index.ts
The CRUD contract is generated via createCrudEndpoints() — add custom endpoints by spreading the base.
Architecture
Contracts are the source of truth. The target architecture (domain, dal, drivers, apps, sdk) is documented in docs/plan-implementacion.md and docs/arquitectura-implementacion.md. Currently only the contracts layer is implemented.
See AGENTS.md for detailed conventions.
