@taekwondo-db/database 0.6.2 → 0.8.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.
Files changed (124) hide show
  1. package/README.md +80 -15
  2. package/audio/chigi/mejumeok-bakkatchigi.mp3 +0 -0
  3. package/audio/chigi/palkkumchi-dollyeochigi.mp3 +0 -0
  4. package/audio/chigi/palkkumchi-geodeureo-dollyeochigi.mp3 +0 -0
  5. package/audio/chigi/sonnal-yeopchigi.mp3 +0 -0
  6. package/audio/jireugi/biteureojireugi.mp3 +0 -0
  7. package/audio/jireugi/dwitjumeok-jireugi.mp3 +0 -0
  8. package/audio/jireugi/jangaemul-nakbeop-jireugi.mp3 +0 -0
  9. package/audio/jjireugi/geodeureo-jjireugi.mp3 +0 -0
  10. package/audio/makgi/arae-yeommakgi.mp3 +0 -0
  11. package/audio/makgi/batangson-geodeureo-anmakgi.mp3 +0 -0
  12. package/audio/nakbeop/cheukbangnakbeop.mp3 +0 -0
  13. package/audio/nakbeop/gongjung-hoejeonnakbeop.mp3 +0 -0
  14. package/audio/nakbeop/hoejeongureugi.mp3 +0 -0
  15. package/audio/nakbeop/hubangnakbeop.mp3 +0 -0
  16. package/audio/nakbeop/jeonbangnakbeop.mp3 +0 -0
  17. package/audio/pihagi/sugyeopihagi.mp3 +0 -0
  18. package/audio/poomsae/chonkwon.mp3 +0 -0
  19. package/audio/poomsae/hansu.mp3 +0 -0
  20. package/audio/poomsae/ilyeo.mp3 +0 -0
  21. package/audio/poomsae/jitae.mp3 +0 -0
  22. package/audio/poomsae/keumgang.mp3 +0 -0
  23. package/audio/poomsae/koryo.mp3 +0 -0
  24. package/audio/poomsae/pyongwon.mp3 +0 -0
  25. package/audio/poomsae/shipjin.mp3 +0 -0
  26. package/audio/poomsae/taebaek.mp3 +0 -0
  27. package/audio/poomsae/taegeuk-1jang.mp3 +0 -0
  28. package/audio/poomsae/taegeuk-2jang.mp3 +0 -0
  29. package/audio/poomsae/taegeuk-3jang.mp3 +0 -0
  30. package/audio/poomsae/taegeuk-4jang.mp3 +0 -0
  31. package/audio/poomsae/taegeuk-5jang.mp3 +0 -0
  32. package/audio/poomsae/taegeuk-6jang.mp3 +0 -0
  33. package/audio/poomsae/taegeuk-7jang.mp3 +0 -0
  34. package/audio/poomsae/taegeuk-8jang.mp3 +0 -0
  35. package/audio/seogi/keun-naranhiseogi.mp3 +0 -0
  36. package/audio/terms/360do.mp3 +0 -0
  37. package/audio/terms/bakkwo.mp3 +0 -0
  38. package/audio/terms/cheukbang.mp3 +0 -0
  39. package/audio/terms/ditgo.mp3 +0 -0
  40. package/audio/terms/garigo.mp3 +0 -0
  41. package/audio/terms/gaseum.mp3 +0 -0
  42. package/audio/terms/gureugi.mp3 +0 -0
  43. package/audio/terms/hoejeon.mp3 +0 -0
  44. package/audio/terms/hoejeonhamyeo.mp3 +0 -0
  45. package/audio/terms/hubang.mp3 +0 -0
  46. package/audio/terms/jangaemul.mp3 +0 -0
  47. package/audio/terms/jase.mp3 +0 -0
  48. package/audio/terms/jeonbang.mp3 +0 -0
  49. package/audio/terms/junbijase.mp3 +0 -0
  50. package/audio/terms/nakbeop.mp3 +0 -0
  51. package/audio/terms/nun.mp3 +0 -0
  52. package/audio/terms/oebal.mp3 +0 -0
  53. package/audio/terms/sugyeo.mp3 +0 -0
  54. package/audio/terms/tucheok.mp3 +0 -0
  55. package/db/chagi.json +55 -89
  56. package/db/chigi.json +102 -14
  57. package/db/ditgi.json +10 -8
  58. package/db/jireugi.json +57 -12
  59. package/db/jjireugi.json +22 -5
  60. package/db/junbijase.json +226 -0
  61. package/db/kkeokgi.json +6 -5
  62. package/db/makgi.json +111 -20
  63. package/db/nakbeop.json +63 -0
  64. package/db/pihagi.json +11 -0
  65. package/db/poomsae/1-taegeuk-1jang.json +214 -0
  66. package/db/poomsae/2-taegeuk-2jang.json +227 -0
  67. package/db/poomsae/3-taegeuk-3jang.json +256 -0
  68. package/db/poomsae/4-taegeuk-4jang.json +267 -0
  69. package/db/poomsae/5-taegeuk-5jang.json +291 -0
  70. package/db/poomsae/6-taegeuk-6jang.json +292 -0
  71. package/db/poomsae/7-taegeuk-7jang.json +342 -0
  72. package/db/poomsae/8-taegeuk-8jang.json +377 -0
  73. package/db/poomsae/a-koryo.json +458 -0
  74. package/db/poomsae/b-keumgang.json +292 -0
  75. package/db/poomsae/c-taebaek.json +332 -0
  76. package/db/poomsae/d-pyongwon.json +289 -0
  77. package/db/poomsae/e-shipjin.json +301 -0
  78. package/db/poomsae/f-jitae.json +326 -0
  79. package/db/poomsae/g-chonkwon.json +340 -0
  80. package/db/poomsae/h-hansu.json +332 -0
  81. package/db/poomsae/i-ilyeo.json +287 -0
  82. package/db/schemas/grades.json +2 -2
  83. package/db/schemas/include.json +11 -0
  84. package/db/schemas/poomsae.json +221 -0
  85. package/db/schemas/terms.json +4 -0
  86. package/db/seogi.json +34 -225
  87. package/db/sources.json +7 -0
  88. package/db/terms.json +153 -3
  89. package/package.json +1 -1
  90. package/src/builtins-empty.js +1 -0
  91. package/src/builtins.d.ts +2 -0
  92. package/src/builtins.js +59 -0
  93. package/src/compose-builtins.js +2 -0
  94. package/src/compose.d.ts +10 -2
  95. package/src/compose.js +52 -7
  96. package/src/database.ts +145 -5
  97. package/src/grade.d.ts +3 -2
  98. package/types/poomsae.d.ts +136 -0
  99. package/types/source.d.ts +4 -1
  100. package/types/technique.d.ts +7 -1
  101. package/types/term.d.ts +13 -1
  102. package/audio/chagi/geodeup-apchagi.mp3 +0 -0
  103. package/audio/chagi/geodeup-dollyeochagi.mp3 +0 -0
  104. package/audio/chagi/geodeup-yeopchagi.mp3 +0 -0
  105. package/img/makgi/bakkanmakgi-front.jpg +0 -0
  106. package/img/makgi/bakkanmakgi-side.jpg +0 -0
  107. /package/audio/{seogi → junbijase}/bojumeokjunbi.mp3 +0 -0
  108. /package/audio/{seogi → junbijase}/gibonjunbi.mp3 +0 -0
  109. /package/audio/{seogi → junbijase}/gyeokpajunbi.mp3 +0 -0
  110. /package/audio/{seogi → junbijase}/gyeopsonjunbi.mp3 +0 -0
  111. /package/audio/{seogi → junbijase}/hakdariseogi-jageun-doljjeogwi.mp3 +0 -0
  112. /package/audio/{seogi → junbijase}/hosinjunbi.mp3 +0 -0
  113. /package/audio/{seogi → junbijase}/jageun-doljjeogwi.mp3 +0 -0
  114. /package/audio/{seogi → junbijase}/keun-doljjeogwi.mp3 +0 -0
  115. /package/audio/{seogi/kyorugiijunbi.mp3 → junbijase/kyorugijunbi.mp3} +0 -0
  116. /package/audio/{seogi → junbijase}/tongmilgijunbi.mp3 +0 -0
  117. /package/audio/kkeokgi/{songarakkeokgi.mp3 → songarakkkeokgi.mp3} +0 -0
  118. /package/img/{seogi → junbijase}/bojumeokjunbi-front.jpg +0 -0
  119. /package/img/{seogi → junbijase}/bojumeokjunbi-side.jpg +0 -0
  120. /package/img/{seogi → junbijase}/gibonjunbi-front.jpg +0 -0
  121. /package/img/{seogi → junbijase}/gyeopsonjunbi-front.jpg +0 -0
  122. /package/img/{seogi → junbijase}/keun-doljjeogwi-front.jpg +0 -0
  123. /package/img/{seogi → junbijase}/tongmilgijunbi-front.jpg +0 -0
  124. /package/img/makgi/{oesanmakgi-front.jpg → palmok-oesanmakgi-front.jpg} +0 -0
