deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
93 lines (92 loc) • 3.58 kB
TypeScript
/**
* @fileoverview ComplianceReport mapper
*
* Maps between DeepSource API models and domain ComplianceReport aggregates.
*/
import { ComplianceReport } from '../../domain/aggregates/compliance-report/compliance-report.aggregate.js';
import { ComplianceReport as ApiComplianceReport } from '../../deepsource.js';
import { ComplianceCategory, ComplianceReportStatus } from '../../domain/aggregates/compliance-report/compliance-report.types.js';
import { ReportType } from '../../types/report-types.js';
/**
* Maps the highest severity from occurrence distribution
*
* @param occurrence - The severity distribution
* @returns The highest severity present
*/
declare function mapHighestSeverity(occurrence: ApiComplianceReport['securityIssueStats'][0]['occurrence']): 'CRITICAL' | 'MAJOR' | 'MINOR' | 'INFO';
/**
* Maps the API report status to domain status
*
* @param apiStatus - The API status
* @returns The domain report status
*/
declare function mapReportStatus(apiStatus?: string): ComplianceReportStatus;
/**
* Maps a DeepSource API compliance report to domain ComplianceReport aggregate
*
* @param apiReport - The API compliance report model
* @param projectKey - The project key
* @param repositoryId - The repository GraphQL ID
* @returns The domain ComplianceReport aggregate
*/
export declare function mapComplianceReportToDomain(apiReport: ApiComplianceReport, projectKey: string, repositoryId: string): ComplianceReport;
/**
* Maps a domain ComplianceReport aggregate to persistence format
*
* @param report - The domain ComplianceReport aggregate
* @returns The persistence model
*/
export declare function mapComplianceReportToPersistence(report: ComplianceReport): {
id: string;
projectKey: string;
repositoryId: string;
reportType: ReportType;
status: ComplianceReportStatus;
categories: ComplianceCategory[];
generatedAt: Date;
lastUpdated: Date;
};
/**
* Creates a category from API security issue stat
*
* @param stat - The API security issue statistic
* @param reportType - The report type for context
* @returns A compliance category
*/
export declare function createCategoryFromStat(stat: {
key: string;
title: string;
occurrence: {
critical: number;
major: number;
minor: number;
total: number;
};
}, reportType: ReportType): ComplianceCategory;
/**
* Estimates compliance score based on issue counts
* This is a simplified calculation since the API doesn't provide the exact score
*
* @param categories - The compliance categories
* @returns Estimated compliance score (0-100)
*/
export declare function estimateComplianceScore(categories: ComplianceCategory[]): number;
/**
* Maps multiple API compliance reports to domain aggregates
*
* @param apiReports - Array of API compliance reports
* @param projectKey - The project key
* @param repositoryId - The repository GraphQL ID
* @returns Array of domain ComplianceReport aggregates
*/
export declare function mapComplianceReportsFromList(apiReports: ApiComplianceReport[], projectKey: string, repositoryId: string): ComplianceReport[];
export declare const ComplianceReportMapper: {
toDomain: typeof mapComplianceReportToDomain;
mapStatus: typeof mapReportStatus;
mapHighestSeverity: typeof mapHighestSeverity;
toPersistence: typeof mapComplianceReportToPersistence;
toDomainFromList: typeof mapComplianceReportsFromList;
createCategoryFromStat: typeof createCategoryFromStat;
estimateComplianceScore: typeof estimateComplianceScore;
};
export {};