@pi-r/oracle 0.6.1 → 0.6.3
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 +2 -0
- package/client/index.js +21 -15
- package/package.json +4 -4
- package/types/index.d.ts +1 -2
package/README.md
CHANGED
package/client/index.js
CHANGED
|
@@ -56,8 +56,12 @@ function removePoolProperties(credential) {
|
|
|
56
56
|
return credential;
|
|
57
57
|
}
|
|
58
58
|
function getPoolKey(credential) {
|
|
59
|
-
if (credential.connectString && (credential.user && credential.password || credential.externalAuth)) {
|
|
60
|
-
|
|
59
|
+
if (credential.connectString && (credential.user && credential.password || credential.externalAuth) || credential.poolAlias) {
|
|
60
|
+
if ('uuidKey' in credential) {
|
|
61
|
+
credential = { ...credential };
|
|
62
|
+
delete credential.uuidKey;
|
|
63
|
+
}
|
|
64
|
+
return JSON.stringify(credential);
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
const useLibDir = () => process.platform === 'win32' || process.platform === 'darwin' && process.arch === 'x64';
|
|
@@ -157,10 +161,16 @@ async function setCredential(item) {
|
|
|
157
161
|
}
|
|
158
162
|
const poolAlias = credential.poolAlias;
|
|
159
163
|
let password, pool;
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
pool
|
|
164
|
+
if ((0, types_1.isString)(usePool)) {
|
|
165
|
+
if (username = credential.user || poolAlias) {
|
|
166
|
+
[password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
|
|
167
|
+
if (pool) {
|
|
168
|
+
pool.add(item, password);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!password) {
|
|
173
|
+
item.usePool = '';
|
|
164
174
|
return;
|
|
165
175
|
}
|
|
166
176
|
}
|
|
@@ -177,15 +187,6 @@ async function setCredential(item) {
|
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
189
|
}
|
|
180
|
-
const poolKey = getPoolKey(credential);
|
|
181
|
-
if (!poolKey) {
|
|
182
|
-
item.usePool = false;
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
|
|
186
|
-
pool.add(item);
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
190
|
const config = this.getPoolConfig("oracle" /* STRINGS.MODULE_NAME */, password);
|
|
190
191
|
if (config) {
|
|
191
192
|
const { min, max, idle, queue_max, queue_idle, timeout } = config;
|
|
@@ -208,6 +209,11 @@ async function setCredential(item) {
|
|
|
208
209
|
credential.connectTimeout ?? (credential.connectTimeout = idle / 1000);
|
|
209
210
|
}
|
|
210
211
|
}
|
|
212
|
+
const poolKey = getPoolKey(credential);
|
|
213
|
+
if ((pool = POOL_STATE[poolKey]) && !pool.closed) {
|
|
214
|
+
pool.add(item);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
211
217
|
new OraclePool(await oracledb.createPool(credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
|
212
218
|
}
|
|
213
219
|
exports.setCredential = setCredential;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/oracle",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Oracle client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/anpham6/pi-r.git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
13
13
|
"directory": "src/db/oracle"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -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.3",
|
|
25
|
+
"@e-mc/types": "^0.8.3",
|
|
26
26
|
"oracledb": "^6.3.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -2,8 +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
|
-
|
|
6
|
-
import type { BindParameters, ConnectionAttributes, ExecuteOptions, PoolAttributes, InitialiseOptions } from 'oracledb';
|
|
5
|
+
import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
|
|
7
6
|
|
|
8
7
|
export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, string | OracleCredential, string>, ExecuteAction<BindParameters> {
|
|
9
8
|
source: "oracle";
|