sovaria-sdk 0.2.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 (36) hide show
  1. sovaria_sdk-0.2.0/.gitignore +161 -0
  2. sovaria_sdk-0.2.0/PKG-INFO +173 -0
  3. sovaria_sdk-0.2.0/README.md +148 -0
  4. sovaria_sdk-0.2.0/__init__.py +0 -0
  5. sovaria_sdk-0.2.0/examples/test_app/README.md +73 -0
  6. sovaria_sdk-0.2.0/examples/test_app/main.py +432 -0
  7. sovaria_sdk-0.2.0/pyproject.toml +44 -0
  8. sovaria_sdk-0.2.0/sovaria/__init__.py +105 -0
  9. sovaria_sdk-0.2.0/sovaria/auth.py +187 -0
  10. sovaria_sdk-0.2.0/sovaria/client.py +2527 -0
  11. sovaria_sdk-0.2.0/sovaria/complete_api.py +1066 -0
  12. sovaria_sdk-0.2.0/sovaria/config.py +91 -0
  13. sovaria_sdk-0.2.0/sovaria/data.py +198 -0
  14. sovaria_sdk-0.2.0/sovaria/models.py +165 -0
  15. sovaria_sdk-0.2.0/sovaria/project.py +374 -0
  16. sovaria_sdk-0.2.0/sovaria/utils/__init__.py +1 -0
  17. sovaria_sdk-0.2.0/sovaria/utils/crypto.py +272 -0
  18. sovaria_sdk-0.2.0/tests/conftest.py +9 -0
  19. sovaria_sdk-0.2.0/tests/integration/__init__.py +1 -0
  20. sovaria_sdk-0.2.0/tests/integration/conftest.py +43 -0
  21. sovaria_sdk-0.2.0/tests/integration/test_api_integration.py +154 -0
  22. sovaria_sdk-0.2.0/tests/integration/test_dapg_workflow.py +123 -0
  23. sovaria_sdk-0.2.0/tests/unit/__init__.py +1 -0
  24. sovaria_sdk-0.2.0/tests/unit/conftest.py +9 -0
  25. sovaria_sdk-0.2.0/tests/unit/test_auth_manager.py +171 -0
  26. sovaria_sdk-0.2.0/tests/unit/test_billing_vector.py +58 -0
  27. sovaria_sdk-0.2.0/tests/unit/test_client_from_project_config.py +40 -0
  28. sovaria_sdk-0.2.0/tests/unit/test_client_requests.py +228 -0
  29. sovaria_sdk-0.2.0/tests/unit/test_client_scope.py +221 -0
  30. sovaria_sdk-0.2.0/tests/unit/test_crypto_utils.py +98 -0
  31. sovaria_sdk-0.2.0/tests/unit/test_dapg_wrappers.py +139 -0
  32. sovaria_sdk-0.2.0/tests/unit/test_data_wrappers.py +67 -0
  33. sovaria_sdk-0.2.0/tests/unit/test_mfa_auth.py +40 -0
  34. sovaria_sdk-0.2.0/tests/unit/test_portal_config.py +70 -0
  35. sovaria_sdk-0.2.0/tests/unit/test_project_scaffold.py +73 -0
  36. sovaria_sdk-0.2.0/tests/unit/test_sync_client.py +81 -0
