import type { AdditionalMetric, currencies, DefaultTimeDimension, LightdashProjectConfig } from '..';
import { type AnyType } from './any';
import { type MetricFilterRule } from './filter';
import type { TimeFrames } from './timeFrames';
export declare enum Compact {
    THOUSANDS = "thousands",
    MILLIONS = "millions",
    BILLIONS = "billions",
    TRILLIONS = "trillions",
    KILOBYTES = "kilobytes",
    MEGABYTES = "megabytes",
    GIGABYTES = "gigabytes",
    TERABYTES = "terabytes",
    PETABYTES = "petabytes",
    KIBIBYTES = "kibibytes",
    MEBIBYTES = "mebibytes",
    GIBIBYTES = "gibibytes",
    TEBIBYTES = "tebibytes",
    PEBIBYTES = "pebibytes"
}
declare const CompactAlias: readonly ["K", "thousand", "M", "million", "B", "billion", "T", "trillion", "KB", "kilobyte", "MB", "megabyte", "GB", "gigabyte", "TB", "terabyte", "PB", "petabyte", "KiB", "kibibyte", "MiB", "mebibyte", "GiB", "gibibyte", "TiB", "tebibyte", "PiB", "pebibyte"];
export declare enum NumberSeparator {
    DEFAULT = "default",// Default separator
    COMMA_PERIOD = "commaPeriod",// 100,000.00
    SPACE_PERIOD = "spacePeriod",// 100 000.00
    PERIOD_COMMA = "periodComma",// 100.000,00
    NO_SEPARATOR_PERIOD = "noSeparatorPeriod"
}
type CompactConfig = {
    compact: Compact;
    alias: Array<(typeof CompactAlias)[number]>;
    orderOfMagnitude: number;
    convertFn: (value: number) => number;
    label: string;
    suffix: string;
};
export type CompactOrAlias = Compact | (typeof CompactAlias)[number];
export declare const CompactConfigMap: Record<Compact, CompactConfig>;
export declare function findCompactConfig(compactOrAlias: CompactOrAlias): CompactConfig | undefined;
export declare enum BinType {
    FIXED_NUMBER = "fixed_number",
    FIXED_WIDTH = "fixed_width",
    CUSTOM_RANGE = "custom_range"
}
export type BinRange = {
    from: number | undefined;
    to: number | undefined;
};
export declare enum CustomDimensionType {
    BIN = "bin",
    SQL = "sql"
}
export interface BaseCustomDimension {
    id: string;
    name: string;
    table: string;
    type: CustomDimensionType;
}
export interface CustomBinDimension extends BaseCustomDimension {
    type: CustomDimensionType.BIN;
    dimensionId: FieldId;
    binType: BinType;
    binNumber?: number;
    binWidth?: number;
    customRange?: BinRange[];
}
export interface CustomSqlDimension extends BaseCustomDimension {
    type: CustomDimensionType.SQL;
    sql: string;
    dimensionType: DimensionType;
}
export type CustomDimension = CustomBinDimension | CustomSqlDimension;
export declare const isCustomDimension: (value: AnyType) => value is CustomDimension;
export declare const isCustomBinDimension: (value: AnyType) => value is CustomBinDimension;
export declare const isCustomSqlDimension: (value: AnyType) => value is CustomSqlDimension;
export type CompiledCustomSqlDimension = CustomSqlDimension & {
    compiledSql: string;
    tablesReferences: Array<string>;
    parameterReferences?: string[];
};
export type CompiledCustomDimension = CustomBinDimension | CompiledCustomSqlDimension;
export declare const isCompiledCustomSqlDimension: (value: AnyType) => value is CompiledCustomSqlDimension;
export type ItemsMap = Record<string, Field | TableCalculation | CustomDimension | Metric>;
export type Item = ItemsMap[string];
export interface CustomFormat {
    type: CustomFormatType;
    round?: number | undefined;
    separator?: NumberSeparator;
    currency?: (typeof currencies)[number] | undefined;
    compact?: CompactOrAlias | undefined;
    prefix?: string | undefined;
    suffix?: string | undefined;
    timeInterval?: TimeFrames;
    custom?: string | undefined;
}
export declare enum CustomFormatType {
    DEFAULT = "default",
    PERCENT = "percent",
    CURRENCY = "currency",
    NUMBER = "number",
    ID = "id",
    DATE = "date",
    TIMESTAMP = "timestamp",
    BYTES_SI = "bytes_si",
    BYTES_IEC = "bytes_iec",
    CUSTOM = "custom"
}
export declare enum TableCalculationType {
    NUMBER = "number",
    STRING = "string",
    DATE = "date",
    TIMESTAMP = "timestamp",
    BOOLEAN = "boolean"
}
export declare enum WindowFunctionType {
    ROW_NUMBER = "row_number",
    PERCENT_RANK = "percent_rank",
    CUME_DIST = "cume_dist",
    RANK = "rank",
    SUM = "sum",
    AVG = "avg",
    COUNT = "count",
    MIN = "min",
    MAX = "max"
}
export declare const nullaryWindowFunctions: WindowFunctionType[];
export declare const unaryWindowFunctions: WindowFunctionType[];
export declare enum FrameType {
    ROWS = "rows",
    RANGE = "range"
}
export declare enum FrameBoundaryType {
    UNBOUNDED_PRECEDING = "unbounded_preceding",
    PRECEDING = "preceding",
    CURRENT_ROW = "current_row",
    FOLLOWING = "following",
    UNBOUNDED_FOLLOWING = "unbounded_following"
}
export type FrameBoundary = {
    type: FrameBoundaryType;
    offset?: number;
};
export type FrameClause = {
    frameType: FrameType;
    start?: FrameBoundary;
    end: FrameBoundary;
};
export declare enum TableCalculationTemplateType {
    PERCENT_CHANGE_FROM_PREVIOUS = "percent_change_from_previous",
    PERCENT_OF_PREVIOUS_VALUE = "percent_of_previous_value",
    PERCENT_OF_COLUMN_TOTAL = "percent_of_column_total",
    RANK_IN_COLUMN = "rank_in_column",
    RUNNING_TOTAL = "running_total",
    WINDOW_FUNCTION = "window_function"
}
export type TableCalculationTemplate = {
    type: TableCalculationTemplateType.PERCENT_CHANGE_FROM_PREVIOUS;
    fieldId: string;
    orderBy: {
        fieldId: string;
        order: 'asc' | 'desc' | null;
    }[];
} | {
    type: TableCalculationTemplateType.PERCENT_OF_PREVIOUS_VALUE;
    fieldId: string;
    orderBy: {
        fieldId: string;
        order: 'asc' | 'desc' | null;
    }[];
} | {
    type: TableCalculationTemplateType.PERCENT_OF_COLUMN_TOTAL;
    fieldId: string;
    partitionBy?: string[];
} | {
    type: TableCalculationTemplateType.RANK_IN_COLUMN;
    fieldId: string;
} | {
    type: TableCalculationTemplateType.RUNNING_TOTAL;
    fieldId: string;
} | {
    type: TableCalculationTemplateType.WINDOW_FUNCTION;
    windowFunction: WindowFunctionType;
    fieldId: string | null;
    orderBy: {
        fieldId: string;
        order: 'asc' | 'desc' | null;
    }[];
    partitionBy: string[];
    frame?: FrameClause;
};
export type TableCalculation = {
    index?: number;
    name: string;
    displayName: string;
    format?: CustomFormat;
    type?: TableCalculationType;
} & ({
    sql: string;
} | {
    template: TableCalculationTemplate;
});
export type TableCalculationMetadata = {
    oldName: string;
    name: string;
};
export declare enum FieldType {
    METRIC = "metric",
    DIMENSION = "dimension"
}
export declare const isTableCalculation: (item: ItemsMap[string] | AdditionalMetric | Pick<Field, "table" | "name">) => item is TableCalculation;
export declare const isSqlTableCalculation: (calc: TableCalculation) => calc is TableCalculation & {
    sql: string;
};
export declare const isTemplateTableCalculation: (calc: TableCalculation) => calc is TableCalculation & {
    template: TableCalculationTemplate;
};
export type CompiledTableCalculation = TableCalculation & {
    compiledSql: string;
    dependsOn: string[];
};
export type FieldUrl = {
    url: string;
    label: string;
};
export interface Field {
    fieldType: FieldType;
    type: string;
    name: string;
    label: string;
    table: string;
    tableLabel: string;
    sql: string;
    description?: string;
    source?: Source | undefined;
    hidden: boolean;
    compact?: CompactOrAlias;
    round?: number;
    format?: Format | string;
    /**
     * @deprecated Use groups property instead.
     */
    groupLabel?: string;
    groups?: string[];
    urls?: FieldUrl[];
    index?: number;
    tags?: string[];
    parameterReferences?: string[];
}
export declare const isField: (field: AnyType) => field is Field;
export type FieldId = string;
export declare const convertFieldRefToFieldId: (fieldRef: string, fallbackTableName?: string) => string;
export type Source = {
    path: string;
    range: {
        start: SourcePosition;
        end: SourcePosition;
    };
    highlight?: {
        start: SourcePosition;
        end: SourcePosition;
    };
    content: string;
};
type SourcePosition = {
    line: number;
    character: number;
};
export declare enum DimensionType {
    STRING = "string",
    NUMBER = "number",
    TIMESTAMP = "timestamp",
    DATE = "date",
    BOOLEAN = "boolean"
}
export interface Dimension extends Field {
    fieldType: FieldType.DIMENSION;
    type: DimensionType;
    /**
     * @deprecated Use groups property instead.
     */
    group?: string;
    requiredAttributes?: Record<string, string | string[]>;
    timeInterval?: TimeFrames;
    timeIntervalBaseDimensionName?: string;
    isAdditionalDimension?: boolean;
    colors?: Record<string, string>;
    isIntervalBase?: boolean;
    aiHint?: string | string[];
    formatOptions?: CustomFormat;
    image?: {
        url: string;
        width?: number;
        height?: number;
        fit?: string;
    };
    spotlight?: {
        filterBy?: boolean;
        segmentBy?: boolean;
    };
}
/**
 * Error information stored on a field when compilation fails but
 * partial compilation mode is enabled.
 */
