import { DepGraph } from 'dependency-graph';
import { type AnyType } from './any';
import { type ColumnInfo, type CompiledModelNode, type ParsedMetric } from './dbtFromSchema';
import { type JoinRelationship } from './explore';
import { type CompactOrAlias, type DimensionType, type FieldUrl, type Format, type Metric, type MetricType, type Source } from './field';
import { type RequiredFilter } from './filterGrammar';
import { type LightdashProjectConfig } from './lightdashProjectConfig';
import { type OrderFieldsByStrategy } from './table';
import { type DefaultTimeDimension, type TimeFrames } from './timeFrames';
export declare enum SupportedDbtAdapter {
    BIGQUERY = "bigquery",
    DATABRICKS = "databricks",
    SNOWFLAKE = "snowflake",
    REDSHIFT = "redshift",
    POSTGRES = "postgres",
    TRINO = "trino",
    CLICKHOUSE = "clickhouse"
}
export type DbtNodeConfig = {
    materialized: string;
    snowflake_warehouse: string;
};
export type DbtNode = {
    unique_id: string;
    resource_type: string;
    config?: DbtNodeConfig;
};
export type DbtRawModelNode = CompiledModelNode & {
    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;
    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;
    group_label?: string;
    joins?: DbtModelJoin[];
    /**
     * 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 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;
    group_label?: string;
    sql_filter?: string;
    sql_where?: string;
    sql_from?: string;
    required_attributes?: Record<string, string | string[]>;
    group_details?: Record<string, DbtModelGroup>;
    default_time_dimension?: {
        field: string;
        interval: TimeFrames;
    };
    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[];
};
export type DbtModelGroup = {
    label: string;
    description?: 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 DbtColumnLightdashDimension = {
    name?: string;
    label?: string;
    type?: DimensionType;
    description?: string;
    sql?: string;
    time_intervals?: boolean | 'default' | 'OFF' | TimeFrames[];
    hidden?: boolean;
    round?: number;
    compact?: CompactOrAlias;
    format?: Format | string;
    group_label?: string;
    groups?: string[] | string;
    colors?: Record<string, string>;
    urls?: FieldUrl[];
    required_attributes?: Record<string, string | string[]>;
    ai_hint?: string | string[];
    image?: {
        url: string;
        width?: number;
        height?: number;
        fit?: 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;
    group_label?: string;
    groups?: string[];
    urls?: FieldUrl[];
    show_underlying_values?: string[];
    filters?: {
        [key: string]: AnyType;
    }[];
    percentile?: number;
    default_time_dimension?: DefaultTimeDimension;
    spotlight?: {
        visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
        categories?: string[];
        filter_by?: string[];
        segment_by?: string[];
        owner?: string;
    };
    ai_hint?: string | 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;
    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 V9MetricRef = {
    name: string;
    package?: string | null;
    version?: string | number | null;
};
export declare const isV9MetricRef: (x: string[] | V9MetricRef) => x is V9MetricRef;
export type DbtMetric = Omit<ParsedMetric, 'refs'> & {
    meta?: Record<string, AnyType> & DbtMetricLightdashMetadata;
    refs?: string[][] | V9MetricRef[];
};
export type DbtMetricLightdashMetadata = {
    hidden?: boolean;
    group_label?: string;
    groups?: string[];
    show_underlying_values?: string[];
    filters: Record<string, AnyType>[];
};
export type DbtDoc = {
    unique_id: string;
    name: string;
    block_contents: string;
};
export interface DbtManifest {
    nodes: Record<string, DbtNode>;
    metadata: DbtRawManifestMetadata;
    metrics: Record<string, DbtMetric>;
    docs: Record<string, DbtDoc>;
}
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;
}
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: string | string[] | 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[]>;
    spotlightConfig?: LightdashProjectConfig['spotlight'];
    modelCategories?: string[];
    modelOwner?: string;
};
export declare const convertModelMetric: ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, modelCategories, modelOwner, }: ConvertModelMetricArgs) => Metric;
type ConvertColumnMetricArgs = Omit<ConvertModelMetricArgs, 'metric'> & {
    metric: DbtColumnLightdashMetric;
    dimensionName?: string;
    dimensionSql: string;
    requiredAttributes?: Record<string, string | string[]>;
    modelCategories?: string[];
};
export declare const convertColumnMetric: ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, modelCategories, modelOwner, }: 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