/** * Manages various types of warnings across the MemberJunction system. * * Features: * - Session-level tracking: Each warning shown once per session * - Debounced output: Groups warnings and displays after a quiet period * - Formatted output: Tree-structured, grouped by entity and warning type * - Configurable: Control debounce timing and behavior via options * - Multiple warning types: Deprecation, field-not-found, and extensible for more * * @example * ```typescript * const wm = WarningManager.Instance; * wm.RecordEntityDeprecationWarning('User Preferences', 'BaseEntity::constructor'); * wm.RecordFieldDeprecationWarning('MJ: AI Prompts', 'OldField', 'MJAIPromptEntity::validate'); * wm.RecordFieldNotFoundWarning('Users', 'DeletedColumn', 'BaseEntity::SetMany'); * // Warnings will be flushed automatically after debounce period * ``` */ import { BaseSingleton } from './BaseSingleton.js'; /** * Configuration options for the warning system */ export interface WarningConfig { /** * Time in milliseconds to wait after last warning before flushing output. * Default: 10000 (10 seconds) */ DebounceMs: number; /** * If true, shows every occurrence of warnings (ignores session tracking). * Default: false */ ShowAll: boolean; /** * If true, disables all warnings. * Default: false */ DisableWarnings: boolean; /** * If true, groups warnings and displays them in formatted tree structure. * If false, displays warnings immediately as they occur. * Default: true */ GroupWarnings: boolean; } /** * Singleton class that manages warnings across the entire application session. * Tracks which warnings have been shown and batches them for clean, grouped output. * * Uses BaseSingleton to guarantee a single instance across the entire process, * even if bundlers duplicate this module across multiple execution paths. */ export declare class WarningManager extends BaseSingleton { private warnedDeprecatedEntities; private warnedDeprecatedFields; private warnedFieldNotFound; private warnedRedundantLoads; private pendingEntityDeprecationWarnings; private pendingFieldDeprecationWarnings; private pendingFieldNotFoundWarnings; private pendingRedundantLoadWarnings; private debounceTimer; private config; /** * Use WarningManager.Instance to get the singleton instance. */ constructor(); /** * Gets the singleton instance of the WarningManager */ static get Instance(): WarningManager; /** * Updates the configuration for the warning system. * This allows runtime customization of behavior. */ UpdateConfig(config: Partial): void; /** * Gets the current configuration */ GetConfig(): Readonly; /** * Records a deprecation warning for an entity. * * @param entityName - The name of the deprecated entity * @param callerName - The name of the caller (e.g., 'BaseEntity::constructor') * @returns true if this warning should be emitted immediately (when ShowAll is true) */ RecordEntityDeprecationWarning(entityName: string, callerName: string): boolean; /** * Records a deprecation warning for an entity field. * * @param entityName - The name of the entity containing the deprecated field * @param fieldName - The name of the deprecated field * @param callerName - The name of the caller (e.g., 'MJAIPromptEntity::validate') * @returns true if this warning should be emitted immediately (when ShowAll is true) */ RecordFieldDeprecationWarning(entityName: string, fieldName: string, callerName: string): boolean; /** * Records a warning when a field is not found in an entity definition. * This typically occurs during data loading when source data contains fields * that don't exist in the entity schema. * * @param entityName - The name of the entity where the field was not found * @param fieldName - The name of the field that was not found * @param context - Context description (e.g., 'BaseEntity::SetMany during data load') * @returns true if this warning should be emitted immediately (when ShowAll is true) */ RecordFieldNotFoundWarning(entityName: string, fieldName: string, context: string): boolean; /** * Records a warning when multiple engines load the same entity data. * This helps developers identify redundant data loading that could be optimized. * * @param entityName - The name of the entity being loaded * @param engines - Array of engine class names that have loaded this entity * @returns true if this is a new warning that will be emitted */ RecordRedundantLoadWarning(entityName: string, engines: string[]): boolean; /** * Schedules a flush of pending warnings after the debounce period. * Resets the timer if new warnings arrive. */ private scheduleFlush; /** * Immediately flushes all pending warnings to the console. * Can be called manually to force output before the debounce period. */ FlushWarnings(): void; /** * Internal method that formats and outputs all pending warnings. */ private flushWarnings; /** * Resets all tracking state. Useful for testing or starting fresh. * Does NOT clear pending warnings - call FlushWarnings first if needed. */ Reset(): void; } /** * @deprecated Use WarningManager instead. This alias is provided for backward compatibility. */ export declare const DeprecationWarningManager: typeof WarningManager; //# sourceMappingURL=warningManager.d.ts.map