packages feed

notion-client 0.7.0.0 → 0.7.0.1

raw patch · 4 files changed

+32/−5 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for notion-client +## 0.7.0.1 (2026-04-16)++### Bug Fixes+* Fix `FromJSON`/`ToJSON` for native icons to use the nested `{"type":"icon","icon":{"name":..., "color":...}}` shape returned by GET endpoints — previously crashed with `key "name" not found` on pages/databases carrying built-in pictogram icons+ ## 0.7.0.0 (2026-04-16)  ### Breaking Changes
notion-client.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.4 name:               notion-client-version:            0.7.0.0+version:            0.7.0.1 synopsis:           Type-safe Haskell client for the Notion API description:   This package provides comprehensive and type-safe bindings
src/Notion/V1/Common.hs view
@@ -147,7 +147,9 @@         "emoji" -> EmojiIcon <$> o .: "emoji"         "file" -> FileIcon <$> o .: "file"         "external" -> ExternalIcon <$> o .: "external"-        "icon" -> NativeIcon <$> o .: "name" <*> o .:? "color"+        "icon" -> do+          inner <- o .: "icon"+          NativeIcon <$> inner .: "name" <*> inner .:? "color"         "custom_emoji" -> CustomEmojiIcon <$> o .: "id"         "file_upload" -> do           uploadObj <- o .: "file_upload"@@ -159,7 +161,11 @@   toJSON (EmojiIcon emoji) = object ["type" .= ("emoji" :: Text), "emoji" .= emoji]   toJSON (FileIcon file) = object ["type" .= ("file" :: Text), "file" .= file]   toJSON (ExternalIcon external) = object ["type" .= ("external" :: Text), "external" .= external]-  toJSON (NativeIcon name color) = object $ ["type" .= ("icon" :: Text), "name" .= name] <> maybe [] (\c -> ["color" .= c]) color+  toJSON (NativeIcon name color) =+    object+      [ "type" .= ("icon" :: Text),+        "icon" .= object (["name" .= name] <> maybe [] (\c -> ["color" .= c]) color)+      ]   toJSON (CustomEmojiIcon eid) = object ["type" .= ("custom_emoji" :: Text), "id" .= eid]   toJSON (FileUploadIcon uid) = object ["type" .= ("file_upload" :: Text), "file_upload" .= object ["id" .= uid]] 
tasty/Main.hs view
@@ -3,6 +3,7 @@ import Data.Aeson qualified as Aeson import Data.Aeson.Key qualified as Key import Data.Aeson.KeyMap qualified as KeyMap+import Data.ByteString.Lazy.Char8 qualified as L8 import Data.IORef (modifyIORef', newIORef, readIORef) import Data.Map qualified as Map import Data.Scientific (Scientific)@@ -649,6 +650,7 @@       testCase "MovePage serialization" testSerializeMovePage,       testCase "ViewType round-trip" testViewTypeRoundTrip,       testCase "NativeIcon round-trip" testNativeIconRoundTrip,+      testCase "NativeIcon read shape" testNativeIconReadShape,       testCase "CustomEmojiIcon round-trip" testCustomEmojiIconRoundTrip,       testCase "CreateView serialization" testSerializeCreateView,       testCase "UpdateView omits Nothing fields" testSerializeUpdateView,@@ -812,8 +814,11 @@   case json of     Aeson.Object o -> do       assertEqual "type" (Just (Aeson.String "icon")) (KeyMap.lookup "type" o)-      assertEqual "name" (Just (Aeson.String "check")) (KeyMap.lookup "name" o)-      assertEqual "color" (Just (Aeson.String "green")) (KeyMap.lookup "color" o)+      case KeyMap.lookup "icon" o of+        Just (Aeson.Object inner) -> do+          assertEqual "name" (Just (Aeson.String "check")) (KeyMap.lookup "name" inner)+          assertEqual "color" (Just (Aeson.String "green")) (KeyMap.lookup "color" inner)+        _ -> assertFailure "Expected nested icon object"     _ -> assertFailure "Expected JSON object"   case Aeson.fromJSON json of     Aeson.Success (NativeIcon n c) -> do@@ -821,6 +826,17 @@       assertEqual "color round-trip" (Just "green") c     Aeson.Success _ -> assertFailure "Expected NativeIcon"     Aeson.Error err -> assertFailure $ "Decode failed: " <> err++testNativeIconReadShape :: Assertion+testNativeIconReadShape = do+  let payload :: L8.ByteString+      payload = "{\"type\":\"icon\",\"icon\":{\"name\":\"clipping\",\"color\":\"lightgray\"}}"+  case Aeson.eitherDecode payload of+    Right (NativeIcon n c) -> do+      assertEqual "name" "clipping" n+      assertEqual "color" (Just "lightgray") c+    Right _ -> assertFailure "Expected NativeIcon"+    Left err -> assertFailure $ "Decode failed: " <> err  testCustomEmojiIconRoundTrip :: Assertion testCustomEmojiIconRoundTrip = do