From fb2e83ab3baf804b563d4423f1edeedf4e2259c4 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Thu, 2 Sep 2021 19:17:34 +0300 Subject: [PATCH] build optimization --- .../counter_rate/counter_rate_fn.ts | 54 ++++++++ .../common/expressions/counter_rate/index.ts | 64 ++-------- .../common/expressions/counter_rate/types.ts | 16 +++ .../common/expressions/datatable/datatable.ts | 94 ++------------ .../expressions/datatable/datatable_fn.ts | 94 ++++++++++++++ .../common/expressions/datatable/types.ts | 17 +++ .../format_column/format_column_fn.ts | 84 +++++++++++++ .../common/expressions/format_column/index.ts | 117 +----------------- .../format_column/supported_formats.ts | 36 ++++++ .../common/expressions/format_column/types.ts | 19 +++ .../public/embeddable/embeddable_factory.ts | 2 +- .../indexpattern_datasource/indexpattern.tsx | 7 +- .../operations/definitions/ranges/ranges.tsx | 2 +- .../lens/public/lens_attribute_service.ts | 2 +- x-pack/plugins/lens/public/plugin.ts | 3 +- x-pack/plugins/lens/public/search_provider.ts | 2 +- .../visualize_field_actions.ts | 2 +- x-pack/plugins/lens/public/utils.ts | 20 +-- x-pack/plugins/lens/public/vis_type_alias.ts | 4 +- 19 files changed, 362 insertions(+), 277 deletions(-) create mode 100644 x-pack/plugins/lens/common/expressions/counter_rate/counter_rate_fn.ts create mode 100644 x-pack/plugins/lens/common/expressions/counter_rate/types.ts create mode 100644 x-pack/plugins/lens/common/expressions/datatable/datatable_fn.ts create mode 100644 x-pack/plugins/lens/common/expressions/datatable/types.ts create mode 100644 x-pack/plugins/lens/common/expressions/format_column/format_column_fn.ts create mode 100644 x-pack/plugins/lens/common/expressions/format_column/supported_formats.ts create mode 100644 x-pack/plugins/lens/common/expressions/format_column/types.ts diff --git a/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate_fn.ts b/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate_fn.ts new file mode 100644 index 00000000000000..6412b508b96493 --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/counter_rate/counter_rate_fn.ts @@ -0,0 +1,54 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { + buildResultColumns, + getBucketIdentifier, +} from '../../../../../../src/plugins/expressions/common'; +import type { CounterRateExpressionFunction } from './types'; + +export const counterRateFn: CounterRateExpressionFunction['fn'] = ( + input, + { by, inputColumnId, outputColumnId, outputColumnName } +) => { + const resultColumns = buildResultColumns(input, outputColumnId, inputColumnId, outputColumnName); + + if (!resultColumns) { + return input; + } + const previousValues: Partial> = {}; + + return { + ...input, + columns: resultColumns, + rows: input.rows.map((row) => { + const newRow = { ...row }; + + const bucketIdentifier = getBucketIdentifier(row, by); + const previousValue = previousValues[bucketIdentifier]; + const currentValue = newRow[inputColumnId]; + if (currentValue != null && previousValue != null) { + const currentValueAsNumber = Number(currentValue); + if (currentValueAsNumber >= previousValue) { + newRow[outputColumnId] = currentValueAsNumber - previousValue; + } else { + newRow[outputColumnId] = currentValueAsNumber; + } + } else { + newRow[outputColumnId] = undefined; + } + + if (currentValue != null) { + previousValues[bucketIdentifier] = Number(currentValue); + } else { + previousValues[bucketIdentifier] = undefined; + } + + return newRow; + }), + }; +}; diff --git a/x-pack/plugins/lens/common/expressions/counter_rate/index.ts b/x-pack/plugins/lens/common/expressions/counter_rate/index.ts index 41f5547dff969e..f58b65814768d2 100644 --- a/x-pack/plugins/lens/common/expressions/counter_rate/index.ts +++ b/x-pack/plugins/lens/common/expressions/counter_rate/index.ts @@ -6,14 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { - getBucketIdentifier, - buildResultColumns, -} from '../../../../../../src/plugins/expressions/common'; -import type { - ExpressionFunctionDefinition, - Datatable, -} from '../../../../../../src/plugins/expressions/common'; + +import type { CounterRateExpressionFunction } from './types'; export interface CounterRateArgs { by?: string[]; @@ -22,13 +16,6 @@ export interface CounterRateArgs { outputColumnName?: string; } -export type ExpressionFunctionCounterRate = ExpressionFunctionDefinition< - 'lens_counter_rate', - Datatable, - CounterRateArgs, - Datatable ->; - /** * Calculates the counter rate of a specified column in the data table. * @@ -59,7 +46,7 @@ export type ExpressionFunctionCounterRate = ExpressionFunctionDefinition< * before comparison. If the values are objects, the return value of their `toString` method will be used for comparison. * Missing values (`null` and `undefined`) will be treated as empty strings. */ -export const counterRate: ExpressionFunctionCounterRate = { +export const counterRate: CounterRateExpressionFunction = { name: 'lens_counter_rate', type: 'datatable', @@ -101,46 +88,9 @@ export const counterRate: ExpressionFunctionCounterRate = { }, }, - fn(input, { by, inputColumnId, outputColumnId, outputColumnName }) { - const resultColumns = buildResultColumns( - input, - outputColumnId, - inputColumnId, - outputColumnName - ); - - if (!resultColumns) { - return input; - } - const previousValues: Partial> = {}; - return { - ...input, - columns: resultColumns, - rows: input.rows.map((row) => { - const newRow = { ...row }; - - const bucketIdentifier = getBucketIdentifier(row, by); - const previousValue = previousValues[bucketIdentifier]; - const currentValue = newRow[inputColumnId]; - if (currentValue != null && previousValue != null) { - const currentValueAsNumber = Number(currentValue); - if (currentValueAsNumber >= previousValue) { - newRow[outputColumnId] = currentValueAsNumber - previousValue; - } else { - newRow[outputColumnId] = currentValueAsNumber; - } - } else { - newRow[outputColumnId] = undefined; - } - - if (currentValue != null) { - previousValues[bucketIdentifier] = Number(currentValue); - } else { - previousValues[bucketIdentifier] = undefined; - } - - return newRow; - }), - }; + async fn(...args) { + /** Build optimization: prevent adding extra code into initial bundle **/ + const { counterRateFn } = await import('./counter_rate_fn'); + return counterRateFn(...args); }, }; diff --git a/x-pack/plugins/lens/common/expressions/counter_rate/types.ts b/x-pack/plugins/lens/common/expressions/counter_rate/types.ts new file mode 100644 index 00000000000000..f9e1cbbb43de37 --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/counter_rate/types.ts @@ -0,0 +1,16 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { Datatable, ExpressionFunctionDefinition } from '../../../../../../src/plugins/expressions'; +import { CounterRateArgs } from './index'; + +export type CounterRateExpressionFunction = ExpressionFunctionDefinition< + 'lens_counter_rate', + Datatable, + CounterRateArgs, + Datatable | Promise +>; diff --git a/x-pack/plugins/lens/common/expressions/datatable/datatable.ts b/x-pack/plugins/lens/common/expressions/datatable/datatable.ts index 32f6c1c089543d..e24cfdf3acded0 100644 --- a/x-pack/plugins/lens/common/expressions/datatable/datatable.ts +++ b/x-pack/plugins/lens/common/expressions/datatable/datatable.ts @@ -6,17 +6,10 @@ */ import { i18n } from '@kbn/i18n'; -import { cloneDeep } from 'lodash'; -import type { - ExecutionContext, - DatatableColumnMeta, - ExpressionFunctionDefinition, -} from '../../../../../../src/plugins/expressions/common'; +import type { ExecutionContext } from '../../../../../../src/plugins/expressions/common'; import type { FormatFactory, LensMultiTable } from '../../types'; import type { ColumnConfigArg } from './datatable_column'; -import { getSortingCriteria } from './sorting'; -import { computeSummaryRowForColumn } from './summary'; -import { transposeTable } from './transpose_helpers'; +import type { DatatableExpressionFunction } from './types'; export interface SortingState { columnId: string | undefined; @@ -43,18 +36,9 @@ export interface DatatableArgs { sortingDirection: SortingState['direction']; } -function isRange(meta: { params?: { id?: string } } | undefined) { - return meta?.params?.id === 'range'; -} - export const getDatatable = ( getFormatFactory: (context: ExecutionContext) => FormatFactory | Promise -): ExpressionFunctionDefinition< - 'lens_datatable', - LensMultiTable, - DatatableArgs, - Promise -> => ({ +): DatatableExpressionFunction => ({ name: 'lens_datatable', type: 'render', inputTypes: ['lens_multitable'], @@ -86,73 +70,9 @@ export const getDatatable = ( help: '', }, }, - async fn(data, args, context) { - let untransposedData: LensMultiTable | undefined; - // do the sorting at this level to propagate it also at CSV download - const [firstTable] = Object.values(data.tables); - const [layerId] = Object.keys(context.inspectorAdapters.tables || {}); - const formatters: Record> = {}; - const formatFactory = await getFormatFactory(context); - - firstTable.columns.forEach((column) => { - formatters[column.id] = formatFactory(column.meta?.params); - }); - - const hasTransposedColumns = args.columns.some((c) => c.isTransposed); - if (hasTransposedColumns) { - // store original shape of data separately - untransposedData = cloneDeep(data); - // transposes table and args inplace - transposeTable(args, firstTable, formatters); - } - - const { sortingColumnId: sortBy, sortingDirection: sortDirection } = args; - - const columnsReverseLookup = firstTable.columns.reduce< - Record - >((memo, { id, name, meta }, i) => { - memo[id] = { name, index: i, meta }; - return memo; - }, {}); - - const columnsWithSummary = args.columns.filter((c) => c.summaryRow); - for (const column of columnsWithSummary) { - column.summaryRowValue = computeSummaryRowForColumn( - column, - firstTable, - formatters, - formatFactory({ id: 'number' }) - ); - } - - if (sortBy && columnsReverseLookup[sortBy] && sortDirection !== 'none') { - // Sort on raw values for these types, while use the formatted value for the rest - const sortingCriteria = getSortingCriteria( - isRange(columnsReverseLookup[sortBy]?.meta) - ? 'range' - : columnsReverseLookup[sortBy]?.meta?.type, - sortBy, - formatters[sortBy], - sortDirection - ); - // replace the table here - context.inspectorAdapters.tables[layerId].rows = (firstTable.rows || []) - .slice() - .sort(sortingCriteria); - // replace also the local copy - firstTable.rows = context.inspectorAdapters.tables[layerId].rows; - } else { - args.sortingColumnId = undefined; - args.sortingDirection = 'none'; - } - return { - type: 'render', - as: 'lens_datatable_renderer', - value: { - data, - untransposedData, - args, - }, - }; + async fn(...args) { + /** Build optimization: prevent adding extra code into initial bundle **/ + const { datatableFn } = await import('./datatable_fn'); + return datatableFn(getFormatFactory)(...args); }, }); diff --git a/x-pack/plugins/lens/common/expressions/datatable/datatable_fn.ts b/x-pack/plugins/lens/common/expressions/datatable/datatable_fn.ts new file mode 100644 index 00000000000000..cafd3526ee2940 --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/datatable/datatable_fn.ts @@ -0,0 +1,94 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { cloneDeep } from 'lodash'; +import { FormatFactory, LensMultiTable } from '../../types'; +import { transposeTable } from './transpose_helpers'; +import { computeSummaryRowForColumn } from './summary'; +import { getSortingCriteria } from './sorting'; +import type { + DatatableColumnMeta, + ExecutionContext, +} from '../../../../../../src/plugins/expressions'; +import type { DatatableExpressionFunction } from './types'; + +function isRange(meta: { params?: { id?: string } } | undefined) { + return meta?.params?.id === 'range'; +} + +export const datatableFn = ( + getFormatFactory: (context: ExecutionContext) => FormatFactory | Promise +) => + (async (data, args, context) => { + let untransposedData: LensMultiTable | undefined; + // do the sorting at this level to propagate it also at CSV download + const [firstTable] = Object.values(data.tables); + const [layerId] = Object.keys(context.inspectorAdapters.tables || {}); + const formatters: Record> = {}; + const formatFactory = await getFormatFactory(context); + + firstTable.columns.forEach((column) => { + formatters[column.id] = formatFactory(column.meta?.params); + }); + + const hasTransposedColumns = args.columns.some((c) => c.isTransposed); + if (hasTransposedColumns) { + // store original shape of data separately + untransposedData = cloneDeep(data); + // transposes table and args inplace + transposeTable(args, firstTable, formatters); + } + + const { sortingColumnId: sortBy, sortingDirection: sortDirection } = args; + + const columnsReverseLookup = firstTable.columns.reduce< + Record + >((memo, { id, name, meta }, i) => { + memo[id] = { name, index: i, meta }; + return memo; + }, {}); + + const columnsWithSummary = args.columns.filter((c) => c.summaryRow); + for (const column of columnsWithSummary) { + column.summaryRowValue = computeSummaryRowForColumn( + column, + firstTable, + formatters, + formatFactory({ id: 'number' }) + ); + } + + if (sortBy && columnsReverseLookup[sortBy] && sortDirection !== 'none') { + // Sort on raw values for these types, while use the formatted value for the rest + const sortingCriteria = getSortingCriteria( + isRange(columnsReverseLookup[sortBy]?.meta) + ? 'range' + : columnsReverseLookup[sortBy]?.meta?.type, + sortBy, + formatters[sortBy], + sortDirection + ); + // replace the table here + context.inspectorAdapters.tables[layerId].rows = (firstTable.rows || []) + .slice() + .sort(sortingCriteria); + // replace also the local copy + firstTable.rows = context.inspectorAdapters.tables[layerId].rows; + } else { + args.sortingColumnId = undefined; + args.sortingDirection = 'none'; + } + return { + type: 'render', + as: 'lens_datatable_renderer', + value: { + data, + untransposedData, + args, + }, + }; + }) as DatatableExpressionFunction['fn']; diff --git a/x-pack/plugins/lens/common/expressions/datatable/types.ts b/x-pack/plugins/lens/common/expressions/datatable/types.ts new file mode 100644 index 00000000000000..f60d3b471a973f --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/datatable/types.ts @@ -0,0 +1,17 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { ExpressionFunctionDefinition } from '../../../../../../src/plugins/expressions'; +import type { LensMultiTable } from '../../types'; +import type { DatatableArgs, DatatableRender } from './datatable'; + +export type DatatableExpressionFunction = ExpressionFunctionDefinition< + 'lens_datatable', + LensMultiTable, + DatatableArgs, + Promise +>; diff --git a/x-pack/plugins/lens/common/expressions/format_column/format_column_fn.ts b/x-pack/plugins/lens/common/expressions/format_column/format_column_fn.ts new file mode 100644 index 00000000000000..37540ee0950afb --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/format_column/format_column_fn.ts @@ -0,0 +1,84 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { supportedFormats } from './supported_formats'; +import type { DatatableColumn } from '../../../../../../src/plugins/expressions'; +import type { FormatColumnArgs } from './index'; +import type { FormatColumnExpressionFunction } from './types'; + +function isNestedFormat(params: DatatableColumn['meta']['params']) { + // if there is a nested params object with an id, it's a nested format + return !!params?.params?.id; +} + +function withParams(col: DatatableColumn, params: Record) { + return { ...col, meta: { ...col.meta, params } }; +} + +export const formatColumnFn: FormatColumnExpressionFunction['fn'] = ( + input, + { format, columnId, decimals, parentFormat }: FormatColumnArgs +) => ({ + ...input, + columns: input.columns.map((col) => { + if (col.id === columnId) { + if (!parentFormat) { + if (supportedFormats[format]) { + return withParams(col, { + id: format, + params: { pattern: supportedFormats[format].decimalsToPattern(decimals) }, + }); + } else if (format) { + return withParams(col, { id: format }); + } else { + return col; + } + } + + const parsedParentFormat = JSON.parse(parentFormat); + const parentFormatId = parsedParentFormat.id; + const parentFormatParams = parsedParentFormat.params ?? {}; + + if (!parentFormatId) { + return col; + } + + if (format && supportedFormats[format]) { + return withParams(col, { + id: parentFormatId, + params: { + id: format, + params: { + pattern: supportedFormats[format].decimalsToPattern(decimals), + }, + ...parentFormatParams, + }, + }); + } + if (parentFormatParams) { + // if original format is already a nested one, we are just replacing the wrapper params + // otherwise wrapping it inside parentFormatId/parentFormatParams + const isNested = isNestedFormat(col.meta.params); + const innerParams = isNested + ? col.meta.params?.params + : { id: col.meta.params?.id, params: col.meta.params?.params }; + + const formatId = isNested ? col.meta.params?.id : parentFormatId; + + return withParams(col, { + ...col.meta.params, + id: formatId, + params: { + ...innerParams, + ...parentFormatParams, + }, + }); + } + } + return col; + }), +}); diff --git a/x-pack/plugins/lens/common/expressions/format_column/index.ts b/x-pack/plugins/lens/common/expressions/format_column/index.ts index c874eac1ede1ff..0fc99ff8f70894 100644 --- a/x-pack/plugins/lens/common/expressions/format_column/index.ts +++ b/x-pack/plugins/lens/common/expressions/format_column/index.ts @@ -5,11 +5,7 @@ * 2.0. */ -import type { - ExpressionFunctionDefinition, - Datatable, - DatatableColumn, -} from '../../../../../../src/plugins/expressions/common'; +import type { FormatColumnExpressionFunction } from './types'; export interface FormatColumnArgs { format: string; @@ -18,42 +14,7 @@ export interface FormatColumnArgs { parentFormat?: string; } -export const supportedFormats: Record< - string, - { decimalsToPattern: (decimals?: number) => string } -> = { - number: { - decimalsToPattern: (decimals = 2) => { - if (decimals === 0) { - return `0,0`; - } - return `0,0.${'0'.repeat(decimals)}`; - }, - }, - percent: { - decimalsToPattern: (decimals = 2) => { - if (decimals === 0) { - return `0,0%`; - } - return `0,0.${'0'.repeat(decimals)}%`; - }, - }, - bytes: { - decimalsToPattern: (decimals = 2) => { - if (decimals === 0) { - return `0,0b`; - } - return `0,0.${'0'.repeat(decimals)}b`; - }, - }, -}; - -export const formatColumn: ExpressionFunctionDefinition< - 'lens_format_column', - Datatable, - FormatColumnArgs, - Datatable -> = { +export const formatColumn: FormatColumnExpressionFunction = { name: 'lens_format_column', type: 'datatable', help: '', @@ -78,75 +39,9 @@ export const formatColumn: ExpressionFunctionDefinition< }, }, inputTypes: ['datatable'], - fn(input, { format, columnId, decimals, parentFormat }: FormatColumnArgs) { - return { - ...input, - columns: input.columns.map((col) => { - if (col.id === columnId) { - if (!parentFormat) { - if (supportedFormats[format]) { - return withParams(col, { - id: format, - params: { pattern: supportedFormats[format].decimalsToPattern(decimals) }, - }); - } else if (format) { - return withParams(col, { id: format }); - } else { - return col; - } - } - - const parsedParentFormat = JSON.parse(parentFormat); - const parentFormatId = parsedParentFormat.id; - const parentFormatParams = parsedParentFormat.params ?? {}; - - if (!parentFormatId) { - return col; - } - - if (format && supportedFormats[format]) { - return withParams(col, { - id: parentFormatId, - params: { - id: format, - params: { - pattern: supportedFormats[format].decimalsToPattern(decimals), - }, - ...parentFormatParams, - }, - }); - } - if (parentFormatParams) { - // if original format is already a nested one, we are just replacing the wrapper params - // otherwise wrapping it inside parentFormatId/parentFormatParams - const isNested = isNestedFormat(col.meta.params); - const innerParams = isNested - ? col.meta.params?.params - : { id: col.meta.params?.id, params: col.meta.params?.params }; - - const formatId = isNested ? col.meta.params?.id : parentFormatId; - - return withParams(col, { - ...col.meta.params, - id: formatId, - params: { - ...innerParams, - ...parentFormatParams, - }, - }); - } - } - return col; - }), - }; + async fn(...args) { + /** Build optimization: prevent adding extra code into initial bundle **/ + const { formatColumnFn } = await import('./format_column_fn'); + return formatColumnFn(...args); }, }; - -function isNestedFormat(params: DatatableColumn['meta']['params']) { - // if there is a nested params object with an id, it's a nested format - return !!params?.params?.id; -} - -function withParams(col: DatatableColumn, params: Record) { - return { ...col, meta: { ...col.meta, params } }; -} diff --git a/x-pack/plugins/lens/common/expressions/format_column/supported_formats.ts b/x-pack/plugins/lens/common/expressions/format_column/supported_formats.ts new file mode 100644 index 00000000000000..d00d2f7dfc22fe --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/format_column/supported_formats.ts @@ -0,0 +1,36 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export const supportedFormats: Record< + string, + { decimalsToPattern: (decimals?: number) => string } +> = { + number: { + decimalsToPattern: (decimals = 2) => { + if (decimals === 0) { + return `0,0`; + } + return `0,0.${'0'.repeat(decimals)}`; + }, + }, + percent: { + decimalsToPattern: (decimals = 2) => { + if (decimals === 0) { + return `0,0%`; + } + return `0,0.${'0'.repeat(decimals)}%`; + }, + }, + bytes: { + decimalsToPattern: (decimals = 2) => { + if (decimals === 0) { + return `0,0b`; + } + return `0,0.${'0'.repeat(decimals)}b`; + }, + }, +}; diff --git a/x-pack/plugins/lens/common/expressions/format_column/types.ts b/x-pack/plugins/lens/common/expressions/format_column/types.ts new file mode 100644 index 00000000000000..589422b253b93a --- /dev/null +++ b/x-pack/plugins/lens/common/expressions/format_column/types.ts @@ -0,0 +1,19 @@ +/* + * 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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { + Datatable, + ExpressionFunctionDefinition, +} from '../../../../../../src/plugins/expressions'; +import type { FormatColumnArgs } from './index'; + +export type FormatColumnExpressionFunction = ExpressionFunctionDefinition< + 'lens_format_column', + Datatable, + FormatColumnArgs, + Datatable | Promise +>; diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts index 5620f053cebf27..954905c51a4b7d 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts +++ b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts @@ -21,7 +21,7 @@ import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public'; import { Start as InspectorStart } from '../../../../../src/plugins/inspector/public'; import { Document } from '../persistence/saved_object_store'; import { LensAttributeService } from '../lens_attribute_service'; -import { DOC_TYPE } from '../../common'; +import { DOC_TYPE } from '../../common/constants'; import { ErrorMessage } from '../editor_frame_service/types'; import { extract, inject } from '../../common/embeddable_factory'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx index c54fa733e74993..6a45e3c987f3d7 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.tsx @@ -70,12 +70,7 @@ export function columnToOperation(column: IndexPatternColumn, uniqueLabel?: stri }; } -export type { - FormatColumnArgs, - TimeScaleArgs, - CounterRateArgs, - ExpressionFunctionCounterRate, -} from '../../common/expressions'; +export type { FormatColumnArgs, TimeScaleArgs, CounterRateArgs } from '../../common/expressions'; export { getSuffixFormatter, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx index ceb02ab724ac58..29e7de18ca4ade 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/ranges/ranges.tsx @@ -21,7 +21,7 @@ import { RangeEditor } from './range_editor'; import { OperationDefinition } from '../index'; import { FieldBasedIndexPatternColumn } from '../column_types'; import { updateColumnParam } from '../../layer_helpers'; -import { supportedFormats } from '../../../../../common/expressions'; +import { supportedFormats } from '../../../../../common/expressions/format_column/supported_formats'; import { MODES, AUTO_BARS, DEFAULT_INTERVAL, MIN_HISTOGRAM_BARS, SLICES } from './constants'; import { IndexPattern, IndexPatternField } from '../../../types'; import { getInvalidFieldMessage, isValidNumber } from '../helpers'; diff --git a/x-pack/plugins/lens/public/lens_attribute_service.ts b/x-pack/plugins/lens/public/lens_attribute_service.ts index 3b8c47022af6e4..039508afc1c91a 100644 --- a/x-pack/plugins/lens/public/lens_attribute_service.ts +++ b/x-pack/plugins/lens/public/lens_attribute_service.ts @@ -16,7 +16,7 @@ import type { import { SavedObjectIndexStore, Document } from './persistence'; import { checkForDuplicateTitle, OnSaveProps } from '../../../../src/plugins/saved_objects/public'; -import { DOC_TYPE } from '../common'; +import { DOC_TYPE } from '../common/constants'; export type LensAttributeService = AttributeService< LensSavedObjectAttributes, diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts index db63b990b90137..fc799d33e5f98e 100644 --- a/x-pack/plugins/lens/public/plugin.ts +++ b/x-pack/plugins/lens/public/plugin.ts @@ -64,7 +64,8 @@ import { ACTION_VISUALIZE_FIELD, VISUALIZE_FIELD_TRIGGER, } from '../../../../src/plugins/ui_actions/public'; -import { APP_ID, FormatFactory, getEditPath, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common'; +import { APP_ID, getEditPath, NOT_INTERNATIONALIZED_PRODUCT_NAME } from '../common/constants'; +import type { FormatFactory } from '../common/types'; import type { VisualizationType } from './types'; import { getLensAliasConfig } from './vis_type_alias'; import { visualizeFieldAction } from './trigger_actions/visualize_field_actions'; diff --git a/x-pack/plugins/lens/public/search_provider.ts b/x-pack/plugins/lens/public/search_provider.ts index 4bc18f2653a0b1..ddbe11a1fc756f 100644 --- a/x-pack/plugins/lens/public/search_provider.ts +++ b/x-pack/plugins/lens/public/search_provider.ts @@ -10,7 +10,7 @@ import { from, of } from 'rxjs'; import { i18n } from '@kbn/i18n'; import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/public'; import { GlobalSearchResultProvider } from '../../global_search/public'; -import { getFullPath } from '../common'; +import { getFullPath } from '../common/constants'; /** * Global search provider adding a Lens entry. diff --git a/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts b/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts index 9e7507b01bc59b..4e105ed9db499a 100644 --- a/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts +++ b/x-pack/plugins/lens/public/trigger_actions/visualize_field_actions.ts @@ -11,7 +11,7 @@ import { ACTION_VISUALIZE_LENS_FIELD, VisualizeFieldContext, } from '../../../../../src/plugins/ui_actions/public'; -import { ApplicationStart } from '../../../../../src/core/public'; +import type { ApplicationStart } from '../../../../../src/core/public'; export const visualizeFieldAction = (application: ApplicationStart) => createAction({ diff --git a/x-pack/plugins/lens/public/utils.ts b/x-pack/plugins/lens/public/utils.ts index b7dd3ed3733cf6..993be9a06a2d99 100644 --- a/x-pack/plugins/lens/public/utils.ts +++ b/x-pack/plugins/lens/public/utils.ts @@ -4,16 +4,20 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ - +import { uniq } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { IndexPattern, IndexPatternsContract, TimefilterContract } from 'src/plugins/data/public'; -import { IUiSettingsClient } from 'kibana/public'; import moment from 'moment-timezone'; -import { SavedObjectReference } from 'kibana/public'; -import { uniq } from 'lodash'; -import { Document } from './persistence/saved_object_store'; -import { Datasource, DatasourceMap } from './types'; -import { DatasourceStates } from './state_management'; + +import type { + IndexPattern, + IndexPatternsContract, + TimefilterContract, +} from 'src/plugins/data/public'; +import type { IUiSettingsClient } from 'kibana/public'; +import type { SavedObjectReference } from 'kibana/public'; +import type { Document } from './persistence/saved_object_store'; +import type { Datasource, DatasourceMap } from './types'; +import type { DatasourceStates } from './state_management'; export function getVisualizeGeoFieldMessage(fieldType: string) { return i18n.translate('xpack.lens.visualizeGeoFieldMessage', { diff --git a/x-pack/plugins/lens/public/vis_type_alias.ts b/x-pack/plugins/lens/public/vis_type_alias.ts index 5b48ef8b31923a..96332e07069b0b 100644 --- a/x-pack/plugins/lens/public/vis_type_alias.ts +++ b/x-pack/plugins/lens/public/vis_type_alias.ts @@ -6,8 +6,8 @@ */ import { i18n } from '@kbn/i18n'; -import { VisTypeAlias } from 'src/plugins/visualizations/public'; -import { getBasePath, getEditPath } from '../common'; +import type { VisTypeAlias } from 'src/plugins/visualizations/public'; +import { getBasePath, getEditPath } from '../common/constants'; export const getLensAliasConfig = (): VisTypeAlias => ({ aliasPath: getBasePath(),