@e-mc/db 0.5.3 → 0.7.0
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/index.js +8 -16
- package/package.json +4 -4
- package/util.d.ts +1 -0
- package/util.js +12 -3
package/index.js
CHANGED
|
@@ -14,6 +14,8 @@ function sanitizePoolConfig(value) {
|
|
|
14
14
|
value.queue_max ?? (value.queue_max = -1);
|
|
15
15
|
value.queue_idle ?? (value.queue_idle = -1);
|
|
16
16
|
value.purge ?? (value.purge = 0);
|
|
17
|
+
value.timeout ?? (value.timeout = -1);
|
|
18
|
+
value.socket_timeout ?? (value.socket_timeout = -1);
|
|
17
19
|
return value;
|
|
18
20
|
}
|
|
19
21
|
function setCert(items, cache) {
|
|
@@ -225,24 +227,12 @@ class Db extends core_1.ClientDb {
|
|
|
225
227
|
resolveSource(source, folder) {
|
|
226
228
|
let result;
|
|
227
229
|
if (source[0] !== '@') {
|
|
228
|
-
|
|
229
|
-
case 'mongodb':
|
|
230
|
-
case 'mssql':
|
|
231
|
-
case 'mysql':
|
|
232
|
-
case 'oracle':
|
|
233
|
-
case 'postgres':
|
|
234
|
-
case 'redis':
|
|
235
|
-
result = '@pi-r/' + source;
|
|
236
|
-
break;
|
|
237
|
-
default:
|
|
238
|
-
result = source;
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
230
|
+
result = this.settings.imports?.[source] || util_1.IMPORTS[source];
|
|
241
231
|
}
|
|
242
|
-
else if (
|
|
243
|
-
folder
|
|
232
|
+
else if (!folder && source.indexOf('/') === -1) {
|
|
233
|
+
folder = 'client';
|
|
244
234
|
}
|
|
245
|
-
return result + (folder ? '/' + folder : '');
|
|
235
|
+
return (result || source) + (folder ? '/' + folder : '');
|
|
246
236
|
}
|
|
247
237
|
getPoolConfig(source, uuidKey) {
|
|
248
238
|
const config = Db.getPoolConfig(source);
|
|
@@ -286,6 +276,8 @@ class Db extends core_1.ClientDb {
|
|
|
286
276
|
throw (0, types_1.errorMessage)(source, "Database provider not found" /* ERR_DB.PROVIDER_NOTFOUND */);
|
|
287
277
|
}
|
|
288
278
|
}
|
|
279
|
+
Db.STORE_RESULT_PARTITION_SIZE = 16 /* CACHE_SIZE.DB_PARTITION_SIZE */;
|
|
280
|
+
Db.STORE_RESULT_PARTITION_MULT = 2 /* CACHE_SIZE.DB_PARTITION_MULT */;
|
|
289
281
|
Object.freeze(types_1.DB_TYPE);
|
|
290
282
|
Object.freeze(util_1.SQL_COMMAND);
|
|
291
283
|
exports.default = Db;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "DB modules for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.
|
|
24
|
-
"@e-mc/request": "0.
|
|
25
|
-
"@e-mc/types": "0.
|
|
23
|
+
"@e-mc/core": "0.7.0",
|
|
24
|
+
"@e-mc/request": "0.7.0",
|
|
25
|
+
"@e-mc/types": "0.7.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/util.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { SQL_COMMAND, DbConnection, ServerAuth } from '../types/lib/db';
|
|
|
4
4
|
|
|
5
5
|
declare namespace util {
|
|
6
6
|
const SQL_COMMAND: SQL_COMMAND;
|
|
7
|
+
const IMPORTS: Record<string, string | undefined>;
|
|
7
8
|
function getBasicAuth(auth: AuthValue): string;
|
|
8
9
|
function getBasicAuth(username: unknown, password?: unknown): string;
|
|
9
10
|
function hasBasicAuth(value: string): boolean;
|
package/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasBasicAuth = exports.getBasicAuth = exports.setUUIDKey = exports.checkEmpty = exports.parseConnectionString = exports.parseServerAuth = exports.SQL_COMMAND = void 0;
|
|
3
|
+
exports.hasBasicAuth = exports.getBasicAuth = exports.setUUIDKey = exports.checkEmpty = exports.parseConnectionString = exports.parseServerAuth = exports.IMPORTS = exports.SQL_COMMAND = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const util_1 = require("../request/util");
|
|
6
6
|
Object.defineProperty(exports, "getBasicAuth", { enumerable: true, get: function () { return util_1.getBasicAuth; } });
|
|
@@ -11,7 +11,16 @@ var SQL_COMMAND;
|
|
|
11
11
|
SQL_COMMAND[SQL_COMMAND["INSERT"] = 2] = "INSERT";
|
|
12
12
|
SQL_COMMAND[SQL_COMMAND["UPDATE"] = 3] = "UPDATE";
|
|
13
13
|
SQL_COMMAND[SQL_COMMAND["DELETE"] = 4] = "DELETE";
|
|
14
|
-
})(SQL_COMMAND
|
|
14
|
+
})(SQL_COMMAND || (exports.SQL_COMMAND = SQL_COMMAND = {}));
|
|
15
|
+
exports.IMPORTS = {
|
|
16
|
+
"mongodb": "@pi-r/mongodb",
|
|
17
|
+
"redis": "@pi-r/redis",
|
|
18
|
+
"mysql": "@pi-r/mysql",
|
|
19
|
+
"postgres": "@pi-r/postgres",
|
|
20
|
+
"mssql": "@pi-r/mssql",
|
|
21
|
+
"oracle": "@pi-r/oracle",
|
|
22
|
+
"mariadb": "@pi-r/mariadb"
|
|
23
|
+
};
|
|
15
24
|
function parseServerAuth(credential, port, all) {
|
|
16
25
|
if (typeof port === 'boolean') {
|
|
17
26
|
all = port;
|
|
@@ -91,7 +100,7 @@ function parseConnectionString(value, scheme = 'http') {
|
|
|
91
100
|
}
|
|
92
101
|
exports.parseConnectionString = parseConnectionString;
|
|
93
102
|
function checkEmpty(value) {
|
|
94
|
-
return value === undefined || value === null ? false : value === 0 || (value instanceof Set ? value.size === 0 : (Array.isArray(value) || (0, types_1.isObject)(value)) && value.length === 0);
|
|
103
|
+
return value === undefined || value === null ? false : value === 0 || (value instanceof Set || value instanceof Map ? value.size === 0 : (Array.isArray(value) || (0, types_1.isObject)(value)) && value.length === 0);
|
|
95
104
|
}
|
|
96
105
|
exports.checkEmpty = checkEmpty;
|
|
97
106
|
function setUUIDKey(item, value) {
|