-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A Haskell neo4j client
--   
--   Library to interact with Neo4j databases.
--   
--   This library covers:
--   
--   <ul>
--   <li>Cypher transactions</li>
--   <li>CRUD operations for nodes, relationships, labels and indexes</li>
--   <li>Batch calls for CRUD operations.</li>
--   <li>Traversal API</li>
--   <li>Authentication</li>
--   <li>SSL</li>
--   </ul>
--   
--   All code has been tested with Neo4j versions 2.0.3, 2.1.5, 2.1.7,
--   2.2.0 and 2.2.1
@package haskell-neo4j-client
@version 0.3.2.4

module Database.Neo4j.Types
newtype Neo4jVersion
Neo4jVersion :: Version -> Neo4jVersion
[runVersion] :: Neo4jVersion -> Version
(<>) :: (Monoid a) => a -> a -> a

-- | Type for a single value of a Neo4j property
data Val
IntVal :: Int64 -> Val
BoolVal :: Bool -> Val
TextVal :: Text -> Val
DoubleVal :: Double -> Val

-- | Wrapping type for a Neo4j single property or array of properties Using
--   these types allows type checking for only correct properties that is
--   int, double, string, boolean and single typed arrays of these, also
--   nulls are not allowed
data PropertyValue
ValueProperty :: Val -> PropertyValue
ArrayProperty :: [Val] -> PropertyValue

-- | This class allows easy construction of property value types from
--   literals
class PropertyValueConstructor a
newval :: PropertyValueConstructor a => a -> PropertyValue

-- | This operator allows easy construction of property value types from
--   literals
(|:) :: PropertyValueConstructor a => Text -> a -> (Text, PropertyValue)

-- | Specifying how to convert property single values to JSON

-- | Specifying how to convert property values to JSON

-- | JSON to single property values

-- | JSON to property values

-- | We use hashmaps to represent Neo4j properties
type Properties = HashMap Text PropertyValue

-- | Shortcut for emtpy properties
emptyProperties :: HashMap Text PropertyValue

-- | Tries to get the path from a URL, we try our best otherwise return the
--   url as is
urlPath :: Text -> Text

-- | Path without the <i>db</i>data part, useful for batch paths and such
urlMinPath :: Text -> Text
data EntityObj
EntityNode :: Node -> EntityObj
EntityRel :: Relationship -> EntityObj

-- | Class for top-level Neo4j entities (nodes and relationships) useful to
--   have generic property management code
class Entity a
entityPath :: Entity a => a -> ByteString
propertyPath :: Entity a => a -> ByteString
getEntityProperties :: Entity a => a -> Properties
setEntityProperties :: Entity a => a -> Properties -> a
entityObj :: Entity a => a -> EntityObj
newtype NodeUrl
NodeUrl :: Text -> NodeUrl
[runNodeUrl] :: NodeUrl -> Text

-- | Representation of a Neo4j node, has a location URI and a set of
--   properties
data Node
Node :: NodePath -> Properties -> Node
[nodePath] :: Node -> NodePath
[nodeProperties] :: Node -> Properties

-- | Get the properties of a node
getNodeProperties :: Node -> Properties

-- | JSON to Node
nodeAPI :: ByteString
nodeAPITxt :: Text
newtype NodePath
NodePath :: Text -> NodePath
[runNodePath] :: NodePath -> Text
class NodeIdentifier a
getNodePath :: NodeIdentifier a => a -> NodePath
runNodeIdentifier :: NodeIdentifier a => a -> ByteString

-- | Type for a relationship type description
type RelationshipType = Text

-- | Relationship direction
data Direction
Outgoing :: Direction
Incoming :: Direction
Any :: Direction

-- | Type for a relationship location
newtype RelUrl
RelUrl :: Text -> RelUrl
[runRelUrl] :: RelUrl -> Text

-- | Type for a Neo4j relationship, has a location URI, a relationship
--   type, a starting node and a destination node
data Relationship
Relationship :: RelPath -> RelationshipType -> Properties -> NodePath -> NodePath -> Relationship
[relPath] :: Relationship -> RelPath
[relType] :: Relationship -> RelationshipType
[relProperties] :: Relationship -> Properties
[relFrom] :: Relationship -> NodePath
[relTo] :: Relationship -> NodePath

-- | Get the properties of a relationship
getRelProperties :: Relationship -> Properties

-- | Get the type of a relationship
getRelType :: Relationship -> RelationshipType

-- | JSON to Relationship
relationshipAPI :: ByteString
relationshipAPITxt :: Text
newtype RelPath
RelPath :: Text -> RelPath
[runRelPath] :: RelPath -> Text
class RelIdentifier a
getRelPath :: RelIdentifier a => a -> RelPath
runRelIdentifier :: RelIdentifier a => a -> ByteString
data EntityPath
EntityRelPath :: RelPath -> EntityPath
EntityNodePath :: NodePath -> EntityPath
class EntityIdentifier a
getEntityPath :: EntityIdentifier a => a -> EntityPath

-- | Type for a label
type Label = Text

-- | Type for an index
data Index
Index :: Label -> [Text] -> Index
[indexLabel] :: Index -> Label
[indexProperties] :: Index -> [Text]

-- | JSON to Index

-- | Exceptions this library can raise
data Neo4jException
Neo4jHttpException :: String -> Neo4jException
Neo4jNonOrphanNodeDeletionException :: ByteString -> Neo4jException
Neo4jNoEntityException :: ByteString -> Neo4jException
Neo4jUnexpectedResponseException :: Status -> Neo4jException
Neo4jNoSuchProperty :: Text -> Neo4jException
Neo4jBatchException :: ByteString -> Neo4jException
Neo4jParseException :: String -> Neo4jException
TransactionEndedExc :: Neo4jException

