diff --git a/src/legacy/core_plugins/data/public/expressions/index.ts b/src/legacy/core_plugins/data/public/expressions/index.ts index ae51804a85fb5..707bcd3cd883e 100644 --- a/src/legacy/core_plugins/data/public/expressions/index.ts +++ b/src/legacy/core_plugins/data/public/expressions/index.ts @@ -19,3 +19,4 @@ export { ExpressionsService, ExpressionsSetup, ExpressionsStart } from './expressions_service'; export { ExpressionRenderer, ExpressionRendererProps } from './expression_renderer'; +export { IInterpreterRenderFunction } from './lib/_types'; diff --git a/src/legacy/core_plugins/expressions/public/index.ts b/src/legacy/core_plugins/expressions/public/index.ts new file mode 100644 index 0000000000000..6c6e72fb2aa5a --- /dev/null +++ b/src/legacy/core_plugins/expressions/public/index.ts @@ -0,0 +1,30 @@ +/* + * 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. + */ + +// /// Define plugin function +import { ExpressionsPlugin as Plugin } from './plugin'; + +export function plugin() { + return new Plugin(); +} + +// /// Export types & static code + +/** @public types */ +export * from './expressions'; diff --git a/src/legacy/core_plugins/expressions/public/mocks.ts b/src/legacy/core_plugins/expressions/public/mocks.ts new file mode 100644 index 0000000000000..42ec5bfb5ba65 --- /dev/null +++ b/src/legacy/core_plugins/expressions/public/mocks.ts @@ -0,0 +1,37 @@ +/* + * 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 { ExpressionsSetup, ExpressionsStart } from '.'; + +function createExpressionsSetupMock() { + const mock: MockedKeys> = {}; + + return mock; +} + +function createExpressionsStartMock() { + const mock: MockedKeys> = {}; + + return mock; +} + +export const expressionsPluginMock = { + createSetup: createExpressionsSetupMock, + createStart: createExpressionsStartMock, +}; diff --git a/src/legacy/core_plugins/expressions/public/plugin.ts b/src/legacy/core_plugins/expressions/public/plugin.ts new file mode 100644 index 0000000000000..b954238c05e59 --- /dev/null +++ b/src/legacy/core_plugins/expressions/public/plugin.ts @@ -0,0 +1,72 @@ +/* + * 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 { CoreSetup, CoreStart, Plugin } from '../../../../core/public'; +import { ExpressionsService, ExpressionsSetup, ExpressionsStart } from './expressions'; +import { + Start as InspectorStart, + Setup as InspectorSetup, +} from '../../../../plugins/inspector/public'; + +/** + * Interface for any dependencies on other plugins' `setup` contracts. + * + * @internal + */ +export interface ExpressionsPluginSetupDependencies { + inspector: InspectorSetup; +} + +export interface ExpressionsPluginStartDependencies { + inspector: InspectorStart; +} + +/** + * Interface for this plugin's returned `setup` contract. + * + * @public + */ + +export class ExpressionsPlugin + implements + Plugin< + ExpressionsSetup, + ExpressionsStart, + ExpressionsPluginSetupDependencies, + ExpressionsPluginStartDependencies + > { + // Exposed services, sorted alphabetically + private readonly expressions: ExpressionsService = new ExpressionsService(); + + public setup(core: CoreSetup): ExpressionsSetup { + return { + ...this.expressions.setup(), + }; + } + + public start(core: CoreStart, plugins: ExpressionsPluginStartDependencies): ExpressionsStart { + return { + ...this.expressions.start({ inspector: plugins.inspector }), + }; + } + + public stop() { + this.expressions.stop(); + } +}