import type { Client as ElasticClient } from '@elastic/elasticsearch'; import type { BatchResult, SessionConfig } from './types.js'; import { Logger } from '../../core/observability/logger.js'; /** * Document session for managing document lifecycle * * Tracks documents during a session and can clean up stale ones at the end. */ export declare class DocumentSession { private client; private index; private logger; private operations; private seenDocuments; private config; private startTimestamp; private isActive; constructor(client: ElasticClient, index: string, logger: Logger, config?: SessionConfig); /** * Start the session */ start(): this; /** * Add a document (upsert - create or update) */ upsert(documentId: string, document: T): this; /** * Create a document (fails if exists) */ create(documentId: string, document: T): this; /** * Update a document (fails if doesn't exist) */ update(documentId: string, document: T, version?: { seqNo: number; primaryTerm: number; }): this; /** * Delete a document */ delete(documentId: string): this; /** * Commit the session and execute all operations */ commit(): Promise; /** * Rollback the session (discard all operations) */ rollback(): void; /** * Execute batch operations */ private executeBatch; /** * Clean up documents not seen in this session */ private cleanupStaleDocuments; /** * Ensure session is active */ private ensureActive; /** * Get session statistics */ getStats(): { isActive: boolean; operationCount: number; seenDocumentCount: number; startTime: Date; }; }