@e-mc/db 0.13.7 → 0.13.9

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 (3) hide show
  1. package/README.md +9 -9
  2. package/index.js +21 -19
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/db
2
2
 
3
- * NodeJS 18.20.5 LTS
3
+ * NodeJS 18.20 LTS
4
4
  * ES2022
5
5
 
6
6
  ## General Usage
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.13.7/lib/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.13.9/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { DbDataSource } from "./squared";
@@ -31,8 +31,8 @@ interface IDb extends IClientDb<IHost, DbModule, DbDataSource, DbSourceOptions,
31
31
  executeQuery(item: DbDataSource, sessionKey: string): Promise<QueryResult>;
32
32
  executeQuery(item: DbDataSource, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
33
33
  executeBatchQuery(batch: DbDataSource[], callback: ErrorQueryCallback, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
34
- executeBatchQuery(batch: DbDataSource[], sessionKey: string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
35
- executeBatchQuery(batch: DbDataSource[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
34
+ executeBatchQuery(batch: DbDataSource[], sessionKey: string | undefined, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
35
+ executeBatchQuery(batch: DbDataSource[], options?: ExecuteBatchQueryOptions, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
36
36
  processRows(batch: DbDataSource[], tasks: Promise<QueryResult | null>[], parallel: boolean): Promise<BatchQueryResult>;
37
37
  processRows(batch: DbDataSource[], tasks: Promise<QueryResult | null>[], options?: ProcessRowsOptions | boolean, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
38
38
  handleFail(err: unknown, item: DbDataSource, options?: HandleFailOptions): boolean;
@@ -214,11 +214,11 @@ const [rows1, rows2] = await instance.executeBatchQuery([
214
214
 
215
215
  ## References
216
216
 
217
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/squared.d.ts
218
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/core.d.ts
219
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/db.d.ts
220
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/http.d.ts
221
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/settings.d.ts
217
+ - https://www.unpkg.com/@e-mc/types@0.13.9/lib/squared.d.ts
218
+ - https://www.unpkg.com/@e-mc/types@0.13.9/lib/core.d.ts
219
+ - https://www.unpkg.com/@e-mc/types@0.13.9/lib/db.d.ts
220
+ - https://www.unpkg.com/@e-mc/types@0.13.9/lib/http.d.ts
221
+ - https://www.unpkg.com/@e-mc/types@0.13.9/lib/settings.d.ts
222
222
 
223
223
  * https://www.npmjs.com/package/@types/node
224
224
 
package/index.js CHANGED
@@ -61,7 +61,10 @@ class Db extends core_1.ClientDb {
61
61
  return this.getClient(item.source).setCredential.call(this, item);
62
62
  }
63
63
  catch (err) {
64
- return Promise.reject(err instanceof Error ? err : new Error(Db.asString(err) || "Invalid credentials"));
64
+ if (err instanceof Error) {
65
+ throw err;
66
+ }
67
+ throw new Error("Invalid credentials", { cause: err });
65
68
  }
66
69
  }
67
70
  getCredential(item) {
@@ -92,26 +95,25 @@ class Db extends core_1.ClientDb {
92
95
  for (let i = 0, length = items.length; i < length; ++i) {
93
96
  const item = items[i];
94
97
  const command = item.withCommand;
95
- if (!command) {
96
- continue;
97
- }
98
- if (!settings && !(0, types_1.isPlainObject)(settings = this.getUserSettings()?.[item.source]?.commands)) {
99
- return;
100
- }
101
- let name, table;
102
- const [group, procedure] = Array.isArray(command) ? command : ({ name, table } = item, [(name || table ? name && table ? name + ':' + table : table || name : typeof item.document === 'string' && item.document) || '', command]);
103
- const data = settings[group]?.[procedure];
104
- if ((0, types_1.isPlainObject)(data)) {
105
- if ('uri' in data) {
106
- delete data.uri;
107
- }
108
- if ('credential' in data) {
109
- delete data.credential;
98
+ if (command) {
99
+ if (!settings && !(0, types_1.isPlainObject)(settings = this.getUserSettings()?.[item.source]?.commands)) {
100
+ return;
110
101
  }
111
- if ('usePool' in data) {
112
- delete data.usePool;
102
+ let name, table;
103
+ const [group, procedure] = Array.isArray(command) ? command : ({ name, table } = item, [(name || table ? name && table ? name + ':' + table : table || name : typeof item.document === 'string' && item.document) || '', command]);
104
+ const data = settings[group]?.[procedure];
105
+ if ((0, types_1.isPlainObject)(data)) {
106
+ if ('uri' in data) {
107
+ delete data.uri;
108
+ }
109
+ if ('credential' in data) {
110
+ delete data.credential;
111
+ }
112
+ if ('usePool' in data) {
113
+ delete data.usePool;
114
+ }
115
+ Object.assign(item, data);
113
116
  }
114
- Object.assign(item, data);
115
117
  }
116
118
  }
117
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/db",
3
- "version": "0.13.7",
3
+ "version": "0.13.9",
4
4
  "description": "DB modules for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "license": "BSD-3-Clause",
20
20
  "homepage": "https://github.com/anpham6/e-mc#readme",
21
21
  "dependencies": {
22
- "@e-mc/core": "0.13.7",
23
- "@e-mc/request": "0.13.7",
24
- "@e-mc/types": "0.13.7"
22
+ "@e-mc/core": "0.13.9",
23
+ "@e-mc/request": "0.13.9",
24
+ "@e-mc/types": "0.13.9"
25
25
  }
26
26
  }