UNPKG

@yihuangdb/storage-object

Version:

A Node.js storage object layer library using Redis OM

184 lines 6.12 kB
/** * @module legacy * @description Backward compatibility layer for the old functional API * * This module provides the original functional API that wraps the new OOP API. * It ensures 100% backward compatibility for existing code while using the new * architecture under the hood. */ import { StorageObject, StorageOptions } from './storage'; import { StorageSchema as EnhancedStorageSchema } from './storage-schema'; import { SchemaConfig } from './schema'; /** * Creates a new storage instance (legacy API) * @deprecated Use StorageSystem.create() instead * * @param name - Name of the storage * @param schema - Schema configuration * @param options - Storage options * @returns Promise resolving to the storage instance * * @example * ```typescript * // Legacy way (still works) * const storage = await createStorage('users', schema, options); * * // New way (recommended) * const storage = await StorageSystem.create('users', schema, options); * ``` */ export declare function createStorage<T extends Record<string, any> = Record<string, any>>(name: string, schema: SchemaConfig | EnhancedStorageSchema<T>, options?: StorageOptions): Promise<StorageObject<T>>; /** * Gets an existing storage instance by name (legacy API) * @deprecated Use StorageSystem.get() instead * * @param name - Name of the storage * @returns Promise resolving to the storage instance or null if not found * * @example * ```typescript * // Legacy way (still works) * const storage = await getStorage('users'); * * // New way (recommended) * const storage = await StorageSystem.get('users'); * ``` */ export declare function getStorage<T extends Record<string, any> = Record<string, any>>(name: string): Promise<StorageObject<T> | null>; /** * Deletes a storage instance (legacy API) * @deprecated Use StorageSystem.delete() instead * * @param name - Name of the storage to delete * @returns Promise resolving to true if deleted, false otherwise * * @example * ```typescript * // Legacy way (still works) * const deleted = await deleteStorage('users'); * * // New way (recommended) * const deleted = await StorageSystem.delete('users'); * ``` */ export declare function deleteStorage(name: string): Promise<boolean>; /** * Gets or creates a storage instance (legacy API) * @deprecated Use StorageSystem.getOrCreate() instead * * @param name - Name of the storage * @param schema - Schema configuration (used if creating new) * @param options - Storage options (used if creating new) * @returns Promise resolving to the storage instance * * @example * ```typescript * // Legacy way (still works) * const storage = await getOrCreateStorage('users', schema, options); * * // New way (recommended) * const storage = await StorageSystem.getOrCreate('users', schema, options); * ``` */ export declare function getOrCreateStorage<T extends Record<string, any> = Record<string, any>>(name: string, schema: SchemaConfig | EnhancedStorageSchema<T>, options?: StorageOptions): Promise<StorageObject<T>>; /** * Lists all storage instances (legacy API) * @deprecated Use StorageSystem.list() instead * * @returns Promise resolving to array of storage names * * @example * ```typescript * // Legacy way (still works) * const storages = await listStorages(); * * // New way (recommended) * const storages = await StorageSystem.list(); * ``` */ export declare function listStorages(): Promise<string[]>; /** * Gets metadata for a storage instance (legacy API) * @deprecated Use StorageSystem.getMetadata() instead * * @param name - Name of the storage * @returns Promise resolving to metadata or null if not found * * @example * ```typescript * // Legacy way (still works) * const metadata = await getStorageMetadata('users'); * * // New way (recommended) * const metadata = await StorageSystem.getMetadata('users'); * ``` */ export declare function getStorageMetadata(name: string): Promise<any | null>; /** * Validates a storage instance (legacy API) * @deprecated Use StorageSystem.validate() instead * * @param name - Name of the storage * @returns Promise resolving to validation result * * @example * ```typescript * // Legacy way (still works) * const isValid = await validateStorage('users'); * * // New way (recommended) * const isValid = await StorageSystem.validate('users'); * ``` */ export declare function validateStorage(name: string): Promise<boolean>; /** * Gets statistics for a storage instance (legacy API) * * @param name - Name of the storage * @returns Promise resolving to storage statistics */ export declare function getStorageStats(name: string): Promise<any>; /** * Backs up all storage instances (legacy API) * * @param path - Path to save backup * @returns Promise resolving to backup result */ export declare function backupStorages(path: string): Promise<any>; /** * Restores storage instances from backup (legacy API) * * @param path - Path to restore from * @returns Promise resolving to restore result */ export declare function restoreStorages(path: string): Promise<any>; /** * Cleans up unused storage instances (legacy API) * * @returns Promise resolving to cleanup result */ export declare function cleanupStorages(): Promise<any>; /** * Gets global statistics across all storages (legacy API) * * @returns Promise resolving to global statistics */ export declare function getGlobalStats(): Promise<any>; /** * Monitors a storage instance (legacy API) * * @param name - Name of the storage * @param callback - Callback function for monitoring events * @returns Unsubscribe function */ export declare function monitorStorage(name: string, callback: (event: any) => void): () => void; /** * Migrates a storage instance to a new schema (legacy API) * * @param name - Name of the storage * @param newSchema - New schema configuration * @returns Promise resolving to migration result */ export declare function migrateStorage(name: string, newSchema: SchemaConfig): Promise<any>; export { getSchemaRegistry } from './schema-registry'; //# sourceMappingURL=legacy.d.ts.map