keiro-dsl-0.18.0.0: test/conformance-calendar-days/Generated/CalendarDays/ProjectionCatalog.hs
-- @generated by keiro-dsl 0.18.0.0 (language keiro-dsl 6) from projection-catalog calendar-days; do not edit.
{-# LANGUAGE OverloadedStrings #-}
module Generated.CalendarDays.ProjectionCatalog
( projectionCatalog
, validatedProjectionCatalog
, projectionCatalogInventory
, projectionCatalogRegistrations
, projectionCatalogAsyncRegistrations
, projectionCatalogQuerySupplies
, registerProjectionCatalog
, calendarWriterProjectionSet
, calendarRebuildRebuildGroupId
, startCalendarRebuildRebuild
) where
import Data.List.NonEmpty (NonEmpty (..))
import Effectful (Eff, IOE, (:>))
import Keiro.Projection (AsyncProjection (..))
import Keiro.Projection.Catalog qualified as Catalog
import Keiro.ReadModel.Rebuild qualified as Rebuild
import Kiroku.Store.Effect (Store)
import Kiroku.Store.Subscription.Types qualified as KirokuSubscription
import CalendarDays.ProjectionCatalog.ProjectionCatalogHoles qualified as Holes
import Generated.CalendarDays.CalendarLookup.ReadModel qualified as RMCalendarLookup
must :: Show error => Either error value -> value
must = either (error . show) id
calendarWriterProjectionSet :: Catalog.ProjectionSet Holes.CalendarWriterEvent
calendarWriterProjectionSet =
Catalog.ProjectionSet
(must (Catalog.mkSourceId "all"))
(Catalog.ProjectionDefinition
(must (Catalog.mkProjectionId "calendar_writer"))
(must (Catalog.mkRebuildGroupId "calendar_rebuild"))
((must (Catalog.mkTargetId "calendar_table")) :| [])
(Catalog.Replayable (Catalog.ReplayAdapter Holes.decodeCalendarWriterReplay Holes.applyCalendarWriterReplay))
(Catalog.AsyncHandler (AsyncProjection "calendar-writer-v1" "calendar-days-calendar-lookup" "calendar-writer" Holes.applyCalendarWriterLive Holes.calendarWriterIdempotencyKey) (must (Catalog.mkSubscriptionId "calendar-writer")) (must (Catalog.mkDedupKeyId "calendar-writer-v1")) (must (Catalog.mkClaimSite "projection-owner calendar_writer async-handler")) :| [])
(must (Catalog.mkClaimSite "projection-owner calendar_writer"))
:| [])
(must (Catalog.mkClaimSite "projection-owner calendar_writer source"))
projectionCatalog :: Catalog.ProjectionCatalog
projectionCatalog =
Catalog.ProjectionCatalog
[Catalog.SourceDeclaration (must (Catalog.mkSourceId "all")) Catalog.AllStreams "all-streams/generated-codec/v1" (must (Catalog.mkClaimSite "source all"))]
[Catalog.TargetDeclaration (must (Catalog.mkTargetId "calendar_table")) (Catalog.QualifiedTable "public" "calendar_values") Catalog.ClearBeforeReplay [] (must (Catalog.mkClaimSite "target calendar_table"))]
[Catalog.RebuildGroupDeclaration (must (Catalog.mkRebuildGroupId "calendar_rebuild")) [(must (Catalog.mkTargetId "calendar_table"))] [] (must (Catalog.mkClaimSite "rebuild-group calendar_rebuild"))]
[]
[]
[Catalog.SubscriptionDeclaration (must (Catalog.mkSubscriptionId "calendar-writer")) "calendar-writer" (must (Catalog.mkSourceId "all")) KirokuSubscription.FromBeginning (must (Catalog.mkClaimSite "projection-owner calendar_writer subscription"))]
[Catalog.DedupKeyDeclaration (must (Catalog.mkDedupKeyId "calendar-writer-v1")) "calendar-writer-v1" (must (Catalog.mkClaimSite "projection-owner calendar_writer dedup"))]
[Catalog.SomeQueryModelBinding (Catalog.QueryModelBinding (must (Catalog.mkQueryModelId "calendar_lookup")) RMCalendarLookup.calendarLookupReadModel (must (Catalog.mkRebuildGroupId "calendar_rebuild")) [(must (Catalog.mkTargetId "calendar_table"))] (must (Catalog.mkClaimSite "readmodel calendar_lookup")))]
[Catalog.SomeProjectionSet calendarWriterProjectionSet]
validatedProjectionCatalog :: Catalog.ValidatedProjectionCatalog
validatedProjectionCatalog = case Catalog.validateProjectionCatalog projectionCatalog of
Catalog.Success catalog -> catalog
Catalog.Failure diagnostics -> error ("keiro-dsl generated an invalid projection catalog: " <> show diagnostics)
projectionCatalogInventory :: Catalog.CatalogInventory
projectionCatalogInventory = Catalog.catalogInventory validatedProjectionCatalog
projectionCatalogRegistrations :: [Catalog.CatalogRegistration]
projectionCatalogRegistrations = Catalog.catalogRegistrations validatedProjectionCatalog
projectionCatalogAsyncRegistrations :: [Catalog.AsyncProjectionRegistration]
projectionCatalogAsyncRegistrations = Catalog.asyncProjectionRegistrations validatedProjectionCatalog
projectionCatalogQuerySupplies :: [Catalog.ResolvedQuerySupply]
projectionCatalogQuerySupplies = Catalog.resolvedQuerySupplies validatedProjectionCatalog
registerProjectionCatalog :: (Store :> es) => Eff es (Either Rebuild.CatalogRegistrationError [Rebuild.GroupRebuildMetadata])
registerProjectionCatalog = Rebuild.registerProjectionCatalog validatedProjectionCatalog
calendarRebuildRebuildGroupId :: Catalog.RebuildGroupId
calendarRebuildRebuildGroupId = (must (Catalog.mkRebuildGroupId "calendar_rebuild"))
startCalendarRebuildRebuild :: (IOE :> es, Store :> es) => Rebuild.RebuildOptions -> Eff es (Either Rebuild.CatalogRebuildError Rebuild.RebuildRunReport)
startCalendarRebuildRebuild = Rebuild.startCatalogRebuild validatedProjectionCatalog calendarRebuildRebuildGroupId