postgrejs 2.16.0 → 2.17.0

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/esm/connection/bind-param.js +1 -5
  3. package/esm/connection/connection.js +16 -20
  4. package/esm/connection/cursor.js +10 -15
  5. package/esm/connection/intl-connection.js +41 -46
  6. package/esm/connection/pool.js +28 -32
  7. package/esm/connection/portal.js +27 -31
  8. package/esm/connection/prepared-statement.js +31 -35
  9. package/esm/constants.js +122 -125
  10. package/esm/data-type-map.js +71 -75
  11. package/esm/data-types/bool-type.js +7 -10
  12. package/esm/data-types/box-type.js +7 -10
  13. package/esm/data-types/bytea-type.js +9 -13
  14. package/esm/data-types/char-type.js +7 -10
  15. package/esm/data-types/circle-type.js +7 -10
  16. package/esm/data-types/date-type.js +12 -15
  17. package/esm/data-types/float4-type.js +7 -10
  18. package/esm/data-types/float8-type.js +7 -10
  19. package/esm/data-types/int2-type.js +10 -13
  20. package/esm/data-types/int2-vector-type.js +13 -16
  21. package/esm/data-types/int4-type.js +10 -13
  22. package/esm/data-types/int8-type.js +9 -12
  23. package/esm/data-types/json-type.js +9 -12
  24. package/esm/data-types/jsonb-type.js +11 -14
  25. package/esm/data-types/lseg-type.js +7 -10
  26. package/esm/data-types/numeric-type.js +8 -12
  27. package/esm/data-types/oid-type.js +15 -18
  28. package/esm/data-types/point-type.js +7 -10
  29. package/esm/data-types/time-type.js +13 -16
  30. package/esm/data-types/timestamp-type.js +12 -15
  31. package/esm/data-types/timestamptz-type.js +12 -15
  32. package/esm/data-types/uuid-type.js +7 -10
  33. package/esm/data-types/varchar-type.js +7 -10
  34. package/esm/index.js +25 -28
  35. package/esm/interfaces/command-result.js +1 -2
  36. package/esm/interfaces/data-mapping-options.js +1 -2
  37. package/esm/interfaces/data-type.js +1 -2
  38. package/esm/interfaces/database-connection-params.js +1 -2
  39. package/esm/interfaces/field-info.js +1 -2
  40. package/esm/interfaces/query-options.js +1 -2
  41. package/esm/interfaces/query-result.js +1 -2
  42. package/esm/interfaces/script-execute-options.js +1 -2
  43. package/esm/interfaces/script-result.js +1 -2
  44. package/esm/interfaces/statement-prepare-options.js +1 -2
  45. package/esm/protocol/backend.js +24 -28
  46. package/esm/protocol/buffer-reader.js +1 -5
  47. package/esm/protocol/database-error.js +1 -5
  48. package/esm/protocol/frontend.js +27 -31
  49. package/esm/protocol/pg-socket.js +48 -53
  50. package/esm/protocol/protocol.js +2 -5
  51. package/esm/protocol/sasl.js +7 -11
  52. package/esm/protocol/smart-buffer.js +5 -10
  53. package/esm/safe-event-emitter.js +2 -6
  54. package/esm/types.js +1 -2
  55. package/esm/util/array-calculatedim.js +1 -4
  56. package/esm/util/bigint-methods.js +2 -6
  57. package/esm/util/config-from-env.js +5 -8
  58. package/esm/util/connection-config.js +8 -13
  59. package/esm/util/convert-row-to-object.js +1 -4
  60. package/esm/util/decode-binaryarray.js +3 -6
  61. package/esm/util/encode-binaryarray.js +5 -8
  62. package/esm/util/escape-literal.js +1 -4
  63. package/esm/util/fast-parseint.js +1 -4
  64. package/esm/util/get-parsers.js +8 -11
  65. package/esm/util/parse-array.js +1 -4
  66. package/esm/util/parse-datetime.js +5 -8
  67. package/esm/util/parse-row.js +1 -4
  68. package/esm/util/parse-time.js +8 -12
  69. package/esm/util/stringify-arrayliteral.js +3 -6
  70. package/esm/util/stringify-for-sql.js +8 -12
  71. package/esm/util/wrap-row-description.js +6 -9
  72. package/package.json +2 -2
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayBoxType = exports.BoxType = void 0;
4
- const constants_js_1 = require("../constants.js");
1
+ import { DataTypeOIDs } from '../constants.js';
5
2
  const BOX_PATTERN1 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
