Skip to content

feat(server): add invitations endpoints and wire CollabModule into AppModule - #15

Closed
facyndev wants to merge 4 commits into
feature/api-rest-crud-02-sessions-terminalsfrom
feature/api-rest-crud
Closed

facyndev wants to merge 4 commits into
feature/api-rest-crud-02-sessions-terminalsfrom
feature/api-rest-crud

Conversation

@facyndev

@facyndev facyndev commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds InvitationsController: POST /workspaces/:id/invitations (invite member, owner-only), POST /sessions/:id/invitations (invite guest, owner-only), GET /invitations (caller's pending invitations with target + inviter), POST /invitations/:id/accept and POST /invitations/:id/decline (invitee-only; 204).
  • Ghost invitees (well-formed UUID, nonexistent user) → 404 via a UserRepository.findById precheck placed after the owner check (no user-enumeration leak; the FK would make any stored row unpersistable — Prisma P2003/Postgres 23503) and no invitation row is stored (asserted). Malformed non-UUID :id params → 404 before Prisma (Postgres uuid columns throw on malformed ids → would be 500).
  • Accept order: domain aggregate save first, setStatus('accepted') last — a failed accept provably leaves the row pending (tested: seeded-member accept → 409 + row still PENDING). Domain errors map to HTTP via domain-errors.ts (NotOwner→403, AlreadyHasAccess→409, already responded→409).
  • InvitationRepository registered and exported in PersistenceModule.
  • AppModule wiring (T5): AppModule now imports CollabModule, so the production module graph exposes the REST surface. New src/app.routes.int.spec.ts boots the real AppModule and pins S14 per controller: unauthenticated hits on workspaces/sessions/terminals/invitations routes → 401, /health stays 200.

Changes

File Change
apps/api/src/collab/invitations.controller.ts 5 authenticated routes (S9–S13)
apps/api/src/collab/invitations.service.ts invite/list/accept/decline orchestration (transactional accept)
apps/api/src/collab/domain-errors.ts domain → HTTP mapping (S15)
apps/api/src/persistence/persistence.module.ts InvitationRepository provided + exported
apps/api/src/app.module.ts imports CollabModule
apps/api/src/collab/invitations.controller.int.spec.ts 24 integration tests (RED→GREEN)
apps/api/src/app.routes.int.spec.ts 5 integration tests on the real AppModule (RED 4/5 → GREEN 5/5)

Test evidence

  • Integration: 153/153 (29 new) · Unit: 166/166 · typecheck exit 0 · build exit 0 · gitleaks clean
  • Parent spot-check re-ran the invitations focused suite (24/24, exit 0).

Chain Context

Field Value
Chain api-rest-crud (REST CRUD: workspaces / sessions / terminals / invitations)
Tracker PR Draft PR feature/api-rest-crud → develop (created after the slice PRs)
Position 3 of 3 slices
Base feature/api-rest-crud-02-sessions-terminals (retarget as ancestors merge)
Depends on #14 (sessions + terminals slice), which depends on #13
Follow-up None (last slice; then the tracker PR merges the full feature)
Review budget 1048 / 400 — size:exception: user-decided slice (feature doc L8) of T4 (delegated writer unit, 5 routes + 24 tests) + T5 (wiring + route spec) + feature-doc closure
Starts at #14 (3d2ae33)
Ends with Complete REST CRUD surface wired into the production AppModule

Chain Overview

develop
  └── #13 workspaces (T1) — merged first
       └── #14 sessions + terminals (T2+T3)
            └── � #<this> invitations + AppModule wiring (T4+T5)
                 └── draft tracker PR: feature/api-rest-crud → develop (full feature)

Scope

  • Includes: invitations lifecycle, ghost-invitee handling, error mapping, AppModule wiring, route-registration spec
  • Excludes: desktop dual storage mode (next feature, separate branch), advisories R3-001/R3-002 (open follow-ups)

Autonomy

  • CI is expected to pass for this PR branch
  • This PR has one deliverable scope
  • This PR can be rolled back without unrelated changes
  • Tests cover this unit (29 integration tests)

@facyndev

Copy link
Copy Markdown
Owner Author

Landed via tracker PR #16 (feature-branch-chain): this slice's commits are on develop as of 0dd8d1c. Closing the review slice — full feature merged.

@facyndev facyndev closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant