keiro-dsl-0.25.1.0: test/conformance-checked-mapping-replay/Generated/CheckedMappingReplay/Inspection.hs
-- @generated by keiro-dsl 0.25.1.0 (language keiro-dsl 6) from context checked-mapping-replay inspection catalog; do not edit.
--
-- The complete read-only inspection catalog for this service: one aggregate
-- inspector per declared aggregate, the replay-audit targets and the projection
-- catalog. Mount them through Keiro.Ops.AppHooks; see docs/user/operations.md.
module Generated.CheckedMappingReplay.Inspection
( aggregateInspectorCatalog
, aggregateInspectors
, inspectionAuditTargets
, inspectionProjectionCatalog
) where
import Data.Aeson (Value, object, (.=))
import Data.Text (pack)
import Generated.CheckedMappingReplay.ProjectionCatalog (validatedProjectionCatalog)
import Generated.CheckedMappingReplay.ReplayAudit (auditTargets)
import Generated.CheckedMappingReplay.ReplayLedger.EventStream qualified as ReplayLedger
import Generated.CheckedMappingReplay.ReplayTarget.EventStream qualified as ReplayTarget
import Keiki.Core (RegFile)
import Keiro.EventStream (EventStream (..))
import Keiro.Inspection.Aggregate (AggregateInspectors, SomeAggregateInspector (..), aggregateInspector, displayViaStateCodec)
import Keiro.Inspection.Aggregate qualified
import Keiro.Projection.Catalog (ValidatedProjectionCatalog)
import Keiro.ReplayAudit (SomeAuditTarget)
import Keiro.Stream (categoryText)
aggregateInspectorCatalog :: [SomeAggregateInspector]
aggregateInspectorCatalog =
[ SomeAggregateInspector (aggregateInspector (categoryText ReplayLedger.replayLedgerCategory) ReplayLedger.replayLedgerEventStream ReplayLedger.replayLedgerCategory (displayFoldedState ReplayLedger.replayLedgerEventStreamDef))
, SomeAggregateInspector (aggregateInspector (categoryText ReplayTarget.replayTargetCategory) ReplayTarget.replayTargetEventStream ReplayTarget.replayTargetCategory (displayFoldedState ReplayTarget.replayTargetEventStreamDef))
]
aggregateInspectors :: AggregateInspectors
aggregateInspectors = case Keiro.Inspection.Aggregate.aggregateInspectors aggregateInspectorCatalog of
Right inspectors -> inspectors
Left message -> error ("keiro-dsl generated an invalid aggregate inspector catalog: " <> show message)
inspectionAuditTargets :: [SomeAuditTarget]
inspectionAuditTargets = auditTargets
inspectionProjectionCatalog :: ValidatedProjectionCatalog
inspectionProjectionCatalog = validatedProjectionCatalog
-- The aggregate's own state codec when its definition declares one (snapshot
-- aggregates), otherwise the vertex label.
displayFoldedState :: (Show s) => EventStream phi rs s ci co -> s -> RegFile rs -> Value
displayFoldedState EventStream {stateCodec = Just codec} = displayViaStateCodec codec
displayFoldedState EventStream {stateCodec = Nothing} = \state _ -> object ["state" .= pack (show state)]