TASK22269: normalize azurestorage hash query path builders
This commit is contained in:
+97
-53
@@ -31,6 +31,59 @@ const QUEUE_PATH = process.env.AZURE_PEDW_QUEUE_ENDPOINT;
|
|||||||
|
|
||||||
const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
||||||
|
|
||||||
|
const buildDownloadBlobQueryPath = ({
|
||||||
|
containerName,
|
||||||
|
casefolderID,
|
||||||
|
blobname,
|
||||||
|
encodeCasefolderID = true,
|
||||||
|
encodeBlobname = true
|
||||||
|
}) => {
|
||||||
|
const casefolderPart = encodeCasefolderID
|
||||||
|
? encodeURIComponent(casefolderID)
|
||||||
|
: casefolderID;
|
||||||
|
const blobPart = encodeBlobname ? encodeURIComponent(blobname) : blobname;
|
||||||
|
|
||||||
|
return (
|
||||||
|
"/api/file/downloadblob?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderPart +
|
||||||
|
"&blobname=" +
|
||||||
|
blobPart
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildDeleteBlobQueryPath = ({
|
||||||
|
containerName,
|
||||||
|
casefolderID,
|
||||||
|
blobname,
|
||||||
|
encodeCasefolderID = true,
|
||||||
|
encodeBlobname = true
|
||||||
|
}) => {
|
||||||
|
const casefolderPart = encodeCasefolderID
|
||||||
|
? encodeURIComponent(casefolderID)
|
||||||
|
: casefolderID;
|
||||||
|
const blobPart = encodeBlobname ? encodeURIComponent(blobname) : blobname;
|
||||||
|
|
||||||
|
return (
|
||||||
|
"/api/file/deleteblob?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderPart +
|
||||||
|
"&blobname=" +
|
||||||
|
blobPart
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildGetBlobListQueryPath = ({ containerName, casefolderID }) => {
|
||||||
|
return (
|
||||||
|
"/api/file/getbloblist?container=" +
|
||||||
|
containerName +
|
||||||
|
"&casefolderID=" +
|
||||||
|
casefolderID
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const createContainerSas = async (containerName) => {
|
export const createContainerSas = async (containerName) => {
|
||||||
// Get environment variables
|
// Get environment variables
|
||||||
|
|
||||||
@@ -214,12 +267,11 @@ export const getBlobs = async (containerName, casefolderID) => {
|
|||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
encodeURIComponent(blob.name),
|
encodeURIComponent(blob.name),
|
||||||
"hashedfilepath": hashAPIPath(
|
"hashedfilepath": hashAPIPath(
|
||||||
"/api/file/downloadblob?container=" +
|
buildDownloadBlobQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID,
|
||||||
encodeURIComponent(casefolderID) +
|
blobname: blob.name.split("/")[2]
|
||||||
"&blobname=" +
|
})
|
||||||
encodeURIComponent(blob.name.split("/")[2])
|
|
||||||
),
|
),
|
||||||
"deletepath":
|
"deletepath":
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
@@ -229,18 +281,17 @@ export const getBlobs = async (containerName, casefolderID) => {
|
|||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
encodeURIComponent(blob.name.split("/")[2]),
|
encodeURIComponent(blob.name.split("/")[2]),
|
||||||
"hasheddeletepath": hashAPIPath(
|
"hasheddeletepath": hashAPIPath(
|
||||||
"/api/file/deleteblob?container=" +
|
buildDeleteBlobQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID,
|
||||||
encodeURIComponent(casefolderID) +
|
blobname: blob.name.split("/")[2]
|
||||||
"&blobname=" +
|
})
|
||||||
encodeURIComponent(blob.name.split("/")[2])
|
|
||||||
),
|
),
|
||||||
"hashgetblobs": hashAPIPath(
|
"hashgetblobs": hashAPIPath(
|
||||||
"/api/file/getbloblist?container=" +
|
buildGetBlobListQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
|
||||||
casefolderID
|
casefolderID
|
||||||
|
})
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1246,26 +1297,24 @@ export const getProgressBlobs = async (containerName, caseReference) => {
|
|||||||
"contentType": blob.contentType,
|
"contentType": blob.contentType,
|
||||||
"lastModified": blob.properties.lastModified,
|
"lastModified": blob.properties.lastModified,
|
||||||
"hashedfilepath": hashAPIPath(
|
"hashedfilepath": hashAPIPath(
|
||||||
"/api/file/downloadblob?container=" +
|
buildDownloadBlobQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID: caseReference,
|
||||||
encodeURIComponent(caseReference) +
|
blobname: blob.name.split("/")[1]
|
||||||
"&blobname=" +
|
})
|
||||||
encodeURIComponent(blob.name.split("/")[1])
|
|
||||||
),
|
),
|
||||||
"hasheddeletepath": hashAPIPath(
|
"hasheddeletepath": hashAPIPath(
|
||||||
"/api/file/deleteblob?container=" +
|
buildDeleteBlobQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID: caseReference,
|
||||||
encodeURIComponent(caseReference) +
|
blobname: blob.name.split("/")[1]
|
||||||
"&blobname=" +
|
})
|
||||||
encodeURIComponent(blob.name.split("/")[1])
|
|
||||||
),
|
),
|
||||||
"hashgetblobs": hashAPIPath(
|
"hashgetblobs": hashAPIPath(
|
||||||
"/api/file/getbloblist?container=" +
|
buildGetBlobListQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID: caseReference
|
||||||
caseReference
|
})
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1455,14 +1504,12 @@ export const getRepsFilesBlobs = async (
|
|||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
encodeURIComponent(blob.name.split("/")[3]),
|
encodeURIComponent(blob.name.split("/")[3]),
|
||||||
"hashedfilepath": hashAPIPath(
|
"hashedfilepath": hashAPIPath(
|
||||||
"/api/file/downloadblob?container=" +
|
buildDownloadBlobQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID:
|
||||||
encodeURIComponent(
|
blob.name.split("/")[0] + "/" + blob.name.split("/")[1],
|
||||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
blobname: blob.name.split("/")[3]
|
||||||
) +
|
})
|
||||||
"&blobname=" +
|
|
||||||
encodeURIComponent(blob.name.split("/")[3])
|
|
||||||
),
|
),
|
||||||
"deletepath":
|
"deletepath":
|
||||||
"/api/file/deleteblob?container=" +
|
"/api/file/deleteblob?container=" +
|
||||||
@@ -1474,22 +1521,19 @@ export const getRepsFilesBlobs = async (
|
|||||||
"&blobname=" +
|
"&blobname=" +
|
||||||
blob.name.split("/")[3],
|
blob.name.split("/")[3],
|
||||||
"hasheddeletepath": hashAPIPath(
|
"hasheddeletepath": hashAPIPath(
|
||||||
"/api/file/deleteblob?container=" +
|
buildDeleteBlobQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID:
|
||||||
encodeURIComponent(
|
blob.name.split("/")[0] + "/" + blob.name.split("/")[1],
|
||||||
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
blobname: blob.name.split("/")[3]
|
||||||
) +
|
})
|
||||||
"&blobname=" +
|
|
||||||
encodeURIComponent(blob.name.split("/")[3])
|
|
||||||
),
|
),
|
||||||
"hashgetblobs": hashAPIPath(
|
"hashgetblobs": hashAPIPath(
|
||||||
"/api/file/getbloblist?container=" +
|
buildGetBlobListQueryPath({
|
||||||
containerName +
|
containerName,
|
||||||
"&casefolderID=" +
|
casefolderID:
|
||||||
blob.name.split("/")[0] +
|
blob.name.split("/")[0] + "/" + blob.name.split("/")[1]
|
||||||
"/" +
|
})
|
||||||
blob.name.split("/")[1]
|
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2905,3 +2905,40 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Remaining non-service candidate for this stream is `actions/azurestorage.js` direct `hashAPIPath` metadata assembly (separate bounded slice if desired).
|
- Remaining non-service candidate for this stream is `actions/azurestorage.js` direct `hashAPIPath` metadata assembly (separate bounded slice if desired).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CL-081: TASK22269 Slice B1.6 — azurestorage hash-query metadata builder normalization
|
||||||
|
|
||||||
|
date: 2026-03-25
|
||||||
|
author: Cline
|
||||||
|
scope: `actions/azurestorage.js`
|
||||||
|
type: change
|
||||||
|
rationale: Continue requested follow-on slice by reducing repeated hash-query path string composition in azure storage metadata builders behind local helper functions.
|
||||||
|
impact: Lowers duplication/drift risk in hashed metadata path generation while preserving existing route and encoding behavior.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Added internal helper builders in `actions/azurestorage.js`:
|
||||||
|
- `buildDownloadBlobQueryPath(...)`
|
||||||
|
- `buildDeleteBlobQueryPath(...)`
|
||||||
|
- `buildGetBlobListQueryPath(...)`
|
||||||
|
- Replaced repeated inline hash path literals with helper usage in targeted metadata object builders:
|
||||||
|
- `getBlobs`
|
||||||
|
- `getProgressBlobs`
|
||||||
|
- `getRepsFilesBlobs`
|
||||||
|
- Preserved existing behavior semantics for hash path construction:
|
||||||
|
- encoded `casefolderID`/`blobname` where previously encoded
|
||||||
|
- unchanged `containerName` and `casefolderID` value sourcing
|
||||||
|
- unchanged returned object field names and shape
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
|
||||||
|
- `npm run lint` -> pass with warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
|
||||||
|
- `node tests/phase22/index.test.cjs` -> pass
|
||||||
|
- `node tests/phase7/service-behaviour.test.cjs` -> pass (13/13)
|
||||||
|
|
||||||
|
Follow-ups:
|
||||||
|
|
||||||
|
- Remaining potential cleanups in `actions/azurestorage.js` are broader non-slice refactors (legacy logging verbosity, large function decomposition) and should be handled separately to keep risk bounded.
|
||||||
|
|||||||
Reference in New Issue
Block a user