refactor(relay): extract shared relay policy presets across endpoints

This commit is contained in:
2026-03-24 18:07:04 +00:00
parent 318f913397
commit fcfb7cf75e
21 changed files with 132 additions and 126 deletions
+37
View File
@@ -1407,3 +1407,40 @@ Validation:
Follow-ups:
- Optional next slice: extract shared relay policy presets into a constants module and reference them from all relayGet endpoints to reduce duplication.
---
### CL-038: TASK22242 P2-S3 closure slice — shared relay policy presets extraction
date: 2026-03-24
author: Cline
scope: `pages/api/middleware/relayPolicyPresets.js`, `pages/api/endpoint/{getaccounts_api,getemailaccountcheck_api,getpreferredlanguage_api,getpersonalaccount_api,getlogin_api,getportallogin_api,getportalloginproxy_api,getbasicsearch_api,getbasicsearchpaged_api,getadvancedsearch_api,getadvancedsearchpaged_api,getportalmoduledetails_api,getportalmoduledetailsproxy_api,getmycases_api,getmyrepresentations_api,getawaitingsubmission_api,getrepresentations_api,getwatchedcases_api}.js`, `tests/phase21/_shared.cjs`
type: change
rationale: Complete the planned P2-S3 final maintainability slice by centralizing repeated relay timeout/retry policy objects into shared presets used consistently across all targeted relayGet endpoints.
impact: Eliminates duplicated policy literals, reduces drift risk, and preserves endpoint contracts/behavior by reusing equivalent policy values.
status: completed
Summary:
- Added new middleware constants module:
- `pages/api/middleware/relayPolicyPresets.js`
- `RELAY_POLICY_STRICT_LOGIN`
- `RELAY_POLICY_LOOKUP`
- `RELAY_POLICY_BOUNDED_READ`
- `RELAY_POLICY_SEARCH_PAGED`
- Refactored 18 relayGet endpoints to import and use shared presets instead of inline `relayPolicy` object literals:
- lookup profile: `getaccounts`, `getemailaccountcheck`, `getpreferredlanguage`, `getpersonalaccount`, `getportalloginproxy`
- strict login profile: `getlogin`, `getportallogin`
- bounded read profile: `getbasicsearch`, `getportalmoduledetails`, `getportalmoduledetailsproxy`, `getmycases`, `getmyrepresentations`, `getawaitingsubmission`, `getrepresentations`, `getwatchedcases`
- search paged profile: `getbasicsearchpaged`, `getadvancedsearch`, `getadvancedsearchpaged`
- Updated phase21 VM test harness (`tests/phase21/_shared.cjs`) to inject preset constants so endpoint contract tests continue to execute with import-stripped modules.
Validation:
- `node tests/phase21/endpoint-handler-contract.test.cjs` -> pass (164/164)
- `node tests/phase21/relay-forwarding-hardening.test.cjs` -> pass (10/10)
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
Follow-ups:
- P2-S3 planned slices are now complete; no further mandatory relay policy rollout slices remain for this stream.