@taekwondo-db/database 0.5.0 → 0.6.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/README.md CHANGED
@@ -47,8 +47,8 @@ audio/terms/ spoken terms (CC BY 4.0)
47
47
  | `supplementaryName` | an alternative romanized name in use. Searchable |
48
48
  | `description` | free text per language; may [reference](#references-in-descriptions) techniques and terms. Not searched |
49
49
  | `terms` | the name word by word; `$space` stands for a space. Their Hangeul is searchable |
50
- | `references` | related techniques; `generic` marks the general technique this one is a variant of, `specialization` the reverse |
51
- | `generic` | the technique is itself a generic term |
50
+ | `references` | at most one: the `generic` technique this one is a variant of. Kept on the variant only — loaded techniques also carry the reverse, their variants, as `specialization`. Cycles are rejected |
51
+ | `generic` | the technique is only a generic term, not one of its own. A technique with variants need not be one |
52
52
  | `sources`, `historic`, `videos`, `images`, `weight` | citations, historic names, video links, [images](#images), weight distribution of stances |
53
53
  | `pronunciation` | the Hangeul of `terms`, [spoken](#pronunciations) |
54
54
 
package/db/chagi.json CHANGED
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "Aneuro Naeryeochagi": {
19
19
  "pronunciation": { "ai": true, "src": "chagi/aneuro-naeryeochagi.mp3" },
20
+ "references": [{ "$ref": "#/Naeryeochagi", "type": "generic" }],
20
21
  "sources": [
21
22
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "225" }
22
23
  ],
@@ -83,6 +84,7 @@
83
84
  },
84
85
  "Bakkeuro Naeryeochagi": {
85
86
  "pronunciation": { "ai": true, "src": "chagi/bakkeuro-naeryeochagi.mp3" },
87
+ "references": [{ "$ref": "#/Naeryeochagi", "type": "generic" }],
86
88
  "sources": [
87
89
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "225" }
88
90
  ],
@@ -182,11 +184,10 @@
182
184
  },
183
185
  "Dollyeochagi": {
184
186
  "description": {
185
- "de": "Der vordere Fuß dient als Drehachse, der Körper dreht sich um etwa 180°. Das Knie steigt, das Bein schnellt heraus, und Fußballen oder Spann treffen das Ziel im rechten Winkel.",
186
- "en": "The front foot acts as the axis while the body rotates about 180°. The knee rises, the leg whips out, and ball of foot or instep connects at a right angle."
187
+ "de": "Der vordere Fuß dient als Drehachse, der Körper dreht sich um etwa 180°. Das Knie steigt, das Bein schnellt heraus, und Fußballen oder Spann treffen das Ziel im rechten Winkel. Zwischen ihm und dem #[Apchagi] liegt der schräge #[Bitgyeochagi].",
188
+ "en": "The front foot acts as the axis while the body rotates about 180°. The knee rises, the leg whips out, and ball of foot or instep connects at a right angle. The slanted #[Bitgyeochagi] sits between it and #[Apchagi]."
187
189
  },
188
190
  "pronunciation": { "ai": true, "src": "chagi/dollyeochagi.mp3" },
189
- "references": [{ "$ref": "#/Bitgyeochagi", "type": "specialization" }],
190
191
  "sources": [
191
192
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "218" }
192
193
  ],
@@ -524,10 +525,6 @@
524
525
  "en": "The leg rises with a bent knee, then straightens and drops from above so the heel or sole lands on the face or chest. Depending on where the opponent stands, it comes as #[Aneuro Naeryeochagi] (inward) or #[Bakkeuro Naeryeochagi] (outward)."
525
526
  },
526
527
  "pronunciation": { "ai": true, "src": "chagi/naeryeochagi.mp3" },
527
- "references": [
528
- { "$ref": "#/Aneuro Naeryeochagi", "type": "specialization" },
529
- { "$ref": "#/Bakkeuro Naeryeochagi", "type": "specialization" }
530
- ],
531
528
  "sources": [
532
529
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "225" }
533
530
  ],
