@codai/cbd
Version:
Codai Better Database - High-Performance Vector Memory System with HPKV-inspired architecture and MCP server
107 lines • 3.67 kB
TypeScript
/**
* File Storage Engine - CBD Universal Data Platform
* 6th Paradigm: File/Blob Storage with AI Intelligence
*
* Features:
* - Multi-cloud file storage (AWS S3, Azure Blob, GCP Storage)
* - AI-powered content analysis and indexing
* - Intelligent cloud selection and cost optimization
* - Seamless integration with structured data paradigms
* - Universal search across all data types
*/
import { Buffer } from 'buffer';
import { EventEmitter } from 'events';
export interface FileDocument {
readonly id?: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly content: Buffer;
readonly metadata?: Record<string, any>;
readonly tags?: string[];
readonly bucket?: string;
}
export interface FileResult {
readonly id: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly url: string;
readonly cdnUrl?: string;
readonly hash: string;
readonly metadata: FileMetadata;
readonly timestamp: Date;
readonly cloudProvider?: string;
readonly bucket: string;
}
export interface FileMetadata {
readonly contentType: string;
readonly size: number;
readonly hash: string;
readonly lastModified: Date;
readonly tags: string[];
readonly analysis?: ContentAnalysis;
readonly custom?: Record<string, any>;
}
export interface ContentAnalysis {
readonly textContent?: string;
readonly language?: string;
readonly sentiment?: number;
readonly keywords: string[];
readonly categories: string[];
readonly confidence: number;
readonly embeddings?: number[];
readonly duplicateOf?: string;
}
export interface FileSearchOptions {
readonly limit?: number;
readonly offset?: number;
readonly contentType?: string;
readonly tags?: string[];
readonly similarity?: number;
readonly includeContent?: boolean;
}
export interface FileSearchResult {
readonly files: FileResult[];
readonly total: number;
readonly searchTime: number;
readonly query: string;
}
export interface CloudStorageAdapter {
store(bucket: string, key: string, file: Buffer, metadata: FileMetadata): Promise<CloudStorageResult>;
retrieve(bucket: string, key: string): Promise<Buffer>;
delete(bucket: string, key: string): Promise<boolean>;
exists(bucket: string, key: string): Promise<boolean>;
list(bucket: string, prefix?: string): Promise<string[]>;
}
export interface CloudStorageResult {
readonly url: string;
readonly cloudProvider: string;
readonly region: string;
readonly storageClass?: string;
readonly requestId: string;
}
export declare class FileStorageEngine extends EventEmitter {
private fileStore;
private buckets;
private contentAnalyzer;
private cloudSelector;
private _cloudAdapters;
constructor();
private initializeCloudAdapters;
initialize(): Promise<void>;
upload(bucket: string, file: FileDocument): Promise<FileResult>;
download(bucket: string, key: string): Promise<FileResult | null>;
getContent(bucket: string, key: string): Promise<Buffer | null>;
delete(bucket: string, key: string): Promise<boolean>;
list(bucket: string, prefix?: string): Promise<FileResult[]>;
search(bucket: string, query: string, options?: FileSearchOptions): Promise<FileSearchResult>;
getStats(): Record<string, any>;
private storeInCloud;
private deleteFromCloud;
private selectStorageClass;
private calculateRelevanceScore;
private getContentTypeStats;
private getCloudProviderStats;
}
//# sourceMappingURL=FileStorageEngine.d.ts.map