packages feed

keiro-dsl-0.10.0.0: test/conformance-snapshot/Generated/HospitalCapacity/Reservation/EventStream.hs

-- @generated by keiro-dsl 0.9.0.0 (language keiro-dsl 4) from aggregate Reservation; do not edit.
module Generated.HospitalCapacity.Reservation.EventStream
  ( reservationCategory
  , reservationCommandCategory
  , reservationEventStream
  , reservationEventStreamDef
  , ReservationEventStream
  , ReservationEventStreamDef
  , reservationSnapshotFixture
  ) where

import Generated.HospitalCapacity.Reservation.Domain
import Generated.HospitalCapacity.Reservation.Codec (reservationCodec)
import Generated.HospitalCapacity.Reservation.Transducer (reservationFoldFingerprint, reservationTransducer)
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.
reservationCategory :: Stream.StreamCategory ReservationEventStreamDef
reservationCategory = Stream.categoryUnsafe "reservation"

-- The same category text, typed for command envelopes such as PMCommand.
reservationCommandCategory :: Stream.StreamCategory ReservationCommand
reservationCommandCategory = 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. 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 reservationFoldFingerprint (defaultStateCodec 1))
    }

reservationSnapshotFixture :: (Int, Text)
reservationSnapshotFixture = (1, "7a181ceb7d798d883d28c85201c5c1692bd314a7b489da9128bff91e0f38cd28")

reservationEventStream :: ReservationEventStream
reservationEventStream =
  mkEventStreamOrThrow "Reservation" reservationEventStreamDef