package/db/chigi.json CHANGED
@@ -116,7 +116,7 @@
116
116
  "en": "The flat hand strikes from outside to inside; since it is quick to perform, it can also serve as a supporting block to deflect an attack."
117
117
  },
118
118
  "pronunciation": { "ai": true, "src": "chigi/batangson-anchigi.mp3" },
119
- "references": [{ "$ref": "#/Anchigi", "type": "generic" }],
119
+ "references": [{ "$ref": "#/Mejumeok Anchigi", "type": "generic" }],
120
120
  "sources": [
121
121
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "184" }
122
122
  ],
@@ -164,7 +164,7 @@
164
164
  "en": "A knife-hand inward strike with a trunk rotation of about 45°; the trunk is turned further than in the normal inward knife-hand strike."
165
165
  },
166
166
  "pronunciation": { "ai": true, "src": "chigi/biteureo-anchigi.mp3" },
167
- "references": [{ "$ref": "#/Anchigi", "type": "generic" }],
167
+ "references": [{ "$ref": "#/Mok Sonnal Anchigi", "type": "generic" }],
168
168
  "sources": [
169
169
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "184" }
170
170
  ],
@@ -582,11 +582,7 @@
582
582
  "en": "Inward hammer-fist blow to the neck or flank."
583
583
  },
584
584
  "pronunciation": { "ai": true, "src": "chigi/mejumeok-anchigi.mp3" },
585
- "references": [
586
- { "$ref": "#/Anchigi", "type": "generic" },
587
- { "$ref": "#/Batangson Anchigi", "type": "specialization" },
588
- { "$ref": "#/Sonnaldeung Anchigi", "type": "specialization" }
589
- ],
585
+ "references": [{ "$ref": "#/Anchigi", "type": "generic" }],
590
586
  "sources": [
591
587
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "184" }
592
588
  ],
@@ -631,10 +627,7 @@
631
627
  "en": "The hammer fist hits the crown or the collarbone; the supporting hand is pulled down powerfully and then drawn to the waist."
632
628
  },
633
629
  "pronunciation": { "ai": true, "src": "chigi/mejumeok-naeryeochigi.mp3" },
634
- "references": [
635
- { "$ref": "#/Naeryeochigi", "type": "generic" },
636
- { "$ref": "#/Naeryeochigi", "type": "specialization" }
637
- ],
630
+ "references": [{ "$ref": "#/Naeryeochigi", "type": "generic" }],
638
631
  "sources": [
639
632
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "186" }
640
633
  ],
@@ -724,14 +717,11 @@
724
717
  },
725
718
  "Mok Jebipum Anchigi": {
726
719
  "description": {
727
- "de": "Die Handkante der vorderen Hand deckt das Gesicht, die Handkante der hinteren Hand schlägt mit einer letzten Handgelenksdrehung auf den Hals; die Schultern drehen sich nach innen, während die Hüfte gedreht wird.",
728
- "en": "The front hand's knife hand guards the face while the back hand's knife hand strikes the neck with a final twist of the wrist; the shoulders turn inward as the waist twists."
720
+ "de": "Die Handkante der vorderen Hand deckt das Gesicht, die Handkante der hinteren Hand schlägt mit einer letzten Handgelenksdrehung auf den Hals; die Schultern drehen sich nach innen, während die Hüfte gedreht wird. Beim #[Teok Jebipum Apchigi] trifft stattdessen die Handfläche das Kinn.",
721
+ "en": "The front hand's knife hand guards the face while the back hand's knife hand strikes the neck with a final twist of the wrist; the shoulders turn inward as the waist twists. In #[Teok Jebipum Apchigi], the palm strikes the jaw instead."
729
722
  },
730
723
  "pronunciation": { "ai": true, "src": "chigi/mok-jebipum-anchigi.mp3" },
731
- "references": [
732
- { "$ref": "#/Jebipumchigi", "type": "generic" },
733
- { "$ref": "#/Teok Jebipum Apchigi", "type": "specialization" }
734
- ],
724
+ "references": [{ "$ref": "#/Jebipumchigi", "type": "generic" }],
735
725
  "sources": [
736
726
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "193" }
737
727
  ],
