settingregistry.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import * as Ajv from 'ajv';
  4. import {
  5. find
  6. } from '@phosphor/algorithm';
  7. import {
  8. JSONExt, JSONObject, JSONValue, Token
  9. } from '@phosphor/coreutils';
  10. import {
  11. IDisposable
  12. } from '@phosphor/disposable';
  13. import {
  14. ISignal, Signal
  15. } from '@phosphor/signaling';
  16. import {
  17. IDataConnector, StateDB
  18. } from '.';
  19. /**
  20. * The key in the schema for setting editor icon class hints.
  21. */
  22. export
  23. const ICON_CLASS_KEY ='jupyter.lab.setting-icon-class';
  24. /**
  25. * The key in the schema for setting editor icon label hints.
  26. */
  27. export
  28. const ICON_LABEL_KEY = 'jupyter.lab.setting-icon-label';
  29. /**
  30. * An alias for the JSON deep copy function.
  31. */
  32. const copy = JSONExt.deepCopy;
  33. /**
  34. * An implementation of a schema validator.
  35. */
  36. export
  37. interface ISchemaValidator {
  38. /**
  39. * Add a schema to the validator.
  40. *
  41. * @param plugin - The plugin ID.
  42. *
  43. * @param schema - The schema being added.
  44. *
  45. * @return A list of errors if the schema fails to validate or `null` if there
  46. * are no errors.
  47. *
  48. * #### Notes
  49. * It is safe to call this function multiple times with the same plugin name.
  50. */
  51. addSchema(plugin: string, schema: ISettingRegistry.ISchema): ISchemaValidator.IError[] | null;
  52. /**
  53. * Validate a plugin's schema and user data; populate the `composite` data.
  54. *
  55. * @param plugin - The plugin being validated. Its `composite` data will be
  56. * populated by reference.
  57. *
  58. * @return A list of errors if either the schema or data fail to validate or
  59. * `null` if there are no errors.
  60. */
  61. validateData(plugin: ISettingRegistry.IPlugin): ISchemaValidator.IError[] | null;
  62. }
  63. /**
  64. * A namespace for schema validator interfaces.
  65. */
  66. export
  67. namespace ISchemaValidator {
  68. /**
  69. * A schema validation error definition.
  70. */
  71. export
  72. interface IError {
  73. /**
  74. * The keyword whose validation failed.
  75. */
  76. keyword: string;
  77. /**
  78. * The error message.
  79. */
  80. message: string;
  81. /**
  82. * The path in the schema where the error occurred.
  83. */
  84. schemaPath: string;
  85. }
  86. }
  87. /* tslint:disable */
  88. /**
  89. * The setting registry token.
  90. */
  91. export
  92. const ISettingRegistry = new Token<ISettingRegistry>('jupyter.services.settings');
  93. /* tslint:enable */
  94. /**
  95. * A namespace for setting registry interfaces.
  96. */
  97. export
  98. namespace ISettingRegistry {
  99. /**
  100. * The settings for a specific plugin.
  101. */
  102. export
  103. interface IPlugin extends JSONObject {
  104. /**
  105. * The name of the plugin.
  106. */
  107. id: string;
  108. /**
  109. * The collection of values for a specified setting.
  110. */
  111. data: ISettingBundle;
  112. /**
  113. * The JSON schema for the plugin.
  114. */
  115. schema: ISchema;
  116. }
  117. /**
  118. * A schema type that is a minimal subset of the formal JSON Schema along with
  119. * optional JupyterLab rendering hints.
  120. */
  121. export
  122. interface ISchema extends JSONObject {
  123. /**
  124. * The JupyterLab icon class hint for a plugin can be overridden by user
  125. * settings. It can also be root level and therefore "private".
  126. */
  127. 'jupyter.lab.setting-icon-class'?: string;
  128. /**
  129. * The JupyterLab icon label hint for a plugin can be overridden by user
  130. * settings. It can also be root level and therefore "private".
  131. */
  132. 'jupyter.lab.setting-icon-label'?: string;
  133. /**
  134. * The default value, if any.
  135. */
  136. default?: any;
  137. /**
  138. * The schema description.
  139. */
  140. description?: string;
  141. /**
  142. * The schema's child properties.
  143. */
  144. properties?: {
  145. /**
  146. * The JupyterLab icon class hint for a plugin can be overridden by user
  147. * settings. It can also be root level and therefore "private".
  148. */
  149. 'jupyter.lab.setting-icon-class'?: ISchema;
  150. /**
  151. * The JupyterLab icon label hint for a plugin can be overridden by user
  152. * settings. It can also be root level and therefore "private".
  153. */
  154. 'jupyter.lab.setting-icon-label'?: ISchema;
  155. /**
  156. * Arbitrary setting keys can be added.
  157. */
  158. [key: string]: ISchema;
  159. };
  160. /**
  161. * The title of the schema.
  162. */
  163. title?: string;
  164. /**
  165. * The type or types of the data.
  166. */
  167. type?: string | string[];
  168. }
  169. /**
  170. * The setting values for a plugin.
  171. */
  172. export
  173. interface ISettingBundle extends JSONObject {
  174. /**
  175. * A composite of the user setting values and the plugin schema defaults.
  176. *
  177. * #### Notes
  178. * The `composite` values will always be a superset of the `user` values.
  179. */
  180. composite: JSONObject;
  181. /**
  182. * The user setting values.
  183. */
  184. user: JSONObject;
  185. }
  186. /**
  187. * An interface for manipulating the settings of a specific plugin.
  188. */
  189. export
  190. interface ISettings extends IDisposable {
  191. /**
  192. * A signal that emits when the plugin's settings have changed.
  193. */
  194. readonly changed: ISignal<this, void>;
  195. /**
  196. * Get the composite of user settings and extension defaults.
  197. */
  198. readonly composite: JSONObject;
  199. /*
  200. * The plugin name.
  201. */
  202. readonly plugin: string;
  203. /**
  204. * Get the plugin settings schema.
  205. */
  206. readonly schema: ISettingRegistry.ISchema;
  207. /**
  208. * Get the user settings.
  209. */
  210. readonly user: JSONObject;
  211. /**
  212. * Remove a single setting.
  213. *
  214. * @param key - The name of the setting being removed.
  215. *
  216. * @returns A promise that resolves when the setting is removed.
  217. *
  218. * #### Notes
  219. * This function is asynchronous because it writes to the setting registry.
  220. */
  221. remove(key: string): Promise<void>;
  222. /**
  223. * Get an individual setting.
  224. *
  225. * @param key - The name of the setting being retrieved.
  226. *
  227. * @returns The setting value.
  228. */
  229. get(key: string): { composite: JSONValue, user: JSONValue };
  230. /**
  231. * Save all of the plugin's user settings at once.
  232. */
  233. save(user: JSONObject): Promise<void>;
  234. /**
  235. * Set a single setting.
  236. *
  237. * @param key - The name of the setting being set.
  238. *
  239. * @param value - The value of the setting.
  240. *
  241. * @returns A promise that resolves when the setting has been saved.
  242. *
  243. * #### Notes
  244. * This function is asynchronous because it writes to the setting registry.
  245. */
  246. set(key: string, value: JSONValue): Promise<void>;
  247. }
  248. }
  249. /**
  250. * An implementation of a setting registry.
  251. */
  252. export
  253. interface ISettingRegistry extends SettingRegistry {}
  254. /**
  255. * The default implementation of a schema validator.
  256. */
  257. class DefaultSchemaValidator implements ISchemaValidator {
  258. /**
  259. * Instantiate a schema validator.
  260. */
  261. constructor() {
  262. this._composer.addSchema(Private.SCHEMA, 'main');
  263. this._validator.addSchema(Private.SCHEMA, 'main');
  264. }
  265. /**
  266. * Add a schema to the validator.
  267. *
  268. * @param plugin - The plugin ID.
  269. *
  270. * @param schema - The schema being added.
  271. *
  272. * @return A list of errors if the schema fails to validate or `null` if there
  273. * are no errors.
  274. *
  275. * #### Notes
  276. * It is safe to call this function multiple times with the same plugin name.
  277. */
  278. addSchema(plugin: string, schema: ISettingRegistry.ISchema): ISchemaValidator.IError[] | null {
  279. const validate = this._validator.getSchema('main');
  280. const valid = validate(schema);
  281. if (valid) {
  282. // Remove if schema already exists.
  283. this._composer.removeSchema(plugin);
  284. this._validator.removeSchema(plugin);
  285. // Add schema to the validator and composer.
  286. this._composer.addSchema(schema, plugin);
  287. this._validator.addSchema(schema, plugin);
  288. return null;
  289. }
  290. return validate.errors as ISchemaValidator.IError[];
  291. }
  292. /**
  293. * Validate a plugin's schema and user data; populate the `composite` data.
  294. *
  295. * @param plugin - The plugin being validated. Its `composite` data will be
  296. * populated by reference.
  297. *
  298. * @return A list of errors if either the schema or data fail to validate or
  299. * `null` if there are no errors.
  300. */
  301. validateData(plugin: ISettingRegistry.IPlugin): ISchemaValidator.IError[] | null {
  302. const validate = this._validator.getSchema(plugin.id);
  303. const compose = this._composer.getSchema(plugin.id);
  304. if (!validate || !compose) {
  305. const errors = this.addSchema(plugin.id, plugin.schema);
  306. if (errors) {
  307. return errors;
  308. }
  309. }
  310. if (!validate(plugin.data.user)) {
  311. return validate.errors as ISchemaValidator.IError[];
  312. }
  313. // Copy the user data before validating (and merging defaults).
  314. plugin.data.composite = copy(plugin.data.user);
  315. if (!compose(plugin.data.composite)) {
  316. return compose.errors as ISchemaValidator.IError[];
  317. }
  318. }
  319. private _composer = new Ajv({ useDefaults: true });
  320. private _validator = new Ajv();
  321. }
  322. /**
  323. * The default concrete implementation of a setting registry.
  324. */
  325. export
  326. class SettingRegistry {
  327. /**
  328. * Create a new setting registry.
  329. */
  330. constructor(options: SettingRegistry.IOptions = { }) {
  331. const namespace = 'jupyter.db.settings';
  332. this._connector = options.connector || new StateDB({ namespace });
  333. this._validator = options.validator || new DefaultSchemaValidator();
  334. this._preload = options.preload || (() => { /* no op */ });
  335. }
  336. /**
  337. * The schema of the setting registry.
  338. */
  339. readonly schema = Private.SCHEMA;
  340. /**
  341. * A signal that emits the name of a plugin when its settings change.
  342. */
  343. get pluginChanged(): ISignal<this, string> {
  344. return this._pluginChanged;
  345. }
  346. /**
  347. * Returns a list of plugin settings held in the registry.
  348. */
  349. get plugins(): ISettingRegistry.IPlugin[] {
  350. const plugins = this._plugins;
  351. return Object.keys(plugins)
  352. .map(p => copy(plugins[p]) as ISettingRegistry.IPlugin);
  353. }
  354. /**
  355. * Get an individual setting.
  356. *
  357. * @param plugin - The name of the plugin whose settings are being retrieved.
  358. *
  359. * @param key - The name of the setting being retrieved.
  360. *
  361. * @returns A promise that resolves when the setting is retrieved.
  362. */
  363. get(plugin: string, key: string): Promise<{ composite: JSONValue, user: JSONValue }> {
  364. const plugins = this._plugins;
  365. if (plugin in plugins) {
  366. const { composite, user } = plugins[plugin].data;
  367. const result = {
  368. composite: key in composite ? copy(composite[key]) : void 0,
  369. user: key in user ? copy(user[key]) : void 0
  370. };
  371. return Promise.resolve(result);
  372. }
  373. return this.load(plugin).then(() => this.get(plugin, key));
  374. }
  375. /**
  376. * Load a plugin's settings into the setting registry.
  377. *
  378. * @param plugin - The name of the plugin whose settings are being loaded.
  379. *
  380. * @returns A promise that resolves with a plugin settings object or rejects
  381. * if the plugin is not found.
  382. */
  383. load(plugin: string): Promise<ISettingRegistry.ISettings> {
  384. const plugins = this._plugins;
  385. const registry = this;
  386. // If the plugin exists, resolve.
  387. if (plugin in plugins) {
  388. const settings = new Settings({ plugin: plugins[plugin], registry });
  389. return Promise.resolve(settings);
  390. }
  391. // If the plugin needs to be loaded from the data connector, fetch.
  392. return this.reload(plugin);
  393. }
  394. /**
  395. * Preload the schema for a plugin.
  396. *
  397. * @param plugin - The plugin ID.
  398. *
  399. * @param schema - The schema being added.
  400. *
  401. * #### Notes
  402. * This method is deprecated and is only intented for use until there is a
  403. * server-side API for storing setting data.
  404. */
  405. preload(plugin: string, schema: ISettingRegistry.ISchema): void {
  406. this._preload(plugin, schema);
  407. }
  408. /**
  409. * Reload a plugin's settings into the registry even if they already exist.
  410. *
  411. * @param plugin - The name of the plugin whose settings are being reloaded.
  412. *
  413. * @returns A promise that resolves with a plugin settings object or rejects
  414. * with a list of `ISchemaValidator.IError` objects if it fails.
  415. */
  416. reload(plugin: string): Promise<ISettingRegistry.ISettings> {
  417. const connector = this._connector;
  418. const plugins = this._plugins;
  419. // If the plugin needs to be loaded from the connector, fetch.
  420. return connector.fetch(plugin).then(data => {
  421. if (!data) {
  422. const message = `Setting data for ${plugin} does not exist.`;
  423. throw [{ keyword: '', message, schemaPath: '' }];
  424. }
  425. this._validate(data);
  426. return new Settings({
  427. plugin: copy(plugins[plugin]) as ISettingRegistry.IPlugin,
  428. registry: this
  429. });
  430. });
  431. }
  432. /**
  433. * Remove a single setting in the registry.
  434. *
  435. * @param plugin - The name of the plugin whose setting is being removed.
  436. *
  437. * @param key - The name of the setting being removed.
  438. *
  439. * @returns A promise that resolves when the setting is removed.
  440. */
  441. remove(plugin: string, key: string): Promise<void> {
  442. const plugins = this._plugins;
  443. if (!(plugin in plugins)) {
  444. return Promise.resolve(void 0);
  445. }
  446. delete plugins[plugin].data.user[key];
  447. return this._save(plugin);
  448. }
  449. /**
  450. * Set a single setting in the registry.
  451. *
  452. * @param plugin - The name of the plugin whose setting is being set.
  453. *
  454. * @param key - The name of the setting being set.
  455. *
  456. * @param value - The value of the setting being set.
  457. *
  458. * @returns A promise that resolves when the setting has been saved.
  459. *
  460. */
  461. set(plugin: string, key: string, value: JSONValue): Promise<void> {
  462. const plugins = this._plugins;
  463. if (!(plugin in plugins)) {
  464. return this.load(plugin).then(() => this.set(plugin, key, value));
  465. }
  466. plugins[plugin].data.user[key] = value;
  467. return this._save(plugin);
  468. }
  469. /**
  470. * Upload a plugin's settings.
  471. *
  472. * @param raw - The raw plugin settings being uploaded.
  473. *
  474. * @returns A promise that resolves when the settings have been saved.
  475. *
  476. * #### Notes
  477. * Only the `user` data will be saved.
  478. */
  479. upload(raw: ISettingRegistry.IPlugin): Promise<void | ISchemaValidator.IError[]> {
  480. const plugins = this._plugins;
  481. const plugin = raw.id;
  482. let errors: ISchemaValidator.IError[] | null = null;
  483. // Validate the user data and create the composite data.
  484. raw.data.user = raw.data.user || { };
  485. delete raw.data.composite;
  486. errors = this._validator.validateData(raw);
  487. if (errors) {
  488. return Promise.reject(errors);
  489. }
  490. // Set the local copy.
  491. plugins[plugin] = raw;
  492. return this._save(plugin);
  493. }
  494. /**
  495. * Save a plugin in the registry.
  496. */
  497. private _save(plugin: string): Promise<void> {
  498. const plugins = this._plugins;
  499. if (!(plugin in plugins)) {
  500. return Promise.reject(`${plugin} does not exist in setting registry.`);
  501. }
  502. this._validate(plugins[plugin]);
  503. return this._connector.save(plugin, plugins[plugin].data.user)
  504. .then(() => { this._pluginChanged.emit(plugin); });
  505. }
  506. /**
  507. * Validate a plugin's data and schema, compose the `composite` data.
  508. */
  509. private _validate(plugin: ISettingRegistry.IPlugin): void {
  510. let errors: ISchemaValidator.IError[] | null = null;
  511. // Add the schema to the registry.
  512. errors = this._validator.addSchema(plugin.id, plugin.schema);
  513. if (errors) {
  514. throw errors;
  515. }
  516. // Validate the user data and create the composite data.
  517. plugin.data.user = plugin.data.user || { };
  518. delete plugin.data.composite;
  519. errors = this._validator.validateData(plugin);
  520. if (errors) {
  521. throw errors;
  522. }
  523. // Set the local copy.
  524. this._plugins[plugin.id] = plugin;
  525. }
  526. private _connector: IDataConnector<ISettingRegistry.IPlugin, JSONObject> | null = null;
  527. private _pluginChanged = new Signal<this, string>(this);
  528. private _plugins: { [name: string]: ISettingRegistry.IPlugin } = Object.create(null);
  529. private _preload: (plugin: string, schema: ISettingRegistry.ISchema) => void;
  530. private _validator: ISchemaValidator | null = null;
  531. }
  532. /**
  533. * A manager for a specific plugin's settings.
  534. */
  535. export
  536. class Settings implements ISettingRegistry.ISettings {
  537. /**
  538. * Instantiate a new plugin settings manager.
  539. */
  540. constructor(options: Settings.IOptions) {
  541. const { plugin } = options;
  542. this.plugin = plugin.id;
  543. this.registry = options.registry;
  544. this._composite = plugin.data.composite || { };
  545. this._schema = plugin.schema || { type: 'object' };
  546. this._user = plugin.data.user || { };
  547. this.registry.pluginChanged.connect(this._onPluginChanged, this);
  548. }
  549. /**
  550. * A signal that emits when the plugin's settings have changed.
  551. */
  552. get changed(): ISignal<this, void> {
  553. return this._changed;
  554. }
  555. /**
  556. * Get the composite of user settings and extension defaults.
  557. */
  558. get composite(): JSONObject {
  559. return this._composite;
  560. }
  561. /**
  562. * Test whether the plugin settings manager disposed.
  563. */
  564. get isDisposed(): boolean {
  565. return this._isDisposed;
  566. }
  567. /**
  568. * Get the plugin settings schema.
  569. */
  570. get schema(): ISettingRegistry.ISchema {
  571. return this._schema;
  572. }
  573. /**
  574. * Get the user settings.
  575. */
  576. get user(): JSONObject {
  577. return this._user;
  578. }
  579. /*
  580. * The plugin name.
  581. */
  582. readonly plugin: string;
  583. /**
  584. * The system registry instance used by the settings manager.
  585. */
  586. readonly registry: SettingRegistry;
  587. /**
  588. * Dispose of the plugin settings resources.
  589. */
  590. dispose(): void {
  591. if (this._isDisposed) {
  592. return;
  593. }
  594. this._isDisposed = true;
  595. this._composite = null;
  596. this._schema = null;
  597. this._user = null;
  598. Signal.clearData(this);
  599. }
  600. /**
  601. * Get an individual setting.
  602. *
  603. * @param key - The name of the setting being retrieved.
  604. *
  605. * @returns The setting value.
  606. *
  607. * #### Notes
  608. * This method returns synchronously because it uses a cached copy of the
  609. * plugin settings that is synchronized with the registry.
  610. */
  611. get(key: string): { composite: JSONValue, user: JSONValue } {
  612. const { composite, user } = this;
  613. return {
  614. composite: key in composite ? copy(composite[key]) : void 0,
  615. user: key in user ? copy(user[key]) : void 0
  616. };
  617. }
  618. /**
  619. * Remove a single setting.
  620. *
  621. * @param key - The name of the setting being removed.
  622. *
  623. * @returns A promise that resolves when the setting is removed.
  624. *
  625. * #### Notes
  626. * This function is asynchronous because it writes to the setting registry.
  627. */
  628. remove(key: string): Promise<void> {
  629. return this.registry.remove(this.plugin, key);
  630. }
  631. /**
  632. * Save all of the plugin's user settings at once.
  633. */
  634. save(user: JSONObject): Promise<void> {
  635. return this.registry.upload({
  636. id: this.plugin,
  637. data: { composite: this._composite, user },
  638. schema: this._schema
  639. });
  640. }
  641. /**
  642. * Set a single setting.
  643. *
  644. * @param key - The name of the setting being set.
  645. *
  646. * @param value - The value of the setting.
  647. *
  648. * @returns A promise that resolves when the setting has been saved.
  649. *
  650. * #### Notes
  651. * This function is asynchronous because it writes to the setting registry.
  652. */
  653. set(key: string, value: JSONValue): Promise<void> {
  654. return this.registry.set(this.plugin, key, value);
  655. }
  656. /**
  657. * Handle plugin changes in the setting registry.
  658. */
  659. private _onPluginChanged(sender: any, plugin: string): void {
  660. if (plugin === this.plugin) {
  661. const found = find(this.registry.plugins, p => p.id === plugin);
  662. if (!found) {
  663. return;
  664. }
  665. const { composite, user } = found.data;
  666. const schema = found.schema;
  667. this._composite = composite || { };
  668. this._schema = schema || { type: 'object' };
  669. this._user = user || { };
  670. this._changed.emit(void 0);
  671. }
  672. }
  673. private _changed = new Signal<this, void>(this);
  674. private _composite: JSONObject = Object.create(null);
  675. private _isDisposed = false;
  676. private _schema: ISettingRegistry.ISchema = Object.create(null);
  677. private _user: JSONObject = Object.create(null);
  678. }
  679. /**
  680. * A namespace for `SettingRegistry` statics.
  681. */
  682. export
  683. namespace SettingRegistry {
  684. /**
  685. * The instantiation options for a setting registry
  686. */
  687. export
  688. interface IOptions {
  689. /**
  690. * The data connector used by the setting registry.
  691. */
  692. connector?: IDataConnector<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin>;
  693. /**
  694. * A function that preloads a plugin's schema in the client-side cache.
  695. *
  696. * #### Notes
  697. * This param is deprecated and is only intented for use until there is a
  698. * server-side API for storing setting data.
  699. */
  700. preload?: (plugin: string, schema: ISettingRegistry.ISchema) => void;
  701. /**
  702. * The validator used to enforce the settings JSON schema.
  703. */
  704. validator?: ISchemaValidator;
  705. }
  706. }
  707. /**
  708. * A namespace for `Settings` statics.
  709. */
  710. export
  711. namespace Settings {
  712. /**
  713. * The instantiation options for a `Settings` object.
  714. */
  715. export
  716. interface IOptions {
  717. /**
  718. * The setting values for a plugin.
  719. */
  720. plugin: ISettingRegistry.IPlugin;
  721. /**
  722. * The system registry instance used by the settings manager.
  723. */
  724. registry: SettingRegistry;
  725. }
  726. }
  727. /**
  728. * A namespace for private module data.
  729. */
  730. export
  731. namespace Private {
  732. /* tslint:disable */
  733. /**
  734. * The schema for settings.
  735. */
  736. export
  737. const SCHEMA: ISettingRegistry.ISchema = {
  738. "$schema": "http://json-schema.org/draft-06/schema",
  739. "title": "Jupyter Settings/Preferences Schema",
  740. "description": "Jupyter settings/preferences schema v0.1.0",
  741. "type": "object",
  742. "additionalProperties": true,
  743. "properties": {
  744. [ICON_CLASS_KEY]: { "type": "string", "default": "jp-FileIcon" },
  745. [ICON_LABEL_KEY]: { "type": "string", "default": "Plugin" }
  746. }
  747. };
  748. /* tslint:enable */
  749. }