Documentation
¶
Index ¶
- func BuildChartQuery(config *ChartConfig) (string, []interface{}, error)
- func GetCompositeTypes(db *sqlx.DB, schemaName string) (map[string][]CompositeTypeAttribute, error)
- func GetCustomTypesWithDetails(db *sqlx.DB, schemaName string) (map[string]interface{}, error)
- func GetEnumTypes(db *sqlx.DB, schemaName string) (map[string][]EnumValue, error)
- func GetTablesPostgreSQL(db *sqlx.DB) ([]string, error)
- func MarshalChartConfig(config *ChartConfig) (string, error)
- func SaveChartConfigToFile(config *ChartConfig, filename string) error
- func ToSql(c *ChartConfig) (string, []interface{}, error)
- func ValidateAndNormalizeConfig(config *ChartConfig) error
- type AxisConfig
- type ChartConfig
- type ChartDataRow
- type ChartOptions
- type ColumnInfo
- type CompositeTypeAttribute
- type CustomType
- type DomainInfo
- type EnumValue
- type FilterConfig
- type JoinConfig
- type OrderConfig
- type TableConfig
- type TableInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildChartQuery ¶
func BuildChartQuery(config *ChartConfig) (string, []interface{}, error)
func GetCompositeTypes ¶
GetCompositeTypes returns all composite types with their attributes
func GetCustomTypesWithDetails ¶
GetCustomTypesWithDetails returns all custom types with their detailed information
func GetEnumTypes ¶
GetEnumTypes returns all ENUM types with their values
func MarshalChartConfig ¶
func MarshalChartConfig(config *ChartConfig) (string, error)
MarshalChartConfig marshals a ChartConfig struct to a JSON string
func SaveChartConfigToFile ¶
func SaveChartConfigToFile(config *ChartConfig, filename string) error
SaveChartConfigToFile marshals and saves a chart configuration to a file
func ToSql ¶
func ToSql(c *ChartConfig) (string, []interface{}, error)
func ValidateAndNormalizeConfig ¶
func ValidateAndNormalizeConfig(config *ChartConfig) error
ValidateAndNormalizeConfig validates and normalizes a chart configuration
Types ¶
type AxisConfig ¶
type AxisConfig struct {
Column string `json:"column"` // "created_at", "amount", "COUNT(*)"
Label string `json:"label"` // Human-readable label
Aggregation string `json:"aggregation"` // "SUM", "COUNT", "AVG", "MIN", "MAX"
DataType string `json:"data_type"` // "numeric", "datetime", "string"
Format string `json:"format,omitempty"` // "currency", "percentage", "date"
Alias string `json:"alias,omitempty"` // NEW
}
type ChartConfig ¶
type ChartConfig struct {
// Chart basics
ChartType string `json:"chart_type"` // "line", "bar", "pie", "scatter", "area", "histogram"
Title string `json:"title"`
Description string `json:"description"`
// Data source
Tables []TableConfig `json:"tables"`
// Axes configuration
XAxis AxisConfig `json:"x_axis"`
YAxis []AxisConfig `json:"y_axis"` // Array to support multiple Y series
// Aggregation and grouping
GroupBy []string `json:"group_by"`
Filters []FilterConfig `json:"filters"`
// Chart-specific options
Options ChartOptions `json:"options"`
// Query limits
Limit int `json:"limit"`
OrderBy []OrderConfig `json:"order_by"`
}
func ParseChartConfigFromFile ¶
func ParseChartConfigFromFile(filename string) (*ChartConfig, error)
ParseChartConfigFromFile reads and unmarshals a chart configuration from a file
func ParseMultipleConfigs ¶
func ParseMultipleConfigs(jsonArrayStr string) ([]*ChartConfig, error)
ParseMultipleConfigs parses multiple chart configurations from a JSON array string
func UnmarshalChartConfig ¶
func UnmarshalChartConfig(jsonStr string) (*ChartConfig, error)
UnmarshalChartConfig unmarshals a JSON string into a ChartConfig struct
func UnmarshalChartConfigs ¶
func UnmarshalChartConfigs(jsonStr string) ([]*ChartConfig, error)
UnmarshalChartConfigs unmarshals a JSON array of chart configurations
type ChartDataRow ¶
type ChartDataRow struct {
XValue interface{} `json:"x_value"`
YValues interface{} `json:"y_values"` // this removes being boxed to an array of values, we can use maps
}
func ScanDynamicChart ¶
func ScanDynamicChart(rows *sqlx.Rows) ([]ChartDataRow, error)
ScanDynamicChart scans chart data with an unknown number of Y-values
type ChartOptions ¶
type ChartOptions struct {
// Visual options
Width int `json:"width"`
Height int `json:"height"`
Theme string `json:"theme"`
// Chart-specific
Stacked bool `json:"stacked,omitempty"` // For bar/area charts
ShowLegend bool `json:"show_legend"`
ShowGrid bool `json:"show_grid"`
// Date/time specific
DateFormat string `json:"date_format,omitempty"`
TimeInterval string `json:"time_interval,omitempty"` // "day", "week", "month", "year"
// Colors
Colors []string `json:"colors,omitempty"`
}
type ColumnInfo ¶
type ColumnInfo struct {
Name string `db:"column_name"`
DataType string `db:"data_type"`
IsNullable string `db:"is_nullable"`
DefaultValue *string `db:"column_default"`
MaxLength *int `db:"character_maximum_length"`
Position int `db:"ordinal_position"`
IsPrimaryKey bool `db:"is_primary_key"`
Comment string `db:"column_comment"`
}
ColumnInfo represents detailed information about a database column
func GetColumnInfoPostgreSQL ¶
func GetColumnInfoPostgreSQL(db *sqlx.DB, tableName string) ([]ColumnInfo, error)
type CompositeTypeAttribute ¶
type CompositeTypeAttribute struct {
TypeName string `db:"type_name"`
AttributeName string `db:"attribute_name"`
DataType string `db:"data_type"`
Position int `db:"position"`
IsNullable bool `db:"is_nullable"`
DefaultValue *string `db:"default_value"`
}
CompositeTypeAttribute represents an attribute of a composite type
type CustomType ¶
type CustomType struct {
SchemaName string `db:"schema_name"`
TypeName string `db:"type_name"`
TypeType string `db:"type_type"`
Category string `db:"category"`
Owner string `db:"owner"`
Description *string `db:"description"`
}
CustomType represents a PostgreSQL custom type
func GetAllCustomTypes ¶
func GetAllCustomTypes(db *sqlx.DB, schemaName string) ([]CustomType, error)
GetAllCustomTypes returns all custom types in the database
func GetRangeTypes ¶
func GetRangeTypes(db *sqlx.DB, schemaName string) ([]CustomType, error)
GetRangeTypes returns all range types
type DomainInfo ¶
type DomainInfo struct {
SchemaName string `db:"schema_name"`
DomainName string `db:"domain_name"`
DataType string `db:"data_type"`
IsNullable bool `db:"is_nullable"`
DefaultValue *string `db:"default_value"`
CheckClause *string `db:"check_clause"`
Description *string `db:"description"`
}
DomainInfo represents a domain type with its constraints
func GetDomainTypes ¶
func GetDomainTypes(db *sqlx.DB, schemaName string) ([]DomainInfo, error)
GetDomainTypes returns all domain types with their constraints
type EnumValue ¶
type EnumValue struct {
TypeName string `db:"type_name"`
EnumLabel string `db:"enum_label"`
SortOrder int `db:"sort_order"`
}
EnumValue represents a value in an ENUM type
type FilterConfig ¶
type FilterConfig struct {
Column string `json:"column"`
Operator string `json:"operator"` // "=", "!=", ">", "<", ">=", "<=", "IN", "LIKE", "BETWEEN"
Value interface{} `json:"value"`
Values []interface{} `json:"values,omitempty"` // For IN operator
Raw string // NEW: if set, use as-is (with placeholders)
RawValues []interface{} // NEW: bind params for Raw
}
type JoinConfig ¶
type OrderConfig ¶
type TableConfig ¶
type TableConfig struct {
Name string `json:"name"`
Alias string `json:"alias,omitempty"`
Joins []JoinConfig `json:"joins,omitempty"`
}
type TableInfo ¶
type TableInfo struct {
Name string
Columns []ColumnInfo
}