packages feed

keiro-dsl-0.18.0.0: test/conformance-calendar-days/Generated/CalendarDays/CalendarStore/EventStream.hs

-- @generated by keiro-dsl 0.18.0.0 (language keiro-dsl 6) from aggregate CalendarStore; do not edit.
module Generated.CalendarDays.CalendarStore.EventStream
  ( calendarStoreCategory
  , calendarStoreCommandCategory
  , calendarStoreEventStream
  , calendarStoreEventStreamDef
  , CalendarStoreEventStream
  , CalendarStoreEventStreamDef
  , calendarStoreSnapshotFixture
  ) where

import Generated.CalendarDays.CalendarStore.Domain
import Generated.CalendarDays.CalendarStore.Codec (calendarStoreCodec)
import Generated.CalendarDays.CalendarStore.Transducer (calendarStoreFoldFingerprint, calendarStoreTransducer)
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.
calendarStoreCategory :: Stream.StreamCategory CalendarStoreEventStreamDef
calendarStoreCategory = Stream.categoryUnsafe "calendarStore"

-- The same category text, typed for command envelopes such as PMCommand.
calendarStoreCommandCategory :: Stream.StreamCategory CalendarStoreCommand
calendarStoreCommandCategory = Stream.categoryUnsafe "calendarStore"

type CalendarStoreEventStreamDef =
  EventStream (HsPred CalendarStoreRegs CalendarStoreCommand) CalendarStoreRegs CalendarStoreVertex CalendarStoreCommand CalendarStoreEvent

type CalendarStoreEventStream =
  ValidatedEventStream (HsPred CalendarStoreRegs CalendarStoreCommand) CalendarStoreRegs CalendarStoreVertex CalendarStoreCommand CalendarStoreEvent

calendarStoreEventStreamDef :: CalendarStoreEventStreamDef
calendarStoreEventStreamDef =
  EventStream
    { transducer = calendarStoreTransducer,
      initialState = CalendarStoreEmpty,
      initialRegisters = initialCalendarStoreRegs,
      eventCodec = calendarStoreCodec,
      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 calendarStoreFoldFingerprint (defaultStateCodec 1))
    }

calendarStoreSnapshotFixture :: (Int, Text)
calendarStoreSnapshotFixture = (1, "calendar-days-v1")

calendarStoreEventStream :: CalendarStoreEventStream
calendarStoreEventStream =
  mkEventStreamOrThrow "CalendarStore" calendarStoreEventStreamDef