keiro-dsl-0.10.0.0: test/conformance-scalar-expressions/Generated/AggregateScalarExpressions/ScalarAccount/Domain.hs
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
-- @generated by keiro-dsl 0.9.0.0 (language keiro-dsl 4) from aggregate ScalarAccount; do not edit.
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, parseRequestId)
import Data.Time.Calendar (fromGregorian)
import Data.Time.Clock (UTCTime(..), picosecondsToDiffTime)
import Numeric.Natural (Natural)
import ScalarExpressions.Bindings qualified as Bindings
import ScalarExpressions.Domain (Limits)
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 :: !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 :: !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", 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") (case parseRequestId "req_01h455vb4pex5vsknk084sn02q" of Right parsed -> parsed; Left _ -> error "generated valid ID sample failed to parse") $
RCons (Proxy @"openedAt") (UTCTime (fromGregorian 2026 1 1) (picosecondsToDiffTime 0)) $
RCons (Proxy @"limits") Bindings.initialLimits RNil
$(deriveAggregateCtorsAll ''ScalarAccountCommand ''ScalarAccountRegs)
$(deriveWireCtorsAll ''ScalarAccountEvent)