rally/generator/codec

Client package codec and page module generator.

Generates:

Types

pub type CodecFile {
  CodecFile(path: String, content: String)
}

Constructors

  • CodecFile(path: String, content: String)

Values

pub fn client_context_seeds(
  source source: String,
  module_path module_path: String,
) -> List(#(String, String))

Extract (module_path, type_name) seeds from a client_context.gleam source so the walker can discover ClientContext types with proper field type resolution, instead of the old hardcoded-StringField path.

pub fn generate(
  contracts contracts: List(
    #(types.ScannedRoute, types.PageContract),
  ),
  discovered discovered: List(walker.DiscoveredType),
  endpoints endpoints: List(scanner.HandlerEndpoint),
  server_symbols server_symbols: List(String),
  protocol protocol: String,
) -> List(CodecFile)

Generate all codec files for the client package.

pub fn generate_json_codecs(
  discovered discovered: List(walker.DiscoveredType),
  endpoints endpoints: List(scanner.HandlerEndpoint),
) -> List(CodecFile)

Generate JSON typed encoder/decoder source for the client package. Uses libero’s JSON codegen to produce per-type json.Json builders and typed decoders for all discovered types.

pub fn generate_json_decode_dispatch(
  discovered: List(walker.DiscoveredType),
) -> CodecFile

Generate a Gleam module that dispatches decoder names to the corresponding JSON typed decoders at runtime.

The decoder_name follows the ETF codec convention (e.g. “decode_pages_home__model”) and is mapped to the json_decode_<qualified_atom_name> function in json_codecs.

pub fn generate_json_type_registry_js(
  discovered: List(walker.DiscoveredType),
) -> CodecFile
Search Document