Aurora. Uix. Integration. Ctx. ContextParserDefaults
(Aurora UIX v0.1.4-rc.9)
Copy Markdown
Default value resolution for Context-based resource configurations.
Automatically discovers and configures Context-based function references for CRUD operations by introspecting context modules and matching function names based on naming conventions. Creates Connector structures wrapping CrudSpec configurations.
Key Features
- Automatic function discovery from context modules
- Convention-based function name matching (e.g.,
list_users,get_user) - Fallback to alternative function names (e.g.,
get_user!) - Integration with Connector and CrudSpec structures
- Support for all standard CRUD operations
Key Constraints
- Requires context module to be available
- Function discovery based on naming conventions
- Returns placeholder function when no valid function is found
- Expected function arities must match operation requirements
Implemented Options
:list_function- Lists all resources:list_function_paginated- Lists resources with pagination:get_function- Retrieves a single resource:delete_function- Deletes a resource:create_function- Creates a new resource:update_function- Updates an existing resource:change_function- Creates a changeset for updates:new_function- Creates a new resource struct
Summary
Functions
Fills in any missing options with default values derived from the Ecto schema or Ash resource. This function can be used to ensure that all necessary options are populated, even if the user did not explicitly provide them. The implementation can be customized to fill in defaults based on the schema or resource configuration.
Resolves default function references for Context-based operations.
Functions
Fills in any missing options with default values derived from the Ecto schema or Ash resource. This function can be used to ensure that all necessary options are populated, even if the user did not explicitly provide them. The implementation can be customized to fill in defaults based on the schema or resource configuration.
Parameters
parsed_opts(map()): The current map of parsed options that may be missing some keys.resource_config(map()): The resource configuration that may contain the Ecto schema or Ash resource information needed to derive default values.
Returns
map(): The updated map of parsed options with missing values filled in.
@spec option_value(map(), map(), keyword(), atom()) :: Aurora.Uix.Integration.Connector.t()
Resolves default function references for Context-based operations.
Discovers functions from the context module using naming conventions, selecting the first available match from a list of candidate names.
Parameters
parsed_opts(map()) - Map containing::source(binary()) - The source name (e.g., "users").:module(binary()) - The module name (e.g., "user").
resource_config(map()) - Map with::context(module()) - The context module to introspect.
auix_action_name(atom()) - The Aurora UIX action key (e.g.,:list_function,:get_function).
Returns
Connector.t() - A %Connector{} struct wrapping the %CrudSpec{} and function reference.
Examples
iex> default_value(%{source: "users", module: "user"}, %{context: MyApp.Accounts},
...> :list_function)
%Connector{type: :ctx, crud_spec: %CrudSpec{function_spec: &MyApp.Accounts.list_users/1}}
iex> default_value(%{module: "post"}, %{context: MyApp.Blog}, :get_function)
%Connector{type: :ctx, crud_spec: %CrudSpec{function_spec: &MyApp.Blog.get_post/2}}