import { SecurityLevel } from "../types/cia"; import { BusinessImpactDetails, CIAComponentType, CIADetails, ROIEstimate } from "../types/cia-services"; import { StatusType } from "../types/common/StatusTypes"; import { AvailabilityDetail, CIAImpactSummaryWidgetProps, ConfidentialityDetail, IntegrityDetail, SecurityLevelWidgetProps } from "../types/widgets"; /** * Type guard utilities for the CIA compliance manager * * These utilities ensure type safety when working with domain-specific types. * Type guards help TypeScript narrow types at runtime, preventing type errors * and enabling safe property access. * * @example * ```typescript * import { isSecurityLevel, isObject } from './typeGuards'; * * // Type guard for security level * const level: unknown = 'High'; * if (isSecurityLevel(level)) { * console.log(level.toUpperCase()); // TypeScript knows level is SecurityLevel * } * * // Type guard for objects * const data: unknown = { key: 'value' }; * if (isObject(data)) { * console.log(data.key); // Safe access after type guard * } * ``` */ /** * Type guard to check if an object is an AvailabilityDetail * * @param obj - Value to check * @returns True if obj is an AvailabilityDetail * * @example * ```typescript * const data: unknown = getAvailabilityData(); * if (isAvailabilityDetail(data)) { * console.log(data.uptime); // Safe to access uptime property * console.log(data.recommendations); // Safe to access array * } * ``` */ export declare function isAvailabilityDetail(obj: unknown): obj is AvailabilityDetail; /** * Type guard to check if an object is an IntegrityDetail */ export declare function isIntegrityDetail(obj: unknown): obj is IntegrityDetail; /** * Type guard to check if an object is a ConfidentialityDetail */ export declare function isConfidentialityDetail(obj: unknown): obj is ConfidentialityDetail; /** * Type guard to check if a CIA detail object exists */ export declare function isValidCIADetail(detail: CIADetails | undefined | null): detail is CIADetails; /** * Type guard to check if a value is a non-null object * * Useful for safely checking if a value is an object before accessing properties. * Filters out null, arrays, and primitive values. * * @param value - Value to check * @returns True if value is a non-null object (excludes arrays) * * @example * ```typescript * isObject({}) // true * isObject({ key: 'val' }) // true * isObject(null) // false * isObject([]) // false (arrays excluded) * isObject('string') // false * isObject(123) // false * * // Usage in code * const data: unknown = getUserData(); * if (isObject(data) && 'name' in data) { * console.log(data.name); // Safe property access * } * ``` */ export declare function isObject(value: unknown): value is Record; /** * Type guard to check if a value is a string */ export declare function isString(value: unknown): value is string; /** * Type guard to check if a value is a number */ export declare function isNumber(value: unknown): value is number; /** * Safely access a nested property in an object using a dot notation path * @param obj The object to access * @param path The path to the property, e.g. 'a.b.c' or 'a[0].b.c' * @param defaultValue The default value to return if the property doesn't exist * @returns The value at the path or the default value */ export declare function safeAccess(obj: unknown, path: string | (string | number)[], defaultValue?: T): T; /** * Ensures value is an array, or converts it to one if not */ export declare function ensureArray(value: T | T[]): T[]; /** * Safely converts string to number, with a fallback value if conversion fails */ export declare function safeNumberConversion(value: string | number | undefined, fallback?: number): number; /** * Helper function to safely access CIA options with string keys * @param options The options object to access * @param key The string key that should be treated as SecurityLevel * @returns The option value or undefined if not found */ export declare function getSecurityLevelOption(options: Record, key: string | undefined): T | undefined; /** * Helper function to check if an object has a property * @param obj The object to check * @param prop The property to check for * @returns True if the object has the property */ export declare function hasProperty(obj: unknown, prop: string): boolean; /** * Type guard for ROI metrics objects * @param value - The value to check * @returns True if the value is a valid ROI metrics object */ export declare function isROIMetrics(value: unknown): boolean; /** * Type guard for technical implementation details * @param value - The value to check * @returns True if the value is a valid technical implementation details object */ export declare function isTechnicalImplementationDetails(value: unknown): boolean; /** * Type guard for security resource objects * @param value - The value to check * @returns True if the value is a valid security resource object */ export declare function isSecurityResource(value: unknown): boolean; /** * Type guard for basic widget props * @param value - The value to check * @returns True if the value has the required widget properties */ export declare function hasWidgetProps(value: unknown): boolean; /** * Type guard for basic widget props * @param value - The value to check * @returns True if the value has the required widget properties */ export declare function isWidgetProps(value: unknown): boolean; /** * Checks if an object is a valid security profile */ export declare function isSecurityProfile(obj: unknown): boolean; /** * Checks if an object is a valid compliance status * * @param obj - Object to check * @returns True if the object is a valid compliance status */ export declare function isComplianceStatus(obj: unknown): boolean; /** * Checks if an object is a valid compliance framework * * @param obj - Object to check * @returns True if the object is a valid compliance framework */ export declare function isComplianceFramework(obj: unknown): boolean; /** * Checks if an object is a valid ROI metric details object */ export declare function isROIMetricDetails(obj: unknown): boolean; /** * Type guard utilities for the CIA compliance manager * * These utilities ensure type safety when working with domain-specific types. */ /** * Type guard for SecurityLevel * * @param value - Value to check * @returns True if the value is a valid SecurityLevel */ export declare function isSecurityLevel(value: unknown): value is SecurityLevel; /** * Type guard for CIAComponentType * * @param value - Value to check * @returns True if the value is a valid CIAComponentType */ export declare function isCIAComponentType(value: unknown): value is CIAComponentType; /** * Type guard for CIADetails * * @param value - Value to check * @returns True if the value has the required properties of CIADetails */ export declare function isCIADetails(value: unknown): value is CIADetails; /** * Type guard for checking if a value is a valid widget props object * @param value - The value to check * @returns True if the value is a valid widget props object */ /** * Type guard for checking if a value is a SecurityLevelWidgetProps * @param value - The value to check * @returns True if the value is a valid SecurityLevelWidgetProps */ export declare function isSecurityLevelWidgetProps(value: unknown): value is SecurityLevelWidgetProps; /** * Type guard for CIAImpactSummaryWidgetProps * @param value - The value to check * @returns True if the value is a valid CIAImpactSummaryWidgetProps */ export declare function isCIAImpactSummaryWidgetProps(value: unknown): value is CIAImpactSummaryWidgetProps; /** * Type guard for BusinessImpactDetails * @param value - The value to check * @returns True if the value is a valid BusinessImpactDetails */ export declare function isBusinessImpactDetails(value: unknown): value is BusinessImpactDetails; /** * Type guard for ROI estimate * @param value - The value to check * @returns True if the value is a valid ROI estimate */ export declare function isROIEstimate(value: unknown): value is ROIEstimate; /** * Checks if an object is a valid widget config */ export declare function isWidgetConfig(obj: unknown): boolean; /** * Checks if an object has a specific tag value */ export declare function hasTagValue(obj: unknown, tagValue: string): boolean; /** * Parse a risk level from a string or number * * @param riskLevel - Risk level to parse * @returns Numeric risk level */ export declare function parseRiskLevel(riskLevel: string | number | null | undefined): number; /** * Extracts CIA security levels from an object */ export declare function extractSecurityLevels(obj: unknown): { availability: string; integrity: string; confidentiality: string; }; /** * Calculates the implementation cost from a cost object */ export declare function getImplementationCost(costObj: unknown): number; /** * Domain-specific type guards for consistent type checking * * ## Business Perspective * * These type guards ensure reliable runtime validation of critical * security and compliance data types, reducing bugs and improving * the stability of security assessments and compliance mappings. 🛡️ * * Consistent type validation is essential for maintaining data integrity * across the application's security models and calculations. */ /** * Type guard for business impact category * * @param value - Value to check * @returns Whether the value is a valid business impact category */ export declare function isBusinessImpactCategory(value: unknown): boolean; /** * Type guard for compliance framework name * * @param value - Value to check * @returns Whether the value is a valid compliance framework name */ export declare function isComplianceFrameworkName(value: unknown): boolean; /** * Type guard for compliance framework object * * @param value - Value to check * @returns Whether the value is a valid compliance framework object */ export declare function isComplianceFrameworkObject(value: unknown): boolean; /** * Type guard for risk level * * @param value - Value to check * @returns Whether the value is a valid risk level */ export declare function isRiskLevel(value: unknown): boolean; /** * Type guard for widget * * @param value - Value to check * @returns Whether the value is a valid widget */ export declare function isWidget(value: unknown): boolean; /** * Type guard for widget type * * @param value - Value to check * @returns Whether the value is a valid widget type */ export declare function isWidgetType(value: unknown): boolean; /** * Type guard to check if a value is a boolean * @param value - Value to check * @returns True if the value is a boolean */ export declare function isBoolean(value: unknown): value is boolean; /** * Type guard to check if a value is an array * @param value - Value to check * @returns True if the value is an array */ export declare function isArray(value: unknown): value is unknown[]; /** * Type guard to check if a value is a function. * Note: `typeof` returns "function" for both callables and class constructors, * so the `Function` type is the correct predicate here. * @param value - Value to check * @returns True if the value is a function */ export declare function isFunction(value: unknown): value is Function; /** * Type guard to check if a value is null * @param value - Value to check * @returns True if the value is null */ export declare function isNull(value: unknown): value is null; /** * Type guard to check if a value is undefined * @param value - Value to check * @returns True if the value is undefined */ export declare function isUndefined(value: unknown): value is undefined; /** * Type guard to check if a value is nullish (null or undefined) * @param value - Value to check * @returns True if the value is null or undefined */ export declare function isNullish(value: unknown): value is null | undefined; /** * Type guard to check if a value is a Date object * @param value - Value to check * @returns True if the value is a Date object */ export declare function isDate(value: unknown): value is Date; /** * Type guard to check if a value is an Error object * @param value - Value to check * @returns True if the value is an Error object */ export declare function isError(value: unknown): value is Error; /** * Check if a value can be used as an object key * @param value - Value to check * @returns True if the value can be used as an object key */ export declare function isValidKey(value: unknown): value is string | number | symbol; /** * Type guard to check if a value is a valid CIA component * Alias for isCIAComponentType for backward compatibility * @param value - Value to check * @returns True if the value is a valid CIA component */ export declare function isCIAComponent(value: unknown): value is CIAComponentType; /** * Safely converts a string to a SecurityLevel, with fallback * @param value The value to convert * @param fallback The fallback value (defaults to "Moderate") * @returns A valid SecurityLevel */ export declare const toSecurityLevel: (value: unknown, fallback?: SecurityLevel) => SecurityLevel; /** * Type guard to check if a value is a valid StatusType * @param value The value to check * @returns Whether the value is a valid StatusType */ export declare function isStatusType(value: unknown): value is StatusType; /** * Safely converts a string to a StatusType, with fallback * @param value The value to convert * @param fallback The fallback value (defaults to "neutral") * @returns A valid StatusType */ export declare const toStatusType: (value: unknown, fallback?: StatusType) => StatusType; /** * Type guard to check if an object has a specific method * @param obj The object to check * @param methodName The method name to check for * @returns True if the object has the method as a function */ export declare function hasMethod(obj: T | null | undefined, methodName: K): obj is T & Record unknown>; //# sourceMappingURL=typeGuards.d.ts.map