feat: adds FastEndpoints core infrastructure and contracts to the web project

This commit is contained in:
BinaryAlley committed 2026-08-17 11:52:20 -07:00
1 parent 394b33efd2
commit 733e174cac
137 files changed
+3139 -158

No files matched your search

@@ -1,8 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Common;
using Lumina.Presentation.Web.Common.DTO.Configuration;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Exceptions;
using Lumina.Presentation.Web.Common.Models.Common;
using Lumina.Presentation.Web.Common.Models.Configuration;
using Lumina.Presentation.Web.Common.Models.FileSystemManagement;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using System;
@@ -35,13 +35,13 @@ public class ApiHttpClient : IApiHttpClient
/// <param name="httpClient">Injected HttpClient for interacting with the API.</param>
/// <param name="httpContextAccessor">Injected service for providing the current HTTP context.</param>
/// <param name="serverConfigurationOptions">Injected server configuration application settings.</param>
public ApiHttpClient(HttpClient httpClient, IHttpContextAccessor httpContextAccessor, IOptionsSnapshot<ServerConfigurationModel> serverConfigurationOptions)
public ApiHttpClient(HttpClient httpClient, IHttpContextAccessor httpContextAccessor, IOptionsSnapshot<ServerConfigurationDto> serverConfigurationOptions)
{
_httpClient = httpClient;
_httpContext = httpContextAccessor.HttpContext;
// read the API server configuration values from the configuration, and assign them to the injected client
ServerConfigurationModel serverConfigurationModel = serverConfigurationOptions.Value;
httpClient.BaseAddress = new Uri($"{serverConfigurationModel.BaseAddress}:{serverConfigurationModel.Port}/api/v{serverConfigurationModel.ApiVersion}/");
ServerConfigurationDto serverConfiguration = serverConfigurationOptions.Value;
httpClient.BaseAddress = new Uri($"{serverConfiguration.BaseAddress}:{serverConfiguration.Port}/api/v{serverConfiguration.ApiVersion}/");
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
@@ -101,7 +101,7 @@ public class ApiHttpClient : IApiHttpClient
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>A model containing the deserialized blob.</returns>
public async Task<BlobDataModel> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default)
public async Task<BlobDataDto> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default)
{
using HttpRequestMessage request = new(HttpMethod.Get, endpoint);
AuthenticationHeaderValue? authenticationHeader = GetAuthenticationHeader();
@@ -112,10 +112,10 @@ public class ApiHttpClient : IApiHttpClient
{
// read the content as a string, for error messages
string content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
ProblemDetailsModel? problemDetails = null;
ProblemDetailsDto? problemDetails = null;
try
{
problemDetails = JsonSerializer.Deserialize<ProblemDetailsModel>(content, _jsonOptions);
problemDetails = JsonSerializer.Deserialize<ProblemDetailsDto>(content, _jsonOptions);
}
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
throw new ApiException(problemDetails, response.StatusCode);
@@ -123,7 +123,7 @@ public class ApiHttpClient : IApiHttpClient
// if the response is successful, read it as a byte array
byte[] responseContent = await response.Content.ReadAsByteArrayAsync(cancellationToken).ConfigureAwait(false);
string contentType = response.Content.Headers.ContentType?.ToString() ?? "application/octet-stream";
return new BlobDataModel { Data = responseContent, ContentType = contentType };
return new BlobDataDto { Data = responseContent, ContentType = contentType };
}
/// <summary>
@@ -142,12 +142,12 @@ public class ApiHttpClient : IApiHttpClient
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
{
ProblemDetailsModel? problemDetails = null;
ProblemDetailsDto? problemDetails = null;
string content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
// attempt to deserialize the response content to ProblemDetailsModel if the request fails
// attempt to deserialize the response content to ProblemDetailsDto if the request fails
try
{
problemDetails = JsonSerializer.Deserialize<ProblemDetailsModel>(content, _jsonOptions);
problemDetails = JsonSerializer.Deserialize<ProblemDetailsDto>(content, _jsonOptions);
}
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
throw new ApiException(problemDetails, response.StatusCode, request.RequestUri?.AbsolutePath);
@@ -194,13 +194,13 @@ public class ApiHttpClient : IApiHttpClient
/// <summary>
/// Sends an HTTP request and deserializes the response into the specified type if the request is successful.
/// If the request fails, it attempts to deserialize the response content into a <see cref="ProblemDetailsModel"/> and throws an <see cref="ApiException"/>.
/// If the request fails, it attempts to deserialize the response content into a <see cref="ProblemDetailsDto"/> and throws an <see cref="ApiException"/>.
/// </summary>
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
/// <param name="request">The <see cref="HttpRequestMessage"/> to be sent.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>The deserialized response content as an object of type <typeparamref name="TResponse"/>.</returns>
/// <exception cref="ApiException">Thrown if the response is not successful, with the <see cref="ProblemDetailsModel"/> if available.</exception>
/// <exception cref="ApiException">Thrown if the response is not successful, with the <see cref="ProblemDetailsDto"/> if available.</exception>
private async Task<TResponse> SendRequestAsync<TResponse>(HttpRequestMessage request, CancellationToken cancellationToken)
{
// send the HTTP request and read the response
@@ -216,11 +216,11 @@ public class ApiHttpClient : IApiHttpClient
}
else
{
ProblemDetailsModel? problemDetails = null;
// attempt to deserialize the response content to ProblemDetailsModel if the request fails
ProblemDetailsDto? problemDetails = null;
// attempt to deserialize the response content to ProblemDetailsDto if the request fails
try
{
problemDetails = JsonSerializer.Deserialize<ProblemDetailsModel>(content, _jsonOptions);
problemDetails = JsonSerializer.Deserialize<ProblemDetailsDto>(content, _jsonOptions);
}
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
throw new ApiException(problemDetails, response.StatusCode, request.RequestUri?.AbsolutePath);
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.FileSystemManagement;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -36,7 +36,7 @@ public interface IApiHttpClient
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>A model containing the deserialized blob.</returns>
Task<BlobDataModel> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default);
Task<BlobDataDto> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default);
/// <summary>
/// Sends a DELETE request to the specified <paramref name="endpoint"/> as an asynchronous operation.
@@ -0,0 +1,11 @@
namespace Lumina.Presentation.Web.Common.Authorization;
/// <summary>
/// Contains the names of the authorization policies defined in the Web application.
/// </summary>
public static class AuthorizationPolicies
{
public const string REQUIRE_ADMIN_ROLE = "RequireAdminRole";
public const string REQUIRE_CREATE_LIBRARIES_PERMISSION = "RequireCreateLibrariesPermission";
public const string REQUIRE_INITIALIZATION = "RequireInitialization";
}
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Enums.Authorization;
using Lumina.Presentation.Web.Common.Models.Authorization;
using Lumina.Presentation.Web.Common.Responses.Authorization;
using Microsoft.AspNetCore.Http;
using System;
using System.Linq;
@@ -55,42 +55,6 @@ public class AuthorizationService : IAuthorizationService
return authorization.Role == role;
}
/// <summary>
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization policy.
/// </summary>
/// <typeparam name="TAuthorizationPolicy">The type of authorization policy to evaluate.</typeparam>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns><see langword="true"/> if the currently logged in user satisfies the policy, <see langword="false"/> otherwise.</returns>
public Task<bool> EvaluatePolicyAsync<TAuthorizationPolicy>(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
/// <summary>
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization requirement.
/// </summary>
/// <param name="requirement">The authorization requirements to check.</param>
/// <returns><see langword="true"/> if the currently logged in user satisfies the requirement, <see langword="false"/> otherwise.</returns>
public async Task<bool> EvaluateAuthorizationAsync(AuthorizationRequirementModel requirement)
{
GetAuthorizationResponse authorization = await GetUserAuthorizationAsync(CancellationToken.None);
if (requirement.Roles?.Length > 0 && !requirement.Roles.Any(role => authorization.Role?.Contains(role) == true))
return false;
if (requirement.Permissions?.Length > 0 && !requirement.Permissions.Any(permission => authorization.Permissions.Contains(permission)))
return false;
//if (_requirement.PolicyType is not null)
//{
// bool response = await _apiHttpClient.PostAsync<bool, object>($"auth/evaluate-policy/{_requirement.PolicyType.Name}", null!);
// if (!response)
// return false;
//}
return true;
}
/// <summary>
/// Retrieves user authorization details from the authorization service.
/// </summary>
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Authorization;
using Lumina.Presentation.Web.Common.Models.Authorization;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -27,19 +26,4 @@ public interface IAuthorizationService
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns><see langword="true"/> if the currently logged in user is in the specified role, <see langword="false"/> otherwise.</returns>
Task<bool> IsInRoleAsync(string role, CancellationToken cancellationToken);
/// <summary>
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization policy.
/// </summary>
/// <typeparam name="TAuthorizationPolicy">The type of authorization policy to evaluate.</typeparam>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns><see langword="true"/> if the currently logged in user satisfies the policy, <see langword="false"/> otherwise.</returns>
Task<bool> EvaluatePolicyAsync<TAuthorizationPolicy>(CancellationToken cancellationToken);
/// <summary>
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization requirement.
/// </summary>
/// <param name="requirement">The authorization requirements to check.</param>
/// <returns><see langword="true"/> if the currently logged in user satisfies the requirement, <see langword="false"/> otherwise.</returns>
Task<bool> EvaluateAuthorizationAsync(AuthorizationRequirementModel requirement);
}
@@ -0,0 +1,32 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Common.Authorization;
/// <summary>
/// FastEndpoints pre-processor that runs the application initialization check before the endpoint handler executes.
/// </summary>
/// <remarks>
/// The check runs the <c>RequireInitialization</c> authorization policy, which queries the remote API and records the pending super admin setup state in the session.
/// Its result is deliberately ignored, because the pages that use this processor must be reachable both before and after the application is initialized.
/// </remarks>
/// <typeparam name="TRequest">The type of the request of the endpoint to which this pre-processor is applied.</typeparam>
public class InitializationCheckPreProcessor<TRequest> : IPreProcessor<TRequest> where TRequest : notnull
{
/// <summary>
/// Runs the initialization check for the current request.
/// </summary>
/// <param name="preProcessorContext">The pre-processor context for the current request.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public async Task PreProcessAsync(IPreProcessorContext<TRequest> preProcessorContext, CancellationToken cancellationToken)
{
HttpContext httpContext = preProcessorContext.HttpContext;
Microsoft.AspNetCore.Authorization.IAuthorizationService authorizationService = httpContext.RequestServices.GetRequiredService<Microsoft.AspNetCore.Authorization.IAuthorizationService>();
await authorizationService.AuthorizeAsync(httpContext.User, httpContext, AuthorizationPolicies.REQUIRE_INITIALIZATION).ConfigureAwait(false);
}
}
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Http;
using Lumina.Presentation.Web.Common.Models.UsersManagement;
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
@@ -28,17 +28,17 @@ public class InitializationHandler : AuthorizationHandler<InitializationRequirem
/// <summary>
/// Checks the application initialization status and authorizes the requirement if initialized.
/// </summary>
/// <param name="context">The authorization context.</param>
/// <param name="requirement">The initialization requirement to be evaluated.</param>
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, InitializationRequirement requirement)
/// <param name="authorizationHandlerContext">The authorization context.</param>
/// <param name="initializationRequirement">The initialization requirement to be evaluated.</param>
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, InitializationRequirement initializationRequirement)
{
InitializationModel result = await _apiHttpClient.GetAsync<InitializationModel>("initialization/").ConfigureAwait(false);
HttpContext? httpContext = context.Resource as HttpContext;
InitializationResponse result = await _apiHttpClient.GetAsync<InitializationResponse>("initialization/").ConfigureAwait(false);
HttpContext? httpContext = authorizationHandlerContext.Resource as HttpContext;
if (result.IsInitialized)
{
// admin account was registered, remove this requirement from the session
httpContext?.Session.Remove(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP);
context.Succeed(requirement);
authorizationHandlerContext.Succeed(initializationRequirement);
}
else // store in session that super admin setup is needed
httpContext?.Session.SetString(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, "true");
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Authorization;
using Microsoft.AspNetCore.Authorization;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Common.Authorization;
/// <summary>
/// Handles the <see cref="PermissionRequirement"/> by checking the currently logged in user's permissions against the remote API.
/// </summary>
public class PermissionAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
{
private readonly IAuthorizationService _authorizationService;
/// <summary>
/// Initializes a new instance of the <see cref="PermissionAuthorizationHandler"/> class.
/// </summary>
/// <param name="authorizationService">Injected service for authorization checks against the remote API.</param>
public PermissionAuthorizationHandler(IAuthorizationService authorizationService)
{
_authorizationService = authorizationService;
}
/// <summary>
/// Succeeds the requirement when the currently logged in user holds any of the required permissions.
/// </summary>
/// <param name="authorizationHandlerContext">The authorization context.</param>
/// <param name="permissionRequirement">The permission requirement to evaluate.</param>
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, PermissionRequirement permissionRequirement)
{
foreach (AuthorizationPermission permission in permissionRequirement.Permissions)
{
if (await _authorizationService.HasPermissionAsync(permission, CancellationToken.None).ConfigureAwait(false))
{
authorizationHandlerContext.Succeed(permissionRequirement);
return;
}
}
}
}
@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Authorization;
using Microsoft.AspNetCore.Authorization;
#endregion
namespace Lumina.Presentation.Web.Common.Authorization;
/// <summary>
/// Defines a requirement that the user must hold at least one of the specified permissions.
/// </summary>
public class PermissionRequirement : IAuthorizationRequirement
{
/// <summary>
/// Gets the permissions that allow access, of which the user must hold at least one.
/// </summary>
public AuthorizationPermission[] Permissions { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PermissionRequirement"/> class.
/// </summary>
/// <param name="permissions">The permissions that allow access.</param>
public PermissionRequirement(params AuthorizationPermission[] permissions)
{
Permissions = permissions;
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Microsoft.AspNetCore.Authorization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Common.Authorization;
/// <summary>
/// Handles the <see cref="RoleRequirement"/> by checking the currently logged in user's role against the remote API.
/// </summary>
public class RoleAuthorizationHandler : AuthorizationHandler<RoleRequirement>
{
private readonly IAuthorizationService _authorizationService;
/// <summary>
/// Initializes a new instance of the <see cref="RoleAuthorizationHandler"/> class.
/// </summary>
/// <param name="authorizationService">Injected service for authorization checks against the remote API.</param>
public RoleAuthorizationHandler(IAuthorizationService authorizationService)
{
_authorizationService = authorizationService;
}
/// <summary>
/// Succeeds the requirement when the currently logged in user belongs to any of the required roles.
/// </summary>
/// <param name="authorizationHandlerContext">The authorization context.</param>
/// <param name="roleRequirement">The role requirement to evaluate.</param>
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, RoleRequirement roleRequirement)
{
foreach (string role in roleRequirement.Roles)
{
if (await _authorizationService.IsInRoleAsync(role, CancellationToken.None).ConfigureAwait(false))
{
authorizationHandlerContext.Succeed(roleRequirement);
return;
}
}
}
}
@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using Microsoft.AspNetCore.Authorization;
#endregion
namespace Lumina.Presentation.Web.Common.Authorization;
/// <summary>
/// Defines a requirement that the user must belong to at least one of the specified roles.
/// </summary>
public class RoleRequirement : IAuthorizationRequirement
{
/// <summary>
/// Gets the roles that allow access, of which the user must belong to at least one.
/// </summary>
public string[] Roles { get; }
/// <summary>
/// Initializes a new instance of the <see cref="RoleRequirement"/> class.
/// </summary>
/// <param name="roles">The roles that allow access.</param>
public RoleRequirement(params string[] roles)
{
Roles = roles;
}
}
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Authorization;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
/// <summary>
/// Data transfer object for an authorization permission.
/// </summary>
/// <param name="Id">The unique identifier of the permission.</param>
/// <param name="PermissionName">The name of the permission.</param>
[DebuggerDisplay("Id: {Id}, PermissionName: {PermissionName}")]
public record PermissionDto(
Guid Id,
AuthorizationPermission PermissionName
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
/// <summary>
/// Data transfer object for an authorization role.
/// </summary>
/// <param name="Id">The unique identifier of the role.</param>
/// <param name="RoleName">The name of the role.</param>
[DebuggerDisplay("Id: {Id}, RoleName: {RoleName}")]
public record RoleDto(
Guid Id,
string RoleName
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
/// <summary>
/// Data transfer object for a model for an authorization role with its permissions.
/// </summary>
/// <param name="Role">The authorization role.</param>
/// <param name="Permissions">The permissions of the authorization role.</param>
[DebuggerDisplay("Role: {Role}")]
public record RolePermissionsDto(
RoleDto Role,
PermissionDto[] Permissions
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
/// <summary>
/// Data transfer object for a user with its authorization permissions.
/// </summary>
/// <param name="User">The user.</param>
/// <param name="Permissions">The authorization permissions of the user.</param>
[DebuggerDisplay("User: {User}")]
public record UserPermissionsDto(
UserDto User,
PermissionDto[] Permissions
);
@@ -0,0 +1,20 @@
using System.Diagnostics;
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for the data shown on the error page.
/// </summary>
[DebuggerDisplay("RequestId: {RequestId}, ShowRequestId: {ShowRequestId}")]
public class ErrorViewDto
{
/// <summary>
/// Gets or sets the request identifier to display.
/// </summary>
public string? RequestId { get; set; }
/// <summary>
/// Gets a value indicating whether the request identifier should be shown.
/// </summary>
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for a request to get genre information.
/// </summary>
[DebuggerDisplay("{Name}")]
public class GenreDto
{
/// <summary>
/// Gets the name of the genre element of the media item.
/// </summary>
public string? Name { get; set; }
}
@@ -0,0 +1,27 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for a request to get language information.
/// </summary>
[DebuggerDisplay("{LanguageName}")]
public class LanguageInfoDto
{
/// <summary>
/// Gets the ISO 639-1 two-letter language code.
/// </summary>
public string? LanguageCode { get; set; }
/// <summary>
/// Gets the full name of the language in English.
/// </summary>
public string? LanguageName { get; set; }
/// <summary>
/// Gets an optional native name of the language.
/// </summary>
public string? NativeName { get; set; }
}
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Notifications;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for notifications.
/// </summary>
/// <param name="Id">The id of the notification.</param>
/// <param name="Message">The message of the notification.</param>
/// <param name="Type">The type of the notification.</param>
[DebuggerDisplay("Id: {Id}, Message: {Message}")]
public record struct NotificationDto(
Guid Id,
string Message,
NotificationType Type
);
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object that follows the RFC 7807 standard for problem details in HTTP APIs.
/// </summary>
[DebuggerDisplay("{Title} ({Status})")]
public class ProblemDetailsDto
{
/// <summary>
/// Gets or sets the URI reference that identifies the problem type.
/// </summary>
[JsonPropertyName("type")]
public string? Type { get; set; }
/// <summary>
/// Gets or sets a short, human-readable summary of the problem type.
/// </summary>
[JsonPropertyName("title")]
public string? Title { get; set; }
/// <summary>
/// Gets or sets the HTTP status code generated by the server for this occurrence of the problem.
/// </summary>
[JsonPropertyName("status")]
public int? Status { get; set; }
/// <summary>
/// Gets or sets a detailed explanation specific to this occurrence of the problem.
/// </summary>
[JsonPropertyName("detail")]
public string? Detail { get; set; }
/// <summary>
/// Gets or sets a URI reference that identifies the specific occurrence of the problem.
/// </summary>
[JsonPropertyName("instance")]
public string? Instance { get; set; }
/// <summary>
/// Gets or sets additional extension data that may be included with the problem details.
/// This allows for including extra, non-standard fields in the problem details.
/// </summary>
[JsonExtensionData]
public IDictionary<string, JsonElement>? Extensions { get; set; }
}
@@ -0,0 +1,27 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for a rating.
/// </summary>
[DebuggerDisplay("Value: {Value}, MaxValue: {MaxValue}")]
public abstract class RatingDto
{
/// <summary>
/// Gets the numeric value of the rating.
/// </summary>
public decimal? Value { get; set; }
/// <summary>
/// Gets the maximum possible rating value.
/// </summary>
public decimal? MaxValue { get; set; }
/// <summary>
/// Gets the optional number of votes or reviews this rating is based on.
/// </summary>
public int? VoteCount { get; set; }
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for a request to get release information.
/// </summary>
[DebuggerDisplay("OriginalReleaseDate: {OriginalReleaseDate}")]
public class ReleaseInfoDto
{
/// <summary>
/// Gets the optional original release date of the media item.
/// </summary>
public DateOnly? OriginalReleaseDate { get; set; }
/// <summary>
/// Gets the optional original release year of the media item.
/// This is useful when only the year of original release is known.
/// </summary>
public int? OriginalReleaseYear { get; set; }
/// <summary>
/// Gets the optional re-release or reissue date of the media item.
/// </summary>
public DateOnly? ReReleaseDate { get; set; }
/// <summary>
/// Gets the optional re-release or reissue year of the media item.
/// </summary>
public int? ReReleaseYear { get; set; }
/// <summary>
/// Gets the optional country or region of release.
/// </summary>
public string? ReleaseCountry { get; set; }
/// <summary>
/// Gets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
/// </summary>
public string? ReleaseVersion { get; set; }
}
@@ -0,0 +1,13 @@
#region ========================================================================= USING =====================================================================================
using System.Text.Json.Serialization;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Response data transfer object for the JSON responses of the web application that do not carry a payload.
/// </summary>
/// <param name="Success">Whether the operation succeeded or not.</param>
public record SuccessResponse(
[property: JsonPropertyName("success")] bool Success
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Text.Json.Serialization;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Response data transfer object for the JSON responses of the web application that carry a payload.
/// </summary>
/// <typeparam name="TData">The type of the payload of the response.</typeparam>
/// <param name="Success">Whether the operation succeeded or not.</param>
/// <param name="Data">The payload of the response.</param>
public record SuccessResponse<TData>(
[property: JsonPropertyName("success")] bool Success,
[property: JsonPropertyName("data")] TData? Data
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Common;
/// <summary>
/// Data transfer object for a request to get tag information.
/// </summary>
[DebuggerDisplay("Name: {Name}")]
public class TagDto
{
/// <summary>
/// Gets the name of the tag element of the media item.
/// </summary>
public string? Name { get; set; }
}
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Configuration;
/// <summary>
/// Data transfer object for deserializing media settings.
/// </summary>
[DebuggerDisplay("Section name: {SECTION_NAME}")]
public class EncryptionSettingsDto
{
public const string SECTION_NAME = "EncryptionSettings";
/// <summary>
/// Gets or sets the root directory where media files are stored.
/// </summary>
public required string SecretKey { get; init; }
}
@@ -0,0 +1,29 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Configuration;
/// <summary>
/// Data transfer object for deserializing server configuration settings.
/// </summary>
[DebuggerDisplay("Section name: {SECTION_NAME}")]
public class ServerConfigurationDto
{
public const string SECTION_NAME = "ServerConfiguration";
/// <summary>
/// Gets or sets the remote API server path.
/// </summary>
public required char ApiVersion { get; init; }
/// <summary>
/// Gets or sets the remote API server path.
/// </summary>
public required string BaseAddress { get; init; }
/// <summary>
/// Gets or sets the remote API server port.
/// </summary>
public required ushort Port { get; init; }
}
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for a model for storing binary data (blob).
/// </summary>
[DebuggerDisplay("ContentType: {ContentType} (Data.Length)")]
public class BlobDataDto
{
/// <summary>
/// Gets or sets the binary data as a byte array.
/// </summary>
public byte[] Data { get; set; } = null!;
/// <summary>
/// Gets or sets the content type (MIME type) of the blob data, such as "image/png" for an image or "application/pdf" for a PDF document.
/// </summary>
public string ContentType { get; set; } = null!;
}
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for directories displayed in custom directory/file browser dialogs.
/// </summary>
[DebuggerDisplay("Path: {Path}")]
public class DirectoryDto : FileSystemItemDto
{
/// <summary>
/// Gets or sets the children items of the directory.
/// </summary>
public List<FileSystemItemDto> Items { get; set; } = [];
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for files displayed in custom directory/file browser dialogs.
/// </summary>
[DebuggerDisplay("Path: {Path}")]
public class FileDto : FileSystemItemDto
{
/// <summary>
/// Gets or sets the size of the file, in bytes
/// </summary>
public long Size { get; set; }
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Base data transfer object for files and directories displayed in custom directory/file browser dialogs.
/// </summary>
[DebuggerDisplay("Path: {Path}")]
public abstract class FileSystemItemDto
{
/// <summary>
/// Gets or sets the full path to the file system item.
/// </summary>
public string? Path { get; set; }
/// <summary>
/// Gets or sets the name of the file system item.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Gets or sets the creation date of the file system item.
/// </summary>
public DateTime DateCreated { get; set; }
/// <summary>
/// Gets or sets the modification date of the file system item.
/// </summary>
public DateTime DateModified { get; set; }
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for a file system node.
/// </summary>
[DebuggerDisplay("Path: {Path}")]
public class FileSystemTreeNodeDto
{
/// <summary>
/// Gets or sets the full path of the file or directory.
/// </summary>
public string Path { get; set; } = null!;
/// <summary>
/// Gets or sets the name of the file or directory.
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// Gets or sets the type of the item, indicating whether it is a file, directory, or drive.
/// </summary>
public FileSystemItemType ItemType { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the node is expanded.
/// </summary>
public bool IsExpanded { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the child nodes have been loaded.
/// </summary>
public bool ChildrenLoaded { get; set; }
/// <summary>
/// Gets or sets the list of child nodes.
/// </summary>
public List<FileSystemTreeNodeDto> Children { get; set; } = [];
}
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.FileSystem;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object containing the file system platform type.
/// </summary>`
[DebuggerDisplay("PlatformType: {PlatformType}")]
public class FileSystemTypeDto
{
/// <summary>
/// Gets or sets the file system platform type.
/// </summary>
public PlatformType PlatformType { get; set; }
}
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for a response to the inquiry about the existence of a file system path.
/// </summary>
/// <param name="Exists">Whether a file system path exists or not.</param>
[DebuggerDisplay("Exists: {Exists}")]
public record PathExistsDto(
bool Exists
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for a response containing a file system path.
/// </summary>
[DebuggerDisplay("Path: {Path}")]
public class PathSegmentDto
{
/// <summary>
/// Gets or sets the returned path.
/// </summary>
public string Path { get; set; } = null!;
}
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for a file system path separator.
/// </summary>
/// <param name="Separator">The system's path separator.</param>
[DebuggerDisplay("Separator: {Separator}")]
public record PathSeparatorDto(
string Separator
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
/// <summary>
/// Data transfer object for a response to the inquiry about the validity of a file system path.
/// </summary>
/// <param name="IsValid">Whether a file system path is valid or not.</param>
[DebuggerDisplay("IsValid: {IsValid}")]
public record PathValidDto(
bool IsValid
);
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a lightweight book element, containing only the properties needed by the client for card-style navigation.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class BookLiteDto
{
/// <summary>
/// Gets or sets the Id of the book.
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the title of the book.
/// </summary>
public string Title { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the release year of the book (re-release year, if available, or original release year), if known.
/// </summary>
public int? ReleaseYear { get; set; }
/// <summary>
/// Gets or sets the path of the image representing the cover of the book, if available.
/// </summary>
public string? CoverPath { get; set; }
}
@@ -0,0 +1,71 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Library;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a library element.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class LibraryDto
{
/// <summary>
/// Gets or sets the unique identifier of the media library.
/// </summary>
public Guid? Id { get; set; }
/// <summary>
/// Gets or sets the unique identifier of the user owning the media library.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets or sets the title of the library.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the type of the library.
/// </summary>
public string? LibraryType { get; set; }
/// <summary>
/// Gets or sets the path of the image file used as the cover for the library.
/// </summary>
public string? CoverImage { get; set; }
/// <summary>
/// Gets or sets the collection of directories that contain the library files.
/// </summary>
public List<string> ContentLocations { get; set; } = [];
/// <summary>
/// Gets or sets whether this media library is enabled or not. A disabled media library is never shown or changed.
/// </summary>
public bool IsEnabled { get; set; } = true;
/// <summary>
/// Gets or sets whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.
/// </summary>
public bool IsLocked { get; set; } = false;
/// <summary>
/// Gets or sets whether this media library should update the metadata of its elements from the web, or not.
/// </summary>
public bool DownloadMetadataFromWeb { get; set; } = true;
/// <summary>
/// Gets or sets whether this media library should copy the downloaded metadata into the media library content locations, or not.
/// </summary>
public bool ShouldSaveMetadataInMediaDirectories { get; set; } = false;
/// <summary>
/// Gets or sets whether this media library should skip the directories whose contents have not changed since the last scan, during the scan. This is an opt-in setting, because it relies on directory metadata,
/// which does not change when the contents of an existing file are edited, and such edits could be missed while this setting is enabled.
/// </summary>
public bool ShouldSkipUnchangedDirectoriesDuringScan { get; set; } = false;
}
@@ -0,0 +1,32 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a media library scan job progress model.
/// </summary>
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}")]
public class LibraryScanJobProgressDto
{
/// <summary>
/// Gets or sets the number of completed items of the media library scan job.
/// </summary>
public int CompletedItems { get; set; }
/// <summary>
/// Gets or sets the total number of items of the media library scan job.
/// </summary>
public int TotalItems { get; set; }
/// <summary>
/// Gets or sets the current operation being performed by the media library scan job.
/// </summary>
public string? CurrentOperation { get; set; }
/// <summary>
/// Gets or sets the ratio between the total number and the completed number of items, as a percentage.
/// </summary>
public decimal ProgressPercentage { get; set; }
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a media library scan progress model.
/// </summary>
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}; LibraryId: {LibraryId}")]
public class LibraryScanProgressDto
{
/// <summary>
/// Gets or sets the unique identifier of the media library scan.
/// </summary>
public Guid ScanId { get; set; }
/// <summary>
/// Gets or sets the unique identifier of the user initiating this media library scan.
/// </summary>
public Guid UserId { get; set; }
/// <summary>
/// Gets or sets the unique identifier of the media library that is scanned.
/// </summary>
public Guid LibraryId { get; set; }
/// <summary>
/// Gets or sets the number of completed jobs of the media library scan job.
/// </summary>
public int CompletedJobs { get; set; }
/// <summary>
/// Gets or sets the total number of jobs of the media library scan job.
/// </summary>
public int TotalJobs { get; set; }
/// <summary>
/// Gets or sets the optional current job progress of the media library scan.
/// </summary>
public LibraryScanJobProgressDto? CurrentJobProgress { get; set; }
/// <summary>
/// Gets or sets the status of the media library scan.
/// </summary>
public string? Status { get; set; }
/// <summary>
/// Gets or sets the ratio between the total number and the completed number of jobs, as a percentage.
/// </summary>
public decimal OverallProgressPercentage { get; set; }
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a paginated collection of lightweight book elements, together with pagination metadata.
/// </summary>
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
public class PaginatedBookLiteDto
{
/// <summary>
/// Gets or sets the collection of lightweight book elements associated with this instance.
/// </summary>
public IReadOnlyList<BookLiteDto> Data { get; set; } = [];
/// <summary>
/// Gets or sets the current page number in a paginated collection.
/// </summary>
public int CurrentPage { get; set; }
/// <summary>
/// Gets or sets the number of items to include per page in paginated results.
/// </summary>
public int PerPage { get; set; }
/// <summary>
/// Gets or sets the total number of elements available in the paginated result set.
/// </summary>
public int Count { get; set; }
/// <summary>
/// Gets or sets the total number of pages based on elements available in the result set and per page.
/// </summary>
public int NumberOfPages { get; set; }
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
/// <summary>
/// Data transfer object for a media library scan response.
/// </summary>
[DebuggerDisplay("ScanId: {ScanId} LibraryId: {LibraryId}")]
public class ScanLibraryDto
{
/// <summary>
/// Gets or sets the Id of the media library scan.
/// </summary>
public Guid? ScanId { get; set; }
/// <summary>
/// Gets or sets the Id of the scanned media library.
/// </summary>
public Guid? LibraryId { get; set; }
}
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.MediaContributors;
/// <summary>
/// Data transfer object for a media contributor.
/// </summary>
[DebuggerDisplay("Name: {Name}")]
public class MediaContributorDto
{
/// <summary>
/// Gets the name of the contributor.
/// </summary>
public MediaContributorNameDto? Name { get; set; }
/// <summary>
/// Gets the role of the contributor.
/// </summary>
public MediaContributorRoleDto? Role { get; set; }
}
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.MediaContributors;
/// <summary>
/// Data transfer object for a media contributor name.
/// </summary>
[DebuggerDisplay("DisplayName: {DisplayName}")]
public class MediaContributorNameDto
{
/// <summary>
/// Gets the name by which the contributor is popularly known.
/// </summary>
public string? DisplayName { get; set; }
/// <summary>
/// Gets the legal name of the contributor.
/// </summary>
public string? LegalName { get; set; }
}
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.MediaContributors;
/// <summary>
/// Data transfer object for a media contributor role.
/// </summary>
[DebuggerDisplay("Name: {Name}")]
public class MediaContributorRoleDto
{
/// <summary>
/// Gets the value representing this object.
/// </summary>
public string? Name { get; set; }
/// <summary>
/// Gets the category of this object.
/// </summary>
public string? Category { get; set; }
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
/// <summary>
/// Data transfer object for a metadata provider configured for a media library.
/// </summary>
[DebuggerDisplay("Name: {Name}")]
public class LibraryMetadataProviderDto
{
/// <summary>
/// Gets or sets the unique identifier of the plugin providing the metadata.
/// </summary>
public Guid PluginId { get; set; }
/// <summary>
/// Gets or sets the display name of the metadata provider.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Gets or sets whether the metadata provider is enabled for the media library.
/// </summary>
public bool IsEnabled { get; set; }
/// <summary>
/// Gets or sets the rank of the metadata provider, determining the order in which providers are tried.
/// </summary>
public int Rank { get; set; }
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Plugins;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
/// <summary>
/// Data transfer object for a detected plugin.
/// </summary>
[DebuggerDisplay("Name: {Name}")]
public class PluginDto
{
/// <summary>
/// Gets or sets the unique identifier of the plugin.
/// </summary>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the display name of the plugin.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the author of the plugin.
/// </summary>
public string Author { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the version of the plugin.
/// </summary>
public string Version { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the description of the plugin.
/// </summary>
public string Description { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the load status of the plugin.
/// </summary>
public PluginLoadStatus LoadStatus { get; set; }
/// <summary>
/// Gets or sets the error message when the plugin failed to load.
/// </summary>
public string? LoadError { get; set; }
/// <summary>
/// Gets or sets the settings of the plugin.
/// </summary>
public Dictionary<string, string>? Settings { get; set; }
}
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Plugins;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
/// <summary>
/// Data transfer object for a single setting of a plugin.
/// </summary>
[DebuggerDisplay("Key: {Key}, Label: {Label}")]
public class PluginSettingDescriptorDto
{
/// <summary>
/// Gets or sets the unique key of the setting.
/// </summary>
public string Key { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the display label of the setting.
/// </summary>
public string Label { get; set; } = string.Empty;
/// <summary>
/// Gets or sets the type of the setting.
/// </summary>
public PluginSettingType Type { get; set; }
/// <summary>
/// Gets or sets the default value of the setting.
/// </summary>
public string? DefaultValue { get; set; }
/// <summary>
/// Gets or sets the list of allowed values, when the setting is a selection.
/// </summary>
public IReadOnlyList<string>? AllowedValues { get; set; }
}
@@ -0,0 +1,29 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
/// <summary>
/// Data transfer object for the settings of a plugin and their schema.
/// </summary>
[DebuggerDisplay("PluginId: {PluginId}")]
public class PluginSettingsDto
{
/// <summary>
/// Gets or sets the unique identifier of the plugin.
/// </summary>
public Guid PluginId { get; set; }
/// <summary>
/// Gets or sets the schema of the plugin settings.
/// </summary>
public List<PluginSettingDescriptorDto> Schema { get; set; } = [];
/// <summary>
/// Gets or sets the current values of the plugin settings.
/// </summary>
public Dictionary<string, string>? Settings { get; set; }
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.UsersManagement;
/// <summary>
/// Data transfer object for a user.
/// </summary>
/// <param name="Id">The unique identifier of the user.</param>
/// <param name="Username">The username of the user.</param>
[DebuggerDisplay("Id: {Id}, Username: {Username}")]
public record UserDto(
Guid Id,
string Username
);
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.UsersManagement;
/// <summary>
/// Data transfer object for the settings of a user.
/// </summary>
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
public class UserSettingsDto
{
/// <summary>
/// Gets or sets the unique identifier of the user that owns these settings.
/// </summary>
public Guid? UserId { get; set; }
/// <summary>
/// Gets or sets whether pagination is enabled for the user, or not.
/// </summary>
public bool IsPaginationEnabled { get; set; } = true;
/// <summary>
/// Gets or sets the number of library items displayed per page when pagination is enabled.
/// </summary>
public int ItemsPerPage { get; set; } = 48;
/// <summary>
/// Gets or sets whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
/// </summary>
public bool IgnoreThePrefixForAlphaPicker { get; set; }
}
@@ -0,0 +1,216 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Data transfer object for a book.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class BookDto
{
/// <summary>
/// Gets the Id of the media item.
/// </summary>
public Guid Id { get; init; }
/// <summary>
/// Gets the Id of the media library this book belongs to.
/// </summary>
public Guid LibraryId { get; init; }
/// <summary>
/// Gets the file system path of the book.
/// </summary>
public string Path { get; init; } = null!;
/// <summary>
/// Gets the title of the media item.
/// </summary>
public string Title { get; init; } = null!;
/// <summary>
/// Gets the original title of the media item.
/// </summary>
public string? OriginalTitle { get; init; }
/// <summary>
/// Gets the optional description of the media item.
/// </summary>
public string? Description { get; init; }
/// <summary>
/// Gets the optional original release date of the media item.
/// </summary>
public DateOnly? OriginalReleaseDate { get; init; }
/// <summary>
/// Gets the optional original release year of the media item.
/// This is useful when only the year of original release is known.
/// </summary>
public int? OriginalReleaseYear { get; init; }
/// <summary>
/// Gets the optional re-release or reissue date of the media item.
/// </summary>
public DateOnly? ReReleaseDate { get; init; }
/// <summary>
/// Gets the optional re-release or reissue year of the media item.
/// </summary>
public int? ReReleaseYear { get; init; }
/// <summary>
/// Gets the optional country or region of release.
/// </summary>
public string? ReleaseCountry { get; init; }
/// <summary>
/// Gets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0")
/// </summary>
public string? ReleaseVersion { get; init; }
/// <summary>
/// Gets the ISO 639-1 two-letter language code.
/// </summary>
public string? LanguageCode { get; init; }
/// <summary>
/// Gets the full name of the language in English.
/// </summary>
public string? LanguageName { get; init; }
/// <summary>
/// Gets an optional native name of the language.
/// </summary>
public string? LanguageNativeName { get; init; }
/// <summary>
/// Gets the optional ISO 639-1 two-letter original language code.
/// </summary>
public string? OriginalLanguageCode { get; init; }
/// <summary>
/// Gets the optional full name of the original language in English.
/// </summary>
public string? OriginalLanguageName { get; init; }
/// <summary>
/// Gets an optional native name of the original language.
/// </summary>
public string? OriginalLanguageNativeName { get; init; }
/// <summary>
/// Gets the list of tags associated with the media item.
/// </summary>
public HashSet<TagDto> Tags { get; set; } = [];
/// <summary>
/// Gets the list of genres associated with the media item.
/// </summary>
public HashSet<GenreDto> Genres { get; set; } = [];
/// <summary>
/// Gets the publisher of the written content.
/// </summary>
public string? Publisher { get; init; }
/// <summary>
/// Gets the number of pages in the written content.
/// </summary>
public int? PageCount { get; init; }
/// <summary>
/// Gets the format of the book (e.g., Hardcover, Paperback), if applicable.
/// </summary>
public string Format { get; init; } = null!;
/// <summary>
/// Gets the edition of the book, if applicable.
/// </summary>
public string? Edition { get; init; }
/// <summary>
/// Gets the volume or book number in the series, if applicable.
/// </summary>
public int? VolumeNumber { get; init; }
/// <summary>
/// Gets the series id, if the book is part of a series.
/// </summary>
//public Guid? BookSeriesId { get; init; } = null;
/// <summary>
/// Gets the ASIN (Amazon Standard Identification Number) of the book.
/// </summary>
public string? ASIN { get; init; } = null!;
/// <summary>
/// Gets the Goodreads ID of the book.
/// </summary>
public string? GoodreadsId { get; init; } = null!;
/// <summary>
/// Gets the Library of Congress Control Number (LCCN) of the book.
/// </summary>
public string? LCCN { get; init; } = null!;
/// <summary>
/// Gets the OCLC Number (WorldCat identifier) of the book.
/// </summary>
public string? OCLCNumber { get; init; } = null!;
/// <summary>
/// Gets the Open Library ID of the book.
/// </summary>
public string? OpenLibraryId { get; init; } = null!;
/// <summary>
/// Gets the LibraryThing ID of the book.
/// </summary>
public string? LibraryThingId { get; init; } = null!;
/// <summary>
/// Gets the Google Books ID of the book.
/// </summary>
public string? GoogleBooksId { get; init; } = null!;
/// <summary>
/// Gets the Barnes & Noble ID of the book.
/// </summary>
public string? BarnesAndNobleId { get; init; } = null!;
/// <summary>
/// Gets the Apple Books ID of the book.
/// </summary>
public string? AppleBooksId { get; init; } = null!;
/// <summary>
/// Gets the list of ISBN (International Standard Book Number) of the book.
/// </summary>
public List<IsbnDto> ISBNs { get; set; } = [];
/// <summary>
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
/// </summary>
//public List<ContributorIdModel> ContributorIds { get; init; } = [];
/// <summary>
/// Gets the list of ratings for this book.
/// </summary>
public List<BookRatingDto> Ratings { get; init; } = [];
/// <summary>
/// Gets the time and date when the entity was added.
/// </summary>
public DateTime Created { get; set; }
/// <summary>
/// Gets the optional time and date when the entity was updated.
/// </summary>
public DateTime? Updated { get; set; }
}
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
using System.Diagnostics;
using Lumina.Presentation.Web.Common.DTO.Common;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Data transfer object for a book rating.
/// </summary>
[DebuggerDisplay("Value: {Value}, MaxValue: {MaxValue}")]
public class BookRatingDto : RatingDto
{
/// <summary>
/// Gets or sets the source of the book rating (e.g., a specific website or platform).
/// </summary>
public BookRatingSource? Source { get; set; }
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Data transfer object for a request to get book series information.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class BookSeriesDto
{
/// <summary>
/// Gets or sets the title of the book series.
/// </summary>
public string? Title { get; set; }
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Data transfer object for a request to get ISBN information.
/// </summary>
[DebuggerDisplay("Value: {Value} ({Format})")]
public class IsbnDto
{
/// <summary>
/// Gets or sets the ISBN value.
/// </summary>
public string? Value { get; set; }
/// <summary>
/// Gets or sets the format of the ISBN (e.g., ISBN-10 or ISBN-13).
/// </summary>
public IsbnFormat? Format { get; set; }
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Data transfer object for a preview of important properties of a book.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class LightBookDto
{
/// <summary>
/// Gets the Id of the media item.
/// </summary>
public required Guid Id { get; init; }
/// <summary>
/// Gets the title of the media item.
/// </summary>
public required string Title { get; init; }
/// <summary>
/// Gets the optional release year (either re-release year, if available, or original release year, if known) of the media item.
/// </summary>
public int? ReleaseYear { get; init; }
/// <summary>
/// Gets the optional path of the image representing the cover of this book.
/// </summary>
public string? CoverPath { get; init; }
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Common;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary;
/// <summary>
/// Data transfer object for written content metadata.
/// </summary>
[DebuggerDisplay("Title: {Title}")]
public class WrittenContentMetadataDto
{
/// <summary>
/// Gets or sets the title of the written content.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the original title of the written content, if different from the current title.
/// </summary>
public string? OriginalTitle { get; set; }
/// <summary>
/// Gets or sets a brief description or summary of the written content.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Gets or sets the release information, including release date and other relevant details.
/// </summary>
public ReleaseInfoDto? ReleaseInfo { get; set; }
/// <summary>
/// Gets or sets the list of genres associated with the written content.
/// </summary>
public List<GenreDto>? Genres { get; set; }
/// <summary>
/// Gets or sets the list of tags that further describe or categorize the written content.
/// </summary>
public List<TagDto>? Tags { get; set; }
/// <summary>
/// Gets or sets the language in which the written content is written.
/// </summary>
public LanguageInfoDto? Language { get; set; }
/// <summary>
/// Gets or sets the original language of the written content, if it has been translated.
/// </summary>
public LanguageInfoDto? OriginalLanguage { get; set; }
/// <summary>
/// Gets or sets the name of the publisher of the written content.
/// </summary>
public string? Publisher { get; set; }
/// <summary>
/// Gets or sets the number of pages in the written content.
/// </summary>
public int? PageCount { get; set; }
}
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Configuration;
using Lumina.Presentation.Web.Common.DTO.Configuration;
using Lumina.Presentation.Web.Common.Utilities;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -26,13 +26,13 @@ internal static class PresentationWebLayerConfiguration
configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
configuration.AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);
serviceCollection.AddOptions<ServerConfigurationModel>()
.Bind(configuration.GetRequiredSection(ServerConfigurationModel.SECTION_NAME))
serviceCollection.AddOptions<ServerConfigurationDto>()
.Bind(configuration.GetRequiredSection(ServerConfigurationDto.SECTION_NAME))
.ValidateFluently()
.ValidateOnStart();
serviceCollection.AddOptions<EncryptionSettingsModel>()
.Bind(configuration.GetRequiredSection(EncryptionSettingsModel.SECTION_NAME))
serviceCollection.AddOptions<EncryptionSettingsDto>()
.Bind(configuration.GetRequiredSection(EncryptionSettingsDto.SECTION_NAME))
.ValidateFluently()
.ValidateOnStart();
@@ -1,13 +1,13 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using FastEndpoints.Swagger;
using FluentValidation;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Authorization;
using Lumina.Presentation.Web.Common.Enums.Authorization;
using Lumina.Presentation.Web.Common.Exceptions;
using Lumina.Presentation.Web.Common.Filters.ActionFilters;
using Lumina.Presentation.Web.Common.Filters.AuthorizationFilters;
using Lumina.Presentation.Web.Common.Http;
using Lumina.Presentation.Web.Common.MiddlewareFilters;
using Lumina.Presentation.Web.Common.Models.Authorization;
using Lumina.Presentation.Web.Common.Localization;
using Lumina.Presentation.Web.Common.Security;
using Lumina.Presentation.Web.Common.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Localization.Routing;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.Extensions.DependencyInjection;
using Polly;
@@ -49,11 +50,7 @@ public static class PresentationWebLayerServices
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddPresentationWebLayerServices(this IServiceCollection services)
{
services.AddControllersWithViews(mvcOptions =>
{
mvcOptions.Filters.Add(new MiddlewareFilterAttribute(typeof(LocalizationPipeline))); // add localization middleware filter
mvcOptions.Filters.Add<StoreLastViewFilter>();
})
services.AddControllersWithViews()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization()
.AddJsonOptions(jsonOptions =>
@@ -62,11 +59,50 @@ public static class PresentationWebLayerServices
jsonOptions.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
jsonOptions.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
// configure the locations where the Razor view engine looks for views and layouts, since the views live under the Core directory
services.Configure<RazorViewEngineOptions>(razorViewEngineOptions =>
{
razorViewEngineOptions.ViewLocationFormats.Clear();
razorViewEngineOptions.ViewLocationFormats.Add("/Core/Views/{1}/{0}.cshtml");
razorViewEngineOptions.ViewLocationFormats.Add("/Core/Views/Shared/{0}.cshtml");
});
// configure the JSON serialization settings used by Results.Json, so that the JSON responses of the endpoints match the MVC responses they replace
services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(jsonOptions =>
{
jsonOptions.SerializerOptions.MaxDepth = 256;
jsonOptions.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
jsonOptions.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
// register the FastEndpoints library, which replaces the MVC controllers for handling the application routes
services.AddFastEndpoints();
// add OpenAPI document generation, so that the endpoints exposed by the web application are discoverable and their contracts are visible
services.AddOpenApi();
services.SwaggerDocument(documentOptions =>
{
documentOptions.SerializerSettings = jsonSerializerOptions =>
{
jsonSerializerOptions.PropertyNamingPolicy = null;
jsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
};
documentOptions.DocumentSettings = aspNetCoreOpenApiDocumentGeneratorSettings =>
{
aspNetCoreOpenApiDocumentGeneratorSettings.DocumentName = "v1";
aspNetCoreOpenApiDocumentGeneratorSettings.Title = "Lumina Web";
aspNetCoreOpenApiDocumentGeneratorSettings.Version = "v1";
};
documentOptions.RemoveEmptyRequestSchema = true;
documentOptions.ShortSchemaNames = true;
});
// configure URL-based localization
services.AddLocalization(localizationOptions =>
{
localizationOptions.ResourcesPath = "Resources";
localizationOptions.ResourcesPath = "Core/Resources";
});
// resolve the resources of the views that live under the Core/Views directory
services.AddSingleton<IHtmlLocalizerFactory, CoreHtmlLocalizerFactory>();
services.Configure<RequestLocalizationOptions>(requestLocalizationOptions =>
{
@@ -190,9 +226,12 @@ public static class PresentationWebLayerServices
};
});
// add an authorization policy that ensures application is initialized with super admin account before allowing access
// add authorization policies that ensure the application is initialized with the super admin account before allowing access,
// and that restrict access based on the roles and permissions retrieved from the remote API
services.AddAuthorizationBuilder()
.AddPolicy("RequireInitialization", authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new InitializationRequirement()));
.AddPolicy(AuthorizationPolicies.REQUIRE_INITIALIZATION, authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new InitializationRequirement()))
.AddPolicy(AuthorizationPolicies.REQUIRE_ADMIN_ROLE, authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new RoleRequirement("Admin")))
.AddPolicy(AuthorizationPolicies.REQUIRE_CREATE_LIBRARIES_PERMISSION, authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new PermissionRequirement(AuthorizationPermission.CanCreateLibraries)));
// add forwarded headers middleware to handle reverse proxy scenarios
services.Configure<ForwardedHeadersOptions>(forwardedHeadersOptions =>
@@ -237,13 +276,13 @@ public static class PresentationWebLayerServices
.AddPolicyHandler(circuitBreakerPolicy);
services.AddScoped<CachedAuthorizationHandler>();
services.AddScoped<ApiAuthorizationFilter>();
services.AddScoped<AuthorizationRequirementModel>();
// enable access to the current HTTP context in non-controller classes
services.AddHttpContextAccessor();
services.AddScoped<IAuthorizationHandler, InitializationHandler>();
services.AddScoped<IAuthorizationHandler, RoleAuthorizationHandler>();
services.AddScoped<IAuthorizationHandler, PermissionAuthorizationHandler>();
services.AddScoped<Authorization.IAuthorizationService, AuthorizationService>();
services.AddSingleton<ICryptographyService, CryptographyService>();
services.AddSingleton<IUrlService, UrlService>();
@@ -1,5 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Models.Common;
using Lumina.Presentation.Web.Common.DTO.Common;
using System;
using System.Net;
#endregion
@@ -19,7 +19,7 @@ public class ApiException : Exception
/// <summary>
/// Gets or sets the problem details represented by this exception.
/// </summary>
public ProblemDetailsModel? ProblemDetails { get; }
public ProblemDetailsDto? ProblemDetails { get; }
/// <summary>
/// Gets or sets the absolute path of the API endpoint that produced this exception.
@@ -32,7 +32,7 @@ public class ApiException : Exception
/// <param name="problemDetails">The problem details object returned by the API.</param>
/// <param name="httpStatusCode">The HTTP status code returned by the API.</param>
/// <param name="requestPath">The absolute path of the API endpoint that produced this exception.</param>
public ApiException(ProblemDetailsModel? problemDetails, HttpStatusCode httpStatusCode, string? requestPath = null) : base(problemDetails?.Title ?? "An error occurred.")
public ApiException(ProblemDetailsDto? problemDetails, HttpStatusCode httpStatusCode, string? requestPath = null) : base(problemDetails?.Title ?? "An error occurred.")
{
ProblemDetails = problemDetails;
HttpStatusCode = httpStatusCode;
@@ -0,0 +1,65 @@
#region ========================================================================= USING =====================================================================================
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Common.Http;
/// <summary>
/// <see cref="IResult"/> that renders a Razor view through the MVC view engine, enabling FastEndpoints endpoints to serve the Razor views of the application.
/// </summary>
/// <remarks>
/// The <see cref="Results"/> class does not expose a method for rendering Razor views, so this custom result reuses the MVC
/// <see cref="ViewResult"/> execution machinery, which preserves layouts, sections, view components and tag helpers.
/// </remarks>
public sealed class RazorViewResult : IResult
{
private readonly string _viewName;
private readonly object? _model;
private readonly IReadOnlyDictionary<string, object?> _viewData;
/// <summary>
/// Initializes a new instance of the <see cref="RazorViewResult"/> class.
/// </summary>
/// <param name="viewName">The name or path of the view to render.</param>
/// <param name="model">The model to pass to the view.</param>
/// <param name="viewData">Optional additional view data entries made available to the view via <c>ViewData</c>.</param>
public RazorViewResult(string viewName, object? model = null, IReadOnlyDictionary<string, object?>? viewData = null)
{
_viewName = viewName;
_model = model;
_viewData = viewData ?? new Dictionary<string, object?>();
}
/// <summary>
/// Renders the configured Razor view to the response.
/// </summary>
/// <param name="httpContext">The <see cref="HttpContext"/> for the current request.</param>
public async Task ExecuteAsync(HttpContext httpContext)
{
// the only accessible ViewDataDictionary constructors require either a model state or an existing dictionary, so start from an empty one and assign the model
// through the Model setter; the setter rebases the model metadata on the runtime type of the value, which is what makes the asp-for tag helpers resolve the
// properties of the actual model type instead of a plain object
IModelMetadataProvider metadataProvider = httpContext.RequestServices.GetRequiredService<IModelMetadataProvider>();
ViewDataDictionary viewData = new(metadataProvider, new ModelStateDictionary()) { Model = _model };
foreach ((string key, object? value) in _viewData)
viewData[key] = value;
// delegate to the MVC view execution machinery instead of rendering the view manually: it discovers the layout and _ViewStart, evaluates the sections,
// and resolves the view components and tag helpers, none of which the Results class can do since it has no view rendering support
ViewResult viewResult = new() { ViewName = _viewName, ViewData = viewData };
IActionResultExecutor<ViewResult> executor = httpContext.RequestServices.GetRequiredService<IActionResultExecutor<ViewResult>>();
// the view engine needs an ActionContext, which FastEndpoints does not provide; synthesize one that carries over the current route data, so that the
// culture route value (and therefore the URL-based localization) keeps working while the view is rendered
ActionContext actionContext = new(httpContext, httpContext.GetRouteData() ?? new RouteData(), new ActionDescriptor());
await executor.ExecuteAsync(actionContext, viewResult).ConfigureAwait(false);
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.Extensions.Localization;
using System;
#endregion
namespace Lumina.Presentation.Web.Common.Localization;
/// <summary>
/// <see cref="IHtmlLocalizerFactory"/> that resolves the resources of the views that live under the <c>Core/Views</c> directory.
/// </summary>
/// <remarks>
/// The view localizer derives the resource base name from the executing view path, so a view at <c>/Core/Views/Auth/Login.cshtml</c> produces the base name
/// <c>{ApplicationName}.Core.Views.Auth.Login</c>. Because the <c>Core</c> segment is only the directory that hosts the views and not part of the resource path,
/// it is stripped here, so that the resources are looked up at <c>{ApplicationName}.Core.Resources.Views.Auth.Login</c>, matching the resource files under
/// <c>Core/Resources/Views/Auth</c>.
/// </remarks>
public class CoreHtmlLocalizerFactory : IHtmlLocalizerFactory
{
private readonly HtmlLocalizerFactory _innerFactory;
/// <summary>
/// Initializes a new instance of the <see cref="CoreHtmlLocalizerFactory"/> class.
/// </summary>
/// <param name="stringLocalizerFactory">Injected factory used to create the underlying string localizers.</param>
public CoreHtmlLocalizerFactory(IStringLocalizerFactory stringLocalizerFactory)
{
_innerFactory = new HtmlLocalizerFactory(stringLocalizerFactory);
}
/// <summary>
/// Creates an <see cref="IHtmlLocalizer"/> for the specified base name and location.
/// </summary>
/// <param name="baseName">The base name of the resource to load strings from.</param>
/// <param name="location">The location to load resources from.</param>
/// <returns>The created <see cref="IHtmlLocalizer"/>.</returns>
public IHtmlLocalizer Create(string baseName, string location)
{
string prefix = location + ".Core.";
string resourceBaseName = baseName.StartsWith(prefix, StringComparison.Ordinal)
? location + "." + baseName.Substring(prefix.Length)
: baseName;
return _innerFactory.Create(resourceBaseName, location);
}
/// <summary>
/// Creates an <see cref="IHtmlLocalizer"/> for the specified resource source type.
/// </summary>
/// <param name="resourceSource">The type of the resource to load strings from.</param>
/// <returns>The created <see cref="IHtmlLocalizer"/>.</returns>
public IHtmlLocalizer Create(Type resourceSource)
{
return _innerFactory.Create(resourceSource);
}
}
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents a request for adding an authorization role.
/// </summary>
/// <param name="RoleName">The name of the role. Required.</param>
/// <param name="Permissions">The collection or permissions of the role. Required.</param>
[DebuggerDisplay("RoleName: {RoleName}")]
public record AddRoleRequest(
string? RoleName,
List<Guid>? Permissions
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents a request for deleting an authorization role.
/// </summary>
/// <param name="RoleId">The unique identifier of the role. Required.</param>
[DebuggerDisplay("RoleId: {RoleId}")]
public record DeleteRoleRequest(
Guid RoleId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents a request to get the authorization permissions of a role identified by <paramref name="RoleId"/>.
/// </summary>
/// <param name="RoleId">The Id of authorization role. Required.</param>
[DebuggerDisplay("RoleId: {RoleId}")]
public record GetRolePermissionsRequest(
Guid RoleId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents the request model for retrieving the authorization permissions of a user identified by <paramref name="UserId"/>.
/// </summary>
/// <param name="UserId">The unique identifier of the user for whom to get the authorization permissions. Required.</param>
[DebuggerDisplay("UserId: {UserId}")]
public record GetUserPermissionsRequest(
Guid UserId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents the request model for retrieving the authorization role of a user identified by <paramref name="UserId"/>.
/// </summary>
/// <param name="UserId">The unique identifier of the user for whom to get the authorization role. Required.</param>
[DebuggerDisplay("UserId: {UserId}")]
public record GetUserRoleRequest(
Guid UserId
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents a request for updating an existing authorization role.
/// </summary>
/// <param name="RoleId">The unique identifier of the role. Required.</param>
/// <param name="RoleName">The name of the role. Required.</param>
/// <param name="Permissions">The collection of Ids of the permissions of the role. Required.</param>
[DebuggerDisplay("RoleName: {RoleName}")]
public record UpdateRoleRequest(
Guid RoleId,
string? RoleName,
List<Guid>? Permissions
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
/// <summary>
/// Represents a request for updating the authorization role and permissions of a user.
/// </summary>
/// <param name="UserId">The unique identifier of the user. Required.</param>
/// <param name="RoleId">The unique identifier of the role. Optional.</param>
/// <param name="Permissions">The collection of Ids of the permissions of the role. Optional.</param>
[DebuggerDisplay("UserId: {UserId}")]
public record UpdateUserRoleAndPermissionsRequest(
Guid UserId,
Guid? RoleId,
List<Guid>? Permissions
);
@@ -0,0 +1,6 @@
namespace Lumina.Presentation.Web.Common.Requests.Common;
/// <summary>
/// Record used for empty requests and responses.
/// </summary>
public record struct EmptyRequest();
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Directories;
/// <summary>
/// Represents a request to get the directories of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the directories. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetDirectoriesRequest(
string? Path,
bool IncludeHiddenElements
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
/// <summary>
/// Represents a request to get the files at a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the files. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetFilesRequest(
string? Path,
bool IncludeHiddenElements
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
/// <summary>
/// Represents a request to get the files of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the tree files. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetTreeFilesRequest(
string? Path,
bool IncludeHiddenElements
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to check the existence of a file system path.
/// </summary>
/// <param name="Path">The file system path to check the exitence of. Required.</param>
/// <param name="IncludeHiddenElements">Whether to include hidden elements in the search results, or not. Optional.</param>
[DebuggerDisplay("Path: {Path}, IncludeHiddenElements: {IncludeHiddenElements}")]
public record CheckPathExistsRequest(
string? Path,
bool IncludeHiddenElements
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents the request for retrieving the parent path of a file system path.
/// </summary>
/// <param name="Path">The path for which the parent path is retrieved.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetPathParentRequest(
string? Path
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to get the root of a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the root. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record GetPathRootRequest(
string? Path
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to split a file system path.
/// </summary>
/// <param name="Path">The file system path for which to get the path segments. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record SplitPathRequest(
string? Path
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
/// <summary>
/// Represents a request to check the validity of a file system path.
/// </summary>
/// <param name="Path">The file system path to validate. Required.</param>
[DebuggerDisplay("Path: {Path}")]
public record ValidatePathRequest(
string? Path
);
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Common;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Libraries;
/// <summary>
/// Represents a request to get the lightweight details of the books of a media library.
/// </summary>
[DebuggerDisplay("LibraryId: {LibraryId}")]
public class GetBooksLiteRequest
{
/// <summary>
/// Gets or sets the Id of the media library whose books are retrieved.
/// </summary>
public Guid LibraryId { get; set; }
/// <summary>
/// Gets or sets the page of results to retrieve.
/// </summary>
public int? CurrentPage { get; set; }
/// <summary>
/// Gets or sets the maximum number of books to retrieve per page.
/// </summary>
public int? PerPage { get; set; }
/// <summary>
/// Gets or sets the search term used to filter results.
/// </summary>
public string? SearchTerm { get; set; }
/// <summary>
/// Gets or sets the alpha key used to filter the results by the first character of their title, for the alpha picker.
/// Can be <see langword="null"/> to disable alpha filtering, a single ASCII letter (case-insensitive) to filter by that letter,
/// "#" to filter by titles whose first character is a digit, or "*" to filter by titles whose first character is neither a letter nor a digit.
/// </summary>
public string? FilterAlphaKey { get; set; }
/// <summary>
/// Gets or sets whether the leading "The " prefix of a title is ignored when computing the alpha key, or not.
/// </summary>
public bool IgnoreThePrefixForAlphaPicker { get; set; }
/// <summary>
/// Gets or sets the name of the field by which to sort the results.
/// </summary>
public string? SortBy { get; set; }
/// <summary>
/// Gets or sets the direction in which to sort the results.
/// </summary>
public SortOrder? SortOrder { get; set; }
}
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
/// <summary>
/// Represents a request to cancel the scan of a media library.
/// </summary>
/// <param name="LibraryId">The unique identifier of the media library whose scan is cancelled. Required.</param>
/// <param name="ScanId">The Id of scan to cancel. Required.</param>
[DebuggerDisplay("LibraryId: {LibraryId}; ScanId: {ScanId}")]
public record CancelLibraryScanRequest(
Guid LibraryId,
Guid ScanId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
/// <summary>
/// Represents a request to delete a media library by its Id.
/// </summary>
/// <param name="Id">The unique identifier of the media library to be deleted. Required.</param>
[DebuggerDisplay("Id: {Id}")]
public record DeleteLibraryRequest(
Guid Id
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
/// <summary>
/// Represents the request for displaying the media library editing view.
/// </summary>
/// <param name="Id">The unique identifier of the media library to edit.</param>
[DebuggerDisplay("Id: {Id}")]
public record EditLibraryRequest(
Guid Id
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
/// <summary>
/// Represents the request for retrieving the metadata providers of a media library.
/// </summary>
/// <param name="LibraryId">The unique identifier of the media library whose metadata providers are retrieved.</param>
[DebuggerDisplay("LibraryId: {LibraryId}")]
public record GetMetadataProvidersRequest(
Guid LibraryId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.Management;
/// <summary>
/// Represents a request to scan a media library.
/// </summary>
/// <param name="Id">The unique identifier of the media library to be scanned. Required.</param>
[DebuggerDisplay("Id: {Id}")]
public record ScanLibraryRequest(
Guid Id
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Represents a request to get a book by the specified Id.
/// </summary>
/// <param name="Id">The unique identifier of the book to retrieve.</param>
[DebuggerDisplay("Id: {Id}")]
public record GetBookRequest(
Guid Id
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
/// <summary>
/// Represents the request for displaying the books browsing view.
/// </summary>
/// <param name="LibraryId">The unique identifier of the media library whose books are browsed.</param>
[DebuggerDisplay("LibraryId: {LibraryId}")]
public record GetBooksViewRequest(
Guid? LibraryId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Plugins;
/// <summary>
/// Represents a request to get the settings of a plugin.
/// </summary>
/// <param name="PluginId">The unique identifier of the plugin. Required.</param>
[DebuggerDisplay("PluginId: {PluginId}")]
public record GetPluginSettingsRequest(
Guid PluginId
);
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Plugins;
/// <summary>
/// Represents a request to reorder the metadata providers of a media library.
/// </summary>
[DebuggerDisplay("LibraryId: {LibraryId}")]
public class ReorderLibraryMetadataProvidersRequest
{
/// <summary>
/// Gets or sets the Id of the media library whose metadata providers are reordered.
/// </summary>
public Guid LibraryId { get; set; }
/// <summary>
/// Gets or sets the plugin Ids in the new order, from highest to lowest rank.
/// </summary>
public List<Guid> PluginIds { get; set; } = [];
}
@@ -0,0 +1,29 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Plugins;
/// <summary>
/// Represents a request to enable or disable a metadata provider for a media library.
/// </summary>
[DebuggerDisplay("LibraryId: {LibraryId}, PluginId: {PluginId}")]
public class SetLibraryMetadataProviderEnabledRequest
{
/// <summary>
/// Gets or sets the Id of the media library whose metadata provider is enabled or disabled.
/// </summary>
public Guid LibraryId { get; set; }
/// <summary>
/// Gets or sets the unique identifier of the plugin providing the metadata.
/// </summary>
public Guid PluginId { get; set; }
/// <summary>
/// Gets or sets whether the metadata provider should be enabled for the media library.
/// </summary>
public bool IsEnabled { get; set; }
}
@@ -0,0 +1,24 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Plugins;
/// <summary>
/// Represents a request to update the settings of a plugin.
/// </summary>
[DebuggerDisplay("PluginId: {PluginId}")]
public class UpdatePluginSettingsRequest
{
/// <summary>
/// Gets or sets the unique identifier of the plugin.
/// </summary>
public Guid PluginId { get; set; }
/// <summary>
/// Gets or sets the settings of the plugin.
/// </summary>
public Dictionary<string, string>? Settings { get; set; }
}
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Tools;
/// <summary>
/// Represents the request for setting the culture used by the application.
/// </summary>
/// <param name="NewCulture">The new culture to set.</param>
/// <param name="ReturnUrl">The URL to return to, after setting the new culture.</param>
[DebuggerDisplay("NewCulture: {NewCulture}, ReturnUrl: {ReturnUrl}")]
public record SetLanguageRequest(
string? NewCulture,
string? ReturnUrl
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.UsersManagement.Authentication;
/// <summary>
/// Represents the request for displaying the account login view.
/// </summary>
/// <param name="ReturnUrl">The URL to return to, after login.</param>
[DebuggerDisplay("ReturnUrl: {ReturnUrl}")]
public record LoginViewRequest(
string? ReturnUrl = null
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.UsersManagement;
/// <summary>
/// Represents the request model for account password change.
/// </summary>
/// <param name="Username">The username of the account. Required.</param>
/// <param name="CurrentPassword">The current password of the account. Required.</param>
/// <param name="NewPassword">The new password of the account. Required.</param>
/// <param name="NewPasswordConfirm">The confirmation of the new password of the account. Required.</param>
[DebuggerDisplay("Username: {Username}")]
public record ChangePasswordRequest(
string? Username,
string? CurrentPassword,
string? NewPassword,
string? NewPasswordConfirm
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.UsersManagement;
/// <summary>
/// Represents the request model for user authentication.
/// </summary>
/// <param name="Username">The username of the account to authenticate. Required.</param>
/// <param name="Password">The password of the account to authenticate. Required.</param>
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account to authenticate. Optional.</param>
/// <param name="ReturnUrl">The URL to return to, after login.</param>
[DebuggerDisplay("Username: {Username}")]
public record LoginRequest(
string? Username = null,
string? Password = null,
string? TotpCode = null,
string? ReturnUrl = null
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.UsersManagement;
/// <summary>
/// Represents the request model for account password recovery.
/// </summary>
/// <param name="Username">The username of the account for which to recover the password. Required.</param>
/// <param name="TotpCode">The TOTP (Time-Based One-Time Password) of the account for which to recover the password. Required.</param>
[DebuggerDisplay("Username: {Username}")]
public record RecoverPasswordRequest(
string? Username,
string? TotpCode
);
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.UsersManagement;
/// <summary>
/// Represents the request model for user registration.
/// </summary>
/// <param name="Username">The desired username for the new account. Required.</param>
/// <param name="Password">The password for the new account. Required.</param>
/// <param name="PasswordConfirm">The confirmation of the entered password, used to ensure consistency. Required.</param>
/// <param name="RegistrationType">Specifies the type of registration, e.g., "Admin" or "User". Required.</param>
/// <param name="Use2fa">Indicates whether two-factor authentication (2FA) should be enabled for the new account. Optional.</param>
[DebuggerDisplay("Username: {Username}")]
public record RegisterRequest(
string? Username,
string? Password,
string? PasswordConfirm,
string? RegistrationType,
bool Use2fa = true
);
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Authorization;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Responses.Authorization;
/// <summary>
/// Represents the response model for an account authorization request.
/// </summary>
/// <param name="UserId">The unique identifier of the user for whom the authorization is retrieved.</param>
/// <param name="Role">The role associated to the user.</param>
/// <param name="Permissions">The collection of permissions associated to the user.</param>
[DebuggerDisplay("UserId: {UserId}")]
public record GetAuthorizationResponse(
Guid UserId,
string? Role,
AuthorizationPermission[] Permissions
);
@@ -0,0 +1,14 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Responses.UsersManagement;
/// <summary>
/// Represents the response model for an account password change request.
/// </summary>
/// <param name="IsPasswordChanged">Whether the password was changed or not.</param>
[DebuggerDisplay("IsPasswordChanged: {IsPasswordChanged}")]
public record ChangePasswordResponse(
bool IsPasswordChanged
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Responses.UsersManagement;
/// <summary>
/// Model for verifying the initialization status of the application.
/// </summary>
[DebuggerDisplay("IsInitialized: {IsInitialized}")]
public class InitializationResponse
{
/// <summary>
/// Gets or sets a value indicating whether the application has been run before, and the super admin account has been created.
/// </summary>
public bool IsInitialized { get; set; }
}
Loaded 100 of 137 files, more files were not shown because too many files have changed in this diff. Show more