UNPKG

apex-code-coverage-transformer

Version:

Transform Salesforce Apex code coverage JSONs into other formats accepted by SonarQube, GitHub, GitLab, Azure, Bitbucket, etc.

91 lines (90 loc) 2.72 kB
import { CoverageHandler } from '../utils/types.js'; /** * Registration information for a coverage format handler. */ export type HandlerRegistration = { /** Format identifier (e.g., 'sonar', 'cobertura') */ name: string; /** Human-readable description of the format */ description: string; /** File extension for this format (e.g., '.xml', '.json', '.info') */ fileExtension: string; /** Factory function to create a new handler instance */ handler: () => CoverageHandler; /** List of platforms/tools compatible with this format */ compatibleWith?: string[]; }; /** * Registry for coverage format handlers. * Provides a centralized system for registering and retrieving format handlers. * * @example * ```typescript * // Register a handler * HandlerRegistry.register({ * name: 'myformat', * description: 'My custom format', * fileExtension: '.xml', * handler: () => new MyFormatHandler(), * }); * * // Retrieve a handler * const handler = HandlerRegistry.get('myformat'); * ``` */ export declare class HandlerRegistry { private static handlers; /** * Register a new format handler. * * @param registration - Handler registration information * @throws Error if a handler with the same name is already registered */ static register(registration: HandlerRegistration): void; /** * Get a handler instance for the specified format. * * @param format - Format identifier * @returns New handler instance * @throws Error if format is not supported */ static get(format: string): CoverageHandler; /** * Get list of all registered format names. * * @returns Array of format identifiers */ static getAvailableFormats(): string[]; /** * Get file extension for a format. * * @param format - Format identifier * @returns File extension including the dot (e.g., '.xml') */ static getExtension(format: string): string; /** * Get description for a format. * * @param format - Format identifier * @returns Human-readable description */ static getDescription(format: string): string; /** * Get compatible platforms for a format. * * @param format - Format identifier * @returns Array of compatible platform names */ static getCompatiblePlatforms(format: string): string[]; /** * Check if a format is registered. * * @param format - Format identifier * @returns True if format is registered */ static has(format: string): boolean; /** * Clear all registered handlers (primarily for testing). */ static clear(): void; }