@pi-r/oracle 0.6.7 → 0.7.1

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
@@ -37,7 +37,7 @@ class OraclePool extends DbPool {
37
37
  }
38
38
  const DRIVER_MODE = process.env.NODE_ORACLEDB_DRIVER_MODE;
39
39
  const POOL_STATE = {};
40
- const POOL_UNUSED = ['poolMax', 'poolMin', 'poolIncrement', 'poolTimeout', 'poolPingInterval', 'poolMaxPerShard', 'connectTimeout', 'queueMax', 'queueRequests', 'queueTimeout'];
40
+ const POOL_UNUSED = ['connectTimeout', 'transportConnectTimeout', 'expireTime', 'poolMax', 'poolMin', 'poolIncrement', 'poolTimeout', 'poolPingInterval', 'poolMaxPerShard', 'queueMax', 'queueRequests', 'queueTimeout', 'enableStatistics', 'sodaMetaDataCache', 'stmtCacheSize'];
41
41
  const POOL_ACTIVE = new WeakSet();
42
42
  function removePoolProperties(credential) {
43
43
  if (!credential.uuidKey && POOL_ACTIVE.has(credential)) {
@@ -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
  }
@@ -89,31 +89,26 @@ function initOracleClient(credential, type) {
89
89
  this.addLog(this.statusType.WARN, err, 'oracledb', credential.libDir);
90
90
  break;
91
91
  default:
92
- this.writeFail(["Unable to configure client", 'oracledb'], err, { type: type !== null && type !== void 0 ? type : 65536, fatal: false });
92
+ this.writeFail(["Unable to configure client", 'oracledb'], err, { type: type ?? 65536, fatal: false });
93
93
  break;
94
94
  }
95
95
  }
96
96
  }
97
97
  }
98
98
  else {
99
- this.writeFail(["Unable to configure client", 'oracledb'], (0, types_1.errorMessage)('oracledb', 'Environment variable "NODE_ORACLEDB_DRIVER_MODE" was not set', 'thick'), { type: type !== null && type !== void 0 ? type : 65536, fatal: false });
99
+ this.writeFail(["Unable to configure client", 'oracledb'], (0, types_1.errorMessage)('oracledb', 'Environment variable "NODE_ORACLEDB_DRIVER_MODE" was not set', 'thick'), { type: type ?? 65536, fatal: false });
100
100
  }
101
101
  delete credential.libDir;
102
102
  }
103
103
  }
104
104
  exports.initOracleClient = initOracleClient;
