Migrate types to packages: Client-side executionContext service (#134992)

* Migrate types to packages: Client-side executionContext service

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

* Fix incorrect import statement

* Import from packages if possible

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Gerard Soldevila 2022-06-28 17:00:38 +02:00 committed by GitHub
parent f308aa166d
commit f609f092a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 779 additions and 92 deletions

View file

@ -164,6 +164,10 @@
"@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-execution-context-browser": "link:bazel-bin/packages/core/execution-context/core-execution-context-browser",
"@kbn/core-execution-context-browser-internal": "link:bazel-bin/packages/core/execution-context/core-execution-context-browser-internal",
"@kbn/core-execution-context-browser-mocks": "link:bazel-bin/packages/core/execution-context/core-execution-context-browser-mocks",
"@kbn/core-execution-context-common": "link:bazel-bin/packages/core/execution-context/core-execution-context-common",
"@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",
@ -694,6 +698,10 @@
"@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-execution-context-browser": "link:bazel-bin/packages/core/execution-context/core-execution-context-browser/npm_module_types",
"@types/kbn__core-execution-context-browser-internal": "link:bazel-bin/packages/core/execution-context/core-execution-context-browser-internal/npm_module_types",
"@types/kbn__core-execution-context-browser-mocks": "link:bazel-bin/packages/core/execution-context/core-execution-context-browser-mocks/npm_module_types",
"@types/kbn__core-execution-context-common": "link:bazel-bin/packages/core/execution-context/core-execution-context-common/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",

View file

@ -33,6 +33,10 @@ 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/execution-context/core-execution-context-browser-internal:build",
"//packages/core/execution-context/core-execution-context-browser-mocks:build",
"//packages/core/execution-context/core-execution-context-browser:build",
"//packages/core/execution-context/core-execution-context-common: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",
@ -196,6 +200,10 @@ 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/execution-context/core-execution-context-browser-internal:build_types",
"//packages/core/execution-context/core-execution-context-browser-mocks:build_types",
"//packages/core/execution-context/core-execution-context-browser:build_types",
"//packages/core/execution-context/core-execution-context-common: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",

View file

@ -0,0 +1,110 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
PKG_DIRNAME = "core-execution-context-browser-internal"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-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//lodash",
"@npm//rxjs",
"//packages/core/analytics/core-analytics-browser-mocks",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"//packages/core/base/core-base-browser-internal:npm_module_types",
"//packages/core/analytics/core-analytics-browser:npm_module_types",
"//packages/core/execution-context/core-execution-context-common:npm_module_types",
"//packages/core/execution-context/core-execution-context-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,
)
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-execution-context-browser-internal
This package contains the internal types and implementation for Core's browser-side execution context 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/execution-context/core-execution-context-browser-internal'],
};

View file

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

