Generates TypeScript schemas for Ash resources.
Uses a unified field classification pattern for determining how to generate
TypeScript definitions. The classify_field/1 function categorizes fields
into types like :primitive, :relationship, :embedded, :union, etc.
Summary
Types
Field categories for schema generation.
Functions
Classifies a field by its type, handling NewType unwrapping and array wrappers.
Classifies an Ash field into a category for schema generation.
Generates all schemas for a single resource. Includes the unified resource schema and optionally an input schema for resources that need it (embedded resources or struct argument resources).
Generates all schemas (unified + input) for a list of resources.
Generates an attributes-only schema for a resource.
Generates an input schema for embedded resources.
Generates a unified resource schema with metadata fields and direct field access. This replaces the multiple separate schemas with a single, metadata-driven schema.
Types
@type field_category() ::
:primitive
| :relationship
| :embedded
| :union
| :typed_map
| :typed_struct
| :calculation
Field categories for schema generation.
:primitive- Simple types mapped directly to TypeScript:relationship- Ash relationships (has_many, belongs_to, etc.):embedded- Embedded resources:union- Ash.Type.Union types:typed_map- Map/Keyword/Tuple with field constraints:typed_struct- Struct with fields and instance_of constraints:calculation- Complex calculations with arguments
Functions
@spec classify_by_type(map()) :: field_category()
Classifies a field by its type, handling NewType unwrapping and array wrappers.
@spec classify_field(map()) :: field_category()
Classifies an Ash field into a category for schema generation.
Handles relationships, calculations, and attribute types. Returns the field category which determines how to generate its TypeScript definition.
Generates all schemas for a single resource. Includes the unified resource schema and optionally an input schema for resources that need it (embedded resources or struct argument resources).
Generates all schemas (unified + input) for a list of resources.
Parameters
resources- List of resources to generate schemas forallowed_resources- List of resources allowed for schema generation (used for filtering)resources_needing_input_schema- Optional list of resources that need InputSchema generated (defaults to embedded resources)
Generates an attributes-only schema for a resource.
This schema only includes attributes (no calculations, relationships, or aggregates). It's used for first aggregates where nested field selection is possible but limited to fields that don't require loading.
For embedded resource attributes, recursively references their AttributesOnlySchema.
Generates an input schema for embedded resources.
Generates a unified resource schema with metadata fields and direct field access. This replaces the multiple separate schemas with a single, metadata-driven schema.