"""Commercial Runtime — open registry kind catalog.

Kinds are data-driven. Built-ins seed the meta-registry; future kinds
require only DB rows (zero code change for CRUD via /registries/{kind}).
"""
from __future__ import annotations

from dataclasses import dataclass


@dataclass(frozen=True)
class RegistryKindSpec:
    kind: str
    path: str
    display_name: str
    description: str
    code_field: str
    list_envelope: str
    public_read: bool = True


# Built-in aliases matching Commercial FE adapters + open expansion.
BUILTIN_REGISTRY_KINDS: tuple[RegistryKindSpec, ...] = (
    RegistryKindSpec("products", "products", "Products", "Platform product registry", "product_code", "products"),
    RegistryKindSpec("bundles", "bundles", "Bundles", "Business bundle registry", "bundle_code", "bundles"),
    RegistryKindSpec("pricing", "pricing", "Pricing", "Pricing catalog items", "pricing_item_code", "items"),
    RegistryKindSpec("plans", "plans", "Plans", "Subscription plans", "plan_code", "plans"),
    RegistryKindSpec("trials", "trials", "Trials", "Trial rule definitions", "trial_code", "trials"),
    RegistryKindSpec("capabilities", "capabilities", "Capabilities", "Capability registry", "capability_code", "capabilities"),
    RegistryKindSpec("policies", "policies", "Policies", "Policy definitions", "policy_code", "policies"),
    RegistryKindSpec("assets", "assets", "Assets", "Asset registry", "asset_code", "assets"),
    RegistryKindSpec("extensions", "extensions", "Extensions", "Extension registry", "extension_code", "extensions"),
    RegistryKindSpec("automation_packs", "automation-packs", "Automation Packs", "Automation catalog packs", "automation_pack_code", "items"),
    RegistryKindSpec("metadata", "metadata", "Metadata", "Metadata key registry", "metadata_key", "items"),
    RegistryKindSpec("recommendation_rules", "recommendation-rules", "Recommendation Rules", "Rule-based recommendation definitions", "rule_id", "rules"),
    RegistryKindSpec("assessment_schemas", "assessment-schemas", "Assessment Schemas", "Configurable assessment schemas", "schema_code", "schemas"),
    RegistryKindSpec("notifications", "notifications", "Notifications", "Notification templates / feed defs", "notification_code", "items"),
    RegistryKindSpec("usage_plans", "usage-plans", "Usage Plans", "Usage / quota plan definitions", "usage_plan_code", "items"),
    RegistryKindSpec("coupons", "coupons", "Coupons", "Coupon definitions", "coupon_code", "items"),
    RegistryKindSpec("promotions", "promotions", "Promotions", "Promotion definitions", "promotion_code", "items"),
    RegistryKindSpec("taxes", "taxes", "Taxes", "Tax class definitions", "tax_code", "items"),
    RegistryKindSpec("currencies", "currencies", "Currencies", "Currency catalog", "currency_code", "items"),
    RegistryKindSpec("regions", "regions", "Regions", "Region catalog", "region_code", "items"),
    RegistryKindSpec("industries", "industries", "Industries", "Industry catalog", "industry_code", "items"),
    RegistryKindSpec("business_types", "business-types", "Business Types", "Business type catalog", "business_type_code", "items"),
    RegistryKindSpec("announcements", "announcements", "Announcements", "Commercial announcements", "announcement_code", "items"),
    RegistryKindSpec("languages", "languages", "Languages", "Language catalog", "language_code", "items"),
)

KIND_BY_PATH = {s.path: s for s in BUILTIN_REGISTRY_KINDS}
KIND_BY_KIND = {s.kind: s for s in BUILTIN_REGISTRY_KINDS}

OBJECT_STATUSES = ("draft", "published", "archived", "deleted")
VISIBILITIES = ("public", "authenticated", "admin", "hidden")
