UNPKG

@yihuangdb/storage-object

Version:

A Node.js storage object layer library using Redis OM

85 lines 2.8 kB
/** * Export Import Manager * * Handles export and import operations for StorageObject data and schemas. * Supports full and incremental exports, various formats, and compression. */ import { RedisClientType } from 'redis'; import { RedisKeyManager } from './redis-key-manager'; import { StorageVersionManager } from './storage-version-manager'; import { StorageObject } from './storage'; /** * Supported export formats for data serialization */ export type ExportFormat = 'json' | 'ndjson' | 'binary'; export interface ExportMetadata { exportId: string; exportTimestamp: number; schemaName: string; exportedSchemaVersion: number; exportedStorageVersion: number; fromStorageVersion?: number; toStorageVersion?: number; exportedEntityCount: number; exportFormat: ExportFormat; isCompressed: boolean; isIncremental: boolean; fileChecksum?: string; } export interface ImportResult { importId: string; importedEntityCount: number; failedEntityCount: number; schemaWasUpdated: boolean; startStorageVersion: number; endStorageVersion: number; importDuration: number; importErrors: Array<{ entityId: string; error: string; }>; } export interface ExportOptions { exportFormat?: ExportFormat; compressOutput?: boolean; includeSchema?: boolean; includeData?: boolean; incrementalExport?: boolean; fromStorageVersion?: number; toStorageVersion?: number; batchSize?: number; outputDirectory?: string; } export interface ImportOptions { validateSchemaVersion?: boolean; entityMergeStrategy?: 'replace' | 'merge' | 'skip'; importBatchSize?: number; continueOnError?: boolean; dryRun?: boolean; importFormat?: ExportFormat; isCompressed?: boolean; } export declare class ExportImportManager { private keyManager; private storageVersionManager; private redis; constructor(keyManager: RedisKeyManager, storageVersionManager: StorageVersionManager, redis: RedisClientType); /** * Validate and sanitize file paths to prevent directory traversal attacks * * @param filePath - The file path to validate * @throws Error if the path is invalid or contains dangerous patterns */ private validatePath; exportFull(storage: StorageObject<any>, filePath: string, options?: ExportOptions): Promise<ExportMetadata>; importFull(storage: StorageObject<any>, filePath: string, options?: ImportOptions): Promise<ImportResult>; private exportSchema; private exportData; private exportAllEntities; private exportIncrementalData; private importSchema; private importData; private importEntity; private calculateChecksum; } //# sourceMappingURL=export-import-manager.d.ts.map