@jupyterlab/services
Version: 
Client APIs for the Jupyter services REST APIs
157 lines (156 loc) • 4.55 kB
TypeScript
import { JSONObject, JSONValue } from '@lumino/coreutils';
import { ServerConnection } from '..';
/**
 * A Configurable data section.
 */
export interface IConfigSection {
    /**
     * The data for this section.
     */
    readonly data: JSONObject;
    /**
     * Modify the stored config values.
     *
     * #### Notes
     * Updates the local data immediately, sends the change to the server,
     * and updates the local data with the response, and fulfils the promise
     * with that data.
     */
    update(newdata: JSONObject): Promise<JSONObject>;
    /**
     * The server settings for the section.
     */
    readonly serverSettings: ServerConnection.ISettings;
}
/**
 * A manager for config sections.
 */
export declare class ConfigSectionManager implements ConfigSection.IManager {
    /**
     * Create a config section manager.
     */
    constructor(options: ConfigSectionManager.IOptions);
    /**
     * Create a config section.
     */
    create(options: ConfigSectionManager.ICreateOptions): Promise<IConfigSection>;
    /**
     * The server settings used to make API requests.
     */
    readonly serverSettings: ServerConnection.ISettings;
}
/**
 * The namespace for ConfigSection statics.
 */
export declare namespace ConfigSection {
    /**
     * Create a config section.
     *
     * @returns A Promise that is fulfilled with the config section is loaded.
     *
     * @deprecated Creating a config section via the `ConfigSection.create()` global has been deprecated and may be removed in a future version.
     * Instead, require the config section manager via the `IConfigSectionManager` token in a plugin.
     */
    function create(options: ConfigSection.IOptions): Promise<IConfigSection>;
    /**
     * Internal function to set the config section manager.
     *
     * @deprecated This function is an internal helper kept for backward compatiblity.
     * It is not part of the public API and may be removed in a future version.
     */
    function _setConfigSectionManager(manager: ConfigSectionManager): void;
    /**
     * The options used to create a config section.
     */
    interface IOptions extends ConfigSectionManager.ICreateOptions {
        /**
         * The optional server settings.
         */
        serverSettings?: ServerConnection.ISettings;
    }
    /**
     * The interface for the build manager.
     */
    interface IManager extends ConfigSectionManager {
    }
}
/**
 * Configurable object with defaults.
 */
export declare class ConfigWithDefaults {
    /**
     * Create a new config with defaults.
     */
    constructor(options: ConfigWithDefaults.IOptions);
    /**
     * Get data from the config section or fall back to defaults.
     */
    get(key: string): JSONValue;
    /**
     * Set a config value.
     *
     * #### Notes
     * Uses the [Jupyter Server API](https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter-server/jupyter_server/main/jupyter_server/services/api/api.yaml#!/config).
     *
     * The promise is fulfilled on a valid response and rejected otherwise.
     *
     * Sends the update to the server, and changes our local copy of the data
     * immediately.
     */
    set(key: string, value: JSONValue): Promise<JSONValue>;
    /**
     * Get data from the Section with our classname, if available.
     *
     * #### Notes
     * If we have no classname, get all of the data in the Section
     */
    private _classData;
    private _section;
    private _defaults;
    private _className;
}
/**
 * A namespace for ConfigWithDefaults statics.
 */
export declare namespace ConfigWithDefaults {
    /**
     * The options used to initialize a ConfigWithDefaults object.
     */
    interface IOptions {
        /**
         * The configuration section.
         */
        section: IConfigSection;
        /**
         * The default values.
         */
        defaults?: JSONObject;
        /**
         * The optional classname namespace.
         */
        className?: string;
    }
}
/**
 * A namespace for config section API interfaces.
 */
export declare namespace ConfigSectionManager {
    /**
     * The instantiation options for a config section manager.
     */
    interface IOptions {
        /**
         * The server settings used to make API requests.
         */
        serverSettings?: ServerConnection.ISettings;
    }
    /**
     * The config section create options
     */
    interface ICreateOptions {
        /**
         * The section name.
         */
        name: string;
    }
}