diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md b/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md
index cd99eabe1e1e5..f66cf883ebffb 100644
--- a/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md
+++ b/docs/development/core/server/kibana-plugin-server.coresetup.elasticsearch.md
@@ -7,9 +7,5 @@
Signature:
```typescript
-elasticsearch: {
- adminClient$: Observable;
- dataClient$: Observable;
- createClient: (type: string, clientConfig?: Partial) => ClusterClient;
- };
+elasticsearch: ElasticsearchServiceSetup;
```
diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.http.md b/docs/development/core/server/kibana-plugin-server.coresetup.http.md
index 1ab58b6c3d997..d55a1ecc532e5 100644
--- a/docs/development/core/server/kibana-plugin-server.coresetup.http.md
+++ b/docs/development/core/server/kibana-plugin-server.coresetup.http.md
@@ -7,12 +7,5 @@
Signature:
```typescript
-http: {
- registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];
- registerAuth: HttpServiceSetup['registerAuth'];
- registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
- basePath: HttpServiceSetup['basePath'];
- createNewServer: HttpServiceSetup['createNewServer'];
- isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
- };
+http: HttpServiceSetup;
```
diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.md b/docs/development/core/server/kibana-plugin-server.coresetup.md
index bc13bad563acb..028a28479c7a5 100644
--- a/docs/development/core/server/kibana-plugin-server.coresetup.md
+++ b/docs/development/core/server/kibana-plugin-server.coresetup.md
@@ -16,6 +16,6 @@ export interface CoreSetup
| Property | Type | Description |
| --- | --- | --- |
-| [elasticsearch](./kibana-plugin-server.coresetup.elasticsearch.md) | {
adminClient$: Observable<ClusterClient>;
dataClient$: Observable<ClusterClient>;
createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ClusterClient;
}
| |
-| [http](./kibana-plugin-server.coresetup.http.md) | {
registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];
registerAuth: HttpServiceSetup['registerAuth'];
registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
basePath: HttpServiceSetup['basePath'];
createNewServer: HttpServiceSetup['createNewServer'];
isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
}
| |
+| [elasticsearch](./kibana-plugin-server.coresetup.elasticsearch.md) | ElasticsearchServiceSetup
| |
+| [http](./kibana-plugin-server.coresetup.http.md) | HttpServiceSetup
| |
diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md
deleted file mode 100644
index 6040b407dd415..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.legacy.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) > [legacy](./kibana-plugin-server.elasticsearchservicesetup.legacy.md)
-
-## ElasticsearchServiceSetup.legacy property
-
-Signature:
-
-```typescript
-readonly legacy: {
- readonly config$: Observable;
- };
-```
diff --git a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md
index a295022971a14..33f023cd50ff5 100644
--- a/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md
+++ b/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.md
@@ -18,5 +18,4 @@ export interface ElasticsearchServiceSetup
| [adminClient$](./kibana-plugin-server.elasticsearchservicesetup.adminclient$.md) | Observable<ClusterClient>
| |
| [createClient](./kibana-plugin-server.elasticsearchservicesetup.createclient.md) | (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ClusterClient
| Create application specific Elasticsearch cluster API client with customized config. |
| [dataClient$](./kibana-plugin-server.elasticsearchservicesetup.dataclient$.md) | Observable<ClusterClient>
| |
-| [legacy](./kibana-plugin-server.elasticsearchservicesetup.legacy.md) | {
readonly config$: Observable<ElasticsearchConfig>;
}
| |
diff --git a/docs/development/core/server/kibana-plugin-server.internalcorestart.md b/docs/development/core/server/kibana-plugin-server.internalcorestart.md
deleted file mode 100644
index 3974ae0582891..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.internalcorestart.md
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [InternalCoreStart](./kibana-plugin-server.internalcorestart.md)
-
-## InternalCoreStart interface
-
-
-Signature:
-
-```typescript
-export interface InternalCoreStart
-```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [plugins](./kibana-plugin-server.internalcorestart.plugins.md) | PluginsServiceStart
| |
-
diff --git a/docs/development/core/server/kibana-plugin-server.legacycoresetup.elasticsearch.md b/docs/development/core/server/kibana-plugin-server.legacycoresetup.elasticsearch.md
new file mode 100644
index 0000000000000..f042e71ebeeb3
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.legacycoresetup.elasticsearch.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [LegacyCoreSetup](./kibana-plugin-server.legacycoresetup.md) > [elasticsearch](./kibana-plugin-server.legacycoresetup.elasticsearch.md)
+
+## LegacyCoreSetup.elasticsearch property
+
+Signature:
+
+```typescript
+elasticsearch: ElasticsearchServiceSetup & {
+ readonly legacy: {
+ readonly config$: Observable;
+ };
+ };
+```
diff --git a/docs/development/core/server/kibana-plugin-server.legacycoresetup.md b/docs/development/core/server/kibana-plugin-server.legacycoresetup.md
new file mode 100644
index 0000000000000..8b7439c527cb7
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.legacycoresetup.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [LegacyCoreSetup](./kibana-plugin-server.legacycoresetup.md)
+
+## LegacyCoreSetup interface
+
+
+Signature:
+
+```typescript
+export interface LegacyCoreSetup extends CoreSetup
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [elasticsearch](./kibana-plugin-server.legacycoresetup.elasticsearch.md) | ElasticsearchServiceSetup & {
readonly legacy: {
readonly config$: Observable<ElasticsearchConfig>;
};
}
| |
+| [plugins](./kibana-plugin-server.legacycoresetup.plugins.md) | PluginsServiceSetup
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.legacycoresetup.plugins.md b/docs/development/core/server/kibana-plugin-server.legacycoresetup.plugins.md
new file mode 100644
index 0000000000000..40e29e272fad2
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.legacycoresetup.plugins.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [LegacyCoreSetup](./kibana-plugin-server.legacycoresetup.md) > [plugins](./kibana-plugin-server.legacycoresetup.plugins.md)
+
+## LegacyCoreSetup.plugins property
+
+Signature:
+
+```typescript
+plugins: PluginsServiceSetup;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.legacycorestart.md b/docs/development/core/server/kibana-plugin-server.legacycorestart.md
new file mode 100644
index 0000000000000..4d7586db48b44
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.legacycorestart.md
@@ -0,0 +1,19 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [LegacyCoreStart](./kibana-plugin-server.legacycorestart.md)
+
+## LegacyCoreStart interface
+
+
+Signature:
+
+```typescript
+export interface LegacyCoreStart extends CoreStart
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [plugins](./kibana-plugin-server.legacycorestart.plugins.md) | PluginsServiceStart
| |
+
diff --git a/docs/development/core/server/kibana-plugin-server.internalcorestart.plugins.md b/docs/development/core/server/kibana-plugin-server.legacycorestart.plugins.md
similarity index 52%
rename from docs/development/core/server/kibana-plugin-server.internalcorestart.plugins.md
rename to docs/development/core/server/kibana-plugin-server.legacycorestart.plugins.md
index 1f6e17325e31d..885ccc2da0d62 100644
--- a/docs/development/core/server/kibana-plugin-server.internalcorestart.plugins.md
+++ b/docs/development/core/server/kibana-plugin-server.legacycorestart.plugins.md
@@ -1,8 +1,8 @@
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [InternalCoreStart](./kibana-plugin-server.internalcorestart.md) > [plugins](./kibana-plugin-server.internalcorestart.plugins.md)
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [LegacyCoreStart](./kibana-plugin-server.legacycorestart.md) > [plugins](./kibana-plugin-server.legacycorestart.plugins.md)
-## InternalCoreStart.plugins property
+## LegacyCoreStart.plugins property
Signature:
diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md
index ab79f2b382909..191819a3e4924 100644
--- a/docs/development/core/server/kibana-plugin-server.md
+++ b/docs/development/core/server/kibana-plugin-server.md
@@ -36,8 +36,9 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | |
| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
-| [InternalCoreStart](./kibana-plugin-server.internalcorestart.md) | |
| [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. |
+| [LegacyCoreSetup](./kibana-plugin-server.legacycoresetup.md) | |
+| [LegacyCoreStart](./kibana-plugin-server.legacycorestart.md) | |
| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of LoggerFactory
interface is to define a way to retrieve a context-based logger instance. |
| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
diff --git a/src/core/public/application/application_service.mock.ts b/src/core/public/application/application_service.mock.ts
index 872980154544f..e43b1086ca108 100644
--- a/src/core/public/application/application_service.mock.ts
+++ b/src/core/public/application/application_service.mock.ts
@@ -18,7 +18,12 @@
*/
import { capabilitiesServiceMock } from './capabilities/capabilities_service.mock';
-import { ApplicationService, ApplicationSetup, ApplicationStart } from './application_service';
+import {
+ ApplicationService,
+ ApplicationSetup,
+ ApplicationStart,
+ InternalApplicationStart,
+} from './application_service';
type ApplicationServiceContract = PublicMethodsOf;
@@ -28,18 +33,27 @@ const createSetupContractMock = (): jest.Mocked => ({
});
const createStartContractMock = (): jest.Mocked => ({
- mount: jest.fn(),
- ...capabilitiesServiceMock.createStartContract(),
+ capabilities: capabilitiesServiceMock.createStartContract().capabilities,
});
+const createInternalStartContractMock = (): DeeplyMockedKeys => {
+ const internalStartContract = {
+ availableApps: [],
+ forPlugin: jest.fn(),
+ };
+ internalStartContract.forPlugin.mockImplementation(createStartContractMock);
+ return internalStartContract;
+};
+
const createMock = (): jest.Mocked => ({
- setup: jest.fn().mockReturnValue(createSetupContractMock()),
- start: jest.fn().mockReturnValue(createStartContractMock()),
+ setup: jest.fn().mockResolvedValue(createSetupContractMock()),
+ start: jest.fn().mockReturnValue(createInternalStartContractMock()),
stop: jest.fn(),
});
export const applicationServiceMock = {
create: createMock,
createSetupContract: createSetupContractMock,
+ createInternalStartContract: createInternalStartContractMock,
createStartContract: createStartContractMock,
};
diff --git a/src/core/public/application/application_service.tsx b/src/core/public/application/application_service.tsx
index e7f18cf7bfcdd..631f5685d1e7c 100644
--- a/src/core/public/application/application_service.tsx
+++ b/src/core/public/application/application_service.tsx
@@ -20,6 +20,7 @@
import { Observable, BehaviorSubject } from 'rxjs';
import { CapabilitiesStart, CapabilitiesService, Capabilities } from './capabilities';
import { InjectedMetadataStart } from '../injected_metadata';
+import { CoreService } from '../../types';
interface BaseApp {
id: string;
@@ -99,11 +100,14 @@ export interface ApplicationSetup {
}
export interface ApplicationStart {
- mount: (mountHandler: Function) => void;
- availableApps: CapabilitiesStart['availableApps'];
capabilities: CapabilitiesStart['capabilities'];
}
+export interface InternalApplicationStart {
+ availableApps: CapabilitiesStart['availableApps'];
+ forPlugin(): ApplicationStart;
+}
+
interface StartDeps {
injectedMetadata: InjectedMetadataStart;
}
@@ -112,12 +116,12 @@ interface StartDeps {
* Service that is responsible for registering new applications.
* @internal
*/
-export class ApplicationService {
+export class ApplicationService implements CoreService {
private readonly apps$ = new BehaviorSubject([]);
private readonly legacyApps$ = new BehaviorSubject([]);
private readonly capabilities = new CapabilitiesService();
- public setup(): ApplicationSetup {
+ public setup() {
return {
registerApp: (app: App) => {
this.apps$.next([...this.apps$.value, app]);
@@ -128,7 +132,7 @@ export class ApplicationService {
};
}
- public async start({ injectedMetadata }: StartDeps): Promise {
+ public async start({ injectedMetadata }: StartDeps) {
this.apps$.complete();
this.legacyApps$.complete();
@@ -139,9 +143,8 @@ export class ApplicationService {
});
return {
- mount() {},
- capabilities,
availableApps,
+ forPlugin: () => ({ capabilities }),
};
}
diff --git a/src/core/public/application/capabilities/capabilities_service.mock.ts b/src/core/public/application/capabilities/capabilities_service.mock.ts
index b6f5323d1907d..339563efaedf4 100644
--- a/src/core/public/application/capabilities/capabilities_service.mock.ts
+++ b/src/core/public/application/capabilities/capabilities_service.mock.ts
@@ -33,7 +33,7 @@ const createStartContractMock = (
type CapabilitiesServiceContract = PublicMethodsOf;
const createMock = (): jest.Mocked => ({
- start: jest.fn().mockImplementation(({ apps }) => createStartContractMock(apps)),
+ start: jest.fn().mockImplementation(async ({ apps }) => createStartContractMock(apps)),
});
export const capabilitiesServiceMock = {
diff --git a/src/core/public/application/index.ts b/src/core/public/application/index.ts
index 137b46e6573e6..a56309df0c956 100644
--- a/src/core/public/application/index.ts
+++ b/src/core/public/application/index.ts
@@ -17,5 +17,10 @@
* under the License.
*/
-export { ApplicationService, ApplicationSetup, ApplicationStart } from './application_service';
+export {
+ ApplicationService,
+ ApplicationSetup,
+ ApplicationStart,
+ InternalApplicationStart,
+} from './application_service';
export { Capabilities } from './capabilities';
diff --git a/src/core/public/chrome/chrome_service.mock.ts b/src/core/public/chrome/chrome_service.mock.ts
index 35ac102c7a40c..24eb54891d355 100644
--- a/src/core/public/chrome/chrome_service.mock.ts
+++ b/src/core/public/chrome/chrome_service.mock.ts
@@ -23,11 +23,11 @@ import {
ChromeBreadcrumb,
ChromeService,
InternalChromeStart,
+ ChromeStart,
} from './chrome_service';
const createStartContractMock = () => {
- const startContract: jest.Mocked = {
- getComponent: jest.fn(),
+ const startContract: DeeplyMockedKeys = {
navLinks: {
getNavLinks$: jest.fn(),
has: jest.fn(),
@@ -76,17 +76,29 @@ const createStartContractMock = () => {
return startContract;
};
+const createInternalStartContractMock = (): DeeplyMockedKeys => {
+ const startContract = createStartContractMock();
+ const internalStartContract: DeeplyMockedKeys = {
+ getComponent: jest.fn(),
+ forPlugin: jest.fn(),
+ };
+ internalStartContract.forPlugin.mockReturnValue(startContract);
+ return internalStartContract;
+};
+
type ChromeServiceContract = PublicMethodsOf;
const createMock = () => {
const mocked: jest.Mocked = {
+ setup: jest.fn(),
start: jest.fn(),
stop: jest.fn(),
};
- mocked.start.mockResolvedValue(createStartContractMock());
+ mocked.start.mockResolvedValue(createInternalStartContractMock());
return mocked;
};
export const chromeServiceMock = {
create: createMock,
+ createInternalStartContract: createInternalStartContractMock,
createStartContract: createStartContractMock,
};
diff --git a/src/core/public/chrome/chrome_service.test.ts b/src/core/public/chrome/chrome_service.test.ts
index 392846f8433ba..23885b5849a04 100644
--- a/src/core/public/chrome/chrome_service.test.ts
+++ b/src/core/public/chrome/chrome_service.test.ts
@@ -38,7 +38,7 @@ const store = new Map();
function defaultStartDeps() {
return {
- application: applicationServiceMock.createStartContract(),
+ application: applicationServiceMock.createInternalStartContract(),
docLinks: docLinksServiceMock.createStartContract(),
http: httpServiceMock.createStartContract(),
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
@@ -94,7 +94,7 @@ Array [
describe('brand', () => {
it('updates/emits the brand as it changes', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getBrand$()
.pipe(toArray())
@@ -128,7 +128,7 @@ Array [
describe('visibility', () => {
it('updates/emits the visibility', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getIsVisible$()
.pipe(toArray())
@@ -153,7 +153,7 @@ Array [
window.history.pushState(undefined, '', '#/home?a=b&embed=true');
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getIsVisible$()
.pipe(toArray())
@@ -178,7 +178,7 @@ Array [
describe('is collapsed', () => {
it('updates/emits isCollapsed', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getIsCollapsed$()
.pipe(toArray())
@@ -201,7 +201,7 @@ Array [
it('only stores true in localStorage', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
start.setIsCollapsed(true);
expect(store.size).toBe(1);
@@ -214,7 +214,7 @@ Array [
describe('application classes', () => {
it('updates/emits the application classes', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getApplicationClasses$()
.pipe(toArray())
@@ -266,7 +266,7 @@ Array [
describe('badge', () => {
it('updates/emits the current badge', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getBadge$()
.pipe(toArray())
@@ -297,7 +297,7 @@ Array [
describe('breadcrumbs', () => {
it('updates/emits the current set of breadcrumbs', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getBreadcrumbs$()
.pipe(toArray())
@@ -339,7 +339,7 @@ Array [
describe('help extension', () => {
it('updates/emits the current help extension', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = start
.getHelpExtension$()
.pipe(toArray())
@@ -363,7 +363,7 @@ Array [
describe('stop', () => {
it('completes applicationClass$, isCollapsed$, breadcrumbs$, isVisible$, and brand$ observables', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
const promise = Rx.combineLatest(
start.getBrand$(),
start.getApplicationClasses$(),
@@ -379,7 +379,7 @@ describe('stop', () => {
it('completes immediately if service already stopped', async () => {
const service = new ChromeService({ browserSupportsCsp: true });
- const start = await service.start(defaultStartDeps());
+ const start = (await service.start(defaultStartDeps())).forPlugin();
service.stop();
await expect(
diff --git a/src/core/public/chrome/chrome_service.tsx b/src/core/public/chrome/chrome_service.tsx
index da57667efa4ff..f1d1673d38454 100644
--- a/src/core/public/chrome/chrome_service.tsx
+++ b/src/core/public/chrome/chrome_service.tsx
@@ -27,7 +27,7 @@ import { IconType } from '@elastic/eui';
import { InjectedMetadataStart } from '../injected_metadata';
import { NotificationsStart } from '../notifications';
-import { ApplicationStart } from '../application';
+import { InternalApplicationStart } from '../application';
import { HttpStart } from '../http';
import { ChromeNavLinks, NavLinksService } from './nav_links';
@@ -35,6 +35,7 @@ import { ChromeRecentlyAccessed, RecentlyAccessedService } from './recently_acce
import { NavControlsService, ChromeNavControls } from './nav_controls';
import { LoadingIndicator, Header } from './ui';
import { DocLinksStart } from '../doc_links';
+import { CoreService } from '../../types';
export { ChromeNavControls, ChromeRecentlyAccessed };
@@ -73,7 +74,7 @@ interface ConstructorParams {
}
interface StartDeps {
- application: ApplicationStart;
+ application: InternalApplicationStart;
docLinks: DocLinksStart;
http: HttpStart;
injectedMetadata: InjectedMetadataStart;
@@ -81,7 +82,7 @@ interface StartDeps {
}
/** @internal */
-export class ChromeService {
+export class ChromeService implements CoreService {
private readonly stop$ = new ReplaySubject(1);
private readonly browserSupportsCsp: boolean;
private readonly navControls = new NavControlsService();
@@ -92,13 +93,9 @@ export class ChromeService {
this.browserSupportsCsp = browserSupportsCsp;
}
- public async start({
- application,
- docLinks,
- http,
- injectedMetadata,
- notifications,
- }: StartDeps): Promise {
+ public setup() {}
+
+ public async start({ application, docLinks, http, injectedMetadata, notifications }: StartDeps) {
const FORCE_HIDDEN = isEmbedParamInHash();
const appTitle$ = new BehaviorSubject('Kibana');
@@ -123,10 +120,6 @@ export class ChromeService {
}
return {
- navControls,
- navLinks,
- recentlyAccessed,
-
getComponent: () => (
@@ -155,75 +148,81 @@ export class ChromeService {
),
- setAppTitle: (appTitle: string) => appTitle$.next(appTitle),
-
- getBrand$: () => brand$.pipe(takeUntil(this.stop$)),
-
- setBrand: (brand: ChromeBrand) => {
- brand$.next(
- Object.freeze({
- logo: brand.logo,
- smallLogo: brand.smallLogo,
- })
- );
- },
-
- getIsVisible$: () =>
- isVisible$.pipe(
- map(visibility => (FORCE_HIDDEN ? false : visibility)),
- takeUntil(this.stop$)
- ),
-
- setIsVisible: (visibility: boolean) => {
- isVisible$.next(visibility);
- },
-
- getIsCollapsed$: () => isCollapsed$.pipe(takeUntil(this.stop$)),
-
- setIsCollapsed: (isCollapsed: boolean) => {
- isCollapsed$.next(isCollapsed);
- if (isCollapsed) {
- localStorage.setItem(IS_COLLAPSED_KEY, 'true');
- } else {
- localStorage.removeItem(IS_COLLAPSED_KEY);
- }
- },
-
- getApplicationClasses$: () =>
- applicationClasses$.pipe(
- map(set => [...set]),
- takeUntil(this.stop$)
- ),
-
- addApplicationClass: (className: string) => {
- const update = new Set([...applicationClasses$.getValue()]);
- update.add(className);
- applicationClasses$.next(update);
- },
-
- removeApplicationClass: (className: string) => {
- const update = new Set([...applicationClasses$.getValue()]);
- update.delete(className);
- applicationClasses$.next(update);
- },
-
- getBadge$: () => badge$.pipe(takeUntil(this.stop$)),
-
- setBadge: (badge: ChromeBadge) => {
- badge$.next(badge);
- },
-
- getBreadcrumbs$: () => breadcrumbs$.pipe(takeUntil(this.stop$)),
-
- setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => {
- breadcrumbs$.next(newBreadcrumbs);
- },
-
- getHelpExtension$: () => helpExtension$.pipe(takeUntil(this.stop$)),
-
- setHelpExtension: (helpExtension?: ChromeHelpExtension) => {
- helpExtension$.next(helpExtension);
- },
+ forPlugin: () => ({
+ navControls,
+ navLinks,
+ recentlyAccessed,
+
+ setAppTitle: (appTitle: string) => appTitle$.next(appTitle),
+
+ getBrand$: () => brand$.pipe(takeUntil(this.stop$)),
+
+ setBrand: (brand: ChromeBrand) => {
+ brand$.next(
+ Object.freeze({
+ logo: brand.logo,
+ smallLogo: brand.smallLogo,
+ })
+ );
+ },
+
+ getIsVisible$: () =>
+ isVisible$.pipe(
+ map(visibility => (FORCE_HIDDEN ? false : visibility)),
+ takeUntil(this.stop$)
+ ),
+
+ setIsVisible: (visibility: boolean) => {
+ isVisible$.next(visibility);
+ },
+
+ getIsCollapsed$: () => isCollapsed$.pipe(takeUntil(this.stop$)),
+
+ setIsCollapsed: (isCollapsed: boolean) => {
+ isCollapsed$.next(isCollapsed);
+ if (isCollapsed) {
+ localStorage.setItem(IS_COLLAPSED_KEY, 'true');
+ } else {
+ localStorage.removeItem(IS_COLLAPSED_KEY);
+ }
+ },
+
+ getApplicationClasses$: () =>
+ applicationClasses$.pipe(
+ map(set => [...set]),
+ takeUntil(this.stop$)
+ ),
+
+ addApplicationClass: (className: string) => {
+ const update = new Set([...applicationClasses$.getValue()]);
+ update.add(className);
+ applicationClasses$.next(update);
+ },
+
+ removeApplicationClass: (className: string) => {
+ const update = new Set([...applicationClasses$.getValue()]);
+ update.delete(className);
+ applicationClasses$.next(update);
+ },
+
+ getBadge$: () => badge$.pipe(takeUntil(this.stop$)),
+
+ setBadge: (badge?: ChromeBadge) => {
+ badge$.next(badge);
+ },
+
+ getBreadcrumbs$: () => breadcrumbs$.pipe(takeUntil(this.stop$)),
+
+ setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => {
+ breadcrumbs$.next(newBreadcrumbs);
+ },
+
+ getHelpExtension$: () => helpExtension$.pipe(takeUntil(this.stop$)),
+
+ setHelpExtension: (helpExtension?: ChromeHelpExtension) => {
+ helpExtension$.next(helpExtension);
+ },
+ }),
};
}
@@ -370,10 +369,13 @@ export interface ChromeStart {
}
/** @internal */
-export interface InternalChromeStart extends ChromeStart {
+export interface InternalChromeStart {
/**
* Used only by MountingService to render the header UI
* @internal
*/
getComponent(): JSX.Element;
+
+ /** @internal */
+ forPlugin(): ChromeStart;
}
diff --git a/src/core/public/chrome/nav_links/nav_links_service.ts b/src/core/public/chrome/nav_links/nav_links_service.ts
index 8dd5525db29da..5b443222b98b6 100644
--- a/src/core/public/chrome/nav_links/nav_links_service.ts
+++ b/src/core/public/chrome/nav_links/nav_links_service.ts
@@ -21,11 +21,11 @@ import { sortBy } from 'lodash';
import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { NavLinkWrapper, ChromeNavLinkUpdateableFields, ChromeNavLink } from './nav_link';
-import { ApplicationStart } from '../../application';
+import { InternalApplicationStart } from '../../application';
import { HttpStart } from '../../http';
interface StartDeps {
- application: ApplicationStart;
+ application: InternalApplicationStart;
http: HttpStart;
}
diff --git a/src/core/public/core_system.ts b/src/core/public/core_system.ts
index f3f466df8a78e..80a960d1fa0dc 100644
--- a/src/core/public/core_system.ts
+++ b/src/core/public/core_system.ts
@@ -19,20 +19,24 @@
import './core.css';
-import { InternalCoreSetup, InternalCoreStart } from '.';
-import { ChromeService } from './chrome';
+import { LegacyCoreSetup, LegacyCoreStart } from '.';
+import { ChromeService, InternalChromeStart } from './chrome';
import { FatalErrorsService, FatalErrorsSetup } from './fatal_errors';
-import { HttpService } from './http';
-import { I18nService } from './i18n';
-import { InjectedMetadataParams, InjectedMetadataService } from './injected_metadata';
+import { HttpService, HttpStart } from './http';
+import { I18nService, I18nStart } from './i18n';
+import {
+ InjectedMetadataParams,
+ InjectedMetadataService,
+ InjectedMetadataStart,
+} from './injected_metadata';
import { LegacyPlatformParams, LegacyPlatformService } from './legacy';
-import { NotificationsService } from './notifications';
-import { OverlayService } from './overlays';
+import { NotificationsService, NotificationsStart } from './notifications';
+import { OverlayService, OverlayStart } from './overlays';
import { PluginsService } from './plugins';
-import { UiSettingsService } from './ui_settings';
-import { ApplicationService } from './application';
+import { UiSettingsService, UiSettingsClientContract } from './ui_settings';
+import { ApplicationService, InternalApplicationStart } from './application';
import { mapToObject } from '../utils/';
-import { DocLinksService } from './doc_links';
+import { DocLinksService, DocLinksStart } from './doc_links';
import { RenderingService } from './rendering';
interface Params {
@@ -47,6 +51,19 @@ interface Params {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface CoreContext {}
+/** @internal */
+export interface InternalCoreStart {
+ application: InternalApplicationStart;
+ chrome: InternalChromeStart;
+ docLinks: DocLinksStart;
+ http: HttpStart;
+ i18n: I18nStart;
+ injectedMetadata: InjectedMetadataStart;
+ notifications: NotificationsStart;
+ overlays: OverlayStart;
+ uiSettings: UiSettingsClientContract;
+}
+
/**
* The CoreSystem is the root of the new platform, and setups all parts
* of Kibana in the UI, including the LegacyPlatform which is managed
@@ -127,7 +144,7 @@ export class CoreSystem {
const notifications = this.notifications.setup({ uiSettings });
const application = this.application.setup();
- const core: InternalCoreSetup = {
+ const core: LegacyCoreSetup = {
application,
fatalErrors: this.fatalErrorsSetup,
http,
@@ -187,7 +204,7 @@ export class CoreSystem {
});
const uiSettings = await this.uiSettings.start();
- const core: InternalCoreStart = {
+ const internalCore: InternalCoreStart = {
application,
chrome,
docLinks,
@@ -199,13 +216,26 @@ export class CoreSystem {
uiSettings,
};
- const plugins = await this.plugins.start(core);
+ const plugins = await this.plugins.start(internalCore);
const rendering = this.rendering.start({
chrome,
targetDomElement: coreUiTargetDomElement,
});
+
+ const legacyCore: LegacyCoreStart = {
+ application: application.forPlugin(),
+ chrome: chrome.forPlugin(),
+ docLinks,
+ http,
+ i18n,
+ injectedMetadata,
+ notifications,
+ overlays,
+ uiSettings,
+ };
+
await this.legacyPlatform.start({
- core,
+ core: legacyCore,
plugins: mapToObject(plugins.contracts),
targetDomElement: rendering.legacyTargetDomElement,
});
diff --git a/src/core/public/index.ts b/src/core/public/index.ts
index 2a88ebf86ab0c..2f3140d3ec55b 100644
--- a/src/core/public/index.ts
+++ b/src/core/public/index.ts
@@ -101,7 +101,7 @@ export interface CoreSetup {
*/
export interface CoreStart {
/** {@link ApplicationStart} */
- application: Pick;
+ application: ApplicationStart;
/** {@link ChromeStart} */
chrome: ChromeStart;
/** {@link DocLinksStart} */
@@ -119,13 +119,13 @@ export interface CoreStart {
}
/** @internal */
-export interface InternalCoreSetup extends CoreSetup {
+export interface LegacyCoreSetup extends CoreSetup {
application: ApplicationSetup;
injectedMetadata: InjectedMetadataSetup;
}
/** @internal */
-export interface InternalCoreStart extends CoreStart {
+export interface LegacyCoreStart extends CoreStart {
application: ApplicationStart;
injectedMetadata: InjectedMetadataStart;
}
diff --git a/src/core/public/legacy/legacy_service.ts b/src/core/public/legacy/legacy_service.ts
index 7d852773ad03f..feeea13a0ff6c 100644
--- a/src/core/public/legacy/legacy_service.ts
+++ b/src/core/public/legacy/legacy_service.ts
@@ -18,7 +18,7 @@
*/
import angular from 'angular';
-import { InternalCoreSetup, InternalCoreStart } from '../';
+import { LegacyCoreSetup, LegacyCoreStart } from '../';
/** @internal */
export interface LegacyPlatformParams {
@@ -27,12 +27,12 @@ export interface LegacyPlatformParams {
}
interface SetupDeps {
- core: InternalCoreSetup;
+ core: LegacyCoreSetup;
plugins: Record;
}
interface StartDeps {
- core: InternalCoreStart;
+ core: LegacyCoreStart;
plugins: Record;
targetDomElement: HTMLElement;
}
diff --git a/src/core/public/plugins/plugin_context.ts b/src/core/public/plugins/plugin_context.ts
index 022c71492f383..493f955391299 100644
--- a/src/core/public/plugins/plugin_context.ts
+++ b/src/core/public/plugins/plugin_context.ts
@@ -17,8 +17,6 @@
* under the License.
*/
-import { omit } from 'lodash';
-
import { DiscoveredPlugin, PluginName } from '../../server';
import { CoreContext } from '../core_system';
import { PluginWrapper } from './plugin';
@@ -97,12 +95,10 @@ export function createPluginStartContext<
plugin: PluginWrapper
): CoreStart {
return {
- application: {
- capabilities: deps.application.capabilities,
- },
+ application: deps.application.forPlugin(),
+ chrome: deps.chrome.forPlugin(),
docLinks: deps.docLinks,
http: deps.http,
- chrome: omit(deps.chrome, 'getComponent'),
i18n: deps.i18n,
notifications: deps.notifications,
overlays: deps.overlays,
diff --git a/src/core/public/plugins/plugins_service.test.ts b/src/core/public/plugins/plugins_service.test.ts
index 55e91bde27cb0..70ff9ff1e851b 100644
--- a/src/core/public/plugins/plugins_service.test.ts
+++ b/src/core/public/plugins/plugins_service.test.ts
@@ -50,13 +50,11 @@ mockPluginInitializerProvider.mockImplementation(
pluginName => mockPluginInitializers.get(pluginName)!
);
-type DeeplyMocked = { [P in keyof T]: jest.Mocked };
-
const mockCoreContext: CoreContext = {};
-let mockSetupDeps: DeeplyMocked;
-let mockSetupContext: DeeplyMocked;
-let mockStartDeps: DeeplyMocked;
-let mockStartContext: DeeplyMocked;
+let mockSetupDeps: DeeplyMockedKeys;
+let mockSetupContext: DeeplyMockedKeys;
+let mockStartDeps: DeeplyMockedKeys;
+let mockStartContext: DeeplyMockedKeys;
beforeEach(() => {
mockSetupDeps = {
@@ -80,10 +78,10 @@ beforeEach(() => {
};
mockSetupContext = omit(mockSetupDeps, 'application', 'injectedMetadata');
mockStartDeps = {
- application: applicationServiceMock.createStartContract(),
+ application: applicationServiceMock.createInternalStartContract(),
docLinks: docLinksServiceMock.createStartContract(),
http: httpServiceMock.createStartContract(),
- chrome: chromeServiceMock.createStartContract(),
+ chrome: chromeServiceMock.createInternalStartContract(),
i18n: i18nServiceMock.createStartContract(),
injectedMetadata: injectedMetadataServiceMock.createStartContract(),
notifications: notificationServiceMock.createStartContract(),
@@ -92,10 +90,8 @@ beforeEach(() => {
};
mockStartContext = {
...omit(mockStartDeps, 'injectedMetadata'),
- application: {
- capabilities: mockStartDeps.application.capabilities,
- },
- chrome: omit(mockStartDeps.chrome, 'getComponent'),
+ application: mockStartDeps.application.forPlugin(),
+ chrome: mockStartDeps.chrome.forPlugin() as DeeplyMockedKeys,
};
// Reset these for each test.
diff --git a/src/core/public/plugins/plugins_service.ts b/src/core/public/plugins/plugins_service.ts
index 03725a9d7f883..6c006c860883c 100644
--- a/src/core/public/plugins/plugins_service.ts
+++ b/src/core/public/plugins/plugins_service.ts
@@ -19,17 +19,17 @@
import { PluginName } from '../../server';
import { CoreService } from '../../types';
-import { CoreContext } from '../core_system';
+import { CoreContext, InternalCoreStart } from '../core_system';
import { PluginWrapper } from './plugin';
import {
createPluginInitializerContext,
createPluginSetupContext,
createPluginStartContext,
} from './plugin_context';
-import { InternalCoreSetup, InternalCoreStart } from '..';
+import { LegacyCoreSetup } from '..';
/** @internal */
-export type PluginsServiceSetupDeps = InternalCoreSetup;
+export type PluginsServiceSetupDeps = LegacyCoreSetup;
/** @internal */
export type PluginsServiceStartDeps = InternalCoreStart;
diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md
index 55f2a25210321..452c9881ba66e 100644
--- a/src/core/public/public.api.md
+++ b/src/core/public/public.api.md
@@ -27,11 +27,7 @@ export interface ApplicationStart {
// Warning: (ae-forgotten-export) The symbol "CapabilitiesStart" needs to be exported by the entry point index.d.ts
//
// (undocumented)
- availableApps: CapabilitiesStart['availableApps'];
- // (undocumented)
capabilities: CapabilitiesStart['capabilities'];
- // (undocumented)
- mount: (mountHandler: Function) => void;
}
// @public
@@ -185,7 +181,7 @@ export interface CoreSetup {
// @public
export interface CoreStart {
// (undocumented)
- application: Pick;
+ application: ApplicationStart;
// (undocumented)
chrome: ChromeStart;
// (undocumented)
@@ -401,7 +397,7 @@ export interface I18nStart {
}
// @internal (undocumented)
-export interface InternalCoreSetup extends CoreSetup {
+export interface LegacyCoreSetup extends CoreSetup {
// (undocumented)
application: ApplicationSetup;
// Warning: (ae-forgotten-export) The symbol "InjectedMetadataSetup" needs to be exported by the entry point index.d.ts
@@ -411,7 +407,7 @@ export interface InternalCoreSetup extends CoreSetup {
}
// @internal (undocumented)
-export interface InternalCoreStart extends CoreStart {
+export interface LegacyCoreStart extends CoreStart {
// (undocumented)
application: ApplicationStart;
// Warning: (ae-forgotten-export) The symbol "InjectedMetadataStart" needs to be exported by the entry point index.d.ts
diff --git a/src/core/public/rendering/rendering_service.test.tsx b/src/core/public/rendering/rendering_service.test.tsx
index 5b4ab93996657..ae2efc2bfc6ec 100644
--- a/src/core/public/rendering/rendering_service.test.tsx
+++ b/src/core/public/rendering/rendering_service.test.tsx
@@ -25,7 +25,7 @@ import { RenderingService } from './rendering_service';
describe('RenderingService#start', () => {
const getService = () => {
const rendering = new RenderingService();
- const chrome = chromeServiceMock.createStartContract();
+ const chrome = chromeServiceMock.createInternalStartContract();
chrome.getComponent.mockReturnValue(Hello chrome!
);
const targetDomElement = document.createElement('div');
const start = rendering.start({ chrome, targetDomElement });
diff --git a/src/core/server/elasticsearch/elasticsearch_service.mock.ts b/src/core/server/elasticsearch/elasticsearch_service.mock.ts
index dd35a4c3f5489..650b937f74f6a 100644
--- a/src/core/server/elasticsearch/elasticsearch_service.mock.ts
+++ b/src/core/server/elasticsearch/elasticsearch_service.mock.ts
@@ -21,7 +21,11 @@ import { BehaviorSubject } from 'rxjs';
import { ClusterClient } from './cluster_client';
import { ScopedClusterClient } from './scoped_cluster_client';
import { ElasticsearchConfig } from './elasticsearch_config';
-import { ElasticsearchService, ElasticsearchServiceSetup } from './elasticsearch_service';
+import {
+ ElasticsearchService,
+ ElasticsearchServiceSetup,
+ InternalElasticsearchServiceSetup,
+} from './elasticsearch_service';
const createScopedClusterClientMock = (): jest.Mocked> => ({
callAsInternalUser: jest.fn(),
@@ -36,10 +40,6 @@ const createClusterClientMock = (): jest.Mocked>
const createSetupContractMock = () => {
const setupContract: jest.Mocked = {
- legacy: {
- config$: new BehaviorSubject({} as ElasticsearchConfig),
- },
-
createClient: jest.fn().mockImplementation(createClusterClientMock),
adminClient$: new BehaviorSubject((createClusterClientMock() as unknown) as ClusterClient),
dataClient$: new BehaviorSubject((createClusterClientMock() as unknown) as ClusterClient),
@@ -47,6 +47,18 @@ const createSetupContractMock = () => {
return setupContract;
};
+const createInternalSetupContractMock = () => {
+ const internalSetupContract: jest.Mocked = {
+ legacy: {
+ config$: new BehaviorSubject({} as ElasticsearchConfig),
+ },
+
+ forPlugin: jest.fn(),
+ };
+ internalSetupContract.forPlugin.mockImplementation(createSetupContractMock);
+ return internalSetupContract;
+};
+
type ElasticsearchServiceContract = PublicMethodsOf;
const createMock = () => {
const mocked: jest.Mocked = {
@@ -54,7 +66,7 @@ const createMock = () => {
start: jest.fn(),
stop: jest.fn(),
};
- mocked.setup.mockResolvedValue(createSetupContractMock());
+ mocked.setup.mockResolvedValue(createInternalSetupContractMock());
mocked.stop.mockResolvedValue();
return mocked;
};
@@ -62,6 +74,7 @@ const createMock = () => {
export const elasticsearchServiceMock = {
create: createMock,
createSetupContract: createSetupContractMock,
+ createInternalSetupContract: createInternalSetupContractMock,
createClusterClient: createClusterClientMock,
createScopedClusterClient: createScopedClusterClientMock,
};
diff --git a/src/core/server/elasticsearch/elasticsearch_service.test.ts b/src/core/server/elasticsearch/elasticsearch_service.test.ts
index e84ddb2baa30c..0340f2255ae38 100644
--- a/src/core/server/elasticsearch/elasticsearch_service.test.ts
+++ b/src/core/server/elasticsearch/elasticsearch_service.test.ts
@@ -45,7 +45,7 @@ configService.atPath.mockReturnValue(
ssl: {
verificationMode: 'none',
},
- } as any)
+ })
);
let env: Env;
@@ -76,10 +76,11 @@ describe('#setup', () => {
() => mockAdminClusterClientInstance
).mockImplementationOnce(() => mockDataClusterClientInstance);
- const setupContract = await elasticsearchService.setup(deps);
+ const internalSetupContract = await elasticsearchService.setup(deps);
+ const setupContract = internalSetupContract.forPlugin();
const [esConfig, adminClient, dataClient] = await combineLatest(
- setupContract.legacy.config$,
+ internalSetupContract.legacy.config$,
setupContract.adminClient$,
setupContract.dataClient$
)
@@ -109,7 +110,7 @@ describe('#setup', () => {
describe('#createClient', () => {
it('allows to specify config properties', async () => {
- const setupContract = await elasticsearchService.setup(deps);
+ const setupContract = (await elasticsearchService.setup(deps)).forPlugin();
const mockClusterClientInstance = { close: jest.fn() };
MockClusterClient.mockImplementation(() => mockClusterClientInstance);
@@ -127,7 +128,7 @@ describe('#setup', () => {
});
it('falls back to elasticsearch default config values if property not specified', async () => {
- const setupContract = await elasticsearchService.setup(deps);
+ const setupContract = (await elasticsearchService.setup(deps)).forPlugin();
// reset all mocks called during setup phase
MockClusterClient.mockClear();
@@ -157,7 +158,7 @@ Object {
`);
});
it('falls back to elasticsearch config if custom config not passed', async () => {
- const setupContract = await elasticsearchService.setup(deps);
+ const setupContract = (await elasticsearchService.setup(deps)).forPlugin();
// reset all mocks called during setup phase
MockClusterClient.mockClear();
diff --git a/src/core/server/elasticsearch/elasticsearch_service.ts b/src/core/server/elasticsearch/elasticsearch_service.ts
index 38a0d19b1ae3f..9f7d47badc13c 100644
--- a/src/core/server/elasticsearch/elasticsearch_service.ts
+++ b/src/core/server/elasticsearch/elasticsearch_service.ts
@@ -39,12 +39,18 @@ interface SetupDeps {
http: HttpServiceSetup;
}
-/** @public */
-export interface ElasticsearchServiceSetup {
+/** @internal */
+export interface InternalElasticsearchServiceSetup {
// Required for the BWC with the legacy Kibana only.
readonly legacy: {
readonly config$: Observable;
};
+
+ forPlugin(): ElasticsearchServiceSetup;
+}
+
+/** @public */
+export interface ElasticsearchServiceSetup {
/**
* Create application specific Elasticsearch cluster API client with customized config.
*
@@ -71,7 +77,7 @@ export interface ElasticsearchServiceSetup {
}
/** @internal */
-export class ElasticsearchService implements CoreService {
+export class ElasticsearchService implements CoreService {
private readonly log: Logger;
private readonly config$: Observable;
private subscription?: Subscription;
@@ -83,7 +89,7 @@ export class ElasticsearchService implements CoreService new ElasticsearchConfig(rawConfig)));
}
- public async setup(deps: SetupDeps): Promise {
+ public async setup(deps: SetupDeps) {
this.log.debug('Setting up elasticsearch service');
const clients$ = this.config$.pipe(
@@ -126,13 +132,15 @@ export class ElasticsearchService implements CoreService clients.config)) },
- adminClient$: clients$.pipe(map(clients => clients.adminClient)),
- dataClient$: clients$.pipe(map(clients => clients.dataClient)),
+ forPlugin: () => ({
+ adminClient$: clients$.pipe(map(clients => clients.adminClient)),
+ dataClient$: clients$.pipe(map(clients => clients.dataClient)),
- createClient: (type: string, clientConfig: Partial = {}) => {
- const finalConfig = merge({}, config, clientConfig);
- return this.createClusterClient(type, finalConfig, deps.http.auth.getAuthHeaders);
- },
+ createClient: (type: string, clientConfig: Partial = {}) => {
+ const finalConfig = merge({}, config, clientConfig);
+ return this.createClusterClient(type, finalConfig, deps.http.auth.getAuthHeaders);
+ },
+ }),
};
}
diff --git a/src/core/server/elasticsearch/index.ts b/src/core/server/elasticsearch/index.ts
index 1d439dfba49e9..eb4b6dc32648b 100644
--- a/src/core/server/elasticsearch/index.ts
+++ b/src/core/server/elasticsearch/index.ts
@@ -17,9 +17,13 @@
* under the License.
*/
-export { ElasticsearchServiceSetup, ElasticsearchService } from './elasticsearch_service';
+export {
+ ElasticsearchServiceSetup,
+ ElasticsearchService,
+ InternalElasticsearchServiceSetup,
+} from './elasticsearch_service';
export { CallAPIOptions, ClusterClient, FakeRequest, LegacyRequest } from './cluster_client';
export { ScopedClusterClient, Headers, APICaller } from './scoped_cluster_client';
export { ElasticsearchClientConfig } from './elasticsearch_client_config';
-export { config } from './elasticsearch_config';
+export { config, ElasticsearchConfig } from './elasticsearch_config';
export { ElasticsearchError, ElasticsearchErrorHelpers } from './errors';
diff --git a/src/core/server/http/http_service.ts b/src/core/server/http/http_service.ts
index b06c690cf2621..0000d6a7fe2d0 100644
--- a/src/core/server/http/http_service.ts
+++ b/src/core/server/http/http_service.ts
@@ -33,6 +33,7 @@ import { HttpsRedirectServer } from './https_redirect_server';
export interface HttpServiceSetup extends HttpServerSetup {
createNewServer: (cfg: Partial) => Promise;
}
+
/** @public */
export interface HttpServiceStart {
/** Indicates if http server is listening on a given port */
diff --git a/src/core/server/index.ts b/src/core/server/index.ts
index 787478d5b3c3f..20d4c81058c24 100644
--- a/src/core/server/index.ts
+++ b/src/core/server/index.ts
@@ -36,11 +36,7 @@
*/
import { Observable } from 'rxjs';
-import {
- ClusterClient,
- ElasticsearchClientConfig,
- ElasticsearchServiceSetup,
-} from './elasticsearch';
+import { ElasticsearchServiceSetup, ElasticsearchConfig } from './elasticsearch';
import { HttpServiceSetup, HttpServiceStart } from './http';
import { PluginsServiceSetup, PluginsServiceStart } from './plugins';
@@ -116,22 +112,8 @@ export { RecursiveReadonly } from '../utils';
* @public
*/
export interface CoreSetup {
- elasticsearch: {
- adminClient$: Observable;
- dataClient$: Observable;
- createClient: (
- type: string,
- clientConfig?: Partial
- ) => ClusterClient;
- };
- http: {
- registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];
- registerAuth: HttpServiceSetup['registerAuth'];
- registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
- basePath: HttpServiceSetup['basePath'];
- createNewServer: HttpServiceSetup['createNewServer'];
- isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
- };
+ elasticsearch: ElasticsearchServiceSetup;
+ http: HttpServiceSetup;
}
/**
@@ -141,17 +123,18 @@ export interface CoreSetup {
*/
export interface CoreStart {} // eslint-disable-line @typescript-eslint/no-empty-interface
-/** @internal */
-export interface InternalCoreSetup {
- http: HttpServiceSetup;
- elasticsearch: ElasticsearchServiceSetup;
+/** @public */
+export interface LegacyCoreSetup extends CoreSetup {
+ elasticsearch: ElasticsearchServiceSetup & {
+ readonly legacy: {
+ readonly config$: Observable;
+ };
+ };
plugins: PluginsServiceSetup;
}
-/**
- * @public
- */
-export interface InternalCoreStart {
+/** @public */
+export interface LegacyCoreStart extends CoreStart {
plugins: PluginsServiceStart;
}
diff --git a/src/core/server/legacy/legacy_service.test.ts b/src/core/server/legacy/legacy_service.test.ts
index fa4d60520818e..89de9d4ed9d87 100644
--- a/src/core/server/legacy/legacy_service.test.ts
+++ b/src/core/server/legacy/legacy_service.test.ts
@@ -29,30 +29,22 @@ import KbnServer from '../../../legacy/server/kbn_server';
import { Config, Env, ObjectToConfigAdapter } from '../config';
import { getEnvOptions } from '../config/__mocks__/env';
import { configServiceMock } from '../config/config_service.mock';
-import { ElasticsearchServiceSetup } from '../elasticsearch';
-import { HttpServiceStart, BasePathProxyServer } from '../http';
+import { BasePathProxyServer } from '../http';
import { loggingServiceMock } from '../logging/logging_service.mock';
import { DiscoveredPlugin, DiscoveredPluginInternal } from '../plugins';
-import { PluginsServiceSetup, PluginsServiceStart } from '../plugins/plugins_service';
+import { LegacyCoreSetup, LegacyCoreStart } from '..';
const MockKbnServer: jest.Mock = KbnServer as any;
let env: Env;
let config$: BehaviorSubject;
let setupDeps: {
- core: {
- elasticsearch: ElasticsearchServiceSetup;
- http: any;
- plugins: PluginsServiceSetup;
- };
+ core: LegacyCoreSetup;
plugins: Record;
};
let startDeps: {
- core: {
- http: HttpServiceStart;
- plugins: PluginsServiceStart;
- };
+ core: LegacyCoreStart;
plugins: Record;
};
@@ -72,7 +64,7 @@ beforeEach(() => {
auth: {
getAuthHeaders: () => undefined,
},
- },
+ } as any,
plugins: {
contracts: new Map([['plugin-id', 'plugin-value']]),
uiPlugins: {
@@ -86,9 +78,6 @@ beforeEach(() => {
startDeps = {
core: {
- http: {
- isListening: () => true,
- },
plugins: { contracts: new Map() },
},
plugins: {},
diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts
index a50f049db2231..7f637fff294b8 100644
--- a/src/core/server/legacy/legacy_service.ts
+++ b/src/core/server/legacy/legacy_service.ts
@@ -20,7 +20,7 @@
import { combineLatest, ConnectableObservable, EMPTY, Observable, Subscription } from 'rxjs';
import { first, map, mergeMap, publishReplay, tap } from 'rxjs/operators';
import { CoreService } from '../../types';
-import { InternalCoreSetup, InternalCoreStart } from '../../server';
+import { LegacyCoreSetup, LegacyCoreStart } from '../../server';
import { Config } from '../config';
import { CoreContext } from '../core_context';
import { DevConfig, DevConfigType } from '../dev';
@@ -47,12 +47,12 @@ function getLegacyRawConfig(config: Config) {
}
interface SetupDeps {
- core: InternalCoreSetup;
+ core: LegacyCoreSetup;
plugins: Record;
}
interface StartDeps {
- core: InternalCoreStart;
+ core: LegacyCoreStart;
plugins: Record;
}
diff --git a/src/core/server/plugins/plugin.test.ts b/src/core/server/plugins/plugin.test.ts
index 0ce4ba2666198..9b1c96849e9fe 100644
--- a/src/core/server/plugins/plugin.test.ts
+++ b/src/core/server/plugins/plugin.test.ts
@@ -31,6 +31,7 @@ import { loggingServiceMock } from '../logging/logging_service.mock';
import { PluginWrapper, PluginManifest } from './plugin';
import { createPluginInitializerContext, createPluginSetupContext } from './plugin_context';
+import { PluginsServiceSetupDeps } from './plugins_service';
const mockPluginInitializer = jest.fn();
const logger = loggingServiceMock.create();
@@ -65,8 +66,8 @@ configService.atPath.mockReturnValue(new BehaviorSubject({ initialize: true }));
let env: Env;
let coreContext: CoreContext;
-const setupDeps = {
- elasticsearch: elasticsearchServiceMock.createSetupContract(),
+const setupDeps: PluginsServiceSetupDeps = {
+ elasticsearch: elasticsearchServiceMock.createInternalSetupContract(),
http: httpServiceMock.createSetupContract(),
};
beforeEach(() => {
diff --git a/src/core/server/plugins/plugin_context.ts b/src/core/server/plugins/plugin_context.ts
index 88039238af09f..a55eb44d279eb 100644
--- a/src/core/server/plugins/plugin_context.ts
+++ b/src/core/server/plugins/plugin_context.ts
@@ -112,19 +112,8 @@ export function createPluginSetupContext(
plugin: PluginWrapper
): CoreSetup {
return {
- elasticsearch: {
- adminClient$: deps.elasticsearch.adminClient$,
- dataClient$: deps.elasticsearch.dataClient$,
- createClient: deps.elasticsearch.createClient,
- },
- http: {
- registerOnPreAuth: deps.http.registerOnPreAuth,
- registerAuth: deps.http.registerAuth,
- registerOnPostAuth: deps.http.registerOnPostAuth,
- basePath: deps.http.basePath,
- createNewServer: deps.http.createNewServer,
- isTlsEnabled: deps.http.isTlsEnabled,
- },
+ elasticsearch: deps.elasticsearch.forPlugin(),
+ http: deps.http,
};
}
diff --git a/src/core/server/plugins/plugins_service.test.ts b/src/core/server/plugins/plugins_service.test.ts
index fbb37f40362b4..719c81fa7ccfe 100644
--- a/src/core/server/plugins/plugins_service.test.ts
+++ b/src/core/server/plugins/plugins_service.test.ts
@@ -30,7 +30,7 @@ import { httpServiceMock } from '../http/http_service.mock';
import { loggingServiceMock } from '../logging/logging_service.mock';
import { PluginDiscoveryError } from './discovery';
import { PluginWrapper } from './plugin';
-import { PluginsService } from './plugins_service';
+import { PluginsService, PluginsServiceSetupDeps } from './plugins_service';
import { PluginsSystem } from './plugins_system';
import { config } from './plugins_config';
@@ -40,8 +40,8 @@ let pluginsService: PluginsService;
let configService: ConfigService;
let env: Env;
let mockPluginSystem: jest.Mocked;
-const setupDeps = {
- elasticsearch: elasticsearchServiceMock.createSetupContract(),
+const setupDeps: PluginsServiceSetupDeps = {
+ elasticsearch: elasticsearchServiceMock.createInternalSetupContract(),
http: httpServiceMock.createSetupContract(),
};
const logger = loggingServiceMock.create();
diff --git a/src/core/server/plugins/plugins_service.ts b/src/core/server/plugins/plugins_service.ts
index 95d3f26fff91e..06b7869498f9d 100644
--- a/src/core/server/plugins/plugins_service.ts
+++ b/src/core/server/plugins/plugins_service.ts
@@ -21,13 +21,12 @@ import { Observable } from 'rxjs';
import { filter, first, map, mergeMap, tap, toArray } from 'rxjs/operators';
import { CoreService } from '../../types';
import { CoreContext } from '../core_context';
-import { ElasticsearchServiceSetup } from '../elasticsearch/elasticsearch_service';
-import { HttpServiceSetup } from '../http/http_service';
import { Logger } from '../logging';
import { discover, PluginDiscoveryError, PluginDiscoveryErrorType } from './discovery';
import { DiscoveredPlugin, DiscoveredPluginInternal, PluginWrapper, PluginName } from './plugin';
import { PluginsConfig, PluginsConfigType } from './plugins_config';
import { PluginsSystem } from './plugins_system';
+import { InternalCoreSetup, InternalCoreStart } from '../server';
/** @public */
export interface PluginsServiceSetup {
@@ -44,13 +43,16 @@ export interface PluginsServiceStart {
}
/** @internal */
-export interface PluginsServiceSetupDeps {
- elasticsearch: ElasticsearchServiceSetup;
- http: HttpServiceSetup;
-}
+export type PluginsServiceSetupDeps = Pick<
+ InternalCoreSetup,
+ Exclude
+>;
/** @internal */
-export interface PluginsServiceStartDeps {} // eslint-disable-line @typescript-eslint/no-empty-interface
+export type PluginsServiceStartDeps = Pick<
+ InternalCoreStart,
+ Exclude
+>;
/** @internal */
export class PluginsService implements CoreService {
diff --git a/src/core/server/plugins/plugins_system.test.ts b/src/core/server/plugins/plugins_system.test.ts
index 9754c1b03d030..d7435ffdfe282 100644
--- a/src/core/server/plugins/plugins_system.test.ts
+++ b/src/core/server/plugins/plugins_system.test.ts
@@ -33,6 +33,7 @@ import { httpServiceMock } from '../http/http_service.mock';
import { loggingServiceMock } from '../logging/logging_service.mock';
import { PluginWrapper, PluginName } from './plugin';
import { PluginsSystem } from './plugins_system';
+import { PluginsServiceSetupDeps } from './plugins_service';
const logger = loggingServiceMock.create();
function createPlugin(
@@ -64,8 +65,8 @@ const configService = configServiceMock.create();
configService.atPath.mockReturnValue(new BehaviorSubject({ initialize: true }));
let env: Env;
let coreContext: CoreContext;
-const setupDeps = {
- elasticsearch: elasticsearchServiceMock.createSetupContract(),
+const setupDeps: PluginsServiceSetupDeps = {
+ elasticsearch: elasticsearchServiceMock.createInternalSetupContract(),
http: httpServiceMock.createSetupContract(),
};
beforeEach(() => {
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index 77059cd1491ad..b43c769a1b032 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -86,20 +86,9 @@ export class ConfigService {
// @public
export interface CoreSetup {
// (undocumented)
- elasticsearch: {
- adminClient$: Observable;
- dataClient$: Observable;
- createClient: (type: string, clientConfig?: Partial) => ClusterClient;
- };
+ elasticsearch: ElasticsearchServiceSetup;
// (undocumented)
- http: {
- registerOnPreAuth: HttpServiceSetup['registerOnPreAuth'];
- registerAuth: HttpServiceSetup['registerAuth'];
- registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
- basePath: HttpServiceSetup['basePath'];
- createNewServer: HttpServiceSetup['createNewServer'];
- isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
- };
+ http: HttpServiceSetup;
}
// @public
@@ -147,10 +136,6 @@ export interface ElasticsearchServiceSetup {
readonly createClient: (type: string, clientConfig?: Partial) => ClusterClient;
// (undocumented)
readonly dataClient$: Observable;
- // (undocumented)
- readonly legacy: {
- readonly config$: Observable;
- };
}
// @public
@@ -179,22 +164,6 @@ export interface HttpServiceStart {
isListening: (port: number) => boolean;
}
-// @internal (undocumented)
-export interface InternalCoreSetup {
- // (undocumented)
- elasticsearch: ElasticsearchServiceSetup;
- // (undocumented)
- http: HttpServiceSetup;
- // (undocumented)
- plugins: PluginsServiceSetup;
-}
-
-// @public (undocumented)
-export interface InternalCoreStart {
- // (undocumented)
- plugins: PluginsServiceStart;
-}
-
// @public
export class KibanaRequest {
// @internal (undocumented)
@@ -227,6 +196,24 @@ export interface KibanaRequestRoute {
path: string;
}
+// @public (undocumented)
+export interface LegacyCoreSetup extends CoreSetup {
+ // (undocumented)
+ elasticsearch: ElasticsearchServiceSetup & {
+ readonly legacy: {
+ readonly config$: Observable;
+ };
+ };
+ // (undocumented)
+ plugins: PluginsServiceSetup;
+}
+
+// @public (undocumented)
+export interface LegacyCoreStart extends CoreStart {
+ // (undocumented)
+ plugins: PluginsServiceStart;
+}
+
// @public
export type LegacyRequest = Request;
@@ -690,6 +677,6 @@ export interface SessionStorageFactory {
// Warnings were encountered during analysis:
//
// src/core/server/plugins/plugin_context.ts:34:10 - (ae-forgotten-export) The symbol "EnvironmentMode" needs to be exported by the entry point index.d.ts
-// src/core/server/plugins/plugins_service.ts:37:5 - (ae-forgotten-export) The symbol "DiscoveredPluginInternal" needs to be exported by the entry point index.d.ts
+// src/core/server/plugins/plugins_service.ts:36:5 - (ae-forgotten-export) The symbol "DiscoveredPluginInternal" needs to be exported by the entry point index.d.ts
```
diff --git a/src/core/server/server.ts b/src/core/server/server.ts
index 01f2673c3f9e5..76679cbe76dd2 100644
--- a/src/core/server/server.ts
+++ b/src/core/server/server.ts
@@ -20,17 +20,35 @@ import { Observable } from 'rxjs';
import { Type } from '@kbn/config-schema';
import { ConfigService, Env, Config, ConfigPath } from './config';
-import { ElasticsearchService } from './elasticsearch';
+import { ElasticsearchService, InternalElasticsearchServiceSetup } from './elasticsearch';
import { HttpService, HttpServiceSetup, Router } from './http';
import { LegacyService } from './legacy';
import { Logger, LoggerFactory } from './logging';
-import { PluginsService, config as pluginsConfig } from './plugins';
+import {
+ PluginsService,
+ config as pluginsConfig,
+ PluginsServiceSetup,
+ PluginsServiceStart,
+} from './plugins';
import { config as elasticsearchConfig } from './elasticsearch';
import { config as httpConfig } from './http';
import { config as loggingConfig } from './logging';
import { config as devConfig } from './dev';
import { mapToObject } from '../utils/';
+import { LegacyCoreSetup, LegacyCoreStart } from '.';
+
+/** @internal */
+export interface InternalCoreSetup {
+ http: HttpServiceSetup;
+ elasticsearch: InternalElasticsearchServiceSetup;
+ plugins: PluginsServiceSetup;
+}
+
+/** @internal */
+export interface InternalCoreStart {
+ plugins: PluginsServiceStart;
+}
export class Server {
public readonly configService: ConfigService;
@@ -61,43 +79,46 @@ export class Server {
const httpSetup = await this.http.setup();
this.registerDefaultRoute(httpSetup);
- const elasticsearchServiceSetup = await this.elasticsearch.setup({
+ const elasticsearchSetup = await this.elasticsearch.setup({
http: httpSetup,
});
const pluginsSetup = await this.plugins.setup({
- elasticsearch: elasticsearchServiceSetup,
+ elasticsearch: elasticsearchSetup,
http: httpSetup,
});
- const coreSetup = {
- elasticsearch: elasticsearchServiceSetup,
+ const legacyCore: LegacyCoreSetup = {
+ elasticsearch: {
+ legacy: elasticsearchSetup.legacy,
+ ...elasticsearchSetup.forPlugin(),
+ },
http: httpSetup,
plugins: pluginsSetup,
};
await this.legacy.setup({
- core: coreSetup,
+ core: legacyCore,
plugins: mapToObject(pluginsSetup.contracts),
});
- return coreSetup;
+ return legacyCore;
}
public async start() {
const pluginsStart = await this.plugins.start({});
- const coreStart = {
+ const legacyStart: LegacyCoreStart = {
plugins: pluginsStart,
};
await this.legacy.start({
- core: coreStart,
+ core: legacyStart,
plugins: mapToObject(pluginsStart.contracts),
});
await this.http.start();
- return coreStart;
+ return legacyStart;
}
public async stop() {
diff --git a/src/core/types/core_service.ts b/src/core/types/core_service.ts
index b99c419b796ba..438cac2a50577 100644
--- a/src/core/types/core_service.ts
+++ b/src/core/types/core_service.ts
@@ -17,9 +17,17 @@
* under the License.
*/
+import { PluginName } from '../server';
+
+export interface PluginScoped {
+ forPlugin(plugin: PluginName): T;
+}
+
+export type LifecycleReturnType = T | PluginScoped | Promise>;
+
/** @internal */
export interface CoreService {
- setup(...params: any[]): Promise;
- start(...params: any[]): Promise;
- stop(): Promise;
+ setup(...params: any[]): LifecycleReturnType;
+ start(...params: any[]): LifecycleReturnType;
+ stop(): void | Promise;
}
diff --git a/src/legacy/server/kbn_server.d.ts b/src/legacy/server/kbn_server.d.ts
index eba6a16674705..e06be1878c6da 100644
--- a/src/legacy/server/kbn_server.d.ts
+++ b/src/legacy/server/kbn_server.d.ts
@@ -22,8 +22,8 @@ import { ResponseObject, Server } from 'hapi';
import {
ConfigService,
ElasticsearchServiceSetup,
- InternalCoreSetup,
- InternalCoreStart,
+ LegacyCoreSetup,
+ LegacyCoreStart,
LoggerFactory,
SavedObjectsClientContract,
SavedObjectsService,
@@ -94,11 +94,11 @@ export default class KbnServer {
logger: LoggerFactory;
};
setup: {
- core: InternalCoreSetup;
+ core: LegacyCoreSetup;
plugins: Record;
};
start: {
- core: InternalCoreStart;
+ core: LegacyCoreStart;
plugins: Record;
};
stop: null;
diff --git a/src/legacy/ui/public/legacy_compat/angular_config.tsx b/src/legacy/ui/public/legacy_compat/angular_config.tsx
index 1e22003b32833..e678c07c160b5 100644
--- a/src/legacy/ui/public/legacy_compat/angular_config.tsx
+++ b/src/legacy/ui/public/legacy_compat/angular_config.tsx
@@ -33,7 +33,7 @@ import * as Rx from 'rxjs';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
-import { InternalCoreStart } from 'kibana/public';
+import { LegacyCoreStart } from 'kibana/public';
import { fatalError } from 'ui/notify';
import { capabilities } from 'ui/capabilities';
@@ -77,7 +77,7 @@ export const configureAppAngularModule = (angularModule: IModule) => {
.run($setupUrlOverflowHandling(newPlatform));
};
-const getEsUrl = (newPlatform: InternalCoreStart) => {
+const getEsUrl = (newPlatform: LegacyCoreStart) => {
const a = document.createElement('a');
a.href = newPlatform.http.basePath.prepend('/elasticsearch');
const protocolPort = /https/.test(a.protocol) ? 443 : 80;
@@ -90,7 +90,7 @@ const getEsUrl = (newPlatform: InternalCoreStart) => {
};
};
-const setupCompileProvider = (newPlatform: InternalCoreStart) => (
+const setupCompileProvider = (newPlatform: LegacyCoreStart) => (
$compileProvider: ICompileProvider
) => {
if (!newPlatform.injectedMetadata.getLegacyMetadata().devMode) {
@@ -98,7 +98,7 @@ const setupCompileProvider = (newPlatform: InternalCoreStart) => (
}
};
-const setupLocationProvider = (newPlatform: InternalCoreStart) => (
+const setupLocationProvider = (newPlatform: LegacyCoreStart) => (
$locationProvider: ILocationProvider
) => {
$locationProvider.html5Mode({
@@ -110,7 +110,7 @@ const setupLocationProvider = (newPlatform: InternalCoreStart) => (
$locationProvider.hashPrefix('');
};
-export const $setupXsrfRequestInterceptor = (newPlatform: InternalCoreStart) => {
+export const $setupXsrfRequestInterceptor = (newPlatform: LegacyCoreStart) => {
const version = newPlatform.injectedMetadata.getLegacyMetadata().version;
// Configure jQuery prefilter
@@ -145,7 +145,7 @@ export const $setupXsrfRequestInterceptor = (newPlatform: InternalCoreStart) =>
* @param {HttpService} $http
* @return {undefined}
*/
-const capture$httpLoadingCount = (newPlatform: InternalCoreStart) => (
+const capture$httpLoadingCount = (newPlatform: LegacyCoreStart) => (
$rootScope: IRootScopeService,
$http: IHttpService
) => {
@@ -166,7 +166,7 @@ const capture$httpLoadingCount = (newPlatform: InternalCoreStart) => (
* lets us integrate with the angular router so that we can automatically clear
* the breadcrumbs if we switch to a Kibana app that does not use breadcrumbs correctly
*/
-const $setupBreadcrumbsAutoClear = (newPlatform: InternalCoreStart) => (
+const $setupBreadcrumbsAutoClear = (newPlatform: LegacyCoreStart) => (
$rootScope: IRootScopeService,
$injector: any
) => {
@@ -213,7 +213,7 @@ const $setupBreadcrumbsAutoClear = (newPlatform: InternalCoreStart) => (
* lets us integrate with the angular router so that we can automatically clear
* the badge if we switch to a Kibana app that does not use the badge correctly
*/
-const $setupBadgeAutoClear = (newPlatform: InternalCoreStart) => (
+const $setupBadgeAutoClear = (newPlatform: LegacyCoreStart) => (
$rootScope: IRootScopeService,
$injector: any
) => {
@@ -253,7 +253,7 @@ const $setupBadgeAutoClear = (newPlatform: InternalCoreStart) => (
* the helpExtension if we switch to a Kibana app that does not set its own
* helpExtension
*/
-const $setupHelpExtensionAutoClear = (newPlatform: InternalCoreStart) => (
+const $setupHelpExtensionAutoClear = (newPlatform: LegacyCoreStart) => (
$rootScope: IRootScopeService,
$injector: any
) => {
@@ -285,7 +285,7 @@ const $setupHelpExtensionAutoClear = (newPlatform: InternalCoreStart) => (
});
};
-const $setupUrlOverflowHandling = (newPlatform: InternalCoreStart) => (
+const $setupUrlOverflowHandling = (newPlatform: LegacyCoreStart) => (
$location: ILocationService,
$rootScope: IRootScopeService,
Private: any,
diff --git a/src/legacy/ui/public/new_platform/new_platform.ts b/src/legacy/ui/public/new_platform/new_platform.ts
index cfcf99fcbc9f2..c4ecb8688284c 100644
--- a/src/legacy/ui/public/new_platform/new_platform.ts
+++ b/src/legacy/ui/public/new_platform/new_platform.ts
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { InternalCoreSetup, InternalCoreStart } from '../../../../core/public';
+import { LegacyCoreSetup, LegacyCoreStart } from '../../../../core/public';
import { Plugin as DataPlugin } from '../../../../plugins/data/public';
export interface PluginsSetup {
@@ -28,12 +28,12 @@ export interface PluginsStart {
}
export const npSetup = {
- core: (null as unknown) as InternalCoreSetup,
+ core: (null as unknown) as LegacyCoreSetup,
plugins: {} as PluginsSetup,
};
export const npStart = {
- core: (null as unknown) as InternalCoreStart,
+ core: (null as unknown) as LegacyCoreStart,
plugins: {} as PluginsStart,
};
@@ -42,18 +42,18 @@ export const npStart = {
* @internal
*/
export function __reset__() {
- npSetup.core = (null as unknown) as InternalCoreSetup;
+ npSetup.core = (null as unknown) as LegacyCoreSetup;
npSetup.plugins = {} as any;
- npStart.core = (null as unknown) as InternalCoreStart;
+ npStart.core = (null as unknown) as LegacyCoreStart;
npStart.plugins = {} as any;
}
-export function __setup__(coreSetup: InternalCoreSetup, plugins: PluginsSetup) {
+export function __setup__(coreSetup: LegacyCoreSetup, plugins: PluginsSetup) {
npSetup.core = coreSetup;
npSetup.plugins = plugins;
}
-export function __start__(coreStart: InternalCoreStart, plugins: PluginsStart) {
+export function __start__(coreStart: LegacyCoreStart, plugins: PluginsStart) {
npStart.core = coreStart;
npStart.plugins = plugins;
}
diff --git a/typings/index.d.ts b/typings/index.d.ts
index c9eb02dbedcfa..1c58a92a046df 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -30,3 +30,10 @@ type MethodKeysOf = {
type PublicMethodsOf = Pick>;
type MockedKeys = { [P in keyof T]: jest.Mocked };
+
+type DeeplyMockedKeys = {
+ [P in keyof T]: T[P] extends (...args: any[]) => any
+ ? jest.MockInstance, Parameters>
+ : DeeplyMockedKeys;
+} &
+ T;
diff --git a/x-pack/legacy/plugins/apm/index.ts b/x-pack/legacy/plugins/apm/index.ts
index aac946a36b458..8aa286b7854a7 100644
--- a/x-pack/legacy/plugins/apm/index.ts
+++ b/x-pack/legacy/plugins/apm/index.ts
@@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n';
import { Server } from 'hapi';
import { resolve } from 'path';
import {
- InternalCoreSetup,
+ LegacyCoreSetup,
PluginInitializerContext
} from '../../../../src/core/server';
import { LegacyPluginInitializer } from '../../../../src/legacy/types';
@@ -109,7 +109,7 @@ export const apm: LegacyPluginInitializer = kibana => {
http: {
server
}
- } as InternalCoreSetup;
+ } as LegacyCoreSetup;
plugin(initializerContext).setup(core);
}
});
diff --git a/x-pack/legacy/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts b/x-pack/legacy/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts
index 8a91bd8781fe7..d17bd409ca5a6 100644
--- a/x-pack/legacy/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts
+++ b/x-pack/legacy/plugins/apm/server/lib/apm_telemetry/make_apm_usage_collector.ts
@@ -4,12 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { getSavedObjectsClient } from '../helpers/saved_objects_client';
import { APM_TELEMETRY_DOC_ID, createApmTelementry } from './apm_telemetry';
-export interface CoreSetupWithUsageCollector extends InternalCoreSetup {
- http: InternalCoreSetup['http'] & {
+export interface CoreSetupWithUsageCollector extends LegacyCoreSetup {
+ http: LegacyCoreSetup['http'] & {
server: {
usage: {
collectorSet: {
diff --git a/x-pack/legacy/plugins/apm/server/lib/index_pattern/index.ts b/x-pack/legacy/plugins/apm/server/lib/index_pattern/index.ts
index aa9e27ed2442a..2a2be0b0b6b6c 100644
--- a/x-pack/legacy/plugins/apm/server/lib/index_pattern/index.ts
+++ b/x-pack/legacy/plugins/apm/server/lib/index_pattern/index.ts
@@ -3,11 +3,11 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { getSavedObjectsClient } from '../helpers/saved_objects_client';
import apmIndexPattern from '../../../../../../../src/legacy/core_plugins/kibana/server/tutorials/apm/index_pattern.json';
-export async function getIndexPattern(core: InternalCoreSetup) {
+export async function getIndexPattern(core: LegacyCoreSetup) {
const { server } = core.http;
const config = server.config();
const apmIndexPatternTitle = config.get('apm_oss.indexPattern');
diff --git a/x-pack/legacy/plugins/apm/server/new-platform/plugin.ts b/x-pack/legacy/plugins/apm/server/new-platform/plugin.ts
index 90af3befcdfa3..52629749e7789 100644
--- a/x-pack/legacy/plugins/apm/server/new-platform/plugin.ts
+++ b/x-pack/legacy/plugins/apm/server/new-platform/plugin.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { makeApmUsageCollector } from '../lib/apm_telemetry';
import { CoreSetupWithUsageCollector } from '../lib/apm_telemetry/make_apm_usage_collector';
import { initErrorsApi } from '../routes/errors';
@@ -17,7 +17,7 @@ import { initIndexPatternApi } from '../routes/index_pattern';
import { initSettingsApi } from '../routes/settings';
export class Plugin {
- public setup(core: InternalCoreSetup) {
+ public setup(core: LegacyCoreSetup) {
initUIFiltersApi(core);
initTransactionGroupsApi(core);
initTracesApi(core);
diff --git a/x-pack/legacy/plugins/apm/server/routes/__test__/routeFailures.test.ts b/x-pack/legacy/plugins/apm/server/routes/__test__/routeFailures.test.ts
index b440b7a576b5e..c83af4f11feb2 100644
--- a/x-pack/legacy/plugins/apm/server/routes/__test__/routeFailures.test.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/__test__/routeFailures.test.ts
@@ -5,7 +5,7 @@
*/
import { flatten } from 'lodash';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { initErrorsApi } from '../errors';
import { initServicesApi } from '../services';
import { initTracesApi } from '../traces';
@@ -13,13 +13,13 @@ import { initTracesApi } from '../traces';
describe('route handlers should fail with a Boom error', () => {
let consoleErrorSpy: any;
- function testRouteFailures(init: (core: InternalCoreSetup) => void) {
+ function testRouteFailures(init: (core: LegacyCoreSetup) => void) {
const mockServer = { route: jest.fn() };
const mockCore = ({
http: {
server: mockServer
}
- } as unknown) as InternalCoreSetup;
+ } as unknown) as LegacyCoreSetup;
init(mockCore);
expect(mockServer.route).toHaveBeenCalled();
diff --git a/x-pack/legacy/plugins/apm/server/routes/errors.ts b/x-pack/legacy/plugins/apm/server/routes/errors.ts
index b4b7f3fdc1a8d..070775c314105 100644
--- a/x-pack/legacy/plugins/apm/server/routes/errors.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/errors.ts
@@ -6,7 +6,7 @@
import Boom from 'boom';
import Joi from 'joi';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { getErrorDistribution } from '../lib/errors/distribution/get_distribution';
import { getErrorGroup } from '../lib/errors/get_error_group';
import { getErrorGroups } from '../lib/errors/get_error_groups';
@@ -19,7 +19,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initErrorsApi(core: InternalCoreSetup) {
+export function initErrorsApi(core: LegacyCoreSetup) {
const { server } = core.http;
server.route({
method: 'GET',
diff --git a/x-pack/legacy/plugins/apm/server/routes/index_pattern.ts b/x-pack/legacy/plugins/apm/server/routes/index_pattern.ts
index 20ae3c3363663..3f72df183fa85 100644
--- a/x-pack/legacy/plugins/apm/server/routes/index_pattern.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/index_pattern.ts
@@ -5,7 +5,7 @@
*/
import Boom from 'boom';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { getIndexPattern } from '../lib/index_pattern';
const ROOT = '/api/apm/index_pattern';
@@ -15,7 +15,7 @@ const defaultErrorHandler = (err: Error & { status?: number }) => {
throw Boom.boomify(err, { statusCode: err.status || 500 });
};
-export function initIndexPatternApi(core: InternalCoreSetup) {
+export function initIndexPatternApi(core: LegacyCoreSetup) {
const { server } = core.http;
server.route({
method: 'GET',
diff --git a/x-pack/legacy/plugins/apm/server/routes/metrics.ts b/x-pack/legacy/plugins/apm/server/routes/metrics.ts
index 16cc8b8a652f2..621634dfdf6d4 100644
--- a/x-pack/legacy/plugins/apm/server/routes/metrics.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/metrics.ts
@@ -6,7 +6,7 @@
import Boom from 'boom';
import Joi from 'joi';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { withDefaultValidators } from '../lib/helpers/input_validation';
import { setupRequest } from '../lib/helpers/setup_request';
import { getMetricsChartDataByAgent } from '../lib/metrics/get_metrics_chart_data_by_agent';
@@ -17,7 +17,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initMetricsApi(core: InternalCoreSetup) {
+export function initMetricsApi(core: LegacyCoreSetup) {
const { server } = core.http;
server.route({
diff --git a/x-pack/legacy/plugins/apm/server/routes/services.ts b/x-pack/legacy/plugins/apm/server/routes/services.ts
index 063bf0556daf5..892c456af678a 100644
--- a/x-pack/legacy/plugins/apm/server/routes/services.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/services.ts
@@ -5,7 +5,7 @@
*/
import Boom from 'boom';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { AgentName } from '../../typings/es_schemas/ui/fields/Agent';
import { createApmTelementry, storeApmTelemetry } from '../lib/apm_telemetry';
import { withDefaultValidators } from '../lib/helpers/input_validation';
@@ -20,7 +20,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initServicesApi(core: InternalCoreSetup) {
+export function initServicesApi(core: LegacyCoreSetup) {
const { server } = core.http;
server.route({
method: 'GET',
diff --git a/x-pack/legacy/plugins/apm/server/routes/settings.ts b/x-pack/legacy/plugins/apm/server/routes/settings.ts
index 388e572ae0b1f..7a9b40448ba62 100644
--- a/x-pack/legacy/plugins/apm/server/routes/settings.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/settings.ts
@@ -5,7 +5,7 @@
*/
import Boom from 'boom';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import Joi from 'joi';
import { setupRequest } from '../lib/helpers/setup_request';
import { getServiceNames } from '../lib/settings/agent_configuration/get_service_names';
@@ -24,7 +24,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initSettingsApi(core: InternalCoreSetup) {
+export function initSettingsApi(core: LegacyCoreSetup) {
const { server } = core.http;
createApmAgentConfigurationIndex(server);
diff --git a/x-pack/legacy/plugins/apm/server/routes/traces.ts b/x-pack/legacy/plugins/apm/server/routes/traces.ts
index a69361903e6bc..715676ff850eb 100644
--- a/x-pack/legacy/plugins/apm/server/routes/traces.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/traces.ts
@@ -6,7 +6,7 @@
import Boom from 'boom';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { withDefaultValidators } from '../lib/helpers/input_validation';
import { setupRequest } from '../lib/helpers/setup_request';
import { getTopTraces } from '../lib/traces/get_top_traces';
@@ -19,7 +19,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initTracesApi(core: InternalCoreSetup) {
+export function initTracesApi(core: LegacyCoreSetup) {
const { server } = core.http;
// Get trace list
diff --git a/x-pack/legacy/plugins/apm/server/routes/transaction_groups.ts b/x-pack/legacy/plugins/apm/server/routes/transaction_groups.ts
index c3c852bf3b61d..178ee02785f04 100644
--- a/x-pack/legacy/plugins/apm/server/routes/transaction_groups.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/transaction_groups.ts
@@ -6,7 +6,7 @@
import Boom from 'boom';
import Joi from 'joi';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { withDefaultValidators } from '../lib/helpers/input_validation';
import { setupRequest } from '../lib/helpers/setup_request';
import { getTransactionCharts } from '../lib/transactions/charts';
@@ -20,7 +20,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initTransactionGroupsApi(core: InternalCoreSetup) {
+export function initTransactionGroupsApi(core: LegacyCoreSetup) {
const { server } = core.http;
server.route({
diff --git a/x-pack/legacy/plugins/apm/server/routes/ui_filters.ts b/x-pack/legacy/plugins/apm/server/routes/ui_filters.ts
index 72c9e72286c08..69f7d2694f70d 100644
--- a/x-pack/legacy/plugins/apm/server/routes/ui_filters.ts
+++ b/x-pack/legacy/plugins/apm/server/routes/ui_filters.ts
@@ -6,7 +6,7 @@
import Boom from 'boom';
import Joi from 'joi';
-import { InternalCoreSetup } from 'src/core/server';
+import { LegacyCoreSetup } from 'src/core/server';
import { withDefaultValidators } from '../lib/helpers/input_validation';
import { setupRequest } from '../lib/helpers/setup_request';
import { getEnvironments } from '../lib/ui_filters/get_environments';
@@ -17,7 +17,7 @@ const defaultErrorHandler = (err: Error) => {
throw Boom.boomify(err, { statusCode: 400 });
};
-export function initUIFiltersApi(core: InternalCoreSetup) {
+export function initUIFiltersApi(core: LegacyCoreSetup) {
const { server } = core.http;
server.route({
method: 'GET',
diff --git a/x-pack/typings/index.d.ts b/x-pack/typings/index.d.ts
index c40ff7f86fe40..53724a72166e1 100644
--- a/x-pack/typings/index.d.ts
+++ b/x-pack/typings/index.d.ts
@@ -25,6 +25,13 @@ declare module 'axios/lib/adapters/xhr';
type MockedKeys = { [P in keyof T]: jest.Mocked };
+type DeeplyMockedKeys = {
+ [P in keyof T]: T[P] extends (...args: any[]) => any
+ ? jest.MockInstance, Parameters>
+ : DeeplyMockedKeys;
+} &
+ T;
+
// allow JSON files to be imported directly without lint errors
// see: https://github.com/palantir/tslint/issues/1264#issuecomment-228433367
// and: https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#arbitrary-expressions-are-forbidden-in-export-assignments-in-ambient-contexts