auto / database /mongo.py
rsnarsna
feat(admin): implement database-backed admin email whitelist validation and endpoints (DEC-027)
04b6a97
Raw History Blame Contribute Delete
2.14 kB
"""
ALLI Backend - MongoDB Repository Facade
Composes modular repository mixins while preserving 100% backward compatibility.
"""
from typing import Optional
from database.repository import WorkflowRepository
from database.connection import MongoConnectionMixin, get_utc_now
from database.workflows_repo import WorkflowsRepoMixin
from database.orgs_repo import OrgsRepoMixin
from database.audit_repo import AuditRepoMixin
from database.blueprints_repo import BlueprintsRepoMixin
from database.templates_repo import TemplatesRepoMixin
from database.catalogs_repo import CatalogsRepoMixin
from database.users_repo import UsersRepoMixin
from database.workspace_env_repo import WorkspaceEnvRepoMixin
from database.admin_repo import AdminRepoMixin
from database.seeds import (
get_default_packages,
get_default_core_specs,
get_default_starter_templates,
)
# Backward-compatible seed constants loaded from backend JSON specs
DEFAULT_PACKAGES = get_default_packages()
DEFAULT_CORE_SPECS = get_default_core_specs()
DEFAULT_STARTER_TEMPLATES = get_default_starter_templates()
class MongoWorkflowRepository(
MongoConnectionMixin,
WorkflowsRepoMixin,
OrgsRepoMixin,
AuditRepoMixin,
BlueprintsRepoMixin,
TemplatesRepoMixin,
CatalogsRepoMixin,
UsersRepoMixin,
WorkspaceEnvRepoMixin,
AdminRepoMixin,
WorkflowRepository,
):
"""Unified MongoDB Atlas + resilient in-memory repository."""
def __init__(self, uri: Optional[str] = None, db_name: Optional[str] = None):
self._init_connection(uri=uri, db_name=db_name)
self._init_workflows_store()
self._init_orgs_store()
self._init_audit_store()
self._init_blueprints_store()
self._init_templates_store()
self._init_catalogs_store()
self._init_users_store()
self._init_workspace_env_store()
self._init_admin_store()
# Central shared singleton instance
workflow_repo = MongoWorkflowRepository()
__all__ = [
"MongoWorkflowRepository",
"workflow_repo",
"get_utc_now",
"DEFAULT_PACKAGES",
"DEFAULT_CORE_SPECS",
"DEFAULT_STARTER_TEMPLATES",
]