keiro-core 0.24.0.0 → 0.26.0.0
raw patch · 3 files changed
Files
- CHANGELOG.md +21/−0
- keiro-core.cabal +1/−1
- src/Keiro/Integration/Event.hs +28/−0
CHANGELOG.md view
@@ -6,6 +6,27 @@ ## [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++- Version and internal dependency bounds align with the shared release.++## 0.25.0.0 — 2026-11-14++### Other Changes++- Version and internal dependency bounds align with the shared release.+ ## 0.24.0.0 — 2026-11-05 No changes this release.
keiro-core.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: keiro-core-version: 0.24.0.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