From a920eac1593672e1a08edd91bd9c470deb9096fd Mon Sep 17 00:00:00 2001 From: Yaroslav Kuznietsov Date: Fri, 23 Sep 2022 17:54:18 +0300 Subject: [PATCH] Fixed bundle size. --- .../public/convert_to_lens/datasource.ts | 20 +++++++++++++++++++ .../public/convert_to_lens/utils.ts | 12 ----------- src/plugins/visualizations/public/index.ts | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 src/plugins/visualizations/public/convert_to_lens/datasource.ts diff --git a/src/plugins/visualizations/public/convert_to_lens/datasource.ts b/src/plugins/visualizations/public/convert_to_lens/datasource.ts new file mode 100644 index 0000000000000..502632651170d --- /dev/null +++ b/src/plugins/visualizations/public/convert_to_lens/datasource.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; + +export const getDataViewByIndexPatternId = async ( + indexPatternId: string | undefined, + dataViews: DataViewsPublicPluginStart +) => { + try { + return indexPatternId ? await dataViews.get(indexPatternId) : await dataViews.getDefault(); + } catch (err) { + return null; + } +}; diff --git a/src/plugins/visualizations/public/convert_to_lens/utils.ts b/src/plugins/visualizations/public/convert_to_lens/utils.ts index 66bc71d3d42be..a5337568b5568 100644 --- a/src/plugins/visualizations/public/convert_to_lens/utils.ts +++ b/src/plugins/visualizations/public/convert_to_lens/utils.ts @@ -8,7 +8,6 @@ import type { DataView } from '@kbn/data-views-plugin/common'; import { METRIC_TYPES } from '@kbn/data-plugin/public'; -import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import { AggBasedColumn, SchemaConfig, SupportedAggregation } from '../../common'; import { convertBucketToColumns } from '../../common/convert_to_lens/lib/buckets'; import { isSiblingPipeline } from '../../common/convert_to_lens/lib/utils'; @@ -122,14 +121,3 @@ export const sortColumns = ( }; export const getColumnIds = (columns: AggBasedColumn[]) => columns.map(({ columnId }) => columnId); - -export const getDataViewByIndexPatternId = async ( - indexPatternId: string | undefined, - dataViews: DataViewsPublicPluginStart -) => { - try { - return indexPatternId ? await dataViews.get(indexPatternId) : await dataViews.getDefault(); - } catch (err) { - return null; - } -}; diff --git a/src/plugins/visualizations/public/index.ts b/src/plugins/visualizations/public/index.ts index c704342f14eac..693bbd26a2e2f 100644 --- a/src/plugins/visualizations/public/index.ts +++ b/src/plugins/visualizations/public/index.ts @@ -74,4 +74,4 @@ export { } from './triggers'; export const convertToLensModule = import('./convert_to_lens'); -export { getDataViewByIndexPatternId } from './convert_to_lens/utils'; +export { getDataViewByIndexPatternId } from './convert_to_lens/datasource';