keiro-dsl-0.10.0.0: test/conformance-aggregate-scalars/Generated/AggregateScalars/ScalarLedger/EventStream.hs
-- @generated by keiro-dsl 0.9.0.0 (language keiro-dsl 4) from aggregate ScalarLedger; do not edit.
module Generated.AggregateScalars.ScalarLedger.EventStream
( scalarLedgerCategory
, scalarLedgerCommandCategory
, scalarLedgerEventStream
, scalarLedgerEventStreamDef
, ScalarLedgerEventStream
, ScalarLedgerEventStreamDef
, scalarLedgerSnapshotFixture
) where
import Generated.AggregateScalars.ScalarLedger.Domain
import Generated.AggregateScalars.ScalarLedger.Codec (scalarLedgerCodec)
import Generated.AggregateScalars.ScalarLedger.Transducer (scalarLedgerFoldFingerprint, scalarLedgerTransducer)
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.
scalarLedgerCategory :: Stream.StreamCategory ScalarLedgerEventStreamDef
scalarLedgerCategory = Stream.categoryUnsafe "scalarLedger"
-- The same category text, typed for command envelopes such as PMCommand.
scalarLedgerCommandCategory :: Stream.StreamCategory ScalarLedgerCommand
scalarLedgerCommandCategory = Stream.categoryUnsafe "scalarLedger"
type ScalarLedgerEventStreamDef =
EventStream (HsPred ScalarLedgerRegs ScalarLedgerCommand) ScalarLedgerRegs ScalarLedgerVertex ScalarLedgerCommand ScalarLedgerEvent
type ScalarLedgerEventStream =
ValidatedEventStream (HsPred ScalarLedgerRegs ScalarLedgerCommand) ScalarLedgerRegs ScalarLedgerVertex ScalarLedgerCommand ScalarLedgerEvent
scalarLedgerEventStreamDef :: ScalarLedgerEventStreamDef
scalarLedgerEventStreamDef =
EventStream
{ transducer = scalarLedgerTransducer,
initialState = ScalarLedgerEmpty,
initialRegisters = initialScalarLedgerRegs,
eventCodec = scalarLedgerCodec,
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 scalarLedgerFoldFingerprint (defaultStateCodec 1))
}
scalarLedgerSnapshotFixture :: (Int, Text)
scalarLedgerSnapshotFixture = (1, "aggregate-scalars-v1")
scalarLedgerEventStream :: ScalarLedgerEventStream
scalarLedgerEventStream =
mkEventStreamOrThrow "ScalarLedger" scalarLedgerEventStreamDef