deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
127 lines (126 loc) • 4.87 kB
TypeScript
/**
* @fileoverview ComplianceReport repository implementation
*
* Concrete implementation of IComplianceReportRepository using DeepSource API.
*/
import { IComplianceReportRepository } from '../../domain/aggregates/compliance-report/compliance-report.repository.js';
import { ComplianceReport } from '../../domain/aggregates/compliance-report/compliance-report.aggregate.js';
import { ProjectKey } from '../../types/branded.js';
import { ReportType } from '../../types/report-types.js';
import { ComplianceReportStatus, ComplianceReportId } from '../../domain/aggregates/compliance-report/compliance-report.types.js';
import { DeepSourceClient } from '../../deepsource.js';
/**
* Concrete implementation of IComplianceReportRepository using DeepSource API
*
* This repository provides access to ComplianceReport aggregates by fetching data
* from the DeepSource API and mapping it to domain models.
*
* Note: The DeepSource API provides compliance reports for specific types
* (OWASP_TOP_10, SANS_TOP_25, MISRA_C). This repository ensures fresh data
* retrieval on every request as per requirements.
*/
export declare class ComplianceReportRepository implements IComplianceReportRepository {
private readonly client;
constructor(client: DeepSourceClient);
/**
* Helper method to get repository ID for a project
*
* @param projectKey - The project key
* @returns The repository GraphQL ID
*/
private getRepositoryId;
/**
* Finds a report by composite ID
*
* @param id - The composite ID (projectKey:reportType)
* @returns The report if found, null otherwise
*/
findById(id: string): Promise<ComplianceReport | null>;
/**
* Finds a report by project and type
*
* @param projectKey - The project key
* @param reportType - The report type
* @returns The report if found, null otherwise
*/
findByProjectAndType(projectKey: ProjectKey, reportType: ReportType): Promise<ComplianceReport | null>;
/**
* Finds the latest reports for a project
*
* @param projectKey - The project key
* @returns All reports for the project, sorted by generation date (newest first)
*/
findLatest(projectKey: ProjectKey): Promise<ComplianceReport[]>;
/**
* Finds reports by status
*
* @param projectKey - The project key
* @param status - The report status
* @returns Reports matching the status
*/
findByStatus(projectKey: ProjectKey, status: ComplianceReportStatus): Promise<ComplianceReport[]>;
/**
* Finds all compliant reports for a project
*
* @param projectKey - The project key
* @returns Reports with compliance score >= 85%
*/
findCompliantReports(projectKey: ProjectKey): Promise<ComplianceReport[]>;
/**
* Finds reports with critical issues
*
* @param projectKey - The project key
* @returns Reports that have critical severity issues
*/
findReportsWithCriticalIssues(projectKey: ProjectKey): Promise<ComplianceReport[]>;
/**
* Finds a report by composite ID components
*
* @param id - The composite ID components
* @returns The report if found, null otherwise
*/
findByCompositeId(id: ComplianceReportId): Promise<ComplianceReport | null>;
/**
* Counts total reports for a project
*
* @param projectKey - The project key
* @returns The total number of reports
*/
countByProject(projectKey: ProjectKey): Promise<number>;
/**
* Counts reports by type for a project
*
* @param projectKey - The project key
* @param reportType - The report type
* @returns The number of reports of the given type
*/
countByType(projectKey: ProjectKey, reportType: ReportType): Promise<number>;
/**
* Checks if a report exists for a project and type
*
* @param projectKey - The project key
* @param reportType - The report type
* @returns True if a report exists, false otherwise
*/
exists(projectKey: ProjectKey, reportType: ReportType): Promise<boolean>;
/**
* Saves compliance report
*
* Note: The DeepSource API doesn't support creating or updating compliance reports.
* Reports are generated automatically based on repository analysis.
*
* @param report - The report to save
* @throws Error indicating the operation is not supported
*/
save(report: ComplianceReport): Promise<void>;
/**
* Deletes compliance report
*
* Note: The DeepSource API doesn't support deleting compliance reports.
* Reports are managed automatically based on repository configuration.
*
* @param id - The report ID to delete
* @throws Error indicating the operation is not supported
*/
delete(id: string): Promise<void>;
}