namespace ColaFlow.Modules.Mcp.Contracts.Tools;

/// <summary>
/// JSON Schema for tool input parameters
/// </summary>
public sealed class McpToolInputSchema
{
    /// <summary>
    /// Schema type (always "object" for tool inputs)
    /// </summary>
    public string Type { get; set; } = "object";

    /// <summary>
    /// Schema properties (parameter definitions)
    /// Key is parameter name, value is parameter schema
    /// </summary>
    public Dictionary<string, JsonSchemaProperty> Properties { get; set; } = new();

    /// <summary>
    /// List of required parameter names
    /// </summary>
    public List<string> Required { get; set; } = new();
}

/// <summary>
/// JSON Schema property definition
/// </summary>
public sealed class JsonSchemaProperty
{
    /// <summary>
    /// Property type: "string", "number", "integer", "boolean", "array", "object"
    /// </summary>
    public string Type { get; set; } = "string";

    /// <summary>
    /// Property description (for AI to understand)
    /// </summary>
    public string? Description { get; set; }

    /// <summary>
    /// Enum values (for restricted choices)
    /// </summary>
    public string[]? Enum { get; set; }

    /// <summary>
    /// String format hint: "uuid", "email", "date-time", "uri", etc.
    /// </summary>
    public string? Format { get; set; }

    /// <summary>
    /// Minimum value (for numbers)
    /// </summary>
    public decimal? Minimum { get; set; }

    /// <summary>
    /// Maximum value (for numbers)
    /// </summary>
    public decimal? Maximum { get; set; }

    /// <summary>
    /// Minimum length (for strings)
    /// </summary>
    public int? MinLength { get; set; }

    /// <summary>
    /// Maximum length (for strings)
    /// </summary>
    public int? MaxLength { get; set; }

    /// <summary>
    /// Pattern (regex) for string validation
    /// </summary>
    public string? Pattern { get; set; }

    /// <summary>
    /// Items schema (for arrays)
    /// </summary>
    public JsonSchemaProperty? Items { get; set; }

    /// <summary>
    /// Properties schema (for nested objects)
    /// </summary>
    public Dictionary<string, JsonSchemaProperty>? Properties { get; set; }

    /// <summary>
    /// Default value
    /// </summary>
    public object? Default { get; set; }
}
