/**
 * Enhanced Model with Relationships
 * Full ORM capabilities with eager/lazy loading
 */
import type { Paginator } from '../database/Paginator';
import type { IQueryBuilder, InsertResult, PaginationOptions } from './QueryBuilder';
import type { IRelationship } from './Relationships';
export interface ModelConfig {
    table: string;
    fillable: string[];
    hidden: string[];
    timestamps?: boolean;
    casts?: Record<string, string>;
    softDeletes?: boolean;
    deleteAtColumn?: string;
    accessors?: Record<string, (value: unknown, attrs: Record<string, unknown>) => unknown>;
    mutators?: Record<string, (value: unknown, attrs: Record<string, unknown>) => unknown>;
    scopes?: Record<string, (builder: IQueryBuilder, ...args: unknown[]) => IQueryBuilder>;
    observers?: Array<{
        saving?: (model: IModel) => void | Promise<void>;
        saved?: (model: IModel) => void | Promise<void>;
        creating?: (model: IModel) => void | Promise<void>;
        created?: (model: IModel) => void | Promise<void>;
        updating?: (model: IModel) => void | Promise<void>;
        updated?: (model: IModel) => void | Promise<void>;
        deleting?: (model: IModel) => void | Promise<void>;
        deleted?: (model: IModel) => void | Promise<void>;
    }>;
    connection?: string;
}
export interface ModelStatic {
    query(): IQueryBuilder;
    getTable?(): string;
    name?: string;
    hydrate?(attributes: Record<string, unknown>): IModel;
}
export interface IModel {
    fill(attributes: Record<string, unknown>): IModel;
    setAttribute(key: string, value: unknown): IModel;
    getAttribute(key: string): unknown;
    getAttributes(): Record<string, unknown>;
    save(): Promise<boolean>;
    delete(): Promise<boolean>;
    restore(): Promise<boolean>;
    forceDelete(): Promise<boolean>;
    isDeleted(): boolean;
    toJSON(): Record<string, unknown>;
    isDirty(key?: string): boolean;
    getTable(): string;
    exists(): boolean;
    setExists(exists: boolean): void;
    setRelation(name: string, value: unknown): void;
    getRelation<T>(name: string): T | undefined;
    hasOne(relatedModel: ModelStatic, foreignKey?: string): IRelationship;
    hasMany(relatedModel: ModelStatic, foreignKey?: string): IRelationship;
    belongsTo(relatedModel: ModelStatic, foreignKey?: string): IRelationship;
    belongsToMany(relatedModel: ModelStatic, throughTable?: string, foreignKey?: string, relatedKey?: string): IRelationship;
    morphOne(relatedModel: ModelStatic, morphName: string, morphType?: string, morphId?: string, localKey?: string): IRelationship;
    morphMany(relatedModel: ModelStatic, morphName: string, morphType?: string, morphId?: string, localKey?: string): IRelationship;
    morphTo(morphName: string, morphMap: Record<string, ModelStatic>, morphType?: string, morphId?: string): IRelationship;
    hasOneThrough(relatedModel: ModelStatic, through: ModelStatic, foreignKey?: string, throughForeignKey?: string, localKey?: string, secondLocalKey?: string): IRelationship;
    hasManyThrough(relatedModel: ModelStatic, through: ModelStatic, foreignKey?: string, throughForeignKey?: string, localKey?: string, secondLocalKey?: string): IRelationship;
}
/**
 * Create a new model instance
 */
export declare const createModel: (config: ModelConfig, attributes?: Record<string, unknown>) => IModel;
/**
 * Get a query builder for a table
 */
export declare const query: (table: string, connection?: string) => IQueryBuilder;
/**
 * Find a model by ID
 */
export declare const find: (config: ModelConfig, id: unknown) => Promise<IModel | null>;
/**
 * Get all records for a model
 */
export declare const all: (config: ModelConfig) => Promise<IModel[]>;
type UnboundModelMethods = Record<string, (m: IModel, ...args: unknown[]) => unknown>;
type BoundModelMethods = Record<string, (...args: never[]) => unknown>;
type BoundFromUnbound<T extends UnboundModelMethods> = {
    [K in keyof T]: T[K] extends (m: IModel, ...args: infer A) => infer R ? (...args: A) => R : never;
};
export type DefinedModel<T extends BoundModelMethods> = {
    create: (attributes?: Record<string, unknown> | undefined) => IModel & T;
    hydrate: (attributes: Record<string, unknown>) => IModel & T;
    hydrateWithRelations(attributes: Record<string, unknown>, related: Record<string, unknown>): IModel & T;
    find: (id: unknown) => Promise<(IModel & T) | null>;
    all: () => Promise<Array<IModel & T>>;
    raw: () => Promise<Array<Record<string, unknown>>>;
    query: () => IQueryBuilder;
    paginate: (page: number, perPage: number, options?: PaginationOptions) => Promise<Paginator<IModel & T>>;
    where: (column: string, operator: string | number | boolean | null, value?: unknown) => IQueryBuilder;
    andWhere: (column: string, operator: string, value?: unknown) => IQueryBuilder;
    orWhere: (column: string, operator: string, value?: unknown) => IQueryBuilder;
    whereIn: (column: string, values: unknown[]) => IQueryBuilder;
    whereNotIn: (column: string, values: unknown[]) => IQueryBuilder;
    select: (...columns: string[]) => IQueryBuilder;
    selectAs: (column: string, alias: string) => IQueryBuilder;
    max: (column: string, alias?: string) => IQueryBuilder;
    join: (table: string, on: string) => IQueryBuilder;
    leftJoin: (table: string, on: string) => IQueryBuilder;
    orderBy: (column: string, direction?: 'ASC' | 'DESC') => IQueryBuilder;
    limit: (count: number) => IQueryBuilder;
    offset: (count: number) => IQueryBuilder;
    withTrashed: () => IQueryBuilder;
    onlyTrashed: () => IQueryBuilder;
    withoutTrashed: () => IQueryBuilder;
    scope: (name: string, ...args: unknown[]) => IQueryBuilder;
    getTable: () => string;
    db: (connection: string) => DefinedModel<T>;
};
/**
 * Define a new model type
 */
export declare function define<const T extends UnboundModelMethods>(config: ModelConfig, methods?: T): DefinedModel<BoundFromUnbound<T>>;
export declare function define<const T extends BoundModelMethods>(config: ModelConfig, plan: (model: IModel) => T): DefinedModel<T>;
/**
 * Model namespace - sealed namespace object grouping all model operations
 * Frozen to prevent accidental mutation
 *
 * @see FRAMEWORK_REFACTOR_FUNCTION_PATTERN.md for Pattern 2 details
 */
export declare const Model: Readonly<{
    create: (config: ModelConfig, attributes?: Record<string, unknown>) => IModel;
    query: (table: string, connection?: string) => IQueryBuilder;
    find: (config: ModelConfig, id: unknown) => Promise<IModel | null>;
    all: (config: ModelConfig) => Promise<IModel[]>;
    insert: (config: ModelConfig, values: Record<string, unknown> | Array<Record<string, unknown>>) => Promise<InsertResult>;
    bulkInsert: (config: ModelConfig, records: Array<Record<string, unknown>>) => Promise<InsertResult>;
    define: typeof define;
}>;
export {};
//# sourceMappingURL=Model.d.ts.map