From eb3b6013b3887d74cdd25c585e6245f232c1762c Mon Sep 17 00:00:00 2001 From: robbond Date: Wed, 25 Mar 2026 06:19:37 +0000 Subject: [PATCH] refactor(actions): adopt endpoint client in reference data service --- actions/clients/README.md | 5 ++ .../services/referenceDataDirectService.js | 80 +++++++------------ memory-bank/change-log.md | 28 +++++++ 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/actions/clients/README.md b/actions/clients/README.md index 6534a3ea..b5fe214c 100644 --- a/actions/clients/README.md +++ b/actions/clients/README.md @@ -7,6 +7,11 @@ Current extracted clients: - `relayClient` (shared hash-signing helper used by account/portal/document direct services) - `endpointClient` (shared JSON request helpers for GET and generic axios config requests) +Current usage includes: + +- relay hash-signing helper reuse across account/portal/document direct services +- shared endpoint JSON request helpers reused by admin/notify/integration/reference-data direct services + Notes: - Core helper extraction and compatibility barrel support remain in place. diff --git a/actions/services/referenceDataDirectService.js b/actions/services/referenceDataDirectService.js index 406c8103..cafa9a7d 100644 --- a/actions/services/referenceDataDirectService.js +++ b/actions/services/referenceDataDirectService.js @@ -1,76 +1,58 @@ -import axios from "axios"; import { BASE_URL } from "../core/env"; import { consoleLogger } from "../core/logger"; import { logAndReturnEmptyValueErrorResponse } from "./httpServiceUtils"; +import { getJson } from "../clients/endpointClient"; export const getAppealsTypes = () => { - return axios - .get(BASE_URL + "/api/endpoint/getappealtypes_api") - .then((res) => res.data) - .catch(logAndReturnEmptyValueErrorResponse); + return getJson(BASE_URL + "/api/endpoint/getappealtypes_api").catch( + logAndReturnEmptyValueErrorResponse + ); }; export const getProjectTypes = () => { - return axios - .get(BASE_URL + "/api/endpoint/getprojecttypes_api") - .then((res) => res.data) - .catch(logAndReturnEmptyValueErrorResponse); + return getJson(BASE_URL + "/api/endpoint/getprojecttypes_api").catch( + logAndReturnEmptyValueErrorResponse + ); }; export const getAppealsTypesForNewAppeal = () => { - return axios - .get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api") - .then((res) => res.data) - .catch(logAndReturnEmptyValueErrorResponse); + return getJson( + BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api" + ).catch(logAndReturnEmptyValueErrorResponse); }; export const getLPA = () => { - return axios - .get(BASE_URL + "/api/endpoint/getlpa_api") - .then((res) => { - return res.data; - }) - .catch(logAndReturnEmptyValueErrorResponse); + return getJson(BASE_URL + "/api/endpoint/getlpa_api").catch( + logAndReturnEmptyValueErrorResponse + ); }; export const getFormData = (whichForm) => { - return axios - .get(BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm) - .then((res) => res.data) - .catch((error) => { - consoleLogger(error); - }); + return getJson( + BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm + ).catch((error) => { + consoleLogger(error); + }); }; export const getMandatoryFields = (whichForm) => { - return axios - .get( - BASE_URL + - "/api/endpoint/getmandatoryfields_api?whichForm=" + - whichForm - ) - .then((res) => res.data) - .catch((error) => { - consoleLogger(error); - }); + return getJson( + BASE_URL + "/api/endpoint/getmandatoryfields_api?whichForm=" + whichForm + ).catch((error) => { + consoleLogger(error); + }); }; export const getPickLists = (whichForm) => { - return axios - .get(BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm) - .then((res) => res.data) - .catch((error) => { - consoleLogger(error); - }); + return getJson( + BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm + ).catch((error) => { + consoleLogger(error); + }); }; export const getNotice = () => { - return axios - .get(BASE_URL + "/api/notices") - .then((res) => { - return res.data; - }) - .catch((error) => { - consoleLogger(error); - }); + return getJson(BASE_URL + "/api/notices").catch((error) => { + consoleLogger(error); + }); }; diff --git a/memory-bank/change-log.md b/memory-bank/change-log.md index 21ea2e49..315a370b 100644 --- a/memory-bank/change-log.md +++ b/memory-bank/change-log.md @@ -1485,3 +1485,31 @@ Addendum (same TASK22260 slice): - `actions/services/integrationDirectService.js` (POST via `requestJson`) - `actions/services/adminDirectService.js` (GET flows via `getJson`) - Updated `actions/clients/README.md` to include `endpointClient` in current extracted clients. + +--- + +### CL-040: TASK22260 next slice — reference-data direct service endpointClient adoption + +date: 2026-03-25 +author: Cline +scope: `actions/services/referenceDataDirectService.js`, `actions/clients/README.md` +type: change +rationale: Continue the incremental façade/client adoption stream by migrating another bounded direct-service module to shared endpoint request helpers. +impact: Reduces axios boilerplate and centralizes JSON extraction behavior for reference-data requests without changing public call signatures. +status: completed + +Summary: + +- Migrated `actions/services/referenceDataDirectService.js` from direct `axios.get(...).then(res => res.data)` patterns to shared `getJson(...)` helper from `actions/clients/endpointClient`. +- Preserved existing error behavior: + - `logAndReturnEmptyValueErrorResponse` for appeals/project/LPA fetches + - `consoleLogger` catch handling for form/mandatory/picklist/notice fetches +- Updated `actions/clients/README.md` usage notes to include reference-data service reuse. + +Validation: + +- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors) + +Follow-ups: + +- Next optional bounded slice: adopt `getJson`/`requestJson` for selected low-risk read paths in `searchDirectService` or `caseDirectService` while preserving per-function error semantics.