UNPKG

deepsource-mcp-server

Version:
92 lines (91 loc) 3.03 kB
/** * @fileoverview Metrics client for the DeepSource API * This module provides functionality for working with DeepSource quality metrics. */ import { BaseDeepSourceClient } from './base-client.js'; import { MetricShortcode, RepositoryMetric, UpdateMetricThresholdParams, UpdateMetricSettingParams, MetricThresholdUpdateResponse, MetricSettingUpdateResponse, MetricHistoryParams, MetricHistoryResponse } from '../types/metrics.js'; /** * Client for interacting with DeepSource metrics API * @class * @extends BaseDeepSourceClient * @public */ export declare class MetricsClient extends BaseDeepSourceClient { /** * Fetches quality metrics from a DeepSource project * @param projectKey The project key to fetch metrics for * @param options Optional filter options * @returns Promise that resolves to an array of repository metrics * @throws {ClassifiedError} When the API request fails * @public */ getQualityMetrics(projectKey: string, options?: { shortcodeIn?: MetricShortcode[]; }): Promise<RepositoryMetric[]>; /** * Updates a metric threshold * @param params Threshold update parameters * @returns Promise that resolves to update response * @public */ setMetricThreshold(params: UpdateMetricThresholdParams): Promise<MetricThresholdUpdateResponse>; /** * Updates metric settings (reporting and enforcement) * @param params Setting update parameters * @returns Promise that resolves to update response * @public */ updateMetricSetting(params: UpdateMetricSettingParams): Promise<MetricSettingUpdateResponse>; /** * Fetches metric history data * @param params History request parameters * @returns Promise that resolves to metric history response * @public */ getMetricHistory(params: MetricHistoryParams): Promise<MetricHistoryResponse | null>; /** * Builds GraphQL query for quality metrics * @private */ private static buildQualityMetricsQuery; /** * Builds GraphQL mutation for updating metric threshold * @private */ private static buildUpdateThresholdMutation; /** * Builds GraphQL mutation for updating metric setting * @private */ private static buildUpdateSettingMutation; /** * Builds GraphQL query for metric history * @private */ private static buildMetricHistoryQuery; /** * Extracts metrics from GraphQL response * @private */ private extractMetricsFromResponse; /** * Extracts history data from GraphQL response * @private */ private extractHistoryFromResponse; /** * Calculates trend from metric history values * @private */ private static calculateTrend; /** * Handles test environment scenarios * @private */ private static handleTestEnvironment; /** * Handles errors during metrics fetching * @private */ private handleMetricsError; }