diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 90f88de7d1104..9aa308c0dc58d 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -62,6 +62,7 @@
/packages/kbn-interpreter/ @elastic/kibana-app-services
/src/plugins/bfetch/ @elastic/kibana-app-services
/src/plugins/data/ @elastic/kibana-app-services
+/src/plugins/data-views/ @elastic/kibana-app-services
/src/plugins/embeddable/ @elastic/kibana-app-services
/src/plugins/expressions/ @elastic/kibana-app-services
/src/plugins/field_formats/ @elastic/kibana-app-services
diff --git a/.i18nrc.json b/.i18nrc.json
index 4107772e421ca..45016edc38dcd 100644
--- a/.i18nrc.json
+++ b/.i18nrc.json
@@ -9,6 +9,7 @@
"bfetch": "src/plugins/bfetch",
"dashboard": "src/plugins/dashboard",
"data": "src/plugins/data",
+ "dataViews": "src/plugins/data_views",
"embeddableApi": "src/plugins/embeddable",
"embeddableExamples": "examples/embeddable_examples",
"fieldFormats": "src/plugins/field_formats",
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 14dfaa84cebb6..8a19562eaff47 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,5 +1,5 @@
# Contributing to Kibana
-If you are an employee at Elastic, please check out our Developer Guide [here](https://docs.elastic.dev/kibana-dev-docs/welcome).
+If you are an employee at Elastic, please check out our Developer Guide [here](https://docs.elastic.dev/kibana-dev-docs/getting-started/welcome).
If you are an external developer, we have a legacy developer guide [here](https://www.elastic.co/guide/en/kibana/master/development.html), or you can view the raw docs from our new, internal Developer Guide [here](./dev_docs/getting_started/dev_welcome.mdx). Eventually, our internal Developer Guide will be opened for public consumption.
diff --git a/STYLEGUIDE.mdx b/STYLEGUIDE.mdx
index 95f29c674da9b..56117d0fd7e59 100644
--- a/STYLEGUIDE.mdx
+++ b/STYLEGUIDE.mdx
@@ -1,6 +1,6 @@
---
id: kibStyleGuide
-slug: /kibana-dev-docs/styleguide
+slug: /kibana-dev-docs/contributing/styleguide
title: Style Guide
summary: JavaScript/TypeScript styleguide.
date: 2021-05-06
diff --git a/dev_docs/api_welcome.mdx b/dev_docs/api_welcome.mdx
index be9281113b3d5..00d5bfb9644af 100644
--- a/dev_docs/api_welcome.mdx
+++ b/dev_docs/api_welcome.mdx
@@ -1,6 +1,6 @@
---
id: kibDevDocsApiWelcome
-slug: /kibana-dev-docs/api-welcome
+slug: /kibana-dev-docs/api-meta/welcome
title: Welcome
summary: How to use our automatically generated API documentation
date: 2021-02-25
diff --git a/dev_docs/best_practices.mdx b/dev_docs/contributing/best_practices.mdx
similarity index 99%
rename from dev_docs/best_practices.mdx
rename to dev_docs/contributing/best_practices.mdx
index 767e525c0afa7..27983d92ed121 100644
--- a/dev_docs/best_practices.mdx
+++ b/dev_docs/contributing/best_practices.mdx
@@ -1,6 +1,6 @@
---
id: kibBestPractices
-slug: /kibana-dev-docs/best-practices
+slug: /kibana-dev-docs/contributing/best-practices
title: Best practices
summary: Best practices to follow when building a Kibana plugin.
date: 2021-03-17
diff --git a/dev_docs/dev_principles.mdx b/dev_docs/contributing/dev_principles.mdx
similarity index 98%
rename from dev_docs/dev_principles.mdx
rename to dev_docs/contributing/dev_principles.mdx
index 4b238ea24f694..0b8f68d232367 100644
--- a/dev_docs/dev_principles.mdx
+++ b/dev_docs/contributing/dev_principles.mdx
@@ -1,10 +1,10 @@
---
id: kibDevPrinciples
-slug: /kibana-dev-docs/dev-principles
+slug: /kibana-dev-docs/contributing/dev-principles
title: Developer principles
-summary: Follow our development principles to help keep our code base stable, maintainable and scalable.
+summary: Follow our development principles to help keep our code base stable, maintainable and scalable.
date: 2021-03-04
-tags: ['kibana','onboarding', 'dev', 'architecture']
+tags: ['kibana', 'onboarding', 'dev', 'architecture']
---
Over time, the Kibana project has been shaped by certain principles. Like Kibana itself, some of these principles were formed by intention while others were the result of evolution and circumstance, but today all are important for the continued success and maintainability of Kibana.
@@ -117,4 +117,4 @@ The primary consumers of the code we write, the APIs that we create, and the fea
Features that we anticipate end users, admins, and plugin developers consuming should be documented through our official docs, but module-level READMEs and code comments are also appropriate.
-Documentation is critical part of developing features and code, so an undocumented feature is an incomplete feature.
\ No newline at end of file
+Documentation is critical part of developing features and code, so an undocumented feature is an incomplete feature.
diff --git a/dev_docs/contributing/how_we_use_github.mdx b/dev_docs/contributing/how_we_use_github.mdx
index f18bcbcf556f5..ff7901fdf08da 100644
--- a/dev_docs/contributing/how_we_use_github.mdx
+++ b/dev_docs/contributing/how_we_use_github.mdx
@@ -1,6 +1,6 @@
---
id: kibGitHub
-slug: /kibana-dev-docs/github
+slug: /kibana-dev-docs/contributing/github
title: How we use Github
summary: Forking, branching, committing and using labels in the Kibana GitHub repo
date: 2021-09-16
diff --git a/dev_docs/contributing/standards.mdx b/dev_docs/contributing/standards.mdx
index 3d41de8f229cc..5f61be80ee207 100644
--- a/dev_docs/contributing/standards.mdx
+++ b/dev_docs/contributing/standards.mdx
@@ -9,7 +9,7 @@ tags: ['contributor', 'dev', 'github', 'getting started', 'onboarding', 'kibana'
## Developer principles
-We expect all developers to read and abide by our overarching .
+We expect all developers to read and abide by our overarching .
## Style guide
diff --git a/dev_docs/getting_started/add_data.mdx b/dev_docs/getting_started/add_data.mdx
index b09e3f6262e77..46822b82fc40d 100644
--- a/dev_docs/getting_started/add_data.mdx
+++ b/dev_docs/getting_started/add_data.mdx
@@ -1,6 +1,6 @@
---
id: kibDevAddData
-slug: /kibana-dev-docs/tutorial/sample-data
+slug: /kibana-dev-docs/getting-started/sample-data
title: Add data
summary: Learn how to add data to Kibana
date: 2021-08-11
diff --git a/dev_docs/getting_started/dev_welcome.mdx b/dev_docs/getting_started/dev_welcome.mdx
index 5e569bd377ee0..4080e0850b946 100644
--- a/dev_docs/getting_started/dev_welcome.mdx
+++ b/dev_docs/getting_started/dev_welcome.mdx
@@ -1,6 +1,6 @@
---
id: kibDevDocsWelcome
-slug: /kibana-dev-docs/welcome
+slug: /kibana-dev-docs/getting-started/welcome
title: Welcome
summary: Build custom solutions and applications on top of Kibana.
date: 2021-01-02
diff --git a/dev_docs/getting_started/hello_world_plugin.mdx b/dev_docs/getting_started/hello_world_plugin.mdx
index 7c02d2807472c..b95d0cac201fc 100644
--- a/dev_docs/getting_started/hello_world_plugin.mdx
+++ b/dev_docs/getting_started/hello_world_plugin.mdx
@@ -1,6 +1,6 @@
---
id: kibHelloWorldApp
-slug: /kibana-dev-docs/hello-world-app
+slug: /kibana-dev-docs/getting-started/hello-world-app
title: Hello World
summary: Build a very basic plugin that registers an application that says "Hello World!".
date: 2021-08-03
diff --git a/dev_docs/getting_started/setting_up_a_development_env.mdx b/dev_docs/getting_started/setting_up_a_development_env.mdx
index 04e0511e255b1..4338083b1bc8d 100644
--- a/dev_docs/getting_started/setting_up_a_development_env.mdx
+++ b/dev_docs/getting_started/setting_up_a_development_env.mdx
@@ -1,6 +1,6 @@
---
id: kibDevTutorialSetupDevEnv
-slug: /kibana-dev-docs/tutorial/setup-dev-env
+slug: /kibana-dev-docs/getting-started/setup-dev-env
title: Set up a Development Environment
summary: Learn how to setup a development environment for contributing to the Kibana repository
date: 2021-04-26
diff --git a/dev_docs/troubleshooting.mdx b/dev_docs/getting_started/troubleshooting.mdx
similarity index 94%
rename from dev_docs/troubleshooting.mdx
rename to dev_docs/getting_started/troubleshooting.mdx
index f624a8cd77507..e0adfbad86a84 100644
--- a/dev_docs/troubleshooting.mdx
+++ b/dev_docs/getting_started/troubleshooting.mdx
@@ -1,6 +1,6 @@
---
id: kibTroubleshooting
-slug: /kibana-dev-docs/troubleshooting
+slug: /kibana-dev-docs/getting-started/troubleshooting
title: Troubleshooting
summary: A collection of tips for working around strange issues.
date: 2021-09-08
diff --git a/dev_docs/key_concepts/anatomy_of_a_plugin.mdx b/dev_docs/key_concepts/anatomy_of_a_plugin.mdx
index 3739f907c3d87..ca9119f4d21b3 100644
--- a/dev_docs/key_concepts/anatomy_of_a_plugin.mdx
+++ b/dev_docs/key_concepts/anatomy_of_a_plugin.mdx
@@ -1,6 +1,6 @@
---
id: kibDevAnatomyOfAPlugin
-slug: /kibana-dev-docs/anatomy-of-a-plugin
+slug: /kibana-dev-docs/key-concepts/anatomy-of-a-plugin
title: Anatomy of a plugin
summary: Anatomy of a Kibana plugin.
date: 2021-08-03
diff --git a/dev_docs/building_blocks.mdx b/dev_docs/key_concepts/building_blocks.mdx
similarity index 51%
rename from dev_docs/building_blocks.mdx
rename to dev_docs/key_concepts/building_blocks.mdx
index 6320a7db4558c..da3d0f32780be 100644
--- a/dev_docs/building_blocks.mdx
+++ b/dev_docs/key_concepts/building_blocks.mdx
@@ -1,26 +1,28 @@
---
id: kibBuildingBlocks
-slug: /kibana-dev-docs/building-blocks
+slug: /kibana-dev-docs/key-concepts/building-blocks
title: Building blocks
summary: Consider these building blocks when developing your plugin.
date: 2021-02-24
-tags: ['kibana','onboarding', 'dev', 'architecture']
+tags: ['kibana', 'onboarding', 'dev', 'architecture']
---
-When building a plugin in Kibana, there are a handful of architectural "building blocks" you can use. Some of these building blocks are "higher-level",
-and some are "lower-level". High-level building blocks come
+When building a plugin in Kibana, there are a handful of architectural "building blocks" you can use. Some of these building blocks are "higher-level",
+and some are "lower-level". High-level building blocks come
with many built-in capabilities, require less maintenance, and evolve new feature sets over time with little to no
- impact on consumers. When developers use high-level building blocks, new features are exposed consistently, across all of Kibana, at the same time.
- On the downside, they are not as flexible as our low-level building blocks.
-
- Low-level building blocks
- provide greater flexibility, but require more code to stitch them together into a meaningful UX. This results in higher maintenance cost for consumers and greater UI/UX variability
- across Kibana.
-
- For example, if an application is using and
- ,
- their application would automatically support runtime fields. If the app is instead using the
- lower-level , additional work would be required.
+impact on consumers. When developers use high-level building blocks, new features are exposed consistently, across all of Kibana, at the same time.
+On the downside, they are not as flexible as our low-level building blocks.
+
+Low-level building blocks
+provide greater flexibility, but require more code to stitch them together into a meaningful UX. This results in higher maintenance cost for consumers and greater UI/UX variability
+across Kibana.
+
+For example, if an application is using and , their application would
+automatically support runtime fields. If the app is instead using the lower-level , additional work would be required.
Armed with this knowledge, you can choose what works best for your use case!
@@ -32,23 +34,15 @@ The following high-level building blocks can be rendered directly into your appl
### Query Bar
-The provides a high-level Query Bar component that comes with support for Lucene, KQL, Saved Queries,
-and .
-
-If you would like to expose the ability to search and filter on Elasticsearch data, the Query Bar provided by the
-
- is your go-to building block.
+The provides a high-level Query Bar component that comes with support for Lucene, KQL, Saved Queries,
+and . If you would like to expose the ability to search and filter on Elasticsearch data, the Query Bar provided by the is your go-to building block.
**Github labels**: `Team:AppServices`, `Feature:QueryBar`
### Dashboard Embeddable
Add a Dashboard Embeddable directly inside your application to provide users with a set of visualizations and graphs that work seamlessly
-with the . Every feature that is added to a registered
-
-(Lens, Maps, Saved Searches and more) will be available automatically, as well as any
- that are
- added to the Embeddable context menu panel (for example, drilldowns, custom panel time ranges, and "share to" features).
+with the . Every feature that is added to a registered (Lens, Maps, Saved Searches and more) will be available automatically, as well as any that are added to the Embeddable context menu panel (for example, drilldowns, custom panel time ranges, and "share to" features).
The Dashboard Embeddable is one of the highest-level UI components you can add to your application.
@@ -56,11 +50,7 @@ The Dashboard Embeddable is one of the highest-level UI components you can add t
### Lens Embeddable
-Check out the Lens Embeddable if you wish to show users visualizations based on Elasticsearch data without worrying about query building and chart rendering. It's built on top of the
- , and integrates with
-
- and . Using the same configuration, it's also possible to link to
- a prefilled Lens editor, allowing the user to drill deeper and explore their data.
+Check out the Lens Embeddable if you wish to show users visualizations based on Elasticsearch data without worrying about query building and chart rendering. It's built on top of the , and integrates with and . Using the same configuration, it's also possible to link to a prefilled Lens editor, allowing the user to drill deeper and explore their data.
**Github labels**: `Team:VisEditors`, `Feature:Lens`
@@ -72,7 +62,7 @@ Check out the Map Embeddable if you wish to embed a map in your application.
### KibanaPageTemplate
-All Kibana pages should use KibanaPageTemplate to setup their pages. It's a thin wrapper around [EuiPageTemplate](https://elastic.github.io/eui/#/layout/page) that makes setting up common types of Kibana pages quicker and easier while also adhering to any Kibana-specific requirements.
+All Kibana pages should use KibanaPageTemplate to setup their pages. It's a thin wrapper around [EuiPageTemplate](https://elastic.github.io/eui/#/layout/page) that makes setting up common types of Kibana pages quicker and easier while also adhering to any Kibana-specific requirements.
Check out for more implementation guidance.
@@ -82,10 +72,11 @@ Check out are a high-level, space-aware abstraction layer that sits
-above Data Streams and Elasticsearch indices. Index Patterns provide users the
-ability to define and customize the data they wish to search and filter on, on a per-space basis. For example, users can specify a set of indices,
-and they can customize the field list with runtime fields, formatting options and custom labels.
+ are a high-level, space-aware
+abstraction layer that sits above Data Streams and Elasticsearch indices. Index Patterns provide users
+the ability to define and customize the data they wish to search and filter on, on a per-space basis.
+For example, users can specify a set of indices, and they can customize the field list with runtime fields,
+formatting options and custom labels.
Index Patterns are used in many other high-level building blocks so we highly recommend you consider this building block for your search needs.
@@ -93,18 +84,23 @@ Index Patterns are used in many other high-level building blocks so we highly re
### Search Source
- is a high-level search service offered by the
-. It requires an
-, and abstracts away the raw ES DSL and search endpoint. Internally
-it uses the ES . Use Search Source if you need to query data
-from Elasticsearch, and you aren't already using one of the high-level UI Components that handles this internally.
+ is a high-level search service
+offered by the . It requires
+an , and abstracts away
+the raw ES DSL and search endpoint. Internally it uses the ES
+. Use Search Source if you need to query data from Elasticsearch, and you aren't already using one of
+the high-level UI Components that handles this internally.
**Github labels**: `Team:AppServices`, `Feature:Search`
### Search Strategies
-Search Strategies are a low-level building block that abstracts away search details, like what REST endpoint is being called. The ES Search Strategy
-is a very lightweight abstraction layer that sits just above querying ES with the elasticsearch-js client. Other search stragies are offered for other
+Search Strategies are a low-level building block that abstracts away search details, like what REST endpoint is being called. The ES Search Strategy
+is a very lightweight abstraction layer that sits just above querying ES with the elasticsearch-js client. Other search stragies are offered for other
languages, like EQL and SQL. These are very low-level building blocks so expect a lot of glue work to make these work with the higher-level abstractions.
**Github labels**: `Team:AppServices`, `Feature:Search`
@@ -112,24 +108,24 @@ languages, like EQL and SQL. These are very low-level building blocks so expect
### Expressions
Expressions are a low-level building block that can be used if you have advanced search needs that requiring piping results into additional functionality, like
-joining and manipulating data. Lens and Canvas are built on top of Expressions. Most developers should be able to use
- or
- , rather than need to access the Expression language directly.
+joining and manipulating data. Lens and Canvas are built on top of Expressions. Most developers should be able to use or , rather than need to
+access the Expression language directly.{' '}
**Github labels**: `Team:AppServices`, `Feature:ExpressionLanguage`
## Saved Objects
- should be used if you need to persist application-level information. If you were building a TODO
-application, each TODO item would be a `Saved Object`. Saved objects come pre-wired with support for bulk export/import, security features like space sharing and
-space isolation, and tags.
+ should be used if you need to persist
+application-level information. If you were building a TODO application, each TODO item would be a `Saved
+Object`. Saved objects come pre-wired with support for bulk export/import, security features like space
+sharing and space isolation, and tags.
**Github labels**: `Team:Core`, `Feature:Saved Objects`
# Integration building blocks
Use the following building blocks to create an inter-connected, cross-application, holistic Kibana experience. These building blocks allow you to expose functionality
- that promotes your own application into other applications, as well as help developers of other applications integrate into your app.
+that promotes your own application into other applications, as well as help developers of other applications integrate into your app.
## UI Actions & Triggers
@@ -141,6 +137,6 @@ application could register a UI Action called "View in Maps" to appear any time
## Embeddables
Embeddables help you integrate your application with the Dashboard application. Register your custom UI Widget as an Embeddable and users will
-be able to add it as a panel on a Dashboard. With a little extra work, it can also be exposed in Canvas workpads.
+be able to add it as a panel on a Dashboard. With a little extra work, it can also be exposed in Canvas workpads.
**Github labels**: `Team:AppServices`, `Feature:Embeddables`
diff --git a/dev_docs/key_concepts/data_views.mdx b/dev_docs/key_concepts/data_views.mdx
index e2b64c8705c48..c514af21c0cf7 100644
--- a/dev_docs/key_concepts/data_views.mdx
+++ b/dev_docs/key_concepts/data_views.mdx
@@ -1,16 +1,16 @@
---
id: kibDataViewsKeyConcepts
-slug: /kibana-dev-docs/data-view-intro
+slug: /kibana-dev-docs/key-concepts/data-view-intro
title: Data Views
summary: Data views are the central method of defining queryable data sets in Kibana
date: 2021-08-11
-tags: ['kibana','dev', 'contributor', 'api docs']
+tags: ['kibana', 'dev', 'contributor', 'api docs']
---
-*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*
+_Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete._
Data views (formerly Kibana index patterns or KIPs) are the central method of describing sets of indices for queries. Usage is strongly recommended
-as a number of high level rely on them. Further, they provide a consistent view of data across
+as a number of high level rely on them. Further, they provide a consistent view of data across
a variety Kibana apps.
Data views are defined by a wildcard string (an index pattern) which matches indices, data streams, and index aliases, optionally specify a
@@ -20,8 +20,6 @@ on the data view via runtime fields. Schema-on-read functionality is provided by

-
-
The data view API is made available via the data plugin (`data.indexPatterns`, soon to be renamed) and most commonly used with
(`data.search.search.SearchSource`) to perform queries. SearchSource will apply existing filters and queries from the search bar UI.
@@ -29,4 +27,3 @@ Users can create data views via [Data view management](https://www.elastic.co/gu
Additionally, they can be created through the data view API.
Data views also allow formatters and custom labels to be defined for fields.
-
diff --git a/dev_docs/kibana_platform_plugin_intro.mdx b/dev_docs/key_concepts/kibana_platform_plugin_intro.mdx
similarity index 99%
rename from dev_docs/kibana_platform_plugin_intro.mdx
rename to dev_docs/key_concepts/kibana_platform_plugin_intro.mdx
index 252a6dcd9cd8e..b2255dbc8e5c4 100644
--- a/dev_docs/kibana_platform_plugin_intro.mdx
+++ b/dev_docs/key_concepts/kibana_platform_plugin_intro.mdx
@@ -1,6 +1,6 @@
---
id: kibPlatformIntro
-slug: /kibana-dev-docs/platform-intro
+slug: /kibana-dev-docs/key-concepts/platform-intro
title: Plugins and the Kibana platform
summary: An introduction to the Kibana platform and how to use it to build a plugin.
date: 2021-01-06
diff --git a/dev_docs/key_concepts/performance.mdx b/dev_docs/key_concepts/performance.mdx
index 2870262825e4a..0201c7774f854 100644
--- a/dev_docs/key_concepts/performance.mdx
+++ b/dev_docs/key_concepts/performance.mdx
@@ -1,6 +1,6 @@
---
id: kibDevPerformance
-slug: /kibana-dev-docs/performance
+slug: /kibana-dev-docs/key-concepts/performance
title: Performance
summary: Performance tips for Kibana development.
date: 2021-09-02
@@ -9,13 +9,13 @@ tags: ['kibana', 'onboarding', 'dev', 'performance']
## Keep Kibana fast
-*tl;dr*: Load as much code lazily as possible. Everyone loves snappy
+_tl;dr_: Load as much code lazily as possible. Everyone loves snappy
applications with a responsive UI and hates spinners. Users deserve the
best experience whether they run Kibana locally or
in the cloud, regardless of their hardware and environment.
There are 2 main aspects of the perceived speed of an application: loading time
-and responsiveness to user actions. Kibana loads and bootstraps *all*
+and responsiveness to user actions. Kibana loads and bootstraps _all_
the plugins whenever a user lands on any page. It means that
every new application affects the overall _loading performance_, as plugin code is
loaded _eagerly_ to initialize the plugin and provide plugin API to dependent
@@ -60,12 +60,12 @@ export class MyPlugin implements Plugin {
### Understanding plugin bundle size
-Kibana Platform plugins are pre-built with `@kbn/optimizer`
+Kibana Platform plugins are pre-built with `@kbn/optimizer`
and distributed as package artifacts. This means that it is no
-longer necessary for us to include the `optimizer` in the
+longer necessary for us to include the `optimizer` in the
distributable version of Kibana Every plugin artifact contains all
plugin dependencies required to run the plugin, except some
-stateful dependencies shared across plugin bundles via
+stateful dependencies shared across plugin bundles via
`@kbn/ui-shared-deps-npm` and `@kbn/ui-shared-deps-src`. This means
that plugin artifacts _tend to be larger_ than they were in the
legacy platform. To understand the current size of your plugin
@@ -101,7 +101,7 @@ node scripts/build_kibana_platform_plugins.js --dist --no-examples --profile
Many OSS tools allow you to analyze the generated stats file:
-* [An official tool](https://webpack.github.io/analyse/#modules) from
-Webpack authors
-* [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/)
-* [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)
+- [An official tool](https://webpack.github.io/analyse/#modules) from
+ Webpack authors
+- [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/)
+- [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)
diff --git a/dev_docs/key_concepts/persistable_state.mdx b/dev_docs/key_concepts/persistable_state.mdx
index 4368417170eed..189259cf1085b 100644
--- a/dev_docs/key_concepts/persistable_state.mdx
+++ b/dev_docs/key_concepts/persistable_state.mdx
@@ -1,19 +1,19 @@
---
id: kibDevDocsPersistableStateIntro
-slug: /kibana-dev-docs/persistable-state-intro
+slug: /kibana-dev-docs/key-concepts/persistable-state-intro
title: Persistable State
summary: Persitable state is a key concept to understand when building a Kibana plugin.
date: 2021-02-02
-tags: ['kibana','dev', 'contributor', 'api docs']
+tags: ['kibana', 'dev', 'contributor', 'api docs']
---
- “Persistable state” is developer-defined state that supports being persisted by a plugin other than the one defining it. Persistable State needs to be serializable and the owner can/should provide utilities to migrate it, extract and inject any it may contain, as well as telemetry collection utilities.
-
+“Persistable state” is developer-defined state that supports being persisted by a plugin other than the one defining it. Persistable State needs to be serializable and the owner can/should provide utilities to migrate it, extract and inject any it may contain, as well as telemetry collection utilities.
+
## Exposing state that can be persisted
Any plugin that exposes state that another plugin might persist should implement interface on their `setup` contract. This will allow plugins persisting the state to easily access migrations and other utilities.
-Example: Data plugin allows you to generate filters. Those filters can be persisted by applications in their saved
+Example: Data plugin allows you to generate filters. Those filters can be persisted by applications in their saved
objects or in the URL. In order to allow apps to migrate the filters in case the structure changes in the future, the Data plugin implements `PersistableStateService` on .
note: There is currently no obvious way for a plugin to know which state is safe to persist. The developer must manually look for a matching `PersistableStateService`, or ad-hoc provided migration utilities (as is the case with Rule Type Parameters).
@@ -26,9 +26,10 @@ interface on their `setup` contract and each item in the collection should imple
Example: Embeddable plugin owns the registry of embeddable factories to which other plugins can register new embeddable factories. Dashboard plugin
stores a bunch of embeddable panels input in its saved object and URL. Embeddable plugin setup contract implements `PersistableStateService`
-interface and each `EmbeddableFactory` needs to implement `PersistableStateDefinition` interface.
+interface and each `EmbeddableFactory` needs to implement `PersistableStateDefinition` interface.
Embeddable plugin exposes this interfaces:
+
```
// EmbeddableInput implements Serializable
@@ -45,7 +46,7 @@ If the state your plugin is storing can be provided by other plugins (your plugi
## Storing persistable state as part of saved object
-Any plugin that stores any persistable state as part of their saved object should make sure that its saved object migration
+Any plugin that stores any persistable state as part of their saved object should make sure that its saved object migration
and reference extraction and injection methods correctly use the matching `PersistableStateService` implementation for the state they are storing.
Take a look at [example saved object](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/server/searchable_list_saved_object.ts#L32) which stores an embeddable state. Note how the `migrations`, `extractReferences` and `injectReferences` are defined.
@@ -58,13 +59,17 @@ of `PersistableStateService` should be called, which will migrate the state from
note: Currently there is no recommended way on how to store version in url and its up to every application to decide on how to implement that.
## Available state operations
-
+
### Extraction/Injection of References
In order to support import and export, and space-sharing capabilities, Saved Objects need to explicitly list any references they contain to other Saved Objects.
To support persisting your state in saved objects owned by another plugin, the and methods of Persistable State interface should be implemented.
-
+
[See example embeddable providing extract/inject functions](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/public/migrations/migrations_embeddable_factory.ts)
@@ -72,7 +77,7 @@ To support persisting your state in saved objects owned by another plugin, the <
As your plugin evolves, you may need to change your state in a breaking way. If that happens, you should write a migration to upgrade the state that existed prior to the change.
-.
+.
[See an example saved object storing embeddable state implementing saved object migration function](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/server/searchable_list_saved_object.ts)
@@ -80,4 +85,4 @@ As your plugin evolves, you may need to change your state in a breaking way. If
## Telemetry
-You might want to collect statistics about how your state is used. If that is the case you should implement the telemetry method of Persistable State interface.
+You might want to collect statistics about how your state is used. If that is the case you should implement the telemetry method of Persistable State interface.
diff --git a/dev_docs/key_concepts/saved_objects.mdx b/dev_docs/key_concepts/saved_objects.mdx
index bef92bf028697..7fe66b9eab95c 100644
--- a/dev_docs/key_concepts/saved_objects.mdx
+++ b/dev_docs/key_concepts/saved_objects.mdx
@@ -1,39 +1,42 @@
---
id: kibDevDocsSavedObjectsIntro
-slug: /kibana-dev-docs/saved-objects-intro
+slug: /kibana-dev-docs/key-concepts/saved-objects-intro
title: Saved Objects
summary: Saved Objects are a key concept to understand when building a Kibana plugin.
date: 2021-02-02
-tags: ['kibana','dev', 'contributor', 'api docs']
+tags: ['kibana', 'dev', 'contributor', 'api docs']
---
"Saved Objects" are developer defined, persisted entities, stored in the Kibana system index (which is also sometimes referred to as the `.kibana` index).
The Saved Objects service allows Kibana plugins to use Elasticsearch like a primary database. Think of it as an Object Document Mapper for Elasticsearch.
- Some examples of Saved Object types are dashboards, lens, canvas workpads, index patterns, cases, ml jobs, and advanced settings. Some Saved Object types are
- exposed to the user in the [Saved Object management UI](https://www.elastic.co/guide/en/kibana/current/managing-saved-objects.html), but not all.
+Some examples of Saved Object types are dashboards, lens, canvas workpads, index patterns, cases, ml jobs, and advanced settings. Some Saved Object types are
+exposed to the user in the [Saved Object management UI](https://www.elastic.co/guide/en/kibana/current/managing-saved-objects.html), but not all.
Developers create and manage their Saved Objects using the SavedObjectClient, while other data in Elasticsearch should be accessed via the data plugin's search
services.

-
-
+
## References
In order to support import and export, and space-sharing capabilities, Saved Objects need to explicitly list any references they contain to other Saved Objects.
The parent should have a reference to it's children, not the other way around. That way when a "parent" is exported (or shared to a space),
- all the "children" will be automatically included. However, when a "child" is exported, it will not include all "parents".
+all the "children" will be automatically included. However, when a "child" is exported, it will not include all "parents".
-
+
## Migrations and Backward compatibility
As your plugin evolves, you may need to change your Saved Object type in a breaking way (for example, changing the type of an attribtue, or removing
an attribute). If that happens, you should write a migration to upgrade the Saved Objects that existed prior to the change.
-.
+.
## Security
@@ -47,30 +50,30 @@ Saved Objects are "space aware". They exist in the space they were created in, a
Feature controls provide another level of isolation and shareability for Saved Objects. Admins can give users and roles read, write or none permissions for each Saved Object type.
-### Object level security (OLS)
+### Object level security (OLS)
OLS is an oft-requested feature that is not implemented yet. When it is, it will provide users with even more sharing and privacy flexibility. Individual
objects can be private to the user, shared with a selection of others, or made public. Much like how sharing Google Docs works.
-
+
## Scalability
By default all saved object types go into a single index. If you expect your saved object type to have a lot of unique fields, or if you expect there
-to be many of them, you can have your objects go in a separate index by using the `indexPattern` field. Reporting and task manager are two
+to be many of them, you can have your objects go in a separate index by using the `indexPattern` field. Reporting and task manager are two
examples of features that use this capability.
## Searchability
-Because saved objects are stored in system indices, they cannot be searched like other data can. If you see the phrase “[X] as data” it is
+Because saved objects are stored in system indices, they cannot be searched like other data can. If you see the phrase “[X] as data” it is
referring to this searching limitation. Users will not be able to create custom dashboards using saved object data, like they would for data stored
in Elasticsearch data indices.
## Saved Objects by value
Sometimes Saved Objects end up persisted inside another Saved Object. We call these Saved Objects “by value”, as opposed to "by
- reference". If an end user creates a visualization and adds it to a dashboard without saving it to the visualization
- library, the data ends up nested inside the dashboard Saved Object. This helps keep the visualization library smaller. It also avoids
- issues with edits propagating - since an entity can only exist in a single place.
- Note that from the end user stand point, we don’t use these terms “by reference” and “by value”.
+reference". If an end user creates a visualization and adds it to a dashboard without saving it to the visualization
+library, the data ends up nested inside the dashboard Saved Object. This helps keep the visualization library smaller. It also avoids
+issues with edits propagating - since an entity can only exist in a single place.
+Note that from the end user stand point, we don’t use these terms “by reference” and “by value”.
## Sharing Saved Objects
@@ -80,7 +83,7 @@ on how it is registered.
If you are adding a **new** object type, when you register it:
1. Use `namespaceType: 'multiple-isolated'` to make these objects exist in exactly one space
-2. Use `namespaceType: 'multiple'` to make these objects exist in one *or more* spaces
+2. Use `namespaceType: 'multiple'` to make these objects exist in one _or more_ spaces
3. Use `namespaceType: 'agnostic'` if you want these objects to always exist in all spaces
If you have an **existing** "legacy" object type that is not shareable (using `namespaceType: 'single'`), see the [legacy developer guide
diff --git a/dev_docs/tutorials/building_a_kibana_distributable.mdx b/dev_docs/tutorials/building_a_kibana_distributable.mdx
index 7b06525a5b977..e73481058ab35 100644
--- a/dev_docs/tutorials/building_a_kibana_distributable.mdx
+++ b/dev_docs/tutorials/building_a_kibana_distributable.mdx
@@ -1,6 +1,6 @@
---
id: kibDevTutorialBuildingDistributable
-slug: /kibana-dev-docs/tutorial/building-distributable
+slug: /kibana-dev-docs/tutorials/building-distributable
title: Building a Kibana distributable
summary: Learn how to build a Kibana distributable
date: 2021-05-10
diff --git a/dev_docs/tutorials/data/search.mdx b/dev_docs/tutorials/data/search.mdx
index 9cf46bb96c72a..81080b0c27418 100644
--- a/dev_docs/tutorials/data/search.mdx
+++ b/dev_docs/tutorials/data/search.mdx
@@ -2,14 +2,14 @@
id: kibDevTutorialDataSearchAndSessions
slug: /kibana-dev-docs/tutorials/data/search-and-sessions
title: Kibana data.search Services
-summary: Kibana Search Services
+summary: Kibana Search Services
date: 2021-02-10
tags: ['kibana', 'onboarding', 'dev', 'tutorials', 'search', 'sessions', 'search-sessions']
---
## Search service
-### Low level search
+### Low level search
Searching data stored in Elasticsearch can be done in various ways, for example using the Elasticsearch REST API or using an `Elasticsearch Client` for low level access.
@@ -50,7 +50,7 @@ export class MyPlugin implements Plugin {
} else {
// handle partial results if you want.
}
- },
+ },
error: (e) => {
// handle error thrown, for example a server hangup
},
@@ -69,36 +69,36 @@ Note: The `data` plugin contains services to help you generate the `query` and `
The `search` method can throw several types of errors, for example:
- - `EsError` for errors originating in Elasticsearch errors
- - `PainlessError` for errors originating from a Painless script
- - `AbortError` if the search was aborted via an `AbortController`
- - `HttpError` in case of a network error
+- `EsError` for errors originating in Elasticsearch errors
+- `PainlessError` for errors originating from a Painless script
+- `AbortError` if the search was aborted via an `AbortController`
+- `HttpError` in case of a network error
-To display the errors in the context of an application, use the helper method provided on the `data.search` service. These errors are shown in a toast message, using the `core.notifications` service.
+To display the errors in the context of an application, use the helper method provided on the `data.search` service. These errors are shown in a toast message, using the `core.notifications` service.
```ts
data.search.search(req).subscribe({
- next: (result) => {},
+ next: (result) => {},
error: (e) => {
data.search.showError(e);
},
-})
+});
```
If you decide to handle errors by yourself, watch for errors coming from `Elasticsearch`. They have an additional `attributes` property that holds the raw error from `Elasticsearch`.
```ts
data.search.search(req).subscribe({
- next: (result) => {},
+ next: (result) => {},
error: (e) => {
if (e instanceof IEsError) {
showErrorReason(e.attributes);
}
},
-})
+});
```
-#### Stop a running search
+#### Stop a running search
The search service `search` method supports a second argument called `options`. One of these options provides an `abortSignal` to stop searches from running to completion, if the result is no longer needed.
@@ -106,20 +106,22 @@ The search service `search` method supports a second argument called `options`.
import { AbortError } from '../../src/data/public';
const abortController = new AbortController();
-data.search.search(req, {
- abortSignal: abortController.signal,
-}).subscribe({
- next: (result) => {
- // handle result
- },
- error: (e) => {
- if (e instanceof AbortError) {
- // you can ignore this error
- return;
- }
- // handle error, for example a server hangup
- },
-});
+data.search
+ .search(req, {
+ abortSignal: abortController.signal,
+ })
+ .subscribe({
+ next: (result) => {
+ // handle result
+ },
+ error: (e) => {
+ if (e instanceof AbortError) {
+ // you can ignore this error
+ return;
+ }
+ // handle error, for example a server hangup
+ },
+ });
// Abort the search request after a second
setTimeout(() => {
@@ -135,13 +137,15 @@ For example, to run an EQL query using the `data.search` service, you should to
```ts
const req = getEqlRequest();
-data.search.search(req, {
- strategy: EQL_SEARCH_STRATEGY,
-}).subscribe({
- next: (result) => {
- // handle EQL result
- },
-});
+data.search
+ .search(req, {
+ strategy: EQL_SEARCH_STRATEGY,
+ })
+ .subscribe({
+ next: (result) => {
+ // handle EQL result
+ },
+ });
```
##### Custom search strategies
@@ -154,18 +158,18 @@ The following example shows how to define, register, and use a search strategy t
// ./myPlugin/server/myStrategy.ts
/**
- * Your custom search strategy should implement the ISearchStrategy interface, requiring at minimum a `search` function.
+ * Your custom search strategy should implement the ISearchStrategy interface, requiring at minimum a `search` function.
*/
export const mySearchStrategyProvider = (
data: PluginStart
): ISearchStrategy => {
const preprocessRequest = (request: IMyStrategyRequest) => {
// Custom preprocessing
- }
+ };
const formatResponse = (response: IMyStrategyResponse) => {
// Custom post-processing
- }
+ };
// Get the default search strategy
const es = data.search.getSearchStrategy(ES_SEARCH_STRATEGY);
@@ -179,16 +183,12 @@ export const mySearchStrategyProvider = (
```ts
// ./myPlugin/server/plugin.ts
-import type {
- CoreSetup,
- CoreStart,
- Plugin,
-} from 'kibana/server';
+import type { CoreSetup, CoreStart, Plugin } from 'kibana/server';
import { mySearchStrategyProvider } from './my_strategy';
/**
- * Your plugin will receive the `data` plugin contact in both the setup and start lifecycle hooks.
+ * Your plugin will receive the `data` plugin contact in both the setup and start lifecycle hooks.
*/
export interface MyPluginSetupDeps {
data: PluginSetup;
@@ -199,13 +199,10 @@ export interface MyPluginStartDeps {
}
/**
- * In your custom server side plugin, register the strategy from the setup contract
+ * In your custom server side plugin, register the strategy from the setup contract
*/
export class MyPlugin implements Plugin {
- public setup(
- core: CoreSetup,
- deps: MyPluginSetupDeps
- ) {
+ public setup(core: CoreSetup, deps: MyPluginSetupDeps) {
core.getStartServices().then(([_, depsStart]) => {
const myStrategy = mySearchStrategyProvider(depsStart.data);
deps.data.search.registerSearchStrategy('myCustomStrategy', myStrategy);
@@ -217,13 +214,15 @@ export class MyPlugin implements Plugin {
```ts
// ./myPlugin/public/plugin.ts
const req = getRequest();
-data.search.search(req, {
- strategy: 'myCustomStrategy',
-}).subscribe({
- next: (result) => {
- // handle result
- },
-});
+data.search
+ .search(req, {
+ strategy: 'myCustomStrategy',
+ })
+ .subscribe({
+ next: (result) => {
+ // handle result
+ },
+ });
```
##### Async search and custom async search strategies
@@ -234,7 +233,7 @@ This synchronous execution works great in most cases. However, with the introduc
The [async_search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html) is what drives more advanced `Kibana` `search` features, such as `partial results` and `search sessions`. [When available](https://www.elastic.co/subscriptions), the default search strategy of `Kibana` is automatically set to the **async** default search strategy (`ENHANCED_ES_SEARCH_STRATEGY`), empowering Kibana to run longer queries, with an **optional** duration restriction defined by the UI setting `search:timeout`.
-If you are implementing your own async custom search strategy, make sure to implement `cancel` and `extend`, as shown in the following example:
+If you are implementing your own async custom search strategy, make sure to implement `cancel` and `extend`, as shown in the following example:
```ts
// ./myPlugin/server/myEnhancedStrategy.ts
@@ -245,7 +244,7 @@ export const myEnhancedSearchStrategyProvider = (
const ese = data.search.getSearchStrategy(ENHANCED_ES_SEARCH_STRATEGY);
return {
search: (request, options, deps) => {
- // search will be called multiple times,
+ // search will be called multiple times,
// be sure your response formatting is capable of handling partial results, as well as the final result.
return formatResponse(ese.search(request, options, deps));
},
@@ -286,7 +285,7 @@ function searchWithSearchSource() {
.setField('query', query)
.setField('fields', selectedFields.length ? selectedFields.map((f) => f.name) : ['*'])
.setField('aggs', getAggsDsl());
-
+
searchSource.fetch$().subscribe({
next: () => {},
error: () => {},
@@ -296,7 +295,7 @@ function searchWithSearchSource() {
### Partial results
-When searching using an `async` strategy (such as async DSL and async EQL), the search service will stream back partial results.
+When searching using an `async` strategy (such as async DSL and async EQL), the search service will stream back partial results.
Although you can ignore the partial results and wait for the final result before rendering, you can also use the partial results to create a more interactive experience for your users. It is highly advised, however, to make sure users are aware that the results they are seeing are partial.
@@ -310,7 +309,7 @@ data.search.search(req).subscribe({
renderPartialResult(res);
}
},
-})
+});
// Skipping partial results
const finalResult = await data.search.search(req).toPromise();
@@ -320,31 +319,29 @@ const finalResult = await data.search.search(req).toPromise();
A search session is a higher level concept than search. A search session describes a grouping of one or more async search requests with additional context.
-Search sessions are handy when you want to enable a user to run something asynchronously (for example, a dashboard over a long period of time), and then quickly restore the results at a later time. The `Search Service` transparently fetches results from the `.async-search` index, instead of running each request again.
+Search sessions are handy when you want to enable a user to run something asynchronously (for example, a dashboard over a long period of time), and then quickly restore the results at a later time. The `Search Service` transparently fetches results from the `.async-search` index, instead of running each request again.
Internally, any search run within a search session is saved into an object, allowing Kibana to manage their lifecycle. Most saved objects are deleted automatically after a short period of time, but if a user chooses to save the search session, the saved object is persisted, so that results can be restored in a later time.
-Stored search sessions are listed in the *Management* application, under *Kibana > Search Sessions*, making it easy to find, manage, and restore them.
+Stored search sessions are listed in the _Management_ application, under _Kibana > Search Sessions_, making it easy to find, manage, and restore them.
As a developer, you might encounter these two common, use cases:
- * Running a search inside an existing search session
- * Supporting search sessions in your application
+- Running a search inside an existing search session
+- Supporting search sessions in your application
#### Running a search inside an existing search session
For this example, assume you are implementing a new type of `Embeddable` that will be shown on dashboards. The same principle applies, however, to any search requests that you are running, as long as the application you are running inside is managing an active session.
-Because the Dashboard application is already managing a search session, all you need to do is pass down the `searchSessionId` argument to any `search` call. This applies to both the low and high level search APIs.
+Because the Dashboard application is already managing a search session, all you need to do is pass down the `searchSessionId` argument to any `search` call. This applies to both the low and high level search APIs.
-The search information will be added to the saved object for the search session.
+The search information will be added to the saved object for the search session.
```ts
-export class SearchEmbeddable
- extends Embeddable {
-
+export class SearchEmbeddable extends Embeddable {
private async fetchData() {
- // Every embeddable receives an optional `searchSessionId` input parameter.
+ // Every embeddable receives an optional `searchSessionId` input parameter.
const { searchSessionId } = this.input;
// Setup your search source
@@ -355,9 +352,11 @@ export class SearchEmbeddable
this.updateOutput({ loading: true, error: undefined });
// Make the request, wait for the final result
- const {rawResponse: resp} = await searchSource.fetch$({
- sessionId: searchSessionId,
- }).toPromise();
+ const { rawResponse: resp } = await searchSource
+ .fetch$({
+ sessionId: searchSessionId,
+ })
+ .toPromise();
this.useSearchResult(resp);
@@ -368,35 +367,37 @@ export class SearchEmbeddable
}
}
}
-
-```
+```
You can also retrieve the active `Search Session ID` from the `Search Service` directly:
```ts
async function fetchData(data: DataPublicPluginStart) {
try {
- return await searchSource.fetch$({
+ return await searchSource
+ .fetch$({
sessionId: data.search.sessions.getSessionId(),
- }).toPromise();
+ })
+ .toPromise();
} catch (e) {
// handle search errors
}
}
-
```
- Search sessions are initiated by the client. If you are using a route that runs server side searches, you can send the `searchSessionId` to the server, and then pass it down to the server side `data.search` function call.
+ Search sessions are initiated by the client. If you are using a route that runs server side
+ searches, you can send the `searchSessionId` to the server, and then pass it down to the server
+ side `data.search` function call.
#### Supporting search sessions in your application
Before implementing the ability to create and restore search sessions in your application, ask yourself the following questions:
-1. **Does your application normally run long operations?** For example, it makes sense for a user to generate a Dashboard or a Canvas report from data stored in cold storage. However, when editing a single visualization, it is best to work with a shorter timeframe of hot or warm data.
+1. **Does your application normally run long operations?** For example, it makes sense for a user to generate a Dashboard or a Canvas report from data stored in cold storage. However, when editing a single visualization, it is best to work with a shorter timeframe of hot or warm data.
2. **Does it make sense for your application to restore a search session?** For example, you might want to restore an interesting configuration of filters of older documents you found in Discover. However, a single Lens or Map visualization might not be as helpful, outside the context of a specific dashboard.
-3. **What is a search session in the context of your application?** Although Discover and Dashboard start a new search session every time the time range or filters change, or when the user clicks **Refresh**, you can manage your sessions differently. For example, if your application has tabs, you might group searches from multiple tabs into a single search session. You must be able to clearly define the **state** used to create the search session`. The **state** refers to any setting that might change the queries being set to `Elasticsearch`.
+3. **What is a search session in the context of your application?** Although Discover and Dashboard start a new search session every time the time range or filters change, or when the user clicks **Refresh**, you can manage your sessions differently. For example, if your application has tabs, you might group searches from multiple tabs into a single search session. You must be able to clearly define the **state** used to create the search session`. The **state** refers to any setting that might change the queries being set to `Elasticsearch`.
Once you answer those questions, proceed to implement the following bits of code in your application.
@@ -409,8 +410,8 @@ export class MyPlugin implements Plugin {
public start(core: CoreStart, { data }: MyPluginStartDependencies) {
const sessionRestorationDataProvider: SearchSessionInfoProvider = {
data,
- getDashboard
- }
+ getDashboard,
+ };
data.search.session.enableStorage({
getName: async () => {
@@ -430,32 +431,34 @@ export class MyPlugin implements Plugin {
```
- The restore state of a search session may be different from the initial state used to create it. For example, where the initial state may contain relative dates, in the restore state, those must be converted to absolute dates. Read more about the [NowProvider]().
+ The restore state of a search session may be different from the initial state used to create it.
+ For example, where the initial state may contain relative dates, in the restore state, those must
+ be converted to absolute dates. Read more about the [NowProvider]().
- Calling `enableStorage` will also enable the `Search Session Indicator` component in the chrome component of your solution. The `Search Session Indicator` is a small button, used by default to engage users and save new search sessions. To implement your own UI, contact the Kibana application services team to decouple this behavior.
+ Calling `enableStorage` will also enable the `Search Session Indicator` component in the chrome
+ component of your solution. The `Search Session Indicator` is a small button, used by default to
+ engage users and save new search sessions. To implement your own UI, contact the Kibana
+ application services team to decouple this behavior.
-##### Start a new search session
+##### Start a new search session
-Make sure to call `start` when the **state** you previously defined changes.
+Make sure to call `start` when the **state** you previously defined changes.
```ts
-
function onSearchSessionConfigChange() {
this.searchSessionId = data.search.sessions.start();
}
-
```
-Pass the `searchSessionId` to every `search` call inside your application. If you're using `Embeddables`, pass down the `searchSessionId` as `input`.
+Pass the `searchSessionId` to every `search` call inside your application. If you're using `Embeddables`, pass down the `searchSessionId` as `input`.
If you can't pass the `searchSessionId` directly, you can retrieve it from the service.
```ts
const currentSearchSessionId = data.search.sessions.getSessionId();
-
```
##### Clear search sessions
@@ -466,19 +469,17 @@ Creating a new search session clears the previous one. You must explicitly `clea
function onDestroy() {
data.search.session.clear();
}
-
```
If you don't call `clear`, you will see a warning in the console while developing. However, when running in production, you will get a fatal error. This is done to avoid leakage of unrelated search requests into an existing search session left open by mistake.
-##### Restore search sessions
+##### Restore search sessions
-The last step of the integration is restoring an existing search session. The `searchSessionId` parameter and the rest of the restore state are passed into the application via the URL. Non-URL support is planned for future releases.
+The last step of the integration is restoring an existing search session. The `searchSessionId` parameter and the rest of the restore state are passed into the application via the URL. Non-URL support is planned for future releases.
If you detect the presense of a `searchSessionId` parameter in the URL, call the `restore` method **instead** of calling `start`. The previous example would now become:
```ts
-
function onSearchSessionConfigChange(searchSessionIdFromUrl?: string) {
if (searchSessionIdFromUrl) {
data.search.sessions.restore(searchSessionIdFromUrl);
@@ -486,7 +487,6 @@ function onSearchSessionConfigChange(searchSessionIdFromUrl?: string) {
data.search.sessions.start();
}
}
-
```
Once you `restore` the session, as long as all `search` requests run with the same `searchSessionId`, the search session should be seamlessly restored.
diff --git a/dev_docs/tutorials/debugging.mdx b/dev_docs/tutorials/debugging.mdx
index c0efd249be066..c612893e4f1f9 100644
--- a/dev_docs/tutorials/debugging.mdx
+++ b/dev_docs/tutorials/debugging.mdx
@@ -1,6 +1,6 @@
---
id: kibDevTutorialDebugging
-slug: /kibana-dev-docs/tutorial/debugging
+slug: /kibana-dev-docs/tutorials/debugging
title: Debugging in development
summary: Learn how to debug Kibana while running from source
date: 2021-04-26
@@ -27,7 +27,7 @@ You will need to run Jest directly from the Node script:
`node --inspect-brk scripts/functional_test_runner`
-### Development Server
+### Development Server
`node --inspect-brk scripts/kibana`
@@ -58,4 +58,4 @@ logging:
level: debug
- name: elasticsearch.query
level: debug
-```
\ No newline at end of file
+```
diff --git a/dev_docs/tutorials/saved_objects.mdx b/dev_docs/tutorials/saved_objects.mdx
index 35efbb97a0a03..29a0b60983d90 100644
--- a/dev_docs/tutorials/saved_objects.mdx
+++ b/dev_docs/tutorials/saved_objects.mdx
@@ -1,6 +1,6 @@
---
id: kibDevTutorialSavedObject
-slug: /kibana-dev-docs/tutorial/saved-objects
+slug: /kibana-dev-docs/tutorials/saved-objects
title: Register a new saved object type
summary: Learn how to register a new saved object type.
date: 2021-02-05
diff --git a/dev_docs/tutorials/submit_a_pull_request.mdx b/dev_docs/tutorials/submit_a_pull_request.mdx
index 2be5973bb3854..5436ebf24e03e 100644
--- a/dev_docs/tutorials/submit_a_pull_request.mdx
+++ b/dev_docs/tutorials/submit_a_pull_request.mdx
@@ -1,6 +1,6 @@
---
id: kibDevTutorialSubmitPullRequest
-slug: /kibana-dev-docs/tutorial/submit-pull-request
+slug: /kibana-dev-docs/tutorials/submit-pull-request
title: Submitting a Kibana pull request
summary: Learn how to submit a Kibana pull request
date: 2021-06-24
diff --git a/dev_docs/tutorials/testing_plugins.mdx b/dev_docs/tutorials/testing_plugins.mdx
index bc92af33d3493..14089bc3fa315 100644
--- a/dev_docs/tutorials/testing_plugins.mdx
+++ b/dev_docs/tutorials/testing_plugins.mdx
@@ -1,6 +1,6 @@
---
id: kibDevTutorialTestingPlugins
-slug: /kibana-dev-docs/tutorial/testing-plugins
+slug: /kibana-dev-docs/tutorials/testing-plugins
title: Testing Kibana Plugins
summary: Learn how to test different aspects of Kibana plugins
date: 2021-07-05
diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc
index edc1821f3b223..7f7041f7815cd 100644
--- a/docs/developer/plugin-list.asciidoc
+++ b/docs/developer/plugin-list.asciidoc
@@ -57,6 +57,12 @@ as uiSettings within the code.
|The data plugin provides common data access services, such as search and query, for solutions and application developers.
+|{kib-repo}blob/{branch}/src/plugins/data_views/README.mdx[dataViews]
+|The data views API provides a consistent method of structuring and formatting documents
+and field lists across the various Kibana apps. Its typically used in conjunction with
+ for composing queries.
+
+
|{kib-repo}blob/{branch}/src/plugins/dev_tools/README.md[devTools]
|The ui/registry/dev_tools is removed in favor of the devTools plugin which exposes a register method in the setup contract.
Registering app works mostly the same as registering apps in core.application.register.
diff --git a/examples/expressions_explorer/public/actions_and_expressions.tsx b/examples/expressions_explorer/public/actions_and_expressions.tsx
index f802a78faf06e..6d0c8886a79f3 100644
--- a/examples/expressions_explorer/public/actions_and_expressions.tsx
+++ b/examples/expressions_explorer/public/actions_and_expressions.tsx
@@ -47,11 +47,11 @@ export function ActionsExpressionsExample({ expressions, actions }: Props) {
};
const handleEvents = (event: any) => {
- if (event.id !== 'NAVIGATE') return;
+ if (event.name !== 'NAVIGATE') return;
// enrich event context with some extra data
event.baseUrl = 'http://www.google.com';
- actions.executeTriggerActions(NAVIGATE_TRIGGER_ID, event.value);
+ actions.executeTriggerActions(NAVIGATE_TRIGGER_ID, event.data);
};
return (
diff --git a/examples/expressions_explorer/public/actions_and_expressions2.tsx b/examples/expressions_explorer/public/actions_and_expressions2.tsx
index 31ba903ad91ac..e7dc28b8b97cd 100644
--- a/examples/expressions_explorer/public/actions_and_expressions2.tsx
+++ b/examples/expressions_explorer/public/actions_and_expressions2.tsx
@@ -50,7 +50,7 @@ export function ActionsExpressionsExample2({ expressions, actions }: Props) {
};
const handleEvents = (event: any) => {
- updateVariables({ color: event.value.href === 'http://www.google.com' ? 'red' : 'blue' });
+ updateVariables({ color: event.data.href === 'http://www.google.com' ? 'red' : 'blue' });
};
return (
diff --git a/examples/expressions_explorer/public/renderers/button.tsx b/examples/expressions_explorer/public/renderers/button.tsx
index 68add91c3cbc9..557180ab73a35 100644
--- a/examples/expressions_explorer/public/renderers/button.tsx
+++ b/examples/expressions_explorer/public/renderers/button.tsx
@@ -18,8 +18,8 @@ export const buttonRenderer: ExpressionRenderDefinition = {
render(domNode, config, handlers) {
const buttonClick = () => {
handlers.event({
- id: 'NAVIGATE',
- value: {
+ name: 'NAVIGATE',
+ data: {
href: config.href,
},
});
diff --git a/legacy_rfcs/README.md b/legacy_rfcs/README.md
index f9f9502ad954b..4ef4db56c004f 100644
--- a/legacy_rfcs/README.md
+++ b/legacy_rfcs/README.md
@@ -1,3 +1,3 @@
# Kibana RFCs
-We no longer follow this RFC process. Internal developers should review the new RFC process in our [internal developer guide](https://docs.elastic.dev/kibana-team/rfc-process)
+We no longer follow this RFC process. Internal developers should review the new RFC process in our [internal developer guide](https://docs.elastic.dev/kibana-dev-docs/contributing/rfc-process)
diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml
index 8fb31b36f39d5..a0ca88e4e04bd 100644
--- a/packages/kbn-optimizer/limits.yml
+++ b/packages/kbn-optimizer/limits.yml
@@ -116,3 +116,4 @@ pageLoadAssetSize:
expressions: 239290
securitySolution: 231753
customIntegrations: 28810
+ dataViews: 42000
diff --git a/src/dev/eslint/lint_files.ts b/src/dev/eslint/lint_files.ts
index 77fe941fb7aeb..5c6118edeb2ec 100644
--- a/src/dev/eslint/lint_files.ts
+++ b/src/dev/eslint/lint_files.ts
@@ -12,41 +12,6 @@ import { REPO_ROOT } from '@kbn/utils';
import { createFailError, ToolingLog } from '@kbn/dev-utils';
import { File } from '../file';
-// For files living on the filesystem
-function lintFilesOnFS(cli: CLIEngine, files: File[]) {
- const paths = files.map((file) => file.getRelativePath());
- return cli.executeOnFiles(paths);
-}
-
-// For files living somewhere else (ie. git object)
-async function lintFilesOnContent(cli: CLIEngine, files: File[]) {
- const report: CLIEngine.LintReport = {
- results: [],
- errorCount: 0,
- warningCount: 0,
- fixableErrorCount: 0,
- fixableWarningCount: 0,
- usedDeprecatedRules: [],
- };
-
- for (let i = 0; i < files.length; i++) {
- const r = cli.executeOnText(await files[i].getContent(), files[i].getRelativePath());
- // Despite a relative path was given, the result would contain an absolute one. Work around it.
- r.results[0].filePath = r.results[0].filePath.replace(
- files[i].getAbsolutePath(),
- files[i].getRelativePath()
- );
- report.results.push(...r.results);
- report.errorCount += r.errorCount;
- report.warningCount += r.warningCount;
- report.fixableErrorCount += r.fixableErrorCount;
- report.fixableWarningCount += r.fixableWarningCount;
- report.usedDeprecatedRules.push(...r.usedDeprecatedRules);
- }
-
- return report;
-}
-
/**
* Lints a list of files with eslint. eslint reports are written to the log
* and a FailError is thrown when linting errors occur.
@@ -55,16 +20,15 @@ async function lintFilesOnContent(cli: CLIEngine, files: File[]) {
* @param {Array} files
* @return {undefined}
*/
-export async function lintFiles(log: ToolingLog, files: File[], { fix }: { fix?: boolean } = {}) {
+export function lintFiles(log: ToolingLog, files: File[], { fix }: { fix?: boolean } = {}) {
const cli = new CLIEngine({
cache: true,
cwd: REPO_ROOT,
fix,
});
- const virtualFilesCount = files.filter((file) => file.isVirtual()).length;
- const report =
- virtualFilesCount && !fix ? await lintFilesOnContent(cli, files) : lintFilesOnFS(cli, files);
+ const paths = files.map((file) => file.getRelativePath());
+ const report = cli.executeOnFiles(paths);
if (fix) {
CLIEngine.outputFixes(report);
diff --git a/src/dev/file.ts b/src/dev/file.ts
index 01005b257a403..b532a7bb70602 100644
--- a/src/dev/file.ts
+++ b/src/dev/file.ts
@@ -7,13 +7,11 @@
*/
import { dirname, extname, join, relative, resolve, sep, basename } from 'path';
-import { createFailError } from '@kbn/dev-utils';
export class File {
private path: string;
private relativePath: string;
private ext: string;
- private fileReader: undefined | (() => Promise);
constructor(path: string) {
this.path = resolve(path);
@@ -57,11 +55,6 @@ export class File {
);
}
- // Virtual files cannot be read as usual, an helper is needed
- public isVirtual() {
- return this.fileReader !== undefined;
- }
-
public getRelativeParentDirs() {
const parents: string[] = [];
@@ -88,15 +81,4 @@ export class File {
public toJSON() {
return this.relativePath;
}
-
- public setFileReader(fileReader: () => Promise) {
- this.fileReader = fileReader;
- }
-
- public getContent() {
- if (this.fileReader) {
- return this.fileReader();
- }
- throw createFailError('getContent() was invoked on a non-virtual File');
- }
}
diff --git a/src/dev/precommit_hook/get_files_for_commit.js b/src/dev/precommit_hook/get_files_for_commit.js
index 52dfab49c5c64..44c8c9d5e6bc0 100644
--- a/src/dev/precommit_hook/get_files_for_commit.js
+++ b/src/dev/precommit_hook/get_files_for_commit.js
@@ -6,65 +6,12 @@
* Side Public License, v 1.
*/
-import { format } from 'util';
import SimpleGit from 'simple-git';
import { fromNode as fcb } from 'bluebird';
import { REPO_ROOT } from '@kbn/utils';
import { File } from '../file';
-/**
- * Return the `git diff` argument used for building the list of files
- *
- * @param {String} gitRef
- * @return {String}
- *
- * gitRef return
- * '' '--cached'
- * '' '~1..'
- * '..' '..'
- * '...' '...'
- * '..' '..'
- * '...' '...'
- * '..' '..'
- * '...' '...'
- */
-function getRefForDiff(gitRef) {
- if (!gitRef) {
- return '--cached';
- } else if (gitRef.includes('..')) {
- return gitRef;
- } else {
- return format('%s~1..%s', gitRef, gitRef);
- }
-}
-
-/**
- * Return the used for reading files content
- *
- * @param {String} gitRef
- * @return {String}
- *
- * gitRef return
- * '' ''
- * '' ''
- * '..' 'HEAD'
- * '...' 'HEAD'
- * '..' ''
- * '...' ''
- * '..' ''
- * '...' ''
- */
-function getRefForCat(gitRef) {
- if (!gitRef) {
- return '';
- } else if (gitRef.includes('..')) {
- return gitRef.endsWith('..') ? 'HEAD' : gitRef.slice(gitRef.lastIndexOf('..') + 2);
- } else {
- return gitRef;
- }
-}
-
/**
* Get the files that are staged for commit (excluding deleted files)
* as `File` objects that are aware of their commit status.
@@ -74,23 +21,29 @@ function getRefForCat(gitRef) {
*/
export async function getFilesForCommit(gitRef) {
const simpleGit = new SimpleGit(REPO_ROOT);
- const gitRefForDiff = getRefForDiff(gitRef);
- const gitRefForCat = getRefForCat(gitRef);
-
- const output = await fcb((cb) => {
- simpleGit.diff(['--diff-filter=d', '--name-only', gitRefForDiff], cb);
- });
+ const gitRefForDiff = gitRef ? gitRef : '--cached';
+ const output = await fcb((cb) => simpleGit.diff(['--name-status', gitRefForDiff], cb));
return (
output
.split('\n')
// Ignore blank lines
.filter((line) => line.trim().length > 0)
- .map((path) => {
- const file = new File(path);
- const object = format('%s:%s', gitRefForCat, path);
- file.setFileReader(() => fcb((cb) => simpleGit.catFile(['-p', object], cb)));
- return file;
+ // git diff --name-status outputs lines with two OR three parts
+ // separated by a tab character
+ .map((line) => line.trim().split('\t'))
+ .map(([status, ...paths]) => {
+ // ignore deleted files
+ if (status === 'D') {
+ return undefined;
+ }
+
+ // the status is always in the first column
+ // .. If the file is edited the line will only have two columns
+ // .. If the file is renamed it will have three columns
+ // .. In any case, the last column is the CURRENT path to the file
+ return new File(paths[paths.length - 1]);
})
+ .filter(Boolean)
);
}
diff --git a/src/dev/run_precommit_hook.js b/src/dev/run_precommit_hook.js
index e1eafaf28d95d..a7bd0a9f57f6e 100644
--- a/src/dev/run_precommit_hook.js
+++ b/src/dev/run_precommit_hook.js
@@ -6,7 +6,9 @@
* Side Public License, v 1.
*/
-import { run, combineErrors, createFlagError, createFailError } from '@kbn/dev-utils';
+import SimpleGit from 'simple-git/promise';
+
+import { run, combineErrors, createFlagError, REPO_ROOT } from '@kbn/dev-utils';
import * as Eslint from './eslint';
import * as Stylelint from './stylelint';
import { getFilesForCommit, checkFileCasing } from './precommit_hook';
@@ -23,11 +25,6 @@ run(
throw createFlagError('expected --max-files to be a number greater than 0');
}
- const virtualFilesCount = files.filter((file) => file.isVirtual()).length;
- if (virtualFilesCount > 0 && virtualFilesCount < files.length) {
- throw createFailError('Mixing of virtual and on-filesystem files is unsupported');
- }
-
if (maxFilesCount && files.length > maxFilesCount) {
log.warning(
`--max-files is set to ${maxFilesCount} and ${files.length} were discovered. The current script execution will be skipped.`
@@ -48,6 +45,11 @@ run(
await Linter.lintFiles(log, filesToLint, {
fix: flags.fix,
});
+
+ if (flags.fix) {
+ const simpleGit = new SimpleGit(REPO_ROOT);
+ await simpleGit.add(filesToLint);
+ }
} catch (error) {
errors.push(error);
}
@@ -71,11 +73,7 @@ run(
help: `
--fix Execute eslint in --fix mode
--max-files Max files number to check against. If exceeded the script will skip the execution
- --ref Run checks against git ref files instead of running against staged ones
- Examples:
- HEAD~1..HEAD files changed in the commit at HEAD
- HEAD equivalent to HEAD~1..HEAD
- main... files changed in current branch since the common ancestor with main
+ --ref Run checks against any git ref files (example HEAD or ) instead of running against staged ones
`,
},
}
diff --git a/src/dev/stylelint/lint_files.js b/src/dev/stylelint/lint_files.js
index 1ebc981728814..6e62c85d44ae8 100644
--- a/src/dev/stylelint/lint_files.js
+++ b/src/dev/stylelint/lint_files.js
@@ -16,51 +16,6 @@ import { createFailError } from '@kbn/dev-utils';
const stylelintPath = path.resolve(__dirname, '..', '..', '..', '.stylelintrc');
const styleLintConfig = safeLoad(fs.readFileSync(stylelintPath));
-// For files living on the filesystem
-function lintFilesOnFS(files) {
- const paths = files.map((file) => file.getRelativePath());
-
- const options = {
- files: paths,
- config: styleLintConfig,
- formatter: 'string',
- ignorePath: path.resolve(__dirname, '..', '..', '..', '.stylelintignore'),
- };
-
- return stylelint.lint(options);
-}
-
-// For files living somewhere else (ie. git object)
-async function lintFilesOnContent(files) {
- const report = {
- errored: false,
- output: '',
- postcssResults: [],
- results: [],
- maxWarningsExceeded: {
- maxWarnings: 0,
- foundWarnings: 0,
- },
- };
-
- for (let i = 0; i < files.length; i++) {
- const options = {
- code: await files[i].getContent(),
- config: styleLintConfig,
- formatter: 'string',
- ignorePath: path.resolve(__dirname, '..', '..', '..', '.stylelintignore'),
- };
- const r = await stylelint.lint(options);
- report.errored = report.errored || r.errored;
- report.output += r.output.replace(//, files[i].getRelativePath()).slice(0, -1);
- report.postcssResults.push(...(r.postcssResults || []));
- report.maxWarnings = r.maxWarnings;
- report.foundWarnings += r.foundWarnings;
- }
-
- return report;
-}
-
/**
* Lints a list of files with eslint. eslint reports are written to the log
* and a FailError is thrown when linting errors occur.
@@ -70,9 +25,16 @@ async function lintFilesOnContent(files) {
* @return {undefined}
*/
export async function lintFiles(log, files) {
- const virtualFilesCount = files.filter((file) => file.isVirtual()).length;
- const report = virtualFilesCount ? await lintFilesOnContent(files) : await lintFilesOnFS(files);
+ const paths = files.map((file) => file.getRelativePath());
+
+ const options = {
+ files: paths,
+ config: styleLintConfig,
+ formatter: 'string',
+ ignorePath: path.resolve(__dirname, '..', '..', '..', '.stylelintignore'),
+ };
+ const report = await stylelint.lint(options);
if (report.errored) {
log.error(report.output);
throw createFailError('[stylelint] errors');
diff --git a/src/plugins/chart_expressions/expression_tagcloud/common/expression_functions/tagcloud_function.test.ts b/src/plugins/chart_expressions/expression_tagcloud/common/expression_functions/tagcloud_function.test.ts
index 8abdc36704b45..86a371afd6912 100644
--- a/src/plugins/chart_expressions/expression_tagcloud/common/expression_functions/tagcloud_function.test.ts
+++ b/src/plugins/chart_expressions/expression_tagcloud/common/expression_functions/tagcloud_function.test.ts
@@ -12,6 +12,8 @@ import { functionWrapper } from '../../../../expressions/common/expression_funct
import { ExpressionValueVisDimension } from '../../../../visualizations/public';
import { Datatable } from '../../../../expressions/common/expression_types/specs';
+type Arguments = Parameters['fn']>[1];
+
describe('interpreter/functions#tagcloud', () => {
const fn = functionWrapper(tagcloudFunction());
const column1 = 'Count';
@@ -26,7 +28,7 @@ describe('interpreter/functions#tagcloud', () => {
{ [column1]: 0, [column2]: 'US' },
{ [column1]: 10, [column2]: 'UK' },
],
- };
+ } as unknown as Datatable;
const visConfig = {
scale: 'linear',
orientation: 'single',
@@ -73,12 +75,12 @@ describe('interpreter/functions#tagcloud', () => {
};
it('returns an object with the correct structure for number accessors', () => {
- const actual = fn(context, { ...visConfig, ...numberAccessors }, undefined);
+ const actual = fn(context, { ...visConfig, ...numberAccessors } as Arguments, undefined);
expect(actual).toMatchSnapshot();
});
it('returns an object with the correct structure for string accessors', () => {
- const actual = fn(context, { ...visConfig, ...stringAccessors }, undefined);
+ const actual = fn(context, { ...visConfig, ...stringAccessors } as Arguments, undefined);
expect(actual).toMatchSnapshot();
});
@@ -93,7 +95,7 @@ describe('interpreter/functions#tagcloud', () => {
},
},
};
- await fn(context, { ...visConfig, ...numberAccessors }, handlers as any);
+ await fn(context, { ...visConfig, ...numberAccessors } as Arguments, handlers as any);
expect(loggedTable!).toMatchSnapshot();
});
diff --git a/src/plugins/data/README.mdx b/src/plugins/data/README.mdx
index 40e82d3034ee2..e24a949a0c2ec 100644
--- a/src/plugins/data/README.mdx
+++ b/src/plugins/data/README.mdx
@@ -1,6 +1,6 @@
---
id: kibDataPlugin
-slug: /kibana-dev-docs/services/data-plugin
+slug: /kibana-dev-docs/key-concepts/data-plugin
title: Data services
image: https://source.unsplash.com/400x175/?Search
summary: The data plugin contains services for searching, querying and filtering.
@@ -49,15 +49,6 @@ This is helpful when you want to provide a user with options, for example when c
```
-## Data Views
-
-The data views API provides a consistent method of structuring and formatting documents
-and field lists across the various Kibana apps. Its typically used in conjunction with
- for composing queries.
-
-*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*
-
-
## Query
The query service is responsible for managing the configuration of a search query (`QueryState`): filters, time range, query string, and settings such as the auto refresh behavior and saved queries.
diff --git a/src/plugins/data/common/constants.ts b/src/plugins/data/common/constants.ts
index 2c339d1408237..c236be18a8e41 100644
--- a/src/plugins/data/common/constants.ts
+++ b/src/plugins/data/common/constants.ts
@@ -9,15 +9,6 @@
export const DEFAULT_QUERY_LANGUAGE = 'kuery';
export const KIBANA_USER_QUERY_LANGUAGE_KEY = 'kibana.userQueryLanguage';
-/** @public **/
-export const DATA_VIEW_SAVED_OBJECT_TYPE = 'index-pattern';
-
-/**
- * @deprecated Use DATA_VIEW_SAVED_OBJECT_TYPE. All index pattern interfaces were renamed.
- */
-
-export const INDEX_PATTERN_SAVED_OBJECT_TYPE = DATA_VIEW_SAVED_OBJECT_TYPE;
-
export type ValueSuggestionsMethod = 'terms_enum' | 'terms_agg';
export const UI_SETTINGS = {
diff --git a/src/plugins/data/common/data_views/index.ts b/src/plugins/data/common/data_views/index.ts
deleted file mode 100644
index fd1df0336815a..0000000000000
--- a/src/plugins/data/common/data_views/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-export * from './constants';
-export * from './fields';
-export * from './types';
-export {
- IndexPatternsService,
- IndexPatternsContract,
- DataViewsService,
- DataViewsContract,
-} from './data_views';
-// todo was trying to export this as type but wasn't working
-export { IndexPattern, IndexPatternListItem, DataView, DataViewListItem } from './data_views';
-export * from './errors';
-export * from './expressions';
diff --git a/src/plugins/data/common/index.ts b/src/plugins/data/common/index.ts
index 8a9a93f96b68b..195cb9d475314 100644
--- a/src/plugins/data/common/index.ts
+++ b/src/plugins/data/common/index.ts
@@ -11,18 +11,68 @@
export * from './constants';
export * from './es_query';
-export * from './data_views';
export * from './kbn_field_types';
export * from './query';
export * from './search';
export * from './types';
-export * from './utils';
export * from './exports';
-
-/**
- *
- * @deprecated Use data plugin interface instead
- * @removeBy 8.1
- */
-
-export { IndexPatternAttributes } from './types';
+export type {
+ IFieldType,
+ IIndexPatternFieldList,
+ FieldFormatMap,
+ RuntimeType,
+ RuntimeField,
+ IIndexPattern,
+ DataViewAttributes,
+ IndexPatternAttributes,
+ FieldAttrs,
+ FieldAttrSet,
+ OnNotification,
+ OnError,
+ UiSettingsCommon,
+ SavedObjectsClientCommonFindArgs,
+ SavedObjectsClientCommon,
+ GetFieldsOptions,
+ GetFieldsOptionsTimePattern,
+ IDataViewsApiClient,
+ IIndexPatternsApiClient,
+ SavedObject,
+ AggregationRestrictions,
+ TypeMeta,
+ FieldSpecConflictDescriptions,
+ FieldSpecExportFmt,
+ FieldSpec,
+ DataViewFieldMap,
+ IndexPatternFieldMap,
+ DataViewSpec,
+ IndexPatternSpec,
+ SourceFilter,
+ IndexPatternExpressionType,
+ IndexPatternLoadStartDependencies,
+ IndexPatternLoadExpressionFunctionDefinition,
+} from '../../data_views/common';
+export {
+ RUNTIME_FIELD_TYPES,
+ FLEET_ASSETS_TO_IGNORE,
+ META_FIELDS,
+ DATA_VIEW_SAVED_OBJECT_TYPE,
+ INDEX_PATTERN_SAVED_OBJECT_TYPE,
+ isFilterable,
+ isNestedField,
+ fieldList,
+ DataViewField,
+ IndexPatternField,
+ DataViewType,
+ IndexPatternType,
+ IndexPatternsService,
+ IndexPatternsContract,
+ DataViewsService,
+ DataViewsContract,
+ IndexPattern,
+ IndexPatternListItem,
+ DataView,
+ DataViewListItem,
+ DuplicateDataViewError,
+ DataViewSavedObjectConflictError,
+ getIndexPatternLoadMeta,
+} from '../../data_views/common';
diff --git a/src/plugins/data/common/mocks.ts b/src/plugins/data/common/mocks.ts
index 66ad3b695d24c..c656d9d21346e 100644
--- a/src/plugins/data/common/mocks.ts
+++ b/src/plugins/data/common/mocks.ts
@@ -6,4 +6,4 @@
* Side Public License, v 1.
*/
-export * from './data_views/fields/fields.mocks';
+export * from '../../data_views/common/fields/fields.mocks';
diff --git a/src/plugins/data/common/search/aggs/param_types/field.ts b/src/plugins/data/common/search/aggs/param_types/field.ts
index e1c872ac16701..05e1302475d04 100644
--- a/src/plugins/data/common/search/aggs/param_types/field.ts
+++ b/src/plugins/data/common/search/aggs/param_types/field.ts
@@ -15,7 +15,7 @@ import {
import { BaseParamType } from './base';
import { propFilter } from '../utils';
import { KBN_FIELD_TYPES } from '../../../kbn_field_types/types';
-import { isNestedField, IndexPatternField } from '../../../data_views/fields';
+import { isNestedField, IndexPatternField } from '../../../../../data_views/common';
const filterByType = propFilter('type');
diff --git a/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts b/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts
index a9078d6042db8..09d68177c3ec3 100644
--- a/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts
+++ b/src/plugins/data/common/search/expressions/esaggs/esaggs_fn.ts
@@ -12,7 +12,7 @@ import { Observable } from 'rxjs';
import type { Datatable, ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { buildExpressionFunction } from '../../../../../../plugins/expressions/common';
-import { IndexPatternExpressionType } from '../../../data_views/expressions';
+import { IndexPatternExpressionType } from '../../../../../data_views/common/expressions';
import { IndexPatternsContract } from '../../..';
import { AggsStart, AggExpressionType, aggCountFnName } from '../../aggs';
diff --git a/src/plugins/data/common/search/search_source/extract_references.ts b/src/plugins/data/common/search/search_source/extract_references.ts
index c7f6c53d0f5f7..dfcd1b12cb62f 100644
--- a/src/plugins/data/common/search/search_source/extract_references.ts
+++ b/src/plugins/data/common/search/search_source/extract_references.ts
@@ -10,7 +10,7 @@ import { SavedObjectReference } from 'src/core/types';
import { Filter } from '@kbn/es-query';
import { SearchSourceFields } from './types';
-import { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../../constants';
+import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../../../data/common';
export const extractReferences = (
state: SearchSourceFields
@@ -22,7 +22,7 @@ export const extractReferences = (
const refName = 'kibanaSavedObjectMeta.searchSourceJSON.index';
references.push({
name: refName,
- type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
+ type: DATA_VIEW_SAVED_OBJECT_TYPE,
id: indexId,
});
searchSourceFields = {
@@ -42,7 +42,7 @@ export const extractReferences = (
const refName = `kibanaSavedObjectMeta.searchSourceJSON.filter[${i}].meta.index`;
references.push({
name: refName,
- type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
+ type: DATA_VIEW_SAVED_OBJECT_TYPE,
id: filterRow.meta.index,
});
return {
diff --git a/src/plugins/data/common/stubs.ts b/src/plugins/data/common/stubs.ts
index 5cddcf397f442..ec53b20f6ff3d 100644
--- a/src/plugins/data/common/stubs.ts
+++ b/src/plugins/data/common/stubs.ts
@@ -6,6 +6,6 @@
* Side Public License, v 1.
*/
-export * from './data_views/field.stub';
-export * from './data_views/data_view.stub';
+export * from '../../data_views/common/field.stub';
+export * from '../../data_views/common/data_view.stub';
export * from './es_query/stubs';
diff --git a/src/plugins/data/common/types.ts b/src/plugins/data/common/types.ts
index c574d4854cfd6..81b47735d8fe2 100644
--- a/src/plugins/data/common/types.ts
+++ b/src/plugins/data/common/types.ts
@@ -8,7 +8,6 @@
export * from './query/types';
export * from './kbn_field_types/types';
-export * from './data_views/types';
/**
* If a service is being shared on both the client and the server, and
diff --git a/src/plugins/data/kibana.json b/src/plugins/data/kibana.json
index c21955501787d..3d70d138d80ed 100644
--- a/src/plugins/data/kibana.json
+++ b/src/plugins/data/kibana.json
@@ -3,8 +3,8 @@
"version": "kibana",
"server": true,
"ui": true,
- "requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats"],
- "serviceFolders": ["search", "data_views", "query", "autocomplete", "ui"],
+ "requiredPlugins": ["bfetch", "expressions", "uiActions", "share", "inspector", "fieldFormats", "dataViews"],
+ "serviceFolders": ["search", "query", "autocomplete", "ui"],
"optionalPlugins": ["usageCollection"],
"extraPublicDirs": ["common"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"],
diff --git a/src/plugins/data/public/data_views/index.ts b/src/plugins/data/public/data_views/index.ts
index 0125b173989fb..4fb2bbaf08503 100644
--- a/src/plugins/data/public/data_views/index.ts
+++ b/src/plugins/data/public/data_views/index.ts
@@ -6,25 +6,4 @@
* Side Public License, v 1.
*/
-export {
- ILLEGAL_CHARACTERS_KEY,
- CONTAINS_SPACES_KEY,
- ILLEGAL_CHARACTERS_VISIBLE,
- ILLEGAL_CHARACTERS,
- validateDataView,
-} from '../../common/data_views/lib';
-export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './data_views';
-
-export { IndexPatternField, IIndexPatternFieldList, TypeMeta } from '../../common/data_views';
-
-export {
- IndexPatternsService,
- IndexPatternsContract,
- IndexPattern,
- DataViewsApiClient,
- DataViewsService,
- DataViewsContract,
- DataView,
-} from './data_views';
-export { UiSettingsPublicToCommon } from './ui_settings_wrapper';
-export { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
+export * from '../../../data_views/public';
diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts
index e1f5b98baca9c..4b6d184f807a4 100644
--- a/src/plugins/data/public/index.ts
+++ b/src/plugins/data/public/index.ts
@@ -83,14 +83,12 @@ export {
IndexPatternLoadExpressionFunctionDefinition,
fieldList,
GetFieldsOptions,
- INDEX_PATTERN_SAVED_OBJECT_TYPE,
AggregationRestrictions,
IndexPatternType,
IndexPatternListItem,
+ DuplicateDataViewError,
} from '../common';
-export { DuplicateDataViewError } from '../common/data_views/errors';
-
/*
* Autocomplete query suggestions:
*/
diff --git a/src/plugins/data/public/plugin.ts b/src/plugins/data/public/plugin.ts
index aa766f78a5ecb..4a55cc2a0d511 100644
--- a/src/plugins/data/public/plugin.ts
+++ b/src/plugins/data/public/plugin.ts
@@ -21,12 +21,6 @@ import { AutocompleteService } from './autocomplete';
import { SearchService } from './search/search_service';
import { QueryService } from './query';
import { createIndexPatternSelect } from './ui/index_pattern_select';
-import {
- DataViewsService,
- onRedirectNoIndexPattern,
- DataViewsApiClient,
- UiSettingsPublicToCommon,
-} from './data_views';
import {
setIndexPatterns,
setNotifications,
@@ -44,8 +38,6 @@ import {
createSelectRangeAction,
} from './actions';
import { APPLY_FILTER_TRIGGER, applyFilterTrigger } from './triggers';
-import { SavedObjectsClientPublicToCommon } from './data_views';
-import { getIndexPatternLoad } from './data_views/expressions';
import { UsageCollectionSetup } from '../../usage_collection/public';
import { getTableViewDescription } from './utils/table_inspector_view';
import { NowProvider, NowProviderInternalContract } from './now_provider';
@@ -89,8 +81,6 @@ export class DataPublicPlugin
): DataPublicPluginSetup {
const startServices = createStartServicesGetter(core.getStartServices);
- expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
-
this.usageCollection = usageCollection;
const searchService = this.searchService.setup(core, {
@@ -138,29 +128,13 @@ export class DataPublicPlugin
public start(
core: CoreStart,
- { uiActions, fieldFormats }: DataStartDependencies
+ { uiActions, fieldFormats, dataViews }: DataStartDependencies
): DataPublicPluginStart {
- const { uiSettings, http, notifications, savedObjects, overlays, application } = core;
+ const { uiSettings, notifications, savedObjects, overlays } = core;
setNotifications(notifications);
setOverlays(overlays);
setUiSettings(uiSettings);
-
- const indexPatterns = new DataViewsService({
- uiSettings: new UiSettingsPublicToCommon(uiSettings),
- savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client),
- apiClient: new DataViewsApiClient(http),
- fieldFormats,
- onNotification: (toastInputFields) => {
- notifications.toasts.add(toastInputFields);
- },
- onError: notifications.toasts.addError.bind(notifications.toasts),
- onRedirectNoIndexPattern: onRedirectNoIndexPattern(
- application.capabilities,
- application.navigateToApp,
- overlays
- ),
- });
- setIndexPatterns(indexPatterns);
+ setIndexPatterns(dataViews);
const query = this.queryService.start({
storage: this.storage,
@@ -168,7 +142,7 @@ export class DataPublicPlugin
uiSettings,
});
- const search = this.searchService.start(core, { fieldFormats, indexPatterns });
+ const search = this.searchService.start(core, { fieldFormats, indexPatterns: dataViews });
setSearchService(search);
uiActions.addTriggerAction(
@@ -197,8 +171,8 @@ export class DataPublicPlugin
},
autocomplete: this.autocomplete.start(),
fieldFormats,
- indexPatterns,
- dataViews: indexPatterns,
+ indexPatterns: dataViews,
+ dataViews,
query,
search,
nowProvider: this.nowProvider,
@@ -214,7 +188,7 @@ export class DataPublicPlugin
return {
...dataServices,
ui: {
- IndexPatternSelect: createIndexPatternSelect(indexPatterns),
+ IndexPatternSelect: createIndexPatternSelect(dataViews),
SearchBar,
},
};
diff --git a/src/plugins/data/public/stubs.ts b/src/plugins/data/public/stubs.ts
index 3d160a56bd8cf..b81d9c4cc78e4 100644
--- a/src/plugins/data/public/stubs.ts
+++ b/src/plugins/data/public/stubs.ts
@@ -7,4 +7,5 @@
*/
export * from '../common/stubs';
-export { createStubDataView } from './data_views/data_views/data_view.stub';
+// eslint-disable-next-line
+export { createStubDataView } from '../../data_views/public/data_views/data_view.stub';
diff --git a/src/plugins/data/public/types.ts b/src/plugins/data/public/types.ts
index 7ed13c2096515..9b16ee39f5c80 100644
--- a/src/plugins/data/public/types.ts
+++ b/src/plugins/data/public/types.ts
@@ -11,6 +11,7 @@ import { CoreStart } from 'src/core/public';
import { BfetchPublicSetup } from 'src/plugins/bfetch/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
+import { DataViewsPublicPluginStart } from 'src/plugins/data_views/public';
import { UiActionsSetup, UiActionsStart } from 'src/plugins/ui_actions/public';
import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/public';
import { AutocompleteSetup, AutocompleteStart } from './autocomplete';
@@ -35,6 +36,7 @@ export interface DataSetupDependencies {
export interface DataStartDependencies {
uiActions: UiActionsStart;
fieldFormats: FieldFormatsStart;
+ dataViews: DataViewsPublicPluginStart;
}
/**
diff --git a/src/plugins/data/server/data_views/index.ts b/src/plugins/data/server/data_views/index.ts
index 7226d6f015cf8..91a61f4bcb7db 100644
--- a/src/plugins/data/server/data_views/index.ts
+++ b/src/plugins/data/server/data_views/index.ts
@@ -6,12 +6,4 @@
* Side Public License, v 1.
*/
-export * from './utils';
-export {
- IndexPatternsFetcher,
- FieldDescriptor,
- shouldReadFieldFromDocValues,
- mergeCapabilitiesWithFields,
- getCapabilitiesForRollupIndices,
-} from './fetcher';
-export { IndexPatternsServiceProvider, IndexPatternsServiceStart } from './index_patterns_service';
+export * from '../../../data_views/server';
diff --git a/src/plugins/data/server/data_views/index_patterns_service.ts b/src/plugins/data/server/data_views/index_patterns_service.ts
deleted file mode 100644
index 5286d1d64794b..0000000000000
--- a/src/plugins/data/server/data_views/index_patterns_service.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-import {
- CoreSetup,
- CoreStart,
- Plugin,
- Logger,
- SavedObjectsClientContract,
- ElasticsearchClient,
- UiSettingsServiceStart,
-} from 'kibana/server';
-import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
-import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
-import { DataPluginStart } from '../plugin';
-import { registerRoutes } from './routes';
-import { indexPatternSavedObjectType } from '../saved_objects';
-import { capabilitiesProvider } from './capabilities_provider';
-import { IndexPatternsCommonService } from '../';
-import { FieldFormatsStart } from '../../../field_formats/server';
-import { getIndexPatternLoad } from './expressions';
-import { UiSettingsServerToCommon } from './ui_settings_wrapper';
-import { IndexPatternsApiServer } from './index_patterns_api_client';
-import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper';
-import { registerIndexPatternsUsageCollector } from './register_index_pattern_usage_collection';
-import { createScriptedFieldsDeprecationsConfig } from './deprecations';
-
-export interface IndexPatternsServiceStart {
- indexPatternsServiceFactory: (
- savedObjectsClient: SavedObjectsClientContract,
- elasticsearchClient: ElasticsearchClient
- ) => Promise;
-}
-
-export interface IndexPatternsServiceSetupDeps {
- expressions: ExpressionsServerSetup;
- logger: Logger;
- usageCollection?: UsageCollectionSetup;
-}
-
-export interface IndexPatternsServiceStartDeps {
- fieldFormats: FieldFormatsStart;
- logger: Logger;
-}
-
-export const indexPatternsServiceFactory =
- ({
- logger,
- uiSettings,
- fieldFormats,
- }: {
- logger: Logger;
- uiSettings: UiSettingsServiceStart;
- fieldFormats: FieldFormatsStart;
- }) =>
- async (
- savedObjectsClient: SavedObjectsClientContract,
- elasticsearchClient: ElasticsearchClient
- ) => {
- const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
- const formats = await fieldFormats.fieldFormatServiceFactory(uiSettingsClient);
-
- return new IndexPatternsCommonService({
- uiSettings: new UiSettingsServerToCommon(uiSettingsClient),
- savedObjectsClient: new SavedObjectsClientServerToCommon(savedObjectsClient),
- apiClient: new IndexPatternsApiServer(elasticsearchClient, savedObjectsClient),
- fieldFormats: formats,
- onError: (error) => {
- logger.error(error);
- },
- onNotification: ({ title, text }) => {
- logger.warn(`${title}${text ? ` : ${text}` : ''}`);
- },
- });
- };
-
-export class IndexPatternsServiceProvider implements Plugin {
- public setup(
- core: CoreSetup,
- { expressions, usageCollection }: IndexPatternsServiceSetupDeps
- ) {
- core.savedObjects.registerType(indexPatternSavedObjectType);
- core.capabilities.registerProvider(capabilitiesProvider);
-
- registerRoutes(core.http, core.getStartServices);
-
- expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
- registerIndexPatternsUsageCollector(core.getStartServices, usageCollection);
- core.deprecations.registerDeprecations(createScriptedFieldsDeprecationsConfig(core));
- }
-
- public start(core: CoreStart, { fieldFormats, logger }: IndexPatternsServiceStartDeps) {
- const { uiSettings } = core;
-
- return {
- indexPatternsServiceFactory: indexPatternsServiceFactory({
- logger,
- uiSettings,
- fieldFormats,
- }),
- };
- }
-}
diff --git a/src/plugins/data/server/data_views/mocks.ts b/src/plugins/data/server/data_views/mocks.ts
index 6435c09cb7ec9..69b57ed079127 100644
--- a/src/plugins/data/server/data_views/mocks.ts
+++ b/src/plugins/data/server/data_views/mocks.ts
@@ -6,8 +6,4 @@
* Side Public License, v 1.
*/
-export function createIndexPatternsStartMock() {
- return {
- indexPatternsServiceFactory: jest.fn().mockResolvedValue({ get: jest.fn() }),
- };
-}
+export * from '../../../data_views/server/mocks';
diff --git a/src/plugins/data/server/index.ts b/src/plugins/data/server/index.ts
index a17c66c694b2d..fce73e65dc699 100644
--- a/src/plugins/data/server/index.ts
+++ b/src/plugins/data/server/index.ts
@@ -30,7 +30,7 @@ export const exporters = {
* Field Formats:
*/
-export { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../common';
+export { DATA_VIEW_SAVED_OBJECT_TYPE } from '../common';
/*
* Index patterns:
diff --git a/src/plugins/data/server/plugin.ts b/src/plugins/data/server/plugin.ts
index 3342519782d7a..cb52500e78f94 100644
--- a/src/plugins/data/server/plugin.ts
+++ b/src/plugins/data/server/plugin.ts
@@ -9,8 +9,8 @@
import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
import { BfetchServerSetup } from 'src/plugins/bfetch/server';
+import { PluginStart as DataViewsServerPluginStart } from 'src/plugins/data_views/server';
import { ConfigSchema } from '../config';
-import { IndexPatternsServiceProvider, IndexPatternsServiceStart } from './data_views';
import { ISearchSetup, ISearchStart, SearchEnhancements } from './search';
import { SearchService } from './search/search_service';
import { QueryService } from './query/query_service';
@@ -43,7 +43,7 @@ export interface DataPluginStart {
* @deprecated - use "fieldFormats" plugin directly instead
*/
fieldFormats: FieldFormatsStart;
- indexPatterns: IndexPatternsServiceStart;
+ indexPatterns: DataViewsServerPluginStart;
}
export interface DataPluginSetupDependencies {
@@ -56,6 +56,7 @@ export interface DataPluginSetupDependencies {
export interface DataPluginStartDependencies {
fieldFormats: FieldFormatsStart;
logger: Logger;
+ dataViews: DataViewsServerPluginStart;
}
export class DataServerPlugin
@@ -71,7 +72,6 @@ export class DataServerPlugin
private readonly scriptsService: ScriptsService;
private readonly kqlTelemetryService: KqlTelemetryService;
private readonly autocompleteService: AutocompleteService;
- private readonly indexPatterns = new IndexPatternsServiceProvider();
private readonly queryService = new QueryService();
private readonly logger: Logger;
@@ -91,11 +91,6 @@ export class DataServerPlugin
this.queryService.setup(core);
this.autocompleteService.setup(core);
this.kqlTelemetryService.setup(core, { usageCollection });
- this.indexPatterns.setup(core, {
- expressions,
- logger: this.logger.get('indexPatterns'),
- usageCollection,
- });
core.uiSettings.register(getUiSettings());
@@ -114,16 +109,11 @@ export class DataServerPlugin
};
}
- public start(core: CoreStart, { fieldFormats }: DataPluginStartDependencies) {
- const indexPatterns = this.indexPatterns.start(core, {
- fieldFormats,
- logger: this.logger.get('indexPatterns'),
- });
-
+ public start(core: CoreStart, { fieldFormats, dataViews }: DataPluginStartDependencies) {
return {
fieldFormats,
- indexPatterns,
- search: this.searchService.start(core, { fieldFormats, indexPatterns }),
+ indexPatterns: dataViews,
+ search: this.searchService.start(core, { fieldFormats, indexPatterns: dataViews }),
};
}
diff --git a/src/plugins/data/server/saved_objects/index.ts b/src/plugins/data/server/saved_objects/index.ts
index 53d4360782b5b..8bfce1a4d3696 100644
--- a/src/plugins/data/server/saved_objects/index.ts
+++ b/src/plugins/data/server/saved_objects/index.ts
@@ -7,6 +7,5 @@
*/
export { querySavedObjectType } from './query';
-export { indexPatternSavedObjectType } from './index_patterns';
export { kqlTelemetry } from './kql_telemetry';
export { searchTelemetry } from './search_telemetry';
diff --git a/src/plugins/data/tsconfig.json b/src/plugins/data/tsconfig.json
index 3687604e05e2b..92f80f47eca64 100644
--- a/src/plugins/data/tsconfig.json
+++ b/src/plugins/data/tsconfig.json
@@ -23,6 +23,7 @@
{ "path": "../usage_collection/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
- { "path": "../field_formats/tsconfig.json" }
+ { "path": "../field_formats/tsconfig.json" },
+ { "path": "../data_views/tsconfig.json" }
]
}
diff --git a/src/plugins/data_views/README.mdx b/src/plugins/data_views/README.mdx
new file mode 100644
index 0000000000000..90efdc18d8fdb
--- /dev/null
+++ b/src/plugins/data_views/README.mdx
@@ -0,0 +1,19 @@
+---
+id: kibDataPlugin
+slug: /kibana-dev-docs/services/data-plugin
+title: Data services
+image: https://source.unsplash.com/400x175/?Search
+summary: The data plugin contains services for searching, querying and filtering.
+date: 2020-12-02
+tags: ['kibana', 'dev', 'contributor', 'api docs']
+---
+
+# Data Views
+
+The data views API provides a consistent method of structuring and formatting documents
+and field lists across the various Kibana apps. Its typically used in conjunction with
+ for composing queries.
+
+*Note: Kibana index patterns are currently being renamed to data views. There will be some naming inconsistencies until the transition is complete.*
+
+
diff --git a/src/plugins/data/common/data_views/constants.ts b/src/plugins/data_views/common/constants.ts
similarity index 81%
rename from src/plugins/data/common/data_views/constants.ts
rename to src/plugins/data_views/common/constants.ts
index 67e266dbd84a2..ca42221806b2e 100644
--- a/src/plugins/data/common/data_views/constants.ts
+++ b/src/plugins/data_views/common/constants.ts
@@ -29,3 +29,14 @@ export const FLEET_ASSETS_TO_IGNORE = {
METRICS_DATA_STREAM_TO_IGNORE: 'metrics-elastic_agent', // ignore ds created by Fleet server itself
METRICS_ENDPOINT_INDEX_TO_IGNORE: 'metrics-endpoint.metadata_current_default', // ignore index created by Fleet endpoint package installed by default in Cloud
};
+
+export const META_FIELDS = 'metaFields';
+
+/** @public **/
+export const DATA_VIEW_SAVED_OBJECT_TYPE = 'index-pattern';
+
+/**
+ * @deprecated Use DATA_VIEW_SAVED_OBJECT_TYPE. All index pattern interfaces were renamed.
+ */
+
+export const INDEX_PATTERN_SAVED_OBJECT_TYPE = DATA_VIEW_SAVED_OBJECT_TYPE;
diff --git a/src/plugins/data/common/data_views/data_view.stub.ts b/src/plugins/data_views/common/data_view.stub.ts
similarity index 94%
rename from src/plugins/data/common/data_views/data_view.stub.ts
rename to src/plugins/data_views/common/data_view.stub.ts
index a3279434c7a0b..2eb6d4f5d7813 100644
--- a/src/plugins/data/common/data_views/data_view.stub.ts
+++ b/src/plugins/data_views/common/data_view.stub.ts
@@ -12,8 +12,8 @@ export {
createStubDataView,
createStubDataView as createStubIndexPattern,
} from './data_views/data_view.stub';
-import { SavedObject } from '../../../../core/types';
-import { DataViewAttributes } from '../types';
+import { SavedObject } from '../../../core/types';
+import { DataViewAttributes } from './types';
export const stubDataView = createStubDataView({
spec: {
diff --git a/src/plugins/data/common/data_views/data_views/__snapshots__/data_view.test.ts.snap b/src/plugins/data_views/common/data_views/__snapshots__/data_view.test.ts.snap
similarity index 100%
rename from src/plugins/data/common/data_views/data_views/__snapshots__/data_view.test.ts.snap
rename to src/plugins/data_views/common/data_views/__snapshots__/data_view.test.ts.snap
diff --git a/src/plugins/data/common/data_views/data_views/__snapshots__/data_views.test.ts.snap b/src/plugins/data_views/common/data_views/__snapshots__/data_views.test.ts.snap
similarity index 100%
rename from src/plugins/data/common/data_views/data_views/__snapshots__/data_views.test.ts.snap
rename to src/plugins/data_views/common/data_views/__snapshots__/data_views.test.ts.snap
diff --git a/src/plugins/data/common/data_views/data_views/_pattern_cache.ts b/src/plugins/data_views/common/data_views/_pattern_cache.ts
similarity index 100%
rename from src/plugins/data/common/data_views/data_views/_pattern_cache.ts
rename to src/plugins/data_views/common/data_views/_pattern_cache.ts
diff --git a/src/plugins/data/common/data_views/data_views/data_view.stub.ts b/src/plugins/data_views/common/data_views/data_view.stub.ts
similarity index 91%
rename from src/plugins/data/common/data_views/data_views/data_view.stub.ts
rename to src/plugins/data_views/common/data_views/data_view.stub.ts
index 5ff2d077812a8..bb7696b0e1262 100644
--- a/src/plugins/data/common/data_views/data_views/data_view.stub.ts
+++ b/src/plugins/data_views/common/data_views/data_view.stub.ts
@@ -8,8 +8,8 @@
import { DataView } from './data_view';
import { DataViewSpec } from '../types';
-import { FieldFormatsStartCommon } from '../../../../field_formats/common';
-import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
+import { FieldFormatsStartCommon } from '../../../field_formats/common';
+import { fieldFormatsMock } from '../../../field_formats/common/mocks';
/**
* Create a custom stub index pattern. Use it in your unit tests where an {@link DataView} expected.
diff --git a/src/plugins/data/common/data_views/data_views/data_view.test.ts b/src/plugins/data_views/common/data_views/data_view.test.ts
similarity index 98%
rename from src/plugins/data/common/data_views/data_views/data_view.test.ts
rename to src/plugins/data_views/common/data_views/data_view.test.ts
index 6aea86a7adae7..990b8fa4d5f35 100644
--- a/src/plugins/data/common/data_views/data_views/data_view.test.ts
+++ b/src/plugins/data_views/common/data_views/data_view.test.ts
@@ -10,12 +10,12 @@ import { map, last } from 'lodash';
import { IndexPattern } from './data_view';
-import { DuplicateField } from '../../../../kibana_utils/common';
+import { DuplicateField } from '../../../kibana_utils/common';
import { IndexPatternField } from '../fields';
-import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
-import { FieldFormat } from '../../../../field_formats/common';
+import { fieldFormatsMock } from '../../../field_formats/common/mocks';
+import { FieldFormat } from '../../../field_formats/common';
import { RuntimeField } from '../types';
import { stubLogstashFields } from '../field.stub';
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
diff --git a/src/plugins/data/common/data_views/data_views/data_view.ts b/src/plugins/data_views/common/data_views/data_view.ts
similarity index 97%
rename from src/plugins/data/common/data_views/data_views/data_view.ts
rename to src/plugins/data_views/common/data_views/data_view.ts
index 18d301d2f9ea7..00b96cda32ad7 100644
--- a/src/plugins/data/common/data_views/data_views/data_view.ts
+++ b/src/plugins/data_views/common/data_views/data_view.ts
@@ -9,19 +9,19 @@
/* eslint-disable max-classes-per-file */
import _, { each, reject } from 'lodash';
-import { castEsToKbnFieldTypeName } from '@kbn/field-types';
+import { castEsToKbnFieldTypeName, ES_FIELD_TYPES, KBN_FIELD_TYPES } from '@kbn/field-types';
import type { estypes } from '@elastic/elasticsearch';
-import { FieldAttrs, FieldAttrSet, DataViewAttributes } from '../..';
+import { FieldAttrs, FieldAttrSet, DataViewAttributes } from '..';
import type { RuntimeField } from '../types';
-import { DuplicateField } from '../../../../kibana_utils/common';
+import { DuplicateField } from '../../../kibana_utils/common';
-import { ES_FIELD_TYPES, KBN_FIELD_TYPES, IIndexPattern, IFieldType } from '../../../common';
+import { IIndexPattern, IFieldType } from '../../common';
import { DataViewField, IIndexPatternFieldList, fieldList } from '../fields';
import { formatHitProvider } from './format_hit';
import { flattenHitWrapper } from './flatten_hit';
-import { FieldFormatsStartCommon, FieldFormat } from '../../../../field_formats/common';
+import { FieldFormatsStartCommon, FieldFormat } from '../../../field_formats/common';
import { DataViewSpec, TypeMeta, SourceFilter, DataViewFieldMap } from '../types';
-import { SerializedFieldFormat } from '../../../../expressions/common';
+import { SerializedFieldFormat } from '../../../expressions/common';
interface DataViewDeps {
spec?: DataViewSpec;
diff --git a/src/plugins/data/common/data_views/data_views/data_views.test.ts b/src/plugins/data_views/common/data_views/data_views.test.ts
similarity index 99%
rename from src/plugins/data/common/data_views/data_views/data_views.test.ts
rename to src/plugins/data_views/common/data_views/data_views.test.ts
index ef9381f16d934..9a01e52ce48e2 100644
--- a/src/plugins/data/common/data_views/data_views/data_views.test.ts
+++ b/src/plugins/data_views/common/data_views/data_views.test.ts
@@ -8,7 +8,7 @@
import { defaults } from 'lodash';
import { DataViewsService, DataView } from '.';
-import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
+import { fieldFormatsMock } from '../../../field_formats/common/mocks';
import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types';
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
diff --git a/src/plugins/data/common/data_views/data_views/data_views.ts b/src/plugins/data_views/common/data_views/data_views.ts
similarity index 96%
rename from src/plugins/data/common/data_views/data_views/data_views.ts
rename to src/plugins/data_views/common/data_views/data_views.ts
index f9b193d154770..77ce1caaaad84 100644
--- a/src/plugins/data/common/data_views/data_views/data_views.ts
+++ b/src/plugins/data_views/common/data_views/data_views.ts
@@ -11,7 +11,7 @@
import { i18n } from '@kbn/i18n';
import { PublicMethodsOf } from '@kbn/utility-types';
import { castEsToKbnFieldTypeName } from '@kbn/field-types';
-import { DATA_VIEW_SAVED_OBJECT_TYPE, SavedObjectsClientCommon } from '../..';
+import { DATA_VIEW_SAVED_OBJECT_TYPE, SavedObjectsClientCommon } from '..';
import { createDataViewCache } from '.';
import type { RuntimeField } from '../types';
@@ -30,9 +30,9 @@ import {
DataViewFieldMap,
TypeMeta,
} from '../types';
-import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '../../../../field_formats/common/';
-import { UI_SETTINGS, SavedObject } from '../../../common';
-import { SavedObjectNotFound } from '../../../../kibana_utils/common';
+import { FieldFormatsStartCommon, FORMATS_UI_SETTINGS } from '../../../field_formats/common/';
+import { META_FIELDS, SavedObject } from '../../common';
+import { SavedObjectNotFound } from '../../../kibana_utils/common';
import { DataViewMissingIndices } from '../lib';
import { findByTitle } from '../utils';
import { DuplicateDataViewError } from '../errors';
@@ -244,7 +244,7 @@ export class DataViewsService {
* @returns FieldSpec[]
*/
getFieldsForWildcard = async (options: GetFieldsOptions) => {
- const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
+ const metaFields = await this.config.get(META_FIELDS);
return this.apiClient.getFieldsForWildcard({
pattern: options.pattern,
metaFields,
@@ -290,7 +290,7 @@ export class DataViewsService {
}
this.onError(err, {
- title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
+ title: i18n.translate('dataViews.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
values: { id: indexPattern.id, title: indexPattern.title },
}),
@@ -336,7 +336,7 @@ export class DataViewsService {
}
this.onError(err, {
- title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
+ title: i18n.translate('dataViews.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
values: { id, title },
}),
@@ -445,7 +445,7 @@ export class DataViewsService {
spec.title as string,
{
pattern: title as string,
- metaFields: await this.config.get(UI_SETTINGS.META_FIELDS),
+ metaFields: await this.config.get(META_FIELDS),
type,
rollupIndex: typeMeta?.params?.rollup_index,
allowNoIndex: spec.allowNoIndex,
@@ -478,7 +478,7 @@ export class DataViewsService {
});
} else {
this.onError(err, {
- title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
+ title: i18n.translate('dataViews.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
values: { id: savedObject.id, title },
}),
@@ -520,7 +520,7 @@ export class DataViewsService {
*/
async create(spec: DataViewSpec, skipFetchFields = false): Promise {
const shortDotsEnable = await this.config.get(FORMATS_UI_SETTINGS.SHORT_DOTS_ENABLE);
- const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
+ const metaFields = await this.config.get(META_FIELDS);
const indexPattern = new DataView({
spec,
@@ -648,7 +648,7 @@ export class DataViewsService {
if (ignoreErrors) {
return;
}
- const title = i18n.translate('data.indexPatterns.unableWriteLabel', {
+ const title = i18n.translate('dataViews.unableWriteLabel', {
defaultMessage:
'Unable to write index pattern! Refresh the page to get the most up to date changes for this index pattern.',
});
diff --git a/src/plugins/data/common/data_views/data_views/ensure_default_data_view.ts b/src/plugins/data_views/common/data_views/ensure_default_data_view.ts
similarity index 100%
rename from src/plugins/data/common/data_views/data_views/ensure_default_data_view.ts
rename to src/plugins/data_views/common/data_views/ensure_default_data_view.ts
diff --git a/src/plugins/data/common/data_views/data_views/flatten_hit.test.ts b/src/plugins/data_views/common/data_views/flatten_hit.test.ts
similarity index 96%
rename from src/plugins/data/common/data_views/data_views/flatten_hit.test.ts
rename to src/plugins/data_views/common/data_views/flatten_hit.test.ts
index 73232a65b6b72..0946f30b85e39 100644
--- a/src/plugins/data/common/data_views/data_views/flatten_hit.test.ts
+++ b/src/plugins/data_views/common/data_views/flatten_hit.test.ts
@@ -8,7 +8,7 @@
import { DataView } from './data_view';
-import { fieldFormatsMock } from '../../../../field_formats/common/mocks';
+import { fieldFormatsMock } from '../../../field_formats/common/mocks';
import { flattenHitWrapper } from './flatten_hit';
import { stubbedSavedObjectIndexPattern } from '../data_view.stub';
diff --git a/src/plugins/data/common/data_views/data_views/flatten_hit.ts b/src/plugins/data_views/common/data_views/flatten_hit.ts
similarity index 100%
rename from src/plugins/data/common/data_views/data_views/flatten_hit.ts
rename to src/plugins/data_views/common/data_views/flatten_hit.ts
diff --git a/src/plugins/data/common/data_views/data_views/format_hit.ts b/src/plugins/data_views/common/data_views/format_hit.ts
similarity index 97%
rename from src/plugins/data/common/data_views/data_views/format_hit.ts
rename to src/plugins/data_views/common/data_views/format_hit.ts
index 39f7fef564eb0..30daf7768c4dc 100644
--- a/src/plugins/data/common/data_views/data_views/format_hit.ts
+++ b/src/plugins/data_views/common/data_views/format_hit.ts
@@ -8,7 +8,7 @@
import _ from 'lodash';
import { DataView } from './data_view';
-import { FieldFormatsContentType } from '../../../../field_formats/common';
+import { FieldFormatsContentType } from '../../../field_formats/common';
const formattedCache = new WeakMap();
const partialFormattedCache = new WeakMap();
diff --git a/src/plugins/data/common/data_views/data_views/index.ts b/src/plugins/data_views/common/data_views/index.ts
similarity index 100%
rename from src/plugins/data/common/data_views/data_views/index.ts
rename to src/plugins/data_views/common/data_views/index.ts
diff --git a/src/plugins/data/common/data_views/errors/data_view_saved_object_conflict.ts b/src/plugins/data_views/common/errors/data_view_saved_object_conflict.ts
similarity index 100%
rename from src/plugins/data/common/data_views/errors/data_view_saved_object_conflict.ts
rename to src/plugins/data_views/common/errors/data_view_saved_object_conflict.ts
diff --git a/src/plugins/data/common/data_views/errors/duplicate_index_pattern.ts b/src/plugins/data_views/common/errors/duplicate_index_pattern.ts
similarity index 100%
rename from src/plugins/data/common/data_views/errors/duplicate_index_pattern.ts
rename to src/plugins/data_views/common/errors/duplicate_index_pattern.ts
diff --git a/src/plugins/data/common/data_views/errors/index.ts b/src/plugins/data_views/common/errors/index.ts
similarity index 100%
rename from src/plugins/data/common/data_views/errors/index.ts
rename to src/plugins/data_views/common/errors/index.ts
diff --git a/src/plugins/data/common/data_views/expressions/index.ts b/src/plugins/data_views/common/expressions/index.ts
similarity index 100%
rename from src/plugins/data/common/data_views/expressions/index.ts
rename to src/plugins/data_views/common/expressions/index.ts
diff --git a/src/plugins/data/common/data_views/expressions/load_index_pattern.ts b/src/plugins/data_views/common/expressions/load_index_pattern.ts
similarity index 90%
rename from src/plugins/data/common/data_views/expressions/load_index_pattern.ts
rename to src/plugins/data_views/common/expressions/load_index_pattern.ts
index dd47a9fc0dfb4..ca0c1090ceea8 100644
--- a/src/plugins/data/common/data_views/expressions/load_index_pattern.ts
+++ b/src/plugins/data_views/common/expressions/load_index_pattern.ts
@@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
import { DataViewsContract } from '../data_views';
import { DataViewSpec } from '..';
-import { SavedObjectReference } from '../../../../../core/types';
+import { SavedObjectReference } from '../../../../core/types';
const name = 'indexPatternLoad';
const type = 'index_pattern';
@@ -46,14 +46,14 @@ export const getIndexPatternLoadMeta = (): Omit<
name,
type,
inputTypes: ['null'],
- help: i18n.translate('data.functions.indexPatternLoad.help', {
+ help: i18n.translate('dataViews.indexPatternLoad.help', {
defaultMessage: 'Loads an index pattern',
}),
args: {
id: {
types: ['string'],
required: true,
- help: i18n.translate('data.functions.indexPatternLoad.id.help', {
+ help: i18n.translate('dataViews.functions.indexPatternLoad.id.help', {
defaultMessage: 'index pattern id to load',
}),
},
diff --git a/src/plugins/data/common/data_views/field.stub.ts b/src/plugins/data_views/common/field.stub.ts
similarity index 100%
rename from src/plugins/data/common/data_views/field.stub.ts
rename to src/plugins/data_views/common/field.stub.ts
diff --git a/src/plugins/data/common/data_views/fields/__snapshots__/data_view_field.test.ts.snap b/src/plugins/data_views/common/fields/__snapshots__/data_view_field.test.ts.snap
similarity index 100%
rename from src/plugins/data/common/data_views/fields/__snapshots__/data_view_field.test.ts.snap
rename to src/plugins/data_views/common/fields/__snapshots__/data_view_field.test.ts.snap
diff --git a/src/plugins/data/common/data_views/fields/data_view_field.test.ts b/src/plugins/data_views/common/fields/data_view_field.test.ts
similarity index 97%
rename from src/plugins/data/common/data_views/fields/data_view_field.test.ts
rename to src/plugins/data_views/common/fields/data_view_field.test.ts
index 9107036c15c1a..9c611354683c2 100644
--- a/src/plugins/data/common/data_views/fields/data_view_field.test.ts
+++ b/src/plugins/data_views/common/fields/data_view_field.test.ts
@@ -8,9 +8,9 @@
import { IndexPatternField } from './data_view_field';
import { IndexPattern } from '..';
-import { KBN_FIELD_TYPES } from '../../../common';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { FieldSpec, RuntimeField } from '../types';
-import { FieldFormat } from '../../../../field_formats/common';
+import { FieldFormat } from '../../../field_formats/common';
describe('Field', function () {
function flatten(obj: Record) {
diff --git a/src/plugins/data/common/data_views/fields/data_view_field.ts b/src/plugins/data_views/common/fields/data_view_field.ts
similarity index 97%
rename from src/plugins/data/common/data_views/fields/data_view_field.ts
rename to src/plugins/data_views/common/fields/data_view_field.ts
index fae0e14b95c05..3ad92a3a7e53d 100644
--- a/src/plugins/data/common/data_views/fields/data_view_field.ts
+++ b/src/plugins/data_views/common/fields/data_view_field.ts
@@ -9,11 +9,11 @@
/* eslint-disable max-classes-per-file */
import { KbnFieldType, getKbnFieldType, castEsToKbnFieldTypeName } from '@kbn/field-types';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
import type { RuntimeField } from '../types';
-import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
import type { IFieldType } from './types';
-import { FieldSpec, DataView } from '../..';
-import { shortenDottedString } from '../../utils';
+import { FieldSpec, DataView } from '..';
+import { shortenDottedString } from './utils';
/** @public */
export class DataViewField implements IFieldType {
diff --git a/src/plugins/data/common/data_views/fields/field_list.ts b/src/plugins/data_views/common/fields/field_list.ts
similarity index 100%
rename from src/plugins/data/common/data_views/fields/field_list.ts
rename to src/plugins/data_views/common/fields/field_list.ts
diff --git a/src/plugins/data/common/data_views/fields/fields.mocks.ts b/src/plugins/data_views/common/fields/fields.mocks.ts
similarity index 100%
rename from src/plugins/data/common/data_views/fields/fields.mocks.ts
rename to src/plugins/data_views/common/fields/fields.mocks.ts
diff --git a/src/plugins/data/common/data_views/fields/index.ts b/src/plugins/data_views/common/fields/index.ts
similarity index 100%
rename from src/plugins/data/common/data_views/fields/index.ts
rename to src/plugins/data_views/common/fields/index.ts
diff --git a/src/plugins/data/common/data_views/fields/types.ts b/src/plugins/data_views/common/fields/types.ts
similarity index 95%
rename from src/plugins/data/common/data_views/fields/types.ts
rename to src/plugins/data_views/common/fields/types.ts
index 2c5934a8e7b3f..2bd1cf5834548 100644
--- a/src/plugins/data/common/data_views/fields/types.ts
+++ b/src/plugins/data_views/common/fields/types.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { DataViewFieldBase } from '@kbn/es-query';
-import { FieldSpec, DataView } from '../..';
+import { FieldSpec, DataView } from '..';
/**
* @deprecated Use {@link IndexPatternField}
diff --git a/src/plugins/data/common/utils/shorten_dotted_string.test.ts b/src/plugins/data_views/common/fields/utils.test.ts
similarity index 92%
rename from src/plugins/data/common/utils/shorten_dotted_string.test.ts
rename to src/plugins/data_views/common/fields/utils.test.ts
index 33a44925982ec..0f2ff280eb61b 100644
--- a/src/plugins/data/common/utils/shorten_dotted_string.test.ts
+++ b/src/plugins/data_views/common/fields/utils.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { shortenDottedString } from './shorten_dotted_string';
+import { shortenDottedString } from './utils';
describe('shortenDottedString', () => {
test('should convert a dot.notated.string into a short string', () => {
diff --git a/src/plugins/data/common/data_views/fields/utils.ts b/src/plugins/data_views/common/fields/utils.ts
similarity index 75%
rename from src/plugins/data/common/data_views/fields/utils.ts
rename to src/plugins/data_views/common/fields/utils.ts
index 9e05bebc746f0..8344a32d78556 100644
--- a/src/plugins/data/common/data_views/fields/utils.ts
+++ b/src/plugins/data_views/common/fields/utils.ts
@@ -22,3 +22,15 @@ export function isFilterable(field: IFieldType): boolean {
export function isNestedField(field: IFieldType): boolean {
return !!field.subType?.nested;
}
+
+const DOT_PREFIX_RE = /(.).+?\./g;
+
+/**
+ * Convert a dot.notated.string into a short
+ * version (d.n.string)
+ *
+ * @return {any}
+ */
+export function shortenDottedString(input: any) {
+ return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
+}
diff --git a/src/plugins/data_views/common/index.ts b/src/plugins/data_views/common/index.ts
new file mode 100644
index 0000000000000..e8b36ab3e8fc1
--- /dev/null
+++ b/src/plugins/data_views/common/index.ts
@@ -0,0 +1,62 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export {
+ RUNTIME_FIELD_TYPES,
+ FLEET_ASSETS_TO_IGNORE,
+ META_FIELDS,
+ DATA_VIEW_SAVED_OBJECT_TYPE,
+ INDEX_PATTERN_SAVED_OBJECT_TYPE,
+} from './constants';
+export type { IFieldType, IIndexPatternFieldList } from './fields';
+export { isFilterable, isNestedField, fieldList, DataViewField, IndexPatternField } from './fields';
+export type {
+ FieldFormatMap,
+ RuntimeType,
+ RuntimeField,
+ IIndexPattern,
+ DataViewAttributes,
+ IndexPatternAttributes,
+ FieldAttrs,
+ FieldAttrSet,
+ OnNotification,
+ OnError,
+ UiSettingsCommon,
+ SavedObjectsClientCommonFindArgs,
+ SavedObjectsClientCommon,
+ GetFieldsOptions,
+ GetFieldsOptionsTimePattern,
+ IDataViewsApiClient,
+ IIndexPatternsApiClient,
+ SavedObject,
+ AggregationRestrictions,
+ TypeMeta,
+ FieldSpecConflictDescriptions,
+ FieldSpecExportFmt,
+ FieldSpec,
+ DataViewFieldMap,
+ IndexPatternFieldMap,
+ DataViewSpec,
+ IndexPatternSpec,
+ SourceFilter,
+} from './types';
+export { DataViewType, IndexPatternType } from './types';
+export {
+ IndexPatternsService,
+ IndexPatternsContract,
+ DataViewsService,
+ DataViewsContract,
+} from './data_views';
+export { IndexPattern, IndexPatternListItem, DataView, DataViewListItem } from './data_views';
+export { DuplicateDataViewError, DataViewSavedObjectConflictError } from './errors';
+export type {
+ IndexPatternExpressionType,
+ IndexPatternLoadStartDependencies,
+ IndexPatternLoadExpressionFunctionDefinition,
+} from './expressions';
+export { getIndexPatternLoadMeta } from './expressions';
diff --git a/src/plugins/data/common/data_views/lib/errors.ts b/src/plugins/data_views/common/lib/errors.ts
similarity index 93%
rename from src/plugins/data/common/data_views/lib/errors.ts
rename to src/plugins/data_views/common/lib/errors.ts
index 83cc7ea56d020..f8422a6e5dd0d 100644
--- a/src/plugins/data/common/data_views/lib/errors.ts
+++ b/src/plugins/data_views/common/lib/errors.ts
@@ -8,7 +8,7 @@
/* eslint-disable */
-import { KbnError } from '../../../../kibana_utils/common/';
+import { KbnError } from '../../../kibana_utils/common';
/**
* Tried to call a method that relies on SearchSource having an indexPattern assigned
diff --git a/src/plugins/data/common/data_views/lib/get_title.ts b/src/plugins/data_views/common/lib/get_title.ts
similarity index 85%
rename from src/plugins/data/common/data_views/lib/get_title.ts
rename to src/plugins/data_views/common/lib/get_title.ts
index 94185eae46893..69471583f139c 100644
--- a/src/plugins/data/common/data_views/lib/get_title.ts
+++ b/src/plugins/data_views/common/lib/get_title.ts
@@ -6,8 +6,8 @@
* Side Public License, v 1.
*/
-import { SavedObjectsClientContract } from '../../../../../core/public';
-import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../constants';
+import { SavedObjectsClientContract } from '../../../../core/public';
+import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../constants';
import { DataViewAttributes } from '../types';
export async function getTitle(
diff --git a/src/plugins/data/common/data_views/lib/index.ts b/src/plugins/data_views/common/lib/index.ts
similarity index 100%
rename from src/plugins/data/common/data_views/lib/index.ts
rename to src/plugins/data_views/common/lib/index.ts
diff --git a/src/plugins/data/common/data_views/lib/types.ts b/src/plugins/data_views/common/lib/types.ts
similarity index 100%
rename from src/plugins/data/common/data_views/lib/types.ts
rename to src/plugins/data_views/common/lib/types.ts
diff --git a/src/plugins/data/common/data_views/lib/validate_data_view.test.ts b/src/plugins/data_views/common/lib/validate_data_view.test.ts
similarity index 100%
rename from src/plugins/data/common/data_views/lib/validate_data_view.test.ts
rename to src/plugins/data_views/common/lib/validate_data_view.test.ts
diff --git a/src/plugins/data/common/data_views/lib/validate_data_view.ts b/src/plugins/data_views/common/lib/validate_data_view.ts
similarity index 100%
rename from src/plugins/data/common/data_views/lib/validate_data_view.ts
rename to src/plugins/data_views/common/lib/validate_data_view.ts
diff --git a/src/plugins/data/common/data_views/mocks.ts b/src/plugins/data_views/common/mocks.ts
similarity index 100%
rename from src/plugins/data/common/data_views/mocks.ts
rename to src/plugins/data_views/common/mocks.ts
diff --git a/src/plugins/data_views/common/stubs.ts b/src/plugins/data_views/common/stubs.ts
new file mode 100644
index 0000000000000..c6895da9bfb3a
--- /dev/null
+++ b/src/plugins/data_views/common/stubs.ts
@@ -0,0 +1,10 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export * from './field.stub';
+export * from './data_views/data_view.stub';
diff --git a/src/plugins/data/common/data_views/types.ts b/src/plugins/data_views/common/types.ts
similarity index 96%
rename from src/plugins/data/common/data_views/types.ts
rename to src/plugins/data_views/common/types.ts
index 85fe98fbcfeb7..2b184bc1ef2a4 100644
--- a/src/plugins/data/common/data_views/types.ts
+++ b/src/plugins/data_views/common/types.ts
@@ -10,11 +10,12 @@ import type { DataViewFieldBase, IFieldSubType, DataViewBase } from '@kbn/es-que
import { ToastInputFields, ErrorToastOptions } from 'src/core/public/notifications';
// eslint-disable-next-line
import type { SavedObject } from 'src/core/server';
+import { KBN_FIELD_TYPES } from '@kbn/field-types';
import { IFieldType } from './fields';
import { RUNTIME_FIELD_TYPES } from './constants';
-import { SerializedFieldFormat } from '../../../expressions/common';
-import { KBN_FIELD_TYPES, DataViewField } from '..';
-import { FieldFormat } from '../../../field_formats/common';
+import { SerializedFieldFormat } from '../../expressions/common';
+import { DataViewField } from './fields';
+import { FieldFormat } from '../../field_formats/common';
export type FieldFormatMap = Record;
diff --git a/src/plugins/data/common/data_views/utils.test.ts b/src/plugins/data_views/common/utils.test.ts
similarity index 100%
rename from src/plugins/data/common/data_views/utils.test.ts
rename to src/plugins/data_views/common/utils.test.ts
diff --git a/src/plugins/data/common/data_views/utils.ts b/src/plugins/data_views/common/utils.ts
similarity index 89%
rename from src/plugins/data/common/data_views/utils.ts
rename to src/plugins/data_views/common/utils.ts
index 2d36ab6c72225..77e9bd76b869c 100644
--- a/src/plugins/data/common/data_views/utils.ts
+++ b/src/plugins/data_views/common/utils.ts
@@ -7,9 +7,9 @@
*/
import type { IndexPatternSavedObjectAttrs } from './data_views';
-import type { SavedObjectsClientCommon } from '../types';
+import type { SavedObjectsClientCommon } from './types';
-import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../constants';
+import { DATA_VIEW_SAVED_OBJECT_TYPE } from './constants';
/**
* Returns an object matching a given title
diff --git a/src/plugins/data_views/jest.config.js b/src/plugins/data_views/jest.config.js
new file mode 100644
index 0000000000000..4c1f067835630
--- /dev/null
+++ b/src/plugins/data_views/jest.config.js
@@ -0,0 +1,16 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+module.exports = {
+ preset: '@kbn/test',
+ rootDir: '../../..',
+ roots: ['/src/plugins/data_views'],
+ coverageDirectory: '/target/kibana-coverage/jest/src/plugins/data_views',
+ coverageReporters: ['text', 'html'],
+ collectCoverageFrom: ['/src/plugins/data_views/{common,public,server}/**/*.{ts,tsx}'],
+};
diff --git a/src/plugins/data_views/kibana.json b/src/plugins/data_views/kibana.json
new file mode 100644
index 0000000000000..27bf536ef8040
--- /dev/null
+++ b/src/plugins/data_views/kibana.json
@@ -0,0 +1,15 @@
+{
+ "id": "dataViews",
+ "version": "kibana",
+ "server": true,
+ "ui": true,
+ "requiredPlugins": ["fieldFormats","expressions"],
+ "optionalPlugins": ["usageCollection"],
+ "extraPublicDirs": ["common"],
+ "requiredBundles": ["kibanaUtils","kibanaReact"],
+ "owner": {
+ "name": "App Services",
+ "githubTeam": "kibana-app-services"
+ },
+ "description": "Data services are useful for searching and querying data from Elasticsearch. Helpful utilities include: a re-usable react query bar, KQL autocomplete, async search, Data Views (Index Patterns) and field formatters."
+}
diff --git a/src/plugins/data/public/data_views/data_views/data_view.stub.ts b/src/plugins/data_views/public/data_views/data_view.stub.ts
similarity index 84%
rename from src/plugins/data/public/data_views/data_views/data_view.stub.ts
rename to src/plugins/data_views/public/data_views/data_view.stub.ts
index b3d8448064c65..f37a8a78b234b 100644
--- a/src/plugins/data/public/data_views/data_views/data_view.stub.ts
+++ b/src/plugins/data_views/public/data_views/data_view.stub.ts
@@ -7,11 +7,11 @@
*/
import { CoreSetup } from 'kibana/public';
-import { FieldFormatsStartCommon } from '../../../../field_formats/common';
-import { getFieldFormatsRegistry } from '../../../../field_formats/public/mocks';
-import * as commonStubs from '../../../common/stubs';
-import { DataView, DataViewSpec } from '../../../common';
-import { coreMock } from '../../../../../core/public/mocks';
+import { FieldFormatsStartCommon } from '../../../field_formats/common';
+import { getFieldFormatsRegistry } from '../../../field_formats/public/mocks';
+import * as commonStubs from '../../common/stubs';
+import { DataView, DataViewSpec } from '../../common';
+import { coreMock } from '../../../../core/public/mocks';
/**
* Create a custom stub index pattern. Use it in your unit tests where an {@link DataView} expected.
* @param spec - Serialized index pattern object
diff --git a/src/plugins/data/public/data_views/data_views/data_views_api_client.test.mock.ts b/src/plugins/data_views/public/data_views/data_views_api_client.test.mock.ts
similarity index 86%
rename from src/plugins/data/public/data_views/data_views/data_views_api_client.test.mock.ts
rename to src/plugins/data_views/public/data_views/data_views_api_client.test.mock.ts
index c53ca7ad89aa9..2fd17b98f7498 100644
--- a/src/plugins/data/public/data_views/data_views/data_views_api_client.test.mock.ts
+++ b/src/plugins/data_views/public/data_views/data_views_api_client.test.mock.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { setup } from '../../../../../core/test_helpers/http_test_setup';
+import { setup } from '../../../../core/test_helpers/http_test_setup';
export const { http } = setup((injectedMetadata) => {
injectedMetadata.getBasePath.mockReturnValue('/hola/daro/');
diff --git a/src/plugins/data/public/data_views/data_views/data_views_api_client.test.ts b/src/plugins/data_views/public/data_views/data_views_api_client.test.ts
similarity index 100%
rename from src/plugins/data/public/data_views/data_views/data_views_api_client.test.ts
rename to src/plugins/data_views/public/data_views/data_views_api_client.test.ts
diff --git a/src/plugins/data/public/data_views/data_views/data_views_api_client.ts b/src/plugins/data_views/public/data_views/data_views_api_client.ts
similarity index 90%
rename from src/plugins/data/public/data_views/data_views/data_views_api_client.ts
rename to src/plugins/data_views/public/data_views/data_views_api_client.ts
index d11ec7cfa003d..d4da9a55c25d1 100644
--- a/src/plugins/data/public/data_views/data_views/data_views_api_client.ts
+++ b/src/plugins/data_views/public/data_views/data_views_api_client.ts
@@ -7,12 +7,8 @@
*/
import { HttpSetup } from 'src/core/public';
-import { DataViewMissingIndices } from '../../../common/data_views/lib';
-import {
- GetFieldsOptions,
- IDataViewsApiClient,
- GetFieldsOptionsTimePattern,
-} from '../../../common/data_views/types';
+import { DataViewMissingIndices } from '../../common/lib';
+import { GetFieldsOptions, IDataViewsApiClient, GetFieldsOptionsTimePattern } from '../../common';
const API_BASE_URL: string = `/api/index_patterns/`;
diff --git a/src/plugins/data/public/data_views/data_views/index.ts b/src/plugins/data_views/public/data_views/index.ts
similarity index 88%
rename from src/plugins/data/public/data_views/data_views/index.ts
rename to src/plugins/data_views/public/data_views/index.ts
index e0d18d47f39db..e476d62774f17 100644
--- a/src/plugins/data/public/data_views/data_views/index.ts
+++ b/src/plugins/data_views/public/data_views/index.ts
@@ -6,6 +6,6 @@
* Side Public License, v 1.
*/
-export * from '../../../common/data_views/data_views';
+export * from '../../common/data_views';
export * from './redirect_no_index_pattern';
export * from './data_views_api_client';
diff --git a/src/plugins/data/public/data_views/data_views/redirect_no_index_pattern.tsx b/src/plugins/data_views/public/data_views/redirect_no_index_pattern.tsx
similarity index 84%
rename from src/plugins/data/public/data_views/data_views/redirect_no_index_pattern.tsx
rename to src/plugins/data_views/public/data_views/redirect_no_index_pattern.tsx
index 88e18060c4d11..456af90a3c6dd 100644
--- a/src/plugins/data/public/data_views/data_views/redirect_no_index_pattern.tsx
+++ b/src/plugins/data_views/public/data_views/redirect_no_index_pattern.tsx
@@ -10,7 +10,7 @@ import { EuiCallOut } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { CoreStart } from 'kibana/public';
-import { toMountPoint } from '../../../../kibana_react/public';
+import { toMountPoint } from '../../../kibana_react/public';
let bannerId: string;
@@ -29,13 +29,10 @@ export const onRedirectNoIndexPattern =
clearTimeout(timeoutId);
}
- const bannerMessage = i18n.translate(
- 'data.indexPatterns.ensureDefaultIndexPattern.bannerLabel',
- {
- defaultMessage:
- 'To visualize and explore data in Kibana, you must create an index pattern to retrieve data from Elasticsearch.',
- }
- );
+ const bannerMessage = i18n.translate('dataViews.ensureDefaultIndexPattern.bannerLabel', {
+ defaultMessage:
+ 'To visualize and explore data in Kibana, you must create an index pattern to retrieve data from Elasticsearch.',
+ });
// Avoid being hostile to new users who don't have an index pattern setup yet
// give them a friendly info message instead of a terse error message
diff --git a/src/plugins/data/public/data_views/expressions/index.ts b/src/plugins/data_views/public/expressions/index.ts
similarity index 100%
rename from src/plugins/data/public/data_views/expressions/index.ts
rename to src/plugins/data_views/public/expressions/index.ts
diff --git a/src/plugins/data/public/data_views/expressions/load_index_pattern.test.ts b/src/plugins/data_views/public/expressions/load_index_pattern.test.ts
similarity index 92%
rename from src/plugins/data/public/data_views/expressions/load_index_pattern.test.ts
rename to src/plugins/data_views/public/expressions/load_index_pattern.test.ts
index befa78c398984..02a530712e80a 100644
--- a/src/plugins/data/public/data_views/expressions/load_index_pattern.test.ts
+++ b/src/plugins/data_views/public/expressions/load_index_pattern.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { IndexPatternLoadStartDependencies } from '../../../common/data_views/expressions';
+import { IndexPatternLoadStartDependencies } from '../../common/expressions';
import { getFunctionDefinition } from './load_index_pattern';
describe('indexPattern expression function', () => {
diff --git a/src/plugins/data/public/data_views/expressions/load_index_pattern.ts b/src/plugins/data_views/public/expressions/load_index_pattern.ts
similarity index 88%
rename from src/plugins/data/public/data_views/expressions/load_index_pattern.ts
rename to src/plugins/data_views/public/expressions/load_index_pattern.ts
index 979861c7da38e..76119f3e50a45 100644
--- a/src/plugins/data/public/data_views/expressions/load_index_pattern.ts
+++ b/src/plugins/data_views/public/expressions/load_index_pattern.ts
@@ -11,8 +11,8 @@ import {
getIndexPatternLoadMeta,
IndexPatternLoadExpressionFunctionDefinition,
IndexPatternLoadStartDependencies,
-} from '../../../common/data_views/expressions';
-import { DataPublicPluginStart, DataStartDependencies } from '../../types';
+} from '../../common/expressions';
+import { DataViewsPublicPluginStart, DataViewsPublicStartDependencies } from '../types';
/**
* Returns the expression function definition. Any stateful dependencies are accessed
@@ -60,11 +60,14 @@ export function getFunctionDefinition({
export function getIndexPatternLoad({
getStartServices,
}: {
- getStartServices: StartServicesAccessor;
+ getStartServices: StartServicesAccessor<
+ DataViewsPublicStartDependencies,
+ DataViewsPublicPluginStart
+ >;
}) {
return getFunctionDefinition({
getStartDependencies: async () => {
- const [, , { indexPatterns }] = await getStartServices();
+ const [, , indexPatterns] = await getStartServices();
return { indexPatterns };
},
});
diff --git a/src/plugins/data_views/public/index.ts b/src/plugins/data_views/public/index.ts
new file mode 100644
index 0000000000000..572806df11fa3
--- /dev/null
+++ b/src/plugins/data_views/public/index.ts
@@ -0,0 +1,45 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export {
+ ILLEGAL_CHARACTERS_KEY,
+ CONTAINS_SPACES_KEY,
+ ILLEGAL_CHARACTERS_VISIBLE,
+ ILLEGAL_CHARACTERS,
+ validateDataView,
+} from '../common/lib';
+export { flattenHitWrapper, formatHitProvider, onRedirectNoIndexPattern } from './data_views';
+
+export { IndexPatternField, IIndexPatternFieldList, TypeMeta } from '../common';
+
+export {
+ IndexPatternsService,
+ IndexPatternsContract,
+ IndexPattern,
+ DataViewsApiClient,
+ DataViewsService,
+ DataViewsContract,
+ DataView,
+} from './data_views';
+export { UiSettingsPublicToCommon } from './ui_settings_wrapper';
+export { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
+
+/*
+ * Plugin setup
+ */
+
+import { DataViewsPublicPlugin } from './plugin';
+
+export function plugin() {
+ return new DataViewsPublicPlugin();
+}
+
+export type { DataViewsPublicPluginSetup, DataViewsPublicPluginStart } from './types';
+
+// Export plugin after all other imports
+export type { DataViewsPublicPlugin as DataPlugin };
diff --git a/src/plugins/data_views/public/plugin.ts b/src/plugins/data_views/public/plugin.ts
new file mode 100644
index 0000000000000..58f66623b64ab
--- /dev/null
+++ b/src/plugins/data_views/public/plugin.ts
@@ -0,0 +1,68 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
+import { getIndexPatternLoad } from './expressions';
+import {
+ DataViewsPublicPluginSetup,
+ DataViewsPublicPluginStart,
+ DataViewsPublicSetupDependencies,
+ DataViewsPublicStartDependencies,
+} from './types';
+
+import {
+ DataViewsService,
+ onRedirectNoIndexPattern,
+ DataViewsApiClient,
+ UiSettingsPublicToCommon,
+ SavedObjectsClientPublicToCommon,
+} from '.';
+
+export class DataViewsPublicPlugin
+ implements
+ Plugin<
+ DataViewsPublicPluginSetup,
+ DataViewsPublicPluginStart,
+ DataViewsPublicSetupDependencies,
+ DataViewsPublicStartDependencies
+ >
+{
+ public setup(
+ core: CoreSetup,
+ { expressions }: DataViewsPublicSetupDependencies
+ ): DataViewsPublicPluginSetup {
+ expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
+
+ return {};
+ }
+
+ public start(
+ core: CoreStart,
+ { fieldFormats }: DataViewsPublicStartDependencies
+ ): DataViewsPublicPluginStart {
+ const { uiSettings, http, notifications, savedObjects, overlays, application } = core;
+
+ return new DataViewsService({
+ uiSettings: new UiSettingsPublicToCommon(uiSettings),
+ savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client),
+ apiClient: new DataViewsApiClient(http),
+ fieldFormats,
+ onNotification: (toastInputFields) => {
+ notifications.toasts.add(toastInputFields);
+ },
+ onError: notifications.toasts.addError.bind(notifications.toasts),
+ onRedirectNoIndexPattern: onRedirectNoIndexPattern(
+ application.capabilities,
+ application.navigateToApp,
+ overlays
+ ),
+ });
+ }
+
+ public stop() {}
+}
diff --git a/src/plugins/data/public/data_views/saved_objects_client_wrapper.test.ts b/src/plugins/data_views/public/saved_objects_client_wrapper.test.ts
similarity index 96%
rename from src/plugins/data/public/data_views/saved_objects_client_wrapper.test.ts
rename to src/plugins/data_views/public/saved_objects_client_wrapper.test.ts
index 221a18ac7fab7..124a66eba57f2 100644
--- a/src/plugins/data/public/data_views/saved_objects_client_wrapper.test.ts
+++ b/src/plugins/data_views/public/saved_objects_client_wrapper.test.ts
@@ -9,7 +9,7 @@
import { SavedObjectsClientPublicToCommon } from './saved_objects_client_wrapper';
import { savedObjectsServiceMock } from 'src/core/public/mocks';
-import { DataViewSavedObjectConflictError } from '../../common/data_views';
+import { DataViewSavedObjectConflictError } from '../common';
describe('SavedObjectsClientPublicToCommon', () => {
const soClient = savedObjectsServiceMock.createStartContract().client;
diff --git a/src/plugins/data/public/data_views/saved_objects_client_wrapper.ts b/src/plugins/data_views/public/saved_objects_client_wrapper.ts
similarity index 98%
rename from src/plugins/data/public/data_views/saved_objects_client_wrapper.ts
rename to src/plugins/data_views/public/saved_objects_client_wrapper.ts
index 1db4e3b1ccd24..beaae6ac3fc21 100644
--- a/src/plugins/data/public/data_views/saved_objects_client_wrapper.ts
+++ b/src/plugins/data_views/public/saved_objects_client_wrapper.ts
@@ -13,7 +13,7 @@ import {
SavedObjectsClientCommonFindArgs,
SavedObject,
DataViewSavedObjectConflictError,
-} from '../../common/data_views';
+} from '../common';
type SOClient = Pick;
diff --git a/src/plugins/data_views/public/types.ts b/src/plugins/data_views/public/types.ts
new file mode 100644
index 0000000000000..20b1cbaf090fa
--- /dev/null
+++ b/src/plugins/data_views/public/types.ts
@@ -0,0 +1,32 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { ExpressionsSetup } from 'src/plugins/expressions/public';
+import { FieldFormatsSetup, FieldFormatsStart } from 'src/plugins/field_formats/public';
+import { PublicMethodsOf } from '@kbn/utility-types';
+import { DataViewsService } from './data_views';
+
+export interface DataViewsPublicSetupDependencies {
+ expressions: ExpressionsSetup;
+ fieldFormats: FieldFormatsSetup;
+}
+
+export interface DataViewsPublicStartDependencies {
+ fieldFormats: FieldFormatsStart;
+}
+
+/**
+ * Data plugin public Setup contract
+ */
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface DataViewsPublicPluginSetup {}
+
+/**
+ * Data plugin public Start contract
+ */
+export type DataViewsPublicPluginStart = PublicMethodsOf;
diff --git a/src/plugins/data/public/data_views/ui_settings_wrapper.ts b/src/plugins/data_views/public/ui_settings_wrapper.ts
similarity index 95%
rename from src/plugins/data/public/data_views/ui_settings_wrapper.ts
rename to src/plugins/data_views/public/ui_settings_wrapper.ts
index f8ae317391fa3..91806867b6730 100644
--- a/src/plugins/data/public/data_views/ui_settings_wrapper.ts
+++ b/src/plugins/data_views/public/ui_settings_wrapper.ts
@@ -7,7 +7,7 @@
*/
import { IUiSettingsClient, PublicUiSettingsParams, UserProvidedValues } from 'src/core/public';
-import { UiSettingsCommon } from '../../common';
+import { UiSettingsCommon } from '../common';
export class UiSettingsPublicToCommon implements UiSettingsCommon {
private uiSettings: IUiSettingsClient;
diff --git a/src/plugins/data/server/data_views/capabilities_provider.ts b/src/plugins/data_views/server/capabilities_provider.ts
similarity index 100%
rename from src/plugins/data/server/data_views/capabilities_provider.ts
rename to src/plugins/data_views/server/capabilities_provider.ts
diff --git a/src/plugins/data_views/server/data_views_service_factory.ts b/src/plugins/data_views/server/data_views_service_factory.ts
new file mode 100644
index 0000000000000..2f720cd7388f4
--- /dev/null
+++ b/src/plugins/data_views/server/data_views_service_factory.ts
@@ -0,0 +1,50 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import {
+ Logger,
+ SavedObjectsClientContract,
+ ElasticsearchClient,
+ UiSettingsServiceStart,
+} from 'kibana/server';
+import { DataViewsService } from '../common';
+import { FieldFormatsStart } from '../../field_formats/server';
+import { UiSettingsServerToCommon } from './ui_settings_wrapper';
+import { IndexPatternsApiServer } from './index_patterns_api_client';
+import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper';
+
+export const dataViewsServiceFactory =
+ ({
+ logger,
+ uiSettings,
+ fieldFormats,
+ }: {
+ logger: Logger;
+ uiSettings: UiSettingsServiceStart;
+ fieldFormats: FieldFormatsStart;
+ }) =>
+ async (
+ savedObjectsClient: SavedObjectsClientContract,
+ elasticsearchClient: ElasticsearchClient
+ ) => {
+ const uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
+ const formats = await fieldFormats.fieldFormatServiceFactory(uiSettingsClient);
+
+ return new DataViewsService({
+ uiSettings: new UiSettingsServerToCommon(uiSettingsClient),
+ savedObjectsClient: new SavedObjectsClientServerToCommon(savedObjectsClient),
+ apiClient: new IndexPatternsApiServer(elasticsearchClient, savedObjectsClient),
+ fieldFormats: formats,
+ onError: (error) => {
+ logger.error(error);
+ },
+ onNotification: ({ title, text }) => {
+ logger.warn(`${title}${text ? ` : ${text}` : ''}`);
+ },
+ });
+ };
diff --git a/src/plugins/data/server/data_views/deprecations/index.ts b/src/plugins/data_views/server/deprecations/index.ts
similarity index 100%
rename from src/plugins/data/server/data_views/deprecations/index.ts
rename to src/plugins/data_views/server/deprecations/index.ts
diff --git a/src/plugins/data/server/data_views/deprecations/scripted_fields.test.ts b/src/plugins/data_views/server/deprecations/scripted_fields.test.ts
similarity index 100%
rename from src/plugins/data/server/data_views/deprecations/scripted_fields.test.ts
rename to src/plugins/data_views/server/deprecations/scripted_fields.test.ts
diff --git a/src/plugins/data/server/data_views/deprecations/scripted_fields.ts b/src/plugins/data_views/server/deprecations/scripted_fields.ts
similarity index 89%
rename from src/plugins/data/server/data_views/deprecations/scripted_fields.ts
rename to src/plugins/data_views/server/deprecations/scripted_fields.ts
index 65cb962196805..9ee2d64e25cb5 100644
--- a/src/plugins/data/server/data_views/deprecations/scripted_fields.ts
+++ b/src/plugins/data_views/server/deprecations/scripted_fields.ts
@@ -13,7 +13,7 @@ import {
RegisterDeprecationsConfig,
} from 'kibana/server';
import { i18n } from '@kbn/i18n';
-import { IndexPatternAttributes } from '../../../common';
+import { IndexPatternAttributes } from '../../common';
type IndexPatternAttributesWithFields = Pick;
@@ -41,10 +41,10 @@ export const createScriptedFieldsDeprecationsConfig: (
return [
{
- title: i18n.translate('data.deprecations.scriptedFieldsTitle', {
+ title: i18n.translate('dataViews.deprecations.scriptedFieldsTitle', {
defaultMessage: 'Found index patterns using scripted fields',
}),
- message: i18n.translate('data.deprecations.scriptedFieldsMessage', {
+ message: i18n.translate('dataViews.deprecations.scriptedFieldsMessage', {
defaultMessage: `You have {numberOfIndexPatternsWithScriptedFields} index patterns ({titlesPreview}...) that use scripted fields. Scripted fields are deprecated and will be removed in future. Use runtime fields instead.`,
values: {
titlesPreview: indexPatternTitles.slice(0, PREVIEW_LIMIT).join('; '),
@@ -56,10 +56,10 @@ export const createScriptedFieldsDeprecationsConfig: (
level: 'warning', // warning because it is not set in stone WHEN we remove scripted fields, hence this deprecation is not a blocker for 8.0 upgrade
correctiveActions: {
manualSteps: [
- i18n.translate('data.deprecations.scriptedFields.manualStepOneMessage', {
+ i18n.translate('dataViews.deprecations.scriptedFields.manualStepOneMessage', {
defaultMessage: 'Navigate to Stack Management > Kibana > Index Patterns.',
}),
- i18n.translate('data.deprecations.scriptedFields.manualStepTwoMessage', {
+ i18n.translate('dataViews.deprecations.scriptedFields.manualStepTwoMessage', {
defaultMessage:
'Update {numberOfIndexPatternsWithScriptedFields} index patterns that have scripted fields to use runtime fields instead. In most cases, to migrate existing scripts, you will need to change "return ;" to "emit();". Index patterns with at least one scripted field: {allTitles}',
values: {
diff --git a/src/plugins/data/server/data_views/error.ts b/src/plugins/data_views/server/error.ts
similarity index 100%
rename from src/plugins/data/server/data_views/error.ts
rename to src/plugins/data_views/server/error.ts
diff --git a/src/plugins/data/server/data_views/expressions/index.ts b/src/plugins/data_views/server/expressions/index.ts
similarity index 100%
rename from src/plugins/data/server/data_views/expressions/index.ts
rename to src/plugins/data_views/server/expressions/index.ts
diff --git a/src/plugins/data/server/data_views/expressions/load_index_pattern.test.ts b/src/plugins/data_views/server/expressions/load_index_pattern.test.ts
similarity index 94%
rename from src/plugins/data/server/data_views/expressions/load_index_pattern.test.ts
rename to src/plugins/data_views/server/expressions/load_index_pattern.test.ts
index 370d7dcfd7eba..94bd854e6734c 100644
--- a/src/plugins/data/server/data_views/expressions/load_index_pattern.test.ts
+++ b/src/plugins/data_views/server/expressions/load_index_pattern.test.ts
@@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
-import { IndexPatternLoadStartDependencies } from '../../../common/data_views/expressions';
+import { IndexPatternLoadStartDependencies } from '../../common/expressions';
import { getFunctionDefinition } from './load_index_pattern';
describe('indexPattern expression function', () => {
diff --git a/src/plugins/data/server/data_views/expressions/load_index_pattern.ts b/src/plugins/data_views/server/expressions/load_index_pattern.ts
similarity index 85%
rename from src/plugins/data/server/data_views/expressions/load_index_pattern.ts
rename to src/plugins/data_views/server/expressions/load_index_pattern.ts
index 4585101f2812c..8ade41132e144 100644
--- a/src/plugins/data/server/data_views/expressions/load_index_pattern.ts
+++ b/src/plugins/data_views/server/expressions/load_index_pattern.ts
@@ -13,8 +13,8 @@ import {
getIndexPatternLoadMeta,
IndexPatternLoadExpressionFunctionDefinition,
IndexPatternLoadStartDependencies,
-} from '../../../common/data_views/expressions';
-import { DataPluginStartDependencies, DataPluginStart } from '../../plugin';
+} from '../../common/expressions';
+import { DataViewsServerPluginStartDependencies, DataViewsServerPluginStart } from '../types';
/**
* Returns the expression function definition. Any stateful dependencies are accessed
@@ -39,7 +39,7 @@ export function getFunctionDefinition({
const kibanaRequest = getKibanaRequest ? getKibanaRequest() : null;
if (!kibanaRequest) {
throw new Error(
- i18n.translate('data.indexPatterns.indexPatternLoad.error.kibanaRequest', {
+ i18n.translate('dataViews.indexPatternLoad.error.kibanaRequest', {
defaultMessage:
'A KibanaRequest is required to execute this search on the server. ' +
'Please provide a request object to the expression execution params.',
@@ -73,13 +73,17 @@ export function getFunctionDefinition({
export function getIndexPatternLoad({
getStartServices,
}: {
- getStartServices: StartServicesAccessor;
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >;
}) {
return getFunctionDefinition({
getStartDependencies: async (request: KibanaRequest) => {
- const [{ elasticsearch, savedObjects }, , { indexPatterns }] = await getStartServices();
+ const [{ elasticsearch, savedObjects }, , { indexPatternsServiceFactory }] =
+ await getStartServices();
return {
- indexPatterns: await indexPatterns.indexPatternsServiceFactory(
+ indexPatterns: await indexPatternsServiceFactory(
savedObjects.getScopedClient(request),
elasticsearch.client.asScoped(request).asCurrentUser
),
diff --git a/src/plugins/data/server/data_views/fetcher/index.ts b/src/plugins/data_views/server/fetcher/index.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/index.ts
rename to src/plugins/data_views/server/fetcher/index.ts
diff --git a/src/plugins/data_views/server/fetcher/index_not_found_exception.json b/src/plugins/data_views/server/fetcher/index_not_found_exception.json
new file mode 100644
index 0000000000000..dc892d95ae397
--- /dev/null
+++ b/src/plugins/data_views/server/fetcher/index_not_found_exception.json
@@ -0,0 +1,21 @@
+{
+ "error" : {
+ "root_cause" : [
+ {
+ "type" : "index_not_found_exception",
+ "reason" : "no such index [poop]",
+ "resource.type" : "index_or_alias",
+ "resource.id" : "poop",
+ "index_uuid" : "_na_",
+ "index" : "poop"
+ }
+ ],
+ "type" : "index_not_found_exception",
+ "reason" : "no such index [poop]",
+ "resource.type" : "index_or_alias",
+ "resource.id" : "poop",
+ "index_uuid" : "_na_",
+ "index" : "poop"
+ },
+ "status" : 404
+}
diff --git a/src/plugins/data/server/data_views/fetcher/index_patterns_fetcher.test.ts b/src/plugins/data_views/server/fetcher/index_patterns_fetcher.test.ts
similarity index 95%
rename from src/plugins/data/server/data_views/fetcher/index_patterns_fetcher.test.ts
rename to src/plugins/data_views/server/fetcher/index_patterns_fetcher.test.ts
index 4bd21fb3a1820..a65d4d551cf7c 100644
--- a/src/plugins/data/server/data_views/fetcher/index_patterns_fetcher.test.ts
+++ b/src/plugins/data_views/server/fetcher/index_patterns_fetcher.test.ts
@@ -8,7 +8,7 @@
import { IndexPatternsFetcher } from '.';
import { ElasticsearchClient } from 'kibana/server';
-import * as indexNotFoundException from '../../../common/search/test_data/index_not_found_exception.json';
+import * as indexNotFoundException from './index_not_found_exception.json';
describe('Index Pattern Fetcher - server', () => {
let indexPatterns: IndexPatternsFetcher;
diff --git a/src/plugins/data/server/data_views/fetcher/index_patterns_fetcher.ts b/src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/index_patterns_fetcher.ts
rename to src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/errors.ts b/src/plugins/data_views/server/fetcher/lib/errors.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/errors.ts
rename to src/plugins/data_views/server/fetcher/lib/errors.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/es_api.test.js b/src/plugins/data_views/server/fetcher/lib/es_api.test.js
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/es_api.test.js
rename to src/plugins/data_views/server/fetcher/lib/es_api.test.js
diff --git a/src/plugins/data/server/data_views/fetcher/lib/es_api.ts b/src/plugins/data_views/server/fetcher/lib/es_api.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/es_api.ts
rename to src/plugins/data_views/server/fetcher/lib/es_api.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/__fixtures__/es_field_caps_response.json b/src/plugins/data_views/server/fetcher/lib/field_capabilities/__fixtures__/es_field_caps_response.json
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/__fixtures__/es_field_caps_response.json
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/__fixtures__/es_field_caps_response.json
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_capabilities.test.js b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_capabilities.test.js
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_capabilities.test.js
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/field_capabilities.test.js
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_capabilities.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_capabilities.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_capabilities.ts
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/field_capabilities.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_caps_response.test.js b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.test.js
similarity index 99%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_caps_response.test.js
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.test.js
index c12eff1b5a377..f1e3f314351de 100644
--- a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_caps_response.test.js
+++ b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.test.js
@@ -13,7 +13,7 @@ import sinon from 'sinon';
import * as shouldReadFieldFromDocValuesNS from './should_read_field_from_doc_values';
import { shouldReadFieldFromDocValues } from './should_read_field_from_doc_values';
-import { getKbnFieldType } from '../../../../../common';
+import { getKbnFieldType } from '@kbn/field-types';
import { readFieldCapsResponse } from './field_caps_response';
import esResponse from './__fixtures__/es_field_caps_response.json';
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_caps_response.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts
similarity index 98%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_caps_response.ts
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts
index 3f83fd71b74e4..6dff343f9e00e 100644
--- a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/field_caps_response.ts
+++ b/src/plugins/data_views/server/fetcher/lib/field_capabilities/field_caps_response.ts
@@ -8,7 +8,7 @@
import { uniq } from 'lodash';
import type { estypes } from '@elastic/elasticsearch';
-import { castEsToKbnFieldTypeName } from '../../../../../common';
+import { castEsToKbnFieldTypeName } from '@kbn/field-types';
import { shouldReadFieldFromDocValues } from './should_read_field_from_doc_values';
import { FieldDescriptor } from '../../../fetcher';
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/index.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/index.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/index.ts
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/index.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/overrides.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/overrides.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/overrides.ts
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/overrides.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/should_read_field_from_doc_values.test.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/should_read_field_from_doc_values.test.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/should_read_field_from_doc_values.test.ts
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/should_read_field_from_doc_values.test.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/field_capabilities/should_read_field_from_doc_values.ts b/src/plugins/data_views/server/fetcher/lib/field_capabilities/should_read_field_from_doc_values.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/field_capabilities/should_read_field_from_doc_values.ts
rename to src/plugins/data_views/server/fetcher/lib/field_capabilities/should_read_field_from_doc_values.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/index.ts b/src/plugins/data_views/server/fetcher/lib/index.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/index.ts
rename to src/plugins/data_views/server/fetcher/lib/index.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/jobs_compatibility.test.js b/src/plugins/data_views/server/fetcher/lib/jobs_compatibility.test.js
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/jobs_compatibility.test.js
rename to src/plugins/data_views/server/fetcher/lib/jobs_compatibility.test.js
diff --git a/src/plugins/data/server/data_views/fetcher/lib/jobs_compatibility.ts b/src/plugins/data_views/server/fetcher/lib/jobs_compatibility.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/jobs_compatibility.ts
rename to src/plugins/data_views/server/fetcher/lib/jobs_compatibility.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/map_capabilities.ts b/src/plugins/data_views/server/fetcher/lib/map_capabilities.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/map_capabilities.ts
rename to src/plugins/data_views/server/fetcher/lib/map_capabilities.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/merge_capabilities_with_fields.ts b/src/plugins/data_views/server/fetcher/lib/merge_capabilities_with_fields.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/merge_capabilities_with_fields.ts
rename to src/plugins/data_views/server/fetcher/lib/merge_capabilities_with_fields.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/resolve_time_pattern.test.js b/src/plugins/data_views/server/fetcher/lib/resolve_time_pattern.test.js
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/resolve_time_pattern.test.js
rename to src/plugins/data_views/server/fetcher/lib/resolve_time_pattern.test.js
diff --git a/src/plugins/data/server/data_views/fetcher/lib/resolve_time_pattern.ts b/src/plugins/data_views/server/fetcher/lib/resolve_time_pattern.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/resolve_time_pattern.ts
rename to src/plugins/data_views/server/fetcher/lib/resolve_time_pattern.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/time_pattern_to_wildcard.test.ts b/src/plugins/data_views/server/fetcher/lib/time_pattern_to_wildcard.test.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/time_pattern_to_wildcard.test.ts
rename to src/plugins/data_views/server/fetcher/lib/time_pattern_to_wildcard.test.ts
diff --git a/src/plugins/data/server/data_views/fetcher/lib/time_pattern_to_wildcard.ts b/src/plugins/data_views/server/fetcher/lib/time_pattern_to_wildcard.ts
similarity index 100%
rename from src/plugins/data/server/data_views/fetcher/lib/time_pattern_to_wildcard.ts
rename to src/plugins/data_views/server/fetcher/lib/time_pattern_to_wildcard.ts
diff --git a/src/plugins/data/server/data_views/has_user_index_pattern.test.ts b/src/plugins/data_views/server/has_user_index_pattern.test.ts
similarity index 99%
rename from src/plugins/data/server/data_views/has_user_index_pattern.test.ts
rename to src/plugins/data_views/server/has_user_index_pattern.test.ts
index efc149b409375..aeaa64b949dbc 100644
--- a/src/plugins/data/server/data_views/has_user_index_pattern.test.ts
+++ b/src/plugins/data_views/server/has_user_index_pattern.test.ts
@@ -7,7 +7,7 @@
*/
import { hasUserIndexPattern } from './has_user_index_pattern';
-import { elasticsearchServiceMock, savedObjectsClientMock } from '../../../../core/server/mocks';
+import { elasticsearchServiceMock, savedObjectsClientMock } from '../../../core/server/mocks';
describe('hasUserIndexPattern', () => {
const esClient = elasticsearchServiceMock.createScopedClusterClient().asCurrentUser;
diff --git a/src/plugins/data/server/data_views/has_user_index_pattern.ts b/src/plugins/data_views/server/has_user_index_pattern.ts
similarity index 91%
rename from src/plugins/data/server/data_views/has_user_index_pattern.ts
rename to src/plugins/data_views/server/has_user_index_pattern.ts
index 97abd0892b836..6566f75ebc52e 100644
--- a/src/plugins/data/server/data_views/has_user_index_pattern.ts
+++ b/src/plugins/data_views/server/has_user_index_pattern.ts
@@ -6,9 +6,9 @@
* Side Public License, v 1.
*/
-import { ElasticsearchClient, SavedObjectsClientContract } from '../../../../core/server';
-import { IndexPatternSavedObjectAttrs } from '../../common/data_views/data_views';
-import { FLEET_ASSETS_TO_IGNORE } from '../../common/data_views/constants';
+import { ElasticsearchClient, SavedObjectsClientContract } from '../../../core/server';
+import { IndexPatternSavedObjectAttrs } from '../common/data_views';
+import { FLEET_ASSETS_TO_IGNORE } from '../common/constants';
interface Deps {
esClient: ElasticsearchClient;
diff --git a/src/plugins/data_views/server/index.ts b/src/plugins/data_views/server/index.ts
new file mode 100644
index 0000000000000..1c7eeb073bbe2
--- /dev/null
+++ b/src/plugins/data_views/server/index.ts
@@ -0,0 +1,37 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export { getFieldByName, findIndexPatternById } from './utils';
+export {
+ IndexPatternsFetcher,
+ FieldDescriptor,
+ shouldReadFieldFromDocValues,
+ mergeCapabilitiesWithFields,
+ getCapabilitiesForRollupIndices,
+} from './fetcher';
+export { IndexPatternsServiceStart } from './types';
+
+import { PluginInitializerContext } from 'src/core/server';
+import { DataViewsServerPlugin } from './plugin';
+import { DataViewsServerPluginSetup, DataViewsServerPluginStart } from './types';
+export type { dataViewsServiceFactory } from './data_views_service_factory';
+
+/**
+ * Static code to be shared externally
+ * @public
+ */
+
+export function plugin(initializerContext: PluginInitializerContext) {
+ return new DataViewsServerPlugin(initializerContext);
+}
+
+export {
+ DataViewsServerPlugin as Plugin,
+ DataViewsServerPluginSetup as PluginSetup,
+ DataViewsServerPluginStart as PluginStart,
+};
diff --git a/src/plugins/data/server/data_views/index_patterns_api_client.ts b/src/plugins/data_views/server/index_patterns_api_client.ts
similarity index 94%
rename from src/plugins/data/server/data_views/index_patterns_api_client.ts
rename to src/plugins/data_views/server/index_patterns_api_client.ts
index 4f71bf218dd4d..26ccdd7e02b4c 100644
--- a/src/plugins/data/server/data_views/index_patterns_api_client.ts
+++ b/src/plugins/data_views/server/index_patterns_api_client.ts
@@ -11,8 +11,8 @@ import {
GetFieldsOptions,
IIndexPatternsApiClient,
GetFieldsOptionsTimePattern,
-} from '../../common/data_views/types';
-import { DataViewMissingIndices } from '../../common/data_views/lib';
+} from '../common/types';
+import { DataViewMissingIndices } from '../common/lib';
import { IndexPatternsFetcher } from './fetcher';
import { hasUserIndexPattern } from './has_user_index_pattern';
diff --git a/src/plugins/data_views/server/mocks.ts b/src/plugins/data_views/server/mocks.ts
new file mode 100644
index 0000000000000..70a582810a1e2
--- /dev/null
+++ b/src/plugins/data_views/server/mocks.ts
@@ -0,0 +1,15 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+export function createIndexPatternsStartMock() {
+ const dataViewsServiceFactory = jest.fn().mockResolvedValue({ get: jest.fn() });
+ return {
+ indexPatternsServiceFactory: dataViewsServiceFactory,
+ dataViewsServiceFactory,
+ };
+}
diff --git a/src/plugins/data_views/server/plugin.ts b/src/plugins/data_views/server/plugin.ts
new file mode 100644
index 0000000000000..7285e74847e58
--- /dev/null
+++ b/src/plugins/data_views/server/plugin.ts
@@ -0,0 +1,74 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from 'src/core/server';
+import { dataViewsServiceFactory } from './data_views_service_factory';
+import { registerRoutes } from './routes';
+import { dataViewSavedObjectType } from './saved_objects';
+import { capabilitiesProvider } from './capabilities_provider';
+import { getIndexPatternLoad } from './expressions';
+import { registerIndexPatternsUsageCollector } from './register_index_pattern_usage_collection';
+import { createScriptedFieldsDeprecationsConfig } from './deprecations';
+import {
+ DataViewsServerPluginSetup,
+ DataViewsServerPluginStart,
+ DataViewsServerPluginSetupDependencies,
+ DataViewsServerPluginStartDependencies,
+} from './types';
+
+export class DataViewsServerPlugin
+ implements
+ Plugin<
+ DataViewsServerPluginSetup,
+ DataViewsServerPluginStart,
+ DataViewsServerPluginSetupDependencies,
+ DataViewsServerPluginStartDependencies
+ >
+{
+ private readonly logger: Logger;
+
+ constructor(initializerContext: PluginInitializerContext) {
+ this.logger = initializerContext.logger.get('dataView');
+ }
+
+ public setup(
+ core: CoreSetup,
+ { expressions, usageCollection }: DataViewsServerPluginSetupDependencies
+ ) {
+ core.savedObjects.registerType(dataViewSavedObjectType);
+ core.capabilities.registerProvider(capabilitiesProvider);
+
+ registerRoutes(core.http, core.getStartServices);
+
+ expressions.registerFunction(getIndexPatternLoad({ getStartServices: core.getStartServices }));
+ registerIndexPatternsUsageCollector(core.getStartServices, usageCollection);
+ core.deprecations.registerDeprecations(createScriptedFieldsDeprecationsConfig(core));
+
+ return {};
+ }
+
+ public start(
+ { uiSettings }: CoreStart,
+ { fieldFormats }: DataViewsServerPluginStartDependencies
+ ) {
+ const serviceFactory = dataViewsServiceFactory({
+ logger: this.logger.get('indexPatterns'),
+ uiSettings,
+ fieldFormats,
+ });
+
+ return {
+ indexPatternsServiceFactory: serviceFactory,
+ dataViewsServiceFactory: serviceFactory,
+ };
+ }
+
+ public stop() {}
+}
+
+export { DataViewsServerPlugin as Plugin };
diff --git a/src/plugins/data/server/data_views/register_index_pattern_usage_collection.test.ts b/src/plugins/data_views/server/register_index_pattern_usage_collection.test.ts
similarity index 98%
rename from src/plugins/data/server/data_views/register_index_pattern_usage_collection.test.ts
rename to src/plugins/data_views/server/register_index_pattern_usage_collection.test.ts
index 2c826185757d6..01d3a574a58cb 100644
--- a/src/plugins/data/server/data_views/register_index_pattern_usage_collection.test.ts
+++ b/src/plugins/data_views/server/register_index_pattern_usage_collection.test.ts
@@ -12,7 +12,7 @@ import {
updateMax,
getIndexPatternTelemetry,
} from './register_index_pattern_usage_collection';
-import { IndexPatternsCommonService } from '..';
+import { DataViewsService } from '../common';
const scriptA = 'emit(0);';
const scriptB = 'emit(1);\nemit(2);';
@@ -32,7 +32,7 @@ const indexPatterns = {
getScriptedFields: () => [],
fields: [],
}),
-} as any as IndexPatternsCommonService;
+} as any as DataViewsService;
describe('index pattern usage collection', () => {
it('minMaxAvgLoC calculates min, max, and average ', () => {
diff --git a/src/plugins/data/server/data_views/register_index_pattern_usage_collection.ts b/src/plugins/data_views/server/register_index_pattern_usage_collection.ts
similarity index 90%
rename from src/plugins/data/server/data_views/register_index_pattern_usage_collection.ts
rename to src/plugins/data_views/server/register_index_pattern_usage_collection.ts
index 36c2a59ce2753..6af2f6df6725e 100644
--- a/src/plugins/data/server/data_views/register_index_pattern_usage_collection.ts
+++ b/src/plugins/data_views/server/register_index_pattern_usage_collection.ts
@@ -8,9 +8,9 @@
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { StartServicesAccessor } from 'src/core/server';
-import { IndexPatternsCommonService } from '..';
-import { SavedObjectsClient } from '../../../../core/server';
-import { DataPluginStartDependencies, DataPluginStart } from '../plugin';
+import { DataViewsService } from '../common';
+import { SavedObjectsClient } from '../../../core/server';
+import { DataViewsServerPluginStartDependencies, DataViewsServerPluginStart } from './types';
interface CountSummary {
min?: number;
@@ -57,7 +57,7 @@ export const updateMax = (currentMax: number | undefined, newVal: number): numbe
}
};
-export async function getIndexPatternTelemetry(indexPatterns: IndexPatternsCommonService) {
+export async function getIndexPatternTelemetry(indexPatterns: DataViewsService) {
const ids = await indexPatterns.getIds();
const countSummaryDefaults: CountSummary = {
@@ -139,7 +139,10 @@ export async function getIndexPatternTelemetry(indexPatterns: IndexPatternsCommo
}
export function registerIndexPatternsUsageCollector(
- getStartServices: StartServicesAccessor,
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >,
usageCollection?: UsageCollectionSetup
): void {
if (!usageCollection) {
@@ -150,8 +153,9 @@ export function registerIndexPatternsUsageCollector(
type: 'index-patterns',
isReady: () => true,
fetch: async () => {
- const [{ savedObjects, elasticsearch }, , { indexPatterns }] = await getStartServices();
- const indexPatternService = await indexPatterns.indexPatternsServiceFactory(
+ const [{ savedObjects, elasticsearch }, , { indexPatternsServiceFactory }] =
+ await getStartServices();
+ const indexPatternService = await indexPatternsServiceFactory(
new SavedObjectsClient(savedObjects.createInternalRepository()),
elasticsearch.client.asInternalUser
);
diff --git a/src/plugins/data/server/data_views/routes.ts b/src/plugins/data_views/server/routes.ts
similarity index 96%
rename from src/plugins/data/server/data_views/routes.ts
rename to src/plugins/data_views/server/routes.ts
index 9488285fc7e2c..48c359cd9d852 100644
--- a/src/plugins/data/server/data_views/routes.ts
+++ b/src/plugins/data_views/server/routes.ts
@@ -19,7 +19,7 @@ import { registerPutScriptedFieldRoute } from './routes/scripted_fields/put_scri
import { registerGetScriptedFieldRoute } from './routes/scripted_fields/get_scripted_field';
import { registerDeleteScriptedFieldRoute } from './routes/scripted_fields/delete_scripted_field';
import { registerUpdateScriptedFieldRoute } from './routes/scripted_fields/update_scripted_field';
-import type { DataPluginStart, DataPluginStartDependencies } from '../plugin';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from './types';
import { registerManageDefaultIndexPatternRoutes } from './routes/default_index_pattern';
import { registerCreateRuntimeFieldRoute } from './routes/runtime_fields/create_runtime_field';
import { registerGetRuntimeFieldRoute } from './routes/runtime_fields/get_runtime_field';
@@ -30,7 +30,10 @@ import { registerHasUserIndexPatternRoute } from './routes/has_user_index_patter
export function registerRoutes(
http: HttpServiceSetup,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) {
const parseMetaFields = (metaFields: string | string[]) => {
let parsedFields: string[] = [];
diff --git a/src/plugins/data/server/data_views/routes/create_index_pattern.ts b/src/plugins/data_views/server/routes/create_index_pattern.ts
similarity index 84%
rename from src/plugins/data/server/data_views/routes/create_index_pattern.ts
rename to src/plugins/data_views/server/routes/create_index_pattern.ts
index 7049903f84e8c..b87b03f8bd4a1 100644
--- a/src/plugins/data/server/data_views/routes/create_index_pattern.ts
+++ b/src/plugins/data_views/server/routes/create_index_pattern.ts
@@ -7,15 +7,15 @@
*/
import { schema } from '@kbn/config-schema';
-import { IndexPatternSpec } from 'src/plugins/data/common';
+import { IndexPatternSpec } from 'src/plugins/data_views/common';
import { handleErrors } from './util/handle_errors';
import {
fieldSpecSchema,
runtimeFieldSpecSchema,
serializedFieldFormatSchema,
} from './util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../core/server';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
const indexPatternSpecSchema = schema.object({
title: schema.string(),
@@ -48,7 +48,10 @@ const indexPatternSpecSchema = schema.object({
export const registerCreateIndexPatternRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -65,8 +68,8 @@ export const registerCreateIndexPatternRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/default_index_pattern.ts b/src/plugins/data_views/server/routes/default_index_pattern.ts
similarity index 76%
rename from src/plugins/data/server/data_views/routes/default_index_pattern.ts
rename to src/plugins/data_views/server/routes/default_index_pattern.ts
index cf5986943eb37..620e201a4850d 100644
--- a/src/plugins/data/server/data_views/routes/default_index_pattern.ts
+++ b/src/plugins/data_views/server/routes/default_index_pattern.ts
@@ -7,13 +7,16 @@
*/
import { schema } from '@kbn/config-schema';
-import { IRouter, StartServicesAccessor } from '../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../core/server';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
import { handleErrors } from './util/handle_errors';
export const registerManageDefaultIndexPatternRoutes = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.get(
{
@@ -23,8 +26,8 @@ export const registerManageDefaultIndexPatternRoutes = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
@@ -57,8 +60,8 @@ export const registerManageDefaultIndexPatternRoutes = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/delete_index_pattern.ts b/src/plugins/data_views/server/routes/delete_index_pattern.ts
similarity index 75%
rename from src/plugins/data/server/data_views/routes/delete_index_pattern.ts
rename to src/plugins/data_views/server/routes/delete_index_pattern.ts
index 14de079470dcb..0d3f929cdccc3 100644
--- a/src/plugins/data/server/data_views/routes/delete_index_pattern.ts
+++ b/src/plugins/data_views/server/routes/delete_index_pattern.ts
@@ -8,12 +8,15 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from './util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../core/server';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
export const registerDeleteIndexPatternRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.delete(
{
@@ -34,8 +37,8 @@ export const registerDeleteIndexPatternRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/fields/update_fields.ts b/src/plugins/data_views/server/routes/fields/update_fields.ts
similarity index 87%
rename from src/plugins/data/server/data_views/routes/fields/update_fields.ts
rename to src/plugins/data_views/server/routes/fields/update_fields.ts
index a510fdaa6e1d8..3e45ee46f2bb7 100644
--- a/src/plugins/data/server/data_views/routes/fields/update_fields.ts
+++ b/src/plugins/data_views/server/routes/fields/update_fields.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from '../util/handle_errors';
import { serializedFieldFormatSchema } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerUpdateFieldsRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -55,8 +61,8 @@ export const registerUpdateFieldsRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/get_index_pattern.ts b/src/plugins/data_views/server/routes/get_index_pattern.ts
similarity index 76%
rename from src/plugins/data/server/data_views/routes/get_index_pattern.ts
rename to src/plugins/data_views/server/routes/get_index_pattern.ts
index 268fd3da8cd6a..7fea748ca3389 100644
--- a/src/plugins/data/server/data_views/routes/get_index_pattern.ts
+++ b/src/plugins/data_views/server/routes/get_index_pattern.ts
@@ -8,12 +8,15 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from './util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../core/server';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
export const registerGetIndexPatternRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.get(
{
@@ -34,8 +37,8 @@ export const registerGetIndexPatternRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/has_user_index_pattern.ts b/src/plugins/data_views/server/routes/has_user_index_pattern.ts
similarity index 69%
rename from src/plugins/data/server/data_views/routes/has_user_index_pattern.ts
rename to src/plugins/data_views/server/routes/has_user_index_pattern.ts
index 7d67e96f39f6e..af0ad1cc88d2e 100644
--- a/src/plugins/data/server/data_views/routes/has_user_index_pattern.ts
+++ b/src/plugins/data_views/server/routes/has_user_index_pattern.ts
@@ -7,12 +7,15 @@
*/
import { handleErrors } from './util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../core/server';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
export const registerHasUserIndexPatternRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.get(
{
@@ -23,8 +26,8 @@ export const registerHasUserIndexPatternRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/runtime_fields/create_runtime_field.ts b/src/plugins/data_views/server/routes/runtime_fields/create_runtime_field.ts
similarity index 82%
rename from src/plugins/data/server/data_views/routes/runtime_fields/create_runtime_field.ts
rename to src/plugins/data_views/server/routes/runtime_fields/create_runtime_field.ts
index faf6d87b6d10b..04b661d14732f 100644
--- a/src/plugins/data/server/data_views/routes/runtime_fields/create_runtime_field.ts
+++ b/src/plugins/data_views/server/routes/runtime_fields/create_runtime_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from '../util/handle_errors';
import { runtimeFieldSpecSchema } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerCreateRuntimeFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -39,8 +45,8 @@ export const registerCreateRuntimeFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/runtime_fields/delete_runtime_field.ts b/src/plugins/data_views/server/routes/runtime_fields/delete_runtime_field.ts
similarity index 79%
rename from src/plugins/data/server/data_views/routes/runtime_fields/delete_runtime_field.ts
rename to src/plugins/data_views/server/routes/runtime_fields/delete_runtime_field.ts
index 58b8529d7cf5a..e5c6b03a64224 100644
--- a/src/plugins/data/server/data_views/routes/runtime_fields/delete_runtime_field.ts
+++ b/src/plugins/data_views/server/routes/runtime_fields/delete_runtime_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { ErrorIndexPatternFieldNotFound } from '../../error';
import { handleErrors } from '../util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerDeleteRuntimeFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.delete(
{
@@ -35,8 +41,8 @@ export const registerDeleteRuntimeFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/runtime_fields/get_runtime_field.ts b/src/plugins/data_views/server/routes/runtime_fields/get_runtime_field.ts
similarity index 79%
rename from src/plugins/data/server/data_views/routes/runtime_fields/get_runtime_field.ts
rename to src/plugins/data_views/server/routes/runtime_fields/get_runtime_field.ts
index 6bc2bf396c0b4..b457ae6b0159b 100644
--- a/src/plugins/data/server/data_views/routes/runtime_fields/get_runtime_field.ts
+++ b/src/plugins/data_views/server/routes/runtime_fields/get_runtime_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { ErrorIndexPatternFieldNotFound } from '../../error';
import { handleErrors } from '../util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerGetRuntimeFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.get(
{
@@ -36,8 +42,8 @@ export const registerGetRuntimeFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/runtime_fields/put_runtime_field.ts b/src/plugins/data_views/server/routes/runtime_fields/put_runtime_field.ts
similarity index 82%
rename from src/plugins/data/server/data_views/routes/runtime_fields/put_runtime_field.ts
rename to src/plugins/data_views/server/routes/runtime_fields/put_runtime_field.ts
index a5e92fa5a36ec..1c3ed99fdf67e 100644
--- a/src/plugins/data/server/data_views/routes/runtime_fields/put_runtime_field.ts
+++ b/src/plugins/data_views/server/routes/runtime_fields/put_runtime_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from '../util/handle_errors';
import { runtimeFieldSpecSchema } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerPutRuntimeFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.put(
{
@@ -38,8 +44,8 @@ export const registerPutRuntimeFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/runtime_fields/update_runtime_field.ts b/src/plugins/data_views/server/routes/runtime_fields/update_runtime_field.ts
similarity index 83%
rename from src/plugins/data/server/data_views/routes/runtime_fields/update_runtime_field.ts
rename to src/plugins/data_views/server/routes/runtime_fields/update_runtime_field.ts
index 3f3aae46c4388..ca92f310ff281 100644
--- a/src/plugins/data/server/data_views/routes/runtime_fields/update_runtime_field.ts
+++ b/src/plugins/data_views/server/routes/runtime_fields/update_runtime_field.ts
@@ -7,16 +7,22 @@
*/
import { schema } from '@kbn/config-schema';
-import { RuntimeField } from 'src/plugins/data/common';
+import { RuntimeField } from 'src/plugins/data_views/common';
import { ErrorIndexPatternFieldNotFound } from '../../error';
import { handleErrors } from '../util/handle_errors';
import { runtimeFieldSpec, runtimeFieldSpecTypeSchema } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerUpdateRuntimeFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -46,8 +52,8 @@ export const registerUpdateRuntimeFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/scripted_fields/create_scripted_field.ts b/src/plugins/data_views/server/routes/scripted_fields/create_scripted_field.ts
similarity index 83%
rename from src/plugins/data/server/data_views/routes/scripted_fields/create_scripted_field.ts
rename to src/plugins/data_views/server/routes/scripted_fields/create_scripted_field.ts
index 4d7b1d87cd9eb..e620960afbe13 100644
--- a/src/plugins/data/server/data_views/routes/scripted_fields/create_scripted_field.ts
+++ b/src/plugins/data_views/server/routes/scripted_fields/create_scripted_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from '../util/handle_errors';
import { fieldSpecSchema } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerCreateScriptedFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -38,8 +44,8 @@ export const registerCreateScriptedFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/scripted_fields/delete_scripted_field.ts b/src/plugins/data_views/server/routes/scripted_fields/delete_scripted_field.ts
similarity index 81%
rename from src/plugins/data/server/data_views/routes/scripted_fields/delete_scripted_field.ts
rename to src/plugins/data_views/server/routes/scripted_fields/delete_scripted_field.ts
index 169351c220ecf..bd1bfe0ec4e25 100644
--- a/src/plugins/data/server/data_views/routes/scripted_fields/delete_scripted_field.ts
+++ b/src/plugins/data_views/server/routes/scripted_fields/delete_scripted_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { ErrorIndexPatternFieldNotFound } from '../../error';
import { handleErrors } from '../util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerDeleteScriptedFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.delete(
{
@@ -39,8 +45,8 @@ export const registerDeleteScriptedFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/scripted_fields/get_scripted_field.ts b/src/plugins/data_views/server/routes/scripted_fields/get_scripted_field.ts
similarity index 81%
rename from src/plugins/data/server/data_views/routes/scripted_fields/get_scripted_field.ts
rename to src/plugins/data_views/server/routes/scripted_fields/get_scripted_field.ts
index 28f3f75a7aa1b..ae9cca2c79b48 100644
--- a/src/plugins/data/server/data_views/routes/scripted_fields/get_scripted_field.ts
+++ b/src/plugins/data_views/server/routes/scripted_fields/get_scripted_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { ErrorIndexPatternFieldNotFound } from '../../error';
import { handleErrors } from '../util/handle_errors';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerGetScriptedFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.get(
{
@@ -39,8 +45,8 @@ export const registerGetScriptedFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/scripted_fields/put_scripted_field.ts b/src/plugins/data_views/server/routes/scripted_fields/put_scripted_field.ts
similarity index 83%
rename from src/plugins/data/server/data_views/routes/scripted_fields/put_scripted_field.ts
rename to src/plugins/data_views/server/routes/scripted_fields/put_scripted_field.ts
index 368ad53eb2258..a6cee3762513e 100644
--- a/src/plugins/data/server/data_views/routes/scripted_fields/put_scripted_field.ts
+++ b/src/plugins/data_views/server/routes/scripted_fields/put_scripted_field.ts
@@ -9,12 +9,18 @@
import { schema } from '@kbn/config-schema';
import { handleErrors } from '../util/handle_errors';
import { fieldSpecSchema } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerPutScriptedFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.put(
{
@@ -38,8 +44,8 @@ export const registerPutScriptedFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/scripted_fields/update_scripted_field.ts b/src/plugins/data_views/server/routes/scripted_fields/update_scripted_field.ts
similarity index 86%
rename from src/plugins/data/server/data_views/routes/scripted_fields/update_scripted_field.ts
rename to src/plugins/data_views/server/routes/scripted_fields/update_scripted_field.ts
index bf10a3ee6389e..2917838293ec8 100644
--- a/src/plugins/data/server/data_views/routes/scripted_fields/update_scripted_field.ts
+++ b/src/plugins/data_views/server/routes/scripted_fields/update_scripted_field.ts
@@ -7,16 +7,22 @@
*/
import { schema } from '@kbn/config-schema';
-import { FieldSpec } from 'src/plugins/data/common';
+import { FieldSpec } from 'src/plugins/data_views/common';
import { ErrorIndexPatternFieldNotFound } from '../../error';
import { handleErrors } from '../util/handle_errors';
import { fieldSpecSchemaFields } from '../util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../../core/server';
+import type {
+ DataViewsServerPluginStart,
+ DataViewsServerPluginStartDependencies,
+} from '../../types';
export const registerUpdateScriptedFieldRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -59,8 +65,8 @@ export const registerUpdateScriptedFieldRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/update_index_pattern.ts b/src/plugins/data_views/server/routes/update_index_pattern.ts
similarity index 91%
rename from src/plugins/data/server/data_views/routes/update_index_pattern.ts
rename to src/plugins/data_views/server/routes/update_index_pattern.ts
index 1c88550c154c5..1421057d65d26 100644
--- a/src/plugins/data/server/data_views/routes/update_index_pattern.ts
+++ b/src/plugins/data_views/server/routes/update_index_pattern.ts
@@ -13,8 +13,8 @@ import {
runtimeFieldSpecSchema,
serializedFieldFormatSchema,
} from './util/schemas';
-import { IRouter, StartServicesAccessor } from '../../../../../core/server';
-import type { DataPluginStart, DataPluginStartDependencies } from '../../plugin';
+import { IRouter, StartServicesAccessor } from '../../../../core/server';
+import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types';
const indexPatternUpdateSchema = schema.object({
title: schema.maybe(schema.string()),
@@ -37,7 +37,10 @@ const indexPatternUpdateSchema = schema.object({
export const registerUpdateIndexPatternRoute = (
router: IRouter,
- getStartServices: StartServicesAccessor
+ getStartServices: StartServicesAccessor<
+ DataViewsServerPluginStartDependencies,
+ DataViewsServerPluginStart
+ >
) => {
router.post(
{
@@ -62,8 +65,8 @@ export const registerUpdateIndexPatternRoute = (
handleErrors(async (ctx, req, res) => {
const savedObjectsClient = ctx.core.savedObjects.client;
const elasticsearchClient = ctx.core.elasticsearch.client.asCurrentUser;
- const [, , { indexPatterns }] = await getStartServices();
- const indexPatternsService = await indexPatterns.indexPatternsServiceFactory(
+ const [, , { indexPatternsServiceFactory }] = await getStartServices();
+ const indexPatternsService = await indexPatternsServiceFactory(
savedObjectsClient,
elasticsearchClient
);
diff --git a/src/plugins/data/server/data_views/routes/util/handle_errors.ts b/src/plugins/data_views/server/routes/util/handle_errors.ts
similarity index 100%
rename from src/plugins/data/server/data_views/routes/util/handle_errors.ts
rename to src/plugins/data_views/server/routes/util/handle_errors.ts
diff --git a/src/plugins/data/server/data_views/routes/util/schemas.ts b/src/plugins/data_views/server/routes/util/schemas.ts
similarity index 96%
rename from src/plugins/data/server/data_views/routes/util/schemas.ts
rename to src/plugins/data_views/server/routes/util/schemas.ts
index 79ee1ffa1ab97..79f493f303801 100644
--- a/src/plugins/data/server/data_views/routes/util/schemas.ts
+++ b/src/plugins/data_views/server/routes/util/schemas.ts
@@ -7,7 +7,7 @@
*/
import { schema, Type } from '@kbn/config-schema';
-import { RUNTIME_FIELD_TYPES, RuntimeType } from '../../../../common';
+import { RUNTIME_FIELD_TYPES, RuntimeType } from '../../../common';
export const serializedFieldFormatSchema = schema.object({
id: schema.maybe(schema.string()),
diff --git a/src/plugins/data/server/saved_objects/index_patterns.ts b/src/plugins/data_views/server/saved_objects/data_views.ts
similarity index 88%
rename from src/plugins/data/server/saved_objects/index_patterns.ts
rename to src/plugins/data_views/server/saved_objects/data_views.ts
index a809f2ce73e1b..d340732873235 100644
--- a/src/plugins/data/server/saved_objects/index_patterns.ts
+++ b/src/plugins/data_views/server/saved_objects/data_views.ts
@@ -8,10 +8,10 @@
import type { SavedObjectsType } from 'kibana/server';
import { indexPatternSavedObjectTypeMigrations } from './index_pattern_migrations';
-import { INDEX_PATTERN_SAVED_OBJECT_TYPE } from '../../common';
+import { DATA_VIEW_SAVED_OBJECT_TYPE } from '../../common';
-export const indexPatternSavedObjectType: SavedObjectsType = {
- name: INDEX_PATTERN_SAVED_OBJECT_TYPE,
+export const dataViewSavedObjectType: SavedObjectsType = {
+ name: DATA_VIEW_SAVED_OBJECT_TYPE,
hidden: false,
namespaceType: 'single',
management: {
diff --git a/src/plugins/data/common/utils/index.ts b/src/plugins/data_views/server/saved_objects/index.ts
similarity index 81%
rename from src/plugins/data/common/utils/index.ts
rename to src/plugins/data_views/server/saved_objects/index.ts
index e07fd18594471..ff0f524ae961c 100644
--- a/src/plugins/data/common/utils/index.ts
+++ b/src/plugins/data_views/server/saved_objects/index.ts
@@ -6,5 +6,4 @@
* Side Public License, v 1.
*/
-/** @internal */
-export { shortenDottedString } from './shorten_dotted_string';
+export { dataViewSavedObjectType } from './data_views';
diff --git a/src/plugins/data/server/saved_objects/index_pattern_migrations.test.ts b/src/plugins/data_views/server/saved_objects/index_pattern_migrations.test.ts
similarity index 100%
rename from src/plugins/data/server/saved_objects/index_pattern_migrations.test.ts
rename to src/plugins/data_views/server/saved_objects/index_pattern_migrations.test.ts
diff --git a/src/plugins/data/server/saved_objects/index_pattern_migrations.ts b/src/plugins/data_views/server/saved_objects/index_pattern_migrations.ts
similarity index 100%
rename from src/plugins/data/server/saved_objects/index_pattern_migrations.ts
rename to src/plugins/data_views/server/saved_objects/index_pattern_migrations.ts
diff --git a/src/plugins/data/common/utils/shorten_dotted_string.ts b/src/plugins/data_views/server/saved_objects/migrations/to_v7_12_0.ts
similarity index 57%
rename from src/plugins/data/common/utils/shorten_dotted_string.ts
rename to src/plugins/data_views/server/saved_objects/migrations/to_v7_12_0.ts
index 53f7471913dc3..955028c0f9bf2 100644
--- a/src/plugins/data/common/utils/shorten_dotted_string.ts
+++ b/src/plugins/data_views/server/saved_objects/migrations/to_v7_12_0.ts
@@ -6,14 +6,12 @@
* Side Public License, v 1.
*/
-const DOT_PREFIX_RE = /(.).+?\./g;
+import type { SavedObjectMigrationFn } from 'kibana/server';
/**
- * Convert a dot.notated.string into a short
- * version (d.n.string)
- *
- * @return {any}
+ * Drop the previous document's attributes, which report `averageDuration` incorrectly.
+ * @param doc
*/
-export function shortenDottedString(input: any) {
- return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
-}
+export const migrate712: SavedObjectMigrationFn = (doc) => {
+ return { ...doc, attributes: {} };
+};
diff --git a/src/plugins/data/server/data_views/saved_objects_client_wrapper.test.ts b/src/plugins/data_views/server/saved_objects_client_wrapper.test.ts
similarity index 96%
rename from src/plugins/data/server/data_views/saved_objects_client_wrapper.test.ts
rename to src/plugins/data_views/server/saved_objects_client_wrapper.test.ts
index bbe857894b3f0..b03532421ecab 100644
--- a/src/plugins/data/server/data_views/saved_objects_client_wrapper.test.ts
+++ b/src/plugins/data_views/server/saved_objects_client_wrapper.test.ts
@@ -9,7 +9,7 @@
import { SavedObjectsClientServerToCommon } from './saved_objects_client_wrapper';
import { SavedObjectsClientContract } from 'src/core/server';
-import { DataViewSavedObjectConflictError } from '../../common/data_views';
+import { DataViewSavedObjectConflictError } from '../common';
describe('SavedObjectsClientPublicToCommon', () => {
const soClient = { resolve: jest.fn() } as unknown as SavedObjectsClientContract;
diff --git a/src/plugins/data/server/data_views/saved_objects_client_wrapper.ts b/src/plugins/data_views/server/saved_objects_client_wrapper.ts
similarity index 98%
rename from src/plugins/data/server/data_views/saved_objects_client_wrapper.ts
rename to src/plugins/data_views/server/saved_objects_client_wrapper.ts
index b37648a3f038e..dc7163c405d4f 100644
--- a/src/plugins/data/server/data_views/saved_objects_client_wrapper.ts
+++ b/src/plugins/data_views/server/saved_objects_client_wrapper.ts
@@ -11,7 +11,7 @@ import {
SavedObjectsClientCommon,
SavedObjectsClientCommonFindArgs,
DataViewSavedObjectConflictError,
-} from '../../common/data_views';
+} from '../common';
export class SavedObjectsClientServerToCommon implements SavedObjectsClientCommon {
private savedObjectClient: SavedObjectsClientContract;
diff --git a/src/plugins/data_views/server/types.ts b/src/plugins/data_views/server/types.ts
new file mode 100644
index 0000000000000..4a57a1d01b9c3
--- /dev/null
+++ b/src/plugins/data_views/server/types.ts
@@ -0,0 +1,51 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+import { Logger, SavedObjectsClientContract, ElasticsearchClient } from 'kibana/server';
+import { ExpressionsServerSetup } from 'src/plugins/expressions/server';
+import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
+import { DataViewsService } from '../common';
+import { FieldFormatsSetup, FieldFormatsStart } from '../../field_formats/server';
+
+type ServiceFactory = (
+ savedObjectsClient: SavedObjectsClientContract,
+ elasticsearchClient: ElasticsearchClient
+) => Promise;
+export interface DataViewsServerPluginStart {
+ dataViewsServiceFactory: ServiceFactory;
+ /**
+ * @deprecated Renamed to dataViewsServiceFactory
+ */
+ indexPatternsServiceFactory: ServiceFactory;
+}
+
+export interface IndexPatternsServiceSetupDeps {
+ expressions: ExpressionsServerSetup;
+ usageCollection?: UsageCollectionSetup;
+}
+
+export interface IndexPatternsServiceStartDeps {
+ fieldFormats: FieldFormatsStart;
+ logger: Logger;
+}
+
+// eslint-disable-next-line @typescript-eslint/no-empty-interface
+export interface DataViewsServerPluginSetup {}
+
+export type IndexPatternsServiceStart = DataViewsServerPluginStart;
+
+export interface DataViewsServerPluginSetupDependencies {
+ fieldFormats: FieldFormatsSetup;
+ expressions: ExpressionsServerSetup;
+ usageCollection?: UsageCollectionSetup;
+}
+
+export interface DataViewsServerPluginStartDependencies {
+ fieldFormats: FieldFormatsStart;
+ logger: Logger;
+}
diff --git a/src/plugins/data/server/data_views/ui_settings_wrapper.ts b/src/plugins/data_views/server/ui_settings_wrapper.ts
similarity index 95%
rename from src/plugins/data/server/data_views/ui_settings_wrapper.ts
rename to src/plugins/data_views/server/ui_settings_wrapper.ts
index dce552205db2e..f42d43c1c24f4 100644
--- a/src/plugins/data/server/data_views/ui_settings_wrapper.ts
+++ b/src/plugins/data_views/server/ui_settings_wrapper.ts
@@ -7,7 +7,7 @@
*/
import { IUiSettingsClient } from 'src/core/server';
-import { UiSettingsCommon } from '../../common';
+import { UiSettingsCommon } from '../common';
export class UiSettingsServerToCommon implements UiSettingsCommon {
private uiSettings: IUiSettingsClient;
diff --git a/src/plugins/data/server/data_views/utils.ts b/src/plugins/data_views/server/utils.ts
similarity index 92%
rename from src/plugins/data/server/data_views/utils.ts
rename to src/plugins/data_views/server/utils.ts
index 7f1a953c482d0..bb7d23f832233 100644
--- a/src/plugins/data/server/data_views/utils.ts
+++ b/src/plugins/data_views/server/utils.ts
@@ -9,10 +9,10 @@
import { SavedObjectsClientContract } from 'kibana/server';
import {
IFieldType,
- INDEX_PATTERN_SAVED_OBJECT_TYPE,
+ DATA_VIEW_SAVED_OBJECT_TYPE,
IndexPatternAttributes,
SavedObject,
-} from '../../common';
+} from '../common';
export const getFieldByName = (
fieldName: string,
@@ -29,7 +29,7 @@ export const findIndexPatternById = async (
index: string
): Promise | undefined> => {
const savedObjectsResponse = await savedObjectsClient.find({
- type: INDEX_PATTERN_SAVED_OBJECT_TYPE,
+ type: DATA_VIEW_SAVED_OBJECT_TYPE,
fields: ['fields'],
search: `"${index}"`,
searchFields: ['title'],
diff --git a/src/plugins/data_views/tsconfig.json b/src/plugins/data_views/tsconfig.json
new file mode 100644
index 0000000000000..f5c80ce30cce0
--- /dev/null
+++ b/src/plugins/data_views/tsconfig.json
@@ -0,0 +1,26 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "outDir": "./target/types",
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationMap": true
+ },
+ "include": [
+ "common/**/*",
+ "public/**/*",
+ "server/**/*",
+ "config.ts",
+ "common/**/*.json",
+ "public/**/*.json",
+ "server/**/*.json"
+ ],
+ "references": [
+ { "path": "../../core/tsconfig.json" },
+ { "path": "../usage_collection/tsconfig.json" },
+ { "path": "../kibana_utils/tsconfig.json" },
+ { "path": "../kibana_react/tsconfig.json" },
+ { "path": "../field_formats/tsconfig.json" },
+ { "path": "../expressions/tsconfig.json" }
+ ]
+}
diff --git a/src/plugins/expressions/.eslintrc.json b/src/plugins/expressions/.eslintrc.json
index 2aab6c2d9093b..d1dbca41acc81 100644
--- a/src/plugins/expressions/.eslintrc.json
+++ b/src/plugins/expressions/.eslintrc.json
@@ -1,5 +1,6 @@
{
"rules": {
- "@typescript-eslint/consistent-type-definitions": 0
+ "@typescript-eslint/consistent-type-definitions": 0,
+ "@typescript-eslint/no-explicit-any": ["error", { "ignoreRestArgs": true }]
}
}
diff --git a/src/plugins/expressions/common/ast/build_expression.ts b/src/plugins/expressions/common/ast/build_expression.ts
index 0f4618b3e699c..6e84594022fdf 100644
--- a/src/plugins/expressions/common/ast/build_expression.ts
+++ b/src/plugins/expressions/common/ast/build_expression.ts
@@ -32,13 +32,13 @@ import { parse } from './parse';
* @param val Value you want to check.
* @return boolean
*/
-export function isExpressionAstBuilder(val: any): val is ExpressionAstExpressionBuilder {
- return val?.type === 'expression_builder';
+export function isExpressionAstBuilder(val: unknown): val is ExpressionAstExpressionBuilder {
+ return (val as Record | undefined)?.type === 'expression_builder';
}
/** @internal */
-export function isExpressionAst(val: any): val is ExpressionAstExpression {
- return val?.type === 'expression';
+export function isExpressionAst(val: unknown): val is ExpressionAstExpression {
+ return (val as Record | undefined)?.type === 'expression';
}
export interface ExpressionAstExpressionBuilder {
diff --git a/src/plugins/expressions/common/ast/types.ts b/src/plugins/expressions/common/ast/types.ts
index e5a79a0a5ddaf..8f376ac547d26 100644
--- a/src/plugins/expressions/common/ast/types.ts
+++ b/src/plugins/expressions/common/ast/types.ts
@@ -64,7 +64,7 @@ export type ExpressionAstFunctionDebug = {
/**
* Raw error that was thrown by the function, if any.
*/
- rawError?: any | Error;
+ rawError?: any | Error; // eslint-disable-line @typescript-eslint/no-explicit-any
/**
* Time in milliseconds it took to execute the function. Duration can be
diff --git a/src/plugins/expressions/common/execution/execution.abortion.test.ts b/src/plugins/expressions/common/execution/execution.abortion.test.ts
index 798558ba7ffb6..fca030fb9a080 100644
--- a/src/plugins/expressions/common/execution/execution.abortion.test.ts
+++ b/src/plugins/expressions/common/execution/execution.abortion.test.ts
@@ -90,7 +90,7 @@ describe('Execution abortion tests', () => {
const completed = jest.fn();
const aborted = jest.fn();
- const defer: ExpressionFunctionDefinition<'defer', any, { time: number }, any> = {
+ const defer: ExpressionFunctionDefinition<'defer', unknown, { time: number }, unknown> = {
name: 'defer',
args: {
time: {
diff --git a/src/plugins/expressions/common/execution/execution.test.ts b/src/plugins/expressions/common/execution/execution.test.ts
index c478977f60764..9b889c62e9ff5 100644
--- a/src/plugins/expressions/common/execution/execution.test.ts
+++ b/src/plugins/expressions/common/execution/execution.test.ts
@@ -17,7 +17,7 @@ import { ExecutionContract } from './execution_contract';
beforeAll(() => {
if (typeof performance === 'undefined') {
- (global as any).performance = { now: Date.now };
+ global.performance = { now: Date.now } as typeof performance;
}
});
@@ -41,7 +41,7 @@ const createExecution = (
const run = async (
expression: string = 'foo bar=123',
context?: Record,
- input: any = null
+ input: unknown = null
) => {
const execution = createExecution(expression, context);
execution.start(input);
@@ -262,45 +262,45 @@ describe('Execution', () => {
describe('execution context', () => {
test('context.variables is an object', async () => {
- const { result } = (await run('introspectContext key="variables"')) as any;
+ const { result } = await run('introspectContext key="variables"');
expect(result).toHaveProperty('result', expect.any(Object));
});
test('context.types is an object', async () => {
- const { result } = (await run('introspectContext key="types"')) as any;
+ const { result } = await run('introspectContext key="types"');
expect(result).toHaveProperty('result', expect.any(Object));
});
test('context.abortSignal is an object', async () => {
- const { result } = (await run('introspectContext key="abortSignal"')) as any;
+ const { result } = await run('introspectContext key="abortSignal"');
expect(result).toHaveProperty('result', expect.any(Object));
});
test('context.inspectorAdapters is an object', async () => {
- const { result } = (await run('introspectContext key="inspectorAdapters"')) as any;
+ const { result } = await run('introspectContext key="inspectorAdapters"');
expect(result).toHaveProperty('result', expect.any(Object));
});
test('context.getKibanaRequest is a function if provided', async () => {
- const { result } = (await run('introspectContext key="getKibanaRequest"', {
+ const { result } = await run('introspectContext key="getKibanaRequest"', {
kibanaRequest: {},
- })) as any;
+ });
expect(result).toHaveProperty('result', expect.any(Function));
});
test('context.getKibanaRequest is undefined if not provided', async () => {
- const { result } = (await run('introspectContext key="getKibanaRequest"')) as any;
+ const { result } = await run('introspectContext key="getKibanaRequest"');
expect(result).toHaveProperty('result', undefined);
});
test('unknown context key is undefined', async () => {
- const { result } = (await run('introspectContext key="foo"')) as any;
+ const { result } = await run('introspectContext key="foo"');
expect(result).toHaveProperty('result', undefined);
});
@@ -314,7 +314,7 @@ describe('Execution', () => {
describe('inspector adapters', () => {
test('by default, "tables" and "requests" inspector adapters are available', async () => {
- const { result } = (await run('introspectContext key="inspectorAdapters"')) as any;
+ const { result } = await run('introspectContext key="inspectorAdapters"');
expect(result).toHaveProperty(
'result',
expect.objectContaining({
@@ -326,9 +326,9 @@ describe('Execution', () => {
test('can set custom inspector adapters', async () => {
const inspectorAdapters = {};
- const { result } = (await run('introspectContext key="inspectorAdapters"', {
+ const { result } = await run('introspectContext key="inspectorAdapters"', {
inspectorAdapters,
- })) as any;
+ });
expect(result).toHaveProperty('result', inspectorAdapters);
});
@@ -351,7 +351,7 @@ describe('Execution', () => {
describe('expression abortion', () => {
test('context has abortSignal object', async () => {
- const { result } = (await run('introspectContext key="abortSignal"')) as any;
+ const { result } = await run('introspectContext key="abortSignal"');
expect(result).toHaveProperty('result.aborted', false);
});
@@ -400,7 +400,7 @@ describe('Execution', () => {
testScheduler.run(({ cold, expectObservable }) => {
const arg = cold(' -a-b-c|', { a: 1, b: 2, c: 3 });
const expected = ' -a-b-c|';
- const observable: ExpressionFunctionDefinition<'observable', any, {}, any> = {
+ const observable: ExpressionFunctionDefinition<'observable', unknown, {}, unknown> = {
name: 'observable',
args: {},
help: '',
@@ -468,7 +468,7 @@ describe('Execution', () => {
});
test('does not execute remaining functions in pipeline', async () => {
- const spy: ExpressionFunctionDefinition<'spy', any, {}, any> = {
+ const spy: ExpressionFunctionDefinition<'spy', unknown, {}, unknown> = {
name: 'spy',
args: {},
help: '',
@@ -621,7 +621,12 @@ describe('Execution', () => {
help: '',
fn: () => arg2,
};
- const max: ExpressionFunctionDefinition<'max', any, { val1: number; val2: number }, any> = {
+ const max: ExpressionFunctionDefinition<
+ 'max',
+ unknown,
+ { val1: number; val2: number },
+ unknown
+ > = {
name: 'max',
args: {
val1: { help: '', types: ['number'] },
@@ -679,7 +684,12 @@ describe('Execution', () => {
describe('when arguments are missing', () => {
it('when required argument is missing and has not alias, returns error', async () => {
- const requiredArg: ExpressionFunctionDefinition<'requiredArg', any, { arg: any }, any> = {
+ const requiredArg: ExpressionFunctionDefinition<
+ 'requiredArg',
+ unknown,
+ { arg: unknown },
+ unknown
+ > = {
name: 'requiredArg',
args: {
arg: {
diff --git a/src/plugins/expressions/common/execution/execution.ts b/src/plugins/expressions/common/execution/execution.ts
index 0bb12951202a5..54a4800ec7c34 100644
--- a/src/plugins/expressions/common/execution/execution.ts
+++ b/src/plugins/expressions/common/execution/execution.ts
@@ -8,6 +8,7 @@
import { i18n } from '@kbn/i18n';
import { isPromise } from '@kbn/std';
+import { ObservableLike, UnwrapObservable, UnwrapPromiseOrReturn } from '@kbn/utility-types';
import { keys, last, mapValues, reduce, zipObject } from 'lodash';
import {
combineLatest,
@@ -44,6 +45,18 @@ import { ExecutionContract } from './execution_contract';
import { ExpressionExecutionParams } from '../service';
import { createDefaultInspectorAdapters } from '../util/create_default_inspector_adapters';
+type UnwrapReturnType unknown> =
+ ReturnType extends ObservableLike
+ ? UnwrapObservable>
+ : UnwrapPromiseOrReturn>;
+
+// type ArgumentsOf = Function extends ExpressionFunction<
+// unknown,
+// infer Arguments
+// >
+// ? Arguments
+// : never;
+
/**
* The result returned after an expression function execution.
*/
@@ -83,7 +96,7 @@ const createAbortErrorValue = () =>
});
export interface ExecutionParams {
- executor: Executor;
+ executor: Executor;
ast?: ExpressionAstExpression;
expression?: string;
params: ExpressionExecutionParams;
@@ -107,7 +120,7 @@ export class Execution<
* N.B. It is initialized to `null` rather than `undefined` for legacy reasons,
* because in legacy interpreter it was set to `null` by default.
*/
- public input: Input = null as any;
+ public input = null as unknown as Input;
/**
* Input of the started execution.
@@ -186,13 +199,13 @@ export class Execution<
});
const inspectorAdapters =
- execution.params.inspectorAdapters || createDefaultInspectorAdapters();
+ (execution.params.inspectorAdapters as InspectorAdapters) || createDefaultInspectorAdapters();
this.context = {
getSearchContext: () => this.execution.params.searchContext || {},
getSearchSessionId: () => execution.params.searchSessionId,
getKibanaRequest: execution.params.kibanaRequest
- ? () => execution.params.kibanaRequest
+ ? () => execution.params.kibanaRequest!
: undefined,
variables: execution.params.variables || {},
types: executor.getTypes(),
@@ -201,14 +214,14 @@ export class Execution<
logDatatable: (name: string, datatable: Datatable) => {
inspectorAdapters.tables[name] = datatable;
},
- isSyncColorsEnabled: () => execution.params.syncColors,
- ...(execution.params as any).extraContext,
+ isSyncColorsEnabled: () => execution.params.syncColors!,
+ ...execution.params.extraContext,
getExecutionContext: () => execution.params.executionContext,
};
this.result = this.input$.pipe(
switchMap((input) =>
- this.race(this.invokeChain(this.state.get().ast.chain, input)).pipe(
+ this.race(this.invokeChain