[Security Solutions] Breaks down the io-ts packages to decrease plugin size (#100058)

## Summary

The io-ts package was too large and needed to broken down more by domain to decrease the lists plugin size and any other plugin wanting to use the packages will not incur big hits as well.

Before we had one large io-ts package:

```
@kbn/securitysolution-io-ts-utils
```

Now we have these broken down 4 packages:

```
@kbn/securitysolution-io-ts-utils
@kbn/securitysolution-io-ts-types
@kbn/securitysolution-io-ts-alerting-types
@kbn/securitysolution-io-ts-list-types   
```

Deps between these packages are:

```
@kbn/securitysolution-io-ts-utils (none)
@kbn/securitysolution-io-ts-types -> @kbn/securitysolution-io-ts-utils
@kbn/securitysolution-io-ts-alerting-types -> @kbn/securitysolution-io-ts-types, @kbn/securitysolution-io-ts-utils
@kbn/securitysolution-io-ts-list-types  -> @kbn/securitysolution-io-ts-types, @kbn/securitysolution-io-ts-utils
```

Short description and function of each (Also in each of their README.md):

```
@kbn/securitysolution-io-ts-utils, Smallest amount of utilities such as format, validate, etc...
@kbn/securitysolution-io-ts-types, Base types such as to_number, to_string, etc...
@kbn/securitysolution-io-ts-alerting-types, Alerting specific types such as severity, from, to, etc...
@kbn/securitysolution-io-ts-list-types, list specific types such as exception lists, exception list types, etc...
```

### Checklist

Delete any items that are not applicable to this PR.

- [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
Frank Hassanabad 2021-05-13 15:36:06 -06:00 committed by GitHub
parent 6bafb59fd5
commit 7dd29a56ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
306 changed files with 897 additions and 423 deletions

View file

@ -137,6 +137,9 @@
"@kbn/monaco": "link:packages/kbn-monaco",
"@kbn/securitysolution-constants": "link:bazel-bin/packages/kbn-securitysolution-constants/npm_module",
"@kbn/securitysolution-es-utils": "link:bazel-bin/packages/kbn-securitysolution-es-utils/npm_module",
"@kbn/securitysolution-io-ts-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-types/npm_module",
"@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-utils": "link:bazel-bin/packages/kbn-securitysolution-utils/npm_module",
"@kbn/server-http-tools": "link:packages/kbn-server-http-tools",

View file

@ -25,6 +25,9 @@ filegroup(
"//packages/kbn-logging:build",
"//packages/kbn-plugin-generator:build",
"//packages/kbn-securitysolution-constants:build",
"//packages/kbn-securitysolution-io-ts-types:build",
"//packages/kbn-securitysolution-io-ts-alerting-types:build",
"//packages/kbn-securitysolution-io-ts-list-types:build",
"//packages/kbn-securitysolution-io-ts-utils:build",
"//packages/kbn-securitysolution-utils:build",
"//packages/kbn-securitysolution-es-utils:build",

View file

@ -0,0 +1,94 @@
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-alerting-types"
PKG_REQUIRE_NAME = "@kbn/securitysolution-io-ts-alerting-types"
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-securitysolution-io-ts-types",
"//packages/kbn-securitysolution-io-ts-utils",
"//packages/elastic-datemath",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//lodash",
"@npm//moment",
"@npm//tslib",
"@npm//uuid",
]
TYPES_DEPS = [
"@npm//@types/flot",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/uuid"
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":tsc"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,8 @@
# kbn-securitysolution-io-ts-alerting-types
Types that are specific to the security solution alerting to be shared among plugins.
Related packages are
* kbn-securitysolution-io-ts-utils
* kbn-securitysolution-io-ts-list-types
* kbn-securitysolution-io-ts-types

View file

@ -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: ['<rootDir>/packages/kbn-securitysolution-io-ts-alerting-types'],
};

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/securitysolution-io-ts-alerting-types",
"version": "1.0.0",
"description": "io ts utilities and types to be shared with plugins from the security solution project",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"private": true
}

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultExportFileName } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_export_file_name', () => {
test('it should validate a regular string', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultFromString } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_from_string', () => {
test('it should validate a from string', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultIntervalString } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_interval_string', () => {
test('it should validate a interval string', () => {

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { Language } from '../language';
import { DefaultLanguageString } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_language_string', () => {
test('it should validate a string', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultMaxSignalsNumber } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { DEFAULT_MAX_SIGNALS } from '../constants';
describe('default_from_string', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultPage } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_page', () => {
test('it should validate a regular number greater than zero', () => {

View file

@ -8,7 +8,7 @@
import * as t from 'io-ts';
import { Either } from 'fp-ts/lib/Either';
import { PositiveIntegerGreaterThanZero } from '../positive_integer_greater_than_zero';
import { PositiveIntegerGreaterThanZero } from '@kbn/securitysolution-io-ts-types';
/**
* Types the DefaultPerPage as:

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultPerPage } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_per_page', () => {
test('it should validate a regular number greater than zero', () => {

View file

@ -8,7 +8,7 @@
import * as t from 'io-ts';
import { Either } from 'fp-ts/lib/Either';
import { PositiveIntegerGreaterThanZero } from '../positive_integer_greater_than_zero';
import { PositiveIntegerGreaterThanZero } from '@kbn/securitysolution-io-ts-types';
/**
* Types the DefaultPerPage as:

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { Threats } from '../threat';
import { DefaultThreatArray } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_threat_null', () => {
test('it should validate an empty array', () => {

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { Throttle } from '../throttle';
import { DefaultThrottleNull } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_throttle_null', () => {
test('it should validate a throttle string', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultToString } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_to_string', () => {
test('it should validate a to string', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultUuid } from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_uuid', () => {
test('it should validate a regular string', () => {

View file

@ -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 * as t from 'io-ts';
import { Either } from 'fp-ts/lib/Either';
import uuid from 'uuid';
import { NonEmptyString } from '@kbn/securitysolution-io-ts-types';
/**
* Types the DefaultUuid as:
* - If null or undefined, then a default string uuid.v4() will be
* created otherwise it will be checked just against an empty string
*/
export const DefaultUuid = new t.Type<string, string | undefined, unknown>(
'DefaultUuid',
t.string.is,
(input, context): Either<t.Errors, string> =>
input == null ? t.success(uuid.v4()) : NonEmptyString.validate(input, context),
t.identity
);

View file

@ -8,7 +8,7 @@
import { Either } from 'fp-ts/lib/Either';
import * as t from 'io-ts';
import { parseScheduleDates } from '../parse_schedule_dates';
import { parseScheduleDates } from '@kbn/securitysolution-io-ts-types';
const stringValidator = (input: unknown): input is string => typeof input === 'string';

View file

@ -0,0 +1,40 @@
/*
* Copyright 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 './actions';
export * from './constants';
export * from './default_actions_array';
export * from './default_export_file_name';
export * from './default_from_string';
export * from './default_interval_string';
export * from './default_language_string';
export * from './default_max_signals_number';
export * from './default_page';
export * from './default_per_page';
export * from './default_risk_score_mapping_array';
export * from './default_severity_mapping_array';
export * from './default_threat_array';
export * from './default_throttle_null';
export * from './default_to_string';
export * from './default_uuid';
export * from './from';
export * from './language';
export * from './max_signals';
export * from './normalized_ml_job_id';
export * from './references_default_array';
export * from './risk_score';
export * from './risk_score_mapping';
export * from './saved_object_attributes';
export * from './severity';
export * from './severity_mapping';
export * from './threat';
export * from './threat_mapping';
export * from './threat_subtechnique';
export * from './threat_tactic';
export * from './threat_technique';
export * from './throttle';

View file

@ -9,7 +9,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import * as t from 'io-ts';
import { PositiveIntegerGreaterThanZero } from '../positive_integer_greater_than_zero';
import { PositiveIntegerGreaterThanZero } from '@kbn/securitysolution-io-ts-types';
export const max_signals = PositiveIntegerGreaterThanZero;
export type MaxSignals = t.TypeOf<typeof max_signals>;

View file

@ -10,7 +10,7 @@
import * as t from 'io-ts';
import { NonEmptyArray } from '../non_empty_array';
import { NonEmptyArray } from '@kbn/securitysolution-io-ts-types';
export const machine_learning_job_id_normalized = NonEmptyArray(t.string);
export type MachineLearningJobIdNormalized = t.TypeOf<typeof machine_learning_job_id_normalized>;

View file

@ -8,13 +8,13 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultStringArray } from '../default_string_array';
import { foldLeftRight, getPaths } from '../test_utils';
import { ReferencesDefaultArray } from '.';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_string_array', () => {
test('it should validate an empty array', () => {
const payload: string[] = [];
const decoded = DefaultStringArray.decode(payload);
const decoded = ReferencesDefaultArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([]);
@ -23,7 +23,7 @@ describe('default_string_array', () => {
test('it should validate an array of strings', () => {
const payload = ['value 1', 'value 2'];
const decoded = DefaultStringArray.decode(payload);
const decoded = ReferencesDefaultArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([]);
@ -32,18 +32,18 @@ describe('default_string_array', () => {
test('it should not validate an array with a number', () => {
const payload = ['value 1', 5];
const decoded = DefaultStringArray.decode(payload);
const decoded = ReferencesDefaultArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([
'Invalid value "5" supplied to "DefaultStringArray"',
'Invalid value "5" supplied to "referencesWithDefaultArray"',
]);
expect(message.schema).toEqual({});
});
test('it should return a default array entry', () => {
const payload = null;
const decoded = DefaultStringArray.decode(payload);
const decoded = ReferencesDefaultArray.decode(payload);
const message = pipe(decoded, foldLeftRight);
expect(getPaths(left(message.errors))).toEqual([]);

View file

@ -8,7 +8,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { RiskScore } from '.';
describe('risk_score', () => {

View file

@ -9,10 +9,9 @@
/* eslint-disable @typescript-eslint/naming-convention */
import * as t from 'io-ts';
import { operator } from '@kbn/securitysolution-io-ts-types';
import { RiskScore } from '../risk_score';
import { operator } from '../operator';
export const riskScoreOrUndefined = t.union([RiskScore, t.undefined]);
export type RiskScoreOrUndefined = t.TypeOf<typeof riskScoreOrUndefined>;

View file

@ -10,7 +10,7 @@
import * as t from 'io-ts';
import { operator } from '../operator';
import { operator } from '@kbn/securitysolution-io-ts-types';
import { severity } from '../severity';
export const severity_mapping_field = t.string;

View file

@ -16,8 +16,7 @@ import {
ThreatMappingEntries,
threat_mapping,
} from '.';
import { foldLeftRight, getPaths } from '../test_utils';
import { exactCheck } from '../exact_check';
import { foldLeftRight, getPaths, exactCheck } from '@kbn/securitysolution-io-ts-utils';
describe('threat_mapping', () => {
describe('threatMappingEntries', () => {

View file

@ -9,10 +9,12 @@
/* eslint-disable @typescript-eslint/naming-convention */
import * as t from 'io-ts';
import {
NonEmptyArray,
NonEmptyString,
PositiveIntegerGreaterThanZero,
} from '@kbn/securitysolution-io-ts-types';
import { language } from '../language';
import { NonEmptyArray } from '../non_empty_array';
import { NonEmptyString } from '../non_empty_string';
import { PositiveIntegerGreaterThanZero } from '../positive_integer_greater_than_zero';
export const threat_query = t.string;
export type ThreatQuery = t.TypeOf<typeof threat_query>;

View file

@ -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-io-ts-alerting-types/src",
"types": [
"jest",
"node"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,94 @@
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"
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-securitysolution-io-ts-types",
"//packages/kbn-securitysolution-io-ts-utils",
"//packages/elastic-datemath",
"@npm//fp-ts",
"@npm//io-ts",
"@npm//lodash",
"@npm//moment",
"@npm//tslib",
"@npm//uuid",
]
TYPES_DEPS = [
"@npm//@types/flot",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/uuid"
]
DEPS = SRC_DEPS + TYPES_DEPS
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)
ts_project(
name = "tsc",
args = ['--pretty'],
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":tsc"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)
filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)

View file

@ -0,0 +1,8 @@
# kbn-securitysolution-io-ts-list-types
io-ts types that are specific to lists to be shared among plugins
Related packages are
* kbn-securitysolution-io-ts-alerting-types
* kbn-securitysolution-io-ts-ts-utils
* kbn-securitysolution-io-ts-types

View file

@ -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: ['<rootDir>/packages/kbn-securitysolution-io-ts-list-types'],
};

View file

@ -0,0 +1,9 @@
{
"name": "@kbn/securitysolution-io-ts-list-types",
"version": "1.0.0",
"description": "io ts utilities and types to be shared with plugins from the security solution project",
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"private": true
}

View file

@ -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',

View file

@ -17,8 +17,8 @@ import {
CommentsArrayOrUndefined,
commentsArrayOrUndefined,
} from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { DATE_NOW } from '../../constants/index.mock';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { DATE_NOW } from '../constants/index.mock';
describe('Comment', () => {
describe('comment', () => {

View file

@ -8,12 +8,12 @@
import * as t from 'io-ts';
import { NonEmptyString } from '../../non_empty_string';
import { created_at } from '../../created_at';
import { created_by } from '../../created_by';
import { id } from '../../id';
import { updated_at } from '../../updated_at';
import { updated_by } from '../../updated_by';
import { NonEmptyString } from '@kbn/securitysolution-io-ts-types';
import { created_at } from '../created_at';
import { created_by } from '../created_by';
import { id } from '../id';
import { updated_at } from '../updated_at';
import { updated_by } from '../updated_by';
export const comment = t.intersection([
t.exact(

View file

@ -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.
*/
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';
export const LIST_ID = 'some-list-id';
export const LIST = 'list';
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';
// Exception List specific
export const ID = 'uuid_here';

View file

@ -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.
*/
/**
* This ID is used for _both_ the Saved Object ID and for the list_id
* for the single global space agnostic endpoint list.
*
* TODO: Create a kbn-securitysolution-constants and add this to it.
* @deprecated Use the ENDPOINT_LIST_ID from the kbn-securitysolution-constants.
*/
export const ENDPOINT_LIST_ID = 'endpoint_list';

View file

@ -17,7 +17,7 @@ import {
CreateCommentsArrayOrUndefined,
createCommentsArrayOrUndefined,
} from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('CreateComment', () => {
describe('createComment', () => {

View file

@ -7,7 +7,7 @@
*/
import * as t from 'io-ts';
import { NonEmptyString } from '../../non_empty_string';
import { NonEmptyString } from '@kbn/securitysolution-io-ts-types';
export const createComment = t.exact(
t.type({

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { CommentsArray } from '../comment';
import { DefaultCommentsArray } from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getCommentsArrayMock } from '../comment/index.mock';
describe('default_comments_array', () => {

View file

@ -8,7 +8,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { CommentsArray } from '../comment';
import { DefaultCommentsArray } from '../default_comments_array';
import { getCommentsArrayMock } from '../comment/index.mock';

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultNamespace } from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_namespace', () => {
test('it should validate "single"', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultNamespaceArray, DefaultNamespaceArrayType } from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_namespace_array', () => {
test('it should validate "null" single item as an array with a "single" value', () => {

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { UpdateCommentsArray } from '../update_comment';
import { DefaultUpdateCommentsArray } from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getUpdateCommentsArrayMock } from '../update_comment/index.mock';
describe('default_update_comments_array', () => {

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { DefaultVersionNumber } from '../default_version_number';
import { foldLeftRight, getPaths } from '../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
describe('default_version_number', () => {
test('it should validate a version number', () => {

View file

@ -14,7 +14,7 @@ import {
nonEmptyEndpointEntriesArray,
NonEmptyEndpointEntriesArray,
} from '.';
import { foldLeftRight, getPaths } from '../../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getEndpointEntryMatchAnyMock } from '../entry_match_any/index.mock';
import { getEndpointEntryNestedMock } from '../entry_nested/index.mock';
import { getEndpointEntriesArrayMock } from './index.mock';

View file

@ -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,

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { getEndpointEntryMatchMock } from './index.mock';
import { EndpointEntryMatch, endpointEntryMatch } from '.';
import { foldLeftRight, getPaths } from '../../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getEntryMatchMock } from '../../entry_match/index.mock';
describe('endpointEntryMatch', () => {

View file

@ -7,8 +7,7 @@
*/
import * as t from 'io-ts';
import { operatorIncluded } from '../../../operator';
import { NonEmptyString } from '../../../non_empty_string';
import { NonEmptyString, operatorIncluded } from '@kbn/securitysolution-io-ts-types';
export const endpointEntryMatch = t.exact(
t.type({

View file

@ -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 => ({

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { getEndpointEntryMatchAnyMock } from './index.mock';
import { EndpointEntryMatchAny, endpointEntryMatchAny } from '.';
import { foldLeftRight, getPaths } from '../../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getEntryMatchAnyMock } from '../../entry_match_any/index.mock';
describe('endpointEntryMatchAny', () => {

View file

@ -7,9 +7,11 @@
*/
import * as t from 'io-ts';
import { nonEmptyOrNullableStringArray } from '../../../non_empty_or_nullable_string_array';
import { operatorIncluded } from '../../../operator';
import { NonEmptyString } from '../../../non_empty_string';
import {
NonEmptyString,
nonEmptyOrNullableStringArray,
operatorIncluded,
} from '@kbn/securitysolution-io-ts-types';
export const endpointEntryMatchAny = t.exact(
t.type({

View file

@ -7,8 +7,7 @@
*/
import * as t from 'io-ts';
import { operatorIncluded } from '../../../operator';
import { NonEmptyString } from '../../../non_empty_string';
import { NonEmptyString, operatorIncluded } from '@kbn/securitysolution-io-ts-types';
export const endpointEntryMatchWildcard = t.exact(
t.type({

View file

@ -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';

View file

@ -9,7 +9,7 @@
import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { EndpointEntryNested, endpointEntryNested } from '.';
import { foldLeftRight, getPaths } from '../../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getEndpointEntryNestedMock } from './index.mock';
import { getEndpointEntryMatchAnyMock } from '../entry_match_any/index.mock';
import {

View file

@ -7,7 +7,7 @@
*/
import * as t from 'io-ts';
import { NonEmptyString } from '../../../non_empty_string';
import { NonEmptyString } from '@kbn/securitysolution-io-ts-types';
import { nonEmptyEndpointNestedEntriesArray } from '../non_empty_nested_entries_array';
export const endpointEntryNested = t.exact(

View file

@ -10,7 +10,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
import { left } from 'fp-ts/lib/Either';
import { getEntryMatchMock } from '../entry_match/index.mock';
import { entriesArray, entriesArrayOrUndefined, entry } from '.';
import { foldLeftRight, getPaths } from '../../test_utils';
import { foldLeftRight, getPaths } from '@kbn/securitysolution-io-ts-utils';
import { getEntryMatchAnyMock } from '../entry_match_any/index.mock';
import { getEntryExistsMock } from '../entries_exist/index.mock';
import { getEntryListMock } from '../entries_list/index.mock';

Some files were not shown because too many files have changed in this diff Show more