@agentuity/postgres 0.1.41

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.
Files changed (48) hide show
  1. package/AGENTS.md +124 -0
  2. package/README.md +297 -0
  3. package/dist/client.d.ts +224 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +670 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/errors.d.ts +109 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +115 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +41 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +47 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/patch.d.ts +65 -0
  16. package/dist/patch.d.ts.map +1 -0
  17. package/dist/patch.js +111 -0
  18. package/dist/patch.js.map +1 -0
  19. package/dist/postgres.d.ts +62 -0
  20. package/dist/postgres.d.ts.map +1 -0
  21. package/dist/postgres.js +63 -0
  22. package/dist/postgres.js.map +1 -0
  23. package/dist/reconnect.d.ts +31 -0
  24. package/dist/reconnect.d.ts.map +1 -0
  25. package/dist/reconnect.js +60 -0
  26. package/dist/reconnect.js.map +1 -0
  27. package/dist/registry.d.ts +71 -0
  28. package/dist/registry.d.ts.map +1 -0
  29. package/dist/registry.js +175 -0
  30. package/dist/registry.js.map +1 -0
  31. package/dist/transaction.d.ts +147 -0
  32. package/dist/transaction.d.ts.map +1 -0
  33. package/dist/transaction.js +287 -0
  34. package/dist/transaction.js.map +1 -0
  35. package/dist/types.d.ts +213 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +55 -0
  40. package/src/client.ts +776 -0
  41. package/src/errors.ts +154 -0
  42. package/src/index.ts +71 -0
  43. package/src/patch.ts +123 -0
  44. package/src/postgres.ts +65 -0
  45. package/src/reconnect.ts +74 -0
  46. package/src/registry.ts +194 -0
  47. package/src/transaction.ts +312 -0
  48. package/src/types.ts +250 -0
package/dist/client.js ADDED
@@ -0,0 +1,670 @@
1
+ import { SQL as BunSQL } from 'bun';
2
+ import { ConnectionClosedError, PostgresError, ReconnectFailedError, QueryTimeoutError, UnsupportedOperationError, isRetryableError, } from './errors';
3
+ import { computeBackoff, sleep, mergeReconnectConfig } from './reconnect';
4
+ import { Transaction } from './transaction';
5
+ import { registerClient, unregisterClient } from './registry';
6
+ /**
7
+ * A resilient PostgreSQL client with automatic reconnection.
8
+ *
9
+ * Wraps Bun's native SQL driver and adds:
10
+ * - Automatic reconnection with exponential backoff
11
+ * - Connection state tracking
12
+ * - Transaction support
13
+ * - Reserved connection support
14
+ *
15
+ * Can be used as a tagged template literal for queries:
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const client = new PostgresClient();
20
+ *
21
+ * // Simple query
22
+ * const users = await client`SELECT * FROM users`;
23
+ *
24
+ * // Parameterized query
25
+ * const user = await client`SELECT * FROM users WHERE id = ${userId}`;
26
+ *
27
+ * // Transaction
28
+ * const tx = await client.begin();
29
+ * await tx`INSERT INTO users (name) VALUES (${name})`;
30
+ * await tx.commit();
31
+ * ```
32
+ */
33
+ export class PostgresClient {
34
+ _sql = null;
35
+ _config;
36
+ _initialized = false; // SQL client created (lazy connection)
37
+ _connected = false; // Actual TCP connection verified
38
+ _reconnecting = false;
39
+ _closed = false;
40
+ _shuttingDown = false;
41
+ _signalHandlers = [];
42
+ _reconnectPromise = null;
43
+ _connectPromise = null;
44
+ _stats = {
45
+ connected: false,
46
+ reconnecting: false,
47
+ totalConnections: 0,
48
+ reconnectAttempts: 0,
49
+ failedReconnects: 0,
50
+ lastConnectedAt: null,
51
+ lastDisconnectedAt: null,
52
+ lastReconnectAttemptAt: null,
53
+ };
54
+ /**
55
+ * Creates a new PostgresClient.
56
+ *
57
+ * Note: By default, the actual TCP connection is established lazily on first query.
58
+ * The `connected` property will be `false` until a query is executed or
59
+ * `waitForConnection()` is called. Set `preconnect: true` in config to
60
+ * establish the connection immediately.
61
+ *
62
+ * @param config - Connection configuration. Can be a connection URL string or a config object.
63
+ * If not provided, uses `process.env.DATABASE_URL`.
64
+ */
65
+ constructor(config) {
66
+ if (typeof config === 'string') {
67
+ this._config = { url: config };
68
+ }
69
+ else {
70
+ this._config = config ?? {};
71
+ }
72
+ // Initialize the SQL client (lazy - doesn't establish TCP connection yet)
73
+ this._initializeSql();
74
+ // Register shutdown signal handlers to prevent reconnection during app shutdown
75
+ this._registerShutdownHandlers();
76
+ // Register this client in the global registry for coordinated shutdown
77
+ registerClient(this);
78
+ // If preconnect is enabled, establish connection immediately
79
+ if (this._config.preconnect) {
80
+ const p = this._warmConnection();
81
+ // Attach no-op catch to suppress unhandled rejection warnings
82
+ // Later awaits will still observe the real rejection
83
+ p.catch(() => { });
84
+ this._connectPromise = p;
85
+ }
86
+ }
87
+ /**
88
+ * Whether the client is currently connected.
89
+ */
90
+ get connected() {
91
+ return this._connected;
92
+ }
93
+ /**
94
+ * Whether the client is shutting down (won't attempt reconnection).
95
+ */
96
+ get shuttingDown() {
97
+ return this._shuttingDown;
98
+ }
99
+ /**
100
+ * Whether a reconnection attempt is in progress.
101
+ */
102
+ get reconnecting() {
103
+ return this._reconnecting;
104
+ }
105
+ /**
106
+ * Connection statistics.
107
+ */
108
+ get stats() {
109
+ return {
110
+ ...this._stats,
111
+ connected: this._connected,
112
+ reconnecting: this._reconnecting,
113
+ };
114
+ }
115
+ /**
116
+ * Execute a query using tagged template literal syntax.
117
+ * If reconnection is in progress, waits for it to complete before executing.
118
+ * Automatically retries on retryable errors.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * const users = await client`SELECT * FROM users WHERE active = ${true}`;
123
+ * ```
124
+ */
125
+ query(strings, ...values) {
126
+ return this._executeWithRetry(async () => {
127
+ const sql = await this._ensureConnectedAsync();
128
+ return sql(strings, ...values);
129
+ });
130
+ }
131
+ /**
132
+ * Begin a new transaction.
133
+ *
134
+ * @param options - Transaction options (isolation level, read-only, deferrable)
135
+ * @returns A Transaction object for executing queries within the transaction
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const tx = await client.begin();
140
+ * try {
141
+ * await tx`INSERT INTO users (name) VALUES (${name})`;
142
+ * await tx`UPDATE accounts SET balance = balance - ${amount} WHERE id = ${fromId}`;
143
+ * await tx.commit();
144
+ * } catch (error) {
145
+ * await tx.rollback();
146
+ * throw error;
147
+ * }
148
+ * ```
149
+ */
150
+ async begin(options) {
151
+ // Use async ensure to wait for connection/reconnect completion
152
+ // This ensures _warmConnection() updates connection stats before we proceed
153
+ const sql = await this._ensureConnectedAsync();
154
+ // Build BEGIN statement with options
155
+ let beginStatement = 'BEGIN';
156
+ if (options?.isolationLevel) {
157
+ beginStatement += ` ISOLATION LEVEL ${options.isolationLevel.toUpperCase()}`;
158
+ }
159
+ if (options?.readOnly) {
160
+ beginStatement += ' READ ONLY';
161
+ }
162
+ else if (options?.readOnly === false) {
163
+ beginStatement += ' READ WRITE';
164
+ }
165
+ if (options?.deferrable === true) {
166
+ beginStatement += ' DEFERRABLE';
167
+ }
168
+ else if (options?.deferrable === false) {
169
+ beginStatement += ' NOT DEFERRABLE';
170
+ }
171
+ // Execute BEGIN
172
+ const connection = await sql.unsafe(beginStatement);
173
+ return new Transaction(sql, connection);
174
+ }
175
+ /**
176
+ * Reserve an exclusive connection from the pool.
177
+ *
178
+ * **Note:** This feature is not currently supported because Bun's SQL driver
179
+ * does not expose connection-level pooling APIs. The underlying driver manages
180
+ * connections internally and does not allow reserving a specific connection.
181
+ *
182
+ * @param _options - Reserve options (unused)
183
+ * @throws {UnsupportedOperationError} Always throws - this operation is not supported
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * // This will throw UnsupportedOperationError
188
+ * const conn = await client.reserve();
189
+ * ```
190
+ */
191
+ async reserve(_options) {
192
+ throw new UnsupportedOperationError({
193
+ operation: 'reserve',
194
+ reason: "Bun's SQL driver does not expose connection-level pooling APIs. " +
195
+ 'Use transactions (begin/commit) for operations that require session-level state.',
196
+ });
197
+ }
198
+ /**
199
+ * Signal that the application is shutting down.
200
+ * This prevents reconnection attempts but doesn't immediately close the connection.
201
+ * Use this when you want to gracefully drain connections before calling close().
202
+ */
203
+ shutdown() {
204
+ this._shuttingDown = true;
205
+ }
206
+ /**
207
+ * Close the client and release all connections.
208
+ */
209
+ async close() {
210
+ this._closed = true;
211
+ this._shuttingDown = true; // Also set shuttingDown to prevent any race conditions
212
+ this._connected = false;
213
+ this._reconnecting = false;
214
+ // Remove signal handlers
215
+ this._removeShutdownHandlers();
216
+ // Unregister from global registry
217
+ unregisterClient(this);
218
+ if (this._sql) {
219
+ await this._sql.close();
220
+ this._sql = null;
221
+ }
222
+ }
223
+ /**
224
+ * Access to raw SQL methods for advanced use cases.
225
+ * Returns the underlying Bun.SQL instance.
226
+ */
227
+ get raw() {
228
+ return this._ensureConnected();
229
+ }
230
+ /**
231
+ * Execute an unsafe (unparameterized) query.
232
+ * Use with caution - this bypasses SQL injection protection.
233
+ *
234
+ * @param query - The raw SQL query string
235
+ */
236
+ unsafe(query) {
237
+ const sql = this._ensureConnected();
238
+ return sql.unsafe(query);
239
+ }
240
+ /**
241
+ * Registers signal handlers to detect application shutdown.
242
+ * When shutdown is detected, reconnection is disabled.
243
+ */
244
+ _registerShutdownHandlers() {
245
+ const shutdownHandler = () => {
246
+ this._shuttingDown = true;
247
+ };
248
+ // Listen for common shutdown signals
249
+ const signals = ['SIGTERM', 'SIGINT'];
250
+ for (const signal of signals) {
251
+ process.on(signal, shutdownHandler);
252
+ this._signalHandlers.push({ signal, handler: shutdownHandler });
253
+ }
254
+ }
255
+ /**
256
+ * Removes signal handlers registered for shutdown detection.
257
+ */
258
+ _removeShutdownHandlers() {
259
+ for (const { signal, handler } of this._signalHandlers) {
260
+ process.off(signal, handler);
261
+ }
262
+ this._signalHandlers = [];
263
+ }
264
+ /**
265
+ * Initializes the internal Bun.SQL client.
266
+ * Note: This creates the SQL client but doesn't establish the TCP connection yet.
267
+ * Bun's SQL driver uses lazy connections - the actual TCP connection is made on first query.
268
+ */
269
+ _initializeSql() {
270
+ if (this._closed || this._initialized) {
271
+ return;
272
+ }
273
+ const url = this._config.url ?? process.env.DATABASE_URL;
274
+ // Build Bun.SQL options - use type assertion since Bun types are a union
275
+ const bunOptions = {
276
+ adapter: 'postgres',
277
+ };
278
+ if (url) {
279
+ bunOptions.url = url;
280
+ }
281
+ if (this._config.hostname)
282
+ bunOptions.hostname = this._config.hostname;
283
+ if (this._config.port)
284
+ bunOptions.port = this._config.port;
285
+ if (this._config.username)
286
+ bunOptions.username = this._config.username;
287
+ if (this._config.password)
288
+ bunOptions.password = this._config.password;
289
+ if (this._config.database)
290
+ bunOptions.database = this._config.database;
291
+ if (this._config.max)
292
+ bunOptions.max = this._config.max;
293
+ if (this._config.idleTimeout !== undefined)
294
+ bunOptions.idleTimeout = this._config.idleTimeout;
295
+ if (this._config.connectionTimeout !== undefined)
296
+ bunOptions.connectionTimeout = this._config.connectionTimeout;
297
+ // Handle TLS configuration
298
+ if (this._config.tls !== undefined) {
299
+ if (typeof this._config.tls === 'boolean') {
300
+ bunOptions.tls = this._config.tls;
301
+ }
302
+ else {
303
+ bunOptions.tls = this._config.tls;
304
+ }
305
+ }
306
+ // Set up onclose handler for reconnection
307
+ bunOptions.onclose = (err) => {
308
+ this._handleClose(err ?? undefined);
309
+ };
310
+ this._sql = new BunSQL(bunOptions);
311
+ this._initialized = true;
312
+ // Note: _connected remains false until we verify the connection with a query
313
+ }
314
+ /**
315
+ * Warms the connection by executing a test query.
316
+ * This establishes the actual TCP connection and verifies it's working.
317
+ */
318
+ async _warmConnection() {
319
+ if (this._closed || this._connected) {
320
+ return;
321
+ }
322
+ if (!this._sql) {
323
+ this._initializeSql();
324
+ }
325
+ // Execute a test query to establish the TCP connection
326
+ // If this fails, the error will propagate to the caller
327
+ await this._sql `SELECT 1`;
328
+ this._connected = true;
329
+ this._stats.totalConnections++;
330
+ this._stats.lastConnectedAt = new Date();
331
+ }
332
+ /**
333
+ * Re-initializes the SQL client for reconnection.
334
+ * Used internally during the reconnection loop.
335
+ */
336
+ _reinitializeSql() {
337
+ this._initialized = false;
338
+ this._connected = false;
339
+ this._initializeSql();
340
+ }
341
+ /**
342
+ * Handles connection close events.
343
+ */
344
+ _handleClose(error) {
345
+ const wasConnected = this._connected;
346
+ this._connected = false;
347
+ this._stats.lastDisconnectedAt = new Date();
348
+ // Call user's onclose callback
349
+ this._config.onclose?.(error);
350
+ // Don't reconnect if explicitly closed OR if application is shutting down
351
+ if (this._closed || this._shuttingDown) {
352
+ return;
353
+ }
354
+ // Check if reconnection is enabled
355
+ const reconnectConfig = mergeReconnectConfig(this._config.reconnect);
356
+ if (!reconnectConfig.enabled) {
357
+ return;
358
+ }
359
+ // If there's an error, check if it's retryable
360
+ // If there's NO error (graceful close), still attempt reconnection
361
+ if (error && !isRetryableError(error)) {
362
+ return;
363
+ }
364
+ // Start reconnection if not already in progress
365
+ if (!this._reconnecting && wasConnected) {
366
+ this._startReconnect();
367
+ }
368
+ }
369
+ /**
370
+ * Starts the reconnection process.
371
+ */
372
+ _startReconnect() {
373
+ if (this._reconnecting || this._closed || this._shuttingDown) {
374
+ return;
375
+ }
376
+ this._reconnecting = true;
377
+ this._reconnectPromise = this._reconnectLoop();
378
+ }
379
+ /**
380
+ * The main reconnection loop with exponential backoff.
381
+ */
382
+ async _reconnectLoop() {
383
+ const config = mergeReconnectConfig(this._config.reconnect);
384
+ let attempt = 0;
385
+ let lastError;
386
+ while (attempt < config.maxAttempts && !this._closed && !this._shuttingDown) {
387
+ this._stats.reconnectAttempts++;
388
+ this._stats.lastReconnectAttemptAt = new Date();
389
+ // Notify about reconnection attempt
390
+ this._config.onreconnect?.(attempt + 1);
391
+ // Calculate backoff delay
392
+ const delay = computeBackoff(attempt, config);
393
+ // Wait before attempting
394
+ await sleep(delay);
395
+ if (this._closed) {
396
+ break;
397
+ }
398
+ try {
399
+ // Close existing connection if any
400
+ if (this._sql) {
401
+ try {
402
+ await this._sql.close();
403
+ }
404
+ catch {
405
+ // Ignore close errors
406
+ }
407
+ this._sql = null;
408
+ }
409
+ // Attempt to reconnect - reinitialize and warm the connection
410
+ this._reinitializeSql();
411
+ await this._warmConnection();
412
+ // Success!
413
+ this._reconnecting = false;
414
+ this._reconnectPromise = null;
415
+ this._config.onreconnected?.();
416
+ return;
417
+ }
418
+ catch (error) {
419
+ lastError =
420
+ error instanceof Error
421
+ ? error
422
+ : new PostgresError({
423
+ message: String(error),
424
+ });
425
+ this._stats.failedReconnects++;
426
+ attempt++;
427
+ }
428
+ }
429
+ // All attempts failed
430
+ this._reconnecting = false;
431
+ this._reconnectPromise = null;
432
+ // Only invoke callback if not explicitly closed/shutdown to avoid noisy/misleading callbacks
433
+ if (!this._closed && !this._shuttingDown) {
434
+ const finalError = new ReconnectFailedError({
435
+ attempts: attempt,
436
+ lastError,
437
+ });
438
+ this._config.onreconnectfailed?.(finalError);
439
+ }
440
+ }
441
+ /**
442
+ * Ensures the client is initialized and returns the SQL instance.
443
+ * This is the synchronous version - use _ensureConnectedAsync when you can await.
444
+ *
445
+ * Note: This returns the SQL instance even if `_connected` is false because
446
+ * Bun's SQL uses lazy connections. The actual connection will be established
447
+ * on first query. Use this for synchronous access to the SQL instance.
448
+ */
449
+ _ensureConnected() {
450
+ if (this._closed) {
451
+ throw new ConnectionClosedError({
452
+ message: 'Client has been closed',
453
+ });
454
+ }
455
+ if (!this._sql) {
456
+ throw new ConnectionClosedError({
457
+ message: 'SQL client not initialized',
458
+ wasReconnecting: this._reconnecting,
459
+ });
460
+ }
461
+ return this._sql;
462
+ }
463
+ /**
464
+ * Ensures the client is connected and returns the SQL instance.
465
+ * If reconnection is in progress, waits for it to complete.
466
+ * If connection hasn't been established yet, warms it first.
467
+ */
468
+ async _ensureConnectedAsync() {
469
+ if (this._closed) {
470
+ throw new ConnectionClosedError({
471
+ message: 'Client has been closed',
472
+ });
473
+ }
474
+ // If preconnect is in progress, wait for it
475
+ if (this._connectPromise) {
476
+ try {
477
+ await this._connectPromise;
478
+ }
479
+ catch (err) {
480
+ this._connectPromise = null;
481
+ throw err;
482
+ }
483
+ this._connectPromise = null;
484
+ }
485
+ // If reconnection is in progress, wait for it to complete
486
+ if (this._reconnecting && this._reconnectPromise) {
487
+ await this._reconnectPromise;
488
+ }
489
+ if (!this._sql) {
490
+ throw new ConnectionClosedError({
491
+ message: 'SQL client not initialized',
492
+ wasReconnecting: false,
493
+ });
494
+ }
495
+ // If not yet connected, warm the connection
496
+ if (!this._connected) {
497
+ await this._warmConnection();
498
+ }
499
+ return this._sql;
500
+ }
501
+ /**
502
+ * Executes an operation with retry logic for retryable errors.
503
+ * Waits for reconnection if one is in progress.
504
+ */
505
+ async _executeWithRetry(operation, maxRetries = 3) {
506
+ let lastError;
507
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
508
+ try {
509
+ // Wait for preconnect if in progress
510
+ if (this._connectPromise) {
511
+ try {
512
+ await this._connectPromise;
513
+ }
514
+ catch (err) {
515
+ this._connectPromise = null;
516
+ throw err;
517
+ }
518
+ this._connectPromise = null;
519
+ }
520
+ // Wait for reconnection if in progress
521
+ if (this._reconnecting && this._reconnectPromise) {
522
+ await this._reconnectPromise;
523
+ }
524
+ if (!this._sql) {
525
+ throw new ConnectionClosedError({
526
+ message: 'SQL client not initialized',
527
+ wasReconnecting: this._reconnecting,
528
+ });
529
+ }
530
+ // If not yet connected, warm the connection
531
+ if (!this._connected) {
532
+ await this._warmConnection();
533
+ }
534
+ return await operation();
535
+ }
536
+ catch (error) {
537
+ lastError = error instanceof Error ? error : new Error(String(error));
538
+ // If it's a retryable error and we have retries left, wait and retry
539
+ if (isRetryableError(error) && attempt < maxRetries) {
540
+ // Wait for reconnection to complete if it started
541
+ if (this._reconnecting && this._reconnectPromise) {
542
+ try {
543
+ await this._reconnectPromise;
544
+ }
545
+ catch {
546
+ // Reconnection failed, will throw below
547
+ }
548
+ }
549
+ continue;
550
+ }
551
+ throw error;
552
+ }
553
+ }
554
+ throw lastError;
555
+ }
556
+ /**
557
+ * Wait for the connection to be established.
558
+ * If the connection hasn't been established yet (lazy connection), this will
559
+ * warm the connection by executing a test query.
560
+ * If reconnection is in progress, waits for it to complete.
561
+ *
562
+ * @param timeoutMs - Optional timeout in milliseconds
563
+ * @throws {ConnectionClosedError} If the client has been closed or connection fails
564
+ */
565
+ async waitForConnection(timeoutMs) {
566
+ if (this._connected && this._sql) {
567
+ return;
568
+ }
569
+ if (this._closed) {
570
+ throw new ConnectionClosedError({
571
+ message: 'Client has been closed',
572
+ });
573
+ }
574
+ const connectOperation = async () => {
575
+ // Wait for preconnect if in progress
576
+ if (this._connectPromise) {
577
+ try {
578
+ await this._connectPromise;
579
+ }
580
+ catch (err) {
581
+ this._connectPromise = null;
582
+ throw err;
583
+ }
584
+ this._connectPromise = null;
585
+ }
586
+ // Wait for reconnection if in progress
587
+ if (this._reconnecting && this._reconnectPromise) {
588
+ await this._reconnectPromise;
589
+ }
590
+ // If still not connected, warm the connection
591
+ if (!this._connected && this._sql) {
592
+ await this._warmConnection();
593
+ }
594
+ if (!this._connected || !this._sql) {
595
+ throw new ConnectionClosedError({
596
+ message: 'Failed to establish connection',
597
+ });
598
+ }
599
+ };
600
+ if (timeoutMs !== undefined) {
601
+ let timerId;
602
+ const timeoutPromise = new Promise((_, reject) => {
603
+ timerId = setTimeout(() => reject(new QueryTimeoutError({
604
+ timeoutMs,
605
+ })), timeoutMs);
606
+ });
607
+ try {
608
+ await Promise.race([connectOperation(), timeoutPromise]);
609
+ }
610
+ finally {
611
+ if (timerId !== undefined) {
612
+ clearTimeout(timerId);
613
+ }
614
+ }
615
+ }
616
+ else {
617
+ await connectOperation();
618
+ }
619
+ }
620
+ }
621
+ /**
622
+ * Creates a PostgresClient that can be called as a tagged template literal.
623
+ *
624
+ * @param config - Connection configuration
625
+ * @returns A callable PostgresClient
626
+ *
627
+ * @internal
628
+ */
629
+ export function createCallableClient(config) {
630
+ const client = new PostgresClient(config);
631
+ // Create a callable function that delegates to client.query
632
+ const callable = function (strings, ...values) {
633
+ return client.query(strings, ...values);
634
+ };
635
+ // Copy all properties and methods from the client to the callable
636
+ Object.setPrototypeOf(callable, PostgresClient.prototype);
637
+ // Define properties that delegate to the client
638
+ Object.defineProperties(callable, {
639
+ connected: {
640
+ get: () => client.connected,
641
+ enumerable: true,
642
+ },
643
+ reconnecting: {
644
+ get: () => client.reconnecting,
645
+ enumerable: true,
646
+ },
647
+ shuttingDown: {
648
+ get: () => client.shuttingDown,
649
+ enumerable: true,
650
+ },
651
+ stats: {
652
+ get: () => client.stats,
653
+ enumerable: true,
654
+ },
655
+ raw: {
656
+ get: () => client.raw,
657
+ enumerable: true,
658
+ },
659
+ });
660
+ // Bind methods to the client
661
+ callable.query = client.query.bind(client);
662
+ callable.begin = client.begin.bind(client);
663
+ callable.reserve = client.reserve.bind(client);
664
+ callable.close = client.close.bind(client);
665
+ callable.shutdown = client.shutdown.bind(client);
666
+ callable.unsafe = client.unsafe.bind(client);
667
+ callable.waitForConnection = client.waitForConnection.bind(client);
668
+ return callable;
669
+ }
670
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,MAAM,EAA2B,MAAM,KAAK,CAAC;AAE7D,OAAO,EACN,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAsB,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAQ9D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,cAAc;IAClB,IAAI,GAAuC,IAAI,CAAC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