packages feed

keiro-dsl-0.7.0.0: test/conformance-behavior-complete/Generated/BehaviorComplete/Journey/Domain.hs

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module Generated.BehaviorComplete.Journey.Domain where

import Data.Aeson (FromJSON, ToJSON)
import Data.Proxy (Proxy (..))
import Data.Text (Text)
import GHC.Generics (Generic)
import Keiki.Core (RegFile (..))
import Keiki.Shape (CanonicalStateShape, CanonicalTypeName)
import BehaviorComplete.Domain qualified
import Data.Time.Calendar (fromGregorian)
import Data.Time.Clock (UTCTime(..), picosecondsToDiffTime)
import Numeric.Natural (Natural)
import Keiki.Generics.TH (deriveAggregateCtorsAll, deriveWireCtorsAll)

newtype RequestId = RequestId Text
  deriving stock (Generic, Eq, Ord, Show)
  deriving anyclass (ToJSON, FromJSON)
instance CanonicalTypeName RequestId

requestIdText :: RequestId -> Text
requestIdText (RequestId t) = t

data JourneyVertex = JourneyEmpty | JourneyActive | JourneyClosed
  deriving stock (Generic, Eq, Ord, Show, Enum, Bounded)
  deriving anyclass (ToJSON, FromJSON)
instance CanonicalStateShape JourneyVertex
instance CanonicalTypeName JourneyVertex

data StartData = StartData
  { requestId :: !RequestId
  , observedAt :: !UTCTime
  , amount :: !Natural
  , details :: !BehaviorComplete.Domain.StartPayload
  }
  deriving stock (Generic, Eq, Show)

data DecideData = DecideData
  { amount :: !Natural
  }
  deriving stock (Generic, Eq, Show)

data PingData = PingData
  { token :: !Bool
  }
  deriving stock (Generic, Eq, Show)

data RetireData = RetireData
  { amount :: !Natural
  }
  deriving stock (Generic, Eq, Show)

data JourneyCommand = Start !StartData
  | Decide !DecideData
  | Ping !PingData
  | Retire !RetireData
  deriving stock (Generic, Eq, Show)

data StartedData = StartedData
  { requestId :: !RequestId
  , observedAt :: !UTCTime
  , amount :: !Natural
  , details :: !BehaviorComplete.Domain.StartPayload
  }
  deriving stock (Generic, Eq, Show)

data DecisionRecordedData = DecisionRecordedData
  { amount :: !Natural
  }
  deriving stock (Generic, Eq, Show)

data RetiredData = RetiredData
  { amount :: !Natural
  }
  deriving stock (Generic, Eq, Show)

data RetirementAuditedData = RetirementAuditedData
  { amount :: !Natural
  }
  deriving stock (Generic, Eq, Show)

data JourneyEvent = Started !StartedData
  | DecisionRecorded !DecisionRecordedData
  | Retired !RetiredData
  | RetirementAudited !RetirementAuditedData
  deriving stock (Generic, Eq, Show)

type JourneyRegs =
  '[ '("lastAmount", Natural)
   ]

initialJourneyRegs :: RegFile JourneyRegs
initialJourneyRegs =
  RCons (Proxy @"lastAmount") 0 RNil

$(deriveAggregateCtorsAll ''JourneyCommand ''JourneyRegs)



$(deriveWireCtorsAll ''JourneyEvent)