@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { KibanaExecutionContext } from '../../types';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
import {
ExecutionContextContainer,
BAGGAGE_MAX_PER_NAME_VALUE_PAIRS,

View file

@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import type { KibanaExecutionContext } from '../../types';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
// Switch to the standard Baggage header
// https://github.com/elastic/apm-agent-rum-js/issues/1040

View file

@ -8,7 +8,8 @@
import { BehaviorSubject, firstValueFrom } from 'rxjs';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-browser';
import { ExecutionContextService, ExecutionContextSetup } from './execution_context_service';
import type { ExecutionContextSetup } from '@kbn/core-execution-context-browser';
import { ExecutionContextService } from './execution_context_service';
describe('ExecutionContextService', () => {
let execContext: ExecutionContextSetup;

View file

@ -7,10 +7,16 @@
*/
import { compact, isEqual, isUndefined, omitBy } from 'lodash';
import { BehaviorSubject, Observable, Subscription, map } from 'rxjs';
import type { Observable } from 'rxjs';
import { BehaviorSubject, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import type { CoreService } from '@kbn/core-base-browser-internal';
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-browser';
import { KibanaExecutionContext } from '../../types';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
import type {
ExecutionContextSetup,
ExecutionContextStart,
} from '@kbn/core-execution-context-browser';
// Should be exported from elastic/apm-rum
export type LabelValue = string | number | boolean;
@ -19,44 +25,6 @@ export interface Labels {
[key: string]: LabelValue;
}
/**
* Kibana execution context.
* Used to provide execution context to Elasticsearch, reporting, performance monitoring, etc.
* @public
**/
export interface ExecutionContextSetup {
/**
* The current context observable
**/
context$: Observable<KibanaExecutionContext>;
/**
* Set the current top level context
**/
set(c$: KibanaExecutionContext): void;
/**
* Get the current top level context
**/
get(): KibanaExecutionContext;
/**
* clears the context
**/
clear(): void;
/**
* returns apm labels
**/
getAsLabels(): Labels;
/**
* merges the current top level context with the specific event context
**/
withGlobalContext(context?: KibanaExecutionContext): KibanaExecutionContext;
}
/**
* See {@link ExecutionContextSetup}.
* @public
*/
export type ExecutionContextStart = ExecutionContextSetup;
export interface SetupDeps {
analytics: AnalyticsServiceSetup;
}

View file

@ -6,7 +6,5 @@
* Side Public License, v 1.
*/
export type { KibanaExecutionContext } from '../../types';
export { ExecutionContextContainer } from './execution_context_container';
export { ExecutionContextService } from './execution_context_service';
export type { ExecutionContextSetup, ExecutionContextStart } from './execution_context_service';
export { ExecutionContextContainer } from './execution_context_container';

View file

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

View file

@ -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-execution-context-browser-mocks"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-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//rxjs",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"//packages/kbn-utility-types:npm_module_types",
"//packages/core/execution-context/core-execution-context-browser:npm_module_types",
"//packages/core/execution-context/core-execution-context-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,
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-execution-context-browser-mocks
This package contains the public mocks for Core's browser-side execution context.

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/execution-context/core-execution-context-browser-mocks'],
};

View file

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

@ -6,10 +6,10 @@
* Side Public License, v 1.
*/
import { PublicMethodsOf } from '@kbn/utility-types';
import { BehaviorSubject } from 'rxjs';
import { ExecutionContextService, ExecutionContextSetup } from './execution_context_service';
import type { PublicMethodsOf } from '@kbn/utility-types';
import type { ExecutionContextSetup } from '@kbn/core-execution-context-browser';
import type { ExecutionContextService } from '@kbn/core-execution-context-browser-internal';
const createContractMock = (): jest.Mocked<ExecutionContextSetup> => ({
context$: new BehaviorSubject({}),

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 { executionContextServiceMock } from './execution_context_service.mock';

View file

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

View file

@ -0,0 +1,105 @@
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-execution-context-browser"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-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 = [
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//rxjs",
"//packages/core/execution-context/core-execution-context-common: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-execution-context-browser
This package contains the public types for Core's browser-side execution context 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/execution-context/core-execution-context-browser'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-execution-context-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,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 { ExecutionContextSetup, ExecutionContextStart } from './types';

View file

@ -0,0 +1,55 @@
/*
* 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 { Observable } from 'rxjs';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
// Should be exported from elastic/apm-rum
export type LabelValue = string | number | boolean;
export interface Labels {
[key: string]: LabelValue;
}
/**
* Kibana execution context.
* Used to provide execution context to Elasticsearch, reporting, performance monitoring, etc.
* @public
**/
export interface ExecutionContextSetup {
/**
* The current context observable
**/
context$: Observable<KibanaExecutionContext>;
/**
* Set the current top level context
**/
set(c$: KibanaExecutionContext): void;
/**
* Get the current top level context
**/
get(): KibanaExecutionContext;
/**
* clears the context
**/
clear(): void;
/**
* returns apm labels
**/
getAsLabels(): Labels;
/**
* merges the current top level context with the specific event context
**/
withGlobalContext(context?: KibanaExecutionContext): KibanaExecutionContext;
}
/**
* See {@link ExecutionContextSetup}.
* @public
*/
export type ExecutionContextStart = ExecutionContextSetup;

View file

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

View file

@ -0,0 +1,103 @@
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-execution-context-common"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-common"
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 = [
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
]
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-execution-context-common
This package contains the common types for Core's execution context.

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/execution-context/core-execution-context-common'],
};

View file

@ -0,0 +1,8 @@
{
"name": "@kbn/core-execution-context-common",
"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,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 { KibanaExecutionContext } from './types';

View file

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

View file

@ -8,12 +8,12 @@
jest.mock('@elastic/apm-rum');
import type { DeeplyMockedKeys, MockedKeys } from '@kbn/utility-types-jest';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { init, apm } from '@elastic/apm-rum';
import type { Transaction } from '@elastic/apm-rum';
import { ApmSystem } from './apm_system';
import { Subject } from 'rxjs';
import { InternalApplicationStart } from './application/types';
import { executionContextServiceMock } from './execution_context/execution_context_service.mock';
const initMock = init as jest.Mocked<typeof init>;
const apmMock = apm as DeeplyMockedKeys<typeof apm>;

View file

@ -8,9 +8,9 @@
import type { ApmBase, AgentConfigOptions, Transaction } from '@elastic/apm-rum';
import { modifyUrl } from '@kbn/std';
import type { ExecutionContextStart } from '@kbn/core-execution-context-browser';
import { CachedResourceObserver } from './apm_resource_counter';
import type { InternalApplicationStart } from './application';
import { ExecutionContextStart } from './execution_context';
/** "GET protocol://hostname:port/pathname" */
const HTTP_REQUEST_TRANSACTION_NAME_REGEX =

View file

@ -18,6 +18,7 @@ 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 { ExecutionContextService } from '@kbn/core-execution-context-browser-internal';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
import { FatalErrorsService } from '@kbn/core-fatal-errors-browser-internal';
import { CoreSetup, CoreStart } from '.';
@ -34,7 +35,6 @@ import { IntegrationsService } from './integrations';
import { DeprecationsService } from './deprecations';
import { CoreApp } from './core_app';
import type { InternalApplicationSetup, InternalApplicationStart } from './application/types';
import { ExecutionContextService } from './execution_context';
import { fetchOptionalMemoryInfo } from './fetch_optional_memory_info';
import { KBN_LOAD_MARKS } from './utils';

View file

@ -11,11 +11,11 @@ import fetchMock from 'fetch-mock/es5/client';
import { readFileSync } from 'fs';
import { join } from 'path';
import { first } from 'rxjs/operators';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { Fetch } from './fetch';
import { BasePath } from './base_path';
import { HttpResponse, HttpFetchOptionsWithPath } from './types';
import { executionContextServiceMock } from '../execution_context/execution_context_service.mock';
function delay<T>(duration: number) {
return new Promise<T>((r) => setTimeout(r, duration));

View file

@ -9,8 +9,9 @@
import { isEmpty, omitBy } from 'lodash';
import { format } from 'url';
import { BehaviorSubject } from 'rxjs';
import {
import type { ExecutionContextSetup } from '@kbn/core-execution-context-browser';
import { ExecutionContextContainer } from '@kbn/core-execution-context-browser-internal';
import type {
IBasePath,
HttpInterceptor,
HttpHandler,
@ -22,7 +23,6 @@ import { HttpFetchError } from './http_fetch_error';
import { HttpInterceptController } from './http_intercept_controller';
import { interceptRequest, interceptResponse } from './intercept';
import { HttpInterceptHaltError } from './http_intercept_halt_error';
import { ExecutionContextContainer, ExecutionContextSetup } from '../execution_context';
interface Params {
basePath: IBasePath;

View file

@ -6,15 +6,15 @@
* Side Public License, v 1.
*/
import { Observable } from 'rxjs';
// @ts-expect-error
import fetchMock from 'fetch-mock/es5/client';
import { loadingServiceMock } from './http_service.test.mocks';
import { loadingServiceMock } from './http_service.test.mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
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';
import { executionContextServiceMock } from '../execution_context/execution_context_service.mock';
describe('interceptors', () => {
afterEach(() => fetchMock.restore());

View file

@ -7,6 +7,7 @@
*/
import type { CoreService } from '@kbn/core-base-browser-internal';
import type { ExecutionContextSetup } from '@kbn/core-execution-context-browser';
import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal';
import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser';
import { HttpSetup, HttpStart } from './types';
@ -15,7 +16,6 @@ import { AnonymousPathsService } from './anonymous_paths_service';
import { LoadingCountService } from './loading_count_service';
import { Fetch } from './fetch';
import { ExternalUrlService } from './external_url_service';
import { ExecutionContextSetup } from '../execution_context';
interface HttpDeps {
injectedMetadata: InternalInjectedMetadataSetup;

View file

@ -8,7 +8,7 @@
import { Observable } from 'rxjs';
import { MaybePromise } from '@kbn/utility-types';
import type { KibanaExecutionContext } from '../execution_context';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
/** @public */
export interface HttpSetup {

View file

@ -33,6 +33,7 @@ import type {
import { DocLinksStart } from '@kbn/core-doc-links-browser';
import type { ThemeServiceSetup, ThemeServiceStart } from '@kbn/core-theme-browser';
import type { AnalyticsServiceSetup, AnalyticsServiceStart } from '@kbn/core-analytics-browser';
import { ExecutionContextSetup, ExecutionContextStart } from '@kbn/core-execution-context-browser';
import type { I18nStart } from '@kbn/core-i18n-browser';
import type {
@ -70,7 +71,6 @@ import { UiSettingsState, IUiSettingsClient } from './ui_settings';
import { ApplicationSetup, Capabilities, ApplicationStart } from './application';
import { SavedObjectsStart } from './saved_objects';
import { DeprecationsServiceStart } from './deprecations';
import { ExecutionContextSetup, ExecutionContextStart } from './execution_context';
export type {
PackageInfo,
@ -216,11 +216,12 @@ export type { MountPoint, UnmountCallback, PublicUiSettingsParams } from './type
export { URL_MAX_LENGTH } from './core_app';
export type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
export type {
KibanaExecutionContext,
ExecutionContextSetup,
ExecutionContextStart,
} from './execution_context';
} from '@kbn/core-execution-context-browser';
/**
* Core services exposed to the `Plugin` setup lifecycle

View file

@ -12,11 +12,12 @@ import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { coreContextMock } from '@kbn/core-base-browser-mocks';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-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 type { PluginInitializerContext, AppMountParameters } from '.';
// Import values from their individual modules instead.
import { ScopedHistory } from './application';
import { applicationServiceMock } from './application/application_service.mock';
@ -27,14 +28,13 @@ import { overlayServiceMock } from './overlays/overlay_service.mock';
import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
import { savedObjectsServiceMock } from './saved_objects/saved_objects_service.mock';
import { deprecationsServiceMock } from './deprecations/deprecations_service.mock';
import { executionContextServiceMock } from './execution_context/execution_context_service.mock';
export { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
export { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
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 { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
export { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
export { httpServiceMock } from './http/http_service.mock';
export { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';

View file

@ -14,7 +14,14 @@ import {
} from './plugins_service.test.mocks';
import { PluginName, PluginType } from '../../server';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { coreMock } from '../mocks';
import {
PluginsService,
PluginsServiceStartDeps,
@ -22,22 +29,16 @@ import {
} from './plugins_service';
import type { InjectedMetadataPlugin } from '@kbn/core-injected-metadata-common-internal';
import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { themeServiceMock } from '@kbn/core-theme-browser-mocks';
import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks';
import { notificationServiceMock } from '../notifications/notifications_service.mock';
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 '@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';
import { CoreSetup, CoreStart, PluginInitializerContext } from '..';
import { savedObjectsServiceMock } from '../saved_objects/saved_objects_service.mock';
import { deprecationsServiceMock } from '../deprecations/deprecations_service.mock';
import { executionContextServiceMock } from '../execution_context/execution_context_service.mock';
export let mockPluginInitializers: Map<PluginName, MockedPluginInitializer>;

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { ExecutionContextContainer } from '../../../public/execution_context/execution_context_container';
import { ExecutionContextContainer } from '@kbn/core-execution-context-browser-internal';
import * as kbnTestServer from '../../../test_helpers/kbn_server';
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

View file

@ -6,10 +6,10 @@
* Side Public License, v 1.
*/
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { HttpService } from '../public/http';
import { executionContextServiceMock } from '../public/execution_context/execution_context_service.mock';
export type SetupTap = (
injectedMetadata: ReturnType<typeof injectedMetadataServiceMock.createSetupContract>,

View file

@ -14,4 +14,4 @@ export * from './capabilities';
export * from './app_category';
export * from './ui_settings';
export * from './saved_objects';
export type { KibanaExecutionContext } from './execution_context';
export type { KibanaExecutionContext } from '@kbn/core-execution-context-common';

View file

@ -12,9 +12,12 @@ import './global_mocks';
import { HttpSetup } from '@kbn/core/public';
import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/public/mocks';
import { notificationServiceMock, fatalErrorsServiceMock } from '@kbn/core/public/mocks';
import { executionContextServiceMock } from '@kbn/core/public/execution_context/execution_context_service.mock';
import { docLinksServiceMock } from '@kbn/core/public/mocks';
import {
notificationServiceMock,
fatalErrorsServiceMock,
docLinksServiceMock,
executionContextServiceMock,
} from '@kbn/core/public/mocks';
import { licensingMock } from '@kbn/licensing-plugin/public/mocks';
import { init as initHttp } from '../../../public/application/services/http';
import { init as initHttpRequests } from './http_requests';

View file

@ -17,6 +17,7 @@ import {
docLinksServiceMock,
} from '@kbn/core/public/mocks';
import { HttpService } from '@kbn/core/public/http';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/public/mocks';
import { PolicyFromES } from '../common/types';
@ -25,7 +26,6 @@ import { init as initHttp } from '../public/application/services/http';
import { init as initUiMetric } from '../public/application/services/ui_metric';
import { KibanaContextProvider } from '../public/shared_imports';
import { PolicyListContextProvider } from '../public/application/sections/policy_list/policy_list_context';
import { executionContextServiceMock } from '@kbn/core/public/execution_context/execution_context_service.mock';
initHttp(
new HttpService().setup({

View file

@ -8,14 +8,11 @@
import React from 'react';
import { HttpSetup } from '@kbn/core/public';
import {
notificationServiceMock,
docLinksServiceMock,
applicationServiceMock,
executionContextServiceMock,
} from '@kbn/core/public/mocks';
import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { notificationServiceMock, applicationServiceMock } from '@kbn/core/public/mocks';
import { GlobalFlyout } from '@kbn/es-ui-shared-plugin/public';
import { AppContextProvider } from '../../../../../app_context';
import { MappingsEditorProvider } from '../../../../mappings_editor';
import { ComponentTemplatesProvider } from '../../../component_templates_context';

View file

@ -11,9 +11,8 @@ import {
notificationServiceMock,
fatalErrorsServiceMock,
docLinksServiceMock,
executionContextServiceMock,
} from '@kbn/core/public/mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/public/mocks';
import { AppContextProvider } from '../../../public/application/app_context';

View file

@ -9,13 +9,13 @@ import { of } from 'rxjs';
import { LocationDescriptorObject } from 'history';
import {
docLinksServiceMock,
uiSettingsServiceMock,
notificationServiceMock,
httpServiceMock,
scopedHistoryMock,
executionContextServiceMock,
} from '@kbn/core/public/mocks';
import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-browser-mocks';
import { AppDeps } from '../../../public/application/app';
import { LicenseStatus } from '../../../common/types/license_status';

View file

@ -3099,6 +3099,22 @@
version "0.0.0"
uid ""
"@kbn/core-execution-context-browser-internal@link:bazel-bin/packages/core/execution-context/core-execution-context-browser-internal":
version "0.0.0"
uid ""
"@kbn/core-execution-context-browser-mocks@link:bazel-bin/packages/core/execution-context/core-execution-context-browser-mocks":
version "0.0.0"
uid ""
"@kbn/core-execution-context-browser@link:bazel-bin/packages/core/execution-context/core-execution-context-browser":
version "0.0.0"
uid ""
"@kbn/core-execution-context-common@link:bazel-bin/packages/core/execution-context/core-execution-context-common":
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 ""
@ -6550,6 +6566,22 @@
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-browser-internal@link:bazel-bin/packages/core/execution-context/core-execution-context-browser-internal/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-browser-mocks@link:bazel-bin/packages/core/execution-context/core-execution-context-browser-mocks/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-browser@link:bazel-bin/packages/core/execution-context/core-execution-context-browser/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-common@link:bazel-bin/packages/core/execution-context/core-execution-context-common/npm_module_types":
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 ""