forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solutions] Breaks down the io-ts packages to decrease plugi…
…n size (elastic#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
- Loading branch information
1 parent
08a4812
commit 6417fac
Showing
306 changed files
with
897 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
packages/kbn-securitysolution-io-ts-alerting-types/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
13 changes: 13 additions & 0 deletions
13
packages/kbn-securitysolution-io-ts-alerting-types/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'], | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/kbn-securitysolution-io-ts-alerting-types/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/kbn-securitysolution-io-ts-alerting-types/src/default_uuid/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/kbn-securitysolution-io-ts-alerting-types/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.