@@ -0,0 +1,161 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ !apps/web/src/lib/
16
+ !apps/web/src/lib/**
17
+ parts/
18
+ sdist/
19
+ var/
20
+ wheels/
21
+ *.egg-info/
22
+ .installed.cfg
23
+ *.egg
24
+ MANIFEST
25
+
26
+ # Virtual environments
27
+
28
+ .venv
29
+ env/
30
+ venv/
31
+ ENV/
32
+ env.bak/
33
+ venv.bak/
34
+ sovaria-env/
35
+
36
+ # Testing
37
+ .tox/
38
+ .coverage
39
+ .coverage.*
40
+ .cache
41
+ nosetests.xml
42
+ coverage.xml
43
+ *.cover
44
+ .hypothesis/
45
+ .pytest_cache/
46
+
47
+ # MyPy
48
+ .mypy_cache/
49
+ .dmypy.json
50
+ dmypy.json
51
+
52
+ # Ruff
53
+ .ruff_cache/
54
+
55
+ # Node.js
56
+ node_modules/
57
+ npm-debug.log*
58
+ yarn-debug.log*
59
+ yarn-error.log*
60
+ .pnp/
61
+ .pnp.js
62
+ .yarn/cache
63
+ .yarn/unplugged
64
+ .yarn/build-state.yml
65
+ .yarn/install-state.gz
66
+
67
+ # Build outputs
68
+ dist/
69
+ .next/
70
+ out/
71
+ .turbo/
72
+
73
+ # IDEs
74
+ .vscode/
75
+ .idea/
76
+ *.swp
77
+ *.swo
78
+ *~
79
+ .DS_Store
80
+
81
+ # Docker
82
+ *.log
83
+ .docker/
84
+
85
+ # Database & Local Dev Data
86
+ infrastructure/local-dev/postgres/
87
+ infrastructure/local-dev/redis/
88
+ infrastructure/local-dev/etcd/
89
+ infrastructure/local-dev/temp-storage/
90
+ *.db
91
+ *.sqlite
92
+ *.sqlite3
93
+
94
+ # Backups & Archives
95
+ _backup_*/
96
+ *.tar.gz
97
+ *.zip
98
+
99
+ # Secrets & Credentials
100
+
101
+ *.key
102
+ *.pem
103
+ *.crt
104
+ secrets/
105
+ credentials/
106
+
107
+ # Terraform
108
+ .terraform/
109
+ *.tfstate
110
+ *.tfstate.backup
111
+ *.tfvars
112
+
113
+ # Kubernetes
114
+ *.kubeconfig
115
+
116
+ # Logs
117
+ logs/
118
+ *.log
119
+
120
+ # OS
121
+ .DS_Store
122
+ Thumbs.db
123
+
124
+ # Compiled binaries
125
+ *.exe
126
+ *.dll
127
+ *.dylib
128
+
129
+ # Generated files
130
+ proto/generated/
131
+ *.pb.go
132
+ *_pb2.py
133
+ *_pb2_grpc.py
134
+
135
+ # Temporary files
136
+ tmp/
137
+ temp/
138
+ .tmp/
139
+
140
+ # Coverage reports
141
+ htmlcov/
142
+ .coverage.*
143
+
144
+ # Compiled documentation
145
+ docs/_build/
146
+ site/
147
+
148
+ # Jupyter Notebooks
149
+ .ipynb_checkpoints/
150
+
151
+ # macOS
152
+ .AppleDouble
153
+ .LSOverride
154
+ Icon
155
+ ._*
156
+
157
+ /implementation_md
158
+
159
+ # dev TLS certs (generated by scripts/gen_grpc_certs.py)
160
+ engines/axis/certs/
161
+ sovaria_data/atlas-rel/atlas_rel.meta.json
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.5
2
+ Name: sovaria-sdk
3
+ Version: 0.2.0
4
+ Summary: Python SDK for Sovaria Gateway and Engines
5
+ Project-URL: Homepage, https://sovaria.in
6
+ Project-URL: Documentation, https://docs.sovaria.in/sdk
7
+ Project-URL: Repository, https://github.com/sovaria/sovaria-sdk
8
+ Author: Sovaria Team
9
+ Requires-Python: >=3.11
10
+ Requires-Dist: argon2-cffi>=23.1.0
11
+ Requires-Dist: cryptography>=46.0.0
12
+ Requires-Dist: email-validator>=2.2.0
13
+ Requires-Dist: httpx>=0.28.1
14
+ Requires-Dist: pydantic>=2.12.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: build>=1.2; extra == 'dev'
17
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
18
+ Requires-Dist: pytest>=8.0; extra == 'dev'
19
+ Requires-Dist: twine>=6.0; extra == 'dev'
20
+ Provides-Extra: docs
21
+ Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
22
+ Requires-Dist: mkdocs>=1.6.0; extra == 'docs'
23
+ Requires-Dist: mkdocstrings[python]>=0.29.0; extra == 'docs'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Sovaria Python SDK
27
+
28
+ Async Python SDK for the Sovaria gateway.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install sovaria-sdk
34
+ ```
35
+
36
+ Local workspace development:
37
+
38
+ ```bash
39
+ pip install -e apps/sdk/python
40
+ ```
41
+
42
+ ## Supabase-Style Bootstrap (Portal Config)
43
+
44
+ ```python
45
+ from sovaria import create_client
46
+
47
+ client = create_client(
48
+ {
49
+ "url": "https://gateway.sovaria.in",
50
+ "org_id": "11111111-1111-1111-1111-111111111111",
51
+ "project_id": "22222222-2222-2222-2222-222222222222",
52
+ "env_id": "33333333-3333-3333-3333-333333333333",
53
+ # optional: portal-issued publishable/anon key
54
+ "publishable_key": "<token>",
55
+ }
56
+ )
57
+ ```
58
+
59
+ Or initialize directly from environment variables:
60
+
61
+ ```python
62
+ from sovaria import SovariaClient
63
+
64
+ client = SovariaClient.from_env()
65
+ ```
66
+
67
+ Supported environment variables:
68
+ - `SOVARIA_URL`
69
+ - `SOVARIA_ORG_ID`
70
+ - `SOVARIA_PROJECT_ID`
71
+ - `SOVARIA_ENV_ID`
72
+ - `SOVARIA_ACCESS_TOKEN` or `SOVARIA_PUBLISHABLE_KEY` or `SOVARIA_ANON_KEY`
73
+
74
+ ## Quick Start
75
+
76
+ ```python
77
+ import asyncio
78
+ from sovaria import SovariaClient
79
+
80
+
81
+ async def main() -> None:
82
+ async with SovariaClient.from_env() as sov:
83
+ await sov.login("you@example.com", "password")
84
+ me = await sov.get_me()
85
+
86
+ # If your token includes scope claims, get_me() auto-hydrates scope.
87
+ # Otherwise, set scope explicitly for SQL/realtime routes:
88
+ # sov.set_scope(org_id="...", project_id="...", env_id="...")
89
+
90
+ health = await sov.get_engines_health()
91
+ print(me)
92
+ print(health)
93
+
94
+ # Realtime usage
95
+ await sov.stream_subscribe("db.table.users", "py-client-1")
96
+ presence = await sov.stream_presence("db.table.users")
97
+ print(presence)
98
+
99
+
100
+ asyncio.run(main())
101
+ ```
102
+
103
+ ## Sync Quick Start
104
+
105
+ ```python
106
+ from sovaria import SovariaSyncClient
107
+
108
+ with SovariaSyncClient.from_env() as sov:
109
+ sov.login("you@example.com", "password")
110
+ me = sov.get_me()
111
+ print(me)
112
+ ```
113
+
114
+ Use `SovariaSyncClient` for WSGI workers, cron jobs, and scripts where an
115
+ explicit async event loop would add unnecessary complexity.
116
+
117
+ ## Coverage
118
+
119
+ - Axis: auth, context, graph
120
+ - Atlas-Doc: put/get/delete/scan plain docs
121
+ - Atlas-Rel: SQL, table lifecycle, migrations
122
+ - Pulse: stream, e2ee key lifecycle, websocket URL helper
123
+ - Guard: templates, CRUD, evaluate, rollback, history
124
+ - Echo: audit + simulation
125
+ - Chrono: commit/timelines/snapshots/converge/variance
126
+ - Gateway: engine health
127
+
128
+ ## Project Scaffold from `sovaria.config.json`
129
+
130
+ You can scaffold a new client project directly from the SDK package.
131
+
132
+ ```python
133
+ from sovaria import (
134
+ DEFAULT_CONFIG_FILENAME,
135
+ create_project_from_config_file,
136
+ write_project_config_template,
137
+ )
138
+
139
+ # 1) Write template config JSON
140
+ write_project_config_template(DEFAULT_CONFIG_FILENAME, name="my-app")
141
+
142
+ # 2) Generate project folder structure from config
143
+ result = create_project_from_config_file(DEFAULT_CONFIG_FILENAME, target_dir=".")
144
+ print(result.project_root)
145
+ ```
146
+
147
+ Generated files include:
148
+
149
+ - `<project>/sovaria.config.json`
150
+ - `<project>/.env.example`
151
+ - `<project>/sovaria/functions/`
152
+ - `<project>/sovaria/migrations/`
153
+ - `<project>/sovaria/tests/`
154
+
155
+ ## Raw API Escape Hatch
156
+
157
+ You can call any gateway endpoint directly:
158
+
159
+ ```python
160
+ await sov.request("GET", "/api/v1/system/engines/health", requires_auth=False)
161
+ ```
162
+
163
+ ## Functions + Storage Pass-Through
164
+
165
+ ```python
166
+ # Forge deployment status
167
+ status = await sov.fn_status("deploy-123")
168
+
169
+ # Generic Vault path operations
170
+ await sov.store_put_json("kv/app/settings", {"theme": "light"})
171
+ settings = await sov.store_get("kv/app/settings")
172
+ await sov.store_delete("kv/app/settings")
173
+ ```
@@ -0,0 +1,148 @@
1
+ # Sovaria Python SDK
2
+
3
+ Async Python SDK for the Sovaria gateway.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install sovaria-sdk
9
+ ```
10
+
11
+ Local workspace development:
12
+
13
+ ```bash
14
+ pip install -e apps/sdk/python
15
+ ```
16
+
17
+ ## Supabase-Style Bootstrap (Portal Config)
18
+
19
+ ```python
20
+ from sovaria import create_client
21
+
22
+ client = create_client(
23
+ {
24
+ "url": "https://gateway.sovaria.in",
25
+ "org_id": "11111111-1111-1111-1111-111111111111",
26
+ "project_id": "22222222-2222-2222-2222-222222222222",
27
+ "env_id": "33333333-3333-3333-3333-333333333333",
28
+ # optional: portal-issued publishable/anon key
29
+ "publishable_key": "<token>",
30
+ }
31
+ )
32
+ ```
33
+
34
+ Or initialize directly from environment variables:
35
+
36
+ ```python
37
+ from sovaria import SovariaClient
38
+
39
+ client = SovariaClient.from_env()
40
+ ```
41
+
42
+ Supported environment variables:
43
+ - `SOVARIA_URL`
44
+ - `SOVARIA_ORG_ID`
45
+ - `SOVARIA_PROJECT_ID`
46
+ - `SOVARIA_ENV_ID`
47
+ - `SOVARIA_ACCESS_TOKEN` or `SOVARIA_PUBLISHABLE_KEY` or `SOVARIA_ANON_KEY`
48
+
49
+ ## Quick Start
50
+
51
+ ```python
52
+ import asyncio
53
+ from sovaria import SovariaClient
54
+
55
+
56
+ async def main() -> None:
57
+ async with SovariaClient.from_env() as sov:
58
+ await sov.login("you@example.com", "password")
59
+ me = await sov.get_me()
60
+
61
+ # If your token includes scope claims, get_me() auto-hydrates scope.
62
+ # Otherwise, set scope explicitly for SQL/realtime routes:
63
+ # sov.set_scope(org_id="...", project_id="...", env_id="...")
64
+
65
+ health = await sov.get_engines_health()
66
+ print(me)
67
+ print(health)
68
+
69
+ # Realtime usage
70
+ await sov.stream_subscribe("db.table.users", "py-client-1")
71
+ presence = await sov.stream_presence("db.table.users")
72
+ print(presence)
73
+
74
+
75
+ asyncio.run(main())
76
+ ```
77
+
78
+ ## Sync Quick Start
79
+
80
+ ```python
81
+ from sovaria import SovariaSyncClient
82
+
83
+ with SovariaSyncClient.from_env() as sov:
84
+ sov.login("you@example.com", "password")
85
+ me = sov.get_me()
86
+ print(me)
87
+ ```
88
+
89
+ Use `SovariaSyncClient` for WSGI workers, cron jobs, and scripts where an
90
+ explicit async event loop would add unnecessary complexity.
91
+
92
+ ## Coverage
93
+
94
+ - Axis: auth, context, graph
95
+ - Atlas-Doc: put/get/delete/scan plain docs
96
+ - Atlas-Rel: SQL, table lifecycle, migrations
97
+ - Pulse: stream, e2ee key lifecycle, websocket URL helper
98
+ - Guard: templates, CRUD, evaluate, rollback, history
99
+ - Echo: audit + simulation
100
+ - Chrono: commit/timelines/snapshots/converge/variance
101
+ - Gateway: engine health
102
+
103
+ ## Project Scaffold from `sovaria.config.json`
104
+
105
+ You can scaffold a new client project directly from the SDK package.
106
+
107
+ ```python
108
+ from sovaria import (
109
+ DEFAULT_CONFIG_FILENAME,
110
+ create_project_from_config_file,
111
+ write_project_config_template,
112
+ )
113
+
114
+ # 1) Write template config JSON
115
+ write_project_config_template(DEFAULT_CONFIG_FILENAME, name="my-app")
116
+
117
+ # 2) Generate project folder structure from config
118
+ result = create_project_from_config_file(DEFAULT_CONFIG_FILENAME, target_dir=".")
119
+ print(result.project_root)
120
+ ```
121
+
122
+ Generated files include:
123
+
124
+ - `<project>/sovaria.config.json`
125
+ - `<project>/.env.example`
126
+ - `<project>/sovaria/functions/`
127
+ - `<project>/sovaria/migrations/`
128
+ - `<project>/sovaria/tests/`
129
+
130
+ ## Raw API Escape Hatch
131
+
132
+ You can call any gateway endpoint directly:
133
+
134
+ ```python
135
+ await sov.request("GET", "/api/v1/system/engines/health", requires_auth=False)
136
+ ```
137
+
138
+ ## Functions + Storage Pass-Through
139
+
140
+ ```python
141
+ # Forge deployment status
142
+ status = await sov.fn_status("deploy-123")
143
+
144
+ # Generic Vault path operations
145
+ await sov.store_put_json("kv/app/settings", {"theme": "light"})
146
+ settings = await sov.store_get("kv/app/settings")
147
+ await sov.store_delete("kv/app/settings")
148
+ ```
File without changes
@@ -0,0 +1,73 @@
1
+ Interactive Sovaria SDK Test Application
2
+
3
+ Location
4
+ - apps/sdk/python/examples/test_app
5
+
6
+ Purpose
7
+ A comprehensive interactive CLI that demonstrates all major SDK capabilities:
8
+ - **Auth**: Register, login, logout, get user profile
9
+ - **Graph**: Create/list nodes, create edges, get context
10
+ - **Documents**: Put/get JSON documents
11
+ - **SQL**: Query relational data via Atlas-Rel
12
+ - **Streams**: Subscribe to realtime channels
13
+ - **System**: Check engines health
14
+
15
+ Features
16
+ - Menu-driven interactive interface
17
+ - Pretty-printed JSON responses
18
+ - Full response dumps for debugging
19
+ - Session persistence (auth state maintained)
20
+ - Error handling and recovery
21
+ - Graceful handling of unavailable services (e.g., Atlas-Rel)
22
+
23
+ Usage
24
+
25
+ Run the app:
26
+
27
+ ```bash
28
+ cd apps/sdk/python
29
+ python examples/test_app/main.py
30
+ ```
31
+
32
+ Or use a custom gateway URL:
33
+
34
+ ```bash
35
+ SOVARIA_URL=http://my-gateway:8000 python examples/test_app/main.py
36
+ ```
37
+
38
+ Interactive Menu
39
+ - `1` — Check system health (engines status)
40
+ - `2` — Register a new user
41
+ - `3` — Login with credentials
42
+ - `4` — View current user profile
43
+ - `5` — Logout
44
+ - `6` — Create a node (ORG, PROJECT, ENV, USER)
45
+ - `7` — List all nodes (with optional type filter)
46
+ - `8` — Get node details by ID
47
+ - `9` — Create an edge (relation between two nodes)
48
+ - `10` — Get user context on a resource
49
+ - `11` — Write a JSON document
50
+ - `12` — Read a JSON document
51
+ - `13` — Execute SQL query (requires Atlas-Rel)
52
+ - `14` — Create a relational table
53
+ - `15` — Subscribe to a realtime channel
54
+ - `0` — Exit
55
+
56
+ Example Workflow
57
+
58
+ 1. Start app: `python examples/test_app/main.py`
59
+ 2. Choose `1` to check gateway health
60
+ 3. Choose `2` to register: `user@example.com`, password, and name
61
+ 4. Choose `6` to create an ORG node: name it "Acme Corp"
62
+ 5. Choose `7` to list all nodes
63
+ 6. Choose `11` to write a document:
64
+ - Collection: `users`
65
+ - Document ID: `doc1`
66
+ - JSON: `{"name": "Alice", "email": "alice@acme.com"}`
67
+ 7. Choose `12` to read the document back
68
+
69
+ Notes
70
+ - The app requires the project virtualenv to be active (SDK dependencies must be installed).
71
+ - JSON input fields expect single-line, compact JSON (no multi-line).
72
+ - Response dumps are optional — you can skip them (press `n` when prompted).
73
+ - If Atlas-Rel is unavailable, SQL queries will fail gracefully with a message.