package/src/compose.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { PoomsaeEntryJson, PoomsaeJson } from "../types/poomsae";
1
2
  import type { SourcesJson } from "../types/source";
2
3
  import type {
3
4
  CustomTechniqueJson,
@@ -15,6 +16,8 @@ export interface Include {
15
16
  techniques?: Record<string, string[] | "*">;
16
17
  /** Builtin terms to load although no included technique uses them. */
17
18
  terms?: string[];
19
+ /** Builtin Poomsae in display order; `"*"` for all. None if omitted. */
20
+ poomsae?: string[] | "*";
18
21
  }
19
22
 
20
23
  export interface ComposeOptions {
@@ -32,24 +35,29 @@ export interface ComposeOptions {
32
35
  techniqueGroups?: Record<string, TechniqueGroupJson> | null;
33
36
  /** Own techniques that carry their own `group`. */
34
37
  customTechniques?: CustomTechniqueJson | null;
38
+ /** Own Poomsae; replace builtin ones with the same key. */
39
+ poomsae?: PoomsaeJson | null;
35
40
  /** Changes to existing techniques; see {@link applyPatch}. */
36
41
  patchTechniques?: PatchTechniqueJson | null;
37
42
  /** Changes to existing terms; see {@link applyPatch}. */
38
43
  patchTerms?: PatchTermJson | null;
39
44
  /**
40
- * From which grade on a technique is relevant, e.g. `{ "9-kup": ["Apchagi"] }`.
41
- * Every technique listed must be loaded, and listed only once.
45
+ * From which grade on a technique or Poomsae is relevant, e.g.
46
+ * `{ "8-kup": ["Taegeuk 1Jang", "Apchagi"] }`. Every technique and Poomsae
47
+ * listed must be loaded, and listed only once.
42
48
  */
43
49
  grades?: GradesJson | null;
44
50
  }
45
51
 
46
52
  export interface Builtins {
53
+ poomsae?: PoomsaeJson;
47
54
  sources: SourcesJson | Record<string, unknown>;
48
55
  techniqueGroups: Record<string, TechniqueGroupJson>;
49
56
  terms: Record<string, TermJson | string>;
50
57
  }
51
58
 
52
59
  export interface ComposedDatabase {
60
+ poomsae: Record<string, PoomsaeEntryJson>;
53
61
  sources: SourcesJson;
54
62
  techniqueGroups: Record<string, Record<string, TechniqueJson>>;
55
63
  customTechniques: Record<string, TechniqueJson>;
package/src/compose.js CHANGED
@@ -12,6 +12,7 @@ import { compareGrades, parseGrade } from "./grade.js";
12
12
 
13
13
  /** Builtins of a database built with `includeBuiltins: false`. */
14
14
  export const NO_BUILTINS = Object.freeze({
15
+ poomsae: {},
15
16
  sources: {},
16
17
  techniqueGroups: {},
17
18
  terms: {},
@@ -196,7 +197,41 @@ export function composeDatabase(options, builtins) {
196
197
  }
197
198
  }
198
199
 
199
- // 4. Terms. Own terms replace builtin ones with the same key.
200
+ // 4. Poomsae. Own ones replace builtin ones with the same key. Techniques
201
+ // that were left out stay as plain names, so the course is complete.
202
+ const builtinPoomsae = Object.fromEntries(entries(builtins.poomsae));
203
+ /** @type {Record<string, object>} */
204
+ const poomsae = {};
205
+ const pickedPoomsae = include ? (include.poomsae ?? []) : "*";
206
+ for (const name of pickedPoomsae === "*"
207
+ ? Object.keys(builtinPoomsae)
208
+ : pickedPoomsae) {
209
+ if (!builtinPoomsae[name]) {
210
+ throw new Error(`include: unknown Poomsae "${name}"`);
211
+ }
212
+ poomsae[name] = structuredClone(builtinPoomsae[name]);
213
+ }
214
+ for (const [name, entry] of entries(options.poomsae)) {
215
+ poomsae[name] = structuredClone(entry);
216
+ }
217
+ if (include) {
218
+ const dropRef = (part) => {
219
+ if (!part?.$ref) return;
220
+ const key = refKey(part);
221
+ if (groupOf.has(key) || !builtinNames.has(key)) return;
222
+ delete part.$ref;
223
+ part.name ??= key;
224
+ };
225
+ for (const { movements } of Object.values(poomsae)) {
226
+ for (const movement of movements) {
227
+ dropRef(movement.stance);
228
+ for (const part of movement.action ?? []) dropRef(part);
229
+ for (const part of movement.nameOfPoom) dropRef(part);
230
+ }
231
+ }
232
+ }
233
+
234
+ // 5. Terms. Own terms replace builtin ones with the same key.
200
235
  const termPool = Object.fromEntries(entries(builtins.terms));
201
236
  for (const [key, term] of entries(options.terms)) termPool[key] = term;
202
237
 
@@ -245,7 +280,7 @@ export function composeDatabase(options, builtins) {
245
280
  terms[key] = applyPatch(terms[key], patch, `${key}.`);
246
281
  }
247
282
 
248
- // 5. Sources. Own sources replace builtin ones with the same key.
283
+ // 6. Sources. Own sources replace builtin ones with the same key.
249
284
  /** @type {Record<string, object>} */
250
285
  let sources;
251
286
  if (include) {
@@ -262,6 +297,9 @@ export function composeDatabase(options, builtins) {
262
297
  }
263
298
  }
264
299
  for (const term of Object.values(terms)) collectHistoric(term.historic);
300
+ for (const entry of Object.values(poomsae)) {
301
+ for (const source of entry.sources ?? []) used.add(refKey(source));
302
+ }
265
303
 
266
304
  sources = {};
267
305
  for (const [key, source] of entries(builtins.sources)) {
@@ -272,7 +310,7 @@ export function composeDatabase(options, builtins) {
272
310
  }
273
311
  for (const [key, source] of entries(options.sources)) sources[key] = source;
274
312
 
275
- // 6. Grades — from which grade on a technique is relevant.
313
+ // 7. Grades — from which grade on a technique or Poomsae is relevant.
276
314
  /** @type {Record<string, string[]>} */
277
315
  const grades = {};
278
316
  /** technique name → grade it is listed at */
@@ -292,11 +330,11 @@ export function composeDatabase(options, builtins) {
292
330
 
293
331
  for (const { grade, names } of listed) {
294
332
  for (const name of names) {
295
- if (!groupOf.has(name)) {
333
+ if (!groupOf.has(name) && !poomsae[name]) {
296
334
  throw new Error(
297
- builtinNames.has(name)
335
+ builtinNames.has(name) || builtinPoomsae[name]
298
336
  ? `grades: "${name}" (${grade.key}) is not included`
299
- : `grades: unknown technique "${name}" (${grade.key})`,
337
+ : `grades: unknown technique or Poomsae "${name}" (${grade.key})`,
300
338
  );
301
339
  }
302
340
  if (gradeOf.has(name)) {
@@ -309,5 +347,12 @@ export function composeDatabase(options, builtins) {
309
347
  grades[grade.key] = [...names];
310
348
  }
311
349
 
312
- return { customTechniques, grades, sources, techniqueGroups: groups, terms };
350
+ return {
351
+ customTechniques,
352
+ grades,
353
+ poomsae,
354
+ sources,
355
+ techniqueGroups: groups,
356
+ terms,
357
+ };
313
358
  }
package/src/database.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import {
2
+ builtinPoomsae,
2
3
  builtinSources,
3
4
  builtinTechniqueGroups,
4
5
  builtinTerms,
5
6
  } from "@taekwondo-db/database/builtins";
6
7
  import type { Historic, HistoricJson } from "../types/historic";
8
+ import type {
9
+ Poomsae,
10
+ PoomsaeEntryJson,
11
+ PoomsaeJson,
12
+ PoomsaeMovement,
13
+ PoomsaeTechniqueJson,
14
+ } from "../types/poomsae";
7
15
  import type { Source, SourceJson, Sources, SourcesJson } from "../types/source";
8
16
  import type {
9
17
  Ref,
@@ -13,7 +21,7 @@ import type {
13
21
  TechniqueReference,
14
22
  TechniqueReferenceJson,
15
23
  } from "../types/technique.d.ts";
16
- import type { Term, TermJson, TermType } from "../types/term.d.ts";
24
+ import type { BodyPart, Term, TermJson, TermType } from "../types/term.d.ts";
17
25
  import type { ComposeOptions } from "./compose.js";
18
26
  import { composeDatabase, NO_BUILTINS } from "./compose.js";
19
27
  import { parseDescription } from "./description.js";
@@ -22,6 +30,15 @@ import { parseGrade } from "./grade.js";
22
30
  import { findHierarchyErrors } from "./hierarchy.js";
23
31
  import { createTechniqueSearch, createTermSearch } from "./search.js";
24
32
 
33
+ export type {
34
+ Poomsae,
35
+ PoomsaeActionTechnique,
36
+ PoomsaeJson,
37
+ PoomsaeMovement,
38
+ PoomsaeStance,
39
+ PoomsaeTechnique,
40
+ Side,
41
+ } from "../types/poomsae";
25
42
  export type { ComposeOptions, Include, TechniqueGroupJson } from "./compose.js";
26
43
  export { applyPatch } from "./compose.js";
27
44
  export type { DescriptionSegmentJson, RefKind } from "./description.js";
@@ -68,11 +85,13 @@ export class TaekwondoDatabase {
68
85
  private techniques = new Map<string, Technique>();
69
86
  private terms = new Map<string, Term>();
70
87
  private sources = new Map<string, Sources>();
88
+ private poomsae = new Map<string, Poomsae>();
71
89
  private json: Record<string, TechniqueJson | string> = {};
72
90
  private allTermJson: Record<string, TermJson | string> = {};
73
91
  private groups: TechniqueGroup[] = [];
74
92
  private grades: Grade[] = [];
75
93
  private gradeTechniques = new Map<string, Technique[]>();
94
+ private gradePoomsae = new Map<string, Poomsae[]>();
76
95
 
77
96
  constructor(options: DatabaseOptions = {}) {
78
97
  const includeBuiltins = options.includeBuiltins ?? true;
@@ -83,6 +102,7 @@ export class TaekwondoDatabase {
83
102
  options,
84
103
  includeBuiltins
85
104
  ? {
105
+ poomsae: builtinPoomsae,
86
106
  sources: builtinSources,
87
107
  techniqueGroups: builtinTechniqueGroups,
88
108
  terms: builtinTerms,
@@ -111,6 +131,7 @@ export class TaekwondoDatabase {
111
131
  throw new Error(hierarchyErrors.join("\n"));
112
132
  }
113
133
  this.addReferences();
134
+ this.loadPoomsae(composed.poomsae);
114
135
  this.assignGrades(composed.grades);
115
136
  }
116
137
 
@@ -176,6 +197,14 @@ export class TaekwondoDatabase {
176
197
  return this.sources.entries();
177
198
  }
178
199
 
200
+ public getPoomsae(key: string): Poomsae | undefined {
201
+ return this.poomsae.get(key);
202
+ }
203
+
204
+ public getAllPoomsae(): MapIterator<[string, Poomsae]> {
205
+ return this.poomsae.entries();
206
+ }
207
+
179
208
  public getGroups(): TechniqueGroup[] {
180
209
  return [...this.groups];
181
210
  }
@@ -196,6 +225,11 @@ export class TaekwondoDatabase {
196
225
  return [...(this.gradeTechniques.get(key) ?? [])];
197
226
  }
198
227
 
228
+ /** The Poomsae that become relevant at this grade, in the given order. */
229
+ public getPoomsaeByGrade(key: string): Poomsae[] {
230
+ return [...(this.gradePoomsae.get(key) ?? [])];
231
+ }
232
+
199
233
  public searchTechniques(input: string, lang: string): Technique[] {
200
234
  return createTechniqueSearch([...this.techniques.values()], lang)(input);
201
235
  }
@@ -226,12 +260,117 @@ export class TaekwondoDatabase {
226
260
  private assignGrades(grades: Record<string, string[]>) {
227
261
  for (const [key, names] of Object.entries(grades)) {
228
262
  const grade = parseGrade(key) as Grade;
229
- const techniques = names.map(
230
- (name) => this.techniques.get(name) as Technique,
231
- );
232
- for (const technique of techniques) technique.grade = grade;
263
+ const techniques: Technique[] = [];
264
+ const poomsae: Poomsae[] = [];
265
+ for (const name of names) {
266
+ const technique = this.techniques.get(name);
267
+ const entry = technique ?? (this.poomsae.get(name) as Poomsae);
268
+ entry.grade = grade;
269
+ if (technique) techniques.push(technique);
270
+ else poomsae.push(entry as Poomsae);
271
+ }
233
272
  this.grades.push(grade);
234
273
  this.gradeTechniques.set(key, techniques);
274
+ this.gradePoomsae.set(key, poomsae);
275
+ }
276
+ }
277
+
278
+ private loadPoomsae(json: PoomsaeJson) {
279
+ for (const [key, entry] of Object.entries(json)) {
280
+ if (typeof entry === "string") {
281
+ continue;
282
+ }
283
+
284
+ this.poomsae.set(key, this.buildPoomsae(key, entry));
285
+ }
286
+ }
287
+
288
+ private buildPoomsae(key: string, entry: PoomsaeEntryJson): Poomsae {
289
+ const { sources, ...rest } = entry;
290
+ const poomsae: Poomsae = { ...rest, movements: [], name: key };
291
+ if (sources) {
292
+ poomsae.sources = this.buildMultipleSources(sources);
293
+ for (const source of poomsae.sources) {
294
+ source.type.poomsae ??= [];
295
+ source.type.poomsae.push(poomsae);
296
+ }
297
+ }
298
+
299
+ /** The technique of a `$ref`, or just the name where there is none. */
300
+ const resolve = (part: Ref | { name: string }) => {
301
+ if (!("$ref" in part)) return { name: part.name };
302
+ const name = "name" in part ? (part.name as string) : undefined;
303
+ const technique = this.deref(this.techniques, part);
304
+ if (technique === undefined) {
305
+ throw new Error(
306
+ `Poomsae "${key}": could not find technique reference: ${part.$ref}`,
307
+ );
308
+ }
309
+ technique.poomsae ??= [];
310
+ if (!technique.poomsae.includes(poomsae)) technique.poomsae.push(poomsae);
311
+ return { name: name ?? technique.name, technique };
312
+ };
313
+
314
+ const resolveAll = <T extends PoomsaeTechniqueJson>(parts: T[]) =>
315
+ parts.map((part) => ({
316
+ ...resolve(part),
317
+ ...(part.side && { side: part.side }),
318
+ ...("kihap" in part && { kihap: part.kihap as boolean }),
319
+ ...("eyeDir" in part && { eyeDir: part.eyeDir as string }),
320
+ ...("inPlace" in part && { inPlace: part.inPlace as boolean }),
321
+ }));
322
+
323
+ this.checkDiagram(key, entry);
324
+
325
+ for (const { stance, action, nameOfPoom, ...rest } of entry.movements) {
326
+ const movement: PoomsaeMovement = {
327
+ ...rest,
328
+ nameOfPoom: resolveAll(nameOfPoom),
329
+ };
330
+ if (stance) {
331
+ movement.stance = {
332
+ ...resolve(stance),
333
+ ...(stance.side && { side: stance.side }),
334
+ };
335
+ }
336
+ if (action) movement.action = resolveAll(action);
337
+ poomsae.movements.push(movement);
338
+ }
339
+ return poomsae;
340
+ }
341
+
342
+ /**
343
+ * The diagram must hold every point its lines pass through and every
344
+ * position; an eye direction may also be a bare direction such as "Ga".
345
+ */
346
+ private checkDiagram(key: string, entry: PoomsaeEntryJson) {
347
+ const { diagram } = entry;
348
+ if (!diagram) return;
349
+ const fail = (message: string) => {
350
+ throw new Error(`Poomsae "${key}": ${message}`);
351
+ };
352
+ const has = (point: string) => Object.hasOwn(diagram.points, point);
353
+ for (const point of diagram.lines.flat()) {
354
+ if (!has(point)) fail(`diagram line passes unknown point: ${point}`);
355
+ }
356
+ for (const { order, position, eyeDir, action = [] } of entry.movements) {
357
+ if (!has(position)) {
358
+ fail(
359
+ `movement ${order}: position is no point of the diagram: ${position}`,
360
+ );
361
+ }
362
+ // An action may look its own way, e.g. a kick before turning.
363
+ for (const look of [eyeDir, ...action.map((a) => a.eyeDir)]) {
364
+ if (
365
+ look !== undefined &&
366
+ !has(look) &&
367
+ !/^(Ga|Na|Da|Ra|Ma)$/.test(look)
368
+ ) {
369
+ fail(
370
+ `movement ${order}: eye direction is no point of the diagram: ${look}`,
371
+ );
372
+ }
373
+ }
235
374
  }
236
375
  }
237
376
 
@@ -307,6 +446,7 @@ export class TaekwondoDatabase {
307
446
  hangeul: entry.hangeul,
308
447
  hanja: entry.hanja,
309
448
  name: key,
449
+ ...(entry.bodyPart && { bodyPart: entry.bodyPart as BodyPart }),
310
450
  ...(entry.pronunciation && { pronunciation: entry.pronunciation }),
311
451
  type: entry.type as TermType | undefined,
312
452
  };
package/src/grade.d.ts CHANGED
@@ -8,9 +8,10 @@ export interface Grade {
8
8
  }
9
9
 
10
10
  /**
11
- * From which grade on a technique is relevant, keyed by grade
11
+ * From which grade on a technique or Poomsae is relevant, keyed by grade
12
12
  * (`"10-kup"` … `"1-kup"`, `"1-poom"` … `"4-poom"`, `"1-dan"` … `"9-dan"`).
13
- * Each technique is listed at most once, at the first grade it belongs to.
13
+ * Each technique and Poomsae is listed at most once, at the first grade it
14
+ * belongs to.
14
15
  */
15
16
  export interface GradesJson {
16
17
  [grade: string]: string[] | string;
@@ -0,0 +1,136 @@
1
+ import type { Grade } from "../src/grade";
2
+ import type { LocalizedString } from "./localized-string";
3
+ import type { Pronunciation } from "./pronunciation";
4
+ import type { Source, SourceJson } from "./source";
5
+ import type { Ref, Technique } from "./technique";
6
+
7
+ /** Apps may show it in Korean: Wen (left), Oreun (right). */
8
+ export type Side = "left" | "right";
9
+
10
+ export interface Poomsae {
11
+ /** The name as the Kukkiwon writes it, e.g. "Taegeuk 1Jang" — also the map key. */
12
+ name: string;
13
+ /** The name in Revised Romanization, where it differs, e.g. "Taegeuk Iljang". */
14
+ supplementaryName?: string;
15
+ hangeul: string;
16
+ /** The Korean name, spoken. */
17
+ pronunciation?: Pronunciation;
18
+ /** Free-form notes on the Poomsae as a whole; may contain `#[...]` references. */
19
+ description?: LocalizedString;
20
+ /** Where the course is described, e.g. a page of the Kukkiwon's textbook. */
21
+ sources?: Source[];
22
+ videos?: {
23
+ link: string;
24
+ name: string;
25
+ }[];
26
+ /** The Poomsae line, to draw it; see {@link PoomsaeDiagram}. */
27
+ diagram?: PoomsaeDiagram;
28
+ /** The course in order; the first movement is Junbi, the last Baro. */
29
+ movements: PoomsaeMovement[];
30
+ /** From which grade on the Poomsae is relevant — set via `DatabaseOptions.grades`. */
31
+ grade?: Grade;
32
+ }
33
+
34
+ /**
35
+ * The Poomsae line, seen from above: Na at the top, Ga at the bottom,
36
+ * Da on the right — x grows toward Da, y toward Ga.
37
+ */
38
+ export interface PoomsaeDiagram {
39
+ /**
40
+ * Where each point lies, as [x, y], keyed by its name such as "Da①". A
41
+ * point off the lines only marks a direction. Every position of the
42
+ * movements is a point; an eye direction may also be a bare direction
43
+ * such as "Ga".
44
+ */
45
+ points: Record<string, [number, number]>;
46
+ /** The line, drawn as polylines through the points. */
47
+ lines: string[][];
48
+ }
49
+
50
+ export interface PoomsaeMovement {
51
+ /** The number of the movement; Junbi first, Baro last. */
52
+ order: "Junbi" | number | "Baro";
53
+ /** The eye direction, a point of the Poomsae line such as "Da①". */
54
+ eyeDir: string;
55
+ /** Where the movement ends. */
56
+ position: string;
57
+ /** The stance the movement ends in. */
58
+ stance?: PoomsaeStance;
59
+ /** The techniques executed on the way, in order; may contain stances. */
60
+ action?: PoomsaeActionTechnique[];
61
+ /** The techniques the movement is named after. */
62
+ nameOfPoom: PoomsaeTechnique[];
63
+ kihap?: boolean;
64
+ /**
65
+ * true: the movement takes no step — it is executed where the movement
66
+ * before ended, its position only naming the direction it faces, e.g.
67
+ * Geumgangmakgi in Ilyeo. false: it takes a step even where it only turns
68
+ * to look elsewhere. Not part of the Kukkiwon's table.
69
+ */
70
+ inPlace?: boolean;
71
+ /** What is special about the movement; may contain `#[...]` references. */
72
+ note?: LocalizedString;
73
+ }
74
+
75
+ export interface PoomsaeStance {
76
+ name: string;
77
+ /** Missing if the database does not have or did not load it. */
78
+ technique?: Technique;
79
+ /**
80
+ * As the Kukkiwon names the stance: the foot in front or crossing, but the
81
+ * supporting leg of Dwitgubi and of stances on one leg.
82
+ */
83
+ side?: Side;
84
+ }
85
+
86
+ export interface PoomsaeTechnique {
87
+ /** The name the Poomsae uses; may be a variant of the technique, e.g. Ttwieo Yeopchagi for Ttwieochagi. */
88
+ name: string;
89
+ /** Missing if the database does not have or did not load it. */
90
+ technique?: Technique;
91
+ /** The side that executes the technique. */
92
+ side?: Side;
93
+ /**
94
+ * The technique takes no step: it is executed where the step before
95
+ * ended. Not part of the Kukkiwon's table.
96
+ */
97
+ inPlace?: boolean;
98
+ }
99
+
100
+ export interface PoomsaeActionTechnique extends PoomsaeTechnique {
101
+ kihap?: boolean;
102
+ /**
103
+ * Where the technique looks, if not where the movement does — e.g. a kick
104
+ * toward Ga before turning to Da②. Not part of the Kukkiwon's table.
105
+ */
106
+ eyeDir?: string;
107
+ }
108
+
109
+ type RefOrName = Ref | { name: string };
110
+
111
+ export type PoomsaeStanceJson = RefOrName & { side?: Side };
112
+ /** With `$ref`, `name` is a variant the technique covers, e.g. Ttwieo Yeopchagi. */
113
+ export type PoomsaeTechniqueJson = (RefOrName | (Ref & { name: string })) & {
114
+ side?: Side;
115
+ inPlace?: boolean;
116
+ };
117
+ export type PoomsaeActionTechniqueJson = PoomsaeTechniqueJson & {
118
+ kihap?: boolean;
119
+ eyeDir?: string;
120
+ };
121
+
122
+ export interface PoomsaeMovementJson
123
+ extends Omit<PoomsaeMovement, "stance" | "action" | "nameOfPoom"> {
124
+ stance?: PoomsaeStanceJson;
125
+ action?: PoomsaeActionTechniqueJson[];
126
+ nameOfPoom: PoomsaeTechniqueJson[];
127
+ }
128
+
129
+ export interface PoomsaeEntryJson
130
+ extends Omit<Poomsae, "name" | "movements" | "grade" | "sources"> {
131
+ movements: PoomsaeMovementJson[];
132
+ sources?: SourceJson[];
133
+ }
134
+
135
+ /** The shape of a file in `db/poomsae/`, and of own Poomsae; string values (`$schema`) are skipped on load. */
136
+ export type PoomsaeJson = Record<string, PoomsaeEntryJson | string>;
package/types/source.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Historic } from "./historic";
2
2
  import type { LocalizedString } from "./localized-string";
3
+ import type { Poomsae } from "./poomsae";
3
4
  import type { Ref, Technique } from "./technique";
4
5
 
5
6
  export interface Source {
@@ -19,6 +20,8 @@ export interface Sources {
19
20
  /** Backlink, populated while loading. */
20
21
  techniques?: Technique[];
21
22
  /** Backlink, populated while loading. */
23
+ poomsae?: Poomsae[];
24
+ /** Backlink, populated while loading. */
22
25
  historic?: Historic[];
23
26
  }
24
27
 
@@ -26,7 +29,7 @@ export type SourceType = "book";
26
29
 
27
30
  /** A source as written in `db/sources.json` — key and backlinks are added on load. */
28
31
  export interface SourceEntryJson
29
- extends Omit<Sources, "name" | "techniques" | "historic"> {}
32
+ extends Omit<Sources, "name" | "techniques" | "historic" | "poomsae"> {}
30
33
 
31
34
  /** The shape of `db/sources.json`; string values (`$schema`) are skipped on load. */
32
35
  export type SourcesJson = Record<string, SourceEntryJson | string>;
@@ -2,6 +2,7 @@ import type { Grade } from "../src/grade";
2
2
  import type { Historic, HistoricJson } from "./historic";
3
3
  import type { Image } from "./image";
4
4
  import type { LocalizedString } from "./localized-string";
5
+ import type { Poomsae } from "./poomsae";
5
6
  import type { Pronunciation } from "./pronunciation";
6
7
  import type { Source, SourceJson } from "./source";
7
8
  import type { Term } from "./term";
@@ -21,7 +22,9 @@ export type BuiltinTechniqueGroup =
21
22
  | "pihagi"
22
23
  | "japgi"
23
24
  | "ppaegi"
24
- | "jjireugi";
25
+ | "jjireugi"
26
+ | "junbijase"
27
+ | "nakbeop";
25
28
 
26
29
  /**
27
30
  * A technique group name. Consumers may define their own groups via
@@ -57,6 +60,8 @@ export interface Technique {
57
60
  }[];
58
61
  /** From which grade on the technique is relevant — set via `DatabaseOptions.grades`. */
59
62
  grade?: Grade;
63
+ /** Poomsae that use the technique — backlink, populated while loading. */
64
+ poomsae?: Poomsae[];
60
65
  }
61
66
 
62
67
  export interface TechniqueReference {
@@ -84,6 +89,7 @@ export interface TechniqueJson
84
89
  | "historic"
85
90
  | "sources"
86
91
  | "grade"
92
+ | "poomsae"
87
93
  > {
88
94
  terms: Ref[];
89
95
  references?: TechniqueReferenceJson[];
package/types/term.d.ts CHANGED
@@ -5,12 +5,16 @@ import type { PatchJson, Ref, Technique } from "./technique";
5
5
 
6
6
  export type TermType = "noun" | "verb" | "adjective" | "adverb" | "modifier";
7
7
 
8
+ /** The body region of a term that names a part of the body. */
9
+ export type BodyPart = "head" | "trunk" | "arm" | "hand" | "leg" | "foot";
10
+
8
11
  export interface Term {
9
12
  name: string;
10
13
  hangeul: string;
11
14
  hanja?: string;
12
15
  pronunciation?: Pronunciation;
13
16
  type?: TermType;
17
+ bodyPart?: BodyPart;
14
18
  lemma?: Term;
15
19
  description: LocalizedString;
16
20
  forms?: Term[];
@@ -23,12 +27,20 @@ export interface Term {
23
27
  export interface TermJson
24
28
  extends Omit<
25
29
  Term,
26
- "historic" | "name" | "lemma" | "type" | "forms" | "terms" | "combinations"
30
+ | "historic"
31
+ | "name"
32
+ | "lemma"
33
+ | "type"
34
+ | "bodyPart"
35
+ | "forms"
36
+ | "terms"
37
+ | "combinations"
27
38
  > {
28
39
  historic?: HistoricJson[];
29
40
  lemma?: Ref;
30
41
  terms?: Ref[];
31
42
  type?: string;
43
+ bodyPart?: string;
32
44
  }
33
45
 
34
46
  export interface CustomTermJson {
Binary file
Binary file
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes