/** * Pre-Save Processor * * Processes data before database write operations by applying * encryption, hashing, validation, transformation, and other operations. */ import { IPreSaveOperation, IPreSaveConfig, IPreSaveResult, IPreSaveEncryptOptions, IPreSaveHashOptions, IPreSaveMaskOptions, IPreSaveValidateOptions, IPreSaveTransformOptions, IPreSaveSlugOptions, IPreSaveTruncateOptions, IPreSaveRoundOptions, IPreSaveClampOptions, IPreSaveDefaultOptions, IPreSaveComputeOptions, IValidationRule } from '../types/presave.interface'; /** * Pre-save processor for applying transformations before database writes */ export declare class PreSaveProcessor { private config; constructor(config?: IPreSaveConfig); /** * Process data through pre-save operations */ process(data: Record | Record[], operations: IPreSaveOperation[]): Promise; /** * Sort operations for proper execution order */ private sortOperations; /** * Apply a single operation to a record */ private applyOperation; /** * Execute a specific operation */ private executeOperation; /** * Encrypt a field value */ private encrypt; /** * Hash a field value (one-way) */ private hash; /** * Mask sensitive data */ private mask; /** * Validate field value */ private validate; /** * Check a single validation rule */ private checkValidationRule; /** * Get default validation error message */ private getDefaultValidationMessage; /** * Apply custom transformation */ private transform; /** * Generate slug from source field */ private generateSlug; /** * Truncate string to max length */ private truncate; /** * Round number to decimals */ private round; /** * Clamp number to range */ private clamp; /** * Apply default value if null/undefined */ private applyDefault; /** * Compute derived field */ private compute; /** * Sanitize HTML/script tags */ private sanitizeHtml; /** * Generate UUID v4 */ private generateUUID; /** * Normalize phone number */ private normalizePhone; /** * Normalize email */ private normalizeEmail; /** * Create an encryption operation */ static encrypt(field: string, options?: Partial>): IPreSaveEncryptOptions; /** * Create a hash operation */ static hash(field: string, options?: Partial>): IPreSaveHashOptions; /** * Create a mask operation */ static mask(field: string, pattern: IPreSaveMaskOptions['pattern'], options?: Partial>): IPreSaveMaskOptions; /** * Create a validate operation */ static validate(field: string, rules: IValidationRule[], options?: Partial>): IPreSaveValidateOptions; /** * Create a transform operation */ static transform(field: string, transformer: IPreSaveTransformOptions['transformer']): IPreSaveTransformOptions; /** * Create a slug operation */ static slug(field: string, sourceField: string, options?: Partial>): IPreSaveSlugOptions; /** * Create a compute operation */ static compute(field: string, compute: IPreSaveComputeOptions['compute'], dependsOn?: string[]): IPreSaveComputeOptions; /** * Create a default operation */ static default(field: string, value: any): IPreSaveDefaultOptions; /** * Create simple operation helpers */ static trim(field: string): IPreSaveOperation; static lowercase(field: string): IPreSaveOperation; static uppercase(field: string): IPreSaveOperation; static sanitize(field: string): IPreSaveOperation; static uuid(field: string): IPreSaveOperation; static timestamp(field: string): IPreSaveOperation; static normalizeEmail(field: string): IPreSaveOperation; static normalizePhone(field: string): IPreSaveOperation; static truncate(field: string, maxLength: number, options?: Partial>): IPreSaveTruncateOptions; static round(field: string, decimals?: number, mode?: 'round' | 'floor' | 'ceil'): IPreSaveRoundOptions; static clamp(field: string, min?: number, max?: number): IPreSaveClampOptions; } /** * Convenience export for operation builder */ export declare const PreSave: typeof PreSaveProcessor;