Aurora. Uix. Integration. Ash. ContextParserDefaults
(Aurora UIX v0.1.4-rc.8)
Copy Markdown
Parsing functionality for Ash-based resource configurations.
Automatically detects and configures context-related functions for resources, such as listing, getting, creating, updating, and deleting elements. Infers function names based on context and schema module conventions using Ash resource naming conventions.
Key Features
- Automatic function discovery from Ash resources
- Primary action detection with fallback to first available action
- Support for paginated and non-paginated read operations
- Function reference creation with action metadata
Key Constraints
- Currently only implements read-related actions (
:list_function,:list_function_paginated,:get_function) - Requires Ash resource configuration
- Returns placeholder function when no valid action is found
- Functions are resolved from configured Ash resource
Implemented Options
:list_function- Function reference for reading all elements:list_function_paginated- Function reference for reading elements using pagination:get_function- Function reference for getting one element:ash_actor_assign(alias::actor_assign) - Atom naming thesocket.assignskey that holds the actor for policy-protected resources. Defaultnil. When set, every generated CRUD call forwardsactor: socket.assigns[<assign>]to Ash. Non-atom values are silently rejected as a defensive measure against typos.
Example
auix_resource_metadata :template,
ash_resource: MyApp.Templates.InterfaceDocumentTemplate,
ash_actor_assign: :current_user # canonical
# or, equivalently:
# actor_assign: :current_user # aliasSee the Ash integration guide — Authorization & policies for the worked example and the full behaviour matrix.
Summary
Functions
Resolves default values for context-derived properties.
Functions
@spec option_value(map(), map(), keyword(), atom()) :: Aurora.Uix.Integration.Connector.t() | nil
Resolves default values for context-derived properties.
Discovers Ash actions from the resource, selecting primary actions when available or falling back to the first available action.
Parameters
parsed_opts(map()) - Map containing resolved options with:sourceand:module.resource_config(map()) - Map with keys::schema(module() | nil) - The Ash resource module.
key(atom()) - The Aurora UIX action key (:list_function,:list_function_paginated,:get_function,:change_function,:create_function,:update_function,:delete_function,:new_function).
Returns
Connector.t() | nil - Returns %Connector{} struct with %CrudSpec{} if action
found, otherwise returns nil for unhandled keys.
Examples
iex> default_value(%{}, %{context: MyApp.Accounts, schema: MyApp.User}, :list_function)
%Connector{type: :ash, crud_spec: %CrudSpec{...}}
iex> default_value(%{}, %{context: nil, schema: MyApp.Post}, :get_function)
%Connector{type: :ash, crud_spec: %CrudSpec{...}}