using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using StardewModdingAPI.Toolkit.Framework.UpdateData; namespace StardewModdingAPI.Web.Framework { /// Generic metadata about a mod page. internal interface IModPage { /********* ** Accessors *********/ /// The mod site containing the mod. ModSiteKey Site { get; } /// The mod's unique ID within the site. string Id { get; } /// The mod name. string? Name { get; } /// The mod's semantic version number. string? Version { get; } /// The mod's web URL. string? Url { get; } /// The mod downloads. IModDownload[] Downloads { get; } /// The mod page status. RemoteModStatus Status { get; } /// A user-friendly error which indicates why fetching the mod info failed (if applicable). string? Error { get; } /// Whether the mod data is valid. [MemberNotNullWhen(true, nameof(IModPage.Name), nameof(IModPage.Url))] [MemberNotNullWhen(false, nameof(IModPage.Error))] bool IsValid { get; } /// Whether this mod page requires update subkeys and does not allow matching downloads without them. bool RequireSubkey { get; } /********* ** Methods *********/ /// Get the mod name for an update subkey, if different from the mod page name. /// The update subkey. string? GetName(string? subkey); /// Get the mod page URL for an update subkey, if different from the mod page it was fetched from. /// The update subkey. string? GetUrl(string? subkey); /// Set the fetched mod info. /// The mod name. /// The mod's semantic version number. /// The mod's web URL. /// The mod downloads. IModPage SetInfo(string name, string? version, string url, IEnumerable downloads); /// Set a mod fetch error. /// The mod availability status on the remote site. /// A user-friendly error which indicates why fetching the mod info failed (if applicable). IModPage SetError(RemoteModStatus status, string error); } }