diff --git a/.sass-lint.yml b/.sass-lint.yml index c5140d3511a2..c0dca04ed8aa 100644 --- a/.sass-lint.yml +++ b/.sass-lint.yml @@ -2,7 +2,6 @@ files: include: - 'src/legacy/core_plugins/metrics/**/*.s+(a|c)ss' - 'src/legacy/core_plugins/timelion/**/*.s+(a|c)ss' - - 'src/legacy/ui/public/query_bar/**/*.s+(a|c)ss' - 'src/legacy/ui/public/vislib/**/*.s+(a|c)ss' - 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss' - 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss' diff --git a/src/legacy/core_plugins/data/public/index.ts b/src/legacy/core_plugins/data/public/index.ts index c3892fa581fc..2412541e8c5c 100644 --- a/src/legacy/core_plugins/data/public/index.ts +++ b/src/legacy/core_plugins/data/public/index.ts @@ -38,7 +38,7 @@ export { IndexPatterns, StaticIndexPattern, } from './index_patterns'; -export { Query, QueryBarInput } from './query'; +export { QueryBarInput } from './query'; export { SearchBar, SearchBarProps, SavedQueryAttributes, SavedQuery } from './search'; /** @public static code */ diff --git a/src/legacy/core_plugins/data/public/mocks.ts b/src/legacy/core_plugins/data/public/mocks.ts index d3b594412796..39d1296ddf8b 100644 --- a/src/legacy/core_plugins/data/public/mocks.ts +++ b/src/legacy/core_plugins/data/public/mocks.ts @@ -18,12 +18,10 @@ */ import { indexPatternsServiceMock } from './index_patterns/index_patterns_service.mock'; -import { queryServiceMock } from './query/query_service.mock'; function createDataSetupMock() { return { indexPatterns: indexPatternsServiceMock.createSetupContract(), - query: queryServiceMock.createSetupContract(), }; } diff --git a/src/legacy/core_plugins/data/public/plugin.ts b/src/legacy/core_plugins/data/public/plugin.ts index 76beb4ee5605..2059f61fde59 100644 --- a/src/legacy/core_plugins/data/public/plugin.ts +++ b/src/legacy/core_plugins/data/public/plugin.ts @@ -19,7 +19,6 @@ import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; import { SearchService, SearchStart, createSearchBar, StatetfulSearchBarProps } from './search'; -import { QueryService, QuerySetup } from './query'; import { IndexPatternsService, IndexPatternsSetup, IndexPatternsStart } from './index_patterns'; import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public'; import { DataPublicPluginStart } from '../../../../plugins/data/public'; @@ -42,7 +41,6 @@ export interface DataPluginStartDependencies { * @public */ export interface DataSetup { - query: QuerySetup; indexPatterns: IndexPatternsSetup; } @@ -52,7 +50,6 @@ export interface DataSetup { * @public */ export interface DataStart { - query: QuerySetup; indexPatterns: IndexPatternsStart; search: SearchStart; ui: { @@ -74,7 +71,6 @@ export interface DataStart { export class DataPlugin implements Plugin { private readonly indexPatterns: IndexPatternsService = new IndexPatternsService(); - private readonly query: QueryService = new QueryService(); private readonly search: SearchService = new SearchService(); private setupApi!: DataSetup; @@ -85,7 +81,6 @@ export class DataPlugin implements Plugin PersistedLog: mockPersistedLogFactory, })); -jest.mock('../lib/fetch_index_patterns', () => ({ +jest.mock('./fetch_index_patterns', () => ({ fetchIndexPatterns: mockFetchIndexPatterns, })); diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx index 77c9169d03aa..31a17315db7d 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_input.tsx @@ -38,6 +38,11 @@ import { AutocompleteSuggestion, AutocompleteSuggestionType, PersistedLog, + toUser, + fromUser, + matchPairs, + getQueryLog, + Query, } from '../../../../../../../plugins/data/public'; import { withKibana, @@ -45,12 +50,10 @@ import { toMountPoint, } from '../../../../../../../plugins/kibana_react/public'; import { IndexPattern, StaticIndexPattern } from '../../../index_patterns'; -import { Query, getQueryLog } from '../index'; -import { fromUser, matchPairs, toUser } from '../lib'; import { QueryLanguageSwitcher } from './language_switcher'; import { SuggestionsComponent } from './typeahead/suggestions_component'; -import { fetchIndexPatterns } from '../lib/fetch_index_patterns'; import { IDataPluginServices } from '../../../types'; +import { fetchIndexPatterns } from './fetch_index_patterns'; interface Props { kibana: KibanaReactContextValue; diff --git a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx index 9bb8e3875a3d..ca0ac3c37184 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx +++ b/src/legacy/core_plugins/data/public/query/query_bar/components/query_bar_top_row.tsx @@ -35,13 +35,17 @@ import { import { EuiSuperUpdateButton, OnRefreshProps } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { Toast } from 'src/core/public'; -import { TimeRange, TimeHistoryContract } from 'src/plugins/data/public'; +import { + TimeRange, + TimeHistoryContract, + Query, + PersistedLog, + getQueryLog, +} from '../../../../../../../plugins/data/public'; import { useKibana, toMountPoint } from '../../../../../../../plugins/kibana_react/public'; -import { PersistedLog } from '../../../../../../../plugins/data/public'; import { IndexPattern } from '../../../index_patterns'; import { QueryBarInput } from './query_bar_input'; -import { Query, getQueryLog } from '../index'; import { IDataPluginServices } from '../../../types'; interface Props { diff --git a/src/legacy/core_plugins/data/public/query/query_bar/index.ts b/src/legacy/core_plugins/data/public/query/query_bar/index.ts index ece45c5bbd5d..f0ad0707c699 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/index.ts +++ b/src/legacy/core_plugins/data/public/query/query_bar/index.ts @@ -19,9 +19,3 @@ export { QueryBarTopRow } from './components/query_bar_top_row'; export { QueryBarInput } from './components/query_bar_input'; - -export { fromUser } from './lib/from_user'; -export { toUser } from './lib/to_user'; -export { getQueryLog } from './lib/get_query_log'; - -export { Query } from '../../../../../../plugins/data/public'; diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/__tests__/lib_user_input.js b/src/legacy/core_plugins/data/public/query/query_bar/lib/__tests__/lib_user_input.js deleted file mode 100644 index ef98f3d07c5b..000000000000 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/__tests__/lib_user_input.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import expect from '@kbn/expect'; - -import { toUser, fromUser } from '../'; - -describe('user input helpers', function () { - - describe('user input parser', function () { - - it('should return the input if passed an object', function () { - expect(fromUser({ foo: 'bar' })).to.eql({ foo: 'bar' }); - }); - - it('unless the object is empty, then convert it to an empty string', function () { - expect(fromUser({})).to.eql(''); - }); - - it('should pass through input strings that not start with {', function () { - expect(fromUser('foo')).to.eql('foo'); - expect(fromUser('400')).to.eql('400'); - expect(fromUser('true')).to.eql('true'); - }); - - it('should parse valid JSON and return the object instead of a string', function () { - expect(fromUser('{}')).to.eql({}); - - // invalid json remains a string - expect(fromUser('{a:b}')).to.eql('{a:b}'); - }); - }); - - describe('model presentation formatter', function () { - it('should present undefined as empty string', function () { - let notDefined; - expect(toUser(notDefined)).to.be(''); - }); - - it('should present null as empty string', function () { - expect(toUser(null)).to.be(''); - }); - - it('should present objects as strings', function () { - expect(toUser({ foo: 'bar' })).to.be('{"foo":"bar"}'); - }); - - it('should present query_string queries as strings', function () { - expect(toUser({ query_string: { query: 'lucene query string' } })).to.be('lucene query string'); - }); - - it('should present query_string queries without a query as an empty string', function () { - expect(toUser({ query_string: {} })).to.be(''); - }); - - it('should present string as strings', function () { - expect(toUser('foo')).to.be('foo'); - }); - - it('should present numbers as strings', function () { - expect(toUser(400)).to.be('400'); - }); - }); -}); diff --git a/src/legacy/core_plugins/data/public/query/query_service.mock.ts b/src/legacy/core_plugins/data/public/query/query_service.mock.ts deleted file mode 100644 index 19a00632ca19..000000000000 --- a/src/legacy/core_plugins/data/public/query/query_service.mock.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { QueryService, QuerySetup } from '.'; - -type QueryServiceClientContract = PublicMethodsOf; - -const createSetupContractMock = () => { - const setupContract: jest.Mocked = { - helpers: { - fromUser: jest.fn(), - toUser: jest.fn(), - getQueryLog: jest.fn(), - }, - }; - - return setupContract; -}; - -const createMock = () => { - const mocked: jest.Mocked = { - setup: jest.fn(), - start: jest.fn(), - stop: jest.fn(), - }; - - mocked.setup.mockReturnValue(createSetupContractMock()); - return mocked; -}; - -export const queryServiceMock = { - create: createMock, - createSetupContract: createSetupContractMock, - createStartContract: createSetupContractMock, -}; diff --git a/src/legacy/core_plugins/data/public/query/query_service.ts b/src/legacy/core_plugins/data/public/query/query_service.ts deleted file mode 100644 index f6f229496f49..000000000000 --- a/src/legacy/core_plugins/data/public/query/query_service.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { fromUser, toUser, getQueryLog } from './query_bar'; - -/** - * Query Service - * - * @internal - */ -export class QueryService { - public setup() { - return { - helpers: { - fromUser, - toUser, - getQueryLog, - }, - }; - } - - public start() { - // nothing to do here yet - } - - public stop() { - // nothing to do here yet - } -} - -/** @public */ -export type QuerySetup = ReturnType; - -export * from './query_bar'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx b/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx index a57b7b17a0da..ea0f6775e483 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx +++ b/src/legacy/core_plugins/data/public/search/search_bar/components/search_bar.tsx @@ -24,9 +24,8 @@ import React, { Component } from 'react'; import ResizeObserver from 'resize-observer-polyfill'; import { get, isEqual } from 'lodash'; -import { TimeRange } from 'src/plugins/data/common/types'; -import { TimeHistoryContract } from 'src/plugins/data/public'; -import { IndexPattern, Query, FilterBar } from '../../../../../data/public'; +import { TimeRange, Query, TimeHistoryContract } from 'src/plugins/data/public'; +import { IndexPattern, FilterBar } from '../../../../../data/public'; import { QueryBarTopRow } from '../../../query'; import { SavedQuery, SavedQueryAttributes } from '../index'; import { SavedQueryMeta, SaveQueryForm } from './saved_query_management/save_query_form'; diff --git a/src/legacy/core_plugins/data/public/search/search_bar/index.tsx b/src/legacy/core_plugins/data/public/search/search_bar/index.tsx index ebde9d60b0b5..f369bf997c1a 100644 --- a/src/legacy/core_plugins/data/public/search/search_bar/index.tsx +++ b/src/legacy/core_plugins/data/public/search/search_bar/index.tsx @@ -17,9 +17,7 @@ * under the License. */ -import { RefreshInterval, TimeRange } from 'src/plugins/data/public'; -import { Query } from '../../query/query_bar'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { RefreshInterval, TimeRange, Query, esFilters } from 'src/plugins/data/public'; export * from './components'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx index 5fa3a938ed9d..b9825ceeecdb 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app.tsx @@ -35,10 +35,10 @@ import { } from 'ui/state_management/app_state'; import { KbnUrl } from 'ui/url/kbn_url'; -import { TimeRange } from 'src/plugins/data/public'; +import { TimeRange, Query } from 'src/plugins/data/public'; import { IndexPattern } from 'ui/index_patterns'; import { IPrivate } from 'ui/private'; -import { StaticIndexPattern, Query, SavedQuery } from 'plugins/data'; +import { StaticIndexPattern, SavedQuery } from 'plugins/data'; import moment from 'moment'; import { Subscription } from 'rxjs'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx index 548a66297a3f..d82b89339b0d 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_app_controller.tsx @@ -50,12 +50,13 @@ import { import { KbnUrl } from 'ui/url/kbn_url'; import { IndexPattern } from 'ui/index_patterns'; import { IPrivate } from 'ui/private'; -import { Query, SavedQuery } from 'src/legacy/core_plugins/data/public'; +import { SavedQuery } from 'src/legacy/core_plugins/data/public'; import { SaveOptions } from 'ui/saved_objects/saved_object'; import { capabilities } from 'ui/capabilities'; import { Subscription } from 'rxjs'; import { npStart } from 'ui/new_platform'; import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder'; +import { Query } from '../../../../../plugins/data/public'; import { start as data } from '../../../data/public/legacy'; import { diff --git a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts index 8ffabe5add1c..1a42ed837a9d 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/dashboard_state_manager.ts @@ -27,9 +27,9 @@ import { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query'; import { Moment } from 'moment'; import { DashboardContainer } from 'src/legacy/core_plugins/dashboard_embeddable_container/public/np_ready/public'; +import { Query } from 'src/plugins/data/public'; import { ViewMode } from '../../../../../../src/plugins/embeddable/public'; import { esFilters } from '../../../../../../src/plugins/data/public'; -import { Query } from '../../../data/public'; import { getAppStateDefaults, migrateAppState } from './lib'; import { convertPanelStateToSavedDashboardPanel } from './lib/embeddable_saved_object_converters'; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts b/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts index 8522495b9ded..e82fc58670e3 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/migrations/move_filters_to_query.ts @@ -17,8 +17,7 @@ * under the License. */ -import { Query } from 'src/legacy/core_plugins/data/public'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters, Query } from '../../../../../../plugins/data/public'; export interface Pre600FilterQuery { // pre 6.0.0 global query:queryString:options were stored per dashboard and would diff --git a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts index 5b860b0a2cc7..5b24aa13f4f7 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard.d.ts @@ -19,9 +19,7 @@ import { SearchSource } from 'ui/courier'; import { SavedObject } from 'ui/saved_objects/saved_object'; -import { RefreshInterval } from 'src/plugins/data/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters, Query, RefreshInterval } from '../../../../../../plugins/data/public'; export interface SavedObjectDashboard extends SavedObject { id?: string; diff --git a/src/legacy/core_plugins/kibana/public/dashboard/types.ts b/src/legacy/core_plugins/kibana/public/dashboard/types.ts index 5aaca7b62094..3c2c87a502da 100644 --- a/src/legacy/core_plugins/kibana/public/dashboard/types.ts +++ b/src/legacy/core_plugins/kibana/public/dashboard/types.ts @@ -18,7 +18,6 @@ */ import { AppState } from 'ui/state_management/app_state'; -import { Query } from 'src/legacy/core_plugins/data/public'; import { AppState as TAppState } from 'ui/state_management/app_state'; import { ViewMode } from 'src/plugins/embeddable/public'; import { @@ -29,7 +28,7 @@ import { RawSavedDashboardPanel640To720, RawSavedDashboardPanel730ToLatest, } from './migrations/types'; -import { esFilters } from '../../../../../plugins/data/public'; +import { Query, esFilters } from '../../../../../plugins/data/public'; export type NavAction = (anchorElement?: any) => void; diff --git a/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts b/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts index 732fb6d2e4e7..d719864d9944 100644 --- a/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts +++ b/src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts @@ -27,8 +27,8 @@ import { TimeRange, onlyDisabledFiltersChanged, getTime, + Query, } from '../../../../../../plugins/data/public'; -import { Query } from '../../../../data/public'; import { APPLY_FILTER_TRIGGER, Container, diff --git a/src/legacy/core_plugins/kibana/public/discover/embeddable/types.ts b/src/legacy/core_plugins/kibana/public/discover/embeddable/types.ts index 5473ec0e7b8b..2d940ad8cba9 100644 --- a/src/legacy/core_plugins/kibana/public/discover/embeddable/types.ts +++ b/src/legacy/core_plugins/kibana/public/discover/embeddable/types.ts @@ -17,13 +17,11 @@ * under the License. */ -import { TimeRange } from 'src/plugins/data/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from 'src/plugins/embeddable/public'; import { StaticIndexPattern } from '../kibana_services'; import { SavedSearch } from '../types'; import { SortOrder } from '../angular/doc_table/components/table_header/helpers'; -import { esFilters } from '../../../../../../plugins/data/public'; +import { esFilters, TimeRange, Query } from '../../../../../../plugins/data/public'; export interface SearchInput extends EmbeddableInput { timeRange: TimeRange; diff --git a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts index 60cf7c7ec192..0b75c6ffa1ff 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/embeddable/visualize_embeddable.ts @@ -33,11 +33,12 @@ import { npStart } from 'ui/new_platform'; import { IExpressionLoaderParams } from '../../../../expressions/public/np_ready/public/types'; import { start as expressions } from '../../../../expressions/public/legacy'; import { VISUALIZE_EMBEDDABLE_TYPE } from './constants'; -import { Query } from '../../../../data/public'; import { TimeRange, + Query, onlyDisabledFiltersChanged, esFilters, + mapAndFlattenFilters, } from '../../../../../../plugins/data/public'; import { EmbeddableInput, @@ -47,7 +48,6 @@ import { APPLY_FILTER_TRIGGER, } from '../../../../../../plugins/embeddable/public'; import { dispatchRenderComplete } from '../../../../../../plugins/kibana_utils/public'; -import { mapAndFlattenFilters } from '../../../../../../plugins/data/public'; const getKeys = (o: T): Array => Object.keys(o) as Array; diff --git a/src/legacy/core_plugins/timelion/public/vis/timelion_request_handler.ts b/src/legacy/core_plugins/timelion/public/vis/timelion_request_handler.ts index 6239e4027c39..35dea4a0deb9 100644 --- a/src/legacy/core_plugins/timelion/public/vis/timelion_request_handler.ts +++ b/src/legacy/core_plugins/timelion/public/vis/timelion_request_handler.ts @@ -22,8 +22,7 @@ import { buildEsQuery, getEsQueryConfig } from '@kbn/es-query'; // @ts-ignore import { timezoneProvider } from 'ui/vis/lib/timezone'; import { KIBANA_CONTEXT_NAME } from 'src/plugins/expressions/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; -import { TimeRange, esFilters } from 'src/plugins/data/public'; +import { Query, TimeRange, esFilters } from 'src/plugins/data/public'; import { VisParams } from 'ui/vis'; import { i18n } from '@kbn/i18n'; import { TimelionVisualizationDependencies } from '../plugin'; diff --git a/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts b/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts index b4c32f37eb90..accc52c1e5a1 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts +++ b/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts @@ -18,11 +18,9 @@ */ import { timefilter } from 'ui/timefilter'; -import { TimeRange } from 'src/plugins/data/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; -import { buildEsQuery, getEsQueryConfig } from '@kbn/es-query'; -import { esFilters } from '../../../../plugins/data/public'; +import { buildEsQuery, getEsQueryConfig } from '@kbn/es-query'; +import { esFilters, TimeRange, Query } from '../../../../plugins/data/public'; // @ts-ignore import { VegaParser } from './data_model/vega_parser'; diff --git a/src/legacy/ui/public/agg_types/buckets/filters.ts b/src/legacy/ui/public/agg_types/buckets/filters.ts index 44a97abb7a1d..a8d509d507c6 100644 --- a/src/legacy/ui/public/agg_types/buckets/filters.ts +++ b/src/legacy/ui/public/agg_types/buckets/filters.ts @@ -27,10 +27,9 @@ import { buildEsQuery } from '@kbn/es-query'; import { FiltersParamEditor, FilterValue } from '../../vis/editors/default/controls/filters'; import { createFilterFilters } from './create_filter/filters'; import { BucketAggType, IBucketAggConfig } from './_bucket_agg_type'; -import { setup as data } from '../../../../core_plugins/data/public/legacy'; import { Storage } from '../../../../../plugins/kibana_utils/public'; +import { getQueryLog } from '../../../../../plugins/data/public'; -const { getQueryLog } = data.query.helpers; const config = chrome.getUiSettingsClient(); const storage = new Storage(window.localStorage); diff --git a/src/legacy/ui/public/utils/migrate_legacy_query.ts b/src/legacy/ui/public/utils/migrate_legacy_query.ts index 06e819d6a64a..8d9b50d5a66b 100644 --- a/src/legacy/ui/public/utils/migrate_legacy_query.ts +++ b/src/legacy/ui/public/utils/migrate_legacy_query.ts @@ -18,7 +18,7 @@ */ import { has } from 'lodash'; -import { Query } from 'plugins/data'; +import { Query } from 'src/plugins/data/public'; /** * Creates a standardized query object from old queries that were either strings or pure ES query DSL diff --git a/src/legacy/ui/public/vis/editors/default/controls/filter.tsx b/src/legacy/ui/public/vis/editors/default/controls/filter.tsx index 4ebe7b0d835d..e847a95ead47 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/filter.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/filter.tsx @@ -20,7 +20,8 @@ import React, { useState } from 'react'; import { EuiForm, EuiButtonIcon, EuiFieldText, EuiFormRow, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { Query, QueryBarInput } from 'plugins/data'; +import { QueryBarInput } from 'plugins/data'; +import { Query } from 'src/plugins/data/public'; import { AggConfig } from '../../..'; import { npStart } from '../../../../new_platform'; import { Storage } from '../../../../../../../plugins/kibana_utils/public'; diff --git a/src/legacy/ui/public/vis/editors/default/controls/filters.tsx b/src/legacy/ui/public/vis/editors/default/controls/filters.tsx index fe72e8dddd68..aa654d26a23f 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/filters.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/filters.tsx @@ -21,7 +21,7 @@ import React, { useState, useEffect } from 'react'; import { omit, isEqual } from 'lodash'; import { htmlIdGenerator, EuiButton, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { Query } from 'plugins/data'; +import { Query } from 'src/plugins/data/public'; import chrome from '../../../../chrome'; import { FilterRow } from './filter'; import { AggParamEditorProps } from '..'; diff --git a/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts b/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts index 912afab74bef..36759551a172 100644 --- a/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts +++ b/src/legacy/ui/public/visualize/loader/utils/query_geohash_bounds.ts @@ -22,11 +22,10 @@ import { get } from 'lodash'; import { toastNotifications } from 'ui/notify'; import { AggConfig } from 'ui/vis'; -import { Query } from 'src/legacy/core_plugins/data/public'; import { timefilter } from 'ui/timefilter'; import { Vis } from '../../../vis'; +import { esFilters, Query } from '../../../../../../plugins/data/public'; import { SearchSource } from '../../../courier'; -import { esFilters } from '../../../../../../plugins/data/public'; interface QueryGeohashBoundsParams { filters?: esFilters.Filter[]; diff --git a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx index 8b258f355843..6cefd11c912f 100644 --- a/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard_embeddable_container/public/embeddable/dashboard_container.tsx @@ -20,7 +20,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { I18nProvider } from '@kbn/i18n/react'; -import { RefreshInterval, TimeRange, Query } from '../../../data/public'; +import { RefreshInterval, TimeRange, Query, esFilters } from '../../../data/public'; import { CoreStart } from '../../../../core/public'; import { IUiActionsStart } from '../ui_actions_plugin'; import { @@ -37,7 +37,6 @@ import { createPanelState } from './panel'; import { DashboardPanelState } from './types'; import { DashboardViewport } from './viewport/dashboard_viewport'; import { Start as InspectorStartContract } from '../../../inspector/public'; -import { esFilters } from '../../../../plugins/data/public'; import { KibanaContextProvider, KibanaReactContext, diff --git a/src/plugins/data/public/query/index.tsx b/src/plugins/data/public/query/index.tsx index 9d7c2ffc56f7..224c2f3a0407 100644 --- a/src/plugins/data/public/query/index.tsx +++ b/src/plugins/data/public/query/index.tsx @@ -17,6 +17,8 @@ * under the License. */ +export * from './lib'; + export * from './query_service'; export * from './filter_manager'; diff --git a/src/plugins/data/public/query/lib/from_user.test.ts b/src/plugins/data/public/query/lib/from_user.test.ts new file mode 100644 index 000000000000..b74a1a07dc35 --- /dev/null +++ b/src/plugins/data/public/query/lib/from_user.test.ts @@ -0,0 +1,45 @@ +/* + * 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 { fromUser } from '../'; + +describe('user input helpers', function() { + describe('user input parser', function() { + it('should return the input if passed an object', function() { + expect(fromUser({ foo: 'bar' })).toEqual({ foo: 'bar' }); + }); + + it('unless the object is empty, then convert it to an empty string', function() { + expect(fromUser({})).toEqual(''); + }); + + it('should pass through input strings that not start with {', function() { + expect(fromUser('foo')).toEqual('foo'); + expect(fromUser('400')).toEqual('400'); + expect(fromUser('true')).toEqual('true'); + }); + + it('should parse valid JSON and return the object instead of a string', function() { + expect(fromUser('{}')).toEqual({}); + + // invalid json remains a string + expect(fromUser('{a:b}')).toEqual('{a:b}'); + }); + }); +}); diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/from_user.ts b/src/plugins/data/public/query/lib/from_user.ts similarity index 96% rename from src/legacy/core_plugins/data/public/query/query_bar/lib/from_user.ts rename to src/plugins/data/public/query/lib/from_user.ts index 15eebaa0b9fd..fbb1726fc99e 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/from_user.ts +++ b/src/plugins/data/public/query/lib/from_user.ts @@ -28,6 +28,10 @@ import _ from 'lodash'; export function fromUser(userInput: object | string) { const matchAll = ''; + if (_.isEmpty(userInput)) { + return ''; + } + if (_.isObject(userInput)) { return userInput; } diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts b/src/plugins/data/public/query/lib/get_query_log.ts similarity index 94% rename from src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts rename to src/plugins/data/public/query/lib/get_query_log.ts index 66424d9a1d6a..67073a907804 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/get_query_log.ts +++ b/src/plugins/data/public/query/lib/get_query_log.ts @@ -19,7 +19,7 @@ import { UiSettingsClientContract } from 'src/core/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; -import { PersistedLog } from '../../../../../../../plugins/data/public'; +import { PersistedLog } from '../persisted_log'; export function getQueryLog( uiSettings: UiSettingsClientContract, diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/index.ts b/src/plugins/data/public/query/lib/index.ts similarity index 93% rename from src/legacy/core_plugins/data/public/query/query_bar/lib/index.ts rename to src/plugins/data/public/query/lib/index.ts index 852f9fd269b3..19ac37fb59ae 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/index.ts +++ b/src/plugins/data/public/query/lib/index.ts @@ -20,3 +20,5 @@ export * from './match_pairs'; export * from './from_user'; export * from './to_user'; +export * from './to_user'; +export * from './get_query_log'; diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/match_pairs.ts b/src/plugins/data/public/query/lib/match_pairs.ts similarity index 100% rename from src/legacy/core_plugins/data/public/query/query_bar/lib/match_pairs.ts rename to src/plugins/data/public/query/lib/match_pairs.ts diff --git a/src/plugins/data/public/query/lib/to_user.test.ts b/src/plugins/data/public/query/lib/to_user.test.ts new file mode 100644 index 000000000000..d13afa251ecb --- /dev/null +++ b/src/plugins/data/public/query/lib/to_user.test.ts @@ -0,0 +1,46 @@ +/* + * 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 { toUser } from '../'; + +describe('user input helpers', function() { + describe('model presentation formatter', function() { + it('should present objects as strings', function() { + expect(toUser({ foo: 'bar' })).toBe('{"foo":"bar"}'); + }); + + it('should present query_string queries as strings', function() { + expect(toUser({ query_string: { query: 'lucene query string' } })).toBe( + 'lucene query string' + ); + }); + + it('should present query_string queries without a query as an empty string', function() { + expect(toUser({ query_string: {} })).toBe(''); + }); + + it('should present string as strings', function() { + expect(toUser('foo')).toBe('foo'); + }); + + it('should present numbers as strings', function() { + expect(toUser(400)).toBe('400'); + }); + }); +}); diff --git a/src/legacy/core_plugins/data/public/query/query_bar/lib/to_user.ts b/src/plugins/data/public/query/lib/to_user.ts similarity index 89% rename from src/legacy/core_plugins/data/public/query/query_bar/lib/to_user.ts rename to src/plugins/data/public/query/lib/to_user.ts index 1eb054ba4051..1fdb2d8ed03d 100644 --- a/src/legacy/core_plugins/data/public/query/query_bar/lib/to_user.ts +++ b/src/plugins/data/public/query/lib/to_user.ts @@ -17,14 +17,12 @@ * under the License. */ -import angular from 'angular'; - /** * Take text from the model and present it to the user as a string * @param text model value * @returns {string} */ -export function toUser(text: { [key: string]: any } | string): string { +export function toUser(text: { [key: string]: any } | string | number): string { if (text == null) { return ''; } @@ -35,7 +33,7 @@ export function toUser(text: { [key: string]: any } | string): string { if (text.query_string) { return toUser(text.query_string.query); } - return angular.toJson(text); + return JSON.stringify(text); } return '' + text; } diff --git a/x-pack/legacy/plugins/graph/public/components/search_bar.tsx b/x-pack/legacy/plugins/graph/public/components/search_bar.tsx index d8576c02d29c..293219cca987 100644 --- a/x-pack/legacy/plugins/graph/public/components/search_bar.tsx +++ b/x-pack/legacy/plugins/graph/public/components/search_bar.tsx @@ -11,12 +11,9 @@ import { i18n } from '@kbn/i18n'; import { connect } from 'react-redux'; import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query'; import { IDataPluginServices } from 'src/legacy/core_plugins/data/public/types'; +import { Query } from 'src/plugins/data/public'; import { IndexPatternSavedObject, IndexPatternProvider } from '../types'; -import { - QueryBarInput, - Query, - IndexPattern, -} from '../../../../../../src/legacy/core_plugins/data/public'; +import { QueryBarInput, IndexPattern } from '../../../../../../src/legacy/core_plugins/data/public'; import { openSourceModal } from '../services/source_modal'; import { diff --git a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx index 2815ac9ddda4..fc5088c1271a 100644 --- a/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx +++ b/x-pack/legacy/plugins/lens/public/app_plugin/app.tsx @@ -8,7 +8,7 @@ import _ from 'lodash'; import React, { useState, useEffect, useCallback } from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { DataPublicPluginStart } from 'src/plugins/data/public'; +import { Query, DataPublicPluginStart } from 'src/plugins/data/public'; import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal'; import { CoreStart, NotificationsStart } from 'src/core/public'; import { @@ -16,7 +16,6 @@ import { IndexPattern as IndexPatternInstance, IndexPatterns as IndexPatternsService, SavedQuery, - Query, } from 'src/legacy/core_plugins/data/public'; import { IStorageWrapper } from 'src/plugins/kibana_utils/public'; import { start as navigation } from '../../../../../../src/legacy/core_plugins/navigation/public/legacy'; diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx index 6d782d119525..fabbb6a5d722 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx @@ -6,7 +6,6 @@ import React, { useEffect, useReducer } from 'react'; import { CoreSetup, CoreStart } from 'src/core/public'; -import { Query, SavedQuery } from '../../../../../../../src/legacy/core_plugins/data/public'; import { ExpressionRenderer } from '../../../../../../../src/legacy/core_plugins/expressions/public'; import { Datasource, @@ -25,7 +24,8 @@ import { Document } from '../../persistence/saved_object_store'; import { getSavedObjectFormat } from './save'; import { WorkspacePanelWrapper } from './workspace_panel_wrapper'; import { generateId } from '../../id_generator'; -import { esFilters } from '../../../../../../../src/plugins/data/public'; +import { SavedQuery } from '../../../../../../../src/legacy/core_plugins/data/public'; +import { esFilters, Query } from '../../../../../../../src/plugins/data/public'; export interface EditorFrameProps { doc?: Document; diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/expression_helpers.ts b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/expression_helpers.ts index 6b15bc5c2ef3..19882b15d40a 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/expression_helpers.ts +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/expression_helpers.ts @@ -4,11 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { TimeRange } from 'src/plugins/data/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; import { Ast, fromExpression, ExpressionFunctionAST } from '@kbn/interpreter/common'; import { Visualization, Datasource, FramePublicAPI } from '../../types'; -import { esFilters } from '../../../../../../../src/plugins/data/public'; +import { esFilters, TimeRange, Query } from '../../../../../../../src/plugins/data/public'; export function prependDatasourceExpression( visualizationExpression: Ast | string | null, diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx index 95d39409c57d..a1a906553fe7 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.test.tsx @@ -5,8 +5,7 @@ */ import { Embeddable } from './embeddable'; -import { TimeRange, esFilters } from 'src/plugins/data/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; +import { Query, TimeRange, esFilters } from 'src/plugins/data/public'; import { ExpressionRendererProps } from 'src/legacy/core_plugins/expressions/public'; import { Document } from '../../persistence'; diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.tsx index 0b5d4909c8e7..11b846b3670f 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/embeddable.tsx @@ -8,8 +8,8 @@ import _ from 'lodash'; import React from 'react'; import { render, unmountComponentAtNode } from 'react-dom'; -import { TimeRange, esFilters } from 'src/plugins/data/public'; -import { Query, StaticIndexPattern } from 'src/legacy/core_plugins/data/public'; +import { Query, TimeRange, esFilters } from 'src/plugins/data/public'; +import { StaticIndexPattern } from 'src/legacy/core_plugins/data/public'; import { ExpressionRenderer } from 'src/legacy/core_plugins/expressions/public'; import { Subscription } from 'rxjs'; import { diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/expression_wrapper.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/expression_wrapper.tsx index fc6122821ebf..b3fadaea0afa 100644 --- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/expression_wrapper.tsx +++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/embeddable/expression_wrapper.tsx @@ -9,8 +9,7 @@ import React from 'react'; import { I18nProvider } from '@kbn/i18n/react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiText, EuiIcon } from '@elastic/eui'; -import { TimeRange, esFilters } from 'src/plugins/data/public'; -import { Query } from 'src/legacy/core_plugins/data/public'; +import { TimeRange, esFilters, Query } from 'src/plugins/data/public'; import { ExpressionRenderer } from 'src/legacy/core_plugins/expressions/public'; export interface ExpressionWrapperProps { diff --git a/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.test.tsx b/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.test.tsx index 4da2a040e997..38e4a3fc2427 100644 --- a/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.test.tsx +++ b/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { IndexPattern } from 'ui/index_patterns'; import { FullTimeRangeSelector } from './index'; -import { Query } from 'src/legacy/core_plugins/data/public'; +import { Query } from 'src/plugins/data/public'; // Create a mock for the setFullTimeRange function in the service. // The mock is hoisted to the top, so need to prefix the mock function diff --git a/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.tsx b/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.tsx index 3c377e4dcb44..f637ffb9beea 100644 --- a/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.tsx +++ b/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector.tsx @@ -7,7 +7,7 @@ import React, { FC } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { Query } from 'src/legacy/core_plugins/data/public'; +import { Query } from 'src/plugins/data/public'; import { IndexPattern } from 'ui/index_patterns'; import { EuiButton } from '@elastic/eui'; import { setFullTimeRange } from './full_time_range_selector_service'; diff --git a/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector_service.ts b/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector_service.ts index 9ed908f9ffce..bd31ccf7eca3 100644 --- a/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector_service.ts +++ b/x-pack/legacy/plugins/ml/public/components/full_time_range_selector/full_time_range_selector_service.ts @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n'; import { IndexPattern } from 'ui/index_patterns'; import { toastNotifications } from 'ui/notify'; import { timefilter } from 'ui/timefilter'; -import { Query } from 'src/legacy/core_plugins/data/public'; +import { Query } from 'src/plugins/data/public'; import dateMath from '@elastic/datemath'; import { ml, GetTimeFieldRangeResponse } from '../../services/ml_api_service';