Skip to content

Commit

Permalink
[data.search.aggs]: Remove remaining client dependencies (#70251)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers authored Jul 8, 2020
1 parent f5b77e1 commit d43c460
Show file tree
Hide file tree
Showing 139 changed files with 1,907 additions and 2,570 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
| --- | --- |
| [getDefaultQuery(language)](./kibana-plugin-plugins-data-public.getdefaultquery.md) | |
| [getEsPreference(uiSettings, sessionId)](./kibana-plugin-plugins-data-public.getespreference.md) | |
| [getQueryLog(uiSettings, storage, appName, language)](./kibana-plugin-plugins-data-public.getquerylog.md) | |
| [getSearchErrorType({ message })](./kibana-plugin-plugins-data-public.getsearcherrortype.md) | |
| [getSearchParamsFromRequest(searchRequest, dependencies)](./kibana-plugin-plugins-data-public.getsearchparamsfromrequest.md) | |
| [getTime(indexPattern, timeRange, options)](./kibana-plugin-plugins-data-public.gettime.md) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
QueryStringInput: React.FC<Pick<Props, "query" | "prepend" | "placeholder" | "onChange" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition">>
QueryStringInput: React.FC<Pick<Props, "query" | "prepend" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition">>
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ search: {
})[];
InvalidEsCalendarIntervalError: typeof InvalidEsCalendarIntervalError;
InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError;
Ipv4Address: typeof Ipv4Address;
isDateHistogramBucketAggConfig: typeof isDateHistogramBucketAggConfig;
isNumberType: (agg: import("./search").AggConfig) => boolean;
isStringType: (agg: import("./search").AggConfig) => boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ search: {
dateHistogramInterval: typeof dateHistogramInterval;
InvalidEsCalendarIntervalError: typeof InvalidEsCalendarIntervalError;
InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError;
Ipv4Address: typeof Ipv4Address;
isValidEsInterval: typeof isValidEsInterval;
isValidInterval: typeof isValidInterval;
parseEsInterval: typeof parseEsInterval;
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/common/search/aggs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
*/

export * from './date_interval_utils';
export * from './ipv4_address';
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
// @ts-ignore

import expect from '@kbn/expect';
import { Ipv4Address } from './ipv4_address';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function isIntegerInRange(integer: number, min: number, max: number) {
);
}

