moved hashapipath to reusable single helper
This commit is contained in:
@@ -3,22 +3,12 @@ import CryptoJS from "crypto-js";
|
||||
import { azureHeaders } from "../../../actions/core/headers";
|
||||
import { consoleLogger } from "../../../actions/core/logger";
|
||||
import { getToken } from "../../../actions/core/token";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
|
||||
const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
const hashAPIPath = (queryPath) => {
|
||||
let hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
);
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
// ✅ IMPORTANT: Only include the 23 types that actually contain pinswg_lpaapplicationreference
|
||||
// You can copy from your existing appealTypeArray but only keep those entities.
|
||||
|
||||
@@ -31,7 +21,7 @@ var appealTypeArrayWithLpaRef = [
|
||||
"MetadataId": "0735866b-5482-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040018",
|
||||
"NavigationProperty": "pinswg_AdvertsIds",
|
||||
"value": "Adverts",
|
||||
"value": "Adverts"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_callinss77s",
|
||||
@@ -41,7 +31,7 @@ var appealTypeArrayWithLpaRef = [
|
||||
"MetadataId": "dd309e51-4982-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040010",
|
||||
"NavigationProperty": "pinswg_CallInsS77Ids",
|
||||
"value": "Called In Applications - S77",
|
||||
"value": "Called In Applications - S77"
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_commonlands",
|
||||
@@ -156,7 +146,7 @@ var appealTypeArrayWithLpaRef = [
|
||||
"MetadataId": "a6c728b0-9081-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040004",
|
||||
"NavigationProperty": "pinswg_HouseholderAppealHASIds",
|
||||
"value": "Householder and Minor Commercial Appeals - HAS/CAS",
|
||||
"value": "Householder and Minor Commercial Appeals - HAS/CAS"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_lawfuldevelopmentcertificates",
|
||||
@@ -166,7 +156,7 @@ var appealTypeArrayWithLpaRef = [
|
||||
"MetadataId": "184e4861-9681-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040008",
|
||||
"NavigationProperty": "pinswg_LawfulDevelopmentCertificatAppIds",
|
||||
"value": "Lawful Development Certificate Appeal - S194 + 195",
|
||||
"value": "Lawful Development Certificate Appeal - S194 + 195"
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_ldps",
|
||||
@@ -224,7 +214,7 @@ var appealTypeArrayWithLpaRef = [
|
||||
"MetadataId": "8d7f813a-4183-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040000",
|
||||
"NavigationProperty": "pinswg_PlanningAppealS78Ids",
|
||||
"value": "Planning Appeal - S78",
|
||||
"value": "Planning Appeal - S78"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningconditionss73s79s",
|
||||
@@ -234,8 +224,8 @@ var appealTypeArrayWithLpaRef = [
|
||||
"MetadataId": "093bf9ff-8d81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040001",
|
||||
"NavigationProperty": "pinswg_PlanningConditionsS73S79Ids",
|
||||
"value": "Planning Conditions - S73 + S79",
|
||||
},
|
||||
"value": "Planning Conditions - S73 + S79"
|
||||
}
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_planningobligationappeals106s",
|
||||
// "LogicalName": "pinswg_planningobligationappeals106",
|
||||
@@ -321,7 +311,7 @@ export default async function ApiProxy(req, res) {
|
||||
"statuscode",
|
||||
"pinswg_lpaapplicationreference",
|
||||
"pinswg_name",
|
||||
"_" + item.NavigationProperty.toLowerCase() + "_value", // for incidentid mapping (same pattern you used)
|
||||
"_" + item.NavigationProperty.toLowerCase() + "_value" // for incidentid mapping (same pattern you used)
|
||||
].join(",");
|
||||
|
||||
const filter = `contains(pinswg_lpaapplicationreference,'${lowered}')`;
|
||||
@@ -360,7 +350,7 @@ export default async function ApiProxy(req, res) {
|
||||
"_" +
|
||||
item.NavigationProperty.toLowerCase() +
|
||||
"_value"
|
||||
] || null,
|
||||
] || null
|
||||
}));
|
||||
|
||||
console.log(
|
||||
@@ -379,7 +369,7 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
const output = {
|
||||
"@odata.count": flattened.length,
|
||||
value: flattened,
|
||||
value: flattened
|
||||
};
|
||||
|
||||
return res.status(200).json(output);
|
||||
|
||||
Reference in New Issue
Block a user