@pi-r/mariadb 0.9.4 → 0.10.1

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/client/index.js CHANGED
@@ -54,7 +54,7 @@ function setCredential(item) {
54
54
  errors.push('user');
55
55
  }
56
56
  if (errors.length > 0) {
57
- throw (0, types_1.errorMessage)("mariadb", 'Not defined - ' + errors.join(' | '));
57
+ throw (0, types_1.errorMessage)("mariadb", "Invalid credentials", errors.join(', '));
58
58
  }
59
59
  if (credential.host?.endsWith('.rds.amazonaws.com')) {
60
60
  try {
@@ -71,9 +71,14 @@ function setCredential(item) {
71
71
  if (!usePool) {
72
72
  return;
73
73
  }
74
+ else if (credential.stream) {
75
+ item.usePool = undefined;
76
+ return;
77
+ }
74
78
  let username, password, pool;
75
79
  if ((0, types_1.isString)(usePool)) {
76
- if (username = credential.user) {
80
+ username = credential.user;
81
+ if (username) {
77
82
  [password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
78
83
  if (pool) {
79
84
  pool.add(item, password);
@@ -87,7 +92,7 @@ function setCredential(item) {
87
92
  }
88
93
  const config = this.getPoolConfig("mariadb", password);
89
94
  if (config) {
90
- const { min, max, idle, queue_idle, timeout, socket_timeout } = config;
95
+ const { min, max, idle, queue_idle, timeout, socket_timeout, server_timeout } = config;
91
96
  if (min >= 0) {
92
97
  credential.minimumIdle ??= min;
93
98
  }
@@ -106,6 +111,9 @@ function setCredential(item) {
106
111
  if (socket_timeout > 0) {
107
112
  credential.socketTimeout ??= socket_timeout;
108
113
  }
114
+ if (server_timeout > 0) {
115
+ credential.initializationTimeout = server_timeout;
116
+ }
109
117
  }
110
118
  const poolKey = DbPool.asString(credential);
111
119
  if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
package/client/pool.js CHANGED
@@ -3,6 +3,8 @@ const types_1 = require("@e-mc/types");
3
3
  const DbPool = require('@e-mc/db/pool');
4
4
  const POOL_ACTIVE = new WeakSet();
5
5
  class MariaDBPool extends DbPool {
6
+ static CACHE_UNUSED = ['connectTimeout', 'socketTimeout', 'compress', 'keepAliveDelay', 'acquireTimeout', 'connectionLimit', 'idleTimeout', 'initializationTimeout', 'minDelayValidation', 'minimumIdle', 'resetAfterUse', 'noControlAfterUse', 'leakDetectionTimeout'];
7
+ static CACHE_IGNORE = ['initSql', 'sessionVariables', 'stream', 'infileStreamFactory'];
6
8
  static asString(credential) {
7
9
  if ((credential.host || credential.socketPath) && credential.user) {
8
10
  return JSON.stringify(this.removeUUIDKey(credential));
@@ -10,6 +12,9 @@ class MariaDBPool extends DbPool {
10
12
  return super.asString(credential);
11
13
  }
12
14
  static sanitize(credential) {
15
+ if (!this.canCache(credential)) {
16
+ return;
17
+ }
13
18
  if (!POOL_ACTIVE.has(credential) || credential.uuidKey) {
14
19
  return credential;
15
20
  }
@@ -24,10 +29,10 @@ class MariaDBPool extends DbPool {
24
29
  result.ssl = { cert };
25
30
  }
26
31
  else if (Buffer.isBuffer(cert)) {
27
- result.ssl = { cert: cert.toString('utf-8') };
32
+ result.ssl = { cert: cert.toString('utf8') };
28
33
  }
29
34
  else if ((0, types_1.isArray)(cert)) {
30
- result.ssl = { cert: cert.reduce((a, b) => a + (Buffer.isBuffer(b) ? b.toString('utf-8') : b), '') };
35
+ result.ssl = { cert: cert.reduce((a, b) => a + (Buffer.isBuffer(b) ? b.toString('utf8') : b), '') };
31
36
  }
32
37
  else {
33
38
  result.ssl = { cert: "Unknown" };
@@ -52,5 +57,4 @@ class MariaDBPool extends DbPool {
52
57
  return this.client.closed;
53
58
  }
54
59
  }
55
- MariaDBPool.CACHE_UNUSED = ['connectTimeout', 'socketTimeout', 'compress', 'keepAliveDelay', 'acquireTimeout', 'connectionLimit', 'idleTimeout', 'initializationTimeout', 'minDelayValidation', 'minimumIdle', 'resetAfterUse', 'noControlAfterUse', 'leakDetectionTimeout'];
56
60
  module.exports = MariaDBPool;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/mariadb",
3
- "version": "0.9.4",
3
+ "version": "0.10.1",
4
4
  "description": "MariaDB client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/pi-r#readme",
22
22
  "dependencies": {
23
- "@e-mc/db": "^0.11.5",
24
- "@e-mc/types": "^0.11.5",
25
- "mariadb": "^3.4.0"
23
+ "@e-mc/db": "^0.12.3",
24
+ "@e-mc/types": "^0.12.3",
25
+ "mariadb": "^3.4.2"
26
26
  }
27
27
  }