Files
task-stream/libs/api/shared/infrastructure
Josep Piguillem 2c501a50d0 feat: uuid ids everywhere, pickers for linked tickets, @pi/ui checkboxes
- Postgres: every table has a uuid `id` (gen_random_uuid()); the event
  store keeps its relay order in `seq`, and the lookup tables their
  uniqueness in constraints of their own.
- MongoDB: `_id` is Mongo's ObjectId; `id` is the domain id (the same
  uuid as the aggregate's stream in Postgres), unique, and every query
  goes by it. Production starts from empty databases.
- Web: linking tickets and hanging one from a parent are picked from a
  searchable select (links across projects, parents within the project)
  instead of typing a key; every checkbox is @pi/ui's pi-checkbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 19:16:43 +02:00
..
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00
2026-10-03 13:40:26 +02:00

api-shared-infrastructure

Event store en PostgreSQL y el camino de los eventos hasta la lectura.

  • Import: @task-stream/api/shared/infrastructure
  • Capa: infrastructure · Tags: scope:api-shared, type:infrastructure

Contenido

  • PostgresEventStore (tabla events, UNIQUE(stream_id, position) → ConcurrencyError).
  • EventSerializer / EventDeserializer y EventStorePublisher (sustituye al publisher del EventBus: commit() persiste).
  • EventStoreRelay: copia los eventos nuevos al Redis Stream (FOR UPDATE SKIP LOCKED).
  • EventsBridge: consume el stream y entrega cada evento a sus @EventsHandler, en orden y esperando (ACK al final); después ejecuta los @Saga() (el EventBus en memoria nunca ve los eventos guardados) y sus comandos, uno a uno.
  • Conexiones Redis (REDIS_CLIENT, GRAPHQL_PUB_SUB) y SharedInfrastructureModule.forRootAsync.

Flujo completo: Arquitectura.

Comandos

npx nx lint api-shared-infrastructure
npx nx test api-shared-infrastructure    # Jest

Reglas de dependencia entre capas: Arquitectura.