Files
Jyotisha/frontend/src/lib/report-subject-request.ts
T
jesse-uxandClaude Code 4d801e53c3
Independent Staging Quality Gate / validate (push) Successful in 16m28s
Independent Staging Quality Gate / publish (push) Successful in 3m33s
fix: integrate people archive, report reader and western chart corrections
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>
2026-09-25 20:41:16 +08:00

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 };
}