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 c13065f4c4975..a30cd2e39ed96 100644 --- a/package.json +++ b/package.json @@ -139,6 +139,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 344a70bad5c20..f92855e7e1cd4 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -13496,14 +13496,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": "追加権限の授与。", @@ -20972,7 +20964,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フィールドはサポートされません) ", @@ -20990,16 +20981,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 5f06bd900c4fb..97a58abf9e5a5 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -13673,14 +13673,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": "授予其他权限。", @@ -21280,7 +21272,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 字段) ", @@ -21298,17 +21289,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 e18a6e6d4c36f..86da558635ac7 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 ""