Alternera.Resource.Info (alternera_resource_sdk v0.9.0)

Copy Markdown View Source

Reads a resource's alternera_resource section and its identity.

Summary

Types

A reference named by its destination's lookup key (Transformers.AddReferenceKeys).

What ui/1 returns: the resource's own UI, by kind.

Functions

Caches pipeline and Lua lookups on each node: true (60 000 ms) or [ttl_ms: n] with n > 0. Off by default: every lookup reads the database.

Caches pipeline and Lua lookups on each node: true (60 000 ms) or [ttl_ms: n] with n > 0. Off by default: every lookup reads the database.

One sentence for lists and MCP.

One sentence for lists and MCP.

What the proxy exposes beyond its UI. Nothing is exposed unless listed.

What the proxy exposes beyond its UI. Nothing is exposed unless listed.

Shown in navigation, lists and MCP.

Shown in navigation, lists and MCP.

The public attributes shown as grid columns, in order.

The public attributes shown as grid columns, in order.

The attribute a pipeline lookup, Lua, a CSV upsert and select labels find a record by. An identity on it alone must make it unique per tenant.

The attribute a pipeline lookup, Lua, a CSV upsert and select labels find a record by. An identity on it alone must make it unique per tenant.

alternera_resource DSL options

Generic actions that change nothing (a calculation, a lookup): any role in the tenant may run them, as it may read, and the API serves them as a GET. Any other generic action needs the role that writes.

Generic actions that change nothing (a calculation, a lookup): any role in the tenant may run them, as it may read, and the API serves them as a GET. Any other generic action needs the role that writes.

A LiveComponent shown in place of the generated page; the same as ui's screen.

A LiveComponent shown in place of the generated page; the same as ui's screen.

alternera_resource.ui DSL entities

A LiveComponent laying out the record form.

A LiveComponent laying out the record form.

alternera_resource.ui DSL options

A LiveComponent shown in place of the generated page.

A LiveComponent shown in place of the generated page.

The lookup cache: nil when off, %{ttl_ms: n} when on (cache true means 60 000 ms). A setting the contract refuses reads as nil.

The one-sentence description, or nil.

The exposed JSON:API routes.

The generic actions in expose api:, each served as a route of its own.

The action names exposed to the MCP tools.

The JSON:API route kinds in expose api: (:index, :get, :post, :patch, :delete).

%{package_id, resource_id, table, schema} as use Alternera.Resource set them.

The display label.

The grid columns, in order.

The lookup key attribute, or nil.

The resource's full name, "<package id>.<resource id>".

A package's own pages and Workbench items, from its domain's alternera_ui section: %{pages: [...], workbench_items: [...]}.

The generic actions that change nothing (read_only_actions).

The belongs_to references whose destination has a lookup key, each with field, the calculation and argument (<relationship>_<key>) that name the record by that key outside the proxy in place of attribute.

Whether the module is a resource of a resource package.

The LiveComponent replacing the generated page, or nil: ui's screen, else the section's own screen option.

The attribute every resource is scoped by: :tenant_id.

The resource's own UI, from alternera_resource's ui section.

Types

reference_key()

@type reference_key() :: %{
  relationship: atom(),
  attribute: atom(),
  destination: module(),
  key: atom(),
  field: atom(),
  type: term(),
  constraints: keyword()
}

A reference named by its destination's lookup key (Transformers.AddReferenceKeys).

ui()

@type ui() :: %{
  screen: module() | nil,
  form: module() | nil,
  cells: %{required(atom()) => module()},
  fields: %{required(atom()) => module()},
  panels: [Alternera.Resource.Extension.Panel.t()],
  actions: [Alternera.Resource.Extension.Action.t()],
  views: [Alternera.Resource.Extension.View.t()],
  workbench_items: [Alternera.Resource.Extension.Surface.t()]
}

What ui/1 returns: the resource's own UI, by kind.

Functions

