import { InternalCoreStart } from './internal_types' ; import { KibanaRequest } from './http/router' ; import { SavedObjectsClientContract } from './saved_objects/types' ; import { InternalSavedObjectsServiceStart , ISavedObjectTypeRegistry , SavedObjectsClientProviderOptions , } from './saved_objects' ; import { InternalElasticsearchServiceStart , IScopedClusterClient } from './elasticsearch' ; import { InternalUiSettingsServiceStart , IUiSettingsClient } from './ui_settings' ; import { DeprecationsClient , InternalDeprecationsServiceStart } from './deprecations' ; class CoreElasticsearchRouteHandlerContext { #client ? : IScopedClusterClient ; constructor ( private readonly elasticsearchStart , private readonly request ) { } public get client ( ) { if ( this . #client == null ) { this . #client = this . elasticsearchStart . client . asScoped ( this . request ) ; } return this . #client ; } } class CoreSavedObjectsRouteHandlerContext { constructor ( private readonly savedObjectsStart , private readonly request ) { } #scopedSavedObjectsClient ? : SavedObjectsClientContract ; #typeRegistry ? : ISavedObjectTypeRegistry ; public get client ( ) { if ( this . #scopedSavedObjectsClient == null ) { this . #scopedSavedObjectsClient = this . savedObjectsStart . getScopedClient ( this . request ) ; } return this . #scopedSavedObjectsClient ; } public get typeRegistry ( ) { if ( this . #typeRegistry == null ) { this . #typeRegistry = this . savedObjectsStart . getTypeRegistry ( ) ; } return this . #typeRegistry ; } public getClient = ( options ? ) => { if ( ! options ) return this . client ; return this . savedObjectsStart . getScopedClient ( this . request , options ) ; } ; public getExporter = ( client ) => { return this . savedObjectsStart . createExporter ( client ) ; } ; public getImporter = ( client ) => { return this . savedObjectsStart . createImporter ( client ) ; } ; } class CoreUiSettingsRouteHandlerContext { #client ? : IUiSettingsClient ; constructor ( private readonly uiSettingsStart , private readonly savedObjectsRouterHandlerContext ) { } public get client ( ) { if ( this . #client == null ) { this . #client = this . uiSettingsStart . asScopedToClient ( this . savedObjectsRouterHandlerContext . client ) ; } return this . #client ; } } class CoreDeprecationsRouteHandlerContext { #client ? : DeprecationsClient ; constructor ( private readonly deprecationsStart , private readonly elasticsearchRouterHandlerContext , private readonly savedObjectsRouterHandlerContext ) { } public get client ( ) { if ( this . #client == null ) { this . #client = this . deprecationsStart . asScopedToClient ( this . elasticsearchRouterHandlerContext . client , this . savedObjectsRouterHandlerContext . client ) ; } return this . #client ; } } export class CoreRouteHandlerContext { readonly elasticsearch : CoreElasticsearchRouteHandlerContext ; readonly savedObjects : CoreSavedObjectsRouteHandlerContext ; readonly uiSettings : CoreUiSettingsRouteHandlerContext ; readonly deprecations : CoreDeprecationsRouteHandlerContext ; constructor ( private readonly coreStart , private readonly request ) { this . elasticsearch = new CoreElasticsearchRouteHandlerContext ( this . coreStart . elasticsearch , this . request ) ; this . savedObjects = new CoreSavedObjectsRouteHandlerContext ( this . coreStart . savedObjects , this . request ) ; this . uiSettings = new CoreUiSettingsRouteHandlerContext ( this . coreStart . uiSettings , this . savedObjects ) ; this . deprecations = new CoreDeprecationsRouteHandlerContext ( this . coreStart . deprecations , this . elasticsearch , this . savedObjects ) ; } }