Type definitions
Introduction
This page describes the types in iztro. Internationalized types are defined in i18n, while the other types are defined in types.
Import internationalized types with the following code:
import { HeavenlyStemName } from "iztro/lib/i18n";To import other types, use:
import { Palace } from "iztro/lib/data/types";Tips
If you find an error or an unsuitable choice in the translations or type definitions, please open an issue. Thank you!
Internationalized types
To support internationalized input and output, iztro defines localized values for its parameters and results. You can pass a value in any supported language: for example, a HeavenlyStemName can be 甲, 갑 or jia.
For example, when calling getHoroscopeStar(), you can pass the Chinese names of the Heavenly Stems(天干) and Earthly Branches(地支) as arguments:
import { getHoroscopeStar } from "iztro/lib/star";
getHoroscopeStar("甲", "子", "decadal");You can also pass names in other supported languages, or mix languages in the same call:
import { getHoroscopeStar } from "iztro/lib/star";
getHoroscopeStar("갑", "zi", "decadal");The output uses the language you select, regardless of the languages used in the input. Set the output language before calling the method:
import { setLanguage } from "iztro/lib/i18n";
setLanguage("ko-KR");
const horoscopeStar = getHoroscopeStar("甲", "zi", "decadal");The output of horoscopeStar will then be in Korean.
horoscopeStar output result
[
[
{
"name": "록존(십년)",
"type": "lucun",
"scope": "decadal"
},
{
"name": "천마(십년)",
"type": "tianma",
"scope": "decadal"
}
],
[
{
"name": "경양(십년)",
"type": "tough",
"scope": "decadal"
},
{
"name": "홍란(십년)",
"type": "flower",
"scope": "decadal"
}
],
[],
[
{
"name": "문창(십년)",
"type": "soft",
"scope": "decadal"
}
],
[],
[
{
"name": "천월(십년)",
"type": "soft",
"scope": "decadal"
}
],
[],
[
{
"name": "문곡(십년)",
"type": "soft",
"scope": "decadal"
},
{
"name": "천희(십년)",
"type": "flower",
"scope": "decadal"
}
],
[],
[],
[],
[
{
"name": "천괴(십년)",
"type": "soft",
"scope": "decadal"
},
{
"name": "타라(십년)",
"type": "tough",
"scope": "decadal"
}
]
]HeavenlyStemName
Defines the names of the ten Heavenly Stems(十天干).
甲 | 乙 | 丙 | 丁 | 戊 | 己 | 庚 | 辛 | 壬 | 癸
EarthlyBranchName
Defines the twelve Earthly Branches(十二地支). The standard romanization of the Earthly Branch woo(午) and the Heavenly Stem wu(戊) is “wu” in both cases. To avoid a naming conflict in multilingual input, the library represents the branch woo(午) as woo.
子 | 丑 | 寅 | 卯 | 辰 | 巳 | 午 | 未 | 申 | 酉 | 戌 | 亥
PalaceName
Defines the Name of Zi Wei Dou Shu(紫微斗數) palaces(宮位).
命宫 | 身宫 | 兄弟 | 夫妻 | 子女 | 财帛 | 疾厄 | 迁移 | 仆役 | 官禄 | 田宅 | 福德 | 父母 | 来因
Brightness
Defines star(星曜) brightness.
"" | 庙 | 旺 | 得 | 利 | 平 | 不 | 陷
Mutagen
Defines the name of four transformation stars(四化星) in Zi Wei Dou Shu(紫微斗數)
禄 | 权 | 科 | 忌
StarName
Defines the names of stars(星曜) in Zi Wei Dou Shu(紫微斗數), including transit stars(流曜).
warrior and breaker, respectively.紫微 | 天机 | 太阳 | 武曲 | 天同 | 廉贞 | 天府 | 太阴 | 贪狼 | 巨门 | 天相 | 天梁 | 七杀 | 破军 | 左辅 | 右弼 | 文昌 | 文曲 | 禄存 | 天马 | 擎羊 | 陀罗 | 火星 | 铃星 | 天魁 | 天钺 | 地空 | 地劫 | 劫杀 | 天空 | 天刑 | 天姚 | 解神 | 阴煞 | 天喜 | 天官 | 天福 | 天哭 | 天虚 | 龙池 | 凤阁 | 红鸾 | 孤辰 | 寡宿 | 蜚廉 | 破碎 | 台辅 | 封诰 | 天巫 | 天月 | 三台 | 八座 | 恩光 | 天贵 | 天才 | 天寿 | 截空 | 旬中 | 旬空 | 空亡 | 截路 | 月德 | 天伤 | 天使 | 天厨 | 长生 | 沐浴 | 冠带 | 临官 | 帝旺 | 衰 | 病 | 死 | 墓 | 绝 | 胎 | 养 | 博士 | 力士 | 青龙 | 小耗 | 将军 | 奏书 | 飞廉 | 喜神 | 病符 | 大耗 | 岁破 | 伏兵 | 官府 | 岁建 | 晦气 | 丧门 | 贯索 | 官符 | 龙德 | 白虎 | 天德 | 吊客 | 将星 | 攀鞍 | 岁驿 | 息神 | 华盖 | 劫煞 | 灾煞 | 天煞 | 指背 | 咸池 | 月煞 | 亡神 | 运魁 | 运钺 | 运昌 | 运曲 | 运鸾 | 运喜 | 运禄 | 运羊 | 运陀 | 运马 | 流魁 | 流钺 | 流昌 | 流曲 | 流鸾 | 流喜 | 流禄 | 流羊 | 流陀 | 流马 | 年解 | 月魁 | 月钺 | 月昌 | 月曲 | 月鸾 | 月喜 | 月禄 | 月羊 | 月陀 | 月马 | 日魁 | 日钺 | 日昌 | 日曲 | 日鸾 | 日喜 | 日禄 | 日羊 | 日陀 | 日马 | 时魁 | 时钺 | 时昌 | 时曲 | 时鸾 | 时喜 | 时禄 | 时羊 | 时陀 | 时马
Alias of the same name stars ^2.6.1
When two stars(星曜) share the same Korean or Vietnamese name, use an alias qualified with Chinese characters to identify the intended star precisely. These aliases are accepted only as input; translated output still uses the original names.
- Korean:
천상(天相),천상(天傷),천월(天鉞),천월(天月),겁살(劫殺),겁살(劫煞),비렴(蜚廉),비렴(飛廉),관부(官府),관부(官符) - Vietnamese:
Kiếp Sát(劫殺),Kiếp Sát(劫煞),Phi Liêm(蜚廉),Phi Liêm(飛廉)
FiveElementsClassName
Defines the name of Five Elements Class(五行局) in Zi Wei Dou Shu(紫微斗數)
水二局 | 木三局 | 金四局 | 土五局 | 火六局
GenderName
Defines the names used for gender.
男 | 女
Common types
Language
export type Language = `zh-CN` | `zh-TW` | `en-US` | `ko-KR` | `ja-JP` | `vi-VN`;Defines the supported language values:
zh-CN: Simplified Chinesezh-TW: Traditional Chineseen-US:Englishko-KR:한국어ja-JP: Japanesevi-VN: Vietnamese
Scope
export type Scope = "origin" | "decadal" | "yearly";Defines the scope of stars(星曜), distinguishing natal stars(本命星曜) from transit stars(流曜):
origin: natal stars(本命星曜)decadal: decadal-cycle stars(大限星曜)yearly: yearly transit stars(流年星曜)
StarType
export type StarType =
| "major"
| "soft"
| "tough"
| "adjective"
| "flower"
| "helper"
| "lucun"
| "tianma";Defines star(星曜) Type. Although romance stars(桃花星) and considery(解神) (including considery(Y)(年解)) are miscellaneous stars(雜曜), they have special significance in chart interpretation and are therefore classified separately. The two auxiliary stars money(祿存) and horse(天馬) also have distinct roles, so each has its own category:
major: major stars(主星)soft: auspicious stars(吉星)tough: malefic stars(煞星)adjective: miscellaneous stars(雜曜)flower: romance stars(桃花)helper:considery(解神)lucun:money(祿存)tianma:horse(天馬)
Stars(星曜)
Star
export type Star = {
name: StarName;
type: StarType;
scope: Scope;
brightness?: Brightness;
mutagen?: Mutagen;
};Defines the data structure for stars(星曜).
| Properties | Meaning | Type |
|---|---|---|
name | Star name(星曜名稱) | StarName |
type | Star type(星曜類型) | StarType |
scope | Scope | Scope |
brightness | Star brightness | Brightness |
mutagen | four transformations(四化) | Mutagen |
Palaces(宮位)
SoulAndBody
export type SoulAndBody = {
soulIndex: number;
bodyIndex: number;
heavenlyStemOfSoul: HeavenlyStemName;
earthlyBranchOfSoul: EarthlyBranchName;
};Defines the positions of the soul(命宮) and body(身宮) palaces.
| Properties | Meaning | Type |
|---|---|---|
soulIndex | soul(命宮) index | number |
bodyIndex | body(身宮) index | number |
heavenlyStemOfSoul | Heavenly Stem of the soul palace(命宮天干) | HeavenlyStemName |
earthlyBranchOfSoul | Earthly Branch of the soul palace(命宮地支) | EarthlyBranchName |
Palace
export type Palace = {
name: PalaceName;
isBodyPalace: boolean;
isOriginalPalace: boolean;
heavenlyStem: HeavenlyStemName;
earthlyBranch: EarthlyBranchName;
majorStars: Star[];
minorStars: Star[];
adjectiveStars: Star[];
changsheng12: StarName;
boshi12: StarName;
jiangqian12: StarName;
suiqian12: StarName;
decadal: Decadal;
ages: number[];
};Defines the data structure for palaces(宮位).
| Properties | Meaning | Type |
|---|---|---|
name | Palace name(宮位名稱) | PalaceName |
isBodyPalace | Whether this is the body palace(身宮) | boolean |
isOriginalPalace | Whether this is the origin palace(來因宮) | boolean |
heavenlyStem | Palace Heavenly Stem(宮位天干) | HeavenlyStemName |
earthlyBranch | Palace Earthly Branch(宮位地支) | EarthlyBranchName |
majorStars | major stars(主星) | Star[] |
minorStars | auxiliary stars(輔星) | Star[] |
adjectiveStars | miscellaneous stars(雜曜) | Star[] |
changsheng12 | Twelve growth-stage stars | StarName |
boshi12 | Twelve Doctor-cycle stars(博士十二神) | StarName |
jiangqian12 | Twelve yearly General-front stars | StarName |
suiqian12 | Twelve yearly Year-front stars | StarName |
decadal | decadal(大限) | Decadal |
ages | age(小限) | number[] |
SurroundedPalaces
export type SurroundedPalaces = {
target: IFunctionalPalace;
opposite: IFunctionalPalace;
wealth: IFunctionalPalace;
career: IFunctionalPalace;
};Defines an object containing the trine and opposite palaces(三方四正).
| Properties | Meaning | Type |
|---|---|---|
target | target palace | IFunctionalPalace |
opposite | opposite palace | IFunctionalPalace |
wealth | Wealth position(財帛位) | IFunctionalPalace |
career | Career position(官祿位) | IFunctionalPalace |
Horoscope periods(運限)
HoroscopeItem
export type HoroscopeItem = {
index: number;
name: string;
heavenlyStem: HeavenlyStemName;
earthlyBranch: EarthlyBranchName;
palaceNames: PalaceName[];
mutagen: StarName[];
stars?: Star[][];
};Defines the data structure used for individual horoscope periods(運限).
| Properties | Meaning | Type |
|---|---|---|
index | Index of the corresponding palace | number |
name ^1.2.3 | Horoscope-period name(運限名稱) | string |
heavenlyStem | Horoscope-period Heavenly Stem(運限天干) | HeavenlyStemName |
earthlyBranch | Horoscope-period Earthly Branch(運限地支) | EarthlyBranchName |
palaceNames | Twelve palaces of the horoscope period(運限十二宮) | PalaceName[] |
mutagen | four transformation stars(四化星) | StarName[] |
stars | transit stars(流曜) | Star[][] |
Decadal
export type Decadal = {
range: [number, number];
heavenlyStem: HeavenlyStemName;
earthlyBranch: EarthlyBranchName;
};Defines the chart’s decadal(大限) data. This type is mainly used in Palace.
| Properties | Meaning | Type |
|---|---|---|
range | Decadal-period starting and ending ages [starting age, ending age] | [number, number] |
heavenlyStem | Decadal-period Heavenly Stem(大限天干) | HeavenlyStemName |
earthlyBranch | Decadal-period Earthly Branch(大限地支) | EarthlyBranchName |
DecadalHoroscope
export type DecadalHoroscope = HoroscopeItem & {
palaceName: PalaceName;
ageRange: [number, number];
yearRange: [number, number];
};Defines a decadal-cycle(大限) list item returned by decadalList().
| Properties | Meaning | Type |
|---|---|---|
palaceName | Natal palace occupied by the decadal period(大限所在本命宮位) | PalaceName |
ageRange | Decadal-period starting and ending nominal ages(虛歲) | [number, number] |
yearRange | Decadal-period starting and ending years | [number, number] |
This type also contains all attributes of HoroscopeItem.
YearlyHoroscope
export type YearlyHoroscope = HoroscopeItem & {
age: number;
year: number;
};Defines a yearly-cycle(流年) list item returned by yearlyList().
| Properties | Meaning | Type |
|---|---|---|
age | Nominal age corresponding to the annual period(流年虛歲) | number |
year | Year of the annual period(流年年份) | number |
This type also contains all attributes of HoroscopeItem.
MonthlyHoroscope
export type MonthlyHoroscope = YearlyHoroscope & {
month: number;
isLeapMonth: boolean;
part: 'normal' | 'first' | 'second';
dayRange: [number, number];
};Defines a monthly-cycle(流月) list item returned by monthlyList().
| Properties | Meaning | Type |
|---|---|---|
month | Lunar month, the first month is 1 | number |
isLeapMonth | Is it a leap month? | boolean |
part | Ordinary month, first half of leap month or second half of leap month | 'normal' | 'first' | 'second' |
dayRange | The corresponding lunar date range for this item | [number, number] |
This type contains all properties of both YearlyHoroscope and HoroscopeItem.
Horoscope
export type Horoscope = {
lunarDate: string;
solarDate: string;
decadal: HoroscopeItem;
age: {
index: number;
nominalAge: number;
};
yearly: HoroscopeItem & {
yearlyDecStar: {
jiangqian12: StarName[];
suiqian12: StarName[]
}
};
monthly: HoroscopeItem;
daily: HoroscopeItem;
hourly: HoroscopeItem;
};Defines a horoscope-period(運限) object containing decadal(大限), yearly(流年), monthly(流月), daily(流日), and hourly(流時) data.
| Properties | Meaning | Type |
|---|---|---|
lunarDate | Lunar-calendar date | string |
solarDate | Gregorian date | string |
decadal | decadal(大限) | HoroscopeItem |
age | age(小限) | { index: number, nominalAge: number } |
yearly | yearly(流年) | HoroscopeItem & { yearlyDecStar: { jiangqian12: StarName[]; suiqian12: StarName[] } } |
monthly | monthly(流月) | HoroscopeItem |
daily | daily(流日) | HoroscopeItem |
hourly | hourly(流時) | HoroscopeItem |
Chart(星盤)
Astrolabe
export type Astrolabe = {
gender: GenderName;
solarDate: string;
lunarDate: string;
chineseDate: string;
rawDates: {
lunarDate: LunarDate;
chineseDate: HeavenlyStemAndEarthlyBranchDate;
};
time: string;
timeRange: string;
sign: string;
zodiac: string;
earthlyBranchOfSoulPalace: EarthlyBranchName;
earthlyBranchOfBodyPalace: EarthlyBranchName;
soul: StarName;
body: StarName;
fiveElementsClass: FiveElementsClassName;
palaces: IFunctionalPalace[];
};Defines a chart(星盤) object.
| Properties | Meaning | Type |
|---|---|---|
gender | gender ^2.0.3 | GenderName |
solarDate | Gregorian date | string |
lunarDate | Lunar-calendar date | string |
chineseDate | Date expressed using Heavenly Stems and Earthly Branches(干支) | string |
rawDates | Raw date data for future use by internal methods | { lunarDate: LunarDate, chineseDate: HeavenlyStemAndEarthlyBranchDate } |
time | Traditional double-hour(時辰) | string |
timeRange | Clock-time range corresponding to the traditional double-hour | string |
sign | Western zodiac sign(星座) | string |
zodiac | Chinese zodiac animal(生肖) | string |
earthlyBranchOfSoulPalace | Earthly Branch of the soul palace(命宮地支) | EarthlyBranchName |
earthlyBranchOfBodyPalace | Earthly Branch of the body palace(身宮地支) | EarthlyBranchName |
soul | Soul ruler star(命主) | StarName |
body | Body ruler star(身主) | StarName |
fiveElementsClass | Five Elements Class(五行局) | FiveElementsClassName |
palaces | Data for the twelve palaces(十二宮) | IFunctionalPalace[] |
Configuration and plugins ^2.3.0
ConfigMutagens
Defines the four transformations(四化) parameter in the global configuration.
type ConfigMutagens = Partial<Record<HeavenlyStemName, StarName[]>>;ConfigBrightness
Defines the brightness parameter in the global configuration.
type ConfigBrightness = Partial<Record<StarName, Brightness[]>>;Config
Defines chart-calculation settings. Use astro.config() to set defaults for subsequently generated charts, or withOptions({ config }) to override the settings for just the chart being generated. Existing charts retain the settings used at their creation (^2.6.2).
type Config = {
// 星曜四化配置
mutagens?: ConfigMutagens;
// 星曜亮度配置
brightness?: ConfigBrightness;
// 年分割点配置
yearDivide?: 'normal' | 'exact';
// 运限分割点配置(^v2.4.3)
horoscopeDivide?: 'normal' | 'exact';
// 小限分割点配置,normal为以自然年分界,birthday为生日分界(^v2.4.5)
// 默认为 normal
ageDivide?: 'normal' | 'birthday';
// 晚子时配置,current 时晚子时算当日,forward 时晚子时算次日(^v2.5.2)
// 默认为 forward
dayDivide?: 'current' | 'forward';
// 安星方法,default 为通行版本,zhongzhou 为中州派版本(^v2.5.0)
// 默认为 default
algorithm?: 'default' | 'zhongzhou';
};For yearDivide and horoscopeDivide, normal uses the first day of the first Chinese lunar month as the year boundary, while exact uses the solar term Start of Spring(立春).
dayDivide only controls which calendar day the late Zi hour(晚子時) belongs to (timeIndex is 12): forward assigns it to the following day, and current assigns it to the current day.
AstroType ^2.5.0
Defines the chart type used by the Zhongzhou school(中州派).
type AstroType = 'heaven' | 'earth' | 'human';| value | Description |
|---|---|
heaven | Natal chart(天盤), the default |
earth | Earth chart(地盤): derive the Five Elements Class from the body palace's stem and branch, and use that palace as the soul palace. |
human | Human chart(人盤): derive the Five Elements Class from the spirit palace's stem and branch, and use that palace as the soul palace. |
Plugin
Defines the plugin type. A plugin is simply a function.
type Plugin = () => void;Tips
A plugin function implicitly receives a this parameter of type T extends FunctionalAstrolabe. See Plugins for details on creating one.