UNPKG

2.85 kBTypeScriptView Raw
1import { JSONObject, JSONValue } from '@lumino/coreutils';
2import { ServerConnection } from '..';
3/**
4 * A Configurable data section.
5 */
6export interface IConfigSection {
7 /**
8 * The data for this section.
9 */
10 readonly data: JSONObject;
11 /**
12 * Modify the stored config values.
13 *
14 * #### Notes
15 * Updates the local data immediately, sends the change to the server,
16 * and updates the local data with the response, and fulfils the promise
17 * with that data.
18 */
19 update(newdata: JSONObject): Promise<JSONObject>;
20 /**
21 * The server settings for the section.
22 */
23 readonly serverSettings: ServerConnection.ISettings;
24}
25/**
26 * The namespace for ConfigSection statics.
27 */
28export declare namespace ConfigSection {
29 /**
30 * Create a config section.
31 *
32 * @returns A Promise that is fulfilled with the config section is loaded.
33 */
34 function create(options: ConfigSection.IOptions): Promise<IConfigSection>;
35 /**
36 * The options used to create a config section.
37 */
38 interface IOptions {
39 /**
40 * The section name.
41 */
42 name: string;
43 /**
44 * The optional server settings.
45 */
46 serverSettings?: ServerConnection.ISettings;
47 }
48}
49/**
50 * Configurable object with defaults.
51 */
52export declare class ConfigWithDefaults {
53 /**
54 * Create a new config with defaults.
55 */
56 constructor(options: ConfigWithDefaults.IOptions);
57 /**
58 * Get data from the config section or fall back to defaults.
59 */
60 get(key: string): JSONValue;
61 /**
62 * Set a config value.
63 *
64 * #### Notes
65 * Uses the [Jupyter Notebook API](http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/notebook/master/notebook/services/api/api.yaml#!/config).
66 *
67 * The promise is fulfilled on a valid response and rejected otherwise.
68 *
69 * Sends the update to the server, and changes our local copy of the data
70 * immediately.
71 */
72 set(key: string, value: JSONValue): Promise<JSONValue>;
73 /**
74 * Get data from the Section with our classname, if available.
75 *
76 * #### Notes
77 * If we have no classname, get all of the data in the Section
78 */
79 private _classData;
80 private _section;
81 private _defaults;
82 private _className;
83}
84/**
85 * A namespace for ConfigWithDefaults statics.
86 */
87export declare namespace ConfigWithDefaults {
88 /**
89 * The options used to initialize a ConfigWithDefaults object.
90 */
91 interface IOptions {
92 /**
93 * The configuration section.
94 */
95 section: IConfigSection;
96 /**
97 * The default values.
98 */
99 defaults?: JSONObject;
100 /**
101 * The optional classname namespace.
102 */
103 className?: string;
104 }
105}
106
\No newline at end of file