generator

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigManager

type ConfigManager struct {
	// contains filtered or unexported fields
}

ConfigManager manages configuration loading and validation

func GetGlobalConfigManager

func GetGlobalConfigManager() *ConfigManager

GetGlobalConfigManager returns the global configuration manager

func NewConfigManager

func NewConfigManager() *ConfigManager

NewConfigManager creates a new configuration manager

func (*ConfigManager) GetConfig

func (cm *ConfigManager) GetConfig() *UnifiedConfig

GetConfig returns the current configuration

func (*ConfigManager) Load

func (cm *ConfigManager) Load() (*UnifiedConfig, error)

Load loads configuration from defaults

type ConfigValidator

type ConfigValidator struct{}

ConfigValidator validates configuration values

func (*ConfigValidator) Validate

func (cv *ConfigValidator) Validate(config *UnifiedConfig) error

Validate validates the configuration

type ControllerConfig

type ControllerConfig struct {
	ResourceName string          `json:"resource_name"`
	PluralName   string          `json:"plural_name"`
	PackageName  string          `json:"package_name"`
	ModulePath   string          `json:"module_path"`
	Paths        ControllerPaths `json:"paths"`
}

type ControllerManager

type ControllerManager struct {
	// contains filtered or unexported fields
}

func NewControllerManager

func NewControllerManager(
	validator *InputValidator,
	projectManager *ProjectManager,
	migrationManager *MigrationManager,
	config *UnifiedConfig,
) *ControllerManager

func (*ControllerManager) GenerateController

func (c *ControllerManager) GenerateController(
	resourceName, tableName string,
	withViews bool,
) error

func (*ControllerManager) GenerateControllerFromModel

func (c *ControllerManager) GenerateControllerFromModel(resourceName string, withViews bool) error

type ControllerPaths

type ControllerPaths struct {
	Controllers string `json:"controllers"`
	Routes      string `json:"routes"`
}

type Coordinator

type Coordinator struct {
	ModelManager      *ModelManager
	ControllerManager *ControllerManager
	ViewManager       *ViewManager
	// contains filtered or unexported fields
}

func NewCoordinator

func NewCoordinator() (Coordinator, error)

func (*Coordinator) GenerateController

func (c *Coordinator) GenerateController(resourceName, tableName string, withViews bool) error

GenerateController coordinates controller and optional view generation

func (*Coordinator) GenerateControllerFromModel

func (c *Coordinator) GenerateControllerFromModel(resourceName string, withViews bool) error

GenerateControllerFromModel coordinates controller and optional view generation from existing model

type DatabaseConfig

type DatabaseConfig struct {
	Type          string   `yaml:"type"`
	MigrationDirs []string `yaml:"migration_dirs"`
	DefaultSchema string   `yaml:"default_schema"`
	Driver        string   `yaml:"driver"`
	Method        string   `yaml:"method"`
}

DatabaseConfig contains database-specific configuration

type FileConfig

type FileConfig struct {
	PrivatePermission os.FileMode `yaml:"private_permission"`
	DirPermission     os.FileMode `yaml:"dir_permission"`
}

FileConfig contains file-related configuration

type GenerationConfig

type GenerationConfig struct {
	GenerateJSON bool   `yaml:"generate_json"`
	OutputFormat string `yaml:"output_format"`
}

GenerationConfig contains code generation configuration

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func New

func New() (Generator, error)

func (*Generator) GenerateController

func (g *Generator) GenerateController(resourceName, tableName string, withViews bool) error

func (*Generator) GenerateControllerFromModel

func (g *Generator) GenerateControllerFromModel(resourceName string, withViews bool) error

func (*Generator) GenerateModel

func (g *Generator) GenerateModel(resourceName string, tableNameOverride string) error

func (*Generator) GenerateQueriesOnly added in v0.36.0

func (g *Generator) GenerateQueriesOnly(resourceName string, tableNameOverride string) error

func (*Generator) GenerateView

func (g *Generator) GenerateView(resourceName, tableName string) error

func (*Generator) GenerateViewFromModel

func (g *Generator) GenerateViewFromModel(resourceName string, withController bool) error

func (*Generator) RefreshConstructors

func (g *Generator) RefreshConstructors(resourceName, tableName string) error

func (*Generator) RefreshModel

func (g *Generator) RefreshModel(resourceName, tableName string) error

func (*Generator) RefreshQueries

func (g *Generator) RefreshQueries(resourceName, tableName string) error

func (*Generator) RefreshQueriesOnly added in v0.36.0

func (g *Generator) RefreshQueriesOnly(resourceName, tableName string, tableNameOverridden bool) error

type InputValidator

type InputValidator struct{}

func NewInputValidator

func NewInputValidator() *InputValidator

func (*InputValidator) ValidateAll

func (v *InputValidator) ValidateAll(resourceName, tableName, modulePath string) error

func (*InputValidator) ValidateFilePath

func (v *InputValidator) ValidateFilePath(filePath string) error

func (*InputValidator) ValidateModulePath

func (v *InputValidator) ValidateModulePath(modulePath string) error

func (*InputValidator) ValidateResourceName

func (v *InputValidator) ValidateResourceName(resourceName string) error

func (*InputValidator) ValidateTableName

func (v *InputValidator) ValidateTableName(tableName string) error

func (*InputValidator) ValidateTableNameOverride

func (v *InputValidator) ValidateTableNameOverride(resourceName, tableNameOverride string) error

type MigrationManager

type MigrationManager struct{}

func NewMigrationManager

