prisma-pglite-bridge 1.0.0 → 1.2.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.
package/dist/index.d.cts CHANGED
@@ -123,11 +123,7 @@ declare class SessionLock {
123
123
  * later be granted ownership after destruction.
124
124
  */
125
125
  cancel(id: symbol, error?: Error): boolean;
126
- /**
127
- * Grant ownership to the next waiter, if any.
128
- *
129
- * @returns `true` if a waiter was unblocked; `false` if the queue was empty.
130
- */
126
+ /** Grant ownership to the next waiter, if any. */
131
127
  private drainWaitQueue;
132
128
  }
133
129
  //#endregion
@@ -159,6 +155,13 @@ interface PGliteDuplexOptions {
159
155
  * weaker durability. Default `true`.
160
156
  */
161
157
  syncToFs?: boolean;
158
+ /**
159
+ * Widen system-catalog "char" columns (OID 18) to text (OID 25) in
160
+ * RowDescription frames. Required for `@prisma/adapter-pg`, which rejects
161
+ * OID 18. Native clients (Prisma CLI engine, psql) need the real OID —
162
+ * `PGliteServer` disables this. Default `true`.
163
+ */
164
+ rewriteSystemCatalogCharOids?: boolean;
162
165
  }
163
166
  /**
164
167
  * Duplex stream that bridges `pg.Client` to an in-process PGlite instance.
@@ -187,6 +190,7 @@ declare class PGliteDuplex extends Duplex {
187
190
  private readonly bridgeId?;
188
191
  private readonly telemetry?;
189
192
  private readonly syncToFs;
193
+ private readonly rewriteSystemCatalogCharOids;
190
194
  private readonly timeout?;
191
195
  private readonly duplexId;
192
196
  /** Incoming bytes framed directly from a queued chunk buffer */
@@ -211,6 +215,9 @@ declare class PGliteDuplex extends Duplex {
211
215
  /** Memoized rollback so concurrent teardown paths (e.g., `_final` then
212
216
  * `_destroy`) don't issue duplicate `ROLLBACK` statements. */
213
217
  private rollbackPromise?;
218
+ private pendingProtocolCleanupBytes;
219
+ private pendingProtocolCleanupCalls;
220
+ private protocolCleanupUnsupported;
214
221
  /** Resolves once the stream has fully torn down (post-`_final` rollback,
215
222
  * post-`_destroy`). Single-shot, mirroring the `'close'` event. */
216
223
  readonly onClose: Promise<void>;
@@ -265,6 +272,9 @@ declare class PGliteDuplex extends Duplex {
265
272
  * waiters behind it).
266
273
  */
267
274
  private runUnderRunExclusive;
275
+ /** Acquire the session, then run `op` under runExclusive without timing —
276
+ * the untimed path shared by startup and the no-telemetry query branch. */
277
+ private runUntimed;
268
278
  /**
269
279
  * Frames and processes regular wire protocol messages.
270
280
  *
@@ -287,6 +297,8 @@ declare class PGliteDuplex extends Duplex {
287
297
  * materializing it.
288
298
  */
289
299
  private flushPipeline;
300
+ private tryContiguousPipelineBatch;
301
+ private concatPipeline;
290
302
  /**
291
303
  * Acquires the session, runs the op under `pglite.runExclusive`, and
292
304
  * updates internal stats and/or publishes diagnostics events when enabled.
@@ -301,10 +313,8 @@ declare class PGliteDuplex extends Duplex {
301
313
  */
302
314
  private runWithTiming;
303
315
  /**
304
- * Sends a message (or pipelined batch) to PGlite and pushes response
305
- * chunks directly to the stream as they arrive. Avoids collecting and
306
- * concatenating for large multi-row responses (e.g., findMany 500 rows
307
- * = ~503 onRawData chunks).
316
+ * Sends a message (or pipelined batch) to PGlite and pushes the raw protocol
317
+ * response to the stream.
308
318
  *
309
319
  * For pipelined Extended Query batches, pass `suppressIntermediateRfq`
310
320
  * so only the final ReadyForQuery reaches the client.
@@ -312,6 +322,7 @@ declare class PGliteDuplex extends Duplex {
312
322
  * Must be called inside runExclusive.
313
323
  */
314
324
  private streamProtocol;
325
+ private clearPGliteProtocolMessages;
315
326
  private acquireSession;
316
327
  /**
317
328
  * Issue `ROLLBACK` against PGlite when the duplex's last observed
package/dist/index.d.mts CHANGED
@@ -124,11 +124,7 @@ declare class SessionLock {
124
124
  * later be granted ownership after destruction.
125
125
  */
126
126
  cancel(id: symbol, error?: Error): boolean;
127
- /**
128
- * Grant ownership to the next waiter, if any.
129
- *
130
- * @returns `true` if a waiter was unblocked; `false` if the queue was empty.
131
- */
127
+ /** Grant ownership to the next waiter, if any. */
132
128
  private drainWaitQueue;
133
129
  }
