) {
+ this.factory = factory;
+ }
+
+ start(
+ coreSetup: CoreSetup,
+ coreStart: CoreStart,
+ canvasSetupPlugins: CanvasSetupDeps,
+ canvasStartPlugins: CanvasStartDeps
+ ) {
+ this.service = this.factory(coreSetup, coreStart, canvasSetupPlugins, canvasStartPlugins);
+ }
+
+ getService(): Service {
+ if (!this.service) {
+ throw new Error('Service not ready');
+ }
+
+ return this.service;
+ }
+
+ stop() {
+ this.service = undefined;
+ }
+}
+
+export type ServiceFromProvider = P extends CanvasServiceProvider ? T : never;
+
+export const services = {
+ notify: new CanvasServiceProvider(notifyServiceFactory),
+};
+
+export interface CanvasServices {
+ notify: ServiceFromProvider;
+}
+
+export const startServices = (
+ coreSetup: CoreSetup,
+ coreStart: CoreStart,
+ canvasSetupPlugins: CanvasSetupDeps,
+ canvasStartPlugins: CanvasStartDeps
+) => {
+ Object.entries(services).forEach(([key, provider]) =>
+ provider.start(coreSetup, coreStart, canvasSetupPlugins, canvasStartPlugins)
+ );
+};
+
+export const stopServices = () => {
+ Object.entries(services).forEach(([key, provider]) => provider.stop());
+};
+
+export const { notify: notifyService } = services;
diff --git a/x-pack/legacy/plugins/canvas/public/services/notify.ts b/x-pack/legacy/plugins/canvas/public/services/notify.ts
new file mode 100644
index 0000000000000..3e18e2178a818
--- /dev/null
+++ b/x-pack/legacy/plugins/canvas/public/services/notify.ts
@@ -0,0 +1,57 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+import { get } from 'lodash';
+import { CanvasServiceFactory } from '.';
+import { formatMsg } from '../../../../../../src/plugins/kibana_legacy/public';
+import { ToastInputFields } from '../../../../../../src/core/public';
+
+const getToast = (err: Error | string, opts: ToastInputFields = {}) => {
+ const errData = (get(err, 'response') || err) as Error | string;
+ const errMsg = formatMsg(errData);
+ const { title, ...rest } = opts;
+ let text;
+
+ if (title) {
+ text = errMsg;
+ }
+
+ return {
+ ...rest,
+ title: title || errMsg,
+ text,
+ };
+};
+
+interface NotifyService {
+ error: (err: string | Error, opts?: ToastInputFields) => void;
+ warning: (err: string | Error, opts?: ToastInputFields) => void;
+ info: (err: string | Error, opts?: ToastInputFields) => void;
+ success: (err: string | Error, opts?: ToastInputFields) => void;
+}
+
+export const notifyServiceFactory: CanvasServiceFactory = (setup, start) => {
+ const toasts = start.notifications.toasts;
+
+ return {
+ /*
+ * @param {(string | Object)} err: message or Error object
+ * @param {Object} opts: option to override toast title or icon, see https://github.com/elastic/kibana/blob/master/src/legacy/ui/public/notify/toasts/TOAST_NOTIFICATIONS.md
+ */
+ error(err, opts) {
+ toasts.addDanger(getToast(err, opts));
+ },
+ warning(err, opts) {
+ toasts.addWarning(getToast(err, opts));
+ },
+ info(err, opts) {
+ toasts.add(getToast(err, opts));
+ },
+ success(err, opts) {
+ toasts.addSuccess(getToast(err, opts));
+ },
+ };
+};
diff --git a/x-pack/legacy/plugins/canvas/public/state/actions/elements.js b/x-pack/legacy/plugins/canvas/public/state/actions/elements.js
index 1798aaab22f06..f4a3393b8962d 100644
--- a/x-pack/legacy/plugins/canvas/public/state/actions/elements.js
+++ b/x-pack/legacy/plugins/canvas/public/state/actions/elements.js
@@ -13,9 +13,9 @@ import { getPages, getNodeById, getNodes, getSelectedPageIndex } from '../select
import { getValue as getResolvedArgsValue } from '../selectors/resolved_args';
import { getDefaultElement } from '../defaults';
import { ErrorStrings } from '../../../i18n';
-import { notify } from '../../lib/notify';
import { runInterpreter, interpretAst } from '../../lib/run_interpreter';
import { subMultitree } from '../../lib/aeroelastic/functional';
+import { services } from '../../services';
import { selectToplevelNodes } from './transient';
import * as args from './resolved_args';
@@ -134,7 +134,7 @@ const fetchRenderableWithContextFn = ({ dispatch }, element, ast, context) => {
dispatch(getAction(renderable));
})
.catch(err => {
- notify.error(err);
+ services.notify.getService().error(err);
dispatch(getAction(err));
});
};
@@ -176,7 +176,7 @@ export const fetchAllRenderables = createThunk(
return runInterpreter(ast, null, { castToRender: true })
.then(renderable => ({ path: argumentPath, value: renderable }))
.catch(err => {
- notify.error(err);
+ services.notify.getService().error(err);
return { path: argumentPath, value: err };
});
});
@@ -293,7 +293,7 @@ const setAst = createThunk('setAst', ({ dispatch }, ast, element, pageId, doRend
const expression = toExpression(ast);
dispatch(setExpression(expression, element.id, pageId, doRender));
} catch (err) {
- notify.error(err);
+ services.notify.getService().error(err);
// TODO: remove this, may have been added just to cause a re-render, but why?
dispatch(setExpression(element.expression, element.id, pageId, doRender));
diff --git a/x-pack/legacy/plugins/canvas/public/state/middleware/es_persist.js b/x-pack/legacy/plugins/canvas/public/state/middleware/es_persist.js
index bcbfc3544981a..a197cdf893244 100644
--- a/x-pack/legacy/plugins/canvas/public/state/middleware/es_persist.js
+++ b/x-pack/legacy/plugins/canvas/public/state/middleware/es_persist.js
@@ -14,7 +14,7 @@ import { setAssets, resetAssets } from '../actions/assets';
import * as transientActions from '../actions/transient';
import * as resolvedArgsActions from '../actions/resolved_args';
import { update, updateAssets, updateWorkpad } from '../../lib/workpad_service';
-import { notify } from '../../lib/notify';
+import { services } from '../../services';
import { canUserWrite } from '../selectors/app';
const { esPersist: strings } = ErrorStrings;
@@ -62,15 +62,15 @@ export const esPersistMiddleware = ({ getState }) => {
const statusCode = err.response && err.response.status;
switch (statusCode) {
case 400:
- return notify.error(err.response, {
+ return services.notify.getService().error(err.response, {
title: strings.getSaveFailureTitle(),
});
case 413:
- return notify.error(strings.getTooLargeErrorMessage(), {
+ return services.notify.getService().error(strings.getTooLargeErrorMessage(), {
title: strings.getSaveFailureTitle(),
});
default:
- return notify.error(err, {
+ return services.notify.getService().error(err, {
title: strings.getUpdateFailureTitle(),
});
}
diff --git a/x-pack/legacy/plugins/canvas/public/state/selectors/workpad.ts b/x-pack/legacy/plugins/canvas/public/state/selectors/workpad.ts
index 84fab0cb0ae6d..1623035bd25ba 100644
--- a/x-pack/legacy/plugins/canvas/public/state/selectors/workpad.ts
+++ b/x-pack/legacy/plugins/canvas/public/state/selectors/workpad.ts
@@ -11,7 +11,12 @@ import { safeElementFromExpression, fromExpression } from '@kbn/interpreter/comm
import { append } from '../../lib/modify_path';
import { getAssets } from './assets';
import { State, CanvasWorkpad, CanvasPage, CanvasElement, ResolvedArgType } from '../../../types';
-import { ExpressionContext, CanvasGroup, PositionedElement } from '../../../types';
+import {
+ ExpressionContext,
+ CanvasGroup,
+ PositionedElement,
+ CanvasWorkpadBoundingBox,
+} from '../../../types';
import {
ExpressionAstArgument,
ExpressionAstFunction,
@@ -91,7 +96,7 @@ export function getWorkpadWidth(state: State): number {
return get(state, append(workpadRoot, 'width'));
}
-export function getWorkpadBoundingBox(state: State) {
+export function getWorkpadBoundingBox(state: State): CanvasWorkpadBoundingBox {
return getPages(state).reduce(
(boundingBox, page) => {
page.elements.forEach(({ position }) => {
diff --git a/x-pack/legacy/plugins/canvas/public/style/index.scss b/x-pack/legacy/plugins/canvas/public/style/index.scss
index 56f9ed8d18cbe..ba0845862368a 100644
--- a/x-pack/legacy/plugins/canvas/public/style/index.scss
+++ b/x-pack/legacy/plugins/canvas/public/style/index.scss
@@ -52,7 +52,8 @@
@import '../components/tooltip_annotation/tooltip_annotation';
@import '../components/workpad/workpad';
@import '../components/workpad_header/control_settings/control_settings';
-@import '../components/workpad_header/workpad_export/workpad_export';
+@import '../components/workpad_header/element_menu/element_menu';
+@import '../components/workpad_header/share_menu/share_menu';
@import '../components/workpad_loader/workpad_loader';
@import '../components/workpad_loader/workpad_dropzone/workpad_dropzone';
@import '../components/workpad_page/workpad_page';
diff --git a/x-pack/legacy/plugins/canvas/shareable_runtime/api/index.ts b/x-pack/legacy/plugins/canvas/shareable_runtime/api/index.ts
index b05379df6b0b1..0780ab46cd873 100644
--- a/x-pack/legacy/plugins/canvas/shareable_runtime/api/index.ts
+++ b/x-pack/legacy/plugins/canvas/shareable_runtime/api/index.ts
@@ -4,7 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import 'core-js/stable';
+import 'regenerator-runtime/runtime';
import 'whatwg-fetch';
-import 'babel-polyfill';
export * from './shareable';
diff --git a/x-pack/legacy/plugins/canvas/shareable_runtime/test/workpads/austin.json b/x-pack/legacy/plugins/canvas/shareable_runtime/test/workpads/austin.json
index f9f999440c7ce..b725afab2b10f 100644
--- a/x-pack/legacy/plugins/canvas/shareable_runtime/test/workpads/austin.json
+++ b/x-pack/legacy/plugins/canvas/shareable_runtime/test/workpads/austin.json
@@ -28878,7 +28878,7 @@
"type": "render",
"as": "markdown",
"value": {
- "content": "```\nexport const githubLimitGauge = () => ({\n name: 'githubLimitGauge',\n displayName: 'Github Limit Gauge',\n help: 'A progress pill displaying...',\n image: header,\n expression: `github_rate_limit \n | filterrows fn={getCell name | eq core} \n | if \n condition={math limit | eq 0} \n then=0 \n else={math \"remaining / limit\"}\n | progress \n label=\"Core\"\n shape=\"horizontalPill\" \n | render\n `,\n };\n}\n```",
+ "content": "```\nexport const githubLimitGauge = () => ({\n name: 'githubLimitGauge',\n displayName: 'Github Limit Gauge',\n help: 'A progress pill displaying...',\n expression: `github_rate_limit \n | filterrows fn={getCell name | eq core} \n | if \n condition={math limit | eq 0} \n then=0 \n else={math \"remaining / limit\"}\n | progress \n label=\"Core\"\n shape=\"horizontalPill\" \n | render\n `,\n };\n}\n```",
"font": {
"type": "style",
"spec": {
@@ -28919,7 +28919,7 @@
"type": "render",
"as": "markdown",
"value": {
- "content": "```\nexport function randomNumber() {\n return {\n name: 'randomNumber',\n displayName: 'Random Number',\n help: 'A random number between 0 and 1.',\n image: header,\n expression: \n 'random \n | math \"round(value, 3)\" \n | metric \"Random Number\"\n ',\n };\n}\n```",
+ "content": "```\nexport function randomNumber() {\n return {\n name: 'randomNumber',\n displayName: 'Random Number',\n help: 'A random number between 0 and 1.',\n expression: \n 'random \n | math \"round(value, 3)\" \n | metric \"Random Number\"\n ',\n };\n}\n```",
"font": {
"type": "style",
"spec": {
diff --git a/x-pack/legacy/plugins/canvas/tasks/mocks/customElementService.js b/x-pack/legacy/plugins/canvas/tasks/mocks/customElementService.js
new file mode 100644
index 0000000000000..3162638cb6c5d
--- /dev/null
+++ b/x-pack/legacy/plugins/canvas/tasks/mocks/customElementService.js
@@ -0,0 +1,43 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License;
+ * you may not use this file except in compliance with the Elastic License.
+ */
+
+export const testCustomElements = [
+ {
+ id: 'custom-element-10d625f5-1342-47c9-8f19-d174ea6b65d5',
+ name: 'customElement1',
+ displayName: 'Custom Element 1',
+ help: 'sample description',
+ image: '',
+ content: `{\"selectedNodes\":[{\"id\":\"element-3383b40a-de5d-4efb-8719-f4d8cffbfa74\",\"position\":{\"left\":142,\"top\":146,\"width\":700,\"height\":300,\"angle\":0,\"parent\":null,\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| pointseries x=\\\"project\\\" y=\\\"sum(price)\\\" color=\\\"state\\\" size=\\\"size(username)\\\"\\n| plot defaultStyle={seriesStyle points=5 fill=1}\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"pointseries\",\"arguments\":{\"x\":[\"project\"],\"y\":[\"sum(price)\"],\"color\":[\"state\"],\"size\":[\"size(username)\"]}},{\"type\":\"function\",\"function\":\"plot\",\"arguments\":{\"defaultStyle\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"seriesStyle\",\"arguments\":{\"points\":[5],\"fill\":[1]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}}]}`,
+ },
+ {
+ id: 'custom-element-b22d8d10-6116-46fb-9b46-c3f3340d3aaa',
+ name: 'customElement2',
+ displayName: 'Custom Element 2',
+ help: 'Aenean eu justo auctor, placerat felis non, scelerisque dolor. ',
+ image: '',
+ content: `{\"selectedNodes\":[{\"id\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"position\":{\"left\":250,\"top\":119,\"width\":340,\"height\":517,\"angle\":0,\"parent\":null,\"type\":\"group\"},\"expression\":\"shape fill=\\\"rgba(255,255,255,0)\\\" | render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"shape\",\"arguments\":{\"fill\":[\"rgba(255,255,255,0)\"]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}},{\"id\":\"element-e2c658ee-7614-4d92-a46e-2b1a81a24485\",\"position\":{\"left\":250,\"top\":405,\"width\":340,\"height\":75,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| markdown \\\"## Jane Doe\\\" \\n font={font family=\\\"'Open Sans', Helvetica, Arial, sans-serif\\\" size=14 align=\\\"center\\\" color=\\\"#000000\\\" weight=\\\"normal\\\" underline=false italic=false}\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"markdown\",\"arguments\":{\"_\":[\"## Jane Doe\"],\"font\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"font\",\"arguments\":{\"family\":[\"'Open Sans', Helvetica, Arial, sans-serif\"],\"size\":[14],\"align\":[\"center\"],\"color\":[\"#000000\"],\"weight\":[\"normal\"],\"underline\":[false],\"italic\":[false]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}},{\"id\":\"element-3d16765e-5251-4954-8e2a-6c64ed465b73\",\"position\":{\"left\":250,\"top\":480,\"width\":340,\"height\":75,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| markdown \\\"### Developer\\\" \\n font={font family=\\\"'Open Sans', Helvetica, Arial, sans-serif\\\" size=14 align=\\\"center\\\" color=\\\"#000000\\\" weight=\\\"normal\\\" underline=false italic=false}\\n| render css=\\\".canvasRenderEl h3 {\\ncolor: #444444;\\n}\\\"\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"markdown\",\"arguments\":{\"_\":[\"### Developer\"],\"font\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"font\",\"arguments\":{\"family\":[\"'Open Sans', Helvetica, Arial, sans-serif\"],\"size\":[14],\"align\":[\"center\"],\"color\":[\"#000000\"],\"weight\":[\"normal\"],\"underline\":[false],\"italic\":[false]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{\"css\":[\".canvasRenderEl h3 {\\ncolor: #444444;\\n}\"]}}]}},{\"id\":\"element-624675cf-46e9-4545-b86a-5409bbe53ac1\",\"position\":{\"left\":250,\"top\":555,\"width\":340,\"height\":81,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| markdown \\n \\\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel sollicitudin mauris, ut scelerisque urna. \\\" \\n font={font family=\\\"'Open Sans', Helvetica, Arial, sans-serif\\\" size=14 align=\\\"center\\\" color=\\\"#000000\\\" weight=\\\"normal\\\" underline=false italic=false}\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"markdown\",\"arguments\":{\"_\":[\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel sollicitudin mauris, ut scelerisque urna. \"],\"font\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"font\",\"arguments\":{\"family\":[\"'Open Sans', Helvetica, Arial, sans-serif\"],\"size\":[14],\"align\":[\"center\"],\"color\":[\"#000000\"],\"weight\":[\"normal\"],\"underline\":[false],\"italic\":[false]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}},{\"id\":\"element-c2916246-26dd-4c65-91c6-d1ad3f1791ee\",\"position\":{\"left\":293,\"top\":119,\"width\":254,\"height\":252,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"image dataurl={asset \\\"asset-0c6f377f-771e-432e-8e2e-15c3e9142ad6\\\"} mode=\\\"contain\\\"\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"image\",\"arguments\":{\"dataurl\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"asset\",\"arguments\":{\"_\":[\"asset-0c6f377f-771e-432e-8e2e-15c3e9142ad6\"]}}]}],\"mode\":[\"contain\"]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}}]}`,
+ },
+ {
+ id: 'custom-element-',
+ name: 'customElement3',
+ displayName: 'Custom Element 3',
+ help:
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce lobortis aliquet arcu ut turpis duis.',
+ image: '',
+ content: `{\"selectedNodes\":[{\"id\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"position\":{\"left\":250,\"top\":119,\"width\":340,\"height\":517,\"angle\":0,\"parent\":null,\"type\":\"group\"},\"expression\":\"shape fill=\\\"rgba(255,255,255,0)\\\" | render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"shape\",\"arguments\":{\"fill\":[\"rgba(255,255,255,0)\"]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}},{\"id\":\"element-e2c658ee-7614-4d92-a46e-2b1a81a24485\",\"position\":{\"left\":250,\"top\":405,\"width\":340,\"height\":75,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| markdown \\\"## Jane Doe\\\" \\n font={font family=\\\"'Open Sans', Helvetica, Arial, sans-serif\\\" size=14 align=\\\"center\\\" color=\\\"#000000\\\" weight=\\\"normal\\\" underline=false italic=false}\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"markdown\",\"arguments\":{\"_\":[\"## Jane Doe\"],\"font\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"font\",\"arguments\":{\"family\":[\"'Open Sans', Helvetica, Arial, sans-serif\"],\"size\":[14],\"align\":[\"center\"],\"color\":[\"#000000\"],\"weight\":[\"normal\"],\"underline\":[false],\"italic\":[false]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}},{\"id\":\"element-3d16765e-5251-4954-8e2a-6c64ed465b73\",\"position\":{\"left\":250,\"top\":480,\"width\":340,\"height\":75,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| markdown \\\"### Developer\\\" \\n font={font family=\\\"'Open Sans', Helvetica, Arial, sans-serif\\\" size=14 align=\\\"center\\\" color=\\\"#000000\\\" weight=\\\"normal\\\" underline=false italic=false}\\n| render css=\\\".canvasRenderEl h3 {\\ncolor: #444444;\\n}\\\"\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"markdown\",\"arguments\":{\"_\":[\"### Developer\"],\"font\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"font\",\"arguments\":{\"family\":[\"'Open Sans', Helvetica, Arial, sans-serif\"],\"size\":[14],\"align\":[\"center\"],\"color\":[\"#000000\"],\"weight\":[\"normal\"],\"underline\":[false],\"italic\":[false]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{\"css\":[\".canvasRenderEl h3 {\\ncolor: #444444;\\n}\"]}}]}},{\"id\":\"element-624675cf-46e9-4545-b86a-5409bbe53ac1\",\"position\":{\"left\":250,\"top\":555,\"width\":340,\"height\":81,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"filters\\n| demodata\\n| markdown \\n \\\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel sollicitudin mauris, ut scelerisque urna. \\\" \\n font={font family=\\\"'Open Sans', Helvetica, Arial, sans-serif\\\" size=14 align=\\\"center\\\" color=\\\"#000000\\\" weight=\\\"normal\\\" underline=false italic=false}\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"filters\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"demodata\",\"arguments\":{}},{\"type\":\"function\",\"function\":\"markdown\",\"arguments\":{\"_\":[\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel sollicitudin mauris, ut scelerisque urna. \"],\"font\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"font\",\"arguments\":{\"family\":[\"'Open Sans', Helvetica, Arial, sans-serif\"],\"size\":[14],\"align\":[\"center\"],\"color\":[\"#000000\"],\"weight\":[\"normal\"],\"underline\":[false],\"italic\":[false]}}]}]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}},{\"id\":\"element-c2916246-26dd-4c65-91c6-d1ad3f1791ee\",\"position\":{\"left\":293,\"top\":119,\"width\":254,\"height\":252,\"angle\":0,\"parent\":\"group-dccf4ed7-1593-49a0-9902-caf4d4a4b7f5\",\"type\":\"element\"},\"expression\":\"image dataurl={asset \\\"asset-0c6f377f-771e-432e-8e2e-15c3e9142ad6\\\"} mode=\\\"contain\\\"\\n| render\",\"ast\":{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"image\",\"arguments\":{\"dataurl\":[{\"type\":\"expression\",\"chain\":[{\"type\":\"function\",\"function\":\"asset\",\"arguments\":{\"_\":[\"asset-0c6f377f-771e-432e-8e2e-15c3e9142ad6\"]}}]}],\"mode\":[\"contain\"]}},{\"type\":\"function\",\"function\":\"render\",\"arguments\":{}}]}}]}`,
+ },
+];
+
+export const create = () => {};
+
+export const get = () => {};
+
+export const update = () => {};
+
+export const remove = () => {};
+
+export const find = () => {};
diff --git a/x-pack/plugins/transform/public/app/components/pivot_preview/index.ts b/x-pack/legacy/plugins/canvas/tasks/mocks/uiMetric.js
similarity index 83%
rename from x-pack/plugins/transform/public/app/components/pivot_preview/index.ts
rename to x-pack/legacy/plugins/canvas/tasks/mocks/uiMetric.js
index 049e73d6309fc..c7e7088812148 100644
--- a/x-pack/plugins/transform/public/app/components/pivot_preview/index.ts
+++ b/x-pack/legacy/plugins/canvas/tasks/mocks/uiMetric.js
@@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export { PivotPreview } from './pivot_preview';
+export const trackCanvasUiMetric = () => {};
diff --git a/x-pack/legacy/plugins/canvas/types/canvas.ts b/x-pack/legacy/plugins/canvas/types/canvas.ts
index f0137479a0b7f..0250b921aadb6 100644
--- a/x-pack/legacy/plugins/canvas/types/canvas.ts
+++ b/x-pack/legacy/plugins/canvas/types/canvas.ts
@@ -56,3 +56,10 @@ export type CanvasTemplate = CanvasWorkpad & {
help: string;
tags: string[];
};
+
+export interface CanvasWorkpadBoundingBox {
+ left: number;
+ right: number;
+ top: number;
+ bottom: number;
+}
diff --git a/x-pack/legacy/plugins/canvas/types/elements.ts b/x-pack/legacy/plugins/canvas/types/elements.ts
index acb1cb9cd7625..86356f5bd32a9 100644
--- a/x-pack/legacy/plugins/canvas/types/elements.ts
+++ b/x-pack/legacy/plugins/canvas/types/elements.ts
@@ -9,10 +9,10 @@ import { CanvasElement } from '.';
export interface ElementSpec {
name: string;
- image: string;
+ icon?: string;
expression: string;
displayName?: string;
- tags?: string[];
+ type?: string;
help?: string;
filter?: string;
width?: number;
@@ -42,10 +42,6 @@ export interface CustomElement {
* base 64 data URL string of the preview image
*/
image?: string;
- /**
- * tags associated with the element
- */
- tags?: string[];
/**
* the element object stringified
*/
diff --git a/x-pack/legacy/plugins/graph/index.ts b/x-pack/legacy/plugins/graph/index.ts
deleted file mode 100644
index 5c7f8fa46c18b..0000000000000
--- a/x-pack/legacy/plugins/graph/index.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-// @ts-ignore
-import migrations from './migrations';
-import mappings from './mappings.json';
-import { LegacyPluginInitializer } from '../../../../src/legacy/plugin_discovery/types';
-
-export const graph: LegacyPluginInitializer = kibana => {
- return new kibana.Plugin({
- id: 'graph',
- configPrefix: 'xpack.graph',
- require: ['kibana', 'elasticsearch', 'xpack_main'],
- uiExports: {
- mappings,
- migrations,
- },
-
- config(Joi: any) {
- return Joi.object({
- enabled: Joi.boolean().default(true),
- canEditDrillDownUrls: Joi.boolean().default(true),
- savePolicy: Joi.string()
- .valid(['config', 'configAndDataWithConsent', 'configAndData', 'none'])
- .default('configAndData'),
- }).default();
- },
- });
-};
diff --git a/x-pack/legacy/plugins/graph/mappings.json b/x-pack/legacy/plugins/graph/mappings.json
deleted file mode 100644
index f1950c459eee5..0000000000000
--- a/x-pack/legacy/plugins/graph/mappings.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "graph-workspace": {
- "properties": {
- "description": {
- "type": "text"
- },
- "kibanaSavedObjectMeta": {
- "properties": {
- "searchSourceJSON": {
- "type": "text"
- }
- }
- },
- "numLinks": {
- "type": "integer"
- },
- "numVertices": {
- "type": "integer"
- },
- "title": {
- "type": "text"
- },
- "version": {
- "type": "integer"
- },
- "wsState": {
- "type": "text"
- }
- }
- }
-}
diff --git a/x-pack/legacy/plugins/graph/migrations.js b/x-pack/legacy/plugins/graph/migrations.js
deleted file mode 100644
index 0cefe6217b45d..0000000000000
--- a/x-pack/legacy/plugins/graph/migrations.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { get } from 'lodash';
-
-export default {
- 'graph-workspace': {
- '7.0.0': doc => {
- // Set new "references" attribute
- doc.references = doc.references || [];
- // Migrate index pattern
- const wsState = get(doc, 'attributes.wsState');
- if (typeof wsState !== 'string') {
- return doc;
- }
- let state;
- try {
- state = JSON.parse(JSON.parse(wsState));
- } catch (e) {
- // Let it go, the data is invalid and we'll leave it as is
- return doc;
- }
- const { indexPattern } = state;
- if (!indexPattern) {
- return doc;
- }
- state.indexPatternRefName = 'indexPattern_0';
- delete state.indexPattern;
- doc.attributes.wsState = JSON.stringify(JSON.stringify(state));
- doc.references.push({
- name: 'indexPattern_0',
- type: 'index-pattern',
- id: indexPattern,
- });
- return doc;
- },
- },
-};
diff --git a/x-pack/legacy/plugins/graph/migrations.test.js b/x-pack/legacy/plugins/graph/migrations.test.js
deleted file mode 100644
index 93162d94857ce..0000000000000
--- a/x-pack/legacy/plugins/graph/migrations.test.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import migrations from './migrations';
-
-describe('graph-workspace', () => {
- describe('7.0.0', () => {
- const migration = migrations['graph-workspace']['7.0.0'];
-
- test('returns doc on empty object', () => {
- expect(migration({})).toMatchInlineSnapshot(`
-Object {
- "references": Array [],
-}
-`);
- });
-
- test('returns doc when wsState is not a string', () => {
- const doc = {
- id: '1',
- attributes: {
- wsState: true,
- },
- };
- expect(migration(doc)).toMatchInlineSnapshot(`
-Object {
- "attributes": Object {
- "wsState": true,
- },
- "id": "1",
- "references": Array [],
-}
-`);
- });
-
- test('returns doc when wsState is not valid JSON', () => {
- const doc = {
- id: '1',
- attributes: {
- wsState: '123abc',
- },
- };
- expect(migration(doc)).toMatchInlineSnapshot(`
-Object {
- "attributes": Object {
- "wsState": "123abc",
- },
- "id": "1",
- "references": Array [],
-}
-`);
- });
-
- test('returns doc when "indexPattern" is missing from wsState', () => {
- const doc = {
- id: '1',
- attributes: {
- wsState: JSON.stringify(JSON.stringify({ foo: true })),
- },
- };
- expect(migration(doc)).toMatchInlineSnapshot(`
-Object {
- "attributes": Object {
- "wsState": "\\"{\\\\\\"foo\\\\\\":true}\\"",
- },
- "id": "1",
- "references": Array [],
-}
-`);
- });
-
- test('extract "indexPattern" attribute from doc', () => {
- const doc = {
- id: '1',
- attributes: {
- wsState: JSON.stringify(JSON.stringify({ foo: true, indexPattern: 'pattern*' })),
- bar: true,
- },
- };
- const migratedDoc = migration(doc);
- expect(migratedDoc).toMatchInlineSnapshot(`
-Object {
- "attributes": Object {
- "bar": true,
- "wsState": "\\"{\\\\\\"foo\\\\\\":true,\\\\\\"indexPatternRefName\\\\\\":\\\\\\"indexPattern_0\\\\\\"}\\"",
- },
- "id": "1",
- "references": Array [
- Object {
- "id": "pattern*",
- "name": "indexPattern_0",
- "type": "index-pattern",
- },
- ],
-}
-`);
- });
- });
-});
diff --git a/x-pack/legacy/plugins/ingest_manager/index.ts b/x-pack/legacy/plugins/ingest_manager/index.ts
index 47c6478f66471..df9923d9f11ec 100644
--- a/x-pack/legacy/plugins/ingest_manager/index.ts
+++ b/x-pack/legacy/plugins/ingest_manager/index.ts
@@ -4,43 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { resolve } from 'path';
-import {
- savedObjectMappings,
- OUTPUT_SAVED_OBJECT_TYPE,
- AGENT_CONFIG_SAVED_OBJECT_TYPE,
- DATASOURCE_SAVED_OBJECT_TYPE,
- PACKAGES_SAVED_OBJECT_TYPE,
-} from '../../../plugins/ingest_manager/server';
-
-// TODO https://github.com/elastic/kibana/issues/46373
-// const INDEX_NAMES = {
-// INGEST: '.kibana',
-// };
export function ingestManager(kibana: any) {
return new kibana.Plugin({
id: 'ingestManager',
publicDir: resolve(__dirname, '../../../plugins/ingest_manager/public'),
- uiExports: {
- savedObjectSchemas: {
- [AGENT_CONFIG_SAVED_OBJECT_TYPE]: {
- isNamespaceAgnostic: true,
- // indexPattern: INDEX_NAMES.INGEST,
- },
- [OUTPUT_SAVED_OBJECT_TYPE]: {
- isNamespaceAgnostic: true,
- // indexPattern: INDEX_NAMES.INGEST,
- },
- [DATASOURCE_SAVED_OBJECT_TYPE]: {
- isNamespaceAgnostic: true,
- // indexPattern: INDEX_NAMES.INGEST,
- },
- [PACKAGES_SAVED_OBJECT_TYPE]: {
- isNamespaceAgnostic: true,
- // indexPattern: INDEX_NAMES.INGEST,
- },
- },
- mappings: savedObjectMappings,
- },
});
}
diff --git a/x-pack/legacy/plugins/maps/index.js b/x-pack/legacy/plugins/maps/index.js
index 8546e3712c763..d1e8892fa2c98 100644
--- a/x-pack/legacy/plugins/maps/index.js
+++ b/x-pack/legacy/plugins/maps/index.js
@@ -57,7 +57,6 @@ export function maps(kibana) {
tilemap: _.get(mapConfig, 'tilemap', []),
};
},
- embeddableFactories: ['plugins/maps/embeddable/map_embeddable_factory'],
styleSheetPaths: `${__dirname}/public/index.scss`,
savedObjectSchemas: {
'maps-telemetry': {
diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts
deleted file mode 100644
index 90b17412377f5..0000000000000
--- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-/*
- Maintain legacy embeddable legacy present while apps switch over
- */
-
-import { npSetup, npStart } from 'ui/new_platform';
-import {
- bindSetupCoreAndPlugins,
- bindStartCoreAndPlugins,
- // eslint-disable-next-line @kbn/eslint/no-restricted-paths
-} from '../../../../../plugins/maps/public/plugin';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { MAP_SAVED_OBJECT_TYPE } from '../../../../../plugins/maps/common/constants';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { MapEmbeddableFactory } from '../../../../../plugins/maps/public/embeddable';
-
-bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins);
-bindStartCoreAndPlugins(npStart.core, npStart.plugins);
-
-export * from '../../../../../plugins/maps/public/embeddable/map_embeddable_factory';
-
-npSetup.plugins.embeddable.registerEmbeddableFactory(
- MAP_SAVED_OBJECT_TYPE,
- new MapEmbeddableFactory()
-);
diff --git a/x-pack/legacy/plugins/rollup/common/index.ts b/x-pack/legacy/plugins/rollup/common/index.ts
deleted file mode 100644
index 526af055a3ef6..0000000000000
--- a/x-pack/legacy/plugins/rollup/common/index.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { LICENSE_TYPE_BASIC, LicenseType } from '../../../common/constants';
-
-export const PLUGIN = {
- ID: 'rollup',
- MINIMUM_LICENSE_REQUIRED: LICENSE_TYPE_BASIC as LicenseType,
- getI18nName: (i18n: any): string => {
- return i18n.translate('xpack.rollupJobs.appName', {
- defaultMessage: 'Rollup jobs',
- });
- },
-};
-
-export * from '../../../../plugins/rollup/common';
diff --git a/x-pack/legacy/plugins/rollup/index.ts b/x-pack/legacy/plugins/rollup/index.ts
deleted file mode 100644
index f33ae7cfee0a2..0000000000000
--- a/x-pack/legacy/plugins/rollup/index.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { PluginInitializerContext } from 'src/core/server';
-import { RollupSetup } from '../../../plugins/rollup/server';
-import { PLUGIN } from './common';
-import { plugin } from './server';
-
-export function rollup(kibana: any) {
- return new kibana.Plugin({
- id: PLUGIN.ID,
- configPrefix: 'xpack.rollup',
- require: ['kibana', 'elasticsearch', 'xpack_main'],
- init(server: any) {
- const { core: coreSetup, plugins } = server.newPlatform.setup;
- const { usageCollection, visTypeTimeseries, indexManagement } = plugins;
-
- const rollupSetup = (plugins.rollup as unknown) as RollupSetup;
-
- const initContext = ({
- config: rollupSetup.__legacy.config,
- logger: rollupSetup.__legacy.logger,
- } as unknown) as PluginInitializerContext;
-
- const rollupPluginInstance = plugin(initContext);
-
- rollupPluginInstance.setup(coreSetup, {
- usageCollection,
- visTypeTimeseries,
- indexManagement,
- __LEGACY: {
- plugins: {
- xpack_main: server.plugins.xpack_main,
- rollup: server.plugins[PLUGIN.ID],
- },
- },
- });
- },
- });
-}
diff --git a/x-pack/legacy/plugins/rollup/kibana.json b/x-pack/legacy/plugins/rollup/kibana.json
deleted file mode 100644
index 78458c9218be3..0000000000000
--- a/x-pack/legacy/plugins/rollup/kibana.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "id": "rollup",
- "version": "kibana",
- "requiredPlugins": [
- "home",
- "index_management",
- "visTypeTimeseries",
- "indexPatternManagement"
- ],
- "optionalPlugins": [
- "usageCollection"
- ],
- "server": true,
- "ui": false
-}
diff --git a/x-pack/legacy/plugins/rollup/server/lib/__tests__/fixtures/jobs.js b/x-pack/legacy/plugins/rollup/server/lib/__tests__/fixtures/jobs.js
deleted file mode 100644
index eb16b211da3fd..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/lib/__tests__/fixtures/jobs.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export const jobs = [
- {
- "job_id" : "foo1",
- "rollup_index" : "foo_rollup",
- "index_pattern" : "foo-*",
- "fields" : {
- "node" : [
- {
- "agg" : "terms"
- }
- ],
- "temperature" : [
- {
- "agg" : "min"
- },
- {
- "agg" : "max"
- },
- {
- "agg" : "sum"
- }
- ],
- "timestamp" : [
- {
- "agg" : "date_histogram",
- "time_zone" : "UTC",
- "interval" : "1h",
- "delay": "7d"
- }
- ],
- "voltage" : [
- {
- "agg" : "histogram",
- "interval": 5
- },
- {
- "agg" : "sum"
- }
- ]
- }
- },
- {
- "job_id" : "foo2",
- "rollup_index" : "foo_rollup",
- "index_pattern" : "foo-*",
- "fields" : {
- "host" : [
- {
- "agg" : "terms"
- }
- ],
- "timestamp" : [
- {
- "agg" : "date_histogram",
- "time_zone" : "UTC",
- "interval" : "1h",
- "delay": "7d"
- }
- ],
- "voltage" : [
- {
- "agg" : "histogram",
- "interval": 20
- }
- ]
- }
- },
- {
- "job_id" : "foo3",
- "rollup_index" : "foo_rollup",
- "index_pattern" : "foo-*",
- "fields" : {
- "timestamp" : [
- {
- "agg" : "date_histogram",
- "time_zone" : "PST",
- "interval" : "1h",
- "delay": "7d"
- }
- ],
- "voltage" : [
- {
- "agg" : "histogram",
- "interval": 5
- },
- {
- "agg" : "sum"
- }
- ]
- }
- }
-];
diff --git a/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.ts b/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.ts
deleted file mode 100644
index 883b3552a7c02..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/lib/call_with_request_factory/call_with_request_factory.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { ElasticsearchServiceSetup } from 'kibana/server';
-import { once } from 'lodash';
-import { elasticsearchJsPlugin } from '../../client/elasticsearch_rollup';
-
-const callWithRequest = once((elasticsearchService: ElasticsearchServiceSetup) => {
- const config = { plugins: [elasticsearchJsPlugin] };
- return elasticsearchService.createClient('rollup', config);
-});
-
-export const callWithRequestFactory = (
- elasticsearchService: ElasticsearchServiceSetup,
- request: any
-) => {
- return (...args: any[]) => {
- return (
- callWithRequest(elasticsearchService)
- .asScoped(request)
- // @ts-ignore
- .callAsCurrentUser(...args)
- );
- };
-};
diff --git a/x-pack/legacy/plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.test.js b/x-pack/legacy/plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.test.js
deleted file mode 100644
index b6cea09e0ea3c..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.test.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import expect from '@kbn/expect';
-import { licensePreRoutingFactory } from '.';
-import {
- LICENSE_STATUS_VALID,
- LICENSE_STATUS_INVALID,
-} from '../../../../../common/constants/license_status';
-import { kibanaResponseFactory } from '../../../../../../../src/core/server';
-
-describe('licensePreRoutingFactory()', () => {
- let mockServer;
- let mockLicenseCheckResults;
-
- beforeEach(() => {
- mockServer = {
- plugins: {
- xpack_main: {
- info: {
- feature: () => ({
- getLicenseCheckResults: () => mockLicenseCheckResults,
- }),
- },
- },
- },
- };
- });
-
- describe('status is invalid', () => {
- beforeEach(() => {
- mockLicenseCheckResults = {
- status: LICENSE_STATUS_INVALID,
- };
- });
-
- it('replies with 403', () => {
- const routeWithLicenseCheck = licensePreRoutingFactory(mockServer, () => {});
- const stubRequest = {};
- const response = routeWithLicenseCheck({}, stubRequest, kibanaResponseFactory);
- expect(response.status).to.be(403);
- });
- });
-
- describe('status is valid', () => {
- beforeEach(() => {
- mockLicenseCheckResults = {
- status: LICENSE_STATUS_VALID,
- };
- });
-
- it('replies with nothing', () => {
- const routeWithLicenseCheck = licensePreRoutingFactory(mockServer, () => null);
- const stubRequest = {};
- const response = routeWithLicenseCheck({}, stubRequest, kibanaResponseFactory);
- expect(response).to.be(null);
- });
- });
-});
diff --git a/x-pack/legacy/plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts b/x-pack/legacy/plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts
deleted file mode 100644
index 353510d96a00d..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import {
- KibanaRequest,
- KibanaResponseFactory,
- RequestHandler,
- RequestHandlerContext,
-} from 'src/core/server';
-import { PLUGIN } from '../../../common';
-import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status';
-import { ServerShim } from '../../types';
-
-export const licensePreRoutingFactory = (
- server: ServerShim,
- handler: RequestHandler
-): RequestHandler => {
- const xpackMainPlugin = server.plugins.xpack_main;
-
- // License checking and enable/disable logic
- return function licensePreRouting(
- ctx: RequestHandlerContext,
- request: KibanaRequest,
- response: KibanaResponseFactory
- ) {
- const licenseCheckResults = xpackMainPlugin.info.feature(PLUGIN.ID).getLicenseCheckResults();
- const { status } = licenseCheckResults;
-
- if (status !== LICENSE_STATUS_VALID) {
- return response.customError({
- body: {
- message: licenseCheckResults.messsage,
- },
- statusCode: 403,
- });
- }
-
- return handler(ctx, request, response);
- };
-};
diff --git a/x-pack/legacy/plugins/rollup/server/plugin.ts b/x-pack/legacy/plugins/rollup/server/plugin.ts
deleted file mode 100644
index 05c22b030fff9..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/plugin.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import { CoreSetup, Plugin, PluginInitializerContext, Logger } from 'src/core/server';
-import { first } from 'rxjs/operators';
-import { i18n } from '@kbn/i18n';
-
-import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
-import { VisTypeTimeseriesSetup } from 'src/plugins/vis_type_timeseries/server';
-import { IndexManagementPluginSetup } from '../../../../plugins/index_management/server';
-import { registerLicenseChecker } from '../../../server/lib/register_license_checker';
-import { PLUGIN } from '../common';
-import { ServerShim, RouteDependencies } from './types';
-
-import {
- registerIndicesRoute,
- registerFieldsForWildcardRoute,
- registerSearchRoute,
- registerJobsRoute,
-} from './routes/api';
-
-import { registerRollupUsageCollector } from './collectors';
-
-import { rollupDataEnricher } from './rollup_data_enricher';
-import { registerRollupSearchStrategy } from './lib/search_strategies';
-
-export class RollupsServerPlugin implements Plugin {
- log: Logger;
-
- constructor(private readonly initializerContext: PluginInitializerContext) {
- this.log = initializerContext.logger.get();
- }
-
- async setup(
- { http, elasticsearch: elasticsearchService }: CoreSetup,
- {
- __LEGACY: serverShim,
- usageCollection,
- visTypeTimeseries,
- indexManagement,
- }: {
- __LEGACY: ServerShim;
- usageCollection?: UsageCollectionSetup;
- visTypeTimeseries?: VisTypeTimeseriesSetup;
- indexManagement?: IndexManagementPluginSetup;
- }
- ) {
- const elasticsearch = await elasticsearchService.adminClient;
- const router = http.createRouter();
- const routeDependencies: RouteDependencies = {
- elasticsearch,
- elasticsearchService,
- router,
- };
-
- registerLicenseChecker(
- serverShim as any,
- PLUGIN.ID,
- PLUGIN.getI18nName(i18n),
- PLUGIN.MINIMUM_LICENSE_REQUIRED
- );
-
- registerIndicesRoute(routeDependencies, serverShim);
- registerFieldsForWildcardRoute(routeDependencies, serverShim);
- registerSearchRoute(routeDependencies, serverShim);
- registerJobsRoute(routeDependencies, serverShim);
-
- if (usageCollection) {
- this.initializerContext.config.legacy.globalConfig$
- .pipe(first())
- .toPromise()
- .then(config => {
- registerRollupUsageCollector(usageCollection, config.kibana.index);
- })
- .catch(e => {
- this.log.warn(`Registering Rollup collector failed: ${e}`);
- });
- }
-
- if (indexManagement && indexManagement.indexDataEnricher) {
- indexManagement.indexDataEnricher.add(rollupDataEnricher);
- }
-
- if (visTypeTimeseries) {
- const { addSearchStrategy } = visTypeTimeseries;
- registerRollupSearchStrategy(routeDependencies, addSearchStrategy);
- }
- }
-
- start() {}
-
- stop() {}
-}
diff --git a/x-pack/legacy/plugins/rollup/server/routes/api/index.ts b/x-pack/legacy/plugins/rollup/server/routes/api/index.ts
deleted file mode 100644
index 146c3e973f9ea..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/routes/api/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-export { registerIndicesRoute } from './indices';
-export { registerFieldsForWildcardRoute } from './index_patterns';
-export { registerSearchRoute } from './search';
-export { registerJobsRoute } from './jobs';
diff --git a/x-pack/legacy/plugins/rollup/server/routes/api/index_patterns.ts b/x-pack/legacy/plugins/rollup/server/routes/api/index_patterns.ts
deleted file mode 100644
index 2516840bd9537..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/routes/api/index_patterns.ts
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import { schema } from '@kbn/config-schema';
-import { RequestHandler } from 'src/core/server';
-
-import { indexBy } from 'lodash';
-import { IndexPatternsFetcher } from '../../shared_imports';
-import { RouteDependencies, ServerShim } from '../../types';
-import { callWithRequestFactory } from '../../lib/call_with_request_factory';
-import { isEsError } from '../../lib/is_es_error';
-import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory';
-import { getCapabilitiesForRollupIndices } from '../../lib/map_capabilities';
-import { mergeCapabilitiesWithFields, Field } from '../../lib/merge_capabilities_with_fields';
-
-const parseMetaFields = (metaFields: string | string[]) => {
- let parsedFields: string[] = [];
- if (typeof metaFields === 'string') {
- parsedFields = JSON.parse(metaFields);
- } else {
- parsedFields = metaFields;
- }
- return parsedFields;
-};
-
-const getFieldsForWildcardRequest = async (context: any, request: any, response: any) => {
- const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
- const indexPatterns = new IndexPatternsFetcher(callAsCurrentUser);
- const { pattern, meta_fields: metaFields } = request.query;
-
- let parsedFields: string[] = [];
- try {
- parsedFields = parseMetaFields(metaFields);
- } catch (error) {
- return response.badRequest({
- body: error,
- });
- }
-
- try {
- const fields = await indexPatterns.getFieldsForWildcard({
- pattern,
- metaFields: parsedFields,
- });
-
- return response.ok({
- body: { fields },
- headers: {
- 'content-type': 'application/json',
- },
- });
- } catch (error) {
- return response.notFound();
- }
-};
-
-/**
- * Get list of fields for rollup index pattern, in the format of regular index pattern fields
- */
-export function registerFieldsForWildcardRoute(deps: RouteDependencies, legacy: ServerShim) {
- const handler: RequestHandler = async (ctx, request, response) => {
- const { params, meta_fields: metaFields } = request.query;
-
- try {
- // Make call and use field information from response
- const { payload } = await getFieldsForWildcardRequest(ctx, request, response);
- const fields = payload.fields;
- const parsedParams = JSON.parse(params);
- const rollupIndex = parsedParams.rollup_index;
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
- const rollupFields: Field[] = [];
- const fieldsFromFieldCapsApi: { [key: string]: any } = indexBy(fields, 'name');
- const rollupIndexCapabilities = getCapabilitiesForRollupIndices(
- await callWithRequest('rollup.rollupIndexCapabilities', {
- indexPattern: rollupIndex,
- })
- )[rollupIndex].aggs;
- // Keep meta fields
- metaFields.forEach(
- (field: string) =>
- fieldsFromFieldCapsApi[field] && rollupFields.push(fieldsFromFieldCapsApi[field])
- );
- const mergedRollupFields = mergeCapabilitiesWithFields(
- rollupIndexCapabilities,
- fieldsFromFieldCapsApi,
- rollupFields
- );
- return response.ok({ body: { fields: mergedRollupFields } });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- deps.router.get(
- {
- path: '/api/index_patterns/rollup/_fields_for_wildcard',
- validate: {
- query: schema.object({
- pattern: schema.string(),
- meta_fields: schema.arrayOf(schema.string(), {
- defaultValue: [],
- }),
- params: schema.string({
- validate(value) {
- try {
- const params = JSON.parse(value);
- const keys = Object.keys(params);
- const { rollup_index: rollupIndex } = params;
-
- if (!rollupIndex) {
- return '[request query.params]: "rollup_index" is required';
- } else if (keys.length > 1) {
- const invalidParams = keys.filter(key => key !== 'rollup_index');
- return `[request query.params]: ${invalidParams.join(', ')} is not allowed`;
- }
- } catch (err) {
- return '[request query.params]: expected JSON string';
- }
- },
- }),
- }),
- },
- },
- licensePreRoutingFactory(legacy, handler)
- );
-}
diff --git a/x-pack/legacy/plugins/rollup/server/routes/api/indices.ts b/x-pack/legacy/plugins/rollup/server/routes/api/indices.ts
deleted file mode 100644
index e78f09a71876b..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/routes/api/indices.ts
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import { schema } from '@kbn/config-schema';
-import { RequestHandler } from 'src/core/server';
-import { callWithRequestFactory } from '../../lib/call_with_request_factory';
-import { isEsError } from '../../lib/is_es_error';
-import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory';
-import { getCapabilitiesForRollupIndices } from '../../lib/map_capabilities';
-import { API_BASE_PATH } from '../../../common';
-import { RouteDependencies, ServerShim } from '../../types';
-
-type NumericField =
- | 'long'
- | 'integer'
- | 'short'
- | 'byte'
- | 'scaled_float'
- | 'double'
- | 'float'
- | 'half_float';
-
-interface FieldCapability {
- date?: any;
- keyword?: any;
- long?: any;
- integer?: any;
- short?: any;
- byte?: any;
- double?: any;
- float?: any;
- half_float?: any;
- scaled_float?: any;
-}
-
-interface FieldCapabilities {
- fields: FieldCapability[];
-}
-
-function isNumericField(fieldCapability: FieldCapability) {
- const numericTypes = [
- 'long',
- 'integer',
- 'short',
- 'byte',
- 'double',
- 'float',
- 'half_float',
- 'scaled_float',
- ];
- return numericTypes.some(numericType => fieldCapability[numericType as NumericField] != null);
-}
-
-export function registerIndicesRoute(deps: RouteDependencies, legacy: ServerShim) {
- const getIndicesHandler: RequestHandler = async (ctx, request, response) => {
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
-
- try {
- const data = await callWithRequest('rollup.rollupIndexCapabilities', {
- indexPattern: '_all',
- });
- return response.ok({ body: getCapabilitiesForRollupIndices(data) });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- const validateIndexPatternHandler: RequestHandler = async (
- ctx,
- request,
- response
- ) => {
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
-
- try {
- const { indexPattern } = request.params;
- const [fieldCapabilities, rollupIndexCapabilities]: [
- FieldCapabilities,
- { [key: string]: any }
- ] = await Promise.all([
- callWithRequest('rollup.fieldCapabilities', { indexPattern }),
- callWithRequest('rollup.rollupIndexCapabilities', { indexPattern }),
- ]);
-
- const doesMatchIndices = Object.entries(fieldCapabilities.fields).length !== 0;
- const doesMatchRollupIndices = Object.entries(rollupIndexCapabilities).length !== 0;
-
- const dateFields: string[] = [];
- const numericFields: string[] = [];
- const keywordFields: string[] = [];
-
- const fieldCapabilitiesEntries = Object.entries(fieldCapabilities.fields);
-
- fieldCapabilitiesEntries.forEach(
- ([fieldName, fieldCapability]: [string, FieldCapability]) => {
- if (fieldCapability.date) {
- dateFields.push(fieldName);
- return;
- }
-
- if (isNumericField(fieldCapability)) {
- numericFields.push(fieldName);
- return;
- }
-
- if (fieldCapability.keyword) {
- keywordFields.push(fieldName);
- }
- }
- );
-
- const body = {
- doesMatchIndices,
- doesMatchRollupIndices,
- dateFields,
- numericFields,
- keywordFields,
- };
-
- return response.ok({ body });
- } catch (err) {
- // 404s are still valid results.
- if (err.statusCode === 404) {
- const notFoundBody = {
- doesMatchIndices: false,
- doesMatchRollupIndices: false,
- dateFields: [],
- numericFields: [],
- keywordFields: [],
- };
- return response.ok({ body: notFoundBody });
- }
-
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
-
- return response.internalError({ body: err });
- }
- };
-
- /**
- * Returns a list of all rollup index names
- */
- deps.router.get(
- {
- path: `${API_BASE_PATH}/indices`,
- validate: false,
- },
- licensePreRoutingFactory(legacy, getIndicesHandler)
- );
-
- /**
- * Returns information on validity of an index pattern for creating a rollup job:
- * - Does the index pattern match any indices?
- * - Does the index pattern match rollup indices?
- * - Which date fields, numeric fields, and keyword fields are available in the matching indices?
- */
- deps.router.get(
- {
- path: `${API_BASE_PATH}/index_pattern_validity/{indexPattern}`,
- validate: {
- params: schema.object({
- indexPattern: schema.string(),
- }),
- },
- },
- licensePreRoutingFactory(legacy, validateIndexPatternHandler)
- );
-}
diff --git a/x-pack/legacy/plugins/rollup/server/routes/api/jobs.ts b/x-pack/legacy/plugins/rollup/server/routes/api/jobs.ts
deleted file mode 100644
index e45713e2b807c..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/routes/api/jobs.ts
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-import { schema } from '@kbn/config-schema';
-import { RequestHandler } from 'src/core/server';
-import { callWithRequestFactory } from '../../lib/call_with_request_factory';
-import { isEsError } from '../../lib/is_es_error';
-import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory';
-import { API_BASE_PATH } from '../../../common';
-import { RouteDependencies, ServerShim } from '../../types';
-
-export function registerJobsRoute(deps: RouteDependencies, legacy: ServerShim) {
- const getJobsHandler: RequestHandler = async (ctx, request, response) => {
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
-
- try {
- const data = await callWithRequest('rollup.jobs');
- return response.ok({ body: data });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- const createJobsHandler: RequestHandler = async (ctx, request, response) => {
- try {
- const { id, ...rest } = request.body.job;
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
- // Create job.
- await callWithRequest('rollup.createJob', {
- id,
- body: rest,
- });
- // Then request the newly created job.
- const results = await callWithRequest('rollup.job', { id });
- return response.ok({ body: results.jobs[0] });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- const startJobsHandler: RequestHandler = async (ctx, request, response) => {
- try {
- const { jobIds } = request.body;
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
-
- const data = await Promise.all(
- jobIds.map((id: string) => callWithRequest('rollup.startJob', { id }))
- ).then(() => ({ success: true }));
- return response.ok({ body: data });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- const stopJobsHandler: RequestHandler = async (ctx, request, response) => {
- try {
- const { jobIds } = request.body;
- // For our API integration tests we need to wait for the jobs to be stopped
- // in order to be able to delete them sequencially.
- const { waitForCompletion } = request.query;
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
- const stopRollupJob = (id: string) =>
- callWithRequest('rollup.stopJob', {
- id,
- waitForCompletion: waitForCompletion === 'true',
- });
- const data = await Promise.all(jobIds.map(stopRollupJob)).then(() => ({ success: true }));
- return response.ok({ body: data });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- const deleteJobsHandler: RequestHandler = async (ctx, request, response) => {
- try {
- const { jobIds } = request.body;
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
- const data = await Promise.all(
- jobIds.map((id: string) => callWithRequest('rollup.deleteJob', { id }))
- ).then(() => ({ success: true }));
- return response.ok({ body: data });
- } catch (err) {
- // There is an issue opened on ES to handle the following error correctly
- // https://github.com/elastic/elasticsearch/issues/42908
- // Until then we'll modify the response here.
- if (err.response && err.response.includes('Job must be [STOPPED] before deletion')) {
- err.status = 400;
- err.statusCode = 400;
- err.displayName = 'Bad request';
- err.message = JSON.parse(err.response).task_failures[0].reason.reason;
- }
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- deps.router.get(
- {
- path: `${API_BASE_PATH}/jobs`,
- validate: false,
- },
- licensePreRoutingFactory(legacy, getJobsHandler)
- );
-
- deps.router.put(
- {
- path: `${API_BASE_PATH}/create`,
- validate: {
- body: schema.object({
- job: schema.object(
- {
- id: schema.string(),
- },
- { unknowns: 'allow' }
- ),
- }),
- },
- },
- licensePreRoutingFactory(legacy, createJobsHandler)
- );
-
- deps.router.post(
- {
- path: `${API_BASE_PATH}/start`,
- validate: {
- body: schema.object({
- jobIds: schema.arrayOf(schema.string()),
- }),
- query: schema.maybe(
- schema.object({
- waitForCompletion: schema.maybe(schema.string()),
- })
- ),
- },
- },
- licensePreRoutingFactory(legacy, startJobsHandler)
- );
-
- deps.router.post(
- {
- path: `${API_BASE_PATH}/stop`,
- validate: {
- body: schema.object({
- jobIds: schema.arrayOf(schema.string()),
- }),
- },
- },
- licensePreRoutingFactory(legacy, stopJobsHandler)
- );
-
- deps.router.post(
- {
- path: `${API_BASE_PATH}/delete`,
- validate: {
- body: schema.object({
- jobIds: schema.arrayOf(schema.string()),
- }),
- },
- },
- licensePreRoutingFactory(legacy, deleteJobsHandler)
- );
-}
diff --git a/x-pack/legacy/plugins/rollup/server/routes/api/search.ts b/x-pack/legacy/plugins/rollup/server/routes/api/search.ts
deleted file mode 100644
index 97999a4b5ce8d..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/routes/api/search.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { schema } from '@kbn/config-schema';
-import { RequestHandler } from 'src/core/server';
-import { callWithRequestFactory } from '../../lib/call_with_request_factory';
-import { isEsError } from '../../lib/is_es_error';
-import { licensePreRoutingFactory } from '../../lib/license_pre_routing_factory';
-import { API_BASE_PATH } from '../../../common';
-import { RouteDependencies, ServerShim } from '../../types';
-
-export function registerSearchRoute(deps: RouteDependencies, legacy: ServerShim) {
- const handler: RequestHandler = async (ctx, request, response) => {
- const callWithRequest = callWithRequestFactory(deps.elasticsearchService, request);
- try {
- const requests = request.body.map(({ index, query }: { index: string; query: any }) =>
- callWithRequest('rollup.search', {
- index,
- rest_total_hits_as_int: true,
- body: query,
- })
- );
- const data = await Promise.all(requests);
- return response.ok({ body: data });
- } catch (err) {
- if (isEsError(err)) {
- return response.customError({ statusCode: err.statusCode, body: err });
- }
- return response.internalError({ body: err });
- }
- };
-
- deps.router.post(
- {
- path: `${API_BASE_PATH}/search`,
- validate: {
- body: schema.arrayOf(
- schema.object({
- index: schema.string(),
- query: schema.any(),
- })
- ),
- },
- },
- licensePreRoutingFactory(legacy, handler)
- );
-}
diff --git a/x-pack/legacy/plugins/rollup/server/types.ts b/x-pack/legacy/plugins/rollup/server/types.ts
deleted file mode 100644
index bcc6770e9b8ee..0000000000000
--- a/x-pack/legacy/plugins/rollup/server/types.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License;
- * you may not use this file except in compliance with the Elastic License.
- */
-
-import { IRouter, ElasticsearchServiceSetup, IClusterClient } from 'src/core/server';
-import { XPackMainPlugin } from '../../xpack_main/server/xpack_main';
-
-export interface ServerShim {
- plugins: {
- xpack_main: XPackMainPlugin;
- rollup: any;
- };
-}
-
-export interface RouteDependencies {
- router: IRouter;
- elasticsearchService: ElasticsearchServiceSetup;
- elasticsearch: IClusterClient;
-}
diff --git a/x-pack/legacy/plugins/rollup/tsconfig.json b/x-pack/legacy/plugins/rollup/tsconfig.json
deleted file mode 100644
index 618c6c3e97b57..0000000000000
--- a/x-pack/legacy/plugins/rollup/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "../../../tsconfig.json"
-}
diff --git a/x-pack/legacy/plugins/task_manager/server/index.ts b/x-pack/legacy/plugins/task_manager/server/index.ts
index ff25d8a1e0e5d..3ea687f7003f4 100644
--- a/x-pack/legacy/plugins/task_manager/server/index.ts
+++ b/x-pack/legacy/plugins/task_manager/server/index.ts
@@ -15,19 +15,26 @@ export { LegacyTaskManagerApi, getTaskManagerSetup, getTaskManagerStart } from '
// Once all plugins are migrated to NP, this can be removed
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { TaskManager } from '../../../../plugins/task_manager/server/task_manager';
+import {
+ LegacyPluginApi,
+ LegacyPluginSpec,
+ ArrayOrItem,
+} from '../../../../../src/legacy/plugin_discovery/types';
const savedObjectSchemas = {
task: {
hidden: true,
isNamespaceAgnostic: true,
convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`,
+ // legacy config is marked as any in core, no choice here
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
indexPattern(config: any) {
return config.get('xpack.task_manager.index');
},
},
};
-export function taskManager(kibana: any) {
+export function taskManager(kibana: LegacyPluginApi): ArrayOrItem {
return new kibana.Plugin({
id: 'task_manager',
require: ['kibana', 'elasticsearch', 'xpack_main'],
@@ -58,7 +65,11 @@ export function taskManager(kibana: any) {
// instead we will start the internal Task Manager plugin when
// all legacy plugins have finished initializing
// Once all plugins are migrated to NP, this can be removed
- this.kbnServer.afterPluginsInit(() => {
+
+ // the typing for the lagcy server isn't quite correct, so
+ // we'll bypase it for now
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (this as any).kbnServer.afterPluginsInit(() => {
taskManagerPlugin.start();
});
return taskManagerPlugin;
@@ -71,5 +82,5 @@ export function taskManager(kibana: any) {
migrations,
savedObjectSchemas,
},
- });
+ } as Legacy.PluginSpecOptions);
}
diff --git a/x-pack/legacy/plugins/task_manager/server/legacy.ts b/x-pack/legacy/plugins/task_manager/server/legacy.ts
index cd2047b757e61..0d50828004a94 100644
--- a/x-pack/legacy/plugins/task_manager/server/legacy.ts
+++ b/x-pack/legacy/plugins/task_manager/server/legacy.ts
@@ -49,10 +49,10 @@ export function createLegacyApi(legacyTaskManager: Promise): Legacy
fetch: (opts: SearchOpts) => legacyTaskManager.then((tm: TaskManager) => tm.fetch(opts)),
get: (id: string) => legacyTaskManager.then((tm: TaskManager) => tm.get(id)),
remove: (id: string) => legacyTaskManager.then((tm: TaskManager) => tm.remove(id)),
- schedule: (taskInstance: TaskInstanceWithDeprecatedFields, options?: any) =>
+ schedule: (taskInstance: TaskInstanceWithDeprecatedFields, options?: object) =>
legacyTaskManager.then((tm: TaskManager) => tm.schedule(taskInstance, options)),
runNow: (taskId: string) => legacyTaskManager.then((tm: TaskManager) => tm.runNow(taskId)),
- ensureScheduled: (taskInstance: TaskInstanceWithId, options?: any) =>
+ ensureScheduled: (taskInstance: TaskInstanceWithId, options?: object) =>
legacyTaskManager.then((tm: TaskManager) => tm.ensureScheduled(taskInstance, options)),
};
}
diff --git a/x-pack/legacy/plugins/task_manager/server/migrations.ts b/x-pack/legacy/plugins/task_manager/server/migrations.ts
index 97c4f97f59c58..1c2cf73d0fe13 100644
--- a/x-pack/legacy/plugins/task_manager/server/migrations.ts
+++ b/x-pack/legacy/plugins/task_manager/server/migrations.ts
@@ -7,7 +7,7 @@ import { SavedObject } from '../../../../../src/core/server';
export const migrations = {
task: {
- '7.4.0': (doc: SavedObject