Documentation
¶
Index ¶
- func BuildModelPath(modelsDir, resourceName string) string
- func ExtractTableNameOverride(modelPath string, resourceName string) (string, bool)
- func ReadDIMode() string
- func ReadInertia() string
- func ReadNullType() string
- func ResolveTableName(modelsDir, resourceName string) string
- func ResolveTableNameWithFlag(modelsDir, resourceName string) (string, bool)
- type ConfigManager
- type ConfigValidator
- type ControllerConfig
- type ControllerManager
- func (c *ControllerManager) GenerateController(resourceName, tableName string, withViews bool, inertia string) error
- func (c *ControllerManager) GenerateControllerFromModel(resourceName string, withViews bool) error
- func (c *ControllerManager) GenerateControllerWithActions(resourceName, tableName string, withViews bool, actions []string, ...) error
- func (c *ControllerManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
- type ControllerPaths
- type Coordinator
- func (c *Coordinator) GenerateController(resourceName, tableName string, withViews bool, inertia string) error
- func (c *Coordinator) GenerateControllerFromModel(resourceName string, withViews bool) error
- func (c *Coordinator) GenerateControllerWithActions(resourceName, tableName string, withViews bool, actions []string, ...) error
- type DatabaseConfig
- type DefaultPrimaryKeyResolver
- type FileConfig
- type FragmentConfig
- type FragmentManager
- type GenerationConfig
- type Generator
- func (g *Generator) ApplyModelUpdate(result *UpdateModelResult) error
- func (g *Generator) GenerateController(resourceName, tableName string, withViews bool, inertia string) error
- func (g *Generator) GenerateControllerFromModel(resourceName string, withViews bool) error
- func (g *Generator) GenerateControllerWithActions(resourceName, tableName string, withViews bool, actions []string, ...) error
- func (g *Generator) GenerateFragment(config FragmentConfig) error
- func (g *Generator) GenerateModel(resourceName string, tableNameOverride string, skipFactory bool) error
- func (g *Generator) GenerateModelWithPK(resourceName string, tableNameOverride string, skipFactory bool, ...) 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) SetControllerPKResolver(resolver PrimaryKeyResolver)
- func (g *Generator) UpdateModel(resourceName string) (*UpdateModelResult, 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) ApplyModelUpdate(result *UpdateModelResult) error
- func (m *ModelManager) GenerateModel(resourceName string, tableNameOverride string, skipFactory bool, ...) error
- func (m *ModelManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
- func (m *ModelManager) UpdateModel(resourceName string) (*UpdateModelResult, error)
- type ModelPaths
- type NopPrimaryKeyResolver
- type PathConfig
- type PrimaryKeyInfo
- type PrimaryKeyResolver
- type ProjectConfig
- type ProjectManager
- type TemplateConfig
- type UnifiedConfig
- type UpdateModelResult
- type ViewConfig
- type ViewManager
- func (v *ViewManager) GenerateView(resourceName, tableName string) error
- func (v *ViewManager) GenerateViewFromModel(resourceName string, withController bool) error
- func (v *ViewManager) GenerateViewWithController(resourceName, tableName string, inertia string) error
- func (v *ViewManager) GenerateViewWithControllerActions(resourceName, tableName string, actions []string, inertia string) error
- 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
ExtractTableNameOverride reads the actual table name from the bun.BaseModel tag in the generated entity struct. e.g.: bun.BaseModel `bun:"table:student_feedback"`
func ReadDIMode ¶
func ReadDIMode() string
ReadDIMode reads the DI mode strategy from andurel.lock. Defaults to "manual" when not configured.
func ReadInertia ¶ added in v1.0.0
func ReadInertia() string
ReadInertia reads the inertia adapter from andurel.lock. Returns "" when not configured (templ-only mode).
func ReadNullType ¶ added in v1.0.0
func ReadNullType() string
ReadNullType reads the nullable type strategy from andurel.lock. Defaults to "sql.Null" when not configured.
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, inertia string, ) error
func (*ControllerManager) GenerateControllerFromModel ¶
func (c *ControllerManager) GenerateControllerFromModel(resourceName string, withViews bool) error
func (*ControllerManager) GenerateControllerWithActions ¶ added in v1.0.0
func (*ControllerManager) SetPrimaryKeyResolver ¶ added in v1.0.0
func (c *ControllerManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
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, inertia string) 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
func (*Coordinator) GenerateControllerWithActions ¶ added in v1.0.0
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 DefaultPrimaryKeyResolver ¶ added in v1.0.0
type DefaultPrimaryKeyResolver struct{}
func (DefaultPrimaryKeyResolver) ConfirmNoPK ¶ added in v1.0.0
func (DefaultPrimaryKeyResolver) ConfirmNoPK(tableName string) (bool, error)
func (DefaultPrimaryKeyResolver) ResolveAlternatePK ¶ added in v1.0.0
func (DefaultPrimaryKeyResolver) ResolveAlternatePK(info PrimaryKeyInfo, tableName string) (PrimaryKeyInfo, error)
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) ApplyModelUpdate ¶ added in v1.0.0
func (g *Generator) ApplyModelUpdate(result *UpdateModelResult) error
func (*Generator) GenerateController ¶
func (*Generator) GenerateControllerFromModel ¶
func (*Generator) GenerateControllerWithActions ¶ added in v1.0.0
func (*Generator) GenerateFragment ¶
func (g *Generator) GenerateFragment(config FragmentConfig) error
func (*Generator) GenerateModel ¶
func (*Generator) GenerateModelWithPK ¶ added in v1.0.0
func (*Generator) GenerateView ¶
func (*Generator) GenerateViewFromModel ¶
func (*Generator) GetModulePath ¶ added in v1.0.0
func (*Generator) SetControllerPKResolver ¶ added in v1.0.0
func (g *Generator) SetControllerPKResolver(resolver PrimaryKeyResolver)
func (*Generator) UpdateModel ¶ added in v1.0.0
func (g *Generator) UpdateModel(resourceName string) (*UpdateModelResult, error)
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) ApplyModelUpdate ¶ added in v1.0.0
func (m *ModelManager) ApplyModelUpdate(result *UpdateModelResult) error
ApplyModelUpdate writes the updated file content and runs the Go formatter.
func (*ModelManager) GenerateModel ¶
func (*ModelManager) SetPrimaryKeyResolver ¶ added in v1.0.0
func (m *ModelManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
func (*ModelManager) UpdateModel ¶ added in v1.0.0
func (m *ModelManager) UpdateModel(resourceName string) (*UpdateModelResult, error)
UpdateModel inspects the existing model file for resourceName, rebuilds the Entity struct from migrations (preserving custom field types), and returns a result describing the change without writing anything.
type ModelPaths ¶
type ModelPaths struct {
Models string `json:"models"`
}
type NopPrimaryKeyResolver ¶ added in v1.0.0
type NopPrimaryKeyResolver struct{}
func (NopPrimaryKeyResolver) ConfirmNoPK ¶ added in v1.0.0
func (NopPrimaryKeyResolver) ConfirmNoPK(_ string) (bool, error)
func (NopPrimaryKeyResolver) ResolveAlternatePK ¶ added in v1.0.0
func (NopPrimaryKeyResolver) ResolveAlternatePK(info PrimaryKeyInfo, _ string) (PrimaryKeyInfo, error)
type PathConfig ¶
type PathConfig struct {
Models string `yaml:"models"`
Controllers string `yaml:"controllers"`
Views string `yaml:"views"`
Routes string `yaml:"routes"`
Migrations string `yaml:"migrations"`
Database string `yaml:"database"`
}
PathConfig contains path configurations
type PrimaryKeyInfo ¶ added in v1.0.0
type PrimaryKeyInfo struct {
ColumnName string // SQL column name (e.g., "id", "user_id")
GoFieldName string // Go struct field name (e.g., "ID", "UserID")
DataType string // SQL data type (e.g., "uuid", "bigint")
GoType string // Go type (e.g., "uuid.UUID", "int64")
IsAutoIncrement bool
Found bool
IsNamedID bool // Whether the PK column is named "id"
}
func DetectPrimaryKey ¶ added in v1.0.0
func DetectPrimaryKey(cat *catalog.Catalog, tableName string) PrimaryKeyInfo
type PrimaryKeyResolver ¶ added in v1.0.0
type PrimaryKeyResolver interface {
ResolveAlternatePK(info PrimaryKeyInfo, tableName string) (PrimaryKeyInfo, error)
ConfirmNoPK(tableName string) (bool, error)
}
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 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 UpdateModelResult ¶ added in v1.0.0
type UpdateModelResult struct {
OldStruct string
NewStruct string
OldFileContent string
NewFileContent string
ModelPath string
HasChanges bool
}
UpdateModelResult holds the before/after state for a model update.
func (*UpdateModelResult) Diff ¶ added in v1.0.0
func (r *UpdateModelResult) Diff() (string, error)
Diff returns a unified diff of the struct definitions and method bodies (Entity, CreateData, UpdateData, Create, Update, Upsert). bun.BaseModel lines are excluded — their alignment changes with field widths and is not schema content.
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, inertia string) error
func (*ViewManager) GenerateViewWithControllerActions ¶ added in v1.0.0
func (v *ViewManager) GenerateViewWithControllerActions(resourceName, tableName string, actions []string, inertia string) error