@contember/database 1.1.0-rc.0 → 1.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/client/Connection.d.ts +11 -17
- package/dist/src/client/Connection.d.ts.map +1 -1
- package/dist/src/client/Connection.js +21 -20
- package/dist/src/client/Connection.js.map +1 -1
- package/dist/src/client/Pool.d.ts +124 -0
- package/dist/src/client/Pool.d.ts.map +1 -0
- package/dist/src/client/Pool.js +368 -0
- package/dist/src/client/Pool.js.map +1 -0
- package/dist/src/client/SingleConnection.d.ts +3 -2
- package/dist/src/client/SingleConnection.d.ts.map +1 -1
- package/dist/src/client/SingleConnection.js +16 -10
- package/dist/src/client/SingleConnection.js.map +1 -1
- package/dist/src/client/errors.d.ts +1 -1
- package/dist/src/client/errors.d.ts.map +1 -1
- package/dist/src/client/errors.js +7 -5
- package/dist/src/client/errors.js.map +1 -1
- package/dist/src/client/execution.d.ts +0 -1
- package/dist/src/client/execution.d.ts.map +1 -1
- package/dist/src/client/execution.js +1 -10
- package/dist/src/client/execution.js.map +1 -1
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/client/index.d.ts.map +1 -1
- package/dist/src/client/index.js +1 -0
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/types.d.ts +4 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/createDatabaseIfNotExists.d.ts +2 -2
- package/dist/src/utils/createDatabaseIfNotExists.d.ts.map +1 -1
- package/dist/src/utils/createDatabaseIfNotExists.js +2 -2
- package/dist/src/utils/createDatabaseIfNotExists.js.map +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/pgClientFactory.d.ts +5 -0
- package/dist/src/utils/pgClientFactory.d.ts.map +1 -0
- package/dist/src/utils/pgClientFactory.js +12 -0
- package/dist/src/utils/pgClientFactory.js.map +1 -0
- package/dist/tests/cases/unit/pool.test.d.ts +2 -0
- package/dist/tests/cases/unit/pool.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/pool.test.js +323 -0
- package/dist/tests/cases/unit/pool.test.js.map +1 -0
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/client/Connection.ts +29 -31
- package/src/client/Pool.ts +455 -0
- package/src/client/SingleConnection.ts +18 -11
- package/src/client/errors.ts +10 -6
- package/src/client/execution.ts +0 -9
- package/src/client/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/types.ts +4 -1
- package/src/utils/createDatabaseIfNotExists.ts +5 -5
- package/src/utils/index.ts +1 -0
- package/src/utils/pgClientFactory.ts +10 -0
- package/tests/cases/unit/pool.test.ts +350 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PoolClosedError = exports.AcquireTimeoutError = exports.PoolError = exports.Pool = exports.poolStatsDescription = void 0;
|
|
7
|
+
const exceptions_1 = require("../exceptions");
|
|
8
|
+
const errorCodes_1 = require("./errorCodes");
|
|
9
|
+
const events_1 = __importDefault(require("events"));
|
|
10
|
+
const errors_1 = require("./errors");
|
|
11
|
+
exports.poolStatsDescription = {
|
|
12
|
+
connection_established_count: 'Total number of established connections.',
|
|
13
|
+
connection_recoverable_error_count: 'Number of connections that failed on recoverable error (e.g. 53300) and retry was tried.',
|
|
14
|
+
connection_error_count: 'Number of non-recoverable errors or recoverable errors reaching max attempts.',
|
|
15
|
+
connection_disposed_idle_timeout_count: 'Number of idle connection, that was disposed after configured timeout.',
|
|
16
|
+
connection_disposed_idle_max_count: 'Number of idle connections, that was immediately disposed, because maximum number of idle connection was reached.',
|
|
17
|
+
connection_disposed_old_count: 'Number of connections, that was too old after it was released.',
|
|
18
|
+
connection_disposed_manual_count: 'Number of manually disposed connection (e.g. due to exception on given connection).',
|
|
19
|
+
connection_released_count: 'Number of connection returned to the pool.',
|
|
20
|
+
connection_reused_immediately_count: 'Number of connections, that was reused by pending item immediately after it was returned to the pool.',
|
|
21
|
+
connection_reused_later_count: 'Number of idle connections, that was reused later.',
|
|
22
|
+
connection_established_idle_count: 'Number of newly established connections, which was not used (e.g. some connection was returned earlier).',
|
|
23
|
+
item_queued_count: 'Number of queued items requesting a connection.',
|
|
24
|
+
item_timeout_count: 'Number of items waiting for connection, which timed out.',
|
|
25
|
+
item_resolved_new_ms_count: 'Number of queued items resolved with newly established connection.',
|
|
26
|
+
item_resolved_new_ms_sum: 'Waiting time of queued items, which was resolved with a new connection.',
|
|
27
|
+
item_resolved_released_ms_count: 'Number of queued items resolved with released connection.',
|
|
28
|
+
item_resolved_released_ms_sum: 'Waiting time of queued items, which was resolved with a released connection.',
|
|
29
|
+
};
|
|
30
|
+
class PoolConnection {
|
|
31
|
+
constructor(client) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
this.disposed = false;
|
|
34
|
+
this.uses = 0;
|
|
35
|
+
this.createdAt = Date.now();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class PendingItem {
|
|
39
|
+
constructor(resolve, reject) {
|
|
40
|
+
this.resolve = resolve;
|
|
41
|
+
this.reject = reject;
|
|
42
|
+
this.createdAt = Date.now();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class Pool extends events_1.default {
|
|
46
|
+
constructor(clientFactory, poolConfig) {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
super();
|
|
49
|
+
this.clientFactory = clientFactory;
|
|
50
|
+
/**
|
|
51
|
+
* pool was closed by calling end().
|
|
52
|
+
* All connection was disposed and it is not possible to acquire new one
|
|
53
|
+
*/
|
|
54
|
+
this.ended = false;
|
|
55
|
+
/**
|
|
56
|
+
* current count of connection attempts
|
|
57
|
+
* also includes timeout between recoverable retries
|
|
58
|
+
*/
|
|
59
|
+
this.connectingCount = 0;
|
|
60
|
+
/**
|
|
61
|
+
* available idle connections
|
|
62
|
+
*/
|
|
63
|
+
this.idle = [];
|
|
64
|
+
/**
|
|
65
|
+
* currently acquired connections
|
|
66
|
+
*/
|
|
67
|
+
this.active = new Set();
|
|
68
|
+
/**
|
|
69
|
+
* items waiting for released or newly established connection
|
|
70
|
+
*/
|
|
71
|
+
this.queue = [];
|
|
72
|
+
this.poolStats = {
|
|
73
|
+
connection_established_count: 0,
|
|
74
|
+
connection_recoverable_error_count: 0,
|
|
75
|
+
connection_error_count: 0,
|
|
76
|
+
connection_disposed_idle_timeout_count: 0,
|
|
77
|
+
connection_disposed_idle_max_count: 0,
|
|
78
|
+
connection_disposed_old_count: 0,
|
|
79
|
+
connection_disposed_manual_count: 0,
|
|
80
|
+
connection_released_count: 0,
|
|
81
|
+
connection_reused_immediately_count: 0,
|
|
82
|
+
connection_reused_later_count: 0,
|
|
83
|
+
connection_established_idle_count: 0,
|
|
84
|
+
item_queued_count: 0,
|
|
85
|
+
item_timeout_count: 0,
|
|
86
|
+
item_resolved_new_ms_count: 0,
|
|
87
|
+
item_resolved_new_ms_sum: 0,
|
|
88
|
+
item_resolved_released_ms_count: 0,
|
|
89
|
+
item_resolved_released_ms_sum: 0,
|
|
90
|
+
};
|
|
91
|
+
this.poolConfig = {
|
|
92
|
+
maxConnections: 10,
|
|
93
|
+
maxConnecting: Math.ceil(((_a = poolConfig.maxConnections) !== null && _a !== void 0 ? _a : 10) / 2),
|
|
94
|
+
maxIdle: Math.ceil(((_b = poolConfig.maxConnections) !== null && _b !== void 0 ? _b : 10) / 2),
|
|
95
|
+
idleTimeoutMs: 10000,
|
|
96
|
+
acquireTimeoutMs: 10000,
|
|
97
|
+
reconnectIntervalMs: 100,
|
|
98
|
+
...poolConfig,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
acquire() {
|
|
102
|
+
if (this.ended) {
|
|
103
|
+
throw new PoolClosedError();
|
|
104
|
+
}
|
|
105
|
+
const poolConnection = this.idle.pop();
|
|
106
|
+
if (poolConnection !== undefined) {
|
|
107
|
+
if (poolConnection.timerId) {
|
|
108
|
+
clearTimeout(poolConnection.timerId);
|
|
109
|
+
}
|
|
110
|
+
poolConnection.uses++;
|
|
111
|
+
this.active.add(poolConnection);
|
|
112
|
+
this.poolStats.connection_reused_later_count++;
|
|
113
|
+
this.log('Item fulfilled with an idle connection.');
|
|
114
|
+
return Promise.resolve(poolConnection);
|
|
115
|
+
}
|
|
116
|
+
const pendingItem = this.createPendingItem();
|
|
117
|
+
this.maybeCreateNew();
|
|
118
|
+
return pendingItem;
|
|
119
|
+
}
|
|
120
|
+
release(poolConnection) {
|
|
121
|
+
if (this.ended) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.log('Releasing a connection.');
|
|
125
|
+
if (!this.active.delete(poolConnection)) {
|
|
126
|
+
throw new exceptions_1.ImplementationException('Connection does not belong to this pool.');
|
|
127
|
+
}
|
|
128
|
+
if ((this.poolConfig.maxUses && poolConnection.uses >= this.poolConfig.maxUses)
|
|
129
|
+
|| (this.poolConfig.maxAgeMs && poolConnection.createdAt + this.poolConfig.maxAgeMs < Date.now())) {
|
|
130
|
+
setImmediate(async () => {
|
|
131
|
+
await this.disposeConnection(poolConnection);
|
|
132
|
+
this.poolStats.connection_disposed_old_count++;
|
|
133
|
+
this.log('Connection has reached max age or usage and was disposed.');
|
|
134
|
+
});
|
|
135
|
+
this.maybeCreateNew();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this.handleAvailableConnection(poolConnection);
|
|
139
|
+
}
|
|
140
|
+
dispose(poolConnection) {
|
|
141
|
+
if (this.ended) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.poolStats.connection_disposed_manual_count++;
|
|
145
|
+
this.log('Releasing and disposing a connection.');
|
|
146
|
+
if (!this.active.delete(poolConnection)) {
|
|
147
|
+
throw new exceptions_1.ImplementationException('Connection does not belong to this pool.');
|
|
148
|
+
}
|
|
149
|
+
setImmediate(async () => {
|
|
150
|
+
await this.disposeConnection(poolConnection);
|
|
151
|
+
this.log('Connection errored and was disposed.');
|
|
152
|
+
});
|
|
153
|
+
this.maybeCreateNew();
|
|
154
|
+
}
|
|
155
|
+
async end() {
|
|
156
|
+
this.ended = true;
|
|
157
|
+
this.queue.forEach(it => it.reject(new PoolClosedError()));
|
|
158
|
+
this.queue = [];
|
|
159
|
+
const allConnections = [...this.idle, ...Array.from(this.active)];
|
|
160
|
+
await Promise.allSettled(allConnections.map(it => this.disposeConnection(it)));
|
|
161
|
+
this.idle = [];
|
|
162
|
+
this.active.clear();
|
|
163
|
+
}
|
|
164
|
+
async closeIdle() {
|
|
165
|
+
this.log('Disposing all idle connection on request.');
|
|
166
|
+
const idle = this.idle;
|
|
167
|
+
this.idle = [];
|
|
168
|
+
await Promise.allSettled(idle.map(it => this.disposeConnection(it)));
|
|
169
|
+
}
|
|
170
|
+
getPoolStatus() {
|
|
171
|
+
return {
|
|
172
|
+
max: this.poolConfig.maxConnections,
|
|
173
|
+
active: this.active.size,
|
|
174
|
+
idle: this.idle.length,
|
|
175
|
+
pending: this.queue.length,
|
|
176
|
+
connecting: this.connectingCount,
|
|
177
|
+
stats: this.poolStats,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async maybeCreateNew(attempt = 1) {
|
|
181
|
+
if (this.ended) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (this.queue.length === 0) {
|
|
185
|
+
this.log('Not connecting, queue is empty.');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const connectingCount = this.connectingCount;
|
|
189
|
+
if (connectingCount >= this.queue.length) {
|
|
190
|
+
this.log('Not connecting, already establishing connection for all queued items.');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const idleCount = this.idle.length;
|
|
194
|
+
if ((this.active.size + idleCount + connectingCount) >= this.poolConfig.maxConnections) {
|
|
195
|
+
this.log('Not connecting, max connections reached.');
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (connectingCount >= this.poolConfig.maxConnecting) {
|
|
199
|
+
this.log('Not connecting, maximum concurrent connection attempts in progress.');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
this.log('Creating a new connection');
|
|
203
|
+
const client = this.clientFactory();
|
|
204
|
+
this.connectingCount++;
|
|
205
|
+
const poolConnection = new PoolConnection(client);
|
|
206
|
+
client.on('error', e => {
|
|
207
|
+
this.log('Client error on idle connection has occurred: ' + e.message);
|
|
208
|
+
this.emit('error', e);
|
|
209
|
+
});
|
|
210
|
+
try {
|
|
211
|
+
await client.connect();
|
|
212
|
+
this.poolStats.connection_established_count++;
|
|
213
|
+
this.log('Connection established');
|
|
214
|
+
this.connectingCount--;
|
|
215
|
+
if (this.ended) {
|
|
216
|
+
await this.disposeConnection(poolConnection);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
this.log('Connection error occurred: ' + e.message);
|
|
222
|
+
try {
|
|
223
|
+
await client.end();
|
|
224
|
+
}
|
|
225
|
+
catch (_a) {
|
|
226
|
+
}
|
|
227
|
+
if (e.code === errorCodes_1.ClientErrorCodes.TOO_MANY_CONNECTIONS || e.code === errorCodes_1.ClientErrorCodes.CANNOT_CONNECT_NOW) {
|
|
228
|
+
this.lastRecoverableError = { error: e, time: Date.now() };
|
|
229
|
+
if (this.poolConfig.reconnectIntervalMs * attempt >= this.poolConfig.acquireTimeoutMs) {
|
|
230
|
+
this.poolStats.connection_error_count++;
|
|
231
|
+
this.log('Recoverable error, max retries reached.');
|
|
232
|
+
this.emit('e', e);
|
|
233
|
+
this.connectingCount--;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
this.poolStats.connection_recoverable_error_count++;
|
|
237
|
+
this.log('Recoverable error, retrying in a moment.');
|
|
238
|
+
this.emit('recoverableError', e);
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
this.connectingCount--;
|
|
241
|
+
this.log('Retrying');
|
|
242
|
+
this.maybeCreateNew(attempt + 1);
|
|
243
|
+
}, this.poolConfig.reconnectIntervalMs);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.poolStats.connection_error_count++;
|
|
248
|
+
this.connectingCount--;
|
|
249
|
+
this.log('Connecting failed, emitting error');
|
|
250
|
+
this.emit('error', e);
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
this.handleAvailableConnection(poolConnection);
|
|
255
|
+
this.maybeCreateNew();
|
|
256
|
+
}
|
|
257
|
+
createPendingItem() {
|
|
258
|
+
return new Promise((resolve, reject) => {
|
|
259
|
+
const timeout = setTimeout(() => {
|
|
260
|
+
const acquireTimeoutError = new AcquireTimeoutError(this.lastRecoverableError && this.lastRecoverableError.time > item.createdAt
|
|
261
|
+
? this.lastRecoverableError.error
|
|
262
|
+
: undefined);
|
|
263
|
+
item.reject(acquireTimeoutError);
|
|
264
|
+
const index = this.queue.indexOf(item);
|
|
265
|
+
if (index > -1) {
|
|
266
|
+
this.queue.splice(index, 1);
|
|
267
|
+
}
|
|
268
|
+
this.poolStats.item_timeout_count++;
|
|
269
|
+
this.log('Queued item timed out');
|
|
270
|
+
}, this.poolConfig.acquireTimeoutMs);
|
|
271
|
+
const item = new PendingItem(it => {
|
|
272
|
+
const duration = Date.now() - item.createdAt;
|
|
273
|
+
const isNew = it.uses === 0;
|
|
274
|
+
this.log(`Queued item fulfilled with ${!isNew ? 'released' : 'new'} connection.`);
|
|
275
|
+
if (isNew) {
|
|
276
|
+
this.poolStats.item_resolved_new_ms_count++;
|
|
277
|
+
this.poolStats.item_resolved_new_ms_sum += duration;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
this.poolStats.item_resolved_released_ms_count++;
|
|
281
|
+
this.poolStats.item_resolved_released_ms_sum += duration;
|
|
282
|
+
}
|
|
283
|
+
clearTimeout(timeout);
|
|
284
|
+
resolve(it);
|
|
285
|
+
}, it => {
|
|
286
|
+
clearTimeout(timeout);
|
|
287
|
+
reject(it);
|
|
288
|
+
});
|
|
289
|
+
this.poolStats.item_queued_count++;
|
|
290
|
+
this.queue.push(item);
|
|
291
|
+
this.log(`Item added to a queue.`);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
handleAvailableConnection(poolConnection) {
|
|
295
|
+
const item = this.queue.shift();
|
|
296
|
+
const isNew = poolConnection.uses === 0;
|
|
297
|
+
if (!isNew) {
|
|
298
|
+
this.poolStats.connection_released_count++;
|
|
299
|
+
}
|
|
300
|
+
if (item) {
|
|
301
|
+
this.active.add(poolConnection);
|
|
302
|
+
item.resolve(poolConnection);
|
|
303
|
+
if (!isNew) {
|
|
304
|
+
this.poolStats.connection_reused_immediately_count++;
|
|
305
|
+
}
|
|
306
|
+
poolConnection.uses++;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (isNew) {
|
|
310
|
+
this.poolStats.connection_established_idle_count++;
|
|
311
|
+
}
|
|
312
|
+
if (this.idle.length >= this.poolConfig.maxIdle) {
|
|
313
|
+
setImmediate(async () => {
|
|
314
|
+
await this.disposeConnection(poolConnection);
|
|
315
|
+
this.poolStats.connection_disposed_idle_max_count++;
|
|
316
|
+
this.log('Too many idle connections, connection disposed.');
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
poolConnection.timerId = setTimeout(async () => {
|
|
321
|
+
const index = this.idle.indexOf(poolConnection);
|
|
322
|
+
if (index > -1) {
|
|
323
|
+
this.idle.splice(index, 1);
|
|
324
|
+
await this.disposeConnection(poolConnection);
|
|
325
|
+
this.poolStats.connection_disposed_idle_timeout_count++;
|
|
326
|
+
this.log('Idle connection disposed after timeout.');
|
|
327
|
+
}
|
|
328
|
+
}, this.poolConfig.idleTimeoutMs);
|
|
329
|
+
this.idle.push(poolConnection);
|
|
330
|
+
this.log('Connection is idle and available.');
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async disposeConnection(connection) {
|
|
334
|
+
try {
|
|
335
|
+
if (connection.disposed) {
|
|
336
|
+
throw new PoolError('Connection is already disposed');
|
|
337
|
+
}
|
|
338
|
+
connection.disposed = true;
|
|
339
|
+
await connection.client.end();
|
|
340
|
+
}
|
|
341
|
+
catch (e) {
|
|
342
|
+
this.on('error', e);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
log(message) {
|
|
346
|
+
if (!this.poolConfig.log)
|
|
347
|
+
return;
|
|
348
|
+
const poolStatus = this.getPoolStatus();
|
|
349
|
+
this.poolConfig.log(message, poolStatus);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
exports.Pool = Pool;
|
|
353
|
+
class PoolError extends errors_1.DatabaseError {
|
|
354
|
+
}
|
|
355
|
+
exports.PoolError = PoolError;
|
|
356
|
+
class AcquireTimeoutError extends PoolError {
|
|
357
|
+
constructor(previous) {
|
|
358
|
+
super('Failed to acquire a connection' + (previous && 'message' in previous ? `. Last error: ${previous.message}` : ''), previous);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
exports.AcquireTimeoutError = AcquireTimeoutError;
|
|
362
|
+
class PoolClosedError extends PoolError {
|
|
363
|
+
constructor() {
|
|
364
|
+
super('Pool is already closed');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
exports.PoolClosedError = PoolClosedError;
|
|
368
|
+
//# sourceMappingURL=Pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pool.js","sourceRoot":"","sources":["../../../src/client/Pool.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAuD;AAEvD,6CAA+C;AA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AAEQ,oBAAI;AAEb,MAAa,SAAU,SAAQ,sBAAa;CAC3C;AADD,8BACC;AAED,MAAa,mBAAoB,SAAQ,SAAS;IACjD,YAAY,QAAa;QACxB,KAAK,CAAC,gCAAgC,GAAG,CAAC,QAAQ,IAAI,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,iBAAiB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;IACnI,CAAC;CACD;AAJD,kDAIC;AAED,MAAa,eAAgB,SAAQ,SAAS;IAC7C;QACC,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAChC,CAAC;CACD;AAJD,0CAIC"}
|
|
@@ -2,19 +2,20 @@ import { ClientConfig } from 'pg';
|
|
|
2
2
|
import { EventManager } from './EventManager';
|
|
3
3
|
import { Client } from './Client';
|
|
4
4
|
import { Connection } from './Connection';
|
|
5
|
-
import {
|
|
5
|
+
import { DatabaseConfig } from '../types';
|
|
6
6
|
export declare class SingleConnection implements Connection.ConnectionLike, Connection.ClientFactory {
|
|
7
7
|
private readonly config;
|
|
8
8
|
private readonly queryConfig;
|
|
9
9
|
readonly eventManager: EventManager;
|
|
10
10
|
private readonly pgClient;
|
|
11
11
|
private isConnected;
|
|
12
|
-
constructor(config: ClientConfig &
|
|
12
|
+
constructor(config: ClientConfig & DatabaseConfig, queryConfig: Connection.QueryConfig, eventManager?: EventManager);
|
|
13
13
|
createClient(schema: string, queryMeta: Record<string, any>): Client;
|
|
14
14
|
transaction<Result>(callback: (connection: Connection.TransactionLike) => Promise<Result> | Result, options?: {
|
|
15
15
|
eventManager?: EventManager;
|
|
16
16
|
}): Promise<Result>;
|
|
17
17
|
end(): Promise<void>;
|
|
18
18
|
query<Row extends Record<string, any>>(sql: string, parameters?: any[], meta?: Record<string, any>, config?: Connection.QueryConfig): Promise<Connection.Result<Row>>;
|
|
19
|
+
private maybeConnect;
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=SingleConnection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleConnection.d.ts","sourceRoot":"","sources":["../../../src/client/SingleConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,IAAI,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SingleConnection.d.ts","sourceRoot":"","sources":["../../../src/client/SingleConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,IAAI,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAIzC,qBAAa,gBAAiB,YAAW,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,aAAa;IAK1F,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;aACZ,YAAY,EAAE,YAAY;IAN3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,WAAW,CAAQ;gBAGT,MAAM,EAAE,YAAY,GAAG,cAAc,EACrC,WAAW,EAAE,UAAU,CAAC,WAAW,EACpC,YAAY,GAAE,YAAqC;IAU7D,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAIrE,WAAW,CAAC,MAAM,EACvB,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,eAAe,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAC9E,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,YAAY,CAAA;KAAO,GAC3C,OAAO,CAAC,MAAM,CAAC;IAwBZ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAKpB,KAAK,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1C,GAAG,EAAE,MAAM,EACX,UAAU,GAAE,GAAG,EAAO,EACtB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC9B,MAAM,GAAE,UAAU,CAAC,WAAgB,GACjC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAUpB,YAAY;CAU1B"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SingleConnection = void 0;
|
|
4
|
-
const pg_1 = require("pg");
|
|
5
4
|
const EventManager_1 = require("./EventManager");
|
|
6
5
|
const Client_1 = require("./Client");
|
|
7
6
|
const Transaction_1 = require("./Transaction");
|
|
8
7
|
const execution_1 = require("./execution");
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
class SingleConnection {
|
|
10
11
|
constructor(config, queryConfig, eventManager = new EventManager_1.EventManager(null)) {
|
|
11
12
|
this.config = config;
|
|
12
13
|
this.queryConfig = queryConfig;
|
|
13
14
|
this.eventManager = eventManager;
|
|
14
15
|
this.isConnected = false;
|
|
15
|
-
this.pgClient =
|
|
16
|
+
this.pgClient = (0, utils_1.createPgClientFactory)(config)();
|
|
16
17
|
this.pgClient.on('error', err => {
|
|
17
18
|
// eslint-disable-next-line no-console
|
|
18
19
|
console.error(err);
|
|
@@ -24,10 +25,7 @@ class SingleConnection {
|
|
|
24
25
|
}
|
|
25
26
|
async transaction(callback, options = {}) {
|
|
26
27
|
var _a;
|
|
27
|
-
|
|
28
|
-
await this.pgClient.connect();
|
|
29
|
-
this.isConnected = true;
|
|
30
|
-
}
|
|
28
|
+
await this.maybeConnect();
|
|
31
29
|
const eventManager = new EventManager_1.EventManager((_a = options.eventManager) !== null && _a !== void 0 ? _a : this.eventManager);
|
|
32
30
|
await (0, execution_1.executeQuery)(this.pgClient, eventManager, {
|
|
33
31
|
sql: 'BEGIN',
|
|
@@ -50,10 +48,7 @@ class SingleConnection {
|
|
|
50
48
|
}
|
|
51
49
|
async query(sql, parameters = [], meta = {}, config = {}) {
|
|
52
50
|
var _a;
|
|
53
|
-
|
|
54
|
-
await this.pgClient.connect();
|
|
55
|
-
this.isConnected = true;
|
|
56
|
-
}
|
|
51
|
+
await this.maybeConnect();
|
|
57
52
|
const query = { sql, parameters, meta, ...this.queryConfig, ...config };
|
|
58
53
|
try {
|
|
59
54
|
return await (0, execution_1.executeQuery)(this.pgClient, (_a = config.eventManager) !== null && _a !== void 0 ? _a : this.eventManager, query, {});
|
|
@@ -62,6 +57,17 @@ class SingleConnection {
|
|
|
62
57
|
throw e;
|
|
63
58
|
}
|
|
64
59
|
}
|
|
60
|
+
async maybeConnect() {
|
|
61
|
+
if (!this.isConnected) {
|
|
62
|
+
try {
|
|
63
|
+
await this.pgClient.connect();
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
throw new errors_1.ClientError(e);
|
|
67
|
+
}
|
|
68
|
+
this.isConnected = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
65
71
|
}
|
|
66
72
|
exports.SingleConnection = SingleConnection;
|
|
67
73
|
//# sourceMappingURL=SingleConnection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingleConnection.js","sourceRoot":"","sources":["../../../src/client/SingleConnection.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SingleConnection.js","sourceRoot":"","sources":["../../../src/client/SingleConnection.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,qCAAiC;AACjC,+CA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{
|
|
|
2
2
|
readonly code?: string;
|
|
3
3
|
readonly originalMessage?: string;
|
|
4
4
|
readonly previous: any;
|
|
5
|
-
constructor(errMessage: string, previous
|
|
5
|
+
constructor(errMessage: string, previous?: Error | any);
|
|
6
6
|
}
|
|
7
7
|
export declare class ClientError extends DatabaseError {
|
|
8
8
|
constructor(previous: Error | any);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/client/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IACvC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAA;IAC7B,SAAgB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxC,SAAgB,QAAQ,EAAE,GAAG,CAAA;gBAEjB,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,GAAG,GAAG;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/client/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;IACvC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAA;IAC7B,SAAgB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxC,SAAgB,QAAQ,EAAE,GAAG,CAAA;gBAEjB,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,GAAG;CAUtD;AAED,qBAAa,WAAY,SAAQ,aAAa;gBACjC,QAAQ,EAAE,KAAK,GAAG,GAAG;CAGjC;AAED,qBAAa,UAAW,SAAQ,aAAa;aAKhB,GAAG,EAAE,MAAM;aAAkB,UAAU,EAAE,GAAG;aAAkB,QAAQ,EAAE,KAAK,GAAG,GAAG;IAJ/G,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAA;IAC7B,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnC,SAAgB,eAAe,CAAC,EAAE,MAAM,CAAA;gBAEZ,GAAG,EAAE,MAAM,EAAkB,UAAU,EAAE,GAAG,EAAkB,QAAQ,EAAE,KAAK,GAAG,GAAG;CAS/G;AAED,qBAAa,qBAAsB,SAAQ,UAAU;CAAG;AAExD,qBAAa,wBAAyB,SAAQ,UAAU;CAAG;AAE3D,qBAAa,oBAAqB,SAAQ,UAAU;CAAG;AAEvD,qBAAa,yBAA0B,SAAQ,UAAU;CAAG;AAE5D,qBAAa,gBAAiB,SAAQ,UAAU;CAAG;AAEnD,qBAAa,uBAAwB,SAAQ,UAAU;CAAG"}
|
|
@@ -4,11 +4,13 @@ exports.TransactionAbortedError = exports.InvalidDataError = exports.Serializati
|
|
|
4
4
|
class DatabaseError extends Error {
|
|
5
5
|
constructor(errMessage, previous) {
|
|
6
6
|
super(errMessage);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
if (previous) {
|
|
8
|
+
const { message, stack, ...other } = previous;
|
|
9
|
+
const otherDefined = Object.fromEntries(Object.entries(other).filter(it => it[1] !== undefined));
|
|
10
|
+
this.previous = { message, ...otherDefined };
|
|
11
|
+
this.code = previous.code;
|
|
12
|
+
this.originalMessage = previous.message;
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
exports.DatabaseError = DatabaseError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/client/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IAKvC,YAAY,UAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/client/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAc,SAAQ,KAAK;IAKvC,YAAY,UAAkB,EAAE,QAAsB;QACrD,KAAK,CAAC,UAAU,CAAC,CAAA;QACjB,IAAI,QAAQ,EAAE;YACb,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAA;YAC7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,SAAQ,UAAU;CAAG;AAAvD,oDAAuD;AAEvD,MAAa,yBAA0B,SAAQ,UAAU;CAAG;AAA5D,8DAA4D;AAE5D,MAAa,gBAAiB,SAAQ,UAAU;CAAG;AAAnD,4CAAmD;AAEnD,MAAa,uBAAwB,SAAQ,UAAU;CAAG;AAA1D,0DAA0D"}
|
|
@@ -3,6 +3,5 @@ import { EventManager } from './EventManager';
|
|
|
3
3
|
import { Connection } from './Connection';
|
|
4
4
|
declare type SomeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
5
5
|
export declare function executeQuery<Row extends Record<string, any>>(pgClient: ClientBase, eventManager: EventManager, { sql, parameters, meta, timing }: SomeOptional<Connection.Query, 'parameters' | 'meta'> & Connection.QueryConfig, context?: Connection.QueryContext): Promise<Connection.Result<Row>>;
|
|
6
|
-
export declare const executeClientOperation: <T>(cb: () => Promise<T>) => Promise<T>;
|
|
7
6
|
export {};
|
|
8
7
|
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/client/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/client/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAgBzC,aAAK,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAE1E,wBAAsB,YAAY,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjE,QAAQ,EAAE,UAAU,EACpB,YAAY,EAAE,YAAY,EAC1B,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAAC,GAAG,UAAU,CAAC,WAAW,EACjH,OAAO,GAAE,UAAU,CAAC,YAAiB,GACnC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CA0DjC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.executeQuery = void 0;
|
|
4
4
|
const EventManager_1 = require("./EventManager");
|
|
5
5
|
const errors_1 = require("./errors");
|
|
6
6
|
const errorCodes_1 = require("./errorCodes");
|
|
@@ -62,13 +62,4 @@ async function executeQuery(pgClient, eventManager, { sql, parameters, meta, tim
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
exports.executeQuery = executeQuery;
|
|
65
|
-
const executeClientOperation = async (cb) => {
|
|
66
|
-
try {
|
|
67
|
-
return await cb();
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
throw new errors_1.ClientError(e);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
exports.executeClientOperation = executeClientOperation;
|
|
74
65
|
//# sourceMappingURL=execution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/client/execution.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../../src/client/execution.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAE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AAE,UAAU,EAAE,KAAK,CAAC,CAAA;YACvD,KAAK,6BAAgB,CAAC,yBAAyB;gBAC9C,MAAM,IAAI,kCAAyB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;YAC5D,KAAK,6BAAgB,CAAC,2BAA2B,CAAC;YAClD,KAAK,6BAAgB,CAAC,uBAAuB;gBAC5C,MAAM,IAAI,yBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;YACnD,KAAK,6BAAgB,CAAC,yBAAyB;gBAC9C,MAAM,IAAI,gCAAuB,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;YAC1D;gBACC,MAAM,IAAI,mBAAU,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,CAAC,CAAA;SAC7C;KACD;AACF,CAAC;AA/DD,oCA+DC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
package/dist/src/client/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./errorCodes"), exports);
|
|
|
19
19
|
__exportStar(require("./errors"), exports);
|
|
20
20
|
__exportStar(require("./Connection"), exports);
|
|
21
21
|
__exportStar(require("./EventManager"), exports);
|
|
22
|
+
__exportStar(require("./Pool"), exports);
|
|
22
23
|
__exportStar(require("./Transaction"), exports);
|
|
23
24
|
__exportStar(require("./SingleConnection"), exports);
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,+CAA4B;AAC5B,2CAAwB;AACxB,+CAA4B;AAC5B,iDAA8B;AAC9B,gDAA6B;AAC7B,qDAAkC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,+CAA4B;AAC5B,2CAAwB;AACxB,+CAA4B;AAC5B,iDAA8B;AAC9B,yCAAsB;AACtB,gDAA6B;AAC7B,qDAAkC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export * from './builders';
|
|
|
9
9
|
export * from './queryable';
|
|
10
10
|
export * from './Literal';
|
|
11
11
|
export * from './types';
|
|
12
|
-
export { wrapIdentifier, retryTransaction, ConstraintHelper, withDatabaseAdvisoryLock, createDatabaseIfNotExists, } from './utils';
|
|
12
|
+
export { wrapIdentifier, retryTransaction, ConstraintHelper, withDatabaseAdvisoryLock, createDatabaseIfNotExists, createPgClientFactory, } from './utils';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|