AshTypescript.Rpc.OutputFormatter (ash_typescript v0.17.2)

Copy Markdown View Source

Formats output data from internal format to client format.

This module handles the conversion of Ash result data to client-expected format. It works with the full resource schema including attributes, relationships, calculations, and aggregates, then delegates to ValueFormatter for recursive type-aware formatting of nested values.

Key responsibilities:

  • Convert internal atom keys to client field names (e.g., :user_id -> "userId")
  • Preserve untyped map keys exactly as stored
  • Handle complex nested structures with relationships, calculations, aggregates
  • Work with ResultProcessor extraction templates
  • Handle pagination structures and result data

Summary

Functions

Formats output data from internal format to client format.

Functions

format(data, resource, action_name, formatter)

Formats output data from internal format to client format.

Converts internal field names to client format while preserving untyped map keys. Handles the full resource schema including relationships, calculations, and aggregates.

Parameters

  • data: The result data from Ash (internal format)
  • resource: The Ash resource module
  • action_name: The name of the action that was performed
  • formatter: The field formatter to use for conversion

Returns

The formatted data with internal atom keys converted to client field names, except for untyped map keys which are preserved exactly.