@@ -760,10 +750,7 @@
760
750
  "en": "The knife hand strikes the neck from the outside; the supporting hand is drawn to the waist in the same rotation, the trunk is turned about 30°, and the knife hand strikes as it rotates."
761
751
  },
762
752
  "pronunciation": { "ai": true, "src": "chigi/mok-sonnal-anchigi.mp3" },
763
- "references": [
764
- { "$ref": "#/Anchigi", "type": "generic" },
765
- { "$ref": "#/Biteureo Anchigi", "type": "specialization" }
766
- ],
753
+ "references": [{ "$ref": "#/Anchigi", "type": "generic" }],
767
754
  "sources": [
768
755
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "184" }
769
756
  ],
@@ -1108,7 +1095,7 @@
1108
1095
  "en": "Downward knife-hand blow against a low target; performed much like #[Mejumeok Naeryeochigi], the downward hammer-fist blow."
1109
1096
  },
1110
1097
  "pronunciation": { "ai": true, "src": "chigi/sonnal-naeryeochigi.mp3" },
1111
- "references": [{ "$ref": "#/Naeryeochigi", "type": "generic" }],
1098
+ "references": [{ "$ref": "#/Mejumeok Naeryeochigi", "type": "generic" }],
1112
1099
  "sources": [
1113
1100
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "186" }
1114
1101
  ],
@@ -1129,7 +1116,7 @@
1129
1116
  "en": "Inward blow with the ridge hand. Power comes solely from turning the shoulder inward and from body weight; the wrist and elbow add no twist of their own."
1130
1117
  },
1131
1118
  "pronunciation": { "ai": true, "src": "chigi/sonnaldeung-anchigi.mp3" },
1132
- "references": [{ "$ref": "#/Anchigi", "type": "generic" }],
1119
+ "references": [{ "$ref": "#/Mejumeok Anchigi", "type": "generic" }],
1133
1120
  "sources": [
1134
1121
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "184" }
1135
1122
  ],
package/db/makgi.json CHANGED
@@ -235,7 +235,10 @@
235
235
  { "$ref": "./terms.json#/yeop" },
236
236
  { "$ref": "./terms.json#/makgi" }
237
237
  ],
238
- "translation": { "de": "Block zur Seite", "en": "Side block" }
238
+ "translation": {
239
+ "de": "Block zur Seite mit dem inneren Unterarm",
240
+ "en": "Inner wrist side block"
241
+ }
239
242
  },
240
243
  "Arae Anpalmok Pyojeok Anmakgi": {
241
244
  "description": {
@@ -280,10 +283,7 @@
280
283
  { "ai": true, "src": "makgi/arae-eotgeoreomakgi-side.jpg" }
281
284
  ],
282
285
  "pronunciation": { "ai": true, "src": "makgi/arae-eotgeoreomakgi.mp3" },
283
- "references": [
284
- { "$ref": "#/Eotgeoreomakgi", "type": "generic" },
285
- { "$ref": "#/Arae Sonnal Eotgeoreomakgi", "type": "specialization" }
286
- ],
286
+ "references": [{ "$ref": "#/Eotgeoreomakgi", "type": "generic" }],
287
287
  "sources": [
288
288
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "155" }
289
289
  ],
@@ -370,7 +370,7 @@
370
370
  "ai": true,
371
371
  "src": "makgi/arae-sonnal-eotgeoreomakgi.mp3"
372
372
  },
373
- "references": [{ "$ref": "#/Eotgeoreomakgi", "type": "generic" }],
373
+ "references": [{ "$ref": "#/Arae Eotgeoreomakgi", "type": "generic" }],
374
374
  "sources": [
375
375
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "155" }
376
376
  ],
@@ -462,7 +462,7 @@
462
462
  },
463
463
  "Arae Sonnal Yeommakgi": {
464
464
  "pronunciation": { "ai": true, "src": "makgi/arae-sonnal-yeommakgi.mp3" },
465
- "references": [{ "$ref": "#/Yeommakgi", "type": "generic" }],
465
+ "references": [{ "$ref": "#/Sonnal Yeommakgi", "type": "generic" }],
466
466
  "sources": [
467
467
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "137" }
468
468
  ],
