turbo-ea-capabilities 2026.4.26__tar.gz
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.
- turbo_ea_capabilities-2026.4.26/.gitignore +39 -0
- turbo_ea_capabilities-2026.4.26/PKG-INFO +87 -0
- turbo_ea_capabilities-2026.4.26/README.md +60 -0
- turbo_ea_capabilities-2026.4.26/pyproject.toml +58 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/__init__.py +33 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/_loader.py +150 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/_models.py +63 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/_version.py +26 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/data/.gitkeep +0 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/data/capabilities.json +43255 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/data/tree.json +39212 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/data/version.json +7 -0
- turbo_ea_capabilities-2026.4.26/src/turbo_ea_capabilities/py.typed +0 -0
- turbo_ea_capabilities-2026.4.26/tests/conftest.py +36 -0
- turbo_ea_capabilities-2026.4.26/tests/fixtures/capabilities.json +46 -0
- turbo_ea_capabilities-2026.4.26/tests/fixtures/tree.json +48 -0
- turbo_ea_capabilities-2026.4.26/tests/fixtures/version.json +6 -0
- turbo_ea_capabilities-2026.4.26/tests/test_loader.py +95 -0
- turbo_ea_capabilities-2026.4.26/tests/test_models.py +52 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Build artefacts
|
|
2
|
+
dist/
|
|
3
|
+
.astro/
|
|
4
|
+
|
|
5
|
+
# Package data is generated by scripts/build_pkg.ts (excluding .gitkeep)
|
|
6
|
+
packages/py/src/turbo_ea_capabilities/data/*.json
|
|
7
|
+
|
|
8
|
+
# Node
|
|
9
|
+
node_modules/
|
|
10
|
+
npm-debug.log*
|
|
11
|
+
yarn-debug.log*
|
|
12
|
+
yarn-error.log*
|
|
13
|
+
.pnpm-debug.log*
|
|
14
|
+
|
|
15
|
+
# Python
|
|
16
|
+
__pycache__/
|
|
17
|
+
*.py[cod]
|
|
18
|
+
*$py.class
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.eggs/
|
|
21
|
+
build/
|
|
22
|
+
*.egg
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
.tox/
|
|
26
|
+
htmlcov/
|
|
27
|
+
.venv/
|
|
28
|
+
venv/
|
|
29
|
+
packages/py/dist/
|
|
30
|
+
|
|
31
|
+
# OS
|
|
32
|
+
.DS_Store
|
|
33
|
+
Thumbs.db
|
|
34
|
+
|
|
35
|
+
# IDE
|
|
36
|
+
.idea/
|
|
37
|
+
.vscode/
|
|
38
|
+
*.swp
|
|
39
|
+
*~
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: turbo-ea-capabilities
|
|
3
|
+
Version: 2026.4.26
|
|
4
|
+
Summary: Reference Business Capability catalogue for Turbo EA - bundled JSON, no network access required.
|
|
5
|
+
Project-URL: Homepage, https://business-capabilities.turbo-ea.org
|
|
6
|
+
Project-URL: Source, https://github.com/vincentmakes/turbo-ea-capabilities
|
|
7
|
+
Project-URL: Issues, https://github.com/vincentmakes/turbo-ea-capabilities/issues
|
|
8
|
+
Author: Turbo EA Maintainers
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: business-capability,catalogue,enterprise-architecture,togaf
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# turbo-ea-capabilities
|
|
29
|
+
|
|
30
|
+
Reference Business Capability catalogue for [Turbo EA](https://turbo-ea.org), bundled as a Python package.
|
|
31
|
+
|
|
32
|
+
All catalogue data ships inside the wheel — no network access required at runtime. Designed for offline / airgapped Turbo EA deployments.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install turbo-ea-capabilities
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from turbo_ea_capabilities import (
|
|
44
|
+
load_all,
|
|
45
|
+
load_tree,
|
|
46
|
+
get_by_id,
|
|
47
|
+
get_children,
|
|
48
|
+
get_subtree,
|
|
49
|
+
get_ancestors,
|
|
50
|
+
VERSION,
|
|
51
|
+
SCHEMA_VERSION,
|
|
52
|
+
GENERATED_AT,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
print(f"Catalogue {VERSION} (schema v{SCHEMA_VERSION}), built {GENERATED_AT}")
|
|
56
|
+
print(f"{len(load_all())} capabilities")
|
|
57
|
+
|
|
58
|
+
root = get_subtree("BC-2")
|
|
59
|
+
for child in root.children:
|
|
60
|
+
print(f" {child.id} {child.name}")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API
|
|
64
|
+
|
|
65
|
+
| Function | Returns |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `load_all()` | `list[Capability]` — flat, every node, sorted by id |
|
|
68
|
+
| `load_tree()` | `list[Capability]` — nested, one entry per L1 |
|
|
69
|
+
| `get_by_id(id)` | `Capability \| None` |
|
|
70
|
+
| `get_children(id)` | `list[Capability]` — direct children only |
|
|
71
|
+
| `get_subtree(id)` | `Capability \| None` — node with `.children` populated recursively |
|
|
72
|
+
| `get_ancestors(id)` | `list[Capability]` — root → parent (excludes the node itself) |
|
|
73
|
+
|
|
74
|
+
`Capability` is a frozen Pydantic v2 model — see `_models.py`.
|
|
75
|
+
|
|
76
|
+
## Versioning
|
|
77
|
+
|
|
78
|
+
Two version numbers travel together:
|
|
79
|
+
|
|
80
|
+
- `VERSION` — semver of the catalogue content.
|
|
81
|
+
- `SCHEMA_VERSION` — integer; bumps only on non-additive field/value changes.
|
|
82
|
+
|
|
83
|
+
Pin against `SCHEMA_VERSION` to detect breaking shape changes; pin against `VERSION` minor for additive content updates.
|
|
84
|
+
|
|
85
|
+
## Source
|
|
86
|
+
|
|
87
|
+
The catalogue YAML and build pipeline live at <https://github.com/vincentmakes/turbo-ea-capabilities>.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# turbo-ea-capabilities
|
|
2
|
+
|
|
3
|
+
Reference Business Capability catalogue for [Turbo EA](https://turbo-ea.org), bundled as a Python package.
|
|
4
|
+
|
|
5
|
+
All catalogue data ships inside the wheel — no network access required at runtime. Designed for offline / airgapped Turbo EA deployments.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install turbo-ea-capabilities
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from turbo_ea_capabilities import (
|
|
17
|
+
load_all,
|
|
18
|
+
load_tree,
|
|
19
|
+
get_by_id,
|
|
20
|
+
get_children,
|
|
21
|
+
get_subtree,
|
|
22
|
+
get_ancestors,
|
|
23
|
+
VERSION,
|
|
24
|
+
SCHEMA_VERSION,
|
|
25
|
+
GENERATED_AT,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
print(f"Catalogue {VERSION} (schema v{SCHEMA_VERSION}), built {GENERATED_AT}")
|
|
29
|
+
print(f"{len(load_all())} capabilities")
|
|
30
|
+
|
|
31
|
+
root = get_subtree("BC-2")
|
|
32
|
+
for child in root.children:
|
|
33
|
+
print(f" {child.id} {child.name}")
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
| Function | Returns |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `load_all()` | `list[Capability]` — flat, every node, sorted by id |
|
|
41
|
+
| `load_tree()` | `list[Capability]` — nested, one entry per L1 |
|
|
42
|
+
| `get_by_id(id)` | `Capability \| None` |
|
|
43
|
+
| `get_children(id)` | `list[Capability]` — direct children only |
|
|
44
|
+
| `get_subtree(id)` | `Capability \| None` — node with `.children` populated recursively |
|
|
45
|
+
| `get_ancestors(id)` | `list[Capability]` — root → parent (excludes the node itself) |
|
|
46
|
+
|
|
47
|
+
`Capability` is a frozen Pydantic v2 model — see `_models.py`.
|
|
48
|
+
|
|
49
|
+
## Versioning
|
|
50
|
+
|
|
51
|
+
Two version numbers travel together:
|
|
52
|
+
|
|
53
|
+
- `VERSION` — semver of the catalogue content.
|
|
54
|
+
- `SCHEMA_VERSION` — integer; bumps only on non-additive field/value changes.
|
|
55
|
+
|
|
56
|
+
Pin against `SCHEMA_VERSION` to detect breaking shape changes; pin against `VERSION` minor for additive content updates.
|
|
57
|
+
|
|
58
|
+
## Source
|
|
59
|
+
|
|
60
|
+
The catalogue YAML and build pipeline live at <https://github.com/vincentmakes/turbo-ea-capabilities>.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.21"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "turbo-ea-capabilities"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Reference Business Capability catalogue for Turbo EA - bundled JSON, no network access required."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "Turbo EA Maintainers" }]
|
|
13
|
+
keywords = ["enterprise-architecture", "business-capability", "togaf", "catalogue"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pydantic>=2.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = [
|
|
32
|
+
"pytest>=8",
|
|
33
|
+
"pytest-cov>=5",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://business-capabilities.turbo-ea.org"
|
|
38
|
+
Source = "https://github.com/vincentmakes/turbo-ea-capabilities"
|
|
39
|
+
Issues = "https://github.com/vincentmakes/turbo-ea-capabilities/issues"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.version]
|
|
42
|
+
source = "code"
|
|
43
|
+
path = "src/turbo_ea_capabilities/_version.py"
|
|
44
|
+
expression = "VERSION"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["src/turbo_ea_capabilities"]
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.sdist]
|
|
50
|
+
include = [
|
|
51
|
+
"/src",
|
|
52
|
+
"/tests",
|
|
53
|
+
"/README.md",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
testpaths = ["tests"]
|
|
58
|
+
addopts = "-q"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Reference Business Capability catalogue.
|
|
2
|
+
|
|
3
|
+
All data is bundled inside the wheel - no network access required.
|
|
4
|
+
"""
|
|
5
|
+
from ._loader import (
|
|
6
|
+
GENERATED_AT,
|
|
7
|
+
NODE_COUNT,
|
|
8
|
+
SCHEMA_VERSION,
|
|
9
|
+
VERSION,
|
|
10
|
+
get_ancestors,
|
|
11
|
+
get_by_id,
|
|
12
|
+
get_children,
|
|
13
|
+
get_subtree,
|
|
14
|
+
iter_subtree,
|
|
15
|
+
load_all,
|
|
16
|
+
load_tree,
|
|
17
|
+
)
|
|
18
|
+
from ._models import Capability
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"Capability",
|
|
22
|
+
"GENERATED_AT",
|
|
23
|
+
"NODE_COUNT",
|
|
24
|
+
"SCHEMA_VERSION",
|
|
25
|
+
"VERSION",
|
|
26
|
+
"get_ancestors",
|
|
27
|
+
"get_by_id",
|
|
28
|
+
"get_children",
|
|
29
|
+
"get_subtree",
|
|
30
|
+
"iter_subtree",
|
|
31
|
+
"load_all",
|
|
32
|
+
"load_tree",
|
|
33
|
+
]
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""Load the bundled JSON catalogue via importlib.resources.
|
|
2
|
+
|
|
3
|
+
`importlib.resources.files()` works correctly with wheels, editable installs,
|
|
4
|
+
zipapps, PyInstaller, and Docker layers - no `__file__` hacks.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from functools import lru_cache
|
|
10
|
+
from importlib.resources import as_file, files
|
|
11
|
+
from typing import Iterable, Optional
|
|
12
|
+
|
|
13
|
+
from ._models import Capability
|
|
14
|
+
|
|
15
|
+
_PACKAGE = "turbo_ea_capabilities"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _read_json(name: str) -> object:
|
|
19
|
+
res = files(_PACKAGE) / "data" / name
|
|
20
|
+
with as_file(res) as path:
|
|
21
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@lru_cache(maxsize=1)
|
|
25
|
+
def _flat_records() -> tuple[Capability, ...]:
|
|
26
|
+
raw = _read_json("capabilities.json")
|
|
27
|
+
if not isinstance(raw, list):
|
|
28
|
+
raise RuntimeError("capabilities.json must be a list")
|
|
29
|
+
return tuple(Capability.model_validate(r) for r in raw)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@lru_cache(maxsize=1)
|
|
33
|
+
def _tree_records() -> tuple[Capability, ...]:
|
|
34
|
+
raw = _read_json("tree.json")
|
|
35
|
+
if not isinstance(raw, list):
|
|
36
|
+
raise RuntimeError("tree.json must be a list")
|
|
37
|
+
return tuple(Capability.model_validate(r) for r in raw)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@lru_cache(maxsize=1)
|
|
41
|
+
def _by_id() -> dict[str, Capability]:
|
|
42
|
+
out: dict[str, Capability] = {}
|
|
43
|
+
for c in _flat_records():
|
|
44
|
+
out[c.id] = c
|
|
45
|
+
return out
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@lru_cache(maxsize=1)
|
|
49
|
+
def _children_index() -> dict[str, tuple[Capability, ...]]:
|
|
50
|
+
"""Map parent_id -> tuple of direct children, sorted by id."""
|
|
51
|
+
parent_to_children: dict[str, list[Capability]] = {}
|
|
52
|
+
for c in _flat_records():
|
|
53
|
+
if c.parent_id is None:
|
|
54
|
+
continue
|
|
55
|
+
parent_to_children.setdefault(c.parent_id, []).append(c)
|
|
56
|
+
return {
|
|
57
|
+
pid: tuple(sorted(kids, key=_compare_key))
|
|
58
|
+
for pid, kids in parent_to_children.items()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _compare_key(c: Capability) -> tuple[int, ...]:
|
|
63
|
+
return tuple(int(s) for s in c.id.removeprefix("BC-").split("."))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@lru_cache(maxsize=1)
|
|
67
|
+
def _version_meta() -> dict:
|
|
68
|
+
raw = _read_json("version.json")
|
|
69
|
+
if not isinstance(raw, dict):
|
|
70
|
+
raise RuntimeError("version.json must be an object")
|
|
71
|
+
return raw
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# ---------------------------------------------------------------------------
|
|
75
|
+
# Public API
|
|
76
|
+
# ---------------------------------------------------------------------------
|
|
77
|
+
def load_all() -> list[Capability]:
|
|
78
|
+
"""Flat list of every capability, sorted by id."""
|
|
79
|
+
return list(_flat_records())
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def load_tree() -> list[Capability]:
|
|
83
|
+
"""Nested tree (one entry per L1), each with `.children` populated."""
|
|
84
|
+
return list(_tree_records())
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_by_id(capability_id: str) -> Optional[Capability]:
|
|
88
|
+
return _by_id().get(capability_id)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def get_children(capability_id: str) -> list[Capability]:
|
|
92
|
+
return list(_children_index().get(capability_id, ()))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def get_subtree(capability_id: str) -> Optional[Capability]:
|
|
96
|
+
"""Return the node with `.children` populated recursively."""
|
|
97
|
+
flat = _by_id().get(capability_id)
|
|
98
|
+
if flat is None:
|
|
99
|
+
return None
|
|
100
|
+
return _hydrate(flat)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _hydrate(node: Capability) -> Capability:
|
|
104
|
+
kids = _children_index().get(node.id, ())
|
|
105
|
+
if not kids:
|
|
106
|
+
return node
|
|
107
|
+
hydrated = tuple(_hydrate(k) for k in kids)
|
|
108
|
+
return node.model_copy(update={"children": hydrated})
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def get_ancestors(capability_id: str) -> list[Capability]:
|
|
112
|
+
"""Root → parent path (excludes the node itself).
|
|
113
|
+
|
|
114
|
+
Returns an empty list for the root or for an unknown id.
|
|
115
|
+
"""
|
|
116
|
+
by_id = _by_id()
|
|
117
|
+
node = by_id.get(capability_id)
|
|
118
|
+
if node is None:
|
|
119
|
+
return []
|
|
120
|
+
chain: list[Capability] = []
|
|
121
|
+
cursor = node
|
|
122
|
+
while cursor.parent_id is not None:
|
|
123
|
+
parent = by_id.get(cursor.parent_id)
|
|
124
|
+
if parent is None:
|
|
125
|
+
break
|
|
126
|
+
chain.append(parent)
|
|
127
|
+
cursor = parent
|
|
128
|
+
chain.reverse()
|
|
129
|
+
return chain
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def iter_subtree(capability_id: str) -> Iterable[Capability]:
|
|
133
|
+
"""BFS-order iterator over a node and its descendants (parent before child)."""
|
|
134
|
+
root = _by_id().get(capability_id)
|
|
135
|
+
if root is None:
|
|
136
|
+
return
|
|
137
|
+
queue: list[Capability] = [root]
|
|
138
|
+
children_index = _children_index()
|
|
139
|
+
while queue:
|
|
140
|
+
cur = queue.pop(0)
|
|
141
|
+
yield cur
|
|
142
|
+
queue.extend(children_index.get(cur.id, ()))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Module-level constants
|
|
146
|
+
_meta = _version_meta()
|
|
147
|
+
VERSION: str = str(_meta.get("catalogue_version", "0.0.0"))
|
|
148
|
+
SCHEMA_VERSION: str = str(_meta.get("schema_version", "0"))
|
|
149
|
+
GENERATED_AT: str = str(_meta.get("generated_at", ""))
|
|
150
|
+
NODE_COUNT: int = int(_meta.get("node_count", 0))
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Pydantic v2 model for a Business Capability.
|
|
2
|
+
|
|
3
|
+
Mirrors `schema/capability.schema.json` in the source repo. The flat-form data
|
|
4
|
+
file (`capabilities.json`) stores `children` as a list of child ids; the nested
|
|
5
|
+
tree file (`tree.json`) stores it as a list of `Capability` objects. The model
|
|
6
|
+
accepts both shapes and the loader normalises them for you.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any, Optional
|
|
11
|
+
|
|
12
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Capability(BaseModel):
|
|
16
|
+
model_config = ConfigDict(frozen=True, extra="forbid")
|
|
17
|
+
|
|
18
|
+
id: str
|
|
19
|
+
name: str
|
|
20
|
+
level: int = Field(ge=1, le=4)
|
|
21
|
+
parent_id: Optional[str] = None
|
|
22
|
+
|
|
23
|
+
description: Optional[str] = None
|
|
24
|
+
aliases: tuple[str, ...] = ()
|
|
25
|
+
owner: Optional[str] = None
|
|
26
|
+
tags: tuple[str, ...] = ()
|
|
27
|
+
industry: Optional[str] = None
|
|
28
|
+
references: tuple[str, ...] = ()
|
|
29
|
+
in_scope: tuple[str, ...] = ()
|
|
30
|
+
out_of_scope: tuple[str, ...] = ()
|
|
31
|
+
|
|
32
|
+
deprecated: bool = False
|
|
33
|
+
deprecation_reason: Optional[str] = None
|
|
34
|
+
successor_id: Optional[str] = None
|
|
35
|
+
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
36
|
+
|
|
37
|
+
children: tuple["Capability", ...] = ()
|
|
38
|
+
|
|
39
|
+
@field_validator("aliases", "tags", "references", "in_scope", "out_of_scope", mode="before")
|
|
40
|
+
@classmethod
|
|
41
|
+
def _coerce_to_tuple(cls, v: Any) -> tuple[str, ...]:
|
|
42
|
+
if v is None:
|
|
43
|
+
return ()
|
|
44
|
+
if isinstance(v, (list, tuple)):
|
|
45
|
+
return tuple(v)
|
|
46
|
+
raise TypeError(f"Expected list/tuple, got {type(v).__name__}")
|
|
47
|
+
|
|
48
|
+
@field_validator("children", mode="before")
|
|
49
|
+
@classmethod
|
|
50
|
+
def _coerce_children(cls, v: Any) -> Any:
|
|
51
|
+
# Accept either a list of ids (from capabilities.json flat form), in
|
|
52
|
+
# which case we strip them — the loader rebuilds children from the
|
|
53
|
+
# full id->Capability map. Or a list of dicts/Capability objects from
|
|
54
|
+
# tree.json, which we pass through.
|
|
55
|
+
if v is None:
|
|
56
|
+
return ()
|
|
57
|
+
if isinstance(v, (list, tuple)) and v and isinstance(v[0], str):
|
|
58
|
+
return ()
|
|
59
|
+
return v
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Forward-ref rebuild for Pydantic v2.
|
|
63
|
+
Capability.model_rebuild()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Hatch version source.
|
|
2
|
+
|
|
3
|
+
Reads the catalogue version from the bundled `data/version.json` file. Falls
|
|
4
|
+
back to `0.0.0` if the data has not been built yet (so editable installs work
|
|
5
|
+
even before the first build).
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
_VERSION_PATH = Path(__file__).parent / "data" / "version.json"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _read() -> str:
|
|
16
|
+
if not _VERSION_PATH.exists():
|
|
17
|
+
return "0.0.0"
|
|
18
|
+
raw = json.loads(_VERSION_PATH.read_text(encoding="utf-8"))
|
|
19
|
+
cv = str(raw.get("catalogue_version", "0.0.0"))
|
|
20
|
+
# Hatch wants a PEP 440-compatible version. The build pipeline emits
|
|
21
|
+
# `<lasttag>+<sha>` for non-tagged builds — that is already PEP 440 local-
|
|
22
|
+
# version syntax, so we pass it through.
|
|
23
|
+
return cv
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
VERSION: str = _read()
|
|
File without changes
|