func NewMigrationManager() *MigrationManager

func (*MigrationManager) BuildCatalogFromMigrations

func (mm *MigrationManager) BuildCatalogFromMigrations(
	tableName string,
	config *UnifiedConfig,
) (*catalog.Catalog, error)

type ModelConfig

type ModelConfig struct {
	TableName    string           `json:"table_name"`
	ResourceName string           `json:"resource_name"`
	PackageName  string           `json:"package_name"`
	DatabaseType string           `json:"database_type"`
	ModulePath   string           `json:"module_path"`
	Paths        ModelPaths       `json:"paths"`
	Generation   GenerationConfig `json:"generation"`
}

type ModelManager

type ModelManager struct {
	// contains filtered or unexported fields
}

func NewModelManager

func NewModelManager(
	validator *InputValidator,
	fileManager files.Manager,
	modelGenerator *models.Generator,
	projectManager *ProjectManager,
	migrationManager *MigrationManager,
	config *UnifiedConfig,
) *ModelManager

func (*ModelManager) GenerateModel

func (m *ModelManager) GenerateModel(resourceName string, tableNameOverride string) error

func (*ModelManager) GenerateQueriesOnly added in v0.36.0

func (m *ModelManager) GenerateQueriesOnly(resourceName string, tableNameOverride string) error

func (*ModelManager) RefreshConstructors

func (m *ModelManager) RefreshConstructors(resourceName, tableName string) error

func (*ModelManager) RefreshModel

func (m *ModelManager) RefreshModel(resourceName, tableName string) error

func (*ModelManager) RefreshQueries

func (m *ModelManager) RefreshQueries(resourceName, tableName string) error

func (*ModelManager) RefreshQueriesOnly added in v0.36.0

func (m *ModelManager) RefreshQueriesOnly(resourceName, tableName string, tableNameOverridden bool) error

type ModelPaths

type ModelPaths struct {
	Models  string `json:"models"`
	Queries string `json:"queries"`
}

type PathConfig

type PathConfig struct {
	Models      string `yaml:"models"`
	Controllers string `yaml:"controllers"`
	Views       string `yaml:"views"`
	Routes      string `yaml:"routes"`
	Queries     string `yaml:"queries"`
	Migrations  string `yaml:"migrations"`
	Database    string `yaml:"database"`
}

PathConfig contains path configurations

type ProjectConfig

type ProjectConfig struct {
	Name        string `yaml:"name"`
	ModulePath  string `yaml:"module_path"`
	PackageName string `yaml:"package_name"`
}

ProjectConfig contains project-specific configuration

type ProjectManager

type ProjectManager struct {
	// contains filtered or unexported fields
}

func NewProjectManager

func NewProjectManager() (*ProjectManager, error)

func (*ProjectManager) GetModulePath

func (pm *ProjectManager) GetModulePath() string

type SQLCConfig

type SQLCConfig struct {
	SQL []SQLConfig `yaml:"sql"`
}

SQLCConfig for reading sqlc.yaml files

type SQLConfig

type SQLConfig struct {
	Engine string `yaml:"engine"`
}

type TemplateConfig

type TemplateConfig struct {
	CacheEnabled bool `yaml:"cache_enabled"`
	CacheTTL     int  `yaml:"cache_ttl"`
}

TemplateConfig contains template-related configuration

type UnifiedConfig

type UnifiedConfig struct {
	Database   DatabaseConfig   `yaml:"database"`
	Paths      PathConfig       `yaml:"paths"`
	Templates  TemplateConfig   `yaml:"templates"`
	Files      FileConfig       `yaml:"files"`
	Project    ProjectConfig    `yaml:"project"`
	Generation GenerationConfig `yaml:"generation"`
}

UnifiedConfig represents the single source of truth for all configuration

func GetGlobalConfig

func GetGlobalConfig() *UnifiedConfig

GetGlobalConfig returns the global configuration

func (*UnifiedConfig) GetControllerConfig

func (uc *UnifiedConfig) GetControllerConfig() ControllerConfig

GetControllerConfig returns configuration for controller generation

func (*UnifiedConfig) GetModelConfig

func (uc *UnifiedConfig) GetModelConfig() ModelConfig

GetModelConfig returns configuration for model generation

func (*UnifiedConfig) GetViewConfig

func (uc *UnifiedConfig) GetViewConfig() ViewConfig

GetViewConfig returns configuration for view generation

type ViewConfig

type ViewConfig struct {
	ResourceName string    `json:"resource_name"`
	PluralName   string    `json:"plural_name"`
	ModulePath   string    `json:"module_path"`
	Paths        ViewPaths `json:"paths"`
}

type ViewManager

type ViewManager struct {
	// contains filtered or unexported fields
}

func NewViewManager

func NewViewManager(
	validator *InputValidator,
	projectManager *ProjectManager,
	migrationManager *MigrationManager,
	viewGenerator *views.Generator,
	config *UnifiedConfig,
) *ViewManager

func (*ViewManager) GenerateView

func (v *ViewManager) GenerateView(resourceName, tableName string) error

func (*ViewManager) GenerateViewFromModel

func (v *ViewManager) GenerateViewFromModel(resourceName string, withController bool) error

func (*ViewManager) GenerateViewWithController

func (v *ViewManager) GenerateViewWithController(resourceName, tableName string) error

type ViewPaths

type ViewPaths struct {
	Views string `json:"views"`
}

Directories

Path Synopsis
internal
ddl

Jump to

Keyboard shortcuts

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