dominus-sdk-python 2.1.6__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 (36) hide show
  1. dominus_sdk_python-2.1.6/PKG-INFO +381 -0
  2. dominus_sdk_python-2.1.6/README.md +350 -0
  3. dominus_sdk_python-2.1.6/dominus/__init__.py +47 -0
  4. dominus_sdk_python-2.1.6/dominus/config/__init__.py +24 -0
  5. dominus_sdk_python-2.1.6/dominus/config/endpoints.py +39 -0
  6. dominus_sdk_python-2.1.6/dominus/errors.py +201 -0
  7. dominus_sdk_python-2.1.6/dominus/helpers/__init__.py +2 -0
  8. dominus_sdk_python-2.1.6/dominus/helpers/auth.py +23 -0
  9. dominus_sdk_python-2.1.6/dominus/helpers/cache.py +192 -0
  10. dominus_sdk_python-2.1.6/dominus/helpers/core.py +657 -0
  11. dominus_sdk_python-2.1.6/dominus/helpers/crypto.py +118 -0
  12. dominus_sdk_python-2.1.6/dominus/namespaces/__init__.py +26 -0
  13. dominus_sdk_python-2.1.6/dominus/namespaces/_deprecated_crossover.py +10 -0
  14. dominus_sdk_python-2.1.6/dominus/namespaces/_deprecated_sql.py +1341 -0
  15. dominus_sdk_python-2.1.6/dominus/namespaces/auth.py +1025 -0
  16. dominus_sdk_python-2.1.6/dominus/namespaces/courier.py +251 -0
  17. dominus_sdk_python-2.1.6/dominus/namespaces/db.py +267 -0
  18. dominus_sdk_python-2.1.6/dominus/namespaces/ddl.py +590 -0
  19. dominus_sdk_python-2.1.6/dominus/namespaces/files.py +299 -0
  20. dominus_sdk_python-2.1.6/dominus/namespaces/health.py +59 -0
  21. dominus_sdk_python-2.1.6/dominus/namespaces/logs.py +367 -0
  22. dominus_sdk_python-2.1.6/dominus/namespaces/open.py +72 -0
  23. dominus_sdk_python-2.1.6/dominus/namespaces/portal.py +504 -0
  24. dominus_sdk_python-2.1.6/dominus/namespaces/redis.py +357 -0
  25. dominus_sdk_python-2.1.6/dominus/namespaces/secrets.py +126 -0
  26. dominus_sdk_python-2.1.6/dominus/services/__init__.py +2 -0
  27. dominus_sdk_python-2.1.6/dominus/services/_deprecated_architect.py +323 -0
  28. dominus_sdk_python-2.1.6/dominus/services/_deprecated_sovereign.py +93 -0
  29. dominus_sdk_python-2.1.6/dominus/start.py +1034 -0
  30. dominus_sdk_python-2.1.6/dominus_sdk_python.egg-info/PKG-INFO +381 -0
  31. dominus_sdk_python-2.1.6/dominus_sdk_python.egg-info/SOURCES.txt +34 -0
  32. dominus_sdk_python-2.1.6/dominus_sdk_python.egg-info/dependency_links.txt +1 -0
  33. dominus_sdk_python-2.1.6/dominus_sdk_python.egg-info/requires.txt +10 -0
  34. dominus_sdk_python-2.1.6/dominus_sdk_python.egg-info/top_level.txt +1 -0
  35. dominus_sdk_python-2.1.6/pyproject.toml +51 -0
  36. dominus_sdk_python-2.1.6/setup.cfg +4 -0
@@ -0,0 +1,381 @@
1
+ Metadata-Version: 2.4
2
+ Name: dominus-sdk-python
3
+ Version: 2.1.6
4
+ Summary: Python SDK for the Dominus Orchestrator Platform
5
+ Author-email: CareBridge Systems <dev@carebridge.io>
6
+ License: Proprietary
7
+ Project-URL: Homepage, https://github.com/carebridgesystems/dominus-sdk-python
8
+ Project-URL: Repository, https://github.com/carebridgesystems/dominus-sdk-python
9
+ Keywords: dominus,carebridge,sdk,orchestrator,api,async
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: Other/Proprietary License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Framework :: AsyncIO
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: httpx>=0.24.0
24
+ Requires-Dist: bcrypt>=4.0.0
25
+ Requires-Dist: cryptography>=41.0.0
26
+ Provides-Extra: jwt
27
+ Requires-Dist: PyJWT>=2.8.0; extra == "jwt"
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
30
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
31
+
32
+ # CB Dominus SDK
33
+
34
+ **Python SDK for the Dominus Orchestrator Platform**
35
+
36
+ A unified, async-first Python SDK providing seamless access to all Dominus backend services including secrets management, database operations, caching, file storage, authentication, schema management, and structured logging.
37
+
38
+ ## Features
39
+
40
+ - **Namespace-based API** - Intuitive access via `dominus.db`, `dominus.redis`, `dominus.files`, etc.
41
+ - **Async/Await** - Built for modern async Python applications
42
+ - **Automatic JWT Management** - Token minting, caching, and refresh handled transparently
43
+ - **Resilience Built-in** - Circuit breaker, exponential backoff, and retry logic
44
+ - **Typed Errors** - Specific error classes for different failure modes
45
+ - **Secure by Default** - Client-side password hashing, encrypted cache, audit trail support
46
+
47
+ ## Quick Start
48
+
49
+ ```python
50
+ from dominus import dominus
51
+
52
+ # Set your token (or use DOMINUS_TOKEN environment variable)
53
+ import os
54
+ os.environ["DOMINUS_TOKEN"] = "your-psk-token"
55
+
56
+ # Start using the SDK
57
+ async def main():
58
+ # Secrets
59
+ db_url = await dominus.get("DATABASE_URL")
60
+
61
+ # Database queries
62
+ users = await dominus.db.query("users", filters={"status": "active"})
63
+
64
+ # Redis caching
65
+ await dominus.redis.set("session:123", {"user": "john"}, ttl=3600)
66
+
67
+ # File storage
68
+ result = await dominus.files.upload(data, "report.pdf", category="reports")
69
+
70
+ # Structured logging
71
+ await dominus.logs.info("User logged in", {"user_id": "123"})
72
+ ```
73
+
74
+ ## Installation
75
+
76
+ ```bash
77
+ # Clone or add as submodule
78
+ git clone https://github.com/carebridgesystems/cb-dominus-sdk.git
79
+
80
+ # Install dependencies
81
+ pip install httpx bcrypt cryptography
82
+ ```
83
+
84
+ ## Namespaces
85
+
86
+ | Namespace | Service | Purpose |
87
+ |-----------|---------|---------|
88
+ | `dominus.secrets` | Warden | Secrets management |
89
+ | `dominus.db` | Scribe | Database CRUD operations |
90
+ | `dominus.redis` | Whisperer | Redis caching |
91
+ | `dominus.files` | Archivist | Object storage (B2) |
92
+ | `dominus.auth` | Guardian | Authentication & authorization |
93
+ | `dominus.ddl` | Smith | Schema DDL & migrations |
94
+ | `dominus.logs` | Herald | Structured logging |
95
+ | `dominus.portal` | Portal | User auth & sessions |
96
+ | `dominus.courier` | Courier | Email delivery (Postmark) |
97
+ | `dominus.open` | Scribe | Direct database access |
98
+ | `dominus.health` | Health | Service health checks |
99
+
100
+ ## Usage Examples
101
+
102
+ ### Secrets Management
103
+
104
+ ```python
105
+ # Root-level shortcuts
106
+ value = await dominus.get("API_KEY")
107
+ await dominus.upsert("API_KEY", "new-value", comment="Updated API key")
108
+
109
+ # Full namespace
110
+ secrets = await dominus.secrets.list(prefix="DB_")
111
+ await dominus.secrets.delete("OLD_KEY")
112
+ ```
113
+
114
+ ### Database Operations
115
+
116
+ ```python
117
+ # Query with filters and pagination
118
+ users = await dominus.db.query(
119
+ "users",
120
+ filters={"status": "active", "role": ["admin", "manager"]},
121
+ sort_by="created_at",
122
+ sort_order="desc",
123
+ limit=50,
124
+ offset=0
125
+ )
126
+
127
+ # Insert
128
+ user = await dominus.db.insert("users", {
129
+ "email": "john@example.com",
130
+ "name": "John Doe"
131
+ })
132
+
133
+ # Update
134
+ await dominus.db.update("users", {"status": "inactive"}, filters={"id": user_id})
135
+
136
+ # Secure table access (requires audit reason)
137
+ patients = await dominus.db.query(
138
+ "patients",
139
+ schema="tenant_acme",
140
+ reason="Reviewing records for appointment #123",
141
+ actor="dr.smith"
142
+ )
143
+ ```
144
+
145
+ ### Redis Caching
146
+
147
+ ```python
148
+ # Key-value operations
149
+ await dominus.redis.set("user:123", {"name": "John"}, ttl=3600)
150
+ value = await dominus.redis.get("user:123")
151
+
152
+ # Distributed locks
153
+ if await dominus.redis.setnx("lock:job", "worker-1", ttl=60):
154
+ try:
155
+ # Do exclusive work
156
+ pass
157
+ finally:
158
+ await dominus.redis.delete("lock:job")
159
+
160
+ # Counters
161
+ await dominus.redis.incr("page:views", delta=1)
162
+
163
+ # Hash operations
164
+ await dominus.redis.hset("user:123", "email", "john@example.com", ttl=3600)
165
+ ```
166
+
167
+ ### File Storage
168
+
169
+ ```python
170
+ # Upload file
171
+ with open("report.pdf", "rb") as f:
172
+ result = await dominus.files.upload(
173
+ data=f.read(),
174
+ filename="report.pdf",
175
+ category="reports"
176
+ )
177
+
178
+ # Get download URL
179
+ download = await dominus.files.download(file_id=result["id"])
180
+ url = download["download_url"]
181
+
182
+ # List files
183
+ files = await dominus.files.list(category="reports", prefix="2025/")
184
+ ```
185
+
186
+ ### Structured Logging
187
+
188
+ ```python
189
+ # Simple logging (auto-captures file and function)
190
+ await dominus.logs.info("User logged in", {"user_id": "123"})
191
+ await dominus.logs.error("Payment failed", {"order_id": "456"})
192
+
193
+ # With exception context
194
+ try:
195
+ risky_operation()
196
+ except Exception as e:
197
+ await dominus.logs.error("Operation failed", exception=e)
198
+
199
+ # Query logs
200
+ errors = await dominus.logs.query(level="error", limit=100)
201
+ ```
202
+
203
+ ### Authentication
204
+
205
+ ```python
206
+ # User management
207
+ user = await dominus.auth.add_user(
208
+ username="john",
209
+ password="secure-password",
210
+ email="john@example.com"
211
+ )
212
+
213
+ # Role management
214
+ role = await dominus.auth.add_role(
215
+ name="Editor",
216
+ scope_slugs=["read", "write", "publish"]
217
+ )
218
+
219
+ # JWT operations
220
+ jwt = await dominus.auth.mint_jwt(user_id=user["id"], expires_in=900)
221
+ claims = await dominus.auth.validate_jwt(token)
222
+ ```
223
+
224
+ ### Schema Management
225
+
226
+ ```python
227
+ # Create table
228
+ await dominus.ddl.add_table("orders", [
229
+ {"name": "id", "type": "UUID", "constraints": ["PRIMARY KEY"]},
230
+ {"name": "user_id", "type": "UUID", "constraints": ["NOT NULL"]},
231
+ {"name": "total", "type": "DECIMAL(10,2)"},
232
+ {"name": "created_at", "type": "TIMESTAMPTZ", "default": "NOW()"}
233
+ ])
234
+
235
+ # Provision tenant schema
236
+ await dominus.ddl.provision_tenant("customer_acme", category_slug="healthcare")
237
+ ```
238
+
239
+ ### User Authentication (Portal)
240
+
241
+ ```python
242
+ # User login
243
+ session = await dominus.portal.login(
244
+ username="john@example.com",
245
+ password="secret123",
246
+ tenant_id="tenant-uuid"
247
+ )
248
+
249
+ # Get current user
250
+ me = await dominus.portal.me()
251
+
252
+ # Get navigation (access-filtered)
253
+ nav = await dominus.portal.get_navigation()
254
+
255
+ # Profile & preferences
256
+ await dominus.portal.update_preferences(theme="dark", timezone="America/New_York")
257
+
258
+ # Logout
259
+ await dominus.portal.logout()
260
+ ```
261
+
262
+ ### Email Delivery (Courier)
263
+
264
+ ```python
265
+ # Send email via Postmark template
266
+ result = await dominus.courier.send(
267
+ template_alias="welcome",
268
+ to="user@example.com",
269
+ from_email="noreply@myapp.com",
270
+ model={"name": "John", "product_name": "My App"}
271
+ )
272
+
273
+ # Convenience methods
274
+ await dominus.courier.send_password_reset(
275
+ to="user@example.com",
276
+ from_email="noreply@myapp.com",
277
+ name="John",
278
+ reset_url="https://myapp.com/reset?token=abc",
279
+ product_name="My App"
280
+ )
281
+ ```
282
+
283
+ ## Error Handling
284
+
285
+ ```python
286
+ from dominus import (
287
+ dominus,
288
+ DominusError,
289
+ AuthenticationError,
290
+ AuthorizationError,
291
+ NotFoundError,
292
+ ValidationError,
293
+ SecureTableError,
294
+ )
295
+
296
+ try:
297
+ user = await dominus.auth.get_user(user_id="invalid")
298
+ except NotFoundError as e:
299
+ print(f"User not found: {e.message}")
300
+ except SecureTableError as e:
301
+ print("Secure table requires 'reason' and 'actor' parameters")
302
+ except DominusError as e:
303
+ print(f"Error {e.status_code}: {e.message}")
304
+ if e.details:
305
+ print(f"Details: {e.details}")
306
+ ```
307
+
308
+ ### Error Types
309
+
310
+ | Error | Status | Description |
311
+ |-------|--------|-------------|
312
+ | `AuthenticationError` | 401 | Invalid or missing token |
313
+ | `AuthorizationError` | 403 | Insufficient permissions |
314
+ | `NotFoundError` | 404 | Resource not found |
315
+ | `ValidationError` | 400 | Invalid request data |
316
+ | `ConflictError` | 409 | Duplicate or version conflict |
317
+ | `ServiceError` | 5xx | Backend service error |
318
+ | `SecureTableError` | 403 | Missing reason for secure table |
319
+ | `ConnectionError` | - | Network connection failed |
320
+ | `TimeoutError` | 504 | Request timed out |
321
+
322
+ ## Configuration
323
+
324
+ ### Environment Variables
325
+
326
+ ```bash
327
+ # Required: PSK token for authentication
328
+ export DOMINUS_TOKEN="your-psk-token"
329
+ ```
330
+
331
+ ### Token Resolution
332
+
333
+ The SDK resolves the authentication token in this order:
334
+ 1. `DOMINUS_TOKEN` environment variable
335
+ 2. Hardcoded fallback in `dominus/start.py`
336
+
337
+ ## Architecture
338
+
339
+ ```
340
+ ┌─────────────────┐
341
+ │ Your App │
342
+ │ (async Python) │
343
+ └────────┬────────┘
344
+ │ await dominus.db.query(...)
345
+
346
+ ┌─────────────────┐
347
+ │ Dominus SDK │ ← JWT caching, circuit breaker, retries
348
+ │ (this package) │
349
+ └────────┬────────┘
350
+ │ HTTPS (base64-encoded JSON)
351
+
352
+ ┌─────────────────────────────────┐
353
+ │ Dominus Orchestrator │
354
+ │ (Cloud Run FastAPI backend) │
355
+ │ │
356
+ │ ┌─────────┬─────────┬────────┐ │
357
+ │ │ Warden │Guardian │Archivist│ │
358
+ │ │ Scribe │ Smith │Whisperer│ │
359
+ │ │ Herald │ Portal │ Courier│ │
360
+ │ └─────────┴─────────┴────────┘ │
361
+ └─────────────────────────────────┘
362
+ ```
363
+
364
+ ## Dependencies
365
+
366
+ - `httpx` - Async HTTP client
367
+ - `bcrypt` - Password hashing
368
+ - `cryptography` - Cache encryption
369
+
370
+ ## Documentation
371
+
372
+ - [Installation & Quick Start](dominus/QUICKSTART.md)
373
+ - [LLM Usage Guide](dominus/LLM-GUIDE.md)
374
+
375
+ ## Version
376
+
377
+ **v2.0.0** - Namespace-based API with unified orchestrator backend
378
+
379
+ ## License
380
+
381
+ Proprietary - CareBridge Systems