Skip to content

Commit

Permalink
Migrate server-side status service to packages (#140067)
Browse files Browse the repository at this point in the history
* create empty packages

* start moving things to packages

* move status types to common package

* create internal common package

* start adapting usages

* more import fixes

* fix more usages

* some test file fixes

* fix some more usages

* fix test_utils import

* fix mixed import

* fix test imports

* updating READMEs

* explicit export of service setup deps

* add jsonc files to new packages

* [CI] Auto-commit changed files from 'node scripts/generate codeowners'

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
pgayvallet and kibanamachine authored Sep 9, 2022
1 parent 0ade1b1 commit 12466d8
Show file tree
Hide file tree
Showing 96 changed files with 1,172 additions and 147 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,11 @@ packages/core/saved-objects/core-saved-objects-server @elastic/kibana-core
packages/core/saved-objects/core-saved-objects-server-internal @elastic/kibana-core
packages/core/saved-objects/core-saved-objects-server-mocks @elastic/kibana-core
packages/core/saved-objects/core-saved-objects-utils-server @elastic/kibana-core
packages/core/status/core-status-common @elastic/kibana-core
packages/core/status/core-status-common-internal @elastic/kibana-core
packages/core/status/core-status-server @elastic/kibana-core
packages/core/status/core-status-server-internal @elastic/kibana-core
packages/core/status/core-status-server-mocks @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-deprecations-getters @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-http-setup-browser @elastic/kibana-core
packages/core/theme/core-theme-browser @elastic/kibana-core
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@
"@kbn/core-saved-objects-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server-internal",
"@kbn/core-saved-objects-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server-mocks",
"@kbn/core-saved-objects-utils-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-utils-server",
"@kbn/core-status-common": "link:bazel-bin/packages/core/status/core-status-common",
"@kbn/core-status-common-internal": "link:bazel-bin/packages/core/status/core-status-common-internal",
"@kbn/core-status-server": "link:bazel-bin/packages/core/status/core-status-server",
"@kbn/core-status-server-internal": "link:bazel-bin/packages/core/status/core-status-server-internal",
"@kbn/core-status-server-mocks": "link:bazel-bin/packages/core/status/core-status-server-mocks",
"@kbn/core-test-helpers-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters",
"@kbn/core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser",
"@kbn/core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser",
Expand Down Expand Up @@ -956,6 +961,11 @@
"@types/kbn__core-saved-objects-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server-mocks/npm_module_types",
"@types/kbn__core-saved-objects-utils-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-utils-server/npm_module_types",
"@types/kbn__core-server-internal-base": "link:bazel-bin/packages/core/server/internal-base/npm_module_types",
"@types/kbn__core-status-common": "link:bazel-bin/packages/core/status/core-status-common/npm_module_types",
"@types/kbn__core-status-common-internal": "link:bazel-bin/packages/core/status/core-status-common-internal/npm_module_types",
"@types/kbn__core-status-server": "link:bazel-bin/packages/core/status/core-status-server/npm_module_types",
"@types/kbn__core-status-server-internal": "link:bazel-bin/packages/core/status/core-status-server-internal/npm_module_types",
"@types/kbn__core-status-server-mocks": "link:bazel-bin/packages/core/status/core-status-server-mocks/npm_module_types",
"@types/kbn__core-test-helpers-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters/npm_module_types",
"@types/kbn__core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser/npm_module_types",
"@types/kbn__core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser/npm_module_types",
Expand Down
10 changes: 10 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ filegroup(
"//packages/core/saved-objects/core-saved-objects-server-internal:build",
"//packages/core/saved-objects/core-saved-objects-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-utils-server:build",
"//packages/core/status/core-status-common:build",
"//packages/core/status/core-status-common-internal:build",
"//packages/core/status/core-status-server:build",
"//packages/core/status/core-status-server-internal:build",
"//packages/core/status/core-status-server-mocks:build",
"//packages/core/test-helpers/core-test-helpers-deprecations-getters:build",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build",
"//packages/core/theme/core-theme-browser:build",
Expand Down Expand Up @@ -438,6 +443,11 @@ filegroup(
"//packages/core/saved-objects/core-saved-objects-server-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-utils-server:build_types",
"//packages/core/status/core-status-common:build_types",
"//packages/core/status/core-status-common-internal:build_types",
"//packages/core/status/core-status-server:build_types",
"//packages/core/status/core-status-server-internal:build_types",
"//packages/core/status/core-status-server-mocks:build_types",
"//packages/core/test-helpers/core-test-helpers-deprecations-getters:build_types",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build_types",
"//packages/core/theme/core-theme-browser:build_types",
Expand Down
2 changes: 0 additions & 2 deletions packages/core/base/core-base-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@
export type { PluginOpaqueId, PluginName, DiscoveredPlugin } from './src/plugins';
export { PluginType } from './src/plugins';
export { EUI_STYLES_GLOBAL } from './src/eui';
export { ServiceStatusLevels } from './src/service_status';
export type { ServiceStatus, ServiceStatusLevel } from './src/service_status';
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ TYPES_DEPS = [
"//packages/kbn-config-schema:npm_module_types",
"//packages/core/base/core-base-common:npm_module_types",
"//packages/core/base/core-base-server-internal:npm_module_types",
"//packages/core/status/core-status-common:npm_module_types",
"//packages/core/analytics/core-analytics-server:npm_module_types",
"//packages/core/http/core-http-server:npm_module_types",
"//packages/core/http/core-http-server-internal:npm_module_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { take } from 'rxjs/operators';
import { Subject, of } from 'rxjs';

import { ServiceStatusLevels, ServiceStatusLevel, ServiceStatus } from '@kbn/core-base-common';
import { ServiceStatusLevels, ServiceStatusLevel, ServiceStatus } from '@kbn/core-status-common';
import { calculateStatus$ } from './status';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { Observable, merge, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ServiceStatus, ServiceStatusLevels } from '@kbn/core-base-common';
import { ServiceStatus, ServiceStatusLevels } from '@kbn/core-status-common';
import { ElasticsearchStatusMeta } from './types';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
ElasticsearchServiceStart,
ElasticsearchServiceSetup,
} from '@kbn/core-elasticsearch-server';
import type { ServiceStatus } from '@kbn/core-base-common';
import type { ServiceStatus } from '@kbn/core-status-common';
import type { NodesVersionCompatibility, NodeInfo } from './version_check/ensure_es_version';
import type { ClusterInfo } from './get_cluster_info';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TYPES_DEPS = [
"@npm//@types/jest",
"@npm//rxjs",
"//packages/kbn-utility-types:npm_module_types",
"//packages/core/base/core-base-common:npm_module_types",
"//packages/core/status/core-status-common:npm_module_types",
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types",
"//packages/core/elasticsearch/core-elasticsearch-client-server-mocks:npm_module_types",
"//packages/core/elasticsearch/core-elasticsearch-server-internal:npm_module_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {
NodesVersionCompatibility,
ClusterInfo,
} from '@kbn/core-elasticsearch-server-internal';
import { type ServiceStatus, ServiceStatusLevels } from '@kbn/core-base-common';
import { type ServiceStatus, ServiceStatusLevels } from '@kbn/core-status-common';

type MockedElasticSearchServicePreboot = jest.Mocked<ElasticsearchServicePreboot>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ RUNTIME_DEPS = [
"@npm//json-stable-stringify",
"//packages/kbn-config-schema",
"//packages/core/base/core-base-common",
"//packages/core/status/core-status-common",
"//packages/core/saved-objects/core-saved-objects-base-server-internal",
"//packages/core/saved-objects/core-saved-objects-api-server-internal",
"//packages/core/saved-objects/core-saved-objects-migration-server-internal",
Expand All @@ -52,6 +53,7 @@ TYPES_DEPS = [
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-logging:npm_module_types",
"//packages/core/base/core-base-common:npm_module_types",
"//packages/core/status/core-status-common:npm_module_types",
"//packages/core/deprecations/core-deprecations-common:npm_module_types",
"//packages/core/http/core-http-server:npm_module_types",
"//packages/core/http/core-http-server-internal:npm_module_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { Subject, Observable, firstValueFrom } from 'rxjs';
import { filter, take, switchMap } from 'rxjs/operators';
import type { Logger } from '@kbn/logging';
import type { ServiceStatus } from '@kbn/core-base-common';
import type { ServiceStatus } from '@kbn/core-status-common';
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
import type { DocLinksServiceStart } from '@kbn/core-doc-links-server';
import type { KibanaRequest } from '@kbn/core-http-server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { of, Observable } from 'rxjs';
import { type ServiceStatus, ServiceStatusLevels } from '@kbn/core-base-common';
import { type ServiceStatus, ServiceStatusLevels } from '@kbn/core-status-common';
import { calculateStatus$ } from './status';
import { take } from 'rxjs/operators';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { Observable, combineLatest } from 'rxjs';
import { startWith, map } from 'rxjs/operators';
import { type ServiceStatus, ServiceStatusLevels } from '@kbn/core-base-common';
import { type ServiceStatus, ServiceStatusLevels } from '@kbn/core-status-common';
import type { SavedObjectStatusMeta } from '@kbn/core-saved-objects-server';
import type { KibanaMigratorStatus } from '@kbn/core-saved-objects-base-server-internal';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ NPM_MODULE_EXTRA_FILES = [

RUNTIME_DEPS = [
"@npm//rxjs",
"//packages/core/base/core-base-common",
"//packages/core/status/core-status-common",
"//packages/core/saved-objects/core-saved-objects-api-server-mocks",
"//packages/core/saved-objects/core-saved-objects-base-server-mocks",
"//packages/core/saved-objects/core-saved-objects-import-export-server-mocks",
Expand All @@ -48,7 +48,7 @@ TYPES_DEPS = [
"@npm//@types/jest",
"@npm//rxjs",
"//packages/kbn-utility-types:npm_module_types",
"//packages/core/base/core-base-common:npm_module_types",
"//packages/core/status/core-status-common:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-server:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-server-internal:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-api-server-mocks:npm_module_types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { ServiceStatusLevels } from '@kbn/core-base-common';
import { ServiceStatusLevels } from '@kbn/core-status-common';
import type {
SavedObjectsServiceSetup,
SavedObjectsServiceStart,
Expand Down
115 changes: 115 additions & 0 deletions packages/core/status/core-status-common-internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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_DIRNAME = "core-status-common-internal"
PKG_REQUIRE_NAME = "@kbn/core-status-common-internal"

SOURCE_FILES = glob(
[
"**/*.ts",
"**/*.tsx",
],
exclude = [
"**/*.config.js",
"**/*.mock.*",
"**/*.test.*",
"**/*.stories.*",
"**/__snapshots__/**",
"**/integration_tests/**",
"**/mocks/**",
"**/scripts/**",
"**/storybook/**",
"**/test_fixtures/**",
"**/test_helpers/**",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

RUNTIME_DEPS = [
]

TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"//packages/core/status/core-status-common:npm_module_types",
"//packages/core/metrics/core-metrics-server:npm_module_types",
]

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

jsts_transpiler(
name = "target_web",
srcs = SRCS,
build_pkg_name = package_name(),
web = True,
)

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",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)

filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)
3 changes: 3 additions & 0 deletions packages/core/status/core-status-common-internal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/core-status-common-internal

This package contains the common internal types for Core's `status` domain.
16 changes: 16 additions & 0 deletions packages/core/status/core-status-common-internal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 type {
StatusInfoCoreStatus,
StatusInfoServiceStatus,
StatusInfo,
StatusResponse,
ServerVersion,
ServerMetrics,
} from './src';
13 changes: 13 additions & 0 deletions packages/core/status/core-status-common-internal/jest.config.js
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/core/status/core-status-common-internal'],
};
7 changes: 7 additions & 0 deletions packages/core/status/core-status-common-internal/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "shared-common",
"id": "@kbn/core-status-common-internal",
"owner": "@elastic/kibana-core",
"runtimeDeps": [],
"typeDeps": []
}
9 changes: 9 additions & 0 deletions packages/core/status/core-status-common-internal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@kbn/core-status-common-internal",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"browser": "./target_web/index.js",
"author": "Kibana Core",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
16 changes: 16 additions & 0 deletions packages/core/status/core-status-common-internal/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 type {
StatusInfo,
StatusInfoCoreStatus,
StatusInfoServiceStatus,
StatusResponse,
ServerVersion,
ServerMetrics,
} from './status';
Loading

0 comments on commit 12466d8

Please sign in to comment.