@@ -475,8 +475,8 @@
475
475
  { "$ref": "./terms.json#/makgi" }
476
476
  ],
477
477
  "translation": {
478
- "de": "Block mit Außenhandkante zur Seite",
479
- "en": "Knife hand side block"
478
+ "de": "Unterer Block mit Außenhandkante zur Seite",
479
+ "en": "Low knife hand side block"
480
480
  }
481
481
  },
482
482
  "Araemakgi": {
@@ -559,7 +559,7 @@
559
559
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "130" }
560
560
  ],
561
561
  "terms": [
562
- { "$ref": "./terms.json#/bakkatpalmok" },
562
+ { "$ref": "./terms.json#/bakkanpalmok" },
563
563
  { "$ref": "./terms.json#/$space" },
564
564
  { "$ref": "./terms.json#/hechyeo" },
565
565
  { "$ref": "./terms.json#/makgi" }
@@ -575,28 +575,6 @@
575
575
  }
576
576
  ]
577
577
  },
578
- "Bakkatpalmok Yeommakgi": {
579
- "description": {
580
- "de": "Der Angriff wird zur Seite abgelenkt.",
581
- "en": "The attack is deflected to the side."
582
- },
583
- "pronunciation": { "ai": true, "src": "makgi/bakkatpalmok-yeommakgi.mp3" },
584
- "references": [
585
- { "$ref": "#/Yeommakgi", "type": "generic" },
586
- { "$ref": "#/Anpalmok Yeommakgi", "type": "specialization" }
587
- ],
588
- "sources": [
589
- { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "136" }
590
- ],
591
- "supplementaryName": "(Bakkatpalmok) Yeommakgi",
592
- "terms": [
593
- { "$ref": "./terms.json#/bakkatpalmok" },
594
- { "$ref": "./terms.json#/$space" },
595
- { "$ref": "./terms.json#/yeop" },
596
- { "$ref": "./terms.json#/makgi" }
597
- ],
598
- "translation": { "de": "Block zur Seite", "en": "Side block" }
599
- },
600
578
  "Ballal Badamakgi": {
601
579
  "description": {
602
580
  "de": "Die Fußkante trifft auf den gegnerischen Angriff, bevor dieser seine volle Wucht entfaltet, und bremst ihn. Ein leicht gebeugtes Knie federt den Aufprall ab.",
@@ -772,10 +750,7 @@
772
750
  { "ai": true, "src": "makgi/eolgul-eotgeoreomakgi-side.jpg" }
773
751
  ],
774
752
  "pronunciation": { "ai": true, "src": "makgi/eolgul-eotgeoreomakgi.mp3" },
775
- "references": [
776
- { "$ref": "#/Eotgeoreomakgi", "type": "generic" },
777
- { "$ref": "#/Eolgul Sonnal Eotgeoreomakgi", "type": "specialization" }
778
- ],
753
+ "references": [{ "$ref": "#/Eotgeoreomakgi", "type": "generic" }],
779
754
  "sources": [
780
755
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "156" }
781
756
  ],
@@ -795,8 +770,8 @@
795
770
  },
