Aurora. Uix. Integration. Ash. CrudSpec
(Aurora UIX v0.1.4-rc.6)
Copy Markdown
Defines the specification structure for Ash CRUD operations.
Encapsulates the Ash resource, action, Aurora UIX action name, and the optional
socket.assigns key that holds the runtime actor used to authorize policy-protected
resources.
Key Features
- Stores Ash resource module references
- Associates Ash actions with Aurora UIX action names
- Enables structured function reference creation
- Carries
:actor_assign— the compile-time atom naming whichsocket.assignskey holds the actor, resolved at every CRUD call site byAurora.Uix.Integration.Ash.Crud.socket_opts/2 - Factory methods for convenient instantiation
Key Constraints
- At least
:resourceshould be provided for meaningful usage :actioncontains Ash action struct (Read, Create, Update, or Destroy) or a function reference (only valid in :ash_new_function option):auix_action_namemaps to Aurora UIX action conventions (e.g.,:list_function,:get_function):actor_assignisnilby default — noactor:is forwarded to Ash, preserving the previous behaviour for resources that do not useAsh.Policy.Authorizer
See the Ash integration guide — Authorization & policies for the end-to-end worked example and the behaviour matrix.
Summary
Functions
Creates an empty CrudSpec struct.
Creates a new CrudSpec struct with the specified values.
Types
Functions
@spec new() :: t()
Creates an empty CrudSpec struct.
Returns
t() - A new empty %CrudSpec{} struct with all fields set to nil.
Examples
iex> new()
%CrudSpec{resource: nil, action: nil, auix_action_name: nil, actor_assign: nil}
Creates a new CrudSpec struct with the specified values.
Parameters
resource(module() | nil) - The Ash resource module.action(struct() | nil) - The Ash action struct.auix_action_name(atom() | nil) - The Aurora UIX action name.opts(keyword()) - Optional extras::actor_assign(atom() | nil) - Name of thesocket.assignskey that holds the actor. When set,Aurora.Uix.Integration.Ash.Crud.socket_opts/2extracts the actor from the socket and forwards it asactor:on every Ash call.
Returns
t() - A new %CrudSpec{} struct with the provided values.
Examples
iex> new(MyApp.User, %Ash.Resource.Actions.Read{}, :list_function)
%CrudSpec{resource: MyApp.User,
action: %Ash.Resource.Actions.Read{}, auix_action_name: :list_function,
actor_assign: nil}
iex> new(MyApp.User, %Ash.Resource.Actions.Read{}, :list_function,
...> actor_assign: :current_user)
%CrudSpec{resource: MyApp.User,
action: %Ash.Resource.Actions.Read{}, auix_action_name: :list_function,
actor_assign: :current_user}