deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
107 lines (106 loc) • 3.24 kB
TypeScript
/**
* @fileoverview MetricValue value object
*
* This module defines the MetricValue value object which represents
* a measured metric value with its unit and display formatting.
*/
import { ValueObject } from '../shared/value-object.js';
/**
* Properties for the MetricValue value object
*/
interface MetricValueProps {
value: number;
unit: string;
displayValue: string;
measuredAt: Date;
}
/**
* Value object representing a metric measurement
*
* Encapsulates a metric value with its unit, display formatting,
* and the timestamp when it was measured.
*
* @example
* ```typescript
* const coverage = MetricValue.create(85.5, '%');
* console.log(coverage.value); // 85.5
* console.log(coverage.displayValue); // "85.5%"
*
* const complexity = MetricValue.create(12, 'points', '12/20');
* console.log(complexity.displayValue); // "12/20"
* ```
*/
export declare class MetricValue extends ValueObject<MetricValueProps> {
private constructor();
/**
* Creates a new MetricValue instance
*
* @param value - The numeric value of the metric
* @param unit - The unit of measurement
* @param displayValue - Optional custom display value (defaults to value + unit)
* @param measuredAt - Optional measurement timestamp (defaults to now)
* @returns A new MetricValue instance
* @throws Error if the value is not a valid number
*/
static create(value: number, unit: string, displayValue?: string, measuredAt?: Date): MetricValue;
/**
* Creates a percentage metric value
*
* @param value - The percentage value
* @param decimalPlaces - Number of decimal places to display (default: 1)
* @returns A new MetricValue instance for percentages
*/
static createPercentage(value: number, decimalPlaces?: number): MetricValue;
/**
* Creates a null/unknown metric value
*
* @param unit - The unit of measurement
* @returns A new MetricValue instance representing an unknown value
*/
static createUnknown(unit: string): MetricValue;
/**
* Gets the numeric value
*/
get value(): number;
/**
* Gets the unit of measurement
*/
get unit(): string;
/**
* Gets the display-formatted value
*/
get displayValue(): string;
/**
* Gets the measurement timestamp
*/
get measuredAt(): Date;
/**
* Checks if this is a percentage value
*/
get isPercentage(): boolean;
/**
* Checks if this represents an unknown/null value
*/
get isUnknown(): boolean;
/**
* Calculates the difference between this value and another
*
* @param other - The other metric value to compare
* @returns The numeric difference
* @throws Error if the units don't match
*/
difference(other: MetricValue): number;
/**
* Calculates the percentage change from another value
*
* @param previous - The previous metric value
* @returns The percentage change
* @throws Error if the units don't match
*/
percentageChange(previous: MetricValue): number;
/**
* Returns a string representation of the metric value
*/
toString(): string;
}
export {};