Help us shape the future of Go! Take the 2026 Go Developer Survey

parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldIR

type FieldIR struct {
	Name       string       // Field name
	Type       string       // Field type as string (e.g., "String", "UUID", "Enum")
	Modifiers  []ModifierIR // Applied modifiers
	EnumValues []string     // For Enum fields, the allowed values
	SourceLine int          // Line number in source file
}

FieldIR represents a parsed field definition.

type HooksIR

type HooksIR struct {
	AfterCreate []JobRefIR // Jobs to enqueue after resource creation
	AfterUpdate []JobRefIR // Jobs to enqueue after resource update
}

HooksIR represents lifecycle job enqueueing declarations for a resource. AfterCreate jobs are enqueued transactionally on CREATE; AfterUpdate on UPDATE.

type JobRefIR

type JobRefIR struct {
	Kind  string // River job worker kind (e.g., "notify_new_product")
	Queue string // River queue name (e.g., "notifications")
}

JobRefIR represents a River job reference extracted from a schema.JobRef literal. Kind is the job worker kind string; Queue is the River queue name.

type ModifierIR

type ModifierIR struct {
	Type       string      // Modifier name (e.g., "Required", "MaxLen", "Default")
	Value      interface{} // Modifier argument if any (int for MaxLen, string for Default, etc.)
	SourceLine int         // Line number in source file
}

ModifierIR represents a parsed modifier on a field.

type ParseResult

type ParseResult struct {
	Resources []ResourceIR // All successfully parsed resources
	Errors    []error      // All parse errors collected during parsing
}

ParseResult represents the output of parsing a directory of schema files. It collects all resources and all errors encountered (not just the first one).

func ParseDir

func ParseDir(dir string) (*ParseResult, error)

ParseDir finds all schema.go files in subdirectories and parses them. It looks for the pattern resources/*/schema.go

func ParseFile

func ParseFile(path string) (*ParseResult, error)

ParseFile parses a single schema file.

func ParseString

func ParseString(source, filename string) (*ParseResult, error)

ParseString parses a schema definition from a string. This is primarily for testing.

type PermissionsIR

type PermissionsIR map[string][]string

PermissionsIR maps operation names to the roles allowed to perform them. Example: {"list": ["admin", "editor"], "delete": ["admin"]}

type RelationshipIR

type RelationshipIR struct {
	Name       string // Relationship name
	Type       string // "BelongsTo", "HasMany", "HasOne", "ManyToMany"
	Table      string // Related table name
	OnDelete   string // Cascade action (empty string = default)
	Optional   bool   // Whether relationship is optional
	Eager      bool   // Whether to eager-load this relationship
	SourceLine int    // Line number in source file
}

RelationshipIR represents a parsed relationship definition.

type ResourceIR

type ResourceIR struct {
	Name          string            // Resource name (e.g., "Product")
	Fields        []FieldIR         // Parsed fields
	Relationships []RelationshipIR  // Parsed relationships
	Options       ResourceOptionsIR // Resource-level options
	HasTimestamps bool              // Whether schema.Timestamps() was called
	SourceFile    string            // Original file path for error reporting
	SourceLine    int               // Line number of schema.Define() call
}

ResourceIR represents a top-level parsed resource definition. This is the domain model IR that the parser produces and the code generator consumes.

type ResourceOptionsIR

type ResourceOptionsIR struct {
	SoftDelete   bool          // Enable soft delete
	Auditable    bool          // Enable audit logging
	TenantScoped bool          // Enable multi-tenancy scoping
	Searchable   bool          // Enable full-text search
	Permissions  PermissionsIR // Role-based permission rules per operation
	Hooks        HooksIR       // Lifecycle River job enqueueing declarations
}

ResourceOptionsIR represents resource-level options.

Jump to

Keyboard shortcuts

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