schema

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidDataType

func IsValidDataType(dt DataType) bool

IsValidDataType returns true if dt is a recognized DataType.

func NormalizeName

func NormalizeName(name string) string

NormalizeName converts a name to a comparable form (lowercase, underscores).

Types

type DataType

type DataType string

DataType represents the type of a field's data.

const (
	TypeString   DataType = "string"
	TypeInt      DataType = "int"
	TypeFloat    DataType = "float"
	TypeBool     DataType = "bool"
	TypeDate     DataType = "date"
	TypeDatetime DataType = "datetime"
)

type Field

type Field struct {
	Name        string   `json:"name" yaml:"name"`
	Type        DataType `json:"type" yaml:"type"`
	Nullable    bool     `json:"nullable,omitempty" yaml:"nullable,omitempty"`
	Description string   `json:"description,omitempty" yaml:"description,omitempty"`
}

Field describes a single field the user wants to extract.

type Schema

type Schema struct {
	Name   string  `json:"name,omitempty" yaml:"name,omitempty"`
	URL    string  `json:"url,omitempty" yaml:"url,omitempty"`
	Fields []Field `json:"fields" yaml:"fields"`
}

Schema is the user-defined extraction schema.

func ParseFields

func ParseFields(fields string) (*Schema, error)

ParseFields parses a comma-separated field string like "name, price, rating" into a Schema with string-typed fields (types will be refined by the LLM).

func ParseYAML

func ParseYAML(path string) (*Schema, error)

ParseYAML reads a YAML schema file and returns the parsed Schema.

func (*Schema) FieldNames

func (s *Schema) FieldNames() []string

FieldNames returns the list of field names.

func (*Schema) Validate

func (s *Schema) Validate() error

Validate checks that the schema is internally consistent.

Jump to

Keyboard shortcuts

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