@e-mc/db 0.5.3 → 0.6.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.
Files changed (4) hide show
  1. package/index.js +6 -16
  2. package/package.json +4 -4
  3. package/util.d.ts +1 -0
  4. package/util.js +12 -3
package/index.js CHANGED
@@ -225,24 +225,12 @@ class Db extends core_1.ClientDb {
225
225
  resolveSource(source, folder) {
226
226
  let result;
227
227
  if (source[0] !== '@') {
228
- switch (source) {
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
- }
228
+ result = this.settings.imports?.[source] || util_1.IMPORTS[source];
241
229
  }
242
- else if ((result = source).indexOf('/') === -1) {
243
- folder || (folder = 'client');
230
+ else if (!folder && source.indexOf('/') === -1) {
231
+ folder = 'client';
244
232
  }
245
- return result + (folder ? '/' + folder : '');
233
+ return (result || source) + (folder ? '/' + folder : '');
246
234
  }
247
235
  getPoolConfig(source, uuidKey) {
248
236
  const config = Db.getPoolConfig(source);
@@ -286,6 +274,8 @@ class Db extends core_1.ClientDb {
286
274
  throw (0, types_1.errorMessage)(source, "Database provider not found" /* ERR_DB.PROVIDER_NOTFOUND */);
287
275
  }
288
276
  }
277
+ Db.STORE_RESULT_PARTITION_SIZE = 16 /* CACHE_SIZE.DB_PARTITION_SIZE */;
278
+ Db.STORE_RESULT_PARTITION_MULT = 2 /* CACHE_SIZE.DB_PARTITION_MULT */;
289
279
  Object.freeze(types_1.DB_TYPE);
290
280
  Object.freeze(util_1.SQL_COMMAND);
291
281
  exports.default = Db;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/db",
3
- "version": "0.5.3",
3
+ "version": "0.6.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.5.3",
24
- "@e-mc/request": "0.5.3",
25
- "@e-mc/types": "0.5.3"
23
+ "@e-mc/core": "0.6.0",
24
+ "@e-mc/request": "0.6.0",
25
+ "@e-mc/types": "0.6.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 = exports.SQL_COMMAND || (exports.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) {