Documentation
¶
Overview ¶
Package generator orchestrates model, controller, view, and scaffold generation.
Index ¶
- func BuildModelPath(modelsDir, resourceName string) string
- func ExtractTableNameOverride(modelPath string, resourceName string) (string, bool)
- func ReadInertia() string
- func ReadNullType() string
- func ResolveTableName(modelsDir, resourceName string) string
- func ResolveTableNameWithFlag(modelsDir, resourceName string) (string, bool)
- type ActionConfig
- type ActionManager
- type ConfigManager
- type ConfigValidator
- type ControllerConfig
- type ControllerManager
- func (c *ControllerManager) GenerateController(resourceName, namespace string, inertia string) error
- func (c *ControllerManager) GenerateControllerFromModel(resourceName string) error
- func (c *ControllerManager) GenerateControllerWithActions(resourceName, namespace string, actions []string, inertia string) error
- func (c *ControllerManager) GenerateControllerWithActionsForModel(resourceName, namespace, modelName, tableName string, actions []string, ...) error
- func (c *ControllerManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
- type ControllerPaths
- type Coordinator
- func (c *Coordinator) GenerateController(resourceName, namespace, tableName string, inertia string, isAPI bool) error
- func (c *Coordinator) GenerateControllerFromModel(resourceName string) error
- func (c *Coordinator) GenerateControllerWithActions(resourceName, namespace, tableName string, actions []string, inertia string, ...) error
- func (c *Coordinator) GenerateControllerWithActionsForModel(resourceName, namespace, modelName, tableName string, actions []string, ...) error
- func (c *Coordinator) GenerateScaffold(resourceName, namespace, tableName string, skipFactory bool, ...) error
- type DatabaseConfig
- type DefaultPrimaryKeyResolver
- type FactorySyncOptions
- type FactorySyncResult
- type FileConfig
- type GenerationConfig
- type Generator
- func (g *Generator) ApplyModelUpdate(result *UpdateModelResult) error
- func (g *Generator) GenerateAction(config ActionConfig) error
- func (g *Generator) GenerateController(resourceName, namespace, tableName string, inertia string, isAPI bool) error
- func (g *Generator) GenerateControllerFromModel(resourceName string) error
- func (g *Generator) GenerateControllerWithActions(resourceName, namespace, tableName string, actions []string, inertia string, ...) error
- func (g *Generator) GenerateControllerWithActionsForModel(resourceName, namespace, modelName, tableName string, actions []string, ...) 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) GenerateScaffold(resourceName, namespace, tableName string, skipFactory bool, ...) error
- func (g *Generator) GenerateView(resourceName, tableName, namespace 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) SyncFactories(opts FactorySyncOptions) ([]*FactorySyncResult, error)
- func (g *Generator) SyncFactory(resourceName string, opts FactorySyncOptions) (*FactorySyncResult, error)
- 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) SyncFactories(opts FactorySyncOptions) ([]*FactorySyncResult, error)
- func (m *ModelManager) SyncFactory(resourceName string, opts FactorySyncOptions) (*FactorySyncResult, error)
- 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, namespace string) error
- func (v *ViewManager) GenerateViewFromModel(resourceName string, withController bool) error
- func (v *ViewManager) GenerateViewWithControllerActions(resourceName, tableName string, namespace string, actions []string, ...) error
- func (v *ViewManager) GenerateViewWithControllerActionsForModel(resourceName, modelName, tableName string, namespace string, actions []string, ...) error
- type ViewPaths
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildModelPath ¶ added in v0.37.2
BuildModelPath performs build model path.
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 ReadInertia ¶ added in v1.0.0
func ReadInertia() string
ReadInertia reads the configured Inertia adapter from andurel.lock. It returns "" when Inertia is not configured.
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
ResolveTableName resolves table name.
func ResolveTableNameWithFlag ¶ added in v0.37.2
ResolveTableNameWithFlag resolves table name with flag.
Types ¶
type ActionConfig ¶ added in v1.0.0
type ActionConfig 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"
}
ActionConfig holds the input configuration for action generation.
type ActionManager ¶ added in v1.0.0
type ActionManager struct {
// contains filtered or unexported fields
}
ActionManager orchestrates action generation across controller and route files.
func NewActionManager ¶ added in v1.0.0
func NewActionManager() *ActionManager
NewActionManager creates a new ActionManager.
func (*ActionManager) GenerateAction ¶ added in v1.0.0
func (am *ActionManager) GenerateAction(config ActionConfig) error
GenerateAction validates inputs, resolves naming, and delegates to ActionInjector for controller and route file modifications.
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"`
}
ControllerConfig configures controller.
type ControllerManager ¶
type ControllerManager struct {
// contains filtered or unexported fields
}
ControllerManager coordinates controller operations.
func NewControllerManager ¶
func NewControllerManager( validator *InputValidator, projectManager *ProjectManager, migrationManager *MigrationManager, config *UnifiedConfig, ) *ControllerManager
NewControllerManager creates a new controller manager.
func (*ControllerManager) GenerateController ¶
func (c *ControllerManager) GenerateController( resourceName, namespace string, inertia string, ) error
GenerateController generates a resource controller using default actions.
func (*ControllerManager) GenerateControllerFromModel ¶
func (c *ControllerManager) GenerateControllerFromModel(resourceName string) error
GenerateControllerFromModel generates a controller by inspecting an existing model file.
func (*ControllerManager) GenerateControllerWithActions ¶ added in v1.0.0
func (c *ControllerManager) GenerateControllerWithActions( resourceName, namespace string, actions []string, inertia string, ) error
GenerateControllerWithActions generates a resource controller for selected actions.
func (*ControllerManager) GenerateControllerWithActionsForModel ¶ added in v1.0.0
func (c *ControllerManager) GenerateControllerWithActionsForModel( resourceName, namespace, modelName, tableName string, actions []string, inertia string, isAPI bool, ) error
GenerateControllerWithActionsForModel generates a controller when resource and model names differ.
func (*ControllerManager) SetPrimaryKeyResolver ¶ added in v1.0.0
func (c *ControllerManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
SetPrimaryKeyResolver sets primary key resolver.
type ControllerPaths ¶
type ControllerPaths struct {
Controllers string `json:"controllers"`
Routes string `json:"routes"`
}
ControllerPaths represents controller paths.
type Coordinator ¶
type Coordinator struct {
ModelManager *ModelManager
ControllerManager *ControllerManager
ViewManager *ViewManager
ActionManager *ActionManager
// contains filtered or unexported fields
}
Coordinator wires the managers that implement high-level generation workflows.
func NewCoordinator ¶
func NewCoordinator() (Coordinator, error)
NewCoordinator creates a new coordinator.
func (*Coordinator) GenerateController ¶
func (c *Coordinator) GenerateController(resourceName, namespace, tableName string, inertia string, isAPI bool) error
GenerateController coordinates controller and optional view generation
func (*Coordinator) GenerateControllerFromModel ¶
func (c *Coordinator) GenerateControllerFromModel(resourceName string) error
GenerateControllerFromModel coordinates controller and view generation from existing model
func (*Coordinator) GenerateControllerWithActions ¶ added in v1.0.0
func (c *Coordinator) GenerateControllerWithActions(resourceName, namespace, tableName string, actions []string, inertia string, isAPI bool) error
GenerateControllerWithActions generates a controller and views for selected actions.
func (*Coordinator) GenerateControllerWithActionsForModel ¶ added in v1.0.0
func (c *Coordinator) GenerateControllerWithActionsForModel(resourceName, namespace, modelName, tableName string, actions []string, inertia string, isAPI bool) error
GenerateControllerWithActionsForModel generates a controller and views when resource and model names differ.
func (*Coordinator) GenerateScaffold ¶ added in v1.0.0
func (c *Coordinator) GenerateScaffold(resourceName, namespace, tableName string, skipFactory bool, primaryKeyColumn string, inertia string, isAPI bool) error
GenerateScaffold coordinates model, controller, and view generation for a complete resource scaffold.
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{}
DefaultPrimaryKeyResolver represents default primary key resolver.
func (DefaultPrimaryKeyResolver) ConfirmNoPK ¶ added in v1.0.0
func (DefaultPrimaryKeyResolver) ConfirmNoPK(tableName string) (bool, error)
ConfirmNoPK performs the confirm no primary key operation.
func (DefaultPrimaryKeyResolver) ResolveAlternatePK ¶ added in v1.0.0
func (DefaultPrimaryKeyResolver) ResolveAlternatePK(info PrimaryKeyInfo, tableName string) (PrimaryKeyInfo, error)
ResolveAlternatePK resolves alternate primary key.
type FactorySyncOptions ¶ added in v1.0.0
FactorySyncOptions configures factory sync behavior.
type FactorySyncResult ¶ added in v1.0.0
type FactorySyncResult struct {
ResourceName string `json:"resource_name"`
Path string `json:"path"`
Missing bool `json:"missing"`
Stale bool `json:"stale"`
Written bool `json:"written"`
Diff string `json:"diff,omitempty"`
Messages []string `json:"messages,omitempty"`
// contains filtered or unexported fields
}
FactorySyncResult represents factory sync result.
func (FactorySyncResult) HasDrift ¶ added in v1.0.0
func (r FactorySyncResult) HasDrift() bool
HasDrift reports whether drift is present.
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
}
Generator is the high-level facade for Andurel code generation.
func (*Generator) ApplyModelUpdate ¶ added in v1.0.0
func (g *Generator) ApplyModelUpdate(result *UpdateModelResult) error
ApplyModelUpdate writes a previously computed model update.
func (*Generator) GenerateAction ¶ added in v1.0.0
func (g *Generator) GenerateAction(config ActionConfig) error
GenerateAction adds an action to an existing controller and route set.
func (*Generator) GenerateController ¶
func (g *Generator) GenerateController(resourceName, namespace, tableName string, inertia string, isAPI bool) error
GenerateController generates controller and route files for a resource.
func (*Generator) GenerateControllerFromModel ¶
GenerateControllerFromModel generates a controller by reading an existing model.
func (*Generator) GenerateControllerWithActions ¶ added in v1.0.0
func (g *Generator) GenerateControllerWithActions(resourceName, namespace, tableName string, actions []string, inertia string, isAPI bool) error
GenerateControllerWithActions generates a controller restricted to the requested actions.
func (*Generator) GenerateControllerWithActionsForModel ¶ added in v1.0.0
func (g *Generator) GenerateControllerWithActionsForModel(resourceName, namespace, modelName, tableName string, actions []string, inertia string, isAPI bool) error
GenerateControllerWithActionsForModel generates a controller for a distinct model name.
func (*Generator) GenerateModel ¶
func (g *Generator) GenerateModel(resourceName string, tableNameOverride string, skipFactory bool) error
GenerateModel generates a model and optional factory for a resource.
func (*Generator) GenerateModelWithPK ¶ added in v1.0.0
func (g *Generator) GenerateModelWithPK(resourceName string, tableNameOverride string, skipFactory bool, primaryKeyColumn string) error
GenerateModelWithPK generates a model using an explicit primary key column.
func (*Generator) GenerateScaffold ¶ added in v1.0.0
func (g *Generator) GenerateScaffold(resourceName, namespace, tableName string, skipFactory bool, primaryKeyColumn string, inertia string, isAPI bool) error
GenerateScaffold generates model, factory, controller, routes, and views for a resource.
func (*Generator) GenerateView ¶
GenerateView generates views for a resource.
func (*Generator) GenerateViewFromModel ¶
GenerateViewFromModel generates views by reading an existing model.
func (*Generator) GetModulePath ¶ added in v1.0.0
GetModulePath returns the current project's Go module path.
func (*Generator) SetControllerPKResolver ¶ added in v1.0.0
func (g *Generator) SetControllerPKResolver(resolver PrimaryKeyResolver)
SetControllerPKResolver overrides primary key resolution for controller generation.
func (*Generator) SyncFactories ¶ added in v1.0.0
func (g *Generator) SyncFactories(opts FactorySyncOptions) ([]*FactorySyncResult, error)
SyncFactories refreshes factories across the project.
func (*Generator) SyncFactory ¶ added in v1.0.0
func (g *Generator) SyncFactory(resourceName string, opts FactorySyncOptions) (*FactorySyncResult, error)
SyncFactory refreshes a factory for one resource.
func (*Generator) UpdateModel ¶ added in v1.0.0
func (g *Generator) UpdateModel(resourceName string) (*UpdateModelResult, error)
UpdateModel computes the changes needed to refresh an existing model.
type InputValidator ¶
type InputValidator struct {
// contains filtered or unexported fields
}
InputValidator validates resource, table, file, and module names used by generators.
func NewInputValidator ¶
func NewInputValidator() *InputValidator
NewInputValidator creates a new input validator.
func (*InputValidator) ValidateAll ¶
func (v *InputValidator) ValidateAll(resourceName, tableName, modulePath string) error
ValidateAll checks the common generation inputs together.
func (*InputValidator) ValidateFilePath ¶
func (v *InputValidator) ValidateFilePath(filePath string) error
ValidateFilePath rejects unsafe, absolute, or traversal-based paths.
func (*InputValidator) ValidateModulePath ¶
func (v *InputValidator) ValidateModulePath(modulePath string) error
ValidateModulePath checks that a Go module path has a usable import shape.
func (*InputValidator) ValidateResourceName ¶
func (v *InputValidator) ValidateResourceName(resourceName string) error
ValidateResourceName checks that a resource name is singular PascalCase.
func (*InputValidator) ValidateTableName ¶
func (v *InputValidator) ValidateTableName(tableName string) error
ValidateTableName checks that a database table name is plural snake_case.
func (*InputValidator) ValidateTableNameOverride ¶
func (v *InputValidator) ValidateTableNameOverride(resourceName, tableNameOverride string) error
ValidateTableNameOverride checks a custom table name and warns about convention drift.
type MigrationManager ¶
type MigrationManager struct{}
MigrationManager coordinates migration operations.
func NewMigrationManager ¶
func NewMigrationManager() *MigrationManager
NewMigrationManager creates a new migration manager.
func (*MigrationManager) BuildCatalogFromMigrations ¶
func (mm *MigrationManager) BuildCatalogFromMigrations( tableName string, config *UnifiedConfig, ) (*catalog.Catalog, error)
BuildCatalogFromMigrations performs the build catalog from migrations operation.
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"`
}
ModelConfig configures model.
type ModelManager ¶
type ModelManager struct {
// contains filtered or unexported fields
}
ModelManager coordinates model operations.
func NewModelManager ¶
func NewModelManager( validator *InputValidator, fileManager files.Manager, modelGenerator *models.Generator, projectManager *ProjectManager, migrationManager *MigrationManager, config *UnifiedConfig, ) *ModelManager
NewModelManager creates a new model manager.
func (*ModelManager) ApplyModelUpdate ¶ added in v1.0.0
func (m *ModelManager) ApplyModelUpdate(result *UpdateModelResult) error
ApplyModelUpdate writes the updated model and factory file content and runs the Go formatter.
func (*ModelManager) GenerateModel ¶
func (m *ModelManager) GenerateModel( resourceName string, tableNameOverride string, skipFactory bool, primaryKeyColumn string, ) error
GenerateModel generates model files for a resource from project migrations.
func (*ModelManager) SetPrimaryKeyResolver ¶ added in v1.0.0
func (m *ModelManager) SetPrimaryKeyResolver(resolver PrimaryKeyResolver)
SetPrimaryKeyResolver overrides primary key resolution during model generation.
func (*ModelManager) SyncFactories ¶ added in v1.0.0
func (m *ModelManager) SyncFactories(opts FactorySyncOptions) ([]*FactorySyncResult, error)
SyncFactories performs the sync factories operation.
func (*ModelManager) SyncFactory ¶ added in v1.0.0
func (m *ModelManager) SyncFactory(resourceName string, opts FactorySyncOptions) (*FactorySyncResult, error)
SyncFactory performs the sync factory operation.
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"`
}
ModelPaths represents model paths.
type NopPrimaryKeyResolver ¶ added in v1.0.0
type NopPrimaryKeyResolver struct{}
NopPrimaryKeyResolver represents nop primary key resolver.
func (NopPrimaryKeyResolver) ConfirmNoPK ¶ added in v1.0.0
func (NopPrimaryKeyResolver) ConfirmNoPK(_ string) (bool, error)
ConfirmNoPK performs the confirm no primary key operation.
func (NopPrimaryKeyResolver) ResolveAlternatePK ¶ added in v1.0.0
func (NopPrimaryKeyResolver) ResolveAlternatePK(info PrimaryKeyInfo, _ string) (PrimaryKeyInfo, error)
ResolveAlternatePK resolves alternate primary key.
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"
}
PrimaryKeyInfo represents primary key info.
func DetectPrimaryKey ¶ added in v1.0.0
func DetectPrimaryKey(cat *catalog.Catalog, tableName string) PrimaryKeyInfo
DetectPrimaryKey detects primary key.
type PrimaryKeyResolver ¶ added in v1.0.0
type PrimaryKeyResolver interface {
ResolveAlternatePK(info PrimaryKeyInfo, tableName string) (PrimaryKeyInfo, error)
ConfirmNoPK(tableName string) (bool, error)
}
PrimaryKeyResolver represents primary key resolver.
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
}
ProjectManager coordinates project operations.
func NewProjectManager ¶
func NewProjectManager() (*ProjectManager, error)
NewProjectManager creates a new project manager.
func (*ProjectManager) GetModulePath ¶
func (pm *ProjectManager) GetModulePath() string
GetModulePath returns module path.
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
FactoryPath string
OldFactoryContent string
NewFactoryContent string
FactoryHasChanges 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.
func (*UpdateModelResult) FactoryDiff ¶ added in v1.0.0
func (r *UpdateModelResult) FactoryDiff() (string, error)
FactoryDiff returns a unified diff of the old vs new factory file content.
type ViewConfig ¶
type ViewConfig struct {
ResourceName string `json:"resource_name"`
PluralName string `json:"plural_name"`
ModulePath string `json:"module_path"`
Paths ViewPaths `json:"paths"`
}
ViewConfig configures view.
type ViewManager ¶
type ViewManager struct {
// contains filtered or unexported fields
}
ViewManager coordinates view operations.
func NewViewManager ¶
func NewViewManager( validator *InputValidator, projectManager *ProjectManager, migrationManager *MigrationManager, viewGenerator *views.Generator, config *UnifiedConfig, ) *ViewManager
NewViewManager creates a new view manager.
func (*ViewManager) GenerateView ¶
func (v *ViewManager) GenerateView(resourceName, tableName, namespace string) error
GenerateView generates views for a resource without changing controllers.
func (*ViewManager) GenerateViewFromModel ¶
func (v *ViewManager) GenerateViewFromModel(resourceName string, withController bool) error
GenerateViewFromModel generates views by inspecting an existing model file.
func (*ViewManager) GenerateViewWithControllerActions ¶ added in v1.0.0
func (v *ViewManager) GenerateViewWithControllerActions(resourceName, tableName string, namespace string, actions []string, inertia string) error
GenerateViewWithControllerActions generates views for selected controller actions.
func (*ViewManager) GenerateViewWithControllerActionsForModel ¶ added in v1.0.0
func (v *ViewManager) GenerateViewWithControllerActionsForModel(resourceName, modelName, tableName string, namespace string, actions []string, inertia string) error
GenerateViewWithControllerActionsForModel generates views when resource and model names differ.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package controllers generates controller and route source files from resource metadata.
|
Package controllers generates controller and route source files from resource metadata. |
|
Package files provides filesystem operations for reading and writing generated projects.
|
Package files provides filesystem operations for reading and writing generated projects. |
|
internal
|
|
|
Package models generates model source files from database schema metadata.
|
Package models generates model source files from database schema metadata. |
|
Package templates exposes the embedded templates used by code generators.
|
Package templates exposes the embedded templates used by code generators. |
|
Package views generates server-rendered and Inertia views from resource metadata.
|
Package views generates server-rendered and Inertia views from resource metadata. |