postgrejs 3.12.0 → 3.12.2

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 (184) hide show
  1. package/README.md +1 -1
  2. package/connection/bind-param.d.ts +21 -0
  3. package/connection/bind-param.js +21 -0
  4. package/connection/connection.d.ts +136 -0
  5. package/connection/connection.js +132 -5
  6. package/connection/copy-stream.d.ts +2 -0
  7. package/connection/copy-stream.js +2 -0
  8. package/connection/cursor.d.ts +67 -5
  9. package/connection/cursor.js +88 -15
  10. package/connection/intl-connection.d.ts +14 -0
  11. package/connection/intl-connection.js +95 -15
  12. package/connection/large-object.d.ts +18 -0
  13. package/connection/large-object.js +17 -0
  14. package/connection/logical-replication.d.ts +15 -0
  15. package/connection/logical-replication.js +6 -0
  16. package/connection/pool.d.ts +80 -0
  17. package/connection/pool.js +82 -9
  18. package/connection/portal.d.ts +37 -0
  19. package/connection/portal.js +29 -0
  20. package/connection/prepared-statement.d.ts +68 -0
  21. package/connection/prepared-statement.js +71 -2
  22. package/constants.d.ts +18 -0
  23. package/constants.js +18 -0
  24. package/data-type-map.d.ts +38 -0
  25. package/data-type-map.js +38 -0
  26. package/data-types/bit-type.d.ts +4 -0
  27. package/data-types/bit-type.js +4 -0
  28. package/data-types/bool-type.d.ts +2 -0
  29. package/data-types/bool-type.js +2 -0
  30. package/data-types/box-type.d.ts +2 -0
  31. package/data-types/box-type.js +2 -0
  32. package/data-types/bytea-type.d.ts +2 -0
  33. package/data-types/bytea-type.js +2 -0
  34. package/data-types/char-type.d.ts +2 -0
  35. package/data-types/char-type.js +2 -0
  36. package/data-types/circle-type.d.ts +2 -0
  37. package/data-types/circle-type.js +2 -0
  38. package/data-types/date-type.d.ts +2 -0
  39. package/data-types/date-type.js +2 -0
  40. package/data-types/float4-type.d.ts +2 -0
  41. package/data-types/float4-type.js +2 -0
  42. package/data-types/float8-type.d.ts +2 -0
  43. package/data-types/float8-type.js +2 -0
  44. package/data-types/inet-type.d.ts +4 -0
  45. package/data-types/inet-type.js +4 -0
  46. package/data-types/int2-type.d.ts +2 -0
  47. package/data-types/int2-type.js +2 -0
  48. package/data-types/int2-vector-type.d.ts +2 -0
  49. package/data-types/int2-vector-type.js +2 -0
  50. package/data-types/int4-type.d.ts +2 -0
  51. package/data-types/int4-type.js +2 -0
  52. package/data-types/int8-type.d.ts +2 -0
  53. package/data-types/int8-type.js +2 -0
  54. package/data-types/interval-type.d.ts +9 -0
  55. package/data-types/interval-type.js +9 -0
  56. package/data-types/json-type.d.ts +2 -0
  57. package/data-types/json-type.js +2 -0
  58. package/data-types/jsonb-type.d.ts +2 -0
  59. package/data-types/jsonb-type.js +2 -0
  60. package/data-types/jsonpath-type.d.ts +2 -0
  61. package/data-types/jsonpath-type.js +2 -0
  62. package/data-types/line-type.d.ts +2 -0
  63. package/data-types/line-type.js +2 -0
  64. package/data-types/lseg-type.d.ts +2 -0
  65. package/data-types/lseg-type.js +2 -0
  66. package/data-types/macaddr-type.d.ts +4 -0
  67. package/data-types/macaddr-type.js +4 -0
  68. package/data-types/money-type.d.ts +1 -0
  69. package/data-types/money-type.js +17 -10
  70. package/data-types/numeric-type.d.ts +2 -0
  71. package/data-types/numeric-type.js +2 -0
  72. package/data-types/oid-type.d.ts +2 -0
  73. package/data-types/oid-type.js +2 -0
  74. package/data-types/oid-vector-type.d.ts +1 -0
  75. package/data-types/oid-vector-type.js +1 -0
  76. package/data-types/path-type.d.ts +4 -0
  77. package/data-types/path-type.js +4 -0
  78. package/data-types/pg-lsn-type.d.ts +2 -0
  79. package/data-types/pg-lsn-type.js +2 -0
  80. package/data-types/point-type.d.ts +2 -0
  81. package/data-types/point-type.js +2 -0
  82. package/data-types/range-type.d.ts +4 -0
  83. package/data-types/range-type.js +4 -0
  84. package/data-types/snapshot-type.d.ts +4 -0
  85. package/data-types/snapshot-type.js +4 -0
  86. package/data-types/tid-type.d.ts +2 -0
  87. package/data-types/tid-type.js +2 -0
  88. package/data-types/time-type.d.ts +2 -0
  89. package/data-types/time-type.js +2 -0
  90. package/data-types/timestamp-type.d.ts +2 -0
  91. package/data-types/timestamp-type.js +2 -0
  92. package/data-types/timestamptz-type.d.ts +2 -0
  93. package/data-types/timestamptz-type.js +2 -0
  94. package/data-types/timetz-type.d.ts +2 -0
  95. package/data-types/timetz-type.js +2 -0
  96. package/data-types/tsvector-type.d.ts +4 -0
  97. package/data-types/tsvector-type.js +4 -0
  98. package/data-types/uuid-type.d.ts +2 -0
  99. package/data-types/uuid-type.js +2 -0
  100. package/data-types/varchar-type.d.ts +2 -0
  101. package/data-types/varchar-type.js +2 -0
  102. package/data-types/xid-type.d.ts +6 -0
  103. package/data-types/xid-type.js +6 -0
  104. package/interfaces/command-result.d.ts +7 -0
  105. package/interfaces/copy-from-rows-options.d.ts +4 -0
  106. package/interfaces/data-mapping-options.d.ts +6 -0
  107. package/interfaces/data-type.d.ts +37 -0
  108. package/interfaces/database-connection-params.d.ts +31 -0
  109. package/interfaces/field-info.d.ts +8 -0
  110. package/interfaces/function-call-options.d.ts +1 -0
  111. package/interfaces/function-call-result.d.ts +6 -0
  112. package/interfaces/pipeline-request.d.ts +2 -0
  113. package/interfaces/query-options.d.ts +7 -0
  114. package/interfaces/query-result.d.ts +7 -0
  115. package/interfaces/script-execute-options.d.ts +4 -0
  116. package/interfaces/script-result.d.ts +1 -0
  117. package/interfaces/statement-prepare-options.d.ts +1 -0
  118. package/package.json +5 -5
  119. package/protocol/backend.d.ts +6 -0
  120. package/protocol/backend.js +35 -5
  121. package/protocol/cert-signature.d.ts +8 -0
  122. package/protocol/cert-signature.js +8 -0
  123. package/protocol/database-error.d.ts +8 -0
  124. package/protocol/database-error.js +8 -0
  125. package/protocol/frontend.d.ts +16 -0
  126. package/protocol/frontend.js +13 -6
  127. package/protocol/pg-socket.d.ts +10 -0
  128. package/protocol/pg-socket.js +14 -7
  129. package/protocol/pgoutput.d.ts +15 -0
  130. package/protocol/pgoutput.js +7 -0
  131. package/protocol/protocol.d.ts +50 -2
  132. package/protocol/protocol.js +17 -1
  133. package/protocol/sasl.d.ts +22 -0
  134. package/protocol/sasl.js +21 -0
  135. package/protocol/smart-buffer.d.ts +4 -0
  136. package/safe-event-emitter.d.ts +7 -0
  137. package/safe-event-emitter.js +7 -0
  138. package/types.d.ts +21 -0
  139. package/util/array-calculatedim.d.ts +10 -0
  140. package/util/array-calculatedim.js +10 -0
  141. package/util/bigint-methods.d.ts +7 -0
  142. package/util/bigint-methods.js +9 -0
  143. package/util/config-from-env.d.ts +10 -0
  144. package/util/config-from-env.js +10 -0
  145. package/util/connection-config.d.ts +17 -0
  146. package/util/connection-config.js +17 -0
  147. package/util/copy-from-rows.d.ts +12 -0
  148. package/util/copy-from-rows.js +9 -0
  149. package/util/decimal-as-string.d.ts +6 -0
  150. package/util/decimal-as-string.js +6 -0
  151. package/util/decode-binaryarray.d.ts +9 -0
  152. package/util/decode-binaryarray.js +9 -0
  153. package/util/escape-literal.d.ts +11 -0
  154. package/util/escape-literal.js +13 -0
  155. package/util/fast-parseint.d.ts +14 -0
  156. package/util/fast-parseint.js +14 -0
  157. package/util/format-datetime.d.ts +26 -0
  158. package/util/format-datetime.js +26 -0
  159. package/util/get-parsers.d.ts +9 -0
  160. package/util/get-parsers.js +9 -0
  161. package/util/hex-text.d.ts +13 -21
  162. package/util/hex-text.js +24 -21
  163. package/util/local-date.d.ts +2 -41
  164. package/util/local-date.js +39 -41
  165. package/util/parse-array.d.ts +8 -0
  166. package/util/parse-array.js +8 -0
  167. package/util/parse-bytea.d.ts +15 -0
  168. package/util/parse-bytea.js +15 -0
  169. package/util/parse-datetime.d.ts +26 -0
  170. package/util/parse-datetime.js +26 -0
  171. package/util/parse-row.d.ts +23 -2
  172. package/util/parse-row.js +56 -36
  173. package/util/parse-time.d.ts +10 -0
  174. package/util/parse-time.js +10 -0
  175. package/util/resolve-column-formats.d.ts +1 -0
  176. package/util/row-decoder.d.ts +32 -0
  177. package/util/row-decoder.js +22 -0
  178. package/util/stringify-arrayliteral.d.ts +33 -0
  179. package/util/stringify-arrayliteral.js +220 -20
  180. package/util/stringify-for-sql.d.ts +17 -0
  181. package/util/stringify-for-sql.js +17 -0
  182. package/util/wrap-row-description.d.ts +10 -0
  183. package/util/wrap-row-description.js +10 -0
  184. package/CHANGELOG.md +0 -1453
@@ -1,5 +1,20 @@
1
1
  import type { DataType } from './interfaces/data-type.js';
2
2
  import type { OID } from './types.js';
3
+ /**
4
+ * Which `DataType` answers for which OID.
5
+ *
6
+ * `GlobalTypeMap` is the one every connection uses unless it was given
7
+ * its own, and it already holds every type this client knows. A caller
8
+ * registers into it to add a type - a PostGIS geometry, a composite of
9
+ * their own - or copies it and registers into the copy to change one
10
+ * type for one connection without touching anyone else's.
11
+ *
12
+ * ```ts
13
+ * const typeMap = new DataTypeMap(GlobalTypeMap);
14
+ * typeMap.register(MyGeometryType);
15
+ * const connection = new Connection({ ...config, typeMap });
16
+ * ```
17
+ */
3
18
  export declare class DataTypeMap {
4
19
  protected _inferScalars: DataType[];
5
20
  protected _inferArrays: DataType[];
@@ -17,7 +32,22 @@ export declare class DataTypeMap {
17
32
  * nothing reported.
18
33
  */
19
34
  constructor(other?: DataTypeMap);
35
+ /**
36
+ * The type registered for an OID.
37
+ *
38
+ * @param oid The type to look up.
39
+ * @returns Its `DataType`, or `undefined` when nothing is registered -
40
+ * in which case values of that type come back as raw `Buffer`s.
41
+ */
20
42
  get(oid: OID): DataType;
43
+ /**
44
+ * Registers a type, or replaces the one already holding its OID.
45
+ *
46
+ * The array counterpart is its own registration: register both to have
47
+ * both read and written.
48
+ *
49
+ * @param dataTypes The type, or several at once.
50
+ */
21
51
  register(dataTypes: DataType | DataType[]): void;
22
52
  /**
23
53
  * The two lists determine() actually walks, newest-registered first.
@@ -35,4 +65,12 @@ export declare class DataTypeMap {
35
65
  protected _rebuildInferenceLists(): void;
36
66
  determine(value: any): OID;
37
67
  }
68
+ /**
69
+ * The map every connection reads unless it was given one of its own -
70
+ * already holding every type this client knows.
71
+ *
72
+ * Registering here changes what every connection in the process does,
73
+ * which is what makes it the place for a type the whole application
74
+ * shares, and the wrong place for one connection's exception.
75
+ */
38
76
  export declare const GlobalTypeMap: DataTypeMap;
package/data-type-map.js CHANGED
@@ -40,6 +40,21 @@ import { ArrayUuidType, UuidType } from './data-types/uuid-type.js';
40
40
  import { ArrayVarcharType, VarcharType } from './data-types/varchar-type.js';
41
41
  import { ArrayCidType, ArrayXid8Type, ArrayXidType, CidType, Xid8Type, XidType, } from './data-types/xid-type.js';
42
42
  import { arrayLeaf } from './util/array-leaf.js';
43
+ /**
44
+ * Which `DataType` answers for which OID.
45
+ *
46
+ * `GlobalTypeMap` is the one every connection uses unless it was given
47
+ * its own, and it already holds every type this client knows. A caller
48
+ * registers into it to add a type - a PostGIS geometry, a composite of
49
+ * their own - or copies it and registers into the copy to change one
50
+ * type for one connection without touching anyone else's.
51
+ *
52
+ * ```ts
53
+ * const typeMap = new DataTypeMap(GlobalTypeMap);
54
+ * typeMap.register(MyGeometryType);
55
+ * const connection = new Connection({ ...config, typeMap });
56
+ * ```
57
+ */
43
58
  export class DataTypeMap {
44
59
  _inferScalars = [];
45
60
  _inferArrays = [];
@@ -67,9 +82,24 @@ export class DataTypeMap {
67
82
  this._inferArrays = other._inferArrays;
68
83
  }
69
84
  }
85
+ /**
86
+ * The type registered for an OID.
87
+ *
88
+ * @param oid The type to look up.
89
+ * @returns Its `DataType`, or `undefined` when nothing is registered -
90
+ * in which case values of that type come back as raw `Buffer`s.
91
+ */
70
92
  get(oid) {
71
93
  return this._itemsByOID[oid];
72
94
  }
95
+ /**
96
+ * Registers a type, or replaces the one already holding its OID.
97
+ *
98
+ * The array counterpart is its own registration: register both to have
99
+ * both read and written.
100
+ *
101
+ * @param dataTypes The type, or several at once.
102
+ */
73
103
  register(dataTypes) {
74
104
  dataTypes = Array.isArray(dataTypes) ? dataTypes : [dataTypes];
75
105
  for (const t of dataTypes) {
@@ -155,6 +185,14 @@ export class DataTypeMap {
155
185
  return DataTypeOIDs.unknown;
156
186
  }
157
187
  }
188
+ /**
189
+ * The map every connection reads unless it was given one of its own -
190
+ * already holding every type this client knows.
191
+ *
192
+ * Registering here changes what every connection in the process does,
193
+ * which is what makes it the place for a type the whole application
194
+ * shares, and the wrong place for one connection's exception.
195
+ */
158
196
  export const GlobalTypeMap = new DataTypeMap();
159
197
  GlobalTypeMap.register([OidType, ArrayOidType]);
160
198
  GlobalTypeMap.register([OidVectorType, ArrayOidVectorType]);
@@ -1,5 +1,9 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `bit(n)`, as a string of `0`s and `1`s - its own text form, and the only lossless one for a length the server chose. */
2
3
  export declare const BitType: DataType;
4
+ /** The `_bit` array of {@link BitType}. */
3
5
  export declare const ArrayBitType: DataType;
6
+ /** `varbit` (bit varying), as a string of `0`s and `1`s. */
4
7
  export declare const VarbitType: DataType;
8
+ /** The `_varbit` array of {@link VarbitType}. */
5
9
  export declare const ArrayVarbitType: DataType;
@@ -75,14 +75,18 @@ function createType(name, oid) {
75
75
  },
76
76
  };
77
77
  }
78
+ /** `bit(n)`, as a string of `0`s and `1`s - its own text form, and the only lossless one for a length the server chose. */
78
79
  export const BitType = createType('bit', DataTypeOIDs.bit);
80
+ /** The `_bit` array of {@link BitType}. */
79
81
  export const ArrayBitType = {
80
82
  ...BitType,
81
83
  name: '_bit',
82
84
  oid: DataTypeOIDs._bit,
83
85
  elementsOID: DataTypeOIDs.bit,
84
86
  };
87
+ /** `varbit` (bit varying), as a string of `0`s and `1`s. */
85
88
  export const VarbitType = createType('varbit', DataTypeOIDs.varbit);
89
+ /** The `_varbit` array of {@link VarbitType}. */
86
90
  export const ArrayVarbitType = {
87
91
  ...VarbitType,
88
92
  name: '_varbit',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `bool`, as a JavaScript boolean. Its text form is the `t`/`f` the server itself writes. */
2
3
  export declare const BoolType: DataType;
4
+ /** The `_bool` array of {@link BoolType}. */
3
5
  export declare const ArrayBoolType: DataType;
@@ -1,4 +1,5 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
+ /** `bool`, as a JavaScript boolean. Its text form is the `t`/`f` the server itself writes. */
2
3
  export const BoolType = {
3
4
  name: 'bool',
4
5
  oid: DataTypeOIDs.bool,
@@ -25,6 +26,7 @@ export const BoolType = {
25
26
  return typeof v === 'boolean';
26
27
  },
27
28
  };
29
+ /** The `_bool` array of {@link BoolType}. */
28
30
  export const ArrayBoolType = {
29
31
  ...BoolType,
30
32
  name: '_bool',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `box`, as a {@link Box}. Its array literal separates elements with a semicolon rather than a comma, which is what `arraySeparator` is for. */
2
3
  export declare const BoxType: DataType;
4
+ /** The `_box` array of {@link BoxType}. */
3
5
  export declare const ArrayBoxType: DataType;
@@ -3,6 +3,7 @@ import { Box, TwoPoints } from './classes/geometric.js';
3
3
  const BOX_PATTERN1 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
4
4
  const BOX_PATTERN2 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
5
5
  const BOX_PATTERN3 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
6
+ /** `box`, as a {@link Box}. Its array literal separates elements with a semicolon rather than a comma, which is what `arraySeparator` is for. */
6
7
  export const BoxType = {
7
8
  name: 'box',
8
9
  oid: DataTypeOIDs.box,
@@ -37,6 +38,7 @@ export const BoxType = {
37
38
  return v instanceof Box || TwoPoints.isTwoPointsLike(v);
38
39
  },
39
40
  };
41
+ /** The `_box` array of {@link BoxType}. */
40
42
  export const ArrayBoxType = {
41
43
  ...BoxType,
42
44
  name: '_box',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `bytea`, as a `Buffer`. The binary format is the bytes themselves; the text one is `\\x`-prefixed hex, at two characters a byte. */
2
3
  export declare const ByteaType: DataType;
4
+ /** The `_bytea` array of {@link ByteaType}. */
3
5
  export declare const ArrayByteaType: DataType;
@@ -1,5 +1,6 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
2
  import { parseBytea, parseByteaBuffer } from '../util/parse-bytea.js';
3
+ /** `bytea`, as a `Buffer`. The binary format is the bytes themselves; the text one is `\\x`-prefixed hex, at two characters a byte. */
3
4
  export const ByteaType = {
4
5
  name: 'bytea',
5
6
  oid: DataTypeOIDs.bytea,
@@ -22,6 +23,7 @@ export const ByteaType = {
22
23
  return v instanceof Buffer;
23
24
  },
24
25
  };
26
+ /** The `_bytea` array of {@link ByteaType}. */
25
27
  export const ArrayByteaType = {
26
28
  ...ByteaType,
27
29
  name: '_bytea',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `char` - the single-byte internal type, not `char(n)` - as a one-character string. */
2
3
  export declare const CharType: DataType;
4
+ /** The `_char` array of {@link CharType}. */
3
5
  export declare const ArrayCharType: DataType;
@@ -1,4 +1,5 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
+ /** `char` - the single-byte internal type, not `char(n)` - as a one-character string. */
2
3
  export const CharType = {
3
4
  name: 'char',
4
5
  oid: DataTypeOIDs.char,
@@ -37,6 +38,7 @@ export const CharType = {
37
38
  */
38
39
  inferrable: false,
39
40
  };
41
+ /** The `_char` array of {@link CharType}. */
40
42
  export const ArrayCharType = {
41
43
  ...CharType,
42
44
  name: '_char',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `circle`, as a {@link Circle} - a centre point and a radius, named as PostgreSQL names them. */
2
3
  export declare const CircleType: DataType;
4
+ /** The `_circle` array of {@link CircleType}. */
3
5
  export declare const ArrayCircleType: DataType;
@@ -4,6 +4,7 @@ const CIRCLE_PATTERN1 = /^< *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\
4
4
  const CIRCLE_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*) *\)$/;
5
5
  const CIRCLE_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *(-?\d+\.?\d*)$/;
6
6
  const CIRCLE_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
7
+ /** `circle`, as a {@link Circle} - a centre point and a radius, named as PostgreSQL names them. */
7
8
  export const CircleType = {
8
9
  name: 'circle',
9
10
  oid: DataTypeOIDs.circle,
@@ -40,6 +41,7 @@ export const CircleType = {
40
41
  return v instanceof Circle || Circle.isCircleLike(v);
41
42
  },
42
43
  };
44
+ /** The `_circle` array of {@link CircleType}. */
43
45
  export const ArrayCircleType = {
44
46
  ...CircleType,
45
47
  name: '_circle',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `date`, as a `Date` at local midnight - or at UTC midnight with `utcDates`. */
2
3
  export declare const DateType: DataType;
4
+ /** The `_date` array of {@link DateType}. */
3
5
  export declare const ArrayDateType: DataType;
@@ -3,6 +3,7 @@ import { formatDate } from '../util/format-datetime.js';
3
3
  import { utcPartsAsLocal } from '../util/local-date.js';
4
4
  import { parseDate } from '../util/parse-datetime.js';
5
5
  const timeShift = 946684800000;
6
+ /** `date`, as a `Date` at local midnight - or at UTC midnight with `utcDates`. */
6
7
  export const DateType = {
7
8
  name: 'date',
8
9
  oid: DataTypeOIDs.date,
@@ -56,6 +57,7 @@ export const DateType = {
56
57
  v.getMilliseconds() === 0);
57
58
  },
58
59
  };
60
+ /** The `_date` array of {@link DateType}. */
59
61
  export const ArrayDateType = {
60
62
  ...DateType,
61
63
  name: '_date',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `float4` (real), as a number - the shortest decimal that reads back as the same 32-bit float. */
2
3
  export declare const Float4Type: DataType;
4
+ /** The `_float4` array of {@link Float4Type}. */
3
5
  export declare const ArrayFloat4Type: DataType;
@@ -1,6 +1,7 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
2
  import { assertCoercedNumber } from '../util/assert-integer.js';
3
3
  import { fastParseFloatBuffer } from '../util/fast-parsefloat.js';
4
+ /** `float4` (real), as a number - the shortest decimal that reads back as the same 32-bit float. */
4
5
  export const Float4Type = {
5
6
  name: 'float4',
6
7
  oid: DataTypeOIDs.float4,
@@ -20,6 +21,7 @@ export const Float4Type = {
20
21
  return typeof v === 'number';
21
22
  },
22
23
  };
24
+ /** The `_float4` array of {@link Float4Type}. */
23
25
  export const ArrayFloat4Type = {
24
26
  ...Float4Type,
25
27
  name: '_float4',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `float8` (double precision), as a number. */
2
3
  export declare const Float8Type: DataType;
4
+ /** The `_float8` array of {@link Float8Type}. */
3
5
  export declare const ArrayFloat8Type: DataType;
@@ -1,6 +1,7 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
2
  import { assertCoercedNumber } from '../util/assert-integer.js';
3
3
  import { fastParseFloatBuffer } from '../util/fast-parsefloat.js';
4
+ /** `float8` (double precision), as a number. */
4
5
  export const Float8Type = {
5
6
  name: 'float8',
6
7
  oid: DataTypeOIDs.float8,
@@ -21,6 +22,7 @@ export const Float8Type = {
21
22
  return typeof v === 'number';
22
23
  },
23
24
  };
25
+ /** The `_float8` array of {@link Float8Type}. */
24
26
  export const ArrayFloat8Type = {
25
27
  ...Float8Type,
26
28
  name: '_float8',
@@ -1,5 +1,9 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `inet`, as a string - an address, with the netmask only when it is not the full width. */
2
3
  export declare const InetType: DataType;
4
+ /** The `_inet` array of {@link InetType}. */
3
5
  export declare const ArrayInetType: DataType;
6
+ /** `cidr`, as a string. The same wire format as {@link InetType}; a network always prints its netmask. */
4
7
  export declare const CidrType: DataType;
8
+ /** The `_cidr` array of {@link CidrType}. */
5
9
  export declare const ArrayCidrType: DataType;
@@ -230,6 +230,7 @@ function decode(v, offset) {
230
230
  v[offset + 7];
231
231
  return isCidr || bits !== size * 8 ? text + '/' + bits : text;
232
232
  }
233
+ /** `inet`, as a string - an address, with the netmask only when it is not the full width. */
233
234
  export const InetType = {
234
235
  name: 'inet',
235
236
  oid: DataTypeOIDs.inet,
@@ -264,12 +265,14 @@ export const InetType = {
264
265
  return !!parseAddress(v);
265
266
  },
266
267
  };
268
+ /** The `_inet` array of {@link InetType}. */
267
269
  export const ArrayInetType = {
268
270
  ...InetType,
269
271
  name: '_inet',
270
272
  oid: DataTypeOIDs._inet,
271
273
  elementsOID: DataTypeOIDs.inet,
272
274
  };
275
+ /** `cidr`, as a string. The same wire format as {@link InetType}; a network always prints its netmask. */
273
276
  export const CidrType = {
274
277
  ...InetType,
275
278
  name: 'cidr',
@@ -278,6 +281,7 @@ export const CidrType = {
278
281
  encode(buf, v, true);
279
282
  },
280
283
  };
284
+ /** The `_cidr` array of {@link CidrType}. */
281
285
  export const ArrayCidrType = {
282
286
  ...CidrType,
283
287
  name: '_cidr',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `int2` (smallint), as a number. */
2
3
  export declare const Int2Type: DataType;
4
+ /** The `_int2` array of {@link Int2Type}. */
3
5
  export declare const ArrayInt2Type: DataType;
@@ -1,6 +1,7 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
2
  import { assertInteger } from '../util/assert-integer.js';
3
3
  import { fastParseInt, fastParseIntBuffer } from '../util/fast-parseint.js';
4
+ /** `int2` (smallint), as a number. */
4
5
  export const Int2Type = {
5
6
  name: 'int2',
6
7
  oid: DataTypeOIDs.int2,
@@ -20,6 +21,7 @@ export const Int2Type = {
20
21
  return (typeof v === 'number' && Number.isInteger(v) && v >= -32768 && v <= 32767);
21
22
  },
22
23
  };
24
+ /** The `_int2` array of {@link Int2Type}. */
23
25
  export const ArrayInt2Type = {
24
26
  ...Int2Type,
25
27
  name: '_int2',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `int2vector`, the catalog's own list of column numbers, as an array of numbers. Subscripted from 0, unlike every ordinary array. */
2
3
  export declare const Int2VectorType: DataType;
4
+ /** The `_int2vector` array of {@link Int2VectorType}. */
3
5
  export declare const ArrayInt2VectorType: DataType;
@@ -3,6 +3,7 @@ import { SmartBuffer } from '../protocol/smart-buffer.js';
3
3
  import { decodeBinaryArray } from '../util/decode-binaryarray.js';
4
4
  import { encodeBinaryArray } from '../util/encode-binaryarray.js';
5
5
  import { fastParseInt } from '../util/fast-parseint.js';
6
+ /** `int2vector`, the catalog's own list of column numbers, as an array of numbers. Subscripted from 0, unlike every ordinary array. */
6
7
  export const Int2VectorType = {
7
8
  name: 'int2vector',
8
9
  oid: DataTypeOIDs.int2vector,
@@ -41,6 +42,7 @@ export const Int2VectorType = {
41
42
  x <= 32767)));
42
43
  },
43
44
  };
45
+ /** The `_int2vector` array of {@link Int2VectorType}. */
44
46
  export const ArrayInt2VectorType = {
45
47
  ...Int2VectorType,
46
48
  name: '_int2vector',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `int4` (integer), as a number. */
2
3
  export declare const Int4Type: DataType;
4
+ /** The `_int4` array of {@link Int4Type}. */
3
5
  export declare const ArrayInt4Type: DataType;
@@ -1,6 +1,7 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
2
  import { assertInteger } from '../util/assert-integer.js';
3
3
  import { fastParseInt, fastParseIntBuffer } from '../util/fast-parseint.js';
4
+ /** `int4` (integer), as a number. */
4
5
  export const Int4Type = {
5
6
  name: 'int4',
6
7
  oid: DataTypeOIDs.int4,
@@ -23,6 +24,7 @@ export const Int4Type = {
23
24
  v <= 2147483647);
24
25
  },
25
26
  };
27
+ /** The `_int4` array of {@link Int4Type}. */
26
28
  export const ArrayInt4Type = {
27
29
  ...Int4Type,
28
30
  name: '_int4',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `int8` (bigint), as a number while one is exact and a `BigInt` beyond that. */
2
3
  export declare const Int8Type: DataType;
4
+ /** The `_int8` array of {@link Int8Type}. */
3
5
  export declare const ArrayInt8Type: DataType;
@@ -3,6 +3,7 @@ import { assertBigInt } from '../util/assert-integer.js';
3
3
  import { readBigInt64BE } from '../util/bigint-methods.js';
4
4
  import { fastParseIntBuffer } from '../util/fast-parseint.js';
5
5
  const maxSafeInteger = BigInt(Number.MAX_SAFE_INTEGER);
6
+ /** `int8` (bigint), as a number while one is exact and a `BigInt` beyond that. */
6
7
  export const Int8Type = {
7
8
  name: 'int8',
8
9
  oid: DataTypeOIDs.int8,
@@ -40,6 +41,7 @@ export const Int8Type = {
40
41
  (v > 2147483647 || v < -2147483648)));
41
42
  },
42
43
  };
44
+ /** The `_int8` array of {@link Int8Type}. */
43
45
  export const ArrayInt8Type = {
44
46
  ...Int8Type,
45
47
  name: '_int8',
@@ -1,5 +1,14 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
2
  import { Interval } from './classes/interval.js';
3
+ /**
4
+ * Reads an interval as the server writes one, in any of the output
5
+ * styles `IntervalStyle` selects.
6
+ *
7
+ * @param v The value's text.
8
+ * @returns The interval, with months, days and microseconds kept apart.
9
+ */
3
10
  export declare function parseIntervalText(v: string): Interval;
11
+ /** `interval`, as an {@link Interval}: months, days and microseconds kept apart, because the server keeps them apart and a month is not a fixed number of days. */
4
12
  export declare const IntervalType: DataType;
13
+ /** The `_interval` array of {@link IntervalType}. */
5
14
  export declare const ArrayIntervalType: DataType;
@@ -18,6 +18,13 @@ function toInterval(v) {
18
18
  throw new TypeError(`"${typeof v}" cannot be encoded as an interval - pass an Interval, ` +
19
19
  'a plain object of its fields, or a string PostgreSQL would accept');
20
20
  }
21
+ /**
22
+ * Reads an interval as the server writes one, in any of the output
23
+ * styles `IntervalStyle` selects.
24
+ *
25
+ * @param v The value's text.
26
+ * @returns The interval, with months, days and microseconds kept apart.
27
+ */
21
28
  export function parseIntervalText(v) {
22
29
  const m = INTERVAL_PATTERN.exec(v);
23
30
  if (!m) {
@@ -41,6 +48,7 @@ export function parseIntervalText(v) {
41
48
  milliseconds: m[8] ? (sign * parseInt(m[8].padEnd(6, '0'), 10)) / 1000 : 0,
42
49
  });
43
50
  }
51
+ /** `interval`, as an {@link Interval}: months, days and microseconds kept apart, because the server keeps them apart and a month is not a fixed number of days. */
44
52
  export const IntervalType = {
45
53
  name: 'interval',
46
54
  oid: DataTypeOIDs.interval,
@@ -71,6 +79,7 @@ export const IntervalType = {
71
79
  return v instanceof Interval;
72
80
  },
73
81
  };
82
+ /** The `_interval` array of {@link IntervalType}. */
74
83
  export const ArrayIntervalType = {
75
84
  ...IntervalType,
76
85
  name: '_interval',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `json`, as the text the server stored - parsing it is the caller's to do, and their choice of parser. */
2
3
  export declare const JsonType: DataType;
4
+ /** The `_json` array of {@link JsonType}. */
3
5
  export declare const ArrayJsonType: DataType;
@@ -1,4 +1,5 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
+ /** `json`, as the text the server stored - parsing it is the caller's to do, and their choice of parser. */
2
3
  export const JsonType = {
3
4
  name: 'json',
4
5
  oid: DataTypeOIDs.json,
@@ -33,6 +34,7 @@ export const JsonType = {
33
34
  function decodeJsonText(v) {
34
35
  return v ? JSON.parse(v) : null;
35
36
  }
37
+ /** The `_json` array of {@link JsonType}. */
36
38
  export const ArrayJsonType = {
37
39
  ...JsonType,
38
40
  name: '_json',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `jsonb`, as text. The binary form carries a version byte the value itself does not. */
2
3
  export declare const JsonbType: DataType;
4
+ /** The `_jsonb` array of {@link JsonbType}. */
3
5
  export declare const ArrayJsonbType: DataType;
@@ -1,4 +1,5 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
+ /** `jsonb`, as text. The binary form carries a version byte the value itself does not. */
2
3
  export const JsonbType = {
3
4
  name: 'jsonb',
4
5
  oid: DataTypeOIDs.jsonb,
@@ -35,6 +36,7 @@ export const JsonbType = {
35
36
  function decodeJsonbText(v) {
36
37
  return v ? JSON.parse(v) : null;
37
38
  }
39
+ /** The `_jsonb` array of {@link JsonbType}. */
38
40
  export const ArrayJsonbType = {
39
41
  ...JsonbType,
40
42
  name: '_jsonb',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `jsonpath`, as text. */
2
3
  export declare const JsonPathType: DataType;
4
+ /** The `_jsonpath` array of {@link JsonPathType}. */
3
5
  export declare const ArrayJsonPathType: DataType;
@@ -11,6 +11,7 @@ import { DataTypeOIDs } from '../constants.js';
11
11
  */
12
12
  /** The only format the server has ever written, and the one it reads. */
13
13
  const JSONPATH_VERSION = 1;
14
+ /** `jsonpath`, as text. */
14
15
  export const JsonPathType = {
15
16
  name: 'jsonpath',
16
17
  oid: DataTypeOIDs.jsonpath,
@@ -45,6 +46,7 @@ export const JsonPathType = {
45
46
  return typeof v === 'string' && /^\s*(?:(?:strict|lax)\s+)?[$@]/.test(v);
46
47
  },
47
48
  };
49
+ /** The `_jsonpath` array of {@link JsonPathType}. */
48
50
  export const ArrayJsonPathType = {
49
51
  ...JsonPathType,
50
52
  name: '_jsonpath',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `line`, as a {@link Line} - the `A`, `B` and `C` of `Ax + By + C = 0`, which is how the server stores it. */
2
3
  export declare const LineType: DataType;
4
+ /** The `_line` array of {@link LineType}. */
3
5
  export declare const ArrayLineType: DataType;
@@ -1,6 +1,7 @@
1
1
  import { DataTypeOIDs } from '../constants.js';
2
2
  import { Line } from './classes/geometric.js';
3
3
  const LINE_PATTERN = /^\{ *(-?[\d.]+(?:e[-+]?\d+)?) *, *(-?[\d.]+(?:e[-+]?\d+)?) *, *(-?[\d.]+(?:e[-+]?\d+)?) *\}$/i;
4
+ /** `line`, as a {@link Line} - the `A`, `B` and `C` of `Ax + By + C = 0`, which is how the server stores it. */
4
5
  export const LineType = {
5
6
  name: 'line',
6
7
  oid: DataTypeOIDs.line,
@@ -33,6 +34,7 @@ export const LineType = {
33
34
  return v instanceof Line || Line.isLineLike(v);
34
35
  },
35
36
  };
37
+ /** The `_line` array of {@link LineType}. */
36
38
  export const ArrayLineType = {
37
39
  ...LineType,
38
40
  name: '_line',
@@ -1,3 +1,5 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `lseg`, as a {@link LineSegment}. */
2
3
  export declare const LsegType: DataType;
4
+ /** The `_lseg` array of {@link LsegType}. */
3
5
  export declare const ArrayLsegType: DataType;
@@ -4,6 +4,7 @@ const LSEG_PATTERN1 = /^\[ *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\
4
4
  const LSEG_PATTERN2 = /^\( *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *\)$/;
5
5
  const LSEG_PATTERN3 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\) *, *\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
6
6
  const LSEG_PATTERN4 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
7
+ /** `lseg`, as a {@link LineSegment}. */
7
8
  export const LsegType = {
8
9
  name: 'lseg',
9
10
  oid: DataTypeOIDs.lseg,
@@ -41,6 +42,7 @@ export const LsegType = {
41
42
  return v instanceof LineSegment || TwoPoints.isTwoPointsLike(v);
42
43
  },
43
44
  };
45
+ /** The `_lseg` array of {@link LsegType}. */
44
46
  export const ArrayLsegType = {
45
47
  ...LsegType,
46
48
  name: '_lseg',
@@ -1,5 +1,9 @@
1
1
  import type { DataType } from '../interfaces/data-type.js';
2
+ /** `macaddr`, as its six-group colon-separated text. */
2
3
  export declare const MacaddrType: DataType;
4
+ /** The `_macaddr` array of {@link MacaddrType}. */
3
5
  export declare const ArrayMacaddrType: DataType;
6
+ /** `macaddr8`, as its eight-group colon-separated text. */
4
7
  export declare const Macaddr8Type: DataType;
8
+ /** The `_macaddr8` array of {@link Macaddr8Type}. */
5
9
  export declare const ArrayMacaddr8Type: DataType;