Documentation
¶
Index ¶
- Variables
- func BuildFuncMap() template.FuncMap
- func DiffResource(resource parser.ResourceIR, projectRoot, projectModule string) (string, error)
- func FormatGoSource(filename string, source []byte) ([]byte, error)
- func Generate(resources []parser.ResourceIR, cfg GenerateConfig) error
- func GenerateAPI(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateActions(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateAtlasSchema(resources []parser.ResourceIR, outputDir string) error
- func GenerateErrors(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateFactories(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateHTML(resources []parser.ResourceIR, outputDir, projectModule string) error
- func GenerateMain(projectRoot, projectModule string) error
- func GenerateMiddleware(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateModels(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GeneratePagination(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateQueries(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateSQLCConfig(resources []parser.ResourceIR, outputDir string, projectModule string, ...) error
- func GenerateTransaction(resources []parser.ResourceIR, outputDir string, projectModule string) error
- func GenerateValidation(resources []parser.ResourceIR, outputDir string, projectModule string) error
- type AtlasTemplateData
- type FactoryTemplateData
- type GenerateConfig
- type ScaffoldResult
Constants ¶
This section is empty.
Variables ¶
var TemplatesFS embed.FS
TemplatesFS contains embedded code generation templates
Functions ¶
func BuildFuncMap ¶
BuildFuncMap returns a FuncMap with all template helper functions.
func DiffResource ¶
func DiffResource(resource parser.ResourceIR, projectRoot, projectModule string) (string, error)
DiffResource produces a unified diff between on-disk scaffold files and freshly-rendered scaffold output. Files that don't exist on disk are reported as "would be created".
func FormatGoSource ¶
FormatGoSource formats Go source code and manages imports automatically. It takes a filename (for context) and raw source bytes, returning formatted source with imports added/removed as needed, or an error if formatting fails.
func Generate ¶
func Generate(resources []parser.ResourceIR, cfg GenerateConfig) error
Generate orchestrates all code generation from parsed resources.
func GenerateAPI ¶
func GenerateAPI(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateAPI generates Huma API Input/Output structs and route registration functions for all resources.
func GenerateActions ¶
func GenerateActions(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateActions generates action interfaces and default implementations for all resources.
func GenerateAtlasSchema ¶
func GenerateAtlasSchema(resources []parser.ResourceIR, outputDir string) error
GenerateAtlasSchema generates an Atlas HCL schema file from parsed resources. The schema file represents the desired database state for Atlas CLI to diff against.
func GenerateErrors ¶
func GenerateErrors(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateErrors generates error types and database error mapping. Signature matches other generators for consistency even though errors are not per-resource.
func GenerateFactories ¶
func GenerateFactories(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateFactories generates test factory files for each resource. Factories provide builder-pattern helpers for creating test data.
func GenerateHTML ¶
func GenerateHTML(resources []parser.ResourceIR, outputDir, projectModule string) error
GenerateHTML generates the HTML primitives library, Datastar SSE helpers, and the HTML route registration dispatcher. These are generated-always files in gen/html/ (not scaffolded-once).
func GenerateMain ¶
GenerateMain scaffolds a main.go in the project root if one doesn't already exist. This follows the scaffold-once pattern: if the user has already edited main.go to include forge framework wiring, we don't overwrite it. Use `forge generate --diff` to show what a fresh main.go would look like.
func GenerateMiddleware ¶
func GenerateMiddleware(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateMiddleware generates panic recovery and error rendering middleware. This generates two files (not per-resource) since middleware is global.
func GenerateModels ¶
func GenerateModels(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateModels generates Go model files for all resources.
func GeneratePagination ¶
func GeneratePagination(resources []parser.ResourceIR, outputDir string, projectModule string) error
GeneratePagination generates pagination utilities for cursor and offset-based pagination. This generates a single file (not per-resource) since pagination logic is generic.
func GenerateQueries ¶
func GenerateQueries(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateQueries generates query builder mod functions for all resources.
func GenerateSQLCConfig ¶
func GenerateSQLCConfig(resources []parser.ResourceIR, outputDir string, projectModule string, projectRoot string) error
GenerateSQLCConfig generates a sqlc.yaml configuration file for the project. This provides an escape hatch for developers to write custom SQL queries.
func GenerateTransaction ¶
func GenerateTransaction(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateTransaction generates transaction wrapper functions with River support. This generates a single file (not per-resource) in gen/forge/.
func GenerateValidation ¶
func GenerateValidation(resources []parser.ResourceIR, outputDir string, projectModule string) error
GenerateValidation generates validation functions for all resources.
Types ¶
type AtlasTemplateData ¶
type AtlasTemplateData struct {
Resources []parser.ResourceIR
}
AtlasTemplateData holds data for rendering the Atlas schema template.
type FactoryTemplateData ¶
type FactoryTemplateData struct {
Name string
Fields []parser.FieldIR
Options parser.ResourceOptionsIR
HasTimestamps bool
ProjectModule string
}
FactoryTemplateData holds data for rendering the factory template.
type GenerateConfig ¶
type GenerateConfig struct {
OutputDir string // Output directory for generated files
ProjectModule string // Go module path of the generated project
ProjectRoot string // Project root directory (parent of OutputDir)
}
GenerateConfig holds configuration for the generator.
type ScaffoldResult ¶
type ScaffoldResult struct {
Created []string // Files written to disk
Skipped []string // Files that already existed (not overwritten)
}
ScaffoldResult holds the outcome of a ScaffoldResource call.
func ScaffoldResource ¶
func ScaffoldResource(resource parser.ResourceIR, projectRoot, projectModule string) (*ScaffoldResult, error)
ScaffoldResource writes scaffold-once files for a resource into resources/<name>/. It skips any file that already exists on disk (protecting developer customizations).