Files
yara724-api/docs/legacy-api-cleanup.md

217 lines
15 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# API legacy retirement and signature status
Reviewed the API controller surface, both frontend source trees (including expert-panel server proxies), runtime service references, API scripts, and workflow/role documentation. This cleanup starts from the working tree containing the claim-beneficiary authorization fixes; it preserves those fixes.
## Signature follow-up
Ordinary users now get the same fresh case status on both the final page and the older waiting-for-signature URL. While waiting, the case is refreshed every 10 seconds and on window focus. The page explicitly says that their signature is recorded and the other party is still required. After the other signature arrives, server-provided nextAction and claimCreation determine the new message and allowed action. Only the beneficiary sees claim creation. Existing expert declaration behavior is retained.
The silent refresh button was removed. A background refresh failure retains the last successful case, explains that it is the last known status, and offers a retry with a loading state. Initial failures still show the full retry screen. Long declarations can scroll on small screens.
## Removed code
- 77 retired routes: obsolete unversioned blame/claim mutations and reads, obsolete expert-claim review/price-drop workflows, hidden registrar V1 aliases, legacy genuine/legal registrations, and deprecated workflow-step helper routes.
- 215 unreachable service methods, including their private helper chains and unused database wrappers. Reachability includes controllers, other services, lifecycle hooks, decorated methods, scripts, callbacks, and conservative handling of dynamic property references.
- 35 orphaned TypeScript files: old DTOs, response types, unused PDF helpers, examples, barrels, and an obsolete JSON pipe.
- Three empty database providers, their unused injections, unused private configuration/price-drop fields, and three retired controllers. Persistent collection registrations and schemas still used by active or blame-expert paths remain.
- The unused frontend claim-picker component, its sort helper, and its unversioned claimable-list client method; the unused legacy Fanavaran client method was also removed.
No database migration, document rewrite, or collection deletion is performed.
## Deliberately retained
- Every V1–V6 screen flow. The current V1 user screens call V2 APIs; UI flow versions and API prefixes are different concepts. V1-specific limits and historical workflow repair remain.
- Both unversioned and V2 blame-expert controllers, the entire blame-expert service, and its reachable legacy helpers, media and historical models.
- The unversioned GET /claim-request-management/car-other-part catalog, GET /expert-claim/imageRequired/:id, GET /expert-claim/stream/:id/voice, and POST /expert-initiated-blame/add-accident-fields/:requestId, because frontend clients/server proxies still reference them. Their guards, roles and responses are unchanged.
- Versioned expert-initiated and registrar APIs, all V3/V4/V5/V6 creation/review/approval/link workflows, role onboarding, inquiries, lookup caching, AI, current Fanavaran stages, uploads, reports, and background retry/maintenance jobs.
- Deprecated report routes that still have frontend callers, and Fanavaran preview query parameters retained for compatibility. A deprecation label by itself was not treated as proof of disuse.
- Historical data/status fallbacks reachable from current endpoints. “Legacy data” is not the same as an unused endpoint.
The remaining large services implement active workflows and Fanavaran mappings; they were not split or rewritten during this cleanup.
## Verification
A structural comparison against the pre-cleanup working tree found identical executable method structure for all 1,336 retained controller/service methods. Formatting, imports and unused constructor dependencies changed; retained method logic did not.
The public route/access contract in test/contracts/api-routes.json was captured from the pre-cleanup controllers after excluding the explicitly retired routes. src/core/api-route-contract.spec.ts checks all 381 remaining routes against live Nest metadata, including controller and method guards and role restrictions. Update this contract deliberately when changing the public API.
Regression coverage includes active claim eligibility, cross-tenant/reviewer authorization, V4/V5 transitions, optional documents, captures/AI, licensing inquiries, Fanavaran stage fields, and pricing. Tests solely exercising removed legacy endpoints were retired; equivalent active V2 safeguards remain tested. Constructor mocks use named dependencies where removals changed argument positions.
The UI status tests cover polling, completion, beneficiary-only actions, initial/background errors and retries. Local browser checks use mocked case responses on the real pages at 320px, 390px and 1366px; they exercise automatic completion and refresh error recovery.
Final checks: 77 API suites / 486 tests passed; API production build passed; both frontend regression suites passed; user UI production build passed. The UI detector reported no findings. Blame-expert source files were not modified.
## Controller audit
Every controller was included. Counts are HTTP routes, including hidden routes.
| Controller | Before | Retained | Retired |
| --- | ---: | ---: | ---: |
| `auth/auth-controllers/actor/actor.auth.controller.ts` | 14 | 12 | 2 |
| `auth/auth-controllers/user/user.auth.controller.ts` | 2 | 2 | 0 |
| `case-expert-report/case-expert-report.controller.ts` | 1 | 1 | 0 |
| `claim-request-management/claim-request-management.controller.ts` | 19 | 1 | 18 |
| `claim-request-management/claim-request-management.v2.controller.ts` | 17 | 17 | 0 |
| `claim-request-management/expert-initiated-claim.mirror.controller.ts` | 11 | 11 | 0 |
| `claim-request-management/registrar-claim.mirror.controller.ts` | 10 | 10 | 0 |
| `claim-request-management/registrar-claim.v1.controller.ts` | 7 | 0 | 7 |
| `client/client-external-inquiries.controller.ts` | 5 | 5 | 0 |
| `client/client-panel.controller.ts` | 2 | 2 | 0 |
| `client/client.controller.ts` | 4 | 4 | 0 |
| `expert-blame/expert-blame.controller.ts` | 10 | 10 | 0 |
| `expert-blame/expert-blame.v2.controller.ts` | 9 | 9 | 0 |
| `expert-claim/expert-claim.controller.ts` | 13 | 2 | 11 |
| `expert-claim/expert-claim.v2.controller.ts` | 23 | 23 | 0 |
| `expert-insurer/expert-insurer.controller.ts` | 23 | 23 | 0 |
| `fanavaran/fanavaran.controller.ts` | 9 | 9 | 0 |
| `lookups/lookups.controller.ts` | 48 | 48 | 0 |
| `profile/profile.controller.ts` | 4 | 4 | 0 |
| `reports/reports.controller.ts` | 5 | 5 | 0 |
| `request-management/call-center-blame-v6.controller.ts` | 6 | 6 | 0 |
| `request-management/expert-initiated-blame-v3.mirror.controller.ts` | 19 | 19 | 0 |
| `request-management/expert-initiated-blame.mirror.controller.ts` | 14 | 14 | 0 |
| `request-management/expert-initiated.controller.ts` | 8 | 1 | 7 |
| `request-management/expert-initiated.v2.controller.ts` | 14 | 14 | 0 |
| `request-management/file-maker-blame-v4.controller.ts` | 15 | 15 | 0 |
| `request-management/file-maker-blame-v5.controller.ts` | 15 | 15 | 0 |
| `request-management/file-maker-claim-approval-v5.controller.ts` | 2 | 2 | 0 |
| `request-management/file-reviewer-blame-v4.controller.ts` | 12 | 12 | 0 |
| `request-management/file-reviewer-blame-v5.controller.ts` | 12 | 12 | 0 |
| `request-management/inquiry-refresh.controller.ts` | 1 | 1 | 0 |
| `request-management/registrar-blame.mirror.controller.ts` | 13 | 13 | 0 |
| `request-management/registrar-initiated.controller.ts` | 10 | 0 | 10 |
| `request-management/request-management.controller.ts` | 14 | 0 | 14 |
| `request-management/request-management.v2.controller.ts` | 15 | 15 | 0 |
| `super-admin/super-admin.controller.ts` | 33 | 31 | 2 |
| `system-settings/system-settings.controller.ts` | 5 | 5 | 0 |
| `workflow-step-management/workflow-step-management.controller.ts` | 14 | 8 | 6 |
## Removed service methods
Line counts below exclude surrounding comments/imports and deleted orphan files.
| Service | Methods | Implementation lines |
| --- | ---: | ---: |
| `users/entities/db-service/damage-expert.db.service.ts` | 1 | 5 |
| `users/entities/db-service/registrar.db.service.ts` | 1 | 3 |
| `users/entities/db-service/file-maker.db.service.ts` | 2 | 8 |
| `users/entities/db-service/file-reviewer.db.service.ts` | 2 | 8 |
| `users/entities/db-service/call-center-agent.db.service.ts` | 1 | 7 |
| `auth/auth-services/actor.auth.service.ts` | 3 | 12 |
| `users/entities/db-service/user.db.service.ts` | 1 | 3 |
| `users/entities/db-service/expert-file-activity.db.service.ts` | 1 | 24 |
| `fanavaran/fanavaran-audit.service.ts` | 1 | 7 |
| `fanavaran/fanavaran-auth.service.ts` | 1 | 3 |
| `fanavaran/fanavaran-location.service.ts` | 1 | 3 |
| `client/external-inquiry-settings.service.ts` | 1 | 11 |
| `client/client.service.ts` | 2 | 6 |
| `client/entities/db-service/branch.db.service.ts` | 1 | 6 |
| `lookups/entities/db-service/lookup.db.service.ts` | 2 | 6 |
| `sand-hub/entity/db-service/sand-hub.db.service.ts` | 4 | 21 |
| `sand-hub/sand-hub.service.ts` | 2 | 23 |
| `plates/plates.service.ts` | 1 | 21 |
| `request-management/entities/db-service/blame-video.db.service.ts` | 1 | 3 |
| `request-management/entities/db-service/request-management.db.service.ts` | 5 | 24 |
| `request-management/entities/db-service/blame-request.db.service.ts` | 1 | 5 |
| `workflow-step-management/entities/db-service/workflow-step.db.service.ts` | 2 | 15 |
| `workflow-step-management/workflow-step-management.service.ts` | 5 | 68 |
| `media-policy/media-policy.service.ts` | 1 | 11 |
| `request-management/entities/db-service/blame-document.db.service.ts` | 3 | 12 |
| `request-management/entities/db-service/sign.db.service.ts` | 1 | 3 |
| `claim-request-management/entites/db-service/claim-case.db.service.ts` | 1 | 3 |
| `claim-request-management/entites/db-service/claim-request-management.db.service.ts` | 11 | 63 |
| `request-management/request-management.service.ts` | 44 | 3222 |
| `claim-request-management/entites/db-service/car-green-card.db.service.ts` | 2 | 8 |
| `claim-request-management/entites/db-service/damage-image.db.service.ts` | 2 | 6 |
| `claim-request-management/entites/db-service/factor-image.db.service.ts` | 1 | 5 |
| `claim-request-management/entites/db-service/video-capture.db.service.ts` | 1 | 5 |
| `claim-request-management/entites/db-service/claim-required-document.db.service.ts` | 4 | 16 |
| `claim-request-management/claim-request-management.service.ts` | 66 | 2123 |
| `expert-claim/expert-claim.service.ts` | 31 | 1334 |
| `expert-insurer/expert-insurer.service.ts` | 3 | 86 |
| `super-admin/super-admin.service.ts` | 2 | 6 |
## Retired route list
These URLs now have no controller handler. Current frontend workflows use their versioned replacements or no longer expose the obsolete operation.
| Method | Retired route |
| --- | --- |
| POST | `/actor/register/genuine` |
| POST | `/actor/register/legal` |
| POST | `/claim-request-management/:blameId` |
| PATCH | `/claim-request-management/car-part-damage/:claimRequestID` |
| PATCH | `/claim-request-management/car-other-part-damage/:claimRequestID` |
| GET | `/claim-request-management/required-documents-status/:claimRequestID` |
| GET | `/claim-request-management/car-part-image-required/:claimRequestID` |
| PATCH | `/claim-request-management/upload-required-document/:claimRequestID` |
| PATCH | `/claim-request-management/capture-car-part-damage/:claimRequestID/:partId` |
| PATCH | `/claim-request-management/car-capture/:claimRequestID` |
| GET | `/claim-request-management/requests` |
| GET | `/claim-request-management/request/:claimRequestId` |
| PUT | `/claim-request-management/request/reply/:claimRequestId` |
| PUT | `/claim-request-management/request/resend/:claimRequestId/objection` |
| PATCH | `/claim-request-management/request/resend/:claimRequestId` |
| PUT | `/claim-request-management/request/:claimRequestId/user-rating` |
| PATCH | `/claim-request-management/request/reply/:claimRequestId/:partId/upload-factor` |
| PATCH | `/claim-request-management/:id/visit` |
| GET | `/claim-request-management/fanavaran-submit/:claimRequestId` |
| POST | `/claim-request-management/fanavaran-submit/:claimRequestId` |
| POST | `/registrar-claim/create-from-blame/:blameRequestId` |
| GET | `/registrar-claim/request/:claimRequestId` |
| PATCH | `/registrar-claim/select-outer-parts/:claimRequestId` |
| PATCH | `/registrar-claim/select-other-parts/:claimRequestId` |
| GET | `/registrar-claim/capture-requirements/:claimRequestId` |
| POST | `/registrar-claim/upload-document/:claimRequestId` |
| POST | `/registrar-claim/capture-part/:claimRequestId` |
| GET | `/expert-claim` |
| GET | `/expert-claim/:id` |
| GET | `/expert-claim/required-documents/:id` |
| PUT | `/expert-claim/lock/:id` |
| PUT | `/expert-claim/reply/submit/:id` |
| PUT | `/expert-claim/resend/submit/:id` |
| GET | `/expert-claim/stream/:id/video` |
| GET | `/expert-claim/link/:id/video` |
| PATCH | `/expert-claim/validate-factors/:claimId` |
| PATCH | `/expert-claim/:id/visit` |
| GET | `/expert-claim/branches/:insuranceId` |
| GET | `/expert-initiated-blame/my-files` |
| POST | `/expert-initiated-blame/complete-blame-data/:requestId` |
| POST | `/expert-initiated-blame/complete-claim-data/:claimRequestId` |
| POST | `/expert-initiated-blame/complete-form-third-party/:requestId` |
| POST | `/expert-initiated-blame/complete-form-car-body/:requestId` |
| POST | `/expert-initiated-blame/upload-video/:requestId` |
| POST | `/expert-initiated-blame/upload-voice/:requestId` |
| POST | `/registrar-initiated-blame/create` |
| GET | `/registrar-initiated-blame/my-files` |
| GET | `/registrar-initiated-blame/blame/:requestId` |
| POST | `/registrar-initiated-blame/send-party-otps/:requestId` |
| POST | `/registrar-initiated-blame/verify-party-otps/:requestId` |
| POST | `/registrar-initiated-blame/complete-blame-data/:requestId` |
| POST | `/registrar-initiated-blame/upload-video/:requestId` |
| POST | `/registrar-initiated-blame/upload-voice/:requestId` |
| POST | `/registrar-initiated-blame/add-accident-fields/:requestId` |
| POST | `/registrar-initiated-blame/upload-party-signature/:requestId` |
| POST | `/blame-request-management/initial-form/:requestId` |
| POST | `/blame-request-management/upload-video/:requestId` |
| POST | `/blame-request-management/add-plate/:requestId` |
| POST | `/blame-request-management/carbody-form/:requestId` |
| POST | `/blame-request-management/carbody-secondform/:requestId` |
| POST | `/blame-request-management/add-detail-location/:requestId` |
| POST | `/blame-request-management/upload-voice/:requestId` |
| POST | `/blame-request-management/add-detail-description/:requestId` |
| POST | `/blame-request-management/add-second-party-details/:phoneNumber/:requestId/:frontendRoutes` |
| GET | `/blame-request-management/requests` |
| GET | `/blame-request-management/creatable-claims` |
| GET | `/blame-request-management/request/:requestId` |
| PUT | `/blame-request-management/request/reply/:requestId` |
| PUT | `/blame-request-management/request/resend/:requestId` |
| POST | `/super-admin/register/genuine` |
| POST | `/super-admin/register/legal` |
| POST | `/workflow-step-management/bulk-upsert` |
| POST | `/workflow-step-management/validate-access` |
| GET | `/workflow-step-management/category/:category` |
| GET | `/workflow-step-management/next-steps/:stepKey` |
| GET | `/workflow-step-management/fields/:stepKey` |
| GET | `/workflow-step-management/step/:stepKey` |