@ventori/contracts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/index.d.mts +1917 -0
- package/dist/index.mjs +305 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @ventori/contracts
|
|
2
|
+
|
|
3
|
+
Shared contracts for Ventori ERP — ts-rest routers, Zod schemas, and inferred types.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
- **ts-rest** v3 — contract-first HTTP routing
|
|
8
|
+
- **Zod** — validation + type inference
|
|
9
|
+
- **TypeScript** 5.x
|
|
10
|
+
- **tsup** — build (esbuild)
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
| Command | Action |
|
|
15
|
+
|----------------|------------------------------|
|
|
16
|
+
| `pnpm install` | Install dependencies |
|
|
17
|
+
| `pnpm build` | Build ESM + DTS |
|
|
18
|
+
| `pnpm lint` | Type check (`tsc --noEmit`) |
|
|
19
|
+
| `pnpm clean` | Remove `dist/` and `.turbo/` |
|
|
20
|
+
|
|
21
|
+
## Project structure
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
src/
|
|
25
|
+
├── common/ Shared utilities (pagination, CRUD factory, error schemas, handlers, HTTP methods)
|
|
26
|
+
├── user/ User schema + contract
|
|
27
|
+
├── product/ Product schema + contract
|
|
28
|
+
├── order/ Order schema + contract
|
|
29
|
+
└── index.ts Package entry point
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Each domain follows the same pattern: a `*.schema.ts` with Zod definitions and a `*.contract.ts` with the ts-rest router.
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { userContract } from "@ventori/contracts";
|
|
38
|
+
|
|
39
|
+
// Types are inferred from the contract
|
|
40
|
+
type User = typeof userContract.findById.responses[200];
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Adding a new entity
|
|
44
|
+
|
|
45
|
+
1. Create `src/{entity}/` with `*.schema.ts` and `*.contract.ts`
|
|
46
|
+
2. Export from `src/{entity}/index.ts`
|
|
47
|
+
3. Add re-export to `src/index.ts`
|
|
48
|
+
|
|
49
|
+
The CRUD contract is generated via `createCrudEndpoints()` — add custom endpoints by spreading the base.
|
|
50
|
+
|
|
51
|
+
## Architecture
|
|
52
|
+
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
See `AGENTS.md` for detailed conventions.
|