UNPKG

@yihuangdb/storage-object

Version:

A Node.js storage object layer library using Redis OM

140 lines 3.78 kB
/** * Redis OM Version Validator * * Enforces strict version matching between the Redis OM client library * and the schema/data stored in Redis. Prevents version mismatches that * could lead to data corruption or incompatibility issues. */ import { RedisClientType } from 'redis'; /** * Version compatibility matrix */ export interface VersionCompatibility { clientVersion: string; schemaVersion: string; isCompatible: boolean; reason?: string; requiredAction?: 'upgrade' | 'downgrade' | 'migrate'; } /** * Version metadata stored in Redis */ export interface RedisOMVersionMetadata { redisOMVersion: string; nodeVersion: string; schemaFormat: string; dataFormat: 'JSON' | 'HASH'; features: string[]; createdAt: string; lastChecked: string; } /** * Version validation result */ export interface VersionValidationResult { valid: boolean; clientVersion: string; storedVersion: string | null; errors: string[]; warnings: string[]; requiredVersion: string; } /** * Redis OM Version Validator */ export declare class RedisOMVersionValidator { private static instance; private readonly keyManager; private readonly metadataKey; private client; private strictMode; private currentVersion; private constructor(); /** * Get singleton instance */ static getInstance(strictMode?: boolean): RedisOMVersionValidator; /** * Initialize with Redis client */ initialize(client: RedisClientType): Promise<void>; /** * Detect current Redis OM version from node_modules */ private detectRedisOMVersion; /** * Validate Redis OM version before operations */ validateVersion(): Promise<VersionValidationResult>; /** * Check if version is supported */ private isVersionSupported; /** * Check if two versions are compatible */ private areVersionsCompatible; /** * Get stored version metadata from Redis */ private getStoredVersionMetadata; /** * Store version metadata in Redis */ private storeVersionMetadata; /** * Check and store version on initialization */ private checkAndStoreVersion; /** * Get features for a specific version */ private getVersionFeatures; /** * Assert version is valid (throws in strict mode) */ assertValidVersion(): Promise<void>; /** * Get compatibility report */ getCompatibilityReport(): Promise<{ currentVersion: string; requiredVersion: string; supportedRange: string; isValid: boolean; storedVersion: string | null; features: string[]; blockedVersions: string[]; }>; /** * Force version update (for migration scenarios) */ forceVersionUpdate(newVersion: string): Promise<void>; /** * Clear version metadata (for testing) */ clearVersionMetadata(): Promise<void>; } /** * Version enforcement error */ export declare class RedisOMVersionError extends Error { readonly currentVersion: string; readonly requiredVersion: string; readonly storedVersion: string | null; constructor(message: string, currentVersion: string, requiredVersion: string, storedVersion: string | null); } /** * Get version validator instance */ export declare function getRedisOMVersionValidator(strictMode?: boolean): RedisOMVersionValidator; /** * Export hard-coded version constants for use in other modules */ export declare const REDIS_OM_VERSION_REQUIREMENTS: { readonly EXACT: "0.4.7"; readonly MINIMUM: "0.4.0"; readonly MAXIMUM: "0.4.9"; readonly BLOCKED: string[]; }; //# sourceMappingURL=redis-om-version-validator.d.ts.map