/*!
 * Copyright 2017 - 2020 by ChartIQ, Inc.
 * All rights reserved.
 */
import { _BaseClient as BaseClient } from "./baseClient";
import { StandardErrorCallback, StandardPromise, StandardError } from "../types";
import { ListenerFunction } from "./StoreModel";
import { QueryResponse } from "./routerClientInstance";
declare type Manifest = Record<string, any>;
declare type FieldOnlyParam = {
    field: string;
};
declare type FieldAndValueParam = {
    field: string;
    value?: any;
};
declare type FieldAndValueParams = FieldAndValueParam[] | string[];
declare type ListenerParam = {
    field: string;
    listener: ListenerFunction;
};
declare type RemoveListenersType = ListenerParam | ListenerParam[];
/**
 * @introduction
 * <h2>Config Client (Finsemble Connect)</h2>
 *
 * This client provides run-time access to Finsemble's configuration.
 * The Config Client functions similar to a global store created with the Distributed Store Client and offers many of the same methods.
 * Values modified at runtime are not persisted.
 *
 *
 * See the [Configuration tutorial](tutorial-Configuration.html) for a configuration overview.
 *
 * @hideconstructor
 * @constructor
 */
export declare class ConfigClient extends BaseClient {
    listeners: Record<string, ListenerFunction[]>;
    subs: Record<string, boolean>;
    constructor();
    /**
     * Retrieves the entire manifest
     * @example
     * FSBL.Clients.ConfigClient.getManifest(function(err, value){ });
     * const {err, data} = await FSBL.Clients.ConfigClient.getManifest();
     */
    getManifest(cb?: StandardErrorCallback<Manifest>): StandardPromise<Manifest>;
    /**
     * Get a value from the config.
     * @param {Function} cb Will return the value if found.
     * @example
     * FSBL.Clients.ConfigClient.getValue({ field:'field1' }, function(err,value){ });
     * FSBL.Clients.ConfigClient.getValue('field1', function(err,value){ });
     * const {err, data} = await FSBL.Clients.ConfigClient.getValue({ field:'field1' });
     * const {err, data} = await FSBL.Clients.ConfigClient.getValue('field1');
     */
    getValue<T = any>(params: FieldOnlyParam | string, cb?: StandardErrorCallback<T>): StandardPromise<T>;
    /**
     * Get multiple values from the config.
     * @param {fieldOnlyParam[] | string[]} fields An array of field objects.
     * @param {Function} cb Will return the value if found.
     *
     * Deprecated functionality: If there are no fields provided, the complete configuration manifest is returned (use getManifest()).
     *
     * @example
     * FSBL.Clients.ConfigClient.getValues(['field1','field2'], function(err,values){ });
     * FSBL.Clients.ConfigClient.getValues(null, callback); // returns the complete manifest containing the finsemble property
     * const {err, data} = await FSBL.Clients.ConfigClient.getValues(['field1', 'field2']);
     */
    getValues<T = any>(fields?: FieldOnlyParam[] | string[] | null, cb?: StandardErrorCallback<Record<string, T>>): StandardPromise<Record<string, T>>;
    /**
     * Set a value in the config. Setting a value will trigger events that you can listen to using <a href="ConfigClient.html#addListener">addListener</a>.
     * @param {function} cb Optional callback
     *
     * @example
     * FSBL.Clients.ConfigClient.setValue({ field:'field1', value:"new value" }, function(err){ });
     * const {err} = await FSBL.Clients.ConfigClient.setValue({ field:'field1', value:'new value' })
     */
    setValue(params: FieldAndValueParam, cb?: StandardErrorCallback<void>): Promise<{
        err: string | null | undefined;
    }>;
    /**
     * This will set multiple values in the config.
     * @param {function} cb Optional callback
     *
     * @example
     * FSBL.Clients.ConfigClient.setValues([{ field:'field1', value: "new value" }]);
     * const {err} = await FSBL.Clients.ConfigClient.setValues([{ field:'field1', value: "new value" }]);
     */
    setValues(fields: FieldAndValueParams, cb?: StandardErrorCallback<void>): Promise<{
        err: string | null | undefined;
    }>;
    /**
     * Remove a value from the config.
     * @param {String} field - Name of field to remove
     * @param {Function} cb -  Returns an error if there is one
     * @example
     * FSBL.Clients.ConfigClient.removeValue('field1', function(err){ });
     * const {err} = await FSBL.Clients.ConfigClient.removeValue('field1');
     */
    removeValue(field: String, cb?: StandardErrorCallback<void>): Promise<{
        err: string | null | undefined;
    }>;
    /**
     * Removes multiple values from the config.
     * @param {fieldAndValueParams} params - An Array of field objects
     * @param {Function} cb -  Returns an error if there is one.
     * @example
     * FSBL.Clients.ConfigClient.removeValues(['field1'], function(err){ });
     * const {err} = await FSBL.Clients.ConfigClient.removeValues(['field1'])
     */
    removeValues(params: FieldAndValueParams, cb?: StandardErrorCallback<void>): Promise<{
        err: StandardError;
    }>;
    /**
     * make sure we dont have duplicate router subscribers
     * @private
     */
    changeSub(change: string): Promise<void>;
    /**
     * Add a listener to the config at either the root config level or field level. If no field is given, the root config level is used. You can also listen for changes to config fields any number of levels deep -- finsemble.configitem.deeperconfigitem.evendeeperconfigitem
     * @param {Function} fn The function to be called when the observed piece of config is modified.
     * @param {Function} cb Callback to be invoked after the listener is added.
     * @example
     * var myFunction = function(err,data){};
     * FSBL.Clients.ConfigClient.addListener({ field:'field1' }, myFunction, cb);
     */
    addListener<T = any>(params: {
        field: string | null;
    }, fn: ListenerFunction<T>, cb?: () => void): void;
    /**
     * Add an array of listeners as objects or strings. If using strings, you must provide a function callback as the second parameter.
     *
     * @param {listenerParam[] | fieldOnlyParam | string[]} params
     * @param {function} fn The function to be called when the observed piece of config is modified.
     * @param {function} cb Callback to be invoked after the listeners are added.
     * @example
     * var myFunction = function(err,data){}
     * FSBL.Clients.ConfigClient.addListeners(
     * 	[
     * 		{ field: "field1", listener: myFunction },
     * 		{ field: "field2", listener: myFunction }
     * 	],
     * 	null,
     * 	cb
     * );
     *
     * FSBL.Clients.ConfigClient.addListeners(
     * [{ field: "field1" }, { field: "field2", listener: myFunction }],
     * myFunction,
     * cb
     * );
     *
     * FSBL.Clients.ConfigClient.addListeners(["field1", "field2"], myFunction, cb);
     */
    addListeners<T = any>(params: ListenerParam[] | string[], fn: ListenerFunction<T>, cb?: () => void): void;
    /**
     * Remove a listener from config. If no field is given, we look for a config root listener
     * @param {function} fn The listener to remove.
     * @param {function} cb Returns true if it was successful in removing the listener.
     *
     * @example
     * var myFunction = function(err,data){ }
     * FSBL.Clients.ConfigClient.removeListener({
     * 	field:'field1'
     * }, myFunction, function(err, bool){ });
     * FSBL.Clients.ConfigClient.removeListener(myFunction, function(err, bool){ });
     */
    removeListener(params: {
        field: string | null;
    }, fn: ListenerFunction<any>, cb?: Function): void;
    /**
     * Remove an array of listeners from the config
     * @param {removeListenersType} params
     * @param {function} fn The listener to remove
     * @param {function} cb Returns true if it was successful in removing the listener.
     *
     * @example
     * var myFunction = function(err,data){ }
     * FSBL.Clients.ConfigClient.removeListeners({
     * 	field: 'field1'
     * }, MyFunction, function(bool){ });
     * FSBL.Clients.ConfigClient.removeListeners([{ field:'field1', listener: MyFunction }], function(bool){ });
     * FSBL.Clients.ConfigClient.removeListeners(['field1'], MyFunction, function(bool) { });
     */
    removeListeners(params: RemoveListenersType, fn?: ListenerFunction<any>, cb?: StandardErrorCallback<boolean>): void;
    /**
     * @private
     * @memberof ConfigClient
     */
    handleChanges: (err: StandardError, response: {
        data: {
            store: string;
            storeData: any;
            field: string | null;
            value: any;
        };
    }) => void;
    /**
     * @private
     * @memberof ConfigClient
     */
    private triggerListeners;
    /**
     * Dynamically set config values within the Finsemble configuration.  New config properties may be set or existing ones modified. Note that configuration changes will not necessarily dynamically modify the components or services that use the corresponding configuration -- it depends if the component or service handles the corresponding change notifications (either though PubSub or the config's DataStore). Also, these changes do not persist in any config files.
     *
     * <b>Note</b>: Anytime config is set using this API, the newConfig along with the updated manifest will by published to the PubSub topic "Config.changeNotification".  To get these notifications any component or service can subscribe to the topic. An example is shown below.
     *
     * <b>Note</b>: Anytime config is set using this API, the dataStore underlying configuration 'Finsemble-Configuration-Store' will also be updated. To get these dataStore events a listener can be set as shown in the example below. However, any config modifications made directly though the DataStore will not result in corresponding PubSub notifications.
     *
     *  <b>Caution</b>: During dynamic configuration, Finsemble can overwrite components already in the configuration when `ConfigClient.processAndSet` is called. To prevent this from happening, set `manifest.component.category = "system"` in the config of the component. This setting is used, for example, to prevent system UI components from being dropped out of the config.

     *

     * @param {object} params
     * @param {object} params.newConfig Provides the configuration properties to add into the existing configuration under manifest.finsemble. This config must match the Finsemble config requirements as described in the [Configuration tutorial]{@tutorial Configuration}. It can include importConfig references to dynamically fetch additional configuration files.
     * @param {boolean} params.overwrite If true then overwrite any preexisting config with new config (can only set to true when running from same origin, not cross-domain); if false then newConfig must not match properties of existing config, including service and component configuration.
     * @param {boolean} params.replace True specifies any component, app, or service definitions in the new config will place all existing non-system component and service configuration
     * @param {StandardErrorCallback} callback Callback to be invoked upon task completion.
     * @return {Promise<Manifest>} Returns the resulting manifest
     * @example
     * // Examples using processAndSet()
     * FSBL.Clients.ConfigClient.processAndSet({ newConfig: { myNewConfigField: 12345 }, overwrite: false });
     * FSBL.Clients.ConfigClient.processAndSet(
     * {
     *	newConfig: {
     *		"myNewConfigField": 12345,
     *		"myNewConfigObject": {
     *			A: "this is a test",
     *			B: "more test"
     *		},
     *		"importConfig": [
     *			"$applicationRoot/configs/application/test.json",
     *		]
     *	},
     *	overwrite: true,
     *  replace: false,
     * },
     *	function (err, finsemble) {
     *		if (err) {
     *			console.error("ConfigClient.set", err);
     *		} else {
     *			console.log("new finsemble config", finsemble);
     *		}
     *	}
     * );
     *
     *  // example subscribing to PubSub to get notifications of dynamic updates
     * RouterClient.subscribe("Config.changeNotification", function (err, notify) {
     *		console.log("set notification", notify.data.newConfig, notify.data.finsemble);
     *	});
     *
     *  // example using DataStore to get notifications of dynamic updates
     * DistributedStoreClient.getStore({ store: 'Finsemble-Configuration-Store', global: true }, function (err, configStore) {
     *		configStore.addListener({ field: "finsemble" }, function (err, newFinsembleConfig) {
     *			console.log("new manifest.finsemble configuration", newFinsembleConfig);
     *		});
     * });
     *
     */
    processAndSet(params: {
        newConfig: Record<string, any>;
        overwrite: boolean;
        replace: boolean;
    }, cb?: StandardErrorCallback<QueryResponse<Manifest>>): StandardPromise<Manifest>;
    /**
     * Sets a value on the configStore and persists that value to storage. On application restart, this value will overwrite any application defaults.
     * @param {fieldAndValueParam} params
     * @param {StandardErrorCallback} callback Callback to be invoked when preferences have been retrieved from the service or on error.
     * @example
     * FSBL.Clients.ConfigClient.setPreference({
     * 	field: "finsemble.initialWorkspace",
     * 	value: "Workspace 2"
     * }, (err, response) => {
     * 		//preference has been set
     * });
     * const {err, data} = await FSBL.Clients.ConfigClient.setPreference({field: "finsemble.initialWorkspace", value: "Workspace 2"});
     */
    setPreference(params: FieldAndValueParam, cb?: StandardErrorCallback<void>): StandardPromise<void>;
    /**
     * Retrieves all of the preferences set for the application.
     * @param {StandardErrorCallback} callback Callback to be invoked when preferences have been retrieved from the service.
     * @example
     * FSBL.Clients.ConfigClient.getPreferences((err, preferences)=> {
     * 		 if (!err) {
     * 		 	console.log(preferences); // an object containing the entire user preferences.
     * 		 }
     * });
     * const {err, data} = await FSBL.Clients.ConfigClient.getPreferences();
     */
    getPreferences(cb?: StandardErrorCallback<Record<string, any> | null>): StandardPromise<Record<string, any> | null>;
    /**
     * Reset a user preference value to default. On application restart, the application default value will be used instead of the preference.
     * @param {fieldOnlyParam} params
     * @param {StandardErrorCallback} callback The callback to be invoked after the preference is removed or on error.
     * @example
     * FSBL.Clients.ConfigClient.unsetPreference({
     * 	field: "finsemble.initialWorkspace",
     * }, (err, response) => {
     * 		//preference has been unset
     * });
     * const {err, data} = await FSBL.Clients.ConfigClient.unsetPreference({field: "finsemble.initialWorkspace"});
     */
    unsetPreference(params: FieldOnlyParam, cb?: StandardErrorCallback<void>): StandardPromise<void>;
}
declare const configClient: ConfigClient;
export default configClient;
//# sourceMappingURL=configClient.d.ts.map