浏览代码

Rename IDatastore to IDataConnector to prevent name collision with phosphor data stores.

Afshin Darian 7 年之前
父节点
当前提交
357828ac6d

+ 4 - 4
packages/apputils-extension/src/index.ts

@@ -29,8 +29,8 @@ import {
 } from './palette';
 
 import {
-  SettingClientDatastore
-} from './settingclientdatastore';
+  SettingClientDataConnector
+} from './settingclientdataconnector';
 
 
 /**
@@ -93,8 +93,8 @@ const palettePlugin: JupyterLabPlugin<ICommandPalette> = {
 const settingPlugin: JupyterLabPlugin<ISettingRegistry> = {
   id: 'jupyter.services.setting-registry',
   activate: () => new SettingRegistry({
-    datastore: new SettingClientDatastore(),
-    preload: SettingClientDatastore.preload
+    connector: new SettingClientDataConnector(),
+    preload: SettingClientDataConnector.preload
   }),
   autoStart: true,
   provides: ISettingRegistry

+ 10 - 10
packages/apputils-extension/src/settingclientdatastore.ts → packages/apputils-extension/src/settingclientdataconnector.ts

@@ -4,7 +4,7 @@
 |----------------------------------------------------------------------------*/
 
 import {
-  IDatastore, ISettingRegistry, StateDB
+  IDataConnector, ISettingRegistry, StateDB
 } from '@jupyterlab/coreutils';
 
 import {
@@ -13,23 +13,23 @@ import {
 
 
 /**
- * A client-side datastore for setting schemas.
+ * A client-side data connector for setting schemas.
  *
  * #### Notes
  * This class is deprecated. Its use is only as a storage mechanism of settings
  * data while an API for server-side persistence is being implemented.
  */
 export
-class SettingClientDatastore extends StateDB implements IDatastore<ISettingRegistry.IPlugin, JSONObject> {
+class SettingClientDataConnector extends StateDB implements IDataConnector<ISettingRegistry.IPlugin, JSONObject> {
   /**
-   * Create a new setting client datastore.
+   * Create a new setting client data connector.
    */
   constructor() {
-    super({ namespace: 'setting-client-datastore' });
+    super({ namespace: 'setting-client-data-connector' });
   }
 
   /**
-   * Retrieve a saved bundle from the datastore.
+   * Retrieve a saved bundle from the data connector.
    */
   fetch(id: string): Promise<ISettingRegistry.IPlugin | null> {
     return super.fetch(id).then(user => {
@@ -41,14 +41,14 @@ class SettingClientDatastore extends StateDB implements IDatastore<ISettingRegis
   }
 
   /**
-   * Remove a value from the datastore.
+   * Remove a value from the data connector.
    */
   remove(id: string): Promise<void> {
     return super.remove(id);
   }
 
   /**
-   * Save the user setting data in the datastore.
+   * Save the user setting data in the data connector.
    */
   save(id: string, user: JSONObject): Promise<void> {
     return super.save(id, user);
@@ -57,10 +57,10 @@ class SettingClientDatastore extends StateDB implements IDatastore<ISettingRegis
 
 
 /**
- * A namespace for `SettingClientDatastore` statics.
+ * A namespace for `SettingClientDataConnector` statics.
  */
 export
-namespace SettingClientDatastore {
+namespace SettingClientDataConnector {
   /**
    * Preload the schema for a plugin.
    */

+ 5 - 5
packages/coreutils/src/interfaces.ts

@@ -25,12 +25,12 @@ interface IChangedArgs<T> {
 
 
 /**
- * The description of a general purpose datastore.
+ * The description of a general purpose data connector.
  */
 export
-interface IDatastore<T, U> {
+interface IDataConnector<T, U> {
   /**
-   * Retrieve a saved bundle from the datastore.
+   * Retrieve a saved bundle from the data connector.
    *
    * @param id - The identifier used to retrieve a data bundle.
    *
@@ -43,7 +43,7 @@ interface IDatastore<T, U> {
   fetch(id: string): Promise<T | null>;
 
   /**
-   * Remove a value from the datastore.
+   * Remove a value from the data connector.
    *
    * @param id - The identifier for the data being removed.
    *
@@ -52,7 +52,7 @@ interface IDatastore<T, U> {
   remove(id: string): Promise<void>;
 
   /**
-   * Save a value in the datastore.
+   * Save a value in the data connector.
    *
    * @param id - The identifier for the data being saved.
    *

+ 10 - 10
packages/coreutils/src/settingregistry.ts

@@ -20,7 +20,7 @@ import {
 } from '@phosphor/signaling';
 
 import {
-  IDatastore, StateDB
+  IDataConnector, StateDB
 } from '.';
 
 
@@ -389,7 +389,7 @@ class SettingRegistry {
    */
   constructor(options: SettingRegistry.IOptions = { }) {
     const namespace = 'jupyter.db.settings';
-    this._datastore = options.datastore || new StateDB({ namespace });
+    this._connector = options.connector || new StateDB({ namespace });
     this._validator = options.validator || new DefaultSchemaValidator();
     this._preload = options.preload || (() => { /* no op */ });
   }
@@ -460,7 +460,7 @@ class SettingRegistry {
       return Promise.resolve(settings);
     }
 
-    // If the plugin needs to be loaded from the datastore, fetch.
+    // If the plugin needs to be loaded from the data connector, fetch.
     return this.reload(plugin);
   }
 
@@ -488,11 +488,11 @@ class SettingRegistry {
    * with a list of `ISchemaValidator.IError` objects if it fails.
    */
   reload(plugin: string): Promise<ISettingRegistry.ISettings> {
-    const datastore = this._datastore;
+    const connector = this._connector;
     const plugins = this._plugins;
 
-    // If the plugin needs to be loaded from the datastore, fetch.
-    return datastore.fetch(plugin).then(data => {
+    // If the plugin needs to be loaded from the connector, fetch.
+    return connector.fetch(plugin).then(data => {
       if (!data) {
         const message = `Setting data for ${plugin} does not exist.`;
         throw [{ keyword: '', message, schemaPath: '' }];
@@ -593,7 +593,7 @@ class SettingRegistry {
 
     this._validate(plugins[plugin]);
 
-    return this._datastore.save(plugin, plugins[plugin].data.user)
+    return this._connector.save(plugin, plugins[plugin].data.user)
       .then(() => { this._pluginChanged.emit(plugin); });
   }
 
@@ -621,7 +621,7 @@ class SettingRegistry {
     this._plugins[plugin.id] = plugin;
   }
 
-  private _datastore: IDatastore<ISettingRegistry.IPlugin, JSONObject> | null = null;
+  private _connector: IDataConnector<ISettingRegistry.IPlugin, JSONObject> | null = null;
   private _pluginChanged = new Signal<this, string>(this);
   private _plugins: { [name: string]: ISettingRegistry.IPlugin } = Object.create(null);
   private _preload: (plugin: string, schema: ISettingRegistry.ISchema) => void;
@@ -812,9 +812,9 @@ namespace SettingRegistry {
   export
   interface IOptions {
     /**
-     * The datastore used by the setting registry.
+     * The data connector used by the setting registry.
      */
-    datastore?: IDatastore<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin>;
+    connector?: IDataConnector<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin>;
 
     /**
      * A function that preloads a plugin's schema in the client-side cache.

+ 2 - 2
packages/coreutils/src/statedb.ts

@@ -6,7 +6,7 @@ import {
 } from '@phosphor/coreutils';
 
 import {
-  IDatastore
+  IDataConnector
 } from '.';
 
 
@@ -39,7 +39,7 @@ interface IStateItem {
  * The description of a state database.
  */
 export
-interface IStateDB extends IDatastore<JSONObject, JSONObject> {
+interface IStateDB extends IDataConnector<JSONObject, JSONObject> {
   /**
    * The maximum allowed length of the data after it has been serialized.
    */