796
771
  "Eolgul Sonnal Biteureo Bakkanmakgi": {
797
772
  "description": {
798
- "de": "Gegen Angriffe zum Gesicht wehrt die Handkante ab, während sich der Rumpf um etwa 45° dreht, sodass sie bis an die äußere Körperlinie gelangt.",
799
- "en": "Against strikes to the face, the knife hand blocks while the torso rotates roughly 45°, carrying the hand out to the edge of the body."
773
+ "de": "Gegen Angriffe zum Gesicht wehrt die Handkante ab, während sich der Rumpf um etwa 45° dreht, sodass sie bis an die äußere Körperlinie gelangt. Ähnelt dem #[Sonnal Biteureo Bakkanmakgi].",
774
+ "en": "Against strikes to the face, the knife hand blocks while the torso rotates roughly 45°, carrying the hand out to the edge of the body. It is similar to #[Sonnal Biteureo Bakkanmakgi]."
800
775
  },
801
776
  "images": [
802
777
  {
@@ -809,10 +784,7 @@
809
784
  "ai": true,
810
785
  "src": "makgi/eolgul-sonnal-biteureo-bakkanmakgi.mp3"
811
786
  },
812
- "references": [
813
- { "$ref": "#/Biteureomakgi", "type": "generic" },
814
- { "$ref": "#/Sonnal Biteureo Bakkanmakgi", "type": "specialization" }
815
- ],
787
+ "references": [{ "$ref": "#/Biteureomakgi", "type": "generic" }],
816
788
  "sources": [
817
789
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "127" }
818
790
  ],
@@ -846,7 +818,7 @@
846
818
  "ai": true,
847
819
  "src": "makgi/eolgul-sonnal-eotgeoreomakgi.mp3"
848
820
  },
849
- "references": [{ "$ref": "#/Eotgeoreomakgi", "type": "generic" }],
821
+ "references": [{ "$ref": "#/Eolgul Eotgeoreomakgi", "type": "generic" }],
850
822
  "sources": [
851
823
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "156" }
852
824
  ],
@@ -1381,7 +1353,7 @@
1381
1353
  { "ai": true, "src": "makgi/sonnal-araemakgi-side.jpg" }
1382
1354
  ],
1383
1355
  "pronunciation": { "ai": true, "src": "makgi/sonnal-araemakgi.mp3" },
1384
- "references": [{ "$ref": "#/Araemakgi", "type": "generic" }],
1356
+ "references": [{ "$ref": "#/Naeryeomakgi", "type": "generic" }],
1385
1357
  "sources": [
1386
1358
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "117" }
1387
1359
  ],
@@ -1565,10 +1537,7 @@
1565
1537
  { "ai": true, "src": "makgi/sonnal-yeommakgi-side.jpg" }
1566
1538
  ],
1567
1539
  "pronunciation": { "ai": true, "src": "makgi/sonnal-yeommakgi.mp3" },
1568
- "references": [
1569
- { "$ref": "#/Yeommakgi", "type": "generic" },
1570
- { "$ref": "#/Arae Sonnal Yeommakgi", "type": "specialization" }
1571
- ],
1540
+ "references": [{ "$ref": "#/Yeommakgi", "type": "generic" }],
1572
1541
  "sources": [
1573
1542
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "136" }
1574
1543
  ],
@@ -1688,11 +1657,12 @@
1688
1657
  "de": "Der Angriff wird mit dem äußeren Handgelenk zur Seite abgelenkt; bei Angriffen auf das Gesicht wird auf der Philtrum-Linie geblockt, bei Angriffen auf den Körper auf der Brustbein-Linie. Der Ellenbogen wird nicht zu weit nach vorn geführt, so dass die blockende Bewegung natürlich nach unten zeigt.",
1689
1658
  "en": "The attack is deflected to the side with the outer wrist; for attacks to the face it blocks on the philtrum line, for the trunk on the sternum line. The elbow is not carried too far forward so the blocking motion naturally points downward."
1690
1659
  },
1691
- "generic": true,
1692
1660
  "pronunciation": { "ai": true, "src": "makgi/yeommakgi.mp3" },
1693
1661
  "sources": [
1694
- { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "135" }
1662
+ { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "135" },
1663
+ { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "136" }
1695
1664
  ],
1665
+ "supplementaryName": "Bakkanpalmok Yeommakgi",
1696
1666
  "terms": [
1697
1667
  { "$ref": "./terms.json#/yeop" },
1698
1668
  { "$ref": "./terms.json#/makgi" }
@@ -25,17 +25,18 @@
25
25
  },
26
26
  "pronunciation": { "$ref": "./pronunciation.json" },
