AshTypescript.Rpc.Codegen.Helpers.ActionIntrospection (ash_typescript v0.17.2)

Copy Markdown View Source

Provides helper functions for analyzing Ash actions.

This module contains utilities for determining action characteristics like:

  • Pagination support (offset, keyset, required, countable)
  • Input requirements
  • Return type field selectability

The return type analysis uses a type-driven classification pattern with classify_return_type/2 for consistent handling of all type variants.

Summary

Functions

Returns true if the action has a default limit configured.

Returns :required | :optional | :none

Returns true if the action requires pagination.

Checks if a generic action returns a field-selectable type.

Returns true if the action supports countable pagination.

Returns true if the action supports keyset-based pagination.

Returns true if the action supports offset-based pagination.

Returns true if the action supports pagination.

Functions

action_has_default_limit?(action)

Returns true if the action has a default limit configured.

action_input_type(resource, action)

Returns :required | :optional | :none

Determines whether an action requires input, has optional input, or has no input. This is based on the action's public arguments and accepted attributes.

action_requires_pagination?(action)

Returns true if the action requires pagination.

action_returns_field_selectable_type?(action)

Checks if a generic action returns a field-selectable type.

Returns:

  • {:ok, :resource, resource_module} - Single resource
  • {:ok, :array_of_resource, resource_module} - Array of resources
  • {:ok, :typed_map, fields} - Typed map with constraints
  • {:ok, :array_of_typed_map, fields} - Array of typed maps
  • {:ok, :typed_struct, {module, fields}} - Type with field constraints (TypedStruct or similar)
  • {:ok, :array_of_typed_struct, {module, fields}} - Array of types with field constraints
  • {:ok, :unconstrained_map, nil} - Map without field constraints
  • {:ok, :array_of_unconstrained_map, nil} - Array of maps without field constraints
  • {:error, :not_generic_action} - Not a generic action
  • {:error, reason} - Other errors

action_supports_countable?(action)

Returns true if the action supports countable pagination.

action_supports_keyset_pagination?(action)

Returns true if the action supports keyset-based pagination.

action_supports_offset_pagination?(action)

Returns true if the action supports offset-based pagination.

action_supports_pagination?(action)

Returns true if the action supports pagination.

Examples

iex> action_supports_pagination?(%{type: :read, get?: false, pagination: %{offset?: true}})
true

iex> action_supports_pagination?(%{type: :read, get?: true})
false