hosteday-python 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. hosteday_python-0.1.0/.gitignore +37 -0
  2. hosteday_python-0.1.0/CHANGELOG.md +19 -0
  3. hosteday_python-0.1.0/LICENSE +21 -0
  4. hosteday_python-0.1.0/PKG-INFO +205 -0
  5. hosteday_python-0.1.0/README.md +156 -0
  6. hosteday_python-0.1.0/examples/README.md +96 -0
  7. hosteday_python-0.1.0/examples/desktop/pyproject.toml +20 -0
  8. hosteday_python-0.1.0/examples/web/README.md +37 -0
  9. hosteday_python-0.1.0/examples/web/pyproject.toml +19 -0
  10. hosteday_python-0.1.0/pyproject.toml +129 -0
  11. hosteday_python-0.1.0/src/hosteday/__init__.py +111 -0
  12. hosteday_python-0.1.0/src/hosteday/_version.py +3 -0
  13. hosteday_python-0.1.0/src/hosteday/auth/__init__.py +34 -0
  14. hosteday_python-0.1.0/src/hosteday/auth/hosteday_auth.py +444 -0
  15. hosteday_python-0.1.0/src/hosteday/auth/hosteday_auth_storage.py +130 -0
  16. hosteday_python-0.1.0/src/hosteday/auth/hosteday_session.py +184 -0
  17. hosteday_python-0.1.0/src/hosteday/auth/hosteday_token_provider.py +82 -0
  18. hosteday_python-0.1.0/src/hosteday/auth/hosteday_user.py +223 -0
  19. hosteday_python-0.1.0/src/hosteday/cli/__init__.py +5 -0
  20. hosteday_python-0.1.0/src/hosteday/cli/setup.py +163 -0
  21. hosteday_python-0.1.0/src/hosteday/config/__init__.py +15 -0
  22. hosteday_python-0.1.0/src/hosteday/config/hosteday_config.py +576 -0
  23. hosteday_python-0.1.0/src/hosteday/config/hosteday_option_keys.py +60 -0
  24. hosteday_python-0.1.0/src/hosteday/config/hosteday_url_resolver.py +255 -0
  25. hosteday_python-0.1.0/src/hosteday/connectivity/__init__.py +5 -0
  26. hosteday_python-0.1.0/src/hosteday/connectivity/hosteday_connectivity.py +147 -0
  27. hosteday_python-0.1.0/src/hosteday/exceptions.py +233 -0
  28. hosteday_python-0.1.0/src/hosteday/features/__init__.py +5 -0
  29. hosteday_python-0.1.0/src/hosteday/features/hosteday_features.py +78 -0
  30. hosteday_python-0.1.0/src/hosteday/hosteday.py +346 -0
  31. hosteday_python-0.1.0/src/hosteday/hosteday_client.py +579 -0
  32. hosteday_python-0.1.0/src/hosteday/http/__init__.py +18 -0
  33. hosteday_python-0.1.0/src/hosteday/http/hosteday_http_client.py +340 -0
  34. hosteday_python-0.1.0/src/hosteday/http/hosteday_response_reader.py +171 -0
  35. hosteday_python-0.1.0/src/hosteday/http/query_builder.py +204 -0
  36. hosteday_python-0.1.0/src/hosteday/jobs/__init__.py +9 -0
  37. hosteday_python-0.1.0/src/hosteday/jobs/hosteday_job_response.py +76 -0
  38. hosteday_python-0.1.0/src/hosteday/jobs/hosteday_jobs_client.py +109 -0
  39. hosteday_python-0.1.0/src/hosteday/notifications/__init__.py +13 -0
  40. hosteday_python-0.1.0/src/hosteday/notifications/hosteday_notification_client.py +290 -0
  41. hosteday_python-0.1.0/src/hosteday/notifications/hosteday_notification_response.py +79 -0
  42. hosteday_python-0.1.0/src/hosteday/py.typed +1 -0
  43. hosteday_python-0.1.0/src/hosteday/reactive/__init__.py +5 -0
  44. hosteday_python-0.1.0/src/hosteday/reactive/observable_state.py +67 -0
  45. hosteday_python-0.1.0/src/hosteday/realtime/__init__.py +31 -0
  46. hosteday_python-0.1.0/src/hosteday/realtime/connection_state.py +14 -0
  47. hosteday_python-0.1.0/src/hosteday/realtime/hosteday_channel.py +258 -0
  48. hosteday_python-0.1.0/src/hosteday/realtime/hosteday_channel_auth.py +163 -0
  49. hosteday_python-0.1.0/src/hosteday/realtime/hosteday_channel_type.py +68 -0
  50. hosteday_python-0.1.0/src/hosteday/realtime/hosteday_realtime_client.py +790 -0
  51. hosteday_python-0.1.0/src/hosteday/realtime/hosteday_realtime_event.py +130 -0
  52. hosteday_python-0.1.0/src/hosteday/web/__init__.py +5 -0
  53. hosteday_python-0.1.0/src/hosteday/web/server.py +637 -0
  54. hosteday_python-0.1.0/src/hosteday_python/__init__.py +6 -0
  55. hosteday_python-0.1.0/src/hosteday_python/py.typed +1 -0
  56. hosteday_python-0.1.0/tests/conftest.py +76 -0
  57. hosteday_python-0.1.0/tests/test_auth.py +140 -0
  58. hosteday_python-0.1.0/tests/test_config_and_urls.py +151 -0
  59. hosteday_python-0.1.0/tests/test_http_and_filters.py +170 -0
  60. hosteday_python-0.1.0/tests/test_initialization.py +122 -0
  61. hosteday_python-0.1.0/tests/test_realtime.py +253 -0
  62. hosteday_python-0.1.0/tests/test_response_reader.py +144 -0
  63. hosteday_python-0.1.0/tests/test_services_and_cli.py +187 -0
  64. hosteday_python-0.1.0/tests/test_web_server.py +185 -0
