Shared logic for schema generation across all validation library targets.
All resource introspection, topological sorting, field resolution, and structural
code generation lives here. Output syntax is delegated to a module implementing
AshTypescript.Codegen.SchemaFormatter.
Consumers (e.g. ZodSchemaGenerator) pass __MODULE__ as the first formatter
argument to each public function.
Summary
Functions
Builds a JS regex flag string from Elixir Regex opts.
Generates a schema definition for an RPC action's input. Returns an empty string when the action has no input.
Generates a schema for a single resource.
Generates schemas for a list of resources (embedded resources, struct args). Returns an empty string when generation is disabled or the list is empty.
Maps Ash type structs (attribute/argument maps) to a schema string.
Handles allow_nil? for string types (non-nullable strings get min-length 1).
Wraps a schema string with wrap_nullable (innermost) and/or wrap_optional
(outermost) based on the two booleans, using the given formatter.
Returns true when a regex source string is safe to emit as a JS literal.
Functions
Builds a JS regex flag string from Elixir Regex opts.
Generates a schema definition for an RPC action's input. Returns an empty string when the action has no input.
Generates a schema for a single resource.
Generates schemas for a list of resources (embedded resources, struct args). Returns an empty string when generation is disabled or the list is empty.
Maps Ash type structs (attribute/argument maps) to a schema string.
Handles allow_nil? for string types (non-nullable strings get min-length 1).
Wraps a schema string with wrap_nullable (innermost) and/or wrap_optional
(outermost) based on the two booleans, using the given formatter.
Returns true when a regex source string is safe to emit as a JS literal.