|
@@ -1,6 +1,8 @@
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Copyright (c) Jupyter Development Team.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
|
|
+import * as Ajv from 'ajv';
|
|
|
|
+
|
|
import {
|
|
import {
|
|
find
|
|
find
|
|
} from '@phosphor/algorithm';
|
|
} from '@phosphor/algorithm';
|
|
@@ -33,6 +35,13 @@ const LEVEL: ISettingRegistry.Level = 'user';
|
|
const copy = JSONExt.deepCopy;
|
|
const copy = JSONExt.deepCopy;
|
|
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * An implementation of a schema validator.
|
|
|
|
+ */
|
|
|
|
+export
|
|
|
|
+interface ISchemaValidator {}
|
|
|
|
+
|
|
|
|
+
|
|
/* tslint:disable */
|
|
/* tslint:disable */
|
|
/**
|
|
/**
|
|
* The setting registry token.
|
|
* The setting registry token.
|
|
@@ -199,6 +208,13 @@ export
|
|
interface ISettingRegistry extends SettingRegistry {}
|
|
interface ISettingRegistry extends SettingRegistry {}
|
|
|
|
|
|
|
|
|
|
|
|
+class DefaultSchemaValidator implements ISchemaValidator {
|
|
|
|
+ constructor() {
|
|
|
|
+ const validator = new Ajv();
|
|
|
|
+ console.log('validator', validator);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The default concrete implementation of a setting registry.
|
|
* The default concrete implementation of a setting registry.
|
|
*/
|
|
*/
|
|
@@ -207,9 +223,10 @@ class SettingRegistry {
|
|
/**
|
|
/**
|
|
* Create a new setting registry.
|
|
* Create a new setting registry.
|
|
*/
|
|
*/
|
|
- constructor(options: SettingRegistry.IOptions = { datastore: null }) {
|
|
|
|
|
|
+ constructor(options: SettingRegistry.IOptions = { }) {
|
|
const namespace = 'jupyter.db.settings';
|
|
const namespace = 'jupyter.db.settings';
|
|
this._datastore = options.datastore || new StateDB({ namespace });
|
|
this._datastore = options.datastore || new StateDB({ namespace });
|
|
|
|
+ this._validator = options.validator || new DefaultSchemaValidator();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -431,6 +448,7 @@ class SettingRegistry {
|
|
private _datastore: IDatastore<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin> | null = null;
|
|
private _datastore: IDatastore<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin> | null = null;
|
|
private _pluginChanged = new Signal<this, string>(this);
|
|
private _pluginChanged = new Signal<this, string>(this);
|
|
private _plugins: { [name: string]: ISettingRegistry.IPlugin } = Object.create(null);
|
|
private _plugins: { [name: string]: ISettingRegistry.IPlugin } = Object.create(null);
|
|
|
|
+ private _validator: ISchemaValidator | null = null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -599,7 +617,12 @@ namespace SettingRegistry {
|
|
/**
|
|
/**
|
|
* The datastore used by the setting registry.
|
|
* The datastore used by the setting registry.
|
|
*/
|
|
*/
|
|
- datastore: IDatastore<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin>;
|
|
|
|
|
|
+ datastore?: IDatastore<ISettingRegistry.IPlugin, ISettingRegistry.IPlugin>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The validator used to enforce the settings JSON schema.
|
|
|
|
+ */
|
|
|
|
+ validator?: ISchemaValidator;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|