alternera_resource_cache(dsl_or_extended)

@spec alternera_resource_cache(dsl_or_extended :: module() | map()) ::
  {:ok, boolean() | keyword()} | :error

Caches pipeline and Lua lookups on each node: true (60 000 ms) or [ttl_ms: n] with n > 0. Off by default: every lookup reads the database.

alternera_resource_cache!(dsl_or_extended)

@spec alternera_resource_cache!(dsl_or_extended :: module() | map()) ::
  (boolean() | keyword()) | no_return()

Caches pipeline and Lua lookups on each node: true (60 000 ms) or [ttl_ms: n] with n > 0. Off by default: every lookup reads the database.

alternera_resource_description(dsl_or_extended)

@spec alternera_resource_description(dsl_or_extended :: module() | map()) ::
  {:ok, String.t()} | :error

One sentence for lists and MCP.

alternera_resource_description!(dsl_or_extended)

@spec alternera_resource_description!(dsl_or_extended :: module() | map()) ::
  String.t() | no_return()

One sentence for lists and MCP.

alternera_resource_expose(dsl_or_extended)

@spec alternera_resource_expose(dsl_or_extended :: module() | map()) ::
  {:ok, mcp: [atom()], api: [atom()]} | :error

What the proxy exposes beyond its UI. Nothing is exposed unless listed.

alternera_resource_expose!(dsl_or_extended)

@spec alternera_resource_expose!(dsl_or_extended :: module() | map()) ::
  [mcp: [atom()], api: [atom()]] | no_return()

What the proxy exposes beyond its UI. Nothing is exposed unless listed.

alternera_resource_label(dsl_or_extended)

@spec alternera_resource_label(dsl_or_extended :: module() | map()) ::
  {:ok, String.t()} | :error

Shown in navigation, lists and MCP.

alternera_resource_label!(dsl_or_extended)

@spec alternera_resource_label!(dsl_or_extended :: module() | map()) ::
  String.t() | no_return()

Shown in navigation, lists and MCP.

alternera_resource_list_fields(dsl_or_extended)

@spec alternera_resource_list_fields(dsl_or_extended :: module() | map()) ::
  {:ok, [atom()]} | :error

The public attributes shown as grid columns, in order.

alternera_resource_list_fields!(dsl_or_extended)

@spec alternera_resource_list_fields!(dsl_or_extended :: module() | map()) ::
  [atom()] | no_return()

The public attributes shown as grid columns, in order.

alternera_resource_lookup_key(dsl_or_extended)

