import { DepGraph } from 'dependency-graph';
import { type AnyType } from './any';
import { type ColumnInfo, type CompiledModelNode } from './dbtFromSchema';
import { type DbtSemanticMetric, type DbtSemanticModel } from './dbtSemanticLayer';
import { type JoinRelationship } from './explore';
import { type CompactOrAlias, type Dimension, type DimensionType, type FieldUrl, type FilterAutocompleteValue, type Format, type Metric, type MetricType, type NumberSeparator, type Source, type TimestampDomain } from './field';
import { type RequiredFilter } from './filterGrammar';
import { type LightdashProjectConfig } from './lightdashProjectConfig';
import { type OrderFieldsByStrategy, type TableBase } from './table';
import { type DefaultTimeDimension, type TimeFrames } from './timeFrames';
export declare enum SupportedDbtAdapter {
    BIGQUERY = "bigquery",
    DATABRICKS = "databricks",
    SNOWFLAKE = "snowflake",
    REDSHIFT = "redshift",
    POSTGRES = "postgres",
    DUCKDB = "duckdb",
    TRINO = "trino",
    CLICKHOUSE = "clickhouse",
    ATHENA = "athena",
    SPARK = "spark"
}
export type DbtNodeConfig = {
    materialized: string;
    snowflake_warehouse: string;
};
export type DbtNode = {
    unique_id: string;
    resource_type: string;
    config?: DbtNodeConfig;
};
export type DbtRawModelNode = Omit<CompiledModelNode, 'resource_type' | 'compiled' | 'language'> & {
    resource_type: 'model' | 'seed';
    compiled?: boolean;
    language?: string;
    columns: {
        [name: string]: DbtModelColumn;
    };
    config?: CompiledModelNode['config'] & {
        meta?: DbtModelMetadata;
    };
    meta: DbtModelMetadata;
};
export type DbtModelNode = DbtRawModelNode & {
    database: string;
    unrendered_config?: {
        meta?: {
            joins?: Array<{
                join: string;
            }>;
        };
    };
};
export type DbtModelColumn = ColumnInfo & {
    meta?: DbtColumnMetadata;
    data_type?: DimensionType;
    /** Catalog-derived timestamp domain; sibling of data_type because
     *  attachTypesToModels overwrites data_type wholesale. */
    timestamp_domain?: TimestampDomain;
    config?: {
        meta?: DbtColumnMetadata;
    };
};
type DbtLightdashFieldTags = {
    tags?: string | string[];
};
export type DbtModelMetadata = DbtModelLightdashConfig & {};
/**
 * Additional dimension definition for explore-scoped dimensions.
 * These dimensions are only available within a specific explore.
 * They can reference fields from joined tables using ${table.field} syntax.
 *
 * Unlike column-level additional dimensions, explore-scoped dimensions
 * require `type` and `sql` since there's no underlying column to infer from.
 */