-- | Type for a connection
data Connection
Connection :: Hostname -> Port -> Manager -> Maybe Credentials -> Bool -> Connection
[dbHostname] :: Connection -> Hostname
[dbPort] :: Connection -> Port
[manager] :: Connection -> Manager
[dbCredentials] :: Connection -> Maybe Credentials
[dbSecure] :: Connection -> Bool
type Hostname = ByteString
type Port = Int
type Credentials = (Username, Password)
type Username = ByteString
type Password = ByteString
getUsername :: Credentials -> ByteString
getPassword :: Credentials -> ByteString

-- | Neo4j monadic type to be able to sequence neo4j commands in a
--   connection
newtype Neo4j a
Neo4j :: (Connection -> IO a) -> Neo4j a
[runNeo4j] :: Neo4j a -> Connection -> IO a
instance GHC.Classes.Eq Database.Neo4j.Types.Neo4jException
instance GHC.Show.Show Database.Neo4j.Types.Neo4jException
instance GHC.Classes.Eq Database.Neo4j.Types.Index
instance GHC.Show.Show Database.Neo4j.Types.Index
instance GHC.Classes.Eq Database.Neo4j.Types.EntityPath
instance GHC.Show.Show Database.Neo4j.Types.EntityPath
instance GHC.Show.Show Database.Neo4j.Types.EntityObj
instance GHC.Classes.Eq Database.Neo4j.Types.EntityObj
instance GHC.Classes.Eq Database.Neo4j.Types.Relationship
instance GHC.Show.Show Database.Neo4j.Types.Relationship
instance GHC.Generics.Generic Database.Neo4j.Types.RelPath
instance GHC.Classes.Ord Database.Neo4j.Types.RelPath
instance GHC.Classes.Eq Database.Neo4j.Types.RelPath
instance GHC.Show.Show Database.Neo4j.Types.RelPath
instance GHC.Generics.Generic Database.Neo4j.Types.RelUrl
instance GHC.Classes.Eq Database.Neo4j.Types.RelUrl
instance GHC.Show.Show Database.Neo4j.Types.RelUrl
instance GHC.Show.Show Database.Neo4j.Types.Direction
instance GHC.Classes.Eq Database.Neo4j.Types.Direction
instance GHC.Classes.Eq Database.Neo4j.Types.Node
instance GHC.Show.Show Database.Neo4j.Types.Node
instance GHC.Generics.Generic Database.Neo4j.Types.NodePath
instance GHC.Classes.Eq Database.Neo4j.Types.NodePath
instance GHC.Classes.Ord Database.Neo4j.Types.NodePath
instance GHC.Show.Show Database.Neo4j.Types.NodePath
instance GHC.Generics.Generic Database.Neo4j.Types.NodeUrl
instance GHC.Classes.Eq Database.Neo4j.Types.NodeUrl
instance GHC.Show.Show Database.Neo4j.Types.NodeUrl
instance GHC.Classes.Eq Database.Neo4j.Types.PropertyValue
instance GHC.Show.Show Database.Neo4j.Types.PropertyValue
instance GHC.Classes.Eq Database.Neo4j.Types.Val
instance GHC.Show.Show Database.Neo4j.Types.Val
instance Database.Neo4j.Types.PropertyValueConstructor GHC.Int.Int64
instance Database.Neo4j.Types.PropertyValueConstructor GHC.Types.Bool
instance Database.Neo4j.Types.PropertyValueConstructor Data.Text.Internal.Text
instance Database.Neo4j.Types.PropertyValueConstructor GHC.Types.Double
instance Database.Neo4j.Types.PropertyValueConstructor [GHC.Int.Int64]
instance Database.Neo4j.Types.PropertyValueConstructor [GHC.Types.Bool]
instance Database.Neo4j.Types.PropertyValueConstructor [Data.Text.Internal.Text]
instance Database.Neo4j.Types.PropertyValueConstructor [GHC.Types.Double]
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Types.Val
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Types.PropertyValue
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Types.Val
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Types.PropertyValue
instance Data.Hashable.Class.Hashable Database.Neo4j.Types.NodeUrl
instance GHC.Classes.Ord Database.Neo4j.Types.Node
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Types.Node
instance Database.Neo4j.Types.Entity Database.Neo4j.Types.Node
instance Data.Hashable.Class.Hashable Database.Neo4j.Types.NodePath
instance Database.Neo4j.Types.NodeIdentifier Database.Neo4j.Types.Node
instance Database.Neo4j.Types.NodeIdentifier Data.ByteString.Internal.ByteString
instance Database.Neo4j.Types.NodeIdentifier GHC.Integer.Type.Integer
instance Database.Neo4j.Types.NodeIdentifier Database.Neo4j.Types.NodePath
instance Database.Neo4j.Types.NodeIdentifier Database.Neo4j.Types.NodeUrl
instance Data.Hashable.Class.Hashable Database.Neo4j.Types.RelUrl
instance GHC.Classes.Ord Database.Neo4j.Types.Relationship
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Types.Relationship
instance Database.Neo4j.Types.Entity Database.Neo4j.Types.Relationship
instance Database.Neo4j.Types.Entity Database.Neo4j.Types.EntityObj
instance Data.Hashable.Class.Hashable Database.Neo4j.Types.RelPath
instance Database.Neo4j.Types.RelIdentifier Database.Neo4j.Types.Relationship
instance Database.Neo4j.Types.RelIdentifier Database.Neo4j.Types.RelPath
instance Database.Neo4j.Types.RelIdentifier Data.ByteString.Internal.ByteString
instance Database.Neo4j.Types.RelIdentifier Database.Neo4j.Types.RelUrl
instance Database.Neo4j.Types.RelIdentifier GHC.Integer.Type.Integer
instance Database.Neo4j.Types.EntityIdentifier Database.Neo4j.Types.Node
instance Database.Neo4j.Types.EntityIdentifier Database.Neo4j.Types.NodePath
instance Database.Neo4j.Types.EntityIdentifier Database.Neo4j.Types.NodeUrl
instance Database.Neo4j.Types.EntityIdentifier Database.Neo4j.Types.Relationship
instance Database.Neo4j.Types.EntityIdentifier Database.Neo4j.Types.RelPath
instance Database.Neo4j.Types.EntityIdentifier Database.Neo4j.Types.RelUrl
instance Database.Neo4j.Types.EntityIdentifier Data.Text.Internal.Text
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Types.Index
instance GHC.Exception.Exception Database.Neo4j.Types.Neo4jException
instance GHC.Base.Monad Database.Neo4j.Types.Neo4j
instance GHC.Base.Functor Database.Neo4j.Types.Neo4j
instance GHC.Base.Applicative Database.Neo4j.Types.Neo4j
instance Control.Monad.IO.Class.MonadIO Database.Neo4j.Types.Neo4j
instance Control.Monad.Catch.MonadThrow Database.Neo4j.Types.Neo4j
instance Control.Monad.Base.MonadBase Database.Neo4j.Types.Neo4j Database.Neo4j.Types.Neo4j
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Types.Neo4jVersion


