mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Migrate server-side uiSettings
domain to packages (#140468)
* create empty packages * move types to public package * move implementation to packages * move mocks to package * start adapting usages * adapt more usages * update readmes * [CI] Auto-commit changed files from 'node scripts/generate codeowners' * fix test usages Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
59ea09f9ee
commit
15270a5bc9
101 changed files with 787 additions and 164 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -785,6 +785,9 @@ packages/core/ui-settings/core-ui-settings-browser @elastic/kibana-core
|
|||
packages/core/ui-settings/core-ui-settings-browser-internal @elastic/kibana-core
|
||||
packages/core/ui-settings/core-ui-settings-browser-mocks @elastic/kibana-core
|
||||
packages/core/ui-settings/core-ui-settings-common @elastic/kibana-core
|
||||
packages/core/ui-settings/core-ui-settings-server @elastic/kibana-core
|
||||
packages/core/ui-settings/core-ui-settings-server-internal @elastic/kibana-core
|
||||
packages/core/ui-settings/core-ui-settings-server-mocks @elastic/kibana-core
|
||||
packages/core/usage-data/core-usage-data-base-server-internal @elastic/kibana-core
|
||||
packages/core/usage-data/core-usage-data-server @elastic/kibana-core
|
||||
packages/core/usage-data/core-usage-data-server-internal @elastic/kibana-core
|
||||
|
|
|
@ -285,6 +285,9 @@
|
|||
"@kbn/core-ui-settings-browser-internal": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-internal",
|
||||
"@kbn/core-ui-settings-browser-mocks": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-mocks",
|
||||
"@kbn/core-ui-settings-common": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-common",
|
||||
"@kbn/core-ui-settings-server": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-server",
|
||||
"@kbn/core-ui-settings-server-internal": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-server-internal",
|
||||
"@kbn/core-ui-settings-server-mocks": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-server-mocks",
|
||||
"@kbn/core-usage-data-base-server-internal": "link:bazel-bin/packages/core/usage-data/core-usage-data-base-server-internal",
|
||||
"@kbn/core-usage-data-server": "link:bazel-bin/packages/core/usage-data/core-usage-data-server",
|
||||
"@kbn/core-usage-data-server-internal": "link:bazel-bin/packages/core/usage-data/core-usage-data-server-internal",
|
||||
|
@ -980,6 +983,9 @@
|
|||
"@types/kbn__core-ui-settings-browser-internal": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-internal/npm_module_types",
|
||||
"@types/kbn__core-ui-settings-browser-mocks": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-browser-mocks/npm_module_types",
|
||||
"@types/kbn__core-ui-settings-common": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-common/npm_module_types",
|
||||
"@types/kbn__core-ui-settings-server": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-server/npm_module_types",
|
||||
"@types/kbn__core-ui-settings-server-internal": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-server-internal/npm_module_types",
|
||||
"@types/kbn__core-ui-settings-server-mocks": "link:bazel-bin/packages/core/ui-settings/core-ui-settings-server-mocks/npm_module_types",
|
||||
"@types/kbn__core-usage-data-base-server-internal": "link:bazel-bin/packages/core/usage-data/core-usage-data-base-server-internal/npm_module_types",
|
||||
"@types/kbn__core-usage-data-server": "link:bazel-bin/packages/core/usage-data/core-usage-data-server/npm_module_types",
|
||||
"@types/kbn__core-usage-data-server-internal": "link:bazel-bin/packages/core/usage-data/core-usage-data-server-internal/npm_module_types",
|
||||
|
|
|
@ -151,6 +151,9 @@ filegroup(
|
|||
"//packages/core/ui-settings/core-ui-settings-browser-internal:build",
|
||||
"//packages/core/ui-settings/core-ui-settings-browser-mocks:build",
|
||||
"//packages/core/ui-settings/core-ui-settings-common:build",
|
||||
"//packages/core/ui-settings/core-ui-settings-server:build",
|
||||
"//packages/core/ui-settings/core-ui-settings-server-internal:build",
|
||||
"//packages/core/ui-settings/core-ui-settings-server-mocks:build",
|
||||
"//packages/core/usage-data/core-usage-data-base-server-internal:build",
|
||||
"//packages/core/usage-data/core-usage-data-server:build",
|
||||
"//packages/core/usage-data/core-usage-data-server-internal:build",
|
||||
|
@ -461,6 +464,9 @@ filegroup(
|
|||
"//packages/core/ui-settings/core-ui-settings-browser-internal:build_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-browser-mocks:build_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-common:build_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-server:build_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-server-internal:build_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-server-mocks:build_types",
|
||||
"//packages/core/usage-data/core-usage-data-base-server-internal:build_types",
|
||||
"//packages/core/usage-data/core-usage-data-server:build_types",
|
||||
"//packages/core/usage-data/core-usage-data-server-internal:build_types",
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-ui-settings-server-internal"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-ui-settings-server-internal"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.config.js",
|
||||
"**/*.mock.*",
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
"**/__snapshots__/**",
|
||||
"**/integration_tests/**",
|
||||
"**/mocks/**",
|
||||
"**/scripts/**",
|
||||
"**/storybook/**",
|
||||
"**/test_fixtures/**",
|
||||
"**/test_helpers/**",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
"@npm//lodash",
|
||||
"@npm//semver",
|
||||
"@npm//moment-timezone",
|
||||
"//packages/kbn-std",
|
||||
"//packages/kbn-i18n",
|
||||
"//packages/kbn-config-schema",
|
||||
"//packages/core/saved-objects/core-saved-objects-utils-server",
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"@npm//@types/semver",
|
||||
"@npm//@types/moment-timezone",
|
||||
"@npm//lodash",
|
||||
"//packages/kbn-ui-shared-deps-npm:npm_module_types",
|
||||
"//packages/kbn-logging:npm_module_types",
|
||||
"//packages/kbn-std:npm_module_types",
|
||||
"//packages/kbn-i18n:npm_module_types",
|
||||
"//packages/kbn-config-schema:npm_module_types",
|
||||
"//packages/core/base/core-base-server-internal:npm_module_types",
|
||||
"//packages/core/http/core-http-server:npm_module_types",
|
||||
"//packages/core/http/core-http-server-internal:npm_module_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-api-server:npm_module_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-server:npm_module_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-server-internal:npm_module_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-utils-server:npm_module_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-common:npm_module_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-server:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-ui-settings-server-internal
|
||||
|
||||
This package contains the internal types and implementation for Core's server-side uiSettings service.
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export {
|
||||
uiSettingsConfig,
|
||||
UiSettingsClient,
|
||||
UiSettingsService,
|
||||
CoreUiSettingsRouteHandlerContext,
|
||||
} from './src';
|
||||
export type {
|
||||
InternalUiSettingsServicePreboot,
|
||||
InternalUiSettingsServiceSetup,
|
||||
InternalUiSettingsServiceStart,
|
||||
UiSettingsServiceOptions,
|
||||
} from './src';
|
||||
|
||||
// only exported for integration tests
|
||||
export { createOrUpgradeSavedConfig } from './src/create_or_upgrade_saved_config';
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/ui-settings/core-ui-settings-server-internal'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/core-ui-settings-server-internal",
|
||||
"owner": "@elastic/kibana-core",
|
||||
"runtimeDeps": [],
|
||||
"typeDeps": [],
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@kbn/core-ui-settings-server-internal",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"author": "Kibana Core",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -7,14 +7,13 @@
|
|||
*/
|
||||
|
||||
import { omit } from 'lodash';
|
||||
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import {
|
||||
IUiSettingsClient,
|
||||
import type {
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UserProvidedValues,
|
||||
} from './types';
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
|
||||
export interface BaseUiSettingsDefaultsClientOptions {
|
||||
overrides?: Record<string, any>;
|
||||
|
@ -26,9 +25,9 @@ export interface BaseUiSettingsDefaultsClientOptions {
|
|||
* Base implementation of the {@link IUiSettingsClient}.
|
||||
*/
|
||||
export abstract class BaseUiSettingsClient implements IUiSettingsClient {
|
||||
private readonly defaults: NonNullable<BaseUiSettingsDefaultsClientOptions['defaults']>;
|
||||
private readonly defaults: Record<string, UiSettingsParams>;
|
||||
private readonly defaultValues: Record<string, unknown>;
|
||||
protected readonly overrides: NonNullable<BaseUiSettingsDefaultsClientOptions['overrides']>;
|
||||
protected readonly overrides: Record<string, any>;
|
||||
protected readonly log: Logger;
|
||||
|
||||
protected constructor(options: BaseUiSettingsDefaultsClientOptions) {
|
||||
|
@ -86,8 +85,12 @@ export abstract class BaseUiSettingsClient implements IUiSettingsClient {
|
|||
}
|
||||
|
||||
abstract getUserProvided<T = any>(): Promise<Record<string, UserProvidedValues<T>>>;
|
||||
|
||||
abstract setMany(changes: Record<string, any>): Promise<void>;
|
||||
|
||||
abstract set(key: string, value: any): Promise<void>;
|
||||
|
||||
abstract remove(key: string): Promise<void>;
|
||||
|
||||
abstract removeMany(keys: string[]): Promise<void>;
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
const oneSec = 1000;
|
||||
const defMaxAge = 5 * oneSec;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
|
@ -6,23 +6,13 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export type { UiSettingsClient, UiSettingsServiceOptions } from './ui_settings_client';
|
||||
|
||||
export { config } from './ui_settings_config';
|
||||
export { uiSettingsConfig } from './ui_settings_config';
|
||||
export { UiSettingsService } from './ui_settings_service';
|
||||
export { CoreUiSettingsRouteHandlerContext } from './ui_settings_route_handler_context';
|
||||
export type { UiSettingsRequestHandlerContext } from './ui_settings_route_handler_context';
|
||||
|
||||
export { UiSettingsClient } from './ui_settings_client';
|
||||
export type { UiSettingsServiceOptions } from './ui_settings_client';
|
||||
export type {
|
||||
UiSettingsServiceSetup,
|
||||
UiSettingsServiceStart,
|
||||
IUiSettingsClient,
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
InternalUiSettingsServicePreboot,
|
||||
InternalUiSettingsServiceSetup,
|
||||
InternalUiSettingsServiceStart,
|
||||
UiSettingsType,
|
||||
UserProvidedValues,
|
||||
DeprecationSettings,
|
||||
} from './types';
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { IRouter, RequestHandlerContextBase } from '@kbn/core-http-server';
|
||||
import type { UiSettingsRequestHandlerContext } from './ui_settings_route_handler_context';
|
||||
import type { UiSettingsRequestHandlerContext } from '@kbn/core-ui-settings-server';
|
||||
|
||||
/**
|
||||
* Request handler context used by core's uiSetting routes.
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectUnsanitizedDoc } from '../..';
|
||||
import type { SavedObjectUnsanitizedDoc } from '@kbn/core-saved-objects-server';
|
||||
import { migrations } from './migrations';
|
||||
|
||||
describe('ui_settings 7.9.0 migrations', () => {
|
|
@ -6,7 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectUnsanitizedDoc, SavedObjectSanitizedDoc } from '../..';
|
||||
import type {
|
||||
SavedObjectUnsanitizedDoc,
|
||||
SavedObjectSanitizedDoc,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
|
||||
export const migrations = {
|
||||
'7.9.0': (doc: SavedObjectUnsanitizedDoc<any>): SavedObjectSanitizedDoc<any> => ({
|
|
@ -6,9 +6,9 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { savedObjectsClientMock } from '../../mocks';
|
||||
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks';
|
||||
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-utils-server';
|
||||
import { SavedObject } from '../../types';
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type { UpgradeableConfigAttributes } from '../create_or_upgrade_saved_config';
|
||||
import { transformDefaultIndex } from './transforms';
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-utils-server';
|
||||
import type { SavedObjectsClientContract } from '../../types';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { UpgradeableConfigAttributes } from '../create_or_upgrade_saved_config';
|
||||
|
||||
/**
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getAccessibilitySettings } from './accessibility';
|
||||
|
||||
describe('accessibility settings', () => {
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getAccessibilitySettings = (): Record<string, UiSettingsParams> => {
|
||||
return {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getAnnouncementsSettings } from './announcements';
|
||||
|
||||
describe('announcements settings', () => {
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getAnnouncementsSettings = (): Record<string, UiSettingsParams> => {
|
||||
return {
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import moment from 'moment-timezone';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getDateFormatSettings } from './date_formats';
|
||||
|
||||
describe('accessibility settings', () => {
|
|
@ -9,7 +9,7 @@
|
|||
import moment from 'moment-timezone';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getDateFormatSettings = (): Record<string, UiSettingsParams> => {
|
||||
const weekdays = moment.weekdays().slice();
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getAccessibilitySettings } from './accessibility';
|
||||
import { getDateFormatSettings } from './date_formats';
|
||||
import { getMiscUiSettings } from './misc';
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { UiSettingsParams } from '../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getMiscUiSettings = (): Record<string, UiSettingsParams> => {
|
||||
return {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getNavigationSettings } from './navigation';
|
||||
|
||||
describe('navigation settings', () => {
|
|
@ -9,7 +9,7 @@
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { isRelativeUrl } from '@kbn/std';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getNavigationSettings = (): Record<string, UiSettingsParams> => {
|
||||
return {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getNotificationsSettings } from './notifications';
|
||||
|
||||
describe('notifications settings', () => {
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getNotificationsSettings = (): Record<string, UiSettingsParams> => {
|
||||
return {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getStateSettings } from './state';
|
||||
|
||||
describe('state settings', () => {
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getStateSettings = (): Record<string, UiSettingsParams> => {
|
||||
return {
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { getThemeSettings } from './theme';
|
||||
|
||||
describe('theme settings', () => {
|
|
@ -9,7 +9,7 @@
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { ThemeVersion } from '@kbn/ui-shared-deps-npm';
|
||||
import { UiSettingsParams } from '../../../types';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
function parseThemeTags() {
|
||||
if (!process.env.KBN_OPTIMIZER_THEMES || process.env.KBN_OPTIMIZER_THEMES === '*') {
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type {
|
||||
IUiSettingsClient,
|
||||
UiSettingsServiceSetup,
|
||||
UiSettingsServiceStart,
|
||||
} from '@kbn/core-ui-settings-server';
|
||||
|
||||
/** @internal */
|
||||
export interface InternalUiSettingsServicePreboot {
|
||||
/**
|
||||
* Creates a {@link IUiSettingsClient} that returns default values for the Core uiSettings.
|
||||
*/
|
||||
createDefaultsClient(): IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type InternalUiSettingsServiceSetup = UiSettingsServiceSetup;
|
||||
|
||||
/** @internal */
|
||||
export type InternalUiSettingsServiceStart = UiSettingsServiceStart;
|
|
@ -9,8 +9,8 @@
|
|||
import type { Logger } from '@kbn/logging';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-utils-server';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { createOrUpgradeSavedConfig } from './create_or_upgrade_saved_config';
|
||||
import { UiSettingsParams } from './types';
|
||||
import { CannotOverrideError } from './ui_settings_errors';
|
||||
import { Cache } from './cache';
|
||||
import { BaseUiSettingsClient } from './base_ui_settings_client';
|
|
@ -21,7 +21,7 @@ const configSchema = schema.object({
|
|||
|
||||
export type UiSettingsConfigType = TypeOf<typeof configSchema>;
|
||||
|
||||
export const config: ServiceConfigDescriptor<UiSettingsConfigType> = {
|
||||
export const uiSettingsConfig: ServiceConfigDescriptor<UiSettingsConfigType> = {
|
||||
path: 'uiSettings',
|
||||
schema: configSchema,
|
||||
deprecations,
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import { UiSettingsParams, UserProvidedValues } from './types';
|
||||
import type { UiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
import { BaseUiSettingsClient } from './base_ui_settings_client';
|
||||
|
||||
export interface UiSettingsDefaultsClientOptions {
|
|
@ -7,15 +7,11 @@
|
|||
*/
|
||||
|
||||
import type { CoreSavedObjectsRouteHandlerContext } from '@kbn/core-saved-objects-server-internal';
|
||||
import type { IUiSettingsClient, InternalUiSettingsServiceStart } from './types';
|
||||
|
||||
/**
|
||||
* Core's `uiSettings` request handler context.
|
||||
* @public
|
||||
*/
|
||||
export interface UiSettingsRequestHandlerContext {
|
||||
client: IUiSettingsClient;
|
||||
}
|
||||
import type {
|
||||
UiSettingsRequestHandlerContext,
|
||||
IUiSettingsClient,
|
||||
} from '@kbn/core-ui-settings-server';
|
||||
import type { InternalUiSettingsServiceStart } from './types';
|
||||
|
||||
/**
|
||||
* The {@link UiSettingsRequestHandlerContext} implementation.
|
|
@ -13,20 +13,20 @@ import type { Logger } from '@kbn/logging';
|
|||
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
|
||||
import type { InternalHttpServiceSetup } from '@kbn/core-http-server-internal';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { InternalSavedObjectsServiceSetup } from '@kbn/core-saved-objects-server-internal';
|
||||
import { UiSettingsConfigType, config as uiConfigDefinition } from './ui_settings_config';
|
||||
import type { InternalSavedObjectsServiceSetup } from '@kbn/core-saved-objects-server-internal';
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { UiSettingsConfigType, uiSettingsConfig as uiConfigDefinition } from './ui_settings_config';
|
||||
import { UiSettingsClient } from './ui_settings_client';
|
||||
import {
|
||||
import type {
|
||||
InternalUiSettingsServicePreboot,
|
||||
InternalUiSettingsServiceSetup,
|
||||
InternalUiSettingsServiceStart,
|
||||
UiSettingsParams,
|
||||
} from './types';
|
||||
import type { InternalUiSettingsRequestHandlerContext } from './internal_types';
|
||||
import { uiSettingsType } from './saved_objects';
|
||||
import { registerRoutes } from './routes';
|
||||
import { getCoreSettings } from './settings';
|
||||
import { UiSettingsDefaultsClient } from './ui_settings_defaults_client';
|
||||
import type { InternalUiSettingsRequestHandlerContext } from './internal_types';
|
||||
|
||||
export interface SetupDeps {
|
||||
http: InternalHttpServiceSetup;
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-ui-settings-server-mocks"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-ui-settings-server-mocks"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.config.js",
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
"**/__snapshots__/**",
|
||||
"**/integration_tests/**",
|
||||
"**/mocks/**",
|
||||
"**/scripts/**",
|
||||
"**/storybook/**",
|
||||
"**/test_fixtures/**",
|
||||
"**/test_helpers/**",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"//packages/kbn-utility-types:npm_module_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-server:npm_module_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-server-internal:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
# @kbn/core-ui-settings-server-mocks
|
||||
|
||||
This package contains the mocks for the server-side uiSettings service:
|
||||
- `uiSettingsServiceMock`
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export { uiSettingsServiceMock } from './src';
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/ui-settings/core-ui-settings-server-mocks'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/core-ui-settings-server-mocks",
|
||||
"owner": "@elastic/kibana-core",
|
||||
"runtimeDeps": [],
|
||||
"typeDeps": [],
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@kbn/core-ui-settings-server-mocks",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"author": "Kibana Core",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export { uiSettingsServiceMock } from './ui_settings_service.mock';
|
|
@ -7,13 +7,13 @@
|
|||
*/
|
||||
|
||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import {
|
||||
IUiSettingsClient,
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
import type {
|
||||
InternalUiSettingsServiceSetup,
|
||||
InternalUiSettingsServiceStart,
|
||||
InternalUiSettingsServicePreboot,
|
||||
} from './types';
|
||||
import type { UiSettingsService } from './ui_settings_service';
|
||||
UiSettingsService,
|
||||
} from '@kbn/core-ui-settings-server-internal';
|
||||
|
||||
const createClientMock = () => {
|
||||
const mocked: jest.Mocked<IUiSettingsClient> = {
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
]
|
||||
}
|
107
packages/core/ui-settings/core-ui-settings-server/BUILD.bazel
Normal file
107
packages/core/ui-settings/core-ui-settings-server/BUILD.bazel
Normal file
|
@ -0,0 +1,107 @@
|
|||
load("@npm//@bazel/typescript:index.bzl", "ts_config")
|
||||
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
||||
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")
|
||||
|
||||
PKG_DIRNAME = "core-ui-settings-server"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-ui-settings-server"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.config.js",
|
||||
"**/*.mock.*",
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
"**/__snapshots__/**",
|
||||
"**/integration_tests/**",
|
||||
"**/mocks/**",
|
||||
"**/scripts/**",
|
||||
"**/storybook/**",
|
||||
"**/test_fixtures/**",
|
||||
"**/test_helpers/**",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"//packages/core/saved-objects/core-saved-objects-api-server:npm_module_types",
|
||||
"//packages/core/ui-settings/core-ui-settings-common:npm_module_types",
|
||||
]
|
||||
|
||||
jsts_transpiler(
|
||||
name = "target_node",
|
||||
srcs = SRCS,
|
||||
build_pkg_name = package_name(),
|
||||
)
|
||||
|
||||
ts_config(
|
||||
name = "tsconfig",
|
||||
src = "tsconfig.json",
|
||||
deps = [
|
||||
"//:tsconfig.base.json",
|
||||
"//:tsconfig.bazel.json",
|
||||
],
|
||||
)
|
||||
|
||||
ts_project(
|
||||
name = "tsc_types",
|
||||
args = ['--pretty'],
|
||||
srcs = SRCS,
|
||||
deps = TYPES_DEPS,
|
||||
declaration = True,
|
||||
declaration_map = True,
|
||||
emit_declaration_only = True,
|
||||
out_dir = "target_types",
|
||||
tsconfig = ":tsconfig",
|
||||
)
|
||||
|
||||
js_library(
|
||||
name = PKG_DIRNAME,
|
||||
srcs = NPM_MODULE_EXTRA_FILES,
|
||||
deps = RUNTIME_DEPS + [":target_node"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm(
|
||||
name = "npm_module",
|
||||
deps = [":" + PKG_DIRNAME],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build",
|
||||
srcs = [":npm_module"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_npm_types(
|
||||
name = "npm_module_types",
|
||||
srcs = SRCS,
|
||||
deps = [":tsc_types"],
|
||||
package_name = PKG_REQUIRE_NAME,
|
||||
tsconfig = ":tsconfig",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "build_types",
|
||||
srcs = [":npm_module_types"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
# @kbn/core-ui-settings-server
|
||||
|
||||
This package contains the public types for the server-side ui-settings service.
|
14
packages/core/ui-settings/core-ui-settings-server/index.ts
Normal file
14
packages/core/ui-settings/core-ui-settings-server/index.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export type {
|
||||
IUiSettingsClient,
|
||||
UiSettingsServiceSetup,
|
||||
UiSettingsServiceStart,
|
||||
UiSettingsRequestHandlerContext,
|
||||
} from './src';
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test/jest_node',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/packages/core/ui-settings/core-ui-settings-server'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/core-ui-settings-server",
|
||||
"owner": "@elastic/kibana-core",
|
||||
"runtimeDeps": [],
|
||||
"typeDeps": [],
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@kbn/core-ui-settings-server",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"author": "Kibana Core",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { IUiSettingsClient } from './ui_settings_client';
|
||||
|
||||
/** @public */
|
||||
export interface UiSettingsServiceSetup {
|
||||
/**
|
||||
* Sets settings with default values for the uiSettings.
|
||||
* @param settings
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* setup(core: CoreSetup){
|
||||
* core.uiSettings.register([{
|
||||
* foo: {
|
||||
* name: i18n.translate('my foo settings'),
|
||||
* value: true,
|
||||
* description: 'add some awesomeness',
|
||||
* },
|
||||
* }]);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
register(settings: Record<string, UiSettingsParams>): void;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface UiSettingsServiceStart {
|
||||
/**
|
||||
* Creates a {@link IUiSettingsClient} with provided *scoped* saved objects client.
|
||||
*
|
||||
* This should only be used in the specific case where the client needs to be accessed
|
||||
* from outside of the scope of a {@link RequestHandler}.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* start(core: CoreStart) {
|
||||
* const soClient = core.savedObjects.getScopedClient(arbitraryRequest);
|
||||
* const uiSettingsClient = core.uiSettings.asScopedToClient(soClient);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
asScopedToClient(savedObjectsClient: SavedObjectsClientContract): IUiSettingsClient;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export type { IUiSettingsClient } from './ui_settings_client';
|
||||
export type { UiSettingsServiceSetup, UiSettingsServiceStart } from './contracts';
|
||||
export type { UiSettingsRequestHandlerContext } from './request_handler_context';
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { IUiSettingsClient } from './ui_settings_client';
|
||||
|
||||
/**
|
||||
* Core's `uiSettings` request handler context.
|
||||
* @public
|
||||
*/
|
||||
export interface UiSettingsRequestHandlerContext {
|
||||
client: IUiSettingsClient;
|
||||
}
|
|
@ -6,20 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import {
|
||||
UiSettingsParams,
|
||||
UserProvidedValues,
|
||||
PublicUiSettingsParams,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
|
||||
export type {
|
||||
UiSettingsParams,
|
||||
DeprecationSettings,
|
||||
PublicUiSettingsParams,
|
||||
UiSettingsType,
|
||||
UserProvidedValues,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
import type { UserProvidedValues, PublicUiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
/**
|
||||
* Server-side client that provides access to the advanced settings stored in elasticsearch.
|
||||
|
@ -71,64 +58,3 @@ export interface IUiSettingsClient {
|
|||
*/
|
||||
isSensitive: (key: string) => boolean;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface InternalUiSettingsServicePreboot {
|
||||
/**
|
||||
* Creates a {@link IUiSettingsClient} that returns default values for the Core uiSettings.
|
||||
*/
|
||||
createDefaultsClient(): IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface InternalUiSettingsServiceSetup {
|
||||
/**
|
||||
* Sets settings with default values for the uiSettings.
|
||||
* @param settings
|
||||
*/
|
||||
register(settings: Record<string, UiSettingsParams>): void;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface UiSettingsServiceSetup {
|
||||
/**
|
||||
* Sets settings with default values for the uiSettings.
|
||||
* @param settings
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* setup(core: CoreSetup){
|
||||
* core.uiSettings.register([{
|
||||
* foo: {
|
||||
* name: i18n.translate('my foo settings'),
|
||||
* value: true,
|
||||
* description: 'add some awesomeness',
|
||||
* },
|
||||
* }]);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
register(settings: Record<string, UiSettingsParams>): void;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface UiSettingsServiceStart {
|
||||
/**
|
||||
* Creates a {@link IUiSettingsClient} with provided *scoped* saved objects client.
|
||||
*
|
||||
* This should only be used in the specific case where the client needs to be accessed
|
||||
* from outside of the scope of a {@link RequestHandler}.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* start(core: CoreStart) {
|
||||
* const soClient = core.savedObjects.getScopedClient(arbitraryRequest);
|
||||
* const uiSettingsClient = core.uiSettings.asScopedToClient(soClient);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
asScopedToClient(savedObjectsClient: SavedObjectsClientContract): IUiSettingsClient;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type InternalUiSettingsServiceStart = UiSettingsServiceStart;
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts",
|
||||
]
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { IRouter, RequestHandlerContextBase } from '@kbn/core-http-server';
|
||||
import type { UiSettingsRequestHandlerContext } from '../ui_settings';
|
||||
import type { UiSettingsRequestHandlerContext } from '@kbn/core-ui-settings-server';
|
||||
|
||||
/**
|
||||
* Request handler context used by core's coreApp routes.
|
||||
|
|
|
@ -13,7 +13,8 @@ import type { SavedObjectsRequestHandlerContext } from '@kbn/core-saved-objects-
|
|||
import { CoreSavedObjectsRouteHandlerContext } from '@kbn/core-saved-objects-server-internal';
|
||||
import type { DeprecationsRequestHandlerContext } from '@kbn/core-deprecations-server';
|
||||
import { CoreDeprecationsRouteHandlerContext } from '@kbn/core-deprecations-server-internal';
|
||||
import { CoreUiSettingsRouteHandlerContext, UiSettingsRequestHandlerContext } from './ui_settings';
|
||||
import type { UiSettingsRequestHandlerContext } from '@kbn/core-ui-settings-server';
|
||||
import { CoreUiSettingsRouteHandlerContext } from '@kbn/core-ui-settings-server-internal';
|
||||
import type { InternalCoreStart } from './internal_types';
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,10 +68,10 @@ import type { DeprecationsServiceSetup } from '@kbn/core-deprecations-server';
|
|||
import type { CoreUsageDataStart, CoreUsageDataSetup } from '@kbn/core-usage-data-server';
|
||||
import type { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
import type { StatusServiceSetup } from '@kbn/core-status-server';
|
||||
import type { UiSettingsServiceSetup, UiSettingsServiceStart } from '@kbn/core-ui-settings-server';
|
||||
|
||||
import { HttpResources } from './http_resources';
|
||||
import { PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId } from './plugins';
|
||||
import { UiSettingsServiceSetup, UiSettingsServiceStart } from './ui_settings';
|
||||
import type { CoreRequestHandlerContext } from './core_route_handler_context';
|
||||
import type { PrebootCoreRequestHandlerContext } from './preboot_core_route_handler_context';
|
||||
|
||||
|
@ -397,16 +397,18 @@ export type {
|
|||
} from '@kbn/core-saved-objects-import-export-server-internal';
|
||||
|
||||
export type {
|
||||
IUiSettingsClient,
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UiSettingsType,
|
||||
UiSettingsServiceSetup,
|
||||
UiSettingsServiceStart,
|
||||
UserProvidedValues,
|
||||
DeprecationSettings,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
export type {
|
||||
IUiSettingsClient,
|
||||
UiSettingsServiceSetup,
|
||||
UiSettingsServiceStart,
|
||||
UiSettingsRequestHandlerContext,
|
||||
} from './ui_settings';
|
||||
} from '@kbn/core-ui-settings-server';
|
||||
|
||||
export type {
|
||||
OpsMetrics,
|
||||
|
|
|
@ -13,11 +13,12 @@ import {
|
|||
TestKibanaUtils,
|
||||
TestUtils,
|
||||
} from '../../../test_helpers/kbn_server';
|
||||
import { createOrUpgradeSavedConfig } from '../../ui_settings/create_or_upgrade_saved_config';
|
||||
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
import { httpServerMock } from '@kbn/core-http-server-mocks';
|
||||
import { createOrUpgradeSavedConfig } from '@kbn/core-ui-settings-server-internal';
|
||||
|
||||
const logger = loggingSystemMock.create().get();
|
||||
|
||||
describe('createOrUpgradeSavedConfig()', () => {
|
||||
let savedObjectsClient: SavedObjectsClientContract;
|
||||
let servers: TestUtils;
|
||||
|
|
|
@ -53,11 +53,11 @@ import type { CoreUsageDataStart } from '@kbn/core-usage-data-server';
|
|||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { I18nServiceSetup } from '@kbn/core-i18n-server';
|
||||
import type { InternalStatusServiceSetup } from '@kbn/core-status-server-internal';
|
||||
import {
|
||||
import type {
|
||||
InternalUiSettingsServicePreboot,
|
||||
InternalUiSettingsServiceSetup,
|
||||
InternalUiSettingsServiceStart,
|
||||
} from './ui_settings';
|
||||
} from '@kbn/core-ui-settings-server-internal';
|
||||
import { InternalRenderingServiceSetup } from './rendering';
|
||||
import { InternalHttpResourcesPreboot, InternalHttpResourcesSetup } from './http_resources';
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import { deprecationsServiceMock } from '@kbn/core-deprecations-server-mocks';
|
|||
import { coreUsageDataServiceMock } from '@kbn/core-usage-data-server-mocks';
|
||||
import { i18nServiceMock } from '@kbn/core-i18n-server-mocks';
|
||||
import { statusServiceMock } from '@kbn/core-status-server-mocks';
|
||||
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
|
||||
import type {
|
||||
PluginInitializerContext,
|
||||
CoreSetup,
|
||||
|
@ -40,7 +41,6 @@ import type {
|
|||
} from '.';
|
||||
import { httpResourcesMock } from './http_resources/http_resources_service.mock';
|
||||
import { renderingMock } from './rendering/rendering_service.mock';
|
||||
import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
||||
import { SharedGlobalConfig } from './plugins';
|
||||
|
||||
export { configServiceMock, configDeprecationsMock } from '@kbn/config-mocks';
|
||||
|
@ -55,7 +55,7 @@ export {
|
|||
savedObjectsRepositoryMock,
|
||||
} from '@kbn/core-saved-objects-api-server-mocks';
|
||||
export { migrationMocks } from '@kbn/core-saved-objects-migration-server-mocks';
|
||||
export { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
||||
export { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
|
||||
export { metricsServiceMock } from '@kbn/core-metrics-server-mocks';
|
||||
export { renderingMock } from './rendering/rendering_service.mock';
|
||||
export { statusServiceMock } from '@kbn/core-status-server-mocks';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line max-classes-per-file
|
||||
import { InternalCorePreboot } from './internal_types';
|
||||
import { IUiSettingsClient } from './ui_settings';
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
import type { InternalCorePreboot } from './internal_types';
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
|
|
@ -17,7 +17,7 @@ import { PackageInfo } from '@kbn/config';
|
|||
import { AuthStatus } from '@kbn/core-http-server';
|
||||
import { UiPlugins } from '../../plugins';
|
||||
import { httpServiceMock, httpServerMock } from '@kbn/core-http-server-mocks';
|
||||
import { uiSettingsServiceMock } from '../../ui_settings/ui_settings_service.mock';
|
||||
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
|
||||
import { bootstrapRendererFactory, BootstrapRenderer } from './bootstrap_renderer';
|
||||
|
||||
const createPackageInfo = (parts: Partial<PackageInfo> = {}): PackageInfo => ({
|
||||
|
|
|
@ -10,8 +10,8 @@ import { createHash } from 'crypto';
|
|||
import { PackageInfo } from '@kbn/config';
|
||||
import { ThemeVersion } from '@kbn/ui-shared-deps-npm';
|
||||
import type { KibanaRequest, HttpAuth } from '@kbn/core-http-server';
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
import { UiPlugins } from '../../plugins';
|
||||
import { IUiSettingsClient } from '../../ui_settings';
|
||||
import { getPluginsBundlePaths } from './get_plugin_bundle_paths';
|
||||
import { getJsDependencyPaths } from './get_js_dependency_paths';
|
||||
import { getThemeTag } from './get_theme_tag';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { RequestHandlerContextBase, IRouter } from '@kbn/core-http-server';
|
||||
import type { UiSettingsRequestHandlerContext } from '../ui_settings';
|
||||
import type { UiSettingsRequestHandlerContext } from '@kbn/core-ui-settings-server';
|
||||
|
||||
/**
|
||||
* Request handler context used by core's rendering routes.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
|
||||
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
|
||||
import { PublicUiSettingsParams, UserProvidedValues } from '../ui_settings';
|
||||
import type { PublicUiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getSettingValue = <T>(
|
||||
settingName: string,
|
||||
|
|
|
@ -17,7 +17,7 @@ import { load } from 'cheerio';
|
|||
|
||||
import { mockRouter } from '@kbn/core-http-router-server-mocks';
|
||||
import { httpServerMock } from '@kbn/core-http-server-mocks';
|
||||
import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock';
|
||||
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
|
||||
import {
|
||||
mockRenderingServiceParams,
|
||||
mockRenderingPrebootDeps,
|
||||
|
|
|
@ -15,6 +15,7 @@ import type { ThemeVersion } from '@kbn/ui-shared-deps-npm';
|
|||
import { firstValueFrom, of } from 'rxjs';
|
||||
import type { CoreContext } from '@kbn/core-base-server-internal';
|
||||
import type { KibanaRequest, HttpAuth } from '@kbn/core-http-server';
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
import type { UiPlugins } from '../plugins';
|
||||
import { Template } from './views';
|
||||
import {
|
||||
|
@ -27,7 +28,6 @@ import {
|
|||
} from './types';
|
||||
import { registerBootstrapRoute, bootstrapRendererFactory } from './bootstrap';
|
||||
import { getSettingValue, getStylesheetPaths } from './render_utils';
|
||||
import { IUiSettingsClient } from '../ui_settings';
|
||||
import { filterUiPlugins } from './filter_ui_plugins';
|
||||
import type { InternalRenderingRequestHandlerContext } from './internal_types';
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ import type {
|
|||
} from '@kbn/core-http-server-internal';
|
||||
import type { InternalElasticsearchServiceSetup } from '@kbn/core-elasticsearch-server-internal';
|
||||
import type { InternalStatusServiceSetup } from '@kbn/core-status-server-internal';
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
import { UiPlugins } from '../plugins';
|
||||
import { IUiSettingsClient } from '../ui_settings';
|
||||
|
||||
/** @internal */
|
||||
export interface RenderingMetadata {
|
||||
|
|
|
@ -51,10 +51,10 @@ jest.doMock('@kbn/core-http-context-server-internal', () => ({
|
|||
ContextService: jest.fn(() => mockContextService),
|
||||
}));
|
||||
|
||||
import { uiSettingsServiceMock } from './ui_settings/ui_settings_service.mock';
|
||||
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
|
||||
|
||||
export const mockUiSettingsService = uiSettingsServiceMock.create();
|
||||
jest.doMock('./ui_settings/ui_settings_service', () => ({
|
||||
jest.doMock('@kbn/core-ui-settings-server-internal', () => ({
|
||||
UiSettingsService: jest.fn(() => mockUiSettingsService),
|
||||
}));
|
||||
|
||||
|
|
|
@ -57,13 +57,12 @@ import {
|
|||
} from '@kbn/core-deprecations-server-internal';
|
||||
import { CoreUsageDataService } from '@kbn/core-usage-data-server-internal';
|
||||
import { StatusService, statusConfig } from '@kbn/core-status-server-internal';
|
||||
import { UiSettingsService, uiSettingsConfig } from '@kbn/core-ui-settings-server-internal';
|
||||
|
||||
import { CoreApp } from './core_app';
|
||||
import { HttpResourcesService } from './http_resources';
|
||||
import { RenderingService } from './rendering';
|
||||
import { UiSettingsService } from './ui_settings';
|
||||
import { PluginsService, config as pluginsConfig } from './plugins';
|
||||
|
||||
import { config as uiSettingsConfig } from './ui_settings';
|
||||
import { InternalCorePreboot, InternalCoreSetup, InternalCoreStart } from './internal_types';
|
||||
import { CoreRouteHandlerContext } from './core_route_handler_context';
|
||||
import { PrebootCoreRouteHandlerContext } from './preboot_core_route_handler_context';
|
||||
|
|
|
@ -47,4 +47,16 @@ export type {
|
|||
} from '@kbn/core-deprecations-common';
|
||||
export type { ExternalUrlConfig } from '@kbn/core-http-server-internal';
|
||||
export type { SavedObjectStatusMeta } from '@kbn/core-saved-objects-server';
|
||||
export * from './ui_settings/types';
|
||||
export type {
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UiSettingsType,
|
||||
UserProvidedValues,
|
||||
DeprecationSettings,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
export type {
|
||||
IUiSettingsClient,
|
||||
UiSettingsServiceSetup,
|
||||
UiSettingsServiceStart,
|
||||
UiSettingsRequestHandlerContext,
|
||||
} from '@kbn/core-ui-settings-server';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue