Metadata-Version: 2.4
Name: invenio-pidbox
Version: 0.1.15
Summary: InvenioRDM PIDBox integration for people and organizations profile templates.
Project-URL: Homepage, https://codeberg.org/front-matter/invenio-pidbox
Project-URL: Repository, https://codeberg.org/front-matter/invenio-pidbox
Project-URL: Bug Tracker, https://codeberg.org/front-matter/invenio-pidbox/issues
License: MIT
License-File: LICENSE
Keywords: author,invenio,organization,pidbox,profiles
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.14
Requires-Dist: commonmeta-py[backend]>=0.269
Requires-Dist: commonmeta-rs>=0.9.73
Requires-Dist: invenio-app-rdm>=14.0.0
Provides-Extra: docs
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == 'docs'
Requires-Dist: sphinx>=5.0.0; extra == 'docs'
Provides-Extra: tests
Requires-Dist: invenio-app>=1.4.0; extra == 'tests'
Requires-Dist: pytest-black>=0.3.0; extra == 'tests'
Requires-Dist: pytest-isort>=3.1.0; extra == 'tests'
Requires-Dist: pytest<9,>=7.4.0; extra == 'tests'
Description-Content-Type: text/markdown

# invenio-pidbox

InvenioRDM integration for people and organization profile templates backed by the commonmeta SQLite store.

## Features

- Ships people and organization profile templates for InvenioRDM
- Injects template context for /people/<orcid> and /organizations/<ror> routes
- Reads ORCID and ROR profiles from the commonmeta SQLite store via commonmeta-py and commonmeta-rs
- Uses the pid_annotations cache layer instead of application-specific people or organizations tables
- Mirrors the profile integration approach used in rogue-scholar
- Provides pidbox-backed deposit autocomplete endpoints for creators and affiliations
- Uses commonmeta-rs Tantivy search for deposit autocomplete suggestions
- Registers deposit form overridable components to route autocomplete calls to pidbox when configured

## Requirements

- Python 3.14+
- A commonmeta SQLite database readable through commonmeta-rs

The extension resolves profile data from the path configured in PIDBOX_SQLITE_PATH.
Internally, commonmeta-rs reads pid_annotations records with source_id 4 for people
(ORCID) and source_id 3 for organizations (ROR).

## Installation

```bash
uv add invenio-pidbox
```

This package depends on commonmeta-py, commonmeta-rs, and invenio-app-rdm at
runtime, so installing invenio-pidbox pulls in the profile backend automatically.

If the profile store lives outside the default commonmeta location, configure
PIDBOX_SQLITE_PATH in your Invenio application.

## Configuration

### Required

- PIDBOX_SQLITE_PATH

Path to the commonmeta SQLite store used for profile pages and pidbox autocomplete.

### Optional deposit autocomplete configuration

- APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES
- APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES_PROVIDER
- PIDBOX_AUTOCOMPLETE_API

To enable pidbox autocomplete in the deposit form, set:

```python
APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES = "search"
APP_RDM_DEPOSIT_FORM_AUTOCOMPLETE_NAMES_PROVIDER = "pidbox"
```

By default, pidbox autocomplete endpoints are:

- /api/pidbox/names
- /api/pidbox/affiliations

You can override those URLs with:

```python
PIDBOX_AUTOCOMPLETE_API = {
	"names": "/api/pidbox/names",
	"affiliations": "/api/pidbox/affiliations",
}
```

## How It Works

When a request path matches /people/<orcid> or /organizations/<ror>, the extension
loads the corresponding commonmeta record from SQLite and exposes template-friendly
objects such as person, organization, employment, identifiers, relations, location,
orcid, ror, and search_config.

The extension also registers default profile routes and a country_name template
filter so it can run against a standard invenio-app-rdm installation.

For deposit form autocomplete, the extension also:

- Exposes pidbox autocomplete API routes backed by commonmeta-rs Tantivy search
- Patches invenio-app-rdm deposit form config at runtime to inject autocomplete endpoint URLs
- Loads deposit form overridable components that switch person/organization remote selects to pidbox endpoints when the provider is set to pidbox

## Development

```bash
uv sync --extra tests
uv run pytest
```

## Entry points

| Group | Name | Value |
|---|---|---|
| `invenio_base.apps` | `invenio_pidbox` | `invenio_pidbox.ext:InvenioPidbox` |
| `invenio_base.api_apps` | `invenio_pidbox` | `invenio_pidbox.ext:InvenioPidbox` |

## License

MIT
