Documentation
¶
Overview ¶
Package appgen emits a generated Go app that embeds build output.
Index ¶
- func BuildBinary(appDir, binaryPath string) (string, error)
- func BuildCronBinary(appDir, binaryPath string) (string, error)
- func BuildWASM(appDir, wasmPath string) (string, error)
- func BuildWorkerBinary(appDir, binaryPath string) (string, error)
- func GeneratedAuditTestSource(options Options) ([]byte, error)
- func StandaloneAuditTestSource(config gowdk.Config, manifest securitymanifest.SecurityManifest, ...) ([]byte, error)
- func StandaloneAuditTestSourceWithPackage(packageName string, config gowdk.Config, ...) ([]byte, error)
- type APIEndpoint
- type ActionEndpoint
- type ActionFragment
- type ActionUploadField
- type ActionValidationRule
- type ApplicationPlan
- type BackendAPIAdapter
- type BackendActionAdapter
- type BackendAdapterIR
- func (ir BackendAdapterIR) BackendImports() map[string]string
- func (ir BackendAdapterIR) GuardNames() []string
- func (ir BackendAdapterIR) HasCORSRoutes() bool
- func (ir BackendAdapterIR) HasCSRFSensitiveAPI() bool
- func (ir BackendAdapterIR) HasDynamicRoutes() bool
- func (ir BackendAdapterIR) HasEndpointKind(kind BackendEndpointKind) bool
- func (ir BackendAdapterIR) HasRegistrations() bool
- type BackendContractExposure
- type BackendDecoder
- type BackendEndpointKind
- type BackendEndpointRegistration
- type BackendFallback
- type BackendFragmentAdapter
- type BackendHandlerCall
- type BackendResponse
- type FragmentEndpoint
- type LayoutErrorPage
- type Options
- type Result
- func Generate(outputDir, appDir string) (Result, error)
- func GenerateBackendWithOptions(appDir string, options Options) (result Result, err error)
- func GenerateBackendWithPlan(appDir string, plan ApplicationPlan) (result Result, err error)
- func GenerateContractCron(appDir string, report contractscan.Report, config gowdk.ContractCronConfig) (result Result, err error)
- func GenerateContractWorker(appDir string, report contractscan.Report, config gowdk.ContractWorkerConfig) (result Result, err error)
- func GenerateWithOptions(outputDir, appDir string, options Options) (result Result, err error)
- func GenerateWithPlan(outputDir, appDir string, plan ApplicationPlan) (result Result, err error)
- type SSRCondSpec
- type SSRListField
- type SSRListSpec
- type SSRLoadReplacement
- type SSRQueryRegion
- type SSRReplacement
- type SSRRoute
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildBinary ¶
BuildBinary compiles the generated app into binaryPath.
func BuildCronBinary ¶ added in v0.12.0
BuildCronBinary compiles the generated contract cron app.
func BuildWorkerBinary ¶ added in v0.12.0
BuildWorkerBinary compiles the generated contract worker app.
func GeneratedAuditTestSource ¶ added in v0.5.0
GeneratedAuditTestSource returns the generated-app audit test file source for options. It returns nil when there is no IR-backed posture to exercise.
func StandaloneAuditTestSource ¶ added in v0.5.0
func StandaloneAuditTestSource(config gowdk.Config, manifest securitymanifest.SecurityManifest, specs []gwdkir.AuditSpec) ([]byte, error)
StandaloneAuditTestSource returns a committable audit test file that drives runtime/app directly from the derived posture. The CLI uses this for `gowdk audit --emit-tests`; `gowdk audit --run` generates a temporary app and runs the generated-app audit test instead.
func StandaloneAuditTestSourceWithPackage ¶ added in v0.5.0
func StandaloneAuditTestSourceWithPackage(packageName string, config gowdk.Config, manifest securitymanifest.SecurityManifest, specs []gwdkir.AuditSpec) ([]byte, error)
StandaloneAuditTestSourceWithPackage returns standalone audit test source using packageName. It exists so the CLI can emit into a directory that already has Go files without creating a mixed-package test setup.
Types ¶
type APIEndpoint ¶ added in v0.1.5
type APIEndpoint struct {
EndpointID gwdkir.EndpointID
PageID string
APIName string
Method string
Route string
Guards []string
ErrorPage string
CORS gwdkir.EndpointCORS
Binding source.BackendBinding
BackendAlias string
Source string
SourceSpan source.SourceSpan
}
APIEndpoint describes a generated API handler.
type ActionEndpoint ¶ added in v0.1.5
type ActionEndpoint struct {
EndpointID gwdkir.EndpointID
PageID string
ActionName string
Method string
Route string
Guards []string
InputName string
InputType string
InputFields []string
UploadFields []ActionUploadField
RequiredFields []string
RequiredMessages map[string]string
ValidationRules []ActionValidationRule
ValidatesInput bool
Redirect string
Fragments []ActionFragment
ErrorPage string
Binding source.BackendBinding
BackendAlias string
Source string
SourceSpan source.SourceSpan
}
ActionEndpoint describes a generated action handler.
type ActionFragment ¶
ActionFragment describes a generated partial response fragment.
type ActionUploadField ¶ added in v0.8.0
type ActionUploadField struct {
Field string
MaxFiles int
MaxBytes int64
AllowedContentTypes []string
}
ActionUploadField describes one generated multipart upload field policy.
type ActionValidationRule ¶ added in v0.1.5
type ActionValidationRule struct {
Field string
MinLength int
MinLengthMessage string
MaxLength int
MaxLengthMessage string
Pattern string
PatternMessage string
}
ActionValidationRule describes one generated server-side form constraint.
type ApplicationPlan ¶ added in v0.12.1
type ApplicationPlan struct {
// contains filtered or unexported fields
}
ApplicationPlan is the normalized generated-application plan consumed by appgen emission. Construct it through PlanApplication or PlanBackendApplication so route defaults, endpoint projections, SSR artifacts, sitemap data, and generator-local validation are finalized before writes.
func PlanApplication ¶ added in v0.12.1
func PlanApplication(outputDir string, options Options) (ApplicationPlan, error)
PlanApplication resolves and validates generated app options before emission.
func PlanBackendApplication ¶ added in v0.12.1
func PlanBackendApplication(options Options) (ApplicationPlan, error)
PlanBackendApplication resolves and validates backend-only generated app options before emission.
type BackendAPIAdapter ¶ added in v0.5.0
type BackendAPIAdapter struct {
Endpoint BackendEndpointRegistration
PageID string
APIName string
Method string
Route string
Guards []string
ErrorPage string
Binding source.BackendBinding
BackendAlias string
}
type BackendActionAdapter ¶ added in v0.5.0
type BackendActionAdapter struct {
Endpoint BackendEndpointRegistration
PageID string
ActionName string
Method string
Route string
Guards []string
InputName string
InputType string
InputFields []string
UploadFields []ActionUploadField
RequiredFields []string
RequiredMessages map[string]string
ValidationRules []ActionValidationRule
ValidatesInput bool
Redirect string
Fragments []ActionFragment
ErrorPage string
Binding source.BackendBinding
BackendAlias string
}
type BackendAdapterIR ¶ added in v0.1.5
type BackendAdapterIR struct {
Registrations []BackendEndpointRegistration
Actions []BackendActionAdapter
APIs []BackendAPIAdapter
Fragments []BackendFragmentAdapter
ContractExposures []BackendContractExposure
Decoders []BackendDecoder
Calls []BackendHandlerCall
Responses []BackendResponse
Fallbacks []BackendFallback
}
func (BackendAdapterIR) BackendImports ¶ added in v0.5.0
func (ir BackendAdapterIR) BackendImports() map[string]string
func (BackendAdapterIR) GuardNames ¶ added in v0.5.0
func (ir BackendAdapterIR) GuardNames() []string
func (BackendAdapterIR) HasCORSRoutes ¶ added in v0.8.0
func (ir BackendAdapterIR) HasCORSRoutes() bool
func (BackendAdapterIR) HasCSRFSensitiveAPI ¶ added in v0.5.0
func (ir BackendAdapterIR) HasCSRFSensitiveAPI() bool
func (BackendAdapterIR) HasDynamicRoutes ¶ added in v0.5.0
func (ir BackendAdapterIR) HasDynamicRoutes() bool
func (BackendAdapterIR) HasEndpointKind ¶ added in v0.5.0
func (ir BackendAdapterIR) HasEndpointKind(kind BackendEndpointKind) bool
func (BackendAdapterIR) HasRegistrations ¶ added in v0.1.5
func (ir BackendAdapterIR) HasRegistrations() bool
type BackendContractExposure ¶ added in v0.1.5
type BackendContractExposure struct {
Endpoint BackendEndpointRegistration
Contract string
ImportAlias string
ImportPath string
Type string
Result string
Roles []string
Guards []string
InputFields []source.BackendInputField
Status gwdkir.ContractBindingStatus
Handler string
Register string
Message string
OwnerKind gwdkir.SourceKind
OwnerID string
Package string
Source string
Span source.SourceSpan
}
type BackendDecoder ¶ added in v0.1.5
type BackendDecoder struct {
Endpoint BackendEndpointRegistration
Function string
Input string
Fields []string
}
type BackendEndpointKind ¶ added in v0.1.5
type BackendEndpointKind string
const ( BackendEndpointAction BackendEndpointKind = "action" BackendEndpointAPI BackendEndpointKind = "api" BackendEndpointFragment BackendEndpointKind = "fragment" BackendEndpointCommand BackendEndpointKind = "command" BackendEndpointQuery BackendEndpointKind = "query" )
type BackendEndpointRegistration ¶ added in v0.1.5
type BackendEndpointRegistration struct {
ID gwdkir.EndpointID
Kind BackendEndpointKind
Method string
Path string
Handler string
PageID string
Name string
Guards []string
CORS *gowdk.CORSConfig
Dynamic bool
Source string
Span source.SourceSpan
}
type BackendFallback ¶ added in v0.1.5
type BackendFallback struct {
Endpoint BackendEndpointRegistration
Status source.BackendBindingStatus
Message string
}
type BackendFragmentAdapter ¶ added in v0.5.0
type BackendHandlerCall ¶ added in v0.1.5
type BackendHandlerCall struct {
Endpoint BackendEndpointRegistration
Alias string
ImportPath string
Function string
Signature source.BackendSignatureKind
InputType string
}
type BackendResponse ¶ added in v0.1.5
type BackendResponse struct {
Endpoint BackendEndpointRegistration
NoStore bool
Partial bool
Redirect string
}
type FragmentEndpoint ¶ added in v0.1.5
type FragmentEndpoint struct {
EndpointID gwdkir.EndpointID
PageID string
FragmentName string
Method string
Route string
RouteParams []source.RouteParam
Target string
HTML string
Package string
Uses map[string]string
Guards []string
Binding source.BackendBinding
BackendAlias string
Source string
SourceSpan source.SourceSpan
}
FragmentEndpoint describes a generated server fragment handler.
type LayoutErrorPage ¶ added in v0.8.0
type Options ¶
type Options struct {
Actions []ActionEndpoint
APIs []APIEndpoint
Fragments []FragmentEndpoint
SSR []SSRRoute
AutoRoutes bool
ProxyBackend bool
Config gowdk.Config
Program *compiler.ValidatedProgram
// IR is the legacy raw-IR option path. Production auto-routing should pass
// Program so generation receives a compiler-validated phase token.
IR *gwdkir.Program
Sitemap buildgen.RuntimeSitemapPlan
}
Options configures generated app output.
func OptionsFromIR ¶ added in v0.5.0
OptionsFromIR returns the production generator options for compiler IR-driven route generation.
func OptionsFromValidatedProgram ¶ added in v0.12.1
func OptionsFromValidatedProgram(config gowdk.Config, program compiler.ValidatedProgram) Options
OptionsFromValidatedProgram returns production generator options for compiler-validated IR-driven route generation.
type Result ¶
type Result struct {
AppDir string
MainPath string
PackagePath string
ModulePath string
OutputDir string
Files []string
BinaryPath string
Role string
Contracts []string
Jobs []string
}
Result describes generated app artifacts.
func GenerateBackendWithOptions ¶ added in v0.1.5
GenerateBackendWithOptions writes a generated Go app that serves only request-time backend routes for feature-bound actions and APIs.
func GenerateBackendWithPlan ¶ added in v0.12.1
func GenerateBackendWithPlan(appDir string, plan ApplicationPlan) (result Result, err error)
GenerateBackendWithPlan writes a generated Go app that serves only request-time backend routes from an application plan.
func GenerateContractCron ¶ added in v0.12.0
func GenerateContractCron(appDir string, report contractscan.Report, config gowdk.ContractCronConfig) (result Result, err error)
GenerateContractCron writes a standalone generated cron role app.
func GenerateContractWorker ¶ added in v0.12.0
func GenerateContractWorker(appDir string, report contractscan.Report, config gowdk.ContractWorkerConfig) (result Result, err error)
GenerateContractWorker writes a standalone generated worker role app.
func GenerateWithOptions ¶
GenerateWithOptions writes a self-contained Go app that embeds outputDir.
func GenerateWithPlan ¶ added in v0.12.1
func GenerateWithPlan(outputDir, appDir string, plan ApplicationPlan) (result Result, err error)
GenerateWithPlan writes a self-contained Go app from an application plan.
type SSRCondSpec ¶ added in v0.6.0
type SSRCondSpec = source.SSRCondSpec
type SSRListField ¶ added in v0.6.0
type SSRListField = source.SSRListField
type SSRListSpec ¶ added in v0.6.0
type SSRListSpec = source.SSRListSpec
type SSRLoadReplacement ¶ added in v0.1.5
type SSRLoadReplacement = source.SSRLoadReplacement
type SSRQueryRegion ¶ added in v0.7.0
type SSRQueryRegion = source.SSRQueryRegion
type SSRReplacement ¶
type SSRReplacement = source.SSRReplacement
type SSRRoute ¶
type SSRRoute struct {
PageID string
Route string
Render gowdk.RenderMode
Cache string
ErrorPage string
LayoutErrorPages []LayoutErrorPage
Locale string
DynamicParams []string
RouteParams []source.RouteParam
Layouts []string
Guards []string
HasLoad bool
LoadBinding source.BackendBinding
LoadBackendAlias string
Source string
SourceSpan source.SourceSpan
HTML string
Replacements []SSRReplacement
LoadReplacements []SSRLoadReplacement
ListSpecs []SSRListSpec
CondSpecs []SSRCondSpec
QueryRegions []SSRQueryRegion
}
SSRRoute describes a generated request-time page handler.
Source Files
¶
- adapter_ir.go
- appgen.go
- audit_tests.go
- auto_routes.go
- build.go
- contract_roles.go
- files.go
- identifier_errors.go
- ir.go
- module.go
- routes.go
- scripts.go
- source.go
- source_actions.go
- source_api.go
- source_auth.go
- source_backend.go
- source_backend_app.go
- source_contracts.go
- source_env.go
- source_fragments.go
- source_guards.go
- source_lifecycle.go
- source_middleware.go
- source_observability.go
- source_rate_limit.go
- source_realtime.go
- source_ssr.go
- source_ssr_regions.go
- template.go
- types.go
- validate_actions.go
- validate_ssr.go