db

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDatabaseFilename

func DefaultDatabaseFilename() (string, error)

Types

type Catalog added in v0.28.0

type Catalog struct {
	Ref     string          `db:"ref"`
	Digest  string          `db:"digest"`
	Title   string          `db:"title"`
	Source  string          `db:"source"`
	Servers []CatalogServer `db:"-"`
}

type CatalogDAO added in v0.28.0

type CatalogDAO interface {
	GetCatalog(ctx context.Context, ref string) (*Catalog, error)
	UpsertCatalog(ctx context.Context, catalog Catalog) error
	DeleteCatalog(ctx context.Context, ref string) error
	ListCatalogs(ctx context.Context) ([]Catalog, error)
}

type CatalogServer added in v0.28.0

type CatalogServer struct {
	ID         *int64   `db:"id" json:"id"`
	ServerType string   `db:"server_type" json:"server_type"`
	Tools      ToolList `db:"tools" json:"tools"`
	Source     string   `db:"source" json:"source"`
	Image      string   `db:"image" json:"image"`
	CatalogRef string   `db:"catalog_ref" json:"catalog_ref"`

	Snapshot *ServerSnapshot `db:"snapshot" json:"snapshot"`
}

type DAO

type DAO interface {
	WorkingSetDAO
	CatalogDAO
}

func New

func New(opts ...Option) (DAO, error)

type Option

type Option func(o *options) error

func WithDatabaseFile

func WithDatabaseFile(dbFile string) Option

type Secret

type Secret struct {
	Provider string `json:"provider"`
}

type SecretMap

type SecretMap map[string]Secret

func (*SecretMap) Scan

func (secrets *SecretMap) Scan(value any) error

func (SecretMap) Value

func (secrets SecretMap) Value() (driver.Value, error)

type Server

type Server struct {
	Type    string         `json:"type"`
	Config  map[string]any `json:"config,omitempty"`
	Secrets string         `json:"secrets,omitempty"`
	Tools   []string       `json:"tools"`
	Source  string         `json:"source,omitempty"`
	Image   string         `json:"image,omitempty"`

	// Optional snapshot of the server schema
	Snapshot *ServerSnapshot `json:"snapshot,omitempty"`
}

type ServerList

type ServerList []Server

func (*ServerList) Scan

func (servers *ServerList) Scan(value any) error

func (ServerList) Value

func (servers ServerList) Value() (driver.Value, error)

type ServerSnapshot added in v0.26.0

type ServerSnapshot struct {
	// TODO(cody): hacky reference to the same type that we use elsewhere
	Server catalog.Server `json:"server"`
}

func (*ServerSnapshot) Scan added in v0.28.0

func (snapshot *ServerSnapshot) Scan(value any) error

func (*ServerSnapshot) Value added in v0.28.0

func (snapshot *ServerSnapshot) Value() (driver.Value, error)

Used as a column in catalogs

type ToolList added in v0.28.0

type ToolList []string

func (*ToolList) Scan added in v0.28.0

func (tools *ToolList) Scan(value any) error

func (ToolList) Value added in v0.28.0

func (tools ToolList) Value() (driver.Value, error)

type WorkingSet

type WorkingSet struct {
	ID      string     `db:"id"`
	Name    string     `db:"name"`
	Servers ServerList `db:"servers"`
	Secrets SecretMap  `db:"secrets"`
}

type WorkingSetDAO

type WorkingSetDAO interface {
	GetWorkingSet(ctx context.Context, id string) (*WorkingSet, error)
	FindWorkingSetsByIDPrefix(ctx context.Context, prefix string) ([]WorkingSet, error)
	ListWorkingSets(ctx context.Context) ([]WorkingSet, error)
	CreateWorkingSet(ctx context.Context, workingSet WorkingSet) error
	UpdateWorkingSet(ctx context.Context, workingSet WorkingSet) error
	RemoveWorkingSet(ctx context.Context, id string) error
	SearchWorkingSets(ctx context.Context, query string, workingSetID string) ([]WorkingSet, error)
}

Jump to

Keyboard shortcuts

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