AshTypescript.TypedController.Codegen (ash_typescript v0.17.3)

Copy Markdown View Source

Entry point for TypeScript path helper code generation.

Orchestrates the generation of TypeScript path helper functions from typed controller routes configured in the DSL.

Summary

Functions

Collects all exports for a list of route infos (for namespace re-export files).

Collects all per-route Zod schemas from typed controller routes.

Generates typed controller TypeScript content for the multi-file architecture.

Generates a namespace re-export file for the given namespace and route infos.

Groups route infos by resolved namespace.

Functions

collect_route_exports(route_infos)

Collects all exports for a list of route infos (for namespace re-export files).

Returns a list of {name, kind} tuples where kind is :value, :type, or :zod_value.

collect_route_zod_schemas(opts \\ [])

Collects all per-route Zod schemas from typed controller routes.

Returns a list of Zod schema strings (one per mutation route that has non-path arguments). These are meant to be passed to SharedSchemaGenerator as :additional_schemas.

generate_controller_content(opts)

Generates typed controller TypeScript content for the multi-file architecture.

This generates the controller routes file with imports from shared types file. No inline types, no Zod schemas — those live in ash_types.ts and ash_zod.ts.

Parameters

  • opts - Options keyword list:
    • :router - Phoenix router module
    • :import_paths - %{types: path} for import resolution (types only, no Zod)

generate_controller_namespace_reexport_content(namespace, route_infos, routes_file_path, zod_file_path)

Generates a namespace re-export file for the given namespace and route infos.

Used by the Orchestrator to generate namespace files with proper import paths.

get_routes_by_namespace(opts \\ [])

Groups route infos by resolved namespace.

Returns a map of %{namespace => [route_info]} where namespace is a string or nil.