@prisma/adapter-neon 7.11.0-dev.1 → 7.11.0-dev.11

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.js CHANGED
@@ -294,14 +294,17 @@ function normalize_array(element_normalizer) {
294
294
  function normalize_numeric(numeric) {
295
295
  return numeric;
296
296
  }
297
+ function expandYear(value) {
298
+ return value.replace(/^(\d{5,})(?=-)/, (_, year) => `+${year.padStart(6, "0")}`);
299
+ }
297
300
  function normalize_date(date) {
298
- return date;
301
+ return expandYear(date);
299
302
  }
300
303
  function normalize_timestamp(time) {
301
- return `${time.replace(" ", "T")}+00:00`;
304
+ return expandYear(`${time.replace(" ", "T")}+00:00`);
302
305
  }
303
306
  function normalize_timestamptz(time) {
304
- return time.replace(" ", "T").replace(/[+-]\d{2}(:\d{2})?$/, "+00:00");
307
+ return expandYear(time.replace(" ", "T").replace(/[+-]\d{2}(:\d{2})?$/, "+00:00"));
305
308
  }
306
309
  function normalize_time(time) {
307
310
  return time;
@@ -316,13 +319,16 @@ function normalize_timez(time) {
316
319
  const pad = (n) => String(n).padStart(2, "0");
317
320
  return `${pad(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}${fraction}`;
318
321
  }
322
+ var SUPPORTED_MONEY_FORMAT = /^(?:(-)[\p{L}\p{Sc}]+|[\p{L}\p{Sc}]+(-)?)(\d{1,3}(?:,\d{3})*)(\.(?!\d{3}$)\d+)?$/u;
319
323
  function normalize_money(money) {
320
- if (!/^-?\$\d{1,3}(,\d{3})*\.\d{2}$/.test(money)) {
324
+ const match = SUPPORTED_MONEY_FORMAT.exec(money);
325
+ if (match === null) {
321
326
  throw new Error(
322
- `Unsupported money format "${money}": only the default lc_monetary format, such as -$1,234.50, is supported`
327
+ `Unsupported money format "${money}": expected a currency symbol directly followed by an amount with "," thousands separators and a "." decimal point, such as -\xA31,234.50`
323
328
  );
324
329
  }
325
- return money.replace(/[^\d.-]/g, "");
330
+ const [, signBeforeSymbol = "", signAfterSymbol = "", integer, fraction = ""] = match;
331
+ return `${signBeforeSymbol}${signAfterSymbol}${integer.replaceAll(",", "")}${fraction}`;
326
332
  }
327
333
  function normalize_xml(xml) {
328
334
  return xml;
@@ -626,6 +632,7 @@ var NeonTransaction = class extends NeonWsQueryable {
626
632
  }
627
633
  closed = false;
628
634
  runningStatements = 0;
635
+ #releaseError;
629
636
  async performIO(query) {
630
637
  if (this.closed) {
631
638
  throw new import_driver_adapter_utils2.DriverAdapterError({
@@ -657,7 +664,7 @@ var NeonTransaction = class extends NeonWsQueryable {
657
664
  if (this.runningStatements > 0) {
658
665
  this.client.release(new Error("Transaction closed with a statement still running"));
659
666
  } else {
660
- this.client.release();
667
+ this.client.release(this.#releaseError);
661
668
  }
662
669
  }
663
670
  }
@@ -669,6 +676,12 @@ var NeonTransaction = class extends NeonWsQueryable {
669
676
  debug(`[js::rollback]`);
670
677
  this.close();
671
678
  }
679
+ onError(error) {
680
+ if (this.#releaseError === void 0 && !isDriverError(error)) {
681
+ this.#releaseError = error instanceof Error ? error : new Error(String(error));
682
+ }
683
+ super.onError(error);
684
+ }
672
685
  async createSavepoint(name2) {
673
686
  await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
674
687
  }
package/dist/index.mjs CHANGED
@@ -257,14 +257,17 @@ function normalize_array(element_normalizer) {
257
257
  function normalize_numeric(numeric) {
258
258
  return numeric;
259
259
  }
260
+ function expandYear(value) {
261
+ return value.replace(/^(\d{5,})(?=-)/, (_, year) => `+${year.padStart(6, "0")}`);
262
+ }
260
263
  function normalize_date(date) {
261
- return date;
264
+ return expandYear(date);
262
265
  }
263
266
  function normalize_timestamp(time) {
264
- return `${time.replace(" ", "T")}+00:00`;
267
+ return expandYear(`${time.replace(" ", "T")}+00:00`);
265
268
  }
266
269
  function normalize_timestamptz(time) {
267
- return time.replace(" ", "T").replace(/[+-]\d{2}(:\d{2})?$/, "+00:00");
270
+ return expandYear(time.replace(" ", "T").replace(/[+-]\d{2}(:\d{2})?$/, "+00:00"));
268
271
  }
269
272
  function normalize_time(time) {
270
273
  return time;
@@ -279,13 +282,16 @@ function normalize_timez(time) {
279
282
  const pad = (n) => String(n).padStart(2, "0");
280
283
  return `${pad(Math.floor(seconds / 3600))}:${pad(Math.floor(seconds / 60) % 60)}:${pad(seconds % 60)}${fraction}`;
281
284
  }
285
+ var SUPPORTED_MONEY_FORMAT = /^(?:(-)[\p{L}\p{Sc}]+|[\p{L}\p{Sc}]+(-)?)(\d{1,3}(?:,\d{3})*)(\.(?!\d{3}$)\d+)?$/u;
282
286
  function normalize_money(money) {
283
- if (!/^-?\$\d{1,3}(,\d{3})*\.\d{2}$/.test(money)) {
287
+ const match = SUPPORTED_MONEY_FORMAT.exec(money);
288
+ if (match === null) {
284
289
  throw new Error(
285
- `Unsupported money format "${money}": only the default lc_monetary format, such as -$1,234.50, is supported`
290
+ `Unsupported money format "${money}": expected a currency symbol directly followed by an amount with "," thousands separators and a "." decimal point, such as -\xA31,234.50`
286
291
  );
287
292
  }
288
- return money.replace(/[^\d.-]/g, "");
293
+ const [, signBeforeSymbol = "", signAfterSymbol = "", integer, fraction = ""] = match;
294
+ return `${signBeforeSymbol}${signAfterSymbol}${integer.replaceAll(",", "")}${fraction}`;
289
295
  }
290
296
  function normalize_xml(xml) {
291
297
  return xml;
@@ -589,6 +595,7 @@ var NeonTransaction = class extends NeonWsQueryable {
589
595
  }
590
596
  closed = false;
591
597
  runningStatements = 0;
598
+ #releaseError;
592
599
  async performIO(query) {
593
600
  if (this.closed) {
594
601
  throw new DriverAdapterError({
@@ -620,7 +627,7 @@ var NeonTransaction = class extends NeonWsQueryable {
620
627
  if (this.runningStatements > 0) {
621
628
  this.client.release(new Error("Transaction closed with a statement still running"));
622
629
  } else {
623
- this.client.release();
630
+ this.client.release(this.#releaseError);
624
631
  }
625
632
  }
626
633
  }
@@ -632,6 +639,12 @@ var NeonTransaction = class extends NeonWsQueryable {
632
639
  debug(`[js::rollback]`);
633
640
  this.close();
634
641
  }
642
+ onError(error) {
643
+ if (this.#releaseError === void 0 && !isDriverError(error)) {
644
+ this.#releaseError = error instanceof Error ? error : new Error(String(error));
645
+ }
646
+ super.onError(error);
647
+ }
635
648
  async createSavepoint(name2) {
636
649
  await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
637
650
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-neon",
3
- "version": "7.11.0-dev.1",
3
+ "version": "7.11.0-dev.11",
4
4
  "description": "Prisma's driver adapter for \"@neondatabase/serverless\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,10 +33,10 @@
33
33
  "dependencies": {
34
34
  "postgres-array": "3.0.4",
35
35
  "@neondatabase/serverless": ">0.6.0 <2",
36
- "@prisma/driver-adapter-utils": "7.11.0-dev.1"
36
+ "@prisma/driver-adapter-utils": "7.11.0-dev.11"
37
37
  },
38
38
  "devDependencies": {
39
- "@prisma/debug": "7.11.0-dev.1"
39
+ "@prisma/debug": "7.11.0-dev.11"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "DEV=true tsx helpers/build.ts",