/** * React hook for executing a Lightdash query. * * Usage: * const { data, loading, error } = useLightdash( * lightdash * .model('orders') * .metrics(['total_revenue']) * .dimensions(['customer_segment']) * ) * * // data is an array of flat objects: * // [{ customer_segment: 'Enterprise', total_revenue: 124000 }] */ import { QueryBuilder } from './query'; import { type SavedChartQuery } from './savedChart'; import type { Column, DownloadUnderlyingDataOptions, DownloadResultsOptions, DownloadResultsResult, FormatFunction, Row, UnderlyingDataOptions, UnderlyingDataResult } from './types'; export type LineageProps = { 'data-ld-query'?: string; }; /** * Props an app spreads onto the root element of a query-bound block so the * Lightdash parent can trace a clicked element back to its query. * Empty (spread-safe) until the query has a queryUuid. */ export declare const buildLineageProps: (queryUuid: string | null) => LineageProps; type UseLightdashResult = { /** Result rows as flat objects. Numbers are numbers, strings are strings. */ data: Row[]; /** Column metadata (name, label, type) */ columns: Column[]; /** Format a field value for display: format(row, 'total_revenue') → "$1,234" */ format: FormatFunction; /** Total rows returned by the source query. */ totalResults: number | null; /** True while the query is executing */ loading: boolean; /** Error if the query failed, null otherwise */ error: Error | null; /** Re-run the query */ refetch: () => void; /** Async query UUID for the source query, once loaded. */ queryUuid: string | null; /** Spread onto the root element of this query's UI block to enable data lineage. */ lineage: LineageProps; /** Fetch raw rows behind an aggregated metric value from this query result. */ getUnderlyingData: (options: UnderlyingDataOptions) => Promise; /** Schedule a backend CSV/XLSX export for rows behind an aggregated metric value. */ downloadUnderlyingData: (options: DownloadUnderlyingDataOptions) => Promise; /** Schedule a backend CSV/XLSX export for this query result. */ downloadResults: (options?: DownloadResultsOptions) => Promise; }; export declare function useLightdash(query: QueryBuilder | SavedChartQuery): UseLightdashResult; export {};