Expressions fully migrated to the New Platform (#50294) (#50994)

* chore: 🤖 use "expressions" namespace for expression translation

* feat: 🎸 move Expressions renderer to the New Platform

* feat: 🎸 move Expression executor to the New Platform

* feat: 🎸 move Expressions loader to the New Platform

* feat: 🎸 re-export Expressions setup, remove services.ts

* feat: 🎸 use "expressions" translation namespace

* feat: 🎸 move Expressions start contract to the New Platform

* feat: 🎸 move expressions mocks to the New Platform

* chore: 🤖 clean up NP-ready Expressions plugin

* feat: 🎸 remove Expressions shim, merge prev PV changes

* feat: 🎸 clean up expressions and interpreter plugins

* fix: 🐛 remember exression services

* fix: 🐛 load legacy Interpeter functions using uiExport

* perf: ️ run executer with always the latest functions

* fix: 🐛 load interpreter actions in Kibana, provide functions

* fix: 🐛 load Interpreter uiExport int Lens app

* fix: 🐛 load Interpeter uiExports int Canvas

* refactor: 💡 move esaggs function to data plugin Search service

* refactor: 💡 move visualization registrants to Visualizations pl

* test: 💍 fix Lens Jest test mocks

* fix: 🐛 correct translations for moved registrants

* chore: 🤖 address PR comments

* fix: 🐛 load Expressions CSS, nuke Expressions legacy plugin

* fix: 🐛 stop leaking CSS classes between Expressiosn and Lens

* chore: 🤖 remove expression types from client-side use /common

* chore: 🤖 address review comments

* fix: 🐛 load interpreter ui-exports in dashboard_viewer

* Have ExpressionRenderer accept className prop.

* Fix static positioning class targets
This commit is contained in:
Vadim Dalecky 2019-11-18 17:46:15 -08:00 committed by GitHub
parent cd8fe02ed0
commit 922f9bd6bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
229 changed files with 690 additions and 1148 deletions

View file

@ -7,8 +7,7 @@
"data": ["src/legacy/core_plugins/data", "src/plugins/data"],
"embeddableApi": "src/plugins/embeddable",
"esUi": "src/plugins/es_ui_shared",
"expressions_np": "src/plugins/expressions",
"expressions": "src/legacy/core_plugins/expressions",
"expressions": "src/plugins/expressions",
"inputControl": "src/legacy/core_plugins/input_control_vis",
"inspector": "src/plugins/inspector",
"inspectorViews": "src/legacy/core_plugins/inspector_views",
@ -34,7 +33,7 @@
"visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud",
"visTypeTimeseries": "src/legacy/core_plugins/vis_type_timeseries",
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
"visualizations": "src/plugins/visualizations"
"visualizations": ["src/plugins/visualizations", "src/legacy/core_plugins/visualizations"]
},
"exclude": ["src/legacy/ui/ui_render/ui_render_mixin.js"],
"translations": []

View file

