namespace ZB.MOM.WW.ScadaBridge.Commons.Types.Templates;

/// <summary>
/// Row-shaped projection of a template for list surfaces (CLI <c>template list</c>,
/// the Central UI template tree, the <c>ListTemplates</c> management command).
///
/// <para>
/// Exists so a template listing can be paged in the DATABASE rather than by
/// materialising every template's full child graph — attributes, alarms, script
/// bodies, compositions and native alarm sources — and then discarding all but
/// one page of it in memory. Child collections are reduced to counts, which is
/// what every list surface actually renders.
/// </para>
///
/// <para>
/// Message-contract evolution rule: this record is additive-only. New fields go
/// on the end with a default so an older peer deserialising a newer payload is
/// unaffected.
/// </para>
/// </summary>
/// <param name="Id">Template id.</param>
/// <param name="Name">Template name.</param>
/// <param name="Description">Optional description.</param>
/// <param name="ParentTemplateId">Parent template id when this template inherits.</param>
/// <param name="FolderId">Containing folder id.</param>
/// <param name="IsDerived">True when the template was auto-derived to back a composition slot.</param>
/// <param name="OwnerCompositionId">Owning composition row for a derived template.</param>
/// <param name="AttributeCount">Number of directly declared attributes.</param>
/// <param name="AlarmCount">Number of directly declared alarms.</param>
/// <param name="ScriptCount">Number of directly declared scripts.</param>
/// <param name="CompositionCount">Number of composition slots.</param>
/// <param name="NativeAlarmSourceCount">Number of native alarm source bindings.</param>
public record TemplateSummary(
    int Id,
    string Name,
    string? Description,
    int? ParentTemplateId,
    int? FolderId,
    bool IsDerived,
    int? OwnerCompositionId,
    int AttributeCount,
    int AlarmCount,
    int ScriptCount,
    int CompositionCount,
    int NativeAlarmSourceCount)
{
    /// <summary>
    /// Hard ceiling applied to a requested page size, mirroring the existing
    /// in-memory <c>Page</c> clamp in the management actor so DB-side paging
    /// cannot be used to pull an unbounded result set.
    /// </summary>
    public const int MaxPageSize = 1000;
}
