mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* remove exports of internal core types * updates documentation * rename internal types file
This commit is contained in:
parent
86f0c17d49
commit
45533f3809
19 changed files with 126 additions and 136 deletions
|
@ -9,5 +9,5 @@ returns `basePath` value, specific for an incoming request.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
get: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string;
|
||||
get: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest) => string;
|
||||
```
|
||||
|
|
|
@ -16,11 +16,11 @@ export declare class BasePath
|
|||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [get](./kibana-plugin-server.basepath.get.md) | | <code>(request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string</code> | returns <code>basePath</code> value, specific for an incoming request. |
|
||||
| [get](./kibana-plugin-server.basepath.get.md) | | <code>(request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest) => string</code> | returns <code>basePath</code> value, specific for an incoming request. |
|
||||
| [prepend](./kibana-plugin-server.basepath.prepend.md) | | <code>(path: string) => string</code> | Prepends <code>path</code> with the basePath. |
|
||||
| [remove](./kibana-plugin-server.basepath.remove.md) | | <code>(path: string) => string</code> | Removes the prepended basePath from the <code>path</code>. |
|
||||
| [serverBasePath](./kibana-plugin-server.basepath.serverbasepath.md) | | <code>string</code> | returns the server's basePath<!-- -->See [BasePath.get](./kibana-plugin-server.basepath.get.md) for getting the basePath value for a specific request |
|
||||
| [set](./kibana-plugin-server.basepath.set.md) | | <code>(request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void</code> | sets <code>basePath</code> value, specific for an incoming request. |
|
||||
| [set](./kibana-plugin-server.basepath.set.md) | | <code>(request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest, requestSpecificBasePath: string) => void</code> | sets <code>basePath</code> value, specific for an incoming request. |
|
||||
|
||||
## Remarks
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ sets `basePath` value, specific for an incoming request.
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
set: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void;
|
||||
set: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest, requestSpecificBasePath: string) => void;
|
||||
```
|
||||
|
|
|
@ -39,21 +39,11 @@
|
|||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
import {
|
||||
ElasticsearchServiceSetup,
|
||||
InternalElasticsearchServiceSetup,
|
||||
IScopedClusterClient,
|
||||
} from './elasticsearch';
|
||||
import { InternalHttpServiceSetup, HttpServiceSetup } from './http';
|
||||
import { ElasticsearchServiceSetup, IScopedClusterClient } from './elasticsearch';
|
||||
import { HttpServiceSetup } from './http';
|
||||
import { PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId } from './plugins';
|
||||
import { ContextSetup } from './context';
|
||||
import { SavedObjectsServiceStart } from './saved_objects';
|
||||
|
||||
import {
|
||||
InternalUiSettingsServiceSetup,
|
||||
IUiSettingsClient,
|
||||
UiSettingsServiceSetup,
|
||||
} from './ui_settings';
|
||||
import { IUiSettingsClient, UiSettingsServiceSetup } from './ui_settings';
|
||||
import { SavedObjectsClientContract } from './saved_objects/types';
|
||||
|
||||
export { bootstrap } from './bootstrap';
|
||||
|
@ -177,7 +167,6 @@ export {
|
|||
export {
|
||||
IUiSettingsClient,
|
||||
UiSettingsParams,
|
||||
InternalUiSettingsServiceSetup,
|
||||
UiSettingsType,
|
||||
UiSettingsServiceSetup,
|
||||
UserProvidedValues,
|
||||
|
@ -251,19 +240,4 @@ export interface CoreSetup {
|
|||
*/
|
||||
export interface CoreStart {} // eslint-disable-line @typescript-eslint/no-empty-interface
|
||||
|
||||
/** @internal */
|
||||
export interface InternalCoreSetup {
|
||||
context: ContextSetup;
|
||||
http: InternalHttpServiceSetup;
|
||||
elasticsearch: InternalElasticsearchServiceSetup;
|
||||
uiSettings: InternalUiSettingsServiceSetup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InternalCoreStart {
|
||||
savedObjects: SavedObjectsServiceStart;
|
||||
}
|
||||
|
||||
export { ContextSetup, PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId };
|
||||
|
|
39
src/core/server/internal_types.ts
Normal file
39
src/core/server/internal_types.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { InternalElasticsearchServiceSetup } from './elasticsearch';
|
||||
import { InternalHttpServiceSetup } from './http';
|
||||
import { InternalUiSettingsServiceSetup } from './ui_settings';
|
||||
import { ContextSetup } from './context';
|
||||
import { SavedObjectsServiceStart } from './saved_objects';
|
||||
|
||||
/** @internal */
|
||||
export interface InternalCoreSetup {
|
||||
context: ContextSetup;
|
||||
http: InternalHttpServiceSetup;
|
||||
elasticsearch: InternalElasticsearchServiceSetup;
|
||||
uiSettings: InternalUiSettingsServiceSetup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InternalCoreStart {
|
||||
savedObjects: SavedObjectsServiceStart;
|
||||
}
|
|
@ -20,7 +20,8 @@
|
|||
import { combineLatest, ConnectableObservable, EMPTY, Observable, Subscription } from 'rxjs';
|
||||
import { first, map, publishReplay, tap } from 'rxjs/operators';
|
||||
import { CoreService } from '../../types';
|
||||
import { InternalCoreSetup, InternalCoreStart, CoreSetup, CoreStart } from '../';
|
||||
import { CoreSetup, CoreStart } from '../';
|
||||
import { InternalCoreSetup, InternalCoreStart } from '../internal_types';
|
||||
import { SavedObjectsLegacyUiExports } from '../types';
|
||||
import { Config } from '../config';
|
||||
import { CoreContext } from '../core_context';
|
||||
|
|
|
@ -28,7 +28,7 @@ import { PluginWrapper } from './plugin';
|
|||
import { DiscoveredPlugin, DiscoveredPluginInternal, PluginName } from './types';
|
||||
import { PluginsConfig, PluginsConfigType } from './plugins_config';
|
||||
import { PluginsSystem } from './plugins_system';
|
||||
import { InternalCoreSetup } from '..';
|
||||
import { InternalCoreSetup } from '../internal_types';
|
||||
|
||||
/** @public */
|
||||
export interface PluginsServiceSetup {
|
||||
|
|
|
@ -449,11 +449,11 @@ export interface AuthToolkit {
|
|||
export class BasePath {
|
||||
// @internal
|
||||
constructor(serverBasePath?: string);
|
||||
get: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string;
|
||||
get: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest) => string;
|
||||
prepend: (path: string) => string;
|
||||
remove: (path: string) => string;
|
||||
readonly serverBasePath: string;
|
||||
set: (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void;
|
||||
set: (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest, requestSpecificBasePath: string) => void;
|
||||
}
|
||||
|
||||
// Warning: (ae-forgotten-export) The symbol "BootstrapArgs" needs to be exported by the entry point index.d.ts
|
||||
|
@ -712,36 +712,6 @@ export interface IndexSettingsDeprecationInfo {
|
|||
[indexName: string]: DeprecationInfo[];
|
||||
}
|
||||
|
||||
// @internal (undocumented)
|
||||
export interface InternalCoreSetup {
|
||||
// (undocumented)
|
||||
context: ContextSetup;
|
||||
// Warning: (ae-forgotten-export) The symbol "InternalElasticsearchServiceSetup" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
elasticsearch: InternalElasticsearchServiceSetup;
|
||||
// Warning: (ae-forgotten-export) The symbol "InternalHttpServiceSetup" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
http: InternalHttpServiceSetup;
|
||||
// (undocumented)
|
||||
uiSettings: InternalUiSettingsServiceSetup;
|
||||
}
|
||||
|
||||
// @internal (undocumented)
|
||||
export interface InternalCoreStart {
|
||||
// Warning: (ae-forgotten-export) The symbol "SavedObjectsServiceStart" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
savedObjects: SavedObjectsServiceStart;
|
||||
}
|
||||
|
||||
// @internal (undocumented)
|
||||
export interface InternalUiSettingsServiceSetup {
|
||||
asScopedToClient(savedObjectsClient: SavedObjectsClientContract): IUiSettingsClient;
|
||||
register(settings: Record<string, UiSettingsParams>): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface IRouter {
|
||||
delete: <P extends ObjectType, Q extends ObjectType, B extends ObjectType>(route: RouteConfig<P, Q, B>, handler: RequestHandler<P, Q, B>) => void;
|
||||
|
@ -839,7 +809,7 @@ export interface LegacyRequest extends Request {
|
|||
|
||||
// @public @deprecated (undocumented)
|
||||
export interface LegacyServiceSetupDeps {
|
||||
// Warning: (ae-incompatible-release-tags) The symbol "core" is marked as @public, but its signature references "InternalCoreSetup" which is marked as @internal
|
||||
// Warning: (ae-forgotten-export) The symbol "InternalCoreSetup" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
core: InternalCoreSetup & {
|
||||
|
@ -851,7 +821,7 @@ export interface LegacyServiceSetupDeps {
|
|||
|
||||
// @public @deprecated (undocumented)
|
||||
export interface LegacyServiceStartDeps {
|
||||
// Warning: (ae-incompatible-release-tags) The symbol "core" is marked as @public, but its signature references "InternalCoreStart" which is marked as @internal
|
||||
// Warning: (ae-forgotten-export) The symbol "InternalCoreStart" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
core: InternalCoreStart & {
|
||||
|
|
|
@ -39,7 +39,8 @@ import { config as uiSettingsConfig } from './ui_settings';
|
|||
import { mapToObject } from '../utils/';
|
||||
import { ContextService } from './context';
|
||||
import { SavedObjectsServiceSetup } from './saved_objects/saved_objects_service';
|
||||
import { RequestHandlerContext, InternalCoreSetup } from '.';
|
||||
import { RequestHandlerContext } from '.';
|
||||
import { InternalCoreSetup } from './internal_types';
|
||||
|
||||
const coreId = Symbol('core');
|
||||
|
||||
|
|
|
@ -7,13 +7,10 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { Server } from 'hapi';
|
||||
import { resolve } from 'path';
|
||||
import {
|
||||
InternalCoreSetup,
|
||||
PluginInitializerContext
|
||||
} from '../../../../src/core/server';
|
||||
import { PluginInitializerContext } from '../../../../src/core/server';
|
||||
import { LegacyPluginInitializer } from '../../../../src/legacy/types';
|
||||
import mappings from './mappings.json';
|
||||
import { plugin } from './server/new-platform/index';
|
||||
import { plugin } from './server/new-platform';
|
||||
|
||||
export const apm: LegacyPluginInitializer = kibana => {
|
||||
return new kibana.Plugin({
|
||||
|
@ -111,12 +108,13 @@ export const apm: LegacyPluginInitializer = kibana => {
|
|||
});
|
||||
|
||||
const initializerContext = {} as PluginInitializerContext;
|
||||
const core = {
|
||||
http: {
|
||||
server
|
||||
}
|
||||
} as InternalCoreSetup;
|
||||
plugin(initializerContext).setup(core);
|
||||
const legacySetup = {
|
||||
server
|
||||
};
|
||||
plugin(initializerContext).setup(
|
||||
server.newPlatform.setup.core,
|
||||
legacySetup
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,26 +4,26 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { InternalCoreSetup } from 'src/core/server';
|
||||
import { CoreSetup } from 'src/core/server';
|
||||
import { getSavedObjectsClient } from '../helpers/saved_objects_client';
|
||||
import { APM_TELEMETRY_DOC_ID, createApmTelementry } from './apm_telemetry';
|
||||
import { LegacySetup } from '../../new-platform/plugin';
|
||||
|
||||
export interface CoreSetupWithUsageCollector extends InternalCoreSetup {
|
||||
http: InternalCoreSetup['http'] & {
|
||||
server: {
|
||||
usage: {
|
||||
collectorSet: {
|
||||
makeUsageCollector: (options: unknown) => unknown;
|
||||
register: (options: unknown) => unknown;
|
||||
};
|
||||
export interface LegacySetupWithUsageCollector extends LegacySetup {
|
||||
server: LegacySetup['server'] & {
|
||||
usage: {
|
||||
collectorSet: {
|
||||
makeUsageCollector: (options: unknown) => unknown;
|
||||
register: (options: unknown) => unknown;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export function makeApmUsageCollector(core: CoreSetupWithUsageCollector) {
|
||||
const { server } = core.http;
|
||||
|
||||
export function makeApmUsageCollector(
|
||||
core: CoreSetup,
|
||||
{ server }: LegacySetupWithUsageCollector
|
||||
) {
|
||||
const apmUsageCollector = server.usage.collectorSet.makeUsageCollector({
|
||||
type: 'apm',
|
||||
fetch: async () => {
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { InternalCoreSetup } from 'src/core/server';
|
||||
import { CoreSetup } from 'src/core/server';
|
||||
import { CallCluster } from '../../../../../../../../src/legacy/core_plugins/elasticsearch';
|
||||
import { getApmIndices } from '../apm_indices/get_apm_indices';
|
||||
import { LegacySetup } from '../../../new-platform/plugin';
|
||||
|
||||
export async function createApmAgentConfigurationIndex(
|
||||
core: InternalCoreSetup
|
||||
core: CoreSetup,
|
||||
{ server }: LegacySetup
|
||||
) {
|
||||
try {
|
||||
const { server } = core.http;
|
||||
const indices = await getApmIndices(server);
|
||||
const index = indices['apm_oss.apmAgentConfigurationIndex'];
|
||||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster(
|
||||
|
|
|
@ -4,16 +4,21 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { InternalCoreSetup } from 'src/core/server';
|
||||
import { Server } from 'hapi';
|
||||
import { CoreSetup } from 'src/core/server';
|
||||
import { makeApmUsageCollector } from '../lib/apm_telemetry';
|
||||
import { CoreSetupWithUsageCollector } from '../lib/apm_telemetry/make_apm_usage_collector';
|
||||
import { LegacySetupWithUsageCollector } from '../lib/apm_telemetry/make_apm_usage_collector';
|
||||
import { createApmAgentConfigurationIndex } from '../lib/settings/agent_configuration/create_agent_config_index';
|
||||
import { createApmApi } from '../routes/create_apm_api';
|
||||
|
||||
export interface LegacySetup {
|
||||
server: Server;
|
||||
}
|
||||
|
||||
export class Plugin {
|
||||
public setup(core: InternalCoreSetup) {
|
||||
createApmApi().init(core);
|
||||
createApmAgentConfigurationIndex(core);
|
||||
makeApmUsageCollector(core as CoreSetupWithUsageCollector);
|
||||
public setup(core: CoreSetup, __LEGACY: LegacySetup) {
|
||||
createApmApi().init(core, __LEGACY);
|
||||
createApmAgentConfigurationIndex(core, __LEGACY);
|
||||
makeApmUsageCollector(core, __LEGACY as LegacySetupWithUsageCollector);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,23 +5,25 @@
|
|||
*/
|
||||
import * as t from 'io-ts';
|
||||
import { createApi } from './index';
|
||||
import { InternalCoreSetup } from 'src/core/server';
|
||||
import { CoreSetup } from 'src/core/server';
|
||||
import { Params } from '../typings';
|
||||
import { LegacySetup } from '../../new-platform/plugin';
|
||||
|
||||
const getCoreMock = () =>
|
||||
const getCoreMock = () => (({} as unknown) as CoreSetup);
|
||||
|
||||
const getLegacyMock = () =>
|
||||
(({
|
||||
http: {
|
||||
server: {
|
||||
route: jest.fn()
|
||||
}
|
||||
server: {
|
||||
route: jest.fn()
|
||||
}
|
||||
} as unknown) as InternalCoreSetup & {
|
||||
http: { server: { route: ReturnType<typeof jest.fn> } };
|
||||
} as unknown) as LegacySetup & {
|
||||
server: { route: ReturnType<typeof jest.fn> };
|
||||
});
|
||||
|
||||
describe('createApi', () => {
|
||||
it('registers a route with the server', () => {
|
||||
const coreMock = getCoreMock();
|
||||
const legacySetupMock = getLegacyMock();
|
||||
|
||||
createApi()
|
||||
.add(() => ({
|
||||
|
@ -36,11 +38,11 @@ describe('createApi', () => {
|
|||
},
|
||||
handler: async () => null
|
||||
}))
|
||||
.init(coreMock);
|
||||
.init(coreMock, legacySetupMock);
|
||||
|
||||
expect(coreMock.http.server.route).toHaveBeenCalledTimes(2);
|
||||
expect(legacySetupMock.server.route).toHaveBeenCalledTimes(2);
|
||||
|
||||
const firstRoute = coreMock.http.server.route.mock.calls[0][0];
|
||||
const firstRoute = legacySetupMock.server.route.mock.calls[0][0];
|
||||
|
||||
expect(firstRoute).toEqual({
|
||||
method: 'GET',
|
||||
|
@ -51,7 +53,7 @@ describe('createApi', () => {
|
|||
handler: expect.any(Function)
|
||||
});
|
||||
|
||||
const secondRoute = coreMock.http.server.route.mock.calls[1][0];
|
||||
const secondRoute = legacySetupMock.server.route.mock.calls[1][0];
|
||||
|
||||
expect(secondRoute).toEqual({
|
||||
method: 'POST',
|
||||
|
@ -66,6 +68,7 @@ describe('createApi', () => {
|
|||
describe('when validating', () => {
|
||||
const initApi = (params: Params) => {
|
||||
const core = getCoreMock();
|
||||
const legacySetupMock = getLegacyMock();
|
||||
const handler = jest.fn();
|
||||
createApi()
|
||||
.add(() => ({
|
||||
|
@ -73,9 +76,9 @@ describe('createApi', () => {
|
|||
params,
|
||||
handler
|
||||
}))
|
||||
.init(core);
|
||||
.init(core, legacySetupMock);
|
||||
|
||||
const route = core.http.server.route.mock.calls[0][0];
|
||||
const route = legacySetupMock.server.route.mock.calls[0][0];
|
||||
|
||||
const routeHandler = route.handler;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
import { merge, pick, omit, difference } from 'lodash';
|
||||
import Boom from 'boom';
|
||||
import { InternalCoreSetup } from 'src/core/server';
|
||||
import { CoreSetup } from 'src/core/server';
|
||||
import { Request, ResponseToolkit } from 'hapi';
|
||||
import * as t from 'io-ts';
|
||||
import { PathReporter } from 'io-ts/lib/PathReporter';
|
||||
|
@ -18,6 +18,7 @@ import {
|
|||
Params
|
||||
} from '../typings';
|
||||
import { jsonRt } from '../../../common/runtime_types/json_rt';
|
||||
import { LegacySetup } from '../../new-platform/plugin';
|
||||
|
||||
const debugRt = t.partial({ _debug: jsonRt.pipe(t.boolean) });
|
||||
|
||||
|
@ -29,10 +30,10 @@ export function createApi() {
|
|||
factoryFns.push(fn);
|
||||
return this as any;
|
||||
},
|
||||
init(core: InternalCoreSetup) {
|
||||
const { server } = core.http;
|
||||
init(core: CoreSetup, __LEGACY: LegacySetup) {
|
||||
const { server } = __LEGACY;
|
||||
factoryFns.forEach(fn => {
|
||||
const { params = {}, ...route } = fn(core) as Route<
|
||||
const { params = {}, ...route } = fn(core, __LEGACY) as Route<
|
||||
string,
|
||||
HttpMethod,
|
||||
Params,
|
||||
|
|
|
@ -9,15 +9,14 @@ import { createRoute } from './create_route';
|
|||
import { getKueryBarIndexPattern } from '../lib/index_pattern/getKueryBarIndexPattern';
|
||||
import { setupRequest } from '../lib/helpers/setup_request';
|
||||
|
||||
export const indexPatternRoute = createRoute(core => ({
|
||||
export const indexPatternRoute = createRoute((core, { server }) => ({
|
||||
path: '/api/apm/index_pattern',
|
||||
handler: async () => {
|
||||
const { server } = core.http;
|
||||
return await getAPMIndexPattern(server);
|
||||
}
|
||||
}));
|
||||
|
||||
export const kueryBarIndexPatternRoute = createRoute(core => ({
|
||||
export const kueryBarIndexPatternRoute = createRoute(() => ({
|
||||
path: '/api/apm/kuery_bar_index_pattern',
|
||||
params: {
|
||||
query: t.partial({
|
||||
|
@ -30,9 +29,7 @@ export const kueryBarIndexPatternRoute = createRoute(core => ({
|
|||
},
|
||||
handler: async (request, { query }) => {
|
||||
const { processorEvent } = query;
|
||||
|
||||
const setup = await setupRequest(request);
|
||||
|
||||
return getKueryBarIndexPattern({ request, processorEvent, setup });
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -16,7 +16,7 @@ import { createRoute } from './create_route';
|
|||
import { uiFiltersRt, rangeRt } from './default_api_types';
|
||||
import { getServiceMap } from '../lib/services/map';
|
||||
|
||||
export const servicesRoute = createRoute(core => ({
|
||||
export const servicesRoute = createRoute((core, { server }) => ({
|
||||
path: '/api/apm/services',
|
||||
params: {
|
||||
query: t.intersection([uiFiltersRt, rangeRt])
|
||||
|
@ -24,7 +24,6 @@ export const servicesRoute = createRoute(core => ({
|
|||
handler: async req => {
|
||||
const setup = await setupRequest(req);
|
||||
const services = await getServices(setup);
|
||||
const { server } = core.http;
|
||||
|
||||
// Store telemetry data derived from services
|
||||
const agentNames = services.items.map(
|
||||
|
|
|
@ -14,28 +14,26 @@ import {
|
|||
import { saveApmIndices } from '../../lib/settings/apm_indices/save_apm_indices';
|
||||
|
||||
// get list of apm indices and values
|
||||
export const apmIndexSettingsRoute = createRoute(core => ({
|
||||
export const apmIndexSettingsRoute = createRoute((core, { server }) => ({
|
||||
method: 'GET',
|
||||
path: '/api/apm/settings/apm-index-settings',
|
||||
handler: async req => {
|
||||
const { server } = core.http;
|
||||
const setup = await setupRequest(req);
|
||||
return await getApmIndexSettings({ setup, server });
|
||||
}
|
||||
}));
|
||||
|
||||
// get apm indices configuration object
|
||||
export const apmIndicesRoute = createRoute(core => ({
|
||||
export const apmIndicesRoute = createRoute((core, { server }) => ({
|
||||
method: 'GET',
|
||||
path: '/api/apm/settings/apm-indices',
|
||||
handler: async req => {
|
||||
const { server } = core.http;
|
||||
return await getApmIndices(server);
|
||||
}
|
||||
}));
|
||||
|
||||
// save ui indices
|
||||
export const saveApmIndicesRoute = createRoute(core => ({
|
||||
export const saveApmIndicesRoute = createRoute((core, { server }) => ({
|
||||
method: 'POST',
|
||||
path: '/api/apm/settings/apm-indices/save',
|
||||
params: {
|
||||
|
@ -50,7 +48,6 @@ export const saveApmIndicesRoute = createRoute(core => ({
|
|||
})
|
||||
},
|
||||
handler: async (req, { body }) => {
|
||||
const { server } = core.http;
|
||||
return await saveApmIndices(server, body);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
import t from 'io-ts';
|
||||
import { Request, ResponseToolkit } from 'hapi';
|
||||
import { InternalCoreSetup } from 'src/core/server';
|
||||
import { CoreSetup } from 'src/core/server';
|
||||
import { PickByValue, Optional } from 'utility-types';
|
||||
import { FetchOptions } from '../../public/services/rest/callApi';
|
||||
import { LegacySetup } from '../new-platform/plugin';
|
||||
|
||||
export interface Params {
|
||||
query?: t.HasProps;
|
||||
|
@ -45,7 +46,10 @@ export type RouteFactoryFn<
|
|||
TMethod extends HttpMethod | undefined,
|
||||
TParams extends Params,
|
||||
TReturn
|
||||
> = (core: InternalCoreSetup) => Route<TPath, TMethod, TParams, TReturn>;
|
||||
> = (
|
||||
core: CoreSetup,
|
||||
__LEGACY: LegacySetup
|
||||
) => Route<TPath, TMethod, TParams, TReturn>;
|
||||
|
||||
export interface RouteState {
|
||||
[key: string]: {
|
||||
|
@ -76,7 +80,7 @@ export interface ServerAPI<TRouteState extends RouteState> {
|
|||
};
|
||||
}
|
||||
>;
|
||||
init: (core: InternalCoreSetup) => void;
|
||||
init: (core: CoreSetup, __LEGACY: LegacySetup) => void;
|
||||
}
|
||||
|
||||
// without this, TS does not recognize possible existence of `params` in `options` below
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue