Metadata-Version: 2.4
Name: dhis2w-core
Version: 1.19.0
Summary: Shared DHIS2 tooling runtime: profile discovery, plugin registry, auth factory, token store, first-party plugins.
Author: Morten Hansen
Author-email: Morten Hansen <morten@winterop.com>
License-Expression: LicenseRef-Proprietary
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: dhis2w-client>=1.19.0,<2.0
Requires-Dist: pydantic>=2.13
Requires-Dist: pydantic-settings>=2.13
Requires-Dist: tomli-w>=1.2
Requires-Dist: typer>=0.26.8
Requires-Dist: rich>=15
Requires-Dist: fastmcp>=3.4.7
Requires-Dist: sqlalchemy[asyncio]>=2.0.52
Requires-Dist: aiosqlite>=0.22
Requires-Dist: bcrypt>=5.0.0
Requires-Dist: questionary>=2.1.1
Requires-Dist: pluginkit>=0.5.1
Requires-Dist: pytest>=9.1.1 ; extra == 'testing'
Requires-Dist: pytest-asyncio>=1.4 ; extra == 'testing'
Requires-Dist: pytest-httpx2>=1.0.0 ; extra == 'testing'
Requires-Dist: respx>=0.23 ; extra == 'testing'
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/winterop-com/dhis2w
Project-URL: Documentation, https://winterop-com.github.io/dhis2w/
Project-URL: Repository, https://github.com/winterop-com/dhis2w
Project-URL: Changelog, https://github.com/winterop-com/dhis2w/blob/main/CHANGELOG.md
Provides-Extra: testing
Description-Content-Type: text/markdown

# dhis2w-core

Shared runtime for `dhis2w-cli` and `dhis2w-mcp`: profile discovery, plugin registry, auth factory, token store, and the first-party plugins (metadata, data, analytics, users, tracker, files, messaging, apps, route, maintenance, doctor, customize, system, profile, dev).

`dhis2w-core` is the bridge between `dhis2w-client` (the pure async API client) and the user-facing surfaces (CLI, MCP). End users typically don't install this directly — they install `dhis2w-cli` or `dhis2w-mcp` which pull `dhis2w-core` in transitively.

## Install

```bash
# Direct (rare — usually you want dhis2w-cli or dhis2w-mcp instead)
uv add dhis2w-core
```

## What's in the box

- **Profile system** — auto-discovers a profile from `.dhis2/profiles.toml` (CWD walk-up) or `~/.config/dhis2/profiles.toml`. `Profile` model + `profile_from_env()` env-var fallback.
- **Plugin host** — a [pluginkit](https://pypi.org/project/pluginkit/) manager that walks `dhis2w_core.v{41,42,43}.plugins.*` plus the `dhis2w.plugins.v1` entry-point group for external packs. Each plugin answers the `contribute(version_key)` extension point with a `Contribution` naming its CLI and MCP modules.
- **Auth factory** — turns a `Profile` into the matching `AuthProvider` from `dhis2w-client`, wires the token store, manages OAuth2 PKCE redirect capture.
- **Token store** — SQLite-backed (`aiosqlite`) at `.dhis2/tokens.sqlite`, keyed by profile name.
- **`open_client(profile)` context manager** — the canonical "give me a connected client" entry point for plugin services.

## Plugins shipped

`metadata`, `data`, `analytics`, `tracker`, `user`, `user_group`, `user_role`, `route`, `apps`, `messaging`, `files`, `maintenance`, `doctor`, `customize`, `system`, `profile`, `dev`, `browser` (CLI-only, opt-in via `[browser]` extra).

Each plugin lives at `packages/dhis2w-core/src/dhis2w_core/v{41,42,43}/plugins/<name>/` (per-version subpackage; one tree per DHIS2 major) with `service.py` (typed business logic), `cli.py` (Typer commands), and `mcp.py` (FastMCP tools) — both surfaces call the same `service.py`.

## Documentation

Full architecture: https://winterop-com.github.io/dhis2w/architecture/overview/.

`dhis2w-core` is one member of the [`dhis2w`](https://github.com/winterop-com/dhis2w) workspace.