-- | Module to manage traversal operations
module Database.Neo4j.Traversal

-- | Different types of uniqueness calculations for a traversal
data Uniqueness
NodeGlobal :: Uniqueness
RelationshipGlobal :: Uniqueness
NodePathUnique :: Uniqueness
RelationshipPath :: Uniqueness

-- | Traversal mode
data TraversalOrder
BreadthFirst :: TraversalOrder
DepthFirst :: TraversalOrder

-- | Built-in return filters
data ReturnFilter
ReturnAll :: ReturnFilter
ReturnAllButStartNode :: ReturnFilter
type RelFilter = (RelationshipType, Direction)

-- | Type containing all info describing a traversal request
data TraversalDesc
TraversalDesc :: TraversalOrder -> [RelFilter] -> Maybe Uniqueness -> Either Integer Text -> Either ReturnFilter Text -> TraversalDesc
[travOrder] :: TraversalDesc -> TraversalOrder
[travRelFilter] :: TraversalDesc -> [RelFilter]
[travUniqueness] :: TraversalDesc -> Maybe Uniqueness
[travDepth] :: TraversalDesc -> Either Integer Text
[travNodeFilter] :: TraversalDesc -> Either ReturnFilter Text

-- | Description of a traversal paging
data TraversalPaging
TraversalPaging :: Integer -> Integer -> TraversalPaging
[pageSize] :: TraversalPaging -> Integer
[pageLeaseSecs] :: TraversalPaging -> Integer

-- | Direction without possibility of ambiguity
data ConcreteDirection
In :: ConcreteDirection
Out :: ConcreteDirection

-- | Data type to describe a path in a graph, that is a single node or
--   nodes interleaved with relationships
data Path a b
PathEnd :: !a -> Path a b
PathLink :: !a -> !b -> !(Path a b) -> Path a b

-- | Path that its data are id's
type IdPath = Path NodePath (RelPath, ConcreteDirection)

-- | Path that its data are full nodes and relationships, not only their
--   id's
type FullPath = Path Node Relationship

-- | Data type that holds a result for a paged traversal with the URI to
--   get the rest of the pages
data PagedTraversal a

-- | Get all the nodes of a path
pathNodes :: Path a b -> [a]

-- | Get all the relationships of a path
pathRels :: Path a b -> [b]

-- | Perform a traversal and get the resulting nodes
traverseGetNodes :: NodeIdentifier a => TraversalDesc -> a -> Neo4j [Node]

-- | Perform a traversal and get the resulting relationship entities
traverseGetRels :: NodeIdentifier a => TraversalDesc -> a -> Neo4j [Relationship]

-- | Perform a traversal and get the resulting node and relationship paths
--   IMPORTANT! In pre 2.2 Neo4j versions the directions in each
--   relationship ID returned have a default value (The API does not
--   provide them)
traverseGetPath :: NodeIdentifier a => TraversalDesc -> a -> Neo4j [IdPath]

-- | Perform a traversal and get the resulting node and relationship
--   entities
traverseGetFullPath :: NodeIdentifier a => TraversalDesc -> a -> Neo4j [FullPath]

-- | Perform a paged traversal and get the resulting nodes
pagedTraverseGetNodes :: NodeIdentifier a => TraversalDesc -> TraversalPaging -> a -> Neo4j (PagedTraversal Node)

-- | Perform a paged traversal and get the resulting relationships
pagedTraverseGetRels :: NodeIdentifier a => TraversalDesc -> TraversalPaging -> a -> Neo4j (PagedTraversal Relationship)

-- | Perform a paged traversal and get the resulting id paths, IMPORTANT!
--   In pre 2.2 Neo4j versions the directions in each relationship ID
--   returned have a default value (The API does not provide them)
pagedTraverseGetPath :: NodeIdentifier a => TraversalDesc -> TraversalPaging -> a -> Neo4j (PagedTraversal IdPath)

-- | Perform a paged traversal and get the resulting paths with full
--   entities
pagedTraverseGetFullPath :: NodeIdentifier a => TraversalDesc -> TraversalPaging -> a -> Neo4j (PagedTraversal FullPath)

-- | Get the values of a paged traversal result
getPagedValues :: PagedTraversal a -> [a]

