Yearly forecast: solar return, transits, progressions, profection, eclipses
- astro-engine: forecast module (solar return moment, slow-planet transits
with exact dates and periods, natal house ingresses, secondary
progressions, annual profection, eclipses via Swiss Ephemeris)
- horoscope-api: POST /v1/forecast, solar return chart cast for the place
of the birthday
- backend: forecasts table, /v1/charts/{id}/forecasts, /v1/forecasts/{id}
and its analyses using a new 'forecast' unit; current year of life open,
the next one 30 days before the birthday
- packages: Páros and Család include forecasts (6 000 / 11 000 Ft),
+1 éves előrejelzés add-on 2 500 Ft; Egy elemzés unchanged
- worker and prompt: forecast kind with five sections and forecast rules
(trends, no event predictions); no birth data, place or exact age sent
- frontend: /kepletek/{id}/elorejelzes with the solar return wheel, the
keys of the year, a monthly timeline, transit list and detailed forecast
- data export: forecasts added, model name removed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
import { ASPECTS, MOON_PHASES, POINTS, dms, orbText, pointName, signName } from "@/lib/astro";
|
||||
import type { Forecast, ForecastContact, SolarReturn } from "@/lib/types";
|
||||
|
||||
/** Sign names with the "into" suffix: Kos → Kosba. */
|
||||
const SIGN_INTO: Record<string, string> = {
|
||||
aries: "Kosba",
|
||||
taurus: "Bikába",
|
||||
gemini: "Ikrekbe",
|
||||
cancer: "Rákba",
|
||||
leo: "Oroszlánba",
|
||||
virgo: "Szűzbe",
|
||||
libra: "Mérlegbe",
|
||||
scorpio: "Skorpióba",
|
||||
sagittarius: "Nyilasba",
|
||||
capricorn: "Bakba",
|
||||
aquarius: "Vízöntőbe",
|
||||
pisces: "Halakba",
|
||||
};
|
||||
|
||||
const ECLIPSE_TYPES: Record<string, string> = {
|
||||
total: "Teljes",
|
||||
annular: "Gyűrűs",
|
||||
hybrid: "Hibrid",
|
||||
partial: "Részleges",
|
||||
penumbral: "Félárnyékos",
|
||||
};
|
||||
|
||||
const utcDate = (iso: string) => {
|
||||
const [y, m, d] = iso.split("-").map(Number);
|
||||
return new Date(Date.UTC(y, m - 1, d));
|
||||
};
|
||||
|
||||
/** `2026-08-20` → `aug. 20.` */
|
||||
export function shortDay(iso: string): string {
|
||||
return new Intl.DateTimeFormat("hu-HU", { month: "short", day: "numeric", timeZone: "UTC" }).format(utcDate(iso));
|
||||
}
|
||||
|
||||
/** `2026-08-20` → `2026. aug. 20.` */
|
||||
export function longDay(iso: string): string {
|
||||
return new Intl.DateTimeFormat("hu-HU", { year: "numeric", month: "short", day: "numeric", timeZone: "UTC" }).format(
|
||||
utcDate(iso),
|
||||
);
|
||||
}
|
||||
|
||||
function monthTitle(key: string): string {
|
||||
return new Intl.DateTimeFormat("hu-HU", { year: "numeric", month: "long", timeZone: "UTC" }).format(
|
||||
utcDate(`${key}-01`),
|
||||
);
|
||||
}
|
||||
|
||||
const glyph = (id: string) => POINTS[id]?.glyph ?? "";
|
||||
|
||||
type Tone = "tense" | "harmonic" | "neutral";
|
||||
|
||||
const toneOf = (c: ForecastContact): Tone =>
|
||||
c.nature === "challenging" ? "tense" : c.nature === "harmonious" ? "harmonic" : "neutral";
|
||||
|
||||
function contactTitle(c: ForecastContact, progressed = false): string {
|
||||
const planet = progressed ? `Progresszív ${pointName(c.planet)}` : pointName(c.planet);
|
||||
return `${planet} ${ASPECTS[c.aspect]?.hu ?? c.aspect} – születési ${pointName(c.natal_point)}`;
|
||||
}
|
||||
|
||||
function periodText(c: ForecastContact, date?: string): string | null {
|
||||
const periods = c.periods ?? [];
|
||||
const p = (date && periods.find((x) => x.start <= date && date <= x.end)) || periods[0];
|
||||
if (!p) return null;
|
||||
return p.start === p.end ? `hatás: ${longDay(p.start)}` : `hatás: ${longDay(p.start)} – ${longDay(p.end)}`;
|
||||
}
|
||||
|
||||
interface Event {
|
||||
date: string;
|
||||
tone: Tone;
|
||||
label: string;
|
||||
title: string;
|
||||
detail: string[];
|
||||
}
|
||||
|
||||
/** Everything datable in the year, in time order. */
|
||||
function events(f: Forecast): Event[] {
|
||||
const out: Event[] = [];
|
||||
const inYear = (d: string) => d >= f.start && d <= f.end;
|
||||
for (const c of f.transits) {
|
||||
const glyphs = `${glyph(c.planet)} ${ASPECTS[c.aspect]?.glyph ?? ""} ${glyph(c.natal_point)}`;
|
||||
if (c.exact.length === 0) {
|
||||
out.push({
|
||||
date: c.peak,
|
||||
tone: toneOf(c),
|
||||
label: glyphs,
|
||||
title: contactTitle(c),
|
||||
detail: [`legközelebb ${orbText(c.min_orb)}`, periodText(c, c.peak) ?? ""].filter(Boolean),
|
||||
});
|
||||
}
|
||||
c.exact.forEach((e, i) => {
|
||||
const pass = c.exact.length > 1 ? `${i + 1}. pontos fényszög` : "pontos";
|
||||
out.push({
|
||||
date: e.date,
|
||||
tone: toneOf(c),
|
||||
label: glyphs,
|
||||
title: contactTitle(c),
|
||||
detail: [
|
||||
e.retrograde ? `${pass}, retrográd mozgás közben` : pass,
|
||||
periodText(c, e.date) ?? "",
|
||||
c.house ? `a ${c.house}. házadban` : "",
|
||||
].filter(Boolean),
|
||||
});
|
||||
});
|
||||
}
|
||||
for (const h of f.transit_houses) {
|
||||
for (const i of h.ingresses) {
|
||||
out.push({
|
||||
date: i.date,
|
||||
tone: "neutral",
|
||||
label: glyph(h.planet),
|
||||
title: `${pointName(h.planet)} a ${i.house}. házadba lép`,
|
||||
detail: i.retrograde ? ["retrográd mozgással"] : [],
|
||||
});
|
||||
}
|
||||
}
|
||||
const p = f.progressions;
|
||||
for (const c of p.contacts) {
|
||||
for (const e of c.exact) {
|
||||
out.push({
|
||||
date: e.date,
|
||||
tone: toneOf(c),
|
||||
label: `${glyph(c.planet)}ᵖ`,
|
||||
title: contactTitle(c, true),
|
||||
detail: ["progresszió, pontos"],
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const b of p.bodies) {
|
||||
const name = `A progresszív ${pointName(b.planet)}`;
|
||||
for (const s of b.sign_changes) {
|
||||
out.push({ date: s.date, tone: "neutral", label: `${glyph(b.planet)}ᵖ`, title: `${name} ${SIGN_INTO[s.sign] ?? signName(s.sign)} lép`, detail: [] });
|
||||
}
|
||||
for (const h of b.house_changes) {
|
||||
out.push({ date: h.date, tone: "neutral", label: `${glyph(b.planet)}ᵖ`, title: `${name} a ${h.house}. házadba lép`, detail: [] });
|
||||
}
|
||||
}
|
||||
if (p.lunar_phase_change) {
|
||||
out.push({
|
||||
date: p.lunar_phase_change.date,
|
||||
tone: "neutral",
|
||||
label: "☽ᵖ",
|
||||
title: `Progresszív holdfázis: ${MOON_PHASES[p.lunar_phase_change.phase] ?? p.lunar_phase_change.phase}`,
|
||||
detail: [],
|
||||
});
|
||||
}
|
||||
for (const e of f.eclipses) {
|
||||
const what = `${ECLIPSE_TYPES[e.eclipse_type] ?? e.eclipse_type} ${e.kind === "solar" ? "napfogyatkozás" : "holdfogyatkozás"}`;
|
||||
out.push({
|
||||
date: e.date,
|
||||
tone: e.contacts.length > 0 ? "tense" : "neutral",
|
||||
label: e.kind === "solar" ? "☉●" : "☽●",
|
||||
title: `${what}, ${signName(e.sign)} ${dms(e.degree_in_sign_dms).split("′")[0]}′`,
|
||||
detail: [
|
||||
e.house ? `a ${e.house}. házadban` : "",
|
||||
...e.contacts.map(
|
||||
(c) => `${ASPECTS[c.aspect]?.hu ?? c.aspect} a születési ${pointName(c.point)} pontoddal (${orbText(c.orb)})`,
|
||||
),
|
||||
].filter(Boolean),
|
||||
});
|
||||
}
|
||||
return out.filter((e) => inYear(e.date)).sort((a, b) => a.date.localeCompare(b.date));
|
||||
}
|
||||
|
||||
/** The year month by month: exact transits, ingresses, progressions, eclipses. */
|
||||
export function ForecastTimeline({ forecast }: { forecast: Forecast }) {
|
||||
const list = events(forecast);
|
||||
const months = new Map<string, Event[]>();
|
||||
for (const e of list) {
|
||||
const key = e.date.slice(0, 7);
|
||||
months.set(key, [...(months.get(key) ?? []), e]);
|
||||
}
|
||||
if (list.length === 0) return <p className="muted">Ebben az évben nincs pontos lassú bolygós fényszög.</p>;
|
||||
return (
|
||||
<div className="timeline">
|
||||
<p className="hint">
|
||||
A lassú bolygók (Jupiter–Plútó) fényszögei a születési képletedhez 1° hatásfokon belül, a progresszió és a
|
||||
fogyatkozások. Egy tranzit a teljes hatásidő alatt érződik, a pontos napok körül a legerősebben.
|
||||
</p>
|
||||
{[...months.entries()].map(([key, items]) => (
|
||||
<section key={key} className="timeline-month" aria-label={monthTitle(key)}>
|
||||
<h3>{monthTitle(key)}</h3>
|
||||
<ol>
|
||||
{items.map((e, i) => (
|
||||
<li key={i} className={`timeline-item tone-${e.tone}`}>
|
||||
<span className="timeline-date">{shortDay(e.date)}</span>
|
||||
<span className="timeline-glyph" aria-hidden="true">
|
||||
{e.label}
|
||||
</span>
|
||||
<span className="timeline-text">
|
||||
<strong>{e.title}</strong>
|
||||
{e.detail.length > 0 && <span className="hint">{e.detail.join(" · ")}</span>}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** The main facts of the year at a glance. */
|
||||
export function ForecastKeys({ forecast, solarReturn }: { forecast: Forecast; solarReturn: SolarReturn | null }) {
|
||||
const sun = solarReturn?.points.find((p) => p.id === "sun");
|
||||
const moon = solarReturn?.points.find((p) => p.id === "moon");
|
||||
const asc = solarReturn?.angles?.ascendant;
|
||||
const ascSign = typeof asc === "object" && asc !== null ? asc.sign : null;
|
||||
const prof = forecast.profection;
|
||||
const pmoon = forecast.progressions.bodies.find((b) => b.planet === "moon");
|
||||
const exact = forecast.transits.filter((t) => t.exact.length > 0).length;
|
||||
return (
|
||||
<div className="card" style={{ gap: 12 }}>
|
||||
<span className="eyebrow">Az év kulcsai</span>
|
||||
<dl className="facts">
|
||||
{ascSign && (
|
||||
<>
|
||||
<dt>Szolár Aszcendens</dt>
|
||||
<dd>
|
||||
{signName(ascSign)}
|
||||
{solarReturn?.natal_house_of_ascendant ? `, a születési ${solarReturn.natal_house_of_ascendant}. házadban` : ""}
|
||||
</dd>
|
||||
</>
|
||||
)}
|
||||
{sun?.house && (
|
||||
<>
|
||||
<dt>Szolár Nap</dt>
|
||||
<dd>a {sun.house}. házban: ez az év fő terepe</dd>
|
||||
</>
|
||||
)}
|
||||
{moon?.house && (
|
||||
<>
|
||||
<dt>Szolár Hold</dt>
|
||||
<dd>
|
||||
{signName(moon.sign)}, a {moon.house}. házban
|
||||
</dd>
|
||||
</>
|
||||
)}
|
||||
{prof && (
|
||||
<>
|
||||
<dt>Az év ura</dt>
|
||||
<dd>
|
||||
{pointName(prof.lord)} ({prof.house}. ház, {signName(prof.sign)})
|
||||
</dd>
|
||||
</>
|
||||
)}
|
||||
{pmoon && (
|
||||
<>
|
||||
<dt>Progresszív Hold</dt>
|
||||
<dd>
|
||||
{signName(pmoon.sign)}
|
||||
{pmoon.house ? `, ${pmoon.house}. ház` : ""} ·{" "}
|
||||
{MOON_PHASES[forecast.progressions.lunar_phase] ?? forecast.progressions.lunar_phase}
|
||||
{pmoon.approximate ? " (bizonytalan)" : ""}
|
||||
</dd>
|
||||
</>
|
||||
)}
|
||||
<dt>Tranzitok</dt>
|
||||
<dd>
|
||||
{exact} pontos lassú bolygós fényszög, {forecast.eclipses.length} fogyatkozás
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** All slow-planet transits of the year as a list. */
|
||||
export function ForecastTransits({ forecast }: { forecast: Forecast }) {
|
||||
if (forecast.transits.length === 0) return <p className="muted">Ebben az évben nincs lassú bolygós tranzit.</p>;
|
||||
return (
|
||||
<ul className="transit-list">
|
||||
{forecast.transits.map((c, i) => (
|
||||
<li key={i} className={`tone-${toneOf(c)}`}>
|
||||
<span className="sym" aria-hidden="true">
|
||||
{glyph(c.planet)} {ASPECTS[c.aspect]?.glyph} {glyph(c.natal_point)}
|
||||
</span>
|
||||
<span>
|
||||
<strong>{contactTitle(c)}</strong>
|
||||
{c.planet === c.natal_point && <span className="pill">életciklus</span>}
|
||||
<span className="hint">
|
||||
{c.exact.length > 0
|
||||
? `pontos: ${c.exact.map((e) => longDay(e.date) + (e.retrograde ? " (R)" : "")).join(", ")}`
|
||||
: `nem pontos az évben, legközelebb ${orbText(c.min_orb)}`}
|
||||
{(c.periods ?? []).length > 0 &&
|
||||
` · hatás: ${(c.periods ?? []).map((p) => `${longDay(p.start)} – ${longDay(p.end)}`).join("; ")}`}
|
||||
{c.house ? ` · ${c.house}. ház` : ""}
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user