using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;

namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services;

/// <summary>
/// Read-only CentralUI facade over the template-inheritance resolve query.
/// Dispatches the <see cref="GetResolvedTemplateMembersCommand"/> to
/// the central <c>ManagementActor</c> through the in-process
/// <c>ManagementActorHolder</c> seam — the SAME Ask path the HTTP
/// <c>/management</c> endpoint uses — and returns the freshly-resolved
/// <see cref="ResolvedTemplateMembers"/> (the full transitively-inherited member
/// set + staleness summary) so the template editor can render the effective
/// inherited view and a base-changed banner.
/// </summary>
/// <remarks>
/// This is a pure authoring-preview read: it never mutates stored rows and is
/// not on the deploy path. A read failure (transport fault, actor not started)
/// yields <c>null</c> (logged) so the editor degrades to its stored-row view
/// rather than throwing. Mirrors <see cref="ISchemaLibraryService"/>'s read
/// path / the other <c>ManagementActorHolder</c>-backed query facades.
/// </remarks>
public interface ITemplateInheritanceQueryService
{
    /// <summary>
    /// Resolves the effective inherited member set for a template.
    /// </summary>
    /// <param name="templateId">The template to resolve.</param>
    /// <param name="cancellationToken">Cancellation token.</param>
    /// <returns>
    /// The freshly-resolved <see cref="ResolvedTemplateMembers"/>, or <c>null</c>
    /// when the read failed (the editor then falls back to its stored-row view).
    /// </returns>
    Task<ResolvedTemplateMembers?> ResolveAsync(
        int templateId, CancellationToken cancellationToken = default);
}
