TASK22224: aggressive non-file parity bundle

This commit is contained in:
2026-03-23 18:32:49 +00:00
parent ba9beda65e
commit 411190e403
8 changed files with 249 additions and 116 deletions
+38 -41
View File
@@ -43,18 +43,18 @@ const encryptDocReference = (documentRef) => {
};
export default async function ApiProxy(req, res) {
var pageNumber = req.query.pageNumber || 1;
var token = await getToken();
const pageNumber = req.query.pageNumber || 1;
const token = await getToken();
var orderby = req.query.orderby || "createdon";
var fieldSort = req.query.fieldSort || "desc";
var showNumberOfRecords = req.query.showNumberOfRecords || 10;
var documentType = req.query.documentType || "all";
var documentOrigin = req.query.documentOrigin || "all";
var numberOfWeeks = req.query.numberWeeks || 1;
const orderby = req.query.orderby || "createdon";
const fieldSort = req.query.fieldSort || "desc";
const showNumberOfRecords = req.query.showNumberOfRecords || 10;
const documentType = req.query.documentType || "all";
const documentOrigin = req.query.documentOrigin || "all";
const numberOfWeeks = req.query.numberWeeks || 1;
var docTypeQueryString = "";
var docOriginQueryString = "";
let docTypeQueryString = "";
let docOriginQueryString = "";
if (documentType != "all") {
if (documentType.indexOf(",") >= 0) {
@@ -108,7 +108,7 @@ export default async function ApiProxy(req, res) {
return resultDate.toISOString().replace(/\.000Z$/, "Z"); // format as 'YYYY-MM-DDT00:00:00Z'
}
var queryUrl =
const queryUrl =
"pinswg_documents?$select=pinswg_name,createdon,pinswg_publishtoweb,_pinswg_documentids_value,pinswg_isharedocumentlocations,pinswg_isharedocumentreference,pinswg_uploadurl,pinswg_uploadstatus,pinswg_origin&$filter=createdon ge " +
daysAgoISO(numberOfWeeks) +
docTypeQueryString +
@@ -131,40 +131,37 @@ export default async function ApiProxy(req, res) {
"\n==========================================\n"
);
var apiResponse = axios
.get(
try {
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPagedCustom(token.access_token, showNumberOfRecords)
)
.then(({ data }) => {
let flattened = data.value.map((r) => ({
...r,
ticketnumber: r.pinswg_DocumentIds?.ticketnumber || null,
publishtoweb: r.pinswg_DocumentIds?.pinswg_publishtoweb || null
}));
);
data.value = flattened;
data.value.forEach(function (element) {
element.pinswg_hashlink = encryptDocReference(
element.pinswg_isharedocumentreference
);
});
const flattened = data.value.map((r) => ({
...r,
ticketnumber: r.pinswg_DocumentIds?.ticketnumber || null,
publishtoweb: r.pinswg_DocumentIds?.pinswg_publishtoweb || null
}));
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((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,
code: "ADMIN_LATEST_DOCS_FETCH_FAILED",
message: "Failed to fetch latest documents"
});
data.value = flattened;
data.value.forEach(function (element) {
element.pinswg_hashlink = encryptDocReference(
element.pinswg_isharedocumentreference
);
});
return apiResponse;
let dataStr;
_.has(data, "@odata.nextLink") == true &&
((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,
code: "ADMIN_LATEST_DOCS_FETCH_FAILED",
message: "Failed to fetch latest documents"
});
}
}
+22 -27
View File
@@ -16,7 +16,6 @@
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { azureHeadersPagedCustom } from "../../../actions/core/headers";
import { getToken } from "../../../actions/core/token";
@@ -29,15 +28,14 @@ const WEBAPI_URL =
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
export default async function ApiProxy(req, res) {
var searchString = req.query.searchString;
var pageNumber = req.query.pageNumber || 1;
var token = await getToken();
const pageNumber = req.query.pageNumber || 1;
const token = await getToken();
var orderby = req.query.orderby || "createdon";
var fieldSort = req.query.fieldSort || "desc";
var showNumberOfRecords = req.query.showNumberOfRecords || 10;
const orderby = req.query.orderby || "createdon";
const fieldSort = req.query.fieldSort || "desc";
const showNumberOfRecords = req.query.showNumberOfRecords || 10;
var queryUrl =
const queryUrl =
"incidents?$select=caseorigincode,pinswg_publishtoweb,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)&$orderby=" +
orderby +
" " +
@@ -55,26 +53,23 @@ export default async function ApiProxy(req, res) {
"\n==========================================\n"
);
var apiResponse = axios
.get(
try {
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPagedCustom(token.access_token, showNumberOfRecords)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((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,
code: "ADMIN_NEW_APPEALS_FETCH_FAILED",
message: "Failed to fetch new appeals"
});
});
);
return apiResponse;
let dataStr;
_.has(data, "@odata.nextLink") == true &&
((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,
code: "ADMIN_NEW_APPEALS_FETCH_FAILED",
message: "Failed to fetch new appeals"
});
}
}
+14 -16
View File
@@ -22,27 +22,25 @@ function flattenWatchlistEntry(entry) {
}
export default async function ApiProxy(req, res) {
var token = await getToken();
const token = await getToken();
var queryUrl =
const queryUrl =
"pinswg_watchlists?$count=true&$filter=pinswg_emailnotifications ne null&$expand=pinswg_Contact($select=contactid,emailaddress1)&$select=pinswg_emailnotifications,_pinswg_watchedcase_value";
return axios
.get(
try {
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
const flattenedResults = data.value.map(flattenWatchlistEntry);
);
const flattenedResults = data.value.map(flattenWatchlistEntry);
return respondSuccess(res, flattenedResults);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "CASE_REF_FETCH_FAILED",
message: "Failed to fetch case references"
});
return respondSuccess(res, flattenedResults);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "CASE_REF_FETCH_FAILED",
message: "Failed to fetch case references"
});
}
}
+14 -16
View File
@@ -22,27 +22,25 @@ function flattenWatchlistEntry(entry) {
}
export default async function ApiProxy(req, res) {
var token = await getToken();
const token = await getToken();
var queryUrl =
const queryUrl =
"pinswg_watchlists?$count=true&$filter=pinswg_emailnotifications ne null&$expand=pinswg_Contact($select=contactid,emailaddress1)&$select=pinswg_emailnotifications,_pinswg_watchedcase_value";
return axios
.get(
try {
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
const flattenedResults = data.value.map(flattenWatchlistEntry);
);
const flattenedResults = data.value.map(flattenWatchlistEntry);
return respondSuccess(res, flattenedResults);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "MAILING_LIST_FETCH_FAILED",
message: "Failed to fetch mailing list"
});
return respondSuccess(res, flattenedResults);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "MAILING_LIST_FETCH_FAILED",
message: "Failed to fetch mailing list"
});
}
}
+14 -15
View File
@@ -31,7 +31,7 @@ import { getPreferredLanguage } from "../../../actions/services/accountService";
import { respondError, respondSuccess } from "../middleware/apiResponse";
export default async function ApiProxy(req, res) {
var data = req.body;
const data = req.body;
const emailAddress = sanitizeString(data?.emailAddress);
if (!isNonEmptyString(emailAddress)) {
@@ -58,7 +58,7 @@ export default async function ApiProxy(req, res) {
}
}
var NotifyClient = require("notifications-node-client").NotifyClient;
const NotifyClient = require("notifications-node-client").NotifyClient;
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
//const emailReplyToId = process.env.EMAIL_REPLY_TO_ID;
@@ -68,20 +68,19 @@ export default async function ApiProxy(req, res) {
payload: redactSensitive(data)
});
notifyClient
.sendEmail(data.templateId, data.emailAddress, {
try {
await notifyClient.sendEmail(data.templateId, data.emailAddress, {
personalisation: data.personalisation,
reference: data.reference
})
.then(() => {
return respondSuccess(res, data);
})
.catch((error) => {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "EMAIL_NOTIFY_FAILED",
message: "Failed to send notify email"
});
});
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "EMAIL_NOTIFY_FAILED",
message: "Failed to send notify email"
});
}
}
+9 -1
View File
@@ -49,8 +49,16 @@ export default async function ApiProxy(req, res) {
const checkquerypath =
"/api/endpoint/getportallogin_api?emailAddress=" + emailAddress;
const encodedCheckquerypath =
"/api/endpoint/getportallogin_api?emailAddress=" +
encodeURIComponent(emailAddress);
if (hashAPIPath(checkquerypath) != "&hash=" + checkHash) {
const expectedHashCandidates = [
hashAPIPath(checkquerypath),
hashAPIPath(encodedCheckquerypath)
];
if (!expectedHashCandidates.includes("&hash=" + checkHash)) {
return respondError(res, {
status: 400,
code: "INVALID_HASH",