export type FieldCompilationError = {
    message: string;
};
type CompiledProperties = {
    compiledSql: string;
    tablesReferences: Array<string> | undefined;
    tablesRequiredAttributes?: Record<string, Record<string, string | string[]>>;
    /**
     * When partial compilation mode is enabled, fields that fail to compile
     * will have this property set instead of causing the entire explore to fail.
     */
    compilationError?: FieldCompilationError;
};
export type CompiledDimension = Dimension & CompiledProperties;
export type CompiledMetric = Metric & CompiledProperties;
/**
 * Type guard to check if a compiled field has a compilation error.
 */
export declare const hasFieldCompilationError: (field: CompiledDimension | CompiledMetric) => boolean;
export type CompiledField = CompiledDimension | CompiledMetric;
export declare const isDimension: (field: ItemsMap[string] | AdditionalMetric | undefined) => field is Dimension;
export declare const isTimeBasedDimension: (item: ItemsMap[string] | AdditionalMetric | undefined) => item is Dimension;
export interface FilterableDimension extends Dimension {
    type: DimensionType.STRING | DimensionType.NUMBER | DimensionType.DATE | DimensionType.TIMESTAMP | DimensionType.BOOLEAN;
}
export type FieldRef = string;
export declare const getFieldRef: (field: Pick<Field, "table" | "name">) => FieldRef;
export declare const getFieldLabel: (field: Field) => string;
export declare enum MetricType {
    PERCENTILE = "percentile",
    AVERAGE = "average",
    COUNT = "count",
    COUNT_DISTINCT = "count_distinct",
    SUM = "sum",
    MIN = "min",
    MAX = "max",
    PERCENT_OF_PREVIOUS = "percent_of_previous",
    PERCENT_OF_TOTAL = "percent_of_total",
    RUNNING_TOTAL = "running_total",
    NUMBER = "number",
    MEDIAN = "median",
    STRING = "string",
    DATE = "date",
    TIMESTAMP = "timestamp",
    BOOLEAN = "boolean"
}
export declare enum Format {
    KM = "km",
    MI = "mi",
    USD = "usd",
    GBP = "gbp",
    EUR = "eur",
    JPY = "jpy",
    DKK = "dkk",
    ID = "id",
    PERCENT = "percent"
}
export declare const isFormat: (value: string | undefined) => value is Format;
export declare const parseMetricType: (metricType: string) => MetricType;
export declare const PostCalculationMetricTypes: MetricType[];
export declare const isMetric: (field: ItemsMap[string] | AdditionalMetric | undefined) => field is Metric;
export declare const isNonAggregateMetric: (field: Field) => boolean;
export declare const isPostCalculationMetricType: (type: MetricType) => boolean;
export declare const isPostCalculationMetric: (field: Field) => boolean;
export declare const isCompiledMetric: (field: ItemsMap[string] | AdditionalMetric | undefined) => field is CompiledMetric;
export interface Metric extends Field {
    fieldType: FieldType.METRIC;
    type: MetricType;
    showUnderlyingValues?: string[];
    filters?: MetricFilterRule[];
    percentile?: number;
    formatOptions?: CustomFormat;
    dimensionReference?: string;
    requiredAttributes?: Record<string, string | string[]>;
    defaultTimeDimension?: DefaultTimeDimension;
    spotlight?: {
        visibility: LightdashProjectConfig['spotlight']['default_visibility'];
        categories?: string[];
        filterBy?: string[];
        segmentBy?: string[];
        owner?: string;
    };
    aiHint?: string | string[];
}
export declare const isFilterableDimension: (dimension: Dimension | undefined) => dimension is FilterableDimension;
export type FilterableField = TableCalculation | Metric | FilterableDimension | CustomSqlDimension;
export declare const isFilterableField: (field: Dimension | ItemsMap[string]) => field is FilterableField;
export type FilterableItem = FilterableField;
export declare const isFilterableItem: (item: ItemsMap[string] | TableCalculation) => item is FilterableItem;
export declare const defaultSql: (columnName: string) => string;
export declare const capitalize: (word: string) => string;
export declare const friendlyName: (text: string) => string;
export declare const isSummable: (item: Item | undefined) => boolean;
export declare const IECByteCompacts: Compact[];
export declare function getCompactOptionsForFormatType(type: CustomFormatType): Compact[];
export {};
//# sourceMappingURL=field.d.ts.map