Documentation
¶
Index ¶
- func GenerateScopes(blocks []ScopeBlock, columns []ColumnDef, modelName string) (string, error)
- func GenerateTableScopes(blocks []ScopeBlock, modelName string, owned bool) string
- func IsTableScope(scope string) bool
- func Merge(srcDir, targetPackage string) (string, error)
- func ScopeForType(colType schema.ColumnType) string
- func Tickle(srcDir, targetPackage string) (map[string]string, error)
- type ColumnDef
- type DocFile
- type ScopeBlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateScopes ¶
func GenerateScopes(blocks []ScopeBlock, columns []ColumnDef, modelName string) (string, error)
GenerateScopes stamps out scope functions for each column of a table. Returns an error if blocks are provided but none match any column.
func GenerateTableScopes ¶
func GenerateTableScopes(blocks []ScopeBlock, modelName string, owned bool) string
GenerateTableScopes stamps out table-level scope functions for a model. "table" blocks are emitted for non-owned tables, "table_owned" for owned tables.
func IsTableScope ¶
IsTableScope returns true if the scope is a table-level scope (not per-column).
func Merge ¶
Merge reads Go source files from srcDir, merges them into a single valid Go file with one package declaration and one consolidated import block, using targetPackage as the package name.
func ScopeForType ¶
func ScopeForType(colType schema.ColumnType) string
ScopeForType maps schema column types to their scope category.
Types ¶
type ColumnDef ¶
type ColumnDef struct {
PascalName string // "UserID", "Status", "CreatedAt"
SnakeName string // "user_id", "status", "created_at"
GoType string // "uuid.UUID", "string", "time.Time"
Scope string // "all", "string", "numeric", "timestamp"
IsEncrypted bool // AES-SIV deterministic — only equality scopes
IsSealed bool // AES-GCM non-deterministic — no scopes at all
}
ColumnDef holds the info needed to stamp out scope functions.
func ColumnsFromTable ¶
ColumnsFromTable extracts column definitions from a schema table.
type DocFile ¶
type DocFile struct {
Name string `json:"name"`
Description string `json:"description"`
Content string `json:"content"`
}
DocFile holds extracted documentation from a markdown file.
func ExtractDocs ¶
ExtractDocs reads all .md files from docsDir. Each file's first line is expected to be a "# Title" header (the name), and the first non-empty line following it is the description. The full content is preserved.
type ScopeBlock ¶
type ScopeBlock struct {
Scope string // "all", "string", "numeric", "timestamp"
Body string // The function template text
}
ScopeBlock represents a template block extracted from a scopes file.
func ParseScopeBlocks ¶
func ParseScopeBlocks(path string) ([]ScopeBlock, error)
ParseScopeBlocks reads a scopes template file and extracts the blocks.