postgrejs 3.11.1 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/connection/bind-param.d.ts +21 -0
- package/connection/bind-param.js +21 -0
- package/connection/connection.d.ts +136 -0
- package/connection/connection.js +132 -5
- package/connection/copy-stream.d.ts +2 -0
- package/connection/copy-stream.js +2 -0
- package/connection/cursor.d.ts +67 -5
- package/connection/cursor.js +88 -15
- package/connection/intl-connection.d.ts +22 -0
- package/connection/intl-connection.js +107 -17
- package/connection/large-object.d.ts +18 -0
- package/connection/large-object.js +17 -0
- package/connection/logical-replication.d.ts +15 -0
- package/connection/logical-replication.js +6 -0
- package/connection/pool.d.ts +80 -0
- package/connection/pool.js +82 -9
- package/connection/portal.d.ts +37 -0
- package/connection/portal.js +29 -0
- package/connection/prepared-statement.d.ts +109 -0
- package/connection/prepared-statement.js +150 -7
- package/constants.d.ts +18 -0
- package/constants.js +18 -0
- package/data-type-map.d.ts +38 -0
- package/data-type-map.js +38 -0
- package/data-types/bit-type.d.ts +4 -0
- package/data-types/bit-type.js +4 -0
- package/data-types/bool-type.d.ts +2 -0
- package/data-types/bool-type.js +2 -0
- package/data-types/box-type.d.ts +2 -0
- package/data-types/box-type.js +2 -0
- package/data-types/bytea-type.d.ts +2 -0
- package/data-types/bytea-type.js +2 -0
- package/data-types/char-type.d.ts +2 -0
- package/data-types/char-type.js +2 -0
- package/data-types/circle-type.d.ts +2 -0
- package/data-types/circle-type.js +2 -0
- package/data-types/date-type.d.ts +2 -0
- package/data-types/date-type.js +2 -0
- package/data-types/float4-type.d.ts +2 -0
- package/data-types/float4-type.js +2 -0
- package/data-types/float8-type.d.ts +2 -0
- package/data-types/float8-type.js +2 -0
- package/data-types/inet-type.d.ts +4 -0
- package/data-types/inet-type.js +4 -0
- package/data-types/int2-type.d.ts +2 -0
- package/data-types/int2-type.js +3 -1
- package/data-types/int2-vector-type.d.ts +2 -0
- package/data-types/int2-vector-type.js +2 -0
- package/data-types/int4-type.d.ts +2 -0
- package/data-types/int4-type.js +3 -1
- package/data-types/int8-type.d.ts +2 -0
- package/data-types/int8-type.js +4 -2
- package/data-types/interval-type.d.ts +9 -0
- package/data-types/interval-type.js +9 -0
- package/data-types/json-type.d.ts +2 -0
- package/data-types/json-type.js +2 -0
- package/data-types/jsonb-type.d.ts +2 -0
- package/data-types/jsonb-type.js +2 -0
- package/data-types/jsonpath-type.d.ts +2 -0
- package/data-types/jsonpath-type.js +2 -0
- package/data-types/line-type.d.ts +2 -0
- package/data-types/line-type.js +2 -0
- package/data-types/lseg-type.d.ts +2 -0
- package/data-types/lseg-type.js +2 -0
- package/data-types/macaddr-type.d.ts +4 -0
- package/data-types/macaddr-type.js +4 -0
- package/data-types/money-type.d.ts +1 -0
- package/data-types/money-type.js +17 -10
- package/data-types/numeric-type.d.ts +2 -0
- package/data-types/numeric-type.js +2 -0
- package/data-types/oid-type.d.ts +2 -0
- package/data-types/oid-type.js +3 -1
- package/data-types/oid-vector-type.d.ts +1 -0
- package/data-types/oid-vector-type.js +1 -0
- package/data-types/path-type.d.ts +4 -0
- package/data-types/path-type.js +4 -0
- package/data-types/pg-lsn-type.d.ts +2 -0
- package/data-types/pg-lsn-type.js +2 -0
- package/data-types/point-type.d.ts +2 -0
- package/data-types/point-type.js +2 -0
- package/data-types/range-type.d.ts +4 -0
- package/data-types/range-type.js +4 -0
- package/data-types/snapshot-type.d.ts +4 -0
- package/data-types/snapshot-type.js +4 -0
- package/data-types/tid-type.d.ts +2 -0
- package/data-types/tid-type.js +2 -0
- package/data-types/time-type.d.ts +2 -0
- package/data-types/time-type.js +2 -0
- package/data-types/timestamp-type.d.ts +2 -0
- package/data-types/timestamp-type.js +2 -0
- package/data-types/timestamptz-type.d.ts +2 -0
- package/data-types/timestamptz-type.js +2 -0
- package/data-types/timetz-type.d.ts +2 -0
- package/data-types/timetz-type.js +2 -0
- package/data-types/tsvector-type.d.ts +4 -0
- package/data-types/tsvector-type.js +4 -0
- package/data-types/uuid-type.d.ts +2 -0
- package/data-types/uuid-type.js +2 -0
- package/data-types/varchar-type.d.ts +2 -0
- package/data-types/varchar-type.js +2 -0
- package/data-types/xid-type.d.ts +6 -0
- package/data-types/xid-type.js +8 -1
- package/interfaces/command-result.d.ts +7 -0
- package/interfaces/copy-from-rows-options.d.ts +4 -0
- package/interfaces/data-mapping-options.d.ts +6 -0
- package/interfaces/data-type.d.ts +37 -0
- package/interfaces/database-connection-params.d.ts +31 -0
- package/interfaces/field-info.d.ts +8 -0
- package/interfaces/function-call-options.d.ts +1 -0
- package/interfaces/function-call-result.d.ts +6 -0
- package/interfaces/pipeline-request.d.ts +2 -0
- package/interfaces/query-options.d.ts +7 -0
- package/interfaces/query-result.d.ts +7 -0
- package/interfaces/script-execute-options.d.ts +4 -0
- package/interfaces/script-result.d.ts +1 -0
- package/interfaces/statement-prepare-options.d.ts +1 -0
- package/package.json +5 -5
- package/protocol/backend.d.ts +6 -0
- package/protocol/backend.js +35 -5
- package/protocol/cert-signature.d.ts +8 -0
- package/protocol/cert-signature.js +8 -0
- package/protocol/database-error.d.ts +8 -0
- package/protocol/database-error.js +8 -0
- package/protocol/frontend.d.ts +16 -0
- package/protocol/frontend.js +13 -6
- package/protocol/pg-socket.d.ts +10 -0
- package/protocol/pg-socket.js +14 -7
- package/protocol/pgoutput.d.ts +15 -0
- package/protocol/pgoutput.js +7 -0
- package/protocol/protocol.d.ts +50 -2
- package/protocol/protocol.js +17 -1
- package/protocol/sasl.d.ts +22 -0
- package/protocol/sasl.js +21 -0
- package/protocol/smart-buffer.d.ts +4 -0
- package/safe-event-emitter.d.ts +7 -0
- package/safe-event-emitter.js +7 -0
- package/types.d.ts +21 -0
- package/util/array-calculatedim.d.ts +10 -0
- package/util/array-calculatedim.js +10 -0
- package/util/assert-integer.d.ts +40 -25
- package/util/assert-integer.js +97 -32
- package/util/bigint-methods.d.ts +7 -0
- package/util/bigint-methods.js +9 -0
- package/util/config-from-env.d.ts +10 -0
- package/util/config-from-env.js +10 -0
- package/util/connection-config.d.ts +17 -0
- package/util/connection-config.js +17 -0
- package/util/copy-from-rows.d.ts +12 -0
- package/util/copy-from-rows.js +9 -0
- package/util/decimal-as-string.d.ts +6 -0
- package/util/decimal-as-string.js +6 -0
- package/util/decode-binaryarray.d.ts +9 -0
- package/util/decode-binaryarray.js +9 -0
- package/util/escape-literal.d.ts +11 -0
- package/util/escape-literal.js +13 -0
- package/util/fast-parseint.d.ts +14 -0
- package/util/fast-parseint.js +14 -0
- package/util/format-datetime.d.ts +26 -0
- package/util/format-datetime.js +26 -0
- package/util/get-parsers.d.ts +9 -0
- package/util/get-parsers.js +9 -0
- package/util/hex-text.d.ts +13 -21
- package/util/hex-text.js +24 -21
- package/util/local-date.d.ts +2 -41
- package/util/local-date.js +39 -41
- package/util/parse-array.d.ts +8 -0
- package/util/parse-array.js +8 -0
- package/util/parse-bytea.d.ts +15 -0
- package/util/parse-bytea.js +15 -0
- package/util/parse-datetime.d.ts +26 -0
- package/util/parse-datetime.js +26 -0
- package/util/parse-row.d.ts +23 -2
- package/util/parse-row.js +56 -36
- package/util/parse-time.d.ts +10 -0
- package/util/parse-time.js +10 -0
- package/util/resolve-column-formats.d.ts +1 -0
- package/util/row-decoder.d.ts +32 -0
- package/util/row-decoder.js +22 -0
- package/util/stringify-arrayliteral.d.ts +33 -0
- package/util/stringify-arrayliteral.js +242 -7
- package/util/stringify-for-sql.d.ts +17 -0
- package/util/stringify-for-sql.js +17 -0
- package/util/unspecified-param.d.ts +26 -2
- package/util/unspecified-param.js +26 -2
- package/util/wrap-row-description.d.ts +10 -0
- package/util/wrap-row-description.js +10 -0
- package/CHANGELOG.md +0 -1426
|
@@ -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;
|
package/data-types/inet-type.js
CHANGED
|
@@ -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',
|
package/data-types/int2-type.js
CHANGED
|
@@ -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,
|
|
@@ -9,7 +10,7 @@ export const Int2Type = {
|
|
|
9
10
|
return '' + v;
|
|
10
11
|
},
|
|
11
12
|
encodeBinary(buf, v) {
|
|
12
|
-
buf.writeInt16BE(assertInteger(
|
|
13
|
+
buf.writeInt16BE(assertInteger(v, 'int2', -32768, 32767));
|
|
13
14
|
},
|
|
14
15
|
decodeBinary(v, offset = 0) {
|
|
15
16
|
return v.readInt16BE(offset);
|
|
@@ -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',
|
package/data-types/int4-type.js
CHANGED
|
@@ -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,
|
|
@@ -9,7 +10,7 @@ export const Int4Type = {
|
|
|
9
10
|
return '' + v;
|
|
10
11
|
},
|
|
11
12
|
encodeBinary(buf, v) {
|
|
12
|
-
buf.writeInt32BE(assertInteger(
|
|
13
|
+
buf.writeInt32BE(assertInteger(v, 'int4', -2147483648, 2147483647));
|
|
13
14
|
},
|
|
14
15
|
decodeBinary(v, offset = 0) {
|
|
15
16
|
return v.readInt32BE(offset);
|
|
@@ -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;
|
package/data-types/int8-type.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
|
-
import {
|
|
2
|
+
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,
|
|
@@ -11,7 +12,7 @@ export const Int8Type = {
|
|
|
11
12
|
return '' + v;
|
|
12
13
|
},
|
|
13
14
|
encodeBinary(buf, v) {
|
|
14
|
-
buf.writeBigInt64BE(
|
|
15
|
+
buf.writeBigInt64BE(assertBigInt(v, 'int8'));
|
|
15
16
|
},
|
|
16
17
|
decodeBinary(buf, offset = 0) {
|
|
17
18
|
const v = typeof buf.readBigInt64BE === 'function'
|
|
@@ -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;
|
package/data-types/json-type.js
CHANGED
|
@@ -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;
|
package/data-types/jsonb-type.js
CHANGED
|
@@ -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',
|
|
@@ -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;
|
package/data-types/line-type.js
CHANGED
|
@@ -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',
|
package/data-types/lseg-type.js
CHANGED
|
@@ -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;
|
|
@@ -79,14 +79,18 @@ function createType(name, oid, size) {
|
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
/** `macaddr`, as its six-group colon-separated text. */
|
|
82
83
|
export const MacaddrType = createType('macaddr', DataTypeOIDs.macaddr, 6);
|
|
84
|
+
/** The `_macaddr` array of {@link MacaddrType}. */
|
|
83
85
|
export const ArrayMacaddrType = {
|
|
84
86
|
...MacaddrType,
|
|
85
87
|
name: '_macaddr',
|
|
86
88
|
oid: DataTypeOIDs._macaddr,
|
|
87
89
|
elementsOID: DataTypeOIDs.macaddr,
|
|
88
90
|
};
|
|
91
|
+
/** `macaddr8`, as its eight-group colon-separated text. */
|
|
89
92
|
export const Macaddr8Type = createType('macaddr8', DataTypeOIDs.macaddr8, 8);
|
|
93
|
+
/** The `_macaddr8` array of {@link Macaddr8Type}. */
|
|
90
94
|
export const ArrayMacaddr8Type = {
|
|
91
95
|
...Macaddr8Type,
|
|
92
96
|
name: '_macaddr8',
|
|
@@ -35,4 +35,5 @@ export declare function moneyToString(minorUnits: bigint, scale: number): string
|
|
|
35
35
|
* knows the server or is reading a value some other server rendered.
|
|
36
36
|
*/
|
|
37
37
|
export declare const MoneyType: DataType;
|
|
38
|
+
/** The `_money` array of {@link MoneyType}. */
|
|
38
39
|
export declare const ArrayMoneyType: DataType;
|
package/data-types/money-type.js
CHANGED
|
@@ -61,18 +61,24 @@ export function moneyToString(minorUnits, scale) {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Below this many minor units the decimal has at most fifteen
|
|
64
|
-
* significant digits, which a double both holds and prints back exactly
|
|
65
|
-
* - so the round trip below can only agree, and asking it is the most
|
|
66
|
-
* expensive thing in the decode: measured over values that vary,
|
|
67
|
-
* `parseFloat` plus the comparison is 241 ns against 113 ns without it,
|
|
68
|
-
* on a decode whose string-building is 109 ns of that.
|
|
69
|
-
*
|
|
70
|
-
* The scale bound is the other half: the test is about *printed* digits,
|
|
71
|
-
* and JavaScript switches to exponential notation below 1e-6, which
|
|
72
|
-
* PostgreSQL never writes. At scale 6 the smallest non-zero value is
|
|
73
|
-
* exactly 1e-6, and no currency has more.
|
|
64
|
+
* significant digits, which a double both holds and prints back exactly.
|
|
74
65
|
*/
|
|
66
|
+
/* So the round trip below can only agree, and asking it is the most
|
|
67
|
+
expensive thing in the decode: measured over values that vary,
|
|
68
|
+
parseFloat plus the comparison is 241 ns against 113 ns without it, on
|
|
69
|
+
a decode whose string-building is 109 ns of that.
|
|
70
|
+
|
|
71
|
+
The scale bound is the other half: the test is about *printed* digits,
|
|
72
|
+
and JavaScript switches to exponential notation below 1e-6, which
|
|
73
|
+
PostgreSQL never writes. At scale 6 the smallest non-zero value is
|
|
74
|
+
exactly 1e-6, and no currency has more. */
|
|
75
75
|
const FAITHFUL_LIMIT = 1000000000000000n; // 10^15
|
|
76
|
+
/**
|
|
77
|
+
* Whether this value is small enough that a double is exact for it.
|
|
78
|
+
*
|
|
79
|
+
* @param minorUnits The amount, in the currency's smallest unit.
|
|
80
|
+
* @param scale How many decimal places that currency has.
|
|
81
|
+
*/
|
|
76
82
|
function isFaithful(minorUnits, scale) {
|
|
77
83
|
return (scale <= 6 && minorUnits < FAITHFUL_LIMIT && minorUnits > -FAITHFUL_LIMIT);
|
|
78
84
|
}
|
|
@@ -225,6 +231,7 @@ function toExactMinor(v, scale) {
|
|
|
225
231
|
const out = BigInt(digits || '0');
|
|
226
232
|
return neg ? -out : out;
|
|
227
233
|
}
|
|
234
|
+
/** The `_money` array of {@link MoneyType}. */
|
|
228
235
|
export const ArrayMoneyType = {
|
|
229
236
|
...MoneyType,
|
|
230
237
|
name: '_money',
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
2
|
/** The decimal without the zeroes a declared scale pads it out to. */
|
|
3
3
|
export declare function trimTrailingZeros(s: string): string;
|
|
4
|
+
/** `numeric`, as a number while one is exact, a {@link Numeric} when it is not, and a string with `decimalAsString`. */
|
|
4
5
|
export declare const NumericType: DataType;
|
|
6
|
+
/** The `_numeric` array of {@link NumericType}. */
|
|
5
7
|
export declare const ArrayNumericType: DataType;
|
|
6
8
|
/**
|
|
7
9
|
* Turns a JS exponential-notation number string (e.g. "1e+21", "-1.5e-7")
|
|
@@ -45,6 +45,7 @@ function toNumberOrNumeric(s) {
|
|
|
45
45
|
const n = parseFloat(s);
|
|
46
46
|
return String(n) === trimTrailingZeros(s) ? n : new Numeric(s);
|
|
47
47
|
}
|
|
48
|
+
/** `numeric`, as a number while one is exact, a {@link Numeric} when it is not, and a string with `decimalAsString`. */
|
|
48
49
|
export const NumericType = {
|
|
49
50
|
name: 'numeric',
|
|
50
51
|
oid: DataTypeOIDs.numeric,
|
|
@@ -200,6 +201,7 @@ export const NumericType = {
|
|
|
200
201
|
return typeof v === 'number' || v instanceof Numeric;
|
|
201
202
|
},
|
|
202
203
|
};
|
|
204
|
+
/** The `_numeric` array of {@link NumericType}. */
|
|
203
205
|
export const ArrayNumericType = {
|
|
204
206
|
...NumericType,
|
|
205
207
|
name: '_numeric',
|
package/data-types/oid-type.d.ts
CHANGED
package/data-types/oid-type.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataTypeNames, DataTypeOIDs } from '../constants.js';
|
|
2
2
|
import { assertInteger } from '../util/assert-integer.js';
|
|
3
3
|
import { fastParseInt, fastParseIntBuffer } from '../util/fast-parseint.js';
|
|
4
|
+
/** `oid`, as a number. */
|
|
4
5
|
export const OidType = {
|
|
5
6
|
name: 'oid',
|
|
6
7
|
oid: DataTypeOIDs.oid,
|
|
@@ -9,7 +10,7 @@ export const OidType = {
|
|
|
9
10
|
return '' + v;
|
|
10
11
|
},
|
|
11
12
|
encodeBinary(buf, v) {
|
|
12
|
-
buf.writeUInt32BE(assertInteger(
|
|
13
|
+
buf.writeUInt32BE(assertInteger(v, 'oid', 0, 4294967295));
|
|
13
14
|
},
|
|
14
15
|
decodeBinary(v, offset = 0) {
|
|
15
16
|
return v.readUInt32BE(offset);
|
|
@@ -20,6 +21,7 @@ export const OidType = {
|
|
|
20
21
|
return typeof v === 'number' && Number.isInteger(v) && !!DataTypeNames[v];
|
|
21
22
|
},
|
|
22
23
|
};
|
|
24
|
+
/** The `_oid` array of {@link OidType}. */
|
|
23
25
|
export const ArrayOidType = {
|
|
24
26
|
...OidType,
|
|
25
27
|
name: '_oid',
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `path`, as a {@link Path}: the points, and whether the path is closed. */
|
|
2
3
|
export declare const PathType: DataType;
|
|
4
|
+
/** The `_path` array of {@link PathType}. */
|
|
3
5
|
export declare const ArrayPathType: DataType;
|
|
6
|
+
/** `polygon`, as a {@link Polygon}. */
|
|
4
7
|
export declare const PolygonType: DataType;
|
|
8
|
+
/** The `_polygon` array of {@link PolygonType}. */
|
|
5
9
|
export declare const ArrayPolygonType: DataType;
|
package/data-types/path-type.js
CHANGED
|
@@ -62,6 +62,7 @@ function toPoints(v, name) {
|
|
|
62
62
|
return v.points;
|
|
63
63
|
throw new TypeError(`"${typeof v}" cannot be encoded as a ${name} - pass a ${name === 'path' ? 'Path' : 'Polygon'} or an array of points`);
|
|
64
64
|
}
|
|
65
|
+
/** `path`, as a {@link Path}: the points, and whether the path is closed. */
|
|
65
66
|
export const PathType = {
|
|
66
67
|
name: 'path',
|
|
67
68
|
oid: DataTypeOIDs.path,
|
|
@@ -97,12 +98,14 @@ export const PathType = {
|
|
|
97
98
|
return v instanceof Path;
|
|
98
99
|
},
|
|
99
100
|
};
|
|
101
|
+
/** The `_path` array of {@link PathType}. */
|
|
100
102
|
export const ArrayPathType = {
|
|
101
103
|
...PathType,
|
|
102
104
|
name: '_path',
|
|
103
105
|
oid: DataTypeOIDs._path,
|
|
104
106
|
elementsOID: DataTypeOIDs.path,
|
|
105
107
|
};
|
|
108
|
+
/** `polygon`, as a {@link Polygon}. */
|
|
106
109
|
export const PolygonType = {
|
|
107
110
|
name: 'polygon',
|
|
108
111
|
oid: DataTypeOIDs.polygon,
|
|
@@ -131,6 +134,7 @@ export const PolygonType = {
|
|
|
131
134
|
return v instanceof Polygon;
|
|
132
135
|
},
|
|
133
136
|
};
|
|
137
|
+
/** The `_polygon` array of {@link PolygonType}. */
|
|
134
138
|
export const ArrayPolygonType = {
|
|
135
139
|
...PolygonType,
|
|
136
140
|
name: '_polygon',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `pg_lsn`, as the `16/B374D848` text the server prints - the spelling every tool and every catalog column uses. */
|
|
2
3
|
export declare const PgLsnType: DataType;
|
|
4
|
+
/** The `_pg_lsn` array of {@link PgLsnType}. */
|
|
3
5
|
export declare const ArrayPgLsnType: DataType;
|
|
@@ -37,6 +37,7 @@ function writeHalf(value, p) {
|
|
|
37
37
|
TEXT[p++] = HEX_UPPER[(value >>> shift) & 15];
|
|
38
38
|
return p;
|
|
39
39
|
}
|
|
40
|
+
/** `pg_lsn`, as the `16/B374D848` text the server prints - the spelling every tool and every catalog column uses. */
|
|
40
41
|
export const PgLsnType = {
|
|
41
42
|
name: 'pg_lsn',
|
|
42
43
|
oid: DataTypeOIDs.pg_lsn,
|
|
@@ -71,6 +72,7 @@ export const PgLsnType = {
|
|
|
71
72
|
return typeof v === 'string' && LSN_PATTERN.test(v);
|
|
72
73
|
},
|
|
73
74
|
};
|
|
75
|
+
/** The `_pg_lsn` array of {@link PgLsnType}. */
|
|
74
76
|
export const ArrayPgLsnType = {
|
|
75
77
|
...PgLsnType,
|
|
76
78
|
name: '_pg_lsn',
|
package/data-types/point-type.js
CHANGED
|
@@ -2,6 +2,7 @@ import { DataTypeOIDs } from '../constants.js';
|
|
|
2
2
|
import { Point } from './classes/geometric.js';
|
|
3
3
|
const POINT_PATTERN1 = /^\( *(-?\d+\.?\d*) *, *(-?\d+\.?\d*) *\)$/;
|
|
4
4
|
const POINT_PATTERN2 = /^(-?\d+\.?\d*) *, *(-?\d+\.?\d*)$/;
|
|
5
|
+
/** `point`, as a {@link Point}. */
|
|
5
6
|
export const PointType = {
|
|
6
7
|
name: 'point',
|
|
7
8
|
oid: DataTypeOIDs.point,
|
|
@@ -33,6 +34,7 @@ export const PointType = {
|
|
|
33
34
|
return v instanceof Point || Point.isPointLike(v);
|
|
34
35
|
},
|
|
35
36
|
};
|
|
37
|
+
/** The `_point` array of {@link PointType}. */
|
|
36
38
|
export const ArrayPointType = {
|
|
37
39
|
...PointType,
|
|
38
40
|
name: '_point',
|
|
@@ -20,4 +20,8 @@ export declare function createRangeType(name: string, oid: OID, element: DataTyp
|
|
|
20
20
|
* repeating it.
|
|
21
21
|
*/
|
|
22
22
|
export declare function createMultiRangeType(name: string, oid: OID, range: DataType): DataType;
|
|
23
|
+
/**
|
|
24
|
+
* Every range and multirange type, built from the types they are ranges
|
|
25
|
+
* of, and registered together.
|
|
26
|
+
*/
|
|
23
27
|
export declare const RangeTypes: DataType[];
|
package/data-types/range-type.js
CHANGED
|
@@ -328,6 +328,10 @@ const BUILT_IN = [
|
|
|
328
328
|
TimestamptzType,
|
|
329
329
|
],
|
|
330
330
|
];
|
|
331
|
+
/**
|
|
332
|
+
* Every range and multirange type, built from the types they are ranges
|
|
333
|
+
* of, and registered together.
|
|
334
|
+
*/
|
|
331
335
|
export const RangeTypes = [];
|
|
332
336
|
for (const [name, oid, arrayOid, multiOid, multiArrayOid, , element,] of BUILT_IN) {
|
|
333
337
|
const rangeType = createRangeType(name, oid, element);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `pg_snapshot`, as the `xmin:xmax:xip_list` text it is written as. */
|
|
2
3
|
export declare const PgSnapshotType: DataType;
|
|
4
|
+
/** The `_pg_snapshot` array of {@link PgSnapshotType}. */
|
|
3
5
|
export declare const ArrayPgSnapshotType: DataType;
|
|
6
|
+
/** `txid_snapshot`, the older spelling of {@link PgSnapshotType}, as the same text. */
|
|
4
7
|
export declare const TxidSnapshotType: DataType;
|
|
8
|
+
/** The `_txid_snapshot` array of {@link TxidSnapshotType}. */
|
|
5
9
|
export declare const ArrayTxidSnapshotType: DataType;
|
|
@@ -80,14 +80,18 @@ function createType(name, oid) {
|
|
|
80
80
|
},
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
/** `pg_snapshot`, as the `xmin:xmax:xip_list` text it is written as. */
|
|
83
84
|
export const PgSnapshotType = createType('pg_snapshot', DataTypeOIDs.pg_snapshot);
|
|
85
|
+
/** The `_pg_snapshot` array of {@link PgSnapshotType}. */
|
|
84
86
|
export const ArrayPgSnapshotType = {
|
|
85
87
|
...PgSnapshotType,
|
|
86
88
|
name: '_pg_snapshot',
|
|
87
89
|
oid: DataTypeOIDs._pg_snapshot,
|
|
88
90
|
elementsOID: DataTypeOIDs.pg_snapshot,
|
|
89
91
|
};
|
|
92
|
+
/** `txid_snapshot`, the older spelling of {@link PgSnapshotType}, as the same text. */
|
|
90
93
|
export const TxidSnapshotType = createType('txid_snapshot', DataTypeOIDs.txid_snapshot);
|
|
94
|
+
/** The `_txid_snapshot` array of {@link TxidSnapshotType}. */
|
|
91
95
|
export const ArrayTxidSnapshotType = {
|
|
92
96
|
...TxidSnapshotType,
|
|
93
97
|
name: '_txid_snapshot',
|
package/data-types/tid-type.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `tid`, a physical row address, as the `(block,offset)` text the server prints. */
|
|
2
3
|
export declare const TidType: DataType;
|
|
4
|
+
/** The `_tid` array of {@link TidType}. */
|
|
3
5
|
export declare const ArrayTidType: DataType;
|