s3db.js 8.1.1 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/s3db.cjs.js +12 -3
- package/dist/s3db.cjs.min.js +1 -1
- package/dist/s3db.es.js +12 -3
- package/dist/s3db.es.min.js +1 -1
- package/dist/s3db.iife.js +12 -3
- package/dist/s3db.iife.min.js +1 -1
- package/package.json +1 -1
- package/src/database.class.js +16 -4
package/dist/s3db.es.js
CHANGED
|
@@ -13503,7 +13503,7 @@ class Database extends EventEmitter {
|
|
|
13503
13503
|
this.id = idGenerator(7);
|
|
13504
13504
|
this.version = "1";
|
|
13505
13505
|
this.s3dbVersion = (() => {
|
|
13506
|
-
const [ok, err, version] = try_fn_default(() => true ? "8.1.
|
|
13506
|
+
const [ok, err, version] = try_fn_default(() => true ? "8.1.3" : "latest");
|
|
13507
13507
|
return ok ? version : "latest";
|
|
13508
13508
|
})();
|
|
13509
13509
|
this.resources = {};
|
|
@@ -13511,7 +13511,7 @@ class Database extends EventEmitter {
|
|
|
13511
13511
|
this.options = options;
|
|
13512
13512
|
this.verbose = options.verbose || false;
|
|
13513
13513
|
this.parallelism = parseInt(options.parallelism + "") || 10;
|
|
13514
|
-
this.plugins =
|
|
13514
|
+
this.plugins = {};
|
|
13515
13515
|
this.pluginList = options.plugins || [];
|
|
13516
13516
|
this.cache = options.cache;
|
|
13517
13517
|
this.passphrase = options.passphrase || "secret";
|
|
@@ -13804,6 +13804,8 @@ class Database extends EventEmitter {
|
|
|
13804
13804
|
if (plugin.beforeSetup) await plugin.beforeSetup();
|
|
13805
13805
|
await plugin.setup(db);
|
|
13806
13806
|
if (plugin.afterSetup) await plugin.afterSetup();
|
|
13807
|
+
const pluginName = this._getPluginName(plugin);
|
|
13808
|
+
this.plugins[pluginName] = plugin;
|
|
13807
13809
|
});
|
|
13808
13810
|
await Promise.all(setupProms);
|
|
13809
13811
|
const startProms = plugins.map(async (plugin) => {
|
|
@@ -13819,8 +13821,15 @@ class Database extends EventEmitter {
|
|
|
13819
13821
|
* @param {Plugin} plugin - Plugin instance to register
|
|
13820
13822
|
* @param {string} [name] - Optional name for the plugin (defaults to plugin.constructor.name)
|
|
13821
13823
|
*/
|
|
13824
|
+
/**
|
|
13825
|
+
* Get the normalized plugin name
|
|
13826
|
+
* @private
|
|
13827
|
+
*/
|
|
13828
|
+
_getPluginName(plugin, customName = null) {
|
|
13829
|
+
return customName || plugin.constructor.name.replace("Plugin", "").toLowerCase();
|
|
13830
|
+
}
|
|
13822
13831
|
async usePlugin(plugin, name = null) {
|
|
13823
|
-
const pluginName =
|
|
13832
|
+
const pluginName = this._getPluginName(plugin, name);
|
|
13824
13833
|
this.plugins[pluginName] = plugin;
|
|
13825
13834
|
if (this.isConnected()) {
|
|
13826
13835
|
await plugin.setup(this);
|