chore(NA): splits types from code on @kbn/logging (#124688)

* chore(NA): splits types from code on @kbn/test

* chore(NA): create new @kbn/test-jest-helpers

* chore(NA): move wrong files into @kbn/test

* chore(NA): remove @kbn/test/jest references

* chore(NA): splits types from code on @kbn/logging

* chore(NA): import type from new @kbn/logging-mocks pkg

* chore(NA): missing deps on bazel build files

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2022-02-07 13:46:50 +00:00 committed by GitHub
parent 807c625ea9
commit a926a57e03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 206 additions and 41 deletions

1
.github/CODEOWNERS vendored
View file

@ -268,6 +268,7 @@
/packages/kbn-std/ @elastic/kibana-core
/packages/kbn-config/ @elastic/kibana-core
/packages/kbn-logging/ @elastic/kibana-core
/packages/kbn-logging-mocks/ @elastic/kibana-core
/packages/kbn-http-tools/ @elastic/kibana-core
/src/plugins/saved_objects_management/ @elastic/kibana-core
/src/dev/run_check_published_api_changes.ts @elastic/kibana-core

View file

@ -144,6 +144,7 @@
"@kbn/interpreter": "link:bazel-bin/packages/kbn-interpreter",
"@kbn/io-ts-utils": "link:bazel-bin/packages/kbn-io-ts-utils",
"@kbn/logging": "link:bazel-bin/packages/kbn-logging",
"@kbn/logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks",
"@kbn/mapbox-gl": "link:bazel-bin/packages/kbn-mapbox-gl",
"@kbn/monaco": "link:bazel-bin/packages/kbn-monaco",
"@kbn/react-field": "link:bazel-bin/packages/kbn-react-field",
@ -586,6 +587,8 @@
"@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__logging": "link:bazel-bin/packages/kbn-logging/npm_module_types",
"@types/kbn__logging-mocks": "link:bazel-bin/packages/kbn-logging-mocks/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",

View file

@ -33,6 +33,7 @@ filegroup(
"//packages/kbn-interpreter:build",
"//packages/kbn-io-ts-utils:build",
"//packages/kbn-logging:build",
"//packages/kbn-logging-mocks:build",
"//packages/kbn-mapbox-gl:build",
"//packages/kbn-monaco:build",
"//packages/kbn-optimizer:build",
@ -101,6 +102,8 @@ filegroup(
"//packages/kbn-i18n-react:build_types",
"//packages/kbn-interpreter:build_types",
"//packages/kbn-io-ts-utils:build_types",
"//packages/kbn-logging:build_types",
"//packages/kbn-logging-mocks:build_types",
"//packages/kbn-mapbox-gl:build_types",
"//packages/kbn-monaco:build_types",
"//packages/kbn-optimizer:build_types",

View file

@ -51,7 +51,7 @@ TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-dev-utils:npm_module_types",
"//packages/kbn-logging",
"//packages/kbn-logging:npm_module_types",
"//packages/kbn-optimizer:npm_module_types",
"//packages/kbn-server-http-tools:npm_module_types",
"//packages/kbn-std:npm_module_types",

View file

@ -34,6 +34,7 @@ RUNTIME_DEPS = [
"//packages/elastic-safer-lodash-set",
"//packages/kbn-config-schema",
"//packages/kbn-logging",
"//packages/kbn-logging-mocks",
"//packages/kbn-std",
"//packages/kbn-utility-types",
"//packages/kbn-i18n",
@ -47,7 +48,8 @@ RUNTIME_DEPS = [
TYPES_DEPS = [
"//packages/elastic-safer-lodash-set:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-logging",
"//packages/kbn-logging:npm_module_types",
"//packages/kbn-logging-mocks:npm_module_types",
"//packages/kbn-std:npm_module_types",
"//packages/kbn-utility-types:npm_module_types",
"//packages/kbn-i18n:npm_module_types",

View file

@ -13,7 +13,7 @@ import { mockApplyDeprecations, mockedChangedPaths } from './config_service.test
import { rawConfigServiceMock } from './raw/raw_config_service.mock';
import { schema } from '@kbn/config-schema';
import { MockedLogger, loggerMock } from '@kbn/logging/mocks';
import { MockedLogger, loggerMock } from '@kbn/logging-mocks';
import type { ConfigDeprecationContext } from './deprecation';
import { ConfigService, Env, RawPackageInfo } from '.';

View file

@ -0,0 +1,106 @@
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-logging-mocks"
PKG_REQUIRE_NAME = "@kbn/logging-mocks"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__logging-mocks"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*"
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"//packages/kbn-logging"
]
TYPES_DEPS = [
"//packages/kbn-logging:npm_module_types",
"@npm//@types/jest",
"@npm//@types/node",
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node"],
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"],
)
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

@ -0,0 +1,7 @@
{
"name": "@kbn/logging-mocks",
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target_node/index.js"
}

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { Logger } from '../logger';
import { Logger } from '@kbn/logging';
export type MockedLogger = jest.Mocked<Logger> & { context: string[] };

View file

@ -0,0 +1,20 @@
{
"extends": "../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/kbn-logging-mocks/src",
"stripInternal": false,
"types": [
"jest",
"node"
]
},
"include": [
"src/**/*.ts"
]
}

View file

@ -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-logging"
PKG_REQUIRE_NAME = "@kbn/logging"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__logging"
SOURCE_FILES = glob(
[
@ -22,7 +23,6 @@ filegroup(
)
NPM_MODULE_EXTRA_FILES = [
"mocks/package.json",
"package.json",
"README.md"
]
@ -69,7 +69,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"],
)
@ -88,3 +88,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

@ -1,5 +0,0 @@
{
"private": true,
"main": "../target_node/mocks/index.js",
"types": "../target_types/mocks/index.d.ts"
}

View file

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

View file

@ -17,7 +17,7 @@ import { loggingSystemMock } from '../../logging/logging_system.mock';
import { createHttpServer } from '../test_utils';
import { HttpService } from '../http_service';
import { Router } from '../router';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
let server: HttpService;
let logger: ReturnType<typeof loggingSystemMock.create>;

View file

@ -6,5 +6,5 @@
* Side Public License, v 1.
*/
export { loggerMock } from '@kbn/logging/mocks';
export type { MockedLogger } from '@kbn/logging/mocks';
export { loggerMock } from '@kbn/logging-mocks';
export type { MockedLogger } from '@kbn/logging-mocks';

View file

@ -7,7 +7,7 @@
*/
import mockFs from 'mock-fs';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { OsCgroupMetricsCollector } from './cgroup';
describe('OsCgroupMetricsCollector', () => {

View file

@ -8,7 +8,7 @@
jest.mock('getos', () => (cb: Function) => cb(null, { dist: 'distrib', release: 'release' }));
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import os from 'os';
import { cgroupCollectorMock } from './os.test.mocks';
import { OsMetricsCollector } from './os';

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import {
mockOsCollector,
mockProcessCollector,

View file

@ -7,7 +7,7 @@
*/
import { CustomIntegrationRegistry } from './custom_integration_registry';
import { loggerMock, MockedLogger } from '@kbn/logging/mocks';
import { loggerMock, MockedLogger } from '@kbn/logging-mocks';
import { IntegrationCategory, CustomIntegration } from '../common';
describe('CustomIntegrationsRegistry', () => {

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { MockedLogger, loggerMock } from '@kbn/logging/mocks';
import { MockedLogger, loggerMock } from '@kbn/logging-mocks';
import { TaskRunnerFactory } from '../task_runner';
import { RuleTypeRegistry, ConstructorOptions } from '../rule_type_registry';
import { taskManagerMock } from '../../../task_manager/server/mocks';

View file

@ -25,7 +25,7 @@ import {
SavedObjectsUpdateResponse,
} from 'kibana/server';
import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { CONNECTOR_ID_REFERENCE_NAME } from '../../common/constants';
import { getNoneCaseConnector } from '../../common/utils';
import { CasesService } from '.';

View file

@ -22,7 +22,7 @@ import {
SavedObjectsUpdateResponse,
} from 'kibana/server';
import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { CaseConfigureService } from '.';
import { ESCasesConfigureAttributes } from './types';
import { CONNECTOR_ID_REFERENCE_NAME } from '../../common/constants';

View file

@ -6,7 +6,7 @@
*/
import { get } from 'lodash';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { savedObjectsClientMock } from '../../../../../../src/core/server/mocks';
import { SavedObject, SavedObjectsFindResponse, SavedObjectsFindResult } from 'kibana/server';
import { ACTION_SAVED_OBJECT_TYPE } from '../../../../actions/server';

View file

@ -8,7 +8,7 @@
jest.mock('timers/promises');
import { setTimeout } from 'timers/promises';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { errors as EsErrors } from '@elastic/elasticsearch';
import { retryTransientEsErrors } from './retry';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import type { Logger } from 'src/core/server';
import { appContextService } from '../../../app_context';

View file

@ -6,7 +6,7 @@
*/
import { elasticsearchServiceMock } from 'src/core/server/mocks';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { createAppContextStartContractMock } from '../../../../mocks';
import { appContextService } from '../../../../services';

View file

@ -9,7 +9,7 @@ import { readFileSync } from 'fs';
import path from 'path';
import { safeLoad } from 'js-yaml';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { elasticsearchServiceMock } from 'src/core/server/mocks';
import { createAppContextStartContractMock } from '../../../../mocks';

View file

@ -21,7 +21,7 @@ jest.mock('./common', () => {
import { errors } from '@elastic/elasticsearch';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import type { ElasticsearchClient, SavedObject, SavedObjectsClientContract } from 'kibana/server';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { ElasticsearchAssetType } from '../../../../types';
import type { Installation, RegistryPackage } from '../../../../types';

View file

@ -7,7 +7,7 @@
jest.mock('../../routes/security');
import type { MockedLogger } from '@kbn/logging/target_types/mocks';
import type { MockedLogger } from '@kbn/logging-mocks';
import type {
ElasticsearchClient,

View file

@ -7,7 +7,7 @@
import type { SavedObjectsClientContract, ElasticsearchClient } from 'src/core/server';
import { savedObjectsClientMock, elasticsearchServiceMock } from 'src/core/server/mocks';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { DEFAULT_SPACE_ID } from '../../../../../spaces/common/constants';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { MockedLogger, loggerMock } from '@kbn/logging/mocks';
import { MockedLogger, loggerMock } from '@kbn/logging-mocks';
import { httpServerMock } from '../../../../../../src/core/server/mocks';
import { ExceptionListClient } from '../exception_lists/exception_list_client';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { CreateExceptionListItemOptions } from '../exception_lists/exception_list_client_types';
import { getCreateExceptionListItemOptionsMock } from '../exception_lists/exception_list_client.mock';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { CollectorFetchContext } from 'src/plugins/usage_collection/server';
import {
Collector,

View file

@ -6,7 +6,7 @@
*/
import { ResourceInstaller } from './resource_installer';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { AlertConsumers } from '@kbn/rule-data-utils';
import { Dataset } from './index_options';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { RuleDataService } from './rule_data_plugin_service';
import { elasticsearchServiceMock } from 'src/core/server/mocks';
import { AlertConsumers } from '@kbn/rule-data-utils';

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import {
ALERT_INSTANCE_ID,
ALERT_RULE_CATEGORY,

View file

@ -13,7 +13,7 @@ import {
ALERT_STATUS_RECOVERED,
ALERT_UUID,
} from '@kbn/rule-data-utils';
import { loggerMock } from '@kbn/logging/mocks';
import { loggerMock } from '@kbn/logging-mocks';
import { castArray, omit } from 'lodash';
import { RuleDataClient } from '../rule_data_client';
import { createRuleDataClientMock } from '../rule_data_client/rule_data_client.mock';

View file

@ -3826,6 +3826,10 @@
version "0.0.0"
uid ""
"@kbn/logging-mocks@link:bazel-bin/packages/kbn-logging-mocks":
version "0.0.0"
uid ""
"@kbn/logging@link:bazel-bin/packages/kbn-logging":
version "0.0.0"
uid ""
@ -6798,6 +6802,14 @@
version "0.0.0"
uid ""
"@types/kbn__logging-mocks@link:bazel-bin/packages/kbn-logging-mocks/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__logging@link:bazel-bin/packages/kbn-logging/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 ""