From fb3f0b07654b30d62e2e5aa699dff2333ddc39c6 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Wed, 19 May 2021 09:51:34 +0200 Subject: [PATCH 01/18] Upgrade accept 3.0.2 and @hapi/accept 5.0.1 to @hapi/accept 5.0.2 (#100294) --- package.json | 3 +- .../bundle_routes/select_compressed_file.ts | 4 +-- yarn.lock | 33 +++---------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index e1a8714968c4b..57f03fe6f5b35 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set/npm_module", "@elastic/search-ui-app-search-connector": "^1.5.0", "@elastic/ui-ace": "0.2.3", + "@hapi/accept": "^5.0.2", "@hapi/boom": "^9.1.1", "@hapi/cookie": "^11.0.2", "@hapi/good-squeeze": "6.0.0", @@ -171,7 +172,6 @@ "JSONStream": "1.3.5", "abort-controller": "^3.0.0", "abortcontroller-polyfill": "^1.4.0", - "accept": "3.0.2", "ajv": "^6.12.4", "angular": "^1.8.0", "angular-aria": "^1.8.0", @@ -488,7 +488,6 @@ "@testing-library/react": "^11.2.6", "@testing-library/react-hooks": "^5.1.1", "@testing-library/user-event": "^13.1.1", - "@types/accept": "3.1.1", "@types/angular": "^1.6.56", "@types/angular-mocks": "^1.7.0", "@types/archiver": "^5.1.0", diff --git a/src/core/server/core_app/bundle_routes/select_compressed_file.ts b/src/core/server/core_app/bundle_routes/select_compressed_file.ts index c7b071a9c3548..36c63f653618c 100644 --- a/src/core/server/core_app/bundle_routes/select_compressed_file.ts +++ b/src/core/server/core_app/bundle_routes/select_compressed_file.ts @@ -7,10 +7,10 @@ */ import { extname } from 'path'; -import Accept from 'accept'; +import Accept from '@hapi/accept'; import { open } from './fs'; -declare module 'accept' { +declare module '@hapi/accept' { // @types/accept does not include the `preferences` argument so we override the type to include it export function encodings(encodingHeader?: string, preferences?: string[]): string[]; } diff --git a/yarn.lock b/yarn.lock index 53a311857e643..94f37c4ce4f33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1766,10 +1766,10 @@ normalize-path "^2.0.1" through2 "^2.0.3" -"@hapi/accept@^5.0.1": - version "5.0.1" - resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.1.tgz#068553e867f0f63225a506ed74e899441af53e10" - integrity sha512-fMr4d7zLzsAXo28PRRQPXR1o2Wmu+6z+VY1UzDp0iFo13Twj8WePakwXBiqn3E1aAlTpSNzCXdnnQXFhst8h8Q== +"@hapi/accept@^5.0.1", "@hapi/accept@^5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.2.tgz#ab7043b037e68b722f93f376afb05e85c0699523" + integrity sha512-CmzBx/bXUR8451fnZRuZAJRlzgm0Jgu5dltTX/bszmR2lheb9BpyN47Q1RbaGTsvFzn0PXAEs+lXDKfshccYZw== dependencies: "@hapi/boom" "9.x.x" "@hapi/hoek" "9.x.x" @@ -4601,11 +4601,6 @@ dependencies: "@turf/helpers" "6.x" -"@types/accept@3.1.1": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@types/accept/-/accept-3.1.1.tgz#74457f6afabd23181e32b6bafae238bda0ce0da7" - integrity sha512-pXwi0bKUriKuNUv7d1xwbxKTqyTIzmMr1StxcGARmiuTLQyjNo+YwDq0w8dzY8wQjPofdgs1hvQLTuJaGuSKiQ== - "@types/angular-mocks@^1.7.0": version "1.7.0" resolved "https://registry.yarnpkg.com/@types/angular-mocks/-/angular-mocks-1.7.0.tgz#310d999a3c47c10ecd8eef466b5861df84799429" @@ -6481,14 +6476,6 @@ abortcontroller-polyfill@^1.4.0: resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.4.0.tgz#0d5eb58e522a461774af8086414f68e1dda7a6c4" integrity sha512-3ZFfCRfDzx3GFjO6RAkYx81lPGpUS20ISxux9gLxuKnqafNcFQo59+IoZqpO2WvQlyc287B62HDnDdNYRmlvWA== -accept@3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/accept/-/accept-3.0.2.tgz#83e41cec7e1149f3fd474880423873db6c6cc9ac" - integrity sha512-bghLXFkCOsC1Y2TZ51etWfKDs6q249SAoHTZVfzWWdlZxoij+mgkj9AmUJWQpDY48TfnrTDIe43Xem4zdMe7mQ== - dependencies: - boom "7.x.x" - hoek "5.x.x" - accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" @@ -8280,13 +8267,6 @@ boolbase@^1.0.0, boolbase@~1.0.0: resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= -boom@7.x.x: - version "7.2.2" - resolved "https://registry.yarnpkg.com/boom/-/boom-7.2.2.tgz#ac92101451aa5cea901aed07d881dd32b4f08345" - integrity sha512-IFUbOa8PS7xqmhIjpeStwT3d09hGkNYQ6aj2iELSTxcVs2u0aKn1NzhkdUQSzsRg1FVkj3uit3I6mXQCBixw+A== - dependencies: - hoek "6.x.x" - bottleneck@^2.15.3: version "2.18.0" resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.18.0.tgz#41fa63ae185b65435d789d1700334bc48222dacf" @@ -15349,11 +15329,6 @@ hoek@5.x.x: resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.4.tgz#0f7fa270a1cafeb364a4b2ddfaa33f864e4157da" integrity sha512-Alr4ZQgoMlnere5FZJsIyfIjORBqZll5POhDsF4q64dPuJR6rNxXdDxtHSQq8OXRurhmx+PWYEE8bXRROY8h0w== -hoek@6.x.x: - version "6.0.3" - resolved "https://registry.yarnpkg.com/hoek/-/hoek-6.0.3.tgz#7884360426d927865a0a1251fc9c59313af5b798" - integrity sha512-TU6RyZ/XaQCTWRLrdqZZtZqwxUVr6PDMfi6MlWNURZ7A6czanQqX4pFE1mdOUQR9FdPCsZ0UzL8jI/izZ+eBSQ== - hoist-non-react-statics@^2.3.1, hoist-non-react-statics@^2.5.5, hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" From 8f1bf66a7b3099de66cc1924ce258799f1cfacba Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 19 May 2021 13:13:07 +0100 Subject: [PATCH 02/18] skip flaky suite (#100296) --- .../security_solution_endpoint/apps/endpoint/policy_details.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts index fc814d7d2b060..6bddb5d38cf72 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts @@ -627,7 +627,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); }); - describe('when on Ingest Policy Edit Package Policy page', async () => { + // FLAKY: https://github.com/elastic/kibana/issues/100296 + describe.skip('when on Ingest Policy Edit Package Policy page', async () => { let policyInfo: PolicyTestResourceInfo; beforeEach(async () => { // Create a policy and navigate to Ingest app From f97aad30f4be6a6f8a3b541621c2229db225c2ab Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 19 May 2021 16:03:27 +0200 Subject: [PATCH 03/18] [Screenshot mode] Create plugin to provide "screenshot mode" awareness (#99627) * initial version of the screenshot mode service * First iteration of client side of screenshot mode plugin Also hooked it up to the chromium browser imitating the preload functionality of electron to set up the environment before code runs. * First implementation of server-side logic for detecting screenshot mode * fix some type issues and do a small refactor * fix size limits, docs and ts issues * fixed types issues and made sure screenshot mode is correctly detected on the client * Moved the screenshot mode header definition to common Added a server-side example for screenshot mode Export the screenshot mode header in both public and server * move require() to screenshotMode plugin * Update chromium_driver.ts * cleaned up some comments, minor refactor in ReportingCore and changed the screenshotmode detection function to check for a specific value. * fix export * Expanded server-side screenshot mode contract with function that checks a kibana request to determine whether we in screenshot mode * added comments to explain use of literal value rather than external reference * updated comment * update reporting example Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Timothy Sullivan Co-authored-by: Tim Sullivan --- docs/developer/plugin-list.asciidoc | 4 + examples/screenshot_mode_example/.i18nrc.json | 7 + examples/screenshot_mode_example/README.md | 9 ++ .../screenshot_mode_example/common/index.ts | 11 ++ examples/screenshot_mode_example/kibana.json | 9 ++ .../public/application.tsx | 33 +++++ .../public/components/app.tsx | 122 ++++++++++++++++++ .../screenshot_mode_example/public/index.scss | 0 .../screenshot_mode_example/public/index.ts | 17 +++ .../screenshot_mode_example/public/plugin.ts | 48 +++++++ .../public/services/index.ts | 9 ++ .../public/services/metrics_tracking.ts | 37 ++++++ .../screenshot_mode_example/public/types.ts | 20 +++ .../screenshot_mode_example/server/index.ts | 12 ++ .../screenshot_mode_example/server/plugin.ts | 31 +++++ .../screenshot_mode_example/server/routes.ts | 21 +++ .../screenshot_mode_example/server/types.ts | 19 +++ .../screenshot_mode_example/tsconfig.json | 17 +++ packages/kbn-optimizer/limits.yml | 1 + src/plugins/screenshot_mode/.i18nrc.json | 7 + src/plugins/screenshot_mode/README.md | 27 ++++ .../screenshot_mode/common/constants.ts | 9 ++ .../common/get_set_browser_screenshot_mode.ts | 63 +++++++++ src/plugins/screenshot_mode/common/index.ts | 15 +++ src/plugins/screenshot_mode/jest.config.js | 13 ++ src/plugins/screenshot_mode/kibana.json | 9 ++ src/plugins/screenshot_mode/public/index.ts | 17 +++ .../screenshot_mode/public/plugin.test.ts | 43 ++++++ src/plugins/screenshot_mode/public/plugin.ts | 25 ++++ src/plugins/screenshot_mode/public/types.ts | 17 +++ src/plugins/screenshot_mode/server/index.ts | 21 +++ .../server/is_screenshot_mode.test.ts | 25 ++++ .../server/is_screenshot_mode.ts | 16 +++ src/plugins/screenshot_mode/server/plugin.ts | 47 +++++++ src/plugins/screenshot_mode/server/types.ts | 35 +++++ src/plugins/screenshot_mode/tsconfig.json | 18 +++ x-pack/examples/reporting_example/kibana.json | 2 +- .../reporting_example/public/application.tsx | 9 +- .../public/components/app.tsx | 5 + .../reporting_example/public/plugin.ts | 4 +- .../reporting_example/public/types.ts | 4 +- x-pack/plugins/reporting/kibana.json | 12 +- .../chromium/driver/chromium_driver.ts | 13 +- .../browsers/chromium/driver_factory/index.ts | 12 +- .../server/browsers/chromium/index.ts | 6 +- .../reporting/server/browsers/index.ts | 13 +- x-pack/plugins/reporting/server/core.ts | 7 + .../server/lib/screenshots/observable.test.ts | 20 +-- x-pack/plugins/reporting/server/plugin.ts | 6 +- .../create_mock_browserdriverfactory.ts | 6 +- x-pack/plugins/reporting/server/types.ts | 2 + x-pack/plugins/reporting/tsconfig.json | 1 + 52 files changed, 907 insertions(+), 49 deletions(-) create mode 100644 examples/screenshot_mode_example/.i18nrc.json create mode 100755 examples/screenshot_mode_example/README.md create mode 100644 examples/screenshot_mode_example/common/index.ts create mode 100644 examples/screenshot_mode_example/kibana.json create mode 100644 examples/screenshot_mode_example/public/application.tsx create mode 100644 examples/screenshot_mode_example/public/components/app.tsx create mode 100644 examples/screenshot_mode_example/public/index.scss create mode 100644 examples/screenshot_mode_example/public/index.ts create mode 100644 examples/screenshot_mode_example/public/plugin.ts create mode 100644 examples/screenshot_mode_example/public/services/index.ts create mode 100644 examples/screenshot_mode_example/public/services/metrics_tracking.ts create mode 100644 examples/screenshot_mode_example/public/types.ts create mode 100644 examples/screenshot_mode_example/server/index.ts create mode 100644 examples/screenshot_mode_example/server/plugin.ts create mode 100644 examples/screenshot_mode_example/server/routes.ts create mode 100644 examples/screenshot_mode_example/server/types.ts create mode 100644 examples/screenshot_mode_example/tsconfig.json create mode 100644 src/plugins/screenshot_mode/.i18nrc.json create mode 100755 src/plugins/screenshot_mode/README.md create mode 100644 src/plugins/screenshot_mode/common/constants.ts create mode 100644 src/plugins/screenshot_mode/common/get_set_browser_screenshot_mode.ts create mode 100644 src/plugins/screenshot_mode/common/index.ts create mode 100644 src/plugins/screenshot_mode/jest.config.js create mode 100644 src/plugins/screenshot_mode/kibana.json create mode 100644 src/plugins/screenshot_mode/public/index.ts create mode 100644 src/plugins/screenshot_mode/public/plugin.test.ts create mode 100644 src/plugins/screenshot_mode/public/plugin.ts create mode 100644 src/plugins/screenshot_mode/public/types.ts create mode 100644 src/plugins/screenshot_mode/server/index.ts create mode 100644 src/plugins/screenshot_mode/server/is_screenshot_mode.test.ts create mode 100644 src/plugins/screenshot_mode/server/is_screenshot_mode.ts create mode 100644 src/plugins/screenshot_mode/server/plugin.ts create mode 100644 src/plugins/screenshot_mode/server/types.ts create mode 100644 src/plugins/screenshot_mode/tsconfig.json diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 067b6b206fa14..4ba5e32eec8b5 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -181,6 +181,10 @@ Content is fetched from the remote (https://feeds.elastic.co and https://feeds-s oss plugins. +|{kib-repo}blob/{branch}/src/plugins/screenshot_mode/README.md[screenshotMode] +|The service exposed by this plugin informs consumers whether they should optimize for non-interactivity. In this way plugins can avoid loading unnecessary code, data or other services. + + |{kib-repo}blob/{branch}/src/plugins/security_oss/README.md[securityOss] |securityOss is responsible for educating users about Elastic's free security features, so they can properly protect the data within their clusters. diff --git a/examples/screenshot_mode_example/.i18nrc.json b/examples/screenshot_mode_example/.i18nrc.json new file mode 100644 index 0000000000000..cce0f6b34fea2 --- /dev/null +++ b/examples/screenshot_mode_example/.i18nrc.json @@ -0,0 +1,7 @@ +{ + "prefix": "screenshotModeExample", + "paths": { + "screenshotModeExample": "." + }, + "translations": ["translations/ja-JP.json"] +} diff --git a/examples/screenshot_mode_example/README.md b/examples/screenshot_mode_example/README.md new file mode 100755 index 0000000000000..ebae7480ca5fe --- /dev/null +++ b/examples/screenshot_mode_example/README.md @@ -0,0 +1,9 @@ +# screenshotModeExample + +A Kibana plugin + +--- + +## Development + +See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment. diff --git a/examples/screenshot_mode_example/common/index.ts b/examples/screenshot_mode_example/common/index.ts new file mode 100644 index 0000000000000..c6b22bdb07785 --- /dev/null +++ b/examples/screenshot_mode_example/common/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export const PLUGIN_NAME = 'Screenshot mode example app'; + +export const BASE_API_ROUTE = '/api/screenshot_mode_example'; diff --git a/examples/screenshot_mode_example/kibana.json b/examples/screenshot_mode_example/kibana.json new file mode 100644 index 0000000000000..4cb8c1a1393fb --- /dev/null +++ b/examples/screenshot_mode_example/kibana.json @@ -0,0 +1,9 @@ +{ + "id": "screenshotModeExample", + "version": "1.0.0", + "kibanaVersion": "kibana", + "server": true, + "ui": true, + "requiredPlugins": ["navigation", "screenshotMode", "usageCollection"], + "optionalPlugins": [] +} diff --git a/examples/screenshot_mode_example/public/application.tsx b/examples/screenshot_mode_example/public/application.tsx new file mode 100644 index 0000000000000..670468c77bd5f --- /dev/null +++ b/examples/screenshot_mode_example/public/application.tsx @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import { AppMountParameters, CoreStart } from '../../../src/core/public'; +import { AppPluginSetupDependencies, AppPluginStartDependencies } from './types'; +import { ScreenshotModeExampleApp } from './components/app'; + +export const renderApp = ( + { notifications, http }: CoreStart, + { screenshotMode }: AppPluginSetupDependencies, + { navigation }: AppPluginStartDependencies, + { appBasePath, element }: AppMountParameters +) => { + ReactDOM.render( + , + element + ); + + return () => ReactDOM.unmountComponentAtNode(element); +}; diff --git a/examples/screenshot_mode_example/public/components/app.tsx b/examples/screenshot_mode_example/public/components/app.tsx new file mode 100644 index 0000000000000..c50eaf5b52568 --- /dev/null +++ b/examples/screenshot_mode_example/public/components/app.tsx @@ -0,0 +1,122 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React, { useEffect } from 'react'; +import { BrowserRouter as Router } from 'react-router-dom'; +import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; + +import { + EuiPage, + EuiPageBody, + EuiPageContent, + EuiPageContentBody, + EuiPageContentHeader, + EuiPageHeader, + EuiTitle, + EuiText, +} from '@elastic/eui'; + +import { CoreStart } from '../../../../src/core/public'; +import { NavigationPublicPluginStart } from '../../../../src/plugins/navigation/public'; +import { + ScreenshotModePluginSetup, + KBN_SCREENSHOT_MODE_HEADER, +} from '../../../../src/plugins/screenshot_mode/public'; + +import { PLUGIN_NAME, BASE_API_ROUTE } from '../../common'; + +interface ScreenshotModeExampleAppDeps { + basename: string; + notifications: CoreStart['notifications']; + http: CoreStart['http']; + navigation: NavigationPublicPluginStart; + screenshotMode: ScreenshotModePluginSetup; +} + +export const ScreenshotModeExampleApp = ({ + basename, + notifications, + http, + navigation, + screenshotMode, +}: ScreenshotModeExampleAppDeps) => { + const isScreenshotMode = screenshotMode.isScreenshotMode(); + + useEffect(() => { + // fire and forget + http.get(`${BASE_API_ROUTE}/check_is_screenshot`, { + headers: isScreenshotMode ? { [KBN_SCREENSHOT_MODE_HEADER]: 'true' } : undefined, + }); + notifications.toasts.addInfo({ + title: 'Welcome to the screenshot example app!', + text: isScreenshotMode + ? 'In screenshot mode we want this to remain visible' + : 'In normal mode this toast will disappear eventually', + toastLifeTimeMs: isScreenshotMode ? 360000 : 3000, + }); + }, [isScreenshotMode, notifications, http]); + return ( + + + <> + + + + + +

+ +

+
+
+ + + +

+ {isScreenshotMode ? ( + + ) : ( + + )} +

+
+
+ + + {isScreenshotMode ? ( +

We detected screenshot mode. The chrome navbar should be hidden.

+ ) : ( +

+ This is how the app looks in normal mode. The chrome navbar should be + visible. +

+ )} +
+
+
+
+
+ +
+
+ ); +}; diff --git a/examples/screenshot_mode_example/public/index.scss b/examples/screenshot_mode_example/public/index.scss new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/examples/screenshot_mode_example/public/index.ts b/examples/screenshot_mode_example/public/index.ts new file mode 100644 index 0000000000000..07768cbb1fdb7 --- /dev/null +++ b/examples/screenshot_mode_example/public/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import './index.scss'; + +import { ScreenshotModeExamplePlugin } from './plugin'; + +// This exports static code and TypeScript types, +// as well as, Kibana Platform `plugin()` initializer. +export function plugin() { + return new ScreenshotModeExamplePlugin(); +} diff --git a/examples/screenshot_mode_example/public/plugin.ts b/examples/screenshot_mode_example/public/plugin.ts new file mode 100644 index 0000000000000..91bcc2410b5fc --- /dev/null +++ b/examples/screenshot_mode_example/public/plugin.ts @@ -0,0 +1,48 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public'; +import { AppPluginSetupDependencies, AppPluginStartDependencies } from './types'; +import { MetricsTracking } from './services'; +import { PLUGIN_NAME } from '../common'; + +export class ScreenshotModeExamplePlugin implements Plugin { + uiTracking = new MetricsTracking(); + + public setup(core: CoreSetup, depsSetup: AppPluginSetupDependencies): void { + const { screenshotMode, usageCollection } = depsSetup; + const isScreenshotMode = screenshotMode.isScreenshotMode(); + + this.uiTracking.setup({ + disableTracking: isScreenshotMode, // In screenshot mode there will be no user interactions to track + usageCollection, + }); + + // Register an application into the side navigation menu + core.application.register({ + id: 'screenshotModeExample', + title: PLUGIN_NAME, + async mount(params: AppMountParameters) { + // Load application bundle + const { renderApp } = await import('./application'); + // Get start services as specified in kibana.json + const [coreStart, depsStart] = await core.getStartServices(); + + // For screenshots we don't need to have the top bar visible + coreStart.chrome.setIsVisible(!isScreenshotMode); + + // Render the application + return renderApp(coreStart, depsSetup, depsStart as AppPluginStartDependencies, params); + }, + }); + } + + public start(core: CoreStart): void {} + + public stop() {} +} diff --git a/examples/screenshot_mode_example/public/services/index.ts b/examples/screenshot_mode_example/public/services/index.ts new file mode 100644 index 0000000000000..5725e52e65097 --- /dev/null +++ b/examples/screenshot_mode_example/public/services/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { MetricsTracking } from './metrics_tracking'; diff --git a/examples/screenshot_mode_example/public/services/metrics_tracking.ts b/examples/screenshot_mode_example/public/services/metrics_tracking.ts new file mode 100644 index 0000000000000..e40b6bbf09e44 --- /dev/null +++ b/examples/screenshot_mode_example/public/services/metrics_tracking.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { UiCounterMetricType, METRIC_TYPE } from '@kbn/analytics'; +import { PLUGIN_NAME } from '../../common'; +import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public'; + +export class MetricsTracking { + private trackingDisabled = false; + private usageCollection?: UsageCollectionSetup; + + private track(eventName: string, type: UiCounterMetricType) { + if (this.trackingDisabled) return; + + this.usageCollection?.reportUiCounter(PLUGIN_NAME, type, eventName); + } + + public setup({ + disableTracking, + usageCollection, + }: { + disableTracking?: boolean; + usageCollection: UsageCollectionSetup; + }) { + this.usageCollection = usageCollection; + if (disableTracking) this.trackingDisabled = true; + } + + public trackInit() { + this.track('init', METRIC_TYPE.LOADED); + } +} diff --git a/examples/screenshot_mode_example/public/types.ts b/examples/screenshot_mode_example/public/types.ts new file mode 100644 index 0000000000000..88812a4a507c9 --- /dev/null +++ b/examples/screenshot_mode_example/public/types.ts @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/public'; +import { ScreenshotModePluginSetup } from '../../../src/plugins/screenshot_mode/public'; +import { UsageCollectionSetup } from '../../../src/plugins/usage_collection/public'; + +export interface AppPluginSetupDependencies { + usageCollection: UsageCollectionSetup; + screenshotMode: ScreenshotModePluginSetup; +} + +export interface AppPluginStartDependencies { + navigation: NavigationPublicPluginStart; +} diff --git a/examples/screenshot_mode_example/server/index.ts b/examples/screenshot_mode_example/server/index.ts new file mode 100644 index 0000000000000..af23ea893a755 --- /dev/null +++ b/examples/screenshot_mode_example/server/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { PluginInitializerContext } from 'kibana/server'; +import { ScreenshotModeExamplePlugin } from './plugin'; + +export const plugin = (ctx: PluginInitializerContext) => new ScreenshotModeExamplePlugin(ctx); diff --git a/examples/screenshot_mode_example/server/plugin.ts b/examples/screenshot_mode_example/server/plugin.ts new file mode 100644 index 0000000000000..5738f4a583a1a --- /dev/null +++ b/examples/screenshot_mode_example/server/plugin.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Plugin, PluginInitializerContext, CoreSetup, Logger } from 'kibana/server'; +import { ScreenshotModePluginSetup } from '../../../src/plugins/screenshot_mode/server'; +import { RouteDependencies } from './types'; +import { registerRoutes } from './routes'; + +export class ScreenshotModeExamplePlugin implements Plugin { + log: Logger; + constructor(ctx: PluginInitializerContext) { + this.log = ctx.logger.get(); + } + setup(core: CoreSetup, { screenshotMode }: { screenshotMode: ScreenshotModePluginSetup }): void { + const deps: RouteDependencies = { + screenshotMode, + router: core.http.createRouter(), + log: this.log, + }; + + registerRoutes(deps); + } + + start() {} + stop() {} +} diff --git a/examples/screenshot_mode_example/server/routes.ts b/examples/screenshot_mode_example/server/routes.ts new file mode 100644 index 0000000000000..adf4c2e2b6fc5 --- /dev/null +++ b/examples/screenshot_mode_example/server/routes.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { RouteDependencies } from './types'; +import { BASE_API_ROUTE } from '../common'; + +export const registerRoutes = ({ router, log, screenshotMode }: RouteDependencies) => { + router.get( + { path: `${BASE_API_ROUTE}/check_is_screenshot`, validate: false }, + async (ctx, req, res) => { + log.info(`Reading screenshot mode from a request: ${screenshotMode.isScreenshotMode(req)}`); + log.info(`Reading is screenshot mode from ctx: ${ctx.screenshotMode.isScreenshot}`); + return res.ok(); + } + ); +}; diff --git a/examples/screenshot_mode_example/server/types.ts b/examples/screenshot_mode_example/server/types.ts new file mode 100644 index 0000000000000..9d8d5888c3ab1 --- /dev/null +++ b/examples/screenshot_mode_example/server/types.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { IRouter, Logger } from 'kibana/server'; +import { ScreenshotModeRequestHandlerContext } from '../../../src/plugins/screenshot_mode/server'; +import { ScreenshotModePluginSetup } from '../../../src/plugins/screenshot_mode/server'; + +export type ScreenshotModeExampleRouter = IRouter; + +export interface RouteDependencies { + screenshotMode: ScreenshotModePluginSetup; + router: ScreenshotModeExampleRouter; + log: Logger; +} diff --git a/examples/screenshot_mode_example/tsconfig.json b/examples/screenshot_mode_example/tsconfig.json new file mode 100644 index 0000000000000..dfb436e7377ac --- /dev/null +++ b/examples/screenshot_mode_example/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "./target", + "skipLibCheck": true + }, + "include": [ + "index.ts", + "public/**/*.ts", + "public/**/*.tsx", + "common/**/*.ts", + "server/**/*.ts", + "../../typings/**/*" + ], + "exclude": [], + "references": [{ "path": "../../src/core/tsconfig.json" }] +} diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 348ecb7eea7f2..2639f6fd273f7 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -110,3 +110,4 @@ pageLoadAssetSize: mapsEms: 26072 timelines: 28613 cases: 162385 + screenshotMode: 17856 diff --git a/src/plugins/screenshot_mode/.i18nrc.json b/src/plugins/screenshot_mode/.i18nrc.json new file mode 100644 index 0000000000000..79643fbb63d30 --- /dev/null +++ b/src/plugins/screenshot_mode/.i18nrc.json @@ -0,0 +1,7 @@ +{ + "prefix": "screenshotMode", + "paths": { + "screenshotMode": "." + }, + "translations": ["translations/ja-JP.json"] +} diff --git a/src/plugins/screenshot_mode/README.md b/src/plugins/screenshot_mode/README.md new file mode 100755 index 0000000000000..faa298b33d5fa --- /dev/null +++ b/src/plugins/screenshot_mode/README.md @@ -0,0 +1,27 @@ +# Screenshot Mode + +The service exposed by this plugin informs consumers whether they should optimize for non-interactivity. In this way plugins can avoid loading unnecessary code, data or other services. + +The primary intention is to inform other lower-level plugins (plugins that don't depend on other plugins) that we do not expect an actual user to interact with browser. In this way we can avoid loading unnecessary resources (code and data). + +**NB** This plugin should have no other dependencies to avoid any possibility of circular dependencies. + +--- + +## Development + +### How to test in screenshot mode + +Please note: the following information is subject to change over time. + +In order to test whether we are correctly detecting screenshot mode, developers can run the following JS snippet: + +```js +window.localStorage.setItem('__KBN_SCREENSHOT_MODE_ENABLED_KEY__', true); +``` + +To get out of screenshot mode, run the following snippet: + +```js +window.localStorage.removeItem('__KBN_SCREENSHOT_MODE_ENABLED_KEY__'); +``` diff --git a/src/plugins/screenshot_mode/common/constants.ts b/src/plugins/screenshot_mode/common/constants.ts new file mode 100644 index 0000000000000..d5073f5920c0e --- /dev/null +++ b/src/plugins/screenshot_mode/common/constants.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export const KBN_SCREENSHOT_MODE_HEADER = 'x-kbn-screenshot-mode'.toLowerCase(); diff --git a/src/plugins/screenshot_mode/common/get_set_browser_screenshot_mode.ts b/src/plugins/screenshot_mode/common/get_set_browser_screenshot_mode.ts new file mode 100644 index 0000000000000..7714f88cebeec --- /dev/null +++ b/src/plugins/screenshot_mode/common/get_set_browser_screenshot_mode.ts @@ -0,0 +1,63 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +// **PLEASE NOTE** +// The functionality in this file targets a browser environment and is intended to be used both in public and server. +// For instance, reporting uses these functions when starting puppeteer to set the current browser into "screenshot" mode. + +export const KBN_SCREENSHOT_MODE_ENABLED_KEY = '__KBN_SCREENSHOT_MODE_ENABLED_KEY__'; + +/** + * This function is responsible for detecting whether we are currently in screenshot mode. + * + * We check in the current window context whether screenshot mode is enabled, otherwise we check + * localStorage. The ability to set a value in localStorage enables more convenient development and testing + * in functionality that needs to detect screenshot mode. + */ +export const getScreenshotMode = (): boolean => { + return ( + ((window as unknown) as Record)[KBN_SCREENSHOT_MODE_ENABLED_KEY] === true || + window.localStorage.getItem(KBN_SCREENSHOT_MODE_ENABLED_KEY) === 'true' + ); +}; + +/** + * Use this function to set the current browser to screenshot mode. + * + * This function should be called as early as possible to ensure that screenshot mode is + * correctly detected for the first page load. It is not suitable for use inside any plugin + * code unless the plugin code is guaranteed to, somehow, load before any other code. + * + * Additionally, we don't know what environment this code will run in so we remove as many external + * references as possible to make it portable. For instance, running inside puppeteer. + */ +export const setScreenshotModeEnabled = () => { + Object.defineProperty( + window, + '__KBN_SCREENSHOT_MODE_ENABLED_KEY__', // Literal value to prevent adding an external reference + { + enumerable: true, + writable: true, + configurable: false, + value: true, + } + ); +}; + +export const setScreenshotModeDisabled = () => { + Object.defineProperty( + window, + '__KBN_SCREENSHOT_MODE_ENABLED_KEY__', // Literal value to prevent adding an external reference + { + enumerable: true, + writable: true, + configurable: false, + value: undefined, + } + ); +}; diff --git a/src/plugins/screenshot_mode/common/index.ts b/src/plugins/screenshot_mode/common/index.ts new file mode 100644 index 0000000000000..fd9ad6f70feba --- /dev/null +++ b/src/plugins/screenshot_mode/common/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { + getScreenshotMode, + setScreenshotModeEnabled, + setScreenshotModeDisabled, +} from './get_set_browser_screenshot_mode'; + +export { KBN_SCREENSHOT_MODE_HEADER } from './constants'; diff --git a/src/plugins/screenshot_mode/jest.config.js b/src/plugins/screenshot_mode/jest.config.js new file mode 100644 index 0000000000000..e84f3742f8c1d --- /dev/null +++ b/src/plugins/screenshot_mode/jest.config.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/src/plugins/screenshot_mode'], +}; diff --git a/src/plugins/screenshot_mode/kibana.json b/src/plugins/screenshot_mode/kibana.json new file mode 100644 index 0000000000000..67c40b20be525 --- /dev/null +++ b/src/plugins/screenshot_mode/kibana.json @@ -0,0 +1,9 @@ +{ + "id": "screenshotMode", + "version": "1.0.0", + "kibanaVersion": "kibana", + "ui": true, + "server": true, + "requiredPlugins": [], + "optionalPlugins": [] +} diff --git a/src/plugins/screenshot_mode/public/index.ts b/src/plugins/screenshot_mode/public/index.ts new file mode 100644 index 0000000000000..6a46b240d592e --- /dev/null +++ b/src/plugins/screenshot_mode/public/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ScreenshotModePlugin } from './plugin'; + +export function plugin() { + return new ScreenshotModePlugin(); +} + +export { KBN_SCREENSHOT_MODE_HEADER, setScreenshotModeEnabled } from '../common'; + +export { ScreenshotModePluginSetup } from './types'; diff --git a/src/plugins/screenshot_mode/public/plugin.test.ts b/src/plugins/screenshot_mode/public/plugin.test.ts new file mode 100644 index 0000000000000..33ae501466876 --- /dev/null +++ b/src/plugins/screenshot_mode/public/plugin.test.ts @@ -0,0 +1,43 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { coreMock } from '../../../../src/core/public/mocks'; +import { ScreenshotModePlugin } from './plugin'; +import { setScreenshotModeEnabled, setScreenshotModeDisabled } from '../common'; + +describe('Screenshot mode public', () => { + let plugin: ScreenshotModePlugin; + + beforeEach(() => { + plugin = new ScreenshotModePlugin(); + }); + + afterAll(() => { + setScreenshotModeDisabled(); + }); + + describe('setup contract', () => { + it('detects screenshot mode "true"', () => { + setScreenshotModeEnabled(); + const screenshotMode = plugin.setup(coreMock.createSetup()); + expect(screenshotMode.isScreenshotMode()).toBe(true); + }); + + it('detects screenshot mode "false"', () => { + setScreenshotModeDisabled(); + const screenshotMode = plugin.setup(coreMock.createSetup()); + expect(screenshotMode.isScreenshotMode()).toBe(false); + }); + }); + + describe('start contract', () => { + it('returns nothing', () => { + expect(plugin.start(coreMock.createStart())).toBe(undefined); + }); + }); +}); diff --git a/src/plugins/screenshot_mode/public/plugin.ts b/src/plugins/screenshot_mode/public/plugin.ts new file mode 100644 index 0000000000000..7a166566a0173 --- /dev/null +++ b/src/plugins/screenshot_mode/public/plugin.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { CoreSetup, CoreStart, Plugin } from '../../../core/public'; + +import { ScreenshotModePluginSetup } from './types'; + +import { getScreenshotMode } from '../common'; + +export class ScreenshotModePlugin implements Plugin { + public setup(core: CoreSetup): ScreenshotModePluginSetup { + return { + isScreenshotMode: () => getScreenshotMode() === true, + }; + } + + public start(core: CoreStart) {} + + public stop() {} +} diff --git a/src/plugins/screenshot_mode/public/types.ts b/src/plugins/screenshot_mode/public/types.ts new file mode 100644 index 0000000000000..744ea8615f2a7 --- /dev/null +++ b/src/plugins/screenshot_mode/public/types.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export interface IScreenshotModeService { + /** + * Returns a boolean indicating whether the current user agent (browser) would like to view UI optimized for + * screenshots or printing. + */ + isScreenshotMode: () => boolean; +} + +export type ScreenshotModePluginSetup = IScreenshotModeService; diff --git a/src/plugins/screenshot_mode/server/index.ts b/src/plugins/screenshot_mode/server/index.ts new file mode 100644 index 0000000000000..68714e9a21b87 --- /dev/null +++ b/src/plugins/screenshot_mode/server/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ScreenshotModePlugin } from './plugin'; + +export { setScreenshotModeEnabled, KBN_SCREENSHOT_MODE_HEADER } from '../common'; + +export { + ScreenshotModeRequestHandlerContext, + ScreenshotModePluginSetup, + ScreenshotModePluginStart, +} from './types'; + +export function plugin() { + return new ScreenshotModePlugin(); +} diff --git a/src/plugins/screenshot_mode/server/is_screenshot_mode.test.ts b/src/plugins/screenshot_mode/server/is_screenshot_mode.test.ts new file mode 100644 index 0000000000000..6d783970bd362 --- /dev/null +++ b/src/plugins/screenshot_mode/server/is_screenshot_mode.test.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { httpServerMock } from 'src/core/server/mocks'; +import { KBN_SCREENSHOT_MODE_HEADER } from '../common'; +import { isScreenshotMode } from './is_screenshot_mode'; + +const { createKibanaRequest } = httpServerMock; + +describe('isScreenshotMode', () => { + test('screenshot headers are present', () => { + expect( + isScreenshotMode(createKibanaRequest({ headers: { [KBN_SCREENSHOT_MODE_HEADER]: 'true' } })) + ).toBe(true); + }); + + test('screenshot headers are not present', () => { + expect(isScreenshotMode(createKibanaRequest())).toBe(false); + }); +}); diff --git a/src/plugins/screenshot_mode/server/is_screenshot_mode.ts b/src/plugins/screenshot_mode/server/is_screenshot_mode.ts new file mode 100644 index 0000000000000..79787bcd1fb50 --- /dev/null +++ b/src/plugins/screenshot_mode/server/is_screenshot_mode.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { KibanaRequest } from 'src/core/server'; +import { KBN_SCREENSHOT_MODE_HEADER } from '../common'; + +export const isScreenshotMode = (request: KibanaRequest): boolean => { + return Object.keys(request.headers).some((header) => { + return header.toLowerCase() === KBN_SCREENSHOT_MODE_HEADER; + }); +}; diff --git a/src/plugins/screenshot_mode/server/plugin.ts b/src/plugins/screenshot_mode/server/plugin.ts new file mode 100644 index 0000000000000..9ef410d999ea5 --- /dev/null +++ b/src/plugins/screenshot_mode/server/plugin.ts @@ -0,0 +1,47 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { Plugin, CoreSetup } from '../../../core/server'; +import { + ScreenshotModeRequestHandlerContext, + ScreenshotModePluginSetup, + ScreenshotModePluginStart, +} from './types'; +import { isScreenshotMode } from './is_screenshot_mode'; + +export class ScreenshotModePlugin + implements Plugin { + public setup(core: CoreSetup): ScreenshotModePluginSetup { + core.http.registerRouteHandlerContext( + 'screenshotMode', + (ctx, req) => { + return { + isScreenshot: isScreenshotMode(req), + }; + } + ); + + // We use "require" here to ensure the import does not have external references due to code bundling that + // commonly happens during transpiling. External references would be missing in the environment puppeteer creates. + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { setScreenshotModeEnabled } = require('../common'); + + return { + setScreenshotModeEnabled, + isScreenshotMode, + }; + } + + public start(): ScreenshotModePluginStart { + return { + isScreenshotMode, + }; + } + + public stop() {} +} diff --git a/src/plugins/screenshot_mode/server/types.ts b/src/plugins/screenshot_mode/server/types.ts new file mode 100644 index 0000000000000..4347252e58fce --- /dev/null +++ b/src/plugins/screenshot_mode/server/types.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { RequestHandlerContext, KibanaRequest } from 'src/core/server'; + +/** + * Any context that requires access to the screenshot mode flag but does not have access + * to request context {@link ScreenshotModeRequestHandlerContext}, for instance if they are pre-context, + * can use this function to check whether the request originates from a client that is in screenshot mode. + */ +type IsScreenshotMode = (request: KibanaRequest) => boolean; + +export interface ScreenshotModePluginSetup { + isScreenshotMode: IsScreenshotMode; + + /** + * Set the current environment to screenshot mode. Intended to run in a browser-environment. + */ + setScreenshotModeEnabled: () => void; +} + +export interface ScreenshotModePluginStart { + isScreenshotMode: IsScreenshotMode; +} + +export interface ScreenshotModeRequestHandlerContext extends RequestHandlerContext { + screenshotMode: { + isScreenshot: boolean; + }; +} diff --git a/src/plugins/screenshot_mode/tsconfig.json b/src/plugins/screenshot_mode/tsconfig.json new file mode 100644 index 0000000000000..58194b385448b --- /dev/null +++ b/src/plugins/screenshot_mode/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": true, + "outDir": "./target/types", + "emitDeclarationOnly": true, + "declaration": true, + "declarationMap": true + }, + "include": [ + "common/**/*", + "public/**/*", + "server/**/*" + ], + "references": [ + { "path": "../../core/tsconfig.json" }, + ] +} diff --git a/x-pack/examples/reporting_example/kibana.json b/x-pack/examples/reporting_example/kibana.json index 22768338aec37..f7e351ba3f3bc 100644 --- a/x-pack/examples/reporting_example/kibana.json +++ b/x-pack/examples/reporting_example/kibana.json @@ -5,5 +5,5 @@ "server": false, "ui": true, "optionalPlugins": [], - "requiredPlugins": ["reporting", "developerExamples", "navigation"] + "requiredPlugins": ["reporting", "developerExamples", "navigation", "screenshotMode"] } diff --git a/x-pack/examples/reporting_example/public/application.tsx b/x-pack/examples/reporting_example/public/application.tsx index 25a1cc767f1f5..0a865d1c9e96b 100644 --- a/x-pack/examples/reporting_example/public/application.tsx +++ b/x-pack/examples/reporting_example/public/application.tsx @@ -8,18 +8,15 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { AppMountParameters, CoreStart } from '../../../../src/core/public'; -import { StartDeps } from './types'; +import { SetupDeps, StartDeps } from './types'; import { ReportingExampleApp } from './components/app'; export const renderApp = ( coreStart: CoreStart, - startDeps: StartDeps, + deps: Omit, { appBasePath, element }: AppMountParameters ) => { - ReactDOM.render( - , - element - ); + ReactDOM.render(, element); return () => ReactDOM.unmountComponentAtNode(element); }; diff --git a/x-pack/examples/reporting_example/public/components/app.tsx b/x-pack/examples/reporting_example/public/components/app.tsx index fd4a85dd06779..0174ec2a17ad4 100644 --- a/x-pack/examples/reporting_example/public/components/app.tsx +++ b/x-pack/examples/reporting_example/public/components/app.tsx @@ -26,6 +26,7 @@ import React, { useEffect, useState } from 'react'; import { BrowserRouter as Router } from 'react-router-dom'; import * as Rx from 'rxjs'; import { takeWhile } from 'rxjs/operators'; +import { ScreenshotModePluginSetup } from 'src/plugins/screenshot_mode/public'; import { CoreStart } from '../../../../../src/core/public'; import { NavigationPublicPluginStart } from '../../../../../src/plugins/navigation/public'; import { constants, ReportingStart } from '../../../../../x-pack/plugins/reporting/public'; @@ -37,6 +38,7 @@ interface ReportingExampleAppDeps { http: CoreStart['http']; navigation: NavigationPublicPluginStart; reporting: ReportingStart; + screenshotMode: ScreenshotModePluginSetup; } const sourceLogos = ['Beats', 'Cloud', 'Logging', 'Kibana']; @@ -46,6 +48,7 @@ export const ReportingExampleApp = ({ notifications, http, reporting, + screenshotMode, }: ReportingExampleAppDeps) => { const { getDefaultLayoutSelectors, ReportingAPIClient } = reporting; const [logos, setLogos] = useState([]); @@ -125,6 +128,8 @@ export const ReportingExampleApp = ({ ))} + +

Screenshot Mode is {screenshotMode.isScreenshotMode() ? 'ON' : 'OFF'}!

diff --git a/x-pack/examples/reporting_example/public/plugin.ts b/x-pack/examples/reporting_example/public/plugin.ts index 6ac1cbe01db92..644ac7cc8d8a8 100644 --- a/x-pack/examples/reporting_example/public/plugin.ts +++ b/x-pack/examples/reporting_example/public/plugin.ts @@ -16,7 +16,7 @@ import { PLUGIN_ID, PLUGIN_NAME } from '../common'; import { SetupDeps, StartDeps } from './types'; export class ReportingExamplePlugin implements Plugin { - public setup(core: CoreSetup, { developerExamples, ...depsSetup }: SetupDeps): void { + public setup(core: CoreSetup, { developerExamples, screenshotMode }: SetupDeps): void { core.application.register({ id: PLUGIN_ID, title: PLUGIN_NAME, @@ -30,7 +30,7 @@ export class ReportingExamplePlugin implements Plugin { unknown ]; // Render the application - return renderApp(coreStart, { ...depsSetup, ...depsStart }, params); + return renderApp(coreStart, { ...depsStart, screenshotMode }, params); }, }); diff --git a/x-pack/examples/reporting_example/public/types.ts b/x-pack/examples/reporting_example/public/types.ts index 56e8c34d9dae4..55a573285e24f 100644 --- a/x-pack/examples/reporting_example/public/types.ts +++ b/x-pack/examples/reporting_example/public/types.ts @@ -5,8 +5,9 @@ * 2.0. */ +import { NavigationPublicPluginStart } from 'src/plugins/navigation/public'; +import { ScreenshotModePluginSetup } from 'src/plugins/screenshot_mode/public'; import { DeveloperExamplesSetup } from '../../../../examples/developer_examples/public'; -import { NavigationPublicPluginStart } from '../../../../src/plugins/navigation/public'; import { ReportingStart } from '../../../plugins/reporting/public'; // eslint-disable-next-line @typescript-eslint/no-empty-interface @@ -16,6 +17,7 @@ export interface PluginStart {} export interface SetupDeps { developerExamples: DeveloperExamplesSetup; + screenshotMode: ScreenshotModePluginSetup; } export interface StartDeps { navigation: NavigationPublicPluginStart; diff --git a/x-pack/plugins/reporting/kibana.json b/x-pack/plugins/reporting/kibana.json index 31f679a4ec8d0..ddba61e9a0b8d 100644 --- a/x-pack/plugins/reporting/kibana.json +++ b/x-pack/plugins/reporting/kibana.json @@ -2,11 +2,7 @@ "id": "reporting", "version": "8.0.0", "kibanaVersion": "kibana", - "optionalPlugins": [ - "security", - "spaces", - "usageCollection" - ], + "optionalPlugins": ["security", "spaces", "usageCollection"], "configPath": ["xpack", "reporting"], "requiredPlugins": [ "data", @@ -16,13 +12,11 @@ "uiActions", "taskManager", "embeddable", + "screenshotMode", "share", "features" ], "server": true, "ui": true, - "requiredBundles": [ - "kibanaReact", - "discover" - ] + "requiredBundles": ["kibanaReact", "discover"] } diff --git a/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts index 914a39fdf1268..30b351ff90b6f 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver/chromium_driver.ts @@ -11,6 +11,8 @@ import open from 'opn'; import puppeteer, { ElementHandle, EvaluateFn, SerializableOrJSHandle } from 'puppeteer'; import { parse as parseUrl } from 'url'; import { getDisallowedOutgoingUrlError } from '../'; +import { ReportingCore } from '../../..'; +import { KBN_SCREENSHOT_MODE_HEADER } from '../../../../../../../src/plugins/screenshot_mode/server'; import { ConditionalHeaders, ConditionalHeadersConditions } from '../../../export_types/common'; import { LevelLogger } from '../../../lib'; import { ViewZoomWidthHeight } from '../../../lib/layouts/layout'; @@ -59,8 +61,14 @@ export class HeadlessChromiumDriver { private listenersAttached = false; private interceptedCount = 0; + private core: ReportingCore; - constructor(page: puppeteer.Page, { inspect, networkPolicy }: ChromiumDriverOptions) { + constructor( + core: ReportingCore, + page: puppeteer.Page, + { inspect, networkPolicy }: ChromiumDriverOptions + ) { + this.core = core; this.page = page; this.inspect = inspect; this.networkPolicy = networkPolicy; @@ -98,6 +106,8 @@ export class HeadlessChromiumDriver { // Reset intercepted request count this.interceptedCount = 0; + const enableScreenshotMode = this.core.getEnableScreenshotMode(); + await this.page.evaluateOnNewDocument(enableScreenshotMode); await this.page.setRequestInterception(true); this.registerListeners(conditionalHeaders, logger); @@ -261,6 +271,7 @@ export class HeadlessChromiumDriver { { ...interceptedRequest.request.headers, ...conditionalHeaders.headers, + [KBN_SCREENSHOT_MODE_HEADER]: 'true', }, (value, name) => ({ name, diff --git a/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts index 5fe2050ddb6f1..2005541b81ead 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts @@ -15,6 +15,7 @@ import * as Rx from 'rxjs'; import { InnerSubscriber } from 'rxjs/internal/InnerSubscriber'; import { ignoreElements, map, mergeMap, tap } from 'rxjs/operators'; import { getChromiumDisconnectedError } from '../'; +import { ReportingCore } from '../../..'; import { BROWSER_TYPE } from '../../../../common/constants'; import { durationToNumber } from '../../../../common/schema_utils'; import { CaptureConfig } from '../../../../server/types'; @@ -32,11 +33,14 @@ export class HeadlessChromiumDriverFactory { private browserConfig: BrowserConfig; private userDataDir: string; private getChromiumArgs: (viewport: ViewportConfig) => string[]; + private core: ReportingCore; - constructor(binaryPath: string, captureConfig: CaptureConfig, logger: LevelLogger) { + constructor(core: ReportingCore, binaryPath: string, logger: LevelLogger) { + this.core = core; this.binaryPath = binaryPath; - this.captureConfig = captureConfig; - this.browserConfig = captureConfig.browser.chromium; + const config = core.getConfig(); + this.captureConfig = config.get('capture'); + this.browserConfig = this.captureConfig.browser.chromium; if (this.browserConfig.disableSandbox) { logger.warning(`Enabling the Chromium sandbox provides an additional layer of protection.`); @@ -138,7 +142,7 @@ export class HeadlessChromiumDriverFactory { this.getProcessLogger(browser, logger).subscribe(); // HeadlessChromiumDriver: object to "drive" a browser page - const driver = new HeadlessChromiumDriver(page, { + const driver = new HeadlessChromiumDriver(this.core, page, { inspect: !!this.browserConfig.inspect, networkPolicy: this.captureConfig.networkPolicy, }); diff --git a/x-pack/plugins/reporting/server/browsers/chromium/index.ts b/x-pack/plugins/reporting/server/browsers/chromium/index.ts index 0d5639254b816..e0d043f821ab4 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/index.ts +++ b/x-pack/plugins/reporting/server/browsers/chromium/index.ts @@ -7,15 +7,15 @@ import { i18n } from '@kbn/i18n'; import { BrowserDownload } from '../'; -import { CaptureConfig } from '../../../server/types'; +import { ReportingCore } from '../../../server'; import { LevelLogger } from '../../lib'; import { HeadlessChromiumDriverFactory } from './driver_factory'; import { ChromiumArchivePaths } from './paths'; export const chromium: BrowserDownload = { paths: new ChromiumArchivePaths(), - createDriverFactory: (binaryPath: string, captureConfig: CaptureConfig, logger: LevelLogger) => - new HeadlessChromiumDriverFactory(binaryPath, captureConfig, logger), + createDriverFactory: (core: ReportingCore, binaryPath: string, logger: LevelLogger) => + new HeadlessChromiumDriverFactory(core, binaryPath, logger), }; export const getChromiumDisconnectedError = () => diff --git a/x-pack/plugins/reporting/server/browsers/index.ts b/x-pack/plugins/reporting/server/browsers/index.ts index df95b69d9d254..c47514960bb09 100644 --- a/x-pack/plugins/reporting/server/browsers/index.ts +++ b/x-pack/plugins/reporting/server/browsers/index.ts @@ -6,9 +6,8 @@ */ import { first } from 'rxjs/operators'; -import { ReportingConfig } from '../'; +import { ReportingCore } from '../'; import { LevelLogger } from '../lib'; -import { CaptureConfig } from '../types'; import { chromium, ChromiumArchivePaths } from './chromium'; import { HeadlessChromiumDriverFactory } from './chromium/driver_factory'; import { installBrowser } from './install'; @@ -18,8 +17,8 @@ export { HeadlessChromiumDriver } from './chromium/driver'; export { HeadlessChromiumDriverFactory } from './chromium/driver_factory'; type CreateDriverFactory = ( + core: ReportingCore, binaryPath: string, - captureConfig: CaptureConfig, logger: LevelLogger ) => HeadlessChromiumDriverFactory; @@ -28,12 +27,8 @@ export interface BrowserDownload { paths: ChromiumArchivePaths; } -export const initializeBrowserDriverFactory = async ( - config: ReportingConfig, - logger: LevelLogger -) => { +export const initializeBrowserDriverFactory = async (core: ReportingCore, logger: LevelLogger) => { const { binaryPath$ } = installBrowser(logger); const binaryPath = await binaryPath$.pipe(first()).toPromise(); - const captureConfig = config.get('capture'); - return chromium.createDriverFactory(binaryPath, captureConfig, logger); + return chromium.createDriverFactory(core, binaryPath, logger); }; diff --git a/x-pack/plugins/reporting/server/core.ts b/x-pack/plugins/reporting/server/core.ts index 62cab5a8fef19..2d55a4aa7fa6d 100644 --- a/x-pack/plugins/reporting/server/core.ts +++ b/x-pack/plugins/reporting/server/core.ts @@ -8,6 +8,7 @@ import Hapi from '@hapi/hapi'; import * as Rx from 'rxjs'; import { first, map, take } from 'rxjs/operators'; +import { ScreenshotModePluginSetup } from 'src/plugins/screenshot_mode/server'; import { BasePath, IClusterClient, @@ -41,6 +42,7 @@ export interface ReportingInternalSetup { security?: SecurityPluginSetup; spaces?: SpacesPluginSetup; taskManager: TaskManagerSetupContract; + screenshotMode: ScreenshotModePluginSetup; logger: LevelLogger; } @@ -237,6 +239,11 @@ export class ReportingCore { return screenshotsObservableFactory(config.get('capture'), browserDriverFactory); } + public getEnableScreenshotMode() { + const { screenshotMode } = this.getPluginSetupDeps(); + return screenshotMode.setScreenshotModeEnabled; + } + /* * Gives synchronous access to the setupDeps */ diff --git a/x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts b/x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts index a10f1f7a3788d..dd8aadb49a5ba 100644 --- a/x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts +++ b/x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts @@ -19,6 +19,7 @@ jest.mock('puppeteer', () => ({ import moment from 'moment'; import * as Rx from 'rxjs'; +import { ReportingCore } from '../..'; import { HeadlessChromiumDriver } from '../../browsers'; import { ConditionalHeaders } from '../../export_types/common'; import { @@ -27,6 +28,7 @@ import { createMockConfigSchema, createMockLayoutInstance, createMockLevelLogger, + createMockReportingCore, } from '../../test_helpers'; import { ElementsPositionAndAttribute } from './'; import * as contexts from './constants'; @@ -37,7 +39,7 @@ import { screenshotsObservableFactory } from './observable'; */ const logger = createMockLevelLogger(); -const reportingConfig = { +const mockSchema = createMockConfigSchema({ capture: { loadDelay: moment.duration(2, 's'), timeouts: { @@ -46,12 +48,13 @@ const reportingConfig = { renderComplete: moment.duration(10, 's'), }, }, -}; -const mockSchema = createMockConfigSchema(reportingConfig); +}); const mockConfig = createMockConfig(mockSchema); const captureConfig = mockConfig.get('capture'); const mockLayout = createMockLayoutInstance(captureConfig); +let core: ReportingCore; + /* * Tests */ @@ -59,7 +62,8 @@ describe('Screenshot Observable Pipeline', () => { let mockBrowserDriverFactory: any; beforeEach(async () => { - mockBrowserDriverFactory = await createMockBrowserDriverFactory(logger, {}); + core = await createMockReportingCore(mockSchema); + mockBrowserDriverFactory = await createMockBrowserDriverFactory(core, logger, {}); }); it('pipelines a single url into screenshot and timeRange', async () => { @@ -118,7 +122,7 @@ describe('Screenshot Observable Pipeline', () => { const mockOpen = jest.fn(); // mocks - mockBrowserDriverFactory = await createMockBrowserDriverFactory(logger, { + mockBrowserDriverFactory = await createMockBrowserDriverFactory(core, logger, { screenshot: mockScreenshot, open: mockOpen, }); @@ -218,7 +222,7 @@ describe('Screenshot Observable Pipeline', () => { }); // mocks - mockBrowserDriverFactory = await createMockBrowserDriverFactory(logger, { + mockBrowserDriverFactory = await createMockBrowserDriverFactory(core, logger, { waitForSelector: mockWaitForSelector, }); @@ -312,7 +316,7 @@ describe('Screenshot Observable Pipeline', () => { return Rx.never().toPromise(); }); - mockBrowserDriverFactory = await createMockBrowserDriverFactory(logger, { + mockBrowserDriverFactory = await createMockBrowserDriverFactory(core, logger, { getCreatePage: mockGetCreatePage, waitForSelector: mockWaitForSelector, }); @@ -345,7 +349,7 @@ describe('Screenshot Observable Pipeline', () => { return Promise.resolve(); } }); - mockBrowserDriverFactory = await createMockBrowserDriverFactory(logger, { + mockBrowserDriverFactory = await createMockBrowserDriverFactory(core, logger, { evaluate: mockBrowserEvaluate, }); mockLayout.getViewport = () => null; diff --git a/x-pack/plugins/reporting/server/plugin.ts b/x-pack/plugins/reporting/server/plugin.ts index 26a9be2b15c3f..fc52e10dd0cf9 100644 --- a/x-pack/plugins/reporting/server/plugin.ts +++ b/x-pack/plugins/reporting/server/plugin.ts @@ -48,12 +48,13 @@ export class ReportingPlugin registerUiSettings(core); const { http } = core; - const { features, licensing, security, spaces, taskManager } = plugins; + const { screenshotMode, features, licensing, security, spaces, taskManager } = plugins; const router = http.createRouter(); const basePath = http.basePath; reportingCore.pluginSetup({ + screenshotMode, features, licensing, basePath, @@ -91,9 +92,8 @@ export class ReportingPlugin // async background start (async () => { await reportingCore.pluginSetsUp(); - const config = reportingCore.getConfig(); - const browserDriverFactory = await initializeBrowserDriverFactory(config, this.logger); + const browserDriverFactory = await initializeBrowserDriverFactory(reportingCore, this.logger); const store = new ReportingStore(reportingCore, this.logger); await reportingCore.pluginStart({ diff --git a/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts index 3446160c0d7f5..7dd7c246e9a04 100644 --- a/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts +++ b/x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts @@ -8,6 +8,7 @@ import moment from 'moment'; import { Page } from 'puppeteer'; import * as Rx from 'rxjs'; +import { ReportingCore } from '..'; import { chromium, HeadlessChromiumDriver, HeadlessChromiumDriverFactory } from '../browsers'; import { LevelLogger } from '../lib'; import { ElementsPositionAndAttribute } from '../lib/screenshots'; @@ -96,6 +97,7 @@ const defaultOpts: CreateMockBrowserDriverFactoryOpts = { }; export const createMockBrowserDriverFactory = async ( + core: ReportingCore, logger: LevelLogger, opts: Partial = {} ): Promise => { @@ -122,9 +124,9 @@ export const createMockBrowserDriverFactory = async ( }; const binaryPath = '/usr/local/share/common/secure/super_awesome_binary'; - const mockBrowserDriverFactory = chromium.createDriverFactory(binaryPath, captureConfig, logger); + const mockBrowserDriverFactory = chromium.createDriverFactory(core, binaryPath, logger); const mockPage = ({ setViewport: () => {} } as unknown) as Page; - const mockBrowserDriver = new HeadlessChromiumDriver(mockPage, { + const mockBrowserDriver = new HeadlessChromiumDriver(core, mockPage, { inspect: true, networkPolicy: captureConfig.networkPolicy, }); diff --git a/x-pack/plugins/reporting/server/types.ts b/x-pack/plugins/reporting/server/types.ts index 757d1a68075a8..7df1dce597d56 100644 --- a/x-pack/plugins/reporting/server/types.ts +++ b/x-pack/plugins/reporting/server/types.ts @@ -8,6 +8,7 @@ import type { IRouter, KibanaRequest, RequestHandlerContext } from 'src/core/server'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { DataPluginStart } from 'src/plugins/data/server/plugin'; +import { ScreenshotModePluginSetup } from 'src/plugins/screenshot_mode/server'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server'; import { LicensingPluginSetup } from '../../licensing/server'; @@ -32,6 +33,7 @@ export interface ReportingSetupDeps { spaces?: SpacesPluginSetup; taskManager: TaskManagerSetupContract; usageCollection?: UsageCollectionSetup; + screenshotMode: ScreenshotModePluginSetup; } export interface ReportingStartDeps { diff --git a/x-pack/plugins/reporting/tsconfig.json b/x-pack/plugins/reporting/tsconfig.json index 88e8d343f4700..c28086b96aea2 100644 --- a/x-pack/plugins/reporting/tsconfig.json +++ b/x-pack/plugins/reporting/tsconfig.json @@ -20,6 +20,7 @@ { "path": "../../../src/plugins/embeddable/tsconfig.json" }, { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../../src/plugins/management/tsconfig.json" }, + { "path": "../../../src/plugins/screenshot_mode/tsconfig.json" }, { "path": "../../../src/plugins/share/tsconfig.json" }, { "path": "../../../src/plugins/ui_actions/tsconfig.json" }, { "path": "../../../src/plugins/usage_collection/tsconfig.json" }, From 907203d68e6f3d576d2901a098c630164f78550f Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Wed, 19 May 2021 10:06:52 -0400 Subject: [PATCH 04/18] Ban use of lodash.template (#100277) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .eslintrc.js | 64 ++++++++++++++----- src/setup_node_env/harden/lodash_template.js | 5 ++ test/harden/lodash_template.js | 2 + .../logs/log_filter/log_filter_state.ts | 2 +- .../pages/link_to/redirect_to_node_logs.tsx | 4 +- .../pages/logs/settings/form_elements.tsx | 2 +- .../components/node_details/tabs/logs.tsx | 2 +- .../shared/field_value_suggestions/index.tsx | 2 +- .../public/hooks/use_values_list.ts | 2 +- .../osquery/public/agents/agents_table.tsx | 2 +- .../public/common/store/sourcerer/helpers.ts | 3 +- .../rules/step_define_rule/index.tsx | 4 +- .../public/timelines/containers/api.ts | 4 +- .../overview/query_bar/use_query_bar.ts | 2 +- 14 files changed, 67 insertions(+), 33 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 20875a2c2913d..a4ce657d523d9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -711,6 +711,33 @@ module.exports = { name: 'lodash/fp/assocPath', message: 'Please use @elastic/safer-lodash-set instead', }, + { + name: 'lodash', + importNames: ['template'], + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + name: 'lodash.template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + name: 'lodash/template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + name: 'lodash/fp', + importNames: ['template'], + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + name: 'lodash/fp/template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, { name: 'react-use', message: 'Please use react-use/lib/{method} instead.', @@ -730,6 +757,11 @@ module.exports = { name: 'lodash.setwith', message: 'Please use @elastic/safer-lodash-set instead', }, + { + name: 'lodash.template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, { name: 'lodash/set', message: 'Please use @elastic/safer-lodash-set instead', @@ -738,6 +770,11 @@ module.exports = { name: 'lodash/setWith', message: 'Please use @elastic/safer-lodash-set instead', }, + { + name: 'lodash/template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, ], }, ], @@ -753,6 +790,18 @@ module.exports = { property: 'set', message: 'Please use @elastic/safer-lodash-set instead', }, + { + object: 'lodash', + property: 'template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, + { + object: '_', + property: 'template', + message: + 'lodash.template is unsafe, and not compatible with our content security policy.', + }, { object: 'lodash', property: 'setWith', @@ -1576,20 +1625,5 @@ module.exports = { '@typescript-eslint/prefer-ts-expect-error': 'error', }, }, - { - files: [ - '**/public/**/*.{js,mjs,ts,tsx}', - '**/common/**/*.{js,mjs,ts,tsx}', - 'packages/**/*.{js,mjs,ts,tsx}', - ], - rules: { - 'no-restricted-imports': [ - 'error', - { - patterns: ['lodash/*', '!lodash/fp', 'rxjs/internal-compatibility'], - }, - ], - }, - }, ], }; diff --git a/src/setup_node_env/harden/lodash_template.js b/src/setup_node_env/harden/lodash_template.js index a0f181eab08fc..3379cbfdeeb94 100644 --- a/src/setup_node_env/harden/lodash_template.js +++ b/src/setup_node_env/harden/lodash_template.js @@ -10,6 +10,8 @@ var hook = require('require-in-the-middle'); var isIterateeCall = require('lodash/_isIterateeCall'); hook(['lodash'], function (lodash) { + // we use lodash.template here to harden third-party usage of this otherwise banned function. + // eslint-disable-next-line no-restricted-properties lodash.template = createProxy(lodash.template); return lodash; }); @@ -52,6 +54,9 @@ function createFpProxy(template) { // > Iteratee arguments are capped to avoid gotchas with variadic iteratees. // this means that we can't specify the options in the second argument to fp.template because it's ignored. // Instead, we're going to use the non-FP _.template with only the first argument which has already been patched + + // we use lodash.template here to harden third-party usage of this otherwise banned function. + // eslint-disable-next-line no-restricted-properties return _.template(args[0]); }, }); diff --git a/test/harden/lodash_template.js b/test/harden/lodash_template.js index ad70f88ad22c5..b04f8ad66275a 100644 --- a/test/harden/lodash_template.js +++ b/test/harden/lodash_template.js @@ -8,6 +8,7 @@ require('../../src/setup_node_env'); const _ = require('lodash'); +// eslint-disable-next-line no-restricted-modules const template = require('lodash/template'); const fp = require('lodash/fp'); const fpTemplate = require('lodash/fp/template'); @@ -24,6 +25,7 @@ test('test setup ok', (t) => { t.end(); }); +// eslint-disable-next-line no-restricted-properties [_.template, template].forEach((fn) => { test(`_.template('<%= foo %>')`, (t) => { const output = fn('<%= foo %>')({ foo: 'bar' }); diff --git a/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts b/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts index 6a78d7c6f94bc..d4cb7ca90541f 100644 --- a/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts +++ b/x-pack/plugins/infra/public/containers/logs/log_filter/log_filter_state.ts @@ -7,7 +7,7 @@ import createContainer from 'constate'; import { useCallback, useState } from 'react'; -import { useDebounce } from 'react-use'; +import useDebounce from 'react-use/lib/useDebounce'; import { esQuery, IIndexPattern, Query } from '../../../../../../../src/plugins/data/public'; type ParsedQuery = ReturnType; diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx index 82e3813bde886..bc8c5699229d8 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx @@ -6,9 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -// Prefer importing entire lodash library, e.g. import { get } from "lodash" -// eslint-disable-next-line no-restricted-imports -import flowRight from 'lodash/flowRight'; +import { flowRight } from 'lodash'; import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; import useMount from 'react-use/lib/useMount'; diff --git a/x-pack/plugins/infra/public/pages/logs/settings/form_elements.tsx b/x-pack/plugins/infra/public/pages/logs/settings/form_elements.tsx index 751d9762b937a..90504a691cb95 100644 --- a/x-pack/plugins/infra/public/pages/logs/settings/form_elements.tsx +++ b/x-pack/plugins/infra/public/pages/logs/settings/form_elements.tsx @@ -7,7 +7,7 @@ import equal from 'fast-deep-equal'; import { useCallback, useMemo, useState } from 'react'; -import { useAsync } from 'react-use'; +import useAsync from 'react-use/lib/useAsync'; import { ObjectEntries } from '../../../../common/utility_types'; import { ChildFormValidationError, GenericValidationError } from './validation_errors'; diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx index 4fa9fdf8cdd4a..b792078c394e9 100644 --- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/logs.tsx @@ -6,7 +6,7 @@ */ import React, { useCallback, useMemo, useState } from 'react'; -import { useThrottle } from 'react-use'; +import useThrottle from 'react-use/lib/useThrottle'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; import { EuiFieldSearch } from '@elastic/eui'; diff --git a/x-pack/plugins/observability/public/components/shared/field_value_suggestions/index.tsx b/x-pack/plugins/observability/public/components/shared/field_value_suggestions/index.tsx index 359710e4b9c59..ebe1111337919 100644 --- a/x-pack/plugins/observability/public/components/shared/field_value_suggestions/index.tsx +++ b/x-pack/plugins/observability/public/components/shared/field_value_suggestions/index.tsx @@ -7,7 +7,7 @@ import React, { useState } from 'react'; -import { useDebounce } from 'react-use'; +import useDebounce from 'react-use/lib/useDebounce'; import { useValuesList } from '../../../hooks/use_values_list'; import { FieldValueSelection } from './field_value_selection'; import { FieldValueSuggestionsProps } from './types'; diff --git a/x-pack/plugins/observability/public/hooks/use_values_list.ts b/x-pack/plugins/observability/public/hooks/use_values_list.ts index 8d6e0abb896b3..ff133d07489b0 100644 --- a/x-pack/plugins/observability/public/hooks/use_values_list.ts +++ b/x-pack/plugins/observability/public/hooks/use_values_list.ts @@ -7,7 +7,7 @@ import { capitalize, union } from 'lodash'; import { useEffect, useState } from 'react'; -import { useDebounce } from 'react-use'; +import useDebounce from 'react-use/lib/useDebounce'; import { IndexPattern } from '../../../../../src/plugins/data/common'; import { ESFilter } from '../../../../../typings/elasticsearch'; import { createEsParams, useEsSearch } from './use_es_search'; diff --git a/x-pack/plugins/osquery/public/agents/agents_table.tsx b/x-pack/plugins/osquery/public/agents/agents_table.tsx index 7f57f70e459da..7e8f49c051614 100644 --- a/x-pack/plugins/osquery/public/agents/agents_table.tsx +++ b/x-pack/plugins/osquery/public/agents/agents_table.tsx @@ -9,7 +9,7 @@ import { find } from 'lodash/fp'; import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { EuiComboBox, EuiHealth, EuiHighlight, EuiSpacer } from '@elastic/eui'; -import { useDebounce } from 'react-use'; +import useDebounce from 'react-use/lib/useDebounce'; import { useAllAgents } from './use_all_agents'; import { useAgentGroups } from './use_agent_groups'; import { useOsqueryPolicies } from './use_osquery_policies'; diff --git a/x-pack/plugins/security_solution/public/common/store/sourcerer/helpers.ts b/x-pack/plugins/security_solution/public/common/store/sourcerer/helpers.ts index 7d817ad30f1a0..fd3a6f1fab3c1 100644 --- a/x-pack/plugins/security_solution/public/common/store/sourcerer/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/store/sourcerer/helpers.ts @@ -5,8 +5,7 @@ * 2.0. */ -// eslint-disable-next-line no-restricted-imports -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash'; import { SourcererModel, SourcererScopeName } from './model'; import { TimelineEventsType } from '../../../../common/types/timeline'; diff --git a/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx b/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx index 29342bd32298e..162f86c543308 100644 --- a/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx @@ -8,9 +8,7 @@ import { EuiButtonEmpty, EuiFormRow, EuiSpacer } from '@elastic/eui'; import React, { FC, memo, useCallback, useState, useEffect } from 'react'; import styled from 'styled-components'; -// Prefer importing entire lodash library, e.g. import { get } from "lodash" -// eslint-disable-next-line no-restricted-imports -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'lodash'; import { IndexPattern } from 'src/plugins/data/public'; import { DEFAULT_INDEX_KEY } from '../../../../../common/constants'; diff --git a/x-pack/plugins/security_solution/public/timelines/containers/api.ts b/x-pack/plugins/security_solution/public/timelines/containers/api.ts index d1c798a27b6c4..e591685a31829 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/api.ts +++ b/x-pack/plugins/security_solution/public/timelines/containers/api.ts @@ -8,9 +8,7 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; -// Prefer importing entire lodash library, e.g. import { get } from "lodash" -// eslint-disable-next-line no-restricted-imports -import isEmpty from 'lodash/isEmpty'; +import { isEmpty } from 'lodash'; import { throwErrors } from '../../../../cases/common'; import { diff --git a/x-pack/plugins/uptime/public/components/overview/query_bar/use_query_bar.ts b/x-pack/plugins/uptime/public/components/overview/query_bar/use_query_bar.ts index 164231bfdd89b..2f2d8bf092ddf 100644 --- a/x-pack/plugins/uptime/public/components/overview/query_bar/use_query_bar.ts +++ b/x-pack/plugins/uptime/public/components/overview/query_bar/use_query_bar.ts @@ -6,7 +6,7 @@ */ import React, { useCallback, useState } from 'react'; -import { useDebounce } from 'react-use'; +import useDebounce from 'react-use/lib/useDebounce'; import { useDispatch } from 'react-redux'; import { Query } from 'src/plugins/data/common'; import { useGetUrlParams, useUpdateKueryString, useUrlParams } from '../../../hooks'; From afaacae777505555dc797826b764fc246392ffbb Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Wed, 19 May 2021 16:36:43 +0200 Subject: [PATCH 05/18] Bump Node.js from version 14.16.1 to 14.17.0 (#100314) --- .ci/Dockerfile | 2 +- .node-version | 2 +- .nvmrc | 2 +- WORKSPACE.bazel | 12 ++++++------ package.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 1c59d6d9aaaf8..3e6dfaefed92f 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -1,7 +1,7 @@ # NOTE: This Dockerfile is ONLY used to run certain tasks in CI. It is not used to run Kibana or as a distributable. # If you're looking for the Kibana Docker image distributable, please see: src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.ts -ARG NODE_VERSION=14.16.1 +ARG NODE_VERSION=14.17.0 FROM node:${NODE_VERSION} AS base diff --git a/.node-version b/.node-version index 6b17d228d3351..62df50f1eefe1 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -14.16.1 +14.17.0 diff --git a/.nvmrc b/.nvmrc index 6b17d228d3351..62df50f1eefe1 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14.16.1 +14.17.0 diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 60af851ff2dc6..d80ad948cbb55 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -27,13 +27,13 @@ check_rules_nodejs_version(minimum_version_string = "3.5.0") # we can update that rule. node_repositories( node_repositories = { - "14.16.1-darwin_amd64": ("node-v14.16.1-darwin-x64.tar.gz", "node-v14.16.1-darwin-x64", "b762b72fc149629b7e394ea9b75a093cad709a9f2f71480942945d8da0fc1218"), - "14.16.1-linux_arm64": ("node-v14.16.1-linux-arm64.tar.xz", "node-v14.16.1-linux-arm64", "b4d474e79f7d33b3b4430fad25c3f836b82ce2d5bb30d4a2c9fa20df027e40da"), - "14.16.1-linux_s390x": ("node-v14.16.1-linux-s390x.tar.xz", "node-v14.16.1-linux-s390x", "af9982fef32e4a3e4a5d66741dcf30ac9c27613bd73582fa1dae1fb25003047a"), - "14.16.1-linux_amd64": ("node-v14.16.1-linux-x64.tar.xz", "node-v14.16.1-linux-x64", "85a89d2f68855282c87851c882d4c4bbea4cd7f888f603722f0240a6e53d89df"), - "14.16.1-windows_amd64": ("node-v14.16.1-win-x64.zip", "node-v14.16.1-win-x64", "e469db37b4df74627842d809566c651042d86f0e6006688f0f5fe3532c6dfa41"), + "14.17.0-darwin_amd64": ("node-v14.17.0-darwin-x64.tar.gz", "node-v14.17.0-darwin-x64", "7b210652e11d1ee25650c164cf32381895e1dcb3e0ff1d0841d8abc1f47ac73e"), + "14.17.0-linux_arm64": ("node-v14.17.0-linux-arm64.tar.xz", "node-v14.17.0-linux-arm64", "712e5575cee20570a0a56f4d4b4572cb0f2ee2f4bce49433de18be0393e7df22"), + "14.17.0-linux_s390x": ("node-v14.17.0-linux-s390x.tar.xz", "node-v14.17.0-linux-s390x", "6419372b9e9ad37e0bce188dc5740f2f060aaa44454418e462b4088a310a1c0b"), + "14.17.0-linux_amd64": ("node-v14.17.0-linux-x64.tar.xz", "node-v14.17.0-linux-x64", "494b161759a3d19c70e3172d33ce1918dd8df9ad20d29d1652a8387a84e2d308"), + "14.17.0-windows_amd64": ("node-v14.17.0-win-x64.zip", "node-v14.17.0-win-x64", "6582a7259c433e9f667dcc4ed3e5d68bc514caba2eed40e4626c8b4c7e5ecd5c"), }, - node_version = "14.16.1", + node_version = "14.17.0", node_urls = [ "https://nodejs.org/dist/v{version}/{filename}", ], diff --git a/package.json b/package.json index 57f03fe6f5b35..fad8fcf8a8716 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "**/underscore": "^1.13.1" }, "engines": { - "node": "14.16.1", + "node": "14.17.0", "yarn": "^1.21.1" }, "dependencies": { From 4256c1823083ab9ebe597d86977e71e768805690 Mon Sep 17 00:00:00 2001 From: Larry Gregory Date: Wed, 19 May 2021 11:33:44 -0400 Subject: [PATCH 06/18] Remove circular dependency between features and security (#100206) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- api_docs/features.json | 60 ++++++++++--- .../server/feature_privilege_iterator.js | 11 --- .../feature_privilege_iterator.test.ts | 2 +- .../feature_privilege_iterator.ts | 44 +++++++-- .../feature_privilege_iterator/index.ts | 5 ++ .../sub_feature_privilege_iterator.ts | 21 ++++- x-pack/plugins/features/server/mocks.ts | 6 ++ .../features/server/oss_features.test.ts | 1 - x-pack/plugins/features/server/plugin.ts | 22 +++++ .../authorization/authorization_service.tsx | 1 - .../security/server/authorization/index.ts | 1 - .../server/authorization/privileges/index.ts | 1 - .../privileges/privileges.test.ts | 90 ++++++++----------- .../authorization/privileges/privileges.ts | 15 ++-- 14 files changed, 179 insertions(+), 101 deletions(-) delete mode 100644 x-pack/plugins/features/server/feature_privilege_iterator.js rename x-pack/plugins/{security/server/authorization/privileges => features/server}/feature_privilege_iterator/feature_privilege_iterator.test.ts (99%) rename x-pack/plugins/{security/server/authorization/privileges => features/server}/feature_privilege_iterator/feature_privilege_iterator.ts (71%) rename x-pack/plugins/{security/server/authorization/privileges => features/server}/feature_privilege_iterator/index.ts (66%) rename x-pack/plugins/{security/server/authorization/privileges => features/server}/feature_privilege_iterator/sub_feature_privilege_iterator.ts (52%) diff --git a/api_docs/features.json b/api_docs/features.json index 7ee7224882213..427525db6c416 100644 --- a/api_docs/features.json +++ b/api_docs/features.json @@ -2101,7 +2101,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 33 + "lineNumber": 41 }, "deprecated": false, "children": [ @@ -2125,7 +2125,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 34 + "lineNumber": 42 }, "deprecated": false, "children": [ @@ -2147,7 +2147,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 34 + "lineNumber": 42 }, "deprecated": false, "isRequired": true @@ -2175,7 +2175,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 35 + "lineNumber": 43 }, "deprecated": false, "children": [ @@ -2197,7 +2197,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 35 + "lineNumber": 43 }, "deprecated": false, "isRequired": true @@ -2225,7 +2225,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 41 + "lineNumber": 49 }, "deprecated": false, "children": [], @@ -2251,7 +2251,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 47 + "lineNumber": 55 }, "deprecated": false, "children": [], @@ -2270,7 +2270,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 48 + "lineNumber": 56 }, "deprecated": false, "children": [], @@ -2288,11 +2288,47 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 56 + "lineNumber": 64 }, "deprecated": false, "children": [], "returnComment": [] + }, + { + "parentPluginId": "features", + "id": "def-server.PluginSetupContract.featurePrivilegeIterator", + "type": "Function", + "tags": [], + "label": "featurePrivilegeIterator", + "description": [ + "\nUtility for iterating through all privileges belonging to a specific feature.\n{@see FeaturePrivilegeIterator }" + ], + "signature": [ + "FeaturePrivilegeIterator" + ], + "source": { + "path": "x-pack/plugins/features/server/plugin.ts", + "lineNumber": 70 + }, + "deprecated": false + }, + { + "parentPluginId": "features", + "id": "def-server.PluginSetupContract.subFeaturePrivilegeIterator", + "type": "Function", + "tags": [], + "label": "subFeaturePrivilegeIterator", + "description": [ + "\nUtility for iterating through all sub-feature privileges belonging to a specific feature.\n{@see SubFeaturePrivilegeIterator }" + ], + "signature": [ + "SubFeaturePrivilegeIterator" + ], + "source": { + "path": "x-pack/plugins/features/server/plugin.ts", + "lineNumber": 76 + }, + "deprecated": false } ], "initialIsOpen": false @@ -2306,7 +2342,7 @@ "description": [], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 59 + "lineNumber": 79 }, "deprecated": false, "children": [ @@ -2330,7 +2366,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 60 + "lineNumber": 80 }, "deprecated": false, "children": [], @@ -2356,7 +2392,7 @@ ], "source": { "path": "x-pack/plugins/features/server/plugin.ts", - "lineNumber": 61 + "lineNumber": 81 }, "deprecated": false, "children": [], diff --git a/x-pack/plugins/features/server/feature_privilege_iterator.js b/x-pack/plugins/features/server/feature_privilege_iterator.js deleted file mode 100644 index 842c30d643b67..0000000000000 --- a/x-pack/plugins/features/server/feature_privilege_iterator.js +++ /dev/null @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -// the file created to remove TS cicular dependency between features and security pluin -// https://github.com/elastic/kibana/issues/87388 -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export { featurePrivilegeIterator } from '../../security/server/authorization'; diff --git a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/feature_privilege_iterator.test.ts b/x-pack/plugins/features/server/feature_privilege_iterator/feature_privilege_iterator.test.ts similarity index 99% rename from x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/feature_privilege_iterator.test.ts rename to x-pack/plugins/features/server/feature_privilege_iterator/feature_privilege_iterator.test.ts index f42ac3ef21c06..6acc29793797f 100644 --- a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/feature_privilege_iterator.test.ts +++ b/x-pack/plugins/features/server/feature_privilege_iterator/feature_privilege_iterator.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { KibanaFeature } from '../../../../../features/server'; +import { KibanaFeature } from '../'; import { featurePrivilegeIterator } from './feature_privilege_iterator'; describe('featurePrivilegeIterator', () => { diff --git a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/feature_privilege_iterator.ts b/x-pack/plugins/features/server/feature_privilege_iterator/feature_privilege_iterator.ts similarity index 71% rename from x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/feature_privilege_iterator.ts rename to x-pack/plugins/features/server/feature_privilege_iterator/feature_privilege_iterator.ts index de2f44a446a19..e194a051c8a6e 100644 --- a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/feature_privilege_iterator.ts +++ b/x-pack/plugins/features/server/feature_privilege_iterator/feature_privilege_iterator.ts @@ -7,20 +7,48 @@ import _ from 'lodash'; -import type { FeatureKibanaPrivileges, KibanaFeature } from '../../../../../features/server'; -import type { LicenseType } from '../../../../../licensing/server'; +import type { FeatureKibanaPrivileges, KibanaFeature } from '../'; +import type { LicenseType } from '../../../licensing/server'; import { subFeaturePrivilegeIterator } from './sub_feature_privilege_iterator'; -interface IteratorOptions { +/** + * Options to control feature privilege iteration. + */ +export interface FeaturePrivilegeIteratorOptions { + /** + * Augment each privilege definition with its sub-feature privileges. + */ augmentWithSubFeaturePrivileges: boolean; + + /** + * The current license type. Controls which sub-features are returned, as they may have different license terms than the overall feature. + */ licenseType: LicenseType; + + /** + * Optional predicate to filter the returned set of privileges. + */ predicate?: (privilegeId: string, privilege: FeatureKibanaPrivileges) => boolean; } -export function* featurePrivilegeIterator( +/** + * Utility for iterating through all privileges belonging to a specific feature. + * Iteration can be customized in several ways: + * - Filter privileges with a given predicate. + * - Augment privileges with their respective sub-feature privileges. + * + * @param feature the feature whose privileges to iterate through. + * @param options options to control iteration. + */ +export type FeaturePrivilegeIterator = ( feature: KibanaFeature, - options: IteratorOptions -): IterableIterator<{ privilegeId: string; privilege: FeatureKibanaPrivileges }> { + options: FeaturePrivilegeIteratorOptions +) => IterableIterator<{ privilegeId: string; privilege: FeatureKibanaPrivileges }>; + +const featurePrivilegeIterator: FeaturePrivilegeIterator = function* featurePrivilegeIterator( + feature: KibanaFeature, + options: FeaturePrivilegeIteratorOptions +) { for (const entry of Object.entries(feature.privileges ?? {})) { const [privilegeId, privilege] = entry; @@ -37,7 +65,7 @@ export function* featurePrivilegeIterator( yield { privilegeId, privilege }; } } -} +}; function mergeWithSubFeatures( privilegeId: string, @@ -97,3 +125,5 @@ function mergeArrays(input1: readonly string[] | undefined, input2: readonly str const second = input2 ?? []; return Array.from(new Set([...first, ...second])); } + +export { featurePrivilegeIterator }; diff --git a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/index.ts b/x-pack/plugins/features/server/feature_privilege_iterator/index.ts similarity index 66% rename from x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/index.ts rename to x-pack/plugins/features/server/feature_privilege_iterator/index.ts index ee7b5d9ab68ab..3be8fd4d81f96 100644 --- a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/index.ts +++ b/x-pack/plugins/features/server/feature_privilege_iterator/index.ts @@ -5,5 +5,10 @@ * 2.0. */ +export type { + FeaturePrivilegeIterator, + FeaturePrivilegeIteratorOptions, +} from './feature_privilege_iterator'; +export type { SubFeaturePrivilegeIterator } from './sub_feature_privilege_iterator'; export { featurePrivilegeIterator } from './feature_privilege_iterator'; export { subFeaturePrivilegeIterator } from './sub_feature_privilege_iterator'; diff --git a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/sub_feature_privilege_iterator.ts b/x-pack/plugins/features/server/feature_privilege_iterator/sub_feature_privilege_iterator.ts similarity index 52% rename from x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/sub_feature_privilege_iterator.ts rename to x-pack/plugins/features/server/feature_privilege_iterator/sub_feature_privilege_iterator.ts index 4e71fb363b080..e4cc52bca81bc 100644 --- a/x-pack/plugins/security/server/authorization/privileges/feature_privilege_iterator/sub_feature_privilege_iterator.ts +++ b/x-pack/plugins/features/server/feature_privilege_iterator/sub_feature_privilege_iterator.ts @@ -5,10 +5,21 @@ * 2.0. */ -import type { KibanaFeature, SubFeaturePrivilegeConfig } from '../../../../../features/common'; -import type { LicenseType } from '../../../../../licensing/server'; +import type { KibanaFeature, SubFeaturePrivilegeConfig } from '../../common'; +import type { LicenseType } from '../../../licensing/server'; -export function* subFeaturePrivilegeIterator( +/** + * Utility for iterating through all sub-feature privileges belonging to a specific feature. + * + * @param feature the feature whose sub-feature privileges to iterate through. + * @param licenseType the current license. + */ +export type SubFeaturePrivilegeIterator = ( + feature: KibanaFeature, + licenseType: LicenseType +) => IterableIterator; + +const subFeaturePrivilegeIterator: SubFeaturePrivilegeIterator = function* subFeaturePrivilegeIterator( feature: KibanaFeature, licenseType: LicenseType ): IterableIterator { @@ -19,4 +30,6 @@ export function* subFeaturePrivilegeIterator( ); } } -} +}; + +export { subFeaturePrivilegeIterator }; diff --git a/x-pack/plugins/features/server/mocks.ts b/x-pack/plugins/features/server/mocks.ts index 7b10a185dd0db..c052f0354a907 100644 --- a/x-pack/plugins/features/server/mocks.ts +++ b/x-pack/plugins/features/server/mocks.ts @@ -6,6 +6,10 @@ */ import { PluginSetupContract, PluginStartContract } from './plugin'; +import { + featurePrivilegeIterator, + subFeaturePrivilegeIterator, +} from './feature_privilege_iterator'; const createSetup = (): jest.Mocked => { return { @@ -15,6 +19,8 @@ const createSetup = (): jest.Mocked => { registerKibanaFeature: jest.fn(), registerElasticsearchFeature: jest.fn(), enableReportingUiCapabilities: jest.fn(), + featurePrivilegeIterator: jest.fn().mockImplementation(featurePrivilegeIterator), + subFeaturePrivilegeIterator: jest.fn().mockImplementation(subFeaturePrivilegeIterator), }; }; diff --git a/x-pack/plugins/features/server/oss_features.test.ts b/x-pack/plugins/features/server/oss_features.test.ts index 86705cae6d5a6..207abaeee9472 100644 --- a/x-pack/plugins/features/server/oss_features.test.ts +++ b/x-pack/plugins/features/server/oss_features.test.ts @@ -6,7 +6,6 @@ */ import { buildOSSFeatures } from './oss_features'; -// @ts-expect-error import { featurePrivilegeIterator } from './feature_privilege_iterator'; import { KibanaFeature } from '.'; import { LicenseType } from '../../licensing/server'; diff --git a/x-pack/plugins/features/server/plugin.ts b/x-pack/plugins/features/server/plugin.ts index 60a48a539f81e..b1f540031f6dc 100644 --- a/x-pack/plugins/features/server/plugin.ts +++ b/x-pack/plugins/features/server/plugin.ts @@ -26,6 +26,14 @@ import { KibanaFeature, KibanaFeatureConfig, } from '../common'; +import type { + FeaturePrivilegeIterator, + SubFeaturePrivilegeIterator, +} from './feature_privilege_iterator'; +import { + featurePrivilegeIterator, + subFeaturePrivilegeIterator, +} from './feature_privilege_iterator'; /** * Describes public Features plugin contract returned at the `setup` stage. @@ -54,6 +62,18 @@ export interface PluginSetupContract { * `features` to include Reporting when registering OSS features. */ enableReportingUiCapabilities(): void; + + /** + * Utility for iterating through all privileges belonging to a specific feature. + * {@see FeaturePrivilegeIterator } + */ + featurePrivilegeIterator: FeaturePrivilegeIterator; + + /** + * Utility for iterating through all sub-feature privileges belonging to a specific feature. + * {@see SubFeaturePrivilegeIterator } + */ + subFeaturePrivilegeIterator: SubFeaturePrivilegeIterator; } export interface PluginStartContract { @@ -110,6 +130,8 @@ export class FeaturesPlugin ), getFeaturesUICapabilities, enableReportingUiCapabilities: this.enableReportingUiCapabilities.bind(this), + featurePrivilegeIterator, + subFeaturePrivilegeIterator, }); } diff --git a/x-pack/plugins/security/server/authorization/authorization_service.tsx b/x-pack/plugins/security/server/authorization/authorization_service.tsx index 144a8bc5fd0c4..1e2588dafe233 100644 --- a/x-pack/plugins/security/server/authorization/authorization_service.tsx +++ b/x-pack/plugins/security/server/authorization/authorization_service.tsx @@ -51,7 +51,6 @@ import { validateReservedPrivileges } from './validate_reserved_privileges'; export { Actions } from './actions'; export { CheckSavedObjectsPrivileges } from './check_saved_objects_privileges'; -export { featurePrivilegeIterator } from './privileges'; interface AuthorizationServiceSetupParams { packageVersion: string; diff --git a/x-pack/plugins/security/server/authorization/index.ts b/x-pack/plugins/security/server/authorization/index.ts index 6cbb4d10c75e4..16a3c2ae50058 100644 --- a/x-pack/plugins/security/server/authorization/index.ts +++ b/x-pack/plugins/security/server/authorization/index.ts @@ -8,5 +8,4 @@ export { Actions } from './actions'; export { AuthorizationService, AuthorizationServiceSetup } from './authorization_service'; export { CheckSavedObjectsPrivileges } from './check_saved_objects_privileges'; -export { featurePrivilegeIterator } from './privileges'; export { CheckPrivilegesPayload } from './types'; diff --git a/x-pack/plugins/security/server/authorization/privileges/index.ts b/x-pack/plugins/security/server/authorization/privileges/index.ts index 90d611180e60c..31c9cf2713c9d 100644 --- a/x-pack/plugins/security/server/authorization/privileges/index.ts +++ b/x-pack/plugins/security/server/authorization/privileges/index.ts @@ -6,4 +6,3 @@ */ export { privilegesFactory, PrivilegesService } from './privileges'; -export { featurePrivilegeIterator } from './feature_privilege_iterator'; diff --git a/x-pack/plugins/security/server/authorization/privileges/privileges.test.ts b/x-pack/plugins/security/server/authorization/privileges/privileges.test.ts index ecbbb637f4da0..dfe6bef1e00e0 100644 --- a/x-pack/plugins/security/server/authorization/privileges/privileges.test.ts +++ b/x-pack/plugins/security/server/authorization/privileges/privileges.test.ts @@ -85,9 +85,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -190,9 +189,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -268,9 +266,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -413,9 +410,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -502,9 +498,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -577,9 +572,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -653,9 +647,8 @@ describe('features', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -723,9 +716,8 @@ describe('reserved', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -762,9 +754,8 @@ describe('reserved', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -837,9 +828,8 @@ describe('reserved', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -901,9 +891,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -1036,9 +1025,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -1274,9 +1262,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -1435,9 +1422,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -1622,9 +1608,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('basic'), @@ -1766,9 +1751,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: false }), getType: jest.fn().mockReturnValue('basic'), @@ -1993,9 +1977,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('gold'), @@ -2229,9 +2212,8 @@ describe('subFeatures', () => { }), ]; - const mockFeaturesPlugin = { - getKibanaFeatures: jest.fn().mockReturnValue(features), - }; + const mockFeaturesPlugin = featuresPluginMock.createSetup(); + mockFeaturesPlugin.getKibanaFeatures.mockReturnValue(features); const mockLicenseService = { getFeatures: jest.fn().mockReturnValue({ allowSubFeaturePrivileges: true }), getType: jest.fn().mockReturnValue('platinum'), diff --git a/x-pack/plugins/security/server/authorization/privileges/privileges.ts b/x-pack/plugins/security/server/authorization/privileges/privileges.ts index 1826b853ce668..9f50fd0fb1d53 100644 --- a/x-pack/plugins/security/server/authorization/privileges/privileges.ts +++ b/x-pack/plugins/security/server/authorization/privileges/privileges.ts @@ -15,10 +15,6 @@ import type { SecurityLicense } from '../../../common/licensing'; import type { RawKibanaPrivileges } from '../../../common/model'; import type { Actions } from '../actions'; import { featurePrivilegeBuilderFactory } from './feature_privilege_builder'; -import { - featurePrivilegeIterator, - subFeaturePrivilegeIterator, -} from './feature_privilege_iterator'; export interface PrivilegesService { get(): RawKibanaPrivileges; @@ -44,7 +40,7 @@ export function privilegesFactory( let readActions: string[] = []; basePrivilegeFeatures.forEach((feature) => { - for (const { privilegeId, privilege } of featurePrivilegeIterator(feature, { + for (const { privilegeId, privilege } of featuresService.featurePrivilegeIterator(feature, { augmentWithSubFeaturePrivileges: true, licenseType, predicate: (pId, featurePrivilege) => !featurePrivilege.excludeFromBasePrivileges, @@ -63,7 +59,7 @@ export function privilegesFactory( const featurePrivileges: Record> = {}; for (const feature of features) { featurePrivileges[feature.id] = {}; - for (const featurePrivilege of featurePrivilegeIterator(feature, { + for (const featurePrivilege of featuresService.featurePrivilegeIterator(feature, { augmentWithSubFeaturePrivileges: true, licenseType, })) { @@ -75,7 +71,7 @@ export function privilegesFactory( } if (allowSubFeaturePrivileges && feature.subFeatures?.length > 0) { - for (const featurePrivilege of featurePrivilegeIterator(feature, { + for (const featurePrivilege of featuresService.featurePrivilegeIterator(feature, { augmentWithSubFeaturePrivileges: false, licenseType, })) { @@ -86,7 +82,10 @@ export function privilegesFactory( ]; } - for (const subFeaturePrivilege of subFeaturePrivilegeIterator(feature, licenseType)) { + for (const subFeaturePrivilege of featuresService.subFeaturePrivilegeIterator( + feature, + licenseType + )) { featurePrivileges[feature.id][subFeaturePrivilege.id] = [ actions.login, actions.version, From ef426206244aebc69e1c6aaae554e7e684214ae3 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Wed, 19 May 2021 11:37:59 -0400 Subject: [PATCH 07/18] [Maps] Add grid-resolution telemetry (#99808) --- .../maps_telemetry/collectors/register.ts | 82 +++++++++++++ .../server/maps_telemetry/maps_telemetry.ts | 5 + .../maps/server/maps_telemetry/util.ts | 48 +++++++- .../schema/xpack_plugins.json | 116 ++++++++++++++++++ 4 files changed, 250 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts b/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts index ded96266ee75f..d6bd87a39eeee 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts @@ -275,6 +275,88 @@ export function registerMapsUsageCollector( }, }, }, + resolutions: { + coarse: { + min: { + type: 'long', + _meta: { description: 'min number of grid-agg layers with coarse resolution' }, + }, + max: { + type: 'long', + _meta: { description: 'max number of grid-agg layers with coarse resolution' }, + }, + avg: { + type: 'float', + _meta: { description: 'avg number of grid-agg layers with coarse resolution' }, + }, + total: { + type: 'long', + _meta: { + description: 'total number of grid-agg layers with coarse resolution', + }, + }, + }, + fine: { + min: { + type: 'long', + _meta: { description: 'min number of grid-agg layers with fine resolution' }, + }, + max: { + type: 'long', + _meta: { description: 'max number of grid-agg layers with fine resolution' }, + }, + avg: { + type: 'float', + _meta: { description: 'avg number of grid-agg layers with fine resolution' }, + }, + total: { + type: 'long', + _meta: { + description: 'total number of grid-agg layers with fine resolution', + }, + }, + }, + most_fine: { + min: { + type: 'long', + _meta: { description: 'min number of grid-agg layers with most_fine resolution' }, + }, + max: { + type: 'long', + _meta: { description: 'max number of grid-agg layers with most_fine resolution' }, + }, + avg: { + type: 'float', + _meta: { description: 'avg number of grid-agg layers with most_fine resolution' }, + }, + total: { + type: 'long', + _meta: { + description: 'total number of grid-agg layers with most_fine resolution', + }, + }, + }, + super_fine: { + min: { + type: 'long', + _meta: { description: 'min number of grid-agg layers with super_fine resolution' }, + }, + max: { + type: 'long', + _meta: { description: 'max number of grid-agg layers with super_fine resolution' }, + }, + avg: { + type: 'float', + _meta: { description: 'avg number of grid-agg layers with super_fine resolution' }, + }, + total: { + type: 'long', + _meta: { + description: 'total number of grid-agg layers with super_fine resolution', + }, + }, + }, + }, joins: { term: { min: { diff --git a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts index d7a4bcf33ea3b..46457265e977e 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts @@ -27,10 +27,12 @@ import { MapsConfigType } from '../../config'; import { injectReferences } from '././../../common/migrations/references'; import { getBaseMapsPerCluster, + getGridResolutionsPerCluster, getScalingOptionsPerCluster, getTelemetryLayerTypesPerCluster, getTermJoinsPerCluster, TELEMETRY_BASEMAP_COUNTS_PER_CLUSTER, + TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER, TELEMETRY_LAYER_TYPE_COUNTS_PER_CLUSTER, TELEMETRY_SCALING_OPTION_COUNTS_PER_CLUSTER, TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER, @@ -66,6 +68,7 @@ export interface LayersStatsUsage { scalingOptions: TELEMETRY_SCALING_OPTION_COUNTS_PER_CLUSTER; joins: TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER; basemaps: TELEMETRY_BASEMAP_COUNTS_PER_CLUSTER; + resolutions: TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER; attributesPerMap: { dataSourcesCount: { min: number; @@ -264,6 +267,7 @@ export function buildMapsSavedObjectsTelemetry(layerLists: LayerDescriptor[][]): const scalingOptions = getScalingOptionsPerCluster(layerLists); const joins = getTermJoinsPerCluster(layerLists); const basemaps = getBaseMapsPerCluster(layerLists); + const resolutions = getGridResolutionsPerCluster(layerLists); return { // Total count of maps @@ -274,6 +278,7 @@ export function buildMapsSavedObjectsTelemetry(layerLists: LayerDescriptor[][]): scalingOptions, joins, basemaps, + resolutions, attributesPerMap: { // Count of data sources per map dataSourcesCount: { diff --git a/x-pack/plugins/maps/server/maps_telemetry/util.ts b/x-pack/plugins/maps/server/maps_telemetry/util.ts index c739f4a539e1e..24d211de659ff 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/util.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/util.ts @@ -11,7 +11,7 @@ import { ESSearchSourceDescriptor, LayerDescriptor, } from '../../common/descriptor_types'; -import { LAYER_TYPE, RENDER_AS, SCALING_TYPES, SOURCE_TYPES } from '../../common'; +import { GRID_RESOLUTION, LAYER_TYPE, RENDER_AS, SCALING_TYPES, SOURCE_TYPES } from '../../common'; import { DEFAULT_EMS_DARKMAP_ID, DEFAULT_EMS_ROADMAP_DESATURATED_ID, @@ -73,6 +73,16 @@ export interface TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER { [TELEMETRY_TERM_JOIN]?: ClusterCountStats; } +export enum TELEMETRY_GRID_RESOLUTION { + COARSE = 'coarse', + FINE = 'fine', + MOST_FINE = 'most_fine', + SUPER_FINE = 'super_fine', +} +export type TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER = { + [key in TELEMETRY_GRID_RESOLUTION]?: ClusterCountStats; +}; + // These capture a particular "combo" of source and layer-settings. // They are mutually exclusive (ie. a layerDescriptor can only be a single telemetry_layer_type) // They are more useful from a telemetry-perspective than: @@ -261,6 +271,42 @@ export function getTermJoinsPerCluster( }); } +function getGridResolution(layerDescriptor: LayerDescriptor): TELEMETRY_GRID_RESOLUTION | null { + if ( + !layerDescriptor.sourceDescriptor || + layerDescriptor.sourceDescriptor.type !== SOURCE_TYPES.ES_GEO_GRID || + !(layerDescriptor.sourceDescriptor as ESGeoGridSourceDescriptor).resolution + ) { + return null; + } + + const descriptor = layerDescriptor.sourceDescriptor as ESGeoGridSourceDescriptor; + + if (descriptor.resolution === GRID_RESOLUTION.COARSE) { + return TELEMETRY_GRID_RESOLUTION.COARSE; + } + + if (descriptor.resolution === GRID_RESOLUTION.FINE) { + return TELEMETRY_GRID_RESOLUTION.FINE; + } + + if (descriptor.resolution === GRID_RESOLUTION.MOST_FINE) { + return TELEMETRY_GRID_RESOLUTION.MOST_FINE; + } + + if (descriptor.resolution === GRID_RESOLUTION.SUPER_FINE) { + return TELEMETRY_GRID_RESOLUTION.SUPER_FINE; + } + + return null; +} + +export function getGridResolutionsPerCluster( + layerLists: LayerDescriptor[][] +): TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER { + return getCountsByCluster(layerLists, getGridResolution); +} + export function getBaseMapsPerCluster( layerLists: LayerDescriptor[][] ): TELEMETRY_BASEMAP_COUNTS_PER_CLUSTER { diff --git a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json index f88034f70ddf4..1c0062a20d892 100644 --- a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json +++ b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @@ -3216,6 +3216,122 @@ } } }, + "resolutions": { + "properties": { + "coarse": { + "properties": { + "min": { + "type": "long", + "_meta": { + "description": "min number of grid-agg layers with coarse resolution" + } + }, + "max": { + "type": "long", + "_meta": { + "description": "max number of grid-agg layers with coarse resolution" + } + }, + "avg": { + "type": "float", + "_meta": { + "description": "avg number of grid-agg layers with coarse resolution" + } + }, + "total": { + "type": "long", + "_meta": { + "description": "total number of grid-agg layers with coarse resolution" + } + } + } + }, + "fine": { + "properties": { + "min": { + "type": "long", + "_meta": { + "description": "min number of grid-agg layers with fine resolution" + } + }, + "max": { + "type": "long", + "_meta": { + "description": "max number of grid-agg layers with fine resolution" + } + }, + "avg": { + "type": "float", + "_meta": { + "description": "avg number of grid-agg layers with fine resolution" + } + }, + "total": { + "type": "long", + "_meta": { + "description": "total number of grid-agg layers with fine resolution" + } + } + } + }, + "most_fine": { + "properties": { + "min": { + "type": "long", + "_meta": { + "description": "min number of grid-agg layers with most_fine resolution" + } + }, + "max": { + "type": "long", + "_meta": { + "description": "max number of grid-agg layers with most_fine resolution" + } + }, + "avg": { + "type": "float", + "_meta": { + "description": "avg number of grid-agg layers with most_fine resolution" + } + }, + "total": { + "type": "long", + "_meta": { + "description": "total number of grid-agg layers with most_fine resolution" + } + } + } + }, + "super_fine": { + "properties": { + "min": { + "type": "long", + "_meta": { + "description": "min number of grid-agg layers with super_fine resolution" + } + }, + "max": { + "type": "long", + "_meta": { + "description": "max number of grid-agg layers with super_fine resolution" + } + }, + "avg": { + "type": "float", + "_meta": { + "description": "avg number of grid-agg layers with super_fine resolution" + } + }, + "total": { + "type": "long", + "_meta": { + "description": "total number of grid-agg layers with super_fine resolution" + } + } + } + } + } + }, "joins": { "properties": { "term": { From 9da1a707d7cc18f59cb0b2fa6f1fab9c0d30494b Mon Sep 17 00:00:00 2001 From: Kevin Logan <56395104+kevinlog@users.noreply.github.com> Date: Wed, 19 May 2021 11:43:18 -0400 Subject: [PATCH 08/18] [Security Solution] Add supported field to ransomware (#100135) --- .../fleet/server/saved_objects/index.ts | 2 + .../migrations/security_solution/index.ts | 1 + .../security_solution/to_v7_14_0.test.ts | 200 ++++++++++++++++++ .../security_solution/to_v7_14_0.ts | 33 +++ .../saved_objects/migrations/to_v7_14_0.ts | 29 +++ .../common/endpoint/models/policy_config.ts | 20 ++ .../common/endpoint/types/index.ts | 7 +- .../common/license/policy_config.test.ts | 35 ++- .../common/license/policy_config.ts | 17 +- .../policy/store/policy_details/index.test.ts | 2 +- .../policy/store/policy_details/selectors.ts | 4 +- .../endpoint/lib/policy/license_watch.ts | 10 +- .../apps/endpoint/policy_details.ts | 6 +- 13 files changed, 344 insertions(+), 22 deletions(-) create mode 100644 x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts create mode 100644 x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts create mode 100644 x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_14_0.ts diff --git a/x-pack/plugins/fleet/server/saved_objects/index.ts b/x-pack/plugins/fleet/server/saved_objects/index.ts index e2e33f1ee6c26..4331baef11001 100644 --- a/x-pack/plugins/fleet/server/saved_objects/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/index.ts @@ -42,6 +42,7 @@ import { migrateSettingsToV7130, migrateOutputToV7130, } from './migrations/to_v7_13_0'; +import { migratePackagePolicyToV7140 } from './migrations/to_v7_14_0'; /* * Saved object types and mappings @@ -267,6 +268,7 @@ const getSavedObjectTypes = ( '7.11.0': migratePackagePolicyToV7110, '7.12.0': migratePackagePolicyToV7120, '7.13.0': migratePackagePolicyToV7130, + '7.14.0': migratePackagePolicyToV7140, }, }, [PACKAGES_SAVED_OBJECT_TYPE]: { diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts index ddce95a96879a..b4f09e541298a 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/index.ts @@ -8,3 +8,4 @@ export { migratePackagePolicyToV7110 } from './to_v7_11_0'; export { migratePackagePolicyToV7120 } from './to_v7_12_0'; export { migrateEndpointPackagePolicyToV7130 } from './to_v7_13_0'; +export { migrateEndpointPackagePolicyToV7140 } from './to_v7_14_0'; diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts new file mode 100644 index 0000000000000..8ccb50735d4fb --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts @@ -0,0 +1,200 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server'; + +import type { PackagePolicy } from '../../../../common'; + +import { migrateEndpointPackagePolicyToV7140 } from './to_v7_14_0'; + +describe('7.14.0 Endpoint Package Policy migration', () => { + const migration = migrateEndpointPackagePolicyToV7140; + it('adds supported option for ransomware on migrations', () => { + const doc = { + id: 'mock-saved-object-id', + attributes: { + name: 'Some Policy Name', + package: { + name: 'endpoint', + title: '', + version: '', + }, + id: 'endpoint', + policy_id: '', + enabled: true, + namespace: '', + output_id: '', + revision: 0, + updated_at: '', + updated_by: '', + created_at: '', + created_by: '', + inputs: [ + { + type: 'endpoint', + enabled: true, + streams: [], + config: { + policy: { + value: { + windows: { + ransomware: { + mode: 'off', + }, + malware: { + mode: 'off', + }, + popup: { + malware: { + message: '', + enabled: false, + }, + ransomware: { + message: '', + enabled: false, + }, + }, + }, + linux: { + events: { process: true, file: true, network: true }, + logging: { file: 'info' }, + }, + }, + }, + }, + }, + ], + }, + type: ' nested', + }; + + expect(migration(doc, {} as SavedObjectMigrationContext)).toEqual({ + attributes: { + name: 'Some Policy Name', + package: { + name: 'endpoint', + title: '', + version: '', + }, + id: 'endpoint', + policy_id: '', + enabled: true, + namespace: '', + output_id: '', + revision: 0, + updated_at: '', + updated_by: '', + created_at: '', + created_by: '', + inputs: [ + { + type: 'endpoint', + enabled: true, + streams: [], + config: { + policy: { + value: { + windows: { + ransomware: { + mode: 'off', + supported: true, + }, + malware: { + mode: 'off', + }, + popup: { + malware: { + message: '', + enabled: false, + }, + ransomware: { + message: '', + enabled: false, + }, + }, + }, + linux: { + events: { process: true, file: true, network: true }, + logging: { file: 'info' }, + }, + }, + }, + }, + }, + ], + }, + type: ' nested', + id: 'mock-saved-object-id', + }); + }); + + it('does not modify non-endpoint package policies', () => { + const doc: SavedObjectUnsanitizedDoc = { + id: 'mock-saved-object-id', + attributes: { + name: 'Some Policy Name', + package: { + name: 'notEndpoint', + title: '', + version: '', + }, + id: 'notEndpoint', + policy_id: '', + enabled: true, + namespace: '', + output_id: '', + revision: 0, + updated_at: '', + updated_by: '', + created_at: '', + created_by: '', + inputs: [ + { + type: 'notEndpoint', + enabled: true, + streams: [], + config: {}, + }, + ], + }, + type: ' nested', + }; + + expect( + migration(doc, {} as SavedObjectMigrationContext) as SavedObjectUnsanitizedDoc + ).toEqual({ + attributes: { + name: 'Some Policy Name', + package: { + name: 'notEndpoint', + title: '', + version: '', + }, + id: 'notEndpoint', + policy_id: '', + enabled: true, + namespace: '', + output_id: '', + revision: 0, + updated_at: '', + updated_by: '', + created_at: '', + created_by: '', + inputs: [ + { + type: 'notEndpoint', + enabled: true, + streams: [], + config: {}, + }, + ], + }, + type: ' nested', + id: 'mock-saved-object-id', + }); + }); +}); diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts new file mode 100644 index 0000000000000..a9acf7865f812 --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObjectMigrationFn, SavedObjectUnsanitizedDoc } from 'kibana/server'; +import { cloneDeep } from 'lodash'; + +import type { PackagePolicy } from '../../../../common'; + +export const migrateEndpointPackagePolicyToV7140: SavedObjectMigrationFn< + PackagePolicy, + PackagePolicy +> = (packagePolicyDoc) => { + const updatedPackagePolicyDoc: SavedObjectUnsanitizedDoc = cloneDeep( + packagePolicyDoc + ); + + if (packagePolicyDoc.attributes.package?.name === 'endpoint') { + const input = updatedPackagePolicyDoc.attributes.inputs[0]; + if (input && input.config) { + const policy = input.config.policy.value; + + // This value is based on license. + // For the migration, we add 'true', our license watcher will correct it, if needed, when the app starts. + policy.windows.ransomware.supported = true; + } + } + + return updatedPackagePolicyDoc; +}; diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_14_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_14_0.ts new file mode 100644 index 0000000000000..3255e15c6ceec --- /dev/null +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/to_v7_14_0.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { SavedObjectMigrationFn } from 'kibana/server'; + +import type { PackagePolicy } from '../../../common'; + +import { migrateEndpointPackagePolicyToV7140 } from './security_solution'; + +export const migratePackagePolicyToV7140: SavedObjectMigrationFn = ( + packagePolicyDoc, + migrationContext +) => { + let updatedPackagePolicyDoc = packagePolicyDoc; + + // Endpoint specific migrations + if (packagePolicyDoc.attributes.package?.name === 'endpoint') { + updatedPackagePolicyDoc = migrateEndpointPackagePolicyToV7140( + packagePolicyDoc, + migrationContext + ); + } + + return updatedPackagePolicyDoc; +}; diff --git a/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts b/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts index cbac2d03cfb97..1bb5cf7bc87c1 100644 --- a/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts +++ b/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts @@ -27,6 +27,7 @@ export const policyFactory = (): PolicyConfig => { }, ransomware: { mode: ProtectionModes.prevent, + supported: true, }, popup: { malware: { @@ -89,6 +90,7 @@ export const policyFactoryWithoutPaidFeatures = ( ...policy.windows, ransomware: { mode: ProtectionModes.off, + supported: false, }, popup: { ...policy.windows.popup, @@ -115,6 +117,24 @@ export const policyFactoryWithoutPaidFeatures = ( }; }; +/** + * Strips paid features from an existing or new `PolicyConfig` for gold and below license + */ +export const policyFactoryWithSupportedFeatures = ( + policy: PolicyConfig = policyFactory() +): PolicyConfig => { + return { + ...policy, + windows: { + ...policy.windows, + ransomware: { + ...policy.windows.ransomware, + supported: true, + }, + }, + }; +}; + /** * Reflects what string the Endpoint will use when message field is default/empty */ diff --git a/x-pack/plugins/security_solution/common/endpoint/types/index.ts b/x-pack/plugins/security_solution/common/endpoint/types/index.ts index b9e72bcd625ec..541507ac048ca 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/index.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/index.ts @@ -835,7 +835,7 @@ export interface PolicyConfig { security: boolean; }; malware: ProtectionFields; - ransomware: ProtectionFields; + ransomware: ProtectionFields & SupportedFields; logging: { file: string; }; @@ -910,6 +910,11 @@ export interface ProtectionFields { mode: ProtectionModes; } +/** Policy: Supported fields */ +export interface SupportedFields { + supported: boolean; +} + /** Policy protection mode options */ export enum ProtectionModes { detect = 'detect', diff --git a/x-pack/plugins/security_solution/common/license/policy_config.test.ts b/x-pack/plugins/security_solution/common/license/policy_config.test.ts index e8637e43ce1c7..219538184765a 100644 --- a/x-pack/plugins/security_solution/common/license/policy_config.test.ts +++ b/x-pack/plugins/security_solution/common/license/policy_config.test.ts @@ -7,11 +7,12 @@ import { isEndpointPolicyValidForLicense, - unsetPolicyFeaturesAboveLicenseLevel, + unsetPolicyFeaturesAccordingToLicenseLevel, } from './policy_config'; import { DefaultMalwareMessage, policyFactory, + policyFactoryWithSupportedFeatures, policyFactoryWithoutPaidFeatures, } from '../endpoint/models/policy_config'; import { licenseMock } from '../../../licensing/common/licensing.mock'; @@ -77,6 +78,7 @@ describe('policy_config and licenses', () => { it('allows ransomware to be turned on for Platinum licenses', () => { const policy = policyFactoryWithoutPaidFeatures(); policy.windows.ransomware.mode = ProtectionModes.prevent; + policy.windows.ransomware.supported = true; const valid = isEndpointPolicyValidForLicense(policy, Platinum); expect(valid).toBeTruthy(); @@ -94,6 +96,7 @@ describe('policy_config and licenses', () => { it('allows ransomware notification to be turned on with a Platinum license', () => { const policy = policyFactoryWithoutPaidFeatures(); policy.windows.popup.ransomware.enabled = true; + policy.windows.ransomware.supported = true; const valid = isEndpointPolicyValidForLicense(policy, Platinum); expect(valid).toBeTruthy(); }); @@ -130,7 +133,7 @@ describe('policy_config and licenses', () => { }); }); - describe('unsetPolicyFeaturesAboveLicenseLevel', () => { + describe('unsetPolicyFeaturesAccordingToLicenseLevel', () => { it('does not change any malware fields with a Platinum license', () => { const policy = policyFactory(); const popupMessage = 'WOOP WOOP'; @@ -138,7 +141,7 @@ describe('policy_config and licenses', () => { policy.mac.popup.malware.message = popupMessage; policy.windows.popup.malware.enabled = false; - const retPolicy = unsetPolicyFeaturesAboveLicenseLevel(policy, Platinum); + const retPolicy = unsetPolicyFeaturesAccordingToLicenseLevel(policy, Platinum); expect(retPolicy.windows.popup.malware.enabled).toBeFalsy(); expect(retPolicy.windows.popup.malware.message).toEqual(popupMessage); expect(retPolicy.mac.popup.malware.message).toEqual(popupMessage); @@ -151,7 +154,7 @@ describe('policy_config and licenses', () => { policy.windows.popup.ransomware.enabled = false; policy.windows.popup.ransomware.message = popupMessage; - const retPolicy = unsetPolicyFeaturesAboveLicenseLevel(policy, Platinum); + const retPolicy = unsetPolicyFeaturesAccordingToLicenseLevel(policy, Platinum); expect(retPolicy.windows.ransomware.mode).toEqual(ProtectionModes.detect); expect(retPolicy.windows.popup.ransomware.enabled).toBeFalsy(); expect(retPolicy.windows.popup.ransomware.message).toEqual(popupMessage); @@ -167,7 +170,7 @@ describe('policy_config and licenses', () => { policy.windows.popup.ransomware.message = popupMessage; policy.windows.popup.ransomware.enabled = false; - const retPolicy = unsetPolicyFeaturesAboveLicenseLevel(policy, Gold); + const retPolicy = unsetPolicyFeaturesAccordingToLicenseLevel(policy, Gold); expect(retPolicy.windows.popup.malware.enabled).toEqual( defaults.windows.popup.malware.enabled ); @@ -183,7 +186,7 @@ describe('policy_config and licenses', () => { const popupMessage = 'WOOP WOOP'; policy.windows.popup.ransomware.message = popupMessage; - const retPolicy = unsetPolicyFeaturesAboveLicenseLevel(policy, Gold); + const retPolicy = unsetPolicyFeaturesAccordingToLicenseLevel(policy, Gold); expect(retPolicy.windows.ransomware.mode).toEqual(defaults.windows.ransomware.mode); expect(retPolicy.windows.popup.ransomware.enabled).toEqual( @@ -194,6 +197,26 @@ describe('policy_config and licenses', () => { // need to invert the test, since it could be either value expect(['', DefaultMalwareMessage]).toContain(retPolicy.windows.popup.ransomware.message); }); + + it('sets ransomware supported field to false when license is below Platinum', () => { + const defaults = policyFactoryWithoutPaidFeatures(); // reference + const policy = policyFactory(); // what we will modify, and should be reset + policy.windows.ransomware.supported = true; + + const retPolicy = unsetPolicyFeaturesAccordingToLicenseLevel(policy, Gold); + + expect(retPolicy.windows.ransomware.supported).toEqual(defaults.windows.ransomware.supported); + }); + + it('sets ransomware supported field to true when license is at Platinum', () => { + const defaults = policyFactoryWithSupportedFeatures(); // reference + const policy = policyFactory(); // what we will modify, and should be reset + policy.windows.ransomware.supported = false; + + const retPolicy = unsetPolicyFeaturesAccordingToLicenseLevel(policy, Platinum); + + expect(retPolicy.windows.ransomware.supported).toEqual(defaults.windows.ransomware.supported); + }); }); describe('policyFactoryWithoutPaidFeatures for gold and below license', () => { diff --git a/x-pack/plugins/security_solution/common/license/policy_config.ts b/x-pack/plugins/security_solution/common/license/policy_config.ts index 903e241b1b490..171f2d9d0287d 100644 --- a/x-pack/plugins/security_solution/common/license/policy_config.ts +++ b/x-pack/plugins/security_solution/common/license/policy_config.ts @@ -11,6 +11,7 @@ import { PolicyConfig } from '../endpoint/types'; import { DefaultMalwareMessage, policyFactoryWithoutPaidFeatures, + policyFactoryWithSupportedFeatures, } from '../endpoint/models/policy_config'; /** @@ -22,6 +23,13 @@ export const isEndpointPolicyValidForLicense = ( license: ILicense | null ): boolean => { if (isAtLeast(license, 'platinum')) { + const defaults = policyFactoryWithSupportedFeatures(); + + // only platinum or higher may enable ransomware + if (policy.windows.ransomware.supported !== defaults.windows.ransomware.supported) { + return false; + } + return true; // currently, platinum allows all features } @@ -62,6 +70,11 @@ export const isEndpointPolicyValidForLicense = ( return false; } + // only platinum or higher may enable ransomware + if (policy.windows.ransomware.supported !== defaults.windows.ransomware.supported) { + return false; + } + return true; }; @@ -69,12 +82,12 @@ export const isEndpointPolicyValidForLicense = ( * Resets paid features in a PolicyConfig back to default values * when unsupported by the given license level. */ -export const unsetPolicyFeaturesAboveLicenseLevel = ( +export const unsetPolicyFeaturesAccordingToLicenseLevel = ( policy: PolicyConfig, license: ILicense | null ): PolicyConfig => { if (isAtLeast(license, 'platinum')) { - return policy; + return policyFactoryWithSupportedFeatures(policy); } // set any license-gated features back to the defaults diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts index 74dfbe4dec3ba..89b8e9d7f5944 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts @@ -284,7 +284,7 @@ describe('policy details: ', () => { security: true, }, malware: { mode: 'prevent' }, - ransomware: { mode: 'off' }, + ransomware: { mode: 'off', supported: false }, popup: { malware: { enabled: true, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/selectors.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/selectors.ts index 98e1fd1f29d97..078aea4ec41ac 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/selectors.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/selectors.ts @@ -8,7 +8,7 @@ import { createSelector } from 'reselect'; import { matchPath } from 'react-router-dom'; import { ILicense } from '../../../../../../../licensing/common/types'; -import { unsetPolicyFeaturesAboveLicenseLevel } from '../../../../../../common/license/policy_config'; +import { unsetPolicyFeaturesAccordingToLicenseLevel } from '../../../../../../common/license/policy_config'; import { PolicyDetailsState } from '../../types'; import { Immutable, @@ -33,7 +33,7 @@ export const licensedPolicy: ( licenseState, (policyData, license) => { if (policyData) { - const policyValue = unsetPolicyFeaturesAboveLicenseLevel( + const policyValue = unsetPolicyFeaturesAccordingToLicenseLevel( policyData.inputs[0].config.policy.value, license as ILicense ); diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/policy/license_watch.ts b/x-pack/plugins/security_solution/server/endpoint/lib/policy/license_watch.ts index 58a73d31708a1..b8c6e57f72cea 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/policy/license_watch.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/policy/license_watch.ts @@ -24,9 +24,9 @@ import { PackagePolicyServiceInterface } from '../../../../../fleet/server'; import { ILicense } from '../../../../../licensing/common/types'; import { isEndpointPolicyValidForLicense, - unsetPolicyFeaturesAboveLicenseLevel, + unsetPolicyFeaturesAccordingToLicenseLevel, } from '../../../../common/license/policy_config'; -import { isAtLeast, LicenseService } from '../../../../common/license/license'; +import { LicenseService } from '../../../../common/license/license'; export class PolicyWatcher { private logger: Logger; @@ -76,10 +76,6 @@ export class PolicyWatcher { } public async watch(license: ILicense) { - if (isAtLeast(license, 'platinum')) { - return; - } - let page = 1; let response: { items: PackagePolicy[]; @@ -114,7 +110,7 @@ export class PolicyWatcher { }; const policyConfig = updatePolicy.inputs[0].config?.policy.value; if (!isEndpointPolicyValidForLicense(policyConfig, license)) { - updatePolicy.inputs[0].config!.policy.value = unsetPolicyFeaturesAboveLicenseLevel( + updatePolicy.inputs[0].config!.policy.value = unsetPolicyFeaturesAccordingToLicenseLevel( policyConfig, license ); diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts index 6bddb5d38cf72..1303dd35fa9f7 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts @@ -285,7 +285,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }, logging: { file: 'info' }, malware: { mode: 'prevent' }, - ransomware: { mode: 'prevent' }, + ransomware: { mode: 'prevent', supported: true }, popup: { malware: { enabled: true, @@ -446,7 +446,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }, logging: { file: 'info' }, malware: { mode: 'prevent' }, - ransomware: { mode: 'prevent' }, + ransomware: { mode: 'prevent', supported: true }, popup: { malware: { enabled: true, @@ -604,7 +604,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }, logging: { file: 'info' }, malware: { mode: 'prevent' }, - ransomware: { mode: 'prevent' }, + ransomware: { mode: 'prevent', supported: true }, popup: { malware: { enabled: true, From 4b0c01a732bb5adb863b68e886fba8cd799a33e6 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 19 May 2021 09:34:14 -0700 Subject: [PATCH 09/18] skip flaky suite (#99581) --- x-pack/test/functional/apps/spaces/spaces_selection.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional/apps/spaces/spaces_selection.ts b/x-pack/test/functional/apps/spaces/spaces_selection.ts index 99efdf29eecb9..f3d3665bf9f61 100644 --- a/x-pack/test/functional/apps/spaces/spaces_selection.ts +++ b/x-pack/test/functional/apps/spaces/spaces_selection.ts @@ -22,7 +22,8 @@ export default function spaceSelectorFunctionalTests({ 'spaceSelector', ]); - describe('Spaces', function () { + // FLAKY: https://github.com/elastic/kibana/issues/99581 + describe.skip('Spaces', function () { this.tags('includeFirefox'); describe('Space Selector', () => { before(async () => { From c0d81c985d2fbf2755b5063b7766ac793e22b3ca Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 19 May 2021 09:45:41 -0700 Subject: [PATCH 10/18] skip failing suite (#98351) --- .../migrationsv2/integration_tests/rewriting_id.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts index 4a1a2b414a642..0f4085f6186be 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/rewriting_id.test.ts @@ -88,7 +88,8 @@ function createRoot() { ); } -describe('migration v2', () => { +// FAILING: https://github.com/elastic/kibana/issues/98351 +describe.skip('migration v2', () => { let esServer: kbnTestServer.TestElasticsearchUtils; let root: Root; From 1915592ecf255527495f190df706ebd5dff3ba00 Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Wed, 19 May 2021 14:38:07 -0400 Subject: [PATCH 11/18] crypto-js 3.3.0 -> 4.0.0 (#100347) --- package.json | 1 + yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fad8fcf8a8716..02ee5e49f1bab 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "**/load-grunt-config/lodash": "^4.17.21", "**/minimist": "^1.2.5", "**/node-jose/node-forge": "^0.10.0", + "**/pdfkit/crypto-js": "4.0.0", "**/prismjs": "1.23.0", "**/react-syntax-highlighter": "^15.3.1", "**/react-syntax-highlighter/**/highlight.js": "^10.4.1", diff --git a/yarn.lock b/yarn.lock index 94f37c4ce4f33..e7011019934ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10345,10 +10345,10 @@ crypto-browserify@^3.0.0, crypto-browserify@^3.11.0: randombytes "^2.0.0" randomfill "^1.0.3" -crypto-js@^3.1.9-1: - version "3.3.0" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" - integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== +crypto-js@4.0.0, crypto-js@^3.1.9-1: + version "4.0.0" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc" + integrity sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg== crypto-random-string@^1.0.0: version "1.0.0" From 0ef6cb315f890a65cb5eae4ba3be66cb83092050 Mon Sep 17 00:00:00 2001 From: Scotty Bollinger Date: Wed, 19 May 2021 14:05:51 -0500 Subject: [PATCH 12/18] [Enterprise Search] Upgrade Kea to 2.4.2 (#100299) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 02ee5e49f1bab..7966f33f26249 100644 --- a/package.json +++ b/package.json @@ -270,7 +270,7 @@ "jsonwebtoken": "^8.5.1", "jsts": "^1.6.2", "@kbn/rule-data-utils": "link:packages/kbn-rule-data-utils", - "kea": "^2.3.0", + "kea": "^2.4.2", "leaflet": "1.5.1", "leaflet-draw": "0.4.14", "leaflet-responsive-popup": "0.6.4", diff --git a/yarn.lock b/yarn.lock index e7011019934ef..6f534be001569 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17852,10 +17852,10 @@ kdbush@^3.0.0: resolved "https://registry.yarnpkg.com/kdbush/-/kdbush-3.0.0.tgz#f8484794d47004cc2d85ed3a79353dbe0abc2bf0" integrity sha512-hRkd6/XW4HTsA9vjVpY9tuXJYLSlelnkTmVFu4M9/7MIYQtFcHpbugAU7UbOfjOiVSVYl2fqgBuJ32JUmRo5Ew== -kea@^2.3.0: - version "2.3.3" - resolved "https://registry.yarnpkg.com/kea/-/kea-2.3.3.tgz#8fbd6d0c4ba5079c5abe46486bbc7dc1fd071a62" - integrity sha512-NZQHisfEvlg+e6BsHckW03IYaIBY+fuK4xiov7ShZ0GudUmNLhqgHSxUsykU/wdrCPEI6ANX1gyDIRTnUd3HyA== +kea@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/kea/-/kea-2.4.2.tgz#53af42702f2c8962422e456e5dd943391bad26e9" + integrity sha512-cdGds/gsJsbo/KbVAMk5/tTr229eDibVT1wmPPxPO/10zYb8GFoP3udBIQb+Hop5qGEu2wIHVdXwJvXqSS8JAg== keyv@^3.0.0: version "3.0.0" From c28b5496a624cae807d29d7d40946143b3014bb5 Mon Sep 17 00:00:00 2001 From: liza-mae Date: Wed, 19 May 2021 13:08:41 -0600 Subject: [PATCH 13/18] Upgrade functional test fixes (#100306) * Upgrade functional test fixes * Fix lint issues --- .../upgrade/apps/canvas/canvas_smoke_tests.ts | 20 +++++++++++++++++-- .../apps/dashboard/dashboard_smoke_tests.ts | 10 +++++----- .../upgrade/apps/maps/maps_smoke_tests.ts | 6 +++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts b/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts index c7db9127e01bd..2f38e828fa64d 100644 --- a/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/canvas/canvas_smoke_tests.ts @@ -11,6 +11,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getPageObjects, getService }: FtrProviderContext) { const retry = getService('retry'); const PageObjects = getPageObjects(['common', 'header']); + const browser = getService('browser'); const testSubjects = getService('testSubjects'); describe('canvas smoke tests', function describeIndexTests() { @@ -23,29 +24,44 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { { name: 'flights', id: 'workpad-a474e74b-aedc-47c3-894a-db77e62c41e0/page/1', + altId: '', numElements: 35, }, - { name: 'logs', id: 'workpad-5563cc40-5760-4afe-bf33-9da72fac53b7/page/1', numElements: 57 }, + { + name: 'logs', + id: 'workpad-5563cc40-5760-4afe-bf33-9da72fac53b7/page/1', + altId: 'workpad-ad72a4e9-b422-480c-be6d-a64a0b79541d', + numElements: 57, + }, { name: 'ecommerce', id: 'workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/1', + altId: '', numElements: 16, }, { name: 'ecommerce', id: 'workpad-e08b9bdb-ec14-4339-94c4-063bddfd610e/page/2', + altId: '', numElements: 9, }, ]; spaces.forEach(({ space, basePath }) => { - canvasTests.forEach(({ name, id, numElements }) => { + canvasTests.forEach(({ name, id, altId, numElements }) => { describe('space ' + space + ' name ' + name, () => { beforeEach(async () => { await PageObjects.common.navigateToActualUrl('canvas', 'workpad/' + id, { basePath, }); await PageObjects.header.waitUntilLoadingHasFinished(); + const url = await browser.getCurrentUrl(); + if (!url.includes(id) && altId.length > 0) { + await PageObjects.common.navigateToActualUrl('canvas', 'workpad/' + altId, { + basePath, + }); + } + await PageObjects.header.waitUntilLoadingHasFinished(); }); it('renders elements on workpad', async () => { await retry.try(async () => { diff --git a/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts b/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts index 9efc9224b2438..73819b5bac695 100644 --- a/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/dashboard/dashboard_smoke_tests.ts @@ -24,9 +24,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { ]; const dashboardTests = [ - { name: 'flights', numPanels: 19 }, - { name: 'logs', numPanels: 11 }, - { name: 'ecommerce', numPanels: 12 }, + { name: 'flights', numPanels: 17 }, + { name: 'logs', numPanels: 10 }, + { name: 'ecommerce', numPanels: 11 }, ]; spaces.forEach(({ space, basePath }) => { @@ -47,7 +47,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const toTime = `${todayYearMonthDay} @ 23:59:59.999`; await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); const panelCount = await PageObjects.dashboard.getPanelCount(); - expect(panelCount).to.be(numPanels); + expect(panelCount).to.be.above(numPanels); }); }); it('should render visualizations', async () => { @@ -60,7 +60,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // log.debug('Checking area, bar and heatmap charts rendered'); // await dashboardExpect.seriesElementCount(15); log.debug('Checking saved searches rendered'); - await dashboardExpect.savedSearchRowCount(50); + await dashboardExpect.savedSearchRowCount(49); log.debug('Checking input controls rendered'); await dashboardExpect.inputControlItemCount(3); log.debug('Checking tag cloud rendered'); diff --git a/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts b/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts index 7ec83aad26641..17b457151bd9e 100644 --- a/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts +++ b/x-pack/test/upgrade/apps/maps/maps_smoke_tests.ts @@ -117,7 +117,7 @@ export default function ({ 'ecommerce_map', updateBaselines ); - expect(percentDifference).to.be.lessThan(0.02); + expect(percentDifference.toFixed(3)).to.be.lessThan(0.031); }); }); @@ -141,7 +141,7 @@ export default function ({ 'flights_map', updateBaselines ); - expect(percentDifference).to.be.lessThan(0.02); + expect(percentDifference.toFixed(3)).to.be.lessThan(0.031); }); }); @@ -166,7 +166,7 @@ export default function ({ 'web_logs_map', updateBaselines ); - expect(percentDifference).to.be.lessThan(0.02); + expect(percentDifference.toFixed(3)).to.be.lessThan(0.031); }); }); }); From 413e2ddf20d6a777ad3115f7f04ac219ef9f9f87 Mon Sep 17 00:00:00 2001 From: Devon Thomson Date: Wed, 19 May 2021 16:19:15 -0400 Subject: [PATCH 14/18] [Dashboard] Embeddable Migrations for By Value Panels (#99715) * Implemented embeddable by value migrations --- ...er.embeddablesetup.getmigrationversions.md | 11 ++ ...ugins-embeddable-server.embeddablesetup.md | 1 + .../integration_tests/migration.test.ts | 4 +- .../embeddable_saved_object_converters.ts | 10 +- .../server/saved_objects/dashboard.ts | 2 +- .../dashboard_migrations.test.ts | 64 +++++++++ .../saved_objects/dashboard_migrations.ts | 122 +++++++++++++++--- src/plugins/embeddable/server/mocks.ts | 1 + src/plugins/embeddable/server/plugin.ts | 19 +++ src/plugins/embeddable/server/server.api.md | 2 + 10 files changed, 210 insertions(+), 26 deletions(-) create mode 100644 docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.getmigrationversions.md diff --git a/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.getmigrationversions.md b/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.getmigrationversions.md new file mode 100644 index 0000000000000..0c8b29c85c05c --- /dev/null +++ b/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.getmigrationversions.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-embeddable-server](./kibana-plugin-plugins-embeddable-server.md) > [EmbeddableSetup](./kibana-plugin-plugins-embeddable-server.embeddablesetup.md) > [getMigrationVersions](./kibana-plugin-plugins-embeddable-server.embeddablesetup.getmigrationversions.md) + +## EmbeddableSetup.getMigrationVersions property + +Signature: + +```typescript +getMigrationVersions: () => string[]; +``` diff --git a/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.md b/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.md index 5109a75ad57f0..9ecf966ece652 100644 --- a/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.md +++ b/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.md @@ -14,6 +14,7 @@ export interface EmbeddableSetup extends PersistableStateService() => string[] | | | [registerEmbeddableFactory](./kibana-plugin-plugins-embeddable-server.embeddablesetup.registerembeddablefactory.md) | (factory: EmbeddableRegistryDefinition) => void | | | [registerEnhancement](./kibana-plugin-plugins-embeddable-server.embeddablesetup.registerenhancement.md) | (enhancement: EnhancementRegistryDefinition) => void | | diff --git a/src/core/server/saved_objects/migrationsv2/integration_tests/migration.test.ts b/src/core/server/saved_objects/migrationsv2/integration_tests/migration.test.ts index 37dfe9bc717d0..53ce21192142d 100644 --- a/src/core/server/saved_objects/migrationsv2/integration_tests/migration.test.ts +++ b/src/core/server/saved_objects/migrationsv2/integration_tests/migration.test.ts @@ -95,7 +95,9 @@ describe('migration v2', () => { .getAllTypes() .reduce((versionMap, type) => { if (type.migrations) { - const highestVersion = Object.keys(type.migrations).sort(Semver.compare).reverse()[0]; + const migrationsMap = + typeof type.migrations === 'function' ? type.migrations() : type.migrations; + const highestVersion = Object.keys(migrationsMap).sort(Semver.compare).reverse()[0]; return { ...versionMap, [type.name]: highestVersion, diff --git a/src/plugins/dashboard/common/embeddable/embeddable_saved_object_converters.ts b/src/plugins/dashboard/common/embeddable/embeddable_saved_object_converters.ts index a06f248eb8125..e62170391381e 100644 --- a/src/plugins/dashboard/common/embeddable/embeddable_saved_object_converters.ts +++ b/src/plugins/dashboard/common/embeddable/embeddable_saved_object_converters.ts @@ -8,11 +8,11 @@ import { omit } from 'lodash'; import { DashboardPanelState, SavedDashboardPanel } from '../types'; -import { SavedObjectEmbeddableInput } from '../../../embeddable/common/'; +import { EmbeddableInput, SavedObjectEmbeddableInput } from '../../../embeddable/common/'; -export function convertSavedDashboardPanelToPanelState( - savedDashboardPanel: SavedDashboardPanel -): DashboardPanelState { +export function convertSavedDashboardPanelToPanelState< + TEmbeddableInput extends EmbeddableInput | SavedObjectEmbeddableInput = SavedObjectEmbeddableInput +>(savedDashboardPanel: SavedDashboardPanel): DashboardPanelState { return { type: savedDashboardPanel.type, gridData: savedDashboardPanel.gridData, @@ -22,7 +22,7 @@ export function convertSavedDashboardPanelToPanelState( ...(savedDashboardPanel.id !== undefined && { savedObjectId: savedDashboardPanel.id }), ...(savedDashboardPanel.title !== undefined && { title: savedDashboardPanel.title }), ...savedDashboardPanel.embeddableConfig, - }, + } as TEmbeddableInput, }; } diff --git a/src/plugins/dashboard/server/saved_objects/dashboard.ts b/src/plugins/dashboard/server/saved_objects/dashboard.ts index aff108682dff5..dfda251e28779 100644 --- a/src/plugins/dashboard/server/saved_objects/dashboard.ts +++ b/src/plugins/dashboard/server/saved_objects/dashboard.ts @@ -61,5 +61,5 @@ export const createDashboardSavedObjectType = ({ version: { type: 'integer' }, }, }, - migrations: createDashboardSavedObjectTypeMigrations(migrationDeps), + migrations: () => createDashboardSavedObjectTypeMigrations(migrationDeps), }); diff --git a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts index 9671a8d847c0a..1d4f83c88ba8d 100644 --- a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts +++ b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.test.ts @@ -16,6 +16,7 @@ import { createInject, } from '../../common/embeddable/dashboard_container_persistable_state'; import { EmbeddableStateWithType } from 'src/plugins/embeddable/common'; +import { SerializableState } from '../../../kibana_utils/common'; const embeddableSetupMock = createEmbeddableSetupMock(); const extract = createExtract(embeddableSetupMock); @@ -38,6 +39,7 @@ const injectImplementation = ( }; embeddableSetupMock.extract.mockImplementation(extractImplementation); embeddableSetupMock.inject.mockImplementation(injectImplementation); +embeddableSetupMock.getMigrationVersions.mockImplementation(() => []); const migrations = createDashboardSavedObjectTypeMigrations({ embeddable: embeddableSetupMock, @@ -554,4 +556,66 @@ describe('dashboard', () => { embeddableSetupMock.extract.mockImplementation(extractImplementation); }); }); + + describe('embeddable migrations for by value panels', () => { + const originalDoc: DashboardDoc730ToLatest = { + attributes: { + description: '', + kibanaSavedObjectMeta: { + searchSourceJSON: + '{"query":{"language":"kuery","query":""},"filter":[{"query":{"match_phrase":{"machine.os.keyword":"osx"}},"$state":{"store":"appState"},"meta":{"type":"phrase","key":"machine.os.keyword","params":{"query":"osx"},"disabled":false,"negate":false,"alias":null,"indexRefName":"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index"}}]}', + }, + optionsJSON: '{"useMargins":true,"hidePanelTitles":false}', + panelsJSON: `[ + {"version":"7.9.3","gridData":{"x":0,"y":0,"w":24,"h":15,"i":"0"},"panelIndex":"0","embeddableConfig":{}}, + {"version":"7.9.3","gridData":{"x":24,"y":0,"w":24,"h":15,"i":"1"},"panelIndex":"1","embeddableConfig":{ "attributes": { "byValueThing": "ThisIsByValue"} }} + ]`, + timeRestore: false, + title: 'Run by value migrations on this dashboard!', + version: 1, + }, + id: '376e6260-1f5e-11eb-91aa-7b6d5f8a61d6', + references: [ + { + id: '90943e30-9a47-11e8-b64d-95841ca0b247', + name: 'kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index', + type: 'index-pattern', + }, + { id: '14e2e710-4258-11e8-b3aa-73fdaf54bfc9', name: 'panel_0', type: 'visualization' }, + ], + type: 'dashboard', + }; + + it('should add all embeddable migrations for versions above 7.12.0 to dashboard saved object migrations', () => { + const newEmbeddableSetupMock = createEmbeddableSetupMock(); + newEmbeddableSetupMock.getMigrationVersions.mockImplementation(() => [ + '7.10.100', + '7.13.0', + '8.0.0', + ]); + const migrationsList = createDashboardSavedObjectTypeMigrations({ + embeddable: newEmbeddableSetupMock, + }); + expect(Object.keys(migrationsList).indexOf('8.0.0')).not.toBe(-1); + expect(Object.keys(migrationsList).indexOf('7.13.0')).not.toBe(-1); + expect(Object.keys(migrationsList).indexOf('7.10.100')).toBe(-1); + }); + + it('runs migrations on by value panels only', () => { + const newEmbeddableSetupMock = createEmbeddableSetupMock(); + newEmbeddableSetupMock.getMigrationVersions.mockImplementation(() => ['7.13.0']); + newEmbeddableSetupMock.migrate.mockImplementation((state: SerializableState) => { + state.superCoolKey = 'ONLY 4 BY VALUE EMBEDDABLES THANK YOU VERY MUCH'; + return state; + }); + const migrationsList = createDashboardSavedObjectTypeMigrations({ + embeddable: newEmbeddableSetupMock, + }); + expect(migrationsList['7.13.0']).toBeDefined(); + const migratedDoc = migrationsList['7.13.0'](originalDoc, contextMock); + expect(migratedDoc.attributes.panelsJSON).toMatchInlineSnapshot( + `"[{\\"version\\":\\"7.9.3\\",\\"gridData\\":{\\"x\\":0,\\"y\\":0,\\"w\\":24,\\"h\\":15,\\"i\\":\\"0\\"},\\"panelIndex\\":\\"0\\",\\"embeddableConfig\\":{}},{\\"version\\":\\"7.13.0\\",\\"gridData\\":{\\"x\\":24,\\"y\\":0,\\"w\\":24,\\"h\\":15,\\"i\\":\\"1\\"},\\"panelIndex\\":\\"1\\",\\"embeddableConfig\\":{\\"attributes\\":{\\"byValueThing\\":\\"ThisIsByValue\\"},\\"superCoolKey\\":\\"ONLY 4 BY VALUE EMBEDDABLES THANK YOU VERY MUCH\\"}}]"` + ); + }); + }); }); diff --git a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts index de44618ad57ee..bb95e9e4c38b8 100644 --- a/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts +++ b/src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts @@ -6,13 +6,26 @@ * Side Public License, v 1. */ +import semver from 'semver'; import { get, flow } from 'lodash'; -import { SavedObjectAttributes, SavedObjectMigrationFn } from 'kibana/server'; +import { + SavedObjectAttributes, + SavedObjectMigrationFn, + SavedObjectMigrationMap, +} from 'kibana/server'; + import { migrations730 } from './migrations_730'; +import { SavedDashboardPanel } from '../../common/types'; +import { EmbeddableSetup } from '../../../embeddable/server'; import { migrateMatchAllQuery } from './migrate_match_all_query'; import { DashboardDoc700To720, DashboardDoc730ToLatest } from '../../common'; -import { EmbeddableSetup } from '../../../embeddable/server'; import { injectReferences, extractReferences } from '../../common/saved_dashboard_references'; +import { + convertPanelStateToSavedDashboardPanel, + convertSavedDashboardPanelToPanelState, +} from '../../common/embeddable/embeddable_saved_object_converters'; +import { SavedObjectEmbeddableInput } from '../../../embeddable/common'; +import { SerializableValue } from '../../../kibana_utils/common'; function migrateIndexPattern(doc: DashboardDoc700To720) { const searchSourceJSON = get(doc, 'attributes.kibanaSavedObjectMeta.searchSourceJSON'); @@ -134,26 +147,97 @@ function createExtractPanelReferencesMigration( }; } +type ValueOrReferenceInput = SavedObjectEmbeddableInput & { attributes?: SerializableValue }; + +// Runs the embeddable migrations on each panel +const migrateByValuePanels = ( + deps: DashboardSavedObjectTypeMigrationsDeps, + version: string +): SavedObjectMigrationFn => (doc: any) => { + const { attributes } = doc; + // Skip if panelsJSON is missing otherwise this will cause saved object import to fail when + // importing objects without panelsJSON. At development time of this, there is no guarantee each saved + // object has panelsJSON in all previous versions of kibana. + if (typeof attributes.panelsJSON !== 'string') { + return attributes; + } + const panels = JSON.parse(attributes.panelsJSON) as SavedDashboardPanel[]; + // Same here, prevent failing saved object import if ever panels aren't an array. + if (!Array.isArray(panels)) { + return attributes; + } + const newPanels: SavedDashboardPanel[] = []; + panels.forEach((panel) => { + // Convert each panel into a state that can be passed to EmbeddablesSetup.migrate + const originalPanelState = convertSavedDashboardPanelToPanelState(panel); + if (originalPanelState.explicitInput.attributes) { + // If this panel is by value, migrate the state using embeddable migrations + const migratedInput = deps.embeddable.migrate( + { + ...originalPanelState.explicitInput, + type: originalPanelState.type, + }, + version + ); + // Convert the embeddable state back into the panel shape + newPanels.push( + convertPanelStateToSavedDashboardPanel( + { + ...originalPanelState, + explicitInput: { ...migratedInput, id: migratedInput.id as string }, + }, + version + ) + ); + } else { + newPanels.push(panel); + } + }); + return { + ...doc, + attributes: { + ...attributes, + panelsJSON: JSON.stringify(newPanels), + }, + }; +}; + export interface DashboardSavedObjectTypeMigrationsDeps { embeddable: EmbeddableSetup; } export const createDashboardSavedObjectTypeMigrations = ( deps: DashboardSavedObjectTypeMigrationsDeps -) => ({ - /** - * We need to have this migration twice, once with a version prior to 7.0.0 once with a version - * after it. The reason for that is, that this migration has been introduced once 7.0.0 was already - * released. Thus a user who already had 7.0.0 installed already got the 7.0.0 migrations below running, - * so we need a version higher than that. But this fix was backported to the 6.7 release, meaning if we - * would only have the 7.0.1 migration in here a user on the 6.7 release will migrate their saved objects - * to the 7.0.1 state, and thus when updating their Kibana to 7.0, will never run the 7.0.0 migrations introduced - * in that version. So we apply this twice, once with 6.7.2 and once with 7.0.1 while the backport to 6.7 - * only contained the 6.7.2 migration and not the 7.0.1 migration. - */ - '6.7.2': flow(migrateMatchAllQuery), - '7.0.0': flow(migrations700), - '7.3.0': flow(migrations730), - '7.9.3': flow(migrateMatchAllQuery), - '7.11.0': flow(createExtractPanelReferencesMigration(deps)), -}); +): SavedObjectMigrationMap => { + const embeddableMigrations = deps.embeddable + .getMigrationVersions() + .filter((version) => semver.gt(version, '7.12.0')) + .map((version): [string, SavedObjectMigrationFn] => { + return [version, migrateByValuePanels(deps, version)]; + }); + + return { + /** + * We need to have this migration twice, once with a version prior to 7.0.0 once with a version + * after it. The reason for that is, that this migration has been introduced once 7.0.0 was already + * released. Thus a user who already had 7.0.0 installed already got the 7.0.0 migrations below running, + * so we need a version higher than that. But this fix was backported to the 6.7 release, meaning if we + * would only have the 7.0.1 migration in here a user on the 6.7 release will migrate their saved objects + * to the 7.0.1 state, and thus when updating their Kibana to 7.0, will never run the 7.0.0 migrations introduced + * in that version. So we apply this twice, once with 6.7.2 and once with 7.0.1 while the backport to 6.7 + * only contained the 6.7.2 migration and not the 7.0.1 migration. + */ + '6.7.2': flow(migrateMatchAllQuery), + '7.0.0': flow(migrations700), + '7.3.0': flow(migrations730), + '7.9.3': flow(migrateMatchAllQuery), + '7.11.0': flow(createExtractPanelReferencesMigration(deps)), + ...Object.fromEntries(embeddableMigrations), + + /** + * Any dashboard saved object migrations that come after this point will have to be wary of + * potentially overwriting embeddable migrations. An example of how to mitigate this follows: + */ + // '7.x': flow(yourNewMigrationFunction, embeddableMigrations['7.x']) + }; +}; diff --git a/src/plugins/embeddable/server/mocks.ts b/src/plugins/embeddable/server/mocks.ts index 057faea608020..63754cecb0270 100644 --- a/src/plugins/embeddable/server/mocks.ts +++ b/src/plugins/embeddable/server/mocks.ts @@ -12,6 +12,7 @@ import { EmbeddableSetup, EmbeddableStart } from './plugin'; export const createEmbeddableSetupMock = (): jest.Mocked => ({ ...createEmbeddablePersistableStateServiceMock(), registerEmbeddableFactory: jest.fn(), + getMigrationVersions: jest.fn().mockReturnValue([]), registerEnhancement: jest.fn(), }); diff --git a/src/plugins/embeddable/server/plugin.ts b/src/plugins/embeddable/server/plugin.ts index 807a8dc3c4b94..f4728bf575a06 100644 --- a/src/plugins/embeddable/server/plugin.ts +++ b/src/plugins/embeddable/server/plugin.ts @@ -16,6 +16,7 @@ import { EmbeddableRegistryDefinition, } from './types'; import { + baseEmbeddableMigrations, getExtractFunction, getInjectFunction, getMigrateFunction, @@ -27,6 +28,7 @@ import { EmbeddableStateWithType } from '../common/types'; export interface EmbeddableSetup extends PersistableStateService { registerEmbeddableFactory: (factory: EmbeddableRegistryDefinition) => void; registerEnhancement: (enhancement: EnhancementRegistryDefinition) => void; + getMigrationVersions: () => string[]; } export type EmbeddableStart = PersistableStateService; @@ -41,6 +43,7 @@ export class EmbeddableServerPlugin implements Plugin { + const uniqueVersions = new Set(); + for (const baseMigrationVersion of Object.keys(baseEmbeddableMigrations)) { + uniqueVersions.add(baseMigrationVersion); + } + const factories = this.embeddableFactories.values(); + for (const factory of factories) { + Object.keys(factory.migrations).forEach((version) => uniqueVersions.add(version)); + } + const enhancements = this.enhancements.values(); + for (const enhancement of enhancements) { + Object.keys(enhancement.migrations).forEach((version) => uniqueVersions.add(version)); + } + return Array.from(uniqueVersions); + }; } diff --git a/src/plugins/embeddable/server/server.api.md b/src/plugins/embeddable/server/server.api.md index 5c7efec57e93b..d5c7ce29bab9e 100644 --- a/src/plugins/embeddable/server/server.api.md +++ b/src/plugins/embeddable/server/server.api.md @@ -23,6 +23,8 @@ export interface EmbeddableRegistryDefinition

{ + // (undocumented) + getMigrationVersions: () => string[]; // (undocumented) registerEmbeddableFactory: (factory: EmbeddableRegistryDefinition) => void; // (undocumented) From c6e8ee2268f73b46a7c123aee2b7ce8c6e30f6cc Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Wed, 19 May 2021 22:39:52 +0200 Subject: [PATCH 15/18] Cleanup package.json resolutions. (#99456) --- package.json | 9 ++--- .../discovery/scan_plugin_search_paths.ts | 4 +- .../shareable_runtime/components/canvas.tsx | 4 +- .../scripts/endpoint/trusted_apps/index.ts | 1 - yarn.lock | 39 ++++++------------- 5 files changed, 20 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 7966f33f26249..07c6087579e79 100644 --- a/package.json +++ b/package.json @@ -71,9 +71,8 @@ "url": "https://github.com/elastic/kibana.git" }, "resolutions": { - "**/@types/node": "14.14.14", + "**/@types/node": "14.14.44", "**/chokidar": "^3.4.3", - "**/cross-fetch/node-fetch": "^2.6.1", "**/deepmerge": "^4.2.2", "**/fast-deep-equal": "^3.1.1", "globby/fast-glob": "3.2.5", @@ -88,7 +87,7 @@ "**/react-syntax-highlighter": "^15.3.1", "**/react-syntax-highlighter/**/highlight.js": "^10.4.1", "**/request": "^2.88.2", - "**/trim": "0.0.3", + "**/trim": "1.0.1", "**/typescript": "4.1.3", "**/underscore": "^1.13.1" }, @@ -329,7 +328,6 @@ "react-ace": "^5.9.0", "react-beautiful-dnd": "^13.0.0", "react-color": "^2.13.8", - "react-datetime": "^2.14.0", "react-dom": "^16.12.0", "react-dropzone": "^4.2.9", "react-fast-compare": "^2.0.4", @@ -567,13 +565,14 @@ "@types/mime": "^2.0.1", "@types/mime-types": "^2.1.0", "@types/minimatch": "^2.0.29", + "@types/minimist": "^1.2.1", "@types/mocha": "^8.2.0", "@types/mock-fs": "^4.10.0", "@types/moment-timezone": "^0.5.12", "@types/mustache": "^0.8.31", "@types/ncp": "^2.0.1", "@types/nock": "^10.0.3", - "@types/node": "14.14.14", + "@types/node": "14.14.44", "@types/node-fetch": "^2.5.7", "@types/node-forge": "^0.9.5", "@types/nodemailer": "^6.4.0", diff --git a/src/core/server/plugins/discovery/scan_plugin_search_paths.ts b/src/core/server/plugins/discovery/scan_plugin_search_paths.ts index ffe73ff9b53e8..51d5a29115c30 100644 --- a/src/core/server/plugins/discovery/scan_plugin_search_paths.ts +++ b/src/core/server/plugins/discovery/scan_plugin_search_paths.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { readdir, stat } from 'fs'; +import { PathLike, readdir, stat, Stats } from 'fs'; import { resolve } from 'path'; import { bindNodeCallback, from, Observable } from 'rxjs'; import { catchError, mergeMap } from 'rxjs/operators'; @@ -14,7 +14,7 @@ import { Logger } from '../../logging'; import { PluginDiscoveryError } from './plugin_discovery_error'; const fsReadDir$ = bindNodeCallback(readdir); -const fsStat$ = bindNodeCallback(stat); +const fsStat$ = bindNodeCallback(stat); const maxScanDepth = 5; diff --git a/x-pack/plugins/canvas/shareable_runtime/components/canvas.tsx b/x-pack/plugins/canvas/shareable_runtime/components/canvas.tsx index 52bf01a3ec003..dd54f95b75fa8 100644 --- a/x-pack/plugins/canvas/shareable_runtime/components/canvas.tsx +++ b/x-pack/plugins/canvas/shareable_runtime/components/canvas.tsx @@ -85,9 +85,9 @@ export const CanvasComponent = ({ // any point, or change the interval, we need to make sure the interval is // killed on React re-render-- otherwise the pages will start bouncing around // as timeouts are accumulated. - clearTimeout(timeout); + window.clearTimeout(timeout); - timeout = setTimeout( + timeout = window.setTimeout( () => onSetPage(page >= workpad.pages.length - 1 ? 0 : page + 1), getTimeInterval(autoplay.interval) ); diff --git a/x-pack/plugins/security_solution/scripts/endpoint/trusted_apps/index.ts b/x-pack/plugins/security_solution/scripts/endpoint/trusted_apps/index.ts index edefaa9c2a50c..bfa3fe88f7ac8 100644 --- a/x-pack/plugins/security_solution/scripts/endpoint/trusted_apps/index.ts +++ b/x-pack/plugins/security_solution/scripts/endpoint/trusted_apps/index.ts @@ -5,7 +5,6 @@ * 2.0. */ -// @ts-ignore import minimist from 'minimist'; import { ToolingLog } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; diff --git a/yarn.lock b/yarn.lock index 6f534be001569..c8293e9f2b914 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5400,10 +5400,10 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-2.0.29.tgz#5002e14f75e2d71e564281df0431c8c1b4a2a36a" integrity sha1-UALhT3Xi1x5WQoHfBDHIwbSio2o= -"@types/minimist@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" - integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= +"@types/minimist@^1.2.0", "@types/minimist@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" + integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== "@types/minipass@*": version "2.2.0" @@ -5472,10 +5472,10 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@12.12.50", "@types/node@14.14.14", "@types/node@8.10.54", "@types/node@>= 8", "@types/node@>=8.9.0", "@types/node@^10.1.0": - version "14.14.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae" - integrity sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ== +"@types/node@*", "@types/node@12.12.50", "@types/node@14.14.44", "@types/node@8.10.54", "@types/node@>= 8", "@types/node@>=8.9.0", "@types/node@^10.1.0": + version "14.14.44" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.44.tgz#df7503e6002847b834371c004b372529f3f85215" + integrity sha512-+gaugz6Oce6ZInfI/tK4Pq5wIIkJMEJUu92RB3Eu93mtj4wjjjz9EB5mLp5s1pSsLXdC/CPut/xF20ZzAQJbTA== "@types/nodemailer@^6.4.0": version "6.4.0" @@ -22747,16 +22747,6 @@ react-color@^2.13.8, react-color@^2.17.0: reactcss "^1.2.0" tinycolor2 "^1.4.1" -react-datetime@^2.14.0: - version "2.15.0" - resolved "https://registry.yarnpkg.com/react-datetime/-/react-datetime-2.15.0.tgz#a8f7da6c58b6b45dbeea32d4e8485db17614e12c" - integrity sha512-RP5OqXVfrhdoFALJzMU8tKxRFaIZzJZqZEpf5oK7pvwG80a/bET/TdJ7jT7W9lyAf1nKNo6zyYkvHW3ZJ/ypvg== - dependencies: - create-react-class "^15.5.2" - object-assign "^3.0.0" - prop-types "^15.5.7" - react-onclickoutside "^6.5.0" - react-dev-utils@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-11.0.4.tgz#a7ccb60257a1ca2e0efe7a83e38e6700d17aa37a" @@ -23042,11 +23032,6 @@ react-motion@^0.4.8: prop-types "^15.5.8" raf "^3.1.0" -react-onclickoutside@^6.5.0: - version "6.7.1" - resolved "https://registry.yarnpkg.com/react-onclickoutside/-/react-onclickoutside-6.7.1.tgz#6a5b5b8b4eae6b776259712c89c8a2b36b17be93" - integrity sha512-p84kBqGaMoa7VYT0vZ/aOYRfJB+gw34yjpda1Z5KeLflg70HipZOT+MXQenEhdkPAABuE2Astq4zEPdMqUQxcg== - react-popper-tooltip@^2.10.1: version "2.11.1" resolved "https://registry.yarnpkg.com/react-popper-tooltip/-/react-popper-tooltip-2.11.1.tgz#3c4bdfd8bc10d1c2b9a162e859bab8958f5b2644" @@ -27130,10 +27115,10 @@ trim-trailing-lines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-trailing-lines/-/trim-trailing-lines-1.1.0.tgz#7aefbb7808df9d669f6da2e438cac8c46ada7684" integrity sha1-eu+7eAjfnWafbaLkOMrIxGradoQ= -trim@0.0.1, trim@0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/trim/-/trim-0.0.3.tgz#05243a47a3a4113e6b49367880a9cca59697a20b" - integrity sha512-h82ywcYhHK7veeelXrCScdH7HkWfbIT1D/CgYO+nmDarz3SGNssVBMws6jU16Ga60AJCRAvPV6w6RLuNerQqjg== +trim@0.0.1, trim@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim/-/trim-1.0.1.tgz#68e78f6178ccab9687a610752f4f5e5a7022ee8c" + integrity sha512-3JVP2YVqITUisXblCDq/Bi4P9457G/sdEamInkyvCsjbTcXLXIiG7XCb4kGMFWh6JGXesS3TKxOPtrncN/xe8w== triple-beam@^1.2.0, triple-beam@^1.3.0: version "1.3.0" From 00479968a134f9763bfd3a22008ddaf4dd8556a8 Mon Sep 17 00:00:00 2001 From: Kevin Logan <56395104+kevinlog@users.noreply.github.com> Date: Wed, 19 May 2021 17:37:43 -0400 Subject: [PATCH 16/18] [Security Solution] Add linux malware config options and migration (#100166) --- .../security_solution/to_v7_14_0.test.ts | 180 +++++++++++------- .../security_solution/to_v7_14_0.ts | 8 +- .../common/endpoint/models/policy_config.ts | 19 ++ .../common/endpoint/types/index.ts | 9 +- .../policy/store/policy_details/index.test.ts | 7 + .../policy/store/policy_details/middleware.ts | 1 + .../policy/store/policy_details/selectors.ts | 2 + .../public/management/pages/policy/types.ts | 5 +- .../components/protection_radio.tsx | 10 +- .../components/user_notification.tsx | 8 +- .../view/policy_forms/protections/malware.tsx | 4 +- .../apps/endpoint/policy_details.ts | 21 ++ 12 files changed, 196 insertions(+), 78 deletions(-) diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts index 8ccb50735d4fb..f0c397e93ac4e 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.ts @@ -13,8 +13,14 @@ import { migrateEndpointPackagePolicyToV7140 } from './to_v7_14_0'; describe('7.14.0 Endpoint Package Policy migration', () => { const migration = migrateEndpointPackagePolicyToV7140; - it('adds supported option for ransomware on migrations', () => { - const doc = { + const policyDoc = ({ + windowsMalware = {}, + windowsRansomware = {}, + windowsPopup = {}, + linuxMalware = {}, + linuxPopup = {}, + }) => { + return { id: 'mock-saved-object-id', attributes: { name: 'Some Policy Name', @@ -42,26 +48,15 @@ describe('7.14.0 Endpoint Package Policy migration', () => { policy: { value: { windows: { - ransomware: { - mode: 'off', - }, - malware: { - mode: 'off', - }, - popup: { - malware: { - message: '', - enabled: false, - }, - ransomware: { - message: '', - enabled: false, - }, - }, + ...windowsMalware, + ...windowsRansomware, + ...windowsPopup, }, linux: { events: { process: true, file: true, network: true }, logging: { file: 'info' }, + ...linuxMalware, + ...linuxPopup, }, }, }, @@ -71,65 +66,108 @@ describe('7.14.0 Endpoint Package Policy migration', () => { }, type: ' nested', }; + }; - expect(migration(doc, {} as SavedObjectMigrationContext)).toEqual({ - attributes: { - name: 'Some Policy Name', - package: { - name: 'endpoint', - title: '', - version: '', + it('adds supported option for ransomware on migrations and linux malware when windows malware is disabled', () => { + const initialDoc = policyDoc({ + windowsMalware: { malware: { mode: 'off' } }, + windowsRansomware: { ransomware: { mode: 'off' } }, + windowsPopup: { + popup: { + malware: { + message: '', + enabled: false, + }, + ransomware: { + message: '', + enabled: false, + }, }, - id: 'endpoint', - policy_id: '', - enabled: true, - namespace: '', - output_id: '', - revision: 0, - updated_at: '', - updated_by: '', - created_at: '', - created_by: '', - inputs: [ - { - type: 'endpoint', + }, + }); + + const migratedDoc = policyDoc({ + windowsMalware: { malware: { mode: 'off' } }, + windowsRansomware: { ransomware: { mode: 'off', supported: true } }, + windowsPopup: { + popup: { + malware: { + message: '', + enabled: false, + }, + ransomware: { + message: '', + enabled: false, + }, + }, + }, + linuxMalware: { + malware: { + mode: 'off', + }, + }, + linuxPopup: { + popup: { + malware: { + message: '', + enabled: false, + }, + }, + }, + }); + + expect(migration(initialDoc, {} as SavedObjectMigrationContext)).toEqual(migratedDoc); + }); + + it('adds supported option for ransomware on migrations and linux malware option and notification customization when windows malware is enabled', () => { + const initialDoc = policyDoc({ + windowsMalware: { malware: { mode: 'on' } }, + windowsRansomware: { ransomware: { mode: 'on' } }, + windowsPopup: { + popup: { + malware: { + message: '', enabled: true, - streams: [], - config: { - policy: { - value: { - windows: { - ransomware: { - mode: 'off', - supported: true, - }, - malware: { - mode: 'off', - }, - popup: { - malware: { - message: '', - enabled: false, - }, - ransomware: { - message: '', - enabled: false, - }, - }, - }, - linux: { - events: { process: true, file: true, network: true }, - logging: { file: 'info' }, - }, - }, - }, - }, }, - ], + ransomware: { + message: '', + enabled: true, + }, + }, }, - type: ' nested', - id: 'mock-saved-object-id', }); + + const migratedDoc = policyDoc({ + windowsMalware: { malware: { mode: 'on' } }, + windowsRansomware: { ransomware: { mode: 'on', supported: true } }, + windowsPopup: { + popup: { + malware: { + message: '', + enabled: true, + }, + ransomware: { + message: '', + enabled: true, + }, + }, + }, + linuxMalware: { + malware: { + mode: 'on', + }, + }, + linuxPopup: { + popup: { + malware: { + message: '', + enabled: true, + }, + }, + }, + }); + + expect(migration(initialDoc, {} as SavedObjectMigrationContext)).toEqual(migratedDoc); }); it('does not modify non-endpoint package policies', () => { diff --git a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts index a9acf7865f812..cd7dcc2d3e1df 100644 --- a/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts +++ b/x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.ts @@ -17,11 +17,17 @@ export const migrateEndpointPackagePolicyToV7140: SavedObjectMigrationFn< const updatedPackagePolicyDoc: SavedObjectUnsanitizedDoc = cloneDeep( packagePolicyDoc ); - if (packagePolicyDoc.attributes.package?.name === 'endpoint') { const input = updatedPackagePolicyDoc.attributes.inputs[0]; if (input && input.config) { const policy = input.config.policy.value; + const linuxMalware = cloneDeep(input.config.policy.value.windows.malware); + const linuxMalwarePopup = { + malware: cloneDeep(input.config.policy.value.windows.popup.malware), + }; + + policy.linux.malware = linuxMalware; + policy.linux.popup = linuxMalwarePopup; // This value is based on license. // For the migration, we add 'true', our license watcher will correct it, if needed, when the app starts. diff --git a/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts b/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts index 1bb5cf7bc87c1..63784b8b8b440 100644 --- a/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts +++ b/x-pack/plugins/security_solution/common/endpoint/models/policy_config.ts @@ -71,6 +71,15 @@ export const policyFactory = (): PolicyConfig => { file: true, network: true, }, + malware: { + mode: ProtectionModes.prevent, + }, + popup: { + malware: { + message: '', + enabled: true, + }, + }, logging: { file: 'info', }, @@ -114,6 +123,16 @@ export const policyFactoryWithoutPaidFeatures = ( }, }, }, + linux: { + ...policy.linux, + popup: { + ...policy.linux.popup, + malware: { + message: '', + enabled: true, + }, + }, + }, }; }; diff --git a/x-pack/plugins/security_solution/common/endpoint/types/index.ts b/x-pack/plugins/security_solution/common/endpoint/types/index.ts index 541507ac048ca..055b3f6a34378 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types/index.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types/index.ts @@ -878,6 +878,13 @@ export interface PolicyConfig { process: boolean; network: boolean; }; + malware: ProtectionFields; + popup: { + malware: { + message: string; + enabled: boolean; + }; + }; logging: { file: string; }; @@ -902,7 +909,7 @@ export interface UIPolicyConfig { /** * Linux-specific policy configuration that is supported via the UI */ - linux: Pick; + linux: Pick; } /** Policy: Protection fields */ diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts index 89b8e9d7f5944..94208390b660b 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/index.test.ts @@ -314,6 +314,13 @@ describe('policy details: ', () => { linux: { events: { process: true, file: true, network: true }, logging: { file: 'info' }, + malware: { mode: 'prevent' }, + popup: { + malware: { + enabled: true, + message: '', + }, + }, }, }, }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts index 2e44021a79126..793d083400aa2 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts @@ -41,6 +41,7 @@ export const policyDetailsMiddlewareFactory: ImmutableMiddlewareFactory UIPolicyConfig = createSel linux: { advanced: linux.advanced, events: linux.events, + malware: linux.malware, + popup: linux.popup, }, }; } diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/types.ts b/x-pack/plugins/security_solution/public/management/pages/policy/types.ts index b2b95e2765bd8..269e70b3c2474 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/types.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/types.ts @@ -122,10 +122,13 @@ export type RansomwareProtectionOSes = KeysByValueCriteria< export type PolicyProtection = | keyof Pick - | keyof Pick; + | keyof Pick + | keyof Pick; export type MacPolicyProtection = keyof Pick; +export type LinuxPolicyProtection = keyof Pick; + export interface GetPolicyListResponse extends GetPackagePoliciesResponse { items: PolicyData[]; } diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/protection_radio.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/protection_radio.tsx index 8394b557207af..fe698fdb727a5 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/protection_radio.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/protection_radio.tsx @@ -14,7 +14,7 @@ import { ProtectionModes, UIPolicyConfig, } from '../../../../../../../common/endpoint/types'; -import { MacPolicyProtection, PolicyProtection } from '../../../types'; +import { MacPolicyProtection, LinuxPolicyProtection, PolicyProtection } from '../../../types'; import { usePolicyDetailsSelector } from '../../policy_hooks'; import { policyConfig } from '../../../store/policy_details/selectors'; import { AppAction } from '../../../../../../common/store/actions'; @@ -46,6 +46,8 @@ export const ProtectionRadio = React.memo( newPayload[os][protection].mode = protectionMode; } else if (os === 'mac') { newPayload[os][protection as MacPolicyProtection].mode = protectionMode; + } else if (os === 'linux') { + newPayload[os][protection as LinuxPolicyProtection].mode = protectionMode; } if (isPlatinumPlus) { if (os === 'windows') { @@ -60,6 +62,12 @@ export const ProtectionRadio = React.memo( } else { newPayload[os].popup[protection as MacPolicyProtection].enabled = false; } + } else if (os === 'linux') { + if (protectionMode === ProtectionModes.prevent) { + newPayload[os].popup[protection as LinuxPolicyProtection].enabled = true; + } else { + newPayload[os].popup[protection as LinuxPolicyProtection].enabled = false; + } } } } diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/user_notification.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/user_notification.tsx index def9e78e994b0..e442491ed7ee8 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/user_notification.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/components/user_notification.tsx @@ -24,7 +24,7 @@ import { ProtectionModes, UIPolicyConfig, } from '../../../../../../../common/endpoint/types'; -import { PolicyProtection, MacPolicyProtection } from '../../../types'; +import { PolicyProtection, MacPolicyProtection, LinuxPolicyProtection } from '../../../types'; import { ConfigFormHeading } from '../../components/config_form'; import { usePolicyDetailsSelector } from '../../policy_hooks'; import { policyConfig } from '../../../store/policy_details/selectors'; @@ -57,6 +57,9 @@ export const UserNotification = React.memo( } else if (os === 'mac') { newPayload[os].popup[protection as MacPolicyProtection].enabled = event.target.checked; + } else if (os === 'linux') { + newPayload[os].popup[protection as LinuxPolicyProtection].enabled = + event.target.checked; } } dispatch({ @@ -77,6 +80,9 @@ export const UserNotification = React.memo( newPayload[os].popup[protection].message = event.target.value; } else if (os === 'mac') { newPayload[os].popup[protection as MacPolicyProtection].message = event.target.value; + } else if (os === 'linux') { + newPayload[os].popup[protection as LinuxPolicyProtection].message = + event.target.value; } } dispatch({ diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/protections/malware.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/protections/malware.tsx index 03cd587ca7e5c..c17d6df36be68 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/protections/malware.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_forms/protections/malware.tsx @@ -24,7 +24,7 @@ import { ProtectionSwitch } from '../components/protection_switch'; * which will configure for all relevant OSes. */ export const MalwareProtections = React.memo(() => { - const OSes: Immutable = [OS.windows, OS.mac]; + const OSes: Immutable = [OS.windows, OS.mac, OS.linux]; const protection = 'malware'; const isPlatinumPlus = useLicense().isPlatinumPlus(); @@ -33,7 +33,7 @@ export const MalwareProtections = React.memo(() => { type={i18n.translate('xpack.securitySolution.endpoint.policy.details.malware', { defaultMessage: 'Malware', })} - supportedOss={[OperatingSystem.WINDOWS, OperatingSystem.MAC]} + supportedOss={[OperatingSystem.WINDOWS, OperatingSystem.MAC, OperatingSystem.LINUX]} dataTestSubj="malwareProtectionsForm" rightCorner={} > diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts index 1303dd35fa9f7..d8bc9f6444f64 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts @@ -261,6 +261,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { events: { file: false, network: true, process: true }, logging: { file: 'info' }, advanced: { agent: { connection_delay: 'true' } }, + malware: { mode: 'prevent' }, + popup: { + malware: { + enabled: true, + message: 'Elastic Security {action} {filename}', + }, + }, }, mac: { events: { file: false, network: true, process: true }, @@ -422,6 +429,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { events: { file: true, network: true, process: true }, logging: { file: 'info' }, advanced: { agent: { connection_delay: 'true' } }, + malware: { mode: 'prevent' }, + popup: { + malware: { + enabled: true, + message: 'Elastic Security {action} {filename}', + }, + }, }, mac: { events: { file: true, network: true, process: true }, @@ -580,6 +594,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { linux: { events: { file: true, network: true, process: true }, logging: { file: 'info' }, + malware: { mode: 'prevent' }, + popup: { + malware: { + enabled: true, + message: 'Elastic Security {action} {filename}', + }, + }, }, mac: { events: { file: true, network: true, process: true }, From 9bf488e8261196ea48a43fad25c2cc1c9395f5a1 Mon Sep 17 00:00:00 2001 From: Frank Hassanabad Date: Wed, 19 May 2021 15:59:52 -0600 Subject: [PATCH 17/18] [Security Solutions] Re-arranges and adds more packages to remove copied code (#100310) ## Summary * Creates a `securitysolution-list-utils` packaged and moves the first set of utilities into there * Fixes a slight bug with `kbn-securitysolution-io-ts-list-types` where the wrong name was used * Moves _all_ of the lists schemas and types into the package `kbn-securitysolution-io-ts-list-types` * Removes copied code found in a few places ## Tech debt * Some spots I have to use an `any` in the package as Kibana kbn packages don't have the types I need * Some spots I copy constants until we can straighten out those pieces. * I keep copied mock files until we figure out how to share mocks from these packages without adding weight or we create dedicated mock packages for all of this. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .i18nrc.json | 15 +- .../monorepo-packages.asciidoc | 1 + package.json | 1 + packages/BUILD.bazel | 1 + .../BUILD.bazel | 2 +- .../src/{ => common}/comment/index.mock.ts | 2 +- .../src/{ => common}/comment/index.test.ts | 2 +- .../src/{ => common}/comment/index.ts | 0 .../{ => common}/create_comment/index.mock.ts | 0 .../{ => common}/create_comment/index.test.ts | 0 .../src/{ => common}/create_comment/index.ts | 0 .../src/{ => common}/created_at/index.ts | 0 .../src/{ => common}/created_by/index.ts | 0 .../src/common/cursor/index.ts | 13 ++ .../default_comments_array/index.test.ts | 0 .../default_comments_array/index.ts | 0 .../index.test.ts | 0 .../default_create_comments_array/index.ts | 0 .../default_namespace/index.test.ts | 0 .../{ => common}/default_namespace/index.ts | 0 .../default_namespace_array/index.test.ts | 0 .../default_namespace_array/index.ts | 0 .../index.test.ts | 0 .../default_update_comments_array/index.ts | 0 .../src/{ => common}/description/index.ts | 0 .../src/common/deserializer/index.ts | 14 ++ .../endpoint/entries/index.mock.ts | 0 .../endpoint/entries/index.test.ts | 0 .../{ => common}/endpoint/entries/index.ts | 0 .../endpoint/entry_match/index.mock.ts | 2 +- .../endpoint/entry_match/index.test.ts | 0 .../endpoint/entry_match/index.ts | 0 .../endpoint/entry_match_any/index.mock.ts | 2 +- .../endpoint/entry_match_any/index.test.ts | 0 .../endpoint/entry_match_any/index.ts | 0 .../endpoint/entry_match_wildcard/index.ts | 0 .../endpoint/entry_nested/index.mock.ts | 2 +- .../endpoint/entry_nested/index.test.ts | 0 .../endpoint/entry_nested/index.ts | 0 .../src/{ => common}/endpoint/index.ts | 4 - .../non_empty_nested_entries_array/index.ts | 0 .../src/{ => common}/entries/index.mock.ts | 0 .../src/{ => common}/entries/index.test.ts | 0 .../src/{ => common}/entries/index.ts | 0 .../{ => common}/entries_exist/index.mock.ts | 2 +- .../{ => common}/entries_exist/index.test.ts | 0 .../src/{ => common}/entries_exist/index.ts | 0 .../{ => common}/entries_list/index.mock.ts | 2 +- .../{ => common}/entries_list/index.test.ts | 0 .../src/{ => common}/entries_list/index.ts | 0 .../{ => common}/entry_match/index.mock.ts | 2 +- .../{ => common}/entry_match/index.test.ts | 0 .../src/{ => common}/entry_match/index.ts | 0 .../entry_match_any/index.mock.ts | 2 +- .../entry_match_any/index.test.ts | 0 .../src/{ => common}/entry_match_any/index.ts | 0 .../entry_match_wildcard/index.mock.ts | 2 +- .../entry_match_wildcard/index.test.ts | 0 .../entry_match_wildcard/index.ts | 0 .../{ => common}/entry_nested/index.mock.ts | 2 +- .../{ => common}/entry_nested/index.test.ts | 0 .../src/{ => common}/entry_nested/index.ts | 0 .../src/common/exception_list/index.test.ts | 45 ++++++ .../src/{ => common}/exception_list/index.ts | 0 .../exception_list_item_type/index.ts | 0 .../src/common/file/index.ts | 10 ++ .../src/common/filter/index.ts | 14 ++ .../src/{ => common}/id/index.ts | 0 .../src/common/immutable/index.ts | 14 ++ .../src/common/index.ts | 62 ++++++++ .../src/common/item/index.ts | 11 ++ .../src/{ => common}/item_id/index.ts | 0 .../src/common/list_id/index.ts | 17 +++ .../src/common/list_operator/index.test.ts | 45 ++++++ .../src/{ => common}/list_operator/index.ts | 0 .../src/common/list_type/index.ts | 14 ++ .../src/{ => common}/lists/index.mock.ts | 2 +- .../src/{ => common}/lists/index.test.ts | 0 .../src/{ => common}/lists/index.ts | 0 .../lists_default_array/index.test.ts | 0 .../{ => common}/lists_default_array/index.ts | 0 .../src/{ => common}/meta/index.ts | 0 .../src/{ => common}/name/index.ts | 0 .../src/common/namespace_type/index.ts | 13 ++ .../non_empty_entries_array/index.test.ts | 0 .../non_empty_entries_array/index.ts | 0 .../index.test.ts | 0 .../non_empty_nested_entries_array/index.ts | 0 .../src/common/os_type/index.test.ts | 46 ++++++ .../src/{ => common}/os_type/index.ts | 0 .../src/common/page/index.ts | 15 ++ .../src/common/per_page/index.ts | 17 +++ .../common/required_keep_undefined/index.ts | 24 +++ .../src/common/serializer/index.ts | 14 ++ .../src/common/sort_field/index.ts | 15 ++ .../src/common/sort_order/index.ts | 15 ++ .../src/{ => common}/tags/index.ts | 0 .../src/common/tie_breaker_id/index.ts | 13 ++ .../src/common/total/index.ts | 13 ++ .../src/common/type/index.test.ts | 34 +++++ .../src/{ => common}/type/index.ts | 0 .../src/common/underscore_version/index.ts | 13 ++ .../{ => common}/update_comment/index.mock.ts | 2 +- .../{ => common}/update_comment/index.test.ts | 0 .../src/{ => common}/update_comment/index.ts | 0 .../src/{ => common}/updated_at/index.ts | 0 .../src/{ => common}/updated_by/index.ts | 0 .../src/common/value/index.ts | 12 ++ .../src/constants/index.mock.ts | 114 ++++++++++++-- .../src/constants/index.ts | 18 +++ .../src/index.ts | 38 +---- .../index.mock.ts | 10 +- .../index.test.ts | 20 +-- .../create_endpoint_list_item_schema/index.ts | 36 +++-- .../index.mock.ts | 61 ++++++++ .../index.test.ts | 19 +-- .../index.ts | 38 ++--- .../index.mock.ts | 60 ++++++++ .../index.test.ts | 12 +- .../create_exception_list_schema/index.ts | 29 ++-- .../create_list_item_schema/index.mock.ts | 35 +++++ .../create_list_item_schema/index.test.ts | 9 +- .../request/create_list_item_schema/index.ts | 13 +- .../request/create_list_schema/index.mock.ts | 41 ++++++ .../request/create_list_schema/index.test.ts | 9 +- .../src/request/create_list_schema/index.ts | 16 +- .../index.mock.ts | 15 ++ .../index.test.ts | 12 +- .../delete_endpoint_list_item_schema/index.ts | 11 +- .../index.mock.ts | 16 ++ .../index.test.ts | 12 +- .../index.ts | 13 +- .../index.mock.ts | 16 ++ .../index.test.ts | 12 +- .../delete_exception_list_schema/index.ts | 13 +- .../delete_list_item_schema/index.mock.ts | 17 +++ .../delete_list_item_schema/index.test.ts | 9 +- .../request/delete_list_item_schema/index.ts | 12 +- .../request/delete_list_schema/index.mock.ts | 17 +++ .../request/delete_list_schema/index.test.ts | 9 +- .../src/request/delete_list_schema/index.ts | 9 +- .../index.mock.ts | 17 +++ .../index.test.ts | 12 +- .../index.ts | 10 +- .../index.mock.ts | 15 ++ .../index.test.ts | 12 +- .../export_list_item_query_schema/index.ts | 9 +- .../index.mock.ts | 12 +- .../index.test.ts | 12 +- .../find_endpoint_list_item_schema/index.ts | 11 +- .../index.mock.ts | 12 +- .../index.test.ts | 11 +- .../find_exception_list_item_schema/index.ts | 14 +- .../find_exception_list_schema/index.mock.ts | 12 +- .../find_exception_list_schema/index.test.ts | 9 +- .../find_exception_list_schema/index.ts | 13 +- .../find_list_item_schema/index.mock.ts | 9 +- .../find_list_item_schema/index.test.ts | 18 +-- .../request/find_list_item_schema/index.ts | 15 +- .../request/find_list_schema/index.mock.ts | 9 +- .../request/find_list_schema/index.test.ts | 9 +- .../src/request/find_list_schema/index.ts | 14 +- .../index.mock.ts | 18 +++ .../index.test.ts | 12 +- .../import_list_item_query_schema/index.ts | 13 +- .../import_list_item_schema/index.mock.ts | 22 +++ .../import_list_item_schema/index.test.ts | 9 +- .../request/import_list_item_schema/index.ts | 9 +- .../src}/request/index.ts | 18 +-- .../patch_list_item_schema/index.mock.ts | 17 +++ .../patch_list_item_schema/index.test.ts | 9 +- .../request/patch_list_item_schema/index.ts | 13 +- .../request/patch_list_schema/index.mock.ts | 9 +- .../request/patch_list_schema/index.test.ts | 9 +- .../src/request/patch_list_schema/index.ts | 14 +- .../index.mock.ts | 16 ++ .../index.test.ts | 12 +- .../read_endpoint_list_item_schema/index.ts | 11 +- .../index.mock.ts | 17 +++ .../index.test.ts | 12 +- .../read_exception_list_item_schema/index.ts | 13 +- .../read_exception_list_schema/index.mock.ts | 17 +++ .../read_exception_list_schema/index.test.ts | 9 +- .../read_exception_list_schema/index.ts | 13 +- .../read_list_item_schema/index.mock.ts | 17 +++ .../read_list_item_schema/index.test.ts | 9 +- .../request/read_list_item_schema/index.ts | 12 +- .../request/read_list_schema/index.mock.ts | 15 ++ .../request/read_list_schema/index.test.ts | 9 +- .../src/request/read_list_schema/index.ts | 8 +- .../index.mock.ts | 9 +- .../index.test.ts | 12 +- .../update_endpoint_list_item_schema/index.ts | 35 ++--- .../index.mock.ts | 52 +++++++ .../index.test.ts | 12 +- .../index.ts | 39 +++-- .../index.test.ts | 9 +- .../index.ts | 7 +- .../index.mock.ts | 35 +++++ .../index.test.ts | 12 +- .../update_exception_list_schema/index.ts | 33 ++--- .../update_list_item_schema/index.mock.ts | 25 ++++ .../update_list_item_schema/index.test.ts | 9 +- .../request/update_list_item_schema/index.ts | 13 +- .../request/update_list_schema/index.mock.ts | 29 ++++ .../request/update_list_schema/index.test.ts | 9 +- .../src/request/update_list_schema/index.ts | 16 +- .../response/acknowledge_schema/index.mock.ts | 13 ++ .../response/acknowledge_schema/index.test.ts | 9 +- .../src/response/acknowledge_schema/index.ts | 5 +- .../create_endpoint_list_schema/index.test.ts | 9 +- .../create_endpoint_list_schema/index.ts | 8 +- .../exception_list_item_schema/index.mock.ts | 69 +++++++++ .../exception_list_item_schema/index.test.ts | 9 +- .../exception_list_item_schema/index.ts | 53 +++++++ .../exception_list_schema/index.mock.ts | 77 ++++++++++ .../exception_list_schema/index.test.ts | 9 +- .../response/exception_list_schema/index.ts | 51 +++++++ .../index.mock.ts | 17 +++ .../index.test.ts | 16 +- .../found_exception_list_item_schema/index.ts | 12 +- .../found_exception_list_schema/index.mock.ts | 17 +++ .../found_exception_list_schema/index.test.ts | 13 +- .../found_exception_list_schema/index.ts | 11 +- .../found_list_item_schema/index.mock.ts | 18 +++ .../response/found_list_item_schema/index.ts | 27 ++++ .../response/found_list_schema/index.mock.ts | 18 +++ .../src/response/found_list_schema/index.ts | 27 ++++ .../src}/response/index.ts | 5 +- .../index.mock.ts | 14 ++ .../index.test.ts | 9 +- .../list_item_index_exist_schema/index.ts | 5 +- .../response/list_item_schema/index.mock.ts | 48 ++++++ .../response/list_item_schema/index.test.ts | 9 +- .../src/response/list_item_schema/index.ts | 46 ++++++ .../src/response/list_schema/index.mock.ts | 54 +++++++ .../src/response/list_schema/index.test.ts | 9 +- .../src/response/list_schema/index.ts | 49 ++++++ .../search_list_item_schema/index.mock.ts | 16 ++ .../search_list_item_schema/index.test.ts | 10 +- .../response/search_list_item_schema/index.ts | 8 +- .../BUILD.bazel | 87 +++++++++++ .../kbn-securitysolution-list-utils/README.md | 5 + .../jest.config.js | 13 ++ .../package.json | 9 ++ .../src/autocomplete_operators/index.ts | 21 +-- .../src/autocomplete_operators/types.ts | 19 +++ .../src/helpers/index.test.ts | 15 ++ .../src/helpers/index.ts | 53 ++++--- .../src/index.ts | 10 ++ .../src/types/index.ts | 17 ++- .../tsconfig.json | 19 +++ x-pack/plugins/lists/common/constants.mock.ts | 2 +- .../build_exceptions_filter.test.ts | 6 +- .../exceptions/build_exceptions_filter.ts | 3 +- .../lists/common/schemas/common/index.ts | 8 - .../common/schemas/common/schemas.test.ts | 139 ------------------ .../lists/common/schemas/common/schemas.ts | 91 ------------ x-pack/plugins/lists/common/schemas/index.ts | 10 -- .../create_exception_list_item_schema.mock.ts | 4 +- .../create_exception_list_schema.mock.ts | 4 +- .../request/create_list_item_schema.mock.ts | 4 +- .../request/create_list_schema.mock.ts | 4 +- .../delete_endpoint_list_item_schema.mock.ts | 14 -- .../delete_exception_list_item_schema.mock.ts | 15 -- .../delete_exception_list_schema.mock.ts | 15 -- .../request/delete_list_item_schema.mock.ts | 16 -- .../request/delete_list_schema.mock.ts | 16 -- ...export_exception_list_query_schema.mock.ts | 16 -- .../export_list_item_query_schema.mock.ts | 14 -- .../import_list_item_query_schema.mock.ts | 17 --- .../request/import_list_item_schema.mock.ts | 2 +- .../request/patch_list_item_schema.mock.ts | 16 -- .../read_endpoint_list_item_schema.mock.ts | 15 -- .../read_exception_list_item_schema.mock.ts | 16 -- .../read_exception_list_schema.mock.ts | 16 -- .../request/read_list_item_schema.mock.ts | 16 -- .../schemas/request/read_list_schema.mock.ts | 14 -- .../update_exception_list_item_schema.mock.ts | 4 +- .../update_exception_list_schema.mock.ts | 4 +- .../request/update_list_item_schema.mock.ts | 4 +- .../request/update_list_schema.mock.ts | 4 +- .../response/acknowledge_schema.mock.ts | 2 +- .../exception_list_item_schema.mock.ts | 4 +- .../response/exception_list_item_schema.ts | 56 ------- .../response/exception_list_schema.mock.ts | 4 +- .../schemas/response/exception_list_schema.ts | 54 ------- .../found_exception_list_item_schema.mock.ts | 3 +- .../found_exception_list_schema.mock.ts | 3 +- .../response/found_list_item_schema.mock.ts | 3 +- .../response/found_list_item_schema.ts | 24 --- .../response/found_list_schema.mock.ts | 3 +- .../schemas/response/found_list_schema.ts | 24 --- .../list_item_index_exist_schema.mock.ts | 2 +- .../schemas/response/list_item_schema.mock.ts | 3 +- .../schemas/response/list_item_schema.ts | 49 ------ .../schemas/response/list_schema.mock.ts | 3 +- .../common/schemas/response/list_schema.ts | 53 ------- .../response/search_list_item_schema.mock.ts | 3 +- .../common/schemas/types/comment.mock.ts | 2 +- .../schemas/types/create_comment.mock.ts | 2 +- .../common/schemas/types/entries.mock.ts | 2 +- .../common/schemas/types/entry_exists.mock.ts | 2 +- .../common/schemas/types/entry_list.mock.ts | 2 +- .../common/schemas/types/entry_match.mock.ts | 2 +- .../schemas/types/entry_match_any.mock.ts | 2 +- .../common/schemas/types/entry_nested.mock.ts | 2 +- .../schemas/types/update_comment.mock.ts | 2 +- x-pack/plugins/lists/common/shared_exports.ts | 9 -- x-pack/plugins/lists/public/exceptions/api.ts | 20 +-- .../autocomplete/field_value_lists.test.tsx | 2 +- .../autocomplete/field_value_lists.tsx | 2 +- .../components/autocomplete/helpers.test.ts | 16 +- .../components/autocomplete/helpers.ts | 11 +- .../components/autocomplete/operator.test.tsx | 2 +- .../builder/entry_delete_button.tsx | 3 +- .../builder/entry_renderer.test.tsx | 4 +- .../components/builder/entry_renderer.tsx | 25 ++-- .../builder/exception_item_renderer.tsx | 9 +- .../builder/exception_items_renderer.tsx | 25 ++-- .../components/builder/helpers.test.ts | 60 ++++---- .../exceptions/components/builder/reducer.ts | 14 +- .../hooks/persist_exception_item.ts | 6 +- .../hooks/persist_exception_list.ts | 2 +- .../lists/public/exceptions/hooks/use_api.ts | 10 +- .../hooks/use_exception_list_items.test.ts | 2 +- .../hooks/use_exception_list_items.ts | 2 +- .../hooks/use_exception_lists.test.ts | 2 +- .../exceptions/hooks/use_exception_lists.ts | 2 +- .../public/exceptions/transforms.test.ts | 12 +- .../lists/public/exceptions/transforms.ts | 6 +- .../plugins/lists/public/exceptions/types.ts | 9 +- .../plugins/lists/public/exceptions/utils.ts | 2 +- x-pack/plugins/lists/public/lists/api.ts | 4 +- x-pack/plugins/lists/public/lists/types.ts | 2 +- x-pack/plugins/lists/public/shared_exports.ts | 7 - .../routes/create_endpoint_list_item_route.ts | 8 +- .../routes/create_endpoint_list_route.ts | 2 +- .../create_exception_list_item_route.ts | 8 +- .../routes/create_exception_list_route.ts | 8 +- .../server/routes/create_list_index_route.ts | 2 +- .../server/routes/create_list_item_route.ts | 2 +- .../lists/server/routes/create_list_route.ts | 6 +- .../routes/delete_endpoint_list_item_route.ts | 8 +- .../delete_exception_list_item_route.ts | 8 +- .../routes/delete_exception_list_route.ts | 8 +- .../server/routes/delete_list_index_route.ts | 2 +- .../server/routes/delete_list_item_route.ts | 6 +- .../lists/server/routes/delete_list_route.ts | 10 +- .../routes/export_exception_list_route.ts | 2 +- .../server/routes/export_list_item_route.ts | 2 +- .../routes/find_endpoint_list_item_route.ts | 8 +- .../routes/find_exception_list_item_route.ts | 8 +- .../routes/find_exception_list_route.ts | 8 +- .../server/routes/find_list_item_route.ts | 8 +- .../lists/server/routes/find_list_route.ts | 2 +- .../server/routes/import_list_item_route.ts | 2 +- .../server/routes/patch_list_item_route.ts | 2 +- .../lists/server/routes/patch_list_route.ts | 2 +- .../routes/read_endpoint_list_item_route.ts | 8 +- .../routes/read_exception_list_item_route.ts | 8 +- .../routes/read_exception_list_route.ts | 8 +- .../server/routes/read_list_index_route.ts | 2 +- .../server/routes/read_list_item_route.ts | 6 +- .../lists/server/routes/read_list_route.ts | 2 +- .../routes/update_endpoint_list_item_route.ts | 8 +- .../update_exception_list_item_route.ts | 10 +- .../routes/update_exception_list_route.ts | 8 +- .../server/routes/update_list_item_route.ts | 2 +- .../lists/server/routes/update_list_route.ts | 2 +- .../plugins/lists/server/routes/validate.ts | 2 +- .../index_es_list_item_schema.ts | 10 +- .../elastic_query/index_es_list_schema.ts | 11 +- .../search_es_list_item_schema.ts | 10 +- .../elastic_response/search_es_list_schema.ts | 11 +- .../exceptions_list_so_schema.ts | 13 +- .../create_endoint_event_filters_list.ts | 2 +- .../exception_lists/create_endpoint_list.ts | 2 +- .../create_endpoint_trusted_apps_list.ts | 4 +- .../exception_lists/create_exception_list.ts | 6 +- .../create_exception_list_item.ts | 6 +- .../exception_lists/delete_exception_list.ts | 9 +- .../delete_exception_list_item.ts | 10 +- .../delete_exception_list_items_by_list.ts | 3 +- .../exception_lists/exception_list_client.ts | 8 +- .../exception_list_client_types.ts | 27 ++-- .../exception_lists/find_exception_list.ts | 10 +- .../find_exception_list_item.ts | 7 +- .../find_exception_list_items.ts | 19 +-- .../exception_lists/get_exception_list.ts | 8 +- .../get_exception_list_item.ts | 8 +- .../exception_lists/update_exception_list.ts | 10 +- .../update_exception_list_item.ts | 10 +- .../server/services/exception_lists/utils.ts | 10 +- .../server/services/items/create_list_item.ts | 8 +- .../services/items/create_list_items_bulk.ts | 8 +- .../server/services/items/delete_list_item.ts | 4 +- .../items/delete_list_item_by_value.ts | 3 +- .../server/services/items/find_list_item.ts | 6 +- .../server/services/items/get_list_item.ts | 3 +- .../services/items/get_list_item_by_value.ts | 4 +- .../services/items/get_list_item_by_values.ts | 3 +- .../items/search_list_item_by_values.test.ts | 2 +- .../items/search_list_item_by_values.ts | 3 +- .../services/items/update_list_item.test.ts | 2 +- .../server/services/items/update_list_item.ts | 8 +- .../items/write_lines_to_bulk_list_items.ts | 13 +- .../server/services/lists/create_list.test.ts | 2 +- .../server/services/lists/create_list.ts | 14 +- .../lists/create_list_if_it_does_not_exist.ts | 15 +- .../server/services/lists/delete_list.ts | 4 +- .../lists/server/services/lists/find_list.ts | 6 +- .../lists/server/services/lists/get_list.ts | 3 +- .../server/services/lists/list_client.ts | 6 +- .../services/lists/list_client_types.ts | 22 ++- .../server/services/lists/update_list.test.ts | 2 +- .../server/services/lists/update_list.ts | 5 +- .../services/utils/calculate_scroll_math.ts | 2 +- .../services/utils/encode_decode_cursor.ts | 6 +- .../services/utils/find_source_type.test.ts | 2 +- .../services/utils/find_source_value.ts | 3 +- .../utils/get_query_filter_from_type_value.ts | 2 +- .../services/utils/get_search_after_scroll.ts | 6 +- .../get_search_after_with_tie_breaker.ts | 3 +- .../utils/get_sort_with_tie_breaker.ts | 3 +- .../utils/get_source_with_tie_breaker.ts | 2 +- .../services/utils/scroll_to_start_page.ts | 6 +- ..._elastic_named_search_to_list_item.test.ts | 3 +- ...sform_elastic_named_search_to_list_item.ts | 3 +- .../utils/transform_elastic_to_list.ts | 2 +- .../transform_elastic_to_list_item.test.ts | 3 +- .../utils/transform_elastic_to_list_item.ts | 3 +- .../transform_list_item_to_elastic_query.ts | 3 +- .../detection_engine/get_query_filter.ts | 8 +- .../schemas/response/rules_schema.test.ts | 2 +- .../common/detection_engine/utils.ts | 7 +- .../data_generators/event_filter_generator.ts | 2 +- .../common/shared_imports.ts | 6 - .../autocomplete/field_value_lists.test.tsx | 2 +- .../autocomplete/field_value_lists.tsx | 3 +- .../components/autocomplete/helpers.test.ts | 4 +- .../common/components/autocomplete/helpers.ts | 9 +- .../components/autocomplete/operator.test.tsx | 2 +- .../components/autocomplete/operators.ts | 110 -------------- .../add_exception_modal/index.test.tsx | 3 +- .../exceptions/add_exception_modal/index.tsx | 11 +- .../edit_exception_modal/index.test.tsx | 2 +- .../exceptions/edit_exception_modal/index.tsx | 8 +- .../components/exceptions/error_callout.tsx | 2 +- .../components/exceptions/helpers.test.tsx | 2 +- .../common/components/exceptions/helpers.tsx | 13 +- .../common/components/exceptions/types.ts | 90 +----------- .../exceptions/use_add_exception.test.tsx | 3 +- .../exceptions/use_add_exception.tsx | 11 +- ...tch_or_create_rule_exception_list.test.tsx | 7 +- ...se_fetch_or_create_rule_exception_list.tsx | 13 +- .../exception_item/exception_details.tsx | 2 +- .../viewer/exception_item/index.tsx | 2 +- .../viewer/exceptions_viewer_items.tsx | 2 +- .../components/exceptions/viewer/helpers.tsx | 8 +- .../components/exceptions/viewer/index.tsx | 6 +- .../components/exceptions/viewer/reducer.ts | 11 +- .../value_lists_management_modal/form.tsx | 4 +- .../modal.test.tsx | 4 +- .../value_lists_management_modal/modal.tsx | 10 +- .../table_helpers.tsx | 2 +- .../value_lists_management_modal/types.ts | 2 +- .../rules/use_dissasociate_exception_list.tsx | 2 +- .../rules/all/exceptions/columns.tsx | 2 +- .../rules/all/exceptions/exceptions_table.tsx | 2 +- .../exceptions/use_all_exception_lists.tsx | 2 +- .../pages/detection_engine/rules/types.ts | 2 +- .../pages/event_filters/service/index.ts | 9 +- .../pages/event_filters/store/action.ts | 4 +- .../pages/event_filters/store/middleware.ts | 14 +- .../pages/event_filters/store/selector.ts | 6 +- .../pages/event_filters/store/utils.ts | 2 +- .../pages/event_filters/test_utils/index.ts | 11 +- .../management/pages/event_filters/types.ts | 6 +- .../view/components/flyout/index.test.tsx | 4 +- .../view/components/form/index.tsx | 3 +- .../view/components/modal/index.test.tsx | 4 +- .../view/event_filters_list_page.tsx | 2 +- .../pages/event_filters/view/translations.ts | 4 +- .../use_event_filters_notification.test.tsx | 5 +- .../public/shared_imports.ts | 5 - .../scripts/endpoint/event_filters/index.ts | 2 +- .../endpoint/lib/artifacts/lists.test.ts | 2 +- .../server/endpoint/lib/artifacts/lists.ts | 7 +- .../routes/trusted_apps/handlers.test.ts | 2 +- .../routes/trusted_apps/mapping.test.ts | 2 +- .../endpoint/routes/trusted_apps/mapping.ts | 3 +- .../routes/trusted_apps/service.test.ts | 2 +- .../endpoint/routes/trusted_apps/service.ts | 6 +- .../manifest_manager/manifest_manager.mock.ts | 2 +- .../lib/detection_engine/rules/types.ts | 6 +- .../lib/detection_engine/rules/utils.ts | 6 +- .../detection_engine/signals/executors/eql.ts | 2 +- .../detection_engine/signals/executors/ml.ts | 2 +- .../signals/executors/query.ts | 2 +- .../signals/executors/threat_match.ts | 2 +- .../signals/executors/threshold.ts | 2 +- .../create_field_and_set_tuples.test.ts | 2 +- .../filters/filter_events_against_list.ts | 3 +- .../detection_engine/signals/filters/types.ts | 3 +- .../signals/find_ml_signals.ts | 2 +- .../detection_engine/signals/get_filter.ts | 2 +- .../signals/search_after_bulk_create.test.ts | 2 +- .../signals/threat_mapping/types.ts | 4 +- .../lib/detection_engine/signals/types.ts | 2 +- .../lib/detection_engine/signals/utils.ts | 3 +- .../server/lib/detection_engine/types.ts | 2 +- .../server/lib/machine_learning/index.ts | 2 +- .../translations/translations/ja-JP.json | 16 -- .../translations/translations/zh-CN.json | 16 -- .../tests/create_exceptions.ts | 2 +- .../detection_engine_api_integration/utils.ts | 14 +- .../tests/create_exception_list_items.ts | 2 +- .../tests/create_exception_lists.ts | 2 +- .../tests/delete_exception_list_items.ts | 2 +- .../tests/delete_exception_lists.ts | 2 +- .../tests/export_list_items.ts | 2 +- .../tests/import_list_items.ts | 3 +- .../tests/read_exception_list_items.ts | 2 +- .../tests/read_exception_lists.ts | 2 +- .../tests/update_exception_list_items.ts | 8 +- .../tests/update_exception_lists.ts | 8 +- .../tests/update_list_items.ts | 10 +- .../security_and_spaces/tests/update_lists.ts | 2 +- x-pack/test/lists_api_integration/utils.ts | 10 +- yarn.lock | 7 + 531 files changed, 3374 insertions(+), 2300 deletions(-) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/comment/index.mock.ts (90%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/comment/index.test.ts (99%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/comment/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/create_comment/index.mock.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/create_comment/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/create_comment/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/created_at/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/created_by/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/cursor/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_comments_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_comments_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_create_comments_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_create_comments_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_namespace/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_namespace/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_namespace_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_namespace_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_update_comments_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/default_update_comments_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/description/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/deserializer/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entries/index.mock.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entries/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entries/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match/index.mock.ts (86%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match_any/index.mock.ts (86%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match_any/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match_any/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_match_wildcard/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_nested/index.mock.ts (92%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_nested/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/entry_nested/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/index.ts (75%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/endpoint/non_empty_nested_entries_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries/index.mock.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries_exist/index.mock.ts (89%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries_exist/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries_exist/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries_list/index.mock.ts (86%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries_list/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entries_list/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match/index.mock.ts (88%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match_any/index.mock.ts (89%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match_any/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match_any/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match_wildcard/index.mock.ts (89%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match_wildcard/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_match_wildcard/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_nested/index.mock.ts (94%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_nested/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/entry_nested/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.test.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/exception_list/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/exception_list_item_type/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/file/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/filter/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/id/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/immutable/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/item/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/item_id/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/list_id/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/list_operator/index.test.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/list_operator/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/list_type/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/lists/index.mock.ts (93%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/lists/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/lists/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/lists_default_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/lists_default_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/meta/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/name/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/namespace_type/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/non_empty_entries_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/non_empty_entries_array/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/non_empty_nested_entries_array/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/non_empty_nested_entries_array/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/os_type/index.test.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/os_type/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/page/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/per_page/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/required_keep_undefined/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/serializer/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/sort_field/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/sort_order/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/tags/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/tie_breaker_id/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/total/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/type/index.test.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/type/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/underscore_version/index.ts rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/update_comment/index.mock.ts (92%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/update_comment/index.test.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/update_comment/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/updated_at/index.ts (100%) rename packages/kbn-securitysolution-io-ts-list-types/src/{ => common}/updated_by/index.ts (100%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/common/value/index.ts rename x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.mock.ts (66%) rename x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.test.ts (94%) rename x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.ts (58%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.test.ts (94%) rename x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.ts (56%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.test.ts (91%) rename x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.ts (64%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/create_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.test.ts (86%) rename x-pack/plugins/lists/common/schemas/request/create_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.ts (55%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/create_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.test.ts (90%) rename x-pack/plugins/lists/common/schemas/request/create_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.ts (63%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.test.ts (85%) rename x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.ts (62%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.ts (60%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.ts (59%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.test.ts (80%) rename x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.ts (57%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/delete_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/request/delete_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.ts (69%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.test.ts (89%) rename x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.ts (57%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.ts (62%) rename x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.mock.ts (63%) rename x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.ts (70%) rename x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.mock.ts (83%) rename x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.test.ts (95%) rename x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.ts (78%) rename x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.mock.ts (64%) rename x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.test.ts (95%) rename x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.ts (68%) rename x-pack/plugins/lists/common/schemas/request/find_list_item_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.mock.ts (71%) rename x-pack/plugins/lists/common/schemas/request/find_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.test.ts (90%) rename x-pack/plugins/lists/common/schemas/request/find_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.ts (68%) rename x-pack/plugins/lists/common/schemas/request/find_list_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.mock.ts (63%) rename x-pack/plugins/lists/common/schemas/request/find_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/request/find_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.ts (66%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.test.ts (91%) rename x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.ts (52%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/import_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/request/import_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.ts (59%) rename {x-pack/plugins/lists/common/schemas => packages/kbn-securitysolution-io-ts-list-types/src}/request/index.ts (86%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.test.ts (90%) rename x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.ts (53%) rename x-pack/plugins/lists/common/schemas/request/patch_list_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.mock.ts (60%) rename x-pack/plugins/lists/common/schemas/request/patch_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/request/patch_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.ts (62%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.test.ts (90%) rename x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.ts (62%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.ts (60%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.test.ts (94%) rename x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.ts (59%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/read_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/request/read_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.ts (52%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/read_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.test.ts (85%) rename x-pack/plugins/lists/common/schemas/request/read_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.ts (58%) rename x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.mock.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.mock.ts (68%) rename x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.test.ts (94%) rename x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.ts (58%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.test.ts (95%) rename x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.ts (57%) rename x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.test.ts (80%) rename x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.ts (75%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.ts (62%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/update_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.test.ts (85%) rename x-pack/plugins/lists/common/schemas/request/update_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.ts (59%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/request/update_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.test.ts (85%) rename x-pack/plugins/lists/common/schemas/request/update_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.ts (60%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/acknowledge_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/response/acknowledge_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.ts (64%) rename x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.test.ts (91%) rename x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.ts (59%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.test.ts (97%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.test.ts (95%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.test.ts (92%) rename x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.ts (52%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.test.ts (93%) rename x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.ts (52%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.mock.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.mock.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.ts rename {x-pack/plugins/lists/common/schemas => packages/kbn-securitysolution-io-ts-list-types/src}/response/index.ts (78%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.test.ts (90%) rename x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.ts (68%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.test.ts (95%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/list_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.test.ts (95%) create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.ts create mode 100644 packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.mock.ts rename x-pack/plugins/lists/common/schemas/response/search_list_item_schema.test.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.test.ts (84%) rename x-pack/plugins/lists/common/schemas/response/search_list_item_schema.ts => packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.ts (76%) create mode 100644 packages/kbn-securitysolution-list-utils/BUILD.bazel create mode 100644 packages/kbn-securitysolution-list-utils/README.md create mode 100644 packages/kbn-securitysolution-list-utils/jest.config.js create mode 100644 packages/kbn-securitysolution-list-utils/package.json rename x-pack/plugins/lists/public/exceptions/components/autocomplete/operators.ts => packages/kbn-securitysolution-list-utils/src/autocomplete_operators/index.ts (76%) create mode 100644 packages/kbn-securitysolution-list-utils/src/autocomplete_operators/types.ts create mode 100644 packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts rename x-pack/plugins/lists/public/exceptions/components/builder/helpers.ts => packages/kbn-securitysolution-list-utils/src/helpers/index.ts (94%) create mode 100644 packages/kbn-securitysolution-list-utils/src/index.ts rename x-pack/plugins/lists/public/exceptions/components/builder/types.ts => packages/kbn-securitysolution-list-utils/src/types/index.ts (81%) create mode 100644 packages/kbn-securitysolution-list-utils/tsconfig.json delete mode 100644 x-pack/plugins/lists/common/schemas/common/index.ts delete mode 100644 x-pack/plugins/lists/common/schemas/common/schemas.test.ts delete mode 100644 x-pack/plugins/lists/common/schemas/common/schemas.ts delete mode 100644 x-pack/plugins/lists/common/schemas/index.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/delete_list_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/read_list_item_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/request/read_list_schema.mock.ts delete mode 100644 x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.ts delete mode 100644 x-pack/plugins/lists/common/schemas/response/exception_list_schema.ts delete mode 100644 x-pack/plugins/lists/common/schemas/response/found_list_item_schema.ts delete mode 100644 x-pack/plugins/lists/common/schemas/response/found_list_schema.ts delete mode 100644 x-pack/plugins/lists/common/schemas/response/list_item_schema.ts delete mode 100644 x-pack/plugins/lists/common/schemas/response/list_schema.ts delete mode 100644 x-pack/plugins/security_solution/public/common/components/autocomplete/operators.ts diff --git a/.i18nrc.json b/.i18nrc.json index efbb5ecc0194e..1e07d662c057a 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -22,10 +22,8 @@ "interpreter": "src/legacy/core_plugins/interpreter", "kbn": "src/legacy/core_plugins/kibana", "kbnDocViews": "src/legacy/core_plugins/kbn_doc_views", - "management": [ - "src/legacy/core_plugins/management", - "src/plugins/management" - ], + "lists": "packages/kbn-securitysolution-list-utils/src", + "management": ["src/legacy/core_plugins/management", "src/plugins/management"], "maps_legacy": "src/plugins/maps_legacy", "monaco": "packages/kbn-monaco/src", "presentationUtil": "src/plugins/presentation_util", @@ -45,10 +43,7 @@ "security": "src/plugins/security_oss", "server": "src/legacy/server", "statusPage": "src/legacy/core_plugins/status_page", - "telemetry": [ - "src/plugins/telemetry", - "src/plugins/telemetry_management_section" - ], + "telemetry": ["src/plugins/telemetry", "src/plugins/telemetry_management_section"], "tileMap": "src/plugins/tile_map", "timelion": ["src/plugins/timelion", "src/plugins/vis_type_timelion"], "uiActions": "src/plugins/ui_actions", @@ -66,8 +61,6 @@ "apmOss": "src/plugins/apm_oss", "usageCollection": "src/plugins/usage_collection" }, - "exclude": [ - "src/legacy/ui/ui_render/ui_render_mixin.js" - ], + "exclude": ["src/legacy/ui/ui_render/ui_render_mixin.js"], "translations": [] } diff --git a/docs/developer/getting-started/monorepo-packages.asciidoc b/docs/developer/getting-started/monorepo-packages.asciidoc index e81875d7893dd..a98aa7aa9cd56 100644 --- a/docs/developer/getting-started/monorepo-packages.asciidoc +++ b/docs/developer/getting-started/monorepo-packages.asciidoc @@ -88,6 +88,7 @@ yarn kbn watch-bazel - kbn/securitysolution-io-ts-list-types - kbn/securitysolution-io-ts-types - @kbn/securitysolution-io-ts-utils +- @kbn/securitysolution-list-utils - @kbn/securitysolution-utils - @kbn/server-http-tools - @kbn/std diff --git a/package.json b/package.json index 07c6087579e79..ba1be68bbcc65 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "@kbn/securitysolution-io-ts-alerting-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types/npm_module", "@kbn/securitysolution-io-ts-list-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-list-types/npm_module", "@kbn/securitysolution-io-ts-utils": "link:bazel-bin/packages/kbn-securitysolution-io-ts-utils/npm_module", + "@kbn/securitysolution-list-utils": "link:bazel-bin/packages/kbn-securitysolution-list-utils/npm_module", "@kbn/securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils/npm_module", "@kbn/server-http-tools": "link:bazel-bin/packages/kbn-server-http-tools/npm_module", "@kbn/server-route-repository": "link:packages/kbn-server-route-repository", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 76250d8a1e864..e400567a28e9b 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -26,6 +26,7 @@ filegroup( "//packages/kbn-logging:build", "//packages/kbn-plugin-generator:build", "//packages/kbn-securitysolution-constants:build", + "//packages/kbn-securitysolution-list-utils:build", "//packages/kbn-securitysolution-io-ts-types:build", "//packages/kbn-securitysolution-io-ts-alerting-types:build", "//packages/kbn-securitysolution-io-ts-list-types:build", diff --git a/packages/kbn-securitysolution-io-ts-list-types/BUILD.bazel b/packages/kbn-securitysolution-io-ts-list-types/BUILD.bazel index e9b806288addd..af8fb6838a5c1 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/BUILD.bazel +++ b/packages/kbn-securitysolution-io-ts-list-types/BUILD.bazel @@ -2,7 +2,7 @@ load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") PKG_BASE_NAME = "kbn-securitysolution-io-ts-list-types" -PKG_REQUIRE_NAME = "@kbn/securitysolution-io-list-types" +PKG_REQUIRE_NAME = "@kbn/securitysolution-io-ts-list-types" SOURCE_FILES = glob( [ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/comment/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.mock.ts similarity index 90% rename from packages/kbn-securitysolution-io-ts-list-types/src/comment/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.mock.ts index 380f7f13b6210..56440d628e4aa 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/comment/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.mock.ts @@ -7,7 +7,7 @@ */ import { Comment, CommentsArray } from '.'; -import { DATE_NOW, ID, USER } from '../constants/index.mock'; +import { DATE_NOW, ID, USER } from '../../constants/index.mock'; export const getCommentsMock = (): Comment => ({ comment: 'some old comment', diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/comment/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.test.ts similarity index 99% rename from packages/kbn-securitysolution-io-ts-list-types/src/comment/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.test.ts index 89e734a92fd04..4af9be0a7f0e6 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/comment/index.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.test.ts @@ -18,7 +18,7 @@ import { commentsArrayOrUndefined, } from '.'; import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { DATE_NOW } from '../constants/index.mock'; +import { DATE_NOW } from '../../constants/index.mock'; describe('Comment', () => { describe('comment', () => { diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/comment/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/comment/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/comment/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/create_comment/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/create_comment/index.mock.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/create_comment/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/create_comment/index.mock.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/create_comment/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/create_comment/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/create_comment/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/create_comment/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/create_comment/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/create_comment/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/create_comment/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/create_comment/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/created_at/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/created_at/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/created_at/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/created_at/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/created_by/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/created_by/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/created_by/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/created_by/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/cursor/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/cursor/index.ts new file mode 100644 index 0000000000000..7d62ea2188a3e --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/cursor/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import * as t from 'io-ts'; + +export const cursor = t.string; +export type Cursor = t.TypeOf; +export const cursorOrUndefined = t.union([cursor, t.undefined]); +export type CursorOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_comments_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_comments_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_comments_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_comments_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_comments_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_comments_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_comments_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_comments_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_create_comments_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_create_comments_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_create_comments_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_create_comments_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_create_comments_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_create_comments_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_create_comments_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_create_comments_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_namespace/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_namespace/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_namespace/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_namespace/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_namespace_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_namespace_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_namespace_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_namespace_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_namespace_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_update_comments_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_update_comments_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_update_comments_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_update_comments_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/default_update_comments_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/default_update_comments_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/default_update_comments_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/default_update_comments_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/description/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/description/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/description/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/description/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/deserializer/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/deserializer/index.ts new file mode 100644 index 0000000000000..903c4c9eadc0f --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/deserializer/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const deserializer = t.string; +export type Deserializer = t.TypeOf; +export const deserializerOrUndefined = t.union([deserializer, t.undefined]); +export type DeserializerOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entries/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entries/index.mock.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entries/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entries/index.mock.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entries/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entries/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entries/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entries/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entries/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entries/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entries/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entries/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.mock.ts similarity index 86% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.mock.ts index 17a1a083d73d8..7104406c4869c 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.mock.ts @@ -7,7 +7,7 @@ */ import { EndpointEntryMatch } from '.'; -import { ENTRY_VALUE, FIELD, MATCH, OPERATOR } from '../../constants/index.mock'; +import { ENTRY_VALUE, FIELD, MATCH, OPERATOR } from '../../../constants/index.mock'; export const getEndpointEntryMatchMock = (): EndpointEntryMatch => ({ field: FIELD, diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.mock.ts similarity index 86% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.mock.ts index 13fb16d73457d..95bd6008f1d7c 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.mock.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { ENTRY_VALUE, FIELD, MATCH_ANY, OPERATOR } from '../../constants/index.mock'; +import { ENTRY_VALUE, FIELD, MATCH_ANY, OPERATOR } from '../../../constants/index.mock'; import { EndpointEntryMatchAny } from '.'; export const getEndpointEntryMatchAnyMock = (): EndpointEntryMatchAny => ({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_any/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_any/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_wildcard/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_wildcard/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_match_wildcard/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_match_wildcard/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.mock.ts similarity index 92% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.mock.ts index 31d983ba58fe3..f59e29c8ce526 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.mock.ts @@ -7,7 +7,7 @@ */ import { EndpointEntryNested } from '.'; -import { FIELD, NESTED } from '../../constants/index.mock'; +import { FIELD, NESTED } from '../../../constants/index.mock'; import { getEndpointEntryMatchMock } from '../entry_match/index.mock'; import { getEndpointEntryMatchAnyMock } from '../entry_match_any/index.mock'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/entry_nested/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/entry_nested/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/index.ts similarity index 75% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/index.ts index 212b5de1470ff..60fafa6193f1f 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/index.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/index.ts @@ -6,8 +6,4 @@ * Side Public License, v 1. */ export * from './entries'; -export * from './entry_match'; -export * from './entry_match_any'; -export * from './entry_match_wildcard'; -export * from './entry_nested'; export * from './non_empty_nested_entries_array'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/endpoint/non_empty_nested_entries_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/non_empty_nested_entries_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/endpoint/non_empty_nested_entries_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/endpoint/non_empty_nested_entries_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries/index.mock.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries/index.mock.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.mock.ts similarity index 89% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.mock.ts index ad2164a3862eb..0882883f4d239 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.mock.ts @@ -7,7 +7,7 @@ */ import { EntryExists } from '.'; -import { EXISTS, FIELD, OPERATOR } from '../constants/index.mock'; +import { EXISTS, FIELD, OPERATOR } from '../../constants/index.mock'; export const getEntryExistsMock = (): EntryExists => ({ field: FIELD, diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries_exist/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries_exist/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.mock.ts similarity index 86% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.mock.ts index 2349b9d5ab2b3..c4afb28f5ac54 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.mock.ts @@ -7,7 +7,7 @@ */ import { EntryList } from '.'; -import { FIELD, LIST, LIST_ID, OPERATOR, TYPE } from '../constants/index.mock'; +import { FIELD, LIST, LIST_ID, OPERATOR, TYPE } from '../../constants/index.mock'; export const getEntryListMock = (): EntryList => ({ field: FIELD, diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entries_list/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entries_list/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.mock.ts similarity index 88% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.mock.ts index 38c9f0f922c46..4fdd8d915fe04 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.mock.ts @@ -7,7 +7,7 @@ */ import { EntryMatch } from '.'; -import { ENTRY_VALUE, FIELD, MATCH, OPERATOR } from '../constants/index.mock'; +import { ENTRY_VALUE, FIELD, MATCH, OPERATOR } from '../../constants/index.mock'; export const getEntryMatchMock = (): EntryMatch => ({ field: FIELD, diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.mock.ts similarity index 89% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.mock.ts index efaf23fe1e784..0022b00c604b0 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.mock.ts @@ -7,7 +7,7 @@ */ import { EntryMatchAny } from '.'; -import { ENTRY_VALUE, FIELD, MATCH_ANY, OPERATOR } from '../constants/index.mock'; +import { ENTRY_VALUE, FIELD, MATCH_ANY, OPERATOR } from '../../constants/index.mock'; export const getEntryMatchAnyMock = (): EntryMatchAny => ({ field: FIELD, diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match_any/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_any/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.mock.ts similarity index 89% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.mock.ts index f81a8c6cba2ef..9810fe5e9875b 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.mock.ts @@ -7,7 +7,7 @@ */ import { EntryMatchWildcard } from '.'; -import { ENTRY_VALUE, FIELD, OPERATOR, WILDCARD } from '../constants/index.mock'; +import { ENTRY_VALUE, FIELD, OPERATOR, WILDCARD } from '../../constants/index.mock'; export const getEntryMatchWildcardMock = (): EntryMatchWildcard => ({ field: FIELD, diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_match_wildcard/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_match_wildcard/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.mock.ts similarity index 94% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.mock.ts index 05f42cdf69bc0..acde4443cccb7 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.mock.ts @@ -7,7 +7,7 @@ */ import { EntryNested } from '.'; -import { NESTED, NESTED_FIELD } from '../constants/index.mock'; +import { NESTED, NESTED_FIELD } from '../../constants/index.mock'; import { getEntryExistsMock } from '../entries_exist/index.mock'; import { getEntryMatchExcludeMock, getEntryMatchMock } from '../entry_match/index.mock'; import { getEntryMatchAnyExcludeMock, getEntryMatchAnyMock } from '../entry_match_any/index.mock'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/entry_nested/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/entry_nested/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.test.ts new file mode 100644 index 0000000000000..f69c172c9b7fe --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.test.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { exceptionListType, ExceptionListTypeEnum } from '.'; + +import { pipe } from 'fp-ts/lib/pipeable'; +import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; + +describe('exceptionListType', () => { + test('it should validate for "detection"', () => { + const payload = 'detection'; + const decoded = exceptionListType.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it should validate for "endpoint"', () => { + const payload = 'endpoint'; + const decoded = exceptionListType.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it should contain same amount of keys as enum', () => { + // Might seem like a weird test, but its meant to + // ensure that if exceptionListType is updated, you + // also update the ExceptionListTypeEnum, a workaround + // for io-ts not yet supporting enums + // https://github.com/gcanti/io-ts/issues/67 + const keys = Object.keys(exceptionListType.keys).sort().join(',').toLowerCase(); + const enumKeys = Object.keys(ExceptionListTypeEnum).sort().join(',').toLowerCase(); + + expect(keys).toEqual(enumKeys); + }); +}); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/exception_list/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/exception_list/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/exception_list_item_type/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list_item_type/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/exception_list_item_type/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/exception_list_item_type/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/file/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/file/index.ts new file mode 100644 index 0000000000000..a8118756e5850 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/file/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import * as t from 'io-ts'; + +export const file = t.object; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/filter/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/filter/index.ts new file mode 100644 index 0000000000000..11d06a95b0bc2 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/filter/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const filter = t.string; +export type Filter = t.TypeOf; +export const filterOrUndefined = t.union([filter, t.undefined]); +export type FilterOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/id/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/id/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/id/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/id/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/immutable/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/immutable/index.ts new file mode 100644 index 0000000000000..a8243906d9e3d --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/immutable/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const immutable = t.boolean; +export type Immutable = t.TypeOf; +export const immutableOrUndefined = t.union([immutable, t.undefined]); +export type ImmutableOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/index.ts new file mode 100644 index 0000000000000..723b2ce201231 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/index.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export * from './comment'; +export * from './create_comment'; +export * from './created_at'; +export * from './created_by'; +export * from './cursor'; +export * from './default_namespace'; +export * from './default_namespace_array'; +export * from './description'; +export * from './deserializer'; +export * from './endpoint'; +export * from './entries'; +export * from './entries_exist'; +export * from './entries_list'; +export * from './entry_match'; +export * from './entry_match_any'; +export * from './entry_match_wildcard'; +export * from './entry_nested'; +export * from './exception_list'; +export * from './exception_list_item_type'; +export * from './filter'; +export * from './id'; +export * from './immutable'; +export * from './item_id'; +export * from './list_id'; +export * from './list_operator'; +export * from './list_type'; +export * from './lists'; +export * from './lists_default_array'; +export * from './meta'; +export * from './name'; +export * from './non_empty_entries_array'; +export * from './non_empty_nested_entries_array'; +export * from './os_type'; +export * from './page'; +export * from './per_page'; +export * from './serializer'; +export * from './sort_field'; +export * from './sort_order'; +export * from './tags'; +export * from './tie_breaker_id'; +export * from './total'; +export * from './type'; +export * from './underscore_version'; +export * from './update_comment'; +export * from './updated_at'; +export * from './updated_by'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/item/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/item/index.ts new file mode 100644 index 0000000000000..d00054b2860af --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/item/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const item = t.string; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/item_id/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/item_id/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/item_id/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/item_id/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/list_id/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_id/index.ts new file mode 100644 index 0000000000000..6e6c0917fc156 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_id/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import * as t from 'io-ts'; +import { NonEmptyString } from '@kbn/securitysolution-io-ts-types'; + +export const list_id = NonEmptyString; +export type ListId = t.TypeOf; +export const list_idOrUndefined = t.union([list_id, t.undefined]); +export type ListIdOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/list_operator/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_operator/index.test.ts new file mode 100644 index 0000000000000..441d62f842153 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_operator/index.test.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { pipe } from 'fp-ts/lib/pipeable'; +import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; + +import { ListOperatorEnum as OperatorEnum, listOperator as operator } from '.'; + +describe('operator', () => { + test('it should validate for "included"', () => { + const payload = 'included'; + const decoded = operator.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it should validate for "excluded"', () => { + const payload = 'excluded'; + const decoded = operator.decode(payload); + const message = pipe(decoded, foldLeftRight); + + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it should contain same amount of keys as enum', () => { + // Might seem like a weird test, but its meant to + // ensure that if operator is updated, you + // also update the operatorEnum, a workaround + // for io-ts not yet supporting enums + // https://github.com/gcanti/io-ts/issues/67 + const keys = Object.keys(operator.keys).sort().join(',').toLowerCase(); + const enumKeys = Object.keys(OperatorEnum).sort().join(',').toLowerCase(); + + expect(keys).toEqual(enumKeys); + }); +}); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/list_operator/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_operator/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/list_operator/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/list_operator/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/list_type/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_type/index.ts new file mode 100644 index 0000000000000..a3ee9b39fc25c --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/list_type/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import * as t from 'io-ts'; + +export const list_type = t.keyof({ item: null, list: null }); +export type ListType = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/lists/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.mock.ts similarity index 93% rename from packages/kbn-securitysolution-io-ts-list-types/src/lists/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.mock.ts index e9f34c4cf789f..c6f54b57d937b 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/lists/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.mock.ts @@ -7,7 +7,7 @@ */ import { List, ListArray } from '.'; -import { ENDPOINT_LIST_ID } from '../constants'; +import { ENDPOINT_LIST_ID } from '../../constants'; export const getListMock = (): List => ({ id: 'some_uuid', diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/lists/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/lists/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/lists/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/lists/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/lists/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/lists_default_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/lists_default_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/lists_default_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/lists_default_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/lists_default_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/lists_default_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/lists_default_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/lists_default_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/meta/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/meta/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/meta/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/meta/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/name/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/name/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/name/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/name/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/namespace_type/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/namespace_type/index.ts new file mode 100644 index 0000000000000..b3929f4df8047 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/namespace_type/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import { DefaultNamespace } from '../default_namespace'; + +export const namespace_type = DefaultNamespace; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/non_empty_entries_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_entries_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/non_empty_entries_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_entries_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/non_empty_entries_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_entries_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/non_empty_entries_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_entries_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/non_empty_nested_entries_array/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_nested_entries_array/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/non_empty_nested_entries_array/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_nested_entries_array/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/non_empty_nested_entries_array/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_nested_entries_array/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/non_empty_nested_entries_array/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/non_empty_nested_entries_array/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/os_type/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/os_type/index.test.ts new file mode 100644 index 0000000000000..9e5e56fa00f1a --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/os_type/index.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { exactCheck } from '@kbn/securitysolution-io-ts-utils'; +import { osType, osTypeArrayOrUndefined } from '.'; + +import { pipe } from 'fp-ts/lib/pipeable'; +import { left } from 'fp-ts/lib/Either'; + +import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; + +describe('osType', () => { + test('it will validate a correct osType', () => { + const payload = 'windows'; + const decoded = osType.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it will fail to validate an incorrect osType', () => { + const payload = 'foo'; + const decoded = osType.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "foo" supplied to ""linux" | "macos" | "windows""', + ]); + expect(message.schema).toEqual({}); + }); + + test('it will default to an empty array when osTypeArrayOrUndefined is used', () => { + const payload = undefined; + const decoded = osTypeArrayOrUndefined.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual([]); + }); +}); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/os_type/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/os_type/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/os_type/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/os_type/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/page/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/page/index.ts new file mode 100644 index 0000000000000..a4b7f44de1df4 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/page/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const page = t.number; // TODO: Change this out for PositiveNumber from siem +export type Page = t.TypeOf; + +export const pageOrUndefined = t.union([page, t.undefined]); +export type PageOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/per_page/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/per_page/index.ts new file mode 100644 index 0000000000000..53f9e310fcf5b --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/per_page/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import * as t from 'io-ts'; + +export const per_page = t.number; // TODO: Change this out for PositiveNumber from siem +export type PerPage = t.TypeOf; + +export const perPageOrUndefined = t.union([per_page, t.undefined]); +export type PerPageOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/required_keep_undefined/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/required_keep_undefined/index.ts new file mode 100644 index 0000000000000..de461c3043e5c --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/required_keep_undefined/index.ts @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/** + * This makes any optional property the same as Required would but also has the + * added benefit of keeping your undefined. + * + * For example: + * type A = RequiredKeepUndefined<{ a?: undefined; b: number }>; + * + * will yield a type of: + * type A = { a: undefined; b: number; } + * @deprecated This has no replacement. We should stop using/relying on this and just remove it. + */ +export type RequiredKeepUndefined = { [K in keyof T]-?: [T[K]] } extends infer U + ? U extends Record + ? { [K in keyof U]: U[K][0] } + : never + : never; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/serializer/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/serializer/index.ts new file mode 100644 index 0000000000000..4404d9b7a6a93 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/serializer/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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const serializer = t.string; +export type Serializer = t.TypeOf; +export const serializerOrUndefined = t.union([serializer, t.undefined]); +export type SerializerOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/sort_field/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/sort_field/index.ts new file mode 100644 index 0000000000000..c92a4f9ceb978 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/sort_field/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import * as t from 'io-ts'; + +export const sort_field = t.string; +export const sortFieldOrUndefined = t.union([sort_field, t.undefined]); +export type SortFieldOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/sort_order/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/sort_order/index.ts new file mode 100644 index 0000000000000..6ccc126680e80 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/sort_order/index.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import * as t from 'io-ts'; + +export const sort_order = t.keyof({ asc: null, desc: null }); +export const sortOrderOrUndefined = t.union([sort_order, t.undefined]); +export type SortOrderOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/tags/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/tags/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/tags/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/tags/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/tie_breaker_id/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/tie_breaker_id/index.ts new file mode 100644 index 0000000000000..041b59d131e6b --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/tie_breaker_id/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/* eslint-disable @typescript-eslint/naming-convention */ + +import * as t from 'io-ts'; + +export const tie_breaker_id = t.string; // TODO: Use UUID for this instead of a string for validation diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/total/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/total/index.ts new file mode 100644 index 0000000000000..9382af486f01d --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/total/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const total = t.number; // TODO: Change this out for PositiveNumber from siem +export const totalUndefined = t.union([total, t.undefined]); +export type TotalOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/type/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/type/index.test.ts new file mode 100644 index 0000000000000..951611539f9cd --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/type/index.test.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { pipe } from 'fp-ts/lib/pipeable'; +import { left } from 'fp-ts/lib/Either'; +import { Type, type } from '.'; +import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; + +describe('type', () => { + test('it will work with a given expected type', () => { + const payload: Type = 'keyword'; + const decoded = type.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([]); + expect(message.schema).toEqual(payload); + }); + + test('it will give an error if given a type that does not exist', () => { + const payload: Type | 'madeup' = 'madeup'; + const decoded = type.decode(payload); + const checked = exactCheck(payload, decoded); + const message = pipe(checked, foldLeftRight); + expect(getPaths(left(message.errors))).toEqual([ + 'Invalid value "madeup" supplied to ""binary" | "boolean" | "byte" | "date" | "date_nanos" | "date_range" | "double" | "double_range" | "float" | "float_range" | "geo_point" | "geo_shape" | "half_float" | "integer" | "integer_range" | "ip" | "ip_range" | "keyword" | "long" | "long_range" | "shape" | "short" | "text""', + ]); + expect(message.schema).toEqual({}); + }); +}); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/type/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/type/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/type/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/type/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/underscore_version/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/underscore_version/index.ts new file mode 100644 index 0000000000000..8a580a1ebeb5a --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/underscore_version/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const _version = t.string; +export const _versionOrUndefined = t.union([_version, t.undefined]); +export type _VersionOrUndefined = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.mock.ts similarity index 92% rename from packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.mock.ts index e9a56119dcc20..3b5cb256b28bf 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.mock.ts @@ -7,7 +7,7 @@ */ import { UpdateComment, UpdateCommentsArray } from '.'; -import { ID } from '../constants/index.mock'; +import { ID } from '../../constants/index.mock'; export const getUpdateCommentMock = (): UpdateComment => ({ comment: 'some comment', diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.test.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.test.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/update_comment/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/update_comment/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/updated_at/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/updated_at/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/updated_at/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/updated_at/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/updated_by/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/updated_by/index.ts similarity index 100% rename from packages/kbn-securitysolution-io-ts-list-types/src/updated_by/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/common/updated_by/index.ts diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/common/value/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/common/value/index.ts new file mode 100644 index 0000000000000..e0a82a3d11e72 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/common/value/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +export const value = t.string; +export const valueOrUndefined = t.union([value, t.undefined]); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.mock.ts index d2107ae864f15..46d9c4c8f68e2 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.mock.ts @@ -5,20 +5,110 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -export const ENTRY_VALUE = 'some host name'; -export const FIELD = 'host.name'; -export const MATCH = 'match'; -export const MATCH_ANY = 'match_any'; -export const OPERATOR = 'included'; -export const NESTED = 'nested'; -export const NESTED_FIELD = 'parent.field'; + +import { EndpointEntriesArray } from '../common/endpoint/entries'; +import { EntriesArray, Entry } from '../common/entries'; +import { EntryMatch } from '../common/entry_match'; +import { EntryNested } from '../common/entry_nested'; +import { OsTypeArray } from '../common/os_type'; + +export const DATE_NOW = '2020-04-20T15:25:31.830Z'; +export const OLD_DATE_RELATIVE_TO_DATE_NOW = '2020-04-19T15:25:31.830Z'; +export const USER = 'some user'; +export const ELASTIC_USER = 'elastic'; +export const LIST_INDEX = '.lists'; +export const LIST_ITEM_INDEX = '.items'; +export const NAME = 'some name'; +export const DESCRIPTION = 'some description'; export const LIST_ID = 'some-list-id'; -export const LIST = 'list'; +export const LIST_ITEM_ID = 'some-list-item-id'; +export const TIE_BREAKER = '6a76b69d-80df-4ab2-8c3e-85f466b06a0e'; +export const TIE_BREAKERS = [ + '21530991-4051-46ec-bc35-2afa09a1b0b5', + '3c662054-ae37-4aa9-9936-3e8e2ea26775', + '60e49a20-3a23-48b6-8bf9-ed5e3b70f7a0', + '38814080-a40f-4358-992a-3b875f9b7dec', + '29fa61be-aaaf-411c-a78a-7059e3f723f1', + '9c19c959-cb9d-4cd2-99e4-1ea2baf0ef0e', + 'd409308c-f94b-4b3a-8234-bbd7a80c9140', + '87824c99-cd83-45c4-8aa6-4ad95dfea62c', + '7b940c17-9355-479f-b882-f3e575718f79', + '5983ad0c-4ef4-4fa0-8308-80ab9ecc4f74', +]; +export const META = {}; export const TYPE = 'ip'; -export const EXISTS = 'exists'; -export const WILDCARD = 'wildcard'; -export const USER = 'some user'; -export const DATE_NOW = '2020-04-20T15:25:31.830Z'; +export const VALUE = '127.0.0.1'; +export const VALUE_2 = '255.255.255'; +export const NAMESPACE_TYPE = 'single'; +export const NESTED_FIELD = 'parent.field'; // Exception List specific export const ID = 'uuid_here'; +export const ITEM_ID = 'some-list-item-id'; +export const DETECTION_TYPE = 'detection'; +export const ENDPOINT_TYPE = 'endpoint'; +export const FIELD = 'host.name'; +export const OPERATOR = 'included'; +export const OPERATOR_EXCLUDED = 'excluded'; +export const ENTRY_VALUE = 'some host name'; +export const MATCH = 'match'; +export const MATCH_ANY = 'match_any'; +export const WILDCARD = 'wildcard'; +export const MAX_IMPORT_PAYLOAD_BYTES = 9000000; +export const IMPORT_BUFFER_SIZE = 1000; +export const LIST = 'list'; +export const EXISTS = 'exists'; +export const NESTED = 'nested'; +export const ENTRIES: EntriesArray = [ + { + entries: [{ field: 'nested.field', operator: 'included', type: 'match', value: 'some value' }], + field: 'some.parentField', + type: 'nested', + }, + { field: 'some.not.nested.field', operator: 'included', type: 'match', value: 'some value' }, +]; +export const ENDPOINT_ENTRIES: EndpointEntriesArray = [ + { + entries: [{ field: 'nested.field', operator: 'included', type: 'match', value: 'some value' }], + field: 'some.parentField', + type: 'nested', + }, + { field: 'some.not.nested.field', operator: 'included', type: 'match', value: 'some value' }, +]; +// ENTRIES_WITH_IDS should only be used to mock out functionality of a collection of transforms +// that are UI specific and useful for UI concerns that are inserted between the +// API and the actual user interface. In some ways these might be viewed as +// technical debt or to compensate for the differences and preferences +// of how ReactJS might prefer data vs. how we want to model data. +export const ENTRIES_WITH_IDS: EntriesArray = [ + { + entries: [ + { + field: 'nested.field', + id: '123', + operator: 'included', + type: 'match', + value: 'some value', + } as EntryMatch & { id: string }, + ], + field: 'some.parentField', + id: '123', + type: 'nested', + } as EntryNested & { id: string }, + { + field: 'some.not.nested.field', + id: '123', + operator: 'included', + type: 'match', + value: 'some value', + } as Entry & { id: string }, +]; +export const ITEM_TYPE = 'simple'; +export const OS_TYPES: OsTypeArray = ['windows']; +export const TAGS = []; +export const COMMENTS = []; +export const FILTER = 'name:Nicolas Bourbaki'; +export const CURSOR = 'c29tZXN0cmluZ2ZvcnlvdQ=='; +export const _VERSION = 'WzI5NywxXQ=='; +export const VERSION = 1; +export const IMMUTABLE = false; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.ts index f86986fc328c5..2f520e79bf42c 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/constants/index.ts @@ -14,3 +14,21 @@ * @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants. */ export const ENDPOINT_LIST_ID = 'endpoint_list'; + +/** + * Description of trusted apps agnostic list + * @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants. + */ +export const ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION = 'Endpoint Security Trusted Apps List'; + +/** + * ID of trusted apps agnostic list + * @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants. + */ +export const ENDPOINT_TRUSTED_APPS_LIST_ID = 'endpoint_trusted_apps'; + +/** + * Name of trusted apps agnostic list + * @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants. + */ +export const ENDPOINT_TRUSTED_APPS_LIST_NAME = 'Endpoint Security Trusted Apps List'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/index.ts index 3c60df315e430..33d97d868771e 100644 --- a/packages/kbn-securitysolution-io-ts-list-types/src/index.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/index.ts @@ -6,39 +6,7 @@ * Side Public License, v 1. */ -export * from './comment'; +export * from './common'; export * from './constants'; -export * from './create_comment'; -export * from './created_at'; -export * from './created_by'; -export * from './default_comments_array'; -export * from './default_create_comments_array'; -export * from './default_namespace'; -export * from './default_namespace_array'; -export * from './default_update_comments_array'; -export * from './description'; -export * from './endpoint'; -export * from './entries'; -export * from './entries_exist'; -export * from './entries_list'; -export * from './entry_match'; -export * from './entry_match_any'; -export * from './entry_match_wildcard'; -export * from './entry_nested'; -export * from './exception_list'; -export * from './exception_list_item_type'; -export * from './id'; -export * from './item_id'; -export * from './list_operator'; -export * from './lists'; -export * from './lists_default_array'; -export * from './meta'; -export * from './name'; -export * from './non_empty_entries_array'; -export * from './non_empty_nested_entries_array'; -export * from './os_type'; -export * from './tags'; -export * from './type'; -export * from './update_comment'; -export * from './updated_at'; -export * from './updated_by'; +export * from './request'; +export * from './response'; diff --git a/x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.mock.ts similarity index 66% rename from x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.mock.ts index bed902d56fd70..c17351ad42edb 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.mock.ts @@ -1,10 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ +import { CreateEndpointListItemSchema } from '.'; import { COMMENTS, DESCRIPTION, @@ -14,9 +16,7 @@ import { NAME, OS_TYPES, TAGS, -} from '../../constants.mock'; - -import { CreateEndpointListItemSchema } from './create_endpoint_list_item_schema'; +} from '../../constants/index.mock'; export const getCreateEndpointListItemSchemaMock = (): CreateEndpointListItemSchema => ({ comments: COMMENTS, diff --git a/x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.test.ts similarity index 94% rename from x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.test.ts index e6287a87c86ef..80e23295b72bc 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.test.ts @@ -1,23 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { CommentsArray } from '@kbn/securitysolution-io-ts-list-types'; - -import { getCreateCommentsArrayMock } from '../types/create_comment.mock'; -import { getCommentsMock } from '../types/comment.mock'; - -import { - CreateEndpointListItemSchema, - createEndpointListItemSchema, -} from './create_endpoint_list_item_schema'; -import { getCreateEndpointListItemSchemaMock } from './create_endpoint_list_item_schema.mock'; +import { getCreateEndpointListItemSchemaMock } from './index.mock'; +import { CreateEndpointListItemSchema, createEndpointListItemSchema } from '.'; +import { getCreateCommentsArrayMock } from '../../common/create_comment/index.mock'; +import { getCommentsMock } from '../../common/comment/index.mock'; +import { CommentsArray } from '../../common/comment'; describe('create_endpoint_list_item_schema', () => { test('it should pass validation when supplied a typical list item request not counting the auto generated uuid', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.ts similarity index 58% rename from x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.ts index 322e31aacd040..8c8e1d3e0db4b 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_endpoint_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_endpoint_list_item_schema/index.ts @@ -1,29 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { - CreateCommentsArray, - DefaultCreateCommentsArray, - EntriesArray, - OsTypeArray, - Tags, - description, - exceptionListItemType, - meta, - name, - nonEmptyEndpointEntriesArray, - osTypeArrayOrUndefined, - tags, -} from '@kbn/securitysolution-io-ts-list-types'; -import { DefaultUuid } from '@kbn/securitysolution-io-ts-types'; -import { ItemId } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { DefaultUuid } from '@kbn/securitysolution-io-ts-types'; +import { nonEmptyEndpointEntriesArray } from '../../common/endpoint/entries'; +import { exceptionListItemType } from '../../common/exception_list_item_type'; +import { DefaultCreateCommentsArray } from '../../common/default_create_comments_array'; +import { OsTypeArray, osTypeArrayOrUndefined } from '../../common/os_type'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { CreateCommentsArray } from '../../common/create_comment'; +import { Tags } from '../../common/tags'; +import { ItemId } from '../../common/item_id'; +import { EntriesArray } from '../../common/entries'; +import { description } from '../../common/description'; +import { name } from '../../common/name'; +import { meta } from '../../common/meta'; +import { tags } from '../../common/tags'; export const createEndpointListItemSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..4ed62887ef9ba --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.mock.ts @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { CreateExceptionListItemSchema } from '.'; +import { + COMMENTS, + DESCRIPTION, + ENTRIES, + ITEM_ID, + ITEM_TYPE, + LIST_ID, + META, + NAME, + NAMESPACE_TYPE, + OS_TYPES, + TAGS, +} from '../../constants/index.mock'; + +export const getCreateExceptionListItemSchemaMock = (): CreateExceptionListItemSchema => ({ + comments: COMMENTS, + description: DESCRIPTION, + entries: ENTRIES, + item_id: undefined, + list_id: LIST_ID, + meta: META, + name: NAME, + namespace_type: NAMESPACE_TYPE, + os_types: OS_TYPES, + tags: TAGS, + type: ITEM_TYPE, +}); + +/** + * Useful for end to end testing + */ +export const getCreateExceptionListItemMinimalSchemaMock = (): CreateExceptionListItemSchema => ({ + description: DESCRIPTION, + entries: ENTRIES, + item_id: ITEM_ID, + list_id: LIST_ID, + name: NAME, + os_types: OS_TYPES, + type: ITEM_TYPE, +}); + +/** + * Useful for end to end testing + */ +export const getCreateExceptionListItemMinimalSchemaMockWithoutId = (): CreateExceptionListItemSchema => ({ + description: DESCRIPTION, + entries: ENTRIES, + list_id: LIST_ID, + name: NAME, + os_types: OS_TYPES, + type: ITEM_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.test.ts similarity index 94% rename from x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.test.ts index 7e8d16663cf5d..033eef405ec90 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.test.ts @@ -1,23 +1,20 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { CommentsArray } from '@kbn/securitysolution-io-ts-list-types'; -import { getCreateCommentsArrayMock } from '../types/create_comment.mock'; -import { getCommentsMock } from '../types/comment.mock'; - -import { - CreateExceptionListItemSchema, - createExceptionListItemSchema, -} from './create_exception_list_item_schema'; -import { getCreateExceptionListItemSchemaMock } from './create_exception_list_item_schema.mock'; +import { getCreateExceptionListItemSchemaMock } from './index.mock'; +import { CreateExceptionListItemSchema, createExceptionListItemSchema } from '.'; +import { getCreateCommentsArrayMock } from '../../common/create_comment/index.mock'; +import { getCommentsMock } from '../../common/comment/index.mock'; +import { CommentsArray } from '../../common/comment'; describe('create_exception_list_item_schema', () => { test('it should pass validation when supplied a typical exception list item request not counting the auto generated uuid', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.ts similarity index 56% rename from x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.ts index d37c7f7aa67b2..e4f92c2819664 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_item_schema/index.ts @@ -1,30 +1,30 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { - CreateCommentsArray, - DefaultCreateCommentsArray, - EntriesArray, - NamespaceType, - OsTypeArray, - Tags, - description, - exceptionListItemType, - meta, - name, - nonEmptyEntriesArray, - osTypeArrayOrUndefined, - tags, -} from '@kbn/securitysolution-io-ts-list-types'; import { DefaultUuid } from '@kbn/securitysolution-io-ts-types'; -import { ItemId, list_id, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { DefaultCreateCommentsArray } from '../../common/default_create_comments_array'; +import { CreateCommentsArray } from '../../common/create_comment'; +import { Tags } from '../../common/tags'; +import { ItemId } from '../../common/item_id'; +import { EntriesArray } from '../../common/entries'; +import { NamespaceType } from '../../common/default_namespace'; +import { OsTypeArray, osTypeArrayOrUndefined } from '../../common/os_type'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { description } from '../../common/description'; +import { list_id } from '../../common/list_id'; +import { name } from '../../common/name'; +import { exceptionListItemType } from '../../common/exception_list_item_type'; +import { meta } from '../../common/meta'; +import { namespace_type } from '../../common/namespace_type'; +import { tags } from '../../common/tags'; +import { nonEmptyEntriesArray } from '../../common/non_empty_entries_array'; export const createExceptionListItemSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.mock.ts new file mode 100644 index 0000000000000..e7a9af74a7b28 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.mock.ts @@ -0,0 +1,60 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { + DESCRIPTION, + ENDPOINT_TYPE, + LIST_ID, + META, + NAME, + NAMESPACE_TYPE, + VERSION, +} from '../../constants/index.mock'; + +import { CreateExceptionListSchema } from '.'; + +export const getCreateExceptionListSchemaMock = (): CreateExceptionListSchema => ({ + description: DESCRIPTION, + list_id: undefined, + meta: META, + name: NAME, + namespace_type: NAMESPACE_TYPE, + os_types: [], + tags: [], + type: ENDPOINT_TYPE, + version: VERSION, +}); + +/** + * Useful for end to end testing + */ +export const getCreateExceptionListMinimalSchemaMock = (): CreateExceptionListSchema => ({ + description: DESCRIPTION, + list_id: LIST_ID, + name: NAME, + type: ENDPOINT_TYPE, +}); + +/** + * Useful for end to end testing + */ +export const getCreateExceptionListMinimalSchemaMockWithoutId = (): CreateExceptionListSchema => ({ + description: DESCRIPTION, + name: NAME, + type: ENDPOINT_TYPE, +}); + +/** + * Useful for end to end testing with detections + */ +export const getCreateExceptionListDetectionSchemaMock = (): CreateExceptionListSchema => ({ + description: DESCRIPTION, + list_id: LIST_ID, + name: NAME, + type: 'detection', +}); diff --git a/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.test.ts similarity index 91% rename from x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.test.ts index e6f29bc02702d..087c0dfe91ac2 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - CreateExceptionListSchema, - createExceptionListSchema, -} from './create_exception_list_schema'; -import { getCreateExceptionListSchemaMock } from './create_exception_list_schema.mock'; +import { CreateExceptionListSchema, createExceptionListSchema } from '.'; +import { getCreateExceptionListSchemaMock } from './index.mock'; describe('create_exception_list_schema', () => { test('it should validate a typical exception lists request and generate a correct body not counting the uuid', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.ts similarity index 64% rename from x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.ts index 30e4ff908ee80..ccd05f4962028 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_exception_list_schema/index.ts @@ -1,30 +1,29 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { - NamespaceType, - OsTypeArray, - Tags, - description, - exceptionListType, - meta, - name, - osTypeArrayOrUndefined, - tags, -} from '@kbn/securitysolution-io-ts-list-types'; import { DefaultUuid, DefaultVersionNumber, DefaultVersionNumberDecoded, } from '@kbn/securitysolution-io-ts-types'; -import { ListId, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { exceptionListType } from '../../common/exception_list'; +import { OsTypeArray, osTypeArrayOrUndefined } from '../../common/os_type'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { Tags } from '../../common/tags'; +import { ListId } from '../../common/list_id'; +import { NamespaceType } from '../../common/default_namespace'; +import { name } from '../../common/name'; +import { description } from '../../common/description'; +import { namespace_type } from '../../common/namespace_type'; +import { tags } from '../../common/tags'; +import { meta } from '../../common/meta'; export const createExceptionListSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..1d3fabc0e5c76 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.mock.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ID, LIST_ITEM_ID, META, VALUE } from '../../constants/index.mock'; + +import { CreateListItemSchema } from '.'; + +export const getCreateListItemSchemaMock = (): CreateListItemSchema => ({ + id: LIST_ITEM_ID, + list_id: LIST_ID, + meta: META, + value: VALUE, +}); + +/** + * Useful for end to end testing + */ +export const getCreateMinimalListItemSchemaMock = (): CreateListItemSchema => ({ + id: LIST_ITEM_ID, + list_id: LIST_ID, + value: VALUE, +}); + +/** + * Useful for end to end testing + */ +export const getCreateMinimalListItemSchemaMockWithoutId = (): CreateListItemSchema => ({ + list_id: LIST_ID, + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.test.ts similarity index 86% rename from x-pack/plugins/lists/common/schemas/request/create_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.test.ts index 99fd1f28dcae3..e1076daf8d6af 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getCreateListItemSchemaMock } from './create_list_item_schema.mock'; -import { CreateListItemSchema, createListItemSchema } from './create_list_item_schema'; +import { getCreateListItemSchemaMock } from './index.mock'; +import { CreateListItemSchema, createListItemSchema } from '.'; describe('create_list_item_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.ts similarity index 55% rename from x-pack/plugins/lists/common/schemas/request/create_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.ts index d11bd03ced916..c99e7b059f479 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_item_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id, meta } from '@kbn/securitysolution-io-ts-list-types'; -import { list_id, value } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { list_id } from '../../common/list_id'; +import { value } from '../../common/value'; +import { id } from '../../common/id'; +import { meta } from '../../common/meta'; export const createListItemSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.mock.ts new file mode 100644 index 0000000000000..7ba996e46defe --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.mock.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { DESCRIPTION, LIST_ID, META, NAME, TYPE, VERSION } from '../../constants/index.mock'; + +import { CreateListSchema } from '.'; + +export const getCreateListSchemaMock = (): CreateListSchema => ({ + description: DESCRIPTION, + deserializer: undefined, + id: LIST_ID, + meta: META, + name: NAME, + serializer: undefined, + type: TYPE, + version: VERSION, +}); + +/** + * Useful for end to end tests and other mechanisms which want to fill in the values + */ +export const getCreateMinimalListSchemaMock = (): CreateListSchema => ({ + description: DESCRIPTION, + id: LIST_ID, + name: NAME, + type: TYPE, +}); + +/** + * Useful for end to end tests and other mechanisms which want to fill in the values + */ +export const getCreateMinimalListSchemaMockWithoutId = (): CreateListSchema => ({ + description: DESCRIPTION, + name: NAME, + type: TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/create_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.test.ts similarity index 90% rename from x-pack/plugins/lists/common/schemas/request/create_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.test.ts index d183465a333af..a170302a19af6 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { CreateListSchema, createListSchema } from './create_list_schema'; -import { getCreateListSchemaMock } from './create_list_schema.mock'; +import { CreateListSchema, createListSchema } from '.'; +import { getCreateListSchemaMock } from './index.mock'; describe('create_list_schema', () => { test('it should validate a typical lists request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/create_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.ts similarity index 63% rename from x-pack/plugins/lists/common/schemas/request/create_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.ts index 1c197a37c0cbd..5c2f3e6d7bde3 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/create_list_schema/index.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; @@ -10,10 +11,15 @@ import { DefaultVersionNumber, DefaultVersionNumberDecoded, } from '@kbn/securitysolution-io-ts-types'; -import { description, id, meta, name, type } from '@kbn/securitysolution-io-ts-list-types'; -import { deserializer, serializer } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { name } from '../../common/name'; +import { description } from '../../common/description'; +import { type } from '../../common/type'; +import { deserializer } from '../../common/deserializer'; +import { id } from '../../common/id'; +import { meta } from '../../common/meta'; +import { serializer } from '../../common/serializer'; export const createListSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..f5c0acc9aaf6d --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.mock.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID } from '../../constants/index.mock'; + +import { DeleteEndpointListItemSchema } from '.'; + +export const getDeleteEndpointListItemSchemaMock = (): DeleteEndpointListItemSchema => ({ + id: ID, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.test.ts similarity index 85% rename from x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.test.ts index 11c3eaf866520..e856853fe7eb7 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - DeleteEndpointListItemSchema, - deleteEndpointListItemSchema, -} from './delete_endpoint_list_item_schema'; -import { getDeleteEndpointListItemSchemaMock } from './delete_endpoint_list_item_schema.mock'; +import { DeleteEndpointListItemSchema, deleteEndpointListItemSchema } from '.'; +import { getDeleteEndpointListItemSchemaMock } from './index.mock'; describe('delete_endpoint_list_item_schema', () => { test('it should validate a typical endpoint list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.ts similarity index 62% rename from x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.ts index 0b714885437a8..05d9891ce06db 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_endpoint_list_item_schema/index.ts @@ -1,15 +1,16 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; -import { item_id } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { id } from '../../common/id'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { item_id } from '../../common/item_id'; export const deleteEndpointListItemSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..90558b81aef84 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.mock.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, NAMESPACE_TYPE } from '../../constants/index.mock'; + +import { DeleteExceptionListItemSchema } from '.'; + +export const getDeleteExceptionListItemSchemaMock = (): DeleteExceptionListItemSchema => ({ + id: ID, + namespace_type: NAMESPACE_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.test.ts index 63a1e29419760..2577fbf95c631 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - DeleteExceptionListItemSchema, - deleteExceptionListItemSchema, -} from './delete_exception_list_item_schema'; -import { getDeleteExceptionListItemSchemaMock } from './delete_exception_list_item_schema.mock'; +import { DeleteExceptionListItemSchema, deleteExceptionListItemSchema } from '.'; +import { getDeleteExceptionListItemSchemaMock } from './index.mock'; describe('delete_exception_list_item_schema', () => { test('it should validate a typical exception list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.ts similarity index 60% rename from x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.ts index 5c6fc9c158b3b..61dd7c62bb5cc 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_item_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { NamespaceType, id } from '@kbn/securitysolution-io-ts-list-types'; -import { item_id, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { NamespaceType } from '../../common/default_namespace'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { item_id } from '../../common/item_id'; +import { namespace_type } from '../../common/namespace_type'; export const deleteExceptionListItemSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.mock.ts new file mode 100644 index 0000000000000..07dc01bc56efd --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.mock.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, NAMESPACE_TYPE } from '../../constants/index.mock'; + +import { DeleteExceptionListSchema } from '.'; + +export const getDeleteExceptionListSchemaMock = (): DeleteExceptionListSchema => ({ + id: ID, + namespace_type: NAMESPACE_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.test.ts index ea591f74b6b15..da47ea67aabce 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - DeleteExceptionListSchema, - deleteExceptionListSchema, -} from './delete_exception_list_schema'; -import { getDeleteExceptionListSchemaMock } from './delete_exception_list_schema.mock'; +import { DeleteExceptionListSchema, deleteExceptionListSchema } from '.'; +import { getDeleteExceptionListSchemaMock } from './index.mock'; describe('delete_exception_list_schema', () => { test('it should validate a typical exception list request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.ts similarity index 59% rename from x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.ts index 2d1d00a6759cf..568ab0bc4bef1 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_exception_list_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { NamespaceType, id } from '@kbn/securitysolution-io-ts-list-types'; -import { list_id, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { NamespaceType } from '../../common/default_namespace'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { list_id } from '../../common/list_id'; +import { namespace_type } from '../../common/namespace_type'; export const deleteExceptionListSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..7404fc61e4040 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, LIST_ID, VALUE } from '../../constants/index.mock'; + +import { DeleteListItemSchema } from '.'; + +export const getDeleteListItemSchemaMock = (): DeleteListItemSchema => ({ + id: ID, + list_id: LIST_ID, + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.test.ts similarity index 80% rename from x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.test.ts index 350243e10e2b9..9d524e1547c94 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { DeleteListItemSchema, deleteListItemSchema } from './delete_list_item_schema'; -import { getDeleteListItemSchemaMock } from './delete_list_item_schema.mock'; +import { DeleteListItemSchema, deleteListItemSchema } from '.'; +import { getDeleteListItemSchemaMock } from './index.mock'; describe('delete_list_item_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.ts similarity index 57% rename from x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.ts index 9cb46b3e36f45..903a6abb1535a 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_item_schema/index.ts @@ -1,15 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; -import { list_id, valueOrUndefined } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { list_id } from '../../common/list_id'; +import { valueOrUndefined } from '../../common/value'; export const deleteListItemSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.mock.ts new file mode 100644 index 0000000000000..790513f4bcacc --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ID } from '../../constants/index.mock'; + +import { DeleteListSchema } from '.'; + +export const getDeleteListSchemaMock = (): DeleteListSchema => ({ + deleteReferences: false, + id: LIST_ID, + ignoreReferences: true, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/request/delete_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.test.ts index 92a33c73ba3be..16e2685682b07 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { DeleteListSchema, deleteListSchema } from './delete_list_schema'; -import { getDeleteListSchemaMock } from './delete_list_schema.mock'; +import { DeleteListSchema, deleteListSchema } from '.'; +import { getDeleteListSchemaMock } from './index.mock'; describe('delete_list_schema', () => { test('it should validate a typical lists request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/delete_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.ts similarity index 69% rename from x-pack/plugins/lists/common/schemas/request/delete_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.ts index 0d6bbc73a2571..ea6e447895367 100644 --- a/x-pack/plugins/lists/common/schemas/request/delete_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/delete_list_schema/index.ts @@ -1,15 +1,16 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; import { DefaultStringBooleanFalse } from '@kbn/securitysolution-io-ts-types'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; export const deleteListSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.mock.ts new file mode 100644 index 0000000000000..a5542d99b007c --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, LIST_ID, NAMESPACE_TYPE } from '../../constants/index.mock'; + +import { ExportExceptionListQuerySchema } from '.'; + +export const getExportExceptionListQuerySchemaMock = (): ExportExceptionListQuerySchema => ({ + id: ID, + list_id: LIST_ID, + namespace_type: NAMESPACE_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.test.ts similarity index 89% rename from x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.test.ts index 06b432e74342d..3d1fcba3f7dbf 100644 --- a/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - ExportExceptionListQuerySchema, - exportExceptionListQuerySchema, -} from './export_exception_list_query_schema'; -import { getExportExceptionListQuerySchemaMock } from './export_exception_list_query_schema.mock'; +import { ExportExceptionListQuerySchema, exportExceptionListQuerySchema } from '.'; +import { getExportExceptionListQuerySchemaMock } from './index.mock'; describe('export_exception_list_schema', () => { test('it should validate a typical lists request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.ts similarity index 57% rename from x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.ts index 47bb1b70ad8b7..ce6dc9a561293 100644 --- a/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_exception_list_query_schema/index.ts @@ -1,14 +1,16 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; -import { list_id, namespace_type } from '../common/schemas'; +import { id } from '../../common/id'; +import { list_id } from '../../common/list_id'; +import { namespace_type } from '../../common/namespace_type'; export const exportExceptionListQuerySchema = t.exact( t.type({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.mock.ts new file mode 100644 index 0000000000000..6adf0160d8483 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.mock.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ID } from '../../constants/index.mock'; + +import { ExportListItemQuerySchema } from '.'; + +export const getExportListItemQuerySchemaMock = (): ExportListItemQuerySchema => ({ + list_id: LIST_ID, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.test.ts index 2ac69e0c281b3..f928bb51328be 100644 --- a/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - ExportListItemQuerySchema, - exportListItemQuerySchema, -} from './export_list_item_query_schema'; -import { getExportListItemQuerySchemaMock } from './export_list_item_query_schema.mock'; +import { ExportListItemQuerySchema, exportListItemQuerySchema } from '.'; +import { getExportListItemQuerySchemaMock } from './index.mock'; describe('export_list_item_schema', () => { test('it should validate a typical lists request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.ts similarity index 62% rename from x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.ts index b6c5a75f03973..cfc43c9e4a1ab 100644 --- a/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/export_list_item_query_schema/index.ts @@ -1,14 +1,15 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { list_id } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { list_id } from '../../common/list_id'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; export const exportListItemQuerySchema = t.exact( t.type({ diff --git a/x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.mock.ts similarity index 63% rename from x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.mock.ts index 9a7566e62e2c7..4343fc88060c2 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.mock.ts @@ -1,16 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { FILTER } from '../../constants.mock'; +import { FILTER } from '../../constants/index.mock'; -import { - FindEndpointListItemSchema, - FindEndpointListItemSchemaDecoded, -} from './find_endpoint_list_item_schema'; +import { FindEndpointListItemSchema, FindEndpointListItemSchemaDecoded } from '.'; export const getFindEndpointListItemSchemaMock = (): FindEndpointListItemSchema => ({ filter: FILTER, diff --git a/x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.test.ts index bd9a2a0bcb9e2..029667c668e3d 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.test.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; @@ -12,11 +13,8 @@ import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts import { getFindEndpointListItemSchemaDecodedMock, getFindEndpointListItemSchemaMock, -} from './find_endpoint_list_item_schema.mock'; -import { - FindEndpointListItemSchema, - findEndpointListItemSchema, -} from './find_endpoint_list_item_schema'; +} from './index.mock'; +import { FindEndpointListItemSchema, findEndpointListItemSchema } from '.'; describe('find_endpoint_list_item_schema', () => { test('it should validate a typical find item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.ts similarity index 70% rename from x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.ts index 06b28ea6cbb4e..d46f937b7ef06 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_endpoint_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_endpoint_list_item_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; import { StringToPositiveNumber } from '@kbn/securitysolution-io-ts-types'; -import { filter, sort_field, sort_order } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { filter } from '../../common/filter'; +import { sort_field } from '../../common/sort_field'; +import { sort_order } from '../../common/sort_order'; export const findEndpointListItemSchema = t.exact( t.partial({ diff --git a/x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.mock.ts similarity index 83% rename from x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.mock.ts index 1faaea0f4d3fe..f6548a2c5f4fe 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.mock.ts @@ -1,16 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { FILTER, LIST_ID, NAMESPACE_TYPE } from '../../constants.mock'; +import { FILTER, LIST_ID, NAMESPACE_TYPE } from '../../constants/index.mock'; -import { - FindExceptionListItemSchema, - FindExceptionListItemSchemaDecoded, -} from './find_exception_list_item_schema'; +import { FindExceptionListItemSchema, FindExceptionListItemSchemaDecoded } from '.'; export const getFindExceptionListItemSchemaMock = (): FindExceptionListItemSchema => ({ filter: FILTER, diff --git a/x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.test.ts similarity index 95% rename from x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.test.ts index d3a594e052c01..04afee30c1ab3 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.test.ts @@ -1,27 +1,28 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { LIST_ID } from '../../constants.mock'; +import { LIST_ID } from '../../constants/index.mock'; import { getFindExceptionListItemSchemaDecodedMock, getFindExceptionListItemSchemaDecodedMultipleMock, getFindExceptionListItemSchemaMock, getFindExceptionListItemSchemaMultipleMock, -} from './find_exception_list_item_schema.mock'; +} from './index.mock'; import { FindExceptionListItemSchema, FindExceptionListItemSchemaDecoded, findExceptionListItemSchema, -} from './find_exception_list_item_schema'; +} from '.'; describe('find_list_item_schema', () => { test('it should validate a typical find item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.ts similarity index 78% rename from x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.ts index d92bfbec02f5a..88756ac0eb301 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_exception_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_item_schema/index.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; @@ -12,13 +13,14 @@ import { NonEmptyStringArray, StringToPositiveNumber, } from '@kbn/securitysolution-io-ts-types'; + import { DefaultNamespaceArray, DefaultNamespaceArrayTypeDecoded, -} from '@kbn/securitysolution-io-ts-list-types'; - -import { sort_field, sort_order } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +} from '../../common/default_namespace_array'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { sort_field } from '../../common/sort_field'; +import { sort_order } from '../../common/sort_order'; export const findExceptionListItemSchema = t.intersection([ t.exact( diff --git a/x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.mock.ts similarity index 64% rename from x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.mock.ts index 782abbdb5368d..c6ec6590a9ce7 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.mock.ts @@ -1,16 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { FILTER, NAMESPACE_TYPE } from '../../constants.mock'; +import { FILTER, NAMESPACE_TYPE } from '../../constants/index.mock'; -import { - FindExceptionListSchema, - FindExceptionListSchemaDecoded, -} from './find_exception_list_schema'; +import { FindExceptionListSchema, FindExceptionListSchemaDecoded } from '.'; export const getFindExceptionListSchemaMock = (): FindExceptionListSchema => ({ filter: FILTER, diff --git a/x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.test.ts similarity index 95% rename from x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.test.ts index b1ec33878bd2a..c3cd75adf7569 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.test.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; @@ -12,12 +13,12 @@ import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts import { getFindExceptionListSchemaDecodedMock, getFindExceptionListSchemaMock, -} from './find_exception_list_schema.mock'; +} from './index.mock'; import { FindExceptionListSchema, FindExceptionListSchemaDecoded, findExceptionListSchema, -} from './find_exception_list_schema'; +} from '.'; describe('find_exception_list_schema', () => { test('it should validate a typical find item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.ts similarity index 68% rename from x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.ts index 6cf31c56ea599..ca5c0f81ae9d6 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_exception_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_exception_list_schema/index.ts @@ -1,16 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; import { StringToPositiveNumber } from '@kbn/securitysolution-io-ts-types'; -import { DefaultNamespaceArray, NamespaceTypeArray } from '@kbn/securitysolution-io-ts-list-types'; -import { filter, sort_field, sort_order } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { DefaultNamespaceArray, NamespaceTypeArray } from '../../common/default_namespace_array'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { filter } from '../../common/filter'; +import { sort_field } from '../../common/sort_field'; +import { sort_order } from '../../common/sort_order'; export const findExceptionListSchema = t.exact( t.partial({ diff --git a/x-pack/plugins/lists/common/schemas/request/find_list_item_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.mock.ts similarity index 71% rename from x-pack/plugins/lists/common/schemas/request/find_list_item_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.mock.ts index 87e100d21385f..4bbfa884610af 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_list_item_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.mock.ts @@ -1,13 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { CURSOR, FILTER, LIST_ID } from '../../constants.mock'; +import { CURSOR, FILTER, LIST_ID } from '../../constants/index.mock'; -import { FindListItemSchema, FindListItemSchemaDecoded } from './find_list_item_schema'; +import { FindListItemSchema, FindListItemSchemaDecoded } from '.'; export const getFindListItemSchemaMock = (): FindListItemSchema => ({ cursor: CURSOR, diff --git a/x-pack/plugins/lists/common/schemas/request/find_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.test.ts similarity index 90% rename from x-pack/plugins/lists/common/schemas/request/find_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.test.ts index 7d298c3bdcb1e..0ee599a7e0f15 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.test.ts @@ -1,25 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { LIST_ID } from '../../constants.mock'; +import { LIST_ID } from '../../constants/index.mock'; -import { - getFindListItemSchemaDecodedMock, - getFindListItemSchemaMock, -} from './find_list_item_schema.mock'; -import { - FindListItemSchema, - FindListItemSchemaDecoded, - findListItemSchema, -} from './find_list_item_schema'; +import { FindListItemSchema, FindListItemSchemaDecoded, findListItemSchema } from '.'; +import { getFindListItemSchemaDecodedMock, getFindListItemSchemaMock } from './index.mock'; describe('find_list_item_schema', () => { test('it should validate a typical find item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/find_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.ts similarity index 68% rename from x-pack/plugins/lists/common/schemas/request/find_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.ts index e0d072780bbf8..7bf6f94e46d40 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_item_schema/index.ts @@ -1,15 +1,20 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { StringToPositiveNumber } from '@kbn/securitysolution-io-ts-types'; -import { cursor, filter, list_id, sort_field, sort_order } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { StringToPositiveNumber } from '@kbn/securitysolution-io-ts-types'; +import { filter } from '../../common/filter'; +import { cursor } from '../../common/cursor'; +import { sort_field } from '../../common/sort_field'; +import { sort_order } from '../../common/sort_order'; +import { list_id } from '../../common/list_id'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; export const findListItemSchema = t.intersection([ t.exact(t.type({ list_id })), diff --git a/x-pack/plugins/lists/common/schemas/request/find_list_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.mock.ts similarity index 63% rename from x-pack/plugins/lists/common/schemas/request/find_list_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.mock.ts index f2a9a44584245..0614e919827ee 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_list_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.mock.ts @@ -1,13 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { FILTER } from '../../constants.mock'; +import { FILTER } from '../../constants/index.mock'; -import { FindListSchema, FindListSchemaEncoded } from './find_list_schema'; +import { FindListSchema, FindListSchemaEncoded } from '.'; export const getFindListSchemaMock = (): FindListSchemaEncoded => ({ filter: FILTER, diff --git a/x-pack/plugins/lists/common/schemas/request/find_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/request/find_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.test.ts index a700c88618d60..a56a56daa7049 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getFindListSchemaDecodedMock, getFindListSchemaMock } from './find_list_schema.mock'; -import { FindListSchemaEncoded, findListSchema } from './find_list_schema'; +import { getFindListSchemaDecodedMock, getFindListSchemaMock } from './index.mock'; +import { FindListSchemaEncoded, findListSchema } from '.'; describe('find_list_schema', () => { test('it should validate a typical find item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/find_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.ts similarity index 66% rename from x-pack/plugins/lists/common/schemas/request/find_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.ts index 4d929d581370c..116e4e9cb7e95 100644 --- a/x-pack/plugins/lists/common/schemas/request/find_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/find_list_schema/index.ts @@ -1,15 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { StringToPositiveNumber } from '@kbn/securitysolution-io-ts-types'; -import { cursor, filter, sort_field, sort_order } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { StringToPositiveNumber } from '@kbn/securitysolution-io-ts-types'; +import { cursor } from '../../common/cursor'; +import { filter } from '../../common/filter'; +import { sort_field } from '../../common/sort_field'; +import { sort_order } from '../../common/sort_order'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; export const findListSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.mock.ts new file mode 100644 index 0000000000000..622400e307811 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.mock.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ID, TYPE } from '../../constants/index.mock'; + +import { ImportListItemQuerySchema } from '.'; + +export const getImportListItemQuerySchemaMock = (): ImportListItemQuerySchema => ({ + deserializer: undefined, + list_id: LIST_ID, + serializer: undefined, + type: TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.test.ts similarity index 91% rename from x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.test.ts index c00609e66af5b..c497ad6c58438 100644 --- a/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - ImportListItemQuerySchema, - importListItemQuerySchema, -} from './import_list_item_query_schema'; -import { getImportListItemQuerySchemaMock } from './import_list_item_query_schema.mock'; +import { ImportListItemQuerySchema, importListItemQuerySchema } from '.'; +import { getImportListItemQuerySchemaMock } from './index.mock'; describe('import_list_item_schema', () => { test('it should validate a typical lists request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.ts similarity index 52% rename from x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.ts index cef803ffa5e45..9d7b782c502b4 100644 --- a/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_query_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { type } from '@kbn/securitysolution-io-ts-list-types'; -import { RequiredKeepUndefined } from '../../types'; -import { deserializer, list_id, serializer } from '../common/schemas'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { deserializer } from '../../common/deserializer'; +import { list_id } from '../../common/list_id'; +import { type } from '../../common/type'; +import { serializer } from '../../common/serializer'; export const importListItemQuerySchema = t.exact( t.partial({ deserializer, list_id, serializer, type }) diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..b770606107177 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.mock.ts @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ImportListItemSchema } from '.'; + +export const getImportListItemSchemaMock = (): ImportListItemSchema => ({ + file: {}, +}); + +/** + * This is useful for end to end tests, it will return a buffer given a string array + * of things to import. + * @param input Array of strings of things to import + */ +export const getImportListItemAsBuffer = (input: string[]): Buffer => { + return Buffer.from(input.join('\r\n')); +}; diff --git a/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/request/import_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.test.ts index 08298a505fa7c..1ede3984c8cc6 100644 --- a/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { ImportListItemSchema, importListItemSchema } from './import_list_item_schema'; -import { getImportListItemSchemaMock } from './import_list_item_schema.mock'; +import { ImportListItemSchema, importListItemSchema } from '.'; +import { getImportListItemSchemaMock } from './index.mock'; describe('import_list_item_schema', () => { test('it should validate a typical lists request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.ts similarity index 59% rename from x-pack/plugins/lists/common/schemas/request/import_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.ts index 03c04c8296ed6..0d4046e6a5241 100644 --- a/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/import_list_item_schema/index.ts @@ -1,14 +1,15 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { file } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { file } from '../../common/file'; export const importListItemSchema = t.exact( t.type({ diff --git a/x-pack/plugins/lists/common/schemas/request/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/index.ts similarity index 86% rename from x-pack/plugins/lists/common/schemas/request/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/index.ts index d29be27c687a2..2c71afd9e066e 100644 --- a/x-pack/plugins/lists/common/schemas/request/index.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/index.ts @@ -1,39 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ - export * from './create_endpoint_list_item_schema'; export * from './create_exception_list_item_schema'; export * from './create_exception_list_schema'; export * from './create_list_item_schema'; export * from './create_list_schema'; export * from './delete_endpoint_list_item_schema'; -export * from './delete_exception_list_item_schema'; export * from './delete_exception_list_schema'; +export * from './delete_exception_list_item_schema'; export * from './delete_list_item_schema'; export * from './delete_list_schema'; export * from './export_exception_list_query_schema'; export * from './export_list_item_query_schema'; export * from './find_endpoint_list_item_schema'; -export * from './find_exception_list_item_schema'; export * from './find_exception_list_schema'; +export * from './find_exception_list_item_schema'; export * from './find_list_item_schema'; export * from './find_list_schema'; +export * from './import_list_item_query_schema'; export * from './import_list_item_schema'; export * from './patch_list_item_schema'; export * from './patch_list_schema'; export * from './read_endpoint_list_item_schema'; -export * from './read_exception_list_schema'; export * from './read_exception_list_item_schema'; +export * from './read_exception_list_schema'; export * from './read_list_item_schema'; export * from './read_list_schema'; export * from './update_endpoint_list_item_schema'; export * from './update_exception_list_item_schema'; -export * from './update_exception_list_schema'; -export * from './import_list_item_query_schema'; -export * from './update_list_schema'; +export * from './update_exception_list_item_validation'; export * from './update_exception_list_schema'; export * from './update_list_item_schema'; +export * from './update_list_schema'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..aac9ae8d60fd3 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ITEM_ID, META, VALUE } from '../../constants/index.mock'; + +import { PatchListItemSchema } from '.'; + +export const getPathListItemSchemaMock = (): PatchListItemSchema => ({ + id: LIST_ITEM_ID, + meta: META, + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.test.ts similarity index 90% rename from x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.test.ts index 2ec903eef1a9d..5ad094de819a7 100644 --- a/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getPathListItemSchemaMock } from './patch_list_item_schema.mock'; -import { PatchListItemSchema, patchListItemSchema } from './patch_list_item_schema'; +import { getPathListItemSchemaMock } from './index.mock'; +import { PatchListItemSchema, patchListItemSchema } from '.'; describe('patch_list_item_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.ts similarity index 53% rename from x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.ts index 2989919421a3c..7de6d75c74eb2 100644 --- a/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_item_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id, meta } from '@kbn/securitysolution-io-ts-list-types'; -import { _version, value } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { _version } from '../../common/underscore_version'; +import { id } from '../../common/id'; +import { meta } from '../../common/meta'; +import { value } from '../../common/value'; export const patchListItemSchema = t.intersection([ t.exact( diff --git a/x-pack/plugins/lists/common/schemas/request/patch_list_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.mock.ts similarity index 60% rename from x-pack/plugins/lists/common/schemas/request/patch_list_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.mock.ts index e6bf23aad843d..f91059e2f936f 100644 --- a/x-pack/plugins/lists/common/schemas/request/patch_list_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.mock.ts @@ -1,13 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { DESCRIPTION, LIST_ITEM_ID, META, NAME } from '../../constants.mock'; +import { DESCRIPTION, LIST_ITEM_ID, META, NAME } from '../../constants/index.mock'; -import { PatchListSchema } from './patch_list_schema'; +import { PatchListSchema } from '.'; export const getPathListSchemaMock = (): PatchListSchema => ({ description: DESCRIPTION, diff --git a/x-pack/plugins/lists/common/schemas/request/patch_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/request/patch_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.test.ts index 7c0e535aed2c2..f27544188ab5f 100644 --- a/x-pack/plugins/lists/common/schemas/request/patch_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getPathListSchemaMock } from './patch_list_schema.mock'; -import { PatchListSchema, patchListSchema } from './patch_list_schema'; +import { getPathListSchemaMock } from './index.mock'; +import { PatchListSchema, patchListSchema } from '.'; describe('patch_list_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/patch_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.ts similarity index 62% rename from x-pack/plugins/lists/common/schemas/request/patch_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.ts index 2cd41584ef9ff..91f3945c7d943 100644 --- a/x-pack/plugins/lists/common/schemas/request/patch_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/patch_list_schema/index.ts @@ -1,16 +1,20 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { description, id, meta, name } from '@kbn/securitysolution-io-ts-list-types'; import { version } from '@kbn/securitysolution-io-ts-types'; -import { _version } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { _version } from '../../common/underscore_version'; +import { meta } from '../../common/meta'; +import { name } from '../../common/name'; +import { description } from '../../common/description'; export const patchListSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..01435c1846814 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.mock.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, ITEM_ID } from '../../constants/index.mock'; + +import { ReadEndpointListItemSchema } from '.'; + +export const getReadEndpointListItemSchemaMock = (): ReadEndpointListItemSchema => ({ + id: ID, + item_id: ITEM_ID, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.test.ts similarity index 90% rename from x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.test.ts index 1c474db0d0bb7..5a1ad2b6158aa 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getReadEndpointListItemSchemaMock } from './read_endpoint_list_item_schema.mock'; -import { - ReadEndpointListItemSchema, - readEndpointListItemSchema, -} from './read_endpoint_list_item_schema'; +import { getReadEndpointListItemSchemaMock } from './index.mock'; +import { ReadEndpointListItemSchema, readEndpointListItemSchema } from '.'; describe('read_endpoint_list_item_schema', () => { test('it should validate a typical list request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.ts similarity index 62% rename from x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.ts index 3f221b473f432..944c4a47298a8 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_endpoint_list_item_schema/index.ts @@ -1,15 +1,16 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; -import { item_id } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { item_id } from '../../common/item_id'; export const readEndpointListItemSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..ee6bc2afad720 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, ITEM_ID, NAMESPACE_TYPE } from '../../constants/index.mock'; + +import { ReadExceptionListItemSchema } from '.'; + +export const getReadExceptionListItemSchemaMock = (): ReadExceptionListItemSchema => ({ + id: ID, + item_id: ITEM_ID, + namespace_type: NAMESPACE_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.test.ts index 8b713dd38c4f2..14a625434c68d 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getReadExceptionListItemSchemaMock } from './read_exception_list_item_schema.mock'; -import { - ReadExceptionListItemSchema, - readExceptionListItemSchema, -} from './read_exception_list_item_schema'; +import { getReadExceptionListItemSchemaMock } from './index.mock'; +import { ReadExceptionListItemSchema, readExceptionListItemSchema } from '.'; describe('read_exception_list_item_schema', () => { test('it should validate a typical exception list request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.ts similarity index 60% rename from x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.ts index 9094296e56196..62b5a0ea9ec4d 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_item_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { NamespaceType, id } from '@kbn/securitysolution-io-ts-list-types'; -import { item_id, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { NamespaceType } from '../../common/default_namespace'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { item_id } from '../../common/item_id'; +import { namespace_type } from '../../common/namespace_type'; export const readExceptionListItemSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.mock.ts new file mode 100644 index 0000000000000..8b21de02356fa --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, LIST_ID, NAMESPACE_TYPE } from '../../constants/index.mock'; + +import { ReadExceptionListSchema } from '.'; + +export const getReadExceptionListSchemaMock = (): ReadExceptionListSchema => ({ + id: ID, + list_id: LIST_ID, + namespace_type: NAMESPACE_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.test.ts similarity index 94% rename from x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.test.ts index 031e3d6efb261..d931dad2ad086 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getReadExceptionListSchemaMock } from './read_exception_list_schema.mock'; -import { ReadExceptionListSchema, readExceptionListSchema } from './read_exception_list_schema'; +import { getReadExceptionListSchemaMock } from './index.mock'; +import { ReadExceptionListSchema, readExceptionListSchema } from '.'; describe('read_exception_list_schema', () => { test('it should validate a typical exception list request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.ts similarity index 59% rename from x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.ts index 9a361e04900ed..ab2427518bfe3 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_exception_list_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { NamespaceType, id } from '@kbn/securitysolution-io-ts-list-types'; -import { list_id, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { NamespaceType } from '../../common/default_namespace'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { list_id } from '../../common/list_id'; +import { namespace_type } from '../../common/namespace_type'; export const readExceptionListSchema = t.exact( t.partial({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..735880d4d0ceb --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ID, LIST_ITEM_ID, VALUE } from '../../constants/index.mock'; + +import { ReadListItemSchema } from '.'; + +export const getReadListItemSchemaMock = (): ReadListItemSchema => ({ + id: LIST_ITEM_ID, + list_id: LIST_ID, + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/request/read_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.test.ts index 18af60f9d9d56..97fd94e5493e0 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getReadListItemSchemaMock } from './read_list_item_schema.mock'; -import { ReadListItemSchema, readListItemSchema } from './read_list_item_schema'; +import { getReadListItemSchemaMock } from './index.mock'; +import { ReadListItemSchema, readListItemSchema } from '.'; describe('read_list_item_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.ts similarity index 52% rename from x-pack/plugins/lists/common/schemas/request/read_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.ts index 0bfa99ee078a1..71eea194ce34a 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_item_schema/index.ts @@ -1,15 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; -import { list_id, value } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { list_id } from '../../common/list_id'; +import { value } from '../../common/value'; export const readListItemSchema = t.exact(t.partial({ id, list_id, value })); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.mock.ts new file mode 100644 index 0000000000000..531616858dace --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.mock.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { LIST_ID } from '../../constants/index.mock'; + +import { ReadListSchema } from '.'; + +export const getReadListSchemaMock = (): ReadListSchema => ({ + id: LIST_ID, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.test.ts similarity index 85% rename from x-pack/plugins/lists/common/schemas/request/read_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.test.ts index e404e99f65218..082c9050a819c 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getReadListSchemaMock } from './read_list_schema.mock'; -import { ReadListSchema, readListSchema } from './read_list_schema'; +import { getReadListSchemaMock } from './index.mock'; +import { ReadListSchema, readListSchema } from '.'; describe('read_list_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/read_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.ts similarity index 58% rename from x-pack/plugins/lists/common/schemas/request/read_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.ts index 5d850b19c4d11..0652caed1657a 100644 --- a/x-pack/plugins/lists/common/schemas/request/read_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/read_list_schema/index.ts @@ -1,12 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id } from '@kbn/securitysolution-io-ts-list-types'; + +import { id } from '../../common/id'; export const readListSchema = t.exact( t.type({ diff --git a/x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.mock.ts similarity index 68% rename from x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.mock.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.mock.ts index 61166e42bd4c2..1eae5ea29a0c5 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.mock.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.mock.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { @@ -16,9 +17,9 @@ import { NAME, OS_TYPES, TAGS, -} from '../../constants.mock'; +} from '../../constants/index.mock'; -import { UpdateEndpointListItemSchema } from './update_endpoint_list_item_schema'; +import { UpdateEndpointListItemSchema } from '.'; export const getUpdateEndpointListItemSchemaMock = (): UpdateEndpointListItemSchema => ({ _version: undefined, diff --git a/x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.test.ts similarity index 94% rename from x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.test.ts index b5bd8caea8f85..258f80890bf51 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - UpdateEndpointListItemSchema, - updateEndpointListItemSchema, -} from './update_endpoint_list_item_schema'; -import { getUpdateEndpointListItemSchemaMock } from './update_endpoint_list_item_schema.mock'; +import { UpdateEndpointListItemSchema, updateEndpointListItemSchema } from '.'; +import { getUpdateEndpointListItemSchemaMock } from './index.mock'; describe('update_endpoint_list_item_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.ts similarity index 58% rename from x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.ts index 011ff24b7fa22..8e5aa41e1fad2 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_endpoint_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_endpoint_list_item_schema/index.ts @@ -1,29 +1,26 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { - DefaultUpdateCommentsArray, - EntriesArray, - OsTypeArray, - Tags, - UpdateCommentsArray, - description, - exceptionListItemType, - id, - meta, - name, - nonEmptyEntriesArray, - osTypeArrayOrUndefined, - tags, -} from '@kbn/securitysolution-io-ts-list-types'; -import { _version } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { DefaultUpdateCommentsArray } from '../../common/default_update_comments_array'; +import { exceptionListItemType } from '../../common/exception_list_item_type'; +import { nonEmptyEntriesArray } from '../../common/non_empty_entries_array'; +import { OsTypeArray, osTypeArrayOrUndefined } from '../../common/os_type'; +import { description } from '../../common/description'; +import { name } from '../../common/name'; +import { _version } from '../../common/underscore_version'; +import { id } from '../../common/id'; +import { meta } from '../../common/meta'; +import { Tags, tags } from '../../common/tags'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { UpdateCommentsArray } from '../../common/update_comment'; +import { EntriesArray } from '../../common/entries'; export const updateEndpointListItemSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..507d570a679e1 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.mock.ts @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { + COMMENTS, + DESCRIPTION, + ENTRIES, + ID, + ITEM_ID, + ITEM_TYPE, + LIST_ITEM_ID, + META, + NAME, + NAMESPACE_TYPE, + OS_TYPES, + TAGS, +} from '../../constants/index.mock'; + +import { UpdateExceptionListItemSchema } from '.'; + +export const getUpdateExceptionListItemSchemaMock = (): UpdateExceptionListItemSchema => ({ + _version: undefined, + comments: COMMENTS, + description: DESCRIPTION, + entries: ENTRIES, + id: ID, + item_id: LIST_ITEM_ID, + meta: META, + name: NAME, + namespace_type: NAMESPACE_TYPE, + os_types: ['linux'], + tags: TAGS, + type: ITEM_TYPE, +}); + +/** + * Useful for end to end tests and other mechanisms which want to fill in the values + * after doing a get of the structure. + */ +export const getUpdateMinimalExceptionListItemSchemaMock = (): UpdateExceptionListItemSchema => ({ + description: DESCRIPTION, + entries: ENTRIES, + item_id: ITEM_ID, + name: NAME, + os_types: OS_TYPES, + type: ITEM_TYPE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.test.ts similarity index 95% rename from x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.test.ts index efcb4ecde1cbb..1a5aff0d1e3d7 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - UpdateExceptionListItemSchema, - updateExceptionListItemSchema, -} from './update_exception_list_item_schema'; -import { getUpdateExceptionListItemSchemaMock } from './update_exception_list_item_schema.mock'; +import { UpdateExceptionListItemSchema, updateExceptionListItemSchema } from '.'; +import { getUpdateExceptionListItemSchemaMock } from './index.mock'; describe('update_exception_list_item_schema', () => { test('it should validate a typical exception list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.ts similarity index 57% rename from x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.ts index 1c751dd3a8c83..2624f36329562 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_schema/index.ts @@ -1,30 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { - DefaultUpdateCommentsArray, - EntriesArray, - NamespaceType, - OsTypeArray, - Tags, - UpdateCommentsArray, - description, - exceptionListItemType, - id, - meta, - name, - nonEmptyEntriesArray, - osTypeArrayOrUndefined, - tags, -} from '@kbn/securitysolution-io-ts-list-types'; - -import { _version, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { NamespaceType } from '../../common/default_namespace'; +import { DefaultUpdateCommentsArray } from '../../common/default_update_comments_array'; +import { EntriesArray } from '../../common/entries'; +import { exceptionListItemType } from '../../common/exception_list_item_type'; +import { nonEmptyEntriesArray } from '../../common/non_empty_entries_array'; +import { OsTypeArray, osTypeArrayOrUndefined } from '../../common/os_type'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { Tags, tags } from '../../common/tags'; +import { UpdateCommentsArray } from '../../common/update_comment'; +import { description } from '../../common/description'; +import { name } from '../../common/name'; +import { _version } from '../../common/underscore_version'; +import { id } from '../../common/id'; +import { meta } from '../../common/meta'; +import { namespace_type } from '../../common/namespace_type'; export const updateExceptionListItemSchema = t.intersection([ t.exact( diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.test.ts similarity index 80% rename from x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.test.ts index c6228698a8cc2..fea25b1ca8a21 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.test.ts @@ -1,12 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { getUpdateExceptionListItemSchemaMock } from './update_exception_list_item_schema.mock'; -import { validateComments } from './update_exception_list_item_validation'; +import { validateComments } from '.'; +import { getUpdateExceptionListItemSchemaMock } from '../update_exception_list_item_schema/index.mock'; describe('update_exception_list_item_validation', () => { describe('#validateComments', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.ts similarity index 75% rename from x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.ts index 1cbd230d5a61b..72c418eb913a2 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_validation.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_item_validation/index.ts @@ -1,11 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ -import { UpdateExceptionListItemSchema } from './update_exception_list_item_schema'; +import { UpdateExceptionListItemSchema } from '../update_exception_list_item_schema'; export const validateComments = (item: UpdateExceptionListItemSchema): string[] => { if (item.comments == null) { diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.mock.ts new file mode 100644 index 0000000000000..34085752d137d --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.mock.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { DESCRIPTION, ID, LIST_ID, META, NAME, NAMESPACE_TYPE } from '../../constants/index.mock'; + +import { UpdateExceptionListSchema } from '.'; + +export const getUpdateExceptionListSchemaMock = (): UpdateExceptionListSchema => ({ + _version: undefined, + description: DESCRIPTION, + id: ID, + list_id: LIST_ID, + meta: META, + name: NAME, + namespace_type: NAMESPACE_TYPE, + os_types: [], + tags: ['malware'], + type: 'endpoint', +}); + +/** + * Useful for end to end tests and other mechanisms which want to fill in the values + * after doing a get of the structure. + */ +export const getUpdateMinimalExceptionListSchemaMock = (): UpdateExceptionListSchema => ({ + description: DESCRIPTION, + list_id: LIST_ID, + name: NAME, + type: 'endpoint', +}); diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.test.ts index 30966f8eafef3..599b091d33e58 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.test.ts @@ -1,19 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { - UpdateExceptionListSchema, - updateExceptionListSchema, -} from './update_exception_list_schema'; -import { getUpdateExceptionListSchemaMock } from './update_exception_list_schema.mock'; +import { UpdateExceptionListSchema, updateExceptionListSchema } from '.'; +import { getUpdateExceptionListSchemaMock } from './index.mock'; describe('update_exception_list_schema', () => { test('it should validate a typical exception list request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.ts similarity index 62% rename from x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.ts index 08f15f52977fd..ce0c16b26d1a4 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_exception_list_schema/index.ts @@ -1,27 +1,26 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { - NamespaceType, - OsTypeArray, - Tags, - description, - exceptionListType, - id, - meta, - name, - osTypeArrayOrUndefined, - tags, -} from '@kbn/securitysolution-io-ts-list-types'; -import { version } from '@kbn/securitysolution-io-ts-types'; -import { _version, list_id, namespace_type } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { version } from '@kbn/securitysolution-io-ts-types'; +import { OsTypeArray, osTypeArrayOrUndefined } from '../../common/os_type'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { Tags, tags } from '../../common/tags'; +import { NamespaceType } from '../../common/default_namespace'; +import { description } from '../../common/description'; +import { name } from '../../common/name'; +import { _version } from '../../common/underscore_version'; +import { exceptionListType } from '../../common/exception_list'; +import { id } from '../../common/id'; +import { list_id } from '../../common/list_id'; +import { meta } from '../../common/meta'; +import { namespace_type } from '../../common/namespace_type'; export const updateExceptionListSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..f296a96d59f19 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.mock.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ID, LIST_ITEM_ID, META, VALUE } from '../../constants/index.mock'; + +import { UpdateListItemSchema } from '.'; + +export const getUpdateListItemSchemaMock = (): UpdateListItemSchema => ({ + id: ID, + meta: META, + value: VALUE, +}); + +/** + * Useful for end to end testing + */ +export const getUpdateMinimalListItemSchemaMock = (): UpdateListItemSchema => ({ + id: LIST_ITEM_ID, + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.test.ts similarity index 85% rename from x-pack/plugins/lists/common/schemas/request/update_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.test.ts index 2775abd1ee8d0..37a534761cf2b 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { UpdateListItemSchema, updateListItemSchema } from './update_list_item_schema'; -import { getUpdateListItemSchemaMock } from './update_list_item_schema.mock'; +import { UpdateListItemSchema, updateListItemSchema } from '.'; +import { getUpdateListItemSchemaMock } from './index.mock'; describe('update_list_item_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.ts similarity index 59% rename from x-pack/plugins/lists/common/schemas/request/update_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.ts index f24902a12d3b7..e96a889dbaf53 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_item_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { id, meta } from '@kbn/securitysolution-io-ts-list-types'; -import { _version, value } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { _version } from '../../common/underscore_version'; +import { id } from '../../common/id'; +import { value } from '../../common/value'; +import { meta } from '../../common/meta'; export const updateListItemSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.mock.ts new file mode 100644 index 0000000000000..058378d262ff0 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.mock.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { DESCRIPTION, LIST_ID, META, NAME, _VERSION } from '../../constants/index.mock'; + +import { UpdateListSchema } from '.'; + +export const getUpdateListSchemaMock = (): UpdateListSchema => ({ + _version: _VERSION, + description: DESCRIPTION, + id: LIST_ID, + meta: META, + name: NAME, +}); + +/** + * Useful for end to end tests and other mechanisms which want to fill in the values + * after doing a get of the structure. + */ +export const getUpdateMinimalListSchemaMock = (): UpdateListSchema => ({ + description: DESCRIPTION, + id: LIST_ID, + name: NAME, +}); diff --git a/x-pack/plugins/lists/common/schemas/request/update_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.test.ts similarity index 85% rename from x-pack/plugins/lists/common/schemas/request/update_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.test.ts index b20aa4d774938..81152f4106f22 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { UpdateListSchema, updateListSchema } from './update_list_schema'; -import { getUpdateListSchemaMock } from './update_list_schema.mock'; +import { UpdateListSchema, updateListSchema } from '.'; +import { getUpdateListSchemaMock } from './index.mock'; describe('update_list_schema', () => { test('it should validate a typical list request', () => { diff --git a/x-pack/plugins/lists/common/schemas/request/update_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.ts similarity index 60% rename from x-pack/plugins/lists/common/schemas/request/update_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.ts index 253c4cec566f4..4847936d8e7a2 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/request/update_list_schema/index.ts @@ -1,16 +1,20 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { description, id, meta, name } from '@kbn/securitysolution-io-ts-list-types'; -import { version } from '@kbn/securitysolution-io-ts-types'; -import { _version } from '../common/schemas'; -import { RequiredKeepUndefined } from '../../types'; +import { version } from '@kbn/securitysolution-io-ts-types'; +import { RequiredKeepUndefined } from '../../common/required_keep_undefined'; +import { id } from '../../common/id'; +import { name } from '../../common/name'; +import { description } from '../../common/description'; +import { _version } from '../../common/underscore_version'; +import { meta } from '../../common/meta'; export const updateListSchema = t.intersection([ t.exact( diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.mock.ts new file mode 100644 index 0000000000000..28bdac2ffc5a7 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.mock.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { AcknowledgeSchema } from '.'; + +export const getAcknowledgeSchemaResponseMock = (): AcknowledgeSchema => ({ + acknowledged: true, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/response/acknowledge_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.test.ts index 54b312fcfdb37..d6ba92fa24919 100644 --- a/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getAcknowledgeSchemaResponseMock } from './acknowledge_schema.mock'; -import { AcknowledgeSchema, acknowledgeSchema } from './acknowledge_schema'; +import { getAcknowledgeSchemaResponseMock } from './index.mock'; +import { AcknowledgeSchema, acknowledgeSchema } from '.'; describe('acknowledge_schema', () => { test('it should validate a typical response', () => { diff --git a/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.ts similarity index 64% rename from x-pack/plugins/lists/common/schemas/response/acknowledge_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.ts index 97a0dc23682c4..f2513cf2ecc5d 100644 --- a/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/acknowledge_schema/index.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; diff --git a/x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.test.ts similarity index 91% rename from x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.test.ts index 1f38044409b2c..b2504ff1f5063 100644 --- a/x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getExceptionListSchemaMock } from './exception_list_schema.mock'; -import { CreateEndpointListSchema, createEndpointListSchema } from './create_endpoint_list_schema'; +import { CreateEndpointListSchema, createEndpointListSchema } from '.'; +import { getExceptionListSchemaMock } from '../exception_list_schema/index.mock'; describe('create_endpoint_list_schema', () => { test('it should validate a typical endpoint list response', () => { diff --git a/x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.ts similarity index 59% rename from x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.ts index 3b4f5a78dd927..0b3c77a20073e 100644 --- a/x-pack/plugins/lists/common/schemas/response/create_endpoint_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/create_endpoint_list_schema/index.ts @@ -1,13 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; - -import { exceptionListSchema } from './exception_list_schema'; +import { exceptionListSchema } from '../exception_list_schema'; export const createEndpointListSchema = t.union([exceptionListSchema, t.exact(t.type({}))]); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..2348584000475 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.mock.ts @@ -0,0 +1,69 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { + COMMENTS, + DATE_NOW, + DESCRIPTION, + ELASTIC_USER, + ENTRIES, + ITEM_ID, + ITEM_TYPE, + LIST_ID, + META, + NAME, + NAMESPACE_TYPE, + OS_TYPES, + TIE_BREAKER, + USER, +} from '../../constants/index.mock'; + +import { ExceptionListItemSchema } from '.'; + +export const getExceptionListItemSchemaMock = ( + overrides?: Partial +): ExceptionListItemSchema => ({ + _version: undefined, + comments: COMMENTS, + created_at: DATE_NOW, + created_by: USER, + description: DESCRIPTION, + entries: ENTRIES, + id: '1', + item_id: 'endpoint_list_item', + list_id: 'endpoint_list_id', + meta: META, + name: NAME, + namespace_type: NAMESPACE_TYPE, + os_types: ['linux'], + tags: ['user added string for a tag', 'malware'], + tie_breaker_id: TIE_BREAKER, + type: ITEM_TYPE, + updated_at: DATE_NOW, + updated_by: USER, + ...(overrides || {}), +}); + +/** + * This is useful for end to end tests where we remove the auto generated parts for comparisons + * such as created_at, updated_at, and id. + */ +export const getExceptionListItemResponseMockWithoutAutoGeneratedValues = (): Partial => ({ + comments: [], + created_by: ELASTIC_USER, + description: DESCRIPTION, + entries: ENTRIES, + item_id: ITEM_ID, + list_id: LIST_ID, + name: NAME, + namespace_type: 'single', + os_types: OS_TYPES, + tags: [], + type: ITEM_TYPE, + updated_by: ELASTIC_USER, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.test.ts similarity index 97% rename from x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.test.ts index b4809ee17b4bb..61471bd589f36 100644 --- a/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getExceptionListItemSchemaMock } from './exception_list_item_schema.mock'; -import { ExceptionListItemSchema, exceptionListItemSchema } from './exception_list_item_schema'; +import { getExceptionListItemSchemaMock } from './index.mock'; +import { ExceptionListItemSchema, exceptionListItemSchema } from '.'; describe('exception_list_item_schema', () => { test('it should validate a typical exception list item response', () => { diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.ts new file mode 100644 index 0000000000000..d2fc52b38f95b --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_item_schema/index.ts @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +import { namespace_type } from '../../common/namespace_type'; +import { metaOrUndefined } from '../../common/meta'; +import { name } from '../../common/name'; +import { created_at } from '../../common/created_at'; +import { created_by } from '../../common/created_by'; +import { id } from '../../common/id'; +import { tie_breaker_id } from '../../common/tie_breaker_id'; +import { updated_at } from '../../common/updated_at'; +import { updated_by } from '../../common/updated_by'; +import { list_id } from '../../common/list_id'; +import { description } from '../../common/description'; +import { osTypeArray } from '../../common/os_type'; +import { tags } from '../../common/tags'; +import { _versionOrUndefined } from '../../common/underscore_version'; +import { commentsArray } from '../../common/comment'; +import { entriesArray } from '../../common/entries'; +import { item_id } from '../../common/item_id'; +import { exceptionListItemType } from '../../common/exception_list_item_type'; + +export const exceptionListItemSchema = t.exact( + t.type({ + _version: _versionOrUndefined, + comments: commentsArray, + created_at, + created_by, + description, + entries: entriesArray, + id, + item_id, + list_id, + meta: metaOrUndefined, + name, + namespace_type, + os_types: osTypeArray, + tags, + tie_breaker_id, + type: exceptionListItemType, + updated_at, + updated_by, + }) +); + +export type ExceptionListItemSchema = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.mock.ts new file mode 100644 index 0000000000000..5928c420c88e3 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.mock.ts @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { + DATE_NOW, + DESCRIPTION, + ELASTIC_USER, + ENDPOINT_TYPE, + IMMUTABLE, + LIST_ID, + META, + NAME, + TIE_BREAKER, + USER, + VERSION, + _VERSION, +} from '../../constants/index.mock'; +import { + ENDPOINT_LIST_ID, + ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION, + ENDPOINT_TRUSTED_APPS_LIST_ID, + ENDPOINT_TRUSTED_APPS_LIST_NAME, +} from '../..'; + +import { ExceptionListSchema } from '.'; + +export const getExceptionListSchemaMock = (): ExceptionListSchema => ({ + _version: _VERSION, + created_at: DATE_NOW, + created_by: USER, + description: DESCRIPTION, + id: '1', + immutable: IMMUTABLE, + list_id: ENDPOINT_LIST_ID, + meta: META, + name: 'Sample Endpoint Exception List', + namespace_type: 'agnostic', + os_types: ['linux'], + tags: ['user added string for a tag', 'malware'], + tie_breaker_id: TIE_BREAKER, + type: ENDPOINT_TYPE, + updated_at: DATE_NOW, + updated_by: 'user_name', + version: VERSION, +}); + +export const getTrustedAppsListSchemaMock = (): ExceptionListSchema => { + return { + ...getExceptionListSchemaMock(), + description: ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION, + list_id: ENDPOINT_TRUSTED_APPS_LIST_ID, + name: ENDPOINT_TRUSTED_APPS_LIST_NAME, + }; +}; + +/** + * This is useful for end to end tests where we remove the auto generated parts for comparisons + * such as created_at, updated_at, and id. + */ +export const getExceptionResponseMockWithoutAutoGeneratedValues = (): Partial => ({ + created_by: ELASTIC_USER, + description: DESCRIPTION, + immutable: IMMUTABLE, + list_id: LIST_ID, + name: NAME, + namespace_type: 'single', + os_types: [], + tags: [], + type: ENDPOINT_TYPE, + updated_by: ELASTIC_USER, + version: VERSION, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.test.ts similarity index 95% rename from x-pack/plugins/lists/common/schemas/response/exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.test.ts index ef2b639ba2f06..2f8a212ba8a06 100644 --- a/x-pack/plugins/lists/common/schemas/response/exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getExceptionListSchemaMock } from './exception_list_schema.mock'; -import { ExceptionListSchema, exceptionListSchema } from './exception_list_schema'; +import { getExceptionListSchemaMock } from './index.mock'; +import { ExceptionListSchema, exceptionListSchema } from '.'; describe('exception_list_schema', () => { test('it should validate a typical exception list response', () => { diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.ts new file mode 100644 index 0000000000000..11912d0ced461 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/exception_list_schema/index.ts @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +import { version } from '@kbn/securitysolution-io-ts-types'; +import { _versionOrUndefined } from '../../common/underscore_version'; +import { namespace_type } from '../../common/namespace_type'; +import { metaOrUndefined } from '../../common/meta'; +import { name } from '../../common/name'; +import { created_at } from '../../common/created_at'; +import { created_by } from '../../common/created_by'; +import { id } from '../../common/id'; +import { tie_breaker_id } from '../../common/tie_breaker_id'; +import { immutable } from '../../common/immutable'; +import { updated_at } from '../../common/updated_at'; +import { updated_by } from '../../common/updated_by'; +import { list_id } from '../../common/list_id'; +import { description } from '../../common/description'; +import { osTypeArray } from '../../common/os_type'; +import { exceptionListType } from '../../common/exception_list'; +import { tags } from '../../common/tags'; + +export const exceptionListSchema = t.exact( + t.type({ + _version: _versionOrUndefined, + created_at, + created_by, + description, + id, + immutable, + list_id, + meta: metaOrUndefined, + name, + namespace_type, + os_types: osTypeArray, + tags, + tie_breaker_id, + type: exceptionListType, + updated_at, + updated_by, + version, + }) +); + +export type ExceptionListSchema = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..d683b833634dc --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FoundExceptionListItemSchema } from '.'; +import { getExceptionListItemSchemaMock } from '../exception_list_item_schema/index.mock'; + +export const getFoundExceptionListItemSchemaMock = (): FoundExceptionListItemSchema => ({ + data: [getExceptionListItemSchemaMock()], + page: 1, + per_page: 1, + total: 1, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.test.ts similarity index 92% rename from x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.test.ts index b04d9fbdad3b7..8ec83d4927370 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.test.ts @@ -1,21 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getExceptionListItemSchemaMock } from './exception_list_item_schema.mock'; -import { getFoundExceptionListItemSchemaMock } from './found_exception_list_item_schema.mock'; -import { - FoundExceptionListItemSchema, - foundExceptionListItemSchema, -} from './found_exception_list_item_schema'; -import { ExceptionListItemSchema } from './exception_list_item_schema'; +import { getFoundExceptionListItemSchemaMock } from './index.mock'; +import { FoundExceptionListItemSchema, foundExceptionListItemSchema } from '.'; +import { ExceptionListItemSchema } from '../exception_list_item_schema'; +import { getExceptionListItemSchemaMock } from '../exception_list_item_schema/index.mock'; describe('found_exception_list_item_schema', () => { test('it should validate a typical exception list response', () => { diff --git a/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.ts similarity index 52% rename from x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.ts index f62f6c7248328..df82a70ef626c 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_item_schema/index.ts @@ -1,15 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { page, per_page, total } from '../common/schemas'; - -import { exceptionListItemSchema } from './exception_list_item_schema'; +import { page } from '../../common/page'; +import { per_page } from '../../common/per_page'; +import { total } from '../../common/total'; +import { exceptionListItemSchema } from '../exception_list_item_schema'; export const foundExceptionListItemSchema = t.exact( t.type({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.mock.ts new file mode 100644 index 0000000000000..4017d30a59224 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.mock.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FoundExceptionListSchema } from '.'; +import { getExceptionListSchemaMock } from '../exception_list_schema/index.mock'; + +export const getFoundExceptionListSchemaMock = (): FoundExceptionListSchema => ({ + data: [getExceptionListSchemaMock()], + page: 1, + per_page: 1, + total: 1, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.test.ts similarity index 93% rename from x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.test.ts index cebf8ccc5d0d3..d37af8c289325 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.test.ts @@ -1,18 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getExceptionListSchemaMock } from './exception_list_schema.mock'; -import { getFoundExceptionListSchemaMock } from './found_exception_list_schema.mock'; -import { FoundExceptionListSchema, foundExceptionListSchema } from './found_exception_list_schema'; -import { ExceptionListSchema } from './exception_list_schema'; +import { getFoundExceptionListSchemaMock } from './index.mock'; +import { FoundExceptionListSchema, foundExceptionListSchema } from '.'; +import { getExceptionListSchemaMock } from '../exception_list_schema/index.mock'; +import { ExceptionListSchema } from '../exception_list_schema'; describe('exception_list_schema', () => { test('it should validate a typical exception list response', () => { diff --git a/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.ts similarity index 52% rename from x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.ts index 501a88d68b7cf..4e430f607fb04 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_exception_list_schema/index.ts @@ -1,15 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; -import { page, per_page, total } from '../common/schemas'; +import { page } from '../../common/page'; +import { per_page } from '../../common/per_page'; +import { total } from '../../common/total'; -import { exceptionListSchema } from './exception_list_schema'; +import { exceptionListSchema } from '../exception_list_schema'; export const foundExceptionListSchema = t.exact( t.type({ diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..a5b0ba9160383 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.mock.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FoundListItemSchema } from '.'; +import { getListItemResponseMock } from '../list_item_schema/index.mock'; + +export const getFoundListItemSchemaMock = (): FoundListItemSchema => ({ + cursor: 'WzI1LFsiNmE3NmI2OWQtODBkZi00YWIyLThjM2UtODVmNDY2YjA2YTBlIl1d', + data: [getListItemResponseMock()], + page: 1, + per_page: 25, + total: 1, +}); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.ts new file mode 100644 index 0000000000000..44a3a6f131063 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_item_schema/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +import { listItemSchema } from '../list_item_schema'; +import { cursor } from '../../common/cursor'; +import { page } from '../../common/page'; +import { per_page } from '../../common/per_page'; +import { total } from '../../common/total'; + +export const foundListItemSchema = t.exact( + t.type({ + cursor, + data: t.array(listItemSchema), + page, + per_page, + total, + }) +); + +export type FoundListItemSchema = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.mock.ts new file mode 100644 index 0000000000000..ed54383602bd8 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.mock.ts @@ -0,0 +1,18 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { FoundListSchema } from '.'; +import { getListResponseMock } from '../list_schema/index.mock'; + +export const getFoundListSchemaMock = (): FoundListSchema => ({ + cursor: '123', + data: [getListResponseMock()], + page: 1, + per_page: 1, + total: 1, +}); diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.ts new file mode 100644 index 0000000000000..4fd8bab462828 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/found_list_schema/index.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +import { listSchema } from '../list_schema'; +import { cursor } from '../../common/cursor'; +import { page } from '../../common/page'; +import { per_page } from '../../common/per_page'; +import { total } from '../../common/total'; + +export const foundListSchema = t.exact( + t.type({ + cursor, + data: t.array(listSchema), + page, + per_page, + total, + }) +); + +export type FoundListSchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/index.ts similarity index 78% rename from x-pack/plugins/lists/common/schemas/response/index.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/index.ts index be67c6f59a66c..005e753ccf1b3 100644 --- a/x-pack/plugins/lists/common/schemas/response/index.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/index.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ export * from './acknowledge_schema'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.mock.ts new file mode 100644 index 0000000000000..4e2f12ca6fa86 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.mock.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ListItemIndexExistSchema } from '.'; + +export const getListItemIndexExistSchemaResponseMock = (): ListItemIndexExistSchema => ({ + list_index: true, + list_item_index: true, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.test.ts similarity index 90% rename from x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.test.ts index 4a0592d49228e..ed2e426fb08dd 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getListItemIndexExistSchemaResponseMock } from './list_item_index_exist_schema.mock'; -import { ListItemIndexExistSchema, listItemIndexExistSchema } from './list_item_index_exist_schema'; +import { getListItemIndexExistSchemaResponseMock } from './index.mock'; +import { ListItemIndexExistSchema, listItemIndexExistSchema } from '.'; describe('list_item_index_exist_schema', () => { test('it should validate a typical list item request', () => { diff --git a/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.ts similarity index 68% rename from x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.ts index fb1070f72daea..9c17823c4bbc6 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_index_exist_schema/index.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..33d3b49cf5492 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.mock.ts @@ -0,0 +1,48 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ListItemSchema } from '.'; +import { + DATE_NOW, + ELASTIC_USER, + LIST_ID, + LIST_ITEM_ID, + META, + TIE_BREAKER, + TYPE, + USER, + VALUE, +} from '../../constants/index.mock'; + +export const getListItemResponseMock = (): ListItemSchema => ({ + _version: undefined, + created_at: DATE_NOW, + created_by: USER, + deserializer: undefined, + id: LIST_ITEM_ID, + list_id: LIST_ID, + meta: META, + serializer: undefined, + tie_breaker_id: TIE_BREAKER, + type: TYPE, + updated_at: DATE_NOW, + updated_by: USER, + value: VALUE, +}); + +/** + * This is useful for end to end tests where we remove the auto generated parts for comparisons + * such as created_at, updated_at, and id. + */ +export const getListItemResponseMockWithoutAutoGeneratedValues = (): Partial => ({ + created_by: ELASTIC_USER, + list_id: LIST_ID, + type: TYPE, + updated_by: ELASTIC_USER, + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.test.ts similarity index 95% rename from x-pack/plugins/lists/common/schemas/response/list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.test.ts index ffe49f305d484..942a2b478639e 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getListItemResponseMock } from './list_item_schema.mock'; -import { ListItemSchema, listItemSchema } from './list_item_schema'; +import { getListItemResponseMock } from './index.mock'; +import { ListItemSchema, listItemSchema } from '.'; describe('list_item_schema', () => { test('it should validate a typical list item response', () => { diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.ts new file mode 100644 index 0000000000000..ae75f3a7741bc --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_item_schema/index.ts @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; + +import { _versionOrUndefined } from '../../common/underscore_version'; +import { deserializerOrUndefined } from '../../common/deserializer'; +import { metaOrUndefined } from '../../common/meta'; +import { serializerOrUndefined } from '../../common/serializer'; +import { created_at } from '../../common/created_at'; +import { created_by } from '../../common/created_by'; +import { id } from '../../common/id'; +import { tie_breaker_id } from '../../common/tie_breaker_id'; +import { type } from '../../common/type'; +import { updated_at } from '../../common/updated_at'; +import { updated_by } from '../../common/updated_by'; +import { list_id } from '../../common/list_id'; +import { value } from '../../common/value'; + +export const listItemSchema = t.exact( + t.type({ + _version: _versionOrUndefined, + created_at, + created_by, + deserializer: deserializerOrUndefined, + id, + list_id, + meta: metaOrUndefined, + serializer: serializerOrUndefined, + tie_breaker_id, + type, + updated_at, + updated_by, + value, + }) +); + +export type ListItemSchema = t.TypeOf; + +export const listItemArraySchema = t.array(listItemSchema); +export type ListItemArraySchema = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.mock.ts new file mode 100644 index 0000000000000..3c78c0cdbc976 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.mock.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ListSchema } from '.'; +import { + DATE_NOW, + DESCRIPTION, + ELASTIC_USER, + IMMUTABLE, + LIST_ID, + META, + NAME, + TIE_BREAKER, + TYPE, + USER, + VERSION, +} from '../../constants/index.mock'; + +export const getListResponseMock = (): ListSchema => ({ + _version: undefined, + created_at: DATE_NOW, + created_by: USER, + description: DESCRIPTION, + deserializer: undefined, + id: LIST_ID, + immutable: IMMUTABLE, + meta: META, + name: NAME, + serializer: undefined, + tie_breaker_id: TIE_BREAKER, + type: TYPE, + updated_at: DATE_NOW, + updated_by: USER, + version: VERSION, +}); + +/** + * This is useful for end to end tests where we remove the auto generated parts for comparisons + * such as created_at, updated_at, and id. + */ +export const getListResponseMockWithoutAutoGeneratedValues = (): Partial => ({ + created_by: ELASTIC_USER, + description: DESCRIPTION, + immutable: IMMUTABLE, + name: NAME, + type: TYPE, + updated_by: ELASTIC_USER, + version: VERSION, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/list_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.test.ts similarity index 95% rename from x-pack/plugins/lists/common/schemas/response/list_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.test.ts index 294f7da9a098f..f83dce410ebec 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getListResponseMock } from './list_schema.mock'; -import { ListSchema, listSchema } from './list_schema'; +import { getListResponseMock } from './index.mock'; +import { ListSchema, listSchema } from '.'; describe('list_schema', () => { test('it should validate a typical list response', () => { diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.ts new file mode 100644 index 0000000000000..9db686e6de255 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/list_schema/index.ts @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import * as t from 'io-ts'; +import { version } from '@kbn/securitysolution-io-ts-types'; +import { _versionOrUndefined } from '../../common/underscore_version'; +import { deserializerOrUndefined } from '../../common/deserializer'; +import { metaOrUndefined } from '../../common/meta'; +import { serializerOrUndefined } from '../../common/serializer'; +import { created_at } from '../../common/created_at'; +import { created_by } from '../../common/created_by'; +import { description } from '../../common/description'; +import { id } from '../../common/id'; +import { immutable } from '../../common/immutable'; +import { name } from '../../common/name'; +import { tie_breaker_id } from '../../common/tie_breaker_id'; +import { type } from '../../common/type'; +import { updated_at } from '../../common/updated_at'; +import { updated_by } from '../../common/updated_by'; + +export const listSchema = t.exact( + t.type({ + _version: _versionOrUndefined, + created_at, + created_by, + description, + deserializer: deserializerOrUndefined, + id, + immutable, + meta: metaOrUndefined, + name, + serializer: serializerOrUndefined, + tie_breaker_id, + type, + updated_at, + updated_by, + version, + }) +); + +export type ListSchema = t.TypeOf; + +export const listArraySchema = t.array(listSchema); +export type ListArraySchema = t.TypeOf; diff --git a/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.mock.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.mock.ts new file mode 100644 index 0000000000000..e4ba46ad8e4a1 --- /dev/null +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.mock.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { SearchListItemSchema } from '.'; +import { VALUE } from '../../constants/index.mock'; +import { getListItemResponseMock } from '../list_item_schema/index.mock'; + +export const getSearchListItemResponseMock = (): SearchListItemSchema => ({ + items: [getListItemResponseMock()], + value: VALUE, +}); diff --git a/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.test.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.test.ts similarity index 84% rename from x-pack/plugins/lists/common/schemas/response/search_list_item_schema.test.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.test.ts index 4919e6a5ca73c..b6cb49abe711e 100644 --- a/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.test.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.test.ts @@ -1,16 +1,17 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; -import { getSearchListItemResponseMock } from './search_list_item_schema.mock'; -import { SearchListItemSchema, searchListItemSchema } from './search_list_item_schema'; +import { getSearchListItemResponseMock } from './index.mock'; +import { SearchListItemSchema, searchListItemSchema } from '.'; describe('search_list_item_schema', () => { test('it should validate a typical search list item response', () => { @@ -24,7 +25,6 @@ describe('search_list_item_schema', () => { }); test('it should NOT validate with an "undefined" for "items"', () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const { items, ...noItems } = getSearchListItemResponseMock(); const decoded = searchListItemSchema.decode(noItems); const checked = exactCheck(noItems, decoded); diff --git a/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.ts b/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.ts similarity index 76% rename from x-pack/plugins/lists/common/schemas/response/search_list_item_schema.ts rename to packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.ts index 0317f1786f947..a2256d1136632 100644 --- a/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.ts +++ b/packages/kbn-securitysolution-io-ts-list-types/src/response/search_list_item_schema/index.ts @@ -1,13 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import * as t from 'io-ts'; - -import { listItemArraySchema } from './list_item_schema'; +import { listItemArraySchema } from '../list_item_schema'; /** * NOTE: Although this is defined within "response" this does not expose a REST API diff --git a/packages/kbn-securitysolution-list-utils/BUILD.bazel b/packages/kbn-securitysolution-list-utils/BUILD.bazel new file mode 100644 index 0000000000000..f79a2ffb21c54 --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/BUILD.bazel @@ -0,0 +1,87 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") + +PKG_BASE_NAME = "kbn-securitysolution-list-utils" + +PKG_REQUIRE_NAME = "@kbn/securitysolution-list-utils" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + ], + exclude = [ + "**/*.test.*", + "**/*.mock.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", + "README.md", +] + +SRC_DEPS = [ + "//packages/kbn-i18n", + "//packages/kbn-securitysolution-io-ts-list-types", + "//packages/kbn-securitysolution-utils", + "@npm//tslib", +] + +TYPES_DEPS = [ + "@npm//@types/jest", + "@npm//@types/node", +] + +DEPS = SRC_DEPS + TYPES_DEPS + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + ], +) + +ts_project( + name = "tsc", + srcs = SRCS, + args = ["--pretty"], + declaration = True, + declaration_map = True, + incremental = True, + out_dir = "target", + root_dir = "src", + source_map = True, + tsconfig = ":tsconfig", + deps = DEPS, +) + +js_library( + name = PKG_BASE_NAME, + package_name = PKG_REQUIRE_NAME, + srcs = NPM_MODULE_EXTRA_FILES, + visibility = ["//visibility:public"], + deps = [":tsc"] + DEPS, +) + +pkg_npm( + name = "npm_module", + deps = [ + ":%s" % PKG_BASE_NAME, + ], +) + +filegroup( + name = "build", + srcs = [ + ":npm_module", + ], + visibility = ["//visibility:public"], +) diff --git a/packages/kbn-securitysolution-list-utils/README.md b/packages/kbn-securitysolution-list-utils/README.md new file mode 100644 index 0000000000000..49826ccdfdf6d --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/README.md @@ -0,0 +1,5 @@ +# kbn-securitysolution-list-utils + +This is where front and backend utilities exist for lists + + diff --git a/packages/kbn-securitysolution-list-utils/jest.config.js b/packages/kbn-securitysolution-list-utils/jest.config.js new file mode 100644 index 0000000000000..1642bae6a4814 --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/jest.config.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../..', + roots: ['/packages/kbn-securitysolution-list-utils'], +}; diff --git a/packages/kbn-securitysolution-list-utils/package.json b/packages/kbn-securitysolution-list-utils/package.json new file mode 100644 index 0000000000000..efd1401ab4332 --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/package.json @@ -0,0 +1,9 @@ +{ + "name": "@kbn/securitysolution-list-utils", + "version": "1.0.0", + "description": "security solution list utilities", + "license": "SSPL-1.0 OR Elastic License 2.0", + "main": "./target/index.js", + "types": "./target/index.d.ts", + "private": true +} diff --git a/x-pack/plugins/lists/public/exceptions/components/autocomplete/operators.ts b/packages/kbn-securitysolution-list-utils/src/autocomplete_operators/index.ts similarity index 76% rename from x-pack/plugins/lists/public/exceptions/components/autocomplete/operators.ts rename to packages/kbn-securitysolution-list-utils/src/autocomplete_operators/index.ts index 83a424d72ec5f..967cebc360f61 100644 --- a/x-pack/plugins/lists/public/exceptions/components/autocomplete/operators.ts +++ b/packages/kbn-securitysolution-list-utils/src/autocomplete_operators/index.ts @@ -1,8 +1,9 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import { i18n } from '@kbn/i18n'; @@ -14,7 +15,7 @@ import { import { OperatorOption } from './types'; export const isOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.isOperatorLabel', { + message: i18n.translate('lists.exceptions.isOperatorLabel', { defaultMessage: 'is', }), operator: OperatorEnum.INCLUDED, @@ -23,7 +24,7 @@ export const isOperator: OperatorOption = { }; export const isNotOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.isNotOperatorLabel', { + message: i18n.translate('lists.exceptions.isNotOperatorLabel', { defaultMessage: 'is not', }), operator: OperatorEnum.EXCLUDED, @@ -32,7 +33,7 @@ export const isNotOperator: OperatorOption = { }; export const isOneOfOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.isOneOfOperatorLabel', { + message: i18n.translate('lists.exceptions.isOneOfOperatorLabel', { defaultMessage: 'is one of', }), operator: OperatorEnum.INCLUDED, @@ -41,7 +42,7 @@ export const isOneOfOperator: OperatorOption = { }; export const isNotOneOfOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.isNotOneOfOperatorLabel', { + message: i18n.translate('lists.exceptions.isNotOneOfOperatorLabel', { defaultMessage: 'is not one of', }), operator: OperatorEnum.EXCLUDED, @@ -50,7 +51,7 @@ export const isNotOneOfOperator: OperatorOption = { }; export const existsOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.existsOperatorLabel', { + message: i18n.translate('lists.exceptions.existsOperatorLabel', { defaultMessage: 'exists', }), operator: OperatorEnum.INCLUDED, @@ -59,7 +60,7 @@ export const existsOperator: OperatorOption = { }; export const doesNotExistOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.doesNotExistOperatorLabel', { + message: i18n.translate('lists.exceptions.doesNotExistOperatorLabel', { defaultMessage: 'does not exist', }), operator: OperatorEnum.EXCLUDED, @@ -68,7 +69,7 @@ export const doesNotExistOperator: OperatorOption = { }; export const isInListOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.isInListOperatorLabel', { + message: i18n.translate('lists.exceptions.isInListOperatorLabel', { defaultMessage: 'is in list', }), operator: OperatorEnum.INCLUDED, @@ -77,7 +78,7 @@ export const isInListOperator: OperatorOption = { }; export const isNotInListOperator: OperatorOption = { - message: i18n.translate('xpack.lists.exceptions.isNotInListOperatorLabel', { + message: i18n.translate('lists.exceptions.isNotInListOperatorLabel', { defaultMessage: 'is not in list', }), operator: OperatorEnum.EXCLUDED, diff --git a/packages/kbn-securitysolution-list-utils/src/autocomplete_operators/types.ts b/packages/kbn-securitysolution-list-utils/src/autocomplete_operators/types.ts new file mode 100644 index 0000000000000..1be21bb62a7fe --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/src/autocomplete_operators/types.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 + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { + ListOperatorEnum as OperatorEnum, + ListOperatorTypeEnum as OperatorTypeEnum, +} from '@kbn/securitysolution-io-ts-list-types'; + +export interface OperatorOption { + message: string; + value: string; + operator: OperatorEnum; + type: OperatorTypeEnum; +} diff --git a/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts b/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts new file mode 100644 index 0000000000000..e0cab13b44521 --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/src/helpers/index.test.ts @@ -0,0 +1,15 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +describe('Exception builder helpers', () => { + test('we should port these tests', () => { + // See the file outside of this at: x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts + // for the tests. We cannot port the tests over until we move the mocks into their own package + // and possibly core mocks end up within packages. + expect(true).toBe(true); + }); +}); diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/helpers.ts b/packages/kbn-securitysolution-list-utils/src/helpers/index.ts similarity index 94% rename from x-pack/plugins/lists/public/exceptions/components/builder/helpers.ts rename to packages/kbn-securitysolution-list-utils/src/helpers/index.ts index c4052acda6045..a483da152ac89 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/helpers.ts +++ b/packages/kbn-securitysolution-list-utils/src/helpers/index.ts @@ -1,36 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import uuid from 'uuid'; import { addIdToItem, removeIdFromItem } from '@kbn/securitysolution-utils'; import { validate } from '@kbn/securitysolution-io-ts-utils'; import { + CreateExceptionListItemSchema, EntriesArray, Entry, EntryNested, + ExceptionListItemSchema, ExceptionListType, + ListSchema, NamespaceType, ListOperatorEnum as OperatorEnum, ListOperatorTypeEnum as OperatorTypeEnum, OsTypeArray, + createExceptionListItemSchema, entriesList, entriesNested, entry, + exceptionListItemSchema, nestedEntryItem, } from '@kbn/securitysolution-io-ts-list-types'; -import { - CreateExceptionListItemSchema, - ExceptionListItemSchema, - ListSchema, - createExceptionListItemSchema, - exceptionListItemSchema, -} from '../../../../common/schemas'; -import { IFieldType, IIndexPattern } from '../../../../../../../src/plugins/data/public'; +// TODO: I have to use any here for now, but once this is available below, we should use the correct types +// import { IFieldType, IIndexPattern } from '../../../../../../../src/plugins/data/public'; +type IFieldType = any; +type IIndexPattern = any; + import { EXCEPTION_OPERATORS, EXCEPTION_OPERATORS_SANS_LISTS, @@ -39,8 +42,8 @@ import { isNotOperator, isOneOfOperator, isOperator, -} from '../autocomplete/operators'; -import { OperatorOption } from '../autocomplete/types'; +} from '../autocomplete_operators'; +import { OperatorOption } from '../autocomplete_operators/types'; import { BuilderEntry, @@ -49,7 +52,7 @@ import { EmptyNestedEntry, ExceptionsBuilderExceptionItem, FormattedBuilderEntry, -} from './types'; +} from '../types'; export const isEntryNested = (item: BuilderEntry): item is EntryNested => { return (item as EntryNested).entries != null; @@ -97,7 +100,6 @@ export const filterExceptionItems = ( if (exceptionListItemSchema.is(item)) { return [...acc, item]; } else if (createExceptionListItemSchema.is(item)) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const { meta, ...rest } = item; const itemSansMetaId: CreateExceptionListItemSchema = { ...rest, meta: undefined }; return [...acc, itemSansMetaId]; @@ -187,7 +189,7 @@ export const getExceptionOperatorSelect = (item: BuilderEntry): OperatorOption = return item.operator === operatorOption.operator && operatorType === operatorOption.type; }); - return foundOperator ?? isOperator; + return foundOperator != null ? foundOperator : isOperator; } }; @@ -225,7 +227,8 @@ export const getUpdatedEntriesOnDelete = ( entryIndex: number, nestedParentIndex: number | null ): ExceptionsBuilderExceptionItem => { - const itemOfInterest: BuilderEntry = exceptionItem.entries[nestedParentIndex ?? entryIndex]; + const itemOfInterest: BuilderEntry = + exceptionItem.entries[nestedParentIndex != null ? nestedParentIndex : entryIndex]; if (nestedParentIndex != null && itemOfInterest.type === OperatorTypeEnum.NESTED) { const updatedEntryEntries = [ @@ -246,7 +249,7 @@ export const getUpdatedEntriesOnDelete = ( const updatedItemOfInterest: EntryNested | EmptyNestedEntry = { entries: updatedEntryEntries, field, - id: itemOfInterest.id ?? `${entryIndex}`, + id: itemOfInterest.id != null ? itemOfInterest.id : `${entryIndex}`, type: OperatorTypeEnum.NESTED, }; @@ -293,6 +296,7 @@ export const getFilteredIndexPatterns = ( return { ...indexPatterns, fields: indexPatterns.fields + // @ts-expect-error This will go away once we type IField from any .filter((indexField) => { const fieldHasCommonParentPath = indexField.subType != null && @@ -302,6 +306,7 @@ export const getFilteredIndexPatterns = ( return fieldHasCommonParentPath; }) + // @ts-expect-error This will go away once we type IField from any .map((f) => { const [fieldNameWithoutParentPath] = f.name.split('.').slice(-1); return { ...f, name: fieldNameWithoutParentPath }; @@ -315,6 +320,7 @@ export const getFilteredIndexPatterns = ( return { ...indexPatterns, fields: indexPatterns.fields.filter( + // @ts-expect-error This will go away once we type IField from any (field) => field.subType != null && field.subType.nested != null ), }; @@ -353,7 +359,7 @@ export const getEntryOnFieldChange = ( updatedEntry: { entries: [ addIdToItem({ - field: newChildFieldValue ?? '', + field: newChildFieldValue != null ? newChildFieldValue : '', operator: isOperator.operator, type: OperatorTypeEnum.MATCH, value: '', @@ -372,7 +378,7 @@ export const getEntryOnFieldChange = ( entries: [ ...parent.parent.entries.slice(0, entryIndex), { - field: newChildFieldValue ?? '', + field: newChildFieldValue != null ? newChildFieldValue : '', id: item.id, operator: isOperator.operator, type: OperatorTypeEnum.MATCH, @@ -685,6 +691,7 @@ export const getFormattedBuilderEntry = ( ): FormattedBuilderEntry => { const { fields } = indexPattern; const field = parent != null ? `${parent.field}.${item.field}` : item.field; + // @ts-expect-error This will go away once we type IField from any const [foundField] = fields.filter(({ name }) => field != null && field === name); const correspondingKeywordField = getCorrespondingKeywordField({ fields, @@ -699,7 +706,7 @@ export const getFormattedBuilderEntry = ( foundField != null ? { ...foundField, name: foundField.name.split('.').slice(-1)[0] } : foundField, - id: item.id ?? `${itemIndex}`, + id: item.id != null ? item.id : `${itemIndex}`, nested: 'child', operator: getExceptionOperatorSelect(item), parent: { parent, parentIndex }, @@ -710,7 +717,7 @@ export const getFormattedBuilderEntry = ( correspondingKeywordField, entryIndex: itemIndex, field: foundField, - id: item.id ?? `${itemIndex}`, + id: item.id != null ? item.id : `${itemIndex}`, nested: undefined, operator: getExceptionOperatorSelect(item), parent: undefined, @@ -757,11 +764,11 @@ export const getFormattedBuilderEntries = ( : { aggregatable: false, esTypes: ['nested'], - name: item.field ?? '', + name: item.field != null ? item.field : '', searchable: false, type: 'string', }, - id: item.id ?? `${index}`, + id: item.id != null ? item.id : `${index}`, nested: 'parent', operator: isOperator, parent: undefined, diff --git a/packages/kbn-securitysolution-list-utils/src/index.ts b/packages/kbn-securitysolution-list-utils/src/index.ts new file mode 100644 index 0000000000000..55dd47d00e4da --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/src/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +export * from './autocomplete_operators'; +export * from './helpers'; +export * from './types'; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/types.ts b/packages/kbn-securitysolution-list-utils/src/types/index.ts similarity index 81% rename from x-pack/plugins/lists/public/exceptions/components/builder/types.ts rename to packages/kbn-securitysolution-list-utils/src/types/index.ts index 5cf4238ab5e0c..c8603fa01157c 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/types.ts +++ b/packages/kbn-securitysolution-list-utils/src/types/index.ts @@ -1,24 +1,31 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. */ import type { + CreateExceptionListItemSchema, Entry, EntryExists, EntryMatch, EntryMatchAny, EntryMatchWildcard, EntryNested, + ExceptionListItemSchema, ListOperatorEnum as OperatorEnum, ListOperatorTypeEnum as OperatorTypeEnum, } from '@kbn/securitysolution-io-ts-list-types'; -import type { CreateExceptionListItemSchema, ExceptionListItemSchema } from '../../../../common'; -import { IFieldType } from '../../../../../../../src/plugins/data/common'; -import { OperatorOption } from '../autocomplete/types'; +import type { OperatorOption } from '../autocomplete_operators/types'; + +/** + * @deprecated Use the one from core once it is in its own package which will be from: + * Original import was // import { IFieldType } from '../../../../../../../src/plugins/data/common'; + */ +type IFieldType = any; export interface FormattedBuilderEntry { id: string; diff --git a/packages/kbn-securitysolution-list-utils/tsconfig.json b/packages/kbn-securitysolution-list-utils/tsconfig.json new file mode 100644 index 0000000000000..c462159445894 --- /dev/null +++ b/packages/kbn-securitysolution-list-utils/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "incremental": true, + "outDir": "target", + "rootDir": "src", + "sourceMap": true, + "sourceRoot": "../../../../packages/kbn-securitysolution-list-utils/src", + "types": [ + "jest", + "node" + ] + }, + "include": [ + "src/**/*" + ] +} diff --git a/x-pack/plugins/lists/common/constants.mock.ts b/x-pack/plugins/lists/common/constants.mock.ts index 325ed48113966..a05b06b086fff 100644 --- a/x-pack/plugins/lists/common/constants.mock.ts +++ b/x-pack/plugins/lists/common/constants.mock.ts @@ -6,7 +6,7 @@ */ import moment from 'moment'; -import { +import type { EndpointEntriesArray, EntriesArray, Entry, diff --git a/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.test.ts b/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.test.ts index ae0cfbfbfc425..b414e76daa558 100644 --- a/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.test.ts +++ b/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.test.ts @@ -5,7 +5,10 @@ * 2.0. */ -import { EntryMatchAny } from '@kbn/securitysolution-io-ts-list-types'; +import type { + EntryMatchAny, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { getEntryMatchExcludeMock, getEntryMatchMock } from '../schemas/types/entry_match.mock'; import { @@ -19,7 +22,6 @@ import { getEntryNestedMock, } from '../schemas/types/entry_nested.mock'; import { getExceptionListItemSchemaMock } from '../schemas/response/exception_list_item_schema.mock'; -import { ExceptionListItemSchema } from '../schemas'; import { buildExceptionFilter, diff --git a/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.ts b/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.ts index 6e76076bc63ef..9276f46e8a82c 100644 --- a/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.ts +++ b/x-pack/plugins/lists/common/exceptions/build_exceptions_filter.ts @@ -7,10 +7,12 @@ import { chunk } from 'lodash/fp'; import { + CreateExceptionListItemSchema, EntryExists, EntryMatch, EntryMatchAny, EntryNested, + ExceptionListItemSchema, entriesExists, entriesMatch, entriesMatchAny, @@ -18,7 +20,6 @@ import { } from '@kbn/securitysolution-io-ts-list-types'; import type { Filter } from '../../../../../src/plugins/data/common'; -import type { CreateExceptionListItemSchema, ExceptionListItemSchema } from '../schemas'; import type { BooleanFilter, NestedFilter } from './types'; import { hasLargeValueList } from './utils'; diff --git a/x-pack/plugins/lists/common/schemas/common/index.ts b/x-pack/plugins/lists/common/schemas/common/index.ts deleted file mode 100644 index 7aa477e1db748..0000000000000 --- a/x-pack/plugins/lists/common/schemas/common/index.ts +++ /dev/null @@ -1,8 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export * from './schemas'; diff --git a/x-pack/plugins/lists/common/schemas/common/schemas.test.ts b/x-pack/plugins/lists/common/schemas/common/schemas.test.ts deleted file mode 100644 index c83691ead2ee6..0000000000000 --- a/x-pack/plugins/lists/common/schemas/common/schemas.test.ts +++ /dev/null @@ -1,139 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { pipe } from 'fp-ts/lib/pipeable'; -import { left } from 'fp-ts/lib/Either'; -import { - ExceptionListTypeEnum, - ListOperatorEnum as OperatorEnum, - Type, - exceptionListType, - listOperator as operator, - osType, - osTypeArrayOrUndefined, - type, -} from '@kbn/securitysolution-io-ts-list-types'; -import { exactCheck, foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils'; - -describe('Common schemas', () => { - describe('operator', () => { - test('it should validate for "included"', () => { - const payload = 'included'; - const decoded = operator.decode(payload); - const message = pipe(decoded, foldLeftRight); - - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(payload); - }); - - test('it should validate for "excluded"', () => { - const payload = 'excluded'; - const decoded = operator.decode(payload); - const message = pipe(decoded, foldLeftRight); - - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(payload); - }); - - test('it should contain same amount of keys as enum', () => { - // Might seem like a weird test, but its meant to - // ensure that if operator is updated, you - // also update the operatorEnum, a workaround - // for io-ts not yet supporting enums - // https://github.com/gcanti/io-ts/issues/67 - const keys = Object.keys(operator.keys).sort().join(',').toLowerCase(); - const enumKeys = Object.keys(OperatorEnum).sort().join(',').toLowerCase(); - - expect(keys).toEqual(enumKeys); - }); - }); - - describe('exceptionListType', () => { - test('it should validate for "detection"', () => { - const payload = 'detection'; - const decoded = exceptionListType.decode(payload); - const message = pipe(decoded, foldLeftRight); - - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(payload); - }); - - test('it should validate for "endpoint"', () => { - const payload = 'endpoint'; - const decoded = exceptionListType.decode(payload); - const message = pipe(decoded, foldLeftRight); - - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(payload); - }); - - test('it should contain same amount of keys as enum', () => { - // Might seem like a weird test, but its meant to - // ensure that if exceptionListType is updated, you - // also update the ExceptionListTypeEnum, a workaround - // for io-ts not yet supporting enums - // https://github.com/gcanti/io-ts/issues/67 - const keys = Object.keys(exceptionListType.keys).sort().join(',').toLowerCase(); - const enumKeys = Object.keys(ExceptionListTypeEnum).sort().join(',').toLowerCase(); - - expect(keys).toEqual(enumKeys); - }); - }); - - describe('type', () => { - test('it will work with a given expected type', () => { - const payload: Type = 'keyword'; - const decoded = type.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(payload); - }); - - test('it will give an error if given a type that does not exist', () => { - const payload: Type | 'madeup' = 'madeup'; - const decoded = type.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "madeup" supplied to ""binary" | "boolean" | "byte" | "date" | "date_nanos" | "date_range" | "double" | "double_range" | "float" | "float_range" | "geo_point" | "geo_shape" | "half_float" | "integer" | "integer_range" | "ip" | "ip_range" | "keyword" | "long" | "long_range" | "shape" | "short" | "text""', - ]); - expect(message.schema).toEqual({}); - }); - }); - - describe('osType', () => { - test('it will validate a correct osType', () => { - const payload = 'windows'; - const decoded = osType.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual(payload); - }); - - test('it will fail to validate an incorrect osType', () => { - const payload = 'foo'; - const decoded = osType.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([ - 'Invalid value "foo" supplied to ""linux" | "macos" | "windows""', - ]); - expect(message.schema).toEqual({}); - }); - - test('it will default to an empty array when osTypeArrayOrUndefined is used', () => { - const payload = undefined; - const decoded = osTypeArrayOrUndefined.decode(payload); - const checked = exactCheck(payload, decoded); - const message = pipe(checked, foldLeftRight); - expect(getPaths(left(message.errors))).toEqual([]); - expect(message.schema).toEqual([]); - }); - }); -}); diff --git a/x-pack/plugins/lists/common/schemas/common/schemas.ts b/x-pack/plugins/lists/common/schemas/common/schemas.ts deleted file mode 100644 index 83ec27d60b76c..0000000000000 --- a/x-pack/plugins/lists/common/schemas/common/schemas.ts +++ /dev/null @@ -1,91 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -/* eslint-disable @typescript-eslint/naming-convention */ - -import * as t from 'io-ts'; -import { NonEmptyString } from '@kbn/securitysolution-io-ts-types'; -import { DefaultNamespace } from '@kbn/securitysolution-io-ts-list-types'; - -export const list_id = NonEmptyString; -export type ListId = t.TypeOf; -export const list_idOrUndefined = t.union([list_id, t.undefined]); -export type ListIdOrUndefined = t.TypeOf; - -export const item = t.string; - -export const file = t.object; -export const list_type = t.keyof({ item: null, list: null }); -export type ListType = t.TypeOf; - -export const item_id = NonEmptyString; -export type ItemId = t.TypeOf; -export const itemIdOrUndefined = t.union([item_id, t.undefined]); -export type ItemIdOrUndefined = t.TypeOf; - -export const per_page = t.number; // TODO: Change this out for PositiveNumber from siem -export type PerPage = t.TypeOf; - -export const perPageOrUndefined = t.union([per_page, t.undefined]); -export type PerPageOrUndefined = t.TypeOf; - -export const total = t.number; // TODO: Change this out for PositiveNumber from siem -export const totalUndefined = t.union([total, t.undefined]); -export type TotalOrUndefined = t.TypeOf; - -export const page = t.number; // TODO: Change this out for PositiveNumber from siem -export type Page = t.TypeOf; - -export const pageOrUndefined = t.union([page, t.undefined]); -export type PageOrUndefined = t.TypeOf; - -export const sort_field = t.string; -export const sortFieldOrUndefined = t.union([sort_field, t.undefined]); -export type SortFieldOrUndefined = t.TypeOf; - -export const sort_order = t.keyof({ asc: null, desc: null }); -export const sortOrderOrUndefined = t.union([sort_order, t.undefined]); -export type SortOrderOrUndefined = t.TypeOf; - -export const filter = t.string; -export type Filter = t.TypeOf; -export const filterOrUndefined = t.union([filter, t.undefined]); -export type FilterOrUndefined = t.TypeOf; - -export const cursor = t.string; -export type Cursor = t.TypeOf; -export const cursorOrUndefined = t.union([cursor, t.undefined]); -export type CursorOrUndefined = t.TypeOf; - -export const namespace_type = DefaultNamespace; - -export const serializer = t.string; -export type Serializer = t.TypeOf; - -export const serializerOrUndefined = t.union([serializer, t.undefined]); -export type SerializerOrUndefined = t.TypeOf; - -export const deserializer = t.string; -export type Deserializer = t.TypeOf; - -export const deserializerOrUndefined = t.union([deserializer, t.undefined]); -export type DeserializerOrUndefined = t.TypeOf; - -export const _version = t.string; -export const _versionOrUndefined = t.union([_version, t.undefined]); -export type _VersionOrUndefined = t.TypeOf; - -export const immutable = t.boolean; -export type Immutable = t.TypeOf; - -export const immutableOrUndefined = t.union([immutable, t.undefined]); -export type ImmutableOrUndefined = t.TypeOf; - -export const value = t.string; -export const valueOrUndefined = t.union([value, t.undefined]); - -export const tie_breaker_id = t.string; // TODO: Use UUID for this instead of a string for validation diff --git a/x-pack/plugins/lists/common/schemas/index.ts b/x-pack/plugins/lists/common/schemas/index.ts deleted file mode 100644 index 7731d555a5dd3..0000000000000 --- a/x-pack/plugins/lists/common/schemas/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export * from './common'; -export * from './request'; -export * from './response'; diff --git a/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.mock.ts index 6ef6b40d706f8..447e79e4f77d7 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/create_exception_list_item_schema.mock.ts @@ -5,6 +5,8 @@ * 2.0. */ +import type { CreateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { COMMENTS, DESCRIPTION, @@ -19,8 +21,6 @@ import { TAGS, } from '../../constants.mock'; -import { CreateExceptionListItemSchema } from './create_exception_list_item_schema'; - export const getCreateExceptionListItemSchemaMock = (): CreateExceptionListItemSchema => ({ comments: COMMENTS, description: DESCRIPTION, diff --git a/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.mock.ts index 49af6f49442ab..2df0de3e8108a 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/create_exception_list_schema.mock.ts @@ -5,6 +5,8 @@ * 2.0. */ +import type { CreateExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { DESCRIPTION, ENDPOINT_TYPE, @@ -15,8 +17,6 @@ import { VERSION, } from '../../constants.mock'; -import { CreateExceptionListSchema } from './create_exception_list_schema'; - export const getCreateExceptionListSchemaMock = (): CreateExceptionListSchema => ({ description: DESCRIPTION, list_id: undefined, diff --git a/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.mock.ts index 3c556ab70e1dc..6587ec3e85873 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/create_list_item_schema.mock.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { LIST_ID, LIST_ITEM_ID, META, VALUE } from '../../constants.mock'; +import type { CreateListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { CreateListItemSchema } from './create_list_item_schema'; +import { LIST_ID, LIST_ITEM_ID, META, VALUE } from '../../constants.mock'; export const getCreateListItemSchemaMock = (): CreateListItemSchema => ({ id: LIST_ITEM_ID, diff --git a/x-pack/plugins/lists/common/schemas/request/create_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/create_list_schema.mock.ts index b922f73a376ba..117659423103d 100644 --- a/x-pack/plugins/lists/common/schemas/request/create_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/create_list_schema.mock.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { DESCRIPTION, LIST_ID, META, NAME, TYPE, VERSION } from '../../constants.mock'; +import type { CreateListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { CreateListSchema } from './create_list_schema'; +import { DESCRIPTION, LIST_ID, META, NAME, TYPE, VERSION } from '../../constants.mock'; export const getCreateListSchemaMock = (): CreateListSchema => ({ description: DESCRIPTION, diff --git a/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.mock.ts deleted file mode 100644 index a6434b0d4a3fd..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/delete_endpoint_list_item_schema.mock.ts +++ /dev/null @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID } from '../../constants.mock'; - -import { DeleteEndpointListItemSchema } from './delete_endpoint_list_item_schema'; - -export const getDeleteEndpointListItemSchemaMock = (): DeleteEndpointListItemSchema => ({ - id: ID, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.mock.ts deleted file mode 100644 index 1dfd8c7663d0a..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_item_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, NAMESPACE_TYPE } from '../../constants.mock'; - -import { DeleteExceptionListItemSchema } from './delete_exception_list_item_schema'; - -export const getDeleteExceptionListItemSchemaMock = (): DeleteExceptionListItemSchema => ({ - id: ID, - namespace_type: NAMESPACE_TYPE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.mock.ts deleted file mode 100644 index 743d504576d88..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/delete_exception_list_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, NAMESPACE_TYPE } from '../../constants.mock'; - -import { DeleteExceptionListSchema } from './delete_exception_list_schema'; - -export const getDeleteExceptionListSchemaMock = (): DeleteExceptionListSchema => ({ - id: ID, - namespace_type: NAMESPACE_TYPE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.mock.ts deleted file mode 100644 index dc9b7443e2202..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/delete_list_item_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, LIST_ID, VALUE } from '../../constants.mock'; - -import { DeleteListItemSchema } from './delete_list_item_schema'; - -export const getDeleteListItemSchemaMock = (): DeleteListItemSchema => ({ - id: ID, - list_id: LIST_ID, - value: VALUE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/delete_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/delete_list_schema.mock.ts deleted file mode 100644 index 74b1fb163fc95..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/delete_list_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { LIST_ID } from '../../constants.mock'; - -import { DeleteListSchema } from './delete_list_schema'; - -export const getDeleteListSchemaMock = (): DeleteListSchema => ({ - deleteReferences: false, - id: LIST_ID, - ignoreReferences: true, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.mock.ts deleted file mode 100644 index 084296d31a76b..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/export_exception_list_query_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, LIST_ID, NAMESPACE_TYPE } from '../../constants.mock'; - -import { ExportExceptionListQuerySchema } from './export_exception_list_query_schema'; - -export const getExportExceptionListQuerySchemaMock = (): ExportExceptionListQuerySchema => ({ - id: ID, - list_id: LIST_ID, - namespace_type: NAMESPACE_TYPE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.mock.ts deleted file mode 100644 index 4cc5a10ede900..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/export_list_item_query_schema.mock.ts +++ /dev/null @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { LIST_ID } from '../../constants.mock'; - -import { ExportListItemQuerySchema } from './export_list_item_query_schema'; - -export const getExportListItemQuerySchemaMock = (): ExportListItemQuerySchema => ({ - list_id: LIST_ID, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.mock.ts deleted file mode 100644 index fac2f2603ee8a..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/import_list_item_query_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { LIST_ID, TYPE } from '../../constants.mock'; - -import { ImportListItemQuerySchema } from './import_list_item_query_schema'; - -export const getImportListItemQuerySchemaMock = (): ImportListItemQuerySchema => ({ - deserializer: undefined, - list_id: LIST_ID, - serializer: undefined, - type: TYPE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.mock.ts index 8a1d6d709c905..e6c696895e8a3 100644 --- a/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/import_list_item_schema.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ImportListItemSchema } from './import_list_item_schema'; +import type { ImportListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; export const getImportListItemSchemaMock = (): ImportListItemSchema => ({ file: {}, diff --git a/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.mock.ts deleted file mode 100644 index a5bbeb59f6554..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/patch_list_item_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { LIST_ITEM_ID, META, VALUE } from '../../constants.mock'; - -import { PatchListItemSchema } from './patch_list_item_schema'; - -export const getPathListItemSchemaMock = (): PatchListItemSchema => ({ - id: LIST_ITEM_ID, - meta: META, - value: VALUE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.mock.ts deleted file mode 100644 index b88a861fe5ff3..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/read_endpoint_list_item_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, ITEM_ID } from '../../constants.mock'; - -import { ReadEndpointListItemSchema } from './read_endpoint_list_item_schema'; - -export const getReadEndpointListItemSchemaMock = (): ReadEndpointListItemSchema => ({ - id: ID, - item_id: ITEM_ID, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.mock.ts deleted file mode 100644 index 1e6e5a158afe9..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/read_exception_list_item_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, ITEM_ID, NAMESPACE_TYPE } from '../../constants.mock'; - -import { ReadExceptionListItemSchema } from './read_exception_list_item_schema'; - -export const getReadExceptionListItemSchemaMock = (): ReadExceptionListItemSchema => ({ - id: ID, - item_id: ITEM_ID, - namespace_type: NAMESPACE_TYPE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.mock.ts deleted file mode 100644 index 4b9cd42546aa2..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/read_exception_list_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ID, LIST_ID, NAMESPACE_TYPE } from '../../constants.mock'; - -import { ReadExceptionListSchema } from './read_exception_list_schema'; - -export const getReadExceptionListSchemaMock = (): ReadExceptionListSchema => ({ - id: ID, - list_id: LIST_ID, - namespace_type: NAMESPACE_TYPE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.mock.ts deleted file mode 100644 index 873909ece055d..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/read_list_item_schema.mock.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { LIST_ID, LIST_ITEM_ID, VALUE } from '../../constants.mock'; - -import { ReadListItemSchema } from './read_list_item_schema'; - -export const getReadListItemSchemaMock = (): ReadListItemSchema => ({ - id: LIST_ITEM_ID, - list_id: LIST_ID, - value: VALUE, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/read_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/read_list_schema.mock.ts deleted file mode 100644 index a0bd7316d22f2..0000000000000 --- a/x-pack/plugins/lists/common/schemas/request/read_list_schema.mock.ts +++ /dev/null @@ -1,14 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { LIST_ID } from '../../constants.mock'; - -import { ReadListSchema } from './read_list_schema'; - -export const getReadListSchemaMock = (): ReadListSchema => ({ - id: LIST_ID, -}); diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.mock.ts index 8eeba162295c1..f4d620f9c88c2 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/update_exception_list_item_schema.mock.ts @@ -5,6 +5,8 @@ * 2.0. */ +import type { UpdateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { COMMENTS, DESCRIPTION, @@ -20,8 +22,6 @@ import { TAGS, } from '../../constants.mock'; -import { UpdateExceptionListItemSchema } from './update_exception_list_item_schema'; - export const getUpdateExceptionListItemSchemaMock = (): UpdateExceptionListItemSchema => ({ _version: undefined, comments: COMMENTS, diff --git a/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.mock.ts index 9a567aca9bd1c..b57317ca2a505 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/update_exception_list_schema.mock.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { DESCRIPTION, ID, LIST_ID, META, NAME, NAMESPACE_TYPE } from '../../constants.mock'; +import type { UpdateExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { UpdateExceptionListSchema } from './update_exception_list_schema'; +import { DESCRIPTION, ID, LIST_ID, META, NAME, NAMESPACE_TYPE } from '../../constants.mock'; export const getUpdateExceptionListSchemaMock = (): UpdateExceptionListSchema => ({ _version: undefined, diff --git a/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.mock.ts index f2f1ad2dd16df..ae8ff98c66b95 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/update_list_item_schema.mock.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { ID, LIST_ITEM_ID, META, VALUE } from '../../constants.mock'; +import type { UpdateListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { UpdateListItemSchema } from './update_list_item_schema'; +import { ID, LIST_ITEM_ID, META, VALUE } from '../../constants.mock'; export const getUpdateListItemSchemaMock = (): UpdateListItemSchema => ({ id: ID, diff --git a/x-pack/plugins/lists/common/schemas/request/update_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/request/update_list_schema.mock.ts index 4fdc990a321c1..d38744a35a6cb 100644 --- a/x-pack/plugins/lists/common/schemas/request/update_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/request/update_list_schema.mock.ts @@ -5,9 +5,9 @@ * 2.0. */ -import { DESCRIPTION, LIST_ID, META, NAME, _VERSION } from '../../constants.mock'; +import type { UpdateListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { UpdateListSchema } from './update_list_schema'; +import { DESCRIPTION, LIST_ID, META, NAME, _VERSION } from '../../constants.mock'; export const getUpdateListSchemaMock = (): UpdateListSchema => ({ _version: _VERSION, diff --git a/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.mock.ts index b189bf9f133bd..0aa6990d44b3d 100644 --- a/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/acknowledge_schema.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { AcknowledgeSchema } from './acknowledge_schema'; +import type { AcknowledgeSchema } from '@kbn/securitysolution-io-ts-list-types'; export const getAcknowledgeSchemaResponseMock = (): AcknowledgeSchema => ({ acknowledged: true, diff --git a/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.mock.ts index c7d1459319eaf..22a176da222d6 100644 --- a/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.mock.ts @@ -5,6 +5,8 @@ * 2.0. */ +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { COMMENTS, DATE_NOW, @@ -22,8 +24,6 @@ import { USER, } from '../../constants.mock'; -import { ExceptionListItemSchema } from './exception_list_item_schema'; - export const getExceptionListItemSchemaMock = ( overrides?: Partial ): ExceptionListItemSchema => ({ diff --git a/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.ts b/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.ts deleted file mode 100644 index 0b6f8a7640529..0000000000000 --- a/x-pack/plugins/lists/common/schemas/response/exception_list_item_schema.ts +++ /dev/null @@ -1,56 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as t from 'io-ts'; -import { - commentsArray, - created_at, - created_by, - description, - entriesArray, - exceptionListItemType, - id, - metaOrUndefined, - name, - osTypeArray, - tags, - updated_at, - updated_by, -} from '@kbn/securitysolution-io-ts-list-types'; - -import { - _versionOrUndefined, - item_id, - list_id, - namespace_type, - tie_breaker_id, -} from '../common/schemas'; - -export const exceptionListItemSchema = t.exact( - t.type({ - _version: _versionOrUndefined, - comments: commentsArray, - created_at, - created_by, - description, - entries: entriesArray, - id, - item_id, - list_id, - meta: metaOrUndefined, - name, - namespace_type, - os_types: osTypeArray, - tags, - tie_breaker_id, - type: exceptionListItemType, - updated_at, - updated_by, - }) -); - -export type ExceptionListItemSchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/exception_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/exception_list_schema.mock.ts index 99c63055e6654..59e1138972ce0 100644 --- a/x-pack/plugins/lists/common/schemas/response/exception_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/exception_list_schema.mock.ts @@ -5,6 +5,8 @@ * 2.0. */ +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { DATE_NOW, DESCRIPTION, @@ -26,8 +28,6 @@ import { ENDPOINT_TRUSTED_APPS_LIST_NAME, } from '../../constants'; -import { ExceptionListSchema } from './exception_list_schema'; - export const getExceptionListSchemaMock = (): ExceptionListSchema => ({ _version: _VERSION, created_at: DATE_NOW, diff --git a/x-pack/plugins/lists/common/schemas/response/exception_list_schema.ts b/x-pack/plugins/lists/common/schemas/response/exception_list_schema.ts deleted file mode 100644 index f96496343fb7e..0000000000000 --- a/x-pack/plugins/lists/common/schemas/response/exception_list_schema.ts +++ /dev/null @@ -1,54 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as t from 'io-ts'; -import { - created_at, - created_by, - description, - exceptionListType, - id, - metaOrUndefined, - name, - osTypeArray, - tags, - updated_at, - updated_by, -} from '@kbn/securitysolution-io-ts-list-types'; -import { version } from '@kbn/securitysolution-io-ts-types'; - -import { - _versionOrUndefined, - immutable, - list_id, - namespace_type, - tie_breaker_id, -} from '../common/schemas'; - -export const exceptionListSchema = t.exact( - t.type({ - _version: _versionOrUndefined, - created_at, - created_by, - description, - id, - immutable, - list_id, - meta: metaOrUndefined, - name, - namespace_type, - os_types: osTypeArray, - tags, - tie_breaker_id, - type: exceptionListType, - updated_at, - updated_by, - version, - }) -); - -export type ExceptionListSchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.mock.ts index bda84ff427bc1..d06ab90e84168 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/found_exception_list_item_schema.mock.ts @@ -5,8 +5,9 @@ * 2.0. */ +import type { FoundExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { getExceptionListItemSchemaMock } from './exception_list_item_schema.mock'; -import { FoundExceptionListItemSchema } from './found_exception_list_item_schema'; export const getFoundExceptionListItemSchemaMock = (): FoundExceptionListItemSchema => ({ data: [getExceptionListItemSchemaMock()], diff --git a/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.mock.ts index a27ff5cf76f08..e3611120348f4 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/found_exception_list_schema.mock.ts @@ -5,8 +5,9 @@ * 2.0. */ +import type { FoundExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { getExceptionListSchemaMock } from './exception_list_schema.mock'; -import { FoundExceptionListSchema } from './found_exception_list_schema'; export const getFoundExceptionListSchemaMock = (): FoundExceptionListSchema => ({ data: [getExceptionListSchemaMock()], diff --git a/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.mock.ts index 1163e13f903b6..38d09810f9b34 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.mock.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { FoundListItemSchema } from './found_list_item_schema'; +import type { FoundListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { getListItemResponseMock } from './list_item_schema.mock'; export const getFoundListItemSchemaMock = (): FoundListItemSchema => ({ diff --git a/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.ts b/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.ts deleted file mode 100644 index 3f8d4a7b1b84c..0000000000000 --- a/x-pack/plugins/lists/common/schemas/response/found_list_item_schema.ts +++ /dev/null @@ -1,24 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as t from 'io-ts'; - -import { cursor, page, per_page, total } from '../common/schemas'; - -import { listItemSchema } from './list_item_schema'; - -export const foundListItemSchema = t.exact( - t.type({ - cursor, - data: t.array(listItemSchema), - page, - per_page, - total, - }) -); - -export type FoundListItemSchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/found_list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/found_list_schema.mock.ts index 94628da28ff5f..1691221842d39 100644 --- a/x-pack/plugins/lists/common/schemas/response/found_list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/found_list_schema.mock.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { FoundListSchema } from './found_list_schema'; +import type { FoundListSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { getListResponseMock } from './list_schema.mock'; export const getFoundListSchemaMock = (): FoundListSchema => ({ diff --git a/x-pack/plugins/lists/common/schemas/response/found_list_schema.ts b/x-pack/plugins/lists/common/schemas/response/found_list_schema.ts deleted file mode 100644 index d51e8b788281f..0000000000000 --- a/x-pack/plugins/lists/common/schemas/response/found_list_schema.ts +++ /dev/null @@ -1,24 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as t from 'io-ts'; - -import { cursor, page, per_page, total } from '../common/schemas'; - -import { listSchema } from './list_schema'; - -export const foundListSchema = t.exact( - t.type({ - cursor, - data: t.array(listSchema), - page, - per_page, - total, - }) -); - -export type FoundListSchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.mock.ts index 70c3f15e032cf..afbb03cab870d 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/list_item_index_exist_schema.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ListItemIndexExistSchema } from './list_item_index_exist_schema'; +import type { ListItemIndexExistSchema } from '@kbn/securitysolution-io-ts-list-types'; export const getListItemIndexExistSchemaResponseMock = (): ListItemIndexExistSchema => ({ list_index: true, diff --git a/x-pack/plugins/lists/common/schemas/response/list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/list_item_schema.mock.ts index 5d630dd8f705d..908ee9feafcc2 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/list_item_schema.mock.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { ListItemSchema } from '../../../common/schemas'; +import type { ListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { DATE_NOW, ELASTIC_USER, diff --git a/x-pack/plugins/lists/common/schemas/response/list_item_schema.ts b/x-pack/plugins/lists/common/schemas/response/list_item_schema.ts deleted file mode 100644 index 3f11718bc42e6..0000000000000 --- a/x-pack/plugins/lists/common/schemas/response/list_item_schema.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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as t from 'io-ts'; -import { - created_at, - created_by, - id, - metaOrUndefined, - type, - updated_at, - updated_by, -} from '@kbn/securitysolution-io-ts-list-types'; - -import { - _versionOrUndefined, - deserializerOrUndefined, - list_id, - serializerOrUndefined, - tie_breaker_id, - value, -} from '../common/schemas'; - -export const listItemSchema = t.exact( - t.type({ - _version: _versionOrUndefined, - created_at, - created_by, - deserializer: deserializerOrUndefined, - id, - list_id, - meta: metaOrUndefined, - serializer: serializerOrUndefined, - tie_breaker_id, - type, - updated_at, - updated_by, - value, - }) -); - -export type ListItemSchema = t.TypeOf; - -export const listItemArraySchema = t.array(listItemSchema); -export type ListItemArraySchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/list_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/list_schema.mock.ts index d1b7c022b3b7a..64afb1e73beaa 100644 --- a/x-pack/plugins/lists/common/schemas/response/list_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/list_schema.mock.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { ListSchema } from '../../../common/schemas'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { DATE_NOW, DESCRIPTION, diff --git a/x-pack/plugins/lists/common/schemas/response/list_schema.ts b/x-pack/plugins/lists/common/schemas/response/list_schema.ts deleted file mode 100644 index 5b478cd25daa6..0000000000000 --- a/x-pack/plugins/lists/common/schemas/response/list_schema.ts +++ /dev/null @@ -1,53 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as t from 'io-ts'; -import { - created_at, - created_by, - description, - id, - metaOrUndefined, - name, - type, - updated_at, - updated_by, -} from '@kbn/securitysolution-io-ts-list-types'; -import { version } from '@kbn/securitysolution-io-ts-types'; - -import { - _versionOrUndefined, - deserializerOrUndefined, - immutable, - serializerOrUndefined, - tie_breaker_id, -} from '../common/schemas'; - -export const listSchema = t.exact( - t.type({ - _version: _versionOrUndefined, - created_at, - created_by, - description, - deserializer: deserializerOrUndefined, - id, - immutable, - meta: metaOrUndefined, - name, - serializer: serializerOrUndefined, - tie_breaker_id, - type, - updated_at, - updated_by, - version, - }) -); - -export type ListSchema = t.TypeOf; - -export const listArraySchema = t.array(listSchema); -export type ListArraySchema = t.TypeOf; diff --git a/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.mock.ts b/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.mock.ts index 6f86102484bb7..d51f454eb3d40 100644 --- a/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.mock.ts +++ b/x-pack/plugins/lists/common/schemas/response/search_list_item_schema.mock.ts @@ -5,7 +5,8 @@ * 2.0. */ -import { SearchListItemSchema } from '../../../common/schemas'; +import type { SearchListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { VALUE } from '../../../common/constants.mock'; import { getListItemResponseMock } from './list_item_schema.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/comment.mock.ts b/x-pack/plugins/lists/common/schemas/types/comment.mock.ts index 5963cb4947a85..cb6e30af7da8c 100644 --- a/x-pack/plugins/lists/common/schemas/types/comment.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/comment.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Comment, CommentsArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { Comment, CommentsArray } from '@kbn/securitysolution-io-ts-list-types'; import { DATE_NOW, ID, USER } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/create_comment.mock.ts b/x-pack/plugins/lists/common/schemas/types/create_comment.mock.ts index 868c43fe5d6da..f8d67f4f2c15d 100644 --- a/x-pack/plugins/lists/common/schemas/types/create_comment.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/create_comment.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CreateComment, CreateCommentsArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { CreateComment, CreateCommentsArray } from '@kbn/securitysolution-io-ts-list-types'; export const getCreateCommentsMock = (): CreateComment => ({ comment: 'some comments', diff --git a/x-pack/plugins/lists/common/schemas/types/entries.mock.ts b/x-pack/plugins/lists/common/schemas/types/entries.mock.ts index caa62c55c93bb..7f1c759c37577 100644 --- a/x-pack/plugins/lists/common/schemas/types/entries.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/entries.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; import { getEntryMatchMock } from './entry_match.mock'; import { getEntryMatchAnyMock } from './entry_match_any.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/entry_exists.mock.ts b/x-pack/plugins/lists/common/schemas/types/entry_exists.mock.ts index 6165184d2a404..a592bf0fdd4b4 100644 --- a/x-pack/plugins/lists/common/schemas/types/entry_exists.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/entry_exists.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EntryExists } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntryExists } from '@kbn/securitysolution-io-ts-list-types'; import { EXISTS, FIELD, OPERATOR } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/entry_list.mock.ts b/x-pack/plugins/lists/common/schemas/types/entry_list.mock.ts index 1cdc86d95ed88..3ab5d6ec17c39 100644 --- a/x-pack/plugins/lists/common/schemas/types/entry_list.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/entry_list.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EntryList } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntryList } from '@kbn/securitysolution-io-ts-list-types'; import { FIELD, LIST, LIST_ID, OPERATOR, TYPE } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/entry_match.mock.ts b/x-pack/plugins/lists/common/schemas/types/entry_match.mock.ts index efcd1e0877d1b..b969e5ceb218e 100644 --- a/x-pack/plugins/lists/common/schemas/types/entry_match.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/entry_match.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EntryMatch } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntryMatch } from '@kbn/securitysolution-io-ts-list-types'; import { ENTRY_VALUE, FIELD, MATCH, OPERATOR } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/entry_match_any.mock.ts b/x-pack/plugins/lists/common/schemas/types/entry_match_any.mock.ts index 60613fc72baba..c06df97257900 100644 --- a/x-pack/plugins/lists/common/schemas/types/entry_match_any.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/entry_match_any.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EntryMatchAny } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntryMatchAny } from '@kbn/securitysolution-io-ts-list-types'; import { ENTRY_VALUE, FIELD, MATCH_ANY, OPERATOR } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/entry_nested.mock.ts b/x-pack/plugins/lists/common/schemas/types/entry_nested.mock.ts index 2497c3d4c3ce2..d0d0a36700982 100644 --- a/x-pack/plugins/lists/common/schemas/types/entry_nested.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/entry_nested.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { EntryNested } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntryNested } from '@kbn/securitysolution-io-ts-list-types'; import { NESTED, NESTED_FIELD } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/schemas/types/update_comment.mock.ts b/x-pack/plugins/lists/common/schemas/types/update_comment.mock.ts index 783b595850bc5..e37ba69f8e308 100644 --- a/x-pack/plugins/lists/common/schemas/types/update_comment.mock.ts +++ b/x-pack/plugins/lists/common/schemas/types/update_comment.mock.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { UpdateComment, UpdateCommentsArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { UpdateComment, UpdateCommentsArray } from '@kbn/securitysolution-io-ts-list-types'; import { ID } from '../../constants.mock'; diff --git a/x-pack/plugins/lists/common/shared_exports.ts b/x-pack/plugins/lists/common/shared_exports.ts index 3f1dc01644e21..6baa46ac5b842 100644 --- a/x-pack/plugins/lists/common/shared_exports.ts +++ b/x-pack/plugins/lists/common/shared_exports.ts @@ -5,15 +5,6 @@ * 2.0. */ -export type { - ListSchema, - ExceptionListSchema, - ExceptionListItemSchema, - CreateExceptionListSchema, - CreateExceptionListItemSchema, - UpdateExceptionListItemSchema, -} from './schemas'; - export { buildExceptionFilter } from './exceptions'; export { diff --git a/x-pack/plugins/lists/public/exceptions/api.ts b/x-pack/plugins/lists/public/exceptions/api.ts index e97530da7904a..19c19c7e2c1ed 100644 --- a/x-pack/plugins/lists/public/exceptions/api.ts +++ b/x-pack/plugins/lists/public/exceptions/api.ts @@ -8,15 +8,6 @@ import { chain, fromEither, tryCatch } from 'fp-ts/lib/TaskEither'; import { flow } from 'fp-ts/lib/function'; import { validateEither } from '@kbn/securitysolution-io-ts-utils'; - -import { toError, toPromise } from '../common/fp_utils'; -import { - ENDPOINT_LIST_URL, - EXCEPTION_LIST_ITEM_URL, - EXCEPTION_LIST_NAMESPACE, - EXCEPTION_LIST_NAMESPACE_AGNOSTIC, - EXCEPTION_LIST_URL, -} from '../../common/constants'; import { CreateEndpointListSchema, ExceptionListItemSchema, @@ -28,7 +19,16 @@ import { exceptionListSchema, foundExceptionListItemSchema, foundExceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import { toError, toPromise } from '../common/fp_utils'; +import { + ENDPOINT_LIST_URL, + EXCEPTION_LIST_ITEM_URL, + EXCEPTION_LIST_NAMESPACE, + EXCEPTION_LIST_NAMESPACE_AGNOSTIC, + EXCEPTION_LIST_URL, +} from '../../common/constants'; import { AddEndpointExceptionListProps, diff --git a/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.test.tsx b/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.test.tsx index a5588b36aae03..8090aa7484bee 100644 --- a/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.test.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.test.tsx @@ -9,10 +9,10 @@ import React from 'react'; import { mount } from 'enzyme'; import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import { waitFor } from '@testing-library/react'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { coreMock } from '../../../../../../../src/core/public/mocks'; import { getField } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; -import { ListSchema } from '../../../../common'; import { getFoundListSchemaMock } from '../../../../../lists/common/schemas/response/found_list_schema.mock'; import { getListResponseMock } from '../../../../../lists/common/schemas/response/list_schema.mock'; import { DATE_NOW, IMMUTABLE, VERSION } from '../../../../../lists/common/constants.mock'; diff --git a/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.tsx b/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.tsx index 3d910403d4843..d6b9ccd57e89e 100644 --- a/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/autocomplete/field_value_lists.tsx @@ -8,8 +8,8 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui'; import { HttpStart } from 'kibana/public'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListSchema } from '../../../../common'; import { IFieldType } from '../../../../../../../src/plugins/data/common'; import { useFindLists } from '../../..'; diff --git a/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.test.ts b/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.test.ts index 2fed462974a26..21764c6f459d8 100644 --- a/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.test.ts +++ b/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.test.ts @@ -6,20 +6,20 @@ */ import moment from 'moment'; - -import { getField } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; -import { IFieldType } from '../../../../../../../src/plugins/data/common'; -import { getListResponseMock } from '../../../../../lists/common/schemas/response/list_schema.mock'; -import { ListSchema } from '../../../../common'; - -import * as i18n from './translations'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { EXCEPTION_OPERATORS, doesNotExistOperator, existsOperator, isNotOperator, isOperator, -} from './operators'; +} from '@kbn/securitysolution-list-utils'; + +import { getField } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; +import { IFieldType } from '../../../../../../../src/plugins/data/common'; +import { getListResponseMock } from '../../../../../lists/common/schemas/response/list_schema.mock'; + +import * as i18n from './translations'; import { checkEmptyValue, filterFieldToList, diff --git a/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.ts b/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.ts index b982193d1d349..965214815eedf 100644 --- a/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.ts +++ b/x-pack/plugins/lists/public/exceptions/components/autocomplete/helpers.ts @@ -7,18 +7,17 @@ import dateMath from '@elastic/datemath'; import { EuiComboBoxOptionOption } from '@elastic/eui'; -import type { Type } from '@kbn/securitysolution-io-ts-list-types'; - -import type { ListSchema } from '../../../../common'; -import { IFieldType } from '../../../../../../../src/plugins/data/common'; - +import type { ListSchema, Type } from '@kbn/securitysolution-io-ts-list-types'; import { EXCEPTION_OPERATORS, doesNotExistOperator, existsOperator, isNotOperator, isOperator, -} from './operators'; +} from '@kbn/securitysolution-list-utils'; + +import { IFieldType } from '../../../../../../../src/plugins/data/common'; + import { GetGenericComboBoxPropsReturn, OperatorOption } from './types'; import * as i18n from './translations'; diff --git a/x-pack/plugins/lists/public/exceptions/components/autocomplete/operator.test.tsx b/x-pack/plugins/lists/public/exceptions/components/autocomplete/operator.test.tsx index 1d033272197ca..dadde8800b67f 100644 --- a/x-pack/plugins/lists/public/exceptions/components/autocomplete/operator.test.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/autocomplete/operator.test.tsx @@ -8,11 +8,11 @@ import React from 'react'; import { mount } from 'enzyme'; import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; +import { isNotOperator, isOperator } from '@kbn/securitysolution-list-utils'; import { getField } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; import { OperatorComponent } from './operator'; -import { isNotOperator, isOperator } from './operators'; describe('OperatorComponent', () => { test('it renders disabled if "isDisabled" is true', () => { diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/entry_delete_button.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/entry_delete_button.tsx index 01739bd3f85cb..b30bcd9ae1621 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/entry_delete_button.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/entry_delete_button.tsx @@ -8,8 +8,7 @@ import React, { useCallback } from 'react'; import { EuiButtonIcon, EuiFlexItem } from '@elastic/eui'; import styled from 'styled-components'; - -import { BuilderEntry } from './types'; +import type { BuilderEntry } from '@kbn/securitysolution-list-utils'; const MyFirstRowContainer = styled(EuiFlexItem)` padding-top: 20px; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx index 1396a47b64713..616757eb5b674 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.test.tsx @@ -9,7 +9,6 @@ import { ReactWrapper, mount } from 'enzyme'; import React from 'react'; import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import { waitFor } from '@testing-library/dom'; - import { doesNotExistOperator, existsOperator, @@ -19,7 +18,8 @@ import { isNotOperator, isOneOfOperator, isOperator, -} from '../autocomplete/operators'; +} from '@kbn/securitysolution-list-utils'; + import { fields, getField, diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx index 09863660e98af..7daef8467dd1a 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/entry_renderer.tsx @@ -10,9 +10,22 @@ import { EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui'; import styled from 'styled-components'; import { ExceptionListType, + ListSchema, ListOperatorTypeEnum as OperatorTypeEnum, OsTypeArray, } from '@kbn/securitysolution-io-ts-list-types'; +import { + BuilderEntry, + EXCEPTION_OPERATORS_ONLY_LISTS, + FormattedBuilderEntry, + getEntryOnFieldChange, + getEntryOnListChange, + getEntryOnMatchAnyChange, + getEntryOnMatchChange, + getEntryOnOperatorChange, + getFilteredIndexPatterns, + getOperatorOptions, +} from '@kbn/securitysolution-list-utils'; import { AutocompleteStart } from '../../../../../../../src/plugins/data/public'; import { IFieldType, IIndexPattern } from '../../../../../../../src/plugins/data/common'; @@ -20,24 +33,12 @@ import { HttpStart } from '../../../../../../../src/core/public'; import { FieldComponent } from '../autocomplete/field'; import { OperatorComponent } from '../autocomplete/operator'; import { OperatorOption } from '../autocomplete/types'; -import { EXCEPTION_OPERATORS_ONLY_LISTS } from '../autocomplete/operators'; import { AutocompleteFieldExistsComponent } from '../autocomplete/field_value_exists'; import { AutocompleteFieldMatchComponent } from '../autocomplete/field_value_match'; import { AutocompleteFieldMatchAnyComponent } from '../autocomplete/field_value_match_any'; import { AutocompleteFieldListsComponent } from '../autocomplete/field_value_lists'; -import { ListSchema } from '../../../../common'; import { getEmptyValue } from '../../../common/empty_value'; -import { - getEntryOnFieldChange, - getEntryOnListChange, - getEntryOnMatchAnyChange, - getEntryOnMatchChange, - getEntryOnOperatorChange, - getFilteredIndexPatterns, - getOperatorOptions, -} from './helpers'; -import { BuilderEntry, FormattedBuilderEntry } from './types'; import * as i18n from './translations'; const MyValuesInput = styled(EuiFlexItem)` diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx index e10cd2934328f..eee5b8b1e992d 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/exception_item_renderer.tsx @@ -11,14 +11,19 @@ import styled from 'styled-components'; import { HttpStart } from 'kibana/public'; import { AutocompleteStart } from 'src/plugins/data/public'; import { ExceptionListType, OsTypeArray } from '@kbn/securitysolution-io-ts-list-types'; +import { + BuilderEntry, + ExceptionsBuilderExceptionItem, + FormattedBuilderEntry, + getFormattedBuilderEntries, + getUpdatedEntriesOnDelete, +} from '@kbn/securitysolution-list-utils'; import { IIndexPattern } from '../../../../../../../src/plugins/data/common'; -import { BuilderEntry, ExceptionsBuilderExceptionItem, FormattedBuilderEntry } from './types'; import { BuilderAndBadgeComponent } from './and_badge'; import { BuilderEntryDeleteButtonComponent } from './entry_delete_button'; import { BuilderEntryItem } from './entry_renderer'; -import { getFormattedBuilderEntries, getUpdatedEntriesOnDelete } from './helpers'; const MyBeautifulLine = styled(EuiFlexItem)` &:after { diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx b/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx index 6058d4f7b725b..1b68ef07657a8 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx +++ b/x-pack/plugins/lists/public/exceptions/components/builder/exception_items_renderer.tsx @@ -11,33 +11,32 @@ import styled from 'styled-components'; import { HttpStart } from 'kibana/public'; import { addIdToItem } from '@kbn/securitysolution-utils'; import { + CreateExceptionListItemSchema, + ExceptionListItemSchema, ExceptionListType, NamespaceType, ListOperatorEnum as OperatorEnum, ListOperatorTypeEnum as OperatorTypeEnum, OsTypeArray, entriesNested, + exceptionListItemSchema, } from '@kbn/securitysolution-io-ts-list-types'; - import { - CreateExceptionListItemSchema, - ExceptionListItemSchema, - exceptionListItemSchema, -} from '../../../../common/schemas'; + CreateExceptionListItemBuilderSchema, + ExceptionsBuilderExceptionItem, + containsValueListEntry, + filterExceptionItems, + getDefaultEmptyEntry, + getDefaultNestedEmptyEntry, + getNewExceptionItem, +} from '@kbn/securitysolution-list-utils'; + import { AutocompleteStart, IIndexPattern } from '../../../../../../../src/plugins/data/public'; import { AndOrBadge } from '../and_or_badge'; -import { CreateExceptionListItemBuilderSchema, ExceptionsBuilderExceptionItem } from './types'; import { BuilderExceptionListItemComponent } from './exception_item_renderer'; import { BuilderLogicButtons } from './logic_buttons'; import { State, exceptionsBuilderReducer } from './reducer'; -import { - containsValueListEntry, - filterExceptionItems, - getDefaultEmptyEntry, - getDefaultNestedEmptyEntry, - getNewExceptionItem, -} from './helpers'; const MyInvisibleAndBadge = styled(EuiFlexItem)` visibility: hidden; diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts b/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts index dbfeaa4a258ca..ec46038c397e5 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts +++ b/x-pack/plugins/lists/public/exceptions/components/builder/helpers.test.ts @@ -6,51 +6,26 @@ */ import { + CreateExceptionListItemSchema, EntryExists, EntryList, EntryMatch, EntryMatchAny, EntryNested, + ExceptionListItemSchema, ExceptionListType, ListOperatorEnum as OperatorEnum, ListOperatorTypeEnum as OperatorTypeEnum, } from '@kbn/securitysolution-io-ts-list-types'; - -import { CreateExceptionListItemSchema, ExceptionListItemSchema } from '../../../../common'; -import { ENTRIES_WITH_IDS } from '../../../../common/constants.mock'; -import { getEntryExistsMock } from '../../../../common/schemas/types/entry_exists.mock'; -import { getExceptionListItemSchemaMock } from '../../../../common/schemas/response/exception_list_item_schema.mock'; -import { - fields, - getField, -} from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; -import { IFieldType, IIndexPattern } from '../../../../../../../src/plugins/data/common'; -import { getEntryNestedMock } from '../../../../common/schemas/types/entry_nested.mock'; -import { getEntryMatchMock } from '../../../../common/schemas/types/entry_match.mock'; -import { getEntryMatchAnyMock } from '../../../../common/schemas/types/entry_match_any.mock'; -import { getListResponseMock } from '../../../../common/schemas/response/list_schema.mock'; import { + BuilderEntry, EXCEPTION_OPERATORS, EXCEPTION_OPERATORS_SANS_LISTS, - doesNotExistOperator, - existsOperator, - isInListOperator, - isNotInListOperator, - isNotOneOfOperator, - isNotOperator, - isOneOfOperator, - isOperator, -} from '../autocomplete/operators'; -import { OperatorOption } from '../autocomplete/types'; -import { getEntryListMock } from '../../../../common/schemas/types/entry_list.mock'; - -import { - BuilderEntry, EmptyEntry, ExceptionsBuilderExceptionItem, FormattedBuilderEntry, -} from './types'; -import { + doesNotExistOperator, + existsOperator, filterExceptionItems, getCorrespondingKeywordField, getEntryFromOperator, @@ -69,7 +44,30 @@ import { getOperatorType, getUpdatedEntriesOnDelete, isEntryNested, -} from './helpers'; + isInListOperator, + isNotInListOperator, + isNotOneOfOperator, + isNotOperator, + isOneOfOperator, + isOperator, +} from '@kbn/securitysolution-list-utils'; + +import { ENTRIES_WITH_IDS } from '../../../../common/constants.mock'; +import { getEntryExistsMock } from '../../../../common/schemas/types/entry_exists.mock'; +import { getExceptionListItemSchemaMock } from '../../../../common/schemas/response/exception_list_item_schema.mock'; +import { + fields, + getField, +} from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; +import { IFieldType, IIndexPattern } from '../../../../../../../src/plugins/data/common'; +import { getEntryNestedMock } from '../../../../common/schemas/types/entry_nested.mock'; +import { getEntryMatchMock } from '../../../../common/schemas/types/entry_match.mock'; +import { getEntryMatchAnyMock } from '../../../../common/schemas/types/entry_match_any.mock'; +import { getListResponseMock } from '../../../../common/schemas/response/list_schema.mock'; +import { OperatorOption } from '../autocomplete/types'; +import { getEntryListMock } from '../../../../common/schemas/types/entry_list.mock'; + +// TODO: ALL THESE TESTS SHOULD BE MOVED TO @kbn/securitysolution-list-utils for its helper. The only reason why they're here is due to missing other packages we hae to create or missing things from kbn packages such as mocks from kibana core jest.mock('uuid', () => ({ v4: jest.fn().mockReturnValue('123'), diff --git a/x-pack/plugins/lists/public/exceptions/components/builder/reducer.ts b/x-pack/plugins/lists/public/exceptions/components/builder/reducer.ts index 0e8a5fadd3b1a..14744bc5cc773 100644 --- a/x-pack/plugins/lists/public/exceptions/components/builder/reducer.ts +++ b/x-pack/plugins/lists/public/exceptions/components/builder/reducer.ts @@ -5,12 +5,14 @@ * 2.0. */ -import { ListOperatorTypeEnum as OperatorTypeEnum } from '@kbn/securitysolution-io-ts-list-types'; - -import { ExceptionListItemSchema } from '../../../../common'; - -import { ExceptionsBuilderExceptionItem } from './types'; -import { getDefaultEmptyEntry } from './helpers'; +import { + ExceptionListItemSchema, + ListOperatorTypeEnum as OperatorTypeEnum, +} from '@kbn/securitysolution-io-ts-list-types'; +import { + ExceptionsBuilderExceptionItem, + getDefaultEmptyEntry, +} from '@kbn/securitysolution-list-utils'; export type ViewerModalName = 'addModal' | 'editModal' | null; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_item.ts b/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_item.ts index 6135d14aef6a4..0ed3668b94c0c 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_item.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_item.ts @@ -6,11 +6,11 @@ */ import { Dispatch, useEffect, useState } from 'react'; - -import { +import type { CreateExceptionListItemSchema, UpdateExceptionListItemSchema, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { addExceptionListItem, updateExceptionListItem } from '../api'; import { transformNewItemOutput, transformOutput } from '../transforms'; import { PersistHookProps } from '../types'; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_list.ts b/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_list.ts index aef87569e7284..eccd8532a7e2f 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_list.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/persist_exception_list.ts @@ -6,8 +6,8 @@ */ import { Dispatch, useEffect, useState } from 'react'; +import type { UpdateExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { UpdateExceptionListSchema } from '../../../common/schemas'; import { addExceptionList, updateExceptionList } from '../api'; import { AddExceptionList, PersistHookProps } from '../types'; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/use_api.ts b/x-pack/plugins/lists/public/exceptions/hooks/use_api.ts index 9e4e338b09dbf..6e04827dad60b 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/use_api.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/use_api.ts @@ -6,15 +6,15 @@ */ import { useMemo } from 'react'; - -import * as Api from '../api'; -import { HttpStart } from '../../../../../../src/core/public'; -import { +import type { CreateExceptionListItemSchema, ExceptionListItemSchema, ExceptionListSchema, UpdateExceptionListItemSchema, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import * as Api from '../api'; +import { HttpStart } from '../../../../../../src/core/public'; import { ApiCallFindListsItemsMemoProps, ApiCallMemoProps, ApiListExportProps } from '../types'; import { getIdsAndNamespaces } from '../utils'; import { transformInput, transformNewItemOutput, transformOutput } from '../transforms'; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.test.ts b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.test.ts index 1191b240d27bb..97c60d1ba80f2 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.test.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.test.ts @@ -6,11 +6,11 @@ */ import { act, renderHook } from '@testing-library/react-hooks'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { coreMock } from '../../../../../../src/core/public/mocks'; import * as api from '../api'; import { getFoundExceptionListItemSchemaMock } from '../../../common/schemas/response/found_exception_list_item_schema.mock'; -import { ExceptionListItemSchema } from '../../../common/schemas'; import { UseExceptionListItemsSuccess, UseExceptionListProps } from '../types'; import { transformInput } from '../transforms'; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.ts b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.ts index b9a8628d2ceac..52fbccc376012 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_list_items.ts @@ -6,10 +6,10 @@ */ import { useEffect, useRef, useState } from 'react'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { fetchExceptionListsItemsByListIds } from '../api'; import { FilterExceptionsOptions, Pagination, UseExceptionListProps } from '../types'; -import { ExceptionListItemSchema } from '../../../common/schemas'; import { getIdsAndNamespaces } from '../utils'; import { transformInput } from '../transforms'; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.test.ts b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.test.ts index 7fdf861543117..ce737c5163d08 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.test.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.test.ts @@ -6,11 +6,11 @@ */ import { act, renderHook } from '@testing-library/react-hooks'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { coreMock } from '../../../../../../src/core/public/mocks'; import * as api from '../api'; import { getFoundExceptionListSchemaMock } from '../../../common/schemas/response/found_exception_list_schema.mock'; -import { ExceptionListSchema } from '../../../common/schemas'; import { UseExceptionListsProps } from '../types'; import { ReturnExceptionLists, useExceptionLists } from './use_exception_lists'; diff --git a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.ts b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.ts index 0a39cf5ba437f..31f4106c3afbb 100644 --- a/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.ts +++ b/x-pack/plugins/lists/public/exceptions/hooks/use_exception_lists.ts @@ -6,10 +6,10 @@ */ import { useEffect, useMemo, useRef, useState } from 'react'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { fetchExceptionLists } from '../api'; import { Pagination, UseExceptionListsProps } from '../types'; -import { ExceptionListSchema } from '../../../common/schemas'; import { getFilters } from '../utils'; export type Func = () => void; diff --git a/x-pack/plugins/lists/public/exceptions/transforms.test.ts b/x-pack/plugins/lists/public/exceptions/transforms.test.ts index b2a1efc1d2c1d..2586571e88c4c 100644 --- a/x-pack/plugins/lists/public/exceptions/transforms.test.ts +++ b/x-pack/plugins/lists/public/exceptions/transforms.test.ts @@ -5,11 +5,15 @@ * 2.0. */ -import { Entry, EntryMatch, EntryNested } from '@kbn/securitysolution-io-ts-list-types'; +import type { + CreateExceptionListItemSchema, + Entry, + EntryMatch, + EntryNested, + ExceptionListItemSchema, + UpdateExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; -import { ExceptionListItemSchema } from '../../common/schemas/response/exception_list_item_schema'; -import { UpdateExceptionListItemSchema } from '../../common/schemas/request/update_exception_list_item_schema'; -import { CreateExceptionListItemSchema } from '../../common/schemas/request/create_exception_list_item_schema'; import { getCreateExceptionListItemSchemaMock } from '../../common/schemas/request/create_exception_list_item_schema.mock'; import { getUpdateExceptionListItemSchemaMock } from '../../common/schemas/request/update_exception_list_item_schema.mock'; import { getExceptionListItemSchemaMock } from '../../common/schemas/response/exception_list_item_schema.mock'; diff --git a/x-pack/plugins/lists/public/exceptions/transforms.ts b/x-pack/plugins/lists/public/exceptions/transforms.ts index 564ba1a699f98..49cf012a1c16b 100644 --- a/x-pack/plugins/lists/public/exceptions/transforms.ts +++ b/x-pack/plugins/lists/public/exceptions/transforms.ts @@ -7,13 +7,13 @@ import { flow } from 'fp-ts/lib/function'; import { addIdToItem, removeIdFromItem } from '@kbn/securitysolution-utils'; -import type { EntriesArray, Entry } from '@kbn/securitysolution-io-ts-list-types'; - import type { CreateExceptionListItemSchema, + EntriesArray, + Entry, ExceptionListItemSchema, UpdateExceptionListItemSchema, -} from '../../common'; +} from '@kbn/securitysolution-io-ts-list-types'; // These are a collection of transforms that are UI specific and useful for UI concerns // that are inserted between the API and the actual user interface. In some ways these diff --git a/x-pack/plugins/lists/public/exceptions/types.ts b/x-pack/plugins/lists/public/exceptions/types.ts index 0cad700b2b598..8686c5d7ad250 100644 --- a/x-pack/plugins/lists/public/exceptions/types.ts +++ b/x-pack/plugins/lists/public/exceptions/types.ts @@ -5,19 +5,20 @@ * 2.0. */ -import { ExceptionListType, NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; - -import { +import type { CreateExceptionListItemSchema, CreateExceptionListSchema, ExceptionListItemSchema, ExceptionListSchema, + ExceptionListType, + NamespaceType, Page, PerPage, TotalOrUndefined, UpdateExceptionListItemSchema, UpdateExceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { HttpStart, NotificationsStart } from '../../../../../src/core/public'; export interface FilterExceptionsOptions { diff --git a/x-pack/plugins/lists/public/exceptions/utils.ts b/x-pack/plugins/lists/public/exceptions/utils.ts index c840a25b2a103..ee0219ba0ed31 100644 --- a/x-pack/plugins/lists/public/exceptions/utils.ts +++ b/x-pack/plugins/lists/public/exceptions/utils.ts @@ -6,7 +6,7 @@ */ import { get } from 'lodash/fp'; -import { NamespaceType, NamespaceTypeArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { NamespaceType, NamespaceTypeArray } from '@kbn/securitysolution-io-ts-list-types'; import { ENDPOINT_TRUSTED_APPS_LIST_ID } from '../../common/constants'; import { diff --git a/x-pack/plugins/lists/public/lists/api.ts b/x-pack/plugins/lists/public/lists/api.ts index 09baa83519fc4..ec17c079b8fff 100644 --- a/x-pack/plugins/lists/public/lists/api.ts +++ b/x-pack/plugins/lists/public/lists/api.ts @@ -9,7 +9,6 @@ import { chain, fromEither, map, tryCatch } from 'fp-ts/lib/TaskEither'; import { flow } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; import { validateEither } from '@kbn/securitysolution-io-ts-utils'; - import { AcknowledgeSchema, DeleteListSchemaEncoded, @@ -29,7 +28,8 @@ import { importListItemSchema, listItemIndexExistSchema, listSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { LIST_INDEX, LIST_ITEM_URL, LIST_PRIVILEGES_URL, LIST_URL } from '../../common/constants'; import { toError, toPromise } from '../common/fp_utils'; diff --git a/x-pack/plugins/lists/public/lists/types.ts b/x-pack/plugins/lists/public/lists/types.ts index ad82a63163ce3..575ccde1ea286 100644 --- a/x-pack/plugins/lists/public/lists/types.ts +++ b/x-pack/plugins/lists/public/lists/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { Type } from '@kbn/securitysolution-io-ts-list-types'; import { HttpStart } from '../../../../../src/core/public'; diff --git a/x-pack/plugins/lists/public/shared_exports.ts b/x-pack/plugins/lists/public/shared_exports.ts index 6d14c6b541904..857109f3a11e7 100644 --- a/x-pack/plugins/lists/public/shared_exports.ts +++ b/x-pack/plugins/lists/public/shared_exports.ts @@ -20,13 +20,6 @@ export { useExportList } from './lists/hooks/use_export_list'; export { useReadListIndex } from './lists/hooks/use_read_list_index'; export { useCreateListIndex } from './lists/hooks/use_create_list_index'; export { useReadListPrivileges } from './lists/hooks/use_read_list_privileges'; -export { - getEntryValue, - getExceptionOperatorSelect, - getOperatorType, - getNewExceptionItem, - addIdToEntries, -} from './exceptions/components/builder/helpers'; export { fetchExceptionListById, addExceptionList, diff --git a/x-pack/plugins/lists/server/routes/create_endpoint_list_item_route.ts b/x-pack/plugins/lists/server/routes/create_endpoint_list_item_route.ts index 9c42df6abd7bd..be2125b6f250a 100644 --- a/x-pack/plugins/lists/server/routes/create_endpoint_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/create_endpoint_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { ENDPOINT_LIST_ID, ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { CreateEndpointListItemSchemaDecoded, createEndpointListItemSchema, exceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { ENDPOINT_LIST_ID, ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils'; import { validateExceptionListSize } from './validate'; diff --git a/x-pack/plugins/lists/server/routes/create_endpoint_list_route.ts b/x-pack/plugins/lists/server/routes/create_endpoint_list_route.ts index 599870c226564..0f30b7d40217f 100644 --- a/x-pack/plugins/lists/server/routes/create_endpoint_list_route.ts +++ b/x-pack/plugins/lists/server/routes/create_endpoint_list_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { createEndpointListSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { ENDPOINT_LIST_URL } from '../../common/constants'; -import { createEndpointListSchema } from '../../common/schemas'; import { buildSiemResponse } from './utils'; import { getExceptionListClient } from './utils/get_exception_list_client'; diff --git a/x-pack/plugins/lists/server/routes/create_exception_list_item_route.ts b/x-pack/plugins/lists/server/routes/create_exception_list_item_route.ts index 81260584e8a50..e85c6480262f0 100644 --- a/x-pack/plugins/lists/server/routes/create_exception_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/create_exception_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { CreateExceptionListItemSchemaDecoded, createExceptionListItemSchema, exceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse } from './utils'; import { getExceptionListClient } from './utils/get_exception_list_client'; diff --git a/x-pack/plugins/lists/server/routes/create_exception_list_route.ts b/x-pack/plugins/lists/server/routes/create_exception_list_route.ts index 1a35bdb008662..fb515591745e4 100644 --- a/x-pack/plugins/lists/server/routes/create_exception_list_route.ts +++ b/x-pack/plugins/lists/server/routes/create_exception_list_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_URL } from '../../common/constants'; import { CreateExceptionListSchemaDecoded, createExceptionListSchema, exceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse } from './utils'; import { getExceptionListClient } from './utils/get_exception_list_client'; diff --git a/x-pack/plugins/lists/server/routes/create_list_index_route.ts b/x-pack/plugins/lists/server/routes/create_list_index_route.ts index 3b0d34b8952a1..db085befa5a2e 100644 --- a/x-pack/plugins/lists/server/routes/create_list_index_route.ts +++ b/x-pack/plugins/lists/server/routes/create_list_index_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { acknowledgeSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_INDEX } from '../../common/constants'; -import { acknowledgeSchema } from '../../common/schemas'; import { buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/create_list_item_route.ts b/x-pack/plugins/lists/server/routes/create_list_item_route.ts index 4df121af4c1ba..961be259cd8d5 100644 --- a/x-pack/plugins/lists/server/routes/create_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/create_list_item_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { createListItemSchema, listItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { createListItemSchema, listItemSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/create_list_route.ts b/x-pack/plugins/lists/server/routes/create_list_route.ts index dabbd690bba21..4135d6d794188 100644 --- a/x-pack/plugins/lists/server/routes/create_list_route.ts +++ b/x-pack/plugins/lists/server/routes/create_list_route.ts @@ -7,10 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { + CreateListSchemaDecoded, + createListSchema, + listSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_URL } from '../../common/constants'; -import { CreateListSchemaDecoded, createListSchema, listSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/delete_endpoint_list_item_route.ts b/x-pack/plugins/lists/server/routes/delete_endpoint_list_item_route.ts index 59d91f6234176..725594c4cbf9e 100644 --- a/x-pack/plugins/lists/server/routes/delete_endpoint_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/delete_endpoint_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { DeleteEndpointListItemSchemaDecoded, deleteEndpointListItemSchema, exceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/delete_exception_list_item_route.ts b/x-pack/plugins/lists/server/routes/delete_exception_list_item_route.ts index ce4f91ffc671a..0467b46c08491 100644 --- a/x-pack/plugins/lists/server/routes/delete_exception_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/delete_exception_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { DeleteExceptionListItemSchemaDecoded, deleteExceptionListItemSchema, exceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/delete_exception_list_route.ts b/x-pack/plugins/lists/server/routes/delete_exception_list_route.ts index eeeb5fb44c16a..7df509690ae90 100644 --- a/x-pack/plugins/lists/server/routes/delete_exception_list_route.ts +++ b/x-pack/plugins/lists/server/routes/delete_exception_list_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_URL } from '../../common/constants'; import { DeleteExceptionListSchemaDecoded, deleteExceptionListSchema, exceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/delete_list_index_route.ts b/x-pack/plugins/lists/server/routes/delete_list_index_route.ts index 22c56a21df419..15b15ec746f23 100644 --- a/x-pack/plugins/lists/server/routes/delete_list_index_route.ts +++ b/x-pack/plugins/lists/server/routes/delete_list_index_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { acknowledgeSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_INDEX } from '../../common/constants'; -import { acknowledgeSchema } from '../../common/schemas'; import { buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/delete_list_item_route.ts b/x-pack/plugins/lists/server/routes/delete_list_item_route.ts index 197590ecb142c..e9cc035dda85a 100644 --- a/x-pack/plugins/lists/server/routes/delete_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/delete_list_item_route.ts @@ -7,10 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { + deleteListItemSchema, + listItemArraySchema, + listItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { deleteListItemSchema, listItemArraySchema, listItemSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/delete_list_route.ts b/x-pack/plugins/lists/server/routes/delete_list_route.ts index 78235584bc0cd..e22fdc5df121e 100644 --- a/x-pack/plugins/lists/server/routes/delete_list_route.ts +++ b/x-pack/plugins/lists/server/routes/delete_list_route.ts @@ -6,18 +6,18 @@ */ import { validate } from '@kbn/securitysolution-io-ts-utils'; -import { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { LIST_URL } from '../../common/constants'; import { + EntriesArray, ExceptionListItemSchema, FoundExceptionListSchema, deleteListSchema, exceptionListItemSchema, listSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { LIST_URL } from '../../common/constants'; import { getSavedObjectType } from '../services/exception_lists/utils'; import { ExceptionListClient } from '../services/exception_lists/exception_list_client'; import { escapeQuotes } from '../services/utils/escape_query'; diff --git a/x-pack/plugins/lists/server/routes/export_exception_list_route.ts b/x-pack/plugins/lists/server/routes/export_exception_list_route.ts index 3d82cbac47a88..8f274d10a870b 100644 --- a/x-pack/plugins/lists/server/routes/export_exception_list_route.ts +++ b/x-pack/plugins/lists/server/routes/export_exception_list_route.ts @@ -6,10 +6,10 @@ */ import { transformError } from '@kbn/securitysolution-es-utils'; +import { exportExceptionListQuerySchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { EXCEPTION_LIST_URL } from '../../common/constants'; -import { exportExceptionListQuerySchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/export_list_item_route.ts b/x-pack/plugins/lists/server/routes/export_list_item_route.ts index 13a2aa9beea05..d104f11024e93 100644 --- a/x-pack/plugins/lists/server/routes/export_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/export_list_item_route.ts @@ -8,10 +8,10 @@ import { Stream } from 'stream'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { exportListItemQuerySchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { exportListItemQuerySchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/find_endpoint_list_item_route.ts b/x-pack/plugins/lists/server/routes/find_endpoint_list_item_route.ts index cbf3c320c407a..0284321ef4619 100644 --- a/x-pack/plugins/lists/server/routes/find_endpoint_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/find_endpoint_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { ENDPOINT_LIST_ID, ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { FindEndpointListItemSchemaDecoded, findEndpointListItemSchema, foundExceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { ENDPOINT_LIST_ID, ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/find_exception_list_item_route.ts b/x-pack/plugins/lists/server/routes/find_exception_list_item_route.ts index 45ce1dbb87fba..fc3450d2277d5 100644 --- a/x-pack/plugins/lists/server/routes/find_exception_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/find_exception_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { FindExceptionListItemSchemaDecoded, findExceptionListItemSchema, foundExceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/find_exception_list_route.ts b/x-pack/plugins/lists/server/routes/find_exception_list_route.ts index 0181bfed5b857..966aa1391a312 100644 --- a/x-pack/plugins/lists/server/routes/find_exception_list_route.ts +++ b/x-pack/plugins/lists/server/routes/find_exception_list_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_URL } from '../../common/constants'; import { FindExceptionListSchemaDecoded, findExceptionListSchema, foundExceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse, getExceptionListClient } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/find_list_item_route.ts b/x-pack/plugins/lists/server/routes/find_list_item_route.ts index c64dfd561e0e3..1ae60f7faba35 100644 --- a/x-pack/plugins/lists/server/routes/find_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/find_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { LIST_ITEM_URL } from '../../common/constants'; import { FindListItemSchemaDecoded, findListItemSchema, foundListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { LIST_ITEM_URL } from '../../common/constants'; import { decodeCursor } from '../services/utils'; import { buildRouteValidation, buildSiemResponse, getListClient } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/find_list_route.ts b/x-pack/plugins/lists/server/routes/find_list_route.ts index 19c20515ef5f2..31e2773359ee1 100644 --- a/x-pack/plugins/lists/server/routes/find_list_route.ts +++ b/x-pack/plugins/lists/server/routes/find_list_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { findListSchema, foundListSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_URL } from '../../common/constants'; -import { findListSchema, foundListSchema } from '../../common/schemas'; import { decodeCursor } from '../services/utils'; import { buildRouteValidation, buildSiemResponse, getListClient } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/import_list_item_route.ts b/x-pack/plugins/lists/server/routes/import_list_item_route.ts index 77d9623f40a23..3843f8389a4ed 100644 --- a/x-pack/plugins/lists/server/routes/import_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/import_list_item_route.ts @@ -8,10 +8,10 @@ import { schema } from '@kbn/config-schema'; import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { importListItemQuerySchema, listSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { importListItemQuerySchema, listSchema } from '../../common/schemas'; import { ConfigType } from '../config'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/patch_list_item_route.ts b/x-pack/plugins/lists/server/routes/patch_list_item_route.ts index ce4ff71a1d886..3e85e501bd216 100644 --- a/x-pack/plugins/lists/server/routes/patch_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/patch_list_item_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { listItemSchema, patchListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { listItemSchema, patchListItemSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/patch_list_route.ts b/x-pack/plugins/lists/server/routes/patch_list_route.ts index 3f2427b30f2be..fb88432bb1960 100644 --- a/x-pack/plugins/lists/server/routes/patch_list_route.ts +++ b/x-pack/plugins/lists/server/routes/patch_list_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { listSchema, patchListSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_URL } from '../../common/constants'; -import { listSchema, patchListSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/read_endpoint_list_item_route.ts b/x-pack/plugins/lists/server/routes/read_endpoint_list_item_route.ts index 72cfe38090cd8..be4a258cd5fb0 100644 --- a/x-pack/plugins/lists/server/routes/read_endpoint_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/read_endpoint_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { ReadEndpointListItemSchemaDecoded, exceptionListItemSchema, readEndpointListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/read_exception_list_item_route.ts b/x-pack/plugins/lists/server/routes/read_exception_list_item_route.ts index 3563645f554bb..e114625cde6a3 100644 --- a/x-pack/plugins/lists/server/routes/read_exception_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/read_exception_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { ReadExceptionListItemSchemaDecoded, exceptionListItemSchema, readExceptionListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/read_exception_list_route.ts b/x-pack/plugins/lists/server/routes/read_exception_list_route.ts index f82c397e67d2b..e88eb9cbb0745 100644 --- a/x-pack/plugins/lists/server/routes/read_exception_list_route.ts +++ b/x-pack/plugins/lists/server/routes/read_exception_list_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_URL } from '../../common/constants'; import { ReadExceptionListSchemaDecoded, exceptionListSchema, readExceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/read_list_index_route.ts b/x-pack/plugins/lists/server/routes/read_list_index_route.ts index 619600f3a7ee1..34344fb1051d2 100644 --- a/x-pack/plugins/lists/server/routes/read_list_index_route.ts +++ b/x-pack/plugins/lists/server/routes/read_list_index_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { listItemIndexExistSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_INDEX } from '../../common/constants'; -import { listItemIndexExistSchema } from '../../common/schemas'; import { buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/read_list_item_route.ts b/x-pack/plugins/lists/server/routes/read_list_item_route.ts index 2355a393d4a77..80a0b4b83514f 100644 --- a/x-pack/plugins/lists/server/routes/read_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/read_list_item_route.ts @@ -7,10 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { + listItemArraySchema, + listItemSchema, + readListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { listItemArraySchema, listItemSchema, readListItemSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/read_list_route.ts b/x-pack/plugins/lists/server/routes/read_list_route.ts index e66774998d554..3446d5af7b5f1 100644 --- a/x-pack/plugins/lists/server/routes/read_list_route.ts +++ b/x-pack/plugins/lists/server/routes/read_list_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { listSchema, readListSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_URL } from '../../common/constants'; -import { listSchema, readListSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/update_endpoint_list_item_route.ts b/x-pack/plugins/lists/server/routes/update_endpoint_list_item_route.ts index 9468fd2e8c226..4f00c94bda73a 100644 --- a/x-pack/plugins/lists/server/routes/update_endpoint_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/update_endpoint_list_item_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { UpdateEndpointListItemSchemaDecoded, exceptionListItemSchema, updateEndpointListItemSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { ENDPOINT_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/update_exception_list_item_route.ts b/x-pack/plugins/lists/server/routes/update_exception_list_item_route.ts index 6fbb1b7de80af..453fdcbdfd916 100644 --- a/x-pack/plugins/lists/server/routes/update_exception_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/update_exception_list_item_route.ts @@ -7,15 +7,15 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { UpdateExceptionListItemSchemaDecoded, exceptionListItemSchema, updateExceptionListItemSchema, -} from '../../common/schemas'; -import { updateExceptionListItemValidate } from '../../common/schemas/request/update_exception_list_item_validation'; + updateExceptionListItemValidate, +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_ITEM_URL } from '../../common/constants'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/update_exception_list_route.ts b/x-pack/plugins/lists/server/routes/update_exception_list_route.ts index cf670b28cee56..ef3da5506ab23 100644 --- a/x-pack/plugins/lists/server/routes/update_exception_list_route.ts +++ b/x-pack/plugins/lists/server/routes/update_exception_list_route.ts @@ -7,14 +7,14 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; - -import type { ListsPluginRouter } from '../types'; -import { EXCEPTION_LIST_URL } from '../../common/constants'; import { UpdateExceptionListSchemaDecoded, exceptionListSchema, updateExceptionListSchema, -} from '../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import type { ListsPluginRouter } from '../types'; +import { EXCEPTION_LIST_URL } from '../../common/constants'; import { buildRouteValidation, diff --git a/x-pack/plugins/lists/server/routes/update_list_item_route.ts b/x-pack/plugins/lists/server/routes/update_list_item_route.ts index f806b3f5d09d7..a8a0189dbb24b 100644 --- a/x-pack/plugins/lists/server/routes/update_list_item_route.ts +++ b/x-pack/plugins/lists/server/routes/update_list_item_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { listItemSchema, updateListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_ITEM_URL } from '../../common/constants'; -import { listItemSchema, updateListItemSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/update_list_route.ts b/x-pack/plugins/lists/server/routes/update_list_route.ts index 25457d7cdb333..c4293d7ca72f4 100644 --- a/x-pack/plugins/lists/server/routes/update_list_route.ts +++ b/x-pack/plugins/lists/server/routes/update_list_route.ts @@ -7,10 +7,10 @@ import { validate } from '@kbn/securitysolution-io-ts-utils'; import { transformError } from '@kbn/securitysolution-es-utils'; +import { listSchema, updateListSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { ListsPluginRouter } from '../types'; import { LIST_URL } from '../../common/constants'; -import { listSchema, updateListSchema } from '../../common/schemas'; import { buildRouteValidation, buildSiemResponse } from './utils'; diff --git a/x-pack/plugins/lists/server/routes/validate.ts b/x-pack/plugins/lists/server/routes/validate.ts index 2577770cf32ef..21e2ad187d045 100644 --- a/x-pack/plugins/lists/server/routes/validate.ts +++ b/x-pack/plugins/lists/server/routes/validate.ts @@ -12,12 +12,12 @@ import { exactCheck, formatErrors, validate } from '@kbn/securitysolution-io-ts- import { NamespaceType, NonEmptyEntriesArray, + foundExceptionListItemSchema, nonEmptyEndpointEntriesArray, } from '@kbn/securitysolution-io-ts-list-types'; import { ExceptionListClient } from '../services/exception_lists/exception_list_client'; import { MAX_EXCEPTION_LIST_SIZE } from '../../common/constants'; -import { foundExceptionListItemSchema } from '../../common/schemas'; export const validateExceptionListSize = async ( exceptionLists: ExceptionListClient, diff --git a/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_item_schema.ts b/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_item_schema.ts index 42788c15736b7..b3130b95fe978 100644 --- a/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_item_schema.ts +++ b/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_item_schema.ts @@ -9,18 +9,16 @@ import * as t from 'io-ts'; import { created_at, created_by, + deserializerOrUndefined, + list_id, metaOrUndefined, + serializerOrUndefined, + tie_breaker_id, updated_at, updated_by, } from '@kbn/securitysolution-io-ts-list-types'; import { esDataTypeUnion } from '../common/schemas'; -import { - deserializerOrUndefined, - list_id, - serializerOrUndefined, - tie_breaker_id, -} from '../../../common/schemas'; export const indexEsListItemSchema = t.intersection([ t.exact( diff --git a/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_schema.ts b/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_schema.ts index 607535b68c1e5..85e2eb95dd7e4 100644 --- a/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_schema.ts +++ b/x-pack/plugins/lists/server/schemas/elastic_query/index_es_list_schema.ts @@ -10,21 +10,18 @@ import { created_at, created_by, description, + deserializerOrUndefined, + immutable, metaOrUndefined, name, + serializerOrUndefined, + tie_breaker_id, type, updated_at, updated_by, } from '@kbn/securitysolution-io-ts-list-types'; import { version } from '@kbn/securitysolution-io-ts-types'; -import { - deserializerOrUndefined, - immutable, - serializerOrUndefined, - tie_breaker_id, -} from '../../../common/schemas'; - export const indexEsListSchema = t.exact( t.type({ created_at, diff --git a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.ts b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.ts index c787f70bfa675..158783ce088b2 100644 --- a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.ts +++ b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_item_schema.ts @@ -9,7 +9,11 @@ import * as t from 'io-ts'; import { created_at, created_by, + deserializerOrUndefined, + list_id, metaOrUndefined, + serializerOrUndefined, + tie_breaker_id, updated_at, updated_by, } from '@kbn/securitysolution-io-ts-list-types'; @@ -39,12 +43,6 @@ import { shortOrUndefined, textOrUndefined, } from '../common/schemas'; -import { - deserializerOrUndefined, - list_id, - serializerOrUndefined, - tie_breaker_id, -} from '../../../common/schemas'; export const searchEsListItemSchema = t.exact( t.type({ diff --git a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.ts b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.ts index f6d6ae4effe72..7e2ca2d6343cb 100644 --- a/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.ts +++ b/x-pack/plugins/lists/server/schemas/elastic_response/search_es_list_schema.ts @@ -10,21 +10,18 @@ import { created_at, created_by, description, + deserializerOrUndefined, + immutable, metaOrUndefined, name, + serializerOrUndefined, + tie_breaker_id, type, updated_at, updated_by, } from '@kbn/securitysolution-io-ts-list-types'; import { version } from '@kbn/securitysolution-io-ts-types'; -import { - deserializerOrUndefined, - immutable, - serializerOrUndefined, - tie_breaker_id, -} from '../../../common/schemas'; - export const searchEsListSchema = t.exact( t.type({ created_at, diff --git a/x-pack/plugins/lists/server/schemas/saved_objects/exceptions_list_so_schema.ts b/x-pack/plugins/lists/server/schemas/saved_objects/exceptions_list_so_schema.ts index d815dbaae0432..b5583e5bc9820 100644 --- a/x-pack/plugins/lists/server/schemas/saved_objects/exceptions_list_so_schema.ts +++ b/x-pack/plugins/lists/server/schemas/saved_objects/exceptions_list_so_schema.ts @@ -14,22 +14,19 @@ import { entriesArrayOrUndefined, exceptionListItemType, exceptionListType, + immutableOrUndefined, + itemIdOrUndefined, + list_id, + list_type, metaOrUndefined, name, osTypeArray, tags, + tie_breaker_id, updated_by, } from '@kbn/securitysolution-io-ts-list-types'; import { versionOrUndefined } from '@kbn/securitysolution-io-ts-types'; -import { - immutableOrUndefined, - itemIdOrUndefined, - list_id, - list_type, - tie_breaker_id, -} from '../../../common/schemas'; - /** * Superset saved object of both lists and list items since they share the same saved object type. */ diff --git a/x-pack/plugins/lists/server/services/exception_lists/create_endoint_event_filters_list.ts b/x-pack/plugins/lists/server/services/exception_lists/create_endoint_event_filters_list.ts index 9bcf6c63d065d..c2a7218f1cef8 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/create_endoint_event_filters_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/create_endoint_event_filters_list.ts @@ -8,13 +8,13 @@ import { SavedObjectsClientContract } from 'kibana/server'; import uuid from 'uuid'; import { Version } from '@kbn/securitysolution-io-ts-types'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ENDPOINT_EVENT_FILTERS_LIST_DESCRIPTION, ENDPOINT_EVENT_FILTERS_LIST_ID, ENDPOINT_EVENT_FILTERS_LIST_NAME, } from '../../../common/constants'; -import { ExceptionListSchema } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_list.ts b/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_list.ts index 86891e5f83955..aaf18362ec745 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_list.ts @@ -8,13 +8,13 @@ import { SavedObjectsClientContract } from 'kibana/server'; import uuid from 'uuid'; import { Version } from '@kbn/securitysolution-io-ts-types'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ENDPOINT_LIST_DESCRIPTION, ENDPOINT_LIST_ID, ENDPOINT_LIST_NAME, } from '../../../common/constants'; -import { ExceptionListSchema } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_trusted_apps_list.ts b/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_trusted_apps_list.ts index ada043403f248..a85f6da0f8b8f 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_trusted_apps_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_trusted_apps_list.ts @@ -7,14 +7,14 @@ import { SavedObjectsClientContract } from 'kibana/server'; import uuid from 'uuid'; -import { Version } from '@kbn/securitysolution-io-ts-types'; +import type { Version } from '@kbn/securitysolution-io-ts-types'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION, ENDPOINT_TRUSTED_APPS_LIST_ID, ENDPOINT_TRUSTED_APPS_LIST_NAME, } from '../../../common/constants'; -import { ExceptionListSchema } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/create_exception_list.ts b/x-pack/plugins/lists/server/services/exception_lists/create_exception_list.ts index c6110dc4f470c..f1d1f15a576a0 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/create_exception_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/create_exception_list.ts @@ -7,9 +7,12 @@ import { SavedObjectsClientContract } from 'kibana/server'; import uuid from 'uuid'; -import { +import type { Description, + ExceptionListSchema, ExceptionListType, + Immutable, + ListId, MetaOrUndefined, Name, NamespaceType, @@ -17,7 +20,6 @@ import { } from '@kbn/securitysolution-io-ts-list-types'; import { Version } from '@kbn/securitysolution-io-ts-types'; -import { ExceptionListSchema, Immutable, ListId } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/create_exception_list_item.ts b/x-pack/plugins/lists/server/services/exception_lists/create_exception_list_item.ts index 0bcc888a4c313..763ee8e3d85c7 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/create_exception_list_item.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/create_exception_list_item.ts @@ -7,11 +7,14 @@ import { SavedObjectsClientContract } from 'kibana/server'; import uuid from 'uuid'; -import { +import type { CreateCommentsArray, Description, EntriesArray, + ExceptionListItemSchema, ExceptionListItemType, + ItemId, + ListId, MetaOrUndefined, Name, NamespaceType, @@ -19,7 +22,6 @@ import { Tags, } from '@kbn/securitysolution-io-ts-list-types'; -import { ExceptionListItemSchema, ItemId, ListId } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { diff --git a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list.ts b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list.ts index 201cb9544a8f3..def0585740d45 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list.ts @@ -6,9 +6,12 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { IdOrUndefined, NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; - -import { ExceptionListSchema, ListIdOrUndefined } from '../../../common/schemas'; +import type { + ExceptionListSchema, + IdOrUndefined, + ListIdOrUndefined, + NamespaceType, +} from '@kbn/securitysolution-io-ts-list-types'; import { getSavedObjectType } from './utils'; import { getExceptionList } from './get_exception_list'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_item.ts b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_item.ts index 9f735fd51c7f2..65df08a445b58 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_item.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_item.ts @@ -6,9 +6,13 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { Id, IdOrUndefined, NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; - -import { ExceptionListItemSchema, ItemIdOrUndefined } from '../../../common/schemas'; +import type { + ExceptionListItemSchema, + Id, + IdOrUndefined, + ItemIdOrUndefined, + NamespaceType, +} from '@kbn/securitysolution-io-ts-list-types'; import { getSavedObjectType } from './utils'; import { getExceptionListItem } from './get_exception_list_item'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts index b08872eac8e01..b3190d174bb71 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/delete_exception_list_items_by_list.ts @@ -5,10 +5,9 @@ * 2.0. */ -import { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListId, NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; import { SavedObjectsClientContract } from '../../../../../../src/core/server/'; -import { ListId } from '../../../common/schemas'; import { findExceptionListItem } from './find_exception_list_item'; import { getSavedObjectType } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/exception_list_client.ts b/x-pack/plugins/lists/server/services/exception_lists/exception_list_client.ts index 84b6de1672cd6..a613219776004 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/exception_list_client.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/exception_list_client.ts @@ -6,14 +6,14 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; - -import { ENDPOINT_LIST_ID } from '../../../common/constants'; -import { +import type { ExceptionListItemSchema, ExceptionListSchema, FoundExceptionListItemSchema, FoundExceptionListSchema, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import { ENDPOINT_LIST_ID } from '../../../common/constants'; import { ConstructorOptions, diff --git a/x-pack/plugins/lists/server/services/exception_lists/exception_list_client_types.ts b/x-pack/plugins/lists/server/services/exception_lists/exception_list_client_types.ts index c6f5e3a3bc166..cbbf7f1513444 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/exception_list_client_types.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/exception_list_client_types.ts @@ -6,7 +6,7 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { +import type { CreateCommentsArray, Description, DescriptionOrUndefined, @@ -15,17 +15,28 @@ import { ExceptionListItemTypeOrUndefined, ExceptionListType, ExceptionListTypeOrUndefined, + FilterOrUndefined, Id, IdOrUndefined, + Immutable, + ItemId, + ItemIdOrUndefined, + ListId, + ListIdOrUndefined, MetaOrUndefined, Name, NameOrUndefined, NamespaceType, NamespaceTypeArray, OsTypeArray, + PageOrUndefined, + PerPageOrUndefined, + SortFieldOrUndefined, + SortOrderOrUndefined, Tags, TagsOrUndefined, UpdateCommentsArray, + _VersionOrUndefined, } from '@kbn/securitysolution-io-ts-list-types'; import { EmptyStringArrayDecoded, @@ -34,20 +45,6 @@ import { VersionOrUndefined, } from '@kbn/securitysolution-io-ts-types'; -import { - FilterOrUndefined, - Immutable, - ItemId, - ItemIdOrUndefined, - ListId, - ListIdOrUndefined, - PageOrUndefined, - PerPageOrUndefined, - SortFieldOrUndefined, - SortOrderOrUndefined, - _VersionOrUndefined, -} from '../../../common/schemas'; - export interface ConstructorOptions { user: string; savedObjectsClient: SavedObjectsClientContract; diff --git a/x-pack/plugins/lists/server/services/exception_lists/find_exception_list.ts b/x-pack/plugins/lists/server/services/exception_lists/find_exception_list.ts index dfe7a97d0b2f3..314cfc75e5a11 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/find_exception_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/find_exception_list.ts @@ -6,17 +6,17 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { NamespaceTypeArray } from '@kbn/securitysolution-io-ts-list-types'; - -import { SavedObjectType } from '../../../common/types'; -import { +import type { FilterOrUndefined, FoundExceptionListSchema, + NamespaceTypeArray, PageOrUndefined, PerPageOrUndefined, SortFieldOrUndefined, SortOrderOrUndefined, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + +import { SavedObjectType } from '../../../common/types'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectTypes, transformSavedObjectsToFoundExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_item.ts b/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_item.ts index b75520614150b..3d050652afed1 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_item.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_item.ts @@ -6,17 +6,16 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; - -import { +import type { FilterOrUndefined, FoundExceptionListItemSchema, ListId, + NamespaceType, PageOrUndefined, PerPageOrUndefined, SortFieldOrUndefined, SortOrderOrUndefined, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; import { findExceptionListsItem } from './find_exception_list_items'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_items.ts b/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_items.ts index ad4646a57a5ca..04eca6a042ace 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_items.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/find_exception_list_items.ts @@ -6,8 +6,16 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { Id, NamespaceTypeArray } from '@kbn/securitysolution-io-ts-list-types'; -import { +import type { + FoundExceptionListItemSchema, + Id, + NamespaceTypeArray, + PageOrUndefined, + PerPageOrUndefined, + SortFieldOrUndefined, + SortOrderOrUndefined, +} from '@kbn/securitysolution-io-ts-list-types'; +import type { EmptyStringArrayDecoded, NonEmptyStringArrayDecoded, } from '@kbn/securitysolution-io-ts-types'; @@ -17,13 +25,6 @@ import { exceptionListAgnosticSavedObjectType, exceptionListSavedObjectType, } from '../../../common/types'; -import { - FoundExceptionListItemSchema, - PageOrUndefined, - PerPageOrUndefined, - SortFieldOrUndefined, - SortOrderOrUndefined, -} from '../../../common/schemas'; import { escapeQuotes } from '../utils/escape_query'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts index 928190efbf531..e1dc8bfe98847 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { IdOrUndefined, NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; +import type { + ExceptionListSchema, + IdOrUndefined, + ListIdOrUndefined, + NamespaceType, +} from '@kbn/securitysolution-io-ts-list-types'; import { SavedObjectsClientContract, SavedObjectsErrorHelpers, } from '../../../../../../src/core/server/'; -import { ExceptionListSchema, ListIdOrUndefined } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts index be612868abe48..a8b201cff0397 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/get_exception_list_item.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { IdOrUndefined, NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; +import type { + ExceptionListItemSchema, + IdOrUndefined, + ItemIdOrUndefined, + NamespaceType, +} from '@kbn/securitysolution-io-ts-list-types'; import { SavedObjectsClientContract, SavedObjectsErrorHelpers, } from '../../../../../../src/core/server/'; -import { ExceptionListItemSchema, ItemIdOrUndefined } from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectToExceptionListItem } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/update_exception_list.ts b/x-pack/plugins/lists/server/services/exception_lists/update_exception_list.ts index 43c319cca0005..0cdae4375fa59 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/update_exception_list.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/update_exception_list.ts @@ -6,23 +6,21 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { +import type { DescriptionOrUndefined, + ExceptionListSchema, ExceptionListTypeOrUndefined, IdOrUndefined, + ListIdOrUndefined, MetaOrUndefined, NameOrUndefined, NamespaceType, OsTypeArray, TagsOrUndefined, + _VersionOrUndefined, } from '@kbn/securitysolution-io-ts-list-types'; import { VersionOrUndefined } from '@kbn/securitysolution-io-ts-types'; -import { - ExceptionListSchema, - ListIdOrUndefined, - _VersionOrUndefined, -} from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { getSavedObjectType, transformSavedObjectUpdateToExceptionList } from './utils'; diff --git a/x-pack/plugins/lists/server/services/exception_lists/update_exception_list_item.ts b/x-pack/plugins/lists/server/services/exception_lists/update_exception_list_item.ts index 0d9ba8d8fefcc..2c1f5b81b2bcf 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/update_exception_list_item.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/update_exception_list_item.ts @@ -6,24 +6,22 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { +import type { DescriptionOrUndefined, EntriesArray, + ExceptionListItemSchema, ExceptionListItemTypeOrUndefined, IdOrUndefined, + ItemIdOrUndefined, MetaOrUndefined, NameOrUndefined, NamespaceType, OsTypeArray, TagsOrUndefined, UpdateCommentsArrayOrUndefined, + _VersionOrUndefined, } from '@kbn/securitysolution-io-ts-list-types'; -import { - ExceptionListItemSchema, - ItemIdOrUndefined, - _VersionOrUndefined, -} from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; import { diff --git a/x-pack/plugins/lists/server/services/exception_lists/utils.ts b/x-pack/plugins/lists/server/services/exception_lists/utils.ts index 12fe8eabd4f6a..7479510110709 100644 --- a/x-pack/plugins/lists/server/services/exception_lists/utils.ts +++ b/x-pack/plugins/lists/server/services/exception_lists/utils.ts @@ -11,6 +11,10 @@ import { CommentsArray, CreateComment, CreateCommentsArray, + ExceptionListItemSchema, + ExceptionListSchema, + FoundExceptionListItemSchema, + FoundExceptionListSchema, NamespaceType, NamespaceTypeArray, UpdateCommentsArrayOrUndefined, @@ -23,12 +27,6 @@ import { exceptionListAgnosticSavedObjectType, exceptionListSavedObjectType, } from '../../../common/types'; -import { - ExceptionListItemSchema, - ExceptionListSchema, - FoundExceptionListItemSchema, - FoundExceptionListSchema, -} from '../../../common/schemas'; import { ExceptionListSoSchema } from '../../schemas/saved_objects'; export const getSavedObjectType = ({ diff --git a/x-pack/plugins/lists/server/services/items/create_list_item.ts b/x-pack/plugins/lists/server/services/items/create_list_item.ts index ebeef3e90933d..b4203f000b7b9 100644 --- a/x-pack/plugins/lists/server/services/items/create_list_item.ts +++ b/x-pack/plugins/lists/server/services/items/create_list_item.ts @@ -7,13 +7,15 @@ import uuid from 'uuid'; import { ElasticsearchClient } from 'kibana/server'; -import { IdOrUndefined, MetaOrUndefined, Type } from '@kbn/securitysolution-io-ts-list-types'; - import { DeserializerOrUndefined, + IdOrUndefined, ListItemSchema, + MetaOrUndefined, SerializerOrUndefined, -} from '../../../common/schemas'; + Type, +} from '@kbn/securitysolution-io-ts-list-types'; + import { transformListItemToElasticQuery } from '../utils'; import { encodeHitVersion } from '../utils/encode_hit_version'; import { IndexEsListItemSchema } from '../../schemas/elastic_query'; diff --git a/x-pack/plugins/lists/server/services/items/create_list_items_bulk.ts b/x-pack/plugins/lists/server/services/items/create_list_items_bulk.ts index 00956a7c3c3fa..d9b3bc322cd7a 100644 --- a/x-pack/plugins/lists/server/services/items/create_list_items_bulk.ts +++ b/x-pack/plugins/lists/server/services/items/create_list_items_bulk.ts @@ -7,10 +7,14 @@ import uuid from 'uuid'; import { ElasticsearchClient } from 'kibana/server'; -import { MetaOrUndefined, Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { + DeserializerOrUndefined, + MetaOrUndefined, + SerializerOrUndefined, + Type, +} from '@kbn/securitysolution-io-ts-list-types'; import { transformListItemToElasticQuery } from '../utils'; -import { DeserializerOrUndefined, SerializerOrUndefined } from '../../../common/schemas'; import { CreateEsBulkTypeSchema, IndexEsListItemSchema } from '../../schemas/elastic_query'; export interface CreateListItemsBulkOptions { diff --git a/x-pack/plugins/lists/server/services/items/delete_list_item.ts b/x-pack/plugins/lists/server/services/items/delete_list_item.ts index c08e683aafa1c..c43f2faf8c52d 100644 --- a/x-pack/plugins/lists/server/services/items/delete_list_item.ts +++ b/x-pack/plugins/lists/server/services/items/delete_list_item.ts @@ -6,9 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Id } from '@kbn/securitysolution-io-ts-list-types'; - -import { ListItemSchema } from '../../../common/schemas'; +import type { Id, ListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getListItem } from '.'; diff --git a/x-pack/plugins/lists/server/services/items/delete_list_item_by_value.ts b/x-pack/plugins/lists/server/services/items/delete_list_item_by_value.ts index 1adcf45e85748..cc3dc92f8f152 100644 --- a/x-pack/plugins/lists/server/services/items/delete_list_item_by_value.ts +++ b/x-pack/plugins/lists/server/services/items/delete_list_item_by_value.ts @@ -6,9 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { ListItemArraySchema } from '../../../common/schemas'; import { getQueryFilterFromTypeValue } from '../utils'; import { getListItemByValues } from './get_list_item_by_values'; diff --git a/x-pack/plugins/lists/server/services/items/find_list_item.ts b/x-pack/plugins/lists/server/services/items/find_list_item.ts index e1586daf1cbb1..803cc34ed2a12 100644 --- a/x-pack/plugins/lists/server/services/items/find_list_item.ts +++ b/x-pack/plugins/lists/server/services/items/find_list_item.ts @@ -6,8 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; - -import { +import type { Filter, FoundListItemSchema, ListId, @@ -15,7 +14,8 @@ import { PerPage, SortFieldOrUndefined, SortOrderOrUndefined, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { SearchEsListItemSchema } from '../../schemas/elastic_response'; import { getList } from '../lists'; import { diff --git a/x-pack/plugins/lists/server/services/items/get_list_item.ts b/x-pack/plugins/lists/server/services/items/get_list_item.ts index a1653cb31ce16..f7b9c06349870 100644 --- a/x-pack/plugins/lists/server/services/items/get_list_item.ts +++ b/x-pack/plugins/lists/server/services/items/get_list_item.ts @@ -6,9 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Id } from '@kbn/securitysolution-io-ts-list-types'; +import type { Id, ListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListItemSchema } from '../../../common/schemas'; import { transformElasticToListItem } from '../utils'; import { findSourceType } from '../utils/find_source_type'; import { SearchEsListItemSchema } from '../../schemas/elastic_response'; diff --git a/x-pack/plugins/lists/server/services/items/get_list_item_by_value.ts b/x-pack/plugins/lists/server/services/items/get_list_item_by_value.ts index a190f9388bef3..d631720d11cd3 100644 --- a/x-pack/plugins/lists/server/services/items/get_list_item_by_value.ts +++ b/x-pack/plugins/lists/server/services/items/get_list_item_by_value.ts @@ -6,9 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; - -import { ListItemArraySchema } from '../../../common/schemas'; +import type { ListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; import { getListItemByValues } from '.'; diff --git a/x-pack/plugins/lists/server/services/items/get_list_item_by_values.ts b/x-pack/plugins/lists/server/services/items/get_list_item_by_values.ts index 0fcb958940d9b..9c7709b6f4459 100644 --- a/x-pack/plugins/lists/server/services/items/get_list_item_by_values.ts +++ b/x-pack/plugins/lists/server/services/items/get_list_item_by_values.ts @@ -6,9 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { ListItemArraySchema } from '../../../common/schemas'; import { TransformElasticToListItemOptions, getQueryFilterFromTypeValue, diff --git a/x-pack/plugins/lists/server/services/items/search_list_item_by_values.test.ts b/x-pack/plugins/lists/server/services/items/search_list_item_by_values.test.ts index 817432495926b..174a44ce16600 100644 --- a/x-pack/plugins/lists/server/services/items/search_list_item_by_values.test.ts +++ b/x-pack/plugins/lists/server/services/items/search_list_item_by_values.test.ts @@ -7,8 +7,8 @@ // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; +import type { SearchListItemArraySchema } from '@kbn/securitysolution-io-ts-list-types'; -import { SearchListItemArraySchema } from '../../../common/schemas'; import { LIST_ID, LIST_ITEM_INDEX, TYPE, VALUE, VALUE_2 } from '../../../common/constants.mock'; import { getSearchListItemMock } from '../../schemas/elastic_response/search_es_list_item_schema.mock'; diff --git a/x-pack/plugins/lists/server/services/items/search_list_item_by_values.ts b/x-pack/plugins/lists/server/services/items/search_list_item_by_values.ts index 2b525fde6a428..942791c0ebe91 100644 --- a/x-pack/plugins/lists/server/services/items/search_list_item_by_values.ts +++ b/x-pack/plugins/lists/server/services/items/search_list_item_by_values.ts @@ -6,9 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { SearchListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { SearchListItemArraySchema } from '../../../common/schemas'; import { TransformElasticMSearchToListItemOptions, getQueryFilterFromTypeValue, diff --git a/x-pack/plugins/lists/server/services/items/update_list_item.test.ts b/x-pack/plugins/lists/server/services/items/update_list_item.test.ts index 195bce879f34d..8d8f1e117647a 100644 --- a/x-pack/plugins/lists/server/services/items/update_list_item.test.ts +++ b/x-pack/plugins/lists/server/services/items/update_list_item.test.ts @@ -7,8 +7,8 @@ // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; +import type { ListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListItemSchema } from '../../../common/schemas'; import { getListItemResponseMock } from '../../../common/schemas/response/list_item_schema.mock'; import { updateListItem } from './update_list_item'; diff --git a/x-pack/plugins/lists/server/services/items/update_list_item.ts b/x-pack/plugins/lists/server/services/items/update_list_item.ts index 4f1a19430aeda..c73149019f416 100644 --- a/x-pack/plugins/lists/server/services/items/update_list_item.ts +++ b/x-pack/plugins/lists/server/services/items/update_list_item.ts @@ -6,9 +6,13 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Id, MetaOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; +import type { + Id, + ListItemSchema, + MetaOrUndefined, + _VersionOrUndefined, +} from '@kbn/securitysolution-io-ts-list-types'; -import { ListItemSchema, _VersionOrUndefined } from '../../../common/schemas'; import { transformListItemToElasticQuery } from '../utils'; import { decodeVersion } from '../utils/decode_version'; import { encodeHitVersion } from '../utils/encode_hit_version'; diff --git a/x-pack/plugins/lists/server/services/items/write_lines_to_bulk_list_items.ts b/x-pack/plugins/lists/server/services/items/write_lines_to_bulk_list_items.ts index 392c44cf72b00..89a6bdbc77878 100644 --- a/x-pack/plugins/lists/server/services/items/write_lines_to_bulk_list_items.ts +++ b/x-pack/plugins/lists/server/services/items/write_lines_to_bulk_list_items.ts @@ -8,16 +8,17 @@ import { Readable } from 'stream'; import { ElasticsearchClient } from 'kibana/server'; -import { MetaOrUndefined, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { Version } from '@kbn/securitysolution-io-ts-types'; - -import { createListIfItDoesNotExist } from '../lists/create_list_if_it_does_not_exist'; -import { +import type { DeserializerOrUndefined, ListIdOrUndefined, ListSchema, + MetaOrUndefined, SerializerOrUndefined, -} from '../../../common/schemas'; + Type, +} from '@kbn/securitysolution-io-ts-list-types'; +import { Version } from '@kbn/securitysolution-io-ts-types'; + +import { createListIfItDoesNotExist } from '../lists/create_list_if_it_does_not_exist'; import { ConfigType } from '../../config'; import { BufferLines } from './buffer_lines'; diff --git a/x-pack/plugins/lists/server/services/lists/create_list.test.ts b/x-pack/plugins/lists/server/services/lists/create_list.test.ts index 600d148d77b95..0474f1bac2700 100644 --- a/x-pack/plugins/lists/server/services/lists/create_list.test.ts +++ b/x-pack/plugins/lists/server/services/lists/create_list.test.ts @@ -7,8 +7,8 @@ // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListSchema } from '../../../common/schemas'; import { getListResponseMock } from '../../../common/schemas/response/list_schema.mock'; import { LIST_ID, LIST_INDEX } from '../../../common/constants.mock'; import { getIndexESListMock } from '../../schemas/elastic_query/index_es_list_schema.mock'; diff --git a/x-pack/plugins/lists/server/services/lists/create_list.ts b/x-pack/plugins/lists/server/services/lists/create_list.ts index bd5b3c901fdc5..6c7081d7c701e 100644 --- a/x-pack/plugins/lists/server/services/lists/create_list.ts +++ b/x-pack/plugins/lists/server/services/lists/create_list.ts @@ -7,22 +7,20 @@ import uuid from 'uuid'; import { ElasticsearchClient } from 'kibana/server'; -import { +import type { Description, + DeserializerOrUndefined, IdOrUndefined, + Immutable, + ListSchema, MetaOrUndefined, Name, + SerializerOrUndefined, Type, } from '@kbn/securitysolution-io-ts-list-types'; -import { Version } from '@kbn/securitysolution-io-ts-types'; +import type { Version } from '@kbn/securitysolution-io-ts-types'; import { encodeHitVersion } from '../utils/encode_hit_version'; -import { - DeserializerOrUndefined, - Immutable, - ListSchema, - SerializerOrUndefined, -} from '../../../common/schemas'; import { IndexEsListSchema } from '../../schemas/elastic_query'; export interface CreateListOptions { diff --git a/x-pack/plugins/lists/server/services/lists/create_list_if_it_does_not_exist.ts b/x-pack/plugins/lists/server/services/lists/create_list_if_it_does_not_exist.ts index 4d4e634a465a7..f97fbd2d88cc0 100644 --- a/x-pack/plugins/lists/server/services/lists/create_list_if_it_does_not_exist.ts +++ b/x-pack/plugins/lists/server/services/lists/create_list_if_it_does_not_exist.ts @@ -6,21 +6,18 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { +import type { Description, + DeserializerOrUndefined, Id, + Immutable, + ListSchema, MetaOrUndefined, Name, + SerializerOrUndefined, Type, } from '@kbn/securitysolution-io-ts-list-types'; -import { Version } from '@kbn/securitysolution-io-ts-types'; - -import { - DeserializerOrUndefined, - Immutable, - ListSchema, - SerializerOrUndefined, -} from '../../../common/schemas'; +import type { Version } from '@kbn/securitysolution-io-ts-types'; import { getList } from './get_list'; import { createList } from './create_list'; diff --git a/x-pack/plugins/lists/server/services/lists/delete_list.ts b/x-pack/plugins/lists/server/services/lists/delete_list.ts index a215044b92b4c..b9a55e107ab76 100644 --- a/x-pack/plugins/lists/server/services/lists/delete_list.ts +++ b/x-pack/plugins/lists/server/services/lists/delete_list.ts @@ -6,9 +6,7 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Id } from '@kbn/securitysolution-io-ts-list-types'; - -import { ListSchema } from '../../../common/schemas'; +import type { Id, ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getList } from './get_list'; diff --git a/x-pack/plugins/lists/server/services/lists/find_list.ts b/x-pack/plugins/lists/server/services/lists/find_list.ts index 92d7262c19543..1c7a5fe60b995 100644 --- a/x-pack/plugins/lists/server/services/lists/find_list.ts +++ b/x-pack/plugins/lists/server/services/lists/find_list.ts @@ -6,15 +6,15 @@ */ import { ElasticsearchClient } from 'kibana/server'; - -import { +import type { Filter, FoundListSchema, Page, PerPage, SortFieldOrUndefined, SortOrderOrUndefined, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { SearchEsListSchema } from '../../schemas/elastic_response'; import { encodeCursor, diff --git a/x-pack/plugins/lists/server/services/lists/get_list.ts b/x-pack/plugins/lists/server/services/lists/get_list.ts index 7ff17bc2ee553..9b120ca0dd358 100644 --- a/x-pack/plugins/lists/server/services/lists/get_list.ts +++ b/x-pack/plugins/lists/server/services/lists/get_list.ts @@ -6,9 +6,8 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { Id } from '@kbn/securitysolution-io-ts-list-types'; +import type { Id, ListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListSchema } from '../../../common/schemas'; import { transformElasticToList } from '../utils/transform_elastic_to_list'; import { SearchEsListSchema } from '../../schemas/elastic_response'; diff --git a/x-pack/plugins/lists/server/services/lists/list_client.ts b/x-pack/plugins/lists/server/services/lists/list_client.ts index a602bcf943808..107bc31f2baea 100644 --- a/x-pack/plugins/lists/server/services/lists/list_client.ts +++ b/x-pack/plugins/lists/server/services/lists/list_client.ts @@ -17,15 +17,15 @@ import { setPolicy, setTemplate, } from '@kbn/securitysolution-es-utils'; - -import { +import type { FoundListItemSchema, FoundListSchema, ListItemArraySchema, ListItemSchema, ListSchema, SearchListItemArraySchema, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { ConfigType } from '../../config'; import { createList, diff --git a/x-pack/plugins/lists/server/services/lists/list_client_types.ts b/x-pack/plugins/lists/server/services/lists/list_client_types.ts index 28732090342cd..86b69d5469dc4 100644 --- a/x-pack/plugins/lists/server/services/lists/list_client_types.ts +++ b/x-pack/plugins/lists/server/services/lists/list_client_types.ts @@ -8,31 +8,29 @@ import { PassThrough, Readable } from 'stream'; import { ElasticsearchClient } from 'kibana/server'; -import { +import type { Description, DescriptionOrUndefined, - Id, - IdOrUndefined, - MetaOrUndefined, - Name, - NameOrUndefined, - Type, -} from '@kbn/securitysolution-io-ts-list-types'; -import { Version, VersionOrUndefined } from '@kbn/securitysolution-io-ts-types'; - -import { DeserializerOrUndefined, Filter, + Id, + IdOrUndefined, Immutable, ListId, ListIdOrUndefined, + MetaOrUndefined, + Name, + NameOrUndefined, Page, PerPage, SerializerOrUndefined, SortFieldOrUndefined, SortOrderOrUndefined, + Type, _VersionOrUndefined, -} from '../../../common/schemas'; +} from '@kbn/securitysolution-io-ts-list-types'; +import { Version, VersionOrUndefined } from '@kbn/securitysolution-io-ts-types'; + import { ConfigType } from '../../config'; export interface ConstructorOptions { diff --git a/x-pack/plugins/lists/server/services/lists/update_list.test.ts b/x-pack/plugins/lists/server/services/lists/update_list.test.ts index 8cc1c60ecc23d..df5aa4e53ca6c 100644 --- a/x-pack/plugins/lists/server/services/lists/update_list.test.ts +++ b/x-pack/plugins/lists/server/services/lists/update_list.test.ts @@ -7,8 +7,8 @@ // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { elasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListSchema } from '../../../common/schemas'; import { getListResponseMock } from '../../../common/schemas/response/list_schema.mock'; import { updateList } from './update_list'; diff --git a/x-pack/plugins/lists/server/services/lists/update_list.ts b/x-pack/plugins/lists/server/services/lists/update_list.ts index 2e1cc43826817..22235341ca075 100644 --- a/x-pack/plugins/lists/server/services/lists/update_list.ts +++ b/x-pack/plugins/lists/server/services/lists/update_list.ts @@ -6,17 +6,18 @@ */ import { ElasticsearchClient } from 'kibana/server'; -import { +import type { DescriptionOrUndefined, Id, + ListSchema, MetaOrUndefined, NameOrUndefined, + _VersionOrUndefined, } from '@kbn/securitysolution-io-ts-list-types'; import { VersionOrUndefined } from '@kbn/securitysolution-io-ts-types'; import { decodeVersion } from '../utils/decode_version'; import { encodeHitVersion } from '../utils/encode_hit_version'; -import { ListSchema, _VersionOrUndefined } from '../../../common/schemas'; import { UpdateEsListSchema } from '../../schemas/elastic_query'; import { getList } from '.'; diff --git a/x-pack/plugins/lists/server/services/utils/calculate_scroll_math.ts b/x-pack/plugins/lists/server/services/utils/calculate_scroll_math.ts index 1ea8deda602c7..e2f2229188ef4 100644 --- a/x-pack/plugins/lists/server/services/utils/calculate_scroll_math.ts +++ b/x-pack/plugins/lists/server/services/utils/calculate_scroll_math.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Page, PerPage } from '../../../common/schemas'; +import type { Page, PerPage } from '@kbn/securitysolution-io-ts-list-types'; interface CalculateScrollMathOptions { perPage: PerPage; diff --git a/x-pack/plugins/lists/server/services/utils/encode_decode_cursor.ts b/x-pack/plugins/lists/server/services/utils/encode_decode_cursor.ts index a1a349d5e38da..e7b785aea9fb5 100644 --- a/x-pack/plugins/lists/server/services/utils/encode_decode_cursor.ts +++ b/x-pack/plugins/lists/server/services/utils/encode_decode_cursor.ts @@ -9,8 +9,10 @@ import * as t from 'io-ts'; import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { exactCheck } from '@kbn/securitysolution-io-ts-utils'; - -import { CursorOrUndefined, SortFieldOrUndefined } from '../../../common/schemas'; +import type { + CursorOrUndefined, + SortFieldOrUndefined, +} from '@kbn/securitysolution-io-ts-list-types'; /** * Used only internally for this ad-hoc opaque cursor structure to keep track of the diff --git a/x-pack/plugins/lists/server/services/utils/find_source_type.test.ts b/x-pack/plugins/lists/server/services/utils/find_source_type.test.ts index 80b10142d553a..9f61173ac2caa 100644 --- a/x-pack/plugins/lists/server/services/utils/find_source_type.test.ts +++ b/x-pack/plugins/lists/server/services/utils/find_source_type.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { Type } from '@kbn/securitysolution-io-ts-list-types'; import { getSearchEsListItemMock } from '../../schemas/elastic_response/search_es_list_item_schema.mock'; import { SearchEsListItemSchema } from '../../schemas/elastic_response'; diff --git a/x-pack/plugins/lists/server/services/utils/find_source_value.ts b/x-pack/plugins/lists/server/services/utils/find_source_value.ts index 7990481c3e3db..ed39b51dac6c6 100644 --- a/x-pack/plugins/lists/server/services/utils/find_source_value.ts +++ b/x-pack/plugins/lists/server/services/utils/find_source_value.ts @@ -6,9 +6,8 @@ */ import Mustache from 'mustache'; -import { type } from '@kbn/securitysolution-io-ts-list-types'; +import { DeserializerOrUndefined, type } from '@kbn/securitysolution-io-ts-list-types'; -import { DeserializerOrUndefined } from '../../../common/schemas'; import { SearchEsListItemSchema } from '../../schemas/elastic_response'; import { esDataTypeGeoPointRange, esDataTypeRange } from '../../schemas/common/schemas'; diff --git a/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts b/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts index 6a30cb5d6a847..a272bc52c857b 100644 --- a/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts +++ b/x-pack/plugins/lists/server/services/utils/get_query_filter_from_type_value.ts @@ -6,7 +6,7 @@ */ import { isEmpty, isObject } from 'lodash/fp'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { Type } from '@kbn/securitysolution-io-ts-list-types'; export type QueryFilterType = [ { term: Record }, diff --git a/x-pack/plugins/lists/server/services/utils/get_search_after_scroll.ts b/x-pack/plugins/lists/server/services/utils/get_search_after_scroll.ts index ae37e47861845..4ddd3f1c73315 100644 --- a/x-pack/plugins/lists/server/services/utils/get_search_after_scroll.ts +++ b/x-pack/plugins/lists/server/services/utils/get_search_after_scroll.ts @@ -6,8 +6,12 @@ */ import { ElasticsearchClient } from 'kibana/server'; +import type { + Filter, + SortFieldOrUndefined, + SortOrderOrUndefined, +} from '@kbn/securitysolution-io-ts-list-types'; -import { Filter, SortFieldOrUndefined, SortOrderOrUndefined } from '../../../common/schemas'; import { Scroll } from '../lists/types'; import { getQueryFilter } from './get_query_filter'; diff --git a/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts b/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts index 3cd902aeeb36e..7db46ce1a464c 100644 --- a/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts +++ b/x-pack/plugins/lists/server/services/utils/get_search_after_with_tie_breaker.ts @@ -5,8 +5,7 @@ * 2.0. */ import type { estypes } from '@elastic/elasticsearch'; - -import { SortFieldOrUndefined } from '../../../common/schemas'; +import type { SortFieldOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; export type TieBreaker = T & { tie_breaker_id: string; diff --git a/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts b/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts index 97cfe3dd8e634..dbcec20d3d8a8 100644 --- a/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts +++ b/x-pack/plugins/lists/server/services/utils/get_sort_with_tie_breaker.ts @@ -5,8 +5,7 @@ * 2.0. */ import type { estypes } from '@elastic/elasticsearch'; - -import { SortFieldOrUndefined, SortOrderOrUndefined } from '../../../common/schemas'; +import { SortFieldOrUndefined, SortOrderOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; export const getSortWithTieBreaker = ({ sortField, diff --git a/x-pack/plugins/lists/server/services/utils/get_source_with_tie_breaker.ts b/x-pack/plugins/lists/server/services/utils/get_source_with_tie_breaker.ts index 7a7e55f542d9e..2526e0240b26b 100644 --- a/x-pack/plugins/lists/server/services/utils/get_source_with_tie_breaker.ts +++ b/x-pack/plugins/lists/server/services/utils/get_source_with_tie_breaker.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SortFieldOrUndefined } from '../../../common/schemas'; +import type { SortFieldOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; export const getSourceWithTieBreaker = ({ sortField, diff --git a/x-pack/plugins/lists/server/services/utils/scroll_to_start_page.ts b/x-pack/plugins/lists/server/services/utils/scroll_to_start_page.ts index 2b65c0df54a83..8ca0d574fd6e6 100644 --- a/x-pack/plugins/lists/server/services/utils/scroll_to_start_page.ts +++ b/x-pack/plugins/lists/server/services/utils/scroll_to_start_page.ts @@ -6,8 +6,12 @@ */ import { ElasticsearchClient } from 'kibana/server'; +import type { + Filter, + SortFieldOrUndefined, + SortOrderOrUndefined, +} from '@kbn/securitysolution-io-ts-list-types'; -import { Filter, SortFieldOrUndefined, SortOrderOrUndefined } from '../../../common/schemas'; import { Scroll } from '../lists/types'; import { calculateScrollMath } from './calculate_scroll_math'; diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.test.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.test.ts index 1846f1b7909fb..75e38819d3b05 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.test.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.test.ts @@ -5,9 +5,10 @@ * 2.0. */ +import type { SearchListItemArraySchema } from '@kbn/securitysolution-io-ts-list-types'; + import { getSearchListItemResponseMock } from '../../../common/schemas/response/search_list_item_schema.mock'; import { LIST_INDEX, LIST_ITEM_ID, TYPE, VALUE } from '../../../common/constants.mock'; -import { SearchListItemArraySchema } from '../../../common/schemas'; import { getSearchEsListItemMock, getSearchListItemMock, diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts index 902fc17039792..b669b983fe46d 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_named_search_to_list_item.ts @@ -6,9 +6,8 @@ */ import type { estypes } from '@elastic/elasticsearch'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import { SearchListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { SearchListItemArraySchema } from '../../../common/schemas'; import { SearchEsListItemSchema } from '../../schemas/elastic_response'; import { transformElasticHitsToListItem } from './transform_elastic_to_list_item'; diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts index 8d8c076f6e219..19177c1c2785f 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list.ts @@ -6,8 +6,8 @@ */ import type { estypes } from '@elastic/elasticsearch'; +import type { ListArraySchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ListArraySchema } from '../../../common/schemas'; import { SearchEsListSchema } from '../../schemas/elastic_response'; import { encodeHitVersion } from './encode_hit_version'; diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.test.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.test.ts index 3629881f61d5a..2714d13cb0a26 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.test.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.test.ts @@ -5,8 +5,9 @@ * 2.0. */ +import type { ListItemArraySchema } from '@kbn/securitysolution-io-ts-list-types'; + import { getListItemResponseMock } from '../../../common/schemas/response/list_item_schema.mock'; -import { ListItemArraySchema } from '../../../common/schemas'; import { getSearchListItemMock } from '../../schemas/elastic_response/search_es_list_item_schema.mock'; import { diff --git a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts index 1cbf72e8eb653..585eeeb118110 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_elastic_to_list_item.ts @@ -6,9 +6,8 @@ */ import type { estypes } from '@elastic/elasticsearch'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListItemArraySchema, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { ListItemArraySchema } from '../../../common/schemas'; import { ErrorWithStatusCode } from '../../error_with_status_code'; import { SearchEsListItemSchema } from '../../schemas/elastic_response'; diff --git a/x-pack/plugins/lists/server/services/utils/transform_list_item_to_elastic_query.ts b/x-pack/plugins/lists/server/services/utils/transform_list_item_to_elastic_query.ts index fc97bef54b0a6..67a7504594bef 100644 --- a/x-pack/plugins/lists/server/services/utils/transform_list_item_to_elastic_query.ts +++ b/x-pack/plugins/lists/server/services/utils/transform_list_item_to_elastic_query.ts @@ -5,9 +5,8 @@ * 2.0. */ -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { SerializerOrUndefined, Type } from '@kbn/securitysolution-io-ts-list-types'; -import { SerializerOrUndefined } from '../../../common/schemas'; import { EsDataTypeGeoPoint, EsDataTypeGeoShape, diff --git a/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.ts b/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.ts index 7d24c1e157e40..4308b814f47a7 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.ts @@ -6,16 +6,16 @@ */ import { Language } from '@kbn/securitysolution-io-ts-alerting-types'; +import type { + ExceptionListItemSchema, + CreateExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { Filter, IIndexPattern, buildEsQuery, EsQueryConfig, } from '../../../../../src/plugins/data/common'; -import { - ExceptionListItemSchema, - CreateExceptionListItemSchema, -} from '../../../lists/common/schemas'; import { ESBoolQuery } from '../typed_json'; import { buildExceptionFilter } from '../shared_imports'; import { Query, Index, TimestampOverrideOrUndefined } from './schemas/common/schemas'; diff --git a/x-pack/plugins/security_solution/common/detection_engine/schemas/response/rules_schema.test.ts b/x-pack/plugins/security_solution/common/detection_engine/schemas/response/rules_schema.test.ts index a8521c013f451..ef18cf24e87a3 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/schemas/response/rules_schema.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/schemas/response/rules_schema.test.ts @@ -29,7 +29,7 @@ import { getThreatMatchingSchemaMock, getRulesEqlSchemaMock, } from './rules_schema.mocks'; -import { ListArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListArray } from '@kbn/securitysolution-io-ts-list-types'; export const ANCHOR_DATE = '2020-02-20T03:57:54.037Z'; diff --git a/x-pack/plugins/security_solution/common/detection_engine/utils.ts b/x-pack/plugins/security_solution/common/detection_engine/utils.ts index 6aa672881ff70..56f2a11900dd3 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/utils.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/utils.ts @@ -7,10 +7,13 @@ import { isEmpty } from 'lodash'; -import type { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { + EntriesArray, + CreateExceptionListItemSchema, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { Type } from '@kbn/securitysolution-io-ts-alerting-types'; -import { CreateExceptionListItemSchema, ExceptionListItemSchema } from '../shared_imports'; import { JobStatus, Threshold, ThresholdNormalized } from './schemas/common/schemas'; diff --git a/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts b/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts index 6bdbb9cde2034..c09f098979160 100644 --- a/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts +++ b/x-pack/plugins/security_solution/common/endpoint/data_generators/event_filter_generator.ts @@ -5,9 +5,9 @@ * 2.0. */ +import type { CreateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { BaseDataGenerator } from './base_data_generator'; import { ENDPOINT_EVENT_FILTERS_LIST_ID } from '../../../../lists/common/constants'; -import { CreateExceptionListItemSchema } from '../../../../lists/common'; import { getCreateExceptionListItemSchemaMock } from '../../../../lists/common/schemas/request/create_exception_list_item_schema.mock'; export class EventFilterGenerator extends BaseDataGenerator { diff --git a/x-pack/plugins/security_solution/common/shared_imports.ts b/x-pack/plugins/security_solution/common/shared_imports.ts index 8f858e724394b..ec84980f2c456 100644 --- a/x-pack/plugins/security_solution/common/shared_imports.ts +++ b/x-pack/plugins/security_solution/common/shared_imports.ts @@ -6,12 +6,6 @@ */ export { - ListSchema, - ExceptionListSchema, - ExceptionListItemSchema, - CreateExceptionListSchema, - CreateExceptionListItemSchema, - UpdateExceptionListItemSchema, ENDPOINT_LIST_ID, ENDPOINT_TRUSTED_APPS_LIST_ID, EXCEPTION_LIST_URL, diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.test.tsx b/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.test.tsx index 45d4137f8c5b0..82b6256ccbc7a 100644 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.test.tsx @@ -11,7 +11,7 @@ import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import { waitFor } from '@testing-library/react'; import { getField } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; -import { ListSchema } from '../../../shared_imports'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getFoundListSchemaMock } from '../../../../../lists/common/schemas/response/found_list_schema.mock'; import { getListResponseMock } from '../../../../../lists/common/schemas/response/list_schema.mock'; import { DATE_NOW, VERSION, IMMUTABLE } from '../../../../../lists/common/constants.mock'; diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.tsx b/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.tsx index 37e5961c8cd7e..8d7929d765b4f 100644 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.tsx +++ b/x-pack/plugins/security_solution/public/common/components/autocomplete/field_value_lists.tsx @@ -8,8 +8,9 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { EuiFormRow, EuiComboBoxOptionOption, EuiComboBox } from '@elastic/eui'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { IFieldType } from '../../../../../../../src/plugins/data/common'; -import { useFindLists, ListSchema } from '../../../shared_imports'; +import { useFindLists } from '../../../shared_imports'; import { useKibana } from '../../../common/lib/kibana'; import { filterFieldToList, getGenericComboBoxProps } from './helpers'; import * as i18n from './translations'; diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.test.ts b/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.test.ts index c001541db5a34..ae695bf7be978 100644 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.test.ts @@ -17,7 +17,7 @@ import { isNotOperator, existsOperator, doesNotExistOperator, -} from './operators'; +} from '@kbn/securitysolution-list-utils'; import { getOperators, checkEmptyValue, @@ -27,7 +27,7 @@ import { filterFieldToList, } from './helpers'; import { getListResponseMock } from '../../../../../lists/common/schemas/response/list_schema.mock'; -import { ListSchema } from '../../../../../lists/common'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; describe('helpers', () => { // @ts-ignore diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.ts b/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.ts index 13f4e5e6fd6f9..81f5a66238567 100644 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.ts +++ b/x-pack/plugins/security_solution/public/common/components/autocomplete/helpers.ts @@ -8,17 +8,16 @@ import dateMath from '@elastic/datemath'; import { EuiComboBoxOptionOption } from '@elastic/eui'; -import type { Type } from '@kbn/securitysolution-io-ts-list-types'; -import type { ListSchema } from '../../../shared_imports'; -import { IFieldType } from '../../../../../../../src/plugins/data/common'; - +import type { Type, ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { EXCEPTION_OPERATORS, isOperator, isNotOperator, existsOperator, doesNotExistOperator, -} from './operators'; +} from '@kbn/securitysolution-list-utils'; +import { IFieldType } from '../../../../../../../src/plugins/data/common'; + import { GetGenericComboBoxPropsReturn, OperatorOption } from './types'; import * as i18n from './translations'; diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/operator.test.tsx b/x-pack/plugins/security_solution/public/common/components/autocomplete/operator.test.tsx index db16cbde2acb4..5e00d2beb571c 100644 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/operator.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/autocomplete/operator.test.tsx @@ -11,7 +11,7 @@ import { EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import { getField } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; import { OperatorComponent } from './operator'; -import { isOperator, isNotOperator } from './operators'; +import { isOperator, isNotOperator } from '@kbn/securitysolution-list-utils'; describe('OperatorComponent', () => { test('it renders disabled if "isDisabled" is true', () => { diff --git a/x-pack/plugins/security_solution/public/common/components/autocomplete/operators.ts b/x-pack/plugins/security_solution/public/common/components/autocomplete/operators.ts deleted file mode 100644 index 53e2ddf84b3d3..0000000000000 --- a/x-pack/plugins/security_solution/public/common/components/autocomplete/operators.ts +++ /dev/null @@ -1,110 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { i18n } from '@kbn/i18n'; -import { - ListOperatorEnum as OperatorEnum, - ListOperatorTypeEnum as OperatorTypeEnum, -} from '@kbn/securitysolution-io-ts-list-types'; -import { OperatorOption } from './types'; - -export const isOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.isOperatorLabel', { - defaultMessage: 'is', - }), - value: 'is', - type: OperatorTypeEnum.MATCH, - operator: OperatorEnum.INCLUDED, -}; - -export const isNotOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.isNotOperatorLabel', { - defaultMessage: 'is not', - }), - value: 'is_not', - type: OperatorTypeEnum.MATCH, - operator: OperatorEnum.EXCLUDED, -}; - -export const isOneOfOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.isOneOfOperatorLabel', { - defaultMessage: 'is one of', - }), - value: 'is_one_of', - type: OperatorTypeEnum.MATCH_ANY, - operator: OperatorEnum.INCLUDED, -}; - -export const isNotOneOfOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.isNotOneOfOperatorLabel', { - defaultMessage: 'is not one of', - }), - value: 'is_not_one_of', - type: OperatorTypeEnum.MATCH_ANY, - operator: OperatorEnum.EXCLUDED, -}; - -export const existsOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.existsOperatorLabel', { - defaultMessage: 'exists', - }), - value: 'exists', - type: OperatorTypeEnum.EXISTS, - operator: OperatorEnum.INCLUDED, -}; - -export const doesNotExistOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.doesNotExistOperatorLabel', { - defaultMessage: 'does not exist', - }), - value: 'does_not_exist', - type: OperatorTypeEnum.EXISTS, - operator: OperatorEnum.EXCLUDED, -}; - -export const isInListOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.isInListOperatorLabel', { - defaultMessage: 'is in list', - }), - value: 'is_in_list', - type: OperatorTypeEnum.LIST, - operator: OperatorEnum.INCLUDED, -}; - -export const isNotInListOperator: OperatorOption = { - message: i18n.translate('xpack.securitySolution.exceptions.isNotInListOperatorLabel', { - defaultMessage: 'is not in list', - }), - value: 'is_not_in_list', - type: OperatorTypeEnum.LIST, - operator: OperatorEnum.EXCLUDED, -}; - -export const EXCEPTION_OPERATORS: OperatorOption[] = [ - isOperator, - isNotOperator, - isOneOfOperator, - isNotOneOfOperator, - existsOperator, - doesNotExistOperator, - isInListOperator, - isNotInListOperator, -]; - -export const EXCEPTION_OPERATORS_SANS_LISTS: OperatorOption[] = [ - isOperator, - isNotOperator, - isOneOfOperator, - isNotOneOfOperator, - existsOperator, - doesNotExistOperator, -]; - -export const EXCEPTION_OPERATORS_ONLY_LISTS: OperatorOption[] = [ - isInListOperator, - isNotInListOperator, -]; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.test.tsx index 5fb527a821bac..fc126fca0270e 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.test.tsx @@ -21,9 +21,8 @@ import { useFetchOrCreateRuleExceptionList } from '../use_fetch_or_create_rule_e import { useSignalIndex } from '../../../../detections/containers/detection_engine/alerts/use_signal_index'; import * as helpers from '../helpers'; import { getExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; -import { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntriesArray, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ExceptionListItemSchema } from '../../../../../../lists/common'; import { getRulesEqlSchemaMock, getRulesSchemaMock, diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.tsx index 3216a020c3b04..288206034a9a0 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/add_exception_modal/index.tsx @@ -29,18 +29,17 @@ import type { ExceptionListType, OsTypeArray, OsType, + ExceptionListItemSchema, + CreateExceptionListItemSchema, } from '@kbn/securitysolution-io-ts-list-types'; +import { ExceptionsBuilderExceptionItem } from '@kbn/securitysolution-list-utils'; import { hasEqlSequenceQuery, isEqlRule, isThresholdRule, } from '../../../../../common/detection_engine/utils'; import { Status } from '../../../../../common/detection_engine/schemas/common/schemas'; -import { - ExceptionListItemSchema, - CreateExceptionListItemSchema, - ExceptionBuilder, -} from '../../../../../public/shared_imports'; +import { ExceptionBuilder } from '../../../../../public/shared_imports'; import * as i18nCommon from '../../../translations'; import * as i18n from './translations'; @@ -64,7 +63,7 @@ import { filterIndexPatterns, } from '../helpers'; import { ErrorInfo, ErrorCallout } from '../error_callout'; -import { AlertData, ExceptionsBuilderExceptionItem } from '../types'; +import { AlertData } from '../types'; import { useFetchIndex } from '../../../containers/source'; import { useGetInstalledJob } from '../../ml/hooks/use_get_jobs'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.test.tsx index ab6d4b401bb41..73f0a19ea1391 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.test.tsx @@ -20,7 +20,7 @@ import { import { useAddOrUpdateException } from '../use_add_exception'; import { useSignalIndex } from '../../../../detections/containers/detection_engine/alerts/use_signal_index'; import { getExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; -import { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntriesArray } from '@kbn/securitysolution-io-ts-list-types'; import { getRulesEqlSchemaMock, getRulesSchemaMock, diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.tsx index ed050574c3994..cc0ee7e1c0ed6 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/edit_exception_modal/index.tsx @@ -26,6 +26,8 @@ import type { ExceptionListType, OsTypeArray, OsType, + ExceptionListItemSchema, + CreateExceptionListItemSchema, } from '@kbn/securitysolution-io-ts-list-types'; import { hasEqlSequenceQuery, @@ -35,11 +37,7 @@ import { import { useFetchIndex } from '../../../containers/source'; import { useSignalIndex } from '../../../../detections/containers/detection_engine/alerts/use_signal_index'; import { useRuleAsync } from '../../../../detections/containers/detection_engine/rules/use_rule_async'; -import { - ExceptionListItemSchema, - CreateExceptionListItemSchema, - ExceptionBuilder, -} from '../../../../../public/shared_imports'; +import { ExceptionBuilder } from '../../../../../public/shared_imports'; import * as i18n from './translations'; import * as sharedI18n from '../translations'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.tsx index ba8b5b522f0a7..67522cfdc8d58 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/error_callout.tsx @@ -16,7 +16,7 @@ import { EuiSpacer, } from '@elastic/eui'; -import { List } from '@kbn/securitysolution-io-ts-list-types'; +import type { List } from '@kbn/securitysolution-io-ts-list-types'; import { HttpSetup } from '../../../../../../../src/core/public'; import { Rule } from '../../../detections/containers/detection_engine/rules/types'; import * as i18n from './translations'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx index 98c2b4db5676e..383b177d40c64 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx @@ -32,6 +32,7 @@ import { ListOperatorTypeEnum as OperatorTypeEnum, EntriesArray, OsTypeArray, + ExceptionListItemSchema, } from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; @@ -39,7 +40,6 @@ import { getEntryMatchMock } from '../../../../../lists/common/schemas/types/ent import { getCommentsArrayMock } from '../../../../../lists/common/schemas/types/comment.mock'; import { fields } from '../../../../../../../src/plugins/data/common/index_patterns/fields/fields.mocks'; import { ENTRIES, OLD_DATE_RELATIVE_TO_DATE_NOW } from '../../../../../lists/common/constants.mock'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas'; import { IFieldType, IIndexPattern } from 'src/plugins/data/common'; jest.mock('uuid', () => ({ diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx index 437e93bb26fef..20413a6493661 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx @@ -22,18 +22,19 @@ import { OsTypeArray, ExceptionListType, ListOperatorTypeEnum as OperatorTypeEnum, -} from '@kbn/securitysolution-io-ts-list-types'; - -import * as i18n from './translations'; -import { AlertData, ExceptionsBuilderExceptionItem, Flattened } from './types'; -import { ExceptionListItemSchema, CreateExceptionListItemSchema, UpdateExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; + +import { getOperatorType, getNewExceptionItem, addIdToEntries, -} from '../../../shared_imports'; + ExceptionsBuilderExceptionItem, +} from '@kbn/securitysolution-list-utils'; +import * as i18n from './translations'; +import { AlertData, Flattened } from './types'; import { IIndexPattern } from '../../../../../../../src/plugins/data/common'; import { Ecs } from '../../../../common/ecs'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/types.ts b/x-pack/plugins/security_solution/public/common/components/exceptions/types.ts index bbf83a58e3679..798a212978208 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/types.ts +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/types.ts @@ -6,25 +6,9 @@ */ import { ReactNode } from 'react'; -import type { - EntryNested, - Entry, - EntryMatch, - EntryMatchAny, - EntryMatchWildcard, - EntryExists, - NamespaceType, - ListOperatorTypeEnum as OperatorTypeEnum, - ListOperatorEnum as OperatorEnum, -} from '@kbn/securitysolution-io-ts-list-types'; +import type { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; import type { Ecs } from '../../../../common/ecs'; import type { CodeSignature } from '../../../../common/ecs/file'; -import type { IFieldType } from '../../../../../../../src/plugins/data/common'; -import type { OperatorOption } from '../autocomplete/types'; -import type { - ExceptionListItemSchema, - CreateExceptionListItemSchema, -} from '../../../shared_imports'; export interface FormattedEntry { fieldName: string; @@ -62,78 +46,6 @@ export interface ExceptionsPagination { pageSizeOptions: number[]; } -export interface FormattedBuilderEntry { - id: string; - field: IFieldType | undefined; - operator: OperatorOption; - value: string | string[] | undefined; - nested: 'parent' | 'child' | undefined; - entryIndex: number; - parent: { parent: BuilderEntryNested; parentIndex: number } | undefined; - correspondingKeywordField: IFieldType | undefined; -} - -export interface EmptyEntry { - id: string; - field: string | undefined; - operator: OperatorEnum; - type: OperatorTypeEnum.MATCH | OperatorTypeEnum.MATCH_ANY; - value: string | string[] | undefined; -} - -export interface EmptyListEntry { - id: string; - field: string | undefined; - operator: OperatorEnum; - type: OperatorTypeEnum.LIST; - list: { id: string | undefined; type: string | undefined }; -} - -export interface EmptyNestedEntry { - id: string; - field: string | undefined; - type: OperatorTypeEnum.NESTED; - entries: Array< - | (EntryMatch & { id?: string }) - | (EntryMatchWildcard & { id?: string }) - | (EntryMatchAny & { id?: string }) - | (EntryExists & { id?: string }) - >; -} - -export type BuilderEntry = - | (Entry & { id?: string }) - | EmptyListEntry - | EmptyEntry - | BuilderEntryNested - | EmptyNestedEntry; - -export type BuilderEntryNested = Omit & { - id?: string; - entries: Array< - | (EntryMatch & { id?: string }) - | (EntryMatchWildcard & { id?: string }) - | (EntryMatchAny & { id?: string }) - | (EntryExists & { id?: string }) - >; -}; - -export type ExceptionListItemBuilderSchema = Omit & { - entries: BuilderEntry[]; -}; - -export type CreateExceptionListItemBuilderSchema = Omit< - CreateExceptionListItemSchema, - 'meta' | 'entries' -> & { - meta: { temporaryUuid: string }; - entries: BuilderEntry[]; -}; - -export type ExceptionsBuilderExceptionItem = - | ExceptionListItemBuilderSchema - | CreateExceptionListItemBuilderSchema; - export interface FlattenedCodeSignature { subject_name: string; trusted: string; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx index c8a624b009c43..2fd70b5451c99 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.test.tsx @@ -20,7 +20,8 @@ import type { ExceptionListItemSchema, CreateExceptionListItemSchema, UpdateExceptionListItemSchema, -} from '../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; + import { useAddOrUpdateException, UseAddOrUpdateExceptionProps, diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx index 6aa68373d5eb5..9a4731749d2ad 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/use_add_exception.tsx @@ -7,13 +7,14 @@ import { useEffect, useRef, useState, useCallback } from 'react'; import { UpdateDocumentByQueryResponse } from 'elasticsearch'; -import { HttpStart } from '../../../../../../../src/core/public'; - -import { +import type { ExceptionListItemSchema, CreateExceptionListItemSchema, - useApi, -} from '../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; +import { HttpStart } from '../../../../../../../src/core/public'; + +import { useApi } from '../../../shared_imports'; + import { updateAlertStatus } from '../../../detections/containers/detection_engine/alerts/api'; import { getUpdateAlertsQuery } from '../../../detections/components/alerts_table/actions'; import { diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.test.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.test.tsx index d38d920eee188..9d018eba0a484 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.test.tsx @@ -12,14 +12,17 @@ import * as rulesApi from '../../../detections/containers/detection_engine/rules import * as listsApi from '../../../../../lists/public/exceptions/api'; import { getExceptionListSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_schema.mock'; import { savedRuleMock } from '../../../detections/containers/detection_engine/rules/mock'; -import type { ExceptionListType, ListArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { + ExceptionListType, + ListArray, + ExceptionListSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { getListArrayMock } from '../../../../common/detection_engine/schemas/types/lists.mock'; import { useFetchOrCreateRuleExceptionList, UseFetchOrCreateRuleExceptionListProps, ReturnUseFetchOrCreateRuleExceptionList, } from './use_fetch_or_create_rule_exception_list'; -import { ExceptionListSchema } from '../../../shared_imports'; const mockKibanaHttpService = coreMock.createStart().http; jest.mock('../../../detections/containers/detection_engine/rules/api'); diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.tsx index 98c207f47a45b..50f943c889838 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/use_fetch_or_create_rule_exception_list.tsx @@ -6,7 +6,12 @@ */ import { useEffect, useState } from 'react'; -import { List, ListArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { + List, + ListArray, + ExceptionListSchema, + CreateExceptionListSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { HttpStart } from '../../../../../../../src/core/public'; import { Rule } from '../../../detections/containers/detection_engine/rules/types'; @@ -19,11 +24,7 @@ import { addExceptionList, addEndpointExceptionList, } from '../../../shared_imports'; -import { - ExceptionListSchema, - CreateExceptionListSchema, - ENDPOINT_LIST_ID, -} from '../../../../common/shared_imports'; +import { ENDPOINT_LIST_ID } from '../../../../common/shared_imports'; export type ReturnUseFetchOrCreateRuleExceptionList = [boolean, ExceptionListSchema | null]; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/exception_details.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/exception_details.tsx index ff242506927f1..d20d28aca6fda 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/exception_details.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/exception_details.tsx @@ -16,10 +16,10 @@ import { import React, { useMemo, Fragment } from 'react'; import styled, { css } from 'styled-components'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import type { DescriptionListItem } from '../../types'; import { getDescriptionListContent } from '../helpers'; import * as i18n from '../../translations'; -import type { ExceptionListItemSchema } from '../../../../../../public/shared_imports'; const MyExceptionDetails = styled(EuiFlexItem)` ${({ theme }) => css` diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/index.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/index.tsx index 7909366e7a32e..b73442b04c9b4 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_item/index.tsx @@ -16,12 +16,12 @@ import { import React, { useEffect, useState, useMemo, useCallback } from 'react'; import styled from 'styled-components'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ExceptionDetails } from './exception_details'; import { ExceptionEntries } from './exception_entries'; import { getFormattedComments } from '../../helpers'; import { getFormattedEntries } from '../helpers'; import type { FormattedEntry, ExceptionListItemIdentifiers } from '../../types'; -import type { ExceptionListItemSchema } from '../../../../../../public/shared_imports'; const MyFlexItem = styled(EuiFlexItem)` &.comments--show { diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_viewer_items.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_viewer_items.tsx index 1e4cd306c4661..64fb032b0425c 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_viewer_items.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exceptions_viewer_items.tsx @@ -9,10 +9,10 @@ import React from 'react'; import { EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import styled from 'styled-components'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import * as i18n from '../translations'; import { ExceptionItem } from './exception_item'; import { AndOrBadge } from '../../and_or_badge'; -import type { ExceptionListItemSchema } from '../../../../../public/shared_imports'; import type { ExceptionListItemIdentifiers } from '../types'; const MyFlexItem = styled(EuiFlexItem)` diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/helpers.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/helpers.tsx index 936423d0c362b..597e8a6fed52f 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/helpers.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/helpers.tsx @@ -7,15 +7,15 @@ import moment from 'moment'; -import { entriesNested } from '@kbn/securitysolution-io-ts-list-types'; +import { entriesNested, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { - ExceptionListItemSchema, getEntryValue, getExceptionOperatorSelect, -} from '../../../../shared_imports'; + BuilderEntry, +} from '@kbn/securitysolution-list-utils'; import { formatOperatingSystems } from '../helpers'; -import type { FormattedEntry, BuilderEntry, DescriptionListItem } from '../types'; +import type { FormattedEntry, DescriptionListItem } from '../types'; import * as i18n from '../translations'; /** diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/index.tsx b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/index.tsx index 8055e771a1647..b1d3f66924342 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/index.tsx @@ -9,7 +9,10 @@ import React, { useCallback, useEffect, useReducer } from 'react'; import { EuiSpacer } from '@elastic/eui'; import uuid from 'uuid'; -import type { ExceptionListTypeEnum } from '@kbn/securitysolution-io-ts-list-types'; +import type { + ExceptionListTypeEnum, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import * as i18n from '../translations'; import { useStateToaster } from '../../toasters'; import { useKibana } from '../../../../common/lib/kibana'; @@ -21,7 +24,6 @@ import { allExceptionItemsReducer, State, ViewerModalName } from './reducer'; import { useExceptionListItems, ExceptionListIdentifiers, - ExceptionListItemSchema, UseExceptionListItemsSuccess, useApi, } from '../../../../../public/shared_imports'; diff --git a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/reducer.ts b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/reducer.ts index 4908a88b72526..4f75aa379cef2 100644 --- a/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/reducer.ts +++ b/x-pack/plugins/security_solution/public/common/components/exceptions/viewer/reducer.ts @@ -5,18 +5,17 @@ * 2.0. */ -import type { ExceptionListType } from '@kbn/securitysolution-io-ts-list-types'; +import type { + ExceptionListType, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import type { FilterOptions, ExceptionsPagination, ExceptionListItemIdentifiers, Filter, } from '../types'; -import type { - ExceptionListItemSchema, - ExceptionListIdentifiers, - Pagination, -} from '../../../../../public/shared_imports'; +import type { ExceptionListIdentifiers, Pagination } from '../../../../../public/shared_imports'; export type ViewerModalName = 'addModal' | 'editModal' | null; diff --git a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/form.tsx b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/form.tsx index ea903882c326d..641a39a4c21a3 100644 --- a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/form.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/form.tsx @@ -18,8 +18,8 @@ import { EuiSelectOption, } from '@elastic/eui'; -import type { Type } from '@kbn/securitysolution-io-ts-list-types'; -import { useImportList, ListSchema } from '../../../shared_imports'; +import type { Type, ListSchema } from '@kbn/securitysolution-io-ts-list-types'; +import { useImportList } from '../../../shared_imports'; import * as i18n from './translations'; import { useKibana } from '../../../common/lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.test.tsx b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.test.tsx index 9f05fdbe6bee8..bc20419db3547 100644 --- a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.test.tsx @@ -10,7 +10,9 @@ import { mount } from 'enzyme'; import { waitFor } from '@testing-library/react'; import { getListResponseMock } from '../../../../../lists/common/schemas/response/list_schema.mock'; -import { exportList, useDeleteList, useFindLists, ListSchema } from '../../../shared_imports'; +import { exportList, useDeleteList, useFindLists } from '../../../shared_imports'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; + import { TestProviders } from '../../../common/mock'; import { ValueListsModal } from './modal'; diff --git a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.tsx b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.tsx index aefa447269f46..348c9c4b24ea3 100644 --- a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/modal.tsx @@ -20,13 +20,9 @@ import { EuiText, } from '@elastic/eui'; -import { - ListSchema, - exportList, - useFindLists, - useDeleteList, - useCursor, -} from '../../../shared_imports'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; +import { exportList, useFindLists, useDeleteList, useCursor } from '../../../shared_imports'; + import { useKibana } from '../../../common/lib/kibana'; import { useAppToasts } from '../../../common/hooks/use_app_toasts'; import * as i18n from './translations'; diff --git a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/table_helpers.tsx b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/table_helpers.tsx index cc9ba225cac0e..e7d726ed89e6f 100644 --- a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/table_helpers.tsx +++ b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/table_helpers.tsx @@ -11,7 +11,7 @@ import React from 'react'; import styled from 'styled-components'; import { EuiButtonIcon, EuiLoadingSpinner, EuiToolTip } from '@elastic/eui'; -import { ListSchema } from '../../../../../lists/common/schemas/response'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { FormattedDate } from '../../../common/components/formatted_date'; import * as i18n from './translations'; import { TableItemCallback, TableProps } from './types'; diff --git a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/types.ts b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/types.ts index 681e9630a0d32..92fb105a3617e 100644 --- a/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/types.ts +++ b/x-pack/plugins/security_solution/public/detections/components/value_lists_management_modal/types.ts @@ -7,7 +7,7 @@ import { EuiBasicTableProps } from '@elastic/eui'; -import { ListSchema } from '../../../../../lists/common/schemas/response'; +import type { ListSchema } from '@kbn/securitysolution-io-ts-list-types'; export interface TableItem extends ListSchema { isDeleting: boolean; diff --git a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_dissasociate_exception_list.tsx b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_dissasociate_exception_list.tsx index 8807f02774e0e..107e66a69768e 100644 --- a/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_dissasociate_exception_list.tsx +++ b/x-pack/plugins/security_solution/public/detections/containers/detection_engine/rules/use_dissasociate_exception_list.tsx @@ -7,7 +7,7 @@ import { useEffect, useState, useRef } from 'react'; -import { List } from '@kbn/securitysolution-io-ts-list-types'; +import type { List } from '@kbn/securitysolution-io-ts-list-types'; import { HttpStart } from '../../../../../../../../src/core/public'; import { patchRule } from './api'; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/columns.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/columns.tsx index 64cb936f160f1..f64586db9b06c 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/columns.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/columns.tsx @@ -11,7 +11,7 @@ import React from 'react'; import { EuiButtonIcon, EuiBasicTableColumn, EuiToolTip } from '@elastic/eui'; import { History } from 'history'; -import { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; +import type { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; import { Spacer } from '../../../../../../common/components/page'; import { FormatUrl } from '../../../../../../common/components/link_to'; import { LinkAnchor } from '../../../../../../common/components/links'; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx index 50cf1b1830fec..e4f627c1ae474 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/exceptions_table.tsx @@ -15,7 +15,7 @@ import { } from '@elastic/eui'; import { History } from 'history'; -import { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; +import type { NamespaceType } from '@kbn/securitysolution-io-ts-list-types'; import { useAppToasts } from '../../../../../../common/hooks/use_app_toasts'; import { AutoDownload } from '../../../../../../common/components/auto_download/auto_download'; import { useKibana } from '../../../../../../common/lib/kibana'; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/use_all_exception_lists.tsx b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/use_all_exception_lists.tsx index d104026c79bfc..44518944a9227 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/use_all_exception_lists.tsx +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/exceptions/use_all_exception_lists.tsx @@ -7,8 +7,8 @@ import { useCallback, useEffect, useState } from 'react'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { Rule } from '../../../../../containers/detection_engine/rules'; -import { ExceptionListSchema } from '../../../../../../../../lists/common'; import { fetchRules } from '../../../../../containers/detection_engine/rules/api'; export interface ExceptionListInfo extends ExceptionListSchema { rules: Rule[]; diff --git a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts index cf82e7cb7944e..dc580f591da56 100644 --- a/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts +++ b/x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { List } from '@kbn/securitysolution-io-ts-list-types'; +import type { List } from '@kbn/securitysolution-io-ts-list-types'; import { RiskScoreMapping, ThreatIndex, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/service/index.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/service/index.ts index 6a95ac5c15e83..30b4c81ba0c3b 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/service/index.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/service/index.ts @@ -6,16 +6,17 @@ */ import { HttpStart } from 'kibana/public'; -import { +import type { + FoundExceptionListItemSchema, ExceptionListItemSchema, CreateExceptionListItemSchema, - ENDPOINT_EVENT_FILTERS_LIST_ID, UpdateExceptionListItemSchema, -} from '../../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; +import { ENDPOINT_EVENT_FILTERS_LIST_ID } from '../../../../shared_imports'; + import { Immutable } from '../../../../../common/endpoint/types'; import { EVENT_FILTER_LIST, EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL } from '../constants'; -import { FoundExceptionListItemSchema } from '../../../../../../lists/common/schemas'; import { EventFiltersService } from '../types'; export class EventFiltersHttpService implements EventFiltersService { diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/action.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/action.ts index 4ae90e7abba90..016170686c7dd 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/action.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/action.ts @@ -6,11 +6,11 @@ */ import { Action } from 'redux'; -import { +import type { ExceptionListItemSchema, CreateExceptionListItemSchema, UpdateExceptionListItemSchema, -} from '../../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; import { AsyncResourceState } from '../../../state/async_resource_state'; import { EventFiltersListPageState } from '../types'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts index d8191850e438e..6712769e8b4af 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/middleware.ts @@ -5,6 +5,11 @@ * 2.0. */ +import type { + CreateExceptionListItemSchema, + ExceptionListItemSchema, + UpdateExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { AppAction } from '../../../../common/store/actions'; import { ImmutableMiddleware, @@ -14,13 +19,8 @@ import { import { EventFiltersHttpService } from '../service'; -import { - CreateExceptionListItemSchema, - ExceptionListItemSchema, - transformNewItemOutput, - transformOutput, - UpdateExceptionListItemSchema, -} from '../../../../shared_imports'; +import { transformNewItemOutput, transformOutput } from '../../../../shared_imports'; + import { getCurrentListPageDataState, getCurrentLocation, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/selector.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/selector.ts index 1bbc695f53236..d4e81fd812668 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/selector.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/selector.ts @@ -7,9 +7,12 @@ import { createSelector } from 'reselect'; import { Pagination } from '@elastic/eui'; +import type { + ExceptionListItemSchema, + FoundExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { EventFiltersListPageState, EventFiltersServiceGetListOptions } from '../types'; -import { ExceptionListItemSchema } from '../../../../shared_imports'; import { ServerApiError } from '../../../../common/types'; import { isLoadingResourceState, @@ -18,7 +21,6 @@ import { isUninitialisedResourceState, getLastLoadedResourceState, } from '../../../state/async_resource_state'; -import { FoundExceptionListItemSchema } from '../../../../../../lists/common/schemas'; import { MANAGEMENT_DEFAULT_PAGE_SIZE, MANAGEMENT_PAGE_SIZE_OPTIONS, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/utils.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/utils.ts index 35ba7ce5853a6..6adc490b40e78 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/store/utils.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/store/utils.ts @@ -6,7 +6,7 @@ */ import uuid from 'uuid'; -import { CreateExceptionListItemSchema } from '../../../../shared_imports'; +import type { CreateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { Ecs } from '../../../../../common/ecs'; import { ENDPOINT_EVENT_FILTERS_LIST_ID } from '../constants'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/test_utils/index.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/test_utils/index.ts index 701fb8d77b2e6..69a8ee383be8e 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/test_utils/index.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/test_utils/index.ts @@ -6,24 +6,23 @@ */ import { combineReducers, createStore } from 'redux'; +import type { + FoundExceptionListItemSchema, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { Ecs } from '../../../../../common/ecs'; import { MANAGEMENT_STORE_GLOBAL_NAMESPACE, MANAGEMENT_STORE_EVENT_FILTERS_NAMESPACE, } from '../../../common/constants'; -import { - EXCEPTION_LIST_ITEM_URL, - EXCEPTION_LIST_URL, - ExceptionListItemSchema, -} from '../../../../shared_imports'; +import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL } from '../../../../shared_imports'; import { eventFiltersPageReducer } from '../store/reducer'; import { httpHandlerMockFactory, ResponseProvidersInterface, } from '../../../../common/mock/endpoint/http_handler_mock_factory'; -import { FoundExceptionListItemSchema } from '../../../../../../lists/common/schemas'; import { getFoundExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/found_exception_list_item_schema.mock'; import { getExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/types.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/types.ts index cc70a2037a5af..be6689b7e5b57 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/types.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/types.ts @@ -5,14 +5,14 @@ * 2.0. */ -import { +import type { + FoundExceptionListItemSchema, CreateExceptionListItemSchema, ExceptionListItemSchema, UpdateExceptionListItemSchema, -} from '../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; import { AsyncResourceState } from '../../state/async_resource_state'; import { Immutable } from '../../../../common/endpoint/types'; -import { FoundExceptionListItemSchema } from '../../../../../lists/common/schemas'; export interface EventFiltersPageLocation { page_index: number; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx index 722eb57bf872c..5ee4c4eb0aacb 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/flyout/index.test.tsx @@ -14,10 +14,10 @@ import { } from '../../../../../../common/mock/endpoint'; import { MiddlewareActionSpyHelper } from '../../../../../../common/store/test_utils'; -import { +import type { CreateExceptionListItemSchema, ExceptionListItemSchema, -} from '../../../../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; import { EventFiltersHttpService } from '../../../service'; import { createdEventFilterEntryMock } from '../../../test_utils'; import { getFormEntryState, isUninitialisedForm } from '../../../store/selector'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx index d74baab0d2bbc..83fd6ff1a366d 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/form/index.tsx @@ -19,6 +19,7 @@ import { } from '@elastic/eui'; import { isEmpty } from 'lodash/fp'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { OperatingSystem } from '../../../../../../../common/endpoint/types'; import { AddExceptionComments } from '../../../../../../common/components/exceptions/add_exception_comments'; import { filterIndexPatterns } from '../../../../../../common/components/exceptions/helpers'; @@ -26,7 +27,7 @@ import { Loader } from '../../../../../../common/components/loader'; import { useKibana } from '../../../../../../common/lib/kibana'; import { useFetchIndex } from '../../../../../../common/containers/source'; import { AppAction } from '../../../../../../common/store/actions'; -import { ExceptionListItemSchema, ExceptionBuilder } from '../../../../../../shared_imports'; +import { ExceptionBuilder } from '../../../../../../shared_imports'; import { useEventFiltersSelector } from '../../hooks'; import { getFormEntryStateMutable, getHasNameError, getNewComment } from '../../../store/selector'; diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/index.test.tsx index 0c976b3571515..178b774e91635 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/modal/index.test.tsx @@ -13,10 +13,10 @@ import { ThemeProvider } from 'styled-components'; import { createGlobalNoMiddlewareStore, ecsEventMock } from '../../../test_utils'; import { getMockTheme } from '../../../../../../common/lib/kibana/kibana_react.mock'; import { MODAL_TITLE, MODAL_SUBTITLE, ACTIONS_CONFIRM, ACTIONS_CANCEL } from './translations'; -import { +import type { CreateExceptionListItemSchema, ExceptionListItemSchema, -} from '../../../../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; jest.mock('../form'); jest.mock('../../hooks', () => { diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx index ea1e041f11c50..32fc018210418 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/event_filters_list_page.tsx @@ -14,6 +14,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, EuiSpacer, EuiHorizontalRule, EuiText } from '@elastic/eui'; import styled from 'styled-components'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { AppAction } from '../../../../common/store/actions'; import { getEventFiltersListPath } from '../../../common/routing'; import { AdministrationListPage as _AdministrationListPage } from '../../../components/administration_list_page'; @@ -33,7 +34,6 @@ import { showDeleteModal, } from '../store/selector'; import { PaginatedContent, PaginatedContentProps } from '../../../components/paginated_content'; -import { ExceptionListItemSchema } from '../../../../../../lists/common'; import { Immutable } from '../../../../../common/endpoint/types'; import { ExceptionItem, diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/translations.ts b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/translations.ts index a33a031d5972e..0d8d4a8706e9c 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/translations.ts +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/translations.ts @@ -7,10 +7,10 @@ import { i18n } from '@kbn/i18n'; -import { +import type { CreateExceptionListItemSchema, UpdateExceptionListItemSchema, -} from '../../../../shared_imports'; +} from '@kbn/securitysolution-io-ts-list-types'; import { ServerApiError } from '../../../../common/types'; export const getCreationSuccessMessage = ( diff --git a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/use_event_filters_notification.test.tsx b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/use_event_filters_notification.test.tsx index 5dcb3fa6a12af..064e3312a52bb 100644 --- a/x-pack/plugins/security_solution/public/management/pages/event_filters/view/use_event_filters_notification.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/event_filters/view/use_event_filters_notification.test.tsx @@ -12,7 +12,10 @@ import { renderHook, act } from '@testing-library/react-hooks'; import { NotificationsStart } from 'kibana/public'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public/context'; -import { CreateExceptionListItemSchema, ExceptionListItemSchema } from '../../../../shared_imports'; +import type { + CreateExceptionListItemSchema, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { createdEventFilterEntryMock, diff --git a/x-pack/plugins/security_solution/public/shared_imports.ts b/x-pack/plugins/security_solution/public/shared_imports.ts index 76ec761d41703..59e49ec45686e 100644 --- a/x-pack/plugins/security_solution/public/shared_imports.ts +++ b/x-pack/plugins/security_solution/public/shared_imports.ts @@ -45,11 +45,6 @@ export { useReadListIndex, useReadListPrivileges, fetchExceptionListById, - addIdToEntries, - getOperatorType, - getNewExceptionItem, - getEntryValue, - getExceptionOperatorSelect, addExceptionList, ExceptionListFilter, ExceptionListIdentifiers, diff --git a/x-pack/plugins/security_solution/scripts/endpoint/event_filters/index.ts b/x-pack/plugins/security_solution/scripts/endpoint/event_filters/index.ts index 93af1f406300c..e3579d11331de 100644 --- a/x-pack/plugins/security_solution/scripts/endpoint/event_filters/index.ts +++ b/x-pack/plugins/security_solution/scripts/endpoint/event_filters/index.ts @@ -9,6 +9,7 @@ import { run, RunFn, createFailError } from '@kbn/dev-utils'; import { KbnClient } from '@kbn/test'; import { AxiosError } from 'axios'; import bluebird from 'bluebird'; +import type { CreateExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { EventFilterGenerator } from '../../../common/endpoint/data_generators/event_filter_generator'; import { ENDPOINT_EVENT_FILTERS_LIST_DESCRIPTION, @@ -17,7 +18,6 @@ import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL, } from '../../../../lists/common/constants'; -import { CreateExceptionListSchema } from '../../../../lists/common'; export const cli = () => { run( diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.test.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.test.ts index 5b4aed35bbc7c..9df242469752e 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.test.ts @@ -9,7 +9,7 @@ import { ExceptionListClient } from '../../../../../lists/server'; import { listMock } from '../../../../../lists/server/mocks'; import { getFoundExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/found_exception_list_item_schema.mock'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; -import { EntriesArray, EntryList } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntriesArray, EntryList } from '@kbn/securitysolution-io-ts-list-types'; import { buildArtifact, getEndpointExceptionList, diff --git a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts index e73e3eb5c56f8..26212da1355db 100644 --- a/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts +++ b/x-pack/plugins/security_solution/server/endpoint/lib/artifacts/lists.ts @@ -7,9 +7,12 @@ import { createHash } from 'crypto'; import { deflate } from 'zlib'; -import { Entry, EntryNested } from '@kbn/securitysolution-io-ts-list-types'; +import type { + Entry, + EntryNested, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { validate } from '@kbn/securitysolution-io-ts-utils'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas'; import { ExceptionListClient } from '../../../../../lists/server'; import { ENDPOINT_LIST_ID, ENDPOINT_TRUSTED_APPS_LIST_ID } from '../../../../common/shared_imports'; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/handlers.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/handlers.test.ts index 0b4e1cb2b09b1..5e60fcd4bb115 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/handlers.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/handlers.test.ts @@ -9,7 +9,7 @@ import { KibanaResponseFactory } from 'kibana/server'; import { xpackMocks } from '../../../../../../mocks'; import { loggingSystemMock, httpServerMock } from '../../../../../../../src/core/server/mocks'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas/response'; +import { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { listMock } from '../../../../../lists/server/mocks'; import { ExceptionListClient } from '../../../../../lists/server'; import { createMockConfig } from '../../../lib/detection_engine/routes/__mocks__'; diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.test.ts index 9ee2ece627841..fe46277664408 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.test.ts @@ -6,7 +6,7 @@ */ import { CreateExceptionListItemOptions } from '../../../../../lists/server'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas/response'; +import { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ConditionEntryField, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.ts b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.ts index 897ffe4ee48cd..1a4ff2812cd23 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mapping.ts @@ -14,10 +14,9 @@ import type { EntryNested, NestedEntriesArray, OsType, + ExceptionListItemSchema, } from '@kbn/securitysolution-io-ts-list-types'; -import type { ExceptionListItemSchema } from '../../../../../lists/common'; - import { ENDPOINT_TRUSTED_APPS_LIST_ID } from '../../../../../lists/common/constants'; import type { CreateExceptionListItemOptions, diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.test.ts b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.test.ts index d99a89ce11137..081010ea0098a 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.test.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas/response'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { listMock } from '../../../../../lists/server/mocks'; import { ExceptionListClient } from '../../../../../lists/server'; import { diff --git a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.ts b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.ts index a2d79f7246b14..c30a7a9a38cdc 100644 --- a/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.ts +++ b/x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/service.ts @@ -5,11 +5,9 @@ * 2.0. */ +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ExceptionListClient } from '../../../../../lists/server'; -import { - ENDPOINT_TRUSTED_APPS_LIST_ID, - ExceptionListItemSchema, -} from '../../../../../lists/common'; +import { ENDPOINT_TRUSTED_APPS_LIST_ID } from '../../../../../lists/common'; import { DeleteTrustedAppsRequestParams, diff --git a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts index 6f41fe3578496..f471ace617a6d 100644 --- a/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts +++ b/x-pack/plugins/security_solution/server/endpoint/services/artifacts/manifest_manager/manifest_manager.mock.ts @@ -12,7 +12,7 @@ import { PackagePolicyServiceInterface } from '../../../../../../fleet/server'; import { createPackagePolicyServiceMock } from '../../../../../../fleet/server/mocks'; import { ExceptionListClient } from '../../../../../../lists/server'; import { listMock } from '../../../../../../lists/server/mocks'; -import { ExceptionListItemSchema } from '../../../../../../lists/common/schemas/response'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { createPackagePolicyWithManifestMock, createPackagePolicyWithInitialManifestMock, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts index 660518fa4d8ee..380eb085e0d5a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/types.ts @@ -14,7 +14,7 @@ import { SavedObjectsFindResponse, SavedObjectsClientContract, } from 'kibana/server'; -import { +import type { MachineLearningJobIdOrUndefined, From, FromOrUndefined, @@ -42,9 +42,9 @@ import { MaxSignalsOrUndefined, MaxSignals, } from '@kbn/securitysolution-io-ts-alerting-types'; -import { VersionOrUndefined, Version } from '@kbn/securitysolution-io-ts-types'; +import type { VersionOrUndefined, Version } from '@kbn/securitysolution-io-ts-types'; -import { ListArrayOrUndefined, ListArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListArrayOrUndefined, ListArray } from '@kbn/securitysolution-io-ts-list-types'; import { UpdateRulesSchema } from '../../../../common/detection_engine/schemas/request'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts index a31f9bec2cd58..6e6bb38e46df6 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rules/utils.ts @@ -6,7 +6,7 @@ */ import { pickBy, isEmpty } from 'lodash/fp'; -import { +import type { FromOrUndefined, MachineLearningJobIdOrUndefined, RiskScoreMappingOrUndefined, @@ -25,8 +25,8 @@ import { SeverityMappingOrUndefined, MaxSignalsOrUndefined, } from '@kbn/securitysolution-io-ts-alerting-types'; -import { ListArrayOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; -import { VersionOrUndefined } from '@kbn/securitysolution-io-ts-types'; +import type { ListArrayOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; +import type { VersionOrUndefined } from '@kbn/securitysolution-io-ts-types'; import { DescriptionOrUndefined, AnomalyThresholdOrUndefined, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts index aa51d133260b8..a5ebfef9d2c68 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/eql.ts @@ -9,6 +9,7 @@ import { ApiResponse } from '@elastic/elasticsearch'; import { performance } from 'perf_hooks'; import { Logger } from 'src/core/server'; import { SavedObject } from 'src/core/types'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { AlertInstanceContext, AlertInstanceState, @@ -16,7 +17,6 @@ import { } from '../../../../../../alerting/server'; import { buildEqlSearchRequest } from '../../../../../common/detection_engine/get_query_filter'; import { hasLargeValueItem } from '../../../../../common/detection_engine/utils'; -import { ExceptionListItemSchema } from '../../../../../common/shared_imports'; import { isOutdated } from '../../migrations/helpers'; import { getIndexVersion } from '../../routes/index/get_index_version'; import { MIN_EQL_RULE_INDEX_VERSION } from '../../routes/index/get_signals_template'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/ml.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/ml.ts index 928767e922d67..28703046289f5 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/ml.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/ml.ts @@ -7,6 +7,7 @@ import { KibanaRequest, Logger } from 'src/core/server'; import { SavedObject } from 'src/core/types'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { AlertInstanceContext, AlertInstanceState, @@ -14,7 +15,6 @@ import { } from '../../../../../../alerting/server'; import { ListClient } from '../../../../../../lists/server'; import { isJobStarted } from '../../../../../common/machine_learning/helpers'; -import { ExceptionListItemSchema } from '../../../../../common/shared_imports'; import { SetupPlugins } from '../../../../plugin'; import { MachineLearningRuleParams } from '../../schemas/rule_schemas'; import { RefreshTypes } from '../../types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/query.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/query.ts index 54f935ec74026..05e2e3056e99e 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/query.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/query.ts @@ -7,13 +7,13 @@ import { SavedObject } from 'src/core/types'; import { Logger } from 'src/core/server'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { AlertInstanceContext, AlertInstanceState, AlertServices, } from '../../../../../../alerting/server'; import { ListClient } from '../../../../../../lists/server'; -import { ExceptionListItemSchema } from '../../../../../common/shared_imports'; import { RefreshTypes } from '../../types'; import { getFilter } from '../get_filter'; import { getInputIndex } from '../get_input_output_index'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threat_match.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threat_match.ts index 62619cf948d40..10b4ce939ca3a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threat_match.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threat_match.ts @@ -7,13 +7,13 @@ import { SavedObject } from 'src/core/types'; import { Logger } from 'src/core/server'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { AlertInstanceContext, AlertInstanceState, AlertServices, } from '../../../../../../alerting/server'; import { ListClient } from '../../../../../../lists/server'; -import { ExceptionListItemSchema } from '../../../../../common/shared_imports'; import { RefreshTypes } from '../../types'; import { getInputIndex } from '../get_input_output_index'; import { RuleRangeTuple, AlertAttributes } from '../types'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts index 204481f5d910c..fa0986044e250 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/executors/threshold.ts @@ -7,13 +7,13 @@ import { Logger } from 'src/core/server'; import { SavedObject } from 'src/core/types'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { AlertInstanceContext, AlertInstanceState, AlertServices, } from '../../../../../../alerting/server'; import { hasLargeValueItem } from '../../../../../common/detection_engine/utils'; -import { ExceptionListItemSchema } from '../../../../../common/shared_imports'; import { ThresholdRuleParams } from '../../schemas/rule_schemas'; import { RefreshTypes } from '../../types'; import { getFilter } from '../get_filter'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/create_field_and_set_tuples.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/create_field_and_set_tuples.test.ts index 578c1aba64558..b46237cc93bc8 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/create_field_and_set_tuples.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/create_field_and_set_tuples.test.ts @@ -11,7 +11,7 @@ import { mockLogger, sampleDocWithSortId } from '../__mocks__/es_results'; import { getExceptionListItemSchemaMock } from '../../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { listMock } from '../../../../../../lists/server/mocks'; import { getSearchListItemResponseMock } from '../../../../../../lists/common/schemas/response/search_list_item_schema.mock'; -import { EntryList } from '@kbn/securitysolution-io-ts-list-types'; +import type { EntryList } from '@kbn/securitysolution-io-ts-list-types'; import { buildRuleMessageMock as buildRuleMessage } from '../rule_messages.mock'; describe('filterEventsAgainstList', () => { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts index f50f0b521ed76..198a1e805febe 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/filter_events_against_list.ts @@ -6,9 +6,8 @@ */ import type { estypes } from '@elastic/elasticsearch'; -import { entriesList } from '@kbn/securitysolution-io-ts-list-types'; +import { entriesList, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; -import { ExceptionListItemSchema } from '../../../../../../lists/common/schemas'; import { hasLargeValueList } from '../../../../../common/detection_engine/utils'; import { FilterEventsAgainstListOptions } from './types'; import { filterEvents } from './filter_events'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts index f653fde816c62..1252ca3f5faa5 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/filters/types.ts @@ -7,10 +7,9 @@ import type { estypes } from '@elastic/elasticsearch'; import { Logger } from 'src/core/server'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; +import type { Type, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ListClient } from '../../../../../../lists/server'; import { BuildRuleMessage } from '../rule_messages'; -import { ExceptionListItemSchema } from '../../../../../../lists/common/schemas'; export interface FilterEventsAgainstListOptions { listClient: ListClient; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/find_ml_signals.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/find_ml_signals.ts index 6870ae2d80bbf..10f89b56229dc 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/find_ml_signals.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/find_ml_signals.ts @@ -6,7 +6,7 @@ */ import dateMath from '@elastic/datemath'; -import { ExceptionListItemSchema } from '../../../../../lists/common'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { KibanaRequest, SavedObjectsClientContract } from '../../../../../../../src/core/server'; import { MlPluginSetup } from '../../../../../ml/server'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/get_filter.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/get_filter.ts index 3d6a1f8da7f4d..346c4adeba537 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/get_filter.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/get_filter.ts @@ -7,6 +7,7 @@ import { BadRequestError } from '@kbn/securitysolution-es-utils'; import { Type, LanguageOrUndefined, Language } from '@kbn/securitysolution-io-ts-alerting-types'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { assertUnreachable } from '../../../../common/utility_types'; import { getQueryFilter } from '../../../../common/detection_engine/get_query_filter'; import { @@ -14,7 +15,6 @@ import { SavedIdOrUndefined, IndexOrUndefined, } from '../../../../common/detection_engine/schemas/common/schemas'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas'; import { AlertInstanceContext, AlertInstanceState, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts index 0c7723b6f4cc2..52c887c3ca55a 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/search_after_bulk_create.test.ts @@ -23,7 +23,7 @@ import uuid from 'uuid'; import { listMock } from '../../../../../lists/server/mocks'; import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; import { BulkResponse, RuleRangeTuple } from './types'; -import { SearchListItemArraySchema } from '../../../../../lists/common/schemas'; +import type { SearchListItemArraySchema } from '@kbn/securitysolution-io-ts-list-types'; import { getSearchListItemResponseMock } from '../../../../../lists/common/schemas/response/search_list_item_schema.mock'; import { getRuleRangeTuples } from './utils'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts index 82fc0dd3abd0a..094c4d74d8ac7 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/threat_mapping/types.ts @@ -5,7 +5,7 @@ * 2.0. */ import type { estypes } from '@elastic/elasticsearch'; -import { +import type { ThreatQuery, ThreatMapping, ThreatMappingEntries, @@ -17,13 +17,13 @@ import { LanguageOrUndefined, Type, } from '@kbn/securitysolution-io-ts-alerting-types'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { ListClient } from '../../../../../../lists/server'; import { AlertInstanceContext, AlertInstanceState, AlertServices, } from '../../../../../../alerting/server'; -import { ExceptionListItemSchema } from '../../../../../../lists/common/schemas'; import { ElasticsearchClient, Logger, SavedObject } from '../../../../../../../../src/core/server'; import { TelemetryEventsSender } from '../../../telemetry/sender'; import { BuildRuleMessage } from '../rule_messages'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts index 80d08a77ba5d2..8f34e58ebc85b 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts @@ -8,6 +8,7 @@ import type { estypes } from '@elastic/elasticsearch'; import { DslQuery, Filter } from 'src/plugins/data/common'; import moment, { Moment } from 'moment'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { Status } from '../../../../common/detection_engine/schemas/common/schemas'; import { RulesSchema } from '../../../../common/detection_engine/schemas/response/rules_schema'; import { @@ -28,7 +29,6 @@ import { import { RefreshTypes } from '../types'; import { ListClient } from '../../../../../lists/server'; import { Logger, SavedObject } from '../../../../../../../src/core/server'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas'; import { BuildRuleMessage } from './rule_messages'; import { TelemetryEventsSender } from '../../telemetry/sender'; import { RuleParams } from '../schemas/rule_schemas'; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts index c2e3fe83b8893..488a46ab4748d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts @@ -14,7 +14,7 @@ import { isEmpty, partition } from 'lodash'; import { ApiResponse, Context } from '@elastic/elasticsearch/lib/Transport'; import { SortResults } from '@elastic/elasticsearch/api/types'; -import { ListArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListArray, ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { TimestampOverrideOrUndefined, Privilege, @@ -27,7 +27,6 @@ import { parseDuration, } from '../../../../../alerting/server'; import { ExceptionListClient, ListClient, ListPluginSetup } from '../../../../../lists/server'; -import { ExceptionListItemSchema } from '../../../../../lists/common/schemas'; import { BulkResponseErrorAggregation, SignalHit, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts index 03ec7928115b7..1b80a9b6b02e2 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/types.ts @@ -26,7 +26,7 @@ import { } from '@kbn/securitysolution-io-ts-alerting-types'; import { Version } from '@kbn/securitysolution-io-ts-types'; -import { ListArrayOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; +import type { ListArrayOrUndefined } from '@kbn/securitysolution-io-ts-list-types'; import { AnomalyThresholdOrUndefined, Description, diff --git a/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts b/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts index db42dc2720b2a..40dc9392d31ea 100644 --- a/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts +++ b/x-pack/plugins/security_solution/server/lib/machine_learning/index.ts @@ -7,8 +7,8 @@ import type { estypes } from '@elastic/elasticsearch'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { buildExceptionFilter } from '../../../common/shared_imports'; -import { ExceptionListItemSchema } from '../../../../lists/common'; import { AnomalyRecordDoc as Anomaly } from '../../../../ml/server'; export { Anomaly }; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 795a61e862601..800231dd5e6ac 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -13488,14 +13488,6 @@ "xpack.lists.exceptions.builder.fieldLabel": "フィールド", "xpack.lists.exceptions.builder.operatorLabel": "演算子", "xpack.lists.exceptions.builder.valueLabel": "値", - "xpack.lists.exceptions.doesNotExistOperatorLabel": "存在しない", - "xpack.lists.exceptions.existsOperatorLabel": "存在する", - "xpack.lists.exceptions.isInListOperatorLabel": "リストにある", - "xpack.lists.exceptions.isNotInListOperatorLabel": "リストにない", - "xpack.lists.exceptions.isNotOneOfOperatorLabel": "is not one of", - "xpack.lists.exceptions.isNotOperatorLabel": "is not", - "xpack.lists.exceptions.isOneOfOperatorLabel": "is one of", - "xpack.lists.exceptions.isOperatorLabel": "is", "xpack.lists.exceptions.orDescription": "OR", "xpack.logstash.addRoleAlert.grantAdditionalPrivilegesDescription": "Kibana の管理で、Kibana ユーザーに {role} ロールを割り当ててください。", "xpack.logstash.addRoleAlert.grantAdditionalPrivilegesTitle": "追加権限の授与。", @@ -20958,7 +20950,6 @@ "xpack.securitySolution.exceptions.detectionListLabel": "検出リスト", "xpack.securitySolution.exceptions.dissasociateExceptionListError": "例外リストを削除できませんでした", "xpack.securitySolution.exceptions.dissasociateListSuccessText": "例外リスト ({id}) が正常に削除されました", - "xpack.securitySolution.exceptions.doesNotExistOperatorLabel": "存在しない", "xpack.securitySolution.exceptions.editButtonLabel": "編集", "xpack.securitySolution.exceptions.editException.bulkCloseLabel": "この例外一致し、このルールによって生成された、すべてのアラートを閉じる", "xpack.securitySolution.exceptions.editException.bulkCloseLabel.disabled": "この例外と一致し、このルールによって生成された、すべてのアラートを閉じる (リストと非ECSフィールドはサポートされません) ", @@ -20976,16 +20967,9 @@ "xpack.securitySolution.exceptions.endpointListLabel": "エンドポイントリスト", "xpack.securitySolution.exceptions.errorLabel": "エラー", "xpack.securitySolution.exceptions.exceptionsPaginationLabel": "ページごとの項目数:{items}", - "xpack.securitySolution.exceptions.existsOperatorLabel": "存在する", "xpack.securitySolution.exceptions.fetch404Error": "関連付けられた例外リスト ({listId}) は存在しません。その他の例外を検出ルールに追加するには、見つからない例外リストを削除してください。", "xpack.securitySolution.exceptions.fetchError": "例外リストの取得エラー", "xpack.securitySolution.exceptions.fieldDescription": "フィールド", - "xpack.securitySolution.exceptions.isInListOperatorLabel": "リストにある", - "xpack.securitySolution.exceptions.isNotInListOperatorLabel": "リストにない", - "xpack.securitySolution.exceptions.isNotOneOfOperatorLabel": "is not one of", - "xpack.securitySolution.exceptions.isNotOperatorLabel": "is not", - "xpack.securitySolution.exceptions.isOneOfOperatorLabel": "is one of", - "xpack.securitySolution.exceptions.isOperatorLabel": "is", "xpack.securitySolution.exceptions.modalErrorAccordionText": "ルール参照情報を表示:", "xpack.securitySolution.exceptions.operatingSystemLabel": "OS", "xpack.securitySolution.exceptions.operatorDescription": "演算子", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 3272e0ecfa8cf..e524d3f3a88d6 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -13665,14 +13665,6 @@ "xpack.lists.exceptions.builder.fieldLabel": "字段", "xpack.lists.exceptions.builder.operatorLabel": "运算符", "xpack.lists.exceptions.builder.valueLabel": "值", - "xpack.lists.exceptions.doesNotExistOperatorLabel": "不存在", - "xpack.lists.exceptions.existsOperatorLabel": "存在", - "xpack.lists.exceptions.isInListOperatorLabel": "在列表中", - "xpack.lists.exceptions.isNotInListOperatorLabel": "不在列表中", - "xpack.lists.exceptions.isNotOneOfOperatorLabel": "不属于", - "xpack.lists.exceptions.isNotOperatorLabel": "不是", - "xpack.lists.exceptions.isOneOfOperatorLabel": "属于", - "xpack.lists.exceptions.isOperatorLabel": "是", "xpack.lists.exceptions.orDescription": "OR", "xpack.logstash.addRoleAlert.grantAdditionalPrivilegesDescription": "在 Kibana“管理”中,将 {role} 角色分配给您的 Kibana 用户。", "xpack.logstash.addRoleAlert.grantAdditionalPrivilegesTitle": "授予其他权限。", @@ -21266,7 +21258,6 @@ "xpack.securitySolution.exceptions.detectionListLabel": "检测列表", "xpack.securitySolution.exceptions.dissasociateExceptionListError": "无法移除例外列表", "xpack.securitySolution.exceptions.dissasociateListSuccessText": "例外列表 ({id}) 已成功移除", - "xpack.securitySolution.exceptions.doesNotExistOperatorLabel": "不存在", "xpack.securitySolution.exceptions.editButtonLabel": "编辑", "xpack.securitySolution.exceptions.editException.bulkCloseLabel": "关闭所有与此例外匹配且根据此规则生成的告警", "xpack.securitySolution.exceptions.editException.bulkCloseLabel.disabled": "关闭所有与此例外匹配且根据此规则生成的告警 (不支持列表和非 ECS 字段) ", @@ -21284,17 +21275,10 @@ "xpack.securitySolution.exceptions.endpointListLabel": "终端列表", "xpack.securitySolution.exceptions.errorLabel": "错误", "xpack.securitySolution.exceptions.exceptionsPaginationLabel": "每页项数:{items}", - "xpack.securitySolution.exceptions.existsOperatorLabel": "存在", "xpack.securitySolution.exceptions.fetch404Error": "关联的例外列表 ({listId}) 已不存在。请移除缺少的例外列表,以将其他例外添加到检测规则。", "xpack.securitySolution.exceptions.fetchError": "提取例外列表时出错", "xpack.securitySolution.exceptions.fieldDescription": "字段", "xpack.securitySolution.exceptions.hideCommentsLabel": "隐藏 ({comments}) 个{comments, plural, other {注释}}", - "xpack.securitySolution.exceptions.isInListOperatorLabel": "在列表中", - "xpack.securitySolution.exceptions.isNotInListOperatorLabel": "不在列表中", - "xpack.securitySolution.exceptions.isNotOneOfOperatorLabel": "不属于", - "xpack.securitySolution.exceptions.isNotOperatorLabel": "不是", - "xpack.securitySolution.exceptions.isOneOfOperatorLabel": "属于", - "xpack.securitySolution.exceptions.isOperatorLabel": "是", "xpack.securitySolution.exceptions.modalErrorAccordionText": "显示规则引用信息:", "xpack.securitySolution.exceptions.operatingSystemLabel": "OS", "xpack.securitySolution.exceptions.operatorDescription": "运算符", diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts index 18f9858726723..c014d08e91f66 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_exceptions.ts @@ -8,6 +8,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import expect from '@kbn/expect'; +import type { CreateExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { CreateRulesSchema, EqlCreateSchema, @@ -24,7 +25,6 @@ import { } from '../../../lists_api_integration/utils'; import { RulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/response'; import { getCreateExceptionListMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; -import { CreateExceptionListItemSchema } from '../../../../plugins/lists/common'; import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL, diff --git a/x-pack/test/detection_engine_api_integration/utils.ts b/x-pack/test/detection_engine_api_integration/utils.ts index 0f888c3ee515a..3a06ea1c8bc7a 100644 --- a/x-pack/test/detection_engine_api_integration/utils.ts +++ b/x-pack/test/detection_engine_api_integration/utils.ts @@ -12,7 +12,13 @@ import { SuperTest } from 'supertest'; import supertestAsPromised from 'supertest-as-promised'; import { Context } from '@elastic/elasticsearch/lib/Transport'; import { SearchResponse } from 'elasticsearch'; -import { NonEmptyEntriesArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { NonEmptyEntriesArray } from '@kbn/securitysolution-io-ts-list-types'; +import type { + CreateExceptionListItemSchema, + CreateExceptionListSchema, + ExceptionListItemSchema, + ExceptionListSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { PrePackagedRulesAndTimelinesStatusSchema } from '../../plugins/security_solution/common/detection_engine/schemas/response'; import { getCreateExceptionListDetectionSchemaMock } from '../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; import { @@ -22,12 +28,6 @@ import { QueryCreateSchema, } from '../../plugins/security_solution/common/detection_engine/schemas/request'; import { EXCEPTION_LIST_ITEM_URL, EXCEPTION_LIST_URL } from '../../plugins/lists/common/constants'; -import { - CreateExceptionListItemSchema, - CreateExceptionListSchema, - ExceptionListItemSchema, - ExceptionListSchema, -} from '../../plugins/lists/common'; import { Signal } from '../../plugins/security_solution/server/lib/detection_engine/signals/types'; import { signalsMigrationType } from '../../plugins/security_solution/server/lib/detection_engine/migrations/saved_objects'; import { diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_list_items.ts index 0d32ea4d1e0ad..b394b0a21e59c 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_list_items.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { ExceptionListItemSchema } from '../../../../plugins/lists/common'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionListItemResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_item_schema.mock'; import { getCreateExceptionListMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; import { diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_lists.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_lists.ts index 49421f40a3053..840a425b4bf5e 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_lists.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/create_exception_lists.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { ExceptionListSchema } from '../../../../plugins/lists/common'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { EXCEPTION_LIST_URL } from '../../../../plugins/lists/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { getExceptionResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_schema.mock'; diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_list_items.ts index 36f72e8b8cb51..4cf95daa146d3 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_list_items.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { ExceptionListItemSchema } from '../../../../plugins/lists/common'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionListItemResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_item_schema.mock'; import { getCreateExceptionListItemMinimalSchemaMock, diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_lists.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_lists.ts index aa916f00d2f88..4b8b9b84f5dfc 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_lists.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/delete_exception_lists.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { ExceptionListSchema } from '../../../../plugins/lists/common'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_schema.mock'; import { getCreateExceptionListMinimalSchemaMock, diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/export_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/export_list_items.ts index 67222000d2d7d..563c0c5b3c313 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/export_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/export_list_items.ts @@ -6,10 +6,10 @@ */ import expect from '@kbn/expect'; +import type { CreateListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getCreateMinimalListItemSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_list_item_schema.mock'; import { getCreateMinimalListSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_list_schema.mock'; import { LIST_ID, NAME } from '../../../../plugins/lists/common/constants.mock'; -import { CreateListItemSchema } from '../../../../plugins/lists/common/schemas'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { LIST_ITEM_URL, LIST_URL } from '../../../../plugins/lists/common/constants'; diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/import_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/import_list_items.ts index 3e20941669976..d80b538882bb8 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/import_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/import_list_items.ts @@ -6,9 +6,8 @@ */ import expect from '@kbn/expect'; -import { ListItemSchema } from '../../../../plugins/lists/common/schemas'; +import type { ListSchema, ListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getListItemResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/list_item_schema.mock'; -import { ListSchema } from '../../../../plugins/lists/common'; import { getListResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/list_schema.mock'; import { FtrProviderContext } from '../../common/ftr_provider_context'; diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_list_items.ts index da0473150a3e3..b3af396e27021 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_list_items.ts @@ -7,12 +7,12 @@ import expect from '@kbn/expect'; +import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionListItemResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_item_schema.mock'; import { getCreateExceptionListItemMinimalSchemaMock, getCreateExceptionListItemMinimalSchemaMockWithoutId, } from '../../../../plugins/lists/common/schemas/request/create_exception_list_item_schema.mock'; -import { ExceptionListItemSchema } from '../../../../plugins/lists/common'; import { getCreateExceptionListMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_lists.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_lists.ts index 0e130c87dce6a..a53f3d1d2bded 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_lists.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/read_exception_lists.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; -import { ExceptionListSchema } from '../../../../plugins/lists/common'; +import type { ExceptionListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_schema.mock'; import { getCreateExceptionListMinimalSchemaMock, diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_list_items.ts index 3af8372f0e71f..d072a96772295 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_list_items.ts @@ -7,6 +7,10 @@ import expect from '@kbn/expect'; +import type { + UpdateExceptionListItemSchema, + ExceptionListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionListItemResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_item_schema.mock'; import { getCreateExceptionListItemMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_item_schema.mock'; import { getCreateExceptionListMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; @@ -17,10 +21,6 @@ import { } from '../../../../plugins/lists/common/constants'; import { deleteAllExceptions, removeExceptionListServerGeneratedProperties } from '../../utils'; -import { - UpdateExceptionListItemSchema, - ExceptionListItemSchema, -} from '../../../../plugins/lists/common/schemas'; import { getUpdateMinimalExceptionListItemSchemaMock } from '../../../../plugins/lists/common/schemas/request/update_exception_list_item_schema.mock'; diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_lists.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_lists.ts index d07e12db1c85b..6f5866e8968ff 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_lists.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_exception_lists.ts @@ -7,16 +7,16 @@ import expect from '@kbn/expect'; +import type { + UpdateExceptionListSchema, + ExceptionListSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { getExceptionResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/exception_list_schema.mock'; import { getCreateExceptionListMinimalSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_exception_list_schema.mock'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { EXCEPTION_LIST_URL } from '../../../../plugins/lists/common/constants'; import { deleteAllExceptions, removeExceptionListServerGeneratedProperties } from '../../utils'; -import { - UpdateExceptionListSchema, - ExceptionListSchema, -} from '../../../../plugins/lists/common/schemas'; import { getUpdateMinimalExceptionListSchemaMock } from '../../../../plugins/lists/common/schemas/request/update_exception_list_schema.mock'; diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_list_items.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_list_items.ts index 3fa9110d8945d..fdcb7eeacdbad 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_list_items.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_list_items.ts @@ -7,6 +7,11 @@ import expect from '@kbn/expect'; +import type { + UpdateListItemSchema, + CreateListItemSchema, + ListItemSchema, +} from '@kbn/securitysolution-io-ts-list-types'; import { getListItemResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/list_item_schema.mock'; import { getCreateMinimalListItemSchemaMock } from '../../../../plugins/lists/common/schemas/request/create_list_item_schema.mock'; import { FtrProviderContext } from '../../common/ftr_provider_context'; @@ -19,11 +24,6 @@ import { removeListItemServerGeneratedProperties, } from '../../utils'; import { getUpdateMinimalListItemSchemaMock } from '../../../../plugins/lists/common/schemas/request/update_list_item_schema.mock'; -import { - UpdateListItemSchema, - CreateListItemSchema, - ListItemSchema, -} from '../../../../plugins/lists/common/schemas'; // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { diff --git a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_lists.ts b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_lists.ts index 05a46a06eab39..ad42f6f9e9e6e 100644 --- a/x-pack/test/lists_api_integration/security_and_spaces/tests/update_lists.ts +++ b/x-pack/test/lists_api_integration/security_and_spaces/tests/update_lists.ts @@ -7,6 +7,7 @@ import expect from '@kbn/expect'; +import type { UpdateListSchema, ListSchema } from '@kbn/securitysolution-io-ts-list-types'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { LIST_URL } from '../../../../plugins/lists/common/constants'; @@ -18,7 +19,6 @@ import { } from '../../utils'; import { getListResponseMockWithoutAutoGeneratedValues } from '../../../../plugins/lists/common/schemas/response/list_schema.mock'; import { getUpdateMinimalListSchemaMock } from '../../../../plugins/lists/common/schemas/request/update_list_schema.mock'; -import { UpdateListSchema, ListSchema } from '../../../../plugins/lists/common/schemas'; // eslint-disable-next-line import/no-default-export export default ({ getService }: FtrProviderContext) => { diff --git a/x-pack/test/lists_api_integration/utils.ts b/x-pack/test/lists_api_integration/utils.ts index 29846a79d6b02..81a4298ea1d0c 100644 --- a/x-pack/test/lists_api_integration/utils.ts +++ b/x-pack/test/lists_api_integration/utils.ts @@ -9,14 +9,14 @@ import { SuperTest } from 'supertest'; import supertestAsPromised from 'supertest-as-promised'; import type { KibanaClient } from '@elastic/elasticsearch/api/kibana'; -import { Type } from '@kbn/securitysolution-io-ts-list-types'; -import { getImportListItemAsBuffer } from '../../plugins/lists/common/schemas/request/import_list_item_schema.mock'; -import { +import type { + Type, + ListSchema, ListItemSchema, ExceptionListSchema, ExceptionListItemSchema, -} from '../../plugins/lists/common/schemas'; -import { ListSchema } from '../../plugins/lists/common'; +} from '@kbn/securitysolution-io-ts-list-types'; +import { getImportListItemAsBuffer } from '../../plugins/lists/common/schemas/request/import_list_item_schema.mock'; import { LIST_INDEX, LIST_ITEM_URL } from '../../plugins/lists/common/constants'; import { countDownES, countDownTest } from '../detection_engine_api_integration/utils'; diff --git a/yarn.lock b/yarn.lock index c8293e9f2b914..19922d11802d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2707,6 +2707,9 @@ uid "" "@kbn/securitysolution-es-utils@link:bazel-bin/packages/kbn-securitysolution-es-utils/npm_module": + version "0.0.0" + uid "" + "@kbn/securitysolution-io-ts-alerting-types@link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types/npm_module": version "0.0.0" uid "" @@ -2723,6 +2726,10 @@ version "0.0.0" uid "" +"@kbn/securitysolution-list-utils@link:bazel-bin/packages/kbn-securitysolution-list-utils/npm_module": + version "0.0.0" + uid "" + "@kbn/securitysolution-utils@link:bazel-bin/packages/kbn-securitysolution-utils/npm_module": version "0.0.0" uid "" From be97fae12ea0e12a2d9d9ffacd0b6e59ba921c20 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 19 May 2021 15:51:32 -0700 Subject: [PATCH 18/18] skip flaky suite (#100372) (#96997) --- .../apps/visualize/input_control_vis/chained_controls.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/functional/apps/visualize/input_control_vis/chained_controls.ts b/test/functional/apps/visualize/input_control_vis/chained_controls.ts index 18d1367b37e72..2f91c789a478b 100644 --- a/test/functional/apps/visualize/input_control_vis/chained_controls.ts +++ b/test/functional/apps/visualize/input_control_vis/chained_controls.ts @@ -17,7 +17,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const find = getService('find'); const comboBox = getService('comboBox'); - describe('chained controls', function () { + // FLAKY: https://github.com/elastic/kibana/issues/96997 + // FLAKY: https://github.com/elastic/kibana/issues/100372 + describe.skip('chained controls', function () { this.tags('includeFirefox'); before(async () => {