diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Endpoint.cs index 835bc448e..69219c56b 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Endpoint.cs @@ -1,5 +1,6 @@ using Elsa.Abstractions; using Elsa.Workflows.Api.Contracts; +using Elsa.Workflows.Api.Endpoints.Shells; using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using Elsa.Workflows; @@ -27,7 +28,7 @@ internal class Reload(IShellReloadOrchestrator shellReloadOrchestrator, IApiSeri } var serializerOptions = apiSerializer.GetOptions(); - var response = Elsa.Workflows.Api.Endpoints.Shells.Reload.Response.FromResult(result); + var response = ShellReloadResponse.FromResult(result); var statusCode = result.Status switch { ShellReloadStatus.Busy => StatusCodes.Status409Conflict, @@ -39,7 +40,7 @@ internal class Reload(IShellReloadOrchestrator shellReloadOrchestrator, IApiSeri await SendJsonAsync(response, statusCode, serializerOptions, cancellationToken); } - private async Task SendJsonAsync(Response response, int statusCode, System.Text.Json.JsonSerializerOptions serializerOptions, CancellationToken cancellationToken) + private async Task SendJsonAsync(ShellReloadResponse response, int statusCode, System.Text.Json.JsonSerializerOptions serializerOptions, CancellationToken cancellationToken) { HttpContext.Response.StatusCode = statusCode; await HttpContext.Response.WriteAsJsonAsync(response, serializerOptions, cancellationToken); diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Models.cs b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Models.cs index 371dd113d..3559f5d7b 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Models.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/Reload/Models.cs @@ -1,33 +1 @@ -using Elsa.Workflows.Api.Contracts; - -namespace Elsa.Workflows.Api.Endpoints.Shells.Reload; - -internal class Response -{ - public ShellReloadStatus Status { get; init; } - public string? RequestedShellId { get; init; } - public DateTimeOffset ReloadedAt { get; init; } - public IReadOnlyCollection Shells { get; init; } = []; - - public static Response FromResult(ShellReloadResult result) => new() - { - Status = result.Status, - RequestedShellId = result.RequestedShellId, - ReloadedAt = result.ReloadedAt, - Shells = result.Shells.Select(x => new ShellResponse - { - ShellId = x.ShellId, - Outcome = x.Outcome, - Requested = x.Requested, - Message = x.Message - }).ToArray() - }; -} - -internal class ShellResponse -{ - public string ShellId { get; init; } = null!; - public ShellReloadItemOutcome Outcome { get; init; } - public bool Requested { get; init; } - public string? Message { get; init; } -} \ No newline at end of file +// Response models for this endpoint are defined in the shared ShellsResponseModels.cs file. diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Endpoint.cs index f1d86dd6a..0da719c5f 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Endpoint.cs @@ -1,5 +1,6 @@ using Elsa.Abstractions; using Elsa.Workflows.Api.Contracts; +using Elsa.Workflows.Api.Endpoints.Shells; using JetBrains.Annotations; using Microsoft.AspNetCore.Http; @@ -17,7 +18,7 @@ internal class ReloadAll(IShellReloadOrchestrator shellReloadOrchestrator) : Els public override async Task HandleAsync(CancellationToken cancellationToken) { var result = await shellReloadOrchestrator.ReloadAllAsync(cancellationToken); - var response = Elsa.Workflows.Api.Endpoints.Shells.ReloadAll.Response.FromResult(result); + var response = ShellReloadResponse.FromResult(result); switch (result.Status) { diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Models.cs b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Models.cs index 714bf48b0..6b426610c 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Models.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ReloadAll/Models.cs @@ -1,33 +1 @@ -using Elsa.Workflows.Api.Contracts; - -namespace Elsa.Workflows.Api.Endpoints.Shells.ReloadAll; - -internal class Response -{ - public ShellReloadStatus Status { get; init; } - public string? RequestedShellId { get; init; } - public DateTimeOffset ReloadedAt { get; init; } - public IReadOnlyCollection Shells { get; init; } = []; - - public static Response FromResult(ShellReloadResult result) => new() - { - Status = result.Status, - RequestedShellId = result.RequestedShellId, - ReloadedAt = result.ReloadedAt, - Shells = result.Shells.Select(x => new ShellResponse - { - ShellId = x.ShellId, - Outcome = x.Outcome, - Requested = x.Requested, - Message = x.Message - }).ToArray() - }; -} - -internal class ShellResponse -{ - public string ShellId { get; init; } = default!; - public ShellReloadItemOutcome Outcome { get; init; } - public bool Requested { get; init; } - public string? Message { get; init; } -} \ No newline at end of file +// Response models for this endpoint are defined in the shared ShellsResponseModels.cs file. \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ShellsResponseModels.cs b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ShellsResponseModels.cs new file mode 100644 index 000000000..df85bbb98 --- /dev/null +++ b/src/modules/Elsa.Workflows.Api/Endpoints/Shells/ShellsResponseModels.cs @@ -0,0 +1,33 @@ +using Elsa.Workflows.Api.Contracts; + +namespace Elsa.Workflows.Api.Endpoints.Shells; + +internal class ShellReloadResponse +{ + public ShellReloadStatus Status { get; init; } + public string? RequestedShellId { get; init; } + public DateTimeOffset ReloadedAt { get; init; } + public IReadOnlyCollection Shells { get; init; } = []; + + public static ShellReloadResponse FromResult(ShellReloadResult result) => new() + { + Status = result.Status, + RequestedShellId = result.RequestedShellId, + ReloadedAt = result.ReloadedAt, + Shells = result.Shells.Select(x => new ShellReloadItemResponse + { + ShellId = x.ShellId, + Outcome = x.Outcome, + Requested = x.Requested, + Message = x.Message + }).ToArray() + }; +} + +internal class ShellReloadItemResponse +{ + public string ShellId { get; init; } = default!; + public ShellReloadItemOutcome Outcome { get; init; } + public bool Requested { get; init; } + public string? Message { get; init; } +}