Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into issue-change-index-…
Browse files Browse the repository at this point in the history
…pattern-to-data-view
  • Loading branch information
nlatipov committed Apr 25, 2022
2 parents 97f6d50 + fb6f64f commit 27a37af
Show file tree
Hide file tree
Showing 738 changed files with 6,252 additions and 3,351 deletions.
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
5 changes: 3 additions & 2 deletions examples/search_examples/server/routes/server_search_route.ts
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"@dnd-kit/core": "^3.1.1",
"@dnd-kit/sortable": "^4.0.0",
"@dnd-kit/utilities": "^2.0.0",
"@elastic/apm-rum": "^5.10.2",
"@elastic/apm-rum-react": "^1.3.4",
"@elastic/apm-rum": "^5.11.0",
"@elastic/apm-rum-react": "^1.4.0",
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "46.0.1",
"@elastic/datemath": "5.0.3",
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

0 comments on commit 27a37af

Please sign in to comment.