File size: 2,143 Bytes
c3082d2
8628c98
 
c3082d2
 
8628c98
c3082d2
8628c98
 
 
 
 
 
 
 
 
04b6a97
8628c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04b6a97
8628c98
 
 
c3082d2
91a883e
8628c98
 
 
 
 
 
 
 
 
04b6a97
fed482a
09f67be
 
 
 
8628c98
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
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",
]