onix-engine 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 onix-codelists 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/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ ONIX Engine project code is licensed under the MIT License; see LICENSE.
2
+
3
+ The ONIX for Books schemas, codelists, and derived schema data in this project
4
+ remain copyright © EDItEUR. They are used under the EDItEUR licence,
5
+ https://doi.org/10.4400/nwgj. EDItEUR is the authority for the ONIX standard.
6
+
7
+ This project does not grant permission to modify or redistribute EDItEUR source
8
+ material beyond the applicable EDItEUR licence, and does not represent arbitrary
9
+ XML extensions as ONIX standards-compliant.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # onix-engine
2
+
3
+ `onix-engine` provides programmatic access to official ONIX for Books codelists and the English Thema classification: retrieve codes, headings, and (for Thema) hierarchy and usage notes. It is deliberately not an ONIX XML parser, validator, or search engine.
4
+
5
+ The included data is generated from **EDItEUR ONIX for Books Codelists Issue 74** and **Thema v1.6**. EDItEUR remains the authority for both datasets.
6
+
7
+ ONIX-derived schemas and data remain © EDItEUR and are used under the EDItEUR licence (DOI [10.4400/nwgj](https://doi.org/10.4400/nwgj)). See [NOTICE](NOTICE). The project code itself is MIT licensed.
8
+
9
+ For the project's long-term transition into a general-purpose ONIX implementation toolkit, see [the architecture direction](ARCHITECTURE.md).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pnpm add onix-engine
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import {
21
+ getCodelistEntries,
22
+ getCodelistEntry,
23
+ getCodelistHeading,
24
+ hasCodelistCode,
25
+ metadata,
26
+ getThemaChildren,
27
+ getThemaEntry,
28
+ themaMetadata,
29
+ } from "onix-engine";
30
+
31
+ const subjectSchemes = getCodelistEntries(27);
32
+ const thema = getCodelistEntry(27, "93");
33
+ const themaHeading = getCodelistHeading(27, "93");
34
+ const valid = hasCodelistCode(27, "93");
35
+
36
+ console.log(metadata.issue); // 74
37
+
38
+ const arts = getThemaEntry("A");
39
+ const artsTopics = getThemaChildren("A");
40
+ const rootCategories = getThemaChildren();
41
+
42
+ console.log(arts?.note);
43
+ console.log(themaMetadata.version); // "v1.6.0"
44
+ ```
45
+
46
+ To retrieve a complete list, use `getCodelist(27)`. `getCodelists()` returns lightweight `{ number, heading }` summaries. Codes are always strings, so leading zeroes such as `"01"` are preserved.
47
+
48
+ Entries work directly as form options:
49
+
50
+ ```tsx
51
+ const options = getCodelistEntries(27).map(({ code, heading }) => ({
52
+ value: code,
53
+ label: `${code} — ${heading}`,
54
+ }));
55
+ ```
56
+
57
+ Thema entries include `parentCode` for hierarchy navigation and `note` when the
58
+ official source supplies usage guidance. Use `getThemaEntries()` to retrieve the
59
+ complete flat list, `getThemaEntry(code)` or `getThemaHeading(code)` for lookup,
60
+ and `hasThemaCode(code)` for validation.
61
+
62
+ ## Browser demo
63
+
64
+ After installing dependencies, start the local codelist browser with:
65
+
66
+ ```bash
67
+ pnpm demo
68
+ ```
69
+
70
+ It opens a Vite development server where you can switch between ONIX codelists
71
+ and Thema, then filter entries by code or heading.
72
+
73
+ ## Updating the source data
74
+
75
+ Place exactly one official ONIX export named
76
+ `ONIX_BookProduct_Codelists_Issue_<issue>.json` and exactly one English Thema
77
+ export named `<YYYYMMDD>_Thema_v<version>_en.json` in `data/raw/`, then run:
78
+
79
+ ```bash
80
+ pnpm generate
81
+ pnpm validate:data
82
+ pnpm test
83
+ ```
84
+
85
+ The importer never modifies files in `data/raw/`. It writes normalized JSON under `data/generated/` and runtime TypeScript modules under `src/generated/`; both are generated files and must not be edited manually. The official JSON contains the human-readable codelist titles, including lists with no entries.
86
+
87
+ Additional ONIX fields (notes and issue-added, issue-modified, and issue-deprecated values) are retained in `data/generated/codelists.json` for future expansion, while the ONIX public entry API intentionally exposes only `code` and `heading`. Thema’s public entries expose `code`, `heading`, `parentCode`, and `note`.