@taekwondo-db/database 0.0.0-stage → 0.2.3

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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +282 -2
  3. package/db/chagi.json +720 -0
  4. package/db/chigi.json +1153 -0
  5. package/db/ditgi.json +101 -0
  6. package/db/japgi.json +154 -0
  7. package/db/jireugi.json +458 -0
  8. package/db/jjireugi.json +111 -0
  9. package/db/kkeokgi.json +58 -0
  10. package/db/makgi.json +1447 -0
  11. package/db/milgi.json +63 -0
  12. package/db/neomgigi.json +45 -0
  13. package/db/pihagi.json +68 -0
  14. package/db/ppaegi.json +174 -0
  15. package/db/schemas/grades.json +22 -0
  16. package/db/schemas/historic.json +21 -0
  17. package/db/schemas/image.json +24 -0
  18. package/db/schemas/include.json +31 -0
  19. package/db/schemas/localized-string.json +17 -0
  20. package/db/schemas/patches.json +12 -0
  21. package/db/schemas/source.json +12 -0
  22. package/db/schemas/sources.json +22 -0
  23. package/db/schemas/techniques.json +86 -0
  24. package/db/schemas/terms.json +52 -0
  25. package/db/seogi.json +602 -0
  26. package/db/sources.json +29 -0
  27. package/db/terms.json +995 -0
  28. package/db/ttwigi.json +59 -0
  29. package/dist/search.browser.js +1197 -0
  30. package/index.js +1 -0
  31. package/package.json +50 -5
  32. package/src/builtins-empty.d.ts +1 -0
  33. package/src/builtins-empty.js +10 -0
  34. package/src/builtins.d.ts +10 -0
  35. package/src/builtins.js +46 -0
  36. package/src/compose-builtins.d.ts +11 -0
  37. package/src/compose-builtins.js +39 -0
  38. package/src/compose.d.ts +76 -0
  39. package/src/compose.js +313 -0
  40. package/src/database.ts +457 -0
  41. package/src/description.d.ts +13 -0
  42. package/src/description.js +63 -0
  43. package/src/grade.d.ts +22 -0
  44. package/src/grade.js +44 -0
  45. package/src/search.d.ts +31 -0
  46. package/src/search.js +59 -0
  47. package/types/historic.d.ts +13 -0
  48. package/types/image.d.ts +9 -0
  49. package/types/localized-string.d.ts +3 -0
  50. package/types/source.d.ts +34 -0
  51. package/types/technique.d.ts +114 -0
  52. package/types/term.d.ts +38 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 taekwondo-db contributors
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 CHANGED
@@ -1,3 +1,283 @@
1
- # Temporary Holding Version
1
+ # Taekwondo Technique Database
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An open JSON database of Taekwondo techniques, terms and sources based on
4
+ published Kukkiwon material, and a small library to load, select, adjust and
5
+ search it. Unofficial; not endorsed by Kukkiwon.
6
+
7
+ [`@taekwondo-db/web-app`](https://gitlab.com/taekwondo-db/taekwondo-db.gitlab.io)
8
+ renders it as a website: <https://taekwondo-db.gitlab.io/>.
9
+
10
+ **Contents:** all 14 Kukkiwon technique groups — seogi, makgi, ditgi, ttwigi,
11
+ pihagi, ppaegi, jireugi, jjireugi, chigi, japgi, milgi, kkeokgi, neomgigi,
12
+ chagi. Translations in German (`de`) and English
13
+ (`en`); Korean is given by the Hangeul of the terms.
14
+
15
+ ## Data
16
+
17
+ ```
18
+ db/<group>.json techniques of one group, keyed by their official name
19
+ db/terms.json Korean terms the technique names are built from
20
+ db/sources.json books and other sources
21
+ db/schemas/ JSON Schemas of all of the above, and of apps' own files
22
+ img/<group>/ illustrations (CC BY 4.0, see License)
23
+ ```
24
+
25
+ ### Techniques
26
+
27
+ ```json
28
+ "Dwikkoaseogi": {
29
+ "translation": { "de": "Hinterer Kreuzstand", "en": "Back cross stance" },
30
+ "terms": [
31
+ { "$ref": "./terms.json#/dwi" },
32
+ { "$ref": "./terms.json#/kkoa" },
33
+ { "$ref": "./terms.json#/seogi" }
34
+ ],
35
+ "references": [{ "$ref": "#/Kkoaseogi", "type": "generic" }],
36
+ "weight": { "front": 10, "back": 90 },
37
+ "sources": [{ "$ref": "./sources.json#/kukkiwon_2022_book_2", "page": "99" }]
38
+ }
39
+ ```
40
+
41
+ | Field | Meaning |
42
+ |---|---|
43
+ | key | the official Kukkiwon name in Revised Romanization; also the lookup key and URL segment |
44
+ | `translation` | the name in each language. Required, searchable |
45
+ | `supplementaryName` | an alternative romanized name in use. Searchable |
46
+ | `description` | free text per language; may [reference](#references-in-descriptions) techniques and terms. Not searched |
47
+ | `terms` | the name word by word; `$space` stands for a space |
48
+ | `references` | related techniques; `generic` marks the general technique this one is a variant of, `specialization` the reverse |
49
+ | `generic` | the technique is itself a generic term |
50
+ | `sources`, `historic`, `videos`, `images`, `weight` | citations, historic names, video links, [images](#images), weight distribution of stances |
51
+
52
+ `$ref` paths are a convention: only the part after `#/` is looked up.
53
+
54
+ ### Terms
55
+
56
+ ```json
57
+ "chagi": { "hangeul": "차기", "description": { "en": "kick" } }
58
+ ```
59
+
60
+ Keyed in Revised Romanization with the pronunciation rules applied. Optional:
61
+ `hanja`, `type`, `lemma`, `terms`, `historic`.
62
+
63
+ ### References in descriptions
64
+
65
+ | Syntax | Refers to |
66
+ |---|---|
67
+ | `#[Ieochagi]` | technique — the key starts upper-case |
68
+ | `#[palmok]` | term — the key starts lower-case |
69
+ | `#[Apchagi\|Apchagis]` | the same, with another label |
70
+ | `#[technique:Jireugi]`, `#[term:jireugi]` | explicit kind |
71
+
72
+ ### Images
73
+
74
+ ```json
75
+ "images": [
76
+ { "src": "seogi/apgubi.jpg", "ai": true },
77
+ { "src": "seogi/apgubi-detail.jpg", "description": { "de": "Beinarbeit im Detail" } }
78
+ ]
79
+ ```
80
+
81
+ `src` is relative to `img/`, with extension (`.jpg`, `.jpeg`, `.png`, `.webp`,
82
+ `.avif`, `.svg`), no leading `/` and no `..`. `description` serves as caption
83
+ and alt text; `ai: true` marks images created or substantially altered by
84
+ generative AI.
85
+
86
+ ## Library
87
+
88
+ Published on npm as
89
+ [`@taekwondo-db/database`](https://www.npmjs.com/package/@taekwondo-db/database):
90
+
91
+ ```bash
92
+ pnpm add @taekwondo-db/database # or: npm install @taekwondo-db/database
93
+ ```
94
+
95
+ ```js
96
+ import { TaekwondoDatabase } from "@taekwondo-db/database";
97
+
98
+ const db = new TaekwondoDatabase();
99
+ db.searchTechniques("Hakdari", "en"); // [Hakdariseogi, …]
100
+ ```
101
+
102
+ The package ships TypeScript (`src/database.ts`). Use it through a bundler or a
103
+ loader that strips types; Node does not strip types below `node_modules`.
104
+
105
+ ### Options
106
+
107
+ | Option | Meaning |
108
+ |---|---|
109
+ | `includeBuiltins` | load the bundled Kukkiwon data. Default `true` |
110
+ | `include` | load only these bundled techniques, see below |
111
+ | `patchTechniques`, `patchTerms` | change bundled techniques and terms, see below |
112
+ | `techniqueGroups` | own techniques, keyed by group; an existing group is extended |
113
+ | `customTechniques` | own techniques that carry their own `group` |
114
+ | `terms`, `sources` | own terms and sources; replace bundled ones of the same key |
115
+ | `grades` | from which grade on a technique is taught, see below |
116
+
117
+ An own technique must not have the name of a bundled one — patch that instead.
118
+ Group names are not a closed set.
119
+
120
+ #### `include`
121
+
122
+ ```js
123
+ { techniques: { seogi: ["Naranhiseogi", "Apseogi"], chagi: "*" }, terms: ["juchum"] }
124
+ ```
125
+
126
+ Techniques by group, in display order; `"*"` loads a whole group. Terms and
127
+ sources follow from what is loaded — directly or through `lemma` and `terms`;
128
+ `terms` adds bundled terms nothing uses. References to techniques left out are
129
+ dropped. Unknown names, wrong groups and patches of techniques left out are
130
+ errors.
131
+
132
+ #### Patches
133
+
134
+ Keyed by technique or term; a patch changes only what it mentions:
135
+
136
+ | Patch value | Effect |
137
+ |---|---|
138
+ | object (`translation`, `description`, …) | merged — `{ "de": … }` keeps `en` |
139
+ | array (`videos`, `images`, `sources`, …) | appended |
140
+ | `null` | removes the field |
141
+ | `{ "$replace": value }` | replaces the field as a whole |
142
+ | `{ "$append": "text" }` | appends to a text, separated by a space |
143
+ | anything else | overwrites |
144
+
145
+ ```js
146
+ {
147
+ Dollyeochagi: {
148
+ description: { de: { $append: "Eigener Zusatz." } },
149
+ videos: [{ link: "https://…", name: "Training" }],
150
+ historic: null,
151
+ },
152
+ }
153
+ ```
154
+
155
+ #### `grades`
156
+
157
+ ```js
158
+ { "9-kup": ["Apgubi", "Araemakgi"], "8-kup": ["Apseogi"] }
159
+ ```
160
+
161
+ Kukkiwon prescribes no grades per technique; a club states from which grade on
162
+ a technique is taught. Keys are `10-kup` … `1-kup`, `1-poom` … `4-poom`,
163
+ `1-dan` … `9-dan`. A technique is listed once, at its first grade. Unknown
164
+ grades or techniques and duplicates are errors.
165
+
166
+ ### Methods
167
+
168
+ | Method | Returns |
169
+ |---|---|
170
+ | `getTechnique(key)`, `getTerm(key)`, `getSource(key)` | one entry with its references resolved, or `undefined` |
171
+ | `getAllTechniques()`, `getAllTerms()`, `getAllSources()` | iterators of `[key, entry]` |
172
+ | `getGroups()`, `getTechniquesByGroup(group)` | the group names; the techniques of one group in order |
173
+ | `getGrades()`, `getTechniquesByGrade(key)` | the grades in use, lowest first; the techniques of one grade |
174
+ | `searchTechniques(input, lang)` | fuzzy search over name, `supplementaryName` and `translation` |
175
+ | `searchTerms(input, lang)` | fuzzy search over name and `description` |
176
+ | `resolveDescription(text)` | the text split into plain text and resolved references; references to what is not loaded become text |
177
+
178
+ Also exported: `applyPatch(target, patch)`, `parseDescription(text)`,
179
+ `stripRefs(text)`, `parseGrade(key)`, `compareGrades(a, b)`,
180
+ `createTechniqueSearch`, `createTermSearch` (see below).
181
+
182
+ ### Searching an own index
183
+
184
+ The search of `searchTechniques` and `searchTerms` is also available on its
185
+ own, for an app that searches a compact index instead of the loaded database —
186
+ e.g. in the browser:
187
+
188
+ ```js
189
+ import { createTechniqueSearch, createTermSearch } from "@taekwondo-db/database/search";
190
+
191
+ const search = createTechniqueSearch(index.techniques, "de");
192
+ search("Reitstand"); // the matching index entries, best first
193
+ ```
194
+
195
+ Entries need `name` and optionally `supplementaryName` and `translation`
196
+ (techniques) or `description` (terms) — localized objects as in the database,
197
+ or strings already in one language. Other fields are passed through.
198
+
199
+ `@taekwondo-db/database/search.browser.js` is the same module bundled with
200
+ Fuse.js: one ES module without imports, to serve as is.
201
+
202
+ ### Composing in Node
203
+
204
+ ```js
205
+ import { builtinImageDir, composeDatabase } from "@taekwondo-db/database/compose";
206
+
207
+ const json = composeDatabase({ include, patchTechniques, grades });
208
+ new TaekwondoDatabase({ includeBuiltins: false, ...json });
209
+ ```
210
+
211
+ Applies the options to the JSON in plain JavaScript, e.g. at build time, so an
212
+ app ships only the result. `builtinImageDir` is the absolute path of `img/`.
213
+ Bundlers can drop the bundled data altogether by aliasing
214
+ `@taekwondo-db/database/builtins` to `@taekwondo-db/database/builtins-empty`.
215
+
216
+ ### Schemas for apps
217
+
218
+ Own files can point their `$schema` at `db/schemas/include.json`,
219
+ `patches.json`, `grades.json`, `techniques.json`, `terms.json` or
220
+ `sources.json`. The include and patch schemas describe only the shape: patched
221
+ results are checked against the technique and term schemas, names when the
222
+ database is built.
223
+
224
+ ## Development
225
+
226
+ The tools come from the Nix flake: Node.js, pnpm, Biome and TypeScript 7
227
+ (`tsc`), pinned in `flake.lock`. CI runs every job in the same dev shell, so
228
+ local and CI versions are identical.
229
+
230
+ ```bash
231
+ nix develop # enter the dev shell (or use direnv with `use flake`)
232
+ pnpm install
233
+ pnpm test # vitest
234
+ pnpm typecheck # tsc
235
+ pnpm build # dist/search.browser.js; also runs before packing
236
+ pnpm validate # data against the schemas, references, image files
237
+ pnpm lint # biome
238
+ ```
239
+
240
+ `nix flake update` moves all tools to the latest versions of the pinned
241
+ nixpkgs release branch.
242
+
243
+ ### Releasing
244
+
245
+ 1. Set `version` in `package.json` and merge.
246
+ 2. Push a tag `v<version>`, e.g. `v0.1.1`. After lint, typecheck, validate and
247
+ test pass, the `publish` job stages the package on npmjs.com
248
+ (`npm stage publish`).
249
+ 3. Then GitLab's
250
+ [`create-release`](https://gitlab.com/components/toolkit) component creates
251
+ a GitLab release for the tag. Its notes come from GitLab's
252
+ [changelog](https://docs.gitlab.com/user/project/changelogs/): every commit
253
+ since the previous version tag whose message carries a `Changelog` trailer,
254
+ grouped by its value (`added`, `fixed`, `changed`, `deprecated`, `removed`,
255
+ `security`, `performance`, `other`):
256
+
257
+ ```
258
+ feat: add Naranhiseogi
259
+
260
+ Changelog: added
261
+ ```
262
+
263
+ Commits without the trailer are left out. When a merge request is squashed,
264
+ put the trailer into the first commit (or the squash commit message).
265
+ 4. Approve the staged version with 2FA, on npmjs.com or with
266
+ `npm stage list @taekwondo-db/database` and `npm stage approve <stage-id>`.
267
+ Only then is it public.
268
+
269
+ The `publish` job authenticates via npm trusted publishing (GitLab OIDC); no
270
+ npm token is stored in GitLab. The trusted publisher on npmjs.com only needs
271
+ the permission to stage, not to publish directly.
272
+
273
+ ## Contributing
274
+
275
+ Only additions backed by an official source are accepted. Keep changes small —
276
+ one technique per merge request where possible.
277
+
278
+ ## License
279
+
280
+ | Part | License |
281
+ |---|---|
282
+ | Code, schemas and the data in `db/` | [MIT](LICENSE) |
283
+ | Images in `img/` | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), see [`img/LICENSE.md`](img/LICENSE.md) |