@omnia/fx
Version:
Provide Omnia Fx typings and tooling for clientside Omnia development.
78 lines (77 loc) • 3.29 kB
TypeScript
import { IMessageBusTopicSubscription, SettingUpdatedMsg } from "../models";
export interface ISuggestedKeyRendererHandler {
/**
* Return an array of the registered html element name that has been suggested to be able to render this key
* */
getSuggestedKeyRenderer: (key: string) => Promise<string>;
}
export interface ISettingsKeyProvider extends ISettingsStorage<any> {
protectKeyWithSecurityRole: (securityRoleId: string) => void;
}
export interface ISettingsKeyProviderWithSuggestedRendererSupport extends ISettingsKeyProvider, ISuggestedKeyRendererHandler, ISettingsStorageWithRendererSuggestion<any> {
}
export interface ISettingsService<T> extends ISuggestedKeyRendererHandler {
registerKeyProvider: (key: string, keyProvider: ISettingsKeyProvider) => void;
}
export interface ISettingsStorage<T> {
/**
* Get the key value
*
* @param key the for which to get value.
* @returns A promise containing the value
*/
getValue: (key: string) => Promise<T>;
/**
* Checks if the current user has access to write the value for a specific key
*
* @param key for which to check access.
* @returns A promise containing the boolean result of the access check
*/
canSetValue: (key: string) => Promise<boolean>;
/**
* Sets a value for the given key
* (Only succeed if current user has access to set key value, see CanSetValue)
*
* @param key for which to add the settings value.
* @param value the value to persist for the key.
* @returns A promise containing the value which has been persisted
*/
setValue: (key: string, value: T) => Promise<T>;
}
export interface ISettingsStorageWithRendererSuggestion<T> extends ISettingsStorage<T> {
/**
* Registers a html element name i.e.web component that you what to handle the editing of settings)
* (Only suggest element that you know kan handle the settings key's value model)
* */
suggestKeyRenderer: (key: string, elementName: string) => void;
}
export interface SettingsServiceConstructor {
securityRoleId: string;
}
export declare class SettingsService<T> implements ISettingsStorage<T>, ISettingsService<T> {
private securityRoleId;
private static SuggestedKeyRenderers;
private static KeyProviders;
/**
* Event dispatcher when a settings key has been updated
*/
private static KeyValueUpdatedPublishSubscribers;
private static LoadedValues;
private static SettingUpdatedPublishSubscriber;
private httpClient;
private permissionService;
private settingsLoader;
constructor(securityRoleId: string);
onKeyValueUpdated: (key: string) => IMessageBusTopicSubscription<T>;
onSettingUpdated: () => IMessageBusTopicSubscription<SettingUpdatedMsg>;
registerKeyProvider: (key: string, keyProvider: ISettingsKeyProvider) => void;
canSetValue(key: string): Promise<boolean>;
setValue(key: string, value: T): Promise<T>;
getValue(key: string): Promise<T>;
suggestKeyRenderer: (key: string, elementName: string) => void;
getSuggestedKeyRenderer: (key: string) => Promise<string>;
private getKeyProvider;
private settingUpdated;
private getKeyValuePublishSubscriber;
reloadSettingsHash(): void;
}