Skip to content

Commit

Permalink
Migrate remaining parts of server-side SO domain to packages (elastic…
Browse files Browse the repository at this point in the history
…#139305)

* create empty packages

* create empty mock packages

* start moving client/repository implementation

* finish moving client/repo code

* move import/export code

* move migration code

* create empty mocks package

* start moving service code

* continue fixing stuff, create yet another package

* create usage-data package for internal contract

* create core-deprecations-server package

* fix last problems

* fix mock package

* start fixing usages

* fix index exports

* start fixing unit tests for new packages

* lint

* fix invalid char

* fix more violations and test failures

* fix more package tests

* adapt more test files

* one more fix

* adapt repo tests

* fix last (?) package tests

* fix moment mocking

* expose import/export error types again

* remove test mocking

* adapt imports

* export as type

* trying to fix the schema check task

* duplicating usage collection types for now

* fix stack trace assertion

* fix duplicate import from different paths

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

* update readme's

* move mocks to a dedicated folder

* self review

* move test_utils to integration tests

* update package files

* rename mocks

* manually adapting exclude

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
2 people authored and Mpdreamz committed Sep 6, 2022
1 parent 6a22cde commit a051d6c
Show file tree
Hide file tree
Showing 456 changed files with 3,733 additions and 721 deletions.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"@kbn/core-deprecations-browser-internal": "link:bazel-bin/packages/core/deprecations/core-deprecations-browser-internal",
"@kbn/core-deprecations-browser-mocks": "link:bazel-bin/packages/core/deprecations/core-deprecations-browser-mocks",
"@kbn/core-deprecations-common": "link:bazel-bin/packages/core/deprecations/core-deprecations-common",
"@kbn/core-deprecations-server": "link:bazel-bin/packages/core/deprecations/core-deprecations-server",
"@kbn/core-doc-links-browser": "link:bazel-bin/packages/core/doc-links/core-doc-links-browser",
"@kbn/core-doc-links-browser-internal": "link:bazel-bin/packages/core/doc-links/core-doc-links-browser-internal",
"@kbn/core-doc-links-browser-mocks": "link:bazel-bin/packages/core/doc-links/core-doc-links-browser-mocks",
Expand Down Expand Up @@ -237,13 +238,21 @@
"@kbn/core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks",
"@kbn/core-saved-objects-api-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-browser",
"@kbn/core-saved-objects-api-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server",
"@kbn/core-saved-objects-api-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server-internal",
"@kbn/core-saved-objects-api-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server-mocks",
"@kbn/core-saved-objects-base-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-internal",
"@kbn/core-saved-objects-base-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-mocks",
"@kbn/core-saved-objects-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser",
"@kbn/core-saved-objects-browser-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-internal",
"@kbn/core-saved-objects-browser-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-mocks",
"@kbn/core-saved-objects-common": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-common",
"@kbn/core-saved-objects-import-export-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-import-export-server-internal",
"@kbn/core-saved-objects-import-export-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-import-export-server-mocks",
"@kbn/core-saved-objects-migration-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-migration-server-internal",
"@kbn/core-saved-objects-migration-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-migration-server-mocks",
"@kbn/core-saved-objects-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server",
"@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-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",
Expand All @@ -254,6 +263,8 @@
"@kbn/core-ui-settings-browser-internal": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-internal",
"@kbn/core-ui-settings-browser-mocks": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-mocks",
"@kbn/core-ui-settings-common": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-common",
"@kbn/core-usage-data-base-server-internal": "link:bazel-bin/packages/core/usage-data/core-usage-data-base-server-internal",
"@kbn/core-usage-data-server": "link:bazel-bin/packages/core/usage-data/core-usage-data-server",
"@kbn/crypto": "link:bazel-bin/packages/kbn-crypto",
"@kbn/crypto-browser": "link:bazel-bin/packages/kbn-crypto-browser",
"@kbn/datemath": "link:bazel-bin/packages/kbn-datemath",
Expand Down Expand Up @@ -827,6 +838,7 @@
"@types/kbn__core-deprecations-browser-internal": "link:bazel-bin/packages/core/deprecations/core-deprecations-browser-internal/npm_module_types",
"@types/kbn__core-deprecations-browser-mocks": "link:bazel-bin/packages/core/deprecations/core-deprecations-browser-mocks/npm_module_types",
"@types/kbn__core-deprecations-common": "link:bazel-bin/packages/core/deprecations/core-deprecations-common/npm_module_types",
"@types/kbn__core-deprecations-server": "link:bazel-bin/packages/core/deprecations/core-deprecations-server/npm_module_types",
"@types/kbn__core-doc-links-browser": "link:bazel-bin/packages/core/doc-links/core-doc-links-browser/npm_module_types",
"@types/kbn__core-doc-links-browser-internal": "link:bazel-bin/packages/core/doc-links/core-doc-links-browser-internal/npm_module_types",
"@types/kbn__core-doc-links-browser-mocks": "link:bazel-bin/packages/core/doc-links/core-doc-links-browser-mocks/npm_module_types",
Expand Down Expand Up @@ -896,13 +908,21 @@
"@types/kbn__core-public-internal-base": "link:bazel-bin/packages/core/public/internal-base/npm_module_types",
"@types/kbn__core-saved-objects-api-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-browser/npm_module_types",
"@types/kbn__core-saved-objects-api-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server/npm_module_types",
"@types/kbn__core-saved-objects-api-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server-internal/npm_module_types",
"@types/kbn__core-saved-objects-api-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server-mocks/npm_module_types",
"@types/kbn__core-saved-objects-base-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-internal/npm_module_types",
"@types/kbn__core-saved-objects-base-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-mocks/npm_module_types",
"@types/kbn__core-saved-objects-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser/npm_module_types",
"@types/kbn__core-saved-objects-browser-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-internal/npm_module_types",
"@types/kbn__core-saved-objects-browser-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-mocks/npm_module_types",
"@types/kbn__core-saved-objects-common": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-common/npm_module_types",
"@types/kbn__core-saved-objects-import-export-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-import-export-server-internal/npm_module_types",
"@types/kbn__core-saved-objects-import-export-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-import-export-server-mocks/npm_module_types",
"@types/kbn__core-saved-objects-migration-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-migration-server-internal/npm_module_types",
"@types/kbn__core-saved-objects-migration-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-migration-server-mocks/npm_module_types",
"@types/kbn__core-saved-objects-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server/npm_module_types",
"@types/kbn__core-saved-objects-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server-internal/npm_module_types",
"@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-test-helpers-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters/npm_module_types",
Expand All @@ -914,6 +934,8 @@
"@types/kbn__core-ui-settings-browser-internal": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-internal/npm_module_types",
"@types/kbn__core-ui-settings-browser-mocks": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-mocks/npm_module_types",
"@types/kbn__core-ui-settings-common": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-common/npm_module_types",
"@types/kbn__core-usage-data-base-server-internal": "link:bazel-bin/packages/core/usage-data/core-usage-data-base-server-internal/npm_module_types",
"@types/kbn__core-usage-data-server": "link:bazel-bin/packages/core/usage-data/core-usage-data-server/npm_module_types",
"@types/kbn__crypto": "link:bazel-bin/packages/kbn-crypto/npm_module_types",
"@types/kbn__crypto-browser": "link:bazel-bin/packages/kbn-crypto-browser/npm_module_types",
"@types/kbn__datemath": "link:bazel-bin/packages/kbn-datemath/npm_module_types",
Expand Down
22 changes: 22 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ filegroup(
"//packages/core/deprecations/core-deprecations-browser-internal:build",
"//packages/core/deprecations/core-deprecations-browser-mocks:build",
"//packages/core/deprecations/core-deprecations-common:build",
"//packages/core/deprecations/core-deprecations-server:build",
"//packages/core/doc-links/core-doc-links-browser:build",
"//packages/core/doc-links/core-doc-links-browser-internal:build",
"//packages/core/doc-links/core-doc-links-browser-mocks:build",
Expand Down Expand Up @@ -102,13 +103,21 @@ filegroup(
"//packages/core/preboot/core-preboot-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-api-browser:build",
"//packages/core/saved-objects/core-saved-objects-api-server:build",
"//packages/core/saved-objects/core-saved-objects-api-server-internal:build",
"//packages/core/saved-objects/core-saved-objects-api-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-base-server-internal:build",
"//packages/core/saved-objects/core-saved-objects-base-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-browser:build",
"//packages/core/saved-objects/core-saved-objects-browser-internal:build",
"//packages/core/saved-objects/core-saved-objects-browser-mocks:build",
"//packages/core/saved-objects/core-saved-objects-common:build",
"//packages/core/saved-objects/core-saved-objects-import-export-server-internal:build",
"//packages/core/saved-objects/core-saved-objects-import-export-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-migration-server-internal:build",
"//packages/core/saved-objects/core-saved-objects-migration-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-server:build",
"//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/test-helpers/core-test-helpers-deprecations-getters:build",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build",
Expand All @@ -119,6 +128,8 @@ filegroup(
"//packages/core/ui-settings/core-ui-settings-browser-internal:build",
"//packages/core/ui-settings/core-ui-settings-browser-mocks:build",
"//packages/core/ui-settings/core-ui-settings-common:build",
"//packages/core/usage-data/core-usage-data-base-server-internal:build",
"//packages/core/usage-data/core-usage-data-server:build",
"//packages/home/sample_data_card:build",
"//packages/home/sample_data_tab:build",
"//packages/home/sample_data_types:build",
Expand Down Expand Up @@ -311,6 +322,7 @@ filegroup(
"//packages/core/deprecations/core-deprecations-browser-internal:build_types",
"//packages/core/deprecations/core-deprecations-browser-mocks:build_types",
"//packages/core/deprecations/core-deprecations-common:build_types",
"//packages/core/deprecations/core-deprecations-server:build_types",
"//packages/core/doc-links/core-doc-links-browser:build_types",
"//packages/core/doc-links/core-doc-links-browser-internal:build_types",
"//packages/core/doc-links/core-doc-links-browser-mocks:build_types",
Expand Down Expand Up @@ -378,13 +390,21 @@ filegroup(
"//packages/core/preboot/core-preboot-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-api-browser:build_types",
"//packages/core/saved-objects/core-saved-objects-api-server:build_types",
"//packages/core/saved-objects/core-saved-objects-api-server-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-api-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-base-server-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-base-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-browser:build_types",
"//packages/core/saved-objects/core-saved-objects-browser-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-browser-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-common:build_types",
"//packages/core/saved-objects/core-saved-objects-import-export-server-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-import-export-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-migration-server-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-migration-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-server:build_types",
"//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/test-helpers/core-test-helpers-deprecations-getters:build_types",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build_types",
Expand All @@ -395,6 +415,8 @@ filegroup(
"//packages/core/ui-settings/core-ui-settings-browser-internal:build_types",
"//packages/core/ui-settings/core-ui-settings-browser-mocks:build_types",
"//packages/core/ui-settings/core-ui-settings-common:build_types",
"//packages/core/usage-data/core-usage-data-base-server-internal:build_types",
"//packages/core/usage-data/core-usage-data-server:build_types",
"//packages/home/sample_data_card:build_types",
"//packages/home/sample_data_tab:build_types",
"//packages/kbn-ace:build_types",
Expand Down
110 changes: 110 additions & 0 deletions packages/core/deprecations/core-deprecations-server/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
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-deprecations-server"
PKG_REQUIRE_NAME = "@kbn/core-deprecations-server"

SOURCE_FILES = glob(
[
"**/*.ts",
],
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/kbn-utility-types:npm_module_types",
"//packages/core/deprecations/core-deprecations-common:npm_module_types",
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-api-server:npm_module_types",
]

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

js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node"],
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/deprecations/core-deprecations-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/core-deprecations-server

This package contains public types for Core's server-side `deprecations` domain.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Side Public License, v 1.
*/

/** @internal */
export const CORE_USAGE_STATS_TYPE = 'core-usage-stats';

/** @internal */
export const CORE_USAGE_STATS_ID = 'core-usage-stats';
export type {
RegisterDeprecationsConfig,
GetDeprecationsContext,
DeprecationsServiceSetup,
DeprecationRegistryProvider,
} from './src';
13 changes: 13 additions & 0 deletions packages/core/deprecations/core-deprecations-server/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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/deprecations/core-deprecations-server'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@kbn/core-deprecations-server",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"author": "Kibana Core",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
Loading

0 comments on commit a051d6c

Please sign in to comment.