@pi-r/oracle 0.7.2 → 0.7.4

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,7 +1,7 @@
1
- ### @pi-r/oracle
2
-
3
- https://e-mc.readthedocs.io/en/latest/db/oracle.html
4
-
5
- ### LICENSE
6
-
1
+ ### @pi-r/oracle
2
+
3
+ https://e-mc.readthedocs.io/en/latest/db/oracle.html
4
+
5
+ ### LICENSE
6
+
7
7
  MIT
package/client/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import type { IModule } from '@e-mc/types/lib';
2
- import type { LogType } from '@e-mc/types/lib/logger';
3
- import type { IDbSourceClient } from '@e-mc/db/types';
4
-
5
- import type { OracleDataSource } from '../types';
6
-
7
- import type { InitialiseOptions } from 'oracledb';
8
-
9
- declare const Oracle: IDbSourceClient<OracleDataSource> & {
10
- initOracleClient(this: IModule, credential: InitialiseOptions, type?: LogType): void;
11
- };
12
-
1
+ import type { IModule } from '@e-mc/types/lib';
2
+ import type { LogType } from '@e-mc/types/lib/logger';
3
+ import type { IDbSourceClient } from '@e-mc/db/types';
4
+
5
+ import type { OracleDataSource } from '../types';
6
+
7
+ import type { InitialiseOptions } from 'oracledb';
8
+
9
+ declare const Oracle: IDbSourceClient<OracleDataSource> & {
10
+ initOracleClient(this: IModule, credential: InitialiseOptions, type?: LogType): void;
11
+ };
12
+
13
13
  export = Oracle;
package/client/pool.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ const DbPool = require('@e-mc/db/pool');
3
+ const POOL_ACTIVE = new WeakSet();
4
+ class OraclePool extends DbPool {
5
+ static asString(credential) {
6
+ if (credential.connectString && (credential.user && credential.password || credential.externalAuth) || credential.poolAlias) {
7
+ return JSON.stringify(this.removeUUIDKey(credential));
8
+ }
9
+ return super.asString(credential);
10
+ }
11
+ static sanitize(credential) {
12
+ if (!POOL_ACTIVE.has(credential) || credential.uuidKey) {
13
+ return credential;
14
+ }
15
+ return super.sanitize(credential);
16
+ }
17
+ get closeable() {
18
+ return super.closeable || this.client.status === 6001;
19
+ }
20
+ async getConnection(credential) {
21
+ if (credential) {
22
+ POOL_ACTIVE.add(credential);
23
+ }
24
+ return this.client.getConnection();
25
+ }
26
+ async close() {
27
+ return this.client.close();
28
+ }
29
+ isEmpty() {
30
+ if (this.closed) {
31
+ return true;
32
+ }
33
+ try {
34
+ const data = this.client.getStatistics();
35
+ if (data) {
36
+ const { connectionsInUse, currentQueueLength } = data;
37
+ return connectionsInUse === 0 && currentQueueLength === 0;
38
+ }
39
+ return true;
40
+ }
41
+ catch {
42
+ return false;
43
+ }
44
+ }
45
+ get closed() {
46
+ return this.client.status === 6002;
47
+ }
48
+ }
49
+ OraclePool.CACHE_UNUSED = ['connectTimeout', 'transportConnectTimeout', 'expireTime', 'poolMax', 'poolMin', 'poolIncrement', 'poolTimeout', 'poolPingInterval', 'poolMaxPerShard', 'queueMax', 'queueRequests', 'queueTimeout', 'enableStatistics', 'sodaMetaDataCache', 'stmtCacheSize'];
50
+ module.exports = OraclePool;
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "@pi-r/oracle",
3
- "version": "0.7.2",
4
- "description": "Oracle client driver for E-mc.",
5
- "main": "client/index.js",
6
- "types": "client/index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/anpham6/pi-r.git",
13
- "directory": "src/db/oracle"
14
- },
15
- "keywords": [
16
- "squared",
17
- "e-mc",
18
- "squared-functions"
19
- ],
20
- "author": "An Pham <anpham6@gmail.com>",
21
- "license": "MIT",
22
- "homepage": "https://github.com/anpham6/pi-r#readme",
23
- "dependencies": {
24
- "@e-mc/db": "^0.9.4",
25
- "@e-mc/types": "^0.9.4",
26
- "oracledb": "^6.5.1"
27
- }
28
- }
1
+ {
2
+ "name": "@pi-r/oracle",
3
+ "version": "0.7.4",
4
+ "description": "Oracle client driver for E-mc.",
5
+ "main": "client/index.js",
6
+ "types": "client/index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/anpham6/pi-r.git",
13
+ "directory": "src/db/oracle"
14
+ },
15
+ "keywords": [
16
+ "squared",
17
+ "e-mc",
18
+ "squared-functions"
19
+ ],
20
+ "author": "An Pham <anpham6@gmail.com>",
21
+ "license": "MIT",
22
+ "homepage": "https://github.com/anpham6/pi-r#readme",
23
+ "dependencies": {
24
+ "@e-mc/db": "^0.9.12",
25
+ "@e-mc/types": "^0.9.12",
26
+ "oracledb": "^6.6.0"
27
+ }
28
+ }
package/types/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import type { DbDataSource } from '@e-mc/types/lib/squared';
2
-
3
- import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
4
-
5
- // @ts-ignore
6
- import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
7
-
8
- export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, OracleCredential, string>, ExecuteAction<BindParameters> {
9
- source: "oracle";
10
- }
11
-
1
+ import type { DbDataSource } from '@e-mc/types/lib/squared';
2
+
3
+ import type { ExecuteAction, ServerAuth } from '@e-mc/types/lib/db';
4
+
5
+ // @ts-ignore
6
+ import type { BindParameters, ConnectionAttributes, ExecuteOptions, InitialiseOptions, PoolAttributes } from 'oracledb';
7
+
8
+ export interface OracleDataSource extends DbDataSource<string, ExecuteOptions, unknown, OracleCredential, string>, ExecuteAction<BindParameters> {
9
+ source: "oracle";
10
+ }
11
+
12
12
  export interface OracleCredential extends ServerAuth, ConnectionAttributes, PoolAttributes, InitialiseOptions {}