#nullable enable
using System.Text.Json.Serialization;
namespace AutopilotMonitor.Shared.Models
{
///
/// Confidence level for an error-code mapping (catalog schemaVersion 2).
///
public enum ErrorCodeConfidence
{
/// Carried over from the v1 catalog without a primary source.
Low,
/// Paraphrase of an enum member name or of an analysis rule's text.
Medium,
/// Taken from an MS Learn page or from the IME build named in .
High,
}
///
/// One Windows / MSI / Intune error-code catalog entry. Mirrors the structure of
/// Resources/error-codes.json (generated by tools/error-codes/generate.mjs)
/// and the TypeScript ErrorCodeEntry in the web app.
///
public sealed class ErrorCodeEntry
{
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
[JsonPropertyName("confidence")]
public ErrorCodeConfidence Confidence { get; set; }
///
/// Provenance token: msdoc:<URL>, ime:<version>, winerror.h,
/// rule:<RULE-ID> or legacy-catalog-v1. Rendered through a formatter, never raw.
///
[JsonPropertyName("source")]
public string Source { get; set; } = string.Empty;
///
/// Family the code belongs to (msi, win32, com, appx, windows-update,
/// cbs, intune-win32, intune-mobile, mdm-enrollment, autopilot,
/// entra-join, delivery-optimization). Deliberately a string, not an enum: a value
/// outside the set must never turn the lazily cached catalog load into a permanent exception.
///
[JsonPropertyName("category")]
public string Category { get; set; } = string.Empty;
/// Symbolic name (ERROR_INSTALL_FAILURE, WU_E_ALL_UPDATES_FAILED, an IME enum member). Optional.
[JsonPropertyName("symbol")]
public string? Symbol { get; set; }
/// True for the MSI return codes the IME retries automatically during the Autopilot ESP.
[JsonPropertyName("imeRetriesDuringEsp")]
public bool ImeRetriesDuringEsp { get; set; }
}
/// One IME app enforcement state (enforcementStates map of the catalog).
public sealed class EnforcementStateEntry
{
/// Numeric state as the catalog keys it ("1000", "6001").
[JsonIgnore]
public string Value { get; set; } = string.Empty;
/// IME enum member name (Success, NotAttemptedDependencyWithFailure).
[JsonPropertyName("name")]
public string Name { get; set; } = string.Empty;
[JsonPropertyName("description")]
public string Description { get; set; } = string.Empty;
}
///
/// Result of : the entry plus the
/// catalog key it was found under and, when the input was a HRESULT_FROM_WIN32 value
/// that resolved to a decimal MSI entry, the Win32 code it was derived from.
///
public sealed class ErrorCodeLookupResult
{
public ErrorCodeLookupResult(ErrorCodeEntry entry, string key, int? derivedFromWin32)
{
Entry = entry;
Key = key;
DerivedFromWin32 = derivedFromWin32;
}
public ErrorCodeEntry Entry { get; }
/// Normalised catalog key that matched (0x80070005, 1603).
public string Key { get; }
///
/// Set when a 0x8007xxxx input had no direct entry and resolved through its low
/// 16 bits to a decimal MSI entry (0x80070643 → 1603). Data for consumers,
/// never merged into the description.
///
public int? DerivedFromWin32 { get; }
}
}