Skip to content

Commit

Permalink
Merge branch 'main' into kertal-pr-2021-12-17-discover-unskip-functional
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Dec 21, 2021
2 parents feeb5db + 8357217 commit 9f7c0bb
Show file tree
Hide file tree
Showing 84 changed files with 243 additions and 88 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 23 additions & 5 deletions packages/kbn-interpreter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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(
[
Expand All @@ -22,7 +23,6 @@ filegroup(
)

NPM_MODULE_EXTRA_FILES = [
"common/package.json",
"package.json",
]

Expand All @@ -31,6 +31,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"@npm//tslib",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
Expand Down Expand Up @@ -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"],
)
Expand All @@ -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"],
)
5 changes: 0 additions & 5 deletions packages/kbn-interpreter/common/package.json

This file was deleted.

5 changes: 3 additions & 2 deletions packages/kbn-interpreter/package.json
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/kbn-interpreter/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
10 changes: 10 additions & 0 deletions packages/kbn-telemetry-tools/src/tools/serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
});
});
});
8 changes: 7 additions & 1 deletion packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import * as ts from 'typescript';
import { uniqBy, pick } from 'lodash';
import { uniqBy, pick, omit } from 'lodash';
import {
getResolvedModuleSourceFile,
getIdentifierDeclarationFromSource,
Expand Down Expand Up @@ -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<SOMETHING, 'prop1' | 'prop2'>`
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) {
Expand Down
1 change: 1 addition & 0 deletions src/fixtures/telemetry_collectors/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ export type RecordWithKnownProps = Record<MappedTypeProps, number>;
export type RecordWithKnownAllProps = Record<MappedTypeAllProps, number>;

export type IndexedAccessType = Pick<WithUnion, 'prop1' | 'prop2'>;
export type OmitIndexedAccessType = Omit<WithUnion, 'prop1' | 'prop2'>;
2 changes: 1 addition & 1 deletion src/plugins/expressions/common/ast/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends ExpressionAstExpression | ExpressionAstArgument>(
ast: T,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/expressions/common/ast/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<E extends string, S extends 'expression' | 'argument'>(
expression: E,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { getType } from '@kbn/interpreter/common';
import { getType } from '@kbn/interpreter';
import {
ExpressionFunctionDefinition,
Datatable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(
Expand All @@ -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 }));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/public/expression_types/arg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgTypeProps, ArgType> {
Expand Down
Loading

0 comments on commit 9f7c0bb

Please sign in to comment.