Metadata-Version: 2.5
Name: nodii-notify
Version: 0.3.0
Summary: Nodii notification request library — one request function, a derived payer, one outbox event per channel (polyglot; TS @nodii/notify is the contract).
Project-URL: Homepage, https://github.com/cognion-nucleus/nodii-libs
Project-URL: Repository, https://github.com/cognion-nucleus/nodii-libs
Author-email: Nodii <ops@nodii.co>
License: MIT
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: nodii-outbox-dispatcher<1.0.0,>=0.7.0
Description-Content-Type: text/markdown

# nodii-notify

Python port of `@nodii/notify` (S08-38, LIB-EVT-21). Every service requests a
notification through one function. The caller states the kind, the sender, the
recipient, the tenant whose data is involved and the channels. It cannot name the
payer: the payer follows from those facts (S08-2).

```python
from nodii_notify import NODII_SENDER, NotifierConfig, UserRecipient, define_notifier

notifier = define_notifier(
    NotifierConfig(
        source_service="nodii-billing-service",
        topic_prefix="billing",
        outbox_table="billing_outbox",
        platform_tenant_id=PLATFORM_TENANT_ID,
    )
)

async with conn.transaction():
    event_ids = await notifier.request_notification(
        conn,
        kind="password_reset_staff",
        sender=NODII_SENDER,
        recipient=UserRecipient(user_id=user_id),
        scope_tenant_id=tenant_id,
        channels=["email"],
        request_id=request_id,
    )
```

The request is written in the caller's transaction, one outbox event per channel.
A refused request raises `NotifyRequestError` with a `code`. `kinds_gen.py` is
generated; never edit it.

```bash
uv run pytest python/notify/tests/
```
