libero/codegen_decoders
Typed decoder generators.
Emits the rpc_decoders.gleam Gleam wrapper and the per-type
rpc_decoders_ffi.mjs JavaScript module that the generated client
stubs use to decode ETF responses into typed Gleam values.
Values
pub fn emit_typed_decoders(
discovered: List(walker.DiscoveredType),
) -> String
Emit a JS string with one decoder function per discovered type and an
ensure_decoders entry point. Does not write to disk; exposed so
tests can assert on the output without filesystem I/O.
pub fn write_decoders_ffi(
config config: config.Config,
discovered discovered: List(walker.DiscoveredType),
endpoints endpoints: List(scanner.HandlerEndpoint),
) -> Result(Nil, gen_error.GenError)
Write the typed decoders FFI file for the consumer. Per-endpoint response decoders are appended after the per-type decoders.
pub fn write_decoders_gleam(
config config: config.Config,
) -> Result(Nil, gen_error.GenError)
Write the Gleam wrapper for the typed decoder FFI.
Surfaces ensure_decoders from the generated JS FFI file to Gleam
callers, which triggers constructor and decoder registration on
import. JS-only, no Erlang target fallback.