Add @trails-cool/api package with Zod schemas for REST API contract

Single source of truth for the Journal REST API:
- API_VERSION semver constant (1.0.0)
- Endpoint path constants (routes, activities, auth, uploads, push)
- Zod schemas for all request/response shapes:
  - Routes: list, detail, create, update, compute
  - Activities: list, detail, create
  - Auth: token exchange, refresh, device management
  - Discovery: instance info + API version
  - Uploads: presigned URL flow
  - Errors: structured error response with field-level details
- Cursor-based pagination schemas
- TypeScript types inferred from Zod (z.infer)

Used by Journal server (validation) and mobile client (type safety).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-12 22:49:30 +02:00
parent 572d240ed1
commit 49b304749e
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
13 changed files with 349 additions and 0 deletions

11
pnpm-lock.yaml generated
View file

@ -410,6 +410,12 @@ importers:
specifier: 'catalog:'
version: 8.0.8(@types/node@25.5.2)(esbuild@0.27.4)(jiti@2.6.1)(tsx@4.21.0)
packages/api:
dependencies:
zod:
specifier: ^3.25.0
version: 3.25.76
packages/db:
dependencies:
drizzle-orm:
@ -4102,6 +4108,9 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
zod@3.25.76:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
snapshots:
'@adobe/css-tools@4.4.4': {}
@ -7620,3 +7629,5 @@ snapshots:
lib0: 0.2.117
yocto-queue@0.1.0: {}
zod@3.25.76: {}