Metadata-Version: 2.4
Name: basehook
Version: 0.2.0
Summary: A modern Python project
Author-email: Your Name <your.email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yourusername/basehook
Project-URL: Repository, https://github.com/yourusername/basehook
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: sqlalchemy[asyncio]>=2.0
Requires-Dist: fastapi>=0.115.0
Requires-Dist: uvicorn>=0.40.0
Requires-Dist: asyncpg>=0.29.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: httpx>=0.24.0; extra == "dev"
Requires-Dist: asyncpg>=0.29.0; extra == "dev"
Requires-Dist: asgi-lifespan>=2.1.0; extra == "dev"
Requires-Dist: pytest-asyncio>=1.3.0; extra == "dev"

# Basehook

A webhook management system that groups updates by thread ID and lets you consume them either one-by-one or buffered (latest revision only).

## Core Concepts

**Thread-based grouping**: Webhooks are grouped by thread ID. Configure JSON paths to extract thread IDs and revision numbers from any format (Slack, GitHub, Shopify, etc.).

**Two consumption modes**:
- `pop(only_last_revision=False)` - Process updates one by one in order
- `pop(only_last_revision=True)` - Buffer updates and only consume the latest revision, skipping outdated ones

**Pull-based processing**: Your application pulls updates via `pop()` instead of receiving direct webhook POSTs. Failed processing is marked as ERROR and visible in the UI for manual retry.

## Quick Deploy

### Docker Compose (Self-hosting)

```bash
git clone https://github.com/mehdigmira/basehook.git
cd basehook
docker-compose up -d
```

Access at `http://localhost:8000`

### Railway (Cloud)

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/5ZGBSB?referralCode=6cnLlI&utm_medium=integration&utm_source=template&utm_campaign=generic)

One-click deploy with PostgreSQL auto-configured.

## Usage

### 1. Configure webhook
Visit the UI and create a webhook with thread ID and revision number paths.

### 2. Install client library
```bash
pip install basehook
```

### 3. Consume updates
```python
from basehook import Basehook

basehook = Basehook(database_url="postgresql+asyncpg://...")

# Process updates one by one (in order)
async with basehook.pop("webhook-name", only_last_revision=False) as update:
    if update:
        process(update)

# Or buffer updates and only process latest revision
async with basehook.pop("webhook-name", only_last_revision=True) as update:
    if update:
        process(update)  # Older revisions automatically skipped
```

## License

MIT
