/** * File System Storage Adapter * File system storage adapter for Node.js environments */ import { GraphVerb, HNSWNoun, HNSWVerb, StatisticsData } from '../../coreTypes.js'; import { BaseStorage } from '../baseStorage.js'; type HNSWNode = HNSWNoun; type Edge = HNSWVerb; /** * File system storage adapter for Node.js environments * Uses the file system to store data in the specified directory structure */ export declare class FileSystemStorage extends BaseStorage { private rootDir; private nounsDir; private verbsDir; private metadataDir; private nounMetadataDir; private verbMetadataDir; private indexDir; private systemDir; private lockDir; private useDualWrite; private activeLocks; /** * Initialize the storage adapter * @param rootDirectory The root directory for storage */ constructor(rootDirectory: string); /** * Initialize the storage adapter */ init(): Promise; /** * Check if a directory exists */ private directoryExists; /** * Ensure a directory exists, creating it if necessary */ private ensureDirectoryExists; /** * Save a node to storage */ protected saveNode(node: HNSWNode): Promise; /** * Get a node from storage */ protected getNode(id: string): Promise; /** * Get all nodes from storage */ protected getAllNodes(): Promise; /** * Get nodes by noun type * @param nounType The noun type to filter by * @returns Promise that resolves to an array of nodes of the specified noun type */ protected getNodesByNounType(nounType: string): Promise; /** * Delete a node from storage */ protected deleteNode(id: string): Promise; /** * Save an edge to storage */ protected saveEdge(edge: Edge): Promise; /** * Get an edge from storage */ protected getEdge(id: string): Promise; /** * Get all edges from storage */ protected getAllEdges(): Promise; /** * Get edges by source */ protected getEdgesBySource(sourceId: string): Promise; /** * Get edges by target */ protected getEdgesByTarget(targetId: string): Promise; /** * Get edges by type */ protected getEdgesByType(type: string): Promise; /** * Delete an edge from storage */ protected deleteEdge(id: string): Promise; /** * Save metadata to storage */ saveMetadata(id: string, metadata: any): Promise; /** * Get metadata from storage */ getMetadata(id: string): Promise; /** * Get multiple metadata objects in batches (CRITICAL: Prevents socket exhaustion) * FileSystem implementation uses controlled concurrency to prevent too many file reads */ getMetadataBatch(ids: string[]): Promise>; /** * Save noun metadata to storage */ saveNounMetadata(id: string, metadata: any): Promise; /** * Get noun metadata from storage */ getNounMetadata(id: string): Promise; /** * Save verb metadata to storage */ saveVerbMetadata(id: string, metadata: any): Promise; /** * Get verb metadata from storage */ getVerbMetadata(id: string): Promise; /** * Get nouns with pagination support * @param options Pagination options */ getNounsWithPagination(options?: { limit?: number; cursor?: string; filter?: any; }): Promise<{ items: HNSWNoun[]; totalCount: number; hasMore: boolean; nextCursor?: string; }>; /** * Clear all data from storage */ clear(): Promise; /** * Get information about storage usage and capacity */ getStorageStatus(): Promise<{ type: string; used: number; quota: number | null; details?: Record; }>; /** * Implementation of abstract methods from BaseStorage */ /** * Save a noun to storage */ protected saveNoun_internal(noun: HNSWNoun): Promise; /** * Get a noun from storage */ protected getNoun_internal(id: string): Promise; /** * Get nouns by noun type */ protected getNounsByNounType_internal(nounType: string): Promise; /** * Delete a noun from storage */ protected deleteNoun_internal(id: string): Promise; /** * Save a verb to storage */ protected saveVerb_internal(verb: HNSWVerb): Promise; /** * Get a verb from storage */ protected getVerb_internal(id: string): Promise; /** * Get verbs by source */ protected getVerbsBySource_internal(sourceId: string): Promise; /** * Get verbs by target */ protected getVerbsByTarget_internal(targetId: string): Promise; /** * Get verbs by type */ protected getVerbsByType_internal(type: string): Promise; /** * Delete a verb from storage */ protected deleteVerb_internal(id: string): Promise; /** * Acquire a file-based lock for coordinating operations across multiple processes * @param lockKey The key to lock on * @param ttl Time to live for the lock in milliseconds (default: 30 seconds) * @returns Promise that resolves to true if lock was acquired, false otherwise */ private acquireLock; /** * Release a file-based lock * @param lockKey The key to unlock * @param lockValue The value used when acquiring the lock (for verification) * @returns Promise that resolves when lock is released */ private releaseLock; /** * Clean up expired lock files */ private cleanupExpiredLocks; /** * Save statistics data to storage with file-based locking */ protected saveStatisticsData(statistics: StatisticsData): Promise; /** * Get statistics data from storage */ protected getStatisticsData(): Promise; /** * Save statistics with backward compatibility (dual write) */ private saveStatisticsWithBackwardCompat; /** * Get statistics with backward compatibility (dual read) */ private getStatisticsWithBackwardCompat; } export {};