@e-mc/db 0.14.0 → 0.14.2

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/README.md +12 -10
  2. package/index.js +1 -1
  3. package/package.json +4 -7
  4. package/pool.js +14 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.14.0/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.14.2/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DbDataSource } from "./squared";
@@ -18,11 +18,11 @@ import type { IHost } from "./index";
18
18
  import type { ClientDbConstructor, IClientDb } from "./core";
19
19
  import type { BatchQueryResult, DB_TYPE, ErrorQueryCallback, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, ProcessRowsOptions, QueryResult, SQL_COMMAND } from "./db";
20
20
  import type { AuthValue } from "./http";
21
- import type { DbCoerceSettings, DbModule, DbSettings, DbSourceOptions, PoolConfig } from "./settings";
21
+ import type { DbCacheSettings, DbCoerceSettings, DbModule, DbSettings, DbSourceOptions, PoolConfig } from "./settings";
22
22
 
23
23
  import type { SecureContextOptions } from "node:tls";
24
24
 
25
- interface IDb extends IClientDb<IHost, DbModule, DbDataSource, DbSourceOptions, DbCoerceSettings> {
25
+ interface IDb extends IClientDb<IHost, DbModule, DbDataSource, DbSourceOptions, DbCoerceSettings & DbCacheSettings> {
26
26
  setCredential(item: DbDataSource): Promise<void>;
27
27
  getCredential(item: DbDataSource): Record<string | number | symbol, unknown>;
28
28
  hasSource(source: string, ...type: number[]): boolean;
@@ -39,8 +39,10 @@ interface IDb extends IClientDb<IHost, DbModule, DbDataSource, DbSourceOptions,
39
39
  readTLSCert(value: unknown, cache?: boolean): string;
40
40
  readTLSConfig(options: SecureContextOptions, cache?: boolean): void;
41
41
  settingsOf(source: string, name: keyof Omit<DbSourceOptions, "coerce">): unknown;
42
+ settingsOf(source: string, name: "cache", component: keyof DbCacheSettings): unknown;
42
43
  settingsOf(source: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
43
44
  settingsKey(source: string, name: keyof Omit<DbSourceOptions, "coerce">): unknown;
45
+ settingsKey(source: string, name: "cache", component: keyof DbCacheSettings): unknown;
44
46
  settingsKey(source: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
45
47
  getPoolConfig(source: string, uuidKey?: string): Required<PoolConfig> | undefined;
46
48
  get sourceType(): DB_TYPE;
@@ -114,7 +116,7 @@ interface DbPoolConstructor {
114
116
  ## Settings
115
117
 
116
118
  ```typescript
117
- import type { DbSourceOptions, PurgeComponent } from "./settings";
119
+ import type { DbSourceOptions, ImportModule, PurgeComponent } from "./settings";
118
120
 
119
121
  interface DbModule {
120
122
  // handler: "@e-mc/db";
@@ -134,7 +136,7 @@ interface DbModule {
134
136
  };
135
137
  session_expires?: number;
136
138
  user_key?: Record<string, DbSourceOptions>;
137
- imports?: StringMap;
139
+ imports?: ImportModule;
138
140
  purge?: PurgeComponent;
139
141
  mariadb?: DbSourceOptions;
140
142
  mongodb?: DbSourceOptions;
@@ -219,11 +221,11 @@ const [rows1, rows2] = await instance.executeBatchQuery([
219
221
 
220
222
  ## References
221
223
 
222
- - https://www.unpkg.com/@e-mc/types@0.14.0/lib/squared.d.ts
223
- - https://www.unpkg.com/@e-mc/types@0.14.0/lib/core.d.ts
224
- - https://www.unpkg.com/@e-mc/types@0.14.0/lib/db.d.ts
225
- - https://www.unpkg.com/@e-mc/types@0.14.0/lib/http.d.ts
226
- - https://www.unpkg.com/@e-mc/types@0.14.0/lib/settings.d.ts
224
+ - https://www.unpkg.com/@e-mc/types@0.14.2/lib/squared.d.ts
225
+ - https://www.unpkg.com/@e-mc/types@0.14.2/lib/core.d.ts
226
+ - https://www.unpkg.com/@e-mc/types@0.14.2/lib/db.d.ts
227
+ - https://www.unpkg.com/@e-mc/types@0.14.2/lib/http.d.ts
228
+ - https://www.unpkg.com/@e-mc/types@0.14.2/lib/settings.d.ts
227
229
 
228
230
  * https://www.npmjs.com/package/@types/node
229
231
 
package/index.js CHANGED
@@ -89,7 +89,7 @@ class Db extends ClientDb {
89
89
  stored = true;
90
90
  }
91
91
  if (isPlainObject(credential)) {
92
- if (this.settingsOf(item.source, 'coerce', 'credential') === true) {
92
+ if (this.hasCoerce(item.source, 'credential')) {
93
93
  coerceObject(credential, stored);
94
94
  }
95
95
  return stored ? item.credential = { ...credential } : credential;
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@e-mc/db",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "DB modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
7
  "repository": {
11
8
  "type": "git",
12
9
  "url": "git+https://github.com/anpham6/e-mc.git",
@@ -19,8 +16,8 @@
19
16
  "license": "BSD-3-Clause",
20
17
  "homepage": "https://github.com/anpham6/e-mc#readme",
21
18
  "dependencies": {
22
- "@e-mc/core": "0.14.0",
23
- "@e-mc/request": "0.14.0",
24
- "@e-mc/types": "0.14.0"
19
+ "@e-mc/core": "0.14.2",
20
+ "@e-mc/request": "0.14.2",
21
+ "@e-mc/types": "0.14.2"
25
22
  }
26
23
  }
package/pool.js CHANGED
@@ -24,8 +24,21 @@ class DbPool {
24
24
  }
25
25
  return true;
26
26
  }
27
- static sanitize(credential) {
27
+ static sanitize(credential, sort) {
28
28
  const properties = this.CACHE_UNUSED;
29
+ if (sort) {
30
+ const items = Object.entries(credential);
31
+ for (let i = 0, j = properties.length; i < j; ++i) {
32
+ const attr = properties[i];
33
+ for (let k = 0, l = items.length; k < l; ++k) {
34
+ if (items[k][0] === attr) {
35
+ items[k][1] = undefined;
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ return Object.fromEntries(items.sort());
41
+ }
29
42
  let result;
30
43
  for (let i = 0, length = properties.length; i < length; ++i) {
31
44
  const attr = properties[i];