import { formatRequest } from '@kbn/server-route-repository/target_node/format_request' ; import type { formatRequest as formatRequestType } from '@kbn/server-route-repository/target_types/format_request' ; import type { HttpSetup } from 'kibana/public' ; import type { AbstractObservabilityClient , ObservabilityClient } from './types' ; export let callObservabilityApi = ( ) => { throw new Error ( 'callObservabilityApi has not been initialized via createCallObservabilityApi' ) ; } ; export function createCallObservabilityApi ( http ) { const client = ( options ) => { const { params : { path , body , query } = { } , endpoint , ... rest } = options ; const { method , pathname } = formatRequest ( endpoint , path ) as ReturnType < typeof formatRequestType > ; return http [ method ] ( pathname , { ... rest , body , query , } ) ; } ; callObservabilityApi = client ; }