import { RedisCacheConfig, SqliteDatabaseConfig, PostgresDatabaseConfig, LocalBlobStoreConfig, InMemoryBlobStoreConfigInput } from './schemas.cjs'; export { BLOB_STORE_TYPES, BlobStoreConfig, BlobStoreConfigSchema, BlobStoreType, CACHE_TYPES, CacheConfig, CacheConfigSchema, CacheType, DATABASE_TYPES, DatabaseConfig, DatabaseConfigSchema, DatabaseType, InMemoryBlobStoreConfig, InMemoryBlobStoreSchema, InMemoryCacheConfig, InMemoryCacheSchema, InMemoryDatabaseConfig, InMemoryDatabaseSchema, LocalBlobStoreConfigInput, LocalBlobStoreSchema, PostgresDatabaseSchema, RedisCacheSchema, SqliteDatabaseSchema, StorageConfig, StorageSchema, ValidatedStorageConfig } from './schemas.cjs'; import { Cache, Logger, Database, BlobStore, BlobInput, BlobMetadata, BlobReference, BlobData, BlobStats } from '@dexto/core'; import { PoolClient } from 'pg'; import 'zod'; /** * In-memory cache store for development and testing. * Supports TTL for automatic cleanup of temporary data. * Data is lost when the process restarts. */ declare class MemoryCacheStore implements Cache { private data; private ttls; private connected; connect(): Promise; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; get(key: string): Promise; set(key: string, value: T, ttlSeconds?: number): Promise; delete(key: string): Promise; private checkConnection; private checkTTL; clear(): Promise; dump(): Promise<{ data: Record; }>; } /** * Redis cache store for production cache operations. * Implements the Cache interface with connection pooling and optimizations. * EXPERIMENTAL - NOT FULLY TESTED YET */ declare class RedisStore implements Cache { private config; private redis; private connected; private logger; constructor(config: RedisCacheConfig, logger: Logger); connect(): Promise; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; get(key: string): Promise; set(key: string, value: T, ttlSeconds?: number): Promise; delete(key: string): Promise; mget(keys: string[]): Promise<(T | undefined)[]>; mset(entries: [string, T][]): Promise; exists(key: string): Promise; expire(key: string, ttlSeconds: number): Promise; increment(key: string, by?: number): Promise; decrement(key: string, by?: number): Promise; private checkConnection; flushdb(): Promise; info(): Promise; } /** * In-memory database store for development and testing. * Supports list operations for message history and enumeration for settings. * Data is lost when the process restarts. */ declare class MemoryDatabaseStore implements Database { private data; private lists; private connected; connect(): Promise; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; get(key: string): Promise; set(key: string, value: T): Promise; setIfAbsent(key: string, value: T): Promise<{ value: T; inserted: boolean; }>; delete(key: string): Promise; list(prefix: string): Promise; append(key: string, item: T): Promise; updateList(key: string, updater: (items: T[]) => { items: T[]; result: R; }): Promise; getRange(key: string, start: number, count: number): Promise; private checkConnection; clear(): Promise; dump(): Promise<{ data: Record; lists: Record; }>; } /** * SQLite database store for local development and production. * Implements the Database interface with proper schema and connection handling. */ declare class SQLiteStore implements Database { private db; private dbPath; private config; private logger; constructor(config: SqliteDatabaseConfig, logger: Logger); private initializeTables; connect(): Promise; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; get(key: string): Promise; set(key: string, value: T): Promise; setIfAbsent(key: string, value: T): Promise<{ value: T; inserted: boolean; }>; delete(key: string): Promise; list(prefix: string): Promise; append(key: string, item: T): Promise; updateList(key: string, updater: (items: T[]) => { items: T[]; result: R; }): Promise; getRange(key: string, start: number, count: number): Promise; private checkConnection; vacuum(): Promise; getStats(): Promise<{ kvCount: number; listCount: number; dbSize: number; }>; } /** * PostgreSQL database store for production database operations. * Implements the Database interface with connection pooling and JSONB support. * EXPERIMENTAL - NOT FULLY TESTED YET */ declare class PostgresStore implements Database { private config; private pool; private connected; private logger; constructor(config: PostgresDatabaseConfig, logger: Logger); connect(): Promise; /** * Creates a PostgreSQL schema if it doesn't exist. */ private createSchema; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; get(key: string): Promise; set(key: string, value: T): Promise; setIfAbsent(key: string, value: T): Promise<{ value: T; inserted: boolean; }>; delete(key: string): Promise; list(prefix: string): Promise; append(key: string, item: T): Promise; updateList(key: string, updater: (items: T[]) => { items: T[]; result: R; }): Promise; getRange(key: string, start: number, count: number): Promise; private createTables; private checkConnection; /** * Check if an error is a connection error that should trigger a retry. * Common with serverless databases (Neon) where connections go stale. */ private isConnectionError; /** * Execute a database operation with automatic retry on connection errors. * Handles serverless DB connection issues (Neon cold starts, stale connections). */ private withRetry; /** * Execute a callback within a database transaction. * Note: On connection failure, the entire callback will be retried on a new connection. * Ensure callback operations are idempotent or use this only for read operations. */ transaction(callback: (client: PoolClient) => Promise): Promise; private transactionOnce; getStats(): Promise<{ kvCount: number; listCount: number; totalSize: string; }>; vacuum(): Promise; } /** * Local filesystem blob store implementation. * * Stores blobs on the local filesystem with content-based deduplication * and metadata tracking. This is the default store for development * and single-machine deployments. */ declare class LocalBlobStore implements BlobStore { private config; private storePath; private connected; private statsCache; private statsCachePromise; private lastStatsRefresh; private logger; private static readonly STATS_REFRESH_INTERVAL_MS; constructor(config: LocalBlobStoreConfig, logger: Logger); connect(): Promise; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; store(input: BlobInput, metadata?: BlobMetadata): Promise; retrieve(reference: string, format?: 'base64' | 'buffer' | 'path' | 'stream' | 'url'): Promise; exists(reference: string): Promise; delete(reference: string): Promise; cleanup(olderThan?: Date): Promise; getStats(): Promise; getStoragePath(): string | undefined; listBlobs(): Promise; private ensureStatsCache; private refreshStatsCache; private updateStatsCacheAfterStore; private updateStatsCacheAfterDelete; /** * Convert various input types to Buffer */ private inputToBuffer; /** * Parse blob reference to extract ID */ private parseReference; /** * Detect MIME type from buffer content and/or filename */ private detectMimeType; /** * Check if buffer contains text content */ private isTextBuffer; } /** * In-memory blob store implementation. * * Stores blobs in memory with content-based deduplication and size limits. * Suitable for development, testing, and scenarios where blob persistence * across restarts is not required. * * Features: * - Content-based deduplication (same as LocalBlobStore) * - Configurable size limits (per-blob and total) * - Automatic cleanup of old blobs * - MIME type detection * - Multi-format retrieval (base64, buffer, stream, data URI) * * Limitations: * - Data lost on restart (no persistence) * - Path format not supported (no filesystem) * - Memory usage proportional to blob size */ type MemoryBlobStoreOptions = Omit; declare class MemoryBlobStore implements BlobStore { private config; private blobs; private connected; private logger; constructor(options: MemoryBlobStoreOptions, logger: Logger); connect(): Promise; disconnect(): Promise; isConnected(): boolean; getStoreType(): string; store(input: BlobInput, metadata?: BlobMetadata): Promise; retrieve(reference: string, format?: 'base64' | 'buffer' | 'path' | 'stream' | 'url'): Promise; exists(reference: string): Promise; delete(reference: string): Promise; cleanup(olderThan?: Date): Promise; getStats(): Promise; listBlobs(): Promise; getStoragePath(): string | undefined; /** * Calculate total size of all blobs in memory */ private getTotalSize; /** * Convert various input types to Buffer. * Copied from LocalBlobStore with minor adaptations. */ private inputToBuffer; /** * Parse blob reference to extract ID. * Copied from LocalBlobStore. */ private parseReference; /** * Detect MIME type from buffer content and/or filename. * Copied from LocalBlobStore. */ private detectMimeType; /** * Check if buffer contains text content. * Copied from LocalBlobStore. */ private isTextBuffer; } export { InMemoryBlobStoreConfigInput, LocalBlobStore, LocalBlobStoreConfig, MemoryBlobStore, MemoryCacheStore, MemoryDatabaseStore, PostgresDatabaseConfig, PostgresStore, RedisCacheConfig, RedisStore, SQLiteStore, SqliteDatabaseConfig };