# 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,
        VendorLetzshopCredentials,
        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.vendor -> "Vendor" (in tenancy module)
# - MarketplaceImportJob.user -> "User" (in tenancy module)
#
# NOTE: This module owns the relationships to tenancy models (User, Vendor).
# Core models should NOT have back-references to optional module models.
from app.modules.orders.models import Order  # noqa: F401
from app.modules.tenancy.models.user import User  # noqa: F401
from app.modules.tenancy.models.vendor import Vendor  # noqa: F401

from app.modules.marketplace.models.marketplace_product import (
    MarketplaceProduct,
    ProductType,
    DigitalDeliveryMethod,
)
from app.modules.marketplace.models.marketplace_product_translation import (
    MarketplaceProductTranslation,
)
from app.modules.marketplace.models.marketplace_import_job import (
    MarketplaceImportJob,
    MarketplaceImportError,
)
from app.modules.marketplace.models.letzshop import (
    # Letzshop credentials and sync
    VendorLetzshopCredentials,
    LetzshopFulfillmentQueue,
    LetzshopVendorCache,
    LetzshopSyncLog,
    # Import jobs
    LetzshopHistoricalImportJob,
)
from app.modules.marketplace.models.onboarding import (
    OnboardingStatus,
    OnboardingStep,
    STEP_ORDER,
    VendorOnboarding,
)

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