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 CHANGED
@@ -13507,7 +13507,7 @@ class Database extends EventEmitter {
13507
13507
  this.id = idGenerator(7);
13508
13508
  this.version = "1";
13509
13509
  this.s3dbVersion = (() => {
13510
- const [ok, err, version] = try_fn_default(() => true ? "8.1.1" : "latest");
13510
+ const [ok, err, version] = try_fn_default(() => true ? "8.1.3" : "latest");
13511
13511
  return ok ? version : "latest";
13512
13512
  })();
13513
13513
  this.resources = {};
@@ -13515,7 +13515,7 @@ class Database extends EventEmitter {
13515
13515
  this.options = options;
13516
13516
  this.verbose = options.verbose || false;
13517
13517
  this.parallelism = parseInt(options.parallelism + "") || 10;
13518
- this.plugins = options.plugins || [];
13518
+ this.plugins = {};
13519
13519
  this.pluginList = options.plugins || [];
13520
13520
  this.cache = options.cache;
13521
13521
  this.passphrase = options.passphrase || "secret";
@@ -13808,6 +13808,8 @@ class Database extends EventEmitter {
13808
13808
  if (plugin.beforeSetup) await plugin.beforeSetup();
13809
13809
  await plugin.setup(db);
13810
13810
  if (plugin.afterSetup) await plugin.afterSetup();
13811
+ const pluginName = this._getPluginName(plugin);
13812
+ this.plugins[pluginName] = plugin;
13811
13813
  });
13812
13814
  await Promise.all(setupProms);
13813
13815
  const startProms = plugins.map(async (plugin) => {
@@ -13823,8 +13825,15 @@ class Database extends EventEmitter {
13823
13825
  * @param {Plugin} plugin - Plugin instance to register
13824
13826
  * @param {string} [name] - Optional name for the plugin (defaults to plugin.constructor.name)
13825
13827
  */
13828
+ /**
13829
+ * Get the normalized plugin name
13830
+ * @private
13831
+ */
13832
+ _getPluginName(plugin, customName = null) {
13833
+ return customName || plugin.constructor.name.replace("Plugin", "").toLowerCase();
13834
+ }
13826
13835
  async usePlugin(plugin, name = null) {
13827
- const pluginName = name || plugin.constructor.name.replace("Plugin", "").toLowerCase();
13836
+ const pluginName = this._getPluginName(plugin, name);
13828
13837
  this.plugins[pluginName] = plugin;
13829
13838
  if (this.isConnected()) {
13830
13839
  await plugin.setup(this);