codegen

package
v0.10.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteAppRouter

func WriteAppRouter(w io.Writer, procs []ProcEntry, defs []typemap.TypeDef) error

WriteAppRouter writes the complete TypeScript AppRouter file given pre-converted procedure entries and interface definitions. Used by both static analysis (Generate) and runtime reflection (GenerateTS).

func WriteEnums added in v0.10.7

func WriteEnums(w io.Writer, defs []typemap.TypeDef) error

WriteEnums writes runtime `as const` objects for named string enum unions. Numeric unions are skipped because the analyzer does not retain const names.

func WriteZodSchemas

func WriteZodSchemas(w io.Writer, procs []ProcEntry, defs []typemap.TypeDef, style typemap.ZodStyle) error

WriteZodSchemas writes Zod 4 validation schemas for all procedure input types and their transitive dependencies.

Types

type EmitPlan

type EmitPlan struct {
	Order  []string                   // type names in dependency order (leaves first)
	Cycles map[string]map[string]bool // parentType → set of field type names needing getter syntax
}

EmitPlan holds the topological order and cycle information for Zod emission.

type GenerateResult

type GenerateResult struct {
	Procs []ProcEntry
	Defs  []typemap.TypeDef
}

GenerateResult holds the output of a generation pass, allowing the caller to also generate Zod schemas from the same data.

func Generate

func Generate(w io.Writer, result *analysis.Result, metas map[string]typemap.TypeMeta) (*GenerateResult, error)

Generate writes the TypeScript AppRouter definition to w using static analysis results.

type ProcEntry

type ProcEntry struct {
	Path     string
	ProcType string
	InputTS  string
	OutputTS string
}

ProcEntry is a procedure with pre-converted TypeScript type strings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL