Merged PR 2121: missing case ref failing sip reps pdf

missing case ref failing sip reps pdf

Related work items: #21254
This commit is contained in:
Robert Bond
2026-02-20 16:17:22 +00:00
3 changed files with 81 additions and 77 deletions
+4 -3
View File
@@ -125,8 +125,8 @@ SHOWMAPS = true
API_ROOT = "http://localhost:3000"
CY_API_ROOT = "http://cymru.local:3000"
I18N_DOMAIN = "cymru.local"
DOCAPI_OFFLINE = "07:00:00,16:00:00"
# DOCAPI_OFFLINE = "01:00:00,04:00:00"
# DOCAPI_OFFLINE = "07:00:00,16:00:00"
DOCAPI_OFFLINE = "01:00:00,04:00:00"
SHOWFILTERDOCS = true
@@ -191,7 +191,8 @@ AZURE_PEDW_STORAGE_ENDPOINT = https://sapltpedwdevuks.blob.core.windows.net
// New test key
AZURE_STORAGE_ACCOUNT_NAME = "sapltpedwtestuks"
AZURE_STORAGE_ACCOUNT_KEY = 5NdDO9GGlbTFLHFOXZRw8H2C0Ow5bFTvHwUHEbStyzg2mbd1uwHSeBSvM/dkN+HfdwrFzqAkwL5P+AStdO6cig==
# AZURE_STORAGE_ACCOUNT_KEY = 5NdDO9GGlbTFLHFOXZRw8H2C0Ow5bFTvHwUHEbStyzg2mbd1uwHSeBSvM/dkN+HfdwrFzqAkwL5P+AStdO6cig==
AZURE_STORAGE_ACCOUNT_KEY = bqJAz5pYQVGee8dnVhlsqW+xHwinNTjgY2AmojNyB+d4uAotMR20WcO4Op13yB+9dFaXAkkjtIA4+AStHT/IYg==
AZURE_PEDW_STORAGE_ENDPOINT = https://sapltpedwtestuks.blob.core.windows.net
// New preprod key
+72 -69
View File
@@ -11,7 +11,7 @@ const {
ContainerSASPermissions,
generateBlobSASQueryParameters,
SASProtocol,
SASProtocol
} = require("@azure/storage-blob");
const {
QueueServiceClient,
@@ -23,7 +23,7 @@ const {
generateAccountSASQueryParameters,
generateQueueSASQueryParameters,
StorageSharedKeyCredential,
QueueClient,
QueueClient
} = require("@azure/storage-queue");
const STORAGE_PATH = process.env.AZURE_PEDW_STORAGE_ENDPOINT;
const STORAGE_CONTAINER = process.env.AZURE_PEDW_CONTAINER;
@@ -67,7 +67,7 @@ export const createContainerSas = async (containerName) => {
permissions: ContainerSASPermissions.parse(containerPermissions),
protocol: SASProtocol.HttpsAndHttp,
startsOn: TEN_MINUTES_BEFORE_NOW,
expiresOn: TEN_MINUTES_AFTER_NOW,
expiresOn: TEN_MINUTES_AFTER_NOW
};
// console.log(
@@ -126,7 +126,7 @@ export const createBlobSas = async (containerName, blobName) => {
permissions: BlobSASPermissions.parse(blobPermissionsForAnonymousUser),
protocol: SASProtocol.HttpsAndHttp,
startsOn: TEN_MINUTES_BEFORE_NOW,
expiresOn: TEN_MINUTES_AFTER_NOW,
expiresOn: TEN_MINUTES_AFTER_NOW
};
const sasToken = generateBlobSASQueryParameters(
@@ -187,7 +187,7 @@ export const getBlobs = async (containerName, casefolderID) => {
const blobObj = [];
for await (const blob of containerClient.listBlobsFlat({
prefix: casefolderID + "/files/",
prefix: casefolderID + "/files/"
})) {
let blobDocumentType = blob.name
.split("/")[2]
@@ -241,7 +241,7 @@ export const getBlobs = async (containerName, casefolderID) => {
containerName +
"&casefolderID=" +
casefolderID
),
)
});
}
//console.log("blobObj:", blobObj);
@@ -277,7 +277,7 @@ export const createBlob = async (formContent, containerName, caseref) => {
const tags = {
containerid: containerName,
caseID: caseID,
blobType: "Appeal",
blobType: "Appeal"
};
//console.log("the tags:", tags);
@@ -310,7 +310,7 @@ export const createRepBlob = async (formContent, containerName, caseref) => {
const tags = {
containerid: containerName,
caseID: formContent.ticketnumber || formContent.caseRef,
blobType: "Representation",
blobType: "Representation"
};
//console.log("the tags:", tags);
@@ -356,7 +356,7 @@ export const createAppealPDFBlob = async (
const uploadOptions = {
blockSize: 4 * 1024 * 1024, // 4 MiB max block size
concurrency: 2, // maximum number of parallel transfer workers
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
maxSingleShotSize: 8 * 1024 * 1024 // 8 MiB initial transfer size
};
console.log("blobName:", blobName);
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
@@ -371,7 +371,7 @@ export const createAppealPDFBlob = async (
caseID: caseID,
blobType: "Appeal PDF",
ishareLocation: whichLocation,
documentLocationId: whichLocation,
documentLocationId: whichLocation
};
//console.log("the tags:", tags);
@@ -405,7 +405,7 @@ export const createRepPDFBlob = async (
const uploadOptions = {
blockSize: 4 * 1024 * 1024, // 4 MiB max block size
concurrency: 2, // maximum number of parallel transfer workers
maxSingleShotSize: 8 * 1024 * 1024, // 8 MiB initial transfer size
maxSingleShotSize: 8 * 1024 * 1024 // 8 MiB initial transfer size
};
console.log("blobName:", blobName);
@@ -417,23 +417,23 @@ export const createRepPDFBlob = async (
repName.indexOf("_IP_") > 0
? "846040005"
: repName.indexOf("_Statement_") > 0
? "846040002"
: repName.indexOf("_Questionnaire_") > 0
? "846040001"
: repName.indexOf("_Comments") > 0
? "846040003"
: repName.indexOf("_Impact") > 0
? "846040029"
: repName.indexOf("_Consultation_Response_") > 0
? "846040036"
: "846040002";
? "846040002"
: repName.indexOf("_Questionnaire_") > 0
? "846040001"
: repName.indexOf("_Comments") > 0
? "846040003"
: repName.indexOf("_Impact") > 0
? "846040029"
: repName.indexOf("_Consultation_Response_") > 0
? "846040036"
: "846040002";
const tags = {
containerid: containerName,
caseID: caseID,
blobType: "Representation PDF",
ishareLocation: whichLocation,
documentLocationId: whichLocation,
documentLocationId: whichLocation
};
//console.log("the tags:", tags);
@@ -447,7 +447,7 @@ export const deleteBlob = async (containerName, blobName) => {
const creds = new DefaultAzureCredential();
const options = {
deleteSnapshots: "include", // or 'only'
deleteSnapshots: "include" // or 'only'
};
const containerToken = await createContainerSas(containerName);
@@ -467,7 +467,7 @@ export const deleteBlobCase = async (containerName, blobName) => {
const creds = new DefaultAzureCredential();
const options = {
deleteSnapshots: "include", // or 'only'
deleteSnapshots: "include" // or 'only'
};
const containerToken = await createContainerSas(containerName);
@@ -479,7 +479,7 @@ export const deleteBlobCase = async (containerName, blobName) => {
console.log("blob to delete:", blobName);
for await (const blob of containerClient.listBlobsFlat({
prefix: blobName,
prefix: blobName
})) {
console.log(" ------ :", blob.name);
containerClient.deleteBlob(blob.name);
@@ -497,7 +497,7 @@ export const deleteBlobRep = async (containerName, blobName) => {
const creds = new DefaultAzureCredential();
const options = {
deleteSnapshots: "include", // or 'only'
deleteSnapshots: "include" // or 'only'
};
const containerToken = await createContainerSas(containerName);
@@ -507,7 +507,7 @@ export const deleteBlobRep = async (containerName, blobName) => {
console.log("blob to delete:", blobName);
for await (const blob of containerClient.listBlobsFlat({
prefix: blobName,
prefix: blobName
})) {
console.log("------ :", blob.name);
const blockBlobClient = containerClient.getBlockBlobClient(blob.name);
@@ -602,21 +602,24 @@ export const uploadFile = async (formContent, containerName, foldername) => {
)
? "846040000"
: files[prop][0].fieldName.indexOf("_IP_") > 0
? "846040005"
: files[prop][0].fieldName.indexOf("_Statement_") > 0
? "846040002"
: files[prop][0].fieldName.indexOf("_Questionnaire_") >
0
? "846040001"
: files[prop][0].fieldName.indexOf("_Comments_") > 0
? "846040003"
: files[prop][0].fieldName.indexOf("_Impact_") > 0
? "846040001"
: files[prop][0].fieldName.indexOf(
"_Consultation_Response_"
) > 0
? "846040036"
: "846040000";
? "846040005"
: files[prop][0].fieldName.indexOf("_Statement_") > 0
? "846040002"
: files[prop][0].fieldName.indexOf(
"_Questionnaire_"
) > 0
? "846040001"
: files[prop][0].fieldName.indexOf("_Comments_") >
0
? "846040003"
: files[prop][0].fieldName.indexOf("_Impact_") >
0
? "846040001"
: files[prop][0].fieldName.indexOf(
"_Consultation_Response_"
) > 0
? "846040036"
: "846040000";
const tags = {
containerid: containerName,
@@ -624,7 +627,7 @@ export const uploadFile = async (formContent, containerName, foldername) => {
documentType: files[prop][0].fieldName.split(".")[1],
blobType: "RepresentationFile",
ishareLocation: whichLocation,
documentLocationId: whichLocation,
documentLocationId: whichLocation
};
const withTags = blockBlobClient.setTags(tags);
const withMeta = blockBlobClient.setMetadata(tags);
@@ -735,14 +738,14 @@ export const uploadSingleFile = async (
{
pattern:
/_Statement_of_Case|_-_Statement_of_Case|_-_Application_Form|_-_Site_Ownership_Certificate|_-_Decision_Notice|_-_Site_Location_Plan|_-_Plans_Drawing_Documents|_-_Additional_Plans_Drawings_Documents|_-_Design_and_Access_Statement|_-_NSB_LPA_Additional_Documents|_-_LPA_Correspondence|_-_LPA_Original_Permission|_-_LPA's_Registration_Letter|_-_Environmental_Statement|_-_Cost_of_Application|_-_Other_Relevant_Material|_-_S106_Agreement_or_Unilateral_Undertaking/,
value: "846040000",
value: "846040000"
},
{ pattern: /_IP_/, value: "846040005" },
{ pattern: /_Statement_/, value: "846040002" },
{ pattern: /_Questionnaire_/, value: "846040001" },
{ pattern: /_Comments_/, value: "846040003" },
{ pattern: /_Impact_/, value: "846040001" },
{ pattern: /_Consultation_Response_/, value: "846040036" },
{ pattern: /_Consultation_Response_/, value: "846040036" }
];
// Find a matching pattern or fallback to default
@@ -763,7 +766,7 @@ export const uploadSingleFile = async (
documentType: files[prop][0].fieldName.split(".")[1],
blobType: "RepresentationFile",
ishareLocation: whichLocation,
documentLocationId: whichLocation,
documentLocationId: whichLocation
};
const withTags = await blockBlobClient.setTags(tags);
const withMeta = await blockBlobClient.setMetadata(tags);
@@ -800,7 +803,7 @@ export const uploadRepFiles = async (
const tags = {
containerid: containerName,
caseID: formContent.split("tmp/")[0],
documentType: "Rep docs",
documentType: "Rep docs"
};
console.log(tags);
const withTags = await blockBlobClient.setTags(tags);
@@ -845,7 +848,7 @@ export const uploadPDFRepFiles = async (
containerid: containerName,
caseID: foldername.split("/")[0],
documentType: repType,
blobType: "RepresentationPDF",
blobType: "RepresentationPDF"
};
//console.log("the tags:", tags);
@@ -898,7 +901,7 @@ export const uploadPDFAppealFiles = async (
const tags = {
containerid: containerName,
caseID: foldername.split("/")[0],
blobType: "AppealPDF",
blobType: "AppealPDF"
};
//console.log("the tags:", tags);
@@ -937,7 +940,7 @@ export const uploadPDFCaseFiles = async (
const tags = {
containerid: containerName,
caseID: foldername.split("/")[0],
blobType: "AppealPDF",
blobType: "AppealPDF"
};
//console.log("the tags:", tags);
@@ -1143,7 +1146,7 @@ export const downloadAllRepsFiles = async (containerName, repsBlobObj) => {
return {
"@odata.count": blobCount,
"value": downloaded,
"value": downloaded
};
};
@@ -1182,7 +1185,7 @@ export const getCaseBlob = async (
const tags = {
containerid: containerName,
caseID: caseReference,
blobType: "Case",
blobType: "Case"
};
//console.log("the tags:", tags);
@@ -1213,7 +1216,7 @@ export const getProgressBlobs = async (containerName, caseReference) => {
let blobCount = 0;
for await (const blob of containerClient.listBlobsFlat({
prefix: caseReference,
prefix: caseReference
})) {
blobCount++;
}
@@ -1226,7 +1229,7 @@ export const getProgressBlobs = async (containerName, caseReference) => {
let blobObj = [];
for await (const blob of containerClient.listBlobsFlat({
prefix: caseReference + "/" + caseReference + "_appeal.json",
prefix: caseReference + "/" + caseReference + "_appeal.json"
})) {
console.log("getProgressBlobs in here", blob.name.split("/"));
blobObj.push({
@@ -1259,14 +1262,14 @@ export const getProgressBlobs = async (containerName, caseReference) => {
containerName +
"&casefolderID=" +
caseReference
),
)
});
}
blobObj = _.sortBy(blobObj, [
function (o) {
return o.lastModified;
},
}
]).reverse()[0];
return blobObj;
@@ -1295,7 +1298,7 @@ export const getAllProgressBlobs = async (containerName) => {
blob.name.split("/")[0] +
"/" +
blob.name.split("/")[0] +
"_case.json",
"_case.json"
// "isCurrentVersion": blob.isCurrentVersion,
// "contentLength": blob.properties.contentLength,
// "contentType": blob.contentType,
@@ -1352,7 +1355,7 @@ export const getRepsBlobs = async (containerName) => {
includeMetadata: true,
includeSnapshots: false,
includeTags: true,
includeVersions: true,
includeVersions: true
};
let blobObj = [];
@@ -1367,7 +1370,7 @@ export const getRepsBlobs = async (containerName) => {
blobObj.push({
"name": blob.name.split("/")[2],
"path": blob.name,
"size": blobClient.getProperties().contentLength,
"size": blobClient.getProperties().contentLength
});
}
@@ -1391,7 +1394,7 @@ export const getRepsFilesBlobs = async (
const blobObj = [];
for await (const blob of containerClient.listBlobsFlat({
prefix: casefolderID + "/" + filenamePrefix + "/files/",
prefix: casefolderID + "/" + filenamePrefix + "/files/"
})) {
let blobDocumentType = blob.name
.split("/")[2]
@@ -1454,7 +1457,7 @@ export const getRepsFilesBlobs = async (
blob.name.split("/")[0] +
"/" +
blob.name.split("/")[1]
),
)
});
}
console.log("blobObj:", blobObj);
@@ -1497,7 +1500,7 @@ export const createQueueSas = async (queueName) => {
var sas_signature_val = {
expiresOn: TEN_MINUTES_AFTER_NOW,
permissions: permission,
queueName: queueName,
queueName: queueName
};
const sasToken = generateQueueSASQueryParameters(
@@ -1541,7 +1544,7 @@ export const createCaseCompleteMessage = async (
caseReference +
"_case.json",
filespath:
endpointURL + "/" + containerName + "/" + caseReference + "/files",
endpointURL + "/" + containerName + "/" + caseReference + "/files"
// uploadUrl: fileRecord.uploadUrl,
// filename: fileRecord.file.name,
@@ -1602,7 +1605,7 @@ export const createRepCompleteMessage = async (
caseReference +
"/" +
filename +
"/files",
"/files"
};
console.log("======================", message, "=====================");
@@ -1628,7 +1631,7 @@ export const listContainers = async (
includeDeleted: false,
includeMetadata: true,
includeSystem: true,
prefix: containerNamePrefix,
prefix: containerNamePrefix
};
console.log(
"\n\n\n=================================================\n",
@@ -1671,7 +1674,7 @@ export const listBlobHierarchical = async (
includeTags: true, // include indexable tags
includeUncommitedBlobs: false, // include uncommitted blobs
includeVersions: false, // include all blob version
prefix: "", // filter by blob name prefix
prefix: "" // filter by blob name prefix
};
let i = 1;
@@ -1757,7 +1760,7 @@ export async function listBlobHierarchicalForUser(containerClient) {
? lastModifiedDate.toISOString()
: null,
createdOn: createdOnDate ? createdOnDate.toISOString() : null,
displayDate,
displayDate
});
}
return blobNames;
@@ -1772,7 +1775,7 @@ export async function listContainersForUser(
includeDeleted: false,
includeMetadata: true,
includeSystem: true,
prefix: containerNamePrefix,
prefix: containerNamePrefix
};
const results = [];
@@ -1790,7 +1793,7 @@ export async function listContainersForUser(
if (blobNames && blobNames.length > 0) {
results.push({
container: containerItem.name,
blobs: blobNames,
blobs: blobNames
});
}
}
+5 -5
View File
@@ -79,7 +79,7 @@ import {
createRepBlob,
uploadFile,
uploadPDFRepFiles,
createRepPDFBlob,
createRepPDFBlob
} from "../../../actions/azurestorage";
import { hashAPIPath } from "../../../actions";
@@ -89,7 +89,7 @@ import ReactPDF, {
Text,
View,
StyleSheet,
PDFViewer,
PDFViewer
} from "@react-pdf/renderer";
import middleware from "../middleware/middleware";
import nextConnect from "next-connect";
@@ -143,7 +143,7 @@ export default async function handler(req, res) {
newblobList = removeNullObjects(newblobList);
Object.assign(blobList, {
"filesList": newblobList,
"filesList": newblobList
});
return blobList;
@@ -166,7 +166,7 @@ export default async function handler(req, res) {
var containerID = reqBodyobj.containerID;
var casefolderID = reqBodyobj.casefolderID;
var caseRef = reqBodyobj.ticketnumber;
var caseRef = reqBodyobj.ticketnumber || reqBodyobj.caseRef;
var representationType = reqBodyobj.representationType;
var repRaiser = reqBodyobj.lastname;
var localeSelect = reqBodyobj.locale;
@@ -315,7 +315,7 @@ export default async function handler(req, res) {
return res.status(200).json({
status: "success",
data: data,
path: `${caseRef}/${reqBodyobj.repfile_name}/files/${reqBodyobj.repfile_name}.pdf`,
path: `${caseRef}/${reqBodyobj.repfile_name}/files/${reqBodyobj.repfile_name}.pdf`
});
})
.catch((error) => {