@pi-r/oracle 0.6.4 → 0.6.6
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 -19
- package/package.json +4 -4
- 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
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
exports.DB_SOURCE_TYPE = exports.DB_SOURCE_CLIENT = exports.checkTimeout = exports.executeBatchQuery = exports.executeQuery = exports.setCredential = exports.initOracleClient = void 0;
|
|
4
3
|
const oracledb = require("oracledb");
|
|
5
4
|
const util_1 = require("@e-mc/db/util");
|
|
@@ -30,10 +29,10 @@ class OraclePool extends DbPool {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
get closeable() {
|
|
33
|
-
return super.closeable || this.client.status === 6001
|
|
32
|
+
return super.closeable || this.client.status === 6001;
|
|
34
33
|
}
|
|
35
34
|
get closed() {
|
|
36
|
-
return this.client.status === 6002
|
|
35
|
+
return this.client.status === 6002;
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
const DRIVER_MODE = process.env.NODE_ORACLEDB_DRIVER_MODE;
|
|
@@ -73,7 +72,7 @@ if (DRIVER_MODE === 'thick' && oracledb.thin) {
|
|
|
73
72
|
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
73
|
}
|
|
75
74
|
catch (err) {
|
|
76
|
-
Db.writeFail(["Unable to configure client"
|
|
75
|
+
Db.writeFail(["Unable to configure client", 'oracledb'], err);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
}
|
|
@@ -90,14 +89,14 @@ function initOracleClient(credential, type) {
|
|
|
90
89
|
this.addLog(this.statusType.WARN, err, 'oracledb', credential.libDir);
|
|
91
90
|
break;
|
|
92
91
|
default:
|
|
93
|
-
this.writeFail(["Unable to configure client"
|
|
92
|
+
this.writeFail(["Unable to configure client", 'oracledb'], err, { type: type ?? 65536, fatal: false });
|
|
94
93
|
break;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
else {
|
|
100
|
-
this.writeFail(["Unable to configure client"
|
|
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 });
|
|
101
100
|
}
|
|
102
101
|
delete credential.libDir;
|
|
103
102
|
}
|
|
@@ -152,7 +151,7 @@ async function setCredential(item) {
|
|
|
152
151
|
errors.push('connectString');
|
|
153
152
|
}
|
|
154
153
|
if (errors.length) {
|
|
155
|
-
throw (0, types_1.errorMessage)("oracle"
|
|
154
|
+
throw (0, types_1.errorMessage)("oracle", 'Not defined - ' + errors.join(' | '));
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
initOracleClient.call(this, credential);
|
|
@@ -188,7 +187,7 @@ async function setCredential(item) {
|
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
}
|
|
191
|
-
const config = this.getPoolConfig("oracle"
|
|
190
|
+
const config = this.getPoolConfig("oracle", password);
|
|
192
191
|
if (config) {
|
|
193
192
|
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
194
193
|
if (min >= 0) {
|
|
@@ -247,16 +246,16 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
247
246
|
if (!parallel) {
|
|
248
247
|
outResult || (outResult = new Array(length));
|
|
249
248
|
}
|
|
250
|
-
const caching = this.hasCache("oracle"
|
|
249
|
+
const caching = this.hasCache("oracle", sessionKey);
|
|
251
250
|
const tasks = new Array(length);
|
|
252
251
|
const clients = [];
|
|
253
252
|
let oraclePool, oracleClient, oracleCredential, onceCredential = connectOnce ? batch[0].credential : undefined;
|
|
254
253
|
const getConnection = async (item, credential) => {
|
|
255
|
-
item.transactionState = 64
|
|
254
|
+
item.transactionState = 64;
|
|
256
255
|
let client;
|
|
257
256
|
if (oraclePool) {
|
|
258
257
|
clients.push(client = await oraclePool.getConnection());
|
|
259
|
-
item.transactionState &= ~64
|
|
258
|
+
item.transactionState &= ~64;
|
|
260
259
|
POOL_ACTIVE.add(credential);
|
|
261
260
|
return client;
|
|
262
261
|
}
|
|
@@ -296,7 +295,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
296
295
|
}
|
|
297
296
|
oracleCredential = credential;
|
|
298
297
|
}
|
|
299
|
-
item.transactionState &= ~64
|
|
298
|
+
item.transactionState &= ~64;
|
|
300
299
|
return client;
|
|
301
300
|
};
|
|
302
301
|
if (this.host?.username) {
|
|
@@ -306,7 +305,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
306
305
|
const item = batch[i];
|
|
307
306
|
const { source, query, params, ignoreCache, options: clientOptions } = item;
|
|
308
307
|
let credential = oracleCredential || onceCredential, error;
|
|
309
|
-
if (!credential && !(0, types_1.isPlainObject)(credential = item.credential) && (error = (0, types_1.errorMessage)(source, "Invalid credentials"
|
|
308
|
+
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
309
|
if (this.handleFail(error, item, { errorQuery })) {
|
|
311
310
|
if (!parallel) {
|
|
312
311
|
tasks.length = 0;
|
|
@@ -322,8 +321,8 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
322
321
|
}
|
|
323
322
|
continue;
|
|
324
323
|
}
|
|
325
|
-
item.transactionState = 1
|
|
326
|
-
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle"
|
|
324
|
+
item.transactionState = 1;
|
|
325
|
+
const streamRow = typeof item.streamRow === 'string' ? this.hasCoerce("oracle", 'options', null, credential) && (0, types_1.asFunction)(item.streamRow) : item.streamRow;
|
|
327
326
|
const cacheValue = ignoreCache === undefined ? sessionKey : Array.isArray(ignoreCache) ? { sessionKey, exclusiveOf: ignoreCache } : { sessionKey, renewCache: ignoreCache === 0 };
|
|
328
327
|
let queryString = '';
|
|
329
328
|
if (caching && ignoreCache !== true && !streamRow) {
|
|
@@ -337,7 +336,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
337
336
|
else {
|
|
338
337
|
outResult[i] = result;
|
|
339
338
|
}
|
|
340
|
-
this.add(item, 4
|
|
339
|
+
this.add(item, 4 | 128);
|
|
341
340
|
continue;
|
|
342
341
|
}
|
|
343
342
|
if (!ignoreCache && outCacheMiss) {
|
|
@@ -388,7 +387,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
388
387
|
reject(error);
|
|
389
388
|
}
|
|
390
389
|
else {
|
|
391
|
-
this.add(item, 4
|
|
390
|
+
this.add(item, 4);
|
|
392
391
|
resolve(!error ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : rows);
|
|
393
392
|
}
|
|
394
393
|
})
|
|
@@ -396,7 +395,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
396
395
|
}
|
|
397
396
|
else {
|
|
398
397
|
const { rows } = await client.execute(query, params || [], executeOptions);
|
|
399
|
-
this.add(item, 4
|
|
398
|
+
this.add(item, 4);
|
|
400
399
|
resolve(rows ? this.setQueryResult(source, removePoolProperties(credential), queryString, rows, cacheValue) : null);
|
|
401
400
|
}
|
|
402
401
|
}
|
|
@@ -420,7 +419,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
420
419
|
}
|
|
421
420
|
}
|
|
422
421
|
return this.processRows(batch, tasks, {
|
|
423
|
-
disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection"
|
|
422
|
+
disconnect: () => clients.forEach(item => item.close(err => err && this.writeFail(["Unable to close connnection", "oracle"], err, { type: 65536, fatal: false }))),
|
|
424
423
|
parallel
|
|
425
424
|
}, outResult);
|
|
426
425
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
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.
|
|
26
|
-
"oracledb": "^6.
|
|
24
|
+
"@e-mc/db": "^0.8.7",
|
|
25
|
+
"@e-mc/types": "^0.8.7",
|
|
26
|
+
"oracledb": "^6.4.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> {
|