generator

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: 27 Imported by: 0

Documentation

Index

Constants

View Source
const IRVersion = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	ID     string
	Schema string

	DomainDir    string
	RepoDir      string
	ServiceDir   string
	TransportDir string

	DomainPkg    string
	RepoPkg      string
	ServicePkg   string
	TransportPkg string

	DomainImport    string
	RepoImport      string
	ServiceImport   string
	TransportImport string

	Resources []*Resource
}

Bucket describes a schema bucket used in layout.mode=by_schema.

type Field

type Field struct {
	DBName          string
	DBNameLower     string
	SQLIdent        string
	GoName          string
	SQLCGoName      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
	GoName         string
	SQLCName       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
	Buckets     []*Bucket
	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
	Clean              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
	RepoCodecRoot  string
	RepoCursorRoot string
	DomainRoot     string
	ServiceRoot    string
	TransportRoot  string
	HTTPRoot       string
	DocsRoot       string

	GeneratedImport  string
	RepoImport       string
	RepoCodecImport  string
	RepoCursorImport 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
	// SQLCModelType is the sqlc-generated model struct name for this table.
	// For Postgres, sqlc prefixes the table name with schema (e.g. "customers.person" -> "CustomersPerson").
	SQLCModelType string

	Prefix   string
	Sym      string
	BucketID string

	DomainDir    string
	RepoDir      string
	ServiceDir   string
	TransDir     string
	DomainFile   string
	RepoFile     string
	ServiceFile  string
	DTOFile      string
	HandlersFile string

	RepoInterfaceName    string
	RepoCtorName         string
	RepoImplName         string
	ServiceInterfaceName string
	ServiceCtorName      string
	ServiceImplName      string
	HandlerTypeName      string
	HandlerCtorName      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
	// VersionField is the aggregate concurrency token (e.g. "version" BIGINT).
	// When set, generated transports/services can require If-Match and enforce optimistic concurrency.
	VersionField   *Field
	Fields         []Field
	CreateFields   []Field
	PatchFields    []Field
	ResponseFields []Field
	// ServerCreateFields lists fields that are set by the server on create (from policy server_fields.create.set).
	// These fields belong to domain CreateInput and repository Create params, but are excluded from transport CreateRequest.
	ServerCreateFields   []ServerField
	Methods              Methods
	List                 *List
	Tabular              []TabularPart
	HasTabular           bool
	HasTabularReplaceAll bool
	// OptimisticLockRequired indicates that mutations must require If-Match (mandatory optimistic concurrency).
	OptimisticLockRequired bool
	SoftDelete             *SoftDelete
	Transaction            *Transaction

	// Authorization seams (per resource, to avoid collisions in shared packages).
	AuthorizerInterfaceName string
	AllowAllAuthorizerName  string
	ServiceOptionName       string
	WithAuthorizerFuncName  string
}

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 ServerField

type ServerField struct {
	Field  Field
	Source 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
	QualifiedName string
	Dir           string
	Table         string
	Route         string
	// SQLCModelType is the sqlc-generated model struct name for this table (schema-prefixed).
	SQLCModelType    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