@m2k-5f/pgtx 2.8.0 → 2.8.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.
- package/README.md +107 -47
- package/dist/clauses/array.clause.d.ts.map +1 -1
- package/dist/clauses/array.clause.js +0 -5
- package/dist/clauses/iden.caluse.d.ts.map +1 -1
- package/dist/clauses/iden.caluse.js +0 -2
- package/dist/clauses/insert.clause.d.ts.map +1 -1
- package/dist/clauses/insert.clause.js +5 -6
- package/dist/clauses/literal.clause.d.ts.map +1 -1
- package/dist/clauses/literal.clause.js +0 -3
- package/dist/clauses/update.clause.d.ts.map +1 -1
- package/dist/clauses/update.clause.js +0 -2
- package/dist/clauses/where.clause.d.ts.map +1 -1
- package/dist/clauses/where.clause.js +0 -2
- package/dist/connection.d.ts +7 -3
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +147 -116
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +40 -9
- package/dist/index.d.ts +30 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/pool.d.ts +2 -0
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +6 -0
- package/dist/protocol/connection-request-writer.d.ts +1 -1
- package/dist/protocol/connection-request-writer.d.ts.map +1 -1
- package/dist/protocol/connection-request-writer.js +1 -3
- package/dist/protocol/connection-response-reader.d.ts +1 -1
- package/dist/protocol/connection-response-reader.js +1 -1
- package/dist/protocol/constants.js +8 -8
- package/dist/protocol/types.d.ts +3 -1
- package/dist/protocol/types.d.ts.map +1 -1
- package/dist/protocol/types.js +91 -1
- package/dist/query.d.ts +9 -11
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +8 -10
- package/dist/transaction.d.ts +10 -2
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +78 -23
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -46
- package/package.json +1 -1
package/dist/pool.js
CHANGED
|
@@ -192,6 +192,12 @@ export class Pool {
|
|
|
192
192
|
get total() {
|
|
193
193
|
return this._total;
|
|
194
194
|
}
|
|
195
|
+
get isOpened() {
|
|
196
|
+
return this._isOpened;
|
|
197
|
+
}
|
|
198
|
+
get isClosed() {
|
|
199
|
+
return !this._isOpened;
|
|
200
|
+
}
|
|
195
201
|
/**
|
|
196
202
|
* Closes idle connections and rejects pending `acquire()` calls. Not usable afterward.
|
|
197
203
|
*/
|
|
@@ -63,7 +63,7 @@ export declare class ConnectionRequestBuffer {
|
|
|
63
63
|
writeBinaryInterval(value: {
|
|
64
64
|
months: number;
|
|
65
65
|
days: number;
|
|
66
|
-
microseconds: number
|
|
66
|
+
microseconds: number;
|
|
67
67
|
}): this;
|
|
68
68
|
writeBinaryJson(value: unknown): this;
|
|
69
69
|
writeBinaryJsonb(value: unknown): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-request-writer.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-request-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,WAAW,EAAgB,YAAY,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AAOhG,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,wBAAwB;IAChC,OAAO,CAAC,YAAY;IAJxB,OAAO;IAQP,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM;IAK3B,IAAI,OAAO,YAEV;IAED,IAAI,OAAO,YAEV;IAGD,IAAI;IAMJ,QAAQ;IAMR,OAAO,CAAC,cAAc;IAoBtB,YAAY,CAAC,MAAM,EAAE,MAAM;IAY3B,WAAW,CAAC,MAAM,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,SAAS,CAAC,EAAE;IAKzD,uBAAuB,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE;IAK5D,oBAAoB,CAAC,KAAK,EAAE,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE;IAK1D,qBAAqB,CAAC,KAAK,EAAE,CAAC,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE;IAK3D,oBAAoB,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE;IAKzD,uBAAuB,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE;IAKrE,SAAS;IAMT,SAAS,CACL,QAAQ,EAAE,MAAM,GAAG,EAAE,EACrB,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,OAAO,EAAE,GAClB,aAAa,GAAG,IAAI;CAwC1B"}
|
|
@@ -350,9 +350,7 @@ export class ConnectionRequestBuffer {
|
|
|
350
350
|
}
|
|
351
351
|
writeBinaryInterval(value) {
|
|
352
352
|
this.writeInt32(16);
|
|
353
|
-
this.
|
|
354
|
-
? value.microseconds
|
|
355
|
-
: BigInt(value.microseconds));
|
|
353
|
+
this.writeInt64(value.microseconds);
|
|
356
354
|
this.writeInt32(value.days);
|
|
357
355
|
this.writeInt32(value.months);
|
|
358
356
|
return this;
|
|
@@ -57,7 +57,7 @@ export declare class ConnectionResponseBuffer {
|
|
|
57
57
|
readBinaryInterval(): {
|
|
58
58
|
months: number;
|
|
59
59
|
days: number;
|
|
60
|
-
microseconds:
|
|
60
|
+
microseconds: number;
|
|
61
61
|
};
|
|
62
62
|
readBinaryJson(fieldLength: number): unknown;
|
|
63
63
|
readBinaryJsonb(fieldLength: number): unknown;
|
|
@@ -286,7 +286,7 @@ export class ConnectionResponseBuffer {
|
|
|
286
286
|
return negative ? `-${result}` : result;
|
|
287
287
|
}
|
|
288
288
|
readBinaryInterval() {
|
|
289
|
-
const microseconds = this.
|
|
289
|
+
const microseconds = this.readInt64();
|
|
290
290
|
const days = this.readInt32();
|
|
291
291
|
const months = this.readInt32();
|
|
292
292
|
return { months, days, microseconds };
|
|
@@ -29,16 +29,16 @@ export const ResponseTypes = {
|
|
|
29
29
|
SSLDenied: 78 // "N"
|
|
30
30
|
};
|
|
31
31
|
export const DataTypeOids = {
|
|
32
|
-
Bool: 16,
|
|
32
|
+
Bool: 16,
|
|
33
33
|
Bytea: 17,
|
|
34
|
-
Char: 18,
|
|
34
|
+
Char: 18,
|
|
35
35
|
Name: 19,
|
|
36
|
-
Text: 25,
|
|
37
|
-
Varchar: 1043,
|
|
38
|
-
Bpchar: 1042,
|
|
39
|
-
Int2: 21,
|
|
40
|
-
Int4: 23,
|
|
41
|
-
Int8: 20,
|
|
36
|
+
Text: 25,
|
|
37
|
+
Varchar: 1043,
|
|
38
|
+
Bpchar: 1042,
|
|
39
|
+
Int2: 21,
|
|
40
|
+
Int4: 23,
|
|
41
|
+
Int8: 20,
|
|
42
42
|
Float4: 700,
|
|
43
43
|
Float8: 701,
|
|
44
44
|
Numeric: 1700,
|
package/dist/protocol/types.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { DataTypeOid } from "./constants";
|
|
|
4
4
|
type BindValidator = (value: unknown) => boolean;
|
|
5
5
|
type BindWriter = (request: ConnectionRequestBuffer, value: any) => void;
|
|
6
6
|
type FieldReader = (response: ConnectionResponseBuffer, fieldLength: number, int8toBigint: boolean) => unknown;
|
|
7
|
-
interface BindHandler {
|
|
7
|
+
export interface BindHandler {
|
|
8
|
+
pgType: string;
|
|
9
|
+
jsShape: string;
|
|
8
10
|
validate: BindValidator;
|
|
9
11
|
write: BindWriter;
|
|
10
12
|
read: FieldReader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/protocol/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,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@ const isPoint = (value) => value !== null &&
|
|
|
5
5
|
'y' in value && typeof value.y === 'number';
|
|
6
6
|
export const handlers = {
|
|
7
7
|
[DataTypeOids.Bool]: {
|
|
8
|
+
pgType: 'bool',
|
|
9
|
+
jsShape: 'boolean',
|
|
8
10
|
validate: (v) => typeof v === 'boolean',
|
|
9
11
|
write: (req, v) => req.writeBinaryBool(v),
|
|
10
12
|
read: (res) => res.readBool(),
|
|
11
13
|
},
|
|
12
14
|
[DataTypeOids.Text]: {
|
|
15
|
+
pgType: 'text',
|
|
16
|
+
jsShape: 'string',
|
|
13
17
|
validate: (v) => typeof v === 'string',
|
|
14
18
|
write: (req, v) => req.writeBinaryString(v),
|
|
15
19
|
read: (res, len) => res.readRawString(len),
|
|
16
20
|
},
|
|
17
21
|
[DataTypeOids.Varchar]: {
|
|
22
|
+
pgType: 'varchar',
|
|
23
|
+
jsShape: 'string',
|
|
18
24
|
validate: (v) => typeof v === 'string',
|
|
19
25
|
write: (req, v) => req.writeBinaryString(v),
|
|
20
26
|
read: (res, len) => res.readRawString(len),
|
|
21
27
|
},
|
|
22
28
|
[DataTypeOids.Char]: {
|
|
29
|
+
pgType: 'char',
|
|
30
|
+
jsShape: 'string',
|
|
23
31
|
validate: (v) => typeof v === 'string',
|
|
24
32
|
write: (req, v) => req.writeBinaryString(v),
|
|
25
33
|
read: (res, len) => res.readRawString(len),
|
|
26
34
|
},
|
|
27
35
|
[DataTypeOids.Bpchar]: {
|
|
36
|
+
pgType: 'bpchar',
|
|
37
|
+
jsShape: 'string',
|
|
28
38
|
validate: (v) => typeof v === 'string',
|
|
29
39
|
write: (req, v) => req.writeBinaryString(v),
|
|
30
40
|
read: (res, len) => res.readRawString(len),
|
|
31
41
|
},
|
|
32
42
|
[DataTypeOids.Name]: {
|
|
43
|
+
pgType: 'name',
|
|
44
|
+
jsShape: 'string',
|
|
33
45
|
validate: (v) => typeof v === 'string' && Buffer.byteLength(v, 'utf-8') <= 63,
|
|
34
46
|
write: (req, v) => req.writeBinaryString(v),
|
|
35
47
|
read: (res, len) => res.readRawString(len),
|
|
36
48
|
},
|
|
37
49
|
[DataTypeOids.Int2]: {
|
|
50
|
+
pgType: 'int2',
|
|
51
|
+
jsShape: 'number (-32768..32767)',
|
|
38
52
|
validate: (v) => typeof v === 'number' &&
|
|
39
53
|
Number.isInteger(v) &&
|
|
40
54
|
v >= -32768 &&
|
|
@@ -43,6 +57,8 @@ export const handlers = {
|
|
|
43
57
|
read: (res) => res.readInt16(),
|
|
44
58
|
},
|
|
45
59
|
[DataTypeOids.Int4]: {
|
|
60
|
+
pgType: 'int4',
|
|
61
|
+
jsShape: 'number (-2147483648..2147483647)',
|
|
46
62
|
validate: (v) => typeof v === 'number' &&
|
|
47
63
|
Number.isInteger(v) &&
|
|
48
64
|
v >= -2147483648 &&
|
|
@@ -51,6 +67,8 @@ export const handlers = {
|
|
|
51
67
|
read: (res) => res.readInt32(),
|
|
52
68
|
},
|
|
53
69
|
[DataTypeOids.Int8]: {
|
|
70
|
+
pgType: 'int8',
|
|
71
|
+
jsShape: 'bigint | number (safe integer)',
|
|
54
72
|
validate: (v) => typeof v === 'bigint' ||
|
|
55
73
|
(typeof v === 'number' && Number.isSafeInteger(v)),
|
|
56
74
|
write: (req, v) => typeof v === 'bigint'
|
|
@@ -59,126 +77,172 @@ export const handlers = {
|
|
|
59
77
|
read: (res, _len, int8toBigint) => int8toBigint ? res.readBigInt64() : res.readInt64(),
|
|
60
78
|
},
|
|
61
79
|
[DataTypeOids.Float4]: {
|
|
80
|
+
pgType: 'float4',
|
|
81
|
+
jsShape: 'number',
|
|
62
82
|
validate: (v) => typeof v === 'number' && Number.isFinite(v),
|
|
63
83
|
write: (req, v) => req.writeBinaryFloat4(v),
|
|
64
84
|
read: (res) => res.readFloat32(),
|
|
65
85
|
},
|
|
66
86
|
[DataTypeOids.Float8]: {
|
|
87
|
+
pgType: 'float8',
|
|
88
|
+
jsShape: 'number',
|
|
67
89
|
validate: (v) => typeof v === 'number' && Number.isFinite(v),
|
|
68
90
|
write: (req, v) => req.writeBinaryFloat8(v),
|
|
69
91
|
read: (res) => res.readFloat64(),
|
|
70
92
|
},
|
|
71
93
|
[DataTypeOids.Bytea]: {
|
|
94
|
+
pgType: 'bytea',
|
|
95
|
+
jsShape: 'Buffer | Uint8Array',
|
|
72
96
|
validate: (v) => Buffer.isBuffer(v) || v instanceof Uint8Array,
|
|
73
97
|
write: (req, v) => req.writeBinaryBytea(v),
|
|
74
98
|
read: (res, len) => res.readBytes(len),
|
|
75
99
|
},
|
|
76
100
|
[DataTypeOids.Timestamp]: {
|
|
101
|
+
pgType: 'timestamp',
|
|
102
|
+
jsShape: 'Date',
|
|
77
103
|
validate: (v) => v instanceof Date,
|
|
78
104
|
write: (req, v) => req.writeBinaryTimestamp(v),
|
|
79
105
|
read: (res) => res.readBinaryTimestamp(),
|
|
80
106
|
},
|
|
81
107
|
[DataTypeOids.Timestamptz]: {
|
|
108
|
+
pgType: 'timestamptz',
|
|
109
|
+
jsShape: 'Date',
|
|
82
110
|
validate: (v) => v instanceof Date,
|
|
83
111
|
write: (req, v) => req.writeBinaryTimestamp(v),
|
|
84
112
|
read: (res) => res.readBinaryTimestamp(),
|
|
85
113
|
},
|
|
86
114
|
[DataTypeOids.Point]: {
|
|
115
|
+
pgType: 'point',
|
|
116
|
+
jsShape: '{ x: number, y: number }',
|
|
87
117
|
validate: isPoint,
|
|
88
118
|
write: (req, v) => req.writeBinaryPoint(v),
|
|
89
119
|
read: (res) => res.readBinaryPoint(),
|
|
90
120
|
},
|
|
91
121
|
[DataTypeOids.Numeric]: {
|
|
122
|
+
pgType: 'numeric',
|
|
123
|
+
jsShape: 'string ("[-]digits[.digits]")',
|
|
92
124
|
validate: (v) => (typeof v === 'string' && /^-?\d*\.?\d+$/.test(v)),
|
|
93
125
|
write: (req, v) => req.writeBinaryNumeric(v),
|
|
94
126
|
read: (res) => res.readBinaryNumeric(),
|
|
95
127
|
},
|
|
96
128
|
[DataTypeOids.Date]: {
|
|
129
|
+
pgType: 'date',
|
|
130
|
+
jsShape: 'Date',
|
|
97
131
|
validate: (v) => v instanceof Date,
|
|
98
132
|
write: (req, v) => req.writeBinaryDate(v),
|
|
99
133
|
read: (res) => res.readBinaryDate(),
|
|
100
134
|
},
|
|
101
135
|
[DataTypeOids.Time]: {
|
|
136
|
+
pgType: 'time',
|
|
137
|
+
jsShape: 'string ("HH:MM:SS.mmm")',
|
|
102
138
|
validate: (v) => typeof v === 'string' &&
|
|
103
139
|
/^(\d{2}):(\d{2}):(\d{2})\.(\d{3})$/.test(v),
|
|
104
140
|
write: (req, v) => req.writeBinaryTime(v),
|
|
105
141
|
read: (res) => res.readBinaryTime(),
|
|
106
142
|
},
|
|
107
143
|
[DataTypeOids.Timetz]: {
|
|
144
|
+
pgType: 'timetz',
|
|
145
|
+
jsShape: 'string ("HH:MM:SS.mmm±HH:MM")',
|
|
108
146
|
validate: (v) => typeof v === 'string' &&
|
|
109
147
|
/^(\d{2}):(\d{2}):(\d{2})\.(\d{3})([+-])(\d{2}):(\d{2})$/.test(v),
|
|
110
148
|
write: (req, v) => req.writeBinaryTimetz(v),
|
|
111
149
|
read: (res) => res.readBinaryTimetz(),
|
|
112
150
|
},
|
|
113
151
|
[DataTypeOids.Interval]: {
|
|
152
|
+
pgType: 'interval',
|
|
153
|
+
jsShape: '{ months: number, days: number, microseconds: number }',
|
|
114
154
|
validate: (v) => v !== null &&
|
|
115
155
|
typeof v === 'object' &&
|
|
116
156
|
'months' in v && typeof v.months === 'number' &&
|
|
117
157
|
'days' in v && typeof v.days === 'number' &&
|
|
118
158
|
'microseconds' in v &&
|
|
119
|
-
|
|
159
|
+
typeof v.microseconds === 'number',
|
|
120
160
|
write: (req, v) => req.writeBinaryInterval(v),
|
|
121
161
|
read: (res) => res.readBinaryInterval(),
|
|
122
162
|
},
|
|
123
163
|
[DataTypeOids.Json]: {
|
|
164
|
+
pgType: 'json',
|
|
165
|
+
jsShape: 'unknown (JSON-serializable)',
|
|
124
166
|
validate: (_v) => true,
|
|
125
167
|
write: (req, v) => req.writeBinaryJson(v),
|
|
126
168
|
read: (res, len) => res.readBinaryJson(len),
|
|
127
169
|
},
|
|
128
170
|
[DataTypeOids.Jsonb]: {
|
|
171
|
+
pgType: 'jsonb',
|
|
172
|
+
jsShape: 'unknown (JSON-serializable)',
|
|
129
173
|
validate: (_v) => true,
|
|
130
174
|
write: (req, v) => req.writeBinaryJsonb(v),
|
|
131
175
|
read: (res, len) => res.readBinaryJsonb(len),
|
|
132
176
|
},
|
|
133
177
|
[DataTypeOids.Uuid]: {
|
|
178
|
+
pgType: 'uuid',
|
|
179
|
+
jsShape: 'string ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")',
|
|
134
180
|
validate: (v) => typeof v === 'string' &&
|
|
135
181
|
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(v),
|
|
136
182
|
write: (req, v) => req.writeBinaryUuid(v),
|
|
137
183
|
read: (res) => res.readBinaryUuid(),
|
|
138
184
|
},
|
|
139
185
|
[DataTypeOids.Cidr]: {
|
|
186
|
+
pgType: 'cidr',
|
|
187
|
+
jsShape: 'string (IPv4/IPv6 address or CIDR)',
|
|
140
188
|
validate: (v) => typeof v === 'string',
|
|
141
189
|
write: (req, v) => req.writeBinaryCidr(v),
|
|
142
190
|
read: (res, len) => res.readBinaryInet(len),
|
|
143
191
|
},
|
|
144
192
|
[DataTypeOids.Inet]: {
|
|
193
|
+
pgType: 'inet',
|
|
194
|
+
jsShape: 'string (IPv4/IPv6 address or CIDR)',
|
|
145
195
|
validate: (v) => typeof v === 'string',
|
|
146
196
|
write: (req, v) => req.writeBinaryInet(v),
|
|
147
197
|
read: (res, len) => res.readBinaryInet(len),
|
|
148
198
|
},
|
|
149
199
|
[DataTypeOids.Macaddr]: {
|
|
200
|
+
pgType: 'macaddr',
|
|
201
|
+
jsShape: 'string ("xx:xx:xx:xx:xx:xx")',
|
|
150
202
|
validate: (v) => typeof v === 'string' &&
|
|
151
203
|
/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i.test(v),
|
|
152
204
|
write: (req, v) => req.writeBinaryMacaddr(v),
|
|
153
205
|
read: (res) => res.readBinaryMacaddr(),
|
|
154
206
|
},
|
|
155
207
|
[DataTypeOids.Oid]: {
|
|
208
|
+
pgType: 'oid',
|
|
209
|
+
jsShape: 'number',
|
|
156
210
|
validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
|
|
157
211
|
write: (req, v) => req.writeBinaryOid(v),
|
|
158
212
|
read: (res) => res.readBinaryOid(),
|
|
159
213
|
},
|
|
160
214
|
[DataTypeOids.Xid]: {
|
|
215
|
+
pgType: 'xid',
|
|
216
|
+
jsShape: 'number',
|
|
161
217
|
validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
|
|
162
218
|
write: (req, v) => req.writeBinaryXid(v),
|
|
163
219
|
read: (res) => res.readBinaryXid(),
|
|
164
220
|
},
|
|
165
221
|
[DataTypeOids.Cid]: {
|
|
222
|
+
pgType: 'cid',
|
|
223
|
+
jsShape: 'number',
|
|
166
224
|
validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
|
|
167
225
|
write: (req, v) => req.writeBinaryCid(v),
|
|
168
226
|
read: (res) => res.readBinaryCid(),
|
|
169
227
|
},
|
|
170
228
|
[DataTypeOids.Regproc]: {
|
|
229
|
+
pgType: 'regproc',
|
|
230
|
+
jsShape: 'number',
|
|
171
231
|
validate: (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0,
|
|
172
232
|
write: (req, v) => req.writeBinaryRegproc(v),
|
|
173
233
|
read: (res) => res.readBinaryRegproc(),
|
|
174
234
|
},
|
|
175
235
|
[DataTypeOids.Lseg]: {
|
|
236
|
+
pgType: 'lseg',
|
|
237
|
+
jsShape: '{ a: Point, b: Point }',
|
|
176
238
|
validate: (v) => v !== null && typeof v === 'object' &&
|
|
177
239
|
isPoint(v.a) && isPoint(v.b),
|
|
178
240
|
write: (req, v) => req.writeBinaryLseg(v),
|
|
179
241
|
read: (res) => res.readBinaryLseg(),
|
|
180
242
|
},
|
|
181
243
|
[DataTypeOids.Path]: {
|
|
244
|
+
pgType: 'path',
|
|
245
|
+
jsShape: '{ closed: boolean, points: Point[] }',
|
|
182
246
|
validate: (v) => v !== null && typeof v === 'object' &&
|
|
183
247
|
typeof v.closed === 'boolean' &&
|
|
184
248
|
Array.isArray(v.points) &&
|
|
@@ -187,12 +251,16 @@ export const handlers = {
|
|
|
187
251
|
read: (res) => res.readBinaryPath(),
|
|
188
252
|
},
|
|
189
253
|
[DataTypeOids.Box]: {
|
|
254
|
+
pgType: 'box',
|
|
255
|
+
jsShape: '{ high: Point, low: Point }',
|
|
190
256
|
validate: (v) => v !== null && typeof v === 'object' &&
|
|
191
257
|
isPoint(v.high) && isPoint(v.low),
|
|
192
258
|
write: (req, v) => req.writeBinaryBox(v),
|
|
193
259
|
read: (res) => res.readBinaryBox(),
|
|
194
260
|
},
|
|
195
261
|
[DataTypeOids.Polygon]: {
|
|
262
|
+
pgType: 'polygon',
|
|
263
|
+
jsShape: '{ points: Point[] }',
|
|
196
264
|
validate: (v) => v !== null && typeof v === 'object' &&
|
|
197
265
|
Array.isArray(v.points) &&
|
|
198
266
|
v.points.every(isPoint),
|
|
@@ -200,6 +268,8 @@ export const handlers = {
|
|
|
200
268
|
read: (res) => res.readBinaryPolygon(),
|
|
201
269
|
},
|
|
202
270
|
[DataTypeOids.Line]: {
|
|
271
|
+
pgType: 'line',
|
|
272
|
+
jsShape: '{ a: number, b: number, c: number }',
|
|
203
273
|
validate: (v) => v !== null && typeof v === 'object' &&
|
|
204
274
|
typeof v.a === 'number' &&
|
|
205
275
|
typeof v.b === 'number' &&
|
|
@@ -208,21 +278,29 @@ export const handlers = {
|
|
|
208
278
|
read: (res) => res.readBinaryLine(),
|
|
209
279
|
},
|
|
210
280
|
[DataTypeOids.BoolArray]: {
|
|
281
|
+
pgType: 'bool[]',
|
|
282
|
+
jsShape: '(boolean | null)[]',
|
|
211
283
|
validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'boolean'),
|
|
212
284
|
write: (req, v) => req.writeBinaryBoolArray(v),
|
|
213
285
|
read: (res, len) => res.readBinaryArray(len, () => res.readBool()),
|
|
214
286
|
},
|
|
215
287
|
[DataTypeOids.Int2Array]: {
|
|
288
|
+
pgType: 'int2[]',
|
|
289
|
+
jsShape: '(number | null)[]',
|
|
216
290
|
validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'number' && Number.isInteger(el) && el >= -32768 && el <= 32767)),
|
|
217
291
|
write: (req, v) => req.writeBinaryInt2Array(v),
|
|
218
292
|
read: (res, len) => res.readBinaryArray(len, () => res.readInt16()),
|
|
219
293
|
},
|
|
220
294
|
[DataTypeOids.Int4Array]: {
|
|
295
|
+
pgType: 'int4[]',
|
|
296
|
+
jsShape: '(number | null)[]',
|
|
221
297
|
validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'number' && Number.isInteger(el) && el >= -2147483648 && el <= 2147483647)),
|
|
222
298
|
write: (req, v) => req.writeBinaryInt4Array(v),
|
|
223
299
|
read: (res, len) => res.readBinaryArray(len, () => res.readInt32()),
|
|
224
300
|
},
|
|
225
301
|
[DataTypeOids.Int8Array]: {
|
|
302
|
+
pgType: 'int8[]',
|
|
303
|
+
jsShape: '(number | bigint | null)[]',
|
|
226
304
|
validate: (v) => Array.isArray(v) && v.every(el => el == null ||
|
|
227
305
|
typeof el === 'bigint' ||
|
|
228
306
|
(typeof el === 'number' && Number.isSafeInteger(el))),
|
|
@@ -230,31 +308,43 @@ export const handlers = {
|
|
|
230
308
|
read: (res, len, int8toBigint) => res.readBinaryArray(len, () => int8toBigint ? res.readBigInt64() : res.readInt64()),
|
|
231
309
|
},
|
|
232
310
|
[DataTypeOids.TextArray]: {
|
|
311
|
+
pgType: 'text[]',
|
|
312
|
+
jsShape: '(string | null)[]',
|
|
233
313
|
validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'string'),
|
|
234
314
|
write: (req, v) => req.writeBinaryTextArray(v),
|
|
235
315
|
read: (res, len) => res.readBinaryArray(len, (l) => res.readRawString(l)),
|
|
236
316
|
},
|
|
237
317
|
[DataTypeOids.VarcharArray]: {
|
|
318
|
+
pgType: 'varchar[]',
|
|
319
|
+
jsShape: '(string | null)[]',
|
|
238
320
|
validate: (v) => Array.isArray(v) && v.every(el => el == null || typeof el === 'string'),
|
|
239
321
|
write: (req, v) => req.writeBinaryVarcharArray(v),
|
|
240
322
|
read: (res, len) => res.readBinaryArray(len, (l) => res.readRawString(l)),
|
|
241
323
|
},
|
|
242
324
|
[DataTypeOids.JsonArray]: {
|
|
325
|
+
pgType: 'json[]',
|
|
326
|
+
jsShape: 'unknown[]',
|
|
243
327
|
validate: (v) => Array.isArray(v),
|
|
244
328
|
write: (req, v) => req.writeBinaryJsonArray(v),
|
|
245
329
|
read: (res, len) => res.readBinaryArray(len, (l) => res.readBinaryJson(l)),
|
|
246
330
|
},
|
|
247
331
|
[DataTypeOids.JsonbArray]: {
|
|
332
|
+
pgType: 'jsonb[]',
|
|
333
|
+
jsShape: 'unknown[]',
|
|
248
334
|
validate: (v) => Array.isArray(v),
|
|
249
335
|
write: (req, v) => req.writeBinaryJsonbArray(v),
|
|
250
336
|
read: (res, len) => res.readBinaryArray(len, (l) => res.readBinaryJsonb(l)),
|
|
251
337
|
},
|
|
252
338
|
[DataTypeOids.UuidArray]: {
|
|
339
|
+
pgType: 'uuid[]',
|
|
340
|
+
jsShape: '(string | null)[]',
|
|
253
341
|
validate: (v) => Array.isArray(v) && v.every(el => el == null || (typeof el === 'string' && /^[0-9a-f-]{36}$/i.test(el))),
|
|
254
342
|
write: (req, v) => req.writeBinaryUuidArray(v),
|
|
255
343
|
read: (res, len) => res.readBinaryArray(len, () => res.readBinaryUuid()),
|
|
256
344
|
},
|
|
257
345
|
[DataTypeOids.NumericArray]: {
|
|
346
|
+
pgType: 'numeric[]',
|
|
347
|
+
jsShape: '(string | null)[]',
|
|
258
348
|
validate: (v) => Array.isArray(v) && v.every(el => el == null ||
|
|
259
349
|
(typeof el === 'number' && Number.isFinite(el)) ||
|
|
260
350
|
(typeof el === 'string' && /^-?\d*\.?\d+$/.test(el))),
|
package/dist/query.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Future, Resolvers } from "fluent-future";
|
|
2
|
-
import {
|
|
2
|
+
import { QueryText, Row, StatementMeta } from "./types";
|
|
3
3
|
import { PostgresError } from "./error";
|
|
4
4
|
export declare abstract class Query {
|
|
5
5
|
protected _timer?: NodeJS.Timeout;
|
|
@@ -8,42 +8,40 @@ export declare abstract class Query {
|
|
|
8
8
|
abstract complete(...args: any[]): void;
|
|
9
9
|
}
|
|
10
10
|
export declare class CollectQuery<T extends Row> extends Query {
|
|
11
|
-
meta: StatementMeta;
|
|
12
11
|
text: QueryText;
|
|
13
12
|
args: unknown[];
|
|
14
|
-
|
|
13
|
+
meta: StatementMeta;
|
|
15
14
|
resolvers: Resolvers<Future<T[], PostgresError>>;
|
|
16
15
|
private _rows;
|
|
17
|
-
constructor(
|
|
16
|
+
constructor(text: QueryText, args: unknown[], meta: StatementMeta, resolvers: Resolvers<Future<T[], PostgresError>>, timeout: number);
|
|
18
17
|
push(value: T): void;
|
|
19
18
|
error(cause: PostgresError): void;
|
|
20
19
|
complete(): void;
|
|
21
20
|
}
|
|
22
21
|
export declare class ExecuteQuery extends Query {
|
|
23
|
-
meta: StatementMeta;
|
|
24
22
|
text: QueryText;
|
|
25
23
|
args: unknown[];
|
|
24
|
+
meta: StatementMeta;
|
|
26
25
|
resolvers: Resolvers<Future<void, PostgresError>>;
|
|
27
|
-
constructor(
|
|
26
|
+
constructor(text: QueryText, args: unknown[], meta: StatementMeta, resolvers: Resolvers<Future<void, PostgresError>>, timeout: number);
|
|
28
27
|
error(cause: PostgresError): void;
|
|
29
28
|
complete(): void;
|
|
30
29
|
}
|
|
31
30
|
export declare class StreamQuery<T> extends Query {
|
|
32
|
-
meta: StatementMeta;
|
|
33
31
|
text: QueryText;
|
|
34
32
|
args: unknown[];
|
|
33
|
+
meta: StatementMeta;
|
|
35
34
|
controller: ReadableStreamDefaultController<T>;
|
|
36
|
-
|
|
37
|
-
constructor(meta: StatementMeta, text: QueryText, args: unknown[], controller: ReadableStreamDefaultController<T>, columns: ColumnDescription[] | null, timeout: number);
|
|
35
|
+
constructor(text: QueryText, args: unknown[], meta: StatementMeta, controller: ReadableStreamDefaultController<T>, timeout: number);
|
|
38
36
|
push(value: T): void;
|
|
39
37
|
error(cause: PostgresError): void;
|
|
40
38
|
complete(): void;
|
|
41
39
|
}
|
|
42
40
|
export declare class ParseQuery extends Query {
|
|
43
|
-
meta: StatementMeta;
|
|
44
41
|
text: QueryText;
|
|
42
|
+
meta: StatementMeta;
|
|
45
43
|
resolvers: Resolvers<Future<StatementMeta, PostgresError>>;
|
|
46
|
-
constructor(
|
|
44
|
+
constructor(text: QueryText, meta: StatementMeta, resolvers: Resolvers<Future<StatementMeta, PostgresError>>, timeout: number);
|
|
47
45
|
error(cause: PostgresError): void;
|
|
48
46
|
complete(): void;
|
|
49
47
|
}
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAqB,SAAS,EAAE,GAAG,EAAE,aAAa,EAAiB,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AAGzD,8BAAsB,KAAK;IACvB,SAAS,C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f,IAAI,EAAE,OAAO,EAAE;IACf,IAAI,EAAE,aAAa;IACnB,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC;gBAH9C,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,OAAO,EAAE,EACf,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC,EACrD,OAAO,EAAE,MAAM;IAMnB,IAAI,CAAC,KAAK,EAAE,CAAC;IAOb,KAAK,CAAC,KAAK,EAAE,aAAa;IAM1B,QAAQ;CAMX;AAED,qBAAa,UAAW,SAAQ,KAAK;IAEtB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,aAAa;IACnB,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAF1D,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,EACjE,OAAO,EAAE,MAAM;IAKnB,KAAK,CAAC,KAAK,EAAE,aAAa;IAM1B,QAAQ;CAIX;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,YAAY,CAAA"}
|
package/dist/query.js
CHANGED
|
@@ -7,12 +7,11 @@ export class Query {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export class CollectQuery extends Query {
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(text, args, meta, resolvers, timeout) {
|
|
11
11
|
super(timeout);
|
|
12
|
-
this.meta = meta;
|
|
13
12
|
this.text = text;
|
|
14
13
|
this.args = args;
|
|
15
|
-
this.
|
|
14
|
+
this.meta = meta;
|
|
16
15
|
this.resolvers = resolvers;
|
|
17
16
|
this._rows = [];
|
|
18
17
|
}
|
|
@@ -29,11 +28,11 @@ export class CollectQuery extends Query {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
export class ExecuteQuery extends Query {
|
|
32
|
-
constructor(
|
|
31
|
+
constructor(text, args, meta, resolvers, timeout) {
|
|
33
32
|
super(timeout);
|
|
34
|
-
this.meta = meta;
|
|
35
33
|
this.text = text;
|
|
36
34
|
this.args = args;
|
|
35
|
+
this.meta = meta;
|
|
37
36
|
this.resolvers = resolvers;
|
|
38
37
|
}
|
|
39
38
|
error(cause) {
|
|
@@ -46,13 +45,12 @@ export class ExecuteQuery extends Query {
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
export class StreamQuery extends Query {
|
|
49
|
-
constructor(
|
|
48
|
+
constructor(text, args, meta, controller, timeout) {
|
|
50
49
|
super(timeout);
|
|
51
|
-
this.meta = meta;
|
|
52
50
|
this.text = text;
|
|
53
51
|
this.args = args;
|
|
52
|
+
this.meta = meta;
|
|
54
53
|
this.controller = controller;
|
|
55
|
-
this.columns = columns;
|
|
56
54
|
}
|
|
57
55
|
push(value) {
|
|
58
56
|
try {
|
|
@@ -73,10 +71,10 @@ export class StreamQuery extends Query {
|
|
|
73
71
|
}
|
|
74
72
|
}
|
|
75
73
|
export class ParseQuery extends Query {
|
|
76
|
-
constructor(
|
|
74
|
+
constructor(text, meta, resolvers, timeout) {
|
|
77
75
|
super(timeout);
|
|
78
|
-
this.meta = meta;
|
|
79
76
|
this.text = text;
|
|
77
|
+
this.meta = meta;
|
|
80
78
|
this.resolvers = resolvers;
|
|
81
79
|
}
|
|
82
80
|
error(cause) {
|
package/dist/transaction.d.ts
CHANGED
|
@@ -25,14 +25,22 @@ export declare class Transaction {
|
|
|
25
25
|
/**
|
|
26
26
|
* Executes a query within the current transaction.
|
|
27
27
|
*/
|
|
28
|
-
query<T extends Row>(
|
|
28
|
+
query<T extends Row>(templates: TemplateStringsArray, ...params: any[]): Future<T[], PostgresError>;
|
|
29
29
|
/**
|
|
30
30
|
* Like {@link query}, but for statements that don't return rows (INSERT/UPDATE/DDL/etc).
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* await tx.execute`UPDATE users SET name = ${name} WHERE id = ${id}`
|
|
34
34
|
*/
|
|
35
|
-
execute(
|
|
35
|
+
execute(templates: TemplateStringsArray, ...params: any[]): Future<void, PostgresError>;
|
|
36
|
+
/**
|
|
37
|
+
* Streams query results as a `ReadableStream`, without buffering rows in memory.
|
|
38
|
+
* Ideal for large result sets or piping straight into an HTTP response.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* for await (const row of conn.stream<User>`SELECT * FROM orders`) { ... }
|
|
42
|
+
*/
|
|
43
|
+
stream<T extends Row>(templates: TemplateStringsArray, ...params: any[]): ReadableStream<T>;
|
|
36
44
|
/**
|
|
37
45
|
* Creates a sub-transaction using PostgreSQL SAVEPOINT.
|
|
38
46
|
* If the callback throws, only the actions within this savepoint are rolled back.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAuE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5G,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAG7B;;;GAGG;AACH,qBAAa,WAAW;IAIhB,QAAQ,CAAC,IAAI,EAAE,UAAU;IAH7B,OAAO,CAAC,UAAU,CAAiB;gBAGtB,IAAI,EAAE,UAAU;IAI7B;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAGD;;OAEG;IACI,MAAM;IAMb;;OAEG;IACI,QAAQ;IAMf;;OAEG;IACI,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAyB7E;;;;;OAKG;IACI,OAAO,CAAC,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAyBhE;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,SAAS,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAsCvE;;;;;;;;;OASG;IACI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;CAS9E"}
|