@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
148 lines • 5.94 kB
TypeScript
/**
* 🏗️ Base Types for Modular Audit Architecture
*
* Common interfaces, types, and utilities used across all analysis groups.
* Provides consistent scoring, grading, and recommendation patterns.
*/
import { Page } from 'playwright';
/** Grade levels used across all analysis groups */
export type Grade = 'A' | 'B' | 'C' | 'D' | 'F';
/** Certificate levels for visual achievement display */
export type CertificateLevel = 'PLATINUM' | 'GOLD' | 'SILVER' | 'BRONZE' | 'NEEDS_IMPROVEMENT';
/** Issue severity levels */
export type IssueSeverity = 'critical' | 'error' | 'warning' | 'notice' | 'info';
/** Recommendation priority levels */
export type RecommendationPriority = 'high' | 'medium' | 'low';
/** Base interface for all analysis results */
export interface BaseAnalysisResult {
/** Overall score for this analysis group (0-100) */
overallScore: number;
/** Letter grade based on score */
grade: Grade;
/** Certificate level for achievements */
certificate: CertificateLevel;
/** Timestamp when analysis was performed */
analyzedAt: string;
/** Analysis duration in milliseconds */
duration: number;
/** Analysis status */
status: 'completed' | 'failed' | 'partial';
}
/** Base interface for issues found during analysis */
export interface BaseIssue {
/** Unique identifier for this issue type */
id: string;
/** Issue severity level */
severity: IssueSeverity;
/** Human-readable issue description */
message: string;
/** Technical details about the issue */
details?: string;
/** CSS selector or location where issue was found */
selector?: string;
/** Code or context related to the issue */
context?: string;
/** Reference to documentation or standards */
reference?: string;
}
/** Base interface for recommendations */
export interface BaseRecommendation {
/** Unique identifier for this recommendation */
id: string;
/** Recommendation priority */
priority: RecommendationPriority;
/** Issue category this addresses */
category: string;
/** Short description of the issue */
issue: string;
/** Recommended action to take */
recommendation: string;
/** Expected impact of implementing the recommendation */
impact: string;
/** Estimated effort to implement (hours) */
effort?: number;
/** Potential improvement in score */
scoreImprovement?: number;
}
/** Base analysis options for all analyzers */
export interface BaseAnalysisOptions {
/** Maximum time to spend on analysis (ms) */
timeout?: number;
/** Whether to include detailed analysis */
includeDetails?: boolean;
/** Whether to generate recommendations */
generateRecommendations?: boolean;
/** Custom configuration for this analysis */
config?: Record<string, unknown>;
}
/** Base interface that all analyzers must implement */
export interface BaseAnalyzer<TResult extends BaseAnalysisResult, TOptions extends BaseAnalysisOptions = BaseAnalysisOptions> {
/** Perform the analysis and return results */
analyze(page: Page, url: string, options?: TOptions): Promise<TResult>;
/** Extract the overall score from analysis results */
getScore(result: TResult): number;
/** Calculate grade from score */
getGrade(score: number): Grade;
/** Calculate certificate level from score */
getCertificateLevel(score: number): CertificateLevel;
/** Extract recommendations from analysis results */
getRecommendations(result: TResult): BaseRecommendation[];
/** Get analyzer name for reporting */
getName(): string;
/** Get analyzer version for tracking */
getVersion(): string;
}
/** Standard grade calculation based on score */
export declare function calculateGrade(score: number): Grade;
/** Standard certificate level calculation based on score */
export declare function calculateCertificateLevel(score: number): CertificateLevel;
/** Calculate weighted average score */
export declare function calculateWeightedScore(scores: Array<{
score: number;
weight: number;
}>): number;
/** Calculate overall score from multiple category scores */
export declare function calculateOverallScore(categoryScores: Record<string, number>, weights?: Record<string, number>): number;
/** Validate that a score is within the valid range */
export declare function validateScore(score: number, context?: string): number;
/** Create a base analysis result with common fields */
export declare function createBaseResult<T extends BaseAnalysisResult>(overallScore: number, partialResult: Omit<T, keyof BaseAnalysisResult>): T;
/** Global analysis configuration */
export interface GlobalAnalysisConfig {
/** Enable verbose logging */
verbose?: boolean;
/** Maximum total analysis time (ms) */
maxAnalysisTime?: number;
/** Number of retries on failure */
retries?: number;
/** User agent to use for analysis */
userAgent?: string;
/** Viewport size for analysis */
viewport?: {
width: number;
height: number;
};
}
/** Default configuration values */
export declare const DEFAULT_CONFIG: Required<GlobalAnalysisConfig>;
/** Simple performance timer */
export declare class PerformanceTimer {
private startTime;
constructor();
/** Get elapsed time in milliseconds */
getElapsed(): number;
/** Reset the timer */
reset(): void;
}
/** Create a timer-enabled wrapper for async operations */
export declare function withTiming<T>(operation: () => Promise<T>, context?: string): Promise<{
result: T;
duration: number;
}>;
/** Validate URL format */
export declare function isValidUrl(urlString: string): boolean;
/** Extract domain from URL */
export declare function extractDomain(url: string): string;
/** Check if URL uses HTTPS */
export declare function isSecureUrl(url: string): boolean;
//# sourceMappingURL=base-types.d.ts.map