diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md
index 152a0e2c48871..5fd3ef5e8ff4b 100644
--- a/STYLEGUIDE.md
+++ b/STYLEGUIDE.md
@@ -141,6 +141,39 @@ function addBar(foos, foo) {
}
```
+### Avoid `any` whenever possible
+
+Since TypeScript 3.0 and the introduction of the
+[`unknown` type](https://mariusschulz.com/blog/the-unknown-type-in-typescript) there are rarely any
+reasons to use `any` as a type. Nearly all places of former `any` usage can be replace by either a
+generic or `unknown` (in cases the type is really not known).
+
+You should always prefer using those mechanisms over using `any`, since they are stricter typed and
+less likely to introduce bugs in the future due to insufficient types.
+
+If you’re not having `any` in your plugin or are starting a new plugin, you should enable the
+[`@typescript-eslint/no-explicit-any`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md)
+linting rule for your plugin via the [`.eslintrc.js`](https://github.com/elastic/kibana/blob/master/.eslintrc.js) config.
+
+### Avoid non-null assertions
+
+You should try avoiding non-null assertions (`!.`) wherever possible. By using them you tell
+TypeScript, that something is not null even though by it’s type it could be. Usage of non-null
+assertions is most often a side-effect of you actually checked that the variable is not `null`
+but TypeScript doesn’t correctly carry on that information till the usage of the variable.
+
+In most cases it’s possible to replace the non-null assertion by structuring your code/checks slightly different
+or using [user defined type guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)
+to properly tell TypeScript what type a variable has.
+
+Using non-null assertion increases the risk for future bugs. In case the condition under which we assumed that the
+variable can’t be null has changed (potentially even due to changes in compeltely different files), the non-null
+assertion would now wrongly disable proper type checking for us.
+
+If you’re not using non-null assertions in your plugin or are starting a new plugin, consider enabling the
+[`@typescript-eslint/no-non-null-assertion`](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-non-null-assertion.md)
+linting rule for you plugin in the [`.eslintrc.js`](https://github.com/elastic/kibana/blob/master/.eslintrc.js) config.
+
### Return/throw early from functions
To avoid deep nesting of if-statements, always return a function's value as early
diff --git a/docs/development/core/public/kibana-plugin-public.applicationsetup.registermountcontext.md b/docs/development/core/public/kibana-plugin-public.applicationsetup.registermountcontext.md
index 0b5bd8eeb36ec..f264ba500ed6e 100644
--- a/docs/development/core/public/kibana-plugin-public.applicationsetup.registermountcontext.md
+++ b/docs/development/core/public/kibana-plugin-public.applicationsetup.registermountcontext.md
@@ -9,7 +9,7 @@ Register a context provider for application mounting. Will only be available to
Signature:
```typescript
-registerMountContext(contextName: T, provider: IContextProvider): void;
+registerMountContext(contextName: T, provider: IContextProvider): void;
```
## Parameters
@@ -17,7 +17,7 @@ registerMountContext(contextName: T, provider:
| Parameter | Type | Description |
| --- | --- | --- |
| contextName | T | The key of [AppMountContext](./kibana-plugin-public.appmountcontext.md) this provider's return value should be attached to. |
-| provider | IContextProvider<AppMountContext, T> | A [IContextProvider](./kibana-plugin-public.icontextprovider.md) function |
+| provider | IContextProvider<App['mount'], T> | A [IContextProvider](./kibana-plugin-public.icontextprovider.md) function |
Returns:
diff --git a/docs/development/core/public/kibana-plugin-public.applicationstart.registermountcontext.md b/docs/development/core/public/kibana-plugin-public.applicationstart.registermountcontext.md
index fc86aaf658b68..62821fcbb92ba 100644
--- a/docs/development/core/public/kibana-plugin-public.applicationstart.registermountcontext.md
+++ b/docs/development/core/public/kibana-plugin-public.applicationstart.registermountcontext.md
@@ -9,7 +9,7 @@ Register a context provider for application mounting. Will only be available to
Signature:
```typescript
-registerMountContext(contextName: T, provider: IContextProvider): void;
+registerMountContext(contextName: T, provider: IContextProvider): void;
```
## Parameters
@@ -17,7 +17,7 @@ registerMountContext(contextName: T, provider:
| Parameter | Type | Description |
| --- | --- | --- |
| contextName | T | The key of [AppMountContext](./kibana-plugin-public.appmountcontext.md) this provider's return value should be attached to. |
-| provider | IContextProvider<AppMountContext, T> | A [IContextProvider](./kibana-plugin-public.icontextprovider.md) function |
+| provider | IContextProvider<App['mount'], T> | A [IContextProvider](./kibana-plugin-public.icontextprovider.md) function |
Returns:
diff --git a/docs/development/core/public/kibana-plugin-public.contextsetup.createcontextcontainer.md b/docs/development/core/public/kibana-plugin-public.contextsetup.createcontextcontainer.md
index 2644596354e38..5334eee842577 100644
--- a/docs/development/core/public/kibana-plugin-public.contextsetup.createcontextcontainer.md
+++ b/docs/development/core/public/kibana-plugin-public.contextsetup.createcontextcontainer.md
@@ -9,9 +9,9 @@ Creates a new [IContextContainer](./kibana-plugin-public.icontextcontainer.md) f
Signature:
```typescript
-createContextContainer(): IContextContainer;
+createContextContainer>(): IContextContainer;
```
Returns:
-`IContextContainer`
+`IContextContainer`
diff --git a/docs/development/core/public/kibana-plugin-public.handlercontexttype.md b/docs/development/core/public/kibana-plugin-public.handlercontexttype.md
new file mode 100644
index 0000000000000..b083449d2b703
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.handlercontexttype.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HandlerContextType](./kibana-plugin-public.handlercontexttype.md)
+
+## HandlerContextType type
+
+Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md) to represent the type of the context.
+
+Signature:
+
+```typescript
+export declare type HandlerContextType> = T extends HandlerFunction ? U : never;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.handlerfunction.md b/docs/development/core/public/kibana-plugin-public.handlerfunction.md
new file mode 100644
index 0000000000000..98c342c17691d
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.handlerfunction.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HandlerFunction](./kibana-plugin-public.handlerfunction.md)
+
+## HandlerFunction type
+
+A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-public.icontextcontainer.md)
+
+Signature:
+
+```typescript
+export declare type HandlerFunction = (context: T, ...args: any[]) => any;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.handlerparameters.md b/docs/development/core/public/kibana-plugin-public.handlerparameters.md
new file mode 100644
index 0000000000000..f46c4b649e943
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.handlerparameters.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [HandlerParameters](./kibana-plugin-public.handlerparameters.md)
+
+## HandlerParameters type
+
+Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-public.handlercontexttype.md).
+
+Signature:
+
+```typescript
+export declare type HandlerParameters> = T extends (context: any, ...args: infer U) => any ? U : never;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.icontextcontainer.createhandler.md b/docs/development/core/public/kibana-plugin-public.icontextcontainer.createhandler.md
index 2a995df45757f..af3b5e3fc2eb6 100644
--- a/docs/development/core/public/kibana-plugin-public.icontextcontainer.createhandler.md
+++ b/docs/development/core/public/kibana-plugin-public.icontextcontainer.createhandler.md
@@ -9,7 +9,7 @@ Create a new handler function pre-wired to context for the plugin.
Signature:
```typescript
-createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler): (...rest: THandlerParameters) => THandlerReturn extends Promise ? THandlerReturn : Promise;
+createHandler(pluginOpaqueId: PluginOpaqueId, handler: THandler): (...rest: HandlerParameters) => ShallowPromise>;
```
## Parameters
@@ -17,11 +17,11 @@ createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandlerPluginOpaqueId | The plugin opaque ID for the plugin that registers this handler. |
-| handler | IContextHandler<TContext, THandlerReturn, THandlerParameters> | Handler function to pass context object to. |
+| handler | THandler | Handler function to pass context object to. |
Returns:
-`(...rest: THandlerParameters) => THandlerReturn extends Promise ? THandlerReturn : Promise`
+`(...rest: HandlerParameters) => ShallowPromise>`
A function that takes `THandlerParameters`, calls `handler` with a new context, and returns a Promise of the `handler` return value.
diff --git a/docs/development/core/public/kibana-plugin-public.icontextcontainer.md b/docs/development/core/public/kibana-plugin-public.icontextcontainer.md
index 0bc7c8f3808d1..f16c07b3d7906 100644
--- a/docs/development/core/public/kibana-plugin-public.icontextcontainer.md
+++ b/docs/development/core/public/kibana-plugin-public.icontextcontainer.md
@@ -9,7 +9,7 @@ An object that handles registration of context providers and configuring handler
Signature:
```typescript
-export interface IContextContainer
+export interface IContextContainer>
```
## Methods
diff --git a/docs/development/core/public/kibana-plugin-public.icontextcontainer.registercontext.md b/docs/development/core/public/kibana-plugin-public.icontextcontainer.registercontext.md
index 2cf10a6ec841d..775f95bd7affa 100644
--- a/docs/development/core/public/kibana-plugin-public.icontextcontainer.registercontext.md
+++ b/docs/development/core/public/kibana-plugin-public.icontextcontainer.registercontext.md
@@ -9,7 +9,7 @@ Register a new context provider.
Signature:
```typescript
-registerContext(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
+registerContext>(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
```
## Parameters
@@ -18,7 +18,7 @@ registerContext(pluginOpaqueId: PluginOpaqu
| --- | --- | --- |
| pluginOpaqueId | PluginOpaqueId | The plugin opaque ID for the plugin that registers this context. |
| contextName | TContextName | The key of the TContext object this provider supplies the value for. |
-| provider | IContextProvider<TContext, TContextName, THandlerParameters> | A [IContextProvider](./kibana-plugin-public.icontextprovider.md) to be called each time a new context is created. |
+| provider | IContextProvider<THandler, TContextName> | A [IContextProvider](./kibana-plugin-public.icontextprovider.md) to be called each time a new context is created. |
Returns:
diff --git a/docs/development/core/public/kibana-plugin-public.icontexthandler.md b/docs/development/core/public/kibana-plugin-public.icontexthandler.md
deleted file mode 100644
index 2251b1131c313..0000000000000
--- a/docs/development/core/public/kibana-plugin-public.icontexthandler.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [IContextHandler](./kibana-plugin-public.icontexthandler.md)
-
-## IContextHandler type
-
-A function registered by a plugin to perform some action.
-
-Signature:
-
-```typescript
-export declare type IContextHandler = (context: TContext, ...rest: THandlerParameters) => TReturn;
-```
-
-## Remarks
-
-A new `TContext` will be built for each handler before invoking.
-
diff --git a/docs/development/core/public/kibana-plugin-public.icontextprovider.md b/docs/development/core/public/kibana-plugin-public.icontextprovider.md
index a84917d6e1442..40f0ee3782f6d 100644
--- a/docs/development/core/public/kibana-plugin-public.icontextprovider.md
+++ b/docs/development/core/public/kibana-plugin-public.icontextprovider.md
@@ -9,7 +9,7 @@ A function that returns a context value for a specific key of given context type
Signature:
```typescript
-export declare type IContextProvider, TContextName extends keyof TContext, TProviderParameters extends any[] = []> = (context: Partial, ...rest: TProviderParameters) => Promise | TContext[TContextName];
+export declare type IContextProvider, TContextName extends keyof HandlerContextType> = (context: Partial>, ...rest: HandlerParameters) => Promise[TContextName]> | HandlerContextType[TContextName];
```
## Remarks
diff --git a/docs/development/core/public/kibana-plugin-public.md b/docs/development/core/public/kibana-plugin-public.md
index e2ef807a75018..7531cf9a06333 100644
--- a/docs/development/core/public/kibana-plugin-public.md
+++ b/docs/development/core/public/kibana-plugin-public.md
@@ -91,11 +91,13 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [AppUnmount](./kibana-plugin-public.appunmount.md) | A function called when an application should be unmounted from the page. This function should be synchronous. |
| [ChromeHelpExtension](./kibana-plugin-public.chromehelpextension.md) | |
| [ChromeNavLinkUpdateableFields](./kibana-plugin-public.chromenavlinkupdateablefields.md) | |
+| [HandlerContextType](./kibana-plugin-public.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md) to represent the type of the context. |
+| [HandlerFunction](./kibana-plugin-public.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-public.icontextcontainer.md) |
+| [HandlerParameters](./kibana-plugin-public.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-public.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-public.handlercontexttype.md). |
| [HttpBody](./kibana-plugin-public.httpbody.md) | |
| [HttpHandler](./kibana-plugin-public.httphandler.md) | |
| [HttpSetup](./kibana-plugin-public.httpsetup.md) | |
| [HttpStart](./kibana-plugin-public.httpstart.md) | |
-| [IContextHandler](./kibana-plugin-public.icontexthandler.md) | A function registered by a plugin to perform some action. |
| [IContextProvider](./kibana-plugin-public.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
| [OverlayBannerMount](./kibana-plugin-public.overlaybannermount.md) | A function that will mount the banner inside the provided element. |
| [OverlayBannerUnmount](./kibana-plugin-public.overlaybannerunmount.md) | A function that will unmount the banner from the element. |
diff --git a/docs/development/core/server/kibana-plugin-server.basepath.get.md b/docs/development/core/server/kibana-plugin-server.basepath.get.md
index 2b3b6c899e8de..04feca7ccc5a8 100644
--- a/docs/development/core/server/kibana-plugin-server.basepath.get.md
+++ b/docs/development/core/server/kibana-plugin-server.basepath.get.md
@@ -9,5 +9,5 @@ returns `basePath` value, specific for an incoming request.
Signature:
```typescript
-get: (request: KibanaRequest | LegacyRequest) => string;
+get: (request: LegacyRequest | KibanaRequest) => string;
```
diff --git a/docs/development/core/server/kibana-plugin-server.basepath.md b/docs/development/core/server/kibana-plugin-server.basepath.md
index 45fb697b329f8..bfa1ea02aec17 100644
--- a/docs/development/core/server/kibana-plugin-server.basepath.md
+++ b/docs/development/core/server/kibana-plugin-server.basepath.md
@@ -16,11 +16,11 @@ export declare class BasePath
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
-| [get](./kibana-plugin-server.basepath.get.md) | | (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest) => string | returns basePath value, specific for an incoming request. |
+| [get](./kibana-plugin-server.basepath.get.md) | | (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>) => string | returns basePath value, specific for an incoming request. |
| [prepend](./kibana-plugin-server.basepath.prepend.md) | | (path: string) => string | returns a new basePath value, prefixed with passed url. |
| [remove](./kibana-plugin-server.basepath.remove.md) | | (path: string) => string | returns a new basePath value, cleaned up from passed url. |
| [serverBasePath](./kibana-plugin-server.basepath.serverbasepath.md) | | string | returns the server's basePathSee [BasePath.get](./kibana-plugin-server.basepath.get.md) for getting the basePath value for a specific request |
-| [set](./kibana-plugin-server.basepath.set.md) | | (request: KibanaRequest<unknown, unknown, unknown> | LegacyRequest, requestSpecificBasePath: string) => void | sets basePath value, specific for an incoming request. |
+| [set](./kibana-plugin-server.basepath.set.md) | | (request: LegacyRequest | KibanaRequest<unknown, unknown, unknown>, requestSpecificBasePath: string) => void | sets basePath value, specific for an incoming request. |
## Remarks
diff --git a/docs/development/core/server/kibana-plugin-server.basepath.set.md b/docs/development/core/server/kibana-plugin-server.basepath.set.md
index 1272a134ef5c4..cec70ee853bfa 100644
--- a/docs/development/core/server/kibana-plugin-server.basepath.set.md
+++ b/docs/development/core/server/kibana-plugin-server.basepath.set.md
@@ -9,5 +9,5 @@ sets `basePath` value, specific for an incoming request.
Signature:
```typescript
-set: (request: KibanaRequest | LegacyRequest, requestSpecificBasePath: string) => void;
+set: (request: LegacyRequest | KibanaRequest, requestSpecificBasePath: string) => void;
```
diff --git a/docs/development/core/server/kibana-plugin-server.contextsetup.createcontextcontainer.md b/docs/development/core/server/kibana-plugin-server.contextsetup.createcontextcontainer.md
index f44e6a3d7640b..7096bfc43a520 100644
--- a/docs/development/core/server/kibana-plugin-server.contextsetup.createcontextcontainer.md
+++ b/docs/development/core/server/kibana-plugin-server.contextsetup.createcontextcontainer.md
@@ -9,9 +9,9 @@ Creates a new [IContextContainer](./kibana-plugin-server.icontextcontainer.md) f
Signature:
```typescript
-createContextContainer(): IContextContainer;
+createContextContainer>(): IContextContainer;
```
Returns:
-`IContextContainer`
+`IContextContainer`
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 254f2728abef1..8474f4ef940dc 100644
--- a/docs/development/core/server/kibana-plugin-server.coresetup.http.md
+++ b/docs/development/core/server/kibana-plugin-server.coresetup.http.md
@@ -14,7 +14,7 @@ http: {
registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
basePath: HttpServiceSetup['basePath'];
isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
- registerRouteHandlerContext: (name: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
+ registerRouteHandlerContext: (name: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
createRouter: () => IRouter;
};
```
diff --git a/docs/development/core/server/kibana-plugin-server.coresetup.md b/docs/development/core/server/kibana-plugin-server.coresetup.md
index ed487a570f286..528557e91bd17 100644
--- a/docs/development/core/server/kibana-plugin-server.coresetup.md
+++ b/docs/development/core/server/kibana-plugin-server.coresetup.md
@@ -18,5 +18,5 @@ export interface CoreSetup
| --- | --- | --- |
| [context](./kibana-plugin-server.coresetup.context.md) | { createContextContainer: ContextSetup['createContextContainer']; } | |
| [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) | { createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; registerOnPreAuth: HttpServiceSetup['registerOnPreAuth']; registerAuth: HttpServiceSetup['registerAuth']; registerOnPostAuth: HttpServiceSetup['registerOnPostAuth']; basePath: HttpServiceSetup['basePath']; isTlsEnabled: HttpServiceSetup['isTlsEnabled']; registerRouteHandlerContext: <T extends keyof RequestHandlerContext>(name: T, provider: RequestHandlerContextProvider<RequestHandlerContext>) => RequestHandlerContextContainer<RequestHandlerContext>; createRouter: () => IRouter; } | |
+| [http](./kibana-plugin-server.coresetup.http.md) | { createCookieSessionStorageFactory: HttpServiceSetup['createCookieSessionStorageFactory']; registerOnPreAuth: HttpServiceSetup['registerOnPreAuth']; registerAuth: HttpServiceSetup['registerAuth']; registerOnPostAuth: HttpServiceSetup['registerOnPostAuth']; basePath: HttpServiceSetup['basePath']; isTlsEnabled: HttpServiceSetup['isTlsEnabled']; registerRouteHandlerContext: <T extends keyof RequestHandlerContext>(name: T, provider: RequestHandlerContextProvider<T>) => RequestHandlerContextContainer; createRouter: () => IRouter; } | |
diff --git a/docs/development/core/server/kibana-plugin-server.handlercontexttype.md b/docs/development/core/server/kibana-plugin-server.handlercontexttype.md
new file mode 100644
index 0000000000000..e8f1f346e8b8e
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.handlercontexttype.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HandlerContextType](./kibana-plugin-server.handlercontexttype.md)
+
+## HandlerContextType type
+
+Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md) to represent the type of the context.
+
+Signature:
+
+```typescript
+export declare type HandlerContextType> = T extends HandlerFunction ? U : never;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.handlerfunction.md b/docs/development/core/server/kibana-plugin-server.handlerfunction.md
new file mode 100644
index 0000000000000..97acd37946fc9
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.handlerfunction.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HandlerFunction](./kibana-plugin-server.handlerfunction.md)
+
+## HandlerFunction type
+
+A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-server.icontextcontainer.md)
+
+Signature:
+
+```typescript
+export declare type HandlerFunction = (context: T, ...args: any[]) => any;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.handlerparameters.md b/docs/development/core/server/kibana-plugin-server.handlerparameters.md
new file mode 100644
index 0000000000000..3dd7998a71a1f
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-server.handlerparameters.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [HandlerParameters](./kibana-plugin-server.handlerparameters.md)
+
+## HandlerParameters type
+
+Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md).
+
+Signature:
+
+```typescript
+export declare type HandlerParameters> = T extends (context: any, ...args: infer U) => any ? U : never;
+```
diff --git a/docs/development/core/server/kibana-plugin-server.httpservicesetup.md b/docs/development/core/server/kibana-plugin-server.httpservicesetup.md
index 92bf158ad3312..eec63cf5c8093 100644
--- a/docs/development/core/server/kibana-plugin-server.httpservicesetup.md
+++ b/docs/development/core/server/kibana-plugin-server.httpservicesetup.md
@@ -10,6 +10,6 @@
```typescript
export declare type HttpServiceSetup = Omit & {
createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter;
- registerRouteHandlerContext: (pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
+ registerRouteHandlerContext: (pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
};
```
diff --git a/docs/development/core/server/kibana-plugin-server.icontextcontainer.createhandler.md b/docs/development/core/server/kibana-plugin-server.icontextcontainer.createhandler.md
index c5549ab017e53..09a9e28d6d0fe 100644
--- a/docs/development/core/server/kibana-plugin-server.icontextcontainer.createhandler.md
+++ b/docs/development/core/server/kibana-plugin-server.icontextcontainer.createhandler.md
@@ -9,7 +9,7 @@ Create a new handler function pre-wired to context for the plugin.
Signature:
```typescript
-createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler): (...rest: THandlerParameters) => THandlerReturn extends Promise ? THandlerReturn : Promise;
+createHandler(pluginOpaqueId: PluginOpaqueId, handler: THandler): (...rest: HandlerParameters) => ShallowPromise>;
```
## Parameters
@@ -17,11 +17,11 @@ createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandlerPluginOpaqueId | The plugin opaque ID for the plugin that registers this handler. |
-| handler | IContextHandler<TContext, THandlerReturn, THandlerParameters> | Handler function to pass context object to. |
+| handler | THandler | Handler function to pass context object to. |
Returns:
-`(...rest: THandlerParameters) => THandlerReturn extends Promise ? THandlerReturn : Promise`
+`(...rest: HandlerParameters) => ShallowPromise>`
A function that takes `THandlerParameters`, calls `handler` with a new context, and returns a Promise of the `handler` return value.
diff --git a/docs/development/core/server/kibana-plugin-server.icontextcontainer.md b/docs/development/core/server/kibana-plugin-server.icontextcontainer.md
index 1ab699be105b4..114da31442ff9 100644
--- a/docs/development/core/server/kibana-plugin-server.icontextcontainer.md
+++ b/docs/development/core/server/kibana-plugin-server.icontextcontainer.md
@@ -9,7 +9,7 @@ An object that handles registration of context providers and configuring handler
Signature:
```typescript
-export interface IContextContainer
+export interface IContextContainer>
```
## Methods
diff --git a/docs/development/core/server/kibana-plugin-server.icontextcontainer.registercontext.md b/docs/development/core/server/kibana-plugin-server.icontextcontainer.registercontext.md
index 1a63f63dc91b4..30d3fc154d1e9 100644
--- a/docs/development/core/server/kibana-plugin-server.icontextcontainer.registercontext.md
+++ b/docs/development/core/server/kibana-plugin-server.icontextcontainer.registercontext.md
@@ -9,7 +9,7 @@ Register a new context provider.
Signature:
```typescript
-registerContext(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
+registerContext>(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
```
## Parameters
@@ -18,7 +18,7 @@ registerContext(pluginOpaqueId: PluginOpaqu
| --- | --- | --- |
| pluginOpaqueId | PluginOpaqueId | The plugin opaque ID for the plugin that registers this context. |
| contextName | TContextName | The key of the TContext object this provider supplies the value for. |
-| provider | IContextProvider<TContext, TContextName, THandlerParameters> | A [IContextProvider](./kibana-plugin-server.icontextprovider.md) to be called each time a new context is created. |
+| provider | IContextProvider<THandler, TContextName> | A [IContextProvider](./kibana-plugin-server.icontextprovider.md) to be called each time a new context is created. |
Returns:
diff --git a/docs/development/core/server/kibana-plugin-server.icontexthandler.md b/docs/development/core/server/kibana-plugin-server.icontexthandler.md
deleted file mode 100644
index c1f5acc22734a..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.icontexthandler.md
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [IContextHandler](./kibana-plugin-server.icontexthandler.md)
-
-## IContextHandler type
-
-A function registered by a plugin to perform some action.
-
-Signature:
-
-```typescript
-export declare type IContextHandler = (context: TContext, ...rest: THandlerParameters) => TReturn;
-```
-
-## Remarks
-
-A new `TContext` will be built for each handler before invoking.
-
diff --git a/docs/development/core/server/kibana-plugin-server.icontextprovider.md b/docs/development/core/server/kibana-plugin-server.icontextprovider.md
index 250e6a2be3f6a..39ace8b9bc57e 100644
--- a/docs/development/core/server/kibana-plugin-server.icontextprovider.md
+++ b/docs/development/core/server/kibana-plugin-server.icontextprovider.md
@@ -9,7 +9,7 @@ A function that returns a context value for a specific key of given context type
Signature:
```typescript
-export declare type IContextProvider, TContextName extends keyof TContext, TProviderParameters extends any[] = []> = (context: Partial, ...rest: TProviderParameters) => Promise | TContext[TContextName];
+export declare type IContextProvider, TContextName extends keyof HandlerContextType> = (context: Partial>, ...rest: HandlerParameters) => Promise[TContextName]> | HandlerContextType[TContextName];
```
## Remarks
diff --git a/docs/development/core/server/kibana-plugin-server.md b/docs/development/core/server/kibana-plugin-server.md
index d943228bbea06..3c01e7aeef325 100644
--- a/docs/development/core/server/kibana-plugin-server.md
+++ b/docs/development/core/server/kibana-plugin-server.md
@@ -116,11 +116,13 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | |
| [GetAuthHeaders](./kibana-plugin-server.getauthheaders.md) | Get headers to authenticate a user against Elasticsearch. |
| [GetAuthState](./kibana-plugin-server.getauthstate.md) | Get authentication state for a request. Returned by auth interceptor. |
+| [HandlerContextType](./kibana-plugin-server.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md) to represent the type of the context. |
+| [HandlerFunction](./kibana-plugin-server.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-server.icontextcontainer.md) |
+| [HandlerParameters](./kibana-plugin-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md), excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md). |
| [Headers](./kibana-plugin-server.headers.md) | Http request headers to read. |
| [HttpResponsePayload](./kibana-plugin-server.httpresponsepayload.md) | Data send to the client as a response payload. |
| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | |
| [IBasePath](./kibana-plugin-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-server.basepath.md) |
-| [IContextHandler](./kibana-plugin-server.icontexthandler.md) | A function registered by a plugin to perform some action. |
| [IContextProvider](./kibana-plugin-server.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
| [IsAuthenticated](./kibana-plugin-server.isauthenticated.md) | Return authentication status for a request. |
| [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
@@ -136,8 +138,6 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [RequestHandler](./kibana-plugin-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) functions. |
| [RequestHandlerContextContainer](./kibana-plugin-server.requesthandlercontextcontainer.md) | An object that handles registration of http request context providers. |
| [RequestHandlerContextProvider](./kibana-plugin-server.requesthandlercontextprovider.md) | Context provider for request handler. Extends request context object with provided functionality or data. |
-| [RequestHandlerParams](./kibana-plugin-server.requesthandlerparams.md) | Parameters passed to the request handler function. |
-| [RequestHandlerReturn](./kibana-plugin-server.requesthandlerreturn.md) | Expected outcome the request handler function. |
| [ResponseError](./kibana-plugin-server.responseerror.md) | Error message and optional data send to the client in case of error. |
| [ResponseErrorAttributes](./kibana-plugin-server.responseerrorattributes.md) | Additional data to provide error details. |
| [ResponseHeaders](./kibana-plugin-server.responseheaders.md) | Http response headers to set. |
diff --git a/docs/development/core/server/kibana-plugin-server.requesthandlercontextcontainer.md b/docs/development/core/server/kibana-plugin-server.requesthandlercontextcontainer.md
index afdb488597069..b76a9ce7d235c 100644
--- a/docs/development/core/server/kibana-plugin-server.requesthandlercontextcontainer.md
+++ b/docs/development/core/server/kibana-plugin-server.requesthandlercontextcontainer.md
@@ -9,5 +9,5 @@ An object that handles registration of http request context providers.
Signature:
```typescript
-export declare type RequestHandlerContextContainer = IContextContainer, RequestHandlerParams>;
+export declare type RequestHandlerContextContainer = IContextContainer>;
```
diff --git a/docs/development/core/server/kibana-plugin-server.requesthandlercontextprovider.md b/docs/development/core/server/kibana-plugin-server.requesthandlercontextprovider.md
index 0d9cc6b70b80c..ea7294b721aab 100644
--- a/docs/development/core/server/kibana-plugin-server.requesthandlercontextprovider.md
+++ b/docs/development/core/server/kibana-plugin-server.requesthandlercontextprovider.md
@@ -9,5 +9,5 @@ Context provider for request handler. Extends request context object with provid
Signature:
```typescript
-export declare type RequestHandlerContextProvider = IContextProvider;
+export declare type RequestHandlerContextProvider = IContextProvider, TContextName>;
```
diff --git a/docs/development/core/server/kibana-plugin-server.requesthandlerparams.md b/docs/development/core/server/kibana-plugin-server.requesthandlerparams.md
deleted file mode 100644
index 7f466845b4d46..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.requesthandlerparams.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RequestHandlerParams](./kibana-plugin-server.requesthandlerparams.md)
-
-## RequestHandlerParams type
-
-Parameters passed to the request handler function.
-
-Signature:
-
-```typescript
-export declare type RequestHandlerParams = [KibanaRequest, KibanaResponseFactory];
-```
diff --git a/docs/development/core/server/kibana-plugin-server.requesthandlerreturn.md b/docs/development/core/server/kibana-plugin-server.requesthandlerreturn.md
deleted file mode 100644
index 6c01e21b6ecbe..0000000000000
--- a/docs/development/core/server/kibana-plugin-server.requesthandlerreturn.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [RequestHandlerReturn](./kibana-plugin-server.requesthandlerreturn.md)
-
-## RequestHandlerReturn type
-
-Expected outcome the request handler function.
-
-Signature:
-
-```typescript
-export declare type RequestHandlerReturn = KibanaResponse;
-```
diff --git a/docs/management/index-patterns.asciidoc b/docs/management/index-patterns.asciidoc
index 25c07dc502484..8d9ef515108ed 100644
--- a/docs/management/index-patterns.asciidoc
+++ b/docs/management/index-patterns.asciidoc
@@ -35,8 +35,11 @@ image:management/index-patterns/images/rollup-index-pattern.png["Menu with rollu
{kib} makes it easy for you to create an index pattern by walking you through
the process. Just start typing in the *Index pattern* field, and {kib} looks for
-the names of {es} indices that match your input. If you want to include
-system indices in your search, toggle the switch in the upper right.
+the names of {es} indices that match your input. Make sure that the name of the
+index pattern is unique.
+
+If you want to include system indices in your search, toggle the switch in the
+upper right.
[role="screenshot"]
image:management/index-patterns/images/create-index-pattern.png["Create index pattern"]
diff --git a/docs/settings/monitoring-settings.asciidoc b/docs/settings/monitoring-settings.asciidoc
index 7330c7e144b60..97fb891c95bdb 100644
--- a/docs/settings/monitoring-settings.asciidoc
+++ b/docs/settings/monitoring-settings.asciidoc
@@ -21,7 +21,7 @@ To control how data is collected from your {es} nodes, you configure
{ref}/monitoring-settings.html[`xpack.monitoring.collection`
settings] in `elasticsearch.yml`. To control how monitoring data is collected
from Logstash, you configure
-{logstash-ref}/configuring-logstash.html#monitoring-settings[`xpack.monitoring` settings]
+{logstash-ref}/monitoring-internal-collection.html#monitoring-settings[`xpack.monitoring` settings]
in `logstash.yml`.
For more information, see
diff --git a/package.json b/package.json
index 8aff95748560d..fb65efdde6912 100644
--- a/package.json
+++ b/package.json
@@ -240,7 +240,7 @@
"style-loader": "0.23.1",
"symbol-observable": "^1.2.0",
"tar": "4.4.13",
- "terser-webpack-plugin": "^1.4.1",
+ "terser-webpack-plugin": "^2.1.2",
"thread-loader": "^2.1.3",
"tinygradient": "0.4.3",
"tinymath": "1.2.1",
diff --git a/packages/kbn-es-query/src/es_query/index.d.ts b/packages/kbn-es-query/src/es_query/index.d.ts
new file mode 100644
index 0000000000000..9510a18441e53
--- /dev/null
+++ b/packages/kbn-es-query/src/es_query/index.d.ts
@@ -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.
+ */
+
+export function buildQueryFromFilters(filters: unknown[], indexPattern: unknown): unknown;
+export function buildEsQuery(
+ indexPattern: unknown,
+ queries: unknown,
+ filters: unknown,
+ config?: {
+ allowLeadingWildcards: boolean;
+ queryStringOptions: unknown;
+ ignoreFilterIfFieldNotInIndex: boolean;
+ dateFormatTZ?: string | null;
+ }
+): unknown;
+export function getEsQueryConfig(config: {
+ get: (name: string) => unknown;
+}): {
+ allowLeadingWildcards: boolean;
+ queryStringOptions: unknown;
+ ignoreFilterIfFieldNotInIndex: boolean;
+ dateFormatTZ?: string | null;
+};
diff --git a/packages/kbn-es-query/src/index.d.ts b/packages/kbn-es-query/src/index.d.ts
index 873636a28889f..ca4455da33f45 100644
--- a/packages/kbn-es-query/src/index.d.ts
+++ b/packages/kbn-es-query/src/index.d.ts
@@ -17,5 +17,6 @@
* under the License.
*/
+export * from './es_query';
export * from './kuery';
export * from './filters';
diff --git a/renovate.json5 b/renovate.json5
index e5dd29aa63190..cd836762b817f 100644
--- a/renovate.json5
+++ b/renovate.json5
@@ -67,6 +67,17 @@
'(\\b|_)jest(\\b|_)',
],
},
+ {
+ groupSlug: '@elastic/charts',
+ groupName: '@elastic/charts related packages',
+ packageNames: [
+ '@elastic/charts',
+ '@types/elastic__charts',
+ ],
+ reviewers: [
+ 'markov00',
+ ],
+ },
{
groupSlug: 'mocha',
groupName: 'mocha related packages',
diff --git a/rfcs/text/0006_management_section_service.md b/rfcs/text/0006_management_section_service.md
new file mode 100644
index 0000000000000..bcb74b1bcd8da
--- /dev/null
+++ b/rfcs/text/0006_management_section_service.md
@@ -0,0 +1,332 @@
+- Start Date: 2019-08-20
+- RFC PR: TBD
+- Kibana Issue: [#43499](https://github.com/elastic/kibana/issues/43499)
+
+# Summary
+Management is one of the four primary "domains" covered by @elastic/kibana-app-arch (along with Data, Embeddables, and Visualizations). There are two main purposes for this service:
+
+1. Own the management "framework" -- the UI that displays the management sidebar nav, the landing page, and handles rendering each of the sections
+2. Expose a registry for other plugins to add their own registry sections to the UI and add nested links to them in the sidebar.
+
+The purpose of this RFC is to consider item 2 above -- the service for registering sections to the nav & loading them up.
+
+# Motivation
+
+## Why now?
+The main driver for considering this now is that the Management API moving to the new platform is going to block other teams from completing migration, so we need to have an answer to what the new platform version of the API looks like as soon as possible in `7.x`.
+
+## Why not just keep the current API and redesign later?
+The answer to that has to do with the items that are currently used in the management implementation which must be removed in order to migrate to NP: the framework currently registers a `uiExport`, and relies on `IndexedArray`, `uiRegistry`, and `ui/routes`.
+
+This means that we will basically need to rebuild the service anyway in order to migrate to the new platform. So if we are going to invest that time, we might as well invest it in building the API the way we want it to be longer term, rather than creating more work for ourselves later.
+
+## Technical goals
+- Remove another usage of `IndexedArray` & `uiRegistry` (required for migration)
+- Remove dependency on `ui/routes` (required for migration)
+- Remove management section `uiExport` (required for migration)
+- Simple API that is designed in keeping with new platform principles
+ - This includes being rendering-framework-agnostic... You should be able to build your management section UI however you'd like
+- Clear separation of app/UI code and service code, even if both live within the same plugin
+- Flexibility to potentially support alternate layouts in the future (see mockups in [reference section](#reference) below)
+
+# Basic example
+This API is influenced heavily by the [application service mounting RFC](https://github.com/elastic/kibana/blob/master/rfcs/text/0004_application_service_mounting.md). The intent is to make the experience consistent with that service; the Management section is basically one big app with a bunch of registered "subapps".
+
+```ts
+// my_plugin/public/plugin.ts
+
+export class MyPlugin {
+ setup(core, { management }) {
+ // Registering a new app to a new section
+ const mySection = management.sections.register({
+ id: 'my-section',
+ title: 'My Main Section', // display name
+ order: 10,
+ euiIconType: 'iconName',
+ });
+ mySection.registerApp({
+ id: 'my-management-app',
+ title: 'My Management App', // display name
+ order: 20,
+ async mount(context, params) {
+ const { renderApp } = await import('./my-section');
+ return renderApp(context, params);
+ }
+ });
+
+ // Registering a new app to an existing section
+ const kibanaSection = management.sections.get('kibana');
+ kibanaSection.registerApp({ id: 'my-kibana-management-app', ... });
+ }
+
+ start(core, { management }) {
+ // access all registered sections, filtered based on capabilities
+ const sections = management.sections.getAvailable();
+ sections.forEach(section => console.log(`${section.id} - ${section.title}`));
+ // automatically navigate to any app by id
+ management.sections.navigateToApp('my-kibana-management-app');
+ }
+}
+
+// my_plugin/public/my-section.tsx
+
+export function renderApp(context, { sectionBasePath, element }) {
+ ReactDOM.render(
+ // `sectionBasePath` would be `/app/management/my-section/my-management-app`
+ ,
+ element
+ );
+
+ // return value must be a function that unmounts (just like Core Application Service)
+ return () => ReactDOM.unmountComponentAtNode(element);
+}
+```
+
+We can also create a utility in `kibana_react` to make it easy for folks to `mount` a React app:
+```ts
+// src/plugins/kibana_react/public/mount_with_react.tsx
+import { KibanaContextProvider } from './context';
+
+export const mountWithReact = (
+ Component: React.ComponentType<{ basename: string }>,
+ context: AppMountContext,
+ params: ManagementSectionMountParams,
+) => {
+ ReactDOM.render(
+ (
+
+
+
+ ),
+ params.element
+ );
+
+ return () => ReactDOM.unmountComponentAtNode(params.element);
+}
+
+// my_plugin/public/plugin.ts
+import { mountWithReact } from 'src/plugins/kibana_react/public';
+
+export class MyPlugin {
+ setup(core, { management }) {
+ const kibanaSection = management.sections.get('kibana');
+ kibanaSection.registerApp({
+ id: 'my-other-kibana-management-app',
+ ...,
+ async mount(context, params) {
+ const { MySection } = await import('./components/my-section');
+ const unmountCallback = mountWithReact(MySection, context, params);
+ return () => unmountCallback();
+ }
+ });
+ }
+}
+```
+
+# Detailed design
+
+```ts
+interface ManagementSetup {
+ sections: SectionsServiceSetup;
+}
+
+interface ManagementStart {
+ sections: SectionsServiceStart;
+}
+
+interface SectionsServiceSetup {
+ get: (sectionId: string) => Section;
+ getAvailable: () => Section[]; // filtered based on capabilities
+ register: RegisterSection;
+}
+
+interface SectionsServiceStart {
+ getAvailable: () => Array>; // filtered based on capabilities
+ // uses `core.application.navigateToApp` under the hood, automatically prepending the `path` for the link
+ navigateToApp: (appId: string, options?: { path?: string; state?: any }) => void;
+}
+
+type RegisterSection = (
+ id: string,
+ title: string,
+ order?: number,
+ euiIconType?: string, // takes precedence over `icon` property.
+ icon?: string, // URL to image file; fallback if no `euiIconType`
+) => Section;
+
+type RegisterManagementApp = (
+ id: string;
+ title: string;
+ order?: number;
+ mount: ManagementSectionMount;
+) => ManagementApp;
+
+type Unmount = () => Promise | void;
+
+interface ManagementSectionMountParams {
+ sectionBasePath: string; // base path for setting up your router
+ element: HTMLElement; // element the section should render into
+}
+
+type ManagementSectionMount = (
+ context: AppMountContext, // provided by core.ApplicationService
+ params: ManagementSectionMountParams,
+) => Unmount | Promise;
+
+interface ManagementApp {
+ id: string;
+ title: string;
+ basePath: string;
+ sectionId: string;
+ order?: number;
+}
+
+interface Section {
+ id: string;
+ title: string;
+ apps: ManagementApp[];
+ registerApp: RegisterManagementApp;
+ order?: number;
+ euiIconType?: string;
+ icon?: string;
+}
+```
+
+# Legacy service (what this would be replacing)
+
+Example of how this looks today:
+```js
+// myplugin/index
+new Kibana.Plugin({
+ uiExports: {
+ managementSections: ['myplugin/management'],
+ }
+});
+
+// myplugin/public/management
+import { management } from 'ui/management';
+
+// completely new section
+const newSection = management.register('mypluginsection', {
+ name: 'mypluginsection',
+ order: 10,
+ display: 'My Plugin',
+ icon: 'iconName',
+});
+newSection.register('mypluginlink', {
+ name: 'mypluginlink',
+ order: 10,
+ display: 'My sublink',
+ url: `#/management/myplugin`,
+});
+
+// new link in existing section
+const kibanaSection = management.getSection('kibana');
+kibanaSection.register('mypluginlink', {
+ name: 'mypluginlink',
+ order: 10,
+ display: 'My sublink',
+ url: `#/management/myplugin`,
+});
+
+// use ui/routes to render component
+import routes from 'ui/routes';
+
+const renderReact = (elem) => {
+ render(, elem);
+};
+
+routes.when('management/myplugin', {
+ controller($scope, $http, kbnUrl) {
+ $scope.$on('$destroy', () => {
+ const elem = document.getElementById('usersReactRoot');
+ if (elem) unmountComponentAtNode(elem);
+ });
+ $scope.$$postDigest(() => {
+ const elem = document.getElementById('usersReactRoot');
+ const changeUrl = (url) => {
+ kbnUrl.change(url);
+ $scope.$apply();
+ };
+ renderReact(elem, $http, changeUrl);
+ });
+ },
+});
+```
+Current public contracts owned by the legacy service:
+```js
+// ui/management/index
+interface API {
+ PAGE_TITLE_COMPONENT: string; // actually related to advanced settings?
+ PAGE_SUBTITLE_COMPONENT: string; // actually related to advanced settings?
+ PAGE_FOOTER_COMPONENT: string; // actually related to advanced settings?
+ SidebarNav: React.SFC;
+ registerSettingsComponent: (
+ id: string,
+ component: string | React.SFC,
+ allowOverride: boolean
+ ) => void;
+ management: new ManagementSection();
+ MANAGEMENT_BREADCRUMB: {
+ text: string;
+ href: string;
+ };
+}
+
+// ui/management/section
+class ManagementSection {
+ get visibleItems,
+ addListener: (fn: function) => void,
+ register: (id: string, options: Options) => ManagementSection,
+ deregister: (id: string) => void,
+ hasItem: (id: string) => boolean,
+ getSection: (id: string) => ManagementSection,
+ hide: () => void,
+ show: () => void,
+ disable: () => void,
+ enable: () => void,
+}
+
+interface Options {
+ order: number | null;
+ display: string | null; // defaults to id
+ url: string | null; // defaults to ''
+ visible: boolean | null; // defaults to true
+ disabled: boolean | null; // defaults to false
+ tooltip: string | null; // defaults to ''
+ icon: string | null; // defaults to ''
+}
+```
+
+# Notes
+
+- The hide/show/disable/enable options were dropped with the assumption that we will be working with uiCapabilities to determine this instead... so people shouldn't need to manage it manually as they can look up a pre-filtered list of sections.
+- This was updated to add flexibility for custom (non-EUI) icons as outlined in [#32661](https://github.com/elastic/kibana/issues/32661). Much like the Core Application Service, you either choose an EUI icon, or provide a URL to an icon.
+
+# Drawbacks
+
+- This removes the ability to infinitely nest sections within each other by making a distinction between a section header and a nav link.
+ - So far we didn't seem to be using this feature anyway, but would like feedback on any use cases for it.
+
+# Reference
+
+- Issues about Global vs Spaces-based management sections: https://github.com/elastic/kibana/issues/37285 https://github.com/elastic/kibana/issues/37283
+- Mockups related to above issues: https://marvelapp.com/52b8616/screen/57582729
+
+# Alternatives
+
+An alternative design would be making everything React-specific and simply requiring consumers of the service to provide a React component to render when a route is hit, or giving them a react-router instance to work with.
+
+This would require slightly less work for folks using the service as it would eliminate the need for a `mount` function. However, it comes at the cost of forcing folks into a specific rendering framework, which ultimately provides less flexibility.
+
+# Adoption strategy
+
+Our strategy for implementing this should be to build the service entirely in the new platform in a `management` plugin, so that plugins can gradually cut over to the new service as they prepare to migrate to the new platform.
+
+One thing we would need to figure out is how to bridge the gap between the new plugin and the legacy `ui/management` service. Ideally we would find a way to integrate the two, such that the management nav could display items registered via both services. This is a strategy we'd need to work out in more detail as we got closer to implementation.
+
+# How we teach this
+
+The hope is that this will already feel familiar to Kibana application developers, as most will have already been exposed to the Core Application Service and how it handles mounting.
+
+A guide could also be added to the "Management" section of the Kibana docs (the legacy service is not even formally documented).
diff --git a/src/core/public/application/application_service.tsx b/src/core/public/application/application_service.tsx
index d1855a0370f00..935844baddf86 100644
--- a/src/core/public/application/application_service.tsx
+++ b/src/core/public/application/application_service.tsx
@@ -27,12 +27,9 @@ import { AppRouter } from './ui';
import { HttpStart } from '../http';
import { ContextSetup, IContextContainer } from '../context';
import {
- AppMountContext,
App,
LegacyApp,
AppMounter,
- AppUnmount,
- AppMountParameters,
InternalApplicationSetup,
InternalApplicationStart,
} from './types';
@@ -64,11 +61,7 @@ export class ApplicationService {
private readonly apps$ = new BehaviorSubject>(new Map());
private readonly legacyApps$ = new BehaviorSubject>(new Map());
private readonly capabilities = new CapabilitiesService();
- private mountContext?: IContextContainer<
- AppMountContext,
- AppUnmount | Promise,
- [AppMountParameters]
- >;
+ private mountContext?: IContextContainer;
public setup({ context }: SetupDeps): InternalApplicationSetup {
this.mountContext = context.createContextContainer();
@@ -98,7 +91,7 @@ export class ApplicationService {
this.legacyApps$.next(new Map([...this.legacyApps$.value.entries(), [app.id, app]]));
},
- registerMountContext: this.mountContext.registerContext,
+ registerMountContext: this.mountContext!.registerContext,
};
}
diff --git a/src/core/public/application/types.ts b/src/core/public/application/types.ts
index 018d7569ce411..b2d0aff26b8b0 100644
--- a/src/core/public/application/types.ts
+++ b/src/core/public/application/types.ts
@@ -193,7 +193,7 @@ export interface ApplicationSetup {
*/
registerMountContext(
contextName: T,
- provider: IContextProvider
+ provider: IContextProvider
): void;
}
@@ -224,7 +224,7 @@ export interface InternalApplicationSetup {
registerMountContext(
pluginOpaqueId: PluginOpaqueId,
contextName: T,
- provider: IContextProvider
+ provider: IContextProvider
): void;
}
@@ -261,7 +261,7 @@ export interface ApplicationStart {
*/
registerMountContext(
contextName: T,
- provider: IContextProvider
+ provider: IContextProvider
): void;
}
@@ -291,7 +291,7 @@ export interface InternalApplicationStart
registerMountContext(
pluginOpaqueId: PluginOpaqueId,
contextName: T,
- provider: IContextProvider
+ provider: IContextProvider
): void;
// Internal APIs
diff --git a/src/core/public/chrome/ui/header/header.tsx b/src/core/public/chrome/ui/header/header.tsx
index afd9f8e4a3820..f24b0ed1681aa 100644
--- a/src/core/public/chrome/ui/header/header.tsx
+++ b/src/core/public/chrome/ui/header/header.tsx
@@ -19,7 +19,7 @@
import Url from 'url';
-import React, { Component, createRef, Fragment } from 'react';
+import React, { Component, createRef } from 'react';
import * as Rx from 'rxjs';
import {
@@ -376,7 +376,7 @@ class HeaderUI extends Component {
];
return (
-
+
@@ -407,11 +407,13 @@ class HeaderUI extends Component {
isLocked={isLocked}
onIsLockedUpdate={onIsLockedUpdate}
>
-
-
-
+
-
+
);
}
diff --git a/src/core/public/context/context_service.ts b/src/core/public/context/context_service.ts
index 704524d838636..dadc509c97821 100644
--- a/src/core/public/context/context_service.ts
+++ b/src/core/public/context/context_service.ts
@@ -18,7 +18,7 @@
*/
import { PluginOpaqueId } from '../../server';
-import { IContextContainer, ContextContainer } from '../../utils/context';
+import { IContextContainer, ContextContainer, HandlerFunction } from '../../utils/context';
import { CoreContext } from '../core_system';
interface StartDeps {
@@ -31,15 +31,8 @@ export class ContextService {
public setup({ pluginDependencies }: StartDeps): ContextSetup {
return {
- createContextContainer: <
- TContext extends {},
- THandlerReturn,
- THandlerParameters extends any[] = []
- >() =>
- new ContextContainer(
- pluginDependencies,
- this.core.coreId
- ),
+ createContextContainer: >() =>
+ new ContextContainer(pluginDependencies, this.core.coreId),
};
}
}
@@ -111,9 +104,5 @@ export interface ContextSetup {
/**
* Creates a new {@link IContextContainer} for a service owner.
*/
- createContextContainer<
- TContext extends {},
- THandlerReturn,
- THandlerParmaters extends any[] = []
- >(): IContextContainer;
+ createContextContainer>(): IContextContainer;
}
diff --git a/src/core/public/context/index.ts b/src/core/public/context/index.ts
index 28b2641b2a5a7..f22c4168d7544 100644
--- a/src/core/public/context/index.ts
+++ b/src/core/public/context/index.ts
@@ -18,4 +18,10 @@
*/
export { ContextService, ContextSetup } from './context_service';
-export { IContextContainer, IContextProvider, IContextHandler } from '../../utils/context';
+export {
+ IContextContainer,
+ IContextProvider,
+ HandlerFunction,
+ HandlerContextType,
+ HandlerParameters,
+} from '../../utils/context';
diff --git a/src/core/public/index.ts b/src/core/public/index.ts
index 393a7076759e8..1e2dfde7496ea 100644
--- a/src/core/public/index.ts
+++ b/src/core/public/index.ts
@@ -67,7 +67,14 @@ import { UiSettingsClient, UiSettingsState, UiSettingsClientContract } from './u
import { ApplicationSetup, Capabilities, ApplicationStart } from './application';
import { DocLinksStart } from './doc_links';
import { SavedObjectsStart } from './saved_objects';
-import { IContextContainer, IContextProvider, ContextSetup, IContextHandler } from './context';
+import {
+ IContextContainer,
+ IContextProvider,
+ ContextSetup,
+ HandlerFunction,
+ HandlerContextType,
+ HandlerParameters,
+} from './context';
export { CoreContext, CoreSystem } from './core_system';
export { RecursiveReadonly } from '../utils';
@@ -217,7 +224,9 @@ export {
ChromeRecentlyAccessedHistoryItem,
ChromeStart,
IContextContainer,
- IContextHandler,
+ HandlerFunction,
+ HandlerContextType,
+ HandlerParameters,
IContextProvider,
ContextSetup,
DocLinksStart,
diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md
index 102e77b564a6d..e6c8f116e5782 100644
--- a/src/core/public/public.api.md
+++ b/src/core/public/public.api.md
@@ -9,6 +9,7 @@ import { MouseEventHandler } from 'react';
import { Observable } from 'rxjs';
import React from 'react';
import * as Rx from 'rxjs';
+import { ShallowPromise } from '@kbn/utility-types';
import { EuiGlobalToastListToast as Toast } from '@elastic/eui';
// @public
@@ -31,7 +32,7 @@ export interface AppBase {
// @public (undocumented)
export interface ApplicationSetup {
register(app: App): void;
- registerMountContext(contextName: T, provider: IContextProvider): void;
+ registerMountContext(contextName: T, provider: IContextProvider): void;
}
// @public (undocumented)
@@ -44,7 +45,7 @@ export interface ApplicationStart {
path?: string;
state?: any;
}): void;
- registerMountContext(contextName: T, provider: IContextProvider): void;
+ registerMountContext(contextName: T, provider: IContextProvider): void;
}
// @public
@@ -213,7 +214,7 @@ export interface ChromeStart {
// @public
export interface ContextSetup {
- createContextContainer(): IContextContainer;
+ createContextContainer>(): IContextContainer;
}
// @internal (undocumented)
@@ -389,6 +390,15 @@ export interface FatalErrorsSetup {
get$: () => Rx.Observable;
}
+// @public
+export type HandlerContextType> = T extends HandlerFunction ? U : never;
+
+// @public
+export type HandlerFunction = (context: T, ...args: any[]) => any;
+
+// @public
+export type HandlerParameters> = T extends (context: any, ...args: infer U) => any ? U : never;
+
// @public (undocumented)
export type HttpBody = BodyInit | null | any;
@@ -551,16 +561,13 @@ export interface I18nStart {
}
// @public
-export interface IContextContainer {
- createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler): (...rest: THandlerParameters) => THandlerReturn extends Promise ? THandlerReturn : Promise;
- registerContext(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
+export interface IContextContainer> {
+ createHandler(pluginOpaqueId: PluginOpaqueId, handler: THandler): (...rest: HandlerParameters) => ShallowPromise>;
+ registerContext>(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
}
// @public
-export type IContextHandler = (context: TContext, ...rest: THandlerParameters) => TReturn;
-
-// @public
-export type IContextProvider, TContextName extends keyof TContext, TProviderParameters extends any[] = []> = (context: Partial, ...rest: TProviderParameters) => Promise | TContext[TContextName];
+export type IContextProvider, TContextName extends keyof HandlerContextType> = (context: Partial>, ...rest: HandlerParameters) => Promise[TContextName]> | HandlerContextType[TContextName];
// @public @deprecated
export interface LegacyCoreSetup extends CoreSetup {
diff --git a/src/core/server/context/context_service.ts b/src/core/server/context/context_service.ts
index 80935840c5536..1c5bd41a01f0f 100644
--- a/src/core/server/context/context_service.ts
+++ b/src/core/server/context/context_service.ts
@@ -18,7 +18,7 @@
*/
import { PluginOpaqueId } from '../../server';
-import { IContextContainer, ContextContainer } from '../../utils/context';
+import { IContextContainer, ContextContainer, HandlerFunction } from '../../utils/context';
import { CoreContext } from '../core_context';
interface SetupDeps {
@@ -31,15 +31,8 @@ export class ContextService {
public setup({ pluginDependencies }: SetupDeps): ContextSetup {
return {
- createContextContainer: <
- TContext extends {},
- THandlerReturn,
- THandlerParameters extends any[] = []
- >() => {
- return new ContextContainer(
- pluginDependencies,
- this.core.coreId
- );
+ createContextContainer: >() => {
+ return new ContextContainer(pluginDependencies, this.core.coreId);
},
};
}
@@ -112,9 +105,5 @@ export interface ContextSetup {
/**
* Creates a new {@link IContextContainer} for a service owner.
*/
- createContextContainer<
- TContext extends {},
- THandlerReturn,
- THandlerParmaters extends any[] = []
- >(): IContextContainer;
+ createContextContainer>(): IContextContainer;
}
diff --git a/src/core/server/context/index.ts b/src/core/server/context/index.ts
index 28b2641b2a5a7..f22c4168d7544 100644
--- a/src/core/server/context/index.ts
+++ b/src/core/server/context/index.ts
@@ -18,4 +18,10 @@
*/
export { ContextService, ContextSetup } from './context_service';
-export { IContextContainer, IContextProvider, IContextHandler } from '../../utils/context';
+export {
+ IContextContainer,
+ IContextProvider,
+ HandlerFunction,
+ HandlerContextType,
+ HandlerParameters,
+} from '../../utils/context';
diff --git a/src/core/server/http/http_service.ts b/src/core/server/http/http_service.ts
index 5814991a2dd27..0ac5ad9276353 100644
--- a/src/core/server/http/http_service.ts
+++ b/src/core/server/http/http_service.ts
@@ -83,8 +83,8 @@ export type HttpServiceSetup = Omit & {
registerRouteHandlerContext: (
pluginOpaqueId: PluginOpaqueId,
contextName: T,
- provider: RequestHandlerContextProvider
- ) => RequestHandlerContextContainer;
+ provider: RequestHandlerContextProvider
+ ) => RequestHandlerContextContainer;
};
/** @public */
@@ -103,7 +103,7 @@ export class HttpService implements CoreService;
+ private requestHandlerContext?: RequestHandlerContextContainer;
constructor(private readonly coreContext: CoreContext) {
this.logger = coreContext.logger;
@@ -150,7 +150,7 @@ export class HttpService implements CoreService(
pluginOpaqueId: PluginOpaqueId,
contextName: T,
- provider: RequestHandlerContextProvider
+ provider: RequestHandlerContextProvider
) => this.requestHandlerContext!.registerContext(pluginOpaqueId, contextName, provider),
};
diff --git a/src/core/server/http/types.ts b/src/core/server/http/types.ts
index a391b2e2e5d45..cade4ea4d4f2c 100644
--- a/src/core/server/http/types.ts
+++ b/src/core/server/http/types.ts
@@ -16,30 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { IContextProvider, IContextContainer } from '../context';
-import { KibanaRequest, KibanaResponseFactory, KibanaResponse } from './router';
-
-/**
- * Parameters passed to the request handler function.
- * @public
- */
-export type RequestHandlerParams = [KibanaRequest, KibanaResponseFactory];
-/**
- * Expected outcome the request handler function.
- * @public
- */
-export type RequestHandlerReturn = KibanaResponse;
+import { IContextProvider, IContextContainer } from '../context';
+import { RequestHandler } from './router';
+import { RequestHandlerContext } from '..';
/**
* An object that handles registration of http request context providers.
* @public
*/
-export type RequestHandlerContextContainer = IContextContainer<
- TContext,
- RequestHandlerReturn | Promise,
- RequestHandlerParams
->;
+export type RequestHandlerContextContainer = IContextContainer>;
/**
* Context provider for request handler.
@@ -47,8 +33,6 @@ export type RequestHandlerContextContainer = IContextContainer<
*
* @public
*/
-export type RequestHandlerContextProvider = IContextProvider<
- TContext,
- keyof TContext,
- RequestHandlerParams
->;
+export type RequestHandlerContextProvider<
+ TContextName extends keyof RequestHandlerContext
+> = IContextProvider, TContextName>;
diff --git a/src/core/server/index.ts b/src/core/server/index.ts
index d3fe64ddc1e0d..ca497e0f2d32d 100644
--- a/src/core/server/index.ts
+++ b/src/core/server/index.ts
@@ -59,7 +59,13 @@ import { SavedObjectsServiceStart } from './saved_objects';
export { bootstrap } from './bootstrap';
export { ConfigPath, ConfigService } from './config';
-export { IContextContainer, IContextProvider, IContextHandler } from './context';
+export {
+ IContextContainer,
+ IContextProvider,
+ HandlerFunction,
+ HandlerContextType,
+ HandlerParameters,
+} from './context';
export { CoreId } from './core_context';
export {
CallAPIOptions,
@@ -102,8 +108,6 @@ export {
RequestHandler,
RequestHandlerContextContainer,
RequestHandlerContextProvider,
- RequestHandlerParams,
- RequestHandlerReturn,
ResponseError,
ResponseErrorAttributes,
ResponseHeaders,
@@ -212,8 +216,8 @@ export interface CoreSetup {
isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
registerRouteHandlerContext: (
name: T,
- provider: RequestHandlerContextProvider
- ) => RequestHandlerContextContainer;
+ provider: RequestHandlerContextProvider
+ ) => RequestHandlerContextContainer;
createRouter: () => IRouter;
};
}
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index ae839644fc2e2..6451e2b9b7153 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -21,6 +21,7 @@ import { Request } from 'hapi';
import { ResponseObject } from 'hapi';
import { ResponseToolkit } from 'hapi';
import { Server } from 'hapi';
+import { ShallowPromise } from '@kbn/utility-types';
import { Stream } from 'stream';
import { Type } from '@kbn/config-schema';
import { TypeOf } from '@kbn/config-schema';
@@ -61,11 +62,11 @@ export interface AuthToolkit {
export class BasePath {
// @internal
constructor(serverBasePath?: string);
- get: (request: KibanaRequest | LegacyRequest) => string;
+ get: (request: LegacyRequest | KibanaRequest) => string;
prepend: (path: string) => string;
remove: (path: string) => string;
readonly serverBasePath: string;
- set: (request: KibanaRequest | LegacyRequest, requestSpecificBasePath: string) => void;
+ set: (request: LegacyRequest | KibanaRequest, requestSpecificBasePath: string) => void;
}
// Warning: (ae-forgotten-export) The symbol "BootstrapArgs" needs to be exported by the entry point index.d.ts
@@ -109,7 +110,7 @@ export class ConfigService {
// @public
export interface ContextSetup {
- createContextContainer(): IContextContainer;
+ createContextContainer>(): IContextContainer;
}
// @internal (undocumented)
@@ -135,7 +136,7 @@ export interface CoreSetup {
registerOnPostAuth: HttpServiceSetup['registerOnPostAuth'];
basePath: HttpServiceSetup['basePath'];
isTlsEnabled: HttpServiceSetup['isTlsEnabled'];
- registerRouteHandlerContext: (name: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
+ registerRouteHandlerContext: (name: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
createRouter: () => IRouter;
};
}
@@ -219,6 +220,15 @@ export type GetAuthState = (request: KibanaRequest | LegacyRequest) => {
state: unknown;
};
+// @public
+export type HandlerContextType> = T extends HandlerFunction ? U : never;
+
+// @public
+export type HandlerFunction = (context: T, ...args: any[]) => any;
+
+// @public
+export type HandlerParameters> = T extends (context: any, ...args: infer U) => any ? U : never;
+
// @public
export type Headers = {
[header in KnownHeaders]?: string | string[] | undefined;
@@ -258,7 +268,7 @@ export interface HttpServerSetup {
// @public (undocumented)
export type HttpServiceSetup = Omit & {
createRouter: (path: string, plugin?: PluginOpaqueId) => IRouter;
- registerRouteHandlerContext: (pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
+ registerRouteHandlerContext: (pluginOpaqueId: PluginOpaqueId, contextName: T, provider: RequestHandlerContextProvider) => RequestHandlerContextContainer;
};
// @public (undocumented)
@@ -270,16 +280,13 @@ export interface HttpServiceStart {
export type IBasePath = Pick;
// @public
-export interface IContextContainer {
- createHandler(pluginOpaqueId: PluginOpaqueId, handler: IContextHandler): (...rest: THandlerParameters) => THandlerReturn extends Promise ? THandlerReturn : Promise;
- registerContext(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
+export interface IContextContainer> {
+ createHandler(pluginOpaqueId: PluginOpaqueId, handler: THandler): (...rest: HandlerParameters) => ShallowPromise>;
+ registerContext>(pluginOpaqueId: PluginOpaqueId, contextName: TContextName, provider: IContextProvider): this;
}
// @public
-export type IContextHandler = (context: TContext, ...rest: THandlerParameters) => TReturn;
-
-// @public
-export type IContextProvider, TContextName extends keyof TContext, TProviderParameters extends any[] = []> = (context: Partial, ...rest: TProviderParameters) => Promise | TContext[TContextName];
+export type IContextProvider, TContextName extends keyof HandlerContextType> = (context: Partial>, ...rest: HandlerParameters) => Promise[TContextName]> | HandlerContextType[TContextName];
// @public
export interface IKibanaSocket {
@@ -602,16 +609,10 @@ export interface RequestHandlerContext {
}
// @public
-export type RequestHandlerContextContainer = IContextContainer, RequestHandlerParams>;
-
-// @public
-export type RequestHandlerContextProvider = IContextProvider;
-
-// @public
-export type RequestHandlerParams = [KibanaRequest, KibanaResponseFactory];
+export type RequestHandlerContextContainer = IContextContainer>;
// @public
-export type RequestHandlerReturn = KibanaResponse;
+export type RequestHandlerContextProvider = IContextProvider, TContextName>;
// @public
export type ResponseError = string | Error | {
diff --git a/src/core/utils/context.mock.ts b/src/core/utils/context.mock.ts
index 4d91c11542b2f..de844f3f0f07d 100644
--- a/src/core/utils/context.mock.ts
+++ b/src/core/utils/context.mock.ts
@@ -19,7 +19,7 @@
import { IContextContainer } from './context';
-export type ContextContainerMock = jest.Mocked>;
+export type ContextContainerMock = jest.Mocked>;
const createContextMock = () => {
const contextMock: ContextContainerMock = {
diff --git a/src/core/utils/context.test.ts b/src/core/utils/context.test.ts
index 1249c14736fb5..4bfeddc2e08c9 100644
--- a/src/core/utils/context.test.ts
+++ b/src/core/utils/context.test.ts
@@ -44,7 +44,7 @@ const coreId = Symbol();
describe('ContextContainer', () => {
it('does not allow the same context to be registered twice', () => {
- const contextContainer = new ContextContainer(plugins, coreId);
+ const contextContainer = new ContextContainer<(context: MyContext) => string>(plugins, coreId);
contextContainer.registerContext(coreId, 'ctxFromA', () => 'aString');
expect(() =>
@@ -56,7 +56,10 @@ describe('ContextContainer', () => {
describe('registerContext', () => {
it('throws error if called with an unknown symbol', async () => {
- const contextContainer = new ContextContainer(plugins, coreId);
+ const contextContainer = new ContextContainer<(context: MyContext) => string>(
+ plugins,
+ coreId
+ );
await expect(() =>
contextContainer.registerContext(Symbol('unknown'), 'ctxFromA', jest.fn())
).toThrowErrorMatchingInlineSnapshot(
@@ -67,7 +70,10 @@ describe('ContextContainer', () => {
describe('context building', () => {
it('resolves dependencies', async () => {
- const contextContainer = new ContextContainer(plugins, coreId);
+ const contextContainer = new ContextContainer<(context: MyContext) => string>(
+ plugins,
+ coreId
+ );
expect.assertions(8);
contextContainer.registerContext(coreId, 'core1', context => {
expect(context).toEqual({});
@@ -118,7 +124,10 @@ describe('ContextContainer', () => {
it('exposes all core context to all providers regardless of registration order', async () => {
expect.assertions(4);
- const contextContainer = new ContextContainer