PhoenixAssets. Types. Walker
(PhoenixAssets v0.1.0)
View Source
Walks Ash resources and renders TypeScript row types.
Given the declarations from PhoenixAssets.Types.Schema, this resolves each
resource's exposed fields (public attributes by default, minus sensitive ones,
adjusted by :omit/:expose, plus whitelisted calculations) and maps each Ash
type to TypeScript. The exposure model is deterministic -- it never tries to
evaluate Ash field policies (which are dynamic); instead PhoenixAssets.Types
cross-checks exposed fields against declared field policies and warns.
Type mapping highlights
uuid,ci_string, datetimes,decimal,binary->stringinteger,float->numberatomwithone_of, or anAsh.Type.Enummodule -> a string-literal union{:array, t}->Array<t>;mapwith:fields-> a typed object- nullable attributes gain
| null - embedded resources are inlined structurally; a cyclic embedding renders
as
unknownat the point of recursion (defense in depth -- current Ash rejects declared type cycles at compile time)
Unknown names in :expose or :calculations raise an ArgumentError
naming the resource and the field, rather than emitting a silently wrong
contract.
Summary
Functions
Resolves the exposed {field_name, ts_type} pairs for a resource declaration.
Renders the full types.ts body from the declared types.
Functions
Resolves the exposed {field_name, ts_type} pairs for a resource declaration.
Public so PhoenixAssets.Types can cross-check the exposed field set against
the resource's field policies.
Renders the full types.ts body from the declared types.