Skip to content

feat(cases/notes): implement investigation notes system (#127) - #177

Merged
mijinummi merged 3 commits into
MD-Creative-Production:mainfrom
amankoli09:feat/investigation-notes-system
Jun 21, 2026
Merged

feat(cases/notes): implement investigation notes system (#127)#177
mijinummi merged 3 commits into
MD-Creative-Production:mainfrom
amankoli09:feat/investigation-notes-system

Conversation

@amankoli09

Copy link
Copy Markdown
Contributor

Closes #127

🧠 Summary

Implements the Investigation Notes System as specified issue
Allows security teams to record, edit, and track investigation findings
per case with a full immutable audit history.

✅ Changes

New: src/modules/cases/notes/

  • NotesService — CRUD + soft-delete + per-note audit trail using PrismaClient.
    • Access controlled: only the note author may update or delete their note (ForbiddenException otherwise).
    • Every write appends an immutable audit entry (created | updated | deleted).
  • NotesController — 5 REST endpoints scoped to /cases/:caseId/notes, including a dedicated /history route.
  • NotesModule — NestJS module; exports NotesService for consumption by other modules.
  • note.interface.ts — Full TypeScript interface definitions (CreateNoteDto, UpdateNoteDto, NoteAuditEntry, InvestigationNote).
  • Unit testsnotes.service.spec.ts (15 cases) + notes.controller.spec.ts (6 cases).

Modified: prisma/schema.prisma

  • Added InvestigationNote model with caseId index, soft-delete fields, and tags array.
  • Added NoteAuditLog model with noteId index for migration-ready dedicated audit storage.

Modified: apps/backend/src/app.module.ts

  • Registered NotesModule so endpoints are live on app startup.

🎯 Acceptance Criteria

  • Notes supported (create, read, update, soft-delete)
  • Changes tracked (immutable NoteAuditLog audit entries on every write)
  • Access controlled (author-only mutations, ForbiddenException enforced)

🔗 Closes #127

…Production#127)

- Add NotesService with create/read/update/soft-delete and audit trail
- Add NotesController with REST endpoints under /cases/:caseId/notes
- Add NotesModule and register it in AppModule
- Add InvestigationNote and NoteAuditLog Prisma models (schema.prisma)
- Add barrel index.ts for clean imports
- Add unit tests for NotesService and NotesController

Closes MD-Creative-Production#127
…ude path and remove type casts

- Move src/modules/cases/notes/ → apps/backend/src/modules/cases/notes/
  so files are covered by tsconfig.json include: ["apps/backend/**/*"]
- Fix import path in app.module.ts: use relative ./modules/cases/notes
  instead of broken ../../../src/modules/cases/notes path
- Replace (prisma.auditLog as any).update() casts with properly typed
  prisma.auditLog.update() calls (no any cast needed)
- Clean up spec: replace mid-test mock re-assignments with mockResolvedValue
@mijinummi

Copy link
Copy Markdown
Collaborator

Hello @amankoli09 , kindly fix and run lint, typescript check, update your branch and push again. Thank you for your contribution.

…-Production#127)

- tsconfig: add explicit "types": ["node", "jest"] so ambient node/jest
  globals resolve under TS 6 (fixes repo-wide "Cannot find name
  'jest'/'process'" type-check errors)
- notes: apply prettier formatting and drop unused PrismaClient import
  to satisfy eslint

No behavior change; all backend tests (119) pass, build is green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mijinummi

Copy link
Copy Markdown
Collaborator

LGTM

@mijinummi
mijinummi merged commit 4b08787 into MD-Creative-Production:main Jun 21, 2026
11 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 21, 2026
3 tasks
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.

Implement Investigation Notes System

2 participants