deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
82 lines (81 loc) • 3.5 kB
TypeScript
/**
* @fileoverview QualityMetrics mapper
*
* Maps between DeepSource API models and domain QualityMetrics aggregates.
*/
import { QualityMetrics } from '../../domain/aggregates/quality-metrics/quality-metrics.aggregate.js';
import { RepositoryMetric, RepositoryMetricItem } from '../../models/metrics.js';
import { MetricConfiguration, MetricHistoryEntry, ThresholdStatus } from '../../domain/aggregates/quality-metrics/quality-metrics.types.js';
import { MetricValue } from '../../domain/value-objects/metric-value.js';
/**
* Maps a single metric item to a domain QualityMetrics aggregate
*
* @param apiMetric - The API metric model
* @param item - The specific metric item
* @param projectKey - The project key
* @param repositoryId - The repository GraphQL ID
* @returns The domain QualityMetrics aggregate
*/
export declare function mapQualityMetricToDomain(apiMetric: RepositoryMetric, item: RepositoryMetricItem, projectKey: string, repositoryId: string): QualityMetrics;
/**
* Maps a DeepSource API metric to domain QualityMetrics aggregates
*
* Since one API metric can have multiple items (e.g., per language),
* this returns an array of QualityMetrics aggregates.
*
* @param apiMetric - The API metric model
* @param projectKey - The project key
* @param repositoryId - The repository GraphQL ID
* @returns Array of domain QualityMetrics aggregates
*/
export declare function mapQualityMetricsToDomainList(apiMetric: RepositoryMetric, projectKey: string, repositoryId: string): QualityMetrics[];
/**
* Maps API threshold status to domain threshold status
*
* @param apiStatus - The API threshold status
* @returns The domain threshold status
*/
export declare function mapThresholdStatus(apiStatus: string): ThresholdStatus;
/**
* Maps a domain QualityMetrics aggregate to persistence format
*
* @param metrics - The domain QualityMetrics aggregate
* @returns The persistence model
*/
export declare function mapQualityMetricsToPersistence(metrics: QualityMetrics): {
id: string;
projectKey: string;
repositoryId: string;
configuration: MetricConfiguration;
currentValue: MetricValue | null;
history: MetricHistoryEntry[];
lastUpdated: Date;
};
/**
* Creates a metric history entry from API data
*
* @param value - The metric value
* @param threshold - The threshold at the time (optional)
* @param commitOid - The commit SHA
* @param recordedAt - When the metric was recorded
* @param unit - The metric unit
* @returns A metric history entry
*/
export declare function createMetricHistoryEntry(value: number, threshold: number | null, commitOid: string, recordedAt: Date, unit: string, minAllowed?: number, maxAllowed?: number): MetricHistoryEntry;
/**
* Maps multiple API metrics to domain aggregates
*
* @param apiMetrics - Array of API metric models
* @param projectKey - The project key
* @param repositoryId - The repository GraphQL ID
* @returns Array of domain QualityMetrics aggregates
*/
export declare function mapQualityMetricsFromList(apiMetrics: RepositoryMetric[], projectKey: string, repositoryId: string): QualityMetrics[];
export declare const QualityMetricsMapper: {
toDomain: typeof mapQualityMetricToDomain;
toDomainList: typeof mapQualityMetricsToDomainList;
mapThresholdStatus: typeof mapThresholdStatus;
toPersistence: typeof mapQualityMetricsToPersistence;
createHistoryEntry: typeof createMetricHistoryEntry;
toDomainFromList: typeof mapQualityMetricsFromList;
};