Metadata-Version: 2.4
Name: nself-plugin-sdk
Version: 1.2.5
Summary: Python plugin authoring SDK for nSelf. Parity with the Go SDK at github.com/nself-org/cli/sdk/go.
License: MIT
Keywords: nself,plugin,sdk,self-hosted
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: fastapi>=0.110
Requires-Dist: httpx>=0.27
Requires-Dist: pyyaml>=6
Requires-Dist: uvicorn[standard]>=0.29
Provides-Extra: db
Requires-Dist: asyncpg>=0.29; extra == 'db'
Provides-Extra: dev
Requires-Dist: asyncpg>=0.29; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: types-pyyaml>=6; extra == 'dev'
Description-Content-Type: text/markdown

# nself-plugin

Python plugin authoring SDK for [nSelf](https://nself.org). Parity with
[plugin-sdk-go](https://github.com/nself-org/plugin-sdk-go) v0.1.0.

## Install

```bash
pip install nself-plugin
```

For database migrations:

```bash
pip install 'nself-plugin[db]'
```

## Quick start

```python
from nself_plugin import Plugin, PluginContext, HealthStatus

plugin = Plugin(name="my-notify", version="1.0.0")

@plugin.install
async def install(ctx: PluginContext) -> None:
    ctx.env.require(["SMTP_HOST", "SMTP_PORT"])

@plugin.start
async def start(ctx: PluginContext) -> None:
    app = ctx.http.create_app()
    app.post("/notify/send")(handler)
    await ctx.http.listen(ctx.port)

@plugin.health
async def health(ctx: PluginContext) -> HealthStatus:
    return await ctx.http.ping("/notify/healthz")
```

## Scaffold a plugin

```bash
nself plugin new my-plugin --lang python
```

## License

MIT
