-
Notifications
You must be signed in to change notification settings - Fork 12
feat(mediator): add persisted sample auditing #790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a7b8eca
feat(mediator): persist sample audit records
Copilot 508a232
docs(mediator): complete persisted auditing task
Copilot cc63ea1
fix(mediator): document audit store parameters
Copilot a20ba2d
feat(mediator): generalize audit records
Copilot 0c3964f
refactor(mediator): order audit fields
Copilot 9eec8b5
feat(mediator): extend persisted audit queries
Copilot 4928f38
fix(mediator): validate audit query inputs
Copilot a6685e1
fix(mediator): bind NodaTime audit filters
Copilot c470ec2
fix(nodatime): add correctly named converter registration
Copilot 5c4ee16
fix(mediator): use bindable audit query
Copilot 820fff7
fix(mediator): generalize minimal api bindings
Copilot 6264a84
fix(mediator): decouple query binding
Copilot 8dd1b7d
fix(mediator): bind audit query filters
Copilot 6c59723
docs(mediator): clarify audit parsing
Copilot 7efb2c6
fix(mediator): bind TypeConverter query values
Copilot a4a944d
fix(mediator): report invalid converter values
Copilot 304258f
fix(mediator): remove converter binding shim
Copilot 578b0d9
chore(mediator-sample): move Database project in the right place
AndreaCuneo 823e9ef
feat(mediator-framework): add tasks for automatic proto export and ex…
AndreaCuneo 8a1981d
feat(mediator): implement ArkTypeConverterValue for route and query p…
AndreaCuneo 82ec727
fix(protobuf): update AdditionalImportDirs path format for consistency
AndreaCuneo 1e72965
Apply suggestions from code review
AndreaCuneo 8bb84ef
refactor(mediator): remove TypeConverter binding support from Minimal…
Copilot 6178326
feat(generator): enhance MinimalApi generator to wrap type converter …
AndreaCuneo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
samples/Ark.MediatorFramework.Sample/Database/dbo/Tables/Audit.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| CREATE TABLE [dbo].[Audit] | ||
| ( | ||
| [Id] UNIQUEIDENTIFIER NOT NULL, | ||
| [UserId] NVARCHAR(255) NOT NULL, | ||
| [Contract] NVARCHAR(255) NOT NULL, | ||
| [Timestamp] DATETIME2(7) NOT NULL, | ||
| CONSTRAINT [PK_Audit] PRIMARY KEY CLUSTERED ([Id]) | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...k.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.Application/AuditContracts.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright (C) 2024 Ark Energy S.r.l. All rights reserved. | ||
| // Licensed under the MIT License. See LICENSE file for license information. | ||
|
|
||
| using Ark.Tools.Core; | ||
| using Ark.Tools.Solid; | ||
|
|
||
| using NodaTime; | ||
|
|
||
| using ProtoBuf; | ||
|
|
||
| namespace Ark.MediatorFramework.Sample.Application; | ||
|
|
||
| /// <summary>Describes a mutation to be persisted in the audit trail.</summary> | ||
| public sealed record AuditEntry | ||
| { | ||
| /// <summary>Gets the authenticated user identifier.</summary> | ||
| public string UserId { get; init; } = "anonymous"; | ||
|
|
||
| /// <summary>Gets the name of the mutated contract.</summary> | ||
| public required string Contract { get; init; } | ||
|
|
||
| /// <summary>Gets the mutation timestamp.</summary> | ||
| public required Instant Timestamp { get; init; } | ||
| } | ||
|
|
||
| /// <summary>Persisted audit record returned by the audit query.</summary> | ||
| [ProtoContract] | ||
| public sealed record AuditRecord | ||
| { | ||
| /// <summary>Gets the audit identifier.</summary> | ||
| [ProtoMember(1)] | ||
| public required Guid Id { get; init; } | ||
|
|
||
| /// <summary>Gets the authenticated user identifier.</summary> | ||
| [ProtoMember(2)] | ||
| public string UserId { get; init; } = "anonymous"; | ||
|
|
||
| /// <summary>Gets the mutated contract name.</summary> | ||
| [ProtoMember(3)] | ||
| public required string Contract { get; init; } | ||
|
|
||
| /// <summary>Gets the mutation timestamp.</summary> | ||
| [ProtoMember(4)] | ||
| public required Instant Timestamp { get; init; } | ||
| } | ||
|
|
||
| /// <summary>Queries the persisted audit trail.</summary> | ||
| [HttpEndpoint("GET", "/api/v{version}/audits")] | ||
| public sealed record GetAuditsQuery : IQuery<PagedResult<AuditRecord>>, IQueryPaged | ||
|
AndreaCuneo marked this conversation as resolved.
|
||
| { | ||
| /// <inheritdoc /> | ||
| public int Skip { get; set; } | ||
|
|
||
| /// <inheritdoc /> | ||
| public int Limit { get; init; } = 25; | ||
|
|
||
| /// <inheritdoc /> | ||
| public IEnumerable<string> Sort { get; init; } = []; | ||
| } | ||
17 changes: 17 additions & 0 deletions
17
....MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.Application/AuditValidators.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright (C) 2024 Ark Energy S.r.l. All rights reserved. | ||
| // Licensed under the MIT License. See LICENSE file for license information. | ||
|
|
||
| using FluentValidation; | ||
|
|
||
| namespace Ark.MediatorFramework.Sample.Application; | ||
|
|
||
| /// <summary>Validates audit query paging parameters.</summary> | ||
| public sealed class GetAuditsValidator : AbstractValidator<GetAuditsQuery> | ||
| { | ||
| /// <summary>Initializes a new instance of the <see cref="GetAuditsValidator"/> class.</summary> | ||
| public GetAuditsValidator() | ||
| { | ||
| RuleFor(query => query.Skip).GreaterThanOrEqualTo(0); | ||
| RuleFor(query => query.Limit).InclusiveBetween(1, 100); | ||
| } | ||
| } | ||
|
AndreaCuneo marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.