>;
total: number;
per_page: number;
page: number;
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index ecfa09fbd37f3..9dc3ac9b94d96 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -657,6 +657,8 @@ export interface CoreStart {
// (undocumented)
elasticsearch: ElasticsearchServiceStart;
// (undocumented)
+ http: HttpServiceStart;
+ // (undocumented)
savedObjects: SavedObjectsServiceStart;
// (undocumented)
uiSettings: UiSettingsServiceStart;
@@ -905,6 +907,12 @@ export type Headers = {
[header: string]: string | string[] | undefined;
};
+// @public (undocumented)
+export interface HttpAuth {
+ get: GetAuthState;
+ isAuthenticated: IsAuthenticated;
+}
+
// @public
export interface HttpResources {
register: (route: RouteConfig
, handler: HttpResourcesRequestHandler
) => void;
@@ -948,17 +956,13 @@ export interface HttpServerInfo {
// @public
export interface HttpServiceSetup {
- // (undocumented)
- auth: {
- get: GetAuthState;
- isAuthenticated: IsAuthenticated;
- };
+ // @deprecated
+ auth: HttpAuth;
basePath: IBasePath;
createCookieSessionStorageFactory: (cookieOptions: SessionStorageCookieOptions) => Promise>;
createRouter: () => IRouter;
csp: ICspConfig;
getServerInfo: () => HttpServerInfo;
- isTlsEnabled: boolean;
registerAuth: (handler: AuthenticationHandler) => void;
registerOnPostAuth: (handler: OnPostAuthHandler) => void;
registerOnPreAuth: (handler: OnPreAuthHandler) => void;
@@ -968,7 +972,9 @@ export interface HttpServiceSetup {
// @public (undocumented)
export interface HttpServiceStart {
- isListening: (port: number) => boolean;
+ auth: HttpAuth;
+ basePath: IBasePath;
+ getServerInfo: () => HttpServerInfo;
}
// @public
@@ -2039,11 +2045,16 @@ export interface SavedObjectsFindResponse {
// (undocumented)
per_page: number;
// (undocumented)
- saved_objects: Array>;
+ saved_objects: Array>;
// (undocumented)
total: number;
}
+// @public (undocumented)
+export interface SavedObjectsFindResult extends SavedObject {
+ score: number;
+}
+
// @public
export interface SavedObjectsImportConflictError {
// (undocumented)
diff --git a/src/core/server/server.ts b/src/core/server/server.ts
index 6ca580083648f..ae1a02cf71b88 100644
--- a/src/core/server/server.ts
+++ b/src/core/server/server.ts
@@ -202,10 +202,12 @@ export class Server {
});
const capabilitiesStart = this.capabilities.start();
const uiSettingsStart = await this.uiSettings.start();
+ const httpStart = this.http.getStartContract();
this.coreStart = {
capabilities: capabilitiesStart,
elasticsearch: elasticsearchStart,
+ http: httpStart,
savedObjects: savedObjectsStart,
uiSettings: uiSettingsStart,
};
@@ -221,6 +223,7 @@ export class Server {
});
await this.http.start();
+
await this.rendering.start({
legacy: this.legacy,
});
diff --git a/src/core/server/ui_settings/ui_settings_service.test.ts b/src/core/server/ui_settings/ui_settings_service.test.ts
index ebcb0cf1d762f..096ca347e6f4b 100644
--- a/src/core/server/ui_settings/ui_settings_service.test.ts
+++ b/src/core/server/ui_settings/ui_settings_service.test.ts
@@ -49,7 +49,7 @@ describe('uiSettings', () => {
beforeEach(() => {
const coreContext = mockCoreContext.create();
coreContext.configService.atPath.mockReturnValue(new BehaviorSubject({ overrides }));
- const httpSetup = httpServiceMock.createSetupContract();
+ const httpSetup = httpServiceMock.createInternalSetupContract();
const savedObjectsSetup = savedObjectsServiceMock.createInternalSetupContract();
setupDeps = { http: httpSetup, savedObjects: savedObjectsSetup };
savedObjectsClient = savedObjectsClientMock.create();
diff --git a/src/dev/storybook/aliases.ts b/src/dev/storybook/aliases.ts
index 2f785896da8d5..85bfd4a7a4d26 100644
--- a/src/dev/storybook/aliases.ts
+++ b/src/dev/storybook/aliases.ts
@@ -22,7 +22,6 @@ export const storybookAliases = {
canvas: 'x-pack/plugins/canvas/scripts/storybook_new.js',
codeeditor: 'src/plugins/kibana_react/public/code_editor/scripts/storybook.ts',
dashboard_enhanced: 'x-pack/plugins/dashboard_enhanced/scripts/storybook.js',
- drilldowns: 'x-pack/plugins/drilldowns/scripts/storybook.js',
embeddable: 'src/plugins/embeddable/scripts/storybook.js',
infra: 'x-pack/legacy/plugins/infra/scripts/storybook.js',
security_solution: 'x-pack/plugins/security_solution/scripts/storybook.js',
diff --git a/src/es_archiver/es_archiver.ts b/src/es_archiver/es_archiver.ts
index f36cbb3f516b9..e335652195b86 100644
--- a/src/es_archiver/es_archiver.ts
+++ b/src/es_archiver/es_archiver.ts
@@ -49,7 +49,7 @@ export class EsArchiver {
this.client = client;
this.dataDir = dataDir;
this.log = log;
- this.kbnClient = new KbnClient(log, [kibanaUrl]);
+ this.kbnClient = new KbnClient(log, { url: kibanaUrl });
}
/**
diff --git a/src/plugins/embeddable/docs/README.md b/src/plugins/embeddable/docs/README.md
index 1b6c7be13b1d4..ce5e76d54a046 100644
--- a/src/plugins/embeddable/docs/README.md
+++ b/src/plugins/embeddable/docs/README.md
@@ -2,4 +2,5 @@
## Reference
-- [Embeddable containers and inherited input state](./containers_and_inherited_state.md)
+- [Input and output state](./input_and_output_state.md)
+- [Common mistakes with embeddable containers and inherited input state](./containers_and_inherited_state.md)
diff --git a/src/plugins/embeddable/docs/containers_and_inherited_state.md b/src/plugins/embeddable/docs/containers_and_inherited_state.md
index c950bef96002a..35e399f89c131 100644
--- a/src/plugins/embeddable/docs/containers_and_inherited_state.md
+++ b/src/plugins/embeddable/docs/containers_and_inherited_state.md
@@ -1,4 +1,4 @@
-## Embeddable containers and inherited input state
+## Common mistakes with embeddable containers and inherited input state
`updateInput` is typed as `updateInput(input: Partial)`. Notice it's _partial_. This is to support the use case of inherited state when an embeddable is inside a container.
diff --git a/src/plugins/embeddable/docs/input_and_output_state.md b/src/plugins/embeddable/docs/input_and_output_state.md
new file mode 100644
index 0000000000000..810dc72664f96
--- /dev/null
+++ b/src/plugins/embeddable/docs/input_and_output_state.md
@@ -0,0 +1,282 @@
+## Input and output state
+
+### What's the difference?
+
+Input vs Output State
+
+| Input | Output |
+| ----------- | ----------- |
+| Public, on the IEmbeddable interface. `embeddable.updateInput(changedInput)` | Protected inside the Embeddable class. `this.updateOutput(changedOutput)` |
+| Serializable representation of the embeddable | Does not need to be serializable |
+| Can be updated throughout the lifecycle of an Embeddable | Often derived from input state |
+
+Non-real examples to showcase the difference:
+
+| Input | Output |
+| ----------- | ----------- |
+| savedObjectId | savedObjectAttributes |
+| esQueryRequest | esQueryResponse |
+| props | renderComplete |
+
+### Types of input state
+
+#### Inherited input state
+
+The only reason we have different types of input state is to support embeddable containers, and children embeddables _inheriting_ state from the container.
+For example, when the dashboard time range changes, so does
+the time range of all children embeddables. Dashboard passes down time range as _inherited_ input state. From the viewpoint of the child Embeddable,
+time range is just input state. It doesn't care where it gets this data from.
+
+
+For example, imagine a container with this input:
+
+```js
+{
+ gridData: {...},
+ timeRange: 'now-15m to now',
+
+ // Every embeddable container has a panels mapping. It's how the base container class manages common changes like children being
+ // added, removed or edited.
+ panels: {
+ ['1']: {
+ // `type` is used to grab the right embeddable factory. Every PanelState must specify one.
+ type: 'clock',
+
+ // `explicitInput` is combined with `inheritedInput` to create `childInput`, and is use like:
+ // `embeddableFactories.get(type).create(childInput)`.
+ explicitInput: {
+
+ // All explicitInput is required to have an id. This is used as a way for the
+ // embeddable to know where it exists in the panels array if it's living in a container.
+ // Note, this is NOT THE SAVED OBJECT ID! Even though it's sometimes used to store the saved object id.
+ id: '1',
+ }
+ }
+ }
+}
+```
+
+That could result in the following input being passed to a child:
+
+```js
+{
+ timeRange: 'now-15m to now',
+ id: '1',
+}
+```
+
+Notice that `gridData` is not passed down, but `timeRange` is. What ends up as _inherited_ state, that is passed down to a child, is up to the specific
+implementation of a container and
+determined by the abstract function `Container.getInheritedInput()`
+
+#### Overridding inherited input
+
+We wanted to support _overriding_ this inherited state, to support the "Per panel time range" feature. The _inherited_ `timeRange` input can be
+overridden by the _explicit_ `timeRange` input.
+
+Take this example dashboard container input:
+
+```js
+{
+ gridData: {...},
+ timeRange: 'now-15m to now',
+ panels: {
+ ['1']: {
+ type: 'clock',
+ explicitInput: {
+ timeRange: 'now-30m to now',
+ id: '1',
+ }
+ },
+ ['2']: {
+ type: 'clock',
+ explicitInput: {
+ id: '2',
+ }
+ },
+}
+```
+
+The first child embeddable will get passed input state:
+
+```js
+{
+ timeRange: 'now-30m to now',
+ id: '1',
+}
+```
+
+This override wouldn't affect other children, so the second child would receive:
+
+```js
+{
+ timeRange: 'now-15m to now',
+ id: '2',
+}
+```
+
+#### EmbeddableInput.id and some technical debt
+
+Above I said:
+
+> From the viewpoint of the child Embeddable,
+> time range is just input state. It doesn't care where it gets this data from.
+
+and this is mostly true, however, the primary reason EmbeddableInput.id exists is to support the
+case where the custom time range badge action needs to look up a child's explicit input on the
+parent. It does this to determine whether or not to show the badge. The logic is something like:
+
+```ts
+ // If there is no explicit input defined on the parent then this embeddable inherits the
+ // time range from whatever the time range of the parent is.
+ return parent.getInput().panels[embeddable.id].explicitInput.timeRange === undefined;
+```
+
+It doesn't just compare the timeRange input on the parent (`embeddable.parent?.getInput().timeRange` )because even if they happen to match,
+we still want the badge showing to indicate the time range is "locked" on this particular panel.
+
+Note that `parent` can be retrieved from either `embeddabble.parent` or `embeddable.getRoot()`. The
+`getRoot` variety will walk up to find the root parent, even though we have no tested or used
+nested containers, it is theoretically possible.
+
+This EmbeddableInput.id parameter is marked as required on the `EmbeddableInput` interface, even though it's only used
+when an embeddable is inside a parent. There is also no
+typescript safety to ensure the id matches the panel id in the parents json:
+
+```js
+ ['2']: {
+ type: 'clock',
+ explicitInput: {
+ id: '3', // No! Should be 2!
+ }
+ },
+```
+
+It should probably be something that the parent passes down to the child specifically, based on the panel mapping key,
+and renamed to something like `panelKeyInParent`.
+
+Note that this has nothing to do with a saved object id, even though in dashboard app, the saved object happens to be
+used as the dashboard container id. Another reason this should probably not be required for embeddables not
+inside containers.
+
+#### A container can pass down any information to the children
+
+It doesn't have to be part of it's own input. It's possible for a container input like:
+
+
+```js
+{
+ timeRange: 'now-15m to now',
+ panels: {
+ ['1']: {
+ type: 'clock',
+ explicitInput: {
+ timeRange: 'now-30m to now',
+ id: '1',
+ }
+ }
+}
+```
+
+to pass down this input:
+
+```js
+{
+ timeRange: 'now-30m to now',
+ id: '1',
+ zed: 'bar', // <-- Where did this come from??
+}
+```
+
+I don't have a realistic use case for this, just noting it's possible in any containers implementation of `getInheritedInput`. Note this is still considered
+inherited input because it's coming from the container.
+
+#### Explicit input stored on behalf of the container
+
+It's possible for a container to store explicit input state on behalf of an embeddable, without knowing what that state is. For example, a container could
+have input state like:
+
+```js
+{
+ timeRange: 'now-15m to now',
+ panels: {
+ ['1']: {
+ type: 'clock',
+ explicitInput: {
+ display: 'analog',
+ id: '1',
+ }
+ }
+}
+```
+
+And what gets passed to the child is:
+
+```js
+{
+ timeRange: 'now-15m to now',
+ id: '1',
+ display: 'analog'
+}
+```
+
+even if a container has no idea about this `clock` embeddable implementation, nor this `explicitInput.display` field.
+
+There are two ways for this kind of state to end up in `panels[id].explicitInput`.
+
+1. `ClockEmbeddableFactory.getExplicitInput` returns it.
+2. `ClockEmbeddableFactory.getDefaultInput` returns it. (This function is largely unused. We may be able to get rid of it.)
+3. Someone called `embeddable.updateInput({ display: 'analog' })`, when the embeddable is a child in a container.
+
+#### Containers can pass down too much information
+
+Lets say our container state is:
+
+```js
+{
+ timeRange: 'now-15m to now',
+ panels: {
+ ['1']: {
+ type: 'helloWorld',
+ explicitInput: {
+ id: '1',
+ }
+ }
+}
+```
+
+What gets passed to the child is:
+
+```js
+{
+ timeRange: 'now-15m to now',
+ id: '1',
+}
+```
+
+It doesn't matter if the embeddable does not require, nor use, `timeRange`. The container passes down inherited input state to every child.
+This could present problems with trying to figure out which embeddables support
+different types of actions. For example, it'd be great if "Customize time range" action only showed up on embeddables that actually did something
+with the `timeRange`. You can't check at runtime whether `input.timeRange === undefined` to do so though, because it will be passed in by the container
+regardless.
+
+
+#### Tech debt warnings
+
+`EmbeddableFactory.getExplicitInput` was intended as a way for an embeddable to retrieve input state it needs, that will not
+be provided by a container. However, an embeddable won't know where it will be rendered, so how will the factory know which
+required data to ask from the user and which will be inherited from the container? I believe `getDefaultInput` was meant to solve this.
+`getDefaultInput` would provide default values, only if the container didn't supply them through inheritance. Explicit input would
+always provide these values, and would always be stored in a containers `panel[id].explicitInput`, even if the container _did_ provide
+them.
+
+There are no real life examples showcasing this, it may not even be really needed by current use cases. Containers were built as an abstraction, with
+the thinking being that it would support any type of rendering of child embeddables - whether in a "snap to grid" style like dashboard,
+or in a free form layout like canvas.
+
+The only real implementation of a container in production code at the time this is written is Dashboard however, with no plans to migrate
+Canvas over to use it (this was the original impetus for an abstraction). The container code is quite complicated with child management,
+so it makes creating a new container very easy, as you can see in the developer examples of containers. But, it's possible this layer was
+ an over abstraction without a real prod use case (I can say that because I wrote it, I'm only insulting myself!) :).
+
+Be sure to read [Common mistakes with embeddable containers and inherited input state](./containers_and_inherited_state.md) next!
\ No newline at end of file
diff --git a/src/plugins/embeddable/public/lib/panel/panel_header/panel_header.tsx b/src/plugins/embeddable/public/lib/panel/panel_header/panel_header.tsx
index 8ba7be7880a7b..7b66f29cc2726 100644
--- a/src/plugins/embeddable/public/lib/panel/panel_header/panel_header.tsx
+++ b/src/plugins/embeddable/public/lib/panel/panel_header/panel_header.tsx
@@ -81,7 +81,7 @@ function renderNotifications(
if (tooltip) {
badge = (
-
+
{badge}
);
diff --git a/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap b/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap
index 1c67f332a12ab..bdf1f075967cb 100644
--- a/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap
+++ b/src/plugins/home/public/application/components/__snapshots__/welcome.test.tsx.snap
@@ -125,7 +125,6 @@ exports[`should render a Welcome screen with the telemetry disclaimer 1`] = `
values={Object {}}
/>
@@ -224,7 +223,6 @@ exports[`should render a Welcome screen with the telemetry disclaimer when optIn
values={Object {}}
/>
@@ -323,7 +321,6 @@ exports[`should render a Welcome screen with the telemetry disclaimer when optIn
values={Object {}}
/>
diff --git a/src/plugins/home/public/application/components/welcome.test.tsx b/src/plugins/home/public/application/components/welcome.test.tsx
index 1332e03ffdc81..701fab3af7539 100644
--- a/src/plugins/home/public/application/components/welcome.test.tsx
+++ b/src/plugins/home/public/application/components/welcome.test.tsx
@@ -30,56 +30,39 @@ jest.mock('../kibana_services', () => ({
}));
test('should render a Welcome screen with the telemetry disclaimer', () => {
- const telemetry = telemetryPluginMock.createSetupContract();
- const component = shallow(
- // @ts-ignore
- {}} telemetry={telemetry} />
- );
+ const telemetry = telemetryPluginMock.createStartContract();
+ const component = shallow( {}} telemetry={telemetry} />);
expect(component).toMatchSnapshot();
});
test('should render a Welcome screen with the telemetry disclaimer when optIn is true', () => {
- const telemetry = telemetryPluginMock.createSetupContract();
+ const telemetry = telemetryPluginMock.createStartContract();
telemetry.telemetryService.getIsOptedIn = jest.fn().mockReturnValue(true);
- const component = shallow(
- // @ts-ignore
- {}} telemetry={telemetry} />
- );
+ const component = shallow( {}} telemetry={telemetry} />);
expect(component).toMatchSnapshot();
});
test('should render a Welcome screen with the telemetry disclaimer when optIn is false', () => {
- const telemetry = telemetryPluginMock.createSetupContract();
+ const telemetry = telemetryPluginMock.createStartContract();
telemetry.telemetryService.getIsOptedIn = jest.fn().mockReturnValue(false);
- const component = shallow(
- // @ts-ignore
- {}} telemetry={telemetry} />
- );
+ const component = shallow( {}} telemetry={telemetry} />);
expect(component).toMatchSnapshot();
});
test('should render a Welcome screen with no telemetry disclaimer', () => {
- // @ts-ignore
- const component = shallow(
- // @ts-ignore
- {}} telemetry={null} />
- );
+ const component = shallow( {}} />);
expect(component).toMatchSnapshot();
});
test('fires opt-in seen when mounted', () => {
- const telemetry = telemetryPluginMock.createSetupContract();
+ const telemetry = telemetryPluginMock.createStartContract();
const mockSetOptedInNoticeSeen = jest.fn();
- // @ts-ignore
telemetry.telemetryNotifications.setOptedInNoticeSeen = mockSetOptedInNoticeSeen;
- shallow(
- // @ts-ignore
- {}} telemetry={telemetry} />
- );
+ shallow( {}} telemetry={telemetry} />);
expect(mockSetOptedInNoticeSeen).toHaveBeenCalled();
});
diff --git a/src/plugins/home/public/application/components/welcome.tsx b/src/plugins/home/public/application/components/welcome.tsx
index d4dcaca317806..f82bd024b80b8 100644
--- a/src/plugins/home/public/application/components/welcome.tsx
+++ b/src/plugins/home/public/application/components/welcome.tsx
@@ -38,7 +38,6 @@ import { METRIC_TYPE } from '@kbn/analytics';
import { FormattedMessage } from '@kbn/i18n/react';
import { getServices } from '../kibana_services';
import { TelemetryPluginStart } from '../../../../telemetry/public';
-import { PRIVACY_STATEMENT_URL } from '../../../../telemetry/common/constants';
import { SampleDataCard } from './sample_data';
interface Props {
@@ -162,7 +161,11 @@ export class Welcome extends React.Component {
id="home.dataManagementDisclaimerPrivacy"
defaultMessage="To learn about how usage data helps us manage and improve our products and services, see our "
/>
-
+
{
let savedObjectsClient: ReturnType;
- const createObj = (id: number): SavedObject => ({
+ const createObj = (id: number): SavedObjectsFindResult => ({
type: 'type',
id: `id-${id}`,
attributes: {},
+ score: 1,
references: [],
});
diff --git a/src/plugins/saved_objects_management/server/lib/find_relationships.test.ts b/src/plugins/saved_objects_management/server/lib/find_relationships.test.ts
index 2c8997c9af21a..e18a45d9bdf44 100644
--- a/src/plugins/saved_objects_management/server/lib/find_relationships.test.ts
+++ b/src/plugins/saved_objects_management/server/lib/find_relationships.test.ts
@@ -77,6 +77,7 @@ describe('findRelationships', () => {
type: 'parent-type',
id: 'parent-id',
attributes: {},
+ score: 1,
references: [],
},
],
diff --git a/src/plugins/telemetry/public/mocks.ts b/src/plugins/telemetry/public/mocks.ts
index 9ec4a3ae86cc7..dd7e5a4cc4ce3 100644
--- a/src/plugins/telemetry/public/mocks.ts
+++ b/src/plugins/telemetry/public/mocks.ts
@@ -25,7 +25,7 @@ import { httpServiceMock } from '../../../core/public/http/http_service.mock';
import { notificationServiceMock } from '../../../core/public/notifications/notifications_service.mock';
import { TelemetryService } from './services/telemetry_service';
import { TelemetryNotifications } from './services/telemetry_notifications/telemetry_notifications';
-import { TelemetryPluginStart, TelemetryPluginConfig } from './plugin';
+import { TelemetryPluginStart, TelemetryPluginSetup, TelemetryPluginConfig } from './plugin';
// The following is to be able to access private methods
/* eslint-disable dot-notation */
@@ -77,20 +77,35 @@ export function mockTelemetryNotifications({
});
}
-export type Setup = jest.Mocked;
+export type Setup = jest.Mocked;
+export type Start = jest.Mocked;
export const telemetryPluginMock = {
createSetupContract,
+ createStartContract,
};
function createSetupContract(): Setup {
const telemetryService = mockTelemetryService();
- const telemetryNotifications = mockTelemetryNotifications({ telemetryService });
const setupContract: Setup = {
telemetryService,
- telemetryNotifications,
};
return setupContract;
}
+
+function createStartContract(): Start {
+ const telemetryService = mockTelemetryService();
+ const telemetryNotifications = mockTelemetryNotifications({ telemetryService });
+
+ const startContract: Start = {
+ telemetryService,
+ telemetryNotifications,
+ telemetryConstants: {
+ getPrivacyStatementUrl: jest.fn(),
+ },
+ };
+
+ return startContract;
+}
diff --git a/src/plugins/telemetry/public/plugin.ts b/src/plugins/telemetry/public/plugin.ts
index a363953978d79..3846e7cb96a19 100644
--- a/src/plugins/telemetry/public/plugin.ts
+++ b/src/plugins/telemetry/public/plugin.ts
@@ -38,6 +38,7 @@ import {
getTelemetrySendUsageFrom,
} from '../common/telemetry_config';
import { getNotifyUserAboutOptInDefault } from '../common/telemetry_config/get_telemetry_notify_user_about_optin_default';
+import { PRIVACY_STATEMENT_URL } from '../common/constants';
export interface TelemetryPluginSetup {
telemetryService: TelemetryService;
@@ -46,6 +47,9 @@ export interface TelemetryPluginSetup {
export interface TelemetryPluginStart {
telemetryService: TelemetryService;
telemetryNotifications: TelemetryNotifications;
+ telemetryConstants: {
+ getPrivacyStatementUrl: () => string;
+ };
}
export interface TelemetryPluginConfig {
@@ -115,6 +119,9 @@ export class TelemetryPlugin implements Plugin PRIVACY_STATEMENT_URL,
+ },
};
}
diff --git a/test/api_integration/apis/saved_objects/find.js b/test/api_integration/apis/saved_objects/find.js
index 7a57d182bc812..7cb5955e4a43d 100644
--- a/test/api_integration/apis/saved_objects/find.js
+++ b/test/api_integration/apis/saved_objects/find.js
@@ -46,6 +46,7 @@ export default function ({ getService }) {
attributes: {
title: 'Count of requests',
},
+ score: 0,
migrationVersion: resp.body.saved_objects[0].migrationVersion,
references: [
{
@@ -134,6 +135,7 @@ export default function ({ getService }) {
.searchSourceJSON,
},
},
+ score: 0,
references: [
{
name: 'kibanaSavedObjectMeta.searchSourceJSON.index',
diff --git a/test/api_integration/apis/saved_objects_management/find.ts b/test/api_integration/apis/saved_objects_management/find.ts
index e15a9e989d21f..4d9f1c1658139 100644
--- a/test/api_integration/apis/saved_objects_management/find.ts
+++ b/test/api_integration/apis/saved_objects_management/find.ts
@@ -56,6 +56,7 @@ export default function ({ getService }: FtrProviderContext) {
type: 'index-pattern',
},
],
+ score: 0,
updated_at: '2017-09-21T18:51:23.794Z',
meta: {
editUrl:
diff --git a/test/common/services/kibana_server/kibana_server.ts b/test/common/services/kibana_server/kibana_server.ts
index 16039d6fee833..4a251cca044d3 100644
--- a/test/common/services/kibana_server/kibana_server.ts
+++ b/test/common/services/kibana_server/kibana_server.ts
@@ -27,9 +27,9 @@ export function KibanaServerProvider({ getService }: FtrProviderContext) {
const config = getService('config');
const lifecycle = getService('lifecycle');
const url = Url.format(config.get('servers.kibana'));
+ const ssl = config.get('servers.kibana').ssl;
const defaults = config.get('uiSettings.defaults');
-
- const kbn = new KbnClient(log, [url], defaults);
+ const kbn = new KbnClient(log, { url, ssl }, defaults);
if (defaults) {
lifecycle.beforeTests.add(async () => {
diff --git a/test/common/services/security/role.ts b/test/common/services/security/role.ts
index dfc6ff9b164e5..caa5549a70f0c 100644
--- a/test/common/services/security/role.ts
+++ b/test/common/services/security/role.ts
@@ -17,27 +17,20 @@
* under the License.
*/
-import axios, { AxiosInstance } from 'axios';
import util from 'util';
-import { ToolingLog } from '@kbn/dev-utils';
+import { KbnClient, ToolingLog } from '@kbn/dev-utils';
export class Role {
- private log: ToolingLog;
- private axios: AxiosInstance;
-
- constructor(url: string, log: ToolingLog) {
- this.log = log;
- this.axios = axios.create({
- headers: { 'kbn-xsrf': 'x-pack/ftr/services/security/role' },
- baseURL: url,
- maxRedirects: 0,
- validateStatus: () => true, // we do our own validation below and throw better error messages
- });
- }
+ constructor(private log: ToolingLog, private kibanaServer: KbnClient) {}
public async create(name: string, role: any) {
this.log.debug(`creating role ${name}`);
- const { data, status, statusText } = await this.axios.put(`/api/security/role/${name}`, role);
+ const { data, status, statusText } = await this.kibanaServer.request({
+ path: `/api/security/role/${name}`,
+ method: 'PUT',
+ body: role,
+ retries: 0,
+ });
if (status !== 204) {
throw new Error(
`Expected status code of 204, received ${status} ${statusText}: ${util.inspect(data)}`
@@ -47,7 +40,10 @@ export class Role {
public async delete(name: string) {
this.log.debug(`deleting role ${name}`);
- const { data, status, statusText } = await this.axios.delete(`/api/security/role/${name}`);
+ const { data, status, statusText } = await this.kibanaServer.request({
+ path: `/api/security/role/${name}`,
+ method: 'DELETE',
+ });
if (status !== 204 && status !== 404) {
throw new Error(
`Expected status code of 204 or 404, received ${status} ${statusText}: ${util.inspect(
diff --git a/test/common/services/security/role_mappings.ts b/test/common/services/security/role_mappings.ts
index cc2fa23825498..7951d4b5b47b2 100644
--- a/test/common/services/security/role_mappings.ts
+++ b/test/common/services/security/role_mappings.ts
@@ -17,30 +17,19 @@
* under the License.
*/
-import axios, { AxiosInstance } from 'axios';
import util from 'util';
-import { ToolingLog } from '@kbn/dev-utils';
+import { KbnClient, ToolingLog } from '@kbn/dev-utils';
export class RoleMappings {
- private log: ToolingLog;
- private axios: AxiosInstance;
-
- constructor(url: string, log: ToolingLog) {
- this.log = log;
- this.axios = axios.create({
- headers: { 'kbn-xsrf': 'x-pack/ftr/services/security/role_mappings' },
- baseURL: url,
- maxRedirects: 0,
- validateStatus: () => true, // we do our own validation below and throw better error messages
- });
- }
+ constructor(private log: ToolingLog, private kbnClient: KbnClient) {}
public async create(name: string, roleMapping: Record) {
this.log.debug(`creating role mapping ${name}`);
- const { data, status, statusText } = await this.axios.post(
- `/internal/security/role_mapping/${name}`,
- roleMapping
- );
+ const { data, status, statusText } = await this.kbnClient.request({
+ path: `/internal/security/role_mapping/${name}`,
+ method: 'POST',
+ body: roleMapping,
+ });
if (status !== 200) {
throw new Error(
`Expected status code of 200, received ${status} ${statusText}: ${util.inspect(data)}`
@@ -51,9 +40,10 @@ export class RoleMappings {
public async delete(name: string) {
this.log.debug(`deleting role mapping ${name}`);
- const { data, status, statusText } = await this.axios.delete(
- `/internal/security/role_mapping/${name}`
- );
+ const { data, status, statusText } = await this.kbnClient.request({
+ path: `/internal/security/role_mapping/${name}`,
+ method: 'DELETE',
+ });
if (status !== 200 && status !== 404) {
throw new Error(
`Expected status code of 200 or 404, received ${status} ${statusText}: ${util.inspect(
diff --git a/test/common/services/security/security.ts b/test/common/services/security/security.ts
index 6ad0933a2a5a2..fae4c9198cab6 100644
--- a/test/common/services/security/security.ts
+++ b/test/common/services/security/security.ts
@@ -17,8 +17,6 @@
* under the License.
*/
-import { format as formatUrl } from 'url';
-
import { Role } from './role';
import { User } from './user';
import { RoleMappings } from './role_mappings';
@@ -28,14 +26,14 @@ import { createTestUserService } from './test_user';
export async function SecurityServiceProvider(context: FtrProviderContext) {
const { getService } = context;
const log = getService('log');
- const config = getService('config');
- const url = formatUrl(config.get('servers.kibana'));
- const role = new Role(url, log);
- const user = new User(url, log);
+ const kibanaServer = getService('kibanaServer');
+
+ const role = new Role(log, kibanaServer);
+ const user = new User(log, kibanaServer);
const testUser = await createTestUserService(role, user, context);
return new (class SecurityService {
- roleMappings = new RoleMappings(url, log);
+ roleMappings = new RoleMappings(log, kibanaServer);
testUser = testUser;
role = role;
user = user;
diff --git a/test/common/services/security/user.ts b/test/common/services/security/user.ts
index ae02127043234..58c4d0f1cf34e 100644
--- a/test/common/services/security/user.ts
+++ b/test/common/services/security/user.ts
@@ -17,33 +17,22 @@
* under the License.
*/
-import axios, { AxiosInstance } from 'axios';
import util from 'util';
-import { ToolingLog } from '@kbn/dev-utils';
+import { KbnClient, ToolingLog } from '@kbn/dev-utils';
export class User {
- private log: ToolingLog;
- private axios: AxiosInstance;
-
- constructor(url: string, log: ToolingLog) {
- this.log = log;
- this.axios = axios.create({
- headers: { 'kbn-xsrf': 'x-pack/ftr/services/security/user' },
- baseURL: url,
- maxRedirects: 0,
- validateStatus: () => true, // we do our own validation below and throw better error messages
- });
- }
+ constructor(private log: ToolingLog, private kbnClient: KbnClient) {}
public async create(username: string, user: any) {
this.log.debug(`creating user ${username}`);
- const { data, status, statusText } = await this.axios.post(
- `/internal/security/users/${username}`,
- {
+ const { data, status, statusText } = await this.kbnClient.request({
+ path: `/internal/security/users/${username}`,
+ method: 'POST',
+ body: {
username,
...user,
- }
- );
+ },
+ });
if (status !== 200) {
throw new Error(
`Expected status code of 200, received ${status} ${statusText}: ${util.inspect(data)}`
@@ -54,9 +43,10 @@ export class User {
public async delete(username: string) {
this.log.debug(`deleting user ${username}`);
- const { data, status, statusText } = await this.axios.delete(
- `/internal/security/users/${username}`
- );
+ const { data, status, statusText } = await await this.kbnClient.request({
+ path: `/internal/security/users/${username}`,
+ method: 'DELETE',
+ });
if (status !== 204) {
throw new Error(
`Expected status code of 204, received ${status} ${statusText}: ${util.inspect(data)}`
diff --git a/test/functional/services/common/browser.ts b/test/functional/services/common/browser.ts
index 3297f6e094f7c..d6a4fc91481de 100644
--- a/test/functional/services/common/browser.ts
+++ b/test/functional/services/common/browser.ts
@@ -529,5 +529,10 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
await driver.executeScript('document.body.scrollLeft = ' + scrollSize);
return this.getScrollLeft();
}
+
+ public async switchToFrame(idOrElement: number | WebElementWrapper) {
+ const _id = idOrElement instanceof WebElementWrapper ? idOrElement._webElement : idOrElement;
+ await driver.switchTo().frame(_id);
+ }
})();
}
diff --git a/test/functional/services/remote/remote.ts b/test/functional/services/remote/remote.ts
index 5a3a775cae0c5..99643929c4682 100644
--- a/test/functional/services/remote/remote.ts
+++ b/test/functional/services/remote/remote.ts
@@ -23,7 +23,7 @@ import { resolve } from 'path';
import { mergeMap } from 'rxjs/operators';
import { FtrProviderContext } from '../../ftr_provider_context';
-import { initWebDriver } from './webdriver';
+import { initWebDriver, BrowserConfig } from './webdriver';
import { Browsers } from './browsers';
export async function RemoteProvider({ getService }: FtrProviderContext) {
@@ -58,12 +58,12 @@ export async function RemoteProvider({ getService }: FtrProviderContext) {
Fs.writeFileSync(path, JSON.stringify(JSON.parse(coverageJson), null, 2));
};
- const { driver, consoleLog$ } = await initWebDriver(
- log,
- browserType,
- lifecycle,
- config.get('browser.logPollingMs')
- );
+ const browserConfig: BrowserConfig = {
+ logPollingMs: config.get('browser.logPollingMs'),
+ acceptInsecureCerts: config.get('browser.acceptInsecureCerts'),
+ };
+
+ const { driver, consoleLog$ } = await initWebDriver(log, browserType, lifecycle, browserConfig);
const isW3CEnabled = (driver as any).executor_.w3c;
const caps = await driver.getCapabilities();
diff --git a/test/functional/services/remote/webdriver.ts b/test/functional/services/remote/webdriver.ts
index 9fbbf28bbf42c..27814060e70c1 100644
--- a/test/functional/services/remote/webdriver.ts
+++ b/test/functional/services/remote/webdriver.ts
@@ -73,13 +73,18 @@ Executor.prototype.execute = preventParallelCalls(
(command: { getName: () => string }) => NO_QUEUE_COMMANDS.includes(command.getName())
);
+export interface BrowserConfig {
+ logPollingMs: number;
+ acceptInsecureCerts: boolean;
+}
+
let attemptCounter = 0;
let edgePaths: { driverPath: string | undefined; browserPath: string | undefined };
async function attemptToCreateCommand(
log: ToolingLog,
browserType: Browsers,
lifecycle: Lifecycle,
- logPollingMs: number
+ config: BrowserConfig
) {
const attemptId = ++attemptCounter;
log.debug('[webdriver] Creating session');
@@ -114,6 +119,7 @@ async function attemptToCreateCommand(
if (certValidation === '0') {
chromeOptions.push('ignore-certificate-errors');
}
+
if (remoteDebug === '1') {
// Visit chrome://inspect in chrome to remotely view/debug
chromeOptions.push('headless', 'disable-gpu', 'remote-debugging-port=9222');
@@ -125,6 +131,7 @@ async function attemptToCreateCommand(
});
chromeCapabilities.set('unexpectedAlertBehaviour', 'accept');
chromeCapabilities.set('goog:loggingPrefs', { browser: 'ALL' });
+ chromeCapabilities.setAcceptInsecureCerts(config.acceptInsecureCerts);
const session = await new Builder()
.forBrowser(browserType)
@@ -137,7 +144,7 @@ async function attemptToCreateCommand(
consoleLog$: pollForLogEntry$(
session,
logging.Type.BROWSER,
- logPollingMs,
+ config.logPollingMs,
lifecycle.cleanup.after$
).pipe(
takeUntil(lifecycle.cleanup.after$),
@@ -174,7 +181,7 @@ async function attemptToCreateCommand(
consoleLog$: pollForLogEntry$(
session,
logging.Type.BROWSER,
- logPollingMs,
+ config.logPollingMs,
lifecycle.cleanup.after$
).pipe(
takeUntil(lifecycle.cleanup.after$),
@@ -206,6 +213,7 @@ async function attemptToCreateCommand(
'browser.helperApps.neverAsk.saveToDisk',
'application/comma-separated-values, text/csv, text/plain'
);
+ firefoxOptions.setAcceptInsecureCerts(config.acceptInsecureCerts);
if (headlessBrowser === '1') {
// See: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode
@@ -317,7 +325,7 @@ export async function initWebDriver(
log: ToolingLog,
browserType: Browsers,
lifecycle: Lifecycle,
- logPollingMs: number
+ config: BrowserConfig
) {
const logger = getLogger('webdriver.http.Executor');
logger.setLevel(logging.Level.FINEST);
@@ -348,7 +356,7 @@ export async function initWebDriver(
while (true) {
const command = await Promise.race([
delay(30 * SECOND),
- attemptToCreateCommand(log, browserType, lifecycle, logPollingMs),
+ attemptToCreateCommand(log, browserType, lifecycle, config),
]);
if (!command) {
diff --git a/test/scripts/jenkins_xpack_firefox_smoke.sh b/test/scripts/jenkins_xpack_firefox_smoke.sh
index fdaee76cafa9d..ae924a5e10552 100755
--- a/test/scripts/jenkins_xpack_firefox_smoke.sh
+++ b/test/scripts/jenkins_xpack_firefox_smoke.sh
@@ -7,4 +7,5 @@ checks-reporter-with-killswitch "X-Pack firefox smoke test" \
--debug --bail \
--kibana-install-dir "$KIBANA_INSTALL_DIR" \
--include-tag "includeFirefox" \
- --config test/functional/config.firefox.js;
+ --config test/functional/config.firefox.js \
+ --config test/functional_embedded/config.firefox.ts;
diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json
index 21b2df3ba12f8..278968cb47231 100644
--- a/x-pack/.i18nrc.json
+++ b/x-pack/.i18nrc.json
@@ -13,7 +13,6 @@
"xpack.crossClusterReplication": "plugins/cross_cluster_replication",
"xpack.dashboardMode": "legacy/plugins/dashboard_mode",
"xpack.data": "plugins/data_enhanced",
- "xpack.drilldowns": "plugins/drilldowns",
"xpack.embeddableEnhanced": "plugins/embeddable_enhanced",
"xpack.endpoint": "plugins/endpoint",
"xpack.features": "plugins/features",
diff --git a/x-pack/legacy/plugins/beats_management/common/config_block_validation.ts b/x-pack/legacy/plugins/beats_management/common/config_block_validation.ts
deleted file mode 100644
index f3d1b9164e976..0000000000000
--- a/x-pack/legacy/plugins/beats_management/common/config_block_validation.ts
+++ /dev/null
@@ -1,57 +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 * as t from 'io-ts';
-import { PathReporter } from 'io-ts/lib/PathReporter';
-import { isLeft } from 'fp-ts/lib/Either';
-import { configBlockSchemas } from './config_schemas';
-import { ConfigurationBlock, createConfigurationBlockInterface } from './domain_types';
-
-export const validateConfigurationBlocks = (configurationBlocks: ConfigurationBlock[]) => {
- const validationMap = {
- isHosts: t.array(t.string),
- isString: t.string,
- isPeriod: t.string,
- isPath: t.string,
- isPaths: t.array(t.string),
- isYaml: t.string,
- };
-
- for (const [index, block] of configurationBlocks.entries()) {
- const blockSchema = configBlockSchemas.find((s) => s.id === block.type);
- if (!blockSchema) {
- throw new Error(
- `Invalid config type of ${block.type} used in 'configuration_blocks' at index ${index}`
- );
- }
-
- const interfaceConfig = blockSchema.configs.reduce((props, config) => {
- if (config.options) {
- props[config.id] = t.keyof(
- Object.fromEntries(config.options.map((opt) => [opt.value, null])) as Record
- );
- } else if (config.validation) {
- props[config.id] = validationMap[config.validation];
- }
-
- return props;
- }, {} as t.Props);
-
- const runtimeInterface = createConfigurationBlockInterface(
- t.literal(blockSchema.id),
- t.interface(interfaceConfig)
- );
-
- const validationResults = runtimeInterface.decode(block);
-
- if (isLeft(validationResults)) {
- throw new Error(
- `configuration_blocks validation error, configuration_blocks at index ${index} is invalid. ${
- PathReporter.report(validationResults)[0]
- }`
- );
- }
- }
-};
diff --git a/x-pack/legacy/plugins/beats_management/common/config_schemas_translations_map.ts b/x-pack/legacy/plugins/beats_management/common/config_schemas_translations_map.ts
index 1aec3e8081708..7cae2a85dc4ca 100644
--- a/x-pack/legacy/plugins/beats_management/common/config_schemas_translations_map.ts
+++ b/x-pack/legacy/plugins/beats_management/common/config_schemas_translations_map.ts
@@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
import { ConfigBlockSchema } from './domain_types';
-export const supportedConfigLabelsMap = new Map([
+const supportedConfigLabelsMap = new Map([
[
'filebeatInputConfig.paths.ui.label',
i18n.translate('xpack.beatsManagement.filebeatInputConfig.pathsLabel', {
diff --git a/x-pack/legacy/plugins/beats_management/common/domain_types.ts b/x-pack/legacy/plugins/beats_management/common/domain_types.ts
index b4a9ac8a07479..32e1d81451c65 100644
--- a/x-pack/legacy/plugins/beats_management/common/domain_types.ts
+++ b/x-pack/legacy/plugins/beats_management/common/domain_types.ts
@@ -7,8 +7,6 @@ import * as t from 'io-ts';
import { configBlockSchemas } from './config_schemas';
import { DateFromString } from './io_ts_types';
-export const OutputTypesArray = ['elasticsearch', 'logstash', 'kafka', 'redis'];
-
// Here we create the runtime check for a generic, unknown beat config type.
// We can also pass in optional params to create spacific runtime checks that
// can be used to validate blocs on the API and UI
diff --git a/x-pack/legacy/plugins/beats_management/common/io_ts_types.ts b/x-pack/legacy/plugins/beats_management/common/io_ts_types.ts
index d77ad92298699..7d71ea5ad8256 100644
--- a/x-pack/legacy/plugins/beats_management/common/io_ts_types.ts
+++ b/x-pack/legacy/plugins/beats_management/common/io_ts_types.ts
@@ -7,7 +7,7 @@
import * as t from 'io-ts';
import { isRight } from 'fp-ts/lib/Either';
-export class DateFromStringType extends t.Type {
+class DateFromStringType extends t.Type {
// eslint-disable-next-line
public readonly _tag: 'DateFromISOStringType' = 'DateFromISOStringType';
constructor() {
diff --git a/x-pack/legacy/plugins/beats_management/common/return_types.ts b/x-pack/legacy/plugins/beats_management/common/return_types.ts
index a7125795a5c7d..7e0e39e12e60a 100644
--- a/x-pack/legacy/plugins/beats_management/common/return_types.ts
+++ b/x-pack/legacy/plugins/beats_management/common/return_types.ts
@@ -34,11 +34,6 @@ export interface ReturnTypeBulkCreate extends BaseReturnType {
}>;
}
-// delete
-export interface ReturnTypeDelete extends BaseReturnType {
- action: 'deleted';
-}
-
export interface ReturnTypeBulkDelete extends BaseReturnType {
results: Array<{
success: boolean;
@@ -84,12 +79,6 @@ export interface ReturnTypeBulkGet extends BaseReturnType {
items: T[];
}
-// action -- e.g. validate config block. Like ES simulate endpoint
-export interface ReturnTypeAction extends BaseReturnType {
- result: {
- [key: string]: any;
- };
-}
// e.g.
// {
// result: {
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/beats/memory_beats_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/beats/memory_beats_adapter.ts
deleted file mode 100644
index afae87c490158..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/beats/memory_beats_adapter.ts
+++ /dev/null
@@ -1,118 +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 { intersection, omit } from 'lodash';
-
-import { CMBeat } from '../../../../common/domain_types';
-import { FrameworkUser } from '../framework/adapter_types';
-import { BeatsTagAssignment, CMBeatsAdapter } from './adapter_types';
-
-export class MemoryBeatsAdapter implements CMBeatsAdapter {
- private beatsDB: CMBeat[];
-
- constructor(beatsDB: CMBeat[]) {
- this.beatsDB = beatsDB;
- }
-
- public async get(user: FrameworkUser, id: string) {
- return this.beatsDB.find((beat) => beat.id === id) || null;
- }
-
- public async insert(user: FrameworkUser, beat: CMBeat) {
- this.beatsDB.push(beat);
- }
-
- public async update(user: FrameworkUser, beat: CMBeat) {
- const beatIndex = this.beatsDB.findIndex((b) => b.id === beat.id);
-
- this.beatsDB[beatIndex] = {
- ...this.beatsDB[beatIndex],
- ...beat,
- };
- }
-
- public async getWithIds(user: FrameworkUser, beatIds: string[]) {
- return this.beatsDB.filter((beat) => beatIds.includes(beat.id));
- }
-
- public async getAllWithTags(user: FrameworkUser, tagIds: string[]): Promise {
- return this.beatsDB.filter((beat) => intersection(tagIds, beat.tags || []).length !== 0);
- }
-
- public async getBeatWithToken(
- user: FrameworkUser,
- enrollmentToken: string
- ): Promise {
- return this.beatsDB.find((beat) => enrollmentToken === beat.enrollment_token) || null;
- }
-
- public async getAll(user: FrameworkUser) {
- return this.beatsDB.map((beat: any) => omit(beat, ['access_token']));
- }
-
- public async removeTagsFromBeats(
- user: FrameworkUser,
- removals: BeatsTagAssignment[]
- ): Promise {
- const beatIds = removals.map((r) => r.beatId);
-
- const response = this.beatsDB
- .filter((beat) => beatIds.includes(beat.id))
- .map((beat) => {
- const tagData = removals.find((r) => r.beatId === beat.id);
- if (tagData) {
- if (beat.tags) {
- beat.tags = beat.tags.filter((tag) => tag !== tagData.tag);
- }
- }
- return beat;
- });
-
- return response.map((item: CMBeat, resultIdx: number) => ({
- idxInRequest: removals[resultIdx].idxInRequest,
- result: 'updated',
- status: 200,
- }));
- }
-
- public async assignTagsToBeats(
- user: FrameworkUser,
- assignments: BeatsTagAssignment[]
- ): Promise {
- const beatIds = assignments.map((r) => r.beatId);
-
- this.beatsDB
- .filter((beat) => beatIds.includes(beat.id))
- .map((beat) => {
- // get tags that need to be assigned to this beat
- const tags = assignments
- .filter((a) => a.beatId === beat.id)
- .map((t: BeatsTagAssignment) => t.tag);
-
- if (tags.length > 0) {
- if (!beat.tags) {
- beat.tags = [];
- }
- const nonExistingTags = tags.filter((t: string) => beat.tags && !beat.tags.includes(t));
-
- if (nonExistingTags.length > 0) {
- beat.tags = beat.tags.concat(nonExistingTags);
- }
- }
- return beat;
- });
-
- return assignments.map((item: BeatsTagAssignment, resultIdx: number) => ({
- idxInRequest: assignments[resultIdx].idxInRequest,
- result: 'updated',
- status: 200,
- }));
- }
-
- public setDB(beatsDB: CMBeat[]) {
- this.beatsDB = beatsDB;
- }
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/configuration_blocks/memory_tags_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/configuration_blocks/memory_tags_adapter.ts
deleted file mode 100644
index ea8a75c92fad2..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/configuration_blocks/memory_tags_adapter.ts
+++ /dev/null
@@ -1,75 +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 Chance from 'chance'; // eslint-disable-line
-import { ConfigurationBlock } from '../../../../common/domain_types';
-import { FrameworkUser } from '../framework/adapter_types';
-import { ConfigurationBlockAdapter } from './adapter_types';
-
-const chance = new Chance();
-
-export class MemoryConfigurationBlockAdapter implements ConfigurationBlockAdapter {
- private db: ConfigurationBlock[] = [];
-
- constructor(db: ConfigurationBlock[]) {
- this.db = db.map((config) => {
- if (config.id === undefined) {
- config.id = chance.word();
- }
- return config as ConfigurationBlock & { id: string };
- });
- }
-
- public async getByIds(user: FrameworkUser, ids: string[]) {
- return this.db.filter((block) => ids.includes(block.id));
- }
- public async delete(user: FrameworkUser, blockIds: string[]) {
- this.db = this.db.filter((block) => !blockIds.includes(block.id));
- return blockIds.map((id) => ({
- id,
- success: true,
- }));
- }
- public async deleteForTags(
- user: FrameworkUser,
- tagIds: string[]
- ): Promise<{ success: boolean; reason?: string }> {
- this.db = this.db.filter((block) => !tagIds.includes(block.tag));
- return {
- success: true,
- };
- }
-
- public async getForTags(user: FrameworkUser, tagIds: string[], page?: number, size?: number) {
- const results = this.db.filter((block) => tagIds.includes(block.id));
- return {
- page: 0,
- total: results.length,
- blocks: results,
- };
- }
-
- public async create(user: FrameworkUser, blocks: ConfigurationBlock[]) {
- return blocks.map((block) => {
- const existingIndex = this.db.findIndex((t) => t.id === block.id);
- if (existingIndex !== -1) {
- this.db[existingIndex] = block;
- } else {
- this.db.push(block);
- }
- return block.id;
- });
- }
-
- public setDB(db: ConfigurationBlock[]) {
- this.db = db.map((block) => {
- if (block.id === undefined) {
- block.id = chance.word();
- }
- return block;
- });
- }
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/__tests__/kibana.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/__tests__/kibana.ts
deleted file mode 100644
index 460fc412e9491..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/__tests__/kibana.ts
+++ /dev/null
@@ -1,40 +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.
- */
-// file.skip
-
-// @ts-ignore
-import { createLegacyEsTestCluster } from '@kbn/test';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { Root } from 'src/core/server/root';
-// @ts-ignore
-import * as kbnTestServer from '../../../../../../../../../src/test_utils/kbn_server';
-import { DatabaseKbnESPlugin } from '../adapter_types';
-import { KibanaDatabaseAdapter } from '../kibana_database_adapter';
-import { contractTests } from './test_contract';
-const es = createLegacyEsTestCluster({});
-
-let legacyServer: any;
-let rootServer: Root;
-contractTests('Kibana Database Adapter', {
- before: async () => {
- await es.start();
-
- rootServer = kbnTestServer.createRootWithCorePlugins({
- server: { maxPayloadBytes: 100 },
- });
-
- await rootServer.setup();
- legacyServer = kbnTestServer.getKbnServer(rootServer);
- return await legacyServer.plugins.elasticsearch.waitUntilReady();
- },
- after: async () => {
- await rootServer.shutdown();
- return await es.cleanup();
- },
- adapterSetup: () => {
- return new KibanaDatabaseAdapter(legacyServer.plugins.elasticsearch as DatabaseKbnESPlugin);
- },
-});
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/__tests__/test_contract.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/__tests__/test_contract.ts
deleted file mode 100644
index 369c2e1056211..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/__tests__/test_contract.ts
+++ /dev/null
@@ -1,58 +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 { DatabaseAdapter } from '../adapter_types';
-
-interface ContractConfig {
- before?(): Promise;
- after?(): Promise;
- adapterSetup(): DatabaseAdapter;
-}
-
-export const contractTests = (testName: string, config: ContractConfig) => {
- describe.skip(testName, () => {
- let database: DatabaseAdapter;
- beforeAll(async () => {
- jest.setTimeout(100000); // 1 second
-
- if (config.before) {
- await config.before();
- }
- });
- afterAll(async () => config.after && (await config.after()));
- beforeEach(async () => {
- database = config.adapterSetup();
- });
-
- it('Unauthorized users cant query', async () => {
- const params = {
- id: `beat:foo`,
- ignore: [404],
- index: '.management-beats',
- };
- let ranWithoutError = false;
- try {
- await database.get({ kind: 'unauthenticated' }, params);
- ranWithoutError = true;
- } catch (e) {
- expect(e).not.toEqual(null);
- }
- expect(ranWithoutError).toEqual(false);
- });
-
- it('Should query ES', async () => {
- const params = {
- id: `beat:foo`,
- ignore: [404],
- index: '.management-beats',
- };
- const response = await database.get({ kind: 'internal' }, params);
-
- expect(response).not.toEqual(undefined);
- // @ts-ignore
- expect(response.found).toEqual(undefined);
- });
- });
-};
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/adapter_types.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/adapter_types.ts
index 0a06c3dcc6412..90519840af213 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/adapter_types.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/adapter_types.ts
@@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
-import { FrameworkRequest, FrameworkUser } from '../framework/adapter_types';
+import { FrameworkUser } from '../framework/adapter_types';
export interface DatabaseAdapter {
get(
@@ -39,15 +39,6 @@ export interface DatabaseAdapter {
putTemplate(name: string, template: any): Promise;
}
-export interface DatabaseKbnESCluster {
- callWithInternalUser(esMethod: string, options: {}): Promise;
- callWithRequest(req: FrameworkRequest, esMethod: string, options: {}): Promise;
-}
-
-export interface DatabaseKbnESPlugin {
- getCluster(clusterName: string): DatabaseKbnESCluster;
-}
-
export interface DatabaseSearchParams extends DatabaseGenericParams {
analyzer?: string;
analyzeWildcard?: boolean;
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts
index 1ca3bcae8bfca..baccbe416f398 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/adapters/database/kibana_database_adapter.ts
@@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
+import { ElasticsearchServiceStart, IClusterClient } from 'src/core/server';
import { FrameworkUser } from '../framework/adapter_types';
import { internalAuthData } from './../framework/adapter_types';
import {
@@ -15,8 +16,6 @@ import {
DatabaseGetDocumentResponse,
DatabaseGetParams,
DatabaseIndexDocumentParams,
- DatabaseKbnESCluster,
- DatabaseKbnESPlugin,
DatabaseMGetParams,
DatabaseMGetResponse,
DatabaseSearchParams,
@@ -24,75 +23,67 @@ import {
} from './adapter_types';
export class KibanaDatabaseAdapter implements DatabaseAdapter {
- private es: DatabaseKbnESCluster;
+ private es: IClusterClient;
- constructor(kbnElasticSearch: DatabaseKbnESPlugin) {
- this.es = kbnElasticSearch.getCluster('admin');
+ constructor(elasticsearch: ElasticsearchServiceStart) {
+ this.es = elasticsearch.legacy.client;
}
public async get(
user: FrameworkUser,
params: DatabaseGetParams
): Promise> {
- const result = await this.callWithUser(user, 'get', params);
- return result;
- // todo
+ return await this.callWithUser(user, 'get', params);
}
public async mget(
user: FrameworkUser,
params: DatabaseMGetParams
): Promise> {
- const result = await this.callWithUser(user, 'mget', params);
- return result;
- // todo
+ return await this.callWithUser(user, 'mget', params);
}
public async bulk(user: FrameworkUser, params: DatabaseBulkIndexDocumentsParams): Promise {
- const result = await this.callWithUser(user, 'bulk', params);
- return result;
+ return await this.callWithUser(user, 'bulk', params);
}
public async create(
user: FrameworkUser,
params: DatabaseCreateDocumentParams
): Promise {
- const result = await this.callWithUser(user, 'create', params);
- return result;
+ return await this.callWithUser(user, 'create', params);
}
+
public async index(user: FrameworkUser, params: DatabaseIndexDocumentParams): Promise {
- const result = await this.callWithUser(user, 'index', params);
- return result;
+ return await this.callWithUser(user, 'index', params);
}
+
public async delete(
user: FrameworkUser,
params: DatabaseDeleteDocumentParams
): Promise {
- const result = await this.callWithUser(user, 'delete', params);
- return result;
+ return await this.callWithUser(user, 'delete', params);
}
public async deleteByQuery(
user: FrameworkUser,
params: DatabaseSearchParams
): Promise {
- const result = await this.callWithUser(user, 'deleteByQuery', params);
- return result;
+ return await this.callWithUser(user, 'deleteByQuery', params);
}
public async search(
user: FrameworkUser,
params: DatabaseSearchParams
): Promise> {
- const result = await this.callWithUser(user, 'search', params);
- return result;
+ return await this.callWithUser(user, 'search', params);
}
public async searchAll(
user: FrameworkUser,
params: DatabaseSearchParams
): Promise> {
- const result = await this.callWithUser(user, 'search', {
+ return await this.callWithUser(user, 'search', {
scroll: '1m',
...params,
body: {
@@ -100,29 +91,24 @@ export class KibanaDatabaseAdapter implements DatabaseAdapter {
...params.body,
},
});
- return result;
}
public async putTemplate(name: string, template: any): Promise {
- const result = await this.callWithUser({ kind: 'internal' }, 'indices.putTemplate', {
+ return await this.callWithUser({ kind: 'internal' }, 'indices.putTemplate', {
name,
body: template,
});
-
- return result;
}
private callWithUser(user: FrameworkUser, esMethod: string, options: any = {}): any {
if (user.kind === 'authenticated') {
- return this.es.callWithRequest(
- {
+ return this.es
+ .asScoped({
headers: user[internalAuthData],
- } as any,
- esMethod,
- options
- );
+ })
+ .callAsCurrentUser(esMethod, options);
} else if (user.kind === 'internal') {
- return this.es.callWithInternalUser(esMethod, options);
+ return this.es.callAsInternalUser(esMethod, options);
} else {
throw new Error('Invalid user type');
}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/events/adapter_types.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/events/adapter_types.ts
deleted file mode 100644
index 4cb38bb3d057b..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/events/adapter_types.ts
+++ /dev/null
@@ -1,12 +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 { BeatEvent } from '../../../../common/domain_types';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { FrameworkUser } from '../../../../../../../plugins/beats_management/public/lib/adapters/framework/adapter_types';
-
-export interface BeatEventsAdapter {
- bulkInsert(user: FrameworkUser, beatId: string, events: BeatEvent[]): Promise;
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.ts
deleted file mode 100644
index b5056140c8b86..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/events/elasticsearch_beat_events_adapter.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 { BeatEvent } from '../../../../common/domain_types';
-// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-import { FrameworkUser } from '../../../../../../../plugins/beats_management/public/lib/adapters/framework/adapter_types';
-import { DatabaseAdapter } from '../database/adapter_types';
-import { BeatEventsAdapter } from './adapter_types';
-
-export class ElasticsearchBeatEventsAdapter implements BeatEventsAdapter {
- // @ts-ignore
- constructor(private readonly database: DatabaseAdapter) {}
-
- // eslint-disable-next-line
- public bulkInsert = async (user: FrameworkUser, beatId: string, events: BeatEvent[]) => {
- // await this.database.putTemplate(INDEX_NAMES.EVENTS_TODAY, beatsIndexTemplate);
- };
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts
index 80599f38d982a..e2703cb5786dd 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts
@@ -8,6 +8,7 @@
import { Lifecycle, ResponseToolkit } from 'hapi';
import * as t from 'io-ts';
+import { CoreSetup, CoreStart } from 'src/core/server';
import { SecurityPluginSetup } from '../../../../../../../plugins/security/server';
import { LicenseType } from '../../../../common/constants/security';
@@ -33,7 +34,6 @@ export interface BackendFrameworkAdapter {
log(text: string): void;
on(event: 'xpack.status.green' | 'elasticsearch.status.green', cb: () => void): void;
getSetting(settingPath: string): any;
- exposeStaticDir(urlPath: string, dir: string): void;
registerRoute(
route: FrameworkRouteOptions
): void;
@@ -42,8 +42,12 @@ export interface BackendFrameworkAdapter {
export interface KibanaLegacyServer {
newPlatform: {
setup: {
+ core: CoreSetup;
plugins: { security: SecurityPluginSetup };
};
+ start: {
+ core: CoreStart;
+ };
};
plugins: {
xpack_main: {
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/hapi_framework_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/hapi_framework_adapter.ts
deleted file mode 100644
index 90500e0283511..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/hapi_framework_adapter.ts
+++ /dev/null
@@ -1,148 +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 { LicenseType } from './../../../../common/constants/security';
-import { KibanaServerRequest } from './adapter_types';
-import {
- BackendFrameworkAdapter,
- FrameworkInfo,
- FrameworkRequest,
- FrameworkResponse,
- FrameworkRouteOptions,
- internalAuthData,
- internalUser,
-} from './adapter_types';
-
-interface TestSettings {
- enrollmentTokensTtlInSeconds: number;
- encryptionKey: string;
-}
-
-export class HapiBackendFrameworkAdapter implements BackendFrameworkAdapter {
- public info: null | FrameworkInfo = null;
- public readonly internalUser = internalUser;
-
- private settings: TestSettings;
- private server: any;
-
- constructor(
- settings: TestSettings = {
- encryptionKey: 'something_who_cares',
- enrollmentTokensTtlInSeconds: 10 * 60, // 10 minutes
- },
- hapiServer?: any,
- license: LicenseType = 'trial',
- securityEnabled: boolean = true,
- licenseActive: boolean = true
- ) {
- this.server = hapiServer;
- this.settings = settings;
- const now = new Date();
-
- this.info = {
- kibana: {
- version: 'unknown',
- },
- license: {
- type: license,
- expired: !licenseActive,
- expiry_date_in_millis: new Date(now.getFullYear(), now.getMonth() + 1, 1).getTime(),
- },
- security: {
- enabled: securityEnabled,
- available: securityEnabled,
- },
- watcher: {
- enabled: true,
- available: true,
- },
- };
- }
- public log(text: string) {
- this.server.log(text);
- }
- public on(event: 'xpack.status.green', cb: () => void) {
- cb();
- }
- public getSetting(settingPath: string) {
- switch (settingPath) {
- case 'xpack.beats.enrollmentTokensTtlInSeconds':
- return this.settings.enrollmentTokensTtlInSeconds;
- case 'xpack.beats.encryptionKey':
- return this.settings.encryptionKey;
- }
- }
-
- public exposeStaticDir(urlPath: string, dir: string): void {
- if (!this.server) {
- throw new Error('Must pass a hapi server into the adapter to use exposeStaticDir');
- }
- this.server.route({
- handler: {
- directory: {
- path: dir,
- },
- },
- method: 'GET',
- path: urlPath,
- });
- }
-
- public registerRoute<
- RouteRequest extends FrameworkRequest,
- RouteResponse extends FrameworkResponse
- >(route: FrameworkRouteOptions) {
- if (!this.server) {
- throw new Error('Must pass a hapi server into the adapter to use registerRoute');
- }
- const wrappedHandler = (licenseRequired: string[]) => (request: any, h: any) => {
- return route.handler(this.wrapRequest(request), h);
- };
-
- this.server.route({
- handler: wrappedHandler(route.licenseRequired || []),
- method: route.method,
- path: route.path,
- config: {
- ...route.config,
- auth: false,
- },
- });
- }
-
- public async injectRequstForTesting({ method, url, headers, payload }: any) {
- return await this.server.inject({ method, url, headers, payload });
- }
-
- private wrapRequest(
- req: InternalRequest
- ): FrameworkRequest {
- const { params, payload, query, headers, info } = req;
-
- const isAuthenticated = headers.authorization != null;
-
- return {
- user: isAuthenticated
- ? {
- kind: 'authenticated',
- [internalAuthData]: headers,
- username: 'elastic',
- roles: ['superuser'],
- full_name: null,
- email: null,
- enabled: true,
- }
- : {
- kind: 'unauthenticated',
- },
- headers,
- info,
- params,
- payload,
- query,
- };
- }
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/integration_tests/kibana.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/integration_tests/kibana.ts
deleted file mode 100644
index 4f0ba01b86082..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/integration_tests/kibana.ts
+++ /dev/null
@@ -1,38 +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.
- */
-// file.skip
-
-import { camelCase } from 'lodash';
-// @ts-ignore
-import * as kbnTestServer from '../../../../../../../../../src/test_utils/kbn_server';
-// @ts-ignore
-import { TestKbnServerConfig } from '../../../../../../../test_utils/kbn_server_config';
-import { CONFIG_PREFIX } from '../../../../../common/constants/plugin';
-import { PLUGIN } from './../../../../../common/constants/plugin';
-import { KibanaBackendFrameworkAdapter } from './../kibana_framework_adapter';
-import { contractTests } from './test_contract';
-
-let kbnServer: any;
-let kbn: any;
-let esServer: any;
-contractTests('Kibana Framework Adapter', {
- async before() {
- const servers = kbnTestServer.createTestServers({
- adjustTimeout: (t: number) => jest.setTimeout(t),
- settings: TestKbnServerConfig,
- });
- esServer = await servers.startES();
- kbn = await servers.startKibana();
- kbnServer = kbn.kbnServer;
- },
- async after() {
- await kbn.stop();
- await esServer.stop();
- },
- adapterSetup: () => {
- return new KibanaBackendFrameworkAdapter(camelCase(PLUGIN.ID), kbnServer.server, CONFIG_PREFIX);
- },
-});
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/integration_tests/test_contract.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/integration_tests/test_contract.ts
deleted file mode 100644
index 8e21f8cf78ad7..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/integration_tests/test_contract.ts
+++ /dev/null
@@ -1,29 +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 { BackendFrameworkAdapter } from '../adapter_types';
-
-interface ContractConfig {
- before(): Promise;
- after(): Promise;
- adapterSetup(): BackendFrameworkAdapter;
-}
-
-export const contractTests = (testName: string, config: ContractConfig) => {
- describe(testName, () => {
- let frameworkAdapter: BackendFrameworkAdapter;
- beforeAll(config.before);
- afterAll(config.after);
- beforeEach(async () => {
- frameworkAdapter = config.adapterSetup();
- });
-
- it('Should have tests here', () => {
- expect(frameworkAdapter.info).toHaveProperty('server');
-
- expect(frameworkAdapter).toHaveProperty('server');
- });
- });
-};
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/kibana_framework_adapter.ts
index 1bf9bbb22b352..3b29e50e4465b 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/kibana_framework_adapter.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/kibana_framework_adapter.ts
@@ -68,18 +68,6 @@ export class KibanaBackendFrameworkAdapter implements BackendFrameworkAdapter {
this.server.log(text);
}
- public exposeStaticDir(urlPath: string, dir: string): void {
- this.server.route({
- handler: {
- directory: {
- path: dir,
- },
- },
- method: 'GET',
- path: urlPath,
- });
- }
-
public registerRoute<
RouteRequest extends FrameworkRequest,
RouteResponse extends FrameworkResponse
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/tags/memory_tags_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/tags/memory_tags_adapter.ts
deleted file mode 100644
index 66a6c7ebebc2c..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/tags/memory_tags_adapter.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 { BeatTag } from '../../../../common/domain_types';
-import { FrameworkUser } from '../framework/adapter_types';
-import { CMTagsAdapter } from './adapter_types';
-
-export class MemoryTagsAdapter implements CMTagsAdapter {
- private tagsDB: BeatTag[] = [];
-
- constructor(tagsDB: BeatTag[]) {
- this.tagsDB = tagsDB;
- }
-
- public async getAll(user: FrameworkUser) {
- return this.tagsDB;
- }
- public async delete(user: FrameworkUser, tagIds: string[]) {
- this.tagsDB = this.tagsDB.filter((tag) => !tagIds.includes(tag.id));
-
- return true;
- }
- public async getTagsWithIds(user: FrameworkUser, tagIds: string[]) {
- return this.tagsDB.filter((tag) => tagIds.includes(tag.id));
- }
-
- public async upsertTag(user: FrameworkUser, tag: BeatTag) {
- const existingTagIndex = this.tagsDB.findIndex((t) => t.id === tag.id);
- if (existingTagIndex !== -1) {
- this.tagsDB[existingTagIndex] = tag;
- } else {
- this.tagsDB.push(tag);
- }
- return tag.id;
- }
-
- public async getWithoutConfigTypes(
- user: FrameworkUser,
- blockTypes: string[]
- ): Promise {
- return this.tagsDB.filter((tag) => tag.hasConfigurationBlocksTypes.includes(blockTypes[0]));
- }
-
- public setDB(tagsDB: BeatTag[]) {
- this.tagsDB = tagsDB;
- }
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/tokens/memory_tokens_adapter.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/tokens/memory_tokens_adapter.ts
deleted file mode 100644
index 431263c808b45..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/tokens/memory_tokens_adapter.ts
+++ /dev/null
@@ -1,49 +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 { FrameworkAuthenticatedUser, FrameworkUser } from '../framework/adapter_types';
-import { CMTokensAdapter, TokenEnrollmentData } from './adapter_types';
-
-export class MemoryTokensAdapter implements CMTokensAdapter {
- private tokenDB: TokenEnrollmentData[];
-
- constructor(tokenDB: TokenEnrollmentData[]) {
- this.tokenDB = tokenDB;
- }
-
- public async deleteEnrollmentToken(user: FrameworkUser, enrollmentToken: string) {
- const index = this.tokenDB.findIndex((token) => token.token === enrollmentToken);
-
- if (index > -1) {
- this.tokenDB.splice(index, 1);
- }
- }
-
- public async getEnrollmentToken(
- user: FrameworkUser,
- tokenString: string
- ): Promise {
- return new Promise((resolve) => {
- return resolve(this.tokenDB.find((token) => token.token === tokenString));
- });
- }
-
- public async insertTokens(user: FrameworkAuthenticatedUser, tokens: TokenEnrollmentData[]) {
- tokens.forEach((token) => {
- const existingIndex = this.tokenDB.findIndex((t) => t.token === token.token);
- if (existingIndex !== -1) {
- this.tokenDB[existingIndex] = token;
- } else {
- this.tokenDB.push(token);
- }
- });
- return tokens;
- }
-
- public setDB(tokenDB: TokenEnrollmentData[]) {
- this.tokenDB = tokenDB;
- }
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/beat_events.ts b/x-pack/legacy/plugins/beats_management/server/lib/beat_events.ts
index f4cb3cb424f6f..54782783f94ca 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/beat_events.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/beat_events.ts
@@ -6,13 +6,11 @@
import { PathReporter } from 'io-ts/lib/PathReporter';
import { isLeft } from 'fp-ts/lib/Either';
import { BeatEvent, RuntimeBeatEvent } from '../../common/domain_types';
-import { BeatEventsAdapter } from './adapters/events/adapter_types';
import { FrameworkUser } from './adapters/framework/adapter_types';
import { CMBeatsDomain } from './beats';
export class BeatEventsLib {
- // @ts-ignore
- constructor(private readonly adapter: BeatEventsAdapter, private readonly beats: CMBeatsDomain) {}
+ constructor(private readonly beats: CMBeatsDomain) {}
public log = async (
user: FrameworkUser,
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/beats.ts b/x-pack/legacy/plugins/beats_management/server/lib/beats.ts
index 3b9c4d35d8331..6b7053f40550b 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/beats.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/beats.ts
@@ -7,7 +7,6 @@
import { uniq } from 'lodash';
import moment from 'moment';
import { CMBeat } from '../../common/domain_types';
-import { findNonExistentItems } from '../utils/find_non_existent_items';
import {
BeatsRemovalReturn,
BeatsTagAssignment,
@@ -249,3 +248,12 @@ function addToResultsToResponse(key: string, response: any, assignmentResults: a
});
return response;
}
+
+export function findNonExistentItems(items: Array<{ id: string }>, requestedItems: string[]) {
+ return requestedItems.reduce((nonExistentItems: string[], requestedItem: string, idx: number) => {
+ if (items.findIndex((item) => item && item.id === requestedItem) === -1) {
+ nonExistentItems.push(requestedItems[idx]);
+ }
+ return nonExistentItems;
+ }, []);
+}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/compose/kibana.ts b/x-pack/legacy/plugins/beats_management/server/lib/compose/kibana.ts
index 2bda2fe85d62f..b6a645ded8164 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/compose/kibana.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/compose/kibana.ts
@@ -9,9 +9,7 @@ import { PLUGIN } from '../../../common/constants';
import { CONFIG_PREFIX } from '../../../common/constants/plugin';
import { ElasticsearchBeatsAdapter } from '../adapters/beats/elasticsearch_beats_adapter';
import { ElasticsearchConfigurationBlockAdapter } from '../adapters/configuration_blocks/elasticsearch_configuration_block_adapter';
-import { DatabaseKbnESPlugin } from '../adapters/database/adapter_types';
import { KibanaDatabaseAdapter } from '../adapters/database/kibana_database_adapter';
-import { ElasticsearchBeatEventsAdapter } from '../adapters/events/elasticsearch_beat_events_adapter';
import { KibanaLegacyServer } from '../adapters/framework/adapter_types';
import { KibanaBackendFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter';
import { ElasticsearchTagsAdapter } from '../adapters/tags/elasticsearch_tags_adapter';
@@ -28,7 +26,7 @@ export function compose(server: KibanaLegacyServer): CMServerLibs {
const framework = new BackendFrameworkLib(
new KibanaBackendFrameworkAdapter(camelCase(PLUGIN.ID), server, CONFIG_PREFIX)
);
- const database = new KibanaDatabaseAdapter(server.plugins.elasticsearch as DatabaseKbnESPlugin);
+ const database = new KibanaDatabaseAdapter(server.newPlatform.start.core.elasticsearch);
const beatsAdapter = new ElasticsearchBeatsAdapter(database);
const configAdapter = new ElasticsearchConfigurationBlockAdapter(database);
@@ -46,7 +44,7 @@ export function compose(server: KibanaLegacyServer): CMServerLibs {
tokens,
framework,
});
- const beatEvents = new BeatEventsLib(new ElasticsearchBeatEventsAdapter(database), beats);
+ const beatEvents = new BeatEventsLib(beats);
const libs: CMServerLibs = {
beatEvents,
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/compose/testing.ts b/x-pack/legacy/plugins/beats_management/server/lib/compose/testing.ts
deleted file mode 100644
index b5fe6195fc7c7..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/lib/compose/testing.ts
+++ /dev/null
@@ -1,51 +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 { MemoryBeatsAdapter } from '../adapters/beats/memory_beats_adapter';
-import { MemoryConfigurationBlockAdapter } from '../adapters/configuration_blocks/memory_tags_adapter';
-import { HapiBackendFrameworkAdapter } from '../adapters/framework/hapi_framework_adapter';
-import { MemoryTagsAdapter } from '../adapters/tags/memory_tags_adapter';
-import { MemoryTokensAdapter } from '../adapters/tokens/memory_tokens_adapter';
-import { BeatEventsLib } from '../beat_events';
-import { CMBeatsDomain } from '../beats';
-import { ConfigurationBlocksLib } from '../configuration_blocks';
-import { BackendFrameworkLib } from '../framework';
-import { CMTagsDomain } from '../tags';
-import { CMTokensDomain } from '../tokens';
-import { CMServerLibs } from '../types';
-
-export function compose(server: any): CMServerLibs {
- const framework = new BackendFrameworkLib(new HapiBackendFrameworkAdapter(undefined, server));
-
- const beatsAdapter = new MemoryBeatsAdapter(server.beatsDB || []);
- const configAdapter = new MemoryConfigurationBlockAdapter(server.configsDB || []);
- const tags = new CMTagsDomain(
- new MemoryTagsAdapter(server.tagsDB || []),
- configAdapter,
- beatsAdapter
- );
- const configurationBlocks = new ConfigurationBlocksLib(configAdapter, tags);
- const tokens = new CMTokensDomain(new MemoryTokensAdapter(server.tokensDB || []), {
- framework,
- });
- const beats = new CMBeatsDomain(beatsAdapter, {
- tags,
- tokens,
- framework,
- });
- const beatEvents = new BeatEventsLib({} as any, beats);
-
- const libs: CMServerLibs = {
- beatEvents,
- framework,
- beats,
- tags,
- tokens,
- configurationBlocks,
- };
-
- return libs;
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/lib/framework.ts b/x-pack/legacy/plugins/beats_management/server/lib/framework.ts
index 1a6f84a6979c6..96a06929073e5 100644
--- a/x-pack/legacy/plugins/beats_management/server/lib/framework.ts
+++ b/x-pack/legacy/plugins/beats_management/server/lib/framework.ts
@@ -16,7 +16,6 @@ import {
export class BackendFrameworkLib {
public log = this.adapter.log;
public on = this.adapter.on.bind(this.adapter);
- public exposeStaticDir = this.adapter.exposeStaticDir;
public internalUser = this.adapter.internalUser;
constructor(private readonly adapter: BackendFrameworkAdapter) {
this.validateConfig();
diff --git a/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts b/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts
deleted file mode 100644
index 156304443431d..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/beats_assignments.test.ts
+++ /dev/null
@@ -1,249 +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 { CMServerLibs } from '../../lib/types';
-import { HapiBackendFrameworkAdapter } from './../../lib/adapters/framework/hapi_framework_adapter';
-import { testHarnes } from './test_harnes';
-
-describe('assign_tags_to_beats', () => {
- let serverLibs: CMServerLibs;
-
- beforeAll(async () => {
- jest.setTimeout(100000); // 1 second
-
- serverLibs = await testHarnes.getServerLibs();
- });
- beforeEach(async () => await testHarnes.loadData());
-
- it('should add a single tag to a single beat', async () => {
- const { result, statusCode } = await ((serverLibs.framework as any)
- .adapter as HapiBackendFrameworkAdapter).injectRequstForTesting({
- method: 'POST',
- url: '/api/beats/agents_tags/assignments',
- headers: {
- 'kbn-xsrf': 'xxx',
- authorization: 'loggedin',
- },
- payload: {
- assignments: [{ beatId: 'bar', tag: 'production' }],
- },
- });
-
- expect(statusCode).toEqual(200);
- expect(result.results).toEqual([{ success: true, result: { message: 'updated' } }]);
- });
-
- it('should not re-add an existing tag to a beat', async () => {
- const { result, statusCode } = await ((serverLibs.framework as any)
- .adapter as HapiBackendFrameworkAdapter).injectRequstForTesting({
- method: 'POST',
- url: '/api/beats/agents_tags/assignments',
- headers: {
- 'kbn-xsrf': 'xxx',
- authorization: 'loggedin',
- },
- payload: {
- assignments: [{ beatId: 'foo', tag: 'production' }],
- },
- });
-
- expect(statusCode).toEqual(200);
-
- expect(result.results).toEqual([{ success: true, result: { message: 'updated' } }]);
-
- const beat = await serverLibs.beats.getById(
- {
- kind: 'internal',
- },
- 'foo'
- );
- expect(beat!.tags).toEqual(['production', 'qa']); // as
- });
-
- it('should add a single tag to a multiple beats', async () => {
- const { result, statusCode } = await ((serverLibs.framework as any)
- .adapter as HapiBackendFrameworkAdapter).injectRequstForTesting({
- method: 'POST',
- url: '/api/beats/agents_tags/assignments',
- headers: {
- 'kbn-xsrf': 'xxx',
- authorization: 'loggedin',
- },
- payload: {
- assignments: [
- { beatId: 'foo', tag: 'development' },
- { beatId: 'bar', tag: 'development' },
- ],
- },
- });
-
- expect(statusCode).toEqual(200);
-
- expect(result.results).toEqual([
- { success: true, result: { message: 'updated' } },
- { success: true, result: { message: 'updated' } },
- ]);
-
- let beat;
-
- beat = await serverLibs.beats.getById(
- {
- kind: 'internal',
- },
- 'foo'
- );
- expect(beat!.tags).toEqual(['production', 'qa', 'development']); // as beat 'foo' already had 'production' and 'qa' tags attached to it
-
- // Beat bar
- beat = await serverLibs.beats.getById(
- {
- kind: 'internal',
- },
- 'bar'
- );
-
- expect(beat!.tags).toEqual(['development']);
- });
-
- it('should add multiple tags to a single beat', async () => {
- const { result, statusCode } = await ((serverLibs.framework as any)
- .adapter as HapiBackendFrameworkAdapter).injectRequstForTesting({
- method: 'POST',
- url: '/api/beats/agents_tags/assignments',
- headers: {
- 'kbn-xsrf': 'xxx',
- authorization: 'loggedin',
- },
- payload: {
- assignments: [
- { beatId: 'bar', tag: 'development' },
- { beatId: 'bar', tag: 'production' },
- ],
- },
- });
-
- expect(statusCode).toEqual(200);
-
- expect(result.results).toEqual([
- { success: true, result: { message: 'updated' } },
- { success: true, result: { message: 'updated' } },
- ]);
-
- const beat = await serverLibs.beats.getById(
- {
- kind: 'internal',
- },
- 'bar'
- );
-
- expect(beat!.tags).toEqual(['development', 'production']);
- });
-
- // it('should add multiple tags to a multiple beats', async () => {
- // const { body: apiResponse } = await supertest
- // .post('/api/beats/agents_tags/assignments')
- // .set('kbn-xsrf', 'xxx')
- // .send({
- // assignments: [{ beatId: 'foo', tag: 'development' }, { beatId: 'bar', tag: 'production' }],
- // })
- // .expect(200);
-
- // expect(apiResponse.assignments).to.eql([
- // { status: 200, result: 'updated' },
- // { status: 200, result: 'updated' },
- // ]);
-
- // let esResponse;
- // let beat;
-
- // // Beat foo
- // esResponse = await es.get({
- // index: ES_INDEX_NAME,
- // type: ES_TYPE_NAME,
- // id: `beat:foo`,
- // });
-
- // beat = esResponse._source.beat;
- // expect(beat.tags).to.eql(['production', 'qa', 'development']); // as beat 'foo' already had 'production' and 'qa' tags attached to it
-
- // // Beat bar
- // esResponse = await es.get({
- // index: ES_INDEX_NAME,
- // type: ES_TYPE_NAME,
- // id: `beat:bar`,
- // });
-
- // beat = esResponse._source.beat;
- // expect(beat.tags).to.eql(['production']);
- // });
-
- // it('should return errors for non-existent beats', async () => {
- // const nonExistentBeatId = chance.word();
-
- // const { body: apiResponse } = await supertest
- // .post('/api/beats/agents_tags/assignments')
- // .set('kbn-xsrf', 'xxx')
- // .send({
- // assignments: [{ beatId: nonExistentBeatId, tag: 'production' }],
- // })
- // .expect(200);
-
- // expect(apiResponse.assignments).to.eql([
- // { status: 404, result: `Beat ${nonExistentBeatId} not found` },
- // ]);
- // });
-
- // it('should return errors for non-existent tags', async () => {
- // const nonExistentTag = chance.word();
-
- // const { body: apiResponse } = await supertest
- // .post('/api/beats/agents_tags/assignments')
- // .set('kbn-xsrf', 'xxx')
- // .send({
- // assignments: [{ beatId: 'bar', tag: nonExistentTag }],
- // })
- // .expect(200);
-
- // expect(apiResponse.assignments).to.eql([
- // { status: 404, result: `Tag ${nonExistentTag} not found` },
- // ]);
-
- // const esResponse = await es.get({
- // index: ES_INDEX_NAME,
- // type: ES_TYPE_NAME,
- // id: `beat:bar`,
- // });
-
- // const beat = esResponse._source.beat;
- // expect(beat).to.not.have.property('tags');
- // });
-
- // it('should return errors for non-existent beats and tags', async () => {
- // const nonExistentBeatId = chance.word();
- // const nonExistentTag = chance.word();
-
- // const { body: apiResponse } = await supertest
- // .post('/api/beats/agents_tags/assignments')
- // .set('kbn-xsrf', 'xxx')
- // .send({
- // assignments: [{ beatID: nonExistentBeatId, tag: nonExistentTag }],
- // })
- // .expect(200);
-
- // expect(apiResponse.assignments).to.eql([
- // { status: 404, result: `Beat ${nonExistentBeatId} and tag ${nonExistentTag} not found` },
- // ]);
-
- // const esResponse = await es.get({
- // index: ES_INDEX_NAME,
- // type: ES_TYPE_NAME,
- // id: `beat:bar`,
- // });
-
- // const beat = esResponse._source.beat;
- // expect(beat).to.not.have.property('tags');
- // });
-});
diff --git a/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/data.json b/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/data.json
deleted file mode 100644
index 4ee5a4a7e2d55..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/data.json
+++ /dev/null
@@ -1,178 +0,0 @@
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "beat:qux",
- "source": {
- "type": "beat",
- "beat": {
- "type": "filebeat",
- "active": true,
- "host_ip": "1.2.3.4",
- "host_name": "foo.bar.com",
- "id": "qux",
- "name": "qux_filebeat",
- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "beat:baz",
- "source": {
- "type": "beat",
- "beat": {
- "type": "metricbeat",
- "active": true,
- "host_ip": "22.33.11.44",
- "host_name": "baz.bar.com",
- "id": "baz",
- "name": "baz_metricbeat",
- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "beat:foo",
- "source": {
- "type": "beat",
- "beat": {
- "type": "metricbeat",
- "active": true,
- "host_ip": "1.2.3.4",
- "host_name": "foo.bar.com",
- "id": "foo",
- "name": "foo_metricbeat",
- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI",
- "verified_on": "2018-05-15T16:25:38.924Z",
- "tags": [
- "production",
- "qa"
- ]
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "beat:bar",
- "source": {
- "type": "beat",
- "beat": {
- "type": "filebeat",
- "active": true,
- "host_ip": "11.22.33.44",
- "host_name": "foo.com",
- "id": "bar",
- "name": "bar_filebeat",
- "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdGVkIjoiMjAxOC0wNi0zMFQwMzo0MjoxNS4yMzBaIiwiaWF0IjoxNTMwMzMwMTM1fQ.SSsX2Byyo1B1bGxV8C3G4QldhE5iH87EY_1r21-bwbI"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "tag:production",
- "source": {
- "type": "tag",
- "tag": {
- "color": "blue"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "tag:development",
- "source": {
- "type": "tag",
- "tag": {
- "color": "red"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "tag:qa",
- "source": {
- "type": "tag",
- "tag": {
- "color": "green"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "configuration_block:SDfsdfIBdsfsf50zbta",
- "source": {
- "type": "configuration_block",
- "configuration_block": {
- "type": "output",
- "description": "some description",
- "tag": "production",
- "last_updated": "2018-05-15T16:25:38.924Z",
- "config": "{ \"username\": \"some-username\", \"hosts\": [\"localhost:11211\"] }"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "configuration_block:W0tpsmIBdsfsf50zbta",
- "source": {
- "type": "configuration_block",
- "configuration_block": {
- "type": "metricbeat.modules",
- "tag": "production",
- "last_updated": "2018-05-15T16:25:38.924Z",
- "config": "{ \"module\": \"memcached\", \"hosts\": [\"localhost:11211\"] }"
- }
- }
- }
-}
-
-{
- "value": {
- "index": ".management-beats",
- "type": "_doc",
- "id": "configuration_block:W0tpsmIBdwcYyG50zbta",
- "source": {
- "type": "configuration_block",
- "configuration_block": {
- "type": "metricbeat.modules",
- "tag": "qa",
- "last_updated": "2018-05-15T16:25:38.924Z",
- "config": "{\"module\": \"memcached\", \"node.namespace\": \"node\", \"hosts\": [\"localhost:4949\"] }"
- }
- }
- }
-}
\ No newline at end of file
diff --git a/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/test_harnes.ts b/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/test_harnes.ts
deleted file mode 100644
index 590ce0bd7b287..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/rest_api/__tests__/test_harnes.ts
+++ /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 { badRequest } from 'boom';
-import { readFile } from 'fs';
-// @ts-ignore
-import Hapi from 'hapi';
-import { resolve } from 'path';
-import { promisify } from 'util';
-import { BeatTag, CMBeat } from '../../../common/domain_types';
-import { TokenEnrollmentData } from '../../lib/adapters/tokens/adapter_types';
-import { compose } from '../../lib/compose/testing';
-import { CMServerLibs } from '../../lib/types';
-import { initManagementServer } from './../../management_server';
-
-const readFileAsync = promisify(readFile);
-let serverLibs: CMServerLibs;
-
-export const testHarnes = {
- description: 'API Development Tests',
- loadData: async () => {
- if (!serverLibs) {
- throw new Error('Server libs not composed yet...');
- }
- const contents = await readFileAsync(resolve(__dirname, './data.json'), 'utf8');
- const database = contents.split(/\n\n/);
-
- // @ts-ignore the private access
- serverLibs.beats.adapter.setDB(
- database.reduce((inserts: CMBeat[], source) => {
- const type = 'beat';
- const data = JSON.parse(source);
-
- if (data.value.source.type === type) {
- inserts.push({
- id: data.value.id.substring(data.value.id.indexOf(':') + 1),
- ...data.value.source[type],
- });
- }
- return inserts;
- }, [])
- );
-
- // @ts-ignore the private access
- serverLibs.tags.adapter.setDB(
- database.reduce((inserts: BeatTag[], source) => {
- const type = 'tag';
- const data = JSON.parse(source);
-
- if (data.value.source.type === type) {
- inserts.push({
- id: data.value.id.substring(data.value.id.indexOf(':') + 1),
- ...data.value.source[type],
- });
- }
- return inserts;
- }, [])
- );
-
- // @ts-ignore the private access
- serverLibs.tokens.adapter.setDB(
- database.reduce((inserts: TokenEnrollmentData[], source) => {
- const type = 'token';
- const data = JSON.parse(source);
-
- if (data.value.source.type === type) {
- inserts.push({
- id: data.value.id.substring(data.value.id.indexOf(':') + 1),
- ...data.value.source[type],
- });
- }
- return inserts;
- }, [])
- );
- },
- getServerLibs: async () => {
- if (!serverLibs) {
- const server = new Hapi.Server({ port: 111111 });
- const versionHeader = 'kbn-version';
- const xsrfHeader = 'kbn-xsrf';
-
- server.ext('onPostAuth', (req: any, h: any) => {
- const isSafeMethod = req.method === 'get' || req.method === 'head';
- const hasVersionHeader = versionHeader in req.headers;
- const hasXsrfHeader = xsrfHeader in req.headers;
-
- if (!isSafeMethod && !hasVersionHeader && !hasXsrfHeader) {
- throw badRequest(`Request must contain a ${xsrfHeader} header.`);
- }
-
- return h.continue;
- });
-
- serverLibs = compose(server);
- initManagementServer(serverLibs);
- }
- return serverLibs;
- },
-};
diff --git a/x-pack/legacy/plugins/beats_management/server/utils/README.md b/x-pack/legacy/plugins/beats_management/server/utils/README.md
deleted file mode 100644
index 8a6a27aa29867..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/utils/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Utils should be data processing functions and other tools.... all in all utils is basicly everything that is not an adaptor, or presenter and yet too much to put in a lib.
\ No newline at end of file
diff --git a/x-pack/legacy/plugins/beats_management/server/utils/find_non_existent_items.ts b/x-pack/legacy/plugins/beats_management/server/utils/find_non_existent_items.ts
deleted file mode 100644
index 0e9b4f0b6fa5e..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/utils/find_non_existent_items.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.
- */
-
-interface RandomItem {
- id: string;
- [key: string]: any;
-}
-
-export function findNonExistentItems(items: RandomItem[], requestedItems: any) {
- return requestedItems.reduce((nonExistentItems: string[], requestedItem: string, idx: number) => {
- if (items.findIndex((item: RandomItem) => item && item.id === requestedItem) === -1) {
- nonExistentItems.push(requestedItems[idx]);
- }
- return nonExistentItems;
- }, []);
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/utils/helper_types.ts b/x-pack/legacy/plugins/beats_management/server/utils/helper_types.ts
deleted file mode 100644
index 96f7b7bc79b62..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/utils/helper_types.ts
+++ /dev/null
@@ -1,13 +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 type InterfaceExcept = Pick>;
-
-export function arrayFromEnum(e: any): T[] {
- return Object.keys(e)
- .filter((key) => isNaN(+key))
- .map((name) => e[name]) as T[];
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/utils/index_templates/beats_template.json b/x-pack/legacy/plugins/beats_management/server/utils/index_templates/beats_template.json
deleted file mode 100644
index ba3a0aba6c256..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/utils/index_templates/beats_template.json
+++ /dev/null
@@ -1,119 +0,0 @@
-{
- "index_patterns": [".management-beats"],
- "version": 66000,
- "settings": {
- "index": {
- "number_of_shards": 1,
- "auto_expand_replicas": "0-1",
- "codec": "best_compression"
- }
- },
- "mappings": {
- "_doc": {
- "dynamic": "strict",
- "properties": {
- "type": {
- "type": "keyword"
- },
- "configuration_block": {
- "properties": {
- "id": {
- "type": "keyword"
- },
- "type": {
- "type": "keyword"
- },
- "tag": {
- "type": "keyword"
- },
- "description": {
- "type": "text"
- },
- "config": {
- "type": "keyword"
- },
- "last_updated": {
- "type": "date"
- }
- }
- },
- "enrollment_token": {
- "properties": {
- "token": {
- "type": "keyword"
- },
- "expires_on": {
- "type": "date"
- }
- }
- },
- "tag": {
- "properties": {
- "id": {
- "type": "keyword"
- },
- "name": {
- "type": "keyword"
- },
- "color": {
- "type": "keyword"
- },
- "hasConfigurationBlocksTypes": {
- "type": "keyword"
- }
- }
- },
- "beat": {
- "properties": {
- "id": {
- "type": "keyword"
- },
- "config_status": {
- "type": "keyword"
- },
- "active": {
- "type": "boolean"
- },
- "last_checkin": {
- "type": "date"
- },
- "enrollment_token": {
- "type": "keyword"
- },
- "access_token": {
- "type": "keyword"
- },
- "verified_on": {
- "type": "date"
- },
- "type": {
- "type": "keyword"
- },
- "version": {
- "type": "keyword"
- },
- "host_ip": {
- "type": "ip"
- },
- "host_name": {
- "type": "keyword"
- },
- "ephemeral_id": {
- "type": "keyword"
- },
- "tags": {
- "type": "keyword"
- },
- "metadata": {
- "dynamic": "true",
- "type": "object"
- },
- "name": {
- "type": "keyword"
- }
- }
- }
- }
- }
- }
-}
diff --git a/x-pack/legacy/plugins/beats_management/server/utils/polyfills.ts b/x-pack/legacy/plugins/beats_management/server/utils/polyfills.ts
deleted file mode 100644
index 5291e2c72be7d..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/utils/polyfills.ts
+++ /dev/null
@@ -1,17 +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 entries = (obj: any) => {
- const ownProps = Object.keys(obj);
- let i = ownProps.length;
- const resArray = new Array(i); // preallocate the Array
-
- while (i--) {
- resArray[i] = [ownProps[i], obj[ownProps[i]]];
- }
-
- return resArray;
-};
diff --git a/x-pack/legacy/plugins/beats_management/server/utils/wrap_request.ts b/x-pack/legacy/plugins/beats_management/server/utils/wrap_request.ts
deleted file mode 100644
index 57cf70a99a296..0000000000000
--- a/x-pack/legacy/plugins/beats_management/server/utils/wrap_request.ts
+++ /dev/null
@@ -1,36 +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 {
- FrameworkRequest,
- internalAuthData,
- KibanaServerRequest,
-} from '../lib/adapters/framework/adapter_types';
-
-export function wrapRequest(
- req: InternalRequest
-): FrameworkRequest {
- const { params, payload, query, headers, info } = req;
-
- const isAuthenticated = headers.authorization != null;
-
- return {
- // @ts-ignore -- partial applucation, adapter adds other user data
- user: isAuthenticated
- ? {
- kind: 'authenticated',
- [internalAuthData]: headers,
- }
- : {
- kind: 'unauthenticated',
- },
- headers,
- info,
- params,
- payload,
- query,
- };
-}
diff --git a/x-pack/legacy/plugins/beats_management/types/eui.d.ts b/x-pack/legacy/plugins/beats_management/types/eui.d.ts
deleted file mode 100644
index 636d0a2f7b51e..0000000000000
--- a/x-pack/legacy/plugins/beats_management/types/eui.d.ts
+++ /dev/null
@@ -1,16 +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.
- */
-
-/**
- * /!\ These type definitions are temporary until the upstream @elastic/eui
- * package includes them.
- */
-
-import * as eui from '@elastic/eui';
-import { Moment } from 'moment';
-import { ChangeEventHandler, MouseEventHandler, ReactType, Ref, FC } from 'react';
-
-declare module '@elastic/eui' {}
diff --git a/x-pack/legacy/plugins/beats_management/wallaby.js b/x-pack/legacy/plugins/beats_management/wallaby.js
deleted file mode 100644
index 823f63b15bcb3..0000000000000
--- a/x-pack/legacy/plugins/beats_management/wallaby.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.
- */
-const path = require('path');
-process.env.NODE_PATH = path.resolve(__dirname, '..', '..', '..', 'node_modules');
-
-module.exports = function (wallaby) {
- return {
- debug: true,
- files: [
- './tsconfig.json',
- //'plugins/beats/public/**/*.+(js|jsx|ts|tsx|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
- 'server/**/*.+(js|jsx|ts|tsx|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
- 'common/**/*.+(js|jsx|ts|tsx|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
- 'public/**/*.+(js|jsx|ts|tsx|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',
- '!**/*.test.ts',
- ],
-
- tests: ['**/*.test.ts', '**/*.test.tsx'],
- env: {
- type: 'node',
- runner: 'node',
- },
- testFramework: {
- type: 'jest',
- //path: jestPath,
- },
- compilers: {
- '**/*.ts?(x)': wallaby.compilers.typeScript({
- typescript: require('typescript'), // eslint-disable-line
- }),
- '**/*.js': wallaby.compilers.babel({
- babelrc: false,
- presets: [require.resolve('@kbn/babel-preset/node_preset')],
- }),
- },
-
- setup: (wallaby) => {
- const path = require('path');
-
- const kibanaDirectory = path.resolve(wallaby.localProjectDir, '..', '..', '..');
- wallaby.testFramework.configure({
- rootDir: wallaby.localProjectDir,
- moduleNameMapper: {
- '^ui/(.*)': `${kibanaDirectory}/src/legacy/ui/public/$1`,
- // eslint-disable-next-line
- '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `${kibanaDirectory}/src/dev/jest/mocks/file_mock.js`,
- '\\.(css|less|scss)$': `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`,
- },
- testURL: 'http://localhost',
- setupFiles: [`${kibanaDirectory}/x-pack/dev-tools/jest/setup/enzyme.js`],
- snapshotSerializers: [`${kibanaDirectory}/node_modules/enzyme-to-json/serializer`],
- transform: {
- '^.+\\.js$': `${kibanaDirectory}/src/dev/jest/babel_transform.js`,
- //"^.+\\.tsx?$": `${kibanaDirectory}/src/dev/jest/ts_transform.js`,
- },
- });
- },
- };
-};
diff --git a/x-pack/plugins/actions/server/actions_client.test.ts b/x-pack/plugins/actions/server/actions_client.test.ts
index 2865bbbe1d944..69fab828e63de 100644
--- a/x-pack/plugins/actions/server/actions_client.test.ts
+++ b/x-pack/plugins/actions/server/actions_client.test.ts
@@ -386,6 +386,7 @@ describe('getAll()', () => {
foo: 'bar',
},
},
+ score: 1,
references: [],
},
],
diff --git a/x-pack/plugins/alerts/server/alerts_client.test.ts b/x-pack/plugins/alerts/server/alerts_client.test.ts
index 9685f58b8fb31..f494f1358980d 100644
--- a/x-pack/plugins/alerts/server/alerts_client.test.ts
+++ b/x-pack/plugins/alerts/server/alerts_client.test.ts
@@ -1667,6 +1667,7 @@ describe('find()', () => {
},
],
},
+ score: 1,
references: [
{
name: 'action_0',
diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx
index 796f2992236f9..d71d5f2cb480d 100644
--- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/Distribution/index.tsx
@@ -5,9 +5,12 @@
*/
import { EuiTitle } from '@elastic/eui';
+import theme from '@elastic/eui/dist/eui_theme_light.json';
+import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
-import { scaleUtc } from 'd3-scale';
import d3 from 'd3';
+import { scaleUtc } from 'd3-scale';
+import mean from 'lodash.mean';
import React from 'react';
import { asRelativeDateTimeRange } from '../../../../utils/formatters';
import { getTimezoneOffsetInMs } from '../../../shared/charts/CustomPlot/getTimezoneOffsetInMs';
@@ -17,7 +20,7 @@ import { EmptyMessage } from '../../../shared/EmptyMessage';
interface IBucket {
key: number;
- count: number;
+ count: number | undefined;
}
// TODO: cleanup duplication of this in distribution/get_distribution.ts (ErrorDistributionAPIResponse) and transactions/distribution/index.ts (TransactionDistributionAPIResponse)
@@ -30,7 +33,7 @@ interface IDistribution {
interface FormattedBucket {
x0: number;
x: number;
- y: number;
+ y: number | undefined;
}
export function getFormattedBuckets(
@@ -64,7 +67,7 @@ export function ErrorDistribution({ distribution, title }: Props) {
distribution.bucketSize
);
- if (!buckets || distribution.noHits) {
+ if (!buckets) {
return (
bucket.y)) || 0;
const xMin = d3.min(buckets, (d) => d.x0);
const xMax = d3.max(buckets, (d) => d.x);
const tickFormat = scaleUtc().domain([xMin, xMax]).tickFormat();
@@ -84,6 +88,7 @@ export function ErrorDistribution({ distribution, title }: Props) {
{title}
bucket.x}
xType="time-utc"
@@ -105,6 +110,17 @@ export function ErrorDistribution({ distribution, title }: Props) {
values: { occCount: value },
})
}
+ legends={[
+ {
+ color: theme.euiColorVis1,
+ // 0a abbreviates large whole numbers with metric prefixes like: 1000 = 1k, 32000 = 32k, 1000000 = 1m
+ legendValue: numeral(averageValue).format('0a'),
+ title: i18n.translate('xpack.apm.errorGroupDetails.avgLabel', {
+ defaultMessage: 'Avg.',
+ }),
+ legendClickDisabled: true,
+ },
+ ]}
/>
);
diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
index d8885ec11c511..225e5ef2f6ca2 100644
--- a/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupDetails/index.tsx
@@ -26,6 +26,9 @@ import { ErrorDistribution } from './Distribution';
import { useLocation } from '../../../hooks/useLocation';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { useTrackPageview } from '../../../../../observability/public';
+import { callApmApi } from '../../../services/rest/createCallApmApi';
+import { ErrorRateChart } from '../../shared/charts/ErrorRateChart';
+import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
const Titles = styled.div`
margin-bottom: ${px(units.plus)};
@@ -61,49 +64,43 @@ export function ErrorGroupDetails() {
const { urlParams, uiFilters } = useUrlParams();
const { serviceName, start, end, errorGroupId } = urlParams;
- const { data: errorGroupData } = useFetcher(
- (callApmApi) => {
- if (serviceName && start && end && errorGroupId) {
- return callApmApi({
- pathname: '/api/apm/services/{serviceName}/errors/{groupId}',
- params: {
- path: {
- serviceName,
- groupId: errorGroupId,
- },
- query: {
- start,
- end,
- uiFilters: JSON.stringify(uiFilters),
- },
+ const { data: errorGroupData } = useFetcher(() => {
+ if (serviceName && start && end && errorGroupId) {
+ return callApmApi({
+ pathname: '/api/apm/services/{serviceName}/errors/{groupId}',
+ params: {
+ path: {
+ serviceName,
+ groupId: errorGroupId,
},
- });
- }
- },
- [serviceName, start, end, errorGroupId, uiFilters]
- );
-
- const { data: errorDistributionData } = useFetcher(
- (callApmApi) => {
- if (serviceName && start && end && errorGroupId) {
- return callApmApi({
- pathname: '/api/apm/services/{serviceName}/errors/distribution',
- params: {
- path: {
- serviceName,
- },
- query: {
- start,
- end,
- groupId: errorGroupId,
- uiFilters: JSON.stringify(uiFilters),
- },
+ query: {
+ start,
+ end,
+ uiFilters: JSON.stringify(uiFilters),
},
- });
- }
- },
- [serviceName, start, end, errorGroupId, uiFilters]
- );
+ },
+ });
+ }
+ }, [serviceName, start, end, errorGroupId, uiFilters]);
+
+ const { data: errorDistributionData } = useFetcher(() => {
+ if (serviceName && start && end && errorGroupId) {
+ return callApmApi({
+ pathname: '/api/apm/services/{serviceName}/errors/distribution',
+ params: {
+ path: {
+ serviceName,
+ },
+ query: {
+ start,
+ end,
+ groupId: errorGroupId,
+ uiFilters: JSON.stringify(uiFilters),
+ },
+ },
+ });
+ }
+ }, [serviceName, start, end, errorGroupId, uiFilters]);
useTrackPageview({ app: 'apm', path: 'error_group_details' });
useTrackPageview({ app: 'apm', path: 'error_group_details', delay: 15000 });
@@ -185,16 +182,24 @@ export function ErrorGroupDetails() {
)}
-
-
+
+
+
+
+
+
+
+
+
+
{showDetails && (
diff --git a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
index ff031c5a86d11..73474208e26c0 100644
--- a/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/ErrorGroupOverview/index.tsx
@@ -13,64 +13,61 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useMemo } from 'react';
-import { useFetcher } from '../../../hooks/useFetcher';
-import { ErrorDistribution } from '../ErrorGroupDetails/Distribution';
-import { ErrorGroupList } from './List';
-import { useUrlParams } from '../../../hooks/useUrlParams';
import { useTrackPageview } from '../../../../../observability/public';
import { PROJECTION } from '../../../../common/projections/typings';
+import { useFetcher } from '../../../hooks/useFetcher';
+import { useUrlParams } from '../../../hooks/useUrlParams';
+import { callApmApi } from '../../../services/rest/createCallApmApi';
+import { ErrorRateChart } from '../../shared/charts/ErrorRateChart';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
+import { ErrorDistribution } from '../ErrorGroupDetails/Distribution';
+import { ErrorGroupList } from './List';
+import { ChartsSyncContextProvider } from '../../../context/ChartsSyncContext';
const ErrorGroupOverview: React.FC = () => {
const { urlParams, uiFilters } = useUrlParams();
const { serviceName, start, end, sortField, sortDirection } = urlParams;
- const { data: errorDistributionData } = useFetcher(
- (callApmApi) => {
- if (serviceName && start && end) {
- return callApmApi({
- pathname: '/api/apm/services/{serviceName}/errors/distribution',
- params: {
- path: {
- serviceName,
- },
- query: {
- start,
- end,
- uiFilters: JSON.stringify(uiFilters),
- },
+ const { data: errorDistributionData } = useFetcher(() => {
+ if (serviceName && start && end) {
+ return callApmApi({
+ pathname: '/api/apm/services/{serviceName}/errors/distribution',
+ params: {
+ path: {
+ serviceName,
},
- });
- }
- },
- [serviceName, start, end, uiFilters]
- );
+ query: {
+ start,
+ end,
+ uiFilters: JSON.stringify(uiFilters),
+ },
+ },
+ });
+ }
+ }, [serviceName, start, end, uiFilters]);
- const { data: errorGroupListData } = useFetcher(
- (callApmApi) => {
- const normalizedSortDirection = sortDirection === 'asc' ? 'asc' : 'desc';
+ const { data: errorGroupListData } = useFetcher(() => {
+ const normalizedSortDirection = sortDirection === 'asc' ? 'asc' : 'desc';
- if (serviceName && start && end) {
- return callApmApi({
- pathname: '/api/apm/services/{serviceName}/errors',
- params: {
- path: {
- serviceName,
- },
- query: {
- start,
- end,
- sortField,
- sortDirection: normalizedSortDirection,
- uiFilters: JSON.stringify(uiFilters),
- },
+ if (serviceName && start && end) {
+ return callApmApi({
+ pathname: '/api/apm/services/{serviceName}/errors',
+ params: {
+ path: {
+ serviceName,
},
- });
- }
- },
- [serviceName, start, end, sortField, sortDirection, uiFilters]
- );
+ query: {
+ start,
+ end,
+ sortField,
+ sortDirection: normalizedSortDirection,
+ uiFilters: JSON.stringify(uiFilters),
+ },
+ },
+ });
+ }
+ }, [serviceName, start, end, sortField, sortDirection, uiFilters]);
useTrackPageview({
app: 'apm',
@@ -102,20 +99,27 @@ const ErrorGroupOverview: React.FC = () => {
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/Controls.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/Controls.tsx
index 2199349952d8d..8775cebc0af55 100644
--- a/x-pack/plugins/apm/public/components/app/ServiceMap/Controls.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/Controls.tsx
@@ -56,18 +56,64 @@ function doZoom(cy: cytoscape.Core | undefined, increment: number) {
}
}
+function useDebugDownloadUrl(cy?: cytoscape.Core) {
+ const [downloadUrl, setDownloadUrl] = useState(undefined);
+ const debug = sessionStorage.getItem('apm_debug') === 'true';
+
+ // Handle elements changes to update the download URL
+ useEffect(() => {
+ const elementsHandler: cytoscape.EventHandler = (event) => {
+ // @ts-ignore The `true` argument to `cy.json` is to flatten the elements
+ // (instead of having them broken into nodes/edges.) DefinitelyTyped has
+ // this wrong.
+ const elementsJson = event.cy.json(true)?.elements.map((element) => ({
+ data: element.data,
+ }));
+ setDownloadUrl(
+ elementsJson.length > 0 && debug
+ ? `data:application/json;charset=utf-8,${encodeURIComponent(
+ JSON.stringify({ elements: elementsJson }, null, ' ')
+ )}`
+ : undefined
+ );
+ };
+
+ if (cy) {
+ cy.on('add remove', elementsHandler);
+ }
+
+ return () => {
+ if (cy) {
+ cy.off('add remove', undefined, elementsHandler);
+ }
+ };
+ }, [cy, debug]);
+
+ return downloadUrl;
+}
+
export function Controls() {
const cy = useContext(CytoscapeContext);
const { urlParams } = useUrlParams();
const currentSearch = urlParams.kuery ?? '';
const [zoom, setZoom] = useState((cy && cy.zoom()) || 1);
+ const downloadUrl = useDebugDownloadUrl(cy);
+ // Handle zoom events
useEffect(() => {
+ const zoomHandler: cytoscape.EventHandler = (event) => {
+ setZoom(event.cy.zoom());
+ };
+
if (cy) {
- cy.on('zoom', (event) => {
- setZoom(event.cy.zoom());
- });
+ cy.on('zoom', zoomHandler);
}
+
+ return () => {
+ if (cy) {
+ cy.off('zoom', undefined, zoomHandler);
+ }
+ };
}, [cy]);
function center() {
@@ -102,6 +148,9 @@ export function Controls() {
const centerLabel = i18n.translate('xpack.apm.serviceMap.center', {
defaultMessage: 'Center',
});
+ const downloadLabel = i18n.translate('xpack.apm.serviceMap.download', {
+ defaultMessage: 'Download',
+ });
const viewFullMapLabel = i18n.translate('xpack.apm.serviceMap.viewFullMap', {
defaultMessage: 'View full service map',
});
@@ -165,6 +214,22 @@ export function Controls() {
)}
+ {downloadUrl && (
+
+
+
+
+
+ )}
);
}
diff --git a/x-pack/plugins/apm/public/components/app/ServiceMap/__stories__/CytoscapeExampleData.stories.tsx b/x-pack/plugins/apm/public/components/app/ServiceMap/__stories__/CytoscapeExampleData.stories.tsx
index 33b3fab28f9ac..3aced1b33dcac 100644
--- a/x-pack/plugins/apm/public/components/app/ServiceMap/__stories__/CytoscapeExampleData.stories.tsx
+++ b/x-pack/plugins/apm/public/components/app/ServiceMap/__stories__/CytoscapeExampleData.stories.tsx
@@ -9,9 +9,12 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiButton,
+ EuiForm,
EuiFieldNumber,
EuiToolTip,
EuiCodeEditor,
+ EuiSpacer,
+ EuiFilePicker,
} from '@elastic/eui';
import { storiesOf } from '@storybook/react';
import React, { useState, useEffect } from 'react';
@@ -99,12 +102,14 @@ storiesOf(STORYBOOK_PATH, module).add(
const [json, setJson] = useState(
getSessionJson() || JSON.stringify(exampleResponseTodo, null, 2)
);
+ const [error, setError] = useState();
+
const [elements, setElements] = useState([]);
useEffect(() => {
try {
setElements(JSON.parse(json).elements);
- } catch (error) {
- console.log(error);
+ } catch (e) {
+ setError(e.message);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
@@ -112,34 +117,76 @@ storiesOf(STORYBOOK_PATH, module).add(
return (
+
+
+
+ {
+ setJson(value);
+ }}
+ />
+
+
+
+ {
+ const item = event?.item(0);
-
-
- {
- setElements(JSON.parse(json).elements);
- setSessionJson(json);
- }}
- >
- Render JSON
-
-
-
- {
- setJson(value);
- }}
- />
+ if (item) {
+ const f = new FileReader();
+ f.onload = (onloadEvent) => {
+ const result = onloadEvent?.target?.result;
+ if (typeof result === 'string') {
+ setJson(result);
+ }
+ };
+ f.readAsText(item);
+ }
+ }}
+ />
+
+ {
+ try {
+ setElements(JSON.parse(json).elements);
+ setSessionJson(json);
+ setError(undefined);
+ } catch (e) {
+ setError(e.message);
+ }
+ }}
+ >
+ Render JSON
+
+
+
+
+
);
},
{
- info: { propTables: false, source: false },
+ info: {
+ propTables: false,
+ source: false,
+ text: `
+ Enter JSON map data into the text box or upload a file and click "Render JSON" to see the results. You can enable a download button on the service map by putting
+
+ \`\`\`
+ sessionStorage.setItem('apm_debug', 'true')
+ \`\`\`
+
+ into the JavaScript console and reloading the page.`,
+ },
}
);
diff --git a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
index bbf3921b383fd..e2609f893dfa0 100644
--- a/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
+++ b/x-pack/plugins/apm/public/components/app/Settings/AgentConfigurations/AgentConfigurationCreateEdit/SettingsPage/SettingsPage.tsx
@@ -223,7 +223,7 @@ export function SettingsPage({
}}
>
-
+
{i18n.translate('xpack.apm.unsavedChanges', {
defaultMessage:
'{unsavedChangesCount, plural, =0{0 unsaved changes} one {1 unsaved change} other {# unsaved changes}} ',
diff --git a/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js
index bf6cf083e00ec..87ab81e738eb8 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js
+++ b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/Legends.js
@@ -105,7 +105,9 @@ export default function Legends({
return (
clickLegend(i)}
+ onClick={
+ serie.legendClickDisabled ? undefined : () => clickLegend(i)
+ }
disabled={seriesEnabledState[i]}
text={text}
color={serie.color}
diff --git a/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/index.js b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/index.js
index e1ffec3a8d97f..7e74961e57ea1 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/index.js
+++ b/x-pack/plugins/apm/public/components/shared/charts/CustomPlot/index.js
@@ -144,7 +144,7 @@ export class InnerCustomPlot extends PureComponent {
const hasValidCoordinates = flatten(series.map((s) => s.data)).some((p) =>
isValidCoordinateValue(p.y)
);
- const noHits = !hasValidCoordinates;
+ const noHits = this.props.noHits || !hasValidCoordinates;
const plotValues = this.getPlotValues({
visibleSeries,
@@ -234,6 +234,7 @@ InnerCustomPlot.propTypes = {
firstSeen: PropTypes.number,
})
),
+ noHits: PropTypes.bool,
};
InnerCustomPlot.defaultProps = {
@@ -241,6 +242,8 @@ InnerCustomPlot.defaultProps = {
tickFormatX: undefined,
tickFormatY: (y) => y,
truncateLegends: false,
+ xAxisTickSizeOuter: 0,
+ noHits: false,
};
export default makeWidthFlexible(InnerCustomPlot);
diff --git a/x-pack/plugins/apm/public/components/shared/charts/ErrorRateChart/index.tsx b/x-pack/plugins/apm/public/components/shared/charts/ErrorRateChart/index.tsx
new file mode 100644
index 0000000000000..7aafa9e1fdcec
--- /dev/null
+++ b/x-pack/plugins/apm/public/components/shared/charts/ErrorRateChart/index.tsx
@@ -0,0 +1,100 @@
+/*
+ * 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 { EuiTitle } from '@elastic/eui';
+import theme from '@elastic/eui/dist/eui_theme_light.json';
+import { i18n } from '@kbn/i18n';
+import mean from 'lodash.mean';
+import React, { useCallback } from 'react';
+import { useChartsSync } from '../../../../hooks/useChartsSync';
+import { useFetcher } from '../../../../hooks/useFetcher';
+import { useUrlParams } from '../../../../hooks/useUrlParams';
+import { callApmApi } from '../../../../services/rest/createCallApmApi';
+import { unit } from '../../../../style/variables';
+import { asPercent } from '../../../../utils/formatters';
+// @ts-ignore
+import CustomPlot from '../CustomPlot';
+
+const tickFormatY = (y?: number) => {
+ return asPercent(y || 0, 1);
+};
+
+export const ErrorRateChart = () => {
+ const { urlParams, uiFilters } = useUrlParams();
+ const syncedChartsProps = useChartsSync();
+
+ const { serviceName, start, end, errorGroupId } = urlParams;
+ const { data: errorRateData } = useFetcher(() => {
+ if (serviceName && start && end) {
+ return callApmApi({
+ pathname: '/api/apm/services/{serviceName}/errors/rate',
+ params: {
+ path: {
+ serviceName,
+ },
+ query: {
+ start,
+ end,
+ uiFilters: JSON.stringify(uiFilters),
+ groupId: errorGroupId,
+ },
+ },
+ });
+ }
+ }, [serviceName, start, end, uiFilters, errorGroupId]);
+
+ const combinedOnHover = useCallback(
+ (hoverX: number) => {
+ return syncedChartsProps.onHover(hoverX);
+ },
+ [syncedChartsProps]
+ );
+
+ const errorRates = errorRateData?.errorRates || [];
+
+ return (
+ <>
+
+
+ {i18n.translate('xpack.apm.errorRateChart.title', {
+ defaultMessage: 'Error Rate',
+ })}
+
+
+ rate.y))),
+ legendClickDisabled: true,
+ title: i18n.translate('xpack.apm.errorRateChart.avgLabel', {
+ defaultMessage: 'Avg.',
+ }),
+ type: 'linemark',
+ hideTooltipValue: true,
+ },
+ {
+ data: errorRates,
+ type: 'line',
+ color: theme.euiColorVis7,
+ hideLegend: true,
+ title: i18n.translate('xpack.apm.errorRateChart.rateLabel', {
+ defaultMessage: 'Rate',
+ }),
+ },
+ ]}
+ onHover={combinedOnHover}
+ tickFormatY={tickFormatY}
+ formatTooltipValue={({ y }: { y?: number }) =>
+ Number.isFinite(y) ? tickFormatY(y) : 'N/A'
+ }
+ height={unit * 10}
+ />
+ >
+ );
+};
diff --git a/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap b/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap
index 1f935af7c8999..a31b9735628ab 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap
+++ b/x-pack/plugins/apm/public/components/shared/charts/Histogram/__test__/__snapshots__/Histogram.test.js.snap
@@ -114,7 +114,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
0 ms
@@ -149,7 +149,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
500 ms
@@ -184,7 +184,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
1,000 ms
@@ -219,7 +219,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
1,500 ms
@@ -254,7 +254,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
2,000 ms
@@ -289,7 +289,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
2,500 ms
@@ -324,7 +324,7 @@ exports[`Histogram Initially should have default markup 1`] = `
x1={0}
x2={0}
y1={-0}
- y2={10}
+ y2={0}
/>
3,000 ms
diff --git a/x-pack/plugins/apm/public/components/shared/charts/Histogram/index.js b/x-pack/plugins/apm/public/components/shared/charts/Histogram/index.js
index 4eca1a37c51bc..002ff19d0d1df 100644
--- a/x-pack/plugins/apm/public/components/shared/charts/Histogram/index.js
+++ b/x-pack/plugins/apm/public/components/shared/charts/Histogram/index.js
@@ -26,6 +26,10 @@ import Tooltip from '../Tooltip';
import theme from '@elastic/eui/dist/eui_theme_light.json';
import { tint } from 'polished';
import { getTimeTicksTZ, getDomainTZ } from '../helper/timezone';
+import Legends from '../CustomPlot/Legends';
+import StatusText from '../CustomPlot/StatusText';
+import { i18n } from '@kbn/i18n';
+import { isValidCoordinateValue } from '../../../../utils/isValidCoordinateValue';
const XY_HEIGHT = unit * 10;
const XY_MARGIN = {
@@ -99,6 +103,7 @@ export class HistogramInner extends PureComponent {
tooltipHeader,
verticalLineHover,
width: XY_WIDTH,
+ legends,
} = this.props;
const { hoveredBucket } = this.state;
if (isEmpty(buckets) || XY_WIDTH === 0) {
@@ -139,102 +144,140 @@ export class HistogramInner extends PureComponent {
const showVerticalLineHover = verticalLineHover(hoveredBucket);
const showBackgroundHover = backgroundHover(hoveredBucket);
+ const hasValidCoordinates = buckets.some((bucket) =>
+ isValidCoordinateValue(bucket.y)
+ );
+ const noHits = this.props.noHits || !hasValidCoordinates;
+
+ const xyPlotProps = {
+ dontCheckIfEmpty: true,
+ xType: this.props.xType,
+ width: XY_WIDTH,
+ height: XY_HEIGHT,
+ margin: XY_MARGIN,
+ xDomain: xDomain,
+ yDomain: yDomain,
+ };
+
+ const xAxisProps = {
+ style: { strokeWidth: '1px' },
+ marginRight: 10,
+ tickSize: 0,
+ tickTotal: X_TICK_TOTAL,
+ tickFormat: formatX,
+ tickValues: xTickValues,
+ };
+
+ const emptyStateChart = (
+
+
+
+
+ );
+
return (
-
-
-
-
-
- {showBackgroundHover && (
-
- )}
-
- {shouldShowTooltip && (
-
- )}
-
- {selectedBucket && (
-
- )}
-
-
-
- {showVerticalLineHover && (
-
- )}
-
- {
- return {
- ...bucket,
- xCenter: (bucket.x0 + bucket.x) / 2,
- };
- })}
- onClick={this.onClick}
- onHover={this.onHover}
- onBlur={this.onBlur}
- x={(d) => x(d.xCenter)}
- y={() => 1}
- />
-
+ {noHits ? (
+ <>{emptyStateChart}>
+ ) : (
+ <>
+
+
+
+
+
+ {showBackgroundHover && (
+
+ )}
+
+ {shouldShowTooltip && (
+
+ )}
+
+ {selectedBucket && (
+
+ )}
+
+
+
+ {showVerticalLineHover && hoveredBucket?.x && (
+
+ )}
+
+ {
+ return {
+ ...bucket,
+ xCenter: (bucket.x0 + bucket.x) / 2,
+ };
+ })}
+ onClick={this.onClick}
+ onHover={this.onHover}
+ onBlur={this.onBlur}
+ x={(d) => x(d.xCenter)}
+ y={() => 1}
+ />
+
+
+ {legends && (
+ {}}
+ truncateLegends={false}
+ noHits={noHits}
+ />
+ )}
+ >
+ )}
);
@@ -255,6 +298,8 @@ HistogramInner.propTypes = {
verticalLineHover: PropTypes.func,
width: PropTypes.number.isRequired,
xType: PropTypes.string,
+ legends: PropTypes.array,
+ noHits: PropTypes.bool,
};
HistogramInner.defaultProps = {
@@ -265,6 +310,7 @@ HistogramInner.defaultProps = {
tooltipHeader: () => null,
verticalLineHover: () => null,
xType: 'linear',
+ noHits: false,
};
export default makeWidthFlexible(HistogramInner);
diff --git a/x-pack/plugins/apm/server/lib/errors/get_error_rate.ts b/x-pack/plugins/apm/server/lib/errors/get_error_rate.ts
new file mode 100644
index 0000000000000..d558e3942a42b
--- /dev/null
+++ b/x-pack/plugins/apm/server/lib/errors/get_error_rate.ts
@@ -0,0 +1,109 @@
+/*
+ * 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 {
+ ERROR_GROUP_ID,
+ PROCESSOR_EVENT,
+ SERVICE_NAME,
+} from '../../../common/elasticsearch_fieldnames';
+import { ProcessorEvent } from '../../../common/processor_event';
+import { getMetricsDateHistogramParams } from '../helpers/metrics';
+import { rangeFilter } from '../helpers/range_filter';
+import {
+ Setup,
+ SetupTimeRange,
+ SetupUIFilters,
+} from '../helpers/setup_request';
+
+export async function getErrorRate({
+ serviceName,
+ groupId,
+ setup,
+}: {
+ serviceName: string;
+ groupId?: string;
+ setup: Setup & SetupTimeRange & SetupUIFilters;
+}) {
+ const { start, end, uiFiltersES, client, indices } = setup;
+
+ const filter = [
+ { term: { [SERVICE_NAME]: serviceName } },
+ { range: rangeFilter(start, end) },
+ ...uiFiltersES,
+ ];
+
+ const aggs = {
+ response_times: {
+ date_histogram: getMetricsDateHistogramParams(start, end),
+ },
+ };
+
+ const getTransactionBucketAggregation = async () => {
+ const resp = await client.search({
+ index: indices['apm_oss.transactionIndices'],
+ body: {
+ size: 0,
+ query: {
+ bool: {
+ filter: [
+ ...filter,
+ { term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } },
+ ],
+ },
+ },
+ aggs,
+ },
+ });
+ return {
+ totalHits: resp.hits.total.value,
+ responseTimeBuckets: resp.aggregations?.response_times.buckets,
+ };
+ };
+ const getErrorBucketAggregation = async () => {
+ const groupIdFilter = groupId
+ ? [{ term: { [ERROR_GROUP_ID]: groupId } }]
+ : [];
+ const resp = await client.search({
+ index: indices['apm_oss.errorIndices'],
+ body: {
+ size: 0,
+ query: {
+ bool: {
+ filter: [
+ ...filter,
+ ...groupIdFilter,
+ { term: { [PROCESSOR_EVENT]: ProcessorEvent.error } },
+ ],
+ },
+ },
+ aggs,
+ },
+ });
+ return resp.aggregations?.response_times.buckets;
+ };
+
+ const [transactions, errorResponseTimeBuckets] = await Promise.all([
+ getTransactionBucketAggregation(),
+ getErrorBucketAggregation(),
+ ]);
+
+ const transactionCountByTimestamp: Record = {};
+ if (transactions?.responseTimeBuckets) {
+ transactions.responseTimeBuckets.forEach((bucket) => {
+ transactionCountByTimestamp[bucket.key] = bucket.doc_count;
+ });
+ }
+
+ const errorRates = errorResponseTimeBuckets?.map((bucket) => {
+ const { key, doc_count: errorCount } = bucket;
+ const relativeRate = errorCount / transactionCountByTimestamp[key];
+ return { x: key, y: relativeRate };
+ });
+
+ return {
+ noHits: transactions?.totalHits === 0,
+ errorRates,
+ };
+}
diff --git a/x-pack/plugins/apm/server/routes/create_apm_api.ts b/x-pack/plugins/apm/server/routes/create_apm_api.ts
index 3088803c3b4b0..a34690aff43b4 100644
--- a/x-pack/plugins/apm/server/routes/create_apm_api.ts
+++ b/x-pack/plugins/apm/server/routes/create_apm_api.ts
@@ -13,6 +13,7 @@ import {
errorDistributionRoute,
errorGroupsRoute,
errorsRoute,
+ errorRateRoute,
} from './errors';
import {
serviceAgentNameRoute,
@@ -87,6 +88,7 @@ const createApmApi = () => {
.add(errorDistributionRoute)
.add(errorGroupsRoute)
.add(errorsRoute)
+ .add(errorRateRoute)
// Services
.add(serviceAgentNameRoute)
diff --git a/x-pack/plugins/apm/server/routes/errors.ts b/x-pack/plugins/apm/server/routes/errors.ts
index 1615550027d3c..97314a9a61661 100644
--- a/x-pack/plugins/apm/server/routes/errors.ts
+++ b/x-pack/plugins/apm/server/routes/errors.ts
@@ -11,6 +11,7 @@ import { getErrorGroup } from '../lib/errors/get_error_group';
import { getErrorGroups } from '../lib/errors/get_error_groups';
import { setupRequest } from '../lib/helpers/setup_request';
import { uiFiltersRt, rangeRt } from './default_api_types';
+import { getErrorRate } from '../lib/errors/get_error_rate';
export const errorsRoute = createRoute(() => ({
path: '/api/apm/services/{serviceName}/errors',
@@ -80,3 +81,26 @@ export const errorDistributionRoute = createRoute(() => ({
return getErrorDistribution({ serviceName, groupId, setup });
},
}));
+
+export const errorRateRoute = createRoute(() => ({
+ path: '/api/apm/services/{serviceName}/errors/rate',
+ params: {
+ path: t.type({
+ serviceName: t.string,
+ }),
+ query: t.intersection([
+ t.partial({
+ groupId: t.string,
+ }),
+ uiFiltersRt,
+ rangeRt,
+ ]),
+ },
+ handler: async ({ context, request }) => {
+ const setup = await setupRequest(context, request);
+ const { params } = context;
+ const { serviceName } = params.path;
+ const { groupId } = params.query;
+ return getErrorRate({ serviceName, groupId, setup });
+ },
+}));
diff --git a/x-pack/plugins/beats_management/server/index.ts b/x-pack/plugins/beats_management/server/index.ts
index 607fb0ab2725d..ad19087f5ac9f 100644
--- a/x-pack/plugins/beats_management/server/index.ts
+++ b/x-pack/plugins/beats_management/server/index.ts
@@ -4,7 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { PluginInitializer } from '../../../../src/core/server';
import { beatsManagementConfigSchema } from '../common';
+import { BeatsManagementPlugin } from './plugin';
export const config = {
schema: beatsManagementConfigSchema,
@@ -16,8 +18,4 @@ export const config = {
},
};
-export const plugin = () => ({
- setup() {},
- start() {},
- stop() {},
-});
+export const plugin: PluginInitializer<{}, {}> = (context) => new BeatsManagementPlugin(context);
diff --git a/x-pack/plugins/beats_management/server/plugin.ts b/x-pack/plugins/beats_management/server/plugin.ts
new file mode 100644
index 0000000000000..a82dbcb4a3a6e
--- /dev/null
+++ b/x-pack/plugins/beats_management/server/plugin.ts
@@ -0,0 +1,39 @@
+/*
+ * 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,
+ CoreStart,
+ Plugin,
+ PluginInitializerContext,
+} from '../../../../src/core/server';
+import { SecurityPluginSetup } from '../../security/server';
+import { LicensingPluginStart } from '../../licensing/server';
+import { BeatsManagementConfigType } from '../common';
+
+interface SetupDeps {
+ security?: SecurityPluginSetup;
+}
+
+interface StartDeps {
+ licensing: LicensingPluginStart;
+}
+
+export class BeatsManagementPlugin implements Plugin<{}, {}, SetupDeps, StartDeps> {
+ constructor(
+ private readonly initializerContext: PluginInitializerContext
+ ) {}
+
+ public async setup(core: CoreSetup, plugins: SetupDeps) {
+ this.initializerContext.config.create();
+
+ return {};
+ }
+
+ public async start(core: CoreStart, { licensing }: StartDeps) {
+ return {};
+ }
+}
diff --git a/x-pack/legacy/plugins/beats_management/types/formsy.d.ts b/x-pack/plugins/beats_management/types/formsy.d.ts
similarity index 100%
rename from x-pack/legacy/plugins/beats_management/types/formsy.d.ts
rename to x-pack/plugins/beats_management/types/formsy.d.ts
diff --git a/x-pack/plugins/canvas/server/routes/custom_elements/create.test.ts b/x-pack/plugins/canvas/server/routes/custom_elements/create.test.ts
index c260d6ca8ac16..db0417434227c 100644
--- a/x-pack/plugins/canvas/server/routes/custom_elements/create.test.ts
+++ b/x-pack/plugins/canvas/server/routes/custom_elements/create.test.ts
@@ -13,12 +13,7 @@ import {
} from 'src/core/server/mocks';
import { CUSTOM_ELEMENT_TYPE } from '../../../common/lib/constants';
import { initializeCreateCustomElementRoute } from './create';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
const mockRouteContext = ({
core: {
@@ -43,7 +38,7 @@ describe('POST custom element', () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeCreateCustomElementRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/custom_elements/delete.test.ts b/x-pack/plugins/canvas/server/routes/custom_elements/delete.test.ts
index e70fae5d18eaf..98b26ec368ab1 100644
--- a/x-pack/plugins/canvas/server/routes/custom_elements/delete.test.ts
+++ b/x-pack/plugins/canvas/server/routes/custom_elements/delete.test.ts
@@ -6,12 +6,7 @@
import { CUSTOM_ELEMENT_TYPE } from '../../../common/lib/constants';
import { initializeDeleteCustomElementRoute } from './delete';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -32,7 +27,7 @@ describe('DELETE custom element', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeDeleteCustomElementRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/custom_elements/find.test.ts b/x-pack/plugins/canvas/server/routes/custom_elements/find.test.ts
index 6644d3b56c681..dead9ded8a14a 100644
--- a/x-pack/plugins/canvas/server/routes/custom_elements/find.test.ts
+++ b/x-pack/plugins/canvas/server/routes/custom_elements/find.test.ts
@@ -5,12 +5,7 @@
*/
import { initializeFindCustomElementsRoute } from './find';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -31,7 +26,7 @@ describe('Find custom element', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeFindCustomElementsRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/custom_elements/get.test.ts b/x-pack/plugins/canvas/server/routes/custom_elements/get.test.ts
index 03ae6048801bf..09b620aeff9bb 100644
--- a/x-pack/plugins/canvas/server/routes/custom_elements/get.test.ts
+++ b/x-pack/plugins/canvas/server/routes/custom_elements/get.test.ts
@@ -6,12 +6,7 @@
import { CUSTOM_ELEMENT_TYPE } from '../../../common/lib/constants';
import { initializeGetCustomElementRoute } from './get';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -32,7 +27,7 @@ describe('GET custom element', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeGetCustomElementRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/custom_elements/update.test.ts b/x-pack/plugins/canvas/server/routes/custom_elements/update.test.ts
index e67e42c26cd2b..19477458bacb5 100644
--- a/x-pack/plugins/canvas/server/routes/custom_elements/update.test.ts
+++ b/x-pack/plugins/canvas/server/routes/custom_elements/update.test.ts
@@ -8,12 +8,7 @@ import sinon from 'sinon';
import { CustomElement } from '../../../types';
import { CUSTOM_ELEMENT_TYPE } from '../../../common/lib/constants';
import { initializeUpdateCustomElementRoute } from './update';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -57,7 +52,7 @@ describe('PUT custom element', () => {
clock = sinon.useFakeTimers(now);
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeUpdateCustomElementRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/es_fields/es_fields.test.ts b/x-pack/plugins/canvas/server/routes/es_fields/es_fields.test.ts
index c3588957ff68e..93fdb4304acc6 100644
--- a/x-pack/plugins/canvas/server/routes/es_fields/es_fields.test.ts
+++ b/x-pack/plugins/canvas/server/routes/es_fields/es_fields.test.ts
@@ -5,12 +5,7 @@
*/
import { initializeESFieldsRoute } from './es_fields';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
httpServiceMock,
httpServerMock,
@@ -31,7 +26,7 @@ describe('Retrieve ES Fields', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeESFieldsRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/shareables/download.test.ts b/x-pack/plugins/canvas/server/routes/shareables/download.test.ts
index be4765217d7aa..75eeb46c890d5 100644
--- a/x-pack/plugins/canvas/server/routes/shareables/download.test.ts
+++ b/x-pack/plugins/canvas/server/routes/shareables/download.test.ts
@@ -7,12 +7,7 @@
jest.mock('fs');
import fs from 'fs';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import { httpServiceMock, httpServerMock, loggingServiceMock } from 'src/core/server/mocks';
import { initializeDownloadShareableWorkpadRoute } from './download';
@@ -25,7 +20,7 @@ describe('Download Canvas shareables runtime', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeDownloadShareableWorkpadRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/shareables/zip.test.ts b/x-pack/plugins/canvas/server/routes/shareables/zip.test.ts
index 63776f897a04c..5a2d122c2754b 100644
--- a/x-pack/plugins/canvas/server/routes/shareables/zip.test.ts
+++ b/x-pack/plugins/canvas/server/routes/shareables/zip.test.ts
@@ -7,12 +7,7 @@
jest.mock('archiver');
const archiver = require('archiver') as jest.Mock;
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import { httpServiceMock, httpServerMock, loggingServiceMock } from 'src/core/server/mocks';
import { initializeZipShareableWorkpadRoute } from './zip';
import { API_ROUTE_SHAREABLE_ZIP } from '../../../common/lib';
@@ -31,7 +26,7 @@ describe('Zips Canvas shareables runtime together with workpad', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeZipShareableWorkpadRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/workpad/create.test.ts b/x-pack/plugins/canvas/server/routes/workpad/create.test.ts
index 02b6376ece2ed..2ed63e7397108 100644
--- a/x-pack/plugins/canvas/server/routes/workpad/create.test.ts
+++ b/x-pack/plugins/canvas/server/routes/workpad/create.test.ts
@@ -13,12 +13,7 @@ import {
} from 'src/core/server/mocks';
import { CANVAS_TYPE } from '../../../common/lib/constants';
import { initializeCreateWorkpadRoute } from './create';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
const mockRouteContext = ({
core: {
@@ -43,7 +38,7 @@ describe('POST workpad', () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeCreateWorkpadRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/workpad/delete.test.ts b/x-pack/plugins/canvas/server/routes/workpad/delete.test.ts
index 57df4e7cffda6..712ff29400382 100644
--- a/x-pack/plugins/canvas/server/routes/workpad/delete.test.ts
+++ b/x-pack/plugins/canvas/server/routes/workpad/delete.test.ts
@@ -6,12 +6,7 @@
import { CANVAS_TYPE } from '../../../common/lib/constants';
import { initializeDeleteWorkpadRoute } from './delete';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -32,7 +27,7 @@ describe('DELETE workpad', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeDeleteWorkpadRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/workpad/find.test.ts b/x-pack/plugins/canvas/server/routes/workpad/find.test.ts
index 08de9b20e9818..e2dd8552379b7 100644
--- a/x-pack/plugins/canvas/server/routes/workpad/find.test.ts
+++ b/x-pack/plugins/canvas/server/routes/workpad/find.test.ts
@@ -5,12 +5,7 @@
*/
import { initializeFindWorkpadsRoute } from './find';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -31,7 +26,7 @@ describe('Find workpad', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeFindWorkpadsRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/workpad/get.test.ts b/x-pack/plugins/canvas/server/routes/workpad/get.test.ts
index 6741f2b3fc9d6..9ecd9ceefed8d 100644
--- a/x-pack/plugins/canvas/server/routes/workpad/get.test.ts
+++ b/x-pack/plugins/canvas/server/routes/workpad/get.test.ts
@@ -6,12 +6,7 @@
import { CANVAS_TYPE } from '../../../common/lib/constants';
import { initializeGetWorkpadRoute } from './get';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -34,7 +29,7 @@ describe('GET workpad', () => {
beforeEach(() => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeGetWorkpadRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/canvas/server/routes/workpad/update.test.ts b/x-pack/plugins/canvas/server/routes/workpad/update.test.ts
index a6b34e7165121..36ea984447d8a 100644
--- a/x-pack/plugins/canvas/server/routes/workpad/update.test.ts
+++ b/x-pack/plugins/canvas/server/routes/workpad/update.test.ts
@@ -7,12 +7,7 @@
import sinon from 'sinon';
import { CANVAS_TYPE } from '../../../common/lib/constants';
import { initializeUpdateWorkpadRoute, initializeUpdateWorkpadAssetsRoute } from './update';
-import {
- IRouter,
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import {
savedObjectsClientMock,
httpServiceMock,
@@ -44,7 +39,7 @@ describe('PUT workpad', () => {
clock = sinon.useFakeTimers(now);
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeUpdateWorkpadRoute({
router,
logger: loggingServiceMock.create().get(),
@@ -158,7 +153,7 @@ describe('update assets', () => {
beforeEach(() => {
clock = sinon.useFakeTimers(now);
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
initializeUpdateWorkpadAssetsRoute({
router,
logger: loggingServiceMock.create().get(),
diff --git a/x-pack/plugins/case/server/routes/api/__fixtures__/mock_router.ts b/x-pack/plugins/case/server/routes/api/__fixtures__/mock_router.ts
index eff91fff32c02..e00c1c111b41b 100644
--- a/x-pack/plugins/case/server/routes/api/__fixtures__/mock_router.ts
+++ b/x-pack/plugins/case/server/routes/api/__fixtures__/mock_router.ts
@@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { IRouter } from 'kibana/server';
import { loggingServiceMock, httpServiceMock } from '../../../../../../../src/core/server/mocks';
import { CaseService, CaseConfigureService } from '../../../services';
import { authenticationMock } from '../__fixtures__';
@@ -16,7 +15,7 @@ export const createRoute = async (
badAuth = false
) => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const log = loggingServiceMock.create().get('case');
diff --git a/x-pack/plugins/case/server/routes/api/utils.test.ts b/x-pack/plugins/case/server/routes/api/utils.test.ts
index 81156b98bab83..2da489e643435 100644
--- a/x-pack/plugins/case/server/routes/api/utils.test.ts
+++ b/x-pack/plugins/case/server/routes/api/utils.test.ts
@@ -222,7 +222,12 @@ describe('Utils', () => {
];
const res = transformCases(
- { saved_objects: mockCases, total: mockCases.length, per_page: 10, page: 1 },
+ {
+ saved_objects: mockCases.map((obj) => ({ ...obj, score: 1 })),
+ total: mockCases.length,
+ per_page: 10,
+ page: 1,
+ },
2,
2,
extraCaseData,
@@ -232,7 +237,11 @@ describe('Utils', () => {
page: 1,
per_page: 10,
total: mockCases.length,
- cases: flattenCaseSavedObjects(mockCases, extraCaseData, '123'),
+ cases: flattenCaseSavedObjects(
+ mockCases.map((obj) => ({ ...obj, score: 1 })),
+ extraCaseData,
+ '123'
+ ),
count_open_cases: 2,
count_closed_cases: 2,
});
@@ -500,7 +509,7 @@ describe('Utils', () => {
describe('transformComments', () => {
it('transforms correctly', () => {
const comments = {
- saved_objects: mockCaseComments,
+ saved_objects: mockCaseComments.map((obj) => ({ ...obj, score: 1 })),
total: mockCaseComments.length,
per_page: 10,
page: 1,
diff --git a/x-pack/plugins/case/server/routes/api/utils.ts b/x-pack/plugins/case/server/routes/api/utils.ts
index b7f3c68d1662f..ec2881807442f 100644
--- a/x-pack/plugins/case/server/routes/api/utils.ts
+++ b/x-pack/plugins/case/server/routes/api/utils.ts
@@ -101,7 +101,7 @@ export const transformCases = (
});
export const flattenCaseSavedObjects = (
- savedObjects: SavedObjectsFindResponse['saved_objects'],
+ savedObjects: Array>,
totalCommentByCase: TotalCommentByCase[],
caseConfigureConnectorId: string = 'none'
): CaseResponse[] =>
@@ -146,7 +146,7 @@ export const transformComments = (
});
export const flattenCommentSavedObjects = (
- savedObjects: SavedObjectsFindResponse['saved_objects']
+ savedObjects: Array>
): CommentResponse[] =>
savedObjects.reduce((acc: CommentResponse[], savedObject: SavedObject) => {
return [...acc, flattenCommentSavedObject(savedObject)];
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_create_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_create_route.test.ts
index 0b5f04556596a..cf2349bc7023c 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_create_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_create_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Create auto-follow pattern', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerCreateRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_delete_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_delete_route.test.ts
index 7468c643a3aa6..b2a3b631333b4 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_delete_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_delete_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Delete auto-follow pattern(s)', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerDeleteRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_fetch_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_fetch_route.test.ts
index 1aa7112c75276..4f2417ec816f4 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_fetch_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_fetch_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Fetch all auto-follow patterns', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerFetchRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_get_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_get_route.test.ts
index 980128027c2f9..802aebd6412fe 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_get_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_get_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Get one auto-follow pattern', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerGetRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_pause_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_pause_route.test.ts
index 5b27c77ca86de..a92a9b5edb9b7 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_pause_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_pause_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Pause auto-follow pattern(s)', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerPauseRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_resume_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_resume_route.test.ts
index afea0f631fe48..4ee77b1b3deaa 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_resume_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_resume_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Resume auto-follow pattern(s)', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerResumeRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_update_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_update_route.test.ts
index bdce84f6404b1..711538e2a1ee0 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_update_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern/register_update_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Update auto-follow pattern', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerUpdateRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_create_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_create_route.test.ts
index ccf7c469fe780..de21458c0a25f 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_create_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_create_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Create follower index', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerCreateRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_fetch_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_fetch_route.test.ts
index e1ec28a7c90b1..ec52f1e431e38 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_fetch_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_fetch_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Fetch all follower indices', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerFetchRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_get_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_get_route.test.ts
index 99c871d5d4f2d..a0feeb2b1e5bc 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_get_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_get_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Get one follower index', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerGetRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_pause_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_pause_route.test.ts
index 3d28d36ac6182..dcbec8703622e 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_pause_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_pause_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Pause follower index/indices', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerPauseRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_resume_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_resume_route.test.ts
index 09975b262dca8..30d25c3bc4d03 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_resume_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_resume_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Resume follower index/indices', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerResumeRoute({
router,
diff --git a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_unfollow_route.test.ts b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_unfollow_route.test.ts
index 5f0d148bfcae9..a56eb8178b478 100644
--- a/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_unfollow_route.test.ts
+++ b/x-pack/plugins/cross_cluster_replication/server/routes/api/follower_index/register_unfollow_route.test.ts
@@ -5,7 +5,7 @@
*/
import { httpServiceMock, httpServerMock } from 'src/core/server/mocks';
-import { IRouter, kibanaResponseFactory, RequestHandler } from 'src/core/server';
+import { kibanaResponseFactory, RequestHandler } from 'src/core/server';
import { isEsError } from '../../../shared_imports';
import { formatEsError } from '../../../lib/format_es_error';
@@ -19,7 +19,7 @@ describe('[CCR API] Unfollow follower index/indices', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerUnfollowRoute({
router,
diff --git a/x-pack/plugins/dashboard_enhanced/kibana.json b/x-pack/plugins/dashboard_enhanced/kibana.json
index 37211ea537179..3a95419d2f2fe 100644
--- a/x-pack/plugins/dashboard_enhanced/kibana.json
+++ b/x-pack/plugins/dashboard_enhanced/kibana.json
@@ -3,6 +3,6 @@
"version": "kibana",
"server": false,
"ui": true,
- "requiredPlugins": ["data", "uiActionsEnhanced", "drilldowns", "embeddable", "dashboard", "share"],
+ "requiredPlugins": ["data", "uiActionsEnhanced", "embeddable", "dashboard", "share"],
"configPath": ["xpack", "dashboardEnhanced"]
}
diff --git a/x-pack/plugins/dashboard_enhanced/public/plugin.ts b/x-pack/plugins/dashboard_enhanced/public/plugin.ts
index 413f5a7afe356..854a4964ffe15 100644
--- a/x-pack/plugins/dashboard_enhanced/public/plugin.ts
+++ b/x-pack/plugins/dashboard_enhanced/public/plugin.ts
@@ -10,12 +10,10 @@ import { EmbeddableSetup, EmbeddableStart } from '../../../../src/plugins/embedd
import { DashboardDrilldownsService } from './services';
import { DataPublicPluginStart } from '../../../../src/plugins/data/public';
import { AdvancedUiActionsSetup, AdvancedUiActionsStart } from '../../ui_actions_enhanced/public';
-import { DrilldownsSetup, DrilldownsStart } from '../../drilldowns/public';
import { DashboardStart } from '../../../../src/plugins/dashboard/public';
export interface SetupDependencies {
uiActionsEnhanced: AdvancedUiActionsSetup;
- drilldowns: DrilldownsSetup;
embeddable: EmbeddableSetup;
share: SharePluginSetup;
}
@@ -23,7 +21,6 @@ export interface SetupDependencies {
export interface StartDependencies {
uiActionsEnhanced: AdvancedUiActionsStart;
data: DataPublicPluginStart;
- drilldowns: DrilldownsStart;
embeddable: EmbeddableStart;
share: SharePluginStart;
dashboard: DashboardStart;
diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx
index 5ec1b881317d6..712a46dc32e08 100644
--- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx
+++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.test.tsx
@@ -9,13 +9,13 @@ import {
OpenFlyoutAddDrilldownParams,
} from './flyout_create_drilldown';
import { coreMock } from '../../../../../../../../src/core/public/mocks';
-import { drilldownsPluginMock } from '../../../../../../drilldowns/public/mocks';
import { ViewMode } from '../../../../../../../../src/plugins/embeddable/public';
import { TriggerContextMapping } from '../../../../../../../../src/plugins/ui_actions/public';
import { MockEmbeddable, enhanceEmbeddable } from '../test_helpers';
+import { uiActionsEnhancedPluginMock } from '../../../../../../ui_actions_enhanced/public/mocks';
const overlays = coreMock.createStart().overlays;
-const drilldowns = drilldownsPluginMock.createStartContract();
+const uiActionsEnhanced = uiActionsEnhancedPluginMock.createStartContract();
const actionParams: OpenFlyoutAddDrilldownParams = {
start: () => ({
@@ -23,7 +23,7 @@ const actionParams: OpenFlyoutAddDrilldownParams = {
overlays,
} as any,
plugins: {
- drilldowns,
+ uiActionsEnhanced,
},
self: {},
}),
diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx
index 326cd551c7f84..4804a700c6cff 100644
--- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx
+++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_create_drilldown/flyout_create_drilldown.tsx
@@ -16,7 +16,7 @@ import { StartServicesGetter } from '../../../../../../../../src/plugins/kibana_
export const OPEN_FLYOUT_ADD_DRILLDOWN = 'OPEN_FLYOUT_ADD_DRILLDOWN';
export interface OpenFlyoutAddDrilldownParams {
- start: StartServicesGetter>;
+ start: StartServicesGetter>;
}
export class FlyoutCreateDrilldownAction implements ActionByType {
@@ -62,7 +62,7 @@ export class FlyoutCreateDrilldownAction implements ActionByType handle.close()}
viewMode={'create'}
dynamicActionManager={embeddable.enhancements.dynamicActions}
diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.test.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.test.tsx
index 309e6cbf53a3d..b9ae45c2853c3 100644
--- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.test.tsx
+++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.test.tsx
@@ -6,14 +6,12 @@
import { FlyoutEditDrilldownAction, FlyoutEditDrilldownParams } from './flyout_edit_drilldown';
import { coreMock } from '../../../../../../../../src/core/public/mocks';
-import { drilldownsPluginMock } from '../../../../../../drilldowns/public/mocks';
import { ViewMode } from '../../../../../../../../src/plugins/embeddable/public';
import { uiActionsEnhancedPluginMock } from '../../../../../../ui_actions_enhanced/public/mocks';
import { EnhancedEmbeddable } from '../../../../../../embeddable_enhanced/public';
import { MockEmbeddable, enhanceEmbeddable } from '../test_helpers';
const overlays = coreMock.createStart().overlays;
-const drilldowns = drilldownsPluginMock.createStartContract();
const uiActionsPlugin = uiActionsEnhancedPluginMock.createPlugin();
const uiActions = uiActionsPlugin.doStart();
@@ -32,7 +30,7 @@ const actionParams: FlyoutEditDrilldownParams = {
overlays,
} as any,
plugins: {
- drilldowns,
+ uiActionsEnhanced: uiActions,
},
self: {},
}),
diff --git a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx
index 5d2a90fdaff08..af1ae67454463 100644
--- a/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx
+++ b/x-pack/plugins/dashboard_enhanced/public/services/drilldowns/actions/flyout_edit_drilldown/flyout_edit_drilldown.tsx
@@ -20,7 +20,7 @@ import { StartServicesGetter } from '../../../../../../../../src/plugins/kibana_
export const OPEN_FLYOUT_EDIT_DRILLDOWN = 'OPEN_FLYOUT_EDIT_DRILLDOWN';
export interface FlyoutEditDrilldownParams {
- start: StartServicesGetter>;
+ start: StartServicesGetter>;
}
export class FlyoutEditDrilldownAction implements ActionByType {
@@ -58,7 +58,7 @@ export class FlyoutEditDrilldownAction implements ActionByType handle.close()}
viewMode={'manage'}
dynamicActionManager={embeddable.enhancements.dynamicActions}
diff --git a/x-pack/plugins/drilldowns/README.md b/x-pack/plugins/drilldowns/README.md
deleted file mode 100644
index 701b6082d4985..0000000000000
--- a/x-pack/plugins/drilldowns/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Drilldowns
-
-Provides functionality to navigate between Kibana apps with context information.
diff --git a/x-pack/plugins/drilldowns/kibana.json b/x-pack/plugins/drilldowns/kibana.json
deleted file mode 100644
index 1614f94b488fd..0000000000000
--- a/x-pack/plugins/drilldowns/kibana.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "id": "drilldowns",
- "version": "kibana",
- "server": false,
- "ui": true,
- "requiredPlugins": ["uiActions", "embeddable", "uiActionsEnhanced"],
- "configPath": ["xpack", "drilldowns"]
-}
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_frame/i18n.ts b/x-pack/plugins/drilldowns/public/components/flyout_frame/i18n.ts
deleted file mode 100644
index 23af89ebf9bc7..0000000000000
--- a/x-pack/plugins/drilldowns/public/components/flyout_frame/i18n.ts
+++ /dev/null
@@ -1,15 +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 { i18n } from '@kbn/i18n';
-
-export const txtClose = i18n.translate('xpack.drilldowns.components.FlyoutFrame.CloseButtonLabel', {
- defaultMessage: 'Close',
-});
-
-export const txtBack = i18n.translate('xpack.drilldowns.components.FlyoutFrame.BackButtonLabel', {
- defaultMessage: 'Back',
-});
diff --git a/x-pack/plugins/drilldowns/public/index.ts b/x-pack/plugins/drilldowns/public/index.ts
deleted file mode 100644
index f976356822dce..0000000000000
--- a/x-pack/plugins/drilldowns/public/index.ts
+++ /dev/null
@@ -1,18 +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 { DrilldownsPlugin } from './plugin';
-
-export {
- SetupContract as DrilldownsSetup,
- SetupDependencies as DrilldownsSetupDependencies,
- StartContract as DrilldownsStart,
- StartDependencies as DrilldownsStartDependencies,
-} from './plugin';
-
-export function plugin() {
- return new DrilldownsPlugin();
-}
diff --git a/x-pack/plugins/drilldowns/public/mocks.ts b/x-pack/plugins/drilldowns/public/mocks.ts
deleted file mode 100644
index 18816243a3572..0000000000000
--- a/x-pack/plugins/drilldowns/public/mocks.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.
- */
-
-import { DrilldownsSetup, DrilldownsStart } from '.';
-
-export type Setup = jest.Mocked;
-export type Start = jest.Mocked;
-
-const createSetupContract = (): Setup => {
- const setupContract: Setup = {
- registerDrilldown: jest.fn(),
- };
- return setupContract;
-};
-
-const createStartContract = (): Start => {
- const startContract: Start = {
- FlyoutManageDrilldowns: jest.fn(),
- };
-
- return startContract;
-};
-
-export const drilldownsPluginMock = {
- createSetupContract,
- createStartContract,
-};
diff --git a/x-pack/plugins/drilldowns/public/plugin.ts b/x-pack/plugins/drilldowns/public/plugin.ts
deleted file mode 100644
index 2805e2b747934..0000000000000
--- a/x-pack/plugins/drilldowns/public/plugin.ts
+++ /dev/null
@@ -1,48 +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 { CoreStart, CoreSetup, Plugin } from 'src/core/public';
-import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public';
-import { AdvancedUiActionsSetup, AdvancedUiActionsStart } from '../../ui_actions_enhanced/public';
-import { createFlyoutManageDrilldowns } from './components/connected_flyout_manage_drilldowns';
-import { Storage } from '../../../../src/plugins/kibana_utils/public';
-
-export interface SetupDependencies {
- uiActions: UiActionsSetup;
- uiActionsEnhanced: AdvancedUiActionsSetup;
-}
-
-export interface StartDependencies {
- uiActions: UiActionsStart;
- uiActionsEnhanced: AdvancedUiActionsStart;
-}
-
-// eslint-disable-next-line
-export interface SetupContract {}
-
-export interface StartContract {
- FlyoutManageDrilldowns: ReturnType;
-}
-
-export class DrilldownsPlugin
- implements Plugin {
- public setup(core: CoreSetup, plugins: SetupDependencies): SetupContract {
- return {};
- }
-
- public start(core: CoreStart, plugins: StartDependencies): StartContract {
- return {
- FlyoutManageDrilldowns: createFlyoutManageDrilldowns({
- uiActionsEnhanced: plugins.uiActionsEnhanced,
- storage: new Storage(localStorage),
- notifications: core.notifications,
- docsLink: core.docLinks.links.dashboard.drilldowns,
- }),
- };
- }
-
- public stop() {}
-}
diff --git a/x-pack/plugins/encrypted_saved_objects/server/saved_objects/encrypted_saved_objects_client_wrapper.test.ts b/x-pack/plugins/encrypted_saved_objects/server/saved_objects/encrypted_saved_objects_client_wrapper.test.ts
index 7098f611defa0..ec5d81532e238 100644
--- a/x-pack/plugins/encrypted_saved_objects/server/saved_objects/encrypted_saved_objects_client_wrapper.test.ts
+++ b/x-pack/plugins/encrypted_saved_objects/server/saved_objects/encrypted_saved_objects_client_wrapper.test.ts
@@ -676,12 +676,14 @@ describe('#find', () => {
id: 'some-id',
type: 'unknown-type',
attributes: { attrOne: 'one', attrSecret: 'secret', attrThree: 'three' },
+ score: 1,
references: [],
},
{
id: 'some-id-2',
type: 'unknown-type',
attributes: { attrOne: 'one', attrSecret: 'secret', attrThree: 'three' },
+ score: 1,
references: [],
},
],
@@ -722,6 +724,7 @@ describe('#find', () => {
attrNotSoSecret: 'not-so-secret',
attrThree: 'three',
},
+ score: 1,
references: [],
},
{
@@ -733,6 +736,7 @@ describe('#find', () => {
attrNotSoSecret: '*not-so-secret*',
attrThree: 'three',
},
+ score: 1,
references: [],
},
],
@@ -793,6 +797,7 @@ describe('#find', () => {
attrNotSoSecret: 'not-so-secret',
attrThree: 'three',
},
+ score: 1,
references: [],
},
{
@@ -804,6 +809,7 @@ describe('#find', () => {
attrNotSoSecret: '*not-so-secret*',
attrThree: 'three',
},
+ score: 1,
references: [],
},
],
diff --git a/x-pack/plugins/index_management/server/routes/api/component_templates/privileges.test.ts b/x-pack/plugins/index_management/server/routes/api/component_templates/privileges.test.ts
index b34ffe3e0baf5..060a423350ada 100644
--- a/x-pack/plugins/index_management/server/routes/api/component_templates/privileges.test.ts
+++ b/x-pack/plugins/index_management/server/routes/api/component_templates/privileges.test.ts
@@ -4,12 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { httpServerMock, httpServiceMock } from 'src/core/server/mocks';
-import {
- kibanaResponseFactory,
- RequestHandlerContext,
- RequestHandler,
- IRouter,
-} from 'src/core/server';
+import { kibanaResponseFactory, RequestHandlerContext, RequestHandler } from 'src/core/server';
import { License } from '../../../services/license';
import { IndexDataEnricher } from '../../../services/index_data_enricher';
@@ -46,7 +41,7 @@ describe('GET privileges', () => {
let routeHandler: RequestHandler;
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerPrivilegesRoute({
router,
@@ -115,7 +110,7 @@ describe('GET privileges', () => {
describe('With security disabled', () => {
beforeEach(() => {
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
registerPrivilegesRoute({
router,
diff --git a/x-pack/plugins/ingest_manager/common/types/rest_spec/fleet_setup.ts b/x-pack/plugins/ingest_manager/common/types/rest_spec/fleet_setup.ts
index ae4cb4e3fce49..50f275bd59137 100644
--- a/x-pack/plugins/ingest_manager/common/types/rest_spec/fleet_setup.ts
+++ b/x-pack/plugins/ingest_manager/common/types/rest_spec/fleet_setup.ts
@@ -10,5 +10,10 @@ export interface CreateFleetSetupResponse {
export interface GetFleetStatusResponse {
isReady: boolean;
- missing_requirements: Array<'tls_required' | 'api_keys' | 'fleet_admin_user'>;
+ missing_requirements: Array<
+ | 'tls_required'
+ | 'api_keys'
+ | 'fleet_admin_user'
+ | 'encrypted_saved_object_encryption_key_required'
+ >;
}
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/setup_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/setup_page/index.tsx
index ffab5866f3b6f..e9c9ce0c513d2 100644
--- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/setup_page/index.tsx
+++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/setup_page/index.tsx
@@ -39,7 +39,9 @@ export const SetupPage: React.FunctionComponent<{
};
const content =
- missingRequirements.includes('tls_required') || missingRequirements.includes('api_keys') ? (
+ missingRequirements.includes('tls_required') ||
+ missingRequirements.includes('api_keys') ||
+ missingRequirements.includes('encrypted_saved_object_encryption_key_required') ? (
<>
@@ -53,12 +55,13 @@ export const SetupPage: React.FunctionComponent<{
-
+
,
diff --git a/x-pack/plugins/ingest_manager/server/plugin.ts b/x-pack/plugins/ingest_manager/server/plugin.ts
index cd44b61974b03..0d53092a0a8ff 100644
--- a/x-pack/plugins/ingest_manager/server/plugin.ts
+++ b/x-pack/plugins/ingest_manager/server/plugin.ts
@@ -67,7 +67,8 @@ export interface IngestManagerSetupDeps {
export type IngestManagerStartDeps = object;
export interface IngestManagerAppContext {
- encryptedSavedObjects: EncryptedSavedObjectsPluginStart;
+ encryptedSavedObjectsStart: EncryptedSavedObjectsPluginStart;
+ encryptedSavedObjectsSetup?: EncryptedSavedObjectsPluginSetup;
security?: SecurityPluginSetup;
config$?: Observable;
savedObjects: SavedObjectsServiceStart;
@@ -115,6 +116,7 @@ export class IngestManagerPlugin
private isProductionMode: boolean;
private kibanaVersion: string;
private httpSetup: HttpServiceSetup | undefined;
+ private encryptedSavedObjectsSetup: EncryptedSavedObjectsPluginSetup | undefined;
constructor(private readonly initializerContext: PluginInitializerContext) {
this.config$ = this.initializerContext.config.create();
@@ -129,6 +131,7 @@ export class IngestManagerPlugin
if (deps.security) {
this.security = deps.security;
}
+ this.encryptedSavedObjectsSetup = deps.encryptedSavedObjects;
this.cloud = deps.cloud;
registerSavedObjects(core.savedObjects);
@@ -187,12 +190,22 @@ export class IngestManagerPlugin
}
if (config.fleet.enabled) {
- registerAgentRoutes(router);
- registerEnrollmentApiKeyRoutes(router);
- registerInstallScriptRoutes({
- router,
- basePath: core.http.basePath,
- });
+ const isESOUsingEphemeralEncryptionKey =
+ deps.encryptedSavedObjects.usingEphemeralEncryptionKey;
+ if (isESOUsingEphemeralEncryptionKey) {
+ if (this.logger) {
+ this.logger.warn(
+ 'Fleet APIs are disabled due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml.'
+ );
+ }
+ } else {
+ registerAgentRoutes(router);
+ registerEnrollmentApiKeyRoutes(router);
+ registerInstallScriptRoutes({
+ router,
+ basePath: core.http.basePath,
+ });
+ }
}
}
}
@@ -204,7 +217,8 @@ export class IngestManagerPlugin
}
) {
appContextService.start({
- encryptedSavedObjects: plugins.encryptedSavedObjects,
+ encryptedSavedObjectsStart: plugins.encryptedSavedObjects,
+ encryptedSavedObjectsSetup: this.encryptedSavedObjectsSetup,
security: this.security,
config$: this.config$,
savedObjects: core.savedObjects,
diff --git a/x-pack/plugins/ingest_manager/server/routes/setup/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/setup/handlers.ts
index 30eb6c0ae8caa..9808343417390 100644
--- a/x-pack/plugins/ingest_manager/server/routes/setup/handlers.ts
+++ b/x-pack/plugins/ingest_manager/server/routes/setup/handlers.ts
@@ -20,6 +20,8 @@ export const getFleetStatusHandler: RequestHandler = async (context, request, re
const isProductionMode = appContextService.getIsProductionMode();
const isCloud = appContextService.getCloud()?.isCloudEnabled ?? false;
const isTLSCheckDisabled = appContextService.getConfig()?.fleet?.tlsCheckDisabled ?? false;
+ const isUsingEphemeralEncryptionKey = appContextService.getEncryptedSavedObjectsSetup()
+ .usingEphemeralEncryptionKey;
const missingRequirements: GetFleetStatusResponse['missing_requirements'] = [];
if (!isAdminUserSetup) {
@@ -32,6 +34,10 @@ export const getFleetStatusHandler: RequestHandler = async (context, request, re
missingRequirements.push('tls_required');
}
+ if (isUsingEphemeralEncryptionKey) {
+ missingRequirements.push('encrypted_saved_object_encryption_key_required');
+ }
+
const body: GetFleetStatusResponse = {
isReady: missingRequirements.length === 0,
missing_requirements: missingRequirements,
diff --git a/x-pack/plugins/ingest_manager/server/services/agents/acks.test.ts b/x-pack/plugins/ingest_manager/server/services/agents/acks.test.ts
index 0d22529fdb031..efdcbdb5c36bb 100644
--- a/x-pack/plugins/ingest_manager/server/services/agents/acks.test.ts
+++ b/x-pack/plugins/ingest_manager/server/services/agents/acks.test.ts
@@ -24,7 +24,7 @@ describe('test agent acks services', () => {
const mockSavedObjectsClient = savedObjectsClientMock.create();
const mockStartEncryptedSOPlugin = encryptedSavedObjectsMock.createStart();
appContextService.start(({
- encryptedSavedObjects: mockStartEncryptedSOPlugin,
+ encryptedSavedObjectsStart: mockStartEncryptedSOPlugin,
} as unknown) as IngestManagerAppContext);
const [
diff --git a/x-pack/plugins/ingest_manager/server/services/app_context.ts b/x-pack/plugins/ingest_manager/server/services/app_context.ts
index 9e6220b6958f1..81a16caa8ce9e 100644
--- a/x-pack/plugins/ingest_manager/server/services/app_context.ts
+++ b/x-pack/plugins/ingest_manager/server/services/app_context.ts
@@ -6,7 +6,10 @@
import { BehaviorSubject, Observable } from 'rxjs';
import { first } from 'rxjs/operators';
import { SavedObjectsServiceStart, HttpServiceSetup, Logger } from 'src/core/server';
-import { EncryptedSavedObjectsClient } from '../../../encrypted_saved_objects/server';
+import {
+ EncryptedSavedObjectsClient,
+ EncryptedSavedObjectsPluginSetup,
+} from '../../../encrypted_saved_objects/server';
import { SecurityPluginSetup } from '../../../security/server';
import { IngestManagerConfigType } from '../../common';
import { IngestManagerAppContext } from '../plugin';
@@ -14,6 +17,7 @@ import { CloudSetup } from '../../../cloud/server';
class AppContextService {
private encryptedSavedObjects: EncryptedSavedObjectsClient | undefined;
+ private encryptedSavedObjectsSetup: EncryptedSavedObjectsPluginSetup | undefined;
private security: SecurityPluginSetup | undefined;
private config$?: Observable;
private configSubject$?: BehaviorSubject;
@@ -25,7 +29,8 @@ class AppContextService {
private httpSetup?: HttpServiceSetup;
public async start(appContext: IngestManagerAppContext) {
- this.encryptedSavedObjects = appContext.encryptedSavedObjects?.getClient();
+ this.encryptedSavedObjects = appContext.encryptedSavedObjectsStart?.getClient();
+ this.encryptedSavedObjectsSetup = appContext.encryptedSavedObjectsSetup;
this.security = appContext.security;
this.savedObjects = appContext.savedObjects;
this.isProductionMode = appContext.isProductionMode;
@@ -95,6 +100,14 @@ class AppContextService {
return this.httpSetup;
}
+ public getEncryptedSavedObjectsSetup() {
+ if (!this.encryptedSavedObjectsSetup) {
+ throw new Error('encryptedSavedObjectsSetup is not set');
+ }
+
+ return this.encryptedSavedObjectsSetup;
+ }
+
public getKibanaVersion() {
if (!this.kibanaVersion) {
throw new Error('Kibana version is not set.');
diff --git a/x-pack/plugins/lists/common/schemas/types/default_comments_array.ts b/x-pack/plugins/lists/common/schemas/types/default_comments_array.ts
index a80bb968561f0..e824d481b3618 100644
--- a/x-pack/plugins/lists/common/schemas/types/default_comments_array.ts
+++ b/x-pack/plugins/lists/common/schemas/types/default_comments_array.ts
@@ -27,8 +27,8 @@ export const DefaultCommentsArray: DefaultCommentsArrayC = new t.Type<
>(
'DefaultCommentsArray',
t.array(comment).is,
- (input): Either =>
- input == null ? t.success([]) : t.array(comment).decode(input),
+ (input, context): Either =>
+ input == null ? t.success([]) : t.array(comment).validate(input, context),
t.identity
);
@@ -43,7 +43,7 @@ export const DefaultCommentsPartialArray: DefaultCommentsPartialArrayC = new t.T
>(
'DefaultCommentsPartialArray',
t.array(commentPartial).is,
- (input): Either =>
- input == null ? t.success([]) : t.array(commentPartial).decode(input),
+ (input, context): Either =>
+ input == null ? t.success([]) : t.array(commentPartial).validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/lists/common/schemas/types/default_entries_array.ts b/x-pack/plugins/lists/common/schemas/types/default_entries_array.ts
index 43698665bb371..82487f04804f1 100644
--- a/x-pack/plugins/lists/common/schemas/types/default_entries_array.ts
+++ b/x-pack/plugins/lists/common/schemas/types/default_entries_array.ts
@@ -22,7 +22,7 @@ export const DefaultEntryArray: DefaultEntriesArrayC = new t.Type<
>(
'DefaultEntryArray',
t.array(entries).is,
- (input): Either =>
- input == null ? t.success([]) : t.array(entries).decode(input),
+ (input, context): Either =>
+ input == null ? t.success([]) : t.array(entries).validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/lists/common/schemas/types/default_namespace.ts b/x-pack/plugins/lists/common/schemas/types/default_namespace.ts
index ebe2cd60cf6c8..c98cb8d2bba72 100644
--- a/x-pack/plugins/lists/common/schemas/types/default_namespace.ts
+++ b/x-pack/plugins/lists/common/schemas/types/default_namespace.ts
@@ -24,7 +24,7 @@ export const DefaultNamespace: DefaultNamespaceC = new t.Type<
>(
'DefaultNamespace',
namespaceType.is,
- (input): Either =>
- input == null ? t.success('single') : namespaceType.decode(input),
+ (input, context): Either =>
+ input == null ? t.success('single') : namespaceType.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/maps/common/map_saved_object_type.ts b/x-pack/plugins/maps/common/map_saved_object_type.ts
index e5b4876186fd8..e195d9e4538f0 100644
--- a/x-pack/plugins/maps/common/map_saved_object_type.ts
+++ b/x-pack/plugins/maps/common/map_saved_object_type.ts
@@ -13,10 +13,6 @@ export type MapSavedObjectAttributes = {
mapStateJSON?: string;
layerListJSON?: string;
uiStateJSON?: string;
- bounds?: {
- type?: string;
- coordinates?: [];
- };
};
export type MapSavedObject = SavedObject;
diff --git a/x-pack/plugins/maps/common/migrations/remove_bounds.test.ts b/x-pack/plugins/maps/common/migrations/remove_bounds.test.ts
new file mode 100644
index 0000000000000..ac1ffd0d8c890
--- /dev/null
+++ b/x-pack/plugins/maps/common/migrations/remove_bounds.test.ts
@@ -0,0 +1,38 @@
+/*
+ * 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 { removeBoundsFromSavedObject } from './remove_bounds';
+
+describe('removeBoundsFromSavedObject', () => {
+ test('Remove when present', () => {
+ const attributes = {
+ title: 'my map',
+ bounds: {
+ type: 'polygon',
+ coordinates: [
+ [
+ [0, 0],
+ [1, 0],
+ [0, 1],
+ [0, 0],
+ ],
+ ],
+ },
+ };
+ expect(removeBoundsFromSavedObject({ attributes })).toEqual({
+ title: 'my map',
+ });
+ });
+
+ test('No-op when absent', () => {
+ const attributes = {
+ title: 'my map',
+ };
+ expect(removeBoundsFromSavedObject({ attributes })).toEqual({
+ title: 'my map',
+ });
+ });
+});
diff --git a/x-pack/plugins/maps/common/migrations/remove_bounds.ts b/x-pack/plugins/maps/common/migrations/remove_bounds.ts
new file mode 100644
index 0000000000000..05c8d965c2ace
--- /dev/null
+++ b/x-pack/plugins/maps/common/migrations/remove_bounds.ts
@@ -0,0 +1,19 @@
+/*
+ * 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 { MapSavedObjectAttributes } from '../map_saved_object_type';
+
+export function removeBoundsFromSavedObject({
+ attributes,
+}: {
+ attributes: MapSavedObjectAttributes;
+}): MapSavedObjectAttributes {
+ const newAttributes = { ...attributes };
+ // @ts-expect-error
+ // This removes an unused parameter from pre 7.8=< saved objects
+ delete newAttributes.bounds;
+ return { ...newAttributes };
+}
diff --git a/x-pack/plugins/maps/common/migrations/scaling_type.ts b/x-pack/plugins/maps/common/migrations/scaling_type.ts
index 98a06a764f4ec..d77ca03ea50b6 100644
--- a/x-pack/plugins/maps/common/migrations/scaling_type.ts
+++ b/x-pack/plugins/maps/common/migrations/scaling_type.ts
@@ -30,7 +30,8 @@ export function migrateUseTopHitsToScalingType({
sourceDescriptor.scalingType = _.get(layerDescriptor, 'sourceDescriptor.useTopHits', false)
? SCALING_TYPES.TOP_HITS
: SCALING_TYPES.LIMIT;
- // @ts-ignore useTopHits no longer in type definition but that does not mean its not in live data
+ // @ts-expect-error
+ // useTopHits no longer in type definition but that does not mean its not in live data
// hence the entire point of this method
delete sourceDescriptor.useTopHits;
}
diff --git a/x-pack/plugins/maps/public/angular/services/saved_gis_map.js b/x-pack/plugins/maps/public/angular/services/saved_gis_map.js
index ddb58b610f5f1..a0beaa768888a 100644
--- a/x-pack/plugins/maps/public/angular/services/saved_gis_map.js
+++ b/x-pack/plugins/maps/public/angular/services/saved_gis_map.js
@@ -11,16 +11,12 @@ import {
getMapZoom,
getMapCenter,
getLayerListRaw,
- getMapExtent,
getRefreshConfig,
getQuery,
getFilters,
getMapSettings,
} from '../../selectors/map_selectors';
import { getIsLayerTOCOpen, getOpenTOCDetails } from '../../selectors/ui_selectors';
-
-import { formatEnvelopeAsPolygon } from '../../elasticsearch_geo_utils';
-
import { copyPersistentState } from '../../reducers/util';
import { extractReferences, injectReferences } from '../../../common/migrations/references';
import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants';
@@ -38,9 +34,6 @@ export function createSavedGisMapClass(services) {
mapStateJSON: 'text',
layerListJSON: 'text',
uiStateJSON: 'text',
- bounds: {
- type: 'object',
- },
};
static fieldOrder = ['title', 'description'];
static searchSource = false;
@@ -106,8 +99,6 @@ export function createSavedGisMapClass(services) {
isLayerTOCOpen: getIsLayerTOCOpen(state),
openTOCDetails: getOpenTOCDetails(state),
});
-
- this.bounds = formatEnvelopeAsPolygon(getMapExtent(state));
}
}
return SavedGisMap;
diff --git a/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json b/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json
index 5bfe8ae38cac9..017f9e69ffe46 100644
--- a/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json
+++ b/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json
@@ -7,34 +7,7 @@
"description": "",
"mapStateJSON": "{\"zoom\":4.82,\"center\":{\"lon\":11.41545,\"lat\":42.0865},\"timeFilters\":{\"from\":\"now-15w\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"language\":\"lucene\",\"query\":\"\"}}",
"layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"VECTOR\"}]",
- "uiStateJSON": "{}",
- "bounds": {
- "type": "polygon",
- "coordinates": [
- [
- [
- -5.29778,
- 51.54155
- ],
- [
- -5.29778,
- 30.98066
- ],
- [
- 28.12868,
- 30.98066
- ],
- [
- 28.12868,
- 51.54155
- ],
- [
- -5.29778,
- 51.54155
- ]
- ]
- ]
- }
+ "uiStateJSON": "{}"
},
"references": [
],
@@ -49,34 +22,7 @@
"description": "",
"mapStateJSON": "{\"zoom\":3.43,\"center\":{\"lon\":-16.30411,\"lat\":42.88411},\"timeFilters\":{\"from\":\"now-15w\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"lucene\"}}",
"layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"france_departments\"},\"id\":\"65xbw\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.25,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#19c1e6\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"},{\"sourceDescriptor\":{\"id\":\"240125db-e612-4001-b853-50107e55d984\",\"type\":\"ES_SEARCH\",\"indexPatternId\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"geoField\":\"geoip.location\",\"limit\":2048,\"filterByMapBounds\":true,\"tooltipProperties\":[]},\"id\":\"mdae9\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#1ce619\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"}]",
- "uiStateJSON": "{}",
- "bounds": {
- "type": "polygon",
- "coordinates": [
- [
- [
- -59.97005,
- 63.9123
- ],
- [
- -59.97005,
- 11.25616
- ],
- [
- 27.36184,
- 11.25616
- ],
- [
- 27.36184,
- 63.9123
- ],
- [
- -59.97005,
- 63.9123
- ]
- ]
- ]
- }
+ "uiStateJSON": "{}"
},
"references": [
],
@@ -91,34 +37,7 @@
"description": "",
"mapStateJSON": "{\"zoom\":2.12,\"center\":{\"lon\":-88.67592,\"lat\":34.23257},\"timeFilters\":{\"from\":\"now-15m\",\"to\":\"now\",\"mode\":\"quick\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"lucene\"}}",
"layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"canada_provinces\"},\"id\":\"kt086\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#60895e\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"}]",
- "uiStateJSON": "{}",
- "bounds": {
- "type": "polygon",
- "coordinates": [
- [
- [
- 163.37506,
- 77.35215
- ],
- [
- 163.37506,
- -46.80667
- ],
- [
- 19.2731,
- -46.80667
- ],
- [
- 19.2731,
- 77.35215
- ],
- [
- 163.37506,
- 77.35215
- ]
- ]
- ]
- }
+ "uiStateJSON": "{}"
},
"references": [
],
diff --git a/x-pack/plugins/maps/server/saved_objects/map.ts b/x-pack/plugins/maps/server/saved_objects/map.ts
index 05f76c060ca94..0fcadc5a97203 100644
--- a/x-pack/plugins/maps/server/saved_objects/map.ts
+++ b/x-pack/plugins/maps/server/saved_objects/map.ts
@@ -17,7 +17,6 @@ export const mapSavedObjects: SavedObjectsType = {
description: { type: 'text' },
title: { type: 'text' },
version: { type: 'integer' },
- bounds: { type: 'geo_shape' },
mapStateJSON: { type: 'text' },
layerListJSON: { type: 'text' },
uiStateJSON: { type: 'text' },
diff --git a/x-pack/plugins/maps/server/saved_objects/migrations.js b/x-pack/plugins/maps/server/saved_objects/migrations.js
index 5f9576740db29..5db21bb110dbb 100644
--- a/x-pack/plugins/maps/server/saved_objects/migrations.js
+++ b/x-pack/plugins/maps/server/saved_objects/migrations.js
@@ -12,6 +12,7 @@ import { addFieldMetaOptions } from '../../common/migrations/add_field_meta_opti
import { migrateSymbolStyleDescriptor } from '../../common/migrations/migrate_symbol_style_descriptor';
import { migrateUseTopHitsToScalingType } from '../../common/migrations/scaling_type';
import { migrateJoinAggKey } from '../../common/migrations/join_agg_key';
+import { removeBoundsFromSavedObject } from '../../common/migrations/remove_bounds';
export const migrations = {
map: {
@@ -61,6 +62,14 @@ export const migrations = {
'7.8.0': (doc) => {
const attributes = migrateJoinAggKey(doc);
+ return {
+ ...doc,
+ attributes,
+ };
+ },
+ '7.9.0': (doc) => {
+ const attributes = removeBoundsFromSavedObject(doc);
+
return {
...doc,
attributes,
diff --git a/x-pack/plugins/security/server/plugin.test.ts b/x-pack/plugins/security/server/plugin.test.ts
index e01c608e5f306..627d1408673be 100644
--- a/x-pack/plugins/security/server/plugin.test.ts
+++ b/x-pack/plugins/security/server/plugin.test.ts
@@ -36,7 +36,12 @@ describe('Security Plugin', () => {
);
mockCoreSetup = coreMock.createSetup();
- mockCoreSetup.http.isTlsEnabled = true;
+ mockCoreSetup.http.getServerInfo.mockReturnValue({
+ host: 'localhost',
+ name: 'kibana',
+ port: 80,
+ protocol: 'https',
+ });
mockClusterClient = elasticsearchServiceMock.createCustomClusterClient();
mockCoreSetup.elasticsearch.legacy.createClient.mockReturnValue(mockClusterClient);
diff --git a/x-pack/plugins/security/server/plugin.ts b/x-pack/plugins/security/server/plugin.ts
index c8f47aaae7b5d..a14617c8489cc 100644
--- a/x-pack/plugins/security/server/plugin.ts
+++ b/x-pack/plugins/security/server/plugin.ts
@@ -118,7 +118,7 @@ export class Plugin {
this.initializerContext.config.create>().pipe(
map((rawConfig) =>
createConfig(rawConfig, this.initializerContext.logger.get('config'), {
- isTLSEnabled: core.http.isTlsEnabled,
+ isTLSEnabled: core.http.getServerInfo().protocol === 'https',
})
)
),
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/add_prepackged_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/add_prepackged_rules_schema.test.ts
index 5d170f5a78645..f946b3ad3b39b 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/add_prepackged_rules_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/add_prepackged_rules_schema.test.ts
@@ -625,7 +625,7 @@ describe('add prepackaged rules schema', () => {
const decoded = addPrepackagedRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "references"']);
expect(message.schema).toEqual({});
});
@@ -776,7 +776,9 @@ describe('add prepackaged rules schema', () => {
const decoded = addPrepackagedRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "max_signals"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -789,7 +791,7 @@ describe('add prepackaged rules schema', () => {
const decoded = addPrepackagedRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to "max_signals"']);
expect(message.schema).toEqual({});
});
@@ -837,9 +839,9 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "0" supplied to ""',
- 'Invalid value "1" supplied to ""',
- 'Invalid value "2" supplied to ""',
+ 'Invalid value "0" supplied to "tags"',
+ 'Invalid value "1" supplied to "tags"',
+ 'Invalid value "2" supplied to "tags"',
]);
expect(message.schema).toEqual({});
});
@@ -871,7 +873,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "framework"',
+ 'Invalid value "undefined" supplied to "threat,framework"',
]);
expect(message.schema).toEqual({});
});
@@ -899,7 +901,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "tactic"',
+ 'Invalid value "undefined" supplied to "threat,tactic"',
]);
expect(message.schema).toEqual({});
});
@@ -925,7 +927,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "technique"',
+ 'Invalid value "undefined" supplied to "threat,technique"',
]);
expect(message.schema).toEqual({});
});
@@ -959,8 +961,8 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "5" supplied to ""',
- 'Invalid value "4" supplied to ""',
+ 'Invalid value "5" supplied to "false_positives"',
+ 'Invalid value "4" supplied to "false_positives"',
]);
expect(message.schema).toEqual({});
});
@@ -1184,7 +1186,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "group"',
+ 'Invalid value "undefined" supplied to "actions,group"',
]);
expect(message.schema).toEqual({});
});
@@ -1198,7 +1200,9 @@ describe('add prepackaged rules schema', () => {
const decoded = addPrepackagedRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "undefined" supplied to "id"']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "undefined" supplied to "actions,id"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -1212,7 +1216,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1227,7 +1231,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "params"',
+ 'Invalid value "undefined" supplied to "actions,params"',
]);
expect(message.schema).toEqual({});
});
@@ -1249,7 +1253,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1323,8 +1327,7 @@ describe('add prepackaged rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- // TODO: Fix/Change the formatErrors to be better able to handle objects
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"somethingHere":"something else"}" supplied to "note"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts
index e79dde41752a3..00854f1ed5526 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_bulk_schema.test.ts
@@ -250,9 +250,8 @@ describe('create_rules_bulk_schema', () => {
const decoded = createRulesBulkSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const output = foldLeftRight(checked);
- // TODO: We should change the formatter used to better print objects
expect(formatErrors(output.errors)).toEqual([
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"something":"some object"}" supplied to "note"',
]);
expect(output.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts
index d672d38028902..a126b833ba461 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/create_rules_schema.test.ts
@@ -614,7 +614,7 @@ describe('create rules schema', () => {
const decoded = createRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "references"']);
expect(message.schema).toEqual({});
});
@@ -721,7 +721,9 @@ describe('create rules schema', () => {
const decoded = createRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "max_signals"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -734,7 +736,7 @@ describe('create rules schema', () => {
const decoded = createRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to "max_signals"']);
expect(message.schema).toEqual({});
});
@@ -782,9 +784,9 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "0" supplied to ""',
- 'Invalid value "1" supplied to ""',
- 'Invalid value "2" supplied to ""',
+ 'Invalid value "0" supplied to "tags"',
+ 'Invalid value "1" supplied to "tags"',
+ 'Invalid value "2" supplied to "tags"',
]);
expect(message.schema).toEqual({});
});
@@ -816,7 +818,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "framework"',
+ 'Invalid value "undefined" supplied to "threat,framework"',
]);
expect(message.schema).toEqual({});
});
@@ -844,7 +846,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "tactic"',
+ 'Invalid value "undefined" supplied to "threat,tactic"',
]);
expect(message.schema).toEqual({});
});
@@ -870,7 +872,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "technique"',
+ 'Invalid value "undefined" supplied to "threat,technique"',
]);
expect(message.schema).toEqual({});
});
@@ -902,8 +904,8 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "5" supplied to ""',
- 'Invalid value "4" supplied to ""',
+ 'Invalid value "5" supplied to "false_positives"',
+ 'Invalid value "4" supplied to "false_positives"',
]);
expect(message.schema).toEqual({});
});
@@ -1081,7 +1083,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "group"',
+ 'Invalid value "undefined" supplied to "actions,group"',
]);
expect(message.schema).toEqual({});
});
@@ -1095,7 +1097,9 @@ describe('create rules schema', () => {
const decoded = createRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "undefined" supplied to "id"']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "undefined" supplied to "actions,id"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -1109,7 +1113,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1124,7 +1128,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "params"',
+ 'Invalid value "undefined" supplied to "actions,params"',
]);
expect(message.schema).toEqual({});
});
@@ -1146,7 +1150,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1198,8 +1202,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- // TODO: Fix/Change the formatErrors to be better able to handle objects
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"somethingHere":"something else"}" supplied to "note"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/export_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/export_rules_schema.test.ts
index 3e9799a5ad2f9..935b4b33081fa 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/export_rules_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/export_rules_schema.test.ts
@@ -34,10 +34,9 @@ describe('create rules schema', () => {
const decoded = exportRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- // TODO: Change formatter to display a better value than [object Object]
expect(getPaths(left(message.errors))).toEqual([
'Invalid value "undefined" supplied to "objects"',
- 'Invalid value "[object Object]" supplied to ""',
+ 'Invalid value "{}" supplied to "({| objects: Array<{| rule_id: string |}> |} | null)"',
]);
expect(message.schema).toEqual(payload);
});
@@ -70,10 +69,9 @@ describe('create rules schema', () => {
const decoded = exportRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- // TODO: Change formatter to display a better value than [object Object]
expect(getPaths(left(message.errors))).toEqual([
'Invalid value "undefined" supplied to "objects,rule_id"',
- 'Invalid value "[object Object]" supplied to ""',
+ 'Invalid value "{"objects":[{"id":"4a7ff83d-3055-4bb2-ba68-587b9c6c15a4"}]}" supplied to "({| objects: Array<{| rule_id: string |}> |} | null)"',
]);
expect(message.schema).toEqual({});
});
@@ -120,7 +118,9 @@ describe('create rules schema', () => {
const decoded = exportRulesQuerySchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "10" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "10" supplied to "file_name"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -151,7 +151,7 @@ describe('create rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "invalid string" supplied to ""',
+ 'Invalid value "invalid string" supplied to "exclude_export_details"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/import_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/import_rules_schema.test.ts
index be2c3e046fe91..9fe3e95a20621 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/import_rules_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/import_rules_schema.test.ts
@@ -625,7 +625,7 @@ describe('import rules schema', () => {
const decoded = importRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "references"']);
expect(message.schema).toEqual({});
});
@@ -773,7 +773,9 @@ describe('import rules schema', () => {
const decoded = importRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "max_signals"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -786,7 +788,7 @@ describe('import rules schema', () => {
const decoded = importRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to "max_signals"']);
expect(message.schema).toEqual({});
});
@@ -834,9 +836,9 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "0" supplied to ""',
- 'Invalid value "1" supplied to ""',
- 'Invalid value "2" supplied to ""',
+ 'Invalid value "0" supplied to "tags"',
+ 'Invalid value "1" supplied to "tags"',
+ 'Invalid value "2" supplied to "tags"',
]);
expect(message.schema).toEqual({});
});
@@ -868,7 +870,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "framework"',
+ 'Invalid value "undefined" supplied to "threat,framework"',
]);
expect(message.schema).toEqual({});
});
@@ -896,7 +898,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "tactic"',
+ 'Invalid value "undefined" supplied to "threat,tactic"',
]);
expect(message.schema).toEqual({});
});
@@ -922,7 +924,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "technique"',
+ 'Invalid value "undefined" supplied to "threat,technique"',
]);
expect(message.schema).toEqual({});
});
@@ -954,8 +956,8 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "5" supplied to ""',
- 'Invalid value "4" supplied to ""',
+ 'Invalid value "5" supplied to "false_positives"',
+ 'Invalid value "4" supplied to "false_positives"',
]);
expect(message.schema).toEqual({});
});
@@ -1254,7 +1256,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "invalid-string" supplied to ""',
+ 'Invalid value "invalid-string" supplied to "overwrite"',
]);
expect(message.schema).toEqual({});
});
@@ -1377,7 +1379,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "group"',
+ 'Invalid value "undefined" supplied to "actions,group"',
]);
expect(message.schema).toEqual({});
});
@@ -1391,7 +1393,9 @@ describe('import rules schema', () => {
const decoded = importRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "undefined" supplied to "id"']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "undefined" supplied to "actions,id"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -1405,7 +1409,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1420,7 +1424,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "params"',
+ 'Invalid value "undefined" supplied to "actions,params"',
]);
expect(message.schema).toEqual({});
});
@@ -1442,7 +1446,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1513,8 +1517,7 @@ describe('import rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- // TODO: Fix/Change the formatErrors to be better able to handle objects
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"somethingHere":"something else"}" supplied to "note"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_bulk_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_bulk_schema.test.ts
index 7b86c02e5c475..a03bb2db0fd4b 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_bulk_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_bulk_schema.test.ts
@@ -92,9 +92,8 @@ describe('patch_rules_bulk_schema', () => {
const decoded = patchRulesBulkSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const output = foldLeftRight(checked);
- // TODO: Fix the formatter to give something better than [object Object]
expect(formatErrors(output.errors)).toEqual([
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"someprop":"some value here"}" supplied to "note"',
]);
expect(output.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_schema.test.ts
index 921e07a29609c..55363ffb18307 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/patch_rules_schema.test.ts
@@ -1065,9 +1065,8 @@ describe('patch_rules_schema', () => {
const decoded = patchRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- // TODO: Change the formatter to output something more readable than [object Object]
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"someProperty":"something else here"}" supplied to "note"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts
index edc652ce3b3f4..4cb38889045fc 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_bulk_schema.test.ts
@@ -246,9 +246,8 @@ describe('update_rules_bulk_schema', () => {
const decoded = updateRulesBulkSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const output = foldLeftRight(checked);
- // TODO: We should change the formatter used to better print objects
expect(formatErrors(output.errors)).toEqual([
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"something":"some object"}" supplied to "note"',
]);
expect(output.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts
index e60522e1964f4..1ff38f1351f59 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/request/update_rules_schema.test.ts
@@ -608,7 +608,7 @@ describe('update rules schema', () => {
const decoded = updateRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "references"']);
expect(message.schema).toEqual({});
});
@@ -756,7 +756,9 @@ describe('update rules schema', () => {
const decoded = updateRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "max_signals"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -769,7 +771,7 @@ describe('update rules schema', () => {
const decoded = updateRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to "max_signals"']);
expect(message.schema).toEqual({});
});
@@ -817,9 +819,9 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "0" supplied to ""',
- 'Invalid value "1" supplied to ""',
- 'Invalid value "2" supplied to ""',
+ 'Invalid value "0" supplied to "tags"',
+ 'Invalid value "1" supplied to "tags"',
+ 'Invalid value "2" supplied to "tags"',
]);
expect(message.schema).toEqual({});
});
@@ -851,7 +853,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "framework"',
+ 'Invalid value "undefined" supplied to "threat,framework"',
]);
expect(message.schema).toEqual({});
});
@@ -879,7 +881,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "tactic"',
+ 'Invalid value "undefined" supplied to "threat,tactic"',
]);
expect(message.schema).toEqual({});
});
@@ -905,7 +907,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "technique"',
+ 'Invalid value "undefined" supplied to "threat,technique"',
]);
expect(message.schema).toEqual({});
});
@@ -937,8 +939,8 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "5" supplied to ""',
- 'Invalid value "4" supplied to ""',
+ 'Invalid value "5" supplied to "false_positives"',
+ 'Invalid value "4" supplied to "false_positives"',
]);
expect(message.schema).toEqual({});
});
@@ -1173,7 +1175,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "group"',
+ 'Invalid value "undefined" supplied to "actions,group"',
]);
expect(message.schema).toEqual({});
});
@@ -1187,7 +1189,9 @@ describe('update rules schema', () => {
const decoded = updateRulesSchema.decode(payload);
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "undefined" supplied to "id"']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "undefined" supplied to "actions,id"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -1201,7 +1205,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1216,7 +1220,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "params"',
+ 'Invalid value "undefined" supplied to "actions,params"',
]);
expect(message.schema).toEqual({});
});
@@ -1238,7 +1242,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "undefined" supplied to "action_type_id"',
+ 'Invalid value "undefined" supplied to "actions,action_type_id"',
]);
expect(message.schema).toEqual({});
});
@@ -1323,8 +1327,7 @@ describe('update rules schema', () => {
const checked = exactCheck(payload, decoded);
const message = pipe(checked, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- // TODO: Fix/Change the formatErrors to be better able to handle objects
- 'Invalid value "[object Object]" supplied to "note"',
+ 'Invalid value "{"somethingHere":"something else"}" supplied to "note"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_boolean_true.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_boolean_true.test.ts
index a2deaf626624f..1f111515d391a 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_boolean_true.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_boolean_true.test.ts
@@ -33,7 +33,9 @@ describe('default_boolean_true', () => {
const decoded = DefaultBooleanTrue.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultBooleanTrue"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_from_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_from_string.test.ts
index d68d447ca4454..3862fcb95b91d 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_from_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/deafult_from_string.test.ts
@@ -24,7 +24,9 @@ describe('default_from_string', () => {
const decoded = DefaultFromString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultFromString"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.test.ts
index 645eade71916f..ac22d36a062cb 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.test.ts
@@ -39,7 +39,9 @@ describe('default_actions_array', () => {
const decoded = DefaultActionsArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultActionsArray"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.ts
index ce3eb7fa7da83..c69ae591f5ddc 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_actions_array.ts
@@ -15,7 +15,8 @@ import { actions, Actions } from '../common/schemas';
export const DefaultActionsArray = new t.Type(
'DefaultActionsArray',
actions.is,
- (input): Either => (input == null ? t.success([]) : actions.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success([]) : actions.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.test.ts
index 1697928b17e0c..954a0f3651048 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.test.ts
@@ -33,7 +33,9 @@ describe('default_boolean_false', () => {
const decoded = DefaultBooleanFalse.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultBooleanFalse"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.ts
index 624b9802f680c..0cab6525779a6 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_false.ts
@@ -14,8 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultBooleanFalse = new t.Type(
'DefaultBooleanFalse',
t.boolean.is,
- (input): Either =>
- input == null ? t.success(false) : t.boolean.decode(input),
+ (input, context): Either =>
+ input == null ? t.success(false) : t.boolean.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_true.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_true.ts
index 58c912a0a8650..6997652b72636 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_true.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_boolean_true.ts
@@ -14,7 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultBooleanTrue = new t.Type(
'DefaultBooleanTrue',
t.boolean.is,
- (input): Either => (input == null ? t.success(true) : t.boolean.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success(true) : t.boolean.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.test.ts
index 386d4c55905cd..4c59ae44fb8d8 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.test.ts
@@ -24,7 +24,9 @@ describe('default_empty_string', () => {
const decoded = DefaultEmptyString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultEmptyString"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.ts
index 6216d0c1111b0..a1103c4aa8d0e 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_empty_string.ts
@@ -14,7 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultEmptyString = new t.Type(
'DefaultEmptyString',
t.string.is,
- (input): Either => (input == null ? t.success('') : t.string.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success('') : t.string.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.test.ts
index 328cd738d7de0..70aa9501a3080 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.test.ts
@@ -24,7 +24,9 @@ describe('default_export_file_name', () => {
const decoded = DefaultExportFileName.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultExportFileName"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.ts
index 41dfdee1e0da0..4c7f663e7f46d 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_export_file_name.ts
@@ -14,8 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultExportFileName = new t.Type(
'DefaultExportFileName',
t.string.is,
- (input): Either =>
- input == null ? t.success('export.ndjson') : t.string.decode(input),
+ (input, context): Either =>
+ input == null ? t.success('export.ndjson') : t.string.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_from_string.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_from_string.ts
index 4217532de954e..b6b432858eb92 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_from_string.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_from_string.ts
@@ -14,8 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultFromString = new t.Type(
'DefaultFromString',
t.string.is,
- (input): Either =>
- input == null ? t.success('now-6m') : t.string.decode(input),
+ (input, context): Either =>
+ input == null ? t.success('now-6m') : t.string.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.test.ts
index 9720178a4ae9b..c7cda54a54b04 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.test.ts
@@ -24,7 +24,9 @@ describe('default_interval_string', () => {
const decoded = DefaultIntervalString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultIntervalString"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.ts
index 579e7591fdb03..9492374ffe91e 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_interval_string.ts
@@ -14,7 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultIntervalString = new t.Type(
'DefaultIntervalString',
t.string.is,
- (input): Either => (input == null ? t.success('5m') : t.string.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success('5m') : t.string.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.test.ts
index e3da8dbd280ab..e210bcf7d881f 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.test.ts
@@ -25,7 +25,9 @@ describe('default_language_string', () => {
const decoded = DefaultLanguageString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultLanguageString"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.ts
index 248e15d56dfd7..1e05a46d7273c 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_language_string.ts
@@ -15,8 +15,8 @@ import { language } from '../common/schemas';
export const DefaultLanguageString = new t.Type(
'DefaultLanguageString',
t.string.is,
- (input): Either =>
- input == null ? t.success('kuery') : language.decode(input),
+ (input, context): Either =>
+ input == null ? t.success('kuery') : language.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.test.ts
index a6f137c3f2113..33ac02ee1bf53 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.test.ts
@@ -25,7 +25,9 @@ describe('default_from_string', () => {
const decoded = DefaultMaxSignalsNumber.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultMaxSignals"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -34,7 +36,9 @@ describe('default_from_string', () => {
const decoded = DefaultMaxSignalsNumber.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "0" supplied to "DefaultMaxSignals"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -43,7 +47,9 @@ describe('default_from_string', () => {
const decoded = DefaultMaxSignalsNumber.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "DefaultMaxSignals"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.ts
index 6f0c32c5466f3..d3c48b5522f57 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_max_signals_number.ts
@@ -23,8 +23,8 @@ export const DefaultMaxSignalsNumber: DefaultMaxSignalsNumberC = new t.Type<
>(
'DefaultMaxSignals',
t.number.is,
- (input): Either => {
- return input == null ? t.success(DEFAULT_MAX_SIGNALS) : max_signals.decode(input);
+ (input, context): Either => {
+ return input == null ? t.success(DEFAULT_MAX_SIGNALS) : max_signals.validate(input, context);
},
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.test.ts
index 1d1d43667c710..dd90813646319 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.test.ts
@@ -33,7 +33,9 @@ describe('default_page', () => {
const decoded = DefaultPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "NaN" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "NaN" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -42,7 +44,9 @@ describe('default_page', () => {
const decoded = DefaultPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "NaN" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "NaN" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -51,7 +55,9 @@ describe('default_page', () => {
const decoded = DefaultPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "0" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -60,7 +66,9 @@ describe('default_page', () => {
const decoded = DefaultPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.ts
index 95e3b42f3e138..96e01d381e34b 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_page.ts
@@ -17,13 +17,13 @@ import { PositiveIntegerGreaterThanZero } from './positive_integer_greater_than_
export const DefaultPage = new t.Type(
'DefaultPerPage',
t.number.is,
- (input): Either => {
+ (input, context): Either => {
if (input == null) {
return t.success(1);
} else if (typeof input === 'string') {
- return PositiveIntegerGreaterThanZero.decode(parseInt(input, 10));
+ return PositiveIntegerGreaterThanZero.validate(parseInt(input, 10), context);
} else {
- return PositiveIntegerGreaterThanZero.decode(input);
+ return PositiveIntegerGreaterThanZero.validate(input, context);
}
},
t.identity
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.test.ts
index 3ecbae6ed43f5..2115d6d3b52ef 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.test.ts
@@ -33,7 +33,9 @@ describe('default_per_page', () => {
const decoded = DefaultPerPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "NaN" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "NaN" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -42,7 +44,9 @@ describe('default_per_page', () => {
const decoded = DefaultPerPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "NaN" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "NaN" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -51,7 +55,9 @@ describe('default_per_page', () => {
const decoded = DefaultPerPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "0" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -60,7 +66,9 @@ describe('default_per_page', () => {
const decoded = DefaultPerPage.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "DefaultPerPage"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.ts
index f96f280f6af11..b78de8b35cede 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_per_page.ts
@@ -17,13 +17,13 @@ import { PositiveIntegerGreaterThanZero } from './positive_integer_greater_than_
export const DefaultPerPage = new t.Type(
'DefaultPerPage',
t.number.is,
- (input): Either => {
+ (input, context): Either => {
if (input == null) {
return t.success(20);
} else if (typeof input === 'string') {
- return PositiveIntegerGreaterThanZero.decode(parseInt(input, 10));
+ return PositiveIntegerGreaterThanZero.validate(parseInt(input, 10), context);
} else {
- return PositiveIntegerGreaterThanZero.decode(input);
+ return PositiveIntegerGreaterThanZero.validate(input, context);
}
},
t.identity
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.test.ts
index 83142c8d65777..6d352f3ffc4ba 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.test.ts
@@ -33,7 +33,9 @@ describe('default_string_array', () => {
const decoded = DefaultStringArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultStringArray"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.ts
index 1f043cfd1b8e5..a8c53c230acd9 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_array.ts
@@ -14,8 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultStringArray = new t.Type(
'DefaultStringArray',
t.array(t.string).is,
- (input): Either =>
- input == null ? t.success([]) : t.array(t.string).decode(input),
+ (input, context): Either =>
+ input == null ? t.success([]) : t.array(t.string).validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.test.ts
index 1941a642e8baf..dcb264d77b14b 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.test.ts
@@ -33,7 +33,9 @@ describe('default_string_boolean_false', () => {
const decoded = DefaultStringBooleanFalse.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultStringBooleanFalse"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -78,7 +80,9 @@ describe('default_string_boolean_false', () => {
const decoded = DefaultStringBooleanFalse.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "junk" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "junk" supplied to "DefaultStringBooleanFalse"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -87,7 +91,9 @@ describe('default_string_boolean_false', () => {
const decoded = DefaultStringBooleanFalse.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "" supplied to "DefaultStringBooleanFalse"',
+ ]);
expect(message.schema).toEqual({});
});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.ts
index 48a40d4b9ceec..aa070c171d7ea 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_string_boolean_false.ts
@@ -15,7 +15,7 @@ import { Either } from 'fp-ts/lib/Either';
export const DefaultStringBooleanFalse = new t.Type(
'DefaultStringBooleanFalse',
t.boolean.is,
- (input): Either => {
+ (input, context): Either => {
if (input == null) {
return t.success(false);
} else if (typeof input === 'string' && input.toLowerCase() === 'true') {
@@ -23,7 +23,7 @@ export const DefaultStringBooleanFalse = new t.Type(
} else if (typeof input === 'string' && input.toLowerCase() === 'false') {
return t.success(false);
} else {
- return t.boolean.decode(input);
+ return t.boolean.validate(input, context);
}
},
t.identity
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.test.ts
index 9819da0b8d463..42193128cccfa 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.test.ts
@@ -47,7 +47,9 @@ describe('default_threat_null', () => {
const decoded = DefaultThreatArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultThreatArray"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.ts
index da0611e24bc7e..5499a3c1e3064 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_threat_array.ts
@@ -15,7 +15,8 @@ import { Threat, threat } from '../common/schemas';
export const DefaultThreatArray = new t.Type(
'DefaultThreatArray',
threat.is,
- (input): Either => (input == null ? t.success([]) : threat.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success([]) : threat.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.test.ts
index 304fd65647c3c..5b08de40e0aa2 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.test.ts
@@ -25,7 +25,9 @@ describe('default_throttle_null', () => {
const decoded = DefaultThrottleNull.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultThreatNull"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.ts
index fd31594323f4d..b76a35c0265a0 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_throttle_null.ts
@@ -15,8 +15,8 @@ import { ThrottleOrNull, throttle } from '../common/schemas';
export const DefaultThrottleNull = new t.Type(
'DefaultThreatNull',
throttle.is,
- (input): Either =>
- input == null ? t.success(null) : throttle.decode(input),
+ (input, context): Either =>
+ input == null ? t.success(null) : throttle.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.test.ts
index 3e22d57cedf99..96c298c805ccb 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.test.ts
@@ -24,7 +24,9 @@ describe('default_to_string', () => {
const decoded = DefaultToString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultToString"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.ts
index 163bcf8c4e5b2..158eedc121c53 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_to_string.ts
@@ -12,9 +12,10 @@ import { Either } from 'fp-ts/lib/Either';
* - If null or undefined, then a default of the string "now" will be used
*/
export const DefaultToString = new t.Type(
- 'DefaultFromString',
+ 'DefaultToString',
t.string.is,
- (input): Either => (input == null ? t.success('now') : t.string.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success('now') : t.string.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.test.ts
index 7dab8869d5d87..4bfeed479d582 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.test.ts
@@ -24,7 +24,7 @@ describe('default_uuid', () => {
const decoded = DefaultUuid.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to "DefaultUuid"']);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.ts
index b0c328a93ff03..74e32e083cc44 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_uuid.ts
@@ -18,8 +18,8 @@ import { NonEmptyString } from './non_empty_string';
export const DefaultUuid = new t.Type(
'DefaultUuid',
t.string.is,
- (input): Either =>
- input == null ? t.success(uuid.v4()) : NonEmptyString.decode(input),
+ (input, context): Either =>
+ input == null ? t.success(uuid.v4()) : NonEmptyString.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.test.ts
index 65697d8830b66..6d701b94a9c4d 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.test.ts
@@ -24,7 +24,9 @@ describe('default_version_number', () => {
const decoded = DefaultVersionNumber.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "0" supplied to "DefaultVersionNumber"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -33,7 +35,9 @@ describe('default_version_number', () => {
const decoded = DefaultVersionNumber.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "DefaultVersionNumber"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -42,7 +46,9 @@ describe('default_version_number', () => {
const decoded = DefaultVersionNumber.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultVersionNumber"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.ts
index 4a310329660df..832c942291c32 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/default_version_number.ts
@@ -15,7 +15,8 @@ import { version, Version } from '../common/schemas';
export const DefaultVersionNumber = new t.Type(
'DefaultVersionNumber',
version.is,
- (input): Either => (input == null ? t.success(1) : version.decode(input)),
+ (input, context): Either =>
+ input == null ? t.success(1) : version.validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/iso_date_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/iso_date_string.test.ts
index e8bce3f38f4b3..ca9244419b286 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/iso_date_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/iso_date_string.test.ts
@@ -25,7 +25,7 @@ describe('ios_date_string', () => {
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "1582677283067" supplied to ""',
+ 'Invalid value "1582677283067" supplied to "IsoDateString"',
]);
expect(message.schema).toEqual({});
});
@@ -35,7 +35,9 @@ describe('ios_date_string', () => {
const decoded = IsoDateString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "2000" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "2000" supplied to "IsoDateString"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -45,7 +47,7 @@ describe('ios_date_string', () => {
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "Wed, 26 Feb 2020 00:36:20 GMT" supplied to ""',
+ 'Invalid value "Wed, 26 Feb 2020 00:36:20 GMT" supplied to "IsoDateString"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.test.ts
index 31e0a8e5c2c73..9eb55c22756fa 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.test.ts
@@ -173,8 +173,8 @@ describe('lists_default_array', () => {
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "5" supplied to ""',
- 'Invalid value "5" supplied to ""',
+ 'Invalid value "5" supplied to "listsWithDefaultArray"',
+ 'Invalid value "5" supplied to "listsWithDefaultArray"',
]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.ts
index 8cdd865469112..7fe98cdc300ef 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/lists_default_array.ts
@@ -24,8 +24,8 @@ export type ListOperator = t.TypeOf;
export const ListsDefaultArray = new t.Type(
'listsWithDefaultArray',
t.array(listAnd).is,
- (input): Either =>
- input == null ? t.success([]) : t.array(listAnd).decode(input),
+ (input, context): Either =>
+ input == null ? t.success([]) : t.array(listAnd).validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_string.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_string.test.ts
index 0a88b87421e70..0c12aa78cd247 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_string.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/non_empty_string.test.ts
@@ -24,7 +24,9 @@ describe('non_empty_string', () => {
const decoded = NonEmptyString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "NonEmptyString"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -33,7 +35,9 @@ describe('non_empty_string', () => {
const decoded = NonEmptyString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "" supplied to "NonEmptyString"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -42,7 +46,9 @@ describe('non_empty_string', () => {
const decoded = NonEmptyString.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value " " supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value " " supplied to "NonEmptyString"',
+ ]);
expect(message.schema).toEqual({});
});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/only_false_allowed.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/only_false_allowed.test.ts
index 01183e59378bd..a11fec1f064b1 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/only_false_allowed.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/only_false_allowed.test.ts
@@ -24,7 +24,9 @@ describe('only_false_allowed', () => {
const decoded = OnlyFalseAllowed.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "true" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "true" supplied to "DefaultBooleanTrue"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -33,7 +35,9 @@ describe('only_false_allowed', () => {
const decoded = OnlyFalseAllowed.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultBooleanTrue"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/positive_integer_greater_than_zero.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/positive_integer_greater_than_zero.test.ts
index 821eb066a6531..b67825b271216 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/positive_integer_greater_than_zero.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/positive_integer_greater_than_zero.test.ts
@@ -24,7 +24,9 @@ describe('positive_integer_greater_than_zero', () => {
const decoded = PositiveIntegerGreaterThanZero.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "0" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "0" supplied to "PositiveIntegerGreaterThanZero"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -33,7 +35,9 @@ describe('positive_integer_greater_than_zero', () => {
const decoded = PositiveIntegerGreaterThanZero.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "PositiveIntegerGreaterThanZero"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -42,7 +46,9 @@ describe('positive_integer_greater_than_zero', () => {
const decoded = PositiveIntegerGreaterThanZero.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "some string" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "some string" supplied to "PositiveIntegerGreaterThanZero"',
+ ]);
expect(message.schema).toEqual({});
});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/postive_integer.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/postive_integer.test.ts
index ea00ecf5efe0d..7324f5ffda062 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/postive_integer.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/postive_integer.test.ts
@@ -33,7 +33,9 @@ describe('positive_integer_greater_than_zero', () => {
const decoded = PositiveInteger.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "-1" supplied to "PositiveInteger"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -42,7 +44,9 @@ describe('positive_integer_greater_than_zero', () => {
const decoded = PositiveInteger.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "some string" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "some string" supplied to "PositiveInteger"',
+ ]);
expect(message.schema).toEqual({});
});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.test.ts
index 83142c8d65777..6d352f3ffc4ba 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.test.ts
@@ -33,7 +33,9 @@ describe('default_string_array', () => {
const decoded = DefaultStringArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "5" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "5" supplied to "DefaultStringArray"',
+ ]);
expect(message.schema).toEqual({});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.ts
index b809181ce8c32..f246a26bdf4cb 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/references_default_array.ts
@@ -14,8 +14,8 @@ import { Either } from 'fp-ts/lib/Either';
export const ReferencesDefaultArray = new t.Type(
'referencesWithDefaultArray',
t.array(t.string).is,
- (input): Either =>
- input == null ? t.success([]) : t.array(t.string).decode(input),
+ (input, context): Either =>
+ input == null ? t.success([]) : t.array(t.string).validate(input, context),
t.identity
);
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/risk_score.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/risk_score.test.ts
index cf849f28a0963..c8bf3cbecdaaf 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/risk_score.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/risk_score.test.ts
@@ -33,7 +33,7 @@ describe('risk_score', () => {
const decoded = RiskScore.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "-1" supplied to "RiskScore"']);
expect(message.schema).toEqual({});
});
@@ -42,7 +42,9 @@ describe('risk_score', () => {
const decoded = RiskScore.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "some string" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual([
+ 'Invalid value "some string" supplied to "RiskScore"',
+ ]);
expect(message.schema).toEqual({});
});
@@ -51,7 +53,7 @@ describe('risk_score', () => {
const decoded = RiskScore.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "101" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "101" supplied to "RiskScore"']);
expect(message.schema).toEqual({});
});
});
diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/uuid.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/uuid.test.ts
index d3a68a7575487..2bfaa3603d6a7 100644
--- a/x-pack/plugins/security_solution/common/detection_engine/schemas/types/uuid.test.ts
+++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/types/uuid.test.ts
@@ -25,7 +25,7 @@ describe('uuid', () => {
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
- 'Invalid value "4656dc92-5832-11ea-8e2d" supplied to ""',
+ 'Invalid value "4656dc92-5832-11ea-8e2d" supplied to "UUID"',
]);
expect(message.schema).toEqual({});
});
@@ -35,7 +35,7 @@ describe('uuid', () => {
const decoded = UUID.decode(payload);
const message = pipe(decoded, foldLeftRight);
- expect(getPaths(left(message.errors))).toEqual(['Invalid value "" supplied to ""']);
+ expect(getPaths(left(message.errors))).toEqual(['Invalid value "" supplied to "UUID"']);
expect(message.schema).toEqual({});
});
});
diff --git a/x-pack/plugins/security_solution/common/format_errors.test.ts b/x-pack/plugins/security_solution/common/format_errors.test.ts
index f9dd9e76a1d9c..c8cd72b72816b 100644
--- a/x-pack/plugins/security_solution/common/format_errors.test.ts
+++ b/x-pack/plugins/security_solution/common/format_errors.test.ts
@@ -127,4 +127,45 @@ describe('utils', () => {
'Invalid value "Some existing error 1" supplied to "some string key 2"',
]);
});
+
+ test('will use a name context if it cannot find a keyContext', () => {
+ const context: t.Context = ([
+ { key: '' },
+ { key: '', type: { name: 'someName' } },
+ ] as unknown) as t.Context;
+ const validationError1: t.ValidationError = {
+ value: 'Some existing error 1',
+ context,
+ };
+ const errors: t.Errors = [validationError1];
+ const output = formatErrors(errors);
+ expect(output).toEqual(['Invalid value "Some existing error 1" supplied to "someName"']);
+ });
+
+ test('will return an empty string if name does not exist but type does', () => {
+ const context: t.Context = ([{ key: '' }, { key: '', type: {} }] as unknown) as t.Context;
+ const validationError1: t.ValidationError = {
+ value: 'Some existing error 1',
+ context,
+ };
+ const errors: t.Errors = [validationError1];
+ const output = formatErrors(errors);
+ expect(output).toEqual(['Invalid value "Some existing error 1" supplied to ""']);
+ });
+
+ test('will stringify an error value', () => {
+ const context: t.Context = ([
+ { key: '' },
+ { key: 'some string key 2' },
+ ] as unknown) as t.Context;
+ const validationError1: t.ValidationError = {
+ value: { foo: 'some error' },
+ context,
+ };
+ const errors: t.Errors = [validationError1];
+ const output = formatErrors(errors);
+ expect(output).toEqual([
+ 'Invalid value "{"foo":"some error"}" supplied to "some string key 2"',
+ ]);
+ });
});
diff --git a/x-pack/plugins/security_solution/common/format_errors.ts b/x-pack/plugins/security_solution/common/format_errors.ts
index d712979f9eff3..ba963f34f2983 100644
--- a/x-pack/plugins/security_solution/common/format_errors.ts
+++ b/x-pack/plugins/security_solution/common/format_errors.ts
@@ -5,19 +5,25 @@
*/
import * as t from 'io-ts';
+import { isObject } from 'lodash/fp';
export const formatErrors = (errors: t.Errors): string[] => {
return errors.map((error) => {
if (error.message != null) {
return error.message;
} else {
- const mappedContext = error.context
+ const keyContext = error.context
.filter(
(entry) => entry.key != null && !Number.isInteger(+entry.key) && entry.key.trim() !== ''
)
.map((entry) => entry.key)
.join(',');
- return `Invalid value "${error.value}" supplied to "${mappedContext}"`;
+
+ const nameContext = error.context.find((entry) => entry.type?.name?.length > 0);
+ const suppliedValue =
+ keyContext !== '' ? keyContext : nameContext != null ? nameContext.type.name : '';
+ const value = isObject(error.value) ? JSON.stringify(error.value) : error.value;
+ return `Invalid value "${value}" supplied to "${suppliedValue}"`;
}
});
};
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts
index fe66496f70dcd..9928ce4807da9 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts
@@ -549,6 +549,7 @@ export const getFindResultStatus = (): SavedObjectsFindResponse<
searchAfterTimeDurations: ['200.00'],
bulkCreateTimeDurations: ['800.43'],
},
+ score: 1,
references: [],
updated_at: '2020-02-18T15:26:51.333Z',
version: 'WzQ2LDFd',
@@ -570,6 +571,7 @@ export const getFindResultStatus = (): SavedObjectsFindResponse<
searchAfterTimeDurations: ['200.00'],
bulkCreateTimeDurations: ['800.43'],
},
+ score: 1,
references: [],
updated_at: '2020-02-18T15:15:58.860Z',
version: 'WzMyLDFd',
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/import_rules_route.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/import_rules_route.test.ts
index 84148231431a1..a1cf9ccc45f38 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/import_rules_route.test.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/routes/rules/import_rules_route.test.ts
@@ -254,16 +254,14 @@ describe('import_rules_route', () => {
errors: [
{
error: {
- // TODO: Change the formatter to do better than output [object Object]
- message: '[object Object]',
+ message: 'Invalid value "undefined" supplied to "rule_id"',
status_code: 400,
},
rule_id: '(unknown id)',
},
{
error: {
- // TODO: Change the formatter to do better than output [object Object]
- message: '[object Object]',
+ message: 'Invalid value "undefined" supplied to "rule_id"',
status_code: 400,
},
rule_id: '(unknown id)',
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts
index 73d3c65774b3d..c4d7df61061bd 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts
@@ -365,9 +365,8 @@ describe('create_rules_stream_from_ndjson', () => {
references: [],
version: 1,
});
- // TODO: Change the formatter to output something better than [object Object]
expect(resultOrError[1].message).toEqual(
- '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]'
+ 'Invalid value "undefined" supplied to "description",Invalid value "undefined" supplied to "risk_score",Invalid value "undefined" supplied to "name",Invalid value "undefined" supplied to "severity",Invalid value "undefined" supplied to "type",Invalid value "undefined" supplied to "rule_id"'
);
expect(resultOrError[2]).toEqual({
actions: [],
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts
index 932a4ef9eed92..d7723232ca921 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts
@@ -7,6 +7,7 @@ import { Transform } from 'stream';
import * as t from 'io-ts';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
+import { formatErrors } from '../../../../common/format_errors';
import { importRuleValidateTypeDependents } from '../../../../common/detection_engine/schemas/request/import_rules_type_dependents';
import { exactCheck } from '../../../../common/exact_check';
import {
@@ -32,7 +33,7 @@ export const validateRules = (): Transform => {
const decoded = importRulesSchema.decode(obj);
const checked = exactCheck(obj, decoded);
const onLeft = (errors: t.Errors): BadRequestError | ImportRulesSchemaDecoded => {
- return new BadRequestError(errors.join());
+ return new BadRequestError(formatErrors(errors).join());
};
const onRight = (schema: ImportRulesSchema): BadRequestError | ImportRulesSchemaDecoded => {
const validationErrors = importRuleValidateTypeDependents(schema);
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts
index 597a74f6efbbd..ed1a239facf79 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts
@@ -33,16 +33,14 @@ describe('get_existing_prepackaged_rules', () => {
});
test('should throw an exception if a pre-packaged rule is not valid', () => {
- // TODO: Improve the error formatter around [object Object]
expect(() => getPrepackagedRules([{ not_valid_made_up_key: true }])).toThrow(
- 'name: "(rule name unknown)", rule_id: "(rule rule_id unknown)" within the folder rules/prepackaged_rules is not a valid detection engine rule. Expect the system to not work with pre-packaged rules until this rule is fixed or the file is removed. Error is: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object], Full rule contents are:\n{\n "not_valid_made_up_key": true\n}'
+ 'name: "(rule name unknown)", rule_id: "(rule rule_id unknown)" within the folder rules/prepackaged_rules is not a valid detection engine rule. Expect the system to not work with pre-packaged rules until this rule is fixed or the file is removed. Error is: Invalid value "undefined" supplied to "description",Invalid value "undefined" supplied to "risk_score",Invalid value "undefined" supplied to "name",Invalid value "undefined" supplied to "severity",Invalid value "undefined" supplied to "type",Invalid value "undefined" supplied to "rule_id",Invalid value "undefined" supplied to "version", Full rule contents are:\n{\n "not_valid_made_up_key": true\n}'
);
});
test('should throw an exception with a message having rule_id and name in it', () => {
- // TODO: Improve the error formatter around [object Object]
expect(() => getPrepackagedRules([{ name: 'rule name', rule_id: 'id-123' }])).toThrow(
- 'name: "rule name", rule_id: "id-123" within the folder rules/prepackaged_rules is not a valid detection engine rule. Expect the system to not work with pre-packaged rules until this rule is fixed or the file is removed. Error is: [object Object],[object Object],[object Object],[object Object],[object Object], Full rule contents are:\n{\n "name": "rule name",\n "rule_id": "id-123"\n}'
+ 'name: "rule name", rule_id: "id-123" within the folder rules/prepackaged_rules is not a valid detection engine rule. Expect the system to not work with pre-packaged rules until this rule is fixed or the file is removed. Error is: Invalid value "undefined" supplied to "description",Invalid value "undefined" supplied to "risk_score",Invalid value "undefined" supplied to "severity",Invalid value "undefined" supplied to "type",Invalid value "undefined" supplied to "version", Full rule contents are:\n{\n "name": "rule name",\n "rule_id": "id-123"\n}'
);
});
});
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.ts
index d2af93c329636..354f8b90fae23 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/get_prepackaged_rules.ts
@@ -7,6 +7,7 @@
import * as t from 'io-ts';
import { fold } from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/pipeable';
+import { formatErrors } from '../../../../common/format_errors';
import { exactCheck } from '../../../../common/exact_check';
import {
addPrepackagedRulesSchema,
@@ -35,11 +36,9 @@ export const validateAllPrepackagedRules = (
`name: "${ruleName}", rule_id: "${ruleId}" within the folder rules/prepackaged_rules ` +
`is not a valid detection engine rule. Expect the system ` +
`to not work with pre-packaged rules until this rule is fixed ` +
- `or the file is removed. Error is: ${errors.join()}, Full rule contents are:\n${JSON.stringify(
- rule,
- null,
- 2
- )}`
+ `or the file is removed. Error is: ${formatErrors(
+ errors
+ ).join()}, Full rule contents are:\n${JSON.stringify(rule, null, 2)}`
);
};
diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/__mocks__/es_results.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/__mocks__/es_results.ts
index 6056e692854af..01ee41e3b877c 100644
--- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/__mocks__/es_results.ts
+++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/__mocks__/es_results.ts
@@ -391,7 +391,7 @@ export const exampleFindRuleStatusResponse: (
total: 1,
per_page: 6,
page: 1,
- saved_objects: mockStatuses,
+ saved_objects: mockStatuses.map((obj) => ({ ...obj, score: 1 })),
});
export const mockLogger: Logger = loggingServiceMock.createLogger();
diff --git a/x-pack/plugins/security_solution/server/utils/read_stream/create_stream_from_ndjson.ts b/x-pack/plugins/security_solution/server/utils/read_stream/create_stream_from_ndjson.ts
index f455ac0696e4e..0eb021bfe2a83 100644
--- a/x-pack/plugins/security_solution/server/utils/read_stream/create_stream_from_ndjson.ts
+++ b/x-pack/plugins/security_solution/server/utils/read_stream/create_stream_from_ndjson.ts
@@ -8,6 +8,7 @@ import { has, isString } from 'lodash/fp';
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import * as t from 'io-ts';
+import { formatErrors } from '../../../common/format_errors';
import { importRuleValidateTypeDependents } from '../../../common/detection_engine/schemas/request/import_rules_type_dependents';
import {
ImportRulesSchemaDecoded,
@@ -47,7 +48,7 @@ export const validateRules = (): Transform => {
const decoded = importRulesSchema.decode(obj);
const checked = exactCheck(obj, decoded);
const onLeft = (errors: t.Errors): BadRequestError | ImportRulesSchemaDecoded => {
- return new BadRequestError(errors.join());
+ return new BadRequestError(formatErrors(errors).join());
};
const onRight = (schema: ImportRulesSchema): BadRequestError | ImportRulesSchemaDecoded => {
const validationErrors = importRuleValidateTypeDependents(schema);
diff --git a/x-pack/plugins/spaces/server/routes/api/external/copy_to_space.test.ts b/x-pack/plugins/spaces/server/routes/api/external/copy_to_space.test.ts
index 09fc990e9935c..53f5a219dda5b 100644
--- a/x-pack/plugins/spaces/server/routes/api/external/copy_to_space.test.ts
+++ b/x-pack/plugins/spaces/server/routes/api/external/copy_to_space.test.ts
@@ -14,7 +14,7 @@ import {
createResolveSavedObjectsImportErrorsMock,
createMockSavedObjectsService,
} from '../__fixtures__';
-import { CoreSetup, IRouter, kibanaResponseFactory, RouteValidatorConfig } from 'src/core/server';
+import { CoreSetup, kibanaResponseFactory, RouteValidatorConfig } from 'src/core/server';
import {
loggingServiceMock,
httpServiceMock,
@@ -54,7 +54,7 @@ describe('copy to space', () => {
const setup = async () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const savedObjectsRepositoryMock = createMockSavedObjectsRepository(spacesSavedObjects);
diff --git a/x-pack/plugins/spaces/server/routes/api/external/delete.test.ts b/x-pack/plugins/spaces/server/routes/api/external/delete.test.ts
index 774b794d77e29..f31ef657642e7 100644
--- a/x-pack/plugins/spaces/server/routes/api/external/delete.test.ts
+++ b/x-pack/plugins/spaces/server/routes/api/external/delete.test.ts
@@ -13,7 +13,6 @@ import {
} from '../__fixtures__';
import {
CoreSetup,
- IRouter,
kibanaResponseFactory,
RouteValidatorConfig,
SavedObjectsErrorHelpers,
@@ -37,7 +36,7 @@ describe('Spaces Public API', () => {
const setup = async () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const savedObjectsRepositoryMock = createMockSavedObjectsRepository(spacesSavedObjects);
diff --git a/x-pack/plugins/spaces/server/routes/api/external/get.test.ts b/x-pack/plugins/spaces/server/routes/api/external/get.test.ts
index 19f9b81baa0b0..55e153cf47f5b 100644
--- a/x-pack/plugins/spaces/server/routes/api/external/get.test.ts
+++ b/x-pack/plugins/spaces/server/routes/api/external/get.test.ts
@@ -11,7 +11,7 @@ import {
mockRouteContext,
} from '../__fixtures__';
import { initGetSpaceApi } from './get';
-import { CoreSetup, IRouter, kibanaResponseFactory } from 'src/core/server';
+import { CoreSetup, kibanaResponseFactory } from 'src/core/server';
import {
loggingServiceMock,
httpServiceMock,
@@ -30,7 +30,7 @@ describe('GET space', () => {
const setup = async () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const coreStart = coreMock.createStart();
diff --git a/x-pack/plugins/spaces/server/routes/api/external/get_all.test.ts b/x-pack/plugins/spaces/server/routes/api/external/get_all.test.ts
index 380cc9dbe5abf..aabd4900c5469 100644
--- a/x-pack/plugins/spaces/server/routes/api/external/get_all.test.ts
+++ b/x-pack/plugins/spaces/server/routes/api/external/get_all.test.ts
@@ -10,7 +10,7 @@ import {
mockRouteContext,
mockRouteContextWithInvalidLicense,
} from '../__fixtures__';
-import { CoreSetup, kibanaResponseFactory, IRouter } from 'src/core/server';
+import { CoreSetup, kibanaResponseFactory } from 'src/core/server';
import {
loggingServiceMock,
httpServiceMock,
@@ -30,7 +30,7 @@ describe('GET /spaces/space', () => {
const setup = async () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const coreStart = coreMock.createStart();
diff --git a/x-pack/plugins/spaces/server/routes/api/external/post.test.ts b/x-pack/plugins/spaces/server/routes/api/external/post.test.ts
index ca3afc04b9798..5e09308f07d31 100644
--- a/x-pack/plugins/spaces/server/routes/api/external/post.test.ts
+++ b/x-pack/plugins/spaces/server/routes/api/external/post.test.ts
@@ -10,7 +10,7 @@ import {
mockRouteContext,
mockRouteContextWithInvalidLicense,
} from '../__fixtures__';
-import { CoreSetup, kibanaResponseFactory, IRouter, RouteValidatorConfig } from 'src/core/server';
+import { CoreSetup, kibanaResponseFactory, RouteValidatorConfig } from 'src/core/server';
import {
loggingServiceMock,
httpServerMock,
@@ -30,7 +30,7 @@ describe('Spaces Public API', () => {
const setup = async () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const coreStart = coreMock.createStart();
diff --git a/x-pack/plugins/spaces/server/routes/api/external/put.test.ts b/x-pack/plugins/spaces/server/routes/api/external/put.test.ts
index 62444fd3e4dfd..7b068d3784043 100644
--- a/x-pack/plugins/spaces/server/routes/api/external/put.test.ts
+++ b/x-pack/plugins/spaces/server/routes/api/external/put.test.ts
@@ -11,7 +11,7 @@ import {
mockRouteContext,
mockRouteContextWithInvalidLicense,
} from '../__fixtures__';
-import { CoreSetup, IRouter, kibanaResponseFactory, RouteValidatorConfig } from 'src/core/server';
+import { CoreSetup, kibanaResponseFactory, RouteValidatorConfig } from 'src/core/server';
import {
loggingServiceMock,
httpServiceMock,
@@ -31,7 +31,7 @@ describe('PUT /api/spaces/space', () => {
const setup = async () => {
const httpService = httpServiceMock.createSetupContract();
- const router = httpService.createRouter('') as jest.Mocked;
+ const router = httpService.createRouter();
const coreStart = coreMock.createStart();
diff --git a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts
index 75cd501a1a9ae..190429d2dacd4 100644
--- a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts
+++ b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts
@@ -138,7 +138,7 @@ const ERROR_NAMESPACE_SPECIFIED = 'Spaces currently determines the namespaces';
test(`passes options.type to baseClient if valid singular type specified`, async () => {
const { client, baseClient } = await createSpacesSavedObjectsClient();
const expectedReturnValue = {
- saved_objects: [createMockResponse()],
+ saved_objects: [createMockResponse()].map((obj) => ({ ...obj, score: 1 })),
total: 1,
per_page: 0,
page: 0,
@@ -158,7 +158,7 @@ const ERROR_NAMESPACE_SPECIFIED = 'Spaces currently determines the namespaces';
test(`supplements options with the current namespace`, async () => {
const { client, baseClient } = await createSpacesSavedObjectsClient();
const expectedReturnValue = {
- saved_objects: [createMockResponse()],
+ saved_objects: [createMockResponse()].map((obj) => ({ ...obj, score: 1 })),
total: 1,
per_page: 0,
page: 0,
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index 488fde10fe96d..d119ddb5a1a1f 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -3970,6 +3970,27 @@
"xpack.uiActionsEnhanced.customizeTimeRangeMenuItem.displayName": "時間範囲のカスタマイズ",
"xpack.uiActionsEnhanced.components.DiscoverDrilldownConfig.chooseIndexPattern": "対象インデックスパターンを選択",
"xpack.uiActionsEnhanced.drilldown.goToDiscover": "Discoverに移動(例)",
+ "xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.helpText": "ドロップダウンを使用すると、パネルを操作するときに、新しい動作を定義できます。複数のオプションを追加するか、既定のフィルタリング動作を上書きできます。",
+ "xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel": "非表示",
+ "xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel": "ドキュメントを表示",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.createDrilldownButtonLabel": "ドリルダウンを作成",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.createDrilldownTitle": "ドリルダウンを作成",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.deleteDrilldownButtonLabel": "ドリルダウンを削除",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.editDrilldownButtonLabel": "保存",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.editDrilldownTitle": "ドリルダウンを編集",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedText": "ドリルダウンを削除しました。",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedTitle": "ドリルダウンが削除されました",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsCRUDErrorTitle": "ドリルダウンの保存エラー",
+ "xpack.uiActionsEnhanced.drilldowns.components.FlyoutFrame.BackButtonLabel": "戻る",
+ "xpack.uiActionsEnhanced.drilldowns.components.FlyoutFrame.CloseButtonLabel": "閉じる",
+ "xpack.uiActionsEnhanced.drilldowns.components.FlyoutListManageDrilldowns.manageDrilldownsTitle": "ドリルダウンを管理",
+ "xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.drilldownAction": "アクション",
+ "xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.nameOfDrilldown": "名前",
+ "xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.untitledDrilldown": "無題のドリルダウン",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.createDrilldownButtonLabel": "新規作成...",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.deleteDrilldownsButtonLabel": "削除({count})",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.editDrilldownButtonLabel": "編集",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.selectThisDrilldownCheckboxLabel": "このドリルダウンを選択",
"xpack.alerts.alertNavigationRegistry.get.missingNavigationError": "「{consumer}」内のアラートタイプ「{alertType}」のナビゲーションは登録されていません。",
"xpack.alerts.alertNavigationRegistry.register.duplicateDefaultError": "「{consumer}」内のデフォルトナビゲーションは既に登録されています。",
"xpack.alerts.alertNavigationRegistry.register.duplicateNavigationError": "「{consumer}」内のアラートタイプ「{alertType}」のナビゲーションは既に登録されています。",
@@ -6121,27 +6142,6 @@
"xpack.data.kueryAutocomplete.orOperatorDescription.oneOrMoreArgumentsText": "1つ以上の引数",
"xpack.data.query.queryBar.cancelLongQuery": "キャンセル",
"xpack.data.query.queryBar.runBeyond": "タイムアウトを越えて実行",
- "xpack.drilldowns.components.DrilldownHelloBar.helpText": "ドロップダウンを使用すると、パネルを操作するときに、新しい動作を定義できます。複数のオプションを追加するか、既定のフィルタリング動作を上書きできます。",
- "xpack.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel": "非表示",
- "xpack.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel": "ドキュメントを表示",
- "xpack.drilldowns.components.flyoutDrilldownWizard.createDrilldownButtonLabel": "ドリルダウンを作成",
- "xpack.drilldowns.components.flyoutDrilldownWizard.createDrilldownTitle": "ドリルダウンを作成",
- "xpack.drilldowns.components.flyoutDrilldownWizard.deleteDrilldownButtonLabel": "ドリルダウンを削除",
- "xpack.drilldowns.components.flyoutDrilldownWizard.editDrilldownButtonLabel": "保存",
- "xpack.drilldowns.components.flyoutDrilldownWizard.editDrilldownTitle": "ドリルダウンを編集",
- "xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedText": "ドリルダウンを削除しました。",
- "xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedTitle": "ドリルダウンが削除されました",
- "xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsCRUDErrorTitle": "ドリルダウンの保存エラー",
- "xpack.drilldowns.components.FlyoutFrame.BackButtonLabel": "戻る",
- "xpack.drilldowns.components.FlyoutFrame.CloseButtonLabel": "閉じる",
- "xpack.drilldowns.components.FlyoutListManageDrilldowns.manageDrilldownsTitle": "ドリルダウンを管理",
- "xpack.drilldowns.components.FormCreateDrilldown.drilldownAction": "アクション",
- "xpack.drilldowns.components.FormCreateDrilldown.nameOfDrilldown": "名前",
- "xpack.drilldowns.components.FormCreateDrilldown.untitledDrilldown": "無題のドリルダウン",
- "xpack.drilldowns.components.ListManageDrilldowns.createDrilldownButtonLabel": "新規作成...",
- "xpack.drilldowns.components.ListManageDrilldowns.deleteDrilldownsButtonLabel": "削除({count})",
- "xpack.drilldowns.components.ListManageDrilldowns.editDrilldownButtonLabel": "編集",
- "xpack.drilldowns.components.ListManageDrilldowns.selectThisDrilldownCheckboxLabel": "このドリルダウンを選択",
"xpack.features.advancedSettingsFeatureName": "高度な設定",
"xpack.features.dashboardFeatureName": "ダッシュボード",
"xpack.features.devToolsFeatureName": "開発ツール",
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 6898093c19fe8..240baa3fe7744 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -3973,6 +3973,27 @@
"xpack.uiActionsEnhanced.customizeTimeRangeMenuItem.displayName": "定制时间范围",
"xpack.uiActionsEnhanced.components.DiscoverDrilldownConfig.chooseIndexPattern": "选择目标索引模式",
"xpack.uiActionsEnhanced.drilldown.goToDiscover": "前往 Discover(示例)",
+ "xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.helpText": "向下钻取可用于定义与面板交互时的新行为。可以添加多个选项或仅覆盖默认筛选行为。",
+ "xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel": "隐藏",
+ "xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel": "查看文档",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.createDrilldownButtonLabel": "创建向下钻取",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.createDrilldownTitle": "创建向下钻取",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.deleteDrilldownButtonLabel": "删除向下钻取",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.editDrilldownButtonLabel": "保存",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.editDrilldownTitle": "编辑向下钻取",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedText": "您已删除向下钻取。",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedTitle": "向下钻取已删除",
+ "xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsCRUDErrorTitle": "保存向下钻取时出错",
+ "xpack.uiActionsEnhanced.drilldowns.components.FlyoutFrame.BackButtonLabel": "上一步",
+ "xpack.uiActionsEnhanced.drilldowns.components.FlyoutFrame.CloseButtonLabel": "关闭",
+ "xpack.uiActionsEnhanced.drilldowns.components.FlyoutListManageDrilldowns.manageDrilldownsTitle": "管理向下钻取",
+ "xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.drilldownAction": "操作",
+ "xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.nameOfDrilldown": "名称",
+ "xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.untitledDrilldown": "未命名向下钻取",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.createDrilldownButtonLabel": "新建",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.deleteDrilldownsButtonLabel": "删除 ({count})",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.editDrilldownButtonLabel": "编辑",
+ "xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.selectThisDrilldownCheckboxLabel": "选择此向下钻取",
"xpack.alerts.alertNavigationRegistry.get.missingNavigationError": "在“{consumer}”内针对告警类型“{alertType}”的导航未注册。",
"xpack.alerts.alertNavigationRegistry.register.duplicateDefaultError": "“{consumer}”内的默认导航已注册。",
"xpack.alerts.alertNavigationRegistry.register.duplicateNavigationError": "在“{consumer}”内针对告警类型“{alertType}”的导航已注册。",
@@ -6124,27 +6145,6 @@
"xpack.data.kueryAutocomplete.orOperatorDescription.oneOrMoreArgumentsText": "一个或多个参数",
"xpack.data.query.queryBar.cancelLongQuery": "取消",
"xpack.data.query.queryBar.runBeyond": "运行超时",
- "xpack.drilldowns.components.DrilldownHelloBar.helpText": "向下钻取可用于定义与面板交互时的新行为。可以添加多个选项或仅覆盖默认筛选行为。",
- "xpack.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel": "隐藏",
- "xpack.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel": "查看文档",
- "xpack.drilldowns.components.flyoutDrilldownWizard.createDrilldownButtonLabel": "创建向下钻取",
- "xpack.drilldowns.components.flyoutDrilldownWizard.createDrilldownTitle": "创建向下钻取",
- "xpack.drilldowns.components.flyoutDrilldownWizard.deleteDrilldownButtonLabel": "删除向下钻取",
- "xpack.drilldowns.components.flyoutDrilldownWizard.editDrilldownButtonLabel": "保存",
- "xpack.drilldowns.components.flyoutDrilldownWizard.editDrilldownTitle": "编辑向下钻取",
- "xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedText": "您已删除向下钻取。",
- "xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedTitle": "向下钻取已删除",
- "xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsCRUDErrorTitle": "保存向下钻取时出错",
- "xpack.drilldowns.components.FlyoutFrame.BackButtonLabel": "上一步",
- "xpack.drilldowns.components.FlyoutFrame.CloseButtonLabel": "关闭",
- "xpack.drilldowns.components.FlyoutListManageDrilldowns.manageDrilldownsTitle": "管理向下钻取",
- "xpack.drilldowns.components.FormCreateDrilldown.drilldownAction": "操作",
- "xpack.drilldowns.components.FormCreateDrilldown.nameOfDrilldown": "名称",
- "xpack.drilldowns.components.FormCreateDrilldown.untitledDrilldown": "未命名向下钻取",
- "xpack.drilldowns.components.ListManageDrilldowns.createDrilldownButtonLabel": "新建",
- "xpack.drilldowns.components.ListManageDrilldowns.deleteDrilldownsButtonLabel": "删除 ({count})",
- "xpack.drilldowns.components.ListManageDrilldowns.editDrilldownButtonLabel": "编辑",
- "xpack.drilldowns.components.ListManageDrilldowns.selectThisDrilldownCheckboxLabel": "选择此向下钻取",
"xpack.features.advancedSettingsFeatureName": "高级设置",
"xpack.features.dashboardFeatureName": "仪表板",
"xpack.features.devToolsFeatureName": "开发工具",
diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx
similarity index 62%
rename from x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx
index 5fde4fc79e433..cd8452ff74ab4 100644
--- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.story.tsx
@@ -12,28 +12,23 @@ import {
dashboardFactory,
urlFactory,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-} from '../../../../ui_actions_enhanced/public/components/action_wizard/test_data';
-import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
-import { StubBrowserStorage } from '../../../../../../src/test_utils/public/stub_browser_storage';
+} from '../../../components/action_wizard/test_data';
+import { Storage } from '../../../../../../../src/plugins/kibana_utils/public';
+import { StubBrowserStorage } from '../../../../../../../src/test_utils/public/stub_browser_storage';
import { mockDynamicActionManager } from './test_data';
+import { ActionFactory } from '../../../dynamic_actions';
const FlyoutManageDrilldowns = createFlyoutManageDrilldowns({
- uiActionsEnhanced: {
- getActionFactories() {
- return [dashboardFactory, urlFactory];
+ actionFactories: [dashboardFactory as ActionFactory, urlFactory as ActionFactory],
+ storage: new Storage(new StubBrowserStorage()),
+ toastService: {
+ addError: (...args: any[]) => {
+ alert(JSON.stringify(args));
+ },
+ addSuccess: (...args: any[]) => {
+ alert(JSON.stringify(args));
},
} as any,
- storage: new Storage(new StubBrowserStorage()),
- notifications: {
- toasts: {
- addError: (...args: any[]) => {
- alert(JSON.stringify(args));
- },
- addSuccess: (...args: any[]) => {
- alert(JSON.stringify(args));
- },
- } as any,
- },
});
storiesOf('components/FlyoutManageDrilldowns', module).add('default', () => (
diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx
similarity index 89%
rename from x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx
index 32cbec795d092..161caa9782f02 100644
--- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.test.tsx
@@ -8,29 +8,23 @@ import React from 'react';
import { cleanup, fireEvent, render, wait } from '@testing-library/react/pure';
import '@testing-library/jest-dom/extend-expect';
import { createFlyoutManageDrilldowns } from './connected_flyout_manage_drilldowns';
-import {
- dashboardFactory,
- urlFactory,
-} from '../../../../ui_actions_enhanced/public/components/action_wizard/test_data';
-import { StubBrowserStorage } from '../../../../../../src/test_utils/public/stub_browser_storage';
-import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
+import { dashboardFactory, urlFactory } from '../../../components/action_wizard/test_data';
+import { StubBrowserStorage } from '../../../../../../../src/test_utils/public/stub_browser_storage';
+import { Storage } from '../../../../../../../src/plugins/kibana_utils/public';
import { mockDynamicActionManager } from './test_data';
import { TEST_SUBJ_DRILLDOWN_ITEM } from '../list_manage_drilldowns';
import { WELCOME_MESSAGE_TEST_SUBJ } from '../drilldown_hello_bar';
-import { coreMock } from '../../../../../../src/core/public/mocks';
+import { coreMock } from '../../../../../../../src/core/public/mocks';
import { NotificationsStart } from 'kibana/public';
import { toastDrilldownsCRUDError } from './i18n';
+import { ActionFactory } from '../../../dynamic_actions';
const storage = new Storage(new StubBrowserStorage());
-const notifications = coreMock.createStart().notifications;
+const toasts = coreMock.createStart().notifications.toasts;
const FlyoutManageDrilldowns = createFlyoutManageDrilldowns({
- uiActionsEnhanced: {
- getActionFactories() {
- return [dashboardFactory, urlFactory];
- },
- } as any,
- storage,
- notifications,
+ actionFactories: [dashboardFactory as ActionFactory, urlFactory as ActionFactory],
+ storage: new Storage(new StubBrowserStorage()),
+ toastService: toasts,
});
// https://github.com/elastic/kibana/issues/59469
@@ -38,8 +32,8 @@ afterEach(cleanup);
beforeEach(() => {
storage.clear();
- (notifications.toasts as jest.Mocked).addSuccess.mockClear();
- (notifications.toasts as jest.Mocked).addError.mockClear();
+ (toasts as jest.Mocked).addSuccess.mockClear();
+ (toasts as jest.Mocked).addError.mockClear();
});
test('Allows to manage drilldowns', async () => {
@@ -163,7 +157,7 @@ test('Create only mode', async () => {
});
fireEvent.click(screen.getAllByText(/Create Drilldown/i)[1]);
- await wait(() => expect(notifications.toasts.addSuccess).toBeCalled());
+ await wait(() => expect(toasts.addSuccess).toBeCalled());
expect(onClose).toBeCalled();
expect(await mockDynamicActionManager.state.get().events.length).toBe(1);
});
@@ -194,7 +188,7 @@ test('After switching between action factories state is restored', async () => {
expect(screen.getByLabelText(/name/i)).toHaveValue('test');
fireEvent.click(screen.getAllByText(/Create Drilldown/i)[1]);
- await wait(() => expect(notifications.toasts.addSuccess).toBeCalled());
+ await wait(() => expect(toasts.addSuccess).toBeCalled());
expect(await (mockDynamicActionManager.state.get().events[0].action.config as any).url).toBe(
'https://elastic.co'
);
@@ -220,7 +214,7 @@ test("Error when can't save drilldown changes", async () => {
});
fireEvent.click(screen.getAllByText(/Create Drilldown/i)[1]);
await wait(() =>
- expect(notifications.toasts.addError).toBeCalledWith(error, { title: toastDrilldownsCRUDError })
+ expect(toasts.addError).toBeCalledWith(error, { title: toastDrilldownsCRUDError })
);
});
diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx
similarity index 86%
rename from x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx
index e05547741871e..fbc72d0470635 100644
--- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/connected_flyout_manage_drilldowns.tsx
@@ -5,24 +5,17 @@
*/
import React, { useEffect, useState } from 'react';
+import { ToastsStart } from 'kibana/public';
import useMountedState from 'react-use/lib/useMountedState';
-import {
- UiActionsEnhancedActionFactory as ActionFactory,
- AdvancedUiActionsStart,
- UiActionsEnhancedDynamicActionManager as DynamicActionManager,
- UiActionsEnhancedSerializedAction,
- UiActionsEnhancedSerializedEvent,
-} from '../../../../ui_actions_enhanced/public';
-import { NotificationsStart } from '../../../../../../src/core/public';
import { DrilldownWizardConfig, FlyoutDrilldownWizard } from '../flyout_drilldown_wizard';
import { FlyoutListManageDrilldowns } from '../flyout_list_manage_drilldowns';
-import { IStorageWrapper } from '../../../../../../src/plugins/kibana_utils/public';
+import { IStorageWrapper } from '../../../../../../../src/plugins/kibana_utils/public';
import {
VALUE_CLICK_TRIGGER,
SELECT_RANGE_TRIGGER,
TriggerContextMapping,
-} from '../../../../../../src/plugins/ui_actions/public';
-import { useContainerState } from '../../../../../../src/plugins/kibana_utils/public';
+} from '../../../../../../../src/plugins/ui_actions/public';
+import { useContainerState } from '../../../../../../../src/plugins/kibana_utils/public';
import { DrilldownListItem } from '../list_manage_drilldowns';
import {
toastDrilldownCreated,
@@ -31,6 +24,12 @@ import {
toastDrilldownsCRUDError,
toastDrilldownsDeleted,
} from './i18n';
+import {
+ ActionFactory,
+ DynamicActionManager,
+ SerializedAction,
+ SerializedEvent,
+} from '../../../dynamic_actions';
interface ConnectedFlyoutManageDrilldownsProps {
dynamicActionManager: DynamicActionManager;
@@ -48,19 +47,16 @@ enum Routes {
}
export function createFlyoutManageDrilldowns({
- uiActionsEnhanced,
+ actionFactories: allActionFactories,
storage,
- notifications,
+ toastService,
docsLink,
}: {
- uiActionsEnhanced: AdvancedUiActionsStart;
+ actionFactories: ActionFactory[];
storage: IStorageWrapper;
- notifications: NotificationsStart;
+ toastService: ToastsStart;
docsLink?: string;
}) {
- // fine to assume this is static,
- // because all action factories should be registered in setup phase
- const allActionFactories = uiActionsEnhanced.getActionFactories();
const allActionFactoriesById = allActionFactories.reduce((acc, next) => {
acc[next.id] = next;
return acc;
@@ -98,7 +94,7 @@ export function createFlyoutManageDrilldowns({
createDrilldown,
editDrilldown,
deleteDrilldown,
- } = useDrilldownsStateManager(props.dynamicActionManager, notifications);
+ } = useDrilldownsStateManager(props.dynamicActionManager, toastService);
/**
* isCompatible promise is not yet resolved.
@@ -130,9 +126,7 @@ export function createFlyoutManageDrilldowns({
/**
* Maps drilldown to list item view model
*/
- function mapToDrilldownToDrilldownListItem(
- drilldown: UiActionsEnhancedSerializedEvent
- ): DrilldownListItem {
+ function mapToDrilldownToDrilldownListItem(drilldown: SerializedEvent): DrilldownListItem {
const actionFactory = allActionFactoriesById[drilldown.action.factoryId];
return {
id: drilldown.eventId,
@@ -260,10 +254,7 @@ function useWelcomeMessage(storage: IStorageWrapper): [boolean, () => void] {
];
}
-function useDrilldownsStateManager(
- actionManager: DynamicActionManager,
- notifications: NotificationsStart
-) {
+function useDrilldownsStateManager(actionManager: DynamicActionManager, toastService: ToastsStart) {
const { events: drilldowns } = useContainerState(actionManager.state);
const [isLoading, setIsLoading] = useState(false);
const isMounted = useMountedState();
@@ -273,7 +264,7 @@ function useDrilldownsStateManager(
try {
await op();
} catch (e) {
- notifications.toasts.addError(e, {
+ toastService.addError(e, {
title: toastDrilldownsCRUDError,
});
if (!isMounted) return;
@@ -283,12 +274,12 @@ function useDrilldownsStateManager(
}
async function createDrilldown(
- action: UiActionsEnhancedSerializedAction,
+ action: SerializedAction,
selectedTriggers: Array
) {
await run(async () => {
await actionManager.createEvent(action, selectedTriggers);
- notifications.toasts.addSuccess({
+ toastService.addSuccess({
title: toastDrilldownCreated.title(action.name),
text: toastDrilldownCreated.text,
});
@@ -297,12 +288,12 @@ function useDrilldownsStateManager(
async function editDrilldown(
drilldownId: string,
- action: UiActionsEnhancedSerializedAction,
+ action: SerializedAction,
selectedTriggers: Array
) {
await run(async () => {
await actionManager.updateEvent(drilldownId, action, selectedTriggers);
- notifications.toasts.addSuccess({
+ toastService.addSuccess({
title: toastDrilldownEdited.title(action.name),
text: toastDrilldownEdited.text,
});
@@ -313,7 +304,7 @@ function useDrilldownsStateManager(
await run(async () => {
drilldownIds = Array.isArray(drilldownIds) ? drilldownIds : [drilldownIds];
await actionManager.deleteEvents(drilldownIds);
- notifications.toasts.addSuccess(
+ toastService.addSuccess(
drilldownIds.length === 1
? {
title: toastDrilldownDeleted.title,
diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/i18n.ts
similarity index 61%
rename from x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/i18n.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/i18n.ts
index 851439eccbe7e..e75ee2634aa43 100644
--- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/i18n.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/i18n.ts
@@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
export const toastDrilldownCreated = {
title: (drilldownName: string) =>
i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownCreatedTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownCreatedTitle',
{
defaultMessage: 'Drilldown "{drilldownName}" created',
values: {
@@ -18,7 +18,7 @@ export const toastDrilldownCreated = {
}
),
text: i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownCreatedText',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownCreatedText',
{
// TODO: remove `Save your dashboard before testing.` part
// when drilldowns are used not only in dashboard
@@ -30,14 +30,17 @@ export const toastDrilldownCreated = {
export const toastDrilldownEdited = {
title: (drilldownName: string) =>
- i18n.translate('xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownEditedTitle', {
- defaultMessage: 'Drilldown "{drilldownName}" updated',
- values: {
- drilldownName,
- },
- }),
+ i18n.translate(
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownEditedTitle',
+ {
+ defaultMessage: 'Drilldown "{drilldownName}" updated',
+ values: {
+ drilldownName,
+ },
+ }
+ ),
text: i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownEditedText',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownEditedText',
{
defaultMessage: 'Save your dashboard before testing.',
}
@@ -46,13 +49,13 @@ export const toastDrilldownEdited = {
export const toastDrilldownDeleted = {
title: i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedTitle',
{
defaultMessage: 'Drilldown deleted',
}
),
text: i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedText',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownDeletedText',
{
defaultMessage: 'Save your dashboard before testing.',
}
@@ -62,14 +65,14 @@ export const toastDrilldownDeleted = {
export const toastDrilldownsDeleted = {
title: (n: number) =>
i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsDeletedTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsDeletedTitle',
{
defaultMessage: '{n} drilldowns deleted',
values: { n },
}
),
text: i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsDeletedText',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsDeletedText',
{
defaultMessage: 'Save your dashboard before testing.',
}
@@ -77,7 +80,7 @@ export const toastDrilldownsDeleted = {
};
export const toastDrilldownsCRUDError = i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsCRUDErrorTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.toast.drilldownsCRUDErrorTitle',
{
defaultMessage: 'Error saving drilldown',
description: 'Title for generic error toast when persisting drilldown updates failed',
diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/index.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/index.ts
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/index.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/index.ts
diff --git a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/test_data.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts
similarity index 90%
rename from x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/test_data.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts
index d585fa0692e8c..58c36e36481b8 100644
--- a/x-pack/plugins/drilldowns/public/components/connected_flyout_manage_drilldowns/test_data.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/connected_flyout_manage_drilldowns/test_data.ts
@@ -9,9 +9,9 @@ import {
UiActionsEnhancedDynamicActionManager as DynamicActionManager,
UiActionsEnhancedDynamicActionManagerState as DynamicActionManagerState,
UiActionsEnhancedSerializedAction,
-} from '../../../../ui_actions_enhanced/public';
-import { TriggerContextMapping } from '../../../../../../src/plugins/ui_actions/public';
-import { createStateContainer } from '../../../../../../src/plugins/kibana_utils/common';
+} from '../../../index';
+import { TriggerContextMapping } from '../../../../../../../src/plugins/ui_actions/public';
+import { createStateContainer } from '../../../../../../../src/plugins/kibana_utils/common';
class MockDynamicActionManager implements PublicMethodsOf {
public readonly state = createStateContainer({
diff --git a/x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/drilldown_hello_bar.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/drilldown_hello_bar.story.tsx
similarity index 93%
rename from x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/drilldown_hello_bar.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/drilldown_hello_bar.story.tsx
index c4a4630397f1c..df168275fceb3 100644
--- a/x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/drilldown_hello_bar.story.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/drilldown_hello_bar.story.tsx
@@ -6,7 +6,7 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
-import { DrilldownHelloBar } from '.';
+import { DrilldownHelloBar } from './index';
const Demo = () => {
const [show, setShow] = React.useState(true);
diff --git a/x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/drilldown_hello_bar.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/drilldown_hello_bar.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/drilldown_hello_bar.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/drilldown_hello_bar.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/i18n.ts
similarity index 73%
rename from x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/i18n.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/i18n.ts
index 622376c5b40ad..e857366690c45 100644
--- a/x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/i18n.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/i18n.ts
@@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
export const txtHelpText = i18n.translate(
- 'xpack.drilldowns.components.DrilldownHelloBar.helpText',
+ 'xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.helpText',
{
defaultMessage:
'Drilldowns enable you to define new behaviors for interacting with panels. You can add multiple actions and override the default filter.',
@@ -15,14 +15,14 @@ export const txtHelpText = i18n.translate(
);
export const txtViewDocsLinkLabel = i18n.translate(
- 'xpack.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.viewDocsLinkLabel',
{
defaultMessage: 'View docs',
}
);
export const txtHideHelpButtonLabel = i18n.translate(
- 'xpack.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.DrilldownHelloBar.hideHelpButtonLabel',
{
defaultMessage: 'Hide',
}
diff --git a/x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/index.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/index.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/drilldown_hello_bar/index.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/drilldown_hello_bar/index.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx
similarity index 90%
rename from x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx
index be048bf920602..2069a83ab8ba0 100644
--- a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.story.tsx
@@ -9,13 +9,13 @@
import * as React from 'react';
import { EuiFlyout } from '@elastic/eui';
import { storiesOf } from '@storybook/react';
-import { FlyoutDrilldownWizard } from '.';
+import { FlyoutDrilldownWizard } from './index';
import {
dashboardFactory,
urlFactory,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
-} from '../../../../ui_actions_enhanced/public/components/action_wizard/test_data';
-import { UiActionsEnhancedActionFactory as ActionFactory } from '../../../../ui_actions_enhanced/public/';
+} from '../../../components/action_wizard/test_data';
+import { ActionFactory } from '../../../dynamic_actions';
storiesOf('components/FlyoutDrilldownWizard', module)
.add('default', () => {
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx
similarity index 98%
rename from x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx
index 8994aac4123e1..58cf2501280c7 100644
--- a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/flyout_drilldown_wizard.tsx
@@ -16,7 +16,7 @@ import {
txtEditDrilldownTitle,
} from './i18n';
import { DrilldownHelloBar } from '../drilldown_hello_bar';
-import { UiActionsEnhancedActionFactory as ActionFactory } from '../../../../ui_actions_enhanced/public';
+import { ActionFactory } from '../../../dynamic_actions';
export interface DrilldownWizardConfig {
name: string;
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/i18n.ts
similarity index 62%
rename from x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/i18n.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/i18n.ts
index a4a2754a444ab..86485dd7b8bbe 100644
--- a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/i18n.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/i18n.ts
@@ -7,35 +7,35 @@
import { i18n } from '@kbn/i18n';
export const txtCreateDrilldownTitle = i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.createDrilldownTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.createDrilldownTitle',
{
defaultMessage: 'Create Drilldown',
}
);
export const txtEditDrilldownTitle = i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.editDrilldownTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.editDrilldownTitle',
{
defaultMessage: 'Edit Drilldown',
}
);
export const txtCreateDrilldownButtonLabel = i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.createDrilldownButtonLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.createDrilldownButtonLabel',
{
defaultMessage: 'Create drilldown',
}
);
export const txtEditDrilldownButtonLabel = i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.editDrilldownButtonLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.editDrilldownButtonLabel',
{
defaultMessage: 'Save',
}
);
export const txtDeleteDrilldownButtonLabel = i18n.translate(
- 'xpack.drilldowns.components.flyoutDrilldownWizard.deleteDrilldownButtonLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.flyoutDrilldownWizard.deleteDrilldownButtonLabel',
{
defaultMessage: 'Delete drilldown',
}
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/index.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/index.ts
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/flyout_drilldown_wizard/index.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_drilldown_wizard/index.ts
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.story.tsx
similarity index 97%
rename from x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.story.tsx
index 7ef0bc5a8bee4..d47c34c4c7ec9 100644
--- a/x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.story.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.story.tsx
@@ -9,7 +9,7 @@
import * as React from 'react';
import { EuiFlyout, EuiButton } from '@elastic/eui';
import { storiesOf } from '@storybook/react';
-import { FlyoutFrame } from '.';
+import { FlyoutFrame } from './index';
storiesOf('components/FlyoutFrame', module)
.add('default', () => {
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.test.tsx
similarity index 98%
rename from x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.test.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.test.tsx
index 0a3989487745f..cdbf36d81de33 100644
--- a/x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.test.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.test.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import { render } from 'react-dom';
import { render as renderTestingLibrary, fireEvent, cleanup } from '@testing-library/react/pure';
-import { FlyoutFrame } from '.';
+import { FlyoutFrame } from './index';
afterEach(cleanup);
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/flyout_frame/flyout_frame.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/flyout_frame.tsx
diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/i18n.ts
new file mode 100644
index 0000000000000..cf0cd95e25c79
--- /dev/null
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/i18n.ts
@@ -0,0 +1,21 @@
+/*
+ * 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 { i18n } from '@kbn/i18n';
+
+export const txtClose = i18n.translate(
+ 'xpack.uiActionsEnhanced.drilldowns.components.FlyoutFrame.CloseButtonLabel',
+ {
+ defaultMessage: 'Close',
+ }
+);
+
+export const txtBack = i18n.translate(
+ 'xpack.uiActionsEnhanced.drilldowns.components.FlyoutFrame.BackButtonLabel',
+ {
+ defaultMessage: 'Back',
+ }
+);
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_frame/index.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/index.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/flyout_frame/index.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_frame/index.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.story.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.story.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/flyout_list_manage_drilldowns.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/i18n.ts
similarity index 79%
rename from x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/i18n.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/i18n.ts
index 0dd4e37d4dddd..f3aba205c0471 100644
--- a/x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/i18n.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/i18n.ts
@@ -7,7 +7,7 @@
import { i18n } from '@kbn/i18n';
export const txtManageDrilldowns = i18n.translate(
- 'xpack.drilldowns.components.FlyoutListManageDrilldowns.manageDrilldownsTitle',
+ 'xpack.uiActionsEnhanced.drilldowns.components.FlyoutListManageDrilldowns.manageDrilldownsTitle',
{
defaultMessage: 'Manage Drilldowns',
}
diff --git a/x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/index.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/index.ts
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/flyout_list_manage_drilldowns/index.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/flyout_list_manage_drilldowns/index.ts
diff --git a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.story.tsx
similarity index 94%
rename from x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.story.tsx
index 2fc35eb6b5298..fe63b0835af9e 100644
--- a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.story.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.story.tsx
@@ -6,7 +6,7 @@
import * as React from 'react';
import { storiesOf } from '@storybook/react';
-import { FormDrilldownWizard } from '.';
+import { FormDrilldownWizard } from './index';
const DemoEditName: React.FC = () => {
const [name, setName] = React.useState('');
diff --git a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.test.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx
similarity index 94%
rename from x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx
index 1813851d728db..622ed58e3625d 100644
--- a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/form_drilldown_wizard.tsx
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/form_drilldown_wizard.tsx
@@ -7,10 +7,8 @@
import React from 'react';
import { EuiFieldText, EuiForm, EuiFormRow, EuiSpacer } from '@elastic/eui';
import { txtDrilldownAction, txtNameOfDrilldown, txtUntitledDrilldown } from './i18n';
-import {
- UiActionsEnhancedActionFactory as ActionFactory,
- ActionWizard,
-} from '../../../../ui_actions_enhanced/public';
+import { ActionFactory } from '../../../dynamic_actions';
+import { ActionWizard } from '../../../components/action_wizard';
const noopFn = () => {};
diff --git a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/i18n.ts
similarity index 68%
rename from x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/i18n.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/i18n.ts
index e9b19ab0afa97..9636b6e8a74e7 100644
--- a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/i18n.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/i18n.ts
@@ -7,21 +7,21 @@
import { i18n } from '@kbn/i18n';
export const txtNameOfDrilldown = i18n.translate(
- 'xpack.drilldowns.components.FormCreateDrilldown.nameOfDrilldown',
+ 'xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.nameOfDrilldown',
{
defaultMessage: 'Name',
}
);
export const txtUntitledDrilldown = i18n.translate(
- 'xpack.drilldowns.components.FormCreateDrilldown.untitledDrilldown',
+ 'xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.untitledDrilldown',
{
defaultMessage: 'Untitled drilldown',
}
);
export const txtDrilldownAction = i18n.translate(
- 'xpack.drilldowns.components.FormCreateDrilldown.drilldownAction',
+ 'xpack.uiActionsEnhanced.drilldowns.components.FormCreateDrilldown.drilldownAction',
{
defaultMessage: 'Action',
}
diff --git a/x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/index.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/index.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/form_drilldown_wizard/index.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/form_drilldown_wizard/index.tsx
diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/index.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/index.ts
new file mode 100644
index 0000000000000..a6bed0078bfd7
--- /dev/null
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/index.ts
@@ -0,0 +1,7 @@
+/*
+ * 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 { createFlyoutManageDrilldowns } from './connected_flyout_manage_drilldowns';
diff --git a/x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/i18n.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/i18n.ts
similarity index 54%
rename from x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/i18n.ts
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/i18n.ts
index fbc7c9dcfb4a1..65087b8523cb1 100644
--- a/x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/i18n.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/i18n.ts
@@ -7,29 +7,32 @@
import { i18n } from '@kbn/i18n';
export const txtCreateDrilldown = i18n.translate(
- 'xpack.drilldowns.components.ListManageDrilldowns.createDrilldownButtonLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.createDrilldownButtonLabel',
{
defaultMessage: 'Create new',
}
);
export const txtEditDrilldown = i18n.translate(
- 'xpack.drilldowns.components.ListManageDrilldowns.editDrilldownButtonLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.editDrilldownButtonLabel',
{
defaultMessage: 'Edit',
}
);
export const txtDeleteDrilldowns = (count: number) =>
- i18n.translate('xpack.drilldowns.components.ListManageDrilldowns.deleteDrilldownsButtonLabel', {
- defaultMessage: 'Delete ({count})',
- values: {
- count,
- },
- });
+ i18n.translate(
+ 'xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.deleteDrilldownsButtonLabel',
+ {
+ defaultMessage: 'Delete ({count})',
+ values: {
+ count,
+ },
+ }
+ );
export const txtSelectDrilldown = i18n.translate(
- 'xpack.drilldowns.components.ListManageDrilldowns.selectThisDrilldownCheckboxLabel',
+ 'xpack.uiActionsEnhanced.drilldowns.components.ListManageDrilldowns.selectThisDrilldownCheckboxLabel',
{
defaultMessage: 'Select this drilldown',
}
diff --git a/x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/index.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/index.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/index.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/index.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/list_manage_drilldowns.story.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/list_manage_drilldowns.story.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/list_manage_drilldowns.story.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/list_manage_drilldowns.story.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/list_manage_drilldowns.test.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/list_manage_drilldowns.test.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/list_manage_drilldowns.test.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/list_manage_drilldowns.test.tsx
diff --git a/x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/list_manage_drilldowns.tsx b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/list_manage_drilldowns.tsx
similarity index 100%
rename from x-pack/plugins/drilldowns/public/components/list_manage_drilldowns/list_manage_drilldowns.tsx
rename to x-pack/plugins/ui_actions_enhanced/public/drilldowns/components/list_manage_drilldowns/list_manage_drilldowns.tsx
diff --git a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/index.ts b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/index.ts
index 7f81a68c803eb..0d469e46fa9fd 100644
--- a/x-pack/plugins/ui_actions_enhanced/public/drilldowns/index.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/drilldowns/index.ts
@@ -5,3 +5,4 @@
*/
export * from './drilldown_definition';
+export * from './components';
diff --git a/x-pack/plugins/ui_actions_enhanced/public/mocks.ts b/x-pack/plugins/ui_actions_enhanced/public/mocks.ts
index 65fde12755beb..196b8f2c1d5c7 100644
--- a/x-pack/plugins/ui_actions_enhanced/public/mocks.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/mocks.ts
@@ -27,6 +27,7 @@ const createStartContract = (): Start => {
...uiActionsPluginMock.createStartContract(),
getActionFactories: jest.fn(),
getActionFactory: jest.fn(),
+ FlyoutManageDrilldowns: jest.fn(),
};
return startContract;
diff --git a/x-pack/plugins/ui_actions_enhanced/public/plugin.ts b/x-pack/plugins/ui_actions_enhanced/public/plugin.ts
index d79996d5ecc1b..04caef92f15a2 100644
--- a/x-pack/plugins/ui_actions_enhanced/public/plugin.ts
+++ b/x-pack/plugins/ui_actions_enhanced/public/plugin.ts
@@ -24,7 +24,6 @@ import {
CUSTOM_TIME_RANGE,
TimeRangeActionContext,
} from './custom_time_range_action';
-
import {
CustomTimeRangeBadge,
CUSTOM_TIME_RANGE_BADGE,
@@ -32,6 +31,8 @@ import {
} from './custom_time_range_badge';
import { CommonlyUsedRange } from './types';
import { UiActionsServiceEnhancements } from './services';
+import { createFlyoutManageDrilldowns } from './drilldowns';
+import { Storage } from '../../../../src/plugins/kibana_utils/public';
interface SetupDependencies {
embeddable: EmbeddableSetup; // Embeddable are needed because they register basic triggers/actions.
@@ -49,7 +50,9 @@ export interface SetupContract
export interface StartContract
extends UiActionsStart,
- Pick {}
+ Pick {
+ FlyoutManageDrilldowns: ReturnType;
+}
declare module '../../../../src/plugins/ui_actions/public' {
export interface ActionContextMapping {
@@ -94,6 +97,12 @@ export class AdvancedUiActionsPublicPlugin
return {
...uiActions,
...this.enhancements,
+ FlyoutManageDrilldowns: createFlyoutManageDrilldowns({
+ actionFactories: this.enhancements.getActionFactories(),
+ storage: new Storage(window?.localStorage),
+ toastService: core.notifications.toasts,
+ docsLink: core.docLinks.links.dashboard.drilldowns,
+ }),
};
}
diff --git a/x-pack/plugins/ui_actions_enhanced/scripts/storybook.js b/x-pack/plugins/ui_actions_enhanced/scripts/storybook.js
index 2a192fc56469e..1e3ab0d96b81c 100644
--- a/x-pack/plugins/ui_actions_enhanced/scripts/storybook.js
+++ b/x-pack/plugins/ui_actions_enhanced/scripts/storybook.js
@@ -9,5 +9,8 @@ import { join } from 'path';
// eslint-disable-next-line
require('@kbn/storybook').runStorybookCli({
name: 'ui_actions_enhanced',
- storyGlobs: [join(__dirname, '..', 'public', 'components', '**', '*.story.tsx')],
+ storyGlobs: [
+ join(__dirname, '..', 'public', 'components', '**', '*.story.tsx'),
+ join(__dirname, '..', 'public', 'drilldowns', 'components', '**', '*.story.tsx'),
+ ],
});
diff --git a/x-pack/scripts/functional_tests.js b/x-pack/scripts/functional_tests.js
index 37b22a687741e..6cafa3eeef08e 100644
--- a/x-pack/scripts/functional_tests.js
+++ b/x-pack/scripts/functional_tests.js
@@ -51,6 +51,7 @@ const onlyNotInCoverageTests = [
require.resolve('../test/licensing_plugin/config.legacy.ts'),
require.resolve('../test/endpoint_api_integration_no_ingest/config.ts'),
require.resolve('../test/reporting_api_integration/config.js'),
+ require.resolve('../test/functional_embedded/config.ts'),
];
require('@kbn/plugin-helpers').babelRegister();
diff --git a/x-pack/test/api_integration/apis/maps/migrations.js b/x-pack/test/api_integration/apis/maps/migrations.js
index 3569d044b5fed..a9ecaac09db9a 100644
--- a/x-pack/test/api_integration/apis/maps/migrations.js
+++ b/x-pack/test/api_integration/apis/maps/migrations.js
@@ -41,7 +41,7 @@ export default function ({ getService }) {
type: 'index-pattern',
},
]);
- expect(resp.body.migrationVersion).to.eql({ map: '7.8.0' });
+ expect(resp.body.migrationVersion).to.eql({ map: '7.9.0' });
expect(resp.body.attributes.layerListJSON.includes('indexPatternRefName')).to.be(true);
});
});
diff --git a/x-pack/test/api_integration/services/ingest_manager.ts b/x-pack/test/api_integration/services/ingest_manager.ts
index bcba36cef42b7..96b1b97a68dc9 100644
--- a/x-pack/test/api_integration/services/ingest_manager.ts
+++ b/x-pack/test/api_integration/services/ingest_manager.ts
@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../ftr_provider_context';
-import { setupRouteService, fleetSetupRouteService } from '../../../plugins/ingest_manager/common';
+import { fleetSetupRouteService } from '../../../plugins/ingest_manager/common';
export function IngestManagerProvider({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
@@ -12,14 +12,11 @@ export function IngestManagerProvider({ getService }: FtrProviderContext) {
async setup() {
const headers = { accept: 'application/json', 'kbn-xsrf': 'some-xsrf-token' };
- const { body } = await supertest
- .get(fleetSetupRouteService.getFleetSetupPath())
+ await supertest
+ .post(fleetSetupRouteService.postFleetSetupPath())
.set(headers)
+ .send({ forceRecreate: true })
.expect(200);
-
- if (!body.isInitialized) {
- await supertest.post(setupRouteService.getSetupPath()).set(headers).expect(200);
- }
},
};
}
diff --git a/x-pack/test/functional_embedded/config.firefox.ts b/x-pack/test/functional_embedded/config.firefox.ts
new file mode 100644
index 0000000000000..2051d1afd4ab3
--- /dev/null
+++ b/x-pack/test/functional_embedded/config.firefox.ts
@@ -0,0 +1,27 @@
+/*
+ * 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 { FtrConfigProviderContext } from '@kbn/test/types/ftr';
+
+export default async function ({ readConfigFile }: FtrConfigProviderContext) {
+ const chromeConfig = await readConfigFile(require.resolve('./config'));
+
+ return {
+ ...chromeConfig.getAll(),
+
+ browser: {
+ type: 'firefox',
+ acceptInsecureCerts: true,
+ },
+
+ suiteTags: {
+ exclude: ['skipFirefox'],
+ },
+
+ junit: {
+ reportName: 'Firefox Kibana Embedded in iframe with X-Pack Security',
+ },
+ };
+}
diff --git a/x-pack/test/functional_embedded/config.ts b/x-pack/test/functional_embedded/config.ts
new file mode 100644
index 0000000000000..95b290ece7db2
--- /dev/null
+++ b/x-pack/test/functional_embedded/config.ts
@@ -0,0 +1,67 @@
+/*
+ * 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 Fs from 'fs';
+import { resolve } from 'path';
+import { CA_CERT_PATH, KBN_CERT_PATH, KBN_KEY_PATH } from '@kbn/dev-utils';
+import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
+import { pageObjects } from '../functional/page_objects';
+
+export default async function ({ readConfigFile }: FtrConfigProviderContext) {
+ const kibanaFunctionalConfig = await readConfigFile(require.resolve('../functional/config.js'));
+
+ const iframeEmbeddedPlugin = resolve(__dirname, './plugins/iframe_embedded');
+
+ const servers = {
+ ...kibanaFunctionalConfig.get('servers'),
+ elasticsearch: {
+ ...kibanaFunctionalConfig.get('servers.elasticsearch'),
+ },
+ kibana: {
+ ...kibanaFunctionalConfig.get('servers.kibana'),
+ protocol: 'https',
+ ssl: {
+ enabled: true,
+ key: Fs.readFileSync(KBN_KEY_PATH).toString('utf8'),
+ certificate: Fs.readFileSync(KBN_CERT_PATH).toString('utf8'),
+ certificateAuthorities: Fs.readFileSync(CA_CERT_PATH).toString('utf8'),
+ },
+ },
+ };
+
+ return {
+ testFiles: [require.resolve('./tests')],
+ servers,
+ services: kibanaFunctionalConfig.get('services'),
+ pageObjects,
+ browser: {
+ acceptInsecureCerts: true,
+ },
+ junit: {
+ reportName: 'Kibana Embedded in iframe with X-Pack Security',
+ },
+
+ esTestCluster: kibanaFunctionalConfig.get('esTestCluster'),
+ apps: {
+ ...kibanaFunctionalConfig.get('apps'),
+ },
+
+ kbnTestServer: {
+ ...kibanaFunctionalConfig.get('kbnTestServer'),
+ serverArgs: [
+ ...kibanaFunctionalConfig.get('kbnTestServer.serverArgs'),
+ `--plugin-path=${iframeEmbeddedPlugin}`,
+ '--server.ssl.enabled=true',
+ `--server.ssl.key=${KBN_KEY_PATH}`,
+ `--server.ssl.certificate=${KBN_CERT_PATH}`,
+ `--server.ssl.certificateAuthorities=${CA_CERT_PATH}`,
+
+ '--xpack.security.sameSiteCookies=None',
+ '--xpack.security.secureCookies=true',
+ ],
+ },
+ };
+}
diff --git a/x-pack/test/functional_embedded/ftr_provider_context.d.ts b/x-pack/test/functional_embedded/ftr_provider_context.d.ts
new file mode 100644
index 0000000000000..5646c06a3cd30
--- /dev/null
+++ b/x-pack/test/functional_embedded/ftr_provider_context.d.ts
@@ -0,0 +1,12 @@
+/*
+ * 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 { GenericFtrProviderContext } from '@kbn/test/types/ftr';
+import { pageObjects } from '../functional/page_objects';
+import { services } from './services';
+
+export type FtrProviderContext = GenericFtrProviderContext;
+export { pageObjects };
diff --git a/x-pack/test/functional_embedded/plugins/iframe_embedded/kibana.json b/x-pack/test/functional_embedded/plugins/iframe_embedded/kibana.json
new file mode 100644
index 0000000000000..ea9f55bd21c6e
--- /dev/null
+++ b/x-pack/test/functional_embedded/plugins/iframe_embedded/kibana.json
@@ -0,0 +1,7 @@
+{
+ "id": "iframe_embedded",
+ "version": "1.0.0",
+ "kibanaVersion": "kibana",
+ "server": true,
+ "ui": false
+}
diff --git a/x-pack/test/functional_embedded/plugins/iframe_embedded/package.json b/x-pack/test/functional_embedded/plugins/iframe_embedded/package.json
new file mode 100644
index 0000000000000..9fa1554e5312b
--- /dev/null
+++ b/x-pack/test/functional_embedded/plugins/iframe_embedded/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "iframe_embedded",
+ "version": "0.0.0",
+ "kibana": {
+ "version": "kibana"
+ },
+ "scripts": {
+ "kbn": "node ../../../../../scripts/kbn.js",
+ "build": "rm -rf './target' && tsc"
+ },
+ "devDependencies": {
+ "typescript": "3.9.5"
+ }
+}
diff --git a/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts b/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts
new file mode 100644
index 0000000000000..976ef19d4d8a7
--- /dev/null
+++ b/x-pack/test/functional_embedded/plugins/iframe_embedded/server/index.ts
@@ -0,0 +1,11 @@
+/*
+ * 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 'kibana/server';
+import { IframeEmbeddedPlugin } from './plugin';
+
+export const plugin = (initContext: PluginInitializerContext) =>
+ new IframeEmbeddedPlugin(initContext);
diff --git a/x-pack/test/functional_embedded/plugins/iframe_embedded/server/plugin.ts b/x-pack/test/functional_embedded/plugins/iframe_embedded/server/plugin.ts
new file mode 100644
index 0000000000000..890fe14cf03cf
--- /dev/null
+++ b/x-pack/test/functional_embedded/plugins/iframe_embedded/server/plugin.ts
@@ -0,0 +1,45 @@
+/*
+ * 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 Url from 'url';
+import { Plugin, CoreSetup, PluginInitializerContext } from 'src/core/server';
+
+function renderBody(iframeUrl: string) {
+ return `
+
+
+
+
+ Kibana embedded in iframe
+
+
+
+
+
+`;
+}
+export class IframeEmbeddedPlugin implements Plugin {
+ constructor(initializerContext: PluginInitializerContext) {}
+
+ public setup(core: CoreSetup) {
+ core.http.resources.register(
+ {
+ path: '/iframe_embedded',
+ validate: false,
+ },
+ async (context, request, response) => {
+ const { protocol, port, host } = core.http.getServerInfo();
+
+ const kibanaUrl = Url.format({ protocol, hostname: host, port });
+
+ return response.renderHtml({
+ body: renderBody(kibanaUrl),
+ });
+ }
+ );
+ }
+ public start() {}
+ public stop() {}
+}
diff --git a/x-pack/plugins/drilldowns/scripts/storybook.js b/x-pack/test/functional_embedded/services.ts
similarity index 53%
rename from x-pack/plugins/drilldowns/scripts/storybook.js
rename to x-pack/test/functional_embedded/services.ts
index 2bfd0eb1a8f19..1bdf67abd89d0 100644
--- a/x-pack/plugins/drilldowns/scripts/storybook.js
+++ b/x-pack/test/functional_embedded/services.ts
@@ -4,10 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { join } from 'path';
+import { services as functionalServices } from '../functional/services';
-// eslint-disable-next-line
-require('@kbn/storybook').runStorybookCli({
- name: 'drilldowns',
- storyGlobs: [join(__dirname, '..', 'public', 'components', '**', '*.story.tsx')],
-});
+export const services = functionalServices;
diff --git a/x-pack/test/functional_embedded/tests/iframe_embedded.ts b/x-pack/test/functional_embedded/tests/iframe_embedded.ts
new file mode 100644
index 0000000000000..9b5c9894a9407
--- /dev/null
+++ b/x-pack/test/functional_embedded/tests/iframe_embedded.ts
@@ -0,0 +1,42 @@
+/*
+ * 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 Url from 'url';
+import expect from '@kbn/expect';
+
+import { FtrProviderContext } from '../ftr_provider_context';
+
+export default function ({ getService, getPageObjects }: FtrProviderContext) {
+ const PageObjects = getPageObjects(['security', 'common']);
+ const browser = getService('browser');
+ const config = getService('config');
+ const testSubjects = getService('testSubjects');
+
+ describe('in iframe', () => {
+ it('should open Kibana for logged-in user', async () => {
+ const isChromeHiddenBefore = await PageObjects.common.isChromeHidden();
+ expect(isChromeHiddenBefore).to.be(true);
+
+ await PageObjects.security.login();
+
+ const { protocol, hostname, port } = config.get('servers.kibana');
+
+ const url = Url.format({
+ protocol,
+ hostname,
+ port,
+ pathname: 'iframe_embedded',
+ });
+
+ await browser.navigateTo(url);
+
+ const iframe = await testSubjects.find('iframe_embedded');
+ await browser.switchToFrame(iframe);
+
+ const isChromeHidden = await PageObjects.common.isChromeHidden();
+ expect(isChromeHidden).to.be(false);
+ });
+ });
+}
diff --git a/x-pack/test/functional_embedded/tests/index.ts b/x-pack/test/functional_embedded/tests/index.ts
new file mode 100644
index 0000000000000..87ac00b242437
--- /dev/null
+++ b/x-pack/test/functional_embedded/tests/index.ts
@@ -0,0 +1,14 @@
+/*
+ * 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 { FtrProviderContext } from '../ftr_provider_context';
+
+export default function ({ loadTestFile }: FtrProviderContext) {
+ describe('Kibana embedded', function () {
+ this.tags('ciGroup2');
+ loadTestFile(require.resolve('./iframe_embedded'));
+ });
+}