postgrejs 2.22.9 → 2.23.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 +18 -1
- package/{esm/connection → connection}/bind-param.js +2 -0
- package/{esm/connection → connection}/connection.js +4 -2
- package/{esm/connection → connection}/cursor.js +8 -3
- package/{esm/connection → connection}/intl-connection.js +6 -3
- package/{esm/connection → connection}/pool.js +4 -1
- package/{esm/connection → connection}/portal.js +3 -1
- package/{esm/connection → connection}/prepared-statement.js +6 -3
- package/{esm/constants.js → constants.js} +1 -1
- package/{types/data-type-map.d.ts → data-type-map.d.ts} +2 -2
- package/{esm/data-type-map.js → data-type-map.js} +2 -2
- package/{esm/data-types → data-types}/int2-vector-type.js +1 -0
- package/{types/data-types → data-types}/timestamptz-type.d.ts +1 -1
- package/{esm/data-types → data-types}/timestamptz-type.js +1 -0
- package/package.json +12 -31
- package/{esm/protocol → protocol}/backend.js +1 -0
- package/{esm/protocol → protocol}/buffer-reader.js +2 -1
- package/{esm/protocol → protocol}/database-error.js +17 -0
- package/{esm/protocol → protocol}/frontend.js +2 -0
- package/{types/protocol → protocol}/pg-socket.d.ts +1 -1
- package/{esm/protocol → protocol}/pg-socket.js +9 -3
- package/{esm/protocol → protocol}/smart-buffer.js +9 -5
- package/{esm/util → util}/bigint-methods.js +1 -0
- package/cjs/connection/bind-param.js +0 -10
- package/cjs/connection/connection.js +0 -295
- package/cjs/connection/cursor.js +0 -91
- package/cjs/connection/intl-connection.js +0 -258
- package/cjs/connection/pool.js +0 -236
- package/cjs/connection/portal.js +0 -157
- package/cjs/connection/prepared-statement.js +0 -226
- package/cjs/constants.js +0 -249
- package/cjs/data-type-map.js +0 -131
- package/cjs/data-types/bool-type.js +0 -33
- package/cjs/data-types/box-type.js +0 -52
- package/cjs/data-types/bytea-type.js +0 -28
- package/cjs/data-types/char-type.js +0 -27
- package/cjs/data-types/circle-type.js +0 -51
- package/cjs/data-types/date-type.js +0 -75
- package/cjs/data-types/float4-type.js +0 -25
- package/cjs/data-types/float8-type.js +0 -25
- package/cjs/data-types/int2-type.js +0 -26
- package/cjs/data-types/int2-vector-type.js +0 -42
- package/cjs/data-types/int4-type.js +0 -28
- package/cjs/data-types/int8-type.js +0 -36
- package/cjs/data-types/json-type.js +0 -40
- package/cjs/data-types/jsonb-type.js +0 -44
- package/cjs/data-types/lseg-type.js +0 -55
- package/cjs/data-types/numeric-type.js +0 -125
- package/cjs/data-types/oid-type.js +0 -32
- package/cjs/data-types/point-type.js +0 -42
- package/cjs/data-types/time-type.js +0 -66
- package/cjs/data-types/timestamp-type.js +0 -89
- package/cjs/data-types/timestamptz-type.js +0 -76
- package/cjs/data-types/uuid-type.js +0 -39
- package/cjs/data-types/varchar-type.js +0 -27
- package/cjs/index.js +0 -28
- package/cjs/interfaces/command-result.js +0 -2
- package/cjs/interfaces/data-mapping-options.js +0 -2
- package/cjs/interfaces/data-type.js +0 -2
- package/cjs/interfaces/database-connection-params.js +0 -2
- package/cjs/interfaces/field-info.js +0 -2
- package/cjs/interfaces/query-options.js +0 -2
- package/cjs/interfaces/query-result.js +0 -2
- package/cjs/interfaces/script-execute-options.js +0 -2
- package/cjs/interfaces/script-result.js +0 -2
- package/cjs/interfaces/statement-prepare-options.js +0 -2
- package/cjs/package.json +0 -3
- package/cjs/protocol/backend.js +0 -262
- package/cjs/protocol/buffer-reader.js +0 -78
- package/cjs/protocol/database-error.js +0 -17
- package/cjs/protocol/frontend.js +0 -255
- package/cjs/protocol/pg-socket.js +0 -367
- package/cjs/protocol/protocol.js +0 -71
- package/cjs/protocol/sasl.js +0 -108
- package/cjs/protocol/smart-buffer.js +0 -178
- package/cjs/safe-event-emitter.js +0 -17
- package/cjs/tsconfig-build-cjs.tsbuildinfo +0 -1
- package/cjs/types.js +0 -2
- package/cjs/util/array-calculatedim.js +0 -18
- package/cjs/util/bigint-methods.js +0 -44
- package/cjs/util/config-from-env.js +0 -29
- package/cjs/util/connection-config.js +0 -61
- package/cjs/util/convert-row-to-object.js +0 -12
- package/cjs/util/decode-binaryarray.js +0 -38
- package/cjs/util/encode-binaryarray.js +0 -44
- package/cjs/util/escape-literal.js +0 -26
- package/cjs/util/fast-parseint.js +0 -31
- package/cjs/util/get-parsers.js +0 -41
- package/cjs/util/parse-array.js +0 -60
- package/cjs/util/parse-datetime.js +0 -37
- package/cjs/util/parse-row.js +0 -11
- package/cjs/util/parse-time.js +0 -30
- package/cjs/util/stringify-arrayliteral.js +0 -37
- package/cjs/util/stringify-for-sql.js +0 -29
- package/cjs/util/wrap-row-description.js +0 -34
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -25
- /package/{types/connection → connection}/bind-param.d.ts +0 -0
- /package/{types/connection → connection}/connection.d.ts +0 -0
- /package/{types/connection → connection}/cursor.d.ts +0 -0
- /package/{types/connection → connection}/intl-connection.d.ts +0 -0
- /package/{types/connection → connection}/pool.d.ts +0 -0
- /package/{types/connection → connection}/portal.d.ts +0 -0
- /package/{types/connection → connection}/prepared-statement.d.ts +0 -0
- /package/{types/constants.d.ts → constants.d.ts} +0 -0
- /package/{types/data-types → data-types}/bool-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/bool-type.js +0 -0
- /package/{types/data-types → data-types}/box-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/box-type.js +0 -0
- /package/{types/data-types → data-types}/bytea-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/bytea-type.js +0 -0
- /package/{types/data-types → data-types}/char-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/char-type.js +0 -0
- /package/{types/data-types → data-types}/circle-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/circle-type.js +0 -0
- /package/{types/data-types → data-types}/date-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/date-type.js +0 -0
- /package/{types/data-types → data-types}/float4-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/float4-type.js +0 -0
- /package/{types/data-types → data-types}/float8-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/float8-type.js +0 -0
- /package/{types/data-types → data-types}/int2-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int2-type.js +0 -0
- /package/{types/data-types → data-types}/int2-vector-type.d.ts +0 -0
- /package/{types/data-types → data-types}/int4-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int4-type.js +0 -0
- /package/{types/data-types → data-types}/int8-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/int8-type.js +0 -0
- /package/{types/data-types → data-types}/json-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/json-type.js +0 -0
- /package/{types/data-types → data-types}/jsonb-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/jsonb-type.js +0 -0
- /package/{types/data-types → data-types}/lseg-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/lseg-type.js +0 -0
- /package/{types/data-types → data-types}/numeric-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/numeric-type.js +0 -0
- /package/{types/data-types → data-types}/oid-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/oid-type.js +0 -0
- /package/{types/data-types → data-types}/point-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/point-type.js +0 -0
- /package/{types/data-types → data-types}/time-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/time-type.js +0 -0
- /package/{types/data-types → data-types}/timestamp-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/timestamp-type.js +0 -0
- /package/{types/data-types → data-types}/uuid-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/uuid-type.js +0 -0
- /package/{types/data-types → data-types}/varchar-type.d.ts +0 -0
- /package/{esm/data-types → data-types}/varchar-type.js +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/interfaces → interfaces}/command-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/command-result.js +0 -0
- /package/{types/interfaces → interfaces}/data-mapping-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/data-mapping-options.js +0 -0
- /package/{types/interfaces → interfaces}/data-type.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/data-type.js +0 -0
- /package/{types/interfaces → interfaces}/database-connection-params.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/database-connection-params.js +0 -0
- /package/{types/interfaces → interfaces}/field-info.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/field-info.js +0 -0
- /package/{types/interfaces → interfaces}/query-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/query-options.js +0 -0
- /package/{types/interfaces → interfaces}/query-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/query-result.js +0 -0
- /package/{types/interfaces → interfaces}/script-execute-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/script-execute-options.js +0 -0
- /package/{types/interfaces → interfaces}/script-result.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/script-result.js +0 -0
- /package/{types/interfaces → interfaces}/statement-prepare-options.d.ts +0 -0
- /package/{esm/interfaces → interfaces}/statement-prepare-options.js +0 -0
- /package/{types/protocol → protocol}/backend.d.ts +0 -0
- /package/{types/protocol → protocol}/buffer-reader.d.ts +0 -0
- /package/{types/protocol → protocol}/database-error.d.ts +0 -0
- /package/{types/protocol → protocol}/frontend.d.ts +0 -0
- /package/{types/protocol → protocol}/protocol.d.ts +0 -0
- /package/{esm/protocol → protocol}/protocol.js +0 -0
- /package/{types/protocol → protocol}/sasl.d.ts +0 -0
- /package/{esm/protocol → protocol}/sasl.js +0 -0
- /package/{types/protocol → protocol}/smart-buffer.d.ts +0 -0
- /package/{types/safe-event-emitter.d.ts → safe-event-emitter.d.ts} +0 -0
- /package/{esm/safe-event-emitter.js → safe-event-emitter.js} +0 -0
- /package/{types/types.d.ts → types.d.ts} +0 -0
- /package/{esm/types.js → types.js} +0 -0
- /package/{types/util → util}/array-calculatedim.d.ts +0 -0
- /package/{esm/util → util}/array-calculatedim.js +0 -0
- /package/{types/util → util}/bigint-methods.d.ts +0 -0
- /package/{types/util → util}/config-from-env.d.ts +0 -0
- /package/{esm/util → util}/config-from-env.js +0 -0
- /package/{types/util → util}/connection-config.d.ts +0 -0
- /package/{esm/util → util}/connection-config.js +0 -0
- /package/{types/util → util}/convert-row-to-object.d.ts +0 -0
- /package/{esm/util → util}/convert-row-to-object.js +0 -0
- /package/{types/util → util}/decode-binaryarray.d.ts +0 -0
- /package/{esm/util → util}/decode-binaryarray.js +0 -0
- /package/{types/util → util}/encode-binaryarray.d.ts +0 -0
- /package/{esm/util → util}/encode-binaryarray.js +0 -0
- /package/{types/util → util}/escape-literal.d.ts +0 -0
- /package/{esm/util → util}/escape-literal.js +0 -0
- /package/{types/util → util}/fast-parseint.d.ts +0 -0
- /package/{esm/util → util}/fast-parseint.js +0 -0
- /package/{types/util → util}/get-parsers.d.ts +0 -0
- /package/{esm/util → util}/get-parsers.js +0 -0
- /package/{types/util → util}/parse-array.d.ts +0 -0
- /package/{esm/util → util}/parse-array.js +0 -0
- /package/{types/util → util}/parse-datetime.d.ts +0 -0
- /package/{esm/util → util}/parse-datetime.js +0 -0
- /package/{types/util → util}/parse-row.d.ts +0 -0
- /package/{esm/util → util}/parse-row.js +0 -0
- /package/{types/util → util}/parse-time.d.ts +0 -0
- /package/{esm/util → util}/parse-time.js +0 -0
- /package/{types/util → util}/stringify-arrayliteral.d.ts +0 -0
- /package/{esm/util → util}/stringify-arrayliteral.js +0 -0
- /package/{types/util → util}/stringify-for-sql.d.ts +0 -0
- /package/{esm/util → util}/stringify-for-sql.js +0 -0
- /package/{types/util → util}/wrap-row-description.d.ts +0 -0
- /package/{esm/util → util}/wrap-row-description.js +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayTimestamptzType = exports.TimestamptzType = void 0;
|
|
4
|
-
const constants_js_1 = require("../constants.js");
|
|
5
|
-
const parse_datetime_js_1 = require("../util/parse-datetime.js");
|
|
6
|
-
const timeShift = 946684800000;
|
|
7
|
-
const timeMul = 4294967296;
|
|
8
|
-
exports.TimestamptzType = {
|
|
9
|
-
name: 'timestamptz',
|
|
10
|
-
oid: constants_js_1.DataTypeOIDs.timestamptz,
|
|
11
|
-
jsType: 'Date',
|
|
12
|
-
parseBinary(v, options) {
|
|
13
|
-
const fetchAsString = options.fetchAsString &&
|
|
14
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.timestamptz);
|
|
15
|
-
const hi = v.readInt32BE();
|
|
16
|
-
const lo = v.readUInt32BE(4);
|
|
17
|
-
if (lo === 0xffffffff && hi === 0x7fffffff)
|
|
18
|
-
return fetchAsString ? 'infinity' : Infinity;
|
|
19
|
-
if (lo === 0x00000000 && hi === -0x80000000)
|
|
20
|
-
return fetchAsString ? '-infinity' : -Infinity;
|
|
21
|
-
// Shift from 2000 to 1970
|
|
22
|
-
let d = new Date((lo + hi * timeMul) / 1000 + timeShift);
|
|
23
|
-
if (fetchAsString || !options.utcDates) {
|
|
24
|
-
d = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
|
|
25
|
-
}
|
|
26
|
-
return fetchAsString ? dateToTimestamptzString(d) : d;
|
|
27
|
-
},
|
|
28
|
-
encodeBinary(buf, v, options) {
|
|
29
|
-
if (typeof v === 'string')
|
|
30
|
-
v = (0, parse_datetime_js_1.parseDateTime)(v, true, true, options.utcDates);
|
|
31
|
-
if (v === Infinity) {
|
|
32
|
-
buf.writeInt32BE(0x7fffffff); // hi
|
|
33
|
-
buf.writeUInt32BE(0xffffffff); // lo
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (v === -Infinity) {
|
|
37
|
-
buf.writeInt32BE(-0x80000000); // hi
|
|
38
|
-
buf.writeUInt32BE(0x00000000); // lo
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!(v instanceof Date))
|
|
42
|
-
v = new Date(v);
|
|
43
|
-
let n = v.getTime();
|
|
44
|
-
n = (n - timeShift) * 1000;
|
|
45
|
-
const hi = Math.floor(n / timeMul);
|
|
46
|
-
const lo = n - hi * timeMul;
|
|
47
|
-
buf.writeInt32BE(hi);
|
|
48
|
-
buf.writeUInt32BE(lo);
|
|
49
|
-
},
|
|
50
|
-
parseText(v, options) {
|
|
51
|
-
const d = (0, parse_datetime_js_1.parseDateTime)(v, true, true, options.utcDates);
|
|
52
|
-
if (options.fetchAsString &&
|
|
53
|
-
options.fetchAsString.includes(constants_js_1.DataTypeOIDs.timestamptz)) {
|
|
54
|
-
if (d instanceof Date)
|
|
55
|
-
return dateToTimestamptzString(d);
|
|
56
|
-
if (d === Infinity)
|
|
57
|
-
return 'infinity';
|
|
58
|
-
if (d === -Infinity)
|
|
59
|
-
return '-infinity';
|
|
60
|
-
return '';
|
|
61
|
-
}
|
|
62
|
-
return d;
|
|
63
|
-
},
|
|
64
|
-
isType(v) {
|
|
65
|
-
return v instanceof Date;
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
function dateToTimestamptzString(d) {
|
|
69
|
-
return d.toISOString().replace('T', ' ');
|
|
70
|
-
}
|
|
71
|
-
exports.ArrayTimestamptzType = {
|
|
72
|
-
...exports.TimestamptzType,
|
|
73
|
-
name: '_timestamptz',
|
|
74
|
-
oid: constants_js_1.DataTypeOIDs._timestamptz,
|
|
75
|
-
elementsOID: constants_js_1.DataTypeOIDs.timestamptz,
|
|
76
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayUuidType = exports.UuidType = void 0;
|
|
4
|
-
const constants_js_1 = require("../constants.js");
|
|
5
|
-
const GUID_PATTERN = /^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/;
|
|
6
|
-
exports.UuidType = {
|
|
7
|
-
name: 'uuid',
|
|
8
|
-
oid: constants_js_1.DataTypeOIDs.uuid,
|
|
9
|
-
jsType: 'String',
|
|
10
|
-
parseBinary(v) {
|
|
11
|
-
return (v.toString('hex', 0, 4) +
|
|
12
|
-
'-' +
|
|
13
|
-
v.toString('hex', 4, 6) +
|
|
14
|
-
'-' +
|
|
15
|
-
v.toString('hex', 6, 8) +
|
|
16
|
-
'-' +
|
|
17
|
-
v.toString('hex', 8, 10) +
|
|
18
|
-
'-' +
|
|
19
|
-
v.toString('hex', 10, 16));
|
|
20
|
-
},
|
|
21
|
-
encodeBinary(buf, v) {
|
|
22
|
-
if (!GUID_PATTERN.test(v))
|
|
23
|
-
throw new Error(`"${v}" is not a valid guid value`);
|
|
24
|
-
const b = Buffer.from(v.replace(/-/g, ''), 'hex');
|
|
25
|
-
buf.writeBuffer(b);
|
|
26
|
-
},
|
|
27
|
-
parseText(v) {
|
|
28
|
-
return v;
|
|
29
|
-
},
|
|
30
|
-
isType(v) {
|
|
31
|
-
return typeof v === 'string' && GUID_PATTERN.test(v);
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
exports.ArrayUuidType = {
|
|
35
|
-
...exports.UuidType,
|
|
36
|
-
name: '_uuid',
|
|
37
|
-
oid: constants_js_1.DataTypeOIDs._uuid,
|
|
38
|
-
elementsOID: constants_js_1.DataTypeOIDs.uuid,
|
|
39
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayVarcharType = exports.VarcharType = void 0;
|
|
4
|
-
const constants_js_1 = require("../constants.js");
|
|
5
|
-
exports.VarcharType = {
|
|
6
|
-
name: 'varchar',
|
|
7
|
-
oid: constants_js_1.DataTypeOIDs.varchar,
|
|
8
|
-
jsType: 'string',
|
|
9
|
-
parseBinary(v) {
|
|
10
|
-
return v.toString('utf8');
|
|
11
|
-
},
|
|
12
|
-
encodeBinary(buf, v) {
|
|
13
|
-
buf.writeString('' + v, 'utf8');
|
|
14
|
-
},
|
|
15
|
-
parseText(v) {
|
|
16
|
-
return '' + v;
|
|
17
|
-
},
|
|
18
|
-
isType(v) {
|
|
19
|
-
return typeof v === 'string';
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
exports.ArrayVarcharType = {
|
|
23
|
-
...exports.VarcharType,
|
|
24
|
-
name: '_varchar',
|
|
25
|
-
oid: constants_js_1.DataTypeOIDs._varchar,
|
|
26
|
-
elementsOID: constants_js_1.DataTypeOIDs.varchar,
|
|
27
|
-
};
|
package/cjs/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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/package.json
DELETED
package/cjs/protocol/backend.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Backend = void 0;
|
|
4
|
-
const buffer_reader_js_1 = require("./buffer-reader.js");
|
|
5
|
-
const protocol_js_1 = require("./protocol.js");
|
|
6
|
-
// 1 byte message type, 4 byte frame length
|
|
7
|
-
const HEADER_LENGTH = 5;
|
|
8
|
-
const ErrorFieldTypes = {
|
|
9
|
-
M: 'message',
|
|
10
|
-
S: 'severity',
|
|
11
|
-
V: 'severity',
|
|
12
|
-
C: 'code',
|
|
13
|
-
D: 'detail',
|
|
14
|
-
H: 'hint',
|
|
15
|
-
P: 'position',
|
|
16
|
-
p: 'internalPosition',
|
|
17
|
-
q: 'internalQuery',
|
|
18
|
-
W: 'where',
|
|
19
|
-
s: 'schema',
|
|
20
|
-
t: 'table',
|
|
21
|
-
c: 'column',
|
|
22
|
-
d: 'dataType',
|
|
23
|
-
n: 'constraint',
|
|
24
|
-
F: 'file',
|
|
25
|
-
L: 'line',
|
|
26
|
-
R: 'routine',
|
|
27
|
-
};
|
|
28
|
-
class Backend {
|
|
29
|
-
reset() {
|
|
30
|
-
this._buf = undefined;
|
|
31
|
-
}
|
|
32
|
-
parse(data, callback) {
|
|
33
|
-
if (this._buf) {
|
|
34
|
-
data = Buffer.concat([this._buf, data]);
|
|
35
|
-
this._buf = undefined;
|
|
36
|
-
}
|
|
37
|
-
const io = new buffer_reader_js_1.BufferReader(data);
|
|
38
|
-
let offsetBookmark;
|
|
39
|
-
while (io.length - io.offset >= HEADER_LENGTH) {
|
|
40
|
-
offsetBookmark = io.offset;
|
|
41
|
-
const code = io.readUInt8();
|
|
42
|
-
const len = io.readUInt32BE();
|
|
43
|
-
// Check if frame data not received yet
|
|
44
|
-
if (io.length - io.offset < len - 4) {
|
|
45
|
-
io.offset = offsetBookmark;
|
|
46
|
-
this._buf = io.readBuffer();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const parser = MessageParsers[code];
|
|
50
|
-
const v = parser && parser(io, code, len);
|
|
51
|
-
callback(code, v);
|
|
52
|
-
// Set offset to next message
|
|
53
|
-
io.offset = offsetBookmark + len + 1;
|
|
54
|
-
}
|
|
55
|
-
if (io.offset < io.length)
|
|
56
|
-
this._buf = io.readBuffer(io.length - io.offset);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Backend = Backend;
|
|
60
|
-
const MessageParsers = {
|
|
61
|
-
[protocol_js_1.Protocol.BackendMessageCode.Authentication]: parseAuthentication,
|
|
62
|
-
[protocol_js_1.Protocol.BackendMessageCode.BackendKeyData]: parseBackendKeyData,
|
|
63
|
-
[protocol_js_1.Protocol.BackendMessageCode.CommandComplete]: parseCommandComplete,
|
|
64
|
-
[protocol_js_1.Protocol.BackendMessageCode.CopyData]: parseCopyData,
|
|
65
|
-
[protocol_js_1.Protocol.BackendMessageCode.CopyInResponse]: parseCopyResponse,
|
|
66
|
-
[protocol_js_1.Protocol.BackendMessageCode.CopyOutResponse]: parseCopyResponse,
|
|
67
|
-
[protocol_js_1.Protocol.BackendMessageCode.CopyBothResponse]: parseCopyResponse,
|
|
68
|
-
[protocol_js_1.Protocol.BackendMessageCode.DataRow]: parseDataRow,
|
|
69
|
-
[protocol_js_1.Protocol.BackendMessageCode.ErrorResponse]: parseErrorResponse,
|
|
70
|
-
[protocol_js_1.Protocol.BackendMessageCode.NoticeResponse]: parseErrorResponse,
|
|
71
|
-
[protocol_js_1.Protocol.BackendMessageCode.NotificationResponse]: parseNotificationResponse,
|
|
72
|
-
[protocol_js_1.Protocol.BackendMessageCode.FunctionCallResponse]: parseFunctionCallResponse,
|
|
73
|
-
[protocol_js_1.Protocol.BackendMessageCode.NegotiateProtocolVersion]: parseNegotiateProtocolVersion,
|
|
74
|
-
[protocol_js_1.Protocol.BackendMessageCode.ParameterDescription]: parseParameterDescription,
|
|
75
|
-
[protocol_js_1.Protocol.BackendMessageCode.ParameterStatus]: parseParameterStatus,
|
|
76
|
-
[protocol_js_1.Protocol.BackendMessageCode.ReadyForQuery]: parseReadyForQuery,
|
|
77
|
-
[protocol_js_1.Protocol.BackendMessageCode.RowDescription]: parseRowDescription,
|
|
78
|
-
};
|
|
79
|
-
function parseAuthentication(io, code, len) {
|
|
80
|
-
const kind = io.readUInt32BE();
|
|
81
|
-
switch (kind) {
|
|
82
|
-
case 0:
|
|
83
|
-
return; // AuthenticationOk
|
|
84
|
-
case 2:
|
|
85
|
-
return {
|
|
86
|
-
kind: 'KerberosV5',
|
|
87
|
-
};
|
|
88
|
-
case 3:
|
|
89
|
-
return {
|
|
90
|
-
kind: 'CleartextPassword',
|
|
91
|
-
};
|
|
92
|
-
case 5:
|
|
93
|
-
return {
|
|
94
|
-
kind: 'MD5Password',
|
|
95
|
-
salt: io.readBuffer(len - 8),
|
|
96
|
-
};
|
|
97
|
-
case 6:
|
|
98
|
-
return {
|
|
99
|
-
kind: 'SCMCredential',
|
|
100
|
-
};
|
|
101
|
-
case 7:
|
|
102
|
-
return {
|
|
103
|
-
kind: 'GSS',
|
|
104
|
-
};
|
|
105
|
-
case 9:
|
|
106
|
-
return {
|
|
107
|
-
kind: 'SSPI',
|
|
108
|
-
};
|
|
109
|
-
case 8:
|
|
110
|
-
return {
|
|
111
|
-
kind: 'GSSContinue',
|
|
112
|
-
data: io.readBuffer(len - 8),
|
|
113
|
-
};
|
|
114
|
-
case 10: {
|
|
115
|
-
const out = {
|
|
116
|
-
kind: 'SASL',
|
|
117
|
-
mechanisms: [],
|
|
118
|
-
};
|
|
119
|
-
let mechanism;
|
|
120
|
-
while ((mechanism = io.readCString())) {
|
|
121
|
-
out.mechanisms.push(mechanism);
|
|
122
|
-
}
|
|
123
|
-
return out;
|
|
124
|
-
}
|
|
125
|
-
case 11:
|
|
126
|
-
return {
|
|
127
|
-
kind: 'SASLContinue',
|
|
128
|
-
data: io.readLString(len - 8, 'utf8'),
|
|
129
|
-
};
|
|
130
|
-
case 12:
|
|
131
|
-
return {
|
|
132
|
-
kind: 'SASLFinal',
|
|
133
|
-
data: io.readLString(len - 8, 'utf8'),
|
|
134
|
-
};
|
|
135
|
-
default:
|
|
136
|
-
throw new Error(`Unknown authentication kind (${kind})`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
function parseBackendKeyData(io) {
|
|
140
|
-
return {
|
|
141
|
-
processID: io.readUInt32BE(),
|
|
142
|
-
secretKey: io.readUInt32BE(),
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function parseCommandComplete(io) {
|
|
146
|
-
return {
|
|
147
|
-
command: io.readCString('utf8'),
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function parseCopyData(io, code, len) {
|
|
151
|
-
return {
|
|
152
|
-
data: io.readBuffer(len - 4),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function parseCopyResponse(io) {
|
|
156
|
-
const out = {
|
|
157
|
-
overallFormat: io.readUInt8() === 0
|
|
158
|
-
? protocol_js_1.Protocol.DataFormat.text
|
|
159
|
-
: protocol_js_1.Protocol.DataFormat.binary,
|
|
160
|
-
columnCount: io.readUInt16BE(),
|
|
161
|
-
};
|
|
162
|
-
if (out.columnCount) {
|
|
163
|
-
out.columnFormats = [];
|
|
164
|
-
for (let i = 0; i < out.columnCount; i++) {
|
|
165
|
-
out.columnFormats.push(io.readUInt16BE() === 0
|
|
166
|
-
? protocol_js_1.Protocol.DataFormat.text
|
|
167
|
-
: protocol_js_1.Protocol.DataFormat.binary);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return out;
|
|
171
|
-
}
|
|
172
|
-
function parseDataRow(io) {
|
|
173
|
-
const out = {
|
|
174
|
-
columnCount: io.readUInt16BE(),
|
|
175
|
-
};
|
|
176
|
-
if (out.columnCount) {
|
|
177
|
-
out.columns = [];
|
|
178
|
-
for (let i = 0; i < out.columnCount; i++) {
|
|
179
|
-
// The length of the column value, in bytes (this count does not include itself).
|
|
180
|
-
// Can be zero. As a special case, -1 indicates a NULL column value.
|
|
181
|
-
// No value bytes follow in the NULL case.
|
|
182
|
-
const l = io.readInt32BE();
|
|
183
|
-
if (l < 0)
|
|
184
|
-
out.columns.push(null);
|
|
185
|
-
else
|
|
186
|
-
out.columns.push(io.readBuffer(l));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return out;
|
|
190
|
-
}
|
|
191
|
-
function parseErrorResponse(io) {
|
|
192
|
-
const out = {};
|
|
193
|
-
let fieldType;
|
|
194
|
-
while ((fieldType = io.readLString(1)) !== '\0') {
|
|
195
|
-
const value = io.readCString('utf8');
|
|
196
|
-
const key = ErrorFieldTypes[fieldType];
|
|
197
|
-
if (key)
|
|
198
|
-
out[key] = value;
|
|
199
|
-
}
|
|
200
|
-
return out;
|
|
201
|
-
}
|
|
202
|
-
function parseNotificationResponse(io) {
|
|
203
|
-
return {
|
|
204
|
-
processId: io.readUInt32BE(),
|
|
205
|
-
channel: io.readCString(),
|
|
206
|
-
payload: io.readCString(),
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
function parseFunctionCallResponse(io, code, len) {
|
|
210
|
-
return {
|
|
211
|
-
result: io.readBuffer(len - 4),
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
function parseNegotiateProtocolVersion(io) {
|
|
215
|
-
return {
|
|
216
|
-
supportedVersionMinor: io.readUInt32BE(),
|
|
217
|
-
numberOfNotSupportedVersions: io.readUInt32BE(),
|
|
218
|
-
option: io.readCString('utf8'),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
function parseParameterDescription(io) {
|
|
222
|
-
const out = {
|
|
223
|
-
parameterCount: io.readUInt32BE(),
|
|
224
|
-
parameterIds: [],
|
|
225
|
-
};
|
|
226
|
-
for (let i = 0; i < out.parameterCount; i++) {
|
|
227
|
-
out.parameterIds.push(io.readUInt32BE());
|
|
228
|
-
}
|
|
229
|
-
return out;
|
|
230
|
-
}
|
|
231
|
-
function parseParameterStatus(io) {
|
|
232
|
-
return {
|
|
233
|
-
name: io.readCString('utf8'),
|
|
234
|
-
value: io.readCString('utf8'),
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function parseReadyForQuery(io) {
|
|
238
|
-
return {
|
|
239
|
-
status: io.readLString(1),
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function parseRowDescription(io) {
|
|
243
|
-
const fieldCount = io.readUInt16BE();
|
|
244
|
-
const out = {
|
|
245
|
-
fields: [],
|
|
246
|
-
};
|
|
247
|
-
for (let i = 0; i < fieldCount; i++) {
|
|
248
|
-
const field = {
|
|
249
|
-
fieldName: io.readCString('utf8'),
|
|
250
|
-
tableId: io.readInt32BE(),
|
|
251
|
-
columnId: io.readInt16BE(),
|
|
252
|
-
dataTypeId: io.readInt32BE(),
|
|
253
|
-
fixedSize: io.readInt16BE(),
|
|
254
|
-
modifier: io.readInt32BE(),
|
|
255
|
-
format: io.readInt16BE() === 0
|
|
256
|
-
? protocol_js_1.Protocol.DataFormat.text
|
|
257
|
-
: protocol_js_1.Protocol.DataFormat.binary,
|
|
258
|
-
};
|
|
259
|
-
out.fields.push(field);
|
|
260
|
-
}
|
|
261
|
-
return out;
|
|
262
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BufferReader = void 0;
|
|
4
|
-
class BufferReader {
|
|
5
|
-
constructor(buffer) {
|
|
6
|
-
this.offset = 0;
|
|
7
|
-
this.buffer = buffer;
|
|
8
|
-
}
|
|
9
|
-
get length() {
|
|
10
|
-
return this.buffer.length;
|
|
11
|
-
}
|
|
12
|
-
readUInt8() {
|
|
13
|
-
this._checkReadable(1);
|
|
14
|
-
const v = this.buffer.readUInt8(this.offset);
|
|
15
|
-
this.offset++;
|
|
16
|
-
return v;
|
|
17
|
-
}
|
|
18
|
-
readUInt16BE() {
|
|
19
|
-
this._checkReadable(2);
|
|
20
|
-
const v = this.buffer.readUInt16BE(this.offset);
|
|
21
|
-
this.offset += 2;
|
|
22
|
-
return v;
|
|
23
|
-
}
|
|
24
|
-
readInt16BE() {
|
|
25
|
-
this._checkReadable(2);
|
|
26
|
-
const v = this.buffer.readInt16BE(this.offset);
|
|
27
|
-
this.offset += 2;
|
|
28
|
-
return v;
|
|
29
|
-
}
|
|
30
|
-
readUInt32BE() {
|
|
31
|
-
this._checkReadable(4);
|
|
32
|
-
const v = this.buffer.readUInt32BE(this.offset);
|
|
33
|
-
this.offset += 4;
|
|
34
|
-
return v;
|
|
35
|
-
}
|
|
36
|
-
readInt32BE() {
|
|
37
|
-
this._checkReadable(4);
|
|
38
|
-
const v = this.buffer.readInt32BE(this.offset);
|
|
39
|
-
this.offset += 4;
|
|
40
|
-
return v;
|
|
41
|
-
}
|
|
42
|
-
readCString(encoding) {
|
|
43
|
-
const idx = this.buffer.indexOf(0, this.offset);
|
|
44
|
-
const v = this.buffer.toString(encoding, this.offset, idx);
|
|
45
|
-
this.offset = idx + 1;
|
|
46
|
-
return v;
|
|
47
|
-
}
|
|
48
|
-
readLString(len, encoding) {
|
|
49
|
-
if (len < 0)
|
|
50
|
-
return null;
|
|
51
|
-
this._checkReadable(len);
|
|
52
|
-
const v = this.buffer.toString(encoding, this.offset, this.offset + len);
|
|
53
|
-
this.offset += len;
|
|
54
|
-
return v;
|
|
55
|
-
}
|
|
56
|
-
readBuffer(len) {
|
|
57
|
-
if (len)
|
|
58
|
-
this._checkReadable(len);
|
|
59
|
-
const end = len !== undefined ? this.offset + len : this.length;
|
|
60
|
-
const buf = this.buffer.slice(this.offset, end);
|
|
61
|
-
this.offset = end;
|
|
62
|
-
return buf;
|
|
63
|
-
}
|
|
64
|
-
moveBy(n) {
|
|
65
|
-
return this.moveTo(this.offset + n);
|
|
66
|
-
}
|
|
67
|
-
moveTo(pos) {
|
|
68
|
-
if (pos >= this.length)
|
|
69
|
-
throw new Error('Eof in buffer detected');
|
|
70
|
-
this.offset = pos;
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
_checkReadable(size) {
|
|
74
|
-
if (this.offset + size - 1 >= this.length)
|
|
75
|
-
throw new Error('Eof in buffer detected');
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.BufferReader = BufferReader;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseError = void 0;
|
|
4
|
-
class DatabaseError extends Error {
|
|
5
|
-
constructor(msg) {
|
|
6
|
-
super(msg.message);
|
|
7
|
-
Object.assign(this, {
|
|
8
|
-
...msg,
|
|
9
|
-
line: undefined,
|
|
10
|
-
file: undefined,
|
|
11
|
-
routine: undefined,
|
|
12
|
-
});
|
|
13
|
-
if (msg.position)
|
|
14
|
-
this.position = parseInt(msg.position, 10) || undefined;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.DatabaseError = DatabaseError;
|