from src.domain.connectors.catalog._base import (
    ConnectorActionDef,
    ConnectorChangelogEntry,
    ConnectorDef,
    ConnectorFieldDef,
)


CONNECTOR = ConnectorDef(
    key="slack",
    name="Slack",
    category="communication",
    auth_type="api_key",
    version="01.00.00",
    icon="slack",
    image_url=None,  # set to your CDN URL
    description="Post messages to Slack channels from the app.",
    docs_url="https://api.slack.com/authentication/basics",
    config_fields=("default_channel_id",),
    secret_fields=("bot_token",),
    config_field_defs=(
        ConnectorFieldDef(
            key="default_channel_id",
            label="Default channel ID",
            description="Channel to post to when an action doesn't specify one, e.g. C0123456789.",
        ),
    ),
    secret_field_defs=(
        ConnectorFieldDef(
            key="bot_token",
            label="Bot User OAuth Token",
            description="Bot token from OAuth & Permissions. Starts with xoxb-. Checked on save.",
            placeholder="xoxb-...",
            required=True,
            input_type="password",
        ),
    ),
    actions=(
        ConnectorActionDef(
            key="post_message",
            slug="slack.post_message",
            name="Post message",
            description="Post a message to a Slack channel via chat.postMessage.",
            input_schema={
                "type": "object",
                "properties": {
                    "channel": {"type": "string"},
                    "text": {"type": "string"},
                    "blocks": {"type": "array"},
                    "thread_ts": {"type": "string"},
                },
                "required": ["text"],
                "additionalProperties": False,
            },
            required_capabilities=("integrations.execute",),
            implements=("messaging.send",),
        ),
    ),
    changelog=(
        ConnectorChangelogEntry(
            version="01.00.00",
            date="2026-09-06",
            notes="Initial release, migrated from the legacy provider registry. post_message action, message_received trigger.",
        ),
    ),
)
