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 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() | Ash.Info.Manifest.Type.t()) :: field_category()
Classifies a field by its type, handling NewType unwrapping and array wrappers.
Accepts Ash field structs or %Ash.Info.Manifest.Type{}.
@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.
Accepts Ash field structs, %Ash.Info.Manifest.Field{}, or %Ash.Info.Manifest.Type{}.
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 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.