Shared TypeScript library for the Lightdash platform containing common types, utilities, and business logic for analytics workflows
Overall
score
72%
Evaluation — 72%
↑ 1.09xAgent success when using this tile
Feature flag definitions for controlling experimental and optional features in Lightdash.
Enumeration of all available feature flags in the system.
enum FeatureFlags {
/** Show user groups functionality */
UserGroupsEnabled = 'user-groups-enabled',
/** Send local timezone to the warehouse session */
EnableUserTimezones = 'enable-user-timezones',
/** Enable dashboard comments */
DashboardComments = 'dashboard-comments-enabled',
/** Enable scheduler task that replaces custom metrics after project compile */
ReplaceCustomMetricsOnCompile = 'replace-custom-metrics-on-compile',
/**
* Enable the dynamic calculation of series color, when not manually set on the chart config.
* This aims to make the colors more consistent, depending on the groups.
*/
CalculateSeriesColor = 'calculate-series-color',
/** Enable the ability to write back custom bin dimensions to dbt */
WriteBackCustomBinDimensions = 'write-back-custom-bin-dimensions',
/** Enable the ability to show the warehouse execution time and total time in the chart tile */
ShowExecutionTime = 'show-execution-time',
/** Enable the ability to create custom visualizations with AI */
AiCustomViz = 'ai-custom-viz',
/** Enable BigQuery SSO authentication */
BigquerySSO = 'bigquery-sso',
/** Use workers for async query execution */
WorkerQueryExecution = 'worker-query-execution',
/** Enable SQL pivot results conversion to PivotData format */
UseSqlPivotResults = 'use-sql-pivot-results',
/** Enable map chart type visualization */
Maps = 'maps',
/** Enable the unused content dashboard showing least viewed charts and dashboards */
UnusedContentDashboard = 'unused-content-dashboard',
/** Enable period-over-period comparisons option */
PeriodOverPeriod = 'pop',
/** Dark mode */
DarkMode = 'dark-mode'
}Type for representing a feature flag with its enabled status.
interface FeatureFlag {
id: string;
enabled: boolean;
}Type guard for checking if a string is a valid feature flag.
/**
* Check if a value is a valid FeatureFlags enum value
* @param value - String value to check
* @returns True if value is a valid feature flag
*/
function isFeatureFlags(value: string): value is FeatureFlags;import { FeatureFlags, type FeatureFlag } from '@lightdash/common';
// Check if dark mode is enabled
function isDarkModeEnabled(flags: FeatureFlag[]): boolean {
const darkModeFlag = flags.find(flag => flag.id === FeatureFlags.DarkMode);
return darkModeFlag?.enabled ?? false;
}
// Check multiple feature flags
function getEnabledFeatures(flags: FeatureFlag[]): string[] {
return flags
.filter(flag => flag.enabled)
.map(flag => flag.id);
}import { FeatureFlags, isFeatureFlags } from '@lightdash/common';
function shouldShowFeature(featureFlagId: string, enabledFlags: FeatureFlag[]): boolean {
// Validate the feature flag exists
if (!isFeatureFlags(featureFlagId)) {
console.warn(`Unknown feature flag: ${featureFlagId}`);
return false;
}
const flag = enabledFlags.find(f => f.id === featureFlagId);
return flag?.enabled ?? false;
}
// Usage example
const showMaps = shouldShowFeature(FeatureFlags.Maps, userFeatureFlags);
const showAiViz = shouldShowFeature(FeatureFlags.AiCustomViz, userFeatureFlags);import { FeatureFlags, type FeatureFlag } from '@lightdash/common';
// Create a feature flag configuration
const defaultFlags: FeatureFlag[] = [
{ id: FeatureFlags.EnableUserTimezones, enabled: true },
{ id: FeatureFlags.DashboardComments, enabled: true },
{ id: FeatureFlags.DarkMode, enabled: false },
{ id: FeatureFlags.AiCustomViz, enabled: false },
{ id: FeatureFlags.Maps, enabled: false }
];
// Helper to check if experimental features are enabled
function hasExperimentalFeatures(flags: FeatureFlag[]): boolean {
const experimentalFlags = [
FeatureFlags.AiCustomViz,
FeatureFlags.Maps,
FeatureFlags.CalculateSeriesColor
];
return flags.some(flag =>
experimentalFlags.includes(flag.id as FeatureFlags) && flag.enabled
);
}EnableUserTimezones - Timezone support for queriesDarkMode - Dark theme supportDashboardComments - Dashboard commenting functionalityUserGroupsEnabled - User groups and permissionsMaps - Geographic map visualizationsAiCustomViz - AI-powered custom visualizationsCalculateSeriesColor - Dynamic series color calculationPeriodOverPeriod - Period comparison analysisWorkerQueryExecution - Async query execution with workersUseSqlPivotResults - SQL-based pivot resultsShowExecutionTime - Query execution time displayBigquerySSO - BigQuery SSO authenticationWriteBackCustomBinDimensions - Write custom bins to dbtUnusedContentDashboard - Content usage analyticsReplaceCustomMetricsOnCompile - Auto-update custom metricsInstall with Tessl CLI
npx tessl i tessl/npm-lightdash--commondocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20