import type { HealthCheckResult } from './types.ts'; /** * The Result class offers a chainable API to create health check results * * @example * ```typescript * // Success result * const success = Result.ok('Database connection is healthy') * * // Warning result * const warning = Result.warning('High memory usage detected') * * // Error result * const error = Result.failed('Database connection failed', new Error('Connection timeout')) * * // With metadata * const result = Result.ok('Service is running') * .setMetaData({ responseTime: 120, uptime: 86400 }) * ``` */ export declare class Result implements HealthCheckResult { message: string; status: HealthCheckResult['status']; finishedAt: Date; /** * Creates a result with success status * * @param message - The success message * * @example * ```typescript * const result = Result.ok('Database connection is healthy') * ``` */ static ok(message: string): Result; /** * Creates a result with failed status * * @param message - The error message or Error object * @param error - Optional error object when message is a string * * @example * ```typescript * const result1 = Result.failed('Database connection failed') * const result2 = Result.failed('Service error', new Error('Connection timeout')) * const result3 = Result.failed(new Error('Critical failure')) * ``` */ static failed(message: string, error?: Error): Result; static failed(error: Error): Result; /** * Creates a result with warning status * * @param message - The warning message * * @example * ```typescript * const result = Result.warning('Memory usage is above 80%') * ``` */ static warning(message: string): Result; /** * Optional metadata associated with the result */ meta?: HealthCheckResult['meta']; /** * Creates a new Result instance * * @param message - The result message * @param status - The result status * @param finishedAt - The timestamp when the check finished */ constructor(message: string, status: HealthCheckResult['status'], finishedAt: Date); /** * Updates the finished at timestamp for the result * * @param finishedAt - The new finish timestamp * * @example * ```typescript * const result = Result.ok('Check completed') * .setFinishedAt(new Date('2024-01-01T10:00:00Z')) * ``` */ setFinishedAt(finishedAt: Date): this; /** * Defines custom meta-data for the result. Calling this method will * override any existing meta-data * * @param metaData - The metadata object to set * * @example * ```typescript * const result = Result.ok('Service is healthy') * .setMetaData({ responseTime: 120, uptime: 86400 }) * ``` */ setMetaData(metaData: Record): this; /** * Merges custom meta-data with the existing meta-data. A shallow * merge is performed * * @param metaData - The metadata object to merge * * @example * ```typescript * const result = Result.ok('Service is healthy') * .setMetaData({ responseTime: 120 }) * .mergeMetaData({ uptime: 86400 }) * // result.meta = { responseTime: 120, uptime: 86400 } * ``` */ mergeMetaData(metaData: Record): this; /** * Converts the result to a plain object * * @example * ```typescript * const result = Result.ok('Service is healthy') * const json = result.toJSON() * console.log(json) // { message: 'Service is healthy', status: 'ok', finishedAt: Date } * ``` */ toJSON(): HealthCheckResult; }