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