diff --git a/docs/technical/api/library/management/Api.Libraries.md b/docs/technical/api/library/management/Api.Libraries.md
index 30a6eba7..4963627e 100644
--- a/docs/technical/api/library/management/Api.Libraries.md
+++ b/docs/technical/api/library/management/Api.Libraries.md
@@ -38,6 +38,9 @@
- [Cancel Library Scan](#cancel-library-scan)
- [Cancel Library Scan Request](#cancel-library-scan-request)
- [Cancel Library Scan Response](#cancel-library-scan-response)
+ - [Get Library Path Template Parts](#get-library-path-template-parts)
+ - [Get Library Path Template Parts Request](#get-library-path-template-parts-request)
+ - [Get Library Path Template Parts Response](#get-library-path-template-parts-response)
## Library
@@ -59,9 +62,10 @@ POST api/v1/libraries
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
- "shouldSkipUnchangedDirectoriesDuringScan": true
+ "shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": []
}
```
@@ -83,9 +87,10 @@ POST api/v1/libraries
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
"shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [],
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
"updatedOnUtc": null
}
@@ -118,9 +123,10 @@ GET api/v1/libraries
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
"shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [],
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
"updatedOnUtc": null
}
@@ -154,9 +160,10 @@ GET api/v1/libraries/enabled
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
"shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [],
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
"updatedOnUtc": null
}
@@ -189,9 +196,10 @@ GET api/v1/libraries/{id}
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
"shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [],
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
"updatedOnUtc": null
}
@@ -217,9 +225,10 @@ PUT api/v1/libraries/{id}
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
- "shouldSkipUnchangedDirectoriesDuringScan": true
+ "shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": []
}
```
@@ -241,9 +250,10 @@ PUT api/v1/libraries/{id}
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
"shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [],
"createdOnUtc": "2025-01-01T12:00:00.0000000Z",
"updatedOnUtc": null
}
@@ -400,3 +410,43 @@ POST api/v1/libraries/{libraryId}/scans/{scanId}/cancel
```js
204 No Content
```
+
+### Get Library Path Template Parts
+
+#### Get Library Path Template Parts Request
+
+```js
+GET api/v1/libraries/path-template-parts/{libraryType}
+```
+
+#### Get Library Path Template Parts Response
+
+```js
+200 Ok
+```
+
+```json
+{
+ "parts": [
+ {
+ "kind": "Artist",
+ "valueType": "Text",
+ "defaultRepresentation": "{0}",
+ "isOptionalByDefault": false
+ },
+ {
+ "kind": "DiscNumber",
+ "valueType": "Integer",
+ "defaultRepresentation": "{0:00}",
+ "isOptionalByDefault": true
+ }
+ ],
+ "defaultTemplateParts": [
+ {
+ "kind": "Artist",
+ "representation": "{0}",
+ "isOptional": false
+ }
+ ]
+}
+```
diff --git a/docs/technical/requests/library/management/AddLibrary.http b/docs/technical/requests/library/management/AddLibrary.http
index f6136db5..0a20c31f 100644
--- a/docs/technical/requests/library/management/AddLibrary.http
+++ b/docs/technical/requests/library/management/AddLibrary.http
@@ -11,7 +11,11 @@ Content-Type: application/json
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
- "shouldSkipUnchangedDirectoriesDuringScan": true
+ "shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [
+ { "kind": "Artist", "representation": "{0}", "isOptional": false },
+ { "kind": "Separator", "representation": "", "isOptional": false }
+ ]
}
diff --git a/docs/technical/requests/library/management/GetLibraryPathTemplateParts.http b/docs/technical/requests/library/management/GetLibraryPathTemplateParts.http
new file mode 100644
index 00000000..1562fed7
--- /dev/null
+++ b/docs/technical/requests/library/management/GetLibraryPathTemplateParts.http
@@ -0,0 +1,2 @@
+GET {{host}}/api/v1/libraries/path-template-parts/Music
+Authorization: Bearer {{ACCESS_TOKEN}}
diff --git a/docs/technical/requests/library/management/UpdateLibrary.http b/docs/technical/requests/library/management/UpdateLibrary.http
index 5cc9136c..aa82d623 100644
--- a/docs/technical/requests/library/management/UpdateLibrary.http
+++ b/docs/technical/requests/library/management/UpdateLibrary.http
@@ -13,7 +13,11 @@ Content-Type: application/json
"coverImage": null,
"isEnabled": true,
"isLocked": false,
- "downloadMetadataFromWeb": true,
+ "canDownloadMetadataFromWeb": true,
"shouldSaveMetadataInMediaDirectories": true,
- "shouldSkipUnchangedDirectoriesDuringScan": true
+ "shouldSkipUnchangedDirectoriesDuringScan": true,
+ "pathTemplateParts": [
+ { "kind": "Artist", "representation": "{0}", "isOptional": false },
+ { "kind": "Separator", "representation": "", "isOptional": false }
+ ]
}
diff --git a/src/Lumina.Application/Common/DTO/MediaLibrary/Management/LibraryPathTemplatePartDto.cs b/src/Lumina.Application/Common/DTO/MediaLibrary/Management/LibraryPathTemplatePartDto.cs
new file mode 100644
index 00000000..05a0898f
--- /dev/null
+++ b/src/Lumina.Application/Common/DTO/MediaLibrary/Management/LibraryPathTemplatePartDto.cs
@@ -0,0 +1,13 @@
+namespace Lumina.Application.Common.DTO.MediaLibrary.Management;
+
+///
+/// Data transfer object for one part of the path template of a media library, carried by the commands that create or update a media library.
+///
+/// The kind of the path part.
+/// The literal text or the value mask of the path part.
+/// Whether the path part can be absent from the path.
+public record LibraryPathTemplatePartDto(
+ string? Kind,
+ string? Representation,
+ bool IsOptional
+);
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 3dfdaa16..993b48a4 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryEntity.cs
@@ -45,6 +45,11 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
///
public required ICollection ContentLocations { get; init; } = [];
+ ///
+ /// Gets the ordered parts of the template describing the structure of the media library on disk.
+ ///
+ public ICollection PathTemplateParts { get; init; } = [];
+
///
/// Gets the list of scans of the media library.
///
@@ -87,6 +92,12 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
///
public string? ArtworkProvidersConfigurationFingerprint { get; set; }
+ ///
+ /// Gets or sets the fingerprint of the path template of the media library, used to detect whether the template
+ /// changed since the last scan, and thus whether the metadata needs to be derived from the paths again.
+ ///
+ public string? PathTemplateFingerprint { get; set; }
+
///
/// Gets the user that owns the media library.
///
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryPathTemplatePartEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryPathTemplatePartEntity.cs
new file mode 100644
index 00000000..dfa26b26
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/MediaLibrary/Management/LibraryPathTemplatePartEntity.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+
+///
+/// Repository entity for one part of the path template of a media library.
+///
+[DebuggerDisplay("Kind: {Kind}; Position: {Position}")]
+public class LibraryPathTemplatePartEntity
+{
+ ///
+ /// Gets or sets the zero based position of the part in the path template.
+ ///
+ public required int Position { get; set; }
+
+ ///
+ /// Gets or sets the kind of the path part.
+ ///
+ public required LibraryPathPartKind Kind { get; set; }
+
+ ///
+ /// Gets or sets the literal text or the value mask of the path part.
+ ///
+ public required string Representation { get; set; }
+
+ ///
+ /// Gets or sets whether the path part can be absent from the path.
+ ///
+ public required bool IsOptional { get; set; }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
index f524961e..e02402e7 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/AddMediaLibraryRequestMapping.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DTO.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
using Lumina.Contracts.Requests.MediaLibrary.Management;
+using System.Linq;
#endregion
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
@@ -26,7 +28,8 @@ public static class AddMediaLibraryRequestMapping
request.IsLocked,
request.CanDownloadMetadataFromWeb,
request.ShouldSaveMetadataInMediaDirectories,
- request.ShouldSkipUnchangedDirectoriesDuringScan
+ request.ShouldSkipUnchangedDirectoriesDuringScan,
+ request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray()
);
}
}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/GetLibraryPathTemplatePartsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/GetLibraryPathTemplatePartsRequestMapping.cs
new file mode 100644
index 00000000..b407fb7a
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/GetLibraryPathTemplatePartsRequestMapping.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
+using Lumina.Contracts.Requests.MediaLibrary.Management;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
+
+///
+/// Extension methods for converting .
+///
+public static class GetLibraryPathTemplatePartsRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetLibraryPathTemplatePartsQuery ToQuery(this GetLibraryPathTemplatePartsRequest request)
+ {
+ return new GetLibraryPathTemplatePartsQuery(
+ request.LibraryType
+ );
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
index 2e7e8142..70060f17 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryEntityMapping.cs
@@ -36,6 +36,9 @@ public static class LibraryEntityMapping
repositoryEntity.CanDownloadMetadataFromWeb,
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
+ [.. repositoryEntity.PathTemplateParts
+ .OrderBy(part => part.Position)
+ .Select(part => new LibraryPathTemplatePartResponse(part.Kind.ToString(), part.Representation, part.IsOptional))],
repositoryEntity.CreatedOnUtc,
repositoryEntity.UpdatedOnUtc
);
@@ -50,6 +53,10 @@ public static class LibraryEntityMapping
///
public static Result ToDomainEntity(this LibraryEntity repositoryEntity)
{
+ Result pathTemplateResult = BuildPathTemplate(repositoryEntity.PathTemplateParts);
+ if (pathTemplateResult.IsFailure)
+ return pathTemplateResult.Errors;
+
return Library.Create(
LibraryId.Create(repositoryEntity.Id),
UserId.Create(repositoryEntity.UserId),
@@ -62,10 +69,31 @@ public static class LibraryEntityMapping
repositoryEntity.CanDownloadMetadataFromWeb,
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
+ pathTemplateResult.Value,
[.. repositoryEntity.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
);
}
+ ///
+ /// Builds the path template of a media library from its ordered stored parts.
+ ///
+ /// The stored parts of the path template.
+ ///
+ /// An containing either the built , or an error message.
+ ///
+ private static Result BuildPathTemplate(IEnumerable parts)
+ {
+ List orderedParts = [];
+ foreach (LibraryPathTemplatePartEntity part in parts.OrderBy(part => part.Position))
+ {
+ Result partResult = LibraryPathPart.Create(part.Kind, part.Representation, part.IsOptional);
+ if (partResult.IsFailure)
+ return partResult.Errors;
+ orderedParts.Add(partResult.Value);
+ }
+ return LibraryPathTemplate.Create(orderedParts);
+ }
+
///
/// Converts to a collection of .
///
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
index be721acb..3d90a2a8 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryMapping.cs
@@ -26,6 +26,13 @@ public static class LibraryMapping
LibraryType = domainEntity.LibraryType,
UserId = domainEntity.UserId.Value,
ContentLocations = [.. domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path })],
+ PathTemplateParts = [.. domainEntity.PathTemplate.Parts.Select((part, index) => new LibraryPathTemplatePartEntity
+ {
+ Kind = part.Kind,
+ Representation = part.Representation,
+ IsOptional = part.IsOptional,
+ Position = index
+ })],
CoverImage = domainEntity.CoverImage.HasValue ? domainEntity.CoverImage.Value : null,
IsEnabled = domainEntity.IsEnabled,
IsLocked = domainEntity.IsLocked,
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryPathTemplatePartDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryPathTemplatePartDtoMapping.cs
new file mode 100644
index 00000000..df2c4165
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/LibraryPathTemplatePartDtoMapping.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DTO.MediaLibrary.Management;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using System;
+using System.Collections.Generic;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
+
+///
+/// Extension methods for converting .
+///
+public static class LibraryPathTemplatePartDtoMapping
+{
+ ///
+ /// Converts the provided path template parts to their domain path parts.
+ ///
+ /// The path template parts to be converted.
+ ///
+ /// An containing either the converted domain path parts, or an error message.
+ ///
+ public static Result> ToDomainParts(this IEnumerable? parts)
+ {
+ List domainParts = [];
+ if (parts is null)
+ return domainParts;
+
+ foreach (LibraryPathTemplatePartDto part in parts)
+ {
+ if (!Enum.TryParse(part.Kind, ignoreCase: true, out LibraryPathPartKind kind))
+ return DomainErrors.Library.PathTemplatePartKindNotSupportedForLibraryType;
+
+ Result partResult = LibraryPathPart.Create(kind, part.Representation, part.IsOptional);
+ if (partResult.IsFailure)
+ return partResult.Errors;
+
+ domainParts.Add(partResult.Value);
+ }
+ return domainParts;
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs
index 374f9e15..529bbc32 100644
--- a/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/Management/UpdateLibraryRequestMapping.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DTO.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
using Lumina.Contracts.Requests.MediaLibrary.Management;
+using System.Linq;
#endregion
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
@@ -28,7 +30,8 @@ public static class UpdateLibraryRequestMapping
request.IsLocked,
request.CanDownloadMetadataFromWeb,
request.ShouldSaveMetadataInMediaDirectories,
- request.ShouldSkipUnchangedDirectoriesDuringScan
+ request.ShouldSkipUnchangedDirectoriesDuringScan,
+ request.PathTemplateParts?.Select(part => new LibraryPathTemplatePartDto(part.Kind, part.Representation, part.IsOptional)).ToArray()
);
}
}
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs
index 995a3ee6..e1ff00bf 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommand.cs
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DTO.MediaLibrary.Management;
using System.Diagnostics;
#endregion
@@ -17,6 +18,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
/// Whether this media library should update the metadata of its elements from the web, or not.
/// Whether this media library should copy the downloaded metadata into the media library content locations, or not.
/// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.
+/// The ordered parts of the template describing the structure of the media library on disk.
[DebuggerDisplay("Title: {Title}")]
public record AddLibraryCommand(
string? Title,
@@ -27,5 +29,6 @@ public record AddLibraryCommand(
bool IsLocked,
bool CanDownloadMetadataFromWeb,
bool ShouldSaveMetadataInMediaDirectories,
- bool ShouldSkipUnchangedDirectoriesDuringScan
+ bool ShouldSkipUnchangedDirectoriesDuringScan,
+ LibraryPathTemplatePartDto[]? PathTemplateParts
) : ICommand;
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 44e6272e..d41a53cb 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandHandler.cs
@@ -11,6 +11,8 @@ using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Events;
using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
@@ -39,6 +41,7 @@ public class AddLibraryCommandHandler : ICommandHandler _validator;
///
@@ -49,6 +52,7 @@ public class AddLibraryCommandHandler : ICommandHandlerInjected service for the queue of domain events.
/// Injected facade service for environment contextual services.
/// Injected store of the provider configurations of the media libraries.
+ /// Injected service for validating and resolving the path templates of the media libraries.
/// Injected unit of work for interacting with the data access layer repositories.
/// Injected validator for application validation rules.
public AddLibraryCommandHandler(
@@ -57,6 +61,7 @@ public class AddLibraryCommandHandler : ICommandHandler validator)
{
@@ -66,6 +71,7 @@ public class AddLibraryCommandHandler : ICommandHandler(command.LibraryType!);
+
+ // A library always carries a path template: the one provided by the user, or the ideal structure of the library type as its default.
+ Result> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
+ if (pathTemplatePartsResult.IsFailure)
+ return pathTemplatePartsResult.Errors;
+ LibraryPathTemplate pathTemplate = command.PathTemplateParts is null
+ ? _pathTemplateService.GetDefaultTemplate(libraryType)
+ : LibraryPathTemplate.Create(pathTemplatePartsResult.Value);
+ Result validatePathTemplateResult = _pathTemplateService.Validate(libraryType, pathTemplate);
+ if (validatePathTemplateResult.IsFailure)
+ return validatePathTemplateResult.Errors;
+
// Create a domain library object.
Result createLibraryResult = Library.Create(
UserId.Create(userId),
command.Title!,
- Enum.Parse(command.LibraryType!),
+ libraryType,
command.ContentLocations!,
Optional.FromNullable(command.CoverImage),
command.IsEnabled,
@@ -120,6 +139,7 @@ public class AddLibraryCommandHandler : ICommandHandler ensureProviderConfigurationsResult = await _providerConfigurationStore.EnsureProviderConfigurationsAsync(
- createLibraryResult.Value.Id.Value, Enum.Parse(command.LibraryType!), cancellationToken).ConfigureAwait(false);
+ createLibraryResult.Value.Id.Value, libraryType, cancellationToken).ConfigureAwait(false);
if (ensureProviderConfigurationsResult.IsFailure)
return ensureProviderConfigurationsResult.Errors;
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 b439d346..a1ad34cb 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/AddLibrary/AddLibraryCommandValidator.cs
@@ -41,5 +41,17 @@ public class AddLibraryCommandValidator : AbstractValidator
.WithError(Errors.Library.TitleCannotBeEmpty)
.MaximumLength(255)
.WithError(Errors.Library.TitleMustBeMaximum255CharactersLong);
+
+ RuleForEach(command => command.PathTemplateParts)
+ .ChildRules(part =>
+ {
+ part.RuleFor(pathPart => pathPart.Kind)
+ .NotEmpty()
+ .WithError(Errors.Library.PathTemplatePartKindNotSupportedForLibraryType);
+ part.RuleFor(pathPart => pathPart.Representation)
+ .NotEmpty()
+ .When(pathPart => !string.Equals(pathPart.Kind, nameof(LibraryPathPartKind.Separator), StringComparison.OrdinalIgnoreCase))
+ .WithError(Errors.Library.PathTemplateLiteralCannotBeEmpty);
+ });
}
}
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs
index 63fd4be0..27965444 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommand.cs
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DTO.MediaLibrary.Management;
using System;
using System.Diagnostics;
#endregion
@@ -20,6 +21,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary
/// Whether this media library should update the metadata of its elements from the web, or not.
/// Whether this media library should copy the downloaded metadata into the media library content locations, or not.
/// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.
+/// The ordered parts of the template describing the structure of the media library on disk.
[DebuggerDisplay("Title: {Title}")]
public record UpdateLibraryCommand(
Guid Id,
@@ -32,5 +34,6 @@ public record UpdateLibraryCommand(
bool IsLocked,
bool CanDownloadMetadataFromWeb,
bool ShouldSaveMetadataInMediaDirectories,
- bool ShouldSkipUnchangedDirectoriesDuringScan
+ bool ShouldSkipUnchangedDirectoriesDuringScan,
+ LibraryPathTemplatePartDto[]? PathTemplateParts
) : ICommand;
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 42fe46cb..6f0a8dc2 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandHandler.cs
@@ -12,6 +12,7 @@ using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.Common.Events;
using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
@@ -43,6 +44,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler _validator;
///
@@ -53,6 +55,7 @@ public class UpdateLibraryCommandHandler : ICommandHandlerInjected service for the queue of domain events.
/// Injected facade service for environment contextual services.
/// Injected store of the provider configurations of the media libraries.
+ /// Injected service for validating and resolving the path templates of the media libraries.
/// Injected unit of work for interacting with the data access layer repositories.
/// Injected validator for application validation rules.
public UpdateLibraryCommandHandler(
@@ -61,6 +64,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler validator)
{
@@ -70,6 +74,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler(command.LibraryType!);
+
+ // A library always carries a path template: the one provided by the user, or the ideal structure of the library type as its default.
+ Result> pathTemplatePartsResult = command.PathTemplateParts.ToDomainParts();
+ if (pathTemplatePartsResult.IsFailure)
+ return pathTemplatePartsResult.Errors;
+ LibraryPathTemplate pathTemplate = command.PathTemplateParts is null
+ ? _pathTemplateService.GetDefaultTemplate(newLibraryType)
+ : LibraryPathTemplate.Create(pathTemplatePartsResult.Value);
+ Result validatePathTemplateResult = _pathTemplateService.Validate(newLibraryType, pathTemplate);
+ if (validatePathTemplateResult.IsFailure)
+ return validatePathTemplateResult.Errors;
+
Result createLibraryResult = Library.Create(
LibraryId.Create(command.Id),
UserId.Create(command.OwnerId),
@@ -136,6 +153,7 @@ public class UpdateLibraryCommandHandler : ICommandHandler ScanId.Create(libraryScan.Id))]
);
if (createLibraryResult.IsFailure)
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 53ed0211..febdd879 100644
--- a/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Commands/UpdateLibrary/UpdateLibraryCommandValidator.cs
@@ -53,5 +53,17 @@ public class UpdateLibraryCommandValidator : AbstractValidator command.PathTemplateParts)
+ .ChildRules(part =>
+ {
+ part.RuleFor(pathPart => pathPart.Kind)
+ .NotEmpty()
+ .WithError(Errors.Library.PathTemplatePartKindNotSupportedForLibraryType);
+ part.RuleFor(pathPart => pathPart.Representation)
+ .NotEmpty()
+ .When(pathPart => !string.Equals(pathPart.Kind, nameof(LibraryPathPartKind.Separator), StringComparison.OrdinalIgnoreCase))
+ .WithError(Errors.Library.PathTemplateLiteralCannotBeEmpty);
+ });
}
}
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryPathTemplateParts/GetLibraryPathTemplatePartsQuery.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryPathTemplateParts/GetLibraryPathTemplatePartsQuery.cs
new file mode 100644
index 00000000..acf7fb9f
--- /dev/null
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryPathTemplateParts/GetLibraryPathTemplatePartsQuery.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
+
+///
+/// Query for getting the path parts available for a media library type.
+///
+/// The media library type whose available path parts are retrieved.
+[DebuggerDisplay("LibraryType: {LibraryType}")]
+public record GetLibraryPathTemplatePartsQuery(
+ string? LibraryType
+) : IQuery;
diff --git a/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryPathTemplateParts/GetLibraryPathTemplatePartsQueryHandler.cs b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryPathTemplateParts/GetLibraryPathTemplatePartsQueryHandler.cs
new file mode 100644
index 00000000..ac64fcec
--- /dev/null
+++ b/src/Lumina.Application/Core/MediaLibrary/Management/Queries/GetLibraryPathTemplateParts/GetLibraryPathTemplatePartsQueryHandler.cs
@@ -0,0 +1,72 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Contracts.Responses.MediaLibrary.Management;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.PathTemplate;
+using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraryPathTemplateParts;
+
+///
+/// Handler for the query to get the path template catalog available for a media library type.
+///
+public class GetLibraryPathTemplatePartsQueryHandler : IQueryHandler>
+{
+ private readonly IReadOnlyList _catalogs;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected path part catalogs of the supported media library types.
+ public GetLibraryPathTemplatePartsQueryHandler(IEnumerable catalogs)
+ {
+ _catalogs = [.. catalogs];
+ }
+
+ ///
+ /// Handles the query to get the path template catalog available for a media library type.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either the path template catalog, or an error message.
+ ///
+ public Task> HandleAsync(GetLibraryPathTemplatePartsQuery query, CancellationToken cancellationToken)
+ {
+ // the library type travels as a string taken from the route, and is matched against the enum the same way the create and update
+ // library commands do, so that a malformed type is reported as an unknown library type instead of silently returning an empty catalog.
+ if (!Enum.TryParse(query.LibraryType, ignoreCase: true, out LibraryType libraryType))
+ return Task.FromResult>(DomainErrors.Library.UnknownLibraryType);
+
+ // only the catalog registered for the requested library type applies, so the parts and the default structure offered to the user are
+ // type aware (music libraries get artist and release parts, book libraries get author and title parts, and so on).
+ ILibraryPathPartCatalog? catalog = _catalogs.FirstOrDefault(candidate => candidate.SupportedLibraryType == libraryType);
+ if (catalog is null)
+ // a library type without a catalog has no structure to describe, so an empty catalog is returned, which the client uses to hide the editor.
+ return Task.FromResult(Result.Success(new LibraryPathTemplateCatalogResponse([], [])));
+
+ // the selectable parts describe what the user can drop into the template, together with the value type and the default on-disk representation of each part.
+ List parts =
+ [
+ .. catalog.GetPartDefinitions().Select(definition => new LibraryPathPartDefinitionResponse(
+ definition.Kind.ToString(),
+ definition.ValueType.ToString(),
+ definition.DefaultRepresentation,
+ definition.IsOptionalByDefault))
+ ];
+ // the default template parts describe the ideal structure the application expects, pre-filled in the editor so the user only edits what deviates.
+ List defaultTemplateParts =
+ [
+ .. catalog.GetDefaultTemplate().Parts.Select(part => new LibraryPathTemplatePartResponse(part.Kind.ToString(), part.Representation, part.IsOptional))
+ ];
+ return Task.FromResult(Result.Success(new LibraryPathTemplateCatalogResponse(parts, defaultTemplateParts)));
+ }
+}
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs
index df43eb8d..8f8e7196 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/AddLibraryRequest.cs
@@ -16,6 +16,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
/// Whether this media library should update the metadata of its elements from the web, or not. Optional.
/// Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.
/// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.
+/// The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.
[DebuggerDisplay("Title: {Title}")]
public record AddLibraryRequest(
string? Title,
@@ -26,5 +27,6 @@ public record AddLibraryRequest(
bool IsLocked,
bool CanDownloadMetadataFromWeb,
bool ShouldSaveMetadataInMediaDirectories,
- bool ShouldSkipUnchangedDirectoriesDuringScan
+ bool ShouldSkipUnchangedDirectoriesDuringScan,
+ LibraryPathTemplatePartRequest[]? PathTemplateParts
);
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/GetLibraryPathTemplatePartsRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/GetLibraryPathTemplatePartsRequest.cs
new file mode 100644
index 00000000..41c8557c
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/GetLibraryPathTemplatePartsRequest.cs
@@ -0,0 +1,14 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.MediaLibrary.Management;
+
+///
+/// Represents a request to get the path parts available for a media library type.
+///
+/// The media library type whose available path parts are retrieved. Required.
+[DebuggerDisplay("LibraryType: {LibraryType}")]
+public record GetLibraryPathTemplatePartsRequest(
+ string? LibraryType
+);
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/LibraryPathTemplatePartRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/LibraryPathTemplatePartRequest.cs
new file mode 100644
index 00000000..bb4fab5e
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/LibraryPathTemplatePartRequest.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.MediaLibrary.Management;
+
+///
+/// Represents one part of the path template of a media library.
+///
+/// The kind of the path part. Required.
+/// The literal text or the value mask of the path part. Optional for separators, required otherwise.
+/// Whether the path part can be absent from the path. Optional.
+[DebuggerDisplay("Kind: {Kind}; Representation: {Representation}")]
+public record LibraryPathTemplatePartRequest(
+ string? Kind,
+ string? Representation,
+ bool IsOptional
+);
diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
index 9590f10a..ba3b9226 100644
--- a/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
+++ b/src/Lumina.Contracts/Requests/MediaLibrary/Management/UpdateLibraryRequest.cs
@@ -19,6 +19,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
/// Whether this media library should update the metadata of its elements from the web, or not. Optional.
/// Whether this media library should copy the downloaded metadata into the media library content locations, or not.
/// Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.
+/// The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.
[DebuggerDisplay("Title: {Title}")]
public record class UpdateLibraryRequest(
Guid Id,
@@ -31,5 +32,6 @@ public record class UpdateLibraryRequest(
bool IsLocked,
bool CanDownloadMetadataFromWeb,
bool ShouldSaveMetadataInMediaDirectories,
- bool ShouldSkipUnchangedDirectoriesDuringScan
+ bool ShouldSkipUnchangedDirectoriesDuringScan,
+ LibraryPathTemplatePartRequest[]? PathTemplateParts
);
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathPartDefinitionResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathPartDefinitionResponse.cs
new file mode 100644
index 00000000..43e7966c
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathPartDefinitionResponse.cs
@@ -0,0 +1,20 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.MediaLibrary.Management;
+
+///
+/// Represents a path part definition response.
+///
+/// The kind of the path part.
+/// The value type captured by the path part.
+/// The default representation of the path part, pre-filled when it is added to a template.
+/// Whether the path part is optional by default.
+[DebuggerDisplay("Kind: {Kind}; ValueType: {ValueType}")]
+public record LibraryPathPartDefinitionResponse(
+ string Kind,
+ string ValueType,
+ string DefaultRepresentation,
+ bool IsOptionalByDefault
+);
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathTemplateCatalogResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathTemplateCatalogResponse.cs
new file mode 100644
index 00000000..91434a61
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathTemplateCatalogResponse.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System.Collections.Generic;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.MediaLibrary.Management;
+
+///
+/// Represents a path template catalog response.
+///
+/// The path parts that can be used in the path template of the library type.
+/// The ordered parts of the default path template of the library type, describing the ideal structure the application expects.
+[DebuggerDisplay("Parts: {Parts.Count}; DefaultTemplateParts: {DefaultTemplateParts.Count}")]
+public record LibraryPathTemplateCatalogResponse(
+ List Parts,
+ List DefaultTemplateParts
+);
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathTemplatePartResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathTemplatePartResponse.cs
new file mode 100644
index 00000000..b48e2e2a
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryPathTemplatePartResponse.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.MediaLibrary.Management;
+
+///
+/// Represents a path template part response.
+///
+/// The kind of the path part.
+/// The literal text or the value mask of the path part.
+/// Whether the path part can be absent from the path.
+[DebuggerDisplay("Kind: {Kind}; Representation: {Representation}")]
+public record LibraryPathTemplatePartResponse(
+ string Kind,
+ string Representation,
+ bool IsOptional
+);
diff --git a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
index 9dff6ddc..63e17fb0 100644
--- a/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
+++ b/src/Lumina.Contracts/Responses/MediaLibrary/Management/LibraryResponse.cs
@@ -21,6 +21,7 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
/// Whether the media library should update the metadata of its elements from the web, or not.
/// Whether the media library should copy the downloaded metadata into the media library content locations, or not.
/// Whether the media library should skip the directories whose contents have not changed since the last scan, during the scan.
+/// The ordered parts of the template describing the structure of the media library on disk.
/// The date and time when the library was created.
/// The optional date and time when the library was updated.
[DebuggerDisplay("Title: {Title}")]
@@ -36,6 +37,7 @@ public record LibraryResponse(
bool CanDownloadMetadataFromWeb,
bool ShouldSaveMetadataInMediaDirectories,
bool ShouldSkipUnchangedDirectoriesDuringScan,
+ List PathTemplateParts,
DateTime CreatedOnUtc,
DateTime? UpdatedOnUtc
);
diff --git a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs
index 5f20f98a..ae9fcc88 100644
--- a/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/LibraryConfiguration.cs
@@ -66,6 +66,11 @@ public class LibraryConfiguration : IEntityTypeConfiguration
.HasDefaultValue(null)
.HasColumnOrder(10);
+ builder.Property(library => library.PathTemplateFingerprint)
+ .HasMaxLength(64)
+ .HasDefaultValue(null)
+ .HasColumnOrder(11);
+
// one user with many libraries
builder.HasOne(library => library.User)
.WithMany(user => user.Libraries)
@@ -95,21 +100,48 @@ public class LibraryConfiguration : IEntityTypeConfiguration
.IsRequired();
});
+ // the path template parts are ordered, so their position is stored explicitly and part of a unique index together with the library
+ builder.OwnsMany(library => library.PathTemplateParts, partBuilder =>
+ {
+ partBuilder.ToTable("LibraryPathTemplateParts");
+ partBuilder.WithOwner()
+ .HasForeignKey("LibraryId");
+
+ partBuilder.Property("Id")
+ .ValueGeneratedOnAdd();
+ partBuilder.HasKey("Id");
+ partBuilder.HasIndex("LibraryId", nameof(LibraryPathTemplatePartEntity.Position))
+ .IsUnique();
+
+ partBuilder.Property(part => part.Position)
+ .HasColumnName("Position")
+ .IsRequired();
+ partBuilder.Property(part => part.Kind)
+ .HasConversion()
+ .HasMaxLength(32)
+ .IsRequired();
+ partBuilder.Property(part => part.Representation)
+ .HasMaxLength(512)
+ .IsRequired();
+ partBuilder.Property(part => part.IsOptional)
+ .IsRequired();
+ });
+
// audit
builder.Property(library => library.CreatedOnUtc)
.IsRequired()
- .HasColumnOrder(11);
+ .HasColumnOrder(12);
builder.Property(library => library.CreatedBy)
.IsRequired()
- .HasColumnOrder(12);
+ .HasColumnOrder(13);
builder.Property(library => library.UpdatedOnUtc)
.HasDefaultValue(null)
- .HasColumnOrder(13);
+ .HasColumnOrder(14);
builder.Property(library => library.UpdatedBy)
.HasDefaultValue(null)
- .HasColumnOrder(14);
+ .HasColumnOrder(15);
}
}
diff --git a/src/Lumina.DataAccess/Common/Migrations/20261008064333_AddsLibraryPathTemplate.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20261008064333_AddsLibraryPathTemplate.Designer.cs
new file mode 100644
index 00000000..412d7c15
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20261008064333_AddsLibraryPathTemplate.Designer.cs
@@ -0,0 +1,3425 @@
+//
+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("20261008064333_AddsLibraryPathTemplate")]
+ partial class AddsLibraryPathTemplate
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.11");
+
+ modelBuilder.Entity("AlbumGenres", b =>
+ {
+ b.Property("AlbumId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("AlbumId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("AlbumGenres", (string)null);
+ });
+
+ modelBuilder.Entity("AlbumTags", b =>
+ {
+ b.Property("AlbumId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("AlbumId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("AlbumTags", (string)null);
+ });
+
+ modelBuilder.Entity("ArtistGenres", b =>
+ {
+ b.Property("ArtistId")
+ .HasColumnType("TEXT");
+
+ b.Property("GenreId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ArtistId", "GenreId");
+
+ b.HasIndex("GenreId");
+
+ b.ToTable("ArtistGenres", (string)null);
+ });
+
+ modelBuilder.Entity("ArtistTags", b =>
+ {
+ b.Property("ArtistId")
+ .HasColumnType("TEXT");
+
+ b.Property("TagId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ArtistId", "TagId");
+
+ b.HasIndex("TagId");
+
+ b.ToTable("ArtistTags", (string)null);
+ });
+
+ 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.MediaContributors.MediaContributorEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Biography")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("DateOfBirth")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("DateOfDeath")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("DisplayName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1)
+ .UseCollation("NOCASE");
+
+ b.Property("LegalName")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.HasKey("Id");
+
+ b.HasIndex("DisplayName")
+ .IsUnique();
+
+ b.ToTable("MediaContributors", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumContributorEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("AlbumId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("MediaContributorId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("Role")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.HasKey("Id");
+
+ b.HasIndex("MediaContributorId");
+
+ b.HasIndex("AlbumId", "MediaContributorId", "Role")
+ .IsUnique();
+
+ b.ToTable("AlbumContributors", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.AlbumEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ASIN")
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(28);
+
+ b.Property("ArtistId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("Barcode")
+ .HasMaxLength(13)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(33);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(32);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("Disambiguation")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("Label")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(27);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("LastMetadataUpdateUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(37);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("MediaFormat")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("MetadataProvider")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(38);
+
+ b.Property("MetadataStatus")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasDefaultValue("Pending")
+ .HasColumnOrder(36);
+
+ b.Property("MusicBrainzReleaseArtistId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(31);
+
+ b.Property("MusicBrainzReleaseGroupId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(30);
+
+ b.Property("MusicBrainzReleaseId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("OriginalLanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("OriginalLanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(17);
+
+ b.Property("OriginalLanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("OriginalReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("OriginalReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(8);
+
+ b.Property("OriginalTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("Packaging")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("ReReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("ReReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(10);
+
+ b.Property("ReleaseCountry")
+ .HasMaxLength(2)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("ReleaseStatus")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(20);
+
+ b.Property("ReleaseTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(26);
+
+ b.Property("ReleaseVersion")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("Script")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("TotalDiscs")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(21);
+
+ b.Property("TotalTracks")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(22);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(35);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(34);
+
+ b.HasKey("Id");
+
+ b.HasIndex("ArtistId", "Title");
+
+ b.HasIndex("LibraryId", "Title");
+
+ b.ToTable("Albums", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistContributorEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ArtistId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("MediaContributorId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("Role")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.HasKey("Id");
+
+ b.HasIndex("MediaContributorId");
+
+ b.HasIndex("ArtistId", "MediaContributorId", "Role")
+ .IsUnique();
+
+ b.ToTable("ArtistContributors", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.ArtistEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Country")
+ .HasMaxLength(2)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("Disambiguation")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("Gender")
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("IsEnded")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(10);
+
+ b.Property("LastMetadataUpdateUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("LifeSpanBegin")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("LifeSpanEnd")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("MetadataProvider")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("MetadataStatus")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasDefaultValue("Pending")
+ .HasColumnOrder(17);
+
+ b.Property("MusicBrainzArtistId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("SortName")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("Type")
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("Website")
+ .HasMaxLength(2048)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId", "Name")
+ .IsUnique();
+
+ b.ToTable("Artists", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicArtworkEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("ArtworkType")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("ContentHash")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(6);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("FileName")
+ .HasMaxLength(2048)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("LastUpdateUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("Ordinal")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.Property("OwnerId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("OwnerType")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("Provider")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(13);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.HasKey("Id");
+
+ b.HasIndex("Status");
+
+ b.HasIndex("OwnerType", "OwnerId", "ArtworkType", "Ordinal")
+ .IsUnique();
+
+ b.ToTable("MusicArtwork", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.MusicLibraryScanItemMetadataEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("AcoustId")
+ .HasMaxLength(64)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(25);
+
+ b.Property("ArtistName")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("AudioCodec")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("BitDepth")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(14);
+
+ b.Property("Bitrate")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(16);
+
+ b.Property("Channels")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(13);
+
+ b.Property("DiscNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(10);
+
+ b.Property("DurationInSeconds")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(11);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("LibraryScanId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.PrimitiveCollection("Moods")
+ .IsRequired()
+ .HasColumnType("TEXT")
+ .HasColumnOrder(30);
+
+ b.Property("MusicBrainzArtistId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(17);
+
+ b.Property("MusicBrainzRecordingId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(21);
+
+ b.Property("MusicBrainzReleaseArtistId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(18);
+
+ b.Property("MusicBrainzReleaseGroupId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(19);
+
+ b.Property("MusicBrainzReleaseId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(20);
+
+ b.Property("MusicBrainzTrackId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(22);
+
+ b.Property("MusicBrainzWorkId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(23);
+
+ b.Property("Path")
+ .IsRequired()
+ .HasMaxLength(2048)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("ReleaseName")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("ReleaseType")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("ReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(6);
+
+ b.Property("ReplayGainAlbumGain")
+ .HasColumnType("decimal(8,2)")
+ .HasColumnOrder(28);
+
+ b.Property("ReplayGainAlbumPeak")
+ .HasColumnType("decimal(8,6)")
+ .HasColumnOrder(29);
+
+ b.Property("ReplayGainTrackGain")
+ .HasColumnType("decimal(8,2)")
+ .HasColumnOrder(26);
+
+ b.Property("ReplayGainTrackPeak")
+ .HasColumnType("decimal(8,6)")
+ .HasColumnOrder(27);
+
+ b.Property("SampleRate")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(12);
+
+ b.Property("TrackNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(9);
+
+ b.Property("TrackTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("WorkTitle")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryScanId", "Path")
+ .IsUnique();
+
+ b.ToTable("MusicLibraryScanItemMetadata", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackContributorEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("MediaContributorId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("Role")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.Property("TrackId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.HasKey("Id");
+
+ b.HasIndex("MediaContributorId");
+
+ b.HasIndex("TrackId", "MediaContributorId", "Role")
+ .IsUnique();
+
+ b.ToTable("TrackContributors", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary.TrackEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("AcoustId")
+ .HasMaxLength(64)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(44);
+
+ b.Property("AlbumId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("AudioCodec")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(24);
+
+ b.Property("BitDepth")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(23);
+
+ b.Property("Bitrate")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(25);
+
+ b.Property("Bpm")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(30);
+
+ b.Property("Channels")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(22);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(38);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(37);
+
+ b.Property("Description")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("Disambiguation")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("DiscNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(27);
+
+ b.Property("DurationInSeconds")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(20);
+
+ b.Property("IsVideo")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(31);
+
+ b.Property("Key")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(29);
+
+ b.Property("LanguageCode")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(14);
+
+ b.Property("LanguageName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(15);
+
+ b.Property("LanguageNativeName")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("LastMetadataUpdateUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(42);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property