diff --git a/.backportrc.json b/.backportrc.json
index 87bc3a1be583ba..8f458343c51afd 100644
--- a/.backportrc.json
+++ b/.backportrc.json
@@ -25,6 +25,7 @@
],
"targetPRLabels": ["backport"],
"branchLabelMapping": {
+ "^v8.0.0$": "master",
"^v7.9.0$": "7.x",
"^v(\\d+).(\\d+).\\d+$": "$1.$2"
}
diff --git a/.eslintignore b/.eslintignore
index fbdd70703f3c40..9de2cc28729602 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -33,6 +33,7 @@ target
/x-pack/plugins/canvas/shareable_runtime/build
/x-pack/plugins/canvas/storybook
/x-pack/plugins/monitoring/public/lib/jquery_flot
+/x-pack/plugins/reporting/server/export_types/printable_pdf/server/lib/pdf/assets/**
/x-pack/legacy/plugins/infra/common/graphql/types.ts
/x-pack/legacy/plugins/infra/public/graphql/types.ts
/x-pack/legacy/plugins/infra/server/graphql/types.ts
diff --git a/docs/development/core/public/kibana-plugin-core-public.chromestart.getcustomnavlink_.md b/docs/development/core/public/kibana-plugin-core-public.chromestart.getcustomnavlink_.md
new file mode 100644
index 00000000000000..64805eefbfea1f
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-core-public.chromestart.getcustomnavlink_.md
@@ -0,0 +1,17 @@
+
+
+[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ChromeStart](./kibana-plugin-core-public.chromestart.md) > [getCustomNavLink$](./kibana-plugin-core-public.chromestart.getcustomnavlink_.md)
+
+## ChromeStart.getCustomNavLink$() method
+
+Get an observable of the current custom nav link
+
+Signature:
+
+```typescript
+getCustomNavLink$(): Observable | undefined>;
+```
+Returns:
+
+`Observable | undefined>`
+
diff --git a/docs/development/core/public/kibana-plugin-core-public.chromestart.md b/docs/development/core/public/kibana-plugin-core-public.chromestart.md
index b4eadc93fe78d3..e983ad50d2afe5 100644
--- a/docs/development/core/public/kibana-plugin-core-public.chromestart.md
+++ b/docs/development/core/public/kibana-plugin-core-public.chromestart.md
@@ -55,6 +55,7 @@ core.chrome.setHelpExtension(elem => {
| [getBadge$()](./kibana-plugin-core-public.chromestart.getbadge_.md) | Get an observable of the current badge |
| [getBrand$()](./kibana-plugin-core-public.chromestart.getbrand_.md) | Get an observable of the current brand information. |
| [getBreadcrumbs$()](./kibana-plugin-core-public.chromestart.getbreadcrumbs_.md) | Get an observable of the current list of breadcrumbs |
+| [getCustomNavLink$()](./kibana-plugin-core-public.chromestart.getcustomnavlink_.md) | Get an observable of the current custom nav link |
| [getHelpExtension$()](./kibana-plugin-core-public.chromestart.gethelpextension_.md) | Get an observable of the current custom help conttent |
| [getIsNavDrawerLocked$()](./kibana-plugin-core-public.chromestart.getisnavdrawerlocked_.md) | Get an observable of the current locked state of the nav drawer. |
| [getIsVisible$()](./kibana-plugin-core-public.chromestart.getisvisible_.md) | Get an observable of the current visibility state of the chrome. |
@@ -64,6 +65,7 @@ core.chrome.setHelpExtension(elem => {
| [setBadge(badge)](./kibana-plugin-core-public.chromestart.setbadge.md) | Override the current badge |
| [setBrand(brand)](./kibana-plugin-core-public.chromestart.setbrand.md) | Set the brand configuration. |
| [setBreadcrumbs(newBreadcrumbs)](./kibana-plugin-core-public.chromestart.setbreadcrumbs.md) | Override the current set of breadcrumbs |
+| [setCustomNavLink(newCustomNavLink)](./kibana-plugin-core-public.chromestart.setcustomnavlink.md) | Override the current set of custom nav link |
| [setHelpExtension(helpExtension)](./kibana-plugin-core-public.chromestart.sethelpextension.md) | Override the current set of custom help content |
| [setHelpSupportUrl(url)](./kibana-plugin-core-public.chromestart.sethelpsupporturl.md) | Override the default support URL shown in the help menu |
| [setIsVisible(isVisible)](./kibana-plugin-core-public.chromestart.setisvisible.md) | Set the temporary visibility for the chrome. This does nothing if the chrome is hidden by default and should be used to hide the chrome for things like full-screen modes with an exit button. |
diff --git a/docs/development/core/public/kibana-plugin-core-public.chromestart.setcustomnavlink.md b/docs/development/core/public/kibana-plugin-core-public.chromestart.setcustomnavlink.md
new file mode 100644
index 00000000000000..adfb57f9c5ff25
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-core-public.chromestart.setcustomnavlink.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ChromeStart](./kibana-plugin-core-public.chromestart.md) > [setCustomNavLink](./kibana-plugin-core-public.chromestart.setcustomnavlink.md)
+
+## ChromeStart.setCustomNavLink() method
+
+Override the current set of custom nav link
+
+Signature:
+
+```typescript
+setCustomNavLink(newCustomNavLink?: Partial): void;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| newCustomNavLink | Partial<ChromeNavLink>
| |
+
+Returns:
+
+`void`
+
diff --git a/docs/development/core/server/kibana-plugin-core-server.coresetup.md b/docs/development/core/server/kibana-plugin-core-server.coresetup.md
index e9ed5b830b6918..32221a320d2a15 100644
--- a/docs/development/core/server/kibana-plugin-core-server.coresetup.md
+++ b/docs/development/core/server/kibana-plugin-core-server.coresetup.md
@@ -22,7 +22,6 @@ export interface CoreSetupStartServicesAccessor<TPluginsStart, TStart> | [StartServicesAccessor](./kibana-plugin-core-server.startservicesaccessor.md) |
| [http](./kibana-plugin-core-server.coresetup.http.md) | HttpServiceSetup & {
resources: HttpResources;
}
| [HttpServiceSetup](./kibana-plugin-core-server.httpservicesetup.md) |
| [logging](./kibana-plugin-core-server.coresetup.logging.md) | LoggingServiceSetup
| [LoggingServiceSetup](./kibana-plugin-core-server.loggingservicesetup.md) |
-| [metrics](./kibana-plugin-core-server.coresetup.metrics.md) | MetricsServiceSetup
| [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) |
| [savedObjects](./kibana-plugin-core-server.coresetup.savedobjects.md) | SavedObjectsServiceSetup
| [SavedObjectsServiceSetup](./kibana-plugin-core-server.savedobjectsservicesetup.md) |
| [status](./kibana-plugin-core-server.coresetup.status.md) | StatusServiceSetup
| [StatusServiceSetup](./kibana-plugin-core-server.statusservicesetup.md) |
| [uiSettings](./kibana-plugin-core-server.coresetup.uisettings.md) | UiSettingsServiceSetup
| [UiSettingsServiceSetup](./kibana-plugin-core-server.uisettingsservicesetup.md) |
diff --git a/docs/development/core/server/kibana-plugin-core-server.coresetup.metrics.md b/docs/development/core/server/kibana-plugin-core-server.coresetup.metrics.md
deleted file mode 100644
index 77c9e867ef8ea8..00000000000000
--- a/docs/development/core/server/kibana-plugin-core-server.coresetup.metrics.md
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [CoreSetup](./kibana-plugin-core-server.coresetup.md) > [metrics](./kibana-plugin-core-server.coresetup.metrics.md)
-
-## CoreSetup.metrics property
-
-[MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md)
-
-Signature:
-
-```typescript
-metrics: MetricsServiceSetup;
-```
diff --git a/docs/development/core/server/kibana-plugin-core-server.corestart.md b/docs/development/core/server/kibana-plugin-core-server.corestart.md
index 6a6bacf1eef40b..acd23f0f473867 100644
--- a/docs/development/core/server/kibana-plugin-core-server.corestart.md
+++ b/docs/development/core/server/kibana-plugin-core-server.corestart.md
@@ -19,6 +19,7 @@ export interface CoreStart
| [capabilities](./kibana-plugin-core-server.corestart.capabilities.md) | CapabilitiesStart
| [CapabilitiesStart](./kibana-plugin-core-server.capabilitiesstart.md) |
| [elasticsearch](./kibana-plugin-core-server.corestart.elasticsearch.md) | ElasticsearchServiceStart
| [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) |
| [http](./kibana-plugin-core-server.corestart.http.md) | HttpServiceStart
| [HttpServiceStart](./kibana-plugin-core-server.httpservicestart.md) |
+| [metrics](./kibana-plugin-core-server.corestart.metrics.md) | MetricsServiceStart
| |
| [savedObjects](./kibana-plugin-core-server.corestart.savedobjects.md) | SavedObjectsServiceStart
| [SavedObjectsServiceStart](./kibana-plugin-core-server.savedobjectsservicestart.md) |
| [uiSettings](./kibana-plugin-core-server.corestart.uisettings.md) | UiSettingsServiceStart
| [UiSettingsServiceStart](./kibana-plugin-core-server.uisettingsservicestart.md) |
diff --git a/docs/development/core/server/kibana-plugin-core-server.corestart.metrics.md b/docs/development/core/server/kibana-plugin-core-server.corestart.metrics.md
new file mode 100644
index 00000000000000..a51c2f842c3464
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-core-server.corestart.metrics.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [CoreStart](./kibana-plugin-core-server.corestart.md) > [metrics](./kibana-plugin-core-server.corestart.metrics.md)
+
+## CoreStart.metrics property
+
+
+Signature:
+
+```typescript
+metrics: MetricsServiceStart;
+```
diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md
index 1a03ac5ee3d1ad..74422c82fc9ea7 100644
--- a/docs/development/core/server/kibana-plugin-core-server.md
+++ b/docs/development/core/server/kibana-plugin-core-server.md
@@ -112,7 +112,7 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [LoggerFactory](./kibana-plugin-core-server.loggerfactory.md) | The single purpose of LoggerFactory
interface is to define a way to retrieve a context-based logger instance. |
| [LoggingServiceSetup](./kibana-plugin-core-server.loggingservicesetup.md) | Provides APIs to plugins for customizing the plugin's logger. |
| [LogMeta](./kibana-plugin-core-server.logmeta.md) | Contextual metadata |
-| [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) | APIs to retrieves metrics gathered and exposed by the core platform. |
+| [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) | |
| [NodesVersionCompatibility](./kibana-plugin-core-server.nodesversioncompatibility.md) | |
| [OnPostAuthToolkit](./kibana-plugin-core-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
| [OnPreAuthToolkit](./kibana-plugin-core-server.onpreauthtoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
@@ -150,7 +150,7 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [SavedObjectsBulkUpdateResponse](./kibana-plugin-core-server.savedobjectsbulkupdateresponse.md) | |
| [SavedObjectsClientProviderOptions](./kibana-plugin-core-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
| [SavedObjectsClientWrapperOptions](./kibana-plugin-core-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
-| [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation. |
+| [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation.Note: this type intentially doesn't include a type definition for defining the dynamic
mapping parameter. Saved Object fields should always inherit the dynamic: 'strict'
paramater. If you are unsure of the shape of your data use type: 'object', enabled: false
instead. |
| [SavedObjectsCoreFieldMapping](./kibana-plugin-core-server.savedobjectscorefieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation. |
| [SavedObjectsCreateOptions](./kibana-plugin-core-server.savedobjectscreateoptions.md) | |
| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-core-server.savedobjectsdeletebynamespaceoptions.md) | |
diff --git a/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.getopsmetrics_.md b/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.getopsmetrics_.md
deleted file mode 100644
index 61107fbf20ad92..00000000000000
--- a/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.getopsmetrics_.md
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) > [getOpsMetrics$](./kibana-plugin-core-server.metricsservicesetup.getopsmetrics_.md)
-
-## MetricsServiceSetup.getOpsMetrics$ property
-
-Retrieve an observable emitting the [OpsMetrics](./kibana-plugin-core-server.opsmetrics.md) gathered. The observable will emit an initial value during core's `start` phase, and a new value every fixed interval of time, based on the `opts.interval` configuration property.
-
-Signature:
-
-```typescript
-getOpsMetrics$: () => Observable;
-```
-
-## Example
-
-
-```ts
-core.metrics.getOpsMetrics$().subscribe(metrics => {
- // do something with the metrics
-})
-
-```
-
diff --git a/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.md b/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.md
index 00045aeac74b4a..0bec919797b6f8 100644
--- a/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.md
+++ b/docs/development/core/server/kibana-plugin-core-server.metricsservicesetup.md
@@ -4,17 +4,8 @@
## MetricsServiceSetup interface
-APIs to retrieves metrics gathered and exposed by the core platform.
-
Signature:
```typescript
export interface MetricsServiceSetup
```
-
-## Properties
-
-| Property | Type | Description |
-| --- | --- | --- |
-| [getOpsMetrics$](./kibana-plugin-core-server.metricsservicesetup.getopsmetrics_.md) | () => Observable<OpsMetrics>
| Retrieve an observable emitting the [OpsMetrics](./kibana-plugin-core-server.opsmetrics.md) gathered. The observable will emit an initial value during core's start
phase, and a new value every fixed interval of time, based on the opts.interval
configuration property. |
-
diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.dynamic.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.dynamic.md
deleted file mode 100644
index e63e543e68d517..00000000000000
--- a/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.dynamic.md
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) > [dynamic](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.dynamic.md)
-
-## SavedObjectsComplexFieldMapping.dynamic property
-
-Signature:
-
-```typescript
-dynamic?: string;
-```
diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.md
index 60e62212609d9f..a7d13b0015e3fd 100644
--- a/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.md
+++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectscomplexfieldmapping.md
@@ -6,6 +6,8 @@
See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation.
+Note: this type intentially doesn't include a type definition for defining the `dynamic` mapping parameter. Saved Object fields should always inherit the `dynamic: 'strict'` paramater. If you are unsure of the shape of your data use `type: 'object', enabled: false` instead.
+
Signature:
```typescript
@@ -16,7 +18,6 @@ export interface SavedObjectsComplexFieldMapping
| Property | Type | Description |
| --- | --- | --- |
-| [dynamic](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.dynamic.md) | string
| |
| [properties](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.properties.md) | SavedObjectsMappingProperties
| |
| [type](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.type.md) | string
| |
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md
index be6af335f20cd5..6f42fb32fdb7be 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.md
@@ -28,6 +28,7 @@ export interface IFieldType
| [searchable](./kibana-plugin-plugins-data-public.ifieldtype.searchable.md) | boolean
| |
| [sortable](./kibana-plugin-plugins-data-public.ifieldtype.sortable.md) | boolean
| |
| [subType](./kibana-plugin-plugins-data-public.ifieldtype.subtype.md) | IFieldSubType
| |
+| [toSpec](./kibana-plugin-plugins-data-public.ifieldtype.tospec.md) | () => FieldSpec
| |
| [type](./kibana-plugin-plugins-data-public.ifieldtype.type.md) | string
| |
| [visualizable](./kibana-plugin-plugins-data-public.ifieldtype.visualizable.md) | boolean
| |
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.tospec.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.tospec.md
new file mode 100644
index 00000000000000..1fb4084c25d343
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldtype.tospec.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldType](./kibana-plugin-plugins-data-public.ifieldtype.md) > [toSpec](./kibana-plugin-plugins-data-public.ifieldtype.tospec.md)
+
+## IFieldType.toSpec property
+
+Signature:
+
+```typescript
+toSpec?: () => FieldSpec;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.fields.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.fields.md
index 9a93148e4a466f..d4dca48c7cd7b4 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.fields.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.fields.md
@@ -7,5 +7,7 @@
Signature:
```typescript
-fields: IIndexPatternFieldList;
+fields: IIndexPatternFieldList & {
+ toSpec: () => FieldSpec[];
+ };
```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.initfromspec.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.initfromspec.md
new file mode 100644
index 00000000000000..764dd116382217
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.initfromspec.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) > [initFromSpec](./kibana-plugin-plugins-data-public.indexpattern.initfromspec.md)
+
+## IndexPattern.initFromSpec() method
+
+Signature:
+
+```typescript
+initFromSpec(spec: IndexPatternSpec): this;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| spec | IndexPatternSpec
| |
+
+Returns:
+
+`this`
+
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md
index 8ffa7b6b36f56b..d39b384c538f1b 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.md
@@ -21,7 +21,7 @@ export declare class IndexPattern implements IIndexPattern
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [fieldFormatMap](./kibana-plugin-plugins-data-public.indexpattern.fieldformatmap.md) | | any
| |
-| [fields](./kibana-plugin-plugins-data-public.indexpattern.fields.md) | | IIndexPatternFieldList
| |
+| [fields](./kibana-plugin-plugins-data-public.indexpattern.fields.md) | | IIndexPatternFieldList & {
toSpec: () => FieldSpec[];
}
| |
| [fieldsFetcher](./kibana-plugin-plugins-data-public.indexpattern.fieldsfetcher.md) | | any
| |
| [flattenHit](./kibana-plugin-plugins-data-public.indexpattern.flattenhit.md) | | any
| |
| [formatField](./kibana-plugin-plugins-data-public.indexpattern.formatfield.md) | | any
| |
@@ -30,7 +30,6 @@ export declare class IndexPattern implements IIndexPattern
| [metaFields](./kibana-plugin-plugins-data-public.indexpattern.metafields.md) | | string[]
| |
| [timeFieldName](./kibana-plugin-plugins-data-public.indexpattern.timefieldname.md) | | string | undefined
| |
| [title](./kibana-plugin-plugins-data-public.indexpattern.title.md) | | string
| |
-| [type](./kibana-plugin-plugins-data-public.indexpattern.type.md) | | string
| |
| [typeMeta](./kibana-plugin-plugins-data-public.indexpattern.typemeta.md) | | TypeMeta
| |
## Methods
@@ -49,6 +48,7 @@ export declare class IndexPattern implements IIndexPattern
| [getSourceFiltering()](./kibana-plugin-plugins-data-public.indexpattern.getsourcefiltering.md) | | |
| [getTimeField()](./kibana-plugin-plugins-data-public.indexpattern.gettimefield.md) | | |
| [init(forceFieldRefresh)](./kibana-plugin-plugins-data-public.indexpattern.init.md) | | |
+| [initFromSpec(spec)](./kibana-plugin-plugins-data-public.indexpattern.initfromspec.md) | | |
| [isTimeBased()](./kibana-plugin-plugins-data-public.indexpattern.istimebased.md) | | |
| [isTimeBasedWildcard()](./kibana-plugin-plugins-data-public.indexpattern.istimebasedwildcard.md) | | |
| [isTimeNanosBased()](./kibana-plugin-plugins-data-public.indexpattern.istimenanosbased.md) | | |
@@ -59,5 +59,6 @@ export declare class IndexPattern implements IIndexPattern
| [removeScriptedField(field)](./kibana-plugin-plugins-data-public.indexpattern.removescriptedfield.md) | | |
| [save(saveAttempts)](./kibana-plugin-plugins-data-public.indexpattern.save.md) | | |
| [toJSON()](./kibana-plugin-plugins-data-public.indexpattern.tojson.md) | | |
+| [toSpec()](./kibana-plugin-plugins-data-public.indexpattern.tospec.md) | | |
| [toString()](./kibana-plugin-plugins-data-public.indexpattern.tostring.md) | | |
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.type.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.tospec.md
similarity index 53%
rename from docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.type.md
rename to docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.tospec.md
index 58047d9e27ac63..d1a78eea660cea 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.type.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpattern.tospec.md
@@ -1,11 +1,15 @@
-[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) > [type](./kibana-plugin-plugins-data-public.indexpattern.type.md)
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) > [toSpec](./kibana-plugin-plugins-data-public.indexpattern.tospec.md)
-## IndexPattern.type property
+## IndexPattern.toSpec() method
Signature:
```typescript
-type?: string;
+toSpec(): IndexPatternSpec;
```
+Returns:
+
+`IndexPatternSpec`
+
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md
index e1e0d58ce38c10..7a195702b6f13f 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md
@@ -9,7 +9,7 @@ Constructs a new instance of the `Field` class
Signature:
```typescript
-constructor(indexPattern: IIndexPattern, spec: FieldSpec | Field, shortDotsEnable: boolean, { fieldFormats, onNotification }: FieldDependencies);
+constructor(indexPattern: IIndexPattern, spec: FieldSpecExportFmt | FieldSpec | Field, shortDotsEnable: boolean, { fieldFormats, onNotification }: FieldDependencies);
```
## Parameters
@@ -17,7 +17,7 @@ constructor(indexPattern: IIndexPattern, spec: FieldSpec | Field, shortDotsEnabl
| Parameter | Type | Description |
| --- | --- | --- |
| indexPattern | IIndexPattern
| |
-| spec | FieldSpec | Field
| |
+| spec | FieldSpecExportFmt | FieldSpec | Field
| |
| shortDotsEnable | boolean
| |
| { fieldFormats, onNotification } | FieldDependencies
| |
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md
index ca2552aeb1b425..ec19a4854bf0e6 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md
@@ -7,5 +7,5 @@
Signature:
```typescript
-conflictDescriptions?: Record;
+conflictDescriptions?: FieldSpecConflictDescriptions;
```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md
index 8fa1ee0d72e54d..d82999e7a96af4 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md
@@ -22,7 +22,7 @@ export declare class Field implements IFieldType
| --- | --- | --- | --- |
| [$$spec](./kibana-plugin-plugins-data-public.indexpatternfield.__spec.md) | | FieldSpec
| |
| [aggregatable](./kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md) | | boolean
| |
-| [conflictDescriptions](./kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md) | | Record<string, string[]>
| |
+| [conflictDescriptions](./kibana-plugin-plugins-data-public.indexpatternfield.conflictdescriptions.md) | | FieldSpecConflictDescriptions
| |
| [count](./kibana-plugin-plugins-data-public.indexpatternfield.count.md) | | number
| |
| [displayName](./kibana-plugin-plugins-data-public.indexpatternfield.displayname.md) | | string
| |
| [esTypes](./kibana-plugin-plugins-data-public.indexpatternfield.estypes.md) | | string[]
| |
@@ -37,6 +37,7 @@ export declare class Field implements IFieldType
| [searchable](./kibana-plugin-plugins-data-public.indexpatternfield.searchable.md) | | boolean
| |
| [sortable](./kibana-plugin-plugins-data-public.indexpatternfield.sortable.md) | | boolean
| |
| [subType](./kibana-plugin-plugins-data-public.indexpatternfield.subtype.md) | | IFieldSubType
| |
+| [toSpec](./kibana-plugin-plugins-data-public.indexpatternfield.tospec.md) | | () => FieldSpecExportFmt
| |
| [type](./kibana-plugin-plugins-data-public.indexpatternfield.type.md) | | string
| |
| [visualizable](./kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md) | | boolean
| |
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tospec.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tospec.md
new file mode 100644
index 00000000000000..35714faa03bc9a
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.tospec.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [toSpec](./kibana-plugin-plugins-data-public.indexpatternfield.tospec.md)
+
+## IndexPatternField.toSpec property
+
+Signature:
+
+```typescript
+toSpec: () => FieldSpecExportFmt;
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isfilter.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isfilter.md
new file mode 100644
index 00000000000000..f1916e89c2c98e
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isfilter.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [isFilter](./kibana-plugin-plugins-data-public.isfilter.md)
+
+## isFilter variable
+
+Signature:
+
+```typescript
+isFilter: (x: unknown) => x is Filter
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isfilters.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isfilters.md
new file mode 100644
index 00000000000000..558da72cc26bb4
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isfilters.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [isFilters](./kibana-plugin-plugins-data-public.isfilters.md)
+
+## isFilters variable
+
+Signature:
+
+```typescript
+isFilters: (x: unknown) => x is Filter[]
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isquery.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isquery.md
new file mode 100644
index 00000000000000..0884566333aa87
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.isquery.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [isQuery](./kibana-plugin-plugins-data-public.isquery.md)
+
+## isQuery variable
+
+Signature:
+
+```typescript
+isQuery: (x: unknown) => x is Query
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.istimerange.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.istimerange.md
new file mode 100644
index 00000000000000..e9420493c82fba
--- /dev/null
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.istimerange.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [isTimeRange](./kibana-plugin-plugins-data-public.istimerange.md)
+
+## isTimeRange variable
+
+Signature:
+
+```typescript
+isTimeRange: (x: unknown) => x is TimeRange
+```
diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
index f62479f02926e5..feeb686a1f5ede 100644
--- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
+++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md
@@ -110,6 +110,10 @@
| [getKbnTypeNames](./kibana-plugin-plugins-data-public.getkbntypenames.md) | Get the esTypes known by all kbnFieldTypes {Array} |
| [indexPatterns](./kibana-plugin-plugins-data-public.indexpatterns.md) | |
| [injectSearchSourceReferences](./kibana-plugin-plugins-data-public.injectsearchsourcereferences.md) | |
+| [isFilter](./kibana-plugin-plugins-data-public.isfilter.md) | |
+| [isFilters](./kibana-plugin-plugins-data-public.isfilters.md) | |
+| [isQuery](./kibana-plugin-plugins-data-public.isquery.md) | |
+| [isTimeRange](./kibana-plugin-plugins-data-public.istimerange.md) | |
| [parseSearchSourceJSON](./kibana-plugin-plugins-data-public.parsesearchsourcejson.md) | |
| [QueryStringInput](./kibana-plugin-plugins-data-public.querystringinput.md) | |
| [search](./kibana-plugin-plugins-data-public.search.md) | |
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md
index 5375cf2a2ef431..77a2954428f8d4 100644
--- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.md
@@ -28,6 +28,7 @@ export interface IFieldType
| [searchable](./kibana-plugin-plugins-data-server.ifieldtype.searchable.md) | boolean
| |
| [sortable](./kibana-plugin-plugins-data-server.ifieldtype.sortable.md) | boolean
| |
| [subType](./kibana-plugin-plugins-data-server.ifieldtype.subtype.md) | IFieldSubType
| |
+| [toSpec](./kibana-plugin-plugins-data-server.ifieldtype.tospec.md) | () => FieldSpec
| |
| [type](./kibana-plugin-plugins-data-server.ifieldtype.type.md) | string
| |
| [visualizable](./kibana-plugin-plugins-data-server.ifieldtype.visualizable.md) | boolean
| |
diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.tospec.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.tospec.md
new file mode 100644
index 00000000000000..d1863bebce4f00
--- /dev/null
+++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.ifieldtype.tospec.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldType](./kibana-plugin-plugins-data-server.ifieldtype.md) > [toSpec](./kibana-plugin-plugins-data-server.ifieldtype.tospec.md)
+
+## IFieldType.toSpec property
+
+Signature:
+
+```typescript
+toSpec?: () => FieldSpec;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/index.md b/docs/development/plugins/kibana_utils/common/state_containers/index.md
new file mode 100644
index 00000000000000..b4e1071ceb7324
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/index.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md)
+
+## API Reference
+
+## Packages
+
+| Package | Description |
+| --- | --- |
+| [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) | State containers are Redux-store-like objects meant to help you manage state in your services or apps. Refer to [guides and examples](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_containers) for more info |
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestate.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestate.md
new file mode 100644
index 00000000000000..92893afc02beff
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestate.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [BaseState](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestate.md)
+
+## BaseState type
+
+Base [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) state shape
+
+Signature:
+
+```typescript
+export declare type BaseState = object;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.get.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.get.md
new file mode 100644
index 00000000000000..b939954d92aa6e
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.get.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) > [get](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.get.md)
+
+## BaseStateContainer.get property
+
+Retrieves current state from the container
+
+Signature:
+
+```typescript
+get: () => State;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md
new file mode 100644
index 00000000000000..66c25c87f5e37d
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md)
+
+## BaseStateContainer interface
+
+Base state container shape without transitions or selectors
+
+Signature:
+
+```typescript
+export interface BaseStateContainer
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [get](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.get.md) | () => State
| Retrieves current state from the container |
+| [set](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.set.md) | (state: State) => void
| Sets state into container |
+| [state$](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.state_.md) | Observable<State>
| of state |
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.set.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.set.md
new file mode 100644
index 00000000000000..ed4ff365adfb35
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.set.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) > [set](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.set.md)
+
+## BaseStateContainer.set property
+
+Sets state into container
+
+Signature:
+
+```typescript
+set: (state: State) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.state_.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.state_.md
new file mode 100644
index 00000000000000..35838fa53d5390
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.state_.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) > [state$](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.state_.md)
+
+## BaseStateContainer.state$ property
+
+ of state
+
+Signature:
+
+```typescript
+state$: Observable;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md
new file mode 100644
index 00000000000000..12af33756fb19d
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [Comparator](./kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md)
+
+## Comparator type
+
+Used to compare state. see [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md)
+
+Signature:
+
+```typescript
+export declare type Comparator = (previous: Result, current: Result) => boolean;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md
new file mode 100644
index 00000000000000..e05f1fb392fe6e
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [Connect](./kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md)
+
+## Connect type
+
+Similar to `connect` from react-redux, allows to map state from state container to component's props
+
+Signature:
+
+```typescript
+export declare type Connect = (mapStateToProp: MapStateToProps>) => (component: ComponentType) => FC>;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer.md
new file mode 100644
index 00000000000000..cc43b59676dc13
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [createStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer.md)
+
+## createStateContainer() function
+
+Creates a state container without transitions and without selectors.
+
+Signature:
+
+```typescript
+export declare function createStateContainer(defaultState: State): ReduxLikeStateContainer;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| defaultState | State
| initial state |
+
+Returns:
+
+`ReduxLikeStateContainer`
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md
new file mode 100644
index 00000000000000..794bf63588312f
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md
@@ -0,0 +1,25 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [createStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md)
+
+## createStateContainer() function
+
+Creates a state container with transitions, but without selectors
+
+Signature:
+
+```typescript
+export declare function createStateContainer(defaultState: State, pureTransitions: PureTransitions): ReduxLikeStateContainer;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| defaultState | State
| initial state |
+| pureTransitions | PureTransitions
| state transitions configuration object. Map of . |
+
+Returns:
+
+`ReduxLikeStateContainer`
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md
new file mode 100644
index 00000000000000..1946baae202f1d
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md
@@ -0,0 +1,27 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [createStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md)
+
+## createStateContainer() function
+
+Creates a state container with transitions and selectors
+
+Signature:
+
+```typescript
+export declare function createStateContainer(defaultState: State, pureTransitions: PureTransitions, pureSelectors: PureSelectors, options?: CreateStateContainerOptions): ReduxLikeStateContainer;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| defaultState | State
| initial state |
+| pureTransitions | PureTransitions
| state transitions configuration object. Map of . |
+| pureSelectors | PureSelectors
| state selectors configuration object. Map of . |
+| options | CreateStateContainerOptions
| state container options [CreateStateContainerOptions](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md) |
+
+Returns:
+
+`ReduxLikeStateContainer`
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md
new file mode 100644
index 00000000000000..4f772c7c54d084
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md
@@ -0,0 +1,25 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [CreateStateContainerOptions](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md) > [freeze](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md)
+
+## CreateStateContainerOptions.freeze property
+
+Function to use when freezing state. Supply identity function. If not provided, default deepFreeze is use.
+
+Signature:
+
+```typescript
+freeze?: (state: T) => T;
+```
+
+## Example
+
+If you expect that your state will be mutated externally an you cannot prevent that
+
+```ts
+{
+ freeze: state => state,
+}
+
+```
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md
new file mode 100644
index 00000000000000..d328d306e93e1d
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [CreateStateContainerOptions](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md)
+
+## CreateStateContainerOptions interface
+
+State container options
+
+Signature:
+
+```typescript
+export interface CreateStateContainerOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [freeze](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md) | <T>(state: T) => T
| Function to use when freezing state. Supply identity function. If not provided, default deepFreeze is use. |
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainerreacthelpers.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainerreacthelpers.md
new file mode 100644
index 00000000000000..a6076490c27465
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainerreacthelpers.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [createStateContainerReactHelpers](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainerreacthelpers.md)
+
+## createStateContainerReactHelpers variable
+
+Creates helpers for using [State Containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) with react Refer to [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_containers/react.md) for details
+
+Signature:
+
+```typescript
+createStateContainerReactHelpers: >() => {
+ Provider: React.Provider;
+ Consumer: React.Consumer;
+ context: React.Context;
+ useContainer: () => Container;
+ useState: () => UnboxState;
+ useTransitions: () => Container["transitions"];
+ useSelector: (selector: (state: UnboxState) => Result, comparator?: Comparator) => Result;
+ connect: Connect>;
+}
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.dispatch.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.dispatch.md
new file mode 100644
index 00000000000000..d4057a549bb0dc
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.dispatch.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [Dispatch](./kibana-plugin-plugins-kibana_utils-common-state_containers.dispatch.md)
+
+## Dispatch type
+
+Redux like dispatch
+
+Signature:
+
+```typescript
+export declare type Dispatch = (action: T) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepureselector.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepureselector.md
new file mode 100644
index 00000000000000..5e4e86ad82d538
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepureselector.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [EnsurePureSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepureselector.md)
+
+## EnsurePureSelector type
+
+
+Signature:
+
+```typescript
+export declare type EnsurePureSelector = Ensure>;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepuretransition.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepuretransition.md
new file mode 100644
index 00000000000000..0e621e989346b4
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepuretransition.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [EnsurePureTransition](./kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepuretransition.md)
+
+## EnsurePureTransition type
+
+
+Signature:
+
+```typescript
+export declare type EnsurePureTransition = Ensure>;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.mapstatetoprops.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.mapstatetoprops.md
new file mode 100644
index 00000000000000..8e6a49ac727426
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.mapstatetoprops.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [MapStateToProps](./kibana-plugin-plugins-kibana_utils-common-state_containers.mapstatetoprops.md)
+
+## MapStateToProps type
+
+State container state to component props mapper. See [Connect](./kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md)
+
+Signature:
+
+```typescript
+export declare type MapStateToProps = (state: State) => StateProps;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md
new file mode 100644
index 00000000000000..e74ff2c6885be1
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md
@@ -0,0 +1,52 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md)
+
+## kibana-plugin-plugins-kibana\_utils-common-state\_containers package
+
+State containers are Redux-store-like objects meant to help you manage state in your services or apps. Refer to [guides and examples](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_containers) for more info
+
+## Functions
+
+| Function | Description |
+| --- | --- |
+| [createStateContainer(defaultState)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer.md) | Creates a state container without transitions and without selectors. |
+| [createStateContainer(defaultState, pureTransitions)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md) | Creates a state container with transitions, but without selectors |
+| [createStateContainer(defaultState, pureTransitions, pureSelectors, options)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md) | Creates a state container with transitions and selectors |
+
+## Interfaces
+
+| Interface | Description |
+| --- | --- |
+| [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) | Base state container shape without transitions or selectors |
+| [CreateStateContainerOptions](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md) | State container options |
+| [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) | Fully featured state container which matches Redux store interface. Extends [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) Allows to use state container with redux libraries |
+| [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) | Fully featured state container with [Selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) and . Extends [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) |
+
+## Variables
+
+| Variable | Description |
+| --- | --- |
+| [createStateContainerReactHelpers](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainerreacthelpers.md) | Creates helpers for using [State Containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) with react Refer to [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_containers/react.md) for details |
+| [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md) | React hook to apply selector to state container to extract only needed information. Will re-render your component only when the section changes. |
+| [useContainerState](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerstate.md) | React hooks that returns the latest state of a [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md). |
+
+## Type Aliases
+
+| Type Alias | Description |
+| --- | --- |
+| [BaseState](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestate.md) | Base [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) state shape |
+| [Comparator](./kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md) | Used to compare state. see [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md) |
+| [Connect](./kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md) | Similar to connect
from react-redux, allows to map state from state container to component's props |
+| [Dispatch](./kibana-plugin-plugins-kibana_utils-common-state_containers.dispatch.md) | Redux like dispatch |
+| [EnsurePureSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepureselector.md) | |
+| [EnsurePureTransition](./kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepuretransition.md) | |
+| [MapStateToProps](./kibana-plugin-plugins-kibana_utils-common-state_containers.mapstatetoprops.md) | State container state to component props mapper. See [Connect](./kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md) |
+| [Middleware](./kibana-plugin-plugins-kibana_utils-common-state_containers.middleware.md) | Redux like Middleware |
+| [PureSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.pureselector.md) | |
+| [PureSelectorsToSelectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectorstoselectors.md) | |
+| [PureSelectorToSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectortoselector.md) | |
+| [Reducer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reducer.md) | Redux like Reducer |
+| [Selector](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) | |
+| [UnboxState](./kibana-plugin-plugins-kibana_utils-common-state_containers.unboxstate.md) | Utility type for inferring state shape from [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) |
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.middleware.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.middleware.md
new file mode 100644
index 00000000000000..574b83306dc959
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.middleware.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [Middleware](./kibana-plugin-plugins-kibana_utils-common-state_containers.middleware.md)
+
+## Middleware type
+
+Redux like Middleware
+
+Signature:
+
+```typescript
+export declare type Middleware = (store: Pick, 'getState' | 'dispatch'>) => (next: (action: TransitionDescription) => TransitionDescription | any) => Dispatch;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselector.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselector.md
new file mode 100644
index 00000000000000..6ac07cba446f51
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselector.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [PureSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.pureselector.md)
+
+## PureSelector type
+
+
+Signature:
+
+```typescript
+export declare type PureSelector = (state: State) => Selector;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectorstoselectors.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectorstoselectors.md
new file mode 100644
index 00000000000000..82a91f7c87e17f
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectorstoselectors.md
@@ -0,0 +1,14 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [PureSelectorsToSelectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectorstoselectors.md)
+
+## PureSelectorsToSelectors type
+
+
+Signature:
+
+```typescript
+export declare type PureSelectorsToSelectors = {
+ [K in keyof T]: PureSelectorToSelector>;
+};
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectortoselector.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectortoselector.md
new file mode 100644
index 00000000000000..5c12afd1cd971a
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectortoselector.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [PureSelectorToSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.pureselectortoselector.md)
+
+## PureSelectorToSelector type
+
+
+Signature:
+
+```typescript
+export declare type PureSelectorToSelector> = ReturnType>;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reducer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reducer.md
new file mode 100644
index 00000000000000..519e6ce7d7cfb3
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reducer.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [Reducer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reducer.md)
+
+## Reducer type
+
+Redux like Reducer
+
+Signature:
+
+```typescript
+export declare type Reducer = (state: State, action: TransitionDescription) => State;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.addmiddleware.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.addmiddleware.md
new file mode 100644
index 00000000000000..e90da05e30d878
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.addmiddleware.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) > [addMiddleware](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.addmiddleware.md)
+
+## ReduxLikeStateContainer.addMiddleware property
+
+Signature:
+
+```typescript
+addMiddleware: (middleware: Middleware) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.dispatch.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.dispatch.md
new file mode 100644
index 00000000000000..7a9755ee3b65cd
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.dispatch.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) > [dispatch](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.dispatch.md)
+
+## ReduxLikeStateContainer.dispatch property
+
+Signature:
+
+```typescript
+dispatch: (action: TransitionDescription) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.getstate.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.getstate.md
new file mode 100644
index 00000000000000..86e1c6dd34cd6a
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.getstate.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) > [getState](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.getstate.md)
+
+## ReduxLikeStateContainer.getState property
+
+Signature:
+
+```typescript
+getState: () => State;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md
new file mode 100644
index 00000000000000..0e08119c1eae44
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md
@@ -0,0 +1,25 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md)
+
+## ReduxLikeStateContainer interface
+
+Fully featured state container which matches Redux store interface. Extends [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) Allows to use state container with redux libraries
+
+Signature:
+
+```typescript
+export interface ReduxLikeStateContainer extends StateContainer
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [addMiddleware](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.addmiddleware.md) | (middleware: Middleware<State>) => void
| |
+| [dispatch](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.dispatch.md) | (action: TransitionDescription) => void
| |
+| [getState](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.getstate.md) | () => State
| |
+| [reducer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.reducer.md) | Reducer<State>
| |
+| [replaceReducer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.replacereducer.md) | (nextReducer: Reducer<State>) => void
| |
+| [subscribe](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.subscribe.md) | (listener: (state: State) => void) => () => void
| |
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.reducer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.reducer.md
new file mode 100644
index 00000000000000..49eabf19340f2b
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.reducer.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) > [reducer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.reducer.md)
+
+## ReduxLikeStateContainer.reducer property
+
+Signature:
+
+```typescript
+reducer: Reducer;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.replacereducer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.replacereducer.md
new file mode 100644
index 00000000000000..2582d31d9adc4f
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.replacereducer.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) > [replaceReducer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.replacereducer.md)
+
+## ReduxLikeStateContainer.replaceReducer property
+
+Signature:
+
+```typescript
+replaceReducer: (nextReducer: Reducer) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.subscribe.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.subscribe.md
new file mode 100644
index 00000000000000..15139a7bd9f3e6
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.subscribe.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) > [subscribe](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.subscribe.md)
+
+## ReduxLikeStateContainer.subscribe property
+
+Signature:
+
+```typescript
+subscribe: (listener: (state: State) => void) => () => void;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md
new file mode 100644
index 00000000000000..5c143551d130b3
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [Selector](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md)
+
+## Selector type
+
+
+Signature:
+
+```typescript
+export declare type Selector = (...args: Args) => Result;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md
new file mode 100644
index 00000000000000..23ec1c8e5be010
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md)
+
+## StateContainer interface
+
+Fully featured state container with [Selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) and . Extends [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md)
+
+Signature:
+
+```typescript
+export interface StateContainer extends BaseStateContainer
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.selectors.md) | Readonly<PureSelectorsToSelectors<PureSelectors>>
| |
+| [transitions](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.transitions.md) | Readonly<PureTransitionsToTransitions<PureTransitions>>
| |
+
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.selectors.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.selectors.md
new file mode 100644
index 00000000000000..2afac07b59e396
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.selectors.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) > [selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.selectors.md)
+
+## StateContainer.selectors property
+
+Signature:
+
+```typescript
+selectors: Readonly>;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.transitions.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.transitions.md
new file mode 100644
index 00000000000000..4712d3287beef5
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.transitions.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) > [transitions](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.transitions.md)
+
+## StateContainer.transitions property
+
+Signature:
+
+```typescript
+transitions: Readonly>;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.unboxstate.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.unboxstate.md
new file mode 100644
index 00000000000000..d4f99841456d74
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.unboxstate.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [UnboxState](./kibana-plugin-plugins-kibana_utils-common-state_containers.unboxstate.md)
+
+## UnboxState type
+
+Utility type for inferring state shape from [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md)
+
+Signature:
+
+```typescript
+export declare type UnboxState> = Container extends StateContainer ? T : never;
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md
new file mode 100644
index 00000000000000..fe5f30a9c84720
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md)
+
+## useContainerSelector variable
+
+React hook to apply selector to state container to extract only needed information. Will re-render your component only when the section changes.
+
+Signature:
+
+```typescript
+useContainerSelector: , Result>(container: Container, selector: (state: UnboxState) => Result, comparator?: Comparator) => Result
+```
diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerstate.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerstate.md
new file mode 100644
index 00000000000000..7cef47c58f9d98
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerstate.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-common-state\_containers](./kibana-plugin-plugins-kibana_utils-common-state_containers.md) > [useContainerState](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerstate.md)
+
+## useContainerState variable
+
+React hooks that returns the latest state of a [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md).
+
+Signature:
+
+```typescript
+useContainerState: >(container: Container) => UnboxState
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/index.md b/docs/development/plugins/kibana_utils/public/state_sync/index.md
new file mode 100644
index 00000000000000..4b345d9130bd54
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/index.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md)
+
+## API Reference
+
+## Packages
+
+| Package | Description |
+| --- | --- |
+| [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) | State syncing utilities are a set of helpers for syncing your application state with URL or browser storage.They are designed to work together with state containers (). But state containers are not required.State syncing utilities include:- util which: - Subscribes to state changes and pushes them to state storage. - Optionally subscribes to state storage changes and pushes them to state. - Two types of storage compatible with syncState
: - - Serializes state and persists it to URL's query param in rison or hashed format. Listens for state updates in the URL and pushes them back to state. - - Serializes state and persists it to browser storage.Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.createkbnurlstatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.createkbnurlstatestorage.md
new file mode 100644
index 00000000000000..22f70ce22b5745
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.createkbnurlstatestorage.md
@@ -0,0 +1,16 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [createKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.createkbnurlstatestorage.md)
+
+## createKbnUrlStateStorage variable
+
+Creates [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) state storage
+
+Signature:
+
+```typescript
+createKbnUrlStateStorage: ({ useHash, history }?: {
+ useHash: boolean;
+ history?: History | undefined;
+}) => IKbnUrlStateStorage
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.createsessionstoragestatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.createsessionstoragestatestorage.md
new file mode 100644
index 00000000000000..dccff93ad17247
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.createsessionstoragestatestorage.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [createSessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.createsessionstoragestatestorage.md)
+
+## createSessionStorageStateStorage variable
+
+Creates [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/session_storage.md)
+
+Signature:
+
+```typescript
+createSessionStorageStateStorage: (storage?: Storage) => ISessionStorageStateStorage
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md
new file mode 100644
index 00000000000000..29a511d57d7bd6
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) > [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md)
+
+## IKbnUrlStateStorage.cancel property
+
+cancels any pending url updates
+
+Signature:
+
+```typescript
+cancel: () => void;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md
new file mode 100644
index 00000000000000..2b55f2aca70c81
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) > [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md)
+
+## IKbnUrlStateStorage.change$ property
+
+Signature:
+
+```typescript
+change$: (key: string) => Observable;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md
new file mode 100644
index 00000000000000..e0e6aa9be4368b
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) > [flush](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md)
+
+## IKbnUrlStateStorage.flush property
+
+synchronously runs any pending url updates returned boolean indicates if change occurred
+
+Signature:
+
+```typescript
+flush: (opts?: {
+ replace?: boolean;
+ }) => boolean;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md
new file mode 100644
index 00000000000000..0eb60c21fbbbfc
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) > [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md)
+
+## IKbnUrlStateStorage.get property
+
+Signature:
+
+```typescript
+get: (key: string) => State | null;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md
new file mode 100644
index 00000000000000..56cefebd2acfe6
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md)
+
+## IKbnUrlStateStorage interface
+
+KbnUrlStateStorage is a state storage for [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) utility which: 1. Keeps state in sync with the URL. 2. Serializes data and stores it in the URL in one of the supported formats: \* Rison encoded. \* Hashed URL: In URL we store only the hash from the serialized state, but the state itself is stored in sessionStorage. See kibana's advanced option for more context state:storeInSessionStorage 3. Takes care of listening to the URL updates and notifies state about the updates. 4. Takes care of batching URL updates to prevent redundant browser history records. [GUIDE](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/kbn_url_storage.md)
+
+Signature:
+
+```typescript
+export interface IKbnUrlStateStorage extends IStateStorage
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md) | () => void
| cancels any pending url updates |
+| [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md) | <State = unknown>(key: string) => Observable<State | null>
| |
+| [flush](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md) | (opts?: {
replace?: boolean;
}) => boolean
| synchronously runs any pending url updates returned boolean indicates if change occurred |
+| [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md) | <State = unknown>(key: string) => State | null
| |
+| [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.set.md) | <State>(key: string, state: State, opts?: {
replace: boolean;
}) => Promise<string | undefined>
| |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.set.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.set.md
new file mode 100644
index 00000000000000..2eab44d3444144
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.set.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) > [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.set.md)
+
+## IKbnUrlStateStorage.set property
+
+Signature:
+
+```typescript
+set: (key: string, state: State, opts?: {
+ replace: boolean;
+ }) => Promise;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md
new file mode 100644
index 00000000000000..ca69609936405c
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [INullableBaseStateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md)
+
+## INullableBaseStateContainer interface
+
+Extension of with one constraint: set state should handle `null` as incoming state
+
+Signature:
+
+```typescript
+export interface INullableBaseStateContainer extends BaseStateContainer
+```
+
+## Remarks
+
+State container for stateSync() have to accept "null" for example, set() implementation could handle null and fallback to some default state this is required to handle edge case, when state in storage becomes empty and syncing is in progress. state container will be notified about about storage becoming empty with null passed in
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.set.md) | (state: State | null) => void
| |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.set.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.set.md
new file mode 100644
index 00000000000000..dd2978f59484a0
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.set.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [INullableBaseStateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md) > [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.set.md)
+
+## INullableBaseStateContainer.set property
+
+Signature:
+
+```typescript
+set: (state: State | null) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.get.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.get.md
new file mode 100644
index 00000000000000..83131c77132cee
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.get.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) > [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.get.md)
+
+## ISessionStorageStateStorage.get property
+
+Signature:
+
+```typescript
+get: (key: string) => State | null;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md
new file mode 100644
index 00000000000000..7792bc3932f956
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md
@@ -0,0 +1,21 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md)
+
+## ISessionStorageStateStorage interface
+
+[IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) for storing state in browser [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/session_storage.md)
+
+Signature:
+
+```typescript
+export interface ISessionStorageStateStorage extends IStateStorage
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.get.md) | <State = unknown>(key: string) => State | null
| |
+| [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.set.md) | <State>(key: string, state: State) => void
| |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.set.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.set.md
new file mode 100644
index 00000000000000..04b0ab01f0d133
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.set.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) > [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.set.md)
+
+## ISessionStorageStateStorage.set property
+
+Signature:
+
+```typescript
+set: (key: string, state: State) => void;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md
new file mode 100644
index 00000000000000..ce771d52a6e60f
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) > [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md)
+
+## IStateStorage.cancel property
+
+Optional method to cancel any pending activity syncState() will call it, if it is provided by IStateStorage
+
+Signature:
+
+```typescript
+cancel?: () => void;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.change_.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.change_.md
new file mode 100644
index 00000000000000..ed6672a3d83c62
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.change_.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) > [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.change_.md)
+
+## IStateStorage.change$ property
+
+Should notify when the stored state has changed
+
+Signature:
+
+```typescript
+change$?: (key: string) => Observable;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.get.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.get.md
new file mode 100644
index 00000000000000..2c0b2ee970cc62
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.get.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) > [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.get.md)
+
+## IStateStorage.get property
+
+Should retrieve state from the storage and deserialize it
+
+Signature:
+
+```typescript
+get: (key: string) => State | null;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md
new file mode 100644
index 00000000000000..2c34a185fb7b12
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md
@@ -0,0 +1,25 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md)
+
+## IStateStorage interface
+
+Any StateStorage have to implement IStateStorage interface StateStorage is responsible for: \* state serialisation / deserialization \* persisting to and retrieving from storage
+
+For an example take a look at already implemented [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) and [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) state storages
+
+Signature:
+
+```typescript
+export interface IStateStorage
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md) | () => void
| Optional method to cancel any pending activity syncState() will call it, if it is provided by IStateStorage |
+| [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.change_.md) | <State = unknown>(key: string) => Observable<State | null>
| Should notify when the stored state has changed |
+| [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.get.md) | <State = unknown>(key: string) => State | null
| Should retrieve state from the storage and deserialize it |
+| [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.set.md) | <State>(key: string, state: State) => any
| Take in a state object, should serialise and persist |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.set.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.set.md
new file mode 100644
index 00000000000000..3f286994ed4afc
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.set.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) > [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.set.md)
+
+## IStateStorage.set property
+
+Take in a state object, should serialise and persist
+
+Signature:
+
+```typescript
+set: (key: string, state: State) => any;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md
new file mode 100644
index 00000000000000..f9368de4240ac6
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateSyncConfig](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md)
+
+## IStateSyncConfig interface
+
+Config for setting up state syncing with
+
+Signature:
+
+```typescript
+export interface IStateSyncConfig
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [stateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statecontainer.md) | INullableBaseStateContainer<State>
| State container to keep in sync with storage, have to implement [INullableBaseStateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md) interface We encourage to use as a state container, but it is also possible to implement own custom container for advanced use cases |
+| [stateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statestorage.md) | StateStorage
| State storage to use, State storage is responsible for serialising / deserialising and persisting / retrieving stored stateThere are common strategies already implemented: see [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) which replicate what State (AppState, GlobalState) in legacy world did |
+| [storageKey](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.storagekey.md) | string
| Storage key to use for syncing, e.g. storageKey '\_a' should sync state to ?\_a query param |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statecontainer.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statecontainer.md
new file mode 100644
index 00000000000000..0098dd5c99aeb3
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statecontainer.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateSyncConfig](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md) > [stateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statecontainer.md)
+
+## IStateSyncConfig.stateContainer property
+
+State container to keep in sync with storage, have to implement [INullableBaseStateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md) interface We encourage to use as a state container, but it is also possible to implement own custom container for advanced use cases
+
+Signature:
+
+```typescript
+stateContainer: INullableBaseStateContainer;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statestorage.md
new file mode 100644
index 00000000000000..ef872ba0ba9b5d
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statestorage.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateSyncConfig](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md) > [stateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.statestorage.md)
+
+## IStateSyncConfig.stateStorage property
+
+State storage to use, State storage is responsible for serialising / deserialising and persisting / retrieving stored state
+
+There are common strategies already implemented: see [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) which replicate what State (AppState, GlobalState) in legacy world did
+
+Signature:
+
+```typescript
+stateStorage: StateStorage;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.storagekey.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.storagekey.md
new file mode 100644
index 00000000000000..d3887c23df1e0d
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.storagekey.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [IStateSyncConfig](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md) > [storageKey](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.storagekey.md)
+
+## IStateSyncConfig.storageKey property
+
+Storage key to use for syncing, e.g. storageKey '\_a' should sync state to ?\_a query param
+
+Signature:
+
+```typescript
+storageKey: string;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md
new file mode 100644
index 00000000000000..137db68cd6b487
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [ISyncStateRef](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md)
+
+## ISyncStateRef interface
+
+
+Signature:
+
+```typescript
+export interface ISyncStateRef
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [start](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.start.md) | StartSyncStateFnType
| start state syncing |
+| [stop](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.stop.md) | StopSyncStateFnType
| stop state syncing |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.start.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.start.md
new file mode 100644
index 00000000000000..d8df808ba215f4
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.start.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [ISyncStateRef](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md) > [start](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.start.md)
+
+## ISyncStateRef.start property
+
+start state syncing
+
+Signature:
+
+```typescript
+start: StartSyncStateFnType;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.stop.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.stop.md
new file mode 100644
index 00000000000000..70356dd9d6c791
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.stop.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [ISyncStateRef](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md) > [stop](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.stop.md)
+
+## ISyncStateRef.stop property
+
+stop state syncing
+
+Signature:
+
+```typescript
+stop: StopSyncStateFnType;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md
new file mode 100644
index 00000000000000..2b02c98e0d6053
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md
@@ -0,0 +1,48 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md)
+
+## kibana-plugin-plugins-kibana\_utils-public-state\_sync package
+
+State syncing utilities are a set of helpers for syncing your application state with URL or browser storage.
+
+They are designed to work together with state containers (). But state containers are not required.
+
+State syncing utilities include:
+
+- [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) util which: - Subscribes to state changes and pushes them to state storage. - Optionally subscribes to state storage changes and pushes them to state. - Two types of storage compatible with `syncState`: - [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) - Serializes state and persists it to URL's query param in rison or hashed format. Listens for state updates in the URL and pushes them back to state. - [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) - Serializes state and persists it to browser storage.
+
+Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples
+
+## Functions
+
+| Function | Description |
+| --- | --- |
+| [syncState({ storageKey, stateStorage, stateContainer, })](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) | Utility for syncing application state wrapped in state container with some kind of storage (e.g. URL) Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples |
+| [syncStates(stateSyncConfigs)](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstates.md) | |
+
+## Interfaces
+
+| Interface | Description |
+| --- | --- |
+| [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) | KbnUrlStateStorage is a state storage for [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) utility which: 1. Keeps state in sync with the URL. 2. Serializes data and stores it in the URL in one of the supported formats: \* Rison encoded. \* Hashed URL: In URL we store only the hash from the serialized state, but the state itself is stored in sessionStorage. See kibana's advanced option for more context state:storeInSessionStorage 3. Takes care of listening to the URL updates and notifies state about the updates. 4. Takes care of batching URL updates to prevent redundant browser history records. [GUIDE](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/kbn_url_storage.md) |
+| [INullableBaseStateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md) | Extension of with one constraint: set state should handle null
as incoming state |
+| [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) | [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) for storing state in browser [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/session_storage.md) |
+| [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) | Any StateStorage have to implement IStateStorage interface StateStorage is responsible for: \* state serialisation / deserialization \* persisting to and retrieving from storageFor an example take a look at already implemented [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) and [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) state storages |
+| [IStateSyncConfig](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md) | Config for setting up state syncing with |
+| [ISyncStateRef](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md) | |
+
+## Variables
+
+| Variable | Description |
+| --- | --- |
+| [createKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.createkbnurlstatestorage.md) | Creates [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) state storage |
+| [createSessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.createsessionstoragestatestorage.md) | Creates [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/session_storage.md) |
+
+## Type Aliases
+
+| Type Alias | Description |
+| --- | --- |
+| [StartSyncStateFnType](./kibana-plugin-plugins-kibana_utils-public-state_sync.startsyncstatefntype.md) | |
+| [StopSyncStateFnType](./kibana-plugin-plugins-kibana_utils-public-state_sync.stopsyncstatefntype.md) | |
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.startsyncstatefntype.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.startsyncstatefntype.md
new file mode 100644
index 00000000000000..23f71ba330d4b9
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.startsyncstatefntype.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [StartSyncStateFnType](./kibana-plugin-plugins-kibana_utils-public-state_sync.startsyncstatefntype.md)
+
+## StartSyncStateFnType type
+
+
+Signature:
+
+```typescript
+export declare type StartSyncStateFnType = () => void;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.stopsyncstatefntype.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.stopsyncstatefntype.md
new file mode 100644
index 00000000000000..69ff6e899e8604
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.stopsyncstatefntype.md
@@ -0,0 +1,12 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [StopSyncStateFnType](./kibana-plugin-plugins-kibana_utils-public-state_sync.stopsyncstatefntype.md)
+
+## StopSyncStateFnType type
+
+
+Signature:
+
+```typescript
+export declare type StopSyncStateFnType = () => void;
+```
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md
new file mode 100644
index 00000000000000..d095c3fffc512a
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md
@@ -0,0 +1,93 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [syncState](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md)
+
+## syncState() function
+
+Utility for syncing application state wrapped in state container with some kind of storage (e.g. URL) Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples
+
+Signature:
+
+```typescript
+export declare function syncState({ storageKey, stateStorage, stateContainer, }: IStateSyncConfig): ISyncStateRef;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| { storageKey, stateStorage, stateContainer, } | IStateSyncConfig<State, IStateStorage>
| |
+
+Returns:
+
+`ISyncStateRef`
+
+- [ISyncStateRef](./kibana-plugin-plugins-kibana_utils-public-state_sync.isyncstateref.md)
+
+## Remarks
+
+1. It is responsibility of consumer to make sure that initial app state and storage are in sync before starting syncing No initial sync happens when syncState() is called
+
+## Example 1
+
+1. the simplest use case
+
+```ts
+const stateStorage = createKbnUrlStateStorage();
+syncState({
+ storageKey: '_s',
+ stateContainer,
+ stateStorage
+});
+
+```
+
+## Example 2
+
+2. conditionally configuring sync strategy
+
+```ts
+const stateStorage = createKbnUrlStateStorage({useHash: config.get('state:stateContainerInSessionStorage')})
+syncState({
+ storageKey: '_s',
+ stateContainer,
+ stateStorage
+});
+
+```
+
+## Example 3
+
+3. implementing custom sync strategy
+
+```ts
+const localStorageStateStorage = {
+ set: (storageKey, state) => localStorage.setItem(storageKey, JSON.stringify(state)),
+ get: (storageKey) => localStorage.getItem(storageKey) ? JSON.parse(localStorage.getItem(storageKey)) : null
+};
+syncState({
+ storageKey: '_s',
+ stateContainer,
+ stateStorage: localStorageStateStorage
+});
+
+```
+
+## Example 4
+
+4. Transform state before serialising Useful for: \* Migration / backward compatibility \* Syncing part of state \* Providing default values
+
+```ts
+const stateToStorage = (s) => ({ tab: s.tab });
+syncState({
+ storageKey: '_s',
+ stateContainer: {
+ get: () => stateToStorage(stateContainer.get()),
+ set: stateContainer.set(({ tab }) => ({ ...stateContainer.get(), tab }),
+ state$: stateContainer.state$.pipe(map(stateToStorage))
+ },
+ stateStorage
+});
+
+```
+
diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstates.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstates.md
new file mode 100644
index 00000000000000..87a2449a384df5
--- /dev/null
+++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstates.md
@@ -0,0 +1,42 @@
+
+
+[Home](./index.md) > [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) > [syncStates](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstates.md)
+
+## syncStates() function
+
+Signature:
+
+```typescript
+export declare function syncStates(stateSyncConfigs: Array>): ISyncStateRef;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| stateSyncConfigs | Array<IStateSyncConfig<any>>
| Array of [IStateSyncConfig](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatesyncconfig.md) to sync |
+
+Returns:
+
+`ISyncStateRef`
+
+## Example
+
+sync multiple different sync configs
+
+```ts
+syncStates([
+ {
+ storageKey: '_s1',
+ stateStorage: stateStorage1,
+ stateContainer: stateContainer1,
+ },
+ {
+ storageKey: '_s2',
+ stateStorage: stateStorage2,
+ stateContainer: stateContainer2,
+ },
+]);
+
+```
+
diff --git a/docs/setup/connect-to-elasticsearch.asciidoc b/docs/setup/connect-to-elasticsearch.asciidoc
index 0575b8532508f9..bffb3f97cd1b9c 100644
--- a/docs/setup/connect-to-elasticsearch.asciidoc
+++ b/docs/setup/connect-to-elasticsearch.asciidoc
@@ -23,8 +23,8 @@ experimental[]
To visualize data in a CSV, JSON, or log file, you can upload it using the File
Data Visualizer. On the home page, click *Import a CSV, NDSON, or log file*, and
then drag your file into the File Data Visualizer. Alternatively, you can open
-it by navigating to the Machine Learning app page from the sidebar menu and
-selecting the Data Visualizer from the top navigation bar on the opening page.
+it by navigating to *Machine Learning* from the side navigation and selecting
+*Data Visualizer*.
[role="screenshot"]
image::images/data-viz-homepage.jpg[File Data Visualizer on the home page]
diff --git a/packages/kbn-monaco/src/xjson/grammar.ts b/packages/kbn-monaco/src/xjson/grammar.ts
index e95059f9ece2dd..fbd7b3d319c1de 100644
--- a/packages/kbn-monaco/src/xjson/grammar.ts
+++ b/packages/kbn-monaco/src/xjson/grammar.ts
@@ -200,12 +200,13 @@ export const createParser = () => {
try {
value();
+ white();
} catch (e) {
errored = true;
annos.push({ type: AnnoTypes.error, at: e.at - 1, text: e.message });
}
if (!errored && ch) {
- error('Syntax error');
+ annos.push({ type: AnnoTypes.error, at: at, text: 'Syntax Error' });
}
return { annotations: annos };
}
diff --git a/packages/kbn-monaco/src/xjson/language.ts b/packages/kbn-monaco/src/xjson/language.ts
index fe505818d3c9ab..54b7004fecd8e5 100644
--- a/packages/kbn-monaco/src/xjson/language.ts
+++ b/packages/kbn-monaco/src/xjson/language.ts
@@ -52,7 +52,10 @@ export const registerGrammarChecker = (editor: monaco.editor.IEditor) => {
const updateAnnos = async () => {
const { annotations } = await wps.getAnnos();
- const model = editor.getModel() as monaco.editor.ITextModel;
+ const model = editor.getModel() as monaco.editor.ITextModel | null;
+ if (!model) {
+ return;
+ }
monaco.editor.setModelMarkers(
model,
OWNER,
diff --git a/scripts/backport.js b/scripts/backport.js
index 64cd5721834ead..2094534e2c4b39 100644
--- a/scripts/backport.js
+++ b/scripts/backport.js
@@ -18,4 +18,5 @@
*/
require('../src/setup_node_env/node_version_validator');
-require('backport');
+var backport = require('backport');
+backport.run();
diff --git a/src/core/public/chrome/ui/header/collapsible_nav.tsx b/src/core/public/chrome/ui/header/collapsible_nav.tsx
index 07541b1adff16c..5abd14312f4a66 100644
--- a/src/core/public/chrome/ui/header/collapsible_nav.tsx
+++ b/src/core/public/chrome/ui/header/collapsible_nav.tsx
@@ -38,7 +38,7 @@ import { AppCategory } from '../../../../types';
import { InternalApplicationStart } from '../../../application/types';
import { HttpStart } from '../../../http';
import { OnIsLockedUpdate } from './';
-import { createEuiListItem, createRecentNavLink } from './nav_link';
+import { createEuiListItem, createRecentNavLink, isModifiedOrPrevented } from './nav_link';
function getAllCategories(allCategorizedLinks: Record) {
const allCategories = {} as Record;
@@ -184,17 +184,13 @@ export function CollapsibleNav({
label: 'Home',
iconType: 'home',
href: homeHref,
- onClick: (event: React.MouseEvent) => {
- closeNav();
- if (
- event.isDefaultPrevented() ||
- event.altKey ||
- event.metaKey ||
- event.ctrlKey
- ) {
+ onClick: (event) => {
+ if (isModifiedOrPrevented(event)) {
return;
}
+
event.preventDefault();
+ closeNav();
navigateToApp('home');
},
},
@@ -230,7 +226,13 @@ export function CollapsibleNav({
return {
...hydratedLink,
'data-test-subj': 'collapsibleNavAppLink--recent',
- onClick: closeNav,
+ onClick: (event) => {
+ if (isModifiedOrPrevented(event)) {
+ return;
+ }
+
+ closeNav();
+ },
};
})}
maxWidth="none"
diff --git a/src/core/public/chrome/ui/header/nav_link.tsx b/src/core/public/chrome/ui/header/nav_link.tsx
index 6b5cecd138376b..c70a40f49643e0 100644
--- a/src/core/public/chrome/ui/header/nav_link.tsx
+++ b/src/core/public/chrome/ui/header/nav_link.tsx
@@ -17,20 +17,15 @@
* under the License.
*/
-import { EuiImage } from '@elastic/eui';
+import { EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { ChromeNavLink, ChromeRecentlyAccessedHistoryItem, CoreStart } from '../../..';
import { HttpStart } from '../../../http';
import { relativeToAbsolute } from '../../nav_links/to_nav_link';
-function isModifiedEvent(event: React.MouseEvent) {
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
-}
-
-function LinkIcon({ url }: { url: string }) {
- return ;
-}
+export const isModifiedOrPrevented = (event: React.MouseEvent) =>
+ event.metaKey || event.altKey || event.ctrlKey || event.shiftKey || event.defaultPrevented;
interface Props {
link: ChromeNavLink;
@@ -69,14 +64,16 @@ export function createEuiListItem({
href,
/* Use href and onClick to support "open in new tab" and SPA navigation in the same link */
onClick(event: React.MouseEvent) {
- onClick();
+ if (!isModifiedOrPrevented(event)) {
+ onClick();
+ }
+
if (
!externalLink && // ignore external links
!legacyMode && // ignore when in legacy mode
!legacy && // ignore links to legacy apps
- !event.defaultPrevented && // onClick prevented default
event.button === 0 && // ignore everything but left clicks
- !isModifiedEvent(event) // ignore clicks with modifier keys
+ !isModifiedOrPrevented(event)
) {
event.preventDefault();
navigateToApp(id);
@@ -88,7 +85,8 @@ export function createEuiListItem({
'data-test-subj': dataTestSubj,
...(basePath && {
iconType: euiIconType,
- icon: !euiIconType && icon ? : undefined,
+ icon:
+ !euiIconType && icon ? : undefined,
}),
};
}
diff --git a/src/core/server/index.ts b/src/core/server/index.ts
index e0afd5e57f0416..7520111bf33ac5 100644
--- a/src/core/server/index.ts
+++ b/src/core/server/index.ts
@@ -60,7 +60,7 @@ import {
} from './saved_objects';
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { UuidServiceSetup } from './uuid';
-import { MetricsServiceSetup } from './metrics';
+import { MetricsServiceStart } from './metrics';
import { StatusServiceSetup } from './status';
import {
LoggingServiceSetup,
@@ -403,8 +403,6 @@ export interface CoreSetup {
contracts: new Map([['plugin-id', 'plugin-value']]),
},
rendering: renderingServiceMock,
- metrics: metricsServiceMock.createInternalSetupContract(),
uuid: uuidSetup,
status: statusServiceMock.createInternalSetupContract(),
logging: loggingServiceMock.createInternalSetupContract(),
diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts
index be737f6593c025..a544bad6c0e41c 100644
--- a/src/core/server/legacy/legacy_service.ts
+++ b/src/core/server/legacy/legacy_service.ts
@@ -276,6 +276,9 @@ export class LegacyService implements CoreService {
createSerializer: startDeps.core.savedObjects.createSerializer,
getTypeRegistry: startDeps.core.savedObjects.getTypeRegistry,
},
+ metrics: {
+ getOpsMetrics$: startDeps.core.metrics.getOpsMetrics$,
+ },
uiSettings: { asScopedToClient: startDeps.core.uiSettings.asScopedToClient },
};
@@ -312,9 +315,6 @@ export class LegacyService implements CoreService {
logging: {
configure: (config$) => setupDeps.core.logging.configure([], config$),
},
- metrics: {
- getOpsMetrics$: setupDeps.core.metrics.getOpsMetrics$,
- },
savedObjects: {
setClientFactoryProvider: setupDeps.core.savedObjects.setClientFactoryProvider,
addClientWrapper: setupDeps.core.savedObjects.addClientWrapper,
diff --git a/src/core/server/metrics/metrics_service.mock.ts b/src/core/server/metrics/metrics_service.mock.ts
index cc53a4e27d5710..769f6ee2a549a7 100644
--- a/src/core/server/metrics/metrics_service.mock.ts
+++ b/src/core/server/metrics/metrics_service.mock.ts
@@ -16,29 +16,46 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+import { BehaviorSubject } from 'rxjs';
import { MetricsService } from './metrics_service';
import {
InternalMetricsServiceSetup,
InternalMetricsServiceStart,
- MetricsServiceSetup,
MetricsServiceStart,
} from './types';
-const createSetupContractMock = () => {
- const setupContract: jest.Mocked = {
- getOpsMetrics$: jest.fn(),
- };
- return setupContract;
-};
-
const createInternalSetupContractMock = () => {
- const setupContract: jest.Mocked = createSetupContractMock();
+ const setupContract: jest.Mocked = {};
return setupContract;
};
const createStartContractMock = () => {
- const startContract: jest.Mocked = {};
+ const startContract: jest.Mocked = {
+ getOpsMetrics$: jest.fn(),
+ };
+ startContract.getOpsMetrics$.mockReturnValue(
+ new BehaviorSubject({
+ process: {
+ memory: {
+ heap: { total_in_bytes: 1, used_in_bytes: 1, size_limit: 1 },
+ resident_set_size_in_bytes: 1,
+ },
+ event_loop_delay: 1,
+ pid: 1,
+ uptime_in_millis: 1,
+ },
+ os: {
+ platform: 'darwin' as const,
+ platformRelease: 'test',
+ load: { '1m': 1, '5m': 1, '15m': 1 },
+ memory: { total_in_bytes: 1, free_in_bytes: 1, used_in_bytes: 1 },
+ uptime_in_millis: 1,
+ },
+ response_times: { avg_in_millis: 1, max_in_millis: 1 },
+ requests: { disconnects: 1, total: 1, statusCodes: { '200': 1 } },
+ concurrent_connections: 1,
+ })
+ );
return startContract;
};
@@ -60,7 +77,7 @@ const createMock = () => {
export const metricsServiceMock = {
create: createMock,
- createSetupContract: createSetupContractMock,
+ createSetupContract: createStartContractMock,
createStartContract: createStartContractMock,
createInternalSetupContract: createInternalSetupContractMock,
createInternalStartContract: createInternalStartContractMock,
diff --git a/src/core/server/metrics/metrics_service.test.ts b/src/core/server/metrics/metrics_service.test.ts
index b3cc06ffca1d21..f2019de7b6cabf 100644
--- a/src/core/server/metrics/metrics_service.test.ts
+++ b/src/core/server/metrics/metrics_service.test.ts
@@ -75,8 +75,8 @@ describe('MetricsService', () => {
it('resets the collector after each collection', async () => {
mockOpsCollector.collect.mockResolvedValue(dummyMetrics);
- const { getOpsMetrics$ } = await metricsService.setup({ http: httpMock });
- await metricsService.start();
+ await metricsService.setup({ http: httpMock });
+ const { getOpsMetrics$ } = await metricsService.start();
// `advanceTimersByTime` only ensure the interval handler is executed
// however the `reset` call is executed after the async call to `collect`
@@ -109,8 +109,8 @@ describe('MetricsService', () => {
describe('#stop', () => {
it('stops the metrics interval', async () => {
- const { getOpsMetrics$ } = await metricsService.setup({ http: httpMock });
- await metricsService.start();
+ await metricsService.setup({ http: httpMock });
+ const { getOpsMetrics$ } = await metricsService.start();
expect(mockOpsCollector.collect).toHaveBeenCalledTimes(1);
@@ -125,8 +125,8 @@ describe('MetricsService', () => {
});
it('completes the metrics observable', async () => {
- const { getOpsMetrics$ } = await metricsService.setup({ http: httpMock });
- await metricsService.start();
+ await metricsService.setup({ http: httpMock });
+ const { getOpsMetrics$ } = await metricsService.start();
let completed = false;
diff --git a/src/core/server/metrics/metrics_service.ts b/src/core/server/metrics/metrics_service.ts
index 0ea9d007926003..f28fb21aaac0d5 100644
--- a/src/core/server/metrics/metrics_service.ts
+++ b/src/core/server/metrics/metrics_service.ts
@@ -45,12 +45,7 @@ export class MetricsService
public async setup({ http }: MetricsServiceSetupDeps): Promise {
this.metricsCollector = new OpsMetricsCollector(http.server);
-
- const metricsObservable = this.metrics$.asObservable();
-
- return {
- getOpsMetrics$: () => metricsObservable,
- };
+ return {};
}
public async start(): Promise {
@@ -68,7 +63,11 @@ export class MetricsService
this.refreshMetrics();
}, config.interval.asMilliseconds());
- return {};
+ const metricsObservable = this.metrics$.asObservable();
+
+ return {
+ getOpsMetrics$: () => metricsObservable,
+ };
}
private async refreshMetrics() {
diff --git a/src/core/server/metrics/types.ts b/src/core/server/metrics/types.ts
index 5c8f18fff380de..cbf0acacd6bab8 100644
--- a/src/core/server/metrics/types.ts
+++ b/src/core/server/metrics/types.ts
@@ -20,12 +20,14 @@
import { Observable } from 'rxjs';
import { OpsProcessMetrics, OpsOsMetrics, OpsServerMetrics } from './collectors';
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface MetricsServiceSetup {}
/**
* APIs to retrieves metrics gathered and exposed by the core platform.
*
* @public
*/
-export interface MetricsServiceSetup {
+export interface MetricsServiceStart {
/**
* Retrieve an observable emitting the {@link OpsMetrics} gathered.
* The observable will emit an initial value during core's `start` phase, and a new value every fixed interval of time,
@@ -40,8 +42,6 @@ export interface MetricsServiceSetup {
*/
getOpsMetrics$: () => Observable;
}
-// eslint-disable-next-line @typescript-eslint/no-empty-interface
-export interface MetricsServiceStart {}
export type InternalMetricsServiceSetup = MetricsServiceSetup;
export type InternalMetricsServiceStart = MetricsServiceStart;
diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts
index 0770e8843e2f63..4491942951c505 100644
--- a/src/core/server/mocks.ts
+++ b/src/core/server/mocks.ts
@@ -46,6 +46,7 @@ export { httpServiceMock } from './http/http_service.mock';
export { loggingSystemMock } from './logging/logging_system.mock';
export { savedObjectsRepositoryMock } from './saved_objects/service/lib/repository.mock';
export { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock';
+export { migrationMocks } from './saved_objects/migrations/mocks';
export { typeRegistryMock as savedObjectsTypeRegistryMock } from './saved_objects/saved_objects_type_registry.mock';
export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
export { metricsServiceMock } from './metrics/metrics_service.mock';
@@ -128,7 +129,6 @@ function createCoreSetupMock({
http: httpMock,
savedObjects: savedObjectsServiceMock.createInternalSetupContract(),
status: statusServiceMock.createSetupContract(),
- metrics: metricsServiceMock.createSetupContract(),
uiSettings: uiSettingsMock,
uuid: uuidServiceMock.createSetupContract(),
logging: loggingServiceMock.createSetupContract(),
@@ -145,6 +145,7 @@ function createCoreStartMock() {
capabilities: capabilitiesServiceMock.createStartContract(),
elasticsearch: elasticsearchServiceMock.createStart(),
http: httpServiceMock.createStartContract(),
+ metrics: metricsServiceMock.createStartContract(),
savedObjects: savedObjectsServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};
@@ -158,7 +159,6 @@ function createInternalCoreSetupMock() {
context: contextServiceMock.createSetupContract(),
elasticsearch: elasticsearchServiceMock.createInternalSetup(),
http: httpServiceMock.createInternalSetupContract(),
- metrics: metricsServiceMock.createInternalSetupContract(),
savedObjects: savedObjectsServiceMock.createInternalSetupContract(),
status: statusServiceMock.createInternalSetupContract(),
uuid: uuidServiceMock.createSetupContract(),
@@ -175,6 +175,7 @@ function createInternalCoreStartMock() {
capabilities: capabilitiesServiceMock.createStartContract(),
elasticsearch: elasticsearchServiceMock.createStart(),
http: httpServiceMock.createInternalStartContract(),
+ metrics: metricsServiceMock.createStartContract(),
savedObjects: savedObjectsServiceMock.createInternalStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};
diff --git a/src/core/server/plugins/plugin_context.ts b/src/core/server/plugins/plugin_context.ts
index 32bc8dc088cad1..4643789d99a88e 100644
--- a/src/core/server/plugins/plugin_context.ts
+++ b/src/core/server/plugins/plugin_context.ts
@@ -169,9 +169,6 @@ export function createPluginSetupContext(
logging: {
configure: (config$) => deps.logging.configure(['plugins', plugin.name], config$),
},
- metrics: {
- getOpsMetrics$: deps.metrics.getOpsMetrics$,
- },
savedObjects: {
setClientFactoryProvider: deps.savedObjects.setClientFactoryProvider,
addClientWrapper: deps.savedObjects.addClientWrapper,
@@ -225,6 +222,9 @@ export function createPluginStartContext(
createSerializer: deps.savedObjects.createSerializer,
getTypeRegistry: deps.savedObjects.getTypeRegistry,
},
+ metrics: {
+ getOpsMetrics$: deps.metrics.getOpsMetrics$,
+ },
uiSettings: {
asScopedToClient: deps.uiSettings.asScopedToClient,
},
diff --git a/src/core/server/saved_objects/mappings/types.ts b/src/core/server/saved_objects/mappings/types.ts
index 8362d1f16bd2a0..c037ed733549e6 100644
--- a/src/core/server/saved_objects/mappings/types.ts
+++ b/src/core/server/saved_objects/mappings/types.ts
@@ -145,10 +145,14 @@ export interface SavedObjectsCoreFieldMapping {
/**
* See {@link SavedObjectsFieldMapping} for documentation.
*
+ * Note: this type intentially doesn't include a type definition for defining
+ * the `dynamic` mapping parameter. Saved Object fields should always inherit
+ * the `dynamic: 'strict'` paramater. If you are unsure of the shape of your
+ * data use `type: 'object', enabled: false` instead.
+ *
* @public
*/
export interface SavedObjectsComplexFieldMapping {
- dynamic?: string;
type?: string;
properties: SavedObjectsMappingProperties;
}
diff --git a/src/core/server/saved_objects/migrations/core/build_active_mappings.ts b/src/core/server/saved_objects/migrations/core/build_active_mappings.ts
index c2a7b11e057cd3..4561f4d30e104f 100644
--- a/src/core/server/saved_objects/migrations/core/build_active_mappings.ts
+++ b/src/core/server/saved_objects/migrations/core/build_active_mappings.ts
@@ -130,6 +130,8 @@ function defaultMapping(): IndexMapping {
dynamic: 'strict',
properties: {
migrationVersion: {
+ // Saved Objects can't redefine dynamic, but we cheat here to support migrations
+ // @ts-expect-error
dynamic: 'true',
type: 'object',
},
diff --git a/src/core/server/saved_objects/migrations/core/index_migrator.ts b/src/core/server/saved_objects/migrations/core/index_migrator.ts
index b2ffe2ad04a880..e588eb7877322a 100644
--- a/src/core/server/saved_objects/migrations/core/index_migrator.ts
+++ b/src/core/server/saved_objects/migrations/core/index_migrator.ts
@@ -195,7 +195,7 @@ async function migrateSourceToDest(context: Context) {
await Index.write(
callCluster,
dest.indexName,
- migrateRawDocs(serializer, documentMigrator.migrate, docs, log)
+ await migrateRawDocs(serializer, documentMigrator.migrate, docs, log)
);
}
}
diff --git a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts
index e55b72be2436d9..6e4dd9615d4230 100644
--- a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts
+++ b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.test.ts
@@ -26,7 +26,7 @@ import { createSavedObjectsMigrationLoggerMock } from '../../migrations/mocks';
describe('migrateRawDocs', () => {
test('converts raw docs to saved objects', async () => {
const transform = jest.fn((doc: any) => _.set(doc, 'attributes.name', 'HOI!'));
- const result = migrateRawDocs(
+ const result = await migrateRawDocs(
new SavedObjectsSerializer(new SavedObjectTypeRegistry()),
transform,
[
@@ -55,7 +55,7 @@ describe('migrateRawDocs', () => {
const transform = jest.fn((doc: any) =>
_.set(_.cloneDeep(doc), 'attributes.name', 'TADA')
);
- const result = migrateRawDocs(
+ const result = await migrateRawDocs(
new SavedObjectsSerializer(new SavedObjectTypeRegistry()),
transform,
[
diff --git a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts
index a2b72ea76c1a28..2bdf59d25dc74d 100644
--- a/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts
+++ b/src/core/server/saved_objects/migrations/core/migrate_raw_docs.ts
@@ -21,7 +21,11 @@
* This file provides logic for migrating raw documents.
*/
-import { SavedObjectsRawDoc, SavedObjectsSerializer } from '../../serialization';
+import {
+ SavedObjectsRawDoc,
+ SavedObjectsSerializer,
+ SavedObjectUnsanitizedDoc,
+} from '../../serialization';
import { TransformFn } from './document_migrator';
import { SavedObjectsMigrationLogger } from '.';
@@ -33,26 +37,51 @@ import { SavedObjectsMigrationLogger } from '.';
* @param {SavedObjectsRawDoc[]} rawDocs
* @returns {SavedObjectsRawDoc[]}
*/
-export function migrateRawDocs(
+export async function migrateRawDocs(
serializer: SavedObjectsSerializer,
migrateDoc: TransformFn,
rawDocs: SavedObjectsRawDoc[],
log: SavedObjectsMigrationLogger
-): SavedObjectsRawDoc[] {
- return rawDocs.map((raw) => {
+): Promise {
+ const migrateDocWithoutBlocking = transformNonBlocking(migrateDoc);
+ const processedDocs = [];
+ for (const raw of rawDocs) {
if (serializer.isRawSavedObject(raw)) {
const savedObject = serializer.rawToSavedObject(raw);
savedObject.migrationVersion = savedObject.migrationVersion || {};
- return serializer.savedObjectToRaw({
- references: [],
- ...migrateDoc(savedObject),
- });
+ processedDocs.push(
+ serializer.savedObjectToRaw({
+ references: [],
+ ...(await migrateDocWithoutBlocking(savedObject)),
+ })
+ );
+ } else {
+ log.error(
+ `Error: Unable to migrate the corrupt Saved Object document ${raw._id}. To prevent Kibana from performing a migration on every restart, please delete or fix this document by ensuring that the namespace and type in the document's id matches the values in the namespace and type fields.`,
+ { rawDocument: raw }
+ );
+ processedDocs.push(raw);
}
+ }
+ return processedDocs;
+}
- log.error(
- `Error: Unable to migrate the corrupt Saved Object document ${raw._id}. To prevent Kibana from performing a migration on every restart, please delete or fix this document by ensuring that the namespace and type in the document's id matches the values in the namespace and type fields.`,
- { rawDocument: raw }
- );
- return raw;
- });
+/**
+ * Migration transform functions are potentially CPU heavy e.g. doing decryption/encryption
+ * or (de)/serializing large JSON payloads.
+ * Executing all transforms for a batch in a synchronous loop can block the event-loop for a long time.
+ * To prevent this we use setImmediate to ensure that the event-loop can process other parallel
+ * work in between each transform.
+ */
+function transformNonBlocking(
+ transform: TransformFn
+): (doc: SavedObjectUnsanitizedDoc) => Promise {
+ // promises aren't enough to unblock the event loop
+ return (doc: SavedObjectUnsanitizedDoc) =>
+ new Promise((resolve) => {
+ // set immediate is though
+ setImmediate(() => {
+ resolve(transform(doc));
+ });
+ });
}
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index 4d6316fceb5682..108826ad61aa26 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -712,8 +712,6 @@ export interface CoreSetup Observable;
}
// @public (undocumented)
@@ -1970,8 +1974,6 @@ export interface SavedObjectsClientWrapperOptions {
// @public
export interface SavedObjectsComplexFieldMapping {
- // (undocumented)
- dynamic?: string;
// (undocumented)
properties: SavedObjectsMappingProperties;
// (undocumented)
diff --git a/src/core/server/server.ts b/src/core/server/server.ts
index 3bbcd0e37e142a..dc37b77c57c92f 100644
--- a/src/core/server/server.ts
+++ b/src/core/server/server.ts
@@ -150,7 +150,7 @@ export class Server {
savedObjects: savedObjectsSetup,
});
- const metricsSetup = await this.metrics.setup({ http: httpSetup });
+ await this.metrics.setup({ http: httpSetup });
const renderingSetup = await this.rendering.setup({
http: httpSetup,
@@ -181,7 +181,6 @@ export class Server {
status: statusSetup,
uiSettings: uiSettingsSetup,
uuid: uuidSetup,
- metrics: metricsSetup,
rendering: renderingSetup,
httpResources: httpResourcesSetup,
logging: loggingSetup,
@@ -211,12 +210,14 @@ export class Server {
});
const capabilitiesStart = this.capabilities.start();
const uiSettingsStart = await this.uiSettings.start();
+ const metricsStart = await this.metrics.start();
const httpStart = this.http.getStartContract();
this.coreStart = {
capabilities: capabilitiesStart,
elasticsearch: elasticsearchStart,
http: httpStart,
+ metrics: metricsStart,
savedObjects: savedObjectsStart,
uiSettings: uiSettingsStart,
};
@@ -236,7 +237,6 @@ export class Server {
await this.rendering.start({
legacy: this.legacy,
});
- await this.metrics.start();
return this.coreStart;
}
diff --git a/src/dev/build/tasks/copy_source_task.js b/src/dev/build/tasks/copy_source_task.js
index ddc6d000bca194..32eb7bf8712e31 100644
--- a/src/dev/build/tasks/copy_source_task.js
+++ b/src/dev/build/tasks/copy_source_task.js
@@ -34,9 +34,7 @@ export const CopySourceTask = {
'!src/test_utils/**',
'!src/fixtures/**',
'!src/legacy/core_plugins/tests_bundle/**',
- '!src/legacy/core_plugins/testbed/**',
'!src/legacy/core_plugins/console/public/tests/**',
- '!src/plugins/testbed/**',
'!src/cli/cluster/**',
'!src/cli/repl/**',
'!src/es_archiver/**',
diff --git a/src/dev/run_check_published_api_changes.ts b/src/dev/run_check_published_api_changes.ts
index 45dafe1b415e38..0aa450c8b002a5 100644
--- a/src/dev/run_check_published_api_changes.ts
+++ b/src/dev/run_check_published_api_changes.ts
@@ -43,7 +43,18 @@ import getopts from 'getopts';
*/
const getReportFileName = (folder: string) => {
- return folder.indexOf('public') > -1 ? 'public' : 'server';
+ switch (true) {
+ case folder.includes('public'):
+ return 'public';
+ case folder.includes('server'):
+ return 'server';
+ case folder.includes('common'):
+ return 'common';
+ default:
+ throw new Error(
+ `folder "${folder}" expected to include one of ["public", "server", "common"]`
+ );
+ }
};
const apiExtractorConfig = (folder: string): ExtractorConfig => {
@@ -131,7 +142,7 @@ const runApiExtractor = (
messageCallback: (message: ExtractorMessage) => {
if (message.messageId === 'console-api-report-not-copied') {
// ConsoleMessageId.ApiReportNotCopied
- log.warning(`You have changed the signature of the ${folder} Core API`);
+ log.warning(`You have changed the signature of the ${folder} public API`);
log.warning(
'To accept these changes run `node scripts/check_published_api_changes.js --accept` and then:\n' +
"\t 1. Commit the updated documentation and API review file '" +
@@ -142,7 +153,7 @@ const runApiExtractor = (
message.handled = true;
} else if (message.messageId === 'console-api-report-copied') {
// ConsoleMessageId.ApiReportCopied
- log.warning(`You have changed the signature of the ${folder} Core API`);
+ log.warning(`You have changed the signature of the ${folder} public API`);
log.warning(
"Please commit the updated API documentation and the API review file: '" +
config.reportFilePath
@@ -150,7 +161,7 @@ const runApiExtractor = (
message.handled = true;
} else if (message.messageId === 'console-api-report-unchanged') {
// ConsoleMessageId.ApiReportUnchanged
- log.info(`Core ${folder} API: no changes detected ✔`);
+ log.info(`${folder} API: no changes detected ✔`);
message.handled = true;
}
},
@@ -170,7 +181,7 @@ async function run(
folder: string,
{ log, opts }: { log: ToolingLog; opts: Options }
): Promise {
- log.info(`Core ${folder} API: checking for changes in API signature...`);
+ log.info(`${folder} API: checking for changes in API signature...`);
const { apiReportChanged, succeeded } = runApiExtractor(log, folder, opts.accept);
@@ -188,7 +199,7 @@ async function run(
log.error(e);
return false;
}
- log.info(`Core ${folder} API: updated documentation ✔`);
+ log.info(`${folder} API: updated documentation ✔`);
}
// If the api signature changed or any errors or warnings occured, exit with an error
@@ -224,24 +235,31 @@ async function run(
opts.help = true;
}
- const folders = ['core/public', 'core/server', 'plugins/data/server', 'plugins/data/public'];
+ const core = ['core/public', 'core/server'];
+ const plugins = [
+ 'plugins/data/server',
+ 'plugins/data/public',
+ 'plugins/kibana_utils/common/state_containers',
+ 'plugins/kibana_utils/public/state_sync',
+ ];
+ const folders = [...core, ...plugins];
if (opts.help) {
process.stdout.write(
dedent(chalk`
{dim usage:} node scripts/check_published_api_changes [...options]
- Checks for any changes to the Kibana Core API
+ Checks for any changes to the Kibana shared API
Examples:
- {dim # Checks for any changes to the Kibana Core API}
+ {dim # Checks for any changes to the Kibana shared API}
{dim $} node scripts/check_published_api_changes
- {dim # Checks for any changes to the Kibana Core API and updates the documentation}
+ {dim # Checks for any changes to the Kibana shared API and updates the documentation}
{dim $} node scripts/check_published_api_changes --docs
- {dim # Checks for and automatically accepts and updates documentation for any changes to the Kibana Core API}
+ {dim # Checks for and automatically accepts and updates documentation for any changes to the Kibana shared API}
{dim $} node scripts/check_published_api_changes --accept
{dim # Only checks the core/public directory}
@@ -249,7 +267,7 @@ async function run(
Options:
--accept {dim Accepts all changes by updating the API Review files and documentation}
- --docs {dim Updates the Core API documentation}
+ --docs {dim Updates the API documentation}
--filter {dim RegExp that folder names must match, folders: [${folders.join(', ')}]}
--help {dim Show this message}
`)
@@ -259,20 +277,22 @@ async function run(
}
try {
- log.info(`Core: Building types...`);
+ log.info(`Building types for api extractor...`);
await runBuildTypes();
} catch (e) {
log.error(e);
return false;
}
- const results = await Promise.all(
- folders
- .filter((folder) => (opts.filter.length ? folder.match(opts.filter) : true))
- .map((folder) => run(folder, { log, opts }))
+ const filteredFolders = folders.filter((folder) =>
+ opts.filter.length ? folder.match(opts.filter) : true
);
+ const results = [];
+ for (const folder of filteredFolders) {
+ results.push(await run(folder, { log, opts }));
+ }
- if (results.find((r) => r === false) !== undefined) {
+ if (results.includes(false)) {
process.exitCode = 1;
}
})().catch((e) => {
diff --git a/src/fixtures/stubbed_saved_object_index_pattern.js b/src/fixtures/stubbed_saved_object_index_pattern.js
index 15e47b40eb203f..8e0e230ef33dd8 100644
--- a/src/fixtures/stubbed_saved_object_index_pattern.js
+++ b/src/fixtures/stubbed_saved_object_index_pattern.js
@@ -27,6 +27,7 @@ export function stubbedSavedObjectIndexPattern(id) {
id,
type: 'index-pattern',
attributes: {
+ timeFieldName: 'timestamp',
customFormats: '{}',
fields: mockLogstashFields,
},
diff --git a/src/legacy/core_plugins/testbed/README.md b/src/legacy/core_plugins/testbed/README.md
deleted file mode 100644
index ac50ffbb804b5c..00000000000000
--- a/src/legacy/core_plugins/testbed/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-## Kibana Testbed
-
-Sometimes when developing for Kibana, it is useful to have an isolated routable space to demonstrate new functionality. This Testbed provides such a space.
-
-To make use of the testbed, edit the testbed.js, testbed.html, and testbed.less files as necessary. When you are done demonstrating
-your new functionality, remember to cleanup your changes and restore the testbed to its pristine state for the next person.
-
-To access the testbed, visit `http://localhost:5601/app/kibana#/testbed`
diff --git a/src/legacy/core_plugins/testbed/package.json b/src/legacy/core_plugins/testbed/package.json
deleted file mode 100644
index 98fcaf7eda95da..00000000000000
--- a/src/legacy/core_plugins/testbed/package.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "name": "testbed",
- "version": "kibana"
-}
\ No newline at end of file
diff --git a/src/legacy/core_plugins/testbed/public/testbed.html b/src/legacy/core_plugins/testbed/public/testbed.html
deleted file mode 100644
index 52455beb02360d..00000000000000
--- a/src/legacy/core_plugins/testbed/public/testbed.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
{{ testbed.data }}
-
-
-
-
-
-
-
-
diff --git a/src/legacy/server/status/routes/api/register_stats.js b/src/legacy/server/status/routes/api/register_stats.js
index 09957e61f74d3d..0221c7e0ea0853 100644
--- a/src/legacy/server/status/routes/api/register_stats.js
+++ b/src/legacy/server/status/routes/api/register_stats.js
@@ -54,7 +54,7 @@ export function registerStatsApi(usageCollection, server, config, kbnServer) {
/* kibana_stats gets singled out from the collector set as it is used
* for health-checking Kibana and fetch does not rely on fetching data
* from ES */
- server.newPlatform.setup.core.metrics.getOpsMetrics$().subscribe((metrics) => {
+ server.newPlatform.start.core.metrics.getOpsMetrics$().subscribe((metrics) => {
lastMetrics = {
...metrics,
timestamp: new Date().toISOString(),
diff --git a/src/plugins/dashboard/public/application/dashboard_app_controller.tsx b/src/plugins/dashboard/public/application/dashboard_app_controller.tsx
index 3c559a6cde211d..b52bf5bf02b7ba 100644
--- a/src/plugins/dashboard/public/application/dashboard_app_controller.tsx
+++ b/src/plugins/dashboard/public/application/dashboard_app_controller.tsx
@@ -60,6 +60,7 @@ import {
ViewMode,
SavedObjectEmbeddableInput,
ContainerOutput,
+ EmbeddableInput,
} from '../../../embeddable/public';
import { NavAction, SavedDashboardPanel } from '../types';
@@ -430,9 +431,16 @@ export class DashboardAppController {
.getStateTransfer(scopedHistory())
.getIncomingEmbeddablePackage();
if (incomingState) {
- container.addNewEmbeddable(incomingState.type, {
- savedObjectId: incomingState.id,
- });
+ if ('id' in incomingState) {
+ container.addNewEmbeddable(incomingState.type, {
+ savedObjectId: incomingState.id,
+ });
+ } else if ('input' in incomingState) {
+ container.addNewEmbeddable(
+ incomingState.type,
+ incomingState.input
+ );
+ }
}
}
diff --git a/src/plugins/data/common/es_query/filters/meta_filter.ts b/src/plugins/data/common/es_query/filters/meta_filter.ts
index ff6dff9d8b7490..e3099ae6a40264 100644
--- a/src/plugins/data/common/es_query/filters/meta_filter.ts
+++ b/src/plugins/data/common/es_query/filters/meta_filter.ts
@@ -107,3 +107,13 @@ export const pinFilter = (filter: Filter) =>
export const unpinFilter = (filter: Filter) =>
!isFilterPinned(filter) ? filter : toggleFilterPinned(filter);
+
+export const isFilter = (x: unknown): x is Filter =>
+ !!x &&
+ typeof x === 'object' &&
+ !!(x as Filter).meta &&
+ typeof (x as Filter).meta === 'object' &&
+ typeof (x as Filter).meta.disabled === 'boolean';
+
+export const isFilters = (x: unknown): x is Filter[] =>
+ Array.isArray(x) && !x.find((y) => !isFilter(y));
diff --git a/src/plugins/data/common/index.ts b/src/plugins/data/common/index.ts
index adbd93d518fc7d..b40e02b709d301 100644
--- a/src/plugins/data/common/index.ts
+++ b/src/plugins/data/common/index.ts
@@ -20,11 +20,12 @@
export * from './constants';
export * from './es_query';
export * from './field_formats';
+export * from './field_mapping';
export * from './index_patterns';
export * from './kbn_field_types';
export * from './query';
export * from './search';
export * from './search/aggs';
+export * from './timefilter';
export * from './types';
export * from './utils';
-export * from './field_mapping';
diff --git a/src/plugins/data/common/index_patterns/fields/__snapshots__/field.test.ts.snap b/src/plugins/data/common/index_patterns/fields/__snapshots__/field.test.ts.snap
index 4593349a408a7d..e61593f6bfb27b 100644
--- a/src/plugins/data/common/index_patterns/fields/__snapshots__/field.test.ts.snap
+++ b/src/plugins/data/common/index_patterns/fields/__snapshots__/field.test.ts.snap
@@ -33,3 +33,43 @@ Object {
"type": "type",
}
`;
+
+exports[`Field spec snapshot 1`] = `
+Object {
+ "aggregatable": true,
+ "conflictDescriptions": Object {
+ "a": Array [
+ "b",
+ "c",
+ ],
+ "d": Array [
+ "e",
+ ],
+ },
+ "count": 1,
+ "esTypes": Array [
+ "type",
+ ],
+ "format": Object {
+ "id": "number",
+ "params": Object {
+ "pattern": "$0,0.[00]",
+ },
+ },
+ "lang": "lang",
+ "name": "name",
+ "readFromDocValues": false,
+ "script": "script",
+ "scripted": true,
+ "searchable": true,
+ "subType": Object {
+ "multi": Object {
+ "parent": "parent",
+ },
+ "nested": Object {
+ "path": "path",
+ },
+ },
+ "type": "type",
+}
+`;
diff --git a/src/plugins/data/common/index_patterns/fields/field.test.ts b/src/plugins/data/common/index_patterns/fields/field.test.ts
index 711c176fed9ccb..910f22088f43a8 100644
--- a/src/plugins/data/common/index_patterns/fields/field.test.ts
+++ b/src/plugins/data/common/index_patterns/fields/field.test.ts
@@ -20,7 +20,7 @@
import { Field } from './field';
import { IndexPattern } from '../index_patterns';
import { FieldFormatsStartCommon } from '../..';
-import { KBN_FIELD_TYPES } from '../../../common';
+import { KBN_FIELD_TYPES, FieldSpec, FieldSpecExportFmt } from '../../../common';
describe('Field', function () {
function flatten(obj: Record) {
@@ -59,8 +59,9 @@ describe('Field', function () {
fieldFormatMap: { name: {}, _source: {}, _score: {}, _id: {} },
} as unknown) as IndexPattern,
format: { name: 'formatName' },
- $$spec: {},
+ $$spec: ({} as unknown) as FieldSpec,
conflictDescriptions: { a: ['b', 'c'], d: ['e'] },
+ toSpec: () => (({} as unknown) as FieldSpecExportFmt),
} as Field;
it('the correct properties are writable', () => {
@@ -145,7 +146,7 @@ describe('Field', function () {
}).toThrow();
expect(() => {
- field.$$spec = { a: 'b' };
+ field.$$spec = ({ a: 'b' } as unknown) as FieldSpec;
}).toThrow();
});
@@ -219,4 +220,21 @@ describe('Field', function () {
});
expect(flatten(field)).toMatchSnapshot();
});
+
+ it('spec snapshot', () => {
+ const field = new Field(
+ {
+ fieldFormatMap: {
+ name: { toJSON: () => ({ id: 'number', params: { pattern: '$0,0.[00]' } }) },
+ },
+ } as IndexPattern,
+ fieldValues,
+ false,
+ {
+ fieldFormats: {} as FieldFormatsStartCommon,
+ onNotification: () => {},
+ }
+ );
+ expect(field.toSpec()).toMatchSnapshot();
+ });
});
diff --git a/src/plugins/data/common/index_patterns/fields/field.ts b/src/plugins/data/common/index_patterns/fields/field.ts
index c53e3f2b1f621f..81c7aff8a0faaa 100644
--- a/src/plugins/data/common/index_patterns/fields/field.ts
+++ b/src/plugins/data/common/index_patterns/fields/field.ts
@@ -28,11 +28,14 @@ import {
FieldFormat,
shortenDottedString,
} from '../../../common';
-import { OnNotification } from '../types';
+import {
+ OnNotification,
+ FieldSpec,
+ FieldSpecConflictDescriptions,
+ FieldSpecExportFmt,
+} from '../types';
import { FieldFormatsStartCommon } from '../../field_formats';
-export type FieldSpec = Record;
-
interface FieldDependencies {
fieldFormats: FieldFormatsStartCommon;
onNotification: OnNotification;
@@ -59,11 +62,11 @@ export class Field implements IFieldType {
readFromDocValues?: boolean;
format: any;
$$spec: FieldSpec;
- conflictDescriptions?: Record;
+ conflictDescriptions?: FieldSpecConflictDescriptions;
constructor(
indexPattern: IIndexPattern,
- spec: FieldSpec | Field,
+ spec: FieldSpecExportFmt | FieldSpec | Field,
shortDotsEnable: boolean,
{ fieldFormats, onNotification }: FieldDependencies
) {
@@ -95,7 +98,7 @@ export class Field implements IFieldType {
if (!type) type = getKbnFieldType('unknown');
- let format = spec.format;
+ let format: any = spec.format;
if (!FieldFormat.isInstanceOfFieldFormat(format)) {
format =
@@ -148,6 +151,26 @@ export class Field implements IFieldType {
// multi info
obj.fact('subType');
- return obj.create();
+ const newObj = obj.create();
+ newObj.toSpec = function () {
+ return {
+ count: this.count,
+ script: this.script,
+ lang: this.lang,
+ conflictDescriptions: this.conflictDescriptions,
+ name: this.name,
+ type: this.type,
+ esTypes: this.esTypes,
+ scripted: this.scripted,
+ searchable: this.searchable,
+ aggregatable: this.aggregatable,
+ readFromDocValues: this.readFromDocValues,
+ subType: this.subType,
+ format: this.indexPattern?.fieldFormatMap[this.name]?.toJSON() || undefined,
+ };
+ };
+ return newObj;
}
+ // only providing type info as constructor returns new object instead of `this`
+ toSpec = () => (({} as unknown) as FieldSpecExportFmt);
}
diff --git a/src/plugins/data/common/index_patterns/fields/field_list.ts b/src/plugins/data/common/index_patterns/fields/field_list.ts
index 173a629863a716..c1ca5341328ce1 100644
--- a/src/plugins/data/common/index_patterns/fields/field_list.ts
+++ b/src/plugins/data/common/index_patterns/fields/field_list.ts
@@ -20,8 +20,8 @@
import { findIndex } from 'lodash';
import { IIndexPattern } from '../../types';
import { IFieldType } from '../../../common';
-import { Field, FieldSpec } from './field';
-import { OnNotification } from '../types';
+import { Field } from './field';
+import { OnNotification, FieldSpec } from '../types';
import { FieldFormatsStartCommon } from '../../field_formats';
type FieldMap = Map;
@@ -102,6 +102,10 @@ export const getIndexPatternFieldListCreator = ({
this.removeByGroup(newField);
this.setByGroup(newField);
};
+
+ toSpec = () => {
+ return [...this.map((field) => field.toSpec())];
+ };
}
return new FieldList(...fieldListParams);
diff --git a/src/plugins/data/common/index_patterns/fields/types.ts b/src/plugins/data/common/index_patterns/fields/types.ts
index c336472a1e7d6f..558b5b57dce40a 100644
--- a/src/plugins/data/common/index_patterns/fields/types.ts
+++ b/src/plugins/data/common/index_patterns/fields/types.ts
@@ -17,10 +17,7 @@
* under the License.
*/
-export interface IFieldSubType {
- multi?: { parent: string };
- nested?: { path: string };
-}
+import { FieldSpec, IFieldSubType } from '../types';
export interface IFieldType {
name: string;
@@ -41,4 +38,5 @@ export interface IFieldType {
subType?: IFieldSubType;
displayName?: string;
format?: any;
+ toSpec?: () => FieldSpec;
}
diff --git a/src/plugins/data/common/index_patterns/index_patterns/__snapshots__/index_pattern.test.ts.snap b/src/plugins/data/common/index_patterns/index_patterns/__snapshots__/index_pattern.test.ts.snap
new file mode 100644
index 00000000000000..047ac836a87d1f
--- /dev/null
+++ b/src/plugins/data/common/index_patterns/index_patterns/__snapshots__/index_pattern.test.ts.snap
@@ -0,0 +1,503 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`IndexPattern toSpec should match snapshot 1`] = `
+Object {
+ "fields": Array [
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 10,
+ "esTypes": Array [
+ "long",
+ ],
+ "format": Object {
+ "id": "number",
+ "params": Object {
+ "pattern": "$0,0.[00]",
+ },
+ },
+ "lang": undefined,
+ "name": "bytes",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "number",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 20,
+ "esTypes": Array [
+ "boolean",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "ssl",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "boolean",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 30,
+ "esTypes": Array [
+ "date",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "@timestamp",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "date",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 30,
+ "esTypes": Array [
+ "date",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "time",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "date",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "keyword",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "@tags",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "date",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "utc_time",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "date",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "integer",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "phpmemory",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "number",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "ip",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "ip",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "ip",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "attachment",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "request_body",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "attachment",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "geo_point",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "point",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "geo_point",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "geo_shape",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "area",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "geo_shape",
+ },
+ Object {
+ "aggregatable": false,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "murmur3",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "hashed",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "murmur3",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "geo_point",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "geo.coordinates",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "geo_point",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "text",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "extension",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "keyword",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "extension.keyword",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": Object {
+ "multi": Object {
+ "parent": "extension",
+ },
+ },
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "text",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "machine.os",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "keyword",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "machine.os.raw",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": Object {
+ "multi": Object {
+ "parent": "machine.os",
+ },
+ },
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "keyword",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "geo.src",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "_id",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "_id",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "_type",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "_type",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "_source",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "_source",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "_source",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "text",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "non-filterable",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": false,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": false,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "text",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "non-sortable",
+ "readFromDocValues": false,
+ "script": undefined,
+ "scripted": false,
+ "searchable": false,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "conflict",
+ ],
+ "format": undefined,
+ "lang": undefined,
+ "name": "custom_user_field",
+ "readFromDocValues": true,
+ "script": undefined,
+ "scripted": false,
+ "searchable": true,
+ "subType": undefined,
+ "type": "conflict",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "text",
+ ],
+ "format": undefined,
+ "lang": "expression",
+ "name": "script string",
+ "readFromDocValues": false,
+ "script": "'i am a string'",
+ "scripted": true,
+ "searchable": true,
+ "subType": undefined,
+ "type": "string",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "long",
+ ],
+ "format": undefined,
+ "lang": "expression",
+ "name": "script number",
+ "readFromDocValues": false,
+ "script": "1234",
+ "scripted": true,
+ "searchable": true,
+ "subType": undefined,
+ "type": "number",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "date",
+ ],
+ "format": undefined,
+ "lang": "painless",
+ "name": "script date",
+ "readFromDocValues": false,
+ "script": "1234",
+ "scripted": true,
+ "searchable": true,
+ "subType": undefined,
+ "type": "date",
+ },
+ Object {
+ "aggregatable": true,
+ "conflictDescriptions": undefined,
+ "count": 0,
+ "esTypes": Array [
+ "murmur3",
+ ],
+ "format": undefined,
+ "lang": "expression",
+ "name": "script murmur3",
+ "readFromDocValues": false,
+ "script": "1234",
+ "scripted": true,
+ "searchable": true,
+ "subType": undefined,
+ "type": "murmur3",
+ },
+ ],
+ "id": "test-pattern",
+ "sourceFilters": undefined,
+ "timeFieldName": "timestamp",
+ "title": "test-pattern",
+ "typeMeta": undefined,
+ "version": 2,
+}
+`;
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index.ts b/src/plugins/data/common/index_patterns/index_patterns/index.ts
index 5fae08f3bb7755..77527857ed0caa 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index.ts
@@ -18,7 +18,6 @@
*/
export * from './index_patterns_api_client';
-export * from './types';
export * from './_pattern_cache';
export * from './flatten_hit';
export * from './format_hit';
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
index cea476781ad3bf..ba8e4f6fb36955 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.test.ts
@@ -30,6 +30,10 @@ import { Field } from '../fields';
import { fieldFormatsMock } from '../../field_formats/mocks';
+class MockFieldFormatter {}
+
+fieldFormatsMock.getType = jest.fn().mockImplementation(() => MockFieldFormatter);
+
jest.mock('../../field_mapping', () => {
const originalModule = jest.requireActual('../../field_mapping');
@@ -303,6 +307,29 @@ describe('IndexPattern', () => {
});
});
+ describe('toSpec', () => {
+ test('should match snapshot', () => {
+ indexPattern.fieldFormatMap.bytes = {
+ toJSON: () => ({ id: 'number', params: { pattern: '$0,0.[00]' } }),
+ };
+ expect(indexPattern.toSpec()).toMatchSnapshot();
+ });
+
+ test('can restore from spec', async () => {
+ indexPattern.fieldFormatMap.bytes = {
+ toJSON: () => ({ id: 'number', params: { pattern: '$0,0.[00]' } }),
+ };
+ const spec = indexPattern.toSpec();
+ const restoredPattern = await create(spec.id as string);
+ restoredPattern.initFromSpec(spec);
+ expect(restoredPattern.id).toEqual(indexPattern.id);
+ expect(restoredPattern.title).toEqual(indexPattern.title);
+ expect(restoredPattern.timeFieldName).toEqual(indexPattern.timeFieldName);
+ expect(restoredPattern.fields.length).toEqual(indexPattern.fields.length);
+ expect(restoredPattern.fieldFormatMap.bytes instanceof MockFieldFormatter).toEqual(true);
+ });
+ });
+
describe('popularizeField', () => {
test('should increment the popularity count by default', () => {
// const saveSpy = sinon.stub(indexPattern, 'save');
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
index cd39a965ae6fce..e9ac5a09b9db3a 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_pattern.ts
@@ -20,6 +20,7 @@
import _, { each, reject } from 'lodash';
import { i18n } from '@kbn/i18n';
import { SavedObjectsClientContract } from 'src/core/public';
+import { SavedObjectAttributes } from 'src/core/public';
import { DuplicateField, SavedObjectNotFound } from '../../../../kibana_utils/common';
import {
@@ -36,11 +37,12 @@ import { createFieldsFetcher } from './_fields_fetcher';
import { formatHitProvider } from './format_hit';
import { flattenHitWrapper } from './flatten_hit';
import { IIndexPatternsApiClient } from '.';
-import { TypeMeta } from '.';
import { OnNotification, OnError } from '../types';
import { FieldFormatsStartCommon } from '../../field_formats';
import { PatternCache } from './_pattern_cache';
import { expandShorthand, FieldMappingSpec, MappingObject } from '../../field_mapping';
+import { IndexPatternSpec, TypeMeta, FieldSpec, SourceFilter } from '../types';
+import { SerializedFieldFormat } from '../../../../expressions/common';
const MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS = 3;
const type = 'index-pattern';
@@ -60,10 +62,9 @@ export class IndexPattern implements IIndexPattern {
public id?: string;
public title: string = '';
- public type?: string;
public fieldFormatMap: any;
public typeMeta?: TypeMeta;
- public fields: IIndexPatternFieldList;
+ public fields: IIndexPatternFieldList & { toSpec: () => FieldSpec[] };
public timeFieldName: string | undefined;
public formatHit: any;
public formatField: any;
@@ -74,7 +75,7 @@ export class IndexPattern implements IIndexPattern {
private savedObjectsClient: SavedObjectsClientContract;
private patternCache: PatternCache;
private getConfig: any;
- private sourceFilters?: [];
+ private sourceFilters?: SourceFilter[];
private originalBody: { [key: string]: any } = {};
public fieldsFetcher: any; // probably want to factor out any direct usage and change to private
private shortDotsEnable: boolean = false;
@@ -196,6 +197,35 @@ export class IndexPattern implements IIndexPattern {
this.initFields();
}
+ public initFromSpec(spec: IndexPatternSpec) {
+ // create fieldFormatMap from field list
+ const fieldFormatMap: Record = {};
+ if (_.isArray(spec.fields)) {
+ spec.fields.forEach((field: FieldSpec) => {
+ if (field.format) {
+ fieldFormatMap[field.name as string] = { ...field.format };
+ }
+ });
+ }
+
+ this.version = spec.version;
+
+ this.title = spec.title || '';
+ this.timeFieldName = spec.timeFieldName;
+ this.sourceFilters = spec.sourceFilters;
+
+ // ignoring this because the same thing happens elsewhere but via _.assign
+ // @ts-ignore
+ this.fields = spec.fields || [];
+ this.typeMeta = spec.typeMeta;
+ this.fieldFormatMap = _.mapValues(fieldFormatMap, (mapping) => {
+ return this.deserializeFieldFormatMap(mapping);
+ });
+
+ this.initFields();
+ return this;
+ }
+
private updateFromElasticSearch(response: any, forceFieldRefresh: boolean = false) {
if (!response.found) {
throw new SavedObjectNotFound(type, this.id, 'management/kibana/indexPatterns');
@@ -206,15 +236,16 @@ export class IndexPattern implements IIndexPattern {
return;
}
- response._source[name] = fieldMapping._deserialize(response._source[name]);
+ response[name] = fieldMapping._deserialize(response[name]);
});
- // give index pattern all of the values in _source
- _.assign(this, response._source);
+ // give index pattern all of the values
+ _.assign(this, response);
if (!this.title && this.id) {
this.title = this.id;
}
+ this.version = response.version;
return this.indexFields(forceFieldRefresh);
}
@@ -266,13 +297,11 @@ export class IndexPattern implements IIndexPattern {
}
const savedObject = await this.savedObjectsClient.get(type, this.id);
- this.version = savedObject._version;
const response = {
- _id: savedObject.id,
- _type: savedObject.type,
- _source: _.cloneDeep(savedObject.attributes),
+ version: savedObject._version,
found: savedObject._version ? true : false,
+ ...(_.cloneDeep(savedObject.attributes) as SavedObjectAttributes),
};
// Do this before we attempt to update from ES since that call can potentially perform a save
this.originalBody = this.prepBody();
@@ -283,6 +312,19 @@ export class IndexPattern implements IIndexPattern {
return this;
}
+ public toSpec(): IndexPatternSpec {
+ return {
+ id: this.id,
+ version: this.version,
+
+ title: this.title,
+ timeFieldName: this.timeFieldName,
+ sourceFilters: this.sourceFilters,
+ fields: this.fields.toSpec(),
+ typeMeta: this.typeMeta,
+ };
+ }
+
// Get the source filtering configuration for that index.
getSourceFiltering() {
return {
diff --git a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
index 22d1765d793488..5e51897d133727 100644
--- a/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
+++ b/src/plugins/data/common/index_patterns/index_patterns/index_patterns.ts
@@ -32,12 +32,8 @@ import {
createEnsureDefaultIndexPattern,
EnsureDefaultIndexPattern,
} from './ensure_default_index_pattern';
-import {
- getIndexPatternFieldListCreator,
- CreateIndexPatternFieldList,
- Field,
- FieldSpec,
-} from '../fields';
+import { getIndexPatternFieldListCreator, CreateIndexPatternFieldList, Field } from '../fields';
+import { IndexPatternSpec, FieldSpec } from '../types';
import { OnNotification, OnError } from '../types';
import { FieldFormatsStartCommon } from '../../field_formats';
@@ -195,6 +191,21 @@ export class IndexPatternsService {
return indexPatternCache.set(id, indexPattern);
};
+ specToIndexPattern(spec: IndexPatternSpec) {
+ const indexPattern = new IndexPattern(spec.id, {
+ getConfig: (cfg: any) => this.config.get(cfg),
+ savedObjectsClient: this.savedObjectsClient,
+ apiClient: this.apiClient,
+ patternCache: indexPatternCache,
+ fieldFormats: this.fieldFormats,
+ onNotification: this.onNotification,
+ onError: this.onError,
+ });
+
+ indexPattern.initFromSpec(spec);
+ return indexPattern;
+ }
+
make = (id?: string): Promise => {
const indexPattern = new IndexPattern(id, {
getConfig: (cfg: any) => this.config.get(cfg),
diff --git a/src/plugins/data/common/index_patterns/index_patterns/types.ts b/src/plugins/data/common/index_patterns/index_patterns/types.ts
deleted file mode 100644
index b2060dd1d48bac..00000000000000
--- a/src/plugins/data/common/index_patterns/index_patterns/types.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 type AggregationRestrictions = Record<
- string,
- {
- agg?: string;
- interval?: number;
- fixed_interval?: string;
- calendar_interval?: string;
- delay?: string;
- time_zone?: string;
- }
->;
-
-export interface TypeMeta {
- aggs?: Record;
- [key: string]: any;
-}
diff --git a/src/plugins/data/common/index_patterns/types.ts b/src/plugins/data/common/index_patterns/types.ts
index 7399bbbc10a7e1..94121a274d686e 100644
--- a/src/plugins/data/common/index_patterns/types.ts
+++ b/src/plugins/data/common/index_patterns/types.ts
@@ -19,6 +19,8 @@
import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications';
import { IFieldType } from './fields';
+import { SerializedFieldFormat } from '../../../expressions/common';
+import { KBN_FIELD_TYPES } from '..';
export interface IIndexPattern {
[key: string]: any;
@@ -51,3 +53,65 @@ export interface IndexPatternAttributes {
export type OnNotification = (toastInputFields: ToastInputFields) => void;
export type OnError = (error: Error, toastInputFields: ErrorToastOptions) => void;
+
+export type AggregationRestrictions = Record<
+ string,
+ {
+ agg?: string;
+ interval?: number;
+ fixed_interval?: string;
+ calendar_interval?: string;
+ delay?: string;
+ time_zone?: string;
+ }
+>;
+
+export interface IFieldSubType {
+ multi?: { parent: string };
+ nested?: { path: string };
+}
+
+export interface TypeMeta {
+ aggs?: Record;
+ [key: string]: any;
+}
+
+export type FieldSpecConflictDescriptions = Record;
+
+// This should become FieldSpec once types are cleaned up
+export interface FieldSpecExportFmt {
+ count?: number;
+ script?: string;
+ lang?: string;
+ conflictDescriptions?: FieldSpecConflictDescriptions;
+ name: string;
+ type: KBN_FIELD_TYPES;
+ esTypes?: string[];
+ scripted: boolean;
+ searchable: boolean;
+ aggregatable: boolean;
+ readFromDocValues?: boolean;
+ subType?: IFieldSubType;
+ format?: SerializedFieldFormat;
+ indexed?: boolean;
+}
+
+export interface FieldSpec {
+ [key: string]: any;
+ format?: SerializedFieldFormat;
+}
+
+export interface IndexPatternSpec {
+ id?: string;
+ version?: string;
+
+ title: string;
+ timeFieldName?: string;
+ sourceFilters?: SourceFilter[];
+ fields?: FieldSpec[];
+ typeMeta?: TypeMeta;
+}
+
+export interface SourceFilter {
+ value: string;
+}
diff --git a/src/plugins/data/common/query/index.ts b/src/plugins/data/common/query/index.ts
index 421cc4f63e4efb..4e90f6f8bb83ec 100644
--- a/src/plugins/data/common/query/index.ts
+++ b/src/plugins/data/common/query/index.ts
@@ -19,3 +19,4 @@
export * from './filter_manager';
export * from './types';
+export * from './is_query';
diff --git a/src/legacy/core_plugins/testbed/index.js b/src/plugins/data/common/query/is_query.ts
similarity index 73%
rename from src/legacy/core_plugins/testbed/index.js
rename to src/plugins/data/common/query/is_query.ts
index f0b61ea0c3de77..08a99a39b1ac19 100644
--- a/src/legacy/core_plugins/testbed/index.js
+++ b/src/plugins/data/common/query/is_query.ts
@@ -17,14 +17,11 @@
* under the License.
*/
-import { resolve } from 'path';
+import { Query } from './types';
-export default function (kibana) {
- return new kibana.Plugin({
- id: 'testbed',
- publicDir: resolve(__dirname, 'public'),
- uiExports: {
- hacks: ['plugins/testbed'],
- },
- });
-}
+export const isQuery = (x: unknown): x is Query =>
+ !!x &&
+ typeof x === 'object' &&
+ typeof (x as Query).language === 'string' &&
+ (typeof (x as Query).query === 'string' ||
+ (typeof (x as Query).query === 'object' && !!(x as Query).query));
diff --git a/src/legacy/core_plugins/testbed/public/index.js b/src/plugins/data/common/timefilter/index.ts
similarity index 94%
rename from src/legacy/core_plugins/testbed/public/index.js
rename to src/plugins/data/common/timefilter/index.ts
index c6687de249cf2a..e0c509e119fda1 100644
--- a/src/legacy/core_plugins/testbed/public/index.js
+++ b/src/plugins/data/common/timefilter/index.ts
@@ -17,4 +17,4 @@
* under the License.
*/
-import './testbed';
+export { isTimeRange } from './is_time_range';
diff --git a/src/legacy/core_plugins/testbed/public/testbed.js b/src/plugins/data/common/timefilter/is_time_range.ts
similarity index 78%
rename from src/legacy/core_plugins/testbed/public/testbed.js
rename to src/plugins/data/common/timefilter/is_time_range.ts
index 13005a6106ca4e..f206cd04dde316 100644
--- a/src/legacy/core_plugins/testbed/public/testbed.js
+++ b/src/plugins/data/common/timefilter/is_time_range.ts
@@ -17,13 +17,10 @@
* under the License.
*/
-import uiRoutes from 'ui/routes';
-import template from './testbed.html';
+import { TimeRange } from './types';
-uiRoutes.when('/testbed', {
- template: template,
- controllerAs: 'testbed',
- controller: class TestbedController {
- constructor() {}
- },
-});
+export const isTimeRange = (x: unknown): x is TimeRange =>
+ !!x &&
+ typeof x === 'object' &&
+ typeof (x as TimeRange).from === 'string' &&
+ typeof (x as TimeRange).to === 'string';
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index 984ce18aa4d839..efce8d2c021c99 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -249,8 +249,6 @@ export {
IndexPattern,
IIndexPatternFieldList,
Field as IndexPatternField,
- TypeMeta as IndexPatternTypeMeta,
- AggregationRestrictions as IndexPatternAggRestrictions,
// TODO: exported only in stub_index_pattern test. Move into data plugin and remove export.
getIndexPatternFieldListCreator,
} from './index_patterns';
@@ -263,6 +261,8 @@ export {
KBN_FIELD_TYPES,
IndexPatternAttributes,
UI_SETTINGS,
+ TypeMeta as IndexPatternTypeMeta,
+ AggregationRestrictions as IndexPatternAggRestrictions,
} from '../common';
/*
@@ -440,6 +440,8 @@ export {
getKbnTypeNames,
} from '../common';
+export { isTimeRange, isQuery, isFilter, isFilters } from '../common';
+
export * from '../common/field_mapping';
/*
diff --git a/src/plugins/data/public/index_patterns/index.ts b/src/plugins/data/public/index_patterns/index.ts
index 0a8397467807c6..2c540527f468d2 100644
--- a/src/plugins/data/public/index_patterns/index.ts
+++ b/src/plugins/data/public/index_patterns/index.ts
@@ -34,11 +34,4 @@ export {
IIndexPatternFieldList,
} from '../../common/index_patterns';
-// TODO: figure out how to replace IndexPatterns in get_inner_angular.
-export {
- IndexPatternsService,
- IndexPatternsContract,
- IndexPattern,
- TypeMeta,
- AggregationRestrictions,
-} from './index_patterns';
+export { IndexPatternsService, IndexPatternsContract, IndexPattern } from './index_patterns';
diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md
index 31dc5b51a06f56..b12ad94017fbbb 100644
--- a/src/plugins/data/public/public.api.md
+++ b/src/plugins/data/public/public.api.md
@@ -902,6 +902,10 @@ export interface IFieldType {
sortable?: boolean;
// (undocumented)
subType?: IFieldSubType;
+ // Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ toSpec?: () => FieldSpec;
// (undocumented)
type: string;
// (undocumented)
@@ -937,8 +941,6 @@ export interface IIndexPattern {
//
// @public (undocumented)
export interface IIndexPatternFieldList extends Array {
- // Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts
- //
// (undocumented)
add(field: FieldSpec): void;
// (undocumented)
@@ -993,7 +995,9 @@ export class IndexPattern implements IIndexPattern {
// (undocumented)
fieldFormatMap: any;
// (undocumented)
- fields: IIndexPatternFieldList;
+ fields: IIndexPatternFieldList & {
+ toSpec: () => FieldSpec[];
+ };
// (undocumented)
fieldsFetcher: any;
// (undocumented)
@@ -1036,6 +1040,10 @@ export class IndexPattern implements IIndexPattern {
id?: string;
// (undocumented)
init(forceFieldRefresh?: boolean): Promise;
+ // Warning: (ae-forgotten-export) The symbol "IndexPatternSpec" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ initFromSpec(spec: IndexPatternSpec): this;
// (undocumented)
isTimeBased(): boolean;
// (undocumented)
@@ -1065,9 +1073,9 @@ export class IndexPattern implements IIndexPattern {
// (undocumented)
toJSON(): string | undefined;
// (undocumented)
- toString(): string;
+ toSpec(): IndexPatternSpec;
// (undocumented)
- type?: string;
+ toString(): string;
// (undocumented)
typeMeta?: IndexPatternTypeMeta;
}
@@ -1106,12 +1114,15 @@ export interface IndexPatternAttributes {
export class IndexPatternField implements IFieldType {
// (undocumented)
$$spec: FieldSpec;
+ // Warning: (ae-forgotten-export) The symbol "FieldSpecExportFmt" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "FieldDependencies" needs to be exported by the entry point index.d.ts
- constructor(indexPattern: IIndexPattern, spec: FieldSpec | IndexPatternField, shortDotsEnable: boolean, { fieldFormats, onNotification }: FieldDependencies);
+ constructor(indexPattern: IIndexPattern, spec: FieldSpecExportFmt | FieldSpec | IndexPatternField, shortDotsEnable: boolean, { fieldFormats, onNotification }: FieldDependencies);
// (undocumented)
aggregatable?: boolean;
+ // Warning: (ae-forgotten-export) The symbol "FieldSpecConflictDescriptions" needs to be exported by the entry point index.d.ts
+ //
// (undocumented)
- conflictDescriptions?: Record;
+ conflictDescriptions?: FieldSpecConflictDescriptions;
// (undocumented)
count?: number;
// (undocumented)
@@ -1141,6 +1152,8 @@ export class IndexPatternField implements IFieldType {
// (undocumented)
subType?: IFieldSubType;
// (undocumented)
+ toSpec: () => FieldSpecExportFmt;
+ // (undocumented)
type: string;
// (undocumented)
visualizable?: boolean;
@@ -1278,6 +1291,26 @@ export interface ISearchStrategy {
search: ISearch;
}
+// Warning: (ae-missing-release-tag) "isFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const isFilter: (x: unknown) => x is Filter;
+
+// Warning: (ae-missing-release-tag) "isFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const isFilters: (x: unknown) => x is Filter[];
+
+// Warning: (ae-missing-release-tag) "isQuery" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const isQuery: (x: unknown) => x is Query;
+
+// Warning: (ae-missing-release-tag) "isTimeRange" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
+//
+// @public (undocumented)
+export const isTimeRange: (x: unknown) => x is TimeRange;
+
// Warning: (ae-missing-release-tag) "ISyncSearchRequest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md
index 2ab0644f7237b7..136d960b52c347 100644
--- a/src/plugins/data/server/server.api.md
+++ b/src/plugins/data/server/server.api.md
@@ -392,6 +392,10 @@ export interface IFieldType {
sortable?: boolean;
// (undocumented)
subType?: IFieldSubType;
+ // Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts
+ //
+ // (undocumented)
+ toSpec?: () => FieldSpec;
// (undocumented)
type: string;
// (undocumented)
diff --git a/src/plugins/discover/public/application/angular/directives/histogram.tsx b/src/plugins/discover/public/application/angular/directives/histogram.tsx
index 8b646106fe52f0..9afe5e48bc5b82 100644
--- a/src/plugins/discover/public/application/angular/directives/histogram.tsx
+++ b/src/plugins/discover/public/application/angular/directives/histogram.tsx
@@ -323,6 +323,7 @@ export class DiscoverHistogram extends Component
({
getServices: () => ({
@@ -74,6 +75,7 @@ function getComponent(selected = false, showDetails = false, useShortDots = fals
format: null,
routes: {},
$$spec: {},
+ toSpec: () => (({} as unknown) as FieldSpecExportFmt),
} as IndexPatternField;
const props = {
diff --git a/src/plugins/discover/public/application/helpers/validate_time_range.test.ts b/src/plugins/discover/public/application/helpers/validate_time_range.test.ts
new file mode 100644
index 00000000000000..a61a729caa22b7
--- /dev/null
+++ b/src/plugins/discover/public/application/helpers/validate_time_range.test.ts
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+import { validateTimeRange } from './validate_time_range';
+import { notificationServiceMock } from '../../../../../core/public/mocks';
+
+describe('Discover validateTimeRange', () => {
+ test('validates given time ranges correctly', async () => {
+ const { toasts } = notificationServiceMock.createStartContract();
+ [
+ { from: '', to: '', result: false },
+ { from: 'now', to: 'now+1h', result: true },
+ { from: 'now', to: 'lala+1h', result: false },
+ { from: '', to: 'now', result: false },
+ { from: 'now', to: '', result: false },
+ { from: ' 2020-06-02T13:36:13.689Z', to: 'now', result: true },
+ { from: ' 2020-06-02T13:36:13.689Z', to: '2020-06-02T13:36:13.690Z', result: true },
+ ].map((test) => {
+ expect(validateTimeRange({ from: test.from, to: test.to }, toasts)).toEqual(test.result);
+ });
+ });
+
+ test('displays a toast when invalid data is entered', async () => {
+ const { toasts } = notificationServiceMock.createStartContract();
+ expect(validateTimeRange({ from: 'now', to: 'null' }, toasts)).toEqual(false);
+ expect(toasts.addDanger).toHaveBeenCalledWith({
+ title: 'Invalid time range',
+ text: "The provided time range is invalid. (from: 'now', to: 'null')",
+ });
+ });
+});
diff --git a/src/plugins/discover/public/application/helpers/validate_time_range.ts b/src/plugins/discover/public/application/helpers/validate_time_range.ts
new file mode 100644
index 00000000000000..411147f827333d
--- /dev/null
+++ b/src/plugins/discover/public/application/helpers/validate_time_range.ts
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+import dateMath from '@elastic/datemath';
+import { i18n } from '@kbn/i18n';
+import { ToastsStart } from 'kibana/public';
+
+/**
+ * Validates a given time filter range, provided by URL or UI
+ * Unless valid, it returns false and displays a notification
+ */
+export function validateTimeRange(
+ { from, to }: { from: string; to: string },
+ toastNotifications: ToastsStart
+): boolean {
+ const fromMoment = dateMath.parse(from);
+ const toMoment = dateMath.parse(to);
+ if (!fromMoment || !toMoment || !fromMoment.isValid() || !toMoment.isValid()) {
+ toastNotifications.addDanger({
+ title: i18n.translate('discover.notifications.invalidTimeRangeTitle', {
+ defaultMessage: `Invalid time range`,
+ }),
+ text: i18n.translate('discover.notifications.invalidTimeRangeText', {
+ defaultMessage: `The provided time range is invalid. (from: '{from}', to: '{to}')`,
+ values: {
+ from,
+ to,
+ },
+ }),
+ });
+ return false;
+ }
+ return true;
+}
diff --git a/src/plugins/discover/public/index.ts b/src/plugins/discover/public/index.ts
index 4154fdfeb3ff48..6ac8f674b61531 100644
--- a/src/plugins/discover/public/index.ts
+++ b/src/plugins/discover/public/index.ts
@@ -27,4 +27,4 @@ export function plugin(initializerContext: PluginInitializerContext) {
export { SavedSearch, SavedSearchLoader, createSavedSearchesLoader } from './saved_searches';
export { ISearchEmbeddable, SEARCH_EMBEDDABLE_TYPE, SearchInput } from './application/embeddable';
-export { DISCOVER_APP_URL_GENERATOR } from './url_generator';
+export { DISCOVER_APP_URL_GENERATOR, DiscoverUrlGeneratorState } from './url_generator';
diff --git a/src/plugins/discover/public/kibana_services.ts b/src/plugins/discover/public/kibana_services.ts
index cca63cd880b600..2c6bbcc3ecce12 100644
--- a/src/plugins/discover/public/kibana_services.ts
+++ b/src/plugins/discover/public/kibana_services.ts
@@ -60,10 +60,23 @@ export const [getDocViewsRegistry, setDocViewsRegistry] = createGetterSetter createHashHistory());
+/**
+ * Discover currently uses two `history` instances: one from Kibana Platform and
+ * another from `history` package. Below function is used every time Discover
+ * app is loaded to synchronize both instances.
+ *
+ * This helper is temporary until https://github.com/elastic/kibana/issues/65161 is resolved.
+ */
+export const syncHistoryLocations = () => {
+ const h = getHistory();
+ Object.assign(h.location, createHashHistory().location);
+ return h;
+};
+
export const [getScopedHistory, setScopedHistory] = createGetterSetter(
'scopedHistory'
);
diff --git a/src/plugins/discover/public/plugin.ts b/src/plugins/discover/public/plugin.ts
index ba97efa55068d7..e97ac783c616f0 100644
--- a/src/plugins/discover/public/plugin.ts
+++ b/src/plugins/discover/public/plugin.ts
@@ -55,6 +55,7 @@ import {
setServices,
setScopedHistory,
getScopedHistory,
+ syncHistoryLocations,
getServices,
} from './kibana_services';
import { createSavedSearchesLoader } from './saved_searches';
@@ -245,6 +246,7 @@ export class DiscoverPlugin
throw Error('Discover plugin method initializeInnerAngular is undefined');
}
setScopedHistory(params.history);
+ syncHistoryLocations();
appMounted();
const {
plugins: { data: dataStart },
diff --git a/src/plugins/discover/public/url_generator.ts b/src/plugins/discover/public/url_generator.ts
index 42d689050d5ad4..c7f2e2147e819c 100644
--- a/src/plugins/discover/public/url_generator.ts
+++ b/src/plugins/discover/public/url_generator.ts
@@ -98,11 +98,13 @@ export class DiscoverUrlGenerator
const queryState: QueryState = {};
if (query) appState.query = query;
- if (filters) appState.filters = filters?.filter((f) => !esFilters.isFilterPinned(f));
+ if (filters && filters.length)
+ appState.filters = filters?.filter((f) => !esFilters.isFilterPinned(f));
if (indexPatternId) appState.index = indexPatternId;
if (timeRange) queryState.time = timeRange;
- if (filters) queryState.filters = filters?.filter((f) => esFilters.isFilterPinned(f));
+ if (filters && filters.length)
+ queryState.filters = filters?.filter((f) => esFilters.isFilterPinned(f));
if (refreshInterval) queryState.refreshInterval = refreshInterval;
let url = `${this.params.appBasePath}#/${savedSearchPath}`;
diff --git a/src/plugins/embeddable/kibana.json b/src/plugins/embeddable/kibana.json
index 06b0e88da334fa..332237d19e2187 100644
--- a/src/plugins/embeddable/kibana.json
+++ b/src/plugins/embeddable/kibana.json
@@ -4,6 +4,7 @@
"server": false,
"ui": true,
"requiredPlugins": [
+ "data",
"inspector",
"uiActions"
],
diff --git a/src/plugins/embeddable/public/index.ts b/src/plugins/embeddable/public/index.ts
index 1d1dc79121937b..f19974942c43d1 100644
--- a/src/plugins/embeddable/public/index.ts
+++ b/src/plugins/embeddable/public/index.ts
@@ -28,6 +28,7 @@ export {
ACTION_EDIT_PANEL,
Adapters,
AddPanelAction,
+ ChartActionContext,
Container,
ContainerInput,
ContainerOutput,
@@ -69,7 +70,7 @@ export {
isRangeSelectTriggerContext,
isValueClickTriggerContext,
EmbeddableStateTransfer,
- EmbeddableOriginatingAppState,
+ EmbeddableEditorState,
EmbeddablePackageState,
EmbeddableRenderer,
EmbeddableRendererProps,
diff --git a/src/plugins/embeddable/public/lib/actions/edit_panel_action.test.tsx b/src/plugins/embeddable/public/lib/actions/edit_panel_action.test.tsx
index 4b602efb027177..594a7ad73c3965 100644
--- a/src/plugins/embeddable/public/lib/actions/edit_panel_action.test.tsx
+++ b/src/plugins/embeddable/public/lib/actions/edit_panel_action.test.tsx
@@ -59,7 +59,7 @@ test('redirects to app using state transfer', async () => {
const embeddable = new EditableEmbeddable({ id: '123', viewMode: ViewMode.EDIT }, true);
embeddable.getOutput = jest.fn(() => ({ editApp: 'ultraVisualize', editPath: '/123' }));
await action.execute({ embeddable });
- expect(stateTransferMock.navigateToWithOriginatingApp).toHaveBeenCalledWith('ultraVisualize', {
+ expect(stateTransferMock.navigateToEditor).toHaveBeenCalledWith('ultraVisualize', {
path: '/123',
state: { originatingApp: 'superCoolCurrentApp' },
});
diff --git a/src/plugins/embeddable/public/lib/actions/edit_panel_action.ts b/src/plugins/embeddable/public/lib/actions/edit_panel_action.ts
index d983dc9f418535..9177a77d547b0b 100644
--- a/src/plugins/embeddable/public/lib/actions/edit_panel_action.ts
+++ b/src/plugins/embeddable/public/lib/actions/edit_panel_action.ts
@@ -24,7 +24,7 @@ import { take } from 'rxjs/operators';
import { ViewMode } from '../types';
import { EmbeddableFactoryNotFoundError } from '../errors';
import { EmbeddableStart } from '../../plugin';
-import { IEmbeddable, EmbeddableOriginatingAppState, EmbeddableStateTransfer } from '../..';
+import { IEmbeddable, EmbeddableEditorState, EmbeddableStateTransfer } from '../..';
export const ACTION_EDIT_PANEL = 'editPanel';
@@ -35,7 +35,7 @@ interface ActionContext {
interface NavigationContext {
app: string;
path: string;
- state?: EmbeddableOriginatingAppState;
+ state?: EmbeddableEditorState;
}
export class EditPanelAction implements Action {
@@ -88,7 +88,7 @@ export class EditPanelAction implements Action {
const appTarget = this.getAppTarget(context);
if (appTarget) {
if (this.stateTransfer && appTarget.state) {
- await this.stateTransfer.navigateToWithOriginatingApp(appTarget.app, {
+ await this.stateTransfer.navigateToEditor(appTarget.app, {
path: appTarget.path,
state: appTarget.state,
});
diff --git a/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx b/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx
index 9c544e86e189ab..fcecf117d7d52b 100644
--- a/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx
+++ b/src/plugins/embeddable/public/lib/embeddables/embeddable.tsx
@@ -51,8 +51,7 @@ export abstract class Embeddable<
// to update input when the parent changes.
private parentSubscription?: Rx.Subscription;
- // TODO: Rename to destroyed.
- private destoyed: boolean = false;
+ private destroyed: boolean = false;
constructor(input: TEmbeddableInput, output: TEmbeddableOutput, parent?: IContainer) {
this.id = input.id;
@@ -123,7 +122,7 @@ export abstract class Embeddable<
}
public updateInput(changes: Partial): void {
- if (this.destoyed) {
+ if (this.destroyed) {
throw new Error('Embeddable has been destroyed');
}
if (this.parent) {
@@ -135,7 +134,7 @@ export abstract class Embeddable<
}
public render(domNode: HTMLElement | Element): void {
- if (this.destoyed) {
+ if (this.destroyed) {
throw new Error('Embeddable has been destroyed');
}
return;
@@ -155,7 +154,7 @@ export abstract class Embeddable<
* implementors to add any additional clean up tasks, like unmounting and unsubscribing.
*/
public destroy(): void {
- this.destoyed = true;
+ this.destroyed = true;
this.input$.complete();
this.output$.complete();
diff --git a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts
index 0d5ae6be68185b..b7dd95ccba32ca 100644
--- a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts
+++ b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.test.ts
@@ -38,7 +38,7 @@ describe('embeddable state transfer', () => {
});
it('can send an outgoing originating app state', async () => {
- await stateTransfer.navigateToWithOriginatingApp(destinationApp, { state: { originatingApp } });
+ await stateTransfer.navigateToEditor(destinationApp, { state: { originatingApp } });
expect(application.navigateToApp).toHaveBeenCalledWith('superUltraVisualize', {
state: { originatingApp: 'superUltraTestDashboard' },
});
@@ -50,7 +50,7 @@ describe('embeddable state transfer', () => {
application.navigateToApp,
(historyMock as unknown) as ScopedHistory
);
- await stateTransfer.navigateToWithOriginatingApp(destinationApp, {
+ await stateTransfer.navigateToEditor(destinationApp, {
state: { originatingApp },
appendToExistingState: true,
});
@@ -94,7 +94,7 @@ describe('embeddable state transfer', () => {
application.navigateToApp,
(historyMock as unknown) as ScopedHistory
);
- const fetchedState = stateTransfer.getIncomingOriginatingApp();
+ const fetchedState = stateTransfer.getIncomingEditorState();
expect(fetchedState).toEqual({ originatingApp: 'extremeSportsKibana' });
});
@@ -104,7 +104,7 @@ describe('embeddable state transfer', () => {
application.navigateToApp,
(historyMock as unknown) as ScopedHistory
);
- const fetchedState = stateTransfer.getIncomingOriginatingApp();
+ const fetchedState = stateTransfer.getIncomingEditorState();
expect(fetchedState).toBeUndefined();
});
diff --git a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts
index 57b425d2df45c2..8f70e5a66c478f 100644
--- a/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts
+++ b/src/plugins/embeddable/public/lib/state_transfer/embeddable_state_transfer.ts
@@ -20,8 +20,8 @@
import { cloneDeep } from 'lodash';
import { ScopedHistory, ApplicationStart } from '../../../../../core/public';
import {
- EmbeddableOriginatingAppState,
- isEmbeddableOriginatingAppState,
+ EmbeddableEditorState,
+ isEmbeddableEditorState,
EmbeddablePackageState,
isEmbeddablePackageState,
} from './types';
@@ -39,16 +39,16 @@ export class EmbeddableStateTransfer {
) {}
/**
- * Fetches an {@link EmbeddableOriginatingAppState | originating app} argument from the scoped
+ * Fetches an {@link EmbeddableEditorState | originating app} argument from the scoped
* history's location state.
*
* @param history - the scoped history to fetch from
* @param options.keysToRemoveAfterFetch - an array of keys to be removed from the state after they are retrieved
*/
- public getIncomingOriginatingApp(options?: {
+ public getIncomingEditorState(options?: {
keysToRemoveAfterFetch?: string[];
- }): EmbeddableOriginatingAppState | undefined {
- return this.getIncomingState(isEmbeddableOriginatingAppState, {
+ }): EmbeddableEditorState | undefined {
+ return this.getIncomingState(isEmbeddableEditorState, {
keysToRemoveAfterFetch: options?.keysToRemoveAfterFetch,
});
}
@@ -70,17 +70,17 @@ export class EmbeddableStateTransfer {
/**
* A wrapper around the {@link ApplicationStart.navigateToApp} method which navigates to the specified appId
- * with {@link EmbeddableOriginatingAppState | originating app state}
+ * with {@link EmbeddableEditorState | embeddable editor state}
*/
- public async navigateToWithOriginatingApp(
+ public async navigateToEditor(
appId: string,
options?: {
path?: string;
- state: EmbeddableOriginatingAppState;
+ state: EmbeddableEditorState;
appendToExistingState?: boolean;
}
): Promise {
- await this.navigateToWithState(appId, options);
+ await this.navigateToWithState(appId, options);
}
/**
diff --git a/src/plugins/embeddable/public/lib/state_transfer/index.ts b/src/plugins/embeddable/public/lib/state_transfer/index.ts
index e51efc5dcca26b..7daa7a0ea81d64 100644
--- a/src/plugins/embeddable/public/lib/state_transfer/index.ts
+++ b/src/plugins/embeddable/public/lib/state_transfer/index.ts
@@ -18,4 +18,4 @@
*/
export { EmbeddableStateTransfer } from './embeddable_state_transfer';
-export { EmbeddableOriginatingAppState, EmbeddablePackageState } from './types';
+export { EmbeddableEditorState, EmbeddablePackageState } from './types';
diff --git a/src/plugins/embeddable/public/lib/state_transfer/types.ts b/src/plugins/embeddable/public/lib/state_transfer/types.ts
index 8eae441d1be23c..a6721784302ac7 100644
--- a/src/plugins/embeddable/public/lib/state_transfer/types.ts
+++ b/src/plugins/embeddable/public/lib/state_transfer/types.ts
@@ -17,33 +17,49 @@
* under the License.
*/
+import { EmbeddableInput } from '..';
+
/**
* Represents a state package that contains the last active app id.
* @public
*/
-export interface EmbeddableOriginatingAppState {
+export interface EmbeddableEditorState {
originatingApp: string;
+ byValueMode?: boolean;
+ valueInput?: EmbeddableInput;
}
-export function isEmbeddableOriginatingAppState(
- state: unknown
-): state is EmbeddableOriginatingAppState {
+export function isEmbeddableEditorState(state: unknown): state is EmbeddableEditorState {
return ensureFieldOfTypeExists('originatingApp', state, 'string');
}
/**
- * Represents a state package that contains all fields necessary to create an embeddable in a container.
+ * Represents a state package that contains all fields necessary to create an embeddable by reference in a container.
* @public
*/
-export interface EmbeddablePackageState {
+export interface EmbeddablePackageByReferenceState {
type: string;
id: string;
}
+/**
+ * Represents a state package that contains all fields necessary to create an embeddable by value in a container.
+ * @public
+ */
+export interface EmbeddablePackageByValueState {
+ type: string;
+ input: EmbeddableInput;
+}
+
+export type EmbeddablePackageState =
+ | EmbeddablePackageByReferenceState
+ | EmbeddablePackageByValueState;
+
export function isEmbeddablePackageState(state: unknown): state is EmbeddablePackageState {
return (
- ensureFieldOfTypeExists('type', state, 'string') &&
- ensureFieldOfTypeExists('id', state, 'string')
+ (ensureFieldOfTypeExists('type', state, 'string') &&
+ ensureFieldOfTypeExists('id', state, 'string')) ||
+ ensureFieldOfTypeExists('input', state, 'object')
);
}
diff --git a/src/plugins/embeddable/public/lib/triggers/triggers.ts b/src/plugins/embeddable/public/lib/triggers/triggers.ts
index 2b447c89e28501..5bb96a708b7ac1 100644
--- a/src/plugins/embeddable/public/lib/triggers/triggers.ts
+++ b/src/plugins/embeddable/public/lib/triggers/triggers.ts
@@ -39,10 +39,6 @@ export interface ValueClickTriggerContext {
};
}
-export const isValueClickTriggerContext = (
- context: ValueClickTriggerContext | RangeSelectTriggerContext
-): context is ValueClickTriggerContext => context.data && 'data' in context.data;
-
export interface RangeSelectTriggerContext {
embeddable?: T;
data: {
@@ -53,8 +49,16 @@ export interface RangeSelectTriggerContext
};
}
+export type ChartActionContext =
+ | ValueClickTriggerContext
+ | RangeSelectTriggerContext;
+
+export const isValueClickTriggerContext = (
+ context: ChartActionContext
+): context is ValueClickTriggerContext => context.data && 'data' in context.data;
+
export const isRangeSelectTriggerContext = (
- context: ValueClickTriggerContext | RangeSelectTriggerContext
+ context: ChartActionContext
): context is RangeSelectTriggerContext => context.data && 'range' in context.data;
export const CONTEXT_MENU_TRIGGER = 'CONTEXT_MENU_TRIGGER';
diff --git a/src/plugins/embeddable/public/mocks.tsx b/src/plugins/embeddable/public/mocks.tsx
index 49910525c7ab18..efd0ccdc4553d7 100644
--- a/src/plugins/embeddable/public/mocks.tsx
+++ b/src/plugins/embeddable/public/mocks.tsx
@@ -31,6 +31,7 @@ import { coreMock } from '../../../core/public/mocks';
import { UiActionsService } from './lib/ui_actions';
import { CoreStart } from '../../../core/public';
import { Start as InspectorStart } from '../../inspector/public';
+import { dataPluginMock } from '../../data/public/mocks';
// eslint-disable-next-line
import { inspectorPluginMock } from '../../inspector/public/mocks';
@@ -78,9 +79,9 @@ export const createEmbeddablePanelMock = ({
export const createEmbeddableStateTransferMock = (): Partial => {
return {
- getIncomingOriginatingApp: jest.fn(),
+ getIncomingEditorState: jest.fn(),
getIncomingEmbeddablePackage: jest.fn(),
- navigateToWithOriginatingApp: jest.fn(),
+ navigateToEditor: jest.fn(),
navigateToWithEmbeddablePackage: jest.fn(),
};
};
@@ -100,6 +101,8 @@ const createStartContract = (): Start => {
EmbeddablePanel: jest.fn(),
getEmbeddablePanel: jest.fn(),
getStateTransfer: jest.fn(() => createEmbeddableStateTransferMock() as EmbeddableStateTransfer),
+ filtersAndTimeRangeFromContext: jest.fn(),
+ filtersFromContext: jest.fn(),
};
return startContract;
};
@@ -108,11 +111,13 @@ const createInstance = (setupPlugins: Partial = {})
const plugin = new EmbeddablePublicPlugin({} as any);
const setup = plugin.setup(coreMock.createSetup(), {
uiActions: setupPlugins.uiActions || uiActionsPluginMock.createSetupContract(),
+ data: dataPluginMock.createSetupContract(),
});
const doStart = (startPlugins: Partial = {}) =>
plugin.start(coreMock.createStart(), {
uiActions: startPlugins.uiActions || uiActionsPluginMock.createStartContract(),
inspector: inspectorPluginMock.createStartContract(),
+ data: dataPluginMock.createStartContract(),
});
return {
plugin,
diff --git a/src/plugins/embeddable/public/plugin.tsx b/src/plugins/embeddable/public/plugin.tsx
index c4e0ca44a4e7e3..03bb4a47792670 100644
--- a/src/plugins/embeddable/public/plugin.tsx
+++ b/src/plugins/embeddable/public/plugin.tsx
@@ -17,6 +17,13 @@
* under the License.
*/
import React from 'react';
+import {
+ DataPublicPluginSetup,
+ DataPublicPluginStart,
+ Filter,
+ TimeRange,
+ esFilters,
+} from '../../data/public';
import { getSavedObjectFinder } from '../../saved_objects/public';
import { UiActionsSetup, UiActionsStart } from '../../ui_actions/public';
import { Start as InspectorStart } from '../../inspector/public';
@@ -36,15 +43,20 @@ import {
defaultEmbeddableFactoryProvider,
IEmbeddable,
EmbeddablePanel,
+ ChartActionContext,
+ isRangeSelectTriggerContext,
+ isValueClickTriggerContext,
} from './lib';
import { EmbeddableFactoryDefinition } from './lib/embeddables/embeddable_factory_definition';
import { EmbeddableStateTransfer } from './lib/state_transfer';
export interface EmbeddableSetupDependencies {
+ data: DataPublicPluginSetup;
uiActions: UiActionsSetup;
}
export interface EmbeddableStartDependencies {
+ data: DataPublicPluginStart;
uiActions: UiActionsStart;
inspector: InspectorStart;
}
@@ -70,6 +82,19 @@ export interface EmbeddableStart {
embeddableFactoryId: string
) => EmbeddableFactory | undefined;
getEmbeddableFactories: () => IterableIterator;
+
+ /**
+ * Given {@link ChartActionContext} returns a list of `data` plugin {@link Filter} entries.
+ */
+ filtersFromContext: (context: ChartActionContext) => Promise;
+
+ /**
+ * Returns possible time range and filters that can be constructed from {@link ChartActionContext} object.
+ */
+ filtersAndTimeRangeFromContext: (
+ context: ChartActionContext
+ ) => Promise<{ filters: Filter[]; timeRange?: TimeRange }>;
+
EmbeddablePanel: EmbeddablePanelHOC;
getEmbeddablePanel: (stateTransfer?: EmbeddableStateTransfer) => EmbeddablePanelHOC;
getStateTransfer: (history?: ScopedHistory) => EmbeddableStateTransfer;
@@ -107,7 +132,7 @@ export class EmbeddablePublicPlugin implements Plugin {
this.embeddableFactories.set(
@@ -121,6 +146,41 @@ export class EmbeddablePublicPlugin implements Plugin {
+ try {
+ if (isRangeSelectTriggerContext(context))
+ return await data.actions.createFiltersFromRangeSelectAction(context.data);
+ if (isValueClickTriggerContext(context))
+ return await data.actions.createFiltersFromValueClickAction(context.data);
+ // eslint-disable-next-line no-console
+ console.warn("Can't extract filters from action.", context);
+ } catch (error) {
+ // eslint-disable-next-line no-console
+ console.warn('Error extracting filters from action. Returning empty filter list.', error);
+ }
+ return [];
+ };
+
+ const filtersAndTimeRangeFromContext: EmbeddableStart['filtersAndTimeRangeFromContext'] = async (
+ context
+ ) => {
+ const filters = await filtersFromContext(context);
+
+ if (!context.data.timeFieldName) return { filters };
+
+ const { timeRangeFilter, restOfFilters } = esFilters.extractTimeFilter(
+ context.data.timeFieldName,
+ filters
+ );
+
+ return {
+ filters: restOfFilters,
+ timeRange: timeRangeFilter
+ ? esFilters.convertRangeFilterToTimeRangeString(timeRangeFilter)
+ : undefined,
+ };
+ };
+
const getEmbeddablePanelHoc = (stateTransfer?: EmbeddableStateTransfer) => ({
embeddable,
hideHeader,
@@ -146,6 +206,8 @@ export class EmbeddablePublicPlugin implements Plugin {
return history
? new EmbeddableStateTransfer(core.application.navigateToApp, history)
diff --git a/src/plugins/embeddable/public/tests/test_plugin.ts b/src/plugins/embeddable/public/tests/test_plugin.ts
index e13a906e30338f..bb12e3d7b90116 100644
--- a/src/plugins/embeddable/public/tests/test_plugin.ts
+++ b/src/plugins/embeddable/public/tests/test_plugin.ts
@@ -23,6 +23,7 @@ import { UiActionsStart } from '../../../ui_actions/public';
import { uiActionsPluginMock } from '../../../ui_actions/public/mocks';
// eslint-disable-next-line
import { inspectorPluginMock } from '../../../inspector/public/mocks';
+import { dataPluginMock } from '../../../data/public/mocks';
import { coreMock } from '../../../../core/public/mocks';
import { EmbeddablePublicPlugin, EmbeddableSetup, EmbeddableStart } from '../plugin';
@@ -42,7 +43,10 @@ export const testPlugin = (
const uiActions = uiActionsPluginMock.createPlugin(coreSetup, coreStart);
const initializerContext = {} as any;
const plugin = new EmbeddablePublicPlugin(initializerContext);
- const setup = plugin.setup(coreSetup, { uiActions: uiActions.setup });
+ const setup = plugin.setup(coreSetup, {
+ data: dataPluginMock.createSetupContract(),
+ uiActions: uiActions.setup,
+ });
return {
plugin,
@@ -51,8 +55,9 @@ export const testPlugin = (
setup,
doStart: (anotherCoreStart: CoreStart = coreStart) => {
const start = plugin.start(anotherCoreStart, {
- uiActions: uiActionsPluginMock.createStartContract(),
+ data: dataPluginMock.createStartContract(),
inspector: inspectorPluginMock.createStartContract(),
+ uiActions: uiActionsPluginMock.createStartContract(),
});
return start;
},
diff --git a/src/plugins/kibana_usage_collection/server/__snapshots__/index.test.ts.snap b/src/plugins/kibana_usage_collection/server/__snapshots__/index.test.ts.snap
index 41c4c33b53c8d3..f07912eff02b7b 100644
--- a/src/plugins/kibana_usage_collection/server/__snapshots__/index.test.ts.snap
+++ b/src/plugins/kibana_usage_collection/server/__snapshots__/index.test.ts.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`kibana_usage_collection Runs the setup method without issues 1`] = `true`;
+exports[`kibana_usage_collection Runs the setup method without issues 1`] = `false`;
exports[`kibana_usage_collection Runs the setup method without issues 2`] = `true`;
diff --git a/src/plugins/kibana_usage_collection/server/index.test.ts b/src/plugins/kibana_usage_collection/server/index.test.ts
index c2680fef01caa7..d4b065896c88c8 100644
--- a/src/plugins/kibana_usage_collection/server/index.test.ts
+++ b/src/plugins/kibana_usage_collection/server/index.test.ts
@@ -17,7 +17,6 @@
* under the License.
*/
-import { BehaviorSubject } from 'rxjs';
import {
coreMock,
savedObjectsRepositoryMock,
@@ -47,30 +46,6 @@ describe('kibana_usage_collection', () => {
test('Runs the setup method without issues', () => {
const coreSetup = coreMock.createSetup();
- coreSetup.metrics.getOpsMetrics$.mockImplementation(
- () =>
- new BehaviorSubject({
- process: {
- memory: {
- heap: { total_in_bytes: 1, used_in_bytes: 1, size_limit: 1 },
- resident_set_size_in_bytes: 1,
- },
- event_loop_delay: 1,
- pid: 1,
- uptime_in_millis: 1,
- },
- os: {
- platform: 'darwin' as const,
- platformRelease: 'test',
- load: { '1m': 1, '5m': 1, '15m': 1 },
- memory: { total_in_bytes: 1, free_in_bytes: 1, used_in_bytes: 1 },
- uptime_in_millis: 1,
- },
- response_times: { avg_in_millis: 1, max_in_millis: 1 },
- requests: { disconnects: 1, total: 1, statusCodes: { '200': 1 } },
- concurrent_connections: 1,
- })
- );
expect(pluginInstance.setup(coreSetup, { usageCollection })).toBe(undefined);
usageCollectors.forEach(({ isReady }) => {
@@ -86,6 +61,7 @@ describe('kibana_usage_collection', () => {
coreStart.uiSettings.asScopedToClient.mockImplementation(() =>
uiSettingsServiceMock.createClient()
);
+
expect(pluginInstance.start(coreStart)).toBe(undefined);
usageCollectors.forEach(({ isReady }) => {
expect(isReady()).toBe(true); // All should return true at this point
diff --git a/src/plugins/kibana_usage_collection/server/plugin.ts b/src/plugins/kibana_usage_collection/server/plugin.ts
index 64d53671002365..803a9146bd08fd 100644
--- a/src/plugins/kibana_usage_collection/server/plugin.ts
+++ b/src/plugins/kibana_usage_collection/server/plugin.ts
@@ -18,18 +18,18 @@
*/
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
-import { Observable } from 'rxjs';
+import { Subject, Observable } from 'rxjs';
import {
PluginInitializerContext,
CoreSetup,
Plugin,
- MetricsServiceSetup,
ISavedObjectsRepository,
IUiSettingsClient,
SharedGlobalConfig,
SavedObjectsClient,
CoreStart,
SavedObjectsServiceSetup,
+ OpsMetrics,
} from '../../../core/server';
import {
registerApplicationUsageCollector,
@@ -49,16 +49,18 @@ export class KibanaUsageCollectionPlugin implements Plugin {
private readonly legacyConfig$: Observable;
private savedObjectsClient?: ISavedObjectsRepository;
private uiSettingsClient?: IUiSettingsClient;
+ private metric$: Subject;
constructor(initializerContext: PluginInitializerContext) {
this.legacyConfig$ = initializerContext.config.legacy.globalConfig$;
+ this.metric$ = new Subject();
}
public setup(
- { savedObjects, metrics, getStartServices }: CoreSetup,
+ { savedObjects }: CoreSetup,
{ usageCollection }: KibanaUsageCollectionPluginsDepsSetup
) {
- this.registerUsageCollectors(usageCollection, metrics, (opts) =>
+ this.registerUsageCollectors(usageCollection, this.metric$, (opts) =>
savedObjects.registerType(opts)
);
}
@@ -68,19 +70,22 @@ export class KibanaUsageCollectionPlugin implements Plugin {
this.savedObjectsClient = savedObjects.createInternalRepository();
const savedObjectsClient = new SavedObjectsClient(this.savedObjectsClient);
this.uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
+ core.metrics.getOpsMetrics$().subscribe(this.metric$);
}
- public stop() {}
+ public stop() {
+ this.metric$.complete();
+ }
private registerUsageCollectors(
usageCollection: UsageCollectionSetup,
- metrics: MetricsServiceSetup,
+ metric$: Subject,
registerType: SavedObjectsRegisterType
) {
const getSavedObjectsClient = () => this.savedObjectsClient;
const getUiSettingsClient = () => this.uiSettingsClient;
- registerOpsStatsCollector(usageCollection, metrics.getOpsMetrics$());
+ registerOpsStatsCollector(usageCollection, metric$);
registerKibanaUsageCollector(usageCollection, this.legacyConfig$);
registerManagementUsageCollector(usageCollection, getUiSettingsClient);
registerUiMetricUsageCollector(usageCollection, registerType, getSavedObjectsClient);
diff --git a/src/plugins/kibana_utils/common/state_containers/common.api.md b/src/plugins/kibana_utils/common/state_containers/common.api.md
new file mode 100644
index 00000000000000..f85458499b7193
--- /dev/null
+++ b/src/plugins/kibana_utils/common/state_containers/common.api.md
@@ -0,0 +1,156 @@
+## API Report File for "kibana"
+
+> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
+
+```ts
+
+import { ComponentType } from 'react';
+import { Ensure } from '@kbn/utility-types';
+import { FC } from 'react';
+import { Observable } from 'rxjs';
+import React from 'react';
+
+// @public
+export type BaseState = object;
+
+// @public
+export interface BaseStateContainer {
+ get: () => State;
+ set: (state: State) => void;
+ // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "Observable"
+ state$: Observable;
+}
+
+// @public
+export type Comparator = (previous: Result, current: Result) => boolean;
+
+// @public
+export type Connect = (mapStateToProp: MapStateToProps>) => (component: ComponentType) => FC>;
+
+// @public
+export function createStateContainer(defaultState: State): ReduxLikeStateContainer;
+
+// @public
+export function createStateContainer(defaultState: State, pureTransitions: PureTransitions): ReduxLikeStateContainer;
+
+// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "PureSelectors"
+//
+// @public
+export function createStateContainer(defaultState: State, pureTransitions: PureTransitions, pureSelectors: PureSelectors, options?: CreateStateContainerOptions): ReduxLikeStateContainer;
+
+// @public
+export interface CreateStateContainerOptions {
+ freeze?: (state: T) => T;
+}
+
+// @public
+export const createStateContainerReactHelpers: >() => {
+ Provider: React.Provider;
+ Consumer: React.Consumer;
+ context: React.Context;
+ useContainer: () => Container;
+ useState: () => UnboxState;
+ useTransitions: () => Container["transitions"];
+ useSelector: (selector: (state: UnboxState) => Result, comparator?: Comparator) => Result;
+ connect: Connect>;
+};
+
+// @public
+export type Dispatch = (action: T) => void;
+
+// @public (undocumented)
+export type EnsurePureSelector = Ensure>;
+
+// Warning: (ae-incompatible-release-tags) The symbol "EnsurePureTransition" is marked as @public, but its signature references "PureTransition" which is marked as @internal
+//
+// @public (undocumented)
+export type EnsurePureTransition = Ensure>;
+
+// @public
+export type MapStateToProps = (state: State) => StateProps;
+
+// Warning: (ae-incompatible-release-tags) The symbol "Middleware" is marked as @public, but its signature references "TransitionDescription" which is marked as @internal
+//
+// @public
+export type Middleware = (store: Pick, 'getState' | 'dispatch'>) => (next: (action: TransitionDescription) => TransitionDescription | any) => Dispatch;
+
+// @public (undocumented)
+export type PureSelector = (state: State) => Selector;
+
+// @public (undocumented)
+export type PureSelectorsToSelectors = {
+ [K in keyof T]: PureSelectorToSelector>;
+};
+
+// @public (undocumented)
+export type PureSelectorToSelector> = ReturnType>;
+
+// @internal (undocumented)
+export type PureTransition = (state: State) => Transition;
+
+// @internal (undocumented)
+export type PureTransitionsToTransitions = {
+ [K in keyof T]: PureTransitionToTransition>;
+};
+
+// @internal (undocumented)
+export type PureTransitionToTransition> = ReturnType;
+
+// Warning: (ae-incompatible-release-tags) The symbol "Reducer" is marked as @public, but its signature references "TransitionDescription" which is marked as @internal
+//
+// @public
+export type Reducer = (state: State, action: TransitionDescription) => State;
+
+// @public
+export interface ReduxLikeStateContainer extends StateContainer {
+ // (undocumented)
+ addMiddleware: (middleware: Middleware) => void;
+ // Warning: (ae-incompatible-release-tags) The symbol "dispatch" is marked as @public, but its signature references "TransitionDescription" which is marked as @internal
+ //
+ // (undocumented)
+ dispatch: (action: TransitionDescription) => void;
+ // (undocumented)
+ getState: () => State;
+ // (undocumented)
+ reducer: Reducer;
+ // (undocumented)
+ replaceReducer: (nextReducer: Reducer) => void;
+ // (undocumented)
+ subscribe: (listener: (state: State) => void) => () => void;
+}
+
+// @public (undocumented)
+export type Selector = (...args: Args) => Result;
+
+// @public
+export interface StateContainer extends BaseStateContainer {
+ // (undocumented)
+ selectors: Readonly>;
+ // Warning: (ae-incompatible-release-tags) The symbol "transitions" is marked as @public, but its signature references "PureTransitionsToTransitions" which is marked as @internal
+ //
+ // (undocumented)
+ transitions: Readonly>;
+}
+
+// @internal (undocumented)
+export type Transition = (...args: Args) => State;
+
+// @internal (undocumented)
+export interface TransitionDescription {
+ // (undocumented)
+ args: Args;
+ // (undocumented)
+ type: Type;
+}
+
+// @public
+export type UnboxState> = Container extends StateContainer ? T : never;
+
+// @public
+export const useContainerSelector: , Result>(container: Container, selector: (state: UnboxState) => Result, comparator?: Comparator) => Result;
+
+// @public
+export const useContainerState: >(container: Container) => UnboxState;
+
+
+```
diff --git a/src/plugins/kibana_utils/common/state_containers/create_state_container.ts b/src/plugins/kibana_utils/common/state_containers/create_state_container.ts
index 69e204a642f934..6bb6e66616c91e 100644
--- a/src/plugins/kibana_utils/common/state_containers/create_state_container.ts
+++ b/src/plugins/kibana_utils/common/state_containers/create_state_container.ts
@@ -44,29 +44,57 @@ const defaultFreeze: (value: T) => T = isProduction
return value as T;
};
+/**
+ * State container options
+ * @public
+ */
export interface CreateStateContainerOptions {
/**
- * Function to use when freezing state. Supply identity function
+ * Function to use when freezing state. Supply identity function.
+ * If not provided, default `deepFreeze` is used.
*
+ * @example
+ * If you expect that your state will be mutated externally an you cannot
+ * prevent that
* ```ts
* {
* freeze: state => state,
* }
* ```
- *
- * if you expect that your state will be mutated externally an you cannot
- * prevent that.
*/
freeze?: (state: T) => T;
}
+/**
+ * Creates a state container without transitions and without selectors.
+ * @param defaultState - initial state
+ * @typeParam State - shape of state
+ * @public
+ */
export function createStateContainer(
defaultState: State
): ReduxLikeStateContainer;
+/**
+ * Creates a state container with transitions, but without selectors.
+ * @param defaultState - initial state
+ * @param pureTransitions - state transitions configuration object. Map of {@link PureTransition}.
+ * @typeParam State - shape of state
+ * @public
+ */
export function createStateContainer(
defaultState: State,
pureTransitions: PureTransitions
): ReduxLikeStateContainer;
+
+/**
+ * Creates a state container with transitions and selectors.
+ * @param defaultState - initial state
+ * @param pureTransitions - state transitions configuration object. Map of {@link PureTransition}.
+ * @param pureSelectors - state selectors configuration object. Map of {@link PureSelectors}.
+ * @param options - state container options {@link CreateStateContainerOptions}
+ * @typeParam State - shape of state
+ * @public
+ */
export function createStateContainer<
State extends BaseState,
PureTransitions extends object,
@@ -77,14 +105,17 @@ export function createStateContainer<
pureSelectors: PureSelectors,
options?: CreateStateContainerOptions
): ReduxLikeStateContainer;
+/**
+ * @internal
+ */
export function createStateContainer<
State extends BaseState,
PureTransitions extends object,
PureSelectors extends object
>(
defaultState: State,
- pureTransitions: PureTransitions = {} as PureTransitions,
- pureSelectors: PureSelectors = {} as PureSelectors,
+ pureTransitions: PureTransitions = {} as PureTransitions, // TODO: https://github.com/elastic/kibana/issues/54439
+ pureSelectors: PureSelectors = {} as PureSelectors, // TODO: https://github.com/elastic/kibana/issues/54439
options: CreateStateContainerOptions = {}
): ReduxLikeStateContainer {
const { freeze = defaultFreeze } = options;
diff --git a/src/plugins/kibana_utils/common/state_containers/create_state_container_react_helpers.ts b/src/plugins/kibana_utils/common/state_containers/create_state_container_react_helpers.ts
index 8536f97e00ed06..4712c2fc233f83 100644
--- a/src/plugins/kibana_utils/common/state_containers/create_state_container_react_helpers.ts
+++ b/src/plugins/kibana_utils/common/state_containers/create_state_container_react_helpers.ts
@@ -17,7 +17,7 @@
* under the License.
*/
-import * as React from 'react';
+import React from 'react';
import useObservable from 'react-use/lib/useObservable';
import defaultComparator from 'fast-deep-equal';
import { Comparator, Connect, StateContainer, UnboxState } from './types';
@@ -25,23 +25,27 @@ import { Comparator, Connect, StateContainer, UnboxState } from './types';
const { useContext, useLayoutEffect, useRef, createElement: h } = React;
/**
- * Returns the latest state of a state container.
+ * React hooks that returns the latest state of a {@link StateContainer}.
*
- * @param container State container which state to track.
+ * @param container - {@link StateContainer} which state to track.
+ * @returns - latest {@link StateContainer} state
+ * @public
*/
export const useContainerState = >(
container: Container
): UnboxState => useObservable(container.state$, container.get());
/**
- * Apply selector to state container to extract only needed information. Will
+ * React hook to apply selector to state container to extract only needed information. Will
* re-render your component only when the section changes.
*
- * @param container State container which state to track.
- * @param selector Function used to pick parts of state.
- * @param comparator Comparator function used to memoize previous result, to not
+ * @param container - {@link StateContainer} which state to track.
+ * @param selector - Function used to pick parts of state.
+ * @param comparator - {@link Comparator} function used to memoize previous result, to not
* re-render React component if state did not change. By default uses
* `fast-deep-equal` package.
+ * @returns - result of a selector(state)
+ * @public
*/
export const useContainerSelector = , Result>(
container: Container,
@@ -68,6 +72,11 @@ export const useContainerSelector = ,
return value;
};
+/**
+ * Creates helpers for using {@link StateContainer | State Containers} with react
+ * Refer to {@link https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_containers/react.md | guide} for details
+ * @public
+ */
export const createStateContainerReactHelpers = >() => {
const context = React.createContext(null as any);
diff --git a/src/plugins/kibana_utils/common/state_containers/index.ts b/src/plugins/kibana_utils/common/state_containers/index.ts
index 43e204ecb79f7b..e2e056bd67da28 100644
--- a/src/plugins/kibana_utils/common/state_containers/index.ts
+++ b/src/plugins/kibana_utils/common/state_containers/index.ts
@@ -17,6 +17,40 @@
* under the License.
*/
-export * from './types';
-export * from './create_state_container';
-export * from './create_state_container_react_helpers';
+/**
+ * State containers are Redux-store-like objects meant to help you manage state in your services or apps.
+ * Refer to {@link https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_containers | guides and examples} for more info
+ *
+ * @packageDocumentation
+ */
+
+export {
+ BaseState,
+ BaseStateContainer,
+ TransitionDescription,
+ StateContainer,
+ ReduxLikeStateContainer,
+ Dispatch,
+ Middleware,
+ Selector,
+ Comparator,
+ MapStateToProps,
+ Connect,
+ Reducer,
+ UnboxState,
+ PureSelectorToSelector,
+ PureSelectorsToSelectors,
+ EnsurePureSelector,
+ PureTransitionsToTransitions,
+ PureTransitionToTransition,
+ EnsurePureTransition,
+ PureSelector,
+ PureTransition,
+ Transition,
+} from './types';
+export { createStateContainer, CreateStateContainerOptions } from './create_state_container';
+export {
+ createStateContainerReactHelpers,
+ useContainerSelector,
+ useContainerState,
+} from './create_state_container_react_helpers';
diff --git a/src/plugins/kibana_utils/common/state_containers/types.ts b/src/plugins/kibana_utils/common/state_containers/types.ts
index 29ffa4cd486b5c..b6adb89d9be7b0 100644
--- a/src/plugins/kibana_utils/common/state_containers/types.ts
+++ b/src/plugins/kibana_utils/common/state_containers/types.ts
@@ -19,28 +19,76 @@
import { Observable } from 'rxjs';
import { Ensure } from '@kbn/utility-types';
+import { FC, ComponentType } from 'react';
+/**
+ * Base {@link StateContainer} state shape
+ * @public
+ */
export type BaseState = object;
+
+/**
+ * @internal
+ */
export interface TransitionDescription {
type: Type;
args: Args;
}
+/**
+ * @internal
+ */
export type Transition = (...args: Args) => State;
+/**
+ * @internal
+ */
export type PureTransition = (
state: State
) => Transition;
+/**
+ * @public
+ */
export type EnsurePureTransition = Ensure>;
+/**
+ * @internal
+ */
export type PureTransitionToTransition> = ReturnType;
+/**
+ * @internal
+ */
export type PureTransitionsToTransitions = {
[K in keyof T]: PureTransitionToTransition>;
};
+/**
+ * Base state container shape without transitions or selectors
+ * @typeParam State - Shape of state in the container. Have to match {@link BaseState} constraint
+ * @public
+ */
export interface BaseStateContainer {
+ /**
+ * Retrieves current state from the container
+ * @returns current state
+ * @public
+ */
get: () => State;
+ /**
+ * Sets state into container
+ * @param state - new state to set
+ */
set: (state: State) => void;
+ /**
+ * {@link Observable} of state
+ */
state$: Observable;
}
+/**
+ * Fully featured state container with {@link Selector | Selectors} and {@link Transition | Transitions}. Extends {@link BaseStateContainer}.
+ * @typeParam State - Shape of state in the container. Has to match {@link BaseState} constraint
+ * @typeParam PureTransitions - map of {@link PureTransition | transitions} to provide on state container
+ * @typeParam PureSelectors - map of {@link PureSelector | selectors} to provide on state container
+ * @public
+ */
export interface StateContainer<
State extends BaseState,
PureTransitions extends object = object,
@@ -50,6 +98,11 @@ export interface StateContainer<
selectors: Readonly>;
}
+/**
+ * Fully featured state container which matches Redux store interface. Extends {@link StateContainer}.
+ * Allows to use state container with redux libraries.
+ * @public
+ */
export interface ReduxLikeStateContainer<
State extends BaseState,
PureTransitions extends object = {},
@@ -63,45 +116,92 @@ export interface ReduxLikeStateContainer<
subscribe: (listener: (state: State) => void) => () => void;
}
+/**
+ * Redux like dispatch
+ * @public
+ */
export type Dispatch = (action: T) => void;
+/**
+ * Redux like Middleware
+ * @public
+ */
export type Middleware = (
store: Pick, 'getState' | 'dispatch'>
) => (
next: (action: TransitionDescription) => TransitionDescription | any
) => Dispatch;
-
+/**
+ * Redux like Reducer
+ * @public
+ */
export type Reducer