cquill/codegen/generator
Types
Result of generating a module
pub type GeneratedModule {
GeneratedModule(
path: String,
filename: String,
content: String,
)
}
Constructors
-
GeneratedModule(path: String, filename: String, content: String)Arguments
- path
-
Module path (e.g., “db/schema/user”)
- filename
-
File name (e.g., “user.gleam”)
- content
-
Generated source code
Configuration for code generation
pub type GeneratorConfig {
GeneratorConfig(
module_prefix: String,
include_timestamps: Bool,
timestamp_fields: List(String),
generate_decoders: Bool,
generate_encoders: Bool,
generate_typed: Bool,
)
}
Constructors
-
GeneratorConfig( module_prefix: String, include_timestamps: Bool, timestamp_fields: List(String), generate_decoders: Bool, generate_encoders: Bool, generate_typed: Bool, )Arguments
- module_prefix
-
Module prefix for generated files (e.g., “db” -> “db/schema/user”)
- include_timestamps
-
Whether to include timestamp fields (inserted_at, updated_at)
- timestamp_fields
-
Names of timestamp fields to treat as auto-generated
- generate_decoders
-
Whether to generate decoders
- generate_encoders
-
Whether to generate encoders
- generate_typed
-
Whether to generate typed columns for the query builder
Values
pub fn default_config() -> GeneratorConfig
Create a default generator configuration
pub fn generate_all(
tables: List(introspection.IntrospectedTable),
enums: List(introspection.IntrospectedEnum),
config: GeneratorConfig,
) -> List(GeneratedModule)
Generate all modules for a complete schema
pub fn generate_enum_module(
enums: List(introspection.IntrospectedEnum),
config: GeneratorConfig,
) -> GeneratedModule
Generate the enum module containing all enum types
pub fn generate_index_module(
tables: List(introspection.IntrospectedTable),
enums: List(introspection.IntrospectedEnum),
config: GeneratorConfig,
) -> GeneratedModule
Generate the index module that re-exports all schemas
pub fn generate_schema_module(
table: introspection.IntrospectedTable,
enums: List(introspection.IntrospectedEnum),
config: GeneratorConfig,
) -> GeneratedModule
Generate a complete schema module for a table
pub fn generate_typed_index_module(
tables: List(introspection.IntrospectedTable),
config: GeneratorConfig,
) -> GeneratedModule
Generate the typed index module that re-exports all typed table modules
pub fn generate_typed_module(
table: introspection.IntrospectedTable,
enums: List(introspection.IntrospectedEnum),
config: GeneratorConfig,
) -> GeneratedModule
Generate a typed column module for a table Creates phantom types and typed column constants for compile-time safety
pub fn module_file_path(module: GeneratedModule) -> String
Get the full file path for a generated module
pub fn with_module_prefix(
config: GeneratorConfig,
prefix: String,
) -> GeneratorConfig
Create a generator configuration with a custom module prefix
pub fn with_timestamp_fields(
config: GeneratorConfig,
fields: List(String),
) -> GeneratorConfig
Set timestamp fields for a configuration
pub fn with_typed_columns(
config: GeneratorConfig,
enabled: Bool,
) -> GeneratorConfig
Enable or disable typed column generation