import { FindOperator, FindOptionsRelationByString, FindOptionsRelations, Repository, SelectQueryBuilder } from 'typeorm';
import { ColumnMetadata } from 'typeorm/metadata/ColumnMetadata';
/**
 * Joins 2 keys as `K`, `K.P`, `K.(P` or `K.P)`
 * The parenthesis notation is included for embedded columns
 */
type Join<K, P> = K extends string ? P extends string ? `${K}${'' extends P ? '' : '.'}${P | `(${P}` | `${P})`}` : never : never;
/**
 * Get the previous number between 0 and 10. Examples:
 *   Prev[3] = 2
 *   Prev[0] = never.
 *   Prev[20] = 0
 */
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...0[]];
/**
 * Unwrap Promise<T> to T
 */
type UnwrapPromise<T> = T extends Promise<infer U> ? UnwrapPromise<U> : T;
/**
 * Unwrap Array<T> to T
 */
type UnwrapArray<T> = T extends Array<infer U> ? UnwrapArray<U> : T;
/**
 * Find all the dotted path properties for a given column.
 *
 * T: The column
 * D: max depth
 */
export type Column<T, D extends number = 2> = [D] extends [never] ? never : T extends Record<string, any> ? {
    [K in keyof T]-?: K extends string ? T[K] extends string | number ? `${K}` : T[K] extends Date ? `${K}` : T[K] extends Array<infer U> ? // yes, unwrap it, and recurse deeper
    `${K}` | Join<K, Column<UnwrapArray<U>, Prev[D]>> : T[K] extends Promise<infer U> ? U extends Array<infer V> ? `${K}` | Join<K, Column<UnwrapArray<V>, Prev[D]>> : `${K}` | Join<K, Column<UnwrapPromise<U>, Prev[D]>> : // no, we have no more special cases, so treat it as an
    `${K}` | Join<K, Column<T[K], Prev[D]>> : never;
}[keyof T] : '';
export type RelationColumn<T> = Extract<Column<T>, {
    [K in Column<T>]: K extends `${infer R}.${string}` ? R : never;
}[Column<T>]>;
export type Order<T> = [Column<T>, 'ASC' | 'DESC'];
export type SortBy<T> = Order<T>[];
export type MappedColumns<T, S> = {
    [key in Column<T> | (string & {})]: S;
};
export type JoinMethod = 'leftJoinAndSelect' | 'innerJoinAndSelect';
export type RelationSchemaInput<T = any> = FindOptionsRelations<T> | RelationColumn<T>[] | FindOptionsRelationByString;
export type RelationSchema<T = any> = {
    [relation in Column<T> | (string & {})]: true;
};
export declare function isEntityKey<T>(entityColumns: Column<T>[], column: string): column is Column<T>;
export declare const positiveNumberOrDefault: (value: number | undefined, defaultValue: number, minValue?: 0 | 1) => number;
export type ColumnProperties = {
    propertyPath?: string;
    propertyName: string;
    isNested: boolean;
    column: string;
};
export declare function getPropertiesByColumnName(column: string): ColumnProperties;
export declare function extractVirtualProperty(qb: SelectQueryBuilder<unknown>, columnProperties: ColumnProperties): Partial<ColumnMetadata>;
export declare function includesAllPrimaryKeyColumns(qb: SelectQueryBuilder<unknown>, propertyPath: string[]): boolean;
export declare function hasColumnWithPropertyPath(qb: SelectQueryBuilder<unknown>, columnProperties: ColumnProperties): boolean;
export declare function checkIsRelation(qb: SelectQueryBuilder<unknown>, propertyPath: string): boolean;
export declare function checkIsNestedRelation(qb: SelectQueryBuilder<unknown>, propertyPath: string): boolean;
export declare function checkIsEmbedded(qb: SelectQueryBuilder<unknown>, propertyPath: string): boolean;
export declare function checkIsArray(qb: SelectQueryBuilder<unknown>, propertyName: string): boolean;
export declare function checkIsJsonb(qb: SelectQueryBuilder<unknown>, propertyName: string): boolean;
export declare function fixColumnAlias(properties: ColumnProperties, alias: string, isRelation?: boolean, isVirtualProperty?: boolean, isEmbedded?: boolean, query?: ColumnMetadata['query']): string;
export declare function getQueryUrlComponents(path: string): {
    queryOrigin: string;
    queryPath: string;
};
export declare function isISODate(str: string): boolean;
export declare function isRepository<T>(repo: unknown | Repository<T>): repo is Repository<T>;
export declare function isFindOperator<T>(value: unknown | FindOperator<T>): value is FindOperator<T>;
export declare function createRelationSchema<T>(configurationRelations: RelationSchemaInput<T>): RelationSchema<T>;
export declare function mergeRelationSchema(...schemas: RelationSchema[]): any;
export declare function getPaddedExpr(valueExpr: string, length: number, dbType: string): string;
export declare function isDateColumnType(type: any): boolean;
export {};