export type DbtExploreLightdashAdditionalDimension = DbtColumnLightdashAdditionalDimension & {
    type: DimensionType;
    sql: string;
};
type ExploreConfig = {
    label?: string;
    description?: string;
    /** @deprecated Use groups instead */
    group_label?: string;
    /**
     * Nested groups for tables in the sidebar (max 5 levels). Group keys
     * resolve to labels via `table_groups` in lightdash.config.yml; missing
     * keys fall back to using the key as the label.
     */
    groups?: string[];
    joins?: DbtModelJoin[];
    case_sensitive?: boolean;
    sql_filter?: string;
    sql_where?: string;
    /**
     * Explore-scoped custom dimensions.
     * These dimensions are only available within this specific explore
     * and can reference fields from any joined table.
     */
    additional_dimensions?: Record<string, DbtExploreLightdashAdditionalDimension>;
};
export type DbtPreAggregateDef = {
    name: string;
    dimensions: string[];
    metrics: string[];
    filters?: Record<string, AnyType>[];
    time_dimension?: string;
    granularity?: string;
    max_rows?: number;
    refresh?: {
        cron?: string;
    };
    materialization_role?: {
        email?: string;
        attributes?: Record<string, string | string[]>;
        [key: string]: unknown;
    };
};
export type SharedDbtModelLightdashConfig = {
    default_filters?: RequiredFilter[];
    /**
     * @deprecated use default_filters instead
     */
    required_filters?: RequiredFilter[];
};
export type FieldSetDefinition = {
    fields: string[];
};
export type DbtModelLightdashConfig = ExploreConfig & SharedDbtModelLightdashConfig & {
    metrics?: Record<string, DbtModelLightdashMetric>;
    sets?: Record<string, FieldSetDefinition>;
    order_fields_by?: OrderFieldsByStrategy;
    sql_filter?: string;
    sql_where?: string;
    sql_from?: string;
    required_attributes?: Record<string, string | string[]>;
    any_attributes?: Record<string, string | string[]>;
    group_details?: Record<string, DbtModelGroup>;
    default_time_dimension?: {
        field: string;
        interval: TimeFrames;
    };
    default_show_underlying_values?: string[];
    spotlight?: {
        visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
        categories?: string[];
        owner?: string;
    };
    explores?: Record<string, ExploreConfig & SharedDbtModelLightdashConfig>;
    ai_hint?: string | string[];
    parameters?: LightdashProjectConfig['parameters'];
    primary_key?: string | string[];
    owner?: string;
    pre_aggregates?: DbtPreAggregateDef[];
};
export type DbtModelGroup = {
    label: string;
    description?: string;
    ai_hint?: string | string[];
};
export type DbtModelJoinType = 'inner' | 'full' | 'left' | 'right';
export type DbtModelJoin = {
    join: string;
    sql_on: string;
    alias?: string;
    label?: string;
    type?: DbtModelJoinType;
    hidden?: boolean;
    fields?: string[];
    always?: boolean;
    relationship?: JoinRelationship;
    description?: string;
};
export type DbtColumnMetadata = DbtColumnLightdashConfig & {};
type DbtColumnLightdashConfig = {
    dimension?: DbtColumnLightdashDimension;
    additional_dimensions?: {
        [subDimensionName: string]: DbtColumnLightdashAdditionalDimension;
    };
    metrics?: {
        [metricName: string]: DbtColumnLightdashMetric;
    };
};
export type DbtFilterAutocompleteConfig = {
    values?: FilterAutocompleteValue[];
    fetch_from_warehouse?: boolean;
    label_dimension?: string;
};
export type DbtColumnLightdashDimension = {
    name?: string;
    label?: string;
    type?: DimensionType;
    description?: string;
    sql?: string;
    time_intervals?: boolean | 'default' | 'OFF' | (TimeFrames | string)[];
    /** Set to false to opt this dim out of display-tz conversion. Defaults to true. */
    convert_timezone?: boolean;
    /** Declares whether the column stores an instant ('aware') or a bare wall
     *  clock ('naive'); overrides the warehouse catalog. */
    timestamp_domain?: TimestampDomain;
    hidden?: boolean;
    round?: number;
    compact?: CompactOrAlias;
    format?: Format | string;
    /** Number separator style for grouping/decimal characters */
    separator?: NumberSeparator;
    /** @deprecated Use groups instead */
    group_label?: string;
    groups?: string[] | string;
    colors?: Record<string, string>;
    urls?: FieldUrl[];
    required_attributes?: Record<string, string | string[]>;
    any_attributes?: Record<string, string | string[]>;
    ai_hint?: string | string[];
    case_sensitive?: boolean;
    filter_autocomplete?: DbtFilterAutocompleteConfig;
    image?: {
        url: string;
        width?: number;
        height?: number;
        fit?: string;
    };
    richText?: string;
    spotlight?: {
        filter_by?: boolean;
        segment_by?: boolean;
    };
} & DbtLightdashFieldTags;
export type DbtColumnLightdashAdditionalDimension = Omit<DbtColumnLightdashDimension, 'name'>;
export type DbtColumnLightdashMetric = {
    label?: string;
    type: MetricType;
    description?: string;
    sql?: string;
    hidden?: boolean;
    compact?: CompactOrAlias;
    round?: number;
    format?: Format | string;
    /** Number separator style for grouping/decimal characters */
    separator?: NumberSeparator;
    /** @deprecated Use groups instead */
    group_label?: string;
    groups?: string[];
    urls?: FieldUrl[];
    show_underlying_values?: string[];
    filters?: {
        [key: string]: AnyType;
    }[];
    percentile?: number;
    distinct_keys?: string | string[];
    default_time_dimension?: DefaultTimeDimension;
    spotlight?: {
        visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
        categories?: string[];
        filter_by?: string[];
        segment_by?: string[];
        default_segment?: string;
        default_filter?: Record<string, AnyType>;
        owner?: string;
    };
    drivers?: string[];
    ai_hint?: string | string[];
    richText?: string;
} & DbtLightdashFieldTags;
export type DbtModelLightdashMetric = DbtColumnLightdashMetric & Required<Pick<DbtColumnLightdashMetric, 'sql'>>;
export declare const normaliseModelDatabase: (model: DbtRawModelNode, targetWarehouse: SupportedDbtAdapter) => DbtModelNode;
export declare const patchPathParts: (patchPath: string) => {
    project: string | null;
    path: string;
};
export type LineageGraph = Record<string, LineageNodeDependency[]>;
export type LineageNodeDependency = {
    type: 'model' | 'seed' | 'source';
    name: string;
};
export declare const buildModelGraph: (allModels: Pick<DbtModelNode, "unique_id" | "name" | "depends_on">[]) => DepGraph<LineageNodeDependency>;
export interface DbtCatalogNode {
    metadata: DbtCatalogNodeMetadata;
    columns: {
        [k: string]: DbtCatalogNodeColumn;
    };
}
export interface DbtCatalogNodeMetadata {
    type: string;
    database: string | null;
    schema: string;
    name: string;
    comment?: string;
    owner?: string;
}
export interface DbtCatalogNodeColumn {
    type: string;
    comment?: string;
    index: number;
    name: string;
}
export interface DbtRpcDocsGenerateResults {
    nodes: {
        [k: string]: DbtCatalogNode;
    };
}
export declare const isDbtRpcDocsGenerateResults: (results: Record<string, AnyType>) => results is DbtRpcDocsGenerateResults;
export interface DbtPackage {
    package: string;
    version: string;
}
export interface DbtPackages {
    packages: DbtPackage[];
}
export declare const isDbtPackages: (results: Record<string, AnyType>) => results is DbtPackages;
export type DbtDoc = {
    unique_id: string;
    name: string;
    block_contents: string;
};
export interface DbtManifest {
    nodes: Record<string, DbtNode>;
    metadata: DbtRawManifestMetadata;
    /**
     * dbt MetricFlow metrics (dbt >= 1.6). Translated into Lightdash metrics
     * during CLI compile — see `translateMetricFlowMetrics`.
     */
    metrics: Record<string, DbtSemanticMetric>;
    docs: Record<string, DbtDoc>;
    /**
     * Opaque manifest sections that Lightdash carries through the multi-source
     * merge (`combineManifestSources`) but does not interpret during compile —
     * the already-compiled `nodes` carry resolved relation_names, so these are
     * not read today. Kept for faithful merging and future write-back source
     * attribution. Optional: not every manifest (or test fixture) includes them.
     */
    sources?: Record<string, AnyType>;
    macros?: Record<string, AnyType>;
    semantic_models?: Record<string, DbtSemanticModel>;
}
export interface DbtRawManifestMetadata {
    dbt_schema_version: string;
    generated_at: string;
    adapter_type: string;
}
export interface DbtManifestMetadata extends DbtRawManifestMetadata {
    adapter_type: SupportedDbtAdapter;
}
export declare const isSupportedDbtAdapter: (x: DbtRawManifestMetadata) => x is DbtManifestMetadata;
export declare const isSupportedDbtAdapterType: (x: string) => x is SupportedDbtAdapter;
export interface DbtRpcGetManifestResults {
    manifest: DbtManifest;
    selectedModelIds?: string[];
}
export declare const isDbtRpcManifestResults: (results: Record<string, AnyType>) => results is DbtRpcGetManifestResults;
export interface DbtRpcCompileResults {
    results: {
        node: DbtNode;
    }[];
}
export declare const isDbtRpcCompileResults: (results: Record<string, AnyType>) => results is DbtRpcCompileResults;
export interface DbtRpcRunSqlResults {
    results: {
        table: {
            column_names: string[];
            rows: AnyType[][];
        };
    }[];
}
export declare const convertToGroups: (dbtGroups: string | string[] | undefined, dbtGroupLabel: string | undefined) => string[];
export declare const convertToAiHints: (aiHint: unknown) => string[] | undefined;
export declare const flattenAiHints: (aiHint: unknown) => string;
export declare const getEffectiveFieldAiHints: (field: Pick<Dimension | Metric, "aiHint" | "groups">, table: Pick<TableBase, "groupDetails"> | undefined) => string[] | undefined;
export declare const isDbtRpcRunSqlResults: (results: Record<string, any>) => results is DbtRpcRunSqlResults;
type ConvertModelMetricArgs = {
    modelName: string;
    name: string;
    metric: DbtModelLightdashMetric;
    source?: Source;
    tableLabel: string;
    dimensionReference?: string;
    requiredAttributes?: Record<string, string | string[]>;
    anyAttributes?: Record<string, string | string[]>;
    spotlightConfig?: LightdashProjectConfig['spotlight'];
    modelCategories?: string[];
    modelOwner?: string;
    defaultShowUnderlyingValues?: string[];
    baseDimensionType?: DimensionType;
    baseDimensionTimeInterval?: TimeFrames;
};
export declare const convertModelMetric: ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, anyAttributes, spotlightConfig, modelCategories, modelOwner, defaultShowUnderlyingValues, baseDimensionType, baseDimensionTimeInterval, }: ConvertModelMetricArgs) => Metric;
type ConvertColumnMetricArgs = Omit<ConvertModelMetricArgs, 'metric' | 'baseDimensionType' | 'baseDimensionTimeInterval'> & {
    metric: DbtColumnLightdashMetric;
    dimensionName?: string;
    dimensionSql: string;
    dimensionType?: DimensionType;
    dimensionTimeInterval?: TimeFrames;
    requiredAttributes?: Record<string, string | string[]>;
    anyAttributes?: Record<string, string | string[]>;
    modelCategories?: string[];
};
export declare const convertColumnMetric: ({ modelName, dimensionName, dimensionSql, dimensionType, dimensionTimeInterval, name, metric, source, tableLabel, requiredAttributes, anyAttributes, spotlightConfig, modelCategories, modelOwner, defaultShowUnderlyingValues, }: ConvertColumnMetricArgs) => Metric;
export declare enum DbtManifestVersion {
    V7 = "v7",
    V8 = "v8",
    V9 = "v9",
    V10 = "v10",
    V11 = "v11",
    V12 = "v12",
    V20 = "v20"
}
export declare const getDbtManifestVersion: (manifest: DbtManifest) => DbtManifestVersion;
export declare const getLatestSupportedDbtManifestVersion: () => DbtManifestVersion;
export declare enum DbtExposureType {
    DASHBOARD = "dashboard",
    NOTEBOOK = "notebook",
    ANALYSIS = "analysis",
    ML = "ml",
    APPLICATION = "application"
}
export type DbtExposure = {
    name: string;
    owner: {
        name: string;
        email: string;
    };
    type: DbtExposureType;
    dependsOn: string[];
    label?: string;
    description?: string;
    url?: string;
    tags?: string[];
};
export declare const getModelsFromManifest: (manifest: DbtManifest) => DbtModelNode[];
export declare function getCompiledModels(manifestModels: DbtModelNode[], compiledModelIds?: string[]): DbtModelNode[];
export {};
//# sourceMappingURL=dbt.d.ts.map