feat(standards): codify codegen, ship generic Tier-B infra, add get_app_template + prompts; fix docs:// regressions

P0: fix doc:// -> docs:// across standards src/server/registry and regenerate stale mongo-ops bundle. P1: build recipe + spec-first routing now document the openapi-first codegen fast path (models/routes with --inject-request/--package). P4: CRUD template documents the model-vs-document id rule (BaseDocument owns id). P5: authless guidance (omit security keys). P6: template gains generic infra (http_cache, keyed SSE bus, KV port+in-memory+Redis), interfaces/openapi.py + .dockerignore + generic build test registered as components, and a get_app_template tool; genericity matrix marks LLM pool + human-in-loop as reference-app patterns. P7: intake/build/start_app/trial prompts. P8: template ships tests/integration/test_openapi_app_builds.py. Rebuilt standards + openapi-first bundles and re-collected.
This commit is contained in:
2026-10-13 03:26:51 +05:30
parent ef951a1913
commit fced40af59
109 changed files with 4082 additions and 5885 deletions

View File

@@ -2,49 +2,14 @@
"module": "mongo_ops.cache.backend",
"content": {
"path": "mongo_ops.cache.backend",
"docstring": "Cache backend abstraction.",
"docstring": "# Summary\n\nCache backend abstraction.",
"objects": {
"ABC": {
"name": "ABC",
"kind": "alias",
"path": "mongo_ops.cache.backend.ABC",
"signature": "<bound method Alias.signature of Alias('ABC', 'abc.ABC')>",
"docstring": null
},
"abstractmethod": {
"name": "abstractmethod",
"kind": "alias",
"path": "mongo_ops.cache.backend.abstractmethod",
"signature": "<bound method Alias.signature of Alias('abstractmethod', 'abc.abstractmethod')>",
"docstring": null
},
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mongo_ops.cache.backend.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.cache.backend.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"ObjectId": {
"name": "ObjectId",
"kind": "alias",
"path": "mongo_ops.cache.backend.ObjectId",
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
"docstring": null
},
"CacheStats": {
"name": "CacheStats",
"kind": "class",
"path": "mongo_ops.cache.backend.CacheStats",
"signature": "<bound method Class.signature of Class('CacheStats', 9, 16)>",
"docstring": null,
"signature": "CacheStats(hits: int = 0, misses: int = 0, sets: int = 0, deletes: int = 0, current_size: int = 0, max_size: int = 0)",
"docstring": "Snapshot of cache usage and activity counters.\n\nAttributes:\n hits (int):\n Number of get() calls that found a value.\n misses (int):\n Number of get() calls that returned None.\n sets (int):\n Number of values written to the cache.\n deletes (int):\n Number of keys removed.\n current_size (int):\n Number of entries currently held.\n max_size (int):\n Maximum number of entries the cache allows (0 = unbounded).",
"members": {
"hits": {
"name": "hits",
@@ -94,8 +59,8 @@
"name": "CircularReferenceError",
"kind": "class",
"path": "mongo_ops.cache.backend.CircularReferenceError",
"signature": "<bound method Class.signature of Class('CircularReferenceError', 19, 24)>",
"docstring": null,
"signature": "CircularReferenceError(collection: str, doc_id: ObjectId, path: list[str])",
"docstring": "Raised when population detects a cycle in the reference graph.\n\nAttributes:\n collection (str):\n Collection where the cycle was detected.\n doc_id (ObjectId):\n Document ID where the cycle was detected.\n path (list[str]):\n Ordered labels describing the visited reference path.",
"members": {
"collection": {
"name": "collection",
@@ -124,64 +89,64 @@
"name": "CacheBackend",
"kind": "class",
"path": "mongo_ops.cache.backend.CacheBackend",
"signature": "<bound method Class.signature of Class('CacheBackend', 27, 58)>",
"docstring": null,
"signature": null,
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
"members": {
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.get",
"signature": "<bound method Function.signature of Function('get', 28, 30)>",
"docstring": null
"signature": "get(key: str) -> bytes | None",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.set",
"signature": "<bound method Function.signature of Function('set', 32, 34)>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None) -> None",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.delete",
"signature": "<bound method Function.signature of Function('delete', 36, 38)>",
"docstring": null
"signature": "delete(key: str) -> None",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.exists",
"signature": "<bound method Function.signature of Function('exists', 40, 42)>",
"docstring": null
"signature": "exists(key: str) -> bool",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.clear_pattern",
"signature": "<bound method Function.signature of Function('clear_pattern', 44, 46)>",
"docstring": null
"signature": "clear_pattern(pattern: str) -> None",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.get_stats",
"signature": "<bound method Function.signature of Function('get_stats', 48, 50)>",
"docstring": null
"signature": "get_stats() -> CacheStats",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
},
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.initialize",
"signature": "<bound method Function.signature of Function('initialize', 52, 54)>",
"docstring": null
"signature": "initialize() -> None",
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.backend.CacheBackend.shutdown",
"signature": "<bound method Function.signature of Function('shutdown', 56, 58)>",
"docstring": null
"signature": "shutdown() -> None",
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
}
}
}

View File

@@ -2,42 +2,14 @@
"module": "mongo_ops.cache.config",
"content": {
"path": "mongo_ops.cache.config",
"docstring": "Cache configuration.",
"docstring": "# Summary\n\nCache configuration.",
"objects": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mongo_ops.cache.config.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"Literal": {
"name": "Literal",
"kind": "alias",
"path": "mongo_ops.cache.config.Literal",
"signature": "<bound method Alias.signature of Alias('Literal', 'typing.Literal')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.cache.config.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"Redis": {
"name": "Redis",
"kind": "alias",
"path": "mongo_ops.cache.config.Redis",
"signature": "<bound method Alias.signature of Alias('Redis', 'redis.asyncio.Redis')>",
"docstring": null
},
"CacheConfig": {
"name": "CacheConfig",
"kind": "class",
"path": "mongo_ops.cache.config.CacheConfig",
"signature": "<bound method Class.signature of Class('CacheConfig', 11, 25)>",
"docstring": null,
"signature": "CacheConfig(enabled: bool = True, backend: Literal['memory', 'redis'] = 'memory', redis_client: Redis | None = None, default_ttl: int = 300, max_entries: int = 10000, key_prefix: str = '', cleanup_interval: int = 60)",
"docstring": "Configuration for the cached repository layer.\n\nAttributes:\n enabled (bool):\n Whether caching is active for the repository.\n backend (Literal[\"memory\", \"redis\"]):\n Which backend to use. Defaults to \"memory\".\n redis_client (Optional[Redis]):\n Redis client required when backend is \"redis\".\n default_ttl (int):\n Default time-to-live for cached entries, in seconds.\n max_entries (int):\n Maximum entries for the in-memory backend.\n key_prefix (str):\n Prefix applied to cache keys; defaults to the collection name\n when empty.\n cleanup_interval (int):\n Interval (seconds) for the in-memory expiry sweep.",
"members": {
"enabled": {
"name": "enabled",

View File

@@ -2,126 +2,70 @@
"module": "mongo_ops.cache.in_memory",
"content": {
"path": "mongo_ops.cache.in_memory",
"docstring": null,
"docstring": "# Summary\n\nIn-memory cache backend with TTL-based eviction and encode/decode helpers.",
"objects": {
"asyncio": {
"name": "asyncio",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.asyncio",
"signature": "<bound method Alias.signature of Alias('asyncio', 'asyncio')>",
"docstring": null
},
"heapq": {
"name": "heapq",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.heapq",
"signature": "<bound method Alias.signature of Alias('heapq', 'heapq')>",
"docstring": null
},
"json": {
"name": "json",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.json",
"signature": "<bound method Alias.signature of Alias('json', 'json')>",
"docstring": null
},
"OrderedDict": {
"name": "OrderedDict",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.OrderedDict",
"signature": "<bound method Alias.signature of Alias('OrderedDict', 'collections.OrderedDict')>",
"docstring": null
},
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"timedelta": {
"name": "timedelta",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.timedelta",
"signature": "<bound method Alias.signature of Alias('timedelta', 'datetime.timedelta')>",
"docstring": null
},
"timezone": {
"name": "timezone",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.timezone",
"signature": "<bound method Alias.signature of Alias('timezone', 'datetime.timezone')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.cache.in_memory.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"CacheBackend": {
"name": "CacheBackend",
"kind": "class",
"path": "mongo_ops.cache.in_memory.CacheBackend",
"signature": "<bound method Alias.signature of Alias('CacheBackend', 'mongo_ops.cache.backend.CacheBackend')>",
"docstring": null,
"signature": null,
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
"members": {
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.get",
"signature": "<bound method Alias.signature of Alias('get', 'mongo_ops.cache.backend.CacheBackend.get')>",
"docstring": null
"signature": "get(key: str)",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.set",
"signature": "<bound method Alias.signature of Alias('set', 'mongo_ops.cache.backend.CacheBackend.set')>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None)",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.delete",
"signature": "<bound method Alias.signature of Alias('delete', 'mongo_ops.cache.backend.CacheBackend.delete')>",
"docstring": null
"signature": "delete(key: str)",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.exists",
"signature": "<bound method Alias.signature of Alias('exists', 'mongo_ops.cache.backend.CacheBackend.exists')>",
"docstring": null
"signature": "exists(key: str)",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.clear_pattern",
"signature": "<bound method Alias.signature of Alias('clear_pattern', 'mongo_ops.cache.backend.CacheBackend.clear_pattern')>",
"docstring": null
"signature": "clear_pattern(pattern: str)",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.get_stats",
"signature": "<bound method Alias.signature of Alias('get_stats', 'mongo_ops.cache.backend.CacheBackend.get_stats')>",
"docstring": null
"signature": "get_stats()",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
},
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.initialize",
"signature": "<bound method Alias.signature of Alias('initialize', 'mongo_ops.cache.backend.CacheBackend.initialize')>",
"docstring": null
"signature": "initialize()",
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.in_memory.CacheBackend.shutdown",
"signature": "<bound method Alias.signature of Alias('shutdown', 'mongo_ops.cache.backend.CacheBackend.shutdown')>",
"docstring": null
"signature": "shutdown()",
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
}
}
},
@@ -129,49 +73,49 @@
"name": "CacheStats",
"kind": "class",
"path": "mongo_ops.cache.in_memory.CacheStats",
"signature": "<bound method Alias.signature of Alias('CacheStats', 'mongo_ops.cache.backend.CacheStats')>",
"docstring": null,
"signature": "CacheStats(hits: int = 0, misses: int = 0, sets: int = 0, deletes: int = 0, current_size: int = 0, max_size: int = 0)",
"docstring": "Snapshot of cache usage and activity counters.\n\nAttributes:\n hits (int):\n Number of get() calls that found a value.\n misses (int):\n Number of get() calls that returned None.\n sets (int):\n Number of values written to the cache.\n deletes (int):\n Number of keys removed.\n current_size (int):\n Number of entries currently held.\n max_size (int):\n Maximum number of entries the cache allows (0 = unbounded).",
"members": {
"hits": {
"name": "hits",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.hits",
"signature": "<bound method Alias.signature of Alias('hits', 'mongo_ops.cache.backend.CacheStats.hits')>",
"signature": null,
"docstring": null
},
"misses": {
"name": "misses",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.misses",
"signature": "<bound method Alias.signature of Alias('misses', 'mongo_ops.cache.backend.CacheStats.misses')>",
"signature": null,
"docstring": null
},
"sets": {
"name": "sets",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.sets",
"signature": "<bound method Alias.signature of Alias('sets', 'mongo_ops.cache.backend.CacheStats.sets')>",
"signature": null,
"docstring": null
},
"deletes": {
"name": "deletes",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.deletes",
"signature": "<bound method Alias.signature of Alias('deletes', 'mongo_ops.cache.backend.CacheStats.deletes')>",
"signature": null,
"docstring": null
},
"current_size": {
"name": "current_size",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.current_size",
"signature": "<bound method Alias.signature of Alias('current_size', 'mongo_ops.cache.backend.CacheStats.current_size')>",
"signature": null,
"docstring": null
},
"max_size": {
"name": "max_size",
"kind": "attribute",
"path": "mongo_ops.cache.in_memory.CacheStats.max_size",
"signature": "<bound method Alias.signature of Alias('max_size', 'mongo_ops.cache.backend.CacheStats.max_size')>",
"signature": null,
"docstring": null
}
}
@@ -180,64 +124,64 @@
"name": "InMemoryCacheBackend",
"kind": "class",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend",
"signature": "<bound method Class.signature of Class('InMemoryCacheBackend', 22, 121)>",
"docstring": null,
"signature": "InMemoryCacheBackend(max_entries: int = 10000, default_ttl: int = 300, cleanup_interval: int = 60)",
"docstring": "Cache backend backed by an in-memory dict with TTL expiry.\n\nEntries are stored in an OrderedDict for LRU-compatible eviction and a\nmin-heap of expiry timestamps drives periodic removal of stale entries.\n\nNotes:\n **Thread safety:**\n\n All operations take an asyncio lock; the backend is safe for\n concurrent use within a single event loop.",
"members": {
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.initialize",
"signature": "<bound method Function.signature of Function('initialize', 38, 39)>",
"docstring": null
"signature": "initialize() -> None",
"docstring": "Start the periodic expired-entry cleanup task."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.shutdown",
"signature": "<bound method Function.signature of Function('shutdown', 41, 48)>",
"docstring": null
"signature": "shutdown() -> None",
"docstring": "Cancel and await the cleanup task."
},
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.get",
"signature": "<bound method Function.signature of Function('get', 50, 57)>",
"docstring": null
"signature": "get(key: str) -> bytes | None",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.set",
"signature": "<bound method Function.signature of Function('set', 59, 68)>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None) -> None",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds; defaults to the backend default."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.delete",
"signature": "<bound method Function.signature of Function('delete', 70, 75)>",
"docstring": null
"signature": "delete(key: str) -> None",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.exists",
"signature": "<bound method Function.signature of Function('exists', 77, 79)>",
"docstring": null
"signature": "exists(key: str) -> bool",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.clear_pattern",
"signature": "<bound method Function.signature of Function('clear_pattern', 81, 86)>",
"docstring": null
"signature": "clear_pattern(pattern: str) -> None",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.in_memory.InMemoryCacheBackend.get_stats",
"signature": "<bound method Function.signature of Function('get_stats', 88, 97)>",
"docstring": null
"signature": "get_stats() -> CacheStats",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
}
}
},
@@ -245,15 +189,15 @@
"name": "encode_value",
"kind": "function",
"path": "mongo_ops.cache.in_memory.encode_value",
"signature": "<bound method Function.signature of Function('encode_value', 127, 128)>",
"docstring": null
"signature": "encode_value(value: dict) -> bytes",
"docstring": "Encode a dict into cache-ready bytes.\n\nNon-serializable values (e.g., ObjectId) are coerced with str().\n\nArgs:\n value (dict):\n The dictionary to encode.\n\nReturns:\n bytes: UTF-8 JSON bytes."
},
"decode_value": {
"name": "decode_value",
"kind": "function",
"path": "mongo_ops.cache.in_memory.decode_value",
"signature": "<bound method Function.signature of Function('decode_value', 131, 132)>",
"docstring": null
"signature": "decode_value(data: bytes) -> dict",
"docstring": "Decode cache bytes back into a dict.\n\nArgs:\n data (bytes):\n UTF-8 JSON bytes produced by encode_value().\n\nReturns:\n dict: The decoded dictionary."
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,84 +2,70 @@
"module": "mongo_ops.cache.redis_backend",
"content": {
"path": "mongo_ops.cache.redis_backend",
"docstring": null,
"docstring": "# Summary\n\nRedis cache backend with key prefixing and pub/sub invalidation.",
"objects": {
"json": {
"name": "json",
"kind": "alias",
"path": "mongo_ops.cache.redis_backend.json",
"signature": "<bound method Alias.signature of Alias('json', 'json')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.cache.redis_backend.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"CacheBackend": {
"name": "CacheBackend",
"kind": "class",
"path": "mongo_ops.cache.redis_backend.CacheBackend",
"signature": "<bound method Alias.signature of Alias('CacheBackend', 'mongo_ops.cache.backend.CacheBackend')>",
"docstring": null,
"signature": null,
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
"members": {
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.get",
"signature": "<bound method Alias.signature of Alias('get', 'mongo_ops.cache.backend.CacheBackend.get')>",
"docstring": null
"signature": "get(key: str)",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.set",
"signature": "<bound method Alias.signature of Alias('set', 'mongo_ops.cache.backend.CacheBackend.set')>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None)",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.delete",
"signature": "<bound method Alias.signature of Alias('delete', 'mongo_ops.cache.backend.CacheBackend.delete')>",
"docstring": null
"signature": "delete(key: str)",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.exists",
"signature": "<bound method Alias.signature of Alias('exists', 'mongo_ops.cache.backend.CacheBackend.exists')>",
"docstring": null
"signature": "exists(key: str)",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.clear_pattern",
"signature": "<bound method Alias.signature of Alias('clear_pattern', 'mongo_ops.cache.backend.CacheBackend.clear_pattern')>",
"docstring": null
"signature": "clear_pattern(pattern: str)",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.get_stats",
"signature": "<bound method Alias.signature of Alias('get_stats', 'mongo_ops.cache.backend.CacheBackend.get_stats')>",
"docstring": null
"signature": "get_stats()",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
},
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.initialize",
"signature": "<bound method Alias.signature of Alias('initialize', 'mongo_ops.cache.backend.CacheBackend.initialize')>",
"docstring": null
"signature": "initialize()",
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.CacheBackend.shutdown",
"signature": "<bound method Alias.signature of Alias('shutdown', 'mongo_ops.cache.backend.CacheBackend.shutdown')>",
"docstring": null
"signature": "shutdown()",
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
}
}
},
@@ -87,129 +73,122 @@
"name": "CacheStats",
"kind": "class",
"path": "mongo_ops.cache.redis_backend.CacheStats",
"signature": "<bound method Alias.signature of Alias('CacheStats', 'mongo_ops.cache.backend.CacheStats')>",
"docstring": null,
"signature": "CacheStats(hits: int = 0, misses: int = 0, sets: int = 0, deletes: int = 0, current_size: int = 0, max_size: int = 0)",
"docstring": "Snapshot of cache usage and activity counters.\n\nAttributes:\n hits (int):\n Number of get() calls that found a value.\n misses (int):\n Number of get() calls that returned None.\n sets (int):\n Number of values written to the cache.\n deletes (int):\n Number of keys removed.\n current_size (int):\n Number of entries currently held.\n max_size (int):\n Maximum number of entries the cache allows (0 = unbounded).",
"members": {
"hits": {
"name": "hits",
"kind": "attribute",
"path": "mongo_ops.cache.redis_backend.CacheStats.hits",
"signature": "<bound method Alias.signature of Alias('hits', 'mongo_ops.cache.backend.CacheStats.hits')>",
"signature": null,
"docstring": null
},
"misses": {
"name": "misses",
"kind": "attribute",
"path": "mongo_ops.cache.redis_backend.CacheStats.misses",
"signature": "<bound method Alias.signature of Alias('misses', 'mongo_ops.cache.backend.CacheStats.misses')>",
"signature": null,
"docstring": null
},
"sets": {
"name": "sets",
"kind": "attribute",
"path": "mongo_ops.cache.redis_backend.CacheStats.sets",
"signature": "<bound method Alias.signature of Alias('sets', 'mongo_ops.cache.backend.CacheStats.sets')>",
"signature": null,
"docstring": null
},
"deletes": {
"name": "deletes",
"kind": "attribute",
"path": "mongo_ops.cache.redis_backend.CacheStats.deletes",
"signature": "<bound method Alias.signature of Alias('deletes', 'mongo_ops.cache.backend.CacheStats.deletes')>",
"signature": null,
"docstring": null
},
"current_size": {
"name": "current_size",
"kind": "attribute",
"path": "mongo_ops.cache.redis_backend.CacheStats.current_size",
"signature": "<bound method Alias.signature of Alias('current_size', 'mongo_ops.cache.backend.CacheStats.current_size')>",
"signature": null,
"docstring": null
},
"max_size": {
"name": "max_size",
"kind": "attribute",
"path": "mongo_ops.cache.redis_backend.CacheStats.max_size",
"signature": "<bound method Alias.signature of Alias('max_size', 'mongo_ops.cache.backend.CacheStats.max_size')>",
"signature": null,
"docstring": null
}
}
},
"Redis": {
"name": "Redis",
"kind": "alias",
"path": "mongo_ops.cache.redis_backend.Redis",
"signature": "<bound method Alias.signature of Alias('Redis', 'redis.asyncio.Redis')>",
"docstring": null
},
"RedisCacheBackend": {
"name": "RedisCacheBackend",
"kind": "class",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend",
"signature": "<bound method Class.signature of Class('RedisCacheBackend', 12, 93)>",
"docstring": null,
"signature": "RedisCacheBackend(redis_client: Redis, key_prefix: str = '', default_ttl: int = 300)",
"docstring": "Cache backend backed by Redis with key prefixing.\n\nValues are stored with a configurable key prefix, and deletions publish\non a shared invalidation channel so other processes can react.\n\nNotes:\n **Lifecycle:**\n\n Requires ``pip install mongo-ops[redis]`` and a live Redis\n connection supplied by the caller.",
"members": {
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.initialize",
"signature": "<bound method Function.signature of Function('initialize', 28, 29)>",
"docstring": null
"signature": "initialize() -> None",
"docstring": "Open the pub/sub subscription used for invalidation."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.shutdown",
"signature": "<bound method Function.signature of Function('shutdown', 31, 34)>",
"docstring": null
"signature": "shutdown() -> None",
"docstring": "Close the pub/sub subscription."
},
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.get",
"signature": "<bound method Function.signature of Function('get', 39, 46)>",
"docstring": null
"signature": "get(key: str) -> bytes | None",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.set",
"signature": "<bound method Function.signature of Function('set', 48, 52)>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None) -> None",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds; defaults to the backend default."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.delete",
"signature": "<bound method Function.signature of Function('delete', 54, 59)>",
"docstring": null
"signature": "delete(key: str) -> None",
"docstring": "Remove a key and publish an invalidation notice.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.exists",
"signature": "<bound method Function.signature of Function('exists', 61, 63)>",
"docstring": null
"signature": "exists(key: str) -> bool",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.clear_pattern",
"signature": "<bound method Function.signature of Function('clear_pattern', 65, 79)>",
"docstring": null
"signature": "clear_pattern(pattern: str) -> None",
"docstring": "Remove all keys matching a glob pattern via SCAN/DEL.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.get_stats",
"signature": "<bound method Function.signature of Function('get_stats', 81, 90)>",
"docstring": null
"signature": "get_stats() -> CacheStats",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: Stats with current_size taken from Redis dbsize."
},
"publish_invalidate": {
"name": "publish_invalidate",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.RedisCacheBackend.publish_invalidate",
"signature": "<bound method Function.signature of Function('publish_invalidate', 92, 93)>",
"docstring": null
"signature": "publish_invalidate(key: str) -> None",
"docstring": "Publish an invalidation notice for a key.\n\nArgs:\n key (str):\n The cache key to broadcast."
}
}
},
@@ -217,15 +196,15 @@
"name": "encode_value",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.encode_value",
"signature": "<bound method Function.signature of Function('encode_value', 99, 100)>",
"docstring": null
"signature": "encode_value(value: dict) -> bytes",
"docstring": "Encode a dict into cache-ready bytes.\n\nNon-serializable values (e.g., ObjectId) are coerced with str().\n\nArgs:\n value (dict):\n The dictionary to encode.\n\nReturns:\n bytes: UTF-8 JSON bytes."
},
"decode_value": {
"name": "decode_value",
"kind": "function",
"path": "mongo_ops.cache.redis_backend.decode_value",
"signature": "<bound method Function.signature of Function('decode_value', 103, 104)>",
"docstring": null
"signature": "decode_value(data: bytes) -> dict",
"docstring": "Decode cache bytes back into a dict.\n\nArgs:\n data (bytes):\n UTF-8 JSON bytes produced by encode_value().\n\nReturns:\n dict: The decoded dictionary."
}
}
}

