Files
Jyotisha/frontend/src/lib/report-theme-evidence-plan.ts
T

149 lines
4.4 KiB
TypeScript

export const REPORT_THEME_IDS = [
"career",
"marriage",
"wealth",
"education",
"migration_home",
"family",
"health_pressure",
"timing",
"general",
] as const;
export type ReportTheme = (typeof REPORT_THEME_IDS)[number];
export type ReportThemeEvidencePlan = Readonly<{
theme: ReportTheme;
section: string;
requiredTechniqueGroups: readonly Readonly<{
label: string;
anyOf: readonly string[];
}>[];
chartIds: readonly string[];
}>;
const PLAN: Readonly<Record<ReportTheme, ReportThemeEvidencePlan>> = {
general: {
theme: "general",
section: "综合基础",
requiredTechniqueGroups: [{ label: "D1", anyOf: ["D1"] }],
chartIds: ["D1"],
},
career: {
theme: "career",
section: "事业发展",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D10", anyOf: ["D10"] },
{ label: "A10", anyOf: ["A10", "Karma Pada"] },
{ label: "AmK", anyOf: ["AmK", "Amatyakaraka"] },
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
{ label: "Narayana", anyOf: ["Narayana", "narayana_dasha"] },
{ label: "Transit", anyOf: ["Transit", "Gochara"] },
],
chartIds: ["D1", "D10"],
},
marriage: {
theme: "marriage",
section: "婚恋关系",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D9", anyOf: ["D9"] },
{ label: "UL", anyOf: ["UL", "Upapada"] },
{ label: "DK", anyOf: ["DK", "Darakaraka"] },
{ label: "A7", anyOf: ["A7"] },
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
],
chartIds: ["D1", "D9"],
},
wealth: {
theme: "wealth",
section: "财富结构",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D2", anyOf: ["D2"] },
{ label: "D11", anyOf: ["D11"] },
{ label: "Yoga", anyOf: ["Yoga", "yogas"] },
{ label: "Ashtakavarga", anyOf: ["Ashtakavarga", "ashtakavarga"] },
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
],
chartIds: ["D1", "D2", "D11"],
},
education: {
theme: "education",
section: "教育学习",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D24", anyOf: ["D24"] },
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
],
chartIds: ["D1", "D24"],
},
migration_home: {
theme: "migration_home",
section: "迁移与居所",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D4", anyOf: ["D4"] },
{ label: "D12", anyOf: ["D12"] },
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
],
chartIds: ["D1", "D4", "D12"],
},
family: {
theme: "family",
section: "家庭与子女",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D7/D12", anyOf: ["D7", "D12"] },
],
chartIds: ["D1", "D7", "D12"],
},
health_pressure: {
theme: "health_pressure",
section: "健康压力(非医疗)",
requiredTechniqueGroups: [
{ label: "D1", anyOf: ["D1"] },
{ label: "D6", anyOf: ["D6"] },
{ label: "D8", anyOf: ["D8"] },
{ label: "D30", anyOf: ["D30"] },
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
],
chartIds: ["D1", "D6", "D8", "D30"],
},
timing: {
theme: "timing",
section: "阶段与时机",
requiredTechniqueGroups: [
{ label: "Vimshottari", anyOf: ["Vimshottari", "dasha_boundaries"] },
{ label: "Narayana", anyOf: ["Narayana", "narayana_dasha"] },
{ label: "Transit", anyOf: ["Transit", "Gochara"] },
],
chartIds: ["D1"],
},
};
const THEME_ALIASES: Readonly<Record<string, ReportTheme>> = {
career: "career",
marriage: "marriage",
wealth: "wealth",
education: "education",
migration: "migration_home",
home: "migration_home",
migration_home: "migration_home",
family: "family",
health: "health_pressure",
health_pressure: "health_pressure",
timing: "timing",
general: "general",
};
export function normalizeReportTheme(theme: string): ReportTheme {
return THEME_ALIASES[theme.trim().toLowerCase()] ?? "general";
}
export function buildReportThemePlan(themes: readonly string[]): readonly ReportThemeEvidencePlan[] {
const normalized = [...new Set(themes.map(normalizeReportTheme))].sort();
return normalized.map((theme) => PLAN[theme]);
}