packages feed

keiro-dsl-0.2.0.0: test/conformance-coldstart/Generated/Billing/Subscription/Projection.hs

{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
-- @generated by keiro-dsl; do not edit. Regenerated from the .keiro spec.
module Generated.Billing.Subscription.Projection
  ( subscriptionsProjection
  , subscriptionsStatusFor
  ) where

import Generated.Billing.Subscription.Domain
import Billing.Subscription.Holes (applySubscriptions)
import Data.Text (Text)
import Keiro.Projection (InlineProjection (..))

-- The deterministic event->status mapping (hole-kind 3, /mapping/), derived
-- from the spec's status-map. The read-model SQL that consumes it lives in
-- the hand-owned Holes module (a DB-coupled hole, delegated to codd).
subscriptionsStatusFor :: SubscriptionEvent -> Maybe Text
subscriptionsStatusFor = \case
  SubscriptionActivated {} -> Just "active"
  SubscriptionCancelled {} -> Just "cancelled"

subscriptionsProjection :: InlineProjection SubscriptionEvent
subscriptionsProjection =
  InlineProjection
    { name = "billing-subscriptions-inline"
    , apply = applySubscriptions
    }