@pi-r/mssql 0.2.10 → 0.2.11
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/client/index.js +7 -5
- package/package.json +1 -1
- package/types/pool.d.ts +69 -0
package/client/index.js
CHANGED
|
@@ -109,7 +109,8 @@ function convertType(sql, type, value, options) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
function getPoolKey(credential) {
|
|
112
|
-
|
|
112
|
+
var _a;
|
|
113
|
+
const tls = (_a = credential.options) === null || _a === void 0 ? void 0 : _a.cryptoCredentialsDetails;
|
|
113
114
|
if (tls) {
|
|
114
115
|
if (!(0, types_1.isObject)(tls)) {
|
|
115
116
|
delete credential.options.cryptoCredentialsDetails;
|
|
@@ -127,6 +128,7 @@ function isOutputParameters(params) {
|
|
|
127
128
|
return (0, types_1.isPlainObject)(params) && Object.keys(params).length === 2 && 'input' in params && 'output' in params;
|
|
128
129
|
}
|
|
129
130
|
function setCredential(item) {
|
|
131
|
+
var _a, _b, _c, _d;
|
|
130
132
|
let credential = this.getCredential(item), hostname, username, password, port, database;
|
|
131
133
|
if (credential) {
|
|
132
134
|
({ username, password, hostname, port, database } = (0, util_1.parseServerAuth)(credential, true));
|
|
@@ -206,16 +208,16 @@ function setCredential(item) {
|
|
|
206
208
|
if (config) {
|
|
207
209
|
const { min, max, idle, queue_idle } = config;
|
|
208
210
|
if (min >= 0) {
|
|
209
|
-
poolConfig.min
|
|
211
|
+
(_a = poolConfig.min) !== null && _a !== void 0 ? _a : (poolConfig.min = min);
|
|
210
212
|
}
|
|
211
213
|
if (max > 0) {
|
|
212
|
-
poolConfig.max
|
|
214
|
+
(_b = poolConfig.max) !== null && _b !== void 0 ? _b : (poolConfig.max = max);
|
|
213
215
|
}
|
|
214
216
|
if (idle >= 0) {
|
|
215
|
-
poolConfig.idleTimeout
|
|
217
|
+
(_c = poolConfig.idleTimeout) !== null && _c !== void 0 ? _c : (poolConfig.idleTimeout = idle);
|
|
216
218
|
}
|
|
217
219
|
if (queue_idle >= 0) {
|
|
218
|
-
poolConfig.acquireTimeout
|
|
220
|
+
(_d = poolConfig.acquireTimeout) !== null && _d !== void 0 ? _d : (poolConfig.acquireTimeout = queue_idle);
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
223
|
new MSSQLPool(new Pool(poolConfig, credential), poolKey, username && password ? { username, password } : undefined).add(item).parent = POOL_STATE;
|
package/package.json
CHANGED
package/types/pool.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint @typescript-eslint/consistent-type-imports: "off" */
|
|
2
|
+
|
|
3
|
+
import type { Connection, ConnectionConfiguration } from 'tedious';
|
|
4
|
+
|
|
5
|
+
import type * as EventEmitter from 'events';
|
|
6
|
+
|
|
7
|
+
declare class Pool extends EventEmitter {
|
|
8
|
+
/**
|
|
9
|
+
* Connection Pool constructor
|
|
10
|
+
* @param poolConfig the pool configuration
|
|
11
|
+
* @param connectionConfig the connection configuration
|
|
12
|
+
*/
|
|
13
|
+
constructor(poolConfig: Pool.PoolConfig, connectionConfig: ConnectionConfiguration);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* acquires a connection from the pool
|
|
17
|
+
* @param callback invoked when the connection is retrieved and ready
|
|
18
|
+
*/
|
|
19
|
+
acquire(callback: (err: Error, connection: Pool.PooledConnection) => void): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* closes opened connections
|
|
23
|
+
*/
|
|
24
|
+
drain(): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare namespace Pool {
|
|
28
|
+
|
|
29
|
+
export class PooledConnection extends Connection {
|
|
30
|
+
/**
|
|
31
|
+
* If the connection is issued from a connection pool returns the connection to the pool.
|
|
32
|
+
*/
|
|
33
|
+
release(): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface PoolConfig {
|
|
37
|
+
/**
|
|
38
|
+
* Minimum concurrent connections
|
|
39
|
+
*/
|
|
40
|
+
min?: number | undefined;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Maximum concurrent connections
|
|
44
|
+
*/
|
|
45
|
+
max?: number | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Defines if logging is activated
|
|
49
|
+
*/
|
|
50
|
+
log?: boolean | undefined;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Idle timeout
|
|
54
|
+
*/
|
|
55
|
+
idleTimeout?: number | undefined;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Retry delay
|
|
59
|
+
*/
|
|
60
|
+
retryDelay?: number | undefined;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Acquire timeout
|
|
64
|
+
*/
|
|
65
|
+
acquireTimeout?: number | undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export = Pool;
|