Skip to content

Commit

Permalink
Migrate server-side rendering service to packages (elastic#141902)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2 people authored and WafaaNasr committed Oct 14, 2022
1 parent c94c383 commit e1adec3
Show file tree
Hide file tree
Showing 79 changed files with 705 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
107 changes: 107 additions & 0 deletions packages/core/plugins/core-plugins-base-server-internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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';
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/plugins/core-plugins-base-server-internal'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "shared-common",
"id": "@kbn/core-plugins-base-server-internal",
"owner": "@elastic/kibana-core",
"runtimeDeps": [],
"typeDeps": [],
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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<PluginName, InternalPluginInfo>;

/**
* Information needed by client-side to load plugins and wire dependencies.
*/
public: Map<PluginName, DiscoveredPlugin>;

/**
* Configuration for plugins to be exposed to the client-side.
*/
browserConfigs: Map<PluginName, Observable<unknown>>;
}

/**
* @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;
}
Original file line number Diff line number Diff line change
@@ -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",
]
}
Loading

0 comments on commit e1adec3

Please sign in to comment.