27
27
  "references": {
28
- "description": "References to other techniques.",
28
+ "description": "The more general technique this one is a variant of. Its specializations are derived from these references.",
29
29
  "items": {
30
30
  "additionalProperties": false,
31
31
  "properties": {
32
32
  "$ref": { "minLength": 1, "type": "string" },
33
33
  "description": { "$ref": "./localized-string.json" },
34
- "type": { "enum": ["specialization", "generic"] }
34
+ "type": { "const": "generic" }
35
35
  },
36
- "required": ["$ref"],
36
+ "required": ["$ref", "type"],
37
37
  "type": "object"
38
38
  },
39
+ "maxItems": 1,
39
40
  "type": "array"
40
41
  },
41
42
  "sources": { "items": { "$ref": "./source.json" }, "type": "array" },
package/db/seogi.json CHANGED
@@ -387,7 +387,6 @@
387
387
  ],
388
388
  "images": [{ "ai": true, "src": "seogi/juchumseogi-front.jpg" }],
389
389
  "pronunciation": { "ai": true, "src": "seogi/juchumseogi.mp3" },
390
- "references": [{ "$ref": "#/Natchueoseogi", "type": "specialization" }],
391
390
  "sources": [
392
391
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "80" }
393
392
  ],
@@ -547,6 +546,7 @@
547
546
  "en": "The stance is lowered below the #[Juchumseogi|horse stance] by setting the feet wider; often used to build muscular endurance."
548
547
  },
549
548
  "pronunciation": { "ai": true, "src": "seogi/natchueoseogi.mp3" },
549
+ "references": [{ "$ref": "#/Juchumseogi", "type": "generic" }],
550
550
  "sources": [
551
551
  { "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "80" }
552
552
  ],
package/db/terms.json CHANGED
@@ -94,18 +94,18 @@
94
94
  "pronunciation": { "ai": true, "src": "terms/badak.mp3" },
95
95
  "type": "noun"
96
96
  },
97
- "bakkat": {
98
- "description": { "de": "nach außen", "en": "outside" },
99
- "hangeul": "바깥",
100
- "pronunciation": { "ai": true, "src": "terms/bakkat.mp3" }
101
- },
102
- "bakkatpalmok": {
97
+ "bakkanpalmok": {
103
98
  "description": { "de": "äußerer Unterarm", "en": "outer wrist" },
104
99
  "hangeul": "바깥팔목",
105
- "pronunciation": { "ai": true, "src": "terms/bakkatpalmok.mp3" },
100
+ "pronunciation": { "ai": true, "src": "terms/bakkanpalmok.mp3" },
106
101
  "terms": [{ "$ref": "#/bakkat" }, { "$ref": "#/palmok" }],
107
102
  "type": "noun"
108
103
  },
104
+ "bakkat": {
105
+ "description": { "de": "nach außen", "en": "outside" },
106
+ "hangeul": "바깥",
107
+ "pronunciation": { "ai": true, "src": "terms/bakkat.mp3" }
108
+ },
109
109
  "bakkeuro": {
110
110
  "description": { "de": "nach außen", "en": "outward" },
111
111
  "hangeul": "밖으로",
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  },
50
50
  "type": "module",
51
51
  "types": "./src/database.ts",
52
- "version": "0.5.0"
52
+ "version": "0.6.0"
53
53
  }
package/src/database.ts CHANGED
@@ -19,6 +19,7 @@ import { composeDatabase, NO_BUILTINS } from "./compose.js";
19
19
  import { parseDescription } from "./description.js";
20
20
  import type { Grade } from "./grade.js";
21
21
  import { parseGrade } from "./grade.js";
22
+ import { findHierarchyErrors } from "./hierarchy.js";
22
23
  import { createTechniqueSearch, createTermSearch } from "./search.js";
23
24
 
24
25
  export type { ComposeOptions, Include, TechniqueGroupJson } from "./compose.js";
@@ -105,6 +106,10 @@ export class TaekwondoDatabase {
105
106
  this.json = { ...this.json, ...composed.customTechniques };
106
107
  this.loadTechniques(composed.customTechniques);
107
108
 
109
+ const hierarchyErrors = findHierarchyErrors(this.json);
110
+ if (hierarchyErrors.length > 0) {
111
+ throw new Error(hierarchyErrors.join("\n"));
112
+ }
108
113
  this.addReferences();
109
114
  this.assignGrades(composed.grades);
110
115
  }
