diff --git a/.gitignore b/.gitignore
index 6bfc04cc..898b006a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -65,5 +65,8 @@ $RECYCLE.BIN/
*.sql
*.sqlite
-# Agent configuration
-AGENTS.md
\ No newline at end of file
+# AI
+AGENTS.[Mm][Dd]
+agents.[Mm][Dd]
+SKILL.[Mm][Dd]
+skill.[Mm][Dd]
\ No newline at end of file
diff --git a/docs/technical/api/Api.Book.md b/docs/technical/api/Api.Book.md
index 6cef1a60..30c4ae9c 100644
--- a/docs/technical/api/Api.Book.md
+++ b/docs/technical/api/Api.Book.md
@@ -21,6 +21,8 @@ POST api/v1/books
```json
{
+ "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
+ "path": "/books/the-fellowship-of-the-ring.epub",
"metadata": {
"title": "The Fellowship of the Ring",
"originalTitle": "The Fellowship of the Ring",
@@ -122,6 +124,9 @@ POST api/v1/books
```json
{
+ "id": "32b336e8-dafc-4a08-9dec-9454e66dd55d",
+ "libraryId": "3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a",
+ "path": "/books/the-fellowship-of-the-ring.epub",
"metadata": {
"publisher": "Houghton Mifflin",
"pageCount": 398,
@@ -205,9 +210,9 @@ POST api/v1/books
"voteCount": 87654
}
],
- "id": {
- "value": "32b336e8-dafc-4a08-9dec-9454e66dd55d"
- }
+ "metadataStatus": "Pending",
+ "lastMetadataUpdateUtc": null,
+ "metadataProvider": null
}
```
@@ -216,7 +221,7 @@ POST api/v1/books
#### Get Books Request
```js
-GET /books
+GET /books?libraryId=3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a
```
#### Get Books Response
diff --git a/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md
new file mode 100644
index 00000000..ac4ef46c
--- /dev/null
+++ b/docs/technical/architecture/architecture-knowledge-management/architecture-decision-log/architecture-decision-record-0010.md
@@ -0,0 +1,47 @@
+# Architecture Decision Record (ADR): 0010 - Failure Semantics of the Best-Effort Metadata Enrichment Job
+
+## Status
+**Accepted** (2026-08-09)
+
+## Context
+ADR-0009 established that every media library scan job wraps its execution in a catch-all that marks the job as `Failed` and publishes the `LibraryScanFailedDomainEvent`. That decision applies to the mandatory scan jobs: file system discovery, scan diff, content hashing and scan results save. These jobs are transactional in nature, and a failure in any of them means the file state of the library was not committed.
+
+The metadata enrichment phase runs after the scan results save job, once the file state of the library is committed and the books are materialized. The enrichment phase is best-effort: a book whose metadata could not be retrieved is still browsable with its shell metadata (path and filename-derived title), and a crash mid-enrichment must not roll back the already committed scan results, nor hide the successfully enriched books. This was an explicit product decision: partial enrichment survives a crash, and the scan is not considered failed because a remote metadata provider was unreachable or a provider crashed.
+
+## Decision
+The metadata enrichment job (`MediaLibraryScanMetadataEnrichmentJob`) is a best-effort job with failure semantics that differ from the mandatory jobs of ADR-0009:
+
+- Per-book failures are isolated: a metadata provider that throws, returns unusable metadata, or fails to be applied marks the book as `Failed` (`MetadataStatus.Failed`) and moves to the next book. The other providers are still tried for the same book, and the other books are still processed.
+- Per-provider failures are isolated: a crashing metadata provider does not prevent the other providers from being tried, in their configured order.
+- The scan is considered completed (`LibraryScanFinishedDomainEvent`) after the enrichment phase, even when some books failed to be enriched. The failure is recorded on the books, not on the scan.
+- Only a host-side catastrophic failure of the enrichment job itself (e.g., a storage error) fails the scan, through the existing catch-all of ADR-0009. In that case the file state is already committed, and a re-scan retries the enrichment.
+
+The `MediaLibraryScanResultsSaveJob` no longer publishes `LibraryScanFinishedDomainEvent`. The event is published by the last job of the directed acyclic job graph: the save job when the library does not permit downloading data from the web (no enrichment phase), or the metadata enrichment job otherwise.
+
+## Consequences
+
+### Positive Outcomes
+| Aspect | Benefit |
+|-----------------------|-----------------------------------------------------------|
+| Partial enrichment | Books successfully enriched before a crash stay browsable and enriched |
+| Provider isolation | A crashing provider does not prevent other providers from being tried |
+| Scan completion | The scan reaches a completed state regardless of enrichment outcome |
+| Retryability | Books with `MetadataStatus.Failed` or `Pending` are re-enriched on the next scan |
+
+### Risks and Tradeoffs
+| Risk | Mitigation Strategy |
+|-------------------------------|-------------------------------------------------------------------|
+| Host failures still fail | Only host-side storage errors fail the scan; re-scan retries enrichment |
+| No per-provider audit trail | Books record the failed status; per-provider error detail is a future refinement |
+
+## Alternatives Considered
+
+### 1. Fail the scan on any enrichment failure
+Keep ADR-0009 semantics for the enrichment job.
+
+**Rejected**: The file state is already committed, and partial enrichment is better than failing a scan that saved the library. Failing the scan would also roll back nothing, while misleading the user about the scan outcome.
+
+### 2. Run enrichment outside the scan lifetime
+Enrich the books asynchronously after the scan, decoupled from the scan progress and cancellation.
+
+**Rejected**: This contradicts the decision that the metadata enrichment phase is part of the scan lifetime, covered by the scan progress reporting and cancellation machinery, so that the scan progress reaches completion only when the metadata is downloaded.
diff --git a/docs/technical/requests/books/Add.http b/docs/technical/requests/books/Add.http
index eacdfed3..73a9c33e 100644
--- a/docs/technical/requests/books/Add.http
+++ b/docs/technical/requests/books/Add.http
@@ -2,6 +2,8 @@ POST {{host}}/api/v1/books
Content-Type: application/json
{
+ "libraryId": "00000000-0000-0000-0000-000000000000",
+ "path": "/books/the-fellowship-of-the-ring.epub",
"metadata": {
"title": "The Fellowship of the Ring",
"originalTitle": "The Fellowship of the Ring",
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/DependencyInjection/OpenLibraryServices.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/DependencyInjection/OpenLibraryServices.cs
new file mode 100644
index 00000000..d102ba55
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/DependencyInjection/OpenLibraryServices.cs
@@ -0,0 +1,57 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Plugins.Contracts.Core.Metadata;
+using Lumina.Plugins.Contracts.Core.Plugins;
+using Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
+using Lumina.Plugins.OpenLibrary.Core;
+using Lumina.Plugins.OpenLibrary.Core.Api;
+using Lumina.Plugins.OpenLibrary.Core.Settings;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.DependencyInjection;
+
+///
+/// Provides extension methods for registering the Open Library metadata provider services.
+///
+internal static class OpenLibraryServices
+{
+ ///
+ /// Registers the Open Library book metadata provider and its dependencies, associated with the plugin that provides it.
+ ///
+ /// The service collection to register the services into.
+ /// The unique identifier of the plugin that provides the metadata.
+ /// Action used to configure the .
+ /// The service collection, for chaining.
+ internal static IServiceCollection AddOpenLibraryBookMetadataProvider(this IServiceCollection services, Guid pluginId, Action? settingsCallback = null)
+ {
+ ArgumentNullException.ThrowIfNull(services);
+
+ // Build the runtime settings per scope, overlaying the settings persisted by the host over the defaults and the optional callback.
+ services.TryAddScoped(serviceProvider =>
+ {
+ OpenLibrarySettingsDto openLibrarySettings = new();
+ settingsCallback?.Invoke(openLibrarySettings);
+
+ IPluginSettingsStore? settingsStore = serviceProvider.GetService();
+ if (settingsStore is not null)
+ {
+ IReadOnlyDictionary? storedSettings = settingsStore.GetSettingsAsync(pluginId, CancellationToken.None).GetAwaiter().GetResult();
+ if (storedSettings is not null)
+ OpenLibrarySettingsLoader.Apply(openLibrarySettings, storedSettings);
+ }
+
+ return openLibrarySettings;
+ });
+
+ services.AddHttpClient();
+
+ // Register the metadata provider as a keyed by pluginId transient service, so it can be resolved specifically among other IRemoteMetadataProvider implementations.
+ services.AddKeyedTransient(pluginId);
+
+ return services;
+ }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryAuthorResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryAuthorResponse.cs
new file mode 100644
index 00000000..d9c9f1a7
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryAuthorResponse.cs
@@ -0,0 +1,29 @@
+#region ========================================================================= USING =====================================================================================
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for an author from the Open Library API.
+///
+internal sealed record OpenLibraryAuthorResponse
+{
+ ///
+ /// Gets the key of the author.
+ ///
+ [JsonPropertyName("key")]
+ public string? Key { get; init; }
+
+ ///
+ /// Gets the name of the author.
+ ///
+ [JsonPropertyName("name")]
+ public string? Name { get; init; }
+
+ ///
+ /// Gets the personal name of the author.
+ ///
+ [JsonPropertyName("personal_name")]
+ public string? PersonalName { get; init; }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryEditionResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryEditionResponse.cs
new file mode 100644
index 00000000..ea5fa21a
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryEditionResponse.cs
@@ -0,0 +1,145 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for an edition from the Open Library API.
+///
+internal sealed record OpenLibraryEditionResponse
+{
+ ///
+ /// Gets the key of the edition.
+ ///
+ [JsonPropertyName("key")]
+ public string? Key { get; init; }
+
+ ///
+ /// Gets the title of the edition.
+ ///
+ [JsonPropertyName("title")]
+ public string? Title { get; init; }
+
+ ///
+ /// Gets the subtitle of the edition.
+ ///
+ [JsonPropertyName("subtitle")]
+ public string? Subtitle { get; init; }
+
+ ///
+ /// Gets the notes of the edition.
+ ///
+ [JsonPropertyName("notes")]
+ public JsonElement Notes { get; init; }
+
+ ///
+ /// Gets the publication date of the edition.
+ ///
+ [JsonPropertyName("publish_date")]
+ public string? PublishDate { get; init; }
+
+ ///
+ /// Gets the publishers of the edition.
+ ///
+ [JsonPropertyName("publishers")]
+ public List Publishers { get; init; } = [];
+
+ ///
+ /// Gets the publication places of the edition.
+ ///
+ [JsonPropertyName("publish_places")]
+ public List PublishPlaces { get; init; } = [];
+
+ ///
+ /// Gets the number of pages of the edition.
+ ///
+ [JsonPropertyName("number_of_pages")]
+ public int? NumberOfPages { get; init; }
+
+ ///
+ /// Gets the physical format of the edition.
+ ///
+ [JsonPropertyName("physical_format")]
+ public string? PhysicalFormat { get; init; }
+
+ ///
+ /// Gets the name of the edition.
+ ///
+ [JsonPropertyName("edition_name")]
+ public string? EditionName { get; init; }
+
+ ///
+ /// Gets the series the edition belongs to.
+ ///
+ [JsonPropertyName("series")]
+ public List Series { get; init; } = [];
+
+ ///
+ /// Gets the volume of the edition within its series.
+ ///
+ [JsonPropertyName("volume")]
+ public string? Volume { get; init; }
+
+ ///
+ /// Gets the ISBN-10 identifiers of the edition.
+ ///
+ [JsonPropertyName("isbn_10")]
+ public List Isbn10 { get; init; } = [];
+
+ ///
+ /// Gets the ISBN-13 identifiers of the edition.
+ ///
+ [JsonPropertyName("isbn_13")]
+ public List Isbn13 { get; init; } = [];
+
+ ///
+ /// Gets the LCCN identifiers of the edition.
+ ///
+ [JsonPropertyName("lccn")]
+ public List Lccn { get; init; } = [];
+
+ ///
+ /// Gets the OCLC numbers of the edition.
+ ///
+ [JsonPropertyName("oclc_numbers")]
+ public List OclcNumbers { get; init; } = [];
+
+ ///
+ /// Gets the external identifiers of the edition, keyed by identifier name.
+ ///
+ [JsonPropertyName("identifiers")]
+ public JsonElement Identifiers { get; init; }
+
+ ///
+ /// Gets the source records of the edition.
+ ///
+ [JsonPropertyName("source_records")]
+ public List SourceRecords { get; init; } = [];
+
+ ///
+ /// Gets the languages of the edition.
+ ///
+ [JsonPropertyName("languages")]
+ public List Languages { get; init; } = [];
+
+ ///
+ /// Gets the authors of the edition.
+ ///
+ [JsonPropertyName("authors")]
+ public List Authors { get; init; } = [];
+
+ ///
+ /// Gets the works the edition belongs to.
+ ///
+ [JsonPropertyName("works")]
+ public List Works { get; init; } = [];
+
+ ///
+ /// Gets the contributions of the edition.
+ ///
+ [JsonPropertyName("contributions")]
+ public List Contributions { get; init; } = [];
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryEditionsResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryEditionsResponse.cs
new file mode 100644
index 00000000..7178fffa
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryEditionsResponse.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for the editions of a work from the Open Library API.
+///
+internal sealed record OpenLibraryEditionsResponse
+{
+ ///
+ /// Gets the editions of the work.
+ ///
+ [JsonPropertyName("entries")]
+ public List Entries { get; init; } = [];
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryKeyReferenceResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryKeyReferenceResponse.cs
new file mode 100644
index 00000000..fc6a40f8
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryKeyReferenceResponse.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for a reference to a resource of the Open Library API by its key.
+///
+internal sealed record OpenLibraryKeyReferenceResponse
+{
+ ///
+ /// Gets the key of the referenced resource.
+ ///
+ [JsonPropertyName("key")]
+ public string? Key { get; init; }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryRatingSummaryResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryRatingSummaryResponse.cs
new file mode 100644
index 00000000..41f3bd70
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryRatingSummaryResponse.cs
@@ -0,0 +1,23 @@
+#region ========================================================================= USING =====================================================================================
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for the summary of the ratings of a work from the Open Library API.
+///
+internal sealed record OpenLibraryRatingSummaryResponse
+{
+ ///
+ /// Gets the average rating of the work.
+ ///
+ [JsonPropertyName("average")]
+ public decimal? Average { get; init; }
+
+ ///
+ /// Gets the number of ratings of the work.
+ ///
+ [JsonPropertyName("count")]
+ public int? Count { get; init; }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryRatingsResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryRatingsResponse.cs
new file mode 100644
index 00000000..76163774
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryRatingsResponse.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for the ratings of a work from the Open Library API.
+///
+internal sealed record OpenLibraryRatingsResponse
+{
+ ///
+ /// Gets the summary of the ratings of the work.
+ ///
+ [JsonPropertyName("summary")]
+ public OpenLibraryRatingSummaryResponse? Summary { get; init; }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibrarySearchDocumentResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibrarySearchDocumentResponse.cs
new file mode 100644
index 00000000..ad166095
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibrarySearchDocumentResponse.cs
@@ -0,0 +1,132 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for a search document from the Open Library API.
+///
+internal sealed record OpenLibrarySearchDocumentResponse
+{
+ ///
+ /// Gets the key of the search document.
+ ///
+ [JsonPropertyName("key")]
+ public string? Key { get; init; }
+
+ ///
+ /// Gets the title of the search document.
+ ///
+ [JsonPropertyName("title")]
+ public string? Title { get; init; }
+
+ ///
+ /// Gets the author names of the search document.
+ ///
+ [JsonPropertyName("author_name")]
+ public List AuthorNames { get; init; } = [];
+
+ ///
+ /// Gets the author keys of the search document.
+ ///
+ [JsonPropertyName("author_key")]
+ public List AuthorKeys { get; init; } = [];
+
+ ///
+ /// Gets the first publication year of the search document.
+ ///
+ [JsonPropertyName("first_publish_year")]
+ public int? FirstPublishYear { get; init; }
+
+ ///
+ /// Gets the edition keys of the search document.
+ ///
+ [JsonPropertyName("edition_key")]
+ public List EditionKeys { get; init; } = [];
+
+ ///
+ /// Gets the ISBNs of the search document.
+ ///
+ [JsonPropertyName("isbn")]
+ public List Isbns { get; init; } = [];
+
+ ///
+ /// Gets the languages of the search document.
+ ///
+ [JsonPropertyName("language")]
+ public List Languages { get; init; } = [];
+
+ ///
+ /// Gets the publishers of the search document.
+ ///
+ [JsonPropertyName("publisher")]
+ public List Publishers { get; init; } = [];
+
+ ///
+ /// Gets the subjects of the search document.
+ ///
+ [JsonPropertyName("subject")]
+ public List Subjects { get; init; } = [];
+
+ ///
+ /// Gets the publication places of the search document.
+ ///
+ [JsonPropertyName("publish_place")]
+ public List PublishPlaces { get; init; } = [];
+
+ ///
+ /// Gets the median number of pages of the search document.
+ ///
+ [JsonPropertyName("number_of_pages_median")]
+ public int? NumberOfPagesMedian { get; init; }
+
+ ///
+ /// Gets the average rating of the search document.
+ ///
+ [JsonPropertyName("ratings_average")]
+ public decimal? RatingsAverage { get; init; }
+
+ ///
+ /// Gets the number of ratings of the search document.
+ ///
+ [JsonPropertyName("ratings_count")]
+ public int? RatingsCount { get; init; }
+
+ ///
+ /// Gets the Amazon identifiers of the search document.
+ ///
+ [JsonPropertyName("id_amazon")]
+ public List AmazonIds { get; init; } = [];
+
+ ///
+ /// Gets the Goodreads identifiers of the search document.
+ ///
+ [JsonPropertyName("id_goodreads")]
+ public List GoodreadsIds { get; init; } = [];
+
+ ///
+ /// Gets the Google identifiers of the search document.
+ ///
+ [JsonPropertyName("id_google")]
+ public List GoogleIds { get; init; } = [];
+
+ ///
+ /// Gets the LibraryThing identifiers of the search document.
+ ///
+ [JsonPropertyName("id_librarything")]
+ public List LibraryThingIds { get; init; } = [];
+
+ ///
+ /// Gets the LCCN identifiers of the search document.
+ ///
+ [JsonPropertyName("lccn")]
+ public List Lccn { get; init; } = [];
+
+ ///
+ /// Gets the OCLC identifiers of the search document.
+ ///
+ [JsonPropertyName("oclc")]
+ public List Oclc { get; init; } = [];
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibrarySearchResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibrarySearchResponse.cs
new file mode 100644
index 00000000..0174289a
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibrarySearchResponse.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for a search from the Open Library API.
+///
+internal sealed record OpenLibrarySearchResponse
+{
+ ///
+ /// Gets the documents that match the search.
+ ///
+ [JsonPropertyName("docs")]
+ public List Documents { get; init; } = [];
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryWorkAuthorResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryWorkAuthorResponse.cs
new file mode 100644
index 00000000..4d0bb561
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryWorkAuthorResponse.cs
@@ -0,0 +1,23 @@
+#region ========================================================================= USING =====================================================================================
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for an author reference within a work from the Open Library API.
+///
+internal sealed record OpenLibraryWorkAuthorResponse
+{
+ ///
+ /// Gets the author of the work.
+ ///
+ [JsonPropertyName("author")]
+ public OpenLibraryKeyReferenceResponse? Author { get; init; }
+
+ ///
+ /// Gets the key of the author reference.
+ ///
+ [JsonPropertyName("key")]
+ public string? Key { get; init; } // Older records can contain a direct key rather than an author wrapper.
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryWorkResponse.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryWorkResponse.cs
new file mode 100644
index 00000000..3a1ca9c1
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/Contracts/Responses/OpenLibraryWorkResponse.cs
@@ -0,0 +1,67 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+
+///
+/// Represents a response for a work from the Open Library API.
+///
+internal sealed record OpenLibraryWorkResponse
+{
+ ///
+ /// Gets the key of the work.
+ ///
+ [JsonPropertyName("key")]
+ public string? Key { get; init; }
+
+ ///
+ /// Gets the title of the work.
+ ///
+ [JsonPropertyName("title")]
+ public string? Title { get; init; }
+
+ ///
+ /// Gets the original title of the work.
+ ///
+ [JsonPropertyName("original_title")]
+ public string? OriginalTitle { get; init; }
+
+ ///
+ /// Gets the description of the work.
+ ///
+ [JsonPropertyName("description")]
+ public JsonElement Description { get; init; }
+
+ ///
+ /// Gets the first publication date of the work.
+ ///
+ [JsonPropertyName("first_publish_date")]
+ public string? FirstPublishDate { get; init; }
+
+ ///
+ /// Gets the subjects of the work.
+ ///
+ [JsonPropertyName("subjects")]
+ public List Subjects { get; init; } = [];
+
+ ///
+ /// Gets the genres of the work.
+ ///
+ [JsonPropertyName("genres")]
+ public List Genres { get; init; } = [];
+
+ ///
+ /// Gets the authors of the work.
+ ///
+ [JsonPropertyName("authors")]
+ public List Authors { get; init; } = [];
+
+ ///
+ /// Gets the original languages of the work.
+ ///
+ [JsonPropertyName("original_languages")]
+ public List OriginalLanguages { get; init; } = [];
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Common/Models/DTO/Settings/OpenLibrarySettingsDto.cs b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/DTO/Settings/OpenLibrarySettingsDto.cs
new file mode 100644
index 00000000..44feda1e
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Common/Models/DTO/Settings/OpenLibrarySettingsDto.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
+
+///
+/// Data transfer object for the settings that configure the Open Library metadata plugin.
+///
+internal sealed class OpenLibrarySettingsDto
+{
+ ///
+ /// Gets or sets the user agent sent with every request to the Open Library API.
+ ///
+ public string UserAgent { get; set; } = "Lumina-OpenLibrary/1.0";
+
+ ///
+ /// Gets or sets the contact email sent with every request to the Open Library API.
+ ///
+ public string? ContactEmail { get; set; }
+
+ ///
+ /// Gets or sets the maximum number of results returned by a single search.
+ ///
+ public int SearchResultLimit { get; set; } = 10;
+
+ ///
+ /// Gets or sets the maximum number of editions fetched for a single work.
+ ///
+ public int WorkEditionLimit { get; set; } = 50;
+
+ ///
+ /// Gets or sets the minimum interval between consecutive requests to the Open Library API.
+ ///
+ public TimeSpan MinimumRequestInterval { get; set; } = TimeSpan.FromSeconds(1.1);
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Core/Api/OpenLibraryHttpClient.cs b/plugins/Lumina.Plugins.OpenLibrary/Core/Api/OpenLibraryHttpClient.cs
new file mode 100644
index 00000000..7749f4a2
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Core/Api/OpenLibraryHttpClient.cs
@@ -0,0 +1,252 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+using Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
+using Lumina.Plugins.OpenLibrary.Core.Mapping;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Text.Json.Serialization;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Core.Api;
+
+///
+/// HTTP client that calls the Open Library API and deserializes its JSON responses into typed response models.
+///
+internal sealed class OpenLibraryHttpClient
+{
+ private readonly HttpClient _httpClient;
+ private readonly OpenLibrarySettingsDto _openLibrarySettings;
+ private readonly SemaphoreSlim _requestGate = new(1, 1);
+ private DateTimeOffset _lastRequestAt = DateTimeOffset.MinValue;
+
+ private static readonly JsonSerializerOptions s_serializerOptions = new(JsonSerializerDefaults.Web)
+ {
+ NumberHandling = JsonNumberHandling.AllowReadingFromString
+ };
+
+ private const string SEARCH_FIELDS =
+ "key,title,author_name,author_key,first_publish_year,edition_key,isbn," +
+ "language,publisher,subject,publish_place,number_of_pages_median," +
+ "ratings_average,ratings_count,id_amazon,id_goodreads,id_google," +
+ "id_librarything,lccn,oclc";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The used to send requests to the Open Library API.
+ /// The settings that configure the Open Library API requests.
+ public OpenLibraryHttpClient(HttpClient httpClient, OpenLibrarySettingsDto openLibrarySettings)
+ {
+ _httpClient = httpClient;
+ _openLibrarySettings = openLibrarySettings;
+
+ _httpClient.BaseAddress ??= new("https://openlibrary.org/");
+ if (_httpClient.DefaultRequestHeaders.UserAgent.Count == 0)
+ _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd(openLibrarySettings.UserAgent);
+
+ if (!string.IsNullOrWhiteSpace(openLibrarySettings.ContactEmail) && _httpClient.DefaultRequestHeaders.From is null)
+ _httpClient.DefaultRequestHeaders.From = openLibrarySettings.ContactEmail!;
+ }
+
+ ///
+ /// Gets an edition by its ISBN.
+ ///
+ /// The ISBN of the edition to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// The edition, or when no edition was found for the ISBN.
+ public Task GetEditionByIsbnAsync(string isbn, CancellationToken cancellationToken)
+ {
+ string normalized = OpenLibraryMapper.NormalizeIsbn(isbn);
+ return GetJsonOrNullAsync($"isbn/{Uri.EscapeDataString(normalized)}.json", cancellationToken);
+ }
+
+ ///
+ /// Gets an edition by its Open Library edition identifier.
+ ///
+ /// The Open Library edition identifier of the edition to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// The edition, or when no edition was found for the identifier.
+ public Task GetEditionAsync(string editionId, CancellationToken cancellationToken)
+ {
+ return GetJsonOrNullAsync($"books/{Uri.EscapeDataString(NormalizeOlid(editionId, 'M'))}.json", cancellationToken);
+ }
+
+ ///
+ /// Gets a work by its Open Library work identifier.
+ ///
+ /// The Open Library work identifier of the work to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// The work, or when no work was found for the identifier.
+ public Task GetWorkAsync(string workId, CancellationToken cancellationToken)
+ {
+ return GetJsonOrNullAsync($"works/{Uri.EscapeDataString(NormalizeOlid(workId, 'W'))}.json", cancellationToken);
+ }
+
+ ///
+ /// Gets an author by its Open Library author identifier.
+ ///
+ /// The Open Library author identifier of the author to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// The author, or when no author was found for the identifier.
+ public Task GetAuthorAsync(string authorId, CancellationToken cancellationToken)
+ {
+ return GetJsonOrNullAsync($"authors/{Uri.EscapeDataString(NormalizeOlid(authorId, 'A'))}.json", cancellationToken);
+ }
+
+ ///
+ /// Gets the ratings of a work by its Open Library work identifier.
+ ///
+ /// The Open Library work identifier of the work to get the ratings for.
+ /// Cancellation token that can be used to stop the execution.
+ /// The ratings, or when no ratings were found for the work.
+ public Task GetRatingsAsync(string workId, CancellationToken cancellationToken)
+ {
+ return GetJsonOrNullAsync($"works/{Uri.EscapeDataString(NormalizeOlid(workId, 'W'))}/ratings.json", cancellationToken);
+ }
+
+ ///
+ /// Gets a list of editions for a work by its Open Library work identifier.
+ ///
+ /// The Open Library work identifier of the work to get the editions for.
+ /// The maximum number of editions to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// The list of editions for the work.
+ public async Task> GetEditionsAsync(string workId, int limit, CancellationToken cancellationToken)
+ {
+ OpenLibraryEditionsResponse? response = await GetJsonOrNullAsync(
+ $"works/{Uri.EscapeDataString(NormalizeOlid(workId, 'W'))}/editions.json" +
+ $"?limit={Math.Clamp(limit, 1, 1000).ToString(CultureInfo.InvariantCulture)}",
+ cancellationToken)
+ .ConfigureAwait(false);
+
+ return response?.Entries ?? [];
+ }
+
+ ///
+ /// Searches Open Library for books matching the lookup.
+ ///
+ /// The lookup describing the book to search for.
+ /// The maximum number of search results to return.
+ /// Cancellation token that can be used to stop the execution.
+ /// The list of search results for the lookup.
+ public async Task> SearchAsync(BookMetadataLookupDto lookup, int limit, CancellationToken cancellationToken)
+ {
+ List> parameters = [];
+
+ string? isbn = lookup.Isbn;
+ string? title = lookup.Title;
+ string? author = lookup.Author;
+ string? languageCode = lookup.LanguageCode;
+
+ if (!string.IsNullOrWhiteSpace(isbn))
+ parameters.Add(new("isbn", OpenLibraryMapper.NormalizeIsbn(isbn)));
+
+ if (!string.IsNullOrWhiteSpace(title))
+ parameters.Add(new("title", title.Trim()));
+
+ if (!string.IsNullOrWhiteSpace(author))
+ parameters.Add(new("author", author.Trim()));
+
+ if (!string.IsNullOrWhiteSpace(languageCode))
+ parameters.Add(new("language", languageCode.Trim()));
+
+ parameters.Add(new("fields", SEARCH_FIELDS));
+ parameters.Add(new("limit", Math.Clamp(limit, 1, 100).ToString(CultureInfo.InvariantCulture)));
+
+ string query = string.Join("&", parameters.Select(pair => $"{Uri.EscapeDataString(pair.Key)}={Uri.EscapeDataString(pair.Value)}"));
+
+ OpenLibrarySearchResponse? response = await GetJsonOrNullAsync($"search.json?{query}", cancellationToken).ConfigureAwait(false);
+
+ return response?.Documents ?? [];
+ }
+
+ ///
+ /// Gets the JSON resource at the given relative URL and deserializes it into .
+ ///
+ /// The type to deserialize the JSON response into.
+ /// The URL of the resource, relative to the base address.
+ /// Cancellation token that can be used to stop the execution.
+ /// The deserialized resource, or when the resource was not found.
+ /// Transient failures and rate limiting are handled by retrying the request up to three times.
+ private async Task GetJsonOrNullAsync(string relativeUrl, CancellationToken cancellationToken)
+ {
+ for (int attempt = 0; attempt < 3; attempt++)
+ {
+ using HttpResponseMessage response = await SendAsync(relativeUrl, cancellationToken).ConfigureAwait(false);
+
+ if (response.StatusCode == HttpStatusCode.NotFound)
+ return default;
+
+ if (response.IsSuccessStatusCode)
+ {
+ await using Stream stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
+ return await JsonSerializer.DeserializeAsync(stream, s_serializerOptions, cancellationToken).ConfigureAwait(false);
+ }
+
+ if (attempt < 2 && (response.StatusCode == HttpStatusCode.TooManyRequests || (int)response.StatusCode >= 500))
+ {
+ TimeSpan retryDelay = response.Headers.RetryAfter?.Delta ?? TimeSpan.FromMilliseconds(250 * Math.Pow(2, attempt));
+ await Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ response.EnsureSuccessStatusCode();
+ }
+
+ return default;
+ }
+
+ ///
+ /// Sends a GET request to the Open Library API, throttled to respect the configured minimum request interval.
+ ///
+ /// The URL of the resource, relative to the base address.
+ /// Cancellation token that can be used to stop the execution.
+ /// The HTTP response message for the request.
+ private async Task SendAsync(string relativeUrl, CancellationToken cancellationToken)
+ {
+ await _requestGate.WaitAsync(cancellationToken).ConfigureAwait(false);
+ try
+ {
+ DateTimeOffset earliestNextRequest = _lastRequestAt + _openLibrarySettings.MinimumRequestInterval;
+ TimeSpan delay = earliestNextRequest - DateTimeOffset.UtcNow;
+ if (delay > TimeSpan.Zero)
+ await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
+
+ HttpRequestMessage request = new(HttpMethod.Get, relativeUrl);
+ request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ HttpResponseMessage response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ _lastRequestAt = DateTimeOffset.UtcNow;
+ return response;
+ }
+ finally
+ {
+ _requestGate.Release();
+ }
+ }
+
+ ///
+ /// Normalizes a raw Open Library identifier into its canonical OLID form.
+ ///
+ /// The raw Open Library identifier to normalize.
+ /// The suffix the OLID must end with, for example M for editions.
+ /// The canonical OLID.
+ /// The value is not a valid Open Library identifier.
+ private static string NormalizeOlid(string value, char expectedSuffix)
+ {
+ string id = value.Trim().TrimEnd('/').Split('/').Last().ToUpperInvariant();
+ if (id.Length < 4 || !id.StartsWith("OL", StringComparison.Ordinal) || id[^1] != expectedSuffix || !id.AsSpan(2, id.Length - 3).ToString().All(char.IsDigit))
+ throw new ArgumentException($"'{value}' is not a valid Open Library {expectedSuffix} identifier.", nameof(value));
+
+ return id;
+ }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Core/Mapping/OpenLibraryMapper.cs b/plugins/Lumina.Plugins.OpenLibrary/Core/Mapping/OpenLibraryMapper.cs
new file mode 100644
index 00000000..041f7146
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Core/Mapping/OpenLibraryMapper.cs
@@ -0,0 +1,532 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.Common;
+using Lumina.Contracts.DTO.MediaContributors;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text.Json;
+using System.Text.RegularExpressions;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Core.Mapping;
+
+///
+/// Maps Open Library API responses into the application's book request DTOs.
+///
+internal static partial class OpenLibraryMapper
+{
+ ///
+ /// Matches a contribution in the form Name (Role).
+ ///
+ [GeneratedRegex(@"^(?.+?)\s*\((?[^)]+)\)\s*$")]
+ private static partial Regex ContributorPattern();
+
+ ///
+ /// Matches a volume number in a series or volume string.
+ ///
+ [GeneratedRegex(@"\b(?:volume|vol\.?|book|no\.?|#)\s*(?\d+)\b", RegexOptions.IgnoreCase)]
+ private static partial Regex VolumePattern();
+
+ ///
+ /// Matches a four digit year.
+ ///
+ [GeneratedRegex(@"\b(?:1[0-9]{3}|20[0-9]{2}|2100)\b")]
+ private static partial Regex YearPattern();
+
+ private static readonly HashSet s_genreWords = new(StringComparer.OrdinalIgnoreCase)
+ {
+ "adventure", "biography", "children's literature", "comics", "crime",
+ "drama", "dystopian", "erotica", "essay", "fantasy", "fiction",
+ "historical fiction", "history", "horror", "humor", "memoir", "mystery",
+ "nonfiction", "poetry", "romance", "science fiction", "thriller",
+ "travel", "young adult"
+ };
+
+ ///
+ /// Maps the edition, work, author, rating, and search data into a full book request.
+ ///
+ /// The lookup describing the book to map.
+ /// The edition data, or when no edition was found.
+ /// The work data, or when no work was found.
+ /// The authors of the book.
+ /// The ratings of the book, or when no ratings were found.
+ /// The search document used as a fallback source of data, or .
+ /// The mapped book request.
+ public static AddBookRequest MapDetailed(
+ BookMetadataLookupDto lookup,
+ OpenLibraryEditionResponse? edition,
+ OpenLibraryWorkResponse? work,
+ IReadOnlyList authors,
+ OpenLibraryRatingsResponse? ratings,
+ OpenLibrarySearchDocumentResponse? fallback = null)
+ {
+ List subjects = DistinctValues(work?.Subjects ?? fallback?.Subjects ?? []);
+ List explicitGenres = DistinctValues(work?.Genres ?? []);
+ List genreNames = explicitGenres.Count > 0 ? explicitGenres : [.. subjects.Where(LooksLikeGenre)];
+
+ (DateOnly? Date, int? Year) originalRelease = ParseOpenLibraryDate(work?.FirstPublishDate);
+ int? originalYear = originalRelease.Date?.Year ?? originalRelease.Year ?? fallback?.FirstPublishYear;
+ (DateOnly? Date, int? Year) editionRelease = ParseOpenLibraryDate(edition?.PublishDate);
+
+ string? workId = ExtractOlid(work?.Key, 'W') ?? ExtractOlid(fallback?.Key, 'W');
+ string? editionId = ExtractOlid(edition?.Key, 'M') ?? fallback?.EditionKeys.FirstOrDefault();
+
+ string? currentLanguageCode = ExtractLanguageCode(edition?.Languages.FirstOrDefault()?.Key) ?? fallback?.Languages.FirstOrDefault();
+ string? originalLanguageCode = ExtractLanguageCode(work?.OriginalLanguages.FirstOrDefault()?.Key);
+
+ Dictionary> identifiers = ReadIdentifiers(edition?.Identifiers ?? default);
+ string? asin = FirstIdentifier(identifiers, "amazon", "asin") ?? FirstSourceIdentifier(edition?.SourceRecords, "amazon") ?? fallback?.AmazonIds.FirstOrDefault();
+ string? goodreadsId = FirstIdentifier(identifiers, "goodreads") ?? fallback?.GoodreadsIds.FirstOrDefault();
+ string? libraryThingId = FirstIdentifier(identifiers, "librarything") ?? fallback?.LibraryThingIds.FirstOrDefault();
+ string? googleBooksId = FirstIdentifier(identifiers, "google", "google_books") ?? FirstSourceIdentifier(edition?.SourceRecords, "google") ?? fallback?.GoogleIds.FirstOrDefault();
+ string? barnesAndNobleId = FirstIdentifier(identifiers, "barnesandnoble", "barnes_and_noble", "bn");
+ string? appleBooksId = FirstIdentifier(identifiers, "apple", "apple_books", "ibooks");
+
+ List isbns = MapIsbns(lookup.Isbn, edition, fallback);
+ List contributors = MapContributors(authors, edition?.Contributions, fallback?.AuthorNames);
+ List mappedRatings = MapRatings(ratings, fallback);
+
+ string? title = FirstNotEmpty(edition?.Title, work?.Title, fallback?.Title);
+ string? description = ReadText(work?.Description ?? default) ?? ReadText(edition?.Notes ?? default);
+ string? releaseCountry = edition?.PublishPlaces.FirstOrDefault() ?? fallback?.PublishPlaces.FirstOrDefault();
+ string? releaseVersion = edition?.EditionName;
+
+ return new AddBookRequest(
+ lookup.LibraryId,
+ lookup.Path,
+ new WrittenContentMetadataDto(
+ title,
+ work?.OriginalTitle,
+ description,
+ new ReleaseInfoDto(
+ originalRelease.Date,
+ originalYear,
+ editionRelease.Date,
+ editionRelease.Date?.Year ?? editionRelease.Year,
+ NullIfWhiteSpace(releaseCountry),
+ NullIfWhiteSpace(releaseVersion)),
+ genreNames.Select(name => new GenreDto(name)).ToList(),
+ subjects.Select(name => new TagDto(name)).ToList(),
+ MapLanguage(currentLanguageCode),
+ MapLanguage(originalLanguageCode),
+ edition?.Publishers.FirstOrDefault() ?? fallback?.Publishers.FirstOrDefault(),
+ edition?.NumberOfPages ?? fallback?.NumberOfPagesMedian),
+ MapFormat(edition?.PhysicalFormat),
+ NullIfWhiteSpace(edition?.EditionName),
+ ParseVolumeNumber(edition?.Volume, edition?.Series.FirstOrDefault()),
+ MapSeries(edition?.Series.FirstOrDefault()),
+ NullIfWhiteSpace(asin),
+ NullIfWhiteSpace(goodreadsId),
+ NullIfWhiteSpace(edition?.Lccn.FirstOrDefault() ?? fallback?.Lccn.FirstOrDefault()),
+ NullIfWhiteSpace(edition?.OclcNumbers.FirstOrDefault() ?? fallback?.Oclc.FirstOrDefault()),
+ editionId ?? workId,
+ NullIfWhiteSpace(libraryThingId),
+ NullIfWhiteSpace(googleBooksId),
+ NullIfWhiteSpace(barnesAndNobleId),
+ NullIfWhiteSpace(appleBooksId),
+ isbns,
+ contributors,
+ mappedRatings);
+ }
+
+ ///
+ /// Maps a search document into a book request candidate.
+ ///
+ /// The lookup describing the book to map.
+ /// The search document to map.
+ /// The mapped book request candidate.
+ public static AddBookRequest MapSearchCandidate(BookMetadataLookupDto lookup, OpenLibrarySearchDocumentResponse document)
+ {
+ return MapDetailed(lookup, null, null, [], null, document);
+ }
+
+ ///
+ /// Normalizes an ISBN into its canonical form without separators or whitespace.
+ ///
+ /// The ISBN to normalize.
+ /// The normalized ISBN.
+ /// The ISBN is empty, white space, or contains invalid characters.
+ public static string NormalizeIsbn(string isbn)
+ {
+ ArgumentException.ThrowIfNullOrWhiteSpace(isbn);
+ string normalized = new string([.. isbn.Where(character => character is not '-' && !char.IsWhiteSpace(character))]).ToUpperInvariant();
+
+ if ((normalized.Length != 10 && normalized.Length != 13) ||
+ normalized[..^1].Any(character => !char.IsDigit(character)) ||
+ (!char.IsDigit(normalized[^1]) && !(normalized.Length == 10 && normalized[^1] == 'X')))
+ throw new ArgumentException("The ISBN must contain 10 or 13 valid characters.", nameof(isbn));
+
+ return normalized;
+ }
+
+ ///
+ /// Extracts the canonical OLID from an Open Library key, when it matches the expected suffix.
+ ///
+ /// The Open Library key to extract the OLID from.
+ /// The suffix the OLID must end with, for example W for works.
+ /// The canonical OLID, or when the key does not contain a matching OLID.
+ public static string? ExtractOlid(string? key, char expectedSuffix)
+ {
+ if (string.IsNullOrWhiteSpace(key))
+ return null;
+
+ string candidate = key.Trim().TrimEnd('/').Split('/').Last().ToUpperInvariant();
+ return candidate.StartsWith("OL", StringComparison.Ordinal) && candidate.EndsWith(expectedSuffix) && candidate.Length > 3 ? candidate : null;
+ }
+
+ ///
+ /// Maps a physical format string into a book format enum value.
+ ///
+ /// The physical format string to map.
+ /// The mapped book format, or when the format is not recognized.
+ public static BookFormat? MapFormat(string? physicalFormat)
+ {
+ if (string.IsNullOrWhiteSpace(physicalFormat))
+ return null;
+
+ string value = physicalFormat.Trim().ToLowerInvariant();
+ if (value.Contains("mass market", StringComparison.Ordinal))
+ return BookFormat.MassMarketPaperback;
+ if (value.Contains("trade paperback", StringComparison.Ordinal))
+ return BookFormat.TradePaperback;
+ if (value.Contains("paperback", StringComparison.Ordinal) || value.Contains("softcover", StringComparison.Ordinal))
+ return BookFormat.Paperback;
+ if (value.Contains("hardcover", StringComparison.Ordinal) || value.Contains("hard cover", StringComparison.Ordinal) || value.Contains("hardback", StringComparison.Ordinal) || value.Contains("clothbound", StringComparison.Ordinal))
+ return BookFormat.Hardcover;
+ if (value.Contains("ebook", StringComparison.Ordinal) || value.Contains("e-book", StringComparison.Ordinal) || value.Contains("electronic", StringComparison.Ordinal))
+ return BookFormat.eBook;
+ if (value.Contains("audiobook", StringComparison.Ordinal) || value.Contains("audio book", StringComparison.Ordinal) || value.Contains("audio cd", StringComparison.Ordinal) || value.Contains("audio cassette", StringComparison.Ordinal))
+ return BookFormat.Audiobook;
+ if (value.Contains("large print", StringComparison.Ordinal))
+ return BookFormat.LargePrint;
+ if (value.Contains("board book", StringComparison.Ordinal))
+ return BookFormat.BoardBook;
+ if (value.Contains("spiral", StringComparison.Ordinal))
+ return BookFormat.SpiralBound;
+ if (value.Contains("library binding", StringComparison.Ordinal))
+ return BookFormat.LibraryBinding;
+ if (value.Contains("leather", StringComparison.Ordinal))
+ return BookFormat.LeatherBound;
+ if (value.Contains("pop-up", StringComparison.Ordinal) || value.Contains("popup", StringComparison.Ordinal))
+ return BookFormat.PopupBook;
+ return null;
+ }
+
+ ///
+ /// Maps the ISBNs from the lookup, edition, and search document into ISBN DTOs, de-duplicating normalized values.
+ ///
+ /// The ISBN of the lookup.
+ /// The edition data to read the ISBNs from.
+ /// The search document to read the ISBNs from.
+ /// The mapped and de-duplicated ISBN DTOs.
+ private static List MapIsbns(string? lookupIsbn, OpenLibraryEditionResponse? edition, OpenLibrarySearchDocumentResponse? fallback)
+ {
+ List result = [];
+ HashSet seen = new(StringComparer.OrdinalIgnoreCase);
+
+ void Add(string? raw, IsbnFormat? declaredFormat = null)
+ {
+ if (string.IsNullOrWhiteSpace(raw))
+ return;
+ string normalized;
+ try
+ {
+ normalized = NormalizeIsbn(raw);
+ }
+ catch (ArgumentException)
+ {
+ return;
+ }
+
+ if (!seen.Add(normalized))
+ return;
+ IsbnFormat format = declaredFormat ?? (normalized.Length == 10 ? IsbnFormat.Isbn10 : IsbnFormat.Isbn13);
+ result.Add(new IsbnDto(normalized, format));
+ }
+
+ Add(lookupIsbn);
+ foreach (string isbn in edition?.Isbn10 ?? [])
+ Add(isbn, IsbnFormat.Isbn10);
+ foreach (string isbn in edition?.Isbn13 ?? [])
+ Add(isbn, IsbnFormat.Isbn13);
+ foreach (string isbn in fallback?.Isbns ?? [])
+ Add(isbn);
+ return result;
+ }
+
+ ///
+ /// Maps the authors and contributions into contributor DTOs, de-duplicating identical name and role pairs.
+ ///
+ /// The authors of the book.
+ /// The contribution strings of the edition.
+ /// The author names from the search document.
+ /// The mapped contributor DTOs.
+ private static List MapContributors(IReadOnlyList authors, IReadOnlyList? contributions, IReadOnlyList? fallbackAuthors)
+ {
+ List result = [];
+ HashSet seen = new(StringComparer.OrdinalIgnoreCase);
+
+ void Add(string? displayName, string? legalName, string role, string category)
+ {
+ if (string.IsNullOrWhiteSpace(displayName) || !seen.Add($"{displayName}|{role}"))
+ return;
+ result.Add(new MediaContributorDto(new MediaContributorNameDto(displayName.Trim(), NullIfWhiteSpace(legalName)), new MediaContributorRoleDto(role, category)));
+ }
+
+ foreach (OpenLibraryAuthorResponse author in authors)
+ Add(author.Name, author.PersonalName, "Author", "Writing");
+ foreach (string authorName in fallbackAuthors ?? [])
+ Add(authorName, null, "Author", "Writing");
+
+ foreach (string contribution in contributions ?? [])
+ {
+ Match match = ContributorPattern().Match(contribution);
+ string name = match.Success ? match.Groups["name"].Value.Trim() : contribution.Trim();
+ string role = match.Success ? match.Groups["role"].Value.Trim() : "Contributor";
+ Add(name, null, role, ContributorCategory(role));
+ }
+ return result;
+ }
+
+ ///
+ /// Maps the ratings into a single Open Library rating DTO when an average or a count is present.
+ ///
+ /// The ratings of the work.
+ /// The search document to read the ratings from.
+ /// The mapped rating DTOs, or an empty list when no rating data was found.
+ private static List MapRatings(OpenLibraryRatingsResponse? ratings, OpenLibrarySearchDocumentResponse? fallback)
+ {
+ decimal? average = ratings?.Summary?.Average ?? fallback?.RatingsAverage;
+ int? count = ratings?.Summary?.Count ?? fallback?.RatingsCount;
+ if (average is null && count is null)
+ return [];
+
+ return [new BookRatingDto(average, 5m, BookRatingSource.OpenLibrary, count)];
+ }
+
+ ///
+ /// Maps a language code into a language info DTO by matching it against known cultures.
+ ///
+ /// The raw language code to map.
+ /// The mapped language info, or when the code is empty.
+ private static LanguageInfoDto? MapLanguage(string? rawCode)
+ {
+ if (string.IsNullOrWhiteSpace(rawCode))
+ return null;
+
+ string code = rawCode.Trim().ToLowerInvariant();
+ IEnumerable cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
+ .Concat(CultureInfo.GetCultures(CultureTypes.NeutralCultures));
+
+ CultureInfo? culture = cultures.FirstOrDefault(candidate =>
+ string.Equals(candidate.TwoLetterISOLanguageName, code, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(candidate.ThreeLetterISOLanguageName, code, StringComparison.OrdinalIgnoreCase));
+
+ return culture is null ? new LanguageInfoDto(code, code, null) : new LanguageInfoDto(culture.TwoLetterISOLanguageName, culture.EnglishName, culture.NativeName);
+ }
+
+ ///
+ /// Maps a series string into a book series DTO.
+ ///
+ /// The series string to map.
+ /// The mapped book series, or when the string is empty.
+ private static BookSeriesDto? MapSeries(string? series)
+ {
+ string? value = NullIfWhiteSpace(series);
+ return value is null ? null : new BookSeriesDto(value);
+ }
+
+ ///
+ /// Parses a volume number from the first candidate that contains one.
+ ///
+ /// The strings that may contain a volume number.
+ /// The parsed volume number, or when no candidate contains one.
+ private static int? ParseVolumeNumber(params string?[] candidates)
+ {
+ foreach (string? candidate in candidates)
+ {
+ if (string.IsNullOrWhiteSpace(candidate))
+ continue;
+ Match match = VolumePattern().Match(candidate);
+ if (match.Success && int.TryParse(match.Groups["number"].Value, out int number))
+ return number;
+ }
+ return null;
+ }
+
+ ///
+ /// Parses an Open Library date string into a date and a year.
+ ///
+ /// The date string to parse.
+ /// The parsed date and year, or values when the string could not be parsed.
+ private static (DateOnly? Date, int? Year) ParseOpenLibraryDate(string? value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ return (null, null);
+
+ DateTimeStyles styles = DateTimeStyles.AllowWhiteSpaces;
+ string[] formats =
+ [
+ "yyyy-MM-dd", "yyyy-M-d", "MMMM d, yyyy", "MMM d, yyyy",
+ "d MMMM yyyy", "d MMM yyyy"
+ ];
+
+ if (DateOnly.TryParseExact(value.Trim(), formats, CultureInfo.InvariantCulture, styles, out DateOnly exact))
+ return (exact, exact.Year);
+
+ Match yearMatch = YearPattern().Match(value);
+ return yearMatch.Success && int.TryParse(yearMatch.Value, out int year) ? (null, year) : (null, null);
+ }
+
+ ///
+ /// Reads the text out of a JSON element that is either a plain string or an object with a value property.
+ ///
+ /// The JSON element to read.
+ /// The text, or when the element does not contain readable text.
+ private static string? ReadText(JsonElement element)
+ {
+ return element.ValueKind switch
+ {
+ JsonValueKind.String => NullIfWhiteSpace(element.GetString()),
+ JsonValueKind.Object when element.TryGetProperty("value", out JsonElement value) => ReadText(value),
+ _ => null
+ };
+ }
+
+ ///
+ /// Reads an identifiers object into a dictionary keyed by identifier name.
+ ///
+ /// The JSON element to read.
+ /// The identifier values keyed by identifier name.
+ private static Dictionary> ReadIdentifiers(JsonElement element)
+ {
+ Dictionary> result = new(StringComparer.OrdinalIgnoreCase);
+ if (element.ValueKind != JsonValueKind.Object)
+ return result;
+
+ foreach (JsonProperty property in element.EnumerateObject())
+ {
+ IEnumerable values = property.Value.ValueKind switch
+ {
+ JsonValueKind.String => [property.Value.GetString()],
+ JsonValueKind.Array => property.Value.EnumerateArray()
+ .Where(item => item.ValueKind == JsonValueKind.String)
+ .Select(item => item.GetString()),
+ _ => []
+ };
+
+ result[property.Name] = [.. values
+ .Where(value => !string.IsNullOrWhiteSpace(value))
+ .Select(value => value!)];
+ }
+
+ return result;
+ }
+
+ ///
+ /// Gets the first value of the first identifier key that has values.
+ ///
+ /// The identifiers to read from.
+ /// The identifier keys to try, in order.
+ /// The first value, or when none of the keys have values.
+ private static string? FirstIdentifier(IReadOnlyDictionary> identifiers, params string[] keys)
+ {
+ foreach (string key in keys)
+ if (identifiers.TryGetValue(key, out List? values) && values.Count > 0)
+ return values[0];
+
+ return null;
+ }
+
+ ///
+ /// Gets the identifier value from a source record prefixed with the given source name.
+ ///
+ /// The source records to read from.
+ /// The source name prefix to match.
+ /// The identifier value, or when no source record matches.
+ private static string? FirstSourceIdentifier(IReadOnlyList? sourceRecords, string source)
+ {
+ string prefix = source + ":";
+ string? match = sourceRecords?.FirstOrDefault(value => value.StartsWith(prefix, StringComparison.OrdinalIgnoreCase));
+ return match?[prefix.Length..];
+ }
+
+ ///
+ /// Extracts the language code from an Open Library language key.
+ ///
+ /// The language key to extract the code from.
+ /// The language code, or when the key is empty.
+ private static string? ExtractLanguageCode(string? key)
+ {
+ return string.IsNullOrWhiteSpace(key) ? null : key.Trim().TrimEnd('/').Split('/').Last();
+ }
+
+ ///
+ /// Trims, filters, and de-duplicates the given values, ignoring case.
+ ///
+ /// The values to process.
+ /// The processed values.
+ private static List DistinctValues(IEnumerable values)
+ {
+ return [.. values.Select(value => value.Trim()).Where(value => value.Length > 0).Distinct(StringComparer.OrdinalIgnoreCase)];
+ }
+
+ ///
+ /// Determines whether a subject is likely to describe a genre.
+ ///
+ /// The subject to check.
+ /// when the subject is a known genre word or ends in fiction or literature.
+ private static bool LooksLikeGenre(string subject)
+ {
+ return s_genreWords.Contains(subject) ||
+ subject.EndsWith(" fiction", StringComparison.OrdinalIgnoreCase) ||
+ subject.EndsWith(" literature", StringComparison.OrdinalIgnoreCase);
+ }
+
+ ///
+ /// Maps a contributor role into a contributor category.
+ ///
+ /// The role to categorize.
+ /// The mapped contributor category.
+ private static string ContributorCategory(string role)
+ {
+ if (role.Contains("illustr", StringComparison.OrdinalIgnoreCase) ||
+ role.Contains("artist", StringComparison.OrdinalIgnoreCase))
+ return "Art";
+ if (role.Contains("translat", StringComparison.OrdinalIgnoreCase))
+ return "Translation";
+ if (role.Contains("edit", StringComparison.OrdinalIgnoreCase) ||
+ role.Contains("author", StringComparison.OrdinalIgnoreCase) ||
+ role.Contains("writer", StringComparison.OrdinalIgnoreCase))
+ return "Writing";
+ if (role.Contains("narrat", StringComparison.OrdinalIgnoreCase))
+ return "Performance";
+ return "Other";
+ }
+
+ ///
+ /// Gets the first value that is not empty or white space.
+ ///
+ /// The values to check, in order.
+ /// The first non-empty value, or when all values are empty.
+ private static string? FirstNotEmpty(params string?[] values)
+ {
+ return values.Select(NullIfWhiteSpace).FirstOrDefault(value => value is not null);
+ }
+
+ ///
+ /// Returns the trimmed value, or when the value is empty or white space.
+ ///
+ /// The value to process.
+ /// The trimmed value, or .
+ private static string? NullIfWhiteSpace(string? value)
+ {
+ return string.IsNullOrWhiteSpace(value) ? null : value.Trim();
+ }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Core/OpenLibraryBookMetadataProvider.cs b/plugins/Lumina.Plugins.OpenLibrary/Core/OpenLibraryBookMetadataProvider.cs
new file mode 100644
index 00000000..570b837d
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Core/OpenLibraryBookMetadataProvider.cs
@@ -0,0 +1,364 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using Lumina.Plugins.Contracts.Core.Metadata;
+using Lumina.Plugins.OpenLibrary.Common.Models.Contracts.Responses;
+using Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
+using Lumina.Plugins.OpenLibrary.Core.Api;
+using Lumina.Plugins.OpenLibrary.Core.Mapping;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Core;
+
+///
+/// Provides book metadata from the Open Library by resolving lookups into book metadata DTOs.
+///
+internal sealed class OpenLibraryBookMetadataProvider : IRemoteMetadataProvider
+{
+ private readonly OpenLibraryHttpClient _openLibraryHttpClient;
+ private readonly OpenLibrarySettingsDto _openLibrarySettings;
+
+ ///
+ /// Gets the display name of the metadata provider.
+ ///
+ public string Name => "Open Library";
+
+ ///
+ /// Gets the media library type this metadata provider supports.
+ ///
+ public LibraryType SupportedLibraryType => LibraryType.Book;
+
+ ///
+ /// Gets a value indicating whether this metadata provider requires access to the web to retrieve metadata.
+ ///
+ public bool RequiresWebAccess => true;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The HTTP client used to call the Open Library API.
+ /// The settings that configure the Open Library API requests.
+ public OpenLibraryBookMetadataProvider(OpenLibraryHttpClient openLibraryHttpClient, OpenLibrarySettingsDto openLibrarySettings)
+ {
+ _openLibraryHttpClient = openLibraryHttpClient;
+ _openLibrarySettings = openLibrarySettings;
+ }
+
+ ///
+ /// Searches for the metadata of the media item described by .
+ ///
+ /// The lookup describing the media item to search for.
+ /// Cancellation token that can be used to stop the execution.
+ /// The collection of metadata candidates found for the media item.
+ public async Task> GetSearchResultsAsync(BookMetadataLookupDto bookMetadataLookup, CancellationToken cancellationToken)
+ {
+ ValidateLookup(bookMetadataLookup);
+
+ if (!string.IsNullOrWhiteSpace(bookMetadataLookup.Isbn) || !string.IsNullOrWhiteSpace(bookMetadataLookup.OpenLibraryId))
+ {
+ AddBookRequest? exactBookRequestMatch = await GetBookAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
+ return exactBookRequestMatch is null ? [] : [new BookMetadataDto(
+ exactBookRequestMatch.Metadata?.Title,
+ exactBookRequestMatch.Metadata?.OriginalTitle,
+ exactBookRequestMatch.Metadata?.Description,
+ exactBookRequestMatch.Metadata?.ReleaseInfo,
+ exactBookRequestMatch.Metadata?.Genres,
+ exactBookRequestMatch.Metadata?.Tags,
+ exactBookRequestMatch.Metadata?.Language,
+ exactBookRequestMatch.Metadata?.OriginalLanguage,
+ exactBookRequestMatch.Metadata?.Publisher,
+ exactBookRequestMatch.Metadata?.PageCount,
+ exactBookRequestMatch.Format,
+ exactBookRequestMatch.Edition,
+ exactBookRequestMatch.VolumeNumber,
+ exactBookRequestMatch.Series,
+ exactBookRequestMatch.ASIN,
+ exactBookRequestMatch.GoodreadsId,
+ exactBookRequestMatch.LCCN,
+ exactBookRequestMatch.OCLCNumber,
+ exactBookRequestMatch.OpenLibraryId,
+ exactBookRequestMatch.LibraryThingId,
+ exactBookRequestMatch.GoogleBooksId,
+ exactBookRequestMatch.BarnesAndNobleId,
+ exactBookRequestMatch.AppleBooksId,
+ exactBookRequestMatch.ISBNs,
+ exactBookRequestMatch.Contributors,
+ exactBookRequestMatch.Ratings,
+ CoverImageUrl: null
+ )];
+ }
+
+ IReadOnlyList openLibrarySearchDocuments = await _openLibraryHttpClient.SearchAsync(bookMetadataLookup, _openLibrarySettings.SearchResultLimit, cancellationToken).ConfigureAwait(false);
+
+ return [.. openLibrarySearchDocuments
+ .Where(openLibrarySearchDocument => !string.IsNullOrWhiteSpace(openLibrarySearchDocument.Title))
+ .Select(openLibrarySearchDocument =>
+ {
+ AddBookRequest addBookRequest = OpenLibraryMapper.MapSearchCandidate(bookMetadataLookup, openLibrarySearchDocument);
+ return new BookMetadataDto(
+ addBookRequest.Metadata?.Title,
+ addBookRequest.Metadata?.OriginalTitle,
+ addBookRequest.Metadata?.Description,
+ addBookRequest.Metadata?.ReleaseInfo,
+ addBookRequest.Metadata?.Genres,
+ addBookRequest.Metadata?.Tags,
+ addBookRequest.Metadata?.Language,
+ addBookRequest.Metadata?.OriginalLanguage,
+ addBookRequest.Metadata?.Publisher,
+ addBookRequest.Metadata?.PageCount,
+ addBookRequest.Format,
+ addBookRequest.Edition,
+ addBookRequest.VolumeNumber,
+ addBookRequest.Series,
+ addBookRequest.ASIN,
+ addBookRequest.GoodreadsId,
+ addBookRequest.LCCN,
+ addBookRequest.OCLCNumber,
+ addBookRequest.OpenLibraryId,
+ addBookRequest.LibraryThingId,
+ addBookRequest.GoogleBooksId,
+ addBookRequest.BarnesAndNobleId,
+ addBookRequest.AppleBooksId,
+ addBookRequest.ISBNs,
+ addBookRequest.Contributors,
+ addBookRequest.Ratings,
+ CoverImageUrl: null
+ );
+ })];
+ }
+
+ ///
+ /// Gets the metadata of the media item described by .
+ ///
+ /// The lookup describing the media item to get the metadata for.
+ /// Cancellation token that can be used to stop the execution.
+ /// The metadata of the media item, or when no metadata was found.
+ public async Task GetMetadataAsync(BookMetadataLookupDto bookMetadataLookup, CancellationToken cancellationToken)
+ {
+ AddBookRequest? exactBookRequestMatch = await GetBookAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
+ return exactBookRequestMatch is null ? null : new BookMetadataDto(
+ exactBookRequestMatch.Metadata?.Title,
+ exactBookRequestMatch.Metadata?.OriginalTitle,
+ exactBookRequestMatch.Metadata?.Description,
+ exactBookRequestMatch.Metadata?.ReleaseInfo,
+ exactBookRequestMatch.Metadata?.Genres,
+ exactBookRequestMatch.Metadata?.Tags,
+ exactBookRequestMatch.Metadata?.Language,
+ exactBookRequestMatch.Metadata?.OriginalLanguage,
+ exactBookRequestMatch.Metadata?.Publisher,
+ exactBookRequestMatch.Metadata?.PageCount,
+ exactBookRequestMatch.Format,
+ exactBookRequestMatch.Edition,
+ exactBookRequestMatch.VolumeNumber,
+ exactBookRequestMatch.Series,
+ exactBookRequestMatch.ASIN,
+ exactBookRequestMatch.GoodreadsId,
+ exactBookRequestMatch.LCCN,
+ exactBookRequestMatch.OCLCNumber,
+ exactBookRequestMatch.OpenLibraryId,
+ exactBookRequestMatch.LibraryThingId,
+ exactBookRequestMatch.GoogleBooksId,
+ exactBookRequestMatch.BarnesAndNobleId,
+ exactBookRequestMatch.AppleBooksId,
+ exactBookRequestMatch.ISBNs,
+ exactBookRequestMatch.Contributors,
+ exactBookRequestMatch.Ratings,
+ CoverImageUrl: null
+ );
+ }
+
+ ///
+ /// Resolves the lookup into a full book request by combining edition, work, author, and rating data from Open Library.
+ ///
+ /// The lookup describing the book to resolve.
+ /// Cancellation token that can be used to stop the execution.
+ /// The resolved book request, or when no matching book was found.
+ public async Task GetBookAsync(BookMetadataLookupDto bookMetadataLookup, CancellationToken cancellationToken = default)
+ {
+ ValidateLookup(bookMetadataLookup);
+
+ OpenLibraryEditionResponse? openLibraryEditionResponse = null;
+ OpenLibraryWorkResponse? openLibraryWorkResponse = null;
+ OpenLibrarySearchDocumentResponse? openLibrarySearchDocumentResponse = null;
+ string? openLibraryId = bookMetadataLookup.OpenLibraryId;
+ string? isbn = bookMetadataLookup.Isbn;
+ // if we have an Open Library Id, that's the first thing we should search by
+ if (!string.IsNullOrWhiteSpace(openLibraryId))
+ {
+ string olid = NormalizeOlid(openLibraryId);
+ if (olid.EndsWith('M'))
+ openLibraryEditionResponse = await _openLibraryHttpClient.GetEditionAsync(olid, cancellationToken).ConfigureAwait(false);
+ else if (olid.EndsWith('W'))
+ {
+ // A work has no publisher-specific details on its own (no ISBN, page count, etc.), so we still need to pull it for its work-level fields (e.g. description, subjects).
+ openLibraryWorkResponse = await _openLibraryHttpClient.GetWorkAsync(olid, cancellationToken).ConfigureAwait(false);
+ // A work can have many editions; SelectEdition picks the one that best matches the lookup criteria (language, format, etc.) instead of assuming the first result is right.
+ openLibraryEditionResponse = SelectEdition(await _openLibraryHttpClient.GetEditionsAsync(olid, _openLibrarySettings.WorkEditionLimit, cancellationToken).ConfigureAwait(false), bookMetadataLookup);
+ }
+ else
+ throw new ArgumentException("A book Open Library ID must be a work ID ending in W or an edition ID ending in M.", nameof(bookMetadataLookup));
+
+ if (openLibraryEditionResponse is null && openLibraryWorkResponse is null)
+ return null;
+ }
+ // no Open Library Id, let's try by ISBN
+ if (openLibraryEditionResponse is null && !string.IsNullOrWhiteSpace(isbn))
+ openLibraryEditionResponse = await _openLibraryHttpClient.GetEditionByIsbnAsync(isbn, cancellationToken).ConfigureAwait(false);
+ // if we still have no results, let's go nuclear and search by metadata
+ if (openLibraryEditionResponse is null && openLibraryWorkResponse is null)
+ {
+ IReadOnlyList searchResults = await _openLibraryHttpClient.SearchAsync(bookMetadataLookup, 1, cancellationToken).ConfigureAwait(false);
+ if (searchResults.Count == 0 || searchResults[0] is null)
+ return null;
+
+ string? workId = OpenLibraryMapper.ExtractOlid(searchResults[0].Key, 'W');
+ if (workId is not null)
+ {
+ openLibraryWorkResponse = await _openLibraryHttpClient.GetWorkAsync(workId, cancellationToken).ConfigureAwait(false);
+ openLibraryEditionResponse = SelectEdition(await _openLibraryHttpClient.GetEditionsAsync(workId, _openLibrarySettings.WorkEditionLimit, cancellationToken).ConfigureAwait(false), bookMetadataLookup);
+ }
+
+ if (openLibraryEditionResponse is null && searchResults[0].EditionKeys.Count > 0)
+ openLibraryEditionResponse = await _openLibraryHttpClient.GetEditionAsync(searchResults[0].EditionKeys[0], cancellationToken).ConfigureAwait(false);
+ }
+ // if by this time we still have no result, let's forget it...
+ if (openLibraryEditionResponse is null && openLibraryWorkResponse is null && openLibrarySearchDocumentResponse is null)
+ return null;
+
+ string? editionWorkId = OpenLibraryMapper.ExtractOlid(openLibraryEditionResponse?.Works.FirstOrDefault()?.Key, 'W');
+ if (openLibraryWorkResponse is null && editionWorkId is not null)
+ openLibraryWorkResponse = await _openLibraryHttpClient.GetWorkAsync(editionWorkId, cancellationToken).ConfigureAwait(false);
+
+ List authorIds = [.. (openLibraryWorkResponse?.Authors
+ .Select(item => OpenLibraryMapper.ExtractOlid(item.Author?.Key ?? item.Key, 'A')) ?? [])
+ .Concat(openLibraryEditionResponse?.Authors
+ .Select(item => OpenLibraryMapper.ExtractOlid(item.Key, 'A')) ?? [])
+ .Where(id => id is not null)
+ .Select(id => id!)
+ .Distinct(StringComparer.OrdinalIgnoreCase)];
+
+ List authors = [];
+ foreach (string authorId in authorIds)
+ {
+ OpenLibraryAuthorResponse? author = await _openLibraryHttpClient.GetAuthorAsync(authorId, cancellationToken).ConfigureAwait(false);
+ if (author is not null)
+ authors.Add(author);
+ }
+
+ string? finalWorkId = OpenLibraryMapper.ExtractOlid(openLibraryWorkResponse?.Key, 'W') ?? editionWorkId;
+ OpenLibraryRatingsResponse? ratings = finalWorkId is null ? null : await _openLibraryHttpClient.GetRatingsAsync(finalWorkId, cancellationToken).ConfigureAwait(false);
+
+ return OpenLibraryMapper.MapDetailed(bookMetadataLookup, openLibraryEditionResponse, openLibraryWorkResponse, authors, ratings, openLibrarySearchDocumentResponse);
+ }
+
+ ///
+ /// Selects the best matching edition from the given editions, favoring matches for the lookup's ISBN and language.
+ ///
+ /// The editions to select from.
+ /// The lookup the selected edition must match.
+ /// The best matching edition, or when no edition was found.
+ private static OpenLibraryEditionResponse? SelectEdition(IReadOnlyList openLibraryEditions, BookMetadataLookupDto bookMetadataLookup)
+ {
+ string? lookupIsbn = bookMetadataLookup.Isbn;
+ string? wantedIsbn = string.IsNullOrWhiteSpace(lookupIsbn) ? null : OpenLibraryMapper.NormalizeIsbn(lookupIsbn);
+ string? wantedLanguage = bookMetadataLookup.LanguageCode?.Trim();
+
+ return openLibraryEditions
+ .Select((edition, index) => new
+ {
+ Edition = edition,
+ Index = index,
+ Score = ScoreEdition(edition, wantedIsbn, wantedLanguage)
+ })
+ .OrderByDescending(item => item.Score)
+ .ThenBy(item => item.Index)
+ .Select(item => item.Edition)
+ .FirstOrDefault();
+ }
+
+ ///
+ /// Scores an edition against the wanted ISBN and language to rank how well it matches the lookup.
+ ///
+ /// The edition to score.
+ /// The normalized ISBN to match, or when the lookup has no ISBN.
+ /// The language code to match, or when the lookup has no language.
+ /// The match score of the edition, where a higher score is a better match.
+ private static int ScoreEdition(OpenLibraryEditionResponse openLibraryEdition, string? wantedIsbn, string? wantedLanguage)
+ {
+ int score = 0;
+ // if we get an ISBN match, that's the most certain identification score
+ if (wantedIsbn is not null && openLibraryEdition.Isbn10.Concat(openLibraryEdition.Isbn13).Any(value => string.Equals(SafeNormalizeIsbn(value), wantedIsbn, StringComparison.OrdinalIgnoreCase)))
+ score += 10_000;
+
+ if (!string.IsNullOrWhiteSpace(wantedLanguage) && openLibraryEdition.Languages.Any(language =>
+ string.Equals(language.Key?.Trim().TrimEnd('/').Split('/').Last(), wantedLanguage, StringComparison.OrdinalIgnoreCase)))
+ score += 1_000;
+
+ if (openLibraryEdition.NumberOfPages is > 0)
+ score += 100;
+ if (openLibraryEdition.Isbn10.Count + openLibraryEdition.Isbn13.Count > 0)
+ score += 50;
+ if (openLibraryEdition.Publishers.Count > 0)
+ score += 20;
+ if (!string.IsNullOrWhiteSpace(openLibraryEdition.PublishDate))
+ score += 10;
+ if (!string.IsNullOrWhiteSpace(openLibraryEdition.EditionName))
+ score += 5;
+ return score;
+ }
+
+ ///
+ /// Normalizes an ISBN, returning when the value is not a valid ISBN.
+ ///
+ /// The ISBN to normalize.
+ /// The normalized ISBN, or when the value is not a valid ISBN.
+ private static string? SafeNormalizeIsbn(string value)
+ {
+ try
+ {
+ return OpenLibraryMapper.NormalizeIsbn(value);
+ }
+ catch (ArgumentException)
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Normalizes a raw Open Library identifier into its canonical OLID form.
+ ///
+ /// The raw Open Library identifier to normalize.
+ /// The canonical OLID.
+ /// The value is not a valid Open Library identifier.
+ private static string NormalizeOlid(string raw)
+ {
+ string id = raw.Trim().TrimEnd('/').Split('/').Last().ToUpperInvariant();
+ if (id.Length < 4 || !id.StartsWith("OL", StringComparison.Ordinal) || (id[^1] is not ('M' or 'W')) || !id.AsSpan(2, id.Length - 3).ToString().All(char.IsDigit))
+ throw new ArgumentException("The Open Library ID is invalid.", nameof(raw));
+
+ return id;
+ }
+
+ ///
+ /// Validates that the lookup contains the information required to resolve book metadata.
+ ///
+ /// The lookup to validate.
+ /// The lookup is missing required information.
+ private static void ValidateLookup(BookMetadataLookupDto bookMetadataLookup)
+ {
+ ArgumentNullException.ThrowIfNull(bookMetadataLookup);
+ if (bookMetadataLookup.LibraryId == Guid.Empty)
+ throw new ArgumentException("LibraryId is required.", nameof(bookMetadataLookup));
+
+ ArgumentException.ThrowIfNullOrWhiteSpace(bookMetadataLookup.Path);
+
+ if (string.IsNullOrWhiteSpace(bookMetadataLookup.Isbn) && string.IsNullOrWhiteSpace(bookMetadataLookup.OpenLibraryId) && string.IsNullOrWhiteSpace(bookMetadataLookup.Title))
+ throw new ArgumentException("At least one of Isbn, OpenLibraryId, or Title is required.", nameof(bookMetadataLookup));
+ }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Core/OpenLibraryPlugin.cs b/plugins/Lumina.Plugins.OpenLibrary/Core/OpenLibraryPlugin.cs
new file mode 100644
index 00000000..ff235f39
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Core/OpenLibraryPlugin.cs
@@ -0,0 +1,87 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
+using Lumina.Plugins.Contracts.Common.Models.DTO.Settings;
+using Lumina.Plugins.Contracts.Core.Plugins;
+using Lumina.Plugins.OpenLibrary.Common.DependencyInjection;
+using Lumina.Plugins.OpenLibrary.Core.Settings;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Core;
+
+///
+/// Plugin that provides book metadata retrieval from Open Library.
+///
+public sealed class OpenLibraryPlugin : IPlugin, IPluginServiceRegistrator
+{
+ ///
+ /// The unique identifier of the plugin.
+ ///
+ public static readonly Guid s_pluginId = new("08b17802-7f9c-4c4b-9d7f-b507bbed3e58");
+
+ ///
+ /// Gets the unique identifier of the plugin.
+ ///
+ public Guid Id => s_pluginId;
+
+ ///
+ /// Gets the display name of the plugin.
+ ///
+ public string Name => "Open Library Metadata";
+
+ ///
+ /// Gets the author of the plugin.
+ ///
+ public string Author => "Lumina";
+
+ ///
+ /// Gets the version of the plugin.
+ ///
+ public Version Version => new(1, 0, 0);
+
+ ///
+ /// Gets the description of the plugin.
+ ///
+ public string Description => "Retrieves book and edition metadata from Open Library.";
+
+ ///
+ /// Gets the settings schema of the plugin.
+ ///
+ /// The settings descriptors of the plugin.
+ public IReadOnlyList GetSettingsSchema()
+ {
+ return
+ [
+ new PluginSettingDescriptorDto(
+ Key: OpenLibrarySettingsKeys.CONTACT_EMAIL,
+ Label: "Contact Email",
+ Type: PluginSettingType.Text),
+ new PluginSettingDescriptorDto(
+ Key: OpenLibrarySettingsKeys.SEARCH_RESULT_LIMIT,
+ Label: "Search Result Limit",
+ Type: PluginSettingType.Number,
+ DefaultValue: "10"),
+ new PluginSettingDescriptorDto(
+ Key: OpenLibrarySettingsKeys.WORK_EDITION_LIMIT,
+ Label: "Work Edition Limit",
+ Type: PluginSettingType.Number,
+ DefaultValue: "50"),
+ new PluginSettingDescriptorDto(
+ Key: OpenLibrarySettingsKeys.MINIMUM_REQUEST_INTERVAL_SECONDS,
+ Label: "Minimum Request Interval (seconds)",
+ Type: PluginSettingType.Number,
+ DefaultValue: "1.1")
+ ];
+ }
+
+ ///
+ /// Registers the services required by the plugin.
+ ///
+ /// The service collection to register the services into.
+ public void RegisterServices(IServiceCollection services)
+ {
+ services.AddOpenLibraryBookMetadataProvider(pluginId: Id);
+ }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Core/Settings/OpenLibrarySettingsKeys.cs b/plugins/Lumina.Plugins.OpenLibrary/Core/Settings/OpenLibrarySettingsKeys.cs
new file mode 100644
index 00000000..c1e83809
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Core/Settings/OpenLibrarySettingsKeys.cs
@@ -0,0 +1,27 @@
+namespace Lumina.Plugins.OpenLibrary.Core.Settings;
+
+///
+/// Keys of the settings of the Open Library metadata plugin, shared by the settings schema and the settings loader.
+///
+internal static class OpenLibrarySettingsKeys
+{
+ ///
+ /// The key of the setting defining the contact email sent to the Open Library API.
+ ///
+ internal const string CONTACT_EMAIL = "ContactEmail";
+
+ ///
+ /// The key of the setting defining the maximum number of results returned by a single search.
+ ///
+ internal const string SEARCH_RESULT_LIMIT = "SearchResultLimit";
+
+ ///
+ /// The key of the setting defining the maximum number of editions fetched for a single work.
+ ///
+ internal const string WORK_EDITION_LIMIT = "WorkEditionLimit";
+
+ ///
+ /// The key of the setting defining the minimum interval between consecutive requests to the Open Library API, in seconds.
+ ///
+ internal const string MINIMUM_REQUEST_INTERVAL_SECONDS = "MinimumRequestIntervalSeconds";
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Core/Settings/OpenLibrarySettingsLoader.cs b/plugins/Lumina.Plugins.OpenLibrary/Core/Settings/OpenLibrarySettingsLoader.cs
new file mode 100644
index 00000000..772ed05e
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Core/Settings/OpenLibrarySettingsLoader.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Plugins.OpenLibrary.Common.Models.DTO.Settings;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+#endregion
+
+namespace Lumina.Plugins.OpenLibrary.Core.Settings;
+
+///
+/// Applies the settings persisted by the host onto the runtime settings of the Open Library metadata plugin.
+///
+internal static class OpenLibrarySettingsLoader
+{
+ ///
+ /// Overlays the persisted onto the provided , keeping the default values of the settings that were not persisted.
+ ///
+ /// The runtime settings onto which the persisted settings are applied.
+ /// The settings persisted by the host, keyed by setting key.
+ public static void Apply(OpenLibrarySettingsDto settings, IReadOnlyDictionary storedSettings)
+ {
+ if (storedSettings.TryGetValue(OpenLibrarySettingsKeys.CONTACT_EMAIL, out string? contactEmail))
+ settings.ContactEmail = string.IsNullOrWhiteSpace(contactEmail) ? null : contactEmail.Trim();
+
+ if (storedSettings.TryGetValue(OpenLibrarySettingsKeys.SEARCH_RESULT_LIMIT, out string? searchResultLimit) &&
+ int.TryParse(searchResultLimit, NumberStyles.Integer, CultureInfo.InvariantCulture, out int searchResultLimitValue))
+ settings.SearchResultLimit = Math.Max(1, searchResultLimitValue);
+
+ if (storedSettings.TryGetValue(OpenLibrarySettingsKeys.WORK_EDITION_LIMIT, out string? workEditionLimit) &&
+ int.TryParse(workEditionLimit, NumberStyles.Integer, CultureInfo.InvariantCulture, out int workEditionLimitValue))
+ settings.WorkEditionLimit = Math.Max(1, workEditionLimitValue);
+
+ if (storedSettings.TryGetValue(OpenLibrarySettingsKeys.MINIMUM_REQUEST_INTERVAL_SECONDS, out string? minimumRequestInterval) &&
+ double.TryParse(minimumRequestInterval, NumberStyles.Float, CultureInfo.InvariantCulture, out double minimumRequestIntervalValue))
+ settings.MinimumRequestInterval = TimeSpan.FromSeconds(Math.Max(0, minimumRequestIntervalValue));
+ }
+}
diff --git a/plugins/Lumina.Plugins.OpenLibrary/Lumina.Plugins.OpenLibrary.csproj b/plugins/Lumina.Plugins.OpenLibrary/Lumina.Plugins.OpenLibrary.csproj
new file mode 100644
index 00000000..a0f2e745
--- /dev/null
+++ b/plugins/Lumina.Plugins.OpenLibrary/Lumina.Plugins.OpenLibrary.csproj
@@ -0,0 +1,32 @@
+
+
+ net10.0
+ disable
+ enable
+ $(SolutionDir)..\bin\plugins\
+ false
+ true
+ true
+ $(WarningsNotAsErrors);NU1901;NU1902;NU1903;NU1904
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ runtime
+
+
+
+
+
+
+
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Authorization/PermissionEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Authorization/PermissionEntity.cs
index ba234131..7af46e9d 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/Authorization/PermissionEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Authorization/PermissionEntity.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Authorization/RoleEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Authorization/RoleEntity.cs
index 2d20d9e5..fb7bc6f4 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/Authorization/RoleEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Authorization/RoleEntity.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Authorization/UserAuthorizationEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Authorization/UserAuthorizationEntity.cs
index f7af1c16..18fae293 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/Authorization/UserAuthorizationEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Authorization/UserAuthorizationEntity.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
index 92edd6ec..ef17ab05 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanEntity.cs
index 90d454d7..989a8519 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanEntity.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs
index 81810acc..fa0788e9 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryScanResultEntity.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
index 101bf831..b526c7b5 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntity.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -19,6 +19,16 @@ public class BookEntity : IStorageEntity, IAuditableEntity
///
public required Guid Id { get; init; }
+ ///
+ /// Gets or sets the Id of the media library this book belongs to.
+ ///
+ public required Guid LibraryId { get; set; }
+
+ ///
+ /// Gets or sets the file system path of the book.
+ ///
+ public required string Path { get; set; }
+
///
/// Gets or sets the title of the media item.
///
@@ -195,6 +205,21 @@ public class BookEntity : IStorageEntity, IAuditableEntity
///
public List Ratings { get; set; } = [];
+ ///
+ /// Gets or sets the status of the metadata enrichment of the book.
+ ///
+ public MetadataStatus MetadataStatus { get; set; }
+
+ ///
+ /// Gets or sets the date and time when the metadata of the book was last enriched.
+ ///
+ public DateTime? LastMetadataUpdateUtc { get; set; }
+
+ ///
+ /// Gets or sets the name of the plugin that enriched the metadata of the book.
+ ///
+ public string? MetadataProvider { get; set; }
+
///
/// Gets or sets the time and date when the entity was added.
///
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs
index f272b2cb..13bbea63 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingEntity.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs
index 6a235202..7f5cc117 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntity.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Plugins/LibraryMetadataProviderConfigurationEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Plugins/LibraryMetadataProviderConfigurationEntity.cs
new file mode 100644
index 00000000..86d2b72e
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Plugins/LibraryMetadataProviderConfigurationEntity.cs
@@ -0,0 +1,59 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.Plugins;
+
+///
+/// Repository entity for the configuration of a metadata provider of a media library.
+///
+[DebuggerDisplay("LibraryId: {LibraryId}, PluginId: {PluginId}")]
+public class LibraryMetadataProviderConfigurationEntity : IStorageEntity, IAuditableEntity
+{
+ ///
+ /// Gets or sets the Id of the configuration.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets or sets the Id of the media library the configuration belongs to.
+ ///
+ public required Guid LibraryId { get; set; }
+
+ ///
+ /// Gets or sets the Id of the plugin providing the metadata.
+ ///
+ public required Guid PluginId { get; set; }
+
+ ///
+ /// Gets or sets whether the metadata provider is enabled for the media library.
+ ///
+ public required bool IsEnabled { get; set; }
+
+ ///
+ /// Gets or sets the rank of the metadata provider, determining the order in which providers are tried.
+ ///
+ public required int Rank { get; set; }
+
+ ///
+ /// Gets or sets the time and date when the entity was added.
+ ///
+ public required DateTime CreatedOnUtc { get; set; }
+
+ ///
+ /// Gets or sets the Id of the user that created the entity.
+ ///
+ public required Guid CreatedBy { get; set; }
+
+ ///
+ /// Gets or sets the optional time and date when the entity was updated.
+ ///
+ public DateTime? UpdatedOnUtc { get; set; }
+
+ ///
+ /// Gets or sets the optional Id of the user that updated the entity.
+ ///
+ public required Guid? UpdatedBy { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Plugins/PluginEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Plugins/PluginEntity.cs
new file mode 100644
index 00000000..5c2c6cf8
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Plugins/PluginEntity.cs
@@ -0,0 +1,75 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.Plugins;
+
+///
+/// Repository entity for a plugin.
+///
+[DebuggerDisplay("Name: {Name}")]
+public class PluginEntity : IStorageEntity, IAuditableEntity
+{
+ ///
+ /// Gets the Id of the plugin.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets or sets the display name of the plugin.
+ ///
+ public required string Name { get; set; }
+
+ ///
+ /// Gets or sets the author of the plugin.
+ ///
+ public required string Author { get; set; }
+
+ ///
+ /// Gets or sets the version of the plugin.
+ ///
+ public required string Version { get; set; }
+
+ ///
+ /// Gets or sets the description of the plugin.
+ ///
+ public required string Description { get; set; }
+
+ ///
+ /// Gets or sets the load status of the plugin.
+ ///
+ public PluginLoadStatus LoadStatus { get; set; }
+
+ ///
+ /// Gets or sets the error message when the plugin failed to load.
+ ///
+ public string? LoadError { get; set; }
+
+ ///
+ /// Gets or sets the serialized settings of the plugin.
+ ///
+ public string? SettingsJson { get; set; }
+
+ ///
+ /// Gets or sets the time and date when the entity was added.
+ ///
+ public required DateTime CreatedOnUtc { get; set; }
+
+ ///
+ /// Gets or sets the Id of the user that created the entity.
+ ///
+ public required Guid CreatedBy { get; set; }
+
+ ///
+ /// Gets or sets the optional time and date when the entity was updated.
+ ///
+ public DateTime? UpdatedOnUtc { get; set; }
+
+ ///
+ /// Gets or sets the optional Id of the user that updated the entity.
+ ///
+ public required Guid? UpdatedBy { get; set; }
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
index 6dbabc93..f6dba43d 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Books/IBookRepository.cs
@@ -1,7 +1,12 @@
#region ========================================================================= USING =====================================================================================
+using ErrorOr;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Books;
@@ -11,6 +16,43 @@ namespace Lumina.Application.Common.DataAccess.Repositories.Books;
///
public interface IBookRepository : IRepository,
IInsertRepositoryAction,
+ IUpdateRepositoryAction,
+ IGetByIdRepositoryAction,
IGetAllRepositoryAction
{
+ ///
+ /// Gets all the books of the media library identified by .
+ ///
+ /// The Id of the media library whose books are retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a collection of , or an error.
+ Task>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
+
+ ///
+ /// Gets the book of the media library identified by that is stored at the provided .
+ ///
+ /// The Id of the media library whose book is retrieved.
+ /// The file system path of the book to be retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the stored at the provided path, or an error.
+ Task> GetByPathAsync(Guid libraryId, string path, CancellationToken cancellationToken);
+
+ ///
+ /// Gets a page of the books of the media library identified by whose metadata has not been enriched yet,
+ /// ordered by path, using keyset pagination.
+ ///
+ /// The Id of the media library whose books are retrieved.
+ /// The path of the last retrieved book, used for keyset pagination. Pass to get the first page.
+ /// The maximum number of books to retrieve.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a page of books needing their metadata enriched, or an error.
+ Task>> GetBooksNeedingMetadataAsync(Guid libraryId, string? lastPath, int pageSize, CancellationToken cancellationToken);
+
+ ///
+ /// Gets the number of books of the media library identified by whose metadata has not been enriched yet.
+ ///
+ /// The Id of the media library whose books are counted.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the number of books needing their metadata enriched, or an error.
+ Task> GetBooksNeedingMetadataCountAsync(Guid libraryId, CancellationToken cancellationToken);
}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanRepository.cs
index 516c8289..54393d7e 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanRepository.cs
@@ -3,7 +3,7 @@ using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Threading;
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
index b8d260c9..a34e4692 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanSnapshotRepository.cs
@@ -24,6 +24,14 @@ public interface ILibraryScanSnapshotRepository : IRepositoryAn containing either a collection of deleted media library scan snapshot item paths, or an error.
Task>> GetDeletedPathsAsync(Guid libraryId, Guid scanId, CancellationToken cancellationToken);
+ ///
+ /// Gets the paths of all the media library scan snapshot items of the media library identified by .
+ ///
+ /// The unique identifier of the library whose media library scan snapshot item paths are retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a collection of media library scan snapshot item paths, or an error.
+ Task>> GetPathsAsync(Guid libraryId, CancellationToken cancellationToken);
+
///
/// Atomically applies the results of the current scan to the storage medium, by replacing the media library scan snapshot of the previous scan with the snapshot of the current scan.
/// The operation updates the changed media library scan snapshot items, deletes the ones that are no longer present on disk, adds audit entries for all changed, new and deleted items,
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs
index 14e22897..da52f84a 100644
--- a/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/MediaLibrary/ILibraryScanStagingResultsRepository.cs
@@ -3,7 +3,7 @@ using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
-using Lumina.Application.Common.Infrastructure.Models.MediaLibraryScanJobPayloads;
+using Lumina.Application.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -44,7 +44,7 @@ public interface ILibraryScanStagingResultsRepository : IRepositoryThe maximum number of staging results to retrieve.
/// Cancellation token that can be used to stop the execution.
/// An containing either a page of staging results that need hashing, or an error.
- Task>> GetFilesToHashPageAsync(Guid scanId, string? lastPath, int pageSize, CancellationToken cancellationToken);
+ Task>> GetFilesToHashPageAsync(Guid scanId, string? lastPath, int pageSize, CancellationToken cancellationToken);
///
/// Updates the content hashes of the provided media library scan staging results.
@@ -53,7 +53,7 @@ public interface ILibraryScanStagingResultsRepository : IRepositoryThe file system items whose content hashes are updated.
/// Cancellation token that can be used to stop the execution.
/// An representing either a successful operation, or an error.
- Task> UpdateFileHashesAsync(Guid scanId, IReadOnlyCollection hashedFiles, CancellationToken cancellationToken);
+ Task> UpdateFileHashesAsync(Guid scanId, IReadOnlyCollection hashedFiles, CancellationToken cancellationToken);
///
/// Clears all the media library scan staging results of the provided media library scan from the storage medium.
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Plugins/ILibraryMetadataProviderConfigurationRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Plugins/ILibraryMetadataProviderConfigurationRepository.cs
new file mode 100644
index 00000000..9eeadf0b
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Plugins/ILibraryMetadataProviderConfigurationRepository.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.Plugins;
+
+///
+/// Interface for the repository for the metadata provider configurations of media libraries.
+///
+public interface ILibraryMetadataProviderConfigurationRepository : IRepository
+{
+ ///
+ /// Gets all the metadata provider configurations of the media library identified by .
+ ///
+ /// The Id of the media library whose metadata provider configurations are retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a collection of , or an error.
+ Task>> GetByLibraryIdAsync(Guid libraryId, CancellationToken cancellationToken);
+
+ ///
+ /// Gets the metadata provider configuration of the media library identified by for the plugin identified by .
+ ///
+ /// The Id of the media library whose metadata provider configuration is retrieved.
+ /// The Id of the plugin whose metadata provider configuration is retrieved.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the , or an error.
+ Task> GetByLibraryAndPluginIdAsync(Guid libraryId, Guid pluginId, CancellationToken cancellationToken);
+
+ ///
+ /// Inserts the provided into the storage medium, or updates it when it already exists.
+ ///
+ /// The metadata provider configuration to insert or update.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> UpsertAsync(LibraryMetadataProviderConfigurationEntity configuration, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Plugins/IPluginRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Plugins/IPluginRepository.cs
new file mode 100644
index 00000000..142eb1ac
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Plugins/IPluginRepository.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.Plugins;
+
+///
+/// Interface for the repository for plugins.
+///
+public interface IPluginRepository : IRepository,
+ IGetByIdRepositoryAction,
+ IGetAllRepositoryAction
+{
+ ///
+ /// Inserts the provided into the storage medium, or updates it when it already exists.
+ ///
+ /// The plugin to insert or update.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> UpsertAsync(PluginEntity plugin, CancellationToken cancellationToken);
+
+ ///
+ /// Updates the settings of the plugin identified by .
+ ///
+ /// The Id of the plugin whose settings are updated.
+ /// The serialized settings of the plugin.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> UpdateSettingsAsync(Guid pluginId, string? settingsJson, CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Authorization/IAuthorizationService.cs b/src/Lumina.Application/Common/Infrastructure/Authorization/IAuthorizationService.cs
index 5dc68ac8..05d3c59c 100644
--- a/src/Lumina.Application/Common/Infrastructure/Authorization/IAuthorizationService.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Authorization/IAuthorizationService.cs
@@ -2,7 +2,7 @@
using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.Infrastructure.Authorization.Policies.Common.Base;
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/Configuration/MediaSettingsModel.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs
similarity index 80%
rename from src/Lumina.Application/Common/Infrastructure/Models/Configuration/MediaSettingsModel.cs
rename to src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs
index c851eb97..f68feee4 100644
--- a/src/Lumina.Application/Common/Infrastructure/Models/Configuration/MediaSettingsModel.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/MediaSettingsDto.cs
@@ -2,13 +2,13 @@
using System.Diagnostics;
#endregion
-namespace Lumina.Application.Common.Infrastructure.Models.Configuration;
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
///
-/// Model for deserializing media settings.
+/// Data transfer object for deserializing media settings.
///
[DebuggerDisplay("{SECTION_NAME}")]
-public class MediaSettingsModel
+public class MediaSettingsDto
{
public const string SECTION_NAME = "MediaSettings";
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/PluginsSettingsDto.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/PluginsSettingsDto.cs
new file mode 100644
index 00000000..b8baeafc
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Configuration/PluginsSettingsDto.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
+
+///
+/// Data transfer object for deserializing plugins settings.
+///
+[DebuggerDisplay("{SECTION_NAME}")]
+public class PluginsSettingsDto
+{
+ public const string SECTION_NAME = "PluginsSettings";
+
+ ///
+ /// Gets or sets the directory where the plugin assemblies are located.
+ ///
+ public required string Directory { get; init; }
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/FileSystem/FileSystemTreeNode.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/FileSystem/FileSystemTreeNodeDto.cs
similarity index 79%
rename from src/Lumina.Application/Common/Infrastructure/Models/FileSystem/FileSystemTreeNode.cs
rename to src/Lumina.Application/Common/Infrastructure/Models/DTO/FileSystem/FileSystemTreeNodeDto.cs
index e0e07f3b..b1851f29 100644
--- a/src/Lumina.Application/Common/Infrastructure/Models/FileSystem/FileSystemTreeNode.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/FileSystem/FileSystemTreeNodeDto.cs
@@ -1,16 +1,16 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
-namespace Lumina.Application.Common.Infrastructure.Models.FileSystem;
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.FileSystem;
///
/// Generic file system node.
///
[DebuggerDisplay("Path: {Path}")]
-public class FileSystemTreeNode
+public class FileSystemTreeNodeDto
{
///
/// Gets or sets the full path of the file or directory.
@@ -30,5 +30,5 @@ public class FileSystemTreeNode
///
/// Gets or sets the list of child nodes.
///
- public List Children { get; set; } = [];
+ public List Children { get; set; } = [];
}
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/HashedFileSystemFile.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/MediaLibraryScanJobPayloads/HashedFileSystemFileDto.cs
similarity index 78%
rename from src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/HashedFileSystemFile.cs
rename to src/Lumina.Application/Common/Infrastructure/Models/DTO/MediaLibraryScanJobPayloads/HashedFileSystemFileDto.cs
index 355b8b9d..3a12b1e7 100644
--- a/src/Lumina.Application/Common/Infrastructure/Models/MediaLibraryScanJobPayloads/HashedFileSystemFile.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/MediaLibraryScanJobPayloads/HashedFileSystemFileDto.cs
@@ -4,14 +4,14 @@ using System.Diagnostics;
using System.Runtime.InteropServices;
#endregion
-namespace Lumina.Application.Common.Infrastructure.Models.MediaLibraryScanJobPayloads;
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads;
///
/// Represents an item for the payload of the file hashing media library scan job.
///
[DebuggerDisplay("Path = {Path}, CurrentHash = {CurrentHash}, OldHash = {OldHash}, Ticks = {Ticks}, Size = {Size}")]
[StructLayout(LayoutKind.Sequential)]
-public struct HashedFileSystemFile : IEquatable
+public struct HashedFileSystemFileDto : IEquatable
{
///
/// The path of the file system file.
@@ -39,7 +39,7 @@ public struct HashedFileSystemFile : IEquatable
public long Ticks { get; set; }
///
- public readonly bool Equals(HashedFileSystemFile other)
+ public readonly bool Equals(HashedFileSystemFileDto other)
{
return Size == other.Size && CurrentHash == other.CurrentHash && OldHash == other.OldHash && Ticks == other.Ticks && Path == other.Path;
}
@@ -47,17 +47,17 @@ public struct HashedFileSystemFile : IEquatable
///
public override readonly bool Equals(object? obj)
{
- return obj is HashedFileSystemFile item && Equals(item);
+ return obj is HashedFileSystemFileDto item && Equals(item);
}
///
- public static bool operator ==(HashedFileSystemFile left, HashedFileSystemFile right)
+ public static bool operator ==(HashedFileSystemFileDto left, HashedFileSystemFileDto right)
{
return left.Equals(right);
}
///
- public static bool operator !=(HashedFileSystemFile left, HashedFileSystemFile right)
+ public static bool operator !=(HashedFileSystemFileDto left, HashedFileSystemFileDto right)
{
return !(left == right);
}
diff --git a/src/Lumina.Application/Common/Infrastructure/Plugins/IPluginManager.cs b/src/Lumina.Application/Common/Infrastructure/Plugins/IPluginManager.cs
new file mode 100644
index 00000000..8ef90497
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Plugins/IPluginManager.cs
@@ -0,0 +1,26 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Plugins.Contracts.Core.Plugins;
+using System;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Plugins;
+
+///
+/// Manager of the plugins loaded by the host application.
+///
+public interface IPluginManager
+{
+ ///
+ /// Gets the plugins that were loaded successfully.
+ ///
+ /// The collection of loaded plugins.
+ IReadOnlyList GetPlugins();
+
+ ///
+ /// Gets the plugin identified by .
+ ///
+ /// The unique identifier of the plugin.
+ /// The plugin, or when no plugin with the provided Id was loaded.
+ IPlugin? GetPlugin(Guid pluginId);
+}
diff --git a/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs b/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs
index 8d42f473..74284d33 100644
--- a/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Security/IFileHashService.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.Infrastructure.Models.MediaLibraryScanJobPayloads;
+using Lumina.Application.Common.Infrastructure.Models.DTO.MediaLibraryScanJobPayloads;
using System;
using System.Collections.Generic;
using System.Threading;
@@ -20,5 +20,5 @@ public interface IFileHashService
/// Callback to invoke during processing of elements.
/// Cancellation token that can be used to stop the execution.
/// A collection of the hashed files, along with their hashes.
- Task> HashFilesAsync(IReadOnlyCollection files, Func callback, CancellationToken cancellationToken);
+ Task> HashFilesAsync(IReadOnlyCollection files, Func callback, CancellationToken cancellationToken);
}
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs
index ce65db5c..211dba64 100644
--- a/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/Common/FileSystemTreeNodeResponseMapping.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
#endregion
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs
index ade9cffa..3a43c1db 100644
--- a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/UnixRootItemMapping.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using System.Linq;
diff --git a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs
index 68666b1d..fce96250 100644
--- a/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/FileSystemManagement/FileSystem/WindowsRootItemMapping.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
#endregion
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
index 75673944..8e74f24c 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
@@ -2,7 +2,7 @@
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
using Lumina.Contracts.Requests.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
#endregion
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
index f0f436d8..37aed932 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestMapping.cs
@@ -19,6 +19,8 @@ public static class AddBookRequestMapping
public static AddBookCommand ToCommand(this AddBookRequest request)
{
return new AddBookCommand(
+ request.LibraryId,
+ request.Path,
request.Metadata,
request.Format,
request.Edition,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
index cb759693..6d6f0e0c 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookEntityMapping.cs
@@ -7,12 +7,13 @@ using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookL
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -110,6 +111,8 @@ public static class BookEntityMapping
return Book.Create(
BookId.Create(repositoryEntity.Id),
+ LibraryId.Create(repositoryEntity.LibraryId),
+ repositoryEntity.Path,
writtenContentMetadataResult.Value,
bookFormat,
Optional.FromNullable(repositoryEntity.Edition),
@@ -190,6 +193,8 @@ public static class BookEntityMapping
);
return new BookResponse(
repositoryEntity.Id,
+ repositoryEntity.LibraryId,
+ repositoryEntity.Path,
metadata,
repositoryEntity.Format,
repositoryEntity.Edition,
@@ -207,6 +212,9 @@ public static class BookEntityMapping
[.. repositoryEntity.ISBNs.ToResponses()],
null,
[.. repositoryEntity.Ratings.ToResponses()],
+ repositoryEntity.MetadataStatus,
+ repositoryEntity.LastMetadataUpdateUtc,
+ repositoryEntity.MetadataProvider,
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
index 04b10163..6738c03b 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMapping.cs
@@ -24,6 +24,8 @@ public static class BookMapping
return new BookEntity
{
Id = domainEntity.Id.Value,
+ LibraryId = domainEntity.LibraryId.Value,
+ Path = domainEntity.Path,
Title = domainEntity.Metadata.Title,
OriginalTitle = domainEntity.Metadata.OriginalTitle.HasValue ? domainEntity.Metadata.OriginalTitle.Value : null,
Description = domainEntity.Metadata.Description.HasValue ? domainEntity.Metadata.Description.Value : null,
@@ -57,6 +59,9 @@ public static class BookMapping
AppleBooksId = domainEntity.AppleBooksId.HasValue ? domainEntity.AppleBooksId.Value : null,
ISBNs = domainEntity.ISBNs.ToRepositoryEntities().ToList(),
Ratings = domainEntity.Ratings.ToRepositoryEntities().ToList(),
+ MetadataStatus = domainEntity.MetadataStatus,
+ LastMetadataUpdateUtc = domainEntity.LastMetadataUpdateUtc.HasValue ? domainEntity.LastMetadataUpdateUtc.Value : null,
+ MetadataProvider = domainEntity.MetadataProvider.HasValue ? domainEntity.MetadataProvider.Value : null,
CreatedOnUtc = domainEntity.CreatedOnUtc,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMapping.cs
new file mode 100644
index 00000000..0e8fa631
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookMetadataDtoMapping.cs
@@ -0,0 +1,137 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Common.ValueObjects.Metadata;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Extension methods for applying to .
+///
+public static class BookMetadataDtoMapping
+{
+ ///
+ /// Applies the metadata of to , marking its metadata as enriched by the provided .
+ ///
+ /// The domain book to which the metadata is applied.
+ /// The metadata to be applied.
+ /// The name of the metadata provider that enriched the book.
+ /// The date and time when the metadata was enriched.
+ /// An representing either a successful operation, or an error.
+ public static ErrorOr ApplyMetadata(this Book book, BookMetadataDto metadata, string providerName, DateTime lastUpdateUtc)
+ {
+ if (string.IsNullOrWhiteSpace(metadata.Title))
+ return Domain.SharedKernel.Common.Errors.Errors.Metadata.TitleCannotBeEmpty;
+ if (metadata.ReleaseInfo is null)
+ return Domain.SharedKernel.Common.Errors.Errors.Metadata.ReleaseInfoCannotBeNull;
+
+ ErrorOr releaseInfoResult = ReleaseInfo.Create(
+ Optional.FromNullable(metadata.ReleaseInfo.OriginalReleaseDate),
+ Optional.FromNullable(metadata.ReleaseInfo.OriginalReleaseYear),
+ Optional.FromNullable(metadata.ReleaseInfo.ReReleaseDate),
+ Optional.FromNullable(metadata.ReleaseInfo.ReReleaseYear),
+ Optional.FromNullable(metadata.ReleaseInfo.ReleaseCountry),
+ Optional.FromNullable(metadata.ReleaseInfo.ReleaseVersion)
+ );
+ if (releaseInfoResult.IsError)
+ return releaseInfoResult.Errors;
+
+ List> domainGenresResult = metadata.Genres is not null
+ ? [.. metadata.Genres.Select(genre => Genre.Create(genre.Name))]
+ : [];
+ List genresErrors = [.. domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors)];
+ if (genresErrors.Count != 0)
+ return genresErrors;
+
+ List> domainTagsResult = metadata.Tags is not null
+ ? [.. metadata.Tags.Select(tag => Tag.Create(tag.Name))]
+ : [];
+ List tagsErrors = [.. domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors)];
+ if (tagsErrors.Count != 0)
+ return tagsErrors;
+
+ Optional languageInfo = Optional.None();
+ if (metadata.Language is not null)
+ {
+ ErrorOr languageInfoResult = LanguageInfo.Create(metadata.Language.LanguageCode, metadata.Language.LanguageName, Optional.FromNullable(metadata.Language.NativeName));
+ if (languageInfoResult.IsError)
+ return languageInfoResult.Errors;
+ languageInfo = languageInfoResult.Value;
+ }
+
+ Optional originalLanguageInfo = Optional.None();
+ if (metadata.OriginalLanguage is not null)
+ {
+ ErrorOr originalLanguageInfoResult = LanguageInfo.Create(metadata.OriginalLanguage.LanguageCode, metadata.OriginalLanguage.LanguageName, Optional.FromNullable(metadata.OriginalLanguage.NativeName));
+ if (originalLanguageInfoResult.IsError)
+ return originalLanguageInfoResult.Errors;
+ originalLanguageInfo = originalLanguageInfoResult.Value;
+ }
+
+ ErrorOr writtenContentMetadataResult = WrittenContentMetadata.Create(
+ metadata.Title,
+ Optional.FromNullable(metadata.OriginalTitle),
+ Optional.FromNullable(metadata.Description),
+ releaseInfoResult.Value,
+ [.. domainGenresResult.Select(genreResult => genreResult.Value)],
+ [.. domainTagsResult.Select(tagResult => tagResult.Value)],
+ languageInfo,
+ originalLanguageInfo,
+ Optional.FromNullable(metadata.Publisher),
+ Optional.FromNullable(metadata.PageCount)
+ );
+ if (writtenContentMetadataResult.IsError)
+ return writtenContentMetadataResult.Errors;
+
+ List> domainIsbnsResult = metadata.Isbns is not null
+ ? [.. metadata.Isbns.Where(isbn => isbn.Value is not null && isbn.Format is not null).Select(isbn => Isbn.Create(isbn.Value, (IsbnFormat)(int)isbn.Format!.Value))]
+ : [];
+ List isbnsErrors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors)];
+ if (isbnsErrors.Count != 0)
+ return isbnsErrors;
+
+ List> domainRatingsResult = metadata.Ratings is not null
+ ? [.. metadata.Ratings.Where(rating => rating.Value is not null && rating.MaxValue is not null).Select(rating => BookRating.Create(
+ rating.Value!.Value,
+ rating.MaxValue!.Value,
+ Optional.FromNullable((BookRatingSource?)(rating.Source is null ? null : (BookRatingSource)(int)rating.Source.Value)),
+ Optional.FromNullable(rating.VoteCount)
+ ))]
+ : [];
+ List ratingsErrors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors)];
+ if (ratingsErrors.Count != 0)
+ return ratingsErrors;
+
+ book.ApplyEnrichedMetadata(
+ writtenContentMetadataResult.Value,
+ Optional.FromNullable(metadata.Format.HasValue ? (BookFormat)(int)metadata.Format.Value : (BookFormat?)null),
+ Optional.FromNullable(metadata.Edition),
+ Optional.FromNullable(metadata.VolumeNumber),
+ Optional.None(),
+ Optional.FromNullable(metadata.ASIN),
+ Optional.FromNullable(metadata.GoodreadsId),
+ Optional.FromNullable(metadata.LCCN),
+ Optional.FromNullable(metadata.OCLCNumber),
+ Optional.FromNullable(metadata.OpenLibraryId),
+ Optional.FromNullable(metadata.LibraryThingId),
+ Optional.FromNullable(metadata.GoogleBooksId),
+ Optional.FromNullable(metadata.BarnesAndNobleId),
+ Optional.FromNullable(metadata.AppleBooksId),
+ [.. domainIsbnsResult.Select(isbnResult => isbnResult.Value)],
+ [.. domainRatingsResult.Select(ratingResult => ratingResult.Value)],
+ providerName,
+ lastUpdateUtc
+ );
+
+ return Result.Success;
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequestMapping.cs
new file mode 100644
index 00000000..0bde6e3f
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
+using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Extension methods for converting .
+///
+public static class GetBooksRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetBooksQuery ToQuery(this GetBooksRequest request)
+ {
+ return new GetBooksQuery(request.LibraryId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs
index 2e98fe35..84ab6502 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingDtoMapping.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
using System.Collections.Generic;
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs
index 3ec0bf7f..d5ffcfbb 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/BookRatingEntityMapping.cs
@@ -2,7 +2,7 @@
using ErrorOr;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
using System.Collections.Generic;
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs
index 0a66285f..61ace5df 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/WrittenContentLibrary/BookLibrary/Common/IsbnDtoMapping.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/GetLibraryMetadataProvidersRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/GetLibraryMetadataProvidersRequestMapping.cs
new file mode 100644
index 00000000..e14f4dab
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/GetLibraryMetadataProvidersRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
+using Lumina.Contracts.Requests.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class GetLibraryMetadataProvidersRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetLibraryMetadataProvidersQuery ToQuery(this GetLibraryMetadataProvidersRequest request)
+ {
+ return new GetLibraryMetadataProvidersQuery(request.LibraryId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/GetPluginSettingsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/GetPluginSettingsRequestMapping.cs
new file mode 100644
index 00000000..8f196830
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/GetPluginSettingsRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Plugins.Queries.GetPluginSettings;
+using Lumina.Contracts.Requests.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class GetPluginSettingsRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetPluginSettingsQuery ToQuery(this GetPluginSettingsRequest request)
+ {
+ return new GetPluginSettingsQuery(request.PluginId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/LibraryMetadataProviderConfigurationEntityMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/LibraryMetadataProviderConfigurationEntityMapping.cs
new file mode 100644
index 00000000..a1c7805b
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/LibraryMetadataProviderConfigurationEntityMapping.cs
@@ -0,0 +1,28 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Contracts.Responses.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class LibraryMetadataProviderConfigurationEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The display name of the metadata provider.
+ /// The converted response.
+ public static LibraryMetadataProviderResponse ToResponse(this LibraryMetadataProviderConfigurationEntity configuration, string providerName)
+ {
+ return new LibraryMetadataProviderResponse(
+ configuration.PluginId,
+ providerName,
+ configuration.IsEnabled,
+ configuration.Rank
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/PluginEntityMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/PluginEntityMapping.cs
new file mode 100644
index 00000000..4864cae7
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/PluginEntityMapping.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Contracts.Responses.Plugins;
+using System.Collections.Generic;
+using System.Text.Json;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class PluginEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted response.
+ public static PluginResponse ToResponse(this PluginEntity pluginEntity)
+ {
+ return new PluginResponse(
+ pluginEntity.Id,
+ pluginEntity.Name,
+ pluginEntity.Author,
+ pluginEntity.Version,
+ pluginEntity.Description,
+ pluginEntity.LoadStatus,
+ pluginEntity.LoadError,
+ pluginEntity.ToSettings()
+ );
+ }
+
+ ///
+ /// Deserializes the settings of .
+ ///
+ /// The repository entity whose settings are deserialized.
+ /// The deserialized settings, or when no settings are stored.
+ public static IReadOnlyDictionary? ToSettings(this PluginEntity pluginEntity)
+ {
+ if (pluginEntity.SettingsJson is null)
+ return null;
+ return JsonSerializer.Deserialize>(pluginEntity.SettingsJson);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/PluginSettingDescriptorMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/PluginSettingDescriptorMapping.cs
new file mode 100644
index 00000000..f454a490
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/PluginSettingDescriptorMapping.cs
@@ -0,0 +1,29 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Responses.Plugins;
+using Lumina.Plugins.Contracts.Common.Models.DTO.Settings;
+using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class PluginSettingDescriptorMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The plugin contract setting descriptor to be converted.
+ /// The converted response.
+ public static PluginSettingDescriptorResponse ToResponse(this PluginSettingDescriptorDto descriptor)
+ {
+ return new PluginSettingDescriptorResponse(
+ descriptor.Key,
+ descriptor.Label,
+ (PluginSettingType)(int)descriptor.Type,
+ descriptor.DefaultValue,
+ descriptor.AllowedValues
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/ReorderLibraryMetadataProvidersRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/ReorderLibraryMetadataProvidersRequestMapping.cs
new file mode 100644
index 00000000..6857df1e
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/ReorderLibraryMetadataProvidersRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
+using Lumina.Contracts.Requests.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class ReorderLibraryMetadataProvidersRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static ReorderLibraryMetadataProvidersCommand ToCommand(this ReorderLibraryMetadataProvidersRequest request)
+ {
+ return new ReorderLibraryMetadataProvidersCommand(request.LibraryId, request.PluginIds);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/SetLibraryMetadataProviderEnabledRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/SetLibraryMetadataProviderEnabledRequestMapping.cs
new file mode 100644
index 00000000..a0b46032
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/SetLibraryMetadataProviderEnabledRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
+using Lumina.Contracts.Requests.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class SetLibraryMetadataProviderEnabledRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static SetLibraryMetadataProviderEnabledCommand ToCommand(this SetLibraryMetadataProviderEnabledRequest request)
+ {
+ return new SetLibraryMetadataProviderEnabledCommand(request.LibraryId, request.PluginId, request.IsEnabled);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Plugins/UpdatePluginSettingsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Plugins/UpdatePluginSettingsRequestMapping.cs
new file mode 100644
index 00000000..6e8f1930
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Plugins/UpdatePluginSettingsRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
+using Lumina.Contracts.Requests.Plugins;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Plugins;
+
+///
+/// Extension methods for converting .
+///
+public static class UpdatePluginSettingsRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static UpdatePluginSettingsCommand ToCommand(this UpdatePluginSettingsRequest request)
+ {
+ return new UpdatePluginSettingsCommand(request.PluginId, request.Settings);
+ }
+}
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
index 95253b8f..f7012600 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Directories/Queries/GetDirectories/GetDirectoriesQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
index 2b15eef1..0e1a77ce 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetFiles/GetFilesQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryValidator.cs
index 59e2480e..efbedf60 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Files/Queries/GetTreeFiles/GetTreeFilesQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/CombinePath/CombinePathCommandValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/CombinePath/CombinePathCommandValidator.cs
index 506ff300..4d02f302 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/CombinePath/CombinePathCommandValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/CombinePath/CombinePathCommandValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/SplitPath/SplitPathCommandValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/SplitPath/SplitPathCommandValidator.cs
index 803d26c9..897c6e4d 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/SplitPath/SplitPathCommandValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Commands/SplitPath/SplitPathCommandValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryValidator.cs
index 4a0d92ad..0cca72a6 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/CheckPathExists/CheckPathExistsQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathParent/GetPathParentQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathParent/GetPathParentQueryValidator.cs
index 1731feff..c74379da 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathParent/GetPathParentQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathParent/GetPathParentQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathRoot/GetPathRootQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathRoot/GetPathRootQueryValidator.cs
index b8987d05..a3b6043a 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathRoot/GetPathRootQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/GetPathRoot/GetPathRootQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/ValidatePath/ValidatePathQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/ValidatePath/ValidatePathQueryValidator.cs
index 3395155e..7740d025 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/ValidatePath/ValidatePathQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Paths/Queries/ValidatePath/ValidatePathQueryValidator.cs
@@ -1,6 +1,6 @@
-#region ========================================================================= USING =====================================================================================
+#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
diff --git a/src/Lumina.Application/Core/FileSystemManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryValidator.cs b/src/Lumina.Application/Core/FileSystemManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryValidator.cs
index 9f9dcf13..c43cd478 100644
--- a/src/Lumina.Application/Core/FileSystemManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryValidator.cs
+++ b/src/Lumina.Application/Core/FileSystemManagement/Thumbnails/Queries/GetThumbnail/GetThumbnailQueryValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
index 0083ff4d..36f8bbcc 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
@@ -8,9 +8,9 @@ using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.Authorization;
-using Lumina.Domain.Common.Enums.MediaLibrary;
-using Lumina.Domain.Common.Enums.PhotoLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
@@ -21,7 +21,7 @@ using System;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
index 21453bb6..8a82e5cf 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Enums.MediaLibrary;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandHandler.cs
index 56f4ef7f..f0e7a489 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandHandler.cs
@@ -13,7 +13,7 @@ using Mediator;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibraryScan;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandValidator.cs
index a2fcc2f9..63d94dc0 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/CancelLibraryScan/CancelLibraryScanCommandValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandHandler.cs
index 64cc22a8..998e77b2 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandHandler.cs
@@ -13,7 +13,7 @@ using Mediator;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.DeleteLibrary;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandValidator.cs
index 6402b54e..af95943b 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/DeleteLibrary/DeleteLibraryCommandValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandHandler.cs
index 472cd2ea..3c25cd1d 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandHandler.cs
@@ -20,7 +20,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandValidator.cs
index 6527d2b0..8a91302e 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/ScanLibrary/ScanLibraryCommandValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
index f7974192..fc69d35e 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
@@ -8,9 +8,9 @@ using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.Authorization;
-using Lumina.Domain.Common.Enums.MediaLibrary;
-using Lumina.Domain.Common.Enums.PhotoLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
using Lumina.Domain.Common.Events;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
@@ -24,7 +24,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
index 3318eb0b..430b5b5c 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Enums.MediaLibrary;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandler.cs
index b9f9bb90..7f7e91eb 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryDeletedDomainEventHandler.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Application.Common.Infrastructure.Models.Configuration;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
@@ -22,15 +22,15 @@ public class LibraryDeletedDomainEventHandler : INotificationHandler
/// Initializes a new instance of the class.
///
/// Injected facade service for environment contextual services.
/// Injected service for handling file system paths.
- /// Injected service for retrieving .
- public LibraryDeletedDomainEventHandler(IEnvironmentContext environmentContext, IPathService pathService, IOptions mediaSettingsModelOptions)
+ /// Injected service for retrieving .
+ public LibraryDeletedDomainEventHandler(IEnvironmentContext environmentContext, IPathService pathService, IOptions mediaSettingsModelOptions)
{
_environmentContext = environmentContext;
_pathService = pathService;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs
index 7028f53c..08f2cb79 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibrarySavedDomainEventHandler.cs
@@ -2,10 +2,9 @@
using ErrorOr;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
-using Lumina.Application.Common.Infrastructure.Models.Configuration;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.PhotoLibrary;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
@@ -18,6 +17,7 @@ using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Events;
@@ -30,7 +30,7 @@ public class LibrarySavedDomainEventHandler : INotificationHandler
/// Initializes a new instance of the class.
@@ -38,12 +38,12 @@ public class LibrarySavedDomainEventHandler : INotificationHandlerInjected unit of work for interacting with the data access layer repositories.
/// Injected facade service for environment contextual services.
/// Injected service for handling file system paths.
- /// Injected service for retrieving .
+ /// Injected service for retrieving .
public LibrarySavedDomainEventHandler(
IUnitOfWork unitOfWork,
IEnvironmentContext environmentContext,
IPathService pathService,
- IOptions mediaSettingsModelOptions)
+ IOptions mediaSettingsModelOptions)
{
_unitOfWork = unitOfWork;
_environmentContext = environmentContext;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandler.cs
index d22c19a0..3137958f 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanCancelledDomainEventHandler.cs
@@ -4,7 +4,7 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandler.cs
index e202ef87..a6b68baa 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFailedDomainEventHandler.cs
@@ -5,7 +5,7 @@ using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Progress;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandler.cs
index 19094896..79726cea 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Events/LibraryScanFinishedDomainEventHandler.cs
@@ -5,7 +5,7 @@ using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Progress;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using Lumina.Domain.Common.Exceptions;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryHandler.cs
index ade05822..d5aeff9a 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryHandler.cs
@@ -7,12 +7,12 @@ using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using Mediator;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibrary;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryValidator.cs
index b74b396c..73a0470f 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibrary/GetLibraryQueryValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryHandler.cs
index 71cec463..55803489 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryHandler.cs
@@ -7,7 +7,7 @@ using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
@@ -15,7 +15,7 @@ using Mediator;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryScanProgress;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryValidator.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryValidator.cs
index c68edca1..1077627a 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryScanProgress/GetLibraryScanProgressQueryValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs
index 707d829f..9b04da3d 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommand.cs
@@ -1,8 +1,9 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Mediator;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using Lumina.Contracts.DTO.MediaContributors;
@@ -15,6 +16,8 @@ namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrar
///
/// Command for adding a book.
///
+/// The Id of the media library this book belongs to.
+/// The file system path of the book.
/// Written content metadata of the book.
/// The format of the book (e.g., Hardcover, Paperback), if applicable.
/// The edition of the book, if applicable.
@@ -32,8 +35,10 @@ namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrar
/// The list of ISBN (International Standard Book Number) of the book.
/// The list of media contributors (actors, directors, etc) starring in this book.
/// The list of ratings for this book.
-[DebuggerDisplay("Title: {Title}")]
+[DebuggerDisplay("Title: {Metadata.Title}")]
public record AddBookCommand(
+ Guid LibraryId,
+ string Path,
WrittenContentMetadataDto? Metadata,
BookFormat? Format,
string? Edition,
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs
index 2e44ac44..e7bb8234 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandHandler.cs
@@ -4,7 +4,7 @@ using Lumina.Application.Common.DataAccess.Repositories.Books;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Common.ValueObjects.Metadata;
@@ -12,6 +12,7 @@ using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaCon
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Mediator;
using System;
using System.Collections.Generic;
@@ -139,6 +140,8 @@ public class AddBookCommandHandler : IRequestHandler createBookResult = Book.Create(
+ LibraryId.Create(request.LibraryId),
+ request.Path,
metadataResult.Value,
Optional.FromNullable(request.Format),
Optional.FromNullable(request.Edition),
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs
index 631c49ee..169a8424 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBook/AddBookCommandValidator.cs
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Enums.BookLibrary;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Errors;
#endregion
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
@@ -16,6 +16,10 @@ public class AddBookCommandValidator : AbstractValidator
///
public AddBookCommandValidator()
{
+ RuleFor(x => x.LibraryId)
+ .NotEmpty().WithMessage(Errors.WrittenContent.BookLibraryCannotBeNull.Description);
+ RuleFor(x => x.Path)
+ .NotEmpty().WithMessage(Errors.WrittenContent.BookPathCannotBeEmpty.Description);
RuleFor(x => x.Metadata)
.NotNull().WithMessage(Errors.Metadata.MetadataCannotBeNull.Description)
.ChildRules(metadata =>
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs
index 85fe67f8..a70060c9 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQuery.cs
@@ -2,12 +2,16 @@
using ErrorOr;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Mediator;
+using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
///
-/// Query for getting all books.
+/// Query for getting all the books of a media library.
///
-public record class GetBooksQuery() : IRequest>>;
+/// The Id of the media library whose books are retrieved.
+public record GetBooksQuery(
+ Guid LibraryId
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs
index 826ddac7..6f1af200 100644
--- a/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryHandler.cs
@@ -41,8 +41,8 @@ public class GetBooksQueryHandler : IRequestHandler();
- // get all books from the book repository
- ErrorOr> getBooksResult = await bookRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
+ // get all books of the media library from the book repository
+ ErrorOr> getBooksResult = await bookRepository.GetByLibraryIdAsync(request.LibraryId, cancellationToken).ConfigureAwait(false);
return getBooksResult.Match(result => ErrorOrFactory.From(getBooksResult.Value.ToResponses()), errors => errors);
}
}
diff --git a/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommand.cs b/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommand.cs
new file mode 100644
index 00000000..1a695d7e
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommand.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Mediator;
+using System;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
+
+///
+/// Command for reordering the metadata providers of a media library.
+///
+/// The Id of the media library whose metadata providers are reordered.
+/// The plugin Ids in the new order, from highest to lowest rank.
+public record ReorderLibraryMetadataProvidersCommand(
+ Guid LibraryId,
+ IReadOnlyList PluginIds
+) : IRequest>;
diff --git a/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommandHandler.cs b/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommandHandler.cs
new file mode 100644
index 00000000..1c1a2034
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommandHandler.cs
@@ -0,0 +1,63 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.UoW;
+using Mediator;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
+
+///
+/// Handler for the command to reorder the metadata providers of a media library.
+///
+public class ReorderLibraryMetadataProvidersCommandHandler : IRequestHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public ReorderLibraryMetadataProvidersCommandHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the command to reorder the metadata providers of a media library.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An representing either a successful operation, or an error.
+ ///
+ public async ValueTask> Handle(ReorderLibraryMetadataProvidersCommand request, CancellationToken cancellationToken)
+ {
+ ILibraryMetadataProviderConfigurationRepository configurationRepository = _unitOfWork.GetRepository();
+ ErrorOr> getConfigurationsResult = await configurationRepository.GetByLibraryIdAsync(request.LibraryId, cancellationToken).ConfigureAwait(false);
+ if (getConfigurationsResult.IsError)
+ return getConfigurationsResult.Errors;
+
+ Dictionary configurationsByPluginId = getConfigurationsResult.Value.ToDictionary(configuration => configuration.PluginId);
+ for (int rank = 0; rank < request.PluginIds.Count; rank++)
+ {
+ Guid pluginId = request.PluginIds[rank];
+ if (configurationsByPluginId.TryGetValue(pluginId, out LibraryMetadataProviderConfigurationEntity? configuration))
+ {
+ configuration.Rank = rank + 1;
+ ErrorOr upsertResult = await configurationRepository.UpsertAsync(configuration, cancellationToken).ConfigureAwait(false);
+ if (upsertResult.IsError)
+ return upsertResult.Errors;
+ }
+ }
+
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ return Result.Success;
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommandValidator.cs b/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommandValidator.cs
new file mode 100644
index 00000000..aff5200e
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/ReorderLibraryMetadataProviders/ReorderLibraryMetadataProvidersCommandValidator.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using FluentValidation;
+using Lumina.Domain.SharedKernel.Common.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
+
+///
+/// Validates the needed validation rules for .
+///
+public class ReorderLibraryMetadataProvidersCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ReorderLibraryMetadataProvidersCommandValidator()
+ {
+ RuleFor(x => x.LibraryId)
+ .NotEmpty().WithMessage(Errors.Plugins.LibraryIdCannotBeEmpty.Description);
+ RuleFor(x => x.PluginIds)
+ .NotNull().WithMessage(Errors.Plugins.PluginIdsListCannotBeNull.Description)
+ .NotEmpty().WithMessage(Errors.Plugins.PluginIdsListCannotBeEmpty.Description);
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommand.cs b/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommand.cs
new file mode 100644
index 00000000..b0e98e20
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommand.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Mediator;
+using System;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
+
+///
+/// Command for enabling or disabling a metadata provider for a media library.
+///
+/// The Id of the media library whose metadata provider is enabled or disabled.
+/// The unique identifier of the plugin providing the metadata.
+/// Whether the metadata provider should be enabled for the media library.
+public record SetLibraryMetadataProviderEnabledCommand(
+ Guid LibraryId,
+ Guid PluginId,
+ bool IsEnabled
+) : IRequest>;
diff --git a/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommandHandler.cs b/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommandHandler.cs
new file mode 100644
index 00000000..3d4be916
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommandHandler.cs
@@ -0,0 +1,79 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.UoW;
+using Mediator;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
+
+///
+/// Handler for the command to enable or disable a metadata provider for a media library.
+///
+public class SetLibraryMetadataProviderEnabledCommandHandler : IRequestHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public SetLibraryMetadataProviderEnabledCommandHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the command to enable or disable a metadata provider for a media library.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An representing either a successful operation, or an error.
+ ///
+ public async ValueTask> Handle(SetLibraryMetadataProviderEnabledCommand request, CancellationToken cancellationToken)
+ {
+ ILibraryMetadataProviderConfigurationRepository configurationRepository = _unitOfWork.GetRepository();
+ ErrorOr getConfigurationResult = await configurationRepository.GetByLibraryAndPluginIdAsync(request.LibraryId, request.PluginId, cancellationToken).ConfigureAwait(false);
+ if (getConfigurationResult.IsError)
+ return getConfigurationResult.Errors;
+
+ LibraryMetadataProviderConfigurationEntity configuration;
+ if (getConfigurationResult.Value is not null)
+ {
+ configuration = getConfigurationResult.Value;
+ configuration.IsEnabled = request.IsEnabled;
+ }
+ else
+ {
+ // compute the rank to assign to the new configuration, appending it after the existing ones
+ ErrorOr> getConfigurationsResult = await configurationRepository.GetByLibraryIdAsync(request.LibraryId, cancellationToken).ConfigureAwait(false);
+ if (getConfigurationsResult.IsError)
+ return getConfigurationsResult.Errors;
+ int nextRank = getConfigurationsResult.Value.Count == 0 ? 1 : getConfigurationsResult.Value.Max(configuration => configuration.Rank) + 1;
+ configuration = new LibraryMetadataProviderConfigurationEntity
+ {
+ Id = Guid.NewGuid(),
+ LibraryId = request.LibraryId,
+ PluginId = request.PluginId,
+ IsEnabled = request.IsEnabled,
+ Rank = nextRank,
+ CreatedOnUtc = default,
+ CreatedBy = default,
+ UpdatedBy = default
+ };
+ }
+
+ ErrorOr upsertResult = await configurationRepository.UpsertAsync(configuration, cancellationToken).ConfigureAwait(false);
+ if (upsertResult.IsError)
+ return upsertResult.Errors;
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ return Result.Success;
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommandValidator.cs b/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommandValidator.cs
new file mode 100644
index 00000000..fc27be68
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/SetLibraryMetadataProviderEnabled/SetLibraryMetadataProviderEnabledCommandValidator.cs
@@ -0,0 +1,23 @@
+#region ========================================================================= USING =====================================================================================
+using FluentValidation;
+using Lumina.Domain.SharedKernel.Common.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
+
+///
+/// Validates the needed validation rules for .
+///
+public class SetLibraryMetadataProviderEnabledCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public SetLibraryMetadataProviderEnabledCommandValidator()
+ {
+ RuleFor(x => x.LibraryId)
+ .NotEmpty().WithMessage(Errors.Plugins.LibraryIdCannotBeEmpty.Description);
+ RuleFor(x => x.PluginId)
+ .NotEmpty().WithMessage(Errors.Plugins.PluginIdCannotBeEmpty.Description);
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommand.cs b/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommand.cs
new file mode 100644
index 00000000..e160d675
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommand.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Mediator;
+using System;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
+
+///
+/// Command for updating the settings of a plugin.
+///
+/// The unique identifier of the plugin.
+/// The settings of the plugin.
+public record UpdatePluginSettingsCommand(
+ Guid PluginId,
+ IReadOnlyDictionary? Settings
+) : IRequest>;
diff --git a/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommandHandler.cs b/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommandHandler.cs
new file mode 100644
index 00000000..e97a118b
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommandHandler.cs
@@ -0,0 +1,47 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.UoW;
+using Mediator;
+using System.Text.Json;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
+
+///
+/// Handler for the command to update the settings of a plugin.
+///
+public class UpdatePluginSettingsCommandHandler : IRequestHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public UpdatePluginSettingsCommandHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the command to update the settings of a plugin.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An representing either a successful operation, or an error.
+ ///
+ public async ValueTask> Handle(UpdatePluginSettingsCommand request, CancellationToken cancellationToken)
+ {
+ IPluginRepository pluginRepository = _unitOfWork.GetRepository();
+ string? settingsJson = request.Settings is not null ? JsonSerializer.Serialize(request.Settings) : null;
+ ErrorOr updateResult = await pluginRepository.UpdateSettingsAsync(request.PluginId, settingsJson, cancellationToken).ConfigureAwait(false);
+ if (updateResult.IsError)
+ return updateResult.Errors;
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ return Result.Success;
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommandValidator.cs b/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommandValidator.cs
new file mode 100644
index 00000000..454fcfec
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Commands/UpdatePluginSettings/UpdatePluginSettingsCommandValidator.cs
@@ -0,0 +1,21 @@
+#region ========================================================================= USING =====================================================================================
+using FluentValidation;
+using Lumina.Domain.SharedKernel.Common.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
+
+///
+/// Validates the needed validation rules for .
+///
+public class UpdatePluginSettingsCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public UpdatePluginSettingsCommandValidator()
+ {
+ RuleFor(x => x.PluginId)
+ .NotEmpty().WithMessage(Errors.Plugins.PluginIdCannotBeEmpty.Description);
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Queries/GetLibraryMetadataProviders/GetLibraryMetadataProvidersQuery.cs b/src/Lumina.Application/Core/Plugins/Queries/GetLibraryMetadataProviders/GetLibraryMetadataProvidersQuery.cs
new file mode 100644
index 00000000..e73ecb00
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Queries/GetLibraryMetadataProviders/GetLibraryMetadataProvidersQuery.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.Plugins;
+using Mediator;
+using System;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
+
+///
+/// Query for getting the metadata providers configured for a media library.
+///
+/// The Id of the media library whose metadata providers are retrieved.
+public record GetLibraryMetadataProvidersQuery(
+ Guid LibraryId
+) : IRequest>>;
diff --git a/src/Lumina.Application/Core/Plugins/Queries/GetLibraryMetadataProviders/GetLibraryMetadataProvidersQueryHandler.cs b/src/Lumina.Application/Core/Plugins/Queries/GetLibraryMetadataProviders/GetLibraryMetadataProvidersQueryHandler.cs
new file mode 100644
index 00000000..46e89a7a
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Queries/GetLibraryMetadataProviders/GetLibraryMetadataProvidersQueryHandler.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Mapping.Plugins;
+using Lumina.Contracts.Responses.Plugins;
+using Mediator;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
+
+///
+/// Handler for the query to get the metadata providers configured for a media library.
+///
+public class GetLibraryMetadataProvidersQueryHandler : IRequestHandler>>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public GetLibraryMetadataProvidersQueryHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the query to get the metadata providers configured for a media library.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either a collection of , or an error.
+ ///
+ public async ValueTask>> Handle(GetLibraryMetadataProvidersQuery request, CancellationToken cancellationToken)
+ {
+ ILibraryMetadataProviderConfigurationRepository configurationRepository = _unitOfWork.GetRepository();
+ ErrorOr> getConfigurationsResult = await configurationRepository.GetByLibraryIdAsync(request.LibraryId, cancellationToken).ConfigureAwait(false);
+ if (getConfigurationsResult.IsError)
+ return getConfigurationsResult.Errors;
+
+ // build a plugin name lookup from the detected plugins
+ IPluginRepository pluginRepository = _unitOfWork.GetRepository();
+ ErrorOr> getPluginsResult = await pluginRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
+ if (getPluginsResult.IsError)
+ return getPluginsResult.Errors;
+ Dictionary pluginNames = getPluginsResult.Value.ToDictionary(plugin => plugin.Id, plugin => plugin.Name);
+
+ return getConfigurationsResult.Value
+ .OrderBy(configuration => configuration.Rank)
+ .Select(configuration => configuration.ToResponse(pluginNames.GetValueOrDefault(configuration.PluginId) ?? string.Empty))
+ .ToList();
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Queries/GetPluginSettings/GetPluginSettingsQuery.cs b/src/Lumina.Application/Core/Plugins/Queries/GetPluginSettings/GetPluginSettingsQuery.cs
new file mode 100644
index 00000000..a7daf05b
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Queries/GetPluginSettings/GetPluginSettingsQuery.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.Plugins;
+using Mediator;
+using System;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Queries.GetPluginSettings;
+
+///
+/// Query for getting the settings of a plugin and their schema.
+///
+/// The unique identifier of the plugin.
+public record GetPluginSettingsQuery(
+ Guid PluginId
+) : IRequest>;
diff --git a/src/Lumina.Application/Core/Plugins/Queries/GetPluginSettings/GetPluginSettingsQueryHandler.cs b/src/Lumina.Application/Core/Plugins/Queries/GetPluginSettings/GetPluginSettingsQueryHandler.cs
new file mode 100644
index 00000000..ce66191a
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Queries/GetPluginSettings/GetPluginSettingsQueryHandler.cs
@@ -0,0 +1,64 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Plugins;
+using Lumina.Application.Common.Mapping.Plugins;
+using Lumina.Contracts.Responses.Plugins;
+using Lumina.Domain.SharedKernel.Common.Errors;
+using Lumina.Plugins.Contracts.Core.Plugins;
+using Mediator;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Queries.GetPluginSettings;
+
+///
+/// Handler for the query to get the settings of a plugin and their schema.
+///
+public class GetPluginSettingsQueryHandler : IRequestHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IPluginManager _pluginManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected manager of the plugins loaded by the host application.
+ public GetPluginSettingsQueryHandler(IUnitOfWork unitOfWork, IPluginManager pluginManager)
+ {
+ _unitOfWork = unitOfWork;
+ _pluginManager = pluginManager;
+ }
+
+ ///
+ /// Handles the query to get the settings of a plugin and their schema.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either a , or an error.
+ ///
+ public async ValueTask> Handle(GetPluginSettingsQuery request, CancellationToken cancellationToken)
+ {
+ IPluginRepository pluginRepository = _unitOfWork.GetRepository();
+ ErrorOr getPluginResult = await pluginRepository.GetByIdAsync(request.PluginId, cancellationToken).ConfigureAwait(false);
+ if (getPluginResult.IsError)
+ return getPluginResult.Errors;
+ PluginEntity? pluginEntity = getPluginResult.Value;
+ if (pluginEntity is null)
+ return Errors.Plugins.PluginNotFound;
+
+ // the schema comes from the loaded plugin, the current values from the storage medium
+ IPlugin? loadedPlugin = _pluginManager.GetPlugin(request.PluginId);
+ IReadOnlyList schema = loadedPlugin is not null
+ ? loadedPlugin.GetSettingsSchema().Select(setting => setting.ToResponse()).ToList()
+ : [];
+ return new PluginSettingsResponse(request.PluginId, schema, pluginEntity.ToSettings());
+ }
+}
diff --git a/src/Lumina.Application/Core/Plugins/Queries/GetPlugins/GetPluginsQuery.cs b/src/Lumina.Application/Core/Plugins/Queries/GetPlugins/GetPluginsQuery.cs
new file mode 100644
index 00000000..2a840280
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Queries/GetPlugins/GetPluginsQuery.cs
@@ -0,0 +1,13 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Contracts.Responses.Plugins;
+using Mediator;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Queries.GetPlugins;
+
+///
+/// Query for getting all the detected plugins.
+///
+public record GetPluginsQuery() : IRequest>>;
diff --git a/src/Lumina.Application/Core/Plugins/Queries/GetPlugins/GetPluginsQueryHandler.cs b/src/Lumina.Application/Core/Plugins/Queries/GetPlugins/GetPluginsQueryHandler.cs
new file mode 100644
index 00000000..fe8a7292
--- /dev/null
+++ b/src/Lumina.Application/Core/Plugins/Queries/GetPlugins/GetPluginsQueryHandler.cs
@@ -0,0 +1,49 @@
+#region ========================================================================= USING =====================================================================================
+using ErrorOr;
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Mapping.Plugins;
+using Lumina.Contracts.Responses.Plugins;
+using Mediator;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Plugins.Queries.GetPlugins;
+
+///
+/// Handler for the query to get all the detected plugins.
+///
+public class GetPluginsQueryHandler : IRequestHandler>>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public GetPluginsQueryHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the query to get all the detected plugins.
+ ///
+ /// The request to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either a collection of , or an error.
+ ///
+ public async ValueTask>> Handle(GetPluginsQuery request, CancellationToken cancellationToken)
+ {
+ IPluginRepository pluginRepository = _unitOfWork.GetRepository();
+ ErrorOr> getPluginsResult = await pluginRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
+ return getPluginsResult.Match(
+ plugins => ErrorOrFactory.From>(plugins.Select(plugin => plugin.ToResponse()).ToList()),
+ errors => errors);
+ }
+}
diff --git a/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandHandler.cs
index 772c1c60..49d328a5 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandHandler.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandHandler.cs
@@ -15,7 +15,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
diff --git a/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandValidator.cs b/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandValidator.cs
index 6cd7fffc..ba3f1589 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandValidator.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authorization/Commands/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsCommandValidator.cs
@@ -2,7 +2,7 @@
using FluentValidation;
using System;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
-using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.SharedKernel.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
diff --git a/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetAuthorization/GetAuthorizationQueryValidator.cs b/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetAuthorization/GetAuthorizationQueryValidator.cs
index a45034e1..aa988eaf 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetAuthorization/GetAuthorizationQueryValidator.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetAuthorization/GetAuthorizationQueryValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserPermissions/GetUserPermissionsQueryValidator.cs b/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserPermissions/GetUserPermissionsQueryValidator.cs
index 987e3052..f4b72b35 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserPermissions/GetUserPermissionsQueryValidator.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserPermissions/GetUserPermissionsQueryValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserRole/GetUserRoleQueryValidator.cs b/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserRole/GetUserRoleQueryValidator.cs
index 954bb659..b4780804 100644
--- a/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserRole/GetUserRoleQueryValidator.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Authorization/Queries/GetUserRole/GetUserRoleQueryValidator.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation;
-using Lumina.Domain.Common.Errors;
+using Lumina.Domain.SharedKernel.Common.Errors;
using System;
#endregion
diff --git a/src/Lumina.Application/Lumina.Application.csproj b/src/Lumina.Application/Lumina.Application.csproj
index ebc70b33..137f8c15 100644
--- a/src/Lumina.Application/Lumina.Application.csproj
+++ b/src/Lumina.Application/Lumina.Application.csproj
@@ -16,6 +16,7 @@
+
diff --git a/src/Lumina.Contracts/DTO/Authentication/PermissionDto.cs b/src/Lumina.Contracts/DTO/Authentication/PermissionDto.cs
index 11eda2ed..078061c4 100644
--- a/src/Lumina.Contracts/DTO/Authentication/PermissionDto.cs
+++ b/src/Lumina.Contracts/DTO/Authentication/PermissionDto.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Contracts/DTO/Common/GenreDto.cs b/src/Lumina.Contracts/DTO/Common/GenreDto.cs
index 2841eb1f..40fd0745 100644
--- a/src/Lumina.Contracts/DTO/Common/GenreDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/GenreDto.cs
@@ -7,7 +7,7 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a genre.
///
-/// Gets the name of the genre.
+/// The name of the genre.
[DebuggerDisplay("Name: {Name}")]
public record GenreDto(
string? Name
diff --git a/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs b/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs
index a3db4e05..b0f702cd 100644
--- a/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/LanguageInfoDto.cs
@@ -7,9 +7,9 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for language information.
///
-/// Gets the ISO code of the language (e.g., "en" for English). Required.
-/// Gets the name of the language in English. Required.
-/// Gets the native name of the language (e.g., "Español" for Spanish). Optional.
+/// The ISO code of the language (e.g., "en" for English). Required.
+/// The name of the language in English. Required.
+/// The native name of the language (e.g., "Español" for Spanish). Optional.
[DebuggerDisplay("LanguageName: {LanguageName}")]
public record LanguageInfoDto(
string? LanguageCode,
diff --git a/src/Lumina.Contracts/DTO/Common/MetadataDto.cs b/src/Lumina.Contracts/DTO/Common/MetadataDto.cs
new file mode 100644
index 00000000..9ad8fe77
--- /dev/null
+++ b/src/Lumina.Contracts/DTO/Common/MetadataDto.cs
@@ -0,0 +1,6 @@
+namespace Lumina.Contracts.DTO.Common;
+
+///
+/// Base type for all metadata returned by a metadata provider.
+///
+public abstract record MetadataDto;
diff --git a/src/Lumina.Contracts/DTO/Common/MetadataLookupDto.cs b/src/Lumina.Contracts/DTO/Common/MetadataLookupDto.cs
new file mode 100644
index 00000000..07023ff2
--- /dev/null
+++ b/src/Lumina.Contracts/DTO/Common/MetadataLookupDto.cs
@@ -0,0 +1,6 @@
+namespace Lumina.Contracts.DTO.Common;
+
+///
+/// Base type for all metadata lookups used to search for media items.
+///
+public abstract record MetadataLookupDto;
diff --git a/src/Lumina.Contracts/DTO/Common/RatingDto.cs b/src/Lumina.Contracts/DTO/Common/RatingDto.cs
index df956380..16694782 100644
--- a/src/Lumina.Contracts/DTO/Common/RatingDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/RatingDto.cs
@@ -7,9 +7,9 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a rating.
///
-/// Gets the rating value.
-/// Gets the maximum possible rating value.
-/// Gets the number of votes that contributed to the rating.
+/// The rating value.
+/// The maximum possible rating value.
+/// The number of votes that contributed to the rating.
[DebuggerDisplay("{Value}/{MaxValue}")]
public abstract record RatingDto(
decimal? Value,
diff --git a/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs b/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs
index 34b314b0..7738b2e2 100644
--- a/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/ReleaseInfoDto.cs
@@ -8,12 +8,12 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a release information.
///
-/// Gets the original release date of the content. Optional.
-/// Gets the original release year of the content. Optional.
-/// Gets the re-release date of the content. Optional.
-/// Gets the re-release year of the content. Optional.
-/// Gets the country where the content was released. Optional.
-/// Gets the version or edition of the content's release. Optional.
+/// The original release date of the content. Optional.
+/// The original release year of the content. Optional.
+/// The re-release date of the content. Optional.
+/// The re-release year of the content. Optional.
+/// The country where the content was released. Optional.
+/// The version or edition of the content's release. Optional.
[DebuggerDisplay("OriginalReleaseDate: {OriginalReleaseDate}")]
public record ReleaseInfoDto(
DateOnly? OriginalReleaseDate,
diff --git a/src/Lumina.Contracts/DTO/Common/TagDto.cs b/src/Lumina.Contracts/DTO/Common/TagDto.cs
index b2d1e834..45ecc898 100644
--- a/src/Lumina.Contracts/DTO/Common/TagDto.cs
+++ b/src/Lumina.Contracts/DTO/Common/TagDto.cs
@@ -7,7 +7,7 @@ namespace Lumina.Contracts.DTO.Common;
///
/// Data transfer object for a tag.
///
-/// Gets the name of the tag.
+/// The name of the tag.
[DebuggerDisplay("Name: {Name}")]
public record TagDto(
string? Name
diff --git a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDto.cs b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDto.cs
new file mode 100644
index 00000000..f557fe73
--- /dev/null
+++ b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDto.cs
@@ -0,0 +1,68 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.Common;
+using Lumina.Contracts.DTO.MediaContributors;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Data transfer object for the metadata of a book returned by a metadata provider.
+///
+/// The title of the book.
+/// The original title of the book, if different from the current title.
+/// A brief description or summary of the book.
+/// The release information, including release date and other relevant details.
+/// The list of genres associated with the book.
+/// The list of tags that further describe or categorize the book.
+/// The language in which the book is written.
+/// The original language of the book, if it has been translated.
+/// The name of the publisher of the book.
+/// The number of pages in the book.
+/// The format of the book (e.g., Hardcover, Paperback), if applicable.
+/// The edition of the book, if applicable.
+/// The volume or book number in the series, if applicable.
+/// The series name, if the book is part of a series.
+/// The ASIN (Amazon Standard Identification Number) of the book, if applicable.
+/// The Goodreads ID of the book, if applicable.
+/// The Library of Congress Control Number (LCCN) of the book, if applicable.
+/// The OCLC Number (WorldCat identifier) of the book, if applicable.
+/// The Open Library ID of the book, if applicable.
+/// The LibraryThing ID of the book, if applicable.
+/// The Google Books ID of the book, if applicable.
+/// The Barnes & Noble ID of the book, if applicable.
+/// The Apple Books ID of the book, if applicable.
+/// The list of ISBN (International Standard Book Number) of the book.
+/// The list of media contributors of the book.
+/// The list of ratings for the book.
+/// The URL of the cover image of the book, if applicable.
+public sealed record BookMetadataDto(
+ string? Title,
+ string? OriginalTitle,
+ string? Description,
+ ReleaseInfoDto? ReleaseInfo,
+ List? Genres,
+ List? Tags,
+ LanguageInfoDto? Language,
+ LanguageInfoDto? OriginalLanguage,
+ string? Publisher,
+ int? PageCount,
+ BookFormat? Format,
+ string? Edition,
+ int? VolumeNumber,
+ BookSeriesDto? Series,
+ string? ASIN,
+ string? GoodreadsId,
+ string? LCCN,
+ string? OCLCNumber,
+ string? OpenLibraryId,
+ string? LibraryThingId,
+ string? GoogleBooksId,
+ string? BarnesAndNobleId,
+ string? AppleBooksId,
+ List? Isbns,
+ List? Contributors,
+ List? Ratings,
+ string? CoverImageUrl
+) : MetadataDto;
diff --git a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataLookupDto.cs b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataLookupDto.cs
new file mode 100644
index 00000000..e8da4e22
--- /dev/null
+++ b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataLookupDto.cs
@@ -0,0 +1,26 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.Common;
+using System;
+#endregion
+
+namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Data transfer object for a book metadata lookup.
+///
+/// The Id of the media library the book belongs to.
+/// The file system path of the book.
+/// The ISBN (International Standard Book Number) of the book, if applicable.
+/// The Open Library ID of the book, if applicable.
+/// The title of the book, if applicable.
+/// The author of the book, if applicable.
+/// The language code of the book, if applicable.
+public sealed record BookMetadataLookupDto(
+ Guid LibraryId,
+ string Path,
+ string? Isbn = null,
+ string? OpenLibraryId = null,
+ string? Title = null,
+ string? Author = null,
+ string? LanguageCode = null
+) : MetadataLookupDto;
diff --git a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDto.cs b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDto.cs
index dcdd4c4f..ab9d6643 100644
--- a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDto.cs
+++ b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookRatingDto.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Contracts.DTO.Common;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnDto.cs b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnDto.cs
index bc0481b7..a201a246 100644
--- a/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnDto.cs
+++ b/src/Lumina.Contracts/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnDto.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Contracts/Lumina.Contracts.csproj b/src/Lumina.Contracts/Lumina.Contracts.csproj
index ce95bf9c..7c054dd5 100644
--- a/src/Lumina.Contracts/Lumina.Contracts.csproj
+++ b/src/Lumina.Contracts/Lumina.Contracts.csproj
@@ -14,6 +14,6 @@
-
+
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
index 2f18881a..ad62394a 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs
index a6c2b4e1..d46fa0c9 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequest.cs
@@ -2,7 +2,8 @@
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
@@ -12,6 +13,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
///
/// Represents a request to add a book.
///
+/// The Id of the media library this book belongs to. Required.
+/// The file system path of the book. Required.
/// Written content metadata of the book. Required.
/// The format of the book (e.g., Hardcover, Paperback). Optional.
/// The edition of the book. Optional.
@@ -31,6 +34,8 @@ namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibra
/// The list of ratings for this book. Required.
[DebuggerDisplay("Title: {Metadata.Title}")]
public record AddBookRequest(
+ Guid LibraryId,
+ string Path,
WrittenContentMetadataDto? Metadata,
BookFormat? Format,
string? Edition,
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequest.cs
new file mode 100644
index 00000000..cbfb36f0
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Represents a request to get the books of a media library.
+///
+/// The Id of the media library whose books are retrieved. Required.
+[DebuggerDisplay("LibraryId: {LibraryId}")]
+public record GetBooksRequest(
+ Guid LibraryId
+);
diff --git a/src/Lumina.Contracts/Requests/Plugins/GetLibraryMetadataProvidersRequest.cs b/src/Lumina.Contracts/Requests/Plugins/GetLibraryMetadataProvidersRequest.cs
new file mode 100644
index 00000000..5e2e14c9
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Plugins/GetLibraryMetadataProvidersRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Plugins;
+
+///
+/// Represents a request to get the metadata providers configured for a media library.
+///
+/// The Id of the media library whose metadata providers are retrieved. Required.
+[DebuggerDisplay("LibraryId: {LibraryId}")]
+public sealed record GetLibraryMetadataProvidersRequest(
+ Guid LibraryId
+);
diff --git a/src/Lumina.Contracts/Requests/Plugins/GetPluginSettingsRequest.cs b/src/Lumina.Contracts/Requests/Plugins/GetPluginSettingsRequest.cs
new file mode 100644
index 00000000..2d0d5d09
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Plugins/GetPluginSettingsRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Plugins;
+
+///
+/// Represents a request to get the settings of a plugin.
+///
+/// The unique identifier of the plugin. Required.
+[DebuggerDisplay("PluginId: {PluginId}")]
+public sealed record GetPluginSettingsRequest(
+ Guid PluginId
+);
diff --git a/src/Lumina.Contracts/Requests/Plugins/ReorderLibraryMetadataProvidersRequest.cs b/src/Lumina.Contracts/Requests/Plugins/ReorderLibraryMetadataProvidersRequest.cs
new file mode 100644
index 00000000..24b6021e
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Plugins/ReorderLibraryMetadataProvidersRequest.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Plugins;
+
+///
+/// Represents a request to reorder the metadata providers of a media library.
+///
+/// The Id of the media library whose metadata providers are reordered. Required.
+/// The plugin Ids in the new order, from highest to lowest rank. Required.
+[DebuggerDisplay("LibraryId: {LibraryId}")]
+public sealed record ReorderLibraryMetadataProvidersRequest(
+ Guid LibraryId,
+ IReadOnlyList PluginIds
+);
diff --git a/src/Lumina.Contracts/Requests/Plugins/SetLibraryMetadataProviderEnabledRequest.cs b/src/Lumina.Contracts/Requests/Plugins/SetLibraryMetadataProviderEnabledRequest.cs
new file mode 100644
index 00000000..342ec7b7
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Plugins/SetLibraryMetadataProviderEnabledRequest.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Plugins;
+
+///
+/// Represents a request to enable or disable a metadata provider for a media library.
+///
+/// The Id of the media library whose metadata provider is enabled or disabled. Required.
+/// The unique identifier of the plugin providing the metadata. Required.
+/// Whether the metadata provider should be enabled for the media library. Required.
+[DebuggerDisplay("LibraryId: {LibraryId}, PluginId: {PluginId}")]
+public sealed record SetLibraryMetadataProviderEnabledRequest(
+ Guid LibraryId,
+ Guid PluginId,
+ bool IsEnabled
+);
diff --git a/src/Lumina.Contracts/Requests/Plugins/UpdatePluginSettingsRequest.cs b/src/Lumina.Contracts/Requests/Plugins/UpdatePluginSettingsRequest.cs
new file mode 100644
index 00000000..0e71bbc7
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Plugins/UpdatePluginSettingsRequest.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Plugins;
+
+///
+/// Represents a request to update the settings of a plugin.
+///
+/// The unique identifier of the plugin. Required.
+/// The settings of the plugin. Required.
+[DebuggerDisplay("PluginId: {PluginId}")]
+public sealed record UpdatePluginSettingsRequest(
+ Guid PluginId,
+ IReadOnlyDictionary? Settings
+);
diff --git a/src/Lumina.Contracts/Responses/Authorization/AuthorizationResponse.cs b/src/Lumina.Contracts/Responses/Authorization/AuthorizationResponse.cs
index 4205f796..497365a8 100644
--- a/src/Lumina.Contracts/Responses/Authorization/AuthorizationResponse.cs
+++ b/src/Lumina.Contracts/Responses/Authorization/AuthorizationResponse.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Contracts/Responses/Authorization/PermissionResponse.cs b/src/Lumina.Contracts/Responses/Authorization/PermissionResponse.cs
index c98d5e2b..a2f5dc46 100644
--- a/src/Lumina.Contracts/Responses/Authorization/PermissionResponse.cs
+++ b/src/Lumina.Contracts/Responses/Authorization/PermissionResponse.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.Authorization;
+using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
#endregion
diff --git a/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs b/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs
index 36a42ce3..615e8bb7 100644
--- a/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs
+++ b/src/Lumina.Contracts/Responses/FileSystemManagement/Common/FileSystemTreeNodeResponse.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Contracts/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponse.cs b/src/Lumina.Contracts/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponse.cs
index 78928e2a..b4634371 100644
--- a/src/Lumina.Contracts/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponse.cs
+++ b/src/Lumina.Contracts/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponse.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.FileSystem;
+using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Contracts/Responses/FileSystemManagement/Thumbnails/ThumbnailResponse.cs b/src/Lumina.Contracts/Responses/FileSystemManagement/Thumbnails/ThumbnailResponse.cs
index 03588a7b..be9447a7 100644
--- a/src/Lumina.Contracts/Responses/FileSystemManagement/Thumbnails/ThumbnailResponse.cs
+++ b/src/Lumina.Contracts/Responses/FileSystemManagement/Thumbnails/ThumbnailResponse.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.PhotoLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
using System.Diagnostics;
#endregion
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
index 4cc80534..9ec7de01 100644
--- a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Domain.Common.Enums.MediaLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs
index 0a67e27e..483b7579 100644
--- a/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponse.cs
@@ -2,7 +2,7 @@
using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
-using Lumina.Domain.Common.Enums.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -14,6 +14,8 @@ namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibr
/// Represents a book response.
///
/// The id of the book.
+/// The Id of the media library this book belongs to.
+/// The file system path of the book.
/// Written content metadata of the book.
/// The format of the book (e.g., Hardcover, Paperback), if applicable.
/// The edition of the book, if applicable.
@@ -31,11 +33,16 @@ namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibr
/// The list of ISBN (International Standard Book Number) of the book.
/// The list of media contributors (actors, directors, etc) starring in this book.
/// The list of ratings for this book.
+/// The status of the metadata enrichment of the book.
+/// The date and time when the metadata of the book was last enriched, if applicable.
+/// The name of the plugin that enriched the metadata of the book, if applicable.
/// The date and time when the book was created.
/// The optional date and time when the book was updated.
[DebuggerDisplay("Title: {Metadata.Title}")]
public record BookResponse(
Guid Id,
+ Guid LibraryId,
+ string Path,
WrittenContentMetadataDto Metadata,
BookFormat? Format,
string? Edition,
@@ -53,6 +60,9 @@ public record BookResponse(
List? ISBNs,
List? Contributors,
List? Ratings,
+ MetadataStatus MetadataStatus,
+ DateTime? LastMetadataUpdateUtc,
+ string? MetadataProvider,
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
diff --git a/src/Lumina.Contracts/Responses/Plugins/LibraryMetadataProviderResponse.cs b/src/Lumina.Contracts/Responses/Plugins/LibraryMetadataProviderResponse.cs
new file mode 100644
index 00000000..b47a3b1a
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Plugins/LibraryMetadataProviderResponse.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+#endregion
+
+namespace Lumina.Contracts.Responses.Plugins;
+
+///
+/// Represents a metadata provider configured for a media library.
+///
+/// The unique identifier of the plugin providing the metadata.
+/// The display name of the metadata provider.
+/// Whether the metadata provider is enabled for the media library.
+/// The rank of the metadata provider, determining the order in which providers are tried.
+public sealed record LibraryMetadataProviderResponse(
+ Guid PluginId,
+ string Name,
+ bool IsEnabled,
+ int Rank
+);
diff --git a/src/Lumina.Contracts/Responses/Plugins/PluginResponse.cs b/src/Lumina.Contracts/Responses/Plugins/PluginResponse.cs
new file mode 100644
index 00000000..f5a290f5
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Plugins/PluginResponse.cs
@@ -0,0 +1,31 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.Plugins;
+
+///
+/// Represents a detected plugin.
+///
+/// The unique identifier of the plugin.
+/// The display name of the plugin.
+/// The author of the plugin.
+/// The version of the plugin.
+/// The description of the plugin.
+/// The load status of the plugin.
+/// The error message when the plugin failed to load, if applicable.
+/// The settings of the plugin.
+[DebuggerDisplay("Name: {Name}")]
+public sealed record PluginResponse(
+ Guid Id,
+ string Name,
+ string Author,
+ string Version,
+ string Description,
+ PluginLoadStatus LoadStatus,
+ string? LoadError,
+ IReadOnlyDictionary? Settings
+);
diff --git a/src/Lumina.Contracts/Responses/Plugins/PluginSettingDescriptorResponse.cs b/src/Lumina.Contracts/Responses/Plugins/PluginSettingDescriptorResponse.cs
new file mode 100644
index 00000000..1da4a682
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Plugins/PluginSettingDescriptorResponse.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Contracts.Responses.Plugins;
+
+///
+/// Describes a single setting of a plugin.
+///
+/// The unique key of the setting.
+/// The display label of the setting.
+/// The type of the setting.
+/// The optional default value of the setting.
+/// The list of allowed values, when the setting is a selection.
+public sealed record PluginSettingDescriptorResponse(
+ string Key,
+ string Label,
+ PluginSettingType Type,
+ string? DefaultValue,
+ IReadOnlyList? AllowedValues
+);
diff --git a/src/Lumina.Contracts/Responses/Plugins/PluginSettingsResponse.cs b/src/Lumina.Contracts/Responses/Plugins/PluginSettingsResponse.cs
new file mode 100644
index 00000000..b9ce52ed
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Plugins/PluginSettingsResponse.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Collections.Generic;
+#endregion
+
+namespace Lumina.Contracts.Responses.Plugins;
+
+///
+/// Represents the settings of a plugin and their schema.
+///
+/// The unique identifier of the plugin.
+/// The schema of the plugin settings.
+/// The current values of the plugin settings.
+public sealed record PluginSettingsResponse(
+ Guid PluginId,
+ IReadOnlyList Schema,
+ IReadOnlyDictionary? Settings
+);
diff --git a/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs
index 438cc6a1..0ad36b8a 100644
--- a/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/BookConfiguration.cs
@@ -130,6 +130,23 @@ public class BookConfiguration : IEntityTypeConfiguration
.HasColumnOrder(28);
builder.Property(book => book.AppleBooksId)
.HasColumnOrder(29);
+ builder.Property(book => book.LibraryId)
+ .IsRequired()
+ .HasColumnOrder(36);
+ builder.Property(book => book.Path)
+ .IsRequired()
+ .HasMaxLength(2048)
+ .HasColumnOrder(37);
+ builder.Property(book => book.MetadataStatus)
+ .HasConversion()
+ .HasMaxLength(20)
+ .IsRequired()
+ .HasColumnOrder(38);
+ builder.Property(book => book.LastMetadataUpdateUtc)
+ .HasColumnOrder(39);
+ builder.Property(book => book.MetadataProvider)
+ .HasMaxLength(100)
+ .HasColumnOrder(40);
builder.Property(book => book.CreatedOnUtc)
.HasColumnOrder(30);
builder.Property(book => book.UpdatedOnUtc)
@@ -219,6 +236,9 @@ public class BookConfiguration : IEntityTypeConfiguration
builder.Property(book => book.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(35);
+
+ builder.HasIndex(book => new { book.LibraryId, book.Path });
+ builder.HasIndex(book => new { book.LibraryId, book.MetadataStatus });
}
}
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryMetadataProviderConfigurationConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryMetadataProviderConfigurationConfiguration.cs
new file mode 100644
index 00000000..2130ed43
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryMetadataProviderConfigurationConfiguration.cs
@@ -0,0 +1,57 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+#endregion
+
+namespace Lumina.DataAccess.Common.Configuration;
+
+///
+/// Configures the entity mapping for the entity.
+///
+public class LibraryMetadataProviderConfigurationConfiguration : IEntityTypeConfiguration
+{
+ ///
+ /// Configures the entity.
+ ///
+ /// The builder to be used to configure the entity.
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("LibraryMetadataProviderConfigurations");
+ builder.HasKey(configuration => configuration.Id);
+ builder.Property(configuration => configuration.Id)
+ .ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
+ .HasColumnOrder(0);
+ builder.Property(configuration => configuration.LibraryId)
+ .IsRequired()
+ .HasColumnOrder(1);
+ builder.Property(configuration => configuration.PluginId)
+ .IsRequired()
+ .HasColumnOrder(2);
+ builder.Property(configuration => configuration.IsEnabled)
+ .IsRequired()
+ .HasColumnOrder(3);
+ builder.Property(configuration => configuration.Rank)
+ .IsRequired()
+ .HasColumnOrder(4);
+
+ // audit
+ builder.Property(configuration => configuration.CreatedOnUtc)
+ .IsRequired()
+ .HasColumnOrder(5);
+
+ builder.Property(configuration => configuration.CreatedBy)
+ .IsRequired()
+ .HasColumnOrder(6);
+
+ builder.Property(configuration => configuration.UpdatedOnUtc)
+ .HasDefaultValue(null)
+ .HasColumnOrder(7);
+
+ builder.Property(configuration => configuration.UpdatedBy)
+ .HasDefaultValue(null)
+ .HasColumnOrder(8);
+
+ builder.HasIndex(configuration => new { configuration.LibraryId, configuration.PluginId });
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Configuration/PluginConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/PluginConfiguration.cs
new file mode 100644
index 00000000..7bc598bd
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Configuration/PluginConfiguration.cs
@@ -0,0 +1,67 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Plugins;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+#endregion
+
+namespace Lumina.DataAccess.Common.Configuration;
+
+///
+/// Configures the entity mapping for the entity.
+///
+public class PluginConfiguration : IEntityTypeConfiguration
+{
+ ///
+ /// Configures the entity.
+ ///
+ /// The builder to be used to configure the entity.
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("Plugins");
+ builder.HasKey(plugin => plugin.Id);
+ builder.Property(plugin => plugin.Id)
+ .ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
+ .HasColumnOrder(0);
+ builder.Property(plugin => plugin.Name)
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnOrder(1);
+ builder.Property(plugin => plugin.Author)
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnOrder(2);
+ builder.Property(plugin => plugin.Version)
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnOrder(3);
+ builder.Property(plugin => plugin.Description)
+ .HasMaxLength(2000)
+ .HasColumnOrder(4);
+ builder.Property(plugin => plugin.LoadStatus)
+ .HasConversion()
+ .HasMaxLength(20)
+ .IsRequired()
+ .HasColumnOrder(5);
+ builder.Property(plugin => plugin.LoadError)
+ .HasMaxLength(2000)
+ .HasColumnOrder(6);
+ builder.Property(plugin => plugin.SettingsJson)
+ .HasColumnOrder(7);
+ builder.Property(plugin => plugin.CreatedOnUtc)
+ .IsRequired()
+ .HasColumnOrder(8);
+
+ // audit
+ builder.Property(plugin => plugin.CreatedBy)
+ .IsRequired()
+ .HasColumnOrder(9);
+
+ builder.Property(plugin => plugin.UpdatedOnUtc)
+ .HasDefaultValue(null)
+ .HasColumnOrder(10);
+
+ builder.Property(plugin => plugin.UpdatedBy)
+ .HasDefaultValue(null)
+ .HasColumnOrder(11);
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.Designer.cs
new file mode 100644
index 00000000..fd0489a7
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20260809171050_AddsBookLibraryAndPathAndMetadataStatus.Designer.cs
@@ -0,0 +1,1048 @@
+//
+using System;
+using Lumina.DataAccess.Core.UoW;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Lumina.DataAccess.Common.Migrations
+{
+ [DbContext(typeof(LuminaDbContext))]
+ [Migration("20260809171050_AddsBookLibraryAndPathAndMetadataStatus")]
+ partial class AddsBookLibraryAndPathAndMetadataStatus
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.0");
+
+ modelBuilder.Entity("BookGenres", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("BookGenres", (string)null);
+ });
+
+ modelBuilder.Entity("BookTags", b =>
+ {
+ b.Property("BookId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BookId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("BookTags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.PermissionEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("PermissionName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Permissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RoleEntity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.HasKey("Id");
+
+ b.ToTable("Roles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.RolePermissionEntity", b =>
+ {
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("RoleId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("RoleId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("RolePermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserPermissionEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("PermissionId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId", "PermissionId");
+
+ b.HasIndex("PermissionId");
+
+ b.HasIndex("UserId", "PermissionId")
+ .IsUnique();
+
+ b.ToTable("UserPermissions", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Authorization.UserRoleEntity", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("UserId");
+
+ b.HasIndex("RoleId");
+
+ b.HasIndex("UserId", "RoleId")
+ .IsUnique();
+
+ b.ToTable("UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.GenreEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Genres", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Common.TagEntity", b =>
+ {
+ b.Property("Name")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Name");
+
+ b.ToTable("Tags", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.DirectoryScanFingerprintEntity", b =>
+ {
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("LastWriteTimeUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.HasKey("LibraryId", "Path");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("DirectoryScanFingerprints", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CoverImage")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("DownloadMetadataFromWeb")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(6);
+
+ b.Property("IsEnabled")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(true)
+ .HasColumnOrder(4);
+
+ b.Property("IsLocked")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("LibraryType")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("ShouldSaveMetadataInMediaDirectories")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ShouldSkipUnchangedDirectoriesDuringScan")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(8);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Libraries", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("LibraryId", "Status", "CreatedOnUtc")
+ .IsDescending(true, false, true);
+
+ b.ToTable("LibraryScans", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanResultEntity", b =>
+ {
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasMaxLength(24)
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("FileSize")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.HasKey("LibraryScanId", "Path");
+
+ b.HasIndex("Path");
+
+ b.HasIndex("ContentHash", "FileSize", "Path");
+
+ b.ToTable("LibraryScanResults", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanSnapshotEntity", b =>
+ {
+ b.Property("LibraryId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("FileSize")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.HasKey("LibraryId", "Path");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("LibraryScanSnapshots", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management.LibraryScanStagingResultsEntity", b =>
+ {
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT");
+
+ b.Property("Path")
+ .HasMaxLength(1024)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("ContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("IsNew")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("NeedsRehash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(6);
+
+ b.Property("PreviousContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("Size")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(2);
+
+ b.Property("Ticks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.HasKey("LibraryScanId", "Path");
+
+ b.HasIndex("LibraryScanId", "NeedsRehash");
+
+ b.ToTable("LibraryScanStagingResults", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary.BookEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ASIN")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(21);
+
+ b.Property("AppleBooksId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("BarnesAndNobleId")
+ .HasMaxLength(10)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(28);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(33);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(32);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("Edition")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("Format")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("GoodreadsId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(22);
+
+ b.Property("GoogleBooksId")
+ .HasMaxLength(12)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(27);
+
+ b.Property("LCCN")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("LastMetadataUpdateUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(39);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(36);
+
+ b.Property("LibraryThingId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(26);
+
+ b.Property("MetadataProvider")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(40);
+
+ b.Property("MetadataStatus")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(38);
+
+ b.Property("OCLCNumber")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("OpenLibraryId")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("OriginalLanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("OriginalLanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("OriginalLanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("OriginalReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("OriginalReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(5);
+
+ b.Property("OriginalTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("PageCount")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(17);
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(2048)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(37);
+
+ b.Property