ueberdb2 4.1.21 → 4.1.23

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.
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var AbstractDatabase = require('../lib/AbstractDatabase.js');
4
- var assert$0 = require('assert');
4
+ var assert = require('assert');
5
5
  var buffer = require('buffer');
6
6
  var crypto = require('crypto');
7
- var es = require('elasticsearch8');
7
+ var elasticsearch8 = require('elasticsearch8');
8
8
 
9
9
  /**
10
10
  * 2015 Visionist, Inc.
@@ -117,7 +117,7 @@ const Database = class extends AbstractDatabase {
117
117
  */
118
118
  async init() {
119
119
  // create elasticsearch client
120
- const client = new es.Client({
120
+ const client = new elasticsearch8.Client({
121
121
  node: `http://${this.settings.host}:${this.settings.port}`,
122
122
  });
123
123
  await client.ping();
@@ -141,9 +141,9 @@ const Database = class extends AbstractDatabase {
141
141
  await client.indices.putAlias({ index: tmpIndex, name: this._index });
142
142
  }
143
143
  const indices = Object.values((await client.indices.get({ index: this._index })));
144
- assert$0.equal(indices.length, 1);
144
+ assert.equal(indices.length, 1);
145
145
  try {
146
- assert$0.deepEqual(indices[0].mappings, mappings);
146
+ assert.deepEqual(indices[0].mappings, mappings);
147
147
  }
148
148
  catch (err) {
149
149
  this.logger.warn(`Index ${this._index} mappings does not match expected; ` +
@@ -4,6 +4,7 @@ var events = require('events');
4
4
 
5
5
  const Database = class extends events.EventEmitter {
6
6
  settings;
7
+ mock;
7
8
  constructor(settings) {
8
9
  super();
9
10
  this.settings = {
@@ -11,6 +12,8 @@ const Database = class extends events.EventEmitter {
11
12
  ...settings,
12
13
  };
13
14
  settings.mock = this;
15
+ this.settings = settings;
16
+ console.log("Initialized");
14
17
  }
15
18
  close(cb) {
16
19
  this.emit('close', cb);
@@ -24,8 +27,8 @@ const Database = class extends events.EventEmitter {
24
27
  get(key, cb) {
25
28
  this.emit('get', key, cb);
26
29
  }
27
- init(cb) {
28
- this.emit('init', cb);
30
+ async init(cb) {
31
+ this.emit('init', cb());
29
32
  }
30
33
  remove(key, cb) {
31
34
  this.emit('remove', key, cb);
@@ -36,7 +36,7 @@ const Database = class extends AbstractDatabase {
36
36
  }
37
37
  clearPing() {
38
38
  if (this.interval) {
39
- clearInterval(this.interval);
39
+ clearInterval(this.interval[Symbol.toPrimitive]());
40
40
  }
41
41
  }
42
42
  schedulePing() {
@@ -43,7 +43,6 @@ const Database = class extends AbstractDatabase {
43
43
  try {
44
44
  return await new Promise((resolve, reject) => {
45
45
  options = { timeout: this.settings.queryTimeout, ...options };
46
- // @ts-ignore
47
46
  this._pool && this._pool.query(options, (err, ...args) => err != null ? reject(err) : resolve(args));
48
47
  });
49
48
  }
package/dist/index.js CHANGED
@@ -52,23 +52,19 @@ const Database = class {
52
52
  }
53
53
  // saves all settings and require the db module
54
54
  this.type = type;
55
- this.dbModule = require(`./databases/${type}_db`);
56
55
  this.dbSettings = dbSettings;
57
56
  this.wrapperSettings = wrapperSettings;
58
57
  this.logger = logging.normalizeLogger(logger);
59
- const db = new this.dbModule.Database(this.dbSettings);
60
- db.logger = this.logger;
61
- this.db = new CacheAndBufferLayer.Database(db, this.wrapperSettings, this.logger);
62
- // Expose the cache wrapper's metrics to the user. See lib/CacheAndBufferLayer.js for details.
63
- //
64
- // WARNING: This feature is EXPERIMENTAL -- do not assume it will continue to exist in its
65
- // current form in a future version.
66
- this.metrics = this.db.metrics;
67
58
  }
68
59
  /**
69
60
  * @param callback - Deprecated. Node-style callback. If null, a Promise is returned.
70
61
  */
71
- init(callback = null) {
62
+ async init(callback = null) {
63
+ this.dbModule = await import(`./databases/${this.type}_db`);
64
+ const db = new this.dbModule.Database(this.dbSettings);
65
+ db.logger = this.logger;
66
+ this.db = new CacheAndBufferLayer.Database(db, this.wrapperSettings, this.logger);
67
+ this.metrics = this.db.metrics;
72
68
  if (callback != null) {
73
69
  return cbDb.init.call(this.db);
74
70
  }
@@ -652,11 +652,7 @@ const clone = (obj, key = '') => {
652
652
  return copy;
653
653
  }
654
654
  throw new Error("Unable to copy obj! Its type isn't supported.");
655
- };
656
- const exportedForTesting = {
657
- LRU,
658
655
  };
659
656
 
660
657
  exports.Database = Database$1;
661
658
  exports.LRU = LRU;
662
- exports.exportedForTesting = exportedForTesting;
@@ -1,15 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var console = require('console');
4
- var process = require('process');
3
+ require('console');
4
+ require('process');
5
5
 
6
- class ConsoleLogger extends console.Console {
7
- constructor(opts = {}) { super({ stdout: process.stdout, stderr: process.stderr, inspectOptions: { depth: Infinity }, ...opts }); }
8
- isDebugEnabled() { return false; }
9
- isInfoEnabled() { return true; }
10
- isWarnEnabled() { return true; }
11
- isErrorEnabled() { return true; }
12
- }
13
6
  const normalizeLogger = (logger) => {
14
7
  const logLevelsUsed = ['debug', 'info', 'warn', 'error'];
15
8
  logger = Object.create(logger || {});
@@ -31,5 +24,4 @@ const normalizeLogger = (logger) => {
31
24
  return logger;
32
25
  };
33
26
 
34
- exports.ConsoleLogger = ConsoleLogger;
35
27
  exports.normalizeLogger = normalizeLogger;
package/package.json CHANGED
@@ -27,12 +27,12 @@
27
27
  "dirty": "^1.1.3",
28
28
  "elasticsearch8": "npm:@elastic/elasticsearch@^8.8.1",
29
29
  "eslint-plugin-import": "^2.28.1",
30
- "mongodb": "^5.7.0",
31
- "mssql": "^9.1.3",
30
+ "mongodb": "^6.0.0",
31
+ "mssql": "^9.2.0",
32
32
  "mysql": "2.18.1",
33
33
  "nano": "^10.1.2",
34
34
  "pg": "^8.11.3",
35
- "redis": "^4.6.7",
35
+ "redis": "^4.6.8",
36
36
  "rethinkdb": "^2.4.2",
37
37
  "semver": "^7.5.4",
38
38
  "simple-git": "^3.19.1"
@@ -42,22 +42,21 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/async": "^3.2.20",
45
- "@types/mocha": "^10.0.1",
46
45
  "@types/mssql": "^8.1.2",
47
46
  "@types/mysql": "^2.15.21",
48
- "@types/node": "^20.4.9",
47
+ "@types/node": "^20.5.7",
49
48
  "@types/pg": "^8.10.2",
50
49
  "@types/rethinkdb": "^2.3.17",
51
50
  "cli-table": "^0.3.11",
52
- "eslint": "^8.47.0",
53
- "eslint-config-etherpad": "^3.0.21",
54
- "mocha": "^10.2.0",
55
- "randexp": "^0.5.3",
51
+ "eslint": "^8.48.0",
52
+ "eslint-config-etherpad": "^3.0.22",
53
+ "randexp-ts": "^1.0.5",
54
+ "vitest": "^0.34.3",
56
55
  "typescript": "^4.9.5",
57
56
  "wtfnode": "^0.9.1",
58
- "rollup": "^3.28.0",
57
+ "rollup": "^3.28.1",
59
58
  "rollup-plugin-typescript2": "^0.35.0",
60
- "@rollup/plugin-node-resolve": "^15.2.0",
59
+ "@rollup/plugin-node-resolve": "^15.2.1",
61
60
  "glob": "^10.3.3"
62
61
  },
63
62
  "repository": {
@@ -65,7 +64,7 @@
65
64
  "url": "https://github.com/ether/ueberDB.git"
66
65
  },
67
66
  "main": "./dist/index",
68
- "version": "4.1.21",
67
+ "version": "4.1.23",
69
68
  "bugs": {
70
69
  "url": "https://github.com/ether/ueberDB/issues"
71
70
  },
@@ -78,10 +77,8 @@
78
77
  "scripts": {
79
78
  "lint": "eslint .",
80
79
  "lint:fix": "eslint --fix .",
81
- "test": "mocha ./dist/test/test*.js",
82
- "test:watch": "mocha ./dist/test/test*.js --watch",
83
- "test-debug": "npx rollup -c rollup.config.cjs && mocha --inspect-brk ./dist/test/test*.js",
84
- "build": "npx rollup -c rollup.config.cjs"
80
+ "build": "npx rollup -c rollup.config.cjs",
81
+ "test": "vitest"
85
82
  },
86
83
  "_npmUser": {
87
84
  "name": "johnyma22",