mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Core] Explicit typings for request handler context (#88718)
* move context to server part. couple with RequestHandlerContext Context implementation will be simplified in follow-up. * adopt core code * adopt bfetch code * adopt data code * adopt search examples * adopt vis_type_timelion * adopt vis_type_timeseries * adopt plugin functional tests * adopt actions * adopt alerting plugin * adopt APM plugin * adopt beats_management * adopt case plugin * adopt cross_cluster_replication * adopt data_enhanced * adopt event_log * adopt global_search * adopt index_management * adopt infra * adopt licensing * adopt lists * adopt logstash * adopt reporting * adopt observability * adopt monitoring * adopt rollup * adopt so tagging * adopt security * adopt security_solutions * adopt watcher * adopt uptime * adopt spaces * adopt snapshot_restore * adopt features changes * mute error when null used to extend context * update docs * small cleanup * add type safety for return type * refactor registerRouteHandlerContext type * update docs * update license header * update docs * fix type error. fetch body does not accept array of strings * fix telemetry test * remove unnecessary ts-ignore * address comments * update docs
This commit is contained in:
parent
d3fa06b268
commit
b3a9754394
382 changed files with 2305 additions and 1872 deletions
|
@ -6,13 +6,16 @@
|
|||
* Public License, v 1.
|
||||
*/
|
||||
|
||||
import {
|
||||
import type {
|
||||
PluginInitializerContext,
|
||||
CoreSetup,
|
||||
CoreStart,
|
||||
Plugin,
|
||||
Logger,
|
||||
} from '../../../src/core/server';
|
||||
RequestHandlerContext,
|
||||
} from 'src/core/server';
|
||||
|
||||
import type { DataApiRequestHandlerContext } from 'src/plugins/data/server';
|
||||
|
||||
import {
|
||||
SearchExamplesPluginSetup,
|
||||
|
@ -42,12 +45,14 @@ export class SearchExamplesPlugin
|
|||
deps: SearchExamplesPluginSetupDeps
|
||||
) {
|
||||
this.logger.debug('search_examples: Setup');
|
||||
const router = core.http.createRouter();
|
||||
const router = core.http.createRouter<
|
||||
RequestHandlerContext & { search: DataApiRequestHandlerContext }
|
||||
>();
|
||||
|
||||
core.getStartServices().then(([_, depsStart]) => {
|
||||
const myStrategy = mySearchStrategyProvider(depsStart.data);
|
||||
deps.data.search.registerSearchStrategy('myStrategy', myStrategy);
|
||||
registerRoutes(router, depsStart.data);
|
||||
registerRoutes(router);
|
||||
});
|
||||
|
||||
return {};
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
* Public License, v 1.
|
||||
*/
|
||||
|
||||
import { IRouter } from 'kibana/server';
|
||||
import { PluginStart as DataPluginStart } from 'src/plugins/data/server';
|
||||
import type { IRouter, RequestHandlerContext } from 'kibana/server';
|
||||
import { DataApiRequestHandlerContext } from 'src/plugins/data/server';
|
||||
import { registerServerSearchRoute } from './server_search_route';
|
||||
|
||||
export function registerRoutes(router: IRouter, data: DataPluginStart) {
|
||||
registerServerSearchRoute(router, data);
|
||||
export function registerRoutes(
|
||||
router: IRouter<RequestHandlerContext & { search: DataApiRequestHandlerContext }>
|
||||
) {
|
||||
registerServerSearchRoute(router);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,16 @@
|
|||
* Public License, v 1.
|
||||
*/
|
||||
|
||||
import { PluginStart as DataPluginStart, IEsSearchRequest } from 'src/plugins/data/server';
|
||||
import { IEsSearchRequest } from 'src/plugins/data/server';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { IEsSearchResponse } from 'src/plugins/data/common';
|
||||
import { IRouter } from '../../../../src/core/server';
|
||||
import type { DataApiRequestHandlerContext } from 'src/plugins/data/server';
|
||||
import type { IRouter, RequestHandlerContext } from 'src/core/server';
|
||||
import { SERVER_SEARCH_ROUTE_PATH } from '../../common';
|
||||
|
||||
export function registerServerSearchRoute(router: IRouter, data: DataPluginStart) {
|
||||
export function registerServerSearchRoute(
|
||||
router: IRouter<RequestHandlerContext & { search: DataApiRequestHandlerContext }>
|
||||
) {
|
||||
router.get(
|
||||
{
|
||||
path: SERVER_SEARCH_ROUTE_PATH,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue