Mairzzcllo/moonbit_sqlc_plugin/plugin does not have a README file

    AdaptCatalog

    pub struct AdaptCatalog {
    name : String
    default_schema : String
    schemas : Array[AdaptSchema]
    }

    Internal model — cleaned-up catalog.

    AdaptColumn

    pub struct AdaptColumn {
    name : String
    not_null : Bool
    is_array : Bool
    ty : AdaptIdentifier
    length : Int
    comment : String
    table : AdaptIdentifier
    }

    Internal model — cleaned-up column.

    AdaptEnum

    pub struct AdaptEnum {
    name : String
    vals : Array[String]
    comment : String
    }

    Internal model — cleaned-up enum.

    AdaptIdentifier

    pub struct AdaptIdentifier {
    catalog : String
    schema : String
    name : String
    }

    Internal model — cleaned-up identifier.

    AdaptParameter

    pub struct AdaptParameter {
    number : Int
    column : AdaptColumn
    }

    Internal model — cleaned-up parameter.

    AdaptQuery

    pub struct AdaptQuery {
    text : String
    name : String
    cmd : QueryCmd
    columns : Array[AdaptColumn]
    params : Array[AdaptParameter]
    comments : Array[String]
    filename : String
    }

    Internal model — cleaned-up query with parsed cmd.

    AdaptRequest

    pub struct AdaptRequest {
    settings : AdaptSettings
    catalog : AdaptCatalog
    queries : Array[AdaptQuery]
    sqlc_version : String
    }

    Top-level internal model for a code generation request.

    AdaptSchema

    pub struct AdaptSchema {
    name : String
    comment : String
    tables : Array[AdaptTable]
    enums : Array[AdaptEnum]
    }

    Internal model — cleaned-up schema.

    AdaptSettings

    pub struct AdaptSettings {
    version : String
    engine : String
    }

    Internal model — cleaned-up settings.

    AdaptTable

    pub struct AdaptTable {
    name : String
    schema : String
    columns : Array[AdaptColumn]
    comment : String
    }

    Internal model — cleaned-up table.

    Catalog

    pub struct Catalog {
    comment : String
    default_schema : String
    name : String
    schemas : Array[Schema]
    }

    Codegen

    pub struct Codegen {
    out : String
    plugin : String
    options : Bytes
    env : Array[String]
    process : CodegenProcess?
    wasm : CodegenWASM?
    }

    CodegenProcess

    pub struct CodegenProcess {
    cmd : String
    }

    CodegenWASM

    pub struct CodegenWASM {
    url : String
    sha256 : String
    }

    Column

    pub struct Column {
    name : String
    not_null : Bool
    is_array : Bool
    comment : String
    length : Int
    is_named_param : Bool
    is_func_call : Bool
    scope : String
    table : Identifier
    table_alias : String
    ty : Identifier
    is_sqlc_slice : Bool
    embed_table : Identifier
    original_name : String
    unsigned : Bool
    array_dims : Int
    }

    ColumnOverride

    pub struct ColumnOverride {
    table : String
    column : String
    moonbit_type : String
    }

    A column-level type override: maps a specific table.column to a MoonBit type.

    CompositeType

    pub struct CompositeType {
    name : String
    comment : String
    }

    Decoder

    type Decoder

    Emitter

    type Emitter

    Pretty Printer / Emitter — P0-006. Converts MoonBit AST (P0-005) into formatted source code. Pure mechanical transformation — no sqlc/IR/database semantics.

    Encoder

    type Encoder

    Enum

    pub struct Enum {
    name : String
    vals : Array[String]
    comment : String
    }

    EnumDef

    pub struct EnumDef {
    name : String
    variants : Array[VariantDef]
    doc : String?
    is_pub : Bool
    }

    Enum definition.

    Expr

    pub enum Expr {
    Block(Array[Expr])
    Ident(String)
    Call(String, Array[Expr])
    Let(String, Expr)
    StrLit(String)
    IntLit(Int)
    ArrLit(Array[Expr])
    Index(Expr, Expr)
    Lambda(Array[ParamDef], Expr)
    BinOp(String, Expr, Expr)
    If(Expr, Expr, Expr)
    Return(Expr)
    Match(Expr, Array[(String, Expr)])
    ForLoop(String, Expr, Array[Expr])
    Unit
    }

    Expression in generated function bodies.

    FieldDef

    pub struct FieldDef {
    name : String
    col_name : String
    ty : TypeExpr
    doc : String?
    json_tag : String?
    db_tag : String?
    }

    A struct field definition.

    File

    pub struct File {
    name : String
    contents : Bytes
    }

    sqlc WASM plugin protocol types. Mirrors protos/plugin/codegen.proto from sqlc-dev/sqlc.

    FnDef

    pub struct FnDef {
    name : String
    params : Array[ParamDef]
    return_ty : TypeExpr
    body : Array[Expr]
    doc : String?
    is_pub : Bool
    }

    Function definition.

    GenerateRequest

    pub struct GenerateRequest {
    settings : Settings
    catalog : Catalog
    queries : Array[Query]
    sqlc_version : String
    plugin_options : Bytes
    global_options : Bytes
    }

    GenerateResponse

    pub struct GenerateResponse {
    files : Array[File]
    }

    Identifier

    pub struct Identifier {
    catalog : String
    schema : String
    name : String
    }

    ImportDef

    pub struct ImportDef {
    path : String
    import_alias : String?
    }

    Import statement.

    InternalField

    pub struct InternalField {
    name : String
    ty : InternalType
    not_null : Bool
    comment : String
    rename_to : String?
    }

    IR field — a named field in a query result or table struct.

    InternalParameter

    pub struct InternalParameter {
    number : Int
    name : String
    ty : InternalType
    not_null : Bool
    }

    IR parameter — a query parameter with position and type.

    InternalQuery

    pub struct InternalQuery {
    name : String
    text : String
    cmd : QueryCardinality
    raw_cmd : QueryCmd
    params : Array[InternalParameter]
    result_shape : InternalResultShape
    comments : Array[String]
    filename : String
    }

    IR query — complete codegen-ready query representation.

    InternalResultShape

    pub enum InternalResultShape {
    Rows(Array[InternalField])
    None
    }

    IR result shape — describes the structure of query results.

    InternalType

    pub enum InternalType {
    Named(String)
    Arr(InternalType)
    }

    IR type — resolved or unresolved type reference.

    MessageOutcome

    pub enum MessageOutcome {
    Ok(Bytes)
    Err(String)
    }

    Outcome of processing a raw protobuf GenerateRequest.

    ParamDef

    pub struct ParamDef {
    name : String
    ty : TypeExpr
    }

    Function parameter definition.

    Parameter

    pub struct Parameter {
    number : Int
    column : Column
    }

    PluginOptions

    pub struct PluginOptions {
    package_name : String
    overrides : Array[(String, String)]
    emit_json_tags : Bool
    emit_db_tags : Bool
    renames : Array[(String, String)]
    emit_sql_as_comment : Bool
    omit_unused_structs : Bool
    emit_empty_slices : Bool
    initialisms : String
    json_tags_case_style : String
    emit_exact_table_names : Bool
    emit_methods_with_db_argument : Bool
    column_overrides : Array[ColumnOverride]
    nullable_overrides : Array[String]
    strict_types : Bool
    runtime_alias : String
    }

    Parsed plugin/global options from codegen configuration.

    Query

    pub struct Query {
    text : String
    name : String
    cmd : String
    columns : Array[Column]
    params : Array[Parameter]
    comments : Array[String]
    filename : String
    insert_into_table : Identifier
    }

    QueryCardinality

    pub enum QueryCardinality {
    OneRow
    ManyRows
    ExecResult
    ExecCount
    }

    Query cardinality — determines generated function signature shape.

    QueryCmd

    pub enum QueryCmd {
    One
    Many
    Exec
    ExecRows
    CopyFrom
    Batch
    ExecLastId
    }

    Parsed query command kind from sqlc's :one, :many, :exec, :execrows, :copyfrom, :batch, :execlastid.

    Schema

    pub struct Schema {
    comment : String
    name : String
    tables : Array[Table]
    enums : Array[Enum]
    composite_types : Array[CompositeType]
    }

    Settings

    pub struct Settings {
    version : String
    engine : String
    schema : Array[String]
    queries : Array[String]
    codegen : Codegen
    }

    SourceFile

    pub struct SourceFile {
    items : Array[TopLevel]
    }

    A MoonBit source file — ordered list of top-level items.

    StructDef

    pub struct StructDef {
    name : String
    fields : Array[FieldDef]
    doc : String?
    is_pub : Bool
    }

    Struct definition.

    Table

    pub struct Table {
    rel : Identifier
    columns : Array[Column]
    comment : String
    }

    TopLevel

    pub enum TopLevel {
    Struct(StructDef)
    Enum(EnumDef)
    Fn(FnDef)
    TypeAlias(TypeAliasDef)
    Import(ImportDef)
    }

    Top-level item in a MoonBit source file.

    TypeAliasDef

    pub struct TypeAliasDef {
    name : String
    underlying : TypeExpr
    doc : String?
    }

    Type alias definition.

    TypeExpr

    pub enum TypeExpr {
    Named(String)
    Parameterized(String, Array[TypeExpr])
    Option(TypeExpr)
    Wildcard
    }

    A type expression — used in struct fields, function signatures, etc.

    VariantDef

    pub struct VariantDef {
    name : String
    doc : String?
    }

    Enum variant definition.

    apply_case_style

    fn apply_case_style(s : String, style : String) -> String

    Apply a case style to a string. Supported styles: "snake" (no change), "camel", "pascal". For "snake", the input is returned as-is (assumed to already be snake_case).

    build_decode_body

    fn build_decode_body(fields : Array[FieldDef]) -> Array[Expr]

    Build the decode body using column name lookup (P0-063). Each getter call uses row.index_of("column_name") as the index argument, so column reordering does not break decoding.

    build_ir

    fn build_ir(req : AdaptRequest, renames : Array[(String, String)]) -> Array[InternalQuery]

    Convert an adapted request into IR queries.

    capitalize_first

    fn capitalize_first(s : String) -> String

    Capitalize the first ASCII lowercase character.

    convert_request

    fn convert_request(req : GenerateRequest) -> AdaptRequest raise

    Convert a raw GenerateRequest into the internal adapter model.

    decode_request

    fn decode_request(data : Bytes) -> GenerateRequest raise

    decode_response

    fn decode_response(data : Bytes) -> GenerateResponse

    default_runtime_alias

    fn default_runtime_alias() -> String

    Default runtime import alias used when plugin option is unset.

    emit_package_declaration

    fn emit_package_declaration(name : String) -> String

    Emit a package declaration line. Defaults to "main" when name is empty or whitespace-only.

    emit_source_file

    fn emit_source_file(file : SourceFile) -> String

    Emit a SourceFile to a formatted MoonBit source string.

    encode_request

    fn encode_request(req : GenerateRequest) -> Bytes

    encode_response

    fn encode_response(resp : GenerateResponse) -> Bytes

    escape_keyword

    fn escape_keyword(name : String) -> String

    Escape a MoonBit identifier that conflicts with a reserved keyword, built-in type, or built-in value by appending "_".

    Special case: "type" → "ty" (preserving existing convention from protobuf schema).

    The keyword set includes:
    • Reserved words: as, async, break, catch, continue, do, else, enum, extern, false, fn, for, if, impl, import, let, loop, match, mut, package, pub, raise, ref, return, struct, test, then, trait, true, try, type, var, while
    • Additional reserved: self, Self, abort, panic, priv, priv, pure
    • Built-in types: Int, Int64, Double, String, Bool, Char, Byte, Unit, Float, Array, Map, Option, Result
    • Built-in values: None, Some, Ok, Err

    generate_decode_fn

    fn generate_decode_fn(sd : StructDef) -> FnDef

    Generate a decode function for a StructDef using typed getters. Uses nested match instead of ? operator (not available in MoonBit 0.1). P0-063: Uses row.index_of("col_name") with original DB column name. Each field produces two nested match levels: one for index_of (Result[Int, DBError]) and one for the typed getter, so column reordering does not break decoding.

    generate_enum_from_enum

    fn generate_enum_from_enum(_name : String, vals : Array[String], comment : String, initialisms : Array[String], type_name : String) -> EnumDef

    Generate an EnumDef from a catalog enum with an optional pre-resolved type name.

    generate_query_fn

    fn generate_query_fn(query : InternalQuery, conn_name : String, conn_ty : TypeExpr, overrides : Array[(String, String)], nullable_overrides : Array[String], emit_sql_as_comment : Bool, _emit_methods_with_db_argument : Bool, emit_empty_slices : Bool, initialisms : Array[String]) -> FnDef

    Generate a single query function FnDef. emit_methods_with_db_argument is accepted for API compatibility with sqlc's other plugins. MoonBit 0.1 always generates standalone functions with DB as first param (see generate_query_fns).

    generate_query_fns

    fn generate_query_fns(queries : Array[InternalQuery], overrides : Array[(String, String)], nullable_overrides : Array[String], emit_sql_as_comment : Bool, emit_methods_with_db_argument : Bool, emit_empty_slices : Bool, initialisms : Array[String]) -> Array[TopLevel]

    Generate all query function TopLevel items from IR queries. Always generates a db: DB overload. Only generates a tx: Transaction overload for queries whose raw_cmd is supported by Transaction (One, Many, Exec, ExecRows).

    emit_methods_with_db_argument: The current codegen strategy always produces standalone functions with db: DB as the first parameter (e.g., pub fn query_list_users(db: DB) -> ...). This is the only feasible approach in MoonBit 0.1 since trait objects and method dispatch are not fully supported. Both true and false produce identical output — standalone functions with a DB argument. A future version might use fn DB::query_list_users() method receiver syntax when MoonBit supports it, at which point false could mean "emit as method on DB type". For now, the option is accepted for API compatibility with sqlc's other plugins but is a no-op.

    generate_source

    fn generate_source(req : GenerateRequest, opts : PluginOptions) -> String raise

    Run the full codegen pipeline: adapter �?IR �?type_gen �?query_gen �?emitter. Accepts parsed PluginOptions for codegen configuration (package_name, etc.).

    generate_sources

    fn generate_sources(req : GenerateRequest, opts : PluginOptions) -> Array[(String, String)] raise

    Run the full codegen pipeline: adapter → IR → type_gen → query_gen → emitter. Returns an array of (filename, source_content) pairs for multi-file output. Types (structs, enums, decode functions) go into "types.mbt". Query functions go into "queries.mbt".

    generate_struct_from_fields

    fn generate_struct_from_fields(type_name : String, fields : Array[InternalField], doc : String?, is_pub : Bool, emit_json_tags : Bool, emit_db_tags : Bool, overrides : Array[(String, String)], nullable_overrides : Array[String], json_tags_case_style : String, _initialisms : Array[String]) -> StructDef

    Generate a StructDef from a list of InternalFields. Each field is mapped through the type mapping layer with nullability handling.

    generate_struct_from_table

    fn generate_struct_from_table(table_name : String, columns : Array[AdaptColumn], comment : String, emit_json_tags : Bool, emit_db_tags : Bool, overrides : Array[(String, String)], column_overrides : Array[ColumnOverride], nullable_overrides : Array[String], renames : Array[(String, String)], emit_exact_table_names : Bool, json_tags_case_style : String, initialisms : Array[String], enum_renames : Array[(String, String)]) -> StructDef

    Generate a StructDef from a catalog table. When emit_exact_table_names=false (default), singularizes the table name before PascalCase.

    generate_types

    fn generate_types(catalog : AdaptCatalog, queries : Array[InternalQuery], adapt_queries : Array[AdaptQuery], emit_json_tags : Bool, emit_db_tags : Bool, overrides : Array[(String, String)], column_overrides : Array[ColumnOverride], nullable_overrides : Array[String], renames : Array[(String, String)], omit_unused_structs : Bool, emit_exact_table_names : Bool, json_tags_case_style : String, initialisms_str : String) -> Array[TopLevel]

    Generate all type definitions from both catalog and queries. Each struct is followed by its decode method.

    generate_types_from_catalog

    fn generate_types_from_catalog(catalog : AdaptCatalog, emit_json_tags : Bool, emit_db_tags : Bool, overrides : Array[(String, String)], column_overrides : Array[ColumnOverride], nullable_overrides : Array[String], renames : Array[(String, String)], omit_unused_structs : Bool, referenced_tables : Array[String], emit_exact_table_names : Bool, json_tags_case_style : String, initialisms : Array[String]) -> Array[TopLevel]

    Generate all type definitions from an AdaptCatalog. Produces StructDef for each table (with decode method) and EnumDef for every enum. When omit_unused_structs is true and referenced_tables is non-empty, only tables whose names appear in the referenced_tables list are included.

    generate_types_from_queries

    fn generate_types_from_queries(queries : Array[InternalQuery], emit_json_tags : Bool, emit_db_tags : Bool, overrides : Array[(String, String)], nullable_overrides : Array[String], json_tags_case_style : String, initialisms : Array[String]) -> Array[TopLevel]

    Generate struct definitions for query result types. Produces a StructDef (with decode method) for each query that has a Rows result shape. The struct is named <QueryName>Row in PascalCase.

    lowercase_first

    fn lowercase_first(s : String) -> String

    Lowercase the first ASCII uppercase character.

    make_all_types_request

    fn make_all_types_request() -> GenerateRequest

    Build a GenerateRequest covering all PG types for comprehensive golden tests. Includes bool, float8, bytea, date, timestamp, timestamptz, jsonb, numeric, uuid, inet, int2, float4, time, interval, varchar, and text array.

    make_array_types_request

    fn make_array_types_request() -> GenerateRequest

    Build a GenerateRequest covering array type columns (int[] and nullable text[]). Tests that is_array=true columns produce Array[T] types in generated code.

    make_commands_request

    fn make_commands_request() -> GenerateRequest

    Build a GenerateRequest exercising :execrows, :copyfrom, :batch, and :execlastid commands. Tests the command dispatch path through the full pipeline.

    make_enum_request

    fn make_enum_request() -> GenerateRequest

    Build a GenerateRequest with an enum type column in a table and query. Tests enum type codegen path through the full pipeline.

    make_keyword_test_request

    fn make_keyword_test_request() -> GenerateRequest

    Build a GenerateRequest for P0-065 keyword escape golden tests. Contains a column named "type" (MoonBit keyword) which must be escaped to "ty" in output.

    make_multi_table_request

    fn make_multi_table_request() -> GenerateRequest

    Build a GenerateRequest with multiple tables (users + posts) and a join query. Tests multi-table scenarios through the full pipeline.

    make_parameterized_request

    fn make_parameterized_request() -> GenerateRequest

    Build a GenerateRequest with parameter-only queries (no table columns in result). Tests the parameterized query codegen path.

    make_realistic_request

    fn make_realistic_request() -> GenerateRequest

    Build a GenerateRequest with realistic sqlc input types: bigserial, schema-qualified, array columns, and full type names like "timestamp with time zone".

    make_users_request

    fn make_users_request() -> GenerateRequest

    Build a realistic GenerateRequest for golden tests.

    map_internal_type

    fn map_internal_type(ir_type : InternalType, overrides : Array[(String, String)], enum_renames : Array[(String, String)]) -> TypeExpr

    Map an IR InternalType to a MoonBit TypeExpr. Handles Named types via the mapping table and Arr types recursively.

    map_internal_type_nullable

    fn map_internal_type_nullable(ir_type : InternalType, not_null : Bool, overrides : Array[(String, String)], nullable_overrides : Array[String], enum_renames : Array[(String, String)]) -> TypeExpr

    Map an IR InternalType to a MoonBit TypeExpr, considering nullability. When not_null is false, wraps in Option[...]. When not_null is true but the type is in nullable_overrides, also wraps in Option[...].

    map_pg_to_value_constructor_str

    fn map_pg_to_value_constructor_str(name : String) -> String

    Map a PG type name to the corresponding Value constructor name string. Returns the string name of the Value variant (e.g., "Int64", "Double", "String", etc.). This is the SINGLE source of truth for PG type → MoonBit Value constructor mapping. Normalizes input: case-insensitive (via to_lower), strips schema prefix.

    parse_initialisms

    fn parse_initialisms(s : String) -> Array[String]

    Parse a comma-separated list of initialisms into an array. e.g., "ID,URL,HTTP" → ["ID", "URL", "HTTP"]

    parse_plugin_options

    fn parse_plugin_options(data : Bytes) -> PluginOptions raise

    Parse plugin_options bytes into a PluginOptions struct. Returns defaults on empty data; warns on malformed or unknown options. Accepts sqlc JSON ({"package_name":"users"}) and legacy key=value lines.

    parse_query_cmd

    fn parse_query_cmd(cmd : String) -> QueryCmd raise

    Parse a sqlc cmd string into a QueryCmd. Unknown or empty cmd strings fail codegen (no silent :exec fallback).

    process_message

    fn process_message(data : Bytes) -> Bytes

    Process a raw protobuf GenerateRequest and return raw GenerateResponse bytes. Moonrun tests use this entry point; errors return an empty GenerateResponse. Production sqlc path uses process_message_outcome + stderr instead.

    Codec errors propagate via raise from decode_request and are caught here. abort() must not be used on decode paths (WASM trap bypasses catch).

    process_message_outcome

    fn process_message_outcome(data : Bytes) -> MessageOutcome

    Process a raw protobuf GenerateRequest and return success or error message. Used by the WASI I/O loop for sqlc-visible error reporting via stderr.

    qual_runtime_name

    fn qual_runtime_name(name : String) -> String

    Qualify a runtime type name for cross-package consumer compilation.

    qual_runtime_type

    fn qual_runtime_type(ty : TypeExpr) -> TypeExpr

    Recursively qualify runtime types in a TypeExpr AST node.

    runtime_db_err_no_rows_fn

    fn runtime_db_err_no_rows_fn() -> String

    runtime_db_err_too_many_rows_fn

    fn runtime_db_err_too_many_rows_fn() -> String

    runtime_exec_result_new_fn

    fn runtime_exec_result_new_fn() -> String

    runtime_null_value_fn

    fn runtime_null_value_fn() -> String

    set_runtime_alias

    fn set_runtime_alias(runtime_alias : String) -> Unit

    Set the runtime import alias for the current codegen pass (from PluginOptions.runtime_alias).

    singularize_table_name

    fn singularize_table_name(name : String) -> String

    Singularize a SQL table name for struct naming (default when emit_exact_table_names=false). Handles common English plural patterns; leaves ambiguous names (e.g. status) unchanged.

    snake_to_camel

    fn snake_to_camel(s : String, initialisms : Array[String]) -> String

    Convert snake_case to camelCase with initialism support.

    Callers should normalize input to lowercase before calling when case is unknown, to avoid mixed-case output like uSERNAME from all-caps input.

    snake_to_pascal

    fn snake_to_pascal(s : String, initialisms : Array[String]) -> String

    Convert snake_case to PascalCase with initialism support. e.g., "get_user_by_id" with initialisms=["ID","URL"] → "GetUserByID"

    Edge Case Behaviors (ADR-004 / P1-041)

    The conversion is a pure algorithmic mapping with the following known edge cases. These behaviors are intentionally preserved; callers should be aware of:

    InputOutputReason
    "user__name""UserName"Double underscore → empty split segment, silently dropped
    "_user""User"Leading underscore → empty first segment, dropped
    "user_name_""UserName"Trailing underscore → empty last segment, dropped
    "USER_NAME""USERNAME"All-caps input stays uppercase (capitalize_first is no-op on uppercase)
    "userName""UserName"No underscore → only first letter capitalized
    "user_name""UserName"Same output as "UserName" — collision risk
    "_"""Single underscore → two empty segments → empty string
    """UnnamedType"Empty input returns sentinel "UnnamedType"

    Collision warning: Different snake_case inputs can produce identical PascalCase output (e.g., "user_name" and "UserName" both → "UserName"). The naming layer does not detect or prevent collisions — higher-level codegen (e.g., generate_types_from_catalog) is responsible for avoiding conflicts (e.g., enum name vs struct name generating the same type).

    Enum/Struct collision: When a table and an enum share the same base name, generate_types_from_catalog disambiguates enums via StatusType suffix (P1-060).

    Empty input: Callers should ensure non-empty input; empty string returns sentinel "UnnamedType" which avoids collision with tables named 'empty'.

    table_struct_base_name

    fn table_struct_base_name(table_name : String, emit_exact_table_names : Bool) -> String

    Resolve catalog table name to MoonBit struct base (before PascalCase / keyword escape).

    table_struct_type_name

    fn table_struct_type_name(table_name : String, emit_exact_table_names : Bool, initialisms : Array[String]) -> String

    Resolve catalog table name to MoonBit struct type name.

    type_to_value_constructor

    fn type_to_value_constructor(ir_type : InternalType, overrides : Array[(String, String)]) -> String

    Map an IR InternalType to a Value constructor name, respecting overrides. If an override is found, returns the override target as the constructor name.

    unqual_runtime_name

    fn unqual_runtime_name(name : String) -> String

    Strip runtime alias prefix from a qualified type name for internal lookups.

    validate_codegen_type_names

    fn validate_codegen_type_names(catalog : AdaptCatalog, queries : Array[InternalQuery], adapt_queries : Array[AdaptQuery], omit_unused_structs : Bool, emit_exact_table_names : Bool, initialisms_str : String) -> Unit raise

    Detect duplicate or colliding MoonBit type names before codegen.

    validate_strict_types

    fn validate_strict_types(catalog : AdaptCatalog, queries : Array[AdaptQuery], overrides : Array[(String, String)], _strict_types : Bool) -> Unit raise

    Fail codegen on unknown PG types (override-aware). Always enforced.

    value_ctor_to_from_fn

    fn value_ctor_to_from_fn(ctor : String) -> String

    Map Value constructor label to a cross-package Value::from_* helper.