Move server-side executionContext service to packages (#135396)

* create the empty server execution-context packages

* move src/core/server/execution-context into packages

* update READMEs

* adapt first server/mocks imports

* move ECC type to public package

* adapt mock imports

* adapt more imports

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Pierre Gayvallet 2022-06-29 15:29:31 +02:00 committed by GitHub
parent 7338acbc7d
commit 111b6f4b99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 595 additions and 85 deletions

View file

@ -170,6 +170,9 @@
"@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-execution-context-server": "link:bazel-bin/packages/core/execution-context/core-execution-context-server",
"@kbn/core-execution-context-server-internal": "link:bazel-bin/packages/core/execution-context/core-execution-context-server-internal",
"@kbn/core-execution-context-server-mocks": "link:bazel-bin/packages/core/execution-context/core-execution-context-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",
@ -709,6 +712,9 @@
"@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-execution-context-server": "link:bazel-bin/packages/core/execution-context/core-execution-context-server/npm_module_types",
"@types/kbn__core-execution-context-server-internal": "link:bazel-bin/packages/core/execution-context/core-execution-context-server-internal/npm_module_types",
"@types/kbn__core-execution-context-server-mocks": "link:bazel-bin/packages/core/execution-context/core-execution-context-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",

View file

@ -39,6 +39,9 @@ filegroup(
"//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/execution-context/core-execution-context-server-internal:build",
"//packages/core/execution-context/core-execution-context-server-mocks:build",
"//packages/core/execution-context/core-execution-context-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",
@ -211,6 +214,9 @@ filegroup(
"//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/execution-context/core-execution-context-server-internal:build_types",
"//packages/core/execution-context/core-execution-context-server-mocks:build_types",
"//packages/core/execution-context/core-execution-context-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",

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-execution-context-server-internal"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-server-internal"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
],
)
SRCS = SOURCE_FILES
filegroup(
name = "srcs",
srcs = SRCS,
)
NPM_MODULE_EXTRA_FILES = [
"package.json",
]
RUNTIME_DEPS = [
"@npm//lodash",
"@npm//rxjs",
"//packages/kbn-config-schema",
]
TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//rxjs",
"@npm//elastic-apm-node",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-logging:npm_module_types",
"//packages/core/base/core-base-server-internal:npm_module_types",
"//packages/core/execution-context/core-execution-context-common:npm_module_types",
"//packages/core/execution-context/core-execution-context-server:npm_module_types",
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
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"],
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,4 @@
# @kbn/core-execution-context-server-internal
This package contains the internal types and implementation for Core's server-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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/execution-context/core-execution-context-server-internal'],
};

View file

