mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Migrate browser-side integrations service to packages (#136514)
* create empty packages * move files to packages * adapt imports * add copy-files argument
This commit is contained in:
parent
e8044a9bc3
commit
0aa12c36fd
29 changed files with 361 additions and 10 deletions
|
@ -199,6 +199,8 @@
|
|||
"@kbn/core-injected-metadata-browser-internal": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-internal",
|
||||
"@kbn/core-injected-metadata-browser-mocks": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-mocks",
|
||||
"@kbn/core-injected-metadata-common-internal": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-common-internal",
|
||||
"@kbn/core-integrations-browser-internal": "link:bazel-bin/packages/core/integrations/core-integrations-browser-internal",
|
||||
"@kbn/core-integrations-browser-mocks": "link:bazel-bin/packages/core/integrations/core-integrations-browser-mocks",
|
||||
"@kbn/core-logging-server": "link:bazel-bin/packages/core/logging/core-logging-server",
|
||||
"@kbn/core-logging-server-internal": "link:bazel-bin/packages/core/logging/core-logging-server-internal",
|
||||
"@kbn/core-logging-server-mocks": "link:bazel-bin/packages/core/logging/core-logging-server-mocks",
|
||||
|
@ -785,6 +787,8 @@
|
|||
"@types/kbn__core-injected-metadata-browser-internal": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-injected-metadata-browser-mocks": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-browser-mocks/npm_module_types",
|
||||
"@types/kbn__core-injected-metadata-common-internal": "link:bazel-bin/packages/core/injected-metadata/core-injected-metadata-common-internal/npm_module_types",
|
||||
"@types/kbn__core-integrations-browser-internal": "link:bazel-bin/packages/core/integrations/core-integrations-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-integrations-browser-mocks": "link:bazel-bin/packages/core/integrations/core-integrations-browser-mocks/npm_module_types",
|
||||
"@types/kbn__core-logging-server": "link:bazel-bin/packages/core/logging/core-logging-server/npm_module_types",
|
||||
"@types/kbn__core-logging-server-internal": "link:bazel-bin/packages/core/logging/core-logging-server-internal/npm_module_types",
|
||||
"@types/kbn__core-logging-server-mocks": "link:bazel-bin/packages/core/logging/core-logging-server-mocks/npm_module_types",
|
||||
|
|
|
@ -67,6 +67,8 @@ filegroup(
|
|||
"//packages/core/injected-metadata/core-injected-metadata-browser-mocks:build",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser:build",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-common-internal:build",
|
||||
"//packages/core/integrations/core-integrations-browser-internal:build",
|
||||
"//packages/core/integrations/core-integrations-browser-mocks:build",
|
||||
"//packages/core/logging/core-logging-server-internal:build",
|
||||
"//packages/core/logging/core-logging-server-mocks:build",
|
||||
"//packages/core/logging/core-logging-server:build",
|
||||
|
@ -275,6 +277,8 @@ filegroup(
|
|||
"//packages/core/injected-metadata/core-injected-metadata-browser-mocks:build_types",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-browser:build_types",
|
||||
"//packages/core/injected-metadata/core-injected-metadata-common-internal:build_types",
|
||||
"//packages/core/integrations/core-integrations-browser-internal:build_types",
|
||||
"//packages/core/integrations/core-integrations-browser-mocks:build_types",
|
||||
"//packages/core/logging/core-logging-server-internal:build_types",
|
||||
"//packages/core/logging/core-logging-server-mocks:build_types",
|
||||
"//packages/core/logging/core-logging-server:build_types",
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
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-integrations-browser-internal"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-integrations-browser-internal"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.css",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
"@npm//rxjs",
|
||||
"@npm//moment-timezone",
|
||||
### test dependencies
|
||||
"//packages/core/ui-settings/core-ui-settings-browser-mocks"
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"@npm//@types/moment-timezone",
|
||||
"@npm//rxjs",
|
||||
"//packages/core/base/core-base-browser-internal:npm_module_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-browser:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_web",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
web = True,
|
||||
additional_args = [
|
||||
"--copy-files",
|
||||
"--quiet"
|
||||
],
|
||||
)
|
||||
|
||||
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 = "src",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-integrations-browser-internal
|
||||
|
||||
Empty package generated by @kbn/generate
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/integrations/core-integrations-browser-internal'],
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@kbn/core-integrations-browser-internal",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"browser": "./target_web/index.js",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -7,3 +7,4 @@
|
|||
*/
|
||||
|
||||
export { IntegrationsService } from './integrations_service';
|
||||
export type { IntegrationsServiceSetupDeps } from './integrations_service';
|
|
@ -12,7 +12,7 @@ import type { IUiSettingsClient } from '@kbn/core-ui-settings-browser';
|
|||
import { MomentService } from './moment';
|
||||
import { StylesService } from './styles';
|
||||
|
||||
export interface Deps {
|
||||
export interface IntegrationsServiceSetupDeps {
|
||||
uiSettings: IUiSettingsClient;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ export class IntegrationsService implements CoreService {
|
|||
await this.moment.setup();
|
||||
}
|
||||
|
||||
public async start({ uiSettings }: Deps) {
|
||||
public async start({ uiSettings }: IntegrationsServiceSetupDeps) {
|
||||
await this.styles.start({ uiSettings });
|
||||
await this.moment.start({ uiSettings });
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
/**
|
||||
* `react-beautiful-dnd` relies on `transition` for functionality
|
||||
* https://github.com/elastic/kibana/issues/95133
|
||||
* https://github.com/elastic/kibana/issues/95133
|
||||
*/
|
||||
*:not(.essentialAnimation):not([data-rbd-draggable-context-id]):not([data-rbd-droppable-context-id]),
|
||||
*:not(.essentialAnimation):before,
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": "src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node",
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
|
@ -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-integrations-browser-mocks"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-integrations-browser-mocks"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
],
|
||||
)
|
||||
|
||||
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/integrations/core-integrations-browser-internal:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_web",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
web = True,
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
root_dir = "src",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node", ":target_web"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-integrations-browser-mocks
|
||||
|
||||
This package contains the mocks from core's browser-side internal integration service.
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/integrations/core-integrations-browser-mocks'],
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@kbn/core-integrations-browser-mocks",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"browser": "./target_web/index.js",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -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.
|
||||
*/
|
||||
|
||||
export { integrationsServiceMock } from './integrations_service.mock';
|
||||
export type {
|
||||
IntegrationsServiceContract,
|
||||
IntegrationsServiceMock,
|
||||
} from './integrations_service.mock';
|
|
@ -7,10 +7,12 @@
|
|||
*/
|
||||
|
||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import { IntegrationsService } from './integrations_service';
|
||||
import type { IntegrationsService } from '@kbn/core-integrations-browser-internal';
|
||||
|
||||
type IntegrationsServiceContract = PublicMethodsOf<IntegrationsService>;
|
||||
const createMock = (): jest.Mocked<IntegrationsServiceContract> => ({
|
||||
export type IntegrationsServiceContract = PublicMethodsOf<IntegrationsService>;
|
||||
export type IntegrationsServiceMock = jest.Mocked<IntegrationsServiceContract>;
|
||||
|
||||
const createMock = (): IntegrationsServiceMock => ({
|
||||
setup: jest.fn(),
|
||||
start: jest.fn(),
|
||||
stop: jest.fn(),
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": "src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node",
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
|
@ -20,7 +20,7 @@ import { overlayServiceMock } from './overlays/overlay_service.mock';
|
|||
import { pluginsServiceMock } from './plugins/plugins_service.mock';
|
||||
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-browser-mocks';
|
||||
import { renderingServiceMock } from './rendering/rendering_service.mock';
|
||||
import { integrationsServiceMock } from './integrations/integrations_service.mock';
|
||||
import { integrationsServiceMock } from '@kbn/core-integrations-browser-mocks';
|
||||
import { coreAppMock } from './core_app/core_app.mock';
|
||||
|
||||
export const analyticsServiceStartMock = analyticsServiceMock.createAnalyticsServiceStart();
|
||||
|
@ -122,7 +122,7 @@ export const MockIntegrationsService = integrationsServiceMock.create();
|
|||
export const IntegrationsServiceConstructor = jest
|
||||
.fn()
|
||||
.mockImplementation(() => MockIntegrationsService);
|
||||
jest.doMock('./integrations', () => ({
|
||||
jest.doMock('@kbn/core-integrations-browser-internal', () => ({
|
||||
IntegrationsService: IntegrationsServiceConstructor,
|
||||
}));
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import { FatalErrorsService } from '@kbn/core-fatal-errors-browser-internal';
|
|||
import { HttpService } from '@kbn/core-http-browser-internal';
|
||||
import { UiSettingsService } from '@kbn/core-ui-settings-browser-internal';
|
||||
import { DeprecationsService } from '@kbn/core-deprecations-browser-internal';
|
||||
import { IntegrationsService } from '@kbn/core-integrations-browser-internal';
|
||||
import { CoreSetup, CoreStart } from '.';
|
||||
import { ChromeService } from './chrome';
|
||||
import { NotificationsService } from './notifications';
|
||||
|
@ -33,7 +34,6 @@ import { PluginsService } from './plugins';
|
|||
import { ApplicationService } from './application';
|
||||
import { RenderingService } from './rendering';
|
||||
import { SavedObjectsService } from './saved_objects';
|
||||
import { IntegrationsService } from './integrations';
|
||||
import { CoreApp } from './core_app';
|
||||
import type { InternalApplicationSetup, InternalApplicationStart } from './application/types';
|
||||
import { fetchOptionalMemoryInfo } from './fetch_optional_memory_info';
|
||||
|
|
16
yarn.lock
16
yarn.lock
|
@ -3283,6 +3283,14 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-integrations-browser-internal@link:bazel-bin/packages/core/integrations/core-integrations-browser-internal":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-integrations-browser-mocks@link:bazel-bin/packages/core/integrations/core-integrations-browser-mocks":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/core-logging-server-internal@link:bazel-bin/packages/core/logging/core-logging-server-internal":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
@ -6953,6 +6961,14 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-integrations-browser-internal@link:bazel-bin/packages/core/integrations/core-integrations-browser-internal/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-integrations-browser-mocks@link:bazel-bin/packages/core/integrations/core-integrations-browser-mocks/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@types/kbn__core-logging-server-internal@link:bazel-bin/packages/core/logging/core-logging-server-internal/npm_module_types":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue