refactor(portal): normalize route composition with fileRouteBuilder
This commit is contained in:
@@ -2,104 +2,124 @@ import { BASE_URL } from "../core/env";
|
|||||||
import { consoleLogger } from "../core/logger";
|
import { consoleLogger } from "../core/logger";
|
||||||
import { buildHashedQueryUrl } from "../clients/relayClient";
|
import { buildHashedQueryUrl } from "../clients/relayClient";
|
||||||
import { getJson, requestJson } from "../clients/endpointClient";
|
import { getJson, requestJson } from "../clients/endpointClient";
|
||||||
|
import {
|
||||||
|
buildFileQuery,
|
||||||
|
withBaseUrl,
|
||||||
|
appendQuerySuffix
|
||||||
|
} from "../clients/fileRouteBuilder";
|
||||||
|
|
||||||
export const getMyCases = (loggedInUserId) => {
|
export const getMyCases = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getmycases_api", {
|
||||||
BASE_URL +
|
|
||||||
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyInvolvements = async (loggedInUserId) => {
|
export const getMyInvolvements = async (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getmyinvolvements_api", {
|
||||||
BASE_URL +
|
|
||||||
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
|
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyLPACases = (lpaid) => {
|
export const getMyLPACases = (lpaid) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getmylpacases_api", {
|
||||||
BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid
|
lpaid
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyRepresentations = (loggedInUserId) => {
|
export const getMyRepresentations = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getmyrepresentations_api", {
|
||||||
BASE_URL +
|
|
||||||
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery(
|
||||||
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
"/api/endpoint/getmyrepresentationsproxy_api",
|
||||||
|
{
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return getJson(route).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRepresentations = (incidentID) => {
|
export const getRepresentations = (incidentID) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getrepresentations_api", {
|
||||||
"/api/endpoint/getrepresentations_api?incidentID=" + incidentID
|
incidentID
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(route).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRepresentationsProxy = (incidentID) => {
|
export const getRepresentationsProxy = (incidentID) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getrepresentationsproxy_api", {
|
||||||
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
|
incidentID
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(route).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWatchedCases = (loggedInUserId) => {
|
export const getWatchedCases = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getwatchedcases_api", {
|
||||||
BASE_URL +
|
|
||||||
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWatchedCasesProxy = (loggedInUserId) => {
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getwatchedcasesproxy_api", {
|
||||||
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(route).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery(
|
||||||
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
"/api/endpoint/getawaitingsubmissionproxy_api",
|
||||||
|
{
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return getJson(route).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAwaitingSubmission = (loggedInUserId) => {
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
||||||
return getJson(
|
const route = buildFileQuery("/api/endpoint/getawaitingsubmission_api", {
|
||||||
BASE_URL +
|
|
||||||
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
|
||||||
loggedInUserId
|
loggedInUserId
|
||||||
).catch((error) => {
|
});
|
||||||
|
|
||||||
|
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -122,9 +142,9 @@ export const createWatchedCases = async (formValues) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteMyRepresentations = (myRepresentationsID) => {
|
export const deleteMyRepresentations = (myRepresentationsID) => {
|
||||||
var queryUrl =
|
var queryUrl = buildFileQuery("/api/endpoint/deletemyrepresentations_api", {
|
||||||
"/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" +
|
myRepresentationsID
|
||||||
myRepresentationsID;
|
});
|
||||||
|
|
||||||
return buildHashedQueryUrl(queryUrl)
|
return buildHashedQueryUrl(queryUrl)
|
||||||
.then((signedUrl) =>
|
.then((signedUrl) =>
|
||||||
@@ -147,8 +167,12 @@ export const deleteMyRepresentations = (myRepresentationsID) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteAwaitingSubmissions = (incidentID) => {
|
export const deleteAwaitingSubmissions = (incidentID) => {
|
||||||
var queryUrl =
|
var queryUrl = buildFileQuery(
|
||||||
"/api/endpoint/deleteawaitingsubmissions_api?incidentID=" + incidentID;
|
"/api/endpoint/deleteawaitingsubmissions_api",
|
||||||
|
{
|
||||||
|
incidentID
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
method: "delete",
|
method: "delete",
|
||||||
@@ -161,8 +185,9 @@ export const deleteAwaitingSubmissions = (incidentID) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const deleteWatchedCases = async (watchedCaseID) => {
|
export const deleteWatchedCases = async (watchedCaseID) => {
|
||||||
var queryUrl =
|
var queryUrl = buildFileQuery("/api/endpoint/deletewatchedcases_api", {
|
||||||
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
|
watchedCaseID
|
||||||
|
});
|
||||||
|
|
||||||
return buildHashedQueryUrl(queryUrl)
|
return buildHashedQueryUrl(queryUrl)
|
||||||
.then((signedUrl) =>
|
.then((signedUrl) =>
|
||||||
@@ -181,23 +206,26 @@ export const sendCaseCompleteMessage = async (
|
|||||||
caseReference,
|
caseReference,
|
||||||
inv
|
inv
|
||||||
) => {
|
) => {
|
||||||
var hashQueryPath =
|
var hashQueryPath = buildFileQuery(
|
||||||
"/api/file/createappealcompletemessage_api?container=" +
|
"/api/file/createappealcompletemessage_api",
|
||||||
containerID +
|
{
|
||||||
"&tempcaseref=" +
|
container: containerID,
|
||||||
caseReference;
|
tempcaseref: caseReference
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl = buildFileQuery("/api/file/createappealcompletemessage_api", {
|
||||||
"/api/file/createappealcompletemessage_api?container=" +
|
container: containerID,
|
||||||
containerID +
|
tempcaseref: caseReference,
|
||||||
"&tempcaseref=" +
|
inv
|
||||||
caseReference +
|
});
|
||||||
"&inv=" +
|
|
||||||
inv;
|
|
||||||
|
|
||||||
var signedQueryUrl = await buildHashedQueryUrl(hashQueryPath);
|
var signedQueryUrl = await buildHashedQueryUrl(hashQueryPath);
|
||||||
|
|
||||||
queryUrl = queryUrl + signedQueryUrl.replace(hashQueryPath, "");
|
queryUrl = appendQuerySuffix(
|
||||||
|
queryUrl,
|
||||||
|
signedQueryUrl.replace(hashQueryPath, "")
|
||||||
|
);
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
method: "get",
|
method: "get",
|
||||||
@@ -213,11 +241,13 @@ export const sendCaseCompleteMessageProxy = async (
|
|||||||
containerID,
|
containerID,
|
||||||
caseReference
|
caseReference
|
||||||
) => {
|
) => {
|
||||||
var queryUrl =
|
var queryUrl = buildFileQuery(
|
||||||
"/api/file/createappealcompletemessageproxy_api?container=" +
|
"/api/file/createappealcompletemessageproxy_api",
|
||||||
containerID +
|
{
|
||||||
"&tempcaseref=" +
|
container: containerID,
|
||||||
caseReference;
|
tempcaseref: caseReference
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
method: "get",
|
method: "get",
|
||||||
@@ -234,13 +264,14 @@ export const sendRepCompleteMessage = async (
|
|||||||
caseReference,
|
caseReference,
|
||||||
fileName
|
fileName
|
||||||
) => {
|
) => {
|
||||||
var hashQueryPath =
|
var hashQueryPath = buildFileQuery(
|
||||||
"/api/file/createrepcompletemessage_api?container=" +
|
"/api/file/createrepcompletemessage_api",
|
||||||
containerID +
|
{
|
||||||
"&tempcaseref=" +
|
container: containerID,
|
||||||
caseReference +
|
tempcaseref: caseReference,
|
||||||
"&repid=" +
|
repid: fileName
|
||||||
fileName;
|
}
|
||||||
|
);
|
||||||
|
|
||||||
var queryUrl = await buildHashedQueryUrl(hashQueryPath);
|
var queryUrl = await buildHashedQueryUrl(hashQueryPath);
|
||||||
|
|
||||||
|
|||||||
@@ -2517,3 +2517,45 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Optional next widened slice: evaluate applying `fileRouteBuilder` to portal/case service file-route call sites for cross-module query-builder consistency.
|
- Optional next widened slice: evaluate applying `fileRouteBuilder` to portal/case service file-route call sites for cross-module query-builder consistency.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CL-071: TASK22260 next widened cross-module slice — portal service query normalization via fileRouteBuilder
|
||||||
|
|
||||||
|
date: 2026-03-25
|
||||||
|
author: Cline
|
||||||
|
scope: `actions/services/portalDirectService.js`
|
||||||
|
type: change
|
||||||
|
rationale: Deliver the requested next wider slice by extending `fileRouteBuilder` adoption beyond document service into portal service, reducing duplicated query string concatenation and improving consistency in signed/unsigned route construction.
|
||||||
|
impact: Improves maintainability and query-construction consistency across high-use portal service flows while preserving existing runtime behavior and hash-signing contracts.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Refactored `actions/services/portalDirectService.js` to use shared route helpers:
|
||||||
|
- `buildFileQuery`
|
||||||
|
- `withBaseUrl`
|
||||||
|
- `appendQuerySuffix`
|
||||||
|
- Normalized query composition across portal service GET/DELETE/message flows:
|
||||||
|
- read/list endpoints (`getMyCases`, `getMyInvolvements`, `getMyLPACases`, `getMyRepresentations`, proxy and watched/awaiting variants)
|
||||||
|
- delete endpoints (`deleteMyRepresentations`, `deleteAwaitingSubmissions`, `deleteWatchedCases`)
|
||||||
|
- file-message endpoints (`sendCaseCompleteMessage`, `sendCaseCompleteMessageProxy`, `sendRepCompleteMessage`)
|
||||||
|
- Preserved behavior contracts:
|
||||||
|
- retained BASE_URL usage patterns for existing BASE_URL-prefixed routes
|
||||||
|
- retained hash-signing flow via `buildHashedQueryUrl`
|
||||||
|
- retained append semantics for signed suffixes in `sendCaseCompleteMessage`
|
||||||
|
- retained request methods, headers, payloads, and catch-path logging
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
|
||||||
|
- `node tests/phase7/service-behaviour.test.cjs` -> pass (13/13)
|
||||||
|
- `node tests/phase22/index.test.cjs` -> pass
|
||||||
|
- core-token: 2/2
|
||||||
|
- client-utils: 6/6
|
||||||
|
- file-client: 4/4
|
||||||
|
- phase22 combined: pass
|
||||||
|
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
|
||||||
|
|
||||||
|
Follow-ups:
|
||||||
|
|
||||||
|
- Optional next widened slice: apply the same query-normalization helpers in `caseDirectService` and add dedicated phase22 behavioral assertions for `portalDirectService` route-building/signing composition.
|
||||||
|
|||||||
Reference in New Issue
Block a user