Skip to content

feat: BL-36/BL-37 – Update & Delete Contact API for DQ Stewards - #427

Merged
mdiapenabc merged 20 commits into
devfrom
feat/contact-update-delete-api
Aug 7, 2026
Merged

feat: BL-36/BL-37 – Update & Delete Contact API for DQ Stewards#427
mdiapenabc merged 20 commits into
devfrom
feat/contact-update-delete-api

Conversation

@saifrazabc

@saifrazabc saifrazabc commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Implements the updateContact (BL-36) and deleteContact (BL-37) service methods for Data Quality Stewards to manually correct and permanently remove CSA child records containing erroneous data. Both operations are restricted to the DATA_QUALITY_STEWARD role and cross-validated against ICM to prevent privilege escalation.

Changes

updateContact (BL-36)

  • Restricts access to DATA_QUALITY_STEWARD role only
  • Blocks updates on contacts in a protected CSA status (BL-35)
  • Validates DIN format (9 digits), uniqueness across all contacts
  • Rejects csaStatusEffectiveDate values set in the future
  • Audit trail created automatically via DB trigger
  • Triggers non-blocking ICM sync-back when din or csaStatus changes; sync failures are logged but do not fail the update

deleteContact (BL-37)

  • Same DQ Steward authorization and protected-status guard as update
  • Permanently removes the contact and all associated ICM/MIS staging data in a single transaction
  • Deletes staging tables in correct reverse-dependency order (children before parents)
  • Prisma FK cascade handles audit_trail, contact_batch_details, and wkl_file_records
  • No ICM sync-back triggered on delete

Shared

  • validateDQAuthorization private helper reused by both methods
  • PROTECTED_CSA_STATUSES constant (BL-35) enforced on both operations

How This Was Tested

Unit tests added in contacts.service.spec.ts covering:

Scenario Coverage
Authorization — null profile, wrong role, ICM mismatch updateContact, deleteContact
Contact not found updateContact, deleteContact
Protected CSA status rejection updateContact, deleteContact
Invalid DIN format updateContact
Invalid DIN checksum updateContact
Duplicate DIN updateContact
Future effective date / CSA sent date updateContact
ICM sync-back triggered on DIN change updateContact
ICM sync-back triggered on status change updateContact
ICM sync-back failure does not break update updateContact
Cascade delete order (staging tables) deleteContact
No ICM sync-back on delete deleteContact
Successful update and delete happy paths Both

Run tests locally:

npm run test -- contacts.service.spec.ts

mdsaraza-png and others added 19 commits August 4, 2026 11:10
…update-delete-api

take pull from origin dev
Extend ICM sync to status effective date changes, remove unused AdminService wiring, align DIN docs with format-only validation, use FDD protected-status message, and assert WKL/batch delete order in tests.
Replace ON DELETE CASCADE on contact_audit_trail with RESTRICT (V28) and delete audit rows explicitly in the DQ hard-delete transaction before removing the contact.
…lete

Extract ordered deleteAllContactDependencies with multi-case legal authority cleanup, MIS staging before case removal, documented table lists, and a pre-delete FK guard for batch, audit, and WKL rows.
CSAGuard on ContactsController requires AdminService; removing AdminModule broke SyncModule and CraModule integration tests.
Restore batch CRA validation (#439), Section 54 eligibility (#440),
and Job Monitoring Alerts UI (#438) from dev after a bad merge
reintroduced pre-#439 code on this branch.
Re-sync contacts.service with dev after merge regressions: clear
needsReview when leaving on_hold in updateCsaStatus and
forceUpdateCsaStatus, remove duplicate clear from resumeContacts,
and restore the corresponding unit tests.
Fixes parse error that broke backend CI after fb71542 added a
redundant import alongside the existing one from b69e3a6.
Delete empty 'use strict' barrel file; all imports use
user-profile.constants directly.
Reject unknown csaStatus values in UpdateContactDto and updateContact
using canonical CSA_STATUS codes (BL-36).
Resolve conflicts in contacts controller and service, keeping DQ
update/delete imports (UserProfileDecorator, USER_PROFILE).
@mdiapenabc
mdiapenabc merged commit 6251749 into dev Aug 7, 2026
15 checks passed
@mdiapenabc
mdiapenabc deleted the feat/contact-update-delete-api branch August 7, 2026 20:35
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.

3 participants