/** * Validation utilities for audio-tools configuration. * * Provides comprehensive validation for configuration objects, backup sources, * and export settings. Also includes connectivity testing for backup sources. * * Validation functions throw descriptive errors when validation fails, following * the codebase's error handling pattern. * * @module audiotools-config/validator */ import type { AudioToolsConfig, BackupSource, ExportConfig } from './types.js'; /** * Validates a backup source configuration. * * Checks all required fields and validates type-specific requirements: * - Name must not be empty * - Type must be 'remote' or 'local' * - Source path must not be empty * - Device must not be empty * - For local sources, sampler must be provided * - Optional UUID fields must be strings if provided * - Optional timestamp fields must be valid ISO 8601 format if provided * * @param source - The backup source to validate * @throws {Error} If validation fails with a descriptive error message * * @example * ```typescript * const source: BackupSource = { * name: 'pi-scsi2', * type: 'remote', * source: 'pi-scsi2.local:~/images/', * device: 'images', * enabled: true * }; * * try { * validateBackupSource(source); * console.log('Source is valid'); * } catch (error) { * console.error('Validation failed:', error.message); * } * ``` */ export declare function validateBackupSource(source: BackupSource): void; /** * Validates export configuration settings. * * Checks all required fields and validates values: * - outputRoot must not be empty * - formats array must not be empty * - formats must contain valid values ('sfz' or 'decentsampler') * - enabledSources must be an array * * @param exportConfig - The export configuration to validate * @throws {Error} If validation fails with a descriptive error message * * @example * ```typescript * const config: ExportConfig = { * outputRoot: '~/.audiotools/sampler-export/extracted', * formats: ['sfz', 'decentsampler'], * skipUnchanged: true, * enabledSources: ['pi-scsi2'] * }; * * try { * validateExportConfig(config); * } catch (error) { * console.error('Export config error:', error.message); * } * ``` */ export declare function validateExportConfig(exportConfig: ExportConfig): void; /** * Validates the complete unified configuration. * * Performs comprehensive validation of the entire configuration structure: * - Version must be present * - Backup config is validated if present * - Export config is validated if present * - All backup sources are validated * - Cross-references between export enabledSources and backup sources are checked * * @param config - The complete audio-tools configuration to validate * @throws {Error} If validation fails with a descriptive error message * * @example * ```typescript * const config = await loadConfig(); * * try { * validateUnifiedConfig(config); * } catch (error) { * console.error('Configuration error:', error.message); * process.exit(1); * } * ``` */ export declare function validateUnifiedConfig(config: AudioToolsConfig): void; /** * Tests connectivity to a backup source. * * Performs actual connectivity tests to verify that a backup source is accessible: * - For remote sources: Tests SSH connection (placeholder - returns true for now) * - For local sources: Checks if the path exists and is readable * * @param source - The backup source to test * @returns Promise resolving to true if accessible, false otherwise * * @example * ```typescript * const source: BackupSource = { * name: 'sd-card', * type: 'local', * source: '/Volumes/AKAI_SD', * device: 'sd-card', * sampler: 's5000', * enabled: true * }; * * const accessible = await testBackupSourceConnection(source); * if (!accessible) { * console.error('Source is not accessible'); * } * ``` */ export declare function testBackupSourceConnection(source: BackupSource): Promise;