@m2k-5f/pgtx 2.5.4 → 2.6.0

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.
@@ -0,0 +1,14 @@
1
+ import { PostgresError } from "./error";
2
+ import { ConnectionRequestWriter } from "./protocol/connection-request-writer";
3
+ import { PostgresQuery } from "./query";
4
+ export declare class Batch {
5
+ private _queryQueue;
6
+ private _buffer;
7
+ constructor(buffer: ConnectionRequestWriter);
8
+ registerQuery(query: PostgresQuery, timeout: number): void;
9
+ end(): ConnectionRequestWriter;
10
+ get current(): PostgresQuery;
11
+ next(): void;
12
+ reject(cause: PostgresError): void;
13
+ }
14
+ //# sourceMappingURL=batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAc,aAAa,EAAsB,MAAM,SAAS,CAAC;AAGxE,qBAAa,KAAK;IACd,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,OAAO,CAAyB;gBAE5B,MAAM,EAAE,uBAAuB;IAK3C,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM;IAgBnD,GAAG;IAIH,IAAI,OAAO,kBAEV;IAED,IAAI;IAIJ,MAAM,CAAC,KAAK,EAAE,aAAa;CAK9B"}
package/dist/batch.js ADDED
@@ -0,0 +1,35 @@
1
+ import { ParseQuery } from "./query";
2
+ import { Queue } from "./queue";
3
+ export class Batch {
4
+ constructor(buffer) {
5
+ this._queryQueue = new Queue();
6
+ this._buffer = buffer;
7
+ }
8
+ registerQuery(query, timeout) {
9
+ this._queryQueue.push(query);
10
+ query.startTimeout(timeout);
11
+ if (query instanceof ParseQuery) {
12
+ this._buffer
13
+ .writeParse(query.statement, query.text)
14
+ .writeDescribe(query.statement);
15
+ return;
16
+ }
17
+ this._buffer
18
+ .writeBind("", query.statement, query.args)
19
+ .writeExecute("");
20
+ }
21
+ end() {
22
+ return this._buffer.writeSync();
23
+ }
24
+ get current() {
25
+ return this._queryQueue.current;
26
+ }
27
+ next() {
28
+ this._queryQueue.next();
29
+ }
30
+ reject(cause) {
31
+ while (this._queryQueue.hasMore) {
32
+ this._queryQueue.shift.reject(cause);
33
+ }
34
+ }
35
+ }
@@ -1,4 +1,4 @@
1
- import { Branded } from "./types";
1
+ import { Branded, ColumnDescription } from "./types";
2
2
  import { Transaction } from "./transaction";
3
3
  import { Future } from 'fluent-future';
4
4
  import { PostgresError } from "./error";
