From 3bcd66590cf14f80db2412b9ea03bd47e505dcef Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Mon, 2 Dec 2019 16:12:20 -0700 Subject: [PATCH 1/3] Remove implicit exports from `ui/courier`. --- src/legacy/ui/public/courier/index.ts | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/legacy/ui/public/courier/index.ts b/src/legacy/ui/public/courier/index.ts index 3c16926d2aba7..6f0b2e83a9ba7 100644 --- a/src/legacy/ui/public/courier/index.ts +++ b/src/legacy/ui/public/courier/index.ts @@ -17,8 +17,27 @@ * under the License. */ -export * from './fetch'; -export * from './search_source'; -export * from './search_strategy'; -export * from './utils/courier_inspector_utils'; -export * from './types'; +export { SearchSource } from './search_source'; +export { searchSourceMock } from './search_source/mocks'; + +export { + addSearchStrategy, // used externally by Rollups + getSearchErrorType, // used externally by Rollups + hasSearchStategyForIndexPattern, // used externally by Discover + isDefaultTypeIndexPattern, // used externally by Discover + SearchError, // used externally by Visualizations & Rollups +} from './search_strategy'; + +export { + getRequestInspectorStats, + getResponseInspectorStats, +} from './utils/courier_inspector_utils'; + +// types +export { SearchSourceContract } from './search_source'; + +export { + EsQuerySortValue, // used externally by Discover + FetchOptions, // used externally by AggTypes + SortDirection, // used externally by Discover +} from './types'; From 8c7c8d1022f49c5e860afc210721eaa578465163 Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Mon, 2 Dec 2019 16:12:42 -0700 Subject: [PATCH 2/3] Clean up miscellaneous courier exports. --- src/legacy/ui/public/courier/fetch/get_search_params.ts | 4 ++-- .../ui/public/courier/utils/courier_inspector_utils.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/legacy/ui/public/courier/fetch/get_search_params.ts b/src/legacy/ui/public/courier/fetch/get_search_params.ts index 21cdbf97945c5..9fb8f2c728c6f 100644 --- a/src/legacy/ui/public/courier/fetch/get_search_params.ts +++ b/src/legacy/ui/public/courier/fetch/get_search_params.ts @@ -40,11 +40,11 @@ export function getSearchParams(config: IUiSettingsClient, esShardTimeout: numbe }; } -export function getIgnoreThrottled(config: IUiSettingsClient) { +function getIgnoreThrottled(config: IUiSettingsClient) { return !config.get('search:includeFrozen'); } -export function getMaxConcurrentShardRequests(config: IUiSettingsClient) { +function getMaxConcurrentShardRequests(config: IUiSettingsClient) { const maxConcurrentShardRequests = config.get('courier:maxConcurrentShardRequests'); return maxConcurrentShardRequests > 0 ? maxConcurrentShardRequests : undefined; } diff --git a/src/legacy/ui/public/courier/utils/courier_inspector_utils.ts b/src/legacy/ui/public/courier/utils/courier_inspector_utils.ts index 2c47fae4cce37..b4d5d5537333e 100644 --- a/src/legacy/ui/public/courier/utils/courier_inspector_utils.ts +++ b/src/legacy/ui/public/courier/utils/courier_inspector_utils.ts @@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n'; import { SearchResponse } from 'elasticsearch'; import { SearchSourceContract, RequestInspectorStats } from '../types'; -function getRequestInspectorStats(searchSource: SearchSourceContract) { +export function getRequestInspectorStats(searchSource: SearchSourceContract) { const stats: RequestInspectorStats = {}; const index = searchSource.getField('index'); @@ -56,7 +56,8 @@ function getRequestInspectorStats(searchSource: SearchSourceContract) { return stats; } -function getResponseInspectorStats( + +export function getResponseInspectorStats( searchSource: SearchSourceContract, resp: SearchResponse ) { @@ -121,5 +122,3 @@ function getResponseInspectorStats( return stats; } - -export { getRequestInspectorStats, getResponseInspectorStats }; From 167661ff8fdc8620285ad8b23571115ef9beefd2 Mon Sep 17 00:00:00 2001 From: Luke Elmers Date: Tue, 3 Dec 2019 08:51:08 -0700 Subject: [PATCH 3/3] Temporarily exclude jest mock from courier exports. --- src/legacy/ui/public/courier/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/legacy/ui/public/courier/index.ts b/src/legacy/ui/public/courier/index.ts index 6f0b2e83a9ba7..c8a06ec2a5518 100644 --- a/src/legacy/ui/public/courier/index.ts +++ b/src/legacy/ui/public/courier/index.ts @@ -18,7 +18,11 @@ */ export { SearchSource } from './search_source'; -export { searchSourceMock } from './search_source/mocks'; + +// TODO: Exporting this mock outside of jest tests causes errors because +// jest is undefined. Need to refactor the mock to be consistent with +// other NP-style mocks. +// export { searchSourceMock } from './search_source/mocks'; export { addSearchStrategy, // used externally by Rollups