diff --git a/.eslintignore b/.eslintignore index aa6dbd7f64ccf..a734d3f9df2c7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -27,10 +27,6 @@ bower_components /x-pack/coverage /x-pack/build /x-pack/plugins/**/__tests__/fixtures/** -/packages/kbn-interpreter/common -/packages/kbn-interpreter/plugin -/packages/kbn-interpreter/public -/packages/kbn-interpreter/server /packages/kbn-interpreter/src/common/lib/grammar.js /x-pack/plugins/canvas/canvas_plugin /x-pack/plugins/canvas/canvas_plugin_src/lib/flot-charts diff --git a/.eslintrc.js b/.eslintrc.js index 131b3851e726b..7dcecacceae8b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -102,7 +102,7 @@ module.exports = { * Files that ARE NOT allowed to use devDependencies */ { - files: ['packages/kbn-ui-framework/**/*', 'x-pack/**/*'], + files: ['packages/kbn-ui-framework/**/*', 'x-pack/**/*', 'packages/kbn-interpreter/**/*'], rules: { 'import/no-extraneous-dependencies': [ 'error', @@ -124,6 +124,8 @@ module.exports = { 'packages/kbn-ui-framework/generator-kui/**/*', 'packages/kbn-ui-framework/Gruntfile.js', 'packages/kbn-es/src/**/*', + 'packages/kbn-interpreter/tasks/**/*', + 'packages/kbn-interpreter/src/plugin/**/*', 'x-pack/{dev-tools,tasks,scripts,test,build_chromium}/**/*', 'x-pack/**/{__tests__,__test__,__jest__,__fixtures__,__mocks__}/**/*', 'x-pack/**/*.test.js', diff --git a/.gitignore b/.gitignore index ca3da4ab034e4..15fa517ae7474 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,3 @@ package-lock.json npm-debug.log* .tern-project **/public/index.css -/packages/kbn-interpreter/plugin diff --git a/package.json b/package.json index ae2763c8ca480..a982137a2d9d8 100644 --- a/package.json +++ b/package.json @@ -199,6 +199,8 @@ "rxjs": "^6.2.1", "script-loader": "0.7.2", "semver": "^5.5.0", + "socket.io": "^2.1.1", + "stream-stream": "^1.2.6", "style-loader": "0.19.0", "tar": "2.2.0", "tinygradient": "0.3.0", diff --git a/packages/kbn-interpreter/.babelrc b/packages/kbn-interpreter/.babelrc index 23999cf4e472a..57a5cc3669eb4 100644 --- a/packages/kbn-interpreter/.babelrc +++ b/packages/kbn-interpreter/.babelrc @@ -1,7 +1,7 @@ { "presets": ["@kbn/babel-preset/webpack_preset"], "plugins": [ - ["transform-runtime", { + ["babel-plugin-transform-runtime", { "polyfill": false, "regenerator": true }] diff --git a/packages/kbn-interpreter/.gitignore b/packages/kbn-interpreter/.gitignore deleted file mode 100644 index 660b153a07e29..0000000000000 --- a/packages/kbn-interpreter/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/common -/plugin -/public -/server diff --git a/packages/kbn-interpreter/.npmignore b/packages/kbn-interpreter/.npmignore new file mode 100644 index 0000000000000..b9bc539e63ce4 --- /dev/null +++ b/packages/kbn-interpreter/.npmignore @@ -0,0 +1,3 @@ +src +tasks +.babelrc diff --git a/packages/kbn-interpreter/common/package.json b/packages/kbn-interpreter/common/package.json new file mode 100644 index 0000000000000..1324e51a661cd --- /dev/null +++ b/packages/kbn-interpreter/common/package.json @@ -0,0 +1,5 @@ +{ + "private": true, + "main": "../target/common/index.js", + "jsnext:main": "../src/common/index.js" +} diff --git a/packages/kbn-interpreter/package.json b/packages/kbn-interpreter/package.json index 715e360c3598e..3c7c1e47a74d7 100644 --- a/packages/kbn-interpreter/package.json +++ b/packages/kbn-interpreter/package.json @@ -3,9 +3,10 @@ "version": "1.0.0", "license": "Apache-2.0", "scripts": { - "build": "babel src --out-dir ./ --ignore 'src/plugin' && node tasks/build.js", "canvas:peg": "pegjs common/lib/grammar.peg", - "kbn:bootstrap": "yarn build" + "build": "node scripts/build", + "kbn:bootstrap": "node scripts/build --dev", + "kbn:watch": "node scripts/build --dev --watch" }, "dependencies": { "lodash": "npm:@elastic/lodash@3.10.1-kibana1", @@ -16,15 +17,19 @@ }, "devDependencies": { "@kbn/babel-preset": "1.0.0", + "@kbn/dev-utils": "1.0.0", "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-loader": "7.1.2", "babel-plugin-transform-runtime": "^6.23.0", "babel-polyfill": "6.20.0", "css-loader": "0.28.7", + "del": "^3.0.0", + "getopts": "^2.2.3", "pegjs": "0.9.0", "sass-loader": "^7.1.0", "style-loader": "0.19.0", + "supports-color": "^5.5.0", "url-loader": "0.5.9", "webpack": "3.6.0" } diff --git a/src/core_plugins/interpreter/plugin_paths.js b/packages/kbn-interpreter/plugin_paths.js similarity index 74% rename from src/core_plugins/interpreter/plugin_paths.js rename to packages/kbn-interpreter/plugin_paths.js index ca44ce1a1f7b2..af05a6c3cfba4 100644 --- a/src/core_plugins/interpreter/plugin_paths.js +++ b/packages/kbn-interpreter/plugin_paths.js @@ -17,11 +17,9 @@ * under the License. */ -import { resolve } from 'path'; +const { resolve } = require('path'); -const dir = resolve(__dirname, '..', '..', '..'); - -export const pluginPaths = { - commonFunctions: resolve(dir, 'node_modules/@kbn/interpreter/plugin/functions/common'), - types: resolve(dir, 'node_modules/@kbn/interpreter/plugin/types'), +exports.pluginPaths = { + commonFunctions: resolve(__dirname, 'target/plugin/functions/common'), + types: resolve(__dirname, 'target/plugin/types'), }; diff --git a/packages/kbn-interpreter/public/package.json b/packages/kbn-interpreter/public/package.json new file mode 100644 index 0000000000000..3aae7e53c3eaa --- /dev/null +++ b/packages/kbn-interpreter/public/package.json @@ -0,0 +1,5 @@ +{ + "private": true, + "main": "../target/public/index.js", + "jsnext:main": "../src/public/index.js" +} diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js b/packages/kbn-interpreter/scripts/build.js similarity index 58% rename from src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js rename to packages/kbn-interpreter/scripts/build.js index 476777b4bc693..23e6e42a8e78a 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/polyfill.js +++ b/packages/kbn-interpreter/scripts/build.js @@ -17,15 +17,4 @@ * under the License. */ -// taken from kibana/src/setup_node_env/babel_register/polyfill.js -// ... -// `babel-preset-env` looks for and rewrites the following import -// statement into a list of import statements based on the polyfills -// necessary for our target environment (the current version of node) -// but since it does that during compilation, `import 'babel-polyfill'` -// must be in a file that is loaded with `require()` AFTER `babel-register` -// is configured. -// -// This is why we have this single statement in it's own file and require -// it from ./babeled.js -import 'babel-polyfill'; +require('../tasks/build/cli'); diff --git a/packages/kbn-interpreter/server/package.json b/packages/kbn-interpreter/server/package.json new file mode 100644 index 0000000000000..2f4ed7dae00d4 --- /dev/null +++ b/packages/kbn-interpreter/server/package.json @@ -0,0 +1,5 @@ +{ + "private": true, + "main": "../target/server/index.js", + "jsnext:main": "../src/server/index.js" +} diff --git a/packages/kbn-interpreter/src/common/index.js b/packages/kbn-interpreter/src/common/index.js new file mode 100644 index 0000000000000..886106d39f4e1 --- /dev/null +++ b/packages/kbn-interpreter/src/common/index.js @@ -0,0 +1,32 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { pathsRegistry } from './lib/paths_registry'; +export { functionsRegistry } from './lib/functions_registry'; +export { typesRegistry } from './lib/types_registry'; +export { createError } from './interpreter/create_error'; +export { interpretProvider } from './interpreter/interpret'; +export { serializeProvider } from './lib/serialize'; +export { fromExpression, toExpression, safeElementFromExpression } from './lib/ast'; +export { Fn } from './lib/fn'; +export { getType } from './lib/get_type'; +export { castProvider } from './interpreter/cast'; +export { parse } from './lib/grammar'; +export { getByAlias } from './lib/get_by_alias'; +export { Registry } from './lib/registry'; diff --git a/packages/kbn-interpreter/src/public/index.js b/packages/kbn-interpreter/src/public/index.js new file mode 100644 index 0000000000000..de8caad1dbc5b --- /dev/null +++ b/packages/kbn-interpreter/src/public/index.js @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { populateBrowserRegistries, getBrowserRegistries } from './browser_registries'; +export { createSocket } from './socket'; +export { initializeInterpreter, interpretAst } from './interpreter'; diff --git a/packages/kbn-interpreter/src/public/interpreter.js b/packages/kbn-interpreter/src/public/interpreter.js index 5c1e199bce363..ba38df27b6f85 100644 --- a/packages/kbn-interpreter/src/public/interpreter.js +++ b/packages/kbn-interpreter/src/public/interpreter.js @@ -29,7 +29,7 @@ let socket; let resolve; const functionList = new Promise(_resolve => (resolve = _resolve)); -export async function initialize() { +export async function initializeInterpreter() { socket = getSocket(); // Listen for interpreter runs diff --git a/packages/kbn-interpreter/src/server/index.js b/packages/kbn-interpreter/src/server/index.js new file mode 100644 index 0000000000000..e481a3ec1fd60 --- /dev/null +++ b/packages/kbn-interpreter/src/server/index.js @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { populateServerRegistries, getServerRegistries } from './server_registries'; +export { getPluginPaths } from './get_plugin_paths'; diff --git a/packages/kbn-interpreter/tasks/build/cli.js b/packages/kbn-interpreter/tasks/build/cli.js new file mode 100644 index 0000000000000..88097c2e90271 --- /dev/null +++ b/packages/kbn-interpreter/tasks/build/cli.js @@ -0,0 +1,113 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { relative } = require('path'); + +const getopts = require('getopts'); +const del = require('del'); +const supportsColor = require('supports-color'); +const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-utils'); + +const { + ROOT_DIR, + PLUGIN_SOURCE_DIR, + BUILD_DIR, + WEBPACK_CONFIG_PATH +} = require('./paths'); + +const unknownFlags = []; +const flags = getopts(process.argv, { + boolean: [ + 'watch', + 'dev', + 'help', + 'debug' + ], + unknown(name) { + unknownFlags.push(name); + } +}); + +const log = new ToolingLog({ + level: pickLevelFromFlags(flags), + writeTo: process.stdout +}); + +if (unknownFlags.length) { + log.error(`Unknown flag(s): ${unknownFlags.join(', ')}`); + flags.help = true; + process.exitCode = 1; +} + +if (flags.help) { + log.info(` + Simple build tool for @kbn/interpreter package + + --dev Build for development, include source maps + --watch Run in watch mode + --debug Turn on debug logging + `); + process.exit(); +} + +withProcRunner(log, async (proc) => { + log.info('Deleting old output'); + await del(BUILD_DIR); + + const cwd = ROOT_DIR; + const env = { ...process.env }; + if (supportsColor.stdout) { + env.FORCE_COLOR = 'true'; + } + + log.info(`Starting babel and webpack${flags.watch ? ' in watch mode' : ''}`); + await Promise.all([ + proc.run('babel ', { + cmd: 'babel', + args: [ + 'src', + '--ignore', `${relative(cwd, PLUGIN_SOURCE_DIR)},*.test.js`, + '--out-dir', relative(cwd, BUILD_DIR), + '--copy-files', + ...(flags.dev ? ['--source-maps', 'inline'] : []), + ...(flags.watch ? ['--watch'] : ['--quiet']) + ], + wait: true, + env, + cwd + }), + + proc.run('webpack', { + cmd: 'webpack', + args: [ + '--config', relative(cwd, WEBPACK_CONFIG_PATH), + '--env.sourceMaps', String(Boolean(flags.dev)), + ...(flags.watch ? ['--watch'] : []), + ], + wait: true, + env, + cwd + }), + ]); + + log.success('Complete'); +}).catch((error) => { + log.error(error); + process.exit(1); +}); diff --git a/packages/kbn-interpreter/tasks/build.js b/packages/kbn-interpreter/tasks/build/paths.js similarity index 60% rename from packages/kbn-interpreter/tasks/build.js rename to packages/kbn-interpreter/tasks/build/paths.js index 37776e8d74cca..5b9128a892e70 100644 --- a/packages/kbn-interpreter/tasks/build.js +++ b/packages/kbn-interpreter/tasks/build/paths.js @@ -17,24 +17,15 @@ * under the License. */ -const webpack = require('webpack'); -const webpackConfig = require('./webpack.plugins'); +const { resolve } = require('path'); -const devtool = 'inline-cheap-module-source-map'; +exports.ROOT_DIR = resolve(__dirname, '../../'); +exports.SOURCE_DIR = resolve(exports.ROOT_DIR, 'src'); +exports.BUILD_DIR = resolve(exports.ROOT_DIR, 'target'); -const onComplete = function (done) { - return function (err, stats) { - if (err) { - done && done(err); - } else { - const seconds = ((stats.endTime - stats.startTime) / 1000).toFixed(2); - console.log(`Plugins built in ${seconds} seconds`); - done && done(); - } - }; -}; +exports.PLUGIN_SOURCE_DIR = resolve(exports.SOURCE_DIR, 'plugin'); +exports.PLUGIN_BUILD_DIR = resolve(exports.BUILD_DIR, 'plugin'); -webpack({ ...webpackConfig, devtool }, onComplete(function () { - console.log('all done'); -})); +exports.WEBPACK_CONFIG_PATH = require.resolve('./webpack.config'); +exports.BABEL_PRESET_PATH = require.resolve('@kbn/babel-preset/webpack_preset'); diff --git a/packages/kbn-interpreter/tasks/build/webpack.config.js b/packages/kbn-interpreter/tasks/build/webpack.config.js new file mode 100644 index 0000000000000..9dc9398563efd --- /dev/null +++ b/packages/kbn-interpreter/tasks/build/webpack.config.js @@ -0,0 +1,110 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { resolve } = require('path'); +const { + PLUGIN_SOURCE_DIR, + PLUGIN_BUILD_DIR, + BABEL_PRESET_PATH, +} = require('./paths'); + +module.exports = function ({ sourceMaps }, { watch }) { + return { + devtool: sourceMaps ? 'inline-cheap-module-source-map' : undefined, + + entry: { + 'types/all': resolve(PLUGIN_SOURCE_DIR, 'types/register.js'), + 'functions/common/all': resolve(PLUGIN_SOURCE_DIR, 'functions/common/register.js'), + }, + + // there were problems with the node and web targets since this code is actually + // targetting both the browser and node.js. If there was a hybrid target we'd use + // it, but this seems to work either way. + target: 'webworker', + + output: { + path: PLUGIN_BUILD_DIR, + filename: '[name].js', // Need long paths here. + libraryTarget: 'umd', + }, + + resolve: { + extensions: ['.js', '.json'], + mainFields: ['browser', 'main'], + }, + + module: { + rules: [ + { + test: /\.js$/, + include: PLUGIN_SOURCE_DIR, + loaders: 'babel-loader', + options: { + babelrc: false, + presets: [BABEL_PRESET_PATH], + }, + }, + { + test: /\.(png|jpg|gif|jpeg|svg)$/, + loaders: ['url-loader'], + }, + { + test: /\.(css|scss)$/, + loaders: ['style-loader', 'css-loader', 'sass-loader'], + }, + ], + }, + + node: { + // Don't replace built-in globals + __filename: false, + __dirname: false, + }, + + watchOptions: { + ignored: [/node_modules/], + }, + + stats: 'errors-only', + + plugins: [ + function loaderFailHandler() { + if (!watch) { + return; + } + + let lastBuildFailed = false; + + // bails on error, including loader errors + // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors + this.plugin('done', function (stats) { + if (stats.hasErrors() || stats.hasWarnings()) { + lastBuildFailed = true; + return; + } + + if (lastBuildFailed) { + lastBuildFailed = false; + console.log('✅ Webpack error resolved'); + } + }); + }, + ] + }; +}; diff --git a/packages/kbn-interpreter/tasks/webpack.plugins.js b/packages/kbn-interpreter/tasks/webpack.plugins.js deleted file mode 100644 index 8a082a011de3e..0000000000000 --- a/packages/kbn-interpreter/tasks/webpack.plugins.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -const path = require('path'); - -const sourceDir = path.resolve(__dirname, '../src/plugin'); -const buildDir = path.resolve(__dirname, '../plugin'); - -module.exports = { - entry: { - 'types/all': path.join(sourceDir, 'types/register.js'), - 'functions/common/all': path.join(sourceDir, 'functions/common/register.js'), - }, - target: 'webworker', - - output: { - path: buildDir, - filename: '[name].js', // Need long paths here. - libraryTarget: 'umd', - }, - - resolve: { - extensions: ['.js', '.json'], - mainFields: ['browser', 'main'], - }, - - plugins: [ - function loaderFailHandler() { - // bails on error, including loader errors - // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors - let isWatch = true; - - this.plugin('run', function (compiler, callback) { - isWatch = false; - callback.call(compiler); - }); - - this.plugin('done', function (stats) { - if (!stats.hasErrors()) { - return; - } - const errorMessage = stats.toString('errors-only'); - if (isWatch) { - console.error(errorMessage); - } - else { - throw new Error(errorMessage); - } - }); - }, - ], - - module: { - rules: [ - { - test: /\.js$/, - exclude: [/node_modules/], - loaders: 'babel-loader', - options: { - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/webpack_preset')], - }, - }, - { - test: /\.(png|jpg|gif|jpeg|svg)$/, - loaders: ['url-loader'], - }, - { - test: /\.(css|scss)$/, - loaders: ['style-loader', 'css-loader', 'sass-loader'], - }, - ], - }, - - node: { - // Don't replace built-in globals - __filename: false, - __dirname: false, - }, - - watchOptions: { - ignored: [/node_modules/], - }, -}; diff --git a/src/core_plugins/interpreter/index.js b/src/core_plugins/interpreter/index.js index 273c8b8c37957..61ff5e1395f10 100644 --- a/src/core_plugins/interpreter/index.js +++ b/src/core_plugins/interpreter/index.js @@ -19,8 +19,8 @@ import { resolve } from 'path'; import init from './init'; -import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry'; -import { pluginPaths } from './plugin_paths'; +import { pathsRegistry } from '@kbn/interpreter/common'; +import { pluginPaths } from '@kbn/interpreter/plugin_paths'; export default function (kibana) { return new kibana.Plugin({ diff --git a/src/core_plugins/interpreter/init.js b/src/core_plugins/interpreter/init.js index 5f6640a9a0402..c48c60ec4bd07 100644 --- a/src/core_plugins/interpreter/init.js +++ b/src/core_plugins/interpreter/init.js @@ -18,8 +18,8 @@ */ import { routes } from './server/routes'; -import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; -import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; +import { functionsRegistry } from '@kbn/interpreter/common'; +import { populateServerRegistries } from '@kbn/interpreter/server'; export default async function (server /*options*/) { server.injectUiAppVars('canvas', () => { diff --git a/src/core_plugins/interpreter/public/load_browser_plugins.js b/src/core_plugins/interpreter/public/load_browser_plugins.js index 6322e8e340e45..6034dae00238c 100644 --- a/src/core_plugins/interpreter/public/load_browser_plugins.js +++ b/src/core_plugins/interpreter/public/load_browser_plugins.js @@ -17,9 +17,8 @@ * under the License. */ -import { populateBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; -import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; -import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; +import { populateBrowserRegistries } from '@kbn/interpreter/public'; +import { typesRegistry, functionsRegistry } from '@kbn/interpreter/common'; const types = { commonFunctions: functionsRegistry, diff --git a/src/core_plugins/interpreter/server/lib/get_plugin_stream.js b/src/core_plugins/interpreter/server/lib/get_plugin_stream.js index d685d365d31a4..3cfe2a89a612e 100644 --- a/src/core_plugins/interpreter/server/lib/get_plugin_stream.js +++ b/src/core_plugins/interpreter/server/lib/get_plugin_stream.js @@ -19,7 +19,7 @@ import fs from 'fs'; import ss from 'stream-stream'; -import { getPluginPaths } from '@kbn/interpreter/server/get_plugin_paths'; +import { getPluginPaths } from '@kbn/interpreter/server'; export const getPluginStream = type => { const stream = ss({ diff --git a/src/core_plugins/interpreter/server/lib/route_expression/index.js b/src/core_plugins/interpreter/server/lib/route_expression/index.js index 1b3556e051d2d..cd56b7e7bfe7e 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/index.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/index.js @@ -17,7 +17,7 @@ * under the License. */ -import { createError } from '@kbn/interpreter/common/interpreter/create_error'; +import { createError } from '@kbn/interpreter/common'; export const routeExpressionProvider = environments => { async function routeExpression(ast, context = null) { diff --git a/src/core_plugins/interpreter/server/lib/route_expression/server.js b/src/core_plugins/interpreter/server/lib/route_expression/server.js index 50a80a1e0275a..23fe1487ddcca 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/server.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/server.js @@ -17,8 +17,8 @@ * under the License. */ -import { getServerRegistries } from '@kbn/interpreter/server/server_registries'; -import { interpretProvider } from '@kbn/interpreter/common/interpreter/interpret'; +import { getServerRegistries } from '@kbn/interpreter/server'; +import { interpretProvider } from '@kbn/interpreter/common'; import { createHandlers } from '../create_handlers'; export const server = async ({ onFunctionNotFound, server, request }) => { diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js index 2a19ef81d135e..837aed5e78f7e 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/thread/babeled.js @@ -17,16 +17,5 @@ * under the License. */ -require('babel-register')({ - ignore: [ - // stolen from kibana/src/setup_node_env/babel_register/register.js - // ignore paths matching `/node_modules/{a}/{b}`, unless `a` - // is `x-pack` and `b` is not `node_modules` - /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, - ], - babelrc: false, - presets: [require.resolve('@kbn/babel-preset/node_preset')], -}); - -require('./polyfill'); +require('../../../../../../setup_node_env'); require('./worker'); diff --git a/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js b/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js index 5159679bb9f4f..e26e3052aedc8 100644 --- a/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js +++ b/src/core_plugins/interpreter/server/lib/route_expression/thread/worker.js @@ -18,9 +18,8 @@ */ import uuid from 'uuid/v4'; -import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; -import { interpretProvider } from '@kbn/interpreter/common/interpreter/interpret'; -import { serializeProvider } from '@kbn/interpreter/common/lib/serialize'; +import { populateServerRegistries } from '@kbn/interpreter/server'; +import { interpretProvider, serializeProvider } from '@kbn/interpreter/common'; // We actually DO need populateServerRegistries here since this is a different node process const pluginsReady = populateServerRegistries(['commonFunctions', 'types']); diff --git a/src/core_plugins/interpreter/server/routes/socket.js b/src/core_plugins/interpreter/server/routes/socket.js index daf16ec7a4432..80733690a7d11 100644 --- a/src/core_plugins/interpreter/server/routes/socket.js +++ b/src/core_plugins/interpreter/server/routes/socket.js @@ -18,9 +18,8 @@ */ import socket from 'socket.io'; -import { serializeProvider } from '@kbn/interpreter/common/lib/serialize'; -import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; -import { getServerRegistries } from '@kbn/interpreter/server/server_registries'; +import { serializeProvider, typesRegistry } from '@kbn/interpreter/common'; +import { getServerRegistries } from '@kbn/interpreter/server'; import { routeExpressionProvider } from '../lib/route_expression/index'; import { browser } from '../lib/route_expression/browser'; import { thread } from '../lib/route_expression/thread/index'; diff --git a/src/core_plugins/interpreter/server/routes/translate.js b/src/core_plugins/interpreter/server/routes/translate.js index 865c0da3e0617..01cd2a2401167 100644 --- a/src/core_plugins/interpreter/server/routes/translate.js +++ b/src/core_plugins/interpreter/server/routes/translate.js @@ -17,7 +17,7 @@ * under the License. */ -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression, toExpression } from '@kbn/interpreter/common'; export function translate(server) { /* diff --git a/src/setup_node_env/babel_register/register.js b/src/setup_node_env/babel_register/register.js index 0a0b542458920..2dd5850cfa9fb 100644 --- a/src/setup_node_env/babel_register/register.js +++ b/src/setup_node_env/babel_register/register.js @@ -41,9 +41,6 @@ var ignore = [ // is `x-pack` and `b` is not `node_modules` /\/node_modules\/(?!x-pack\/(?!node_modules)([^\/]+))([^\/]+\/[^\/]+)/, - // ignore paths matching `/kbn-interpreter` - /\/kbn-interpreter\//, - // ignore paths matching `/canvas/canvas_plugin/{a}/{b}` unless // `a` is `functions` and `b` is `server` /\/canvas\/canvas_plugin\/(?!functions\/server)([^\/]+\/[^\/]+)/, diff --git a/x-pack/package.json b/x-pack/package.json index 3de8ae20ca623..b77f35be97456 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -247,9 +247,7 @@ "rison-node": "0.3.1", "rxjs": "^6.2.1", "semver": "5.1.0", - "socket.io": "^2.1.1", "squel": "^5.12.2", - "stream-stream": "^1.2.6", "style-it": "^1.6.12", "styled-components": "3.3.3", "tar-fs": "1.13.0", diff --git a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js b/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js index 6ca97f159a1d5..b03e5aaf5b78e 100644 --- a/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js +++ b/x-pack/plugins/canvas/__tests__/fixtures/function_specs.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Fn } from '@kbn/interpreter/common/lib/fn'; +import { Fn } from '@kbn/interpreter/common'; import { functions as browserFns } from '../../canvas_plugin_src/functions/browser'; import { functions as commonFns } from '../../canvas_plugin_src/functions/common'; import { functions as serverFns } from '../../canvas_plugin_src/functions/server/src'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js index fcda50653380c..48e4b1d8d8a49 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/as.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; export const asFn = () => ({ name: 'as', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js index c02c6a2d2691b..825744858527f 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/mapColumn.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; export const mapColumn = () => ({ name: 'mapColumn', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js index ce4b9170d1710..6391b01c3ded6 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/plot/get_flot_axis_config.js @@ -5,7 +5,7 @@ */ import { get, map } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; export const getFlotAxisConfig = (axis, argValue, { columns, ticks, font } = {}) => { if (!argValue || argValue.show === false) return { show: false }; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js index b144cf179652d..4a5d06ac8c170 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/functions/common/staticColumn.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; export const staticColumn = () => ({ name: 'staticColumn', diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js index 04f92bc475256..884981929a9ff 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/dropdown_filter/index.js @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; import { get } from 'lodash'; -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression, toExpression } from '@kbn/interpreter/common'; import { DropdownFilter } from './component'; export const dropdownFilter = () => ({ diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js index 7ace73bc430d5..880afcd35f654 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_filter/time_filter.js @@ -7,7 +7,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common'; import { TimePicker } from '../time_picker'; import { TimePickerMini } from '../time_picker_mini'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js index 2ffc7bcf44208..c74fc590cc3fe 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/renderers/time_filter/index.js @@ -7,7 +7,7 @@ import ReactDOM from 'react-dom'; import React from 'react'; import { get, set } from 'lodash'; -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression, toExpression } from '@kbn/interpreter/common'; import { TimeFilter } from './components/time_filter'; export const timeFilter = () => ({ 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 64a426a84a7cd..d60b834931cb3 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 { compose, withPropsOnChange, withHandlers } from 'recompose'; import PropTypes from 'prop-types'; import { EuiSelect, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { sortBy } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; import { createStatefulPropHoc } from '../../../../public/components/enhance/stateful_prop'; import { templateFromReactComponent } from '../../../../public/lib/template_from_react_component'; import { SimpleMathFunction } from './simple_math_function'; diff --git a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js index fc0f89692f646..2090b7d1dc585 100644 --- a/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js +++ b/x-pack/plugins/canvas/canvas_plugin_src/uis/arguments/palette.js @@ -7,7 +7,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { get } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; import { PalettePicker } from '../../../public/components/palette_picker'; import { templateFromReactComponent } from '../../../public/lib/template_from_react_component'; diff --git a/x-pack/plugins/canvas/common/functions/to.js b/x-pack/plugins/canvas/common/functions/to.js index 25446b2868652..afc58b52b692c 100644 --- a/x-pack/plugins/canvas/common/functions/to.js +++ b/x-pack/plugins/canvas/common/functions/to.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { castProvider } from '@kbn/interpreter/common/interpreter/cast'; +import { castProvider } from '@kbn/interpreter/common'; export const to = () => ({ name: 'to', diff --git a/x-pack/plugins/canvas/common/lib/autocomplete.js b/x-pack/plugins/canvas/common/lib/autocomplete.js index 5a18c2570919b..8be391aea884a 100644 --- a/x-pack/plugins/canvas/common/lib/autocomplete.js +++ b/x-pack/plugins/canvas/common/lib/autocomplete.js @@ -5,8 +5,7 @@ */ import { uniq } from 'lodash'; -import { parse } from '@kbn/interpreter/common/lib/grammar'; -import { getByAlias } from '@kbn/interpreter/common/lib/get_by_alias'; +import { parse, getByAlias } from '@kbn/interpreter/common'; const MARKER = 'CANVAS_SUGGESTION_MARKER'; diff --git a/x-pack/plugins/canvas/index.js b/x-pack/plugins/canvas/index.js index c06a7f241e147..04c961bf23777 100644 --- a/x-pack/plugins/canvas/index.js +++ b/x-pack/plugins/canvas/index.js @@ -5,7 +5,7 @@ */ import { resolve } from 'path'; -import { pathsRegistry } from '@kbn/interpreter/common/lib/paths_registry'; +import { pathsRegistry } from '@kbn/interpreter/common'; import init from './init'; import { mappings } from './server/mappings'; import { CANVAS_APP } from './common/lib'; diff --git a/x-pack/plugins/canvas/init.js b/x-pack/plugins/canvas/init.js index 1c4479df03b3a..4ce65ff683024 100644 --- a/x-pack/plugins/canvas/init.js +++ b/x-pack/plugins/canvas/init.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; -import { populateServerRegistries } from '@kbn/interpreter/server/server_registries'; +import { functionsRegistry } from '@kbn/interpreter/common'; +import { populateServerRegistries } from '@kbn/interpreter/server'; import { routes } from './server/routes'; import { commonFunctions } from './common/functions'; import { registerCanvasUsageCollector } from './server/usage'; diff --git a/x-pack/plugins/canvas/public/components/app/index.js b/x-pack/plugins/canvas/public/components/app/index.js index b776bf59efc99..6fc4a107f719a 100644 --- a/x-pack/plugins/canvas/public/components/app/index.js +++ b/x-pack/plugins/canvas/public/components/app/index.js @@ -4,11 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { createSocket } from '@kbn/interpreter/public/socket'; -import { initialize as initializeInterpreter } from '@kbn/interpreter/public/interpreter'; +import { + createSocket, + initializeInterpreter, + populateBrowserRegistries, +} from '@kbn/interpreter/public'; import { connect } from 'react-redux'; import { compose, withProps } from 'recompose'; -import { populateBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; import { getAppReady, getBasePath } from '../../state/selectors/app'; import { appReady, appError } from '../../state/actions/app'; import { loadPrivateBrowserFunctions } from '../../lib/load_private_browser_functions'; 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 13ecfe89bb922..074314f4d2456 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 @@ -8,7 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { compose, withProps, withPropsOnChange } from 'recompose'; import { EuiForm, EuiTextArea, EuiButton, EuiButtonEmpty, EuiFormRow } from '@elastic/eui'; -import { fromExpression, toExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression, toExpression } from '@kbn/interpreter/common'; import { createStatefulPropHoc } from '../../components/enhance/stateful_prop'; export const AdvancedFailureComponent = props => { diff --git a/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js b/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js index f1f3fb2ddae97..7cb5a6f3c54fc 100644 --- a/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js +++ b/x-pack/plugins/canvas/public/components/datasource/datasource_preview/index.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; +import { interpretAst } from '@kbn/interpreter/public'; import { pure, compose, lifecycle, withState, branch, renderComponent } from 'recompose'; import { PropTypes } from 'prop-types'; import { Loading } from '../../loading'; diff --git a/x-pack/plugins/canvas/public/components/element_content/element_content.js b/x-pack/plugins/canvas/public/components/element_content/element_content.js index cb53f9efd0e63..cf885b347aad0 100644 --- a/x-pack/plugins/canvas/public/components/element_content/element_content.js +++ b/x-pack/plugins/canvas/public/components/element_content/element_content.js @@ -8,7 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { pure, compose, branch, renderComponent } from 'recompose'; import Style from 'style-it'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; import { Loading } from '../loading'; import { RenderWithFn } from '../render_with_fn'; import { ElementShareContainer } from '../element_share_container'; diff --git a/x-pack/plugins/canvas/public/components/expression/index.js b/x-pack/plugins/canvas/public/components/expression/index.js index 81d73959e83b8..cb4cc251fbbe1 100644 --- a/x-pack/plugins/canvas/public/components/expression/index.js +++ b/x-pack/plugins/canvas/public/components/expression/index.js @@ -15,7 +15,7 @@ import { branch, renderComponent, } from 'recompose'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common'; import { getSelectedPage, getSelectedElement } from '../../state/selectors/workpad'; import { setExpression, flushContext } from '../../state/actions/elements'; import { getFunctionDefinitions } from '../../lib/function_definitions'; 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 84748f5bbbbb3..7f60a43835eba 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 @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; +import { interpretAst } from '@kbn/interpreter/public'; import { compose, withProps } from 'recompose'; import { get } from 'lodash'; -import { toExpression } from '@kbn/interpreter/common/lib/ast'; +import { toExpression } from '@kbn/interpreter/common'; import { modelRegistry, viewRegistry, transformRegistry } from '../../expression_types'; import { FunctionFormList as Component } from './function_form_list'; diff --git a/x-pack/plugins/canvas/public/expression_types/arg_type.js b/x-pack/plugins/canvas/public/expression_types/arg_type.js index a19c726e138c2..f2ad9338925a9 100644 --- a/x-pack/plugins/canvas/public/expression_types/arg_type.js +++ b/x-pack/plugins/canvas/public/expression_types/arg_type.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { BaseForm } from './base_form'; export class ArgType extends BaseForm { diff --git a/x-pack/plugins/canvas/public/expression_types/datasource.js b/x-pack/plugins/canvas/public/expression_types/datasource.js index cd9a8af5f0182..0539486146136 100644 --- a/x-pack/plugins/canvas/public/expression_types/datasource.js +++ b/x-pack/plugins/canvas/public/expression_types/datasource.js @@ -6,7 +6,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { RenderToDom } from '../components/render_to_dom'; import { ExpressionFormHandlers } from '../../common/lib/expression_form_handlers'; import { BaseForm } from './base_form'; diff --git a/x-pack/plugins/canvas/public/expression_types/function_form.js b/x-pack/plugins/canvas/public/expression_types/function_form.js index c7bc16a5b2e2b..ba58424b7b8c3 100644 --- a/x-pack/plugins/canvas/public/expression_types/function_form.js +++ b/x-pack/plugins/canvas/public/expression_types/function_form.js @@ -7,7 +7,7 @@ import { EuiCallOut } from '@elastic/eui'; import React from 'react'; import { isPlainObject, uniq, last, compact } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common'; import { ArgAddPopover } from '../components/arg_add_popover'; import { SidebarSection } from '../components/sidebar/sidebar_section'; import { SidebarSectionTitle } from '../components/sidebar/sidebar_section_title'; diff --git a/x-pack/plugins/canvas/public/expression_types/model.js b/x-pack/plugins/canvas/public/expression_types/model.js index 7ce1126bdec55..1bdcbdeefb50a 100644 --- a/x-pack/plugins/canvas/public/expression_types/model.js +++ b/x-pack/plugins/canvas/public/expression_types/model.js @@ -5,7 +5,7 @@ */ import { get, pick } from 'lodash'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { FunctionForm } from './function_form'; const NO_NEXT_EXP = 'no next expression'; diff --git a/x-pack/plugins/canvas/public/expression_types/transform.js b/x-pack/plugins/canvas/public/expression_types/transform.js index 760eae46195d6..ddbdbd5567983 100644 --- a/x-pack/plugins/canvas/public/expression_types/transform.js +++ b/x-pack/plugins/canvas/public/expression_types/transform.js @@ -5,7 +5,7 @@ */ import { pick } from 'lodash'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { FunctionForm } from './function_form'; export class Transform extends FunctionForm { diff --git a/x-pack/plugins/canvas/public/expression_types/view.js b/x-pack/plugins/canvas/public/expression_types/view.js index 1b7fe13d508b0..6d0b6cd7a2817 100644 --- a/x-pack/plugins/canvas/public/expression_types/view.js +++ b/x-pack/plugins/canvas/public/expression_types/view.js @@ -5,7 +5,7 @@ */ import { pick } from 'lodash'; -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { FunctionForm } from './function_form'; export class View extends FunctionForm { diff --git a/x-pack/plugins/canvas/public/functions/filters.js b/x-pack/plugins/canvas/public/functions/filters.js index 3c578a93fc3b6..ca78b119d2a59 100644 --- a/x-pack/plugins/canvas/public/functions/filters.js +++ b/x-pack/plugins/canvas/public/functions/filters.js @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; -import { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; +import { interpretAst } from '@kbn/interpreter/public'; +import { fromExpression, typesRegistry } from '@kbn/interpreter/common'; import { getState } from '../state/store'; import { getGlobalFilterExpression } from '../state/selectors/workpad'; diff --git a/x-pack/plugins/canvas/public/lib/arg_helpers.js b/x-pack/plugins/canvas/public/lib/arg_helpers.js index e1cd8b64b323f..5640a218170e8 100644 --- a/x-pack/plugins/canvas/public/lib/arg_helpers.js +++ b/x-pack/plugins/canvas/public/lib/arg_helpers.js @@ -5,7 +5,7 @@ */ import { includes } from 'lodash'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { getType } from '@kbn/interpreter/common'; /* diff --git a/x-pack/plugins/canvas/public/lib/elements_registry.js b/x-pack/plugins/canvas/public/lib/elements_registry.js index dc3d743f49877..5f91377be2f48 100644 --- a/x-pack/plugins/canvas/public/lib/elements_registry.js +++ b/x-pack/plugins/canvas/public/lib/elements_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { Element } from './element'; class ElementsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/function_definitions.js b/x-pack/plugins/canvas/public/lib/function_definitions.js index c0f3496dfc083..40b122f2f6a03 100644 --- a/x-pack/plugins/canvas/public/lib/function_definitions.js +++ b/x-pack/plugins/canvas/public/lib/function_definitions.js @@ -5,7 +5,7 @@ */ import uniqBy from 'lodash.uniqby'; -import { getBrowserRegistries } from '@kbn/interpreter/public/browser_registries'; +import { getBrowserRegistries } from '@kbn/interpreter/public'; import { getServerFunctions } from '../state/selectors/app'; export async function getFunctionDefinitions(state) { diff --git a/x-pack/plugins/canvas/public/lib/functions_registry.js b/x-pack/plugins/canvas/public/lib/functions_registry.js index 36f9a631f06ea..f90fe453e9a1c 100644 --- a/x-pack/plugins/canvas/public/lib/functions_registry.js +++ b/x-pack/plugins/canvas/public/lib/functions_registry.js @@ -5,4 +5,4 @@ */ // export the common registry here, so it's available in plugin public code -export { functionsRegistry } from '@kbn/interpreter/common/lib/functions_registry'; +export { functionsRegistry } from '@kbn/interpreter/common'; 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 696c058e34a2b..f9a560f2cfb12 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 @@ -5,7 +5,7 @@ */ import { get, mapValues, map } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common'; export function parseSingleFunctionChain(filterString) { const ast = fromExpression(filterString); diff --git a/x-pack/plugins/canvas/public/lib/render_functions_registry.js b/x-pack/plugins/canvas/public/lib/render_functions_registry.js index a34ed009a33b1..0a4b09cd17ca2 100644 --- a/x-pack/plugins/canvas/public/lib/render_functions_registry.js +++ b/x-pack/plugins/canvas/public/lib/render_functions_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { RenderFunction } from './render_function'; class RenderFunctionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/run_interpreter.js b/x-pack/plugins/canvas/public/lib/run_interpreter.js index 7bb898b254ec8..3c193130c1fe1 100644 --- a/x-pack/plugins/canvas/public/lib/run_interpreter.js +++ b/x-pack/plugins/canvas/public/lib/run_interpreter.js @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; -import { getType } from '@kbn/interpreter/common/lib/get_type'; +import { interpretAst } from '@kbn/interpreter/public'; +import { fromExpression, getType } from '@kbn/interpreter/common'; import { notify } from './notify'; /** diff --git a/x-pack/plugins/canvas/public/lib/transitions_registry.js b/x-pack/plugins/canvas/public/lib/transitions_registry.js index 8ead0aa896ab7..e6418a56e100b 100644 --- a/x-pack/plugins/canvas/public/lib/transitions_registry.js +++ b/x-pack/plugins/canvas/public/lib/transitions_registry.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Registry } from '@kbn/interpreter/common/lib/registry'; +import { Registry } from '@kbn/interpreter/common'; import { Transition } from '../transitions/transition'; class TransitionsRegistry extends Registry { diff --git a/x-pack/plugins/canvas/public/lib/types_registry.js b/x-pack/plugins/canvas/public/lib/types_registry.js index 05b82c744c383..292e1547f482f 100644 --- a/x-pack/plugins/canvas/public/lib/types_registry.js +++ b/x-pack/plugins/canvas/public/lib/types_registry.js @@ -5,4 +5,4 @@ */ // export the common registry here, so it's available in plugin public code -export { typesRegistry } from '@kbn/interpreter/common/lib/types_registry'; +export { typesRegistry } from '@kbn/interpreter/common'; diff --git a/x-pack/plugins/canvas/public/state/actions/elements.js b/x-pack/plugins/canvas/public/state/actions/elements.js index be157d9d8085b..5224f1228417a 100644 --- a/x-pack/plugins/canvas/public/state/actions/elements.js +++ b/x-pack/plugins/canvas/public/state/actions/elements.js @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { interpretAst } from '@kbn/interpreter/public/interpreter'; +import { interpretAst } from '@kbn/interpreter/public'; import { createAction } from 'redux-actions'; import { createThunk } from 'redux-thunks'; import { set, del } from 'object-path-immutable'; import { get, pick, cloneDeep, without } from 'lodash'; -import { toExpression, safeElementFromExpression } from '@kbn/interpreter/common/lib/ast'; +import { toExpression, safeElementFromExpression } from '@kbn/interpreter/common'; import { getPages, getElementById, getSelectedPageIndex } from '../selectors/workpad'; import { getValue as getResolvedArgsValue } from '../selectors/resolved_args'; import { getDefaultElement } from '../defaults'; diff --git a/x-pack/plugins/canvas/public/state/selectors/workpad.js b/x-pack/plugins/canvas/public/state/selectors/workpad.js index 6d888f60c2191..1e767b847c460 100644 --- a/x-pack/plugins/canvas/public/state/selectors/workpad.js +++ b/x-pack/plugins/canvas/public/state/selectors/workpad.js @@ -5,7 +5,7 @@ */ import { get, omit } from 'lodash'; -import { safeElementFromExpression } from '@kbn/interpreter/common/lib/ast'; +import { safeElementFromExpression } from '@kbn/interpreter/common'; import { append } from '../../lib/modify_path'; import { getAssets } from './assets'; diff --git a/x-pack/plugins/canvas/server/usage/collector.js b/x-pack/plugins/canvas/server/usage/collector.js index d76d023f7c7e4..a73ab069638b0 100644 --- a/x-pack/plugins/canvas/server/usage/collector.js +++ b/x-pack/plugins/canvas/server/usage/collector.js @@ -5,7 +5,7 @@ */ import { sum as arraySum, min as arrayMin, max as arrayMax, get } from 'lodash'; -import { fromExpression } from '@kbn/interpreter/common/lib/ast'; +import { fromExpression } from '@kbn/interpreter/common'; import { CANVAS_USAGE_TYPE, CANVAS_TYPE } from '../../common/lib/constants'; /* diff --git a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js index 1ac1fca8b1b5a..0968417d5d260 100644 --- a/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js +++ b/x-pack/plugins/canvas/tasks/helpers/webpack.plugins.js @@ -47,17 +47,10 @@ export function getWebpackConfig({ devtool, watch } = {}) { function loaderFailHandler() { // bails on error, including loader errors // see https://github.com/webpack/webpack/issues/708, which does not fix loader errors - let isWatch = true; - - this.plugin('run', function(compiler, callback) { - isWatch = false; - callback.call(compiler); - }); - this.plugin('done', function(stats) { if (!stats.hasErrors()) return; const errorMessage = stats.toString('errors-only'); - if (isWatch) console.error(errorMessage); + if (watch) console.error(errorMessage); else throw new Error(errorMessage); }); }, diff --git a/yarn.lock b/yarn.lock index 542b3d64e7aa9..f2b9986e39b9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9224,6 +9224,11 @@ getopts@^2.0.6: resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.0.6.tgz#4788d533a977527e79efd57b5e742ffa0dd33105" integrity sha512-LauKhe3IAHTAlefQNg1I4rZRE6uPrCWwtVh/rMwHAvqY0PaEkRxOzhgyam0+ZBGdh0K6vybD81KeaS6v6H9+Ww== +getopts@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.3.tgz#11d229775e2ec2067ed8be6fcc39d9b4bf39cf7d" + integrity sha512-viEcb8TpgeG05+Nqo5EzZ8QR0hxdyrYDp6ZSTZqe2M/h53Bk036NmqG38Vhf5RGirC/Of9Xql+v66B2gp256SQ== + getos@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/getos/-/getos-3.1.0.tgz#db3aa4df15a3295557ce5e81aa9e3e5cdfaa6567" @@ -20114,7 +20119,7 @@ supports-color@^5.2.0, supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -supports-color@^5.4.0: +supports-color@^5.4.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==