packages feed

bolt 0.1.0.1 → 0.1.0.2

raw patch · 5 files changed

+92/−4 lines, 5 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Database.Bolt.Protocol.Ver1.Graph: Node :: Identity -> [Label] -> Properties -> Node
+ Database.Bolt.Protocol.Ver1.Graph: Path :: [Node] -> [UnboundedRelationship] -> [Int64] -> Path
+ Database.Bolt.Protocol.Ver1.Graph: Relationship :: Identity -> Identity -> Identity -> Type -> Properties -> Relationship
+ Database.Bolt.Protocol.Ver1.Graph: UnboundedRelationship :: Identity -> Type -> Properties -> UnboundedRelationship
+ Database.Bolt.Protocol.Ver1.Graph: [endNodeIdentity] :: Relationship -> Identity
+ Database.Bolt.Protocol.Ver1.Graph: [nodeIdentity] :: Node -> Identity
+ Database.Bolt.Protocol.Ver1.Graph: [nodeLabels] :: Node -> [Label]
+ Database.Bolt.Protocol.Ver1.Graph: [nodeProperties] :: Node -> Properties
+ Database.Bolt.Protocol.Ver1.Graph: [pathNodes] :: Path -> [Node]
+ Database.Bolt.Protocol.Ver1.Graph: [pathRelationships] :: Path -> [UnboundedRelationship]
+ Database.Bolt.Protocol.Ver1.Graph: [pathSequence] :: Path -> [Int64]
+ Database.Bolt.Protocol.Ver1.Graph: [relIdentity] :: Relationship -> Identity
+ Database.Bolt.Protocol.Ver1.Graph: [relProperties] :: Relationship -> Properties
+ Database.Bolt.Protocol.Ver1.Graph: [relType] :: Relationship -> Type
+ Database.Bolt.Protocol.Ver1.Graph: [startNodeIdentity] :: Relationship -> Identity
+ Database.Bolt.Protocol.Ver1.Graph: [urelIdentity] :: UnboundedRelationship -> Identity
+ Database.Bolt.Protocol.Ver1.Graph: [urelProperties] :: UnboundedRelationship -> Properties
+ Database.Bolt.Protocol.Ver1.Graph: [urelType] :: UnboundedRelationship -> Type
+ Database.Bolt.Protocol.Ver1.Graph: data Node
+ Database.Bolt.Protocol.Ver1.Graph: data Path
+ Database.Bolt.Protocol.Ver1.Graph: data Relationship
+ Database.Bolt.Protocol.Ver1.Graph: data UnboundedRelationship
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.FromPackStream Database.Bolt.Protocol.Ver1.Graph.Node
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.FromPackStream Database.Bolt.Protocol.Ver1.Graph.Path
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.FromPackStream Database.Bolt.Protocol.Ver1.Graph.Relationship
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.FromPackStream Database.Bolt.Protocol.Ver1.Graph.UnboundedRelationship
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.ToPackStream Database.Bolt.Protocol.Ver1.Graph.Node
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.ToPackStream Database.Bolt.Protocol.Ver1.Graph.Path
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.ToPackStream Database.Bolt.Protocol.Ver1.Graph.Relationship
+ Database.Bolt.Protocol.Ver1.Graph: instance Data.PackStream.ToPackStream Database.Bolt.Protocol.Ver1.Graph.UnboundedRelationship
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Classes.Eq Database.Bolt.Protocol.Ver1.Graph.Node
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Classes.Eq Database.Bolt.Protocol.Ver1.Graph.Path
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Classes.Eq Database.Bolt.Protocol.Ver1.Graph.Relationship
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Classes.Eq Database.Bolt.Protocol.Ver1.Graph.UnboundedRelationship
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Show.Show Database.Bolt.Protocol.Ver1.Graph.Node
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Show.Show Database.Bolt.Protocol.Ver1.Graph.Path
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Show.Show Database.Bolt.Protocol.Ver1.Graph.Relationship
+ Database.Bolt.Protocol.Ver1.Graph: instance GHC.Show.Show Database.Bolt.Protocol.Ver1.Graph.UnboundedRelationship
+ Database.Bolt.Protocol.Ver1.Types: type Identity = Int64
+ Database.Bolt.Protocol.Ver1.Types: type Label = Text
+ Database.Bolt.Protocol.Ver1.Types: type Properties = Object
+ Database.Bolt.Protocol.Ver1.Types: type Type = Text

Files

bolt.cabal view
@@ -1,5 +1,5 @@ name:                bolt
-version:             0.1.0.1
+version:             0.1.0.2
 synopsis:            Bolt driver for Neo4j
 description:         Please see README.md
 homepage:            https://github.com/bflyblue/bolt#readme
@@ -19,6 +19,7 @@   exposed-modules:     Data.PackStream
                      , Database.Bolt.Exception
                      , Database.Bolt.Protocol.Ver1
+                     , Database.Bolt.Protocol.Ver1.Graph
                      , Database.Bolt.Protocol.Ver1.Message
                      , Database.Bolt.Protocol.Ver1.Pretty
                      , Database.Bolt.Protocol.Ver1.Request
src/Data/PackStream.hs view
@@ -184,7 +184,7 @@        | 0xa0 <= marker && marker < 0xb0
                           -> getMap (fromIntegral marker .&. 0x0f)
        | marker == 0xd8   -> fromIntegral <$> getWord8    >>= getMap
