from simorgh.apps.modules.registry import CapabilitySpec, FeatureSpec, ModuleManifest, ServiceContract, register_module

register_module(
    ModuleManifest(
        name="platform_core",
        version=1,
        domain="platform",
        label_key="platform_core.module_label",
        description="Platform Core — shared infrastructure, base models, attachments, comments, "
        "activity feed, custom fields, tags, notes, forms, print engine, document templates, "
        "export layouts, and utility services",
        events=(
            "core.attachment_added",
            "core.attachment_removed",
            "core.comment_added",
            "core.comment_updated",
            "core.comment_deleted",
            "core.activity_recorded",
            "core.custom_field_defined",
            "core.custom_field_value_changed",
            "core.tag_created",
            "core.tag_deleted",
            "core.tags_added",
            "core.tags_removed",
            "core.tags_set",
            "core.note_created",
            "core.note_edited",
            "core.note_deleted",
            "core.mention_created",
            "core.reference_number_generated",
            "core.reference_sequence_created",
            "core.form_definition_created",
            "core.form_definition_updated",
            "core.form_definition_deleted",
            "core.form_submitted",
            "core.import_job_created",
            "core.import_job_completed",
            "core.import_job_failed",
            "core.export_job_created",
            "core.export_job_completed",
            "core.export_job_failed",
            "core.print_template_created",
            "core.print_template_updated",
            "core.print_template_deleted",
            "core.document_template_created",
            "core.document_template_updated",
            "core.document_template_deleted",
            "core.export_layout_created",
            "core.export_layout_updated",
            "core.export_layout_deleted",
        ),
        contracts=(
            ServiceContract(
                name="platform_core.print.render_pdf",
                provider="simorgh.apps.platform_core.services:render_pdf",
                description="Render a PrintTemplate with entity context to PDF bytes.",
            ),
            ServiceContract(
                name="platform_core.print.render_html_preview",
                provider="simorgh.apps.platform_core.services:render_html_preview",
                description="Render a PrintTemplate with entity context to an HTML preview string.",
            ),
            ServiceContract(
                name="platform_core.document.render_document",
                provider="simorgh.apps.platform_core.services:render_document",
                description="Render a DocumentTemplate with context to an HTML string.",
            ),
            ServiceContract(
                name="platform_core.document.render_document_pdf",
                provider="simorgh.apps.platform_core.services:render_document_pdf",
                description="Render a DocumentTemplate with context to PDF bytes.",
            ),
        ),
        capabilities=(
            CapabilitySpec(slug="core", label_key="platform_core.capabilities.core",
                          description="Core infrastructure and base models", icon="cpu"),
            CapabilitySpec(slug="files", label_key="platform_core.capabilities.files",
                          description="File attachments and storage abstraction", icon="paperclip"),
            CapabilitySpec(slug="collaboration", label_key="platform_core.capabilities.collaboration",
                          description="Comments, activity feed, tags, and notes", icon="message-square"),
            CapabilitySpec(slug="search", label_key="platform_core.capabilities.search",
                          description="Global search across all registered entities", icon="search"),
            CapabilitySpec(slug="forms", label_key="platform_core.capabilities.forms",
                          description="Dynamic forms and custom fields", icon="layout"),
            CapabilitySpec(slug="io", label_key="platform_core.capabilities.io",
                          description="Import, export, and data pipelines", icon="download"),
            CapabilitySpec(slug="print", label_key="platform_core.capabilities.print",
                          description="HTML-to-PDF print engine", icon="printer"),
            CapabilitySpec(slug="templates", label_key="platform_core.capabilities.templates",
                          description="Message and document templates", icon="file-text"),
        ),
        features=(
            FeatureSpec(code="core.base_models", label_key="platform_core.features.base_models", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Shared base models: UUIDModel, TenantScopedModel, SoftDeleteModel, TimeStampedModel"),
            FeatureSpec(code="core.scoped_queries", label_key="platform_core.features.scoped_queries", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Permission-aware scoped query engine for all tenants"),
            FeatureSpec(code="search.global_search", label_key="platform_core.features.global_search", scope="tenant", default_enabled=True, is_platform_internal=False, description="Unified global search across all registered entities"),
            FeatureSpec(code="files.attachments", label_key="platform_core.features.attachments", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="File attachments on any entity with StorageService abstraction"),
            FeatureSpec(code="collaboration.comments", label_key="platform_core.features.comments", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Threaded comments with @mentions on any entity"),
            FeatureSpec(code="collaboration.activity_feed", label_key="platform_core.features.activity_feed", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Append-only activity feed for entities"),
            FeatureSpec(code="forms.custom_fields", label_key="platform_core.features.custom_fields", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Dynamic custom field definitions and values on entities"),
            FeatureSpec(code="collaboration.tags", label_key="platform_core.features.tags", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Polymorphic tags on any entity"),
            FeatureSpec(code="collaboration.notes", label_key="platform_core.features.notes", scope="tenant", default_enabled=True, is_always_on=True, is_platform_internal=True, description="Private/team/workspace notes on any entity"),
            FeatureSpec(code="forms.dynamic_forms", label_key="platform_core.features.dynamic_forms", scope="tenant", default_enabled=True, is_platform_internal=True, description="Schema-driven dynamic form builder with webhook/callback submissions"),
            FeatureSpec(code="core.reference_numbers", label_key="platform_core.features.reference_numbers", scope="tenant", default_enabled=True, is_platform_internal=True, description="Atomic reference number sequences per entity type"),
            FeatureSpec(code="io.import_engine", label_key="platform_core.features.import_engine", scope="tenant", default_enabled=True, is_platform_internal=True, description="CSV/Excel bulk import engine with validation and error reporting"),
            FeatureSpec(code="io.export_engine", label_key="platform_core.features.export_engine", scope="tenant", default_enabled=True, is_platform_internal=True, description="CSV/Excel/JSON bulk export engine"),
            FeatureSpec(code="print.print_engine", label_key="platform_core.features.print_engine", scope="tenant", default_enabled=True, is_platform_internal=True, description="HTML-to-PDF print engine with Jinja2 templates"),
            FeatureSpec(code="templates.message_templates", label_key="platform_core.features.message_templates", scope="tenant", default_enabled=True, is_platform_internal=True, description="Multi-channel message templates for notifications"),
            FeatureSpec(code="templates.document_templates", label_key="platform_core.features.document_templates", scope="tenant", default_enabled=True, is_platform_internal=True, description="Reusable document templates with sections for PDF generation"),
            FeatureSpec(code="io.export_layouts", label_key="platform_core.features.export_layouts", scope="tenant", default_enabled=True, is_platform_internal=True, description="Export layout configurations for formatted CSV/Excel/PDF exports"),
        ),
    )
)