@ -0,0 +1,7 @@
{
"name": "@kbn/core-execution-context-server-internal",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
import { TypeOf, schema } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';
import type { ServiceConfigDescriptor } from '@kbn/core-base-server-internal';
const configSchema = schema.object({
@ -16,9 +16,11 @@ const configSchema = schema.object({
/**
* @internal
*/
export type ExecutionContextConfigType = TypeOf<typeof configSchema>;
export interface ExecutionContextConfigType {
enabled: boolean;
}
export const config: ServiceConfigDescriptor<ExecutionContextConfigType> = {
export const executionContextConfig: ServiceConfigDescriptor<ExecutionContextConfigType> = {
path: 'execution_context',
schema: configSchema,
};

View file

@ -7,7 +7,7 @@
*/
import { Blob } from 'buffer';
import type { KibanaExecutionContext } from '../../types';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
import {
ExecutionContextContainer,

View file

@ -5,7 +5,9 @@
* 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 type { IExecutionContextContainer } from '@kbn/core-execution-context-server';
// Switch to the standard Baggage header. blocked by
// https://github.com/elastic/apm-agent-nodejs/issues/2102
@ -41,14 +43,6 @@ function enforceMaxLength(header: string): string {
return header.slice(0, MAX_BAGGAGE_LENGTH);
}
/**
* @public
*/
export interface IExecutionContextContainer {
toString(): string;
toJSON(): Readonly<KibanaExecutionContext>;
}
function stringify(ctx: KibanaExecutionContext): string {
const encodeURIComponentIfNotEmpty = (val?: string) => encodeURIComponent(val || '');
const stringifiedCtx = `${encodeURIComponentIfNotEmpty(ctx.type)}:${encodeURIComponentIfNotEmpty(

View file

@ -14,6 +14,7 @@ import {
} from './execution_context_service';
const delay = (ms: number = 100) => new Promise((resolve) => setTimeout(resolve, ms));
describe('ExecutionContextService', () => {
describe('setup', () => {
let service: InternalExecutionContextSetup;

View file

@ -6,28 +6,27 @@
* Side Public License, v 1.
*/
import { AsyncLocalStorage } from 'async_hooks';
import apm from 'elastic-apm-node';
import type apm from 'elastic-apm-node';
import { isUndefined, omitBy } from 'lodash';
import type { Subscription } from 'rxjs';
import type { Logger } from '@kbn/logging';
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
import type { KibanaExecutionContext } from '../../types';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
import type { IExecutionContextContainer } from '@kbn/core-execution-context-server';
import type { ExecutionContextConfigType } from './execution_context_config';
import {
ExecutionContextContainer,
IExecutionContextContainer,
getParentContextFrom,
} from './execution_context_container';
import { ExecutionContextContainer, getParentContextFrom } from './execution_context_container';
/**
* @internal
*/
export interface IExecutionContext {
getParentContextFrom(headers: Record<string, string>): KibanaExecutionContext | undefined;
setRequestId(requestId: string): void;
set(context: KibanaExecutionContext): void;
/**
* The sole purpose of this imperative internal API is to be used by the http service.
* The event-based nature of Hapi server doesn't allow us to wrap a request handler with "withContext".
@ -36,11 +35,14 @@ export interface IExecutionContext {
* https://nodejs.org/api/async_context.html#async_context_asynclocalstorage_enterwith_store
*/
get(): IExecutionContextContainer | undefined;
withContext<R>(context: KibanaExecutionContext | undefined, fn: () => R): R;
/**
* returns serialized representation to send as a header
**/
getAsHeader(): string | undefined;
/**
* returns apm labels
**/
@ -57,24 +59,6 @@ export type InternalExecutionContextSetup = IExecutionContext;
*/
export type InternalExecutionContextStart = IExecutionContext;
/**
* @public
*/
export interface ExecutionContextSetup {
/**
* Keeps track of execution context while the passed function is executed.
* Data are carried over all async operations spawned by the passed function.
* The nested calls stack the registered context on top of each other.
**/
withContext<R>(context: KibanaExecutionContext | undefined, fn: (...args: any[]) => R): R;
getAsLabels(): apm.Labels;
}
/**
* @public
*/
export type ExecutionContextStart = ExecutionContextSetup;
export class ExecutionContextService
implements CoreService<InternalExecutionContextSetup, InternalExecutionContextStart>
{

View file

@ -6,14 +6,10 @@
* Side Public License, v 1.
*/
export type { KibanaExecutionContext } from '../../types';
export { ExecutionContextService } from './execution_context_service';
export type {
InternalExecutionContextSetup,
InternalExecutionContextStart,
ExecutionContextSetup,
ExecutionContextStart,
IExecutionContext,
} from './execution_context_service';
export type { IExecutionContextContainer } from './execution_context_container';
export { config } from './execution_context_config';
export { executionContextConfig } from './execution_context_config';

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,98 @@
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-server-mocks"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-server-mocks"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
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",
"//packages/core/execution-context/core-execution-context-common:npm_module_types",
"//packages/core/execution-context/core-execution-context-server:npm_module_types",
"//packages/core/execution-context/core-execution-context-server-internal:npm_module_types",
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
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"],
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,4 @@
# @kbn/core-execution-context-server-mocks
This package contains the mocks for Core's server-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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/execution-context/core-execution-context-server-mocks'],
};

View file

@ -0,0 +1,7 @@
{
"name": "@kbn/core-execution-context-server-mocks",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -6,12 +6,12 @@
* Side Public License, v 1.
*/
import type { KibanaExecutionContext } from '../../types';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
import type { ExecutionContextSetup } from '@kbn/core-execution-context-server';
import type {
IExecutionContext,
InternalExecutionContextSetup,
ExecutionContextSetup,
} from './execution_context_service';
} from '@kbn/core-execution-context-server-internal';
// attempted removal of any: unsuccessful! In theory, replaceable with <R>/R
function withContextMock(context: KibanaExecutionContext | undefined, fn: () => any): any {

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,97 @@
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-server"
PKG_REQUIRE_NAME = "@kbn/core-execution-context-server"
SOURCE_FILES = glob(
[
"src/**/*.ts",
],
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//elastic-apm-node",
"//packages/core/execution-context/core-execution-context-common:npm_module_types",
]
jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)
ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)
ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
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"],
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,4 @@
# @kbn/core-execution-context-server
This package contains the public types for Core's server-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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/execution-context/core-execution-context-server'],
};

View file

@ -0,0 +1,7 @@
{
"name": "@kbn/core-execution-context-server",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}

View file

@ -0,0 +1,29 @@
/*
* 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 apm from 'elastic-apm-node';
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
/**
* @public
*/
export interface ExecutionContextSetup {
/**
* Keeps track of execution context while the passed function is executed.
* Data are carried over all async operations spawned by the passed function.
* The nested calls stack the registered context on top of each other.
**/
withContext<R>(context: KibanaExecutionContext | undefined, fn: (...args: any[]) => R): R;
getAsLabels(): apm.Labels;
}
/**
* @public
*/
export type ExecutionContextStart = ExecutionContextSetup;

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 { ExecutionContextSetup, ExecutionContextStart } from './contracts';
export type { IExecutionContextContainer } from './types';

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.
*/
import type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
/**
* @public
*/
export interface IExecutionContextContainer {
toString(): string;
toJSON(): Readonly<KibanaExecutionContext>;
}

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

@ -11,9 +11,9 @@ import { REPO_ROOT } from '@kbn/utils';
import { Env } from '@kbn/config';
import { getEnvOptions } from '@kbn/config-mocks';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { HttpService, InternalHttpServicePreboot, InternalHttpServiceSetup } from '../../http';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { CapabilitiesService, CapabilitiesSetup } from '..';
import { createHttpServer } from '../../http/test_utils';

View file

@ -10,8 +10,8 @@ import { resolve } from 'path';
import { readFile } from 'fs/promises';
import supertest from 'supertest';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { HttpService, IRouter } from '../../http';
import { createHttpServer } from '../../http/test_utils';
import { registerRouteForBundle } from '../bundle_routes/bundles_route';

View file

@ -30,8 +30,8 @@ import { configServiceMock, getEnvOptions } from '@kbn/config-mocks';
import type { CoreContext } from '@kbn/core-base-server-internal';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { httpServiceMock } from '../http/http_service.mock';
import { executionContextServiceMock } from '../execution_context/execution_context_service.mock';
import { configSchema, ElasticsearchConfig } from './elasticsearch_config';
import { ElasticsearchService, SetupDeps } from './elasticsearch_service';
import { elasticsearchClientMock } from './client/mocks';

View file

@ -12,12 +12,15 @@ import { map, shareReplay, takeUntil } from 'rxjs/operators';
import type { Logger } from '@kbn/logging';
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
import { registerAnalyticsContextProvider } from './register_analytics_context_provider';
import type {
InternalExecutionContextSetup,
IExecutionContext,
} from '@kbn/core-execution-context-server-internal';
import { registerAnalyticsContextProvider } from './register_analytics_context_provider';
import { ClusterClient, ElasticsearchClientConfig } from './client';
import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config';
import type { InternalHttpServiceSetup, IAuthHeadersStorage } from '../http';
import type { InternalExecutionContextSetup, IExecutionContext } from '../execution_context';
import {
InternalElasticsearchServicePreboot,
InternalElasticsearchServiceSetup,

View file

@ -23,8 +23,8 @@ import { firstValueFrom, Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import apm from 'elastic-apm-node';
import type { Logger, LoggerFactory } from '@kbn/logging';
import type { InternalExecutionContextSetup } from '@kbn/core-execution-context-server-internal';
import { HttpConfig } from './http_config';
import type { InternalExecutionContextSetup } from '../execution_context';
import { adoptToHapiAuthFormat, AuthenticationHandler } from './lifecycle/auth';
import { adoptToHapiOnPreAuth, OnPreAuthHandler } from './lifecycle/on_pre_auth';
import { adoptToHapiOnPostAuthFormat, OnPostAuthHandler } from './lifecycle/on_post_auth';

View file

@ -14,11 +14,11 @@ import { REPO_ROOT } from '@kbn/utils';
import { ConfigService, Env } from '@kbn/config';
import { getEnvOptions } from '@kbn/config-mocks';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { HttpService } from '.';
import { HttpConfigType, config } from './http_config';
import { httpServerMock } from './http_server.mocks';
import { contextServiceMock } from '../context/context_service.mock';
import { executionContextServiceMock } from '../execution_context/execution_context_service.mock';
import { config as cspConfig } from '../csp';
import { config as externalUrlConfig, ExternalUrlConfig } from '../external_url';
import { Router } from './router';

View file

@ -14,9 +14,9 @@ import { Logger } from '@kbn/logging';
import { Env } from '@kbn/config';
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
import type { PluginOpaqueId } from '@kbn/core-base-common';
import type { InternalExecutionContextSetup } from '@kbn/core-execution-context-server-internal';
import type { RequestHandlerContext } from '..';
import type { InternalExecutionContextSetup } from '../execution_context';
import { ContextSetup, InternalContextPreboot } from '../context';
import { CspConfigType, config as cspConfig } from '../csp';

View file

@ -15,12 +15,12 @@ import { ByteSizeValue } from '@kbn/config-schema';
import { Env } from '@kbn/config';
import { getEnvOptions, configServiceMock } from '@kbn/config-mocks';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import type { CoreContext } from '@kbn/core-base-server-internal';
import { HttpService } from '../http_service';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { httpServerMock } from '../http_server.mocks';
import { createCookieSessionStorageFactory } from '../cookie_session_storage';

View file

@ -10,12 +10,12 @@ import supertest from 'supertest';
import { parse as parseCookie } from 'tough-cookie';
import { schema } from '@kbn/config-schema';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { ensureRawRequest } from '../router';
import { HttpService } from '../http_service';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { createHttpServer } from '../test_utils';
let server: HttpService;

View file

@ -18,7 +18,7 @@ import { HttpServerSetup } from '../http_server';
import { IRouter, RouteRegistrar } from '../router';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pkg = require('../../../../../package.json');

View file

@ -9,8 +9,8 @@
import supertest from 'supertest';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { createHttpServer } from '../test_utils';
import { HttpService } from '../http_service';

View file

@ -12,11 +12,11 @@ jest.mock('uuid', () => ({
import supertest from 'supertest';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { HttpService } from '../http_service';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { createHttpServer } from '../test_utils';
import { schema } from '@kbn/config-schema';

View file

@ -12,8 +12,8 @@ import supertest from 'supertest';
import { schema } from '@kbn/config-schema';
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { createHttpServer } from '../test_utils';
import { HttpService } from '../http_service';
import { Router } from '../router';

View file

@ -38,6 +38,10 @@ import type {
AnalyticsServiceStart,
AnalyticsServicePreboot,
} from '@kbn/core-analytics-server';
import type {
ExecutionContextSetup,
ExecutionContextStart,
} from '@kbn/core-execution-context-server';
import {
ElasticsearchServiceSetup,
configSchema as elasticsearchConfigSchema,
@ -89,9 +93,8 @@ export type {
ConfigUsageData,
};
import type { ExecutionContextSetup, ExecutionContextStart } from './execution_context';
export type { IExecutionContextContainer, KibanaExecutionContext } from './execution_context';
export type { KibanaExecutionContext } from '@kbn/core-execution-context-common';
export type { IExecutionContextContainer } from '@kbn/core-execution-context-server';
export { bootstrap } from './bootstrap';
export type {

View file

@ -17,6 +17,10 @@ import type {
AnalyticsServiceStart,
} from '@kbn/core-analytics-server';
import type { InternalEnvironmentServiceSetup } from '@kbn/core-environment-server-internal';
import type {
InternalExecutionContextSetup,
InternalExecutionContextStart,
} from '@kbn/core-execution-context-server-internal';
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { InternalContextPreboot, ContextSetup } from './context';
import {
@ -45,10 +49,6 @@ import { InternalStatusServiceSetup } from './status';
import { CoreUsageDataStart, InternalCoreUsageDataSetup } from './core_usage_data';
import { I18nServiceSetup } from './i18n';
import { InternalDeprecationsServiceSetup, InternalDeprecationsServiceStart } from './deprecations';
import type {
InternalExecutionContextSetup,
InternalExecutionContextStart,
} from './execution_context';
import { InternalPrebootServicePreboot } from './preboot';
/** @internal */

View file

@ -13,7 +13,7 @@ import { Server as HapiServer } from '@hapi/hapi';
import { createHttpServer } from '../../http/test_utils';
import { HttpService, IRouter } from '../../http';
import { contextServiceMock } from '../../context/context_service.mock';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { ServerMetricsCollector } from '../collectors/server';
import { setTimeout as setTimeoutPromise } from 'timers/promises';

View file

@ -16,6 +16,7 @@ import { loggingSystemMock, loggingServiceMock } from '@kbn/core-logging-server-
import { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';
import { environmentServiceMock } from '@kbn/core-environment-server-mocks';
import { nodeServiceMock } from '@kbn/core-node-server-mocks';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import type {
PluginInitializerContext,
CoreSetup,
@ -39,7 +40,6 @@ import { statusServiceMock } from './status/status_service.mock';
import { coreUsageDataServiceMock } from './core_usage_data/core_usage_data_service.mock';
import { i18nServiceMock } from './i18n/i18n_service.mock';
import { deprecationsServiceMock } from './deprecations/deprecations_service.mock';
import { executionContextServiceMock } from './execution_context/execution_context_service.mock';
import { prebootServiceMock } from './preboot/preboot_service.mock';
export { configServiceMock, configDeprecationsMock } from '@kbn/config-mocks';
@ -63,7 +63,7 @@ export { capabilitiesServiceMock } from './capabilities/capabilities_service.moc
export { coreUsageDataServiceMock } from './core_usage_data/core_usage_data_service.mock';
export { i18nServiceMock } from './i18n/i18n_service.mock';
export { deprecationsServiceMock } from './deprecations/deprecations_service.mock';
export { executionContextServiceMock } from './execution_context/execution_context_service.mock';
export { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
export { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
export { analyticsServiceMock } from '@kbn/core-analytics-server-mocks';

View file

@ -11,7 +11,7 @@ import { registerGetRoute } from '../get';
import { ContextService } from '../../../context';
import { savedObjectsClientMock } from '../../service/saved_objects_client.mock';
import { CoreUsageStatsClient } from '../../../core_usage_data';
import { executionContextServiceMock } from '../../../execution_context/execution_context_service.mock';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { coreUsageStatsClientMock } from '../../../core_usage_data/core_usage_stats_client.mock';
import { coreUsageDataServiceMock } from '../../../core_usage_data/core_usage_data_service.mock';
import { HttpService, InternalHttpServiceSetup } from '../../../http';

View file

@ -13,7 +13,7 @@ import { savedObjectsClientMock } from '../../service/saved_objects_client.mock'
import { CoreUsageStatsClient } from '../../../core_usage_data';
import { coreUsageStatsClientMock } from '../../../core_usage_data/core_usage_stats_client.mock';
import { coreUsageDataServiceMock } from '../../../core_usage_data/core_usage_data_service.mock';
import { executionContextServiceMock } from '../../../execution_context/execution_context_service.mock';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { HttpService, InternalHttpServiceSetup } from '../../../http';
import { createHttpServer, createCoreContext } from '../../../http/test_utils';
import { contextServiceMock, coreMock } from '../../../mocks';

View file

@ -6,10 +6,10 @@
* Side Public License, v 1.
*/
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { ContextService } from '../../context';
import { createHttpServer, createCoreContext } from '../../http/test_utils';
import { contextServiceMock, coreMock } from '../../mocks';
import { executionContextServiceMock } from '../../execution_context/execution_context_service.mock';
import { SavedObjectsType } from '../types';
const defaultCoreId = Symbol('core');

View file

@ -25,6 +25,10 @@ import { NodeService, nodeConfig } from '@kbn/core-node-server-internal';
import { AnalyticsService } from '@kbn/core-analytics-server-internal';
import type { AnalyticsServiceSetup } from '@kbn/core-analytics-server';
import { EnvironmentService, pidConfig } from '@kbn/core-environment-server-internal';
import {
ExecutionContextService,
executionContextConfig,
} from '@kbn/core-execution-context-server-internal';
import { CoreApp } from './core_app';
import { I18nService } from './i18n';
import { ElasticsearchService } from './elasticsearch';
@ -38,7 +42,6 @@ import { MetricsService, opsConfig } from './metrics';
import { CapabilitiesService } from './capabilities';
// do not try to shorten the import to `./status`, it will break server test mocking
import { StatusService } from './status/status_service';
import { ExecutionContextService } from './execution_context';
import { config as cspConfig } from './csp';
import { config as elasticsearchConfig } from './elasticsearch';
@ -53,7 +56,6 @@ import { CoreUsageDataService } from './core_usage_data';
import { DeprecationsService, config as deprecationConfig } from './deprecations';
import { CoreRouteHandlerContext } from './core_route_handler_context';
import { config as externalUrlConfig } from './external_url';
import { config as executionContextConfig } from './execution_context';
import { PrebootCoreRouteHandlerContext } from './preboot_core_route_handler_context';
import { PrebootService } from './preboot';
import { DiscoveredPlugins } from './plugins';

View file

@ -19,7 +19,7 @@ import { HttpService, InternalHttpServiceSetup } from '../../../http';
import { registerStatusRoute } from '../status';
import { ServiceStatus, ServiceStatusLevels, ServiceStatusLevel } from '../../types';
import { statusServiceMock } from '../../status_service.mock';
import { executionContextServiceMock } from '../../../execution_context/execution_context_service.mock';
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
import { contextServiceMock } from '../../../context/context_service.mock';
const coreId = Symbol('core');

View file

@ -3099,6 +3099,14 @@
version "0.0.0"
uid ""
"@kbn/core-environment-server-internal@link:bazel-bin/packages/core/environment/core-environment-server-internal":
version "0.0.0"
uid ""
"@kbn/core-environment-server-mocks@link:bazel-bin/packages/core/environment/core-environment-server-mocks":
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 ""
@ -3115,6 +3123,18 @@
version "0.0.0"
uid ""
"@kbn/core-execution-context-server-internal@link:bazel-bin/packages/core/execution-context/core-execution-context-server-internal":
version "0.0.0"
uid ""
"@kbn/core-execution-context-server-mocks@link:bazel-bin/packages/core/execution-context/core-execution-context-server-mocks":
version "0.0.0"
uid ""
"@kbn/core-execution-context-server@link:bazel-bin/packages/core/execution-context/core-execution-context-server":
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 ""
@ -3127,14 +3147,6 @@
version "0.0.0"
uid ""
"@kbn/core-environment-server-internal@link:bazel-bin/packages/core/environment/core-environment-server-internal":
version "0.0.0"
uid ""
"@kbn/core-environment-server-mocks@link:bazel-bin/packages/core/environment/core-environment-server-mocks":
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 ""
@ -6610,6 +6622,18 @@
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-server-internal@link:bazel-bin/packages/core/execution-context/core-execution-context-server-internal/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-server-mocks@link:bazel-bin/packages/core/execution-context/core-execution-context-server-mocks/npm_module_types":
version "0.0.0"
uid ""
"@types/kbn__core-execution-context-server@link:bazel-bin/packages/core/execution-context/core-execution-context-server/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 ""