@pi-r/oracle 0.6.4 → 0.6.5
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/LICENSE +1 -1
- package/README.md +6 -3
- package/client/index.d.ts +1 -0
- package/client/index.js +18 -18
- package/package.json +3 -3
- package/types/index.d.ts +1 -0
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
# @pi-r/oracle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Documentation
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
- [E-mc](https://e-mc.readthedocs.io/en/latest/db/oracle.html)
|
|
6
|
+
- [squared](https://squared.readthedocs.io)
|
|
7
|
+
|
|
8
|
+
## LICENSE
|
|
6
9
|
|
|
7
10
|
MIT
|
package/client/index.d.ts
CHANGED
package/client/index.js
CHANGED
|
@@ -30,10 +30,10 @@ class OraclePool extends DbPool {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
get closeable() {
|
|
33
|
-
return super.closeable || this.client.status === 6001
|
|
33
|
+
return super.closeable || this.client.status === 6001;
|
|
34
34
|
}
|
|
35
35
|
get closed() {
|
|
36
|
-
return this.client.status === 6002
|
|
36
|
+
return this.client.status === 6002;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
const DRIVER_MODE = process.env.NODE_ORACLEDB_DRIVER_MODE;
|
|
@@ -73,7 +73,7 @@ if (DRIVER_MODE === 'thick' && oracledb.thin) {
|
|
|
73
73
|
oracledb.initOracleClient({ libDir, configDir: process.env.NODE_ORACLEDB_CLIENT_CONFIG_DIR, driverName: process.env.NODE_ORACLEDB_CLIENT_DRIVER_NAME, errorUrl: process.env.NODE_ORACLEDB_CLIENT_ERROR_URL });
|
|
74
74
|
}
|
|
75
75
|
catch (err) {
|
|
76
|
-
Db.writeFail(["Unable to configure client"
|
|
76
|
+
Db.writeFail(["Unable to configure client", 'oracledb'], err);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -90,14 +90,14 @@ function initOracleClient(credential, type) {
|
|
|
90
90
|
this.addLog(this.statusType.WARN, err, 'oracledb', credential.libDir);
|
|
91
91
|
break;
|
|
92
92
|
default:
|
|
93
|
-
this.writeFail(["Unable to configure client"
|
|
93
|
+
this.writeFail(["Unable to configure client", 'oracledb'], err, { type: type ?? 65536, fatal: false });
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
|
-
this.writeFail(["Unable to configure client"
|
|
100
|
+
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 });
|
|
101
101
|
}
|
|
102
102
|
delete credential.libDir;
|
|
103
103
|
}
|
|
@@ -152,7 +152,7 @@ async function setCredential(item) {
|
|
|
152
152
|
errors.push('connectString');
|
|
153
153
|
}
|
|
154
154
|
if (errors.length) {
|
|
155
|
-
throw (0, types_1.errorMessage)("oracle"
|
|
155
|
+
throw (0, types_1.errorMessage)("oracle", 'Not defined - ' + errors.join(' | '));
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
initOracleClient.call(this, credential);
|
|
@@ -188,7 +188,7 @@ async function setCredential(item) {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
const config = this.getPoolConfig("oracle"
|
|
191
|
+
const config = this.getPoolConfig("oracle", password);
|
|
192
192
|
if (config) {
|
|
193
193
|
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
194
194
|
if (min >= 0) {
|
|
@@ -247,16 +247,16 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
247
247
|
if (!parallel) {
|
|
248
248
|
outResult || (outResult = new Array(length));
|
|
249
249
|
}
|
|
250
|
-
const caching = this.hasCache("oracle"
|
|
250
|
+
const caching = this.hasCache("oracle", sessionKey);
|
|
251
251
|
const tasks = new Array(length);
|
|
252
252
|
const clients = [];
|
|
253
253
|
let oraclePool, oracleClient, oracleCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
|
|
254
254
|
const getConnection = async (item, credential) => {
|
|
255
|
-
item.transactionState = 64
|
|
255
|
+
item.transactionState = 64;
|
|
256
256
|
let client;
|
|
257
257
|
if (oraclePool) {
|
|
258
258
|
clients.push(client = await oraclePool.getConnection());
|
|
259
|
-
item.transactionState &= ~64
|
|
259
|
+
item.transactionState &= ~64;
|
|
260
260
|
POOL_ACTIVE.add(credential);
|
|
261
261
|
return client;
|
|
262
262
|
}
|
|
@@ -296,7 +296,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
296
296
|
}
|
|
297
297
|
oracleCredential = credential;
|
|
298
298
|
}
|
|
299
|
-
item.transactionState &= ~64
|
|
299
|
+
item.transactionState &= ~64;
|
|
300
300
|
return client;
|
|
301
301
|
};
|
|
302
302
|
if (this.host?.username) {
|
|
@@ -306,7 +306,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
306
306
|
const item = batch[i];
|
|
307
307
|
const { source, query, params, ignoreCache, options: clientOptions } = item;
|
|
308
308
|
let credential = oracleCredential || onceCredential, error;
|
|
309
|
-
if (!credential && !(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials"
|
|
309
|
+
if (!credential && !(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials")) || !query && (error = (0, types_1.errorMessage)(source, "Missing database query"))) {
|
|
310
310
|
if (this.handleFail(error, item, { errorQuery })) {
|
|
311
311
|
if (!parallel) {
|
|
312
312
|
tasks.length = 0;
|
|
@@ -322,8 +322,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
322
322
|
}
|
|
323
323
|
continue;
|
|
324
324
|
}
|
|
325
|
-
item.transactionState = 1
|
|
326
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle"
|
|
325
|
+
item.transactionState = 1;
|
|
326
|
+
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
|
|
327
327
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
328
328
|
let queryString = '';
|
|
329
329
|
if (caching && ignoreCache !== true && !streamRow) {
|
|
@@ -337,7 +337,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
337
337
|
else {
|
|
338
338
|
outResult[i] = result;
|
|
339
339
|
}
|
|
340
|
-
this.add(item, 4
|
|
340
|
+
this.add(item, 4 | 128);
|
|
341
341
|
continue;
|
|
342
342
|
}
|
|
343
343
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -388,7 +388,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
388
388
|
reject(error);
|
|
389
389
|
}
|
|
390
390
|
else {
|
|
391
|
-
this.add(item, 4
|
|
391
|
+
this.add(item, 4);
|
|
392
392
|
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows);
|
|
393
393
|
}
|
|
394
394
|
})
|
|
@@ -396,7 +396,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
396
396
|
}
|
|
397
397
|
else {
|
|
398
398
|
const { rows } = await client.execute(query, params || [], executeOptions);
|
|
399
|
-
this.add(item, 4
|
|
399
|
+
this.add(item, 4);
|
|
400
400
|
resolve(rows ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : null);
|
|
401
401
|
}
|
|
402
402
|
}
|
|
@@ -420,7 +420,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
return this.processRows(batch, tasks, {
|
|
423
|
-
disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection"
|
|
423
|
+
disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false }))),
|
|
424
424
|
parallel
|
|
425
425
|
}, outResult);
|
|
426
426
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
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.
|
|
25
|
-
"@e-mc/types": "^0.8.
|
|
24
|
+
"@e-mc/db": "^0.8.6",
|
|
25
|
+
"@e-mc/types": "^0.8.6",
|
|
26
26
|
"oracledb": "^6.3.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { DbDataSource } from '@e-mc/types/lib/squared';
|
|
|
2
2
|
|
|
3
3
|
import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
|
|
4
4
|
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
|
|
6
7
|
|
|
7
8
|
export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, string | OracleCredential, string>, ExecuteAction<BindParameters> {
|