import { ElasticsearchConnectionManager } from '../../core/connection/connection-manager.js'; import { Logger } from '../../core/observability/logger.js'; import { MetricsCollector } from '../../core/observability/metrics.js'; import { TracingProvider } from '../../core/observability/tracing.js'; import { DocumentSession } from './document-session.js'; import type { DocumentWithMeta, SessionConfig, SnapshotProcessor, SnapshotMeta, IteratorOptions } from './types.js'; /** * Document manager configuration */ export interface DocumentManagerConfig { /** Index name */ index: string; /** Connection manager (optional, will use singleton if not provided) */ connectionManager?: ElasticsearchConnectionManager; /** Logger (optional, will use default if not provided) */ logger?: Logger; /** Metrics collector (optional) */ metrics?: MetricsCollector; /** Tracing provider (optional) */ tracing?: TracingProvider; /** Auto-create index if it doesn't exist */ autoCreateIndex?: boolean; /** Default batch size for operations */ defaultBatchSize?: number; } /** * Fluent document manager for Elasticsearch * * @example * ```typescript * const docs = new DocumentManager('products'); * await docs.initialize(); * * // Session-based operations * await docs * .session() * .start() * .upsert('prod-1', { name: 'Widget', price: 99.99 }) * .upsert('prod-2', { name: 'Gadget', price: 149.99 }) * .commit(); * * // Get a document * const product = await docs.get('prod-1'); * * // Create snapshot * const snapshot = await docs.snapshot(async (iterator) => { * const products = []; * for await (const doc of iterator) { * products.push(doc._source); * } * return { totalCount: products.length, products }; * }); * ``` */ export declare class DocumentManager { private client; private connectionManager; private logger; private metrics; private tracing; private index; private config; private isInitialized; constructor(config: DocumentManagerConfig); /** * Static factory method for fluent creation */ static create(index: string, config?: Omit): DocumentManager; /** * Initialize the document manager */ initialize(): Promise; /** * Create a new session for batch operations */ session(config?: SessionConfig): DocumentSession; /** * Get a single document by ID */ get(documentId: string): Promise | null>; /** * Create a document */ create(documentId: string, document: T): Promise; /** * Update a document */ update(documentId: string, document: Partial, options?: { seqNo?: number; primaryTerm?: number; }): Promise; /** * Upsert a document (create or update) */ upsert(documentId: string, document: T): Promise; /** * Delete a document */ delete(documentId: string): Promise; /** * Check if index exists */ exists(): Promise; /** * Delete the index */ deleteIndex(): Promise; /** * Get document count */ count(query?: unknown): Promise; /** * Create a snapshot with custom processor */ snapshot(processor: SnapshotProcessor): Promise>; /** * Iterate over all documents */ iterate(options?: IteratorOptions): AsyncIterableIterator>; /** * Get latest snapshot */ private getLatestSnapshot; /** * Store snapshot */ private storeSnapshot; /** * Ensure manager is initialized */ private ensureInitialized; /** * Get index name */ getIndex(): string; }