@pi-r/oracle 0.6.6 → 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/README.md CHANGED
@@ -1,10 +1,7 @@
1
- # @pi-r/oracle
1
+ ### @pi-r/oracle
2
2
 
3
- ## Documentation
3
+ https://e-mc.readthedocs.io/en/latest/db/oracle.html
4
4
 
5
- - [E-mc](https://e-mc.readthedocs.io/en/latest/db/oracle.html)
6
- - [squared](https://squared.readthedocs.io)
7
-
8
- ## LICENSE
5
+ ### LICENSE
9
6
 
10
7
  MIT
package/client/index.d.ts CHANGED
@@ -4,7 +4,6 @@ import type { IDbSourceClient } from '@e-mc/db/types';
4
4
 
5
5
  import type { OracleDataSource } from '../types';
6
6
 
7
- // @ts-ignore
8
7
  import type { InitialiseOptions } from 'oracledb';
9
8
 
10
9
  declare const Oracle: IDbSourceClient<OracleDataSource> & {
package/client/index.js CHANGED
@@ -45,7 +45,7 @@ function removePoolProperties(credential) {
45
45
  for (let i = 0, length = POOL_UNUSED.length; i < length; ++i) {
46
46
  const attr = POOL_UNUSED[i];
47
47
  if (attr in credential) {
48
- result || (result = { ...credential });
48
+ result ||= { ...credential };
49
49
  delete result[attr];
50
50
  }
51
51
  }
@@ -105,14 +105,10 @@ exports.initOracleClient = initOracleClient;
105
105
  async function setCredential(item) {
106
106
  let credential = this.getCredential(item), hostname, port, username, database;
107
107
  if (credential) {
108
- ({ hostname, port, username } = (0, util_1.parseServerAuth)(credential));
109
- credential.user || (credential.user = username);
110
- if ('database' in credential) {
111
- database = credential.database;
112
- delete credential.database;
113
- }
108
+ ({ hostname, port, database, username } = (0, util_1.parseServerAuth)(credential));
109
+ credential.user ||= username;
114
110
  if ('connectionString' in credential) {
115
- credential.connectString || (credential.connectString = credential.connectionString);
111
+ credential.connectString ||= credential.connectionString;
116
112
  delete credential.connectionString;
117
113
  }
118
114
  }
@@ -131,7 +127,7 @@ async function setCredential(item) {
131
127
  item.credential = credential;
132
128
  }
133
129
  if (hostname) {
134
- credential.connectString || (credential.connectString = hostname + (port ? ':' + port : '') + (database ? '/' + database : ''));
130
+ credential.connectString ||= hostname + (port ? ':' + port : '') + (database ? '/' + database : '');
135
131
  }
136
132
  if (credential.externalAuth) {
137
133
  delete credential.user;
@@ -191,22 +187,22 @@ async function setCredential(item) {
191
187
  if (config) {
192
188
  const { min, max, idle, queue_max, queue_idle, timeout } = config;
193
189
  if (min >= 0) {
194
- credential.poolMin ?? (credential.poolMin = min);
190
+ credential.poolMin ??= min;
195
191
  }
196
192
  if (max > 0) {
197
- credential.poolMax ?? (credential.poolMax = max);
193
+ credential.poolMax ??= max;
198
194
  }
199
195
  if (idle >= 0) {
200
- credential.poolTimeout ?? (credential.poolTimeout = idle / 1000);
196
+ credential.poolTimeout ??= idle / 1000;
201
197
  }
202
198
  if (queue_max >= 0) {
203
- credential.queueMax ?? (credential.queueMax = queue_max);
199
+ credential.queueMax ??= queue_max;
204
200
  }
205
201
  if (queue_idle >= 0) {
206
- credential.queueTimeout ?? (credential.queueTimeout = queue_idle);
202
+ credential.queueTimeout ??= queue_idle;
207
203
  }
208
204
  if (timeout >= 0) {
209
- credential.connectTimeout ?? (credential.connectTimeout = idle / 1000);
205
+ credential.connectTimeout ??= idle / 1000;
210
206
  }
211
207
  }
212
208
  const poolKey = getPoolKey(credential);
@@ -244,7 +240,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
244
240
  parallel = !batch.some(item => item.parallel === false);
245
241
  }
246
242
  if (!parallel) {
247
- outResult || (outResult = new Array(length));
243
+ outResult ||= new Array(length);
248
244
  }
249
245
  const caching = this.hasCache("oracle", sessionKey);
250
246
  const tasks = new Array(length);
@@ -288,7 +284,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
288
284
  pool.connected = false;
289
285
  }
290
286
  }
291
- clients.push(client || (client = await oracledb.getConnection((oracleCredential || credential))));
287
+ clients.push(client ||= await oracledb.getConnection((oracleCredential || credential)));
292
288
  if (connectOnce) {
293
289
  if (!parallel) {
294
290
  oracleClient = client;
@@ -322,7 +318,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
322
318
  continue;
323
319
  }
324
320
  item.transactionState = 1;
325
- const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
321
+ const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
326
322
  const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
327
323
  let queryString = '';
328
324
  if (caching && ignoreCache !== true && !streamRow) {
@@ -381,7 +377,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
381
377
  }
382
378
  rows.push(row);
383
379
  })
384
- .on('error', err => error || (error = err))
380
+ .on('error', err => error ||= err)
385
381
  .on('close', () => {
386
382
  if (error && this.handleFail(error, item, { errorQuery, commandType })) {
387
383
  reject(error);
@@ -419,7 +415,13 @@ async function executeBatchQuery(batch, options = '', outResult) {
419
415
  }
420
416
  }
421
417
  return this.processRows(batch, tasks, {
422
- disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false }))),
418
+ disconnect: () => clients.forEach(item => {
419
+ item.close(err => {
420
+ if (err) {
421
+ this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false });
422
+ }
423
+ });
424
+ }),
423
425
  parallel
424
426
  }, outResult);
425
427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oracle",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "Oracle client driver for E-mc.",
5
5
  "main": "client/index.js",
6
6
  "types": "client/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/anpham6/pi-r#readme",
23
23
  "dependencies": {
24
- "@e-mc/db": "^0.8.7",
25
- "@e-mc/types": "^0.8.7",
24
+ "@e-mc/db": "^0.9.0",
25
+ "@e-mc/types": "^0.9.0",
26
26
  "oracledb": "^6.4.0"
27
27
  }
28
28
  }
package/types/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
5
5
  // @ts-ignore
6
6
  import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
7
7
 
8
- export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, string | OracleCredential, string>, ExecuteAction<BindParameters> {
8
+ export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, OracleCredential, string>, ExecuteAction<BindParameters> {
9
9
  source: "oracle";
10
10
  }
11
11