Validate on Linux Node 22 and PostgreSQL 17: 3894 frontend tests and 64 database tests pass, with no removed test names or new failures. Preserve static Home, bounded gzip, assertion-change records and manual acceptance gaps. Co-Authored-By: Claude Code <noreply@anthropic.com>
19 lines
782 B
TypeScript
19 lines
782 B
TypeScript
import { subjectIdFromQuery } from "./subject-birth.ts";
|
|
|
|
export function normalizeReportSubjectRequest(rawBody: unknown): {
|
|
subjectId: string;
|
|
body: unknown;
|
|
mismatch: boolean;
|
|
} {
|
|
if (!rawBody || typeof rawBody !== "object" || Array.isArray(rawBody)) {
|
|
return { subjectId: "self", body: rawBody, mismatch: false };
|
|
}
|
|
const body = { ...rawBody } as Record<string, unknown>;
|
|
const mismatch = "subjectId" in body && "chartProfileId" in body
|
|
&& subjectIdFromQuery(body.subjectId) !== subjectIdFromQuery(body.chartProfileId);
|
|
const subjectId = subjectIdFromQuery("chartProfileId" in body ? body.chartProfileId : body.subjectId);
|
|
delete body.subjectId;
|
|
body.chartProfileId = subjectId === "self" ? null : subjectId;
|
|
return { subjectId, body, mismatch };
|
|
}
|