index.d.tsā¢9.06 kB
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
/** Configuration for vector operations */
export interface VectorConfig {
/** Use SIMD instructions when available */
useSimd: boolean
/** Use parallel processing for batch operations */
useParallel: boolean
/** Similarity threshold for filtering results */
similarityThreshold: number
}
/** Result of a similarity search */
export interface SimilarityResult {
/** Index in the original vector collection */
index: number
/** Path or identifier for the vector */
path: string
/** Similarity score (0.0 to 1.0) */
similarity: number
}
/** Batch embedding generation result */
export interface BatchEmbeddingResult {
/** Generated embeddings - flattened array (embeddings_count * embedding_size) */
embeddingsFlat: Array<number>
/** Number of embeddings */
embeddingsCount: number
/** Size of each embedding */
embeddingSize: number
/** Processing time in milliseconds */
processingTimeMs: number
/** Whether SIMD was used */
usedSimd: boolean
}
/** Standalone function for quick similarity calculation */
export declare function quickCosineSimilarity(vecA: Array<number>, vecB: Array<number>): number
/** Benchmark vector operations performance */
export declare function benchmarkVectorOperations(vectorSize: number, numVectors: number): Record<string, number>
/** Configuration for file search operations */
export interface FileSearchConfig {
/** Maximum depth for directory traversal (-1 for unlimited) */
maxDepth: number
/** Follow symbolic links */
followSymlinks: boolean
/** Include hidden files (.dot files) */
includeHidden: boolean
/** Use parallel processing */
useParallel: boolean
/** Patterns to exclude */
excludePatterns: Array<string>
/** File size limit in bytes (0 for no limit) */
maxFileSize: number
}
/** File metadata result */
export interface FileInfo {
/** Absolute path to the file */
path: string
/** File name */
name: string
/** File size in bytes */
size: number
/** Last modified timestamp (milliseconds since Unix epoch) */
lastModified: number
/** Is directory */
isDirectory: boolean
/** File extension (if any) */
extension?: string
}
/** Text search result */
export interface TextSearchResult {
/** File path */
path: string
/** Line number (1-based) */
lineNumber: number
/** Column start position */
columnStart: number
/** Column end position */
columnEnd: number
/** The matching line content */
lineContent: string
/** Match text */
matchText: string
}
/** Directory statistics */
export interface DirectoryStats {
/** Total size in bytes */
totalSize: number
/** Number of files */
fileCount: number
/** Number of directories */
directoryCount: number
/** Largest file size */
largestFileSize: number
/** Average file size */
averageFileSize: number
}
/** Standalone function for quick file search */
export declare function quickFindFiles(rootPath: string, pattern: string): Array<FileInfo>
/** Standalone function for quick text search */
export declare function quickSearchText(rootPath: string, searchText: string, filePattern?: string | undefined | null): Array<TextSearchResult>
/** Benchmark file search performance */
export declare function benchmarkFileSearch(rootPath: string, pattern: string, iterations: number): Record<string, number>
/** Configuration for text processing */
export interface TextProcessingConfig {
/** Case-sensitive matching */
caseSensitive: boolean
/** Use overlapping matches */
overlapping: boolean
/** Maximum match count (0 for unlimited) */
maxMatches: number
}
/** Text match result */
export interface TextMatch {
/** Start position of the match */
start: number
/** End position of the match */
end: number
/** The matched text */
text: string
/** Pattern index (for multi-pattern search) */
patternIndex: number
}
/** Quick substring search function */
export declare function quickSubstringSearch(text: string, patterns: Array<string>, caseSensitive?: boolean | undefined | null): Array<TextMatch>
/** Path validation result */
export interface PathValidationResult {
/** Whether the path is valid */
isValid: boolean
/** Sanitized path (if valid) */
sanitizedPath?: string
/** Error message (if invalid) */
error?: string
}
/** Quick path validation function */
export declare function quickValidatePath(path: string, basePath: string): boolean
/** Benchmark result */
export interface BenchmarkResult {
/** Test name */
name: string
/** Average execution time in milliseconds */
avgTimeMs: number
/** Operations per second */
opsPerSec: number
/** Performance improvement ratio */
speedup: number
}
/** Quick benchmark function */
export declare function quickBenchmark(): Record<string, number>
/**
* Initialize the MOIDVK Rust core module
*
* Returns a success message indicating the core has been initialized
*/
export declare function initializeRustCore(): string
/**
* Get the version of the MOIDVK core crate
*
* Returns the version string from Cargo.toml
*/
export declare function getVersion(): string
/**
* Get performance information about the Rust runtime
*
* Returns JSON string with SIMD support, thread count, allocator info, etc.
*/
export declare function getPerformanceInfo(): string
/** Vector operations implementation */
export declare class VectorOperations {
/**
* Create a new vector operations instance with optional configuration
*
* # Arguments
* * `config` - Optional configuration for vector operations
*/
constructor(config?: VectorConfig | undefined | null)
/**
* Calculate cosine similarity between two vectors
* 10-20x faster than JavaScript implementation
*/
cosineSimilarity(vecA: Array<number>, vecB: Array<number>): number
/**
* Calculate cosine similarity for multiple vector pairs in parallel
* 20-50x faster than JavaScript for large batches
*/
batchCosineSimilarity(queryVector: Array<number>, vectorsFlat: Array<number>, vectorSize: number): Array<number>
/**
* Find the most similar vectors from a collection
* Returns top-k results above the similarity threshold
*/
findSimilarVectors(queryVector: Array<number>, vectorsFlat: Array<number>, vectorSize: number, paths: Array<string>, topK: number): Array<SimilarityResult>
/** Normalize a vector to unit length */
normalizeVector(vector: Array<number>): Array<number>
/** Calculate the L2 norm (magnitude) of a vector */
vectorNorm(vector: Array<number>): number
/** Compute pairwise distances between all vectors in a collection */
pairwiseDistances(vectorsFlat: Array<number>, vectorSize: number): Array<number>
/** Create embeddings cache key from vector */
createCacheKey(vector: Array<number>): string
}
/** File search operations implementation */
export declare class FileSearch {
/**
* Create a new file search instance with optional configuration
*
* # Arguments
* * `config` - Optional configuration for file search operations
*/
constructor(config?: FileSearchConfig | undefined | null)
/**
* Search for files by glob pattern
* 5-10x faster than Node.js glob implementations
*/
findFilesByPattern(rootPath: string, pattern: string): Array<FileInfo>
/**
* Search for text content within files
* 10-20x faster than JavaScript regex operations on large files
*/
searchTextInFiles(rootPath: string, searchText: string, filePattern?: string | undefined | null, caseSensitive?: boolean | undefined | null): Array<TextSearchResult>
/** Get directory statistics (size, file count, etc.) */
getDirectoryStats(path: string): DirectoryStats
/** Create a map of file extensions to their counts */
getFileExtensionStats(path: string): Record<string, number>
/** Fast duplicate file finder using content hashing */
findDuplicateFiles(path: string): Record<string, Array<string>>
}
/** Text processor for high-performance pattern matching */
export declare class TextProcessor {
/** Create a new text processing instance with optional configuration */
constructor(config?: TextProcessingConfig | undefined | null)
/** Fast substring search using Aho-Corasick */
findSubstrings(text: string, patterns: Array<string>): Array<TextMatch>
/** Regex pattern matching */
findRegexMatches(text: string, pattern: string): Array<TextMatch>
}
/** Security utilities */
export declare class SecurityUtils {
/** Create a new security utilities instance */
constructor()
/** Validate and sanitize file path */
validatePath(path: string, basePath: string): PathValidationResult
/** Sanitize filename by removing dangerous characters */
sanitizeFilename(filename: string): string
}
/** Benchmark suite */
export declare class BenchmarkSuite {
/** Create a new benchmark runner instance */
constructor()
/** Run all performance benchmarks */
runAllBenchmarks(): Array<BenchmarkResult>
/** Get benchmark results */
getResults(): Array<BenchmarkResult>
}