mdb-engine 0.1.6__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.
- mdb_engine/README.md +144 -0
- mdb_engine/__init__.py +37 -0
- mdb_engine/auth/README.md +631 -0
- mdb_engine/auth/__init__.py +128 -0
- mdb_engine/auth/casbin_factory.py +199 -0
- mdb_engine/auth/casbin_models.py +46 -0
- mdb_engine/auth/config_defaults.py +71 -0
- mdb_engine/auth/config_helpers.py +213 -0
- mdb_engine/auth/cookie_utils.py +158 -0
- mdb_engine/auth/decorators.py +350 -0
- mdb_engine/auth/dependencies.py +747 -0
- mdb_engine/auth/helpers.py +64 -0
- mdb_engine/auth/integration.py +578 -0
- mdb_engine/auth/jwt.py +225 -0
- mdb_engine/auth/middleware.py +241 -0
- mdb_engine/auth/oso_factory.py +323 -0
- mdb_engine/auth/provider.py +570 -0
- mdb_engine/auth/restrictions.py +271 -0
- mdb_engine/auth/session_manager.py +477 -0
- mdb_engine/auth/token_lifecycle.py +213 -0
- mdb_engine/auth/token_store.py +289 -0
- mdb_engine/auth/users.py +1516 -0
- mdb_engine/auth/utils.py +614 -0
- mdb_engine/cli/__init__.py +13 -0
- mdb_engine/cli/commands/__init__.py +7 -0
- mdb_engine/cli/commands/generate.py +105 -0
- mdb_engine/cli/commands/migrate.py +83 -0
- mdb_engine/cli/commands/show.py +70 -0
- mdb_engine/cli/commands/validate.py +63 -0
- mdb_engine/cli/main.py +41 -0
- mdb_engine/cli/utils.py +92 -0
- mdb_engine/config.py +217 -0
- mdb_engine/constants.py +160 -0
- mdb_engine/core/README.md +542 -0
- mdb_engine/core/__init__.py +42 -0
- mdb_engine/core/app_registration.py +392 -0
- mdb_engine/core/connection.py +243 -0
- mdb_engine/core/engine.py +749 -0
- mdb_engine/core/index_management.py +162 -0
- mdb_engine/core/manifest.py +2793 -0
- mdb_engine/core/seeding.py +179 -0
- mdb_engine/core/service_initialization.py +355 -0
- mdb_engine/core/types.py +413 -0
- mdb_engine/database/README.md +522 -0
- mdb_engine/database/__init__.py +31 -0
- mdb_engine/database/abstraction.py +635 -0
- mdb_engine/database/connection.py +387 -0
- mdb_engine/database/scoped_wrapper.py +1721 -0
- mdb_engine/embeddings/README.md +184 -0
- mdb_engine/embeddings/__init__.py +62 -0
- mdb_engine/embeddings/dependencies.py +193 -0
- mdb_engine/embeddings/service.py +759 -0
- mdb_engine/exceptions.py +167 -0
- mdb_engine/indexes/README.md +651 -0
- mdb_engine/indexes/__init__.py +21 -0
- mdb_engine/indexes/helpers.py +145 -0
- mdb_engine/indexes/manager.py +895 -0
- mdb_engine/memory/README.md +451 -0
- mdb_engine/memory/__init__.py +30 -0
- mdb_engine/memory/service.py +1285 -0
- mdb_engine/observability/README.md +515 -0
- mdb_engine/observability/__init__.py +42 -0
- mdb_engine/observability/health.py +296 -0
- mdb_engine/observability/logging.py +161 -0
- mdb_engine/observability/metrics.py +297 -0
- mdb_engine/routing/README.md +462 -0
- mdb_engine/routing/__init__.py +73 -0
- mdb_engine/routing/websockets.py +813 -0
- mdb_engine/utils/__init__.py +7 -0
- mdb_engine-0.1.6.dist-info/METADATA +213 -0
- mdb_engine-0.1.6.dist-info/RECORD +75 -0
- mdb_engine-0.1.6.dist-info/WHEEL +5 -0
- mdb_engine-0.1.6.dist-info/entry_points.txt +2 -0
- mdb_engine-0.1.6.dist-info/licenses/LICENSE +661 -0
- mdb_engine-0.1.6.dist-info/top_level.txt +1 -0
mdb_engine/exceptions.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Custom exceptions for MDB_ENGINE.
|
|
3
|
+
|
|
4
|
+
These exceptions provide more specific error types while maintaining
|
|
5
|
+
backward compatibility with RuntimeError.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any, Dict, List, Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MongoDBEngineError(RuntimeError):
|
|
12
|
+
"""
|
|
13
|
+
Base exception for MongoDB Engine errors.
|
|
14
|
+
|
|
15
|
+
This exception maintains backward compatibility with RuntimeError
|
|
16
|
+
while providing a more specific base class for MDB_ENGINE errors.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
message: Error message
|
|
20
|
+
context: Optional dictionary with additional context (app_slug,
|
|
21
|
+
collection_name, etc.)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self, message: str, context: Optional[Dict[str, Any]] = None) -> None:
|
|
25
|
+
"""
|
|
26
|
+
Initialize the exception.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
message: Error message
|
|
30
|
+
context: Optional dictionary with additional context information
|
|
31
|
+
"""
|
|
32
|
+
super().__init__(message)
|
|
33
|
+
self.message = message
|
|
34
|
+
self.context = context or {}
|
|
35
|
+
|
|
36
|
+
def __str__(self) -> str:
|
|
37
|
+
"""Return formatted error message with context if available."""
|
|
38
|
+
if self.context:
|
|
39
|
+
context_str = ", ".join(f"{k}={v}" for k, v in self.context.items())
|
|
40
|
+
return f"{self.message} (context: {context_str})"
|
|
41
|
+
return self.message
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class InitializationError(MongoDBEngineError):
|
|
45
|
+
"""
|
|
46
|
+
Raised when engine initialization fails.
|
|
47
|
+
|
|
48
|
+
This exception is raised when MongoDB connection fails or
|
|
49
|
+
other critical initialization steps fail.
|
|
50
|
+
|
|
51
|
+
Attributes:
|
|
52
|
+
message: Error message
|
|
53
|
+
mongo_uri: MongoDB connection URI (if available)
|
|
54
|
+
db_name: Database name (if available)
|
|
55
|
+
context: Additional context information
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
def __init__(
|
|
59
|
+
self,
|
|
60
|
+
message: str,
|
|
61
|
+
mongo_uri: Optional[str] = None,
|
|
62
|
+
db_name: Optional[str] = None,
|
|
63
|
+
context: Optional[Dict[str, Any]] = None,
|
|
64
|
+
) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Initialize the initialization error.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
message: Error message
|
|
70
|
+
mongo_uri: MongoDB connection URI (if available)
|
|
71
|
+
db_name: Database name (if available)
|
|
72
|
+
context: Additional context information
|
|
73
|
+
"""
|
|
74
|
+
context = context or {}
|
|
75
|
+
if mongo_uri:
|
|
76
|
+
context["mongo_uri"] = mongo_uri
|
|
77
|
+
if db_name:
|
|
78
|
+
context["db_name"] = db_name
|
|
79
|
+
super().__init__(message, context=context)
|
|
80
|
+
self.mongo_uri = mongo_uri
|
|
81
|
+
self.db_name = db_name
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class ManifestValidationError(MongoDBEngineError):
|
|
85
|
+
"""
|
|
86
|
+
Raised when manifest validation fails.
|
|
87
|
+
|
|
88
|
+
This exception provides more context about validation failures
|
|
89
|
+
while maintaining compatibility with RuntimeError.
|
|
90
|
+
|
|
91
|
+
Attributes:
|
|
92
|
+
message: Error message
|
|
93
|
+
error_paths: List of JSON paths with validation errors
|
|
94
|
+
manifest_slug: App slug from manifest (if available)
|
|
95
|
+
schema_version: Schema version used for validation (if available)
|
|
96
|
+
context: Additional context information
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
def __init__(
|
|
100
|
+
self,
|
|
101
|
+
message: str,
|
|
102
|
+
error_paths: Optional[List[str]] = None,
|
|
103
|
+
manifest_slug: Optional[str] = None,
|
|
104
|
+
schema_version: Optional[str] = None,
|
|
105
|
+
context: Optional[Dict[str, Any]] = None,
|
|
106
|
+
) -> None:
|
|
107
|
+
"""
|
|
108
|
+
Initialize the manifest validation error.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
message: Error message
|
|
112
|
+
error_paths: List of JSON paths with validation errors
|
|
113
|
+
manifest_slug: App slug from manifest (if available)
|
|
114
|
+
schema_version: Schema version used for validation (if available)
|
|
115
|
+
context: Additional context information
|
|
116
|
+
"""
|
|
117
|
+
context = context or {}
|
|
118
|
+
if error_paths:
|
|
119
|
+
context["error_paths"] = error_paths
|
|
120
|
+
if manifest_slug:
|
|
121
|
+
context["manifest_slug"] = manifest_slug
|
|
122
|
+
if schema_version:
|
|
123
|
+
context["schema_version"] = schema_version
|
|
124
|
+
super().__init__(message, context=context)
|
|
125
|
+
self.error_paths = error_paths
|
|
126
|
+
self.manifest_slug = manifest_slug
|
|
127
|
+
self.schema_version = schema_version
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class ConfigurationError(MongoDBEngineError):
|
|
131
|
+
"""
|
|
132
|
+
Raised when configuration is invalid or missing.
|
|
133
|
+
|
|
134
|
+
This exception is raised when required configuration
|
|
135
|
+
parameters are missing or invalid.
|
|
136
|
+
|
|
137
|
+
Attributes:
|
|
138
|
+
message: Error message
|
|
139
|
+
config_key: Configuration key that caused the error (if available)
|
|
140
|
+
config_value: Configuration value that caused the error (if available)
|
|
141
|
+
context: Additional context information
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
def __init__(
|
|
145
|
+
self,
|
|
146
|
+
message: str,
|
|
147
|
+
config_key: Optional[str] = None,
|
|
148
|
+
config_value: Optional[Any] = None,
|
|
149
|
+
context: Optional[Dict[str, Any]] = None,
|
|
150
|
+
) -> None:
|
|
151
|
+
"""
|
|
152
|
+
Initialize the configuration error.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
message: Error message
|
|
156
|
+
config_key: Configuration key that caused the error (if available)
|
|
157
|
+
config_value: Configuration value that caused the error (if available)
|
|
158
|
+
context: Additional context information
|
|
159
|
+
"""
|
|
160
|
+
context = context or {}
|
|
161
|
+
if config_key:
|
|
162
|
+
context["config_key"] = config_key
|
|
163
|
+
if config_value is not None:
|
|
164
|
+
context["config_value"] = config_value
|
|
165
|
+
super().__init__(message, context=context)
|
|
166
|
+
self.config_key = config_key
|
|
167
|
+
self.config_value = config_value
|