-- | Get the next page of values from a traversal result
nextTraversalPage :: FromJSON a => PagedTraversal a -> Neo4j (PagedTraversal a)

-- | Whether a paged traversal is done
pagedTraversalDone :: PagedTraversal a -> Bool
instance GHC.Show.Show a => GHC.Show.Show (Database.Neo4j.Traversal.PagedTraversal a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Database.Neo4j.Traversal.PagedTraversal a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Database.Neo4j.Traversal.PagedTraversal a)
instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (Database.Neo4j.Traversal.Path a b)
instance (GHC.Classes.Ord b, GHC.Classes.Ord a) => GHC.Classes.Ord (Database.Neo4j.Traversal.Path a b)
instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (Database.Neo4j.Traversal.Path a b)
instance GHC.Classes.Ord Database.Neo4j.Traversal.ConcreteDirection
instance GHC.Show.Show Database.Neo4j.Traversal.ConcreteDirection
instance GHC.Classes.Eq Database.Neo4j.Traversal.ConcreteDirection
instance GHC.Show.Show Database.Neo4j.Traversal.TraversalPaging
instance GHC.Classes.Eq Database.Neo4j.Traversal.TraversalPaging
instance GHC.Show.Show Database.Neo4j.Traversal.TraversalDesc
instance GHC.Classes.Eq Database.Neo4j.Traversal.TraversalDesc
instance GHC.Show.Show Database.Neo4j.Traversal.ReturnFilter
instance GHC.Classes.Eq Database.Neo4j.Traversal.ReturnFilter
instance GHC.Show.Show Database.Neo4j.Traversal.TraversalOrder
instance GHC.Classes.Eq Database.Neo4j.Traversal.TraversalOrder
instance GHC.Show.Show Database.Neo4j.Traversal.Uniqueness
instance GHC.Classes.Eq Database.Neo4j.Traversal.Uniqueness
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Traversal.TraversalOrder
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Traversal.ReturnFilter
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Traversal.RelFilterT
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Traversal.MaybeUniqueness
instance Data.Default.Class.Default Database.Neo4j.Traversal.TraversalDesc
instance Data.Default.Class.Default Database.Neo4j.Traversal.TraversalPaging
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Traversal.ConcreteDirection
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Traversal.IdPath
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Traversal.FullPath


-- | IMPORTANT! MODULE DEPRECATED, better use the code in this same library
--   that uses the Neo4j transactional endpoint in
--   <a>Database.Neo4j.Transactional.Cypher</a> Module to provide Cypher
--   support. Currently we allow sending queries with parameters, the
--   result is a collection of column headers and JSON data values, the
--   Graph object has the function addCypher that tries to find nodes and
--   relationships in a cypher query result and insert them in a
--   <a>Database.Neo4j.Graph</a> object
--   
--   <pre>
--   import qualified Database.Neo4j.Cypher as C
--   
--   withConnection host port $ do
--      ...
--      -- Run a cypher query with parameters
--      res &lt;- C.cypher "CREATE (n:Person { name : {name} }) RETURN n" M.fromList [("name", C.newparam ("Pep" :: T.Text))]
--   
--      -- Get all nodes and relationships that this query returned and insert them in a Graph object
--      let graph = G.addCypher (C.fromSuccess res) G.empty
--   
--      -- Get the column headers
--      let columnHeaders = C.cols $ C.fromSuccess res
--   
--      -- Get the rows of JSON values received
--      let values = C.vals $ C.fromSuccess res
--   </pre>
module Database.Neo4j.Cypher

-- | Type for a Cypher response with tuples containing column name and
--   their values
data Response
Response :: [Text] -> [[Value]] -> Response
[cols] :: Response -> [Text]
[vals] :: Response -> [[Value]]

-- | Value for a cypher parmeter value, might be a literal, a property map
--   or a list of property maps
data ParamValue
ParamLiteral :: PropertyValue -> ParamValue
ParamProperties :: Properties -> ParamValue
ParamPropertiesArray :: [Properties] -> ParamValue

-- | We use hashmaps to represent Cypher parameters
type Params = HashMap Text ParamValue
newparam :: PropertyValueConstructor a => a -> ParamValue

-- | Run a cypher query

-- | <i>Deprecated: Use Database.Neo4j.Transactional.Cypher instead</i>
cypher :: Text -> Params -> Neo4j (Either Text Response)

-- | Get the result of the response or a default value

-- | <i>Deprecated: Use Database.Neo4j.Transactional.Cypher instead</i>
fromResult :: Response -> Either Text Response -> Response

-- | Get the result of the response or a default value

-- | <i>Deprecated: Use Database.Neo4j.Transactional.Cypher instead</i>
fromSuccess :: Either Text Response -> Response

-- | True if the operation succeeded

-- | <i>Deprecated: Use Database.Neo4j.Transactional.Cypher instead</i>
isSuccess :: Either Text Response -> Bool
instance GHC.Classes.Eq Database.Neo4j.Cypher.ParamValue
instance GHC.Show.Show Database.Neo4j.Cypher.ParamValue
instance GHC.Classes.Eq Database.Neo4j.Cypher.Response
instance GHC.Show.Show Database.Neo4j.Cypher.Response
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Cypher.Response
instance Data.Aeson.Types.ToJSON.ToJSON Database.Neo4j.Cypher.ParamValue


-- | Module to handle <a>Graph</a> objects. These have information about a
--   group of nodes, relationships, and information about labels per node
--   and nodes per label. Notice a graph can have relationships and at the
--   same time not have some of the nodes of those relationships, see the
--   section called handling orphaned relationships. This is so because
--   commands in a batch might retrieve relationships but might not create
--   or retrieve their respective nodes.
module Database.Neo4j.Graph
data Graph
type LabelSet = HashSet Label

