"""Sample tool definitions for testing."""

from dataclasses import dataclass, field


@dataclass
class MockTool:
    name: str
    description: str | None = None
    inputSchema: dict | None = None


SIMPLE_TOOL = MockTool(
    name="get_time",
    description="Get the current time",
    inputSchema={
        "type": "object",
        "properties": {
            "timezone": {"type": "string", "description": "IANA timezone"}
        },
        "required": [],
    },
)

MEDIUM_TOOL = MockTool(
    name="search_files",
    description="Search for files matching a pattern in a directory. Supports glob patterns and recursive search through subdirectories.",
    inputSchema={
        "type": "object",
        "properties": {
            "pattern": {"type": "string", "description": "Glob pattern to match files"},
            "directory": {"type": "string", "description": "Root directory to search from"},
            "recursive": {"type": "boolean", "description": "Whether to search subdirectories"},
            "max_results": {"type": "integer", "description": "Maximum number of results to return"},
            "include_hidden": {"type": "boolean", "description": "Whether to include hidden files"},
        },
        "required": ["pattern"],
    },
)

BLOATED_TOOL = MockTool(
    name="execute_complex_query",
    description=(
        "Execute a complex database query against the configured data source. "
        "This tool supports multiple query languages including SQL, GraphQL, and a custom DSL. "
        "It can handle joins across multiple tables, subqueries, aggregations, window functions, "
        "and common table expressions. Results are returned in a configurable format with optional "
        "pagination, sorting, and filtering. The tool automatically handles connection pooling, "
        "retry logic, and timeout management. It supports both synchronous and asynchronous "
        "execution modes. When using the async mode, a callback URL can be provided to receive "
        "results when the query completes. The tool also supports query plan analysis, "
        "performance profiling, and result caching with configurable TTL. "
        "For advanced usage, you can specify isolation levels for transactions, configure "
        "read replicas for load balancing, enable query result streaming for large datasets, "
        "set up automatic retry policies with exponential backoff, and configure detailed "
        "audit logging for compliance purposes. The tool integrates with distributed tracing "
        "systems via OpenTelemetry and supports custom middleware hooks for request/response "
        "transformation. Query results can be automatically serialized to various formats "
        "including JSON, CSV, Parquet, and Arrow IPC. The tool also supports prepared "
        "statements with parameter binding to prevent SQL injection attacks."
    ),
    inputSchema={
        "type": "object",
        "properties": {
            "query": {"type": "string", "description": "The query string to execute against the database engine"},
            "language": {"type": "string", "enum": ["sql", "graphql", "dsl", "cypher", "sparql"], "description": "Query language to use for parsing and execution"},
            "database": {"type": "string", "description": "Target database name or connection identifier"},
            "schema": {"type": "string", "description": "Database schema to set as the default search path"},
            "timeout": {"type": "integer", "description": "Query timeout in milliseconds, after which the query will be cancelled"},
            "max_rows": {"type": "integer", "description": "Maximum number of rows to return in the result set"},
            "offset": {"type": "integer", "description": "Number of rows to skip for pagination support"},
            "format": {"type": "string", "enum": ["json", "csv", "table", "parquet", "arrow"], "description": "Output serialization format for the query results"},
            "async_mode": {"type": "boolean", "description": "Whether to run the query asynchronously and return a job ID"},
            "callback_url": {"type": "string", "description": "Webhook URL to POST results to when async query completes"},
            "cache_ttl": {"type": "integer", "description": "Time-to-live in seconds for caching the query results"},
            "explain": {"type": "boolean", "description": "Return the query execution plan instead of results"},
            "profile": {"type": "boolean", "description": "Enable detailed performance profiling and timing information"},
            "isolation_level": {"type": "string", "enum": ["read_uncommitted", "read_committed", "repeatable_read", "serializable"], "description": "Transaction isolation level"},
            "read_replica": {"type": "boolean", "description": "Route query to a read replica for load balancing"},
            "streaming": {"type": "boolean", "description": "Enable result streaming for large datasets"},
            "retry_policy": {
                "type": "object",
                "description": "Configuration for automatic query retry on transient failures",
                "properties": {
                    "max_retries": {"type": "integer", "description": "Maximum number of retry attempts"},
                    "backoff_factor": {"type": "number", "description": "Exponential backoff multiplier"},
                    "retry_on": {"type": "array", "items": {"type": "string"}, "description": "List of error codes to retry on"},
                },
            },
            "audit": {
                "type": "object",
                "description": "Audit logging configuration for compliance tracking",
                "properties": {
                    "enabled": {"type": "boolean", "description": "Whether to enable audit logging"},
                    "user_id": {"type": "string", "description": "User identifier for the audit trail"},
                    "reason": {"type": "string", "description": "Business justification for the query"},
                    "classification": {"type": "string", "enum": ["public", "internal", "confidential", "restricted"], "description": "Data classification level"},
                },
            },
            "parameters": {
                "type": "object",
                "description": "Query parameters for prepared statement binding",
                "properties": {
                    "bindings": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "name": {"type": "string", "description": "Parameter name as referenced in the query"},
                                "value": {"type": "string", "description": "Parameter value to bind"},
                                "type": {"type": "string", "description": "Data type for proper casting"},
                            },
                        },
                    },
                },
            },
            "tracing": {
                "type": "object",
                "description": "Distributed tracing configuration via OpenTelemetry",
                "properties": {
                    "trace_id": {"type": "string", "description": "Parent trace identifier"},
                    "span_name": {"type": "string", "description": "Name for the query span"},
                    "attributes": {"type": "object", "description": "Additional span attributes"},
                },
            },
        },
        "required": ["query", "language"],
    },
)

MINIMAL_TOOL = MockTool(
    name="ping",
    description="Ping",
    inputSchema={"type": "object", "properties": {}},
)

DEEPLY_NESTED_TOOL = MockTool(
    name="nested_tool",
    description="A tool with deeply nested schema",
    inputSchema={
        "type": "object",
        "properties": {
            "level1": {
                "type": "object",
                "properties": {
                    "level2": {
                        "type": "object",
                        "properties": {
                            "level3": {
                                "type": "object",
                                "properties": {
                                    "level4": {
                                        "type": "object",
                                        "properties": {
                                            "value": {"type": "string"}
                                        },
                                    }
                                },
                            }
                        },
                    }
                },
            }
        },
    },
)

ALL_TOOLS = [SIMPLE_TOOL, MEDIUM_TOOL, BLOATED_TOOL, MINIMAL_TOOL, DEEPLY_NESTED_TOOL]
