UNAVI Docs unavi.xyz
Build · Scripting API

wired:peer

Who the local user is, and who speaks for each document.

A document's author is the user holding its write key. Not transferable. Its holder is the peer currently deciding how it moves, by default the author's peer. Holding is transferable. Authors and holders are users, named by DID.

Interface identity

Uses did, error.

self-did

funcself-did: func() -> result<did, error>

The local user's identifier.

Interface authority

Uses did, error, document.

author

funcauthor: func(document: borrow<document>) -> result<option<did>, error>

Who authors document, or none when no author has proven itself, as with a space's own content.

holder

funcholder: func(document: borrow<document>) -> result<option<did>, error>

Who holds document now: the latest peer to take hold, else its author. none outside a space.

is-author

funcis-author: func(document: borrow<document>) -> result<bool, error>

Whether the local user authors document, whose shared layer every viewer applies in full.

is-holder

funcis-holder: func(document: borrow<document>) -> result<bool, error>

Whether this peer holds document now.

take-hold

functake-hold: func(document: borrow<document>) -> result<_, error>

Takes hold of a document the script may write, so this peer drives its motion. Anyone may hold; a standing reservation narrows that to the reserved user or the author.

release-hold

funcrelease-hold: func(document: borrow<document>, to: option<did>) -> result<_, error>

Gives up this peer's hold, opening it to anyone, or reserving the next hold for to while it stands unclaimed.

Source

/// Who the local user is, and who speaks for each document.
///
/// A document's author is the user holding its write key. Not transferable.
/// Its holder is the peer currently deciding how it moves, by default the
/// author's peer. Holding is transferable. Authors and holders are users,
/// named by DID.
package wired:peer;

interface identity {
  use wired:core/ids.{did};
  use wired:core/error.{error};

  /// The local user's identifier.
  self-did: func() -> result<did, error>;
}

interface authority {
  use wired:core/ids.{did};
  use wired:core/error.{error};
  use wired:scene/document.{document};

  /// Who authors `document`, or `none` when no author has proven itself,
  /// as with a space's own content.
  author: func(document: borrow<document>) -> result<option<did>, error>;
  /// Who holds `document` now: the latest peer to take hold, else its
  /// author. `none` outside a space.
  holder: func(document: borrow<document>) -> result<option<did>, error>;

  /// Whether the local user authors `document`, whose `shared` layer every
  /// viewer applies in full.
  is-author: func(document: borrow<document>) -> result<bool, error>;
  /// Whether this peer holds `document` now.
  is-holder: func(document: borrow<document>) -> result<bool, error>;

  /// Takes hold of a document the script may write, so this peer drives its
  /// motion. Anyone may hold; a standing reservation narrows that to the
  /// reserved user or the author.
  take-hold: func(document: borrow<document>) -> result<_, error>;
  /// Gives up this peer's hold, opening it to anyone, or reserving the next
  /// hold for `to` while it stands unclaimed.
  release-hold: func(document: borrow<document>, to: option<did>) -> result<_, error>;
}