Skip to content

Commit

Permalink
chore(NA): splits types from code on @kbn/io-ts-utils (#123431)
Browse files Browse the repository at this point in the history
* chore(NA): splits types from code on @kbn/io-ts-utils

* chore(NA): missing import keys

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
mistic and kibanamachine authored Jan 21, 2022
1 parent 7255901 commit 735948d
Show file tree
Hide file tree
Showing 40 changed files with 52 additions and 92 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ const RESTRICTED_IMPORTS = [
name: 'react-use',
message: 'Please use react-use/lib/{method} instead.',
},
{
name: '@kbn/io-ts-utils',
message: `Import directly from @kbn/io-ts-utils/{method} submodules`,
},
];

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
"@types/kbn__interpreter": "link:bazel-bin/packages/kbn-interpreter/npm_module_types",
"@types/kbn__io-ts-utils": "link:bazel-bin/packages/kbn-io-ts-utils/npm_module_types",
"@types/kbn__mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types",
"@types/kbn__monaco": "link:bazel-bin/packages/kbn-monaco/npm_module_types",
"@types/kbn__optimizer": "link:bazel-bin/packages/kbn-optimizer/npm_module_types",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ filegroup(
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
"//packages/kbn-interpreter:build_types",
"//packages/kbn-io-ts-utils:build_types",
"//packages/kbn-mapbox-gl:build_types",
"//packages/kbn-monaco:build_types",
"//packages/kbn-optimizer:build_types",
Expand Down
37 changes: 22 additions & 15 deletions packages/kbn-io-ts-utils/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +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-io-ts-utils"
PKG_REQUIRE_NAME = "@kbn/io-ts-utils"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__io-ts-utils"

SOURCE_FILES = glob(
[
Expand All @@ -23,17 +24,6 @@ filegroup(

NPM_MODULE_EXTRA_FILES = [
"package.json",
"deep_exact_rt/package.json",
"iso_to_epoch_rt/package.json",
"json_rt/package.json",
"merge_rt/package.json",
"non_empty_string_rt/package.json",
"parseable_types/package.json",
"props_to_schema/package.json",
"strict_keys_rt/package.json",
"to_boolean_rt/package.json",
"to_json_schema/package.json",
"to_number_rt/package.json",
]

RUNTIME_DEPS = [
Expand Down Expand Up @@ -86,7 +76,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand All @@ -105,3 +95,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"],
)
4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/deep_exact_rt/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/iso_to_epoch_rt/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/json_rt/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/merge_rt/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/non_empty_string_rt/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/kbn-io-ts-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@kbn/io-ts-utils",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
Expand Down
4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/parseable_types/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/props_to_schema/package.json

This file was deleted.

2 changes: 2 additions & 0 deletions packages/kbn-io-ts-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Side Public License, v 1.
*/

export type { NonEmptyStringBrand } from './non_empty_string_rt';

export { deepExactRt } from './deep_exact_rt';
export { jsonRt } from './json_rt';
export { mergeRt } from './merge_rt';
Expand Down
4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/strict_keys_rt/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/to_boolean_rt/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/to_json_schema/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/kbn-io-ts-utils/to_number_rt/package.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/kbn-server-route-repository/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-io-ts-utils",
"//packages/kbn-io-ts-utils:npm_module_types",
"@npm//@hapi/boom",
"@npm//fp-ts",
"@npm//utility-types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { jsonRt } from '@kbn/io-ts-utils';
import * as t from 'io-ts';
import { decodeRequestParams } from './decode_request_params';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { omitBy, isPlainObject, isEmpty } from 'lodash';
import { isLeft } from 'fp-ts/lib/Either';
import { PathReporter } from 'io-ts/lib/PathReporter';
import Boom from '@hapi/boom';
import { strictKeysRt } from '@kbn/io-ts-utils/strict_keys_rt';
import { strictKeysRt } from '@kbn/io-ts-utils';
import { RouteParamsRT } from './typings';

interface KibanaRequestParams {
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-typed-react-router-config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/kbn-io-ts-utils",
"//packages/kbn-io-ts-utils:npm_module_types",
"@npm//query-string",
"@npm//utility-types",
"@npm//@types/jest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import React from 'react';
import * as t from 'io-ts';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { toNumberRt } from '@kbn/io-ts-utils';
import { createRouter } from './create_router';
import { createMemoryHistory } from 'history';
import { route } from './route';
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-typed-react-router-config/src/create_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
} from 'react-router-config';
import qs from 'query-string';
import { findLastIndex, merge, compact } from 'lodash';
import { mergeRt } from '@kbn/io-ts-utils/merge_rt';
import { deepExactRt } from '@kbn/io-ts-utils/deep_exact_rt';
import { deepExactRt, mergeRt } from '@kbn/io-ts-utils';
import { FlattenRoutesOf, Route, Router } from './types';

function toReactRouterPath(path: string) {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/common/environment_rt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/
import * as t from 'io-ts';
import { nonEmptyStringRt } from '@kbn/io-ts-utils/non_empty_string_rt';
import { nonEmptyStringRt } from '@kbn/io-ts-utils';
import {
ENVIRONMENT_ALL,
ENVIRONMENT_NOT_DEFINED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n';
import { Outlet } from '@kbn/typed-react-router-config';
import * as t from 'io-ts';
import React from 'react';
import { toBooleanRt } from '@kbn/io-ts-utils/to_boolean_rt';
import { toBooleanRt } from '@kbn/io-ts-utils';
import { RedirectTo } from '../redirect_to';
import { comparisonTypeRt } from '../../../../common/runtime_types/comparison_type_rt';
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as t from 'io-ts';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { Outlet } from '@kbn/typed-react-router-config';
import { toBooleanRt } from '@kbn/io-ts-utils/to_boolean_rt';
import { toBooleanRt } from '@kbn/io-ts-utils';
import { comparisonTypeRt } from '../../../../common/runtime_types/comparison_type_rt';
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';
import { environmentRt } from '../../../../common/environment_rt';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { jsonRt } from '@kbn/io-ts-utils';
import { createServerRouteRepository } from '@kbn/server-route-repository';
import { ServerRoute } from '@kbn/server-route-repository';
import * as t from 'io-ts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
parseEndpoint,
routeValidationObject,
} from '@kbn/server-route-repository';
import { mergeRt } from '@kbn/io-ts-utils/merge_rt';
import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { jsonRt, mergeRt } from '@kbn/io-ts-utils';
import { pickKeys } from '../../../common/utils/pick_keys';
import { APMRouteHandlerResources, TelemetryUsageCounter } from '../typings';
import type { ApmPluginRequestHandlerContext } from '../typings';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/backends/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as t from 'io-ts';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { toNumberRt } from '@kbn/io-ts-utils';
import { setupRequest } from '../../lib/helpers/setup_request';
import {
environmentRt,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/correlations/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as t from 'io-ts';
import Boom from '@hapi/boom';

import { i18n } from '@kbn/i18n';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { toNumberRt } from '@kbn/io-ts-utils';

import { isActivePlatinumLicense } from '../../../common/license_check';

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/default_api_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as t from 'io-ts';
import { isoToEpochRt } from '@kbn/io-ts-utils/iso_to_epoch_rt';
import { isoToEpochRt } from '@kbn/io-ts-utils';

export { environmentRt } from '../../common/environment_rt';

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/apm/server/routes/errors/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { jsonRt, toNumberRt } from '@kbn/io-ts-utils';
import * as t from 'io-ts';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import { getErrorDistribution } from './distribution/get_distribution';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as t from 'io-ts';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { toNumberRt } from '@kbn/io-ts-utils';
import { getOverallLatencyDistribution } from './get_overall_latency_distribution';
import { setupRequest } from '../../lib/helpers/setup_request';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as t from 'io-ts';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { toNumberRt } from '@kbn/io-ts-utils';
import { setupRequest } from '../../lib/helpers/setup_request';
import { getServiceCount } from './get_service_count';
import { getTransactionsPerMinute } from './get_transactions_per_minute';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/rum_client/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import * as t from 'io-ts';
import { Logger } from 'kibana/server';
import { isoToEpochRt } from '@kbn/io-ts-utils/iso_to_epoch_rt';
import { isoToEpochRt } from '@kbn/io-ts-utils';
import { setupRequest, Setup } from '../../lib/helpers/setup_request';
import { getClientMetrics } from './get_client_metrics';
import { getJSErrors } from './get_js_errors';
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/apm/server/routes/services/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
*/

import Boom from '@hapi/boom';
import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { isoToEpochRt } from '@kbn/io-ts-utils/iso_to_epoch_rt';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { isoToEpochRt, jsonRt, toNumberRt } from '@kbn/io-ts-utils';
import * as t from 'io-ts';
import { uniq } from 'lodash';
import { latencyAggregationTypeRt } from '../../../common/latency_aggregation_types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import * as t from 'io-ts';
import Boom from '@hapi/boom';
import { toBooleanRt } from '@kbn/io-ts-utils/to_boolean_rt';
import { toBooleanRt } from '@kbn/io-ts-utils';
import { maxSuggestions } from '../../../../../observability/common';
import { setupRequest } from '../../../lib/helpers/setup_request';
import { getServiceNames } from './get_service_names';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/source_maps/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import Boom from '@hapi/boom';
import * as t from 'io-ts';
import { SavedObjectsClientContract } from 'kibana/server';
import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { jsonRt } from '@kbn/io-ts-utils';
import {
createApmArtifact,
deleteApmArtifact,
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/apm/server/routes/transactions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
* 2.0.
*/

import { jsonRt } from '@kbn/io-ts-utils/json_rt';
import { toNumberRt } from '@kbn/io-ts-utils/to_number_rt';
import { jsonRt, toNumberRt } from '@kbn/io-ts-utils';
import * as t from 'io-ts';
import {
LatencyAggregationType,
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5864,6 +5864,10 @@
version "0.0.0"
uid ""

"@types/kbn__io-ts-utils@link:bazel-bin/packages/kbn-io-ts-utils/npm_module_types":
version "0.0.0"
uid ""

"@types/kbn__mapbox-gl@link:bazel-bin/packages/kbn-mapbox-gl/npm_module_types":
version "0.0.0"
uid ""
Expand Down

0 comments on commit 735948d

Please sign in to comment.