Skip to content

feat: add core report fields to Mros entity (PR 1.1)#3621

Merged
TaprootFreak merged 3 commits intodevelopfrom
feat/mros-report-fields-core
Apr 23, 2026
Merged

feat: add core report fields to Mros entity (PR 1.1)#3621
TaprootFreak merged 3 commits intodevelopfrom
feat/mros-report-fields-core

Conversation

@TaprootFreak
Copy link
Copy Markdown
Collaborator

Summary

First of four small API PRs that prepare Mros for full goAML SAR export. This one adds the core report-content fields that appear in every goAML report:

  • reportCode (string, default SAR)
  • reason (long text — Darstellung des Sachverhalts)
  • action (long text — Grund für Verdacht / Was haben Sie bereits unternommen)
  • indicators (JSON-serialised string[] of goAML indicator codes, e.g. ["0002M","1004V","2008G","3004B","3005B","3007B"])

Accessors on the entity expose indicatorCodes as a typed string[] so callers don't see the raw JSON string.

reason, action, indicators are nullable so existing rows stay valid. DTO fields are optional; the create/edit flow on the frontend will enforce required semantics gradually.

Files

  • mros.entity.ts — new columns + indicatorCodes getter/setter
  • create-mros.dto.ts / update-mros.dto.ts — new optional fields
  • mros.service.ts — maps indicators: string[] DTO → entity via setter
  • migration/1776957972101-AddMrosReportFields.js

Roadmap

  • PR 1.1 (this one): core report fields
  • PR 1.2: personOverrides JSON column
  • PR 1.3: Mros ↔ Transaction many-to-many
  • PR 1.4: frontend edit page
  • Phase 2: XML export + XSD validation + download endpoint

Test plan

  • Migration applies cleanly (up + down)
  • Existing MROS row still readable (all new fields null / default SAR)
  • POST /mros with indicators array → stored as JSON string, getById returns row with indicators readable via indicatorCodes
  • PUT /mros/:id with indicators array → updates correctly; with indicators absent → existing value preserved

Extends the Mros entity with the core goAML SAR report-content fields
that every MROS submission needs:

- reportCode (default SAR)
- reason  (Sachverhalt long text)
- action  (Grund / Unternommen long text)
- indicators (JSON-serialised array of goAML indicator codes)

reason/action/indicators are nullable for backward compatibility with
existing rows; the DTOs mark them optional so the UI can roll the
fields out gradually.
To be replaced by a TypeORM-generated migration via
  npm run migration AddMrosReportFields
so the DEFAULT/constraint names match TypeORM's deterministic hash
naming (learned from PR #3613 / constraint-name drift).
@TaprootFreak TaprootFreak merged commit d638dac into develop Apr 23, 2026
7 checks passed
@TaprootFreak TaprootFreak deleted the feat/mros-report-fields-core branch April 23, 2026 15:49
@davidleomay
Copy link
Copy Markdown
Member

Migration was missing!

@TaprootFreak
Copy link
Copy Markdown
Collaborator Author

Fix in #3627. Migration constraint name computed via TypeORM's hash formula (sha1('mros_reportCode').substring(0,27)) — verified against AddMros's existing constraints, so no future drift.

TaprootFreak added a commit that referenced this pull request Apr 27, 2026
Follow-up to PR #3621 — the entity columns reportCode/reason/action/
indicators were merged without a corresponding migration.

Constraint names match TypeORM's auto-generated format
(DF_ + sha1('mros_<column>').substring(0, 27)) so a future
'npm run migration' run on this schema doesn't see drift.
TaprootFreak added a commit that referenced this pull request Apr 27, 2026
…3628)

Reality update from PR #3621: contributors / AI assistants without
local DB setup couldn't run 'npm run migration', so they skipped the
migration entirely (David caught it after merge). The strict ban on
hand-writing didn't survive contact with that case.

The new policy keeps 'npm run migration' as the preferred path but
adds an explicit fallback: hand-written is allowed if the constraint
names match TypeORM's deterministic algorithm. Documents the formula
(prefix + sha1 substring + length per constraint type) and the
many-to-many join-table conventions.

Verifiable: every contributor can sanity-check their hashes against
existing 'AddMros'-style constraints before pushing.
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.

2 participants