refactor(api): migrate batch 8 endpoints to relayGet
This commit is contained in:
@@ -939,3 +939,38 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Continue with next bounded P2-S2 batch from remaining legacy GET endpoints (e.g., advanced/basic paged search-detail clusters and related non-migrated proxies).
|
- Continue with next bounded P2-S2 batch from remaining legacy GET endpoints (e.g., advanced/basic paged search-detail clusters and related non-migrated proxies).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CL-025: TASK22229 P2-S2 Batch 8 (basic search details + DNS details relay GET cluster)
|
||||||
|
|
||||||
|
date: 2026-03-24
|
||||||
|
author: Cline
|
||||||
|
scope: `pages/api/endpoint/{getbasicsearchpaged_api,getbasicsearchdetails_api,getbasicsearchdetailspaged_api,getbasicdnssearchdetails_api,getbasicdnssearchdetailspaged_api}.js`, `tests/phase21/endpoint-handler-contract.test.cjs`
|
||||||
|
type: change
|
||||||
|
rationale: Continue the P2-S2 relay migration using bounded commits by moving the remaining basic-search-details and DNS-details GET handlers to shared `relayGet`, preserving existing guards and response contracts.
|
||||||
|
impact: Reduced duplicated relay plumbing and more consistent forwarding behavior across search-detail handlers; no intended API contract changes.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Migrated Batch 8 endpoints to shared `relayGet`:
|
||||||
|
- `getbasicsearchpaged_api.js`
|
||||||
|
- `getbasicsearchdetails_api.js`
|
||||||
|
- `getbasicsearchdetailspaged_api.js`
|
||||||
|
- `getbasicdnssearchdetails_api.js`
|
||||||
|
- `getbasicdnssearchdetailspaged_api.js`
|
||||||
|
- Preserved existing validation guards and error contracts.
|
||||||
|
- Preserved existing endpoint-specific transforms:
|
||||||
|
- `@odata.nextLink` normalization in paged responses
|
||||||
|
- flattened ticketnumber enrichment for search detail handlers
|
||||||
|
- Updated phase21 endpoint contract tests to inject `relayGet` mocks for migrated handlers in validation and catch-path tests.
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
|
||||||
|
- `node tests/phase21/endpoint-handler-contract.test.cjs` -> pass (152/152)
|
||||||
|
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
|
||||||
|
|
||||||
|
Follow-ups:
|
||||||
|
|
||||||
|
- Continue P2-S2 with next bounded batch from remaining legacy GET endpoints (currently: `createwatchedcases_api`, `deletewatchedcasesproxy_api`, `getadvancedsearch_api`, `getadvancedsearchpaged_api`, `getappealid_api`, `getbasicdnssearchpaged_api`, `getbasicpartsaveddetails_api`, `getbasicsearch_by_address_api`, `getbasicsearch_by_lparref_api`, `getdnscoords_api`, `getdnslist_api`, `getmylpacases_api`, `getportallogin_api`).
|
||||||
|
|||||||
@@ -10,18 +10,10 @@
|
|||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import _ from "lodash";
|
|
||||||
import { azureHeaders } from "../../../actions/core/headers";
|
import { azureHeaders } from "../../../actions/core/headers";
|
||||||
import { consoleLogger } from "../../../actions/core/logger";
|
|
||||||
import { getToken } from "../../../actions/core/token";
|
|
||||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||||
import { hashAPIPath } from "../../../actions/core/hash";
|
import { respondError } from "../middleware/apiResponse";
|
||||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
import { relayGet } from "../middleware/relayForwarding";
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
const caseReference = req.query.caseReference;
|
const caseReference = req.query.caseReference;
|
||||||
@@ -37,28 +29,21 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
let queryUrl =
|
||||||
const token = await getToken();
|
"pinswg_dnses?$filter=pinswg_name eq '" +
|
||||||
|
caseReference +
|
||||||
|
"&$count=true";
|
||||||
|
|
||||||
let queryUrl =
|
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
|
||||||
"pinswg_dnses?$filter=pinswg_name eq '" +
|
|
||||||
caseReference +
|
|
||||||
"&$count=true";
|
|
||||||
|
|
||||||
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
|
return relayGet({
|
||||||
|
queryUrl,
|
||||||
const { data } = await axios.get(
|
res,
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||||
azureHeaders(token.access_token)
|
errorResponse: {
|
||||||
);
|
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "BASIC_DNS_SEARCH_DETAILS_FETCH_FAILED",
|
code: "BASIC_DNS_SEARCH_DETAILS_FETCH_FAILED",
|
||||||
message: "Failed to fetch basic DNS search details"
|
message: "Failed to fetch basic DNS search details"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,18 +9,11 @@
|
|||||||
* 200:
|
* 200:
|
||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
import axios from "axios";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { azureHeadersPaged } from "../../../actions/core/headers";
|
import { azureHeadersPaged } from "../../../actions/core/headers";
|
||||||
import { consoleLogger } from "../../../actions/core/logger";
|
|
||||||
import { getToken } from "../../../actions/core/token";
|
|
||||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||||
import { hashAPIPath } from "../../../actions/core/hash";
|
import { respondError } from "../middleware/apiResponse";
|
||||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
import { relayGet } from "../middleware/relayForwarding";
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
const caseReference = req.query.caseReference;
|
const caseReference = req.query.caseReference;
|
||||||
@@ -36,33 +29,29 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
let queryUrl =
|
||||||
const token = await getToken();
|
"pinswg_dnses?$filter=pinswg_name eq '" +
|
||||||
|
caseReference +
|
||||||
|
"&$count=true";
|
||||||
|
|
||||||
let queryUrl =
|
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
|
||||||
"pinswg_dnses?$filter=pinswg_name eq '" +
|
|
||||||
caseReference +
|
|
||||||
"&$count=true";
|
|
||||||
|
|
||||||
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
|
return relayGet({
|
||||||
|
queryUrl,
|
||||||
|
res,
|
||||||
|
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
|
||||||
|
transformData: (data) => {
|
||||||
|
if (_.has(data, "@odata.nextLink") === true) {
|
||||||
|
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||||
|
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||||
|
}
|
||||||
|
|
||||||
const { data } = await axios.get(
|
return data;
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
},
|
||||||
azureHeadersPaged(token.access_token)
|
errorResponse: {
|
||||||
);
|
|
||||||
|
|
||||||
if (_.has(data, "@odata.nextLink") === true) {
|
|
||||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
|
||||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "BASIC_DNS_SEARCH_DETAILS_PAGED_FETCH_FAILED",
|
code: "BASIC_DNS_SEARCH_DETAILS_PAGED_FETCH_FAILED",
|
||||||
message: "Failed to fetch paged basic DNS search details"
|
message: "Failed to fetch paged basic DNS search details"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,18 +29,11 @@
|
|||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import { azureHeaders } from "../../../actions/core/headers";
|
import { azureHeaders } from "../../../actions/core/headers";
|
||||||
import { consoleLogger } from "../../../actions/core/logger";
|
|
||||||
import { getToken } from "../../../actions/core/token";
|
|
||||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||||
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
||||||
import { hashAPIPath } from "../../../actions/core/hash";
|
import { respondError } from "../middleware/apiResponse";
|
||||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
import { relayGet } from "../middleware/relayForwarding";
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
const appealTypeName = req.query.appealTypeName;
|
const appealTypeName = req.query.appealTypeName;
|
||||||
@@ -77,67 +70,63 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const navigationProperty =
|
||||||
const token = await getToken();
|
getNavigationPropertyByPrimaryAttribute(
|
||||||
|
primaryIdAttribute
|
||||||
|
).NavigationProperty;
|
||||||
|
|
||||||
const navigationProperty =
|
let queryUrl =
|
||||||
getNavigationPropertyByPrimaryAttribute(
|
appealTypeName +
|
||||||
primaryIdAttribute
|
"?$filter=_" +
|
||||||
).NavigationProperty;
|
(primaryIdAttribute == "pinswg_sipscase"
|
||||||
|
? "pinswg_sipscase_value"
|
||||||
|
: primaryIdAttribute + "s_value ") +
|
||||||
|
" eq " +
|
||||||
|
incidentID +
|
||||||
|
"&$count=true" +
|
||||||
|
"&$expand=" +
|
||||||
|
navigationProperty +
|
||||||
|
"($select=ticketnumber)";
|
||||||
|
|
||||||
let queryUrl =
|
//" and statuscode eq 1&$count=true";
|
||||||
appealTypeName +
|
|
||||||
"?$filter=_" +
|
|
||||||
(primaryIdAttribute == "pinswg_sipscase"
|
|
||||||
? "pinswg_sipscase_value"
|
|
||||||
: primaryIdAttribute + "s_value ") +
|
|
||||||
" eq " +
|
|
||||||
incidentID +
|
|
||||||
"&$count=true" +
|
|
||||||
"&$expand=" +
|
|
||||||
navigationProperty +
|
|
||||||
"($select=ticketnumber)";
|
|
||||||
|
|
||||||
//" and statuscode eq 1&$count=true";
|
// queryUrl =
|
||||||
|
// queryUrl +
|
||||||
|
// getSelectQuery(appealTypeName) +
|
||||||
|
// ",_" +
|
||||||
|
// (primaryIdAttribute == "pinswg_sipscase"
|
||||||
|
// ? "pinswg_sipscase_value"
|
||||||
|
// : primaryIdAttribute + "s_value");
|
||||||
|
|
||||||
// queryUrl =
|
queryUrl = queryUrl + getSelectQuery(appealTypeName);
|
||||||
// queryUrl +
|
|
||||||
// getSelectQuery(appealTypeName) +
|
|
||||||
// ",_" +
|
|
||||||
// (primaryIdAttribute == "pinswg_sipscase"
|
|
||||||
// ? "pinswg_sipscase_value"
|
|
||||||
// : primaryIdAttribute + "s_value");
|
|
||||||
|
|
||||||
queryUrl = queryUrl + getSelectQuery(appealTypeName);
|
// console.log(
|
||||||
|
// "\n==========================================\n",
|
||||||
|
// "\nSearch Details query ",
|
||||||
|
// "\nAppealType: " + appealTypeName,
|
||||||
|
// "\nIncident ID: " + incidentID,
|
||||||
|
// "\n\nQuery url: " + queryUrl,
|
||||||
|
// "\n==========================================\n"
|
||||||
|
// );
|
||||||
|
|
||||||
// console.log(
|
return relayGet({
|
||||||
// "\n==========================================\n",
|
queryUrl,
|
||||||
// "\nSearch Details query ",
|
res,
|
||||||
// "\nAppealType: " + appealTypeName,
|
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||||
// "\nIncident ID: " + incidentID,
|
transformData: (data) => {
|
||||||
// "\n\nQuery url: " + queryUrl,
|
let flattened = data.value.map((r) => ({
|
||||||
// "\n==========================================\n"
|
...r,
|
||||||
// );
|
ticketnumber: r[navigationProperty]?.ticketnumber || null
|
||||||
|
}));
|
||||||
|
|
||||||
const { data } = await axios.get(
|
data.value = flattened;
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
|
||||||
azureHeaders(token.access_token)
|
|
||||||
);
|
|
||||||
|
|
||||||
let flattened = data.value.map((r) => ({
|
return data;
|
||||||
...r,
|
},
|
||||||
ticketnumber: r[navigationProperty]?.ticketnumber || null
|
errorResponse: {
|
||||||
}));
|
|
||||||
|
|
||||||
data.value = flattened;
|
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "BASIC_SEARCH_DETAILS_FETCH_FAILED",
|
code: "BASIC_SEARCH_DETAILS_FETCH_FAILED",
|
||||||
message: "Failed to fetch basic search details"
|
message: "Failed to fetch basic search details"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,19 +29,12 @@
|
|||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { azureHeadersPaged } from "../../../actions/core/headers";
|
import { azureHeadersPaged } from "../../../actions/core/headers";
|
||||||
import { consoleLogger } from "../../../actions/core/logger";
|
|
||||||
import { getToken } from "../../../actions/core/token";
|
|
||||||
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
import { getSelectQuery } from "../../../actions/selectQueryTypes";
|
||||||
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
import { getNavigationPropertyByPrimaryAttribute } from "../../../components/utils";
|
||||||
import { hashAPIPath } from "../../../actions/core/hash";
|
import { respondError } from "../middleware/apiResponse";
|
||||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
import { relayGet } from "../middleware/relayForwarding";
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
const appealTypeName = req.query.appealTypeName;
|
const appealTypeName = req.query.appealTypeName;
|
||||||
@@ -78,64 +71,60 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const navigationProperty =
|
||||||
const token = await getToken();
|
getNavigationPropertyByPrimaryAttribute(
|
||||||
|
primaryIdAttribute
|
||||||
|
).NavigationProperty;
|
||||||
|
|
||||||
const navigationProperty =
|
// "?$filter=_" +
|
||||||
getNavigationPropertyByPrimaryAttribute(
|
// (primaryIdAttribute == "pinswg_sipscase"
|
||||||
primaryIdAttribute
|
// ? "pinswg_sipscase_value"
|
||||||
).NavigationProperty;
|
// : primaryIdAttribute + "s_value ") +
|
||||||
|
// " eq " +
|
||||||
|
// incidentID +
|
||||||
|
|
||||||
// "?$filter=_" +
|
let queryUrl =
|
||||||
// (primaryIdAttribute == "pinswg_sipscase"
|
appealTypeName +
|
||||||
// ? "pinswg_sipscase_value"
|
"?$filter=" +
|
||||||
// : primaryIdAttribute + "s_value ") +
|
incidentID +
|
||||||
// " eq " +
|
"&$count=true" +
|
||||||
// incidentID +
|
"&$expand=" +
|
||||||
|
navigationProperty +
|
||||||
|
"($select=ticketnumber)";
|
||||||
|
|
||||||
let queryUrl =
|
//" and statuscode eq 1&$count=true";
|
||||||
appealTypeName +
|
|
||||||
"?$filter=" +
|
|
||||||
incidentID +
|
|
||||||
"&$count=true" +
|
|
||||||
"&$expand=" +
|
|
||||||
navigationProperty +
|
|
||||||
"($select=ticketnumber)";
|
|
||||||
|
|
||||||
//" and statuscode eq 1&$count=true";
|
queryUrl =
|
||||||
|
queryUrl +
|
||||||
|
getSelectQuery(appealTypeName) +
|
||||||
|
",_" +
|
||||||
|
(primaryIdAttribute == "pinswg_sipscase"
|
||||||
|
? "pinswg_sipscase_value"
|
||||||
|
: primaryIdAttribute + "s_value");
|
||||||
|
|
||||||
queryUrl =
|
return relayGet({
|
||||||
queryUrl +
|
queryUrl,
|
||||||
getSelectQuery(appealTypeName) +
|
res,
|
||||||
",_" +
|
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
|
||||||
(primaryIdAttribute == "pinswg_sipscase"
|
transformData: (data) => {
|
||||||
? "pinswg_sipscase_value"
|
let flattened = data.value.map((r) => ({
|
||||||
: primaryIdAttribute + "s_value");
|
...r,
|
||||||
|
ticketnumber: r[navigationProperty]?.ticketnumber || null
|
||||||
|
}));
|
||||||
|
|
||||||
const { data } = await axios.get(
|
data.value = flattened;
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
|
||||||
azureHeadersPaged(token.access_token)
|
|
||||||
);
|
|
||||||
|
|
||||||
let flattened = data.value.map((r) => ({
|
if (_.has(data, "@odata.nextLink") === true) {
|
||||||
...r,
|
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||||
ticketnumber: r[navigationProperty]?.ticketnumber || null
|
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||||
}));
|
}
|
||||||
|
|
||||||
data.value = flattened;
|
return data;
|
||||||
|
},
|
||||||
if (_.has(data, "@odata.nextLink") === true) {
|
errorResponse: {
|
||||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
|
||||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "BASIC_SEARCH_DETAILS_PAGED_FETCH_FAILED",
|
code: "BASIC_SEARCH_DETAILS_PAGED_FETCH_FAILED",
|
||||||
message: "Failed to fetch paged basic search details"
|
message: "Failed to fetch paged basic search details"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,17 +42,10 @@
|
|||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
|
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
|
||||||
import { consoleLogger } from "../../../actions/core/logger";
|
import { respondError } from "../middleware/apiResponse";
|
||||||
import { getToken } from "../../../actions/core/token";
|
import { relayGet } from "../middleware/relayForwarding";
|
||||||
import { hashAPIPath } from "../../../actions/core/hash";
|
|
||||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
let searchString = req.query.searchString;
|
let searchString = req.query.searchString;
|
||||||
@@ -96,48 +89,45 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
searchString = searchString.replace(/\'/g, "''");
|
||||||
const token = await getToken();
|
|
||||||
|
|
||||||
searchString = searchString.replace(/\'/g, "''");
|
const queryUrl =
|
||||||
|
"incidents?$select=pinswg_environmentalstatementlocation,pinswg_caseaddress,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference,pinswg_appellantagent,pinswg_appellantfirstname,pinswg_appellantlastname&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
|
||||||
|
searchString +
|
||||||
|
"') or contains(ticketnumber, '" +
|
||||||
|
searchString +
|
||||||
|
"') or contains(pinswg_lpareference, '" +
|
||||||
|
searchString +
|
||||||
|
"')) and pinswg_appealcasetype ne null " +
|
||||||
|
(process.env.SHOWSIPS !== "true"
|
||||||
|
? "and pinswg_appealcasetype ne 846040002 "
|
||||||
|
: "") +
|
||||||
|
"and pinswg_publishtoweb eq true&$orderby=" +
|
||||||
|
orderby +
|
||||||
|
" " +
|
||||||
|
fieldSort +
|
||||||
|
"&$count=true" +
|
||||||
|
(typeof pageNumber != "undefined"
|
||||||
|
? "&$skiptoken=" + '<cookie pagenumber="' + pageNumber + '" />'
|
||||||
|
: "");
|
||||||
|
|
||||||
const queryUrl =
|
return relayGet({
|
||||||
"incidents?$select=pinswg_environmentalstatementlocation,pinswg_caseaddress,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference,pinswg_appellantagent,pinswg_appellantfirstname,pinswg_appellantlastname&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
|
queryUrl,
|
||||||
searchString +
|
res,
|
||||||
"') or contains(ticketnumber, '" +
|
requestOptionsBuilder: (accessToken) =>
|
||||||
searchString +
|
azureHeadersPagedCustom(accessToken, showNumberOfRecords),
|
||||||
"') or contains(pinswg_lpareference, '" +
|
transformData: (data) => {
|
||||||
searchString +
|
if (_.has(data, "@odata.nextLink") === true) {
|
||||||
"')) and pinswg_appealcasetype ne null " +
|
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||||
(process.env.SHOWSIPS !== "true"
|
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||||
? "and pinswg_appealcasetype ne 846040002 "
|
}
|
||||||
: "") +
|
|
||||||
"and pinswg_publishtoweb eq true&$orderby=" +
|
|
||||||
orderby +
|
|
||||||
" " +
|
|
||||||
fieldSort +
|
|
||||||
"&$count=true" +
|
|
||||||
(typeof pageNumber != "undefined"
|
|
||||||
? "&$skiptoken=" + '<cookie pagenumber="' + pageNumber + '" />'
|
|
||||||
: "");
|
|
||||||
|
|
||||||
const { data } = await axios.get(
|
return data;
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
},
|
||||||
azureHeadersPagedCustom(token.access_token, showNumberOfRecords)
|
errorResponse: {
|
||||||
);
|
|
||||||
|
|
||||||
if (_.has(data, "@odata.nextLink") === true) {
|
|
||||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
|
||||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "BASIC_SEARCH_PAGED_FETCH_FAILED",
|
code: "BASIC_SEARCH_PAGED_FETCH_FAILED",
|
||||||
message: "Failed to fetch paged basic search results"
|
message: "Failed to fetch paged basic search results"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1794,6 +1794,7 @@ test("getbasicsearchdetails returns APPEAL_TYPE_NAME_REQUIRED when appealTypeNam
|
|||||||
const mod = loadModule("pages/api/endpoint/getbasicsearchdetails_api.js", {
|
const mod = loadModule("pages/api/endpoint/getbasicsearchdetails_api.js", {
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async () => ({}),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=title",
|
getSelectQuery: () => "&$select=title",
|
||||||
getNavigationPropertyByPrimaryAttribute: () => ({
|
getNavigationPropertyByPrimaryAttribute: () => ({
|
||||||
@@ -1825,6 +1826,8 @@ test("getbasicsearchdetails catch path returns BASIC_SEARCH_DETAILS_FETCH_FAILED
|
|||||||
const mod = loadModule("pages/api/endpoint/getbasicsearchdetails_api.js", {
|
const mod = loadModule("pages/api/endpoint/getbasicsearchdetails_api.js", {
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async ({ res, errorResponse }) =>
|
||||||
|
respondErrorMock(res, errorResponse),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=title",
|
getSelectQuery: () => "&$select=title",
|
||||||
getNavigationPropertyByPrimaryAttribute: () => ({
|
getNavigationPropertyByPrimaryAttribute: () => ({
|
||||||
@@ -1863,6 +1866,7 @@ test("getbasicsearchdetailspaged returns APPEAL_TYPE_NAME_REQUIRED when appealTy
|
|||||||
{
|
{
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async () => ({}),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=title",
|
getSelectQuery: () => "&$select=title",
|
||||||
getNavigationPropertyByPrimaryAttribute: () => ({
|
getNavigationPropertyByPrimaryAttribute: () => ({
|
||||||
@@ -1898,6 +1902,8 @@ test("getbasicsearchdetailspaged catch path returns BASIC_SEARCH_DETAILS_PAGED_F
|
|||||||
{
|
{
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async ({ res, errorResponse }) =>
|
||||||
|
respondErrorMock(res, errorResponse),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=title",
|
getSelectQuery: () => "&$select=title",
|
||||||
getNavigationPropertyByPrimaryAttribute: () => ({
|
getNavigationPropertyByPrimaryAttribute: () => ({
|
||||||
@@ -1936,6 +1942,7 @@ test("getbasicsearchpaged returns ORDER_BY_REQUIRED when orderby missing", async
|
|||||||
const mod = loadModule("pages/api/endpoint/getbasicsearchpaged_api.js", {
|
const mod = loadModule("pages/api/endpoint/getbasicsearchpaged_api.js", {
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async () => ({}),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
azureHeadersPagedCustom: () => ({}),
|
azureHeadersPagedCustom: () => ({}),
|
||||||
@@ -1962,6 +1969,8 @@ test("getbasicsearchpaged catch path returns BASIC_SEARCH_PAGED_FETCH_FAILED", a
|
|||||||
const mod = loadModule("pages/api/endpoint/getbasicsearchpaged_api.js", {
|
const mod = loadModule("pages/api/endpoint/getbasicsearchpaged_api.js", {
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async ({ res, errorResponse }) =>
|
||||||
|
respondErrorMock(res, errorResponse),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
azureHeadersPagedCustom: () => ({}),
|
azureHeadersPagedCustom: () => ({}),
|
||||||
@@ -2187,6 +2196,7 @@ test("getbasicdnssearchdetails returns CASE_REFERENCE_REQUIRED when caseReferenc
|
|||||||
{
|
{
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async () => ({}),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=pinswg_name",
|
getSelectQuery: () => "&$select=pinswg_name",
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
@@ -2213,6 +2223,8 @@ test("getbasicdnssearchdetails catch path returns BASIC_DNS_SEARCH_DETAILS_FETCH
|
|||||||
{
|
{
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async ({ res, errorResponse }) =>
|
||||||
|
respondErrorMock(res, errorResponse),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=pinswg_name",
|
getSelectQuery: () => "&$select=pinswg_name",
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
@@ -2243,6 +2255,7 @@ test("getbasicdnssearchdetailspaged returns CASE_REFERENCE_REQUIRED when caseRef
|
|||||||
{
|
{
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async () => ({}),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=pinswg_name",
|
getSelectQuery: () => "&$select=pinswg_name",
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
@@ -2270,6 +2283,8 @@ test("getbasicdnssearchdetailspaged catch path returns BASIC_DNS_SEARCH_DETAILS_
|
|||||||
{
|
{
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async ({ res, errorResponse }) =>
|
||||||
|
respondErrorMock(res, errorResponse),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
getSelectQuery: () => "&$select=pinswg_name",
|
getSelectQuery: () => "&$select=pinswg_name",
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
|
|||||||
Reference in New Issue
Block a user