Metadata-Version: 2.5
Name: hosteday_python
Version: 0.1.0
Summary: Official Python SDK for HosteDay — Isolated Cloud Backends, Dynamic REST CRUD, Auth, Realtime (Laravel Reverb / Pusher v7), Push Notifications, and Background Jobs.
Project-URL: Homepage, https://hosteday.com
Project-URL: Documentation, https://hosteday.com/docs/hosteday-python
Project-URL: Portal, https://hosteday.com/sdks/hosteday-python
Project-URL: Repository, https://github.com/mustafa3max/hosteday-python
Project-URL: Issues, https://github.com/mustafa3max/hosteday-python/issues
Author-email: HosteDay Engineering <sdk@hosteday.com>
License: MIT
License-File: LICENSE
Keywords: async,baas,hosteday,hosteday_python,laravel-reverb,pusher,realtime,sdk,websockets
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
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
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: fastapi<1.0.0,>=0.115.0
Requires-Dist: httpx<1.0.0,>=0.27.0
Requires-Dist: python-multipart<1.0.0,>=0.0.9
Requires-Dist: uvicorn[standard]<1.0.0,>=0.30.0
Requires-Dist: websockets<16.0,>=13.0
Provides-Extra: all
Requires-Dist: cryptography>=43.0.0; extra == 'all'
Requires-Dist: keyring>=25.0.0; extra == 'all'
Requires-Dist: pynacl>=1.5.0; extra == 'all'
Requires-Dist: rich>=13.7.0; extra == 'all'
Provides-Extra: cli
Requires-Dist: rich>=13.7.0; extra == 'cli'
Provides-Extra: crypto
Requires-Dist: pynacl>=1.5.0; extra == 'crypto'
Provides-Extra: dev
Requires-Dist: mypy>=1.11.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.3.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: encrypted
Requires-Dist: cryptography>=43.0.0; extra == 'encrypted'
Requires-Dist: keyring>=25.0.0; extra == 'encrypted'
Description-Content-Type: text/markdown

# HosteDay Python SDK (`hosteday_python`)

[![PyPI version](https://img.shields.io/pypi/v/hosteday_python.svg)](https://pypi.org/project/hosteday_python/)
[![Python Versions](https://img.shields.io/pypi/pyversions/hosteday_python.svg)](https://pypi.org/project/hosteday_python/)
[![License: MIT](https://img.shields.io/badge/License-MIT-10B981.svg)](https://opensource.org/licenses/MIT)

Official asynchronous Python SDK for **HosteDay** — isolated cloud backends with standard REST CRUD, authentication, Laravel Reverb / Pusher v7 realtime WebSockets, push notifications, background jobs, and an embedded BFF web server.

Designed for 100% architectural and wire-protocol parity with **`hosteday_flutter`** and **`hosteday_kotlin`**.

---

## Installation

```bash
pip install hosteday_python
```

Optional extras:

```bash
# Encrypted private channels (PyNaCl)
pip install "hosteday_python[crypto]"

# OS keyring session persistence
pip install "hosteday_python[encrypted]"

# Rich CLI output
pip install "hosteday_python[cli]"

# Everything
pip install "hosteday_python[all]"
```

---

## Zero-Config Setup CLI

Generate `hosteday_config.json` (or `.env`) directly from your HosteDay dashboard setup token:

```bash
hosteday-setup --project my-app --token "<setup_token>" --output hosteday_config.json
# Or generate a .env file:
hosteday-setup --project my-app --token "<setup_token>" --format env --output .env
```

---

## Quickstart

You can import from either `hosteday` or `hosteday_python`:

```python
import asyncio
from pathlib import Path
from hosteday import Hosteday, JsonFileHostedayAuthStorage


async def main() -> None:
    await Hosteday.initialize_app(
        config_path=Path("hosteday_config.json"),
        auth_storage=JsonFileHostedayAuthStorage(Path(".hosteday_session.json")),
    )
    try:
        # 1. Authentication
        cred = await Hosteday.auth.sign_in_with_email_and_password(
            email="dev@hosteday.com",
            password="StrongPassword!123",
        )
        print("Signed in:", cred.user.display_name)

        # 2. Standard CRUD (index, show, create, update, delete)
        # No `/api/` prefix needed — Hosteday resolves `/api` automatically.
        page = await Hosteday.client.index(
            "notes",
            page=1,
            per_page=15,
            search="launch",
            with_auth=True,
        )
        first = await Hosteday.client.show("notes", id=page.items[0]["id"], with_auth=True)
        created = await Hosteday.client.create("notes", body={"data": "Shipped v0.1.0!"})
        updated = await Hosteday.client.update("notes", id=created["id"], body={"data": "Updated!"})
        await Hosteday.client.delete("notes", id=updated["id"])

        # 3. Realtime WebSockets (Laravel Reverb / Pusher v7)
        await Hosteday.realtime.listen_public(
            channel="announcements",
            event="NotificationReceived",
            on_event=lambda e: print(e.name, e.payload),
        )

        # 4. Push Notifications
        await Hosteday.notifications.sync_device_token(
            token="<fcm_device_token>",
            device_type="web",
            device_name="Chrome Desktop",
        )

        # 5. Background Jobs
        job = await Hosteday.jobs.dispatch(name="GenerateReport", payload={"report_id": 1})
        print("Job ID:", job.job_id, "Status:", job["status"])
    finally:
        await Hosteday.dispose()


asyncio.run(main())
```

---

## Embedded Web App & BFF Server (`HostedayWebApp`)

Build and serve a full SPA + BFF web application with built-in auth, realtime channel authorization, device token sync, and one-line CRUD endpoints — without writing any web-framework boilerplate:

```python
from pathlib import Path
from hosteday import Hosteday

web = Hosteday.create_web_app(
    title="My HosteDay App",
    config_path=Path("hosteday_config.json"),
    static_dir=Path("static"),
)

# Register GET/POST/PUT/DELETE /bff/notes in one line:
web.crud("notes", owner_field="user_id")

# Or add custom routes cleanly:
@web.get("health")
async def health() -> dict[str, bool]:
    return {"ok": True}

if __name__ == "__main__":
    web.serve(host="127.0.0.1", port=8000)
```

---

## Development & Verification

```bash
pip install -e ".[dev]"
ruff check src tests examples
mypy src
pytest -v
```

---

## Official Links

- **SDK Portal:** <https://hosteday.com/sdks/hosteday-python>
- **Documentation:** <https://hosteday.com/docs/hosteday-python>
- **PyPI:** <https://pypi.org/project/hosteday_python/>
- **Source & Issues:** <https://github.com/mustafa3max/hosteday-python>