6
3
  const BOX_PATTERN2 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
7
4
  const BOX_PATTERN3 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
8
- exports.BoxType = {
5
+ export const BoxType = {
9
6
  name: 'box',
10
- oid: constants_js_1.DataTypeOIDs.box,
7
+ oid: DataTypeOIDs.box,
11
8
  jsType: 'object',
12
9
  arraySeparator: ';',
13
10
  parseBinary(v) {
@@ -44,9 +41,9 @@ exports.BoxType = {
44
41
  typeof v.y2 === 'number');
45
42
  },
46
43
  };
47
- exports.ArrayBoxType = {
48
- ...exports.BoxType,
44
+ export const ArrayBoxType = {
45
+ ...BoxType,
49
46
  name: '_box',
50
- oid: constants_js_1.DataTypeOIDs._box,
51
- elementsOID: constants_js_1.DataTypeOIDs.box,
47
+ oid: DataTypeOIDs._box,
48
+ elementsOID: DataTypeOIDs.box,
52
49
  };
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayByteaType = exports.ByteaType = void 0;
4
- const tslib_1 = require("tslib");
5
- const postgres_bytea_1 = tslib_1.__importDefault(require("postgres-bytea"));
6
- const constants_js_1 = require("../constants.js");
7
- exports.ByteaType = {
1
+ import decodeBytea from 'postgres-bytea';
2
+ import { DataTypeOIDs } from '../constants.js';
3
+ export const ByteaType = {
8
4
  name: 'bytea',
9
- oid: constants_js_1.DataTypeOIDs.bytea,
5
+ oid: DataTypeOIDs.bytea,
10
6
  jsType: 'Buffer',
11
7
  parseBinary(v) {
12
8
  return v;
@@ -14,14 +10,14 @@ exports.ByteaType = {
14
10
  encodeBinary(buf, v) {
15
11
  buf.writeBuffer(v);
16
12
  },
17
- parseText: postgres_bytea_1.default,
13
+ parseText: decodeBytea,
18
14
  isType(v) {
19
15
  return v instanceof Buffer;
20
16
  },
21
17
  };
22
- exports.ArrayByteaType = {
23
- ...exports.ByteaType,
18
+ export const ArrayByteaType = {
19
+ ...ByteaType,
24
20
  name: '_bytea',
25
- oid: constants_js_1.DataTypeOIDs._bytea,
26
- elementsOID: constants_js_1.DataTypeOIDs.bytea,
21
+ oid: DataTypeOIDs._bytea,
22
+ elementsOID: DataTypeOIDs.bytea,
27
23
  };
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayCharType = exports.CharType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.CharType = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ export const CharType = {
6
3
  name: 'char',
7
- oid: constants_js_1.DataTypeOIDs.char,
4
+ oid: DataTypeOIDs.char,
8
5
  jsType: 'string',
9
6
  parseBinary(v) {
10
7
  return v.toString('utf8');
@@ -19,9 +16,9 @@ exports.CharType = {
19
16
  return typeof v === 'string' && v.length === 1;
20
17
  },
21
18
  };
22
- exports.ArrayCharType = {
23
- ...exports.CharType,
19
+ export const ArrayCharType = {
20
+ ...CharType,
24
21
  name: '_char',
25
- oid: constants_js_1.DataTypeOIDs._char,
26
- elementsOID: constants_js_1.DataTypeOIDs.char,
22
+ oid: DataTypeOIDs._char,
23
+ elementsOID: DataTypeOIDs.char,
27
24
  };
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayCircleType = exports.CircleType = void 0;
4
- const constants_js_1 = require("../constants.js");
1
+ import { DataTypeOIDs } from '../constants.js';
5
2
  const CIRCLE_PATTERN1 = /^< *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *>$/;
6
3
  const CIRCLE_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *\)$/;
7
4
  const CIRCLE_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*)$/;
8
5
  const CIRCLE_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
9
- exports.CircleType = {
6
+ export const CircleType = {
10
7
  name: 'circle',
11
- oid: constants_js_1.DataTypeOIDs.circle,
8
+ oid: DataTypeOIDs.circle,
12
9
  jsType: 'object',
13
10
  parseBinary(v) {
14
11
  return {
@@ -40,9 +37,9 @@ exports.CircleType = {
40
37
  typeof v.r === 'number');
41
38
  },
42
39
  };
43
- exports.ArrayCircleType = {
44
- ...exports.CircleType,
40
+ export const ArrayCircleType = {
41
+ ...CircleType,
45
42
  name: '_circle',
46
- oid: constants_js_1.DataTypeOIDs._circle,
47
- elementsOID: constants_js_1.DataTypeOIDs.circle,
43
+ oid: DataTypeOIDs._circle,
44
+ elementsOID: DataTypeOIDs.circle,
48
45
  };
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayDateType = exports.DateType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const parse_datetime_js_1 = require("../util/parse-datetime.js");
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ import { parseDateTime } from '../util/parse-datetime.js';
6
3
  const timeShift = 946684800000;
7
- exports.DateType = {
4
+ export const DateType = {
8
5
  name: 'date',
9
- oid: constants_js_1.DataTypeOIDs.date,
6
+ oid: DataTypeOIDs.date,
10
7
  jsType: 'Date',
11
8
  parseBinary(v, options) {
12
- const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
9
+ const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.date);
13
10
  const t = v.readInt32BE();
14
11
  if (t === 0x7fffffff)
15
12
  return fetchAsString ? 'infinity' : Infinity;
@@ -23,7 +20,7 @@ exports.DateType = {
23
20
  },
24
21
  encodeBinary(buf, v, options) {
25
22
  if (typeof v === 'string')
26
- v = (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
23
+ v = parseDateTime(v, false, false, options.utcDates);
27
24
  if (v === Infinity) {
28
25
  buf.writeInt32BE(0x7fffffff);
29
26
  return;
@@ -40,10 +37,10 @@ exports.DateType = {
40
37
  buf.writeInt32BE(t);
41
38
  },
42
39
  parseText(v, options) {
43
- const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.date);
40
+ const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.date);
44
41
  if (fetchAsString)
45
42
  return v;
46
- return (0, parse_datetime_js_1.parseDateTime)(v, false, false, options.utcDates);
43
+ return parseDateTime(v, false, false, options.utcDates);
47
44
  },
48
45
  isType(v) {
49
46
  return (v instanceof Date &&
@@ -59,9 +56,9 @@ function padZero(v) {
59
56
  function dateToDateString(d) {
60
57
  return d.getFullYear() + '-' + padZero(d.getMonth() + 1) + '-' + padZero(d.getDate());
61
58
  }
62
- exports.ArrayDateType = {
63
- ...exports.DateType,
59
+ export const ArrayDateType = {
60
+ ...DateType,
64
61
  name: '_date',
65
- oid: constants_js_1.DataTypeOIDs._date,
66
- elementsOID: constants_js_1.DataTypeOIDs.date,
62
+ oid: DataTypeOIDs._date,
63
+ elementsOID: DataTypeOIDs.date,
67
64
  };
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayFloat4Type = exports.Float4Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.Float4Type = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ export const Float4Type = {
6
3
  name: 'float4',
7
- oid: constants_js_1.DataTypeOIDs.float4,
4
+ oid: DataTypeOIDs.float4,
8
5
  jsType: 'number',
9
6
  parseBinary(v) {
10
7
  return Math.round((v.readFloatBE(0) + Number.EPSILON) * 100) / 100;
@@ -17,9 +14,9 @@ exports.Float4Type = {
17
14
  return typeof v === 'number';
18
15
  },
19
16
  };
20
- exports.ArrayFloat4Type = {
21
- ...exports.Float4Type,
17
+ export const ArrayFloat4Type = {
18
+ ...Float4Type,
22
19
  name: '_float4',
23
- oid: constants_js_1.DataTypeOIDs._float4,
24
- elementsOID: constants_js_1.DataTypeOIDs.float4,
20
+ oid: DataTypeOIDs._float4,
21
+ elementsOID: DataTypeOIDs.float4,
25
22
  };
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayFloat8Type = exports.Float8Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.Float8Type = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ export const Float8Type = {
6
3
  name: 'float8',
7
- oid: constants_js_1.DataTypeOIDs.float8,
4
+ oid: DataTypeOIDs.float8,
8
5
  jsType: 'number',
9
6
  parseBinary(v) {
10
7
  return v.readDoubleBE(0);
@@ -17,9 +14,9 @@ exports.Float8Type = {
17
14
  return typeof v === 'number';
18
15
  },
19
16
  };
20
- exports.ArrayFloat8Type = {
21
- ...exports.Float8Type,
17
+ export const ArrayFloat8Type = {
18
+ ...Float8Type,
22
19
  name: '_float8',
23
- oid: constants_js_1.DataTypeOIDs._float8,
24
- elementsOID: constants_js_1.DataTypeOIDs.float8,
20
+ oid: DataTypeOIDs._float8,
21
+ elementsOID: DataTypeOIDs.float8,
25
22
  };
@@ -1,26 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt2Type = exports.Int2Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
6
- exports.Int2Type = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ import { fastParseInt } from '../util/fast-parseint.js';
3
+ export const Int2Type = {
7
4
  name: 'int2',
8
- oid: constants_js_1.DataTypeOIDs.int2,
5
+ oid: DataTypeOIDs.int2,
9
6
  jsType: 'number',
10
7
  parseBinary(v) {
11
8
  return v.readInt16BE(0);
12
9
  },
13
10
  encodeBinary(buf, v) {
14
- buf.writeInt16BE((0, fast_parseint_js_1.fastParseInt)(v));
11
+ buf.writeInt16BE(fastParseInt(v));
15
12
  },
16
- parseText: fast_parseint_js_1.fastParseInt,
13
+ parseText: fastParseInt,
17
14
  isType(v) {
18
15
  return typeof v === 'number' && Number.isInteger(v) && v >= -32768 && v <= 32767;
19
16
  },
20
17
  };
21
- exports.ArrayInt2Type = {
22
- ...exports.Int2Type,
18
+ export const ArrayInt2Type = {
19
+ ...Int2Type,
23
20
  name: '_int2',
24
- oid: constants_js_1.DataTypeOIDs._int2,
25
- elementsOID: constants_js_1.DataTypeOIDs.int2,
21
+ oid: DataTypeOIDs._int2,
22
+ elementsOID: DataTypeOIDs.int2,
26
23
  };
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt2VectorType = exports.Int2VectorType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const decode_binaryarray_js_1 = require("../util/decode-binaryarray.js");
6
- const encode_binaryarray_js_1 = require("../util/encode-binaryarray.js");
7
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
8
- exports.Int2VectorType = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ import { decodeBinaryArray } from '../util/decode-binaryarray.js';
3
+ import { encodeBinaryArray } from '../util/encode-binaryarray.js';
4
+ import { fastParseInt } from '../util/fast-parseint.js';
5
+ export const Int2VectorType = {
9
6
  name: 'int2vector',
10
- oid: constants_js_1.DataTypeOIDs.int2vector,
7
+ oid: DataTypeOIDs.int2vector,
11
8
  jsType: 'array',
12
9
  parseBinary(v) {
13
- return (0, decode_binaryarray_js_1.decodeBinaryArray)(v, b => b.readInt16BE()) || undefined;
10
+ return decodeBinaryArray(v, b => b.readInt16BE()) || undefined;
14
11
  },
15
12
  encodeBinary(buf, v) {
16
- (0, encode_binaryarray_js_1.encodeBinaryArray)(buf, v, constants_js_1.DataTypeOIDs.int2, {}, (io, x) => {
13
+ encodeBinaryArray(buf, v, DataTypeOIDs.int2, {}, (io, x) => {
17
14
  io.writeInt16BE(x);
18
15
  });
19
16
  },
@@ -21,7 +18,7 @@ exports.Int2VectorType = {
21
18
  return [v.length];
22
19
  },
23
20
  parseText(str) {
24
- return str.split(' ').map(fast_parseint_js_1.fastParseInt);
21
+ return str.split(' ').map(fastParseInt);
25
22
  },
26
23
  encodeText(v) {
27
24
  return v.join(' ');
@@ -30,9 +27,9 @@ exports.Int2VectorType = {
30
27
  return (Array.isArray(v) && !v.find(x => !(typeof x === 'number' && Number.isInteger(x) && x >= -32768 && x <= 32767)));
31
28
  },
32
29
  };
33
- exports.ArrayInt2VectorType = {
34
- ...exports.Int2VectorType,
30
+ export const ArrayInt2VectorType = {
31
+ ...Int2VectorType,
35
32
  name: '_int2vector',
36
- oid: constants_js_1.DataTypeOIDs._int2vector,
37
- elementsOID: constants_js_1.DataTypeOIDs.int2vector,
33
+ oid: DataTypeOIDs._int2vector,
34
+ elementsOID: DataTypeOIDs.int2vector,
38
35
  };
@@ -1,26 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt4Type = exports.Int4Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
6
- exports.Int4Type = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ import { fastParseInt } from '../util/fast-parseint.js';
3
+ export const Int4Type = {
7
4
  name: 'int4',
8
- oid: constants_js_1.DataTypeOIDs.int4,
5
+ oid: DataTypeOIDs.int4,
9
6
  jsType: 'number',
10
7
  parseBinary(v) {
11
8
  return v.readInt32BE(0);
12
9
  },
13
10
  encodeBinary(buf, v) {
14
- buf.writeInt32BE((0, fast_parseint_js_1.fastParseInt)(v));
11
+ buf.writeInt32BE(fastParseInt(v));
15
12
  },
16
- parseText: fast_parseint_js_1.fastParseInt,
13
+ parseText: fastParseInt,
17
14
  isType(v) {
18
15
  return typeof v === 'number' && Number.isInteger(v) && v <= Number.MAX_SAFE_INTEGER;
19
16
  },
20
17
  };
21
- exports.ArrayInt4Type = {
22
- ...exports.Int4Type,
18
+ export const ArrayInt4Type = {
19
+ ...Int4Type,
23
20
  name: '_int4',
24
- oid: constants_js_1.DataTypeOIDs._int4,
25
- elementsOID: constants_js_1.DataTypeOIDs.int4,
21
+ oid: DataTypeOIDs._int4,
22
+ elementsOID: DataTypeOIDs.int4,
26
23
  };
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayInt8Type = exports.Int8Type = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const bigint_methods_js_1 = require("../util/bigint-methods.js");
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ import { readBigInt64BE } from '../util/bigint-methods.js';
6
3
  const maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER);
7
- exports.Int8Type = {
4
+ export const Int8Type = {
8
5
  name: 'int8',
9
- oid: constants_js_1.DataTypeOIDs.int8,
6
+ oid: DataTypeOIDs.int8,
10
7
  jsType: 'BigInt',
11
8
  parseBinary(buf) {
12
- const v = typeof buf.readBigInt64BE === 'function' ? buf.readBigInt64BE(0) : (0, bigint_methods_js_1.readBigInt64BE)(buf);
9
+ const v = typeof buf.readBigInt64BE === 'function' ? buf.readBigInt64BE(0) : readBigInt64BE(buf);
13
10
  return v >= -maxSafeInteger && v <= maxSafeInteger ? Number(v) : v;
14
11
  },
15
12
  encodeBinary(buf, v) {
@@ -23,9 +20,9 @@ exports.Int8Type = {
23
20
  return typeof v === 'bigint' || (typeof v === 'number' && Number.isInteger(v) && v > Number.MAX_SAFE_INTEGER);
24
21
  },
25
22
  };
26
- exports.ArrayInt8Type = {
27
- ...exports.Int8Type,
23
+ export const ArrayInt8Type = {
24
+ ...Int8Type,
28
25
  name: '_int8',
29
- oid: constants_js_1.DataTypeOIDs._int8,
30
- elementsOID: constants_js_1.DataTypeOIDs.int8,
26
+ oid: DataTypeOIDs._int8,
27
+ elementsOID: DataTypeOIDs.int8,
31
28
  };
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayJsonType = exports.JsonType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- exports.JsonType = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ export const JsonType = {
6
3
  name: 'json',
7
- oid: constants_js_1.DataTypeOIDs.json,
4
+ oid: DataTypeOIDs.json,
8
5
  jsType: 'string',
9
6
  parseBinary(v, options) {
10
7
  const content = v.toString('utf8');
11
- const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
8
+ const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.jsonb);
12
9
  if (fetchAsString)
13
10
  return content;
14
11
  return content ? JSON.parse(content) : undefined;
@@ -21,7 +18,7 @@ exports.JsonType = {
21
18
  return '' + v;
22
19
  },
23
20
  parseText(v, options) {
24
- const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.jsonb);
21
+ const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.jsonb);
25
22
  if (fetchAsString)
26
23
  return v;
27
24
  return v ? JSON.parse(v) : null;
@@ -30,9 +27,9 @@ exports.JsonType = {
30
27
  return v && typeof v === 'object';
31
28
  },
32
29
  };
33
- exports.ArrayJsonType = {
34
- ...exports.JsonType,
30
+ export const ArrayJsonType = {
31
+ ...JsonType,
35
32
  name: '_json',
36
- oid: constants_js_1.DataTypeOIDs._json,
37
- elementsOID: constants_js_1.DataTypeOIDs.json,
33
+ oid: DataTypeOIDs._json,
34
+ elementsOID: DataTypeOIDs.json,
38
35
  };
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayJsonbType = exports.JsonbType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const buffer_reader_js_1 = require("../protocol/buffer-reader.js");
6
- exports.JsonbType = {
1
+ import { DataTypeOIDs } from '../constants.js';
2
+ import { BufferReader } from '../protocol/buffer-reader.js';
3
+ export const JsonbType = {
7
4
  name: 'jsonb',
8
- oid: constants_js_1.DataTypeOIDs.jsonb,
5
+ oid: DataTypeOIDs.jsonb,
9
6
  jsType: 'string',
10
7
  parseBinary(v, options) {
11
- const buf = new buffer_reader_js_1.BufferReader(v);
8
+ const buf = new BufferReader(v);
12
9
  if (buf.readUInt8() !== 1)
13
10
  throw new Error('Unexpected Jsonb version value in header');
14
- const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
11
+ const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.json);
15
12
  const content = buf.readLString(buf.length - buf.offset);
16
13
  if (fetchAsString)
17
14
  return content;
@@ -25,7 +22,7 @@ exports.JsonbType = {
25
22
  return '\x0001' + v;
26
23
  },
27
24
  parseText(v, options) {
28
- const fetchAsString = options.fetchAsString && options.fetchAsString.includes(constants_js_1.DataTypeOIDs.json);
25
+ const fetchAsString = options.fetchAsString && options.fetchAsString.includes(DataTypeOIDs.json);
29
26
  if (fetchAsString)
30
27
  return v;
31
28
  return v ? JSON.parse(v) : null;
@@ -34,9 +31,9 @@ exports.JsonbType = {
34
31
  return v && typeof v === 'object';
35
32
  },
36
33
  };
37
- exports.ArrayJsonbType = {
38
- ...exports.JsonbType,
34
+ export const ArrayJsonbType = {
35
+ ...JsonbType,
39
36
  name: '_jsonb',
40
- oid: constants_js_1.DataTypeOIDs._jsonb,
41
- elementsOID: constants_js_1.DataTypeOIDs.jsonb,
37
+ oid: DataTypeOIDs._jsonb,
38
+ elementsOID: DataTypeOIDs.jsonb,
42
39
  };
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayLsegType = exports.LsegType = void 0;
4
- const constants_js_1 = require("../constants.js");
1
+ import { DataTypeOIDs } from '../constants.js';
5
2
  const LSEG_PATTERN1 = /^\[ *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *]$/;
6
3
  const LSEG_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
7
4
  const LSEG_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
8
5
  const LSEG_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
9
- exports.LsegType = {
6
+ export const LsegType = {
10
7
  name: 'lseg',
11
- oid: constants_js_1.DataTypeOIDs.lseg,
8
+ oid: DataTypeOIDs.lseg,
12
9
  jsType: 'object',
13
10
  parseBinary(v) {
14
11
  return {
@@ -44,9 +41,9 @@ exports.LsegType = {
44
41
  typeof v.y2 === 'number');
45
42
  },
46
43
  };
47
- exports.ArrayLsegType = {
48
- ...exports.LsegType,
44
+ export const ArrayLsegType = {
45
+ ...LsegType,
49
46
  name: '_lseg',
50
- oid: constants_js_1.DataTypeOIDs._lseg,
51
- elementsOID: constants_js_1.DataTypeOIDs.lseg,
47
+ oid: DataTypeOIDs._lseg,
48
+ elementsOID: DataTypeOIDs.lseg,
52
49
  };
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayNumericType = exports.NumericType = void 0;
4
- exports.numberBytesToString = numberBytesToString;
5
- const constants_js_1 = require("../constants.js");
1
+ import { DataTypeOIDs } from '../constants.js';
6
2
  const NUMERIC_NEG = 0x4000;
7
3
  const NUMERIC_NAN = 0xc000;
8
4
  const DEC_DIGITS = 4;
9
5
  const ROUND_POWERS = [0, 1000, 100, 10];
10
- exports.NumericType = {
6
+ export const NumericType = {
11
7
  name: 'numeric',
12
- oid: constants_js_1.DataTypeOIDs.numeric,
8
+ oid: DataTypeOIDs.numeric,
13
9
  jsType: 'number',
14
10
  parseBinary(v) {
15
11
  const len = v.readInt16BE();
@@ -34,11 +30,11 @@ exports.NumericType = {
34
30
  return typeof v === 'number';
35
31
  },
36
32
  };
37
- exports.ArrayNumericType = {
38
- ...exports.NumericType,
33
+ export const ArrayNumericType = {
34
+ ...NumericType,
39
35
  name: '_numeric',
40
- oid: constants_js_1.DataTypeOIDs._numeric,
41
- elementsOID: constants_js_1.DataTypeOIDs.numeric,
36
+ oid: DataTypeOIDs._numeric,
37
+ elementsOID: DataTypeOIDs.numeric,
42
38
  };
43
39
  /* https://github.com/pgjdbc/pgjdbc/blob/3eca3a76aa4a04cb28cb960ed674cb67db30b5e3/pgjdbc/src/main/java/org/postgresql/util/ByteConverter.java */
44
40
  /**
@@ -49,7 +45,7 @@ exports.ArrayNumericType = {
49
45
  * @param sign the sign of the number
50
46
  * @return String the number as String
51
47
  */
52
- function numberBytesToString(digits, scale, weight, sign) {
48
+ export function numberBytesToString(digits, scale, weight, sign) {
53
49
  let i;
54
50
  let d;
55
51
  /*
@@ -1,32 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VectorOidType = exports.ArrayOidType = exports.OidType = void 0;
4
- const constants_js_1 = require("../constants.js");
5
- const fast_parseint_js_1 = require("../util/fast-parseint.js");
6
- exports.OidType = {
1
+ import { DataTypeNames, DataTypeOIDs } from '../constants.js';
2
+ import { fastParseInt } from '../util/fast-parseint.js';
3
+ export const OidType = {
7
4
  name: 'oid',
8
- oid: constants_js_1.DataTypeOIDs.oid,
5
+ oid: DataTypeOIDs.oid,
9
6
  jsType: 'number',
10
7
  parseBinary(v) {
11
8
  return v.readUInt32BE(0);
12
9
  },
13
10
  encodeBinary(buf, v) {
14
- buf.writeUInt32BE((0, fast_parseint_js_1.fastParseInt)(v));
11
+ buf.writeUInt32BE(fastParseInt(v));
15
12
  },
16
- parseText: fast_parseint_js_1.fastParseInt,
13
+ parseText: fastParseInt,
17
14
  isType(v) {
18
- return typeof v === 'number' && Number.isInteger(v) && !!constants_js_1.DataTypeNames[v];
15
+ return typeof v === 'number' && Number.isInteger(v) && !!DataTypeNames[v];
19
16
  },
20
17
  };
21
- exports.ArrayOidType = {
22
- ...exports.OidType,
18
+ export const ArrayOidType = {
19
+ ...OidType,
23
20
  name: '_oid',
24
- oid: constants_js_1.DataTypeOIDs._oid,
25
- elementsOID: constants_js_1.DataTypeOIDs.oid,
21
+ oid: DataTypeOIDs._oid,
22
+ elementsOID: DataTypeOIDs.oid,
26
23
  };
27
- exports.VectorOidType = {
28
- ...exports.OidType,
24
+ export const VectorOidType = {
25
+ ...OidType,
29
26
  name: '_oidvector',
30
- oid: constants_js_1.DataTypeOIDs.oidvector,
31
- elementsOID: constants_js_1.DataTypeOIDs.oid,
27
+ oid: DataTypeOIDs.oidvector,
28
+ elementsOID: DataTypeOIDs.oid,
32
29
  };
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayPointType = exports.PointType = void 0;
4
- const constants_js_1 = require("../constants.js");
1
+ import { DataTypeOIDs } from '../constants.js';
5
2
  const POINT_PATTERN1 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
6
3
  const POINT_PATTERN2 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
7
- exports.PointType = {
4
+ export const PointType = {
8
5
  name: 'point',
9
- oid: constants_js_1.DataTypeOIDs.point,
6
+ oid: DataTypeOIDs.point,
10
7
  jsType: 'object',
11
8
  parseBinary(v) {
12
9
  return {
@@ -31,9 +28,9 @@ exports.PointType = {
31
28
  return typeof v === 'object' && Object.keys(v).length === 2 && typeof v.x === 'number' && typeof v.y === 'number';
32
29
  },
33
30
  };
34
- exports.ArrayPointType = {
35
- ...exports.PointType,
31
+ export const ArrayPointType = {
32
+ ...PointType,
36
33
  name: '_point',
37
- oid: constants_js_1.DataTypeOIDs._point,
38
- elementsOID: constants_js_1.DataTypeOIDs.point,
34
+ oid: DataTypeOIDs._point,
35
+ elementsOID: DataTypeOIDs.point,
39
36
  };