Documentation
¶
Index ¶
- Constants
- func GetStorageUnitModel(unit StorageUnit) *model.StorageUnit
- func IntPtr(i int) *int
- func ValidateColumnType(typeName string, metadata *DatabaseMetadata) error
- type ChatMessage
- type Column
- type Credentials
- type DatabaseMetadata
- type DatabaseType
- type Engine
- type ExternalModel
- type ForeignKeyRelationship
- type GetRowsResult
- type GraphUnit
- type GraphUnitRelationship
- type GraphUnitRelationshipType
- type LoginProfileRetriever
- type Plugin
- type PluginConfig
- type PluginFunctions
- type Record
- type StorageUnit
- type TypeCategory
- type TypeDefinition
- type UnsupportedTypeError
Constants ¶
const ( DatabaseType_Postgres = "Postgres" DatabaseType_MySQL = "MySQL" DatabaseType_MariaDB = "MariaDB" DatabaseType_Sqlite3 = "Sqlite3" DatabaseType_MongoDB = "MongoDB" DatabaseType_Redis = "Redis" DatabaseType_ElasticSearch = "ElasticSearch" DatabaseType_ClickHouse = "ClickHouse" DatabaseType_ElastiCache = "ElastiCache" // Uses Redis plugin for now DatabaseType_DocumentDB = "DocumentDB" // Uses MongoDB plugin for now )
const ( GraphUnitRelationshipType_OneToOne = "OneToOne" GraphUnitRelationshipType_OneToMany = "OneToMany" GraphUnitRelationshipType_ManyToOne = "ManyToOne" GraphUnitRelationshipType_ManyToMany = "ManyToMany" GraphUnitRelationshipType_Unknown = "Unknown" )
Variables ¶
This section is empty.
Functions ¶
func GetStorageUnitModel ¶
func GetStorageUnitModel(unit StorageUnit) *model.StorageUnit
GetStorageUnitModel converts an engine StorageUnit to a GraphQL model StorageUnit.
func ValidateColumnType ¶
func ValidateColumnType(typeName string, metadata *DatabaseMetadata) error
ValidateColumnType checks if a column type string is valid against the TypeDefinitions. It parses the type string (e.g., "VARCHAR(255)") and validates: - The base type exists in TypeDefinitions (or AliasMap) - Length/precision parameters match the type's requirements Returns nil if valid, or an error describing the issue.
Types ¶
type ChatMessage ¶
type ChatMessage struct {
Type string
Result *GetRowsResult
Text string
}
ChatMessage represents a message in an AI chat conversation with optional query results.
type Column ¶
type Column struct {
Type string
Name string
IsPrimary bool
IsForeignKey bool
ReferencedTable *string
ReferencedColumn *string
Length *int // For VARCHAR(n), CHAR(n) types
Precision *int // For DECIMAL(p,s) types
Scale *int // For DECIMAL(p,s) types
}
Column describes a database column including its type, name, and relationship metadata.
type Credentials ¶
type Credentials struct {
Id *string
Type string
Hostname string
Username string
Password string
Database string
Advanced []Record
AccessToken *string
IsProfile bool
}
Credentials holds authentication and connection details for a database.
type DatabaseMetadata ¶
type DatabaseMetadata struct {
DatabaseType DatabaseType
TypeDefinitions []TypeDefinition
Operators []string
AliasMap map[string]string
}
DatabaseMetadata contains all metadata for a database type
type Engine ¶
type Engine struct {
Plugins []*Plugin
LoginProfiles []types.DatabaseCredentials
ProfileRetrievers []LoginProfileRetriever
}
Engine manages database plugins and login profiles.
func (*Engine) AddLoginProfile ¶
func (e *Engine) AddLoginProfile(profile types.DatabaseCredentials)
AddLoginProfile adds database credentials to the engine's profile list.
func (*Engine) Choose ¶
func (e *Engine) Choose(databaseType DatabaseType) *Plugin
Choose returns the plugin that matches the given database type, or nil if not found.
func (*Engine) RegisterProfileRetriever ¶
func (e *Engine) RegisterProfileRetriever(retriever LoginProfileRetriever)
RegisterProfileRetriever adds a function that retrieves database credentials on demand.
func (*Engine) RegistryPlugin ¶
RegistryPlugin adds a database plugin to the engine.
type ExternalModel ¶
type ExternalModel struct {
Type string // Provider type: "OpenAI", "Anthropic", "Ollama", etc.
Token string // API key
Model string // User-selected model: "gpt-4o", "claude-sonnet-4", etc.
Endpoint string // Base URL (for Ollama/generic providers)
}
ExternalModel represents an external AI model configuration for chat functionality.
type ForeignKeyRelationship ¶
type ForeignKeyRelationship struct {
ColumnName string
ReferencedTable string
ReferencedColumn string
}
ForeignKeyRelationship describes a foreign key constraint on a column.
type GetRowsResult ¶
GetRowsResult contains the result of a row query including columns, data, and pagination info.
type GraphUnit ¶
type GraphUnit struct {
Unit StorageUnit
Relations []GraphUnitRelationship
}
GraphUnit represents a table and its relationships for graph visualization.
type GraphUnitRelationship ¶
type GraphUnitRelationship struct {
Name string
RelationshipType GraphUnitRelationshipType
SourceColumn *string
TargetColumn *string
}
GraphUnitRelationship describes a foreign key relationship between two tables.
type GraphUnitRelationshipType ¶
type GraphUnitRelationshipType string
GraphUnitRelationshipType defines the cardinality of a relationship between tables.
type LoginProfileRetriever ¶
type LoginProfileRetriever func() ([]types.DatabaseCredentials, error)
LoginProfileRetriever is a function that retrieves stored database credentials.
type Plugin ¶
type Plugin struct {
PluginFunctions
Type DatabaseType
}
Plugin wraps PluginFunctions with a database type identifier.
type PluginConfig ¶
type PluginConfig struct {
Credentials *Credentials
ExternalModel *ExternalModel
}
PluginConfig contains all configuration needed to connect to and operate on a database.
func NewPluginConfig ¶
func NewPluginConfig(credentials *Credentials) *PluginConfig
NewPluginConfig creates a new PluginConfig with the given credentials.
type PluginFunctions ¶
type PluginFunctions interface {
GetDatabases(config *PluginConfig) ([]string, error)
IsAvailable(config *PluginConfig) bool
GetAllSchemas(config *PluginConfig) ([]string, error)
GetStorageUnits(config *PluginConfig, schema string) ([]StorageUnit, error)
StorageUnitExists(config *PluginConfig, schema string, storageUnit string) (bool, error)
AddStorageUnit(config *PluginConfig, schema string, storageUnit string, fields []Record) (bool, error)
UpdateStorageUnit(config *PluginConfig, schema string, storageUnit string, values map[string]string, updatedColumns []string) (bool, error)
AddRow(config *PluginConfig, schema string, storageUnit string, values []Record) (bool, error)
DeleteRow(config *PluginConfig, schema string, storageUnit string, values map[string]string) (bool, error)
GetRows(config *PluginConfig, schema string, storageUnit string, where *model.WhereCondition, sort []*model.SortCondition, pageSize int, pageOffset int) (*GetRowsResult, error)
GetRowCount(config *PluginConfig, schema string, storageUnit string, where *model.WhereCondition) (int64, error)
GetGraph(config *PluginConfig, schema string) ([]GraphUnit, error)
RawExecute(config *PluginConfig, query string) (*GetRowsResult, error)
Chat(config *PluginConfig, schema string, previousConversation string, query string) ([]*ChatMessage, error)
ExportData(config *PluginConfig, schema string, storageUnit string, writer func([]string) error, selectedRows []map[string]any) error
FormatValue(val any) string
GetColumnsForTable(config *PluginConfig, schema string, storageUnit string) ([]Column, error)
// Mock data generation methods
GetColumnConstraints(config *PluginConfig, schema string, storageUnit string) (map[string]map[string]any, error)
ClearTableData(config *PluginConfig, schema string, storageUnit string) (bool, error)
// Foreign key detection
GetForeignKeyRelationships(config *PluginConfig, schema string, storageUnit string) (map[string]*ForeignKeyRelationship, error)
// Transaction support
WithTransaction(config *PluginConfig, operation func(tx any) error) error
// Database metadata for frontend type/operator configuration
GetDatabaseMetadata() *DatabaseMetadata
}
PluginFunctions defines the interface that all database plugins must implement. Each method provides a specific database operation capability.
type Record ¶
Record represents a key-value pair with optional extra metadata, used for column attributes, configuration, and data transfer.
type StorageUnit ¶
StorageUnit represents a database table, collection, or equivalent storage structure.
type TypeCategory ¶
type TypeCategory string
TypeCategory represents the category of a database type for UI grouping
const ( TypeCategoryNumeric TypeCategory = "numeric" TypeCategoryText TypeCategory = "text" TypeCategoryBinary TypeCategory = "binary" TypeCategoryDatetime TypeCategory = "datetime" TypeCategoryBoolean TypeCategory = "boolean" TypeCategoryJSON TypeCategory = "json" TypeCategoryOther TypeCategory = "other" )
type TypeDefinition ¶
type TypeDefinition struct {
ID string // Canonical type name (e.g., "VARCHAR", "INTEGER")
Label string // Display label for UI (e.g., "varchar", "integer")
HasLength bool // Shows length input when selected (VARCHAR, CHAR)
HasPrecision bool // Shows precision/scale inputs (DECIMAL, NUMERIC)
DefaultLength *int // Default length for types with HasLength
DefaultPrecision *int // Default precision for types with HasPrecision
Category TypeCategory // Type category for grouping
}
TypeDefinition describes a database column type with its metadata
type UnsupportedTypeError ¶
UnsupportedTypeError is returned when a column type is not supported by the database
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string