chore(NA): splits types from code on @kbn/securitysolution-io-ts-utils (#121677)

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

* chore(NA): fix package.json

* chore(NA): merge and solve conflicts with main

* chore(NA): remove any from types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2021-12-22 00:24:58 +00:00 committed by GitHub
parent 9ca9fe7577
commit 0a75d426b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 43 additions and 20 deletions

View file

@ -590,6 +590,7 @@
"@types/kbn__securitysolution-io-ts-alerting-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types/npm_module_types", "@types/kbn__securitysolution-io-ts-alerting-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-alerting-types/npm_module_types",
"@types/kbn__securitysolution-io-ts-list-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-list-types/npm_module_types", "@types/kbn__securitysolution-io-ts-list-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-list-types/npm_module_types",
"@types/kbn__securitysolution-io-ts-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-types/npm_module_types", "@types/kbn__securitysolution-io-ts-types": "link:bazel-bin/packages/kbn-securitysolution-io-ts-types/npm_module_types",
"@types/kbn__securitysolution-io-ts-utils": "link:bazel-bin/packages/kbn-securitysolution-io-ts-utils/npm_module_types",
"@types/kbn__securitysolution-list-api": "link:bazel-bin/packages/kbn-securitysolution-list-api/npm_module_types", "@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-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-hooks": "link:bazel-bin/packages/kbn-securitysolution-list-hooks/npm_module_types",

View file

@ -107,6 +107,7 @@ filegroup(
"//packages/kbn-securitysolution-io-ts-alerting-types:build_types", "//packages/kbn-securitysolution-io-ts-alerting-types:build_types",
"//packages/kbn-securitysolution-io-ts-list-types:build_types", "//packages/kbn-securitysolution-io-ts-list-types:build_types",
"//packages/kbn-securitysolution-io-ts-types:build_types", "//packages/kbn-securitysolution-io-ts-types:build_types",
"//packages/kbn-securitysolution-io-ts-utils:build_types",
"//packages/kbn-securitysolution-list-api:build_types", "//packages/kbn-securitysolution-list-api:build_types",
"//packages/kbn-securitysolution-list-constants:build_types", "//packages/kbn-securitysolution-list-constants:build_types",
"//packages/kbn-securitysolution-list-hooks:build_types", "//packages/kbn-securitysolution-list-hooks:build_types",

View file

@ -38,9 +38,10 @@ RUNTIME_DEPS = [
TYPES_DEPS = [ TYPES_DEPS = [
"//packages/kbn-securitysolution-io-ts-types:npm_module_types", "//packages/kbn-securitysolution-io-ts-types:npm_module_types",
"//packages/kbn-securitysolution-io-ts-utils", "//packages/kbn-securitysolution-io-ts-utils:npm_module_types",
"@npm//fp-ts", "@npm//fp-ts",
"@npm//io-ts", "@npm//io-ts",
"@npm//tslib",
"@npm//@types/jest", "@npm//@types/jest",
"@npm//@types/node", "@npm//@types/node",
"@npm//@types/uuid" "@npm//@types/uuid"

View file

@ -38,10 +38,11 @@ RUNTIME_DEPS = [
TYPES_DEPS = [ TYPES_DEPS = [
"//packages/kbn-securitysolution-io-ts-types:npm_module_types", "//packages/kbn-securitysolution-io-ts-types:npm_module_types",
"//packages/kbn-securitysolution-io-ts-utils", "//packages/kbn-securitysolution-io-ts-utils:npm_module_types",
"//packages/kbn-securitysolution-list-constants:npm_module_types", "//packages/kbn-securitysolution-list-constants:npm_module_types",
"@npm//fp-ts", "@npm//fp-ts",
"@npm//io-ts", "@npm//io-ts",
"@npm//tslib",
"@npm//@types/jest", "@npm//@types/jest",
"@npm//@types/node", "@npm//@types/node",
] ]

View file

@ -36,9 +36,10 @@ RUNTIME_DEPS = [
] ]
TYPES_DEPS = [ TYPES_DEPS = [
"//packages/kbn-securitysolution-io-ts-utils", "//packages/kbn-securitysolution-io-ts-utils:npm_module_types",
"@npm//fp-ts", "@npm//fp-ts",
"@npm//io-ts", "@npm//io-ts",
"@npm//tslib",
"@npm//@types/jest", "@npm//@types/jest",
"@npm//@types/node", "@npm//@types/node",
"@npm//@types/uuid" "@npm//@types/uuid"

View file

@ -1,9 +1,10 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project") load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm") load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler") load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_BASE_NAME = "kbn-securitysolution-io-ts-utils" PKG_BASE_NAME = "kbn-securitysolution-io-ts-utils"
PKG_REQUIRE_NAME = "@kbn/securitysolution-io-ts-utils" PKG_REQUIRE_NAME = "@kbn/securitysolution-io-ts-utils"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__securitysolution-io-ts-utils"
SOURCE_FILES = glob( SOURCE_FILES = glob(
[ [
@ -86,7 +87,7 @@ ts_project(
js_library( js_library(
name = PKG_BASE_NAME, name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES, 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, package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
@ -105,3 +106,20 @@ filegroup(
], ],
visibility = ["//visibility:public"], 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", "license": "SSPL-1.0 OR Elastic License 2.0",
"browser": "./target_web/index.js", "browser": "./target_web/index.js",
"main": "./target_node/index.js", "main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"private": true "private": true
} }

View file

@ -38,10 +38,11 @@ RUNTIME_DEPS = [
TYPES_DEPS = [ TYPES_DEPS = [
"//packages/kbn-securitysolution-io-ts-list-types:npm_module_types", "//packages/kbn-securitysolution-io-ts-list-types:npm_module_types",
"//packages/kbn-securitysolution-io-ts-utils", "//packages/kbn-securitysolution-io-ts-utils:npm_module_types",
"//packages/kbn-securitysolution-list-constants:npm_module_types", "//packages/kbn-securitysolution-list-constants:npm_module_types",
"@npm//fp-ts", "@npm//fp-ts",
"@npm//io-ts", "@npm//io-ts",
"@npm//tslib",
"@npm//@types/jest", "@npm//@types/jest",
"@npm//@types/node", "@npm//@types/node",
] ]

View file

@ -52,8 +52,6 @@ TYPES_DEPS = [
"@npm//@types/react", "@npm//@types/react",
"@npm//@types/testing-library__react-hooks", "@npm//@types/testing-library__react-hooks",
"@npm//fp-ts", "@npm//fp-ts",
# TODO: Remove once the bug on pkg_npm_types around transitive type deps got solved
"@npm//io-ts",
"@npm//tslib", "@npm//tslib",
] ]

View file

@ -74,11 +74,11 @@ export const transformInput = (exceptionItem: ExceptionListItemSchema): Exceptio
export const addIdToExceptionItemEntries = ( export const addIdToExceptionItemEntries = (
exceptionItem: ExceptionListItemSchema exceptionItem: ExceptionListItemSchema
): ExceptionListItemSchema => { ): ExceptionListItemSchema => {
const entries = exceptionItem.entries.map((entry: any) => { const entries = exceptionItem.entries.map((entry) => {
if (entry.type === 'nested') { if (entry.type === 'nested') {
return addIdToItem({ return addIdToItem({
...entry, ...entry,
entries: entry.entries.map((nestedEntry: any) => addIdToItem(nestedEntry)), entries: entry.entries.map((nestedEntry) => addIdToItem(nestedEntry)),
}); });
} else { } else {
return addIdToItem(entry); return addIdToItem(entry);
@ -100,11 +100,11 @@ export const removeIdFromExceptionItemsEntries = <T extends { entries: EntriesAr
exceptionItem: T exceptionItem: T
): T => { ): T => {
const { entries } = exceptionItem; const { entries } = exceptionItem;
const entriesNoId = entries.map((entry: any) => { const entriesNoId = entries.map((entry) => {
if (entry.type === 'nested') { if (entry.type === 'nested') {
return removeIdFromItem({ return removeIdFromItem({
...entry, ...entry,
entries: entry.entries.map((nestedEntry: any) => removeIdFromItem(nestedEntry)), entries: entry.entries.map((nestedEntry) => removeIdFromItem(nestedEntry)),
}); });
} else { } else {
return removeIdFromItem<Entry>(entry); 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 // This data transform is UI specific and useful for UI concerns
// to compensate for the differences and preferences of how ReactJS might prefer // 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 // data vs. how we want to model data. View `transformInput` for more details
exceptions: data.map((item: any) => transformInput(item)), exceptions: data.map((item) => transformInput(item)),
pagination: { pagination: {
page, page,
perPage, perPage,

View file

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

View file

@ -43,7 +43,7 @@ TYPES_DEPS = [
"//packages/kbn-es-query:npm_module_types", "//packages/kbn-es-query:npm_module_types",
"//packages/kbn-i18n:npm_module_types", "//packages/kbn-i18n:npm_module_types",
"//packages/kbn-securitysolution-io-ts-list-types:npm_module_types", "//packages/kbn-securitysolution-io-ts-list-types:npm_module_types",
"//packages/kbn-securitysolution-io-ts-utils", "//packages/kbn-securitysolution-io-ts-utils:npm_module_types",
"//packages/kbn-securitysolution-list-constants:npm_module_types", "//packages/kbn-securitysolution-list-constants:npm_module_types",
"//packages/kbn-securitysolution-utils:npm_module_types", "//packages/kbn-securitysolution-utils:npm_module_types",
"@npm//@elastic/elasticsearch", "@npm//@elastic/elasticsearch",
@ -51,8 +51,6 @@ TYPES_DEPS = [
"@npm//@types/lodash", "@npm//@types/lodash",
"@npm//@types/node", "@npm//@types/node",
"@npm//@types/uuid", "@npm//@types/uuid",
# TODO: Remove once the bug on pkg_npm_types around transitive type deps got solved
"@npm//io-ts",
"@npm//tslib", "@npm//tslib",
] ]

View file

@ -5957,6 +5957,10 @@
version "0.0.0" version "0.0.0"
uid "" uid ""
"@types/kbn__securitysolution-io-ts-utils@link:bazel-bin/packages/kbn-securitysolution-io-ts-utils/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__securitysolution-list-api@link:bazel-bin/packages/kbn-securitysolution-list-api/npm_module_types": "@types/kbn__securitysolution-list-api@link:bazel-bin/packages/kbn-securitysolution-list-api/npm_module_types":
version "0.0.0" version "0.0.0"
uid "" uid ""