moved hashapipath to reusable single helper
This commit is contained in:
@@ -21,25 +21,12 @@ import { JSONPath as jsonpath } from "jsonpath-plus";
|
||||
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) => {
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
);
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
|
||||
//return "&hash=" + hashlink;
|
||||
|
||||
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
const getIncident = async (incidentID) => {
|
||||
const queryUrl =
|
||||
process.env.API_ROOT +
|
||||
@@ -48,7 +35,7 @@ const getIncident = async (incidentID) => {
|
||||
|
||||
var config = {
|
||||
method: "get",
|
||||
url: queryUrl,
|
||||
url: queryUrl
|
||||
};
|
||||
|
||||
return axios(config)
|
||||
@@ -84,7 +71,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "0735866b-5482-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040018",
|
||||
"NavigationProperty": "pinswg_AdvertsIds",
|
||||
"value": "Adverts",
|
||||
"value": "Adverts"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_callinss77s",
|
||||
@@ -94,7 +81,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "dd309e51-4982-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040010",
|
||||
"NavigationProperty": "pinswg_CallInsS77Ids",
|
||||
"value": "Called In Applications - S77",
|
||||
"value": "Called In Applications - S77"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_commonlands",
|
||||
@@ -104,7 +91,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "4161a618-5082-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040016",
|
||||
"NavigationProperty": "pinswg_CommonLandIds",
|
||||
"value": "Common Land",
|
||||
"value": "Common Land"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
@@ -115,7 +102,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "0c309f3c-4882-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040009",
|
||||
"NavigationProperty": "pinswg_CommunityInfrastructureLevyIds",
|
||||
"value": "Community Infrastructure Levy - S117, 118, & 119",
|
||||
"value": "Community Infrastructure Levy - S117, 118, & 119"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_compulsorypurchaseorderses",
|
||||
@@ -125,7 +112,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "054da4c7-5582-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040019",
|
||||
"NavigationProperty": "pinswg_CompulsoryPurchaseOrdersIds",
|
||||
"value": "Compulsory Purchase Orders",
|
||||
"value": "Compulsory Purchase Orders"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_dnses",
|
||||
@@ -135,7 +122,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "36f07225-4a82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040011",
|
||||
"NavigationProperty": "pinswg_DNSIds",
|
||||
"value": "Developments of National Significance",
|
||||
"value": "Developments of National Significance"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_electricityacts",
|
||||
@@ -145,7 +132,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "6aedaab1-4a82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040012",
|
||||
"NavigationProperty": "pinswg_ElectricityActIds",
|
||||
"value": "Electricity Act",
|
||||
"value": "Electricity Act"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName":
|
||||
@@ -157,8 +144,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "c697be96-9481-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040006",
|
||||
"NavigationProperty": "pinswg_EnforcementListedBuildingConseIds",
|
||||
"value":
|
||||
"Enforcement Listed Building and Conservation Appeal - S39",
|
||||
"value": "Enforcement Listed Building and Conservation Appeal - S39"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_enforcementnoticeappeals174s",
|
||||
@@ -168,7 +154,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "930a3cc4-9181-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040005",
|
||||
"NavigationProperty": "pinswg_EnforcementNoticeAppealS174Ids",
|
||||
"value": "Enforcement Notice Appeal - S174",
|
||||
"value": "Enforcement Notice Appeal - S174"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_environmentalpermittings",
|
||||
@@ -178,7 +164,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "62d4aa9a-5682-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040020",
|
||||
"NavigationProperty": "pinswg_EnforcementPermittingIds",
|
||||
"value": "Environmental Permitting",
|
||||
"value": "Environmental Permitting"
|
||||
},
|
||||
// {
|
||||
// "LogicalCollectionName": "pinswg_harbourrevisionorders",
|
||||
@@ -200,7 +186,7 @@ export default async function ApiProxy(req, res) {
|
||||
"appealTypeID": "846040017",
|
||||
"NavigationProperty": "pinswg_HedgesHedgerowsTreePreservatioIds",
|
||||
"value":
|
||||
"High Hedges, Tree Preservation orders, Hedgerows, Tree Replacement Notice.",
|
||||
"High Hedges, Tree Preservation orders, Hedgerows, Tree Replacement Notice."
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_householderappealhases",
|
||||
@@ -210,7 +196,7 @@ export default async function ApiProxy(req, res) {
|
||||
"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",
|
||||
@@ -220,7 +206,7 @@ export default async function ApiProxy(req, res) {
|
||||
"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",
|
||||
@@ -249,7 +235,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "bb302784-9581-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040007",
|
||||
"NavigationProperty": "pinswg_MaintenanceofLandS217Ids",
|
||||
"value": "Maintenance of Land - S217",
|
||||
"value": "Maintenance of Land - S217"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_miscellaneouscaseworks",
|
||||
@@ -258,7 +244,7 @@ export default async function ApiProxy(req, res) {
|
||||
"UrlName": "miscellaneouscasework",
|
||||
"MetadataId": "f519aa8e-5782-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040022",
|
||||
"NavigationProperty": "pinswg_MiscellaneousCasewordIds",
|
||||
"NavigationProperty": "pinswg_MiscellaneousCasewordIds"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_nonvalidations",
|
||||
@@ -268,7 +254,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "37f31a93-5882-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040024",
|
||||
"NavigationProperty": "pinswg_NonValidationIds",
|
||||
"value": "Non-Validation",
|
||||
"value": "Non-Validation"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningappeals78s",
|
||||
@@ -278,7 +264,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "8d7f813a-4183-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040000",
|
||||
"NavigationProperty": "pinswg_PlanningAppealS78Ids",
|
||||
"value": "Planning Appeal - S78",
|
||||
"value": "Planning Appeal - S78"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningconditionss73s79s",
|
||||
@@ -288,7 +274,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "093bf9ff-8d81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040001",
|
||||
"NavigationProperty": "pinswg_PlanningConditionsS73S79Ids",
|
||||
"value": "Planning Conditions - S73 + S79",
|
||||
"value": "Planning Conditions - S73 + S79"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_planningobligationappeals106s",
|
||||
@@ -298,7 +284,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "cb8beeae-8f81-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040003",
|
||||
"NavigationProperty": "pinswg_PlanningObligationAppealS106Ids",
|
||||
"value": "Planning Obligation Appeal - S106",
|
||||
"value": "Planning Obligation Appeal - S106"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_sipses",
|
||||
@@ -309,7 +295,7 @@ export default async function ApiProxy(req, res) {
|
||||
"appealTypeID": "846040002",
|
||||
"tmpNav": "pinswg_sipsid",
|
||||
"NavigationProperty": "pinswg_sipscase",
|
||||
"value": "SIP",
|
||||
"value": "SIP"
|
||||
},
|
||||
|
||||
{
|
||||
@@ -320,7 +306,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "4ccc6e93-4f82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040015",
|
||||
"NavigationProperty": "pinswg_ROWIds",
|
||||
"value": "Rights of Way",
|
||||
"value": "Rights of Way"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_transportandworkacts",
|
||||
@@ -330,7 +316,7 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "bc3edc4b-7d82-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040013",
|
||||
"NavigationProperty": "pinswg_TransportandWorkActIds",
|
||||
"value": "Transport and Works Act",
|
||||
"value": "Transport and Works Act"
|
||||
},
|
||||
{
|
||||
"LogicalCollectionName": "pinswg_wayleaves",
|
||||
@@ -340,8 +326,8 @@ export default async function ApiProxy(req, res) {
|
||||
"MetadataId": "a0652117-5782-eb11-aac0-00224800be9c",
|
||||
"appealTypeID": "846040021",
|
||||
"NavigationProperty": "pinswg_WayleaveIds",
|
||||
"value": "Wayleave",
|
||||
},
|
||||
"value": "Wayleave"
|
||||
}
|
||||
];
|
||||
|
||||
const getSearchResultsObj = await Promise.all(
|
||||
@@ -398,14 +384,15 @@ export default async function ApiProxy(req, res) {
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_town"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_dnses" ||
|
||||
item.LogicalCollectionName == "pinswg_sipses"
|
||||
? "pinswg_addresstown"
|
||||
: "pinswg_siteaddresstown") +
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_dnses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_sipses"
|
||||
? "pinswg_addresstown"
|
||||
: "pinswg_siteaddresstown") +
|
||||
", '" +
|
||||
town +
|
||||
"')) "
|
||||
@@ -420,16 +407,17 @@ export default async function ApiProxy(req, res) {
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_county"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_dnses" ||
|
||||
item.LogicalCollectionName == "pinswg_sipses"
|
||||
? "pinswg_addresscounty"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_sitecounty"
|
||||
: "pinswg_siteaddresscounty") +
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_dnses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_sipses"
|
||||
? "pinswg_addresscounty"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_sitecounty"
|
||||
: "pinswg_siteaddresscounty") +
|
||||
", '" +
|
||||
county +
|
||||
"')) "
|
||||
@@ -444,12 +432,12 @@ export default async function ApiProxy(req, res) {
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_postcode"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_postcode"
|
||||
: "pinswg_siteaddresspostcode") +
|
||||
"pinswg_transportandworkacts" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses"
|
||||
? "pinswg_postcode"
|
||||
: "pinswg_siteaddresspostcode") +
|
||||
", '" +
|
||||
postcode +
|
||||
"')) "
|
||||
@@ -506,38 +494,38 @@ export default async function ApiProxy(req, res) {
|
||||
"pinswg_harbourrevisionorders"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_addresspostcode"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName == "pinswg_sipses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_postcode"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_sitecounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode"
|
||||
: "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_siteaddresscounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode") +
|
||||
"pinswg_electricityacts" ||
|
||||
item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName == "pinswg_sipses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_addresstown,pinswg_addressline1,pinswg_addresscounty,pinswg_addressline2,pinswg_postcode"
|
||||
: item.LogicalCollectionName == "pinswg_rows"
|
||||
? "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_sitecounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode"
|
||||
: "pinswg_siteaddresstown,pinswg_siteaddressline1,pinswg_siteaddresscounty,pinswg_siteaddressline2,pinswg_siteaddresspostcode") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_dnses" ||
|
||||
item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_dateofdecision,"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_nonvalidations"
|
||||
? "pinswg_decisionissueddate,"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts"
|
||||
? "pinswg_datedecision,"
|
||||
: item.LogicalCollectionName == "pinswg_sipses"
|
||||
? ""
|
||||
: "pinswg_casedecisiondate,") +
|
||||
"pinswg_nonvalidations"
|
||||
? "pinswg_decisionissueddate,"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_electricityacts"
|
||||
? "pinswg_datedecision,"
|
||||
: item.LogicalCollectionName == "pinswg_sipses"
|
||||
? ""
|
||||
: "pinswg_casedecisiondate,") +
|
||||
(item.LogicalCollectionName == "pinswg_planningappeals78s"
|
||||
? "pinswg_dicision"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_decsision"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_nonvalidations"
|
||||
? "pinswg_decisionissued"
|
||||
: "pinswg_decision") +
|
||||
"pinswg_transportandworkacts"
|
||||
? "pinswg_decsision"
|
||||
: item.LogicalCollectionName ==
|
||||
"pinswg_nonvalidations"
|
||||
? "pinswg_decisionissued"
|
||||
: "pinswg_decision") +
|
||||
"," +
|
||||
(item.LogicalCollectionName == "pinswg_nonvalidations" ||
|
||||
item.LogicalCollectionName == "pinswg_sipses"
|
||||
@@ -615,7 +603,7 @@ export default async function ApiProxy(req, res) {
|
||||
: "_" +
|
||||
item.NavigationProperty.toLowerCase() +
|
||||
"_value"
|
||||
],
|
||||
]
|
||||
});
|
||||
});
|
||||
return searchResultsObj.push(data);
|
||||
@@ -632,7 +620,7 @@ export default async function ApiProxy(req, res) {
|
||||
searchResultsObj = jsonpath({
|
||||
path: "$..[?(@ && @.pinswg_name)]",
|
||||
json: searchResultsObj,
|
||||
eval: true,
|
||||
eval: true
|
||||
});
|
||||
|
||||
searchResultsObj = searchResultsObj.filter((arr) => arr.incidentid != null);
|
||||
@@ -663,7 +651,7 @@ export default async function ApiProxy(req, res) {
|
||||
Object.assign(key, {
|
||||
"pinswg_publishtoweb": incidentObj.pinswg_publishtoweb,
|
||||
"ticketnumber": incidentObj.ticketnumber,
|
||||
"pinswg_lpareference": incidentObj.pinswg_lpareference,
|
||||
"pinswg_lpareference": incidentObj.pinswg_lpareference
|
||||
});
|
||||
|
||||
return incidentObj;
|
||||
@@ -695,7 +683,7 @@ export default async function ApiProxy(req, res) {
|
||||
let searchResultsOutputObj = {};
|
||||
Object.assign(searchResultsOutputObj, {
|
||||
"@odata.count": searchResultsObj.length,
|
||||
"value": searchResultsObj,
|
||||
"value": searchResultsObj
|
||||
});
|
||||
|
||||
return res.status(200).json(searchResultsOutputObj);
|
||||
|
||||
Reference in New Issue
Block a user