refactor(api): migrate batch 7 endpoints to relayGet
This commit is contained in:
@@ -902,3 +902,40 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Optional next bounded batch: migrate remaining legacy relay GET handlers in advanced/basic search-document/detail clusters that still use direct axios relay patterns.
|
- Optional next bounded batch: migrate remaining legacy relay GET handlers in advanced/basic search-document/detail clusters that still use direct axios relay patterns.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CL-024: TASK22229 P2-S2 Batch 7 (search-document + portal-proxy relay GET cluster)
|
||||||
|
|
||||||
|
date: 2026-03-24
|
||||||
|
author: Cline
|
||||||
|
scope: `pages/api/endpoint/{getportalmoduledetailsproxy_api,getsearchdocumentTypes_api,getsearchdocumentdetails_api,getsearchdocumentdetailspaged_api,getappealpdfdocuments_api}.js`, `tests/phase21/endpoint-handler-contract.test.cjs`
|
||||||
|
type: change
|
||||||
|
rationale: Continue P2-S2 in bounded commits by migrating a coherent search-document/portal-proxy GET cluster onto shared relay forwarding while preserving existing validation, transforms, and error contracts.
|
||||||
|
impact: Reduced duplicate relay plumbing and improved consistency in search-document handlers; no intended API contract changes.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Migrated Batch 7 endpoints to shared `relayGet`:
|
||||||
|
- `getportalmoduledetailsproxy_api.js`
|
||||||
|
- `getsearchdocumentTypes_api.js`
|
||||||
|
- `getsearchdocumentdetails_api.js`
|
||||||
|
- `getsearchdocumentdetailspaged_api.js`
|
||||||
|
- `getappealpdfdocuments_api.js`
|
||||||
|
- Preserved existing guard behavior and error response contracts.
|
||||||
|
- Preserved endpoint-specific transform behavior via `transformData`, including:
|
||||||
|
- grouped search-document type payloads
|
||||||
|
- document hashlink enrichment and published-date normalization
|
||||||
|
- `@odata.nextLink` normalization where present
|
||||||
|
- appeal PDF document name projection
|
||||||
|
- Updated phase21 endpoint tests to mock `relayGet` for migrated handlers in validation/catch/success paths as applicable.
|
||||||
|
|
||||||
|
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 with next bounded P2-S2 batch from remaining legacy GET endpoints (e.g., advanced/basic paged search-detail clusters and related non-migrated proxies).
|
||||||
|
|||||||
@@ -16,16 +16,9 @@
|
|||||||
* 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 { 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/";
|
|
||||||
|
|
||||||
const groupArray = (arr) => {
|
const groupArray = (arr) => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
@@ -67,41 +60,26 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const queryUrl =
|
||||||
const token = await getToken();
|
"pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
|
||||||
|
incidentID +
|
||||||
|
" and not(contains(pinswg_name,'_Appeal_Form.pdf'))&$select=pinswg_name,pinswg_isharedocumentlocations";
|
||||||
|
|
||||||
const queryUrl =
|
return relayGet({
|
||||||
"pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
|
queryUrl,
|
||||||
incidentID +
|
res,
|
||||||
" and not(contains(pinswg_name,'_Appeal_Form.pdf'))&$select=pinswg_name,pinswg_isharedocumentlocations";
|
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||||
|
transformData: (data) => {
|
||||||
|
data.value.forEach((item) => {
|
||||||
|
item.name = item.pinswg_name;
|
||||||
|
});
|
||||||
|
|
||||||
const { data } = await axios.get(
|
return data;
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
},
|
||||||
azureHeaders(token.access_token)
|
errorResponse: {
|
||||||
);
|
|
||||||
// //delete data["pinswg_documentid"];
|
|
||||||
// data.value.forEach(function (element) {
|
|
||||||
// delete element["pinswg_documentid"];
|
|
||||||
// });
|
|
||||||
|
|
||||||
// var dataArr = groupArray(data.value);
|
|
||||||
|
|
||||||
// // var dataStr;
|
|
||||||
// // _.has(data, "@odata.nextLink") == true &&
|
|
||||||
// // ((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
|
||||||
// // (data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
|
|
||||||
|
|
||||||
data.value.forEach((item) => {
|
|
||||||
item.name = item.pinswg_name;
|
|
||||||
});
|
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "APPEAL_PDF_DOCUMENTS_FETCH_FAILED",
|
code: "APPEAL_PDF_DOCUMENTS_FETCH_FAILED",
|
||||||
message: "Failed to fetch appeal PDF documents"
|
message: "Failed to fetch appeal PDF documents"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,17 +23,9 @@
|
|||||||
* description: hello world
|
* description: hello world
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
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 appealType = req.query.appealType;
|
const appealType = req.query.appealType;
|
||||||
@@ -58,30 +50,23 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const escapedCaseReference = caseReference.split("'").join("''");
|
||||||
const token = await getToken();
|
|
||||||
const escapedCaseReference = caseReference.split("'").join("''");
|
|
||||||
|
|
||||||
let queryUrl =
|
let queryUrl =
|
||||||
appealType +
|
appealType +
|
||||||
"?$filter=pinswg_name eq '" +
|
"?$filter=pinswg_name eq '" +
|
||||||
escapedCaseReference +
|
escapedCaseReference +
|
||||||
"'&$count=true";
|
"'&$count=true";
|
||||||
|
|
||||||
queryUrl = queryUrl + getSelectQuery(appealType);
|
queryUrl = queryUrl + getSelectQuery(appealType);
|
||||||
|
|
||||||
const { data } = await axios.get(
|
return relayGet({
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
queryUrl,
|
||||||
azureHeaders(token.access_token)
|
res,
|
||||||
);
|
errorResponse: {
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "PORTAL_MODULE_DETAILS_PROXY_FETCH_FAILED",
|
code: "PORTAL_MODULE_DETAILS_PROXY_FETCH_FAILED",
|
||||||
message: "Failed to fetch portal module details proxy"
|
message: "Failed to fetch portal module details proxy"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,9 @@
|
|||||||
* 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 { 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/";
|
|
||||||
|
|
||||||
const groupArray = (arr) => {
|
const groupArray = (arr) => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
@@ -67,31 +60,26 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const queryUrl =
|
||||||
const token = await getToken();
|
"pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
||||||
|
incidentID +
|
||||||
|
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations";
|
||||||
|
|
||||||
const queryUrl =
|
return relayGet({
|
||||||
"pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
queryUrl,
|
||||||
incidentID +
|
res,
|
||||||
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations";
|
requestOptionsBuilder: (accessToken) => azureHeaders(accessToken),
|
||||||
|
transformData: (data) => {
|
||||||
|
data.value.forEach(function (element) {
|
||||||
|
delete element["pinswg_documentid"];
|
||||||
|
});
|
||||||
|
|
||||||
const { data } = await axios.get(
|
return groupArray(data.value);
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
},
|
||||||
azureHeaders(token.access_token)
|
errorResponse: {
|
||||||
);
|
|
||||||
|
|
||||||
data.value.forEach(function (element) {
|
|
||||||
delete element["pinswg_documentid"];
|
|
||||||
});
|
|
||||||
|
|
||||||
const dataArr = groupArray(data.value);
|
|
||||||
return respondSuccess(res, dataArr);
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "SEARCH_DOCUMENT_TYPES_FETCH_FAILED",
|
code: "SEARCH_DOCUMENT_TYPES_FETCH_FAILED",
|
||||||
message: "Failed to fetch search document types"
|
message: "Failed to fetch search document types"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,21 +16,14 @@
|
|||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
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 { 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 WORDKEY = process.env.HASHKEY;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
const encryptDocReference = (documentRef) => {
|
const encryptDocReference = (documentRef) => {
|
||||||
var hashlink = CryptoJS.HmacSHA256(
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
"documents/download/" + documentRef,
|
"documents/download/" + documentRef,
|
||||||
@@ -55,43 +48,39 @@ export default async function ApiProxy(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const queryUrl =
|
||||||
const token = await getToken();
|
"pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
||||||
|
incidentID +
|
||||||
|
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate,pinswg_documentpublisheddate";
|
||||||
|
|
||||||
const queryUrl =
|
return relayGet({
|
||||||
"pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
queryUrl,
|
||||||
incidentID +
|
res,
|
||||||
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate,pinswg_documentpublisheddate";
|
requestOptionsBuilder: (accessToken) => azureHeadersPaged(accessToken),
|
||||||
|
transformData: (data) => {
|
||||||
const { data } = await axios.get(
|
data.value.forEach(function (element) {
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
Object.assign(element, {
|
||||||
azureHeadersPaged(token.access_token)
|
"pinswg_documentpublisheddate":
|
||||||
);
|
element.pinswg_documentpublisheddate != null
|
||||||
|
? element.pinswg_documentpublisheddate
|
||||||
data.value.forEach(function (element) {
|
: element.pinswg_latestpublisheddate
|
||||||
Object.assign(element, {
|
});
|
||||||
"pinswg_documentpublisheddate":
|
element.pinswg_hashlink = encryptDocReference(
|
||||||
element.pinswg_documentpublisheddate != null
|
element.pinswg_isharedocumentreference
|
||||||
? element.pinswg_documentpublisheddate
|
);
|
||||||
: element.pinswg_latestpublisheddate
|
|
||||||
});
|
});
|
||||||
element.pinswg_hashlink = encryptDocReference(
|
|
||||||
element.pinswg_isharedocumentreference
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (_.has(data, "@odata.nextLink") === true) {
|
if (_.has(data, "@odata.nextLink") === true) {
|
||||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
return data;
|
||||||
} catch (error) {
|
},
|
||||||
consoleLogger(error);
|
errorResponse: {
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "SEARCH_DOCUMENT_DETAILS_FETCH_FAILED",
|
code: "SEARCH_DOCUMENT_DETAILS_FETCH_FAILED",
|
||||||
message: "Failed to fetch search document details"
|
message: "Failed to fetch search document details"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,21 +42,14 @@
|
|||||||
* description: Success
|
* description: Success
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import axios from "axios";
|
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
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 WORDKEY = process.env.HASHKEY;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
const WEBAPI_URL =
|
|
||||||
process.env.RELAY_ROOT ||
|
|
||||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
||||||
|
|
||||||
const encryptDocReference = (documentRef) => {
|
const encryptDocReference = (documentRef) => {
|
||||||
var hashlink = CryptoJS.HmacSHA256(
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
"documents/download/" + documentRef,
|
"documents/download/" + documentRef,
|
||||||
@@ -150,53 +143,49 @@ export default async function ApiProxy(req, res) {
|
|||||||
//console.log("has this passed docuemntType:", documentType);
|
//console.log("has this passed docuemntType:", documentType);
|
||||||
//(documentType !="all" && " pinswg_pinswg_isharedocumentlocations eq " + )
|
//(documentType !="all" && " pinswg_pinswg_isharedocumentlocations eq " + )
|
||||||
|
|
||||||
try {
|
const queryUrl =
|
||||||
const token = await getToken();
|
"pinswg_documents?$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
||||||
|
incidentID +
|
||||||
|
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null" +
|
||||||
|
docTypeQueryString +
|
||||||
|
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate,pinswg_documentpublisheddate&$orderby=" +
|
||||||
|
orderby +
|
||||||
|
" " +
|
||||||
|
fieldSort +
|
||||||
|
"&$count=true" +
|
||||||
|
(typeof pageNumber != "undefined"
|
||||||
|
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
|
||||||
|
: "");
|
||||||
|
|
||||||
const queryUrl =
|
return relayGet({
|
||||||
"pinswg_documents?$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
queryUrl,
|
||||||
incidentID +
|
res,
|
||||||
" and pinswg_latestpublishedversion ne null and pinswg_latestpublisheddate ne null" +
|
requestOptionsBuilder: (accessToken) =>
|
||||||
docTypeQueryString +
|
azureHeadersPagedCustom(accessToken, showNumberOfRecords),
|
||||||
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference,pinswg_name,pinswg_latestpublishedversion,pinswg_latestpublisheddate,pinswg_documentpublisheddate&$orderby=" +
|
transformData: (data) => {
|
||||||
orderby +
|
data.value.forEach(function (element) {
|
||||||
" " +
|
Object.assign(element, {
|
||||||
fieldSort +
|
"pinswg_documentpublisheddate":
|
||||||
"&$count=true" +
|
element.pinswg_documentpublisheddate != null
|
||||||
(typeof pageNumber != "undefined"
|
? element.pinswg_documentpublisheddate
|
||||||
? "&$skiptoken=" +
|
: element.pinswg_latestpublisheddate
|
||||||
('<cookie pagenumber="' + pageNumber + '" />')
|
});
|
||||||
: "");
|
element.pinswg_hashlink = encryptDocReference(
|
||||||
|
element.pinswg_isharedocumentreference
|
||||||
const { data } = await axios.get(
|
);
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
|
||||||
azureHeadersPagedCustom(token.access_token, showNumberOfRecords)
|
|
||||||
);
|
|
||||||
|
|
||||||
data.value.forEach(function (element) {
|
|
||||||
Object.assign(element, {
|
|
||||||
"pinswg_documentpublisheddate":
|
|
||||||
element.pinswg_documentpublisheddate != null
|
|
||||||
? element.pinswg_documentpublisheddate
|
|
||||||
: element.pinswg_latestpublisheddate
|
|
||||||
});
|
});
|
||||||
element.pinswg_hashlink = encryptDocReference(
|
|
||||||
element.pinswg_isharedocumentreference
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (_.has(data, "@odata.nextLink") === true) {
|
if (_.has(data, "@odata.nextLink") === true) {
|
||||||
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
||||||
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return respondSuccess(res, data);
|
return data;
|
||||||
} catch (error) {
|
},
|
||||||
consoleLogger(error);
|
errorResponse: {
|
||||||
return respondError(res, {
|
|
||||||
status: 400,
|
status: 400,
|
||||||
code: "SEARCH_DOCUMENT_DETAILS_PAGED_FETCH_FAILED",
|
code: "SEARCH_DOCUMENT_DETAILS_PAGED_FETCH_FAILED",
|
||||||
message: "Failed to fetch paged search document details"
|
message: "Failed to fetch paged search document details"
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1341,6 +1341,7 @@ test("getsearchdocumentdetails returns INCIDENT_ID_REQUIRED when incidentid miss
|
|||||||
{
|
{
|
||||||
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",
|
||||||
azureHeadersPaged: () => ({}),
|
azureHeadersPaged: () => ({}),
|
||||||
@@ -1368,6 +1369,8 @@ test("getsearchdocumentdetails catch path returns SEARCH_DOCUMENT_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" }),
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
azureHeadersPaged: () => ({}),
|
azureHeadersPaged: () => ({}),
|
||||||
@@ -1402,6 +1405,7 @@ test("getsearchdocumentdetailspaged returns INCIDENT_ID_REQUIRED when incidentid
|
|||||||
{
|
{
|
||||||
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: () => ({}),
|
||||||
@@ -1435,6 +1439,8 @@ test("getsearchdocumentdetailspaged catch path returns SEARCH_DOCUMENT_DETAILS_P
|
|||||||
{
|
{
|
||||||
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: () => ({}),
|
||||||
@@ -1474,6 +1480,7 @@ test("getsearchdocumentTypes returns INCIDENT_ID_REQUIRED when incidentid missin
|
|||||||
const mod = loadModule("pages/api/endpoint/getsearchdocumentTypes_api.js", {
|
const mod = loadModule("pages/api/endpoint/getsearchdocumentTypes_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",
|
||||||
azureHeaders: () => ({}),
|
azureHeaders: () => ({}),
|
||||||
@@ -1493,6 +1500,8 @@ test("getsearchdocumentTypes catch path returns SEARCH_DOCUMENT_TYPES_FETCH_FAIL
|
|||||||
const mod = loadModule("pages/api/endpoint/getsearchdocumentTypes_api.js", {
|
const mod = loadModule("pages/api/endpoint/getsearchdocumentTypes_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",
|
||||||
azureHeaders: () => ({}),
|
azureHeaders: () => ({}),
|
||||||
@@ -1519,6 +1528,19 @@ test("getsearchdocumentTypes success returns grouped data payload contract", asy
|
|||||||
const mod = loadModule("pages/api/endpoint/getsearchdocumentTypes_api.js", {
|
const mod = loadModule("pages/api/endpoint/getsearchdocumentTypes_api.js", {
|
||||||
respondError: respondErrorMock,
|
respondError: respondErrorMock,
|
||||||
respondSuccess: respondSuccessMock,
|
respondSuccess: respondSuccessMock,
|
||||||
|
relayGet: async ({ res }) =>
|
||||||
|
respondSuccessMock(res, [
|
||||||
|
{
|
||||||
|
pinswg_isharedocumentlocations: 1,
|
||||||
|
pinswg_isharedocumentlocationsLabel: "Plans",
|
||||||
|
count: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pinswg_isharedocumentlocations: 2,
|
||||||
|
pinswg_isharedocumentlocationsLabel: "Letters",
|
||||||
|
count: 1
|
||||||
|
}
|
||||||
|
]),
|
||||||
getToken: async () => ({ access_token: "token" }),
|
getToken: async () => ({ access_token: "token" }),
|
||||||
hashAPIPath: () => "&hash=expected",
|
hashAPIPath: () => "&hash=expected",
|
||||||
azureHeaders: () => ({}),
|
azureHeaders: () => ({}),
|
||||||
@@ -2334,6 +2356,7 @@ test("getportalmoduledetailsproxy returns APPEAL_TYPE_REQUIRED when appealType m
|
|||||||
{
|
{
|
||||||
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",
|
||||||
@@ -2357,6 +2380,8 @@ test("getportalmoduledetailsproxy catch path returns PORTAL_MODULE_DETAILS_PROXY
|
|||||||
{
|
{
|
||||||
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",
|
||||||
@@ -3468,6 +3493,7 @@ test("getappealpdfdocuments returns INCIDENT_ID_REQUIRED when incidentid missing
|
|||||||
const mod = loadModule("pages/api/endpoint/getappealpdfdocuments_api.js", {
|
const mod = loadModule("pages/api/endpoint/getappealpdfdocuments_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",
|
||||||
azureHeaders: () => ({}),
|
azureHeaders: () => ({}),
|
||||||
@@ -3487,6 +3513,8 @@ test("getappealpdfdocuments catch path returns APPEAL_PDF_DOCUMENTS_FETCH_FAILED
|
|||||||
const mod = loadModule("pages/api/endpoint/getappealpdfdocuments_api.js", {
|
const mod = loadModule("pages/api/endpoint/getappealpdfdocuments_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",
|
||||||
azureHeaders: () => ({}),
|
azureHeaders: () => ({}),
|
||||||
|
|||||||
Reference in New Issue
Block a user