packages feed

keiro-dsl-0.12.0.0: test/conformance-skeletons/SkelWorkflow/Generated/MyService/HospitalTransferReservation/WorkflowRuntime.hs

-- @generated by keiro-dsl 0.11.0.0 (language keiro-dsl 4) from workflow HospitalTransferReservation; do not edit.
module SkelWorkflow.Generated.MyService.HospitalTransferReservation.WorkflowRuntime
  ( workflowName
  , AwaitBinding
  , allocateDeclaredAwait
  , reservationConfirmationAwait
  , awaitLabels
  , declaredPatches
  , declaredPatchStepNames
  , withDeclaredPatches
  ) where

import Data.Aeson (FromJSON)
import Data.Set (Set)
import Data.Set qualified as Set
import Data.Text (Text)
import Effectful (Eff, IOE, (:>))
import Keiro.Workflow (StepName (..), Workflow, WorkflowRunOptions (..))
import Keiro.Workflow.Awakeable (AwakeableId, awakeableNamed)
import Keiro.Workflow.Types (PatchId (..), WorkflowName (..), patchStepName)
import Kiroku.Store.Effect (Store)

workflowName :: WorkflowName
workflowName = WorkflowName "hospital-transfer-reservation"

-- | A declared await label. The constructor stays private so consumers
-- can allocate only labels that exist in the source workflow.
data AwaitBinding = AwaitBinding StepName

allocateDeclaredAwait
  :: (Workflow :> es, Store :> es, IOE :> es, FromJSON a)
  => AwaitBinding
  -> Eff es (AwakeableId, Eff es a)
allocateDeclaredAwait (AwaitBinding label) = awakeableNamed label

reservationConfirmationAwait :: AwaitBinding
reservationConfirmationAwait = AwaitBinding (StepName "reservation-confirmation")

awaitLabels :: [Text]
awaitLabels = ["reservation-confirmation"]

declaredPatches :: Set PatchId
declaredPatches = Set.fromList []

-- The journal keys the runtime records patch decisions under.
declaredPatchStepNames :: [Text]
declaredPatchStepNames = map patchStepName (Set.toList declaredPatches)

-- Activate exactly the patches declared by this spec for a workflow run.
withDeclaredPatches :: WorkflowRunOptions -> WorkflowRunOptions
withDeclaredPatches opts = opts{activePatches = declaredPatches}