@ -35,6 +35,7 @@ export default function DataPlugin(kibana: any) {
},
init: (server: Legacy.Server) => ({}),
uiExports: {
interpreter: ['plugins/data/search/expressions/boot'],
injectDefaultVars: () => ({}),
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
mappings,

View file

@ -17,5 +17,7 @@
* under the License.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/fonts';
import { npSetup } from 'ui/new_platform';
import { esaggs } from './esaggs';
npSetup.plugins.expressions.registerFunction(esaggs);

View file

@ -22,22 +22,32 @@ import { i18n } from '@kbn/i18n';
import { AggConfigs } from 'ui/agg_types/agg_configs';
import { createFormat } from 'ui/visualize/loader/pipeline_helpers/utilities';
import chrome from 'ui/chrome';
import { Query, TimeRange, esFilters } from 'src/plugins/data/public';
import { SearchSource } from '../../../../ui/public/courier/search_source';
import {
KibanaContext,
KibanaDatatable,
ExpressionFunction,
KibanaDatatableColumn,
} from 'src/plugins/expressions/public';
import { SearchSource } from '../../../../../ui/public/courier/search_source';
// @ts-ignore
import {
FilterBarQueryFilterProvider,
QueryFilter,
} from '../../../../ui/public/filter_manager/query_filter';
} from '../../../../../ui/public/filter_manager/query_filter';
import { buildTabularInspectorData } from '../../../../ui/public/inspector/build_tabular_inspector_data';
import { buildTabularInspectorData } from '../../../../../ui/public/inspector/build_tabular_inspector_data';
import {
getRequestInspectorStats,
getResponseInspectorStats,
} from '../../../../ui/public/courier/utils/courier_inspector_utils';
import { calculateObjectHash } from '../../../../ui/public/vis/lib/calculate_object_hash';
import { getTime } from '../../../../ui/public/timefilter';
} from '../../../../../ui/public/courier/utils/courier_inspector_utils';
import { calculateObjectHash } from '../../../../../ui/public/vis/lib/calculate_object_hash';
import { getTime } from '../../../../../ui/public/timefilter';
// @ts-ignore
import { tabifyAggResponse } from '../../../../../ui/public/agg_response/tabify/tabify';
import { start as data } from '../../../../data/public/legacy';
import { PersistedState } from '../../../../../ui/public/persisted_state';
import { Adapters } from '../../../../../../plugins/inspector/public';
export interface RequestHandlerParams {
searchSource: SearchSource;
@ -55,14 +65,6 @@ export interface RequestHandlerParams {
abortSignal?: AbortSignal;
}
// @ts-ignore
import { tabifyAggResponse } from '../../../../ui/public/agg_response/tabify/tabify';
import { KibanaContext, KibanaDatatable } from '../../common';
import { ExpressionFunction, KibanaDatatableColumn } from '../../types';
import { start as data } from '../../../data/public/legacy';
import { PersistedState } from '../../../../ui/public/persisted_state';
import { Adapters } from '../../../../../plugins/inspector/public';
const name = 'esaggs';
type Context = KibanaContext | null;
@ -140,17 +142,14 @@ const handleCourierRequest = async ({
if (shouldQuery) {
inspectorAdapters.requests.reset();
const request = inspectorAdapters.requests.start(
i18n.translate('interpreter.functions.esaggs.inspector.dataRequest.title', {
i18n.translate('data.functions.esaggs.inspector.dataRequest.title', {
defaultMessage: 'Data',
}),
{
description: i18n.translate(
'interpreter.functions.esaggs.inspector.dataRequest.description',
{
defaultMessage:
'This request queries Elasticsearch to fetch the data for the visualization.',
}
),
description: i18n.translate('data.functions.esaggs.inspector.dataRequest.description', {
defaultMessage:
'This request queries Elasticsearch to fetch the data for the visualization.',
}),
}
);
request.stats(getRequestInspectorStats(requestSearchSource));
@ -229,7 +228,7 @@ export const esaggs = (): ExpressionFunction<typeof name, Context, Arguments, Re
context: {
types: ['kibana_context', 'null'],
},
help: i18n.translate('interpreter.functions.esaggs.help', {
help: i18n.translate('data.functions.esaggs.help', {
defaultMessage: 'Run AggConfig aggregation',
}),
args: {

View file

@ -1,4 +0,0 @@
{
"name": "expressions",
"version": "kibana"
}

View file

@ -1,20 +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 * from './index';

View file

@ -1,20 +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 * from './np_ready/public/index';

View file

@ -1,20 +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 * from './np_ready/public/legacy';

View file

@ -1,20 +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 * from './np_ready/public/mocks';

View file

@ -1,9 +0,0 @@
{
"id": "expressions",
"version": "kibana",
"server": false,
"ui": true,
"requiredPlugins": [
"inspector"
]
}

View file

@ -1 +0,0 @@
@import './expression_renderer';

View file

@ -1,29 +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 { PluginInitializerContext } from '../../../../../../core/public';
import { ExpressionsPublicPlugin } from './plugin';
export * from './plugin';
export { ExpressionRenderer, ExpressionRendererProps } from './expression_renderer';
export { IInterpreterRenderFunction, IInterpreterRenderHandlers } from './types';
export function plugin(initializerContext: PluginInitializerContext) {
return new ExpressionsPublicPlugin(initializerContext);
}

View file

@ -1,33 +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.
*/
/* eslint-disable */
import { npSetup, npStart } from 'ui/new_platform';
/* eslint-enable */
import { plugin } from '.';
const expressionsPlugin = plugin({} as any);
export const setup = expressionsPlugin.setup(npSetup.core, {
inspector: npSetup.plugins.inspector,
});
export const start = expressionsPlugin.start(npStart.core, {
inspector: npStart.plugins.inspector,
});

View file

@ -1,95 +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.
*/
/* eslint-disable */
import { npSetup } from 'ui/new_platform';
/* eslint-enable */
import { ExpressionsSetup } from '../../../../../../plugins/expressions/public';
import {
CoreSetup,
CoreStart,
Plugin,
PluginInitializerContext,
} from '../../../../../../core/public';
import {
Start as InspectorStart,
Setup as InspectorSetup,
} from '../../../../../../plugins/inspector/public';
import { ExpressionInterpreter } from './types';
import { setInterpreter, setInspector, setRenderersRegistry } from './services';
import { ExpressionRendererImplementation } from './expression_renderer';
import { ExpressionLoader, loader } from './loader';
import { ExpressionDataHandler, execute } from './execute';
import { ExpressionRenderHandler, render } from './render';
export interface ExpressionsSetupDeps {
inspector: InspectorSetup;
}
export interface ExpressionsStartDeps {
inspector: InspectorStart;
}
export { ExpressionsSetup };
export type ExpressionsStart = ReturnType<ExpressionsPublicPlugin['start']>;
export class ExpressionsPublicPlugin
implements
Plugin<ExpressionsSetup, ExpressionsStart, ExpressionsSetupDeps, ExpressionsStartDeps> {
constructor(initializerContext: PluginInitializerContext) {}
public setup(core: CoreSetup, plugins: ExpressionsSetupDeps): ExpressionsSetup {
setRenderersRegistry(npSetup.plugins.expressions.__LEGACY.renderers);
// eslint-disable-next-line
const { getInterpreter } = require('../../../../interpreter/public/interpreter');
getInterpreter()
.then(({ interpreter }: { interpreter: ExpressionInterpreter }) => {
setInterpreter(interpreter);
})
.catch((e: Error) => {
throw new Error('interpreter is not initialized');
});
return {
registerType: npSetup.plugins.expressions.registerType,
registerFunction: npSetup.plugins.expressions.registerFunction,
registerRenderer: npSetup.plugins.expressions.registerRenderer,
__LEGACY: npSetup.plugins.expressions.__LEGACY,
};
}
public start(core: CoreStart, { inspector }: ExpressionsStartDeps) {
setInspector(inspector);
return {
execute,
render,
loader,
ExpressionRenderer: ExpressionRendererImplementation,
ExpressionDataHandler,
ExpressionRenderHandler,
ExpressionLoader,
};
}
public stop() {}
}

View file

@ -1,31 +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 { ExpressionInterpreter } from './types';
import { createGetterSetter } from '../../../../../../plugins/kibana_utils/public';
import { Start as IInspector } from '../../../../../../plugins/inspector/public';
import { ExpressionsSetup } from './plugin';
export const [getInspector, setInspector] = createGetterSetter<IInspector>('Inspector');
export const [getInterpreter, setInterpreter] = createGetterSetter<ExpressionInterpreter>(
'Interpreter'
);
export const [getRenderersRegistry, setRenderersRegistry] = createGetterSetter<
ExpressionsSetup['__LEGACY']['renderers']
>('Renderers registry');

View file

@ -1,20 +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 * from './np_ready/public/plugin';

View file

@ -1,18 +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.
*/

View file

@ -18,7 +18,9 @@
*/
jest.mock('ui/new_platform');
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
import { inputControlVis } from './input_control_fn';
describe('interpreter/functions#input_control_vis', () => {

View file

@ -0,0 +1,22 @@
Interpreter legacy plugin has been migrated to the New Platform. Use
`expressions` New Platform plugin instead.
In the New Platform:
```ts
class MyPlugin {
setup(core, { expressions }) {
expressions.registerFunction(myFunction);
}
start(core, { expressions }) {
}
}
```
In the Legacy Platform:
```ts
import { npSetup, npStart } from 'ui/new_platform';
npSetup.plugins.expressions.registerFunction(myFunction);
```

View file

@ -1,43 +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 {
getType,
interpreterProvider,
serializeProvider,
Datatable,
DatatableColumn,
DatatableRow,
DatatableColumnType,
ExpressionImage,
Filter,
InterpreterErrorType,
isDatatable,
KibanaContext,
KibanaDatatable,
PointSeries,
PointSeriesColumns,
PointSeriesColumn,
PointSeriesColumnName,
Render,
ExpressionTypeStyle,
Style,
Type,
} from '../../../../plugins/expressions/public';
export const API_ROUTE = '/api/interpreter';

View file

@ -31,6 +31,7 @@ export default function InterpreterPlugin(kibana: any) {
injectDefaultVars: server => ({
serverBasePath: server.config().get('server.basePath'),
}),
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
},
config: (Joi: any) => {
return Joi.object({

View file

@ -25,9 +25,7 @@ import { register, registryFactory, Registry, Fn } from '@kbn/interpreter/common
// @ts-ignore
import { routes } from './server/routes';
import { typeSpecs as types } from '../../../plugins/expressions/public';
import { Type } from './common';
import { typeSpecs as types, Type } from '../../../plugins/expressions/common';
import { Legacy } from '../../../../kibana';
export class TypesRegistry extends Registry<any, any> {

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/functions/clog';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/functions/font';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/functions/kibana';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/visualizations/public/expression_functions/range';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/visualizations/public/expression_functions/vis_dimension';

View file

@ -0,0 +1,4 @@
// Import the EUI global scope so we can use EUI constants
@import 'src/legacy/ui/public/styles/_styling_constants';
@import '../../../../plugins/expressions/public/index';

View file

@ -22,13 +22,10 @@ import 'uiExports/interpreter';
import { register, registryFactory } from '@kbn/interpreter/common';
import { npSetup } from 'ui/new_platform';
import { registries } from './registries';
import { visualization } from './renderers/visualization';
import {
ExpressionInterpretWithHandlers,
ExpressionExecutor,
} from '../../../../plugins/expressions/public';
import { esaggs as esaggsFn } from './functions/esaggs';
import { visualization as visualizationFn } from './functions/visualization';
// Expose kbnInterpreter.register(specs) and kbnInterpreter.registries() globally so that plugins
// can register without a transpile step.
@ -38,13 +35,6 @@ import { visualization as visualizationFn } from './functions/visualization';
registryFactory(registries)
);
// TODO: This needs to be moved to `data` plugin Search service.
registries.browserFunctions.register(esaggsFn);
// TODO: This needs to be moved to `visualizations` plugin.
registries.browserFunctions.register(visualizationFn);
registries.renderers.register(visualization);
// TODO: This function will be left behind in the legacy platform.
let executorPromise: Promise<ExpressionExecutor> | undefined;
export const getInterpreter = async () => {

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../../plugins/expressions/public/create_handlers';

View file

@ -1,26 +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.
*/
/* eslint-disable */
export * from '../../../../../plugins/expressions/public/types/style';
export {
FontLabel as FontFamily,
FontValue,
} from '../../../../../plugins/expressions/public/fonts';
/* eslint-enable */

View file

@ -19,9 +19,11 @@
import Boom from 'boom';
import Joi from 'joi';
import { serializeProvider, API_ROUTE } from '../../common';
import { serializeProvider } from '../../../../../plugins/expressions/common';
import { createHandlers } from '../lib/create_handlers';
const API_ROUTE = '/api/interpreter';
/**
* Register the Canvas function endopints.
*

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../plugins/expressions/public/functions/tests/utils';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../plugins/expressions/public/types/arguments';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../plugins/expressions/public/types/common';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../plugins/expressions/public/types/functions';

View file

@ -1,20 +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 * from '../../../../plugins/expressions/public';

View file

@ -1,21 +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.
*/
// eslint-disable-next-line
export * from '../../../../plugins/expressions/public/types';

View file

@ -17,7 +17,8 @@
* under the License.
*/
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
import { kibanaPie } from './pie_fn';
jest.mock('ui/new_platform');

View file

@ -43,6 +43,7 @@ import 'uiExports/embeddableActions';
import 'uiExports/inspectorViews';
import 'uiExports/search';
import 'uiExports/shareContextMenuExtensions';
import 'uiExports/interpreter';
import 'ui/autoload/all';
import 'ui/kbn_top_nav';

View file

@ -30,8 +30,7 @@ import { queryGeohashBounds } from 'ui/visualize/loader/utils';
import { getTableAggs } from 'ui/visualize/loader/pipeline_helpers/utilities';
import { AppState } from 'ui/state_management/app_state';
import { npStart } from 'ui/new_platform';
import { IExpressionLoaderParams } from '../../../../expressions/public/np_ready/public/types';
import { start as expressions } from '../../../../expressions/public/legacy';
import { IExpressionLoaderParams } from 'src/plugins/expressions/public';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
import {
TimeRange,
@ -87,7 +86,7 @@ export interface VisualizeOutput extends EmbeddableOutput {
visTypeName: string;
}
type ExpressionLoader = InstanceType<typeof expressions.ExpressionLoader>;
type ExpressionLoader = InstanceType<typeof npStart.plugins.expressions.ExpressionLoader>;
export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOutput> {
private handler?: ExpressionLoader;
@ -289,7 +288,7 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
domNode.appendChild(div);
this.domNode = div;
this.handler = new expressions.ExpressionLoader(this.domNode);
this.handler = new npStart.plugins.expressions.ExpressionLoader(this.domNode);
this.subscriptions.push(
this.handler.events$.subscribe(async event => {

View file

@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const regionMapPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'region_map',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
hacks: [resolve(__dirname, 'public/legacy')],

View file

@ -17,7 +17,8 @@
* under the License.
*/
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
import { createRegionMapFn } from './region_map_fn';
jest.mock('ui/new_platform');

View file

@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const tileMapPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'tile_map',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -17,7 +17,8 @@
* under the License.
*/
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
import { createTileMapFn } from './tile_map_fn';
jest.mock('ui/new_platform');

View file

@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const markdownPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'markdown_vis',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -17,8 +17,8 @@
* under the License.
*/
// @ts-ignore
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
import { createMarkdownVisFn } from './markdown_fn';
describe('interpreter/functions#markdown', () => {

View file

@ -18,7 +18,7 @@
*/
import { i18n } from '@kbn/i18n';
import { ExpressionFunction, Render } from '../../interpreter/types';
import { ExpressionFunction, Render } from '../../../../plugins/expressions/public';
import { Arguments, MarkdownVisParams } from './types';
const name = 'markdownVis';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { Style } from '../../interpreter/public/types';
import { Style } from 'src/plugins/expressions/public';
export interface Arguments {
markdown: string;

View file

@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const metricPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'metric_vis',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -19,8 +19,8 @@
import { createMetricVisFn } from './metric_vis_fn';
// @ts-ignore
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
jest.mock('ui/new_platform');

View file

@ -20,7 +20,13 @@
import { i18n } from '@kbn/i18n';
import { vislibColorMaps, ColorSchemas } from 'ui/vislib/components/color/colormaps';
import { ExpressionFunction, KibanaDatatable, Range, Render, Style } from '../../interpreter/types';
import {
ExpressionFunction,
KibanaDatatable,
Range,
Render,
Style,
} from '../../../../plugins/expressions/public';
import { ColorModes } from '../../kbn_vislib_vis_types/public/utils/collections';
import { visType, DimensionsVisParam, VisParams } from './types';

View file

@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const tableVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'table_vis',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -19,8 +19,8 @@
import { createTableVisFn } from './table_vis_fn';
// @ts-ignore
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
jest.mock('ui/new_platform');

View file

@ -20,7 +20,11 @@
import { i18n } from '@kbn/i18n';
import { tableVisResponseHandler } from './table_vis_request_handler';
import { ExpressionFunction, KibanaDatatable, Render } from '../../interpreter/types';
import {
ExpressionFunction,
KibanaDatatable,
Render,
} from '../../../../plugins/expressions/public';
const name = 'kibana_table';

View file

@ -25,7 +25,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const tagCloudPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'tagcloud',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -19,8 +19,8 @@
import { createTagCloudFn } from './tag_cloud_fn';
// @ts-ignore
import { functionWrapper } from '../../interpreter/test_helpers';
// eslint-disable-next-line
import { functionWrapper } from '../../../../plugins/expressions/public/functions/tests/utils';
describe('interpreter/functions#tagcloud', () => {
const fn = functionWrapper(createTagCloudFn);

View file

@ -19,7 +19,11 @@
import { i18n } from '@kbn/i18n';
import { ExpressionFunction, KibanaDatatable, Render } from '../../interpreter/types';
import {
ExpressionFunction,
KibanaDatatable,
Render,
} from '../../../../plugins/expressions/public';
import { TagCloudVisParams } from './types';
const name = 'tagcloud';

View file

@ -30,7 +30,7 @@ import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy
const metricsPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'metrics',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n';
import { PersistedState } from 'ui/persisted_state';
import chrome from 'ui/chrome';
import { ExpressionFunction, KibanaContext, Render } from '../../interpreter/types';
import { ExpressionFunction, KibanaContext, Render } from '../../../../plugins/expressions/public';
// @ts-ignore
import { createMetricsRequestHandler } from './request_handler';

View file

@ -28,7 +28,7 @@ const vegaPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlugin
// It is required to change the configuration property
// vega.enableExternalUrls -> vis_type_vega.enableExternalUrls
id: 'vega',
require: ['kibana', 'elasticsearch', 'interpreter', 'expressions'],
require: ['kibana', 'elasticsearch'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
styleSheetPaths: resolve(__dirname, 'public/index.scss'),

View file

@ -20,7 +20,7 @@
import { get } from 'lodash';
import { i18n } from '@kbn/i18n';
import { ExpressionFunction, KibanaContext, Render } from '../../interpreter/types';
import { ExpressionFunction, KibanaContext, Render } from '../../../../plugins/expressions/public';
import { VegaVisualizationDependencies } from './plugin';
import { createVegaRequestHandler } from './vega_request_handler';

View file

@ -18,25 +18,17 @@
*/
import { resolve } from 'path';
import { Legacy } from '../../../../kibana';
import { LegacyPluginInitializer } from '../../../../src/legacy/types';
export const visualizations: LegacyPluginInitializer = kibana =>
new kibana.Plugin({
id: 'visualizations',
publicDir: resolve(__dirname, 'public'),
require: [],
uiExports: {
interpreter: ['plugins/visualizations/expressions/boot'],
},
});
// eslint-disable-next-line import/no-default-export
export default function DataExpressionsPlugin(kibana: any) {
const config: Legacy.PluginSpecOptions = {
id: 'expressions',
require: ['elasticsearch'],
publicDir: resolve(__dirname, 'public'),
config: (Joi: any) => {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
init: (server: Legacy.Server) => ({}),
uiExports: {
injectDefaultVars: () => ({}),
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
},
};
return new kibana.Plugin(config);
}
export default visualizations;

View file

@ -0,0 +1,4 @@
{
"name": "visualizations",
"version": "kibana"
}

View file

@ -17,8 +17,9 @@
* under the License.
*/
import { Adapters } from '../../../../../../plugins/inspector/public';
import { TimeRange, Query } from '../../../../../../plugins/data/public';
import { npSetup } from 'ui/new_platform';
import { visualization as visualizationFunction } from './visualization_function';
import { visualization as visualizationRenderer } from './visualization_renderer';
export { TimeRange, Adapters, Query };
export * from '../../../../../../plugins/expressions/public';
npSetup.plugins.expressions.registerFunction(visualizationFunction);
npSetup.plugins.expressions.registerRenderer(visualizationRenderer);

View file

@ -23,9 +23,9 @@ import chrome from 'ui/chrome';
import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
import { PersistedState } from 'ui/persisted_state';
import { VisResponseValue } from 'src/plugins/visualizations/public';
import { ExpressionFunction, Render } from 'src/plugins/expressions/public';
import { start as data } from '../../../data/public/legacy';
import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
import { ExpressionFunction, Render } from '../../types';
import { start as visualizations } from '../np_ready/public/legacy';
interface Arguments {
index?: string | null;
@ -47,7 +47,7 @@ export type ExpressionFunctionVisualization = ExpressionFunction<
export const visualization = (): ExpressionFunctionVisualization => ({
name: 'visualization',
type: 'render',
help: i18n.translate('interpreter.functions.visualization.help', {
help: i18n.translate('visualizations.functions.visualization.help', {
defaultMessage: 'A simple visualization',
}),
args: {

View file

@ -73,6 +73,7 @@ export interface LegacyPluginOptions {
embeddableActions?: string[];
embeddableFactories?: string[];
uiSettingDefaults?: Record<string, any>;
interpreter: string | string[];
}>;
uiCapabilities?: Capabilities;
publicDir: any;

View file

@ -18,7 +18,7 @@
*/
import { i18n } from '@kbn/i18n';
import { ExpressionType } from '../types';
import { ExpressionType } from '../../common/types';
import { Datatable } from './datatable';
import { Render } from './render';
@ -33,7 +33,7 @@ export const number = (): ExpressionType<typeof name, number> => ({
const value = Number(n);
if (Number.isNaN(value)) {
throw new Error(
i18n.translate('expressions_np.types.number.fromStringConversionErrorMessage', {
i18n.translate('expressions.types.number.fromStringConversionErrorMessage', {
defaultMessage: 'Can\'t typecast "{string}" string to number',
values: {
string: n,

View file

@ -0,0 +1,151 @@
/*
* 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.
*/
/**
* This type contains a unions of all supported font labels, or the the name of
* the font the user would see in a UI.
*/
export type FontLabel = typeof fonts[number]['label'];
/**
* This type contains a union of all supported font values, equivalent to the CSS
* `font-value` property.
*/
export type FontValue = typeof fonts[number]['value'];
/**
* An interface representing a font in Canvas, with a textual label and the CSS
* `font-value`.
*/
export interface Font {
label: FontLabel;
value: FontValue;
}
// This function allows one to create a strongly-typed font for inclusion in
// the font collection. As a result, the values and labels are known to the
// type system, preventing one from specifying a non-existent font at build
// time.
function createFont<
RawFont extends { value: RawFontValue; label: RawFontLabel },
RawFontValue extends string,
RawFontLabel extends string
>(font: RawFont) {
return font;
}
export const americanTypewriter = createFont({
label: 'American Typewriter',
value: "'American Typewriter', 'Courier New', Courier, Monaco, mono",
});
export const arial = createFont({ label: 'Arial', value: 'Arial, sans-serif' });
export const baskerville = createFont({
label: 'Baskerville',
value: "Baskerville, Georgia, Garamond, 'Times New Roman', Times, serif",
});
export const bookAntiqua = createFont({
label: 'Book Antiqua',
value: "'Book Antiqua', Georgia, Garamond, 'Times New Roman', Times, serif",
});
export const brushScript = createFont({
label: 'Brush Script',
value: "'Brush Script MT', 'Comic Sans', sans-serif",
});
export const chalkboard = createFont({
label: 'Chalkboard',
value: "Chalkboard, 'Comic Sans', sans-serif",
});
export const didot = createFont({
label: 'Didot',
value: "Didot, Georgia, Garamond, 'Times New Roman', Times, serif",
});
export const futura = createFont({
label: 'Futura',
value: 'Futura, Impact, Helvetica, Arial, sans-serif',
});
export const gillSans = createFont({
label: 'Gill Sans',
value:
"'Gill Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Helvetica, Arial, sans-serif",
});
export const helveticaNeue = createFont({
label: 'Helvetica Neue',
value: "'Helvetica Neue', Helvetica, Arial, sans-serif",
});
export const hoeflerText = createFont({
label: 'Hoefler Text',
value: "'Hoefler Text', Garamond, Georgia, 'Times New Roman', Times, serif",
});
export const lucidaGrande = createFont({
label: 'Lucida Grande',
value: "'Lucida Grande', 'Lucida Sans Unicode', Lucida, Verdana, Helvetica, Arial, sans-serif",
});
export const myriad = createFont({
label: 'Myriad',
value: 'Myriad, Helvetica, Arial, sans-serif',
});
export const openSans = createFont({
label: 'Open Sans',
value: "'Open Sans', Helvetica, Arial, sans-serif",
});
export const optima = createFont({
label: 'Optima',
value: "Optima, 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Helvetica, Arial, sans-serif",
});
export const palatino = createFont({
label: 'Palatino',
value: "Palatino, 'Book Antiqua', Georgia, Garamond, 'Times New Roman', Times, serif",
});
/**
* A collection of supported fonts.
*/
export const fonts = [
americanTypewriter,
arial,
baskerville,
bookAntiqua,
brushScript,
chalkboard,
didot,
futura,
gillSans,
helveticaNeue,
hoeflerText,
lucidaGrande,
myriad,
openSans,
optima,
palatino,
];

View file

@ -17,4 +17,6 @@
* under the License.
*/
export * from '../types';
export * from './type';
export * from './types';
export * from './expression_types';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { getType } from './interpreter';
import { getType } from './type';
describe('getType()', () => {
test('returns "null" string for null or undefined', () => {

View file

@ -17,9 +17,8 @@
* under the License.
*/
import { get } from 'lodash';
import { AnyExpressionType } from './types';
import { ExpressionValue } from './types/types';
import { get, identity } from 'lodash';
import { AnyExpressionType, ExpressionValue } from './types';
export function getType(node: any) {
if (node == null) return 'null';
@ -30,6 +29,22 @@ export function getType(node: any) {
return typeof node;
}
export function serializeProvider(types: any) {
return {
serialize: provider('serialize'),
deserialize: provider('deserialize'),
};
function provider(key: any) {
return (context: any) => {
const type = getType(context);
const typeDef = types[type];
const fn: any = get(typeDef, key) || identity;
return fn(context);
};
}
}
export class Type {
name: string;

View file

@ -17,4 +17,34 @@
* under the License.
*/
export * from './types';
export {
TypeToString,
KnownTypeToString,
TypeString,
UnmappedTypeStrings,
UnwrapPromise,
SerializedFieldFormat,
} from './common';
export * from './style';
export { ArgumentType } from './arguments';
export { ExpressionFunction, AnyExpressionFunction, FunctionHandlers } from './functions';
export type ExpressionArgAST = string | boolean | number | ExpressionAST;
export interface ExpressionFunctionAST {
type: 'function';
function: string;
arguments: {
[key: string]: ExpressionArgAST[];
};
}
export interface ExpressionAST {
type: 'expression';
chain: ExpressionFunctionAST[];
}

View file

@ -1,6 +1,3 @@
// Import the EUI global scope so we can use EUI constants
@import 'src/legacy/ui/public/styles/_styling_constants';
/* Expressions plugin styles */
// Prefix all styles with "exp" to avoid conflicts.
@ -10,4 +7,4 @@
// expChart__legend--small
// expChart__legend-isLoading
@import './np_ready/public/index';
@import './expression_renderer';

View file

@ -17,9 +17,9 @@
* under the License.
*/
import { execute, ExpressionDataHandler } from './execute';
import { fromExpression } from '@kbn/interpreter/common';
import { ExpressionAST } from './types';
import { execute, ExpressionDataHandler } from './execute';
import { ExpressionAST } from '../common/types';
jest.mock('./services', () => ({
getInterpreter: () => {

View file

@ -18,9 +18,10 @@
*/
import { fromExpression, toExpression } from '@kbn/interpreter/common';
import { DataAdapter, RequestAdapter, Adapters } from '../../../../../../plugins/inspector/public';
import { DataAdapter, RequestAdapter, Adapters } from '../../inspector/public';
import { getInterpreter } from './services';
import { ExpressionAST, IExpressionLoaderParams, IInterpreterResult } from './types';
import { IExpressionLoaderParams, IInterpreterResult } from './types';
import { ExpressionAST } from '../common/types';
/**
* The search context describes a specific context (filters, time range and query)

Some files were not shown because too many files have changed in this diff Show more