/**
 * Represents the result of a single health check execution
 *
 * @example
 * ```typescript
 * // Success result
 * const result: HealthCheckResult = {
 *   message: 'Database connection is healthy',
 *   status: 'ok',
 *   finishedAt: new Date(),
 *   meta: { responseTime: 120 }
 * }
 *
 * // Or using Result class
 * const result2 = Result.ok('Service is running')
 *   .setMetaData({ uptime: 86400 })
 *   .toJSON()
 * ```
 */
export type HealthCheckResult = {
    /**
     * A summary of the check result
     */
    message: string;
    /**
     * The status of the check
     */
    status: 'ok' | 'warning' | 'error';
    /**
     * Date/time when this check was completed
     */
    finishedAt: Date;
    /**
     * Optional meta-data associated with the check
     */
    meta?: Record<string, any>;
};
/**
 * The health check report generated by the health check runner.
 * Contains the overall status and results of all executed health checks.
 *
 * @example
 * ```typescript
 * const healthChecks = new HealthChecks()
 * healthChecks.register([
 *   new DiskSpaceCheck().warnWhenExceeds(70).failWhenExceeds(85),
 *   new MemoryHeapCheck().warnWhenExceeds('200 mb')
 * ])
 *
 * const report: HealthCheckReport = await healthChecks.run()
 *
 * console.log(report.isHealthy) // true or false
 * console.log(report.status) // 'ok' | 'warning' | 'error'
 * console.log(report.checks.length) // 2
 * console.log(report.debugInfo.pid) // Process ID
 *
 * // Check individual results
 * report.checks.forEach(check => {
 *   console.log(`${check.name}: ${check.status}`)
 *   if (check.isCached) {
 *     console.log('Result was cached')
 *   }
 * })
 * ```
 */
export type HealthCheckReport = {
    /**
     * Indicates whether the entire report is healthy. The value will be set to
     * false when one or more of the checks has a status of "error"
     */
    isHealthy: boolean;
    /**
     * Status of the entire report
     *
     * - Set to "ok" when all checks have ok status
     * - Set to "warning" when one or more checks have warning status
     * - Set to "error" when one or more checks have error status
     */
    status: 'ok' | 'warning' | 'error';
    /**
     * The date/time when the entire report was computed
     */
    finishedAt: Date;
    /**
     * The debugging information for the running process
     */
    debugInfo: {
        /**
         * The process id
         */
        pid: number;
        /**
         * The process id for the parent process (if any)
         */
        ppid?: number;
        /**
         * The number of seconds for which the process has been
         * running.
         */
        uptime: number;
        /**
         * Node.js version
         */
        version: string;
        /**
         * The platform on which the application is running
         */
        platform: string;
    };
    /**
     * Performed checks and their results
     */
    checks: ({
        isCached: boolean;
        name: string;
    } & HealthCheckResult)[];
};
/**
 * Contract that all health checks must implement.
 * Defines the required properties and methods for a health check.
 *
 * @example
 * ```typescript
 * class DatabaseCheck extends BaseCheck implements HealthCheckContract {
 *   name = 'Database connection check'
 *   cacheDuration = 60 // Cache for 60 seconds
 *
 *   async run(): Promise<HealthCheckResult> {
 *     try {
 *       // Check database connection
 *       await database.raw('SELECT 1')
 *       return Result.ok('Database connection is healthy')
 *         .setMetaData({ connectionPool: database.pool.numUsed() })
 *     } catch (error) {
 *       return Result.failed('Database connection failed', error)
 *     }
 *   }
 * }
 *
 * // Usage
 * const dbCheck = new DatabaseCheck()
 * const result = await dbCheck.run()
 * ```
 */
export interface HealthCheckContract {
    /**
     * A unique name for the check
     */
    name: string;
    /**
     * Whether to cache the results or not. The value must be
     * specified in seconds
     */
    cacheDuration?: number;
    /**
     * The method to execute to perform the check
     */
    run(): Promise<HealthCheckResult>;
}
/**
 * Tracing data shared with the health check channel subscribers.
 * This data is passed to diagnostic channel listeners when health checks are executed.
 *
 * @example
 * ```typescript
 * healthCheck.subscribe({
 *   start(data: HealthCheckTracingData) {
 *     console.log(`Starting check: ${data.check.name}`)
 *   },
 *   end(data: HealthCheckTracingData) {
 *     console.log(`Finished check: ${data.check.name}`)
 *   }
 * })
 * ```
 */
export type HealthCheckTracingData = {
    /**
     * The health check instance being executed
     */
    check: HealthCheckContract;
};
