Skip to content

Commit f08b027

Browse files
sejlikavilla
andauthored
[Discover-next] add query enhancements plugin as a core plugin (#7212) (#7400)
Introduces the addition of a new core plugin called `Query Enhancements` This plugin seems to be focused on enhancing query capabilities, particularly in areas like PPL (Piped Processing Language), SQL, and natural language query assistance. The plugin is set up with the necessary configuration files: - src/plugins/query_enhancements/opensearch_dashboards.json: Defines the plugin's metadata and dependencies. - src/plugins/query_enhancements/common/config.ts: Contains the configuration schema for the plugin. - src/plugins/query_enhancements/public/plugin.tsx: The main plugin file that sets up the public-facing part of the plugin. - src/plugins/query_enhancements/server/plugin.ts: The server-side setup for the plugin. A significant part of the plugin is dedicated to a "Query Assist" feature: - src/plugins/query_enhancements/public/query_assist/: This directory contains components, hooks, and utilities for the Query Assist feature. - src/plugins/query_enhancements/public/query_assist/components/query_assist_bar.tsx: A React component for the Query Assist bar. - src/plugins/query_enhancements/server/routes/query_assist/: Server-side routing for Query Assist functionality. The plugin introduces several search interceptors: - src/plugins/query_enhancements/public/search/ppl_search_interceptor.ts - src/plugins/query_enhancements/public/search/sql_search_interceptor.ts - src/plugins/query_enhancements/public/search/sql_async_search_interceptor.ts These interceptors likely modify or enhance the search functionality for different query languages. There's a new feature for data source connections: - src/plugins/query_enhancements/public/data_source_connection/: This directory contains components and services for managing data source connections. The plugin implements server-side search strategies for different query types: - src/plugins/query_enhancements/server/search/ppl_search_strategy.ts - src/plugins/query_enhancements/server/search/sql_search_strategy.ts - src/plugins/query_enhancements/server/search/sql_async_search_strategy.ts There are some modifications to existing files outside the new plugin directory: - src/plugins/data/public/index.ts: Exports new types and interfaces. - src/plugins/data/public/ui/index.ts: Exports new UI components. - src/plugins/data/public/ui/query_editor/index.tsx: Modifies the QueryEditor component. The plugin includes a comprehensive test setup: - src/plugins/query_enhancements/test/: Contains Jest configuration and setup files for testing. Contains work by @sejli @joshuali925 @Swiddis @paulstn @mengweieric Thx @ashwin-pc for the description summary #6072 #6074 #6075 Commits include: * init * fixing bugs and removing target * add target and build to .gitignore * Remove SQL Async and Query Assist Going for the light weight solution for 2.15. So took out what wasn't required deliverable. However, I created a branch `feature/discover-next` which has the state where all the features where added so we can port it over post 2.15. * adding fix for PPL queries * Clean up files and add helper functions * final touches * [Discover-next] add query assist to query enhancements plugin (#6895) it adds query assist specific logic in query enhancements plugin to show a UI above the PPL search bar if user has configured PPL agent. Issues Resolved: #6820 * add query assist to query enhancements * align language to uppercase * pick PR 6167 * use useState hooks for query assist There is a bug in data explorer `AppContainer` where memorized `DiscoverCanvas` gets unmounted after `setQuery`. PR 6167 works around it by memorizing `AppContainer`. As query assist is no longer being unmounted, we can use proper hooks to persist state now. * Revert "pick PR 6167" This reverts commit acb0d41. Wait for official 6167 to merge to avoid conflict * address comments for PR 6894 --------- (cherry picked from commit 016e0f2) * [Discover-next] Address comments for search bar extensions and query assist (#6933) * pass dependencies to isEnabled func * add lazy and memo to search bar extensions * move ppl specific string out from query assist * prevent setstate after hook unmounts * add max-height to search bar extensions * prevent setstate after component unmounts * move ml-commons API to common/index.ts * improve i18n and accessibility usages * add hard-coded suggestions for sample data indices --------- (cherry picked from commit 4aade0f) * [Discover-next] Support data sources for query assist (#6972) * disable query assist for non-default datasource * disable query assist input when loading * support MDS for query assist * add unit tests for agents * Revert "add unit tests for agents" This reverts commit 983514e. The test configs are not yet setup in query_enhancements plugins. --------- (cherry picked from commit 328e08e) * add query assist banner * implement banner rendering logic * pick opensearch-project/dashboards-observability/pull/1896 * Conditionally render the data source select config * restore no space * add basic tests * add index selector This is a temporary solution given that in discover the index pattern selector will be removed. Before datasource and dataset selectors are added, query assist will rely on this index pattern selector to determine which index user wants to query. * MDS working with PPL and SQL Utilizing the work from MDS to make PPL and SQL calls to a remote cluster. * rename logo to mark * extract supported languages to config * Add missing license headers * initial implementation for async queries * remove queryId and sessionId from facet * fix: Update call out tests with intl wrapper * maintenance: Add and apply lint command * changing to observables * search interceptor and cleanup * moving polling class into plugin * Some minor clean ups plus lint * test: Add mock-heavy tests for sql search strategy * test: add GH workflows * More clean ups Add some props interfaces and consolidated some of the facets * chore: apply auto-lints to plugin * Not done * working * working and styled * add connection service * Update public/types.ts * Update public/plugin.tsx * Update public/plugin.tsx * fix linter * add more tests for query assist (#31) add more tests for query assist update eslint config to make it work increase index selector width * fix!: remove dataSource key in get connection response The `Connection` type does not have the extra `dataSource` object around response, and most of the time code references connection over dataSource. remove the redundent object to make response consistent with type. * change isEnabled to an observable based on selected connection * protect duplicated calls * [build] import via start services * Changeset file for PR #7212 created/updated * foobar * updating imports still in progress * Update more imports * fix setting of state * fixes bugs * Update test --------- (cherry picked from commit 9194d83) Signed-off-by: Kawika Avilla <kavilla414@gmail.com> Signed-off-by: Sean Li <lnse@amazon.com> Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
1 parent 293afd1 commit f08b027

File tree

84 files changed

+4542
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4542
-8
lines changed

changelogs/fragments/7212.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
feat:
2+
- Add query enhancements plugin as a core plugin ([#7212](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7212))

docs/_sidebar.md

+191
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
* [Home](/)
2+
3+
- Capabilities
4+
- [Read_only_mode](capabilities/read_only_mode.md)
5+
- Charts
6+
- [Current_usage](charts/current_usage.md)
7+
- Docker dev
8+
- [Docker dev setup manual](docker-dev/docker-dev-setup-manual.md)
9+
- Multi datasource
10+
- [Client_management_design](multi-datasource/client_management_design.md)
11+
- [High_level_design](multi-datasource/high_level_design.md)
12+
- [User_stories](multi-datasource/user_stories.md)
13+
- [Openapi](openapi/README.md)
14+
- Plugins
15+
- [Data_persistence](plugins/data_persistence.md)
16+
- Saved_objects
17+
- [Saved_object_repository_factory_design](saved_objects/saved_object_repository_factory_design.md)
18+
- Telemetry
19+
- [Telemetry](telemetry/telemetry.md)
20+
- src
21+
- [Core](../src/core/README.md)
22+
- dev
23+
- [Build](../src/dev/build/README.md)
24+
- [I18n](../src/dev/i18n/README.md)
25+
- plugins
26+
- [Application_config](../src/plugins/application_config/README.md)
27+
- [Bfetch](../src/plugins/bfetch/README.md)
28+
- [Charts](../src/plugins/charts/README.md)
29+
- console
30+
- public
31+
- application
32+
- [Hooks](../src/plugins/console/public/application/hooks/README.md)
33+
- [Csp_handler](../src/plugins/csp_handler/README.md)
34+
- [Dashboard](../src/plugins/dashboard/README.md)
35+
- [Data](../src/plugins/data/README.md)
36+
- [Data_explorer](../src/plugins/data_explorer/README.md)
37+
- [Data_source](../src/plugins/data_source/README.md)
38+
- [Data_source_management](../src/plugins/data_source_management/README.md)
39+
- [Dev_tools](../src/plugins/dev_tools/README.md)
40+
- [Discover](../src/plugins/discover/README.md)
41+
- [Embeddable](../src/plugins/embeddable/README.md)
42+
- [Expressions](../src/plugins/expressions/README.md)
43+
- [Home](../src/plugins/home/README.md)
44+
- index_pattern_management
45+
- public
46+
- components
47+
- create_index_pattern_wizard
48+
- [CREATE_INDEX_PATTERN](../src/plugins/index_pattern_management/public/components/create_index_pattern_wizard/CREATE_INDEX_PATTERN.md)
49+
- [Input_control_vis](../src/plugins/input_control_vis/README.md)
50+
- [Inspector](../src/plugins/inspector/README.md)
51+
- [Navigation](../src/plugins/navigation/README.md)
52+
- [Opensearch_dashboards_legacy](../src/plugins/opensearch_dashboards_legacy/README.md)
53+
- [Opensearch_dashboards_overview](../src/plugins/opensearch_dashboards_overview/README.md)
54+
- [Opensearch_dashboards_react](../src/plugins/opensearch_dashboards_react/README.md)
55+
- [Opensearch_dashboards_usage_collection](../src/plugins/opensearch_dashboards_usage_collection/README.md)
56+
- [Opensearch_dashboards_utils](../src/plugins/opensearch_dashboards_utils/README.md)
57+
- opensearch_ui_shared
58+
- public
59+
- forms
60+
- [Form_wizard](../src/plugins/opensearch_ui_shared/public/forms/form_wizard/README.md)
61+
- [Multi_content](../src/plugins/opensearch_ui_shared/public/forms/multi_content/README.md)
62+
- [Query_enhancements](../src/plugins/query_enhancements/README.md)
63+
- [Saved_objects](../src/plugins/saved_objects/README.md)
64+
- [Saved_objects_management](../src/plugins/saved_objects_management/README.md)
65+
- [Share](../src/plugins/share/README.md)
66+
- [Telemetry](../src/plugins/telemetry/README.md)
67+
- [Telemetry_collection_manager](../src/plugins/telemetry_collection_manager/README.md)
68+
- [Telemetry_management_section](../src/plugins/telemetry_management_section/README.md)
69+
- [Ui_actions](../src/plugins/ui_actions/README.md)
70+
- [Url_forwarding](../src/plugins/url_forwarding/README.md)
71+
- [Usage_collection](../src/plugins/usage_collection/README.md)
72+
- [Vis_augmenter](../src/plugins/vis_augmenter/README.md)
73+
- [Vis_builder](../src/plugins/vis_builder/README.md)
74+
- [Vis_default_editor](../src/plugins/vis_default_editor/README.md)
75+
- [Vis_type_markdown](../src/plugins/vis_type_markdown/README.md)
76+
- [Vis_type_metric](../src/plugins/vis_type_metric/README.md)
77+
- [Vis_type_table](../src/plugins/vis_type_table/README.md)
78+
- [Vis_type_tagcloud](../src/plugins/vis_type_tagcloud/README.md)
79+
- [Vis_type_timeline](../src/plugins/vis_type_timeline/README.md)
80+
- [Vis_type_timeseries](../src/plugins/vis_type_timeseries/README.md)
81+
- [Vis_type_vega](../src/plugins/vis_type_vega/README.md)
82+
- [Vis_type_vislib](../src/plugins/vis_type_vislib/README.md)
83+
- [Vis_type_xy](../src/plugins/vis_type_xy/README.md)
84+
- [Visualizations](../src/plugins/visualizations/README.md)
85+
- [Visualize](../src/plugins/visualize/README.md)
86+
- [Workspace](../src/plugins/workspace/README.md)
87+
- examples
88+
- [Dashboard_embeddable_examples](../examples/dashboard_embeddable_examples/README.md)
89+
- [Developer_examples](../examples/developer_examples/README.md)
90+
- embeddable_examples
91+
- public
92+
- [Todo](../examples/embeddable_examples/public/todo/README.md)
93+
- [Expressions_example](../examples/expressions_example/README.md)
94+
- [Multiple_data_source_examples](../examples/multiple_data_source_examples/README.md)
95+
- [Routing_example](../examples/routing_example/README.md)
96+
- [Search_examples](../examples/search_examples/README.md)
97+
- [Ui_action_examples](../examples/ui_action_examples/README.md)
98+
- [Ui_actions_explorer](../examples/ui_actions_explorer/README.md)
99+
- [Url_generators_examples](../examples/url_generators_examples/README.md)
100+
- [Url_generators_explorer](../examples/url_generators_explorer/README.md)
101+
- packages
102+
- [Opensearch datemath](../packages/opensearch-datemath/readme.md)
103+
- [Opensearch eslint config opensearch dashboards](../packages/opensearch-eslint-config-opensearch-dashboards/README.md)
104+
- [Opensearch safer lodash set](../packages/opensearch-safer-lodash-set/README.md)
105+
- [Osd ace](../packages/osd-ace/README.md)
106+
- [Osd apm config loader](../packages/osd-apm-config-loader/README.md)
107+
- [Osd babel preset](../packages/osd-babel-preset/README.md)
108+
- [Osd config](../packages/osd-config/README.md)
109+
- [Osd config schema](../packages/osd-config-schema/README.md)
110+
- [Osd cross platform](../packages/osd-cross-platform/README.md)
111+
- [Osd dev utils](../packages/osd-dev-utils/README.md)
112+
- [Osd eslint import resolver opensearch dashboards](../packages/osd-eslint-import-resolver-opensearch-dashboards/README.md)
113+
- [Osd eslint plugin eslint](../packages/osd-eslint-plugin-eslint/README.md)
114+
- [Osd expect](../packages/osd-expect/README.md)
115+
- [Osd i18n](../packages/osd-i18n/README.md)
116+
- [Osd logging](../packages/osd-logging/README.md)
117+
- [Osd monaco](../packages/osd-monaco/README.md)
118+
- [Osd opensearch](../packages/osd-opensearch/README.md)
119+
- [Osd optimizer](../packages/osd-optimizer/README.md)
120+
- [Osd plugin generator](../packages/osd-plugin-generator/README.md)
121+
- [Osd plugin helpers](../packages/osd-plugin-helpers/README.md)
122+
- [Osd pm](../packages/osd-pm/README.md)
123+
- [Osd spec to console](../packages/osd-spec-to-console/README.md)
124+
- [Osd std](../packages/osd-std/README.md)
125+
- [Osd stylelint config](../packages/osd-stylelint-config/README.md)
126+
- [Osd stylelint plugin stylelint](../packages/osd-stylelint-plugin-stylelint/README.md)
127+
- [Osd telemetry tools](../packages/osd-telemetry-tools/README.md)
128+
- [Osd test](../packages/osd-test/README.md)
129+
- [Osd test subj selector](../packages/osd-test-subj-selector/README.md)
130+
- [Osd ui framework](../packages/osd-ui-framework/README.md)
131+
- [Osd ui shared deps](../packages/osd-ui-shared-deps/README.md)
132+
- [Osd utility types](../packages/osd-utility-types/README.md)
133+
- [Osd utils](../packages/osd-utils/README.md)
134+
- [README](../packages/README.md)
135+
- release-notes
136+
- [Opensearch dashboards.release notes 1.0.0 rc1](../release-notes/opensearch-dashboards.release-notes-1.0.0-rc1.md)
137+
- [Opensearch dashboards.release notes 1.0.0](../release-notes/opensearch-dashboards.release-notes-1.0.0.md)
138+
- [Opensearch dashboards.release notes 1.1.0](../release-notes/opensearch-dashboards.release-notes-1.1.0.md)
139+
- [Opensearch dashboards.release notes 1.2.0](../release-notes/opensearch-dashboards.release-notes-1.2.0.md)
140+
- [Opensearch dashboards.release notes 1.3.0](../release-notes/opensearch-dashboards.release-notes-1.3.0.md)
141+
- [Opensearch dashboards.release notes 1.3.1](../release-notes/opensearch-dashboards.release-notes-1.3.1.md)
142+
- [Opensearch dashboards.release notes 1.3.10](../release-notes/opensearch-dashboards.release-notes-1.3.10.md)
143+
- [Opensearch dashboards.release notes 1.3.11](../release-notes/opensearch-dashboards.release-notes-1.3.11.md)
144+
- [Opensearch dashboards.release notes 1.3.12](../release-notes/opensearch-dashboards.release-notes-1.3.12.md)
145+
- [Opensearch dashboards.release notes 1.3.13](../release-notes/opensearch-dashboards.release-notes-1.3.13.md)
146+
- [Opensearch dashboards.release notes 1.3.14](../release-notes/opensearch-dashboards.release-notes-1.3.14.md)
147+
- [Opensearch dashboards.release notes 1.3.15](../release-notes/opensearch-dashboards.release-notes-1.3.15.md)
148+
- [Opensearch dashboards.release notes 1.3.17](../release-notes/opensearch-dashboards.release-notes-1.3.17.md)
149+
- [Opensearch dashboards.release notes 1.3.2](../release-notes/opensearch-dashboards.release-notes-1.3.2.md)
150+
- [Opensearch dashboards.release notes 1.3.3](../release-notes/opensearch-dashboards.release-notes-1.3.3.md)
151+
- [Opensearch dashboards.release notes 1.3.5](../release-notes/opensearch-dashboards.release-notes-1.3.5.md)
152+
- [Opensearch dashboards.release notes 1.3.6](../release-notes/opensearch-dashboards.release-notes-1.3.6.md)
153+
- [Opensearch dashboards.release notes 1.3.7](../release-notes/opensearch-dashboards.release-notes-1.3.7.md)
154+
- [Opensearch dashboards.release notes 1.3.8](../release-notes/opensearch-dashboards.release-notes-1.3.8.md)
155+
- [Opensearch dashboards.release notes 1.3.9](../release-notes/opensearch-dashboards.release-notes-1.3.9.md)
156+
- [Opensearch dashboards.release notes 2.0.0 rc1](../release-notes/opensearch-dashboards.release-notes-2.0.0-rc1.md)
157+
- [Opensearch dashboards.release notes 2.0.0](../release-notes/opensearch-dashboards.release-notes-2.0.0.md)
158+
- [Opensearch dashboards.release notes 2.0.1](../release-notes/opensearch-dashboards.release-notes-2.0.1.md)
159+
- [Opensearch dashboards.release notes 2.1.0](../release-notes/opensearch-dashboards.release-notes-2.1.0.md)
160+
- [Opensearch dashboards.release notes 2.10.0](../release-notes/opensearch-dashboards.release-notes-2.10.0.md)
161+
- [Opensearch dashboards.release notes 2.11.0](../release-notes/opensearch-dashboards.release-notes-2.11.0.md)
162+
- [Opensearch dashboards.release notes 2.11.1](../release-notes/opensearch-dashboards.release-notes-2.11.1.md)
163+
- [Opensearch dashboards.release notes 2.12.0](../release-notes/opensearch-dashboards.release-notes-2.12.0.md)
164+
- [Opensearch dashboards.release notes 2.13.0](../release-notes/opensearch-dashboards.release-notes-2.13.0.md)
165+
- [Opensearch dashboards.release notes 2.14.0](../release-notes/opensearch-dashboards.release-notes-2.14.0.md)
166+
- [Opensearch dashboards.release notes 2.15.0](../release-notes/opensearch-dashboards.release-notes-2.15.0.md)
167+
- [Opensearch dashboards.release notes 2.2.0](../release-notes/opensearch-dashboards.release-notes-2.2.0.md)
168+
- [Opensearch dashboards.release notes 2.2.1](../release-notes/opensearch-dashboards.release-notes-2.2.1.md)
169+
- [Opensearch dashboards.release notes 2.3.0](../release-notes/opensearch-dashboards.release-notes-2.3.0.md)
170+
- [Opensearch dashboards.release notes 2.4.0](../release-notes/opensearch-dashboards.release-notes-2.4.0.md)
171+
- [Opensearch dashboards.release notes 2.4.1](../release-notes/opensearch-dashboards.release-notes-2.4.1.md)
172+
- [Opensearch dashboards.release notes 2.5.0](../release-notes/opensearch-dashboards.release-notes-2.5.0.md)
173+
- [Opensearch dashboards.release notes 2.6.0](../release-notes/opensearch-dashboards.release-notes-2.6.0.md)
174+
- [Opensearch dashboards.release notes 2.7.0](../release-notes/opensearch-dashboards.release-notes-2.7.0.md)
175+
- [Opensearch dashboards.release notes 2.8.0](../release-notes/opensearch-dashboards.release-notes-2.8.0.md)
176+
- [Opensearch dashboards.release notes 2.9.0](../release-notes/opensearch-dashboards.release-notes-2.9.0.md)
177+
- scripts
178+
- [README](../scripts/README.md)
179+
- [DOCS_README](DOCS_README.md)
180+
- [Theme](theme.md)
181+
- [CHANGELOG](../CHANGELOG.md)
182+
- [CODE_OF_CONDUCT](../CODE_OF_CONDUCT.md)
183+
- [COMMUNICATIONS](../COMMUNICATIONS.md)
184+
- [CONTRIBUTING](../CONTRIBUTING.md)
185+
- [DEVELOPER_GUIDE](../DEVELOPER_GUIDE.md)
186+
- [MAINTAINERS](../MAINTAINERS.md)
187+
- [README](../README.md)
188+
- [RELEASING](../RELEASING.md)
189+
- [SECURITY](../SECURITY.md)
190+
- [TESTING](../TESTING.md)
191+
- [TYPESCRIPT](../TYPESCRIPT.md)

src/plugins/data/public/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,12 @@ export {
437437
IndexPatternSelectProps,
438438
QueryStringInput,
439439
QueryStringInputProps,
440+
QueryEditor,
441+
QueryEditorExtensionConfig,
442+
QueryEditorExtensions,
443+
QueryEditorExtensionDependencies,
444+
QueryEditorProps,
445+
QueryEditorTopRow,
440446
// for BWC, keeping the old name
441447
IUiStart as DataPublicPluginStartUi,
442448
} from './ui';

src/plugins/data/public/ui/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,13 @@ export {
3939
export { IndexPatternSelectProps } from './index_pattern_select';
4040
export { FilterLabel } from './filter_bar';
4141
export { QueryStringInput, QueryStringInputProps } from './query_string_input';
42+
export {
43+
QueryEditorTopRow,
44+
QueryEditor,
45+
QueryEditorProps,
46+
QueryEditorExtensions,
47+
QueryEditorExtensionDependencies,
48+
QueryEditorExtensionConfig,
49+
} from './query_editor';
4250
export { SearchBar, SearchBarProps, StatefulSearchBarProps } from './search_bar';
4351
export { SuggestionsComponent } from './typeahead';

src/plugins/data/public/ui/query_editor/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ export const QueryEditor = (props: QueryEditorProps) => (
2525
);
2626
export type { QueryEditorProps };
2727

28-
export { QueryEditorExtensions, QueryEditorExtensionConfig } from './query_editor_extensions';
28+
export {
29+
QueryEditorExtensions,
30+
QueryEditorExtensionDependencies,
31+
QueryEditorExtensionConfig,
32+
} from './query_editor_extensions';

src/plugins/data/public/ui/query_editor/query_editor.tsx

+17-6
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ export default class QueryEditorUI extends Component<Props, State> {
212212
: undefined;
213213
this.onChange(newQuery, dateRange);
214214
this.onSubmit(newQuery, dateRange);
215-
this.setState({ isDataSourcesVisible: enhancement?.searchBar?.showDataSourceSelector ?? true });
215+
this.setState({
216+
isDataSourcesVisible: enhancement?.searchBar?.showDataSourcesSelector ?? true,
217+
isDataSetsVisible: enhancement?.searchBar?.showDataSetsSelector ?? true,
218+
});
216219
};
217220

218221
private initPersistedLog = () => {
@@ -225,10 +228,15 @@ export default class QueryEditorUI extends Component<Props, State> {
225228
private initDataSourcesVisibility = () => {
226229
if (this.componentIsUnmounting) return;
227230

228-
const isDataSourcesVisible =
229-
this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
230-
?.showDataSourceSelector ?? true;
231-
this.setState({ isDataSourcesVisible });
231+
return this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
232+
?.showDataSourcesSelector;
233+
};
234+
235+
private initDataSetsVisibility = () => {
236+
if (this.componentIsUnmounting) return;
237+
238+
return this.props.settings.getQueryEnhancements(this.props.query.language)?.searchBar
239+
?.showDataSetsSelector;
232240
};
233241

234242
public onMouseEnterSuggestion = (index: number) => {
@@ -245,7 +253,10 @@ export default class QueryEditorUI extends Component<Props, State> {
245253

246254
this.initPersistedLog();
247255
// this.fetchIndexPatterns().then(this.updateSuggestions);
248-
this.initDataSourcesVisibility();
256+
this.setState({
257+
isDataSourcesVisible: this.initDataSourcesVisibility() || true,
258+
isDataSetsVisible: this.initDataSetsVisibility() || true,
259+
});
249260
}
250261

251262
public componentDidUpdate(prevProps: Props) {

src/plugins/data/public/ui/query_editor/query_editor_extensions/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ export const QueryEditorExtensions = (props: ComponentProps<typeof LazyQueryEdit
1414
</React.Suspense>
1515
);
1616

17-
export { QueryEditorExtensionConfig } from './query_editor_extension';
17+
export {
18+
QueryEditorExtensionDependencies,
19+
QueryEditorExtensionConfig,
20+
} from './query_editor_extension';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"prefix": "queryEnhancements",
3+
"paths": {
4+
"queryEnhancements": "."
5+
},
6+
"translations": ["translations/ja-JP.json"]
7+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Query Enhancements Plugin
2+
3+
Optional plugin, that registers query enhancing capabilities within
4+
the application.
5+
6+
## List of enhancements
7+
8+
* PPL within Discover
9+
* SQL within Discover
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { schema, TypeOf } from '@osd/config-schema';
7+
8+
export const configSchema = schema.object({
9+
enabled: schema.boolean({ defaultValue: true }),
10+
queryAssist: schema.object({
11+
supportedLanguages: schema.arrayOf(
12+
schema.object({
13+
language: schema.string(),
14+
agentConfig: schema.string(),
15+
}),
16+
{
17+
defaultValue: [{ language: 'PPL', agentConfig: 'os_query_assist_ppl' }],
18+
}
19+
),
20+
}),
21+
});
22+
23+
export type ConfigSchema = TypeOf<typeof configSchema>;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export const PLUGIN_ID = 'queryEnhancements';
7+
export const PLUGIN_NAME = 'queryEnhancements';
8+
9+
export const BASE_API = '/api/enhancements';
10+
11+
export const SEARCH_STRATEGY = {
12+
PPL: 'ppl',
13+
SQL: 'sql',
14+
SQL_ASYNC: 'sqlasync',
15+
};
16+
17+
export const API = {
18+
SEARCH: `${BASE_API}/search`,
19+
PPL_SEARCH: `${BASE_API}/search/${SEARCH_STRATEGY.PPL}`,
20+
SQL_SEARCH: `${BASE_API}/search/${SEARCH_STRATEGY.SQL}`,
21+
SQL_ASYNC_SEARCH: `${BASE_API}/search/${SEARCH_STRATEGY.SQL_ASYNC}`,
22+
QUERY_ASSIST: {
23+
LANGUAGES: `${BASE_API}/assist/languages`,
24+
GENERATE: `${BASE_API}/assist/generate`,
25+
},
26+
DATA_SOURCE: {
27+
CONNECTIONS: `${BASE_API}/datasource/connections`,
28+
},
29+
};
30+
31+
export const URI = {
32+
PPL: '/_plugins/_ppl',
33+
SQL: '/_plugins/_sql',
34+
ASYNC_QUERY: '/_plugins/_async_query',
35+
ML: '/_plugins/_ml',
36+
OBSERVABILITY: '/_plugins/_observability',
37+
DATA_CONNECTIONS: '/_plugins/_query/_datasources',
38+
};
39+
40+
export const OPENSEARCH_API = {
41+
PANELS: `${URI.OBSERVABILITY}/object`,
42+
DATA_CONNECTIONS: URI.DATA_CONNECTIONS,
43+
};
44+
45+
export const UI_SETTINGS = {};
46+
47+
export const ERROR_DETAILS = { GUARDRAILS_TRIGGERED: 'guardrails triggered' };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export * from './constants';
7+
export * from './types';
8+
export * from './utils';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
export { QueryAssistParameters, QueryAssistResponse } from './types';

0 commit comments

Comments
 (0)