fix(rectification): show the house table and hide the activity fold
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,18 @@ export type RectificationCandidate = Readonly<{
|
||||
tiedMinuteCount: number;
|
||||
}>;
|
||||
|
||||
export type RectificationHouseRow = Readonly<{
|
||||
house: number;
|
||||
sign: string;
|
||||
occupants: readonly string[];
|
||||
}>;
|
||||
|
||||
export type RectificationHouseTable = Readonly<{
|
||||
time: string;
|
||||
lagna: string;
|
||||
houses: readonly RectificationHouseRow[];
|
||||
}>;
|
||||
|
||||
export type RectificationCandidateResult = Readonly<{
|
||||
resultId: string;
|
||||
candidates: readonly RectificationCandidate[];
|
||||
@@ -15,6 +27,7 @@ export type RectificationCandidateResult = Readonly<{
|
||||
representativeTime: string | null;
|
||||
selectedTime: string | null;
|
||||
selectionKind: string | null;
|
||||
houseTable: RectificationHouseTable | null;
|
||||
}>;
|
||||
|
||||
function record(value: unknown): Record<string, unknown> | null {
|
||||
@@ -36,6 +49,43 @@ function finiteNumber(value: unknown): number | null {
|
||||
}
|
||||
|
||||
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
||||
const deniedHouseTable = /lon|latitude|longitude|degree|score|fingerprint/i;
|
||||
|
||||
export function parseRectificationHouseTable(value: unknown): RectificationHouseTable | null {
|
||||
const row = record(value);
|
||||
const tableTime = time(row?.time);
|
||||
const lagna = text(row?.lagna)?.trim() ?? "";
|
||||
if (!row || !tableTime || !lagna || !Array.isArray(row.houses) || row.houses.length !== 12) return null;
|
||||
const houses: RectificationHouseRow[] = [];
|
||||
for (let index = 0; index < 12; index += 1) {
|
||||
const house = record(row.houses[index]);
|
||||
const houseNumber = finiteNumber(house?.house);
|
||||
const sign = text(house?.sign)?.trim() ?? "";
|
||||
if (
|
||||
!house
|
||||
|| houseNumber !== index + 1
|
||||
|| !sign
|
||||
|| deniedHouseTable.test(sign)
|
||||
|| !Array.isArray(house.occupants)
|
||||
) return null;
|
||||
const occupants: string[] = [];
|
||||
for (const occupant of house.occupants) {
|
||||
const label = text(occupant)?.trim() ?? "";
|
||||
if (!label) continue;
|
||||
if (deniedHouseTable.test(label)) return null;
|
||||
occupants.push(label);
|
||||
}
|
||||
houses.push({ house: houseNumber, sign, occupants });
|
||||
}
|
||||
return { time: tableTime, lagna, houses };
|
||||
}
|
||||
|
||||
function houseTableFromSnapshot(snapshot: Record<string, unknown>): RectificationHouseTable | null {
|
||||
return parseRectificationHouseTable(snapshot.houseTable)
|
||||
?? parseRectificationHouseTable(snapshot.house_table)
|
||||
?? parseRectificationHouseTable(record(snapshot.decisionReceipt)?.house_table)
|
||||
?? parseRectificationHouseTable(record(snapshot.decision_receipt)?.house_table);
|
||||
}
|
||||
|
||||
export function parseRectificationCandidateResult(value: unknown): RectificationCandidateResult | null {
|
||||
const snapshot = record(value);
|
||||
@@ -71,6 +121,7 @@ export function parseRectificationCandidateResult(value: unknown): Rectification
|
||||
representativeTime: time(snapshot.representativeTime),
|
||||
selectedTime: time(snapshot.selectedTime),
|
||||
selectionKind: text(snapshot.selectionKind),
|
||||
houseTable: houseTableFromSnapshot(snapshot),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { PublicRectificationMethod } from "./rectification-agentic/v9/public-receipt";
|
||||
|
||||
export const PUBLIC_RECTIFICATION_METHOD_LABELS: Readonly<Record<PublicRectificationMethod, string>> = {
|
||||
"d1-rashi": "D1 本命盘",
|
||||
"d2-hora": "D2 财帛分盘",
|
||||
"d4-chaturthamsha": "D4 迁移分盘",
|
||||
"d9-navamsa": "D9 婚姻分盘",
|
||||
"d10-dashamsa": "D10 事业分盘",
|
||||
"d11-labhamsha": "D11 收益分盘",
|
||||
"d24-chaturvimshamsha": "D24 教育分盘",
|
||||
"d30-trimshamsha": "D30 健康压力分盘",
|
||||
"vimshottari-dasha": "Vimshottari",
|
||||
"narayana-dasha": "Narayana",
|
||||
gochara: "Gochara",
|
||||
ashtakavarga: "Ashtakavarga",
|
||||
shadbala: "Shadbala",
|
||||
"arudha-pada": "Arudha Pada",
|
||||
"functional-benefic-malefic": "本命功能吉凶星",
|
||||
};
|
||||
|
||||
export function vargaSentenceFromMethods(
|
||||
methods: readonly string[] | null | undefined,
|
||||
): string | null {
|
||||
const labels = [...new Set((methods ?? []).flatMap((method) => {
|
||||
const label = PUBLIC_RECTIFICATION_METHOD_LABELS[method as PublicRectificationMethod];
|
||||
return label ? [label] : [];
|
||||
}))];
|
||||
if (labels.length === 0) return null;
|
||||
return `本轮对照了${labels.join("、")}。`;
|
||||
}
|
||||
Reference in New Issue
Block a user