Spacetimedbex.Codegen (spacetimedbex v0.1.2)

Copy Markdown View Source

Generates Elixir source code from a SpacetimeDB schema.

Pure function: takes a %Schema{} and a base module name, returns a list of {relative_path, source_string} tuples ready to be written to disk.

Generated modules

  • BaseModule.Tables.TableName — defstruct + @type t + from_row/1 for each table
  • BaseModule.Reducers — typed functions that call Client.call_reducer
  • BaseModule.Clientuse Spacetimedbex.Client skeleton with config and stub callbacks

Summary

Functions

Generate source files from a schema.

Functions

generate(schema, base_module, opts \\ [])

@spec generate(Spacetimedbex.Schema.t(), String.t(), keyword()) :: [
  {String.t(), String.t()}
]

Generate source files from a schema.

Returns [{relative_path, formatted_source}].