Alva.Codegen.DtoGenerator (Alva v0.1.0)

Copy Markdown View Source

Generates TypeScript interfaces for Ash resources and their filter types.

Produces the types.ts file that defines TypeScript interfaces for each Ash resource, plus filter interfaces for resources with enable_filter: true. Also provides output_type/2 to determine the return type of an event.

See Mix.Tasks.Alva.Codegen for the full code generation pipeline.

Summary

Functions

Generates the complete types.ts content including base filter types, resource filter interfaces, and resource data interfaces.

Derives the TypeScript interface name from an Ash resource module.

Determines the TypeScript output type for a given event.

Functions

generate_types_ts(resources, events_map \\ nil)

(since 0.1.0)

Generates the complete types.ts content including base filter types, resource filter interfaces, and resource data interfaces.

interface_name(resource)

(since 0.1.0)

Derives the TypeScript interface name from an Ash resource module.

Uses the last segment of the module name (e.g. MyApp.Catalog.ProductProduct).

output_type(resource, event_def)

(since 0.1.0)

Determines the TypeScript output type for a given event.

Returns "InterfaceName[]" for list reads, or "InterfaceName" for single-record reads, lookups, and mutations.