[{"name":"Urbit","comment":"\n\n\n# Data Types\n\n@docs Session, Message, MessageData, url, ship, uid, lastEventId\n\n\n# Connection Setup\n\nThese are **required** in order to maintain an active connection to an urbit\nship and to perform poke/subscription requests.\n\n@docs connect, connectUnauth, setupEventSource, messages, ack\n\n\n# Stateless Requests\n\nThese do not require an active connection, however they do at least require you\nto be authenticated.\n\n@docs login, scry, spider\n\n\n# Stateful Requests\n\n@docs poke, subscribe, unsubscribe, disconnect\n\n\n# Helpers\n\n@docs genChannelId, genUid\n\n","unions":[{"name":"MessageData","comment":" An incoming message may be one of the following:\n\n  - `Poke` represents a response for a previous poke\n  - `Subscribe` represents a response for a subscription requests\n  - `Diff` represents a new incoming diff for a subscription\n  - `Quit` means you have been kicked from a subscription and should likely\n    attempt to resubscribe\n\nIn all cases the first `Int` value represents the Id of the message it is\nrelevant to.\n\n","args":[],"cases":[["Poke",["Basics.Int","Result.Result String.String ()"]],["Subscribe",["Basics.Int","Result.Result String.String ()"]],["Diff",["Basics.Int","Json.Encode.Value"]],["Quit",["Basics.Int"]]]},{"name":"Session","comment":" A session represents an active connection to an urbit ship.\n","args":[],"cases":[]}],"aliases":[{"name":"Message","comment":" Represents an incoming message.\n","args":[],"type":"{ lastEventId : Basics.Int, data : Urbit.MessageData }"}],"values":[{"name":"ack","comment":" Acknowledge an incoming message. Must be performed for every incoming\nmessage received.\n","type":"{ lastEventId : Basics.Int, session : Urbit.Session } -> (Result.Result Http.Error () -> msg) -> ( Urbit.Session, Platform.Cmd.Cmd msg )"},{"name":"connect","comment":" Connect to an urbit ship and return a `Session` on success. Should be\nfollowed by [setupEventSource](#setupEventSource) (this must be done as a\nseparate step due to the nature of Elm ports).\n\nYou can generate a unique `channelId` any way you wish, however the provided\n[genChannelId](#genChannelId) function is recommended.\n\n","type":"{ ship : String.String, url : String.String, channelId : String.String, code : String.String } -> (Result.Result Http.Error Urbit.Session -> msg) -> Platform.Cmd.Cmd msg"},{"name":"connectUnauth","comment":" Alternative to [connect](#connect) that does not require a `code`.\n\n**Note:** Ensure the correct cookie is set through some other means beforehand\nor else this will not work. Hosting from within an urbit using the :file-server\napp with public set to false should work, for example.\n\n","type":"{ ship : String.String, url : String.String, channelId : String.String } -> (Result.Result Http.Error Urbit.Session -> msg) -> Platform.Cmd.Cmd msg"},{"name":"disconnect","comment":" Safely deletes a channel.\n","type":"Urbit.Session -> (Result.Result Http.Error () -> msg) -> Platform.Cmd.Cmd msg"},{"name":"genChannelId","comment":" Recommended way to create a unique id for a session's channel. Takes the\ncurrent time and returns a random generator which can then be used to generate\nthe full ID.\n","type":"Time.Posix -> Random.Generator String.String"},{"name":"genUid","comment":" Helper for generating random urbit UIDs.\n\nBased off of <https://github.com/urbit/urbit/blob/137e4428f617c13f28ed31e520eff98d251ed3e9/pkg/interface/src/lib/util.js#L3>\n\n","type":"Random.Generator String.String"},{"name":"lastEventId","comment":" Get a Session's lastEventId.\n","type":"Urbit.Session -> Basics.Int"},{"name":"login","comment":" Login to an urbit without maintaining an active connection. This will allow\nfor stateless scry and spider requests that require authentication but _not_\nothers.\n\n**Note:** This is not required if you have already used [connect](#connect) to\nauthenticate.\n\n","type":"{ url : String.String, code : String.String } -> (Result.Result Http.Error () -> msg) -> Platform.Cmd.Cmd msg"},{"name":"messages","comment":" Subscribe to incoming messages from urbit. See [setupEventSource](#setupEventSource)\nabove for instructions on how to use this. Every message received _must_ be\nacknowledged by using the related [ack](#ack) function, otherwise urbit will\nstop accepting any further messages.\n","type":"((Json.Encode.Value -> msg) -> Platform.Sub.Sub msg) -> (Result.Result Json.Decode.Error Urbit.Message -> msg) -> Platform.Sub.Sub msg"},{"name":"poke","comment":" Poke an app on a ship.\n","type":"{ ship : String.String, app : String.String, mark : String.String, json : Json.Encode.Value, session : Urbit.Session } -> (Result.Result Http.Error () -> msg) -> ( Urbit.Session, Platform.Cmd.Cmd msg )"},{"name":"scry","comment":" Make a scry request.\n","type":"{ url : String.String, app : String.String, path : String.String, mark : String.String, decoder : Json.Decode.Decoder a } -> (Result.Result Http.Error a -> msg) -> Platform.Cmd.Cmd msg"},{"name":"setupEventSource","comment":" This will set up the realtime communication channel with urbit. Because Elm\ndoes not support the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)\nAPI required, this must be done using ports. Elm does not allow ports to be\npublished as part of a package, but luckily the setup for this is fairly\nstraightforward.\n\nFirst, copy/paste the following into your js file and replace any references to\n`app` with the variable name of your running Elm app:\n\n```js\napp.ports.setupUrbitEventSource.subscribe((url) => {\n  const eventSource = new EventSource(url, { withCredentials: true });\n\n  eventSource.onmessage = function (event) {\n    app.ports.onUrbitMessage.send({ message: event });\n  };\n\n  eventSource.onerror = function (event) {\n    app.ports.onUrbitMessage.send({ error: event });\n  };\n});\n```\n\nNext, declare a port module and the following ports to handle the initial setup\nand incoming messages:\n\n    port setupUrbitEventSource : String -> Cmd msg\n\n    port onUrbitMessage : (JE.Value -> msg) -> Sub msg\n\nNow, the newly created `setupUrbitEventSource` can be passed as the first\nargument to our [setupEventSource](#setupEventSource) function and used to\nperform the necessary setup. Similarly, the `onUrbitMessage` function can be\npassed as the first argument to [messages](#messages) below to set up the\nsubscription to incoming events.\n\n    setupCommand =\n        Urbit.setupEventSource setupUrbitEventSource session\n\n    messagesSubscription =\n        Urbit.messages onUrbitMessage GotUrbitMessage\n\nSee the Elm [guide](https://guide.elm-lang.org/interop/ports.html) for further\ninformation regarding ports.\n\n","type":"(String.String -> Platform.Cmd.Cmd msg) -> Urbit.Session -> Platform.Cmd.Cmd msg"},{"name":"ship","comment":" Get a Session's ship.\n","type":"Urbit.Session -> String.String"},{"name":"spider","comment":" Start a thread and get the response.\n","type":"{ url : String.String, inputMark : String.String, outputMark : String.String, threadName : String.String, body : Json.Encode.Value } -> (Result.Result Http.Error Json.Decode.Value -> msg) -> Platform.Cmd.Cmd msg"},{"name":"subscribe","comment":" Subscribe to ship events on some path.\n","type":"{ ship : String.String, app : String.String, path : String.String, session : Urbit.Session } -> (Result.Result Http.Error () -> msg) -> ( Urbit.Session, Platform.Cmd.Cmd msg )"},{"name":"uid","comment":" Get a Session's uid.\n","type":"Urbit.Session -> String.String"},{"name":"unsubscribe","comment":" Unsubscribe from an existing subscription.\n","type":"Basics.Int -> Urbit.Session -> (Result.Result Http.Error () -> msg) -> ( Urbit.Session, Platform.Cmd.Cmd msg )"},{"name":"url","comment":" Get a Session's url.\n","type":"Urbit.Session -> String.String"}],"binops":[]},{"name":"Urbit.Graph","comment":"\n\n\n# Store\n\n@docs Store, Resource, emptyStore, getFromStore\n\n\n# Graph\n\n@docs Graph, Node, getNodeChildren, getNodePost, Post, Index, newNode\n@docs textContent, urlContent, mentionContent, codeContent\n\n\n# Requests\n\n@docs getGraph, subscribeToGraphUpdates, addNodes, addNodesSpider\n@docs createManagedGraph, createUnmanagedGraph, deleteGraphSpider\n\n\n# Updates\n\n@docs Update, updateDecoder, updateStore\n\n","unions":[{"name":"Node","comment":" A node in a graph. Contains a [Post](#Post) and possibly children.\n","args":[],"cases":[]},{"name":"Store","comment":" A collection of [Graphs](#Graph) identified by [Resources](#Resource).\n","args":[],"cases":[]},{"name":"Update","comment":" Represents a change to the graph store.\n","args":[],"cases":[]}],"aliases":[{"name":"Graph","comment":" An ordered dict of nodes.\n","args":[],"type":"Dict.Dict String.String Urbit.Graph.Node"},{"name":"Index","comment":" An index uniquely identifying a node within a graph.\n","args":[],"type":"List.List String.String"},{"name":"Post","comment":" A post in a graph. The contents are a list of JSON values.\n","args":[],"type":"{ index : Urbit.Graph.Index, author : String.String, timeSent : Time.Posix, contents : List.List Json.Encode.Value, hash : Maybe.Maybe String.String }"},{"name":"Resource","comment":" A pair of a ship and a name uniquely identifying a graph.\n","args":[],"type":"{ ship : String.String, name : String.String }"}],"values":[{"name":"addNodes","comment":" Add nodes to the graph store.\n","type":"{ resource : Urbit.Graph.Resource, nodes : List.List Urbit.Graph.Node, session : Urbit.Session } -> (Result.Result Http.Error () -> msg) -> ( Urbit.Session, Platform.Cmd.Cmd msg )"},{"name":"addNodesSpider","comment":" Add nodes to the graph store via a spider thread.\n","type":"{ url : String.String, resource : Urbit.Graph.Resource, nodes : List.List Urbit.Graph.Node } -> (Result.Result Http.Error Json.Decode.Value -> msg) -> Platform.Cmd.Cmd msg"},{"name":"codeContent","comment":" Create a `code` content type for a post.\n","type":"{ expression : String.String, output : String.String } -> Json.Encode.Value"},{"name":"createManagedGraph","comment":" Create a new graph associated with an existing group.\n","type":"{ url : String.String, group : Urbit.Graph.Resource, resource : Urbit.Graph.Resource, title : String.String, description : String.String, graphModule : String.String, mark : String.String } -> (Result.Result Http.Error Json.Decode.Value -> msg) -> Platform.Cmd.Cmd msg"},{"name":"createUnmanagedGraph","comment":" Create a new graph unassociated with any group.\n","type":"{ url : String.String, resource : Urbit.Graph.Resource, title : String.String, description : String.String, invites : List.List String.String, graphModule : String.String, mark : String.String } -> (Result.Result Http.Error Json.Decode.Value -> msg) -> Platform.Cmd.Cmd msg"},{"name":"deleteGraphSpider","comment":" Delete a graph from the graph store via a spider thread.\n","type":"{ url : String.String, resource : Urbit.Graph.Resource } -> (Result.Result Http.Error Json.Decode.Value -> msg) -> Platform.Cmd.Cmd msg"},{"name":"emptyStore","comment":" Create an empty [Store](#Store).\n","type":"Urbit.Graph.Store"},{"name":"getFromStore","comment":" Get a graph from a [Store](#Store) using a resource.\n","type":"Urbit.Graph.Resource -> Urbit.Graph.Store -> Maybe.Maybe Urbit.Graph.Graph"},{"name":"getGraph","comment":" Get a graph from the graph store.\n","type":"{ url : String.String, resource : Urbit.Graph.Resource } -> (Result.Result Http.Error Urbit.Graph.Update -> msg) -> Platform.Cmd.Cmd msg"},{"name":"getNodeChildren","comment":" Get the children of a node.\n","type":"Urbit.Graph.Node -> Urbit.Graph.Graph"},{"name":"getNodePost","comment":" Get the post associated with a node.\n","type":"Urbit.Graph.Node -> Urbit.Graph.Post"},{"name":"mentionContent","comment":" Create a `mention` content type for a post.\n","type":"String.String -> Json.Encode.Value"},{"name":"newNode","comment":" Create a new node from a post.\n","type":"Urbit.Graph.Post -> Urbit.Graph.Node"},{"name":"subscribeToGraphUpdates","comment":" Subscribe to changes to the graph store.\n","type":"{ ship : String.String, session : Urbit.Session } -> (Result.Result Http.Error () -> msg) -> ( Urbit.Session, Platform.Cmd.Cmd msg )"},{"name":"textContent","comment":" Create a `text` content type for a post.\n","type":"String.String -> Json.Encode.Value"},{"name":"updateDecoder","comment":" Decode a graph store update, typically from an incoming diff or scry\nrequest.\n","type":"Json.Decode.Decoder Urbit.Graph.Update"},{"name":"updateStore","comment":" Apply a change to the graph store.\n","type":"Urbit.Graph.Update -> Urbit.Graph.Store -> Urbit.Graph.Store"},{"name":"urlContent","comment":" Create a `url` content type for a post.\n","type":"String.String -> Json.Encode.Value"}],"binops":[]}]