From d2defb061ecd24351ed0e77b4de2e42cd5695fe3 Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Wed, 16 Sep 2020 09:17:05 +0200 Subject: [PATCH] Move core config service to `kbn/config` package (#76874) * move deprecations and raw loader to package * move config service to package * start to adapt the usages * adapt yet more usages * update generated doc * move logging types to `@kbn/logging` * update generated doc * add yarn.lock symlink * merge @kbn-logging PR * adapt Env.createDefault * update generated doc * remove mock exports from the main entrypoint to avoid importing it in production code * use dynamic require to import `REPO_ROOT` from bootstrap file * move logger mock to kbn-logging package * address review comments * import PublicMethodOf from kbn/utility-types * fix import conflict * update generated doc * use the @kbn/std package * update generated doc * adapt plugin service mock --- ...-plugin-core-public.environmentmode.dev.md | 11 -- ...bana-plugin-core-public.environmentmode.md | 21 --- ...plugin-core-public.environmentmode.name.md | 11 -- ...plugin-core-public.environmentmode.prod.md | 11 -- .../core/public/kibana-plugin-core-public.md | 2 - ...a-plugin-core-public.packageinfo.branch.md | 11 -- ...plugin-core-public.packageinfo.buildnum.md | 11 -- ...plugin-core-public.packageinfo.buildsha.md | 11 -- ...ana-plugin-core-public.packageinfo.dist.md | 11 -- .../kibana-plugin-core-public.packageinfo.md | 23 --- ...-plugin-core-public.packageinfo.version.md | 11 -- ...na-plugin-core-server.configdeprecation.md | 18 --- ...in-core-server.configdeprecationfactory.md | 36 ----- ...-server.configdeprecationfactory.rename.md | 36 ----- ...configdeprecationfactory.renamefromroot.md | 39 ----- ...-server.configdeprecationfactory.unused.md | 35 ---- ...configdeprecationfactory.unusedfromroot.md | 37 ----- ...gin-core-server.configdeprecationlogger.md | 13 -- ...n-core-server.configdeprecationprovider.md | 28 ---- .../kibana-plugin-core-server.configpath.md | 12 -- ...-plugin-core-server.environmentmode.dev.md | 11 -- ...bana-plugin-core-server.environmentmode.md | 21 --- ...plugin-core-server.environmentmode.name.md | 11 -- ...plugin-core-server.environmentmode.prod.md | 11 -- .../kibana-plugin-core-server.logger.debug.md | 25 --- .../kibana-plugin-core-server.logger.error.md | 25 --- .../kibana-plugin-core-server.logger.fatal.md | 25 --- .../kibana-plugin-core-server.logger.get.md | 33 ---- .../kibana-plugin-core-server.logger.info.md | 25 --- .../kibana-plugin-core-server.logger.md | 26 --- .../kibana-plugin-core-server.logger.trace.md | 25 --- .../kibana-plugin-core-server.logger.warn.md | 25 --- ...na-plugin-core-server.loggerfactory.get.md | 24 --- ...kibana-plugin-core-server.loggerfactory.md | 20 --- .../kibana-plugin-core-server.logmeta.md | 13 -- .../core/server/kibana-plugin-core-server.md | 10 -- ...a-plugin-core-server.packageinfo.branch.md | 11 -- ...plugin-core-server.packageinfo.buildnum.md | 11 -- ...plugin-core-server.packageinfo.buildsha.md | 11 -- ...ana-plugin-core-server.packageinfo.dist.md | 11 -- .../kibana-plugin-core-server.packageinfo.md | 23 --- ...-plugin-core-server.packageinfo.version.md | 11 -- ...ver.pluginconfigdescriptor.deprecations.md | 2 +- ...ugin-core-server.pluginconfigdescriptor.md | 2 +- ...n-core-server.pluginmanifest.configpath.md | 2 +- ...ibana-plugin-core-server.pluginmanifest.md | 2 +- package.json | 2 + packages/kbn-config/README.md | 3 + .../kbn-config}/__fixtures__/config.yml | 0 .../kbn-config}/__fixtures__/config_flat.yml | 0 .../__fixtures__/en_var_ref_config.yml | 0 .../kbn-config}/__fixtures__/one.yml | 0 .../kbn-config}/__fixtures__/two.yml | 0 packages/kbn-config/package.json | 30 ++++ .../kbn-config/src}/__mocks__/env.ts | 0 .../__snapshots__/config_service.test.ts.snap | 0 .../src}/__snapshots__/env.test.ts.snap | 0 .../kbn-config/src}/apply_argv.test.ts | 0 .../kbn-config/src}/config.mock.ts | 0 .../kbn-config/src}/config.test.ts | 0 .../kbn-config/src}/config.ts | 2 +- .../kbn-config/src}/config_service.mock.ts | 0 .../src}/config_service.test.mocks.ts | 2 +- .../kbn-config/src}/config_service.test.ts | 34 ++-- .../kbn-config/src}/config_service.ts | 7 +- .../deprecation/apply_deprecations.test.ts | 0 .../src}/deprecation/apply_deprecations.ts | 0 .../deprecation/deprecation_factory.test.ts | 0 .../src}/deprecation/deprecation_factory.ts | 0 packages/kbn-config/src/deprecation/index.ts | 28 ++++ .../kbn-config/src}/deprecation/types.ts | 0 .../kbn-config/src}/env.test.mocks.ts | 14 +- .../kbn-config/src}/env.test.ts | 47 ++++-- .../config => packages/kbn-config/src}/env.ts | 28 ++-- packages/kbn-config/src/index.ts | 37 +++++ ...gacy_object_to_config_adapter.test.ts.snap | 0 packages/kbn-config/src/legacy/index.ts | 23 +++ .../legacy_object_to_config_adapter.test.ts | 0 .../legacy_object_to_config_adapter.ts | 15 +- packages/kbn-config/src/mocks.ts | 28 ++++ .../src}/object_to_config_adapter.test.ts | 0 .../src}/object_to_config_adapter.ts | 0 .../__snapshots__/read_config.test.ts.snap | 0 .../src/raw}/ensure_deep_object.test.ts | 0 .../kbn-config/src/raw}/ensure_deep_object.ts | 0 packages/kbn-config/src/raw/index.ts | 21 +++ .../src/raw}/raw_config_service.mock.ts | 1 + .../src/raw}/raw_config_service.test.mocks.ts | 0 .../src/raw}/raw_config_service.test.ts | 2 +- .../kbn-config/src/raw}/raw_config_service.ts | 0 .../kbn-config/src/raw}/read_config.test.ts | 2 +- .../kbn-config/src/raw}/read_config.ts | 0 .../kbn-config/src}/types.ts | 0 packages/kbn-config/tsconfig.json | 12 ++ packages/kbn-config/yarn.lock | 1 + packages/kbn-logging/README.md | 61 +++++++ packages/kbn-logging/package.json | 18 +++ packages/kbn-logging/src/appenders.ts | 39 +++++ packages/kbn-logging/src/index.ts | 25 +++ packages/kbn-logging/src/layout.ts | 28 ++++ .../kbn-logging/src}/log_level.test.ts | 0 .../kbn-logging/src}/log_level.ts | 0 .../kbn-logging/src}/log_record.ts | 0 packages/kbn-logging/src/logger.ts | 96 +++++++++++ .../kbn-logging/src}/logger_factory.ts | 0 packages/kbn-logging/src/mocks/index.ts | 20 +++ packages/kbn-logging/src/mocks/logger.mock.ts | 70 ++++++++ packages/kbn-logging/tsconfig.json | 11 ++ packages/kbn-logging/yarn.lock | 1 + packages/kbn-std/package.json | 3 +- packages/kbn-std/src/index.ts | 2 +- packages/kbn-std/src/url.ts | 7 +- packages/kbn-std/tsconfig.json | 5 +- .../reload_logging_config.test.ts | 3 +- src/core/public/public.api.md | 29 +--- src/core/server/bootstrap.ts | 10 +- .../capabilities_service.test.ts | 6 +- .../deprecation/core_deprecations.test.ts | 3 +- .../config/deprecation/core_deprecations.ts | 2 +- src/core/server/config/deprecation/index.ts | 9 -- src/core/server/config/index.ts | 26 +-- src/core/server/config/mocks.ts | 25 +++ src/core/server/core_context.mock.ts | 7 +- .../elasticsearch_config.test.ts | 2 +- .../elasticsearch_service.test.ts | 6 +- .../environment/environment_service.test.ts | 3 +- .../http/cookie_session_storage.test.ts | 10 +- src/core/server/http/http_service.mock.ts | 2 +- src/core/server/http/http_service.test.ts | 11 +- .../lifecycle_handlers.test.ts | 2 +- src/core/server/http/test_utils.ts | 6 +- .../config/ensure_valid_configuration.test.ts | 2 +- src/core/server/legacy/config/index.ts | 1 - src/core/server/legacy/index.ts | 2 +- .../legacy/integration_tests/logging.test.ts | 4 +- .../server/legacy/legacy_internals.test.ts | 2 +- src/core/server/legacy/legacy_service.test.ts | 8 +- .../logging/appenders/legacy_appender.test.ts | 3 +- .../logging/appenders/legacy_appender.ts | 3 +- .../logging/legacy_logging_server.test.ts | 2 +- .../legacy/logging/legacy_logging_server.ts | 3 +- .../server/logging/appenders/appenders.ts | 21 +-- .../appenders/buffer/buffer_appender.test.ts | 3 +- .../appenders/buffer/buffer_appender.ts | 3 +- .../console/console_appender.test.ts | 3 +- .../appenders/console/console_appender.ts | 6 +- .../appenders/file/file_appender.test.ts | 3 +- .../logging/appenders/file/file_appender.ts | 5 +- src/core/server/logging/index.ts | 15 +- .../logging/layouts/conversions/date.ts | 2 +- .../logging/layouts/conversions/level.ts | 3 +- .../logging/layouts/conversions/logger.ts | 2 +- .../logging/layouts/conversions/message.ts | 2 +- .../logging/layouts/conversions/meta.ts | 3 +- .../server/logging/layouts/conversions/pid.ts | 2 +- .../logging/layouts/conversions/type.ts | 3 +- .../logging/layouts/json_layout.test.ts | 3 +- .../server/logging/layouts/json_layout.ts | 4 +- src/core/server/logging/layouts/layouts.ts | 10 +- .../logging/layouts/pattern_layout.test.ts | 3 +- .../server/logging/layouts/pattern_layout.ts | 3 +- src/core/server/logging/logger.mock.ts | 28 +--- src/core/server/logging/logger.test.ts | 3 +- src/core/server/logging/logger.ts | 81 +--------- src/core/server/logging/logger_adapter.ts | 3 +- src/core/server/logging/logging_service.ts | 2 +- .../server/logging/logging_system.mock.ts | 20 +-- src/core/server/logging/logging_system.ts | 8 +- .../server/metrics/metrics_service.test.ts | 3 +- src/core/server/mocks.ts | 2 +- .../plugin_manifest_parser.test.mocks.ts | 8 +- .../discovery/plugin_manifest_parser.test.ts | 4 +- .../discovery/plugins_discovery.test.mocks.ts | 9 +- .../discovery/plugins_discovery.test.ts | 8 +- .../plugins_service.test.mocks.ts | 12 +- .../integration_tests/plugins_service.test.ts | 7 +- src/core/server/plugins/plugin.test.ts | 6 +- .../server/plugins/plugin_context.test.ts | 6 +- .../server/plugins/plugins_config.test.ts | 7 +- .../plugins/plugins_service.test.mocks.ts | 24 ++- .../server/plugins/plugins_service.test.ts | 7 +- .../server/plugins/plugins_system.test.ts | 6 +- src/core/server/root/index.test.mocks.ts | 13 +- src/core/server/root/index.test.ts | 5 +- src/core/server/server.api.md | 152 ++++-------------- src/core/server/server.test.mocks.ts | 7 +- src/core/server/server.test.ts | 6 +- src/core/server/types.ts | 2 +- src/core/test_helpers/kbn_server.ts | 4 +- src/plugins/data/public/public.api.md | 4 + src/plugins/data/server/server.api.md | 6 + yarn.lock | 126 ++++++++++++++- 192 files changed, 1079 insertions(+), 1320 deletions(-) delete mode 100644 docs/development/core/public/kibana-plugin-core-public.environmentmode.dev.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.environmentmode.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.environmentmode.name.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.environmentmode.prod.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.packageinfo.branch.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.packageinfo.buildnum.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.packageinfo.buildsha.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.packageinfo.dist.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.packageinfo.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.packageinfo.version.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecation.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.rename.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.renamefromroot.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unused.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unusedfromroot.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationlogger.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configdeprecationprovider.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.configpath.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.environmentmode.dev.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.environmentmode.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.environmentmode.name.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.environmentmode.prod.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.debug.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.error.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.fatal.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.get.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.info.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.trace.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logger.warn.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.loggerfactory.get.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.loggerfactory.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.logmeta.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.packageinfo.branch.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.packageinfo.buildnum.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.packageinfo.buildsha.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.packageinfo.dist.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.packageinfo.md delete mode 100644 docs/development/core/server/kibana-plugin-core-server.packageinfo.version.md create mode 100644 packages/kbn-config/README.md rename {src/core/server/config => packages/kbn-config}/__fixtures__/config.yml (100%) rename {src/core/server/config => packages/kbn-config}/__fixtures__/config_flat.yml (100%) rename {src/core/server/config => packages/kbn-config}/__fixtures__/en_var_ref_config.yml (100%) rename {src/core/server/config => packages/kbn-config}/__fixtures__/one.yml (100%) rename {src/core/server/config => packages/kbn-config}/__fixtures__/two.yml (100%) create mode 100644 packages/kbn-config/package.json rename {src/core/server/config => packages/kbn-config/src}/__mocks__/env.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/__snapshots__/config_service.test.ts.snap (100%) rename {src/core/server/config => packages/kbn-config/src}/__snapshots__/env.test.ts.snap (100%) rename {src/core/server/config => packages/kbn-config/src}/apply_argv.test.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/config.mock.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/config.test.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/config.ts (99%) rename {src/core/server/config => packages/kbn-config/src}/config_service.mock.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/config_service.test.mocks.ts (94%) rename {src/core/server/config => packages/kbn-config/src}/config_service.test.ts (95%) rename {src/core/server/config => packages/kbn-config/src}/config_service.ts (97%) rename {src/core/server/config => packages/kbn-config/src}/deprecation/apply_deprecations.test.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/deprecation/apply_deprecations.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/deprecation/deprecation_factory.test.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/deprecation/deprecation_factory.ts (100%) create mode 100644 packages/kbn-config/src/deprecation/index.ts rename {src/core/server/config => packages/kbn-config/src}/deprecation/types.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/env.test.mocks.ts (81%) rename {src/core/server/config => packages/kbn-config/src}/env.test.ts (89%) rename {src/core/server/config => packages/kbn-config/src}/env.ts (87%) create mode 100644 packages/kbn-config/src/index.ts rename {src/core/server/legacy/config => packages/kbn-config/src/legacy}/__snapshots__/legacy_object_to_config_adapter.test.ts.snap (100%) create mode 100644 packages/kbn-config/src/legacy/index.ts rename {src/core/server/legacy/config => packages/kbn-config/src/legacy}/legacy_object_to_config_adapter.test.ts (100%) rename {src/core/server/legacy/config => packages/kbn-config/src/legacy}/legacy_object_to_config_adapter.ts (92%) create mode 100644 packages/kbn-config/src/mocks.ts rename {src/core/server/config => packages/kbn-config/src}/object_to_config_adapter.test.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/object_to_config_adapter.ts (100%) rename {src/core/server/config => packages/kbn-config/src/raw}/__snapshots__/read_config.test.ts.snap (100%) rename {src/core/server/config => packages/kbn-config/src/raw}/ensure_deep_object.test.ts (100%) rename {src/core/server/config => packages/kbn-config/src/raw}/ensure_deep_object.ts (100%) create mode 100644 packages/kbn-config/src/raw/index.ts rename {src/core/server/config => packages/kbn-config/src/raw}/raw_config_service.mock.ts (99%) rename {src/core/server/config => packages/kbn-config/src/raw}/raw_config_service.test.mocks.ts (100%) rename {src/core/server/config => packages/kbn-config/src/raw}/raw_config_service.test.ts (98%) rename {src/core/server/config => packages/kbn-config/src/raw}/raw_config_service.ts (100%) rename {src/core/server/config => packages/kbn-config/src/raw}/read_config.test.ts (96%) rename {src/core/server/config => packages/kbn-config/src/raw}/read_config.ts (100%) rename {src/core/server/config => packages/kbn-config/src}/types.ts (100%) create mode 100644 packages/kbn-config/tsconfig.json create mode 120000 packages/kbn-config/yarn.lock create mode 100644 packages/kbn-logging/README.md create mode 100644 packages/kbn-logging/package.json create mode 100644 packages/kbn-logging/src/appenders.ts create mode 100644 packages/kbn-logging/src/index.ts create mode 100644 packages/kbn-logging/src/layout.ts rename {src/core/server/logging => packages/kbn-logging/src}/log_level.test.ts (100%) rename {src/core/server/logging => packages/kbn-logging/src}/log_level.ts (100%) rename {src/core/server/logging => packages/kbn-logging/src}/log_record.ts (100%) create mode 100644 packages/kbn-logging/src/logger.ts rename {src/core/server/logging => packages/kbn-logging/src}/logger_factory.ts (100%) create mode 100644 packages/kbn-logging/src/mocks/index.ts create mode 100644 packages/kbn-logging/src/mocks/logger.mock.ts create mode 100644 packages/kbn-logging/tsconfig.json create mode 120000 packages/kbn-logging/yarn.lock create mode 100644 src/core/server/config/mocks.ts diff --git a/docs/development/core/public/kibana-plugin-core-public.environmentmode.dev.md b/docs/development/core/public/kibana-plugin-core-public.environmentmode.dev.md deleted file mode 100644 index 68ea11c62cf96..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.environmentmode.dev.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) > [dev](./kibana-plugin-core-public.environmentmode.dev.md) - -## EnvironmentMode.dev property - -Signature: - -```typescript -dev: boolean; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.environmentmode.md b/docs/development/core/public/kibana-plugin-core-public.environmentmode.md deleted file mode 100644 index 34ca3a0000563..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.environmentmode.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) - -## EnvironmentMode interface - - -Signature: - -```typescript -export interface EnvironmentMode -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [dev](./kibana-plugin-core-public.environmentmode.dev.md) | boolean | | -| [name](./kibana-plugin-core-public.environmentmode.name.md) | 'development' | 'production' | | -| [prod](./kibana-plugin-core-public.environmentmode.prod.md) | boolean | | - diff --git a/docs/development/core/public/kibana-plugin-core-public.environmentmode.name.md b/docs/development/core/public/kibana-plugin-core-public.environmentmode.name.md deleted file mode 100644 index 2d1722a82417c..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.environmentmode.name.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) > [name](./kibana-plugin-core-public.environmentmode.name.md) - -## EnvironmentMode.name property - -Signature: - -```typescript -name: 'development' | 'production'; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.environmentmode.prod.md b/docs/development/core/public/kibana-plugin-core-public.environmentmode.prod.md deleted file mode 100644 index 5145f8f6887e5..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.environmentmode.prod.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) > [prod](./kibana-plugin-core-public.environmentmode.prod.md) - -## EnvironmentMode.prod property - -Signature: - -```typescript -prod: boolean; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.md b/docs/development/core/public/kibana-plugin-core-public.md index f2bf72a597656..85ef00d271415 100644 --- a/docs/development/core/public/kibana-plugin-core-public.md +++ b/docs/development/core/public/kibana-plugin-core-public.md @@ -55,7 +55,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [CoreSetup](./kibana-plugin-core-public.coresetup.md) | Core services exposed to the Plugin setup lifecycle | | [CoreStart](./kibana-plugin-core-public.corestart.md) | Core services exposed to the Plugin start lifecycle | | [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) | | -| [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) | | | [ErrorToastOptions](./kibana-plugin-core-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) error APIs. | | [FatalErrorInfo](./kibana-plugin-core-public.fatalerrorinfo.md) | Represents the message and stack of a fatal Error | | [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. | @@ -85,7 +84,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [OverlayBannersStart](./kibana-plugin-core-public.overlaybannersstart.md) | | | [OverlayRef](./kibana-plugin-core-public.overlayref.md) | Returned by [OverlayStart](./kibana-plugin-core-public.overlaystart.md) methods for closing a mounted overlay. | | [OverlayStart](./kibana-plugin-core-public.overlaystart.md) | | -| [PackageInfo](./kibana-plugin-core-public.packageinfo.md) | | | [Plugin](./kibana-plugin-core-public.plugin.md) | The interface that should be returned by a PluginInitializer. | | [PluginInitializerContext](./kibana-plugin-core-public.plugininitializercontext.md) | The available core services passed to a PluginInitializer | | [SavedObject](./kibana-plugin-core-public.savedobject.md) | | diff --git a/docs/development/core/public/kibana-plugin-core-public.packageinfo.branch.md b/docs/development/core/public/kibana-plugin-core-public.packageinfo.branch.md deleted file mode 100644 index 24fd8a74c84f1..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.packageinfo.branch.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PackageInfo](./kibana-plugin-core-public.packageinfo.md) > [branch](./kibana-plugin-core-public.packageinfo.branch.md) - -## PackageInfo.branch property - -Signature: - -```typescript -branch: string; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.packageinfo.buildnum.md b/docs/development/core/public/kibana-plugin-core-public.packageinfo.buildnum.md deleted file mode 100644 index b849b7bdc2a54..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.packageinfo.buildnum.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PackageInfo](./kibana-plugin-core-public.packageinfo.md) > [buildNum](./kibana-plugin-core-public.packageinfo.buildnum.md) - -## PackageInfo.buildNum property - -Signature: - -```typescript -buildNum: number; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.packageinfo.buildsha.md b/docs/development/core/public/kibana-plugin-core-public.packageinfo.buildsha.md deleted file mode 100644 index 42e5a21ab2f54..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.packageinfo.buildsha.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PackageInfo](./kibana-plugin-core-public.packageinfo.md) > [buildSha](./kibana-plugin-core-public.packageinfo.buildsha.md) - -## PackageInfo.buildSha property - -Signature: - -```typescript -buildSha: string; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.packageinfo.dist.md b/docs/development/core/public/kibana-plugin-core-public.packageinfo.dist.md deleted file mode 100644 index ac6e39e07172b..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.packageinfo.dist.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PackageInfo](./kibana-plugin-core-public.packageinfo.md) > [dist](./kibana-plugin-core-public.packageinfo.dist.md) - -## PackageInfo.dist property - -Signature: - -```typescript -dist: boolean; -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.packageinfo.md b/docs/development/core/public/kibana-plugin-core-public.packageinfo.md deleted file mode 100644 index e819fb7990e5d..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.packageinfo.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PackageInfo](./kibana-plugin-core-public.packageinfo.md) - -## PackageInfo interface - - -Signature: - -```typescript -export interface PackageInfo -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [branch](./kibana-plugin-core-public.packageinfo.branch.md) | string | | -| [buildNum](./kibana-plugin-core-public.packageinfo.buildnum.md) | number | | -| [buildSha](./kibana-plugin-core-public.packageinfo.buildsha.md) | string | | -| [dist](./kibana-plugin-core-public.packageinfo.dist.md) | boolean | | -| [version](./kibana-plugin-core-public.packageinfo.version.md) | string | | - diff --git a/docs/development/core/public/kibana-plugin-core-public.packageinfo.version.md b/docs/development/core/public/kibana-plugin-core-public.packageinfo.version.md deleted file mode 100644 index 5a7649a1445f6..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.packageinfo.version.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PackageInfo](./kibana-plugin-core-public.packageinfo.md) > [version](./kibana-plugin-core-public.packageinfo.version.md) - -## PackageInfo.version property - -Signature: - -```typescript -version: string; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecation.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecation.md deleted file mode 100644 index 6fa74bccb4fc5..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecation.md +++ /dev/null @@ -1,18 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) - -## ConfigDeprecation type - -Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-core-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. - -Signature: - -```typescript -export declare type ConfigDeprecation = (config: Record, fromPath: string, logger: ConfigDeprecationLogger) => Record; -``` - -## Remarks - -This should only be manually implemented if [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) does not provide the proper helpers for a specific deprecation need. - diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.md deleted file mode 100644 index 8b34b379af67e..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.md +++ /dev/null @@ -1,36 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) - -## ConfigDeprecationFactory interface - -Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-core-server.configdeprecationprovider.md). - -See methods documentation for more detailed examples. - -Signature: - -```typescript -export interface ConfigDeprecationFactory -``` - -## Example - - -```typescript -const provider: ConfigDeprecationProvider = ({ rename, unused }) => [ - rename('oldKey', 'newKey'), - unused('deprecatedKey'), -] - -``` - -## Methods - -| Method | Description | -| --- | --- | -| [rename(oldKey, newKey)](./kibana-plugin-core-server.configdeprecationfactory.rename.md) | Rename a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the oldKey was found and deprecation applied. | -| [renameFromRoot(oldKey, newKey, silent)](./kibana-plugin-core-server.configdeprecationfactory.renamefromroot.md) | Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied.This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. | -| [unused(unusedKey)](./kibana-plugin-core-server.configdeprecationfactory.unused.md) | Remove a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the unused key was found and deprecation applied. | -| [unusedFromRoot(unusedKey)](./kibana-plugin-core-server.configdeprecationfactory.unusedfromroot.md) | Remove a configuration property from the root configuration. Will log a deprecation warning if the unused key was found and deprecation applied.This should be only used when removing properties from outside of a plugin's configuration. To remove properties from inside a plugin's configuration, use 'unused' instead. | - diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.rename.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.rename.md deleted file mode 100644 index 91bf1b86fe52e..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.rename.md +++ /dev/null @@ -1,36 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) > [rename](./kibana-plugin-core-server.configdeprecationfactory.rename.md) - -## ConfigDeprecationFactory.rename() method - -Rename a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the oldKey was found and deprecation applied. - -Signature: - -```typescript -rename(oldKey: string, newKey: string): ConfigDeprecation; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| oldKey | string | | -| newKey | string | | - -Returns: - -`ConfigDeprecation` - -## Example - -Rename 'myplugin.oldKey' to 'myplugin.newKey' - -```typescript -const provider: ConfigDeprecationProvider = ({ rename }) => [ - rename('oldKey', 'newKey'), -] - -``` - diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.renamefromroot.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.renamefromroot.md deleted file mode 100644 index cc8cde9a5ed79..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.renamefromroot.md +++ /dev/null @@ -1,39 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) > [renameFromRoot](./kibana-plugin-core-server.configdeprecationfactory.renamefromroot.md) - -## ConfigDeprecationFactory.renameFromRoot() method - -Rename a configuration property from the root configuration. Will log a deprecation warning if the oldKey was found and deprecation applied. - -This should be only used when renaming properties from different configuration's path. To rename properties from inside a plugin's configuration, use 'rename' instead. - -Signature: - -```typescript -renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| oldKey | string | | -| newKey | string | | -| silent | boolean | | - -Returns: - -`ConfigDeprecation` - -## Example - -Rename 'oldplugin.key' to 'newplugin.key' - -```typescript -const provider: ConfigDeprecationProvider = ({ renameFromRoot }) => [ - renameFromRoot('oldplugin.key', 'newplugin.key'), -] - -``` - diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unused.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unused.md deleted file mode 100644 index e7443b135984f..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unused.md +++ /dev/null @@ -1,35 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) > [unused](./kibana-plugin-core-server.configdeprecationfactory.unused.md) - -## ConfigDeprecationFactory.unused() method - -Remove a configuration property from inside a plugin's configuration path. Will log a deprecation warning if the unused key was found and deprecation applied. - -Signature: - -```typescript -unused(unusedKey: string): ConfigDeprecation; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unusedKey | string | | - -Returns: - -`ConfigDeprecation` - -## Example - -Flags 'myplugin.deprecatedKey' as unused - -```typescript -const provider: ConfigDeprecationProvider = ({ unused }) => [ - unused('deprecatedKey'), -] - -``` - diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unusedfromroot.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unusedfromroot.md deleted file mode 100644 index 8d5ed349e60e9..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationfactory.unusedfromroot.md +++ /dev/null @@ -1,37 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) > [unusedFromRoot](./kibana-plugin-core-server.configdeprecationfactory.unusedfromroot.md) - -## ConfigDeprecationFactory.unusedFromRoot() method - -Remove a configuration property from the root configuration. Will log a deprecation warning if the unused key was found and deprecation applied. - -This should be only used when removing properties from outside of a plugin's configuration. To remove properties from inside a plugin's configuration, use 'unused' instead. - -Signature: - -```typescript -unusedFromRoot(unusedKey: string): ConfigDeprecation; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| unusedKey | string | | - -Returns: - -`ConfigDeprecation` - -## Example - -Flags 'somepath.deprecatedProperty' as unused - -```typescript -const provider: ConfigDeprecationProvider = ({ unusedFromRoot }) => [ - unusedFromRoot('somepath.deprecatedProperty'), -] - -``` - diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationlogger.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationlogger.md deleted file mode 100644 index 15da7d24b4a7c..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationlogger.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationLogger](./kibana-plugin-core-server.configdeprecationlogger.md) - -## ConfigDeprecationLogger type - -Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) - -Signature: - -```typescript -export declare type ConfigDeprecationLogger = (message: string) => void; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.configdeprecationprovider.md b/docs/development/core/server/kibana-plugin-core-server.configdeprecationprovider.md deleted file mode 100644 index 64351cbdb4a71..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configdeprecationprovider.md +++ /dev/null @@ -1,28 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigDeprecationProvider](./kibana-plugin-core-server.configdeprecationprovider.md) - -## ConfigDeprecationProvider type - -A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md). - -See [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) for more usage examples. - -Signature: - -```typescript -export declare type ConfigDeprecationProvider = (factory: ConfigDeprecationFactory) => ConfigDeprecation[]; -``` - -## Example - - -```typescript -const provider: ConfigDeprecationProvider = ({ rename, unused }) => [ - rename('oldKey', 'newKey'), - unused('deprecatedKey'), - myCustomDeprecation, -] - -``` - diff --git a/docs/development/core/server/kibana-plugin-core-server.configpath.md b/docs/development/core/server/kibana-plugin-core-server.configpath.md deleted file mode 100644 index 0b15d3ca727f2..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.configpath.md +++ /dev/null @@ -1,12 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ConfigPath](./kibana-plugin-core-server.configpath.md) - -## ConfigPath type - - -Signature: - -```typescript -export declare type ConfigPath = string | string[]; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.environmentmode.dev.md b/docs/development/core/server/kibana-plugin-core-server.environmentmode.dev.md deleted file mode 100644 index c1b9d5b7e19b1..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.environmentmode.dev.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) > [dev](./kibana-plugin-core-server.environmentmode.dev.md) - -## EnvironmentMode.dev property - -Signature: - -```typescript -dev: boolean; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.environmentmode.md b/docs/development/core/server/kibana-plugin-core-server.environmentmode.md deleted file mode 100644 index 94795754739ab..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.environmentmode.md +++ /dev/null @@ -1,21 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) - -## EnvironmentMode interface - - -Signature: - -```typescript -export interface EnvironmentMode -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [dev](./kibana-plugin-core-server.environmentmode.dev.md) | boolean | | -| [name](./kibana-plugin-core-server.environmentmode.name.md) | 'development' | 'production' | | -| [prod](./kibana-plugin-core-server.environmentmode.prod.md) | boolean | | - diff --git a/docs/development/core/server/kibana-plugin-core-server.environmentmode.name.md b/docs/development/core/server/kibana-plugin-core-server.environmentmode.name.md deleted file mode 100644 index 5627deab9e83e..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.environmentmode.name.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) > [name](./kibana-plugin-core-server.environmentmode.name.md) - -## EnvironmentMode.name property - -Signature: - -```typescript -name: 'development' | 'production'; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.environmentmode.prod.md b/docs/development/core/server/kibana-plugin-core-server.environmentmode.prod.md deleted file mode 100644 index 1ed3fa33b8997..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.environmentmode.prod.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) > [prod](./kibana-plugin-core-server.environmentmode.prod.md) - -## EnvironmentMode.prod property - -Signature: - -```typescript -prod: boolean; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.debug.md b/docs/development/core/server/kibana-plugin-core-server.logger.debug.md deleted file mode 100644 index c2b95d92b21d1..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.debug.md +++ /dev/null @@ -1,25 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [debug](./kibana-plugin-core-server.logger.debug.md) - -## Logger.debug() method - -Log messages useful for debugging and interactive investigation - -Signature: - -```typescript -debug(message: string, meta?: LogMeta): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| message | string | The log message | -| meta | LogMeta | | - -Returns: - -`void` - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.error.md b/docs/development/core/server/kibana-plugin-core-server.logger.error.md deleted file mode 100644 index 68e7499fabc32..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.error.md +++ /dev/null @@ -1,25 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [error](./kibana-plugin-core-server.logger.error.md) - -## Logger.error() method - -Logs abnormal or unexpected errors or messages that caused a failure in the application flow - -Signature: - -```typescript -error(errorOrMessage: string | Error, meta?: LogMeta): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| errorOrMessage | string | Error | An Error object or message string to log | -| meta | LogMeta | | - -Returns: - -`void` - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.fatal.md b/docs/development/core/server/kibana-plugin-core-server.logger.fatal.md deleted file mode 100644 index d39194d2126b7..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.fatal.md +++ /dev/null @@ -1,25 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [fatal](./kibana-plugin-core-server.logger.fatal.md) - -## Logger.fatal() method - -Logs abnormal or unexpected errors or messages that caused an unrecoverable failure - -Signature: - -```typescript -fatal(errorOrMessage: string | Error, meta?: LogMeta): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| errorOrMessage | string | Error | An Error object or message string to log | -| meta | LogMeta | | - -Returns: - -`void` - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.get.md b/docs/development/core/server/kibana-plugin-core-server.logger.get.md deleted file mode 100644 index 5f69831a73808..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.get.md +++ /dev/null @@ -1,33 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [get](./kibana-plugin-core-server.logger.get.md) - -## Logger.get() method - -Returns a new [Logger](./kibana-plugin-core-server.logger.md) instance extending the current logger context. - -Signature: - -```typescript -get(...childContextPaths: string[]): Logger; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| childContextPaths | string[] | | - -Returns: - -`Logger` - -## Example - - -```typescript -const logger = loggerFactory.get('plugin', 'service'); // 'plugin.service' context -const subLogger = logger.get('feature'); // 'plugin.service.feature' context - -``` - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.info.md b/docs/development/core/server/kibana-plugin-core-server.logger.info.md deleted file mode 100644 index 7e786ed0e3f9b..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.info.md +++ /dev/null @@ -1,25 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [info](./kibana-plugin-core-server.logger.info.md) - -## Logger.info() method - -Logs messages related to general application flow - -Signature: - -```typescript -info(message: string, meta?: LogMeta): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| message | string | The log message | -| meta | LogMeta | | - -Returns: - -`void` - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.md b/docs/development/core/server/kibana-plugin-core-server.logger.md deleted file mode 100644 index 7012358524c35..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.md +++ /dev/null @@ -1,26 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) - -## Logger interface - -Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. - -Signature: - -```typescript -export interface Logger -``` - -## Methods - -| Method | Description | -| --- | --- | -| [debug(message, meta)](./kibana-plugin-core-server.logger.debug.md) | Log messages useful for debugging and interactive investigation | -| [error(errorOrMessage, meta)](./kibana-plugin-core-server.logger.error.md) | Logs abnormal or unexpected errors or messages that caused a failure in the application flow | -| [fatal(errorOrMessage, meta)](./kibana-plugin-core-server.logger.fatal.md) | Logs abnormal or unexpected errors or messages that caused an unrecoverable failure | -| [get(childContextPaths)](./kibana-plugin-core-server.logger.get.md) | Returns a new [Logger](./kibana-plugin-core-server.logger.md) instance extending the current logger context. | -| [info(message, meta)](./kibana-plugin-core-server.logger.info.md) | Logs messages related to general application flow | -| [trace(message, meta)](./kibana-plugin-core-server.logger.trace.md) | Log messages at the most detailed log level | -| [warn(errorOrMessage, meta)](./kibana-plugin-core-server.logger.warn.md) | Logs abnormal or unexpected errors or messages | - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.trace.md b/docs/development/core/server/kibana-plugin-core-server.logger.trace.md deleted file mode 100644 index b8d761f69541e..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.trace.md +++ /dev/null @@ -1,25 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [trace](./kibana-plugin-core-server.logger.trace.md) - -## Logger.trace() method - -Log messages at the most detailed log level - -Signature: - -```typescript -trace(message: string, meta?: LogMeta): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| message | string | The log message | -| meta | LogMeta | | - -Returns: - -`void` - diff --git a/docs/development/core/server/kibana-plugin-core-server.logger.warn.md b/docs/development/core/server/kibana-plugin-core-server.logger.warn.md deleted file mode 100644 index 21cefe4f748dd..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logger.warn.md +++ /dev/null @@ -1,25 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [Logger](./kibana-plugin-core-server.logger.md) > [warn](./kibana-plugin-core-server.logger.warn.md) - -## Logger.warn() method - -Logs abnormal or unexpected errors or messages - -Signature: - -```typescript -warn(errorOrMessage: string | Error, meta?: LogMeta): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| errorOrMessage | string | Error | An Error object or message string to log | -| meta | LogMeta | | - -Returns: - -`void` - diff --git a/docs/development/core/server/kibana-plugin-core-server.loggerfactory.get.md b/docs/development/core/server/kibana-plugin-core-server.loggerfactory.get.md deleted file mode 100644 index d081d359b9480..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.loggerfactory.get.md +++ /dev/null @@ -1,24 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [LoggerFactory](./kibana-plugin-core-server.loggerfactory.md) > [get](./kibana-plugin-core-server.loggerfactory.get.md) - -## LoggerFactory.get() method - -Returns a `Logger` instance for the specified context. - -Signature: - -```typescript -get(...contextParts: string[]): Logger; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| contextParts | string[] | Parts of the context to return logger for. For example get('plugins', 'pid') will return a logger for the plugins.pid context. | - -Returns: - -`Logger` - diff --git a/docs/development/core/server/kibana-plugin-core-server.loggerfactory.md b/docs/development/core/server/kibana-plugin-core-server.loggerfactory.md deleted file mode 100644 index 8795413bf675a..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.loggerfactory.md +++ /dev/null @@ -1,20 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [LoggerFactory](./kibana-plugin-core-server.loggerfactory.md) - -## LoggerFactory interface - -The single purpose of `LoggerFactory` interface is to define a way to retrieve a context-based logger instance. - -Signature: - -```typescript -export interface LoggerFactory -``` - -## Methods - -| Method | Description | -| --- | --- | -| [get(contextParts)](./kibana-plugin-core-server.loggerfactory.get.md) | Returns a Logger instance for the specified context. | - diff --git a/docs/development/core/server/kibana-plugin-core-server.logmeta.md b/docs/development/core/server/kibana-plugin-core-server.logmeta.md deleted file mode 100644 index 56a2af7e826c6..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.logmeta.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [LogMeta](./kibana-plugin-core-server.logmeta.md) - -## LogMeta interface - -Contextual metadata - -Signature: - -```typescript -export interface LogMeta -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md index 30b98b9f0553e..69f2cf0338a01 100644 --- a/docs/development/core/server/kibana-plugin-core-server.md +++ b/docs/development/core/server/kibana-plugin-core-server.md @@ -65,7 +65,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [Capabilities](./kibana-plugin-core-server.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. | | [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) | APIs to manage the [Capabilities](./kibana-plugin-core-server.capabilities.md) that will be used by the application.Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the registerProvider method.Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the registerSwitcher method.Refers to the methods documentation for complete description and examples. | | [CapabilitiesStart](./kibana-plugin-core-server.capabilitiesstart.md) | APIs to access the application [Capabilities](./kibana-plugin-core-server.capabilities.md). | -| [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) | Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-core-server.configdeprecationprovider.md).See methods documentation for more detailed examples. | | [ContextSetup](./kibana-plugin-core-server.contextsetup.md) | An object that handles registration of context providers and configuring handlers with context. | | [CoreSetup](./kibana-plugin-core-server.coresetup.md) | Context passed to the plugins setup method. | | [CoreStart](./kibana-plugin-core-server.corestart.md) | Context passed to the plugins start method. | @@ -81,7 +80,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) | | | [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) | | | [ElasticsearchStatusMeta](./kibana-plugin-core-server.elasticsearchstatusmeta.md) | | -| [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) | | | [ErrorHttpResponseOptions](./kibana-plugin-core-server.errorhttpresponseoptions.md) | HTTP response parameters | | [Explanation](./kibana-plugin-core-server.explanation.md) | | | [FakeRequest](./kibana-plugin-core-server.fakerequest.md) | Fake request object created manually by Kibana plugins. | @@ -114,11 +112,8 @@ The plugin integrates with the core system via lifecycle events: `setup` | [LegacyRequest](./kibana-plugin-core-server.legacyrequest.md) | | | [LegacyServiceSetupDeps](./kibana-plugin-core-server.legacyservicesetupdeps.md) | | | [LegacyServiceStartDeps](./kibana-plugin-core-server.legacyservicestartdeps.md) | | -| [Logger](./kibana-plugin-core-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. | | [LoggerContextConfigInput](./kibana-plugin-core-server.loggercontextconfiginput.md) | | -| [LoggerFactory](./kibana-plugin-core-server.loggerfactory.md) | The single purpose of LoggerFactory interface is to define a way to retrieve a context-based logger instance. | | [LoggingServiceSetup](./kibana-plugin-core-server.loggingservicesetup.md) | Provides APIs to plugins for customizing the plugin's logger. | -| [LogMeta](./kibana-plugin-core-server.logmeta.md) | Contextual metadata | | [MetricsServiceSetup](./kibana-plugin-core-server.metricsservicesetup.md) | APIs to retrieves metrics gathered and exposed by the core platform. | | [NodesVersionCompatibility](./kibana-plugin-core-server.nodesversioncompatibility.md) | | | [OnPostAuthToolkit](./kibana-plugin-core-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. | @@ -131,7 +126,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [OpsOsMetrics](./kibana-plugin-core-server.opsosmetrics.md) | OS related metrics | | [OpsProcessMetrics](./kibana-plugin-core-server.opsprocessmetrics.md) | Process related metrics | | [OpsServerMetrics](./kibana-plugin-core-server.opsservermetrics.md) | server related metrics | -| [PackageInfo](./kibana-plugin-core-server.packageinfo.md) | | | [Plugin](./kibana-plugin-core-server.plugin.md) | The interface that should be returned by a PluginInitializer. | | [PluginConfigDescriptor](./kibana-plugin-core-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. | | [PluginInitializerContext](./kibana-plugin-core-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. | @@ -233,10 +227,6 @@ The plugin integrates with the core system via lifecycle events: `setup` | [AuthResult](./kibana-plugin-core-server.authresult.md) | | | [CapabilitiesProvider](./kibana-plugin-core-server.capabilitiesprovider.md) | See [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) | | [CapabilitiesSwitcher](./kibana-plugin-core-server.capabilitiesswitcher.md) | See [CapabilitiesSetup](./kibana-plugin-core-server.capabilitiessetup.md) | -| [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) | Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-core-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. | -| [ConfigDeprecationLogger](./kibana-plugin-core-server.configdeprecationlogger.md) | Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) | -| [ConfigDeprecationProvider](./kibana-plugin-core-server.configdeprecationprovider.md) | A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md).See [ConfigDeprecationFactory](./kibana-plugin-core-server.configdeprecationfactory.md) for more usage examples. | -| [ConfigPath](./kibana-plugin-core-server.configpath.md) | | | [DestructiveRouteMethod](./kibana-plugin-core-server.destructiveroutemethod.md) | Set of HTTP methods changing the state of the server. | | [ElasticsearchClient](./kibana-plugin-core-server.elasticsearchclient.md) | Client used to query the elasticsearch cluster. | | [ElasticsearchClientConfig](./kibana-plugin-core-server.elasticsearchclientconfig.md) | Configuration options to be used to create a [cluster client](./kibana-plugin-core-server.iclusterclient.md) using the [createClient API](./kibana-plugin-core-server.elasticsearchservicestart.createclient.md) | diff --git a/docs/development/core/server/kibana-plugin-core-server.packageinfo.branch.md b/docs/development/core/server/kibana-plugin-core-server.packageinfo.branch.md deleted file mode 100644 index 34fbd56045921..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.packageinfo.branch.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PackageInfo](./kibana-plugin-core-server.packageinfo.md) > [branch](./kibana-plugin-core-server.packageinfo.branch.md) - -## PackageInfo.branch property - -Signature: - -```typescript -branch: string; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.packageinfo.buildnum.md b/docs/development/core/server/kibana-plugin-core-server.packageinfo.buildnum.md deleted file mode 100644 index acc33fae18fbc..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.packageinfo.buildnum.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PackageInfo](./kibana-plugin-core-server.packageinfo.md) > [buildNum](./kibana-plugin-core-server.packageinfo.buildnum.md) - -## PackageInfo.buildNum property - -Signature: - -```typescript -buildNum: number; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.packageinfo.buildsha.md b/docs/development/core/server/kibana-plugin-core-server.packageinfo.buildsha.md deleted file mode 100644 index 14ad75168fd85..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.packageinfo.buildsha.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PackageInfo](./kibana-plugin-core-server.packageinfo.md) > [buildSha](./kibana-plugin-core-server.packageinfo.buildsha.md) - -## PackageInfo.buildSha property - -Signature: - -```typescript -buildSha: string; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.packageinfo.dist.md b/docs/development/core/server/kibana-plugin-core-server.packageinfo.dist.md deleted file mode 100644 index d7567010ddd53..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.packageinfo.dist.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PackageInfo](./kibana-plugin-core-server.packageinfo.md) > [dist](./kibana-plugin-core-server.packageinfo.dist.md) - -## PackageInfo.dist property - -Signature: - -```typescript -dist: boolean; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.packageinfo.md b/docs/development/core/server/kibana-plugin-core-server.packageinfo.md deleted file mode 100644 index 3e1789d8df896..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.packageinfo.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PackageInfo](./kibana-plugin-core-server.packageinfo.md) - -## PackageInfo interface - - -Signature: - -```typescript -export interface PackageInfo -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [branch](./kibana-plugin-core-server.packageinfo.branch.md) | string | | -| [buildNum](./kibana-plugin-core-server.packageinfo.buildnum.md) | number | | -| [buildSha](./kibana-plugin-core-server.packageinfo.buildsha.md) | string | | -| [dist](./kibana-plugin-core-server.packageinfo.dist.md) | boolean | | -| [version](./kibana-plugin-core-server.packageinfo.version.md) | string | | - diff --git a/docs/development/core/server/kibana-plugin-core-server.packageinfo.version.md b/docs/development/core/server/kibana-plugin-core-server.packageinfo.version.md deleted file mode 100644 index 1606ab5901941..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.packageinfo.version.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [PackageInfo](./kibana-plugin-core-server.packageinfo.md) > [version](./kibana-plugin-core-server.packageinfo.version.md) - -## PackageInfo.version property - -Signature: - -```typescript -version: string; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.deprecations.md b/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.deprecations.md index d539b5a0501c1..d06b3cb9fa64a 100644 --- a/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.deprecations.md +++ b/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.deprecations.md @@ -4,7 +4,7 @@ ## PluginConfigDescriptor.deprecations property -Provider for the [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) to apply to the plugin configuration. +Provider for the to apply to the plugin configuration. Signature: diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.md b/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.md index 964d45f155948..5708c4f9a3f88 100644 --- a/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.md +++ b/docs/development/core/server/kibana-plugin-core-server.pluginconfigdescriptor.md @@ -44,7 +44,7 @@ export const config: PluginConfigDescriptor = { | Property | Type | Description | | --- | --- | --- | -| [deprecations](./kibana-plugin-core-server.pluginconfigdescriptor.deprecations.md) | ConfigDeprecationProvider | Provider for the [ConfigDeprecation](./kibana-plugin-core-server.configdeprecation.md) to apply to the plugin configuration. | +| [deprecations](./kibana-plugin-core-server.pluginconfigdescriptor.deprecations.md) | ConfigDeprecationProvider | Provider for the to apply to the plugin configuration. | | [exposeToBrowser](./kibana-plugin-core-server.pluginconfigdescriptor.exposetobrowser.md) | {
[P in keyof T]?: boolean;
} | List of configuration properties that will be available on the client-side plugin. | | [schema](./kibana-plugin-core-server.pluginconfigdescriptor.schema.md) | PluginConfigSchema<T> | Schema to use to validate the plugin configuration.[PluginConfigSchema](./kibana-plugin-core-server.pluginconfigschema.md) | diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.configpath.md b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.configpath.md index c391431e12b1c..8aa603242df8e 100644 --- a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.configpath.md +++ b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.configpath.md @@ -4,7 +4,7 @@ ## PluginManifest.configPath property -Root [configuration path](./kibana-plugin-core-server.configpath.md) used by the plugin, defaults to "id" in snake\_case format. +Root used by the plugin, defaults to "id" in snake\_case format. Signature: diff --git a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md index 6db2f89590149..b0182a7c48e16 100644 --- a/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md +++ b/docs/development/core/server/kibana-plugin-core-server.pluginmanifest.md @@ -20,7 +20,7 @@ Should never be used in code outside of Core but is exported for documentation p | Property | Type | Description | | --- | --- | --- | -| [configPath](./kibana-plugin-core-server.pluginmanifest.configpath.md) | ConfigPath | Root [configuration path](./kibana-plugin-core-server.configpath.md) used by the plugin, defaults to "id" in snake\_case format. | +| [configPath](./kibana-plugin-core-server.pluginmanifest.configpath.md) | ConfigPath | Root used by the plugin, defaults to "id" in snake\_case format. | | [extraPublicDirs](./kibana-plugin-core-server.pluginmanifest.extrapublicdirs.md) | string[] | Specifies directory names that can be imported by other ui-plugins built using the same instance of the @kbn/optimizer. A temporary measure we plan to replace with better mechanisms for sharing static code between plugins | | [id](./kibana-plugin-core-server.pluginmanifest.id.md) | PluginName | Identifier of the plugin. Must be a string in camelCase. Part of a plugin public contract. Other plugins leverage it to access plugin API, navigate to the plugin, etc. | | [kibanaVersion](./kibana-plugin-core-server.pluginmanifest.kibanaversion.md) | string | The version of Kibana the plugin is compatible with, defaults to "version". | diff --git a/package.json b/package.json index 8bbbaa341adf5..93fea19f631e3 100644 --- a/package.json +++ b/package.json @@ -134,9 +134,11 @@ "@hapi/wreck": "^15.0.2", "@kbn/analytics": "1.0.0", "@kbn/babel-preset": "1.0.0", + "@kbn/config": "1.0.0", "@kbn/config-schema": "1.0.0", "@kbn/i18n": "1.0.0", "@kbn/interpreter": "1.0.0", + "@kbn/logging": "1.0.0", "@kbn/pm": "1.0.0", "@kbn/std": "1.0.0", "@kbn/telemetry-tools": "1.0.0", diff --git a/packages/kbn-config/README.md b/packages/kbn-config/README.md new file mode 100644 index 0000000000000..343748cb0d817 --- /dev/null +++ b/packages/kbn-config/README.md @@ -0,0 +1,3 @@ +# `@kbn/config` — Kibana configuration file loader + +This package contains the configuration service used to load and read the kibana configuration file diff --git a/src/core/server/config/__fixtures__/config.yml b/packages/kbn-config/__fixtures__/config.yml similarity index 100% rename from src/core/server/config/__fixtures__/config.yml rename to packages/kbn-config/__fixtures__/config.yml diff --git a/src/core/server/config/__fixtures__/config_flat.yml b/packages/kbn-config/__fixtures__/config_flat.yml similarity index 100% rename from src/core/server/config/__fixtures__/config_flat.yml rename to packages/kbn-config/__fixtures__/config_flat.yml diff --git a/src/core/server/config/__fixtures__/en_var_ref_config.yml b/packages/kbn-config/__fixtures__/en_var_ref_config.yml similarity index 100% rename from src/core/server/config/__fixtures__/en_var_ref_config.yml rename to packages/kbn-config/__fixtures__/en_var_ref_config.yml diff --git a/src/core/server/config/__fixtures__/one.yml b/packages/kbn-config/__fixtures__/one.yml similarity index 100% rename from src/core/server/config/__fixtures__/one.yml rename to packages/kbn-config/__fixtures__/one.yml diff --git a/src/core/server/config/__fixtures__/two.yml b/packages/kbn-config/__fixtures__/two.yml similarity index 100% rename from src/core/server/config/__fixtures__/two.yml rename to packages/kbn-config/__fixtures__/two.yml diff --git a/packages/kbn-config/package.json b/packages/kbn-config/package.json new file mode 100644 index 0000000000000..2d9dbc3b7ab8f --- /dev/null +++ b/packages/kbn-config/package.json @@ -0,0 +1,30 @@ +{ + "name": "@kbn/config", + "main": "./target/index.js", + "types": "./target/index.d.ts", + "version": "1.0.0", + "license": "Apache-2.0", + "private": true, + "scripts": { + "build": "tsc", + "kbn:bootstrap": "yarn build" + }, + "dependencies": { + "@elastic/safer-lodash-set": "0.0.0", + "@kbn/config-schema": "1.0.0", + "@kbn/dev-utils": "1.0.0", + "@kbn/logging": "1.0.0", + "@kbn/std": "1.0.0", + "@kbn/utility-types": "1.0.0", + "js-yaml": "3.13.1", + "load-json-file": "^6.2.0", + "lodash": "^4.17.20", + "moment": "^2.24.0", + "rxjs": "^6.5.5", + "type-detect": "^4.0.8" + }, + "devDependencies": { + "typescript": "4.0.2", + "tsd": "^0.7.4" + } +} diff --git a/src/core/server/config/__mocks__/env.ts b/packages/kbn-config/src/__mocks__/env.ts similarity index 100% rename from src/core/server/config/__mocks__/env.ts rename to packages/kbn-config/src/__mocks__/env.ts diff --git a/src/core/server/config/__snapshots__/config_service.test.ts.snap b/packages/kbn-config/src/__snapshots__/config_service.test.ts.snap similarity index 100% rename from src/core/server/config/__snapshots__/config_service.test.ts.snap rename to packages/kbn-config/src/__snapshots__/config_service.test.ts.snap diff --git a/src/core/server/config/__snapshots__/env.test.ts.snap b/packages/kbn-config/src/__snapshots__/env.test.ts.snap similarity index 100% rename from src/core/server/config/__snapshots__/env.test.ts.snap rename to packages/kbn-config/src/__snapshots__/env.test.ts.snap diff --git a/src/core/server/config/apply_argv.test.ts b/packages/kbn-config/src/apply_argv.test.ts similarity index 100% rename from src/core/server/config/apply_argv.test.ts rename to packages/kbn-config/src/apply_argv.test.ts diff --git a/src/core/server/config/config.mock.ts b/packages/kbn-config/src/config.mock.ts similarity index 100% rename from src/core/server/config/config.mock.ts rename to packages/kbn-config/src/config.mock.ts diff --git a/src/core/server/config/config.test.ts b/packages/kbn-config/src/config.test.ts similarity index 100% rename from src/core/server/config/config.test.ts rename to packages/kbn-config/src/config.test.ts diff --git a/src/core/server/config/config.ts b/packages/kbn-config/src/config.ts similarity index 99% rename from src/core/server/config/config.ts rename to packages/kbn-config/src/config.ts index a4026b1d88ac3..3d012dd5f3885 100644 --- a/src/core/server/config/config.ts +++ b/packages/kbn-config/src/config.ts @@ -23,7 +23,7 @@ export type ConfigPath = string | string[]; /** * Checks whether specified value can be considered as config path. * @param value Value to check. - * @internal + * @public */ export function isConfigPath(value: unknown): value is ConfigPath { if (!value) { diff --git a/src/core/server/config/config_service.mock.ts b/packages/kbn-config/src/config_service.mock.ts similarity index 100% rename from src/core/server/config/config_service.mock.ts rename to packages/kbn-config/src/config_service.mock.ts diff --git a/src/core/server/config/config_service.test.mocks.ts b/packages/kbn-config/src/config_service.test.mocks.ts similarity index 94% rename from src/core/server/config/config_service.test.mocks.ts rename to packages/kbn-config/src/config_service.test.mocks.ts index 1299c4c0b4eb1..1b70802e9805e 100644 --- a/src/core/server/config/config_service.test.mocks.ts +++ b/packages/kbn-config/src/config_service.test.mocks.ts @@ -18,7 +18,7 @@ */ export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] }); -jest.mock('../../../../package.json', () => mockPackage); +jest.mock('../../../package.json', () => mockPackage); export const mockApplyDeprecations = jest.fn((config, deprecations, log) => config); jest.mock('./deprecation/apply_deprecations', () => ({ diff --git a/src/core/server/config/config_service.test.ts b/packages/kbn-config/src/config_service.test.ts similarity index 95% rename from src/core/server/config/config_service.test.ts rename to packages/kbn-config/src/config_service.test.ts index 95153447bd4a9..b32b405455700 100644 --- a/src/core/server/config/config_service.test.ts +++ b/packages/kbn-config/src/config_service.test.ts @@ -20,22 +20,36 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { first, take } from 'rxjs/operators'; -import { mockPackage, mockApplyDeprecations } from './config_service.test.mocks'; -import { rawConfigServiceMock } from './raw_config_service.mock'; +import { mockApplyDeprecations } from './config_service.test.mocks'; +import { rawConfigServiceMock } from './raw/raw_config_service.mock'; import { schema } from '@kbn/config-schema'; +import { MockedLogger, loggerMock } from '@kbn/logging/target/mocks'; + +import { ConfigService, Env, RawPackageInfo } from '.'; -import { ConfigService, Env } from '.'; -import { loggingSystemMock } from '../logging/logging_system.mock'; import { getEnvOptions } from './__mocks__/env'; +const packageInfos: RawPackageInfo = { + branch: 'master', + version: '8.0.0', + build: { + number: 42, + sha: 'one', + }, +}; const emptyArgv = getEnvOptions(); -const defaultEnv = new Env('/kibana', emptyArgv); -const logger = loggingSystemMock.create(); +const defaultEnv = new Env('/kibana', packageInfos, emptyArgv); + +let logger: MockedLogger; const getRawConfigProvider = (rawConfig: Record) => rawConfigServiceMock.create({ rawConfig }); +beforeEach(() => { + logger = loggerMock.create(); +}); + test('returns config at path as observable', async () => { const rawConfig = getRawConfigProvider({ key: 'foo' }); const configService = new ConfigService(rawConfig, defaultEnv, logger); @@ -237,7 +251,7 @@ test('tracks unhandled paths', async () => { }); test('correctly passes context', async () => { - mockPackage.raw = { + const mockPackage = { branch: 'feature-v1', version: 'v1', build: { @@ -247,7 +261,7 @@ test('correctly passes context', async () => { }, }; - const env = new Env('/kibana', getEnvOptions()); + const env = new Env('/kibana', mockPackage, getEnvOptions()); const rawConfigProvider = rawConfigServiceMock.create({ rawConfig: { foo: {} } }); const schemaDefinition = schema.object({ @@ -441,9 +455,9 @@ test('logs deprecation warning during validation', async () => { return config; }); - loggingSystemMock.clear(logger); + loggerMock.clear(logger); await configService.validate(); - expect(loggingSystemMock.collect(logger).warn).toMatchInlineSnapshot(` + expect(loggerMock.collect(logger).warn).toMatchInlineSnapshot(` Array [ Array [ "some deprecation message", diff --git a/src/core/server/config/config_service.ts b/packages/kbn-config/src/config_service.ts similarity index 97% rename from src/core/server/config/config_service.ts rename to packages/kbn-config/src/config_service.ts index d77ee980b0491..faa8397cd6d6e 100644 --- a/src/core/server/config/config_service.ts +++ b/packages/kbn-config/src/config_service.ts @@ -16,23 +16,24 @@ * specific language governing permissions and limitations * under the License. */ + import type { PublicMethodsOf } from '@kbn/utility-types'; import { Type } from '@kbn/config-schema'; import { isEqual } from 'lodash'; import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; import { distinctUntilChanged, first, map, shareReplay, take } from 'rxjs/operators'; +import { Logger, LoggerFactory } from '@kbn/logging'; import { Config, ConfigPath, Env } from '.'; -import { Logger, LoggerFactory } from '../logging'; import { hasConfigPathIntersection } from './config'; -import { RawConfigurationProvider } from './raw_config_service'; +import { RawConfigurationProvider } from './raw/raw_config_service'; import { applyDeprecations, ConfigDeprecationWithContext, ConfigDeprecationProvider, configDeprecationFactory, } from './deprecation'; -import { LegacyObjectToConfigAdapter } from '../legacy/config'; +import { LegacyObjectToConfigAdapter } from './legacy'; /** @internal */ export type IConfigService = PublicMethodsOf; diff --git a/src/core/server/config/deprecation/apply_deprecations.test.ts b/packages/kbn-config/src/deprecation/apply_deprecations.test.ts similarity index 100% rename from src/core/server/config/deprecation/apply_deprecations.test.ts rename to packages/kbn-config/src/deprecation/apply_deprecations.test.ts diff --git a/src/core/server/config/deprecation/apply_deprecations.ts b/packages/kbn-config/src/deprecation/apply_deprecations.ts similarity index 100% rename from src/core/server/config/deprecation/apply_deprecations.ts rename to packages/kbn-config/src/deprecation/apply_deprecations.ts diff --git a/src/core/server/config/deprecation/deprecation_factory.test.ts b/packages/kbn-config/src/deprecation/deprecation_factory.test.ts similarity index 100% rename from src/core/server/config/deprecation/deprecation_factory.test.ts rename to packages/kbn-config/src/deprecation/deprecation_factory.test.ts diff --git a/src/core/server/config/deprecation/deprecation_factory.ts b/packages/kbn-config/src/deprecation/deprecation_factory.ts similarity index 100% rename from src/core/server/config/deprecation/deprecation_factory.ts rename to packages/kbn-config/src/deprecation/deprecation_factory.ts diff --git a/packages/kbn-config/src/deprecation/index.ts b/packages/kbn-config/src/deprecation/index.ts new file mode 100644 index 0000000000000..504dbfeeb001a --- /dev/null +++ b/packages/kbn-config/src/deprecation/index.ts @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + ConfigDeprecation, + ConfigDeprecationWithContext, + ConfigDeprecationLogger, + ConfigDeprecationFactory, + ConfigDeprecationProvider, +} from './types'; +export { configDeprecationFactory } from './deprecation_factory'; +export { applyDeprecations } from './apply_deprecations'; diff --git a/src/core/server/config/deprecation/types.ts b/packages/kbn-config/src/deprecation/types.ts similarity index 100% rename from src/core/server/config/deprecation/types.ts rename to packages/kbn-config/src/deprecation/types.ts diff --git a/src/core/server/config/env.test.mocks.ts b/packages/kbn-config/src/env.test.mocks.ts similarity index 81% rename from src/core/server/config/env.test.mocks.ts rename to packages/kbn-config/src/env.test.mocks.ts index d35afdf0b66e5..3976b1c2016fb 100644 --- a/src/core/server/config/env.test.mocks.ts +++ b/packages/kbn-config/src/env.test.mocks.ts @@ -17,7 +17,10 @@ * under the License. */ -jest.mock('path', () => ({ +const realPath = jest.requireActual('path'); + +jest.doMock('path', () => ({ + ...realPath, resolve(...pathSegments: string[]) { return pathSegments.join('/'); }, @@ -26,5 +29,10 @@ jest.mock('path', () => ({ }, })); -export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] }); -jest.mock('../../../../package.json', () => mockPackage); +export const mockPackage = { + raw: {}, +}; + +jest.doMock('load-json-file', () => ({ + sync: () => mockPackage.raw, +})); diff --git a/src/core/server/config/env.test.ts b/packages/kbn-config/src/env.test.ts similarity index 89% rename from src/core/server/config/env.test.ts rename to packages/kbn-config/src/env.test.ts index 0fffcc44781d9..f3d51a021246e 100644 --- a/src/core/server/config/env.test.ts +++ b/packages/kbn-config/src/env.test.ts @@ -19,9 +19,24 @@ import { mockPackage } from './env.test.mocks'; -import { Env } from '.'; +import { Env, RawPackageInfo } from './env'; import { getEnvOptions } from './__mocks__/env'; +const REPO_ROOT = '/test/kibanaRoot'; + +const packageInfos: RawPackageInfo = { + branch: 'master', + version: '8.0.0', + build: { + number: 42, + sha: 'one', + }, +}; + +beforeEach(() => { + mockPackage.raw = {}; +}); + test('correctly creates default environment in dev mode.', () => { mockPackage.raw = { branch: 'some-branch', @@ -29,6 +44,7 @@ test('correctly creates default environment in dev mode.', () => { }; const defaultEnv = Env.createDefault( + REPO_ROOT, getEnvOptions({ configs: ['/test/cwd/config/kibana.yml'], isDevClusterMaster: true, @@ -50,6 +66,7 @@ test('correctly creates default environment in prod distributable mode.', () => }; const defaultEnv = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { dev: false }, configs: ['/some/other/path/some-kibana.yml'], @@ -71,6 +88,7 @@ test('correctly creates default environment in prod non-distributable mode.', () }; const defaultEnv = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { dev: false }, configs: ['/some/other/path/some-kibana.yml'], @@ -92,6 +110,7 @@ test('correctly creates default environment if `--env.name` is supplied.', () => }; const defaultDevEnv = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { envName: 'development' }, configs: ['/some/other/path/some-kibana.yml'], @@ -99,6 +118,7 @@ test('correctly creates default environment if `--env.name` is supplied.', () => ); const defaultProdEnv = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { dev: false, envName: 'production' }, configs: ['/some/other/path/some-kibana.yml'], @@ -110,18 +130,17 @@ test('correctly creates default environment if `--env.name` is supplied.', () => }); test('correctly creates environment with constructor.', () => { - mockPackage.raw = { - branch: 'feature-v1', - version: 'v1', - build: { - distributable: true, - number: 100, - sha: 'feature-v1-build-sha', - }, - }; - const env = new Env( '/some/home/dir', + { + branch: 'feature-v1', + version: 'v1', + build: { + distributable: true, + number: 100, + sha: 'feature-v1-build-sha', + }, + }, getEnvOptions({ cliArgs: { dev: false }, configs: ['/some/other/path/some-kibana.yml'], @@ -134,6 +153,7 @@ test('correctly creates environment with constructor.', () => { test('pluginSearchPaths contains x-pack plugins path if --oss flag is false', () => { const env = new Env( '/some/home/dir', + packageInfos, getEnvOptions({ cliArgs: { oss: false }, }) @@ -145,6 +165,7 @@ test('pluginSearchPaths contains x-pack plugins path if --oss flag is false', () test('pluginSearchPaths does not contains x-pack plugins path if --oss flag is true', () => { const env = new Env( '/some/home/dir', + packageInfos, getEnvOptions({ cliArgs: { oss: true }, }) @@ -156,6 +177,7 @@ test('pluginSearchPaths does not contains x-pack plugins path if --oss flag is t test('pluginSearchPaths contains examples plugins path if --run-examples flag is true', () => { const env = new Env( '/some/home/dir', + packageInfos, getEnvOptions({ cliArgs: { runExamples: true }, }) @@ -167,6 +189,7 @@ test('pluginSearchPaths contains examples plugins path if --run-examples flag is test('pluginSearchPaths contains x-pack/examples plugins path if --run-examples flag is true', () => { const env = new Env( '/some/home/dir', + packageInfos, getEnvOptions({ cliArgs: { runExamples: true }, }) @@ -178,6 +201,7 @@ test('pluginSearchPaths contains x-pack/examples plugins path if --run-examples test('pluginSearchPaths does not contains examples plugins path if --run-examples flag is false', () => { const env = new Env( '/some/home/dir', + packageInfos, getEnvOptions({ cliArgs: { runExamples: false }, }) @@ -189,6 +213,7 @@ test('pluginSearchPaths does not contains examples plugins path if --run-example test('pluginSearchPaths does not contains x-pack/examples plugins path if --run-examples flag is false', () => { const env = new Env( '/some/home/dir', + packageInfos, getEnvOptions({ cliArgs: { runExamples: false }, }) diff --git a/src/core/server/config/env.ts b/packages/kbn-config/src/env.ts similarity index 87% rename from src/core/server/config/env.ts rename to packages/kbn-config/src/env.ts index d8b056996315b..250c7b72d47a9 100644 --- a/src/core/server/config/env.ts +++ b/packages/kbn-config/src/env.ts @@ -17,13 +17,10 @@ * under the License. */ -import { resolve, dirname } from 'path'; +import { resolve, join } from 'path'; +import loadJsonFile from 'load-json-file'; import { PackageInfo, EnvironmentMode } from './types'; -// `require` is necessary for this to work inside x-pack code as well -// eslint-disable-next-line @typescript-eslint/no-var-requires -const pkg = require('../../../../package.json'); - /** @internal */ export interface EnvOptions { configs: string[]; @@ -50,13 +47,26 @@ export interface CliArgs { dist: boolean; } +/** @internal */ +export interface RawPackageInfo { + branch: string; + version: string; + build: { + distributable?: boolean; + number: number; + sha: string; + }; +} + export class Env { /** * @internal */ - public static createDefault(options: EnvOptions): Env { - const repoRoot = dirname(require.resolve('../../../../package.json')); - return new Env(repoRoot, options); + public static createDefault(repoRoot: string, options: EnvOptions, pkg?: RawPackageInfo): Env { + if (!pkg) { + pkg = loadJsonFile.sync(join(repoRoot, 'package.json')) as RawPackageInfo; + } + return new Env(repoRoot, pkg, options); } /** @internal */ @@ -99,7 +109,7 @@ export class Env { /** * @internal */ - constructor(public readonly homeDir: string, options: EnvOptions) { + constructor(public readonly homeDir: string, pkg: RawPackageInfo, options: EnvOptions) { this.configDir = resolve(this.homeDir, 'config'); this.binDir = resolve(this.homeDir, 'bin'); this.logDir = resolve(this.homeDir, 'log'); diff --git a/packages/kbn-config/src/index.ts b/packages/kbn-config/src/index.ts new file mode 100644 index 0000000000000..f02514a92e606 --- /dev/null +++ b/packages/kbn-config/src/index.ts @@ -0,0 +1,37 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + applyDeprecations, + ConfigDeprecation, + ConfigDeprecationFactory, + configDeprecationFactory, + ConfigDeprecationLogger, + ConfigDeprecationProvider, + ConfigDeprecationWithContext, +} from './deprecation'; + +export { RawConfigurationProvider, RawConfigService, getConfigFromFiles } from './raw'; + +export { ConfigService, IConfigService } from './config_service'; +export { Config, ConfigPath, isConfigPath, hasConfigPathIntersection } from './config'; +export { ObjectToConfigAdapter } from './object_to_config_adapter'; +export { CliArgs, Env, RawPackageInfo } from './env'; +export { EnvironmentMode, PackageInfo } from './types'; +export { LegacyObjectToConfigAdapter, LegacyLoggingConfig } from './legacy'; diff --git a/src/core/server/legacy/config/__snapshots__/legacy_object_to_config_adapter.test.ts.snap b/packages/kbn-config/src/legacy/__snapshots__/legacy_object_to_config_adapter.test.ts.snap similarity index 100% rename from src/core/server/legacy/config/__snapshots__/legacy_object_to_config_adapter.test.ts.snap rename to packages/kbn-config/src/legacy/__snapshots__/legacy_object_to_config_adapter.test.ts.snap diff --git a/packages/kbn-config/src/legacy/index.ts b/packages/kbn-config/src/legacy/index.ts new file mode 100644 index 0000000000000..cad6b754e956c --- /dev/null +++ b/packages/kbn-config/src/legacy/index.ts @@ -0,0 +1,23 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + LegacyObjectToConfigAdapter, + LegacyLoggingConfig, +} from './legacy_object_to_config_adapter'; diff --git a/src/core/server/legacy/config/legacy_object_to_config_adapter.test.ts b/packages/kbn-config/src/legacy/legacy_object_to_config_adapter.test.ts similarity index 100% rename from src/core/server/legacy/config/legacy_object_to_config_adapter.test.ts rename to packages/kbn-config/src/legacy/legacy_object_to_config_adapter.test.ts diff --git a/src/core/server/legacy/config/legacy_object_to_config_adapter.ts b/packages/kbn-config/src/legacy/legacy_object_to_config_adapter.ts similarity index 92% rename from src/core/server/legacy/config/legacy_object_to_config_adapter.ts rename to packages/kbn-config/src/legacy/legacy_object_to_config_adapter.ts index 3e496648c3af9..e8fca8735a6d9 100644 --- a/src/core/server/legacy/config/legacy_object_to_config_adapter.ts +++ b/packages/kbn-config/src/legacy/legacy_object_to_config_adapter.ts @@ -17,10 +17,17 @@ * under the License. */ -import { ConfigPath } from '../../config'; -import { ObjectToConfigAdapter } from '../../config/object_to_config_adapter'; -import { LoggingConfigType } from '../../logging/logging_config'; -import { LegacyVars } from '../types'; +import { ConfigPath } from '../config'; +import { ObjectToConfigAdapter } from '../object_to_config_adapter'; + +// TODO: fix once core schemas are moved to this package +type LoggingConfigType = any; + +/** + * @internal + * @deprecated + */ +export type LegacyVars = Record; /** * Represents logging config supported by the legacy platform. diff --git a/packages/kbn-config/src/mocks.ts b/packages/kbn-config/src/mocks.ts new file mode 100644 index 0000000000000..5ca5de3a328a2 --- /dev/null +++ b/packages/kbn-config/src/mocks.ts @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// these CANT be exported by the main entrypoint, as it cause ts check failures +// in `src/test` and `src/xpack/test` projects due to definition conflicts between +// mocha and jest declaring the same globals such as `it` or `beforeAll`, as the test +// files imports types from `core` that is importing the main `@kbn/config` entrypoint. +// For now, these should be imported using `import {} from '@kbn/config/target/mocks'` +export { configMock } from './config.mock'; +export { configServiceMock } from './config_service.mock'; +export { rawConfigServiceMock } from './raw/raw_config_service.mock'; +export { getEnvOptions } from './__mocks__/env'; diff --git a/src/core/server/config/object_to_config_adapter.test.ts b/packages/kbn-config/src/object_to_config_adapter.test.ts similarity index 100% rename from src/core/server/config/object_to_config_adapter.test.ts rename to packages/kbn-config/src/object_to_config_adapter.test.ts diff --git a/src/core/server/config/object_to_config_adapter.ts b/packages/kbn-config/src/object_to_config_adapter.ts similarity index 100% rename from src/core/server/config/object_to_config_adapter.ts rename to packages/kbn-config/src/object_to_config_adapter.ts diff --git a/src/core/server/config/__snapshots__/read_config.test.ts.snap b/packages/kbn-config/src/raw/__snapshots__/read_config.test.ts.snap similarity index 100% rename from src/core/server/config/__snapshots__/read_config.test.ts.snap rename to packages/kbn-config/src/raw/__snapshots__/read_config.test.ts.snap diff --git a/src/core/server/config/ensure_deep_object.test.ts b/packages/kbn-config/src/raw/ensure_deep_object.test.ts similarity index 100% rename from src/core/server/config/ensure_deep_object.test.ts rename to packages/kbn-config/src/raw/ensure_deep_object.test.ts diff --git a/src/core/server/config/ensure_deep_object.ts b/packages/kbn-config/src/raw/ensure_deep_object.ts similarity index 100% rename from src/core/server/config/ensure_deep_object.ts rename to packages/kbn-config/src/raw/ensure_deep_object.ts diff --git a/packages/kbn-config/src/raw/index.ts b/packages/kbn-config/src/raw/index.ts new file mode 100644 index 0000000000000..e32920fe64d67 --- /dev/null +++ b/packages/kbn-config/src/raw/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { RawConfigService, RawConfigurationProvider } from './raw_config_service'; +export { getConfigFromFiles } from './read_config'; diff --git a/src/core/server/config/raw_config_service.mock.ts b/packages/kbn-config/src/raw/raw_config_service.mock.ts similarity index 99% rename from src/core/server/config/raw_config_service.mock.ts rename to packages/kbn-config/src/raw/raw_config_service.mock.ts index 73a3b5cc9e4d0..53ea797dac9e5 100644 --- a/src/core/server/config/raw_config_service.mock.ts +++ b/packages/kbn-config/src/raw/raw_config_service.mock.ts @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ + import type { PublicMethodsOf } from '@kbn/utility-types'; import { RawConfigService } from './raw_config_service'; import { Observable, of } from 'rxjs'; diff --git a/src/core/server/config/raw_config_service.test.mocks.ts b/packages/kbn-config/src/raw/raw_config_service.test.mocks.ts similarity index 100% rename from src/core/server/config/raw_config_service.test.mocks.ts rename to packages/kbn-config/src/raw/raw_config_service.test.mocks.ts diff --git a/src/core/server/config/raw_config_service.test.ts b/packages/kbn-config/src/raw/raw_config_service.test.ts similarity index 98% rename from src/core/server/config/raw_config_service.test.ts rename to packages/kbn-config/src/raw/raw_config_service.test.ts index 8846ea3847f79..444d67985250b 100644 --- a/src/core/server/config/raw_config_service.test.ts +++ b/packages/kbn-config/src/raw/raw_config_service.test.ts @@ -20,7 +20,7 @@ import { mockGetConfigFromFiles } from './raw_config_service.test.mocks'; import { first } from 'rxjs/operators'; -import { RawConfigService } from '.'; +import { RawConfigService } from './raw_config_service'; const configFile = '/config/kibana.yml'; const anotherConfigFile = '/config/kibana.dev.yml'; diff --git a/src/core/server/config/raw_config_service.ts b/packages/kbn-config/src/raw/raw_config_service.ts similarity index 100% rename from src/core/server/config/raw_config_service.ts rename to packages/kbn-config/src/raw/raw_config_service.ts diff --git a/src/core/server/config/read_config.test.ts b/packages/kbn-config/src/raw/read_config.test.ts similarity index 96% rename from src/core/server/config/read_config.test.ts rename to packages/kbn-config/src/raw/read_config.test.ts index 46b75f28eb987..89b73c5d4e26a 100644 --- a/src/core/server/config/read_config.test.ts +++ b/packages/kbn-config/src/raw/read_config.test.ts @@ -20,7 +20,7 @@ import { relative, resolve } from 'path'; import { getConfigFromFiles } from './read_config'; -const fixtureFile = (name: string) => `${__dirname}/__fixtures__/${name}`; +const fixtureFile = (name: string) => resolve(`${__dirname}/../../__fixtures__/${name}`); test('reads single yaml from file system and parses to json', () => { const config = getConfigFromFiles([fixtureFile('config.yml')]); diff --git a/src/core/server/config/read_config.ts b/packages/kbn-config/src/raw/read_config.ts similarity index 100% rename from src/core/server/config/read_config.ts rename to packages/kbn-config/src/raw/read_config.ts diff --git a/src/core/server/config/types.ts b/packages/kbn-config/src/types.ts similarity index 100% rename from src/core/server/config/types.ts rename to packages/kbn-config/src/types.ts diff --git a/packages/kbn-config/tsconfig.json b/packages/kbn-config/tsconfig.json new file mode 100644 index 0000000000000..ba00ddfa6adb6 --- /dev/null +++ b/packages/kbn-config/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "declaration": true, + "outDir": "./target", + "stripInternal": false, + "declarationMap": true, + "types": ["jest", "node"] + }, + "include": ["./src/**/*.ts"], + "exclude": ["target"] +} diff --git a/packages/kbn-config/yarn.lock b/packages/kbn-config/yarn.lock new file mode 120000 index 0000000000000..3f82ebc9cdbae --- /dev/null +++ b/packages/kbn-config/yarn.lock @@ -0,0 +1 @@ +../../yarn.lock \ No newline at end of file diff --git a/packages/kbn-logging/README.md b/packages/kbn-logging/README.md new file mode 100644 index 0000000000000..8bde73722deb0 --- /dev/null +++ b/packages/kbn-logging/README.md @@ -0,0 +1,61 @@ +# kbn-logging + +Base types for the kibana platform logging system. + +Note that this package currently only contains logging types. The only concrete implementation +is still in `core` for now. + +- [Loggers, Appenders and Layouts](#loggers-appenders-and-layouts) +- [Logger hierarchy](#logger-hierarchy) +- [Log level](#log-level) +- [Layouts](#layouts) + +The way logging works in Kibana is inspired by `log4j 2` logging framework used by [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#logging). +The main idea is to have consistent logging behaviour (configuration, log format etc.) across the entire Elastic Stack +where possible. + +## Loggers, Appenders and Layouts + +Kibana logging system has three main components: _loggers_, _appenders_ and _layouts_. These components allow us to log +messages according to message type and level, and to control how these messages are formatted and where the final logs +will be displayed or stored. + +__Loggers__ define what logging settings should be applied at the particular context. + +__Appenders__ define where log messages are displayed (eg. stdout or console) and stored (eg. file on the disk). + +__Layouts__ define how log messages are formatted and what type of information they include. + + +## Logger hierarchy + +Every logger has its unique name or context that follows hierarchical naming rule. The logger is considered to be an +ancestor of another logger if its name followed by a `.` is a prefix of the descendant logger name. For example logger +with `a.b` context is an ancestor of logger with `a.b.c` context. All top-level loggers are descendants of special +logger with `root` context that resides at the top of the logger hierarchy. This logger always exists and +fully configured. + +Developer can configure _log level_ and _appenders_ that should be used within particular context. If logger configuration +specifies only _log level_ then _appenders_ configuration will be inherited from the ancestor logger. + +__Note:__ in the current implementation log messages are only forwarded to appenders configured for a particular logger +context or to appenders of the closest ancestor if current logger doesn't have any appenders configured. That means that +we __don't support__ so called _appender additivity_ when log messages are forwarded to _every_ distinct appender within +ancestor chain including `root`. + +## Log level + +Currently we support the following log levels: _all_, _fatal_, _error_, _warn_, _info_, _debug_, _trace_, _off_. +Levels are ordered, so _all_ > _fatal_ > _error_ > _warn_ > _info_ > _debug_ > _trace_ > _off_. +A log record is being logged by the logger if its level is higher than or equal to the level of its logger. Otherwise, +the log record is ignored. + +The _all_ and _off_ levels can be used only in configuration and are just handy shortcuts that allow developer to log every +log record or disable logging entirely for the specific context. + +## Layouts + +Every appender should know exactly how to format log messages before they are written to the console or file on the disk. +This behaviour is controlled by the layouts and configured through `appender.layout` configuration property for every +custom appender. Currently we don't define any default layout for the custom appenders, so one should always make the choice +explicitly. diff --git a/packages/kbn-logging/package.json b/packages/kbn-logging/package.json new file mode 100644 index 0000000000000..922d562733622 --- /dev/null +++ b/packages/kbn-logging/package.json @@ -0,0 +1,18 @@ +{ + "name": "@kbn/logging", + "version": "1.0.0", + "private": true, + "license": "Apache-2.0", + "main": "./target/index.js", + "scripts": { + "build": "tsc", + "kbn:bootstrap": "yarn build", + "kbn:watch": "yarn build --watch" + }, + "dependencies": { + "@kbn/std": "1.0.0" + }, + "devDependencies": { + "typescript": "4.0.2" + } +} diff --git a/packages/kbn-logging/src/appenders.ts b/packages/kbn-logging/src/appenders.ts new file mode 100644 index 0000000000000..346d3d6dd1068 --- /dev/null +++ b/packages/kbn-logging/src/appenders.ts @@ -0,0 +1,39 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { LogRecord } from './log_record'; + +/** + * Entity that can append `LogRecord` instances to file, stdout, memory or whatever + * is implemented internally. It's supposed to be used by `Logger`. + * @internal + */ +export interface Appender { + append(record: LogRecord): void; +} + +/** + * This interface should be additionally implemented by the `Appender`'s if they are supposed + * to be properly disposed. It's intentionally separated from `Appender` interface so that `Logger` + * that interacts with `Appender` doesn't have control over appender lifetime. + * @internal + */ +export interface DisposableAppender extends Appender { + dispose: () => void; +} diff --git a/packages/kbn-logging/src/index.ts b/packages/kbn-logging/src/index.ts new file mode 100644 index 0000000000000..d06218ac2eeb5 --- /dev/null +++ b/packages/kbn-logging/src/index.ts @@ -0,0 +1,25 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { LogLevel, LogLevelId } from './log_level'; +export { LogRecord } from './log_record'; +export { Logger, LogMeta } from './logger'; +export { LoggerFactory } from './logger_factory'; +export { Layout } from './layout'; +export { Appender, DisposableAppender } from './appenders'; diff --git a/packages/kbn-logging/src/layout.ts b/packages/kbn-logging/src/layout.ts new file mode 100644 index 0000000000000..75556eab88bb6 --- /dev/null +++ b/packages/kbn-logging/src/layout.ts @@ -0,0 +1,28 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { LogRecord } from './log_record'; + +/** + * Entity that can format `LogRecord` instance into a string. + * @internal + */ +export interface Layout { + format(record: LogRecord): string; +} diff --git a/src/core/server/logging/log_level.test.ts b/packages/kbn-logging/src/log_level.test.ts similarity index 100% rename from src/core/server/logging/log_level.test.ts rename to packages/kbn-logging/src/log_level.test.ts diff --git a/src/core/server/logging/log_level.ts b/packages/kbn-logging/src/log_level.ts similarity index 100% rename from src/core/server/logging/log_level.ts rename to packages/kbn-logging/src/log_level.ts diff --git a/src/core/server/logging/log_record.ts b/packages/kbn-logging/src/log_record.ts similarity index 100% rename from src/core/server/logging/log_record.ts rename to packages/kbn-logging/src/log_record.ts diff --git a/packages/kbn-logging/src/logger.ts b/packages/kbn-logging/src/logger.ts new file mode 100644 index 0000000000000..50e002a87fc52 --- /dev/null +++ b/packages/kbn-logging/src/logger.ts @@ -0,0 +1,96 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { LogRecord } from './log_record'; + +/** + * Contextual metadata + * + * @public + */ +export interface LogMeta { + [key: string]: any; +} + +/** + * Logger exposes all the necessary methods to log any type of information and + * this is the interface used by the logging consumers including plugins. + * + * @public + */ +export interface Logger { + /** + * Log messages at the most detailed log level + * + * @param message - The log message + * @param meta - + */ + trace(message: string, meta?: LogMeta): void; + + /** + * Log messages useful for debugging and interactive investigation + * @param message - The log message + * @param meta - + */ + debug(message: string, meta?: LogMeta): void; + + /** + * Logs messages related to general application flow + * @param message - The log message + * @param meta - + */ + info(message: string, meta?: LogMeta): void; + + /** + * Logs abnormal or unexpected errors or messages + * @param errorOrMessage - An Error object or message string to log + * @param meta - + */ + warn(errorOrMessage: string | Error, meta?: LogMeta): void; + + /** + * Logs abnormal or unexpected errors or messages that caused a failure in the application flow + * + * @param errorOrMessage - An Error object or message string to log + * @param meta - + */ + error(errorOrMessage: string | Error, meta?: LogMeta): void; + + /** + * Logs abnormal or unexpected errors or messages that caused an unrecoverable failure + * + * @param errorOrMessage - An Error object or message string to log + * @param meta - + */ + fatal(errorOrMessage: string | Error, meta?: LogMeta): void; + + /** @internal */ + log(record: LogRecord): void; + + /** + * Returns a new {@link Logger} instance extending the current logger context. + * + * @example + * ```typescript + * const logger = loggerFactory.get('plugin', 'service'); // 'plugin.service' context + * const subLogger = logger.get('feature'); // 'plugin.service.feature' context + * ``` + */ + get(...childContextPaths: string[]): Logger; +} diff --git a/src/core/server/logging/logger_factory.ts b/packages/kbn-logging/src/logger_factory.ts similarity index 100% rename from src/core/server/logging/logger_factory.ts rename to packages/kbn-logging/src/logger_factory.ts diff --git a/packages/kbn-logging/src/mocks/index.ts b/packages/kbn-logging/src/mocks/index.ts new file mode 100644 index 0000000000000..c7be3a1b8ce8c --- /dev/null +++ b/packages/kbn-logging/src/mocks/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { MockedLogger, loggerMock } from './logger.mock'; diff --git a/packages/kbn-logging/src/mocks/logger.mock.ts b/packages/kbn-logging/src/mocks/logger.mock.ts new file mode 100644 index 0000000000000..1a4c7a2dadf68 --- /dev/null +++ b/packages/kbn-logging/src/mocks/logger.mock.ts @@ -0,0 +1,70 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Logger } from '../logger'; + +export type MockedLogger = jest.Mocked & { context: string[] }; + +const createLoggerMock = (context: string[] = []) => { + const mockLog: MockedLogger = { + context, + debug: jest.fn(), + error: jest.fn(), + fatal: jest.fn(), + info: jest.fn(), + log: jest.fn(), + trace: jest.fn(), + warn: jest.fn(), + get: jest.fn(), + }; + mockLog.get.mockImplementation((...ctx) => ({ + ctx, + ...mockLog, + })); + + return mockLog; +}; + +const clearLoggerMock = (logger: MockedLogger) => { + logger.debug.mockClear(); + logger.info.mockClear(); + logger.warn.mockClear(); + logger.error.mockClear(); + logger.trace.mockClear(); + logger.fatal.mockClear(); + logger.log.mockClear(); +}; + +const collectLoggerMock = (logger: MockedLogger) => { + return { + debug: logger.debug.mock.calls, + error: logger.error.mock.calls, + fatal: logger.fatal.mock.calls, + info: logger.info.mock.calls, + log: logger.log.mock.calls, + trace: logger.trace.mock.calls, + warn: logger.warn.mock.calls, + }; +}; + +export const loggerMock = { + create: createLoggerMock, + clear: clearLoggerMock, + collect: collectLoggerMock, +}; diff --git a/packages/kbn-logging/tsconfig.json b/packages/kbn-logging/tsconfig.json new file mode 100644 index 0000000000000..c55c05de30a52 --- /dev/null +++ b/packages/kbn-logging/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target", + "stripInternal": false, + "declaration": true, + "declarationMap": true, + "types": ["jest", "node"] + }, + "include": ["./src/**/*.ts"] +} diff --git a/packages/kbn-logging/yarn.lock b/packages/kbn-logging/yarn.lock new file mode 120000 index 0000000000000..3f82ebc9cdbae --- /dev/null +++ b/packages/kbn-logging/yarn.lock @@ -0,0 +1 @@ +../../yarn.lock \ No newline at end of file diff --git a/packages/kbn-std/package.json b/packages/kbn-std/package.json index 4c67706b45d27..2cc9fd72082be 100644 --- a/packages/kbn-std/package.json +++ b/packages/kbn-std/package.json @@ -15,7 +15,6 @@ }, "dependencies": { "@kbn/utility-types": "1.0.0", - "lodash": "^4.17.15", - "query-string": "5.1.1" + "lodash": "^4.17.15" } } diff --git a/packages/kbn-std/src/index.ts b/packages/kbn-std/src/index.ts index 7cf70a0e28e2c..8cffcd43d7537 100644 --- a/packages/kbn-std/src/index.ts +++ b/packages/kbn-std/src/index.ts @@ -24,6 +24,6 @@ export { mapToObject } from './map_to_object'; export { merge } from './merge'; export { pick } from './pick'; export { withTimeout } from './promise'; -export { isRelativeUrl, modifyUrl, URLMeaningfulParts } from './url'; +export { isRelativeUrl, modifyUrl, URLMeaningfulParts, ParsedQuery } from './url'; export { unset } from './unset'; export { getFlattenedObject } from './get_flattened_object'; diff --git a/packages/kbn-std/src/url.ts b/packages/kbn-std/src/url.ts index 910fc8eaa4381..7a0f08130816d 100644 --- a/packages/kbn-std/src/url.ts +++ b/packages/kbn-std/src/url.ts @@ -16,9 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -import { ParsedQuery } from 'query-string'; + import { format as formatUrl, parse as parseUrl, UrlObject } from 'url'; +// duplicate type from 'query-string' to avoid adding the d.ts file to all packages depending on kbn-std +export interface ParsedQuery { + [key: string]: T | T[] | null | undefined; +} + /** * We define our own typings because the current version of @types/node * declares properties to be optional "hostname?: string". diff --git a/packages/kbn-std/tsconfig.json b/packages/kbn-std/tsconfig.json index 5c86ad17a90e9..fd186a6e43d1c 100644 --- a/packages/kbn-std/tsconfig.json +++ b/packages/kbn-std/tsconfig.json @@ -8,9 +8,6 @@ "declarationMap": true, "types": ["jest", "node"] }, - "include": [ - "./src/**/*.ts", - "../../typings/query_string.d.ts" - ], + "include": ["./src/**/*.ts"], "exclude": ["target"] } diff --git a/src/cli/serve/integration_tests/reload_logging_config.test.ts b/src/cli/serve/integration_tests/reload_logging_config.test.ts index 35391b9b58ecc..55f71ea2401db 100644 --- a/src/cli/serve/integration_tests/reload_logging_config.test.ts +++ b/src/cli/serve/integration_tests/reload_logging_config.test.ts @@ -26,8 +26,7 @@ import Del from 'del'; import * as Rx from 'rxjs'; import { map, filter, take } from 'rxjs/operators'; import { safeDump } from 'js-yaml'; - -import { getConfigFromFiles } from '../../../core/server/config/read_config'; +import { getConfigFromFiles } from '@kbn/config'; const legacyConfig = follow('__fixtures__/reload_logging_config/kibana.test.yml'); const configFileLogConsole = follow( diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index d0b9e115bd524..d22c7ae805827 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -7,6 +7,8 @@ import { Action } from 'history'; import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; import Boom from 'boom'; +import { ConfigPath } from '@kbn/config'; +import { EnvironmentMode } from '@kbn/config'; import { EuiBreadcrumb } from '@elastic/eui'; import { EuiButtonEmptyProps } from '@elastic/eui'; import { EuiConfirmModalProps } from '@elastic/eui'; @@ -19,8 +21,11 @@ import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import { KibanaConfigType } from 'src/core/server/kibana_config'; import { Location } from 'history'; import { LocationDescriptorObject } from 'history'; +import { Logger } from '@kbn/logging'; +import { LogMeta } from '@kbn/logging'; import { MaybePromise } from '@kbn/utility-types'; import { Observable } from 'rxjs'; +import { PackageInfo } from '@kbn/config'; import { Path } from 'history'; import { PublicMethodsOf } from '@kbn/utility-types'; import { PublicUiSettingsParams as PublicUiSettingsParams_2 } from 'src/core/server/types'; @@ -576,15 +581,7 @@ export interface DocLinksStart { }; } -// @public (undocumented) -export interface EnvironmentMode { - // (undocumented) - dev: boolean; - // (undocumented) - name: 'development' | 'production'; - // (undocumented) - prod: boolean; -} +export { EnvironmentMode } // @public export interface ErrorToastOptions extends ToastOptions { @@ -912,19 +909,7 @@ export interface OverlayStart { openModal: OverlayModalStart['open']; } -// @public (undocumented) -export interface PackageInfo { - // (undocumented) - branch: string; - // (undocumented) - buildNum: number; - // (undocumented) - buildSha: string; - // (undocumented) - dist: boolean; - // (undocumented) - version: string; -} +export { PackageInfo } // @public export interface Plugin { diff --git a/src/core/server/bootstrap.ts b/src/core/server/bootstrap.ts index c0cbe3a39ff54..ff1a5c0340c46 100644 --- a/src/core/server/bootstrap.ts +++ b/src/core/server/bootstrap.ts @@ -60,7 +60,15 @@ export async function bootstrap({ return; } - const env = Env.createDefault({ + // `bootstrap` is exported from the `src/core/server/index` module, + // meaning that any test importing, implicitly or explicitly, anything concrete + // from `core/server` will load `dev-utils`. As some tests are mocking the `fs` package, + // and as `REPO_ROOT` is initialized on the fly when importing `dev-utils` and requires + // the `fs` package, it causes failures. This is why we use a dynamic `require` here. + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { REPO_ROOT } = require('@kbn/utils'); + + const env = Env.createDefault(REPO_ROOT, { configs, cliArgs, isDevClusterMaster: isMaster && cliArgs.dev && features.isClusterModeSupported, diff --git a/src/core/server/capabilities/integration_tests/capabilities_service.test.ts b/src/core/server/capabilities/integration_tests/capabilities_service.test.ts index b4d620965b047..17f2c77bbf660 100644 --- a/src/core/server/capabilities/integration_tests/capabilities_service.test.ts +++ b/src/core/server/capabilities/integration_tests/capabilities_service.test.ts @@ -18,16 +18,18 @@ */ import supertest from 'supertest'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { HttpService, InternalHttpServiceSetup } from '../../http'; import { contextServiceMock } from '../../context/context_service.mock'; import { loggingSystemMock } from '../../logging/logging_system.mock'; import { Env } from '../../config'; -import { getEnvOptions } from '../../config/__mocks__/env'; +import { getEnvOptions } from '../../config/mocks'; import { CapabilitiesService, CapabilitiesSetup } from '..'; import { createHttpServer } from '../../http/test_utils'; const coreId = Symbol('core'); -const env = Env.createDefault(getEnvOptions()); + +const env = Env.createDefault(REPO_ROOT, getEnvOptions()); describe('CapabilitiesService', () => { let server: HttpService; diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index adf0f52339366..7a69dc2fa726e 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -17,9 +17,8 @@ * under the License. */ +import { configDeprecationFactory, applyDeprecations } from '@kbn/config'; import { coreDeprecationProvider } from './core_deprecations'; -import { configDeprecationFactory } from './deprecation_factory'; -import { applyDeprecations } from './apply_deprecations'; const initialEnv = { ...process.env }; diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index b87596af45282..bcbd127203bc4 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -18,7 +18,7 @@ */ import { has, get } from 'lodash'; -import { ConfigDeprecationProvider, ConfigDeprecation } from './types'; +import { ConfigDeprecationProvider, ConfigDeprecation } from '@kbn/config'; const configPathDeprecation: ConfigDeprecation = (settings, fromPath, log) => { if (has(process.env, 'CONFIG_PATH')) { diff --git a/src/core/server/config/deprecation/index.ts b/src/core/server/config/deprecation/index.ts index f79338665166b..9e8e2e5a2bddf 100644 --- a/src/core/server/config/deprecation/index.ts +++ b/src/core/server/config/deprecation/index.ts @@ -17,13 +17,4 @@ * under the License. */ -export { - ConfigDeprecation, - ConfigDeprecationWithContext, - ConfigDeprecationLogger, - ConfigDeprecationFactory, - ConfigDeprecationProvider, -} from './types'; -export { configDeprecationFactory } from './deprecation_factory'; export { coreDeprecationProvider } from './core_deprecations'; -export { applyDeprecations } from './apply_deprecations'; diff --git a/src/core/server/config/index.ts b/src/core/server/config/index.ts index 04dc402d35b22..f69a5d081cc8a 100644 --- a/src/core/server/config/index.ts +++ b/src/core/server/config/index.ts @@ -17,17 +17,25 @@ * under the License. */ -export { ConfigService, IConfigService } from './config_service'; -export { RawConfigService, RawConfigurationProvider } from './raw_config_service'; -export { Config, ConfigPath, isConfigPath, hasConfigPathIntersection } from './config'; -export { ObjectToConfigAdapter } from './object_to_config_adapter'; -export { CliArgs, Env } from './env'; +export { coreDeprecationProvider } from './deprecation'; + export { + ConfigService, + IConfigService, + RawConfigService, + RawConfigurationProvider, + Config, + ConfigPath, + isConfigPath, + hasConfigPathIntersection, + ObjectToConfigAdapter, + CliArgs, + Env, ConfigDeprecation, ConfigDeprecationLogger, ConfigDeprecationProvider, ConfigDeprecationFactory, - coreDeprecationProvider, -} from './deprecation'; - -export { EnvironmentMode, PackageInfo } from './types'; + EnvironmentMode, + PackageInfo, + LegacyObjectToConfigAdapter, +} from '@kbn/config'; diff --git a/src/core/server/config/mocks.ts b/src/core/server/config/mocks.ts new file mode 100644 index 0000000000000..960dda496e635 --- /dev/null +++ b/src/core/server/config/mocks.ts @@ -0,0 +1,25 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + getEnvOptions, + rawConfigServiceMock, + configServiceMock, + configMock, +} from '@kbn/config/target/mocks'; diff --git a/src/core/server/core_context.mock.ts b/src/core/server/core_context.mock.ts index 2b887358818e3..bbf04783278f7 100644 --- a/src/core/server/core_context.mock.ts +++ b/src/core/server/core_context.mock.ts @@ -16,15 +16,16 @@ * specific language governing permissions and limitations * under the License. */ + +import { REPO_ROOT } from '@kbn/dev-utils'; import { CoreContext } from './core_context'; -import { getEnvOptions } from './config/__mocks__/env'; import { Env, IConfigService } from './config'; +import { configServiceMock, getEnvOptions } from './config/mocks'; import { loggingSystemMock } from './logging/logging_system.mock'; -import { configServiceMock } from './config/config_service.mock'; import { ILoggingSystem } from './logging'; function create({ - env = Env.createDefault(getEnvOptions()), + env = Env.createDefault(REPO_ROOT, getEnvOptions()), logger = loggingSystemMock.create(), configService = configServiceMock.create(), }: { diff --git a/src/core/server/elasticsearch/elasticsearch_config.test.ts b/src/core/server/elasticsearch/elasticsearch_config.test.ts index 06b862d2454d8..72744008fbbca 100644 --- a/src/core/server/elasticsearch/elasticsearch_config.test.ts +++ b/src/core/server/elasticsearch/elasticsearch_config.test.ts @@ -23,8 +23,8 @@ import { mockReadPkcs12Truststore, } from './elasticsearch_config.test.mocks'; +import { applyDeprecations, configDeprecationFactory } from '@kbn/config'; import { ElasticsearchConfig, config } from './elasticsearch_config'; -import { applyDeprecations, configDeprecationFactory } from '../config/deprecation'; const CONFIG_PATH = 'elasticsearch'; diff --git a/src/core/server/elasticsearch/elasticsearch_service.test.ts b/src/core/server/elasticsearch/elasticsearch_service.test.ts index 49f5c8dd98790..ce82410f6061e 100644 --- a/src/core/server/elasticsearch/elasticsearch_service.test.ts +++ b/src/core/server/elasticsearch/elasticsearch_service.test.ts @@ -20,10 +20,10 @@ import { MockLegacyClusterClient, MockClusterClient } from './elasticsearch_service.test.mocks'; import { BehaviorSubject } from 'rxjs'; import { first } from 'rxjs/operators'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; +import { configServiceMock, getEnvOptions } from '../config/mocks'; import { CoreContext } from '../core_context'; -import { configServiceMock } from '../config/config_service.mock'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { httpServiceMock } from '../http/http_service.mock'; import { auditTrailServiceMock } from '../audit_trail/audit_trail_service.mock'; @@ -64,7 +64,7 @@ let mockClusterClientInstance: ReturnType; beforeEach(() => { - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); coreContext = { coreId: Symbol(), env, logger, configService: configService as any }; elasticsearchService = new ElasticsearchService(coreContext); diff --git a/src/core/server/environment/environment_service.test.ts b/src/core/server/environment/environment_service.test.ts index f6cffb5e26a9e..e4dcfc49c1130 100644 --- a/src/core/server/environment/environment_service.test.ts +++ b/src/core/server/environment/environment_service.test.ts @@ -18,13 +18,14 @@ */ import { BehaviorSubject } from 'rxjs'; + import { EnvironmentService } from './environment_service'; import { resolveInstanceUuid } from './resolve_uuid'; import { createDataFolder } from './create_data_folder'; import { writePidFile } from './write_pid_file'; import { CoreContext } from '../core_context'; -import { configServiceMock } from '../config/config_service.mock'; +import { configServiceMock } from '../config/mocks'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { mockCoreContext } from '../core_context.mock'; diff --git a/src/core/server/http/cookie_session_storage.test.ts b/src/core/server/http/cookie_session_storage.test.ts index 8e5dec7d4eadd..b7ade0cbde0fc 100644 --- a/src/core/server/http/cookie_session_storage.test.ts +++ b/src/core/server/http/cookie_session_storage.test.ts @@ -18,20 +18,20 @@ */ import request from 'request'; import supertest from 'supertest'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { ByteSizeValue } from '@kbn/config-schema'; import { BehaviorSubject } from 'rxjs'; import { CoreContext } from '../core_context'; import { HttpService } from './http_service'; import { KibanaRequest } from './router'; - import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; -import { configServiceMock } from '../config/config_service.mock'; + import { contextServiceMock } from '../context/context_service.mock'; import { loggingSystemMock } from '../logging/logging_system.mock'; - +import { getEnvOptions, configServiceMock } from '../config/mocks'; import { httpServerMock } from './http_server.mocks'; + import { createCookieSessionStorageFactory } from './cookie_session_storage'; let server: HttpService; @@ -72,7 +72,7 @@ configService.atPath.mockReturnValue( beforeEach(() => { logger = loggingSystemMock.create(); - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); coreContext = { coreId: Symbol(), env, logger, configService: configService as any }; server = new HttpService(coreContext); diff --git a/src/core/server/http/http_service.mock.ts b/src/core/server/http/http_service.mock.ts index 3e38f6a6d384d..f81708145edc4 100644 --- a/src/core/server/http/http_service.mock.ts +++ b/src/core/server/http/http_service.mock.ts @@ -22,7 +22,6 @@ import type { PublicMethodsOf } from '@kbn/utility-types'; import { CspConfig } from '../csp'; import { mockRouter, RouterMock } from './router/router.mock'; -import { configMock } from '../config/config.mock'; import { InternalHttpServiceSetup, HttpServiceSetup, @@ -37,6 +36,7 @@ import { sessionStorageMock } from './cookie_session_storage.mocks'; import { OnPostAuthToolkit } from './lifecycle/on_post_auth'; import { OnPreAuthToolkit } from './lifecycle/on_pre_auth'; import { OnPreResponseToolkit } from './lifecycle/on_pre_response'; +import { configMock } from '../config/mocks'; type BasePathMocked = jest.Mocked; type AuthMocked = jest.Mocked; diff --git a/src/core/server/http/http_service.test.ts b/src/core/server/http/http_service.test.ts index 3d759b427d9fb..11cea88fa0dd2 100644 --- a/src/core/server/http/http_service.test.ts +++ b/src/core/server/http/http_service.test.ts @@ -21,17 +21,18 @@ import { mockHttpServer } from './http_service.test.mocks'; import { noop } from 'lodash'; import { BehaviorSubject } from 'rxjs'; +import { REPO_ROOT } from '@kbn/dev-utils'; +import { getEnvOptions } from '../config/mocks'; import { HttpService } from '.'; import { HttpConfigType, config } from './http_config'; import { httpServerMock } from './http_server.mocks'; import { ConfigService, Env } from '../config'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { contextServiceMock } from '../context/context_service.mock'; -import { getEnvOptions } from '../config/__mocks__/env'; import { config as cspConfig } from '../csp'; const logger = loggingSystemMock.create(); -const env = Env.createDefault(getEnvOptions()); +const env = Env.createDefault(REPO_ROOT, getEnvOptions()); const coreId = Symbol(); const createConfigService = (value: Partial = {}) => { @@ -115,7 +116,7 @@ test('spins up notReady server until started if configured with `autoListen:true const service = new HttpService({ coreId, configService, - env: new Env('.', getEnvOptions()), + env: Env.createDefault(REPO_ROOT, getEnvOptions()), logger, }); @@ -263,7 +264,7 @@ test('does not start http server if process is dev cluster master', async () => const service = new HttpService({ coreId, configService, - env: new Env('.', getEnvOptions({ isDevClusterMaster: true })), + env: Env.createDefault(REPO_ROOT, getEnvOptions({ isDevClusterMaster: true })), logger, }); @@ -288,7 +289,7 @@ test('does not start http server if configured with `autoListen:false`', async ( const service = new HttpService({ coreId, configService, - env: new Env('.', getEnvOptions()), + env: Env.createDefault(REPO_ROOT, getEnvOptions()), logger, }); diff --git a/src/core/server/http/integration_tests/lifecycle_handlers.test.ts b/src/core/server/http/integration_tests/lifecycle_handlers.test.ts index 8d70b5c3ad119..a964130550bf5 100644 --- a/src/core/server/http/integration_tests/lifecycle_handlers.test.ts +++ b/src/core/server/http/integration_tests/lifecycle_handlers.test.ts @@ -26,7 +26,7 @@ import { HttpService } from '../http_service'; import { HttpServerSetup } from '../http_server'; import { IRouter, RouteRegistrar } from '../router'; -import { configServiceMock } from '../../config/config_service.mock'; +import { configServiceMock } from '../../config/mocks'; import { contextServiceMock } from '../../context/context_service.mock'; // eslint-disable-next-line @typescript-eslint/no-var-requires diff --git a/src/core/server/http/test_utils.ts b/src/core/server/http/test_utils.ts index c3afae108027e..b4d91926f13f4 100644 --- a/src/core/server/http/test_utils.ts +++ b/src/core/server/http/test_utils.ts @@ -18,16 +18,16 @@ */ import { BehaviorSubject } from 'rxjs'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { ByteSizeValue } from '@kbn/config-schema'; import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; import { HttpService } from './http_service'; import { CoreContext } from '../core_context'; -import { configServiceMock } from '../config/config_service.mock'; +import { getEnvOptions, configServiceMock } from '../config/mocks'; import { loggingSystemMock } from '../logging/logging_system.mock'; const coreId = Symbol('core'); -const env = Env.createDefault(getEnvOptions()); +const env = Env.createDefault(REPO_ROOT, getEnvOptions()); const logger = loggingSystemMock.create(); diff --git a/src/core/server/legacy/config/ensure_valid_configuration.test.ts b/src/core/server/legacy/config/ensure_valid_configuration.test.ts index d8917b46eba62..702840b8a0a6a 100644 --- a/src/core/server/legacy/config/ensure_valid_configuration.test.ts +++ b/src/core/server/legacy/config/ensure_valid_configuration.test.ts @@ -19,7 +19,7 @@ import { ensureValidConfiguration } from './ensure_valid_configuration'; import { getUnusedConfigKeys } from './get_unused_config_keys'; -import { configServiceMock } from '../../config/config_service.mock'; +import { configServiceMock } from '../../config/mocks'; jest.mock('./get_unused_config_keys'); diff --git a/src/core/server/legacy/config/index.ts b/src/core/server/legacy/config/index.ts index b56b83ca324cb..c8781945d7cbc 100644 --- a/src/core/server/legacy/config/index.ts +++ b/src/core/server/legacy/config/index.ts @@ -18,4 +18,3 @@ */ export { ensureValidConfiguration } from './ensure_valid_configuration'; -export { LegacyObjectToConfigAdapter } from './legacy_object_to_config_adapter'; diff --git a/src/core/server/legacy/index.ts b/src/core/server/legacy/index.ts index 208e9b1167253..6b0963e3129c6 100644 --- a/src/core/server/legacy/index.ts +++ b/src/core/server/legacy/index.ts @@ -18,7 +18,7 @@ */ /** @internal */ -export { LegacyObjectToConfigAdapter, ensureValidConfiguration } from './config'; +export { ensureValidConfiguration } from './config'; /** @internal */ export { LegacyInternals } from './legacy_internals'; /** @internal */ diff --git a/src/core/server/legacy/integration_tests/logging.test.ts b/src/core/server/legacy/integration_tests/logging.test.ts index 2ebe17ea92978..dfcecd3f36b36 100644 --- a/src/core/server/legacy/integration_tests/logging.test.ts +++ b/src/core/server/legacy/integration_tests/logging.test.ts @@ -16,6 +16,8 @@ * specific language governing permissions and limitations * under the License. */ + +import { LegacyLoggingConfig } from '@kbn/config'; import * as kbnTestServer from '../../../test_helpers/kbn_server'; import { @@ -23,8 +25,6 @@ import { getLegacyPlatformLogsFromMock, } from '../../logging/integration_tests/utils'; -import { LegacyLoggingConfig } from '../config/legacy_object_to_config_adapter'; - function createRoot(legacyLoggingConfig: LegacyLoggingConfig = {}) { return kbnTestServer.createRoot({ migrations: { skip: true }, // otherwise stuck in polling ES diff --git a/src/core/server/legacy/legacy_internals.test.ts b/src/core/server/legacy/legacy_internals.test.ts index 67f2f433d4570..935e36a989a0c 100644 --- a/src/core/server/legacy/legacy_internals.test.ts +++ b/src/core/server/legacy/legacy_internals.test.ts @@ -19,7 +19,7 @@ import { Server } from 'hapi'; -import { configMock } from '../config/config.mock'; +import { configMock } from '../config/mocks'; import { httpServiceMock } from '../http/http_service.mock'; import { httpServerMock } from '../http/http_server.mocks'; import { findLegacyPluginSpecsMock } from './legacy_service.test.mocks'; diff --git a/src/core/server/legacy/legacy_service.test.ts b/src/core/server/legacy/legacy_service.test.ts index f3ce89f83a610..549252723be3f 100644 --- a/src/core/server/legacy/legacy_service.test.ts +++ b/src/core/server/legacy/legacy_service.test.ts @@ -25,16 +25,16 @@ import { } from './legacy_service.test.mocks'; import { BehaviorSubject, throwError } from 'rxjs'; +import { REPO_ROOT } from '@kbn/dev-utils'; // @ts-expect-error js file to remove TS dependency on cli import { ClusterManager as MockClusterManager } from './cluster_manager'; import KbnServer from '../../../legacy/server/kbn_server'; import { Config, Env, ObjectToConfigAdapter } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; import { BasePathProxyServer } from '../http'; import { DiscoveredPlugin } from '../plugins'; -import { configServiceMock } from '../config/config_service.mock'; +import { getEnvOptions, configServiceMock } from '../config/mocks'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { contextServiceMock } from '../context/context_service.mock'; import { httpServiceMock } from '../http/http_service.mock'; @@ -68,7 +68,7 @@ let environmentSetup: ReturnType { coreId = Symbol(); - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); configService = configServiceMock.create(); environmentSetup = environmentServiceMock.createSetupContract(); @@ -363,6 +363,7 @@ describe('once LegacyService is set up in `devClusterMaster` mode', () => { const devClusterLegacyService = new LegacyService({ coreId, env: Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { silent: true, basePath: false }, isDevClusterMaster: true, @@ -391,6 +392,7 @@ describe('once LegacyService is set up in `devClusterMaster` mode', () => { const devClusterLegacyService = new LegacyService({ coreId, env: Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { quiet: true, basePath: true }, isDevClusterMaster: true, diff --git a/src/core/server/legacy/logging/appenders/legacy_appender.test.ts b/src/core/server/legacy/logging/appenders/legacy_appender.test.ts index 538d987e781d0..697e5bc37d602 100644 --- a/src/core/server/legacy/logging/appenders/legacy_appender.test.ts +++ b/src/core/server/legacy/logging/appenders/legacy_appender.test.ts @@ -19,8 +19,7 @@ jest.mock('../legacy_logging_server'); -import { LogLevel } from '../../../logging/log_level'; -import { LogRecord } from '../../../logging/log_record'; +import { LogRecord, LogLevel } from '../../../logging'; import { LegacyLoggingServer } from '../legacy_logging_server'; import { LegacyAppender } from './legacy_appender'; diff --git a/src/core/server/legacy/logging/appenders/legacy_appender.ts b/src/core/server/legacy/logging/appenders/legacy_appender.ts index a5d36423ba4c6..67337c7d67629 100644 --- a/src/core/server/legacy/logging/appenders/legacy_appender.ts +++ b/src/core/server/legacy/logging/appenders/legacy_appender.ts @@ -18,8 +18,7 @@ */ import { schema } from '@kbn/config-schema'; -import { DisposableAppender } from '../../../logging/appenders/appenders'; -import { LogRecord } from '../../../logging/log_record'; +import { DisposableAppender, LogRecord } from '../../../logging'; import { LegacyLoggingServer } from '../legacy_logging_server'; import { LegacyVars } from '../../types'; diff --git a/src/core/server/legacy/logging/legacy_logging_server.test.ts b/src/core/server/legacy/logging/legacy_logging_server.test.ts index 6dca3a199728e..2f6c34e0fc5d6 100644 --- a/src/core/server/legacy/logging/legacy_logging_server.test.ts +++ b/src/core/server/legacy/logging/legacy_logging_server.test.ts @@ -20,7 +20,7 @@ jest.mock('../../../../legacy/server/config'); jest.mock('../../../../legacy/server/logging'); -import { LogLevel } from '../../logging/log_level'; +import { LogLevel } from '../../logging'; import { LegacyLoggingServer } from './legacy_logging_server'; test('correctly forwards log records.', () => { diff --git a/src/core/server/legacy/logging/legacy_logging_server.ts b/src/core/server/legacy/logging/legacy_logging_server.ts index 4a7fea87cf69f..096dbe54565e1 100644 --- a/src/core/server/legacy/logging/legacy_logging_server.ts +++ b/src/core/server/legacy/logging/legacy_logging_server.ts @@ -23,8 +23,7 @@ import Podium from 'podium'; import { Config } from '../../../../legacy/server/config'; // @ts-expect-error: implicit any for JS file import { setupLogging } from '../../../../legacy/server/logging'; -import { LogLevel } from '../../logging/log_level'; -import { LogRecord } from '../../logging/log_record'; +import { LogLevel, LogRecord } from '../../logging'; import { LegacyVars } from '../../types'; export const metadataSymbol = Symbol('log message with metadata'); diff --git a/src/core/server/logging/appenders/appenders.ts b/src/core/server/logging/appenders/appenders.ts index 9c19ee2bd8be5..4e6920c50686c 100644 --- a/src/core/server/logging/appenders/appenders.ts +++ b/src/core/server/logging/appenders/appenders.ts @@ -19,13 +19,13 @@ import { schema } from '@kbn/config-schema'; import { assertNever } from '@kbn/std'; +import { DisposableAppender } from '@kbn/logging'; import { LegacyAppender, LegacyAppenderConfig, } from '../../legacy/logging/appenders/legacy_appender'; import { Layouts } from '../layouts/layouts'; -import { LogRecord } from '../log_record'; import { ConsoleAppender, ConsoleAppenderConfig } from './console/console_appender'; import { FileAppender, FileAppenderConfig } from './file/file_appender'; @@ -44,25 +44,6 @@ export const appendersSchema = schema.oneOf([ /** @public */ export type AppenderConfigType = ConsoleAppenderConfig | FileAppenderConfig | LegacyAppenderConfig; -/** - * Entity that can append `LogRecord` instances to file, stdout, memory or whatever - * is implemented internally. It's supposed to be used by `Logger`. - * @internal - */ -export interface Appender { - append(record: LogRecord): void; -} - -/** - * This interface should be additionally implemented by the `Appender`'s if they are supposed - * to be properly disposed. It's intentionally separated from `Appender` interface so that `Logger` - * that interacts with `Appender` doesn't have control over appender lifetime. - * @internal - */ -export interface DisposableAppender extends Appender { - dispose: () => void; -} - /** @internal */ export class Appenders { public static configSchema = appendersSchema; diff --git a/src/core/server/logging/appenders/buffer/buffer_appender.test.ts b/src/core/server/logging/appenders/buffer/buffer_appender.test.ts index 49d70db8d5d43..7981aef64e589 100644 --- a/src/core/server/logging/appenders/buffer/buffer_appender.test.ts +++ b/src/core/server/logging/appenders/buffer/buffer_appender.test.ts @@ -17,8 +17,7 @@ * under the License. */ -import { LogLevel } from '../../log_level'; -import { LogRecord } from '../../log_record'; +import { LogLevel, LogRecord } from '@kbn/logging'; import { BufferAppender } from './buffer_appender'; test('`flush()` does not return any record buffered at the beginning.', () => { diff --git a/src/core/server/logging/appenders/buffer/buffer_appender.ts b/src/core/server/logging/appenders/buffer/buffer_appender.ts index 7024d3e5d16df..9e3a9d0f910f8 100644 --- a/src/core/server/logging/appenders/buffer/buffer_appender.ts +++ b/src/core/server/logging/appenders/buffer/buffer_appender.ts @@ -17,8 +17,7 @@ * under the License. */ -import { LogRecord } from '../../log_record'; -import { DisposableAppender } from '../appenders'; +import { LogRecord, DisposableAppender } from '@kbn/logging'; /** * Simple appender that just buffers `LogRecord` instances it receives. It is a *reserved* appender diff --git a/src/core/server/logging/appenders/console/console_appender.test.ts b/src/core/server/logging/appenders/console/console_appender.test.ts index 6e30df1cfb65c..0601ac10167ac 100644 --- a/src/core/server/logging/appenders/console/console_appender.test.ts +++ b/src/core/server/logging/appenders/console/console_appender.test.ts @@ -29,8 +29,7 @@ jest.mock('../../layouts/layouts', () => { }; }); -import { LogLevel } from '../../log_level'; -import { LogRecord } from '../../log_record'; +import { LogRecord, LogLevel } from '@kbn/logging'; import { ConsoleAppender } from './console_appender'; test('`configSchema` creates correct schema.', () => { diff --git a/src/core/server/logging/appenders/console/console_appender.ts b/src/core/server/logging/appenders/console/console_appender.ts index a54674b1d347c..dc491fcff664c 100644 --- a/src/core/server/logging/appenders/console/console_appender.ts +++ b/src/core/server/logging/appenders/console/console_appender.ts @@ -18,10 +18,8 @@ */ import { schema } from '@kbn/config-schema'; - -import { Layout, Layouts, LayoutConfigType } from '../../layouts/layouts'; -import { LogRecord } from '../../log_record'; -import { DisposableAppender } from '../appenders'; +import { Layout, LogRecord, DisposableAppender } from '@kbn/logging'; +import { Layouts, LayoutConfigType } from '../../layouts/layouts'; const { literal, object } = schema; diff --git a/src/core/server/logging/appenders/file/file_appender.test.ts b/src/core/server/logging/appenders/file/file_appender.test.ts index bff60029faf11..645455c5ae04c 100644 --- a/src/core/server/logging/appenders/file/file_appender.test.ts +++ b/src/core/server/logging/appenders/file/file_appender.test.ts @@ -19,8 +19,7 @@ import { mockCreateWriteStream } from './file_appender.test.mocks'; -import { LogLevel } from '../../log_level'; -import { LogRecord } from '../../log_record'; +import { LogRecord, LogLevel } from '@kbn/logging'; import { FileAppender } from './file_appender'; const tickMs = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/src/core/server/logging/appenders/file/file_appender.ts b/src/core/server/logging/appenders/file/file_appender.ts index a0e484cd87c8f..b1712bd4e9412 100644 --- a/src/core/server/logging/appenders/file/file_appender.ts +++ b/src/core/server/logging/appenders/file/file_appender.ts @@ -18,11 +18,10 @@ */ import { schema } from '@kbn/config-schema'; +import { LogRecord, Layout, DisposableAppender } from '@kbn/logging'; import { createWriteStream, WriteStream } from 'fs'; -import { Layout, Layouts, LayoutConfigType } from '../../layouts/layouts'; -import { LogRecord } from '../../log_record'; -import { DisposableAppender } from '../appenders'; +import { Layouts, LayoutConfigType } from '../../layouts/layouts'; export interface FileAppenderConfig { kind: 'file'; diff --git a/src/core/server/logging/index.ts b/src/core/server/logging/index.ts index 9471972030281..01f153cae9e2d 100644 --- a/src/core/server/logging/index.ts +++ b/src/core/server/logging/index.ts @@ -17,10 +17,17 @@ * under the License. */ -export { Logger, LogMeta } from './logger'; -export { LoggerFactory } from './logger_factory'; -export { LogRecord } from './log_record'; -export { LogLevel } from './log_level'; +export { + DisposableAppender, + Appender, + LogRecord, + Layout, + LoggerFactory, + LogMeta, + Logger, + LogLevelId, + LogLevel, +} from '@kbn/logging'; export { config, LoggingConfigType, diff --git a/src/core/server/logging/layouts/conversions/date.ts b/src/core/server/logging/layouts/conversions/date.ts index d3ed54fb98240..3a43c0ffcd389 100644 --- a/src/core/server/logging/layouts/conversions/date.ts +++ b/src/core/server/logging/layouts/conversions/date.ts @@ -18,9 +18,9 @@ */ import moment from 'moment-timezone'; import { last } from 'lodash'; +import { LogRecord } from '@kbn/logging'; import { Conversion } from './type'; -import { LogRecord } from '../../log_record'; const dateRegExp = /%date({(?[^}]+)})?({(?[^}]+)})?/g; diff --git a/src/core/server/logging/layouts/conversions/level.ts b/src/core/server/logging/layouts/conversions/level.ts index 58b271140eff5..83208242dc258 100644 --- a/src/core/server/logging/layouts/conversions/level.ts +++ b/src/core/server/logging/layouts/conversions/level.ts @@ -18,10 +18,9 @@ */ import chalk from 'chalk'; +import { LogRecord, LogLevel } from '@kbn/logging'; import { Conversion } from './type'; -import { LogLevel } from '../../log_level'; -import { LogRecord } from '../../log_record'; const LEVEL_COLORS = new Map([ [LogLevel.Fatal, chalk.red], diff --git a/src/core/server/logging/layouts/conversions/logger.ts b/src/core/server/logging/layouts/conversions/logger.ts index debb1737ab95a..e63976052443b 100644 --- a/src/core/server/logging/layouts/conversions/logger.ts +++ b/src/core/server/logging/layouts/conversions/logger.ts @@ -18,9 +18,9 @@ */ import chalk from 'chalk'; +import { LogRecord } from '@kbn/logging'; import { Conversion } from './type'; -import { LogRecord } from '../../log_record'; export const LoggerConversion: Conversion = { pattern: /%logger/g, diff --git a/src/core/server/logging/layouts/conversions/message.ts b/src/core/server/logging/layouts/conversions/message.ts index f8c5e68ada4fb..73d85532a5a90 100644 --- a/src/core/server/logging/layouts/conversions/message.ts +++ b/src/core/server/logging/layouts/conversions/message.ts @@ -17,8 +17,8 @@ * under the License. */ +import { LogRecord } from '@kbn/logging'; import { Conversion } from './type'; -import { LogRecord } from '../../log_record'; export const MessageConversion: Conversion = { pattern: /%message/g, diff --git a/src/core/server/logging/layouts/conversions/meta.ts b/src/core/server/logging/layouts/conversions/meta.ts index ee8c207389fbe..b78db41b7e969 100644 --- a/src/core/server/logging/layouts/conversions/meta.ts +++ b/src/core/server/logging/layouts/conversions/meta.ts @@ -16,8 +16,9 @@ * specific language governing permissions and limitations * under the License. */ + +import { LogRecord } from '@kbn/logging'; import { Conversion } from './type'; -import { LogRecord } from '../../log_record'; export const MetaConversion: Conversion = { pattern: /%meta/g, diff --git a/src/core/server/logging/layouts/conversions/pid.ts b/src/core/server/logging/layouts/conversions/pid.ts index 37d34a4f1cf8b..f6902005f5668 100644 --- a/src/core/server/logging/layouts/conversions/pid.ts +++ b/src/core/server/logging/layouts/conversions/pid.ts @@ -17,8 +17,8 @@ * under the License. */ +import { LogRecord } from '@kbn/logging'; import { Conversion } from './type'; -import { LogRecord } from '../../log_record'; export const PidConversion: Conversion = { pattern: /%pid/g, diff --git a/src/core/server/logging/layouts/conversions/type.ts b/src/core/server/logging/layouts/conversions/type.ts index a57a1f954e53a..be172a0a98f7d 100644 --- a/src/core/server/logging/layouts/conversions/type.ts +++ b/src/core/server/logging/layouts/conversions/type.ts @@ -16,7 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import { LogRecord } from 'kibana/server'; + +import { LogRecord } from '@kbn/logging'; export interface Conversion { pattern: RegExp; diff --git a/src/core/server/logging/layouts/json_layout.test.ts b/src/core/server/logging/layouts/json_layout.test.ts index 6cda1e4806aa8..f476e3f217278 100644 --- a/src/core/server/logging/layouts/json_layout.test.ts +++ b/src/core/server/logging/layouts/json_layout.test.ts @@ -17,8 +17,7 @@ * under the License. */ -import { LogLevel } from '../log_level'; -import { LogRecord } from '../log_record'; +import { LogLevel, LogRecord } from '@kbn/logging'; import { JsonLayout } from './json_layout'; const timestamp = new Date(Date.UTC(2012, 1, 1, 14, 30, 22, 11)); diff --git a/src/core/server/logging/layouts/json_layout.ts b/src/core/server/logging/layouts/json_layout.ts index 37eb6b8c4806e..7573d0b837416 100644 --- a/src/core/server/logging/layouts/json_layout.ts +++ b/src/core/server/logging/layouts/json_layout.ts @@ -20,9 +20,7 @@ import moment from 'moment-timezone'; import { merge } from 'lodash'; import { schema } from '@kbn/config-schema'; - -import { LogRecord } from '../log_record'; -import { Layout } from './layouts'; +import { LogRecord, Layout } from '@kbn/logging'; const { literal, object } = schema; diff --git a/src/core/server/logging/layouts/layouts.ts b/src/core/server/logging/layouts/layouts.ts index 03e8adbee6311..faf05e4d1e347 100644 --- a/src/core/server/logging/layouts/layouts.ts +++ b/src/core/server/logging/layouts/layouts.ts @@ -18,9 +18,9 @@ */ import { schema } from '@kbn/config-schema'; +import { Layout } from '@kbn/logging'; import { assertNever } from '@kbn/std'; -import { LogRecord } from '../log_record'; import { JsonLayout, JsonLayoutConfigType } from './json_layout'; import { PatternLayout, PatternLayoutConfigType } from './pattern_layout'; @@ -28,14 +28,6 @@ const { oneOf } = schema; export type LayoutConfigType = PatternLayoutConfigType | JsonLayoutConfigType; -/** - * Entity that can format `LogRecord` instance into a string. - * @internal - */ -export interface Layout { - format(record: LogRecord): string; -} - /** @internal */ export class Layouts { public static configSchema = oneOf([JsonLayout.configSchema, PatternLayout.configSchema]); diff --git a/src/core/server/logging/layouts/pattern_layout.test.ts b/src/core/server/logging/layouts/pattern_layout.test.ts index cce55b147e0ed..d37ee3c87d08f 100644 --- a/src/core/server/logging/layouts/pattern_layout.test.ts +++ b/src/core/server/logging/layouts/pattern_layout.test.ts @@ -17,9 +17,8 @@ * under the License. */ +import { LogLevel, LogRecord } from '@kbn/logging'; import { stripAnsiSnapshotSerializer } from '../../../test_helpers/strip_ansi_snapshot_serializer'; -import { LogLevel } from '../log_level'; -import { LogRecord } from '../log_record'; import { PatternLayout, patternSchema } from './pattern_layout'; const timestamp = new Date(Date.UTC(2012, 1, 1, 14, 30, 22, 11)); diff --git a/src/core/server/logging/layouts/pattern_layout.ts b/src/core/server/logging/layouts/pattern_layout.ts index 5dfc8aca77f18..2ca444f54b499 100644 --- a/src/core/server/logging/layouts/pattern_layout.ts +++ b/src/core/server/logging/layouts/pattern_layout.ts @@ -18,9 +18,8 @@ */ import { schema } from '@kbn/config-schema'; +import { LogRecord, Layout } from '@kbn/logging'; -import { LogRecord } from '../log_record'; -import { Layout } from './layouts'; import { Conversion, LoggerConversion, diff --git a/src/core/server/logging/logger.mock.ts b/src/core/server/logging/logger.mock.ts index a3bb07ea4c095..5af967ecd430e 100644 --- a/src/core/server/logging/logger.mock.ts +++ b/src/core/server/logging/logger.mock.ts @@ -17,30 +17,4 @@ * under the License. */ -import { Logger } from './logger'; - -export type MockedLogger = jest.Mocked & { context: string[] }; - -const createLoggerMock = (context: string[] = []) => { - const mockLog: MockedLogger = { - context, - debug: jest.fn(), - error: jest.fn(), - fatal: jest.fn(), - info: jest.fn(), - log: jest.fn(), - trace: jest.fn(), - warn: jest.fn(), - get: jest.fn(), - }; - mockLog.get.mockImplementation((...ctx) => ({ - ctx, - ...mockLog, - })); - - return mockLog; -}; - -export const loggerMock = { - create: createLoggerMock, -}; +export { loggerMock, MockedLogger } from '@kbn/logging/target/mocks'; diff --git a/src/core/server/logging/logger.test.ts b/src/core/server/logging/logger.test.ts index 1cc00a254300b..1796519ff65e5 100644 --- a/src/core/server/logging/logger.test.ts +++ b/src/core/server/logging/logger.test.ts @@ -17,9 +17,8 @@ * under the License. */ +import { LogLevel, Appender } from '@kbn/logging'; import { LoggingConfig } from './logging_config'; -import { Appender } from './appenders/appenders'; -import { LogLevel } from './log_level'; import { BaseLogger } from './logger'; const context = LoggingConfig.getLoggerContext(['context', 'parent', 'child']); diff --git a/src/core/server/logging/logger.ts b/src/core/server/logging/logger.ts index 285998c23832c..6861072ef3b8b 100644 --- a/src/core/server/logging/logger.ts +++ b/src/core/server/logging/logger.ts @@ -17,86 +17,7 @@ * under the License. */ -import { Appender } from './appenders/appenders'; -import { LogLevel } from './log_level'; -import { LogRecord } from './log_record'; -import { LoggerFactory } from './logger_factory'; - -/** - * Contextual metadata - * - * @public - */ -export interface LogMeta { - [key: string]: any; -} - -/** - * Logger exposes all the necessary methods to log any type of information and - * this is the interface used by the logging consumers including plugins. - * - * @public - */ -export interface Logger { - /** - * Log messages at the most detailed log level - * - * @param message - The log message - * @param meta - - */ - trace(message: string, meta?: LogMeta): void; - - /** - * Log messages useful for debugging and interactive investigation - * @param message - The log message - * @param meta - - */ - debug(message: string, meta?: LogMeta): void; - - /** - * Logs messages related to general application flow - * @param message - The log message - * @param meta - - */ - info(message: string, meta?: LogMeta): void; - - /** - * Logs abnormal or unexpected errors or messages - * @param errorOrMessage - An Error object or message string to log - * @param meta - - */ - warn(errorOrMessage: string | Error, meta?: LogMeta): void; - - /** - * Logs abnormal or unexpected errors or messages that caused a failure in the application flow - * - * @param errorOrMessage - An Error object or message string to log - * @param meta - - */ - error(errorOrMessage: string | Error, meta?: LogMeta): void; - - /** - * Logs abnormal or unexpected errors or messages that caused an unrecoverable failure - * - * @param errorOrMessage - An Error object or message string to log - * @param meta - - */ - fatal(errorOrMessage: string | Error, meta?: LogMeta): void; - - /** @internal */ - log(record: LogRecord): void; - - /** - * Returns a new {@link Logger} instance extending the current logger context. - * - * @example - * ```typescript - * const logger = loggerFactory.get('plugin', 'service'); // 'plugin.service' context - * const subLogger = logger.get('feature'); // 'plugin.service.feature' context - * ``` - */ - get(...childContextPaths: string[]): Logger; -} +import { Appender, LogLevel, LogRecord, LoggerFactory, LogMeta, Logger } from '@kbn/logging'; function isError(x: any): x is Error { return x instanceof Error; diff --git a/src/core/server/logging/logger_adapter.ts b/src/core/server/logging/logger_adapter.ts index 14e5712e55c58..4ce65bf3302e7 100644 --- a/src/core/server/logging/logger_adapter.ts +++ b/src/core/server/logging/logger_adapter.ts @@ -17,8 +17,7 @@ * under the License. */ -import { LogRecord } from './log_record'; -import { Logger, LogMeta } from './logger'; +import { LogRecord, Logger, LogMeta } from '@kbn/logging'; /** @internal */ export class LoggerAdapter implements Logger { diff --git a/src/core/server/logging/logging_service.ts b/src/core/server/logging/logging_service.ts index 09051f8f07702..f2b609f2258c7 100644 --- a/src/core/server/logging/logging_service.ts +++ b/src/core/server/logging/logging_service.ts @@ -18,10 +18,10 @@ */ import { Observable, Subscription } from 'rxjs'; +import { Logger } from '@kbn/logging'; import { CoreService } from '../../types'; import { LoggingConfig, LoggerContextConfigInput } from './logging_config'; import { ILoggingSystem } from './logging_system'; -import { Logger } from './logger'; import { CoreContext } from '../core_context'; /** diff --git a/src/core/server/logging/logging_system.mock.ts b/src/core/server/logging/logging_system.mock.ts index ac1e9b5196002..6ea784be5411f 100644 --- a/src/core/server/logging/logging_system.mock.ts +++ b/src/core/server/logging/logging_system.mock.ts @@ -18,8 +18,8 @@ */ // Test helpers to simplify mocking logs and collecting all their outputs +import { LoggerFactory } from '@kbn/logging'; import { ILoggingSystem } from './logging_system'; -import { LoggerFactory } from './logger_factory'; import { loggerMock, MockedLogger } from './logger.mock'; const createLoggingSystemMock = () => { @@ -48,15 +48,7 @@ const createLoggingSystemMock = () => { const collectLoggingSystemMock = (loggerFactory: LoggerFactory) => { const mockLog = loggerFactory.get() as MockedLogger; - return { - debug: mockLog.debug.mock.calls, - error: mockLog.error.mock.calls, - fatal: mockLog.fatal.mock.calls, - info: mockLog.info.mock.calls, - log: mockLog.log.mock.calls, - trace: mockLog.trace.mock.calls, - warn: mockLog.warn.mock.calls, - }; + return loggerMock.collect(mockLog); }; const clearLoggingSystemMock = (loggerFactory: LoggerFactory) => { @@ -67,13 +59,7 @@ const clearLoggingSystemMock = (loggerFactory: LoggerFactory) => { mockedLoggerFactory.stop.mockClear(); const mockLog = loggerFactory.get() as MockedLogger; - mockLog.debug.mockClear(); - mockLog.info.mockClear(); - mockLog.warn.mockClear(); - mockLog.error.mockClear(); - mockLog.trace.mockClear(); - mockLog.fatal.mockClear(); - mockLog.log.mockClear(); + loggerMock.clear(mockLog); }; export const loggingSystemMock = { diff --git a/src/core/server/logging/logging_system.ts b/src/core/server/logging/logging_system.ts index a3970b1720950..8bc22bdf537af 100644 --- a/src/core/server/logging/logging_system.ts +++ b/src/core/server/logging/logging_system.ts @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ + import type { PublicMethodsOf } from '@kbn/utility-types'; -import { Appenders, DisposableAppender } from './appenders/appenders'; +import { DisposableAppender, LogLevel, Logger, LoggerFactory } from '@kbn/logging'; +import { Appenders } from './appenders/appenders'; import { BufferAppender } from './appenders/buffer/buffer_appender'; -import { LogLevel } from './log_level'; -import { BaseLogger, Logger } from './logger'; +import { BaseLogger } from './logger'; import { LoggerAdapter } from './logger_adapter'; -import { LoggerFactory } from './logger_factory'; import { LoggingConfigType, LoggerConfigType, diff --git a/src/core/server/metrics/metrics_service.test.ts b/src/core/server/metrics/metrics_service.test.ts index f2019de7b6cab..269931d0e33ad 100644 --- a/src/core/server/metrics/metrics_service.test.ts +++ b/src/core/server/metrics/metrics_service.test.ts @@ -18,10 +18,11 @@ */ import moment from 'moment'; + +import { configServiceMock } from '../config/mocks'; import { mockOpsCollector } from './metrics_service.test.mocks'; import { MetricsService } from './metrics_service'; import { mockCoreContext } from '../core_context.mock'; -import { configServiceMock } from '../config/config_service.mock'; import { httpServiceMock } from '../http/http_service.mock'; import { take } from 'rxjs/operators'; diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index 3c79706422cd4..5d6bf41fec3f3 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -37,10 +37,10 @@ import { environmentServiceMock } from './environment/environment_service.mock'; import { statusServiceMock } from './status/status_service.mock'; import { auditTrailServiceMock } from './audit_trail/audit_trail_service.mock'; +export { configServiceMock } from './config/mocks'; export { httpServerMock } from './http/http_server.mocks'; export { httpResourcesMock } from './http_resources/http_resources_service.mock'; export { sessionStorageMock } from './http/cookie_session_storage.mocks'; -export { configServiceMock } from './config/config_service.mock'; export { elasticsearchServiceMock } from './elasticsearch/elasticsearch_service.mock'; export { httpServiceMock } from './http/http_service.mock'; export { loggingSystemMock } from './logging/logging_system.mock'; diff --git a/src/core/server/plugins/discovery/plugin_manifest_parser.test.mocks.ts b/src/core/server/plugins/discovery/plugin_manifest_parser.test.mocks.ts index eb8dc1e609582..3634a7ed2c277 100644 --- a/src/core/server/plugins/discovery/plugin_manifest_parser.test.mocks.ts +++ b/src/core/server/plugins/discovery/plugin_manifest_parser.test.mocks.ts @@ -17,6 +17,12 @@ * under the License. */ +const realFs = jest.requireActual('fs'); + export const mockReadFile = jest.fn(); const mockStat = jest.fn(); -jest.mock('fs', () => ({ readFile: mockReadFile, stat: mockStat })); +jest.doMock('fs', () => ({ + ...realFs, + readFile: mockReadFile, + stat: mockStat, +})); diff --git a/src/core/server/plugins/discovery/plugin_manifest_parser.test.ts b/src/core/server/plugins/discovery/plugin_manifest_parser.test.ts index 836aabf881474..cb9f5982d0f19 100644 --- a/src/core/server/plugins/discovery/plugin_manifest_parser.test.ts +++ b/src/core/server/plugins/discovery/plugin_manifest_parser.test.ts @@ -17,9 +17,9 @@ * under the License. */ -import { PluginDiscoveryErrorType } from './plugin_discovery_error'; - import { mockReadFile } from './plugin_manifest_parser.test.mocks'; + +import { PluginDiscoveryErrorType } from './plugin_discovery_error'; import { loggingSystemMock } from '../../logging/logging_system.mock'; import { resolve } from 'path'; diff --git a/src/core/server/plugins/discovery/plugins_discovery.test.mocks.ts b/src/core/server/plugins/discovery/plugins_discovery.test.mocks.ts index 83accc06cb995..131ee58e21a81 100644 --- a/src/core/server/plugins/discovery/plugins_discovery.test.mocks.ts +++ b/src/core/server/plugins/discovery/plugins_discovery.test.mocks.ts @@ -17,5 +17,10 @@ * under the License. */ -export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] }); -jest.mock('../../../../../package.json', () => mockPackage); +export const mockPackage = { + raw: {}, +}; + +jest.doMock('load-json-file', () => ({ + sync: () => mockPackage.raw, +})); diff --git a/src/core/server/plugins/discovery/plugins_discovery.test.ts b/src/core/server/plugins/discovery/plugins_discovery.test.ts index 4894f19e38df4..0dfc5599e8007 100644 --- a/src/core/server/plugins/discovery/plugins_discovery.test.ts +++ b/src/core/server/plugins/discovery/plugins_discovery.test.ts @@ -17,18 +17,19 @@ * under the License. */ +// must be before mocks imports to avoid conflicting with `REPO_ROOT` accessor. +import { REPO_ROOT } from '@kbn/dev-utils'; import { mockPackage } from './plugins_discovery.test.mocks'; import mockFs from 'mock-fs'; import { loggingSystemMock } from '../../logging/logging_system.mock'; +import { getEnvOptions, rawConfigServiceMock } from '../../config/mocks'; import { first, map, toArray } from 'rxjs/operators'; import { resolve } from 'path'; import { ConfigService, Env } from '../../config'; -import { getEnvOptions } from '../../config/__mocks__/env'; import { PluginsConfig, PluginsConfigType, config } from '../plugins_config'; import type { InstanceInfo } from '../plugin_context'; import { discover } from './plugins_discovery'; -import { rawConfigServiceMock } from '../../config/raw_config_service.mock'; import { CoreContext } from '../../core_context'; const KIBANA_ROOT = process.cwd(); @@ -94,6 +95,7 @@ describe('plugins discovery system', () => { }; env = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { envName: 'development' }, }) @@ -382,6 +384,7 @@ describe('plugins discovery system', () => { const extraPluginTestPath = resolve(process.cwd(), 'my-extra-plugin'); env = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { dev: false, envName: 'development' }, }) @@ -409,6 +412,7 @@ describe('plugins discovery system', () => { const extraPluginTestPath = resolve(process.cwd(), 'my-extra-plugin'); env = Env.createDefault( + REPO_ROOT, getEnvOptions({ cliArgs: { dev: false, envName: 'production' }, }) diff --git a/src/core/server/plugins/integration_tests/plugins_service.test.mocks.ts b/src/core/server/plugins/integration_tests/plugins_service.test.mocks.ts index d81a7eb5db4ae..ed73fe9b99be6 100644 --- a/src/core/server/plugins/integration_tests/plugins_service.test.mocks.ts +++ b/src/core/server/plugins/integration_tests/plugins_service.test.mocks.ts @@ -17,11 +17,13 @@ * under the License. */ -export const mockPackage = new Proxy( - { raw: { __dirname: '/tmp' } as any }, - { get: (obj, prop) => obj.raw[prop] } -); -jest.mock('../../../../core/server/utils/package_json', () => ({ pkg: mockPackage })); +export const mockPackage = { + raw: { __dirname: '/tmp' } as any, +}; + +jest.doMock('load-json-file', () => ({ + sync: () => mockPackage.raw, +})); export const mockDiscover = jest.fn(); jest.mock('../discovery/plugins_discovery', () => ({ discover: mockDiscover })); diff --git a/src/core/server/plugins/integration_tests/plugins_service.test.ts b/src/core/server/plugins/integration_tests/plugins_service.test.ts index 5a216b75a83b9..93fee05016ff2 100644 --- a/src/core/server/plugins/integration_tests/plugins_service.test.ts +++ b/src/core/server/plugins/integration_tests/plugins_service.test.ts @@ -17,15 +17,16 @@ * under the License. */ +// must be before mocks imports to avoid conflicting with `REPO_ROOT` accessor. +import { REPO_ROOT } from '@kbn/dev-utils'; import { mockPackage, mockDiscover } from './plugins_service.test.mocks'; import { join } from 'path'; import { PluginsService } from '../plugins_service'; import { ConfigPath, ConfigService, Env } from '../../config'; -import { getEnvOptions } from '../../config/__mocks__/env'; +import { getEnvOptions, rawConfigServiceMock } from '../../config/mocks'; import { BehaviorSubject, from } from 'rxjs'; -import { rawConfigServiceMock } from '../../config/raw_config_service.mock'; import { config } from '../plugins_config'; import { loggingSystemMock } from '../../logging/logging_system.mock'; import { environmentServiceMock } from '../../environment/environment_service.mock'; @@ -93,7 +94,7 @@ describe('PluginsService', () => { }, }; - const env = Env.createDefault(getEnvOptions()); + const env = Env.createDefault(REPO_ROOT, getEnvOptions()); const config$ = new BehaviorSubject>({ plugins: { initialize: true, diff --git a/src/core/server/plugins/plugin.test.ts b/src/core/server/plugins/plugin.test.ts index 1108ffc248161..ae22ead2aa4be 100644 --- a/src/core/server/plugins/plugin.test.ts +++ b/src/core/server/plugins/plugin.test.ts @@ -19,14 +19,14 @@ import { join } from 'path'; import { BehaviorSubject } from 'rxjs'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { schema } from '@kbn/config-schema'; import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; import { CoreContext } from '../core_context'; import { coreMock } from '../mocks'; -import { configServiceMock } from '../config/config_service.mock'; import { loggingSystemMock } from '../logging/logging_system.mock'; +import { getEnvOptions, configServiceMock } from '../config/mocks'; import { PluginWrapper } from './plugin'; import { PluginManifest } from './types'; @@ -77,7 +77,7 @@ const setupDeps = coreMock.createInternalSetup(); beforeEach(() => { coreId = Symbol('core'); - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); instanceInfo = { uuid: 'instance-uuid', }; diff --git a/src/core/server/plugins/plugin_context.test.ts b/src/core/server/plugins/plugin_context.test.ts index 578c5f39d71ea..5ce91c9a623dc 100644 --- a/src/core/server/plugins/plugin_context.test.ts +++ b/src/core/server/plugins/plugin_context.test.ts @@ -19,12 +19,12 @@ import { duration } from 'moment'; import { first } from 'rxjs/operators'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { createPluginInitializerContext, InstanceInfo } from './plugin_context'; import { CoreContext } from '../core_context'; import { Env } from '../config'; import { loggingSystemMock } from '../logging/logging_system.mock'; -import { rawConfigServiceMock } from '../config/raw_config_service.mock'; -import { getEnvOptions } from '../config/__mocks__/env'; +import { rawConfigServiceMock, getEnvOptions } from '../config/mocks'; import { PluginManifest } from './types'; import { Server } from '../server'; import { fromRoot } from '../utils'; @@ -58,7 +58,7 @@ describe('createPluginInitializerContext', () => { instanceInfo = { uuid: 'instance-uuid', }; - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); const config$ = rawConfigServiceMock.create({ rawConfig: {} }); server = new Server(config$, env, logger); await server.setupCoreConfig(); diff --git a/src/core/server/plugins/plugins_config.test.ts b/src/core/server/plugins/plugins_config.test.ts index 180d6093e0404..2a64e79d19bda 100644 --- a/src/core/server/plugins/plugins_config.test.ts +++ b/src/core/server/plugins/plugins_config.test.ts @@ -17,13 +17,14 @@ * under the License. */ +import { REPO_ROOT } from '@kbn/dev-utils'; +import { getEnvOptions } from '../config/mocks'; import { PluginsConfig, PluginsConfigType } from './plugins_config'; import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; describe('PluginsConfig', () => { it('retrieves additionalPluginPaths from config.paths when in production mode', () => { - const env = Env.createDefault(getEnvOptions({ cliArgs: { dev: false } })); + const env = Env.createDefault(REPO_ROOT, getEnvOptions({ cliArgs: { dev: false } })); const rawConfig: PluginsConfigType = { initialize: true, paths: ['some-path', 'another-path'], @@ -33,7 +34,7 @@ describe('PluginsConfig', () => { }); it('retrieves additionalPluginPaths from config.paths when in development mode', () => { - const env = Env.createDefault(getEnvOptions({ cliArgs: { dev: true } })); + const env = Env.createDefault(REPO_ROOT, getEnvOptions({ cliArgs: { dev: true } })); const rawConfig: PluginsConfigType = { initialize: true, paths: ['some-path', 'another-path'], diff --git a/src/core/server/plugins/plugins_service.test.mocks.ts b/src/core/server/plugins/plugins_service.test.mocks.ts index 8d4ba12c8375c..15e4187ef95ed 100644 --- a/src/core/server/plugins/plugins_service.test.mocks.ts +++ b/src/core/server/plugins/plugins_service.test.mocks.ts @@ -17,11 +17,25 @@ * under the License. */ -export const mockPackage = new Proxy( - { raw: { __dirname: '/tmp' } as any }, - { get: (obj, prop) => obj.raw[prop] } -); -jest.mock('../../../core/server/utils/package_json', () => ({ pkg: mockPackage })); +import { REPO_ROOT } from '@kbn/utils'; +import { resolve } from 'path'; + +const loadJsonFile = jest.requireActual('load-json-file'); +const kibanaPackagePath = resolve(REPO_ROOT, 'package.json'); + +export const mockPackage = { + raw: { __dirname: '/tmp', name: 'kibana' } as any, +}; + +jest.doMock('load-json-file', () => ({ + ...loadJsonFile, + sync: (path: string) => { + if (path === kibanaPackagePath) { + return mockPackage.raw; + } + return loadJsonFile.sync(path); + }, +})); export const mockDiscover = jest.fn(); jest.mock('./discovery/plugins_discovery', () => ({ discover: mockDiscover })); diff --git a/src/core/server/plugins/plugins_service.test.ts b/src/core/server/plugins/plugins_service.test.ts index 5e613343c302f..d36fd2251176a 100644 --- a/src/core/server/plugins/plugins_service.test.ts +++ b/src/core/server/plugins/plugins_service.test.ts @@ -22,11 +22,10 @@ import { mockDiscover, mockPackage } from './plugins_service.test.mocks'; import { resolve, join } from 'path'; import { BehaviorSubject, from } from 'rxjs'; import { schema } from '@kbn/config-schema'; -import { createAbsolutePathSerializer } from '@kbn/dev-utils'; +import { createAbsolutePathSerializer, REPO_ROOT } from '@kbn/dev-utils'; import { ConfigPath, ConfigService, Env } from '../config'; -import { rawConfigServiceMock } from '../config/raw_config_service.mock'; -import { getEnvOptions } from '../config/__mocks__/env'; +import { rawConfigServiceMock, getEnvOptions } from '../config/mocks'; import { coreMock } from '../mocks'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { environmentServiceMock } from '../environment/environment_service.mock'; @@ -116,7 +115,7 @@ describe('PluginsService', () => { }; coreId = Symbol('core'); - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); config$ = new BehaviorSubject>({ plugins: { initialize: true } }); const rawConfigService = rawConfigServiceMock.create({ rawConfig$: config$ }); diff --git a/src/core/server/plugins/plugins_system.test.ts b/src/core/server/plugins/plugins_system.test.ts index 71ac31db13f92..ae9267ca5cf60 100644 --- a/src/core/server/plugins/plugins_system.test.ts +++ b/src/core/server/plugins/plugins_system.test.ts @@ -24,10 +24,10 @@ import { import { BehaviorSubject } from 'rxjs'; +import { REPO_ROOT } from '@kbn/dev-utils'; import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; +import { configServiceMock, getEnvOptions } from '../config/mocks'; import { CoreContext } from '../core_context'; -import { configServiceMock } from '../config/config_service.mock'; import { loggingSystemMock } from '../logging/logging_system.mock'; import { PluginWrapper } from './plugin'; @@ -74,7 +74,7 @@ const setupDeps = coreMock.createInternalSetup(); const startDeps = coreMock.createInternalStart(); beforeEach(() => { - env = Env.createDefault(getEnvOptions()); + env = Env.createDefault(REPO_ROOT, getEnvOptions()); coreContext = { coreId: Symbol(), env, logger, configService: configService as any }; diff --git a/src/core/server/root/index.test.mocks.ts b/src/core/server/root/index.test.mocks.ts index ef4a40fa3db2d..d81b1575adb88 100644 --- a/src/core/server/root/index.test.mocks.ts +++ b/src/core/server/root/index.test.mocks.ts @@ -23,15 +23,14 @@ jest.doMock('../logging/logging_system', () => ({ LoggingSystem: jest.fn(() => logger), })); -import { configServiceMock } from '../config/config_service.mock'; -export const configService = configServiceMock.create(); -jest.doMock('../config/config_service', () => ({ - ConfigService: jest.fn(() => configService), -})); +const realKbnConfig = jest.requireActual('@kbn/config'); -import { rawConfigServiceMock } from '../config/raw_config_service.mock'; +import { configServiceMock, rawConfigServiceMock } from '../config/mocks'; +export const configService = configServiceMock.create(); export const rawConfigService = rawConfigServiceMock.create(); -jest.doMock('../config/raw_config_service', () => ({ +jest.doMock('@kbn/config', () => ({ + ...realKbnConfig, + ConfigService: jest.fn(() => configService), RawConfigService: jest.fn(() => rawConfigService), })); diff --git a/src/core/server/root/index.test.ts b/src/core/server/root/index.test.ts index 5b853903ea4be..4d3fe24c7ba83 100644 --- a/src/core/server/root/index.test.ts +++ b/src/core/server/root/index.test.ts @@ -21,11 +21,12 @@ import { rawConfigService, configService, logger, mockServer } from './index.tes import { BehaviorSubject } from 'rxjs'; import { filter, first } from 'rxjs/operators'; +import { REPO_ROOT } from '@kbn/dev-utils'; +import { getEnvOptions } from '../config/mocks'; import { Root } from '.'; import { Env } from '../config'; -import { getEnvOptions } from '../config/__mocks__/env'; -const env = new Env('.', getEnvOptions()); +const env = Env.createDefault(REPO_ROOT, getEnvOptions()); let mockConsoleError: jest.SpyInstance; diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index 05eb1b8d42386..ab26f29dce3af 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -21,6 +21,7 @@ import { CatSnapshotsParams } from 'elasticsearch'; import { CatTasksParams } from 'elasticsearch'; import { CatThreadPoolParams } from 'elasticsearch'; import { ClearScrollParams } from 'elasticsearch'; +import { CliArgs } from '@kbn/config'; import { Client } from 'elasticsearch'; import { ClientOptions } from '@elastic/elasticsearch'; import { ClusterAllocationExplainParams } from 'elasticsearch'; @@ -31,7 +32,13 @@ import { ClusterPutSettingsParams } from 'elasticsearch'; import { ClusterRerouteParams } from 'elasticsearch'; import { ClusterStateParams } from 'elasticsearch'; import { ClusterStatsParams } from 'elasticsearch'; +import { ConfigDeprecation } from '@kbn/config'; +import { ConfigDeprecationFactory } from '@kbn/config'; +import { ConfigDeprecationLogger } from '@kbn/config'; +import { ConfigDeprecationProvider } from '@kbn/config'; import { ConfigOptions } from 'elasticsearch'; +import { ConfigPath } from '@kbn/config'; +import { ConfigService } from '@kbn/config'; import { CountParams } from 'elasticsearch'; import { CreateDocumentParams } from 'elasticsearch'; import { DeleteDocumentByQueryParams } from 'elasticsearch'; @@ -40,6 +47,7 @@ import { DeleteScriptParams } from 'elasticsearch'; import { DeleteTemplateParams } from 'elasticsearch'; import { DetailedPeerCertificate } from 'tls'; import { Duration } from 'moment'; +import { EnvironmentMode } from '@kbn/config'; import { ExistsParams } from 'elasticsearch'; import { ExplainParams } from 'elasticsearch'; import { FieldStatsParams } from 'elasticsearch'; @@ -94,6 +102,11 @@ import { IngestPutPipelineParams } from 'elasticsearch'; import { IngestSimulateParams } from 'elasticsearch'; import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import { KibanaConfigType } from 'src/core/server/kibana_config'; +import { Logger } from '@kbn/logging'; +import { LoggerFactory } from '@kbn/logging'; +import { LogLevel } from '@kbn/logging'; +import { LogMeta } from '@kbn/logging'; +import { LogRecord } from '@kbn/logging'; import { MGetParams } from 'elasticsearch'; import { MGetResponse } from 'elasticsearch'; import { MSearchParams } from 'elasticsearch'; @@ -105,6 +118,7 @@ import { NodesInfoParams } from 'elasticsearch'; import { NodesStatsParams } from 'elasticsearch'; import { ObjectType } from '@kbn/config-schema'; import { Observable } from 'rxjs'; +import { PackageInfo } from '@kbn/config'; import { PathConfigType } from '@kbn/utils'; import { PeerCertificate } from 'tls'; import { PingParams } from 'elasticsearch'; @@ -363,45 +377,17 @@ export const config: { }; }; -// @public -export type ConfigDeprecation = (config: Record, fromPath: string, logger: ConfigDeprecationLogger) => Record; +export { ConfigDeprecation } -// @public -export interface ConfigDeprecationFactory { - rename(oldKey: string, newKey: string): ConfigDeprecation; - renameFromRoot(oldKey: string, newKey: string, silent?: boolean): ConfigDeprecation; - unused(unusedKey: string): ConfigDeprecation; - unusedFromRoot(unusedKey: string): ConfigDeprecation; -} +export { ConfigDeprecationFactory } -// @public -export type ConfigDeprecationLogger = (message: string) => void; +export { ConfigDeprecationLogger } -// @public -export type ConfigDeprecationProvider = (factory: ConfigDeprecationFactory) => ConfigDeprecation[]; +export { ConfigDeprecationProvider } -// @public (undocumented) -export type ConfigPath = string | string[]; +export { ConfigPath } -// @internal (undocumented) -export class ConfigService { - // Warning: (ae-forgotten-export) The symbol "RawConfigurationProvider" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "Env" needs to be exported by the entry point index.d.ts - constructor(rawConfigProvider: RawConfigurationProvider, env: Env, logger: LoggerFactory); - addDeprecationProvider(path: ConfigPath, provider: ConfigDeprecationProvider): void; - atPath(path: ConfigPath): Observable; - // Warning: (ae-forgotten-export) The symbol "Config" needs to be exported by the entry point index.d.ts - getConfig$(): Observable; - // (undocumented) - getUnusedPaths(): Promise; - // (undocumented) - getUsedPaths(): Promise; - // (undocumented) - isEnabledAtPath(path: ConfigPath): Promise; - optionalAtPath(path: ConfigPath): Observable; - setSchema(path: ConfigPath, schema: Type): Promise; - validate(): Promise; - } +export { ConfigService } // @public export interface ContextSetup { @@ -673,15 +659,7 @@ export interface ElasticsearchStatusMeta { warningNodes: NodesVersionCompatibility['warningNodes']; } -// @public (undocumented) -export interface EnvironmentMode { - // (undocumented) - dev: boolean; - // (undocumented) - name: 'development' | 'production'; - // (undocumented) - prod: boolean; -} +export { EnvironmentMode } // @public export interface ErrorHttpResponseOptions { @@ -1419,18 +1397,7 @@ export interface LegacyUiExports { // @public export type LifecycleResponseFactory = typeof lifecycleResponseFactory; -// @public -export interface Logger { - debug(message: string, meta?: LogMeta): void; - error(errorOrMessage: string | Error, meta?: LogMeta): void; - fatal(errorOrMessage: string | Error, meta?: LogMeta): void; - get(...childContextPaths: string[]): Logger; - info(message: string, meta?: LogMeta): void; - // @internal (undocumented) - log(record: LogRecord): void; - trace(message: string, meta?: LogMeta): void; - warn(errorOrMessage: string | Error, meta?: LogMeta): void; -} +export { Logger } // Warning: (ae-forgotten-export) The symbol "loggerSchema" needs to be exported by the entry point index.d.ts // @@ -1445,69 +1412,18 @@ export interface LoggerContextConfigInput { loggers?: LoggerConfigType[]; } -// @public -export interface LoggerFactory { - get(...contextParts: string[]): Logger; -} +export { LoggerFactory } // @public export interface LoggingServiceSetup { configure(config$: Observable): void; } -// @internal -export class LogLevel { - // (undocumented) - static readonly All: LogLevel; - // (undocumented) - static readonly Debug: LogLevel; - // (undocumented) - static readonly Error: LogLevel; - // (undocumented) - static readonly Fatal: LogLevel; - static fromId(level: LogLevelId): LogLevel; - // Warning: (ae-forgotten-export) The symbol "LogLevelId" needs to be exported by the entry point index.d.ts - // - // (undocumented) - readonly id: LogLevelId; - // (undocumented) - static readonly Info: LogLevel; - // (undocumented) - static readonly Off: LogLevel; - supports(level: LogLevel): boolean; - // (undocumented) - static readonly Trace: LogLevel; - // (undocumented) - readonly value: number; - // (undocumented) - static readonly Warn: LogLevel; -} +export { LogLevel } -// @public -export interface LogMeta { - // (undocumented) - [key: string]: any; -} +export { LogMeta } -// @internal -export interface LogRecord { - // (undocumented) - context: string; - // (undocumented) - error?: Error; - // (undocumented) - level: LogLevel; - // (undocumented) - message: string; - // (undocumented) - meta?: { - [name: string]: any; - }; - // (undocumented) - pid: number; - // (undocumented) - timestamp: Date; -} +export { LogRecord } // @public export interface MetricsServiceSetup { @@ -1666,19 +1582,7 @@ export interface OpsServerMetrics { }; } -// @public (undocumented) -export interface PackageInfo { - // (undocumented) - branch: string; - // (undocumented) - buildNum: number; - // (undocumented) - buildSha: string; - // (undocumented) - dist: boolean; - // (undocumented) - version: string; -} +export { PackageInfo } // @public export interface Plugin { @@ -1692,6 +1596,7 @@ export interface Plugin { + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported deprecations?: ConfigDeprecationProvider; exposeToBrowser?: { [P in keyof T]?: boolean; @@ -1729,6 +1634,7 @@ export interface PluginInitializerContext { // @public export interface PluginManifest { + // Warning: (ae-unresolved-link) The @link reference could not be resolved: Reexported declarations are not supported readonly configPath: ConfigPath; // @deprecated readonly extraPublicDirs?: string[]; diff --git a/src/core/server/server.test.mocks.ts b/src/core/server/server.test.mocks.ts index 471e482a20e96..77f2787b75412 100644 --- a/src/core/server/server.test.mocks.ts +++ b/src/core/server/server.test.mocks.ts @@ -41,9 +41,12 @@ jest.mock('./legacy/legacy_service', () => ({ LegacyService: jest.fn(() => mockLegacyService), })); -import { configServiceMock } from './config/config_service.mock'; +const realKbnConfig = jest.requireActual('@kbn/config'); + +import { configServiceMock } from './config/mocks'; export const mockConfigService = configServiceMock.create(); -jest.doMock('./config/config_service', () => ({ +jest.doMock('@kbn/config', () => ({ + ...realKbnConfig, ConfigService: jest.fn(() => mockConfigService), })); diff --git a/src/core/server/server.test.ts b/src/core/server/server.test.ts index 8bf16d9130ef5..3258840d09df2 100644 --- a/src/core/server/server.test.ts +++ b/src/core/server/server.test.ts @@ -35,14 +35,14 @@ import { } from './server.test.mocks'; import { BehaviorSubject } from 'rxjs'; +import { REPO_ROOT } from '@kbn/dev-utils'; +import { rawConfigServiceMock, getEnvOptions } from './config/mocks'; import { Env } from './config'; import { Server } from './server'; -import { getEnvOptions } from './config/__mocks__/env'; import { loggingSystemMock } from './logging/logging_system.mock'; -import { rawConfigServiceMock } from './config/raw_config_service.mock'; -const env = new Env('.', getEnvOptions()); +const env = Env.createDefault(REPO_ROOT, getEnvOptions()); const logger = loggingSystemMock.create(); const rawConfigService = rawConfigServiceMock.create({}); diff --git a/src/core/server/types.ts b/src/core/server/types.ts index 2433aad1a2be5..f8d2f635671fa 100644 --- a/src/core/server/types.ts +++ b/src/core/server/types.ts @@ -22,4 +22,4 @@ export { PluginOpaqueId } from './plugins/types'; export * from './saved_objects/types'; export * from './ui_settings/types'; export * from './legacy/types'; -export { EnvironmentMode, PackageInfo } from './config/types'; +export type { EnvironmentMode, PackageInfo } from '@kbn/config'; diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index c65a9dee0a234..3bb1b202f811c 100644 --- a/src/core/test_helpers/kbn_server.ts +++ b/src/core/test_helpers/kbn_server.ts @@ -17,7 +17,7 @@ * under the License. */ import { Client } from 'elasticsearch'; -import { ToolingLog } from '@kbn/dev-utils'; +import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils'; import { createLegacyEsTestCluster, DEFAULT_SUPERUSER_PASS, @@ -66,7 +66,7 @@ export function createRootWithSettings( settings: Record, cliArgs: Partial = {} ) { - const env = Env.createDefault({ + const env = Env.createDefault(REPO_ROOT, { configs: [], cliArgs: { dev: false, diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 597dc5db32c1f..c0a165d546701 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -17,6 +17,7 @@ import { CoreSetup as CoreSetup_2 } from 'kibana/public'; import { CoreStart } from 'kibana/public'; import { CoreStart as CoreStart_2 } from 'src/core/public'; import { Ensure } from '@kbn/utility-types'; +import { EnvironmentMode } from '@kbn/config'; import { ErrorToastOptions } from 'src/core/public/notifications'; import { EuiBreadcrumb } from '@elastic/eui'; import { EuiButtonEmptyProps } from '@elastic/eui'; @@ -38,12 +39,15 @@ import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import { KibanaConfigType } from 'src/core/server/kibana_config'; import { Location } from 'history'; import { LocationDescriptorObject } from 'history'; +import { Logger } from '@kbn/logging'; +import { LogMeta } from '@kbn/logging'; import { MaybePromise } from '@kbn/utility-types'; import { METRIC_TYPE } from '@kbn/analytics'; import { Moment } from 'moment'; import moment from 'moment'; import { NameList } from 'elasticsearch'; import { Observable } from 'rxjs'; +import { PackageInfo } from '@kbn/config'; import { Path } from 'history'; import { Plugin as Plugin_2 } from 'src/core/public'; import { PluginInitializerContext as PluginInitializerContext_2 } from 'src/core/public'; diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index 5fa9821ef7ea5..bc626b62b6409 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -32,6 +32,7 @@ import { ClusterPutSettingsParams } from 'elasticsearch'; import { ClusterRerouteParams } from 'elasticsearch'; import { ClusterStateParams } from 'elasticsearch'; import { ClusterStatsParams } from 'elasticsearch'; +import { ConfigDeprecationProvider } from '@kbn/config'; import { CoreSetup } from 'src/core/server'; import { CoreSetup as CoreSetup_2 } from 'kibana/server'; import { CoreStart } from 'src/core/server'; @@ -43,6 +44,7 @@ import { DeleteScriptParams } from 'elasticsearch'; import { DeleteTemplateParams } from 'elasticsearch'; import { Duration } from 'moment'; import { Ensure } from '@kbn/utility-types'; +import { EnvironmentMode } from '@kbn/config'; import { ErrorToastOptions } from 'src/core/public/notifications'; import { ExistsParams } from 'elasticsearch'; import { ExplainParams } from 'elasticsearch'; @@ -104,7 +106,10 @@ import { KibanaClient } from '@elastic/elasticsearch/api/kibana'; import { KibanaConfigType as KibanaConfigType_2 } from 'src/core/server/kibana_config'; import { KibanaRequest } from 'kibana/server'; import { LegacyAPICaller as LegacyAPICaller_2 } from 'kibana/server'; +import { Logger } from '@kbn/logging'; import { Logger as Logger_2 } from 'kibana/server'; +import { LoggerFactory } from '@kbn/logging'; +import { LogMeta } from '@kbn/logging'; import { MGetParams } from 'elasticsearch'; import { MGetResponse } from 'elasticsearch'; import { Moment } from 'moment'; @@ -117,6 +122,7 @@ import { NodesHotThreadsParams } from 'elasticsearch'; import { NodesInfoParams } from 'elasticsearch'; import { NodesStatsParams } from 'elasticsearch'; import { Observable } from 'rxjs'; +import { PackageInfo } from '@kbn/config'; import { PathConfigType } from '@kbn/utils'; import { PingParams } from 'elasticsearch'; import { Plugin as Plugin_2 } from 'src/core/server'; diff --git a/yarn.lock b/yarn.lock index 92072225f7145..761654c68ec07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5735,6 +5735,11 @@ ansi-escapes@^1.0.0, ansi-escapes@^1.1.0: resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" integrity sha1-06ioOzGapneTZisT52HHkRQiMG4= +ansi-escapes@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" + integrity sha1-W65SvkJIeN2Xg+iRDj/Cki6DyBs= + ansi-escapes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" @@ -8075,6 +8080,15 @@ camelcase-keys@^2.0.0: camelcase "^2.0.0" map-obj "^1.0.0" +camelcase-keys@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" + integrity sha1-oqpfsa9oh1glnDLBQUJteJI7m3c= + dependencies: + camelcase "^4.1.0" + map-obj "^2.0.0" + quick-lru "^1.0.0" + camelcase-keys@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" @@ -8099,7 +8113,7 @@ camelcase@^3.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" integrity sha1-MvxLn82vhF/N9+c7uXysImHwqwo= -camelcase@^4.0.0: +camelcase@^4.0.0, camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= @@ -10382,7 +10396,7 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= -decamelize-keys@^1.1.0: +decamelize-keys@^1.0.0, decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" integrity sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk= @@ -11902,6 +11916,17 @@ eslint-config-prettier@^6.11.0: dependencies: get-stdin "^6.0.0" +eslint-formatter-pretty@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-1.3.0.tgz#985d9e41c1f8475f4a090c5dbd2dfcf2821d607e" + integrity sha512-5DY64Y1rYCm7cfFDHEGUn54bvCnK+wSUVF07N8oXeqUJFSd+gnYOTXbzelQ1HurESluY6gnEQPmXOIkB4Wa+gA== + dependencies: + ansi-escapes "^2.0.0" + chalk "^2.1.0" + log-symbols "^2.0.0" + plur "^2.1.2" + string-width "^2.0.0" + eslint-formatter-pretty@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-4.0.0.tgz#dc15f3bf4fb51b7ba5fbedb77f57ba8841140ce2" @@ -14193,7 +14218,7 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" -globby@^9.2.0: +globby@^9.1.0, globby@^9.2.0: version "9.2.0" resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d" integrity sha512-ollPHROa5mcxDEkwg6bPt3QbEf4pDQSNtd6JPL1YvOvAo/7/0VAm9TccUeoTmarjPw4pfUthSCqcyfNB1I3ZSg== @@ -16223,6 +16248,11 @@ iron@5.x.x: cryptiles "4.x.x" hoek "5.x.x" +irregular-plurals@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-1.4.0.tgz#2ca9b033651111855412f16be5d77c62a458a766" + integrity sha1-LKmwM2UREYVUEvFr5dd8YqRYp2Y= + irregular-plurals@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-3.2.0.tgz#b19c490a0723798db51b235d7e39add44dab0822" @@ -19082,7 +19112,7 @@ log-ok@^0.1.1: ansi-green "^0.1.1" success-symbol "^0.1.0" -log-symbols@2.2.0, log-symbols@^2.1.0, log-symbols@^2.2.0: +log-symbols@2.2.0, log-symbols@^2.0.0, log-symbols@^2.1.0, log-symbols@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== @@ -19373,6 +19403,11 @@ map-obj@^1.0.0, map-obj@^1.0.1: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= +map-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" + integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk= + map-obj@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5" @@ -19676,6 +19711,21 @@ meow@^3.0.0, meow@^3.3.0, meow@^3.7.0: redent "^1.0.0" trim-newlines "^1.0.0" +meow@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" + integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== + dependencies: + camelcase-keys "^4.0.0" + decamelize-keys "^1.0.0" + loud-rejection "^1.0.0" + minimist-options "^3.0.1" + normalize-package-data "^2.3.4" + read-pkg-up "^3.0.0" + redent "^2.0.0" + trim-newlines "^2.0.0" + yargs-parser "^10.0.0" + meow@^6.1.1: version "6.1.1" resolved "https://registry.yarnpkg.com/meow/-/meow-6.1.1.tgz#1ad64c4b76b2a24dfb2f635fddcadf320d251467" @@ -19946,6 +19996,14 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" +minimist-options@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" + integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + minimist-options@^4.0.2: version "4.1.0" resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619" @@ -22432,6 +22490,13 @@ plugin-error@^1.0.1: arr-union "^3.1.0" extend-shallow "^3.0.2" +plur@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/plur/-/plur-2.1.2.tgz#7482452c1a0f508e3e344eaec312c91c29dc655a" + integrity sha1-dIJFLBoPUI4+NE6uwxLJHCncZVo= + dependencies: + irregular-plurals "^1.0.0" + plur@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/plur/-/plur-4.0.0.tgz#729aedb08f452645fe8c58ef115bf16b0a73ef84" @@ -23137,6 +23202,11 @@ queue@6.0.1: dependencies: inherits "~2.0.3" +quick-lru@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" + integrity sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g= + quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -24158,6 +24228,14 @@ read-pkg-up@^2.0.0: find-up "^2.0.0" read-pkg "^2.0.0" +read-pkg-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" + integrity sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= + dependencies: + find-up "^2.0.0" + read-pkg "^3.0.0" + read-pkg-up@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-4.0.0.tgz#1b221c6088ba7799601c808f91161c66e58f8978" @@ -24387,6 +24465,14 @@ redent@^1.0.0: indent-string "^2.1.0" strip-indent "^1.0.1" +redent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" + integrity sha1-wbIAe0LVfrE4kHmzyDM2OdXhzKo= + dependencies: + indent-string "^3.0.0" + strip-indent "^2.0.0" + redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -27013,6 +27099,11 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g= + strip-indent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" @@ -28107,6 +28198,11 @@ trim-newlines@^1.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= +trim-newlines@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" + integrity sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA= + trim-newlines@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30" @@ -28213,6 +28309,19 @@ tsd@^0.13.1: read-pkg-up "^7.0.0" update-notifier "^4.1.0" +tsd@^0.7.4: + version "0.7.4" + resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.7.4.tgz#d9aba567f1394641821a6800dcee60746c87bd03" + integrity sha512-cqr1s2GHtVkU3L/4BXDaeJOjFEuZ7iOVC+hwmyx4G7Eo26mSXCFNnwFm4EasK/MW2HdY3AQWux+AjYzDYLzZow== + dependencies: + eslint-formatter-pretty "^1.3.0" + globby "^9.1.0" + meow "^5.0.0" + path-exists "^3.0.0" + read-pkg-up "^4.0.0" + typescript "^3.0.1" + update-notifier "^2.5.0" + tslib@^1, tslib@^1.0.0, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.13.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" @@ -28379,7 +28488,7 @@ typescript-tuple@^2.2.1: dependencies: typescript-compare "^0.0.2" -typescript@4.0.2, typescript@^3.0.3, typescript@^3.2.2, typescript@^3.3.3333, typescript@^3.4.5, typescript@~3.7.2: +typescript@4.0.2, typescript@^3.0.1, typescript@^3.0.3, typescript@^3.2.2, typescript@^3.3.3333, typescript@^3.4.5, typescript@~3.7.2: version "4.0.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2" integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== @@ -30604,6 +30713,13 @@ yargs-parser@5.0.0-security.0: camelcase "^3.0.0" object.assign "^4.1.0" +yargs-parser@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" + integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== + dependencies: + camelcase "^4.1.0" + yargs-parser@^18.1.1, yargs-parser@^18.1.2, yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"