brainy/.recovery-workspace/dist-backup-20250910-141917/api/DataAPI.d.ts
David Snelling 8ff382ca3b chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
2025-09-10 15:18:04 -07:00

118 lines
2.9 KiB
TypeScript

/**
* Data Management API for Brainy 3.0
* Provides backup, restore, import, export, and data management
*/
import { StorageAdapter } from '../coreTypes.js';
import { Entity, Relation } from '../types/brainy.types.js';
import { NounType } from '../types/graphTypes.js';
export interface BackupOptions {
includeVectors?: boolean;
compress?: boolean;
format?: 'json' | 'binary';
}
export interface RestoreOptions {
merge?: boolean;
overwrite?: boolean;
validate?: boolean;
}
export interface ImportOptions {
format: 'json' | 'csv' | 'parquet';
mapping?: Record<string, string>;
batchSize?: number;
validate?: boolean;
}
export interface ExportOptions {
format?: 'json' | 'csv' | 'parquet';
filter?: {
type?: NounType | NounType[];
where?: Record<string, any>;
service?: string;
};
includeVectors?: boolean;
}
export interface BackupData {
version: string;
timestamp: number;
entities: Array<{
id: string;
vector?: number[];
type: string;
metadata: any;
service?: string;
}>;
relations: Array<{
id: string;
from: string;
to: string;
type: string;
weight: number;
metadata?: any;
}>;
config?: Record<string, any>;
stats: {
entityCount: number;
relationCount: number;
vectorDimensions?: number;
};
}
export interface ImportResult {
successful: number;
failed: number;
errors: Array<{
item: any;
error: string;
}>;
duration: number;
}
export declare class DataAPI {
private storage;
private getEntity;
private getRelation?;
private brain;
constructor(storage: StorageAdapter, getEntity: (id: string) => Promise<Entity | null>, getRelation?: ((id: string) => Promise<Relation | null>) | undefined, brain?: any);
/**
* Create a backup of all data
*/
backup(options?: BackupOptions): Promise<BackupData>;
/**
* Restore data from a backup
*/
restore(params: {
backup: BackupData;
merge?: boolean;
overwrite?: boolean;
validate?: boolean;
}): Promise<void>;
/**
* Clear data
*/
clear(params?: {
entities?: boolean;
relations?: boolean;
config?: boolean;
}): Promise<void>;
/**
* Import data from various formats
*/
import(params: ImportOptions & {
data: any;
}): Promise<ImportResult>;
/**
* Export data to various formats
*/
export(params?: ExportOptions): Promise<any>;
/**
* Get storage statistics
*/
getStats(): Promise<{
entities: number;
relations: number;
storageSize?: number;
vectorDimensions?: number;
}>;
private applyMapping;
private validateImportItem;
private matchesFilter;
private convertToCSV;
private generateId;
}