import { ReviewComment } from './ReviewComment'; export interface ReviewReport { readonly id: string; readonly timestamp: Date; readonly summary: string; readonly overallScore: number; readonly comments: ReviewComment[]; readonly metrics: ReviewMetrics; readonly recommendations: string[]; } export interface ReviewMetrics { readonly totalComments: number; readonly errorCount: number; readonly warningCount: number; readonly infoCount: number; readonly suggestionCount: number; readonly filesReviewed: number; readonly linesAdded: number; readonly linesRemoved: number; readonly testCoverage?: number; } export interface ReviewReportBuilder { id(id: string): ReviewReportBuilder; timestamp(timestamp: Date): ReviewReportBuilder; summary(summary: string): ReviewReportBuilder; overallScore(score: number): ReviewReportBuilder; addComment(comment: ReviewComment): ReviewReportBuilder; comments(comments: ReviewComment[]): ReviewReportBuilder; metrics(metrics: ReviewMetrics): ReviewReportBuilder; addRecommendation(recommendation: string): ReviewReportBuilder; recommendations(recommendations: string[]): ReviewReportBuilder; build(): ReviewReport; } export class ReviewReportImpl implements ReviewReportBuilder { private report: any = { comments: [], recommendations: [], }; id(id: string): ReviewReportBuilder { this.report.id = id; return this; } timestamp(timestamp: Date): ReviewReportBuilder { this.report.timestamp = timestamp; return this; } summary(summary: string): ReviewReportBuilder { this.report.summary = summary; return this; } overallScore(score: number): ReviewReportBuilder { if (score < 0 || score > 100) { throw new Error('Overall score must be between 0 and 100'); } this.report.overallScore = score; return this; } addComment(comment: ReviewComment): ReviewReportBuilder { if (!this.report.comments) { this.report.comments = []; } this.report.comments.push(comment); return this; } comments(comments: ReviewComment[]): ReviewReportBuilder { this.report.comments = comments; return this; } metrics(metrics: ReviewMetrics): ReviewReportBuilder { this.report.metrics = metrics; return this; } addRecommendation(recommendation: string): ReviewReportBuilder { if (!this.report.recommendations) { this.report.recommendations = []; } this.report.recommendations.push(recommendation); return this; } recommendations(recommendations: string[]): ReviewReportBuilder { this.report.recommendations = recommendations; return this; } build(): ReviewReport { if (!this.report.id || !this.report.timestamp || !this.report.summary || this.report.overallScore === undefined || !this.report.comments || !this.report.metrics || !this.report.recommendations) { throw new Error('Required fields missing for ReviewReport'); } return { id: this.report.id, timestamp: this.report.timestamp, summary: this.report.summary, overallScore: this.report.overallScore, comments: this.report.comments, metrics: this.report.metrics, recommendations: this.report.recommendations, }; } }