Implements the four-stage pipeline:
- parse_request/3 - Parse and validate input with fail-fast
- execute_ash_action/1 - Execute Ash operations
- filter_result_fields/2 - Apply field selection
- format_output/2 - Format for client consumption
Summary
Functions
Stage 2: Execute Ash action using the parsed request.
Stage 4: Format output for client consumption.
Stage 4: Format output for client consumption with type awareness.
Formats a sort string by converting field names from client format to internal format.
Stage 1: Parse and validate request.
Stage 3: Filter result fields using the extraction template.
Functions
@spec execute_ash_action(AshTypescript.Rpc.Request.t()) :: {:ok, term()} | {:error, term()}
Stage 2: Execute Ash action using the parsed request.
Builds the appropriate Ash query/changeset and executes it. Returns the raw Ash result for further processing.
Stage 4: Format output for client consumption.
Applies output field formatting and final response structure.
Stage 4: Format output for client consumption with type awareness.
Applies type-aware output field formatting and final response structure.
Formats a sort string by converting field names from client format to internal format.
Handles Ash.Query.sort_input format:
- "name" or "+name" (ascending)
- "++name" (ascending with nils first)
- "-name" (descending)
- "--name" (descending with nils last)
- "-name,++title" (multiple fields with different modifiers)
Preserves sort modifiers while converting field names using the input formatter.
Examples
iex> format_sort_string("--startDate,++insertedAt", :camel_case)
"--start_date,++inserted_at"
iex> format_sort_string("-userName", :camel_case)
"-user_name"
iex> format_sort_string(nil, :camel_case)
nil
@spec parse_request(atom(), Plug.Conn.t() | Phoenix.Socket.t(), map(), keyword()) :: {:ok, AshTypescript.Rpc.Request.t()} | {:error, term()}
Stage 1: Parse and validate request.
Converts raw request parameters into a structured Request with validated fields. Fails fast on any invalid input - no permissive modes.
@spec process_result(term(), AshTypescript.Rpc.Request.t()) :: {:ok, term()} | {:error, term()}
Stage 3: Filter result fields using the extraction template.
Applies field selection to the Ash result using the pre-computed template. Performance-optimized single-pass filtering. For unconstrained maps, returns the normalized result directly. Handles metadata extraction for both read and mutation actions. If the extraction template is empty for mutation actions (create/update), returns empty data.