import { Observable } from 'rxjs' ; import { deepFreeze } from '@osd/std' ; import { PluginName } from '../plugins' ; typeParam public export interface ServiceStatus < Meta extends Record < string , any > | unknown = unknown > { /**
     * The current availability level of the service.
     */ level : ServiceStatusLevel ; /**
     * A high-level summary of the service status.
     */ summary : string ; /**
     * A more detailed description of the service status.
     */ detail ? : string ; /**
     * A URL to open in a new tab about how to resolve or troubleshoot the problem.
     */ documentationUrl ? : string ; /**
     * Any JSON-serializable data to be included in the HTTP API response. Useful for providing more fine-grained,
     * machine-readable information about the service status. May include status information for underlying features.
     */ meta ? : Meta ; } remarks public export const ServiceStatusLevels = deepFreeze ( { /**
     * Everything is working!
     */ available : { toString : ( ) => 'available' , valueOf : ( ) => 0 , toJSON ( ) { return this . toString ( ) ; } , } , /**
     * Some features may not be working.
     */ degraded : { toString : ( ) => 'degraded' , valueOf : ( ) => 1 , toJSON ( ) { return this . toString ( ) ; } , } , /**
     * The service is unavailable, but other functions that do not depend on this service should work.
     */ unavailable : { toString : ( ) => 'unavailable' , valueOf : ( ) => 2 , toJSON ( ) { return this . toString ( ) ; } , } , /**
     * Block all user functions and display the status page, reserved for Core services only.
     */ critical : { toString : ( ) => 'critical' , valueOf : ( ) => 3 , toJSON ( ) { return this . toString ( ) ; } , } , } ) ; /**
 * A convenience type that represents the union of each value in  ServiceStatusLevels .
 *  public export type ServiceStatusLevel = typeof ServiceStatusLevels [ keyof typeof ServiceStatusLevels ] ; internalRemarks public export interface CoreStatus { opensearch : ServiceStatus ; savedObjects : ServiceStatus ; } remarks By default, a plugin inherits it's current status from the most severe status level of any Core services and any
 * plugins that it depends on. This default status is available on the
 *  ServiceStatusSetup . derivedStatus$ API.
 *
 * Plugins may customize their status calculation by calling the  ServiceStatusSetup . set API
 * with an Observable. Within this Observable, a plugin may choose to only depend on the status of some of its
 * dependencies, to ignore severe status levels of particular Core services they are not concerned with, or to make its
 * status dependent on other external services.
 *
 *  example example public export interface StatusServiceSetup { /**
     * Current status for all Core services.
     */ core$ : Observable < CoreStatus > ; remarks The level of the overall status will reflect the most severe status of any core service or plugin.
     *
     * Exposed only for reporting purposes to outside systems and should not be used by plugins. Instead, plugins should
     * only depend on the statuses of  StatusServiceSetup . core$ or their dependencies.
      overall$ : Observable < ServiceStatus > ; remarks See the  StatusServiceSetup . derivedStatus$ API for leveraging the default status
     * calculation that is provided by Core.
      set ( status$ ) : void ; /**
     * Current status for all plugins this plugin depends on.
     * Each key of the `Record` is a plugin id.
     */ dependencies$ : Observable < Record < string , ServiceStatus > > ; remarks By default, plugins inherit this derived status from their dependencies.
     * Calling  StatusSetup . set overrides this default status.
     *
     * This may emit multliple times for a single status change event as propagates
     * through the dependency tree
      derivedStatus$ : Observable < ServiceStatus > ; /**
     * Whether or not the status HTTP APIs are available to unauthenticated users when an authentication provider is
     * present.
     */ isStatusPageAnonymous : ( ) => boolean ; } internal export interface InternalStatusServiceSetup extends Pick < StatusServiceSetup , 'core$' | 'overall$' | 'isStatusPageAnonymous' > { plugins : { set ( plugin , status$ ) : void ; getDependenciesStatus$ ( plugin ) : Observable < Record < string , ServiceStatus > > ; getDerivedStatus$ ( plugin ) : Observable < ServiceStatus > ; } ; }