refactor actions into core modules and grouped services
This commit is contained in:
+11
@@ -50,3 +50,14 @@ pages/admin/logchecker.js
|
||||
pages/baracuda.html
|
||||
pages/holding-min.html
|
||||
pages/holding.html
|
||||
|
||||
# Cline / AI-assistant governance artifacts (keep local-only)
|
||||
.clinerules
|
||||
.clinerules/
|
||||
CONTRIBUTING_AI.md
|
||||
GUARDRAILS.md
|
||||
ai-prompts/
|
||||
context/
|
||||
memory-bank/
|
||||
workflows/
|
||||
AI_CONTEXT.md
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Actions Clients
|
||||
|
||||
This folder is reserved for extracted client wrappers from `actions/index.js` as part of the Priority 1 refactor plan.
|
||||
|
||||
Phase 1 delivered core helper extraction and compatibility barrel support.
|
||||
Client-level extraction (`relayClient`, `endpointClient`, `fileClient`, `notifyClient`) is planned for the next increment.
|
||||
@@ -0,0 +1,15 @@
|
||||
const port = parseInt(process.env.PORT, 10) || 3000;
|
||||
|
||||
export const BASE_URL =
|
||||
typeof window !== "undefined"
|
||||
? window.apiRoot
|
||||
: process.env.API_ROOT || `http://localhost:${port}`;
|
||||
|
||||
export const API_PATH = "/api/data/v8.2/";
|
||||
|
||||
export const WEBAPI_URL =
|
||||
process.env.RELAY_ROOT ||
|
||||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
||||
|
||||
export const ACCESS_TOKEN_ENDPOINT = process.env.ACCESS_TOKEN_ENDPOINT;
|
||||
export const TENANT_ID = process.env.TENANT;
|
||||
@@ -0,0 +1,22 @@
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
export const hashAPIPath = (queryPath) => {
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
);
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
|
||||
};
|
||||
|
||||
export const hashString = (stringToHash) => {
|
||||
let hashedStr = CryptoJS.AES.encrypt(stringToHash, "pedw");
|
||||
return hashedStr.toString();
|
||||
};
|
||||
|
||||
export const dehashString = (stringToDeHash) => {
|
||||
let dehashedStr = CryptoJS.AES.decrypt(decodeURI(stringToDeHash), "pedw");
|
||||
return dehashedStr.toString(CryptoJS.enc.Utf8);
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
export const azureHeaders = (access_token) => {
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + access_token
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const azureHeadersNoOdata = (access_token) => {
|
||||
return {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + access_token
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const azureHeadersPaged = (access_token) => {
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer":
|
||||
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + access_token
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json;odata.metadata=none",
|
||||
"Prefer":
|
||||
'odata.include-annotations="*",return=representation, odata.maxpagesize=' +
|
||||
showNumberOfRecords,
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + access_token
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
import _ from "lodash";
|
||||
|
||||
export const getIP = (req) => {
|
||||
const forwarded = req.headers["x-forwarded-for"];
|
||||
|
||||
const ip =
|
||||
typeof forwarded === "string"
|
||||
? forwarded.split(/, /)[0]
|
||||
: req.socket.remoteAddress;
|
||||
|
||||
console.info(
|
||||
"\n====================\n Client IP address: " + ip,
|
||||
"\n=====================\n"
|
||||
);
|
||||
};
|
||||
|
||||
export const consoleLogger = (err) => {
|
||||
console.log(
|
||||
"\n\n/////////////////////////////////////////////////\nRaw Error " +
|
||||
err +
|
||||
"\n\n/////////////////////////////////////////////////\n"
|
||||
);
|
||||
var errStr =
|
||||
"\n\n/////////////////////////////////////////////////\nServer Error " +
|
||||
"\n" +
|
||||
(_.has(err, "name") ? "Name: " + err.name + "\n" : "") +
|
||||
(_.has(err, "code") ? "Code: " + err.code + "\n" : "") +
|
||||
(_.has(err, "query") ? "Query: " + err.query + "\n" : "") +
|
||||
(_.has(err, "message") ? "Message: " + err.message + "\n" : "") +
|
||||
(_.has(err, "request.url")
|
||||
? "request.url: " + err.request.url + "\n"
|
||||
: "") +
|
||||
(_.has(err, "response.status") ? "Status: " + err.code + "\n" : "") +
|
||||
(_.has(err, "response.statusText")
|
||||
? "\nStatusText: " + err.response.status + "\n"
|
||||
: "") +
|
||||
(_.has(err, "response.request.socket.remoteAddress")
|
||||
? "\nRequest IP: " +
|
||||
err.response.request.socket.remoteAddress +
|
||||
"\n"
|
||||
: "") +
|
||||
(_.has(err, "response.data.error.message")
|
||||
? "\nMessage: " + err.response.data.error.message + "\n"
|
||||
: "") +
|
||||
(_.has(err, "response.config.url")
|
||||
? "\nRequest URL: " + err.config.url + "\n"
|
||||
: "") +
|
||||
(_.has(err, "response.headers.date")
|
||||
? "\nRequest Time: " + err.response.headers.date + "\n"
|
||||
: "") +
|
||||
(_.has(err, "config.url")
|
||||
? "\nAxios config url: " + err.config.url + "\n"
|
||||
: "") +
|
||||
(_.has(err, "config.url")
|
||||
? "\nAxios message url: " + err.message + "\n"
|
||||
: "") +
|
||||
(_.has(err, "config.data")
|
||||
? "\nRequest payload: " + err.config.data + "\n"
|
||||
: "") +
|
||||
"\n/////////////////////////////////////////////////\n";
|
||||
|
||||
console.log(errStr);
|
||||
};
|
||||
|
||||
export const conLog = (err) => {
|
||||
var errStr =
|
||||
"\n\n/////////////////////////////////////////////////\nResponse: " +
|
||||
"\n" +
|
||||
err +
|
||||
"\n/////////////////////////////////////////////////\n\n";
|
||||
|
||||
console.log(errStr);
|
||||
return errStr;
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
import axios from "axios";
|
||||
import { ACCESS_TOKEN_ENDPOINT, TENANT_ID } from "./env";
|
||||
import { consoleLogger } from "./logger";
|
||||
|
||||
const cache = {};
|
||||
|
||||
const tokenBody =
|
||||
"grant_type=" +
|
||||
process.env.GRANT_TYPE +
|
||||
"&client_id=" +
|
||||
process.env.CLIENT_ID +
|
||||
"&client_secret=" +
|
||||
process.env.CLIENT_SECRET +
|
||||
"&scope=" +
|
||||
"https://" +
|
||||
process.env.RELAYURI +
|
||||
"/.default";
|
||||
|
||||
const tokenConfig = {
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Cache-Control": "no-cache"
|
||||
}
|
||||
};
|
||||
|
||||
export const getToken = () => {
|
||||
return axios
|
||||
.post(
|
||||
`${ACCESS_TOKEN_ENDPOINT}${TENANT_ID}/oauth2/v2.0/token`,
|
||||
tokenBody,
|
||||
tokenConfig
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.then((data) => {
|
||||
cache.tokenResponse = data;
|
||||
return data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
return error;
|
||||
});
|
||||
};
|
||||
+6
-2321
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
getPersonalAccount,
|
||||
getLogin,
|
||||
updatePassword,
|
||||
updateAccount,
|
||||
createAccount,
|
||||
getEmailAccountCheck,
|
||||
getPortalLogin,
|
||||
getPortalLoginProxy,
|
||||
getPreferredLanguage
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export {
|
||||
getPersonalAccount,
|
||||
getLogin,
|
||||
updatePassword,
|
||||
updateAccount,
|
||||
createAccount,
|
||||
getEmailAccountCheck,
|
||||
getPortalLogin,
|
||||
getPortalLoginProxy,
|
||||
getPreferredLanguage
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import {
|
||||
getNewAppeals,
|
||||
getNewAppealsPage,
|
||||
getNewDocumentsPaged
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export { getNewAppeals, getNewAppealsPage, getNewDocumentsPaged };
|
||||
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
getCaseMessage,
|
||||
getIncidentbyID,
|
||||
getSIPSEvents,
|
||||
getSIPSMedia,
|
||||
getAppealID,
|
||||
createNewCase,
|
||||
createNewCaseBlob,
|
||||
updateCase,
|
||||
updateCaseBlob,
|
||||
patchCase,
|
||||
getCase,
|
||||
getCaseByID,
|
||||
getAppealPDFDocs,
|
||||
getAppealPDFDocument,
|
||||
getPartSavedAppeal,
|
||||
getIsPublishedbyID,
|
||||
getPortalModuleDetails,
|
||||
getPortalModuleDetailsProxy
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export {
|
||||
getCaseMessage,
|
||||
getIncidentbyID,
|
||||
getSIPSEvents,
|
||||
getSIPSMedia,
|
||||
getAppealID,
|
||||
createNewCase,
|
||||
createNewCaseBlob,
|
||||
updateCase,
|
||||
updateCaseBlob,
|
||||
patchCase,
|
||||
getCase,
|
||||
getCaseByID,
|
||||
getAppealPDFDocs,
|
||||
getAppealPDFDocument,
|
||||
getPartSavedAppeal,
|
||||
getIsPublishedbyID,
|
||||
getPortalModuleDetails,
|
||||
getPortalModuleDetailsProxy
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
getAwaitingSubmissionFromBlob,
|
||||
getRepsFromBlob,
|
||||
getRepsFromBlobProxy,
|
||||
getAwaitingSubmissionFromBlobProxy,
|
||||
deleteAwaitingSubmissionsFromBlob,
|
||||
deleteMyRepresentationsFromBlob,
|
||||
uploadFiles,
|
||||
uploadSingleFile,
|
||||
uploadRepFiles,
|
||||
generateRepPDF,
|
||||
generateAppealPDF,
|
||||
getFilesFromBlob,
|
||||
getFilesFromBlobproxy,
|
||||
getFilesFromBlobHashed,
|
||||
deleteBlob,
|
||||
deleteRepBlob,
|
||||
downloadBlob,
|
||||
getProgressFromBlob,
|
||||
createContainerProxy
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export {
|
||||
getAwaitingSubmissionFromBlob,
|
||||
getRepsFromBlob,
|
||||
getRepsFromBlobProxy,
|
||||
getAwaitingSubmissionFromBlobProxy,
|
||||
deleteAwaitingSubmissionsFromBlob,
|
||||
deleteMyRepresentationsFromBlob,
|
||||
uploadFiles,
|
||||
uploadSingleFile,
|
||||
uploadRepFiles,
|
||||
generateRepPDF,
|
||||
generateAppealPDF,
|
||||
getFilesFromBlob,
|
||||
getFilesFromBlobproxy,
|
||||
getFilesFromBlobHashed,
|
||||
deleteBlob,
|
||||
deleteRepBlob,
|
||||
downloadBlob,
|
||||
getProgressFromBlob,
|
||||
createContainerProxy
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
export * from "./searchService";
|
||||
export * from "./caseService";
|
||||
export * from "./accountService";
|
||||
export * from "./portalService";
|
||||
export * from "./documentService";
|
||||
export * from "./referenceDataService";
|
||||
export * from "./notifyService";
|
||||
export * from "./adminService";
|
||||
export * from "./integrationService";
|
||||
@@ -0,0 +1,3 @@
|
||||
import { createCRMTask } from "./legacyActionsService";
|
||||
|
||||
export { createCRMTask };
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
import { sendEmail } from "./legacyActionsService";
|
||||
|
||||
export { sendEmail };
|
||||
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
getMyCases,
|
||||
getMyInvolvements,
|
||||
getMyLPACases,
|
||||
getMyRepresentations,
|
||||
getMyRepresentationsProxy,
|
||||
getRepresentations,
|
||||
getRepresentationsProxy,
|
||||
getWatchedCases,
|
||||
getWatchedCasesProxy,
|
||||
getAwaitingSubmission,
|
||||
getAwaitingSubmissionProxy,
|
||||
createWatchedCases,
|
||||
deleteWatchedCases,
|
||||
deleteMyRepresentations,
|
||||
deleteAwaitingSubmissions,
|
||||
sendCaseCompleteMessage,
|
||||
sendCaseCompleteMessageProxy,
|
||||
sendRepCompleteMessage,
|
||||
setRepInvolvment,
|
||||
setCaseInvolvment
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export {
|
||||
getMyCases,
|
||||
getMyInvolvements,
|
||||
getMyLPACases,
|
||||
getMyRepresentations,
|
||||
getMyRepresentationsProxy,
|
||||
getRepresentations,
|
||||
getRepresentationsProxy,
|
||||
getWatchedCases,
|
||||
getWatchedCasesProxy,
|
||||
getAwaitingSubmission,
|
||||
getAwaitingSubmissionProxy,
|
||||
createWatchedCases,
|
||||
deleteWatchedCases,
|
||||
deleteMyRepresentations,
|
||||
deleteAwaitingSubmissions,
|
||||
sendCaseCompleteMessage,
|
||||
sendCaseCompleteMessageProxy,
|
||||
sendRepCompleteMessage,
|
||||
setRepInvolvment,
|
||||
setCaseInvolvment
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import {
|
||||
getAppealsTypes,
|
||||
getProjectTypes,
|
||||
getAppealsTypesForNewAppeal,
|
||||
getLPA,
|
||||
getFormData,
|
||||
getMandatoryFields,
|
||||
getPickLists,
|
||||
getNotice
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export {
|
||||
getAppealsTypes,
|
||||
getProjectTypes,
|
||||
getAppealsTypesForNewAppeal,
|
||||
getLPA,
|
||||
getFormData,
|
||||
getMandatoryFields,
|
||||
getPickLists,
|
||||
getNotice
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
getBasicSearch,
|
||||
getAddressSearch,
|
||||
getAddressSearchPaged,
|
||||
getBasicSearchPaged,
|
||||
getAdvancedSearch,
|
||||
getAdvancedSearchPaged,
|
||||
getBasicDNSURLSearch,
|
||||
getBasicDNSSearch,
|
||||
getBasicDNSSearchPaged,
|
||||
getDNSCoords,
|
||||
getDNSList,
|
||||
getBasicSearchDetails,
|
||||
getBasicSearchDetailsPaged,
|
||||
getBasicPartSavedDetails,
|
||||
getSearchDocumentDetails,
|
||||
getSearchDocumentTypes,
|
||||
getSearchDocumentDetailsPaged,
|
||||
getLinkedCases
|
||||
} from "./legacyActionsService";
|
||||
|
||||
export {
|
||||
getBasicSearch,
|
||||
getAddressSearch,
|
||||
getAddressSearchPaged,
|
||||
getBasicSearchPaged,
|
||||
getAdvancedSearch,
|
||||
getAdvancedSearchPaged,
|
||||
getBasicDNSURLSearch,
|
||||
getBasicDNSSearch,
|
||||
getBasicDNSSearchPaged,
|
||||
getDNSCoords,
|
||||
getDNSList,
|
||||
getBasicSearchDetails,
|
||||
getBasicSearchDetailsPaged,
|
||||
getBasicPartSavedDetails,
|
||||
getSearchDocumentDetails,
|
||||
getSearchDocumentTypes,
|
||||
getSearchDocumentDetailsPaged,
|
||||
getLinkedCases
|
||||
};
|
||||
Reference in New Issue
Block a user