Files
TREK/shared
Maurice 52552133e3 feat(journey): comment on journal entries and follow a share link by email
The people on a journey can now talk about its entries, and a reader of its
share link can comment there too and follow the journey by email (#1702,

- journey_entry_comments holds a comment under an entry: by an account or
  signed with a name through the link, plain text up to 2000 characters. It
  goes with its entry and journey; a deleted account leaves it as unknown.
  Everyone on the journey reads and writes them, the author or an editor
  deletes one, an editor hides one from everyone but the editors.
- The share link gains allow_comments and allow_subscriptions (default 0,
  kept when a save leaves them out). Readers comment under the entries the
  link shows, behind the link's password gate, with a honeypot field and a
  limit per address and link. The public payload says what a reader may do.
- journey_share_subscribers holds an address following a link, with double
  opt-in: one mail asks to confirm it, nothing else is sent before. The mail
  links open app pages that post the token, so a scanner changes nothing.
  The owner lists and removes the addresses; they go with the link.
- A daily job (journey-digest) tells everyone on a journey about entries
  published since the last run (journey_entry_published, their settings
  apply, not about their own), mails each confirmed follower once a day in
  their language with an unsubscribe link and a List-Unsubscribe header, and
  forgets addresses unconfirmed for a week. journey_entries.announced marks
  what was told; existing published entries start as told.
- The owner hears about a new comment (journey_comment). Both events are
  translated in every locale, as are the follower mails.
- journey:entry:commented pings the journey's people; the journal page
  leaves it to the comments reader instead of reloading.
- MCP: list_journey_comments, set_journey_comment_hidden,
  delete_journey_comment, list_journey_subscribers, remove_journey_subscriber,
  and create_journey_share_link takes both switches like the REST route. The
  assistant is not offered the follower tools.
2026-11-30 16:56:15 +01:00
..
2026-06-16 22:22:45 +02:00
2026-06-16 22:22:45 +02:00

@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): via paths in server/tsconfig.json.
  • Client (vite): via resolve.alias in client/vite.config.ts (+ paths for 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.