libero/config

Types

Everything libero needs from its invocation args, normalized. Paths are derived from –namespace and –client with single-SPA defaults when those flags are absent.

pub type Config {
  Config(
    ws_mode: WsMode,
    namespace: option.Option(String),
    client_root: String,
    atoms_output: String,
    atoms_module: String,
    config_output: String,
    register_relpath_prefix: String,
    decoders_ffi_output: String,
    decoders_gleam_output: String,
    decoders_prelude_import_path: String,
    shared_src: option.Option(String),
    server_src: option.Option(String),
    server_generated: String,
    client_generated: String,
  )
}

Constructors

  • Config(
      ws_mode: WsMode,
      namespace: option.Option(String),
      client_root: String,
      atoms_output: String,
      atoms_module: String,
      config_output: String,
      register_relpath_prefix: String,
      decoders_ffi_output: String,
      decoders_gleam_output: String,
      decoders_prelude_import_path: String,
      shared_src: option.Option(String),
      server_src: option.Option(String),
      server_generated: String,
      client_generated: String,
    )

    Arguments

    atoms_output

    Path to the generated .erl file that pre-registers all constructor atoms for safe ETF decoding.

    atoms_module

    Erlang module name for the atoms .erl file, using Gleam’s path-to-module convention (@ separators).

    register_relpath_prefix

    Bundle-relative prefix that prepends every import in the generated FFI .mjs file. Depth depends on where the decoder files land inside the consumer client package.

    decoders_ffi_output

    Path to the generated rpc_decoders_ffi.mjs file.

    decoders_gleam_output

    Path to the generated rpc_decoders.gleam wrapper file.

    decoders_prelude_import_path

    Import path the generated decoders FFI uses to pull from the static decoders_prelude.mjs shipped with libero.

Errors from config construction (invalid namespace, etc.).

pub type ConfigError {
  InvalidNamespace(namespace: String)
}

Constructors

  • InvalidNamespace(namespace: String)

How the generated client resolves its WebSocket URL.

pub type WsMode {
  WsFullUrl(url: String)
  WsPathOnly(path: String)
}

Constructors

  • WsFullUrl(url: String)

    Hardcoded full URL (from –ws-url). Single-host deployments.

  • WsPathOnly(path: String)

    Path-only, resolved at runtime from window.location (from –ws-path). Multi-tenant deployments where multiple subdomains share one bundle.

Values

pub fn build_config(
  ws_mode ws_mode: WsMode,
  namespace namespace: option.Option(String),
  client_root client_root: String,
  shared_root shared_root: Result(String, Nil),
  server_root server_root: Result(String, Nil),
) -> Result(Config, ConfigError)

Derive all paths from –namespace and –client. When namespace is None the paths land under generated/libero/ inside the consumer’s server and client packages. When set, paths are nested one level deeper under generated/libero// to keep multi-SPA output physically isolated.

pub fn describe_error(error: ConfigError) -> String

Format a ConfigError as a user-facing error message.

pub fn find_flag(
  args args: List(String),
  name name: String,
) -> Result(String, Nil)

Extract a --name=value flag from the argument list.

Only supports --key=value syntax (not space-separated --key value). This is intentional: find_flag is used for libero’s internal codegen flags which always use = form. The space-separated pattern (--database pg, --target javascript) is handled by positional matching in cli.parse_args and is not interchangeable with this function.

Search Document