/**
 * Relation Loader Module for Drizzle ORM
 *
 * This module provides utilities for building joins and loading related data
 * in Drizzle ORM, matching Sequelize's include/association behavior.
 *
 * Features:
 * - BelongsTo join building
 * - HasOne join building
 * - HasMany separate query loading
 * - BelongsToMany (M2M) through junction tables
 * - M2A polymorphic relations
 * - Nested relation loading (include.include)
 * - Relation filtering and ordering
 */
import { SQL } from 'drizzle-orm';
import { PgTable } from 'drizzle-orm/pg-core';
import type { ProcessedInclude, ExpandedFieldsResult } from '../types/index.js';
export declare function expandFieldsWithIncludes(fields: string[], tableName: string): ExpandedFieldsResult;
/**
 * Build LEFT JOIN clause for includes
 * Only for BelongsTo and HasOne relations
 * HasMany will use separate queries
 */
export declare function buildJoinsForIncludes(includes: ProcessedInclude[]): SQL[];
/**
 * Load HasMany relations with separate queries
 * This is more efficient than joining for one-to-many relations
 */
export declare function loadHasManyRelations(db: any, mainRecords: any[], includes: ProcessedInclude[], sourceTableName: string): Promise<any[]>;
/**
 * Load M2A (polymorphic) relations with junction table
 */
export declare function loadM2ARelations(db: any, mainRecords: any[], includes: ProcessedInclude[], sourceTableName: string): Promise<any[]>;
/**
 * Load BelongsToMany (M2M) relations with junction table
 */
export declare function loadBelongsToManyRelations(db: any, mainRecords: any[], includes: ProcessedInclude[], sourceTableName: string): Promise<any[]>;
/**
 * Load all separate-query relations (HasMany, BelongsToMany)
 */
/**
 * Nest flattened BelongsTo/HasOne relation data from JOINs
 * Converts { "category.name": "Electronics", "category.id": "123" }
 * to { category: { name: "Electronics", id: "123" } }
 */
export declare function nestJoinedRelations(records: any[], includes: ProcessedInclude[], parentPath?: string): any[];
export declare function loadSeparateRelations(db: any, mainRecords: any[], includes: ProcessedInclude[], sourceTableName: string): Promise<any[]>;
/**
 * Build complete select with joins
 * Returns SELECT columns and JOIN clauses
 */
export declare function buildSelectWithJoins(mainTable: PgTable, directFields: string[], includes: ProcessedInclude[]): {
    selectColumns: Record<string, any>;
    joins: SQL[];
};
/**
 * Utility: Check if any include requires separate query
 */
export declare function hasSeparateQueries(includes: ProcessedInclude[]): boolean;
/**
 * Utility: Get all relation names from includes (flat list)
 */
export declare function getRelationNames(includes: ProcessedInclude[]): string[];
//# sourceMappingURL=relationLoader.d.ts.map