chore(NA): splits types from code on @kbn/securitysolution-list-utils (#121689)

* chore(NA): splits types from code on @kbn/securitysolution-list-utils

* chore(NA): add todos to remove later
This commit is contained in:
Tiago Costa 2021-12-21 20:38:34 +00:00 committed by GitHub
parent cb588a3a15
commit 769efcdd2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 14 deletions

View file

@ -593,6 +593,7 @@
"@types/kbn__securitysolution-list-api": "link:bazel-bin/packages/kbn-securitysolution-list-api/npm_module_types",
"@types/kbn__securitysolution-list-constants": "link:bazel-bin/packages/kbn-securitysolution-list-constants/npm_module_types",
"@types/kbn__securitysolution-list-hooks": "link:bazel-bin/packages/kbn-securitysolution-list-hooks/npm_module_types",
"@types/kbn__securitysolution-list-utils": "link:bazel-bin/packages/kbn-securitysolution-list-utils/npm_module_types",
"@types/kbn__securitysolution-rules": "link:bazel-bin/packages/kbn-securitysolution-rules/npm_module_types",
"@types/kbn__securitysolution-t-grid": "link:bazel-bin/packages/kbn-securitysolution-t-grid/npm_module_types",
"@types/kbn__securitysolution-utils": "link:bazel-bin/packages/kbn-securitysolution-utils/npm_module_types",

View file

@ -110,6 +110,7 @@ filegroup(
"//packages/kbn-securitysolution-list-api:build_types",
"//packages/kbn-securitysolution-list-constants:build_types",
"//packages/kbn-securitysolution-list-hooks:build_types",
"//packages/kbn-securitysolution-list-utils:build_types",
"//packages/kbn-securitysolution-rules:build_types",
"//packages/kbn-securitysolution-t-grid:build_types",
"//packages/kbn-securitysolution-utils:build_types",

View file

@ -31,6 +31,7 @@ NPM_MODULE_EXTRA_FILES = [
]
RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/kbn-es-query",
"//packages/kbn-i18n",
"//packages/kbn-securitysolution-io-ts-list-types",
@ -40,22 +41,26 @@ RUNTIME_DEPS = [
"@npm//@testing-library/react",
"@npm//@testing-library/react-hooks",
"@npm//enzyme",
"@npm//lodash",
"@npm//moment",
"@npm//react",
]
TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"//packages/kbn-es-query:npm_module_types",
"//packages/kbn-i18n:npm_module_types",
"//packages/kbn-securitysolution-io-ts-list-types:npm_module_types",
"//packages/kbn-securitysolution-list-hooks:npm_module_types",
"//packages/kbn-securitysolution-list-utils",
"//packages/kbn-securitysolution-list-utils:npm_module_types",
"@npm//@elastic/eui",
"@npm//@testing-library/react",
"@npm//@testing-library/react-hooks",
"@npm//moment",
"@npm//tslib",
"@npm//@types/enzyme",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/react",
]

View file

@ -36,6 +36,7 @@ RUNTIME_DEPS = [
"//packages/kbn-securitysolution-list-utils",
"//packages/kbn-securitysolution-utils",
"@npm//@testing-library/react-hooks",
"@npm//fp-ts",
"@npm//react",
]
@ -44,12 +45,16 @@ TYPES_DEPS = [
"//packages/kbn-securitysolution-io-ts-list-types:npm_module_types",
"//packages/kbn-securitysolution-list-api:npm_module_types",
"//packages/kbn-securitysolution-list-constants:npm_module_types",
"//packages/kbn-securitysolution-list-utils",
"//packages/kbn-securitysolution-list-utils:npm_module_types",
"//packages/kbn-securitysolution-utils:npm_module_types",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/react",
"@npm//@types/testing-library__react-hooks",
"@npm//fp-ts",
# TODO: Remove once the bug on pkg_npm_types around transitive type deps got solved
"@npm//io-ts",
"@npm//tslib",
]
jsts_transpiler(

View file

@ -74,11 +74,11 @@ export const transformInput = (exceptionItem: ExceptionListItemSchema): Exceptio
export const addIdToExceptionItemEntries = (
exceptionItem: ExceptionListItemSchema
): ExceptionListItemSchema => {
const entries = exceptionItem.entries.map((entry) => {
const entries = exceptionItem.entries.map((entry: any) => {
if (entry.type === 'nested') {
return addIdToItem({
...entry,
entries: entry.entries.map((nestedEntry) => addIdToItem(nestedEntry)),
entries: entry.entries.map((nestedEntry: any) => addIdToItem(nestedEntry)),
});
} else {
return addIdToItem(entry);
@ -100,11 +100,11 @@ export const removeIdFromExceptionItemsEntries = <T extends { entries: EntriesAr
exceptionItem: T
): T => {
const { entries } = exceptionItem;
const entriesNoId = entries.map((entry) => {
const entriesNoId = entries.map((entry: any) => {
if (entry.type === 'nested') {
return removeIdFromItem({
...entry,
entries: entry.entries.map((nestedEntry) => removeIdFromItem(nestedEntry)),
entries: entry.entries.map((nestedEntry: any) => removeIdFromItem(nestedEntry)),
});
} else {
return removeIdFromItem<Entry>(entry);

View file

@ -203,7 +203,7 @@ export const useApi = (http: HttpStart): ExceptionsApi => {
// This data transform is UI specific and useful for UI concerns
// to compensate for the differences and preferences of how ReactJS might prefer
// data vs. how we want to model data. View `transformInput` for more details
exceptions: data.map((item) => transformInput(item)),
exceptions: data.map((item: any) => transformInput(item)),
pagination: {
page,
perPage,

View file

@ -120,7 +120,7 @@ export const useExceptionListItems = ({
// Please see `x-pack/plugins/lists/public/exceptions/transforms.ts` doc notes
// for context around the temporary `id`
const transformedData = data.map((item) => transformInput(item));
const transformedData = data.map((item: any) => transformInput(item));
if (isSubscribed) {
setPagination({

View file

@ -1,10 +1,10 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_BASE_NAME = "kbn-securitysolution-list-utils"
PKG_REQUIRE_NAME = "@kbn/securitysolution-list-utils"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__securitysolution-list-utils"
SOURCE_FILES = glob(
[
@ -51,6 +51,9 @@ TYPES_DEPS = [
"@npm//@types/lodash",
"@npm//@types/node",
"@npm//@types/uuid",
# TODO: Remove once the bug on pkg_npm_types around transitive type deps got solved
"@npm//io-ts",
"@npm//tslib",
]
jsts_transpiler(
@ -92,7 +95,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
@ -112,3 +115,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)
pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)
filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)

View file

@ -5,6 +5,5 @@
"license": "SSPL-1.0 OR Elastic License 2.0",
"browser": "./target_web/index.js",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"private": true
}

View file

@ -5969,6 +5969,10 @@
version "0.0.0"
uid ""
"@types/kbn__securitysolution-list-utils@link:bazel-bin/packages/kbn-securitysolution-list-utils/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__securitysolution-rules@link:bazel-bin/packages/kbn-securitysolution-rules/npm_module_types":
version "0.0.0"
uid ""