@@ -0,0 +1,37 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Virtual environments
7
+ .venv/
8
+ venv/
9
+ ENV/
10
+ env/
11
+
12
+ # Distribution / packaging
13
+ build/
14
+ dist/
15
+ *.egg-info/
16
+ *.egg
17
+
18
+ # Testing, type-checking, and linting caches
19
+ .pytest_cache/
20
+ .mypy_cache/
21
+ .ruff_cache/
22
+ .coverage
23
+ htmlcov/
24
+
25
+ # Local secrets & HosteDay runtime files (only *.example.json templates are tracked)
26
+ .env
27
+ .env.*
28
+ hosteday_config.json
29
+ firebase-config.json
30
+ .hosteday_session.json
31
+ .hosteday_web_session.json
32
+ .hosteday_prefs.json
33
+
34
+ # IDE & OS metadata
35
+ .vscode/
36
+ .idea/
37
+ .DS_Store
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to **`hosteday_python`** will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2026-11-28
8
+
9
+ ### Added
10
+ - **Static Facade & Lifecycle (`Hosteday`)**: Zero-config initialization (`Hosteday.initialize_app`), in-flight deduplication, atomic rollback on failure, `Hosteday.dispose()`, and automatic `firebase-config.json` discovery alongside `hosteday_config.json`.
11
+ - **Standard High-Level CRUD (`Hosteday.client`)**: Semantic resource methods (`index`, `show`, `create`, `update`, `delete`) with automatic `/api` URL resolution, strict Origin Lock & path-traversal security guardrails, Laravel filter/search/relation query builder, automatic envelope unwrapping (paginated and flat lists), and automatic `PATCH -> PUT` fallback on `404/405`.
12
+ - **Authentication & Sessions (`Hosteday.auth`)**: Sign-in, registration, password reset, profile & avatar updates, email verification, account deletion, reactive `user_changes()` stream, and pluggable storage backends (`MemoryHostedayAuthStorage`, `JsonFileHostedayAuthStorage`, `KeyringHostedayAuthStorage`).
13
+ - **Realtime Engine (`Hosteday.realtime`)**: Native async Pusher v7 / Laravel Reverb WebSocket client supporting public, private, presence (member tracking & snapshot replay), and private-encrypted (`PyNaCl`) channels, client whispers, heartbeat ping/pong, and exponential backoff reconnect.
14
+ - **Push Notifications (`Hosteday.notifications`)**: Device token registration/unlinking, registered device listing, and notification dispatch with auth lifecycle hooks.
15
+ - **Background Jobs (`Hosteday.jobs`)**: Async job dispatching, status polling, and job listing.
16
+ - **Connectivity & Feature Entitlements**: Hybrid passive + active connectivity monitoring (`Hosteday.connectivity`) and plan feature flags (`Hosteday.features`).
17
+ - **Embedded Web App Server (`HostedayWebApp`)**: High-level `Hosteday.create_web_app(...)`, `Hosteday.serve_web(...)`, `@web.get/post/put/patch/delete`, one-line `web.crud(...)`, built-in BFF routes, and SPA / Firebase Service Worker serving with zero framework boilerplate.
18
+ - **Zero-Config Setup CLI (`hosteday-setup`)**: Automated fetching and writing of `hosteday_config.json` or `.env` directly from HosteDay setup tokens.
19
+ - **PEP 561 Typing**: Full `strict = true` mypy compliance with bundled `py.typed` markers in both `hosteday` and `hosteday_python`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HosteDay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,205 @@
1
+ Metadata-Version: 2.5
2
+ Name: hosteday_python
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for HosteDay — Isolated Cloud Backends, Dynamic REST CRUD, Auth, Realtime (Laravel Reverb / Pusher v7), Push Notifications, and Background Jobs.
5
+ Project-URL: Homepage, https://hosteday.com
6
+ Project-URL: Documentation, https://hosteday.com/docs/hosteday-python
7
+ Project-URL: Portal, https://hosteday.com/sdks/hosteday-python
8
+ Project-URL: Repository, https://github.com/mustafa3max/hosteday-python
9
+ Project-URL: Issues, https://github.com/mustafa3max/hosteday-python/issues
10
+ Author-email: HosteDay Engineering <sdk@hosteday.com>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: async,baas,hosteday,hosteday_python,laravel-reverb,pusher,realtime,sdk,websockets
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Framework :: AsyncIO
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: fastapi<1.0.0,>=0.115.0
26
+ Requires-Dist: httpx<1.0.0,>=0.27.0
27
+ Requires-Dist: python-multipart<1.0.0,>=0.0.9
28
+ Requires-Dist: uvicorn[standard]<1.0.0,>=0.30.0
29
+ Requires-Dist: websockets<16.0,>=13.0
30
+ Provides-Extra: all
31
+ Requires-Dist: cryptography>=43.0.0; extra == 'all'
32
+ Requires-Dist: keyring>=25.0.0; extra == 'all'
33
+ Requires-Dist: pynacl>=1.5.0; extra == 'all'
34
+ Requires-Dist: rich>=13.7.0; extra == 'all'
35
+ Provides-Extra: cli
36
+ Requires-Dist: rich>=13.7.0; extra == 'cli'
37
+ Provides-Extra: crypto
38
+ Requires-Dist: pynacl>=1.5.0; extra == 'crypto'
39
+ Provides-Extra: dev
40
+ Requires-Dist: mypy>=1.11.0; extra == 'dev'
41
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
42
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
43
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
44
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
45
+ Provides-Extra: encrypted
46
+ Requires-Dist: cryptography>=43.0.0; extra == 'encrypted'
47
+ Requires-Dist: keyring>=25.0.0; extra == 'encrypted'
48
+ Description-Content-Type: text/markdown
49
+
50
+ # HosteDay Python SDK (`hosteday_python`)
51
+
52
+ [![PyPI version](https://img.shields.io/pypi/v/hosteday_python.svg)](https://pypi.org/project/hosteday_python/)
53
+ [![Python Versions](https://img.shields.io/pypi/pyversions/hosteday_python.svg)](https://pypi.org/project/hosteday_python/)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-10B981.svg)](https://opensource.org/licenses/MIT)
55
+
56
+ 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.
57
+
58
+ Designed for 100% architectural and wire-protocol parity with **`hosteday_flutter`** and **`hosteday_kotlin`**.
59
+
60
+ ---
61
+
62
+ ## Installation
63
+
64
+ ```bash
65
+ pip install hosteday_python
66
+ ```
67
+
68
+ Optional extras:
69
+
70
+ ```bash
71
+ # Encrypted private channels (PyNaCl)
72
+ pip install "hosteday_python[crypto]"
73
+
74
+ # OS keyring session persistence
75
+ pip install "hosteday_python[encrypted]"
76
+
77
+ # Rich CLI output
78
+ pip install "hosteday_python[cli]"
79
+
80
+ # Everything
81
+ pip install "hosteday_python[all]"
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Zero-Config Setup CLI
87
+
88
+ Generate `hosteday_config.json` (or `.env`) directly from your HosteDay dashboard setup token:
89
+
90
+ ```bash
91
+ hosteday-setup --project my-app --token "<setup_token>" --output hosteday_config.json
92
+ # Or generate a .env file:
93
+ hosteday-setup --project my-app --token "<setup_token>" --format env --output .env
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Quickstart
99
+
100
+ You can import from either `hosteday` or `hosteday_python`:
101
+
102
+ ```python
103
+ import asyncio
104
+ from pathlib import Path
105
+ from hosteday import Hosteday, JsonFileHostedayAuthStorage
106
+
107
+
108
+ async def main() -> None:
109
+ await Hosteday.initialize_app(
110
+ config_path=Path("hosteday_config.json"),
111
+ auth_storage=JsonFileHostedayAuthStorage(Path(".hosteday_session.json")),
112
+ )
113
+ try:
114
+ # 1. Authentication
115
+ cred = await Hosteday.auth.sign_in_with_email_and_password(
116
+ email="dev@hosteday.com",
117
+ password="StrongPassword!123",
118
+ )
119
+ print("Signed in:", cred.user.display_name)
120
+
121
+ # 2. Standard CRUD (index, show, create, update, delete)
122
+ # No `/api/` prefix needed — Hosteday resolves `/api` automatically.
123
+ page = await Hosteday.client.index(
124
+ "notes",
125
+ page=1,
126
+ per_page=15,
127
+ search="launch",
128
+ with_auth=True,
129
+ )
130
+ first = await Hosteday.client.show("notes", id=page.items[0]["id"], with_auth=True)
131
+ created = await Hosteday.client.create("notes", body={"data": "Shipped v0.1.0!"})
132
+ updated = await Hosteday.client.update("notes", id=created["id"], body={"data": "Updated!"})
133
+ await Hosteday.client.delete("notes", id=updated["id"])
134
+
135
+ # 3. Realtime WebSockets (Laravel Reverb / Pusher v7)
136
+ await Hosteday.realtime.listen_public(
137
+ channel="announcements",
138
+ event="NotificationReceived",
139
+ on_event=lambda e: print(e.name, e.payload),
140
+ )
141
+
142
+ # 4. Push Notifications
143
+ await Hosteday.notifications.sync_device_token(
144
+ token="<fcm_device_token>",
145
+ device_type="web",
146
+ device_name="Chrome Desktop",
147
+ )
148
+
149
+ # 5. Background Jobs
150
+ job = await Hosteday.jobs.dispatch(name="GenerateReport", payload={"report_id": 1})
151
+ print("Job ID:", job.job_id, "Status:", job["status"])
152
+ finally:
153
+ await Hosteday.dispose()
154
+
155
+
156
+ asyncio.run(main())
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Embedded Web App & BFF Server (`HostedayWebApp`)
162
+
163
+ 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:
164
+
165
+ ```python
166
+ from pathlib import Path
167
+ from hosteday import Hosteday
168
+
169
+ web = Hosteday.create_web_app(
170
+ title="My HosteDay App",
171
+ config_path=Path("hosteday_config.json"),
172
+ static_dir=Path("static"),
173
+ )
174
+
175
+ # Register GET/POST/PUT/DELETE /bff/notes in one line:
176
+ web.crud("notes", owner_field="user_id")
177
+
178
+ # Or add custom routes cleanly:
179
+ @web.get("health")
180
+ async def health() -> dict[str, bool]:
181
+ return {"ok": True}
182
+
183
+ if __name__ == "__main__":
184
+ web.serve(host="127.0.0.1", port=8000)
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Development & Verification
190
+
191
+ ```bash
192
+ pip install -e ".[dev]"
193
+ ruff check src tests examples
194
+ mypy src
195
+ pytest -v
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Official Links
201
+
202
+ - **SDK Portal:** <https://hosteday.com/sdks/hosteday-python>
203
+ - **Documentation:** <https://hosteday.com/docs/hosteday-python>
204
+ - **PyPI:** <https://pypi.org/project/hosteday_python/>
205
+ - **Source & Issues:** <https://github.com/mustafa3max/hosteday-python>
@@ -0,0 +1,156 @@
1
+ # HosteDay Python SDK (`hosteday_python`)
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/hosteday_python.svg)](https://pypi.org/project/hosteday_python/)
4
+ [![Python Versions](https://img.shields.io/pypi/pyversions/hosteday_python.svg)](https://pypi.org/project/hosteday_python/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-10B981.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ 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.
8
+
9
+ Designed for 100% architectural and wire-protocol parity with **`hosteday_flutter`** and **`hosteday_kotlin`**.
10
+
11
+ ---
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install hosteday_python
17
+ ```
18
+
19
+ Optional extras:
20
+
21
+ ```bash
22
+ # Encrypted private channels (PyNaCl)
23
+ pip install "hosteday_python[crypto]"
24
+
25
+ # OS keyring session persistence
26
+ pip install "hosteday_python[encrypted]"
27
+
28
+ # Rich CLI output
29
+ pip install "hosteday_python[cli]"
30
+
31
+ # Everything
32
+ pip install "hosteday_python[all]"
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Zero-Config Setup CLI
38
+
39
+ Generate `hosteday_config.json` (or `.env`) directly from your HosteDay dashboard setup token:
40
+
41
+ ```bash
42
+ hosteday-setup --project my-app --token "<setup_token>" --output hosteday_config.json
43
+ # Or generate a .env file:
44
+ hosteday-setup --project my-app --token "<setup_token>" --format env --output .env
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Quickstart
50
+
51
+ You can import from either `hosteday` or `hosteday_python`:
52
+
53
+ ```python
54
+ import asyncio
55
+ from pathlib import Path
56
+ from hosteday import Hosteday, JsonFileHostedayAuthStorage
57
+
58
+
59
+ async def main() -> None:
60
+ await Hosteday.initialize_app(
61
+ config_path=Path("hosteday_config.json"),
62
+ auth_storage=JsonFileHostedayAuthStorage(Path(".hosteday_session.json")),
63
+ )
64
+ try:
65
+ # 1. Authentication
66
+ cred = await Hosteday.auth.sign_in_with_email_and_password(
67
+ email="dev@hosteday.com",
68
+ password="StrongPassword!123",
69
+ )
70
+ print("Signed in:", cred.user.display_name)
71
+
72
+ # 2. Standard CRUD (index, show, create, update, delete)
73
+ # No `/api/` prefix needed — Hosteday resolves `/api` automatically.
74
+ page = await Hosteday.client.index(
75
+ "notes",
76
+ page=1,
77
+ per_page=15,
78
+ search="launch",
79
+ with_auth=True,
80
+ )
81
+ first = await Hosteday.client.show("notes", id=page.items[0]["id"], with_auth=True)
82
+ created = await Hosteday.client.create("notes", body={"data": "Shipped v0.1.0!"})
83
+ updated = await Hosteday.client.update("notes", id=created["id"], body={"data": "Updated!"})
84
+ await Hosteday.client.delete("notes", id=updated["id"])
85
+
86
+ # 3. Realtime WebSockets (Laravel Reverb / Pusher v7)
87
+ await Hosteday.realtime.listen_public(
88
+ channel="announcements",
89
+ event="NotificationReceived",
90
+ on_event=lambda e: print(e.name, e.payload),
91
+ )
92
+
93
+ # 4. Push Notifications
94
+ await Hosteday.notifications.sync_device_token(
95
+ token="<fcm_device_token>",
96
+ device_type="web",
97
+ device_name="Chrome Desktop",
98
+ )
99
+
100
+ # 5. Background Jobs
101
+ job = await Hosteday.jobs.dispatch(name="GenerateReport", payload={"report_id": 1})
102
+ print("Job ID:", job.job_id, "Status:", job["status"])
103
+ finally:
104
+ await Hosteday.dispose()
105
+
106
+
107
+ asyncio.run(main())
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Embedded Web App & BFF Server (`HostedayWebApp`)
113
+
114
+ 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:
115
+
116
+ ```python
117
+ from pathlib import Path
118
+ from hosteday import Hosteday
119
+
120
+ web = Hosteday.create_web_app(
121
+ title="My HosteDay App",
122
+ config_path=Path("hosteday_config.json"),
123
+ static_dir=Path("static"),
124
+ )
125
+
126
+ # Register GET/POST/PUT/DELETE /bff/notes in one line:
127
+ web.crud("notes", owner_field="user_id")
128
+
129
+ # Or add custom routes cleanly:
130
+ @web.get("health")
131
+ async def health() -> dict[str, bool]:
132
+ return {"ok": True}
133
+
134
+ if __name__ == "__main__":
135
+ web.serve(host="127.0.0.1", port=8000)
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Development & Verification
141
+
142
+ ```bash
143
+ pip install -e ".[dev]"
144
+ ruff check src tests examples
145
+ mypy src
146
+ pytest -v
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Official Links
152
+
153
+ - **SDK Portal:** <https://hosteday.com/sdks/hosteday-python>
154
+ - **Documentation:** <https://hosteday.com/docs/hosteday-python>
155
+ - **PyPI:** <https://pypi.org/project/hosteday_python/>
156
+ - **Source & Issues:** <https://github.com/mustafa3max/hosteday-python>
@@ -0,0 +1,96 @@
1
+ # HosteDay Python SDK — Examples
2
+
3
+ This directory contains organized, ready-to-run reference examples demonstrating the **`hosteday_python`** SDK across CLI scripts, FastAPI backends, and PySide6 desktop applications.
4
+
5
+ ## Directory Structure
6
+
7
+ ```text
8
+ examples/
9
+ ├── README.md # This guide
10
+ ├── config/
11
+ │ └── hosteday_config.json # Shared reference Zero-Config template
12
+ ├── quickstart/
13
+ │ └── full_sdk_demo.py # End-to-end script covering all 7 SDK modules
14
+ ├── fastapi/
15
+ │ └── fastapi_integration.py # Production FastAPI lifespan & CRUD integration
16
+ └── desktop/ # PySide6 + qasync Desktop Reference App
17
+ ├── pyproject.toml
18
+ ├── hosteday_config.json
19
+ ├── firebase-config.example.json
20
+ ├── assets/logo.png
21
+ └── src/hosteday_desktop/
22
+ └── web/ # FastAPI + SPA Consumer Web App
23
+ ├── pyproject.toml
24
+ ├── hosteday_config.example.json
25
+ ├── firebase-config.example.json
26
+ ├── app/ # FastAPI BFF (main.py, config.py, routes.py)
27
+ └── static/ # Responsive RTL/LTR SPA + Firebase Service Worker
28
+ ```
29
+
30
+ ---
31
+
32
+ ## 1. Configuration (`examples/config/hosteday_config.json`)
33
+
34
+ Before running the examples against a live HosteDay project, replace the placeholders in `examples/config/hosteday_config.json` (or generate one automatically via `hosteday-setup`):
35
+
36
+ ```bash
37
+ hosteday-setup --project <your-slug> --token "<setup-token>" --output examples/config/hosteday_config.json
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 2. Quickstart Script (`examples/quickstart/full_sdk_demo.py`)
43
+
44
+ Demonstrates Zero-Config initialization, Auth, standard CRUD (`index`, `show`, `create`, `update`, `delete`), Realtime (Public, Presence, Whisper, REST Publish), Push Notifications, and Background Jobs:
45
+
46
+ ```bash
47
+ cd hosteday_python
48
+ .venv/bin/python examples/quickstart/full_sdk_demo.py
49
+ ```
50
+
51
+ ---
52
+
53
+ ## 3. FastAPI Integration (`examples/fastapi/fastapi_integration.py`)
54
+
55
+ Demonstrates `Hosteday.initialize_app()` and `Hosteday.dispose()` inside a FastAPI `lifespan` context with CRUD endpoints:
56
+
57
+ ```bash
58
+ cd hosteday_python
59
+ .venv/bin/pip install fastapi uvicorn
60
+ HOSTEDAY_PROJECT_DOMAIN=your-project.hosteday.com \
61
+ HOSTEDAY_PROJECT_API_KEY=your-api-key \
62
+ .venv/bin/uvicorn examples.fastapi.fastapi_integration:app --reload
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 4. Desktop Reference App (`examples/desktop/`)
68
+
69
+ Full-featured **PySide6 + qasync** desktop application with official HosteDay Dark/Light themes, live connectivity indicator, toast notifications, and complete Auth & User Dashboard flows:
70
+
71
+ ```bash
72
+ cd hosteday_python
73
+ .venv/bin/pip install -e ./examples/desktop
74
+ .venv/bin/hosteday-desktop
75
+ ```
76
+
77
+ ### Firebase Web Config (`firebase-config.json`)
78
+
79
+ To enable Firebase configuration without modifying `hosteday_config.json`, download your official **`firebase-config.json`** from the **Web** section of your HosteDay dashboard and place it in either:
80
+
81
+ - `examples/desktop/firebase-config.json`, or
82
+ - `examples/desktop/web/firebase-config.json`
83
+
84
+ `HostedayConfig.from_file()` automatically discovers and merges `firebase-config.json` (`apiKey`, `appId`, `messagingSenderId`, `projectId`, `authDomain`, `storageBucket`, `measurementId`, `vapidKey`). See `examples/desktop/firebase-config.example.json` for the expected schema. Live desktop notifications are also bridged automatically over `Hosteday.realtime` (`private-user.{user_id}` and `announcements`) and surfaced via in-app toast banners and OS system tray notifications (`QSystemTrayIcon`).
85
+
86
+ ---
87
+
88
+ ## 5. Consumer Web App (`examples/web/`)
89
+
90
+ Responsive **HosteDay Web App** powered directly by `Hosteday.create_web_app(...)` with unified HosteDay Emerald Dark/Light themes, Arabic (RTL) & English (LTR) support, live auctions over WebSockets, product marketplace, Firebase Web Push (`firebase-messaging-sw.js`), and full profile management:
91
+
92
+ ```bash
93
+ cd hosteday_python
94
+ .venv/bin/pip install -e ./examples/web
95
+ .venv/bin/hosteday-web
96
+ ```
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hosteday-desktop-example"
7
+ version = "0.1.0"
8
+ description = "Official PySide6 + qasync Desktop Reference App for the HosteDay Python SDK."
9
+ requires-python = ">=3.10"
10
+ dependencies = [
11
+ "hosteday_python>=0.1.0",
12
+ "PySide6>=6.7.0",
13
+ "qasync>=0.27.1",
14
+ ]
15
+
16
+ [project.scripts]
17
+ hosteday-desktop = "hosteday_desktop.main:main"
18
+
19
+ [tool.hatch.build.targets.wheel]
20
+ packages = ["src/hosteday_desktop"]
@@ -0,0 +1,37 @@
1
+ # HosteDay Auctions — Consumer Web App (`examples/web`)
2
+
3
+ A responsive, consumer-grade **Live Auctions & Marketplace** single-page web application (SPA) built directly with **`hosteday_python`** (`Hosteday.create_web_app(...)` & `web.serve(port=8000)`).
4
+
5
+ ## Features
6
+ - **Zero Web-Framework Boilerplate**: Auth, Profile, Avatar upload, Realtime channel auth, Web Push device sync, and SPA static serving are all built directly into `Hosteday.create_web_app(...)`.
7
+ - **Unified HosteDay Emerald Identity** across **HosteDay Dark** and **HosteDay Light** modes.
8
+ - **Full Bilingual Support**: Instant **Arabic (RTL)** and **English (LTR)** switching with local preference persistence.
9
+ - **5 End-User Views**:
10
+ 1. **Live Auctions**: Real-time bidding (`+$50`, `+$100`, `+$250`, custom bid), live countdown timer, active participants by name, and live bid activity feed over WebSockets.
11
+ 2. **Explore Products (Marketplace)**: Responsive product cards grid with search, filter chips, pagination, and product details modal.
12
+ 3. **Notifications**: Clean real-time notification feed powered by both WebSockets and **Firebase Web Push** (`firebase-messaging-sw.js`).
13
+ 4. **Profile**: Full-width responsive profile with real circular avatar rendering, click-to-zoom lightbox preview, profile name & photo updates, email verification, password reset, and account management.
14
+ 5. **Settings**: Theme toggle, language switcher, browser push notifications toggle, and sign-out.
15
+
16
+ ## Quick Start
17
+
18
+ 1. Place your real `hosteday_config.json` (and optionally `firebase-config.json` downloaded from the Web section of your HosteDay dashboard) inside `examples/web/`:
19
+ ```bash
20
+ cp examples/web/hosteday_config.example.json examples/web/hosteday_config.json
21
+ cp examples/web/firebase-config.example.json examples/web/firebase-config.json
22
+ ```
23
+ *(If `examples/web/hosteday_config.json` is not present, the app automatically falls back to `examples/desktop/hosteday_config.json` or `examples/config/hosteday_config.json`.)*
24
+
25
+ 2. Install and run directly with Python (or `hosteday-web`):
26
+ ```bash
27
+ cd hosteday_python
28
+ .venv/bin/pip install -e ./examples/web
29
+ .venv/bin/hosteday-web
30
+ ```
31
+ Or run directly as a module:
32
+ ```bash
33
+ cd hosteday_python/examples/web
34
+ ../../.venv/bin/python -m app.main
35
+ ```
36
+
37
+ 3. Open [http://127.0.0.1:8000](http://127.0.0.1:8000) in your browser.
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "hosteday-web-example"
7
+ version = "0.1.0"
8
+ description = "Consumer-grade HosteDay Auctions & Marketplace Web App powered by hosteday_python."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "hosteday_python>=0.1.0",
13
+ ]
14
+
15
+ [project.scripts]
16
+ hosteday-web = "app.main:run"
17
+
18
+ [tool.hatch.build.targets.wheel]
19
+ packages = ["app"]