import { SecurityLevel } from "../types/cia"; import { CIAComponentType, CIADataProvider, CIADetails } from "../types/cia-services"; import { IBaseService, ValidationResult } from "../types/services"; import { ServiceError, ErrorContext } from "./errors"; /** * Common interface for CIA services */ export interface CIAService { getComponentDetails(component: CIAComponentType, level: SecurityLevel): CIADetails | undefined; getSecurityLevelDescription(level: SecurityLevel): string; getRiskLevelFromSecurityLevel(level: SecurityLevel): string; } /** * Base service class that provides common functionality * for security-related services * * ## Key Features * - Standardized error handling * - Input validation * - Common utility methods * - Consistent logging patterns */ export declare class BaseService implements CIAService, IBaseService { /** * Service name for identification */ readonly name: string; /** * Data provider used by the service */ protected dataProvider: CIADataProvider; /** * Create a new service instance * * @param dataProvider - Data provider for security information */ constructor(dataProvider: CIADataProvider); /** * Validate input parameters (to be overridden by subclasses) * * @param input - Input to validate * @returns True if valid, false otherwise */ validate(input: unknown): boolean; /** * Validate input with detailed results * * @param input - Input to validate * @returns Validation result with errors */ protected validateWithDetails(input: unknown): ValidationResult; /** * Handle errors consistently across services * * @param error - Error to handle * @returns ServiceError */ handleError(error: Error): ServiceError; /** * Validate security level * * @param level - Security level to validate * @returns True if valid * @throws ServiceError if invalid */ protected validateSecurityLevel(level: SecurityLevel): boolean; /** * Validate CIA component type * * @param component - Component to validate * @returns True if valid * @throws ServiceError if invalid */ protected validateComponent(component: CIAComponentType): boolean; /** * Check if a string is a valid CIA component type */ protected isCIAComponentType(component: string): component is CIAComponentType; /** * Get component details for a specific component and security level */ getComponentDetails(component: CIAComponentType, level: SecurityLevel): CIADetails | undefined; /** * Get options for a CIA component */ protected getCIAOptions(component: CIAComponentType): Record; /** * Get security level description */ getSecurityLevelDescription(level: SecurityLevel): string; /** * Get risk level from security level */ getRiskLevelFromSecurityLevel(level: SecurityLevel): string; /** * Calculate security level value from level string */ protected getSecurityLevelValue(level: SecurityLevel): number; /** * Capitalize first letter of a string */ protected capitalizeFirstLetter(string: string): string; /** * Get default security icon for a level */ protected getDefaultSecurityIcon(level: SecurityLevel): string; /** * Get value points for a security level */ protected getValuePoints(level: SecurityLevel): string[]; /** * Default implementation of value points */ private getDefaultValuePoints; /** * Validate a numeric value for formatting * * @param value - Value to validate * @param context - Context for error logging * @returns True if valid, false otherwise */ private validateNumericValue; /** * Formats a currency value * * @param value - Numeric value to format * @returns Formatted currency string */ protected formatCurrency(value: number): string; /** * Formats a percentage value * * @param value - Numeric percentage value * @returns Formatted percentage string */ protected formatPercentage(value: number): string; /** * Safe get from object with fallback * * @param obj - Object to get from * @param key - Key to retrieve * @param fallback - Fallback value * @returns Value or fallback */ protected safeGet(obj: Record | undefined, key: string, fallback: T): T; /** * Log operation with context * * @param level - Log level * @param message - Message to log * @param context - Additional context */ protected logOperation(level: 'info' | 'warn' | 'error', message: string, context?: ErrorContext): void; } //# sourceMappingURL=BaseService.d.ts.map