keiro-dsl-0.21.0.0: test/conformance-mapped-register-construction/Generated/MappedRegisterConstruction/Lifecycle/EventStream.hs
-- @generated by keiro-dsl 0.21.0.0 (language keiro-dsl 6) from aggregate Lifecycle; do not edit.
module Generated.MappedRegisterConstruction.Lifecycle.EventStream
( lifecycleCategory
, lifecycleCommandCategory
, lifecycleEventStream
, lifecycleEventStreamDef
, LifecycleEventStream
, LifecycleEventStreamDef
, lifecycleSnapshotFixture
) where
import Generated.MappedRegisterConstruction.Lifecycle.Domain
import Generated.MappedRegisterConstruction.Lifecycle.Codec (lifecycleCodec)
import Generated.MappedRegisterConstruction.Lifecycle.Transducer (lifecycleFoldFingerprint, lifecycleTransducer)
import Keiki.Core (HsPred)
import Keiro.EventStream (EventStream (..), SnapshotPolicy (..))
import Keiro.EventStream.Validate (ValidatedEventStream, mkEventStreamOrThrow)
import Data.Text (Text)
import Keiro.Snapshot.Codec (defaultStateCodec, withFoldFingerprint)
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.
lifecycleCategory :: Stream.StreamCategory LifecycleEventStreamDef
lifecycleCategory = Stream.categoryUnsafe "lifecycle"
-- The same category text, typed for command envelopes such as PMCommand.
lifecycleCommandCategory :: Stream.StreamCategory LifecycleCommand
lifecycleCommandCategory = Stream.categoryUnsafe "lifecycle"
type LifecycleEventStreamDef =
EventStream (HsPred LifecycleRegs LifecycleCommand) LifecycleRegs LifecycleVertex LifecycleCommand LifecycleEvent
type LifecycleEventStream =
ValidatedEventStream (HsPred LifecycleRegs LifecycleCommand) LifecycleRegs LifecycleVertex LifecycleCommand LifecycleEvent
lifecycleEventStreamDef :: LifecycleEventStreamDef
lifecycleEventStreamDef =
EventStream
{ transducer = lifecycleTransducer,
initialState = LifecycleEmpty,
initialRegisters = initialLifecycleRegs,
eventCodec = lifecycleCodec,
resolveStreamName = Stream.streamName,
snapshotPolicy = Every 1,
-- The snapshot discriminator composes: the spec's state-codec version (bump it
-- in the spec's `state-codec version=` clause), keiki's register and
-- control-state shape hashes, and this fold fingerprint derived from the
-- spec's transition surface (guards, writes, emits, states, register
-- initials, referenced rules). Spec-visible fold changes invalidate old
-- snapshots automatically. Version-2 Hole-owned transitions additionally
-- compose their explicit hand-owned FoldVersion tokens here; bump the
-- corresponding token whenever that Hole behavior changes.
stateCodec = Just (withFoldFingerprint lifecycleFoldFingerprint (defaultStateCodec 1))
}
lifecycleSnapshotFixture :: (Int, Text)
lifecycleSnapshotFixture = (1, "mapped-register-construction-v1")
lifecycleEventStream :: LifecycleEventStream
lifecycleEventStream =
mkEventStreamOrThrow "Lifecycle" lifecycleEventStreamDef