Create packages for browser-side fatalErrors service (#134962)

This commit is contained in:
Christiane (Tina) Heiligers 2022-06-23 12:29:44 -07:00 committed by GitHub
parent acfd0517a2
commit f68999d631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 632 additions and 84 deletions

View file

@ -7,7 +7,11 @@
"bfetch": "src/plugins/bfetch",
"charts": "src/plugins/charts",
"console": "src/plugins/console",
"core": ["src/core", "packages/core/i18n/core-i18n-browser-internal"],
"core": [
"src/core",
"packages/core/i18n/core-i18n-browser-internal",
"packages/core/fatal-errors/core-fatal-errors-browser-internal"
],
"customIntegrations": "src/plugins/custom_integrations",
"dashboard": "src/plugins/dashboard",
"controls": "src/plugins/controls",

View file

@ -167,6 +167,9 @@
"@kbn/core-doc-links-server": "link:bazel-bin/packages/core/doc-links/core-doc-links-server",
"@kbn/core-doc-links-server-internal": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-internal",
"@kbn/core-doc-links-server-mocks": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-mocks",
"@kbn/core-fatal-errors-browser": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser",
"@kbn/core-fatal-errors-browser-internal": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal",
"@kbn/core-fatal-errors-browser-mocks": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks",
"@kbn/core-i18n-browser": "link:bazel-bin/packages/core/i18n/core-i18n-browser",
"@kbn/core-i18n-browser-internal": "link:bazel-bin/packages/core/i18n/core-i18n-browser-internal",
"@kbn/core-i18n-browser-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-browser-mocks",
@ -705,6 +708,9 @@
"@types/kbn__core-doc-links-server": "link:bazel-bin/packages/core/doc-links/core-doc-links-server/npm_module_types",
"@types/kbn__core-doc-links-server-internal": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-internal/npm_module_types",
"@types/kbn__core-doc-links-server-mocks": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-mocks/npm_module_types",
"@types/kbn__core-fatal-errors-browser": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser/npm_module_types",
"@types/kbn__core-fatal-errors-browser-internal": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal/npm_module_types",
"@types/kbn__core-fatal-errors-browser-mocks": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks/npm_module_types",
"@types/kbn__core-i18n-browser": "link:bazel-bin/packages/core/i18n/core-i18n-browser/npm_module_types",
"@types/kbn__core-i18n-browser-internal": "link:bazel-bin/packages/core/i18n/core-i18n-browser-internal/npm_module_types",
"@types/kbn__core-i18n-browser-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-browser-mocks/npm_module_types",

View file

@ -33,6 +33,9 @@ filegroup(
"//packages/core/doc-links/core-doc-links-server-internal:build",
"//packages/core/doc-links/core-doc-links-server-mocks:build",
"//packages/core/doc-links/core-doc-links-server:build",
"//packages/core/fatal-errors/core-fatal-errors-browser-internal:build",
"//packages/core/fatal-errors/core-fatal-errors-browser-mocks:build",
"//packages/core/fatal-errors/core-fatal-errors-browser:build",
"//packages/core/i18n/core-i18n-browser-internal:build",
"//packages/core/i18n/core-i18n-browser-mocks:build",
"//packages/core/i18n/core-i18n-browser:build",
@ -193,6 +196,9 @@ filegroup(
"//packages/core/doc-links/core-doc-links-server-internal:build_types",
"//packages/core/doc-links/core-doc-links-server-mocks:build_types",
"//packages/core/doc-links/core-doc-links-server:build_types",
"//packages/core/fatal-errors/core-fatal-errors-browser-internal:build_types",
"//packages/core/fatal-errors/core-fatal-errors-browser-mocks:build_types",
"//packages/core/fatal-errors/core-fatal-errors-browser:build_types",
"//packages/core/i18n/core-i18n-browser-internal:build_types",
"//packages/core/i18n/core-i18n-browser-mocks:build_types",
"//packages/core/i18n/core-i18n-browser:build_types",

View file

@ -0,0 +1,125 @@
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-fatal-errors-browser-internal"
PKG_REQUIRE_NAME = "@kbn/core-fatal-errors-browser-internal"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//react",
"@npm//react-dom",
"@npm//rxjs",
"@npm//@elastic/eui",
"//packages/core/theme/core-theme-browser-internal",
"//packages/core/theme/core-theme-browser-mocks",
"//packages/core/injected-metadata/core-injected-metadata-browser-mocks",
"//packages/kbn-i18n-react",
"//packages/kbn-test-jest-helpers",
"//packages/kbn-test-subj-selector",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//@types/react-dom",
"@npm//rxjs",
"@npm//@elastic/eui",
"//packages/core/injected-metadata/core-injected-metadata-browser-internal:npm_module_types",
"//packages/core/theme/core-theme-browser:npm_module_types",
"//packages/core/theme/core-theme-browser-internal:npm_module_types",
"//packages/core/i18n/core-i18n-browser:npm_module_types",
"//packages/core/fatal-errors/core-fatal-errors-browser:npm_module_types",
"//packages/kbn-i18n-react:npm_module_types",
"//packages/kbn-test-jest-helpers",
"//packages/kbn-test-subj-selector",
]
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,
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"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-fatal-errors-browser-internal
This package contains the implementation and internal types of the browser-side fatalErrors service.

View file

@ -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/fatal-errors/core-fatal-errors-browser-internal'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-fatal-errors-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"
}

View file

@ -9,7 +9,7 @@
import { EuiCallOut } from '@elastic/eui';
import testSubjSelector from '@kbn/test-subj-selector';
import React from 'react';
import * as Rx from 'rxjs';
import { of, ReplaySubject } from 'rxjs';
import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers';
import { FatalErrorsScreen } from './fatal_errors_screen';
@ -27,7 +27,7 @@ describe('FatalErrorsScreen', () => {
const defaultProps = {
buildNumber: 123,
kibanaVersion: 'bar',
errorInfo$: Rx.of(errorInfoFoo, errorInfoBar),
errorInfo$: of(errorInfoFoo, errorInfoBar),
};
const noop = () => {
@ -67,7 +67,7 @@ describe('FatalErrorsScreen', () => {
});
it('rerenders when errorInfo$ emits more errors', () => {
const errorInfo$ = new Rx.ReplaySubject<typeof errorInfoFoo>();
const errorInfo$ = new ReplaySubject<typeof errorInfoFoo>();
const el = shallowWithIntl(<FatalErrorsScreen {...defaultProps} errorInfo$={errorInfo$} />);

View file

@ -17,17 +17,16 @@ import {
EuiPageContent,
} from '@elastic/eui';
import React from 'react';
import * as Rx from 'rxjs';
import { tap } from 'rxjs/operators';
import { Observable, Subscription, merge, tap, fromEvent } from 'rxjs';
import { FormattedMessage } from '@kbn/i18n-react';
import { FatalErrorInfo } from './get_error_info';
import { FatalErrorInfo } from '@kbn/core-fatal-errors-browser';
interface Props {
kibanaVersion: string;
buildNumber: number;
errorInfo$: Rx.Observable<FatalErrorInfo>;
errorInfo$: Observable<FatalErrorInfo>;
}
interface State {
@ -39,12 +38,12 @@ export class FatalErrorsScreen extends React.Component<Props, State> {
errors: [],
};
private subscription?: Rx.Subscription;
private subscription?: Subscription;
public componentDidMount() {
this.subscription = Rx.merge(
this.subscription = merge(
// reload the page if hash-based navigation is attempted
Rx.fromEvent(window, 'hashchange').pipe(
fromEvent(window, 'hashchange').pipe(
tap(() => {
window.location.reload();
})

View file

@ -6,10 +6,10 @@
* Side Public License, v 1.
*/
import * as Rx from 'rxjs';
import { Observable } from 'rxjs';
expect.addSnapshotSerializer({
test: (val) => val instanceof Rx.Observable,
test: (val) => val instanceof Observable,
print: () => `Rx.Observable`,
});

View file

@ -8,55 +8,26 @@
import React from 'react';
import { render } from 'react-dom';
import * as Rx from 'rxjs';
import { first, tap } from 'rxjs/operators';
import { ReplaySubject, first, tap } from 'rxjs';
import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal';
import type { ThemeServiceSetup } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '../utils';
import type { FatalErrorInfo, FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import { FatalErrorsScreen } from './fatal_errors_screen';
import { FatalErrorInfo, getErrorInfo } from './get_error_info';
import { getErrorInfo } from './get_error_info';
export interface Deps {
/** @internal */
export interface FatalErrorsServiceSetupDeps {
i18n: I18nStart;
theme: ThemeServiceSetup;
injectedMetadata: InternalInjectedMetadataSetup;
}
/**
* FatalErrors stop the Kibana Public Core and displays a fatal error screen
* with details about the Kibana build and the error.
*
* @public
*/
export interface FatalErrorsSetup {
/**
* Add a new fatal error. This will stop the Kibana Public Core and display
* a fatal error screen with details about the Kibana build and the error.
*
* @param error - The error to display
* @param source - Adds a prefix of the form `${source}: ` to the error message
*/
add: (error: string | Error, source?: string) => never;
/**
* An Observable that will emit whenever a fatal error is added with `add()`
*/
get$: () => Rx.Observable<FatalErrorInfo>;
}
/**
* FatalErrors stop the Kibana Public Core and displays a fatal error screen
* with details about the Kibana build and the error.
*
* @public
*/
export type FatalErrorsStart = FatalErrorsSetup;
/** @internal */
export class FatalErrorsService {
private readonly errorInfo$ = new Rx.ReplaySubject<FatalErrorInfo>();
private readonly errorInfo$ = new ReplaySubject<FatalErrorInfo>();
private fatalErrors?: FatalErrorsSetup;
/**
@ -67,7 +38,7 @@ export class FatalErrorsService {
*/
constructor(private rootDomElement: HTMLElement, private onFirstErrorCb: () => void) {}
public setup(deps: Deps) {
public setup(deps: FatalErrorsServiceSetupDeps) {
this.errorInfo$
.pipe(
first(),
@ -115,7 +86,7 @@ export class FatalErrorsService {
return fatalErrors;
}
private renderError({ i18n, theme, injectedMetadata }: Deps) {
private renderError({ i18n, theme, injectedMetadata }: FatalErrorsServiceSetupDeps) {
// delete all content in the rootDomElement
this.rootDomElement.textContent = '';

View file

@ -7,7 +7,7 @@
*/
import { inspect } from 'util';
import type { FatalErrorInfo } from '@kbn/core-fatal-errors-browser';
/**
* Produce a string version of an error,
*/
@ -63,13 +63,3 @@ export function getErrorInfo(error: any, source?: string): FatalErrorInfo {
stack: formatStack(error),
};
}
/**
* Represents the `message` and `stack` of a fatal Error
*
* @public
* */
export interface FatalErrorInfo {
message: string;
stack: string | undefined;
}

View file

@ -7,5 +7,4 @@
*/
export { FatalErrorsService } from './fatal_errors_service';
export type { FatalErrorsSetup, FatalErrorsStart } from './fatal_errors_service';
export type { FatalErrorInfo } from './get_error_info';
export type { FatalErrorsServiceSetupDeps } from './fatal_errors_service';

View file

@ -0,0 +1,18 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -0,0 +1,109 @@
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-fatal-errors-browser-mocks"
PKG_REQUIRE_NAME = "@kbn/core-fatal-errors-browser-mocks"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//react",
"//packages/core/fatal-errors/core-fatal-errors-browser-internal",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"//packages/core/fatal-errors/core-fatal-errors-browser:npm_module_types",
"//packages/core/fatal-errors/core-fatal-errors-browser-internal:npm_module_types",
"//packages/kbn-utility-types: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,
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"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-fatal-errors-browser-mocks
This package contains the mocks for Core's fatalErrors service.

View file

@ -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/fatal-errors/core-fatal-errors-browser-mocks'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-fatal-errors-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"
}

View file

@ -7,7 +7,8 @@
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { FatalErrorsService, FatalErrorsSetup } from './fatal_errors_service';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
import { FatalErrorsService } from '@kbn/core-fatal-errors-browser-internal';
const createSetupContractMock = () => {
const setupContract: jest.Mocked<FatalErrorsSetup> = {

View file

@ -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 { fatalErrorsServiceMock } from './fatal_errors_service.mock';

View file

@ -0,0 +1,18 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -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-fatal-errors-browser"
PKG_REQUIRE_NAME = "@kbn/core-fatal-errors-browser"
SOURCE_FILES = glob(
[
"src/**/*.ts",
"src/**/*.tsx",
],
exclude = [
"**/*.test.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//react"
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/react",
"@npm//rxjs",
]
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,
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"],
)

View file

@ -0,0 +1,3 @@
# @kbn/core-fatal-errors-browser
This package contains the browser public types for the fatalErrors core service.

View file

@ -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/fatal-errors/core-fatal-errors-browser'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-fatal-errors-browser",
"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"
}

View file

@ -0,0 +1,38 @@
/*
* 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 { FatalErrorInfo } from './get_error_info';
/**
* FatalErrors stop the Kibana Public Core and displays a fatal error screen
* with details about the Kibana build and the error.
*
* @public
*/
export interface FatalErrorsSetup {
/**
* Add a new fatal error. This will stop the Kibana Public Core and display
* a fatal error screen with details about the Kibana build and the error.
*
* @param error - The error to display
* @param source - Adds a prefix of the form `${source}: ` to the error message
*/
add: (error: string | Error, source?: string) => never;
/**
* An Observable that will emit whenever a fatal error is added with `add()`
*/
get$: () => Observable<FatalErrorInfo>;
}
/**
* FatalErrors stop the Kibana Public Core and displays a fatal error screen
* with details about the Kibana build and the error.
*
* @public
*/
export type FatalErrorsStart = FatalErrorsSetup;

View file

@ -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.
*/
/**
* Represents the `message` and `stack` of a fatal Error
*
* @public
* */
export interface FatalErrorInfo {
message: string;
stack: string | undefined;
}

View file

@ -0,0 +1,10 @@
/*
* 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 { FatalErrorsSetup, FatalErrorsStart } from './contract';
export type { FatalErrorInfo } from './get_error_info';

View file

@ -0,0 +1,18 @@
{
"extends": "../../../../tsconfig.bazel.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "target_types",
"rootDir": "src",
"stripInternal": false,
"types": [
"jest",
"node",
"react"
]
},
"include": [
"src/**/*"
]
}

View file

@ -46,6 +46,7 @@ TYPES_DEPS = [
"//packages/core/base/core-base-common:npm_module_types",
"//packages/core/injected-metadata/core-injected-metadata-browser-internal:npm_module_types",
"//packages/core/theme/core-theme-browser:npm_module_types",
"//packages/core/i18n/core-i18n-browser:npm_module_types",
]
jsts_transpiler(

View file

@ -8,8 +8,8 @@
import React, { FC } from 'react';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import { CoreThemeProvider } from '@kbn/core-theme-browser-internal';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreThemeProvider } from './core_theme_provider';
interface CoreContextProviderProps {
theme: ThemeServiceStart;

View file

@ -9,3 +9,4 @@
export { ThemeService } from './theme_service';
export { CoreThemeProvider } from './core_theme_provider';
export type { ThemeServiceSetupDeps } from './theme_service';
export { CoreContextProvider } from './core_context_provider';

View file

@ -12,7 +12,7 @@ import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { applicationServiceMock } from './application/application_service.mock';
import { chromeServiceMock } from './chrome/chrome_service.mock';
import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { httpServiceMock } from './http/http_service.mock';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { notificationServiceMock } from './notifications/notifications_service.mock';
@ -48,7 +48,7 @@ export const MockFatalErrorsService = fatalErrorsServiceMock.create();
export const FatalErrorsServiceConstructor = jest
.fn()
.mockImplementation(() => MockFatalErrorsService);
jest.doMock('./fatal_errors', () => ({
jest.doMock('@kbn/core-fatal-errors-browser-internal', () => ({
FatalErrorsService: FatalErrorsServiceConstructor,
}));

View file

@ -18,9 +18,10 @@ import { ThemeService } from '@kbn/core-theme-browser-internal';
import type { AnalyticsServiceSetup, AnalyticsServiceStart } from '@kbn/core-analytics-browser';
import { AnalyticsService } from '@kbn/core-analytics-browser-internal';
import { I18nService } from '@kbn/core-i18n-browser-internal';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
import { FatalErrorsService } from '@kbn/core-fatal-errors-browser-internal';
import { CoreSetup, CoreStart } from '.';
import { ChromeService } from './chrome';
import { FatalErrorsService, FatalErrorsSetup } from './fatal_errors';
import { HttpService } from './http';
import { NotificationsService } from './notifications';
import { OverlayService } from './overlays';

View file

@ -10,7 +10,7 @@
import fetchMock from 'fetch-mock/es5/client';
import { loadingServiceMock } from './http_service.test.mocks';
import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { HttpService } from './http_service';
import { Observable } from 'rxjs';

View file

@ -8,8 +8,8 @@
import type { CoreService } from '@kbn/core-base-browser-internal';
import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
import { HttpSetup, HttpStart } from './types';
import { FatalErrorsSetup } from '../fatal_errors';
import { BasePath } from './base_path';
import { AnonymousPathsService } from './anonymous_paths_service';
import { LoadingCountService } from './loading_count_service';

View file

@ -9,7 +9,7 @@
import { Observable, throwError, of, Subject } from 'rxjs';
import { toArray } from 'rxjs/operators';
import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { LoadingCountService } from './loading_count_service';
describe('LoadingCountService', () => {

View file

@ -17,7 +17,7 @@ import {
tap,
} from 'rxjs/operators';
import type { CoreService } from '@kbn/core-base-browser-internal';
import { FatalErrorsSetup } from '../fatal_errors';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
/** @public */
export interface LoadingCountSetup {

View file

@ -35,6 +35,11 @@ import type { ThemeServiceSetup, ThemeServiceStart } from '@kbn/core-theme-brows
import type { AnalyticsServiceSetup, AnalyticsServiceStart } from '@kbn/core-analytics-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type {
FatalErrorsSetup,
FatalErrorsStart,
FatalErrorInfo,
} from '@kbn/core-fatal-errors-browser';
import {
ChromeBadge,
ChromeBreadcrumb,
@ -57,7 +62,6 @@ import {
NavType,
ChromeHelpMenuActions,
} from './chrome';
import { FatalErrorsSetup, FatalErrorsStart, FatalErrorInfo } from './fatal_errors';
import { HttpSetup, HttpStart } from './http';
import { NotificationsSetup, NotificationsStart } from './notifications';
import { OverlayStart } from './overlays';

View file

@ -7,7 +7,7 @@
*/
import { applicationServiceMock } from './application/application_service.mock';
import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
export const fatalErrorMock = fatalErrorsServiceMock.createSetupContract();
export const coreSystemMock = {
setup: jest.fn().mockResolvedValue({

View file

@ -15,12 +15,12 @@ import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
// Only import types from '.' to avoid triggering default Jest mocks.
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { PluginInitializerContext, AppMountParameters } from '.';
// Import values from their individual modules instead.
import { ScopedHistory } from './application';
import { applicationServiceMock } from './application/application_service.mock';
import { chromeServiceMock } from './chrome/chrome_service.mock';
import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
import { httpServiceMock } from './http/http_service.mock';
import { notificationServiceMock } from './notifications/notifications_service.mock';
import { overlayServiceMock } from './overlays/overlay_service.mock';
@ -35,7 +35,7 @@ export { themeServiceMock } from '@kbn/core-theme-browser-mocks';
export { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
export { chromeServiceMock } from './chrome/chrome_service.mock';
export { executionContextServiceMock } from './execution_context/execution_context_service.mock';
export { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock';
export { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
export { httpServiceMock } from './http/http_service.mock';
export { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
export { notificationServiceMock } from './notifications/notifications_service.mock';

View file

@ -11,11 +11,11 @@ import { render, unmountComponentAtNode } from 'react-dom';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import { IUiSettingsClient } from '../../ui_settings';
import { GlobalToastList } from './global_toast_list';
import { ToastsApi, IToasts } from './toasts_api';
import { OverlayStart } from '../../overlays';
import { CoreContextProvider } from '../../utils';
interface SetupDeps {
uiSettings: IUiSettingsClient;

View file

@ -14,9 +14,10 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { Subject } from 'rxjs';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import { MountPoint } from '../../types';
import { OverlayRef } from '../types';
import { MountWrapper, CoreContextProvider } from '../../utils';
import { MountWrapper } from '../../utils';
/**
* A FlyoutRef is a reference to an opened flyout panel. It offers methods to

View file

@ -15,9 +15,10 @@ import { render, unmountComponentAtNode } from 'react-dom';
import { Subject } from 'rxjs';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import { MountPoint } from '../../types';
import { OverlayRef } from '../types';
import { MountWrapper, CoreContextProvider } from '../../utils';
import { MountWrapper } from '../../utils';
/**
* A ModalRef is a reference to an opened modal. It offers methods to

View file

@ -30,7 +30,7 @@ import { applicationServiceMock } from '../application/application_service.mock'
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { overlayServiceMock } from '../overlays/overlay_service.mock';
import { chromeServiceMock } from '../chrome/chrome_service.mock';
import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { httpServiceMock } from '../http/http_service.mock';

View file

@ -12,10 +12,10 @@ import { pairwise, startWith } from 'rxjs/operators';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import { CoreContextProvider } from '@kbn/core-theme-browser-internal';
import type { InternalChromeStart } from '../chrome';
import type { InternalApplicationStart } from '../application';
import type { OverlayStart } from '../overlays';
import { CoreContextProvider } from '../utils';
import { AppWrapper } from './app_containers';
export interface StartDeps {

View file

@ -8,5 +8,4 @@
export { Sha256 } from './crypto';
export { MountWrapper, mountReactNode } from './mount';
export { CoreContextProvider } from './core_context_provider';
export { KBN_LOAD_MARKS } from './consts';

View file

@ -7,8 +7,8 @@
*/
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { HttpService } from '../public/http';
import { fatalErrorsServiceMock } from '../public/fatal_errors/fatal_errors_service.mock';
import { executionContextServiceMock } from '../public/execution_context/execution_context_service.mock';
export type SetupTap = (

View file

@ -3099,6 +3099,18 @@
version "0.0.0"
uid ""
"@kbn/core-fatal-errors-browser-internal@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal":
version "0.0.0"
uid ""
"@kbn/core-fatal-errors-browser-mocks@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks":
version "0.0.0"
uid ""
"@kbn/core-fatal-errors-browser@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser":
version "0.0.0"
uid ""
"@kbn/core-i18n-browser-internal@link:bazel-bin/packages/core/i18n/core-i18n-browser-internal":
version "0.0.0"
uid ""
@ -6542,6 +6554,18 @@
version "0.0.0"
uid ""
"@types/kbn__core-fatal-errors-browser-internal@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-fatal-errors-browser-mocks@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-fatal-errors-browser@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-i18n-browser-internal@link:bazel-bin/packages/core/i18n/core-i18n-browser-internal/npm_module_types":
version "0.0.0"
uid ""