View File

@@ -2,111 +2,69 @@
"module": "mongo_ops.cache.repository",
"content": {
"path": "mongo_ops.cache.repository",
"docstring": null,
"docstring": "# Summary\n\nCached repository layer that combines a repository with a cache backend.",
"objects": {
"Generic": {
"name": "Generic",
"kind": "alias",
"path": "mongo_ops.cache.repository.Generic",
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.cache.repository.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.cache.repository.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mongo_ops.cache.repository.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"Union": {
"name": "Union",
"kind": "alias",
"path": "mongo_ops.cache.repository.Union",
"signature": "<bound method Alias.signature of Alias('Union', 'typing.Union')>",
"docstring": null
},
"ObjectId": {
"name": "ObjectId",
"kind": "alias",
"path": "mongo_ops.cache.repository.ObjectId",
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
"docstring": null
},
"BaseDocument": {
"name": "BaseDocument",
"kind": "class",
"path": "mongo_ops.cache.repository.BaseDocument",
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"signature": null,
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"members": {
"id": {
"name": "id",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.id",
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
"signature": null,
"docstring": null
},
"created_at": {
"name": "created_at",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.created_at",
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
"signature": null,
"docstring": null
},
"updated_at": {
"name": "updated_at",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.updated_at",
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
"signature": null,
"docstring": null
},
"Config": {
"name": "Config",
"kind": "class",
"path": "mongo_ops.cache.repository.BaseDocument.Config",
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
"signature": null,
"docstring": null,
"members": {
"populate_by_name": {
"name": "populate_by_name",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.Config.populate_by_name",
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
"signature": null,
"docstring": null
},
"arbitrary_types_allowed": {
"name": "arbitrary_types_allowed",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.Config.arbitrary_types_allowed",
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
"signature": null,
"docstring": null
},
"json_encoders": {
"name": "json_encoders",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.Config.json_encoders",
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
"signature": null,
"docstring": null
},
"json_schema_extra": {
"name": "json_schema_extra",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseDocument.Config.json_schema_extra",
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
"signature": null,
"docstring": null
}
}
@@ -117,14 +75,14 @@
"name": "BaseRepository",
"kind": "class",
"path": "mongo_ops.cache.repository.BaseRepository",
"signature": "<bound method Alias.signature of Alias('BaseRepository', 'mongo_ops.repository.BaseRepository')>",
"docstring": "Base repository class combining CRUD operations and collection management.\n\nThis class simplifies repository creation by automatically obtaining the \ndatabase connection and collection instance.\n\nAttributes:\n collection_name: The name of the collection managed by this repository.",
"signature": "BaseRepository(collection_name: str, model: type[T])",
"docstring": "Base repository class combining CRUD operations and collection management.\n\nThis class simplifies repository creation by automatically obtaining the\ndatabase connection and collection instance.\n\nAttributes:\n collection_name: The name of the collection managed by this repository.",
"members": {
"collection_name": {
"name": "collection_name",
"kind": "attribute",
"path": "mongo_ops.cache.repository.BaseRepository.collection_name",
"signature": "<bound method Alias.signature of Alias('collection_name', 'mongo_ops.repository.BaseRepository.collection_name')>",
"signature": null,
"docstring": null
}
}
@@ -133,64 +91,64 @@
"name": "CacheBackend",
"kind": "class",
"path": "mongo_ops.cache.repository.CacheBackend",
"signature": "<bound method Alias.signature of Alias('CacheBackend', 'mongo_ops.cache.backend.CacheBackend')>",
"docstring": null,
"signature": null,
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
"members": {
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.get",
"signature": "<bound method Alias.signature of Alias('get', 'mongo_ops.cache.backend.CacheBackend.get')>",
"docstring": null
"signature": "get(key: str)",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.set",
"signature": "<bound method Alias.signature of Alias('set', 'mongo_ops.cache.backend.CacheBackend.set')>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None)",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.delete",
"signature": "<bound method Alias.signature of Alias('delete', 'mongo_ops.cache.backend.CacheBackend.delete')>",
"docstring": null
"signature": "delete(key: str)",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.exists",
"signature": "<bound method Alias.signature of Alias('exists', 'mongo_ops.cache.backend.CacheBackend.exists')>",
"docstring": null
"signature": "exists(key: str)",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.clear_pattern",
"signature": "<bound method Alias.signature of Alias('clear_pattern', 'mongo_ops.cache.backend.CacheBackend.clear_pattern')>",
"docstring": null
"signature": "clear_pattern(pattern: str)",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.get_stats",
"signature": "<bound method Alias.signature of Alias('get_stats', 'mongo_ops.cache.backend.CacheBackend.get_stats')>",
"docstring": null
"signature": "get_stats()",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
},
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.initialize",
"signature": "<bound method Alias.signature of Alias('initialize', 'mongo_ops.cache.backend.CacheBackend.initialize')>",
"docstring": null
"signature": "initialize()",
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.cache.repository.CacheBackend.shutdown",
"signature": "<bound method Alias.signature of Alias('shutdown', 'mongo_ops.cache.backend.CacheBackend.shutdown')>",
"docstring": null
"signature": "shutdown()",
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
}
}
},
@@ -198,56 +156,56 @@
"name": "CacheConfig",
"kind": "class",
"path": "mongo_ops.cache.repository.CacheConfig",
"signature": "<bound method Alias.signature of Alias('CacheConfig', 'mongo_ops.cache.config.CacheConfig')>",
"docstring": null,
"signature": "CacheConfig(enabled: bool = True, backend: Literal['memory', 'redis'] = 'memory', redis_client: Redis | None = None, default_ttl: int = 300, max_entries: int = 10000, key_prefix: str = '', cleanup_interval: int = 60)",
"docstring": "Configuration for the cached repository layer.\n\nAttributes:\n enabled (bool):\n Whether caching is active for the repository.\n backend (Literal[\"memory\", \"redis\"]):\n Which backend to use. Defaults to \"memory\".\n redis_client (Optional[Redis]):\n Redis client required when backend is \"redis\".\n default_ttl (int):\n Default time-to-live for cached entries, in seconds.\n max_entries (int):\n Maximum entries for the in-memory backend.\n key_prefix (str):\n Prefix applied to cache keys; defaults to the collection name\n when empty.\n cleanup_interval (int):\n Interval (seconds) for the in-memory expiry sweep.",
"members": {
"enabled": {
"name": "enabled",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.enabled",
"signature": "<bound method Alias.signature of Alias('enabled', 'mongo_ops.cache.config.CacheConfig.enabled')>",
"signature": null,
"docstring": null
},
"backend": {
"name": "backend",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.backend",
"signature": "<bound method Alias.signature of Alias('backend', 'mongo_ops.cache.config.CacheConfig.backend')>",
"signature": null,
"docstring": null
},
"redis_client": {
"name": "redis_client",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.redis_client",
"signature": "<bound method Alias.signature of Alias('redis_client', 'mongo_ops.cache.config.CacheConfig.redis_client')>",
"signature": null,
"docstring": null
},
"default_ttl": {
"name": "default_ttl",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.default_ttl",
"signature": "<bound method Alias.signature of Alias('default_ttl', 'mongo_ops.cache.config.CacheConfig.default_ttl')>",
"signature": null,
"docstring": null
},
"max_entries": {
"name": "max_entries",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.max_entries",
"signature": "<bound method Alias.signature of Alias('max_entries', 'mongo_ops.cache.config.CacheConfig.max_entries')>",
"signature": null,
"docstring": null
},
"key_prefix": {
"name": "key_prefix",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.key_prefix",
"signature": "<bound method Alias.signature of Alias('key_prefix', 'mongo_ops.cache.config.CacheConfig.key_prefix')>",
"signature": null,
"docstring": null
},
"cleanup_interval": {
"name": "cleanup_interval",
"kind": "attribute",
"path": "mongo_ops.cache.repository.CacheConfig.cleanup_interval",
"signature": "<bound method Alias.signature of Alias('cleanup_interval', 'mongo_ops.cache.config.CacheConfig.cleanup_interval')>",
"signature": null,
"docstring": null
}
}
@@ -256,15 +214,15 @@
"name": "decode_value",
"kind": "function",
"path": "mongo_ops.cache.repository.decode_value",
"signature": "<bound method Alias.signature of Alias('decode_value', 'mongo_ops.cache.in_memory.decode_value')>",
"docstring": null
"signature": "decode_value(data: bytes)",
"docstring": "Decode cache bytes back into a dict.\n\nArgs:\n data (bytes):\n UTF-8 JSON bytes produced by encode_value().\n\nReturns:\n dict: The decoded dictionary."
},
"encode_value": {
"name": "encode_value",
"kind": "function",
"path": "mongo_ops.cache.repository.encode_value",
"signature": "<bound method Alias.signature of Alias('encode_value', 'mongo_ops.cache.in_memory.encode_value')>",
"docstring": null
"signature": "encode_value(value: dict)",
"docstring": "Encode a dict into cache-ready bytes.\n\nNon-serializable values (e.g., ObjectId) are coerced with str().\n\nArgs:\n value (dict):\n The dictionary to encode.\n\nReturns:\n bytes: UTF-8 JSON bytes."
},
"T": {
"name": "T",
@@ -277,50 +235,50 @@
"name": "CachedBaseRepository",
"kind": "class",
"path": "mongo_ops.cache.repository.CachedBaseRepository",
"signature": "<bound method Class.signature of Class('CachedBaseRepository', 14, 92)>",
"docstring": null,
"signature": "CachedBaseRepository(collection_name: str, model: type[T], cache_backend: CacheBackend, config: CacheConfig | None = None)",
"docstring": "Repository that reads and writes through a cache backend.\n\nWraps an existing BaseRepository with an ID-keyed cache. Reads consult\nthe backend first and fall through to MongoDB on a miss, populating the\ncache on success. Writes invalidate or refresh the affected key.\n\nNotes:\n **Guarantees:**\n\n - The cache holds the raw document shape (``model_dump``), so FK\n references round-trip as hex strings, not populated models.\n - When ``config.enabled`` is False the repository behaves exactly\n like its parent with no cache access.",
"members": {
"get_by_id": {
"name": "get_by_id",
"kind": "function",
"path": "mongo_ops.cache.repository.CachedBaseRepository.get_by_id",
"signature": "<bound method Function.signature of Function('get_by_id', 33, 48)>",
"docstring": null
"signature": "get_by_id(id: str | ObjectId) -> T | None",
"docstring": "Fetch a document, reading through the cache when enabled.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n\nReturns:\n Optional[T]: The model instance, or None when not found."
},
"create": {
"name": "create",
"kind": "function",
"path": "mongo_ops.cache.repository.CachedBaseRepository.create",
"signature": "<bound method Function.signature of Function('create', 50, 56)>",
"docstring": null
"signature": "create(data: T) -> T",
"docstring": "Insert a document and cache the raw snapshot.\n\nArgs:\n data (T):\n The model instance to insert.\n\nReturns:\n T: The created model instance, including its ID."
},
"update": {
"name": "update",
"kind": "function",
"path": "mongo_ops.cache.repository.CachedBaseRepository.update",
"signature": "<bound method Function.signature of Function('update', 58, 67)>",
"docstring": null
"signature": "update(id: str | ObjectId, data: dict) -> T | None",
"docstring": "Update a document and refresh its cache entry.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n data (dict):\n Fields to set via $set.\n\nReturns:\n Optional[T]: The updated model instance, or None when not found."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.cache.repository.CachedBaseRepository.delete",
"signature": "<bound method Function.signature of Function('delete', 69, 74)>",
"docstring": null
"signature": "delete(id: str | ObjectId) -> bool",
"docstring": "Delete a document and remove its cache entry.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n\nReturns:\n bool: True if a document was deleted, False otherwise."
},
"warm_cache": {
"name": "warm_cache",
"kind": "function",
"path": "mongo_ops.cache.repository.CachedBaseRepository.warm_cache",
"signature": "<bound method Function.signature of Function('warm_cache', 76, 87)>",
"docstring": null
"signature": "warm_cache(ids: list[str | ObjectId]) -> int",
"docstring": "Pre-populate the cache for a set of document IDs.\n\nDocs already present in the cache are skipped.\n\nArgs:\n ids (list[Union[str, ObjectId]]):\n Document IDs to warm.\n\nReturns:\n int: Number of entries added to the cache."
},
"invalidate_cache": {
"name": "invalidate_cache",
"kind": "function",
"path": "mongo_ops.cache.repository.CachedBaseRepository.invalidate_cache",
"signature": "<bound method Function.signature of Function('invalidate_cache', 89, 92)>",
"docstring": null
"signature": "invalidate_cache(id: str | ObjectId) -> None",
"docstring": "Remove a single document's cache entry.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID to invalidate."
}
}
}

View File

@@ -2,77 +2,49 @@
"module": "mongo_ops.connection",
"content": {
"path": "mongo_ops.connection",
"docstring": "MongoDB connection management.",
"docstring": "# Summary\n\nMongoDB connection management.",
"objects": {
"asynccontextmanager": {
"name": "asynccontextmanager",
"kind": "alias",
"path": "mongo_ops.connection.asynccontextmanager",
"signature": "<bound method Alias.signature of Alias('asynccontextmanager', 'contextlib.asynccontextmanager')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.connection.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"AsyncIOMotorClient": {
"name": "AsyncIOMotorClient",
"kind": "alias",
"path": "mongo_ops.connection.AsyncIOMotorClient",
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorClient', 'motor.motor_asyncio.AsyncIOMotorClient')>",
"docstring": null
},
"AsyncIOMotorDatabase": {
"name": "AsyncIOMotorDatabase",
"kind": "alias",
"path": "mongo_ops.connection.AsyncIOMotorDatabase",
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorDatabase', 'motor.motor_asyncio.AsyncIOMotorDatabase')>",
"docstring": null
},
"MongoConnectionManager": {
"name": "MongoConnectionManager",
"kind": "class",
"path": "mongo_ops.connection.MongoConnectionManager",
"signature": "<bound method Class.signature of Class('MongoConnectionManager', 8, 114)>",
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and \ndatabase instances, ensuring they are properly initialized and closed \nacross the application lifecycle.",
"signature": null,
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and\ndatabase instances, ensuring they are properly initialized and closed\nacross the application lifecycle.",
"members": {
"connect": {
"name": "connect",
"kind": "function",
"path": "mongo_ops.connection.MongoConnectionManager.connect",
"signature": "<bound method Function.signature of Function('connect', 22, 45)>",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri: MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name: Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
"signature": "connect(uri: str, db_name: str, **kwargs: Any) -> AsyncIOMotorDatabase",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri (str): MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name (str): Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
},
"disconnect": {
"name": "disconnect",
"kind": "function",
"path": "mongo_ops.connection.MongoConnectionManager.disconnect",
"signature": "<bound method Function.signature of Function('disconnect', 47, 55)>",
"signature": "disconnect() -> None",
"docstring": "Close the active MongoDB connection and cleanup resources."
},
"get_database": {
"name": "get_database",
"kind": "function",
"path": "mongo_ops.connection.MongoConnectionManager.get_database",
"signature": "<bound method Function.signature of Function('get_database', 57, 70)>",
"signature": "get_database() -> AsyncIOMotorDatabase",
"docstring": "Retrieve the current database instance.\n\nReturns:\n AsyncIOMotorDatabase: The active database instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"get_client": {
"name": "get_client",
"kind": "function",
"path": "mongo_ops.connection.MongoConnectionManager.get_client",
"signature": "<bound method Function.signature of Function('get_client', 72, 85)>",
"signature": "get_client() -> AsyncIOMotorClient",
"docstring": "Retrieve the current client instance.\n\nReturns:\n AsyncIOMotorClient: The active Motor client instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"lifespan": {
"name": "lifespan",
"kind": "function",
"path": "mongo_ops.connection.MongoConnectionManager.lifespan",
"signature": "<bound method Function.signature of Function('lifespan', 87, 114)>",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting \nlifespan management.\n\nArgs:\n uri: MongoDB connection URI.\n db_name: Name of the database.\n **kwargs: Additional Motor client options.\n\nYields:\n AsyncIOMotorDatabase: The active database instance.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
"signature": "lifespan(uri: str, db_name: str, **kwargs: Any) -> AbstractAsyncContextManager[AsyncIOMotorDatabase]",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting\nlifespan management.\n\nNotes:\n Connects to MongoDB on entry, yields the active database instance\n to the context body, and disconnects on exit.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,77 +2,21 @@
"module": "mongo_ops.models",
"content": {
"path": "mongo_ops.models",
"docstring": "Base document models for MongoDB.",
"docstring": "# Summary\n\nBase document models for MongoDB.",
"objects": {
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mongo_ops.models.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.models.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.models.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"ObjectId": {
"name": "ObjectId",
"kind": "alias",
"path": "mongo_ops.models.ObjectId",
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
"docstring": null
},
"BaseModel": {
"name": "BaseModel",
"kind": "alias",
"path": "mongo_ops.models.BaseModel",
"signature": "<bound method Alias.signature of Alias('BaseModel', 'pydantic.BaseModel')>",
"docstring": null
},
"Field": {
"name": "Field",
"kind": "alias",
"path": "mongo_ops.models.Field",
"signature": "<bound method Alias.signature of Alias('Field', 'pydantic.Field')>",
"docstring": null
},
"GetCoreSchemaHandler": {
"name": "GetCoreSchemaHandler",
"kind": "alias",
"path": "mongo_ops.models.GetCoreSchemaHandler",
"signature": "<bound method Alias.signature of Alias('GetCoreSchemaHandler', 'pydantic.GetCoreSchemaHandler')>",
"docstring": null
},
"core_schema": {
"name": "core_schema",
"kind": "alias",
"path": "mongo_ops.models.core_schema",
"signature": "<bound method Alias.signature of Alias('core_schema', 'pydantic_core.core_schema')>",
"docstring": null
},
"PyObjectId": {
"name": "PyObjectId",
"kind": "class",
"path": "mongo_ops.models.PyObjectId",
"signature": "<bound method Class.signature of Class('PyObjectId', 10, 65)>",
"docstring": "Custom ObjectId type compatible with Pydantic v2.\n\nThis class extends the standard BSON ObjectId to provide validation and \nserialization support within Pydantic models.",
"signature": null,
"docstring": "Custom ObjectId type compatible with Pydantic v2.\n\nThis class extends the standard BSON ObjectId to provide validation and\nserialization support within Pydantic models.",
"members": {
"validate": {
"name": "validate",
"kind": "function",
"path": "mongo_ops.models.PyObjectId.validate",
"signature": "<bound method Function.signature of Function('validate', 35, 53)>",
"docstring": "Validate the input value and convert it to an ObjectId if possible.\n\nArgs:\n v: The value to validate (can be str or ObjectId).\n\nReturns:\n ObjectId: The validated ObjectId instance.\n\nRaises:\n ValueError: If the value is not a valid ObjectId."
"signature": "validate(v: Any) -> ObjectId",
"docstring": "Validate the input value and convert it to an ObjectId if possible.\n\nArgs:\n v (Any): The value to validate (can be str or ObjectId).\n\nReturns:\n ObjectId: The validated ObjectId instance.\n\nRaises:\n ValueError: If the value is not a valid ObjectId."
}
}
},
@@ -80,8 +24,8 @@
"name": "BaseDocument",
"kind": "class",
"path": "mongo_ops.models.BaseDocument",
"signature": "<bound method Class.signature of Class('BaseDocument', 68, 95)>",
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"signature": null,
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"members": {
"id": {
"name": "id",
@@ -108,7 +52,7 @@
"name": "Config",
"kind": "class",
"path": "mongo_ops.models.BaseDocument.Config",
"signature": "<bound method Class.signature of Class('Config', 86, 95)>",
"signature": null,
"docstring": null,
"members": {
"populate_by_name": {

View File

@@ -2,90 +2,34 @@
"module": "mongo_ops.populate.engine",
"content": {
"path": "mongo_ops.populate.engine",
"docstring": null,
"docstring": "# Summary\n\nRecursive document population engine with cycle detection.",
"objects": {
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.populate.engine.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mongo_ops.populate.engine.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.populate.engine.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.populate.engine.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"Set": {
"name": "Set",
"kind": "alias",
"path": "mongo_ops.populate.engine.Set",
"signature": "<bound method Alias.signature of Alias('Set', 'typing.Set')>",
"docstring": null
},
"Tuple": {
"name": "Tuple",
"kind": "alias",
"path": "mongo_ops.populate.engine.Tuple",
"signature": "<bound method Alias.signature of Alias('Tuple', 'typing.Tuple')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mongo_ops.populate.engine.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"ObjectId": {
"name": "ObjectId",
"kind": "alias",
"path": "mongo_ops.populate.engine.ObjectId",
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
"docstring": null
},
"CircularReferenceError": {
"name": "CircularReferenceError",
"kind": "class",
"path": "mongo_ops.populate.engine.CircularReferenceError",
"signature": "<bound method Alias.signature of Alias('CircularReferenceError', 'mongo_ops.cache.backend.CircularReferenceError')>",
"docstring": null,
"signature": "CircularReferenceError(collection: str, doc_id: ObjectId, path: list[str])",
"docstring": "Raised when population detects a cycle in the reference graph.\n\nAttributes:\n collection (str):\n Collection where the cycle was detected.\n doc_id (ObjectId):\n Document ID where the cycle was detected.\n path (list[str]):\n Ordered labels describing the visited reference path.",
"members": {
"collection": {
"name": "collection",
"kind": "attribute",
"path": "mongo_ops.populate.engine.CircularReferenceError.collection",
"signature": "<bound method Alias.signature of Alias('collection', 'mongo_ops.cache.backend.CircularReferenceError.collection')>",
"signature": null,
"docstring": null
},
"doc_id": {
"name": "doc_id",
"kind": "attribute",
"path": "mongo_ops.populate.engine.CircularReferenceError.doc_id",
"signature": "<bound method Alias.signature of Alias('doc_id', 'mongo_ops.cache.backend.CircularReferenceError.doc_id')>",
"signature": null,
"docstring": null
},
"path": {
"name": "path",
"kind": "attribute",
"path": "mongo_ops.populate.engine.CircularReferenceError.path",
"signature": "<bound method Alias.signature of Alias('path', 'mongo_ops.cache.backend.CircularReferenceError.path')>",
"signature": null,
"docstring": null
}
}
@@ -94,63 +38,63 @@
"name": "BaseDocument",
"kind": "class",
"path": "mongo_ops.populate.engine.BaseDocument",
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"signature": null,
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"members": {
"id": {
"name": "id",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.id",
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
"signature": null,
"docstring": null
},
"created_at": {
"name": "created_at",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.created_at",
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
"signature": null,
"docstring": null
},
"updated_at": {
"name": "updated_at",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.updated_at",
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
"signature": null,
"docstring": null
},
"Config": {
"name": "Config",
"kind": "class",
"path": "mongo_ops.populate.engine.BaseDocument.Config",
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
"signature": null,
"docstring": null,
"members": {
"populate_by_name": {
"name": "populate_by_name",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.populate_by_name",
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
"signature": null,
"docstring": null
},
"arbitrary_types_allowed": {
"name": "arbitrary_types_allowed",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.arbitrary_types_allowed",
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
"signature": null,
"docstring": null
},
"json_encoders": {
"name": "json_encoders",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.json_encoders",
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
"signature": null,
"docstring": null
},
"json_schema_extra": {
"name": "json_schema_extra",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.json_schema_extra",
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
"signature": null,
"docstring": null
}
}
@@ -161,49 +105,49 @@
"name": "PopulateRule",
"kind": "class",
"path": "mongo_ops.populate.engine.PopulateRule",
"signature": "<bound method Alias.signature of Alias('PopulateRule', 'mongo_ops.populate.rules.PopulateRule')>",
"docstring": null,
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
"members": {
"field_name": {
"name": "field_name",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.field_name",
"signature": "<bound method Alias.signature of Alias('field_name', 'mongo_ops.populate.rules.PopulateRule.field_name')>",
"signature": null,
"docstring": null
},
"collection_name": {
"name": "collection_name",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.collection_name",
"signature": "<bound method Alias.signature of Alias('collection_name', 'mongo_ops.populate.rules.PopulateRule.collection_name')>",
"signature": null,
"docstring": null
},
"nested_rules": {
"name": "nested_rules",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.nested_rules",
"signature": "<bound method Alias.signature of Alias('nested_rules', 'mongo_ops.populate.rules.PopulateRule.nested_rules')>",
"signature": null,
"docstring": null
},
"max_depth": {
"name": "max_depth",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.max_depth",
"signature": "<bound method Alias.signature of Alias('max_depth', 'mongo_ops.populate.rules.PopulateRule.max_depth')>",
"signature": null,
"docstring": null
},
"filter": {
"name": "filter",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.filter",
"signature": "<bound method Alias.signature of Alias('filter', 'mongo_ops.populate.rules.PopulateRule.filter')>",
"signature": null,
"docstring": null
},
"projection": {
"name": "projection",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.projection",
"signature": "<bound method Alias.signature of Alias('projection', 'mongo_ops.populate.rules.PopulateRule.projection')>",
"signature": null,
"docstring": null
}
}
@@ -219,29 +163,29 @@
"name": "PopulationEngine",
"kind": "class",
"path": "mongo_ops.populate.engine.PopulationEngine",
"signature": "<bound method Class.signature of Class('PopulationEngine', 12, 165)>",
"docstring": null,
"signature": "PopulationEngine(repos: dict[str, Any], global_max_depth: int = 10)",
"docstring": "Resolves FK references across collections with cycle detection.\n\nThe engine holds a registry of repositories keyed by collection name and\nwalks documents according to PopulateRules, resolving ObjectId references\ninto model instances. A visited-path set guards against circular graphs.\n\nNotes:\n **Guarantees:**\n\n - A reference that cannot be resolved becomes None (scalar) or a\n None entry (list) rather than raising.\n - Depth is capped by both per-rule max_depth and a global\n global_max_depth.",
"members": {
"register_repo": {
"name": "register_repo",
"kind": "function",
"path": "mongo_ops.populate.engine.PopulationEngine.register_repo",
"signature": "<bound method Function.signature of Function('register_repo', 21, 22)>",
"docstring": null
"signature": "register_repo(collection_name: str, repo: Any) -> None",
"docstring": "Register or replace the repository for a collection.\n\nArgs:\n collection_name (str):\n Collection the repository manages.\n repo (Any):\n Repository exposing get_by_id() used to resolve references."
},
"populate": {
"name": "populate",
"kind": "function",
"path": "mongo_ops.populate.engine.PopulationEngine.populate",
"signature": "<bound method Function.signature of Function('populate', 24, 77)>",
"docstring": null
"signature": "populate(document: T, rules: list[PopulateRule], depth: int = 0, _visited: set[tuple[str, str]] | None = None, _path: list[str] | None = None) -> T",
"docstring": "Resolve FK fields on a document according to the given rules.\n\nArgs:\n document (T):\n The document to populate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to resolve and how deep.\n depth (int):\n Current recursion depth. Defaults to 0.\n _visited (Optional[set[tuple[str, str]]]):\n Internal set of (class, id) pairs on the active path.\n _path (Optional[list[str]]):\n Internal path labels used for cycle reporting.\n\nReturns:\n T: The populated document.\n\nRaises:\n CircularReferenceError: If a cycle is detected on the active path."
},
"depopulate": {
"name": "depopulate",
"kind": "function",
"path": "mongo_ops.populate.engine.PopulationEngine.depopulate",
"signature": "<bound method Function.signature of Function('depopulate', 136, 165)>",
"docstring": null
"signature": "depopulate(document: T, rules: list[PopulateRule]) -> T",
"docstring": "Collapse populated model references back to their ObjectIds.\n\nThis is the inverse of populate(): model-valued FK fields are reduced\nto stored identifiers before the document is written to MongoDB.\n\nArgs:\n document (T):\n The document to depopulate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to collapse.\n\nReturns:\n T: The depopulated document.\n\nRaises:\n AttributeError: If a list entry is not a BaseDocument where\n expected."
}
}
}

View File

@@ -2,35 +2,35 @@
"module": "mongo_ops.populate",
"content": {
"path": "mongo_ops.populate",
"docstring": null,
"docstring": "# Summary\n\nDocument populating rules and population engine.",
"objects": {
"PopulationEngine": {
"name": "PopulationEngine",
"kind": "class",
"path": "mongo_ops.populate.PopulationEngine",
"signature": "<bound method Alias.signature of Alias('PopulationEngine', 'mongo_ops.populate.engine.PopulationEngine')>",
"docstring": null,
"signature": "PopulationEngine(repos: dict[str, Any], global_max_depth: int = 10)",
"docstring": "Resolves FK references across collections with cycle detection.\n\nThe engine holds a registry of repositories keyed by collection name and\nwalks documents according to PopulateRules, resolving ObjectId references\ninto model instances. A visited-path set guards against circular graphs.\n\nNotes:\n **Guarantees:**\n\n - A reference that cannot be resolved becomes None (scalar) or a\n None entry (list) rather than raising.\n - Depth is capped by both per-rule max_depth and a global\n global_max_depth.",
"members": {
"register_repo": {
"name": "register_repo",
"kind": "function",
"path": "mongo_ops.populate.PopulationEngine.register_repo",
"signature": "<bound method Alias.signature of Alias('register_repo', 'mongo_ops.populate.engine.PopulationEngine.register_repo')>",
"docstring": null
"signature": "register_repo(collection_name: str, repo: Any)",
"docstring": "Register or replace the repository for a collection.\n\nArgs:\n collection_name (str):\n Collection the repository manages.\n repo (Any):\n Repository exposing get_by_id() used to resolve references."
},
"populate": {
"name": "populate",
"kind": "function",
"path": "mongo_ops.populate.PopulationEngine.populate",
"signature": "<bound method Alias.signature of Alias('populate', 'mongo_ops.populate.engine.PopulationEngine.populate')>",
"docstring": null
"signature": "populate(document: T, rules: list[PopulateRule], depth: int = 0, _visited: set[tuple[str, str]] | None = None, _path: list[str] | None = None)",
"docstring": "Resolve FK fields on a document according to the given rules.\n\nArgs:\n document (T):\n The document to populate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to resolve and how deep.\n depth (int):\n Current recursion depth. Defaults to 0.\n _visited (Optional[set[tuple[str, str]]]):\n Internal set of (class, id) pairs on the active path.\n _path (Optional[list[str]]):\n Internal path labels used for cycle reporting.\n\nReturns:\n T: The populated document.\n\nRaises:\n CircularReferenceError: If a cycle is detected on the active path."
},
"depopulate": {
"name": "depopulate",
"kind": "function",
"path": "mongo_ops.populate.PopulationEngine.depopulate",
"signature": "<bound method Alias.signature of Alias('depopulate', 'mongo_ops.populate.engine.PopulationEngine.depopulate')>",
"docstring": null
"signature": "depopulate(document: T, rules: list[PopulateRule])",
"docstring": "Collapse populated model references back to their ObjectIds.\n\nThis is the inverse of populate(): model-valued FK fields are reduced\nto stored identifiers before the document is written to MongoDB.\n\nArgs:\n document (T):\n The document to depopulate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to collapse.\n\nReturns:\n T: The depopulated document.\n\nRaises:\n AttributeError: If a list entry is not a BaseDocument where\n expected."
}
}
},
@@ -38,49 +38,49 @@
"name": "PopulateRule",
"kind": "class",
"path": "mongo_ops.populate.PopulateRule",
"signature": "<bound method Alias.signature of Alias('PopulateRule', 'mongo_ops.populate.rules.PopulateRule')>",
"docstring": null,
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
"members": {
"field_name": {
"name": "field_name",
"kind": "attribute",
"path": "mongo_ops.populate.PopulateRule.field_name",
"signature": "<bound method Alias.signature of Alias('field_name', 'mongo_ops.populate.rules.PopulateRule.field_name')>",
"signature": null,
"docstring": null
},
"collection_name": {
"name": "collection_name",
"kind": "attribute",
"path": "mongo_ops.populate.PopulateRule.collection_name",
"signature": "<bound method Alias.signature of Alias('collection_name', 'mongo_ops.populate.rules.PopulateRule.collection_name')>",
"signature": null,
"docstring": null
},
"nested_rules": {
"name": "nested_rules",
"kind": "attribute",
"path": "mongo_ops.populate.PopulateRule.nested_rules",
"signature": "<bound method Alias.signature of Alias('nested_rules', 'mongo_ops.populate.rules.PopulateRule.nested_rules')>",
"signature": null,
"docstring": null
},
"max_depth": {
"name": "max_depth",
"kind": "attribute",
"path": "mongo_ops.populate.PopulateRule.max_depth",
"signature": "<bound method Alias.signature of Alias('max_depth', 'mongo_ops.populate.rules.PopulateRule.max_depth')>",
"signature": null,
"docstring": null
},
"filter": {
"name": "filter",
"kind": "attribute",
"path": "mongo_ops.populate.PopulateRule.filter",
"signature": "<bound method Alias.signature of Alias('filter', 'mongo_ops.populate.rules.PopulateRule.filter')>",
"signature": null,
"docstring": null
},
"projection": {
"name": "projection",
"kind": "attribute",
"path": "mongo_ops.populate.PopulateRule.projection",
"signature": "<bound method Alias.signature of Alias('projection', 'mongo_ops.populate.rules.PopulateRule.projection')>",
"signature": null,
"docstring": null
}
}
@@ -90,90 +90,34 @@
"kind": "module",
"path": "mongo_ops.populate.engine",
"signature": null,
"docstring": null,
"docstring": "# Summary\n\nRecursive document population engine with cycle detection.",
"members": {
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.populate.engine.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mongo_ops.populate.engine.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.populate.engine.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.populate.engine.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"Set": {
"name": "Set",
"kind": "alias",
"path": "mongo_ops.populate.engine.Set",
"signature": "<bound method Alias.signature of Alias('Set', 'typing.Set')>",
"docstring": null
},
"Tuple": {
"name": "Tuple",
"kind": "alias",
"path": "mongo_ops.populate.engine.Tuple",
"signature": "<bound method Alias.signature of Alias('Tuple', 'typing.Tuple')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mongo_ops.populate.engine.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"ObjectId": {
"name": "ObjectId",
"kind": "alias",
"path": "mongo_ops.populate.engine.ObjectId",
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
"docstring": null
},
"CircularReferenceError": {
"name": "CircularReferenceError",
"kind": "class",
"path": "mongo_ops.populate.engine.CircularReferenceError",
"signature": "<bound method Alias.signature of Alias('CircularReferenceError', 'mongo_ops.cache.backend.CircularReferenceError')>",
"docstring": null,
"signature": "CircularReferenceError(collection: str, doc_id: ObjectId, path: list[str])",
"docstring": "Raised when population detects a cycle in the reference graph.\n\nAttributes:\n collection (str):\n Collection where the cycle was detected.\n doc_id (ObjectId):\n Document ID where the cycle was detected.\n path (list[str]):\n Ordered labels describing the visited reference path.",
"members": {
"collection": {
"name": "collection",
"kind": "attribute",
"path": "mongo_ops.populate.engine.CircularReferenceError.collection",
"signature": "<bound method Alias.signature of Alias('collection', 'mongo_ops.cache.backend.CircularReferenceError.collection')>",
"signature": null,
"docstring": null
},
"doc_id": {
"name": "doc_id",
"kind": "attribute",
"path": "mongo_ops.populate.engine.CircularReferenceError.doc_id",
"signature": "<bound method Alias.signature of Alias('doc_id', 'mongo_ops.cache.backend.CircularReferenceError.doc_id')>",
"signature": null,
"docstring": null
},
"path": {
"name": "path",
"kind": "attribute",
"path": "mongo_ops.populate.engine.CircularReferenceError.path",
"signature": "<bound method Alias.signature of Alias('path', 'mongo_ops.cache.backend.CircularReferenceError.path')>",
"signature": null,
"docstring": null
}
}
@@ -182,63 +126,63 @@
"name": "BaseDocument",
"kind": "class",
"path": "mongo_ops.populate.engine.BaseDocument",
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"signature": null,
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"members": {
"id": {
"name": "id",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.id",
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
"signature": null,
"docstring": null
},
"created_at": {
"name": "created_at",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.created_at",
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
"signature": null,
"docstring": null
},
"updated_at": {
"name": "updated_at",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.updated_at",
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
"signature": null,
"docstring": null
},
"Config": {
"name": "Config",
"kind": "class",
"path": "mongo_ops.populate.engine.BaseDocument.Config",
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
"signature": null,
"docstring": null,
"members": {
"populate_by_name": {
"name": "populate_by_name",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.populate_by_name",
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
"signature": null,
"docstring": null
},
"arbitrary_types_allowed": {
"name": "arbitrary_types_allowed",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.arbitrary_types_allowed",
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
"signature": null,
"docstring": null
},
"json_encoders": {
"name": "json_encoders",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.json_encoders",
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
"signature": null,
"docstring": null
},
"json_schema_extra": {
"name": "json_schema_extra",
"kind": "attribute",
"path": "mongo_ops.populate.engine.BaseDocument.Config.json_schema_extra",
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
"signature": null,
"docstring": null
}
}
@@ -249,49 +193,49 @@
"name": "PopulateRule",
"kind": "class",
"path": "mongo_ops.populate.engine.PopulateRule",
"signature": "<bound method Alias.signature of Alias('PopulateRule', 'mongo_ops.populate.rules.PopulateRule')>",
"docstring": null,
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
"members": {
"field_name": {
"name": "field_name",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.field_name",
"signature": "<bound method Alias.signature of Alias('field_name', 'mongo_ops.populate.rules.PopulateRule.field_name')>",
"signature": null,
"docstring": null
},
"collection_name": {
"name": "collection_name",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.collection_name",
"signature": "<bound method Alias.signature of Alias('collection_name', 'mongo_ops.populate.rules.PopulateRule.collection_name')>",
"signature": null,
"docstring": null
},
"nested_rules": {
"name": "nested_rules",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.nested_rules",
"signature": "<bound method Alias.signature of Alias('nested_rules', 'mongo_ops.populate.rules.PopulateRule.nested_rules')>",
"signature": null,
"docstring": null
},
"max_depth": {
"name": "max_depth",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.max_depth",
"signature": "<bound method Alias.signature of Alias('max_depth', 'mongo_ops.populate.rules.PopulateRule.max_depth')>",
"signature": null,
"docstring": null
},
"filter": {
"name": "filter",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.filter",
"signature": "<bound method Alias.signature of Alias('filter', 'mongo_ops.populate.rules.PopulateRule.filter')>",
"signature": null,
"docstring": null
},
"projection": {
"name": "projection",
"kind": "attribute",
"path": "mongo_ops.populate.engine.PopulateRule.projection",
"signature": "<bound method Alias.signature of Alias('projection', 'mongo_ops.populate.rules.PopulateRule.projection')>",
"signature": null,
"docstring": null
}
}
@@ -307,29 +251,29 @@
"name": "PopulationEngine",
"kind": "class",
"path": "mongo_ops.populate.engine.PopulationEngine",
"signature": "<bound method Class.signature of Class('PopulationEngine', 12, 165)>",
"docstring": null,
"signature": "PopulationEngine(repos: dict[str, Any], global_max_depth: int = 10)",
"docstring": "Resolves FK references across collections with cycle detection.\n\nThe engine holds a registry of repositories keyed by collection name and\nwalks documents according to PopulateRules, resolving ObjectId references\ninto model instances. A visited-path set guards against circular graphs.\n\nNotes:\n **Guarantees:**\n\n - A reference that cannot be resolved becomes None (scalar) or a\n None entry (list) rather than raising.\n - Depth is capped by both per-rule max_depth and a global\n global_max_depth.",
"members": {
"register_repo": {
"name": "register_repo",
"kind": "function",
"path": "mongo_ops.populate.engine.PopulationEngine.register_repo",
"signature": "<bound method Function.signature of Function('register_repo', 21, 22)>",
"docstring": null
"signature": "register_repo(collection_name: str, repo: Any) -> None",
"docstring": "Register or replace the repository for a collection.\n\nArgs:\n collection_name (str):\n Collection the repository manages.\n repo (Any):\n Repository exposing get_by_id() used to resolve references."
},
"populate": {
"name": "populate",
"kind": "function",
"path": "mongo_ops.populate.engine.PopulationEngine.populate",
"signature": "<bound method Function.signature of Function('populate', 24, 77)>",
"docstring": null
"signature": "populate(document: T, rules: list[PopulateRule], depth: int = 0, _visited: set[tuple[str, str]] | None = None, _path: list[str] | None = None) -> T",
"docstring": "Resolve FK fields on a document according to the given rules.\n\nArgs:\n document (T):\n The document to populate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to resolve and how deep.\n depth (int):\n Current recursion depth. Defaults to 0.\n _visited (Optional[set[tuple[str, str]]]):\n Internal set of (class, id) pairs on the active path.\n _path (Optional[list[str]]):\n Internal path labels used for cycle reporting.\n\nReturns:\n T: The populated document.\n\nRaises:\n CircularReferenceError: If a cycle is detected on the active path."
},
"depopulate": {
"name": "depopulate",
"kind": "function",
"path": "mongo_ops.populate.engine.PopulationEngine.depopulate",
"signature": "<bound method Function.signature of Function('depopulate', 136, 165)>",
"docstring": null
"signature": "depopulate(document: T, rules: list[PopulateRule]) -> T",
"docstring": "Collapse populated model references back to their ObjectIds.\n\nThis is the inverse of populate(): model-valued FK fields are reduced\nto stored identifiers before the document is written to MongoDB.\n\nArgs:\n document (T):\n The document to depopulate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to collapse.\n\nReturns:\n T: The depopulated document.\n\nRaises:\n AttributeError: If a list entry is not a BaseDocument where\n expected."
}
}
}
@@ -340,49 +284,14 @@
"kind": "module",
"path": "mongo_ops.populate.rules",
"signature": null,
"docstring": null,
"docstring": "# Summary\n\nPopulate rules describing which foreign-key fields to resolve.",
"members": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mongo_ops.populate.rules.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.populate.rules.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mongo_ops.populate.rules.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.populate.rules.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.populate.rules.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"PopulateRule": {
"name": "PopulateRule",
"kind": "class",
"path": "mongo_ops.populate.rules.PopulateRule",
"signature": "<bound method Class.signature of Class('PopulateRule', 5, 12)>",
"docstring": null,
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
"members": {
"field_name": {
"name": "field_name",

View File

@@ -2,49 +2,14 @@
"module": "mongo_ops.populate.rules",
"content": {
"path": "mongo_ops.populate.rules",
"docstring": null,
"docstring": "# Summary\n\nPopulate rules describing which foreign-key fields to resolve.",
"objects": {
"dataclass": {
"name": "dataclass",
"kind": "alias",
"path": "mongo_ops.populate.rules.dataclass",
"signature": "<bound method Alias.signature of Alias('dataclass', 'dataclasses.dataclass')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.populate.rules.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mongo_ops.populate.rules.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.populate.rules.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.populate.rules.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"PopulateRule": {
"name": "PopulateRule",
"kind": "class",
"path": "mongo_ops.populate.rules.PopulateRule",
"signature": "<bound method Class.signature of Class('PopulateRule', 5, 12)>",
"docstring": null,
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
"members": {
"field_name": {
"name": "field_name",

View File

@@ -2,105 +2,70 @@
"module": "mongo_ops.registry",
"content": {
"path": "mongo_ops.registry",
"docstring": "Model registration for multi-service initialization.",
"docstring": "# Summary\n\nModel registration for multi-service initialization.",
"objects": {
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mongo_ops.registry.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.registry.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.registry.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"Type": {
"name": "Type",
"kind": "alias",
"path": "mongo_ops.registry.Type",
"signature": "<bound method Alias.signature of Alias('Type', 'typing.Type')>",
"docstring": null
},
"AsyncIOMotorDatabase": {
"name": "AsyncIOMotorDatabase",
"kind": "alias",
"path": "mongo_ops.registry.AsyncIOMotorDatabase",
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorDatabase', 'motor.motor_asyncio.AsyncIOMotorDatabase')>",
"docstring": null
},
"CacheBackend": {
"name": "CacheBackend",
"kind": "class",
"path": "mongo_ops.registry.CacheBackend",
"signature": "<bound method Alias.signature of Alias('CacheBackend', 'mongo_ops.cache.backend.CacheBackend')>",
"docstring": null,
"signature": null,
"docstring": "Abstract interface for cache backends.\n\nImplementations store byte-encoded values keyed by string, track usage\nstatistics, and manage their own lifecycle. The in-memory and Redis\nbackends both implement this contract.",
"members": {
"get": {
"name": "get",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.get",
"signature": "<bound method Alias.signature of Alias('get', 'mongo_ops.cache.backend.CacheBackend.get')>",
"docstring": null
"signature": "get(key: str)",
"docstring": "Fetch a value from the cache.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n Optional[bytes]: The cached bytes, or None on a miss."
},
"set": {
"name": "set",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.set",
"signature": "<bound method Alias.signature of Alias('set', 'mongo_ops.cache.backend.CacheBackend.set')>",
"docstring": null
"signature": "set(key: str, value: bytes, ttl: int | None = None)",
"docstring": "Store a value in the cache.\n\nArgs:\n key (str):\n The cache key.\n value (bytes):\n The byte-encoded value to store.\n ttl (Optional[int]):\n Time-to-live in seconds. When None, the backend default\n applies."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.delete",
"signature": "<bound method Alias.signature of Alias('delete', 'mongo_ops.cache.backend.CacheBackend.delete')>",
"docstring": null
"signature": "delete(key: str)",
"docstring": "Remove a key from the cache.\n\nArgs:\n key (str):\n The cache key."
},
"exists": {
"name": "exists",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.exists",
"signature": "<bound method Alias.signature of Alias('exists', 'mongo_ops.cache.backend.CacheBackend.exists')>",
"docstring": null
"signature": "exists(key: str)",
"docstring": "Check whether a key is present.\n\nArgs:\n key (str):\n The cache key.\n\nReturns:\n bool: True if the key exists, False otherwise."
},
"clear_pattern": {
"name": "clear_pattern",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.clear_pattern",
"signature": "<bound method Alias.signature of Alias('clear_pattern', 'mongo_ops.cache.backend.CacheBackend.clear_pattern')>",
"docstring": null
"signature": "clear_pattern(pattern: str)",
"docstring": "Remove all keys matching a glob pattern.\n\nArgs:\n pattern (str):\n Glob-style pattern; a trailing `*` matches prefixes."
},
"get_stats": {
"name": "get_stats",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.get_stats",
"signature": "<bound method Alias.signature of Alias('get_stats', 'mongo_ops.cache.backend.CacheBackend.get_stats')>",
"docstring": null
"signature": "get_stats()",
"docstring": "Return a snapshot of cache statistics.\n\nReturns:\n CacheStats: A copy of the current stats counters."
},
"initialize": {
"name": "initialize",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.initialize",
"signature": "<bound method Alias.signature of Alias('initialize', 'mongo_ops.cache.backend.CacheBackend.initialize')>",
"docstring": null
"signature": "initialize()",
"docstring": "Start background resources owned by the backend.\n\nShould be called once during application startup, after the\nrepositories are connected."
},
"shutdown": {
"name": "shutdown",
"kind": "function",
"path": "mongo_ops.registry.CacheBackend.shutdown",
"signature": "<bound method Alias.signature of Alias('shutdown', 'mongo_ops.cache.backend.CacheBackend.shutdown')>",
"docstring": null
"signature": "shutdown()",
"docstring": "Stop and release background resources.\n\nShould be called once during application shutdown."
}
}
},
@@ -108,43 +73,43 @@
"name": "MongoConnectionManager",
"kind": "class",
"path": "mongo_ops.registry.MongoConnectionManager",
"signature": "<bound method Alias.signature of Alias('MongoConnectionManager', 'mongo_ops.connection.MongoConnectionManager')>",
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and \ndatabase instances, ensuring they are properly initialized and closed \nacross the application lifecycle.",
"signature": null,
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and\ndatabase instances, ensuring they are properly initialized and closed\nacross the application lifecycle.",
"members": {
"connect": {
"name": "connect",
"kind": "function",
"path": "mongo_ops.registry.MongoConnectionManager.connect",
"signature": "<bound method Alias.signature of Alias('connect', 'mongo_ops.connection.MongoConnectionManager.connect')>",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri: MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name: Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
"signature": "connect(uri: str, db_name: str, **kwargs: Any)",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri (str): MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name (str): Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
},
"disconnect": {
"name": "disconnect",
"kind": "function",
"path": "mongo_ops.registry.MongoConnectionManager.disconnect",
"signature": "<bound method Alias.signature of Alias('disconnect', 'mongo_ops.connection.MongoConnectionManager.disconnect')>",
"signature": "disconnect()",
"docstring": "Close the active MongoDB connection and cleanup resources."
},
"get_database": {
"name": "get_database",
"kind": "function",
"path": "mongo_ops.registry.MongoConnectionManager.get_database",
"signature": "<bound method Alias.signature of Alias('get_database', 'mongo_ops.connection.MongoConnectionManager.get_database')>",
"signature": "get_database()",
"docstring": "Retrieve the current database instance.\n\nReturns:\n AsyncIOMotorDatabase: The active database instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"get_client": {
"name": "get_client",
"kind": "function",
"path": "mongo_ops.registry.MongoConnectionManager.get_client",
"signature": "<bound method Alias.signature of Alias('get_client', 'mongo_ops.connection.MongoConnectionManager.get_client')>",
"signature": "get_client()",
"docstring": "Retrieve the current client instance.\n\nReturns:\n AsyncIOMotorClient: The active Motor client instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"lifespan": {
"name": "lifespan",
"kind": "function",
"path": "mongo_ops.registry.MongoConnectionManager.lifespan",
"signature": "<bound method Alias.signature of Alias('lifespan', 'mongo_ops.connection.MongoConnectionManager.lifespan')>",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting \nlifespan management.\n\nArgs:\n uri: MongoDB connection URI.\n db_name: Name of the database.\n **kwargs: Additional Motor client options.\n\nYields:\n AsyncIOMotorDatabase: The active database instance.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
"signature": "lifespan(uri: str, db_name: str, **kwargs: Any)",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting\nlifespan management.\n\nNotes:\n Connects to MongoDB on entry, yields the active database instance\n to the context body, and disconnects on exit.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
}
}
},
@@ -152,63 +117,63 @@
"name": "BaseDocument",
"kind": "class",
"path": "mongo_ops.registry.BaseDocument",
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"signature": null,
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"members": {
"id": {
"name": "id",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.id",
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
"signature": null,
"docstring": null
},
"created_at": {
"name": "created_at",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.created_at",
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
"signature": null,
"docstring": null
},
"updated_at": {
"name": "updated_at",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.updated_at",
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
"signature": null,
"docstring": null
},
"Config": {
"name": "Config",
"kind": "class",
"path": "mongo_ops.registry.BaseDocument.Config",
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
"signature": null,
"docstring": null,
"members": {
"populate_by_name": {
"name": "populate_by_name",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.Config.populate_by_name",
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
"signature": null,
"docstring": null
},
"arbitrary_types_allowed": {
"name": "arbitrary_types_allowed",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.Config.arbitrary_types_allowed",
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
"signature": null,
"docstring": null
},
"json_encoders": {
"name": "json_encoders",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.Config.json_encoders",
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
"signature": null,
"docstring": null
},
"json_schema_extra": {
"name": "json_schema_extra",
"kind": "attribute",
"path": "mongo_ops.registry.BaseDocument.Config.json_schema_extra",
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
"signature": null,
"docstring": null
}
}
@@ -219,63 +184,63 @@
"name": "ModelRegistry",
"kind": "class",
"path": "mongo_ops.registry.ModelRegistry",
"signature": "<bound method Class.signature of Class('ModelRegistry', 11, 149)>",
"docstring": "Registry for managing multiple models and their collections.\n\nThis registry allows central management of collections and their \nassociated indexes, making it easier to perform mass initialization \nat application startup.",
"signature": null,
"docstring": "Registry for managing multiple models and their collections.\n\nThis registry allows central management of collections and their\nassociated indexes, making it easier to perform mass initialization\nat application startup.",
"members": {
"register": {
"name": "register",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.register",
"signature": "<bound method Function.signature of Function('register', 24, 48)>",
"docstring": "Register a model with its collection and indexes.\n\nArgs:\n collection_name: Name of the MongoDB collection.\n model: Document model class (subclass of BaseDocument).\n indexes: List of index specifications (e.g., [(\"email\", 1)]).\n\nUsage:\n ModelRegistry.register(\n \"users\",\n UserDocument,\n indexes=[(\"email\", 1), (\"created_at\", -1)]\n )"
"signature": "register(collection_name: str, model: type[BaseDocument], indexes: list[tuple] | None = None) -> None",
"docstring": "Register a model with its collection and indexes.\n\nArgs:\n collection_name (str): Name of the MongoDB collection.\n model (type[BaseDocument]): Document model class (subclass of BaseDocument).\n indexes (list[Any]): List of index specifications. Each spec is passed\n directly to pymongo's create_index. Supported forms:\n - single field: (\"email\", 1)\n - compound: [(\"author_id\", 1), (\"created_at\", -1)]\n - with options: {\"keys\": [(\"username\", 1)], \"options\": {\"unique\": True}}\n\nExample:\n ModelRegistry.register(\"users\", UserDocument, indexes=[(\"email\", 1)])\n ModelRegistry.register(\n \"posts\",\n PostDocument,\n indexes=[[(\"author_id\", 1), (\"created_at\", -1)]],\n )"
},
"initialize_all": {
"name": "initialize_all",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.initialize_all",
"signature": "<bound method Function.signature of Function('initialize_all', 50, 67)>",
"docstring": "Initialize all registered collections and create indexes.\n\nThis method should be called during application startup to ensure \nall necessary indexes exist in the database.\n\nArgs:\n db: Database instance. If not provided, uses the global database \n from MongoConnectionManager."
"signature": "initialize_all(db: AsyncIOMotorDatabase | None = None) -> None",
"docstring": "Initialize all registered collections and create indexes.\n\nThis method should be called during application startup to ensure\nall necessary indexes exist in the database.\n\nArgs:\n db (Optional[AsyncIOMotorDatabase]): Database instance. If not provided,\n uses the global database from MongoConnectionManager."
},
"get_model": {
"name": "get_model",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.get_model",
"signature": "<bound method Function.signature of Function('get_model', 69, 85)>",
"docstring": "Retrieve a registered model by its collection name.\n\nArgs:\n collection_name: The name of the collection.\n\nReturns:\n Type[BaseDocument]: The registered model class.\n\nRaises:\n KeyError: If the model for the given collection is not registered."
"signature": "get_model(collection_name: str) -> type[BaseDocument]",
"docstring": "Retrieve a registered model by its collection name.\n\nArgs:\n collection_name (str): The name of the collection.\n\nReturns:\n type[BaseDocument]: The registered model class.\n\nRaises:\n KeyError: If the model for the given collection is not registered."
},
"list_collections": {
"name": "list_collections",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.list_collections",
"signature": "<bound method Function.signature of Function('list_collections', 87, 95)>",
"docstring": "List all registered collection names.\n\nReturns:\n List[str]: A list of collection names."
"signature": "list_collections() -> list[str]",
"docstring": "List all registered collection names.\n\nReturns:\n list[str]: A list of collection names."
},
"get_cache_backend": {
"name": "get_cache_backend",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.get_cache_backend",
"signature": "<bound method Function.signature of Function('get_cache_backend', 97, 105)>",
"signature": "get_cache_backend() -> CacheBackend | None",
"docstring": "Get the registered cache backend instance.\n\nReturns:\n Optional[CacheBackend]: The cache backend, if registered."
},
"set_cache_backend": {
"name": "set_cache_backend",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.set_cache_backend",
"signature": "<bound method Function.signature of Function('set_cache_backend', 107, 119)>",
"docstring": "Register a cache backend for all cache-enabled repositories.\n\nShould be called after MongoDB connection is established,\nbefore cache-backed repositories are used.\n\nArgs:\n backend: A CacheBackend instance (InMemoryCacheBackend\n or RedisCacheBackend)."
"signature": "set_cache_backend(backend: CacheBackend) -> None",
"docstring": "Register a cache backend for all cache-enabled repositories.\n\nShould be called after MongoDB connection is established,\nbefore cache-backed repositories are used.\n\nArgs:\n backend (CacheBackend): A CacheBackend instance (InMemoryCacheBackend\n or RedisCacheBackend)."
},
"initialize_cache": {
"name": "initialize_cache",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.initialize_cache",
"signature": "<bound method Function.signature of Function('initialize_cache', 121, 137)>",
"signature": "initialize_cache() -> None",
"docstring": "Initialize the registered cache backend.\n\nMust be called after set_cache_backend() and before any\ncache-backed repository operations. Typically called right\nafter MongoDB connection is established.\n\nRaises:\n RuntimeError: If no cache backend has been registered."
},
"shutdown_cache": {
"name": "shutdown_cache",
"kind": "function",
"path": "mongo_ops.registry.ModelRegistry.shutdown_cache",
"signature": "<bound method Function.signature of Function('shutdown_cache', 139, 149)>",
"signature": "shutdown_cache() -> None",
"docstring": "Shutdown the registered cache backend gracefully.\n\nShould be called during application shutdown to clean up\nbackground tasks (e.g., in-memory TTL cleanup)."
}
}

View File

@@ -2,119 +2,49 @@
"module": "mongo_ops.repository",
"content": {
"path": "mongo_ops.repository",
"docstring": "Repository patterns and CRUD mixins for MongoDB.",
"docstring": "# Summary\n\nRepository patterns and CRUD mixins for MongoDB.",
"objects": {
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "mongo_ops.repository.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.repository.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "mongo_ops.repository.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"Generic": {
"name": "Generic",
"kind": "alias",
"path": "mongo_ops.repository.Generic",
"signature": "<bound method Alias.signature of Alias('Generic', 'typing.Generic')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.repository.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"Optional": {
"name": "Optional",
"kind": "alias",
"path": "mongo_ops.repository.Optional",
"signature": "<bound method Alias.signature of Alias('Optional', 'typing.Optional')>",
"docstring": null
},
"TypeVar": {
"name": "TypeVar",
"kind": "alias",
"path": "mongo_ops.repository.TypeVar",
"signature": "<bound method Alias.signature of Alias('TypeVar', 'typing.TypeVar')>",
"docstring": null
},
"Union": {
"name": "Union",
"kind": "alias",
"path": "mongo_ops.repository.Union",
"signature": "<bound method Alias.signature of Alias('Union', 'typing.Union')>",
"docstring": null
},
"ObjectId": {
"name": "ObjectId",
"kind": "alias",
"path": "mongo_ops.repository.ObjectId",
"signature": "<bound method Alias.signature of Alias('ObjectId', 'bson.ObjectId')>",
"docstring": null
},
"AsyncIOMotorCollection": {
"name": "AsyncIOMotorCollection",
"kind": "alias",
"path": "mongo_ops.repository.AsyncIOMotorCollection",
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorCollection', 'motor.motor_asyncio.AsyncIOMotorCollection')>",
"docstring": null
},
"MongoConnectionManager": {
"name": "MongoConnectionManager",
"kind": "class",
"path": "mongo_ops.repository.MongoConnectionManager",
"signature": "<bound method Alias.signature of Alias('MongoConnectionManager', 'mongo_ops.connection.MongoConnectionManager')>",
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and \ndatabase instances, ensuring they are properly initialized and closed \nacross the application lifecycle.",
"signature": null,
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and\ndatabase instances, ensuring they are properly initialized and closed\nacross the application lifecycle.",
"members": {
"connect": {
"name": "connect",
"kind": "function",
"path": "mongo_ops.repository.MongoConnectionManager.connect",
"signature": "<bound method Alias.signature of Alias('connect', 'mongo_ops.connection.MongoConnectionManager.connect')>",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri: MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name: Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
"signature": "connect(uri: str, db_name: str, **kwargs: Any)",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri (str): MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name (str): Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
},
"disconnect": {
"name": "disconnect",
"kind": "function",
"path": "mongo_ops.repository.MongoConnectionManager.disconnect",
"signature": "<bound method Alias.signature of Alias('disconnect', 'mongo_ops.connection.MongoConnectionManager.disconnect')>",
"signature": "disconnect()",
"docstring": "Close the active MongoDB connection and cleanup resources."
},
"get_database": {
"name": "get_database",
"kind": "function",
"path": "mongo_ops.repository.MongoConnectionManager.get_database",
"signature": "<bound method Alias.signature of Alias('get_database', 'mongo_ops.connection.MongoConnectionManager.get_database')>",
"signature": "get_database()",
"docstring": "Retrieve the current database instance.\n\nReturns:\n AsyncIOMotorDatabase: The active database instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"get_client": {
"name": "get_client",
"kind": "function",
"path": "mongo_ops.repository.MongoConnectionManager.get_client",
"signature": "<bound method Alias.signature of Alias('get_client', 'mongo_ops.connection.MongoConnectionManager.get_client')>",
"signature": "get_client()",
"docstring": "Retrieve the current client instance.\n\nReturns:\n AsyncIOMotorClient: The active Motor client instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"lifespan": {
"name": "lifespan",
"kind": "function",
"path": "mongo_ops.repository.MongoConnectionManager.lifespan",
"signature": "<bound method Alias.signature of Alias('lifespan', 'mongo_ops.connection.MongoConnectionManager.lifespan')>",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting \nlifespan management.\n\nArgs:\n uri: MongoDB connection URI.\n db_name: Name of the database.\n **kwargs: Additional Motor client options.\n\nYields:\n AsyncIOMotorDatabase: The active database instance.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
"signature": "lifespan(uri: str, db_name: str, **kwargs: Any)",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting\nlifespan management.\n\nNotes:\n Connects to MongoDB on entry, yields the active database instance\n to the context body, and disconnects on exit.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
}
}
},
@@ -122,63 +52,63 @@
"name": "BaseDocument",
"kind": "class",
"path": "mongo_ops.repository.BaseDocument",
"signature": "<bound method Alias.signature of Alias('BaseDocument', 'mongo_ops.models.BaseDocument')>",
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent \nMongoDB documents. It includes automatic handling of the `_id` field \nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"signature": null,
"docstring": "Base document class with common MongoDB fields.\n\nInherit from this class to create Pydantic models that represent\nMongoDB documents. It includes automatic handling of the `_id` field\nand timestamps.\n\nAttributes:\n id: The MongoDB document ID (aliased to `_id`).\n created_at: Timestamp when the document was created.\n updated_at: Timestamp when the document was last updated.",
"members": {
"id": {
"name": "id",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.id",
"signature": "<bound method Alias.signature of Alias('id', 'mongo_ops.models.BaseDocument.id')>",
"signature": null,
"docstring": null
},
"created_at": {
"name": "created_at",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.created_at",
"signature": "<bound method Alias.signature of Alias('created_at', 'mongo_ops.models.BaseDocument.created_at')>",
"signature": null,
"docstring": null
},
"updated_at": {
"name": "updated_at",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.updated_at",
"signature": "<bound method Alias.signature of Alias('updated_at', 'mongo_ops.models.BaseDocument.updated_at')>",
"signature": null,
"docstring": null
},
"Config": {
"name": "Config",
"kind": "class",
"path": "mongo_ops.repository.BaseDocument.Config",
"signature": "<bound method Alias.signature of Alias('Config', 'mongo_ops.models.BaseDocument.Config')>",
"signature": null,
"docstring": null,
"members": {
"populate_by_name": {
"name": "populate_by_name",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.Config.populate_by_name",
"signature": "<bound method Alias.signature of Alias('populate_by_name', 'mongo_ops.models.BaseDocument.Config.populate_by_name')>",
"signature": null,
"docstring": null
},
"arbitrary_types_allowed": {
"name": "arbitrary_types_allowed",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.Config.arbitrary_types_allowed",
"signature": "<bound method Alias.signature of Alias('arbitrary_types_allowed', 'mongo_ops.models.BaseDocument.Config.arbitrary_types_allowed')>",
"signature": null,
"docstring": null
},
"json_encoders": {
"name": "json_encoders",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.Config.json_encoders",
"signature": "<bound method Alias.signature of Alias('json_encoders', 'mongo_ops.models.BaseDocument.Config.json_encoders')>",
"signature": null,
"docstring": null
},
"json_schema_extra": {
"name": "json_schema_extra",
"kind": "attribute",
"path": "mongo_ops.repository.BaseDocument.Config.json_schema_extra",
"signature": "<bound method Alias.signature of Alias('json_schema_extra', 'mongo_ops.models.BaseDocument.Config.json_schema_extra')>",
"signature": null,
"docstring": null
}
}
@@ -189,29 +119,29 @@
"name": "PopulationEngine",
"kind": "class",
"path": "mongo_ops.repository.PopulationEngine",
"signature": "<bound method Alias.signature of Alias('PopulationEngine', 'mongo_ops.populate.engine.PopulationEngine')>",
"docstring": null,
"signature": "PopulationEngine(repos: dict[str, Any], global_max_depth: int = 10)",
"docstring": "Resolves FK references across collections with cycle detection.\n\nThe engine holds a registry of repositories keyed by collection name and\nwalks documents according to PopulateRules, resolving ObjectId references\ninto model instances. A visited-path set guards against circular graphs.\n\nNotes:\n **Guarantees:**\n\n - A reference that cannot be resolved becomes None (scalar) or a\n None entry (list) rather than raising.\n - Depth is capped by both per-rule max_depth and a global\n global_max_depth.",
"members": {
"register_repo": {
"name": "register_repo",
"kind": "function",
"path": "mongo_ops.repository.PopulationEngine.register_repo",
"signature": "<bound method Alias.signature of Alias('register_repo', 'mongo_ops.populate.engine.PopulationEngine.register_repo')>",
"docstring": null
"signature": "register_repo(collection_name: str, repo: Any)",
"docstring": "Register or replace the repository for a collection.\n\nArgs:\n collection_name (str):\n Collection the repository manages.\n repo (Any):\n Repository exposing get_by_id() used to resolve references."
},
"populate": {
"name": "populate",
"kind": "function",
"path": "mongo_ops.repository.PopulationEngine.populate",
"signature": "<bound method Alias.signature of Alias('populate', 'mongo_ops.populate.engine.PopulationEngine.populate')>",
"docstring": null
"signature": "populate(document: T, rules: list[PopulateRule], depth: int = 0, _visited: set[tuple[str, str]] | None = None, _path: list[str] | None = None)",
"docstring": "Resolve FK fields on a document according to the given rules.\n\nArgs:\n document (T):\n The document to populate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to resolve and how deep.\n depth (int):\n Current recursion depth. Defaults to 0.\n _visited (Optional[set[tuple[str, str]]]):\n Internal set of (class, id) pairs on the active path.\n _path (Optional[list[str]]):\n Internal path labels used for cycle reporting.\n\nReturns:\n T: The populated document.\n\nRaises:\n CircularReferenceError: If a cycle is detected on the active path."
},
"depopulate": {
"name": "depopulate",
"kind": "function",
"path": "mongo_ops.repository.PopulationEngine.depopulate",
"signature": "<bound method Alias.signature of Alias('depopulate', 'mongo_ops.populate.engine.PopulationEngine.depopulate')>",
"docstring": null
"signature": "depopulate(document: T, rules: list[PopulateRule])",
"docstring": "Collapse populated model references back to their ObjectIds.\n\nThis is the inverse of populate(): model-valued FK fields are reduced\nto stored identifiers before the document is written to MongoDB.\n\nArgs:\n document (T):\n The document to depopulate in place.\n rules (list[PopulateRule]):\n Rules describing which fields to collapse.\n\nReturns:\n T: The depopulated document.\n\nRaises:\n AttributeError: If a list entry is not a BaseDocument where\n expected."
}
}
},
@@ -219,49 +149,49 @@
"name": "PopulateRule",
"kind": "class",
"path": "mongo_ops.repository.PopulateRule",
"signature": "<bound method Alias.signature of Alias('PopulateRule', 'mongo_ops.populate.rules.PopulateRule')>",
"docstring": null,
"signature": "PopulateRule(field_name: str, collection_name: str, nested_rules: list[PopulateRule] | None = None, max_depth: int = 1, filter: dict[str, Any] | None = None, projection: dict[str, Any] | None = None)",
"docstring": "Describes how a foreign-key field resolves to another collection.\n\nA rule declares the field to resolve, the collection its references\npoint at, and optional nested rules applied to the referenced document\nitself. It also bounds how deep the resolution may recurse.\n\nAttributes:\n field_name (str):\n Name of the FK field on the source document.\n collection_name (str):\n Collection the reference points into.\n nested_rules (Optional[list[PopulateRule]]):\n Sub-rules applied to the referenced document. Defaults to None.\n max_depth (int):\n Maximum recursion depth for this rule. Defaults to 1.\n filter (Optional[dict[str, Any]]):\n Optional Mongo filter applied when fetching the reference.\n Defaults to None.\n projection (Optional[dict[str, Any]]):\n Optional Mongo projection applied when fetching the reference.\n Defaults to None.",
"members": {
"field_name": {
"name": "field_name",
"kind": "attribute",
"path": "mongo_ops.repository.PopulateRule.field_name",
"signature": "<bound method Alias.signature of Alias('field_name', 'mongo_ops.populate.rules.PopulateRule.field_name')>",
"signature": null,
"docstring": null
},
"collection_name": {
"name": "collection_name",
"kind": "attribute",
"path": "mongo_ops.repository.PopulateRule.collection_name",
"signature": "<bound method Alias.signature of Alias('collection_name', 'mongo_ops.populate.rules.PopulateRule.collection_name')>",
"signature": null,
"docstring": null
},
"nested_rules": {
"name": "nested_rules",
"kind": "attribute",
"path": "mongo_ops.repository.PopulateRule.nested_rules",
"signature": "<bound method Alias.signature of Alias('nested_rules', 'mongo_ops.populate.rules.PopulateRule.nested_rules')>",
"signature": null,
"docstring": null
},
"max_depth": {
"name": "max_depth",
"kind": "attribute",
"path": "mongo_ops.repository.PopulateRule.max_depth",
"signature": "<bound method Alias.signature of Alias('max_depth', 'mongo_ops.populate.rules.PopulateRule.max_depth')>",
"signature": null,
"docstring": null
},
"filter": {
"name": "filter",
"kind": "attribute",
"path": "mongo_ops.repository.PopulateRule.filter",
"signature": "<bound method Alias.signature of Alias('filter', 'mongo_ops.populate.rules.PopulateRule.filter')>",
"signature": null,
"docstring": null
},
"projection": {
"name": "projection",
"kind": "attribute",
"path": "mongo_ops.repository.PopulateRule.projection",
"signature": "<bound method Alias.signature of Alias('projection', 'mongo_ops.populate.rules.PopulateRule.projection')>",
"signature": null,
"docstring": null
}
}
@@ -277,8 +207,8 @@
"name": "CRUDMixin",
"kind": "class",
"path": "mongo_ops.repository.CRUDMixin",
"signature": "<bound method Class.signature of Class('CRUDMixin', 16, 196)>",
"docstring": "Generic CRUD operations mixin for MongoDB collections.\n\nThis mixin provides standard Create, Read, Update, and Delete operations \nthat work with Pydantic models.\n\nAttributes:\n collection: The Motor collection instance.\n model: The Pydantic model class representing the document.",
"signature": "CRUDMixin(collection: AsyncIOMotorCollection, model: type[T])",
"docstring": "Generic CRUD operations mixin for MongoDB collections.\n\nThis mixin provides standard Create, Read, Update, and Delete operations\nthat work with Pydantic models.\n\nAttributes:\n collection: The Motor collection instance.\n model: The Pydantic model class representing the document.",
"members": {
"collection": {
"name": "collection",
@@ -298,57 +228,57 @@
"name": "data_to_model",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.data_to_model",
"signature": "<bound method Function.signature of Function('data_to_model', 39, 40)>",
"signature": "data_to_model(data: dict) -> T",
"docstring": null
},
"create": {
"name": "create",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.create",
"signature": "<bound method Function.signature of Function('create', 42, 58)>",
"docstring": "Create a new document in the collection.\n\nArgs:\n data: The Pydantic model instance to insert.\n\nReturns:\n T: The created Pydantic model instance, including the assigned ID."
"signature": "create(data: T) -> T",
"docstring": "Create a new document in the collection.\n\nArgs:\n data (T): The Pydantic model instance to insert.\n\nReturns:\n T: The created Pydantic model instance, including the assigned ID."
},
"get_by_id": {
"name": "get_by_id",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.get_by_id",
"signature": "<bound method Function.signature of Function('get_by_id', 60, 74)>",
"docstring": "Retrieve a document by its ID.\n\nArgs:\n id: The document ID (string or ObjectId).\n\nReturns:\n Optional[T]: The Pydantic model instance if found, else None."
"signature": "get_by_id(id: str | ObjectId) -> T | None",
"docstring": "Retrieve a document by its ID.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n\nReturns:\n Optional[T]: The Pydantic model instance if found, else None."
},
"get_many": {
"name": "get_many",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.get_many",
"signature": "<bound method Function.signature of Function('get_many', 76, 115)>",
"docstring": "Retrieve multiple documents with filtering, pagination, and sorting.\n\nArgs:\n filter: MongoDB filter dictionary (e.g., {\"is_active\": True}).\n skip: Number of documents to skip for pagination.\n limit: Maximum number of documents to return (default 100).\n sort: List of sort specifications [(field, direction), ...].\n E.g., [(\"created_at\", -1)] for descending.\n\nReturns:\n List[T]: A list of Pydantic model instances.\n\nUsage:\n ```python\n users = await repo.get_many(\n filter={\"role\": \"admin\"},\n limit=10,\n sort=[(\"username\", 1)]\n )\n ```"
"signature": "get_many(filter: dict[str, Any] | None = None, skip: int = 0, limit: int = 100, sort: list[tuple] | None = None) -> list[T]",
"docstring": "Retrieve multiple documents with filtering, pagination, and sorting.\n\nArgs:\n filter (Optional[Dict[str, Any]]): MongoDB filter dictionary (e.g., {\"is_active\": True}).\n skip (int): Number of documents to skip for pagination.\n limit (int): Maximum number of documents to return (default 100).\n sort (Optional[List[tuple]]): List of sort specifications [(field, direction), ...].\n E.g., [(\"created_at\", -1)] for descending.\n\nReturns:\n List[T]: A list of Pydantic model instances.\n\nExample:\n ```python\n users = await repo.get_many(\n filter={\"role\": \"admin\"},\n limit=10,\n sort=[(\"username\", 1)]\n )\n ```"
},
"update": {
"name": "update",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.update",
"signature": "<bound method Function.signature of Function('update', 117, 142)>",
"docstring": "Update a document by its ID using the $set operator.\n\nArgs:\n id: The document ID (string or ObjectId).\n data: A dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None.\n\nUsage:\n ```python\n updated_user = await repo.update(user_id, {\"email\": \"new@example.com\"})\n ```"
"signature": "update(id: str | ObjectId, data: dict[str, Any]) -> T | None",
"docstring": "Update a document by its ID using the $set operator.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n data (Dict[str, Any]): A dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None.\n\nExample:\n ```python\n updated_user = await repo.update(user_id, {\"email\": \"new@example.com\"})\n ```"
},
"patch": {
"name": "patch",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.patch",
"signature": "<bound method Function.signature of Function('patch', 144, 167)>",
"docstring": "Partially update a document using $set (REST PATCH semantics).\n\nUnlike update(), patch() takes a partial dict and applies only those\nfields. PopulatingRepository overrides this to prevent patching FK fields.\n\nArgs:\n id: The document ID (string or ObjectId).\n data: A partial dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None."
"signature": "patch(id: str | ObjectId, data: dict[str, Any]) -> T | None",
"docstring": "Partially update a document using $set (REST PATCH semantics).\n\nUnlike update(), patch() takes a partial dict and applies only those\nfields. PopulatingRepository overrides this to prevent patching FK fields.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n data (Dict[str, Any]): A partial dictionary of fields and values to update.\n\nReturns:\n Optional[T]: The updated Pydantic model instance if found, else None."
},
"delete": {
"name": "delete",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.delete",
"signature": "<bound method Function.signature of Function('delete', 169, 183)>",
"docstring": "Delete a document by its ID.\n\nArgs:\n id: The document ID (string or ObjectId).\n\nReturns:\n bool: True if a document was deleted, False otherwise."
"signature": "delete(id: str | ObjectId) -> bool",
"docstring": "Delete a document by its ID.\n\nArgs:\n id (Union[str, ObjectId]): The document ID (string or ObjectId).\n\nReturns:\n bool: True if a document was deleted, False otherwise."
},
"count": {
"name": "count",
"kind": "function",
"path": "mongo_ops.repository.CRUDMixin.count",
"signature": "<bound method Function.signature of Function('count', 185, 196)>",
"docstring": "Count documents matching a filter.\n\nArgs:\n filter: MongoDB filter dictionary.\n\nReturns:\n int: The number of matching documents."
"signature": "count(filter: dict[str, Any] | None = None) -> int",
"docstring": "Count documents matching a filter.\n\nArgs:\n filter (Optional[Dict[str, Any]]): MongoDB filter dictionary.\n\nReturns:\n int: The number of matching documents."
}
}
},
@@ -356,8 +286,8 @@
"name": "BaseRepository",
"kind": "class",
"path": "mongo_ops.repository.BaseRepository",
"signature": "<bound method Class.signature of Class('BaseRepository', 199, 221)>",
"docstring": "Base repository class combining CRUD operations and collection management.\n\nThis class simplifies repository creation by automatically obtaining the \ndatabase connection and collection instance.\n\nAttributes:\n collection_name: The name of the collection managed by this repository.",
"signature": "BaseRepository(collection_name: str, model: type[T])",
"docstring": "Base repository class combining CRUD operations and collection management.\n\nThis class simplifies repository creation by automatically obtaining the\ndatabase connection and collection instance.\n\nAttributes:\n collection_name: The name of the collection managed by this repository.",
"members": {
"collection_name": {
"name": "collection_name",
@@ -372,8 +302,8 @@
"name": "PopulatingRepository",
"kind": "class",
"path": "mongo_ops.repository.PopulatingRepository",
"signature": "<bound method Class.signature of Class('PopulatingRepository', 224, 342)>",
"docstring": null,
"signature": "PopulatingRepository(collection_name: str, model: type[T], population_engine: PopulationEngine | None = None, populate_rules: list[PopulateRule] | None = None)",
"docstring": "Repository that auto-populates and depopulates FK references.\n\nOn read, ObjectId FK fields are resolved to model instances according to\nthe configured PopulateRules. On write, populated model references are\ncollapsed back to ObjectIds before hitting MongoDB.\n\nNotes:\n **Guarantees:**\n\n - Populate rules apply on both read (data_to_model) and write\n (create/update) paths.\n - Patching FK fields via patch() is rejected.\n - Class attributes `population_engine` and `_populate_rules` must\n be set (see set_population_engine/set_populate_rules) for any\n population to occur.",
"members": {
"population_engine": {
"name": "population_engine",
@@ -386,43 +316,43 @@
"name": "set_population_engine",
"kind": "function",
"path": "mongo_ops.repository.PopulatingRepository.set_population_engine",
"signature": "<bound method Function.signature of Function('set_population_engine', 236, 237)>",
"docstring": null
"signature": "set_population_engine(engine: PopulationEngine) -> None",
"docstring": "Attach (or replace) the population engine.\n\nArgs:\n engine (PopulationEngine):\n Engine used to resolve references."
},
"set_populate_rules": {
"name": "set_populate_rules",
"kind": "function",
"path": "mongo_ops.repository.PopulatingRepository.set_populate_rules",
"signature": "<bound method Function.signature of Function('set_populate_rules', 239, 240)>",
"docstring": null
"signature": "set_populate_rules(rules: list[PopulateRule]) -> None",
"docstring": "Set the FK resolution rules.\n\nArgs:\n rules (list[PopulateRule]):\n Rules describing which fields resolve and how deep."
},
"data_to_model": {
"name": "data_to_model",
"kind": "function",
"path": "mongo_ops.repository.PopulatingRepository.data_to_model",
"signature": "<bound method Function.signature of Function('data_to_model', 242, 244)>",
"docstring": null
"signature": "data_to_model(data: dict) -> T",
"docstring": "Convert a raw dict to a model, resolving FK references first.\n\nArgs:\n data (dict):\n Raw document dictionary.\n\nReturns:\n T: The populated model instance.\n\nRaises:\n ValueError: If a FK field holds an embedded dict instead of an\n ObjectId."
},
"create": {
"name": "create",
"kind": "function",
"path": "mongo_ops.repository.PopulatingRepository.create",
"signature": "<bound method Function.signature of Function('create', 322, 328)>",
"docstring": null
"signature": "create(data: T) -> T",
"docstring": "Depopulate, insert, and re-populate a new document.\n\nArgs:\n data (T):\n The model instance to insert (FK fields may hold models).\n\nReturns:\n T: The created model instance, including its ID."
},
"update": {
"name": "update",
"kind": "function",
"path": "mongo_ops.repository.PopulatingRepository.update",
"signature": "<bound method Function.signature of Function('update', 330, 332)>",
"docstring": null
"signature": "update(id: str | ObjectId, data: T) -> T | None",
"docstring": "Depopulate and update a document by ID.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n data (T):\n The model instance holding the updated fields.\n\nReturns:\n Optional[T]: The updated model instance, or None when not found."
},
"patch": {
"name": "patch",
"kind": "function",
"path": "mongo_ops.repository.PopulatingRepository.patch",
"signature": "<bound method Function.signature of Function('patch', 334, 342)>",
"docstring": null
"signature": "patch(id: str | ObjectId, data: dict[str, Any]) -> T | None",
"docstring": "Partially update a document, rejecting FK field changes.\n\nArgs:\n id (Union[str, ObjectId]):\n The document ID.\n data (dict[str, Any]):\n Partial dictionary of fields to update.\n\nReturns:\n Optional[T]: The updated model instance, or None when not found.\n\nRaises:\n ValueError: If any FK field is present in the patch payload."
}
}
}

View File

@@ -2,91 +2,49 @@
"module": "mongo_ops.transactions",
"content": {
"path": "mongo_ops.transactions",
"docstring": "Transaction management helpers for MongoDB.",
"docstring": "# Summary\n\nTransaction management helpers for MongoDB.",
"objects": {
"Awaitable": {
"name": "Awaitable",
"kind": "alias",
"path": "mongo_ops.transactions.Awaitable",
"signature": "<bound method Alias.signature of Alias('Awaitable', 'collections.abc.Awaitable')>",
"docstring": null
},
"asynccontextmanager": {
"name": "asynccontextmanager",
"kind": "alias",
"path": "mongo_ops.transactions.asynccontextmanager",
"signature": "<bound method Alias.signature of Alias('asynccontextmanager', 'contextlib.asynccontextmanager')>",
"docstring": null
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "mongo_ops.transactions.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Callable": {
"name": "Callable",
"kind": "alias",
"path": "mongo_ops.transactions.Callable",
"signature": "<bound method Alias.signature of Alias('Callable', 'typing.Callable')>",
"docstring": null
},
"List": {
"name": "List",
"kind": "alias",
"path": "mongo_ops.transactions.List",
"signature": "<bound method Alias.signature of Alias('List', 'typing.List')>",
"docstring": null
},
"AsyncIOMotorClientSession": {
"name": "AsyncIOMotorClientSession",
"kind": "alias",
"path": "mongo_ops.transactions.AsyncIOMotorClientSession",
"signature": "<bound method Alias.signature of Alias('AsyncIOMotorClientSession', 'motor.motor_asyncio.AsyncIOMotorClientSession')>",
"docstring": null
},
"MongoConnectionManager": {
"name": "MongoConnectionManager",
"kind": "class",
"path": "mongo_ops.transactions.MongoConnectionManager",
"signature": "<bound method Alias.signature of Alias('MongoConnectionManager', 'mongo_ops.connection.MongoConnectionManager')>",
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and \ndatabase instances, ensuring they are properly initialized and closed \nacross the application lifecycle.",
"signature": null,
"docstring": "Manages MongoDB connections with async lifecycle.\n\nThis class provides a singleton-like manager for the MongoDB client and\ndatabase instances, ensuring they are properly initialized and closed\nacross the application lifecycle.",
"members": {
"connect": {
"name": "connect",
"kind": "function",
"path": "mongo_ops.transactions.MongoConnectionManager.connect",
"signature": "<bound method Alias.signature of Alias('connect', 'mongo_ops.connection.MongoConnectionManager.connect')>",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri: MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name: Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
"signature": "connect(uri: str, db_name: str, **kwargs: Any)",
"docstring": "Connect to MongoDB and initialize the shared client.\n\nArgs:\n uri (str): MongoDB connection URI (e.g., \"mongodb://localhost:27017\").\n db_name (str): Name of the database to use.\n **kwargs: Additional Motor client options (e.g., maxPoolSize).\n\nReturns:\n AsyncIOMotorDatabase: The initialized database instance."
},
"disconnect": {
"name": "disconnect",
"kind": "function",
"path": "mongo_ops.transactions.MongoConnectionManager.disconnect",
"signature": "<bound method Alias.signature of Alias('disconnect', 'mongo_ops.connection.MongoConnectionManager.disconnect')>",
"signature": "disconnect()",
"docstring": "Close the active MongoDB connection and cleanup resources."
},
"get_database": {
"name": "get_database",
"kind": "function",
"path": "mongo_ops.transactions.MongoConnectionManager.get_database",
"signature": "<bound method Alias.signature of Alias('get_database', 'mongo_ops.connection.MongoConnectionManager.get_database')>",
"signature": "get_database()",
"docstring": "Retrieve the current database instance.\n\nReturns:\n AsyncIOMotorDatabase: The active database instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"get_client": {
"name": "get_client",
"kind": "function",
"path": "mongo_ops.transactions.MongoConnectionManager.get_client",
"signature": "<bound method Alias.signature of Alias('get_client', 'mongo_ops.connection.MongoConnectionManager.get_client')>",
"signature": "get_client()",
"docstring": "Retrieve the current client instance.\n\nReturns:\n AsyncIOMotorClient: The active Motor client instance.\n\nRaises:\n RuntimeError: If connect() has not been called yet."
},
"lifespan": {
"name": "lifespan",
"kind": "function",
"path": "mongo_ops.transactions.MongoConnectionManager.lifespan",
"signature": "<bound method Alias.signature of Alias('lifespan', 'mongo_ops.connection.MongoConnectionManager.lifespan')>",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting \nlifespan management.\n\nArgs:\n uri: MongoDB connection URI.\n db_name: Name of the database.\n **kwargs: Additional Motor client options.\n\nYields:\n AsyncIOMotorDatabase: The active database instance.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
"signature": "lifespan(uri: str, db_name: str, **kwargs: Any)",
"docstring": "Async context manager for managing connection lifecycle.\n\nDesigned for use with FastAPI or other frameworks supporting\nlifespan management.\n\nNotes:\n Connects to MongoDB on entry, yields the active database instance\n to the context body, and disconnects on exit.\n\nUsage:\n @asynccontextmanager\n async def lifespan(app: FastAPI):\n async with MongoConnectionManager.lifespan(uri, db_name):\n yield"
}
}
},
@@ -94,22 +52,22 @@
"name": "TransactionManager",
"kind": "class",
"path": "mongo_ops.transactions.TransactionManager",
"signature": "<bound method Class.signature of Class('TransactionManager', 11, 69)>",
"docstring": "Simplified multi-document transaction handling.\n\nThis class provides helpers for executing operations within a MongoDB \ntransaction, ensuring ACID compliance for multi-document updates.",
"signature": null,
"docstring": "Simplified multi-document transaction handling.\n\nThis class provides helpers for executing operations within a MongoDB\ntransaction, ensuring ACID compliance for multi-document updates.",
"members": {
"start_session": {
"name": "start_session",
"kind": "function",
"path": "mongo_ops.transactions.TransactionManager.start_session",
"signature": "<bound method Function.signature of Function('start_session', 19, 39)>",
"docstring": "Start a transaction session as an async context manager.\n\nArgs:\n **kwargs: Transaction options (e.g., read_concern, write_concern).\n\nYields:\n AsyncIOMotorClientSession: The active session with a started transaction.\n\nUsage:\n async with TransactionManager.start_session() as session:\n await collection.insert_one(doc, session=session)\n await other_collection.update_one(filter, update, session=session)"
"signature": "start_session(**kwargs: Any) -> AbstractAsyncContextManager[AsyncIOMotorClientSession]",
"docstring": "Start a transaction session as an async context manager.\n\nNotes:\n Yields the active session with a started transaction; callers\n run their operations against the session inside the with-block.\n\nUsage:\n async with TransactionManager.start_session() as session:\n await collection.insert_one(doc, session=session)\n await other_collection.update_one(filter, update, session=session)"
},
"execute_transaction": {
"name": "execute_transaction",
"kind": "function",
"path": "mongo_ops.transactions.TransactionManager.execute_transaction",
"signature": "<bound method Function.signature of Function('execute_transaction', 41, 69)>",
"docstring": "Execute multiple operations within a single transaction.\n\nArgs:\n operations: A list of async callables that accept a session \n parameter and return a result.\n **kwargs: Transaction options.\n\nReturns:\n List[Any]: A list containing the results of each operation.\n\nUsage:\n results = await TransactionManager.execute_transaction([\n lambda s: repo1.create(data1, session=s),\n lambda s: repo2.update(id, data2, session=s),\n ])"
"signature": "execute_transaction(operations: list[Callable[[AsyncIOMotorClientSession], Awaitable[Any]]], **kwargs: Any) -> list[Any]",
"docstring": "Execute multiple operations within a single transaction.\n\nArgs:\n operations (List[Callable[[AsyncIOMotorClientSession], Awaitable[Any]]]): A list of async\n callables that accept a session parameter and return a result.\n **kwargs: Transaction options.\n\nReturns:\n List[Any]: A list containing the results of each operation.\n\nExample:\n results = await TransactionManager.execute_transaction([\n lambda s: repo1.create(data1, session=s),\n lambda s: repo2.update(id, data2, session=s),\n ])"
}
}
}