import { Service, ServiceParameters } from "./service.js";
/**
 * Service that can store configuration
 */
interface ConfigurationProvider {
    /**
     *
     * @param id of the configuration to retrieve
     */
    getConfiguration(id: string): Promise<{
        [key: string]: any;
    }>;
    /**
     * Return true if the service can detect modification
     *
     * If false, then ConfigurationService will set an interval
     * and check every checkInterval @{ConfigurationServiceParameters.checkInterval}
     *
     * @param id of the source to check
     * @param callback to call if source has changed
     */
    canTriggerConfiguration(id: string, callback: () => void): boolean;
}
export declare class ConfigurationServiceParameters extends ServiceParameters {
    /**
     * Check configuration every {checkInterval} seconds
     */
    checkInterval?: number;
    /**
     * Format sourceServiceName:sourceId
     */
    source: string;
    /**
     * Default configuration to use
     */
    default: any;
    constructor(params: any);
}
export type ConfigurationEvents = {
    "Configuration.Applied": any;
    "Configuration.Applying": any;
    "Configuration.Loaded": any;
};
/**
 * Handle sessionSecret ( rolling between two secrets ) expire every hour
 * Handle longTermSecret ( rolling between two longer secret ) expire every month
 *
 * Load configuration from another service
 *
 * If the result contains `webda.services` in his object then webda configuration will
 * be dynamically reloaded
 *
 * @category CoreServices
 * @WebdaModda
 */
export default class ConfigurationService<T extends ConfigurationServiceParameters = ConfigurationServiceParameters, E extends ConfigurationEvents = ConfigurationEvents> extends Service<T, E> {
    protected serializedConfiguration: any;
    /**
     *
     */
    protected nextCheck: number;
    /**
     * Service that will provide the information
     */
    protected sourceService: ConfigurationProvider;
    /**
     * Source id to retrieve
     */
    protected sourceId: string;
    /**
     * Interval between two checks
     */
    private interval;
    /**
     * Watchs for configuration update
     */
    protected watchs: any[];
    /**
     * Current configuration
     */
    protected configuration: any;
    /**
     * Load parameters
     *
     * @param params
     * @ignore
     */
    loadParameters(params: any): ServiceParameters;
    /**
     * @inheritdoc
     */
    init(): Promise<this>;
    /**
     * Watch a specific configuration modification
     *
     * @param jsonPath JSON Path to the object to watch
     * @param callback Method to call with the updated version
     * @param defaultValue Default value of the jsonPath if it does not exist
     */
    watch(jsonPath: string, callback: (update: any) => void | Promise<void>, defaultValue?: any): void;
    /**
     * Clear the check interval if exist
     */
    stop(): Promise<void>;
    /**
     *
     * @returns current configuration
     */
    getConfiguration(): any;
    /**
     * We cannot reinit the configurationService by itself
     *
     * @inheritdoc
     */
    reinit(_config: any): Promise<this>;
    /**
     * Load the configuration by calling the source service with the source id
     * @returns
     */
    protected loadConfiguration(): Promise<{
        [key: string]: any;
    }>;
    initConfiguration(): Promise<{
        [key: string]: any;
    }>;
    /**
     * Checking for configuration updates
     *
     * If configuration is updated, it will trigger all the watchs accordingly
     *
     * @returns
     */
    protected checkUpdate(dynamic?: boolean): Promise<void>;
    /**
     * Update the next check time
     */
    protected updateNextCheck(): void;
    /**
     * Read the file and store it
     */
    loadAndStoreConfiguration(): Promise<{
        [key: string]: any;
    }>;
}
export { ConfigurationProvider, ConfigurationService };
