@prisma/adapter-neon 6.15.0-dev.2 → 6.15.0-dev.21
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 +55 -16
- package/dist/index.mjs +55 -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,51 @@ 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 formatTime(arg);
|
|
372
|
+
case "DATE":
|
|
373
|
+
return formatDate(arg);
|
|
374
|
+
default:
|
|
375
|
+
return formatDateTime(arg);
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
|
-
|
|
378
|
+
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
379
|
+
return Buffer.from(arg, "base64");
|
|
380
|
+
}
|
|
381
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
382
|
+
return Buffer.from(arg);
|
|
383
|
+
}
|
|
384
|
+
if (ArrayBuffer.isView(arg)) {
|
|
385
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
386
|
+
}
|
|
387
|
+
return arg;
|
|
388
|
+
}
|
|
389
|
+
function formatDateTime(date) {
|
|
390
|
+
const pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
391
|
+
const ms = date.getUTCMilliseconds();
|
|
392
|
+
return date.getUTCFullYear() + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate()) + " " + pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (ms ? "." + String(ms).padStart(3, "0") : "");
|
|
393
|
+
}
|
|
394
|
+
function formatDate(date) {
|
|
395
|
+
const pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
396
|
+
return date.getUTCFullYear() + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate());
|
|
397
|
+
}
|
|
398
|
+
function formatTime(date) {
|
|
399
|
+
const pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
400
|
+
const ms = date.getUTCMilliseconds();
|
|
401
|
+
return pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (ms ? "." + String(ms).padStart(3, "0") : "");
|
|
371
402
|
}
|
|
372
403
|
|
|
373
404
|
// src/errors.ts
|
|
@@ -522,12 +553,11 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
522
553
|
this.client = client;
|
|
523
554
|
}
|
|
524
555
|
async performIO(query) {
|
|
525
|
-
const { sql, args
|
|
556
|
+
const { sql, args } = query;
|
|
526
557
|
try {
|
|
527
558
|
const result = await this.client.query(
|
|
528
559
|
{
|
|
529
560
|
text: sql,
|
|
530
|
-
values: fixArrayBufferValues(values),
|
|
531
561
|
rowMode: "array",
|
|
532
562
|
types: {
|
|
533
563
|
// This is the error expected:
|
|
@@ -550,7 +580,7 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
550
580
|
}
|
|
551
581
|
}
|
|
552
582
|
},
|
|
553
|
-
|
|
583
|
+
args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
554
584
|
);
|
|
555
585
|
return result;
|
|
556
586
|
} catch (e) {
|
|
@@ -592,6 +622,10 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
|
|
|
592
622
|
const tag = "[js::startTransaction]";
|
|
593
623
|
debug("%s options: %O", tag, options);
|
|
594
624
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
625
|
+
conn.on("error", (err) => {
|
|
626
|
+
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
627
|
+
this.options?.onConnectionError?.(err);
|
|
628
|
+
});
|
|
595
629
|
try {
|
|
596
630
|
const tx = new NeonTransaction(conn, options);
|
|
597
631
|
await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
|
|
@@ -632,7 +666,12 @@ var PrismaNeonAdapterFactory = class {
|
|
|
632
666
|
provider = "postgres";
|
|
633
667
|
adapterName = name;
|
|
634
668
|
async connect() {
|
|
635
|
-
|
|
669
|
+
const pool = new neon.Pool(this.config);
|
|
670
|
+
pool.on("error", (err) => {
|
|
671
|
+
debug(`Error from pool client: ${err.message} %O`, err);
|
|
672
|
+
this.options?.onPoolError?.(err);
|
|
673
|
+
});
|
|
674
|
+
return new PrismaNeonAdapter(pool, this.options);
|
|
636
675
|
}
|
|
637
676
|
};
|
|
638
677
|
var PrismaNeonHTTPAdapter = class extends NeonQueryable {
|
package/dist/index.mjs
CHANGED
|
@@ -317,20 +317,51 @@ 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 formatTime(arg);
|
|
335
|
+
case "DATE":
|
|
336
|
+
return formatDate(arg);
|
|
337
|
+
default:
|
|
338
|
+
return formatDateTime(arg);
|
|
331
339
|
}
|
|
332
340
|
}
|
|
333
|
-
|
|
341
|
+
if (typeof arg === "string" && argType.scalarType === "bytes") {
|
|
342
|
+
return Buffer.from(arg, "base64");
|
|
343
|
+
}
|
|
344
|
+
if (Array.isArray(arg) && argType.scalarType === "bytes") {
|
|
345
|
+
return Buffer.from(arg);
|
|
346
|
+
}
|
|
347
|
+
if (ArrayBuffer.isView(arg)) {
|
|
348
|
+
return Buffer.from(arg.buffer, arg.byteOffset, arg.byteLength);
|
|
349
|
+
}
|
|
350
|
+
return arg;
|
|
351
|
+
}
|
|
352
|
+
function formatDateTime(date) {
|
|
353
|
+
const pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
354
|
+
const ms = date.getUTCMilliseconds();
|
|
355
|
+
return date.getUTCFullYear() + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate()) + " " + pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (ms ? "." + String(ms).padStart(3, "0") : "");
|
|
356
|
+
}
|
|
357
|
+
function formatDate(date) {
|
|
358
|
+
const pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
359
|
+
return date.getUTCFullYear() + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate());
|
|
360
|
+
}
|
|
361
|
+
function formatTime(date) {
|
|
362
|
+
const pad = (n, z = 2) => String(n).padStart(z, "0");
|
|
363
|
+
const ms = date.getUTCMilliseconds();
|
|
364
|
+
return pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (ms ? "." + String(ms).padStart(3, "0") : "");
|
|
334
365
|
}
|
|
335
366
|
|
|
336
367
|
// src/errors.ts
|
|
@@ -485,12 +516,11 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
485
516
|
this.client = client;
|
|
486
517
|
}
|
|
487
518
|
async performIO(query) {
|
|
488
|
-
const { sql, args
|
|
519
|
+
const { sql, args } = query;
|
|
489
520
|
try {
|
|
490
521
|
const result = await this.client.query(
|
|
491
522
|
{
|
|
492
523
|
text: sql,
|
|
493
|
-
values: fixArrayBufferValues(values),
|
|
494
524
|
rowMode: "array",
|
|
495
525
|
types: {
|
|
496
526
|
// This is the error expected:
|
|
@@ -513,7 +543,7 @@ var NeonWsQueryable = class extends NeonQueryable {
|
|
|
513
543
|
}
|
|
514
544
|
}
|
|
515
545
|
},
|
|
516
|
-
|
|
546
|
+
args.map((arg, i) => mapArg(arg, query.argTypes[i]))
|
|
517
547
|
);
|
|
518
548
|
return result;
|
|
519
549
|
} catch (e) {
|
|
@@ -555,6 +585,10 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
|
|
|
555
585
|
const tag = "[js::startTransaction]";
|
|
556
586
|
debug("%s options: %O", tag, options);
|
|
557
587
|
const conn = await this.client.connect().catch((error) => this.onError(error));
|
|
588
|
+
conn.on("error", (err) => {
|
|
589
|
+
debug(`Error from pool connection: ${err.message} %O`, err);
|
|
590
|
+
this.options?.onConnectionError?.(err);
|
|
591
|
+
});
|
|
558
592
|
try {
|
|
559
593
|
const tx = new NeonTransaction(conn, options);
|
|
560
594
|
await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
|
|
@@ -595,7 +629,12 @@ var PrismaNeonAdapterFactory = class {
|
|
|
595
629
|
provider = "postgres";
|
|
596
630
|
adapterName = name;
|
|
597
631
|
async connect() {
|
|
598
|
-
|
|
632
|
+
const pool = new neon.Pool(this.config);
|
|
633
|
+
pool.on("error", (err) => {
|
|
634
|
+
debug(`Error from pool client: ${err.message} %O`, err);
|
|
635
|
+
this.options?.onPoolError?.(err);
|
|
636
|
+
});
|
|
637
|
+
return new PrismaNeonAdapter(pool, this.options);
|
|
599
638
|
}
|
|
600
639
|
};
|
|
601
640
|
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.21",
|
|
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.21"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@swc/core": "1.11.5",
|