-- | Create an empty graph
empty :: Graph

-- | Add a node to the graph
addNode :: Node -> Graph -> Graph

-- | Add a node to the graph with an identifier
addNamedNode :: String -> Node -> Graph -> Graph

-- | Whether a node is present in the graph
hasNode :: NodeIdentifier a => a -> Graph -> Bool

-- | Delete a node from the graph
deleteNode :: NodeIdentifier a => a -> Graph -> Graph

-- | Get a list with all the nodes in the graph
getNodes :: Graph -> [Node]

-- | Get a node in the graph
getNode :: NodeIdentifier a => a -> Graph -> Maybe Node

-- | Get a node by name in the graph, if any
getNamedNode :: String -> Graph -> Maybe Node

-- | Get outgoing relationships from a node
getNodeFrom :: NodeIdentifier a => a -> Graph -> Maybe [Relationship]

-- | Get incoming relationships from a node
getNodeTo :: NodeIdentifier a => a -> Graph -> Maybe [Relationship]

-- | Get a list with all the relationships in the graph
getRelationships :: Graph -> [Relationship]

-- | Whether a relationship is present in the graph
hasRelationship :: RelIdentifier a => a -> Graph -> Bool

-- | Add a relationship to the graph
addRelationship :: Relationship -> Graph -> Graph

-- | Add a relationship to the graph with an identified
addNamedRelationship :: String -> Relationship -> Graph -> Graph

-- | Delete a relationship from the graph
deleteRelationship :: RelIdentifier a => a -> Graph -> Graph

-- | Get the "node from" from a relationship
getRelationshipNodeFrom :: Relationship -> Graph -> Maybe Node

-- | Get the "node to" from a relationship
getRelationshipNodeTo :: Relationship -> Graph -> Maybe Node

-- | Get a relationship in the graph
getRelationship :: RelIdentifier a => a -> Graph -> Maybe Relationship

-- | Get a relationship by name in the graph, if any
getNamedRelationship :: String -> Graph -> Maybe Relationship

-- | Get relationships missing their "from" node
getOrphansFrom :: Graph -> [Relationship]

-- | Get relationships missing their "to" node
getOrphansTo :: Graph -> [Relationship]

-- | Remove all relationships with a missing node
cleanOrphanRelationships :: Graph -> Graph

-- | Set the properties of a node or relationship in the graph, if not
--   present it won't do anything
setProperties :: EntityIdentifier a => a -> Properties -> Graph -> Graph

-- | Set a property of a node or relationship in the graph, if not present
--   it won't do anything
setProperty :: EntityIdentifier a => a -> Text -> PropertyValue -> Graph -> Graph

-- | Delete all the properties of a node or relationship, if the entity is
--   not present it won't do anything
deleteProperties :: EntityIdentifier a => a -> Graph -> Graph

-- | Delete a property of a node or relationship, if the entity is not
--   present it won't do anything
deleteProperty :: EntityIdentifier a => a -> Text -> Graph -> Graph

-- | Set what labels a node has
setNodeLabels :: NodeIdentifier a => a -> [Label] -> Graph -> Graph

-- | Add a label to a node
addNodeLabel :: NodeIdentifier a => a -> Label -> Graph -> Graph

-- | Get the labels of a node
getNodeLabels :: NodeIdentifier a => a -> Graph -> LabelSet

-- | Remove a label from a node
deleteNodeLabel :: NodeIdentifier a => a -> Label -> Graph -> Graph

-- | Feed a cypher result (from the old API) into a graph (looks for nodes
--   and relationships and inserts them)
addCypher :: Response -> Graph -> Graph

-- | Filter the nodes of a graph
nodeFilter :: (Node -> Bool) -> Graph -> Graph

-- | Filter the relationships of a graph
relationshipFilter :: (Relationship -> Bool) -> Graph -> Graph

-- | Add two graphs resulting in a graph with all the nodes, labels and
--   relationships of both | If a node/entity is present in both the second
--   one will be chosen
union :: Graph -> Graph -> Graph

-- | Remove the nodes and relationships in the first graph that appear in
--   the second
difference :: Graph -> Graph -> Graph

-- | Have a graph that only has nodes and relationships that are present in
--   both
intersection :: Graph -> Graph -> Graph
instance GHC.Show.Show Database.Neo4j.Graph.Graph
instance GHC.Classes.Eq Database.Neo4j.Graph.Graph


-- | Module to provide Cypher support using the transactional endpoint.
--   
--   Example:
--   
--   <pre>
--   import qualified Database.Neo4j.Transactional.Cypher as T
--   
--   withConnection host port $ do
--      ...
--      res &lt;- TC.runTransaction $ do
--              -- Queries return a result with columns, rows, a list of graphs and stats
--              result &lt;- TC.cypher "CREATE (pere: PERSON {age: {age}}) CREATE (pau: PERSON {props}) \
--                                \CREATE p1 = (pere)-[:KNOWS]-&gt;(pau) RETURN pere, pau, p1, pere.age" $
--                                  M.fromList [("age", TC.newparam (78 :: Int64)),
--                                              ("props", TC.ParamProperties $ M.fromList["age" |: (99 :: Int64)])]
--              -- if any of the commands returns an error the transaction is rollbacked and leaves
--              result 2 &lt;- T.cypher "not a command" M.empty
--              void $ TC.cypher "CREATE (pep: PERSON {age: 55})" M.empty
--              -- Transactions are implicitly commited/rollbacked (in case of exception)
--              -- but can be explicitly committed and rollbacked
--              return (result, result2)
--   </pre>
module Database.Neo4j.Transactional.Cypher

