Merge branch 'feat/ContainerHelper' into v2.1
Some checks failed
Dev Publish: Nuget / Publish Dev Packages (push) Failing after 31s
Some checks failed
Dev Publish: Nuget / Publish Dev Packages (push) Failing after 31s
# Conflicts: # Moonlight.Api/Services/ApplicationService.cs # Moonlight.Api/Startup/Startup.Base.cs # Moonlight.Shared/Http/SerializationContext.cs
This commit is contained in:
20
Moonlight.Shared/Http/Events/RebuildEventDto.cs
Normal file
20
Moonlight.Shared/Http/Events/RebuildEventDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Moonlight.Shared.Http.Events;
|
||||
|
||||
public struct RebuildEventDto
|
||||
{
|
||||
[JsonPropertyName("type")]
|
||||
public RebuildEventType Type { get; set; }
|
||||
|
||||
[JsonPropertyName("data")]
|
||||
public string Data { get; set; }
|
||||
}
|
||||
|
||||
public enum RebuildEventType
|
||||
{
|
||||
Log = 0,
|
||||
Failed = 1,
|
||||
Succeeded = 2,
|
||||
Step = 3
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.ApiKeys;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.ApiKeys;
|
||||
|
||||
public class CreateApiKeyDto
|
||||
{
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[MaxLength(300)] public string Description { get; set; } = "";
|
||||
|
||||
|
||||
[Required]
|
||||
public string[] Permissions { get; set; }
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.ApiKeys;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.ApiKeys;
|
||||
|
||||
public class UpdateApiKeyDto
|
||||
{
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[MaxLength(300)] public string Description { get; set; } = "";
|
||||
|
||||
[Required]
|
||||
public string[] Permissions { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
|
||||
|
||||
public class RequestRebuildDto
|
||||
{
|
||||
public bool NoBuildCache { get; set; }
|
||||
|
||||
public RequestRebuildDto()
|
||||
{
|
||||
}
|
||||
|
||||
public RequestRebuildDto(bool noBuildCache)
|
||||
{
|
||||
NoBuildCache = noBuildCache;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
|
||||
|
||||
public class SetVersionDto
|
||||
{
|
||||
[Required]
|
||||
[RegularExpression(@"^(?!\/|.*\/\/|.*\.\.|.*\/$)[A-Za-z0-9._/-]+$", ErrorMessage = "Invalid version format")]
|
||||
public string Version { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Roles;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.Roles;
|
||||
|
||||
public class CreateRoleDto
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Roles;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.Roles;
|
||||
|
||||
public class UpdateRoleDto
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Themes;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.Themes;
|
||||
|
||||
public class CreateThemeDto
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Themes;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.Themes;
|
||||
|
||||
public class UpdateThemeDto
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Users;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.Users;
|
||||
|
||||
public class CreateUserDto
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Users;
|
||||
namespace Moonlight.Shared.Http.Requests.Admin.Users;
|
||||
|
||||
public class UpdateUserDto
|
||||
{
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.ApiKeys;
|
||||
namespace Moonlight.Shared.Http.Responses.Admin.ApiKeys;
|
||||
|
||||
public record ApiKeyDto(int Id, string Name, string Description, string[] Permissions, string Key, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);
|
||||
3
Moonlight.Shared/Http/Responses/Admin/Auth/ClaimDto.cs
Normal file
3
Moonlight.Shared/Http/Responses/Admin/Auth/ClaimDto.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Admin.Auth;
|
||||
|
||||
public record ClaimDto(string Type, string Value);
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Auth;
|
||||
namespace Moonlight.Shared.Http.Responses.Admin.Auth;
|
||||
|
||||
public record SchemeDto(string Name, string DisplayName);
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Admin;
|
||||
|
||||
public record ContainerHelperStatusDto(bool IsEnabled, bool IsReachable);
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Frontend;
|
||||
namespace Moonlight.Shared.Http.Responses.Admin.Frontend;
|
||||
|
||||
public record FrontendConfigDto(string Name, string? ThemeCss);
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Themes;
|
||||
namespace Moonlight.Shared.Http.Responses.Admin.Themes;
|
||||
|
||||
public record ThemeDto(int Id, string Name, string Author, string Version, string CssContent, bool IsEnabled);
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Users;
|
||||
namespace Moonlight.Shared.Http.Responses.Admin.Users;
|
||||
|
||||
public record UserDto(int Id, string Username, string Email, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Auth;
|
||||
|
||||
public record ClaimDto(string Type, string Value);
|
||||
10
Moonlight.Shared/Http/Responses/ProblemDetails.cs
Normal file
10
Moonlight.Shared/Http/Responses/ProblemDetails.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Moonlight.Shared.Http.Responses;
|
||||
|
||||
public class ProblemDetails
|
||||
{
|
||||
public string Type { get; set; }
|
||||
public string Title { get; set; }
|
||||
public int Status { get; set; }
|
||||
public string? Detail { get; set; }
|
||||
public Dictionary<string, string[]>? Errors { get; set; }
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Moonlight.Shared.Http.Requests.ApiKeys;
|
||||
using Moonlight.Shared.Http.Requests.Roles;
|
||||
using Moonlight.Shared.Http.Requests.Themes;
|
||||
using Moonlight.Shared.Http.Requests.Users;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Moonlight.Shared.Http.Events;
|
||||
using Moonlight.Shared.Http.Requests.Admin.ApiKeys;
|
||||
using Moonlight.Shared.Http.Requests.Admin.ContainerHelper;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Roles;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Themes;
|
||||
using Moonlight.Shared.Http.Requests.Admin.Users;
|
||||
using Moonlight.Shared.Http.Responses;
|
||||
using Moonlight.Shared.Http.Responses.Admin;
|
||||
using Moonlight.Shared.Http.Responses.ApiKeys;
|
||||
using Moonlight.Shared.Http.Responses.Auth;
|
||||
using Moonlight.Shared.Http.Responses.Themes;
|
||||
using Moonlight.Shared.Http.Responses.Users;
|
||||
using Moonlight.Shared.Http.Responses.Admin.ApiKeys;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Auth;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Themes;
|
||||
using Moonlight.Shared.Http.Responses.Admin.Users;
|
||||
|
||||
namespace Moonlight.Shared.Http;
|
||||
|
||||
@@ -44,8 +47,32 @@ namespace Moonlight.Shared.Http;
|
||||
[JsonSerializable(typeof(PagedData<ThemeDto>))]
|
||||
[JsonSerializable(typeof(ThemeDto))]
|
||||
|
||||
// Events
|
||||
[JsonSerializable(typeof(RebuildEventDto))]
|
||||
|
||||
// Container Helper
|
||||
[JsonSerializable(typeof(ContainerHelperStatusDto))]
|
||||
[JsonSerializable(typeof(RequestRebuildDto))]
|
||||
[JsonSerializable(typeof(SetVersionDto))]
|
||||
|
||||
//Misc
|
||||
[JsonSerializable(typeof(VersionDto))]
|
||||
[JsonSerializable(typeof(ProblemDetails))]
|
||||
public partial class SerializationContext : JsonSerializerContext
|
||||
{
|
||||
private static JsonSerializerOptions? InternalTunedOptions;
|
||||
|
||||
public static JsonSerializerOptions TunedOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (InternalTunedOptions != null)
|
||||
return InternalTunedOptions;
|
||||
|
||||
InternalTunedOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
||||
InternalTunedOptions.TypeInfoResolverChain.Add(Default);
|
||||
|
||||
return InternalTunedOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user