@prisma/adapter-neon 6.15.0-dev.3 → 6.15.0-dev.5
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.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -16
- package/dist/index.mjs +39 -16
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -354,20 +354,35 @@ var customParsers = {
|
|
|
354
354
|
[ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit),
|
|
355
355
|
[ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml)
|
|
356
356
|
};
|
|
357
|
-
function
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
357
|
+
function mapArg(arg, argType) {
|
|
358
|
+
if (arg === null) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
if (Array.isArray(arg) && argType.arity === "list") {
|
|
362
|
+
return arg.map((value) => mapArg(value, argType));
|
|
363
|
+
}
|
|
364
|
+
if (typeof arg === "string" && argType.scalarType === "datetime") {
|
|
365
|
+
arg = new Date(arg);
|
|
366
|
+
}
|
|
367
|
+
if (arg instanceof Date) {
|
|
368
|
+
switch (argType.dbType) {
|
|
369
|
+
case "TIME":
|
|
370
|
+
case "TIMETZ":
|
|
371
|
+
return arg.toISOString().split("T")[1];
|
|
372
|
+
default:
|
|
373
|
+
return arg.toISOString();
|
|
368
374
|
}
|
|
369
375
|
}
|
|
370
|
-
|
|
376
|
+
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
377
|
+
return Buffer.from(arg, "base64");
|
|
378
|
+
}
|
|
379
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
380
|
+
return Buffer.from(arg);
|
|
381
|
+
}
|
|
382
|
+
if (ArrayBuffer.isView(arg)) {
|
|
383
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
384
|
+
}
|
|
385
|
+
return arg;
|
|
371
386
|
}
|
|
372
387
|
|
|
373
388
|
// src/errors.ts
|
|
@@ -522,12 +537,11 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
522
537
|
this.client = client;
|
|
523
538
|
}
|
|
524
539
|
async performIO(query) {
|
|
525
|
-
const { sql, args
|
|
540
|
+
const { sql, args } = query;
|
|
526
541
|
try {
|
|
527
542
|
const result = await this.client.query(
|
|
528
543
|
{
|
|
529
544
|
text: sql,
|
|
530
|
-
values: fixArrayBufferValues(values),
|
|
531
545
|
rowMode: "array",
|
|
532
546
|
types: {
|
|
533
547
|
// This is the error expected:
|
|
@@ -550,7 +564,7 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
550
564
|
}
|
|
551
565
|
}
|
|
552
566
|
},
|
|
553
|
-
|
|
567
|
+
args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
554
568
|
);
|
|
555
569
|
return result;
|
|
556
570
|
} catch (e) {
|
|
@@ -592,6 +606,10 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
|
|
|
592
606
|
const tag = "[js::startTransaction]";
|
|
593
607
|
debug("%s options: %O", tag, options);
|
|
594
608
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
609
|
+
conn.on("error", (err) => {
|
|
610
|
+
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
611
|
+
this.options?.onConnectionError?.(err);
|
|
612
|
+
});
|
|
595
613
|
try {
|
|
596
614
|
const tx = new NeonTransaction(conn, options);
|
|
597
615
|
await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
|
|
@@ -632,7 +650,12 @@ var PrismaNeonAdapterFactory = class {
|
|
|
632
650
|
provider = "postgres";
|
|
633
651
|
adapterName = name;
|
|
634
652
|
async connect() {
|
|
635
|
-
|
|
653
|
+
const pool = new neon.Pool(this.config);
|
|
654
|
+
pool.on("error", (err) => {
|
|
655
|
+
debug(`Error from pool client: ${err.message} %O`, err);
|
|
656
|
+
this.options?.onPoolError?.(err);
|
|
657
|
+
});
|
|
658
|
+
return new PrismaNeonAdapter(pool, this.options);
|
|
636
659
|
}
|
|
637
660
|
};
|
|
638
661
|
var PrismaNeonHTTPAdapter = class extends NeonQueryable {
|
package/dist/index.mjs
CHANGED
|
@@ -317,20 +317,35 @@ var customParsers = {
|
|
|
317
317
|
[ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit),
|
|
318
318
|
[ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml)
|
|
319
319
|
};
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
320
|
+
function mapArg(arg, argType) {
|
|
321
|
+
if (arg === null) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
if (Array.isArray(arg) && argType.arity === "list") {
|
|
325
|
+
return arg.map((value) => mapArg(value, argType));
|
|
326
|
+
}
|
|
327
|
+
if (typeof arg === "string" && argType.scalarType === "datetime") {
|
|
328
|
+
arg = new Date(arg);
|
|
329
|
+
}
|
|
330
|
+
if (arg instanceof Date) {
|
|
331
|
+
switch (argType.dbType) {
|
|
332
|
+
case "TIME":
|
|
333
|
+
case "TIMETZ":
|
|
334
|
+
return arg.toISOString().split("T")[1];
|
|
335
|
+
default:
|
|
336
|
+
return arg.toISOString();
|
|
331
337
|
}
|
|
332
338
|
}
|
|
333
|
-
|
|
339
|
+
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
340
|
+
return Buffer.from(arg, "base64");
|
|
341
|
+
}
|
|
342
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
343
|
+
return Buffer.from(arg);
|
|
344
|
+
}
|
|
345
|
+
if (ArrayBuffer.isView(arg)) {
|
|
346
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
347
|
+
}
|
|
348
|
+
return arg;
|
|
334
349
|
}
|
|
335
350
|
|
|
336
351
|
// src/errors.ts
|
|
@@ -485,12 +500,11 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
485
500
|
this.client = client;
|
|
486
501
|
}
|
|
487
502
|
async performIO(query) {
|
|
488
|
-
const { sql, args
|
|
503
|
+
const { sql, args } = query;
|
|
489
504
|
try {
|
|
490
505
|
const result = await this.client.query(
|
|
491
506
|
{
|
|
492
507
|
text: sql,
|
|
493
|
-
values: fixArrayBufferValues(values),
|
|
494
508
|
rowMode: "array",
|
|
495
509
|
types: {
|
|
496
510
|
// This is the error expected:
|
|
@@ -513,7 +527,7 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
513
527
|
}
|
|
514
528
|
}
|
|
515
529
|
},
|
|
516
|
-
|
|
530
|
+
args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
517
531
|
);
|
|
518
532
|
return result;
|
|
519
533
|
} catch (e) {
|
|
@@ -555,6 +569,10 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
|
|
|
555
569
|
const tag = "[js::startTransaction]";
|
|
556
570
|
debug("%s options: %O", tag, options);
|
|
557
571
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
572
|
+
conn.on("error", (err) => {
|
|
573
|
+
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
574
|
+
this.options?.onConnectionError?.(err);
|
|
575
|
+
});
|
|
558
576
|
try {
|
|
559
577
|
const tx = new NeonTransaction(conn, options);
|
|
560
578
|
await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
|
|
@@ -595,7 +613,12 @@ var PrismaNeonAdapterFactory = class {
|
|
|
595
613
|
provider = "postgres";
|
|
596
614
|
adapterName = name;
|
|
597
615
|
async connect() {
|
|
598
|
-
|
|
616
|
+
const pool = new neon.Pool(this.config);
|
|
617
|
+
pool.on("error", (err) => {
|
|
618
|
+
debug(`Error from pool client: ${err.message} %O`, err);
|
|
619
|
+
this.options?.onPoolError?.(err);
|
|
620
|
+
});
|
|
621
|
+
return new PrismaNeonAdapter(pool, this.options);
|
|
599
622
|
}
|
|
600
623
|
};
|
|
601
624
|
var PrismaNeonHTTPAdapter = class extends NeonQueryable {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-neon",
|
|
3
|
-
"version": "6.15.0-dev.
|
|
3
|
+
"version": "6.15.0-dev.5",
|
|
4
4
|
"description": "Prisma's driver adapter for \"@neondatabase/serverless\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"postgres-array": "3.0.4",
|
|
35
35
|
"@neondatabase/serverless": ">0.6.0 <2",
|
|
36
|
-
"@prisma/driver-adapter-utils": "6.15.0-dev.
|
|
36
|
+
"@prisma/driver-adapter-utils": "6.15.0-dev.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@swc/core": "1.11.5",
|