import { CoreSetup , PluginInitializerContext , KibanaRequest , RequestHandlerContext , } from 'kibana/server' ; import { LicensingApiRequestHandlerContext } from '../../../../licensing/server' ; import { createAnnotationsClient } from './create_annotations_client' ; import { registerAnnotationAPIs } from './register_annotation_apis' ; interface Params { index : string ; core : CoreSetup ; context : PluginInitializerContext ; } export type ScopedAnnotationsClientFactory = Awaited < ReturnType < typeof bootstrapAnnotations > > [ 'getScopedAnnotationsClient' ] ; export type ScopedAnnotationsClient = ReturnType < ScopedAnnotationsClientFactory > ; export type AnnotationsAPI = Awaited < ReturnType < typeof bootstrapAnnotations > > ; export async function bootstrapAnnotations ( { index , core , context } ) { const logger = context . logger . get ( 'annotations' ) ; registerAnnotationAPIs ( { core , index , logger , } ) ; return { getScopedAnnotationsClient : ( requestContext , request ) => { return createAnnotationsClient ( { index , esClient : requestContext . core . elasticsearch . client . asCurrentUser , logger , license : requestContext . licensing ?. license , } ) ; } , } ; }