figbus/elm-urbit-api/4.0.0

NOTE: the latest version is 4.0.1

Urbit.Graph

Store

type Store

A collection of Graphs identified by Resources.

Create an empty Store.

getFromStore : Resource -> Store -> Maybe Graph

Get a graph from a Store using a resource.

Resource

type alias Resource =
{ ship : Atom
, name : String
}

A pair of a ship and a name uniquely identifying a graph.

parseResource : String -> Result (List DeadEnd) Resource

Parses a resource string into a Resource type.

parseResource "~zod/hello"
encodeResource : Resource -> Value

Encode a Resource into a JSON value of the form:

{
  "ship": "~zod",
  "name": "example"
}
resourceToString : Resource -> String

Encode a Resource into a string of the form:

"~zod/example"
resourceToPath : Resource -> String

Encode a Resource into a path string of the form:

"/ship/~zod/example"

Graph

type alias Graph =
Dict String Node

An ordered dict of nodes.

type Node

A node in a graph. Contains a Post and possibly children.

Get the children of a node.

getNodePost : Node -> Post

Get the post associated with a node.

type alias Post =
{ index : Index
, author : Atom
, timeSent : Posix
, contents : List Value
, hash : Maybe String
}

A post in a graph. The contents are a list of JSON values.

type alias Index =
List String

An index uniquely identifying a node within a graph.

newNode : Post -> Node

Create a new node from a post.

textContent : String -> Value

Create a text content type for a post.

urlContent : String -> Value

Create a url content type for a post.

mentionContent : String -> Value

Create a mention content type for a post.

{ expression : String
, output : String
}
-> Value

Create a code content type for a post.

Requests

{ url : String
, resource : Resource
}
-> (Result Error Update -> msg)
-> Cmd msg

Get a graph from the graph store.

Subscribe to changes to the graph store.

{ resource : Resource
, nodes : List Node
, session : Session
}
-> OutMsg

Add nodes to the graph store.

{ url : String
, resource : Resource
, nodes : List Node
}
-> (Result Error Value -> msg)
-> Cmd msg

Add nodes to the graph store via a spider thread.

{ url : String
, group : Resource
, resource : Resource
, title : String
, description : String
, graphModule : String
, mark : String
}
-> (Result Error () -> msg)
-> Cmd msg

Create a new graph associated with an existing group.

{ url : String
, resource : Resource
, title : String
, description : String
, invites : List Atom
, graphModule : String
, mark : String
}
-> (Result Error () -> msg)
-> Cmd msg

Create a new graph unassociated with any group.

{ url : String
, resource : Resource
}
-> (Result Error () -> msg)
-> Cmd msg

Delete a graph from the graph store via a spider thread.

Updates

type Update

Represents a change to the graph store.

Decode a graph store update, typically from an incoming diff or scry request.

Apply a change to the graph store.