keiro-dsl-0.4.0.1: test/conformance-snapshot/Generated/HospitalCapacity/Reservation/EventStream.hs
-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module Generated.HospitalCapacity.Reservation.EventStream (
reservationCategory,
reservationEventStream,
reservationEventStreamDef,
ReservationEventStream,
ReservationEventStreamDef,
reservationSnapshotFixture,
) where
import Data.Text (Text)
import Generated.HospitalCapacity.Reservation.Codec (reservationCodec)
import Generated.HospitalCapacity.Reservation.Domain
import HospitalCapacity.Reservation.Holes (reservationTransducer)
import Keiki.Core (HsPred)
import Keiro.EventStream (EventStream (..), SnapshotPolicy (..))
import Keiro.EventStream.Validate (ValidatedEventStream, mkEventStreamOrThrow)
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.
reservationCategory :: Stream.StreamCategory a
reservationCategory = Stream.categoryUnsafe "reservation"
type ReservationEventStreamDef =
EventStream (HsPred ReservationRegs ReservationCommand) ReservationRegs ReservationVertex ReservationCommand ReservationEvent
type ReservationEventStream =
ValidatedEventStream (HsPred ReservationRegs ReservationCommand) ReservationRegs ReservationVertex ReservationCommand ReservationEvent
reservationEventStreamDef :: ReservationEventStreamDef
reservationEventStreamDef =
EventStream
{ transducer = reservationTransducer
, initialState = ReservationUnrequested
, initialRegisters = initialReservationRegs
, eventCodec = reservationCodec
, resolveStreamName = Stream.streamName
, snapshotPolicy = Every 100
, -- 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. Fold changes made ONLY in the hand-owned Holes
-- module are invisible here: bump `state-codec version=` manually or old
-- snapshots will be served stale.
stateCodec = Just (withFoldFingerprint "2367ef6fadf0e751" (defaultStateCodec 1))
}
reservationSnapshotFixture :: (Int, Text)
reservationSnapshotFixture = (1, "7eb3a94f62f947231375d44083e2a1c8029d91ffe0329107d55092ed3430efcc")
reservationEventStream :: ReservationEventStream
reservationEventStream =
mkEventStreamOrThrow "Reservation" reservationEventStreamDef