keiro-dsl-0.17.0.0: test/conformance-structural-nominals/Generated/StructuralNominalLeaves/TemplateCatalog/EventStream.hs
-- @generated by keiro-dsl 0.17.0.0 (language keiro-dsl 6) from aggregate TemplateCatalog; do not edit.
module Generated.StructuralNominalLeaves.TemplateCatalog.EventStream
( templateCatalogCategory
, templateCatalogCommandCategory
, templateCatalogEventStream
, templateCatalogEventStreamDef
, TemplateCatalogEventStream
, TemplateCatalogEventStreamDef
, templateCatalogSnapshotFixture
) where
import Generated.StructuralNominalLeaves.TemplateCatalog.Domain
import Generated.StructuralNominalLeaves.TemplateCatalog.Codec (templateCatalogCodec)
import Generated.StructuralNominalLeaves.TemplateCatalog.Transducer (templateCatalogFoldFingerprint, templateCatalogTransducer)
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.
templateCatalogCategory :: Stream.StreamCategory TemplateCatalogEventStreamDef
templateCatalogCategory = Stream.categoryUnsafe "templateCatalog"
-- The same category text, typed for command envelopes such as PMCommand.
templateCatalogCommandCategory :: Stream.StreamCategory TemplateCatalogCommand
templateCatalogCommandCategory = Stream.categoryUnsafe "templateCatalog"
type TemplateCatalogEventStreamDef =
EventStream (HsPred TemplateCatalogRegs TemplateCatalogCommand) TemplateCatalogRegs TemplateCatalogVertex TemplateCatalogCommand TemplateCatalogEvent
type TemplateCatalogEventStream =
ValidatedEventStream (HsPred TemplateCatalogRegs TemplateCatalogCommand) TemplateCatalogRegs TemplateCatalogVertex TemplateCatalogCommand TemplateCatalogEvent
templateCatalogEventStreamDef :: TemplateCatalogEventStreamDef
templateCatalogEventStreamDef =
EventStream
{ transducer = templateCatalogTransducer,
initialState = TemplateCatalogEmpty,
initialRegisters = initialTemplateCatalogRegs,
eventCodec = templateCatalogCodec,
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 templateCatalogFoldFingerprint (defaultStateCodec 1))
}
templateCatalogSnapshotFixture :: (Int, Text)
templateCatalogSnapshotFixture = (1, "structural-nominal-leaves-v1")
templateCatalogEventStream :: TemplateCatalogEventStream
templateCatalogEventStream =
mkEventStreamOrThrow "TemplateCatalog" templateCatalogEventStreamDef