using ScadaLink.Commons.Types;
using ScadaLink.Commons.Types.Flattening;

namespace ScadaLink.DeploymentManager;

/// <summary>
/// Abstraction over the TemplateEngine flattening + validation + hashing pipeline.
/// Used by DeploymentService to obtain a validated, hashed FlattenedConfiguration.
/// </summary>
public interface IFlatteningPipeline
{
    /// <summary>
    /// Flattens and validates an instance configuration, returning the configuration,
    /// revision hash, and validation result.
    /// </summary>
    Task<Result<FlatteningPipelineResult>> FlattenAndValidateAsync(
        int instanceId,
        CancellationToken cancellationToken = default);
}

/// <summary>
/// Result of the flattening pipeline: configuration, hash, and validation.
/// </summary>
public record FlatteningPipelineResult(
    FlattenedConfiguration Configuration,
    string RevisionHash,
    ValidationResult Validation);
