* Move query utils to NP * Updated Query imports * A few import fixes * Fix import * Fix docs
This commit is contained in:
parent
112be014a8
commit
3b1768f007
|
@ -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'
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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<DataSetup, DataStart, {}, DataPluginStartDependencies> {
|
||||
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<DataSetup, DataStart, {}, DataPluginSt
|
|||
|
||||
this.setupApi = {
|
||||
indexPatterns: this.indexPatterns.setup(),
|
||||
query: this.query.setup(),
|
||||
};
|
||||
|
||||
return this.setupApi;
|
||||
|
@ -132,7 +127,6 @@ export class DataPlugin implements Plugin<DataSetup, DataStart, {}, DataPluginSt
|
|||
|
||||
public stop() {
|
||||
this.indexPatterns.stop();
|
||||
this.query.stop();
|
||||
this.search.stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export * from './query_service';
|
||||
export * from './query_bar';
|
||||
|
|
|
@ -49,7 +49,7 @@ jest.mock('../../../../../../../plugins/data/public/query/persisted_log', () =>
|
|||
PersistedLog: mockPersistedLogFactory,
|
||||
}));
|
||||
|
||||
jest.mock('../lib/fetch_index_patterns', () => ({
|
||||
jest.mock('./fetch_index_patterns', () => ({
|
||||
fetchIndexPatterns: mockFetchIndexPatterns,
|
||||
}));
|
||||
|
||||
|
|
|
@ -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<IDataPluginServices>;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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<QueryService>;
|
||||
|
||||
const createSetupContractMock = () => {
|
||||
const setupContract: jest.Mocked<QuerySetup> = {
|
||||
helpers: {
|
||||
fromUser: jest.fn(),
|
||||
toUser: jest.fn(),
|
||||
getQueryLog: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
return setupContract;
|
||||
};
|
||||
|
||||
const createMock = () => {
|
||||
const mocked: jest.Mocked<QueryServiceClientContract> = {
|
||||
setup: jest.fn(),
|
||||
start: jest.fn(),
|
||||
stop: jest.fn(),
|
||||
};
|
||||
|
||||
mocked.setup.mockReturnValue(createSetupContractMock());
|
||||
return mocked;
|
||||
};
|
||||
|
||||
export const queryServiceMock = {
|
||||
create: createMock,
|
||||
createSetupContract: createSetupContractMock,
|
||||
createStartContract: createSetupContractMock,
|
||||
};
|
|
@ -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<QueryService['setup']>;
|
||||
|
||||
export * from './query_bar';
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import {
|
|||
TimeRange,
|
||||
onlyDisabledFiltersChanged,
|
||||
getTime,
|
||||
Query,
|
||||
} from '../../../../../../plugins/data/public';
|
||||
import { Query } from '../../../../data/public';
|
||||
import {
|
||||
APPLY_FILTER_TRIGGER,
|
||||
Container,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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 '..';
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export * from './lib';
|
||||
|
||||
export * from './query_service';
|
||||
export * from './filter_manager';
|
||||
|
||||
|
|
45
src/plugins/data/public/query/lib/from_user.test.ts
Normal file
45
src/plugins/data/public/query/lib/from_user.test.ts
Normal file
|
@ -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}');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -28,6 +28,10 @@ import _ from 'lodash';
|
|||
export function fromUser(userInput: object | string) {
|
||||
const matchAll = '';
|
||||
|
||||
if (_.isEmpty(userInput)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (_.isObject(userInput)) {
|
||||
return userInput;
|
||||
}
|
|
@ -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,
|
|
@ -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';
|
46
src/plugins/data/public/query/lib/to_user.test.ts
Normal file
46
src/plugins/data/public/query/lib/to_user.test.ts
Normal file
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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;
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
Loading…
Reference in a new issue