105
105
  async function setCredential(item) {
106
- var _a, _b, _c, _d, _e, _f;
107
106
  let credential = this.getCredential(item), hostname, port, username, database;
108
107
  if (credential) {
109
- ({ hostname, port, username } = (0, util_1.parseServerAuth)(credential));
110
- credential.user || (credential.user = username);
111
- if ('database' in credential) {
112
- database = credential.database;
113
- delete credential.database;
114
- }
108
+ ({ hostname, port, database, username } = (0, util_1.parseServerAuth)(credential));
109
+ credential.user ||= username;
115
110
  if ('connectionString' in credential) {
116
- credential.connectString || (credential.connectString = credential.connectionString);
111
+ credential.connectString ||= credential.connectionString;
117
112
  delete credential.connectionString;
118
113
  }
119
114
  }
@@ -132,7 +127,7 @@ async function setCredential(item) {
132
127
  item.credential = credential;
133
128
  }
134
129
  if (hostname) {
135
- credential.connectString || (credential.connectString = hostname + (port ? ':' + port : '') + (database ? '/' + database : ''));
130
+ credential.connectString ||= hostname + (port ? ':' + port : '') + (database ? '/' + database : '');
136
131
  }
137
132
  if (credential.externalAuth) {
138
133
  delete credential.user;
@@ -192,22 +187,22 @@ async function setCredential(item) {
192
187
  if (config) {
193
188
  const { min, max, idle, queue_max, queue_idle, timeout } = config;
194
189
  if (min >= 0) {
195
- (_a = credential.poolMin) !== null && _a !== void 0 ? _a : (credential.poolMin = min);
190
+ credential.poolMin ??= min;
196
191
  }
197
192
  if (max > 0) {
198
- (_b = credential.poolMax) !== null && _b !== void 0 ? _b : (credential.poolMax = max);
193
+ credential.poolMax ??= max;
199
194
  }
200
195
  if (idle >= 0) {
201
- (_c = credential.poolTimeout) !== null && _c !== void 0 ? _c : (credential.poolTimeout = idle / 1000);
196
+ credential.poolTimeout ??= idle / 1000;
202
197
  }
203
198
  if (queue_max >= 0) {
204
- (_d = credential.queueMax) !== null && _d !== void 0 ? _d : (credential.queueMax = queue_max);
199
+ credential.queueMax ??= queue_max;
205
200
  }
206
201
  if (queue_idle >= 0) {
207
- (_e = credential.queueTimeout) !== null && _e !== void 0 ? _e : (credential.queueTimeout = queue_idle);
202
+ credential.queueTimeout ??= queue_idle;
208
203
  }
209
204
  if (timeout >= 0) {
210
- (_f = credential.connectTimeout) !== null && _f !== void 0 ? _f : (credential.connectTimeout = idle / 1000);
205
+ credential.connectTimeout ??= idle / 1000;
211
206
  }
212
207
  }
213
208
  const poolKey = getPoolKey(credential);
@@ -223,7 +218,6 @@ async function executeQuery(item, options) {
223
218
  }
224
219
  exports.executeQuery = executeQuery;
225
220
  async function executeBatchQuery(batch, options = '', outResult) {
226
- var _a;
227
221
  const length = batch.length;
228
222
  if (length === 0) {
229
223
  return [];
@@ -246,7 +240,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
246
240
  parallel = !batch.some(item => item.parallel === false);
247
241
  }
248
242
  if (!parallel) {
249
- outResult || (outResult = new Array(length));
243
+ outResult ||= new Array(length);
250
244
  }
251
245
  const caching = this.hasCache("oracle", sessionKey);
252
246
  const tasks = new Array(length);
@@ -290,7 +284,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
290
284
  pool.connected = false;
291
285
  }
292
286
  }
293
- clients.push(client || (client = await oracledb.getConnection((oracleCredential || credential))));
287
+ clients.push(client ||= await oracledb.getConnection((oracleCredential || credential)));
294
288
  if (connectOnce) {
295
289
  if (!parallel) {
296
290
  oracleClient = client;
@@ -300,7 +294,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
300
294
  item.transactionState &= ~64;
301
295
  return client;
302
296
  };
303
- if ((_a = this.host) === null || _a === void 0 ? void 0 : _a.username) {
297
+ if (this.host?.username) {
304
298
  this.applyCommand(...batch);
305
299
  }
306
300
  for (let i = 0; i < length; ++i) {
@@ -324,7 +318,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
324
318
  continue;
325
319
  }
326
320
  item.transactionState = 1;
327
- 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;
328
322
  const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
329
323
  let queryString = '';
330
324
  if (caching && ignoreCache !== true && !streamRow) {
@@ -383,7 +377,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
383
377
  }
384
378
  rows.push(row);
385
379
  })
386
- .on('error', err => error || (error = err))
380
+ .on('error', err => error ||= err)
387
381
  .on('close', () => {
388
382
  if (error && this.handleFail(error, item, { errorQuery, commandType })) {
389
383
  reject(error);
@@ -421,7 +415,13 @@ async function executeBatchQuery(batch, options = '', outResult) {
421
415
  }
422
416
  }
423
417
  return this.processRows(batch, tasks, {
424
- 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
+ }),
425
425
  parallel
426
426
  }, outResult);
427
427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/oracle",
3
- "version": "0.6.7",
3
+ "version": "0.7.1",
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.8",
25
- "@e-mc/types": "^0.8.8",
26
- "oracledb": "^6.4.0"
24
+ "@e-mc/db": "^0.9.2",
25
+ "@e-mc/types": "^0.9.2",
26
+ "oracledb": "^6.5.1"
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