Incant.Service.Session (incant v0.1.0)

Copy Markdown

Admin UI session for one discovered Incant service entry.

A session wraps %Incant.Service.Entry{} and exposes admin-shaped operations without leaking SafeRPC operation tuples or Incant service request structs into LiveView/rendering code.

Summary

Functions

Returns the loaded transport-safe admin contract.

Fetches a surface by id from the loaded contract.

Lists all surfaces from the loaded contract.

Builds a session for a discovered service entry.

Types

surface()

@type surface() :: map()

t()

@type t() :: %Incant.Service.Session{context: map(), entry: Incant.Service.Entry.t()}

Functions

contract(session)

@spec contract(t()) :: Incant.Admin.Contract.t()

Returns the loaded transport-safe admin contract.

fetch_surface(session, surface_id, opts \\ [])

@spec fetch_surface(t(), String.t() | atom(), keyword()) ::
  {:ok, surface()} | {:error, term()}

Fetches a surface by id from the loaded contract.

index(session, surface_id, params \\ %{}, context \\ %{}, opts \\ [])

@spec index(t(), String.t() | atom(), map(), map(), keyword()) ::
  {:ok, map()} | {:error, term()}

Indexes a remote resource surface.

list_surfaces(session, opts \\ [])

@spec list_surfaces(
  t(),
  keyword()
) :: [surface()]

Lists all surfaces from the loaded contract.

new(entry, opts \\ [])

@spec new(
  Incant.Service.Entry.t(),
  keyword()
) :: t()

Builds a session for a discovered service entry.

read(session, surface_id, id, context \\ %{}, opts \\ [])

@spec read(t(), String.t() | atom(), term(), map(), keyword()) ::
  {:ok, term()} | {:error, term()}

Reads one remote resource item.

run_action(session, surface_id, action_id, payload \\ %{}, context \\ %{}, opts \\ [])

@spec run_action(
  t(),
  String.t() | atom(),
  String.t() | atom(),
  map(),
  map(),
  keyword()
) ::
  {:ok, Incant.ActionResult.t()} | {:error, term()}

Runs an action on a remote resource surface.

run_widget(session, surface_id, widget_id, variables \\ %{}, context \\ %{}, opts \\ [])

@spec run_widget(
  t(),
  String.t() | atom(),
  String.t() | atom(),
  map(),
  map(),
  keyword()
) ::
  {:ok, term()} | {:error, term()}

Runs a remote dashboard widget query.