-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up data plugin #39554
Closed
Closed
Clean up data plugin #39554
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b8713d2
Clean up plugin definition.
lukeelmers 3a46a95
Move interpreter imports to expressions service.
lukeelmers 7d702ef
Move plugin definition to dedicated file.
lukeelmers 0527707
Move files that don\'t need to be tsx to ts.
lukeelmers e9c6646
Update comment to clarify purpose of export.
lukeelmers ea1771e
Resolve merge conflicts & clean up types.
lukeelmers eb2df50
Fix typo from resolving merge conflicts.
lukeelmers 0cf6e19
Alphabetize services.
lukeelmers 42329a3
Clean up imports that caused broken type checks.
lukeelmers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { CoreSetup, CoreStart, Plugin } from '../../../../core/public'; | ||
|
||
// Services | ||
import { ExpressionsService, ExpressionsSetup } from './expressions'; | ||
import { FilterService, FilterSetup } from './filter'; | ||
import { IndexPatternsService, IndexPatternsSetup } from './index_patterns'; | ||
import { QueryService, QuerySetup } from './query'; | ||
import { SearchService, SearchSetup } from './search'; | ||
|
||
/** | ||
* Data Plugin - public | ||
* | ||
* Shared services for applications to access, query, and manipulate data in Kibana. | ||
*/ | ||
export class DataPublicPlugin | ||
implements Plugin<DataSetup, DataStart, DataSetupPlugins, DataStartPlugins> { | ||
// Exposed services, sorted alphabetically | ||
private readonly expressions = new ExpressionsService(); | ||
private readonly filter = new FilterService(); | ||
private readonly indexPatterns = new IndexPatternsService(); | ||
private readonly query = new QueryService(); | ||
private readonly search = new SearchService(); | ||
|
||
public setup(core: CoreSetup, plugins: DataSetupPlugins): DataSetup { | ||
const indexPatternsSetup = this.indexPatterns.setup(); | ||
|
||
return { | ||
expressions: this.expressions.setup(), | ||
indexPatterns: indexPatternsSetup, | ||
filter: this.filter.setup({ | ||
indexPatterns: indexPatternsSetup.indexPatterns, | ||
}), | ||
query: this.query.setup(), | ||
search: this.search.setup(), | ||
}; | ||
} | ||
|
||
public start(core: CoreStart, plugins: DataStartPlugins): DataStart { | ||
return {}; | ||
} | ||
|
||
public stop() { | ||
this.expressions.stop(); | ||
this.indexPatterns.stop(); | ||
this.filter.stop(); | ||
this.query.stop(); | ||
this.search.stop(); | ||
} | ||
} | ||
|
||
/** | ||
* Interface for this plugin's returned `setup` contract. | ||
* | ||
* @public | ||
*/ | ||
export interface DataSetup { | ||
expressions: ExpressionsSetup; | ||
indexPatterns: IndexPatternsSetup; | ||
filter: FilterSetup; | ||
query: QuerySetup; | ||
search: SearchSetup; | ||
} | ||
|
||
/** | ||
* Interface for this plugin's returned `start` contract. | ||
* | ||
* @public | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface DataStart {} | ||
|
||
/** | ||
* Interface for any dependencies on other plugins' `setup` contracts. | ||
* | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface DataSetupPlugins {} | ||
|
||
/** | ||
* Interface for any dependencies on other plugins' `start` contracts. | ||
* | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface DataStartPlugins {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,31 @@ | |
* under the License. | ||
*/ | ||
|
||
import { DataPlugin } from './index'; | ||
|
||
/** | ||
* We export data here so that users importing from 'plugins/data' | ||
* will automatically receive the response value of the `setup` contract, mimicking | ||
* the data that will eventually be injected by the new platform. | ||
* New Platform Shim | ||
* | ||
* In this file, we import any legacy dependencies we have, and shim them into | ||
* our plugin by manually constructing the values that the new platform will | ||
* eventually be passing to the `setup` method of our plugin definition. | ||
* | ||
* The idea is that our `plugin.ts` can stay "pure" and not contain any legacy | ||
* world code. Then when it comes time to migrate to the new platform, we can | ||
* simply delete this shim file. | ||
* | ||
* We are also calling `setup` here and exporting our public contract so that | ||
* other legacy plugins are able to import from '../core_plugins/data/setup' | ||
* and receive the response value of the `setup` contract, mimicking the | ||
* data that will eventually be injected by the new platform. | ||
*/ | ||
export const data = new DataPlugin().setup(); | ||
import { npSetup } from 'ui/new_platform'; | ||
|
||
import { CoreSetup } from '../../../../core/public'; | ||
import { DataPublicPlugin, DataSetupPlugins } from './plugin'; | ||
|
||
// core shims | ||
const coreSetup: CoreSetup = npSetup.core; | ||
|
||
// plugin dependency shims | ||
const pluginsSetup: DataSetupPlugins = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great. :) |
||
|
||
export const data = new DataPublicPlugin().setup(coreSetup, pluginsSetup); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit unrelated but shouldn't we have
registerFunction
here?I saw @ppisljar added it to expressions on markdown vis.