GET /api/tours/library lists the tours of every trip the user owns or is a member of, with the trip each is in and how many tours each trip holds, to choose one to take over into the trip being planned. It is narrowed by a part of the name (matched ignoring case, a "%" or "_" just a character), a type or one trip, and the asking trip can be left out; up to 100 tours, and the answer says when there were more. GET /api/tours/library/:placeId previews one: its facts and its line thinned to 400 points, its ends kept. Neither is trip-scoped, so every answer is bounded by the user's own trips, read anew each call: a tour of a trip out of reach is "not found", nothing hints that it exists. Measures stay null where the tour has none. POST /api/trips/:tripId/tours/take-over copies one into this trip, which the guard checks with 'place_edit'; the source trip is checked against the user's trips as they are at that moment, and the source is read again inside the write. The copy is a tour of its own: its line, measures, settings and control points, without days, without its stops' links to places of the other trip and without the obstacle decisions taken there; it keeps the import record of its line. A copy that fails leaves nothing behind. Where it came from is kept as text (tours.taken_over_from_trip_title and taken_over_from_tour_name, migration 045100), not as a pointer, and read back in the provenance as takenOverFrom; a copy of such a copy names it too. The in-trip copy (P2C-07) and the take-over share one copy routine. MCP: list_tour_library and take_over_tour, over the same service and checks. The repository tests follow the hiking preferences column of MF-08.
@trek/shared
Single source of truth for TREK's API contracts, expressed as Zod schemas and consumed by both the server (request validation + inferred DTO types) and the client (typed requests/responses).
This package is part of the incremental NestJS + React 19 migration (see the "Brownfield Rewrite" board). It is intentionally dormant until modules start importing it — adding it changes nothing for users.
Rules
- One folder per domain:
src/<domain>/<domain>.schema.ts(+.spec.ts). - Domain-agnostic building blocks live in
src/common/. - A route is only considered migrated once its contract lives here.
- Schemas are the source of truth; server DTOs and client types are inferred from them
(
z.infer<typeof schema>), never hand-duplicated.
Consumption (dev)
Both apps resolve @trek/shared to this package's TypeScript source:
- Server (
tsx): viapathsinserver/tsconfig.json. - Client (
vite): viaresolve.aliasinclient/vite.config.ts(+pathsfor the type-checker).
Production packaging (Docker / workspace wiring) is introduced in card F2, when the server first depends on this package at runtime. Until then prod builds are untouched.
Not yet here
The canonical error envelope is finalised in card F5 (it must match TREK's current Express error responses byte-for-byte), so it is deliberately not invented in F1.