Skip to content

Commit

Permalink
[Execution context] Add nested context support (#107523)
Browse files Browse the repository at this point in the history
* Add nested context support

* remove execution context service on the client side

ExecutionContextContaier is not compatible with SerializableState, so I had to fall back to passing context as POJO. With this change, using a service looks like overhead.

* update docs

* fix test

* address comments from Josh

* put export back

* update docs

* remove outdated export

* use input.title for unsaved vis

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
mshustov and kibanamachine committed Aug 10, 2021
1 parent 7366df9 commit 5480c4d
Show file tree
Hide file tree
Showing 94 changed files with 887 additions and 805 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface CoreStart
| [chrome](./kibana-plugin-core-public.corestart.chrome.md) | <code>ChromeStart</code> | [ChromeStart](./kibana-plugin-core-public.chromestart.md) |
| [deprecations](./kibana-plugin-core-public.corestart.deprecations.md) | <code>DeprecationsServiceStart</code> | [DeprecationsServiceStart](./kibana-plugin-core-public.deprecationsservicestart.md) |
| [docLinks](./kibana-plugin-core-public.corestart.doclinks.md) | <code>DocLinksStart</code> | [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) |
| [executionContext](./kibana-plugin-core-public.corestart.executioncontext.md) | <code>ExecutionContextServiceStart</code> | [ExecutionContextServiceStart](./kibana-plugin-core-public.executioncontextservicestart.md) |
| [fatalErrors](./kibana-plugin-core-public.corestart.fatalerrors.md) | <code>FatalErrorsStart</code> | [FatalErrorsStart](./kibana-plugin-core-public.fatalerrorsstart.md) |
| [http](./kibana-plugin-core-public.corestart.http.md) | <code>HttpStart</code> | [HttpStart](./kibana-plugin-core-public.httpstart.md) |
| [i18n](./kibana-plugin-core-public.corestart.i18n.md) | <code>I18nStart</code> | [I18nStart](./kibana-plugin-core-public.i18nstart.md) |
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
context?: IExecutionContextContainer;
context?: KibanaExecutionContext;
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface HttpFetchOptions extends HttpRequestInit
| --- | --- | --- |
| [asResponse](./kibana-plugin-core-public.httpfetchoptions.asresponse.md) | <code>boolean</code> | When <code>true</code> the return type of [HttpHandler](./kibana-plugin-core-public.httphandler.md) will be an [HttpResponse](./kibana-plugin-core-public.httpresponse.md) with detailed request and response information. When <code>false</code>, the return type will just be the parsed response body. Defaults to <code>false</code>. |
| [asSystemRequest](./kibana-plugin-core-public.httpfetchoptions.assystemrequest.md) | <code>boolean</code> | Whether or not the request should include the "system request" header to differentiate an end user request from Kibana internal request. Can be read on the server-side using KibanaRequest\#isSystemRequest. Defaults to <code>false</code>. |
| [context](./kibana-plugin-core-public.httpfetchoptions.context.md) | <code>IExecutionContextContainer</code> | |
| [context](./kibana-plugin-core-public.httpfetchoptions.context.md) | <code>KibanaExecutionContext</code> | |
| [headers](./kibana-plugin-core-public.httpfetchoptions.headers.md) | <code>HttpHeadersInit</code> | Headers to send with the request. See [HttpHeadersInit](./kibana-plugin-core-public.httpheadersinit.md)<!-- -->. |
| [prependBasePath](./kibana-plugin-core-public.httpfetchoptions.prependbasepath.md) | <code>boolean</code> | Whether or not the request should automatically prepend the basePath. Defaults to <code>true</code>. |
| [query](./kibana-plugin-core-public.httpfetchoptions.query.md) | <code>HttpFetchQuery</code> | The query string for an HTTP request. See [HttpFetchQuery](./kibana-plugin-core-public.httpfetchquery.md)<!-- -->. |
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [KibanaExecutionContext](./kibana-plugin-core-public.kibanaexecutioncontext.md)

## KibanaExecutionContext interface
## KibanaExecutionContext type

Represents a meta-information about a Kibana entity initiating a search request.

<b>Signature:</b>

```typescript
export interface KibanaExecutionContext
export declare type KibanaExecutionContext = {
readonly type: string;
readonly name: string;
readonly id: string;
readonly description: string;
readonly url?: string;
parent?: KibanaExecutionContext;
};
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [description](./kibana-plugin-core-public.kibanaexecutioncontext.description.md) | <code>string</code> | human readable description. For example, a vis title, action name |
| [id](./kibana-plugin-core-public.kibanaexecutioncontext.id.md) | <code>string</code> | unique value to identify the source |
| [name](./kibana-plugin-core-public.kibanaexecutioncontext.name.md) | <code>string</code> | public name of a user-facing feature |
| [type](./kibana-plugin-core-public.kibanaexecutioncontext.type.md) | <code>string</code> | Kibana application initated an operation. |
| [url](./kibana-plugin-core-public.kibanaexecutioncontext.url.md) | <code>string</code> | in browser - url to navigate to a current page, on server - endpoint path, for task: task SO url |

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 1 addition & 3 deletions docs/development/core/public/kibana-plugin-core-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) | |
| [DomainDeprecationDetails](./kibana-plugin-core-public.domaindeprecationdetails.md) | |
| [ErrorToastOptions](./kibana-plugin-core-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) error APIs. |
| [ExecutionContextServiceStart](./kibana-plugin-core-public.executioncontextservicestart.md) | |
| [FatalErrorInfo](./kibana-plugin-core-public.fatalerrorinfo.md) | Represents the <code>message</code> and <code>stack</code> of a fatal Error |
| [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. |
| [HttpFetchOptions](./kibana-plugin-core-public.httpfetchoptions.md) | All options that may be used with a [HttpHandler](./kibana-plugin-core-public.httphandler.md)<!-- -->. |
Expand All @@ -80,14 +79,12 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [I18nStart](./kibana-plugin-core-public.i18nstart.md) | I18nStart.Context is required by any localizable React component from @<!-- -->kbn/i18n and @<!-- -->elastic/eui packages and is supposed to be used as the topmost component for any i18n-compatible React tree. |
| [IAnonymousPaths](./kibana-plugin-core-public.ianonymouspaths.md) | APIs for denoting paths as not requiring authentication |
| [IBasePath](./kibana-plugin-core-public.ibasepath.md) | APIs for manipulating the basePath on URL segments. |
| [IExecutionContextContainer](./kibana-plugin-core-public.iexecutioncontextcontainer.md) | |
| [IExternalUrl](./kibana-plugin-core-public.iexternalurl.md) | APIs for working with external URLs. |
| [IExternalUrlPolicy](./kibana-plugin-core-public.iexternalurlpolicy.md) | A policy describing whether access to an external destination is allowed. |
| [IHttpFetchError](./kibana-plugin-core-public.ihttpfetcherror.md) | |
| [IHttpInterceptController](./kibana-plugin-core-public.ihttpinterceptcontroller.md) | Used to halt a request Promise chain in a [HttpInterceptor](./kibana-plugin-core-public.httpinterceptor.md)<!-- -->. |
| [IHttpResponseInterceptorOverrides](./kibana-plugin-core-public.ihttpresponseinterceptoroverrides.md) | Properties that can be returned by HttpInterceptor.request to override the response. |
| [IUiSettingsClient](./kibana-plugin-core-public.iuisettingsclient.md) | Client-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. [IUiSettingsClient](./kibana-plugin-core-public.iuisettingsclient.md) |
| [KibanaExecutionContext](./kibana-plugin-core-public.kibanaexecutioncontext.md) | |
| [NavigateToAppOptions](./kibana-plugin-core-public.navigatetoappoptions.md) | Options for the [navigateToApp API](./kibana-plugin-core-public.applicationstart.navigatetoapp.md) |
| [NotificationsSetup](./kibana-plugin-core-public.notificationssetup.md) | |
| [NotificationsStart](./kibana-plugin-core-public.notificationsstart.md) | |
Expand Down Expand Up @@ -162,6 +159,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [FatalErrorsStart](./kibana-plugin-core-public.fatalerrorsstart.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. |
| [HttpStart](./kibana-plugin-core-public.httpstart.md) | See [HttpSetup](./kibana-plugin-core-public.httpsetup.md) |
| [IToasts](./kibana-plugin-core-public.itoasts.md) | Methods for adding and removing global toast messages. See [ToastsApi](./kibana-plugin-core-public.toastsapi.md)<!-- -->. |
| [KibanaExecutionContext](./kibana-plugin-core-public.kibanaexecutioncontext.md) | Represents a meta-information about a Kibana entity initiating a search request. |
| [MountPoint](./kibana-plugin-core-public.mountpoint.md) | A function that should mount DOM content inside the provided container element and return a handler to unmount it. |
| [NavType](./kibana-plugin-core-public.navtype.md) | |
| [PluginInitializer](./kibana-plugin-core-public.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>public</code> directory should conform to this interface. |
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ export interface ExecutionContextSetup

| Method | Description |
| --- | --- |
| [get()](./kibana-plugin-core-server.executioncontextsetup.get.md) | Retrieves an opearation meta-data for the current async context. |
| [set(context)](./kibana-plugin-core-server.executioncontextsetup.set.md) | Stores the meta-data of a runtime operation. Data are carried over all async operations automatically. The sequential calls merge provided "context" object shallowly. |
| [withContext(context, fn)](./kibana-plugin-core-server.executioncontextsetup.withcontext.md) | Keeps track of execution context while the passed function is executed. Data are carried over all async operations spawned by the passed function. The nested calls stack the registered context on top of each other. |

This file was deleted.

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; [ExecutionContextSetup](./kibana-plugin-core-server.executioncontextsetup.md) &gt; [withContext](./kibana-plugin-core-server.executioncontextsetup.withcontext.md)

## ExecutionContextSetup.withContext() method

Keeps track of execution context while the passed function is executed. Data are carried over all async operations spawned by the passed function. The nested calls stack the registered context on top of each other.

<b>Signature:</b>

```typescript
withContext<R>(context: KibanaExecutionContext | undefined, fn: (...args: any[]) => R): R;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| context | <code>KibanaExecutionContext &#124; undefined</code> | |
| fn | <code>(...args: any[]) =&gt; R</code> | |

<b>Returns:</b>

`R`

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<b>Signature:</b>

```typescript
toJSON(): Readonly<KibanaServerExecutionContext>;
toJSON(): Readonly<KibanaExecutionContext>;
```
<b>Returns:</b>

`Readonly<KibanaServerExecutionContext>`
`Readonly<KibanaExecutionContext>`

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5480c4d

Please sign in to comment.