Documentation
¶
Index ¶
- Variables
- func DeriveFacets(vc *ViewConfig)
- func ExportData[T any](data []T, payload *Payload, typeName string) (string, error)
- func IsCacheError(err error) bool
- func IsSDKError(err error) bool
- func IsValidationError(err error) bool
- func NormalizeFields(fields *[]FieldConfig)
- func RegisterDataFacet(df DataFacet)
- func SetMenuOrder(vc *ViewConfig)
- func SortFields(vc *ViewConfig)
- type ActionConfig
- type Bucket
- type BucketInterface
- type BucketStats
- type Buckets
- func (b *Buckets) EnsureSeriesExists(name string)
- func (b *Buckets) GetSeries(name string) []Bucket
- func (b *Buckets) SetAssetName(assetIdentifier string, assetName *coreTypes.Name)
- func (b *Buckets) SetSeries(name string, buckets []Bucket)
- func (b *Buckets) UpdateSeries(name string, updateFunc func([]Bucket) []Bucket)
- type Collection
- type CollectionError
- func NewCacheError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
- func NewSDKError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
- func NewStoreError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
- func NewValidationError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
- type ColumnConfig
- type Crud
- type DataFacet
- type DataLoadedPayload
- type DetailPanelConfig
- type DetailRendererConfig
- type ErrorType
- type FacetChartConfig
- type FacetConfig
- type FieldConfig
- type GridInfo
- type MetricConfig
- type NavigationPayload
- type NavigationTarget
- type Page
- type PanelChartConfig
- type Payload
- type Period
- type ProjectPayload
- type RowActionConfig
- type RowActionPayload
- type RowIdentifier
- type StoreState
- type Summary
- type SummaryAccumulator
- type ViewConfig
Constants ¶
This section is empty.
Variables ¶
var AllCruds = []struct { Value crud.Operation `json:"value"` TSName string `json:"tsname"` }{ {crud.Create, "CREATE"}, {crud.Update, "UPDATE"}, {crud.Delete, "DELETE"}, {crud.Undelete, "UNDELETE"}, {crud.Remove, "REMOVE"}, {crud.Autoname, "AUTONAME"}, }
var ( AllDataFacets = []struct { Value DataFacet `json:"value"` TSName string `json:"tsname"` }{} )
var AllPeriods = []struct { Value Period `json:"value"` TSName string `json:"tsname"` }{ {PeriodBlockly, "BLOCKLY"}, {PeriodHourly, "HOURLY"}, {PeriodDaily, "DAILY"}, {PeriodWeekly, "WEEKLY"}, {PeriodMonthly, "MONTHLY"}, {PeriodQuarterly, "QUARTERLY"}, {PeriodAnnual, "ANNUAL"}, }
var AllStates = []struct { Value StoreState `json:"value"` TSName string `json:"tsname"` }{ {StateStale, "STALE"}, {StateFetching, "FETCHING"}, {StateLoaded, "LOADED"}, }
Functions ¶
func DeriveFacets ¶
func DeriveFacets(vc *ViewConfig)
DeriveFacets populates Columns and DetailPanels from Fields when present. It preserves existing Columns/DetailPanels if Fields is empty.
func ExportData ¶
ExportData is the unified export function that handles file creation with proper extension and format
func IsCacheError ¶
IsCacheError checks if an error is a cache-related error
func IsSDKError ¶
IsSDKError checks if an error is an SDK operation error
func IsValidationError ¶
IsValidationError checks if an error is a validation error
func NormalizeFields ¶
func NormalizeFields(fields *[]FieldConfig)
NormalizeFields normalizes field configurations in place.
func RegisterDataFacet ¶
func RegisterDataFacet(df DataFacet)
func SetMenuOrder ¶
func SetMenuOrder(vc *ViewConfig)
SetMenuOrder applies menu ordering and facet configurations from embedded or file-based config to ViewConfig. When TB_ALLVIEWS environment variable is set, ordering and disabled state configurations are ignored.
func SortFields ¶
func SortFields(vc *ViewConfig)
SortFields sorts columns and detail fields by their explicit order values. It does not assign defaults; ordering must be provided in config.
Types ¶
type ActionConfig ¶
type ActionConfig struct {
Name string `json:"name"`
Label string `json:"label"`
Icon string `json:"icon"`
Confirmation bool `json:"confirmation"`
}
ActionConfig represents an available action (delete, remove, etc.)
type Bucket ¶
type BucketInterface ¶
type BucketInterface interface {
GetBuckets() *Buckets
ClearBuckets()
SetBuckets(buckets *Buckets)
UpdateBuckets(updateFunc func(*Buckets))
}
BucketInterface defines bucket operations that facets must implement
type BucketStats ¶
type BucketStats struct {
Total float64 `json:"total"`
Average float64 `json:"average"`
Min float64 `json:"min"`
Max float64 `json:"max"`
Count int `json:"count"`
}
func NewBucketStats ¶
func NewBucketStats() BucketStats
NewBucketStats creates a new BucketStats with zero values
type Buckets ¶
type Buckets struct {
// Flexible series structure using named metrics
Series map[string][]Bucket `json:"series"`
AssetNames map[string]*coreTypes.Name `json:"assetNames,omitempty"` // Maps series prefix to asset name
GridInfo GridInfo `json:"gridInfo"`
}
func NewBuckets ¶
func NewBuckets() *Buckets
NewBuckets creates a new Buckets struct with proper initialization
func NewBucketsWithGridInfo ¶
NewBuckets creates a new Buckets struct with proper initialization
func (*Buckets) EnsureSeriesExists ¶
EnsureSeriesExists ensures a series exists, creating it if necessary
func (*Buckets) SetAssetName ¶
SetAssetName stores the asset name for a series prefix (e.g., "0x1234567890ab_ETH")
type Collection ¶
type Collection interface {
GetPage(payload *Payload, first, pageSize int, sort sdk.SortSpec, filter string) (Page, error)
FetchByFacet(payload *Payload)
Reset(payload *Payload)
NeedsUpdate(payload *Payload) bool
GetSummary(payload *Payload) Summary
ExportData(payload *Payload) (string, error)
ChangeVisibility(payload *Payload) error
GetConfig() (*ViewConfig, error)
SummaryAccumulator
}
type CollectionError ¶
type CollectionError struct {
Type ErrorType
Operation string
Collection string
DataFacet DataFacet
Underlying error
Message string
}
CollectionError provides structured error information with context
func NewCacheError ¶
func NewCacheError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
NewCacheError creates an error for cache-related failures
func NewSDKError ¶
func NewSDKError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
NewSDKError creates an error for SDK operation failures
func NewStoreError ¶
func NewStoreError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
NewStoreError creates an error for store operation failures
func NewValidationError ¶
func NewValidationError(collection string, dataFacet DataFacet, operation string, err error) *CollectionError
NewValidationError creates an error for invalid parameters or configuration
func (*CollectionError) Error ¶
func (e *CollectionError) Error() string
func (*CollectionError) Unwrap ¶
func (e *CollectionError) Unwrap() error
type ColumnConfig ¶
type ColumnConfig struct {
Key string `json:"key"`
Header string `json:"header"`
Width int `json:"width"`
Sortable bool `json:"sortable"`
Type string `json:"type"`
Order int `json:"order"`
}
ColumnConfig represents a table column configuration
type DataLoadedPayload ¶
type DataLoadedPayload struct {
Payload
CurrentCount int `json:"currentCount"`
ExpectedTotal int `json:"expectedTotal"`
State StoreState `json:"state"`
Summary Summary `json:"summary"`
Error string `json:"error,omitempty"`
Timestamp int64 `json:"timestamp"`
EventPhase string `json:"eventPhase"`
Operation string `json:"operation,omitempty"`
}
type DetailPanelConfig ¶
type DetailPanelConfig struct {
Title string `json:"title"`
Collapsed bool `json:"collapsed"`
Fields []DetailRendererConfig `json:"fields"`
}
DetailPanelConfig represents a detail panel section
type DetailRendererConfig ¶
type DetailRendererConfig struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"`
DetailOrder int `json:"detailOrder"`
}
DetailRendererConfig represents a field in a detail panel
type ErrorType ¶
type ErrorType string
ErrorType represents different categories of errors that can occur
type FacetChartConfig ¶
type FacetChartConfig struct {
SeriesStrategy string `json:"seriesStrategy,omitempty"` // how to group data into series ("address", "symbol", "address+symbol")
SeriesPrefixLen int `json:"seriesPrefixLen,omitempty"` // prefix length for collision avoidance (8-15)
}
FacetChartConfig represents facet-level chart configuration
type FacetConfig ¶
type FacetConfig struct {
Name string `json:"name"`
Store string `json:"store"`
ViewType string `json:"viewType,omitempty"`
DividerBefore bool `json:"dividerBefore"`
Disabled bool `json:"disabled"`
CanClose bool `json:"canClose"`
Fields []FieldConfig `json:"fields"`
Columns []ColumnConfig `json:"columns"`
DetailPanels []DetailPanelConfig `json:"detailPanels"`
Actions []string `json:"actions"`
HeaderActions []string `json:"headerActions"`
Panel string `json:"panel"`
PanelChartConfig *PanelChartConfig `json:"panelChartConfig,omitempty"`
FacetChartConfig *FacetChartConfig `json:"facetChartConfig,omitempty"`
RowAction *RowActionConfig `json:"rowAction,omitempty"`
}
FacetConfig represents configuration for a single facet within a view
type FieldConfig ¶
type FieldConfig struct {
Key string `json:"key"`
Label string `json:"label"`
Type string `json:"type"`
Section string `json:"section"`
Width int `json:"width"`
Sortable bool `json:"sortable"`
Order int `json:"order"`
DetailOrder int `json:"detailOrder"`
NoTable bool `json:"-"`
NoDetail bool `json:"-"`
ColumnLabel string `json:"-"`
DetailLabel string `json:"-"`
}
FieldConfig is the single source-of-truth for facet fields Header is derived from Label; do not duplicate.
type GridInfo ¶
type GridInfo struct {
Rows int `json:"rows"`
Columns int `json:"columns"`
MaxBlock uint64 `json:"maxBlock"`
Size uint64 `json:"size"`
BucketCount int `json:"bucketCount"`
}
func NewGridInfo ¶
func NewGridInfo() GridInfo
NewGridInfo creates a new GridInfo with proper default values
type MetricConfig ¶
type MetricConfig struct {
Key string `json:"key"` // unique identifier
Label string `json:"label"` // display name
BucketsField string `json:"bucketsField"` // field name in Buckets struct
Bytes bool `json:"bytes"` // whether to format as bytes
}
MetricConfig represents a single metric configuration
type NavigationPayload ¶
type NavigationPayload struct {
}
type NavigationTarget ¶
type NavigationTarget struct {
}
NavigationTarget defines the destination for row navigation actions
type Page ¶
type Page interface {
GetFacet() DataFacet
GetTotalItems() int
GetExpectedTotal() int
GetState() StoreState
}
type PanelChartConfig ¶
type PanelChartConfig struct {
Type string `json:"type"` // "barchart" or "heatmap"
DefaultMetric string `json:"defaultMetric"` // key of default metric
SkipUntil string `json:"skipUntil,omitempty"` // optional date filter
TimeGroupBy string `json:"timeGroupBy,omitempty"` // "daily", "monthly", "quarterly", "annual"
Metrics []MetricConfig `json:"metrics"` // available metrics
}
PanelChartConfig represents visualization panel configuration
type Payload ¶
type Payload struct {
Collection string `json:"collection"`
DataFacet DataFacet `json:"dataFacet"`
ActiveChain string `json:"activeChain,omitempty"`
ActiveAddress string `json:"activeAddress,omitempty"`
ActiveContract string `json:"activeContract,omitempty"`
ActivePeriod Period `json:"activePeriod,omitempty"`
ConnectedAddress string `json:"connectedAddress,omitempty"`
TargetAddress string `json:"targetAddress,omitempty"`
TargetSwitch bool `json:"targetSwitch,omitempty"`
Format string `json:"format,omitempty"`
ProjectPath string `json:"projectPath,omitempty"`
}
func (*Payload) ShouldSummarize ¶
type Period ¶
type Period string
Period represents different time aggregation levels
const ( PeriodBlockly Period = "blockly" // Default - no aggregation, raw data PeriodHourly Period = "hourly" PeriodDaily Period = "daily" PeriodWeekly Period = "weekly" PeriodMonthly Period = "monthly" PeriodQuarterly Period = "quarterly" PeriodAnnual Period = "annual" )
Period constants for different time aggregation levels
type ProjectPayload ¶
type ProjectPayload struct {
HasProject bool `json:"hasProject"`
ActiveChain string `json:"activeChain"`
ActivePeriod Period `json:"activePeriod"`
ActiveAddress string `json:"activeAddress"`
ActiveContract string `json:"activeContract"`
LastView string `json:"lastView"`
LastFacetMap map[string]DataFacet `json:"lastFacetMap"`
}
type RowActionConfig ¶
type RowActionConfig struct {
Type string `json:"type"` // "navigate", "modal", "custom", "none"
Target *NavigationTarget `json:"target,omitempty"` // For navigation actions
CustomHandler string `json:"customHandler,omitempty"` // For custom actions
Parameters map[string]interface{} `json:"parameters,omitempty"` // Additional parameters
}
RowActionConfig defines what happens when a user presses Enter on a table row
func NewRowActionNavigation ¶
func NewRowActionNavigation(targetView, targetFacet, fieldType, fieldName string) *RowActionConfig
NewRowActionNavigation creates a navigation row action with sensible defaults
type RowActionPayload ¶
type RowActionPayload struct {
Payload
RowData map[string]interface{} `json:"rowData"`
RowAction *RowActionConfig `json:"rowAction"`
ContextValues map[string]interface{} `json:"contextValues,omitempty"` // Processed context values
}
type RowIdentifier ¶
type RowIdentifier struct {
Type string `json:"type"` // "address", "hash", "blockRange"
FieldName string `json:"fieldName"` // Field name to extract from row data
ContextKey string `json:"contextKey,omitempty"` // Key to use in context (defaults to Type)
}
RowIdentifier represents different ways to identify/extract context from a row
type StoreState ¶
type StoreState string
const ( StateStale StoreState = "stale" // Needs refresh StateFetching StoreState = "fetching" // Currently loading StateLoaded StoreState = "loaded" // Complete data )
type SummaryAccumulator ¶
type ViewConfig ¶
type ViewConfig struct {
ViewName string `json:"viewName"`
Disabled bool `json:"disabled"`
Facets map[string]FacetConfig `json:"facets"`
Actions map[string]ActionConfig `json:"actions"`
FacetOrder []string `json:"facetOrder"`
MenuOrder int `json:"menuOrder,omitempty"`
MenuPosition string `json:"menuPosition,omitempty"`
MenuLabel string `json:"menuLabel,omitempty"`
}
ViewConfig represents the complete configuration for a view
func (*ViewConfig) IsDisabled ¶
func (vc *ViewConfig) IsDisabled() bool
IsDisabled returns true if the view is disabled or all its facets are disabled