packages feed

keiro-dsl-0.6.0.0: test/conformance-scalar-expressions/Generated/AggregateScalarExpressions/ScalarAccount/EventStream.hs

-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module Generated.AggregateScalarExpressions.ScalarAccount.EventStream
  ( scalarAccountCategory
  , scalarAccountEventStream
  , scalarAccountEventStreamDef
  , ScalarAccountEventStream
  , ScalarAccountEventStreamDef
  , scalarAccountSnapshotFixture
  ) where

import Generated.AggregateScalarExpressions.ScalarAccount.Domain
import Generated.AggregateScalarExpressions.ScalarAccount.Codec (scalarAccountCodec)
import Generated.AggregateScalarExpressions.ScalarAccount.Transducer (scalarAccountFoldFingerprint, scalarAccountTransducer)
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.
scalarAccountCategory :: Stream.StreamCategory a
scalarAccountCategory = Stream.categoryUnsafe "scalarAccount"

type ScalarAccountEventStreamDef =
  EventStream (HsPred ScalarAccountRegs ScalarAccountCommand) ScalarAccountRegs ScalarAccountVertex ScalarAccountCommand ScalarAccountEvent

type ScalarAccountEventStream =
  ValidatedEventStream (HsPred ScalarAccountRegs ScalarAccountCommand) ScalarAccountRegs ScalarAccountVertex ScalarAccountCommand ScalarAccountEvent

scalarAccountEventStreamDef :: ScalarAccountEventStreamDef
scalarAccountEventStreamDef =
  EventStream
    { transducer = scalarAccountTransducer
    , initialState = ScalarAccountOpen
    , initialRegisters = initialScalarAccountRegs
    , eventCodec = scalarAccountCodec
    , 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 scalarAccountFoldFingerprint (defaultStateCodec 1))
    }

scalarAccountSnapshotFixture :: (Int, Text)
scalarAccountSnapshotFixture = (1, "aggregate-scalar-expressions-v2")

scalarAccountEventStream :: ScalarAccountEventStream
scalarAccountEventStream =
  mkEventStreamOrThrow "ScalarAccount" scalarAccountEventStreamDef