config

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config loads and validates the db-catalyst configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Enabled bool
	Dir     string
}

Cache is the normalized cache configuration forwarded to the pipeline.

type CacheConfig

type CacheConfig struct {
	Enabled bool   `toml:"enabled"`
	Dir     string `toml:"dir"`
}

CacheConfig captures caching configuration for incremental builds.

type ColumnOverride

type ColumnOverride struct {
	Column string `toml:"column"`
	GoType any    `toml:"go_type"` // Can be string or complex object
}

ColumnOverride defines column-specific type overrides (sqlc compatibility).

type Config

type Config struct {
	Package         string                `toml:"package"`
	Out             string                `toml:"out"`
	Language        Language              `toml:"language"`
	Database        Database              `toml:"database"`
	SQLiteDriver    Driver                `toml:"sqlite_driver"`
	Schemas         []string              `toml:"schemas"`
	Queries         []string              `toml:"queries"`
	CustomTypes     CustomTypesConfig     `toml:"custom_types"`
	Generation      GenerationOptions     `toml:"generation"`
	PreparedQueries PreparedQueriesConfig `toml:"prepared_queries"`
	Cache           CacheConfig           `toml:"cache"`
}

Config mirrors the expected db-catalyst TOML schema.

type CustomTypeMapping

type CustomTypeMapping struct {
	CustomType string `toml:"custom_type"`
	SQLiteType string `toml:"sqlite_type"`
	GoType     string `toml:"go_type"`
	GoImport   string `toml:"go_import"`
	GoPackage  string `toml:"go_package"`
	Pointer    bool   `toml:"pointer"`
}

CustomTypeMapping defines how a custom type maps to SQLite and Go types.

type CustomTypesConfig

type CustomTypesConfig struct {
	Mappings []CustomTypeMapping `toml:"mapping"`
}

CustomTypesConfig captures custom type mappings.

type Database

type Database string

Database identifies the target database dialect.

const (
	// DatabaseSQLite targets SQLite.
	DatabaseSQLite Database = "sqlite"
	// DatabasePostgreSQL targets PostgreSQL.
	DatabasePostgreSQL Database = "postgresql"
	// DatabaseMySQL targets MySQL.
	DatabaseMySQL Database = "mysql"
)

type DatabaseTypeOverride

type DatabaseTypeOverride struct {
	DatabaseType string `toml:"db_type"`
	GoType       string `toml:"go_type"`
}

DatabaseTypeOverride defines db_type to go_type mappings (sqlc compatibility).

type Driver

type Driver string

Driver identifies the SQLite driver implementation to target.

const (
	// DriverModernC targets modernc.org/sqlite.
	DriverModernC Driver = "modernc"
	// DriverMattN targets github.com/mattn/go-sqlite3.
	DriverMattN Driver = "mattn"
)

type GenerationOptions

type GenerationOptions struct {
	EmitEmptySlices     bool   `toml:"emit_empty_slices"`
	EmitPreparedQueries bool   `toml:"emit_prepared_queries"`
	EmitJSONTags        bool   `toml:"emit_json_tags"`
	EmitPointersForNull bool   `toml:"emit_pointers_for_null"`
	SQLDialect          string `toml:"sql_dialect"`
}

GenerationOptions captures additional generation options.

type GoTypeDetails

type GoTypeDetails struct {
	Import  string `toml:"import"`
	Package string `toml:"package"`
	Type    string `toml:"type"`
	Pointer bool   `toml:"pointer"`
}

GoTypeDetails captures complex go_type configuration (sqlc compatibility).

type JobPlan

type JobPlan struct {
	Package             string
	Out                 string
	Language            Language
	Database            Database
	SQLiteDriver        Driver
	Schemas             []string
	Queries             []string
	CustomTypes         []CustomTypeMapping
	EmitJSONTags        bool
	EmitPointersForNull bool
	PreparedQueries     PreparedQueries
	SQLDialect          string
	Cache               Cache
}

JobPlan is the fully-resolved configuration used by downstream stages.

type Language

type Language string

Language identifies the target programming language for code generation.

const (
	// LanguageGo generates Go code.
	LanguageGo Language = "go"
	// LanguageRust generates Rust code.
	LanguageRust Language = "rust"
	// LanguageTypeScript generates TypeScript code.
	LanguageTypeScript Language = "typescript"
)

type LoadOptions

type LoadOptions struct {
	Strict   bool
	Resolver *fileset.Resolver
	// Logger receives warning messages. If nil, warnings are only added to Result.Warnings.
	Logger logging.Logger
}

LoadOptions tunes config loading behavior.

type OverridesConfig

type OverridesConfig struct {
	DatabaseTypes []DatabaseTypeOverride `toml:"overrides"`
	Columns       []ColumnOverride       `toml:"overrides"`
}

OverridesConfig captures sqlc-style overrides.

type PreparedQueries

type PreparedQueries struct {
	Enabled         bool
	Metrics         bool
	ThreadSafe      bool
	EmitEmptySlices bool
}

PreparedQueries is the normalized configuration forwarded to the pipeline.

type PreparedQueriesConfig

type PreparedQueriesConfig struct {
	Enabled         bool `toml:"enabled"`
	Metrics         bool `toml:"metrics"`
	ThreadSafe      bool `toml:"thread_safe"`
	EmitEmptySlices bool `toml:"emit_empty_slices"`
}

PreparedQueriesConfig captures optional prepared statement generation settings.

type Result

type Result struct {
	Plan     JobPlan
	Warnings []string
}

Result wraps a loaded job plan alongside any non-fatal warnings.

func Load

func Load(path string, opts LoadOptions) (Result, error)

Load reads, validates, and resolves a db-catalyst configuration file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL