bazi-terms 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AskingMing (https://askingming.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # bazi-terms
2
+
3
+ > Bilingual (中文 / English) terminology database for Bazi / Four Pillars of Destiny (八字·四柱). Zero dependencies, framework-agnostic. Part of [BaziKit](../../README.md).
4
+
5
+ Every concept a Bazi chart uses — Heavenly Stems, Earthly Branches, Ten Gods, Shen Sha, Na Yin, Growth Stages, interactions and general chart vocabulary — as structured, translated data you can drop into any app, blog glossary or i18n layer.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install bazi-terms
11
+ ```
12
+
13
+ ESM + CJS builds with full TypeScript declarations.
14
+
15
+ ## Coverage
16
+
17
+ | Category | Export | Size |
18
+ | --- | --- | --- |
19
+ | Ten Heavenly Stems 天干 | `STEMS` | 10 |
20
+ | Twelve Earthly Branches 地支 | `BRANCHES` | 12 |
21
+ | Five Elements 五行 (+ generating/controlling cycles) | `ELEMENTS`, `ELEMENT_CYCLES` | 5 |
22
+ | Ten Gods 十神 (+ Day Master) | `TEN_GODS` | 11 |
23
+ | Twelve Growth Stages 十二长生 | `GROWTH_STAGES` | 12 |
24
+ | Shen Sha 神煞 (symbolic stars) | `SHEN_SHA` | 38 |
25
+ | Sixty Jiazi Na Yin 六十甲子纳音 | `NA_YIN` | 30 melodies / 60 pairs |
26
+ | Interactions 刑冲合会 (+ pairing tables) | `INTERACTION_TYPES` | 8 |
27
+ | General vocabulary 通用术语 | `GENERAL_TERMS` | 40+ |
28
+
29
+ Each term carries `key`, `zh`, `en`, optional `pinyin` and an English `definition` you can copy straight into a glossary or tooltip.
30
+
31
+ ## API
32
+
33
+ ### Translation helpers
34
+
35
+ ```ts
36
+ import { t, translate, ALL_TERMS, TERM_BY_KEY } from 'bazi-terms';
37
+
38
+ t('dayMaster'); // 'Day Master' — translate a term KEY
39
+ t('dayMaster', 'zh'); // '日主'
40
+
41
+ // translate() accepts a key OR any raw engine value (Chinese / English key),
42
+ // resolving aliases, Na Yin pairs and interaction descriptions:
43
+ translate('元男'); // 'Day Master' (元男/元女/日元 → Day Master)
44
+ translate('偏官'); // 'Seven Killings' (alias of 七杀)
45
+ translate('枭神'); // 'Indirect Resource'
46
+ translate('海中金'); // 'Sea Gold'
47
+ translate('甲子'); // 'Sea Gold' (Na Yin by sexagenary pair)
48
+ translate('午子相冲'); // 'Clash' (Chinese description)
49
+ translate('metal', 'zh'); // '金'
50
+ ```
51
+
52
+ `translate()` never throws — unknown input is returned unchanged, so it is safe to pipe raw engine output through it.
53
+
54
+ ### Category resolvers
55
+
56
+ ```ts
57
+ import {
58
+ stemByChar, branchByChar, elementOf,
59
+ tenGodByZh, growthStageByZh, shenShaByZh, naYinOf,
60
+ interactionFromZh, interactionFromEnum,
61
+ } from 'bazi-terms';
62
+
63
+ stemByChar('庚'); // { key: 'geng', element: 'metal', polarity: 'yang', ... }
64
+ branchByChar('午'); // { key: 'wuHorse', zodiacEn: 'Horse', element: 'fire', ... }
65
+ elementOf('金'); // { key: 'metal', ... } (accepts '金' or 'metal')
66
+ tenGodByZh('正财'); // { key: 'zhengCai', en: 'Direct Wealth', ... }
67
+ naYinOf('甲子'); // { key: 'seaGold', en: 'Sea Gold', pairs: ['甲子','乙丑'] }
68
+ shenShaByZh('天乙贵人'); // { key: 'tianYiGuiRen', en: 'Heavenly Nobleman', ... }
69
+ growthStageByZh('帝旺'); // { key: 'peak', en: 'Peak', ... }
70
+
71
+ // Interaction resolvers accept either representation:
72
+ interactionFromZh('卯子相刑'); // Chinese description → { key: 'xiangXing', en: 'Punishment' }
73
+ interactionFromEnum('CLASH'); // English enum → { key: 'liuChong', en: 'Clash' }
74
+ ```
75
+
76
+ ### Pairing tables
77
+
78
+ Reference data for validating or reconstructing relationships from raw branch characters:
79
+
80
+ ```ts
81
+ import {
82
+ STEM_COMBINATIONS, LIU_HE, LIU_CHONG, SAN_HE, SAN_HUI,
83
+ XIANG_HAI, XIANG_PO, XIANG_XING,
84
+ } from 'bazi-terms';
85
+
86
+ LIU_CHONG; // [['子','午'], ['丑','未'], ['寅','申'], ['卯','酉'], ['辰','戌'], ['巳','亥']]
87
+ SAN_HE; // [['申','子','辰'], ['亥','卯','未'], ['寅','午','戌'], ['巳','酉','丑']]
88
+ ```
89
+
90
+ ## Engine compatibility
91
+
92
+ Most Bazi engines emit **Chinese values** for ten gods, Na Yin, growth stages and Shen Sha — even those whose field *names* are English. So a single `zh → key` mapping serves them all. Where engines differ (some use `元男` for the Day Master; others use interaction enums like `CLASH`), `bazi-terms` normalizes them through aliases and dedicated resolvers (`interactionFromZh` for Chinese descriptions, `interactionFromEnum` for English enums).
93
+
94
+ ## License
95
+
96
+ [MIT](./LICENSE) © 2026 [AskingMing](https://askingming.com).