/**
 * Query Builder Module for Drizzle ORM
 *
 * This module provides query building utilities that convert Sequelize-style
 * filter/where objects into Drizzle ORM where conditions.
 *
 * Features:
 * - Convert filter objects to Drizzle where conditions
 * - Support AND/OR logical operators
 * - Handle nested conditions and relations
 * - Column qualification for joins
 * - Type casting support
 * - Pagination helpers
 *
 * RELATION PATH FILTERING:
 * - Relation path filters (e.g., "userRoles.role.name") ARE NOW SUPPORTED
 *   1. Parses relation paths into segments
 *   2. Recursively resolves each segment by looking up relation metadata
 *   3. Builds LEFT JOIN clauses dynamically
 *   4. Returns the final column reference for the WHERE clause
 *
 *   Example usage:
 *     conditions: {
 *       "userRoles.role.name": { in: ["admin", "user"] },
 *       "author.company.name": { eq: "ACME" }
 *     }
 *
 *   The query builder will automatically generate the necessary JOINs:
 *     LEFT JOIN userRoles_... ON ...
 *     LEFT JOIN roles_... ON ...
 *     LEFT JOIN companies_... ON ...
 *
 *   Joins are accumulated in ctx.joins array and must be applied by the caller.
 *
 * NOTES:
 * - Currently supports BelongsTo, HasMany, and HasOne relations
 * - BelongsToMany (many-to-many) uses simplified join (needs junction table support)
 * - Coordination with the two-query approach for HasMany sorting is handled by the caller
 */
import { SQL } from 'drizzle-orm';
import { JoinDefinition as RelationJoinDefinition } from './relationPathResolver.js';
import type { FilterObject, QueryContext, PaginationOptions, PaginationMetadata } from '../types/index.js';
export type { FilterObject, QueryContext, PaginationOptions, PaginationMetadata };
export type { RelationJoinDefinition as JoinDefinition };
/**
 * Main function: Convert Sequelize-style filter to Drizzle where condition
 *
 * @param filter - Filter object (Sequelize-style)
 * @param ctx - Query context with table schema information
 * @returns Drizzle SQL where condition
 *
 * @example
 * ```typescript
 * const filter = {
 *   age: { gt: 18 },
 *   status: { in: ['active', 'pending'] }
 * };
 *
 * const where = drizzleWhere(filter, {
 *   table: usersTable,
 *   tableName: 'users',
 *   schema: usersTable
 * });
 *
 * // Use in query:
 * const results = await db.select().from(usersTable).where(where);
 * ```
 */
export declare function drizzleWhere(filter: FilterObject | null | undefined, ctx: QueryContext): SQL | undefined;
/**
 * Extract field paths from relational conditions
 * Used to determine which relations need to be included/joined
 */
export declare function extractFieldPathsFromRelConditions(relConditions: any): string[];
/**
 * Combine multiple filters with AND logic
 * Returns empty object instead of undefined for better type safety
 */
export declare function combineFilters(...filters: (FilterObject | null | undefined)[]): FilterObject;
/**
 * Apply pagination to query
 * Supports both limit/offset and page/pageSize styles
 * When page is provided with limit, uses limit as pageSize and calculates offset
 */
export declare function applyPagination(options: PaginationOptions): {
    limit?: number;
    offset?: number;
};
/**
 * Calculate pagination metadata
 */
export declare function calculatePaginationMetadata(total: number, options: PaginationOptions): PaginationMetadata;
/**
 * Helper to build WHERE clause from multiple filter sources
 * Useful for combining base filters, user filters, tenant filters, etc.
 */
export declare function buildWhereClause(ctx: QueryContext, ...filters: (FilterObject | null | undefined)[]): SQL | undefined;
/**
 * Extract all field names from a filter object
 * Useful for permission validation
 */
export declare function extractFieldNamesFromFilter(filter: FilterObject): string[];
/**
 * Apply PostgreSQL full-text search to a query
 * Matches Sequelize implementation for compatibility
 *
 * @param tableName - Name of the table being searched
 * @param tableColumns - Column definitions from the table schema
 * @param searchQuery - The search string
 * @param searchFields - Fields to search in (optional, defaults to string fields)
 * @param sortByRelevance - Whether to sort by relevance score
 * @returns SQL condition for full-text search and optional order clause
 */
export declare function applyFullTextSearch(tableName: string, tableColumns: Record<string, any>, searchQuery: string, searchFields?: string[], sortByRelevance?: boolean): {
    searchCondition: SQL;
    orderClause?: SQL;
};
//# sourceMappingURL=queryBuilder.d.ts.map