/**
 * Relation Types
 * Centralized relation and association type definitions
 */
import type { SQL } from 'drizzle-orm';
import type { PgTable, PgColumn } from 'drizzle-orm/pg-core';
import type { SortObject } from '@baasix/types';
import type { FilterObject } from './query.js';
/**
 * Association types matching Sequelize conventions
 */
export type AssociationType = 'HasMany' | 'BelongsTo' | 'HasOne' | 'BelongsToMany' | 'M2A';
/**
 * Relation types supported
 */
export type RelationType = 'BelongsTo' | 'HasOne' | 'HasMany' | 'BelongsToMany' | 'M2A';
/**
 * Association definition interface
 */
export interface AssociationDefinition {
    type: AssociationType;
    model: string;
    foreignKey?: string;
    otherKey?: string;
    through?: string;
    as?: string;
    polymorphic?: boolean;
    onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
    onUpdate?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
}
/**
 * Include configuration for loading relations
 * Matches Sequelize include format
 */
export interface IncludeConfig {
    relation: string;
    as?: string;
    required?: boolean;
    where?: FilterObject;
    attributes?: string[];
    include?: IncludeConfig[];
    sort?: SortObject;
    limit?: number;
    separate?: boolean;
}
/**
 * Processed include with join information
 */
export interface ProcessedInclude {
    relation: string;
    relationType: RelationType;
    table: PgTable;
    joinCondition: SQL;
    where?: SQL | FilterObject;
    attributes: string[];
    nested: ProcessedInclude[];
    required: boolean;
    separate: boolean;
    alias?: string;
}
/**
 * Field expansion result with includes
 */
export interface ExpandedFieldsResult {
    directFields: string[];
    includes: ProcessedInclude[];
    relationPaths: Map<string, ProcessedInclude>;
}
/**
 * Join definition to be applied to the query
 */
export interface JoinDefinition {
    table: any;
    tableName: string;
    alias: string;
    condition: SQL;
    conditionSQL: string;
    type: 'left' | 'inner' | 'right';
}
/**
 * Result of resolving a relation path
 */
export interface ResolvedPath {
    column: PgColumn | null;
    columnPath: string;
    joins: JoinDefinition[];
    finalTable: any;
    finalAlias: string;
}
/**
 * Result of processing relational data
 */
export interface RelationalResult {
    result: Record<string, any>;
    deferredHasMany: Array<{
        association: string;
        value: any;
        associationInfo: any;
    }>;
    deferredM2M: Array<{
        association: string;
        value: any;
        associationInfo: any;
    }>;
    deferredM2A: Array<{
        association: string;
        value: any;
        associationInfo: any;
    }>;
}
//# sourceMappingURL=relations.d.ts.map