dominus-sdk-python-dev 2.1.7__py3-none-any.whl → 2.2.0__py3-none-any.whl

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.
dominus/__init__.py CHANGED
@@ -4,29 +4,36 @@ CB Dominus SDK - Ultra-flat async SDK for CareBridge Services
4
4
  Ultra-Flat API:
5
5
  from dominus import dominus
6
6
 
7
- # Secrets (root level)
7
+ # Secrets (root level shortcuts)
8
8
  value = await dominus.get("DB_URL")
9
9
  await dominus.upsert("KEY", "value")
10
10
 
11
- # Auth (root level)
12
- await dominus.add_user(username="john", password="secret", role_id="...")
13
- await dominus.add_scope(slug="read", display_name="Read", tenant_category_id=1)
14
- result = await dominus.verify_user_password(username="john", password="secret")
11
+ # Database (namespace-based)
12
+ tables = await dominus.db.tables()
13
+ rows = await dominus.db.query("users", filters={"status": "active"})
14
+ await dominus.db.insert("users", {"name": "John"})
15
15
 
16
- # SQL data - app schema (root level)
17
- tables = await dominus.list_tables()
18
- rows = await dominus.query_table("users")
19
- await dominus.insert_row("users", {"name": "John"})
16
+ # Auth (namespace-based)
17
+ users = await dominus.auth.list_users()
18
+ await dominus.auth.create_user(username="john", email="j@ex.com", password="secret")
19
+
20
+ # DDL (namespace-based)
21
+ await dominus.ddl.create_table("public", "users", [{"name": "id", "type": "UUID"}])
22
+
23
+ # Files (namespace-based)
24
+ result = await dominus.files.upload(data=file_bytes, filename="report.pdf", category="reports")
20
25
 
21
- # SQL data - secure schema (secure namespace)
22
- rows = await dominus.secure.query_table("patients")
23
- await dominus.secure.insert_row("patients", {"mrn": "12345"})
26
+ # Secure table access with audit logging
27
+ rows = await dominus.db_secure.query("patients", context=SecureAccessContext(
28
+ reason="Reviewing chart",
29
+ actor=user_id
30
+ ))
24
31
 
25
- # Schema DDL - app schema (root level)
26
- await dominus.add_table("users", [{"name": "id", "type": "UUID"}])
32
+ # Admin operations
33
+ await dominus.admin.reseed_admin_category()
27
34
 
28
- # Schema DDL - secure schema (secure namespace)
29
- await dominus.secure.add_table("patients", [...])
35
+ # Portal authentication
36
+ session = await dominus.portal.login("user@example.com", "password", "tenant-id")
30
37
 
31
38
  # Open DSN
32
39
  dsn = await dominus.open.dsn()
@@ -34,14 +41,68 @@ Ultra-Flat API:
34
41
  # Health
35
42
  status = await dominus.health.check()
36
43
 
37
- Backward Compatible String API:
44
+ Backward Compatible APIs:
45
+ # String-based API
38
46
  result = await dominus("secrets.get", key="DB_URL")
47
+
48
+ # Flat API (root level shortcuts for common operations)
49
+ await dominus.list_tables()
50
+ await dominus.query_table("users")
51
+ await dominus.insert_row("users", {"name": "John"})
52
+
53
+ Crypto Helpers:
54
+ from dominus import hash_password, hash_psk, generate_token
55
+ hashed = hash_password("secret")
39
56
  """
40
- from .start import dominus
57
+ from .start import dominus, Dominus
41
58
  from .helpers.core import DominusResponse
42
59
 
43
- __version__ = "0.3.0"
60
+ # Export crypto helpers
61
+ from .helpers.crypto import (
62
+ hash_password,
63
+ verify_password,
64
+ hash_psk,
65
+ verify_psk,
66
+ generate_psk_local,
67
+ hash_token,
68
+ generate_token,
69
+ )
70
+
71
+ # Export namespace classes for type hints
72
+ from .namespaces.db import DbNamespace
73
+ from .namespaces.auth import AuthNamespace
74
+ from .namespaces.ddl import DdlNamespace
75
+ from .namespaces.files import FilesNamespace
76
+ from .namespaces.portal import PortalNamespace
77
+ from .namespaces.admin import AdminNamespace
78
+ from .namespaces.secure import SecureNamespace, SecureAccessContext
79
+
80
+ # Export cache utilities
81
+ from .helpers.cache import dominus_cache
82
+
83
+ __version__ = "2.2.0"
44
84
  __all__ = [
85
+ # Main SDK instance
45
86
  "dominus",
87
+ "Dominus",
46
88
  "DominusResponse",
89
+ # Crypto helpers
90
+ "hash_password",
91
+ "verify_password",
92
+ "hash_psk",
93
+ "verify_psk",
94
+ "generate_psk_local",
95
+ "hash_token",
96
+ "generate_token",
97
+ # Namespace classes (for type hints)
98
+ "DbNamespace",
99
+ "AuthNamespace",
100
+ "DdlNamespace",
101
+ "FilesNamespace",
102
+ "PortalNamespace",
103
+ "AdminNamespace",
104
+ "SecureNamespace",
105
+ "SecureAccessContext",
106
+ # Cache utilities
107
+ "dominus_cache",
47
108
  ]
@@ -1,24 +1,24 @@
1
1
  """SDK Configuration"""
2
2
  from .endpoints import (
3
+ BASE_URL,
3
4
  SOVEREIGN_URL,
4
5
  ARCHITECT_URL,
5
6
  ORCHESTRATOR_URL,
6
7
  WARDEN_URL,
8
+ get_base_url,
7
9
  get_service_url,
8
10
  get_architect_url,
9
11
  get_sovereign_url,
10
- PROJECT_NUMBER,
11
- REGION,
12
12
  )
13
13
 
14
14
  __all__ = [
15
+ "BASE_URL",
15
16
  "SOVEREIGN_URL",
16
17
  "ARCHITECT_URL",
17
18
  "ORCHESTRATOR_URL",
18
19
  "WARDEN_URL",
20
+ "get_base_url",
19
21
  "get_service_url",
20
22
  "get_architect_url",
21
23
  "get_sovereign_url",
22
- "PROJECT_NUMBER",
23
- "REGION",
24
24
  ]
@@ -0,0 +1,58 @@
1
+ """
2
+ Admin Namespace - Infrastructure and administrative operations.
3
+
4
+ Provides admin-level operations for seeding and resetting data.
5
+ """
6
+ from typing import Any, Dict, TYPE_CHECKING
7
+
8
+ if TYPE_CHECKING:
9
+ from ..start import Dominus
10
+
11
+
12
+ class AdminNamespace:
13
+ """
14
+ Administrative operations namespace.
15
+
16
+ Provides infrastructure-level operations like reseeding admin data
17
+ and resetting schemas.
18
+
19
+ Usage:
20
+ # Reseed admin category with default data
21
+ result = await dominus.admin.reseed_admin_category()
22
+
23
+ # Reset and reseed admin category
24
+ result = await dominus.admin.reset_admin_category()
25
+ """
26
+
27
+ def __init__(self, client: "Dominus"):
28
+ self._client = client
29
+
30
+ async def reseed_admin_category(self) -> Dict[str, Any]:
31
+ """
32
+ Reseed the admin category with default data.
33
+
34
+ Adds default scopes, roles, and navigation items to the admin
35
+ tenant category without dropping existing data.
36
+
37
+ Returns:
38
+ Dict with success status, message, and seeded_entities
39
+ """
40
+ return await self._client._request(
41
+ endpoint="/api/admin/reseed",
42
+ method="POST"
43
+ )
44
+
45
+ async def reset_admin_category(self) -> Dict[str, Any]:
46
+ """
47
+ Reset and reseed the admin category.
48
+
49
+ Drops all data from admin schemas and reseeds with default data.
50
+ WARNING: This is a destructive operation.
51
+
52
+ Returns:
53
+ Dict with success status, message, and operations
54
+ """
55
+ return await self._client._request(
56
+ endpoint="/api/admin/reset",
57
+ method="POST"
58
+ )