-- | Type for a Cypher response with tuples containing column name and
--   their values
data Result
Result :: [Text] -> [[Value]] -> [Graph] -> Stats -> Result
[cols] :: Result -> [Text]
[vals] :: Result -> [[Value]]
[graph] :: Result -> [Graph]
[stats] :: Result -> Stats

-- | Holds the connection stats
data Stats
Stats :: Bool -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Stats
[containsUpdates] :: Stats -> Bool
[nodesCreated] :: Stats -> Integer
[nodesDeleted] :: Stats -> Integer
[propsSet] :: Stats -> Integer
[relsCreated] :: Stats -> Integer
[relsDeleted] :: Stats -> Integer
[lblsAdded] :: Stats -> Integer
[lblsRemoved] :: Stats -> Integer
[idxAdded] :: Stats -> Integer
[idxRemoved] :: Stats -> Integer
[constAdded] :: Stats -> Integer
[constRemoved] :: Stats -> Integer

-- | Value for a cypher parmeter value, might be a literal, a property map
--   or a list of property maps
data ParamValue
ParamLiteral :: PropertyValue -> ParamValue
ParamProperties :: Properties -> ParamValue
ParamPropertiesArray :: [Properties] -> ParamValue

-- | We use hashmaps to represent Cypher parameters
type Params = HashMap Text ParamValue
newparam :: PropertyValueConstructor a => a -> ParamValue

-- | Default stats
emptyStats :: Stats

-- | Error code and message for a transaction error
type TransError = (Text, Text)
type Transaction a = ExceptT TransError (ReaderT Connection (StateT TransState (ResourceT IO))) a
loneQuery :: Text -> Params -> Neo4j (Either TransError Result)

-- | Run a transaction and get its final result, has an implicit commit
--   request (or rollback if an exception occurred). This implicit
--   commit/rollback will only be executed if it hasn't before because of
--   an explicit one
runTransaction :: Transaction a -> Neo4j (Either TransError a)

-- | Run a cypher query in a transaction, if an error occurs the
--   transaction will stop and rollback
cypher :: Text -> Params -> Transaction Result

-- | Rollback a transaction. After this, executing rollback, commit,
--   keepalive, cypher in the transaction will result in an exception
rollback :: Transaction ()

-- | Commit a transaction. After this, executing rollback, commit,
--   keepalive, cypher in the transaction will result in an exception
commit :: Transaction ()

-- | Send a keep alive message to an open transaction
keepalive :: Transaction ()

-- | Send a cypher query and commit at the same time, if an error occurs
--   the transaction will be rolled back. After this, executing rollback,
--   commit, keepalive, cypher in the transaction will result in an
--   exception
commitWith :: Text -> Params -> Transaction Result

-- | Rollback a transaction and stop processing it, set the message that
--   runTransaction will return as error
rollbackAndLeave :: Text -> Transaction ()

-- | True if the operation succeeded
isSuccess :: Either TransError Result -> Bool

-- | Get the result of the response or a default value
fromResult :: Result -> Either TransError Result -> Result

-- | Get the result of the response or a default value
fromSuccess :: Either TransError Result -> Result
instance GHC.Classes.Eq Database.Neo4j.Transactional.Cypher.Response
instance GHC.Show.Show Database.Neo4j.Transactional.Cypher.Response
instance GHC.Show.Show Database.Neo4j.Transactional.Cypher.DataElem
instance GHC.Classes.Eq Database.Neo4j.Transactional.Cypher.DataElem
instance GHC.Show.Show Database.Neo4j.Transactional.Cypher.CypherRel
instance GHC.Classes.Eq Database.Neo4j.Transactional.Cypher.CypherRel
instance GHC.Show.Show Database.Neo4j.Transactional.Cypher.CypherNode
instance GHC.Classes.Eq Database.Neo4j.Transactional.Cypher.CypherNode
instance GHC.Classes.Eq Database.Neo4j.Transactional.Cypher.Result
instance GHC.Show.Show Database.Neo4j.Transactional.Cypher.Result
instance GHC.Show.Show Database.Neo4j.Transactional.Cypher.Stats
instance GHC.Classes.Eq Database.Neo4j.Transactional.Cypher.Stats
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Transactional.Cypher.Stats
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Transactional.Cypher.CypherNode
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Transactional.Cypher.CypherRel
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Transactional.Cypher.DataElem
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Transactional.Cypher.Result
instance Data.Aeson.Types.FromJSON.FromJSON Database.Neo4j.Transactional.Cypher.Response

module Database.Neo4j.Batch
type Batch a = State BatchState a
runBatch :: Batch a -> Neo4j Graph
newtype BatchFuture a
BatchFuture :: Int -> BatchFuture a
class NodeBatchIdentifier a
class RelBatchIdentifier a
class BatchEntity a

-- | Batch operation to create a node
createNode :: Properties -> Batch (BatchFuture Node)

-- | Batch operation to create a node and assign it a name to easily
--   retrieve it from the resulting graph of the batch
createNamedNode :: String -> Properties -> Batch (BatchFuture Node)

-- | Batch operation to get a node from the DB
getNode :: NodeBatchIdentifier a => a -> Batch (BatchFuture Node)

-- | Batch operation to get a node from the DB and assign it a name
getNamedNode :: NodeBatchIdentifier a => String -> a -> Batch (BatchFuture Node)

-- | Batch operation to delete a node
deleteNode :: NodeBatchIdentifier a => a -> Batch (BatchFuture ())

-- | Create a new relationship with a type and a set of properties
createRelationship :: (NodeBatchIdentifier a, NodeBatchIdentifier b) => RelationshipType -> Properties -> a -> b -> Batch (BatchFuture Relationship)

