model

package
v0.2.19 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIParams

type APIParams struct {
	Name        string `yaml:"name" json:"name,omitempty"`
	Description string `yaml:"description" json:"description,omitempty"`
	Version     string `yaml:"version" json:"version,omitempty"`
}

type ColumnSchema

type ColumnSchema struct {
	Name       string     `yaml:"name" json:"name,omitempty"`
	Type       ColumnType `yaml:"type" json:"type,omitempty"`
	PrimaryKey bool       `yaml:"primary_key" json:"primary_key,omitempty"`
	PII        bool       `yaml:"pii" json:"pii,omitempty"`
}

type ColumnType

type ColumnType string

ColumnType represents the allowed data types for columns

const (
	TypeString   ColumnType = "string"
	TypeDatetime ColumnType = "date-time"
	TypeNumber   ColumnType = "number"
	TypeInteger  ColumnType = "integer"
	TypeBoolean  ColumnType = "boolean"
	TypeNull     ColumnType = "null"
	TypeObject   ColumnType = "object"
	TypeArray    ColumnType = "array"
)

func (ColumnType) IsValid

func (ct ColumnType) IsValid() bool

IsValid checks if the column type is one of the allowed types

func (ColumnType) MarshalJSON

func (ct ColumnType) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (ColumnType) MarshalYAML

func (ct ColumnType) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler interface

func (ColumnType) String

func (ct ColumnType) String() string

String implements fmt.Stringer interface

func (*ColumnType) UnmarshalJSON

func (ct *ColumnType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

func (*ColumnType) UnmarshalYAML

func (ct *ColumnType) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler interface

type Config

type Config struct {
	API      APIParams      `yaml:"api" json:"api"`
	Database Database       `yaml:"database" json:"database"`
	Plugins  map[string]any `yaml:"plugins" json:"plugins"`
}

func FromDSN added in v0.2.1

func FromDSN(dsn string) (*Config, error)

func FromYaml

func FromYaml(raw []byte) (*Config, error)

func (*Config) ParamRaw

func (g *Config) ParamRaw() string

type Database

type Database struct {
	Type       string               `yaml:"type" json:"type,omitempty"`
	Connection any                  `yaml:"connection" json:"connection,omitempty"`
	Endpoints  []Endpoint           `yaml:"endpoints" json:"endpoints,omitempty"`
	Tables     []TableWithEndpoints `yaml:"tables" json:"tables,omitempty"`
}

func (Database) GetAllEndpoints added in v0.2.16

func (d Database) GetAllEndpoints() []Endpoint

GetAllEndpoints returns all endpoints from both database level and table level

type Endpoint

type Endpoint struct {
	Group         string           `yaml:"group" json:"group,omitempty"`
	HTTPMethod    string           `yaml:"http_method" json:"http_method,omitempty"`
	HTTPPath      string           `yaml:"http_path" json:"path,omitempty"`
	MCPMethod     string           `yaml:"mcp_method" json:"mcp_method,omitempty"`
	Summary       string           `yaml:"summary" json:"summary,omitempty"`
	Description   string           `yaml:"description" json:"description,omitempty"`
	Query         string           `yaml:"query" json:"query,omitempty"`
	IsArrayResult bool             `yaml:"is_array_result" json:"is_array_result,omitempty"`
	Params        []EndpointParams `yaml:"params" json:"params,omitempty"`
}

type EndpointParams

type EndpointParams struct {
	Name     string      `yaml:"name" json:"name,omitempty"`
	Type     string      `yaml:"type" json:"type,omitempty"`
	Location string      `yaml:"location" json:"location,omitempty"`
	Required bool        `yaml:"required" json:"required,omitempty"`
	Format   string      `yaml:"format,omitempty" json:"format,omitempty"`
	Default  interface{} `yaml:"default,omitempty" json:"default,omitempty"`
}

type Table

type Table struct {
	Name     string         `yaml:"name" json:"name,omitempty"`
	Columns  []ColumnSchema `yaml:"columns" json:"columns,omitempty"`
	RowCount int            `yaml:"row_count" json:"row_count,omitempty"`
}

type TableWithEndpoints added in v0.2.16

type TableWithEndpoints struct {
	Name      string         `yaml:"name" json:"name,omitempty"`
	Columns   []ColumnSchema `yaml:"columns" json:"columns,omitempty"`
	RowCount  int            `yaml:"row_count" json:"row_count,omitempty"`
	Endpoints []Endpoint     `yaml:"endpoints" json:"endpoints,omitempty"`
}

Jump to

Keyboard shortcuts

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