codegen

package
v0.0.0-...-4d4e4f8 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const IRVersion = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	DBName          string
	DBNameLower     string
	SQLIdent        string
	GoName          string
	JSONName        string
	DomainType      string
	TransportType   string
	SQLCType        string
	Nullable        bool
	HasDefault      bool
	SystemTimestamp bool
	IsArray         bool
	IsSecret        bool
}

type Filter

type Filter struct {
	Name           string
	Field          string
	Op             string
	QueryParam     string
	QueryParamFrom string
	QueryParamTo   string
	MaxLen         int
	DomainType     string
	DomainTypeIn   string
	TransportType  string
	SQLCType       string
}

type HTTPDefaults

type HTTPDefaults struct {
	BasePath     string
	CursorParam  string
	NextField    string
	DefaultMode  string
	DefaultLimit int
	MaxLimit     int
	MaxOffset    int
}

type IDDefaults

type IDDefaults struct {
	DefaultMode   string
	UUIDMode      string
	UUIDAlgorithm string
	Int64Mode     string
}

type IR

type IR struct {
	IRVersion   int
	SpecVersion int
	Workdir     string
	ModulePath  string
	Output      Outputs
	Logging     Logging
	ID          IDDefaults
	HTTP        HTTPDefaults
	Schema      SchemaInfo
	Resources   []*Resource
}

func BuildIR

func BuildIR(ctx context.Context, cat *parser.Catalog, genSpec *spec.GenSpec, opts Options) (*IR, error)

type List

type List struct {
	Modes             []string
	DefaultMode       string
	DefaultLimit      int
	MaxLimit          int
	MaxOffset         int
	DefaultSort       string
	AllowSortOverride bool
	Total             string
	Sorts             []Sort
	Filters           []Filter
}

type Logging

type Logging struct {
	Enabled   bool
	Package   string
	Interface string
	ParamName string
	Import    string
	Type      string
}

type Manifest

type Manifest struct {
	Version           int              `yaml:"version"`
	RequiresIRVersion int              `yaml:"requires_ir_version"`
	Templates         []*TemplateEntry `yaml:"templates"`
}

func ParseManifest

func ParseManifest(data []byte) (*Manifest, error)

type Methods

type Methods struct {
	Create bool
	Get    bool
	Patch  bool
	Delete string
	List   bool
}

type Options

type Options struct {
	Workdir            string
	SchemaPath         string
	TemplatesDir       string
	OutputRootOverride string
	Overwrite          bool
	Gofmt              bool
	Goimports          bool
	Prune              bool
	ForcePrune         bool
	Check              bool
	Diff               bool
	DryRun             bool
	Targets            []string
	Stdout             io.Writer
}

type OrderingPolicy

type OrderingPolicy struct {
	Field       string
	GoName      string
	DomainType  string
	AutoAssign  bool
	SortDefault string
}

type Outputs

type Outputs struct {
	GeneratedRoot string
	RepoRoot      string
	DomainRoot    string
	ServiceRoot   string
	TransportRoot string
	HTTPRoot      string
	DocsRoot      string

	RepoImport      string
	DomainImport    string
	ServiceImport   string
	TransportImport string
	HTTPImport      string
	DocsImport      string
}

type Resource

type Resource struct {
	Name       string
	Dir        string
	Schema     string
	Table      string
	Route      string
	Kind       string
	GoName     string
	Package    string
	DomainPkg  string
	RepoPkg    string
	ServicePkg string
	TransPkg   string

	DomainImport    string
	RepoImport      string
	ServiceImport   string
	TransportImport string
	SQLCImport      string
	HTTPImport      string

	IDMode               string
	PK                   Field
	Fields               []Field
	CreateFields         []Field
	PatchFields          []Field
	ResponseFields       []Field
	Methods              Methods
	List                 *List
	Tabular              []TabularPart
	HasTabular           bool
	HasTabularReplaceAll bool
	SoftDelete           *SoftDelete
	Transaction          *Transaction
}

type Result

type Result struct {
	FilesWritten  []string
	FilesPruned   []string
	FilesExpected []string
}

func Generate

func Generate(ctx context.Context, cat *parser.Catalog, genSpec *spec.GenSpec, opts Options) (*Result, error)

type SchemaInfo

type SchemaInfo struct {
	Hash string
}

type SoftDelete

type SoftDelete struct {
	Column          string
	FilterByDefault bool
}

type Sort

type Sort struct {
	Name             string
	OrderBy          []string
	CursorFields     []string
	CursorFieldInfo  []Field
	Direction        string
	Mixed            bool
	QueryCursor      string
	QueryOffset      string
	QueryOffsetCount string
}

type TabularMethods

type TabularMethods struct {
	List       bool
	Create     bool
	Patch      bool
	Delete     bool
	ReplaceAll bool
}

type TabularPart

type TabularPart struct {
	Name             string
	Dir              string
	Table            string
	Route            string
	FKField          string
	FKGoName         string
	IDField          string
	IDGoName         string
	IDDomainType     string
	IDMode           string
	UniqueFields     []string
	UniqueFieldsInfo []Field
	PatchKeys        []Field
	Methods          TabularMethods
	Ordering         *OrderingPolicy
	List             *List
	Fields           []Field
	CreateFields     []Field
	PatchFields      []Field
	ResponseFields   []Field
	ReplaceKey       *Field
	Queries          TabularQueries
}

type TabularQueries

type TabularQueries struct {
	ListCursor         string
	ListOffset         string
	ListOffsetCount    string
	Create             string
	CreateWithDefaults string
	Patch              string
	Delete             string
	DeleteMissing      string
	Upsert             string
}

type TemplateEntry

type TemplateEntry struct {
	Name    string   `yaml:"name"`
	Scope   string   `yaml:"scope"`
	Source  string   `yaml:"source"`
	Output  string   `yaml:"output"`
	Package string   `yaml:"package"`
	Targets []string `yaml:"targets"`
}

type Transaction

type Transaction struct {
	RequiredFor []string
}

Jump to

Keyboard shortcuts

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