Skip to content

Commit

Permalink
extract public uiSettings params in a separate type
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 12, 2020
1 parent 1036d77 commit 075fe07
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Returns registered uiSettings values [UiSettingsParams](./kibana-plugin-core-ser
<b>Signature:</b>

```typescript
getRegistered: () => Readonly<Record<string, Omit<UiSettingsParams, 'schema'>>>;
getRegistered: () => Readonly<Record<string, PublicUiSettingsParams>>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface IUiSettingsClient
| --- | --- | --- |
| [get](./kibana-plugin-core-server.iuisettingsclient.get.md) | <code>&lt;T = any&gt;(key: string) =&gt; Promise&lt;T&gt;</code> | Retrieves uiSettings values set by the user with fallbacks to default values if not specified. |
| [getAll](./kibana-plugin-core-server.iuisettingsclient.getall.md) | <code>&lt;T = any&gt;() =&gt; Promise&lt;Record&lt;string, T&gt;&gt;</code> | Retrieves a set of all uiSettings values set by the user with fallbacks to default values if not specified. |
| [getRegistered](./kibana-plugin-core-server.iuisettingsclient.getregistered.md) | <code>() =&gt; Readonly&lt;Record&lt;string, Omit&lt;UiSettingsParams, 'schema'&gt;&gt;&gt;</code> | Returns registered uiSettings values [UiSettingsParams](./kibana-plugin-core-server.uisettingsparams.md) |
| [getRegistered](./kibana-plugin-core-server.iuisettingsclient.getregistered.md) | <code>() =&gt; Readonly&lt;Record&lt;string, PublicUiSettingsParams&gt;&gt;</code> | Returns registered uiSettings values [UiSettingsParams](./kibana-plugin-core-server.uisettingsparams.md) |
| [getUserProvided](./kibana-plugin-core-server.iuisettingsclient.getuserprovided.md) | <code>&lt;T = any&gt;() =&gt; Promise&lt;Record&lt;string, UserProvidedValues&lt;T&gt;&gt;&gt;</code> | Retrieves a set of all uiSettings values set by the user. |
| [isOverridden](./kibana-plugin-core-server.iuisettingsclient.isoverridden.md) | <code>(key: string) =&gt; boolean</code> | Shows whether the uiSettings value set by the user. |
| [remove](./kibana-plugin-core-server.iuisettingsclient.remove.md) | <code>(key: string) =&gt; Promise&lt;void&gt;</code> | Removes uiSettings value by key. |
Expand Down
1 change: 1 addition & 0 deletions docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [PluginInitializer](./kibana-plugin-core-server.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>server</code> directory should conform to this interface. |
| [PluginName](./kibana-plugin-core-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |
| [PluginOpaqueId](./kibana-plugin-core-server.pluginopaqueid.md) | |
| [PublicUiSettingsParams](./kibana-plugin-core-server.publicuisettingsparams.md) | A sub-set of [UiSettingsParams](./kibana-plugin-core-server.uisettingsparams.md) exposed to the client-side. |
| [RecursiveReadonly](./kibana-plugin-core-server.recursivereadonly.md) | |
| [RedirectResponseOptions](./kibana-plugin-core-server.redirectresponseoptions.md) | HTTP response parameters for redirection response |
| [RequestHandler](./kibana-plugin-core-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-core-server.kibanaresponsefactory.md) functions. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [PublicUiSettingsParams](./kibana-plugin-core-server.publicuisettingsparams.md)

## PublicUiSettingsParams type

A sub-set of [UiSettingsParams](./kibana-plugin-core-server.uisettingsparams.md) exposed to the client-side.

<b>Signature:</b>

```typescript
export declare type PublicUiSettingsParams = Omit<UiSettingsParams, 'schema'>;
```
1 change: 1 addition & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export {
export {
IUiSettingsClient,
UiSettingsParams,
PublicUiSettingsParams,
UiSettingsType,
UiSettingsServiceSetup,
UiSettingsServiceStart,
Expand Down
5 changes: 4 additions & 1 deletion src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ export interface IScopedRenderingClient {
export interface IUiSettingsClient {
get: <T = any>(key: string) => Promise<T>;
getAll: <T = any>() => Promise<Record<string, T>>;
getRegistered: () => Readonly<Record<string, Omit<UiSettingsParams, 'schema'>>>;
getRegistered: () => Readonly<Record<string, PublicUiSettingsParams>>;
getUserProvided: <T = any>() => Promise<Record<string, UserProvidedValues<T>>>;
isOverridden: (key: string) => boolean;
remove: (key: string) => Promise<void>;
Expand Down Expand Up @@ -1427,6 +1427,9 @@ export interface PluginsServiceStart {
contracts: Map<PluginName, unknown>;
}

// @public
export type PublicUiSettingsParams = Omit<UiSettingsParams, 'schema'>;

// Warning: (ae-forgotten-export) The symbol "RecursiveReadonlyArray" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
Expand Down
1 change: 1 addition & 0 deletions src/core/server/ui_settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export {
UiSettingsServiceStart,
IUiSettingsClient,
UiSettingsParams,
PublicUiSettingsParams,
InternalUiSettingsServiceSetup,
InternalUiSettingsServiceStart,
UiSettingsType,
Expand Down
5 changes: 3 additions & 2 deletions src/core/server/ui_settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
* under the License.
*/
import { SavedObjectsClientContract } from '../saved_objects/types';
import { UiSettingsParams, UserProvidedValues } from '../../types';
import { UiSettingsParams, UserProvidedValues, PublicUiSettingsParams } from '../../types';
export {
UiSettingsParams,
PublicUiSettingsParams,
StringValidationRegexString,
StringValidationRegex,
StringValidation,
Expand All @@ -41,7 +42,7 @@ export interface IUiSettingsClient {
/**
* Returns registered uiSettings values {@link UiSettingsParams}
*/
getRegistered: () => Readonly<Record<string, Omit<UiSettingsParams, 'schema'>>>;
getRegistered: () => Readonly<Record<string, PublicUiSettingsParams>>;
/**
* Retrieves uiSettings values set by the user with fallbacks to default values if not specified.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { SavedObjectsErrorHelpers } from '../saved_objects';
import { SavedObjectsClientContract } from '../saved_objects/types';
import { Logger } from '../logging';
import { createOrUpgradeSavedConfig } from './create_or_upgrade_saved_config';
import { IUiSettingsClient, UiSettingsParams } from './types';
import { IUiSettingsClient, UiSettingsParams, PublicUiSettingsParams } from './types';
import { CannotOverrideError } from './ui_settings_errors';

export interface UiSettingsServiceOptions {
Expand Down Expand Up @@ -72,7 +72,7 @@ export class UiSettingsClient implements IUiSettingsClient {
}

getRegistered() {
const copiedDefaults: Record<string, Omit<UiSettingsParams, 'schema'>> = {};
const copiedDefaults: Record<string, PublicUiSettingsParams> = {};
for (const [key, value] of Object.entries(this.defaults)) {
copiedDefaults[key] = omit(value, 'schema');
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/types/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export interface UiSettingsParams<T = unknown> {
schema?: Type<T>;
}

/**
* A sub-set of {@link UiSettingsParams} exposed to the client-side.
* @public
* */
export type PublicUiSettingsParams = Omit<UiSettingsParams, 'schema'>;

/**
* Allows regex objects or a regex string
* @public
Expand Down

0 comments on commit 075fe07

Please sign in to comment.