Refactor workflows and improve API responses

- Added `BackToPerMethodId` constant and updated validation rules in `CloseWorkflowCommandValidator`.
- Refactored `GetWorkflowsQueryHandler` for simpler `hasListingData` logic.
- Replaced strongly-typed properties with `JsonElement` in `ContractsSourceBlock` and `FerdinandSourceBlock`.
- Updated `WorkflowListingReadModel` to use smaller data types for efficiency.
- Refactored `WorkflowRepository` to use JSON-based data retrieval and parsing.
- Introduced `MetaOnlyResponse` and `WorkflowsResponse` for consistent API responses.
- Updated `DocumentsController` and `WorkflowsController` to use new response types.
- Added `ApiKeyAuthMiddleware` for API key validation and integrated it into the middleware pipeline.
- Refactored `ExceptionHandlingMiddleware` to use `MetaOnlyResponse` for error handling.
- Performed general cleanup and modernization for improved readability and maintainability.
This commit is contained in:
2026-10-10 20:47:31 +02:00
parent 600374a6f0
commit 70e82567d8
14 changed files with 352 additions and 166 deletions

View File

@@ -1,5 +1,8 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
using System.Text.Json;
using System.Text.Json.Serialization;
/// <summary>
/// Represents workflow data for the Contracts source system.
/// </summary>
@@ -8,30 +11,30 @@ public sealed record ContractsSourceBlock : SourceBlock
/// <summary>
/// Gets available approval profiles.
/// </summary>
public required IReadOnlyList<ProfileItem> Profiles { get; init; }
[JsonPropertyName("profile")]
public required IReadOnlyList<JsonElement> Profile { get; init; }
/// <summary>
/// Gets workflow listing items.
/// </summary>
public required IReadOnlyList<WorkflowListingItem> Listing { get; init; }
[JsonPropertyName("Listing")]
public required IReadOnlyList<JsonElement> Listing { get; init; }
/// <summary>
/// Gets already executed approvals.
/// </summary>
public required IReadOnlyList<ApprovalItem> Approvals { get; init; }
[JsonPropertyName("approvals")]
public required IReadOnlyList<JsonElement> Approvals { get; init; }
/// <summary>
/// Gets document references for workflows.
/// </summary>
public required IReadOnlyList<DocumentReferenceItem> Documents { get; init; }
[JsonPropertyName("document")]
public required IReadOnlyList<JsonElement> Document { get; init; }
/// <summary>
/// Gets available closing methods for workflows.
/// </summary>
public required IReadOnlyList<ClosingMethodItem> ClosingMethods { get; init; }
/// <summary>
/// Gets available rejection reasons for rejection-type methods.
/// </summary>
public required IReadOnlyList<RejectionReasonItem> RejectionReasons { get; init; }
[JsonPropertyName("closing_method")]
public required IReadOnlyList<JsonElement> ClosingMethod { get; init; }
}

View File

@@ -1,5 +1,8 @@
namespace DigitalData.TaskFlow.Domain.Workflows;
using System.Text.Json;
using System.Text.Json.Serialization;
/// <summary>
/// Represents workflow data for the Ferdinand source system.
/// </summary>
@@ -8,30 +11,36 @@ public sealed record FerdinandSourceBlock : SourceBlock
/// <summary>
/// Gets available approval profiles.
/// </summary>
public required IReadOnlyList<ProfileItem> Profiles { get; init; }
[JsonPropertyName("profile")]
public required IReadOnlyList<JsonElement> Profile { get; init; }
/// <summary>
/// Gets workflow listing items.
/// </summary>
public required IReadOnlyList<WorkflowListingItem> Listing { get; init; }
[JsonPropertyName("Listing")]
public required IReadOnlyList<JsonElement> Listing { get; init; }
/// <summary>
/// Gets already executed approvals.
/// </summary>
public required IReadOnlyList<ApprovalItem> Approvals { get; init; }
[JsonPropertyName("approvals")]
public required IReadOnlyList<JsonElement> Approvals { get; init; }
/// <summary>
/// Gets document references for workflows.
/// </summary>
public required IReadOnlyList<DocumentReferenceItem> Documents { get; init; }
[JsonPropertyName("document")]
public required IReadOnlyList<JsonElement> Document { get; init; }
/// <summary>
/// Gets available closing methods for workflows.
/// </summary>
public required IReadOnlyList<ClosingMethodItem> ClosingMethods { get; init; }
[JsonPropertyName("closing_method")]
public required IReadOnlyList<JsonElement> ClosingMethod { get; init; }
/// <summary>
/// Gets available rejection reasons for rejection-type methods.
/// </summary>
public required IReadOnlyList<RejectionReasonItem> RejectionReasons { get; init; }
[JsonPropertyName("rejection_reason")]
public required IReadOnlyList<JsonElement> RejectionReason { get; init; }
}