diff --git a/src/main/riddl/Events/Reservations/reservation.riddl b/src/main/riddl/Events/Reservations/reservation.riddl index 0c3ba60e..b90062da 100644 --- a/src/main/riddl/Events/Reservations/reservation.riddl +++ b/src/main/riddl/Events/Reservations/reservation.riddl @@ -4,13 +4,7 @@ type ReservationId is Id (ImprovingApp.Events.ReservationContext.Reservation) context ReservationContext is { include "reservationTypeDefinitions" include "reservationMessages" - - // TODO: List the names of the public reservation events here - type PublicReservationEvent is one of { - ??? - } - - outlet Events is type PublicReservationEvent + include "reservationSources" entity Reservation is { option event-sourced @@ -22,7 +16,7 @@ context ReservationContext is { record ImprovingApp.Events.ReservationContext.Reservation.DraftState "Copy fields from the command into Draft fields" "adjust meta fields to reflect the change set" - send event ReservationEstablished to outlet ReservationContext.Events + send event ReservationEstablished to outlet ReservationEventsSource.Events } on other { error "Only EstablishReservation command is allowed in the default state" @@ -41,7 +35,7 @@ context ReservationContext is { } on command ImprovingApp.Events.ReservationContext.EditReservationInfo { set field ImprovingApp.Events.ReservationContext.Reservation.Draft.reservationInfo to "EditReservationInfo.info" - send event ReservationInfoUpdated to outlet ReservationContext.Events + send event ReservationInfoUpdated to outlet ReservationEventsSource.Events } on command ImprovingApp.Events.ReservationContext.UpdateReservationStatus { "morph entity Reservation to state provided in UpdateReservationStatus" diff --git a/src/main/riddl/Events/Reservations/reservationSources.riddl b/src/main/riddl/Events/Reservations/reservationSources.riddl new file mode 100644 index 00000000..727dd752 --- /dev/null +++ b/src/main/riddl/Events/Reservations/reservationSources.riddl @@ -0,0 +1,41 @@ +connector ReservationCommandsChannel is { + from outlet ReservationCommandsSource.Commands to + inlet ReservationCommandsSink.Commands +} + +connector ReservationEventsChannel is { + from outlet ReservationEventsSource.Events to + inlet ReservationEventsSink.Events +} + +source ReservationCommandsSource is { + outlet Commands is type ReservationCommand +} + +sink ReservationCommandsSink is { + inlet Commands is type ReservationCommand +} + +source ReservationEventsSource is { + outlet Events is type ReservationEvent +} + +sink ReservationEventsSink is { + inlet Events is type ReservationEvent +} + +type ReservationCommand is one of { + EstablishReservation, + EditReservationInfo, + UpdateReservationStatus, + DeleteReservation, + GetReservationInfo +} + +type ReservationEvent is one of { + ReservationEstablished, + ReservationInfoUpdated, + ReservationStatusUpdated, + ReservationDeleted, + ReservationInfoResult +} \ No newline at end of file diff --git a/src/main/riddl/Events/eventContext.riddl b/src/main/riddl/Events/eventContext.riddl index 97e2709a..bff1dbb4 100644 --- a/src/main/riddl/Events/eventContext.riddl +++ b/src/main/riddl/Events/eventContext.riddl @@ -6,7 +6,7 @@ context EventContext is { include "eventTypeDefinitions" include "eventSources" - function incrementDelayedEventTime is { + function IncrementDelayedEventTime is { requires {originalTime: DateTime, duration: Duration} returns { newTime: DateTime } body ??? @@ -41,7 +41,7 @@ context EventContext is { handler EventHandler is { on command CreateEvent { - send event EventCreated to outlet EventEvents.Events + send event EventCreated to outlet EventEventsSource.Events morph entity Event to state DraftEvent with record DraftEventState } on other { @@ -60,7 +60,7 @@ context EventContext is { on command ScheduleEvent{ if "all required info fields are present" then { "set a scheduled Akka call for emitting StartEvent at DraftEventState.info.expectedStart" - send event EventScheduled to outlet EventEvents.Events + send event EventScheduled to outlet EventEventsSource.Events morph entity Event to state ScheduledEvent with record ScheduledEventState } } @@ -68,12 +68,12 @@ context EventContext is { set field DraftEventState.info to "EventContext.newEditableInfoFromFieldsPresentInEditable" set field DraftEventState.meta to "EventMetaInfo" send event EventRescheduled - to outlet EventEvents.Events + to outlet EventEventsSource.Events } on command CancelEvent{ if "all required info fields are present" then { "cancel associated scheduled call to emit StartEvent" - send event EventCancelled to outlet EventEvents.Events + send event EventCancelled to outlet EventEventsSource.Events morph entity Event to state ScheduledEvent with record ScheduledEventState } } @@ -82,13 +82,13 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field DraftEventState.info to "EditableEventInfo" set field DraftEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on command DelayEvent{ if "all required info fields are present" then { "adjust associated scheduled call to emit StartEvent" - send event EventDelayed to outlet EventEvents.Events + send event EventDelayed to outlet EventEventsSource.Events morph entity Event to state ScheduledEvent with record ScheduledEventState } } @@ -127,21 +127,21 @@ context EventContext is { on command EditEventInfo { set field ScheduledEventState.info to "EventContext.newInfoFromFieldsPresentInEditable" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventInfoEdited to outlet EventEvents.Events + send event EventInfoEdited to outlet EventEventsSource.Events } on command CancelEvent { "cancel associated scheduled call to emit StartEvent" - send event EventCancelled to outlet EventEvents.Events + send event EventCancelled to outlet EventEventsSource.Events become entity Event to handler CancelledEventHandler } on command DelayEvent { "adjust associated scheduled Akka call to emit StartEvent" - send event EventDelayed to outlet EventEvents.Events + send event EventDelayed to outlet EventEventsSource.Events become entity Event to handler DelayedEventHandler } on command StartEvent{ "create scheduled Akka call using ScheduledEventState.info.expectedEnd to emit EndEvent" - send event EventStarted to outlet EventEvents.Events + send event EventStarted to outlet EventEventsSource.Events become entity Event to handler InProgressEventHandler } briefly "to be invoked by Akka scheduler upon ScheduleEvent reception" on command RescheduleEvent { @@ -149,7 +149,7 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on command EndEvent{ @@ -178,14 +178,14 @@ context EventContext is { } on command DelayEvent{ "adjust associated scheduled Akka call to emit StartEvent" - send event EventDelayed to outlet EventEvents.Events + send event EventDelayed to outlet EventEventsSource.Events become entity Event to handler DelayedEventHandler } on command StartEvent { error "Event is already started. Cannot start an event that is already in progress" } on command EndEvent { - send event EventEnded to outlet EventEvents.Events + send event EventEnded to outlet EventEventsSource.Events become entity Event to handler PastEventHandler } // TODO: specify AddLiveUpdate on clause @@ -203,11 +203,11 @@ context EventContext is { on command EditEventInfo{ set field ScheduledEventState.info to "EventContext.newInfoFromFieldsPresentInEditable" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventInfoEdited to outlet EventEvents.Events + send event EventInfoEdited to outlet EventEventsSource.Events } on command CancelEvent{ "cancel associated scheduled call to emit StartEvent" - send event EventCancelled to outlet EventEvents.Events + send event EventCancelled to outlet EventEventsSource.Events become entity Event to handler CancelledEventHandler } on command RescheduleEvent{ @@ -215,7 +215,7 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on command DelayEvent{ @@ -223,7 +223,7 @@ context EventContext is { } on command StartEvent{ "create scheduled Akka call using ScheduledEventState.info.expectedEnd to emit EndEvent" - send event EventStarted to outlet EventEvents.Events + send event EventStarted to outlet EventEventsSource.Events become entity Event to handler InProgressEventHandler } briefly "to be invoked by Akka scheduler upon ScheduleEvent reception" on command EndEvent{ @@ -240,7 +240,7 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on other { diff --git a/src/main/riddl/Events/eventSources.riddl b/src/main/riddl/Events/eventSources.riddl index ce7673b9..8bfd9150 100644 --- a/src/main/riddl/Events/eventSources.riddl +++ b/src/main/riddl/Events/eventSources.riddl @@ -1,22 +1,56 @@ -source LiveUpdates is { - outlet Updates is type LiveUpdate -} explained as "This is a source for things that happen as an event progresses" - -// plant EventPlant is { -// pipe EventPipe is {???} -// } +// source LiveUpdates is { +// outlet Updates is type LiveUpdate +// } explained as "This is a source for things that happen as an event progresses" //ReservationAddedToEvent, -type PublicEventEvent is one of { - Events.EventContext.EventInfoEdited, - Events.EventContext.EventCreated, - Events.EventContext.EventScheduled, - Events.EventContext.EventCancelled, - Events.EventContext.EventRescheduled, - Events.EventContext.EventDelayed, - Events.EventContext.EventStarted, - Events.EventContext.EventEnded + +connector EventCommandsChannel is { + from outlet EventCommandsSource.Commands to + inlet EventCommandsSink.Commands +} + +connector EventEventsChannel is { + from outlet EventEventsSource.Events to + inlet EventEventsSink.Events +} + +source EventCommandsSource is { + outlet Commands is type EventCommand +} + +sink EventCommandsSink is { + inlet Commands is type EventCommand } -source EventEvents is { - outlet Events is type PublicEventEvent -} explained as "This is a source for event from Events entities" \ No newline at end of file + +source EventEventsSource is { + outlet Events is type EventEvent +} + +sink EventEventsSink is { + inlet Events is type EventEvent +} + +type EventCommand is one of { + EditEventInfo, + CreateEvent, + ScheduleEvent, + CancelEvent, + RescheduleEvent, + DelayEvent, + StartEvent, + EndEvent, + TerminateEvent, + AddLiveUpdate +} + +type EventEvent is one of { + EventInfoEdited, + EventCreated, + EventScheduled, + EventCancelled, + EventRescheduled, + EventDelayed, + EventStarted, + EventEnded, + EventTerminated +} \ No newline at end of file diff --git a/src/main/riddl/Gateway/ReservationGateway/reservationStories.riddl b/src/main/riddl/Gateway/ReservationGateway/reservationStories.riddl index 4a8a8f78..6c4e337a 100644 --- a/src/main/riddl/Gateway/ReservationGateway/reservationStories.riddl +++ b/src/main/riddl/Gateway/ReservationGateway/reservationStories.riddl @@ -11,10 +11,10 @@ epic CreateReservation { step from user GatewayAPI "Create Reservation" to entity ImprovingApp.Events.ReservationContext.Reservation briefly "create reservation" step send event ImprovingApp.Events.ReservationContext.ReservationEstablished - from entity ImprovingApp.Events.ReservationContext.Reservation to source ImprovingApp.Events.ReservationContext.PublicReservationEvent + from entity ImprovingApp.Events.ReservationContext.Reservation to source ImprovingApp.Events.ReservationContext.ReservationEventsSource briefly "reservation created" step send event ImprovingApp.Events.ReservationContext.ReservationEstablished - from source ImprovingApp.Events.ReservationContext.PublicReservationEvent to application App + from source ImprovingApp.Events.ReservationContext.ReservationEventsSource to application App } } briefly "A story about creating a reservation in Improving.app" described as "This is the story of how a reservation comes into existence" diff --git a/src/main/riddl/Gateway/gatewayStories.riddl b/src/main/riddl/Gateway/gatewayStories.riddl index c756dc77..a3bbb675 100644 --- a/src/main/riddl/Gateway/gatewayStories.riddl +++ b/src/main/riddl/Gateway/gatewayStories.riddl @@ -9,9 +9,9 @@ epic RegisterMember { briefly "send creation message" step from context GatewayAPI "Register Member" to entity ImprovingApp.MemberContext.Member briefly "add new Member" - step send event ImprovingApp.MemberContext.MemberRegistered from entity ImprovingApp.MemberContext.Member to source ImprovingApp.MemberContext.MemberEvents + step send event ImprovingApp.MemberContext.MemberRegistered from entity ImprovingApp.MemberContext.Member to source ImprovingApp.MemberContext.MemberEventsSource briefly "Member added in Draft state" - step send event ImprovingApp.MemberContext.MemberRegistered from source ImprovingApp.MemberContext.MemberEvents to application App + step send event ImprovingApp.MemberContext.MemberRegistered from source ImprovingApp.MemberContext.MemberEventsSource to application App //example Foo is {...} } } briefly "A story about registering a member in Improving.app" diff --git a/src/main/riddl/ImprovingApp.conf b/src/main/riddl/ImprovingApp.conf index e9af801d..95b1847a 100644 --- a/src/main/riddl/ImprovingApp.conf +++ b/src/main/riddl/ImprovingApp.conf @@ -5,9 +5,8 @@ command = hugo # This block provides options that are common to any command. common = { - show-times = true show-include-times = true - verbose = true + verbose = false quiet = false dry-run = false show-warnings = true @@ -16,6 +15,7 @@ common = { show-usage-warnings = false debug = false group-by-message-kind = true + warnings-are-fatal = true } # This block provides options for the "hugo" command to translate riddl to a hugo web site. diff --git a/src/main/riddl/Members/memberSources.riddl b/src/main/riddl/Members/memberSources.riddl new file mode 100644 index 00000000..2806c419 --- /dev/null +++ b/src/main/riddl/Members/memberSources.riddl @@ -0,0 +1,43 @@ +connector MemberCommandsChannel is { + from outlet MemberCommandsSource.Commands to + inlet MemberCommandsSink.Commands +} + +connector MemberEventsChannel is { + from outlet MemberEventsSource.Events to + inlet MemberEventsSink.Events +} + +source MemberCommandsSource is { + outlet Commands is type MemberCommand +} + +sink MemberCommandsSink is { + inlet Commands is type MemberCommand +} + +source MemberEventsSource is { + outlet Events is type MemberEvent +} + +sink MemberEventsSink is { + inlet Events is type MemberEvent +} + +type MemberCommand is one of { + ImprovingApp.MemberContext.RegisterMember, + ImprovingApp.MemberContext.ActivateMember, + ImprovingApp.MemberContext.SuspendMember, + ImprovingApp.MemberContext.TerminateMember, + ImprovingApp.MemberContext.EditMemberInfo, + ImprovingApp.MemberContext.GetMemberData +} + +type MemberEvent is one of { + ImprovingApp.MemberContext.MemberRegistered, + ImprovingApp.MemberContext.MemberActivated, + ImprovingApp.MemberContext.MemberSuspended, + ImprovingApp.MemberContext.MemberTerminated, + ImprovingApp.MemberContext.MemberInfoEdited, + ImprovingApp.MemberContext.MemberData +} \ No newline at end of file diff --git a/src/main/riddl/Members/members.riddl b/src/main/riddl/Members/members.riddl index acc04ca5..e1921a09 100644 --- a/src/main/riddl/Members/members.riddl +++ b/src/main/riddl/Members/members.riddl @@ -1,19 +1,9 @@ context MemberContext is { + include "memberSources" + type MemberId is Id(MemberContext.Member) briefly "Unique identifier for Tenant Entity" - type PublicMemberEvent is one of { - ImprovingApp.MemberContext.MemberRegistered, - ImprovingApp.MemberContext.MemberActivated, - ImprovingApp.MemberContext.MemberSuspended, - ImprovingApp.MemberContext.MemberTerminated, - ImprovingApp.MemberContext.MemberInfoEdited, - ImprovingApp.MemberContext.MemberData - } - source MemberEvents is { - outlet Events is type PublicMemberEvent - } explained as "This is a source for Organization Events" - type MemberMap is mapping from MemberContext.MemberId to MemberContext.Info //Member Details @@ -249,7 +239,7 @@ context MemberContext is { on command ImprovingApp.MemberContext.ActivateMember { if "all required fields in requiredInfo are not None or Empty" then { - send event MemberRegistered to outlet MemberEvents.Events + send event MemberRegistered to outlet MemberEventsSource.Events morph entity Member to state RegisteredMemberState with record RegisteredMember } else { @@ -261,13 +251,13 @@ context MemberContext is { on command EditMemberInfo { set field Member.DraftMemberState.info to "MemberContext.EditableInfo" set field Member.DraftMemberState.meta to "MemberContext.MetaInfo" - send event MemberInfoEdited to outlet ImprovingApp.MemberContext.MemberEvents.Events + send event MemberInfoEdited to outlet ImprovingApp.MemberContext.MemberEventsSource.Events } // For GetMemberData, eventually probably only admins and self should be able to make this call. Also // potentially allow other roles to get some limited information (this will require adding another // aggregate). on query GetMemberData { - send record MemberInfo to outlet ImprovingApp.MemberContext.MemberEvents.Events + send record MemberInfo to outlet ImprovingApp.MemberContext.MemberEventsSource.Events } } } described as { @@ -310,11 +300,11 @@ context MemberContext is { lastUpdatedBy = @EditMemberInfo.editingMember, currentState = @MemberStates.Draft )" - send event MemberInfoEdited to outlet ImprovingApp.MemberContext.MemberEvents.Events + send event MemberInfoEdited to outlet ImprovingApp.MemberContext.MemberEventsSource.Events } on command ImprovingApp.MemberContext.SuspendMember { if "all required fields in requiredInfo are not None or Empty" then { - send event MemberSuspended to outlet MemberEvents.Events + send event MemberSuspended to outlet MemberEventsSource.Events become entity Member to handler SuspendedMemberHandler } } @@ -331,12 +321,12 @@ context MemberContext is { error "Member has already been registered." } on command ImprovingApp.MemberContext.ActivateMember { - send event ImprovingApp.GatewayAPI.MemberGateway.MemberActivated to outlet ImprovingApp.MemberContext.MemberEvents.Events + send event ImprovingApp.GatewayAPI.MemberGateway.MemberActivated to outlet ImprovingApp.MemberContext.MemberEventsSource.Events become entity ImprovingApp.MemberContext.Member to handler ActiveMemberHandler } on command ImprovingApp.MemberContext.SuspendMember { set field RegisteredMemberState.meta to "MemberContext.MetaInfo" - send event ImprovingApp.MemberContext.MemberSuspended to outlet ImprovingApp.MemberContext.MemberEvents.Events + send event ImprovingApp.MemberContext.MemberSuspended to outlet ImprovingApp.MemberContext.MemberEventsSource.Events } briefly "A suspension reason can be updated by re-issuing the command" on command ImprovingApp.MemberContext.TerminateMember { set field RegisteredMemberState.meta to "MemberContext.MetaInfo" diff --git a/src/main/riddl/Organization/organization.riddl b/src/main/riddl/Organization/organization.riddl index 42ea5713..8b6ab31d 100644 --- a/src/main/riddl/Organization/organization.riddl +++ b/src/main/riddl/Organization/organization.riddl @@ -14,7 +14,7 @@ context OrganizationContext is { handler OrganizationHandler is { on command ImprovingApp.OrganizationContext.EstablishOrganization { - send event ImprovingApp.OrganizationContext.OrganizationEstablished to outlet OrganizationEvents.Events + send event ImprovingApp.OrganizationContext.OrganizationEstablished to outlet OrganizationEventsSource.Source morph entity ImprovingApp.OrganizationContext.Organization to state DraftOrganization with record DraftOrganizationState } on other { @@ -40,7 +40,7 @@ context OrganizationContext is { on command EditOrganizationInfo { set field DraftOrganizationState.info to "OrganizationContext.Info" set field DraftOrganizationState.orgMeta to "OrganizationContext.MetaInfo" - send event OrganizationInfoEdited to outlet OrganizationEvents.Events + send event OrganizationInfoEdited to outlet OrganizationEventsSource.Source } on command UpdateParent { if "successful" then { @@ -241,7 +241,7 @@ context OrganizationContext is { on command ImprovingApp.OrganizationContext.EditOrganizationInfo { set field EstablishedOrganizationState.info to "OrganizationContext.Info" set field EstablishedOrganizationState.orgMeta to "OrganizationContext.MetaInfo" - send event OrganizationInfoEdited to outlet OrganizationEvents.Events + send event OrganizationInfoEdited to outlet OrganizationEventsSource.Source } on command ImprovingApp.OrganizationContext.UpdateParent { if "editingMember is not Authorized" then { @@ -360,7 +360,7 @@ context OrganizationContext is { // } on command ImprovingApp.OrganizationContext.SuspendOrganization { set field EstablishedOrganizationState.orgMeta to "OrganizationContext.MetaInfo" - send event OrganizationSuspended to outlet OrganizationEvents.Events + send event OrganizationSuspended to outlet OrganizationEventsSource.Source become entity ImprovingApp.OrganizationContext.Organization to handler SuspendedOrganizationHandler } on command ImprovingApp.OrganizationContext.TerminateOrganization { @@ -401,13 +401,13 @@ context OrganizationContext is { on command ActivateOrganization { set field EstablishedOrganizationState.orgMeta to "OrganizationContext.MetaInfo" send event OrganizationActivated - to outlet OrganizationEvents.Events + to outlet OrganizationEventsSource.Source become entity ImprovingApp.OrganizationContext.Organization to handler ActiveOrganizationHandler } on command SuspendOrganization { set field EstablishedOrganizationState.orgMeta to "OrganizationContext.MetaInfo" - send event OrganizationSuspended to outlet OrganizationEvents.Events + send event OrganizationSuspended to outlet OrganizationEventsSource.Source become entity ImprovingApp.OrganizationContext.Organization to handler SuspendedOrganizationHandler } briefly "A suspension reason can be updated by re-issuing the command" on command TerminateOrganization { diff --git a/src/main/riddl/Organization/organizationSources.riddl b/src/main/riddl/Organization/organizationSources.riddl index d7bf9a54..effc4b55 100644 --- a/src/main/riddl/Organization/organizationSources.riddl +++ b/src/main/riddl/Organization/organizationSources.riddl @@ -1,4 +1,42 @@ -type PublicOrganizationEvent is one of { +connector OrganizationEventsChannel is { + from outlet OrganizationEventsSource.Source to + inlet OrganizationEventsSink.Sink +} + +connector OrganizationCommandsChannel is { + from outlet OrganizationCommandsSource.Source to + inlet OrganizationCommandsSink.Sink +} + +source OrganizationEventsSource is { + outlet Source is type OrganizationEvent +} + +sink OrganizationEventsSink is { + inlet Sink is type OrganizationEvent +} + +source OrganizationCommandsSource is { + outlet Source is type OrganizationCommand +} + +sink OrganizationCommandsSink is { + inlet Sink is type OrganizationCommand +} + +type OrganizationCommand is one of { + ImprovingApp.OrganizationContext.EstablishOrganization, + ImprovingApp.OrganizationContext.ActivateOrganization, + ImprovingApp.OrganizationContext.SuspendOrganization, + ImprovingApp.OrganizationContext.TerminateOrganization, + ImprovingApp.OrganizationContext.EditOrganizationInfo, + ImprovingApp.OrganizationContext.AddMembersToOrganization, + ImprovingApp.OrganizationContext.AddOwnersToOrganization, + ImprovingApp.OrganizationContext.UpdateOrganizationContacts, + ImprovingApp.OrganizationContext.UpdateOrganizationAccounts +} + +type OrganizationEvent is one of { ImprovingApp.OrganizationContext.OrganizationEstablished, ImprovingApp.OrganizationContext.OrganizationActivated, ImprovingApp.OrganizationContext.OrganizationSuspended, @@ -9,7 +47,3 @@ type PublicOrganizationEvent is one of { ImprovingApp.OrganizationContext.OrganizationContactsUpdated, ImprovingApp.OrganizationContext.OrganizationAccountsUpdated } - -source OrganizationEvents is { - outlet Events is type PublicOrganizationEvent -} explained as "This is a source for Organization Events" \ No newline at end of file diff --git a/src/main/riddl/Product/product.riddl b/src/main/riddl/Product/product.riddl index 5d3ab4c5..82ac91b7 100644 --- a/src/main/riddl/Product/product.riddl +++ b/src/main/riddl/Product/product.riddl @@ -1,15 +1,5 @@ context ProductContext is { - type PublicProductEvent is one of { - ProductCreated, - ProductInfoUpdated, - ProductDeleted, - ProductActivated, - ProductInactivated - } - - source ProductEvents is { - outlet Events is type PublicProductEvent - } explained as "This is a source for Product Events" + include "productSources" type ProductDetails is any of {TicketDetails} type ProductStatus is any of {Draft, Active, InActive, Deleted} briefly "Note: Delete is not the same as in Org, Tenant, etc because there is no PII. Here it is more like Terminate" @@ -97,7 +87,7 @@ context ProductContext is { on command DeleteProduct{ set field DraftProductState.meta to "ProductContext.ProductMetaInfo" send event ProductDeleted - to outlet ProductEvents.Events + to outlet ProductEventsSource.Events morph entity ProductContext.Product to state DeletedProductState with record DeletedProduct } on command ActivateProduct{ @@ -106,7 +96,7 @@ context ProductContext is { } else { // "all required fields are present" set field DraftProductState.meta to "ProductContext.ProductMetaInfo" - send event ProductActivated to outlet ProductEvents.Events + send event ProductActivated to outlet ProductEventsSource morph entity Product to state DefinedProductState with record DefinedProduct } } @@ -136,7 +126,7 @@ context ProductContext is { } on command ProductContext.DeleteProduct{ set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" - send event ProductDeleted to outlet ProductEvents.Events + send event ProductDeleted to outlet ProductEventsSource.Events morph entity ProductContext.Product to state DeletedProductState with record DeletedProduct } on command ProductContext.ActivateProduct{ @@ -144,7 +134,7 @@ context ProductContext is { } on command ProductContext.InactivateProduct { set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" - send event ProductInactivated to outlet ProductEvents.Events + send event ProductInactivated to outlet ProductEventsSource.Events become entity ProductContext.Product to handler Product.DefinedProductState.InactiveProductHandler } on query GetProductInfo{ @@ -162,12 +152,12 @@ context ProductContext is { } on command ProductContext.DeleteProduct{ set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" - send event ProductDeleted to outlet ProductEvents.Events + send event ProductDeleted to outlet ProductEventsSource.Events morph entity ProductContext.Product to state ProductContext.Product.DeletedProductState with record DeletedProduct } on command ProductContext.ActivateProduct{ set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" - send event ProductActivated to outlet ProductEvents.Events + send event ProductActivated to outlet ProductEventsSource.Events become entity ProductContext.Product to handler Product.DefinedProductState.ActiveProductHandler } on command ProductContext.InactivateProduct{ diff --git a/src/main/riddl/Product/productSources.riddl b/src/main/riddl/Product/productSources.riddl new file mode 100644 index 00000000..9bfd0eb9 --- /dev/null +++ b/src/main/riddl/Product/productSources.riddl @@ -0,0 +1,41 @@ +connector ProductCommandsChannel is { + from outlet ProductCommandsSource.Commands to + inlet ProductCommandsSink.Commands +} + +connector ProductEventsChannel is { + from outlet ProductEventsSource.Events to + inlet ProductEventsSink.Events +} + +source ProductCommandsSource is { + outlet Commands is type ProductCommand +} + +sink ProductCommandsSink is { + inlet Commands is type ProductCommand +} + +source ProductEventsSource is { + outlet Events is type ProductEvent +} + +sink ProductEventsSink is { + inlet Events is type ProductEvent +} + +type ProductCommand is one of { + ImprovingApp.ProductContext.CreateProduct, + UpdateProductInfo, + DeleteProduct, + ActivateProduct, + InactivateProduct +} + +type ProductEvent is one of { + ProductCreated, + ProductInfoUpdated, + ProductDeleted, + ProductActivated, + ProductInactivated +} diff --git a/src/main/riddl/Store/Store.riddl b/src/main/riddl/Store/Store.riddl index d2cd0157..f80f8d06 100644 --- a/src/main/riddl/Store/Store.riddl +++ b/src/main/riddl/Store/Store.riddl @@ -1,18 +1,5 @@ context StoreContext is { - type PublicStoreEvent is one of { - StoreCreated, - StoreInfoEdited, - StoreIsReady, - StoreDeleted, - StoreOpened, - StoreClosed, - ProductsAddedToStore, - ProductsRemovedFromStore - } - - source StoreEvents is { - outlet Events is type PublicStoreEvent - } explained as "This is a source for Store Events" + include "storeSources" type StoreStates is any of {Draft, Ready, Open, Closed, Deleted} type StoreId is Id(StoreContext.Store) @@ -76,8 +63,7 @@ context StoreContext is { handler DefaultStoreHandler is { on command CreateStore { - send event StoreCreated - to outlet StoreEvents.Events + send event StoreCreated to outlet StoreEventsSource.Events morph entity StoreContext.Store to state Store.DraftStore with record Store.DraftStoreData } on other { @@ -154,13 +140,13 @@ context StoreContext is { } on command OpenStore { set field Store.CreatedStore.meta to "StoreContext.MetaInfo" - send event StoreOpened to outlet StoreEvents.Events + send event StoreOpened to outlet StoreEventsSource.Events become entity StoreContext.Store to handler StoreContext.Store.CreatedStore.OpenStoreHandler } on command CloseStore { "ensure all orders associated with store are Delivered or Cancelled before closing store" set field CreatedStore.meta to "StoreContext.MetaInfo" - send event StoreClosed to outlet StoreEvents.Events + send event StoreClosed to outlet StoreEventsSource.Events become entity StoreContext.Store to handler StoreContext.Store.CreatedStore.ClosedStoreHandler } on command AddProductsToStore { @@ -203,7 +189,7 @@ context StoreContext is { on command CloseStore { "ensure all orders associated with store are Delivered or Cancelled before closing store" set field CreatedStore.meta to "StoreContext.MetaInfo" - send event StoreClosed to outlet StoreEvents.Events + send event StoreClosed to outlet StoreEventsSource.Events become entity StoreContext.Store to handler StoreContext.Store.CreatedStore.ClosedStoreHandler } on command AddProductsToStore { @@ -239,12 +225,12 @@ context StoreContext is { } on command DeleteStore { set field CreatedStore.meta to "StoreContext.MetaInfo" - send event StoreDeleted to outlet StoreEvents.Events + send event StoreDeleted to outlet StoreEventsSource.Events morph entity StoreContext.Store to state DeletedStore with record DeletedStoreData } on command OpenStore { set field CreatedStore.meta to "StoreContext.MetaInfo" - send event StoreOpened to outlet StoreEvents.Events + send event StoreOpened to outlet StoreEventsSource.Events become entity StoreContext.Store to handler Store.CreatedStore.OpenStoreHandler } on command CloseStore { diff --git a/src/main/riddl/Store/storeSources.riddl b/src/main/riddl/Store/storeSources.riddl new file mode 100644 index 00000000..b4f844ef --- /dev/null +++ b/src/main/riddl/Store/storeSources.riddl @@ -0,0 +1,50 @@ +connector StoreCommandsChannel is { + from outlet StoreCommandsSource.Commands to + inlet StoreCommandsSink.Commands +} + +connector StoreEventsChannel is { + from outlet StoreEventsSource.Events to + inlet StoreEventsSink.Events +} + +source StoreCommandsSource is { + outlet Commands is type StoreCommand +} + +sink StoreCommandsSink is { + inlet Commands is type StoreCommand +} + +source StoreEventsSource is { + outlet Events is type StoreEvent +} + +sink StoreEventsSink is { + inlet Events is type StoreEvent +} + +type StoreCommand is one of { + CreateStore, + EditStoreInfo, + MakeStoreReady, + DeleteStore, + OpenStore, + CloseStore, + TerminateStore, + AddProductsToStore, + RemoveProductsFromStore, + GetStoreInfo, + GetProductsInStore +} + +type StoreEvent is one of { + StoreCreated, + StoreInfoEdited, + StoreIsReady, + StoreDeleted, + StoreOpened, + StoreClosed, + ProductsAddedToStore, + ProductsRemovedFromStore +} \ No newline at end of file diff --git a/src/main/riddl/Tenant/tenant.riddl b/src/main/riddl/Tenant/tenant.riddl index bdf09820..eac278da 100644 --- a/src/main/riddl/Tenant/tenant.riddl +++ b/src/main/riddl/Tenant/tenant.riddl @@ -19,7 +19,7 @@ context TenantContext is { if "primaryContact info is not complete" then { error "primaryContact must be complete in order to establish a Tenant" } else { - send event TenantEstablished to outlet TenantEvents.Events + send event TenantEstablished to outlet TenantEventsSource.Events morph entity Tenant to state EstablishedTenant with record EstablishedTenantState } @@ -155,14 +155,14 @@ context TenantContext is { "Copy fields which are present from TenantContext.EditInfo.newInfo into info fields" set field EstablishedTenantState.meta to "record TenantContext.TenantMetaInfo" send event TenantContext.InfoEdited - to outlet TenantEvents.Events + to outlet TenantEventsSource.Events } on command SuspendTenant { if "updating user is not authorized to suspend tenant" then { error "User is not authorized to suspend Tenant" } else { set field EstablishedTenantState.meta to "record TenantContext.TenantMetaInfo" - send event TenantContext.TenantSuspended to outlet TenantEvents.Events + send event TenantContext.TenantSuspended to outlet TenantEventsSource.Events become entity Tenant to handler SuspendedTenantHandler } } @@ -171,7 +171,7 @@ context TenantContext is { error "User is not authorized to modify Tenant" } else { set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" - send event TenantContext.TenantTerminated to outlet TenantEvents.Events + send event TenantContext.TenantTerminated to outlet TenantEventsSource.Events morph entity Tenant to state TerminatedTenant with record TerminatedTenantState } } @@ -215,14 +215,14 @@ context TenantContext is { "Copy fields which are present from TenantContext.EditInfo.newInfo into info fields" set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" send event TenantContext.InfoEdited - to outlet TenantEvents.Events + to outlet TenantEventsSource.Events } on command ActivateTenant { if "updating user is not authorized to activate the tenant" then{ error "User is not authorized to Activate Tenant" } else { set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" - send event TenantContext.TenantSuspended to outlet TenantEvents.Events + send event TenantContext.TenantSuspended to outlet TenantEventsSource.Events become entity Tenant to handler ActiveTenantHandler } } @@ -232,7 +232,7 @@ context TenantContext is { } else { // set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" send event TenantContext.TenantTerminated - to outlet TenantEvents.Events + to outlet TenantEventsSource.Events morph entity Tenant to state TerminatedTenant with record TerminatedTenantState } } diff --git a/src/main/riddl/Tenant/tenantSources.riddl b/src/main/riddl/Tenant/tenantSources.riddl index 8fc30c76..0b7ca6ff 100644 --- a/src/main/riddl/Tenant/tenantSources.riddl +++ b/src/main/riddl/Tenant/tenantSources.riddl @@ -1,10 +1,41 @@ -type PublicTenantEvent is one of { - TenantContext.InfoEdited, - TenantContext.TenantActivated, - TenantContext.TenantSuspended, - TenantContext.TenantTerminated +connector TenantCommandsChannel is { + from outlet TenantCommandsSource.Commands to + inlet TenantCommandsSink.Commands } -source TenantEvents is { - outlet Events is type PublicTenantEvent -} explained as "This is a source for Tenant Events" +connector TenantEventsChannel is { + from outlet TenantEventsSource.Events to + inlet TenantEventsSink.Events +} + +source TenantCommandsSource is { + outlet Commands is type TenantCommand +} + +sink TenantCommandsSink is { + inlet Commands is type TenantCommand +} + +source TenantEventsSource is { + outlet Events is type TenantEvent +} + +sink TenantEventsSink is { + inlet Events is type TenantEvent +} + +type TenantCommand is one of { + EstablishTenant, + ActivateTenant, + SuspendTenant, + TerminateTenant, + EditInfo +} + +type TenantEvent is one of { + TenantEstablished, + TenantActivated, + TenantSuspended, + TenantTerminated, + InfoEdited +}