From e1adec3e09eb9cda55b94157c1517677d685c55b Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Mon, 3 Oct 2022 09:52:17 +0200 Subject: [PATCH] Migrate server-side `rendering` service to packages (#141902) * create empty packages * moves files to packages * adapt usages * updating READMEs and packages jsons * [CI] Auto-commit changed files from 'node scripts/generate codeowners' * adapt more usages * more import fixes * fix mock method names * export the `Fonts` component for security... * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * fix more usages again * includes tsx files Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .github/CODEOWNERS | 3 + package.json | 6 + packages/BUILD.bazel | 6 + .../BUILD.bazel | 107 +++++++++++++++ .../README.md | 3 + .../index.ts | 9 ++ .../jest.config.js | 13 ++ .../kibana.jsonc | 7 + .../package.json | 8 ++ .../src/index.ts | 9 ++ .../src/types.ts | 51 +++++++ .../tsconfig.json | 17 +++ .../BUILD.bazel | 127 ++++++++++++++++++ .../core-rendering-server-internal/README.md | 3 + .../core-rendering-server-internal/index.ts | 17 +++ .../jest.config.js | 13 ++ .../kibana.jsonc | 7 + .../package.json | 8 ++ .../rendering_service.test.ts.snap | 0 .../render_template.test.ts.snap | 0 .../bootstrap_renderer.test.mocks.ts | 0 .../src}/bootstrap/bootstrap_renderer.test.ts | 2 +- .../src}/bootstrap/bootstrap_renderer.ts | 2 +- .../bootstrap/get_js_dependency_paths.test.ts | 0 .../src}/bootstrap/get_js_dependency_paths.ts | 0 .../bootstrap/get_plugin_bundle_paths.test.ts | 3 +- .../src}/bootstrap/get_plugin_bundle_paths.ts | 2 +- .../src}/bootstrap/get_theme_tag.test.ts | 0 .../src}/bootstrap/get_theme_tag.ts | 0 .../src}/bootstrap/index.ts | 0 .../bootstrap/register_bootstrap_route.ts | 0 .../src}/bootstrap/render_template.test.ts | 0 .../src}/bootstrap/render_template.ts | 0 .../src}/filter_ui_plugins.test.ts | 3 +- .../src}/filter_ui_plugins.ts | 2 +- .../src}/index.ts | 1 + .../src}/internal_types.ts | 0 .../src}/render_utils.test.ts | 0 .../src}/render_utils.ts | 0 .../src}/rendering_service.test.mocks.ts | 0 .../src}/rendering_service.test.ts | 2 +- .../src}/rendering_service.tsx | 4 +- .../src/test_helpers}/params.ts | 13 +- .../src/test_helpers}/rendering_service.ts | 0 .../src}/types.ts | 4 +- .../src}/views/fonts.tsx | 0 .../src}/views/index.ts | 1 + .../src}/views/logo.tsx | 0 .../src}/views/styles.tsx | 0 .../src}/views/template.tsx | 0 .../tsconfig.json | 19 +++ .../core-rendering-server-mocks/BUILD.bazel | 106 +++++++++++++++ .../core-rendering-server-mocks/README.md | 4 + .../core-rendering-server-mocks/index.ts | 9 ++ .../jest.config.js | 13 ++ .../core-rendering-server-mocks/kibana.jsonc | 7 + .../core-rendering-server-mocks/package.json | 8 ++ .../core-rendering-server-mocks/src/index.ts | 9 ++ .../src}/rendering_service.mock.ts | 25 +++- .../core-rendering-server-mocks/tsconfig.json | 17 +++ .../register_bundle_routes.test.ts | 2 +- .../bundle_routes/register_bundle_routes.ts | 2 +- src/core/server/core_app/core_app.test.ts | 2 +- src/core/server/core_app/core_app.ts | 2 +- .../http_resources_service.test.ts | 6 +- .../http_resources/http_resources_service.ts | 5 +- src/core/server/index.ts | 1 - src/core/server/internal_types.ts | 2 +- src/core/server/mocks.ts | 6 +- src/core/server/plugins/index.ts | 1 - src/core/server/plugins/plugins_service.ts | 28 +--- src/core/server/plugins/types.ts | 22 --- src/core/server/server.test.mocks.ts | 8 +- src/core/server/server.ts | 2 +- .../unauthenticated_page.test.tsx | 2 +- .../authorization/reset_session_page.test.tsx | 2 +- .../security/server/prompt_page.test.tsx | 2 +- .../plugins/security/server/prompt_page.tsx | 2 +- yarn.lock | 24 ++++ 79 files changed, 705 insertions(+), 86 deletions(-) create mode 100644 packages/core/plugins/core-plugins-base-server-internal/BUILD.bazel create mode 100644 packages/core/plugins/core-plugins-base-server-internal/README.md create mode 100644 packages/core/plugins/core-plugins-base-server-internal/index.ts create mode 100644 packages/core/plugins/core-plugins-base-server-internal/jest.config.js create mode 100644 packages/core/plugins/core-plugins-base-server-internal/kibana.jsonc create mode 100644 packages/core/plugins/core-plugins-base-server-internal/package.json create mode 100644 packages/core/plugins/core-plugins-base-server-internal/src/index.ts create mode 100644 packages/core/plugins/core-plugins-base-server-internal/src/types.ts create mode 100644 packages/core/plugins/core-plugins-base-server-internal/tsconfig.json create mode 100644 packages/core/rendering/core-rendering-server-internal/BUILD.bazel create mode 100644 packages/core/rendering/core-rendering-server-internal/README.md create mode 100644 packages/core/rendering/core-rendering-server-internal/index.ts create mode 100644 packages/core/rendering/core-rendering-server-internal/jest.config.js create mode 100644 packages/core/rendering/core-rendering-server-internal/kibana.jsonc create mode 100644 packages/core/rendering/core-rendering-server-internal/package.json rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/__snapshots__/rendering_service.test.ts.snap (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/__snapshots__/render_template.test.ts.snap (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/bootstrap_renderer.test.mocks.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/bootstrap_renderer.test.ts (98%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/bootstrap_renderer.ts (97%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/get_js_dependency_paths.test.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/get_js_dependency_paths.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/get_plugin_bundle_paths.test.ts (94%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/get_plugin_bundle_paths.ts (95%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/get_theme_tag.test.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/get_theme_tag.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/index.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/register_bootstrap_route.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/render_template.test.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/bootstrap/render_template.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/filter_ui_plugins.test.ts (93%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/filter_ui_plugins.ts (95%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/index.ts (94%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/internal_types.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/render_utils.test.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/render_utils.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/rendering_service.test.mocks.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/rendering_service.test.ts (99%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/rendering_service.tsx (98%) rename {src/core/server/rendering/__mocks__ => packages/core/rendering/core-rendering-server-internal/src/test_helpers}/params.ts (85%) rename {src/core/server/rendering/__mocks__ => packages/core/rendering/core-rendering-server-internal/src/test_helpers}/rendering_service.ts (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/types.ts (96%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/views/fonts.tsx (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/views/index.ts (92%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/views/logo.tsx (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/views/styles.tsx (100%) rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-internal/src}/views/template.tsx (100%) create mode 100644 packages/core/rendering/core-rendering-server-internal/tsconfig.json create mode 100644 packages/core/rendering/core-rendering-server-mocks/BUILD.bazel create mode 100644 packages/core/rendering/core-rendering-server-mocks/README.md create mode 100644 packages/core/rendering/core-rendering-server-mocks/index.ts create mode 100644 packages/core/rendering/core-rendering-server-mocks/jest.config.js create mode 100644 packages/core/rendering/core-rendering-server-mocks/kibana.jsonc create mode 100644 packages/core/rendering/core-rendering-server-mocks/package.json create mode 100644 packages/core/rendering/core-rendering-server-mocks/src/index.ts rename {src/core/server/rendering => packages/core/rendering/core-rendering-server-mocks/src}/rendering_service.mock.ts (55%) create mode 100644 packages/core/rendering/core-rendering-server-mocks/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0a1fcc60d55b6..b7d588bc89269 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -784,6 +784,7 @@ packages/core/notifications/core-notifications-browser-mocks @elastic/kibana-cor packages/core/overlays/core-overlays-browser @elastic/kibana-core packages/core/overlays/core-overlays-browser-internal @elastic/kibana-core packages/core/overlays/core-overlays-browser-mocks @elastic/kibana-core +packages/core/plugins/core-plugins-base-server-internal @elastic/kibana-core packages/core/plugins/core-plugins-browser @elastic/kibana-core packages/core/plugins/core-plugins-browser-internal @elastic/kibana-core packages/core/plugins/core-plugins-browser-mocks @elastic/kibana-core @@ -792,6 +793,8 @@ packages/core/preboot/core-preboot-server-internal @elastic/kibana-core packages/core/preboot/core-preboot-server-mocks @elastic/kibana-core packages/core/rendering/core-rendering-browser-internal @elastic/kibana-core packages/core/rendering/core-rendering-browser-mocks @elastic/kibana-core +packages/core/rendering/core-rendering-server-internal @elastic/kibana-core +packages/core/rendering/core-rendering-server-mocks @elastic/kibana-core packages/core/root/core-root-browser-internal @elastic/kibana-core packages/core/saved-objects/core-saved-objects-api-browser @elastic/kibana-core packages/core/saved-objects/core-saved-objects-api-server @elastic/kibana-core diff --git a/package.json b/package.json index e7b1f86b9c053..4108e83b0e6c6 100644 --- a/package.json +++ b/package.json @@ -254,6 +254,7 @@ "@kbn/core-overlays-browser": "link:bazel-bin/packages/core/overlays/core-overlays-browser", "@kbn/core-overlays-browser-internal": "link:bazel-bin/packages/core/overlays/core-overlays-browser-internal", "@kbn/core-overlays-browser-mocks": "link:bazel-bin/packages/core/overlays/core-overlays-browser-mocks", + "@kbn/core-plugins-base-server-internal": "link:bazel-bin/packages/core/plugins/core-plugins-base-server-internal", "@kbn/core-plugins-browser": "link:bazel-bin/packages/core/plugins/core-plugins-browser", "@kbn/core-plugins-browser-internal": "link:bazel-bin/packages/core/plugins/core-plugins-browser-internal", "@kbn/core-plugins-browser-mocks": "link:bazel-bin/packages/core/plugins/core-plugins-browser-mocks", @@ -262,6 +263,8 @@ "@kbn/core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks", "@kbn/core-rendering-browser-internal": "link:bazel-bin/packages/core/rendering/core-rendering-browser-internal", "@kbn/core-rendering-browser-mocks": "link:bazel-bin/packages/core/rendering/core-rendering-browser-mocks", + "@kbn/core-rendering-server-internal": "link:bazel-bin/packages/core/rendering/core-rendering-server-internal", + "@kbn/core-rendering-server-mocks": "link:bazel-bin/packages/core/rendering/core-rendering-server-mocks", "@kbn/core-root-browser-internal": "link:bazel-bin/packages/core/root/core-root-browser-internal", "@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", @@ -978,6 +981,7 @@ "@types/kbn__core-overlays-browser": "link:bazel-bin/packages/core/overlays/core-overlays-browser/npm_module_types", "@types/kbn__core-overlays-browser-internal": "link:bazel-bin/packages/core/overlays/core-overlays-browser-internal/npm_module_types", "@types/kbn__core-overlays-browser-mocks": "link:bazel-bin/packages/core/overlays/core-overlays-browser-mocks/npm_module_types", + "@types/kbn__core-plugins-base-server-internal": "link:bazel-bin/packages/core/plugins/core-plugins-base-server-internal/npm_module_types", "@types/kbn__core-plugins-browser": "link:bazel-bin/packages/core/plugins/core-plugins-browser/npm_module_types", "@types/kbn__core-plugins-browser-internal": "link:bazel-bin/packages/core/plugins/core-plugins-browser-internal/npm_module_types", "@types/kbn__core-plugins-browser-mocks": "link:bazel-bin/packages/core/plugins/core-plugins-browser-mocks/npm_module_types", @@ -987,6 +991,8 @@ "@types/kbn__core-public-internal-base": "link:bazel-bin/packages/core/public/internal-base/npm_module_types", "@types/kbn__core-rendering-browser-internal": "link:bazel-bin/packages/core/rendering/core-rendering-browser-internal/npm_module_types", "@types/kbn__core-rendering-browser-mocks": "link:bazel-bin/packages/core/rendering/core-rendering-browser-mocks/npm_module_types", + "@types/kbn__core-rendering-server-internal": "link:bazel-bin/packages/core/rendering/core-rendering-server-internal/npm_module_types", + "@types/kbn__core-rendering-server-mocks": "link:bazel-bin/packages/core/rendering/core-rendering-server-mocks/npm_module_types", "@types/kbn__core-root-browser-internal": "link:bazel-bin/packages/core/root/core-root-browser-internal/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", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index cf97e501df09c..0d5ecd4bc4cfc 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -120,6 +120,7 @@ filegroup( "//packages/core/overlays/core-overlays-browser:build", "//packages/core/overlays/core-overlays-browser-internal:build", "//packages/core/overlays/core-overlays-browser-mocks:build", + "//packages/core/plugins/core-plugins-base-server-internal:build", "//packages/core/plugins/core-plugins-browser:build", "//packages/core/plugins/core-plugins-browser-internal:build", "//packages/core/plugins/core-plugins-browser-mocks:build", @@ -128,6 +129,8 @@ filegroup( "//packages/core/preboot/core-preboot-server-mocks:build", "//packages/core/rendering/core-rendering-browser-internal:build", "//packages/core/rendering/core-rendering-browser-mocks:build", + "//packages/core/rendering/core-rendering-server-internal:build", + "//packages/core/rendering/core-rendering-server-mocks:build", "//packages/core/root/core-root-browser-internal:build", "//packages/core/saved-objects/core-saved-objects-api-browser:build", "//packages/core/saved-objects/core-saved-objects-api-server:build", @@ -454,6 +457,7 @@ filegroup( "//packages/core/overlays/core-overlays-browser:build_types", "//packages/core/overlays/core-overlays-browser-internal:build_types", "//packages/core/overlays/core-overlays-browser-mocks:build_types", + "//packages/core/plugins/core-plugins-base-server-internal:build_types", "//packages/core/plugins/core-plugins-browser:build_types", "//packages/core/plugins/core-plugins-browser-internal:build_types", "//packages/core/plugins/core-plugins-browser-mocks:build_types", @@ -462,6 +466,8 @@ filegroup( "//packages/core/preboot/core-preboot-server-mocks:build_types", "//packages/core/rendering/core-rendering-browser-internal:build_types", "//packages/core/rendering/core-rendering-browser-mocks:build_types", + "//packages/core/rendering/core-rendering-server-internal:build_types", + "//packages/core/rendering/core-rendering-server-mocks:build_types", "//packages/core/root/core-root-browser-internal:build_types", "//packages/core/saved-objects/core-saved-objects-api-browser:build_types", "//packages/core/saved-objects/core-saved-objects-api-server:build_types", diff --git a/packages/core/plugins/core-plugins-base-server-internal/BUILD.bazel b/packages/core/plugins/core-plugins-base-server-internal/BUILD.bazel new file mode 100644 index 0000000000000..7e4d73b638a75 --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/BUILD.bazel @@ -0,0 +1,107 @@ +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-plugins-base-server-internal" +PKG_REQUIRE_NAME = "@kbn/core-plugins-base-server-internal" + +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", + "@npm//rxjs", + "//packages/core/base/core-base-common: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", + 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"], +) diff --git a/packages/core/plugins/core-plugins-base-server-internal/README.md b/packages/core/plugins/core-plugins-base-server-internal/README.md new file mode 100644 index 0000000000000..565082ebccc04 --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/README.md @@ -0,0 +1,3 @@ +# @kbn/core-plugins-base-server-internal + +This package contains base internal types of the `plugins` domain used across other core domains. diff --git a/packages/core/plugins/core-plugins-base-server-internal/index.ts b/packages/core/plugins/core-plugins-base-server-internal/index.ts new file mode 100644 index 0000000000000..3052f46e9fe7a --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/index.ts @@ -0,0 +1,9 @@ +/* + * 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 { UiPlugins, InternalPluginInfo } from './src'; diff --git a/packages/core/plugins/core-plugins-base-server-internal/jest.config.js b/packages/core/plugins/core-plugins-base-server-internal/jest.config.js new file mode 100644 index 0000000000000..9a9b5aa5ec9bf --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/jest.config.js @@ -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: ['/packages/core/plugins/core-plugins-base-server-internal'], +}; diff --git a/packages/core/plugins/core-plugins-base-server-internal/kibana.jsonc b/packages/core/plugins/core-plugins-base-server-internal/kibana.jsonc new file mode 100644 index 0000000000000..a593530ab5fc4 --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/kibana.jsonc @@ -0,0 +1,7 @@ +{ + "type": "shared-common", + "id": "@kbn/core-plugins-base-server-internal", + "owner": "@elastic/kibana-core", + "runtimeDeps": [], + "typeDeps": [], +} diff --git a/packages/core/plugins/core-plugins-base-server-internal/package.json b/packages/core/plugins/core-plugins-base-server-internal/package.json new file mode 100644 index 0000000000000..6af3453f1a29b --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/core-plugins-base-server-internal", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "author": "Kibana Core", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/packages/core/plugins/core-plugins-base-server-internal/src/index.ts b/packages/core/plugins/core-plugins-base-server-internal/src/index.ts new file mode 100644 index 0000000000000..ade9e77fc1783 --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/src/index.ts @@ -0,0 +1,9 @@ +/* + * 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 { UiPlugins, InternalPluginInfo } from './types'; diff --git a/packages/core/plugins/core-plugins-base-server-internal/src/types.ts b/packages/core/plugins/core-plugins-base-server-internal/src/types.ts new file mode 100644 index 0000000000000..d0afcce5dba5c --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/src/types.ts @@ -0,0 +1,51 @@ +/* + * 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. + */ + +import type { Observable } from 'rxjs'; +import type { DiscoveredPlugin, PluginName } from '@kbn/core-base-common'; + +/** @internal */ +export interface UiPlugins { + /** + * Paths to all discovered ui plugin entrypoints on the filesystem, even if + * disabled. + */ + internal: Map; + + /** + * Information needed by client-side to load plugins and wire dependencies. + */ + public: Map; + + /** + * Configuration for plugins to be exposed to the client-side. + */ + browserConfigs: Map>; +} + +/** + * @internal + */ +export interface InternalPluginInfo { + /** + * Version of the plugin + */ + readonly version: string; + /** + * Bundles that must be loaded for this plugin + */ + readonly requiredBundles: readonly string[]; + /** + * Path to the target/public directory of the plugin which should be served + */ + readonly publicTargetDir: string; + /** + * Path to the plugin assets directory. + */ + readonly publicAssetsDir: string; +} diff --git a/packages/core/plugins/core-plugins-base-server-internal/tsconfig.json b/packages/core/plugins/core-plugins-base-server-internal/tsconfig.json new file mode 100644 index 0000000000000..71bb40fe57f3f --- /dev/null +++ b/packages/core/plugins/core-plugins-base-server-internal/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "stripInternal": false, + "types": [ + "jest", + "node" + ] + }, + "include": [ + "**/*.ts", + ] +} diff --git a/packages/core/rendering/core-rendering-server-internal/BUILD.bazel b/packages/core/rendering/core-rendering-server-internal/BUILD.bazel new file mode 100644 index 0000000000000..b02ff09264699 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/BUILD.bazel @@ -0,0 +1,127 @@ +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-rendering-server-internal" +PKG_REQUIRE_NAME = "@kbn/core-rendering-server-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 = [ + "@npm//react", + "@npm//react-dom", + "@npm//rxjs", + "//packages/kbn-i18n", + "//packages/kbn-ui-shared-deps-npm", + "//packages/kbn-ui-shared-deps-src", +] + +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", + "@npm//@types/react", + "@npm//@types/react-dom", + "@npm//rxjs", + "//packages/kbn-i18n:npm_module_types", + "//packages/kbn-ui-shared-deps-npm:npm_module_types", + "//packages/kbn-ui-shared-deps-src:npm_module_types", + "//packages/core/base/core-base-server-internal:npm_module_types", + "//packages/core/injected-metadata/core-injected-metadata-common-internal:npm_module_types", + "//packages/core/http/core-http-server:npm_module_types", + "//packages/core/http/core-http-server-internal:npm_module_types", + "//packages/core/elasticsearch/core-elasticsearch-server-internal:npm_module_types", + "//packages/core/status/core-status-server-internal:npm_module_types", + "//packages/core/ui-settings/core-ui-settings-common:npm_module_types", + "//packages/core/ui-settings/core-ui-settings-server:npm_module_types", + "//packages/core/plugins/core-plugins-base-server-internal: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", + 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"], +) diff --git a/packages/core/rendering/core-rendering-server-internal/README.md b/packages/core/rendering/core-rendering-server-internal/README.md new file mode 100644 index 0000000000000..629ac2047de02 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/README.md @@ -0,0 +1,3 @@ +# @kbn/core-rendering-server-internal + +This package contains the internal types and implementation for Core's server-side rendering service. diff --git a/packages/core/rendering/core-rendering-server-internal/index.ts b/packages/core/rendering/core-rendering-server-internal/index.ts new file mode 100644 index 0000000000000..7ddc442a74253 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/index.ts @@ -0,0 +1,17 @@ +/* + * 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 { RenderingService, Fonts } from './src'; +export type { + InternalRenderingServicePreboot, + InternalRenderingServiceSetup, + IRenderOptions, + RenderingMetadata, + RenderingPrebootDeps, + RenderingSetupDeps, +} from './src'; diff --git a/packages/core/rendering/core-rendering-server-internal/jest.config.js b/packages/core/rendering/core-rendering-server-internal/jest.config.js new file mode 100644 index 0000000000000..48ca2e89b9763 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/jest.config.js @@ -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: ['/packages/core/rendering/core-rendering-server-internal'], +}; diff --git a/packages/core/rendering/core-rendering-server-internal/kibana.jsonc b/packages/core/rendering/core-rendering-server-internal/kibana.jsonc new file mode 100644 index 0000000000000..2ce227d70528f --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/kibana.jsonc @@ -0,0 +1,7 @@ +{ + "type": "shared-common", + "id": "@kbn/core-rendering-server-internal", + "owner": "@elastic/kibana-core", + "runtimeDeps": [], + "typeDeps": [], +} diff --git a/packages/core/rendering/core-rendering-server-internal/package.json b/packages/core/rendering/core-rendering-server-internal/package.json new file mode 100644 index 0000000000000..ef29d29e9fa2f --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/core-rendering-server-internal", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "author": "Kibana Core", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/src/core/server/rendering/__snapshots__/rendering_service.test.ts.snap b/packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap similarity index 100% rename from src/core/server/rendering/__snapshots__/rendering_service.test.ts.snap rename to packages/core/rendering/core-rendering-server-internal/src/__snapshots__/rendering_service.test.ts.snap diff --git a/src/core/server/rendering/bootstrap/__snapshots__/render_template.test.ts.snap b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/__snapshots__/render_template.test.ts.snap similarity index 100% rename from src/core/server/rendering/bootstrap/__snapshots__/render_template.test.ts.snap rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/__snapshots__/render_template.test.ts.snap diff --git a/src/core/server/rendering/bootstrap/bootstrap_renderer.test.mocks.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.mocks.ts similarity index 100% rename from src/core/server/rendering/bootstrap/bootstrap_renderer.test.mocks.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.mocks.ts diff --git a/src/core/server/rendering/bootstrap/bootstrap_renderer.test.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts similarity index 98% rename from src/core/server/rendering/bootstrap/bootstrap_renderer.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts index a1ed415f72c42..af9de3fbd6ff1 100644 --- a/src/core/server/rendering/bootstrap/bootstrap_renderer.test.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.test.ts @@ -15,7 +15,7 @@ import { import { PackageInfo } from '@kbn/config'; import { AuthStatus } from '@kbn/core-http-server'; -import { UiPlugins } from '../../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { httpServiceMock, httpServerMock } from '@kbn/core-http-server-mocks'; import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks'; import { bootstrapRendererFactory, BootstrapRenderer } from './bootstrap_renderer'; diff --git a/src/core/server/rendering/bootstrap/bootstrap_renderer.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.ts similarity index 97% rename from src/core/server/rendering/bootstrap/bootstrap_renderer.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.ts index 4c20f8d3d799a..8424bb3e68a1d 100644 --- a/src/core/server/rendering/bootstrap/bootstrap_renderer.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/bootstrap_renderer.ts @@ -11,7 +11,7 @@ import { PackageInfo } from '@kbn/config'; import { ThemeVersion } from '@kbn/ui-shared-deps-npm'; import type { KibanaRequest, HttpAuth } from '@kbn/core-http-server'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-server'; -import { UiPlugins } from '../../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { getPluginsBundlePaths } from './get_plugin_bundle_paths'; import { getJsDependencyPaths } from './get_js_dependency_paths'; import { getThemeTag } from './get_theme_tag'; diff --git a/src/core/server/rendering/bootstrap/get_js_dependency_paths.test.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_js_dependency_paths.test.ts similarity index 100% rename from src/core/server/rendering/bootstrap/get_js_dependency_paths.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_js_dependency_paths.test.ts diff --git a/src/core/server/rendering/bootstrap/get_js_dependency_paths.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_js_dependency_paths.ts similarity index 100% rename from src/core/server/rendering/bootstrap/get_js_dependency_paths.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_js_dependency_paths.ts diff --git a/src/core/server/rendering/bootstrap/get_plugin_bundle_paths.test.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_plugin_bundle_paths.test.ts similarity index 94% rename from src/core/server/rendering/bootstrap/get_plugin_bundle_paths.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_plugin_bundle_paths.test.ts index e3746eeb17a00..619765cdc7b6a 100644 --- a/src/core/server/rendering/bootstrap/get_plugin_bundle_paths.test.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_plugin_bundle_paths.test.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import { InternalPluginInfo, PluginType, UiPlugins } from '../../plugins'; +import { PluginType } from '@kbn/core-base-common'; +import type { InternalPluginInfo, UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { getPluginsBundlePaths } from './get_plugin_bundle_paths'; const createUiPlugins = (pluginDeps: Record) => { diff --git a/src/core/server/rendering/bootstrap/get_plugin_bundle_paths.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_plugin_bundle_paths.ts similarity index 95% rename from src/core/server/rendering/bootstrap/get_plugin_bundle_paths.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_plugin_bundle_paths.ts index e5a9ed9fdd3d0..ad9f3edb4aa51 100644 --- a/src/core/server/rendering/bootstrap/get_plugin_bundle_paths.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_plugin_bundle_paths.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { UiPlugins } from '../../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { filterUiPlugins } from '../filter_ui_plugins'; export interface PluginInfo { diff --git a/src/core/server/rendering/bootstrap/get_theme_tag.test.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_theme_tag.test.ts similarity index 100% rename from src/core/server/rendering/bootstrap/get_theme_tag.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_theme_tag.test.ts diff --git a/src/core/server/rendering/bootstrap/get_theme_tag.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_theme_tag.ts similarity index 100% rename from src/core/server/rendering/bootstrap/get_theme_tag.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/get_theme_tag.ts diff --git a/src/core/server/rendering/bootstrap/index.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/index.ts similarity index 100% rename from src/core/server/rendering/bootstrap/index.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/index.ts diff --git a/src/core/server/rendering/bootstrap/register_bootstrap_route.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/register_bootstrap_route.ts similarity index 100% rename from src/core/server/rendering/bootstrap/register_bootstrap_route.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/register_bootstrap_route.ts diff --git a/src/core/server/rendering/bootstrap/render_template.test.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/render_template.test.ts similarity index 100% rename from src/core/server/rendering/bootstrap/render_template.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/render_template.test.ts diff --git a/src/core/server/rendering/bootstrap/render_template.ts b/packages/core/rendering/core-rendering-server-internal/src/bootstrap/render_template.ts similarity index 100% rename from src/core/server/rendering/bootstrap/render_template.ts rename to packages/core/rendering/core-rendering-server-internal/src/bootstrap/render_template.ts diff --git a/src/core/server/rendering/filter_ui_plugins.test.ts b/packages/core/rendering/core-rendering-server-internal/src/filter_ui_plugins.test.ts similarity index 93% rename from src/core/server/rendering/filter_ui_plugins.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/filter_ui_plugins.test.ts index fc013b4be0d07..096e0cc57b1f6 100644 --- a/src/core/server/rendering/filter_ui_plugins.test.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/filter_ui_plugins.test.ts @@ -6,7 +6,8 @@ * Side Public License, v 1. */ -import type { DiscoveredPlugin, PluginName, UiPlugins } from '../plugins'; +import type { PluginName, DiscoveredPlugin } from '@kbn/core-base-common'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { filterUiPlugins } from './filter_ui_plugins'; function createMockPlugin(params: Partial) { diff --git a/src/core/server/rendering/filter_ui_plugins.ts b/packages/core/rendering/core-rendering-server-internal/src/filter_ui_plugins.ts similarity index 95% rename from src/core/server/rendering/filter_ui_plugins.ts rename to packages/core/rendering/core-rendering-server-internal/src/filter_ui_plugins.ts index d3ca102a35758..e1be7719bfea7 100644 --- a/src/core/server/rendering/filter_ui_plugins.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/filter_ui_plugins.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { UiPlugins } from '../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; /** * Gets the array of plugins that should be enabled on the page. diff --git a/src/core/server/rendering/index.ts b/packages/core/rendering/core-rendering-server-internal/src/index.ts similarity index 94% rename from src/core/server/rendering/index.ts rename to packages/core/rendering/core-rendering-server-internal/src/index.ts index 6cf0e2a74aa1f..e1cac45f7765c 100644 --- a/src/core/server/rendering/index.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/index.ts @@ -7,6 +7,7 @@ */ export { RenderingService } from './rendering_service'; +export { Fonts } from './views'; export type { InternalRenderingServicePreboot, InternalRenderingServiceSetup, diff --git a/src/core/server/rendering/internal_types.ts b/packages/core/rendering/core-rendering-server-internal/src/internal_types.ts similarity index 100% rename from src/core/server/rendering/internal_types.ts rename to packages/core/rendering/core-rendering-server-internal/src/internal_types.ts diff --git a/src/core/server/rendering/render_utils.test.ts b/packages/core/rendering/core-rendering-server-internal/src/render_utils.test.ts similarity index 100% rename from src/core/server/rendering/render_utils.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/render_utils.test.ts diff --git a/src/core/server/rendering/render_utils.ts b/packages/core/rendering/core-rendering-server-internal/src/render_utils.ts similarity index 100% rename from src/core/server/rendering/render_utils.ts rename to packages/core/rendering/core-rendering-server-internal/src/render_utils.ts diff --git a/src/core/server/rendering/rendering_service.test.mocks.ts b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.mocks.ts similarity index 100% rename from src/core/server/rendering/rendering_service.test.mocks.ts rename to packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.mocks.ts diff --git a/src/core/server/rendering/rendering_service.test.ts b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts similarity index 99% rename from src/core/server/rendering/rendering_service.test.ts rename to packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts index 424bcd8a6533b..48196717c6f9f 100644 --- a/src/core/server/rendering/rendering_service.test.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.test.ts @@ -22,7 +22,7 @@ import { mockRenderingServiceParams, mockRenderingPrebootDeps, mockRenderingSetupDeps, -} from './__mocks__/params'; +} from './test_helpers/params'; import { InternalRenderingServicePreboot, InternalRenderingServiceSetup } from './types'; import { RenderingService } from './rendering_service'; import { AuthStatus } from '@kbn/core-http-server'; diff --git a/src/core/server/rendering/rendering_service.tsx b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx similarity index 98% rename from src/core/server/rendering/rendering_service.tsx rename to packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx index c5b56a06782bc..653768c83d784 100644 --- a/src/core/server/rendering/rendering_service.tsx +++ b/packages/core/rendering/core-rendering-server-internal/src/rendering_service.tsx @@ -8,15 +8,15 @@ import React from 'react'; import { renderToStaticMarkup } from 'react-dom/server'; +import { firstValueFrom, of } from 'rxjs'; import { catchError, take, timeout } from 'rxjs/operators'; import { i18n } from '@kbn/i18n'; import type { ThemeVersion } from '@kbn/ui-shared-deps-npm'; -import { firstValueFrom, of } from 'rxjs'; import type { CoreContext } from '@kbn/core-base-server-internal'; import type { KibanaRequest, HttpAuth } from '@kbn/core-http-server'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-server'; -import type { UiPlugins } from '../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { Template } from './views'; import { IRenderOptions, diff --git a/src/core/server/rendering/__mocks__/params.ts b/packages/core/rendering/core-rendering-server-internal/src/test_helpers/params.ts similarity index 85% rename from src/core/server/rendering/__mocks__/params.ts rename to packages/core/rendering/core-rendering-server-internal/src/test_helpers/params.ts index c75353b87a65d..51dfab71efd22 100644 --- a/src/core/server/rendering/__mocks__/params.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/test_helpers/params.ts @@ -10,7 +10,6 @@ import { mockCoreContext } from '@kbn/core-base-server-mocks'; import { httpServiceMock } from '@kbn/core-http-server-mocks'; import { elasticsearchServiceMock } from '@kbn/core-elasticsearch-server-mocks'; import { statusServiceMock } from '@kbn/core-status-server-mocks'; -import { pluginServiceMock } from '../../plugins/plugins_service.mock'; const context = mockCoreContext.create(); const httpPreboot = httpServiceMock.createInternalPrebootContract(); @@ -18,14 +17,22 @@ const httpSetup = httpServiceMock.createInternalSetupContract(); const status = statusServiceMock.createInternalSetupContract(); const elasticsearch = elasticsearchServiceMock.createInternalSetup(); +function createUiPlugins() { + return { + browserConfigs: new Map(), + internal: new Map(), + public: new Map(), + }; +} + export const mockRenderingServiceParams = context; export const mockRenderingPrebootDeps = { http: httpPreboot, - uiPlugins: pluginServiceMock.createUiPlugins(), + uiPlugins: createUiPlugins(), }; export const mockRenderingSetupDeps = { elasticsearch, http: httpSetup, - uiPlugins: pluginServiceMock.createUiPlugins(), + uiPlugins: createUiPlugins(), status, }; diff --git a/src/core/server/rendering/__mocks__/rendering_service.ts b/packages/core/rendering/core-rendering-server-internal/src/test_helpers/rendering_service.ts similarity index 100% rename from src/core/server/rendering/__mocks__/rendering_service.ts rename to packages/core/rendering/core-rendering-server-internal/src/test_helpers/rendering_service.ts diff --git a/src/core/server/rendering/types.ts b/packages/core/rendering/core-rendering-server-internal/src/types.ts similarity index 96% rename from src/core/server/rendering/types.ts rename to packages/core/rendering/core-rendering-server-internal/src/types.ts index 7068d2a9b789d..e2f7797ac5c42 100644 --- a/src/core/server/rendering/types.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/types.ts @@ -17,7 +17,7 @@ import type { import type { InternalElasticsearchServiceSetup } from '@kbn/core-elasticsearch-server-internal'; import type { InternalStatusServiceSetup } from '@kbn/core-status-server-internal'; import type { IUiSettingsClient } from '@kbn/core-ui-settings-server'; -import { UiPlugins } from '../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; /** @internal */ export interface RenderingMetadata { @@ -46,7 +46,7 @@ export interface RenderingSetupDeps { uiPlugins: UiPlugins; } -/** @public */ +/** @internal */ export interface IRenderOptions { /** * Set whether the page is anonymous, which determines what plugins are enabled and whether to output user settings in the page metadata. diff --git a/src/core/server/rendering/views/fonts.tsx b/packages/core/rendering/core-rendering-server-internal/src/views/fonts.tsx similarity index 100% rename from src/core/server/rendering/views/fonts.tsx rename to packages/core/rendering/core-rendering-server-internal/src/views/fonts.tsx diff --git a/src/core/server/rendering/views/index.ts b/packages/core/rendering/core-rendering-server-internal/src/views/index.ts similarity index 92% rename from src/core/server/rendering/views/index.ts rename to packages/core/rendering/core-rendering-server-internal/src/views/index.ts index 1aa6e658e3d29..01f395261eccf 100644 --- a/src/core/server/rendering/views/index.ts +++ b/packages/core/rendering/core-rendering-server-internal/src/views/index.ts @@ -7,3 +7,4 @@ */ export { Template } from './template'; +export { Fonts } from './fonts'; diff --git a/src/core/server/rendering/views/logo.tsx b/packages/core/rendering/core-rendering-server-internal/src/views/logo.tsx similarity index 100% rename from src/core/server/rendering/views/logo.tsx rename to packages/core/rendering/core-rendering-server-internal/src/views/logo.tsx diff --git a/src/core/server/rendering/views/styles.tsx b/packages/core/rendering/core-rendering-server-internal/src/views/styles.tsx similarity index 100% rename from src/core/server/rendering/views/styles.tsx rename to packages/core/rendering/core-rendering-server-internal/src/views/styles.tsx diff --git a/src/core/server/rendering/views/template.tsx b/packages/core/rendering/core-rendering-server-internal/src/views/template.tsx similarity index 100% rename from src/core/server/rendering/views/template.tsx rename to packages/core/rendering/core-rendering-server-internal/src/views/template.tsx diff --git a/packages/core/rendering/core-rendering-server-internal/tsconfig.json b/packages/core/rendering/core-rendering-server-internal/tsconfig.json new file mode 100644 index 0000000000000..73c8a6666ff7e --- /dev/null +++ b/packages/core/rendering/core-rendering-server-internal/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "stripInternal": false, + "types": [ + "jest", + "node", + "react", + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ] +} diff --git a/packages/core/rendering/core-rendering-server-mocks/BUILD.bazel b/packages/core/rendering/core-rendering-server-mocks/BUILD.bazel new file mode 100644 index 0000000000000..9ec36da1a1f67 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/BUILD.bazel @@ -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_DIRNAME = "core-rendering-server-mocks" +PKG_REQUIRE_NAME = "@kbn/core-rendering-server-mocks" + +SOURCE_FILES = glob( + [ + "**/*.ts", + ], + exclude = [ + "**/*.config.js", + "**/*.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/rendering/core-rendering-server-internal: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", + 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"], +) diff --git a/packages/core/rendering/core-rendering-server-mocks/README.md b/packages/core/rendering/core-rendering-server-mocks/README.md new file mode 100644 index 0000000000000..72df549319198 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/README.md @@ -0,0 +1,4 @@ +# @kbn/core-rendering-server-mocks + +This package contains mocks for Core's server-side rendering service. +- `renderingServiceMock` diff --git a/packages/core/rendering/core-rendering-server-mocks/index.ts b/packages/core/rendering/core-rendering-server-mocks/index.ts new file mode 100644 index 0000000000000..e7ce72ce797fb --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/index.ts @@ -0,0 +1,9 @@ +/* + * 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 { renderingServiceMock } from './src'; diff --git a/packages/core/rendering/core-rendering-server-mocks/jest.config.js b/packages/core/rendering/core-rendering-server-mocks/jest.config.js new file mode 100644 index 0000000000000..5dc1ae51c50b0 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/jest.config.js @@ -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: ['/packages/core/rendering/core-rendering-server-mocks'], +}; diff --git a/packages/core/rendering/core-rendering-server-mocks/kibana.jsonc b/packages/core/rendering/core-rendering-server-mocks/kibana.jsonc new file mode 100644 index 0000000000000..a04eae9cadc20 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/kibana.jsonc @@ -0,0 +1,7 @@ +{ + "type": "shared-common", + "id": "@kbn/core-rendering-server-mocks", + "owner": "@elastic/kibana-core", + "runtimeDeps": [], + "typeDeps": [], +} diff --git a/packages/core/rendering/core-rendering-server-mocks/package.json b/packages/core/rendering/core-rendering-server-mocks/package.json new file mode 100644 index 0000000000000..572e1d5530587 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/core-rendering-server-mocks", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "author": "Kibana Core", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/packages/core/rendering/core-rendering-server-mocks/src/index.ts b/packages/core/rendering/core-rendering-server-mocks/src/index.ts new file mode 100644 index 0000000000000..d56794e3e9ac6 --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/src/index.ts @@ -0,0 +1,9 @@ +/* + * 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 { renderingServiceMock } from './rendering_service.mock'; diff --git a/src/core/server/rendering/rendering_service.mock.ts b/packages/core/rendering/core-rendering-server-mocks/src/rendering_service.mock.ts similarity index 55% rename from src/core/server/rendering/rendering_service.mock.ts rename to packages/core/rendering/core-rendering-server-mocks/src/rendering_service.mock.ts index 3d8213da62c6d..5cdf5c92f9237 100644 --- a/src/core/server/rendering/rendering_service.mock.ts +++ b/packages/core/rendering/core-rendering-server-mocks/src/rendering_service.mock.ts @@ -6,7 +6,14 @@ * Side Public License, v 1. */ -import { InternalRenderingServicePreboot, InternalRenderingServiceSetup } from './types'; +import type { PublicMethodsOf } from '@kbn/utility-types'; +import type { + InternalRenderingServicePreboot, + InternalRenderingServiceSetup, + RenderingService, +} from '@kbn/core-rendering-server-internal'; + +export type RenderingServiceMock = jest.Mocked>; function createRenderingPreboot() { const mocked: jest.Mocked = { @@ -22,7 +29,21 @@ function createRenderingSetup() { return mocked; } -export const renderingMock = { +function createRenderingService() { + const mock: RenderingServiceMock = { + preboot: jest.fn(), + setup: jest.fn(), + stop: jest.fn(), + }; + + mock.preboot.mockResolvedValue(createRenderingPreboot()); + mock.setup.mockResolvedValue(createRenderingSetup()); + + return mock; +} + +export const renderingServiceMock = { + create: createRenderingService, createPrebootContract: createRenderingPreboot, createSetupContract: createRenderingSetup, }; diff --git a/packages/core/rendering/core-rendering-server-mocks/tsconfig.json b/packages/core/rendering/core-rendering-server-mocks/tsconfig.json new file mode 100644 index 0000000000000..71bb40fe57f3f --- /dev/null +++ b/packages/core/rendering/core-rendering-server-mocks/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "stripInternal": false, + "types": [ + "jest", + "node" + ] + }, + "include": [ + "**/*.ts", + ] +} diff --git a/src/core/server/core_app/bundle_routes/register_bundle_routes.test.ts b/src/core/server/core_app/bundle_routes/register_bundle_routes.test.ts index 12f3041ec53fb..f816a85404f7a 100644 --- a/src/core/server/core_app/bundle_routes/register_bundle_routes.test.ts +++ b/src/core/server/core_app/bundle_routes/register_bundle_routes.test.ts @@ -10,7 +10,7 @@ import { registerRouteForBundleMock } from './register_bundle_routes.test.mocks' import { PackageInfo } from '@kbn/config'; import { httpServiceMock } from '@kbn/core-http-server-mocks'; -import { InternalPluginInfo, UiPlugins } from '../../plugins'; +import type { InternalPluginInfo, UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { registerBundleRoutes } from './register_bundle_routes'; import { FileHashCache } from './file_hash_cache'; diff --git a/src/core/server/core_app/bundle_routes/register_bundle_routes.ts b/src/core/server/core_app/bundle_routes/register_bundle_routes.ts index 6f701b46dcc8b..4adb50fdc96ca 100644 --- a/src/core/server/core_app/bundle_routes/register_bundle_routes.ts +++ b/src/core/server/core_app/bundle_routes/register_bundle_routes.ts @@ -12,7 +12,7 @@ import { fromRoot } from '@kbn/utils'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm'; import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src'; import type { IRouter } from '@kbn/core-http-server'; -import { UiPlugins } from '../../plugins'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { FileHashCache } from './file_hash_cache'; import { registerRouteForBundle } from './bundles_route'; diff --git a/src/core/server/core_app/core_app.test.ts b/src/core/server/core_app/core_app.test.ts index 913ac2aa9ef67..76663eeed2fd1 100644 --- a/src/core/server/core_app/core_app.test.ts +++ b/src/core/server/core_app/core_app.test.ts @@ -10,9 +10,9 @@ import { registerBundleRoutesMock } from './core_app.test.mocks'; import { mockCoreContext } from '@kbn/core-base-server-mocks'; import { mockRouter } from '@kbn/core-http-router-server-mocks'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { coreMock, httpServerMock } from '../mocks'; import { httpResourcesMock } from '../http_resources/http_resources_service.mock'; -import type { UiPlugins } from '../plugins'; import { PluginType } from '../plugins'; import { CoreApp } from './core_app'; import { RequestHandlerContext } from '..'; diff --git a/src/core/server/core_app/core_app.ts b/src/core/server/core_app/core_app.ts index d6f305698fc94..b8701d7646b7e 100644 --- a/src/core/server/core_app/core_app.ts +++ b/src/core/server/core_app/core_app.ts @@ -20,10 +20,10 @@ import type { KibanaRequest, IBasePath, } from '@kbn/core-http-server'; +import type { UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { HttpResources, HttpResourcesServiceToolkit } from '../http_resources'; import { InternalCorePreboot, InternalCoreSetup } from '../internal_types'; import { registerBundleRoutes } from './bundle_routes'; -import { UiPlugins } from '../plugins'; import type { InternalCoreAppRequestHandlerContext } from './internal_types'; /** @internal */ diff --git a/src/core/server/http_resources/http_resources_service.test.ts b/src/core/server/http_resources/http_resources_service.test.ts index 47b0ef049485b..ea04f30847508 100644 --- a/src/core/server/http_resources/http_resources_service.test.ts +++ b/src/core/server/http_resources/http_resources_service.test.ts @@ -13,7 +13,7 @@ import type { RouteConfig } from '@kbn/core-http-server'; import { mockCoreContext } from '@kbn/core-base-server-mocks'; import { httpServiceMock, httpServerMock } from '@kbn/core-http-server-mocks'; import { coreMock } from '../mocks'; -import { renderingMock } from '../rendering/rendering_service.mock'; +import { renderingServiceMock } from '@kbn/core-rendering-server-mocks'; import { HttpResourcesService, PrebootDeps, SetupDeps } from './http_resources_service'; import { httpResourcesMock } from './http_resources_service.mock'; import { HttpResources } from '..'; @@ -37,11 +37,11 @@ describe('HttpResources service', () => { beforeEach(() => { prebootDeps = { http: httpServiceMock.createInternalPrebootContract(), - rendering: renderingMock.createPrebootContract(), + rendering: renderingServiceMock.createPrebootContract(), }; setupDeps = { http: httpServiceMock.createInternalSetupContract(), - rendering: renderingMock.createSetupContract(), + rendering: renderingServiceMock.createSetupContract(), }; service = new HttpResourcesService(coreContext); router = httpServiceMock.createRouter(); diff --git a/src/core/server/http_resources/http_resources_service.ts b/src/core/server/http_resources/http_resources_service.ts index 5db20bf45e409..7cc88699ea7ba 100644 --- a/src/core/server/http_resources/http_resources_service.ts +++ b/src/core/server/http_resources/http_resources_service.ts @@ -18,8 +18,11 @@ import type { InternalHttpServiceSetup, InternalHttpServicePreboot, } from '@kbn/core-http-server-internal'; +import type { + InternalRenderingServicePreboot, + InternalRenderingServiceSetup, +} from '@kbn/core-rendering-server-internal'; import type { RequestHandlerContext } from '@kbn/core-http-request-handler-context-server'; -import { InternalRenderingServicePreboot, InternalRenderingServiceSetup } from '../rendering'; import { InternalHttpResourcesSetup, HttpResources, diff --git a/src/core/server/index.ts b/src/core/server/index.ts index 020975c15fb1b..dafd53e374fe8 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -230,7 +230,6 @@ export type { HttpResourcesRequestHandler, } from './http_resources'; -export type { IRenderOptions } from './rendering'; export type { LoggingServiceSetup, LoggerContextConfigInput, diff --git a/src/core/server/internal_types.ts b/src/core/server/internal_types.ts index e744ae01d1be0..683d08fe4f849 100644 --- a/src/core/server/internal_types.ts +++ b/src/core/server/internal_types.ts @@ -58,7 +58,7 @@ import type { InternalUiSettingsServiceSetup, InternalUiSettingsServiceStart, } from '@kbn/core-ui-settings-server-internal'; -import { InternalRenderingServiceSetup } from './rendering'; +import type { InternalRenderingServiceSetup } from '@kbn/core-rendering-server-internal'; import { InternalHttpResourcesPreboot, InternalHttpResourcesSetup } from './http_resources'; /** @internal */ diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index 6c2ef712cbf56..cd0429415e7cb 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -31,6 +31,7 @@ import { coreUsageDataServiceMock } from '@kbn/core-usage-data-server-mocks'; import { i18nServiceMock } from '@kbn/core-i18n-server-mocks'; import { statusServiceMock } from '@kbn/core-status-server-mocks'; import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks'; +import { renderingServiceMock } from '@kbn/core-rendering-server-mocks'; import type { PluginInitializerContext, CoreSetup, @@ -40,7 +41,6 @@ import type { RequestHandlerContext, } from '.'; import { httpResourcesMock } from './http_resources/http_resources_service.mock'; -import { renderingMock } from './rendering/rendering_service.mock'; import { SharedGlobalConfig } from './plugins'; export { configServiceMock, configDeprecationsMock } from '@kbn/config-mocks'; @@ -57,7 +57,7 @@ export { export { migrationMocks } from '@kbn/core-saved-objects-migration-server-mocks'; export { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks'; export { metricsServiceMock } from '@kbn/core-metrics-server-mocks'; -export { renderingMock } from './rendering/rendering_service.mock'; +export { renderingServiceMock } from '@kbn/core-rendering-server-mocks'; export { statusServiceMock } from '@kbn/core-status-server-mocks'; export { contextServiceMock } from '@kbn/core-http-context-server-mocks'; export { capabilitiesServiceMock } from '@kbn/core-capabilities-server-mocks'; @@ -237,7 +237,7 @@ function createInternalCoreSetupMock() { environment: environmentServiceMock.createSetupContract(), i18n: i18nServiceMock.createSetupContract(), httpResources: httpResourcesMock.createSetupContract(), - rendering: renderingMock.createSetupContract(), + rendering: renderingServiceMock.createSetupContract(), uiSettings: uiSettingsServiceMock.createSetupContract(), logging: loggingServiceMock.createInternalSetupContract(), metrics: metricsServiceMock.createInternalSetupContract(), diff --git a/src/core/server/plugins/index.ts b/src/core/server/plugins/index.ts index 1b655ccd8bd98..2111d467ef3c2 100644 --- a/src/core/server/plugins/index.ts +++ b/src/core/server/plugins/index.ts @@ -10,7 +10,6 @@ export { PluginsService } from './plugins_service'; export type { PluginsServiceSetup, PluginsServiceStart, - UiPlugins, DiscoveredPlugins, } from './plugins_service'; export { config } from './plugins_config'; diff --git a/src/core/server/plugins/plugins_service.ts b/src/core/server/plugins/plugins_service.ts index a95619f3bc453..3305ff0a06b43 100644 --- a/src/core/server/plugins/plugins_service.ts +++ b/src/core/server/plugins/plugins_service.ts @@ -17,15 +17,10 @@ import type { CoreContext, CoreService } from '@kbn/core-base-server-internal'; import type { PluginName } from '@kbn/core-base-common'; import type { InternalEnvironmentServicePreboot } from '@kbn/core-environment-server-internal'; import type { InternalNodeServicePreboot } from '@kbn/core-node-server-internal'; +import type { InternalPluginInfo, UiPlugins } from '@kbn/core-plugins-base-server-internal'; import { discover, PluginDiscoveryError, PluginDiscoveryErrorType } from './discovery'; import { PluginWrapper } from './plugin'; -import { - DiscoveredPlugin, - InternalPluginInfo, - PluginConfigDescriptor, - PluginDependencies, - PluginType, -} from './types'; +import { DiscoveredPlugin, PluginConfigDescriptor, PluginDependencies, PluginType } from './types'; import { PluginsConfig, PluginsConfigType } from './plugins_config'; import { PluginsSystem } from './plugins_system'; import { createBrowserConfig } from './create_browser_config'; @@ -48,25 +43,6 @@ export interface PluginsServiceSetup { contracts: Map; } -/** @internal */ -export interface UiPlugins { - /** - * Paths to all discovered ui plugin entrypoints on the filesystem, even if - * disabled. - */ - internal: Map; - - /** - * Information needed by client-side to load plugins and wire dependencies. - */ - public: Map; - - /** - * Configuration for plugins to be exposed to the client-side. - */ - browserConfigs: Map>; -} - /** @internal */ export interface PluginsServiceStart { /** Start contracts returned by plugins. */ diff --git a/src/core/server/plugins/types.ts b/src/core/server/plugins/types.ts index f8b20b66f5069..699631bc4411e 100644 --- a/src/core/server/plugins/types.ts +++ b/src/core/server/plugins/types.ts @@ -254,28 +254,6 @@ export interface PluginManifest { readonly enabledOnAnonymousPages?: boolean; } -/** - * @internal - */ -export interface InternalPluginInfo { - /** - * Version of the plugin - */ - readonly version: string; - /** - * Bundles that must be loaded for this plugin - */ - readonly requiredBundles: readonly string[]; - /** - * Path to the target/public directory of the plugin which should be served - */ - readonly publicTargetDir: string; - /** - * Path to the plugin assets directory. - */ - readonly publicAssetsDir: string; -} - /** * The interface that should be returned by a `PluginInitializer` for a `preboot` plugin. * diff --git a/src/core/server/server.test.mocks.ts b/src/core/server/server.test.mocks.ts index dec2b17ae8c61..3e1d5c0e3a28f 100644 --- a/src/core/server/server.test.mocks.ts +++ b/src/core/server/server.test.mocks.ts @@ -63,10 +63,12 @@ jest.doMock('@kbn/core-config-server-internal', () => ({ ensureValidConfiguration: mockEnsureValidConfiguration, })); -import { RenderingService, mockRenderingService } from './rendering/__mocks__/rendering_service'; +import { renderingServiceMock } from '@kbn/core-rendering-server-mocks'; -export { mockRenderingService }; -jest.doMock('./rendering/rendering_service', () => ({ RenderingService })); +export const mockRenderingService = renderingServiceMock.create(); +jest.doMock('@kbn/core-rendering-server-internal', () => ({ + RenderingService: jest.fn(() => mockRenderingService), +})); import { environmentServiceMock } from '@kbn/core-environment-server-mocks'; diff --git a/src/core/server/server.ts b/src/core/server/server.ts index e333e8b81a404..b7f41dd31dd04 100644 --- a/src/core/server/server.ts +++ b/src/core/server/server.ts @@ -66,10 +66,10 @@ import type { RequestHandlerContext, PrebootRequestHandlerContext, } from '@kbn/core-http-request-handler-context-server'; +import { RenderingService } from '@kbn/core-rendering-server-internal'; import { CoreApp } from './core_app'; import { HttpResourcesService } from './http_resources'; -import { RenderingService } from './rendering'; import { PluginsService, config as pluginsConfig } from './plugins'; import { InternalCorePreboot, InternalCoreSetup, InternalCoreStart } from './internal_types'; import { DiscoveredPlugins } from './plugins'; diff --git a/x-pack/plugins/security/server/authentication/unauthenticated_page.test.tsx b/x-pack/plugins/security/server/authentication/unauthenticated_page.test.tsx index 708ca11ca8f78..aca2a5dd77e6c 100644 --- a/x-pack/plugins/security/server/authentication/unauthenticated_page.test.tsx +++ b/x-pack/plugins/security/server/authentication/unauthenticated_page.test.tsx @@ -12,7 +12,7 @@ import { coreMock } from '@kbn/core/server/mocks'; import { UnauthenticatedPage } from './unauthenticated_page'; -jest.mock('@kbn/core/server/rendering/views/fonts', () => ({ +jest.mock('@kbn/core-rendering-server-internal', () => ({ Fonts: () => <>MockedFonts, })); diff --git a/x-pack/plugins/security/server/authorization/reset_session_page.test.tsx b/x-pack/plugins/security/server/authorization/reset_session_page.test.tsx index d5bce1e146eb1..8111246f0776d 100644 --- a/x-pack/plugins/security/server/authorization/reset_session_page.test.tsx +++ b/x-pack/plugins/security/server/authorization/reset_session_page.test.tsx @@ -12,7 +12,7 @@ import { coreMock } from '@kbn/core/server/mocks'; import { ResetSessionPage } from './reset_session_page'; -jest.mock('@kbn/core/server/rendering/views/fonts', () => ({ +jest.mock('@kbn/core-rendering-server-internal', () => ({ Fonts: () => <>MockedFonts, })); diff --git a/x-pack/plugins/security/server/prompt_page.test.tsx b/x-pack/plugins/security/server/prompt_page.test.tsx index 11b45f62f05d6..ef59cacd31bfc 100644 --- a/x-pack/plugins/security/server/prompt_page.test.tsx +++ b/x-pack/plugins/security/server/prompt_page.test.tsx @@ -12,7 +12,7 @@ import { coreMock } from '@kbn/core/server/mocks'; import { PromptPage } from './prompt_page'; -jest.mock('@kbn/core/server/rendering/views/fonts', () => ({ +jest.mock('@kbn/core-rendering-server-internal', () => ({ Fonts: () => <>MockedFonts, })); diff --git a/x-pack/plugins/security/server/prompt_page.tsx b/x-pack/plugins/security/server/prompt_page.tsx index e15574d5af4ef..14f59df15db39 100644 --- a/x-pack/plugins/security/server/prompt_page.tsx +++ b/x-pack/plugins/security/server/prompt_page.tsx @@ -20,8 +20,8 @@ import createCache from '@emotion/cache'; import type { ReactNode } from 'react'; import React from 'react'; +import { Fonts } from '@kbn/core-rendering-server-internal'; import type { IBasePath } from '@kbn/core/server'; -import { Fonts } from '@kbn/core/server/rendering/views/fonts'; import { i18n } from '@kbn/i18n'; import { I18nProvider } from '@kbn/i18n-react'; import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm'; diff --git a/yarn.lock b/yarn.lock index 968956a15ccfa..b9db4636175d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3118,6 +3118,10 @@ version "0.0.0" uid "" +"@kbn/core-plugins-base-server-internal@link:bazel-bin/packages/core/plugins/core-plugins-base-server-internal": + version "0.0.0" + uid "" + "@kbn/core-plugins-browser-internal@link:bazel-bin/packages/core/plugins/core-plugins-browser-internal": version "0.0.0" uid "" @@ -3150,6 +3154,14 @@ version "0.0.0" uid "" +"@kbn/core-rendering-server-internal@link:bazel-bin/packages/core/rendering/core-rendering-server-internal": + version "0.0.0" + uid "" + +"@kbn/core-rendering-server-mocks@link:bazel-bin/packages/core/rendering/core-rendering-server-mocks": + version "0.0.0" + uid "" + "@kbn/core-root-browser-internal@link:bazel-bin/packages/core/root/core-root-browser-internal": version "0.0.0" uid "" @@ -7251,6 +7263,10 @@ version "0.0.0" uid "" +"@types/kbn__core-plugins-base-server-internal@link:bazel-bin/packages/core/plugins/core-plugins-base-server-internal/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__core-plugins-browser-internal@link:bazel-bin/packages/core/plugins/core-plugins-browser-internal/npm_module_types": version "0.0.0" uid "" @@ -7287,6 +7303,14 @@ version "0.0.0" uid "" +"@types/kbn__core-rendering-server-internal@link:bazel-bin/packages/core/rendering/core-rendering-server-internal/npm_module_types": + version "0.0.0" + uid "" + +"@types/kbn__core-rendering-server-mocks@link:bazel-bin/packages/core/rendering/core-rendering-server-mocks/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__core-root-browser-internal@link:bazel-bin/packages/core/root/core-root-browser-internal/npm_module_types": version "0.0.0" uid ""