using StabilityMatrix.Core.Models.FileInterfaces;
using StabilityMatrix.Core.Models.Progress;
namespace StabilityMatrix.Core.Models.Packages.Extensions;
///
/// Interface for a package extension manager.
///
public interface IPackageExtensionManager
{
///
/// Default manifests for this extension manager.
///
IEnumerable DefaultManifests { get; }
///
/// Get manifests given an installed package.
/// By default returns .
///
IEnumerable GetManifests(InstalledPackage installedPackage)
{
return DefaultManifests;
}
///
/// Get extensions from the provided manifest.
///
Task> GetManifestExtensionsAsync(
ExtensionManifest manifest,
CancellationToken cancellationToken = default
);
///
/// Get extensions from all provided manifests.
///
async Task> GetManifestExtensionsAsync(
IEnumerable manifests,
CancellationToken cancellationToken = default
)
{
var extensions = Enumerable.Empty();
foreach (var manifest in manifests)
{
cancellationToken.ThrowIfCancellationRequested();
extensions = extensions.Concat(
await GetManifestExtensionsAsync(manifest, cancellationToken).ConfigureAwait(false)
);
}
return extensions;
}
///
/// Get all installed extensions for the provided package.
///
Task> GetInstalledExtensionsAsync(
InstalledPackage installedPackage,
CancellationToken cancellationToken = default
);
///
/// Install an extension to the provided package.
///
Task InstallExtensionAsync(
PackageExtension extension,
InstalledPackage installedPackage,
PackageExtensionVersion? version = null,
IProgress? progress = null,
CancellationToken cancellationToken = default
);
///
/// Update an installed extension to the provided version.
/// If no version is provided, the latest version will be used.
///
Task UpdateExtensionAsync(
InstalledPackageExtension installedExtension,
InstalledPackage installedPackage,
PackageExtensionVersion? version = null,
IProgress? progress = null,
CancellationToken cancellationToken = default
);
///
/// Uninstall an installed extension.
///
Task UninstallExtensionAsync(
InstalledPackageExtension installedExtension,
InstalledPackage installedPackage,
IProgress? progress = null,
CancellationToken cancellationToken = default
);
}