packages feed

keiro-core 0.25.1.0 → 0.26.0.0

raw patch · 3 files changed

+38/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Keiro.Integration.Event: decodeJsonIntegrationEventWith :: (Text -> Value -> Either Text a) -> IntegrationEvent -> Either IntegrationEventError a

Files

CHANGELOG.md view
@@ -6,6 +6,15 @@  ## [Unreleased] +## 0.26.0.0 — 2026-11-18++### New Features++- `Keiro.Integration.Event.decodeJsonIntegrationEventWith` decodes an envelope's JSON+  payload with a parser that also receives the envelope's `eventType`, reporting the+  parser's `Left` as `DecodeFailed`. It joins an envelope to the `parse<Contract>PayloadAs`+  decoder keiro-dsl generates for a `discriminator from envelope` contract. (IR-64)+ ## 0.25.1.0 — 2026-11-16  ### Other Changes
keiro-core.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: keiro-core-version: 0.25.1.0+version: 0.26.0.0 synopsis: Core contracts for Keiro packages description:   Stable stream, codec, event-stream, and integration-event contracts
src/Keiro/Integration/Event.hs view
@@ -21,6 +21,7 @@     -- * JSON convenience helpers     encodeJsonIntegrationEvent,     decodeJsonIntegrationEvent,+    decodeJsonIntegrationEventWith,      -- * Wire mapping     integrationPayload,@@ -289,6 +290,33 @@     Right value -> Right (value :: Value)   case parseEither parseJSON parsed of     Left err -> Left (DecodeFailed (Text.pack err))+    Right value -> Right value++-- | Decode a JSON payload with a parser that also receives the envelope's+-- 'eventType'.+--+-- This joins an envelope to a decoder whose payload carries no body+-- discriminator, such as the @parse\<Contract\>PayloadAs@ function that+-- keiro-dsl generates for a contract declared with+-- @discriminator from envelope@. The parser chooses the event from the+-- event type and should reject a type it does not declare.+--+-- Returns 'UnsupportedContentType' if the envelope's 'contentType' is not+-- 'ApplicationJson', 'MalformedPayload' if the bytes are not valid JSON, and+-- 'DecodeFailed' with the parser's message if the parser returns 'Left'.+decodeJsonIntegrationEventWith ::+  (Text -> Value -> Either Text a) ->+  IntegrationEvent ->+  Either IntegrationEventError a+decodeJsonIntegrationEventWith parser event = do+  case event ^. #contentType of+    ApplicationJson -> pure ()+    OtherContentType raw -> Left (UnsupportedContentType raw)+  parsed <- case Aeson.eitherDecodeStrict (event ^. #payloadBytes) of+    Left err -> Left (MalformedPayload (Text.pack err))+    Right value -> Right (value :: Value)+  case parser (event ^. #eventType) parsed of+    Left err -> Left (DecodeFailed err)     Right value -> Right value  eventIdToUuid :: EventId -> UUID.UUID