using ColaFlow.Modules.Mcp.Application.DTOs;
using ColaFlow.Modules.Mcp.Domain.ValueObjects;

namespace ColaFlow.Modules.Mcp.Application.Services;

/// <summary>
/// Service interface for PendingChange management
/// </summary>
public interface IPendingChangeService
{
    /// <summary>
    /// Create a new PendingChange
    /// </summary>
    Task<PendingChangeDto> CreateAsync(
        CreatePendingChangeRequest request,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Get a PendingChange by ID
    /// </summary>
    Task<PendingChangeDto?> GetByIdAsync(
        Guid id,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Get list of PendingChanges with filtering and pagination
    /// </summary>
    Task<(List<PendingChangeDto> Items, int TotalCount)> GetPendingChangesAsync(
        PendingChangeFilterDto filter,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Approve a PendingChange (triggers execution)
    /// </summary>
    Task ApproveAsync(
        Guid pendingChangeId,
        Guid approvedBy,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Reject a PendingChange
    /// </summary>
    Task RejectAsync(
        Guid pendingChangeId,
        Guid rejectedBy,
        string reason,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Mark a PendingChange as applied (called after successful execution)
    /// </summary>
    Task MarkAsAppliedAsync(
        Guid pendingChangeId,
        string result,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// Expire old PendingChanges (called by background job)
    /// </summary>
    Task<int> ExpireOldChangesAsync(CancellationToken cancellationToken = default);

    /// <summary>
    /// Delete a PendingChange (only allowed for Expired status)
    /// </summary>
    Task DeleteAsync(
        Guid pendingChangeId,
        CancellationToken cancellationToken = default);
}
