Files
orion/app/modules/cms/definition.py
Samir Boulahtit 1a52611438 feat: implement three-tier module classification and framework layer
Module Classification:
- Core (4): core, tenancy, cms, customers - always enabled
- Optional (7): payments, billing, inventory, orders, marketplace, analytics, messaging
- Internal (2): dev-tools, monitoring - admin-only

Key Changes:
- Rename platform-admin module to tenancy
- Promote CMS and Customers to core modules
- Create new payments module (gateway abstractions)
- Add billing→payments and orders→payments dependencies
- Mark dev-tools and monitoring as internal modules

New Infrastructure:
- app/modules/events.py: Module event bus (ENABLED, DISABLED, STARTUP, SHUTDOWN)
- app/modules/migrations.py: Module-specific migration discovery
- app/core/observability.py: Health checks, Prometheus metrics, Sentry integration

Enhanced ModuleDefinition:
- version, is_internal, permissions
- config_schema, default_config
- migrations_path
- Lifecycle hooks: on_enable, on_disable, on_startup, health_check

New Registry Functions:
- get_optional_module_codes(), get_internal_module_codes()
- is_core_module(), is_internal_module()
- get_modules_by_tier(), get_module_tier()

Migrations:
- zc*: Rename platform-admin to tenancy
- zd*: Ensure CMS and Customers enabled for all platforms

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 22:02:39 +01:00

82 lines
2.5 KiB
Python

# app/modules/cms/definition.py
"""
CMS module definition.
Defines the CMS module including its features, menu items,
route configurations, and self-contained component paths.
This is a self-contained module with:
- Services: app.modules.cms.services
- Models: app.modules.cms.models
- Exceptions: app.modules.cms.exceptions
- Templates: app.modules.cms.templates (namespaced as cms/)
"""
from app.modules.base import ModuleDefinition
from models.database.admin_menu_config import FrontendType
def _get_admin_router():
"""Lazy import of admin router to avoid circular imports."""
from app.modules.cms.routes.admin import admin_router
return admin_router
def _get_vendor_router():
"""Lazy import of vendor router to avoid circular imports."""
from app.modules.cms.routes.vendor import vendor_router
return vendor_router
# CMS module definition - Self-contained module (pilot)
cms_module = ModuleDefinition(
code="cms",
name="Content Management",
description="Content pages, media library, and vendor themes.",
features=[
"cms_basic", # Basic page editing
"cms_custom_pages", # Custom page creation
"cms_unlimited_pages", # No page limit
"cms_templates", # Page templates
"cms_seo", # SEO tools
"media_library", # Media file management
],
menu_items={
FrontendType.ADMIN: [
"content-pages", # Platform content pages
"vendor-themes", # Theme management
],
FrontendType.VENDOR: [
"content-pages", # Vendor content pages
"media", # Media library
],
},
is_core=True, # CMS is a core module - content management is fundamental
# Self-contained module configuration
is_self_contained=True,
services_path="app.modules.cms.services",
models_path="app.modules.cms.models",
exceptions_path="app.modules.cms.exceptions",
# Module templates (namespaced as cms/admin/*.html and cms/vendor/*.html)
templates_path="templates",
# Module-specific translations (accessible via cms.* keys)
locales_path="locales",
)
def get_cms_module_with_routers() -> ModuleDefinition:
"""
Get CMS module with routers attached.
This function attaches the routers lazily to avoid circular imports
during module initialization.
"""
cms_module.admin_router = _get_admin_router()
cms_module.vendor_router = _get_vendor_router()
return cms_module
__all__ = ["cms_module", "get_cms_module_with_routers"]