mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[uiSettings] improves browser-side public types (#149645)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> fix https://github.com/elastic/kibana/issues/137609
This commit is contained in:
parent
2e740c50e2
commit
04affacf80
11 changed files with 27 additions and 25 deletions
|
@ -8,13 +8,13 @@
|
|||
|
||||
import UiSharedDepsNpm from '@kbn/ui-shared-deps-npm';
|
||||
import * as UiSharedDepsSrc from '@kbn/ui-shared-deps-src';
|
||||
import type { PublicUiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
import type { UiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export const getSettingValue = <T>(
|
||||
settingName: string,
|
||||
settings: {
|
||||
user?: Record<string, UserProvidedValues<unknown>>;
|
||||
defaults: Readonly<Record<string, PublicUiSettingsParams>>;
|
||||
defaults: Readonly<Record<string, Omit<UiSettingsParams, 'schema'>>>;
|
||||
},
|
||||
convert: (raw: unknown) => T
|
||||
): T => {
|
||||
|
|
|
@ -10,8 +10,12 @@ import { cloneDeep, defaultsDeep } from 'lodash';
|
|||
import { Observable, Subject, concat, defer, of } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
|
||||
import { UserProvidedValues, PublicUiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import { IUiSettingsClient, UiSettingsState } from '@kbn/core-ui-settings-browser';
|
||||
import { UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
import {
|
||||
IUiSettingsClient,
|
||||
UiSettingsState,
|
||||
PublicUiSettingsParams,
|
||||
} from '@kbn/core-ui-settings-browser';
|
||||
|
||||
import { UiSettingsApi } from './ui_settings_api';
|
||||
|
||||
|
|
|
@ -6,4 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export type { UiSettingsState, IUiSettingsClient, SettingsStart, SettingsSetup } from './src/types';
|
||||
export type {
|
||||
PublicUiSettingsParams,
|
||||
UiSettingsState,
|
||||
IUiSettingsClient,
|
||||
SettingsStart,
|
||||
SettingsSetup,
|
||||
} from './src/types';
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
*/
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { PublicUiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
import type { UiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
|
||||
export type PublicUiSettingsParams = Omit<UiSettingsParams, 'schema'>;
|
||||
|
||||
/** @public */
|
||||
export interface UiSettingsState {
|
||||
|
|
|
@ -10,7 +10,6 @@ export type {
|
|||
UiSettingsType,
|
||||
DeprecationSettings,
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UserProvidedValues,
|
||||
UiSettingsScope,
|
||||
} from './src/ui_settings';
|
||||
|
|
|
@ -94,12 +94,6 @@ export interface UiSettingsParams<T = unknown> {
|
|||
scope?: UiSettingsScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* A sub-set of {@link UiSettingsParams} exposed to the client-side.
|
||||
* @public
|
||||
* */
|
||||
export type PublicUiSettingsParams = Omit<UiSettingsParams, 'schema'>;
|
||||
|
||||
/**
|
||||
* Describes the values explicitly set by user.
|
||||
* @public
|
||||
|
|
|
@ -8,11 +8,7 @@
|
|||
|
||||
import { omit } from 'lodash';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import type {
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UserProvidedValues,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
import type { UiSettingsParams, UserProvidedValues } from '@kbn/core-ui-settings-common';
|
||||
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
|
||||
|
||||
export interface BaseUiSettingsDefaultsClientOptions {
|
||||
|
@ -42,7 +38,7 @@ export abstract class BaseUiSettingsClient implements IUiSettingsClient {
|
|||
}
|
||||
|
||||
getRegistered() {
|
||||
const copiedDefaults: Record<string, PublicUiSettingsParams> = {};
|
||||
const copiedDefaults: Record<string, Omit<UiSettingsParams, 'schema'>> = {};
|
||||
for (const [key, value] of Object.entries(this.defaults)) {
|
||||
copiedDefaults[key] = omit(value, 'schema');
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { UserProvidedValues, PublicUiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
import type { UserProvidedValues, UiSettingsParams } from '@kbn/core-ui-settings-common';
|
||||
|
||||
/**
|
||||
* Server-side client that provides access to the advanced settings stored in elasticsearch.
|
||||
|
@ -20,7 +20,7 @@ export interface IUiSettingsClient {
|
|||
/**
|
||||
* Returns registered uiSettings values {@link UiSettingsParams}
|
||||
*/
|
||||
getRegistered: () => Readonly<Record<string, PublicUiSettingsParams>>;
|
||||
getRegistered: () => Readonly<Record<string, Omit<UiSettingsParams, 'schema'>>>;
|
||||
/**
|
||||
* Retrieves uiSettings values set by the user with fallbacks to default values if not specified.
|
||||
*/
|
||||
|
|
|
@ -34,7 +34,11 @@ export type {
|
|||
FatalErrorsStart,
|
||||
FatalErrorInfo,
|
||||
} from '@kbn/core-fatal-errors-browser';
|
||||
export type { UiSettingsState, IUiSettingsClient } from '@kbn/core-ui-settings-browser';
|
||||
export type {
|
||||
UiSettingsState,
|
||||
IUiSettingsClient,
|
||||
PublicUiSettingsParams,
|
||||
} from '@kbn/core-ui-settings-browser';
|
||||
export type { Capabilities } from '@kbn/core-capabilities-common';
|
||||
export type { SavedObjectsStart } from '@kbn/core-saved-objects-browser';
|
||||
export type { NotificationsSetup, NotificationsStart } from '@kbn/core-notifications-browser';
|
||||
|
@ -76,7 +80,6 @@ export {
|
|||
} from '@kbn/core-application-common';
|
||||
export type {
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UserProvidedValues,
|
||||
UiSettingsType,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
|
|
|
@ -389,7 +389,6 @@ export type {
|
|||
|
||||
export type {
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UiSettingsType,
|
||||
UserProvidedValues,
|
||||
DeprecationSettings,
|
||||
|
|
|
@ -23,6 +23,5 @@ export type {
|
|||
UiSettingsType,
|
||||
DeprecationSettings,
|
||||
UiSettingsParams,
|
||||
PublicUiSettingsParams,
|
||||
UserProvidedValues,
|
||||
} from '@kbn/core-ui-settings-common';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue