UNPKG

@difizen/mana-core

Version:

129 lines 5.46 kB
import type { Event } from '@difizen/mana-common'; import { URI } from '@difizen/mana-common'; import { Syringe } from '@difizen/mana-syringe'; export declare const IConfigurationService: Syringe.DefinedToken; export declare function isConfigurationOverrides(thing: any): thing is IConfigurationOverrides; export interface IConfigurationOverrides { overrideIdentifier?: string | null; resource?: URI | null; } export declare enum ConfigurationTarget { USER = 1, USER_LOCAL = 2, USER_REMOTE = 3, WORKSPACE = 4, WORKSPACE_FOLDER = 5, DEFAULT = 6, MEMORY = 7 } export declare function ConfigurationTargetToString(configurationTarget: ConfigurationTarget): "USER" | "USER_LOCAL" | "USER_REMOTE" | "WORKSPACE" | "WORKSPACE_FOLDER" | "DEFAULT" | "MEMORY"; export interface IConfigurationChange { keys: string[]; overrides: [string, string[]][]; } export interface IConfigurationChangeEvent { readonly source: ConfigurationTarget; readonly affectedKeys: string[]; readonly change: IConfigurationChange; affectsConfiguration: (configuration: string, overrides?: IConfigurationOverrides) => boolean; readonly sourceConfig: any; } export interface IConfigurationValue<T> { readonly defaultValue?: T | undefined; readonly userValue?: T | undefined; readonly userLocalValue?: T | undefined; readonly userRemoteValue?: T | undefined; readonly workspaceValue?: T | undefined; readonly workspaceFolderValue?: T | undefined; readonly memoryValue?: T | undefined; readonly value?: T | undefined; readonly default?: { value?: T | undefined; override?: T | undefined; } | undefined; readonly user?: { value?: T; override?: T; } | undefined; readonly userLocal?: { value?: T; override?: T; } | undefined; readonly userRemote?: { value?: T; override?: T; } | undefined; readonly workspace?: { value?: T; override?: T; } | undefined; readonly workspaceFolder?: { value?: T; override?: T; } | undefined; readonly memory?: { value?: T; override?: T; } | undefined; readonly overrideIdentifiers?: string[]; } export interface IConfigurationService { readonly _serviceBrand: undefined; onDidChangeConfiguration: Event<IConfigurationChangeEvent>; getConfigurationData: () => IConfigurationData | null; /** * Fetches the value of the section for the given overrides. * Value can be of native type or an object keyed off the section name. * * @param section - Section of the configuraion. Can be `null` or `undefined`. * @param overrides - Overrides that has to be applied while fetching * */ getValue: (<T>() => T) & (<T>(section: string) => T) & (<T>(overrides: IConfigurationOverrides) => T) & (<T>(section: string, overrides: IConfigurationOverrides) => T); updateValue: ((key: string, value: any) => Promise<void>) & ((key: string, value: any, overrides: IConfigurationOverrides) => Promise<void>) & ((key: string, value: any, target: ConfigurationTarget) => Promise<void>) & ((key: string, value: any, overrides: IConfigurationOverrides, target: ConfigurationTarget, donotNotifyError?: boolean) => Promise<void>); inspect: <T>(key: string, overrides?: IConfigurationOverrides) => IConfigurationValue<T>; reloadConfiguration: (target?: ConfigurationTarget /** | IWorkspaceFolder **/) => Promise<void>; keys: () => { default: string[]; user: string[]; workspace: string[]; workspaceFolder: string[]; memory?: string[]; }; } export interface IConfigurationModel { contents: any; keys: string[]; overrides: IOverrides[]; } export interface IOverrides { keys: string[]; contents: any; identifiers: string[]; } export interface IConfigurationData { defaults: IConfigurationModel; user: IConfigurationModel; workspace: IConfigurationModel; } export interface IConfigurationCompareResult { added: string[]; removed: string[]; updated: string[]; overrides: [string, string[]][]; } export declare function compare(from: IConfigurationModel | undefined, to: IConfigurationModel | undefined): IConfigurationCompareResult; export declare function toOverrides(raw: any, conflictReporter: (message: string) => void): IOverrides[]; export declare function toValuesTree(properties: Record<string, any>, conflictReporter: (message: string) => void): any; export declare function addToValueTree(settingsTreeRoot: any, key: string, value: any, conflictReporter: (message: string) => void): void; export declare function removeFromValueTree(valueTree: any, key: string): void; /** * A helper function to get the configuration value with a specific settings path (e.g. config.some.setting) */ export declare function getConfigurationValue<T>(config: any, settingPath: string, defaultValue?: T): T; export declare function merge(base: any, add: any, overwrite: boolean): void; export declare function getConfigurationKeys(): string[]; export declare function getDefaultValues(): any; export declare function keyFromOverrideIdentifier(overrideIdentifier: string): string; export declare function getMigratedSettingValue<T>(configurationService: IConfigurationService, currentSettingName: string, legacySettingName: string): T; //# sourceMappingURL=configuration.d.ts.map