tickle

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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

func IsTableScope(scope string) bool

IsTableScope returns true if the scope is a table-level scope (not per-column).

func Merge

func Merge(srcDir, targetPackage string) (string, error)

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.

func Tickle

func Tickle(srcDir, targetPackage string) (map[string]string, error)

Tickle reads Go source files from srcDir and returns their contents with the package declaration replaced to targetPackage. Each file's content is returned as a map of filename → source.

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

func ColumnsFromTable(table *schema.Table) []ColumnDef

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

func ExtractDocs(docsDir string) ([]DocFile, error)

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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