From 986d0aa2568fa5af644a3cf23db464abcdcddf90 Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 9 Oct 2026 23:05:47 +0200 Subject: [PATCH] feat(domain): add workflow API core models and meta codes --- .../Closing/CloseWorkflowDecision.cs | 22 +++++ .../Closing/CloseWorkflowResult.cs | 17 ++++ .../Common/ApiEnvelope.cs | 18 ++++ .../Common/MetaEntry.cs | 17 ++++ .../Documents/DocumentBinaryResult.cs | 27 ++++++ .../Enums/MetaCode.cs | 42 +++++++++ .../Workflows/ApprovalItem.cs | 32 +++++++ .../Workflows/ClosingMethodItem.cs | 27 ++++++ .../Workflows/ContractsSourceBlock.cs | 37 ++++++++ .../Workflows/DocumentReferenceItem.cs | 27 ++++++ .../Workflows/FerdinandSourceBlock.cs | 37 ++++++++ .../Workflows/ProfileItem.cs | 22 +++++ .../Workflows/RejectionReasonItem.cs | 17 ++++ .../Workflows/SourceBlock.cs | 12 +++ .../Workflows/WorkflowListingItem.cs | 87 +++++++++++++++++++ .../Workflows/WorkflowSourcesResponse.cs | 12 +++ 16 files changed, 453 insertions(+) create mode 100644 src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowDecision.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowResult.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Common/ApiEnvelope.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Common/MetaEntry.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Documents/DocumentBinaryResult.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Enums/MetaCode.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/ApprovalItem.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/ClosingMethodItem.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/ContractsSourceBlock.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/DocumentReferenceItem.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/FerdinandSourceBlock.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/ProfileItem.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/RejectionReasonItem.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/SourceBlock.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowListingItem.cs create mode 100644 src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowSourcesResponse.cs diff --git a/src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowDecision.cs b/src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowDecision.cs new file mode 100644 index 0000000..3cbcf50 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowDecision.cs @@ -0,0 +1,22 @@ +namespace DigitalData.TaskFlow.Domain.Closing; + +/// +/// Represents the user decision payload for closing a workflow process. +/// +public sealed record CloseWorkflowDecision +{ + /// + /// Gets the selected closing method identifier. + /// + public required int ClosingMethodId { get; init; } + + /// + /// Gets the optional comment attached to the decision. + /// + public string? Comment { get; init; } + + /// + /// Gets the optional rejection reason identifier. + /// + public int? RejectionReasonId { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowResult.cs b/src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowResult.cs new file mode 100644 index 0000000..7ee69b3 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Closing/CloseWorkflowResult.cs @@ -0,0 +1,17 @@ +namespace DigitalData.TaskFlow.Domain.Closing; + +/// +/// Represents the result of a workflow closing operation. +/// +public sealed record CloseWorkflowResult +{ + /// + /// Gets the process identifier. + /// + public required int ProcessId { get; init; } + + /// + /// Gets a value indicating whether the process was closed successfully. + /// + public required bool IsClosed { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Common/ApiEnvelope.cs b/src/core/DigitalData.TaskFlow.Domain/Common/ApiEnvelope.cs new file mode 100644 index 0000000..b96ab0e --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Common/ApiEnvelope.cs @@ -0,0 +1,18 @@ +namespace DigitalData.TaskFlow.Domain.Common; + +/// +/// Represents the standard API envelope that contains meta information and payload data. +/// +/// Type of the payload in the response. +public sealed record ApiEnvelope +{ + /// + /// Gets the list of metadata entries describing the business result. + /// + public required IReadOnlyList Meta { get; init; } + + /// + /// Gets the payload data returned by the endpoint. + /// + public T? Data { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Common/MetaEntry.cs b/src/core/DigitalData.TaskFlow.Domain/Common/MetaEntry.cs new file mode 100644 index 0000000..6d99b83 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Common/MetaEntry.cs @@ -0,0 +1,17 @@ +namespace DigitalData.TaskFlow.Domain.Common; + +/// +/// Represents a single metadata item describing the business result state of an API response. +/// +public sealed record MetaEntry +{ + /// + /// Gets the domain-specific result code. + /// + public required int Code { get; init; } + + /// + /// Gets the human-readable message that belongs to . + /// + public required string Message { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Documents/DocumentBinaryResult.cs b/src/core/DigitalData.TaskFlow.Domain/Documents/DocumentBinaryResult.cs new file mode 100644 index 0000000..2f072fa --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Documents/DocumentBinaryResult.cs @@ -0,0 +1,27 @@ +namespace DigitalData.TaskFlow.Domain.Documents; + +/// +/// Represents binary document content returned by the document endpoint. +/// +public sealed record DocumentBinaryResult +{ + /// + /// Gets the raw binary content. + /// + public required byte[] Content { get; init; } + + /// + /// Gets the MIME content type. + /// + public required string ContentType { get; init; } + + /// + /// Gets the file name used for download. + /// + public required string FileName { get; init; } + + /// + /// Gets the content length in bytes. + /// + public required long Length { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Enums/MetaCode.cs b/src/core/DigitalData.TaskFlow.Domain/Enums/MetaCode.cs new file mode 100644 index 0000000..168fc00 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Enums/MetaCode.cs @@ -0,0 +1,42 @@ +namespace DigitalData.TaskFlow.Domain.Enums; + +/// +/// Defines domain-level result codes used in API meta responses. +/// +public enum MetaCode +{ + /// + /// Operation completed successfully. + /// + Ok = 0, + + /// + /// Request is valid but no open workflows are available. + /// + NoOpenWorkflows = 1, + + /// + /// Caller has no access to the requested resource. + /// + NoAccess = 2, + + /// + /// Request is invalid or authentication failed according to endpoint rules. + /// + InvalidRequest = 4, + + /// + /// Internal server error occurred. + /// + InternalError = 5, + + /// + /// Requested resource was not found. + /// + NotFound = 6, + + /// + /// Target workflow was already closed. + /// + AlreadyClosed = 7 +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/ApprovalItem.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/ApprovalItem.cs new file mode 100644 index 0000000..177368f --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/ApprovalItem.cs @@ -0,0 +1,32 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents a completed approval action for a workflow process. +/// +public sealed record ApprovalItem +{ + /// + /// Gets the process identifier. + /// + public required int ProcessId { get; init; } + + /// + /// Gets the approval sequence index. + /// + public required int Sequence { get; init; } + + /// + /// Gets the user name or identifier of the approver. + /// + public required string ApprovedBy { get; init; } + + /// + /// Gets the UTC timestamp when approval was recorded. + /// + public required DateTime ApprovedAtUtc { get; init; } + + /// + /// Gets the optional approval comment. + /// + public string? Comment { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/ClosingMethodItem.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/ClosingMethodItem.cs new file mode 100644 index 0000000..223f734 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/ClosingMethodItem.cs @@ -0,0 +1,27 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents a workflow closing option available for user decision. +/// +public sealed record ClosingMethodItem +{ + /// + /// Gets the closing method identifier. + /// + public required int ClosingMethodId { get; init; } + + /// + /// Gets the display name of the method. + /// + public required string Name { get; init; } + + /// + /// Gets a value indicating whether a comment is mandatory for this method. + /// + public required bool CommentRequired { get; init; } + + /// + /// Gets a value indicating whether this method represents a rejection. + /// + public required bool IsRejection { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/ContractsSourceBlock.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/ContractsSourceBlock.cs new file mode 100644 index 0000000..54c2cd9 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/ContractsSourceBlock.cs @@ -0,0 +1,37 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents workflow data for the Contracts source system. +/// +public sealed record ContractsSourceBlock : SourceBlock +{ + /// + /// Gets available approval profiles. + /// + public required IReadOnlyList Profiles { get; init; } + + /// + /// Gets workflow listing items. + /// + public required IReadOnlyList Listing { get; init; } + + /// + /// Gets already executed approvals. + /// + public required IReadOnlyList Approvals { get; init; } + + /// + /// Gets document references for workflows. + /// + public required IReadOnlyList Documents { get; init; } + + /// + /// Gets available closing methods for workflows. + /// + public required IReadOnlyList ClosingMethods { get; init; } + + /// + /// Gets available rejection reasons for rejection-type methods. + /// + public required IReadOnlyList RejectionReasons { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/DocumentReferenceItem.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/DocumentReferenceItem.cs new file mode 100644 index 0000000..c90f399 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/DocumentReferenceItem.cs @@ -0,0 +1,27 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents a lightweight document reference linked to a workflow process. +/// +public sealed record DocumentReferenceItem +{ + /// + /// Gets the document identifier used for binary retrieval. + /// + public required string Id { get; init; } + + /// + /// Gets the process identifier. + /// + public required int ProcessId { get; init; } + + /// + /// Gets the document title. + /// + public required string Title { get; init; } + + /// + /// Gets the document subtitle. + /// + public required string Subtitle { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/FerdinandSourceBlock.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/FerdinandSourceBlock.cs new file mode 100644 index 0000000..9872378 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/FerdinandSourceBlock.cs @@ -0,0 +1,37 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents workflow data for the Ferdinand source system. +/// +public sealed record FerdinandSourceBlock : SourceBlock +{ + /// + /// Gets available approval profiles. + /// + public required IReadOnlyList Profiles { get; init; } + + /// + /// Gets workflow listing items. + /// + public required IReadOnlyList Listing { get; init; } + + /// + /// Gets already executed approvals. + /// + public required IReadOnlyList Approvals { get; init; } + + /// + /// Gets document references for workflows. + /// + public required IReadOnlyList Documents { get; init; } + + /// + /// Gets available closing methods for workflows. + /// + public required IReadOnlyList ClosingMethods { get; init; } + + /// + /// Gets available rejection reasons for rejection-type methods. + /// + public required IReadOnlyList RejectionReasons { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/ProfileItem.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/ProfileItem.cs new file mode 100644 index 0000000..a71a46d --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/ProfileItem.cs @@ -0,0 +1,22 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents an approval profile for workflow processing. +/// +public sealed record ProfileItem +{ + /// + /// Gets the profile identifier. + /// + public required int ProfileId { get; init; } + + /// + /// Gets the display title of the profile. + /// + public required string Title { get; init; } + + /// + /// Gets the optional priority value. + /// + public int? Priority { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/RejectionReasonItem.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/RejectionReasonItem.cs new file mode 100644 index 0000000..fddaccb --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/RejectionReasonItem.cs @@ -0,0 +1,17 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents a rejection reason that can be selected for rejection methods. +/// +public sealed record RejectionReasonItem +{ + /// + /// Gets the rejection reason identifier. + /// + public required int RejectionReasonId { get; init; } + + /// + /// Gets the display name of the rejection reason. + /// + public required string Name { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/SourceBlock.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/SourceBlock.cs new file mode 100644 index 0000000..8808ae2 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/SourceBlock.cs @@ -0,0 +1,12 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Base type for source-specific workflow blocks. +/// +public abstract record SourceBlock +{ + /// + /// Gets the source system name. + /// + public required string Source { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowListingItem.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowListingItem.cs new file mode 100644 index 0000000..77feff1 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowListingItem.cs @@ -0,0 +1,87 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents a single workflow listing row. +/// +public sealed record WorkflowListingItem +{ + /// + /// Gets the process identifier. + /// + public required int ProcessId { get; init; } + + /// + /// Gets the profile identifier associated with the process. + /// + public required int ProfileId { get; init; } + + /// + /// Gets the voucher type. + /// + public required string VoucherType { get; init; } + + /// + /// Gets the voucher number. + /// + public required string VoucherNumber { get; init; } + + /// + /// Gets the voucher date. + /// + public required DateOnly VoucherDate { get; init; } + + /// + /// Gets the cost center number. + /// + public required string CostCenter { get; init; } + + /// + /// Gets the cost center description. + /// + public required string CostCenterDescription { get; init; } + + /// + /// Gets the client number. + /// + public required int ClientNumber { get; init; } + + /// + /// Gets the client name. + /// + public required string ClientName { get; init; } + + /// + /// Gets the supplier number. + /// + public required string SupplierNumber { get; init; } + + /// + /// Gets the supplier name. + /// + public required string SupplierName { get; init; } + + /// + /// Gets the net amount. + /// + public required decimal NetAmount { get; init; } + + /// + /// Gets the gross amount. + /// + public required decimal GrossAmount { get; init; } + + /// + /// Gets the discount amount. + /// + public required decimal DiscountAmount { get; init; } + + /// + /// Gets the currency. + /// + public required string Currency { get; init; } + + /// + /// Gets the priority value. + /// + public required int Priority { get; init; } +} diff --git a/src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowSourcesResponse.cs b/src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowSourcesResponse.cs new file mode 100644 index 0000000..ff36086 --- /dev/null +++ b/src/core/DigitalData.TaskFlow.Domain/Workflows/WorkflowSourcesResponse.cs @@ -0,0 +1,12 @@ +namespace DigitalData.TaskFlow.Domain.Workflows; + +/// +/// Represents the workflow payload grouped by source systems. +/// +public sealed record WorkflowSourcesResponse +{ + /// + /// Gets the source blocks included in the response. + /// + public required IReadOnlyList Sources { get; init; } +}