@@ -399,10 +404,10 @@ export class TaekwondoDatabase {
399
404
  const entry = (this.json as any)[key] as TechniqueJson;
400
405
 
401
406
  if (entry.references) {
402
- technique.references = this.derefTechniqueReferences(
403
- technique,
404
- entry.references,
405
- );
407
+ technique.references = [
408
+ ...this.derefTechniqueReferences(technique, entry.references),
409
+ ...(technique.references ?? []),
410
+ ];
406
411
  }
407
412
  }
408
413
 
@@ -444,15 +449,13 @@ export class TaekwondoDatabase {
444
449
  };
445
450
  dereferenced.push(result);
446
451
 
447
- if (ref.type === "generic") {
448
- if (technique.references === undefined) {
449
- technique.references = [];
450
- }
451
- technique.references?.push({
452
- technique: referencingTechnique,
453
- type: "specialization",
454
- });
452
+ if (technique.references === undefined) {
453
+ technique.references = [];
455
454
  }
455
+ technique.references.push({
456
+ technique: referencingTechnique,
457
+ type: "specialization",
458
+ });
456
459
  }
457
460
  return dereferenced;
458
461
  }
@@ -0,0 +1,5 @@
1
+ import type { TechniqueJson } from "../types/technique";
2
+
3
+ export declare function findHierarchyErrors(
4
+ techniques: Record<string, TechniqueJson | string>,
5
+ ): string[];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The technique hierarchy is kept on the more specific technique only, as its
3
+ * `generic` reference; the reverse `specialization` is derived when loading.
4
+ * Every technique has at most one generic technique, and following them never
5
+ * leads back to where it started.
6
+ */
7
+ export function findHierarchyErrors(techniques) {
8
+ const errors = [];
9
+ const genericOf = new Map();
10
+ for (const [name, technique] of Object.entries(techniques)) {
11
+ if (typeof technique !== "object") continue;
12
+ const generic = [];
13
+ for (const ref of technique.references ?? []) {
14
+ if (ref.type === "generic") {
15
+ generic.push(ref.$ref.split("#/")[1]);
16
+ } else {
17
+ errors.push(
18
+ `Technique "${name}": reference type "${ref.type}" is not allowed — only "generic" is kept, on the more specific technique`,
19
+ );
20
+ }
21
+ }
22
+ if (generic.length > 1) {
23
+ errors.push(
24
+ `Technique "${name}" has more than one generic technique: ${generic.join(", ")}`,
25
+ );
26
+ }
27
+ if (generic.length > 0) genericOf.set(name, generic[0]);
28
+ }
29
+
30
+ const reported = new Set();
31
+ for (const name of genericOf.keys()) {
32
+ const chain = [name];
33
+ for (let next = genericOf.get(name); next; next = genericOf.get(next)) {
34
+ const start = chain.indexOf(next);
35
+ if (start !== -1) {
36
+ const cycle = chain.slice(start);
37
+ if (!cycle.some((member) => reported.has(member))) {
38
+ errors.push(
39
+ `Generic techniques form a cycle: ${[...cycle, next].join(" → ")}`,
40
+ );
41
+ }
42
+ for (const member of cycle) reported.add(member);
43
+ break;
44
+ }
45
+ chain.push(next);
46
+ }
47
+ }
48
+ return errors;
49
+ }
@@ -67,8 +67,11 @@ export interface TechniqueReference {
67
67
 
68
68
  export type Ref = { $ref: string };
69
69
 
70
- export interface TechniqueReferenceJson
71
- extends Omit<TechniqueReference & Ref, "technique"> {}
70
+ /** Kept on the more specific technique only; `specialization` is derived. */
71
+ export interface TechniqueReferenceJson extends Ref {
72
+ type: "generic";
73
+ description?: LocalizedString;
74
+ }
72
75
 
73
76
  export interface TechniqueJson
74
77
  extends Omit<