postgrejs 2.12.0 → 2.15.1
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/CHANGELOG.md +231 -191
- package/README.md +112 -96
- package/cjs/connection/connection.js +10 -5
- package/cjs/connection/cursor.js +2 -4
- package/cjs/connection/intl-connection.js +19 -12
- package/cjs/connection/pool.js +12 -6
- package/cjs/connection/prepared-statement.js +6 -3
- package/cjs/data-types/bytea-type.js +2 -4
- package/cjs/data-types/numeric-type.js +2 -2
- package/cjs/data-types/time-type.js +2 -1
- package/cjs/data-types/timestamp-type.js +2 -1
- package/cjs/data-types/timestamptz-type.js +2 -1
- package/cjs/index.js +26 -39
- package/cjs/protocol/frontend.js +8 -5
- package/cjs/protocol/pg-socket.js +33 -31
- package/cjs/protocol/sasl.js +14 -14
- package/cjs/protocol/smart-buffer.js +2 -24
- package/cjs/util/array-calculatedim.js +1 -2
- package/cjs/util/bigint-methods.js +2 -3
- package/cjs/util/config-from-env.js +1 -2
- package/cjs/util/connection-config.js +8 -11
- package/cjs/util/convert-row-to-object.js +1 -2
- package/cjs/util/decode-binaryarray.js +1 -2
- package/cjs/util/encode-binaryarray.js +1 -2
- package/cjs/util/escape-literal.js +1 -2
- package/cjs/util/fast-parseint.js +1 -2
- package/cjs/util/get-parsers.js +1 -2
- package/cjs/util/parse-array.js +1 -2
- package/cjs/util/parse-datetime.js +1 -2
- package/cjs/util/parse-row.js +1 -2
- package/cjs/util/parse-time.js +2 -2
- package/cjs/util/stringify-arrayliteral.js +1 -2
- package/cjs/util/stringify-for-sql.js +2 -3
- package/cjs/util/wrap-row-description.js +1 -2
- package/esm/connection/connection.js +10 -5
- package/esm/connection/intl-connection.js +17 -10
- package/esm/connection/pool.js +12 -6
- package/esm/connection/prepared-statement.js +6 -3
- package/esm/data-types/time-type.js +2 -1
- package/esm/data-types/timestamp-type.js +2 -1
- package/esm/data-types/timestamptz-type.js +2 -1
- package/esm/index.js +5 -5
- package/esm/protocol/frontend.js +8 -5
- package/esm/protocol/pg-socket.js +28 -24
- package/esm/protocol/sasl.js +12 -10
- package/esm/util/connection-config.js +4 -4
- package/package.json +5 -5
- package/typings/connection/connection.d.ts +0 -1
- package/typings/connection/cursor.d.ts +0 -1
- package/typings/connection/prepared-statement.d.ts +0 -1
- package/typings/index.d.ts +5 -5
- package/typings/interfaces/database-connection-params.d.ts +1 -1
- package/typings/protocol/backend.d.ts +0 -1
- package/typings/protocol/buffer-reader.d.ts +0 -1
- package/typings/protocol/frontend.d.ts +0 -1
- package/typings/protocol/pg-socket.d.ts +0 -1
- package/typings/protocol/protocol.d.ts +0 -1
- package/typings/protocol/smart-buffer.d.ts +0 -1
- package/typings/safe-event-emitter.d.ts +0 -1
- package/typings/types.d.ts +0 -1
- package/typings/util/bigint-methods.d.ts +0 -1
- package/typings/util/decode-binaryarray.d.ts +0 -1
package/cjs/index.js
CHANGED
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./connection/
|
|
21
|
-
__exportStar(require("./connection/
|
|
22
|
-
__exportStar(require("./connection/
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./interfaces/command-result.js"), exports);
|
|
26
|
-
__exportStar(require("./interfaces/data-mapping-options.js"), exports);
|
|
27
|
-
__exportStar(require("./interfaces/data-type.js"), exports);
|
|
28
|
-
__exportStar(require("./interfaces/database-connection-params.js"), exports);
|
|
29
|
-
__exportStar(require("./interfaces/field-info.js"), exports);
|
|
30
|
-
__exportStar(require("./interfaces/query-options.js"), exports);
|
|
31
|
-
__exportStar(require("./interfaces/query-result.js"), exports);
|
|
32
|
-
__exportStar(require("./interfaces/script-execute-options.js"), exports);
|
|
33
|
-
__exportStar(require("./interfaces/script-result.js"), exports);
|
|
34
|
-
__exportStar(require("./interfaces/statement-prepare-options.js"), exports);
|
|
35
|
-
__exportStar(require("./
|
|
36
|
-
__exportStar(require("./
|
|
37
|
-
__exportStar(require("./
|
|
38
|
-
__exportStar(require("./util/
|
|
39
|
-
__exportStar(require("./util/
|
|
40
|
-
__exportStar(require("./
|
|
41
|
-
__exportStar(require("./
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./connection/bind-param.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./connection/connection.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./connection/cursor.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./connection/pool.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./connection/prepared-statement.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./data-type-map.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./interfaces/command-result.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./interfaces/data-mapping-options.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./interfaces/data-type.js"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./interfaces/database-connection-params.js"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./interfaces/field-info.js"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./interfaces/query-options.js"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./interfaces/query-result.js"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./interfaces/script-execute-options.js"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./interfaces/script-result.js"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./interfaces/statement-prepare-options.js"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./protocol/database-error.js"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./protocol/smart-buffer.js"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./util/connection-config.js"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./util/escape-literal.js"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./util/parse-datetime.js"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./util/stringify-arrayliteral.js"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./util/stringify-for-sql.js"), exports);
|
package/cjs/protocol/frontend.js
CHANGED
|
@@ -161,8 +161,9 @@ class Frontend {
|
|
|
161
161
|
return setLengthAndFlush(io, 1);
|
|
162
162
|
}
|
|
163
163
|
getDescribeMessage(args) {
|
|
164
|
-
if (args.name && args.name.length > 63)
|
|
165
|
-
throw new Error(args.type === 'P' ? 'Portal' : 'Statement
|
|
164
|
+
if (args.name && args.name.length > 63) {
|
|
165
|
+
throw new Error(args.type === 'P' ? 'Portal' : 'Statement name length must be lower than 63');
|
|
166
|
+
}
|
|
166
167
|
const io = this._io
|
|
167
168
|
.start()
|
|
168
169
|
.writeInt8(protocol_js_1.Protocol.FrontendMessageCode.Describe)
|
|
@@ -172,8 +173,9 @@ class Frontend {
|
|
|
172
173
|
return setLengthAndFlush(io, 1);
|
|
173
174
|
}
|
|
174
175
|
getExecuteMessage(args) {
|
|
175
|
-
if (args.fetchCount && (args.fetchCount < 0 || args.fetchCount > 4294967295))
|
|
176
|
+
if (args.fetchCount && (args.fetchCount < 0 || args.fetchCount > 4294967295)) {
|
|
176
177
|
throw new Error('fetchCount can be between 0 and 4294967295');
|
|
178
|
+
}
|
|
177
179
|
const io = this._io
|
|
178
180
|
.start()
|
|
179
181
|
.writeInt8(protocol_js_1.Protocol.FrontendMessageCode.Execute)
|
|
@@ -183,8 +185,9 @@ class Frontend {
|
|
|
183
185
|
return setLengthAndFlush(io, 1);
|
|
184
186
|
}
|
|
185
187
|
getCloseMessage(args) {
|
|
186
|
-
if (args.name && args.name.length > 63)
|
|
187
|
-
throw new Error(args.type === 'P' ? 'Portal' : 'Statement
|
|
188
|
+
if (args.name && args.name.length > 63) {
|
|
189
|
+
throw new Error(args.type === 'P' ? 'Portal' : 'Statement name length must be lower than 63');
|
|
190
|
+
}
|
|
188
191
|
const io = this._io
|
|
189
192
|
.start()
|
|
190
193
|
.writeInt8(protocol_js_1.Protocol.FrontendMessageCode.Close)
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PgSocket = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
6
|
+
const net_1 = tslib_1.__importDefault(require("net"));
|
|
7
|
+
const putil_promisify_1 = tslib_1.__importDefault(require("putil-promisify"));
|
|
8
|
+
const tls_1 = tslib_1.__importDefault(require("tls"));
|
|
11
9
|
const constants_js_1 = require("../constants.js");
|
|
12
10
|
const safe_event_emitter_js_1 = require("../safe-event-emitter.js");
|
|
13
11
|
const backend_js_1 = require("./backend.js");
|
|
@@ -59,30 +57,31 @@ class PgSocket extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
59
57
|
socket.setTimeout(0);
|
|
60
58
|
if (this.options.keepAlive || this.options.keepAlive == null)
|
|
61
59
|
socket.setKeepAlive(true);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
60
|
+
socket.write(this._frontend.getSSLRequestMessage());
|
|
61
|
+
socket.once('data', x => {
|
|
62
|
+
this._removeListeners();
|
|
63
|
+
if (x.toString() === 'S') {
|
|
64
|
+
const tslOptions = { ...options.ssl, socket };
|
|
65
|
+
if (options.host && net_1.default.isIP(options.host) === 0)
|
|
66
|
+
tslOptions.servername = options.host;
|
|
67
|
+
const tlsSocket = (this._socket = tls_1.default.connect(tslOptions));
|
|
68
|
+
tlsSocket.once('error', errorHandler);
|
|
69
|
+
tlsSocket.once('secureConnect', () => {
|
|
70
|
+
this._removeListeners();
|
|
71
|
+
this._handleConnect();
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (x.toString() === 'N') {
|
|
76
|
+
if (options.requireSSL) {
|
|
79
77
|
return errorHandler(new Error('Server does not support SSL connections'));
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
}
|
|
79
|
+
this._removeListeners();
|
|
80
|
+
this._handleConnect();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return errorHandler(new Error('There was an error establishing an SSL connection'));
|
|
84
|
+
});
|
|
86
85
|
};
|
|
87
86
|
socket.setNoDelay(true);
|
|
88
87
|
socket.setTimeout(options.connectTimeoutMs || 30000, () => errorHandler(new Error('Connection timed out')));
|
|
@@ -289,8 +288,9 @@ class PgSocket extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
289
288
|
});
|
|
290
289
|
break;
|
|
291
290
|
case protocol_js_1.Protocol.AuthenticationMessageKind.SASL: {
|
|
292
|
-
if (!msg.mechanisms.includes('SCRAM-SHA-256'))
|
|
291
|
+
if (!msg.mechanisms.includes('SCRAM-SHA-256')) {
|
|
293
292
|
throw new Error('SASL: Only mechanism SCRAM-SHA-256 is currently supported');
|
|
293
|
+
}
|
|
294
294
|
const saslSession = (this._saslSession = sasl_js_1.SASL.createSession(this.options.user || '', 'SCRAM-SHA-256'));
|
|
295
295
|
this._send(this._frontend.getSASLMessage(saslSession));
|
|
296
296
|
break;
|
|
@@ -314,6 +314,8 @@ class PgSocket extends safe_event_emitter_js_1.SafeEventEmitter {
|
|
|
314
314
|
this._saslSession = undefined;
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
317
|
+
default:
|
|
318
|
+
break;
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
_handleParameterStatus(msg) {
|
package/cjs/protocol/sasl.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.SASL = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
7
5
|
/* eslint-disable no-bitwise */
|
|
8
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
6
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
9
7
|
var SASL;
|
|
10
8
|
(function (SASL) {
|
|
11
9
|
const CLIENT_KEY = 'Client Key';
|
|
@@ -39,6 +37,8 @@ var SASL;
|
|
|
39
37
|
case 'i':
|
|
40
38
|
iteration = parseInt(i.substring(2), 10);
|
|
41
39
|
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
if (!nonce)
|
|
@@ -75,25 +75,25 @@ var SASL;
|
|
|
75
75
|
throw new Error('SASL: Server signature does not match');
|
|
76
76
|
}
|
|
77
77
|
SASL.finalizeSession = finalizeSession;
|
|
78
|
-
function
|
|
78
|
+
const firstMessageBare = function (username, nonce) {
|
|
79
79
|
return `n=${username},r=${nonce}`;
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
81
|
/**
|
|
82
82
|
* Hi() is, essentially, PBKDF2 [RFC2898] with HMAC() as the
|
|
83
83
|
* pseudorandom function (PRF) and with dkLen == output length of
|
|
84
84
|
* HMAC() == output length of H()
|
|
85
85
|
*/
|
|
86
|
-
function
|
|
86
|
+
const hi = function (text, salt, iterations) {
|
|
87
87
|
return crypto_1.default.pbkdf2Sync(text, Buffer.from(salt, 'base64'), iterations, 32, 'sha256');
|
|
88
|
-
}
|
|
88
|
+
};
|
|
89
89
|
const encode64 = str => Buffer.from(str).toString('base64');
|
|
90
|
-
function
|
|
90
|
+
const hmac = function (key, msg) {
|
|
91
91
|
return crypto_1.default.createHmac('sha256', key).update(msg).digest();
|
|
92
|
-
}
|
|
93
|
-
function
|
|
92
|
+
};
|
|
93
|
+
const hash = function (data) {
|
|
94
94
|
return crypto_1.default.createHash('sha256').update(data).digest();
|
|
95
|
-
}
|
|
96
|
-
function
|
|
95
|
+
};
|
|
96
|
+
const xor = function (a, b) {
|
|
97
97
|
a = Buffer.isBuffer(a) ? a : Buffer.from(a);
|
|
98
98
|
b = Buffer.isBuffer(b) ? b : Buffer.from(b);
|
|
99
99
|
if (a.length !== b.length)
|
|
@@ -104,5 +104,5 @@ var SASL;
|
|
|
104
104
|
out[i] = a[i] ^ b[i];
|
|
105
105
|
}
|
|
106
106
|
return out;
|
|
107
|
-
}
|
|
107
|
+
};
|
|
108
108
|
})(SASL || (exports.SASL = SASL = {}));
|
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.SmartBuffer = void 0;
|
|
27
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const os = tslib_1.__importStar(require("os"));
|
|
28
6
|
const bigint_methods_js_1 = require("../util/bigint-methods.js");
|
|
29
7
|
const buffer_reader_js_1 = require("./buffer-reader.js");
|
|
30
8
|
class SmartBuffer extends buffer_reader_js_1.BufferReader {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.arrayCalculateDim =
|
|
3
|
+
exports.arrayCalculateDim = arrayCalculateDim;
|
|
4
4
|
function arrayCalculateDim(arr) {
|
|
5
5
|
if (!arr || arr.length === 0)
|
|
6
6
|
return [0];
|
|
@@ -16,4 +16,3 @@ function arrayCalculateDim(arr) {
|
|
|
16
16
|
iterate(arr, 1);
|
|
17
17
|
return dim;
|
|
18
18
|
}
|
|
19
|
-
exports.arrayCalculateDim = arrayCalculateDim;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.readBigInt64BE = readBigInt64BE;
|
|
4
|
+
exports.writeBigUInt64BE = writeBigUInt64BE;
|
|
4
5
|
/* eslint-disable no-bitwise */
|
|
5
6
|
const big0 = BigInt(0);
|
|
6
7
|
const beAnd = BigInt('0xffffffff');
|
|
@@ -17,7 +18,6 @@ function readBigInt64BE(buf, offset = 0) {
|
|
|
17
18
|
buf[++offset];
|
|
18
19
|
return ((BigInt(val) << big32) + BigInt(buf[++offset] * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + last));
|
|
19
20
|
}
|
|
20
|
-
exports.readBigInt64BE = readBigInt64BE;
|
|
21
21
|
function writeBigUInt64BE(buf, value, offset = 0) {
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
let lo = Number(value & beAnd);
|
|
@@ -39,4 +39,3 @@ function writeBigUInt64BE(buf, value, offset = 0) {
|
|
|
39
39
|
buf[offset] = hi;
|
|
40
40
|
return offset + 8;
|
|
41
41
|
}
|
|
42
|
-
exports.writeBigUInt64BE = writeBigUInt64BE;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configFromEnv =
|
|
3
|
+
exports.configFromEnv = configFromEnv;
|
|
4
4
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
5
5
|
function configFromEnv() {
|
|
6
6
|
const env = process.env;
|
|
@@ -27,4 +27,3 @@ function configFromEnv() {
|
|
|
27
27
|
}
|
|
28
28
|
return result;
|
|
29
29
|
}
|
|
30
|
-
exports.configFromEnv = configFromEnv;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
3
|
+
exports.getConnectionConfig = getConnectionConfig;
|
|
4
|
+
exports.parseConnectionString = parseConnectionString;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
8
7
|
const config_from_env_js_1 = require("./config-from-env.js");
|
|
9
8
|
function getConnectionConfig(config) {
|
|
10
9
|
const cfg = (0, config_from_env_js_1.configFromEnv)();
|
|
@@ -23,16 +22,13 @@ function getConnectionConfig(config) {
|
|
|
23
22
|
cfg.host = cfg.host || '127.0.0.1';
|
|
24
23
|
return cfg;
|
|
25
24
|
}
|
|
26
|
-
exports.getConnectionConfig = getConnectionConfig;
|
|
27
25
|
function parseConnectionString(str) {
|
|
28
26
|
if (str.startsWith('/'))
|
|
29
27
|
str = 'socket:/' + str;
|
|
30
28
|
if (!str.includes('://'))
|
|
31
29
|
str = 'postgres://' + str;
|
|
32
30
|
const parsed = new URL(str);
|
|
33
|
-
const getFirst = (v) =>
|
|
34
|
-
return typeof v === 'string' ? v : Array.isArray(v) ? v[0] : '';
|
|
35
|
-
};
|
|
31
|
+
const getFirst = (v) => (typeof v === 'string' ? v : Array.isArray(v) ? v[0] : '');
|
|
36
32
|
const cfg = {};
|
|
37
33
|
cfg.host = decodeURI(parsed.hostname || '');
|
|
38
34
|
if (parsed.port)
|
|
@@ -54,12 +50,13 @@ function parseConnectionString(str) {
|
|
|
54
50
|
cfg.database = decodeURI(getFirst(parsed.searchParams.get('db')));
|
|
55
51
|
if (parsed.searchParams.get('schema'))
|
|
56
52
|
cfg.schema = decodeURI(getFirst(parsed.searchParams.get('schema')));
|
|
57
|
-
if (parsed.searchParams.get('application_name'))
|
|
53
|
+
if (parsed.searchParams.get('application_name')) {
|
|
58
54
|
cfg.applicationName = decodeURI(getFirst(parsed.searchParams.get('application_name')));
|
|
55
|
+
}
|
|
59
56
|
if (parsed.username)
|
|
60
57
|
cfg.user = parsed.username;
|
|
61
58
|
if (parsed.password)
|
|
62
59
|
cfg.password = parsed.password;
|
|
60
|
+
cfg.requireSSL = parsed.searchParams.get('sslmode') === 'require';
|
|
63
61
|
return cfg;
|
|
64
62
|
}
|
|
65
|
-
exports.parseConnectionString = parseConnectionString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertRowToObject =
|
|
3
|
+
exports.convertRowToObject = convertRowToObject;
|
|
4
4
|
function convertRowToObject(fields, row) {
|
|
5
5
|
const out = {};
|
|
6
6
|
const l = row.length;
|
|
@@ -10,4 +10,3 @@ function convertRowToObject(fields, row) {
|
|
|
10
10
|
}
|
|
11
11
|
return out;
|
|
12
12
|
}
|
|
13
|
-
exports.convertRowToObject = convertRowToObject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeBinaryArray =
|
|
3
|
+
exports.decodeBinaryArray = decodeBinaryArray;
|
|
4
4
|
const buffer_reader_js_1 = require("../protocol/buffer-reader.js");
|
|
5
5
|
function decodeBinaryArray(buf, decoder, options = {}) {
|
|
6
6
|
if (!buf.length)
|
|
@@ -36,4 +36,3 @@ function decodeBinaryArray(buf, decoder, options = {}) {
|
|
|
36
36
|
}
|
|
37
37
|
return readDim(0);
|
|
38
38
|
}
|
|
39
|
-
exports.decodeBinaryArray = decodeBinaryArray;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encodeBinaryArray =
|
|
3
|
+
exports.encodeBinaryArray = encodeBinaryArray;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const array_calculatedim_js_1 = require("./array-calculatedim.js");
|
|
6
6
|
function encodeBinaryArray(io, value, itemOid, options, encode, encodeCalculateDimFn) {
|
|
@@ -42,4 +42,3 @@ function encodeBinaryArray(io, value, itemOid, options, encode, encodeCalculateD
|
|
|
42
42
|
if (hasNull)
|
|
43
43
|
io.buffer.writeInt32BE(1, zeroOffset + 4);
|
|
44
44
|
}
|
|
45
|
-
exports.encodeBinaryArray = encodeBinaryArray;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.escapeLiteral =
|
|
3
|
+
exports.escapeLiteral = escapeLiteral;
|
|
4
4
|
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
|
|
5
5
|
function escapeLiteral(str) {
|
|
6
6
|
let backSlash = false;
|
|
@@ -24,4 +24,3 @@ function escapeLiteral(str) {
|
|
|
24
24
|
out = ' E' + out;
|
|
25
25
|
return out;
|
|
26
26
|
}
|
|
27
|
-
exports.escapeLiteral = escapeLiteral;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fastParseInt =
|
|
3
|
+
exports.fastParseInt = fastParseInt;
|
|
4
4
|
function fastParseInt(str) {
|
|
5
5
|
/* istanbul ignore next */
|
|
6
6
|
if (typeof str === 'number')
|
|
@@ -29,4 +29,3 @@ function fastParseInt(str) {
|
|
|
29
29
|
} while (++i < strLength);
|
|
30
30
|
return neg ? -res : res;
|
|
31
31
|
}
|
|
32
|
-
exports.fastParseInt = fastParseInt;
|
package/cjs/util/get-parsers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getParsers =
|
|
3
|
+
exports.getParsers = getParsers;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const decode_binaryarray_js_1 = require("./decode-binaryarray.js");
|
|
6
6
|
const parse_array_js_1 = require("./parse-array.js");
|
|
@@ -39,4 +39,3 @@ function getParsers(typeMap, fields) {
|
|
|
39
39
|
}
|
|
40
40
|
return parsers;
|
|
41
41
|
}
|
|
42
|
-
exports.getParsers = getParsers;
|
package/cjs/util/parse-array.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parsePostgresArray =
|
|
3
|
+
exports.parsePostgresArray = parsePostgresArray;
|
|
4
4
|
function parsePostgresArray(s, opts) {
|
|
5
5
|
if (!s)
|
|
6
6
|
return;
|
|
@@ -58,4 +58,3 @@ function parsePostgresArray(s, opts) {
|
|
|
58
58
|
iterate(out);
|
|
59
59
|
return out.length ? out[0] : undefined;
|
|
60
60
|
}
|
|
61
|
-
exports.parsePostgresArray = parsePostgresArray;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseDateTime =
|
|
3
|
+
exports.parseDateTime = parseDateTime;
|
|
4
4
|
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
5
5
|
const fast_parseint_js_1 = require("./fast-parseint.js");
|
|
6
6
|
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
@@ -35,4 +35,3 @@ function parseDateTime(str, parseTime, parseTimeZone, utc) {
|
|
|
35
35
|
return new Date(Date.UTC(...args));
|
|
36
36
|
return new Date(...args);
|
|
37
37
|
}
|
|
38
|
-
exports.parseDateTime = parseDateTime;
|
package/cjs/util/parse-row.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseRow =
|
|
3
|
+
exports.parseRow = parseRow;
|
|
4
4
|
function parseRow(parsers, row, options) {
|
|
5
5
|
const l = row.length;
|
|
6
6
|
let i;
|
|
@@ -8,4 +8,3 @@ function parseRow(parsers, row, options) {
|
|
|
8
8
|
row[i] = row[i] == null ? null : parsers[i].call(undefined, row[i], options);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
exports.parseRow = parseRow;
|
package/cjs/util/parse-time.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TIME_PATTERN = exports.STRICT_TIME_PATTERN = void 0;
|
|
4
|
+
exports.parseTime = parseTime;
|
|
4
5
|
const fast_parseint_js_1 = require("./fast-parseint.js");
|
|
5
6
|
// eslint-disable-next-line
|
|
6
7
|
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
@@ -26,4 +27,3 @@ function parseTime(str, parseTimeZone, utc) {
|
|
|
26
27
|
return new Date(Date.UTC(...args));
|
|
27
28
|
return new Date(...args);
|
|
28
29
|
}
|
|
29
|
-
exports.parseTime = parseTime;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyArrayLiteral =
|
|
3
|
+
exports.stringifyArrayLiteral = stringifyArrayLiteral;
|
|
4
4
|
const array_calculatedim_js_1 = require("./array-calculatedim.js");
|
|
5
5
|
function stringifyArrayLiteral(value, options, encode) {
|
|
6
6
|
const dim = (0, array_calculatedim_js_1.arrayCalculateDim)(value);
|
|
@@ -32,7 +32,6 @@ function stringifyArrayLiteral(value, options, encode) {
|
|
|
32
32
|
};
|
|
33
33
|
return writeDim(value, 0);
|
|
34
34
|
}
|
|
35
|
-
exports.stringifyArrayLiteral = stringifyArrayLiteral;
|
|
36
35
|
function escapeArrayItem(str) {
|
|
37
36
|
return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
38
37
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.stringifyArrayForSQL = stringifyArrayForSQL;
|
|
4
|
+
exports.stringifyValueForSQL = stringifyValueForSQL;
|
|
4
5
|
const uuid_type_js_1 = require("../data-types/uuid-type.js");
|
|
5
6
|
const escape_literal_js_1 = require("./escape-literal.js");
|
|
6
7
|
function stringifyArrayForSQL(v, options, encode) {
|
|
7
8
|
const arr = v.map(x => stringifyValueForSQL(x, options, encode));
|
|
8
9
|
return 'ARRAY[' + arr.join(',') + ']';
|
|
9
10
|
}
|
|
10
|
-
exports.stringifyArrayForSQL = stringifyArrayForSQL;
|
|
11
11
|
function stringifyValueForSQL(v, options, encode) {
|
|
12
12
|
if (v == null)
|
|
13
13
|
return 'null';
|
|
@@ -27,4 +27,3 @@ function stringifyValueForSQL(v, options, encode) {
|
|
|
27
27
|
return (0, escape_literal_js_1.escapeLiteral)(JSON.stringify(v)) + '::json';
|
|
28
28
|
return (0, escape_literal_js_1.escapeLiteral)('' + v);
|
|
29
29
|
}
|
|
30
|
-
exports.stringifyValueForSQL = stringifyValueForSQL;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapRowDescription =
|
|
3
|
+
exports.wrapRowDescription = wrapRowDescription;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
function wrapRowDescription(typeMap, fields, columnFormat) {
|
|
6
6
|
return fields.map((f, idx) => {
|
|
@@ -32,4 +32,3 @@ function wrapRowDescription(typeMap, fields, columnFormat) {
|
|
|
32
32
|
return x;
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
exports.wrapRowDescription = wrapRowDescription;
|