-- | Create a new relationship with a type and a set of properties and
--   assign it an identifier
createNamedRelationship :: (NodeBatchIdentifier a, NodeBatchIdentifier b) => String -> RelationshipType -> Properties -> a -> b -> Batch (BatchFuture Relationship)

-- | Refresh a relationship entity with the contents in the DB
getRelationship :: RelBatchIdentifier r => r -> Batch (BatchFuture Relationship)

-- | Refresh a relationship entity with the contents in the DB and assign
--   it an identifier
getNamedRelationship :: RelBatchIdentifier r => String -> r -> Batch (BatchFuture Relationship)

-- | Get the "node from" from a relationship from the DB
getRelationshipFrom :: Relationship -> Batch (BatchFuture Node)

-- | Get the "node to" from a relationship from the DB
getRelationshipTo :: Relationship -> Batch (BatchFuture Node)

-- | Delete a relationship
deleteRelationship :: RelBatchIdentifier r => r -> Batch (BatchFuture ())

-- | Get all relationships for a node
getRelationships :: NodeBatchIdentifier n => n -> Direction -> [RelationshipType] -> Batch (BatchFuture [Relationship])

-- | Set all relationship/node properties
setProperties :: BatchEntity a => a -> Properties -> Batch (BatchFuture ())

-- | Set a relationship/node property
setProperty :: BatchEntity a => a -> Text -> PropertyValue -> Batch (BatchFuture ())

-- | Delete all relationship/node properties
deleteProperties :: BatchEntity a => a -> Batch (BatchFuture ())

-- | Delete a relationship/node property
deleteProperty :: BatchEntity a => a -> Text -> Batch (BatchFuture ())

-- | Retrieve all labels for a node, if the node doesn't exist already it
--   will raise an exception | Raises Neo4jNoEntityException if the node
--   doesn't exist
getLabels :: NodeBatchIdentifier a => a -> Batch (BatchFuture [Label])

-- | Get all nodes using a label and a property
getNodesByLabelAndProperty :: Label -> Maybe (Text, PropertyValue) -> Batch (BatchFuture [Node])

-- | Add labels to a node | Raises Neo4jNoEntityException if the node
--   doesn't exist
addLabels :: NodeBatchIdentifier a => [Label] -> a -> Batch (BatchFuture ())

-- | Change node labels | Raises Neo4jNoEntityException if the node doesn't
--   exist
changeLabels :: NodeBatchIdentifier a => [Label] -> a -> Batch (BatchFuture ())

-- | Remove a label for a node | Raises Neo4jNoEntityException if the node
--   doesn't exist
removeLabel :: NodeBatchIdentifier a => Label -> a -> Batch (BatchFuture ())


-- | Library to interact with the Neo4j REST API.
module Database.Neo4j

-- | Type for a connection
data Connection
type Hostname = ByteString
type Port = Int
type Credentials = (Username, Password)

-- | Create a new connection that can be manually closed with runResourceT
newConnection :: Hostname -> Port -> IO Connection

-- | Run a set of Neo4j commands in a single connection
withConnection :: Hostname -> Port -> Neo4j a -> IO a

-- | Create a new connection that can be manually closed with runResourceT
--   using provided credentials for basic auth
newAuthConnection :: Hostname -> Port -> Credentials -> IO Connection

-- | Run a set of Neo4j commands in a single connection using provided
--   credentials for basic auth
withAuthConnection :: Hostname -> Port -> Credentials -> Neo4j a -> IO a

-- | Create a new https connection that can be manually closed with
--   runResourceT
newSecureConnection :: Hostname -> Port -> IO Connection

-- | Run a set of Neo4j commands in a single https connection
withSecureConnection :: Hostname -> Port -> Neo4j a -> IO a

-- | Create a new https connection that can be manually closed with
--   runResourceT using provided credentials for basic auth
newSecureAuthConnection :: Hostname -> Port -> Credentials -> IO Connection

-- | Run a set of Neo4j commands in a single https connection using
--   provided credentials for basic auth
withSecureAuthConnection :: Hostname -> Port -> Credentials -> Neo4j a -> IO a

-- | Neo4j monadic type to be able to sequence neo4j commands in a
--   connection
newtype Neo4j a
Neo4j :: (Connection -> IO a) -> Neo4j a
[runNeo4j] :: Neo4j a -> Connection -> IO a

-- | Type for a single value of a Neo4j property
data Val
IntVal :: Int64 -> Val
BoolVal :: Bool -> Val
TextVal :: Text -> Val
DoubleVal :: Double -> Val

-- | Wrapping type for a Neo4j single property or array of properties Using
--   these types allows type checking for only correct properties that is
--   int, double, string, boolean and single typed arrays of these, also
--   nulls are not allowed
data PropertyValue
ValueProperty :: Val -> PropertyValue
ArrayProperty :: [Val] -> PropertyValue
newval :: PropertyValueConstructor a => a -> PropertyValue

-- | This operator allows easy construction of property value types from
--   literals
(|:) :: PropertyValueConstructor a => Text -> a -> (Text, PropertyValue)

-- | We use hashmaps to represent Neo4j properties
type Properties = HashMap Text PropertyValue

-- | Shortcut for emtpy properties
emptyProperties :: HashMap Text PropertyValue

-- | Retrieve relationship/node properties from the DB, if the entity is
--   not present it will raise an exception If the entity doesn't exist it
--   will raise a Neo4jNoEntity exception
getProperties :: Entity a => a -> Neo4j Properties

-- | Get a relationship/node property If the 404 is because the parent
--   entity doesn't exist we'll raise the corresponding Neo4jNoEntity If
--   the 404 is because there is no property just return Nothing
getProperty :: Entity a => a -> Text -> Neo4j (Maybe PropertyValue)

