import type { AdditionalMetric, CustomDimension, Filter, InternalFilterDefinition, ParametersValuesMap, Sort, TableCalculation } from './types'; /** * A reference to a saved Lightdash chart, run live by UUID via * `POST /query/chart` instead of an inline metric query. Produced by the * `savedChart(uuid)` factory and accepted by `useLightdash`. * * CRITICAL: this mirrors the ENTIRE chainable `QueryBuilder` surface. Generated * apps chain builder methods on every query (`.dimensions().metrics().filters() * .metricFilters().sorts().label().limit()…`); calling a method that doesn't exist on a plain * object throws `TypeError: X is not a function` and crashes the whole app. So a * linked chart must be exactly as crash-safe as a normal query — every method * below exists and is chainable. * * A saved chart's structure is governed by the chart itself, so the structural * methods (dimensions/metrics/sorts/table-calcs/additional-metrics/ * custom-dimensions) are accepted but IGNORED. `.label()`, `.limit()`, * `.parameters()` and `.filters()` affect the run — the `/query/chart` * endpoint supports them. * * If you add a method to `QueryBuilder`, add it here too (see savedChart.test.ts, * which chains every QueryBuilder method to guard against a missing one). */ export type SavedChartQuery = { kind: 'savedChart'; chartUuid: string; /** Captured `.label()` value — surfaced in the query inspector. */ labelText?: string; /** Captured `.limit()` value — sent to /query/chart. */ limitValue?: number; /** Captured `.parameters()` values — sent to /query/chart. */ parameterValues?: ParametersValuesMap; /** Captured .filters() — ANDed onto the chart's filters server-side. Field ids are qualified (e.g. orders_status). */ filterValues?: InternalFilterDefinition[]; label: (name: string) => SavedChartQuery; limit: (n: number) => SavedChartQuery; parameters: (map: ParametersValuesMap) => SavedChartQuery; filters: (filters: Filter[]) => SavedChartQuery; dimensions: (fields: string[]) => SavedChartQuery; metrics: (fields: string[]) => SavedChartQuery; sorts: (sorts: Sort[]) => SavedChartQuery; tableCalculations: (calcs: TableCalculation[]) => SavedChartQuery; additionalMetrics: (metrics: AdditionalMetric[]) => SavedChartQuery; customDimensions: (dims: CustomDimension[]) => SavedChartQuery; metricFilters: (filters: Filter[]) => SavedChartQuery; }; export declare function savedChart(chartUuid: string, label?: string): SavedChartQuery; /** Identity key for a saved-chart query — anything that changes the run must change the key. */ export declare function savedChartQueryKey(q: SavedChartQuery): string;