@pi-r/mongodb 0.6.6 → 0.6.8

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @pi-r/mongodb
2
2
 
3
+ PEP 402 - Forever Dodgers
4
+
3
5
  ## Documentation
4
6
 
5
7
  - [E-mc](https://e-mc.readthedocs.io/en/latest/db/mongodb.html)
package/client/index.js CHANGED
@@ -37,11 +37,12 @@ class MongoDBPool extends DbPool {
37
37
  return topology ? super.closeable || topology.s.state === 'closing' : true;
38
38
  }
39
39
  get closed() {
40
+ var _a;
40
41
  const topology = this.client.topology;
41
42
  if (topology && (this.success > 0 || this.failed > 0)) {
42
43
  return topology.isDestroyed();
43
44
  }
44
- return this.client.s?.hasBeenClosed === true;
45
+ return ((_a = this.client.s) === null || _a === void 0 ? void 0 : _a.hasBeenClosed) === true;
45
46
  }
46
47
  }
47
48
  const POOL_STATE = {};
@@ -66,7 +67,7 @@ function removePoolProperties(credential) {
66
67
  }
67
68
  function getCacheObject(item) {
68
69
  const credential = item.credential;
69
- return { uri: item.uri, options: item.options, uuidKey: credential?.uuidKey };
70
+ return { uri: item.uri, options: item.options, uuidKey: credential === null || credential === void 0 ? void 0 : credential.uuidKey };
70
71
  }
71
72
  function getPoolKey(credential) {
72
73
  const { options, uri } = credential;
@@ -75,18 +76,19 @@ function getPoolKey(credential) {
75
76
  }
76
77
  }
