@pi-r/postgres 0.6.5 → 0.6.7
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 +10 -8
- package/package.json +6 -6
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.setAuthentication = void 0;
|
|
4
3
|
const postgres = require("pg");
|
|
5
4
|
const connectionString = require("pg-connection-string");
|
|
@@ -47,6 +46,7 @@ function removePoolProperties(credential) {
|
|
|
47
46
|
return credential;
|
|
48
47
|
}
|
|
49
48
|
function fromConnectionString(credential, uri) {
|
|
49
|
+
var _a;
|
|
50
50
|
const { user, password, host, port, database, application_name, ssl } = connectionString.parse(uri);
|
|
51
51
|
if (!credential.user) {
|
|
52
52
|
credential.user = user;
|
|
@@ -59,7 +59,7 @@ function fromConnectionString(credential, uri) {
|
|
|
59
59
|
credential.database || (credential.database = database);
|
|
60
60
|
credential.application_name || (credential.application_name = application_name);
|
|
61
61
|
if (ssl) {
|
|
62
|
-
credential.ssl
|
|
62
|
+
(_a = credential.ssl) !== null && _a !== void 0 ? _a : (credential.ssl = (0, types_1.isPlainObject)(ssl) ? ssl : true);
|
|
63
63
|
}
|
|
64
64
|
return credential;
|
|
65
65
|
}
|
|
@@ -85,6 +85,7 @@ function setAuthentication(credential) {
|
|
|
85
85
|
}
|
|
86
86
|
exports.setAuthentication = setAuthentication;
|
|
87
87
|
function setCredential(item) {
|
|
88
|
+
var _a, _b, _c, _d, _e;
|
|
88
89
|
let credential = this.getCredential(item);
|
|
89
90
|
if (credential) {
|
|
90
91
|
setAuthentication.call(this, credential);
|
|
@@ -116,7 +117,7 @@ function setCredential(item) {
|
|
|
116
117
|
}
|
|
117
118
|
let username, password, pool;
|
|
118
119
|
if ((0, types_1.isString)(usePool)) {
|
|
119
|
-
if (username = credential.user || credential.connectionString && (0, util_1.parseConnectionString)(credential.connectionString)
|
|
120
|
+
if (username = credential.user || credential.connectionString && ((_a = (0, util_1.parseConnectionString)(credential.connectionString)) === null || _a === void 0 ? void 0 : _a.username)) {
|
|
120
121
|
[password, pool] = DbPool.validateKey(POOL_STATE, username, usePool);
|
|
121
122
|
if (pool) {
|
|
122
123
|
pool.add(item, password);
|
|
@@ -132,16 +133,16 @@ function setCredential(item) {
|
|
|
132
133
|
if (config) {
|
|
133
134
|
const { min, max, idle, timeout } = config;
|
|
134
135
|
if (min >= 0) {
|
|
135
|
-
credential.min
|
|
136
|
+
(_b = credential.min) !== null && _b !== void 0 ? _b : (credential.min = min);
|
|
136
137
|
}
|
|
137
138
|
if (max > 0) {
|
|
138
|
-
credential.max
|
|
139
|
+
(_c = credential.max) !== null && _c !== void 0 ? _c : (credential.max = max);
|
|
139
140
|
}
|
|
140
141
|
if (idle > 0) {
|
|
141
|
-
credential.idleTimeoutMillis
|
|
142
|
+
(_d = credential.idleTimeoutMillis) !== null && _d !== void 0 ? _d : (credential.idleTimeoutMillis = idle);
|
|
142
143
|
}
|
|
143
144
|
if (timeout > 0) {
|
|
144
|
-
credential.connectionTimeoutMillis
|
|
145
|
+
(_e = credential.connectionTimeoutMillis) !== null && _e !== void 0 ? _e : (credential.connectionTimeoutMillis = timeout);
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
const poolKey = getPoolKey(credential);
|
|
@@ -157,6 +158,7 @@ async function executeQuery(item, options) {
|
|
|
157
158
|
}
|
|
158
159
|
exports.executeQuery = executeQuery;
|
|
159
160
|
async function executeBatchQuery(batch, options = '', outResult) {
|
|
161
|
+
var _a;
|
|
160
162
|
const length = batch.length;
|
|
161
163
|
if (length === 0) {
|
|
162
164
|
return [];
|
|
@@ -238,7 +240,7 @@ async function executeBatchQuery(batch, options = '', outResult) {
|
|
|
238
240
|
item.transactionState &= ~64;
|
|
239
241
|
return client;
|
|
240
242
|
};
|
|
241
|
-
if (this.host
|
|
243
|
+
if ((_a = this.host) === null || _a === void 0 ? void 0 : _a.username) {
|
|
242
244
|
this.applyCommand(...batch);
|
|
243
245
|
}
|
|
244
246
|
for (let i = 0; i < length; ++i) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-r/postgres",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "PostgreSQL client driver for E-mc.",
|
|
5
5
|
"main": "client/index.js",
|
|
6
6
|
"types": "client/index.d.ts",
|
|
@@ -21,10 +21,10 @@
|
|
|
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
|
-
"pg": "^8.11.
|
|
27
|
-
"pg-connection-string": "^2.6.
|
|
28
|
-
"pg-query-stream": "^4.5.
|
|
24
|
+
"@e-mc/db": "^0.8.8",
|
|
25
|
+
"@e-mc/types": "^0.8.8",
|
|
26
|
+
"pg": "^8.11.5",
|
|
27
|
+
"pg-connection-string": "^2.6.4",
|
|
28
|
+
"pg-query-stream": "^4.5.5"
|
|
29
29
|
}
|
|
30
30
|
}
|