diff --git a/.gitignore b/.gitignore
index 898b006a..12452e6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,8 @@ $RECYCLE.BIN/
# Archives
*.zip
+# bundled themes should be tracked
+!src/Lumina.Presentation.Api/Core/Themes/Bundled/*.zip
*.tar.gz
*.rar
diff --git a/docs/technical/theming/Theming.md b/docs/technical/theming/Theming.md
new file mode 100644
index 00000000..3a206beb
--- /dev/null
+++ b/docs/technical/theming/Theming.md
@@ -0,0 +1,334 @@
+# Lumina Theming
+
+The web client of Lumina is a themed shell: every page is rendered inside the templates of an active theme. A theme is a self contained ZIP archive with a manifest, HTML templates and static assets. This document explains how themes are structured, how the template engine works, and how to create, install and manage a theme.
+
+- [Lumina Theming](#lumina-theming)
+ - [Overview](#overview)
+ - [Theme Pack Structure](#theme-pack-structure)
+ - [The Manifest (theme.json)](#the-manifest-themejson)
+ - [Pack Validation Rules](#pack-validation-rules)
+ - [Templates](#templates)
+ - [Template Syntax](#template-syntax)
+ - [Expressions](#expressions)
+ - [Safety Limits](#safety-limits)
+ - [Template Resolution](#template-resolution)
+ - [The Layout Template (shared/layout)](#the-layout-template-sharedlayout)
+ - [The Navigation Template (shared/nav-menu)](#the-navigation-template-sharednav-menu)
+ - [Page Templates](#page-templates)
+ - [The Scripts Section](#the-scripts-section)
+ - [Assets](#assets)
+ - [Configuration Options](#configuration-options)
+ - [Creating a Theme](#creating-a-theme)
+ - [Installing a Theme](#installing-a-theme)
+ - [Bundled Themes](#bundled-themes)
+ - [Selecting the Current Theme](#selecting-the-current-theme)
+ - [Managing Themes from the Administration Page](#managing-themes-from-the-administration-page)
+ - [Security Notes](#security-notes)
+
+## Overview
+
+The application stores installed themes on the API server and serves their templates and assets. The web client fetches the templates of the active theme and renders them locally with a small, non-executable Mustache-style template engine. Theme templates can interpolate values, iterate collections and test truthiness, but they cannot run code.
+
+Because the templates are HTML, a theme can restyle the whole application, rearrange the layout and navigation, and provide custom pages for the built-in routes. A theme cannot extend the functionality of the application: it only shapes how the existing pages look and are structured.
+
+## Theme Pack Structure
+
+A theme pack is a directory that is shipped as a ZIP archive with `theme.json` at its root:
+
+```
+my-theme/
+ theme.json
+ assets/
+ preview.svg
+ theme.css
+ templates/
+ index.html
+ shared/
+ layout.html
+ nav-menu.html
+ not-found.html
+ library/
+ written-content-library/
+ book-library/
+ books/
+ index.html
+```
+
+Only three locations may exist inside a pack:
+
+- `theme.json`, the manifest, at the root of the archive.
+- `templates/`, holding the HTML templates.
+- `assets/`, holding any static file served to the browser (stylesheets, images, fonts, scripts).
+
+The bundled reference theme `editorial-paper` follows exactly this layout and is the best starting point when authoring a new theme.
+
+## The Manifest (theme.json)
+
+The manifest is a JSON object describing the theme. The example below is the manifest of the bundled `editorial-paper` theme:
+
+```json
+{
+ "schemaVersion": 1,
+ "id": "editorial-paper",
+ "name": "Editorial Paper",
+ "description": "A clean, readable proof of concept theme.",
+ "author": "Lumina",
+ "version": "1.4.0",
+ "preview": "assets/preview.svg",
+ "templates": {
+ "default": "templates/index.html"
+ }
+}
+```
+
+| Field | Required | Rule |
+| --- | --- | --- |
+| `schemaVersion` | yes | Must be `1`. |
+| `id` | yes | A lowercase kebab-case value, up to 64 characters, used to reference the theme. For example `editorial-paper` or `my-dark-theme`. |
+| `name` | yes | Display name, up to 80 characters. |
+| `description` | yes | Description of the theme, up to 300 characters. |
+| `author` | yes | Author of the theme, up to 80 characters. |
+| `version` | yes | Semantic version form, for example `1.0.0`. Up to 40 characters. |
+| `preview` | no | Path to a preview image, relative to the pack root and under `assets/`. Shown on the administration page. |
+| `templates` | yes | A mapping from template key to a file under `templates/`, with 1 to 32 entries. Must include the `default` key. |
+
+All text fields must be non-empty and must not contain control characters. Template keys follow the same lowercase kebab-case rule as the theme id and are at most 40 characters. Template paths are normalized and must point to an existing file under `templates/`.
+
+## Pack Validation Rules
+
+A theme archive is validated on install:
+
+- `theme.json` must exist at the root of the archive and be at most 64 KB.
+- Only `theme.json`, files under `templates/` and files under `assets/` are allowed. Anything else makes the archive invalid.
+- Paths are normalized and any path that would escape the pack is rejected.
+- `theme.json` must contain a valid manifest object that satisfies the rules in the previous section.
+
+Installing a theme is an atomic operation: an invalid pack is rejected entirely and nothing is left behind.
+
+## Templates
+
+Templates are rendered with the built-in template engine. The engine is intentionally small and safe: it parses Mustache-style tags and renders them against a model. It never executes arbitrary code.
+
+### Template Syntax
+
+| Syntax | Meaning |
+| --- | --- |
+| `{{name}}` | Outputs the value of `name`, HTML-escaped. |
+| `{{{name}}}` | Outputs the value of `name` without escaping. |
+| `{{&name}}` | Outputs the value of `name` without escaping. |
+| `{{!comment}}` | A comment, produces no output. |
+| `{{#name}}...{{/name}}` | A section. Renders its children when the value is truthy. When the value is a collection, the children are rendered once per item. |
+| `{{^name}}...{{/name}}` | An inverted section. Renders its children when the value is falsy. |
+
+### Expressions
+
+Expressions resolve against the model and support:
+
+- Dotted property paths, for example `{{user.name}}`. Dictionary keys and public properties are matched case-insensitively.
+- Parent traversal, for example `{{../title}}`, to reach values outside the current section scope.
+- The current value, for example `{{.}}`.
+- `{{#count}}` on a collection, where `Count` is exposed for collections.
+
+Values that do not exist resolve to an empty string for variables, or to falsy for sections. Truthiness follows these rules: `null`, `false`, empty strings and empty collections are falsy; everything else is truthy.
+
+### Safety Limits
+
+The template engine enforces hard limits so a single theme cannot exhaust the server:
+
+| Limit | Value |
+| --- | --- |
+| Maximum section nesting depth | 32 levels |
+| Maximum expression length | 120 characters |
+| Maximum rendered output | 4 MB per page |
+
+A template that exceeds any of these limits is rejected with a template error and the page falls back to the application layout.
+
+### Template Resolution
+
+Every themed page is identified by a page key that mirrors the path of the corresponding Razor view. When a page is rendered, its template is selected in this order:
+
+1. An explicit mapping in `templates` when the manifest declares the page key.
+2. A mirrored template file at `templates/{pageKey}.html`, walking up the scope of the path when the exact mirror does not exist.
+3. The `default` template from the manifest.
+
+For example, the books index page has the page key `library/written-content-library/book-library/books/index`. The engine tries, in order: the explicit `templates` entry for that key, `templates/library/written-content-library/book-library/books/index.html`, then the parent scopes such as `templates/library/written-content-library/book-library/books.html`, and finally the `default` template.
+
+Known page keys:
+
+| Page key | Purpose |
+| --- | --- |
+| `shared/layout` | The layout that wraps the shell of every page. |
+| `shared/nav-menu` | The navigation menu of the theme. |
+| `shared/not-found` | The 404 page. |
+| `library/written-content-library/book-library/books/index` | The books browsing page. |
+
+### The Layout Template (shared/layout)
+
+Every page is rendered inside the layout template. The layout receives a model with the following fields:
+
+| Field | Content |
+| --- | --- |
+| `title` | The title of the page. |
+| `assetBase` | The base URL of the theme assets, for example `/theme-assets/editorial-paper/assets`. |
+| `appHead` | The head links of the application, such as its global stylesheets. |
+| `nav` | The fully rendered navigation menu HTML. |
+| `content` | The fully rendered content section of the page. |
+| `audioPlayer` | The rendered audio player when the user is authenticated, empty otherwise. |
+| `appScripts` | The global scripts of the application. |
+| `scripts` | The rendered script section of the page. |
+| `mainStyle` | An inline style for the main content area, `bottom: 0px;` when the user is not authenticated and empty otherwise. |
+
+The layout template of the bundled theme shows the intended shape:
+
+```html
+
+
+
+
+
+```
+
+The rendered page content, navigation and scripts are inserted unescaped with `{{&...}}`, because they are trusted application HTML. The layout is best effort: when the theme cannot be loaded or rendered, the application falls back to its built-in layout, so a broken theme never takes the whole site down.
+
+### The Navigation Template (shared/nav-menu)
+
+The navigation template renders the menu of the active theme. Its model contains the site name and two menu structures, one for the mobile menu and one for the desktop menu bar:
+
+- `siteName` is the site name.
+- `mobileSections` and `menubarSections` are lists of sections.
+- A section has a `label` and a list of `items`.
+- An item has a `label`, an optional `url`, an optional `cssClass` and a list of `children`. Items with children are submenus, items without children are plain links.
+
+The navigation template is also best effort: when its template cannot be rendered, the application menu is used instead.
+
+### Page Templates
+
+The remaining templates render individual pages. Each page exposes its own data, so the available fields depend on the page. In addition to page specific values, pages expose a `strings` dictionary with the localized strings of the page, keyed by their resource names, so templates can pull any label without hardcoding text.
+
+Page templates are rendered into a content section that the layout wraps. A page template can also declare a reserved top-level `scripts` section, whose content is rendered separately and passed to the layout, mirroring the `Scripts` section of a Razor view:
+
+```html
+{{#title}}
+
{{title}}
+{{/title}}
+
+{{^title}}
+
No title available.
+{{/title}}
+
+{{#sections}}
+
+
{{label}}
+
+{{/sections}}
+
+{{#scripts}}
+
+{{/scripts}}
+```
+
+### The Scripts Section
+
+JavaScript is always allowed in themes: script elements in templates are served and rendered as-is, and script files under `assets/` are served normally. A theme relies on scripts for the client side navigation of the application, because pages are swapped in place by the global AJAX navigator, so themes are expected to ship their own JavaScript. Because JavaScript is enabled, *themes can execute malicious code*, so, be aware about the source of your installed themes! Themes bundled with the application are reviewed and safe.
+
+## Assets
+
+Static files under `assets/` are served to the browser. The asset base URL is available to the layout and page templates as `assetBase`, so a stylesheet is referenced as `{{assetBase}}/theme.css`. Assets are served only from within the pack, and paths that would escape the pack are rejected.
+
+The `preview` field of the manifest points at an asset that is shown as the theme thumbnail on the administration page.
+
+## Configuration Options
+
+The theme engine is configured through the `ThemeEngine` section of the API configuration (`appsettings.shared.json`):
+
+| Option | Default | Meaning |
+| --- | --- | --- |
+| `StoragePath` | `themes` | Directory where installed theme packs are stored, relative to the API base directory when not rooted. |
+| `BundledThemesPath` | `themes/bundled` | Directory where the theme archives shipped with the application are located. |
+| `DefaultThemeId` | `lumina-default` | Identifier of the theme selected when no valid current theme is persisted. |
+| `MaxArchiveBytes` | `8388608` | Maximum size of an uploaded theme archive, in bytes (8 MB). |
+| `MaxExpandedBytes` | `25165824` | Maximum total size of an extracted theme pack, in bytes (24 MB). |
+| `MaxSingleFileBytes` | `6291456` | Maximum size of a single file within a theme pack, in bytes (6 MB). |
+| `MaxEntries` | `250` | Maximum number of entries in a theme pack archive. |
+
+## Creating a Theme
+
+1. Create a directory for the theme with `theme.json`, a `templates/` directory and an `assets/` directory, following the layout of `editorial-paper`.
+2. Write the manifest following the field rules in [The Manifest (theme.json)](#the-manifest-themejson).
+3. Author the templates. Start with `templates/shared/layout.html` and `templates/shared/nav-menu.html`, then add page templates and the `default` template.
+4. Add the static files under `assets/`, for example a stylesheet referenced from the layout.
+5. Keep the pack within the size limits: the archive at most 8 MB, the extracted pack at most 24 MB, no single file larger than 6 MB and at most 250 entries.
+6. Compress the directory into a ZIP archive with `theme.json` at the root of the archive, not nested inside an extra folder.
+
+## Installing a Theme
+
+A theme is installed by uploading its ZIP archive:
+
+- From the administration themes page, using the upload control.
+- Directly against the API with a `multipart/form-data` POST to `POST /api/v1/themes`, sending the archive in a form field named `archive`.
+
+The archive is validated against the pack rules and stored on the server under `themes/{id}`. Installing a theme with an id that already exists replaces the files of the existing theme. A newly installed theme is not active until it is selected as the current theme.
+
+Validation failures are returned as problem details, for example when the archive is unreadable, the manifest is invalid, or a template references a missing file.
+
+## Bundled Themes
+
+The archives shipped with the application live in the API under `Core/Themes/Bundled` and are installed automatically at startup by the theme detection job. `editorial-paper` is the bundled reference theme.
+
+A bundled theme whose files go missing or are corrupted is restored automatically from its shipped archive on the next startup, unless the user explicitly deleted the theme from the Administrator - Themes page. This means bundled themes always come back unless the user removes them. The last available theme cannot be deleted.
+
+## Selecting the Current Theme
+
+The current theme is the one whose templates are used for page rendering. At startup, when no theme is current, the application activates one automatically, preferring the configured default theme id. The active theme is exposed at `GET /api/v1/themes/current` and can be changed from the administration page, which calls `PUT /api/v1/themes/current`.
+
+## Managing Themes from the Administration Page
+
+The administration themes page lists every installed theme and provides:
+
+- A preview thumbnail for each theme, taken from the `preview` field of the manifest.
+- The source of the theme, either bundled with the application or provided by a user.
+- The ability to set the current theme, download a theme as a ZIP archive and install a new theme.
+- The ability to delete a theme, subject to these rules:
+ - Only administrators can delete themes.
+ - The last remaining bundled theme cannot be deleted, so the application never ends up without a theme.
+ - When the active theme is deleted, another available theme is activated automatically, preferring the configured default.
+ - Bundled themes are soft deleted (the theme files are deleted, but the theme zip archive is kept), so they can be restored; user themes are removed entirely, because their files are not shipped with the application.
+
+## Security Notes
+
+Theme packs are treated as untrusted input:
+
+- Values rendered with `{{name}}` are HTML-encoded, so a theme cannot inject markup through a model value.
+- Themes can contain javascript, which means, they can run malicious code. Only install themes from sources you trust, or review the code of the theme files.
+- Paths are normalized and validated so that templates and assets cannot escape the theme pack or the storage directory.
+- The template engine has no access to the application and cannot execute code, only render values against the model.
+- Size and count limits prevent an archive from exhausting server memory or disk.
diff --git a/src/Lumina.Application/Common/DataAccess/Entities/Themes/ThemeEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/Themes/ThemeEntity.cs
new file mode 100644
index 00000000..4b698c47
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Entities/Themes/ThemeEntity.cs
@@ -0,0 +1,90 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Entities.Themes;
+
+///
+/// Repository entity for a theme.
+///
+[DebuggerDisplay("ThemeId: {ThemeId}, Name: {Name}")]
+public class ThemeEntity : IStorageEntity, IAuditableEntity
+{
+ ///
+ /// Gets the Id of the theme.
+ ///
+ public required Guid Id { get; init; }
+
+ ///
+ /// Gets or sets the unique identifier of the theme, taken from its manifest and used by clients to reference it.
+ ///
+ public required string ThemeId { get; set; }
+
+ ///
+ /// Gets or sets the display name of the theme.
+ ///
+ public required string Name { get; set; }
+
+ ///
+ /// Gets or sets the description of the theme.
+ ///
+ public required string Description { get; set; }
+
+ ///
+ /// Gets or sets the author of the theme.
+ ///
+ public required string Author { get; set; }
+
+ ///
+ /// Gets or sets the version of the theme, using semantic version form.
+ ///
+ public required string Version { get; set; }
+
+ ///
+ /// Gets or sets the path of the theme preview image, relative to the theme pack root, or when the theme has no preview.
+ ///
+ public string? PreviewPath { get; set; }
+
+ ///
+ /// Gets or sets the source the theme was installed from.
+ ///
+ public required ThemeInstallSource InstallSource { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether this is the currently active theme. At most one theme can be current.
+ ///
+ public bool? IsCurrent { get; set; }
+
+ ///
+ /// Gets or sets a value indicating whether the theme was soft deleted, so it is not shown and not reinstalled automatically.
+ ///
+ public bool IsDeleted { get; set; }
+
+ ///
+ /// Gets or sets the UTC timestamp at which the theme was installed.
+ ///
+ public required DateTime InstalledAtUtc { 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/UsersManagement/UserSettingsEntity.cs b/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs
index 768de9e8..524544bb 100644
--- a/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs
+++ b/src/Lumina.Application/Common/DataAccess/Entities/UsersManagement/UserSettingsEntity.cs
@@ -37,6 +37,11 @@ public class UserSettingsEntity : IStorageEntity, IAuditableEntity
///
public bool IgnoreThePrefixForAlphaPicker { get; set; }
+ ///
+ /// Gets or sets whether the theme data served to this user is cached, or not.
+ ///
+ public bool IsThemeCachingEnabled { get; set; } = true;
+
///
/// Gets or sets the time and date when the entity was added.
///
diff --git a/src/Lumina.Application/Common/DataAccess/Repositories/Themes/IThemeRepository.cs b/src/Lumina.Application/Common/DataAccess/Repositories/Themes/IThemeRepository.cs
new file mode 100644
index 00000000..ae0d994b
--- /dev/null
+++ b/src/Lumina.Application/Common/DataAccess/Repositories/Themes/IThemeRepository.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
+using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
+using Lumina.Domain.Common.Primitives;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.DataAccess.Repositories.Themes;
+
+///
+/// Interface for the repository for themes.
+///
+public interface IThemeRepository : IRepository,
+ IGetAllRepositoryAction,
+ IInsertRepositoryAction,
+ IUpdateRepositoryAction,
+ IDeleteByIdRepositoryAction
+{
+ ///
+ /// Gets a theme identified by its manifest from the storage medium.
+ ///
+ /// The manifest id of the theme to get.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either a identified by , or an error.
+ Task> GetByThemeIdAsync(string themeId, CancellationToken cancellationToken);
+
+ ///
+ /// Gets the currently active theme from the storage medium.
+ ///
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the active , or an error.
+ Task> GetCurrentAsync(CancellationToken cancellationToken);
+}
diff --git a/src/Lumina.Application/Common/DataAccess/UoW/IUnitOfWork.cs b/src/Lumina.Application/Common/DataAccess/UoW/IUnitOfWork.cs
index f8717656..dc49b1f4 100644
--- a/src/Lumina.Application/Common/DataAccess/UoW/IUnitOfWork.cs
+++ b/src/Lumina.Application/Common/DataAccess/UoW/IUnitOfWork.cs
@@ -3,6 +3,7 @@ using Lumina.Application.Common.DataAccess.Repositories.Authorization;
using Lumina.Application.Common.DataAccess.Repositories.Books;
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
+using Lumina.Application.Common.DataAccess.Repositories.Themes;
using Lumina.Application.Common.DataAccess.Repositories.Users;
using System.Threading;
using System.Threading.Tasks;
@@ -75,6 +76,11 @@ public interface IUnitOfWork
///
IPluginRepository PluginRepository { get; }
+ ///
+ /// Gets the theme repository.
+ ///
+ IThemeRepository ThemeRepository { get; }
+
///
/// Gets the user repository.
///
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeArchiveDto.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeArchiveDto.cs
new file mode 100644
index 00000000..58b3d228
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeArchiveDto.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+
+///
+/// Data transfer object for a downloadable archive of a theme pack.
+///
+/// The bytes of the ZIP archive.
+/// The file name to expose when downloading the archive.
+/// The MIME content type of the archive.
+[DebuggerDisplay("FileName: {FileName}")]
+public sealed record ThemeArchiveDto(
+ byte[] Bytes,
+ string FileName,
+ string ContentType
+);
diff --git a/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeAssetDto.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeAssetDto.cs
new file mode 100644
index 00000000..307392cf
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeAssetDto.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+
+///
+/// Data transfer object for a theme asset file served by the theme service.
+///
+/// The bytes of the asset file.
+/// The MIME content type of the asset file.
+[DebuggerDisplay("ContentType: {ContentType}")]
+public sealed record ThemeAssetDto(
+ byte[] Bytes,
+ string ContentType
+);
diff --git a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeManifestDto.cs b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDto.cs
similarity index 87%
rename from src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeManifestDto.cs
rename to src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDto.cs
index 1e2f2b48..1888eda3 100644
--- a/src/Lumina.Presentation.Web/Common/DTO/Themes/ThemeManifestDto.cs
+++ b/src/Lumina.Application/Common/Infrastructure/Models/DTO/Themes/ThemeManifestDto.cs
@@ -4,10 +4,10 @@ using System.Collections.Generic;
using System.Diagnostics;
#endregion
-namespace Lumina.Presentation.Web.Common.DTO.Themes;
+namespace Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
///
-/// Data transfer object for the theme.json manifest of a theme package.
+/// Data transfer object for the theme.json manifest of a theme pack.
///
[DebuggerDisplay("Id: {Id}, Name: {Name}")]
public sealed class ThemeManifestDto
@@ -18,7 +18,7 @@ public sealed class ThemeManifestDto
public int SchemaVersion { get; set; }
///
- /// Gets or sets the unique identifier of the theme, a lowercase kebab-case value.
+ /// Gets or sets the unique identifier of the theme, a lowercase kebab-case value used by clients to reference it.
///
public string Id { get; set; } = string.Empty;
@@ -43,12 +43,12 @@ public sealed class ThemeManifestDto
public string Version { get; set; } = string.Empty;
///
- /// Gets or sets the preview image path relative to the theme package root, or when the theme has no preview.
+ /// Gets or sets the preview image path relative to the theme pack root, or when the theme has no preview.
///
public string? Preview { get; set; }
///
- /// Gets or sets the template mappings from template key to an HTML file path under templates/.
+ /// Gets or sets the template mappings from template key to a file path under templates/.
///
public Dictionary Templates { get; set; } = new(StringComparer.OrdinalIgnoreCase);
}
diff --git a/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs b/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs
new file mode 100644
index 00000000..e9c2bd4a
--- /dev/null
+++ b/src/Lumina.Application/Common/Infrastructure/Themes/IThemeService.cs
@@ -0,0 +1,105 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+using Lumina.Domain.Common.Primitives;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Common.Infrastructure.Themes;
+
+///
+/// Service for the storage and serving of theme packs.
+///
+public interface IThemeService
+{
+ ///
+ /// Gets the maximum allowed size of a theme archive, in bytes.
+ ///
+ long MaxArchiveBytes { get; }
+
+ ///
+ /// Gets the identifier of the theme selected when no valid current theme is available.
+ ///
+ string DefaultThemeId { get; }
+
+ ///
+ /// Installs a theme pack from the provided archive, replacing the files of an existing theme with the same manifest id.
+ ///
+ /// The ZIP archive stream of the theme pack.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the parsed manifest of the installed theme, or an error.
+ Task> InstallAsync(Stream archive, CancellationToken cancellationToken);
+
+ ///
+ /// Reads the manifest of a theme pack archive without installing it.
+ ///
+ /// The path of the theme pack ZIP archive.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the parsed manifest, or an error.
+ Task> ReadManifestFromArchiveAsync(string archivePath, CancellationToken cancellationToken);
+
+ ///
+ /// Deletes the stored files of a theme pack.
+ ///
+ /// The manifest id of the theme.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> DeleteAsync(string themeId, CancellationToken cancellationToken);
+
+ ///
+ /// Loads the manifest of an installed theme pack from its storage location.
+ ///
+ /// The manifest id of the theme.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the parsed manifest, or an error.
+ Task> LoadManifestAsync(string themeId, CancellationToken cancellationToken);
+
+ ///
+ /// Gets the sanitized content of the template selected by a page key, falling back to the default template when the key is missing.
+ ///
+ /// The manifest id of the theme.
+ /// The page key that selects the template.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the template content, or an error.
+ Task> GetTemplateAsync(string themeId, string pageKey, CancellationToken cancellationToken);
+
+ ///
+ /// Gets a theme asset file.
+ ///
+ /// The manifest id of the theme.
+ /// The asset path relative to the theme pack root.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the asset, or an error.
+ Task> GetAssetAsync(string themeId, string assetPath, CancellationToken cancellationToken);
+
+ ///
+ /// Builds a downloadable ZIP archive of an installed theme pack.
+ ///
+ /// The manifest id of the theme.
+ /// Cancellation token that can be used to stop the execution.
+ /// An containing either the archive, or an error.
+ Task> BuildArchiveAsync(string themeId, CancellationToken cancellationToken);
+
+ ///
+ /// Restores the files of a bundled theme from its shipped archive, used when the stored files were removed externally.
+ ///
+ /// The manifest id of the theme.
+ /// Cancellation token that can be used to stop the execution.
+ /// An representing either a successful operation, or an error.
+ Task> RestoreBundledThemeAsync(string themeId, CancellationToken cancellationToken);
+
+ ///
+ /// Checks whether the stored pack files of a theme still exist.
+ ///
+ /// The manifest id of the theme.
+ /// when the theme pack files exist, otherwise.
+ bool HasThemePack(string themeId);
+
+ ///
+ /// Gets the paths of the theme pack archives shipped with the application.
+ ///
+ /// The list of bundled theme archive paths.
+ IReadOnlyList GetBundledThemeArchivePaths();
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/DeleteThemeRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/DeleteThemeRequestMapping.cs
new file mode 100644
index 00000000..144c8493
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/DeleteThemeRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Themes.Management.Commands.DeleteTheme;
+using Lumina.Contracts.Requests.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class DeleteThemeRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static DeleteThemeCommand ToCommand(this DeleteThemeRequest request)
+ {
+ return new DeleteThemeCommand(request.ThemeId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/GetThemeArchiveRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/GetThemeArchiveRequestMapping.cs
new file mode 100644
index 00000000..11a4b707
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/GetThemeArchiveRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Themes.Management.Queries.GetThemeArchive;
+using Lumina.Contracts.Requests.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class GetThemeArchiveRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetThemeArchiveQuery ToQuery(this GetThemeArchiveRequest request)
+ {
+ return new GetThemeArchiveQuery(request.ThemeId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/GetThemeAssetRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/GetThemeAssetRequestMapping.cs
new file mode 100644
index 00000000..c2f718d3
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/GetThemeAssetRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Themes.Management.Queries.GetThemeAsset;
+using Lumina.Contracts.Requests.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class GetThemeAssetRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetThemeAssetQuery ToQuery(this GetThemeAssetRequest request)
+ {
+ return new GetThemeAssetQuery(request.ThemeId, request.AssetPath);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/GetThemeTemplateRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/GetThemeTemplateRequestMapping.cs
new file mode 100644
index 00000000..647c8db8
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/GetThemeTemplateRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Themes.Management.Queries.GetThemeTemplate;
+using Lumina.Contracts.Requests.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class GetThemeTemplateRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted query.
+ public static GetThemeTemplateQuery ToQuery(this GetThemeTemplateRequest request)
+ {
+ return new GetThemeTemplateQuery(request.ThemeId, request.PageKey);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/RestoreThemeRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/RestoreThemeRequestMapping.cs
new file mode 100644
index 00000000..e4087116
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/RestoreThemeRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Themes.Management.Commands.RestoreTheme;
+using Lumina.Contracts.Requests.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class RestoreThemeRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static RestoreThemeCommand ToCommand(this RestoreThemeRequest request)
+ {
+ return new RestoreThemeCommand(request.ThemeId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/SetCurrentThemeRequestMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/SetCurrentThemeRequestMapping.cs
new file mode 100644
index 00000000..035b69e1
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/SetCurrentThemeRequestMapping.cs
@@ -0,0 +1,22 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Themes.Management.Commands.SetCurrentTheme;
+using Lumina.Contracts.Requests.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class SetCurrentThemeRequestMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The request to be converted.
+ /// The converted command.
+ public static SetCurrentThemeCommand ToCommand(this SetCurrentThemeRequest request)
+ {
+ return new SetCurrentThemeCommand(request.ThemeId);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/Themes/ThemeEntityMapping.cs b/src/Lumina.Application/Common/Mapping/Themes/ThemeEntityMapping.cs
new file mode 100644
index 00000000..b3460bc2
--- /dev/null
+++ b/src/Lumina.Application/Common/Mapping/Themes/ThemeEntityMapping.cs
@@ -0,0 +1,33 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Contracts.Responses.Themes;
+#endregion
+
+namespace Lumina.Application.Common.Mapping.Themes;
+
+///
+/// Extension methods for converting .
+///
+public static class ThemeEntityMapping
+{
+ ///
+ /// Converts to .
+ ///
+ /// The repository entity to be converted.
+ /// The converted response.
+ public static ThemeResponse ToResponse(this ThemeEntity theme)
+ {
+ return new ThemeResponse(
+ theme.Id,
+ theme.ThemeId,
+ theme.Name,
+ theme.Description,
+ theme.Author,
+ theme.Version,
+ theme.PreviewPath,
+ theme.InstallSource,
+ theme.IsCurrent,
+ theme.InstalledAtUtc,
+ theme.IsDeleted);
+ }
+}
diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs
index 8eee0bcb..23504a3c 100644
--- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UpdateUserSettingsRequestMapping.cs
@@ -20,6 +20,7 @@ public static class UpdateUserSettingsRequestMapping
return new UpdateUserSettingsCommand(
request.IsPaginationEnabled,
request.ItemsPerPage,
- request.IgnoreThePrefixForAlphaPicker);
+ request.IgnoreThePrefixForAlphaPicker,
+ request.IsThemeCachingEnabled);
}
}
diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs
index a109efca..b96f8fdb 100644
--- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsEntityMapping.cs
@@ -28,7 +28,8 @@ public static class UserSettingsEntityMapping
UserId.Create(repositoryEntity.UserId),
repositoryEntity.IsPaginationEnabled,
repositoryEntity.ItemsPerPage,
- repositoryEntity.IgnoreThePrefixForAlphaPicker);
+ repositoryEntity.IgnoreThePrefixForAlphaPicker,
+ repositoryEntity.IsThemeCachingEnabled);
}
///
@@ -42,6 +43,7 @@ public static class UserSettingsEntityMapping
repositoryEntity.UserId,
repositoryEntity.IsPaginationEnabled,
repositoryEntity.ItemsPerPage,
- repositoryEntity.IgnoreThePrefixForAlphaPicker);
+ repositoryEntity.IgnoreThePrefixForAlphaPicker,
+ repositoryEntity.IsThemeCachingEnabled);
}
}
diff --git a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs
index 45764c56..7a22ee1e 100644
--- a/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs
+++ b/src/Lumina.Application/Common/Mapping/UsersManagement/Users/UserSettingsMapping.cs
@@ -24,7 +24,8 @@ public static class UserSettingsMapping
UserId = domainEntity.UserId.Value,
IsPaginationEnabled = domainEntity.IsPaginationEnabled,
ItemsPerPage = domainEntity.ItemsPerPage,
- IgnoreThePrefixForAlphaPicker = domainEntity.IgnoreThePrefixForAlphaPicker
+ IgnoreThePrefixForAlphaPicker = domainEntity.IgnoreThePrefixForAlphaPicker,
+ IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled
};
}
@@ -39,6 +40,7 @@ public static class UserSettingsMapping
domainEntity.UserId.Value,
domainEntity.IsPaginationEnabled,
domainEntity.ItemsPerPage,
- domainEntity.IgnoreThePrefixForAlphaPicker);
+ domainEntity.IgnoreThePrefixForAlphaPicker,
+ domainEntity.IsThemeCachingEnabled);
}
}
diff --git a/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs b/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs
index 86912552..2e14e2f2 100644
--- a/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs
+++ b/src/Lumina.Application/Common/Utilities/ValidatorUtilities.cs
@@ -39,6 +39,33 @@ public static class ValidatorUtilities
return ruleBuilder.Must(value => !value.HasValue || value.Value > valueToCompare);
}
+ ///
+ /// Defines a validation rule that ensures the long property is greater than the specified value.
+ ///
+ /// The type of the request being validated.
+ /// The rule builder instance.
+ /// The value that the property must be greater than.
+ /// The current instance for method chaining.
+ public static IRuleBuilder GreaterThan(this IRuleBuilder ruleBuilder, long valueToCompare)
+ {
+ return ruleBuilder.Must(value => value > valueToCompare);
+ }
+
+ ///
+ /// Defines a validation rule that ensures the nullable long property is greater than the specified value.
+ ///
+ ///
+ /// If the property is , this rule passes (use to check for missing values).
+ ///
+ /// The type of the request being validated.
+ /// The rule builder instance.
+ /// The value that the property must be greater than.
+ /// The current instance for method chaining.
+ public static IRuleBuilder GreaterThan(this IRuleBuilder ruleBuilder, long valueToCompare)
+ {
+ return ruleBuilder.Must(value => !value.HasValue || value.Value > valueToCompare);
+ }
+
///
/// Defines a validation rule that ensures the decimal property is greater than the specified value.
///
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommand.cs b/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommand.cs
new file mode 100644
index 00000000..38666b55
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommand.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.DeleteTheme;
+
+///
+/// Command for deleting a theme.
+///
+/// The manifest id of the theme to delete.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record DeleteThemeCommand(
+ string? ThemeId
+) : ICommand;
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommandHandler.cs b/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommandHandler.cs
new file mode 100644
index 00000000..ec859146
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommandHandler.cs
@@ -0,0 +1,140 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Authorization;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.DeleteTheme;
+
+///
+/// Handler for the command to delete a theme.
+///
+public class DeleteThemeCommandHandler : ICommandHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IThemeService _themeService;
+ private readonly ICurrentUserService _currentUserService;
+ private readonly IAuthorizationService _authorizationService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service for the server-side storage and serving of theme packs.
+ /// Injected service to retrieve the current user information.
+ /// Injected service for authorization related functionality.
+ /// Injected validator for application validation rules.
+ public DeleteThemeCommandHandler(
+ IUnitOfWork unitOfWork,
+ IThemeService themeService,
+ ICurrentUserService currentUserService,
+ IAuthorizationService authorizationService,
+ IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _themeService = themeService;
+ _currentUserService = currentUserService;
+ _authorizationService = authorizationService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the command to delete a theme.
+ ///
+ /// The command to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An representing either a successful operation, or an error.
+ ///
+ public async Task> HandleAsync(DeleteThemeCommand command, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(command);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Guid? currentUserId = _currentUserService.UserId;
+ if (currentUserId is null)
+ return ApplicationErrors.Authorization.NotAuthorized;
+ Guid userId = currentUserId.Value;
+
+ // only admins can delete themes
+ if (!await _authorizationService.IsInRoleAsync(userId, "Admin", cancellationToken).ConfigureAwait(false))
+ return ApplicationErrors.Authorization.NotAuthorized;
+
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(command.ThemeId!, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity? theme = getThemeResult.Value;
+ if (theme is null || theme.IsDeleted)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ Result> getAllResult = await _unitOfWork.ThemeRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
+ if (getAllResult.IsFailure)
+ return getAllResult.Errors;
+
+ List availableThemes = getAllResult.Value.Where(availableTheme => !availableTheme.IsDeleted).ToList();
+
+ // at least one bundled theme must always remain available, so the application never ends up without any theme
+ if (theme.InstallSource == ThemeInstallSource.Bundled)
+ {
+ int availableBundledThemes = availableThemes.Count(availableTheme => availableTheme.InstallSource == ThemeInstallSource.Bundled);
+ if (availableBundledThemes <= 1)
+ return DomainErrors.Themes.LastBundledThemeCannotBeDeleted;
+ }
+
+ // if the deleted theme was the active one, switch to another available theme, preferring the configured default
+ if (theme.IsCurrent == true)
+ {
+ ThemeEntity? replacementTheme = availableThemes
+ .Where(availableTheme => availableTheme.Id != theme.Id)
+ .OrderBy(availableTheme => string.Equals(availableTheme.ThemeId, _themeService.DefaultThemeId, StringComparison.OrdinalIgnoreCase) ? 0 : 1)
+ .ThenBy(availableTheme => availableTheme.ThemeId, StringComparer.OrdinalIgnoreCase)
+ .FirstOrDefault();
+ if (replacementTheme is null)
+ return DomainErrors.Themes.ThemeCannotBeDeleted;
+
+ replacementTheme.IsCurrent = true;
+ await _unitOfWork.ThemeRepository.UpdateAsync(replacementTheme, cancellationToken).ConfigureAwait(false);
+ }
+
+ if (theme.InstallSource == ThemeInstallSource.Bundled)
+ {
+ // bundled themes are soft deleted, so they can be restored automatically later, as long as the user did not delete them
+ theme.IsDeleted = true;
+ theme.IsCurrent = null;
+ theme.UpdatedOnUtc = DateTime.UtcNow;
+ theme.UpdatedBy = userId;
+ await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ // user themes are removed entirely, because their files are not shipped with the application and could never be restored
+ Result deleteResult = await _unitOfWork.ThemeRepository.DeleteByIdAsync(theme.Id, cancellationToken).ConfigureAwait(false);
+ if (deleteResult.IsFailure)
+ return deleteResult.Errors;
+ }
+
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+
+ Result deleteFilesResult = await _themeService.DeleteAsync(theme.ThemeId, cancellationToken).ConfigureAwait(false);
+ if (deleteFilesResult.IsFailure)
+ return deleteFilesResult.Errors;
+
+ return Result.Success;
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommandValidator.cs b/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommandValidator.cs
new file mode 100644
index 00000000..752eb358
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/DeleteTheme/DeleteThemeCommandValidator.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Commands.DeleteTheme;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.DeleteTheme;
+
+///
+/// Validates the needed validation rules for .
+///
+public class DeleteThemeCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DeleteThemeCommandValidator()
+ {
+ RuleFor(command => command.ThemeId)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeIdCannotBeEmpty);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommand.cs b/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommand.cs
new file mode 100644
index 00000000..488d3442
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommand.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+using System.IO;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.InstallTheme;
+
+///
+/// Command for installing a theme pack, replacing the files of an existing theme with the same manifest id.
+///
+/// The ZIP archive stream of the theme pack.
+/// The file name of the uploaded archive.
+[DebuggerDisplay("FileName: {FileName}")]
+public record InstallThemeCommand(
+ Stream? Archive,
+ string? FileName
+) : ICommand;
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommandHandler.cs b/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommandHandler.cs
new file mode 100644
index 00000000..e914fa89
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommandHandler.cs
@@ -0,0 +1,149 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.Repositories.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Authorization;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Mapping.Themes;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.InstallTheme;
+
+///
+/// Handler for the command to install a theme pack.
+///
+public class InstallThemeCommandHandler : ICommandHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IThemeService _themeService;
+ private readonly ICurrentUserService _currentUserService;
+ private readonly IAuthorizationService _authorizationService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service for the server-side storage and serving of theme packs.
+ /// Injected service to retrieve the current user information.
+ /// Injected service for authorization related functionality.
+ /// Injected validator for application validation rules.
+ public InstallThemeCommandHandler(
+ IUnitOfWork unitOfWork,
+ IThemeService themeService,
+ ICurrentUserService currentUserService,
+ IAuthorizationService authorizationService,
+ IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _themeService = themeService;
+ _currentUserService = currentUserService;
+ _authorizationService = authorizationService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the command to install a theme pack.
+ ///
+ /// The command to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either a successfully installed , or an error.
+ ///
+ public async Task> HandleAsync(InstallThemeCommand command, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(command);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Guid? currentUserId = _currentUserService.UserId;
+ if (currentUserId is null)
+ return ApplicationErrors.Authorization.NotAuthorized;
+ Guid userId = currentUserId.Value;
+
+ // only admins can install themes
+ if (!await _authorizationService.IsInRoleAsync(userId, "Admin", cancellationToken).ConfigureAwait(false))
+ return ApplicationErrors.Authorization.NotAuthorized;
+
+ // store the theme pack files on the server, replacing the files of an existing theme with the same manifest id
+ Result installResult = await _themeService.InstallAsync(command.Archive!, cancellationToken).ConfigureAwait(false);
+ if (installResult.IsFailure)
+ return installResult.Errors;
+
+ ThemeManifestDto manifest = installResult.Value;
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(manifest.Id, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity themeEntity;
+ if (getThemeResult.Value is not null)
+ {
+ ThemeEntity existingTheme = getThemeResult.Value;
+ themeEntity = new ThemeEntity
+ {
+ Id = existingTheme.Id,
+ ThemeId = manifest.Id,
+ Name = manifest.Name,
+ Description = manifest.Description,
+ Author = manifest.Author,
+ Version = manifest.Version,
+ PreviewPath = manifest.Preview,
+ InstallSource = existingTheme.InstallSource,
+ IsCurrent = existingTheme.IsCurrent,
+ // reinstalling a theme must bring it back even if it was soft deleted before, so the uploaded pack becomes visible again
+ IsDeleted = false,
+ InstalledAtUtc = DateTime.UtcNow,
+ CreatedOnUtc = existingTheme.CreatedOnUtc,
+ CreatedBy = existingTheme.CreatedBy,
+ UpdatedOnUtc = DateTime.UtcNow,
+ UpdatedBy = userId
+ };
+
+ Result updateResult = await _unitOfWork.ThemeRepository.UpdateAsync(themeEntity, cancellationToken).ConfigureAwait(false);
+ if (updateResult.IsFailure)
+ return updateResult.Errors;
+ }
+ else
+ {
+ themeEntity = new ThemeEntity
+ {
+ Id = Guid.NewGuid(),
+ ThemeId = manifest.Id,
+ Name = manifest.Name,
+ Description = manifest.Description,
+ Author = manifest.Author,
+ Version = manifest.Version,
+ PreviewPath = manifest.Preview,
+ InstallSource = ThemeInstallSource.Uploaded,
+ InstalledAtUtc = DateTime.UtcNow,
+ CreatedOnUtc = DateTime.UtcNow,
+ CreatedBy = userId,
+ UpdatedBy = userId
+ };
+
+ Result insertResult = await _unitOfWork.ThemeRepository.InsertAsync(themeEntity, cancellationToken).ConfigureAwait(false);
+ if (insertResult.IsFailure)
+ {
+ // roll back the stored files so a failed install leaves no orphaned theme pack behind
+ await _themeService.DeleteAsync(manifest.Id, cancellationToken).ConfigureAwait(false);
+ return insertResult.Errors;
+ }
+ }
+
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ return themeEntity.ToResponse();
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommandValidator.cs b/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommandValidator.cs
new file mode 100644
index 00000000..11c9698a
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/InstallTheme/InstallThemeCommandValidator.cs
@@ -0,0 +1,25 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Errors;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Commands.InstallTheme;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.InstallTheme;
+
+///
+/// Validates the needed validation rules for .
+///
+public class InstallThemeCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public InstallThemeCommandValidator()
+ {
+ RuleFor(command => command.Archive)
+ .NotNull()
+ .WithError(DomainErrors.Themes.ThemeArchiveCannotBeNull);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommand.cs b/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommand.cs
new file mode 100644
index 00000000..642eb561
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommand.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.RestoreTheme;
+
+///
+/// Command for restoring a soft deleted bundled theme.
+///
+/// The manifest id of the theme to restore.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record RestoreThemeCommand(
+ string? ThemeId
+) : ICommand;
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommandHandler.cs b/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommandHandler.cs
new file mode 100644
index 00000000..c092f1ac
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommandHandler.cs
@@ -0,0 +1,106 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Authorization;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.RestoreTheme;
+
+///
+/// Handler for the command to restore a soft deleted bundled theme.
+///
+public class RestoreThemeCommandHandler : ICommandHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IThemeService _themeService;
+ private readonly ICurrentUserService _currentUserService;
+ private readonly IAuthorizationService _authorizationService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service for the server-side storage and serving of theme packs.
+ /// Injected service to retrieve the current user information.
+ /// Injected service for authorization related functionality.
+ /// Injected validator for application validation rules.
+ public RestoreThemeCommandHandler(
+ IUnitOfWork unitOfWork,
+ IThemeService themeService,
+ ICurrentUserService currentUserService,
+ IAuthorizationService authorizationService,
+ IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _themeService = themeService;
+ _currentUserService = currentUserService;
+ _authorizationService = authorizationService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the command to restore a soft deleted bundled theme.
+ ///
+ /// The command to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An representing either a successful operation, or an error.
+ ///
+ public async Task> HandleAsync(RestoreThemeCommand command, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(command);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Guid? currentUserId = _currentUserService.UserId;
+ if (currentUserId is null)
+ return ApplicationErrors.Authorization.NotAuthorized;
+ Guid userId = currentUserId.Value;
+
+ // only admins can restore themes
+ if (!await _authorizationService.IsInRoleAsync(userId, "Admin", cancellationToken).ConfigureAwait(false))
+ return ApplicationErrors.Authorization.NotAuthorized;
+
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(command.ThemeId!, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity? theme = getThemeResult.Value;
+ if (theme is null)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ // only bundled themes are soft deleted, so only a soft deleted bundled theme can be restored
+ if (!theme.IsDeleted || theme.InstallSource != ThemeInstallSource.Bundled)
+ return DomainErrors.Themes.ThemeCannotBeRestored;
+
+ // restore the pack files from the shipped archive before reactivating the theme
+ Result restoreFilesResult = await _themeService.RestoreBundledThemeAsync(theme.ThemeId, cancellationToken).ConfigureAwait(false);
+ if (restoreFilesResult.IsFailure)
+ return restoreFilesResult.Errors;
+
+ theme.IsDeleted = false;
+ theme.IsCurrent = null;
+ theme.UpdatedOnUtc = DateTime.UtcNow;
+ theme.UpdatedBy = userId;
+ Result updateResult = await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
+ if (updateResult.IsFailure)
+ return updateResult.Errors;
+
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+
+ return Result.Success;
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommandValidator.cs b/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommandValidator.cs
new file mode 100644
index 00000000..d2b145a9
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/RestoreTheme/RestoreThemeCommandValidator.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Commands.RestoreTheme;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.RestoreTheme;
+
+///
+/// Validates the needed validation rules for .
+///
+public class RestoreThemeCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RestoreThemeCommandValidator()
+ {
+ RuleFor(command => command.ThemeId)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeIdCannotBeEmpty);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommand.cs b/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommand.cs
new file mode 100644
index 00000000..37bc72be
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommand.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.SetCurrentTheme;
+
+///
+/// Command for setting the currently active theme.
+///
+/// The manifest id of the theme to activate.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record SetCurrentThemeCommand(
+ string? ThemeId
+) : ICommand;
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommandHandler.cs b/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommandHandler.cs
new file mode 100644
index 00000000..3269b174
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommandHandler.cs
@@ -0,0 +1,103 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Authentication;
+using Lumina.Application.Common.Infrastructure.Authorization;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Mapping.Themes;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.SetCurrentTheme;
+
+///
+/// Handler for the command to set the currently active theme.
+///
+public class SetCurrentThemeCommandHandler : ICommandHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly ICurrentUserService _currentUserService;
+ private readonly IAuthorizationService _authorizationService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service to retrieve the current user information.
+ /// Injected service for authorization related functionality.
+ /// Injected validator for application validation rules.
+ public SetCurrentThemeCommandHandler(
+ IUnitOfWork unitOfWork,
+ ICurrentUserService currentUserService,
+ IAuthorizationService authorizationService,
+ IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _currentUserService = currentUserService;
+ _authorizationService = authorizationService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the command to set the currently active theme.
+ ///
+ /// The command to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either the newly active , or an error.
+ ///
+ public async Task> HandleAsync(SetCurrentThemeCommand command, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(command);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Guid? currentUserId = _currentUserService.UserId;
+ if (currentUserId is null)
+ return ApplicationErrors.Authorization.NotAuthorized;
+ Guid userId = currentUserId.Value;
+
+ // only admins can change the active theme
+ if (!await _authorizationService.IsInRoleAsync(userId, "Admin", cancellationToken).ConfigureAwait(false))
+ return ApplicationErrors.Authorization.NotAuthorized;
+
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(command.ThemeId!, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity? theme = getThemeResult.Value;
+ if (theme is null || theme.IsDeleted)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ if (theme.IsCurrent == true)
+ return theme.ToResponse();
+
+ Result getCurrentResult = await _unitOfWork.ThemeRepository.GetCurrentAsync(cancellationToken).ConfigureAwait(false);
+ if (getCurrentResult.IsFailure)
+ return getCurrentResult.Errors;
+
+ ThemeEntity? currentTheme = getCurrentResult.Value;
+ if (currentTheme is not null && currentTheme.Id != theme.Id)
+ {
+ currentTheme.IsCurrent = null;
+ await _unitOfWork.ThemeRepository.UpdateAsync(currentTheme, cancellationToken).ConfigureAwait(false);
+ }
+
+ theme.IsCurrent = true;
+ theme.UpdatedOnUtc = DateTime.UtcNow;
+ theme.UpdatedBy = userId;
+ await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
+
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ return theme.ToResponse();
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommandValidator.cs b/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommandValidator.cs
new file mode 100644
index 00000000..29ab5055
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Commands/SetCurrentTheme/SetCurrentThemeCommandValidator.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Commands.SetCurrentTheme;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Commands.SetCurrentTheme;
+
+///
+/// Validates the needed validation rules for .
+///
+public class SetCurrentThemeCommandValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public SetCurrentThemeCommandValidator()
+ {
+ RuleFor(command => command.ThemeId)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeIdCannotBeEmpty);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetCurrentTheme/GetCurrentThemeQuery.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetCurrentTheme/GetCurrentThemeQuery.cs
new file mode 100644
index 00000000..510ccf83
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetCurrentTheme/GetCurrentThemeQuery.cs
@@ -0,0 +1,13 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetCurrentTheme;
+
+///
+/// Query for retrieving the currently active theme.
+///
+[DebuggerDisplay("GetCurrentThemeQuery")]
+public record GetCurrentThemeQuery : IQuery;
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetCurrentTheme/GetCurrentThemeQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetCurrentTheme/GetCurrentThemeQueryHandler.cs
new file mode 100644
index 00000000..3014a68e
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetCurrentTheme/GetCurrentThemeQueryHandler.cs
@@ -0,0 +1,50 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Mapping.Themes;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using System.Threading;
+using System.Threading.Tasks;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetCurrentTheme;
+
+///
+/// Handler for the query to get the currently active theme.
+///
+public class GetCurrentThemeQueryHandler : IQueryHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public GetCurrentThemeQueryHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the query to get the currently active theme.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either the active , or an error.
+ ///
+ public async Task> HandleAsync(GetCurrentThemeQuery query, CancellationToken cancellationToken)
+ {
+ Result getCurrentResult = await _unitOfWork.ThemeRepository.GetCurrentAsync(cancellationToken).ConfigureAwait(false);
+ if (getCurrentResult.IsFailure)
+ return getCurrentResult.Errors;
+
+ if (getCurrentResult.Value is null)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ return getCurrentResult.Value.ToResponse();
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQuery.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQuery.cs
new file mode 100644
index 00000000..c5163a09
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQuery.cs
@@ -0,0 +1,16 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeArchive;
+
+///
+/// Query for retrieving the downloadable archive of a theme.
+///
+/// The manifest id of the theme.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record GetThemeArchiveQuery(
+ string? ThemeId
+) : IQuery;
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQueryHandler.cs
new file mode 100644
index 00000000..5d9012bb
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQueryHandler.cs
@@ -0,0 +1,68 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeArchive;
+
+///
+/// Handler for the query to get the downloadable archive of a theme.
+///
+public class GetThemeArchiveQueryHandler : IQueryHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IThemeService _themeService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service for the server-side storage and serving of theme packs.
+ /// Injected validator for application validation rules.
+ public GetThemeArchiveQueryHandler(IUnitOfWork unitOfWork, IThemeService themeService, IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _themeService = themeService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the query to get the downloadable archive of a theme.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either the archive of the theme, or an error.
+ ///
+ public async Task> HandleAsync(GetThemeArchiveQuery query, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(query);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(query.ThemeId!, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity? theme = getThemeResult.Value;
+ if (theme is null || theme.IsDeleted)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ Result archiveResult = await _themeService.BuildArchiveAsync(theme.ThemeId, cancellationToken).ConfigureAwait(false);
+ if (archiveResult.IsFailure)
+ return archiveResult.Errors;
+
+ return new ThemeArchiveResponse(archiveResult.Value.Bytes, archiveResult.Value.FileName, archiveResult.Value.ContentType);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQueryValidator.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQueryValidator.cs
new file mode 100644
index 00000000..073e83ac
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeArchive/GetThemeArchiveQueryValidator.cs
@@ -0,0 +1,24 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Queries.GetThemeArchive;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeArchive;
+
+///
+/// Validates the needed validation rules for .
+///
+public class GetThemeArchiveQueryValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public GetThemeArchiveQueryValidator()
+ {
+ RuleFor(query => query.ThemeId)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeIdCannotBeEmpty);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQuery.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQuery.cs
new file mode 100644
index 00000000..a576fafa
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQuery.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeAsset;
+
+///
+/// Query for retrieving an asset file of a theme.
+///
+/// The manifest id of the theme.
+/// The asset path relative to the theme pack root.
+[DebuggerDisplay("ThemeId: {ThemeId}, AssetPath: {AssetPath}")]
+public record GetThemeAssetQuery(
+ string? ThemeId,
+ string? AssetPath
+) : IQuery;
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQueryHandler.cs
new file mode 100644
index 00000000..9f69ce6a
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQueryHandler.cs
@@ -0,0 +1,82 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeAsset;
+
+///
+/// Handler for the query to get an asset file of a theme.
+///
+public class GetThemeAssetQueryHandler : IQueryHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IThemeService _themeService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service for the server-side storage and serving of theme packs.
+ /// Injected validator for application validation rules.
+ public GetThemeAssetQueryHandler(IUnitOfWork unitOfWork, IThemeService themeService, IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _themeService = themeService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the query to get an asset file of a theme.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either the asset of the theme, or an error.
+ ///
+ public async Task> HandleAsync(GetThemeAssetQuery query, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(query);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(query.ThemeId!, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity? theme = getThemeResult.Value;
+ if (theme is null || theme.IsDeleted)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ Result assetResult = await _themeService.GetAssetAsync(theme.ThemeId, query.AssetPath!, cancellationToken).ConfigureAwait(false);
+ if (assetResult.IsFailure)
+ {
+ // the stored files of a bundled theme removed externally are restored, so its assets keep being served
+ if (theme.InstallSource == ThemeInstallSource.Bundled)
+ {
+ Result restoreResult = await _themeService.RestoreBundledThemeAsync(theme.ThemeId, cancellationToken).ConfigureAwait(false);
+ if (restoreResult.IsFailure)
+ return restoreResult.Errors;
+
+ assetResult = await _themeService.GetAssetAsync(theme.ThemeId, query.AssetPath!, cancellationToken).ConfigureAwait(false);
+ }
+
+ if (assetResult.IsFailure)
+ return assetResult.Errors;
+ }
+
+ return new ThemeAssetResponse(assetResult.Value.Bytes, assetResult.Value.ContentType);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQueryValidator.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQueryValidator.cs
new file mode 100644
index 00000000..2600048d
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeAsset/GetThemeAssetQueryValidator.cs
@@ -0,0 +1,28 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Queries.GetThemeAsset;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeAsset;
+
+///
+/// Validates the needed validation rules for .
+///
+public class GetThemeAssetQueryValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public GetThemeAssetQueryValidator()
+ {
+ RuleFor(query => query.ThemeId)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeIdCannotBeEmpty);
+
+ RuleFor(query => query.AssetPath)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeAssetPathCannotBeEmpty);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQuery.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQuery.cs
new file mode 100644
index 00000000..f56b71ae
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQuery.cs
@@ -0,0 +1,13 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeSettings;
+
+///
+/// Query for retrieving the theme engine settings.
+///
+[DebuggerDisplay("GetThemeSettingsQuery")]
+public record GetThemeSettingsQuery : IQuery;
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs
new file mode 100644
index 00000000..ea90c975
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeSettings/GetThemeSettingsQueryHandler.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeSettings;
+
+///
+/// Handler for the query to get the theme engine settings.
+///
+public class GetThemeSettingsQueryHandler : IQueryHandler>
+{
+ private readonly IThemeService _themeService;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected service for the server-side storage and serving of theme packs.
+ public GetThemeSettingsQueryHandler(IThemeService themeService)
+ {
+ _themeService = themeService;
+ }
+
+ ///
+ /// Handles the query to get the theme engine settings.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing the theme engine settings, or an error.
+ ///
+ public Task> HandleAsync(GetThemeSettingsQuery query, CancellationToken cancellationToken)
+ {
+ ThemeSettingsResponse response = new(_themeService.MaxArchiveBytes, _themeService.DefaultThemeId);
+ return Task.FromResult(Result.From(response));
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQuery.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQuery.cs
new file mode 100644
index 00000000..fbab092e
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQuery.cs
@@ -0,0 +1,18 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeTemplate;
+
+///
+/// Query for retrieving the template of a theme selected by a page key.
+///
+/// The manifest id of the theme.
+/// The page key that selects the template.
+[DebuggerDisplay("ThemeId: {ThemeId}, PageKey: {PageKey}")]
+public record GetThemeTemplateQuery(
+ string? ThemeId,
+ string? PageKey
+) : IQuery;
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQueryHandler.cs
new file mode 100644
index 00000000..e547d303
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQueryHandler.cs
@@ -0,0 +1,113 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Infrastructure.Themes;
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Mapping.Themes;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+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.Themes.Management.Queries.GetThemeTemplate;
+
+///
+/// Handler for the query to get the template of a theme.
+///
+public class GetThemeTemplateQueryHandler : IQueryHandler>
+{
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly IThemeService _themeService;
+ private readonly IValidator _validator;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ /// Injected service for the server-side storage and serving of theme packs.
+ /// Injected validator for application validation rules.
+ public GetThemeTemplateQueryHandler(IUnitOfWork unitOfWork, IThemeService themeService, IValidator validator)
+ {
+ _unitOfWork = unitOfWork;
+ _themeService = themeService;
+ _validator = validator;
+ }
+
+ ///
+ /// Handles the query to get the template of a theme.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either the template of the theme, or an error.
+ ///
+ public async Task> HandleAsync(GetThemeTemplateQuery query, CancellationToken cancellationToken)
+ {
+ List validationResult = _validator.Validate(query);
+ if (validationResult.Count > 0)
+ return validationResult;
+
+ Result getThemeResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(query.ThemeId!, cancellationToken).ConfigureAwait(false);
+ if (getThemeResult.IsFailure)
+ return getThemeResult.Errors;
+
+ ThemeEntity? theme = getThemeResult.Value;
+ if (theme is null || theme.IsDeleted)
+ return DomainErrors.Themes.ThemeNotFound;
+
+ Result templateResult = await _themeService.GetTemplateAsync(theme.ThemeId, query.PageKey!, cancellationToken).ConfigureAwait(false);
+ if (templateResult.IsFailure)
+ {
+ // the stored files of a bundled theme removed externally are restored, and if the broken theme was the
+ // active one, the configured default theme is activated, so clients always have a renderable theme
+ if (theme.InstallSource == ThemeInstallSource.Bundled && await TryRestoreBundledThemeAsync(theme, cancellationToken).ConfigureAwait(false))
+ templateResult = await _themeService.GetTemplateAsync(theme.ThemeId, query.PageKey!, cancellationToken).ConfigureAwait(false);
+
+ if (templateResult.IsFailure)
+ return templateResult.Errors;
+ }
+
+ return new ThemeTemplateResponse(theme.ToResponse(), templateResult.Value);
+ }
+
+ ///
+ /// Restores the files of a bundled theme whose stored files were removed externally, and switches the active theme to the configured default when the broken theme was the active one.
+ ///
+ /// The bundled theme to restore.
+ /// Cancellation token that can be used to stop the execution.
+ /// when the theme was restored; otherwise.
+ private async Task TryRestoreBundledThemeAsync(ThemeEntity theme, CancellationToken cancellationToken)
+ {
+ Result restoreResult = await _themeService.RestoreBundledThemeAsync(theme.ThemeId, cancellationToken).ConfigureAwait(false);
+ if (restoreResult.IsFailure)
+ return false;
+
+ if (theme.IsCurrent == true)
+ {
+ Result getDefaultResult = await _unitOfWork.ThemeRepository.GetByThemeIdAsync(_themeService.DefaultThemeId, cancellationToken).ConfigureAwait(false);
+ if (getDefaultResult.IsFailure)
+ return true;
+
+ ThemeEntity? defaultTheme = getDefaultResult.Value;
+ if (defaultTheme is not null && !defaultTheme.IsDeleted && defaultTheme.Id != theme.Id)
+ {
+ theme.IsCurrent = null;
+ await _unitOfWork.ThemeRepository.UpdateAsync(theme, cancellationToken).ConfigureAwait(false);
+
+ defaultTheme.IsCurrent = true;
+ await _unitOfWork.ThemeRepository.UpdateAsync(defaultTheme, cancellationToken).ConfigureAwait(false);
+
+ await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQueryValidator.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQueryValidator.cs
new file mode 100644
index 00000000..1818dbe4
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemeTemplate/GetThemeTemplateQueryValidator.cs
@@ -0,0 +1,28 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.Infrastructure.Validation;
+using Lumina.Application.Common.Utilities;
+using Lumina.Application.Core.Themes.Management.Queries.GetThemeTemplate;
+using DomainErrors = Lumina.Domain.Common.Errors.Errors;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemeTemplate;
+
+///
+/// Validates the needed validation rules for .
+///
+public class GetThemeTemplateQueryValidator : AbstractValidator
+{
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public GetThemeTemplateQueryValidator()
+ {
+ RuleFor(query => query.ThemeId)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.ThemeIdCannotBeEmpty);
+
+ RuleFor(query => query.PageKey)
+ .NotEmpty()
+ .WithError(DomainErrors.Themes.PageKeyCannotBeEmpty);
+ }
+}
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemes/GetThemesQuery.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemes/GetThemesQuery.cs
new file mode 100644
index 00000000..05dd246d
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemes/GetThemesQuery.cs
@@ -0,0 +1,13 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemes;
+
+///
+/// Query for retrieving all installed themes.
+///
+[DebuggerDisplay("GetThemesQuery")]
+public record GetThemesQuery : IQuery;
diff --git a/src/Lumina.Application/Core/Themes/Management/Queries/GetThemes/GetThemesQueryHandler.cs b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemes/GetThemesQueryHandler.cs
new file mode 100644
index 00000000..03eb9b5a
--- /dev/null
+++ b/src/Lumina.Application/Core/Themes/Management/Queries/GetThemes/GetThemesQueryHandler.cs
@@ -0,0 +1,56 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.CQRS;
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Lumina.Application.Common.DataAccess.UoW;
+using Lumina.Application.Common.Mapping.Themes;
+using Lumina.Contracts.Responses.Themes;
+using Lumina.Domain.Common.Primitives;
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Application.Core.Themes.Management.Queries.GetThemes;
+
+///
+/// Handler for the query to get all installed themes.
+///
+public class GetThemesQueryHandler : IQueryHandler>>
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected unit of work for interacting with the data access layer repositories.
+ public GetThemesQueryHandler(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ ///
+ /// Handles the query to get all installed themes.
+ ///
+ /// The query to be handled.
+ /// Cancellation token that can be used to stop the execution.
+ ///
+ /// An containing either a collection of , or an error.
+ ///
+ public async Task>> HandleAsync(GetThemesQuery query, CancellationToken cancellationToken)
+ {
+ Result> getThemesResult = await _unitOfWork.ThemeRepository.GetAllAsync(cancellationToken).ConfigureAwait(false);
+ if (getThemesResult.IsFailure)
+ return getThemesResult.Errors;
+
+ // deleted bundled themes are returned as well, so the administration page can offer to restore them
+ return Result.From>([.. getThemesResult.Value
+ .OrderBy(theme => theme.IsDeleted)
+ // the shipped bundled themes are listed before the user themes, so the defaults stay the most visible
+ .ThenByDescending(theme => theme.InstallSource == ThemeInstallSource.Bundled)
+ .ThenBy(theme => theme.Name, StringComparer.OrdinalIgnoreCase)
+ .Select(theme => theme.ToResponse())]);
+ }
+}
diff --git a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs
index a7f081cf..0e798ccc 100644
--- a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommand.cs
@@ -10,8 +10,10 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe
/// Whether pagination is enabled for the user, or not.
/// The number of library items displayed per page when pagination is enabled.
/// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
+/// Whether the theme data served to this user is cached, or not.
public record UpdateUserSettingsCommand(
bool IsPaginationEnabled,
int ItemsPerPage,
- bool IgnoreThePrefixForAlphaPicker
+ bool IgnoreThePrefixForAlphaPicker,
+ bool IsThemeCachingEnabled
) : ICommand;
diff --git a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs
index 4070ab3a..3028518b 100644
--- a/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs
+++ b/src/Lumina.Application/Core/UsersManagement/Settings/Commands/UpdateUserSettings/UpdateUserSettingsCommandHandler.cs
@@ -72,7 +72,8 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler updateSettingsResult = toDomainEntityResult.Value.UpdateSettings(
command.IsPaginationEnabled,
command.ItemsPerPage,
- command.IgnoreThePrefixForAlphaPicker);
+ command.IgnoreThePrefixForAlphaPicker,
+ command.IsThemeCachingEnabled);
if (updateSettingsResult.IsFailure)
return updateSettingsResult.Errors;
diff --git a/src/Lumina.Contracts/Requests/Themes/DeleteThemeRequest.cs b/src/Lumina.Contracts/Requests/Themes/DeleteThemeRequest.cs
new file mode 100644
index 00000000..1b7de807
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Themes/DeleteThemeRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Themes;
+
+///
+/// Represents a request to delete a theme.
+///
+/// The manifest id of the theme to delete. Required.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record DeleteThemeRequest(
+ string? ThemeId
+);
diff --git a/src/Lumina.Contracts/Requests/Themes/GetThemeArchiveRequest.cs b/src/Lumina.Contracts/Requests/Themes/GetThemeArchiveRequest.cs
new file mode 100644
index 00000000..0d356b69
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Themes/GetThemeArchiveRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Themes;
+
+///
+/// Represents a request to download the archive of a theme.
+///
+/// The manifest id of the theme. Required.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record GetThemeArchiveRequest(
+ string? ThemeId
+);
diff --git a/src/Lumina.Contracts/Requests/Themes/GetThemeAssetRequest.cs b/src/Lumina.Contracts/Requests/Themes/GetThemeAssetRequest.cs
new file mode 100644
index 00000000..24c01a97
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Themes/GetThemeAssetRequest.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Themes;
+
+///
+/// Represents a request to get an asset file of a theme.
+///
+/// The manifest id of the theme. Required.
+/// The asset path relative to the theme pack root. Required.
+[DebuggerDisplay("ThemeId: {ThemeId}, AssetPath: {AssetPath}")]
+public record GetThemeAssetRequest(
+ string? ThemeId,
+ string? AssetPath
+);
diff --git a/src/Lumina.Contracts/Requests/Themes/GetThemeTemplateRequest.cs b/src/Lumina.Contracts/Requests/Themes/GetThemeTemplateRequest.cs
new file mode 100644
index 00000000..47e047a8
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Themes/GetThemeTemplateRequest.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Themes;
+
+///
+/// Represents a request to get the template of a theme selected by a page key.
+///
+/// The manifest id of the theme. Required.
+/// The page key that selects the template. Required.
+[DebuggerDisplay("ThemeId: {ThemeId}, PageKey: {PageKey}")]
+public record GetThemeTemplateRequest(
+ string? ThemeId,
+ string? PageKey
+);
diff --git a/src/Lumina.Contracts/Requests/Themes/RestoreThemeRequest.cs b/src/Lumina.Contracts/Requests/Themes/RestoreThemeRequest.cs
new file mode 100644
index 00000000..b0e07d08
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Themes/RestoreThemeRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Themes;
+
+///
+/// Represents a request to restore a soft deleted bundled theme.
+///
+/// The manifest id of the theme to restore. Required.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record RestoreThemeRequest(
+ string? ThemeId
+);
diff --git a/src/Lumina.Contracts/Requests/Themes/SetCurrentThemeRequest.cs b/src/Lumina.Contracts/Requests/Themes/SetCurrentThemeRequest.cs
new file mode 100644
index 00000000..9e171853
--- /dev/null
+++ b/src/Lumina.Contracts/Requests/Themes/SetCurrentThemeRequest.cs
@@ -0,0 +1,15 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Requests.Themes;
+
+///
+/// Represents a request to set the currently active theme.
+///
+/// The manifest id of the theme to activate. Required.
+[DebuggerDisplay("ThemeId: {ThemeId}")]
+public record SetCurrentThemeRequest(
+ string? ThemeId
+);
diff --git a/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs b/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs
index eb76b7ad..2b0ad237 100644
--- a/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs
+++ b/src/Lumina.Contracts/Requests/UsersManagement/Settings/UpdateUserSettingsRequest.cs
@@ -10,9 +10,11 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings;
/// Whether pagination is enabled for the user, or not. Required.
/// The number of library items displayed per page when pagination is enabled. Required.
/// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required.
+/// Whether the theme data served to this user is cached, or not. Required.
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
public sealed record UpdateUserSettingsRequest(
bool IsPaginationEnabled,
int ItemsPerPage,
- bool IgnoreThePrefixForAlphaPicker
+ bool IgnoreThePrefixForAlphaPicker,
+ bool IsThemeCachingEnabled
);
diff --git a/src/Lumina.Contracts/Responses/Themes/ThemeArchiveResponse.cs b/src/Lumina.Contracts/Responses/Themes/ThemeArchiveResponse.cs
new file mode 100644
index 00000000..841c8bc8
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Themes/ThemeArchiveResponse.cs
@@ -0,0 +1,19 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.Themes;
+
+///
+/// Represents a theme archive response.
+///
+/// The bytes of the ZIP archive.
+/// The file name to expose when downloading the archive.
+/// The MIME content type of the archive.
+[DebuggerDisplay("FileName: {FileName}")]
+public record ThemeArchiveResponse(
+ byte[] Bytes,
+ string FileName,
+ string ContentType
+);
diff --git a/src/Lumina.Contracts/Responses/Themes/ThemeAssetResponse.cs b/src/Lumina.Contracts/Responses/Themes/ThemeAssetResponse.cs
new file mode 100644
index 00000000..f7c3d7b5
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Themes/ThemeAssetResponse.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.Themes;
+
+///
+/// Represents a theme asset response.
+///
+/// The bytes of the asset file.
+/// The MIME content type of the asset file.
+[DebuggerDisplay("ContentType: {ContentType}")]
+public record ThemeAssetResponse(
+ byte[] Bytes,
+ string ContentType
+);
diff --git a/src/Lumina.Contracts/Responses/Themes/ThemeResponse.cs b/src/Lumina.Contracts/Responses/Themes/ThemeResponse.cs
new file mode 100644
index 00000000..b8aca76f
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Themes/ThemeResponse.cs
@@ -0,0 +1,36 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Domain.SharedKernel.Common.Enums.Themes;
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.Themes;
+
+///
+/// Represents a theme response.
+///
+/// The unique identifier of the theme.
+/// The manifest id of the theme, used by clients to reference it.
+/// The display name of the theme.
+/// The description of the theme.
+/// The author of the theme.
+/// The version of the theme, using semantic version form.
+/// The path of the theme preview image, relative to the theme pack root, or when the theme has no preview.
+/// The source the theme was installed from.
+/// Whether the theme is the currently active one.
+/// The UTC timestamp at which the theme was installed.
+/// Whether the theme was deleted by the user, which is only possible for bundled themes.
+[DebuggerDisplay("ThemeId: {ThemeId}, Name: {Name}")]
+public record ThemeResponse(
+ Guid Id,
+ string ThemeId,
+ string Name,
+ string Description,
+ string Author,
+ string Version,
+ string? PreviewPath,
+ ThemeInstallSource InstallSource,
+ bool? IsCurrent,
+ DateTime InstalledAtUtc,
+ bool IsDeleted
+);
diff --git a/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs b/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs
new file mode 100644
index 00000000..def03523
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Themes/ThemeSettingsResponse.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.Themes;
+
+///
+/// Represents a theme settings response.
+///
+/// The maximum allowed size of a theme archive, in bytes.
+/// The identifier of the theme selected when no valid current theme is available.
+[DebuggerDisplay("MaxArchiveBytes: {MaxArchiveBytes}")]
+public record ThemeSettingsResponse(
+ long MaxArchiveBytes,
+ string DefaultThemeId
+);
diff --git a/src/Lumina.Contracts/Responses/Themes/ThemeTemplateResponse.cs b/src/Lumina.Contracts/Responses/Themes/ThemeTemplateResponse.cs
new file mode 100644
index 00000000..7e14fc5d
--- /dev/null
+++ b/src/Lumina.Contracts/Responses/Themes/ThemeTemplateResponse.cs
@@ -0,0 +1,17 @@
+#region ========================================================================= USING =====================================================================================
+using System;
+using System.Diagnostics;
+#endregion
+
+namespace Lumina.Contracts.Responses.Themes;
+
+///
+/// Represents a theme template response.
+///
+/// The theme the template belongs to.
+/// The sanitized content of the template.
+[DebuggerDisplay("ThemeId: {Theme.ThemeId}")]
+public record ThemeTemplateResponse(
+ ThemeResponse Theme,
+ string Template
+);
diff --git a/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs b/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs
index 2e29dd70..3c362b34 100644
--- a/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs
+++ b/src/Lumina.Contracts/Responses/UsersManagement/Settings/UserSettingsResponse.cs
@@ -12,10 +12,12 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings;
/// Whether pagination is enabled for the user, or not.
/// The number of library items displayed per page when pagination is enabled.
/// Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
+/// Whether the theme data served to this user is cached, or not.
[DebuggerDisplay("UserId: {UserId}")]
public sealed record UserSettingsResponse(
Guid UserId,
bool IsPaginationEnabled,
int ItemsPerPage,
- bool IgnoreThePrefixForAlphaPicker
+ bool IgnoreThePrefixForAlphaPicker,
+ bool IsThemeCachingEnabled
);
diff --git a/src/Lumina.DataAccess/Common/Configuration/ThemeConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/ThemeConfiguration.cs
new file mode 100644
index 00000000..5f36830f
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Configuration/ThemeConfiguration.cs
@@ -0,0 +1,100 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Common.DataAccess.Entities.Themes;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using System;
+#endregion
+
+namespace Lumina.DataAccess.Common.Configuration;
+
+///
+/// Configures the entity mapping for the entity.
+///
+public class ThemeConfiguration : IEntityTypeConfiguration
+{
+ ///
+ /// Configures the entity.
+ ///
+ /// The builder to be used to configure the entity.
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("Themes");
+ builder.HasKey(theme => theme.Id);
+ builder.Property(theme => theme.Id)
+ .ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the install, we need to tell EF not to generate it
+ .HasColumnOrder(0);
+
+ // the manifest id is the business key used by the clients, so it must be unique
+ builder.HasIndex(theme => theme.ThemeId)
+ .IsUnique();
+
+ builder.Property(theme => theme.ThemeId)
+ .IsRequired()
+ .HasMaxLength(64)
+ .HasColumnOrder(1);
+
+ builder.Property(theme => theme.Name)
+ .IsRequired()
+ .HasMaxLength(80)
+ .HasColumnOrder(2);
+
+ builder.Property(theme => theme.Description)
+ .IsRequired()
+ .HasMaxLength(300)
+ .HasColumnOrder(3);
+
+ builder.Property(theme => theme.Author)
+ .IsRequired()
+ .HasMaxLength(80)
+ .HasColumnOrder(4);
+
+ builder.Property(theme => theme.Version)
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnOrder(5);
+
+ builder.Property(theme => theme.PreviewPath)
+ .HasMaxLength(240)
+ .HasDefaultValue(null)
+ .HasColumnOrder(6);
+
+ builder.Property(theme => theme.InstallSource)
+ .IsRequired()
+ .HasConversion()
+ .HasColumnOrder(7);
+
+ // at most one theme can be current: the filtered unique index guarantees it at the database level, since every row that is not current has a null value here, and nulls are allowed to repeat
+ builder.HasIndex(theme => theme.IsCurrent)
+ .IsUnique()
+ .HasFilter("IsCurrent = 1");
+
+ builder.Property(theme => theme.IsCurrent)
+ .HasDefaultValue(null)
+ .HasColumnOrder(8);
+
+ builder.Property(theme => theme.IsDeleted)
+ .HasDefaultValue(false)
+ .HasColumnOrder(9);
+
+ builder.Property(theme => theme.InstalledAtUtc)
+ .IsRequired()
+ .HasColumnOrder(10);
+
+ // audit
+ builder.Property(theme => theme.CreatedOnUtc)
+ .IsRequired()
+ .HasColumnOrder(11);
+
+ builder.Property(theme => theme.CreatedBy)
+ .IsRequired()
+ .HasColumnOrder(12);
+
+ builder.Property(theme => theme.UpdatedOnUtc)
+ .HasDefaultValue(null)
+ .HasColumnOrder(13);
+
+ builder.Property(theme => theme.UpdatedBy)
+ .HasDefaultValue(null)
+ .HasColumnOrder(14);
+ }
+}
diff --git a/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs b/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs
index a24022a1..ca160a72 100644
--- a/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs
+++ b/src/Lumina.DataAccess/Common/Configuration/UserSettingsConfiguration.cs
@@ -47,6 +47,10 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration settings.IsThemeCachingEnabled)
+ .IsRequired()
+ .HasColumnOrder(9);
+
// audit
builder.Property(settings => settings.CreatedOnUtc)
.IsRequired()
diff --git a/src/Lumina.DataAccess/Common/Migrations/20260819181057_AddsThemesTable.Designer.cs b/src/Lumina.DataAccess/Common/Migrations/20260819181057_AddsThemesTable.Designer.cs
new file mode 100644
index 00000000..d63afd4c
--- /dev/null
+++ b/src/Lumina.DataAccess/Common/Migrations/20260819181057_AddsThemesTable.Designer.cs
@@ -0,0 +1,1302 @@
+//
+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("20260819181057_AddsThemesTable")]
+ partial class AddsThemesTable
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.11");
+
+ 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("Publisher")
+ .HasMaxLength(100)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(16);
+
+ b.Property("ReReleaseDate")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("ReReleaseYear")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(7);
+
+ b.Property("ReleaseCountry")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("ReleaseVersion")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("Title")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(35);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(34);
+
+ b.Property("VolumeNumber")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(20);
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId", "MetadataStatus");
+
+ b.HasIndex("LibraryId", "Path");
+
+ b.ToTable("Books", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.LibraryMetadataProviderConfigurationEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("IsEnabled")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(3);
+
+ b.Property("LibraryId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("PluginId")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("Rank")
+ .HasColumnType("INTEGER")
+ .HasColumnOrder(4);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId", "PluginId");
+
+ b.ToTable("LibraryMetadataProviderConfigurations", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Plugins.PluginEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Author")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(2);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(9);
+
+ b.Property("CreatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(8);
+
+ b.Property("Description")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("LoadError")
+ .HasMaxLength(2000)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(6);
+
+ b.Property("LoadStatus")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(5);
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(1);
+
+ b.Property("SettingsJson")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(7);
+
+ b.Property("UpdatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(11);
+
+ b.Property("UpdatedOnUtc")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(10);
+
+ b.Property("Version")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(3);
+
+ b.HasKey("Id");
+
+ b.ToTable("Plugins", (string)null);
+ });
+
+ modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Themes.ThemeEntity", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(0);
+
+ b.Property("Author")
+ .IsRequired()
+ .HasMaxLength(80)
+ .HasColumnType("TEXT")
+ .HasColumnOrder(4);
+
+ b.Property("CreatedBy")
+ .HasColumnType("TEXT")
+ .HasColumnOrder(12);
+
+ b.Property