/**
 * Base Repository Pattern
 *
 * Provides abstract repository interface for domain entities
 * with tenant scoping, soft deletes, and pagination.
 *
 * @packageDocumentation
 */
export interface QueryOptions {
    /** Limit number of results */
    limit?: number;
    /** Offset for pagination */
    offset?: number;
    /** Cursor for cursor-based pagination */
    cursor?: string;
    /** Include soft-deleted records */
    includeDeleted?: boolean;
    /** Order by field */
    orderBy?: string;
    /** Order direction */
    orderDir?: 'asc' | 'desc';
}
export interface PaginatedResult<T> {
    /** Items in current page */
    items: T[];
    /** Total count (if available) */
    total?: number;
    /** Limit used */
    limit: number;
    /** Offset used */
    offset?: number;
    /** Next cursor for pagination */
    nextCursor?: string;
    /** Has more results */
    hasMore: boolean;
}
export interface EntityMeta {
    /** Creation timestamp */
    createdAt: string;
    /** Last update timestamp */
    updatedAt: string;
    /** Soft delete timestamp */
    deletedAt?: string;
}
export interface TenantScoped {
    /** Tenant identifier */
    tenantId: string;
}
/**
 * Abstract base repository for domain entities
 */
export declare abstract class BaseRepository<T, ID = string> {
    protected readonly entityName: string;
    constructor(entityName: string);
    /**
     * Create a new entity
     */
    abstract create(entity: Omit<T, 'id' | 'createdAt' | 'updatedAt'>): Promise<T>;
    /**
     * Find entity by ID
     */
    abstract findById(id: ID): Promise<T | null>;
    /**
     * Find entities by tenant
     */
    abstract findByTenant(tenantId: string, options?: QueryOptions): Promise<PaginatedResult<T>>;
    /**
     * Update an entity
     */
    abstract update(id: ID, updates: Partial<T>): Promise<T>;
    /**
     * Soft delete an entity
     */
    abstract softDelete(id: ID): Promise<void>;
    /**
     * Hard delete an entity (use with caution)
     */
    abstract hardDelete(id: ID): Promise<void>;
    /**
     * Check if entity exists
     */
    abstract exists(id: ID): Promise<boolean>;
    /**
     * Count entities by tenant
     */
    abstract countByTenant(tenantId: string): Promise<number>;
    /**
     * Log repository operation
     */
    protected logOperation(operation: string, id?: ID, details?: Record<string, unknown>): void;
}
export interface CacheAdapter {
    get<T>(key: string): Promise<T | null>;
    set<T>(key: string, value: T, ttlMs: number): Promise<void>;
    delete(key: string): Promise<void>;
    deletePattern(pattern: string): Promise<void>;
}
export interface CacheOptions {
    /** TTL in milliseconds */
    ttl: number;
    /** Key prefix */
    prefix: string;
    /** Whether to cache list results */
    cacheList?: boolean;
}
/**
 * Cached repository wrapper using cache-aside pattern
 */
export declare class CachedRepository<T extends TenantScoped, ID = string> {
    private inner;
    private cache;
    private options;
    constructor(inner: BaseRepository<T, ID>, cache: CacheAdapter, options: CacheOptions);
    private cacheKey;
    private tenantCacheKey;
    /**
     * Find by ID with cache
     */
    findById(id: ID): Promise<T | null>;
    /**
     * Create with cache invalidation
     */
    create(entity: Omit<T, 'id' | 'createdAt' | 'updatedAt'>): Promise<T>;
    /**
     * Update with cache invalidation
     */
    update(id: ID, updates: Partial<T>): Promise<T>;
    /**
     * Delete with cache invalidation
     */
    softDelete(id: ID): Promise<void>;
    /**
     * Find by tenant with optional caching
     */
    findByTenant(tenantId: string, options?: QueryOptions): Promise<PaginatedResult<T>>;
    /**
     * Invalidate cache for an entity
     */
    invalidate(id: ID): Promise<void>;
    /**
     * Invalidate all cache for a tenant
     */
    invalidateTenant(tenantId: string): Promise<void>;
}
export interface UnitOfWork {
    /** Begin transaction */
    begin(): Promise<void>;
    /** Commit transaction */
    commit(): Promise<void>;
    /** Rollback transaction */
    rollback(): Promise<void>;
    /** Execute within transaction */
    execute<T>(fn: () => Promise<T>): Promise<T>;
}
/**
 * Create a unit of work for transactional operations
 */
export declare function createUnitOfWork(getConnection: () => Promise<{
    query: (sql: string) => Promise<void>;
}>): UnitOfWork;
/**
 * Specification interface for complex queries
 */
export interface Specification<T> {
    /** Check if entity satisfies specification */
    isSatisfiedBy(entity: T): boolean;
    /** Convert to SQL WHERE clause */
    toSql(): {
        clause: string;
        params: unknown[];
    };
    /** Combine with AND */
    and(other: Specification<T>): Specification<T>;
    /** Combine with OR */
    or(other: Specification<T>): Specification<T>;
    /** Negate specification */
    not(): Specification<T>;
}
/**
 * Base specification implementation
 */
export declare abstract class BaseSpecification<T> implements Specification<T> {
    abstract isSatisfiedBy(entity: T): boolean;
    abstract toSql(): {
        clause: string;
        params: unknown[];
    };
    and(other: Specification<T>): Specification<T>;
    or(other: Specification<T>): Specification<T>;
    not(): Specification<T>;
}
//# sourceMappingURL=repository.d.ts.map