refactor: remove all backward compatibility code across 70 files
Some checks failed
CI / ruff (push) Successful in 11s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has started running

Clean up 28 backward compatibility instances identified in the codebase.
The app is not live, so all shims are replaced with the target architecture:

- Remove legacy Inventory.location column (use bin_location exclusively)
- Remove dashboard _extract_metric_value helper (use flat metrics dict)
- Remove legacy stat field duplicates (total_stores, total_imports, etc.)
- Remove 13 re-export shims and class aliases across modules
- Remove module-enabling JSON fallback (use PlatformModule junction table)
- Remove menu_to_legacy_format() conversion (return dataclasses directly)
- Remove title/description from MarketplaceProductBase schema
- Clean billing convenience method docstrings
- Clean test fixtures and backward-compat comments
- Add PlatformModule seeding to init_production.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 13:20:29 +01:00
parent b0db8133a0
commit aad18c27ab
70 changed files with 501 additions and 841 deletions

View File

@@ -6,10 +6,10 @@ Single source of truth for detecting which frontend type a request targets.
Handles both development (path-based) and production (domain-based) routing.
Detection priority:
1. Admin subdomain (admin.oms.lu)
1. Admin subdomain (admin.omsflow.lu)
2. Path-based admin/store (/admin/*, /store/*, /api/v1/admin/*)
3. Custom domain lookup (mybakery.lu -> STOREFRONT)
4. Store subdomain (orion.oms.lu -> STOREFRONT)
4. Store subdomain (orion.omsflow.lu -> STOREFRONT)
5. Storefront paths (/storefront/*, /api/v1/storefront/*)
6. Default to PLATFORM (marketing pages)
@@ -62,7 +62,7 @@ class FrontendDetector:
Detect frontend type from request.
Args:
host: Request host header (e.g., "oms.lu", "orion.oms.lu", "localhost:8000")
host: Request host header (e.g., "omsflow.lu", "orion.omsflow.lu", "localhost:8000")
path: Request path (e.g., "/admin/stores", "/storefront/products")
has_store_context: True if request.state.store is set (from middleware)
@@ -82,7 +82,7 @@ class FrontendDetector:
},
)
# 1. Admin subdomain (admin.oms.lu)
# 1. Admin subdomain (admin.omsflow.lu)
if subdomain == "admin":
logger.debug("[FRONTEND_DETECTOR] Detected ADMIN from subdomain")
return FrontendType.ADMIN
@@ -110,7 +110,7 @@ class FrontendDetector:
logger.debug("[FRONTEND_DETECTOR] Detected PLATFORM from path")
return FrontendType.PLATFORM
# 3. Store subdomain detection (orion.oms.lu)
# 3. Store subdomain detection (orion.omsflow.lu)
# If subdomain exists and is not reserved -> it's a store storefront
if subdomain and subdomain not in cls.RESERVED_SUBDOMAINS:
logger.debug(
@@ -138,7 +138,7 @@ class FrontendDetector:
@classmethod
def _get_subdomain(cls, host: str) -> str | None:
"""
Extract subdomain from host (e.g., 'orion' from 'orion.oms.lu').
Extract subdomain from host (e.g., 'orion' from 'orion.omsflow.lu').
Returns None for localhost, IP addresses, or root domains.
Handles special case of admin.localhost for development.
@@ -195,13 +195,3 @@ class FrontendDetector:
def is_api_request(cls, path: str) -> bool:
"""Check if request is for API endpoints (any frontend's API)."""
return path.startswith("/api/")
# Convenience function for backwards compatibility
def get_frontend_type(host: str, path: str, has_store_context: bool = False) -> FrontendType:
"""
Convenience function to detect frontend type.
Wrapper around FrontendDetector.detect() for simpler imports.
"""
return FrontendDetector.detect(host, path, has_store_context)