77
78
  function setCredential(item) {
79
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
78
80
  const credential = this.getCredential(item);
79
81
  const options = item.options || (item.options = {});
80
82
  let uri = item.uri;
81
83
  if (credential) {
82
84
  let { protocol, server, hostname, port, username, password } = (0, util_1.parseServerAuth)(credential, 27017), { auth, authMechanism = 'DEFAULT', authSource, authMechanismProperties } = credential, authentication = '';
83
85
  if (authMechanism === 'GSSAPI') {
84
- const principal = auth?.username || username || options.auth?.username;
86
+ const principal = (auth === null || auth === void 0 ? void 0 : auth.username) || username || ((_a = options.auth) === null || _a === void 0 ? void 0 : _a.username);
85
87
  if ((0, types_1.isString)(principal)) {
86
88
  authentication = encodeURIComponent(principal) + '@';
87
89
  }
88
90
  }
89
- else if (auth?.username) {
91
+ else if (auth === null || auth === void 0 ? void 0 : auth.username) {
90
92
  options.auth = auth;
91
93
  }
92
94
  if (!uri || !Db.isURL(uri)) {
@@ -174,7 +176,7 @@ function setCredential(item) {
174
176
  }
175
177
  let username, password, pool;
176
178
  if ((0, types_1.isString)(usePool)) {
177
- if (username = options.auth?.username || item.uri && (0, util_1.parseConnectionString)(item.uri)?.username) {
179
+ if (username = ((_b = options.auth) === null || _b === void 0 ? void 0 : _b.username) || item.uri && ((_c = (0, util_1.parseConnectionString)(item.uri)) === null || _c === void 0 ? void 0 : _c.username)) {
178
180
  [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
179
181
  if (pool) {
180
182
  pool.add(item, password);
@@ -190,25 +192,25 @@ function setCredential(item) {
190
192
  if (config) {
191
193
  const { min, max, idle, queue_max, queue_idle, timeout, socket_timeout } = config;
192
194
  if (min >= 0) {
193
- options.minPoolSize ?? (options.minPoolSize = min);
195
+ (_d = options.minPoolSize) !== null && _d !== void 0 ? _d : (options.minPoolSize = min);
194
196
  }
195
197
  if (max > 0) {
196
- options.maxPoolSize ?? (options.maxPoolSize = max);
198
+ (_e = options.maxPoolSize) !== null && _e !== void 0 ? _e : (options.maxPoolSize = max);
197
199
  }
198
200
  if (idle >= 0) {
199
- options.maxIdleTimeMS ?? (options.maxIdleTimeMS = idle);
201
+ (_f = options.maxIdleTimeMS) !== null && _f !== void 0 ? _f : (options.maxIdleTimeMS = idle);
200
202
  }
201
203
  if (queue_max > 0) {
202
- options.maxConnecting ?? (options.maxConnecting = queue_max);
204
+ (_g = options.maxConnecting) !== null && _g !== void 0 ? _g : (options.maxConnecting = queue_max);
203
205
  }
204
206
  if (queue_idle >= 0) {
205
- options.waitQueueTimeoutMS ?? (options.waitQueueTimeoutMS = queue_idle);
207
+ (_h = options.waitQueueTimeoutMS) !== null && _h !== void 0 ? _h : (options.waitQueueTimeoutMS = queue_idle);
206
208
  }
207
209
  if (timeout > 0) {
208
- options.connectTimeoutMS ?? (options.connectTimeoutMS = timeout);
210
+ (_j = options.connectTimeoutMS) !== null && _j !== void 0 ? _j : (options.connectTimeoutMS = timeout);
209
211
  }
210
212
  if (socket_timeout > 0) {
211
- options.socketTimeoutMS ?? (options.socketTimeoutMS = socket_timeout);
213
+ (_k = options.socketTimeoutMS) !== null && _k !== void 0 ? _k : (options.socketTimeoutMS = socket_timeout);
212
214
  }
213
215
  }
214
216
  const poolKey = getPoolKey(item);
@@ -224,6 +226,7 @@ async function executeQuery(item, options) {
224
226
  }
225
227
  exports.executeQuery = executeQuery;
226
228
  async function executeBatchQuery(batch, options = '', outResult) {
229
+ var _a;
227
230
  const length = batch.length;
228
231
  if (length === 0) {
229
232
  return [];
@@ -285,7 +288,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
285
288
  item.transactionState &= ~64;
286
289
  return client;
287
290
  };
288
- if (this.host?.username) {
291
+ if ((_a = this.host) === null || _a === void 0 ? void 0 : _a.username) {
289
292
  this.applyCommand(...batch);
290
293
  }
291
294
  for (let i = 0; i < length; ++i) {
@@ -311,9 +314,9 @@ async function executeBatchQuery(batch, options = '', outResult) {
311
314
  continue;
312
315
  }
313
316
  item.transactionState = 1;
314
- const getInstance = (target) => target.db(name, client?.db);
315
- const getCollection = (target) => getInstance(target).collection(table, client?.collection);
316
- const runCommand = async (target, document) => getInstance(target).command(document, client?.command);
317
+ const getInstance = (target) => target.db(name, client === null || client === void 0 ? void 0 : client.db);
318
+ const getCollection = (target) => getInstance(target).collection(table, client === null || client === void 0 ? void 0 : client.collection);
319
+ const runCommand = async (target, document) => getInstance(target).command(document, client === null || client === void 0 ? void 0 : client.command);
317
320
  const credential = mongoCredential || onceCredential || getCacheObject(item);
318
321
  const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
319
322
  const coercing = this.hasCoerce("mongodb", 'options', credential.uuidKey);
@@ -371,6 +374,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
371
374
  onceCredential = undefined;
372
375
  }
373
376
  tasks[i] = new Promise(async (resolve, reject) => {
377
+ var _a, _b;
374
378
  let commandType;
375
379
  try {
376
380
  const instance = mongoClient || await getConnection(item, credential);
@@ -385,7 +389,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
385
389
  }
386
390
  if (Array.isArray(update)) {
387
391
  commandType = this.commandType.INSERT;
388
- const insertOptions = item.execute?.insert;
392
+ const insertOptions = (_a = item.execute) === null || _a === void 0 ? void 0 : _a.insert;
389
393
  if (insertOptions && coercing) {
390
394
  (0, types_1.coerceObject)(insertOptions);
391
395
  }
@@ -433,7 +437,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
433
437
  else {
434
438
  if (update && updateType === 1) {
435
439
  commandType = this.commandType.UPDATE;
436
- const updateOptions = item.execute?.update;
440
+ const updateOptions = (_b = item.execute) === null || _b === void 0 ? void 0 : _b.update;
437
441
  if (updateOptions && coercing) {
438
442
  (0, types_1.coerceObject)(updateOptions);
439
443
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mongodb",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "MongoDB client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -21,9 +21,9 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.8.7",
25
- "@e-mc/request": "^0.8.7",
26
- "@e-mc/types": "^0.8.7",
27
- "mongodb": "^6.5.0"
24
+ "@e-mc/db": "^0.8.14",
25
+ "@e-mc/request": "^0.8.14",
26
+ "@e-mc/types": "^0.8.14",
27
+ "mongodb": "^6.8.0"
28
28
  }
29
29
  }