UNPKG

@casoon/auditmysite

Version:

Professional website analysis suite with robust accessibility testing, Core Web Vitals performance monitoring, SEO analysis, and content optimization insights. Features isolated browser contexts, retry mechanisms, and comprehensive API endpoints for profe

181 lines 5.04 kB
/** * 🎯 Stable Audit Interface * * This interface provides a stable, reliable API for website auditing. * It abstracts internal complexity and ensures consistent behavior. * * Key Features: * - Simple, consistent API * - Built-in error handling and validation * - Progress monitoring * - Health checks * - Comprehensive results * * Usage: * ```typescript * const auditor = new StableAuditor({ * maxPages: 5, * timeout: 60000, * outputFormat: 'markdown' * }); * * const results = await auditor.auditWebsite('https://example.com/sitemap.xml'); * ``` */ export interface StableAuditConfig { /** Maximum number of pages to audit */ maxPages: number; /** Timeout per page in milliseconds (default: 90000) */ timeout?: number; /** Number of concurrent workers (default: 3) */ maxConcurrent?: number; /** Output format (default: 'html') */ outputFormat?: 'html' | 'markdown' | 'both'; /** Output directory (default: './reports') */ outputDir?: string; /** WCAG standard to test against (default: 'WCAG2AA') */ standard?: 'WCAG2A' | 'WCAG2AA' | 'WCAG2AAA'; /** Enable detailed logging (default: false) */ verbose?: boolean; /** Custom report filename prefix */ reportPrefix?: string; } export interface AuditResult { /** Overall audit summary */ summary: { totalPages: number; testedPages: number; passedPages: number; failedPages: number; crashedPages: number; successRate: number; totalDuration: number; averagePageTime: number; }; /** Per-page results */ pages: PageAuditResult[]; /** Generated report files */ reports: { html?: string; markdown?: string; }; /** Performance metrics */ performance: { avgLoadTime: number; avgAccessibilityScore: number; avgPerformanceScore: number; avgSeoScore: number; }; /** Audit metadata */ metadata: { auditDate: string; version: string; config: StableAuditConfig; systemInfo: { nodeVersion: string; memoryUsage: NodeJS.MemoryUsage; }; }; } export interface PageAuditResult { url: string; title: string; passed: boolean; crashed: boolean; duration: number; scores: { accessibility: number; performance: number; seo: number; mobile: number; }; issues: { errors: AuditIssue[]; warnings: AuditIssue[]; notices: AuditIssue[]; }; metrics: { loadTime: number; contentSize: number; resourceCount: number; }; } export interface AuditIssue { type: 'accessibility' | 'performance' | 'seo' | 'mobile'; severity: 'error' | 'warning' | 'notice'; rule: string; message: string; element?: string; selector?: string; } export interface AuditProgress { phase: 'initializing' | 'parsing' | 'testing' | 'generating' | 'complete'; progress: number; completed: number; total: number; currentUrl?: string; eta?: number; message?: string; } export type ProgressCallback = (progress: AuditProgress) => void; export type ErrorCallback = (error: AuditError) => void; export interface AuditError { code: 'SITEMAP_ERROR' | 'BROWSER_ERROR' | 'TIMEOUT_ERROR' | 'VALIDATION_ERROR' | 'SYSTEM_ERROR'; message: string; url?: string; details?: any; recoverable: boolean; } /** * Stable Auditor Class - The main interface for website auditing */ export declare class StableAuditor { private config; private accessibilityChecker?; private browserPoolManager?; private progressCallback?; private errorCallback?; private isInitialized; private healthStatus; constructor(config: StableAuditConfig); /** * Set progress callback to monitor audit progress */ onProgress(callback: ProgressCallback): this; /** * Set error callback to handle recoverable errors */ onError(callback: ErrorCallback): this; /** * Initialize the auditor (must be called before auditing) */ initialize(): Promise<void>; /** * Perform a complete website audit */ auditWebsite(sitemapUrl: string): Promise<AuditResult>; /** * Cleanup resources (call when done) */ cleanup(): Promise<void>; /** * Get current health status of the auditor */ getHealthStatus(): { status: string; details: any; }; private validateAndNormalizeConfig; private performHealthCheck; private parseSitemap; private auditPages; private transformToPageAuditResult; private generateReports; private generateMarkdownReport; private calculateSummary; private calculatePerformanceMetrics; private reportProgress; private reportError; } export declare function createStableAuditor(config: StableAuditConfig): StableAuditor; //# sourceMappingURL=stable-audit-interface.d.ts.map