Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ContextContainer to lazily initialize providers #129896

Merged
merged 102 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
05a0241
Change ContextContainer to lazily initialize providers
pgayvallet Apr 11, 2022
38e61ac
Introduce CustomRequestHandlerContext, start adapting usages
pgayvallet Apr 11, 2022
c6cf90a
adapt IContextProvider's return type
pgayvallet Apr 11, 2022
04e5e54
start fixing violations
pgayvallet Apr 12, 2022
2719fcb
fixing violations - 2
pgayvallet Apr 12, 2022
4cedaae
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 12, 2022
f90a188
adapt home routes
pgayvallet Apr 12, 2022
dc3a394
fix remaining core violation
pgayvallet Apr 12, 2022
57d1b96
fix violations on core tests
pgayvallet Apr 12, 2022
7ed155d
fixing more violations
pgayvallet Apr 12, 2022
8bf2fa0
fixing more violations
pgayvallet Apr 12, 2022
82cdae6
update generated doc...
pgayvallet Apr 12, 2022
2f252f6
fix more violations
pgayvallet Apr 12, 2022
23d6acc
adapt remaining RequestHandlerContext
pgayvallet Apr 12, 2022
b6f2c3c
fix more violations
pgayvallet Apr 12, 2022
fce3359
fix non-async method
pgayvallet Apr 12, 2022
715fe1e
more fixes
pgayvallet Apr 12, 2022
59e48ca
fix another await in non async method
pgayvallet Apr 12, 2022
1ce4a3b
add yet another missing async
pgayvallet Apr 12, 2022
3839cc7
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 12, 2022
d103103
add yet yet another missing async
pgayvallet Apr 12, 2022
2c63b12
Merge remote-tracking branch 'refs/remotes/origin/kbn-84763-route-han…
pgayvallet Apr 12, 2022
67b2f4c
update fleet's endpoints
pgayvallet Apr 12, 2022
70ce8b0
fix telemetry endpoints
pgayvallet Apr 12, 2022
1fb86c4
fix event_log endpoints
pgayvallet Apr 12, 2022
8770e4d
fix some security unit tests
pgayvallet Apr 12, 2022
7ace964
adapt canvas routes
pgayvallet Apr 12, 2022
7b84453
adapt alerting routes
pgayvallet Apr 12, 2022
62f1801
adapt more so_tagging routes
pgayvallet Apr 12, 2022
3c718c5
fix data_enhanced routes
pgayvallet Apr 12, 2022
f16b681
fix license_management routes
pgayvallet Apr 12, 2022
e81658f
fix file_upload routes
pgayvallet Apr 12, 2022
f63822d
fix index_management routes
pgayvallet Apr 12, 2022
eddd4ae
fix lists routes
pgayvallet Apr 12, 2022
16aae35
fix snapshot_restore routes
pgayvallet Apr 12, 2022
337efee
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 12, 2022
7c1822c
fix rule_registry routes
pgayvallet Apr 12, 2022
fc3ede6
fix ingest_pipelines routes
pgayvallet Apr 12, 2022
9a767b4
fix remote_clusters routes
pgayvallet Apr 12, 2022
d16797a
fix index_lifecycle_management routes
pgayvallet Apr 12, 2022
432b822
improve and fix the lazy implementation
pgayvallet Apr 12, 2022
c8fb382
fix triggers_actions_ui endpoints
pgayvallet Apr 13, 2022
7d40c60
start fixing unit tests
pgayvallet Apr 13, 2022
307cff6
fix cases routes
pgayvallet Apr 13, 2022
f784655
fix transform routes
pgayvallet Apr 13, 2022
970cf3f
fix upgrade_assistant routes
pgayvallet Apr 13, 2022
dbe6a72
fix uptime route wrapper
pgayvallet Apr 13, 2022
00275f7
fix uptime route wrapper bis
pgayvallet Apr 13, 2022
e0b99f4
update osquery routes
pgayvallet Apr 13, 2022
23e064e
update cross_cluster_replication routes
pgayvallet Apr 13, 2022
852e07d
fix some ML routes / wrappers
pgayvallet Apr 13, 2022
39645a3
adapt maps routes
pgayvallet Apr 13, 2022
5e77c92
adapt rollup routes
pgayvallet Apr 13, 2022
34142e1
fix some canvas unit tests
pgayvallet Apr 13, 2022
6d22af2
fix more canvas unit tests
pgayvallet Apr 13, 2022
ffe8119
fix observability wrapper
pgayvallet Apr 13, 2022
30f04af
fix (?) infra type hell
pgayvallet Apr 13, 2022
71675b2
start fixing monitoring
pgayvallet Apr 13, 2022
89eef85
fix a few test plugins
pgayvallet Apr 13, 2022
874cd67
woups
pgayvallet Apr 13, 2022
6237c9b
fix yet more violations
pgayvallet Apr 13, 2022
dfc8abd
fixing UA tests
pgayvallet Apr 13, 2022
924a369
fix logstash handlers
pgayvallet Apr 13, 2022
9a432e5
fix fleet unit tests
pgayvallet Apr 13, 2022
117ddf8
lint?
pgayvallet Apr 13, 2022
2f21942
one more batch
pgayvallet Apr 13, 2022
ed7051f
update security_solution endpoints
pgayvallet Apr 13, 2022
28067d5
start fixing security_solution mocks
pgayvallet Apr 13, 2022
6ef7452
start fixing security_solution tests
pgayvallet Apr 13, 2022
239e6eb
fix more security_solution tests
pgayvallet Apr 13, 2022
b2b2a23
fix more security_solution tests
pgayvallet Apr 13, 2022
3b82ac2
just one more
pgayvallet Apr 13, 2022
0d8d70b
fix last (?) security_solution tests
pgayvallet Apr 14, 2022
c5cd69f
fix timelion javascript file
pgayvallet Apr 14, 2022
ba9e7c0
fix more test plugins
pgayvallet Apr 14, 2022
bff2c1d
fix transforms context type
pgayvallet Apr 14, 2022
fea2487
fix ml context type
pgayvallet Apr 14, 2022
723a052
fix context tests
pgayvallet Apr 14, 2022
5c45cce
fix securitySolution withEndpointAuthz tests
pgayvallet Apr 14, 2022
16ab3c9
fix features unit tests
pgayvallet Apr 14, 2022
10864fc
fix actions unit tests
pgayvallet Apr 14, 2022
ca1c749
Merge commit 'bd8171c13e085f95318e8785560d2e6ec8e473db' into kbn-8476…
pgayvallet Apr 19, 2022
ff9a15c
fix imports
pgayvallet Apr 19, 2022
1005cda
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 19, 2022
80d918a
fix duplicate import
pgayvallet Apr 19, 2022
4701088
fix some merge problems
pgayvallet Apr 19, 2022
e07ee2c
fix new usage
pgayvallet Apr 19, 2022
2540784
fix new test
pgayvallet Apr 19, 2022
f261fa4
introduces context.resolve
pgayvallet Apr 20, 2022
4c3af80
down the rabbit hole again
pgayvallet Apr 20, 2022
169c73b
start fixing test type failures
pgayvallet Apr 20, 2022
861b5ee
more test type failures fixes
pgayvallet Apr 20, 2022
0614bbd
move import comment back to correct place
pgayvallet Apr 20, 2022
4937199
more test type failures fixes, bis
pgayvallet Apr 20, 2022
7499001
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 21, 2022
a40bcdf
use context.resolve for security solution rules routes
pgayvallet Apr 21, 2022
301ec95
fix new violations due to master merge
pgayvallet Apr 21, 2022
2d0a87d
remove comment
pgayvallet Apr 21, 2022
c9941df
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 21, 2022
b483dcc
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 21, 2022
e890739
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 22, 2022
b958776
Merge remote-tracking branch 'upstream/main' into kbn-84763-route-han…
pgayvallet Apr 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreRequestHandlerContext](./kibana-plugin-core-server.corerequesthandlercontext.md) &gt; [deprecations](./kibana-plugin-core-server.corerequesthandlercontext.deprecations.md)

## CoreRequestHandlerContext.deprecations property

<b>Signature:</b>

```typescript
deprecations: {
client: DeprecationsClient;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreRequestHandlerContext](./kibana-plugin-core-server.corerequesthandlercontext.md) &gt; [elasticsearch](./kibana-plugin-core-server.corerequesthandlercontext.elasticsearch.md)

## CoreRequestHandlerContext.elasticsearch property

<b>Signature:</b>

```typescript
elasticsearch: {
client: IScopedClusterClient;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreRequestHandlerContext](./kibana-plugin-core-server.corerequesthandlercontext.md)

## CoreRequestHandlerContext interface

The `core` context provided to route handler.

Provides the following clients and services: - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.client](./kibana-plugin-core-server.iscopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request

<b>Signature:</b>

```typescript
export interface CoreRequestHandlerContext
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [deprecations](./kibana-plugin-core-server.corerequesthandlercontext.deprecations.md) | { client: DeprecationsClient; } | |
| [elasticsearch](./kibana-plugin-core-server.corerequesthandlercontext.elasticsearch.md) | { client: IScopedClusterClient; } | |
| [savedObjects](./kibana-plugin-core-server.corerequesthandlercontext.savedobjects.md) | { client: SavedObjectsClientContract; typeRegistry: ISavedObjectTypeRegistry; getClient: (options?: SavedObjectsClientProviderOptions) =&gt; SavedObjectsClientContract; getExporter: (client: SavedObjectsClientContract) =&gt; ISavedObjectsExporter; getImporter: (client: SavedObjectsClientContract) =&gt; ISavedObjectsImporter; } | |
| [uiSettings](./kibana-plugin-core-server.corerequesthandlercontext.uisettings.md) | { client: IUiSettingsClient; } | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreRequestHandlerContext](./kibana-plugin-core-server.corerequesthandlercontext.md) &gt; [savedObjects](./kibana-plugin-core-server.corerequesthandlercontext.savedobjects.md)

## CoreRequestHandlerContext.savedObjects property

<b>Signature:</b>

```typescript
savedObjects: {
client: SavedObjectsClientContract;
typeRegistry: ISavedObjectTypeRegistry;
getClient: (options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract;
getExporter: (client: SavedObjectsClientContract) => ISavedObjectsExporter;
getImporter: (client: SavedObjectsClientContract) => ISavedObjectsImporter;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CoreRequestHandlerContext](./kibana-plugin-core-server.corerequesthandlercontext.md) &gt; [uiSettings](./kibana-plugin-core-server.corerequesthandlercontext.uisettings.md)

## CoreRequestHandlerContext.uiSettings property

<b>Signature:</b>

```typescript
uiSettings: {
client: IUiSettingsClient;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CustomRequestHandlerContext](./kibana-plugin-core-server.customrequesthandlercontext.md)

## CustomRequestHandlerContext type


<b>Signature:</b>

```typescript
export declare type CustomRequestHandlerContext<T> = RequestHandlerContext & {
[Key in keyof T]: T[Key] extends Promise<unknown> ? T[Key] : Promise<T[Key]>;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ async (context, request, response) => {
| [registerOnPreAuth](./kibana-plugin-core-server.httpservicesetup.registeronpreauth.md) | (handler: OnPreAuthHandler) =&gt; void | To define custom logic to perform for incoming requests before the Auth interceptor performs a check that user has access to requested resources. |
| [registerOnPreResponse](./kibana-plugin-core-server.httpservicesetup.registeronpreresponse.md) | (handler: OnPreResponseHandler) =&gt; void | To define custom logic to perform for the server response. |
| [registerOnPreRouting](./kibana-plugin-core-server.httpservicesetup.registeronprerouting.md) | (handler: OnPreRoutingHandler) =&gt; void | To define custom logic to perform for incoming requests before server performs a route lookup. |
| [registerRouteHandlerContext](./kibana-plugin-core-server.httpservicesetup.registerroutehandlercontext.md) | &lt;Context extends RequestHandlerContext, ContextName extends keyof Context&gt;(contextName: ContextName, provider: RequestHandlerContextProvider&lt;Context, ContextName&gt;) =&gt; RequestHandlerContextContainer | Register a context provider for a route handler. |
| [registerRouteHandlerContext](./kibana-plugin-core-server.httpservicesetup.registerroutehandlercontext.md) | &lt;Context extends RequestHandlerContext, ContextName extends keyof Omit&lt;Context, 'resolve'&gt;&gt;(contextName: ContextName, provider: RequestHandlerContextProvider&lt;Context, ContextName&gt;) =&gt; RequestHandlerContextContainer | Register a context provider for a route handler. |

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Register a context provider for a route handler.
<b>Signature:</b>

```typescript
registerRouteHandlerContext: <Context extends RequestHandlerContext, ContextName extends keyof Context>(contextName: ContextName, provider: RequestHandlerContextProvider<Context, ContextName>) => RequestHandlerContextContainer;
registerRouteHandlerContext: <Context extends RequestHandlerContext, ContextName extends keyof Omit<Context, 'resolve'>>(contextName: ContextName, provider: RequestHandlerContextProvider<Context, ContextName>) => RequestHandlerContextContainer;
```

## Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A function that returns a context value for a specific key of given context type
<b>Signature:</b>

```typescript
export declare type IContextProvider<Context extends RequestHandlerContext, ContextName extends keyof Context> = (context: Omit<Context, ContextName>, ...rest: HandlerParameters<RequestHandler>) => Promise<Context[ContextName]> | Context[ContextName];
export declare type IContextProvider<Context extends RequestHandlerContext, ContextName extends keyof Context> = (context: Omit<Context, ContextName>, ...rest: HandlerParameters<RequestHandler>) => MaybePromise<Awaited<Context[ContextName]>>;
```

## Remarks
Expand Down
5 changes: 4 additions & 1 deletion docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [ConfigDeprecationDetails](./kibana-plugin-core-server.configdeprecationdetails.md) | |
| [ContextSetup](./kibana-plugin-core-server.contextsetup.md) | An object that handles registration of context providers and configuring handlers with context. |
| [CorePreboot](./kibana-plugin-core-server.corepreboot.md) | Context passed to the <code>setup</code> method of <code>preboot</code> plugins. |
| [CoreRequestHandlerContext](./kibana-plugin-core-server.corerequesthandlercontext.md) | The <code>core</code> context provided to route handler.<!-- -->Provides the following clients and services: - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.client](./kibana-plugin-core-server.iscopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
| [CoreSetup](./kibana-plugin-core-server.coresetup.md) | Context passed to the <code>setup</code> method of <code>standard</code> plugins. |
| [CoreStart](./kibana-plugin-core-server.corestart.md) | Context passed to the plugins <code>start</code> method. |
| [CoreStatus](./kibana-plugin-core-server.corestatus.md) | Status of core services. |
Expand Down Expand Up @@ -133,7 +134,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [PrebootPlugin](./kibana-plugin-core-server.prebootplugin.md) | The interface that should be returned by a <code>PluginInitializer</code> for a <code>preboot</code> plugin. |
| [PrebootServicePreboot](./kibana-plugin-core-server.prebootservicepreboot.md) | Kibana Preboot Service allows to control the boot flow of Kibana. Preboot plugins can use it to hold the boot until certain condition is met. |
| [RegisterDeprecationsConfig](./kibana-plugin-core-server.registerdeprecationsconfig.md) | |
| [RequestHandlerContext](./kibana-plugin-core-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.<!-- -->Provides the following clients and services: - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.client](./kibana-plugin-core-server.iscopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
| [RequestHandlerContext](./kibana-plugin-core-server.requesthandlercontext.md) | Base context passed to a route handler. |
| [RequestHandlerContextBase](./kibana-plugin-core-server.requesthandlercontextbase.md) | \* |
| [ResolveCapabilitiesOptions](./kibana-plugin-core-server.resolvecapabilitiesoptions.md) | Defines a set of additional options for the <code>resolveCapabilities</code> method of [CapabilitiesStart](./kibana-plugin-core-server.capabilitiesstart.md)<!-- -->. |
| [RouteConfig](./kibana-plugin-core-server.routeconfig.md) | Route specific configuration. |
| [RouteConfigOptions](./kibana-plugin-core-server.routeconfigoptions.md) | Additional route options. |
Expand Down Expand Up @@ -262,6 +264,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [AuthResult](./kibana-plugin-core-server.authresult.md) | |
| [CapabilitiesProvider](./kibana-plugin-core-server.capabilitiesprovider.md) | See [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) |
| [CapabilitiesSwitcher](./kibana-plugin-core-server.capabilitiesswitcher.md) | See [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) |
| [CustomRequestHandlerContext](./kibana-plugin-core-server.customrequesthandlercontext.md) | |
| [DeprecationsDetails](./kibana-plugin-core-server.deprecationsdetails.md) | |
| [DestructiveRouteMethod](./kibana-plugin-core-server.destructiveroutemethod.md) | Set of HTTP methods changing the state of the server. |
| [DocLinksServiceStart](./kibana-plugin-core-server.doclinksservicestart.md) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,5 @@
<b>Signature:</b>

```typescript
core: {
savedObjects: {
client: SavedObjectsClientContract;
typeRegistry: ISavedObjectTypeRegistry;
getClient: (options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract;
getExporter: (client: SavedObjectsClientContract) => ISavedObjectsExporter;
getImporter: (client: SavedObjectsClientContract) => ISavedObjectsImporter;
};
elasticsearch: {
client: IScopedClusterClient;
};
uiSettings: {
client: IUiSettingsClient;
};
deprecations: {
client: DeprecationsClient;
};
};
core: Promise<CoreRequestHandlerContext>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

## RequestHandlerContext interface

Plugin specific context passed to a route handler.

Provides the following clients and services: - [savedObjects.client](./kibana-plugin-core-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [savedObjects.typeRegistry](./kibana-plugin-core-server.isavedobjecttyperegistry.md) - Type registry containing all the registered types. - [elasticsearch.client](./kibana-plugin-core-server.iscopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-core-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request
Base context passed to a route handler.

<b>Signature:</b>

```typescript
export interface RequestHandlerContext
export interface RequestHandlerContext extends RequestHandlerContextBase
```
<b>Extends:</b> RequestHandlerContextBase

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [core](./kibana-plugin-core-server.requesthandlercontext.core.md) | { savedObjects: { client: SavedObjectsClientContract; typeRegistry: ISavedObjectTypeRegistry; getClient: (options?: SavedObjectsClientProviderOptions) =&gt; SavedObjectsClientContract; getExporter: (client: SavedObjectsClientContract) =&gt; ISavedObjectsExporter; getImporter: (client: SavedObjectsClientContract) =&gt; ISavedObjectsImporter; }; elasticsearch: { client: IScopedClusterClient; }; uiSettings: { client: IUiSettingsClient; }; deprecations: { client: DeprecationsClient; }; } | |
| [core](./kibana-plugin-core-server.requesthandlercontext.core.md) | Promise&lt;CoreRequestHandlerContext&gt; | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [RequestHandlerContextBase](./kibana-plugin-core-server.requesthandlercontextbase.md)

## RequestHandlerContextBase interface

\*

<b>Signature:</b>

```typescript
export interface RequestHandlerContextBase
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [resolve](./kibana-plugin-core-server.requesthandlercontextbase.resolve.md) | &lt;T extends keyof Omit&lt;this, 'resolve'&gt;&gt;(parts: T\[\]) =&gt; Promise&lt;AwaitedProperties&lt;Pick&lt;this, T&gt;&gt;&gt; | Await all the specified context parts and return them. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [RequestHandlerContextBase](./kibana-plugin-core-server.requesthandlercontextbase.md) &gt; [resolve](./kibana-plugin-core-server.requesthandlercontextbase.resolve.md)

## RequestHandlerContextBase.resolve property

Await all the specified context parts and return them.

<b>Signature:</b>

```typescript
resolve: <T extends keyof Omit<this, 'resolve'>>(parts: T[]) => Promise<AwaitedProperties<Pick<this, T>>>;
```

## Example


```ts
const resolved = await context.resolve(['core', 'pluginA']);
const esClient = resolved.core.elasticsearch.client;
const pluginAService = resolved.pluginA.someService;
```

2 changes: 1 addition & 1 deletion examples/screenshot_mode_example/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const registerRoutes = ({ router, log, screenshotMode }: RouteDependencie
{ path: `${BASE_API_ROUTE}/check_is_screenshot`, validate: false },
async (ctx, req, res) => {
log.info(`Reading screenshot mode from a request: ${screenshotMode.isScreenshotMode(req)}`);
log.info(`Reading is screenshot mode from ctx: ${ctx.screenshotMode.isScreenshot}`);
log.info(`Reading is screenshot mode from ctx: ${(await ctx.screenshotMode).isScreenshot}`);
return res.ok();
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export function registerServerSearchRoute(router: IRouter<DataRequestHandlerCont
const abortSignal = getRequestAbortedSignal(request.events.aborted$);

try {
const res = await context
.search!.search(
const search = await context.search;
const res = await search
.search(
{
params: {
index,
Expand Down
7 changes: 7 additions & 0 deletions packages/kbn-utility-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ export type MaybePromise<T> = T | Promise<T>;
*/
export type ShallowPromise<T> = T extends Promise<infer U> ? Promise<U> : Promise<T>;

/**
* Unwrap all promise attributes of the given type
*/
export type AwaitedProperties<T> = {
[K in keyof T]: Awaited<T[K]>;
};

/**
* Minimal interface for an object resembling an `Observable`.
*/
Expand Down
Loading