// eslint-disable-next-line import/no-default-export
export class Ipv4Address {
private value: number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import { createFiltersFromRangeSelectAction } from './create_filters_from_range_

import { IndexPatternsContract, RangeFilter } from '../../../public';
import { dataPluginMock } from '../../../public/mocks';
import { setIndexPatterns } from '../../../public/services';
import { mockDataServices } from '../../../public/search/aggs/test_helpers';
import { setIndexPatterns, setSearchService } from '../../../public/services';
import { TriggerContextMapping } from '../../../../ui_actions/public';

describe('brushEvent', () => {
Expand All @@ -51,9 +50,10 @@ describe('brushEvent', () => {
];

beforeEach(() => {
mockDataServices();
const dataStart = dataPluginMock.createStartContract();
setSearchService(dataStart.search);
setIndexPatterns(({
...dataPluginMock.createStartContract().indexPatterns,
...dataStart.indexPatterns,
get: async () => indexPattern,
} as unknown) as IndexPatternsContract);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import {
IndexPatternsContract,
} from '../../../public';
import { dataPluginMock } from '../../../public/mocks';
import { setIndexPatterns } from '../../../public/services';
import { mockDataServices } from '../../../public/search/aggs/test_helpers';
import { setIndexPatterns, setSearchService } from '../../../public/services';
import { createFiltersFromValueClickAction } from './create_filters_from_value_click';
import { ValueClickContext } from '../../../../embeddable/public';

Expand Down Expand Up @@ -72,9 +71,10 @@ describe('createFiltersFromValueClick', () => {
},
];

mockDataServices();
const dataStart = dataPluginMock.createStartContract();
setSearchService(dataStart.search);
setIndexPatterns(({
...dataPluginMock.createStartContract().indexPatterns,
...dataStart.indexPatterns,
get: async () => ({
id: 'logstash-*',
fields: {
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ import {
dateHistogramInterval,
InvalidEsCalendarIntervalError,
InvalidEsIntervalFormatError,
Ipv4Address,
isValidEsInterval,
isValidInterval,
parseEsInterval,
Expand Down Expand Up @@ -373,6 +374,7 @@ export const search = {
intervalOptions,
InvalidEsCalendarIntervalError,
InvalidEsIntervalFormatError,
Ipv4Address,
isDateHistogramBucketAggConfig, // TODO: remove in build_pipeline refactor
isNumberType,
isStringType,
Expand Down Expand Up @@ -417,7 +419,6 @@ export {
connectToQueryState,
syncQueryStateWithUrl,
QueryState,
getQueryLog,
getDefaultQuery,
FilterManager,
SavedQuery,
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ export class DataPublicPlugin implements Plugin<DataPublicPluginSetup, DataPubli
});
setIndexPatterns(indexPatterns);

const query = this.queryService.start(savedObjects);
const query = this.queryService.start({
storage: this.storage,
savedObjectsClient: savedObjects.client,
uiSettings,
});
setQueryService(query);

const search = this.searchService.start(core, { indexPatterns });
Expand Down
48 changes: 23 additions & 25 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { EuiGlobalToastListToast } from '@elastic/eui';
import { ExclusiveUnion } from '@elastic/eui';
import { ExistsParams } from 'elasticsearch';
import { ExplainParams } from 'elasticsearch';
import { ExpressionAstFunction } from 'src/plugins/expressions/public';
import { ExpressionAstFunction } from 'src/plugins/expressions/common';
import { ExpressionsSetup } from 'src/plugins/expressions/public';
import { FieldStatsParams } from 'elasticsearch';
import { GenericParams } from 'elasticsearch';
Expand Down Expand Up @@ -145,17 +145,19 @@ import { RecursiveReadonly } from '@kbn/utility-types';
import { ReindexParams } from 'elasticsearch';
import { ReindexRethrottleParams } from 'elasticsearch';
import { RenderSearchTemplateParams } from 'elasticsearch';
import { RequestAdapter } from 'src/plugins/inspector/common';
import { RequestStatistics } from 'src/plugins/inspector/common';
import { Required } from '@kbn/utility-types';
import * as Rx from 'rxjs';
import { SavedObject } from 'src/core/server';
import { SavedObject as SavedObject_3 } from 'src/core/public';
import { SavedObjectsClientContract as SavedObjectsClientContract_3 } from 'src/core/public';
import { SavedObjectsClientContract } from 'src/core/public';
import { ScrollParams } from 'elasticsearch';
import { SearchParams } from 'elasticsearch';
import { SearchResponse as SearchResponse_2 } from 'elasticsearch';
import { SearchShardsParams } from 'elasticsearch';
import { SearchTemplateParams } from 'elasticsearch';
import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/expressions/public';
import { SerializedFieldFormat as SerializedFieldFormat_2 } from 'src/plugins/expressions/common';
import { SnapshotCreateParams } from 'elasticsearch';
import { SnapshotCreateRepositoryParams } from 'elasticsearch';
import { SnapshotDeleteParams } from 'elasticsearch';
Expand Down Expand Up @@ -299,7 +301,7 @@ export const connectToQueryState: <S extends QueryState>({ timefilter: { timefil
// Warning: (ae-missing-release-tag) "createSavedQueryService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const createSavedQueryService: (savedObjectsClient: SavedObjectsClientContract_3) => SavedQueryService;
export const createSavedQueryService: (savedObjectsClient: SavedObjectsClientContract) => SavedQueryService;

// Warning: (ae-missing-release-tag) "CustomFilter" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
Expand Down Expand Up @@ -750,12 +752,6 @@ export const getIndexPatternFieldListCreator: ({ fieldFormats, onNotification, }
// @public
export const getKbnTypeNames: () => string[];

// Warning: (ae-forgotten-export) The symbol "PersistedLog" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "getQueryLog" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function getQueryLog(uiSettings: IUiSettingsClient, storage: IStorageWrapper, appName: string, language: string): PersistedLog<any>;

// Warning: (ae-missing-release-tag) "getSearchErrorType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -1486,7 +1482,7 @@ export interface QueryState {
// Warning: (ae-missing-release-tag) "QueryStringInput" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "prepend" | "placeholder" | "onChange" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition">>;
export const QueryStringInput: React.FC<Pick<Props_3, "query" | "prepend" | "placeholder" | "onChange" | "onBlur" | "onSubmit" | "indexPatterns" | "dataTestSubj" | "screenTitle" | "disableAutoFocus" | "persistedLog" | "bubbleSubmitEvent" | "languageSwitcherPopoverAnchorPosition">>;

// @public (undocumented)
export type QuerySuggestion = QuerySuggestionBasic | QuerySuggestionField;
Expand Down Expand Up @@ -1675,6 +1671,7 @@ export const search: {
})[];
InvalidEsCalendarIntervalError: typeof InvalidEsCalendarIntervalError;
InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError;
Ipv4Address: typeof Ipv4Address;
isDateHistogramBucketAggConfig: typeof isDateHistogramBucketAggConfig;
isNumberType: (agg: import("./search").AggConfig) => boolean;
isStringType: (agg: import("./search").AggConfig) => boolean;
Expand Down Expand Up @@ -1979,20 +1976,21 @@ export const UI_SETTINGS: {
// src/plugins/data/public/index.ts:233:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:233:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:233:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:369:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:369:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:369:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:369:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:371:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:372:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:381:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:395:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:370:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:372:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:373:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:382:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:383:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:384:1 - (ae-forgotten-export) The symbol "Ipv4Address" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:385:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/index.ts:397:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/query/state_sync/connect_to_query_state.ts:40:60 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts
// src/plugins/data/public/types.ts:53:5 - (ae-forgotten-export) The symbol "createFiltersFromRangeSelectAction" needs to be exported by the entry point index.d.ts
Expand Down
44 changes: 44 additions & 0 deletions src/plugins/data/public/query/lib/add_to_query_log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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 { IUiSettingsClient } from 'src/core/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { Query } from '../../../common';
import { getQueryLog } from './get_query_log';

interface AddToQueryLogDependencies {
uiSettings: IUiSettingsClient;
storage: IStorageWrapper;
}

export function createAddToQueryLog({ storage, uiSettings }: AddToQueryLogDependencies) {
/**
* This function is to be used in conjunction with `<QueryStringInput />`.
* It provides a way for external editors to add new filter entries to the
* persisted query log which lives in `localStorage`. These entries are then
* read by `<QueryStringInput />` and provided in the autocomplete options.
*
* @param appName Name of the app where this filter is added from.
* @param query Filter value to add.
*/
return function addToQueryLog(appName: string, { language, query }: Query) {
const persistedLog = getQueryLog(uiSettings, storage, appName, language);
persistedLog.add(query);
};
}
1 change: 1 addition & 0 deletions src/plugins/data/public/query/lib/get_query_log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { PersistedLog } from '../persisted_log';
import { UI_SETTINGS } from '../../../common';

/** @internal */
export function getQueryLog(
uiSettings: IUiSettingsClient,
storage: IStorageWrapper,
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/data/public/query/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
* under the License.
*/

export * from './match_pairs';
export * from './add_to_query_log';
export * from './from_user';
export * from './get_default_query';
export * from './get_query_log';
export * from './match_pairs';
export * from './to_user';
export * from './to_user';
export * from './get_query_log';
export * from './get_default_query';
3 changes: 2 additions & 1 deletion src/plugins/data/public/query/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ const createSetupContractMock = () => {

const createStartContractMock = () => {
const startContract: jest.Mocked<QueryStart> = {
addToQueryLog: jest.fn(),
filterManager: jest.fn() as any,
timefilter: timefilterServiceMock.createStartContract(),
savedQueries: jest.fn() as any,
state$: new Observable(),
timefilter: timefilterServiceMock.createStartContract(),
};

return startContract;
Expand Down
Loading

0 comments on commit d43c460

Please sign in to comment.