AshTypescript.Rpc.ValueFormatter (ash_typescript v0.18.0)

Copy Markdown View Source

Unified value formatting for RPC input/output.

Traverses composite values recursively, applying field name mappings and type-aware formatting at each level. All type dispatch uses %Ash.Info.Manifest.Type{} exclusively — no raw Ash type atoms or {:array, _} tuples.

Key Design Principle

The "parent resource" is never needed because each type is self-describing. When we recurse into a nested value, we pass the sub-field's %Ash.Info.Manifest.Type{} which contains all type information needed.

Summary

Types

direction()

@type direction() :: :input | :output

Functions

format(value, type, constraints, formatter, direction, resource_lookups \\ nil, ti \\ %{})

Formats a value based on its type.

Parameters

  • value - The value to format
  • type - An %Ash.Info.Manifest.Type{}, %Ash.Info.Manifest.Field{}, %Ash.Info.Manifest.Relationship{}, or nil
  • constraints - Unused (kept for backward compatibility at call sites)
  • formatter - The field formatter configuration (:camel_case, :snake_case, etc.)
  • direction - :input (client→internal) or :output (internal→client)
  • resource_lookups - Pre-computed resource lookup map