TASK22269: normalize document hash-suffix route composition
This commit is contained in:
@@ -31,3 +31,7 @@ export const withBaseUrl = (baseUrl, route) => {
|
|||||||
export const appendQuerySuffix = (route, suffix = "") => {
|
export const appendQuerySuffix = (route, suffix = "") => {
|
||||||
return `${route}${suffix}`;
|
return `${route}${suffix}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const appendHashSuffix = (route, hashBuilder) => {
|
||||||
|
return appendQuerySuffix(route, hashBuilder(route));
|
||||||
|
};
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { hashAPIPath } from "../core/hash";
|
|||||||
import {
|
import {
|
||||||
buildFileQuery,
|
buildFileQuery,
|
||||||
withBaseUrl,
|
withBaseUrl,
|
||||||
appendQuerySuffix
|
appendQuerySuffix,
|
||||||
|
appendHashSuffix
|
||||||
} from "../clients/fileRouteBuilder";
|
} from "../clients/fileRouteBuilder";
|
||||||
import {
|
import {
|
||||||
getFileJson,
|
getFileJson,
|
||||||
@@ -19,7 +20,7 @@ export const getAwaitingSubmissionFromBlob = (containerName) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return getFileJson(
|
return getFileJson(
|
||||||
withBaseUrl(BASE_URL, appendQuerySuffix(route, hashAPIPath(route)))
|
withBaseUrl(BASE_URL, appendHashSuffix(route, hashAPIPath))
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
@@ -31,7 +32,7 @@ export const getRepsFromBlob = (containerName) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return getFileJson(
|
return getFileJson(
|
||||||
withBaseUrl(BASE_URL, appendQuerySuffix(route, hashAPIPath(route)))
|
withBaseUrl(BASE_URL, appendHashSuffix(route, hashAPIPath))
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
@@ -227,7 +228,7 @@ export const getFilesFromBlob = (containerName, casefolderID) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return getFileJson(
|
return getFileJson(
|
||||||
withBaseUrl(BASE_URL, appendQuerySuffix(route, hashAPIPath(route)))
|
withBaseUrl(BASE_URL, appendHashSuffix(route, hashAPIPath))
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
@@ -328,7 +329,7 @@ export const getProgressFromBlob = async (containerName, casereference) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return getFileJson(
|
return getFileJson(
|
||||||
withBaseUrl(BASE_URL, appendQuerySuffix(route, hashAPIPath(route)))
|
withBaseUrl(BASE_URL, appendHashSuffix(route, hashAPIPath))
|
||||||
).catch((error) => {
|
).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
});
|
});
|
||||||
@@ -338,7 +339,7 @@ export const createContainerProxy = (containerName) => {
|
|||||||
var route = buildFileQuery("/api/file/setupcontainer", {
|
var route = buildFileQuery("/api/file/setupcontainer", {
|
||||||
ident: containerName
|
ident: containerName
|
||||||
});
|
});
|
||||||
var queryUrl = appendQuerySuffix(route, hashAPIPath(route));
|
var queryUrl = appendHashSuffix(route, hashAPIPath);
|
||||||
|
|
||||||
return getFileJson(withBaseUrl(BASE_URL, queryUrl)).catch((error) => {
|
return getFileJson(withBaseUrl(BASE_URL, queryUrl)).catch((error) => {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
|
|||||||
@@ -2871,3 +2871,37 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Remaining special-case signed pattern is now primarily the signed-suffix append composition in `sendCaseCompleteMessage` (already using shared `buildSignedUrl`), with broader module migrations to be planned in future bounded slices.
|
- Remaining special-case signed pattern is now primarily the signed-suffix append composition in `sendCaseCompleteMessage` (already using shared `buildSignedUrl`), with broader module migrations to be planned in future bounded slices.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### CL-080: TASK22269 Slice B1.5 — document hash-suffix route normalization helper
|
||||||
|
|
||||||
|
date: 2026-03-25
|
||||||
|
author: Cline
|
||||||
|
scope: `actions/clients/fileRouteBuilder.js`, `actions/services/documentDirectService.js`, `tests/{serviceHarness,phase22/client-utils-behaviour}.cjs`
|
||||||
|
type: change
|
||||||
|
rationale: Continue grouped follow-on candidates by normalizing repeated deterministic hash-suffix route assembly in document service behind one shared route-builder helper.
|
||||||
|
impact: Reduces repeated `appendQuerySuffix(route, hashAPIPath(route))` composition drift risk while preserving route/query/hash behavior.
|
||||||
|
status: completed
|
||||||
|
|
||||||
|
Summary:
|
||||||
|
|
||||||
|
- Added `appendHashSuffix(route, hashBuilder)` to `fileRouteBuilder`.
|
||||||
|
- Migrated document service deterministic hash-suffix paths to new helper:
|
||||||
|
- `getAwaitingSubmissionFromBlob`
|
||||||
|
- `getRepsFromBlob`
|
||||||
|
- `getFilesFromBlob`
|
||||||
|
- `getProgressFromBlob`
|
||||||
|
- `createContainerProxy`
|
||||||
|
- Updated shared VM harness defaults (`tests/serviceHarness.cjs`) to inject `appendHashSuffix`.
|
||||||
|
- Expanded phase22 utility test to cover new helper behavior (`tests/phase22/client-utils-behaviour.test.cjs`).
|
||||||
|
|
||||||
|
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 non-service candidate for this stream is `actions/azurestorage.js` direct `hashAPIPath` metadata assembly (separate bounded slice if desired).
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ const loadFileRouteBuilderModule = (injected = {}) => {
|
|||||||
source = source.replace(/import[\s\S]*?from\s+"[^"]+";\n?/g, "");
|
source = source.replace(/import[\s\S]*?from\s+"[^"]+";\n?/g, "");
|
||||||
source = source.replace(/export const\s+/g, "const ");
|
source = source.replace(/export const\s+/g, "const ");
|
||||||
source +=
|
source +=
|
||||||
"\nmodule.exports = { buildFileQuery, withBaseUrl, appendQuerySuffix };\n";
|
"\nmodule.exports = { buildFileQuery, withBaseUrl, appendQuerySuffix, appendHashSuffix };\n";
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
module: { exports: {} },
|
module: { exports: {} },
|
||||||
@@ -211,6 +211,12 @@ test("clients/fileRouteBuilder builds query with optional encoding and suffix he
|
|||||||
mod.appendQuerySuffix(unencoded, "&hash=123"),
|
mod.appendQuerySuffix(unencoded, "&hash=123"),
|
||||||
"/api/file/getbloblist?container=abc&casefolderID=x/y&hash=123"
|
"/api/file/getbloblist?container=abc&casefolderID=x/y&hash=123"
|
||||||
);
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
mod.appendHashSuffix(unencoded, (route) =>
|
||||||
|
route.includes("getbloblist") ? "&hash=abc" : ""
|
||||||
|
),
|
||||||
|
"/api/file/getbloblist?container=abc&casefolderID=x/y&hash=abc"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
|
|||||||
@@ -200,6 +200,8 @@ const loadServiceModule = (fileName, injected = {}) => {
|
|||||||
const defaultWithBaseUrl = (baseUrl, route) => `${baseUrl}${route}`;
|
const defaultWithBaseUrl = (baseUrl, route) => `${baseUrl}${route}`;
|
||||||
const defaultAppendQuerySuffix = (route, suffix = "") =>
|
const defaultAppendQuerySuffix = (route, suffix = "") =>
|
||||||
`${route}${suffix}`;
|
`${route}${suffix}`;
|
||||||
|
const defaultAppendHashSuffix = (route, hashBuilder) =>
|
||||||
|
defaultAppendQuerySuffix(route, hashBuilder(route));
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
module: { exports: {} },
|
module: { exports: {} },
|
||||||
@@ -230,6 +232,7 @@ const loadServiceModule = (fileName, injected = {}) => {
|
|||||||
withBaseUrl: injected.withBaseUrl || defaultWithBaseUrl,
|
withBaseUrl: injected.withBaseUrl || defaultWithBaseUrl,
|
||||||
appendQuerySuffix:
|
appendQuerySuffix:
|
||||||
injected.appendQuerySuffix || defaultAppendQuerySuffix,
|
injected.appendQuerySuffix || defaultAppendQuerySuffix,
|
||||||
|
appendHashSuffix: injected.appendHashSuffix || defaultAppendHashSuffix,
|
||||||
...injected
|
...injected
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user