@@ -18,6 +18,10 @@ export type ConnectionParams = {
18
18
  export type StatementName = Branded<string, 'StatementName'>;
19
19
  export type QueryText = Branded<string, 'QueryText'>;
20
20
  export type ChannelName = Branded<string, "ChannelName">;
21
+ export type QueryMeta = {
22
+ statement: StatementName;
23
+ columns: ColumnDescription[];
24
+ };
21
25
  /**
22
26
  * Represents a single dedicated connection to the PostgreSQL database.
23
27
  *
@@ -50,21 +54,18 @@ export type ChannelName = Branded<string, "ChannelName">;
50
54
  */
51
55
  export declare class Connection {
52
56
  private readonly params;
53
- private _isFlushing;
57
+ private _activeBatch;
54
58
  private _isOpened;
55
59
  private _isReconnecting;
60
+ private _cachedBuffer;
56
61
  private _socket;
57
- private _writer;
58
62
  private _batchQueue;
59
- private _described;
60
- private _describingPending;
61
63
  private _parsed;
62
- private _parsingPending;
64
+ private _parsing;
63
65
  private _listeningCallbacks;
64
66
  private _stmtCounter;
65
67
  private _logLevel;
66
68
  private _nextStatement;
67
- private _checkOpened;
68
69
  private constructor();
69
70
  /**
70
71
  * Creates a new database connection.
@@ -85,6 +86,8 @@ export declare class Connection {
85
86
  * ```
86
87
  */
87
88
  static new(params: ConnectionParams): Future<Connection, PostgresError>;
89
+ private _registerBatch;
90
+ private _sync;
88
91
  /**
89
92
  * Executes a query using tagged template literals.
90
93
  *
@@ -195,17 +198,12 @@ export declare class Connection {
195
198
  */
196
199
  stream<T extends Record<string, any>>(templates: TemplateStringsArray, ...params: any[]): ReadableStream<T>;
197
200
  private _streamWithController;
198
- private _createQuery;
199
- private _createStream;
200
- private _writeQuery;
201
- private _registerFlush;
202
- private _flush;
203
201
  private _registerReconnect;
204
202
  private _resetConnectionState;
205
203
  private _reconnect;
206
204
  private _restoreSubscriptions;
207
205
  private _getCurrentQuery;
208
- private _rejectPipeline;
206
+ private _rejectAllBatches;
209
207
  private _handlePacket;
210
208
  /**
211
209
  * Checks if the connection is still alive and usable.
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAK3C,OAAO,EAAS,MAAM,EAAM,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGvC,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,UAAU,GAAG,WAAW,CAAA;CAC1C,CAAA;AAaD,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAE5D,MAAM,MAAM,SAAS,GAAG,O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
- import { nextTick } from "process";
2
1
  import { ConnectionRequestWriter } from "./protocol/connection-request-writer";
3
2
  import { createAuthorizedSocket } from "./protocol/socket-authorization";
4
3
  import { ResponseTypes } from "./protocol/constants";
5
4
  import { compileSqlTemplate } from "./utils/template-compiler";
6
5
  import { Transaction } from "./transaction";
7
6
  import { SocketConnector } from "./protocol/socket-connector";
8
- import { Queue, RingQueue } from "./queue";
9
- import { Query, QueryState, StreamQuery } from "./query";
7
+ import { Queue } from "./queue";
8
+ import { ParseQuery, SimpleQuery, StreamQuery } from "./query";
10
9
  import { sql } from ".";
11
10
  import { Begin, Future, Ok } from 'fluent-future';
12
- import { PostgresError } from "./error";
13
- const ErrBatchOverflowed = new PostgresError(`BatchOverflowError: Connection queue capacity exceeded.
14
- Please increase the batch capacity parameter in your connection config.`);
15
- const ErrConnectionClosed = new PostgresError("Connection is closed", 'connection_closed', "", "ERROR");
16
- const ErrConnectionReconnecring = new PostgresError("Connection are reconnecting", "connection_reconnecting", "", "ERROR");
11
+ import { ErrConnectionClosed, ErrConnectionReconnecting } from "./error";
12
+ import { Batch } from "./batch";
17
13
  /**
18
14
  * Represents a single dedicated connection to the PostgreSQL database.
19
15
  *
@@ -48,28 +44,19 @@ export class Connection {
48
44
  _nextStatement() {
49
45
  return `s-${this._stmtCounter++}`;
50
46
  }
51
- _checkOpened() {
52
- if (!this.isOpened)
53
- throw ErrConnectionClosed;
54
- }
55
- constructor(socket, writer, logLevel, params) {
56
- this._isFlushing = false;
47
+ constructor(socket, logLevel, params) {
48
+ this._activeBatch = null;
57
49
  this._isOpened = true;
58
50
  this._isReconnecting = false;
51
+ this._cachedBuffer = ConnectionRequestWriter.new();
59
52
  this._batchQueue = new Queue();
60
- this._described = new Map();
61
- this._describingPending = new Set();
62
53
  this._parsed = new Map();
63
- this._parsingPending = new Map();
54
+ this._parsing = new Map();
64
55
  this._listeningCallbacks = new Map();
65
56
  this._stmtCounter = 0;
66
57
  this.params = params;
67
58
  this._logLevel = logLevel;
68
- this._socket = new SocketConnector(socket, (type, _, reader) => this._handlePacket(type, reader), (err) => {
69
- // console.log(err)
70
- this._registerReconnect();
71
- });
72
- this._writer = writer;
59
+ this._socket = new SocketConnector(socket, (type, _, reader) => this._handlePacket(type, reader), () => this._registerReconnect());
73
60
  }
74
61
  /**
75
62
  * Creates a new database connection.
@@ -92,7 +79,39 @@ export class Connection {
92
79
  static new(params) {
93
80
  const writer = ConnectionRequestWriter.new();
94
81
  return createAuthorizedSocket(writer, params)
95
- .andThen(socket => Ok(new Connection(socket, writer, params.logLevel || 'error', params)));
82
+ .andThen(socket => Ok(new Connection(socket, params.logLevel || 'error', params)));
83
+ }
84
+ _registerBatch() {
85
+ if (!this._activeBatch) {
86
+ const batch = new Batch(this._cachedBuffer.clear());
87
+ this._activeBatch = batch;
88
+ setImmediate(() => {
89
+ this._sync(batch);
90
+ });
91
+ return batch;
92
+ }
93
+ return this._activeBatch;
94
+ }
95
+ _sync(batch) {
96
+ if (!this._isOpened) {
97
+ batch.reject(ErrConnectionClosed);
98
+ return;
99
+ }
100
+ if (this._isReconnecting) {
101
+ this._reconnect()
102
+ .then(() => {
103
+ this._activeBatch = null;
104
+ void this._restoreSubscriptions();
105
+ this._socket.write(this._registerBatch().end());
106
+ this._batchQueue.push(this._registerBatch());
107
+ })
108
+ .then(() => {
109
+ this._isReconnecting = false;
110
+ });
111
+ }
112
+ this._socket.write(batch.end());
113
+ this._activeBatch = null;
114
+ this._batchQueue.push(batch);
96
115
  }
97
116
  /**
98
117
  * Executes a query using tagged template literals.
@@ -119,16 +138,32 @@ export class Connection {
119
138
  * ```
120
139
  */
121
140
  query(templates, ...params) {
122
- this._checkOpened();
141
+ if (!this._isOpened)
142
+ return Future.reject(ErrConnectionClosed);
143
+ if (this._isReconnecting)
144
+ return Future.reject(ErrConnectionReconnecting);
123
145
  const { text, args } = compileSqlTemplate(templates, params);
124
146
  if (this._logLevel === 'query') {
125
147
  console.log(`\nQUERY: ${text}\n${args.length !== 0 ? `ARGUMENTS: [${args}]\n` : ""}`);
126
148
  }
127
- const query = this._createQuery(text, args);
128
- if (this._writeQuery(query))
129
- return Future.reject(ErrBatchOverflowed);
130
- query.startTimeout(this.params.queryTimeout || 30000);
131
- return query.future;
149
+ const batch = this._registerBatch();
150
+ if (this._parsed.has(text)) {
151
+ const meta = this._parsed.get(text);
152
+ const query = new SimpleQuery(meta.statement, text, args, meta.columns);
153
+ batch.registerQuery(query, this.params.queryTimeout || 30000);
154
+ return query.future;
155
+ }
156
+ if (!this._parsing.has(text)) {
157
+ const parseQuery = new ParseQuery(this._nextStatement(), text);
158
+ this._parsing.set(text, parseQuery.future);
159
+ batch.registerQuery(parseQuery, this.params.queryTimeout || 30000);
160
+ }
161
+ const future = this._parsing.get(text);
162
+ return future.andThen(meta => {
163
+ const query = new SimpleQuery(meta.statement, text, args, meta.columns);
164
+ this._registerBatch().registerQuery(query, this.params.queryTimeout || 30000);
165
+ return query.future;
166
+ });
132
167
  }
133
168
  /**
134
169
  * Starts a managed transaction on this connection.
@@ -152,7 +187,10 @@ export class Connection {
152
187
  * ```
153
188
  */
154
189
  begin(txCallback) {
155
- this._checkOpened();
190
+ if (!this._isOpened)
191
+ return Future.reject(ErrConnectionClosed);
192
+ if (this._isReconnecting)
193
+ return Future.reject(ErrConnectionReconnecting);
156
194
  const tx = new Transaction(this);
157
195
  return Begin()
158
196
  .andThen(() => tx.query `BEGIN`)
@@ -178,7 +216,10 @@ export class Connection {
178
216
  * ```
179
217
  */
180
218
  notify(channelName, payload = "") {
181
- this._checkOpened();
219
+ if (!this._isOpened)
220
+ return Future.reject(ErrConnectionClosed);
221
+ if (this._isReconnecting)
222
+ return Future.reject(ErrConnectionReconnecting);
182
223
  return this.query `select pg_notify(${channelName}, ${payload})`;
183
224
  }
184
225
  /**
@@ -193,7 +234,10 @@ export class Connection {
193
234
  * ```
194
235
  */
195
236
  listen(channelName, callback) {
196
- this._checkOpened();
237
+ if (!this._isOpened)
238
+ return Future.reject(ErrConnectionClosed);
239
+ if (this._isReconnecting)
240
+ return Future.reject(ErrConnectionReconnecting);
197
241
  if (!this._listeningCallbacks.has(channelName)) {
198
242
  this._listeningCallbacks.set(channelName, new Set());
199
243
  }
@@ -213,7 +257,10 @@ export class Connection {
213
257
  * ```
214
258
  */
215
259
  unlisten(channelName, callback) {
216
- this._checkOpened();
260
+ if (!this._isOpened)
261
+ return Future.reject(ErrConnectionClosed);
262
+ if (this._isReconnecting)
263
+ return Future.reject(ErrConnectionReconnecting);
217
264
  if (!this._listeningCallbacks.has(channelName)) {
218
265
  return Ok();
219
266
  }
@@ -251,7 +298,10 @@ export class Connection {
251
298
  * }
252
299
  */
253
300
  stream(templates, ...params) {
254
- this._checkOpened();
301
+ if (!this._isOpened)
302
+ throw ErrConnectionClosed;
303
+ if (this._isReconnecting)
304
+ throw ErrConnectionReconnecting;
255
305
  const { text, args } = compileSqlTemplate(templates, params);
256
306
  if (this._logLevel === 'query') {
257
307
  console.log(`\nQUERY: ${text}\n${args.length !== 0 ? `ARGUMENTS: [${args}]\n` : ""}`);
@@ -262,150 +312,71 @@ export class Connection {
262
312
  controller = c;
263
313
  }
264
314
  });
265
- const query = this._createStream(text, args, controller);
266
- if (this._writeQuery(query))
267
- throw ErrBatchOverflowed;
268
- query.startTimeout(this.params.queryTimeout || 30000);
315
+ const batch = this._registerBatch();
316
+ if (this._parsed.has(text)) {
317
+ const meta = this._parsed.get(text);
318
+ const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
319
+ batch.registerQuery(query, this.params.queryTimeout || 30000);
320
+ return stream;
321
+ }
322
+ if (!this._parsing.has(text)) {
323
+ const parseQuery = new ParseQuery(this._nextStatement(), text);
324
+ this._parsing.set(text, parseQuery.future);
325
+ batch.registerQuery(parseQuery, this.params.queryTimeout || 30000);
326
+ }
327
+ const future = this._parsing.get(text);
328
+ future
329
+ .tap(meta => {
330
+ const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
331
+ this._registerBatch().registerQuery(query, this.params.queryTimeout || 30000);
332
+ })
333
+ .catch(err => controller.error(err));
269
334
  return stream;
270
335
  }
271
336
  _streamWithController(templates, params, controller) {
272
- this._checkOpened();
337
+ if (!this._isOpened)
338
+ throw ErrConnectionClosed;
339
+ if (this._isReconnecting)
340
+ throw ErrConnectionReconnecting;
273
341
  const { text, args } = compileSqlTemplate(templates, params);
274
342
  if (this._logLevel === 'query') {
275
343
  console.log(`\nQUERY: ${text}\n${args.length !== 0 ? `ARGUMENTS: [${args}]\n` : ""}`);
276
344
  }
277
- const query = this._createStream(text, args, controller);
278
- if (this._writeQuery(query))
279
- throw ErrBatchOverflowed;
280
- query.startTimeout(this.params.queryTimeout || 30000);
281
- return query;
282
- }
283
- _createQuery(text, args) {
345
+ const batch = this._registerBatch();
284
346
  if (this._parsed.has(text)) {
285
- const statementName = this._parsed.get(text);
286
- if (this._described.has(statementName)) {
287
- const columns = this._described.get(statementName);
288
- return new Query(text, args, QueryState.Executing, statementName, columns);
289
- }
290
- else {
291
- if (this._describingPending.has(statementName)) {
292
- return new Query(text, args, QueryState.Executing, statementName);
293
- }
294
- else {
295
- this._describingPending.add(statementName);
296
- return new Query(text, args, QueryState.Describing, statementName);
297
- }
298
- }
347
+ const meta = this._parsed.get(text);
348
+ const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
349
+ batch.registerQuery(query, this.params.queryTimeout || 30000);
299
350
  }
300
- else {
301
- if (this._parsingPending.has(text)) {
302
- const statementName = this._parsingPending.get(text);
303
- return new Query(text, args, QueryState.Describing, statementName);
304
- }
305
- else {
306
- const statementName = this._nextStatement();
307
- this._parsingPending.set(text, statementName);
308
- return new Query(text, args, QueryState.Parsing, statementName);
309
- }
310
- }
311
- }
312
- _createStream(text, args, controller) {
313
- if (this._parsed.has(text)) {
314
- const statementName = this._parsed.get(text);
315
- if (this._described.has(statementName)) {
316
- const columns = this._described.get(statementName);
317
- return new StreamQuery(text, args, QueryState.Executing, statementName, controller, columns);
318
- }
319
- else {
320
- if (this._describingPending.has(statementName)) {
321
- return new StreamQuery(text, args, QueryState.Executing, statementName, controller);
322
- }
323
- else {
324
- this._describingPending.add(statementName);
325
- return new StreamQuery(text, args, QueryState.Describing, statementName, controller);
326
- }
327
- }
328
- }
329
- else {
330
- if (this._parsingPending.has(text)) {
331
- const statementName = this._parsingPending.get(text);
332
- return new StreamQuery(text, args, QueryState.Describing, statementName, controller);
333
- }
334
- else {
335
- const statementName = this._nextStatement();
336
- this._parsingPending.set(text, statementName);
337
- return new StreamQuery(text, args, QueryState.Parsing, statementName, controller);
338
- }
339
- }
340
- }
341
- _writeQuery(query) {
342
- const batch = this._registerFlush();
343
- if (batch.isFull)
344
- return true;
345
- batch.push(query);
346
- if (query.state === QueryState.Parsing) {
347
- this._writer
348
- .writeParse(query.statementName, query.text)
349
- .writeDescribe(query.statementName);
350
- }
351
- if (query.state === QueryState.Describing) {
352
- this._writer
353
- .writeDescribe(query.statementName);
354
- }
355
- this._writer
356
- .writeBind("", query.statementName, query.args)
357
- .writeExecute("");
358
- }
359
- _registerFlush() {
360
- if (!this._isFlushing) {
361
- this._isFlushing = true;
362
- const batch = new RingQueue(this.params.batchCapacity);
363
- this._batchQueue.push(batch);
364
- this.params.flushShedule === 'nextTick'
365
- ? nextTick(() => this._flush())
366
- : setImmediate(() => this._flush());
367
- return batch;
368
- }
369
- return this._batchQueue.last;
370
- }
371
- _flush() {
372
- if (!this._isOpened) {
373
- this._rejectPipeline(ErrConnectionClosed);
374
- return;
375
- }
376
- if (this._isReconnecting) {
377
- this._reconnect().then(() => {
378
- this._socket.write(this._writer.writeSync());
379
- this._writer.clear();
380
- this._isFlushing = false;
381
- });
382
- }
383
- else {
384
- this._socket.write(this._writer.writeSync());
385
- this._writer.clear();
386
- this._isFlushing = false;
351
+ if (!this._parsing.has(text)) {
352
+ const parseQuery = new ParseQuery(this._nextStatement(), text);
353
+ this._parsing.set(text, parseQuery.future);
354
+ batch.registerQuery(parseQuery, this.params.queryTimeout || 30000);
387
355
  }
356
+ const future = this._parsing.get(text);
357
+ future
358
+ .tap(meta => {
359
+ const query = new StreamQuery(meta.statement, text, args, controller, meta.columns);
360
+ this._registerBatch().registerQuery(query, this.params.queryTimeout || 30000);
361
+ })
362
+ .catch(err => controller.error(err));
388
363
  }
389
364
  _registerReconnect() {
365
+ if (this._isReconnecting)
366
+ return;
390
367
  this._isReconnecting = true;
391
- this._rejectPipeline(ErrConnectionReconnecring);
392
368
  }
393
369
  _resetConnectionState(cause) {
394
370
  this._parsed.clear();
395
- this._described.clear();
396
- this._describingPending.clear();
397
- this._parsingPending.clear();
398
- this._writer.clear();
399
- this._rejectPipeline(cause);
371
+ this._parsing.clear();
372
+ this._activeBatch = null;
373
+ this._rejectAllBatches(cause);
400
374
  }
401
375
  async _reconnect() {
402
- console.log('reconnecting');
403
- this._resetConnectionState(ErrConnectionReconnecring);
404
376
  const socket = await createAuthorizedSocket(ConnectionRequestWriter.new(), this.params);
405
377
  const connector = new SocketConnector(socket, (type, _, reader) => this._handlePacket(type, reader), (err) => this._registerReconnect());
406
378
  this._socket = connector;
407
- void this._restoreSubscriptions();
408
- this._isReconnecting = false;
379
+ this._resetConnectionState(ErrConnectionReconnecting);
409
380
  }
410
381
  _restoreSubscriptions() {
411
382
  if (this._listeningCallbacks.size === 0)
@@ -418,12 +389,9 @@ export class Connection {
418
389
  _getCurrentQuery() {
419
390
  return this._batchQueue.current.current;
420
391
  }
421
- _rejectPipeline(error) {
422
- if (this._batchQueue.isFree)
423
- return;
424
- const queue = this._batchQueue.current;
425
- while (queue.hasMore) {
426
- queue.shift.reject(error);
392
+ _rejectAllBatches(cause) {
393
+ while (this._batchQueue.hasMore) {
394
+ this._batchQueue.shift.reject(cause);
427
395
  }
428
396
  }
429
397
  _handlePacket(type, reader) {
@@ -431,10 +399,6 @@ export class Connection {
431
399
  case ResponseTypes.ParseComplete:
432
400
  {
433
401
  reader.readParseComplete();
434
- const query = this._getCurrentQuery();
435
- this._parsingPending.delete(query.text);
436
- this._parsed.set(query.text, query.statementName);
437
- query.state = QueryState.Describing;
438
402
  }
439
403
  break;
440
404
  case ResponseTypes.BindComplete:
@@ -456,46 +420,36 @@ export class Connection {
456
420
  {
457
421
  reader.readNoData();
458
422
  const query = this._getCurrentQuery();
459
- this._describingPending.delete(query.statementName);
460
- this._described.set(query.statementName, []);
461
- query.state = QueryState.Executing;
462
- query.columns = [];
423
+ const meta = { statement: query.statement, columns: [] };
424
+ this._parsing.delete(query.text);
425
+ query.resolve(meta);
426
+ this._parsed.set(query.text, meta);
427
+ this._batchQueue.current.next();
463
428
  }
464
429
  break;
465
430
  case ResponseTypes.RowDescription:
466
431
  {
467
432
  const columns = reader.readRowDescription();
468
433
  const query = this._getCurrentQuery();
469
- this._describingPending.delete(query.statementName);
470
- this._described.set(query.statementName, columns);
471
- query.state = QueryState.Executing;
472
- query.columns = columns;
434
+ const meta = { statement: query.statement, columns };
435
+ this._parsing.delete(query.text);
436
+ query.resolve(meta);
437
+ this._parsed.set(query.text, meta);
438
+ this._batchQueue.current.next();
473
439
  }
474
440
  break;
475
441
  case ResponseTypes.DataRow:
476
442
  {
477
443
  let query = this._getCurrentQuery();
478
- if (!query.columns) {
479
- query.columns = this._described.get(query.statementName);
480
- }
481
444
  query.push(reader.readDataRow(query.columns, this.params.int8toBigint));
482
445
  }
483
446
  break;
484
447
  case ResponseTypes.ComandComplete:
485
448
  {
486
449
  reader.readCommandComplete();
487
- if (this._batchQueue.isFree) {
488
- this.close();
489
- break;
490
- }
491
450
  const query = this._getCurrentQuery();
492
- if (!query) {
493
- this.close();
494
- break;
495
- }
496
- query.state = QueryState.Completed;
497
- this._batchQueue.current.next();
498
451
  query.resolve();
452
+ this._batchQueue.current.next();
499
453
  }
500
454
  break;
501
455
  case ResponseTypes.ErrorResponse:
@@ -505,16 +459,8 @@ export class Connection {
505
459
  console.log(`\nError: ${error}\n`);
506
460
  }
507
461
  const query = this._getCurrentQuery();
508
- switch (query.state) {
509
- case QueryState.Parsing:
510
- this._parsingPending.delete(query.text);
511
- break;
512
- case QueryState.Describing:
513
- this._describingPending.delete(query.statementName);
514
- break;
515
- }
516
- query.state = QueryState.Failed;
517
- this._rejectPipeline(error);
462
+ this._parsing.delete(query.text);
463
+ this._batchQueue.current.reject(error);
518
464
  }
519
465
  break;
520
466
  case ResponseTypes.ReadyForQuery:
@@ -540,7 +486,7 @@ export class Connection {
540
486
  callbackSet.forEach(cb => cb(payload));
541
487
  }
542
488
  break;
543
- default: console.warn('Undeclared response type: ', type);
489
+ default: console.log('Undeclared response type: ', type);
544
490
  }
545
491
  }
546
492
  /**
@@ -563,9 +509,6 @@ export class Connection {
563
509
  close() {
564
510
  this._isOpened = false;
565
511
  this._socket.destroy();
566
- while (this._batchQueue.hasMore) {
567
- this._rejectPipeline(ErrConnectionClosed);
568
- this._batchQueue.next();
569
- }
512
+ this._rejectAllBatches(ErrConnectionClosed);
570
513
  }
571
514
  }
package/dist/error.d.ts CHANGED
@@ -15,4 +15,7 @@ export declare class PostgresError extends Error {
15
15
  get isTimeout(): boolean;
16
16
  get isConnectionFailure(): boolean;
17
17
  }
18
+ export declare const ErrQueryTimeout: PostgresError;
19
+ export declare const ErrConnectionClosed: PostgresError;
20
+ export declare const ErrConnectionReconnecting: PostgresError;
18
21
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IAEhB,OAAO,EAAE,MAAM;IACxB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;gBART,OAAO,EAAE,MAAM,EACxB,IAAI,GAAE,MAAqB,EAC3B,MAAM,GAAE,MAAW,EACnB,QAAQ,GAAE,MAAW,EACrB,KAAK,GAAE,MAAW,EAClB,IAAI,GAAE,MAAW,EACjB,QAAQ,GAAE,MAAW,EACrB,QAAQ,GAAE,MAAW,EACrB,UAAU,GAAE,MAAW;IAQlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAID,IAAI,UAAU,IAAI,OAAO,CAExB;IAID,IAAI,qBAAqB,IAAI,OAAO,CAEnC;IAGD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGD,IAAI,mBAAmB,IAAI,OAAO,CAEjC;CACJ"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IAEhB,OAAO,EAAE,MAAM;IACxB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,MAAM;gBART,OAAO,EAAE,MAAM,EACxB,IAAI,GAAE,MAAqB,EAC3B,MAAM,GAAE,MAAW,EACnB,QAAQ,GAAE,MAAW,EACrB,KAAK,GAAE,MAAW,EAClB,IAAI,GAAE,MAAW,EACjB,QAAQ,GAAE,MAAW,EACrB,QAAQ,GAAE,MAAW,EACrB,UAAU,GAAE,MAAW;IAQlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAID,IAAI,UAAU,IAAI,OAAO,CAExB;IAID,IAAI,qBAAqB,IAAI,OAAO,CAEnC;IAGD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGD,IAAI,mBAAmB,IAAI,OAAO,CAEjC;CACJ;AAED,eAAO,MAAM,eAAe,eAA8C,CAAA;AAE1E,eAAO,MAAM,mBAAmB,eAA8E,CAAA;AAC9G,eAAO,MAAM,yBAAyB,eAA2F,CAAA"}
package/dist/error.js CHANGED
@@ -31,3 +31,6 @@ export class PostgresError extends Error {
31
31
  return this.code.startsWith('08') || this.code.startsWith('57') && this.code !== '57014';
32
32
  }
33
33
  }
34
+ export const ErrQueryTimeout = new PostgresError('Query timeout', '57014');
35
+ export const ErrConnectionClosed = new PostgresError("Connection is closed", 'connection_closed', "", "ERROR");
36
+ export const ErrConnectionReconnecting = new PostgresError("Connection are reconnecting", "connection_reconnecting", "", "ERROR");
@@ -1 +1 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,EAAS,MAAM,EAAM,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,KAAK,UAAU,GAAG,gBAAgB,GAAG;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,IAAI;IACb,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAQ;IAEzB,OAAO,CAAC,YAAY;gBAIR,MAAM,EAAE,UAAU;IAM9B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO;IA2BP;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;IAUnD;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,IAAI,EAAE,UAAU;IAiBxB;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,WAAW,EAAE,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,IAAI,IAAI,WAEP;IAGD;;;OAGG;IACH,IAAI,KAAK,WAER;IAGD;;;;;;;;;;OAUG;IACH,KAAK;CAWR"}
package/dist/pool.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Connection } from "./connection";
2
- import { Queue } from "./queue";
2
+ import { Queue, RingQueue } from "./queue";
3
3
  import { Begin, Future, Ok } from "fluent-future";
4
4
  import { PostgresError } from "./error";
5
5
  const ErrPoolClosed = new PostgresError('Pool closed');
@@ -44,12 +44,12 @@ export class Pool {
44
44
  throw new Error('Pool closed');
45
45
  }
46
46
  constructor(params) {
47
- this._available = new Queue();
48
47
  this._total = 0;
49
48
  this._waiting = new Queue();
50
49
  this._isClosed = false;
51
50
  this._config = params;
52
51
  this._max = params.max || 20;
52
+ this._available = new RingQueue(this._max);
53
53
  }
54
54
  /**
55
55
  * Acquires a dedicated connection from the pool.
@@ -1 +1 @@
1
- {"version":3,"file":"connection-request-writer.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-request-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAA;AAGvD,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,wBAAwB;IAHpC,OAAO;IAOP,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM;IAK3B,OAAO,CAAC,cAAc;IAmBtB,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,YAAY,CAAC,WAAW,EAAE,WAAW;IAQrC,YAAY;IAMZ,UAAU;IAUV,QAAQ;IAKR,KAAK;CAIR;AAGD,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,MAAM;IADlB,OAAO;IAIP,MAAM,CAAC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;IAKR,KAAK;CAIR;AAGD,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,MAAM;IADlB,OAAO;IAIP,MAAM,CAAC,GAAG;IAMV,UAAU,CAAC,IAAI,EAAE,MAAM;IASvB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM;IAW1C,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,EAAE;IAUxC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IAmBtF,UAAU,CAAC,IAAI,EAAE,MAAM;IAUvB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAY3C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE;IAUlC,SAAS;IAOT,aAAa,CAAC,QAAQ,EAAE,MAAM;IAS9B,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM;IAW9D,iBAAiB,CAAC,kBAAkB,EAAE,MAAM;IAS5C,QAAQ;IAKR,KAAK;CAKR"}
@@ -61,6 +61,7 @@ export class ConnectionRequestBuffer {
61
61
  return this.writeInt32(0);
62
62
  }
63
63
  endRequest() {
64
+ this.ensureCapacity(4);
64
65
  this.buffer.writeInt32BE(this.offset - (this.lastRequestLenByteOffset), this.lastRequestLenByteOffset);
65
66
  return this;
66
67
  }
package/dist/query.d.ts CHANGED
@@ -1,46 +1,53 @@
1
1
  import { Future } from "fluent-future";
2
- import { QueryText, StatementName } from "./connection";
2
+ import { QueryMeta, QueryText, StatementName } from "./connection";
3
3
  import { ColumnDescription, ValueOF } from "./types";
4
4
  import { PostgresError } from "./error";
5
5
  export declare const QueryState: {
6
6
  readonly Parsing: 0;
7
- readonly Describing: 1;
8
- readonly Executing: 2;
9
- readonly Completed: 3;
10
- readonly Failed: 4;
7
+ readonly Executing: 1;
8
+ readonly Completed: 2;
9
+ readonly Failed: 3;
11
10
  };
12
11
  export type State = ValueOF<typeof QueryState>;
13
- export declare class Query<T> {
12
+ export declare abstract class Query {
13
+ statement: StatementName;
14
+ protected _timer?: NodeJS.Timeout;
15
+ constructor(statement: StatementName);
16
+ startTimeout(timeout: number): void;
17
+ abstract reject(cause: PostgresError): void;
18
+ abstract resolve(...args: any[]): void;
19
+ }
20
+ export declare class SimpleQuery<T> extends Query {
14
21
  text: QueryText;
15
22
  args: (string | null)[];
16
- state: State;
17
- statementName: StatementName;
18
- columns?: ColumnDescription[] | undefined;
23
+ columns: ColumnDescription[];
19
24
  future: Future<T[], PostgresError>;
20
25
  private _resolve;
21
26
  private _reject;
22
27
  private _rows;
23
- private _timer?;
24
- constructor(text: QueryText, args: (string | null)[], state: State, statementName: StatementName, columns?: ColumnDescription[] | undefined);
25
- startTimeout(timeout: number): void;
26
- setState(state: State): void;
28
+ constructor(statement: StatementName, text: QueryText, args: (string | null)[], columns: ColumnDescription[]);
27
29
  push(value: T): void;
28
30
  reject(cause: PostgresError): void;
29
31
  resolve(): void;
30
32
  }
31
- export declare class StreamQuery<T> {
33
+ export declare class ParseQuery extends Query {
34
+ text: QueryText;
35
+ future: Future<QueryMeta, PostgresError>;
36
+ private _resolve;
37
+ private _reject;
38
+ constructor(statement: StatementName, text: QueryText);
39
+ reject(cause: PostgresError): void;
40
+ resolve(meta: QueryMeta): void;
41
+ }
42
+ export declare class StreamQuery<T> extends Query {
32
43
  text: QueryText;
33
44
  args: (string | null)[];
34
- state: State;
35
- statementName: StatementName;
36
- private _controller;
37
- columns?: ColumnDescription[] | undefined;
38
- private _timer?;
39
- constructor(text: QueryText, args: (string | null)[], state: State, statementName: StatementName, _controller: ReadableStreamDefaultController<T>, columns?: ColumnDescription[] | undefined);
40
- setState(state: State): void;
41
- startTimeout(timeout: number): void;
45
+ controller: ReadableStreamDefaultController<T>;
46
+ columns: ColumnDescription[];
47
+ constructor(statement: StatementName, text: QueryText, args: (string | null)[], controller: ReadableStreamDefaultController<T>, columns: ColumnDescription[]);
42
48
  push(value: T): void;
43
49
  reject(cause: PostgresError): void;
44
50
  resolve(): void;
45
51
  }
52
+ export type PostgresQuery = SimpleQuery<any> | ParseQuery | StreamQuery<any>;
46
53
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC,eAAO,MAAM,UAAU;;;;;;CAMb,CAAA;AAGV,MAAM,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,UAAU,CAAC,CAAA;AAG9C,qBAAa,KAAK,CAAC,CAAC;IASL,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IACvB,KAAK,EAAE,KAAK;IACZ,aAAa,EAAE,aAAa;IAC5B,OAAO,CAAC,EAAE,iBAAiB,EAAE;IAZxC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;IAClC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,KAAK,CAAU;IAEvB,OAAO,CAAC,MAAM,CAAC,CAAgB;gBAGpB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,iBAAiB,EAAE,YAAA;IAQxC,YAAY,CAAC,OAAO,EAAE,MAAM;IAO5B,QAAQ,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CAAC,EAAE;IACvB,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC;IAC9C,OAAO,EAAE,iBAAiB,EAAE;gBAJnC,SAAS,EAAE,aAAa,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,EACvB,UAAU,EAAE,+BAA+B,CAAC,CAAC,CAAC,EAC9C,OAAO,EAAE,iBAAiB,EAAE;IAMvC,IAAI,CAAC,KAAK,EAAE,CAAC;IAKb,MAAM,CAAC,KAAK,EAAE,aAAa;IAM3B,OAAO;CAIV;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAA"}
package/dist/query.js CHANGED
@@ -1,18 +1,26 @@
1
1
  import { Future } from "fluent-future";
2
- import { PostgresError } from "./error";
2
+ import { ErrQueryTimeout } from "./error";
3
3
  export const QueryState = {
4
4
  Parsing: 0,
5
- Describing: 1,
6
- Executing: 2,
7
- Completed: 3,
8
- Failed: 4
5
+ Executing: 1,
6
+ Completed: 2,
7
+ Failed: 3
9
8
  };
10
9
  export class Query {
11
- constructor(text, args, state, statementName, columns) {
10
+ constructor(statement) {
11
+ this.statement = statement;
12
+ }
13
+ startTimeout(timeout) {
14
+ this._timer = setTimeout(() => {
15
+ this.reject(ErrQueryTimeout);
16
+ }, timeout);
17
+ }
18
+ }
19
+ export class SimpleQuery extends Query {
20
+ constructor(statement, text, args, columns) {
21
+ super(statement);
12
22
  this.text = text;
13
23
  this.args = args;
14
- this.state = state;
15
- this.statementName = statementName;
16
24
  this.columns = columns;
17
25
  this._rows = [];
18
26
  const { future, reject, resolve } = Future.withResolvers();
@@ -20,14 +28,6 @@ export class Query {
20
28
  this._resolve = resolve;
21
29
  this._reject = reject;
22
30
  }
23
- startTimeout(timeout) {
24
- this._timer = setTimeout(() => {
25
- this.reject(new PostgresError('Query timeout', '57014'));
26
- }, timeout);
27
- }
28
- setState(state) {
29
- this.state = state;
30
- }
31
31
  push(value) {
32
32
  this._rows.push(value);
33
33
  }
@@ -40,32 +40,41 @@ export class Query {
40
40
  this._resolve(this._rows);
41
41
  }
42
42
  }
43
- export class StreamQuery {
44
- constructor(text, args, state, statementName, _controller, columns) {
43
+ export class ParseQuery extends Query {
44
+ constructor(statement, text) {
45
+ super(statement);
45
46
  this.text = text;
46
- this.args = args;
47
- this.state = state;
48
- this.statementName = statementName;
49
- this._controller = _controller;
50
- this.columns = columns;
47
+ const { future, reject, resolve } = Future.withResolvers();
48
+ this.future = future;
49
+ this._resolve = resolve;
50
+ this._reject = reject;
51
51
  }
52
- setState(state) {
53
- this.state = state;
52
+ reject(cause) {
53
+ clearTimeout(this._timer);
54
+ this._reject(cause);
54
55
  }
55
- startTimeout(timeout) {
56
- this._timer = setTimeout(() => {
57
- this.reject(new PostgresError('Query timeout', '57014'));
58
- }, timeout);
56
+ resolve(meta) {
57
+ clearTimeout(this._timer);
58
+ this._resolve(meta);
59
+ }
60
+ }
61
+ export class StreamQuery extends Query {
62
+ constructor(statement, text, args, controller, columns) {
63
+ super(statement);
64
+ this.text = text;
65
+ this.args = args;
66
+ this.controller = controller;
67
+ this.columns = columns;
59
68
  }
60
69
  push(value) {
61
- this._controller.enqueue(value);
70
+ this.controller.enqueue(value);
62
71
  }
63
72
  reject(cause) {
64
73
  clearTimeout(this._timer);
65
- this._controller.error(cause);
74
+ this.controller.error(cause);
66
75
  }
67
76
  resolve() {
68
77
  clearTimeout(this._timer);
69
- this._controller.close();
78
+ this.controller.close();
70
79
  }
71
80
  }
@@ -17,11 +17,11 @@ export declare class Transaction {
17
17
  /**
18
18
  * Commits the current transaction.
19
19
  */
20
- commit(): Future<Record<string, any>[], any>;
20
+ commit(): Future<Record<string, any>[], PostgresError>;
21
21
  /**
22
22
  * Rolls back the current transaction.
23
23
  */
24
- rollback(): Future<Record<string, any>[], any>;
24
+ rollback(): Future<Record<string, any>[], PostgresError>;
25
25
  /**
26
26
  * Executes a query within the current transaction.
27
27
  */
@@ -36,6 +36,6 @@ export declare class Transaction {
36
36
  * if (error) throw new Error() // Only this insert rolls back
37
37
  * });
38
38
  */
39
- savepoint<T>(name: string, callback: (tx: Transaction) => Promise<T>): Future<T, Error>;
39
+ savepoint<T>(name: string, callback: (tx: Transaction) => Promise<T>): Future<T, unknown>;
40
40
  }
41
41
  //# sourceMappingURL=transaction.d.ts.map
@@ -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,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC;;;GAGG;AACH,qBAAa,WAAW;IAIhB,QAAQ,CAAC,IAAI,EAAE,UAAU;IAH7B,OAAO,CAAC,UAAU,CAAiB;gBAGtB,IAAI,EAAE,UAAU;IAG7B;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACI,MAAM;IAOb;;OAEG;IACI,QAAQ;IAOf;;OAEG;IACI,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAK3F;;;;;;;;;OASG;IACI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC;CAWjG"}
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,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC;;;GAGG;AACH,qBAAa,WAAW;IAIhB,QAAQ,CAAC,IAAI,EAAE,UAAU;IAH7B,OAAO,CAAC,UAAU,CAAiB;gBAGtB,IAAI,EAAE,UAAU;IAG7B;;OAEG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACI,MAAM;IAOb;;OAEG;IACI,QAAQ;IAOf;;OAEG;IACI,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE;IAK3F;;;;;;;;;OASG;IACI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC;CAW9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"template-compiler.d.ts","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,gBAAgB,EAAoB,MAAM,UAAU,CAAA;AAInF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,SAAS,SAAI,GAAG,gBAAgB,CAoCpH"}
1
+ {"version":3,"file":"template-compiler.d.ts","sourceRoot":"","sources":["../../src/utils/template-compiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAIjE,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,SAAS,SAAI,GAAG,gBAAgB,CAqCpH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m2k-5f/pgtx",
3
- "version": "2.5.4",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "description": "Blazing-fast PostgreSQL driver with pipeline support.",
6
6
  "files": [
@@ -52,6 +52,6 @@
52
52
  "typescript": "^5.9.3"
53
53
  },
54
54
  "dependencies": {
55
- "fluent-future": "^1.4.1"
55
+ "fluent-future": "^1.5.0"
56
56
  }
57
57
  }