import { type AnyType } from './any';
import { type DateZoom } from './api/paginatedQuery';
import { type CompactOrAlias, type CompiledCustomDimension, type CompiledDimension, type CompiledMetric, type CompiledTableCalculation, type CustomDimension, type CustomFormat, type Dimension, type FieldId, type Format, type Metric, type MetricType, type TableCalculation } from './field';
import { type Filters, type MetricFilterRule } from './filter';
import { type TimeFrames } from './timeFrames';
export interface AdditionalMetric {
    label?: string;
    type: MetricType;
    description?: string;
    sql: string;
    hidden?: boolean;
    round?: number;
    compact?: CompactOrAlias;
    format?: Format | string;
    table: string;
    name: string;
    index?: number;
    filters?: MetricFilterRule[];
    baseDimensionName?: string;
    uuid?: string | null;
    percentile?: number;
    formatOptions?: CustomFormat;
    /**
     * Optional marker for metrics generated by the system.
     * Currently used for Period-over-Period (PoP) previous-period metrics.
     */
    generationType?: 'periodOverPeriod';
    /**
     * For PoP-generated metrics, the base metric id that this metric is derived from.
     */
    baseMetricId?: FieldId;
    /**
     * For PoP-generated metrics, the time dimension id used for the comparison.
     */
    timeDimensionId?: FieldId;
    /**
     * For PoP-generated metrics, the granularity used for the comparison.
     */
    granularity?: TimeFrames;
    /**
     * For PoP-generated metrics, the number of periods to offset by (>= 1).
     */
    periodOffset?: number;
}
export declare const isAdditionalMetric: (value: AnyType) => value is AdditionalMetric;
export interface PeriodOverPeriodAdditionalMetric extends AdditionalMetric {
    generationType: 'periodOverPeriod';
    /**
     * The base metric id that this metric is the previous-period version of.
     * This avoids relying on suffix parsing to establish the relationship.
     */
    baseMetricId: FieldId;
    /**
     * The time dimension field id used for the comparison.
     */
    timeDimensionId: FieldId;
    /**
     * Granularity for the comparison (derived from the chosen time dimension).
     */
    granularity: TimeFrames;
    /**
     * Number of periods to offset by (>= 1).
     */
    periodOffset: number;
}
type PeriodOverPeriodGeneratedMetricMetadata = {
    generationType: 'periodOverPeriod';
    baseMetricId: FieldId;
    timeDimensionId: FieldId;
    granularity: TimeFrames;
    periodOffset: number;
};
/**
 * Type guard for Period-over-Period generated metric metadata.
 *
 * Note: This metadata can exist on both `AdditionalMetric` objects (query-time)
 * and the converted `Metric` objects in `ItemsMap` (render-time), since we
 * preserve these fields during conversion.
 */
export declare const hasPeriodOverPeriodGeneratedMetricMetadata: (value: AnyType) => value is PeriodOverPeriodGeneratedMetricMetadata;
export declare const isPeriodOverPeriodAdditionalMetric: (value: AnyType) => value is PeriodOverPeriodAdditionalMetric;
export declare const hasFormatOptions: (value: AnyType) => value is {
    formatOptions: CustomFormat;
};
export declare const getCustomMetricDimensionId: (metric: AdditionalMetric) => string;
export type MetricOverrides = {
    [key: string]: Pick<Metric, 'formatOptions'>;
};
export type DimensionOverrides = {
    [key: string]: Pick<Dimension, 'formatOptions'>;
};
export type MetricQuery = {
    exploreName: string;
    dimensions: FieldId[];
    metrics: FieldId[];
    filters: Filters;
    sorts: SortField[];
    limit: number;
    tableCalculations: TableCalculation[];
    additionalMetrics?: AdditionalMetric[];
    customDimensions?: CustomDimension[];
    metricOverrides?: MetricOverrides;
    dimensionOverrides?: DimensionOverrides;
    timezone?: string;
    metadata?: {
        hasADateDimension: Pick<CompiledDimension, 'label' | 'name' | 'table'>;
    };
};
export type CompiledMetricQuery = Omit<MetricQuery, 'customDimensions'> & {
    compiledTableCalculations: CompiledTableCalculation[];
    compiledAdditionalMetrics: CompiledMetric[];
    compiledCustomDimensions: CompiledCustomDimension[];
};
export type SortField = {
    fieldId: string;
    descending: boolean;
    nullsFirst?: boolean;
};
export declare const getAdditionalMetricLabel: (item: AdditionalMetric) => string;
type FilterGroupResponse = {
    id: string;
    or: AnyType[];
} | {
    id: string;
    and: AnyType[];
};
export type FiltersResponse = {
    dimensions?: FilterGroupResponse;
    metrics?: FilterGroupResponse;
    tableCalculations?: FilterGroupResponse;
};
export type MetricQueryResponse = {
    exploreName: string;
    dimensions: FieldId[];
    metrics: FieldId[];
    filters: FiltersResponse;
    sorts: SortField[];
    limit: number;
    tableCalculations: TableCalculation[];
    additionalMetrics?: AdditionalMetric[];
    customDimensions?: CustomDimension[];
    metadata?: {
        hasADateDimension: Pick<CompiledDimension, 'label' | 'name' | 'table'>;
    };
};
export declare const countCustomDimensionsInMetricQuery: (metricQuery: MetricQuery) => {
    numFixedWidthBinCustomDimensions: number;
    numFixedBinsBinCustomDimensions: number;
    numCustomRangeBinCustomDimensions: number;
    numCustomSqlDimensions: number;
};
export declare const hasCustomBinDimension: (metricQuery: MetricQuery | undefined) => boolean | undefined;
export type MetricQueryRequest = {
    exploreName: string;
    dimensions: FieldId[];
    metrics: FieldId[];
    filters: {
        dimensions?: AnyType;
        metrics?: AnyType;
        tableCalculations?: AnyType;
    };
    sorts: SortField[];
    limit: number;
    tableCalculations: TableCalculation[];
    additionalMetrics?: AdditionalMetric[];
    csvLimit?: number;
    customDimensions?: CustomDimension[];
    dateZoom?: DateZoom;
    metadata?: MetricQuery['metadata'];
    timezone?: string;
    metricOverrides?: MetricOverrides;
    dimensionOverrides?: DimensionOverrides;
};
export type QueryWarning = {
    message: string;
    fields?: string[];
    tables?: string[];
};
export {};
//# sourceMappingURL=metricQuery.d.ts.map