@m2k-5f/pgtx 2.8.1 → 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 +3 -2
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +76 -41
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +1 -0
- 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 +0 -2
- package/dist/protocol/types.d.ts.map +1 -1
- package/dist/protocol/types.js +2 -2
- 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/connection.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Queue } from "./queue";
|
|
|
6
6
|
import { CollectQuery, StreamQuery, ExecuteQuery, ParseQuery } from "./query";
|
|
7
7
|
import { sql } from ".";
|
|
8
8
|
import { Begin, Future, Ok } from 'fluent-future';
|
|
9
|
-
import { ErrConnectionClosed, ErrConnectionReconnecting } from "./error";
|
|
9
|
+
import { ErrConnectionClosed, ErrConnectionReconnecting, ErrTransactionInProgress } from "./error";
|
|
10
10
|
import { nextTick } from "process";
|
|
11
11
|
import { authorizeSocket, createSocket, upgradeSocket } from "./protocol/socket-authorization";
|
|
12
12
|
import { ConnectionRequestBuffer } from "./protocol/connection-request-writer";
|
|
@@ -51,14 +51,14 @@ export class Connection {
|
|
|
51
51
|
+ `\x1b[33m└────────────────────────────────────────────────\x1b[0m\n`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
_registerSсhedule() {
|
|
55
55
|
if (!this._sheduled) {
|
|
56
56
|
this._sheduled = true;
|
|
57
57
|
this._writer.clear();
|
|
58
|
-
shedule[this.config.
|
|
58
|
+
shedule[this.config.syncSсhedule](() => this._sсhedule());
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
_sсhedule() {
|
|
62
62
|
if (this._reconnecting)
|
|
63
63
|
return;
|
|
64
64
|
this._writer.hasMore && this._socket.write(this._writer);
|
|
@@ -66,7 +66,7 @@ export class Connection {
|
|
|
66
66
|
this._sheduled = false;
|
|
67
67
|
}
|
|
68
68
|
_registerQuery(query) {
|
|
69
|
-
this.
|
|
69
|
+
this._registerSсhedule();
|
|
70
70
|
if (query instanceof ParseQuery) {
|
|
71
71
|
this._writer
|
|
72
72
|
.writeParse(query.meta.statement, query.text)
|
|
@@ -92,6 +92,7 @@ export class Connection {
|
|
|
92
92
|
this._closing = null;
|
|
93
93
|
this._closed = false;
|
|
94
94
|
this._reconnecting = null;
|
|
95
|
+
this._inTransaction = false;
|
|
95
96
|
this._parsed = new Map();
|
|
96
97
|
this._parsing = new Map();
|
|
97
98
|
this._listeningCallbacks = new Map();
|
|
@@ -109,7 +110,7 @@ export class Connection {
|
|
|
109
110
|
logLevel: config.logLevel || 'error',
|
|
110
111
|
int8toBigint: config.int8toBigint || false,
|
|
111
112
|
queryTimeout: config.queryTimeout || 30000,
|
|
112
|
-
|
|
113
|
+
syncSсhedule: config.syncSсhedule || 'Immediate',
|
|
113
114
|
ssl: config.caPath ? 'require' : (config.ssl || 'prefer')
|
|
114
115
|
};
|
|
115
116
|
return createSocket(conf)
|
|
@@ -125,19 +126,28 @@ export class Connection {
|
|
|
125
126
|
* const users = await conn.query<User>`SELECT * FROM users WHERE id = ${1}`
|
|
126
127
|
*/
|
|
127
128
|
query(templates, ...params) {
|
|
128
|
-
if (this.isClosed)
|
|
129
|
+
if (this.isClosed) {
|
|
130
|
+
this._logError(ErrConnectionClosed);
|
|
129
131
|
return Future.reject(ErrConnectionClosed);
|
|
132
|
+
}
|
|
133
|
+
if (this._inTransaction) {
|
|
134
|
+
this._logError(ErrTransactionInProgress);
|
|
135
|
+
return Future.reject(ErrTransactionInProgress);
|
|
136
|
+
}
|
|
130
137
|
const { text, args } = compileSqlTemplate(templates, params);
|
|
131
138
|
const resolvers = Future.withResolvers();
|
|
132
|
-
if (this._reconnecting)
|
|
133
|
-
return this._reconnecting
|
|
139
|
+
if (this._reconnecting) {
|
|
140
|
+
return this._reconnecting
|
|
141
|
+
.tapErr(err => this._logError(err))
|
|
142
|
+
.andThen(() => this._performQuery(text, args, resolvers));
|
|
143
|
+
}
|
|
134
144
|
return this._performQuery(text, args, resolvers);
|
|
135
145
|
}
|
|
136
146
|
_performQuery(text, args, resolvers) {
|
|
137
147
|
this._logQuery(text, args);
|
|
138
148
|
const parsed = this._parsed.get(text);
|
|
139
149
|
if (parsed) {
|
|
140
|
-
const query = new CollectQuery(
|
|
150
|
+
const query = new CollectQuery(text, args, parsed, resolvers, this.config.queryTimeout);
|
|
141
151
|
const err = this._registerQuery(query);
|
|
142
152
|
if (err) {
|
|
143
153
|
query.error(err);
|
|
@@ -146,13 +156,18 @@ export class Connection {
|
|
|
146
156
|
return query.resolvers.future;
|
|
147
157
|
}
|
|
148
158
|
if (!this._parsing.has(text)) {
|
|
149
|
-
const
|
|
159
|
+
const newMeta = {
|
|
160
|
+
statement: this._nextStatement(),
|
|
161
|
+
columns: EMPTY_ARRAY,
|
|
162
|
+
parameters: EMPTY_ARRAY
|
|
163
|
+
};
|
|
164
|
+
const parseQuery = new ParseQuery(text, newMeta, Future.withResolvers(), this.config.queryTimeout);
|
|
150
165
|
this._registerQuery(parseQuery);
|
|
151
166
|
this._parsing.set(text, parseQuery.resolvers.future);
|
|
152
167
|
}
|
|
153
168
|
const parsing = this._parsing.get(text);
|
|
154
169
|
return parsing.andThen(meta => {
|
|
155
|
-
const query = new CollectQuery(
|
|
170
|
+
const query = new CollectQuery(text, args, meta, resolvers, this.config.queryTimeout);
|
|
156
171
|
const err = this._registerQuery(query);
|
|
157
172
|
if (err) {
|
|
158
173
|
query.error(err);
|
|
@@ -168,19 +183,28 @@ export class Connection {
|
|
|
168
183
|
* await conn.execute`UPDATE users SET name = ${name} WHERE id = ${id}`
|
|
169
184
|
*/
|
|
170
185
|
execute(templates, ...params) {
|
|
171
|
-
if (this.isClosed)
|
|
186
|
+
if (this.isClosed) {
|
|
187
|
+
this._logError(ErrConnectionClosed);
|
|
172
188
|
return Future.reject(ErrConnectionClosed);
|
|
189
|
+
}
|
|
190
|
+
if (this._inTransaction) {
|
|
191
|
+
this._logError(ErrTransactionInProgress);
|
|
192
|
+
return Future.reject(ErrTransactionInProgress);
|
|
193
|
+
}
|
|
173
194
|
const { text, args } = compileSqlTemplate(templates, params);
|
|
174
195
|
const resolvers = Future.withResolvers();
|
|
175
|
-
if (this._reconnecting)
|
|
176
|
-
return this._reconnecting
|
|
196
|
+
if (this._reconnecting) {
|
|
197
|
+
return this._reconnecting
|
|
198
|
+
.tapErr(err => this._logError(err))
|
|
199
|
+
.andThen(() => this._performExecute(text, args, resolvers));
|
|
200
|
+
}
|
|
177
201
|
return this._performExecute(text, args, resolvers);
|
|
178
202
|
}
|
|
179
203
|
_performExecute(text, args, resolvers) {
|
|
180
204
|
this._logQuery(text, args);
|
|
181
205
|
const parsed = this._parsed.get(text);
|
|
182
206
|
if (parsed) {
|
|
183
|
-
const query = new ExecuteQuery(
|
|
207
|
+
const query = new ExecuteQuery(text, args, parsed, resolvers, this.config.queryTimeout);
|
|
184
208
|
const err = this._registerQuery(query);
|
|
185
209
|
if (err) {
|
|
186
210
|
query.error(err);
|
|
@@ -189,13 +213,18 @@ export class Connection {
|
|
|
189
213
|
return query.resolvers.future;
|
|
190
214
|
}
|
|
191
215
|
if (!this._parsing.has(text)) {
|
|
192
|
-
const
|
|
216
|
+
const newMeta = {
|
|
217
|
+
statement: this._nextStatement(),
|
|
218
|
+
columns: EMPTY_ARRAY,
|
|
219
|
+
parameters: EMPTY_ARRAY
|
|
220
|
+
};
|
|
221
|
+
const parseQuery = new ParseQuery(text, newMeta, Future.withResolvers(), this.config.queryTimeout);
|
|
193
222
|
this._registerQuery(parseQuery);
|
|
194
223
|
this._parsing.set(text, parseQuery.resolvers.future);
|
|
195
224
|
}
|
|
196
225
|
const parsing = this._parsing.get(text);
|
|
197
226
|
return parsing.andThen(meta => {
|
|
198
|
-
const query = new ExecuteQuery(
|
|
227
|
+
const query = new ExecuteQuery(text, args, meta, resolvers, this.config.queryTimeout);
|
|
199
228
|
const err = this._registerQuery(query);
|
|
200
229
|
if (err) {
|
|
201
230
|
query.error(err);
|
|
@@ -212,8 +241,14 @@ export class Connection {
|
|
|
212
241
|
* for await (const row of conn.stream<User>`SELECT * FROM orders`) { ... }
|
|
213
242
|
*/
|
|
214
243
|
stream(templates, ...params) {
|
|
215
|
-
if (this.isClosed)
|
|
244
|
+
if (this.isClosed) {
|
|
245
|
+
this._logError(ErrConnectionClosed);
|
|
216
246
|
throw ErrConnectionClosed;
|
|
247
|
+
}
|
|
248
|
+
if (this._inTransaction) {
|
|
249
|
+
this._logError(ErrTransactionInProgress);
|
|
250
|
+
throw (ErrTransactionInProgress);
|
|
251
|
+
}
|
|
217
252
|
const { text, args } = compileSqlTemplate(templates, params);
|
|
218
253
|
let controller;
|
|
219
254
|
const stream = new ReadableStream({
|
|
@@ -224,7 +259,11 @@ export class Connection {
|
|
|
224
259
|
if (this._reconnecting) {
|
|
225
260
|
this._reconnecting
|
|
226
261
|
.tap(() => this._performStream(text, args, controller))
|
|
227
|
-
.tapErr(err =>
|
|
262
|
+
.tapErr(err => {
|
|
263
|
+
this._logError(err);
|
|
264
|
+
controller.error(err);
|
|
265
|
+
})
|
|
266
|
+
.recover();
|
|
228
267
|
return stream;
|
|
229
268
|
}
|
|
230
269
|
this._performStream(text, args, controller);
|
|
@@ -234,7 +273,7 @@ export class Connection {
|
|
|
234
273
|
this._logQuery(text, args);
|
|
235
274
|
const parsed = this._parsed.get(text);
|
|
236
275
|
if (parsed) {
|
|
237
|
-
const query = new StreamQuery(
|
|
276
|
+
const query = new StreamQuery(text, args, parsed, controller, this.config.queryTimeout);
|
|
238
277
|
const err = this._registerQuery(query);
|
|
239
278
|
if (err) {
|
|
240
279
|
controller.error(err);
|
|
@@ -243,14 +282,15 @@ export class Connection {
|
|
|
243
282
|
return;
|
|
244
283
|
}
|
|
245
284
|
if (!this._parsing.has(text)) {
|
|
246
|
-
const
|
|
285
|
+
const newMeta = { statement: this._nextStatement(), columns: EMPTY_ARRAY, parameters: EMPTY_ARRAY };
|
|
286
|
+
const parseQuery = new ParseQuery(text, newMeta, Future.withResolvers(), this.config.queryTimeout);
|
|
247
287
|
this._registerQuery(parseQuery);
|
|
248
288
|
this._parsing.set(text, parseQuery.resolvers.future);
|
|
249
289
|
}
|
|
250
290
|
const parsing = this._parsing.get(text);
|
|
251
291
|
parsing
|
|
252
292
|
.tap(meta => {
|
|
253
|
-
const query = new StreamQuery(
|
|
293
|
+
const query = new StreamQuery(text, args, meta, controller, this.config.queryTimeout);
|
|
254
294
|
const err = this._registerQuery(query);
|
|
255
295
|
if (err) {
|
|
256
296
|
controller.error(err);
|
|
@@ -271,13 +311,12 @@ export class Connection {
|
|
|
271
311
|
* })
|
|
272
312
|
*/
|
|
273
313
|
begin(txCallback) {
|
|
274
|
-
if (this.isClosed)
|
|
275
|
-
return Future.reject(ErrConnectionClosed);
|
|
276
314
|
return Begin()
|
|
277
315
|
.andThen(() => this.execute `begin`)
|
|
278
316
|
.andThen(() => {
|
|
317
|
+
this._inTransaction = true;
|
|
279
318
|
const tx = new Transaction(this);
|
|
280
|
-
return Future.of(txCallback(tx))
|
|
319
|
+
return Future.of(() => txCallback(tx))
|
|
281
320
|
.tap(() => {
|
|
282
321
|
if (tx.isActive)
|
|
283
322
|
return tx.commit();
|
|
@@ -286,29 +325,25 @@ export class Connection {
|
|
|
286
325
|
if (tx.isActive)
|
|
287
326
|
return tx.rollback();
|
|
288
327
|
});
|
|
289
|
-
})
|
|
328
|
+
})
|
|
329
|
+
.finally(() => this._inTransaction = false);
|
|
290
330
|
}
|
|
291
331
|
/** Sends a `pg_notify` message on `channelName` (payload ≤ 8000 bytes). */
|
|
292
332
|
notify(channelName, payload = "") {
|
|
293
|
-
|
|
294
|
-
return Future.reject(ErrConnectionClosed);
|
|
295
|
-
return this.execute `select pg_notify(${channelName}, ${payload})`.map(() => { });
|
|
333
|
+
return this.execute `select pg_notify(${channelName}, ${payload})`;
|
|
296
334
|
}
|
|
297
335
|
/** Subscribes `callback` to `channelName`, issuing `LISTEN` on first subscription. */
|
|
298
336
|
listen(channelName, callback) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return this.execute `listen ${sql.ident(channelName)};`;
|
|
337
|
+
return this.execute `listen ${sql.ident(channelName)};`
|
|
338
|
+
.tap(() => {
|
|
339
|
+
if (!this._listeningCallbacks.has(channelName)) {
|
|
340
|
+
this._listeningCallbacks.set(channelName, new Set());
|
|
341
|
+
}
|
|
342
|
+
this._listeningCallbacks.get(channelName).add(callback);
|
|
343
|
+
});
|
|
307
344
|
}
|
|
308
345
|
/** Unsubscribes `callback`, issuing `UNLISTEN` once no callbacks remain. */
|
|
309
346
|
unlisten(channelName, callback) {
|
|
310
|
-
if (this.isClosed)
|
|
311
|
-
return Future.reject(ErrConnectionClosed);
|
|
312
347
|
if (!this._listeningCallbacks.has(channelName)) {
|
|
313
348
|
return Ok();
|
|
314
349
|
}
|
|
@@ -316,7 +351,7 @@ export class Connection {
|
|
|
316
351
|
callbackSet.delete(callback);
|
|
317
352
|
if (callbackSet.size === 0) {
|
|
318
353
|
this._listeningCallbacks.delete(channelName);
|
|
319
|
-
return this.execute `unlisten ${sql.ident(channelName)}
|
|
354
|
+
return this.execute `unlisten ${sql.ident(channelName)};`;
|
|
320
355
|
}
|
|
321
356
|
return Ok();
|
|
322
357
|
}
|
package/dist/error.d.ts
CHANGED
|
@@ -31,5 +31,6 @@ export declare const ErrSSLDenied: PostgresError;
|
|
|
31
31
|
export declare const ErrDatabaseNotFound: PostgresError;
|
|
32
32
|
export declare const ErrUntrustedCertificate: PostgresError;
|
|
33
33
|
export declare const ErrCertificateFileNotFound: PostgresError;
|
|
34
|
+
export declare const ErrTransactionInProgress: PostgresError;
|
|
34
35
|
export declare function createBindTypeError(index: number, expectedType: DataTypeOid, actualValue: unknown): PostgresError;
|
|
35
36
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,sBAAsB,CAAA;AAGhE,qBAAa,aAAc,SAAQ,KAAK;IAEhB,OAAO,EAAE,MAAM;IACxB,IAAI,EAAE,MAAM;IACZ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A;AACxF,eAAO,MAAM,uBAAuB,eAA4E,CAAA;AAChH,eAAO,MAAM,0BAA0B,eAAkF,CAAA;AACzH,eAAO,MAAM,wBAAwB,eAGpC,CAAA;AA+BD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,GAAG,aAAa,CAqBjH"}
|
package/dist/error.js
CHANGED
|
@@ -52,6 +52,7 @@ export const ErrSSLDenied = new PostgresError("SSL is required but server denied
|
|
|
52
52
|
export const ErrDatabaseNotFound = new PostgresError('Database with that dsn not found');
|
|
53
53
|
export const ErrUntrustedCertificate = new PostgresError("Database SSL certificate is untrusted or self-signed");
|
|
54
54
|
export const ErrCertificateFileNotFound = new PostgresError("The SSL certificate file specified in caPath was not found");
|
|
55
|
+
export const ErrTransactionInProgress = new PostgresError("This connection has an active transaction — use the Transaction object passed into begin()'s callback instead of the Connection directly", 'transaction_in_progress', '', "ERROR");
|
|
55
56
|
function describeValue(value) {
|
|
56
57
|
if (value === null)
|
|
57
58
|
return 'null';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,35 @@ import { Pool as PgtxPool } from "./pool";
|
|
|
2
2
|
import { IdentifierClause, InsertClause, ArrayClause, UpdateClause, ExcludeUpdateClause, WhereClause, LiteralClause, FragmentClause } from './clauses';
|
|
3
3
|
import { Connection } from "./connection";
|
|
4
4
|
import { Transaction } from "./transaction";
|
|
5
|
+
export type PgPoint = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
export type PgLine = {
|
|
10
|
+
a: number;
|
|
11
|
+
b: number;
|
|
12
|
+
c: number;
|
|
13
|
+
};
|
|
14
|
+
export type PgLineSegment = {
|
|
15
|
+
a: PgPoint;
|
|
16
|
+
b: PgPoint;
|
|
17
|
+
};
|
|
18
|
+
export type PgBox = {
|
|
19
|
+
high: PgPoint;
|
|
20
|
+
low: PgPoint;
|
|
21
|
+
};
|
|
22
|
+
export type PgPath = {
|
|
23
|
+
closed: boolean;
|
|
24
|
+
points: PgPoint[];
|
|
25
|
+
};
|
|
26
|
+
export type PgPolygon = {
|
|
27
|
+
points: PgPoint[];
|
|
28
|
+
};
|
|
29
|
+
export type PgInterval = {
|
|
30
|
+
months: number;
|
|
31
|
+
days: number;
|
|
32
|
+
microseconds: number;
|
|
33
|
+
};
|
|
5
34
|
/**
|
|
6
35
|
* Core SQL tagging utility for Pgtx.
|
|
7
36
|
* Provides type-safe helpers for building dynamic queries with recursive support.
|
|
@@ -16,7 +45,7 @@ export declare const sql: {
|
|
|
16
45
|
* // Result: (name, age) VALUES ($1, $2)
|
|
17
46
|
*
|
|
18
47
|
* @example
|
|
19
|
-
* sql.insert(
|
|
48
|
+
* sql.insert({ id: 1 }, { id: 2 })
|
|
20
49
|
* // Result: (id) VALUES ($1), ($2)
|
|
21
50
|
*/
|
|
22
51
|
insert: typeof InsertClause.create;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEnB,WAAW,EACX,aAAa,EACb,cAAc,EACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEnB,WAAW,EACX,aAAa,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O,EAAE,WAAW,IAAI,WAAW,EAAE,CAAA;AAErC,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,CAAA;AAG3B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
package/dist/pool.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ export declare class Pool {
|
|
|
73
73
|
get size(): number;
|
|
74
74
|
/** Total connections managed (idle + in use). */
|
|
75
75
|
get total(): number;
|
|
76
|
+
get isOpened(): boolean;
|
|
77
|
+
get isClosed(): boolean;
|
|
76
78
|
/**
|
|
77
79
|
* Closes idle connections and rejects pending `acquire()` calls. Not usable afterward.
|
|
78
80
|
*/
|
package/dist/pool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAS,MAAM,EAAM,MAAM,eAAe,CAAC;AAClD,OAAO,EAAiB,aAAa,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAc,iBAAiB,EAAE,GAAG,EAAU,MAAM,SAAS,CAAC;AAIrE;;;;;;;;GAQG;AACH,qBAAa,IAAI;IACb,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAO;gBAEZ,MAAM,EAAE,iBAAiB;IAOrC;;;OAGG;IACH,OAAO;IA2BP;;;;;OAKG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;IAUnD,wFAAwF;IACxF,OAAO,CAAC,IAAI,EAAE,UAAU;IAoBxB;;;;;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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,EAAE,MAAM;IAS1B,UAAU,CAAC,MAAM,EAAE,MAAM;IAUzB,UAAU,CAAC,MAAM,EAAE,MAAM;IAUzB,SAAS,CAAC,IAAI,EAAE,MAAM;IAStB,SAAS,CAAC,IAAI,EAAE,MAAM;IAQtB,aAAa,CAAC,KAAK,EAAE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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
|
@@ -5,9 +5,7 @@ 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
7
|
export interface BindHandler {
|
|
8
|
-
/** Имя типа в PostgreSQL — используется в сообщениях об ошибках. */
|
|
9
8
|
pgType: string;
|
|
10
|
-
/** Ожидаемая JS-форма значения — используется в сообщениях об ошибках. */
|
|
11
9
|
jsShape: string;
|
|
12
10
|
validate: BindValidator;
|
|
13
11
|
write: BindWriter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/protocol/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AAEvD,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;AAChD,KAAK,UAAU,GAAG,CAAC,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;AACxE,KAAK,WAAW,GAAG,CACf,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,KACpB,OAAO,CAAA;AAEZ,MAAM,WAAW,WAAW;IACxB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/protocol/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AAEvD,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAA;AAChD,KAAK,UAAU,GAAG,CAAC,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;AACxE,KAAK,WAAW,GAAG,CACf,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,KACpB,OAAO,CAAA;AAEZ,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,aAAa,CAAA;IACvB,KAAK,EAAE,UAAU,CAAA;IACjB,IAAI,EAAE,WAAW,CAAA;CACpB;AASD,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CA2d9D,CAAA"}
|
package/dist/protocol/types.js
CHANGED
|
@@ -150,13 +150,13 @@ export const handlers = {
|
|
|
150
150
|
},
|
|
151
151
|
[DataTypeOids.Interval]: {
|
|
152
152
|
pgType: 'interval',
|
|
153
|
-
jsShape: '{ months: number, days: number, microseconds: number
|
|
153
|
+
jsShape: '{ months: number, days: number, microseconds: number }',
|
|
154
154
|
validate: (v) => v !== null &&
|
|
155
155
|
typeof v === 'object' &&
|
|
156
156
|
'months' in v && typeof v.months === 'number' &&
|
|
157
157
|
'days' in v && typeof v.days === 'number' &&
|
|
158
158
|
'microseconds' in v &&
|
|
159
|
-
|
|
159
|
+
typeof v.microseconds === 'number',
|
|
160
160
|
write: (req, v) => req.writeBinaryInterval(v),
|
|
161
161
|
read: (res) => res.readBinaryInterval(),
|
|
162
162
|
},
|
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,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