@spec alternera_resource_lookup_key(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

The attribute a pipeline lookup, Lua, a CSV upsert and select labels find a record by. An identity on it alone must make it unique per tenant.

alternera_resource_lookup_key!(dsl_or_extended)

@spec alternera_resource_lookup_key!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

The attribute a pipeline lookup, Lua, a CSV upsert and select labels find a record by. An identity on it alone must make it unique per tenant.

alternera_resource_options(dsl_or_extended)

@spec alternera_resource_options(dsl_or_extended :: module() | map()) :: %{
  required(atom()) => any()
}

alternera_resource DSL options

Returns a map containing the and any configured or default values.

alternera_resource_read_only_actions(dsl_or_extended)

@spec alternera_resource_read_only_actions(dsl_or_extended :: module() | map()) ::
  {:ok, [atom()]} | :error

Generic actions that change nothing (a calculation, a lookup): any role in the tenant may run them, as it may read, and the API serves them as a GET. Any other generic action needs the role that writes.

alternera_resource_read_only_actions!(dsl_or_extended)

@spec alternera_resource_read_only_actions!(dsl_or_extended :: module() | map()) ::
  [atom()] | no_return()

Generic actions that change nothing (a calculation, a lookup): any role in the tenant may run them, as it may read, and the API serves them as a GET. Any other generic action needs the role that writes.

alternera_resource_screen(dsl_or_extended)

@spec alternera_resource_screen(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

A LiveComponent shown in place of the generated page; the same as ui's screen.

alternera_resource_screen!(dsl_or_extended)

@spec alternera_resource_screen!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

A LiveComponent shown in place of the generated page; the same as ui's screen.

alternera_resource_ui(dsl_or_extended)

@spec alternera_resource_ui(dsl_or_extended :: module() | map()) :: [struct()]

alternera_resource.ui DSL entities

alternera_resource_ui_form(dsl_or_extended)

@spec alternera_resource_ui_form(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

A LiveComponent laying out the record form.

alternera_resource_ui_form!(dsl_or_extended)

@spec alternera_resource_ui_form!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

A LiveComponent laying out the record form.

alternera_resource_ui_options(dsl_or_extended)

@spec alternera_resource_ui_options(dsl_or_extended :: module() | map()) :: %{
  required(atom()) => any()
}

alternera_resource.ui DSL options

Returns a map containing the and any configured or default values.

alternera_resource_ui_screen(dsl_or_extended)

@spec alternera_resource_ui_screen(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

A LiveComponent shown in place of the generated page.

alternera_resource_ui_screen!(dsl_or_extended)

@spec alternera_resource_ui_screen!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

A LiveComponent shown in place of the generated page.

cache(resource)

@spec cache(module() | map()) :: %{ttl_ms: pos_integer()} | nil

The lookup cache: nil when off, %{ttl_ms: n} when on (cache true means 60 000 ms). A setting the contract refuses reads as nil.

description(resource)

@spec description(module() | map()) :: String.t() | nil

The one-sentence description, or nil.

expose_api(resource)

@spec expose_api(module() | map()) :: [atom()]

The exposed JSON:API routes.

expose_api_actions(resource)

@spec expose_api_actions(module() | map()) :: [atom()]

The generic actions in expose api:, each served as a route of its own.

expose_mcp(resource)

@spec expose_mcp(module() | map()) :: [atom()]

The action names exposed to the MCP tools.

expose_routes(resource)

@spec expose_routes(module() | map()) :: [atom()]

The JSON:API route kinds in expose api: (:index, :get, :post, :patch, :delete).

identity(resource)

@spec identity(module()) :: map()

%{package_id, resource_id, table, schema} as use Alternera.Resource set them.

label(resource)

@spec label(module() | map()) :: String.t() | nil

The display label.

list_fields(resource)

@spec list_fields(module() | map()) :: [atom()]

The grid columns, in order.

lookup_key(resource)

@spec lookup_key(module() | map()) :: atom() | nil

The lookup key attribute, or nil.

name(resource)

@spec name(module()) :: String.t()

The resource's full name, "<package id>.<resource id>".

package_ui(domain)

@spec package_ui(module()) :: %{
  pages: [Alternera.Resource.Extension.Surface.t()],
  workbench_items: [Alternera.Resource.Extension.Surface.t()]
}

A package's own pages and Workbench items, from its domain's alternera_ui section: %{pages: [...], workbench_items: [...]}.

read_only_actions(resource)

@spec read_only_actions(module() | map()) :: [atom()]

The generic actions that change nothing (read_only_actions).

reference_keys(resource)

@spec reference_keys(module()) :: [reference_key()]

The belongs_to references whose destination has a lookup key, each with field, the calculation and argument (<relationship>_<key>) that name the record by that key outside the proxy in place of attribute.

resource?(module)

@spec resource?(module()) :: boolean()

Whether the module is a resource of a resource package.

screen(resource)

@spec screen(module() | map()) :: module() | nil

The LiveComponent replacing the generated page, or nil: ui's screen, else the section's own screen option.

tenant_attribute()

@spec tenant_attribute() :: atom()

The attribute every resource is scoped by: :tenant_id.

ui(resource)

@spec ui(module() | map()) :: ui()

The resource's own UI, from alternera_resource's ui section.