Quick reference for key types in @lightdash/common. For detailed documentation, see the Core Types API.
interface Explore {
name: string;
label: string;
baseTable: string;
tables: Record<string, CompiledTable>;
joinedTables: CompiledExploreJoin[];
// ... additional properties
}Main data model containing tables, dimensions, and metrics.
interface Dimension {
fieldType: 'dimension';
type: DimensionType;
name: string;
label: string;
table: string;
sql: string;
// ... additional properties
}
interface Metric {
fieldType: 'metric';
type: MetricType;
name: string;
label: string;
table: string;
sql: string;
// ... additional properties
}Dimension Types: string, number, timestamp, date, boolean
Metric Types: count, count_distinct, sum, average, min, max, percentile, number
interface MetricQuery {
exploreName: string;
dimensions: FieldId[];
metrics: FieldId[];
filters: Filters;
sorts: SortField[];
limit: number;
tableCalculations: TableCalculation[];
additionalMetrics?: AdditionalMetric[];
customDimensions?: CustomDimension[];
}Defines what data to fetch from an explore.
interface Filters {
dimensions?: FilterGroup;
metrics?: FilterGroup;
tableCalculations?: FilterGroup;
}
type FilterGroup = {
id: string;
and: (FilterGroup | FilterRule)[];
} | {
id: string;
or: (FilterGroup | FilterRule)[];
};
interface FilterRule {
id: string;
target: { fieldId: string };
operator: FilterOperator;
values?: any[];
}Common Operators: equals, notEquals, greaterThan, lessThan, inThePast, inTheNext, inBetween, startsWith, include
interface Dashboard {
uuid: string;
name: string;
projectUuid: string;
tiles: DashboardTile[];
filters: DashboardFilters;
// ... additional properties
}interface SavedChart {
uuid: string;
name: string;
projectUuid: string;
tableName: string;
metricQuery: MetricQuery;
chartConfig: ChartConfig;
// ... additional properties
}Chart Types: bar, line, area, scatter, pie, table, big_number
interface CustomFormat {
type: CustomFormatType;
round?: number;
separator?: NumberSeparator;
currency?: string;
compact?: Compact;
prefix?: string;
suffix?: string;
}Format Types: default, percent, currency, number, date, timestamp
Compact Options: thousands (K), millions (M), billions (B), trillions (T)
type MemberAbility = Ability<[AbilityAction, Subject]>;
// Usage
const ability = defineUserAbility(user, projectProfiles);
ability.can('view', 'Dashboard') // boolean
ability.can('update', 'SavedChart') // booleanActions: view, create, update, delete, manage, export, promote
Subjects: Dashboard, SavedChart, Space, Project, Organization, Explore, etc.
interface WarehouseClient {
credentials: WarehouseCredentials;
runQuery(sql: string): Promise<WarehouseResults>;
getCatalog(): Promise<WarehouseCatalog>;
// ... additional methods
}Warehouse Types: bigquery, postgres, snowflake, redshift, databricks, trino, clickhouse
class ExploreCompiler {
constructor(warehouseSqlBuilder: WarehouseSqlBuilder);
compileExplore(uncompiledExplore: UncompiledExplore): Explore;
compileDimension(dimension: Dimension, ...): CompiledDimension;
compileMetric(metric: Metric, ...): CompiledMetric;
}Compiles dbt models into executable explores.
// Get fields from explore
getFields(explore: Explore): CompiledField[]
getDimensions(explore: Explore): CompiledDimension[]
getMetrics(explore: Explore): CompiledMetric[]
// Create maps for O(1) lookups
getFieldMap(explore: Explore, ...): Record<string, Field>
getItemMap(explore: Explore, ...): ItemsMap
// Formatting
formatItemValue(item: Item, value: any): string
formatDate(date: Date, timeInterval?: TimeFrames): string
formatNumberValue(value: number, format?: Format): string// Field type checks
isField(value: any): value is Field
isDimension(field: Field): field is Dimension
isMetric(field: Field): field is Metric
// Filter checks
isFilterGroup(value: any): value is FilterGroup
isFilterRule(value: any): value is FilterRule
// Custom dimension checks
isCustomDimension(value: any): value is CustomDimension
isTableCalculation(value: any): value is TableCalculationNULL, NOT_NULL, EQUALS, NOT_EQUALS, STARTS_WITH, ENDS_WITH, INCLUDE, NOT_INCLUDE, LESS_THAN, GREATER_THAN, IN_THE_PAST, IN_THE_NEXT, IN_THE_CURRENT, IN_BETWEEN
VERTICAL_BAR, HORIZONTAL_BAR, LINE, AREA, SCATTER, PIE, TABLE, BIG_NUMBER, FUNNEL
DAY, WEEK, MONTH, QUARTER, YEAR, HOUR, MINUTE, SECOND
STRING, NUMBER, TIMESTAMP, DATE, BOOLEAN
COUNT, COUNT_DISTINCT, SUM, AVERAGE, MIN, MAX, PERCENTILE, NUMBER
For complete API documentation with examples, see: