/**
 * Chunk operations for DatabaseService
 *
 * Handles all CRUD operations for text chunks including
 * batch inserts, embedding status updates, filtered queries,
 * and neighbor lookups.
 */
import Database from 'better-sqlite3';
import { Chunk } from '../../../models/chunk.js';
/**
 * Filter options for getChunksFiltered
 */
export interface ChunkFilterOptions {
    section_path_filter?: string;
    heading_filter?: string;
    content_type_filter?: string[];
    min_quality_score?: number;
    embedding_status?: 'pending' | 'complete' | 'failed';
    is_atomic?: boolean;
    page_range?: {
        min_page?: number;
        max_page?: number;
    };
    limit?: number;
    offset?: number;
    include_text?: boolean;
}
/**
 * Insert a chunk
 *
 * @param db - Database connection
 * @param chunk - Chunk data (created_at, embedding_status, embedded_at will be generated)
 * @param updateMetadataCounts - Callback to update metadata counts
 * @returns string - The chunk ID
 */
export declare function insertChunk(db: Database.Database, chunk: Omit<Chunk, 'created_at' | 'embedding_status' | 'embedded_at'>, updateMetadataCounts: () => void): string;
/**
 * Insert multiple chunks in a batch transaction
 *
 * @param db - Database connection
 * @param chunks - Array of chunk data
 * @param updateMetadataCounts - Callback to update metadata counts
 * @param transaction - Transaction wrapper function
 * @returns string[] - Array of chunk IDs
 */
export declare function insertChunks(db: Database.Database, chunks: Omit<Chunk, 'created_at' | 'embedding_status' | 'embedded_at'>[], updateMetadataCounts: () => void, transaction: <T>(fn: () => T) => T): string[];
/**
 * Get a chunk by ID
 *
 * @param db - Database connection
 * @param id - Chunk ID
 * @returns Chunk | null - The chunk or null if not found
 */
export declare function getChunk(db: Database.Database, id: string): Chunk | null;
/**
 * Check if a document has any chunks (M-9: avoids loading all chunk rows)
 *
 * @param db - Database connection
 * @param documentId - Document ID
 * @returns boolean - true if document has at least one chunk
 */
export declare function hasChunksByDocumentId(db: Database.Database, documentId: string): boolean;
/**
 * Get all chunks for a document
 *
 * @param db - Database connection
 * @param documentId - Document ID
 * @returns Chunk[] - Array of chunks ordered by chunk_index
 */
export declare function getChunksByDocumentId(db: Database.Database, documentId: string, options?: {
    limit?: number;
    offset?: number;
}): Chunk[];
/**
 * Get all chunks for an OCR result
 *
 * @param db - Database connection
 * @param ocrResultId - OCR result ID
 * @returns Chunk[] - Array of chunks ordered by chunk_index
 */
export declare function getChunksByOCRResultId(db: Database.Database, ocrResultId: string, options?: {
    limit?: number;
    offset?: number;
}): Chunk[];
/**
 * Get chunks pending embedding generation
 *
 * @param db - Database connection
 * @param limit - Optional maximum number of chunks to return
 * @returns Chunk[] - Array of pending chunks
 */
export declare function getPendingEmbeddingChunks(db: Database.Database, limit?: number): Chunk[];
/**
 * Update chunk embedding status
 *
 * @param db - Database connection
 * @param id - Chunk ID
 * @param status - New embedding status
 * @param embeddedAt - Optional ISO 8601 timestamp when embedded
 * @param updateMetadataModified - Callback to update metadata modified timestamp
 */
export declare function updateChunkEmbeddingStatus(db: Database.Database, id: string, status: 'pending' | 'complete' | 'failed', embeddedAt: string | undefined, updateMetadataModified: () => void): void;
/**
 * Get chunks for a document with dynamic filtering.
 *
 * Builds a parameterized WHERE clause from the provided filters.
 * For content_type_filter, uses LIKE matching against the JSON-encoded
 * content_types column (e.g., content_types LIKE '%table%').
 *
 * @param db - Database connection
 * @param documentId - Document ID to filter by
 * @param filters - Filter options
 * @returns Object with chunks array and total count
 */
export declare function getChunksFiltered(db: Database.Database, documentId: string, filters: ChunkFilterOptions): {
    chunks: Chunk[];
    total: number;
};
/**
 * Get neighboring chunks around a given chunk index for context building.
 *
 * Returns chunks with chunk_index in range [chunkIndex - count, chunkIndex + count],
 * ordered by chunk_index.
 *
 * @param db - Database connection
 * @param documentId - Document ID
 * @param chunkIndex - Center chunk index
 * @param count - Number of neighbors on each side
 * @returns Chunk[] - Array of neighboring chunks (including center)
 */
export declare function getChunkNeighbors(db: Database.Database, documentId: string, chunkIndex: number, count: number): Chunk[];
//# sourceMappingURL=chunk-operations.d.ts.map