# app/modules/marketplace/models/__init__.py
"""
Marketplace module database models.

This is the canonical location for marketplace models. Module models are automatically
discovered and registered with SQLAlchemy's Base.metadata at startup.

Usage:
    from app.modules.marketplace.models import (
        MarketplaceProduct,
        MarketplaceImportJob,
        StoreLetzshopCredentials,
        LetzshopHistoricalImportJob,
    )
"""

# Import models from other modules FIRST to resolve string-based relationship references.
# These imports are NOT re-exported, just ensure models are registered with SQLAlchemy
# before the marketplace models are loaded.
#
# Relationships being resolved:
# - LetzshopFulfillmentQueue.order -> "Order" (in orders module)
# - MarketplaceImportJob.store -> "Store" (in tenancy module)
# - MarketplaceImportJob.user -> "User" (in tenancy module)
#
# NOTE: This module owns the relationships to tenancy models (User, Store).
# Core models should NOT have back-references to optional module models.
from app.modules.marketplace.models.letzshop import (
    LetzshopFulfillmentQueue,
    # Import jobs
    LetzshopHistoricalImportJob,
    LetzshopStoreCache,
    LetzshopSyncLog,
    # Letzshop credentials and sync
    StoreLetzshopCredentials,
)
from app.modules.marketplace.models.marketplace_import_job import (
    MarketplaceImportError,
    MarketplaceImportJob,
)
from app.modules.marketplace.models.marketplace_product import (
    DigitalDeliveryMethod,
    MarketplaceProduct,
    ProductType,
)
from app.modules.marketplace.models.marketplace_product_translation import (
    MarketplaceProductTranslation,
)
from app.modules.marketplace.models.onboarding import (
    STEP_ORDER,
    OnboardingStatus,
    OnboardingStep,
    StoreOnboarding,
)
from app.modules.orders.models import Order  # noqa: F401
from app.modules.tenancy.models.store import Store  # noqa: F401
from app.modules.tenancy.models.user import User  # noqa: F401

__all__ = [
    # Marketplace products
    "MarketplaceProduct",
    "MarketplaceProductTranslation",
    "ProductType",
    "DigitalDeliveryMethod",
    # Import jobs
    "MarketplaceImportJob",
    "MarketplaceImportError",
    "LetzshopHistoricalImportJob",
    # Letzshop models
    "StoreLetzshopCredentials",
    "LetzshopFulfillmentQueue",
    "LetzshopStoreCache",
    "LetzshopSyncLog",
    # Onboarding
    "OnboardingStatus",
    "OnboardingStep",
    "STEP_ORDER",
    "StoreOnboarding",
]
