namespace ZB.MOM.WW.OtOpcUa.AdminUI.Uns;

/// <summary>
/// Outcome of a Raw-tree rename. Like <see cref="UnsMutationResult"/> it reports success/failure,
/// but a rename additionally surfaces <see cref="Warnings"/>: non-blocking advisories the UI shows
/// after the rename succeeds (a RawPath segment changed, so downstream references may need attention).
/// In this batch the warnings answerable from the schema are wired — a renamed node with historized
/// tags beneath it, or raw tags referenced by an equipment (<c>UnsTagReference</c>). Batch 3 adds the
/// script-substring scan to the same list. On failure <see cref="Ok"/> is false, <see cref="Error"/>
/// carries the operator-facing message, and <see cref="Warnings"/> is empty.
/// </summary>
/// <param name="Ok">Whether the rename was applied.</param>
/// <param name="Error">The operator-facing failure message, or <c>null</c> on success.</param>
/// <param name="Warnings">Non-blocking advisories to show after a successful rename; empty when there are none.</param>
public readonly record struct RawRenameResult(bool Ok, string? Error, IReadOnlyList<string> Warnings)
{
    /// <summary>A successful rename carrying zero or more advisory warnings.</summary>
    public static RawRenameResult Success(IReadOnlyList<string>? warnings = null) =>
        new(true, null, warnings ?? Array.Empty<string>());

    /// <summary>A failed rename carrying the operator-facing message.</summary>
    public static RawRenameResult Failure(string error) =>
        new(false, error, Array.Empty<string>());
}
