keiro-dsl-0.7.0.0: test/conformance-scalar-expressions/Generated/AggregateScalarExpressions/ScalarAccount/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.AggregateScalarExpressions.ScalarAccount.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 Generated.AggregateScalarExpressions.Nominals (AccountMode (..), RequestId (..))
import Data.Time.Calendar (fromGregorian)
import Data.Time.Clock (UTCTime(..), picosecondsToDiffTime)
import Numeric.Natural (Natural)
import ScalarExpressions.Bindings qualified
import ScalarExpressions.Domain qualified
import Keiki.Generics.TH (deriveAggregateCtorsAll, deriveWireCtorsAll)
data ScalarAccountVertex = ScalarAccountOpen | ScalarAccountReviewed | ScalarAccountClosed
deriving stock (Generic, Eq, Ord, Show, Enum, Bounded)
deriving anyclass (ToJSON, FromJSON)
instance CanonicalStateShape ScalarAccountVertex
instance CanonicalTypeName ScalarAccountVertex
data AdjustData = AdjustData
{ balance :: !Integer
, requested :: !Natural
, machine :: !Int
, label :: !Text
, active :: !Bool
, mode :: !AccountMode
, requestId :: !RequestId
, observedAt :: !UTCTime
, limits :: !ScalarExpressions.Domain.Limits
}
deriving stock (Generic, Eq, Show)
data CloseData = CloseData
{ balance :: !Integer
}
deriving stock (Generic, Eq, Show)
data ScalarAccountCommand = Adjust !AdjustData
| Close !CloseData
deriving stock (Generic, Eq, Show)
data AdjustedData = AdjustedData
{ balance :: !Integer
, requested :: !Natural
, machine :: !Int
, label :: !Text
, active :: !Bool
, mode :: !AccountMode
, requestId :: !RequestId
, observedAt :: !UTCTime
, limits :: !ScalarExpressions.Domain.Limits
}
deriving stock (Generic, Eq, Show)
data ClosedEventData = ClosedEventData
{ balance :: !Integer
}
deriving stock (Generic, Eq, Show)
data ScalarAccountEvent = Adjusted !AdjustedData
| ClosedEvent !ClosedEventData
deriving stock (Generic, Eq, Show)
type ScalarAccountRegs =
'[ '("balance", Integer)
, '("reserved", Natural)
, '("capacity", Natural)
, '("machine", Int)
, '("label", Text)
, '("active", Bool)
, '("mode", AccountMode)
, '("requestId", RequestId)
, '("openedAt", UTCTime)
, '("limits", ScalarExpressions.Domain.Limits)
]
initialScalarAccountRegs :: RegFile ScalarAccountRegs
initialScalarAccountRegs =
RCons (Proxy @"balance") 0 $
RCons (Proxy @"reserved") 0 $
RCons (Proxy @"capacity") 5 $
RCons (Proxy @"machine") 0 $
RCons (Proxy @"label") "" $
RCons (Proxy @"active") False $
RCons (Proxy @"mode") Normal $
RCons (Proxy @"requestId") (RequestId "") $
RCons (Proxy @"openedAt") (UTCTime (fromGregorian 2026 1 1) (picosecondsToDiffTime 0)) $
RCons (Proxy @"limits") ScalarExpressions.Bindings.initialLimits RNil
$(deriveAggregateCtorsAll ''ScalarAccountCommand ''ScalarAccountRegs)
$(deriveWireCtorsAll ''ScalarAccountEvent)