Documentation
¶
Index ¶
- func BuildModelPath(modelsDir, resourceName string) string
- func ExtractTableNameOverride(modelPath string, resourceName string) (string, bool)
- func ResolveTableName(modelsDir, queriesDir, resourceName string) string
- func ResolveTableNameWithFlag(modelsDir, queriesDir, resourceName string) (string, bool)
- type ConfigManager
- type ConfigValidator
- type ControllerConfig
- type ControllerManager
- type ControllerPaths
- type Coordinator
- type DatabaseConfig
- type FileConfig
- type FragmentConfig
- type FragmentManager
- type GenerationConfig
- type Generator
- func (g *Generator) GenerateController(resourceName, tableName string, withViews bool) error
- func (g *Generator) GenerateControllerFromModel(resourceName string, withViews bool) error
- func (g *Generator) GenerateFragment(config FragmentConfig) error
- func (g *Generator) GenerateModel(resourceName string, tableNameOverride string, skipFactory bool) error
- func (g *Generator) GenerateQueriesOnly(tableName string) error
- func (g *Generator) GenerateView(resourceName, tableName string) error
- func (g *Generator) GenerateViewFromModel(resourceName string, withController bool) error
- func (g *Generator) GetModulePath() string
- func (g *Generator) RefreshQueries(resourceName, tableName string) error
- func (g *Generator) RefreshQueriesOnly(tableName string) error
- type InputValidator
- func (v *InputValidator) ValidateAll(resourceName, tableName, modulePath string) error
- func (v *InputValidator) ValidateFilePath(filePath string) error
- func (v *InputValidator) ValidateModulePath(modulePath string) error
- func (v *InputValidator) ValidateResourceName(resourceName string) error
- func (v *InputValidator) ValidateTableName(tableName string) error
- func (v *InputValidator) ValidateTableNameOverride(resourceName, tableNameOverride string) error
- type MigrationManager
- type ModelConfig
- type ModelManager
- func (m *ModelManager) GenerateModel(resourceName string, tableNameOverride string, skipFactory bool) error
- func (m *ModelManager) GenerateQueriesOnly(tableName string) error
- func (m *ModelManager) RefreshQueries(resourceName, tableName string) error
- func (m *ModelManager) RefreshQueriesOnly(tableName string) error
- type ModelPaths
- type PathConfig
- type ProjectConfig
- type ProjectManager
- type SQLCConfig
- type SQLConfig
- type TemplateConfig
- type UnifiedConfig
- type ViewConfig
- type ViewManager
- type ViewPaths
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildModelPath ¶ added in v0.37.2
func ExtractTableNameOverride ¶ added in v0.37.2
func ResolveTableName ¶ added in v0.37.2
func ResolveTableNameWithFlag ¶ added in v0.37.2
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 Coordinator ¶
type Coordinator struct {
ModelManager *ModelManager
ControllerManager *ControllerManager
ViewManager *ViewManager
FragmentManager *FragmentManager
// 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 FragmentConfig ¶
type FragmentConfig struct {
ControllerName string // PascalCase, e.g. "Webhook"
MethodName string // PascalCase, e.g. "Validate"
Path string // Route path, e.g. "/validate" or "/:id/approve"
HTTPMethod string // HTTP method, e.g. "GET", "POST"
}
FragmentConfig holds the input configuration for fragment generation.
type FragmentManager ¶
type FragmentManager struct {
// contains filtered or unexported fields
}
FragmentManager orchestrates fragment generation across controller, routes, and connect files.
func NewFragmentManager ¶
func NewFragmentManager() *FragmentManager
NewFragmentManager creates a new FragmentManager.
func (*FragmentManager) GenerateFragment ¶
func (fm *FragmentManager) GenerateFragment(config FragmentConfig) error
GenerateFragment validates inputs, resolves naming, and delegates to FragmentInjector for the three file modifications.
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 (*Generator) GenerateController ¶
func (*Generator) GenerateControllerFromModel ¶
func (*Generator) GenerateFragment ¶
func (g *Generator) GenerateFragment(config FragmentConfig) error
func (*Generator) GenerateModel ¶
func (*Generator) GenerateQueriesOnly ¶ added in v0.36.0
func (*Generator) GenerateView ¶
func (*Generator) GenerateViewFromModel ¶
func (*Generator) GetModulePath ¶ added in v1.0.0
func (*Generator) RefreshQueries ¶
func (*Generator) RefreshQueriesOnly ¶ added in v0.36.0
type InputValidator ¶
type InputValidator struct {
// contains filtered or unexported fields
}
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, skipFactory bool, ) error
func (*ModelManager) GenerateQueriesOnly ¶ added in v0.36.0
func (m *ModelManager) GenerateQueriesOnly(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(tableName string) error
type ModelPaths ¶
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 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 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