diff --git a/package.json b/package.json index f2a40b4ae564e..18d7ce10286ec 100644 --- a/package.json +++ b/package.json @@ -575,6 +575,7 @@ "@types/kbn__field-types": "link:bazel-bin/packages/kbn-field-types/npm_module_types", "@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types", "@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types", + "@types/kbn__interpreter": "link:bazel-bin/packages/kbn-interpreter/npm_module_types", "@types/kbn__mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types", "@types/kbn__monaco": "link:bazel-bin/packages/kbn-monaco/npm_module_types", "@types/kbn__optimizer": "link:bazel-bin/packages/kbn-optimizer/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index dfe7768e2ad15..04c4bc9b9901c 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -93,6 +93,7 @@ filegroup( "//packages/kbn-field-types:build_types", "//packages/kbn-i18n:build_types", "//packages/kbn-i18n-react:build_types", + "//packages/kbn-interpreter:build_types", "//packages/kbn-mapbox-gl:build_types", "//packages/kbn-monaco:build_types", "//packages/kbn-optimizer:build_types", diff --git a/packages/kbn-interpreter/BUILD.bazel b/packages/kbn-interpreter/BUILD.bazel index 52df0f0aa8d85..fd19413116f8d 100644 --- a/packages/kbn-interpreter/BUILD.bazel +++ b/packages/kbn-interpreter/BUILD.bazel @@ -1,10 +1,11 @@ -load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") +load("@npm//@bazel/typescript:index.bzl", "ts_config") load("@npm//peggy:index.bzl", "peggy") -load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") -load("//src/dev/bazel:index.bzl", "jsts_transpiler") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") PKG_BASE_NAME = "kbn-interpreter" PKG_REQUIRE_NAME = "@kbn/interpreter" +TYPES_PKG_REQUIRE_NAME = "@types/kbn__interpreter" SOURCE_FILES = glob( [ @@ -22,7 +23,6 @@ filegroup( ) NPM_MODULE_EXTRA_FILES = [ - "common/package.json", "package.json", ] @@ -31,6 +31,7 @@ RUNTIME_DEPS = [ ] TYPES_DEPS = [ + "@npm//tslib", "@npm//@types/jest", "@npm//@types/lodash", "@npm//@types/node", @@ -84,7 +85,7 @@ ts_project( js_library( name = PKG_BASE_NAME, srcs = NPM_MODULE_EXTRA_FILES + [":grammar"], - deps = RUNTIME_DEPS + [":target_node", ":tsc_types"], + deps = RUNTIME_DEPS + [":target_node"], package_name = PKG_REQUIRE_NAME, visibility = ["//visibility:public"], ) @@ -103,3 +104,20 @@ filegroup( ], visibility = ["//visibility:public"], ) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = TYPES_PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [ + ":npm_module_types", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-interpreter/common/package.json b/packages/kbn-interpreter/common/package.json deleted file mode 100644 index 6d03f2e1c6236..0000000000000 --- a/packages/kbn-interpreter/common/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "private": true, - "main": "../target_node/common/index.js", - "types": "../target_types/common/index.d.ts" -} \ No newline at end of file diff --git a/packages/kbn-interpreter/package.json b/packages/kbn-interpreter/package.json index efdb30e105186..b27bc0f9d5059 100644 --- a/packages/kbn-interpreter/package.json +++ b/packages/kbn-interpreter/package.json @@ -1,6 +1,7 @@ { "name": "@kbn/interpreter", - "private": "true", + "main": "./target_node/index.js", "version": "1.0.0", - "license": "SSPL-1.0 OR Elastic License 2.0" + "license": "SSPL-1.0 OR Elastic License 2.0", + "private": true } \ No newline at end of file diff --git a/packages/kbn-interpreter/src/common/lib/ast.from_expression.test.js b/packages/kbn-interpreter/src/common/lib/ast.from_expression.test.js index 4011292178cfa..11a25f6250cd6 100644 --- a/packages/kbn-interpreter/src/common/lib/ast.from_expression.test.js +++ b/packages/kbn-interpreter/src/common/lib/ast.from_expression.test.js @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { getType } from './get_type'; describe('ast fromExpression', () => { diff --git a/packages/kbn-interpreter/src/common/lib/ast.to_expression.test.js b/packages/kbn-interpreter/src/common/lib/ast.to_expression.test.js index b500ca06836a4..14b75ab557f01 100644 --- a/packages/kbn-interpreter/src/common/lib/ast.to_expression.test.js +++ b/packages/kbn-interpreter/src/common/lib/ast.to_expression.test.js @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { toExpression } from '@kbn/interpreter/common'; +import { toExpression } from '@kbn/interpreter'; describe('ast toExpression', () => { describe('single expression', () => { diff --git a/packages/kbn-interpreter/src/index.ts b/packages/kbn-interpreter/src/index.ts new file mode 100644 index 0000000000000..16d45459af845 --- /dev/null +++ b/packages/kbn-interpreter/src/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from './common'; diff --git a/packages/kbn-telemetry-tools/src/tools/serializer.test.ts b/packages/kbn-telemetry-tools/src/tools/serializer.test.ts index 0ab4e2500a38b..3398cd0ae6947 100644 --- a/packages/kbn-telemetry-tools/src/tools/serializer.test.ts +++ b/packages/kbn-telemetry-tools/src/tools/serializer.test.ts @@ -156,4 +156,14 @@ describe('getDescriptor', () => { prop2: { kind: ts.SyntaxKind.StringKeyword, type: 'StringKeyword' }, }); }); + + it('serializes OmitIndexedAccessType', () => { + const usageInterface = usageInterfaces.get('OmitIndexedAccessType')!; + const descriptor = getDescriptor(usageInterface, tsProgram); + expect(descriptor).toEqual({ + prop3: { kind: ts.SyntaxKind.StringKeyword, type: 'StringKeyword' }, + prop4: { kind: ts.SyntaxKind.StringLiteral, type: 'StringLiteral' }, + prop5: { kind: ts.SyntaxKind.FirstLiteralToken, type: 'FirstLiteralToken' }, + }); + }); }); diff --git a/packages/kbn-telemetry-tools/src/tools/serializer.ts b/packages/kbn-telemetry-tools/src/tools/serializer.ts index 7dbd5288737ed..31fad9a5dadb2 100644 --- a/packages/kbn-telemetry-tools/src/tools/serializer.ts +++ b/packages/kbn-telemetry-tools/src/tools/serializer.ts @@ -7,7 +7,7 @@ */ import * as ts from 'typescript'; -import { uniqBy, pick } from 'lodash'; +import { uniqBy, pick, omit } from 'lodash'; import { getResolvedModuleSourceFile, getIdentifierDeclarationFromSource, @@ -236,6 +236,12 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor | const pickPropNames = getConstraints(node.typeArguments![1], program); return pick(parentDescriptor, pickPropNames); } + // Support `Omit` + if (symbolName === 'Omit') { + const parentDescriptor = getDescriptor(node.typeArguments![0], program); + const omitPropNames = getConstraints(node.typeArguments![1], program); + return omit(parentDescriptor, omitPropNames); + } const declaration = (symbol?.getDeclarations() || [])[0]; if (declaration) { diff --git a/src/fixtures/telemetry_collectors/constants.ts b/src/fixtures/telemetry_collectors/constants.ts index 92829f82c108b..37f94730afb40 100644 --- a/src/fixtures/telemetry_collectors/constants.ts +++ b/src/fixtures/telemetry_collectors/constants.ts @@ -65,3 +65,4 @@ export type RecordWithKnownProps = Record; export type RecordWithKnownAllProps = Record; export type IndexedAccessType = Pick; +export type OmitIndexedAccessType = Omit; diff --git a/src/plugins/expressions/common/ast/format.ts b/src/plugins/expressions/common/ast/format.ts index a23c5aa13b4a5..f08a32dd8035d 100644 --- a/src/plugins/expressions/common/ast/format.ts +++ b/src/plugins/expressions/common/ast/format.ts @@ -9,7 +9,7 @@ import { ExpressionAstExpression, ExpressionAstArgument } from './types'; // eslint-disable-next-line @typescript-eslint/no-var-requires -const { toExpression } = require('@kbn/interpreter/common'); +const { toExpression } = require('@kbn/interpreter'); export function format( ast: T, diff --git a/src/plugins/expressions/common/ast/parse.ts b/src/plugins/expressions/common/ast/parse.ts index 977ea39256fd7..9bd230eb424b4 100644 --- a/src/plugins/expressions/common/ast/parse.ts +++ b/src/plugins/expressions/common/ast/parse.ts @@ -9,7 +9,7 @@ import { ExpressionAstExpression, ExpressionAstArgument } from './types'; // eslint-disable-next-line @typescript-eslint/no-var-requires -const { parse: parseRaw } = require('@kbn/interpreter/common'); +const { parse: parseRaw } = require('@kbn/interpreter'); export function parse( expression: E, diff --git a/src/plugins/presentation_util/public/components/expression_input/autocomplete.ts b/src/plugins/presentation_util/public/components/expression_input/autocomplete.ts index 5f0c9cab6215c..b2d486f435a47 100644 --- a/src/plugins/presentation_util/public/components/expression_input/autocomplete.ts +++ b/src/plugins/presentation_util/public/components/expression_input/autocomplete.ts @@ -8,7 +8,7 @@ import { uniq } from 'lodash'; // @ts-expect-error untyped library -import { parse } from '@kbn/interpreter/common'; +import { parse } from '@kbn/interpreter'; import { ExpressionAstExpression, ExpressionAstFunction, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.ts b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.ts index c4d6a08227c08..373a9504712d6 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getType } from '@kbn/interpreter/common'; +import { getType } from '@kbn/interpreter'; import { ExpressionFunctionDefinition, Datatable, diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/embeddable.test.ts b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/embeddable.test.ts index 4b78acec8750a..3e0d4a1c890af 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/embeddable.test.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/embeddable.test.ts @@ -8,7 +8,7 @@ import { toExpression } from './embeddable'; import { EmbeddableInput } from '../../../../types'; import { decode } from '../../../../common/lib/embeddable_dataurl'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; describe('toExpression', () => { describe('by-reference embeddable input', () => { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.test.ts b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.test.ts index 224cdfba389d7..9382ec20ec320 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.test.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.test.ts @@ -7,7 +7,7 @@ import { toExpression } from './lens'; import { SavedLensInput } from '../../../functions/external/saved_lens'; -import { fromExpression, Ast } from '@kbn/interpreter/common'; +import { fromExpression, Ast } from '@kbn/interpreter'; import { chartPluginMock } from 'src/plugins/charts/public/mocks'; const baseEmbeddableInput = { diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.ts b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.ts index 5a13b73b3fe74..1d3a5eb9164b7 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/lens.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { toExpression as toExpressionString } from '@kbn/interpreter/common'; +import { toExpression as toExpressionString } from '@kbn/interpreter'; import { PaletteRegistry } from 'src/plugins/charts/public'; import { SavedLensInput } from '../../../functions/external/saved_lens'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/map.test.ts b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/map.test.ts index af7b40a9b283d..e2dbf5298d71c 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/map.test.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/map.test.ts @@ -6,7 +6,7 @@ */ import { toExpression } from './map'; -import { fromExpression, Ast } from '@kbn/interpreter/common'; +import { fromExpression, Ast } from '@kbn/interpreter'; const baseSavedMapInput = { id: 'elementId', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/visualization.test.ts b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/visualization.test.ts index 4c61a130f3c95..b26d3b054c767 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/visualization.test.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/input_type_to_expression/visualization.test.ts @@ -6,7 +6,7 @@ */ import { toExpression } from './visualization'; -import { fromExpression, Ast } from '@kbn/interpreter/common'; +import { fromExpression, Ast } from '@kbn/interpreter'; const baseInput = { id: 'elementId', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/dropdown_filter/index.tsx b/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/dropdown_filter/index.tsx index ef470c6e6e236..372bcbb5642cb 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/dropdown_filter/index.tsx +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/dropdown_filter/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression, toExpression, Ast } from '@kbn/interpreter/common'; +import { fromExpression, toExpression, Ast } from '@kbn/interpreter'; import { get } from 'lodash'; import React from 'react'; import ReactDOM from 'react-dom'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/components/time_filter.tsx b/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/components/time_filter.tsx index a8343eed272b5..ae27d667ee153 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/components/time_filter.tsx +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/components/time_filter.tsx @@ -9,7 +9,7 @@ import { EuiSuperDatePicker, OnTimeChangeProps, EuiSuperDatePickerCommonRange } import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { UnitStrings } from '../../../../../i18n/units'; const { quickRanges: strings } = UnitStrings; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/index.tsx b/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/index.tsx index 884f960e85558..e81ca2cc1f057 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/index.tsx +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/filters/time_filter/index.tsx @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; -import { toExpression } from '@kbn/interpreter/common'; +import { toExpression } from '@kbn/interpreter'; import { UI_SETTINGS } from '../../../../../../../src/plugins/data/public'; import { KibanaThemeProvider } from '../../../../../../../src/plugins/kibana_react/public'; import { syncFilterExpression } from '../../../../public/lib/sync_filter_expression'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js index 5008aa42e802a..f300957c39525 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/datacolumn/index.js @@ -9,7 +9,7 @@ import React, { useState, useCallback, useEffect } from 'react'; import PropTypes from 'prop-types'; import { EuiSelect, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { sortBy } from 'lodash'; -import { getType } from '@kbn/interpreter/common'; +import { getType } from '@kbn/interpreter'; import { templateFromReactComponent } from '../../../../public/lib/template_from_react_component'; import { ArgumentStrings } from '../../../../i18n'; import { SimpleMathFunction } from './simple_math_function'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette/utils.ts b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette/utils.ts index 5734bf7ce4f66..e701f0fcbf9f7 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette/utils.ts +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette/utils.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { getType } from '@kbn/interpreter/common'; +import { getType } from '@kbn/interpreter'; import { ExpressionAstArgument, ExpressionAstFunction } from 'src/plugins/expressions'; import { identifyPalette, ColorPalette, identifyPartialPalette } from '../../../../common/lib'; import { ArgumentStrings } from '../../../../i18n'; diff --git a/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js b/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js index e47ccafe8b6e7..7b0ec0808318d 100644 --- a/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js +++ b/x-pack/plugins/canvas/public/components/arg_form/advanced_failure.js @@ -9,7 +9,7 @@ import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { EuiTextArea, EuiButton, EuiButtonEmpty, EuiFormRow, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { fromExpression, toExpression } from '@kbn/interpreter/common'; +import { fromExpression, toExpression } from '@kbn/interpreter'; const strings = { getApplyButtonLabel: () => diff --git a/x-pack/plugins/canvas/public/components/asset_manager/asset.tsx b/x-pack/plugins/canvas/public/components/asset_manager/asset.tsx index 9ddbe25c846ae..9150b78f6000a 100644 --- a/x-pack/plugins/canvas/public/components/asset_manager/asset.tsx +++ b/x-pack/plugins/canvas/public/components/asset_manager/asset.tsx @@ -9,7 +9,7 @@ import { Dispatch } from 'redux'; import { connect } from 'react-redux'; import { set } from '@elastic/safer-lodash-set'; -import { fromExpression, toExpression } from '@kbn/interpreter/common'; +import { fromExpression, toExpression } from '@kbn/interpreter'; // @ts-expect-error untyped local import { elementsRegistry } from '../../lib/elements_registry'; diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.tsx b/x-pack/plugins/canvas/public/components/element_content/element_content.tsx index d508c21cb17d6..e5202f9c97aa3 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.tsx +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.tsx @@ -11,7 +11,7 @@ import { omitBy, isNil } from 'lodash'; import Style from 'style-it'; import { ExpressionRenderer } from 'src/plugins/expressions'; -import { getType } from '@kbn/interpreter/common'; +import { getType } from '@kbn/interpreter'; import { Loading } from '../loading'; import { RenderWithFn } from '../render_with_fn'; // @ts-expect-error Untyped local diff --git a/x-pack/plugins/canvas/public/components/expression/index.tsx b/x-pack/plugins/canvas/public/components/expression/index.tsx index 14d46ecfff388..37bbbd1f5a4c1 100644 --- a/x-pack/plugins/canvas/public/components/expression/index.tsx +++ b/x-pack/plugins/canvas/public/components/expression/index.tsx @@ -7,7 +7,7 @@ import React, { FC, useState, useCallback, useMemo, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { useExpressionsService } from '../../services'; import { getSelectedPage, getSelectedElement } from '../../state/selectors/workpad'; // @ts-expect-error diff --git a/x-pack/plugins/canvas/public/components/function_form/index.tsx b/x-pack/plugins/canvas/public/components/function_form/index.tsx index 47c6925f6fbbb..2494396d3712b 100644 --- a/x-pack/plugins/canvas/public/components/function_form/index.tsx +++ b/x-pack/plugins/canvas/public/components/function_form/index.tsx @@ -7,7 +7,7 @@ import React, { useCallback } from 'react'; import { shallowEqual, useDispatch, useSelector } from 'react-redux'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import deepEqual from 'react-fast-compare'; import { ExpressionAstExpression, diff --git a/x-pack/plugins/canvas/public/components/function_form_list/index.js b/x-pack/plugins/canvas/public/components/function_form_list/index.js index 2fb51245da99e..94de0a8838af7 100644 --- a/x-pack/plugins/canvas/public/components/function_form_list/index.js +++ b/x-pack/plugins/canvas/public/components/function_form_list/index.js @@ -7,7 +7,7 @@ import { compose, withProps } from 'recompose'; import { get } from 'lodash'; -import { toExpression } from '@kbn/interpreter/common'; +import { toExpression } from '@kbn/interpreter'; import { interpretAst } from '../../lib/run_interpreter'; import { modelRegistry, viewRegistry, transformRegistry } from '../../expression_types'; import { FunctionFormList as Component } from './function_form_list'; diff --git a/x-pack/plugins/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts b/x-pack/plugins/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts index 2f8e2503ea57e..18a7ab9b3208c 100644 --- a/x-pack/plugins/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts +++ b/x-pack/plugins/canvas/public/components/hooks/workpad/use_incoming_embeddable.ts @@ -7,7 +7,7 @@ import { useEffect } from 'react'; import { useDispatch } from 'react-redux'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { CANVAS_APP } from '../../../../common/lib'; import { decode, encode } from '../../../../common/lib/embeddable_dataurl'; import { CanvasElement, CanvasPage } from '../../../../types'; @@ -60,7 +60,7 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => { const updatedInput = { ...originalInput, ...incomingInput }; const expression = `embeddable config="${encode(updatedInput)}" - type="${type}" + type="${type}" | render`; dispatch( @@ -77,7 +77,7 @@ export const useIncomingEmbeddable = (selectedPage: CanvasPage) => { dispatch(selectToplevelNodes([embeddableId])); } else { const expression = `embeddable config="${encode(incomingInput)}" - type="${type}" + type="${type}" | render`; dispatch(addElement(selectedPage.id, { expression })); } diff --git a/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts b/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts index 10643e729d837..85b195214d44b 100644 --- a/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts +++ b/x-pack/plugins/canvas/public/components/workpad_filters/hooks/use_canvas_filters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { shallowEqual, useSelector } from 'react-redux'; import { State } from '../../../../types'; import { getFiltersByGroups } from '../../../lib/filter'; diff --git a/x-pack/plugins/canvas/public/expression_types/arg.ts b/x-pack/plugins/canvas/public/expression_types/arg.ts index 0fc1c996f327c..9c46f4d1e2b99 100644 --- a/x-pack/plugins/canvas/public/expression_types/arg.ts +++ b/x-pack/plugins/canvas/public/expression_types/arg.ts @@ -7,7 +7,7 @@ import { merge } from 'lodash'; import { createElement } from 'react'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; // @ts-expect-error unconverted components import { ArgForm } from '../components/arg_form'; import { argTypeRegistry } from './arg_type_registry'; diff --git a/x-pack/plugins/canvas/public/expression_types/arg_type_registry.ts b/x-pack/plugins/canvas/public/expression_types/arg_type_registry.ts index 579245d0d312b..d2f8f796438df 100644 --- a/x-pack/plugins/canvas/public/expression_types/arg_type_registry.ts +++ b/x-pack/plugins/canvas/public/expression_types/arg_type_registry.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { ArgType, ArgTypeProps } from './arg_type'; class ArgTypeRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/expression_types/datasource.tsx b/x-pack/plugins/canvas/public/expression_types/datasource.tsx index e3cde6c683be9..5f85b5ec20abd 100644 --- a/x-pack/plugins/canvas/public/expression_types/datasource.tsx +++ b/x-pack/plugins/canvas/public/expression_types/datasource.tsx @@ -8,7 +8,7 @@ import React, { useEffect, useRef, useCallback, ReactPortal, useState, memo } from 'react'; import useEffectOnce from 'react-use/lib/useEffectOnce'; import deepEqual from 'react-fast-compare'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { createPortal } from 'react-dom'; import { BaseForm, BaseFormProps } from './base_form'; import { ExpressionFormHandlers } from '../../common/lib'; diff --git a/x-pack/plugins/canvas/public/expression_types/datasource_registry.ts b/x-pack/plugins/canvas/public/expression_types/datasource_registry.ts index b6427fac9d4a0..c9417163d266b 100644 --- a/x-pack/plugins/canvas/public/expression_types/datasource_registry.ts +++ b/x-pack/plugins/canvas/public/expression_types/datasource_registry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Datasource } from './datasource'; import type { Datasource as DatasourceType, DatasourceProps } from './datasource'; diff --git a/x-pack/plugins/canvas/public/expression_types/function_form.tsx b/x-pack/plugins/canvas/public/expression_types/function_form.tsx index 9028a0999149c..b2fbfa387b49f 100644 --- a/x-pack/plugins/canvas/public/expression_types/function_form.tsx +++ b/x-pack/plugins/canvas/public/expression_types/function_form.tsx @@ -8,7 +8,7 @@ import React, { ReactElement } from 'react'; import { EuiCallOut } from '@elastic/eui'; import { isPlainObject, uniq, last, compact } from 'lodash'; -import { Ast, fromExpression } from '@kbn/interpreter/common'; +import { Ast, fromExpression } from '@kbn/interpreter'; import { ArgAddPopover } from '../components/arg_add_popover'; // @ts-expect-error unconverted components import { SidebarSection } from '../components/sidebar/sidebar_section'; diff --git a/x-pack/plugins/canvas/public/expression_types/model_registry.ts b/x-pack/plugins/canvas/public/expression_types/model_registry.ts index f5c290f2fe2e9..f7f5db54da604 100644 --- a/x-pack/plugins/canvas/public/expression_types/model_registry.ts +++ b/x-pack/plugins/canvas/public/expression_types/model_registry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Model } from './model'; import type { ModelProps, Model as ModelType } from './model'; diff --git a/x-pack/plugins/canvas/public/expression_types/transform_registry.ts b/x-pack/plugins/canvas/public/expression_types/transform_registry.ts index a69f5fcf554fe..57ea07fcaea2e 100644 --- a/x-pack/plugins/canvas/public/expression_types/transform_registry.ts +++ b/x-pack/plugins/canvas/public/expression_types/transform_registry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Transform } from './transform'; import type { Transform as TransformType, TransformProps } from './transform'; diff --git a/x-pack/plugins/canvas/public/expression_types/view_registry.ts b/x-pack/plugins/canvas/public/expression_types/view_registry.ts index 108a65c73ec60..9fec5f20eb288 100644 --- a/x-pack/plugins/canvas/public/expression_types/view_registry.ts +++ b/x-pack/plugins/canvas/public/expression_types/view_registry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { View } from './view'; import type { View as ViewType, ViewProps } from './view'; diff --git a/x-pack/plugins/canvas/public/functions/filters.ts b/x-pack/plugins/canvas/public/functions/filters.ts index ca2cede4e8555..2634d76297b58 100644 --- a/x-pack/plugins/canvas/public/functions/filters.ts +++ b/x-pack/plugins/canvas/public/functions/filters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { get } from 'lodash'; import { ExpressionFunctionDefinition } from 'src/plugins/expressions/public'; import { interpretAst } from '../lib/run_interpreter'; diff --git a/x-pack/plugins/canvas/public/functions/to.ts b/x-pack/plugins/canvas/public/functions/to.ts index 907d1f3d3a635..2866ed4d1cded 100644 --- a/x-pack/plugins/canvas/public/functions/to.ts +++ b/x-pack/plugins/canvas/public/functions/to.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { castProvider } from '@kbn/interpreter/common'; +import { castProvider } from '@kbn/interpreter'; import { ExpressionFunctionDefinition } from 'src/plugins/expressions/public'; import { getFunctionHelp, getFunctionErrors } from '../../i18n'; import { InitializeArguments } from '.'; diff --git a/x-pack/plugins/canvas/public/lib/arg_helpers.js b/x-pack/plugins/canvas/public/lib/arg_helpers.js index 82d905deb6707..57cbaef5a2791 100644 --- a/x-pack/plugins/canvas/public/lib/arg_helpers.js +++ b/x-pack/plugins/canvas/public/lib/arg_helpers.js @@ -6,7 +6,7 @@ */ import { includes } from 'lodash'; -import { getType } from '@kbn/interpreter/common'; +import { getType } from '@kbn/interpreter'; /* diff --git a/x-pack/plugins/canvas/public/lib/elements_registry.js b/x-pack/plugins/canvas/public/lib/elements_registry.js index 65de169b7f34b..be4efda3a0e84 100644 --- a/x-pack/plugins/canvas/public/lib/elements_registry.js +++ b/x-pack/plugins/canvas/public/lib/elements_registry.js @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Element } from './element'; class ElementsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/filter.ts b/x-pack/plugins/canvas/public/lib/filter.ts index 56f6558eff48b..6e9db1757ccc7 100644 --- a/x-pack/plugins/canvas/public/lib/filter.ts +++ b/x-pack/plugins/canvas/public/lib/filter.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { flowRight, get, groupBy } from 'lodash'; import { Filter as FilterType, diff --git a/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts b/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts index 5061e47a44347..e035e30e307f0 100644 --- a/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts +++ b/x-pack/plugins/canvas/public/lib/filter_adapters.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ExpressionFunctionAST } from '@kbn/interpreter/common'; +import { ExpressionFunctionAST } from '@kbn/interpreter'; import { adaptCanvasFilter } from './filter_adapters'; describe('adaptCanvasFilter', () => { diff --git a/x-pack/plugins/canvas/public/lib/filter_adapters.ts b/x-pack/plugins/canvas/public/lib/filter_adapters.ts index 478b0a5302631..67bdf13d19999 100644 --- a/x-pack/plugins/canvas/public/lib/filter_adapters.ts +++ b/x-pack/plugins/canvas/public/lib/filter_adapters.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ExpressionFunctionAST } from '@kbn/interpreter/common'; +import { ExpressionFunctionAST } from '@kbn/interpreter'; import { identity } from 'lodash'; import { ExpressionAstArgument, Filter, FilterType } from '../../types'; diff --git a/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js b/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js index a3c9b43e22052..68afc6a5276db 100644 --- a/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js +++ b/x-pack/plugins/canvas/public/lib/parse_single_function_chain.js @@ -6,7 +6,7 @@ */ import { get, mapValues, map } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; export function parseSingleFunctionChain(filterString) { const ast = fromExpression(filterString); diff --git a/x-pack/plugins/canvas/public/lib/run_interpreter.ts b/x-pack/plugins/canvas/public/lib/run_interpreter.ts index 9633d91b8b8b2..77c31b11924c0 100644 --- a/x-pack/plugins/canvas/public/lib/run_interpreter.ts +++ b/x-pack/plugins/canvas/public/lib/run_interpreter.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression, getType } from '@kbn/interpreter/common'; +import { fromExpression, getType } from '@kbn/interpreter'; import { pluck } from 'rxjs/operators'; import { ExpressionValue, ExpressionAstExpression } from 'src/plugins/expressions/public'; import { pluginServices } from '../services'; diff --git a/x-pack/plugins/canvas/public/lib/sync_filter_expression.ts b/x-pack/plugins/canvas/public/lib/sync_filter_expression.ts index ce89e8e142891..7cb349494ec64 100644 --- a/x-pack/plugins/canvas/public/lib/sync_filter_expression.ts +++ b/x-pack/plugins/canvas/public/lib/sync_filter_expression.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import immutable from 'object-path-immutable'; import { get } from 'lodash'; diff --git a/x-pack/plugins/canvas/public/lib/tags_registry.ts b/x-pack/plugins/canvas/public/lib/tags_registry.ts index ab3914ce68f03..f885cfd606037 100644 --- a/x-pack/plugins/canvas/public/lib/tags_registry.ts +++ b/x-pack/plugins/canvas/public/lib/tags_registry.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Tag, TagSpec } from './tag'; class TagRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/templates_registry.js b/x-pack/plugins/canvas/public/lib/templates_registry.js index c8b9a379bcd72..51ca0ba7fb433 100644 --- a/x-pack/plugins/canvas/public/lib/templates_registry.js +++ b/x-pack/plugins/canvas/public/lib/templates_registry.js @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Template } from './template'; class TemplateRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/transitions_registry.js b/x-pack/plugins/canvas/public/lib/transitions_registry.js index 7a786c7cd196b..f8b4d195b964b 100644 --- a/x-pack/plugins/canvas/public/lib/transitions_registry.js +++ b/x-pack/plugins/canvas/public/lib/transitions_registry.js @@ -5,7 +5,7 @@ * 2.0. */ -import { Registry } from '@kbn/interpreter/common'; +import { Registry } from '@kbn/interpreter'; import { Transition } from '../transitions/transition'; class TransitionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/registries.ts b/x-pack/plugins/canvas/public/registries.ts index 56d89affce5ea..f5d670919a3f8 100644 --- a/x-pack/plugins/canvas/public/registries.ts +++ b/x-pack/plugins/canvas/public/registries.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { addRegistries, register } from '@kbn/interpreter/common'; +import { addRegistries, register } from '@kbn/interpreter'; // @ts-expect-error untyped local import { elementsRegistry } from './lib/elements_registry'; // @ts-expect-error untyped local diff --git a/x-pack/plugins/canvas/public/state/actions/elements.js b/x-pack/plugins/canvas/public/state/actions/elements.js index c8d322163b54f..4b14e17a2d105 100644 --- a/x-pack/plugins/canvas/public/state/actions/elements.js +++ b/x-pack/plugins/canvas/public/state/actions/elements.js @@ -8,7 +8,7 @@ import { createAction } from 'redux-actions'; import immutable from 'object-path-immutable'; import { get, pick, cloneDeep, without } from 'lodash'; -import { toExpression, safeElementFromExpression } from '@kbn/interpreter/common'; +import { toExpression, safeElementFromExpression } from '@kbn/interpreter'; import { createThunk } from '../../lib/create_thunk'; import { getPages, diff --git a/x-pack/plugins/canvas/public/state/reducers/embeddable.ts b/x-pack/plugins/canvas/public/state/reducers/embeddable.ts index 092d4300d86b7..5b963e2c80c7e 100644 --- a/x-pack/plugins/canvas/public/state/reducers/embeddable.ts +++ b/x-pack/plugins/canvas/public/state/reducers/embeddable.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression, toExpression } from '@kbn/interpreter/common'; +import { fromExpression, toExpression } from '@kbn/interpreter'; import { handleActions } from 'redux-actions'; import { State } from '../../../types'; diff --git a/x-pack/plugins/canvas/public/state/selectors/workpad.ts b/x-pack/plugins/canvas/public/state/selectors/workpad.ts index c419862e76379..a2c001d58cedd 100644 --- a/x-pack/plugins/canvas/public/state/selectors/workpad.ts +++ b/x-pack/plugins/canvas/public/state/selectors/workpad.ts @@ -6,7 +6,7 @@ */ import { get, omit } from 'lodash'; -import { safeElementFromExpression, fromExpression } from '@kbn/interpreter/common'; +import { safeElementFromExpression, fromExpression } from '@kbn/interpreter'; import { CanvasRenderedWorkpad } from '../../../shareable_runtime/types'; import { append } from '../../lib/modify_path'; import { getAssets } from './assets'; diff --git a/x-pack/plugins/canvas/server/saved_objects/workpad_references.ts b/x-pack/plugins/canvas/server/saved_objects/workpad_references.ts index e9eefa1bdb3f4..806f08b17651c 100644 --- a/x-pack/plugins/canvas/server/saved_objects/workpad_references.ts +++ b/x-pack/plugins/canvas/server/saved_objects/workpad_references.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { fromExpression, toExpression } from '@kbn/interpreter/common'; +import { fromExpression, toExpression } from '@kbn/interpreter'; import { PersistableStateService } from '../../../../../src/plugins/kibana_utils/common'; import { SavedObjectReference } from '../../../../../src/core/server'; import { WorkpadAttributes } from '../routes/workpad/workpad_attributes'; diff --git a/x-pack/plugins/canvas/server/workpad_route_context.test.ts b/x-pack/plugins/canvas/server/workpad_route_context.test.ts index 6496edf1a0e12..9626b2ffd9575 100644 --- a/x-pack/plugins/canvas/server/workpad_route_context.test.ts +++ b/x-pack/plugins/canvas/server/workpad_route_context.test.ts @@ -6,7 +6,7 @@ */ import sinon from 'sinon'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { createWorkpadRouteContext } from './workpad_route_context'; import { RequestHandlerContext, SavedObjectReference } from 'src/core/server'; import { savedObjectsClientMock } from 'src/core/server/mocks'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx b/x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx index 3e8a31fa53915..d03263305bb90 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/visualization.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { buildExpression } from '../../../../../src/plugins/expressions/public'; import { createMockDatasource, createMockFramePublicAPI, DatasourceMock } from '../mocks'; import { DatatableVisualizationState, getDatatableVisualization } from './visualization'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx b/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx index ca8cbbf067b06..108d01acd33a9 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/visualization.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { render } from 'react-dom'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { I18nProvider } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import type { PaletteRegistry } from 'src/plugins/charts/public'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/__mocks__/expression_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/__mocks__/expression_helpers.ts index 8606d7737195c..4e7869646c310 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/__mocks__/expression_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/__mocks__/expression_helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; export function buildExpression(): Ast { return { diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx index f7fcc012ec168..174bb48bc9e41 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/editor_frame.test.tsx @@ -32,7 +32,7 @@ import { EditorFrame, EditorFrameProps } from './editor_frame'; import { DatasourcePublicAPI, DatasourceSuggestion, Visualization } from '../../types'; import { act } from 'react-dom/test-utils'; import { coreMock } from 'src/core/public/mocks'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { createMockVisualization, createMockDatasource, diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts index 2ba93608eddc7..a8d58e51691f9 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Ast, fromExpression, ExpressionFunctionAST } from '@kbn/interpreter/common'; +import { Ast, fromExpression, ExpressionFunctionAST } from '@kbn/interpreter'; import { DatasourceStates } from '../../state_management'; import { Visualization, DatasourcePublicAPI, DatasourceMap } from '../../types'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts index a09cf269f753c..9ead8c225240b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts @@ -6,7 +6,7 @@ */ import { SavedObjectReference } from 'kibana/public'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import memoizeOne from 'memoize-one'; import { Datasource, diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts index f3245759c9ef5..ac55d966927bd 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_helpers.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { IconType } from '@elastic/eui/src/components/icon/icon'; import { Datatable } from 'src/plugins/expressions'; import { PaletteOutput } from 'src/plugins/charts/public'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx index 7a74e0c9cc5aa..f6fccbb831eae 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx @@ -21,7 +21,7 @@ import { EuiAccordion, } from '@elastic/eui'; import { IconType } from '@elastic/eui/src/components/icon/icon'; -import { Ast, toExpression } from '@kbn/interpreter/common'; +import { Ast, toExpression } from '@kbn/interpreter'; import { i18n } from '@kbn/i18n'; import classNames from 'classnames'; import { ExecutionContextSearch } from 'src/plugins/data/public'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index 2ed65d3b0f146..fef71e92c5f2c 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -26,7 +26,7 @@ jest.mock('../../../debounced_component', () => { import { WorkspacePanel } from './workspace_panel'; import { ReactWrapper } from 'enzyme'; import { DragDrop, ChildDragDropProvider } from '../../../drag_drop'; -import { fromExpression } from '@kbn/interpreter/common'; +import { fromExpression } from '@kbn/interpreter'; import { coreMock } from 'src/core/public/mocks'; import { esFilters, IndexPattern } from '../../../../../../../src/plugins/data/public'; import type { FieldSpec } from '../../../../../../../src/plugins/data/common'; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index b8885e53d5e42..ebf3bc8f82a24 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -8,7 +8,7 @@ import React, { useState, useEffect, useMemo, useContext, useCallback } from 'react'; import classNames from 'classnames'; import { FormattedMessage } from '@kbn/i18n-react'; -import { toExpression } from '@kbn/interpreter/common'; +import { toExpression } from '@kbn/interpreter'; import { i18n } from '@kbn/i18n'; import { EuiEmptyPrompt, diff --git a/x-pack/plugins/lens/public/embeddable/embeddable.tsx b/x-pack/plugins/lens/public/embeddable/embeddable.tsx index aef3cda8679ea..d31b3ab0cfdf5 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable.tsx +++ b/x-pack/plugins/lens/public/embeddable/embeddable.tsx @@ -21,7 +21,7 @@ import type { PaletteOutput } from 'src/plugins/charts/public'; import type { Start as InspectorStart } from 'src/plugins/inspector/public'; import { Subscription } from 'rxjs'; -import { toExpression, Ast } from '@kbn/interpreter/common'; +import { toExpression, Ast } from '@kbn/interpreter'; import { RenderMode } from 'src/plugins/expressions'; import { map, distinctUntilChanged, skip } from 'rxjs/operators'; import fastIsEqual from 'fast-deep-equal'; diff --git a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts index 63b07affcb9ed..c1bc5aacc3943 100644 --- a/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts +++ b/x-pack/plugins/lens/public/embeddable/embeddable_factory.ts @@ -8,7 +8,7 @@ import type { Capabilities, HttpSetup, ThemeServiceStart } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { RecursiveReadonly } from '@kbn/utility-types'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; import { IndexPatternsContract, TimefilterContract } from '../../../../../src/plugins/data/public'; import { ReactExpressionRendererType } from '../../../../../src/plugins/expressions/public'; diff --git a/x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx b/x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx index 5a80290aa0101..0ba31b7f15231 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { render } from 'react-dom'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n-react'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { Position } from '@elastic/charts'; import { ThemeServiceStart } from 'kibana/public'; import { KibanaThemeProvider } from '../../../../../src/plugins/kibana_react/public'; diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts index 50f72e5d2cd7b..a0a6d6b26fe17 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/indexpattern.test.ts @@ -12,7 +12,7 @@ import { DatasourcePublicAPI, Operation, Datasource, FramePublicAPI } from '../t import { coreMock } from 'src/core/public/mocks'; import { IndexPatternPersistedState, IndexPatternPrivateState } from './types'; import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { chartPluginMock } from '../../../../../src/plugins/charts/public/mocks'; import { getFieldByNameFactory } from './pure_helpers'; import { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts index 0ec7ad046ac2a..cec6294f7f314 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/calculations/utils.ts @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import type { ExpressionFunctionAST } from '@kbn/interpreter/common'; +import type { ExpressionFunctionAST } from '@kbn/interpreter'; import memoizeOne from 'memoize-one'; import { LayerType, layerTypes } from '../../../../../common'; import type { TimeScaleUnit } from '../../../../../common/expressions'; diff --git a/x-pack/plugins/lens/public/metric_visualization/visualization.tsx b/x-pack/plugins/lens/public/metric_visualization/visualization.tsx index 87e51378377aa..920c594952ed0 100644 --- a/x-pack/plugins/lens/public/metric_visualization/visualization.tsx +++ b/x-pack/plugins/lens/public/metric_visualization/visualization.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { I18nProvider } from '@kbn/i18n-react'; import { render } from 'react-dom'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { ThemeServiceStart } from 'kibana/public'; import { KibanaThemeProvider } from '../../../../../src/plugins/kibana_react/public'; import { ColorMode } from '../../../../../src/plugins/charts/common'; diff --git a/x-pack/plugins/lens/public/pie_visualization/to_expression.ts b/x-pack/plugins/lens/public/pie_visualization/to_expression.ts index f7e76567743e4..fd92c14e33808 100644 --- a/x-pack/plugins/lens/public/pie_visualization/to_expression.ts +++ b/x-pack/plugins/lens/public/pie_visualization/to_expression.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { Ast } from '@kbn/interpreter/common'; +import type { Ast } from '@kbn/interpreter'; import type { PaletteRegistry } from 'src/plugins/charts/public'; import type { Operation, DatasourcePublicAPI } from '../types'; import { DEFAULT_PERCENT_DECIMALS, EMPTY_SIZE_RATIOS } from './constants'; diff --git a/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx b/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx index 2c409ddacaf0f..94a2ec2eaac1c 100644 --- a/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx +++ b/x-pack/plugins/lens/public/visualizations/gauge/visualization.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { render } from 'react-dom'; import { i18n } from '@kbn/i18n'; import { FormattedMessage, I18nProvider } from '@kbn/i18n-react'; -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { DatatableRow } from 'src/plugins/expressions'; import type { GaugeArguments } from '../../../../../../src/plugins/chart_expressions/expression_gauge/common'; import { diff --git a/x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts b/x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts index ea4db04080f65..c0dfbd9986087 100644 --- a/x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts +++ b/x-pack/plugins/lens/public/xy_visualization/to_expression.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { Position } from '@elastic/charts'; import { chartPluginMock } from '../../../../../src/plugins/charts/public/mocks'; import { getXyVisualization } from './xy_visualization'; diff --git a/x-pack/plugins/lens/public/xy_visualization/to_expression.ts b/x-pack/plugins/lens/public/xy_visualization/to_expression.ts index 22d680caeb12c..b593b6e294844 100644 --- a/x-pack/plugins/lens/public/xy_visualization/to_expression.ts +++ b/x-pack/plugins/lens/public/xy_visualization/to_expression.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Ast } from '@kbn/interpreter/common'; +import { Ast } from '@kbn/interpreter'; import { ScaleType } from '@elastic/charts'; import { PaletteRegistry } from 'src/plugins/charts/public'; import { State } from './types'; diff --git a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts index f4f16f21452fb..152ed173f8903 100644 --- a/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts +++ b/x-pack/plugins/lens/server/migrations/saved_object_migrations.ts @@ -6,7 +6,7 @@ */ import { cloneDeep } from 'lodash'; -import { fromExpression, toExpression, Ast, ExpressionFunctionAST } from '@kbn/interpreter/common'; +import { fromExpression, toExpression, Ast, ExpressionFunctionAST } from '@kbn/interpreter'; import { SavedObjectMigrationMap, SavedObjectMigrationFn, diff --git a/x-pack/plugins/observability/public/hooks/use_alert_permission.test.tsx b/x-pack/plugins/observability/public/hooks/use_alert_permission.test.tsx new file mode 100644 index 0000000000000..3df79bec1a8f2 --- /dev/null +++ b/x-pack/plugins/observability/public/hooks/use_alert_permission.test.tsx @@ -0,0 +1,108 @@ +/* + * 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 { getAlertsPermissions, useGetUserAlertsPermissions } from './use_alert_permission'; +import { applicationServiceMock } from 'src/core/public/mocks'; +import { renderHook } from '@testing-library/react-hooks'; + +describe('getAlertsPermissions', () => { + it('returns a fallback when featureId is nullish or missing from capabilities', () => { + const { capabilities } = applicationServiceMock.createStartContract(); + + expect(getAlertsPermissions(capabilities, '')).toEqual({ + crud: false, + read: false, + loading: false, + featureId: '', + }); + + expect(getAlertsPermissions(capabilities, 'abc')).toEqual({ + crud: false, + read: false, + loading: false, + featureId: 'abc', + }); + }); + + it('returns proper permissions when featureId is a key in capabilities', () => { + const capabilities = Object.assign( + {}, + applicationServiceMock.createStartContract().capabilities, + { + apm: { 'alerting:save': false, 'alerting:show': true, loading: true }, + uptime: { loading: true, save: true, show: true }, + } + ); + + expect(getAlertsPermissions(capabilities, 'uptime')).toEqual({ + crud: true, + read: true, + loading: false, + featureId: 'uptime', + }); + + expect(getAlertsPermissions(capabilities, 'apm')).toEqual({ + crud: false, + read: true, + loading: false, + featureId: 'apm', + }); + }); +}); + +describe('useGetUserAlertPermissions', function () { + const timeout = 1_000; + + it( + 'updates permissions when featureId changes', + async function () { + const capabilities = Object.assign( + {}, + applicationServiceMock.createStartContract().capabilities, + { + apm: { 'alerting:save': false, 'alerting:show': true }, + uptime: { save: true, show: true }, + } + ); + + const { result, rerender } = renderHook( + ({ featureId }) => useGetUserAlertsPermissions(capabilities, featureId), + { + initialProps: { featureId: 'uptime' }, + } + ); + expect(result.current.read).toBe(true); + expect(result.current.crud).toBe(true); + + rerender({ featureId: 'apm' }); + expect(result.current.read).toBe(true); + expect(result.current.crud).toBe(false); + }, + timeout + ); + + it( + 'returns default permissions when permissions for featureId are missing', + async function () { + const { capabilities } = applicationServiceMock.createStartContract(); + + const { result } = renderHook( + ({ featureId }) => useGetUserAlertsPermissions(capabilities, featureId), + { + initialProps: { featureId: 'uptime' }, + } + ); + expect(result.current).toEqual({ + crud: false, + read: false, + loading: false, + featureId: null, + }); + }, + timeout + ); +}); diff --git a/x-pack/plugins/observability/public/hooks/use_alert_permission.ts b/x-pack/plugins/observability/public/hooks/use_alert_permission.ts index d754c53f23f5c..2b7eddd5c7182 100644 --- a/x-pack/plugins/observability/public/hooks/use_alert_permission.ts +++ b/x-pack/plugins/observability/public/hooks/use_alert_permission.ts @@ -7,7 +7,7 @@ import { useEffect, useState } from 'react'; import { RecursiveReadonly } from '@kbn/utility-types'; -import { Capabilities } from '../../../../../src/core/types'; +import { Capabilities } from 'src/core/types'; export interface UseGetUserAlertsPermissionsProps { crud: boolean; @@ -36,6 +36,7 @@ export const getAlertsPermissions = ( read: (featureId === 'apm' ? uiCapabilities[featureId]['alerting:show'] : uiCapabilities[featureId].show) as boolean, + loading: false, featureId, }; }; diff --git a/yarn.lock b/yarn.lock index c769e5d86d62a..3a460ff52e8d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5864,6 +5864,10 @@ version "0.0.0" uid "" +"@types/kbn__interpreter@link:bazel-bin/packages/kbn-interpreter/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__mapbox-gl@link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types": version "0.0.0" uid ""