AshUi.ResourceBlueprint (ash_ui v0.1.0)

Copy Markdown View Source

Normalized resource contract consumed by the runtime and adapters.

name is retained as a stable alias of id .

Summary

Types

action()

@type action() :: %{
  name: atom(),
  type: atom(),
  when_variant: atom() | nil,
  arguments: [map()],
  set: [%{field: atom(), expr: Ash.Expr.t()}],
  changes: [map()]
}

attribute()

@type attribute() :: %{
  :name => atom(),
  :type => atom(),
  :default => term(),
  optional(:route) => map() | nil,
  primary_key?: boolean(),
  required?: boolean(),
  public?: boolean()
}

calculation()

@type calculation() :: %{
  name: atom(),
  type: atom(),
  constraints: keyword(),
  calculation: module() | {module(), keyword()} | nil,
  expr: Ash.Expr.t() | nil,
  allow_nil?: boolean()
}

relationship()

@type relationship() :: %{
  :name => atom(),
  :type => :belongs_to | :has_many | :has_one,
  :destination => module(),
  :destination_kind => :static,
  :destination_resource => t() | nil,
  :source_attribute => atom() | nil,
  :destination_attribute => atom() | nil,
  :define_attribute? => boolean() | nil,
  :attribute_type => atom() | module() | nil,
  :allow_nil? => boolean() | nil,
  optional(:read_action) => atom() | nil,
  optional(:filter) => term(),
  optional(:sort) => term(),
  optional(:limit) => integer() | nil,
  optional(:offset) => non_neg_integer() | nil,
  optional(:no_attributes?) => boolean(),
  optional(:required_parent_attrs) => [atom()]
}

route()

@type route() :: %{
  params: [%{name: atom(), type: atom(), default: term()}],
  queries: [%{name: atom(), default: term()}],
  states: [
    %{
      name: atom(),
      type: atom(),
      param: atom(),
      constraints: keyword(),
      default: term()
    }
  ]
}

t()

@type t() :: %AshUi.ResourceBlueprint{
  actions: [action()],
  aggregates: [map()],
  attributes: [attribute()],
  calculations: [calculation()],
  client_drivers: [atom() | String.t()],
  data_layer: module() | atom() | nil,
  deferred_checks: [map()],
  domain: module() | nil,
  dynamic_map_props: [map()],
  extensions: [module()],
  id: atom(),
  module: module() | nil,
  name: atom() | nil,
  relationships: [relationship()],
  route: route(),
  source: term(),
  strict_expressions?: :off | :warn | :strict,
  stylesheets: [String.t()],
  view: map() | nil
}