Skip to content

Commit

Permalink
chore(NA): splits types from code on @kbn/interpreter (#121576)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
mistic and kibanamachine authored Dec 21, 2021
1 parent cc3772c commit 8357217
Showing 79 changed files with 115 additions and 86 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
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(
[
@@ -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"],
)
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
@@ -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', () => {
Original file line number Diff line number Diff line change
@@ -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', () => {
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';
2 changes: 1 addition & 1 deletion src/plugins/expressions/common/ast/format.ts
Original file line number Diff line number Diff line change
@@ -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,
2 changes: 1 addition & 1 deletion src/plugins/expressions/common/ast/parse.ts
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
* 2.0.
*/

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

Original file line number Diff line number Diff line change
@@ -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',
Original file line number Diff line number Diff line change
@@ -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',
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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: () =>
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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 }));
}
Original file line number Diff line number Diff line change
@@ -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';
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
@@ -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';
Original file line number Diff line number Diff line change
@@ -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> {
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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';

Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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';

Loading

0 comments on commit 8357217

Please sign in to comment.