Adds metadata and artwork provider configuration seeding

Seeds a disabled provider configuration for every loaded plugin supporting
a library type, so that libraries list the metadata and artwork providers
they can use. Configurations are seeded on startup, on library creation,
and reconciled when the library type changes, and are removed only when a
library or a plugin is deleted. Reads the library metadata providers
through the new provider configuration store.
This commit is contained in:
BinaryAlley committed 2026-08-26 19:14:35 +03:00
1 parent 9ae8c0c394
commit 00dcf3d471
20 files changed
+1139 -27

No files matched your search

@@ -39,4 +39,30 @@ public interface IArtworkProviderConfigurationRepository : IRepository<LibraryAr
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> UpsertAsync(LibraryArtworkProviderConfigurationEntity configuration, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the artwork provider configurations of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose artwork provider configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the artwork provider configurations referencing the plugin identified by <paramref name="pluginId"/>.
/// </summary>
/// <param name="pluginId">The Id of the plugin whose artwork provider configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByPluginIdAsync(Guid pluginId, CancellationToken cancellationToken);
/// <summary>
/// Deletes the artwork provider configurations of the media library identified by <paramref name="libraryId"/> that reference
/// one of the plugins identified by <paramref name="pluginIds"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose artwork provider configurations are deleted.</param>
/// <param name="pluginIds">The Ids of the plugins whose configurations of the media library are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByLibraryIdAndPluginIdsAsync(Guid libraryId, IEnumerable<Guid> pluginIds, CancellationToken cancellationToken);
}
@@ -39,4 +39,30 @@ public interface ILibraryMetadataProviderConfigurationRepository : IRepository<L
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> UpsertAsync(LibraryMetadataProviderConfigurationEntity configuration, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the metadata provider configurations of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose metadata provider configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the metadata provider configurations referencing the plugin identified by <paramref name="pluginId"/>.
/// </summary>
/// <param name="pluginId">The Id of the plugin whose metadata provider configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByPluginIdAsync(Guid pluginId, CancellationToken cancellationToken);
/// <summary>
/// Deletes the metadata provider configurations of the media library identified by <paramref name="libraryId"/> that reference
/// one of the plugins identified by <paramref name="pluginIds"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose metadata provider configurations are deleted.</param>
/// <param name="pluginIds">The Ids of the plugins whose configurations of the media library are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> DeleteByLibraryIdAndPluginIdsAsync(Guid libraryId, IEnumerable<Guid> pluginIds, CancellationToken cancellationToken);
}
@@ -0,0 +1,61 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Plugins;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.Infrastructure.Plugins;
/// <summary>
/// Store of the metadata and artwork provider configurations of the media libraries.
/// </summary>
public interface IMediaLibraryProviderConfigurationStore
{
/// <summary>
/// Gets the metadata provider configurations of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose metadata provider configurations are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the configurations, or an error.</returns>
Task<Result<IReadOnlyList<LibraryMetadataProviderConfigurationEntity>>> GetConfigurationsAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Adds a disabled provider configuration for every loaded plugin that supports the provided library type and has no
/// configuration yet for the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose provider configurations are ensured.</param>
/// <param name="libraryType">The type of the media library, used to determine the plugins whose providers apply.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Success>> EnsureProviderConfigurationsAsync(Guid libraryId, LibraryType libraryType, CancellationToken cancellationToken);
/// <summary>
/// Replaces the provider configurations of the media library identified by <paramref name="libraryId"/> so that they
/// match the plugins supporting the provided library type.
/// </summary>
/// <param name="libraryId">The Id of the media library whose provider configurations are reconciled.</param>
/// <param name="libraryType">The type of the media library, used to determine the plugins whose providers apply.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Success>> ReconcileProviderConfigurationsAsync(Guid libraryId, LibraryType libraryType, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the provider configurations of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose provider configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> RemoveProviderConfigurationsForLibraryAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the provider configurations referencing the plugin identified by <paramref name="pluginId"/>.
/// </summary>
/// <param name="pluginId">The Id of the plugin whose provider configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> RemoveProviderConfigurationsAsync(Guid pluginId, CancellationToken cancellationToken);
}