134
130
  //#endregion
@@ -160,6 +156,13 @@ interface PGliteDuplexOptions {
160
156
  * weaker durability. Default `true`.
161
157
  */
162
158
  syncToFs?: boolean;
159
+ /**
160
+ * Widen system-catalog "char" columns (OID 18) to text (OID 25) in
161
+ * RowDescription frames. Required for `@prisma/adapter-pg`, which rejects
162
+ * OID 18. Native clients (Prisma CLI engine, psql) need the real OID —
163
+ * `PGliteServer` disables this. Default `true`.
164
+ */
165
+ rewriteSystemCatalogCharOids?: boolean;
163
166
  }
164
167
  /**
165
168
  * Duplex stream that bridges `pg.Client` to an in-process PGlite instance.
@@ -188,6 +191,7 @@ declare class PGliteDuplex extends Duplex {
188
191
  private readonly bridgeId?;
189
192
  private readonly telemetry?;
190
193
  private readonly syncToFs;
194
+ private readonly rewriteSystemCatalogCharOids;
191
195
  private readonly timeout?;
192
196
  private readonly duplexId;
193
197
  /** Incoming bytes framed directly from a queued chunk buffer */
@@ -212,6 +216,9 @@ declare class PGliteDuplex extends Duplex {
212
216
  /** Memoized rollback so concurrent teardown paths (e.g., `_final` then
213
217
  * `_destroy`) don't issue duplicate `ROLLBACK` statements. */
214
218
  private rollbackPromise?;
219
+ private pendingProtocolCleanupBytes;
220
+ private pendingProtocolCleanupCalls;
221
+ private protocolCleanupUnsupported;
215
222
  /** Resolves once the stream has fully torn down (post-`_final` rollback,
216
223
  * post-`_destroy`). Single-shot, mirroring the `'close'` event. */
217
224
  readonly onClose: Promise<void>;
@@ -266,6 +273,9 @@ declare class PGliteDuplex extends Duplex {
266
273
  * waiters behind it).
267
274
  */
268
275
  private runUnderRunExclusive;
276
+ /** Acquire the session, then run `op` under runExclusive without timing —
277
+ * the untimed path shared by startup and the no-telemetry query branch. */
278
+ private runUntimed;
269
279
  /**
270
280
  * Frames and processes regular wire protocol messages.
271
281
  *
@@ -288,6 +298,8 @@ declare class PGliteDuplex extends Duplex {
288
298
  * materializing it.
289
299
  */
290
300
  private flushPipeline;
301
+ private tryContiguousPipelineBatch;
302
+ private concatPipeline;
291
303
  /**
292
304
  * Acquires the session, runs the op under `pglite.runExclusive`, and
293
305
  * updates internal stats and/or publishes diagnostics events when enabled.
@@ -302,10 +314,8 @@ declare class PGliteDuplex extends Duplex {
302
314
  */
303
315
  private runWithTiming;
304
316
  /**
305
- * Sends a message (or pipelined batch) to PGlite and pushes response
306
- * chunks directly to the stream as they arrive. Avoids collecting and
307
- * concatenating for large multi-row responses (e.g., findMany 500 rows
308
- * = ~503 onRawData chunks).
317
+ * Sends a message (or pipelined batch) to PGlite and pushes the raw protocol
318
+ * response to the stream.
309
319
  *
310
320
  * For pipelined Extended Query batches, pass `suppressIntermediateRfq`
311
321
  * so only the final ReadyForQuery reaches the client.
@@ -313,6 +323,7 @@ declare class PGliteDuplex extends Duplex {
313
323
  * Must be called inside runExclusive.
314
324
  */
315
325
  private streamProtocol;
326
+ private clearPGliteProtocolMessages;
316
327
  private acquireSession;
317
328
  /**
318
329
  * Issue `ROLLBACK` against PGlite when the duplex's last observed