-- | Set all relationship/node properties If the entity doesn't exist it
--   will raise a Neo4jNoEntity exception
setProperties :: Entity a => a -> Properties -> Neo4j a

-- | Set a relationship/node property If the entity doesn't exist it will
--   raise a Neo4jNoEntity exception
setProperty :: Entity a => a -> Text -> PropertyValue -> Neo4j a

-- | Delete all relationship/node properties If the entity doesn't exist it
--   will raise a Neo4jNoEntity exception
deleteProperties :: Entity a => a -> Neo4j a

-- | Delete a relationship/node property If the entity doesn't exist it
--   will raise a Neo4jNoEntity exception
deleteProperty :: Entity a => a -> Text -> Neo4j a

-- | Representation of a Neo4j node, has a location URI and a set of
--   properties
data Node

-- | Get the properties of a node
getNodeProperties :: Node -> Properties

-- | Create a new node with a set of properties
createNode :: Properties -> Neo4j Node

-- | Refresh a node entity with the contents in the DB
getNode :: NodeIdentifier a => a -> Neo4j (Maybe Node)

-- | Delete a node, if the node has relationships it will raise a
--   Neo4jNonOrphanNodeDeletion
deleteNode :: NodeIdentifier a => a -> Neo4j ()

-- | Get the ID of a node
nodeId :: Node -> ByteString
nodePath :: Node -> NodePath
runNodeIdentifier :: NodeIdentifier a => a -> ByteString
class NodeIdentifier a
getNodePath :: NodeIdentifier a => a -> NodePath
newtype NodePath
NodePath :: Text -> NodePath
[runNodePath] :: NodePath -> Text

-- | Type for a Neo4j relationship, has a location URI, a relationship
--   type, a starting node and a destination node
data Relationship

-- | Relationship direction
data Direction
Outgoing :: Direction
Incoming :: Direction
Any :: Direction

-- | Type for a relationship type description
type RelationshipType = Text

-- | Create a new relationship with a type and a set of properties
createRelationship :: RelationshipType -> Properties -> Node -> Node -> Neo4j Relationship

-- | Refresh a relationship entity with the contents in the DB
getRelationship :: RelIdentifier a => a -> Neo4j (Maybe Relationship)

-- | Delete a relationship
deleteRelationship :: RelIdentifier a => a -> Neo4j ()

-- | Get all relationships for a node, if the node has disappeared it will
--   raise an exception
getRelationships :: Node -> Direction -> [RelationshipType] -> Neo4j [Relationship]

-- | Get the ID of a relationship
relId :: Relationship -> ByteString
relPath :: Relationship -> RelPath

-- | Gets all relationship types in the DB
allRelationshipTypes :: Neo4j [RelationshipType]

-- | Get the properties of a relationship
getRelProperties :: Relationship -> Properties

-- | Get the type of a relationship
getRelType :: Relationship -> RelationshipType
runRelIdentifier :: RelIdentifier a => a -> ByteString

-- | Get the "node from" from a relationship from the DB | Raises
--   Neo4jNoEntityException if the node (and thus the relationship) does
--   not exist any more
getRelationshipFrom :: Relationship -> Neo4j Node

-- | Get the "node to" from a relationship from the DB | Raises
--   Neo4jNoEntityException if the node (and thus the relationship) does
--   not exist any more
getRelationshipTo :: Relationship -> Neo4j Node
class RelIdentifier a
getRelPath :: RelIdentifier a => a -> RelPath
newtype RelPath
RelPath :: Text -> RelPath
[runRelPath] :: RelPath -> Text
class EntityIdentifier a
getEntityPath :: EntityIdentifier a => a -> EntityPath

-- | Type for a label
type Label = Text

-- | Get all labels in the DB
allLabels :: Neo4j [Label]

-- | Retrieve all labels for a node, if the node doesn't exist already it
--   will raise an exception | Raises Neo4jNoEntityException if the node
--   doesn't exist
getLabels :: Node -> Neo4j [Label]

-- | Get all nodes using a label and a property
getNodesByLabelAndProperty :: Label -> Maybe (Text, PropertyValue) -> Neo4j [Node]

-- | Add labels to a node | Raises Neo4jNoEntityException if the node
--   doesn't exist
addLabels :: [Label] -> Node -> Neo4j ()

-- | Change node labels | Raises Neo4jNoEntityException if the node doesn't
--   exist
changeLabels :: [Label] -> Node -> Neo4j ()

-- | Remove a label for a node | Raises Neo4jNoEntityException if the node
--   doesn't exist
removeLabel :: Label -> Node -> Neo4j ()

-- | Type for an index
data Index
Index :: Label -> [Text] -> Index
[indexLabel] :: Index -> Label
[indexProperties] :: Index -> [Text]

-- | Creates an index for a label and a property
createIndex :: Label -> Text -> Neo4j Index

-- | Gets all indexes for a label
getIndexes :: Label -> Neo4j [Index]

-- | Drop and index
dropIndex :: Label -> Text -> Neo4j ()

-- | Exceptions this library can raise
data Neo4jException
Neo4jHttpException :: String -> Neo4jException
Neo4jNonOrphanNodeDeletionException :: ByteString -> Neo4jException
Neo4jNoEntityException :: ByteString -> Neo4jException
Neo4jUnexpectedResponseException :: Status -> Neo4jException
Neo4jNoSuchProperty :: Text -> Neo4jException
Neo4jBatchException :: ByteString -> Neo4jException
Neo4jParseException :: String -> Neo4jException
TransactionEndedExc :: Neo4jException
getDatabaseVersion :: Neo4j Neo4jVersion
