import type { ChangeDetectorPlugin } from './plugin-types'; /** * A single validation error with location context. * * @alpha */ export interface PluginValidationError { /** * Dot-notation path to the invalid field. * * @example 'metadata.id', 'inputProcessors[0].extensions' */ readonly path: string; /** * Human-readable error message. */ readonly message: string; /** * Plugin ID if known (may not be available if metadata is invalid). */ readonly pluginId?: string; } /** * Result of validating a plugin. * * @alpha */ export interface PluginValidationResult { /** * Whether the plugin passed all validation checks. */ readonly valid: boolean; /** * List of validation errors (empty if valid). */ readonly errors: readonly PluginValidationError[]; /** * List of validation warnings (non-fatal issues). */ readonly warnings: readonly PluginValidationError[]; } /** * Options for plugin validation. * * @alpha */ export interface PluginValidationOptions { /** * Package name for error context (e.g., npm package name). */ readonly packageName?: string; /** * Whether to validate that factory functions are callable. * Defaults to true. */ readonly validateFactories?: boolean; /** * Whether to allow plugins with no capabilities. * Defaults to false (at least one capability required). */ readonly allowEmptyCapabilities?: boolean; } /** * Validates a plugin conforms to the expected structure. * * @remarks * This function performs comprehensive validation including: * - Metadata validation (id, name, version) * - Capability validation (inputProcessors, policies, reporters, validators) * - Unique ID checks within each capability type * - Factory function validation (optional) * * @param plugin - The plugin to validate (can be any value) * @param options - Validation options * @returns Validation result with errors and warnings * * @example * ```typescript * import { validatePlugin } from '@api-extractor-tools/change-detector-core'; * * const result = validatePlugin(myPlugin, { packageName: 'my-plugin' }); * if (!result.valid) { * console.error('Plugin validation failed:', result.errors); * } * ``` * * @alpha */ export declare function validatePlugin(plugin: unknown, options?: PluginValidationOptions): PluginValidationResult; /** * Type guard to check if a value is a valid ChangeDetectorPlugin. * * @remarks * This is a convenience function that combines validation with type narrowing. * For detailed error information, use `validatePlugin()` directly. * * @param plugin - The value to check * @returns True if the value is a valid plugin * * @example * ```typescript * if (isValidPlugin(loadedModule)) { * // loadedModule is typed as ChangeDetectorPlugin * registry.register(loadedModule); * } * ``` * * @alpha */ export declare function isValidPlugin(plugin: unknown): plugin is ChangeDetectorPlugin; /** * Formats validation errors into a human-readable string. * * @param result - The validation result * @param packageName - Optional package name for context * @returns Formatted error message * * @alpha */ export declare function formatValidationErrors(result: PluginValidationResult, packageName?: string): string; //# sourceMappingURL=plugin-validation.d.ts.map