keiro-dsl-0.17.0.0: test/conformance-process-state-authority/Generated/IncidentResponse/Escalation/EventStream.hs
-- @generated by keiro-dsl 0.17.0.0 (language keiro-dsl 6) from aggregate Escalation; do not edit.
module Generated.IncidentResponse.Escalation.EventStream
( escalationCategory
, escalationCommandCategory
, escalationEventStream
, escalationEventStreamDef
, EscalationEventStream
, EscalationEventStreamDef
, escalationDomainCommandHandler
) where
import Generated.IncidentResponse.Escalation.Domain
import Generated.IncidentResponse.Escalation.Codec (escalationCodec)
import Generated.IncidentResponse.Escalation.Transducer (escalationTransducer)
import Generated.IncidentResponse.Nominals (EscalationNoOp (..), EscalationRejection (..))
import Keiki.Core (EdgeRef (..), HsPred)
import Keiki.Core qualified as K
import Keiro.Command (DomainCommandHandler (..), SilentCommandContext (..), SilentDomainDecision (..))
import Keiro.EventStream (EventStream (..), SnapshotPolicy (..))
import Keiro.EventStream.Validate (ValidatedEventStream, mkEventStreamOrThrow)
import Keiro.Stream qualified as Stream
-- The validated aggregate stream category (hole-kind 5: referenced, never retyped).
-- Entity streams are '<category>-<id>' via Keiro.Stream.entityStream.
-- categoryUnsafe is safe here because this generated literal passed the DSL category proof.
escalationCategory :: Stream.StreamCategory EscalationEventStreamDef
escalationCategory = Stream.categoryUnsafe "escalation"
-- The same category text, typed for command envelopes such as PMCommand.
escalationCommandCategory :: Stream.StreamCategory EscalationCommand
escalationCommandCategory = Stream.categoryUnsafe "escalation"
type EscalationEventStreamDef =
EventStream (HsPred EscalationRegs EscalationCommand) EscalationRegs EscalationVertex EscalationCommand EscalationEvent
type EscalationEventStream =
ValidatedEventStream (HsPred EscalationRegs EscalationCommand) EscalationRegs EscalationVertex EscalationCommand EscalationEvent
escalationEventStreamDef :: EscalationEventStreamDef
escalationEventStreamDef =
EventStream
{ transducer = escalationTransducer,
initialState = EscalationOpen,
initialRegisters = initialEscalationRegs,
eventCodec = escalationCodec,
resolveStreamName = Stream.streamName,
snapshotPolicy = Never,
stateCodec = Nothing
}
escalationEventStream :: EscalationEventStream
escalationEventStream =
mkEventStreamOrThrow "Escalation" escalationEventStreamDef
escalationDomainCommandHandler
:: DomainCommandHandler
(HsPred EscalationRegs EscalationCommand)
EscalationRegs
EscalationVertex
EscalationCommand
EscalationEvent
EscalationRejection
EscalationNoOp
escalationDomainCommandHandler =
DomainCommandHandler escalationEventStream escalationSilentDecision
escalationSilentDecision
:: SilentCommandContext EscalationRegs EscalationVertex EscalationCommand
-> SilentDomainDecision
EscalationRejection
EscalationNoOp
escalationSilentDecision (SilentCommandContext _ registers command (EdgeRef edgeSource edgeIndex)) =
case edgeSource of
EscalationOpen ->
case edgeIndex of
2 -> SilentNoOp (K.evalTerm (K.lit Ignored) registers command)
_ -> outcomeInvariant edgeSource edgeIndex
_ -> outcomeInvariant edgeSource edgeIndex
where
outcomeInvariant source index =
error ("generated domain outcome invariant failed for aggregate Escalation edge " <> show source <> "#" <> show index)