UNPKG

@codai/memorai-core

Version:

Simplified advanced memory engine - no tiers, just powerful semantic search with persistence

88 lines 2.46 kB
/** * Production PostgreSQL Storage Adapter * Enterprise-grade PostgreSQL implementation with connection pooling, transactions, and error handling */ import { PoolConfig } from 'pg'; import { MemoryMetadata } from '../types/index.js'; import { MemoryFilters, StorageAdapter } from './StorageAdapter.js'; export interface PostgreSQLConfig extends PoolConfig { host: string; port: number; database: string; user: string; password: string; ssl?: boolean | object; connectionTimeoutMillis?: number; idleTimeoutMillis?: number; max?: number; min?: number; } /** * Production PostgreSQL storage adapter with enterprise features */ export declare class ProductionPostgreSQLAdapter implements StorageAdapter { private config; private pool; private isInitialized; constructor(config: PostgreSQLConfig); /** * Initialize the adapter and create necessary tables */ initialize(): Promise<void>; /** * Store a memory in PostgreSQL with transaction support */ store(memory: MemoryMetadata): Promise<void>; /** * Retrieve a memory by ID */ retrieve(id: string): Promise<MemoryMetadata | null>; /** * Update memory with optimistic locking */ update(id: string, updates: Partial<MemoryMetadata>): Promise<void>; /** * Delete a memory by ID */ delete(id: string): Promise<void>; /** * List memories with advanced filtering and pagination */ list(filters?: MemoryFilters): Promise<MemoryMetadata[]>; /** * Clear memories with optional tenant filtering */ clear(tenantId?: string): Promise<void>; /** * Get memory count with filtering */ getCount(filters?: MemoryFilters): Promise<number>; /** * Perform bulk operations with transaction support */ bulkStore(memories: MemoryMetadata[]): Promise<void>; /** * Close the connection pool */ close(): Promise<void>; /** * Health check for the adapter */ healthCheck(): Promise<{ status: 'healthy' | 'unhealthy'; details: any; }>; /** * Create tables if they don't exist */ private createTablesIfNotExists; /** * Create indexes for better performance */ private createIndexes; /** * Convert database row to MemoryMetadata */ private rowToMemory; } //# sourceMappingURL=ProductionPostgreSQLAdapter.d.ts.map