-       | marker == 0xd8   -> fromIntegral <$> getWord16be >>= getMap
+       | marker == 0xd9   -> fromIntegral <$> getWord16be >>= getMap
        | marker == 0xda   -> fromIntegral <$> getWord32be >>= getMap
 
        | 0xb0 <= marker && marker < 0xc0
@@ -221,7 +221,7 @@     |               -0x80 <= i && i < 0x80               = putWord8 0xc8 >> putWord8    (fromIntegral i)
     |             -0x8000 <= i && i < 0x8000             = putWord8 0xc9 >> putWord16be (fromIntegral i)
     |         -0x80000000 <= i && i < 0x80000000         = putWord8 0xca >> putWord32be (fromIntegral i)
-    | otherwise                                          = putWord8 0xca >> putWord64be (fromIntegral i)
+    | otherwise                                          = putWord8 0xcb >> putWord64be (fromIntegral i)
 
 putPackStream (String t) = do
     let size = T.length t
+ src/Database/Bolt/Protocol/Ver1/Graph.hs view
@@ -0,0 +1,82 @@+{-# LANGUAGE OverloadedStrings #-}
+
+module Database.Bolt.Protocol.Ver1.Graph
+ ( Node(..)
+ , Relationship(..)
+ , Path(..)
+ , UnboundedRelationship(..)
+ )
+where
+
+import           Data.Int
+import           Data.PackStream
+
+import           Database.Bolt.Protocol.Ver1.Types
+
+data Node = Node
+    { nodeIdentity      :: Identity
+    , nodeLabels        :: [Label]
+    , nodeProperties    :: Properties
+    } deriving (Show, Eq)
+
+data Relationship = Relationship
+    { relIdentity       :: Identity
+    , startNodeIdentity :: Identity
+    , endNodeIdentity   :: Identity
+    , relType           :: Type
+    , relProperties     :: Properties
+    } deriving (Show, Eq)
+
+data Path = Path
+    { pathNodes         :: [Node]
+    , pathRelationships :: [UnboundedRelationship]
+    , pathSequence      :: [Int64]
+    } deriving (Show, Eq)
+
+data UnboundedRelationship = UnboundedRelationship
+    { urelIdentity      :: Identity
+    , urelType          :: Type
+    , urelProperties    :: Properties
+    } deriving (Show, Eq)
+
+instance ToPackStream Node where
+    toPackStream (Node nodeid labels props) = Struct 0x4e [toPackStream nodeid, toPackStream labels, toPackStream props]
+
+instance FromPackStream Node where
+    parsePackStream s = do
+        struct <- parsePackStream s
+        case struct of
+            (Struct 0x4e [nodeid, labels, props]) -> Node <$> parsePackStream nodeid <*> parsePackStream labels <*> parsePackStream props
+            _                                     -> error "Invalid Node"
+
+instance ToPackStream Relationship where
+    toPackStream (Relationship relid start end ty props) = Struct 0x52 [ toPackStream relid, toPackStream start, toPackStream end
+                                                                       , toPackStream ty, toPackStream props ]
+
+instance FromPackStream Relationship where
+    parsePackStream s = do
+        struct <- parsePackStream s
+        case struct of
+            (Struct 0x52 [relid, start, end, ty, props]) -> Relationship <$> parsePackStream relid <*> parsePackStream start <*> parsePackStream end
+                                                                         <*> parsePackStream ty <*> parsePackStream props
+            _                                            -> error "Invalid Relationship"
+
+instance ToPackStream Path where
+    toPackStream (Path nodes rels seqn) = Struct 0x50 [ toPackStream nodes, toPackStream rels, toPackStream seqn]
+
+instance FromPackStream Path where
+    parsePackStream s = do
+        struct <- parsePackStream s
+        case struct of
+            (Struct 0x50 [nodes, rels, seqn]) -> Path <$> parsePackStream nodes <*> parsePackStream rels <*> parsePackStream seqn
+            _                                 -> error "Invalid Path"
+
+instance ToPackStream UnboundedRelationship where
+    toPackStream (UnboundedRelationship relid ty props) = Struct 0x72 [toPackStream relid, toPackStream ty, toPackStream props]
+
+instance FromPackStream UnboundedRelationship where
+    parsePackStream s = do
+        struct <- parsePackStream s
+        case struct of
+            (Struct 0x72 [relid, ty, props]) -> UnboundedRelationship <$> parsePackStream relid <*> parsePackStream ty <*> parsePackStream props
+            _                                -> error "Invalid UnboundedRelationship"
src/Database/Bolt/Protocol/Ver1/Message.hs view
@@ -50,7 +50,7 @@             (Struct 0x71 value)                  -> return $ Record  value
             (Struct 0x7e [metadata])             -> Ignored <$> parsePackStream metadata
             (Struct 0x7f [metadata])             -> Failure <$> parsePackStream metadata
-            _                                    -> error "Invalid message"
+            _                                    -> error "Invalid Message"
 
 data AuthToken = NoAuth
                | Basic Principal Credentials
src/Database/Bolt/Protocol/Ver1/Types.hs view
@@ -1,5 +1,6 @@ module Database.Bolt.Protocol.Ver1.Types where
 
+import           Data.Int
 import qualified Data.HashMap.Strict as HM
 import           Data.PackStream
 import           Data.Text           (Text)
@@ -8,8 +9,12 @@ type Principal   = Text
 type Credentials = Text
 type Statement   = Text
+type Label       = Text
+type Type        = Text
+type Identity    = Int64
 
 type Object      = HM.HashMap Text PackStream
 type Parameters  = Object
+type Properties  = Object
 type Metadata    = Object
 type Record      = [PackStream]