deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
95 lines (94 loc) • 2.92 kB
TypeScript
/**
* @fileoverview ThresholdValue value object
*
* This module defines the ThresholdValue value object which represents
* a metric threshold with validation rules.
*/
import { ValueObject } from '../shared/value-object.js';
/**
* Properties for the ThresholdValue value object
*/
interface ThresholdValueProps {
value: number;
unit: string;
minAllowed: number;
maxAllowed: number;
}
/**
* Value object representing a metric threshold
*
* Encapsulates a threshold value with its unit and allowed range.
* Ensures the value is always within the valid range.
*
* @example
* ```typescript
* const coverageThreshold = ThresholdValue.create(80, '%', 0, 100);
* console.log(coverageThreshold.value); // 80
* console.log(coverageThreshold.isPercentage); // true
*
* // This will throw an error
* const invalidThreshold = ThresholdValue.create(150, '%', 0, 100);
* ```
*/
export declare class ThresholdValue extends ValueObject<ThresholdValueProps> {
private constructor();
/**
* Creates a new ThresholdValue instance
*
* @param value - The threshold value
* @param unit - The unit of measurement (e.g., '%', 'ms')
* @param minAllowed - The minimum allowed value
* @param maxAllowed - The maximum allowed value
* @returns A new ThresholdValue instance
* @throws Error if the value is outside the allowed range
*/
static create(value: number, unit: string, minAllowed: number, maxAllowed: number): ThresholdValue;
/**
* Creates a percentage threshold (0-100)
*
* @param value - The percentage value
* @returns A new ThresholdValue instance for percentages
*/
static createPercentage(value: number): ThresholdValue;
/**
* Gets the threshold value
*/
get value(): number;
/**
* Gets the unit of measurement
*/
get unit(): string;
/**
* Gets the minimum allowed value
*/
get minAllowed(): number;
/**
* Gets the maximum allowed value
*/
get maxAllowed(): number;
/**
* Checks if this is a percentage threshold
*/
get isPercentage(): boolean;
/**
* Updates the threshold value
*
* @param newValue - The new threshold value
* @returns A new ThresholdValue instance with the updated value
* @throws Error if the new value is outside the allowed range
*/
updateValue(newValue: number): ThresholdValue;
/**
* Checks if a given value meets this threshold
*
* @param value - The value to check
* @param direction - Whether higher values are better ('upward') or lower values are better ('downward')
* @returns True if the value meets the threshold, false otherwise
*/
isMet(value: number, direction: 'upward' | 'downward'): boolean;
/**
* Returns a string representation of the threshold
*/
toString(): string;
}
export {};