mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
parent
cab952bb92
commit
ee093bbcdf
54 changed files with 63 additions and 276 deletions
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"private": true,
|
||||
"main": "../target/public/index.js",
|
||||
"jsnext:main": "../src/public/index.js"
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"private": true,
|
||||
"main": "../target/server/index.js",
|
||||
"jsnext:main": "../src/server/index.js"
|
||||
}
|
|
@ -17,15 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { FunctionsRegistry } from './lib/functions_registry';
|
||||
export { TypesRegistry } from './lib/types_registry';
|
||||
export { createError } from './interpreter/create_error';
|
||||
export { interpreterProvider } 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 { castProvider } from './lib/cast';
|
||||
export { parse } from './lib/grammar';
|
||||
export { getByAlias } from './lib/get_by_alias';
|
||||
export { Registry } from './lib/registry';
|
||||
|
|
|
@ -1,28 +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.
|
||||
*/
|
||||
|
||||
export { initializeInterpreter } from './interpreter';
|
||||
export { RenderFunctionsRegistry } from './render_functions_registry';
|
||||
export { registries } from './registries';
|
||||
import { registries } from './registries';
|
||||
import { registryFactory } from '../common';
|
||||
|
||||
// Expose kbnInterpreter.register(specs) and kbnInterpreter.registries() globally so that plugins
|
||||
// can register without a transpile step.
|
||||
global.kbnInterpreter = Object.assign(global.kbnInterpreter || {}, registryFactory(registries));
|
|
@ -1,34 +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.
|
||||
*/
|
||||
|
||||
import { register, FunctionsRegistry, TypesRegistry } from '../common';
|
||||
import { RenderFunctionsRegistry } from './render_functions_registry';
|
||||
import { browserFunctions } from '../plugin/functions/browser';
|
||||
import { typeSpecs } from '../plugin/types';
|
||||
|
||||
export const registries = {
|
||||
browserFunctions: new FunctionsRegistry(),
|
||||
renderers: new RenderFunctionsRegistry(),
|
||||
types: new TypesRegistry(),
|
||||
};
|
||||
|
||||
register(registries, {
|
||||
browserFunctions,
|
||||
types: typeSpecs,
|
||||
});
|
|
@ -27,7 +27,6 @@ const { ToolingLog, withProcRunner, pickLevelFromFlags } = require('@kbn/dev-uti
|
|||
const {
|
||||
ROOT_DIR,
|
||||
BUILD_DIR,
|
||||
WEBPACK_CONFIG_PATH
|
||||
} = require('./paths');
|
||||
|
||||
const unknownFlags = [];
|
||||
|
@ -75,7 +74,7 @@ withProcRunner(log, async (proc) => {
|
|||
env.FORCE_COLOR = 'true';
|
||||
}
|
||||
|
||||
log.info(`Starting babel and webpack${flags.watch ? ' in watch mode' : ''}`);
|
||||
log.info(`Starting babel ${flags.watch ? ' in watch mode' : ''}`);
|
||||
await Promise.all([
|
||||
proc.run('babel ', {
|
||||
cmd: 'babel',
|
||||
|
@ -91,18 +90,6 @@ withProcRunner(log, async (proc) => {
|
|||
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');
|
||||
|
|
|
@ -23,9 +23,5 @@ exports.ROOT_DIR = resolve(__dirname, '../../');
|
|||
exports.SOURCE_DIR = resolve(exports.ROOT_DIR, 'src');
|
||||
exports.BUILD_DIR = resolve(exports.ROOT_DIR, 'target');
|
||||
|
||||
exports.PLUGIN_SOURCE_DIR = resolve(exports.SOURCE_DIR, 'plugin');
|
||||
exports.PLUGIN_BUILD_DIR = resolve(exports.BUILD_DIR, 'canvas_plugin');
|
||||
|
||||
exports.WEBPACK_CONFIG_PATH = require.resolve('./webpack.config');
|
||||
exports.BABEL_PRESET_PATH = require.resolve('@kbn/babel-preset/webpack_preset');
|
||||
|
||||
|
|
|
@ -1,135 +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 { resolve } = require('path');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
|
||||
const { createServerCodeTransformer } = require('./server_code_transformer');
|
||||
|
||||
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,
|
||||
|
||||
mode: 'none',
|
||||
entry: {
|
||||
'types/all': resolve(PLUGIN_SOURCE_DIR, 'types/register.js'),
|
||||
'functions/browser/all': resolve(PLUGIN_SOURCE_DIR, 'functions/browser/register.js'),
|
||||
'functions/browser/common': 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',
|
||||
// Note: this is needed due to a not yet resolved bug on
|
||||
// webpack 4 with umd modules generation.
|
||||
// For now we have 2 quick workarounds: one is what is implemented
|
||||
// below another is to change the libraryTarget to commonjs
|
||||
//
|
||||
// The issues can be followed on:
|
||||
// https://github.com/webpack/webpack/issues/6642
|
||||
// https://github.com/webpack/webpack/issues/6525
|
||||
// https://github.com/webpack/webpack/issues/6677
|
||||
globalObject: `(typeof self !== 'undefined' ? self : this)`,
|
||||
},
|
||||
|
||||
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: [
|
||||
new CopyWebpackPlugin([
|
||||
{
|
||||
from: resolve(PLUGIN_SOURCE_DIR, 'functions/common'),
|
||||
to: resolve(PLUGIN_BUILD_DIR, 'functions/common'),
|
||||
ignore: '**/__tests__/**',
|
||||
transform: createServerCodeTransformer(sourceMaps)
|
||||
},
|
||||
]),
|
||||
|
||||
function LoaderFailHandlerPlugin() {
|
||||
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.hooks.done.tapPromise('LoaderFailHandlerPlugin', async stats => {
|
||||
if (stats.hasErrors() || stats.hasWarnings()) {
|
||||
lastBuildFailed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastBuildFailed) {
|
||||
lastBuildFailed = false;
|
||||
console.log('✅ Webpack error resolved');
|
||||
}
|
||||
});
|
||||
},
|
||||
]
|
||||
};
|
||||
};
|
|
@ -17,8 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Registry } from './registry';
|
||||
import { Fn } from './fn';
|
||||
import { Fn, Registry } from '@kbn/interpreter/common';
|
||||
|
||||
export class FunctionsRegistry extends Registry {
|
||||
wrapper(obj) {
|
|
@ -19,10 +19,7 @@
|
|||
|
||||
import clone from 'lodash.clone';
|
||||
import { each, keys, last, mapValues, reduce, zipObject } from 'lodash';
|
||||
import { getType } from '../lib/get_type';
|
||||
import { fromExpression } from '../lib/ast';
|
||||
import { getByAlias } from '../lib/get_by_alias';
|
||||
import { castProvider } from './cast';
|
||||
import { getType, fromExpression, getByAlias, castProvider } from '@kbn/interpreter/common';
|
||||
import { createError } from './create_error';
|
||||
|
||||
export function interpreterProvider(config) {
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { get, identity } from 'lodash';
|
||||
import { getType } from './get_type';
|
||||
import { getType } from '@kbn/interpreter/common';
|
||||
|
||||
export function serializeProvider(types) {
|
||||
return {
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
// All types must be universal and be castable on the client or on the server
|
||||
import { get } from 'lodash';
|
||||
import { getType } from './get_type';
|
||||
import { getType } from '@kbn/interpreter/common';
|
||||
|
||||
// TODO: Currently all casting functions must be syncronous.
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Registry } from './registry';
|
||||
import { Registry } from '@kbn/interpreter/common';
|
||||
import { Type } from './type';
|
||||
|
||||
export class TypesRegistry extends Registry {
|
|
@ -18,18 +18,31 @@
|
|||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import { registryFactory } from '@kbn/interpreter/common';
|
||||
|
||||
// @ts-ignore
|
||||
import { registries } from '@kbn/interpreter/server';
|
||||
import { register, registryFactory } from '@kbn/interpreter/common';
|
||||
|
||||
// @ts-ignore
|
||||
import { routes } from './server/routes';
|
||||
|
||||
import { Legacy } from '../../../../kibana';
|
||||
|
||||
// @ts-ignore
|
||||
import { FunctionsRegistry } from './common/functions_registry';
|
||||
// @ts-ignore
|
||||
import { typeSpecs as types } from './common/types';
|
||||
// @ts-ignore
|
||||
import { TypesRegistry } from './common/types_registry';
|
||||
|
||||
export const registries = {
|
||||
types: new TypesRegistry(),
|
||||
serverFunctions: new FunctionsRegistry(),
|
||||
};
|
||||
|
||||
export async function init(server: Legacy.Server /*options*/) {
|
||||
server.injectUiAppVars('canvas', () => {
|
||||
register(registries, {
|
||||
types,
|
||||
});
|
||||
|
||||
const config = server.config();
|
||||
const basePath = config.get('server.basePath');
|
||||
const reportingBrowserType = (() => {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { clog } from './clog';
|
||||
import { esaggs } from './esaggs';
|
||||
import { kibana } from './kibana';
|
||||
import { kibanaContext } from './kibana_context';
|
||||
|
@ -35,6 +36,6 @@ import { vislib } from './vislib';
|
|||
import { visualization } from './visualization';
|
||||
|
||||
export const functions = [
|
||||
esaggs, kibana, kibanaContext, vega, timelionVis, tsvb, kibanaMarkdown, inputControlVis,
|
||||
clog, esaggs, kibana, kibanaContext, vega, timelionVis, tsvb, kibanaMarkdown, inputControlVis,
|
||||
metric, kibanaPie, regionmap, tilemap, kibanaTable, tagcloud, vislib, visualization
|
||||
];
|
||||
|
|
|
@ -17,14 +17,21 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { register } from '@kbn/interpreter/common';
|
||||
import { initializeInterpreter, registries } from '@kbn/interpreter/public';
|
||||
import { register, registryFactory } from '@kbn/interpreter/common';
|
||||
import { initializeInterpreter } from './lib/interpreter';
|
||||
import { registries } from './registries';
|
||||
import { kfetch } from 'ui/kfetch';
|
||||
import { ajaxStream } from 'ui/ajax_stream';
|
||||
import { functions } from './functions';
|
||||
import { visualization } from './renderers/visualization';
|
||||
import { typeSpecs } from '../common/types';
|
||||
|
||||
// Expose kbnInterpreter.register(specs) and kbnInterpreter.registries() globally so that plugins
|
||||
// can register without a transpile step.
|
||||
global.kbnInterpreter = Object.assign(global.kbnInterpreter || {}, registryFactory(registries));
|
||||
|
||||
register(registries, {
|
||||
types: typeSpecs,
|
||||
browserFunctions: functions,
|
||||
renderers: [visualization],
|
||||
});
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { interpreterProvider } from '../common/interpreter/interpret';
|
||||
import { serializeProvider } from '../common/lib/serialize';
|
||||
import { interpreterProvider } from '../../common/interpreter/interpret';
|
||||
import { serializeProvider } from '../../common/serialize';
|
||||
import { createHandlers } from './create_handlers';
|
||||
import { batchedFetch } from './batched_fetch';
|
||||
import { FUNCTIONS_URL } from './consts';
|
|
@ -20,11 +20,11 @@
|
|||
import { FUNCTIONS_URL } from './consts';
|
||||
import { initializeInterpreter } from './interpreter';
|
||||
|
||||
jest.mock('../common/interpreter/interpret', () => ({
|
||||
jest.mock('../../common/interpreter/interpret', () => ({
|
||||
interpreterProvider: () => () => ({}),
|
||||
}));
|
||||
|
||||
jest.mock('../common/lib/serialize', () => ({
|
||||
jest.mock('../../common/serialize', () => ({
|
||||
serializeProvider: () => ({ serialize: () => ({}) }),
|
||||
}));
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Registry } from '../common';
|
||||
import { Registry } from '@kbn/interpreter/common';
|
||||
import { RenderFunction } from './render_function';
|
||||
|
||||
class RenderFunctionsRegistry extends Registry {
|
|
@ -17,7 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { browserFunctions } from './index';
|
||||
import { FunctionsRegistry } from '../../common/functions_registry';
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
browserFunctions.forEach(canvas.register);
|
||||
export const functionsRegistry = new FunctionsRegistry();
|
|
@ -17,14 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { typeSpecs as types } from '../plugin/types';
|
||||
import { register, TypesRegistry, FunctionsRegistry } from '../common';
|
||||
import { typesRegistry } from './type_registry';
|
||||
import { functionsRegistry } from './functions_registry';
|
||||
import { renderersRegistry } from './renderer_registry';
|
||||
|
||||
export const registries = {
|
||||
types: new TypesRegistry(),
|
||||
serverFunctions: new FunctionsRegistry(),
|
||||
const registries = {
|
||||
browserFunctions: functionsRegistry,
|
||||
renderers: renderersRegistry,
|
||||
types: typesRegistry,
|
||||
};
|
||||
|
||||
register(registries, {
|
||||
types,
|
||||
});
|
||||
export { registries, typesRegistry, functionsRegistry, renderersRegistry };
|
|
@ -17,4 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import '../common/register';
|
||||
import { RenderFunctionsRegistry } from '../lib/render_functions_registry';
|
||||
|
||||
export const renderersRegistry = new RenderFunctionsRegistry();
|
|
@ -17,8 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { clog } from './clog';
|
||||
import { TypesRegistry } from '../../common/types_registry';
|
||||
|
||||
export const browserFunctions = [
|
||||
clog,
|
||||
];
|
||||
export const typesRegistry = new TypesRegistry();
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import Boom from 'boom';
|
||||
import { serializeProvider } from '@kbn/interpreter/common';
|
||||
import { serializeProvider } from '../../common/serialize';
|
||||
import { API_ROUTE } from '../../common/constants';
|
||||
import { createHandlers } from '../lib/create_handlers';
|
||||
import Joi from 'joi';
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
// @ts-ignore untyped dependency
|
||||
import { registries } from '@kbn/interpreter/public';
|
||||
import { EventEmitter } from 'events';
|
||||
import { debounce, forEach, get } from 'lodash';
|
||||
import * as Rx from 'rxjs';
|
||||
import { share } from 'rxjs/operators';
|
||||
// @ts-ignore untyped dependency
|
||||
import { registries } from '../../../../core_plugins/interpreter/public/registries';
|
||||
import { Inspector } from '../../inspector';
|
||||
import { Adapters } from '../../inspector/types';
|
||||
import { PersistedState } from '../../persisted_state';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { getInterpreter } from 'plugins/interpreter/interpreter';
|
||||
import { registries } from '@kbn/interpreter/public';
|
||||
import { registries } from 'plugins/interpreter/registries';
|
||||
import { register, addRegistries } from '@kbn/interpreter/common';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose, withProps } from 'recompose';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { registries } from '@kbn/interpreter/public';
|
||||
import { registries } from 'plugins/interpreter/registries';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { compose, withProps } from 'recompose';
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { interpretAst } from 'plugins/interpreter/interpreter';
|
||||
import { registries } from '@kbn/interpreter/public';
|
||||
import { registries } from 'plugins/interpreter/registries';
|
||||
import { fromExpression } from '@kbn/interpreter/common';
|
||||
import { getState } from '../state/store';
|
||||
import { getGlobalFilterExpression } from '../state/selectors/workpad';
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { registries } from 'plugins/interpreter/registries';
|
||||
import { castProvider } from '@kbn/interpreter/common';
|
||||
import { registries } from '@kbn/interpreter/public';
|
||||
|
||||
export const to = () => ({
|
||||
name: 'to',
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { registries } from '@kbn/interpreter/public';
|
||||
import { registries } from 'plugins/interpreter/registries';
|
||||
import uniqBy from 'lodash.uniqby';
|
||||
import { getServerFunctions } from '../state/selectors/app';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue