From dd1b19356ee60918178845d517166a945b2d5e15 Mon Sep 17 00:00:00 2001 From: Tomohisa Takaoka Date: Mon, 30 Dec 2024 17:29:29 -0800 Subject: [PATCH 1/3] Working on the file and namespaces --- internalUsages/Pure.Domain/Branch.cs | 4 + internalUsages/Pure.Domain/BranchCreated.cs | 4 + .../Pure.Domain/BranchNameChanged.cs | 4 + internalUsages/Pure.Domain/BranchProjector.cs | 15 + .../Pure.Domain/BuyingShoppingCart.cs | 4 + .../Pure.Domain/ChangeBranchName.cs | 14 + internalUsages/Pure.Domain/Class1.cs | 264 ------- internalUsages/Pure.Domain/ConfirmUser.cs | 12 + internalUsages/Pure.Domain/ConfirmedUser.cs | 4 + .../Pure.Domain/CreateShoppingCart.cs | 15 + .../PaymentProcessedShoppingCart.cs | 4 + .../PaymentProcessingShoppingCart.cs | 8 + internalUsages/Pure.Domain/RegisterBranch.cs | 12 + internalUsages/Pure.Domain/RegisterBranch2.cs | 4 + internalUsages/Pure.Domain/RegisterBranch3.cs | 7 + internalUsages/Pure.Domain/RegisterUser.cs | 24 + internalUsages/Pure.Domain/RevokeUser.cs | 24 + .../Pure.Domain/ShoppingCartCreated.cs | 4 + .../Pure.Domain/ShoppingCartItemAdded.cs | 4 + .../Pure.Domain/ShoppingCartItems.cs | 3 + .../Pure.Domain/ShoppingCartProjector.cs | 24 + internalUsages/Pure.Domain/UnconfirmedUser.cs | 121 +++ internalUsages/Pure.Domain/UserConfirmed.cs | 4 + internalUsages/Pure.Domain/UserProjector.cs | 32 + internalUsages/Pure.Domain/UserRegistered.cs | 4 + internalUsages/Pure.Domain/UserUnconfirmed.cs | 4 + .../Pools/BetweenSortableIdCondition.cs | 8 + .../Pools/SinceSortableIdCondition.cs | 5 - .../CommandExecutionExtensionGenerator.cs | 20 +- .../EventTypesGenerator.cs | 3 +- src/Sekiban.Pure/Aggregates/Aggregate.cs | 39 + .../Aggregates/EmptyAggregatePayload.cs | 6 + src/Sekiban.Pure/Aggregates/IAggregate.cs | 13 + .../Aggregates/IAggregatePayload.cs | 3 + src/Sekiban.Pure/Class1.cs | 699 ------------------ .../Command/Executor/CommandContext.cs | 37 + .../Executor/CommandContextWithoutState.cs | 27 + .../Command/Executor/CommandExecuted.cs | 4 + .../Command/Executor/CommandExecutor.cs | 174 +++++ .../Command/Executor/CommandResponse.cs | 4 + .../Command/Executor/ICommandContext.cs | 15 + .../Command/Executor/ICommandExecutor.cs | 3 + src/Sekiban.Pure/Command/Handlers/ICommand.cs | 3 + .../Handlers/ICommandContextWithoutState.cs | 13 + .../Command/Handlers/ICommandGetProjector.cs | 7 + .../Command/Handlers/ICommandHandler.cs | 22 + .../Command/Handlers/ICommandHandlerAsync.cs | 10 + .../Command/Handlers/ICommandHandlerCommon.cs | 7 + .../Handlers/ICommandHandlerInjection.cs | 13 + .../Handlers/ICommandHandlerInjectionAsync.cs | 25 + .../Handlers/ICommandPartitionSpecifier.cs | 6 + .../ICommandWithAggregateRestriction.cs | 4 + .../Command/Handlers/ICommandWithHandler.cs | 12 + .../Handlers/ICommandWithHandlerAsync.cs | 23 + .../Handlers/ICommandWithHandlerCommon.cs | 7 + .../Handlers/ICommandWithHandlerInjection.cs | 23 + .../ICommandWithHandlerInjectionAsync.cs | 13 + .../Command/Handlers/NoInjection.cs | 6 + .../Command/Resources/CommandResource.cs | 33 + .../Resources/CommandResourcePublishOnly.cs | 18 + .../CommandResourcePublishOnlyTask.cs | 17 + .../CommandResourcePublishOnlyWithInject.cs | 19 + ...ommandResourcePublishOnlyWithInjectTask.cs | 18 + .../Command/Resources/CommandResourceTask.cs | 32 + .../Resources/CommandResourceWithInject.cs | 34 + .../CommandResourceWithInjectTask.cs | 34 + .../Command/Resources/ICommandResource.cs | 13 + src/Sekiban.Pure/Documents/PartitionKeys.cs | 31 + .../Documents/TenantPartitionKeys.cs | 11 + src/Sekiban.Pure/Events/EmptyEventTypes.cs | 12 + src/Sekiban.Pure/Events/Event.cs | 10 + src/Sekiban.Pure/Events/EventOrNone.cs | 2 +- src/Sekiban.Pure/Events/IEvent.cs | 11 + src/Sekiban.Pure/Events/IEventPayload.cs | 3 + src/Sekiban.Pure/Events/IEventTypes.cs | 11 + .../SekibanAggregateTypeException.cs | 4 - ...ekibanAggregateTypeRestrictionException.cs | 5 + .../SekibanCommandHandlerNotMatchException.cs | 4 + .../SekibanEventTypeNotFoundException.cs | 4 + src/Sekiban.Pure/Extensions/GuidExtensions.cs | 13 + .../Projectors/IAggregateProjector.cs | 8 + .../Projectors/NoneAggregateProjector.cs | 8 + src/Sekiban.Pure/Repositories/Repository.cs | 20 + src/Sekiban.Web/Common/RuntimeChecker.cs | 10 + .../SekibanControllerFeatureProvider.cs | 143 ++-- ....cs => SerializationModeOptionsContext.cs} | 11 - .../Definitions/WeatherForecast.cs | 8 + tests/Pure.Domain.Test/UnitTest1.cs | 4 + 88 files changed, 1389 insertions(+), 1039 deletions(-) create mode 100644 internalUsages/Pure.Domain/Branch.cs create mode 100644 internalUsages/Pure.Domain/BranchCreated.cs create mode 100644 internalUsages/Pure.Domain/BranchNameChanged.cs create mode 100644 internalUsages/Pure.Domain/BranchProjector.cs create mode 100644 internalUsages/Pure.Domain/BuyingShoppingCart.cs create mode 100644 internalUsages/Pure.Domain/ChangeBranchName.cs delete mode 100644 internalUsages/Pure.Domain/Class1.cs create mode 100644 internalUsages/Pure.Domain/ConfirmUser.cs create mode 100644 internalUsages/Pure.Domain/ConfirmedUser.cs create mode 100644 internalUsages/Pure.Domain/CreateShoppingCart.cs create mode 100644 internalUsages/Pure.Domain/PaymentProcessedShoppingCart.cs create mode 100644 internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs create mode 100644 internalUsages/Pure.Domain/RegisterBranch.cs create mode 100644 internalUsages/Pure.Domain/RegisterBranch2.cs create mode 100644 internalUsages/Pure.Domain/RegisterBranch3.cs create mode 100644 internalUsages/Pure.Domain/RegisterUser.cs create mode 100644 internalUsages/Pure.Domain/RevokeUser.cs create mode 100644 internalUsages/Pure.Domain/ShoppingCartCreated.cs create mode 100644 internalUsages/Pure.Domain/ShoppingCartItemAdded.cs create mode 100644 internalUsages/Pure.Domain/ShoppingCartItems.cs create mode 100644 internalUsages/Pure.Domain/ShoppingCartProjector.cs create mode 100644 internalUsages/Pure.Domain/UnconfirmedUser.cs create mode 100644 internalUsages/Pure.Domain/UserConfirmed.cs create mode 100644 internalUsages/Pure.Domain/UserProjector.cs create mode 100644 internalUsages/Pure.Domain/UserRegistered.cs create mode 100644 internalUsages/Pure.Domain/UserUnconfirmed.cs create mode 100644 src/Sekiban.Core.DotNet/Documents/Pools/BetweenSortableIdCondition.cs create mode 100644 src/Sekiban.Pure/Aggregates/Aggregate.cs create mode 100644 src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs create mode 100644 src/Sekiban.Pure/Aggregates/IAggregate.cs create mode 100644 src/Sekiban.Pure/Aggregates/IAggregatePayload.cs delete mode 100644 src/Sekiban.Pure/Class1.cs create mode 100644 src/Sekiban.Pure/Command/Executor/CommandContext.cs create mode 100644 src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs create mode 100644 src/Sekiban.Pure/Command/Executor/CommandExecuted.cs create mode 100644 src/Sekiban.Pure/Command/Executor/CommandExecutor.cs create mode 100644 src/Sekiban.Pure/Command/Executor/CommandResponse.cs create mode 100644 src/Sekiban.Pure/Command/Executor/ICommandContext.cs create mode 100644 src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommand.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandGetProjector.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs create mode 100644 src/Sekiban.Pure/Command/Handlers/NoInjection.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResource.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs create mode 100644 src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs create mode 100644 src/Sekiban.Pure/Command/Resources/ICommandResource.cs create mode 100644 src/Sekiban.Pure/Documents/PartitionKeys.cs create mode 100644 src/Sekiban.Pure/Documents/TenantPartitionKeys.cs create mode 100644 src/Sekiban.Pure/Events/EmptyEventTypes.cs create mode 100644 src/Sekiban.Pure/Events/Event.cs create mode 100644 src/Sekiban.Pure/Events/IEvent.cs create mode 100644 src/Sekiban.Pure/Events/IEventPayload.cs create mode 100644 src/Sekiban.Pure/Events/IEventTypes.cs create mode 100644 src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs create mode 100644 src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs create mode 100644 src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs create mode 100644 src/Sekiban.Pure/Extensions/GuidExtensions.cs create mode 100644 src/Sekiban.Pure/Projectors/IAggregateProjector.cs create mode 100644 src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs create mode 100644 src/Sekiban.Pure/Repositories/Repository.cs create mode 100644 src/Sekiban.Web/Common/RuntimeChecker.cs rename tests/AotTechnicalTesting/Definitions/{def.cs => SerializationModeOptionsContext.cs} (69%) create mode 100644 tests/AotTechnicalTesting/Definitions/WeatherForecast.cs diff --git a/internalUsages/Pure.Domain/Branch.cs b/internalUsages/Pure.Domain/Branch.cs new file mode 100644 index 00000000..6905dee2 --- /dev/null +++ b/internalUsages/Pure.Domain/Branch.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure; +namespace Pure.Domain; + +public record Branch(string Name) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/BranchCreated.cs b/internalUsages/Pure.Domain/BranchCreated.cs new file mode 100644 index 00000000..d47e9a75 --- /dev/null +++ b/internalUsages/Pure.Domain/BranchCreated.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record BranchCreated(string Name) : IEventPayload; diff --git a/internalUsages/Pure.Domain/BranchNameChanged.cs b/internalUsages/Pure.Domain/BranchNameChanged.cs new file mode 100644 index 00000000..5192381d --- /dev/null +++ b/internalUsages/Pure.Domain/BranchNameChanged.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record BranchNameChanged(string Name) : IEventPayload; diff --git a/internalUsages/Pure.Domain/BranchProjector.cs b/internalUsages/Pure.Domain/BranchProjector.cs new file mode 100644 index 00000000..12d9dbe4 --- /dev/null +++ b/internalUsages/Pure.Domain/BranchProjector.cs @@ -0,0 +1,15 @@ +using Sekiban.Pure; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Pure.Domain; + +public class BranchProjector : IAggregateProjector +{ + public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => + (payload, ev.GetPayload()) switch + { + (EmptyAggregatePayload, BranchCreated created) => new Branch(created.Name), + (Branch branch, BranchNameChanged changed) => new Branch(changed.Name), + _ => payload + }; +} diff --git a/internalUsages/Pure.Domain/BuyingShoppingCart.cs b/internalUsages/Pure.Domain/BuyingShoppingCart.cs new file mode 100644 index 00000000..4f7a9c21 --- /dev/null +++ b/internalUsages/Pure.Domain/BuyingShoppingCart.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure; +namespace Pure.Domain; + +public record BuyingShoppingCart(Guid UserId, List Items) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/ChangeBranchName.cs b/internalUsages/Pure.Domain/ChangeBranchName.cs new file mode 100644 index 00000000..f48b618e --- /dev/null +++ b/internalUsages/Pure.Domain/ChangeBranchName.cs @@ -0,0 +1,14 @@ +using ResultBoxes; +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record ChangeBranchName(Guid BranchId, string NameToChange) + : ICommandWithHandler +{ + public ResultBox Handle(ChangeBranchName command, ICommandContext context) => + context.AppendEvent(new BranchNameChanged(command.NameToChange)); + public PartitionKeys SpecifyPartitionKeys(ChangeBranchName command) => + PartitionKeys.Existing(BranchId); +} diff --git a/internalUsages/Pure.Domain/Class1.cs b/internalUsages/Pure.Domain/Class1.cs deleted file mode 100644 index 3ed5fe83..00000000 --- a/internalUsages/Pure.Domain/Class1.cs +++ /dev/null @@ -1,264 +0,0 @@ -using ResultBoxes; -using Sekiban.Pure; -namespace Pure.Domain; - -public record UnconfirmedUser(string Name, string Email) : IAggregatePayload; -public record ConfirmedUser(string Name, string Email) : IAggregatePayload; -public record UserRegistered(string Name, string Email) : IEventPayload; -public record UserConfirmed : IEventPayload; -public record UserUnconfirmed : IEventPayload; -public class UserProjector : IAggregateProjector -{ - public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => (payload, ev.GetPayload()) switch - { - (EmptyAggregatePayload, UserRegistered registered) => new UnconfirmedUser(registered.Name, registered.Email), - (UnconfirmedUser unconfirmedUser, UserConfirmed) => new ConfirmedUser( - unconfirmedUser.Name, - unconfirmedUser.Email), - (ConfirmedUser confirmedUser, UserUnconfirmed) => new UnconfirmedUser(confirmedUser.Name, confirmedUser.Email), - _ => payload - }; - public string GetVersion() => "1.0.1"; - // public static Func Projector() => - // (payload, ev) => (payload, ev.GetPayload()) switch - // { - // (EmptyAggregatePayload, UserRegistered registered) => new UnconfirmedUser( - // registered.Name, - // registered.Email), - // (UnconfirmedUser unconfirmedUser, UserConfirmed) => new ConfirmedUser( - // unconfirmedUser.Name, - // unconfirmedUser.Email), - // (ConfirmedUser confirmedUser, UserUnconfirmed) => new UnconfirmedUser( - // confirmedUser.Name, - // confirmedUser.Email), - // _ => payload - // }; -} -public record Branch(string Name) : IAggregatePayload; -public record BranchCreated(string Name) : IEventPayload; -public record BranchNameChanged(string Name) : IEventPayload; -public class BranchProjector : IAggregateProjector -{ - public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => - (payload, ev.GetPayload()) switch - { - (EmptyAggregatePayload, BranchCreated created) => new Branch(created.Name), - (Branch branch, BranchNameChanged changed) => new Branch(changed.Name), - _ => payload - }; -} -public record RegisterBranch(string Name) : ICommandWithHandler -{ - public PartitionKeys SpecifyPartitionKeys(RegisterBranch command) => PartitionKeys.Generate(); - public ResultBox Handle(RegisterBranch command, ICommandContext context) => - EventOrNone.Event(new BranchCreated(command.Name)); -} -public record ChangeBranchName(Guid BranchId, string NameToChange) - : ICommandWithHandler -{ - public ResultBox Handle(ChangeBranchName command, ICommandContext context) => - context.AppendEvent(new BranchNameChanged(command.NameToChange)); - public PartitionKeys SpecifyPartitionKeys(ChangeBranchName command) => - PartitionKeys.Existing(BranchId); -} -public record RegisterBranch2(string Name) : ICommand; -public record RegisterBranch3(string Name) : ICommandWithAggregateRestriction -{ -} -public record RegisterUser(string Name, string Email) - : ICommandWithHandlerInjection -{ - public PartitionKeys SpecifyPartitionKeys(RegisterUser command) => PartitionKeys.Generate(); - public ResultBox Handle( - RegisterUser command, - Injection injection, - ICommandContext context) => - ResultBox - .Start - .Conveyor(m => injection.EmailExists(command.Email).ToResultBox()) - .Verify( - exists => exists - ? ExceptionOrNone.FromException(new ApplicationException("Email already exists")) - : ExceptionOrNone.None) - .Conveyor(_ => EventOrNone.Event(new UserRegistered(command.Name, command.Email))); - public record Injection(Func EmailExists); -} -public record ConfirmUser(Guid UserId) : ICommandWithHandler -{ - public ResultBox Handle(ConfirmUser command, ICommandContext context) => - EventOrNone.Event(new UserConfirmed()); - public PartitionKeys SpecifyPartitionKeys(ConfirmUser command) => PartitionKeys.Existing(UserId); -} -public record RevokeUser(Guid UserId) - : ICommandWithHandlerInjection -{ - public PartitionKeys SpecifyPartitionKeys(RevokeUser command) => PartitionKeys.Existing(UserId); - public ResultBox Handle( - RevokeUser command, - Injection injection, - ICommandContext context) => - context - .GetAggregate() - .Conveyor(aggregate => injection.UserExists(aggregate.PartitionKeys.AggregateId).ToResultBox()) - .Verify( - exists => exists - ? ExceptionOrNone.None - : ExceptionOrNone.FromException(new ApplicationException("user already exists"))) - .Conveyor(_ => EventOrNone.Event(new UserUnconfirmed())); - public record Injection(Func UserExists); -} -// public class Test -// { -// public void Test1() -// { -// var commandExecutor = new CommandExecutor(); -// commandExecutor.Execute(new RegisterBranch("name")); -// commandExecutor.Execute( -// new RegisterUser("tomo", "tomo@example.com"), -// new RegisterUser.Injection(email => false)); -// commandExecutor.Execute(new ConfirmUser(GuidExtensions.CreateVersion7())); -// } -// } -public class ShoppingCartProjector : IAggregateProjector -{ - public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => - (payload, ev.GetPayload()) switch - { - (EmptyAggregatePayload, ShoppingCartCreated created) => new BuyingShoppingCart( - created.UserId, - new List()), - (BuyingShoppingCart buyingShoppingCart, ShoppingCartItemAdded added) => new BuyingShoppingCart( - buyingShoppingCart.UserId, - buyingShoppingCart - .Items - .Append(new ShoppingCartItems(added.Name, added.Quantity, Guid.NewGuid(), 100)) - .ToList()), - (BuyingShoppingCart buyingShoppingCart, PaymentProcessedShoppingCart processed) => - new EmptyAggregatePayload(), - _ => payload - }; -} -public record ShoppingCartItems(string Name, int Quantity, Guid ItemId, int Price); -public record BuyingShoppingCart(Guid UserId, List Items) : IAggregatePayload; -public record ShoppingCartCreated(Guid UserId) : IEventPayload; -public record ShoppingCartItemAdded(string Name, int Quantity) : IEventPayload; -public record PaymentProcessingShoppingCart( - Guid UserId, - List Items, - int TotalPrice, - string PaymentMethod) : IAggregatePayload; -public record PaymentProcessedShoppingCart(string PaymentMethod) : IEventPayload; -public record CreateShoppingCart(Guid UserId) : ICommandWithHandlerAsync -{ - public PartitionKeys SpecifyPartitionKeys(CreateShoppingCart command) => - PartitionKeys.Generate(); - public Task> HandleAsync( - CreateShoppingCart command, - ICommandContext context) => - EventOrNone.Event(new ShoppingCartCreated(command.UserId)).ToTask(); -} - -// public static class Extensions -// { -// public static Task> ExecuteFunction( -// this CommandExecutor executor, -// ConfirmUser command, -// IAggregateProjector projector, -// Func specifyPartitionKeys, -// Func, ResultBox> handler) => -// executor.ExecuteFunction( -// command, -// (command as ICommandGetProjector).GetProjector(), -// command.SpecifyPartitionKeys, -// command.Handle); -// } -// now writing manually, but it will be generated by the source generator -// public class DomainEventTypes : IEventTypes -// { -// public ResultBox GenerateTypedEvent( -// IEventPayload payload, -// PartitionKeys partitionKeys, -// string sortableUniqueId, -// int version) => payload switch -// { -// UserRegistered userRegistered => new Event( -// userRegistered, -// partitionKeys, -// sortableUniqueId, -// version), -// UserConfirmed userConfirmed => new Event( -// userConfirmed, -// partitionKeys, -// sortableUniqueId, -// version), -// UserUnconfirmed userUnconfirmed => new Event( -// userUnconfirmed, -// partitionKeys, -// sortableUniqueId, -// version), -// BranchCreated branchCreated => new Event( -// branchCreated, -// partitionKeys, -// sortableUniqueId, -// version), -// BranchNameChanged branchNameChanged => new Event( -// branchNameChanged, -// partitionKeys, -// sortableUniqueId, -// version), -// _ => ResultBox.FromException( -// new SekibanEventTypeNotFoundException($"Event Type {payload.GetType().Name} Not Found")) -// }; -// } -// public class CpPureDomainEventTypes : IEventTypes -// { -// public ResultBox GenerateTypedEvent( -// IEventPayload payload, -// PartitionKeys partitionKeys, -// string sortableUniqueId, -// int version) => payload switch -// { -// UserRegistered userregistered => new Event( -// userregistered, -// partitionKeys, -// sortableUniqueId, -// version), -// UserConfirmed userconfirmed => new Event( -// userconfirmed, -// partitionKeys, -// sortableUniqueId, -// version), -// UserUnconfirmed userunconfirmed => new Event( -// userunconfirmed, -// partitionKeys, -// sortableUniqueId, -// version), -// BranchCreated branchcreated => new Event( -// branchcreated, -// partitionKeys, -// sortableUniqueId, -// version), -// BranchNameChanged branchnamechanged => new Event( -// branchnamechanged, -// partitionKeys, -// sortableUniqueId, -// version), -// ShoppingCartCreated shoppingcartcreated => new Event( -// shoppingcartcreated, -// partitionKeys, -// sortableUniqueId, -// version), -// ShoppingCartItemAdded shoppingcartitemadded => new Event( -// shoppingcartitemadded, -// partitionKeys, -// sortableUniqueId, -// version), -// PaymentProcessedShoppingCart paymentprocessedshoppingcart => new Event( -// paymentprocessedshoppingcart, -// partitionKeys, -// sortableUniqueId, -// version), -// _ => ResultBox.FromException( -// new SekibanEventTypeNotFoundException($"Event Type {payload.GetType().Name} Not Found")) -// }; -// } diff --git a/internalUsages/Pure.Domain/ConfirmUser.cs b/internalUsages/Pure.Domain/ConfirmUser.cs new file mode 100644 index 00000000..c96600cc --- /dev/null +++ b/internalUsages/Pure.Domain/ConfirmUser.cs @@ -0,0 +1,12 @@ +using ResultBoxes; +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record ConfirmUser(Guid UserId) : ICommandWithHandler +{ + public ResultBox Handle(ConfirmUser command, ICommandContext context) => + EventOrNone.Event(new UserConfirmed()); + public PartitionKeys SpecifyPartitionKeys(ConfirmUser command) => PartitionKeys.Existing(UserId); +} diff --git a/internalUsages/Pure.Domain/ConfirmedUser.cs b/internalUsages/Pure.Domain/ConfirmedUser.cs new file mode 100644 index 00000000..b9630b5a --- /dev/null +++ b/internalUsages/Pure.Domain/ConfirmedUser.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure; +namespace Pure.Domain; + +public record ConfirmedUser(string Name, string Email) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/CreateShoppingCart.cs b/internalUsages/Pure.Domain/CreateShoppingCart.cs new file mode 100644 index 00000000..3022bc5b --- /dev/null +++ b/internalUsages/Pure.Domain/CreateShoppingCart.cs @@ -0,0 +1,15 @@ +using ResultBoxes; +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record CreateShoppingCart(Guid UserId) : ICommandWithHandlerAsync +{ + public PartitionKeys SpecifyPartitionKeys(CreateShoppingCart command) => + PartitionKeys.Generate(); + public Task> HandleAsync( + CreateShoppingCart command, + ICommandContext context) => + EventOrNone.Event(new ShoppingCartCreated(command.UserId)).ToTask(); +} diff --git a/internalUsages/Pure.Domain/PaymentProcessedShoppingCart.cs b/internalUsages/Pure.Domain/PaymentProcessedShoppingCart.cs new file mode 100644 index 00000000..84387fac --- /dev/null +++ b/internalUsages/Pure.Domain/PaymentProcessedShoppingCart.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record PaymentProcessedShoppingCart(string PaymentMethod) : IEventPayload; diff --git a/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs b/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs new file mode 100644 index 00000000..176896d6 --- /dev/null +++ b/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs @@ -0,0 +1,8 @@ +using Sekiban.Pure; +namespace Pure.Domain; + +public record PaymentProcessingShoppingCart( + Guid UserId, + List Items, + int TotalPrice, + string PaymentMethod) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/RegisterBranch.cs b/internalUsages/Pure.Domain/RegisterBranch.cs new file mode 100644 index 00000000..7bacde21 --- /dev/null +++ b/internalUsages/Pure.Domain/RegisterBranch.cs @@ -0,0 +1,12 @@ +using ResultBoxes; +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record RegisterBranch(string Name) : ICommandWithHandler +{ + public PartitionKeys SpecifyPartitionKeys(RegisterBranch command) => PartitionKeys.Generate(); + public ResultBox Handle(RegisterBranch command, ICommandContext context) => + EventOrNone.Event(new BranchCreated(command.Name)); +} diff --git a/internalUsages/Pure.Domain/RegisterBranch2.cs b/internalUsages/Pure.Domain/RegisterBranch2.cs new file mode 100644 index 00000000..0ef7b3dc --- /dev/null +++ b/internalUsages/Pure.Domain/RegisterBranch2.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Command.Handlers; +namespace Pure.Domain; + +public record RegisterBranch2(string Name) : ICommand; diff --git a/internalUsages/Pure.Domain/RegisterBranch3.cs b/internalUsages/Pure.Domain/RegisterBranch3.cs new file mode 100644 index 00000000..fdae07e6 --- /dev/null +++ b/internalUsages/Pure.Domain/RegisterBranch3.cs @@ -0,0 +1,7 @@ +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +namespace Pure.Domain; + +public record RegisterBranch3(string Name) : ICommandWithAggregateRestriction +{ +} diff --git a/internalUsages/Pure.Domain/RegisterUser.cs b/internalUsages/Pure.Domain/RegisterUser.cs new file mode 100644 index 00000000..0e4897c6 --- /dev/null +++ b/internalUsages/Pure.Domain/RegisterUser.cs @@ -0,0 +1,24 @@ +using ResultBoxes; +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record RegisterUser(string Name, string Email) + : ICommandWithHandlerInjection +{ + public PartitionKeys SpecifyPartitionKeys(RegisterUser command) => PartitionKeys.Generate(); + public ResultBox Handle( + RegisterUser command, + Injection injection, + ICommandContext context) => + ResultBox + .Start + .Conveyor(m => injection.EmailExists(command.Email).ToResultBox()) + .Verify( + exists => exists + ? ExceptionOrNone.FromException(new ApplicationException("Email already exists")) + : ExceptionOrNone.None) + .Conveyor(_ => EventOrNone.Event(new UserRegistered(command.Name, command.Email))); + public record Injection(Func EmailExists); +} diff --git a/internalUsages/Pure.Domain/RevokeUser.cs b/internalUsages/Pure.Domain/RevokeUser.cs new file mode 100644 index 00000000..fa829ffa --- /dev/null +++ b/internalUsages/Pure.Domain/RevokeUser.cs @@ -0,0 +1,24 @@ +using ResultBoxes; +using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record RevokeUser(Guid UserId) + : ICommandWithHandlerInjection +{ + public PartitionKeys SpecifyPartitionKeys(RevokeUser command) => PartitionKeys.Existing(UserId); + public ResultBox Handle( + RevokeUser command, + Injection injection, + ICommandContext context) => + context + .GetAggregate() + .Conveyor(aggregate => injection.UserExists(aggregate.PartitionKeys.AggregateId).ToResultBox()) + .Verify( + exists => exists + ? ExceptionOrNone.None + : ExceptionOrNone.FromException(new ApplicationException("user already exists"))) + .Conveyor(_ => EventOrNone.Event(new UserUnconfirmed())); + public record Injection(Func UserExists); +} diff --git a/internalUsages/Pure.Domain/ShoppingCartCreated.cs b/internalUsages/Pure.Domain/ShoppingCartCreated.cs new file mode 100644 index 00000000..39625f25 --- /dev/null +++ b/internalUsages/Pure.Domain/ShoppingCartCreated.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record ShoppingCartCreated(Guid UserId) : IEventPayload; diff --git a/internalUsages/Pure.Domain/ShoppingCartItemAdded.cs b/internalUsages/Pure.Domain/ShoppingCartItemAdded.cs new file mode 100644 index 00000000..542b0730 --- /dev/null +++ b/internalUsages/Pure.Domain/ShoppingCartItemAdded.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record ShoppingCartItemAdded(string Name, int Quantity) : IEventPayload; diff --git a/internalUsages/Pure.Domain/ShoppingCartItems.cs b/internalUsages/Pure.Domain/ShoppingCartItems.cs new file mode 100644 index 00000000..1f5c56c4 --- /dev/null +++ b/internalUsages/Pure.Domain/ShoppingCartItems.cs @@ -0,0 +1,3 @@ +namespace Pure.Domain; + +public record ShoppingCartItems(string Name, int Quantity, Guid ItemId, int Price); diff --git a/internalUsages/Pure.Domain/ShoppingCartProjector.cs b/internalUsages/Pure.Domain/ShoppingCartProjector.cs new file mode 100644 index 00000000..8c7841db --- /dev/null +++ b/internalUsages/Pure.Domain/ShoppingCartProjector.cs @@ -0,0 +1,24 @@ +using Sekiban.Pure; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Pure.Domain; + +public class ShoppingCartProjector : IAggregateProjector +{ + public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => + (payload, ev.GetPayload()) switch + { + (EmptyAggregatePayload, ShoppingCartCreated created) => new BuyingShoppingCart( + created.UserId, + new List()), + (BuyingShoppingCart buyingShoppingCart, ShoppingCartItemAdded added) => new BuyingShoppingCart( + buyingShoppingCart.UserId, + buyingShoppingCart + .Items + .Append(new ShoppingCartItems(added.Name, added.Quantity, Guid.NewGuid(), 100)) + .ToList()), + (BuyingShoppingCart buyingShoppingCart, PaymentProcessedShoppingCart processed) => + new EmptyAggregatePayload(), + _ => payload + }; +} diff --git a/internalUsages/Pure.Domain/UnconfirmedUser.cs b/internalUsages/Pure.Domain/UnconfirmedUser.cs new file mode 100644 index 00000000..b282b179 --- /dev/null +++ b/internalUsages/Pure.Domain/UnconfirmedUser.cs @@ -0,0 +1,121 @@ +using Sekiban.Pure; +namespace Pure.Domain; + +public record UnconfirmedUser(string Name, string Email) : IAggregatePayload; +// public class Test +// { +// public void Test1() +// { +// var commandExecutor = new CommandExecutor(); +// commandExecutor.Execute(new RegisterBranch("name")); +// commandExecutor.Execute( +// new RegisterUser("tomo", "tomo@example.com"), +// new RegisterUser.Injection(email => false)); +// commandExecutor.Execute(new ConfirmUser(GuidExtensions.CreateVersion7())); +// } +// } + +// public static class Extensions +// { +// public static Task> ExecuteFunction( +// this CommandExecutor executor, +// ConfirmUser command, +// IAggregateProjector projector, +// Func specifyPartitionKeys, +// Func, ResultBox> handler) => +// executor.ExecuteFunction( +// command, +// (command as ICommandGetProjector).GetProjector(), +// command.SpecifyPartitionKeys, +// command.Handle); +// } +// now writing manually, but it will be generated by the source generator +// public class DomainEventTypes : IEventTypes +// { +// public ResultBox GenerateTypedEvent( +// IEventPayload payload, +// PartitionKeys partitionKeys, +// string sortableUniqueId, +// int version) => payload switch +// { +// UserRegistered userRegistered => new Event( +// userRegistered, +// partitionKeys, +// sortableUniqueId, +// version), +// UserConfirmed userConfirmed => new Event( +// userConfirmed, +// partitionKeys, +// sortableUniqueId, +// version), +// UserUnconfirmed userUnconfirmed => new Event( +// userUnconfirmed, +// partitionKeys, +// sortableUniqueId, +// version), +// BranchCreated branchCreated => new Event( +// branchCreated, +// partitionKeys, +// sortableUniqueId, +// version), +// BranchNameChanged branchNameChanged => new Event( +// branchNameChanged, +// partitionKeys, +// sortableUniqueId, +// version), +// _ => ResultBox.FromException( +// new SekibanEventTypeNotFoundException($"Event Type {payload.GetType().Name} Not Found")) +// }; +// } +// public class CpPureDomainEventTypes : IEventTypes +// { +// public ResultBox GenerateTypedEvent( +// IEventPayload payload, +// PartitionKeys partitionKeys, +// string sortableUniqueId, +// int version) => payload switch +// { +// UserRegistered userregistered => new Event( +// userregistered, +// partitionKeys, +// sortableUniqueId, +// version), +// UserConfirmed userconfirmed => new Event( +// userconfirmed, +// partitionKeys, +// sortableUniqueId, +// version), +// UserUnconfirmed userunconfirmed => new Event( +// userunconfirmed, +// partitionKeys, +// sortableUniqueId, +// version), +// BranchCreated branchcreated => new Event( +// branchcreated, +// partitionKeys, +// sortableUniqueId, +// version), +// BranchNameChanged branchnamechanged => new Event( +// branchnamechanged, +// partitionKeys, +// sortableUniqueId, +// version), +// ShoppingCartCreated shoppingcartcreated => new Event( +// shoppingcartcreated, +// partitionKeys, +// sortableUniqueId, +// version), +// ShoppingCartItemAdded shoppingcartitemadded => new Event( +// shoppingcartitemadded, +// partitionKeys, +// sortableUniqueId, +// version), +// PaymentProcessedShoppingCart paymentprocessedshoppingcart => new Event( +// paymentprocessedshoppingcart, +// partitionKeys, +// sortableUniqueId, +// version), +// _ => ResultBox.FromException( +// new SekibanEventTypeNotFoundException($"Event Type {payload.GetType().Name} Not Found")) +// }; +// } diff --git a/internalUsages/Pure.Domain/UserConfirmed.cs b/internalUsages/Pure.Domain/UserConfirmed.cs new file mode 100644 index 00000000..81e70da5 --- /dev/null +++ b/internalUsages/Pure.Domain/UserConfirmed.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record UserConfirmed : IEventPayload; diff --git a/internalUsages/Pure.Domain/UserProjector.cs b/internalUsages/Pure.Domain/UserProjector.cs new file mode 100644 index 00000000..a75caf9e --- /dev/null +++ b/internalUsages/Pure.Domain/UserProjector.cs @@ -0,0 +1,32 @@ +using Sekiban.Pure; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Pure.Domain; + +public class UserProjector : IAggregateProjector +{ + public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => (payload, ev.GetPayload()) switch + { + (EmptyAggregatePayload, UserRegistered registered) => new UnconfirmedUser(registered.Name, registered.Email), + (UnconfirmedUser unconfirmedUser, UserConfirmed) => new ConfirmedUser( + unconfirmedUser.Name, + unconfirmedUser.Email), + (ConfirmedUser confirmedUser, UserUnconfirmed) => new UnconfirmedUser(confirmedUser.Name, confirmedUser.Email), + _ => payload + }; + public string GetVersion() => "1.0.1"; + // public static Func Projector() => + // (payload, ev) => (payload, ev.GetPayload()) switch + // { + // (EmptyAggregatePayload, UserRegistered registered) => new UnconfirmedUser( + // registered.Name, + // registered.Email), + // (UnconfirmedUser unconfirmedUser, UserConfirmed) => new ConfirmedUser( + // unconfirmedUser.Name, + // unconfirmedUser.Email), + // (ConfirmedUser confirmedUser, UserUnconfirmed) => new UnconfirmedUser( + // confirmedUser.Name, + // confirmedUser.Email), + // _ => payload + // }; +} diff --git a/internalUsages/Pure.Domain/UserRegistered.cs b/internalUsages/Pure.Domain/UserRegistered.cs new file mode 100644 index 00000000..1cd89148 --- /dev/null +++ b/internalUsages/Pure.Domain/UserRegistered.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record UserRegistered(string Name, string Email) : IEventPayload; diff --git a/internalUsages/Pure.Domain/UserUnconfirmed.cs b/internalUsages/Pure.Domain/UserUnconfirmed.cs new file mode 100644 index 00000000..707b7b6c --- /dev/null +++ b/internalUsages/Pure.Domain/UserUnconfirmed.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Pure.Domain; + +public record UserUnconfirmed : IEventPayload; diff --git a/src/Sekiban.Core.DotNet/Documents/Pools/BetweenSortableIdCondition.cs b/src/Sekiban.Core.DotNet/Documents/Pools/BetweenSortableIdCondition.cs new file mode 100644 index 00000000..d5957c96 --- /dev/null +++ b/src/Sekiban.Core.DotNet/Documents/Pools/BetweenSortableIdCondition.cs @@ -0,0 +1,8 @@ +using Sekiban.Core.Documents.ValueObjects; +namespace Sekiban.Core.Documents.Pools; + +public record BetweenSortableIdCondition(SortableUniqueIdValue Start, SortableUniqueIdValue End) : ISortableIdCondition +{ + public bool OutsideOfRange(SortableUniqueIdValue toCompare) => + Start.IsLaterThan(toCompare) || End.IsEarlierThan(toCompare); +} diff --git a/src/Sekiban.Core.DotNet/Documents/Pools/SinceSortableIdCondition.cs b/src/Sekiban.Core.DotNet/Documents/Pools/SinceSortableIdCondition.cs index 3b0214c8..82189a1c 100644 --- a/src/Sekiban.Core.DotNet/Documents/Pools/SinceSortableIdCondition.cs +++ b/src/Sekiban.Core.DotNet/Documents/Pools/SinceSortableIdCondition.cs @@ -5,8 +5,3 @@ public record SinceSortableIdCondition(SortableUniqueIdValue SortableUniqueId) : { public bool OutsideOfRange(SortableUniqueIdValue toCompare) => SortableUniqueId.IsLaterThan(toCompare); } -public record BetweenSortableIdCondition(SortableUniqueIdValue Start, SortableUniqueIdValue End) : ISortableIdCondition -{ - public bool OutsideOfRange(SortableUniqueIdValue toCompare) => - Start.IsLaterThan(toCompare) || End.IsEarlierThan(toCompare); -} diff --git a/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs b/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs index 8eba1c7f..f49845ff 100644 --- a/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs +++ b/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs @@ -49,7 +49,8 @@ public ImmutableArray GetCommandWithHandlerValues( Compilation compilation, ImmutableArray types) { - var iCommmandWithHandlerSymbol = compilation.GetTypeByMetadataName("Sekiban.Pure.ICommandWithHandler`2"); + var iCommmandWithHandlerSymbol + = compilation.GetTypeByMetadataName("Sekiban.Pure.Command.Handlers.ICommandWithHandler`2"); if (iCommmandWithHandlerSymbol == null) return new ImmutableArray(); var eventTypes = ImmutableArray.CreateBuilder(); @@ -84,7 +85,8 @@ public ImmutableArray GetCommandWithHandlerAsyncValues Compilation compilation, ImmutableArray types) { - var iCommmandWithHandlerSymbol = compilation.GetTypeByMetadataName("Sekiban.Pure.ICommandWithHandlerAsync`2"); + var iCommmandWithHandlerSymbol + = compilation.GetTypeByMetadataName("Sekiban.Pure.Command.Handlers.ICommandWithHandlerAsync`2"); if (iCommmandWithHandlerSymbol == null) return new ImmutableArray(); var eventTypes = ImmutableArray.CreateBuilder(); @@ -120,7 +122,7 @@ public ImmutableArray GetICommandWithHandlerInjectionV ImmutableArray types) { var iCommandWithHandlerSymbol - = compilation.GetTypeByMetadataName("Sekiban.Pure.ICommandWithHandlerInjection`3"); + = compilation.GetTypeByMetadataName("Sekiban.Pure.Command.Handlers.ICommandWithHandlerInjection`3"); if (iCommandWithHandlerSymbol == null) return new ImmutableArray(); var eventTypes = ImmutableArray.CreateBuilder(); @@ -156,7 +158,7 @@ public ImmutableArray GetICommandWithHandlerInjectionA ImmutableArray types) { var iCommandWithHandlerSymbol - = compilation.GetTypeByMetadataName("Sekiban.Pure.ICommandWithHandlerInjectionAsync`3"); + = compilation.GetTypeByMetadataName("Sekiban.Pure.Command.Handlers.ICommandWithHandlerInjectionAsync`3"); if (iCommandWithHandlerSymbol == null) return new ImmutableArray(); var eventTypes = ImmutableArray.CreateBuilder(); @@ -193,9 +195,9 @@ public ImmutableArray GetCommandValues( ImmutableArray types, ImmutableArray alreadyFoundCommands) { - var iCommandSymbol = compilation.GetTypeByMetadataName("Sekiban.Pure.ICommand"); + var iCommandSymbol = compilation.GetTypeByMetadataName("Sekiban.Pure.Command.Handlers.ICommand"); var iCommandWithAggregateRestrictionSymbol - = compilation.GetTypeByMetadataName("Sekiban.Pure.ICommandWithAggregateRestriction`1"); + = compilation.GetTypeByMetadataName("Sekiban.Pure.Command.Handlers.ICommandWithAggregateRestriction`1"); if (iCommandSymbol == null || iCommandWithAggregateRestrictionSymbol == null) return new ImmutableArray(); var eventTypes = ImmutableArray.CreateBuilder(); @@ -244,8 +246,12 @@ private string GenerateSourceCode(ImmutableArray event sb.AppendLine("using System.Threading.Tasks;"); sb.AppendLine("using ResultBoxes;"); sb.AppendLine("using Sekiban.Pure;"); + sb.AppendLine("using Sekiban.Pure.Projectors;"); sb.AppendLine("using Sekiban.Pure.Exception;"); - + sb.AppendLine("using Sekiban.Pure.Events;"); + sb.AppendLine("using Sekiban.Pure.Events;"); + sb.AppendLine("using Sekiban.Pure.Command.Handlers;"); + sb.AppendLine("using Sekiban.Pure.Command.Resources;"); sb.AppendLine(); sb.AppendLine($"namespace {rootNamespace}.Generated"); sb.AppendLine("{"); diff --git a/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs b/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs index c1b224ff..7372844c 100644 --- a/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs +++ b/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs @@ -45,7 +45,7 @@ public ImmutableArray GetEventValues( Compilation compilation, ImmutableArray types) { - var iEventPayloadSymbol = compilation.GetTypeByMetadataName("Sekiban.Pure.IEventPayload"); + var iEventPayloadSymbol = compilation.GetTypeByMetadataName("Sekiban.Pure.Events.IEventPayload"); if (iEventPayloadSymbol == null) return new ImmutableArray(); var eventTypes = ImmutableArray.CreateBuilder(); @@ -78,6 +78,7 @@ private string GenerateSourceCode(ImmutableArray event sb.AppendLine("using ResultBoxes;"); sb.AppendLine("using Sekiban.Pure;"); sb.AppendLine("using Sekiban.Pure.Exception;"); + sb.AppendLine("using Sekiban.Pure.Events;"); sb.AppendLine(); sb.AppendLine($"namespace {rootNamespace}.Generated"); diff --git a/src/Sekiban.Pure/Aggregates/Aggregate.cs b/src/Sekiban.Pure/Aggregates/Aggregate.cs new file mode 100644 index 00000000..c0cef0e8 --- /dev/null +++ b/src/Sekiban.Pure/Aggregates/Aggregate.cs @@ -0,0 +1,39 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Exception; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure; + +public record Aggregate( + IAggregatePayload Payload, + PartitionKeys PartitionKeys, + int Version, + string LastSortableUniqueId) : IAggregate +{ + public static Aggregate Empty => new(new EmptyAggregatePayload(), PartitionKeys.Generate(), 0, string.Empty); + public IAggregatePayload GetPayload() => Payload; + public static Aggregate EmptyFromPartitionKeys(PartitionKeys keys) => + new(new EmptyAggregatePayload(), keys, 0, string.Empty); + public ResultBox> ToTypedPayload() + where TAggregatePayload : IAggregatePayload => Payload is TAggregatePayload typedPayload + ? ResultBox.FromValue( + new Aggregate(typedPayload, PartitionKeys, Version, LastSortableUniqueId)) + : new SekibanAggregateTypeException("Payload is not typed to " + typeof(TAggregatePayload).Name); + public ResultBox Project(IEvent ev, IAggregateProjector projector) => this with + { + Payload = projector.Project(Payload, ev), + LastSortableUniqueId = ev.SortableUniqueId, + Version = Version + 1 + }; + public ResultBox Project(List events, IAggregateProjector projector) => ResultBox + .FromValue(events) + .ReduceEach(this, (ev, aggregate) => aggregate.Project(ev, projector)); +} +public record Aggregate( + TAggregatePayload Payload, + PartitionKeys PartitionKeys, + int Version, + string LastSortableUniqueId) : IAggregate where TAggregatePayload : IAggregatePayload +{ + public IAggregatePayload GetPayload() => Payload; +} diff --git a/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs b/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs new file mode 100644 index 00000000..79ff17e7 --- /dev/null +++ b/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs @@ -0,0 +1,6 @@ +namespace Sekiban.Pure; + +public record EmptyAggregatePayload : IAggregatePayload +{ + public static EmptyAggregatePayload Empty => new(); +} diff --git a/src/Sekiban.Pure/Aggregates/IAggregate.cs b/src/Sekiban.Pure/Aggregates/IAggregate.cs new file mode 100644 index 00000000..44eda0ba --- /dev/null +++ b/src/Sekiban.Pure/Aggregates/IAggregate.cs @@ -0,0 +1,13 @@ +using ResultBoxes; +using Sekiban.Core.Documents.ValueObjects; +namespace Sekiban.Pure; + +public interface IAggregate +{ + public int Version { get; } + public string LastSortableUniqueId { get; } + public PartitionKeys PartitionKeys { get; } + public OptionalValue GetLastSortableUniqueIdValue() => + SortableUniqueIdValue.OptionalValue(LastSortableUniqueId); + public IAggregatePayload GetPayload(); +} diff --git a/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs b/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs new file mode 100644 index 00000000..488ef6b7 --- /dev/null +++ b/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs @@ -0,0 +1,3 @@ +namespace Sekiban.Pure; + +public interface IAggregatePayload; diff --git a/src/Sekiban.Pure/Class1.cs b/src/Sekiban.Pure/Class1.cs deleted file mode 100644 index f02b58de..00000000 --- a/src/Sekiban.Pure/Class1.cs +++ /dev/null @@ -1,699 +0,0 @@ -using ResultBoxes; -using Sekiban.Core.Documents.ValueObjects; -using Sekiban.Core.Shared; -using Sekiban.Pure.Exception; -using System.Diagnostics.CodeAnalysis; -using System.Reflection; -namespace Sekiban.Pure; - -public interface IEvent -{ - public int Version { get; } - public string SortableUniqueId { get; } - public PartitionKeys PartitionKeys { get; } - public SortableUniqueIdValue GetSortableUniqueId() => new(SortableUniqueId); - public IEventPayload GetPayload(); -} -public record Event( - TEventPayload Payload, - PartitionKeys PartitionKeys, - string SortableUniqueId, - int Version) : IEvent where TEventPayload : IEventPayload -{ - public IEventPayload GetPayload() => Payload; -} -public interface IAggregatePayload; -public record EmptyAggregatePayload : IAggregatePayload -{ - public static EmptyAggregatePayload Empty => new(); -} -public record Aggregate( - IAggregatePayload Payload, - PartitionKeys PartitionKeys, - int Version, - string LastSortableUniqueId) : IAggregate -{ - public static Aggregate Empty => new(new EmptyAggregatePayload(), PartitionKeys.Generate(), 0, string.Empty); - public IAggregatePayload GetPayload() => Payload; - public static Aggregate EmptyFromPartitionKeys(PartitionKeys keys) => - new(new EmptyAggregatePayload(), keys, 0, string.Empty); - public ResultBox> ToTypedPayload() - where TAggregatePayload : IAggregatePayload => Payload is TAggregatePayload typedPayload - ? ResultBox.FromValue( - new Aggregate(typedPayload, PartitionKeys, Version, LastSortableUniqueId)) - : new SekibanAggregateTypeException("Payload is not typed to " + typeof(TAggregatePayload).Name); - public ResultBox Project(IEvent ev, IAggregateProjector projector) => this with - { - Payload = projector.Project(Payload, ev), - LastSortableUniqueId = ev.SortableUniqueId, - Version = Version + 1 - }; - public ResultBox Project(List events, IAggregateProjector projector) => ResultBox - .FromValue(events) - .ReduceEach(this, (ev, aggregate) => aggregate.Project(ev, projector)); -} -public record Aggregate( - TAggregatePayload Payload, - PartitionKeys PartitionKeys, - int Version, - string LastSortableUniqueId) : IAggregate where TAggregatePayload : IAggregatePayload -{ - public IAggregatePayload GetPayload() => Payload; -} -public interface IAggregate -{ - public int Version { get; } - public string LastSortableUniqueId { get; } - public PartitionKeys PartitionKeys { get; } - public OptionalValue GetLastSortableUniqueIdValue() => - SortableUniqueIdValue.OptionalValue(LastSortableUniqueId); - public IAggregatePayload GetPayload(); -} -public interface IEventPayload; -public interface IAggregateProjector -{ - public IAggregatePayload Project(IAggregatePayload payload, IEvent ev); - public virtual string GetVersion() => "initial"; -} -public class NoneAggregateProjector : IAggregateProjector -{ - public static NoneAggregateProjector Empty => new(); - public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => payload; -} -public interface ICommandContext : ICommandContextWithoutState - where TAggregatePayload : IAggregatePayload -{ - CommandExecuted ICommandContextWithoutState.GetCommandExecuted(List producedEvents) => new( - GetAggregateCommon().PartitionKeys, - GetAggregateCommon().LastSortableUniqueId, - producedEvents); - internal IAggregate GetAggregateCommon(); - public ResultBox> GetAggregate(); -} -public interface ICommandContextWithoutState -{ - public List Events { get; } - public PartitionKeys GetPartitionKeys(); - public int GetNextVersion(); - public int GetCurrentVersion(); - internal CommandExecuted GetCommandExecuted(List producedEvents); - public ResultBox AppendEvent(IEventPayload eventPayload); -} -public interface ICommand; -public interface ICommandWithAggregateRestriction : ICommand - where TAggregatePayload : IAggregatePayload; -public record NoInjection -{ - public static NoInjection Empty => new(); -} -public interface - ICommandHandler : ICommandHandlerCommon - where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload -{ - public ResultBox Handle(TCommand command, ICommandContext context); -} -public interface - ICommandHandlerAsync : ICommandHandlerCommon - where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload -{ - public Task> HandleAsync(TCommand command, ICommandContext context); -} -public interface - ICommandHandlerCommon : ICommandWithAggregateRestriction - where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload -{ -} -public interface - ICommandHandlerInjection : ICommandHandlerCommon where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload -{ - public ResultBox Handle( - TCommand command, - TInjection injection, - ICommandContext context); -} -public interface - ICommandHandlerInjectionAsync : ICommandHandlerCommon where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload -{ - public Task> HandleAsync( - TCommand command, - TInjection injection, - ICommandContext context); -} -public interface ICommandPartitionSpecifier where TCommand : ICommand, IEquatable -{ - public PartitionKeys SpecifyPartitionKeys(TCommand command); -} -public interface - ICommandWithHandler : ICommandWithHandlerCommon, - ICommandHandler where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandler<,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface - ICommandWithHandlerAsync : - ICommandWithHandlerCommon, - ICommandHandlerAsync where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerAsync<,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface - ICommandWithHandlerInjection : - ICommandWithHandlerCommon, - ICommandHandlerInjection where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjection<,,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface - ICommandWithHandlerInjectionAsync : - ICommandWithHandlerCommon, - ICommandHandlerInjectionAsync where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjectionAsync<,,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface - ICommandWithHandlerInjection : - ICommandWithHandlerCommon, - ICommandHandlerInjection where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() - where TAggregatePayload : IAggregatePayload -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjection<,,,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface - ICommandWithHandlerInjectionAsync : - ICommandWithHandlerCommon, - ICommandHandlerInjectionAsync where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() - where TAggregatePayload : IAggregatePayload -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjectionAsync<,,,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface ICommandGetProjector -{ - public IAggregateProjector GetProjector(); -} -public interface ICommandWithHandlerCommon : ICommand, - ICommandHandlerCommon, - ICommandGetProjector, - ICommandPartitionSpecifier where TCommand : ICommand, IEquatable - where TAggregatePayload : IAggregatePayload; -public interface - ICommandWithHandler : - ICommandWithHandlerCommon, - ICommandHandler where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() - where TAggregatePayload : IAggregatePayload -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandler<,,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public interface - ICommandWithHandlerAsync : - ICommandWithHandlerCommon, - ICommandHandlerAsync where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() - where TAggregatePayload : IAggregatePayload -{ - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerAsync<,,>))] - IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); -} -public static class PartitionKeys where TAggregateProjector : IAggregateProjector, new() -{ - public static PartitionKeys Generate(string rootPartitionKey = PartitionKeys.DefaultRootPartitionKey) => - PartitionKeys.Generate(rootPartitionKey); - public static PartitionKeys Existing(Guid aggregateId, string group = PartitionKeys.DefaultAggregateGroupName) => - PartitionKeys.Existing(aggregateId, group); -} -public static class GuidExtensions -{ - - public static Guid CreateVersion7() - { -#if NET9_0 - return Guid.CreateVersion7(); -#else - return Guid.NewGuid(); -#endif - } -} -public record PartitionKeys(Guid AggregateId, string Group, string RootPartitionKey) -{ - public const string DefaultRootPartitionKey = "default"; - public const string DefaultAggregateGroupName = "default"; - public static PartitionKeys Generate( - string group = DefaultAggregateGroupName, - string rootPartitionKey = DefaultRootPartitionKey) => - new(GuidExtensions.CreateVersion7(), group, rootPartitionKey); - public static PartitionKeys Generate(string rootPartitionKey = DefaultRootPartitionKey) - where TAggregateProjector : IAggregateProjector => - new(GuidExtensions.CreateVersion7(), typeof(TAggregateProjector).Name, rootPartitionKey); - public static PartitionKeys Existing( - Guid aggregateId, - string group = "default", - string rootPartitionKey = "default") => - new(aggregateId, group, rootPartitionKey); - public static PartitionKeys Existing(Guid aggregateId, string rootPartitionKey = "default") - where TAggregateProjector : IAggregateProjector => - new(aggregateId, typeof(TAggregateProjector).Name, rootPartitionKey); -} -public record TenantPartitionKeys(string TenantCode) -{ - public static TenantPartitionKeys Tenant(string tenantCode) => new(tenantCode); - - public PartitionKeys Generate(string group = PartitionKeys.DefaultAggregateGroupName) => - PartitionKeys.Generate(group, TenantCode); - public PartitionKeys Existing(Guid aggregateId, string group = PartitionKeys.DefaultAggregateGroupName) => - PartitionKeys.Existing(aggregateId, group, TenantCode); -} -public record CommandResponse(PartitionKeys PartitionKeys, List Events, int Version); -public interface ICommandExecutor; -public class CommandExecutor : ICommandExecutor -{ - public IEventTypes EventTypes { get; init; } = new EmptyEventTypes(); - - public Task> ExecuteWithResource( - TCommand command, - ICommandResource resource) where TCommand : ICommand, IEquatable => - ExecuteGeneralNonGeneric( - command, - resource.GetProjector(), - resource.GetSpecifyPartitionKeysFunc(), - resource.GetInjection(), - resource.GetHandler(), - resource.GetAggregatePayloadType()); - - #region Private Methods - [DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(CommandExecutor))] - [UnconditionalSuppressMessage( - "AOT", - "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", - Justification = "")] - public async Task> ExecuteGeneralNonGeneric( - ICommand command, - IAggregateProjector projector, - Delegate specifyPartitionKeys, - object? inject, - Delegate handler, - OptionalValue aggregatePayloadType) - { - var commandType = command.GetType(); - var injectType = inject is not null ? inject.GetType() : typeof(NoInjection); - var optionalType = typeof(OptionalValue<>).MakeGenericType(injectType); - var optionalMethod = optionalType?.GetMethod( - nameof(OptionalValue.FromValue), - BindingFlags.Static | BindingFlags.Public); - var injectValue = inject is not null - ? optionalMethod?.Invoke(null, new[] { inject }) - : OptionalValue.Empty; - var aggregatePayloadTypeValue = aggregatePayloadType.HasValue - ? aggregatePayloadType.GetValue() - : typeof(IAggregatePayload); - var method = GetType().GetMethod(nameof(ExecuteGeneral), BindingFlags.Public | BindingFlags.Instance); - if (method is null) { return new SekibanCommandHandlerNotMatchException("Method not found"); } - var genericMethod = method.MakeGenericMethod(commandType, injectType, aggregatePayloadTypeValue); - var result = genericMethod.Invoke( - this, - new[] { command, projector, specifyPartitionKeys, injectValue, handler }); - if (result is Task> task) { return await task; } - return new SekibanCommandHandlerNotMatchException("Result is not Task>"); - } - - - [DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(CommandExecutor))] - public Task> ExecuteGeneral( - TCommand command, - IAggregateProjector projector, - Func specifyPartitionKeys, - OptionalValue inject, - Delegate handler) where TCommand : ICommand where TAggregatePayload : IAggregatePayload => - specifyPartitionKeys(command) - .ToResultBox() - .Combine( - keys => CreateCommandContextWithoutState( - command, - keys, - projector, - handler)) - .Combine( - (partitionKeys, context) => - RunHandler(command, context, inject, handler) - .Conveyor(eventOrNone => EventToCommandExecuted(context, eventOrNone))) - .Conveyor(values => Repository.Save(values.Value3.ProducedEvents).Remap(_ => values)) - .Conveyor( - (partitionKeys, context, executed) => ResultBox.FromValue( - new CommandResponse( - partitionKeys, - executed.ProducedEvents, - executed.ProducedEvents.Count > 0 - ? executed.ProducedEvents.Last().Version - : context.GetCurrentVersion()))); - private ResultBox - CreateCommandContextWithoutState( - TCommand command, - PartitionKeys partitionKeys, - IAggregateProjector projector, - Delegate handler) where TCommand : ICommand where TAggregatePayload : IAggregatePayload => - handler switch - { - Func> handler1 => - ResultBox.FromValue( - new CommandContextWithoutState(partitionKeys, EventTypes)), - Func>> handler1 => - ResultBox.FromValue( - new CommandContextWithoutState(partitionKeys, EventTypes)), - Func> handler1 => - ResultBox.FromValue( - new CommandContextWithoutState(partitionKeys, EventTypes)), - Func>> handler1 => - ResultBox.FromValue( - new CommandContextWithoutState(partitionKeys, EventTypes)), - _ => ResultBox - .Start - .Conveyor(keys => Repository.Load(partitionKeys, projector)) - .Verify(aggregate => VerifyAggregateType(command, aggregate)) - .Conveyor( - aggregate => ResultBox.FromValue( - new CommandContext(aggregate, projector, EventTypes))) - }; - - private ExceptionOrNone VerifyAggregateType(TCommand command, Aggregate aggregate) - where TCommand : ICommand where TAggregatePayload : IAggregatePayload => - aggregate.GetPayload() is not TAggregatePayload - ? ExceptionOrNone.FromException( - new SekibanAggregateTypeRestrictionException( - $"To execute command {command.GetType().Name}, " + - $"Aggregate must be {aggregate.GetPayload().GetType().Name}," + - $" but currently aggregate type is {aggregate.GetPayload().GetType().Name}")) - : ExceptionOrNone.None; - - private Task> RunHandler( - TCommand command, - ICommandContextWithoutState context, - OptionalValue inject, - Delegate handler) where TCommand : ICommand where TAggregatePayload : IAggregatePayload => - (handler, inject.HasValue, context) switch - { - (Func> handler1, _, { } contextWithout) => - Task.FromResult(handler1(command, contextWithout)), - (Func>> handler1, _, { } contextWithout) - => handler1(command, contextWithout), - (Func> handler1, true, { - } contextWithout) => Task.FromResult(handler1(command, inject.GetValue(), contextWithout)), - (Func>> handler1, true, { - } contextWithout) => handler1(command, inject.GetValue(), contextWithout), - (Func, ResultBox> handler1, _, - ICommandContext stateContext) => handler1(command, stateContext).ToTask(), - (Func, ResultBox> handler1, true, - ICommandContext stateContext) => handler1(command, inject.GetValue(), stateContext) - .ToTask(), - (Func, Task>> handler1, _, - ICommandContext stateContext) => handler1(command, stateContext), - (Func, Task>> handler1, true, - ICommandContext stateContext) => handler1(command, inject.GetValue(), stateContext), - _ => ResultBox - .FromException( - new SekibanCommandHandlerNotMatchException( - $"{handler.GetType().Name} does not match as command handler")) - .ToTask() - }; - private ResultBox EventToCommandExecuted( - ICommandContextWithoutState commandContext, - EventOrNone eventOrNone) => - (eventOrNone.HasEvent - ? EventTypes - .GenerateTypedEvent( - eventOrNone.GetValue(), - commandContext.GetPartitionKeys(), - SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), - commandContext.GetNextVersion()) - .Remap(ev => commandContext.Events.Append(ev).ToList()) - : ResultBox.FromValue(commandContext.Events)).Remap(commandContext.GetCommandExecuted); - #endregion -} -public record CommandExecuted(PartitionKeys PartitionKeys, string LastSortableUniqueId, List ProducedEvents); -public class CommandContext( - Aggregate aggregate, - IAggregateProjector projector, - IEventTypes eventTypes) : ICommandContext where TAggregatePayload : IAggregatePayload -{ - public Aggregate Aggregate { get; set; } = aggregate; - public IAggregateProjector Projector { get; } = projector; - public IEventTypes EventTypes { get; } = eventTypes; - public List Events { get; } = new(); - public PartitionKeys GetPartitionKeys() => Aggregate.PartitionKeys; - public int GetNextVersion() => Aggregate.Version + 1; - public int GetCurrentVersion() => Aggregate.Version; - public IAggregate GetAggregateCommon() => Aggregate; - public ResultBox> GetAggregate() => Aggregate.ToTypedPayload(); - public ResultBox AppendEvent(IEventPayload eventPayload) - { - var toAdd = EventTypes.GenerateTypedEvent( - eventPayload, - Aggregate.PartitionKeys, - SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), - Aggregate.Version + 1); - if (!toAdd.IsSuccess) { return EventOrNone.Empty; } - var ev = toAdd.GetValue(); - var aggregatePayload = Projector.Project(Aggregate.GetPayload(), toAdd.GetValue()); - var projected = Aggregate.Project(ev, Projector); - if (projected.IsSuccess) { Aggregate = projected.GetValue(); } else { return EventOrNone.Empty; } - Events.Add(ev); - return EventOrNone.Empty; - } -} -public record CommandContextWithoutState(PartitionKeys PartitionKeys, IEventTypes EventTypes) - : ICommandContextWithoutState -{ - public List Events { get; } = new(); - public PartitionKeys GetPartitionKeys() => PartitionKeys; - public int GetNextVersion() => 0; - public int GetCurrentVersion() => 0; - public CommandExecuted GetCommandExecuted(List producedEvents) => new( - PartitionKeys, - SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), - producedEvents); - public ResultBox AppendEvent(IEventPayload eventPayload) => EventTypes - .GenerateTypedEvent( - eventPayload, - PartitionKeys, - SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), - 0) - .Do(ev => Events.Add(ev)) - .Remap(_ => EventOrNone.Empty); -} -public class Repository -{ - public static List Events { get; set; } = new(); - public Func Deserializer { get; set; } = s => throw new NotImplementedException(); - public Func Serializer { get; set; } = s => throw new NotImplementedException(); - public static ResultBox Load(PartitionKeys partitionKeys) - where TAggregateProjector : IAggregateProjector, new() => Load(partitionKeys, new TAggregateProjector()); - public static ResultBox Load(PartitionKeys partitionKeys, IAggregateProjector projector) => - ResultBox - .FromValue( - Events.Where(e => e.PartitionKeys.Equals(partitionKeys)).OrderBy(e => e.SortableUniqueId).ToList()) - .Conveyor(events => Aggregate.EmptyFromPartitionKeys(partitionKeys).Project(events, projector)); - - public static ResultBox Save(List events) => ResultBox.Start.Do(() => Events.AddRange(events)); -} -public interface IEventTypes -{ - public ResultBox GenerateTypedEvent( - IEventPayload payload, - PartitionKeys partitionKeys, - string sortableUniqueId, - int version); -} -public class EmptyEventTypes : IEventTypes -{ - public ResultBox GenerateTypedEvent( - IEventPayload payload, - PartitionKeys partitionKeys, - string sortableUniqueId, - int version) => ResultBox.FromException(new SekibanEventTypeNotFoundException("")); -} -public interface ICommandResource where TCommand : ICommand, IEquatable -{ - public Func GetSpecifyPartitionKeysFunc(); - public OptionalValue GetAggregatePayloadType(); - public Type GetCommandType(); - public IAggregateProjector GetProjector(); - public object? GetInjection(); - public Delegate GetHandler(); -} -public record CommandResource( - Func SpecifyPartitionKeys, - Func, ResultBox> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TAggregatePayload : IAggregatePayload - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => NoInjection.Empty; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); -} -public record CommandResourceTask( - Func SpecifyPartitionKeys, - Func, Task>> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TAggregatePayload : IAggregatePayload - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => NoInjection.Empty; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); -} -public record CommandResource( - Func SpecifyPartitionKeys, - Func, ResultBox> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => NoInjection.Empty; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; -} -public record CommandResourceTask( - Func SpecifyPartitionKeys, - Func, Task>> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object GetInjection() => NoInjection.Empty; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; -} -public record CommandResourceWithInject( - Func SpecifyPartitionKeys, - TInject? Injection, - Func, ResultBox> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => Injection; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; -} -public record CommandResourceWithInjectTask( - Func SpecifyPartitionKeys, - TInject? Injection, - Func, Task>> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => Injection; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; -} -public record CommandResourceWithInject( - Func SpecifyPartitionKeys, - TInject? Injection, - Func, ResultBox> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TAggregatePayload : IAggregatePayload - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => Injection; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); -} -public record CommandResourceWithInjectTask( - Func SpecifyPartitionKeys, - TInject? Injection, - Func, Task>> Handler) - : ICommandResource where TCommand : ICommand, IEquatable - where TAggregatePayload : IAggregatePayload - where TProjector : IAggregateProjector, new() -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => new TProjector(); - public object? GetInjection() => Injection; - public Delegate GetHandler() => Handler; - public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); -} -public record CommandResourcePublishOnly( - Func SpecifyPartitionKeys, - Func> Handler) : ICommandResource - where TCommand : ICommand, IEquatable -{ - - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; - public object? GetInjection() => null; - public Delegate GetHandler() => Handler; -} -public record CommandResourcePublishOnlyWithInject( - Func SpecifyPartitionKeys, - TInject? Injection, - Func> Handler) : ICommandResource - where TCommand : ICommand, IEquatable -{ - - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; - public object? GetInjection() => Injection; - public Delegate GetHandler() => Handler; -} -public record CommandResourcePublishOnlyTask( - Func SpecifyPartitionKeys, - Func>> Handler) : ICommandResource - where TCommand : ICommand, IEquatable -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; - public object? GetInjection() => null; - public Delegate GetHandler() => Handler; -} -public record CommandResourcePublishOnlyWithInjectTask( - Func SpecifyPartitionKeys, - TInject? Injection, - Func>> Handler) - : ICommandResource where TCommand : ICommand, IEquatable -{ - public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; - public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; - public Type GetCommandType() => typeof(TCommand); - public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; - public object? GetInjection() => Injection; - public Delegate GetHandler() => Handler; -} diff --git a/src/Sekiban.Pure/Command/Executor/CommandContext.cs b/src/Sekiban.Pure/Command/Executor/CommandContext.cs new file mode 100644 index 00000000..86a2c1fd --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/CommandContext.cs @@ -0,0 +1,37 @@ +using ResultBoxes; +using Sekiban.Core.Documents.ValueObjects; +using Sekiban.Core.Shared; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure; + +public class CommandContext( + Aggregate aggregate, + IAggregateProjector projector, + IEventTypes eventTypes) : ICommandContext where TAggregatePayload : IAggregatePayload +{ + public Aggregate Aggregate { get; set; } = aggregate; + public IAggregateProjector Projector { get; } = projector; + public IEventTypes EventTypes { get; } = eventTypes; + public List Events { get; } = new(); + public PartitionKeys GetPartitionKeys() => Aggregate.PartitionKeys; + public int GetNextVersion() => Aggregate.Version + 1; + public int GetCurrentVersion() => Aggregate.Version; + public IAggregate GetAggregateCommon() => Aggregate; + public ResultBox> GetAggregate() => Aggregate.ToTypedPayload(); + public ResultBox AppendEvent(IEventPayload eventPayload) + { + var toAdd = EventTypes.GenerateTypedEvent( + eventPayload, + Aggregate.PartitionKeys, + SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), + Aggregate.Version + 1); + if (!toAdd.IsSuccess) { return EventOrNone.Empty; } + var ev = toAdd.GetValue(); + var aggregatePayload = Projector.Project(Aggregate.GetPayload(), toAdd.GetValue()); + var projected = Aggregate.Project(ev, Projector); + if (projected.IsSuccess) { Aggregate = projected.GetValue(); } else { return EventOrNone.Empty; } + Events.Add(ev); + return EventOrNone.Empty; + } +} diff --git a/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs b/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs new file mode 100644 index 00000000..518f0c76 --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs @@ -0,0 +1,27 @@ +using ResultBoxes; +using Sekiban.Core.Documents.ValueObjects; +using Sekiban.Core.Shared; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Sekiban.Pure; + +public record CommandContextWithoutState(PartitionKeys PartitionKeys, IEventTypes EventTypes) + : ICommandContextWithoutState +{ + public List Events { get; } = new(); + public PartitionKeys GetPartitionKeys() => PartitionKeys; + public int GetNextVersion() => 0; + public int GetCurrentVersion() => 0; + public CommandExecuted GetCommandExecuted(List producedEvents) => new( + PartitionKeys, + SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), + producedEvents); + public ResultBox AppendEvent(IEventPayload eventPayload) => EventTypes + .GenerateTypedEvent( + eventPayload, + PartitionKeys, + SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), + 0) + .Do(ev => Events.Add(ev)) + .Remap(_ => EventOrNone.Empty); +} diff --git a/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs b/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs new file mode 100644 index 00000000..a82b1af0 --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Sekiban.Pure; + +public record CommandExecuted(PartitionKeys PartitionKeys, string LastSortableUniqueId, List ProducedEvents); diff --git a/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs b/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs new file mode 100644 index 00000000..2ad5b3b3 --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs @@ -0,0 +1,174 @@ +using ResultBoxes; +using Sekiban.Core.Documents.ValueObjects; +using Sekiban.Core.Shared; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +using Sekiban.Pure.Exception; +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +using System.Reflection; +namespace Sekiban.Pure; + +public class CommandExecutor : ICommandExecutor +{ + public IEventTypes EventTypes { get; init; } = new EmptyEventTypes(); + + public Task> ExecuteWithResource( + TCommand command, + ICommandResource resource) where TCommand : ICommand, IEquatable => + ExecuteGeneralNonGeneric( + command, + resource.GetProjector(), + resource.GetSpecifyPartitionKeysFunc(), + resource.GetInjection(), + resource.GetHandler(), + resource.GetAggregatePayloadType()); + + #region Private Methods + [DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(CommandExecutor))] + [UnconditionalSuppressMessage( + "AOT", + "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", + Justification = "")] + public async Task> ExecuteGeneralNonGeneric( + ICommand command, + IAggregateProjector projector, + Delegate specifyPartitionKeys, + object? inject, + Delegate handler, + OptionalValue aggregatePayloadType) + { + var commandType = command.GetType(); + var injectType = inject is not null ? inject.GetType() : typeof(NoInjection); + var optionalType = typeof(OptionalValue<>).MakeGenericType(injectType); + var optionalMethod = optionalType?.GetMethod( + nameof(OptionalValue.FromValue), + BindingFlags.Static | BindingFlags.Public); + var injectValue = inject is not null + ? optionalMethod?.Invoke(null, new[] { inject }) + : OptionalValue.Empty; + var aggregatePayloadTypeValue = aggregatePayloadType.HasValue + ? aggregatePayloadType.GetValue() + : typeof(IAggregatePayload); + var method = GetType().GetMethod(nameof(ExecuteGeneral), BindingFlags.Public | BindingFlags.Instance); + if (method is null) { return new SekibanCommandHandlerNotMatchException("Method not found"); } + var genericMethod = method.MakeGenericMethod(commandType, injectType, aggregatePayloadTypeValue); + var result = genericMethod.Invoke( + this, + new[] { command, projector, specifyPartitionKeys, injectValue, handler }); + if (result is Task> task) { return await task; } + return new SekibanCommandHandlerNotMatchException("Result is not Task>"); + } + + + [DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(CommandExecutor))] + public Task> ExecuteGeneral( + TCommand command, + IAggregateProjector projector, + Func specifyPartitionKeys, + OptionalValue inject, + Delegate handler) where TCommand : ICommand where TAggregatePayload : IAggregatePayload => + specifyPartitionKeys(command) + .ToResultBox() + .Combine( + keys => CreateCommandContextWithoutState( + command, + keys, + projector, + handler)) + .Combine( + (partitionKeys, context) => + RunHandler(command, context, inject, handler) + .Conveyor(eventOrNone => EventToCommandExecuted(context, eventOrNone))) + .Conveyor(values => Repository.Save(values.Value3.ProducedEvents).Remap(_ => values)) + .Conveyor( + (partitionKeys, context, executed) => ResultBox.FromValue( + new CommandResponse( + partitionKeys, + executed.ProducedEvents, + executed.ProducedEvents.Count > 0 + ? executed.ProducedEvents.Last().Version + : context.GetCurrentVersion()))); + private ResultBox + CreateCommandContextWithoutState( + TCommand command, + PartitionKeys partitionKeys, + IAggregateProjector projector, + Delegate handler) where TCommand : ICommand where TAggregatePayload : IAggregatePayload => + handler switch + { + Func> handler1 => + ResultBox.FromValue( + new CommandContextWithoutState(partitionKeys, EventTypes)), + Func>> handler1 => + ResultBox.FromValue( + new CommandContextWithoutState(partitionKeys, EventTypes)), + Func> handler1 => + ResultBox.FromValue( + new CommandContextWithoutState(partitionKeys, EventTypes)), + Func>> handler1 => + ResultBox.FromValue( + new CommandContextWithoutState(partitionKeys, EventTypes)), + _ => ResultBox + .Start + .Conveyor(keys => Repository.Load(partitionKeys, projector)) + .Verify(aggregate => VerifyAggregateType(command, aggregate)) + .Conveyor( + aggregate => ResultBox.FromValue( + new CommandContext(aggregate, projector, EventTypes))) + }; + + private ExceptionOrNone VerifyAggregateType(TCommand command, Aggregate aggregate) + where TCommand : ICommand where TAggregatePayload : IAggregatePayload => + aggregate.GetPayload() is not TAggregatePayload + ? ExceptionOrNone.FromException( + new SekibanAggregateTypeRestrictionException( + $"To execute command {command.GetType().Name}, " + + $"Aggregate must be {aggregate.GetPayload().GetType().Name}," + + $" but currently aggregate type is {aggregate.GetPayload().GetType().Name}")) + : ExceptionOrNone.None; + + private Task> RunHandler( + TCommand command, + ICommandContextWithoutState context, + OptionalValue inject, + Delegate handler) where TCommand : ICommand where TAggregatePayload : IAggregatePayload => + (handler, inject.HasValue, context) switch + { + (Func> handler1, _, { } contextWithout) => + Task.FromResult(handler1(command, contextWithout)), + (Func>> handler1, _, { } contextWithout) + => handler1(command, contextWithout), + (Func> handler1, true, { + } contextWithout) => Task.FromResult(handler1(command, inject.GetValue(), contextWithout)), + (Func>> handler1, true, { + } contextWithout) => handler1(command, inject.GetValue(), contextWithout), + (Func, ResultBox> handler1, _, + ICommandContext stateContext) => handler1(command, stateContext).ToTask(), + (Func, ResultBox> handler1, true, + ICommandContext stateContext) => handler1(command, inject.GetValue(), stateContext) + .ToTask(), + (Func, Task>> handler1, _, + ICommandContext stateContext) => handler1(command, stateContext), + (Func, Task>> handler1, true, + ICommandContext stateContext) => handler1(command, inject.GetValue(), stateContext), + _ => ResultBox + .FromException( + new SekibanCommandHandlerNotMatchException( + $"{handler.GetType().Name} does not match as command handler")) + .ToTask() + }; + private ResultBox EventToCommandExecuted( + ICommandContextWithoutState commandContext, + EventOrNone eventOrNone) => + (eventOrNone.HasEvent + ? EventTypes + .GenerateTypedEvent( + eventOrNone.GetValue(), + commandContext.GetPartitionKeys(), + SortableUniqueIdValue.Generate(SekibanDateProducer.GetRegistered().UtcNow, Guid.NewGuid()), + commandContext.GetNextVersion()) + .Remap(ev => commandContext.Events.Append(ev).ToList()) + : ResultBox.FromValue(commandContext.Events)).Remap(commandContext.GetCommandExecuted); + #endregion +} diff --git a/src/Sekiban.Pure/Command/Executor/CommandResponse.cs b/src/Sekiban.Pure/Command/Executor/CommandResponse.cs new file mode 100644 index 00000000..d2a7faf1 --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/CommandResponse.cs @@ -0,0 +1,4 @@ +using Sekiban.Pure.Events; +namespace Sekiban.Pure; + +public record CommandResponse(PartitionKeys PartitionKeys, List Events, int Version); diff --git a/src/Sekiban.Pure/Command/Executor/ICommandContext.cs b/src/Sekiban.Pure/Command/Executor/ICommandContext.cs new file mode 100644 index 00000000..802af1d0 --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/ICommandContext.cs @@ -0,0 +1,15 @@ +using ResultBoxes; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +namespace Sekiban.Pure; + +public interface ICommandContext : ICommandContextWithoutState + where TAggregatePayload : IAggregatePayload +{ + CommandExecuted ICommandContextWithoutState.GetCommandExecuted(List producedEvents) => new( + GetAggregateCommon().PartitionKeys, + GetAggregateCommon().LastSortableUniqueId, + producedEvents); + internal IAggregate GetAggregateCommon(); + public ResultBox> GetAggregate(); +} diff --git a/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs b/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs new file mode 100644 index 00000000..5d04ce00 --- /dev/null +++ b/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs @@ -0,0 +1,3 @@ +namespace Sekiban.Pure; + +public interface ICommandExecutor; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommand.cs b/src/Sekiban.Pure/Command/Handlers/ICommand.cs new file mode 100644 index 00000000..7a501561 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommand.cs @@ -0,0 +1,3 @@ +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommand; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs b/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs new file mode 100644 index 00000000..f610ca8b --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs @@ -0,0 +1,13 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommandContextWithoutState +{ + public List Events { get; } + public PartitionKeys GetPartitionKeys(); + public int GetNextVersion(); + public int GetCurrentVersion(); + internal CommandExecuted GetCommandExecuted(List producedEvents); + public ResultBox AppendEvent(IEventPayload eventPayload); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandGetProjector.cs b/src/Sekiban.Pure/Command/Handlers/ICommandGetProjector.cs new file mode 100644 index 00000000..f3f62d10 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandGetProjector.cs @@ -0,0 +1,7 @@ +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommandGetProjector +{ + public IAggregateProjector GetProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs new file mode 100644 index 00000000..77f949d5 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs @@ -0,0 +1,22 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandHandler : ICommandHandlerCommon + where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload +{ + public ResultBox Handle(TCommand command, ICommandContext context); +} +public interface + ICommandWithHandler : + ICommandWithHandlerCommon, + ICommandHandler where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() + where TAggregatePayload : IAggregatePayload +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandler<,,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs new file mode 100644 index 00000000..a7f9d48f --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs @@ -0,0 +1,10 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandHandlerAsync : ICommandHandlerCommon + where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload +{ + public Task> HandleAsync(TCommand command, ICommandContext context); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs new file mode 100644 index 00000000..0fe9015c --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs @@ -0,0 +1,7 @@ +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandHandlerCommon : ICommandWithAggregateRestriction + where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload +{ +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs new file mode 100644 index 00000000..415fe84f --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs @@ -0,0 +1,13 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandHandlerInjection : ICommandHandlerCommon where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload +{ + public ResultBox Handle( + TCommand command, + TInjection injection, + ICommandContext context); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs new file mode 100644 index 00000000..78e891be --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs @@ -0,0 +1,25 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandHandlerInjectionAsync : ICommandHandlerCommon where TCommand : ICommand, IEquatable where TAggregatePayload : IAggregatePayload +{ + public Task> HandleAsync( + TCommand command, + TInjection injection, + ICommandContext context); +} +public interface + ICommandWithHandlerInjectionAsync : + ICommandWithHandlerCommon, + ICommandHandlerInjectionAsync where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() + where TAggregatePayload : IAggregatePayload +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjectionAsync<,,,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs b/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs new file mode 100644 index 00000000..bc67c822 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs @@ -0,0 +1,6 @@ +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommandPartitionSpecifier where TCommand : ICommand, IEquatable +{ + public PartitionKeys SpecifyPartitionKeys(TCommand command); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs new file mode 100644 index 00000000..51a1ed9d --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs @@ -0,0 +1,4 @@ +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommandWithAggregateRestriction : ICommand + where TAggregatePayload : IAggregatePayload; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs new file mode 100644 index 00000000..5a9de8f9 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs @@ -0,0 +1,12 @@ +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandWithHandler : ICommandWithHandlerCommon, + ICommandHandler where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandler<,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs new file mode 100644 index 00000000..9e194350 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs @@ -0,0 +1,23 @@ +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandWithHandlerAsync : + ICommandWithHandlerCommon, + ICommandHandlerAsync where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerAsync<,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} +public interface + ICommandWithHandlerAsync : + ICommandWithHandlerCommon, + ICommandHandlerAsync where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() + where TAggregatePayload : IAggregatePayload +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerAsync<,,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs new file mode 100644 index 00000000..ab99a4ae --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs @@ -0,0 +1,7 @@ +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommandWithHandlerCommon : ICommand, + ICommandHandlerCommon, + ICommandGetProjector, + ICommandPartitionSpecifier where TCommand : ICommand, IEquatable + where TAggregatePayload : IAggregatePayload; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs new file mode 100644 index 00000000..b0820f74 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs @@ -0,0 +1,23 @@ +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandWithHandlerInjection : + ICommandWithHandlerCommon, + ICommandHandlerInjection where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() + where TAggregatePayload : IAggregatePayload +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjection<,,,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} +public interface + ICommandWithHandlerInjection : + ICommandWithHandlerCommon, + ICommandHandlerInjection where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjection<,,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs new file mode 100644 index 00000000..aa562098 --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs @@ -0,0 +1,13 @@ +using Sekiban.Pure.Projectors; +using System.Diagnostics.CodeAnalysis; +namespace Sekiban.Pure.Command.Handlers; + +public interface + ICommandWithHandlerInjectionAsync : + ICommandWithHandlerCommon, + ICommandHandlerInjectionAsync where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICommandWithHandlerInjectionAsync<,,>))] + IAggregateProjector ICommandGetProjector.GetProjector() => new TProjector(); +} diff --git a/src/Sekiban.Pure/Command/Handlers/NoInjection.cs b/src/Sekiban.Pure/Command/Handlers/NoInjection.cs new file mode 100644 index 00000000..1b9ad28e --- /dev/null +++ b/src/Sekiban.Pure/Command/Handlers/NoInjection.cs @@ -0,0 +1,6 @@ +namespace Sekiban.Pure.Command.Handlers; + +public record NoInjection +{ + public static NoInjection Empty => new(); +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResource.cs b/src/Sekiban.Pure/Command/Resources/CommandResource.cs new file mode 100644 index 00000000..f8ea91f2 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResource.cs @@ -0,0 +1,33 @@ +using ResultBoxes; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Resources; + +public record CommandResource( + Func SpecifyPartitionKeys, + Func, ResultBox> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => NoInjection.Empty; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; +} +public record CommandResource( + Func SpecifyPartitionKeys, + Func, ResultBox> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TAggregatePayload : IAggregatePayload + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => NoInjection.Empty; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs new file mode 100644 index 00000000..f3ff9257 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs @@ -0,0 +1,18 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourcePublishOnly( + Func SpecifyPartitionKeys, + Func> Handler) : ICommandResource + where TCommand : ICommand, IEquatable +{ + + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; + public object? GetInjection() => null; + public Delegate GetHandler() => Handler; +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs new file mode 100644 index 00000000..6aa7e980 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs @@ -0,0 +1,17 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourcePublishOnlyTask( + Func SpecifyPartitionKeys, + Func>> Handler) : ICommandResource + where TCommand : ICommand, IEquatable +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; + public object? GetInjection() => null; + public Delegate GetHandler() => Handler; +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs new file mode 100644 index 00000000..50b16b84 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs @@ -0,0 +1,19 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourcePublishOnlyWithInject( + Func SpecifyPartitionKeys, + TInject? Injection, + Func> Handler) : ICommandResource + where TCommand : ICommand, IEquatable +{ + + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; + public object? GetInjection() => Injection; + public Delegate GetHandler() => Handler; +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs new file mode 100644 index 00000000..9da5bdff --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs @@ -0,0 +1,18 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourcePublishOnlyWithInjectTask( + Func SpecifyPartitionKeys, + TInject? Injection, + Func>> Handler) + : ICommandResource where TCommand : ICommand, IEquatable +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => NoneAggregateProjector.Empty; + public object? GetInjection() => Injection; + public Delegate GetHandler() => Handler; +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs new file mode 100644 index 00000000..7ca76232 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs @@ -0,0 +1,32 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourceTask( + Func SpecifyPartitionKeys, + Func, Task>> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object GetInjection() => NoInjection.Empty; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; +} +public record CommandResourceTask( + Func SpecifyPartitionKeys, + Func, Task>> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TAggregatePayload : IAggregatePayload + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => NoInjection.Empty; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs new file mode 100644 index 00000000..be47abd6 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs @@ -0,0 +1,34 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourceWithInject( + Func SpecifyPartitionKeys, + TInject? Injection, + Func, ResultBox> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TAggregatePayload : IAggregatePayload + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => Injection; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); +} +public record CommandResourceWithInject( + Func SpecifyPartitionKeys, + TInject? Injection, + Func, ResultBox> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => Injection; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; +} diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs new file mode 100644 index 00000000..a13f08f9 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs @@ -0,0 +1,34 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public record CommandResourceWithInjectTask( + Func SpecifyPartitionKeys, + TInject? Injection, + Func, Task>> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => Injection; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => OptionalValue.Empty; +} +public record CommandResourceWithInjectTask( + Func SpecifyPartitionKeys, + TInject? Injection, + Func, Task>> Handler) + : ICommandResource where TCommand : ICommand, IEquatable + where TAggregatePayload : IAggregatePayload + where TProjector : IAggregateProjector, new() +{ + public Func GetSpecifyPartitionKeysFunc() => SpecifyPartitionKeys; + public Type GetCommandType() => typeof(TCommand); + public IAggregateProjector GetProjector() => new TProjector(); + public object? GetInjection() => Injection; + public Delegate GetHandler() => Handler; + public OptionalValue GetAggregatePayloadType() => typeof(TAggregatePayload); +} diff --git a/src/Sekiban.Pure/Command/Resources/ICommandResource.cs b/src/Sekiban.Pure/Command/Resources/ICommandResource.cs new file mode 100644 index 00000000..a59c5450 --- /dev/null +++ b/src/Sekiban.Pure/Command/Resources/ICommandResource.cs @@ -0,0 +1,13 @@ +using ResultBoxes; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure.Command.Handlers; + +public interface ICommandResource where TCommand : ICommand, IEquatable +{ + public Func GetSpecifyPartitionKeysFunc(); + public OptionalValue GetAggregatePayloadType(); + public Type GetCommandType(); + public IAggregateProjector GetProjector(); + public object? GetInjection(); + public Delegate GetHandler(); +} diff --git a/src/Sekiban.Pure/Documents/PartitionKeys.cs b/src/Sekiban.Pure/Documents/PartitionKeys.cs new file mode 100644 index 00000000..da8b96c7 --- /dev/null +++ b/src/Sekiban.Pure/Documents/PartitionKeys.cs @@ -0,0 +1,31 @@ +using Sekiban.Pure.Extensions; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure; + +public record PartitionKeys(Guid AggregateId, string Group, string RootPartitionKey) +{ + public const string DefaultRootPartitionKey = "default"; + public const string DefaultAggregateGroupName = "default"; + public static PartitionKeys Generate( + string group = DefaultAggregateGroupName, + string rootPartitionKey = DefaultRootPartitionKey) => + new(GuidExtensions.CreateVersion7(), group, rootPartitionKey); + public static PartitionKeys Generate(string rootPartitionKey = DefaultRootPartitionKey) + where TAggregateProjector : IAggregateProjector => + new(GuidExtensions.CreateVersion7(), typeof(TAggregateProjector).Name, rootPartitionKey); + public static PartitionKeys Existing( + Guid aggregateId, + string group = "default", + string rootPartitionKey = "default") => + new(aggregateId, group, rootPartitionKey); + public static PartitionKeys Existing(Guid aggregateId, string rootPartitionKey = "default") + where TAggregateProjector : IAggregateProjector => + new(aggregateId, typeof(TAggregateProjector).Name, rootPartitionKey); +} +public static class PartitionKeys where TAggregateProjector : IAggregateProjector, new() +{ + public static PartitionKeys Generate(string rootPartitionKey = PartitionKeys.DefaultRootPartitionKey) => + PartitionKeys.Generate(rootPartitionKey); + public static PartitionKeys Existing(Guid aggregateId, string group = PartitionKeys.DefaultAggregateGroupName) => + PartitionKeys.Existing(aggregateId, group); +} diff --git a/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs b/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs new file mode 100644 index 00000000..76d841d6 --- /dev/null +++ b/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs @@ -0,0 +1,11 @@ +namespace Sekiban.Pure; + +public record TenantPartitionKeys(string TenantCode) +{ + public static TenantPartitionKeys Tenant(string tenantCode) => new(tenantCode); + + public PartitionKeys Generate(string group = PartitionKeys.DefaultAggregateGroupName) => + PartitionKeys.Generate(group, TenantCode); + public PartitionKeys Existing(Guid aggregateId, string group = PartitionKeys.DefaultAggregateGroupName) => + PartitionKeys.Existing(aggregateId, group, TenantCode); +} diff --git a/src/Sekiban.Pure/Events/EmptyEventTypes.cs b/src/Sekiban.Pure/Events/EmptyEventTypes.cs new file mode 100644 index 00000000..669259e5 --- /dev/null +++ b/src/Sekiban.Pure/Events/EmptyEventTypes.cs @@ -0,0 +1,12 @@ +using ResultBoxes; +using Sekiban.Pure.Exception; +namespace Sekiban.Pure.Events; + +public class EmptyEventTypes : IEventTypes +{ + public ResultBox GenerateTypedEvent( + IEventPayload payload, + PartitionKeys partitionKeys, + string sortableUniqueId, + int version) => ResultBox.FromException(new SekibanEventTypeNotFoundException("")); +} diff --git a/src/Sekiban.Pure/Events/Event.cs b/src/Sekiban.Pure/Events/Event.cs new file mode 100644 index 00000000..a0b50f58 --- /dev/null +++ b/src/Sekiban.Pure/Events/Event.cs @@ -0,0 +1,10 @@ +namespace Sekiban.Pure.Events; + +public record Event( + TEventPayload Payload, + PartitionKeys PartitionKeys, + string SortableUniqueId, + int Version) : IEvent where TEventPayload : IEventPayload +{ + public IEventPayload GetPayload() => Payload; +} diff --git a/src/Sekiban.Pure/Events/EventOrNone.cs b/src/Sekiban.Pure/Events/EventOrNone.cs index 2e67b000..622115b1 100644 --- a/src/Sekiban.Pure/Events/EventOrNone.cs +++ b/src/Sekiban.Pure/Events/EventOrNone.cs @@ -1,5 +1,5 @@ using ResultBoxes; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Events; public record EventOrNone(IEventPayload? EventPayload, bool HasEvent) { diff --git a/src/Sekiban.Pure/Events/IEvent.cs b/src/Sekiban.Pure/Events/IEvent.cs new file mode 100644 index 00000000..d66fbea0 --- /dev/null +++ b/src/Sekiban.Pure/Events/IEvent.cs @@ -0,0 +1,11 @@ +using Sekiban.Core.Documents.ValueObjects; +namespace Sekiban.Pure.Events; + +public interface IEvent +{ + public int Version { get; } + public string SortableUniqueId { get; } + public PartitionKeys PartitionKeys { get; } + public SortableUniqueIdValue GetSortableUniqueId() => new(SortableUniqueId); + public IEventPayload GetPayload(); +} diff --git a/src/Sekiban.Pure/Events/IEventPayload.cs b/src/Sekiban.Pure/Events/IEventPayload.cs new file mode 100644 index 00000000..d8aea10c --- /dev/null +++ b/src/Sekiban.Pure/Events/IEventPayload.cs @@ -0,0 +1,3 @@ +namespace Sekiban.Pure.Events; + +public interface IEventPayload; diff --git a/src/Sekiban.Pure/Events/IEventTypes.cs b/src/Sekiban.Pure/Events/IEventTypes.cs new file mode 100644 index 00000000..7f9c875d --- /dev/null +++ b/src/Sekiban.Pure/Events/IEventTypes.cs @@ -0,0 +1,11 @@ +using ResultBoxes; +namespace Sekiban.Pure.Events; + +public interface IEventTypes +{ + public ResultBox GenerateTypedEvent( + IEventPayload payload, + PartitionKeys partitionKeys, + string sortableUniqueId, + int version); +} diff --git a/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs b/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs index 436c8754..12a72097 100644 --- a/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs +++ b/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs @@ -2,7 +2,3 @@ namespace Sekiban.Pure.Exception; public class SekibanAggregateTypeException(string message) : ApplicationException(message), ISekibanException; -public class SekibanAggregateTypeRestrictionException(string message) - : ApplicationException(message), ISekibanException; -public class SekibanEventTypeNotFoundException(string message) : ApplicationException(message), ISekibanException; -public class SekibanCommandHandlerNotMatchException(string message) : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs b/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs new file mode 100644 index 00000000..f2a16f7a --- /dev/null +++ b/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs @@ -0,0 +1,5 @@ +using Sekiban.Core.Exceptions; +namespace Sekiban.Pure.Exception; + +public class SekibanAggregateTypeRestrictionException(string message) + : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs b/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs new file mode 100644 index 00000000..6f517544 --- /dev/null +++ b/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs @@ -0,0 +1,4 @@ +using Sekiban.Core.Exceptions; +namespace Sekiban.Pure.Exception; + +public class SekibanCommandHandlerNotMatchException(string message) : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs b/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs new file mode 100644 index 00000000..f665153f --- /dev/null +++ b/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs @@ -0,0 +1,4 @@ +using Sekiban.Core.Exceptions; +namespace Sekiban.Pure.Exception; + +public class SekibanEventTypeNotFoundException(string message) : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Extensions/GuidExtensions.cs b/src/Sekiban.Pure/Extensions/GuidExtensions.cs new file mode 100644 index 00000000..e6dfe19d --- /dev/null +++ b/src/Sekiban.Pure/Extensions/GuidExtensions.cs @@ -0,0 +1,13 @@ +namespace Sekiban.Pure.Extensions; + +public static class GuidExtensions +{ + public static Guid CreateVersion7() + { +#if NET9_0 + return Guid.CreateVersion7(); +#else + return Guid.NewGuid(); +#endif + } +} diff --git a/src/Sekiban.Pure/Projectors/IAggregateProjector.cs b/src/Sekiban.Pure/Projectors/IAggregateProjector.cs new file mode 100644 index 00000000..30576ad2 --- /dev/null +++ b/src/Sekiban.Pure/Projectors/IAggregateProjector.cs @@ -0,0 +1,8 @@ +using Sekiban.Pure.Events; +namespace Sekiban.Pure.Projectors; + +public interface IAggregateProjector +{ + public IAggregatePayload Project(IAggregatePayload payload, IEvent ev); + public virtual string GetVersion() => "initial"; +} diff --git a/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs b/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs new file mode 100644 index 00000000..b1e8ac79 --- /dev/null +++ b/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs @@ -0,0 +1,8 @@ +using Sekiban.Pure.Events; +namespace Sekiban.Pure.Projectors; + +public class NoneAggregateProjector : IAggregateProjector +{ + public static NoneAggregateProjector Empty => new(); + public IAggregatePayload Project(IAggregatePayload payload, IEvent ev) => payload; +} diff --git a/src/Sekiban.Pure/Repositories/Repository.cs b/src/Sekiban.Pure/Repositories/Repository.cs new file mode 100644 index 00000000..eb61a4ce --- /dev/null +++ b/src/Sekiban.Pure/Repositories/Repository.cs @@ -0,0 +1,20 @@ +using ResultBoxes; +using Sekiban.Pure.Events; +using Sekiban.Pure.Projectors; +namespace Sekiban.Pure; + +public class Repository +{ + public static List Events { get; set; } = new(); + public Func Deserializer { get; set; } = s => throw new NotImplementedException(); + public Func Serializer { get; set; } = s => throw new NotImplementedException(); + public static ResultBox Load(PartitionKeys partitionKeys) + where TAggregateProjector : IAggregateProjector, new() => Load(partitionKeys, new TAggregateProjector()); + public static ResultBox Load(PartitionKeys partitionKeys, IAggregateProjector projector) => + ResultBox + .FromValue( + Events.Where(e => e.PartitionKeys.Equals(partitionKeys)).OrderBy(e => e.SortableUniqueId).ToList()) + .Conveyor(events => Aggregate.EmptyFromPartitionKeys(partitionKeys).Project(events, projector)); + + public static ResultBox Save(List events) => ResultBox.Start.Do(() => Events.AddRange(events)); +} diff --git a/src/Sekiban.Web/Common/RuntimeChecker.cs b/src/Sekiban.Web/Common/RuntimeChecker.cs new file mode 100644 index 00000000..4201e77e --- /dev/null +++ b/src/Sekiban.Web/Common/RuntimeChecker.cs @@ -0,0 +1,10 @@ +namespace Sekiban.Web.Common; + +public static class RuntimeChecker +{ + public static bool IsDotNet9OrLater() + { + var version = Environment.Version; + return version.Major >= 9; + } +} diff --git a/src/Sekiban.Web/Common/SekibanControllerFeatureProvider.cs b/src/Sekiban.Web/Common/SekibanControllerFeatureProvider.cs index 6b5b1648..aec34abc 100644 --- a/src/Sekiban.Web/Common/SekibanControllerFeatureProvider.cs +++ b/src/Sekiban.Web/Common/SekibanControllerFeatureProvider.cs @@ -7,15 +7,6 @@ using System.Reflection; namespace Sekiban.Web.Common; - -public static class RuntimeChecker -{ - public static bool IsDotNet9OrLater() - { - var version = Environment.Version; - return version.Major >= 9; - } -} /// /// Controller feature provider for sekiban commands and queries /// @@ -23,7 +14,8 @@ public class SekibanControllerFeatureProvider : IApplicationFeatureProvider _webDependencyDefinition = webDependencyDefinition; + public SekibanControllerFeatureProvider(IWebDependencyDefinition webDependencyDefinition) => + _webDependencyDefinition = webDependencyDefinition; public void PopulateFeature(IEnumerable parts, ControllerFeature feature) { @@ -32,7 +24,10 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur if (implementationType != null && implementationType.IsCommandHandlerType()) { feature.Controllers.Add( - _webDependencyDefinition.Options.BaseControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseControllerType + .MakeGenericType( implementationType.GetAggregatePayloadTypeFromCommandHandlerType(), implementationType.GetCommandTypeFromCommandHandlerType()) .GetTypeInfo()); @@ -40,13 +35,18 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur if (implementationType != null && implementationType.IsCommandWithHandlerType()) { var aggregateType = implementationType.GetAggregatePayloadTypeFromCommandWithHandlerType(); - if (aggregateType == typeof(SnapshotManager) || (aggregateType.IsGenericType && aggregateType.GetGenericTypeDefinition() == typeof(ITenantAggregatePayload<>))) + if (aggregateType == typeof(SnapshotManager) || + aggregateType.IsGenericType && + aggregateType.GetGenericTypeDefinition() == typeof(ITenantAggregatePayload<>)) { continue; } - + feature.Controllers.Add( - _webDependencyDefinition.Options.BaseControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseControllerType + .MakeGenericType( implementationType.GetAggregatePayloadTypeFromCommandWithHandlerType(), implementationType) .GetTypeInfo()); @@ -54,27 +54,44 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur } foreach (var aggregateType in _webDependencyDefinition.GetAggregatePayloadTypes()) { - if (aggregateType == typeof(SnapshotManager) || (aggregateType.IsGenericType && aggregateType.GetGenericTypeDefinition() == typeof(ITenantParentAggregatePayload<>))) + if (aggregateType == typeof(SnapshotManager) || + aggregateType.IsGenericType && + aggregateType.GetGenericTypeDefinition() == typeof(ITenantParentAggregatePayload<>)) { continue; } - - feature.Controllers.Add(_webDependencyDefinition.Options.BaseGetAggregateControllerType.MakeGenericType(aggregateType).GetTypeInfo()); + + feature.Controllers.Add( + _webDependencyDefinition + .Options + .BaseGetAggregateControllerType + .MakeGenericType(aggregateType) + .GetTypeInfo()); } foreach (var aggregateType in _webDependencyDefinition.GetAggregatePayloadSubtypes()) { - feature.Controllers.Add(_webDependencyDefinition.Options.BaseGetAggregateControllerType.MakeGenericType(aggregateType).GetTypeInfo()); + feature.Controllers.Add( + _webDependencyDefinition + .Options + .BaseGetAggregateControllerType + .MakeGenericType(aggregateType) + .GetTypeInfo()); } foreach (var projectionType in _webDependencyDefinition.GetSingleProjectionTypes()) { if (projectionType.IsSingleProjectionPayloadType()) { feature.Controllers.Add( - _webDependencyDefinition.Options.BaseSingleProjectionControllerType.MakeGenericType(projectionType).GetTypeInfo()); + _webDependencyDefinition + .Options + .BaseSingleProjectionControllerType + .MakeGenericType(projectionType) + .GetTypeInfo()); } } - - foreach (var projectionType in _webDependencyDefinition.GetAggregateListQueryTypes() + + foreach (var projectionType in _webDependencyDefinition + .GetAggregateListQueryTypes() .Concat(_webDependencyDefinition.GetSimpleAggregateListQueryTypes())) { if (!projectionType.IsAggregateListQueryType()) @@ -82,28 +99,33 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } var aggregateType = projectionType.GetAggregateTypeFromAggregateListQueryType(); - if (aggregateType == typeof(SnapshotManager) || (aggregateType.IsGenericType && aggregateType.GetGenericTypeDefinition() == typeof(ITenantAggregatePayload<>))) + if (aggregateType == typeof(SnapshotManager) || + aggregateType.IsGenericType && + aggregateType.GetGenericTypeDefinition() == typeof(ITenantAggregatePayload<>)) { continue; } - + // aggregate type is interface and runtime is dotnet 9, it will continue it will throw exception when generate swagger if (aggregateType.IsInterface && RuntimeChecker.IsDotNet9OrLater()) { continue; } - + feature.Controllers.Add( - _webDependencyDefinition.Options.BaseAggregateListQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseAggregateListQueryControllerType + .MakeGenericType( projectionType.GetAggregateTypeFromAggregateListQueryType(), projectionType, projectionType.GetParamTypeFromAggregateListQueryType(), projectionType.GetResponseTypeFromAggregateListQueryType()) .GetTypeInfo()); } - - - + + + foreach (var projectionType in _webDependencyDefinition.GetAggregateQueryTypes()) { if (!projectionType.IsAggregateQueryType()) @@ -111,14 +133,17 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseAggregateQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseAggregateQueryControllerType + .MakeGenericType( projectionType.GetAggregateTypeFromAggregateQueryType(), projectionType, projectionType.GetParamTypeFromAggregateQueryType(), projectionType.GetResponseTypeFromAggregateQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetSingleProjectionListQueryTypes()) { if (!queryType.IsSingleProjectionListQueryType()) @@ -126,14 +151,17 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseSingleProjectionListQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseSingleProjectionListQueryControllerType + .MakeGenericType( queryType.GetSingleProjectionTypeFromSingleProjectionListQueryType(), queryType, queryType.GetParamTypeFromSingleProjectionListQueryType(), queryType.GetResponseTypeFromSingleProjectionListQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetSingleProjectionQueryTypes()) { if (!queryType.IsSingleProjectionQueryType()) @@ -141,14 +169,17 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseSingleProjectionQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseSingleProjectionQueryControllerType + .MakeGenericType( queryType.GetSingleProjectionTypeFromSingleProjectionQueryType(), queryType, queryType.GetParamTypeFromSingleProjectionQueryType(), queryType.GetResponseTypeFromSingleProjectionQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetMultiProjectionListQueryTypes()) { if (!queryType.IsMultiProjectionListQueryType()) @@ -156,14 +187,17 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseMultiProjectionListQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseMultiProjectionListQueryControllerType + .MakeGenericType( queryType.GetMultiProjectionTypeFromMultiProjectionListQueryType(), queryType, queryType.GetParamTypeFromMultiProjectionListQueryType(), queryType.GetResponseTypeFromMultiProjectionListQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetMultiProjectionQueryTypes()) { if (!queryType.IsMultiProjectionQueryType()) @@ -171,14 +205,17 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseMultiProjectionQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseMultiProjectionQueryControllerType + .MakeGenericType( queryType.GetMultiProjectionTypeFromMultiProjectionQueryType(), queryType, queryType.GetParamTypeFromMultiProjectionQueryType(), queryType.GetResponseTypeFromMultiProjectionQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetGeneralListQueryTypes()) { if (!queryType.IsGeneralListQueryType()) @@ -186,13 +223,16 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseGeneralListQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseGeneralListQueryControllerType + .MakeGenericType( queryType, queryType.GetParamTypeFromGeneralListQueryType(), queryType.GetResponseTypeFromGeneralListQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetGeneralQueryTypes()) { if (!queryType.IsGeneralQueryType()) @@ -200,13 +240,16 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseGeneralQueryControllerType.MakeGenericType( + _webDependencyDefinition + .Options + .BaseGeneralQueryControllerType + .MakeGenericType( queryType, queryType.GetParamTypeFromGeneralQueryType(), queryType.GetResponseTypeFromGeneralQueryType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetNextQueryTypes()) { if (!queryType.IsQueryNextType()) @@ -214,10 +257,13 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseNextQueryControllerType.MakeGenericType(queryType, queryType.GetResponseTypeFromQueryNextType()) + _webDependencyDefinition + .Options + .BaseNextQueryControllerType + .MakeGenericType(queryType, queryType.GetResponseTypeFromQueryNextType()) .GetTypeInfo()); } - + foreach (var queryType in _webDependencyDefinition.GetNextListQueryTypes()) { if (!queryType.IsListQueryNextType()) @@ -225,11 +271,14 @@ public void PopulateFeature(IEnumerable parts, ControllerFeatur continue; } feature.Controllers.Add( - _webDependencyDefinition.Options.BaseNextListQueryControllerType + _webDependencyDefinition + .Options + .BaseNextListQueryControllerType .MakeGenericType(queryType, queryType.GetResponseTypeFromQueryNextType()) .GetTypeInfo()); } - - feature.Controllers.Add(_webDependencyDefinition.Options.BaseIndexControllerType.MakeGenericType(typeof(object)).GetTypeInfo()); + + feature.Controllers.Add( + _webDependencyDefinition.Options.BaseIndexControllerType.MakeGenericType(typeof(object)).GetTypeInfo()); } } diff --git a/tests/AotTechnicalTesting/Definitions/def.cs b/tests/AotTechnicalTesting/Definitions/SerializationModeOptionsContext.cs similarity index 69% rename from tests/AotTechnicalTesting/Definitions/def.cs rename to tests/AotTechnicalTesting/Definitions/SerializationModeOptionsContext.cs index d39b7f89..9921dff1 100644 --- a/tests/AotTechnicalTesting/Definitions/def.cs +++ b/tests/AotTechnicalTesting/Definitions/SerializationModeOptionsContext.cs @@ -1,14 +1,6 @@ using System.Text.Json.Serialization; namespace AotTechnicalTesting.Definitions; -public class WeatherForecast -{ - public DateTime Date { get; set; } - public int TemperatureCelsius { get; set; } - public string? Summary { get; set; } -} - - [JsonSourceGenerationOptions( WriteIndented = true, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, @@ -17,6 +9,3 @@ public class WeatherForecast internal partial class SerializationModeOptionsContext : JsonSerializerContext { } - - - diff --git a/tests/AotTechnicalTesting/Definitions/WeatherForecast.cs b/tests/AotTechnicalTesting/Definitions/WeatherForecast.cs new file mode 100644 index 00000000..d6b6ff0e --- /dev/null +++ b/tests/AotTechnicalTesting/Definitions/WeatherForecast.cs @@ -0,0 +1,8 @@ +namespace AotTechnicalTesting.Definitions; + +public class WeatherForecast +{ + public DateTime Date { get; set; } + public int TemperatureCelsius { get; set; } + public string? Summary { get; set; } +} diff --git a/tests/Pure.Domain.Test/UnitTest1.cs b/tests/Pure.Domain.Test/UnitTest1.cs index 7536adbc..c44c4d1c 100644 --- a/tests/Pure.Domain.Test/UnitTest1.cs +++ b/tests/Pure.Domain.Test/UnitTest1.cs @@ -1,7 +1,11 @@ using Pure.Domain.Generated; using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Command.Resources; +using Sekiban.Pure.Events; using Sekiban.Pure.Exception; +using Sekiban.Pure.Projectors; namespace Pure.Domain.Test; public class UnitTest1 From b4311f802a3d74420e0606bba067b6da3ad6fecf Mon Sep 17 00:00:00 2001 From: Tomohisa Takaoka Date: Mon, 30 Dec 2024 22:25:36 -0800 Subject: [PATCH 2/3] Adding namespaces --- internalUsages/Pure.Domain/ChangeBranchName.cs | 1 + internalUsages/Pure.Domain/ConfirmUser.cs | 1 + internalUsages/Pure.Domain/CreateShoppingCart.cs | 1 + internalUsages/Pure.Domain/RegisterBranch.cs | 1 + internalUsages/Pure.Domain/RegisterUser.cs | 1 + internalUsages/Pure.Domain/RevokeUser.cs | 1 + .../CommandExecutionExtensionGenerator.cs | 1 + src/Sekiban.Pure/Command/Executor/CommandContext.cs | 2 +- src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs | 2 +- src/Sekiban.Pure/Command/Executor/CommandExecuted.cs | 2 +- src/Sekiban.Pure/Command/Executor/CommandExecutor.cs | 2 +- src/Sekiban.Pure/Command/Executor/CommandResponse.cs | 2 +- src/Sekiban.Pure/Command/Executor/ICommandContext.cs | 2 +- src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs | 2 +- .../Command/Handlers/ICommandContextWithoutState.cs | 1 + src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs | 1 + src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs | 1 + src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs | 1 + .../Command/Handlers/ICommandHandlerInjectionAsync.cs | 1 + src/Sekiban.Pure/Command/Resources/CommandResource.cs | 1 + src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs | 1 + src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs | 1 + .../Command/Resources/CommandResourceWithInjectTask.cs | 1 + tests/Pure.Domain.Test/UnitTest1.cs | 1 + 24 files changed, 24 insertions(+), 7 deletions(-) diff --git a/internalUsages/Pure.Domain/ChangeBranchName.cs b/internalUsages/Pure.Domain/ChangeBranchName.cs index f48b618e..94ae2fad 100644 --- a/internalUsages/Pure.Domain/ChangeBranchName.cs +++ b/internalUsages/Pure.Domain/ChangeBranchName.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/ConfirmUser.cs b/internalUsages/Pure.Domain/ConfirmUser.cs index c96600cc..a264e4e3 100644 --- a/internalUsages/Pure.Domain/ConfirmUser.cs +++ b/internalUsages/Pure.Domain/ConfirmUser.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/CreateShoppingCart.cs b/internalUsages/Pure.Domain/CreateShoppingCart.cs index 3022bc5b..479c9973 100644 --- a/internalUsages/Pure.Domain/CreateShoppingCart.cs +++ b/internalUsages/Pure.Domain/CreateShoppingCart.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/RegisterBranch.cs b/internalUsages/Pure.Domain/RegisterBranch.cs index 7bacde21..fefa837c 100644 --- a/internalUsages/Pure.Domain/RegisterBranch.cs +++ b/internalUsages/Pure.Domain/RegisterBranch.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/RegisterUser.cs b/internalUsages/Pure.Domain/RegisterUser.cs index 0e4897c6..53124c0c 100644 --- a/internalUsages/Pure.Domain/RegisterUser.cs +++ b/internalUsages/Pure.Domain/RegisterUser.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/RevokeUser.cs b/internalUsages/Pure.Domain/RevokeUser.cs index fa829ffa..4cf559a4 100644 --- a/internalUsages/Pure.Domain/RevokeUser.cs +++ b/internalUsages/Pure.Domain/RevokeUser.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs b/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs index f49845ff..a686cee7 100644 --- a/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs +++ b/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs @@ -252,6 +252,7 @@ private string GenerateSourceCode(ImmutableArray event sb.AppendLine("using Sekiban.Pure.Events;"); sb.AppendLine("using Sekiban.Pure.Command.Handlers;"); sb.AppendLine("using Sekiban.Pure.Command.Resources;"); + sb.AppendLine("using Sekiban.Pure.Command.Executor;"); sb.AppendLine(); sb.AppendLine($"namespace {rootNamespace}.Generated"); sb.AppendLine("{"); diff --git a/src/Sekiban.Pure/Command/Executor/CommandContext.cs b/src/Sekiban.Pure/Command/Executor/CommandContext.cs index 86a2c1fd..940d5428 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandContext.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandContext.cs @@ -3,7 +3,7 @@ using Sekiban.Core.Shared; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public class CommandContext( Aggregate aggregate, diff --git a/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs b/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs index 518f0c76..a3496115 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs @@ -3,7 +3,7 @@ using Sekiban.Core.Shared; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public record CommandContextWithoutState(PartitionKeys PartitionKeys, IEventTypes EventTypes) : ICommandContextWithoutState diff --git a/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs b/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs index a82b1af0..b33437a8 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs @@ -1,4 +1,4 @@ using Sekiban.Pure.Events; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public record CommandExecuted(PartitionKeys PartitionKeys, string LastSortableUniqueId, List ProducedEvents); diff --git a/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs b/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs index 2ad5b3b3..284165d9 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs @@ -7,7 +7,7 @@ using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; using System.Reflection; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public class CommandExecutor : ICommandExecutor { diff --git a/src/Sekiban.Pure/Command/Executor/CommandResponse.cs b/src/Sekiban.Pure/Command/Executor/CommandResponse.cs index d2a7faf1..80c7c14e 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandResponse.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandResponse.cs @@ -1,4 +1,4 @@ using Sekiban.Pure.Events; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public record CommandResponse(PartitionKeys PartitionKeys, List Events, int Version); diff --git a/src/Sekiban.Pure/Command/Executor/ICommandContext.cs b/src/Sekiban.Pure/Command/Executor/ICommandContext.cs index 802af1d0..2251534b 100644 --- a/src/Sekiban.Pure/Command/Executor/ICommandContext.cs +++ b/src/Sekiban.Pure/Command/Executor/ICommandContext.cs @@ -1,7 +1,7 @@ using ResultBoxes; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public interface ICommandContext : ICommandContextWithoutState where TAggregatePayload : IAggregatePayload diff --git a/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs b/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs index 5d04ce00..0761d28c 100644 --- a/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs +++ b/src/Sekiban.Pure/Command/Executor/ICommandExecutor.cs @@ -1,3 +1,3 @@ -namespace Sekiban.Pure; +namespace Sekiban.Pure.Command.Executor; public interface ICommandExecutor; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs b/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs index f610ca8b..8b6b46c1 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs index 77f949d5..82b10e31 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs index a7f9d48f..0ec7e71f 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs index 415fe84f..fbce6712 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs index 78e891be..3bfce480 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResource.cs b/src/Sekiban.Pure/Command/Resources/CommandResource.cs index f8ea91f2..3bf9b9d0 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResource.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResource.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs index 7ca76232..64e2ff65 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs index be47abd6..296e6bd4 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs index a13f08f9..79b5bc99 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/tests/Pure.Domain.Test/UnitTest1.cs b/tests/Pure.Domain.Test/UnitTest1.cs index c44c4d1c..ee7a2769 100644 --- a/tests/Pure.Domain.Test/UnitTest1.cs +++ b/tests/Pure.Domain.Test/UnitTest1.cs @@ -1,6 +1,7 @@ using Pure.Domain.Generated; using ResultBoxes; using Sekiban.Pure; +using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Command.Resources; using Sekiban.Pure.Events; From 9f35b50ae5a627ac2efcce47a30f89eabdcb2459 Mon Sep 17 00:00:00 2001 From: Tomohisa Takaoka Date: Mon, 30 Dec 2024 22:47:27 -0800 Subject: [PATCH 3/3] completed split --- .../Aggregates/MultiTenantDependency.cs | 1 - internalUsages/Pure.Domain/Branch.cs | 2 +- internalUsages/Pure.Domain/BranchProjector.cs | 2 +- .../Pure.Domain/BuyingShoppingCart.cs | 2 +- .../Pure.Domain/ChangeBranchName.cs | 3 ++- internalUsages/Pure.Domain/ConfirmUser.cs | 2 +- internalUsages/Pure.Domain/ConfirmedUser.cs | 2 +- .../Pure.Domain/CreateShoppingCart.cs | 3 ++- .../PaymentProcessingShoppingCart.cs | 2 +- internalUsages/Pure.Domain/RegisterBranch.cs | 3 ++- internalUsages/Pure.Domain/RegisterBranch3.cs | 2 +- internalUsages/Pure.Domain/RegisterUser.cs | 3 ++- internalUsages/Pure.Domain/RevokeUser.cs | 2 +- .../Pure.Domain/ShoppingCartProjector.cs | 2 +- internalUsages/Pure.Domain/UnconfirmedUser.cs | 2 +- internalUsages/Pure.Domain/UserProjector.cs | 2 +- .../AspireCosmosDbFactory.cs | 6 +++-- .../SekibanEventSourcingDependency.cs | 2 -- .../Documents/PostgresDocumentWriter.cs | 6 ++--- .../CommandExecutionExtensionGenerator.cs | 2 ++ .../EventTypesGenerator.cs | 1 + src/Sekiban.Pure/Aggregates/Aggregate.cs | 3 ++- .../Aggregates/EmptyAggregatePayload.cs | 2 +- src/Sekiban.Pure/Aggregates/IAggregate.cs | 4 +-- .../Aggregates/IAggregatePayload.cs | 2 +- .../Command/Executor/CommandContext.cs | 5 ++-- .../Executor/CommandContextWithoutState.cs | 2 +- .../Command/Executor/CommandExecuted.cs | 1 + .../Command/Executor/CommandExecutor.cs | 4 ++- .../Command/Executor/CommandResponse.cs | 1 + .../Command/Executor/ICommandContext.cs | 1 + .../Handlers/ICommandContextWithoutState.cs | 1 + .../Command/Handlers/ICommandHandler.cs | 1 + .../Command/Handlers/ICommandHandlerAsync.cs | 1 + .../Command/Handlers/ICommandHandlerCommon.cs | 1 + .../Handlers/ICommandHandlerInjection.cs | 1 + .../Handlers/ICommandHandlerInjectionAsync.cs | 1 + .../Handlers/ICommandPartitionSpecifier.cs | 1 + .../ICommandWithAggregateRestriction.cs | 1 + .../Command/Handlers/ICommandWithHandler.cs | 1 + .../Handlers/ICommandWithHandlerAsync.cs | 1 + .../Handlers/ICommandWithHandlerCommon.cs | 1 + .../Handlers/ICommandWithHandlerInjection.cs | 1 + .../ICommandWithHandlerInjectionAsync.cs | 1 + .../Command/Resources/CommandResource.cs | 2 ++ .../Resources/CommandResourcePublishOnly.cs | 1 + .../CommandResourcePublishOnlyTask.cs | 1 + .../CommandResourcePublishOnlyWithInject.cs | 1 + ...ommandResourcePublishOnlyWithInjectTask.cs | 1 + .../Command/Resources/CommandResourceTask.cs | 2 ++ .../Resources/CommandResourceWithInject.cs | 2 ++ .../CommandResourceWithInjectTask.cs | 2 ++ .../Command/Resources/ICommandResource.cs | 1 + src/Sekiban.Pure/Documents/DocumentType.cs | 2 +- src/Sekiban.Pure/Documents/IDocument.cs | 3 +-- src/Sekiban.Pure/Documents/PartitionKeys.cs | 2 +- .../Documents/SortableUniqueIdValue.cs | 2 +- .../Documents/TenantPartitionKeys.cs | 2 +- src/Sekiban.Pure/Events/EmptyEventTypes.cs | 1 + src/Sekiban.Pure/Events/Event.cs | 1 + src/Sekiban.Pure/Events/IEvent.cs | 2 +- src/Sekiban.Pure/Events/IEventTypes.cs | 1 + .../Exception/ISekibanException.cs | 2 +- .../SekibanAggregateTypeException.cs | 1 - ...ekibanAggregateTypeRestrictionException.cs | 1 - .../SekibanCommandHandlerNotMatchException.cs | 1 - .../SekibanEventTypeNotFoundException.cs | 1 - .../Projectors/IAggregateProjector.cs | 1 + .../Projectors/NoneAggregateProjector.cs | 1 + src/Sekiban.Pure/Repositories/Repository.cs | 4 ++- tests/Pure.Domain.Test/UnitTest1.cs | 2 ++ .../Stories/CosmosAggregateSubtypeTest.cs | 1 - .../Stories/CosmosAggregateSubtypeTypeR.cs | 7 ++---- .../Stories/CosmosCustomerDbStoryBasic.cs | 1 - .../Stories/CosmosEventOrderSpec.cs | 1 - .../Stories/CosmosInheritInSubtypesTest.cs | 3 +-- .../CosmosMultiProjectionSnapshotTests.cs | 7 ++---- .../Stories/CosmosMultiTenantDocumentTests.cs | 1 - .../CosmosMultipleEventsInOneClassTest.cs | 1 - .../Stories/CosmosPerformanceTest.cs | 1 - .../Stories/CosmosResultBoxSpec.cs | 3 +-- .../Stories/InheritedSubtypeTests.cs | 23 +++++++++++------ .../Stories/MultipleDbStoryTest.cs | 21 +++++++++++----- .../Stories/SimpleQueryTest.cs | 25 ++++--------------- .../Tests/CustomerDbStoryBasicDynamo.cs | 1 - .../Tests/DynamoAggregateSubtypeTest.cs | 1 - .../Tests/DynamoAggregateSubtypeTypeR.cs | 7 ++---- .../DynamoMultiProjectionSnapshotTests.cs | 7 ++---- .../Tests/DynamoMultiTenantDocumentTests.cs | 1 - .../DynamoMultipleEventsInOneClassTest.cs | 1 - .../Tests/DynamoQueryPerformanceTest.cs | 1 - .../Tests/EventOrderSpecDynamo.cs | 1 - .../Tests/AggregateSubtypeTestPostgres.cs | 7 ++---- .../Tests/AggregateSubtypeTypeRPostgres.cs | 7 ++---- .../Tests/CustomerDbStoryBasicPostgres.cs | 1 - .../Tests/EventOrderSpecPostgres.cs | 1 - .../MultiProjectionSnapshotTestsPostgres.cs | 5 ++-- .../Tests/MultiTenantDocumentTestsPostgres.cs | 7 ++---- .../MultipleEventsInOneClassTestPostgres.cs | 5 ++-- .../Tests/QueryPerformanceTestBasePostgres.cs | 7 ++---- 100 files changed, 147 insertions(+), 141 deletions(-) diff --git a/internalUsages/MultiTenant.Domain/Aggregates/MultiTenantDependency.cs b/internalUsages/MultiTenant.Domain/Aggregates/MultiTenantDependency.cs index d9d57245..f4740a77 100644 --- a/internalUsages/MultiTenant.Domain/Aggregates/MultiTenantDependency.cs +++ b/internalUsages/MultiTenant.Domain/Aggregates/MultiTenantDependency.cs @@ -1,5 +1,4 @@ using MultiTenant.Domain.Aggregates.Clients; -using MultiTenant.Domain.Aggregates.Clients.Commands; using MultiTenant.Domain.Aggregates.Clients.Queries; using Sekiban.Core.Dependency; using System.Reflection; diff --git a/internalUsages/Pure.Domain/Branch.cs b/internalUsages/Pure.Domain/Branch.cs index 6905dee2..0893826e 100644 --- a/internalUsages/Pure.Domain/Branch.cs +++ b/internalUsages/Pure.Domain/Branch.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; namespace Pure.Domain; public record Branch(string Name) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/BranchProjector.cs b/internalUsages/Pure.Domain/BranchProjector.cs index 12d9dbe4..28469083 100644 --- a/internalUsages/Pure.Domain/BranchProjector.cs +++ b/internalUsages/Pure.Domain/BranchProjector.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/BuyingShoppingCart.cs b/internalUsages/Pure.Domain/BuyingShoppingCart.cs index 4f7a9c21..4d825a85 100644 --- a/internalUsages/Pure.Domain/BuyingShoppingCart.cs +++ b/internalUsages/Pure.Domain/BuyingShoppingCart.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; namespace Pure.Domain; public record BuyingShoppingCart(Guid UserId, List Items) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/ChangeBranchName.cs b/internalUsages/Pure.Domain/ChangeBranchName.cs index 94ae2fad..b230b688 100644 --- a/internalUsages/Pure.Domain/ChangeBranchName.cs +++ b/internalUsages/Pure.Domain/ChangeBranchName.cs @@ -1,7 +1,8 @@ using ResultBoxes; -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/ConfirmUser.cs b/internalUsages/Pure.Domain/ConfirmUser.cs index a264e4e3..c5436d02 100644 --- a/internalUsages/Pure.Domain/ConfirmUser.cs +++ b/internalUsages/Pure.Domain/ConfirmUser.cs @@ -1,7 +1,7 @@ using ResultBoxes; -using Sekiban.Pure; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/ConfirmedUser.cs b/internalUsages/Pure.Domain/ConfirmedUser.cs index b9630b5a..067a1bb9 100644 --- a/internalUsages/Pure.Domain/ConfirmedUser.cs +++ b/internalUsages/Pure.Domain/ConfirmedUser.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; namespace Pure.Domain; public record ConfirmedUser(string Name, string Email) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/CreateShoppingCart.cs b/internalUsages/Pure.Domain/CreateShoppingCart.cs index 479c9973..c8dc014b 100644 --- a/internalUsages/Pure.Domain/CreateShoppingCart.cs +++ b/internalUsages/Pure.Domain/CreateShoppingCart.cs @@ -1,7 +1,8 @@ using ResultBoxes; -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs b/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs index 176896d6..e2128afd 100644 --- a/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs +++ b/internalUsages/Pure.Domain/PaymentProcessingShoppingCart.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; namespace Pure.Domain; public record PaymentProcessingShoppingCart( diff --git a/internalUsages/Pure.Domain/RegisterBranch.cs b/internalUsages/Pure.Domain/RegisterBranch.cs index fefa837c..4795eaaa 100644 --- a/internalUsages/Pure.Domain/RegisterBranch.cs +++ b/internalUsages/Pure.Domain/RegisterBranch.cs @@ -1,7 +1,8 @@ using ResultBoxes; -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/RegisterBranch3.cs b/internalUsages/Pure.Domain/RegisterBranch3.cs index fdae07e6..630c236e 100644 --- a/internalUsages/Pure.Domain/RegisterBranch3.cs +++ b/internalUsages/Pure.Domain/RegisterBranch3.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Handlers; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/RegisterUser.cs b/internalUsages/Pure.Domain/RegisterUser.cs index 53124c0c..90da9752 100644 --- a/internalUsages/Pure.Domain/RegisterUser.cs +++ b/internalUsages/Pure.Domain/RegisterUser.cs @@ -1,7 +1,8 @@ using ResultBoxes; -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/RevokeUser.cs b/internalUsages/Pure.Domain/RevokeUser.cs index 4cf559a4..91b229a1 100644 --- a/internalUsages/Pure.Domain/RevokeUser.cs +++ b/internalUsages/Pure.Domain/RevokeUser.cs @@ -1,7 +1,7 @@ using ResultBoxes; -using Sekiban.Pure; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/ShoppingCartProjector.cs b/internalUsages/Pure.Domain/ShoppingCartProjector.cs index 8c7841db..4892bdc9 100644 --- a/internalUsages/Pure.Domain/ShoppingCartProjector.cs +++ b/internalUsages/Pure.Domain/ShoppingCartProjector.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Pure.Domain; diff --git a/internalUsages/Pure.Domain/UnconfirmedUser.cs b/internalUsages/Pure.Domain/UnconfirmedUser.cs index b282b179..d9bba3c5 100644 --- a/internalUsages/Pure.Domain/UnconfirmedUser.cs +++ b/internalUsages/Pure.Domain/UnconfirmedUser.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; namespace Pure.Domain; public record UnconfirmedUser(string Name, string Email) : IAggregatePayload; diff --git a/internalUsages/Pure.Domain/UserProjector.cs b/internalUsages/Pure.Domain/UserProjector.cs index a75caf9e..f412524e 100644 --- a/internalUsages/Pure.Domain/UserProjector.cs +++ b/internalUsages/Pure.Domain/UserProjector.cs @@ -1,4 +1,4 @@ -using Sekiban.Pure; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Pure.Domain; diff --git a/src/Sekiban.Aspire.Infrastructure.Cosmos/AspireCosmosDbFactory.cs b/src/Sekiban.Aspire.Infrastructure.Cosmos/AspireCosmosDbFactory.cs index 54a5669f..52794f6d 100644 --- a/src/Sekiban.Aspire.Infrastructure.Cosmos/AspireCosmosDbFactory.cs +++ b/src/Sekiban.Aspire.Infrastructure.Cosmos/AspireCosmosDbFactory.cs @@ -3,7 +3,6 @@ using Sekiban.Core.Aggregate; using Sekiban.Core.Cache; using Sekiban.Core.Documents; -using Sekiban.Infrastructure.Azure.Storage.Blobs; using Sekiban.Infrastructure.Cosmos; namespace Sekiban.Aspire.Infrastructure.Cosmos; @@ -36,7 +35,10 @@ public async Task CosmosActionAsync( return await cosmosDbFactory.CosmosActionAsync(documentType, containerGroup, cosmosAction); } - public async Task CosmosActionAsync(DocumentType documentType, AggregateContainerGroup containerGroup, Func cosmosAction) + public async Task CosmosActionAsync( + DocumentType documentType, + AggregateContainerGroup containerGroup, + Func cosmosAction) { cosmosDbFactory.SearchCosmosClientAsync = GetCosmosClientFromAspire; await cosmosDbFactory.CosmosActionAsync(documentType, containerGroup, cosmosAction); diff --git a/src/Sekiban.Core.DotNet/Dependency/SekibanEventSourcingDependency.cs b/src/Sekiban.Core.DotNet/Dependency/SekibanEventSourcingDependency.cs index 4f899682..1778ebf8 100644 --- a/src/Sekiban.Core.DotNet/Dependency/SekibanEventSourcingDependency.cs +++ b/src/Sekiban.Core.DotNet/Dependency/SekibanEventSourcingDependency.cs @@ -1,6 +1,4 @@ -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; using Sekiban.Core.Command; using Sekiban.Core.Setting; using Sekiban.Core.Shared; diff --git a/src/Sekiban.Infrastructure.Postgres/Documents/PostgresDocumentWriter.cs b/src/Sekiban.Infrastructure.Postgres/Documents/PostgresDocumentWriter.cs index effe1158..4b0abe00 100644 --- a/src/Sekiban.Infrastructure.Postgres/Documents/PostgresDocumentWriter.cs +++ b/src/Sekiban.Infrastructure.Postgres/Documents/PostgresDocumentWriter.cs @@ -4,7 +4,6 @@ using Sekiban.Core.Documents.Pools; using Sekiban.Core.Events; using Sekiban.Core.Exceptions; -using Sekiban.Core.PubSub; using Sekiban.Core.Setting; using Sekiban.Core.Shared; using Sekiban.Core.Snapshot; @@ -12,9 +11,8 @@ using System.Text; namespace Sekiban.Infrastructure.Postgres.Documents; -public class PostgresDocumentWriter( - PostgresDbFactory dbFactory, - IBlobAccessor blobAccessor) : IDocumentPersistentWriter, IEventPersistentWriter +public class PostgresDocumentWriter(PostgresDbFactory dbFactory, IBlobAccessor blobAccessor) + : IDocumentPersistentWriter, IEventPersistentWriter { public async Task SaveItemAsync(TDocument document, IWriteDocumentStream writeDocumentStream) where TDocument : IDocument diff --git a/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs b/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs index a686cee7..aeb18e64 100644 --- a/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs +++ b/src/Sekiban.Pure.SourceGenerator/CommandExecutionExtensionGenerator.cs @@ -253,6 +253,8 @@ private string GenerateSourceCode(ImmutableArray event sb.AppendLine("using Sekiban.Pure.Command.Handlers;"); sb.AppendLine("using Sekiban.Pure.Command.Resources;"); sb.AppendLine("using Sekiban.Pure.Command.Executor;"); + sb.AppendLine("using Sekiban.Pure.Aggregates;"); + sb.AppendLine("using Sekiban.Pure.Documents;"); sb.AppendLine(); sb.AppendLine($"namespace {rootNamespace}.Generated"); sb.AppendLine("{"); diff --git a/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs b/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs index 7372844c..cce6ef81 100644 --- a/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs +++ b/src/Sekiban.Pure.SourceGenerator/EventTypesGenerator.cs @@ -79,6 +79,7 @@ private string GenerateSourceCode(ImmutableArray event sb.AppendLine("using Sekiban.Pure;"); sb.AppendLine("using Sekiban.Pure.Exception;"); sb.AppendLine("using Sekiban.Pure.Events;"); + sb.AppendLine("using Sekiban.Pure.Documents;"); sb.AppendLine(); sb.AppendLine($"namespace {rootNamespace}.Generated"); diff --git a/src/Sekiban.Pure/Aggregates/Aggregate.cs b/src/Sekiban.Pure/Aggregates/Aggregate.cs index c0cef0e8..0df3e415 100644 --- a/src/Sekiban.Pure/Aggregates/Aggregate.cs +++ b/src/Sekiban.Pure/Aggregates/Aggregate.cs @@ -1,8 +1,9 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Exception; using Sekiban.Pure.Projectors; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Aggregates; public record Aggregate( IAggregatePayload Payload, diff --git a/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs b/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs index 79ff17e7..d200a187 100644 --- a/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs +++ b/src/Sekiban.Pure/Aggregates/EmptyAggregatePayload.cs @@ -1,4 +1,4 @@ -namespace Sekiban.Pure; +namespace Sekiban.Pure.Aggregates; public record EmptyAggregatePayload : IAggregatePayload { diff --git a/src/Sekiban.Pure/Aggregates/IAggregate.cs b/src/Sekiban.Pure/Aggregates/IAggregate.cs index 44eda0ba..daabcef3 100644 --- a/src/Sekiban.Pure/Aggregates/IAggregate.cs +++ b/src/Sekiban.Pure/Aggregates/IAggregate.cs @@ -1,6 +1,6 @@ using ResultBoxes; -using Sekiban.Core.Documents.ValueObjects; -namespace Sekiban.Pure; +using Sekiban.Pure.Documents; +namespace Sekiban.Pure.Aggregates; public interface IAggregate { diff --git a/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs b/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs index 488ef6b7..c5a95acb 100644 --- a/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs +++ b/src/Sekiban.Pure/Aggregates/IAggregatePayload.cs @@ -1,3 +1,3 @@ -namespace Sekiban.Pure; +namespace Sekiban.Pure.Aggregates; public interface IAggregatePayload; diff --git a/src/Sekiban.Pure/Command/Executor/CommandContext.cs b/src/Sekiban.Pure/Command/Executor/CommandContext.cs index 940d5428..fa9046e6 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandContext.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandContext.cs @@ -1,6 +1,7 @@ using ResultBoxes; -using Sekiban.Core.Documents.ValueObjects; using Sekiban.Core.Shared; +using Sekiban.Pure.Aggregates; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Executor; @@ -14,7 +15,6 @@ public class CommandContext( public IAggregateProjector Projector { get; } = projector; public IEventTypes EventTypes { get; } = eventTypes; public List Events { get; } = new(); - public PartitionKeys GetPartitionKeys() => Aggregate.PartitionKeys; public int GetNextVersion() => Aggregate.Version + 1; public int GetCurrentVersion() => Aggregate.Version; public IAggregate GetAggregateCommon() => Aggregate; @@ -34,4 +34,5 @@ public ResultBox AppendEvent(IEventPayload eventPayload) Events.Add(ev); return EventOrNone.Empty; } + public PartitionKeys GetPartitionKeys() => Aggregate.PartitionKeys; } diff --git a/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs b/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs index a3496115..71d6b3fb 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandContextWithoutState.cs @@ -1,7 +1,7 @@ using ResultBoxes; -using Sekiban.Core.Documents.ValueObjects; using Sekiban.Core.Shared; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Executor; diff --git a/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs b/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs index b33437a8..95b96d7c 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandExecuted.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Executor; diff --git a/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs b/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs index 284165d9..6aa14460 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandExecutor.cs @@ -1,10 +1,12 @@ using ResultBoxes; -using Sekiban.Core.Documents.ValueObjects; using Sekiban.Core.Shared; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Exception; using Sekiban.Pure.Projectors; +using Sekiban.Pure.Repositories; using System.Diagnostics.CodeAnalysis; using System.Reflection; namespace Sekiban.Pure.Command.Executor; diff --git a/src/Sekiban.Pure/Command/Executor/CommandResponse.cs b/src/Sekiban.Pure/Command/Executor/CommandResponse.cs index 80c7c14e..3d2f324c 100644 --- a/src/Sekiban.Pure/Command/Executor/CommandResponse.cs +++ b/src/Sekiban.Pure/Command/Executor/CommandResponse.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Executor; diff --git a/src/Sekiban.Pure/Command/Executor/ICommandContext.cs b/src/Sekiban.Pure/Command/Executor/ICommandContext.cs index 2251534b..57718c10 100644 --- a/src/Sekiban.Pure/Command/Executor/ICommandContext.cs +++ b/src/Sekiban.Pure/Command/Executor/ICommandContext.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Executor; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs b/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs index 8b6b46c1..364bff2b 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandContextWithoutState.cs @@ -1,5 +1,6 @@ using ResultBoxes; using Sekiban.Pure.Command.Executor; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs index 82b10e31..6cf4bdb4 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandler.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs index 0ec7e71f..a261c52b 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerAsync.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs index 0fe9015c..46a996c6 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerCommon.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; namespace Sekiban.Pure.Command.Handlers; public interface diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs index fbce6712..e2911141 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjection.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs index 3bfce480..031c47e3 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandHandlerInjectionAsync.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs b/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs index bc67c822..b426be20 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandPartitionSpecifier.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Documents; namespace Sekiban.Pure.Command.Handlers; public interface ICommandPartitionSpecifier where TCommand : ICommand, IEquatable diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs index 51a1ed9d..d29075d0 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithAggregateRestriction.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; namespace Sekiban.Pure.Command.Handlers; public interface ICommandWithAggregateRestriction : ICommand diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs index 5a9de8f9..023c262f 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandler.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs index 9e194350..6315e6cb 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerAsync.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs index ab99a4ae..888ff00b 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerCommon.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; namespace Sekiban.Pure.Command.Handlers; public interface ICommandWithHandlerCommon : ICommand, diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs index b0820f74..78b39cd9 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjection.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs index aa562098..3c18511f 100644 --- a/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs +++ b/src/Sekiban.Pure/Command/Handlers/ICommandWithHandlerInjectionAsync.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Projectors; using System.Diagnostics.CodeAnalysis; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResource.cs b/src/Sekiban.Pure/Command/Resources/CommandResource.cs index 3bf9b9d0..3dee2f20 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResource.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResource.cs @@ -1,6 +1,8 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Resources; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs index f3ff9257..82d8cbdb 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnly.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs index 6aa7e980..40989677 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyTask.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs index 50b16b84..cbf6947a 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInject.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs index 9da5bdff..489678eb 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourcePublishOnlyWithInjectTask.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs index 64e2ff65..048da70e 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceTask.cs @@ -1,5 +1,7 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs index 296e6bd4..877e47fe 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInject.cs @@ -1,5 +1,7 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs index 79b5bc99..72d6cf48 100644 --- a/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs +++ b/src/Sekiban.Pure/Command/Resources/CommandResourceWithInjectTask.cs @@ -1,5 +1,7 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Command.Executor; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Command/Resources/ICommandResource.cs b/src/Sekiban.Pure/Command/Resources/ICommandResource.cs index a59c5450..3c9a960f 100644 --- a/src/Sekiban.Pure/Command/Resources/ICommandResource.cs +++ b/src/Sekiban.Pure/Command/Resources/ICommandResource.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Projectors; namespace Sekiban.Pure.Command.Handlers; diff --git a/src/Sekiban.Pure/Documents/DocumentType.cs b/src/Sekiban.Pure/Documents/DocumentType.cs index 85fd9276..74d98a9b 100644 --- a/src/Sekiban.Pure/Documents/DocumentType.cs +++ b/src/Sekiban.Pure/Documents/DocumentType.cs @@ -1,4 +1,4 @@ -namespace Sekiban.Core.Documents; +namespace Sekiban.Pure.Documents; /// /// Document Type : used in Documents, what type of document diff --git a/src/Sekiban.Pure/Documents/IDocument.cs b/src/Sekiban.Pure/Documents/IDocument.cs index e8ab0f9f..f6e39c7d 100644 --- a/src/Sekiban.Pure/Documents/IDocument.cs +++ b/src/Sekiban.Pure/Documents/IDocument.cs @@ -1,5 +1,4 @@ -using Sekiban.Core.Documents.ValueObjects; -namespace Sekiban.Core.Documents; +namespace Sekiban.Pure.Documents; /// /// Basic Document Structure to Persist Events, Commands and Snapshots diff --git a/src/Sekiban.Pure/Documents/PartitionKeys.cs b/src/Sekiban.Pure/Documents/PartitionKeys.cs index da8b96c7..3b85120a 100644 --- a/src/Sekiban.Pure/Documents/PartitionKeys.cs +++ b/src/Sekiban.Pure/Documents/PartitionKeys.cs @@ -1,6 +1,6 @@ using Sekiban.Pure.Extensions; using Sekiban.Pure.Projectors; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Documents; public record PartitionKeys(Guid AggregateId, string Group, string RootPartitionKey) { diff --git a/src/Sekiban.Pure/Documents/SortableUniqueIdValue.cs b/src/Sekiban.Pure/Documents/SortableUniqueIdValue.cs index df89ce9d..9eccf8f6 100644 --- a/src/Sekiban.Pure/Documents/SortableUniqueIdValue.cs +++ b/src/Sekiban.Pure/Documents/SortableUniqueIdValue.cs @@ -1,6 +1,6 @@ using ResultBoxes; using Sekiban.Core.Shared; -namespace Sekiban.Core.Documents.ValueObjects; +namespace Sekiban.Pure.Documents; /// /// Calculate helper value document for Sortable Unique Id diff --git a/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs b/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs index 76d841d6..811ba9a7 100644 --- a/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs +++ b/src/Sekiban.Pure/Documents/TenantPartitionKeys.cs @@ -1,4 +1,4 @@ -namespace Sekiban.Pure; +namespace Sekiban.Pure.Documents; public record TenantPartitionKeys(string TenantCode) { diff --git a/src/Sekiban.Pure/Events/EmptyEventTypes.cs b/src/Sekiban.Pure/Events/EmptyEventTypes.cs index 669259e5..d8153bb0 100644 --- a/src/Sekiban.Pure/Events/EmptyEventTypes.cs +++ b/src/Sekiban.Pure/Events/EmptyEventTypes.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; using Sekiban.Pure.Exception; namespace Sekiban.Pure.Events; diff --git a/src/Sekiban.Pure/Events/Event.cs b/src/Sekiban.Pure/Events/Event.cs index a0b50f58..52df5866 100644 --- a/src/Sekiban.Pure/Events/Event.cs +++ b/src/Sekiban.Pure/Events/Event.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Documents; namespace Sekiban.Pure.Events; public record Event( diff --git a/src/Sekiban.Pure/Events/IEvent.cs b/src/Sekiban.Pure/Events/IEvent.cs index d66fbea0..0c0ea819 100644 --- a/src/Sekiban.Pure/Events/IEvent.cs +++ b/src/Sekiban.Pure/Events/IEvent.cs @@ -1,4 +1,4 @@ -using Sekiban.Core.Documents.ValueObjects; +using Sekiban.Pure.Documents; namespace Sekiban.Pure.Events; public interface IEvent diff --git a/src/Sekiban.Pure/Events/IEventTypes.cs b/src/Sekiban.Pure/Events/IEventTypes.cs index 7f9c875d..48c431dd 100644 --- a/src/Sekiban.Pure/Events/IEventTypes.cs +++ b/src/Sekiban.Pure/Events/IEventTypes.cs @@ -1,4 +1,5 @@ using ResultBoxes; +using Sekiban.Pure.Documents; namespace Sekiban.Pure.Events; public interface IEventTypes diff --git a/src/Sekiban.Pure/Exception/ISekibanException.cs b/src/Sekiban.Pure/Exception/ISekibanException.cs index 895dc846..d1d456af 100644 --- a/src/Sekiban.Pure/Exception/ISekibanException.cs +++ b/src/Sekiban.Pure/Exception/ISekibanException.cs @@ -1,4 +1,4 @@ -namespace Sekiban.Core.Exceptions; +namespace Sekiban.Pure.Exception; /// /// BaseType for the Sekiban Exception diff --git a/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs b/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs index 12a72097..7473fb12 100644 --- a/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs +++ b/src/Sekiban.Pure/Exception/SekibanAggregateTypeException.cs @@ -1,4 +1,3 @@ -using Sekiban.Core.Exceptions; namespace Sekiban.Pure.Exception; public class SekibanAggregateTypeException(string message) : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs b/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs index f2a16f7a..54b4f62a 100644 --- a/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs +++ b/src/Sekiban.Pure/Exception/SekibanAggregateTypeRestrictionException.cs @@ -1,4 +1,3 @@ -using Sekiban.Core.Exceptions; namespace Sekiban.Pure.Exception; public class SekibanAggregateTypeRestrictionException(string message) diff --git a/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs b/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs index 6f517544..d0a3f208 100644 --- a/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs +++ b/src/Sekiban.Pure/Exception/SekibanCommandHandlerNotMatchException.cs @@ -1,4 +1,3 @@ -using Sekiban.Core.Exceptions; namespace Sekiban.Pure.Exception; public class SekibanCommandHandlerNotMatchException(string message) : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs b/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs index f665153f..e6eed6c5 100644 --- a/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs +++ b/src/Sekiban.Pure/Exception/SekibanEventTypeNotFoundException.cs @@ -1,4 +1,3 @@ -using Sekiban.Core.Exceptions; namespace Sekiban.Pure.Exception; public class SekibanEventTypeNotFoundException(string message) : ApplicationException(message), ISekibanException; diff --git a/src/Sekiban.Pure/Projectors/IAggregateProjector.cs b/src/Sekiban.Pure/Projectors/IAggregateProjector.cs index 30576ad2..c9a04695 100644 --- a/src/Sekiban.Pure/Projectors/IAggregateProjector.cs +++ b/src/Sekiban.Pure/Projectors/IAggregateProjector.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Events; namespace Sekiban.Pure.Projectors; diff --git a/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs b/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs index b1e8ac79..4c765cf3 100644 --- a/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs +++ b/src/Sekiban.Pure/Projectors/NoneAggregateProjector.cs @@ -1,3 +1,4 @@ +using Sekiban.Pure.Aggregates; using Sekiban.Pure.Events; namespace Sekiban.Pure.Projectors; diff --git a/src/Sekiban.Pure/Repositories/Repository.cs b/src/Sekiban.Pure/Repositories/Repository.cs index eb61a4ce..9c3dc5e4 100644 --- a/src/Sekiban.Pure/Repositories/Repository.cs +++ b/src/Sekiban.Pure/Repositories/Repository.cs @@ -1,7 +1,9 @@ using ResultBoxes; +using Sekiban.Pure.Aggregates; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Projectors; -namespace Sekiban.Pure; +namespace Sekiban.Pure.Repositories; public class Repository { diff --git a/tests/Pure.Domain.Test/UnitTest1.cs b/tests/Pure.Domain.Test/UnitTest1.cs index ee7a2769..45f90f12 100644 --- a/tests/Pure.Domain.Test/UnitTest1.cs +++ b/tests/Pure.Domain.Test/UnitTest1.cs @@ -4,9 +4,11 @@ using Sekiban.Pure.Command.Executor; using Sekiban.Pure.Command.Handlers; using Sekiban.Pure.Command.Resources; +using Sekiban.Pure.Documents; using Sekiban.Pure.Events; using Sekiban.Pure.Exception; using Sekiban.Pure.Projectors; +using Sekiban.Pure.Repositories; namespace Pure.Domain.Test; public class UnitTest1 diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTest.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTest.cs index abb17541..49f9216e 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTest.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTest.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTypeR.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTypeR.cs index 591ae03a..7a07ea27 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTypeR.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosAggregateSubtypeTypeR.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; @@ -6,10 +5,8 @@ namespace Sekiban.Test.CosmosDb.Stories; public class CosmosAggregateSubtypeTypeR : AggregateSubtypeTypeR { - public CosmosAggregateSubtypeTypeR(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new CosmosSekibanServiceProviderGenerator()) + public CosmosAggregateSubtypeTypeR(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : + base(sekibanTestFixture, testOutputHelper, new CosmosSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosCustomerDbStoryBasic.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosCustomerDbStoryBasic.cs index 645c641d..e9c0937c 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosCustomerDbStoryBasic.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosCustomerDbStoryBasic.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosEventOrderSpec.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosEventOrderSpec.cs index 4feaa024..689034e6 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosEventOrderSpec.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosEventOrderSpec.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosInheritInSubtypesTest.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosInheritInSubtypesTest.cs index 42d28d8d..69b69577 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosInheritInSubtypesTest.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosInheritInSubtypesTest.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; @@ -11,4 +10,4 @@ public class CosmosInheritInSubtypesTest( output, new CosmosSekibanServiceProviderGenerator()) { -} \ No newline at end of file +} diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiProjectionSnapshotTests.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiProjectionSnapshotTests.cs index 2d716dd4..00675a39 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiProjectionSnapshotTests.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiProjectionSnapshotTests.cs @@ -1,14 +1,11 @@ -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; public class CosmosMultiProjectionSnapshotTests : MultiProjectionSnapshotTests { - public CosmosMultiProjectionSnapshotTests(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new CosmosSekibanServiceProviderGenerator()) + public CosmosMultiProjectionSnapshotTests(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) + : base(sekibanTestFixture, testOutputHelper, new CosmosSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiTenantDocumentTests.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiTenantDocumentTests.cs index ea868f95..529a87b1 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiTenantDocumentTests.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultiTenantDocumentTests.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultipleEventsInOneClassTest.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultipleEventsInOneClassTest.cs index 39d71dd9..97e6125d 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultipleEventsInOneClassTest.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosMultipleEventsInOneClassTest.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosPerformanceTest.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosPerformanceTest.cs index 56772573..055db067 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosPerformanceTest.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosPerformanceTest.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; diff --git a/tests/Sekiban.Test.CosmosDb/Stories/CosmosResultBoxSpec.cs b/tests/Sekiban.Test.CosmosDb/Stories/CosmosResultBoxSpec.cs index ad87a3d2..914f1a9e 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/CosmosResultBoxSpec.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/CosmosResultBoxSpec.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.CosmosDb.Stories; @@ -11,4 +10,4 @@ public CosmosResultBoxSpec(SekibanTestFixture sekibanTestFixture, ITestOutputHel new CosmosSekibanServiceProviderGenerator()) { } -} \ No newline at end of file +} diff --git a/tests/Sekiban.Test.CosmosDb/Stories/InheritedSubtypeTests.cs b/tests/Sekiban.Test.CosmosDb/Stories/InheritedSubtypeTests.cs index 2529122d..67c84ed2 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/InheritedSubtypeTests.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/InheritedSubtypeTests.cs @@ -6,7 +6,6 @@ using Sekiban.Core.Documents.Pools; using Sekiban.Core.Query.MultiProjections; using Sekiban.Core.Query.SingleProjections.Projections; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using System.Threading.Tasks; using Xunit; @@ -33,7 +32,8 @@ public async Task SubtypeSnapshotTest1UseJson() { RemoveAllFromDefaultAndDissolvable(); - commandResponse = await commandExecutor.ExecCommandWithEventsAsync(new OpenInheritedAggregate { YearMonth = 202001 }); + commandResponse + = await commandExecutor.ExecCommandWithEventsAsync(new OpenInheritedAggregate { YearMonth = 202001 }); Assert.NotNull(commandResponse.AggregateId); var aggregateId = commandResponse.AggregateId!.Value; @@ -42,8 +42,12 @@ public async Task SubtypeSnapshotTest1UseJson() var aggregateState = await aggregateLoader.AsDefaultStateFromInitialAsync(aggregateId); - var snapshotDocument = await singleProjectionSnapshotAccessor.SnapshotDocumentFromAggregateStateAsync(aggregateState!); - await documentPersistentWriter.SaveSingleSnapshotAsync(snapshotDocument!, new AggregateWriteStream(typeof(IInheritedAggregate)), false); + var snapshotDocument + = await singleProjectionSnapshotAccessor.SnapshotDocumentFromAggregateStateAsync(aggregateState!); + await documentPersistentWriter.SaveSingleSnapshotAsync( + snapshotDocument!, + new AggregateWriteStream(typeof(IInheritedAggregate)), + false); ResetInMemoryDocumentStoreAndCache(); @@ -63,7 +67,8 @@ public async Task SubtypeSnapshotTest2UseBlob() { RemoveAllFromDefaultAndDissolvable(); - commandResponse = await commandExecutor.ExecCommandWithEventsAsync(new OpenInheritedAggregate { YearMonth = 202001 }); + commandResponse + = await commandExecutor.ExecCommandWithEventsAsync(new OpenInheritedAggregate { YearMonth = 202001 }); Assert.NotNull(commandResponse.AggregateId); var aggregateId = commandResponse.AggregateId!.Value; @@ -72,8 +77,12 @@ public async Task SubtypeSnapshotTest2UseBlob() var aggregateState = await aggregateLoader.AsDefaultStateFromInitialAsync(aggregateId); - var snapshotDocument = await singleProjectionSnapshotAccessor.SnapshotDocumentFromAggregateStateAsync(aggregateState!); - await documentPersistentWriter.SaveSingleSnapshotAsync(snapshotDocument!, new AggregateWriteStream(typeof(IInheritedAggregate)), true); + var snapshotDocument + = await singleProjectionSnapshotAccessor.SnapshotDocumentFromAggregateStateAsync(aggregateState!); + await documentPersistentWriter.SaveSingleSnapshotAsync( + snapshotDocument!, + new AggregateWriteStream(typeof(IInheritedAggregate)), + true); ResetInMemoryDocumentStoreAndCache(); diff --git a/tests/Sekiban.Test.CosmosDb/Stories/MultipleDbStoryTest.cs b/tests/Sekiban.Test.CosmosDb/Stories/MultipleDbStoryTest.cs index d2f0d8af..a403dceb 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/MultipleDbStoryTest.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/MultipleDbStoryTest.cs @@ -2,7 +2,6 @@ using FeatureCheck.Domain.Aggregates.Branches.Commands; using FeatureCheck.Domain.Shared; using Sekiban.Core.Setting; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using System.Threading.Tasks; using Xunit; @@ -44,7 +43,9 @@ await _sekibanContext.SekibanActionAsync( }); // If you get a List with "Default", you get one record. - var list = await _sekibanContext.SekibanActionAsync(DefaultDb, async () => await multiProjectionService.GetAggregateList()); + var list = await _sekibanContext.SekibanActionAsync( + DefaultDb, + async () => await multiProjectionService.GetAggregateList()); Assert.Single(list); // If you don't attach anything, it is also obtained from the Default Db. @@ -52,7 +53,9 @@ await _sekibanContext.SekibanActionAsync( Assert.Single(list); // If you get a List with "Secondary", you get zero records. - list = await _sekibanContext.SekibanActionAsync(SecondaryDb, async () => await multiProjectionService.GetAggregateList()); + list = await _sekibanContext.SekibanActionAsync( + SecondaryDb, + async () => await multiProjectionService.GetAggregateList()); Assert.Empty(list); // Create three pieces of data with "Secondary". @@ -66,7 +69,9 @@ await _sekibanContext.SekibanActionAsync( }); // If you get a List with "Default", you get one record. - list = await _sekibanContext.SekibanActionAsync(DefaultDb, async () => await multiProjectionService.GetAggregateList()); + list = await _sekibanContext.SekibanActionAsync( + DefaultDb, + async () => await multiProjectionService.GetAggregateList()); Assert.Single(list); // If you don't attach anything, it is also obtained from the Default Db. @@ -74,7 +79,9 @@ await _sekibanContext.SekibanActionAsync( Assert.Single(list); // If you get a List with "Secondary", you get three records. - list = await _sekibanContext.SekibanActionAsync(SecondaryDb, async () => await multiProjectionService.GetAggregateList()); + list = await _sekibanContext.SekibanActionAsync( + SecondaryDb, + async () => await multiProjectionService.GetAggregateList()); Assert.Equal(3, list.Count); // nesting database can work. @@ -83,7 +90,9 @@ await _sekibanContext.SekibanActionAsync( async () => { // If you get a List with "Secondary", you get three records. - list = await _sekibanContext.SekibanActionAsync(SecondaryDb, async () => await multiProjectionService.GetAggregateList()); + list = await _sekibanContext.SekibanActionAsync( + SecondaryDb, + async () => await multiProjectionService.GetAggregateList()); Assert.Equal(3, list.Count); // After the nesting seconds, go back to default database. diff --git a/tests/Sekiban.Test.CosmosDb/Stories/SimpleQueryTest.cs b/tests/Sekiban.Test.CosmosDb/Stories/SimpleQueryTest.cs index a9b776b3..5be2c17d 100644 --- a/tests/Sekiban.Test.CosmosDb/Stories/SimpleQueryTest.cs +++ b/tests/Sekiban.Test.CosmosDb/Stories/SimpleQueryTest.cs @@ -6,7 +6,6 @@ using FeatureCheck.Domain.Shared; using Sekiban.Core.Command; using Sekiban.Core.Query.QueryModel; -using Sekiban.Infrastructure.Cosmos; using Sekiban.Test.Abstructs.Abstructs; using System.Threading.Tasks; using Xunit; @@ -29,15 +28,7 @@ public SimpleQueryTest(SekibanTestFixture sekibanTestFixture, ITestOutputHelper public async Task QueryExecuteAggregateListAsync() { - await _queryExecutor.ExecuteAsync( - new BasicClientQueryParameter( - null, - null, - null, - null, - null, - null, - null)); + await _queryExecutor.ExecuteAsync(new BasicClientQueryParameter(null, null, null, null, null, null, null)); } [Fact] @@ -63,20 +54,14 @@ public async Task QueryExecuteSingleProjectionAsync() public async Task QueryExecuteMultipleProjectionListAsync() { await _queryExecutor.ExecuteAsync( - new ClientLoyaltyPointQuery.Parameter( - null, - null, - null, - null, - null, - null, - null, - null)); + new ClientLoyaltyPointQuery.Parameter(null, null, null, null, null, null, null, null)); } [Fact] public async Task QueryExecuteMultipleProjectionAsync() { await _queryExecutor.ExecuteAsync( - new ClientLoyaltyPointMultiProjectionQuery.Parameter(null, ClientLoyaltyPointMultiProjectionQuery.QuerySortKeys.Points)); + new ClientLoyaltyPointMultiProjectionQuery.Parameter( + null, + ClientLoyaltyPointMultiProjectionQuery.QuerySortKeys.Points)); } } diff --git a/tests/Sekiban.Test.Dynamo/Tests/CustomerDbStoryBasicDynamo.cs b/tests/Sekiban.Test.Dynamo/Tests/CustomerDbStoryBasicDynamo.cs index 9393a209..abefd574 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/CustomerDbStoryBasicDynamo.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/CustomerDbStoryBasicDynamo.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; diff --git a/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTest.cs b/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTest.cs index 6f10e6ac..e82a7123 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTest.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTest.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; diff --git a/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTypeR.cs b/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTypeR.cs index 4f213574..64f743e6 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTypeR.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/DynamoAggregateSubtypeTypeR.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; @@ -6,10 +5,8 @@ namespace Sekiban.Test.Dynamo.Tests; public class DynamoAggregateSubtypeTypeR : AggregateSubtypeTypeR { - public DynamoAggregateSubtypeTypeR(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new DynamoSekibanServiceProviderGenerator()) + public DynamoAggregateSubtypeTypeR(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : + base(sekibanTestFixture, testOutputHelper, new DynamoSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiProjectionSnapshotTests.cs b/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiProjectionSnapshotTests.cs index 41880b78..5fb3d0be 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiProjectionSnapshotTests.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiProjectionSnapshotTests.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; @@ -6,10 +5,8 @@ namespace Sekiban.Test.Dynamo.Tests; public class DynamoMultiProjectionSnapshotTests : MultiProjectionSnapshotTests { - public DynamoMultiProjectionSnapshotTests(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new DynamoSekibanServiceProviderGenerator()) + public DynamoMultiProjectionSnapshotTests(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) + : base(sekibanTestFixture, testOutputHelper, new DynamoSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiTenantDocumentTests.cs b/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiTenantDocumentTests.cs index 6a80c46c..b9f49a00 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiTenantDocumentTests.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/DynamoMultiTenantDocumentTests.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; diff --git a/tests/Sekiban.Test.Dynamo/Tests/DynamoMultipleEventsInOneClassTest.cs b/tests/Sekiban.Test.Dynamo/Tests/DynamoMultipleEventsInOneClassTest.cs index d38a1ccf..aa8982f4 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/DynamoMultipleEventsInOneClassTest.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/DynamoMultipleEventsInOneClassTest.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; diff --git a/tests/Sekiban.Test.Dynamo/Tests/DynamoQueryPerformanceTest.cs b/tests/Sekiban.Test.Dynamo/Tests/DynamoQueryPerformanceTest.cs index 25c8d1e0..ebaefe1a 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/DynamoQueryPerformanceTest.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/DynamoQueryPerformanceTest.cs @@ -1,4 +1,3 @@ -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; diff --git a/tests/Sekiban.Test.Dynamo/Tests/EventOrderSpecDynamo.cs b/tests/Sekiban.Test.Dynamo/Tests/EventOrderSpecDynamo.cs index d8686ac1..fafea07d 100644 --- a/tests/Sekiban.Test.Dynamo/Tests/EventOrderSpecDynamo.cs +++ b/tests/Sekiban.Test.Dynamo/Tests/EventOrderSpecDynamo.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Dynamo; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Dynamo.Tests; diff --git a/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTestPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTestPostgres.cs index be14094d..9dacdf19 100644 --- a/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTestPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTestPostgres.cs @@ -1,14 +1,11 @@ -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; public class AggregateSubtypeTestPostgres : AggregateSubtypeTest { - public AggregateSubtypeTestPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new PostgresSekibanServiceProviderGenerator()) + public AggregateSubtypeTestPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : + base(sekibanTestFixture, testOutputHelper, new PostgresSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTypeRPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTypeRPostgres.cs index 67e0425a..24cd7f5d 100644 --- a/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTypeRPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/AggregateSubtypeTypeRPostgres.cs @@ -1,14 +1,11 @@ -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; public class AggregateSubtypeTypeRPostgres : AggregateSubtypeTypeR { - public AggregateSubtypeTypeRPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new PostgresSekibanServiceProviderGenerator()) + public AggregateSubtypeTypeRPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : + base(sekibanTestFixture, testOutputHelper, new PostgresSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.Postgres/Tests/CustomerDbStoryBasicPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/CustomerDbStoryBasicPostgres.cs index 36cb85eb..ac7638ea 100644 --- a/tests/Sekiban.Test.Postgres/Tests/CustomerDbStoryBasicPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/CustomerDbStoryBasicPostgres.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; diff --git a/tests/Sekiban.Test.Postgres/Tests/EventOrderSpecPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/EventOrderSpecPostgres.cs index a1e5877b..d27bb4d6 100644 --- a/tests/Sekiban.Test.Postgres/Tests/EventOrderSpecPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/EventOrderSpecPostgres.cs @@ -1,5 +1,4 @@ using FeatureCheck.Domain.Shared; -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; diff --git a/tests/Sekiban.Test.Postgres/Tests/MultiProjectionSnapshotTestsPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/MultiProjectionSnapshotTestsPostgres.cs index 0a2d68c9..241a8130 100644 --- a/tests/Sekiban.Test.Postgres/Tests/MultiProjectionSnapshotTestsPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/MultiProjectionSnapshotTestsPostgres.cs @@ -1,11 +1,12 @@ -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; public class MultiProjectionSnapshotTestsPostgres : MultiProjectionSnapshotTests { - public MultiProjectionSnapshotTestsPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( + public MultiProjectionSnapshotTestsPostgres( + SekibanTestFixture sekibanTestFixture, + ITestOutputHelper testOutputHelper) : base( sekibanTestFixture, testOutputHelper, new PostgresSekibanServiceProviderGenerator()) diff --git a/tests/Sekiban.Test.Postgres/Tests/MultiTenantDocumentTestsPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/MultiTenantDocumentTestsPostgres.cs index c4307dde..708ceddc 100644 --- a/tests/Sekiban.Test.Postgres/Tests/MultiTenantDocumentTestsPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/MultiTenantDocumentTestsPostgres.cs @@ -1,14 +1,11 @@ -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; public class MultiTenantDocumentTestsPostgres : MultiTenantDocumentTests { - public MultiTenantDocumentTestsPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new PostgresSekibanServiceProviderGenerator()) + public MultiTenantDocumentTestsPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : + base(sekibanTestFixture, testOutputHelper, new PostgresSekibanServiceProviderGenerator()) { } } diff --git a/tests/Sekiban.Test.Postgres/Tests/MultipleEventsInOneClassTestPostgres.cs b/tests/Sekiban.Test.Postgres/Tests/MultipleEventsInOneClassTestPostgres.cs index 19ec54e6..4e0feec4 100644 --- a/tests/Sekiban.Test.Postgres/Tests/MultipleEventsInOneClassTestPostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/MultipleEventsInOneClassTestPostgres.cs @@ -1,11 +1,12 @@ -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; public class MultipleEventsInOneClassTestPostgres : MultipleEventsInOneClassTest { - public MultipleEventsInOneClassTestPostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( + public MultipleEventsInOneClassTestPostgres( + SekibanTestFixture sekibanTestFixture, + ITestOutputHelper testOutputHelper) : base( sekibanTestFixture, testOutputHelper, new PostgresSekibanServiceProviderGenerator()) diff --git a/tests/Sekiban.Test.Postgres/Tests/QueryPerformanceTestBasePostgres.cs b/tests/Sekiban.Test.Postgres/Tests/QueryPerformanceTestBasePostgres.cs index cb08a316..0a626a4d 100644 --- a/tests/Sekiban.Test.Postgres/Tests/QueryPerformanceTestBasePostgres.cs +++ b/tests/Sekiban.Test.Postgres/Tests/QueryPerformanceTestBasePostgres.cs @@ -1,14 +1,11 @@ -using Sekiban.Infrastructure.Postgres; using Sekiban.Test.Abstructs.Abstructs; using Xunit.Abstractions; namespace Sekiban.Test.Postgres.Tests; public class QueryPerformanceTestBasePostgres : QueryPerformanceTestBase { - public QueryPerformanceTestBasePostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : base( - sekibanTestFixture, - testOutputHelper, - new PostgresSekibanServiceProviderGenerator()) + public QueryPerformanceTestBasePostgres(SekibanTestFixture sekibanTestFixture, ITestOutputHelper testOutputHelper) : + base(sekibanTestFixture, testOutputHelper, new PostgresSekibanServiceProviderGenerator()) { } }