postgrejs 3.12.0 → 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 +14 -0
- package/connection/intl-connection.js +95 -15
- 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 +68 -0
- package/connection/prepared-statement.js +71 -2
- 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 +2 -0
- 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 +2 -0
- package/data-types/int8-type.d.ts +2 -0
- package/data-types/int8-type.js +2 -0
- 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 +2 -0
- 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 +6 -0
- 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/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 +220 -20
- package/util/stringify-for-sql.d.ts +17 -0
- package/util/stringify-for-sql.js +17 -0
- package/util/wrap-row-description.d.ts +10 -0
- package/util/wrap-row-description.js +10 -0
- package/CHANGELOG.md +0 -1453
|
@@ -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,
|
|
@@ -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;
|
package/data-types/tid-type.js
CHANGED
|
@@ -11,6 +11,7 @@ import { DataTypeOIDs } from '../constants.js';
|
|
|
11
11
|
* leaves it a string too.
|
|
12
12
|
*/
|
|
13
13
|
const TID_PATTERN = /^\(\s*(\d+)\s*,\s*(\d+)\s*\)$/;
|
|
14
|
+
/** `tid`, a physical row address, as the `(block,offset)` text the server prints. */
|
|
14
15
|
export const TidType = {
|
|
15
16
|
name: 'tid',
|
|
16
17
|
oid: DataTypeOIDs.tid,
|
|
@@ -42,6 +43,7 @@ export const TidType = {
|
|
|
42
43
|
return typeof v === 'string' && TID_PATTERN.test(v);
|
|
43
44
|
},
|
|
44
45
|
};
|
|
46
|
+
/** The `_tid` array of {@link TidType}. */
|
|
45
47
|
export const ArrayTidType = {
|
|
46
48
|
...TidType,
|
|
47
49
|
name: '_tid',
|
package/data-types/time-type.js
CHANGED
|
@@ -3,6 +3,7 @@ import { formatTime } from '../util/format-datetime.js';
|
|
|
3
3
|
import { utcPartsAsLocal } from '../util/local-date.js';
|
|
4
4
|
import { parseTime, STRICT_TIME_PATTERN } from '../util/parse-time.js';
|
|
5
5
|
const timeMul = 4294967296;
|
|
6
|
+
/** `time`, as a `Date` on the epoch day carrying that clock time. */
|
|
6
7
|
export const TimeType = {
|
|
7
8
|
name: 'time',
|
|
8
9
|
oid: DataTypeOIDs.time,
|
|
@@ -46,6 +47,7 @@ export const TimeType = {
|
|
|
46
47
|
(typeof v === 'string' && STRICT_TIME_PATTERN.test(v)));
|
|
47
48
|
},
|
|
48
49
|
};
|
|
50
|
+
/** The `_time` array of {@link TimeType}. */
|
|
49
51
|
export const ArrayTimeType = {
|
|
50
52
|
...TimeType,
|
|
51
53
|
name: '_time',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `timestamp` (without time zone), as a `Date` reading that wall clock locally - or in UTC with `utcDates`. */
|
|
2
3
|
export declare const TimestampType: DataType;
|
|
4
|
+
/** The `_timestamp` array of {@link TimestampType}. */
|
|
3
5
|
export declare const ArrayTimestampType: DataType;
|
|
@@ -5,6 +5,7 @@ import { parseDateTime } from '../util/parse-datetime.js';
|
|
|
5
5
|
import { parsePgTimestampBuffer } from '../util/parse-pg-timestamp.js';
|
|
6
6
|
const timeShift = 946684800000;
|
|
7
7
|
const timeMul = 4294967296;
|
|
8
|
+
/** `timestamp` (without time zone), as a `Date` reading that wall clock locally - or in UTC with `utcDates`. */
|
|
8
9
|
export const TimestampType = {
|
|
9
10
|
name: 'timestamp',
|
|
10
11
|
oid: DataTypeOIDs.timestamp,
|
|
@@ -72,6 +73,7 @@ export const TimestampType = {
|
|
|
72
73
|
!(v.getFullYear() === 1970 && v.getMonth() === 0 && v.getDate() === 1));
|
|
73
74
|
},
|
|
74
75
|
};
|
|
76
|
+
/** The `_timestamp` array of {@link TimestampType}. */
|
|
75
77
|
export const ArrayTimestampType = {
|
|
76
78
|
...TimestampType,
|
|
77
79
|
name: '_timestamp',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `timestamptz`, as a `Date` at the instant it names, which is what the type stores. */
|
|
2
3
|
export declare const TimestamptzType: DataType;
|
|
4
|
+
/** The `_timestamptz` array of {@link TimestamptzType}. */
|
|
3
5
|
export declare const ArrayTimestamptzType: DataType;
|
|
@@ -5,6 +5,7 @@ import { parseDateTimeTz } from '../util/parse-datetime.js';
|
|
|
5
5
|
import { parsePgTimestampBuffer } from '../util/parse-pg-timestamp.js';
|
|
6
6
|
const timeShift = 946684800000;
|
|
7
7
|
const timeMul = 4294967296;
|
|
8
|
+
/** `timestamptz`, as a `Date` at the instant it names, which is what the type stores. */
|
|
8
9
|
export const TimestamptzType = {
|
|
9
10
|
name: 'timestamptz',
|
|
10
11
|
oid: DataTypeOIDs.timestamptz,
|
|
@@ -80,6 +81,7 @@ export const TimestamptzType = {
|
|
|
80
81
|
return v instanceof Date;
|
|
81
82
|
},
|
|
82
83
|
};
|
|
84
|
+
/** The `_timestamptz` array of {@link TimestamptzType}. */
|
|
83
85
|
export const ArrayTimestamptzType = {
|
|
84
86
|
...TimestamptzType,
|
|
85
87
|
name: '_timestamptz',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `timetz`, as a string: the clock time and its offset, which a `Date` has nowhere to keep. */
|
|
2
3
|
export declare const TimeTzType: DataType;
|
|
4
|
+
/** The `_timetz` array of {@link TimeTzType}. */
|
|
3
5
|
export declare const ArrayTimeTzType: DataType;
|
|
@@ -117,6 +117,7 @@ function formatTimeTz(micros, zone) {
|
|
|
117
117
|
out += ':' + pad(zs);
|
|
118
118
|
return out;
|
|
119
119
|
}
|
|
120
|
+
/** `timetz`, as a string: the clock time and its offset, which a `Date` has nowhere to keep. */
|
|
120
121
|
export const TimeTzType = {
|
|
121
122
|
name: 'timetz',
|
|
122
123
|
oid: DataTypeOIDs.timetz,
|
|
@@ -176,6 +177,7 @@ export const TimeTzType = {
|
|
|
176
177
|
}
|
|
177
178
|
},
|
|
178
179
|
};
|
|
180
|
+
/** The `_timetz` array of {@link TimeTzType}. */
|
|
179
181
|
export const ArrayTimeTzType = {
|
|
180
182
|
...TimeTzType,
|
|
181
183
|
name: '_timetz',
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `tsvector`, as its own text - the lexemes with their positions and weights. */
|
|
2
3
|
export declare const TsVectorType: DataType;
|
|
4
|
+
/** The `_tsvector` array of {@link TsVectorType}. */
|
|
3
5
|
export declare const ArrayTsVectorType: DataType;
|
|
6
|
+
/** `tsquery`, as its own text. */
|
|
4
7
|
export declare const TsQueryType: DataType;
|
|
8
|
+
/** The `_tsquery` array of {@link TsQueryType}. */
|
|
5
9
|
export declare const ArrayTsQueryType: DataType;
|
|
@@ -170,6 +170,7 @@ function printQuery(node, parentPriority, rightPhraseOp) {
|
|
|
170
170
|
? '( ' + out + ' )'
|
|
171
171
|
: out;
|
|
172
172
|
}
|
|
173
|
+
/** `tsvector`, as its own text - the lexemes with their positions and weights. */
|
|
173
174
|
export const TsVectorType = {
|
|
174
175
|
name: 'tsvector',
|
|
175
176
|
oid: DataTypeOIDs.tsvector,
|
|
@@ -190,12 +191,14 @@ export const TsVectorType = {
|
|
|
190
191
|
return typeof v === 'string';
|
|
191
192
|
},
|
|
192
193
|
};
|
|
194
|
+
/** The `_tsvector` array of {@link TsVectorType}. */
|
|
193
195
|
export const ArrayTsVectorType = {
|
|
194
196
|
...TsVectorType,
|
|
195
197
|
name: '_tsvector',
|
|
196
198
|
oid: DataTypeOIDs._tsvector,
|
|
197
199
|
elementsOID: DataTypeOIDs.tsvector,
|
|
198
200
|
};
|
|
201
|
+
/** `tsquery`, as its own text. */
|
|
199
202
|
export const TsQueryType = {
|
|
200
203
|
...TsVectorType,
|
|
201
204
|
name: 'tsquery',
|
|
@@ -208,6 +211,7 @@ export const TsQueryType = {
|
|
|
208
211
|
return printQuery(readQueryNode(v, { p: offset + 4 }), 0, false);
|
|
209
212
|
},
|
|
210
213
|
};
|
|
214
|
+
/** The `_tsquery` array of {@link TsQueryType}. */
|
|
211
215
|
export const ArrayTsQueryType = {
|
|
212
216
|
...TsQueryType,
|
|
213
217
|
name: '_tsquery',
|
package/data-types/uuid-type.js
CHANGED
|
@@ -11,6 +11,7 @@ TEXT[8] = TEXT[13] = TEXT[18] = TEXT[23] = 45; /* - */
|
|
|
11
11
|
/** Where each of the sixteen bytes writes its two characters. */
|
|
12
12
|
const POSITIONS = [0, 2, 4, 6, 9, 11, 14, 16, 19, 21, 24, 26, 28, 30, 32, 34];
|
|
13
13
|
const GUID_PATTERN = /^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}$/;
|
|
14
|
+
/** `uuid`, as its canonical 36-character text. */
|
|
14
15
|
export const UuidType = {
|
|
15
16
|
name: 'uuid',
|
|
16
17
|
oid: DataTypeOIDs.uuid,
|
|
@@ -41,6 +42,7 @@ export const UuidType = {
|
|
|
41
42
|
return typeof v === 'string' && GUID_PATTERN.test(v);
|
|
42
43
|
},
|
|
43
44
|
};
|
|
45
|
+
/** The `_uuid` array of {@link UuidType}. */
|
|
44
46
|
export const ArrayUuidType = {
|
|
45
47
|
...UuidType,
|
|
46
48
|
name: '_uuid',
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `varchar`, `text`, `name` and the other string types, as strings. */
|
|
2
3
|
export declare const VarcharType: DataType;
|
|
4
|
+
/** The `_varchar` array of {@link VarcharType}. */
|
|
3
5
|
export declare const ArrayVarcharType: DataType;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypeOIDs } from '../constants.js';
|
|
2
|
+
/** `varchar`, `text`, `name` and the other string types, as strings. */
|
|
2
3
|
export const VarcharType = {
|
|
3
4
|
name: 'varchar',
|
|
4
5
|
oid: DataTypeOIDs.varchar,
|
|
@@ -28,6 +29,7 @@ export const VarcharType = {
|
|
|
28
29
|
return typeof v === 'string';
|
|
29
30
|
},
|
|
30
31
|
};
|
|
32
|
+
/** The `_varchar` array of {@link VarcharType}. */
|
|
31
33
|
export const ArrayVarcharType = {
|
|
32
34
|
...VarcharType,
|
|
33
35
|
name: '_varchar',
|
package/data-types/xid-type.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { DataType } from '../interfaces/data-type.js';
|
|
2
|
+
/** `xid`, a 32-bit transaction id, as a number. */
|
|
2
3
|
export declare const XidType: DataType;
|
|
4
|
+
/** The `_xid` array of {@link XidType}. */
|
|
3
5
|
export declare const ArrayXidType: DataType;
|
|
6
|
+
/** `cid`, a command id within a transaction, as a number. */
|
|
4
7
|
export declare const CidType: DataType;
|
|
8
|
+
/** The `_cid` array of {@link CidType}. */
|
|
5
9
|
export declare const ArrayCidType: DataType;
|
|
10
|
+
/** `xid8`, the 64-bit transaction id, as a number while one is exact and a `BigInt` beyond. */
|
|
6
11
|
export declare const Xid8Type: DataType;
|
|
12
|
+
/** The `_xid8` array of {@link Xid8Type}. */
|
|
7
13
|
export declare const ArrayXid8Type: DataType;
|
package/data-types/xid-type.js
CHANGED
|
@@ -57,20 +57,25 @@ function createUInt32Type(name, oid) {
|
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
+
/** `xid`, a 32-bit transaction id, as a number. */
|
|
60
61
|
export const XidType = createUInt32Type('xid', DataTypeOIDs.xid);
|
|
62
|
+
/** The `_xid` array of {@link XidType}. */
|
|
61
63
|
export const ArrayXidType = {
|
|
62
64
|
...XidType,
|
|
63
65
|
name: '_xid',
|
|
64
66
|
oid: DataTypeOIDs._xid,
|
|
65
67
|
elementsOID: DataTypeOIDs.xid,
|
|
66
68
|
};
|
|
69
|
+
/** `cid`, a command id within a transaction, as a number. */
|
|
67
70
|
export const CidType = createUInt32Type('cid', DataTypeOIDs.cid);
|
|
71
|
+
/** The `_cid` array of {@link CidType}. */
|
|
68
72
|
export const ArrayCidType = {
|
|
69
73
|
...CidType,
|
|
70
74
|
name: '_cid',
|
|
71
75
|
oid: DataTypeOIDs._cid,
|
|
72
76
|
elementsOID: DataTypeOIDs.cid,
|
|
73
77
|
};
|
|
78
|
+
/** `xid8`, the 64-bit transaction id, as a number while one is exact and a `BigInt` beyond. */
|
|
74
79
|
export const Xid8Type = {
|
|
75
80
|
name: 'xid8',
|
|
76
81
|
oid: DataTypeOIDs.xid8,
|
|
@@ -103,6 +108,7 @@ export const Xid8Type = {
|
|
|
103
108
|
(typeof v === 'number' && Number.isInteger(v) && v >= 0));
|
|
104
109
|
},
|
|
105
110
|
};
|
|
111
|
+
/** The `_xid8` array of {@link Xid8Type}. */
|
|
106
112
|
export const ArrayXid8Type = {
|
|
107
113
|
...Xid8Type,
|
|
108
114
|
name: '_xid8',
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { Row } from '../types.js';
|
|
2
2
|
import type { FieldInfo } from './field-info.js';
|
|
3
|
+
/**
|
|
4
|
+
* What one statement answered with: its rows, what its columns were, and
|
|
5
|
+
* what the server said it did.
|
|
6
|
+
*
|
|
7
|
+
* `QueryResult` is this plus a cursor; a script's results are a list of
|
|
8
|
+
* these, one per statement in it.
|
|
9
|
+
*/
|
|
3
10
|
export interface CommandResult {
|
|
4
11
|
/**
|
|
5
12
|
* Name of the command (INSERT, SELECT, UPDATE, etc.)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { DataTypeMap } from '../data-type-map.js';
|
|
2
2
|
import type { OID } from '../types.js';
|
|
3
3
|
import type { DataMappingOptions } from './data-mapping-options.js';
|
|
4
|
+
/**
|
|
5
|
+
* What `copyFromRows()` takes: which columns the rows line up with, how
|
|
6
|
+
* to encode their values, and how to stop.
|
|
7
|
+
*/
|
|
4
8
|
export interface CopyFromRowsOptions extends DataMappingOptions {
|
|
5
9
|
/** Type registry used to encode values; defaults to GlobalTypeMap. */
|
|
6
10
|
typeMap?: DataTypeMap;
|
|
@@ -34,6 +34,12 @@ export interface FetchAsStringSelector {
|
|
|
34
34
|
*/
|
|
35
35
|
ranges?: boolean;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* How values are turned into JavaScript and back.
|
|
39
|
+
*
|
|
40
|
+
* Set on the connection to apply to everything it runs, or per call to
|
|
41
|
+
* apply to one - a call that says nothing takes the connection's.
|
|
42
|
+
*/
|
|
37
43
|
export interface DataMappingOptions {
|
|
38
44
|
/**
|
|
39
45
|
* Decode `numeric` and `money` into the exact decimal string they
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
import type { DecodeBinaryFunction, DecodeTextBufferFunction, DecodeTextFunction, EncodeAsNullFunction, EncodeBinaryFunction, EncodeCalculateDimFunction, EncodeTextFunction, OID } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* How one PostgreSQL type is read and written.
|
|
4
|
+
*
|
|
5
|
+
* One of these per type in a `DataTypeMap`, and the extension point for
|
|
6
|
+
* a type this client does not know: register it on the global map or on
|
|
7
|
+
* one of a connection's own, and every column and parameter of that OID
|
|
8
|
+
* goes through it.
|
|
9
|
+
*
|
|
10
|
+
* A type needs to decode - both formats, since which one arrives depends
|
|
11
|
+
* on what the column asked for - and needs to encode only what callers
|
|
12
|
+
* will send. Registering the array counterpart is a separate entry, with
|
|
13
|
+
* `elementsOID` pointing back at this one.
|
|
14
|
+
*/
|
|
2
15
|
export interface DataType {
|
|
16
|
+
/** The type's own OID, as `pg_type` gives it. */
|
|
3
17
|
oid: OID;
|
|
18
|
+
/** The type's name, for `FieldInfo.dataTypeName` and for errors. */
|
|
4
19
|
name: string;
|
|
20
|
+
/** For an array type, the OID of what it is an array of. */
|
|
5
21
|
elementsOID?: OID;
|
|
22
|
+
/** Whether this entry is the array counterpart. */
|
|
6
23
|
isArray?: boolean;
|
|
24
|
+
/** What a decoded value is, named for `FieldInfo.jsType`. */
|
|
7
25
|
jsType: string;
|
|
26
|
+
/** What separates elements in this type's array literal - a comma for all but `box`. */
|
|
8
27
|
arraySeparator?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a JavaScript value could be of this type, asked when nothing
|
|
30
|
+
* declared one - see `inferrable` for when it is asked at all.
|
|
31
|
+
*/
|
|
9
32
|
isType: (v: any) => boolean;
|
|
10
33
|
/**
|
|
11
34
|
* Whether DataTypeMap.determine() may pick this type for a value, which
|
|
@@ -18,12 +41,22 @@ export interface DataType {
|
|
|
18
41
|
* `new BindParam(oid, value)`.
|
|
19
42
|
*/
|
|
20
43
|
inferrable?: boolean;
|
|
44
|
+
/** Reads a value out of the binary wire format. */
|
|
21
45
|
decodeBinary: DecodeBinaryFunction;
|
|
46
|
+
/** Reads a value out of the text the server rendered. */
|
|
22
47
|
decodeText: DecodeTextFunction;
|
|
48
|
+
/**
|
|
49
|
+
* Reads a text value straight from the wire buffer, when the type can
|
|
50
|
+
* do better than being handed a string.
|
|
51
|
+
*/
|
|
23
52
|
decodeTextBuffer?: DecodeTextBufferFunction;
|
|
53
|
+
/** Whether a value should go out as SQL NULL rather than be encoded. */
|
|
24
54
|
encodeAsNull?: EncodeAsNullFunction;
|
|
55
|
+
/** Writes a value in the binary wire format. */
|
|
25
56
|
encodeBinary?: EncodeBinaryFunction;
|
|
57
|
+
/** Renders a value as the text the server parses. */
|
|
26
58
|
encodeText?: EncodeTextFunction;
|
|
59
|
+
/** Measures an array's dimensions, for a type whose values are arrays themselves. */
|
|
27
60
|
encodeCalculateDim?: EncodeCalculateDimFunction;
|
|
28
61
|
}
|
|
29
62
|
/**
|
|
@@ -35,8 +68,12 @@ export interface DataType {
|
|
|
35
68
|
* object of these four numbers is still accepted as a parameter.
|
|
36
69
|
*/
|
|
37
70
|
export interface Rectangle {
|
|
71
|
+
/** First corner's x. */
|
|
38
72
|
x1: number;
|
|
73
|
+
/** First corner's y. */
|
|
39
74
|
y1: number;
|
|
75
|
+
/** Second corner's x. */
|
|
40
76
|
x2: number;
|
|
77
|
+
/** Second corner's y. */
|
|
41
78
|
y2: number;
|
|
42
79
|
}
|