@prisma/client-engine-runtime 7.2.0-integration-engines-7-2-0-3-aqrln-zpupkzknszlw-04d61c41ec1a025cabe14093fa3121a5f45040ab.1 → 7.3.0-integration-fix-6-19-0-cloudflare-accelerate-engine.1

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 CHANGED
@@ -2,24 +2,15 @@ import { ArgType } from '@prisma/driver-adapter-utils';
2
2
  import { Arity } from '@prisma/driver-adapter-utils';
3
3
  import { ConnectionInfo } from '@prisma/driver-adapter-utils';
4
4
  import { Context } from '@opentelemetry/api';
5
- import { Decimal } from '@prisma/client-runtime-utils';
5
+ import { Decimal } from 'decimal.js';
6
6
  import type { IsolationLevel } from '@prisma/driver-adapter-utils';
7
7
  import { Span } from '@opentelemetry/api';
8
8
  import { SpanOptions } from '@opentelemetry/api';
9
- import type { SqlCommenterContext } from '@prisma/sqlcommenter';
10
- import type { SqlCommenterPlugin } from '@prisma/sqlcommenter';
11
- import type { SqlCommenterQueryInfo } from '@prisma/sqlcommenter';
12
9
  import { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
13
10
  import { SqlQueryable } from '@prisma/driver-adapter-utils';
14
11
  import { SqlResultSet } from '@prisma/driver-adapter-utils';
15
12
  import { Transaction } from '@prisma/driver-adapter-utils';
16
13
 
17
- /**
18
- * Applies SQL commenter plugins and returns the merged key-value pairs.
19
- * Keys with undefined values are filtered out.
20
- */
21
- export declare function applySqlCommenters(plugins: SqlCommenterPlugin[], context: SqlCommenterContext): Record<string, string>;
22
-
23
14
  export declare type BatchResponse = MultiBatchResponse | CompactedBatchResponse;
24
15
 
25
16
  export declare type BigIntTaggedValue = {
@@ -47,11 +38,8 @@ export declare type CompactedBatchResponse = {
47
38
  */
48
39
  export declare function convertCompactedRows(rows: {}[], compiledBatch: CompactedBatchResponse): unknown[];
49
40
 
50
- export declare class DataMapperError extends UserFacingError {
41
+ export declare class DataMapperError extends Error {
51
42
  name: string;
52
- constructor(message: string, options?: {
53
- cause?: unknown;
54
- });
55
43
  }
56
44
 
57
45
  export declare type DataRule = {
@@ -246,7 +234,7 @@ export declare type QueryEvent = {
246
234
 
247
235
  export declare class QueryInterpreter {
248
236
  #private;
249
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, sqlCommenter, }: QueryInterpreterOptions);
237
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, }: QueryInterpreterOptions);
250
238
  static forSql(options: {
251
239
  transactionManager: QueryInterpreterTransactionManager;
252
240
  placeholderValues: Record<string, unknown>;
@@ -254,7 +242,6 @@ export declare class QueryInterpreter {
254
242
  tracingHelper: TracingHelper;
255
243
  provider?: SchemaProvider;
256
244
  connectionInfo?: ConnectionInfo;
257
- sqlCommenter?: QueryInterpreterSqlCommenter;
258
245
  }): QueryInterpreter;
259
246
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
260
247
  private interpretNode;
@@ -269,12 +256,6 @@ export declare type QueryInterpreterOptions = {
269
256
  rawSerializer?: (results: SqlResultSet) => Value;
270
257
  provider?: SchemaProvider;
271
258
  connectionInfo?: ConnectionInfo;
272
- sqlCommenter?: QueryInterpreterSqlCommenter;
273
- };
274
-
275
- export declare type QueryInterpreterSqlCommenter = {
276
- plugins: SqlCommenterPlugin[];
277
- queryInfo: SqlCommenterQueryInfo;
278
259
  };
279
260
 
280
261
  export declare type QueryInterpreterTransactionManager = {
package/dist/index.d.ts CHANGED
@@ -2,24 +2,15 @@ import { ArgType } from '@prisma/driver-adapter-utils';
2
2
  import { Arity } from '@prisma/driver-adapter-utils';
3
3
  import { ConnectionInfo } from '@prisma/driver-adapter-utils';
4
4
  import { Context } from '@opentelemetry/api';
5
- import { Decimal } from '@prisma/client-runtime-utils';
5
+ import { Decimal } from 'decimal.js';
6
6
  import type { IsolationLevel } from '@prisma/driver-adapter-utils';
7
7
  import { Span } from '@opentelemetry/api';
8
8
  import { SpanOptions } from '@opentelemetry/api';
9
- import type { SqlCommenterContext } from '@prisma/sqlcommenter';
10
- import type { SqlCommenterPlugin } from '@prisma/sqlcommenter';
11
- import type { SqlCommenterQueryInfo } from '@prisma/sqlcommenter';
12
9
  import { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
13
10
  import { SqlQueryable } from '@prisma/driver-adapter-utils';
14
11
  import { SqlResultSet } from '@prisma/driver-adapter-utils';
15
12
  import { Transaction } from '@prisma/driver-adapter-utils';
16
13
 
17
- /**
18
- * Applies SQL commenter plugins and returns the merged key-value pairs.
19
- * Keys with undefined values are filtered out.
20
- */
21
- export declare function applySqlCommenters(plugins: SqlCommenterPlugin[], context: SqlCommenterContext): Record<string, string>;
22
-
23
14
  export declare type BatchResponse = MultiBatchResponse | CompactedBatchResponse;
24
15
 
25
16
  export declare type BigIntTaggedValue = {
@@ -47,11 +38,8 @@ export declare type CompactedBatchResponse = {
47
38
  */
48
39
  export declare function convertCompactedRows(rows: {}[], compiledBatch: CompactedBatchResponse): unknown[];
49
40
 
50
- export declare class DataMapperError extends UserFacingError {
41
+ export declare class DataMapperError extends Error {
51
42
  name: string;
52
- constructor(message: string, options?: {
53
- cause?: unknown;
54
- });
55
43
  }
56
44
 
57
45
  export declare type DataRule = {
@@ -246,7 +234,7 @@ export declare type QueryEvent = {
246
234
 
247
235
  export declare class QueryInterpreter {
248
236
  #private;
249
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, sqlCommenter, }: QueryInterpreterOptions);
237
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, }: QueryInterpreterOptions);
250
238
  static forSql(options: {
251
239
  transactionManager: QueryInterpreterTransactionManager;
252
240
  placeholderValues: Record<string, unknown>;
@@ -254,7 +242,6 @@ export declare class QueryInterpreter {
254
242
  tracingHelper: TracingHelper;
255
243
  provider?: SchemaProvider;
256
244
  connectionInfo?: ConnectionInfo;
257
- sqlCommenter?: QueryInterpreterSqlCommenter;
258
245
  }): QueryInterpreter;
259
246
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
260
247
  private interpretNode;
@@ -269,12 +256,6 @@ export declare type QueryInterpreterOptions = {
269
256
  rawSerializer?: (results: SqlResultSet) => Value;
270
257
  provider?: SchemaProvider;
271
258
  connectionInfo?: ConnectionInfo;
272
- sqlCommenter?: QueryInterpreterSqlCommenter;
273
- };
274
-
275
- export declare type QueryInterpreterSqlCommenter = {
276
- plugins: SqlCommenterPlugin[];
277
- queryInfo: SqlCommenterQueryInfo;
278
259
  };
279
260
 
280
261
  export declare type QueryInterpreterTransactionManager = {
package/dist/index.js CHANGED
@@ -35,7 +35,6 @@ __export(index_exports, {
35
35
  TransactionManager: () => TransactionManager,
36
36
  TransactionManagerError: () => TransactionManagerError,
37
37
  UserFacingError: () => UserFacingError,
38
- applySqlCommenters: () => applySqlCommenters,
39
38
  convertCompactedRows: () => convertCompactedRows,
40
39
  deserializeJsonResponse: () => deserializeJsonResponse,
41
40
  doKeysMatch: () => doKeysMatch,
@@ -50,10 +49,10 @@ __export(index_exports, {
50
49
  module.exports = __toCommonJS(index_exports);
51
50
 
52
51
  // src/json-protocol.ts
53
- var import_client_runtime_utils2 = require("@prisma/client-runtime-utils");
52
+ var import_decimal2 = require("decimal.js");
54
53
 
55
54
  // src/utils.ts
56
- var import_client_runtime_utils = require("@prisma/client-runtime-utils");
55
+ var import_decimal = __toESM(require("decimal.js"));
57
56
  function assertNever(_, message) {
58
57
  throw new Error(message);
59
58
  }
@@ -68,7 +67,7 @@ function doKeysMatch(lhs, rhs) {
68
67
  if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
69
68
  return lhs[key] === rhs[key];
70
69
  }
71
- if (import_client_runtime_utils.Decimal.isDecimal(lhs[key]) || import_client_runtime_utils.Decimal.isDecimal(rhs[key])) {
70
+ if (import_decimal.default.isDecimal(lhs[key]) || import_decimal.default.isDecimal(rhs[key])) {
72
71
  const lhsDecimal = asDecimal(lhs[key]);
73
72
  const rhsDecimal = asDecimal(rhs[key]);
74
73
  return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
@@ -87,10 +86,10 @@ function doKeysMatch(lhs, rhs) {
87
86
  });
88
87
  }
89
88
  function asDecimal(value) {
90
- if (import_client_runtime_utils.Decimal.isDecimal(value)) {
89
+ if (import_decimal.default.isDecimal(value)) {
91
90
  return value;
92
91
  } else if (typeof value === "number" || typeof value === "string") {
93
- return new import_client_runtime_utils.Decimal(value);
92
+ return new import_decimal.default(value);
94
93
  } else {
95
94
  return;
96
95
  }
@@ -179,7 +178,7 @@ function normalizeTaggedValue({ $type, value }) {
179
178
  case "DateTime":
180
179
  return { $type, value: new Date(value).toISOString() };
181
180
  case "Decimal":
182
- return { $type, value: String(new import_client_runtime_utils2.Decimal(value)) };
181
+ return { $type, value: String(new import_decimal2.Decimal(value)) };
183
182
  case "Json":
184
183
  return { $type, value: JSON.stringify(JSON.parse(value)) };
185
184
  default:
@@ -222,7 +221,7 @@ function deserializeTaggedValue({ $type, value }) {
222
221
  case "DateTime":
223
222
  return new Date(value);
224
223
  case "Decimal":
225
- return new import_client_runtime_utils2.Decimal(value);
224
+ return new import_decimal2.Decimal(value);
226
225
  case "Json":
227
226
  return JSON.parse(value);
228
227
  default:
@@ -300,8 +299,6 @@ function getErrorCode(err) {
300
299
  return "P2002";
301
300
  case "ForeignKeyConstraintViolation":
302
301
  return "P2003";
303
- case "InvalidInputValue":
304
- return "P2007";
305
302
  case "UnsupportedNativeDataType":
306
303
  return "P2010";
307
304
  case "NullConstraintViolation":
@@ -398,8 +395,6 @@ function renderErrorMessage(err) {
398
395
  return `Error in external connector (id ${err.cause.id})`;
399
396
  case "TooManyConnections":
400
397
  return `Too many database connections opened: ${err.cause.cause}`;
401
- case "InvalidInputValue":
402
- return `Invalid input value: ${err.cause.message}`;
403
398
  case "sqlite":
404
399
  case "postgres":
405
400
  case "mysql":
@@ -448,12 +443,9 @@ function convertCompactedRows(rows, compiledBatch) {
448
443
  }
449
444
 
450
445
  // src/interpreter/data-mapper.ts
451
- var import_client_runtime_utils3 = require("@prisma/client-runtime-utils");
452
- var DataMapperError = class extends UserFacingError {
446
+ var import_decimal3 = __toESM(require("decimal.js"));
447
+ var DataMapperError = class extends Error {
453
448
  name = "DataMapperError";
454
- constructor(message, options) {
455
- super(message, "P2023", options);
456
- }
457
449
  };
458
450
  function applyDataMap(data, structure, enums) {
459
451
  switch (structure.type) {
@@ -613,7 +605,7 @@ function mapValue(value, columnName, scalarType, enums) {
613
605
  throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
614
606
  }
615
607
  case "decimal":
616
- if (typeof value !== "number" && typeof value !== "string" && !import_client_runtime_utils3.Decimal.isDecimal(value)) {
608
+ if (typeof value !== "number" && typeof value !== "string" && !import_decimal3.default.isDecimal(value)) {
617
609
  throw new DataMapperError(`Expected a decimal in column '${columnName}', got ${typeof value}: ${value}`);
618
610
  }
619
611
  return { $type: "Decimal", value };
@@ -699,43 +691,6 @@ function normalizeDateTime(dt) {
699
691
  return dtWithTz;
700
692
  }
701
693
 
702
- // src/sql-commenter.ts
703
- function formatSqlComment(tags) {
704
- const entries = Object.entries(tags);
705
- if (entries.length === 0) {
706
- return "";
707
- }
708
- entries.sort(([a], [b]) => a.localeCompare(b));
709
- const parts = entries.map(([key, value]) => {
710
- const encodedKey = encodeURIComponent(key);
711
- const encodedValue = encodeURIComponent(value).replace(/'/g, "\\'");
712
- return `${encodedKey}='${encodedValue}'`;
713
- });
714
- return `/*${parts.join(",")}*/`;
715
- }
716
- function applySqlCommenters(plugins, context) {
717
- const merged = {};
718
- for (const plugin of plugins) {
719
- const tags = plugin(context);
720
- for (const [key, value] of Object.entries(tags)) {
721
- if (value !== void 0) {
722
- merged[key] = value;
723
- }
724
- }
725
- }
726
- return merged;
727
- }
728
- function buildSqlComment(plugins, context) {
729
- const tags = applySqlCommenters(plugins, context);
730
- return formatSqlComment(tags);
731
- }
732
- function appendSqlComment(sql, comment) {
733
- if (!comment) {
734
- return sql;
735
- }
736
- return `${sql} ${comment}`;
737
- }
738
-
739
694
  // src/tracing.ts
740
695
  var import_api = require("@opentelemetry/api");
741
696
  var noopTracingHelper = {
@@ -1486,8 +1441,7 @@ var QueryInterpreter = class _QueryInterpreter {
1486
1441
  #serializer;
1487
1442
  #rawSerializer;
1488
1443
  #provider;
1489
- #connectionInfo;
1490
- #sqlCommenter;
1444
+ #connectioInfo;
1491
1445
  constructor({
1492
1446
  transactionManager,
1493
1447
  placeholderValues,
@@ -1496,8 +1450,7 @@ var QueryInterpreter = class _QueryInterpreter {
1496
1450
  serializer,
1497
1451
  rawSerializer,
1498
1452
  provider,
1499
- connectionInfo,
1500
- sqlCommenter
1453
+ connectionInfo
1501
1454
  }) {
1502
1455
  this.#transactionManager = transactionManager;
1503
1456
  this.#placeholderValues = placeholderValues;
@@ -1506,8 +1459,7 @@ var QueryInterpreter = class _QueryInterpreter {
1506
1459
  this.#serializer = serializer;
1507
1460
  this.#rawSerializer = rawSerializer ?? serializer;
1508
1461
  this.#provider = provider;
1509
- this.#connectionInfo = connectionInfo;
1510
- this.#sqlCommenter = sqlCommenter;
1462
+ this.#connectioInfo = connectionInfo;
1511
1463
  }
1512
1464
  static forSql(options) {
1513
1465
  return new _QueryInterpreter({
@@ -1518,8 +1470,7 @@ var QueryInterpreter = class _QueryInterpreter {
1518
1470
  serializer: serializeSql,
1519
1471
  rawSerializer: serializeRawSql,
1520
1472
  provider: options.provider,
1521
- connectionInfo: options.connectionInfo,
1522
- sqlCommenter: options.sqlCommenter
1473
+ connectionInfo: options.connectionInfo
1523
1474
  });
1524
1475
  }
1525
1476
  async run(queryPlan, queryable) {
@@ -1583,11 +1534,10 @@ var QueryInterpreter = class _QueryInterpreter {
1583
1534
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1584
1535
  let sum = 0;
1585
1536
  for (const query of queries) {
1586
- const commentedQuery = this.#applyComments(query);
1587
1537
  sum += await this.#withQuerySpanAndEvent(
1588
- commentedQuery,
1538
+ query,
1589
1539
  queryable,
1590
- () => queryable.executeRaw(commentedQuery).catch(
1540
+ () => queryable.executeRaw(query).catch(
1591
1541
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1592
1542
  )
1593
1543
  );
@@ -1598,11 +1548,10 @@ var QueryInterpreter = class _QueryInterpreter {
1598
1548
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1599
1549
  let results;
1600
1550
  for (const query of queries) {
1601
- const commentedQuery = this.#applyComments(query);
1602
1551
  const result = await this.#withQuerySpanAndEvent(
1603
- commentedQuery,
1552
+ query,
1604
1553
  queryable,
1605
- () => queryable.queryRaw(commentedQuery).catch(
1554
+ () => queryable.queryRaw(query).catch(
1606
1555
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1607
1556
  )
1608
1557
  );
@@ -1724,8 +1673,8 @@ var QueryInterpreter = class _QueryInterpreter {
1724
1673
  }
1725
1674
  }
1726
1675
  #maxChunkSize() {
1727
- if (this.#connectionInfo?.maxBindValues !== void 0) {
1728
- return this.#connectionInfo.maxBindValues;
1676
+ if (this.#connectioInfo?.maxBindValues !== void 0) {
1677
+ return this.#connectioInfo.maxBindValues;
1729
1678
  }
1730
1679
  return this.#providerMaxChunkSize();
1731
1680
  }
@@ -1760,22 +1709,6 @@ var QueryInterpreter = class _QueryInterpreter {
1760
1709
  onQuery: this.#onQuery
1761
1710
  });
1762
1711
  }
1763
- #applyComments(query) {
1764
- if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
1765
- return query;
1766
- }
1767
- const comment = buildSqlComment(this.#sqlCommenter.plugins, {
1768
- query: this.#sqlCommenter.queryInfo,
1769
- sql: query.sql
1770
- });
1771
- if (!comment) {
1772
- return query;
1773
- }
1774
- return {
1775
- ...query,
1776
- sql: appendSqlComment(query.sql, comment)
1777
- };
1778
- }
1779
1712
  };
1780
1713
  function isEmpty(value) {
1781
1714
  if (Array.isArray(value)) {
@@ -1878,7 +1811,7 @@ function evalFieldOperation(op, value, scope, generators) {
1878
1811
  }
1879
1812
 
1880
1813
  // src/raw-json-protocol.ts
1881
- var import_client_runtime_utils4 = require("@prisma/client-runtime-utils");
1814
+ var import_decimal4 = __toESM(require("decimal.js"));
1882
1815
  function normalizeRawJsonProtocolResponse(response) {
1883
1816
  for (let i = 0; i < response.rows.length; i++) {
1884
1817
  const row = response.rows[i];
@@ -1896,7 +1829,7 @@ function normalizeValue(type, value) {
1896
1829
  case "bigint":
1897
1830
  return String(BigInt(value));
1898
1831
  case "decimal":
1899
- return String(new import_client_runtime_utils4.Decimal(value));
1832
+ return String(new import_decimal4.default(value));
1900
1833
  case "bigint-array":
1901
1834
  return value.map((v) => normalizeValue("bigint", v));
1902
1835
  case "decimal-array":
@@ -1918,13 +1851,6 @@ async function randomUUID() {
1918
1851
  return crypto.randomUUID();
1919
1852
  }
1920
1853
 
1921
- // src/web-platform.ts
1922
- async function once(target, event) {
1923
- return new Promise((resolve) => {
1924
- target.addEventListener(event, resolve, { once: true });
1925
- });
1926
- }
1927
-
1928
1854
  // src/transaction-manager/transaction-manager-error.ts
1929
1855
  var TransactionManagerError = class extends UserFacingError {
1930
1856
  name = "TransactionManagerError";
@@ -2040,19 +1966,15 @@ var TransactionManager = class {
2040
1966
  startedAt: Date.now(),
2041
1967
  transaction: void 0
2042
1968
  };
2043
- const abortController = new AbortController();
2044
- const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
2045
- startTimer?.unref?.();
2046
- const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
2047
- transaction.transaction = await Promise.race([
2048
- startTransactionPromise.finally(() => clearTimeout(startTimer)),
2049
- once(abortController.signal, "abort").then(() => void 0)
2050
- ]);
2051
1969
  this.transactions.set(transaction.id, transaction);
1970
+ let hasTimedOut = false;
1971
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1972
+ startTimer?.unref?.();
1973
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1974
+ clearTimeout(startTimer);
2052
1975
  switch (transaction.status) {
2053
1976
  case "waiting":
2054
- if (abortController.signal.aborted) {
2055
- void startTransactionPromise.then((tx) => tx.rollback()).catch((e) => debug("error in discarded transaction:", e));
1977
+ if (hasTimedOut) {
2056
1978
  await this.#closeTransaction(transaction, "timed_out");
2057
1979
  throw new TransactionStartTimeoutError();
2058
1980
  }
@@ -2148,13 +2070,8 @@ var TransactionManager = class {
2148
2070
  await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
2149
2071
  } else {
2150
2072
  const query = COMMIT_QUERY();
2151
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query)).then(
2152
- () => tx.transaction.commit(),
2153
- (err) => {
2154
- const fail = () => Promise.reject(err);
2155
- return tx.transaction.rollback().then(fail, fail);
2156
- }
2157
- );
2073
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2074
+ await tx.transaction.commit();
2158
2075
  }
2159
2076
  } else if (tx.transaction) {
2160
2077
  if (tx.transaction.options.usePhantomQuery) {
@@ -2165,11 +2082,8 @@ var TransactionManager = class {
2165
2082
  );
2166
2083
  } else {
2167
2084
  const query = ROLLBACK_QUERY();
2168
- try {
2169
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2170
- } finally {
2171
- await tx.transaction.rollback();
2172
- }
2085
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2086
+ await tx.transaction.rollback();
2173
2087
  }
2174
2088
  }
2175
2089
  } finally {
@@ -2224,7 +2138,6 @@ function createTimeoutIfDefined(cb, ms) {
2224
2138
  TransactionManager,
2225
2139
  TransactionManagerError,
2226
2140
  UserFacingError,
2227
- applySqlCommenters,
2228
2141
  convertCompactedRows,
2229
2142
  deserializeJsonResponse,
2230
2143
  doKeysMatch,
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/json-protocol.ts
2
- import { Decimal as Decimal2 } from "@prisma/client-runtime-utils";
2
+ import { Decimal as Decimal2 } from "decimal.js";
3
3
 
4
4
  // src/utils.ts
5
- import { Decimal } from "@prisma/client-runtime-utils";
5
+ import Decimal from "decimal.js";
6
6
  function assertNever(_, message) {
7
7
  throw new Error(message);
8
8
  }
@@ -249,8 +249,6 @@ function getErrorCode(err) {
249
249
  return "P2002";
250
250
  case "ForeignKeyConstraintViolation":
251
251
  return "P2003";
252
- case "InvalidInputValue":
253
- return "P2007";
254
252
  case "UnsupportedNativeDataType":
255
253
  return "P2010";
256
254
  case "NullConstraintViolation":
@@ -347,8 +345,6 @@ function renderErrorMessage(err) {
347
345
  return `Error in external connector (id ${err.cause.id})`;
348
346
  case "TooManyConnections":
349
347
  return `Too many database connections opened: ${err.cause.cause}`;
350
- case "InvalidInputValue":
351
- return `Invalid input value: ${err.cause.message}`;
352
348
  case "sqlite":
353
349
  case "postgres":
354
350
  case "mysql":
@@ -397,12 +393,9 @@ function convertCompactedRows(rows, compiledBatch) {
397
393
  }
398
394
 
399
395
  // src/interpreter/data-mapper.ts
400
- import { Decimal as Decimal3 } from "@prisma/client-runtime-utils";
401
- var DataMapperError = class extends UserFacingError {
396
+ import Decimal3 from "decimal.js";
397
+ var DataMapperError = class extends Error {
402
398
  name = "DataMapperError";
403
- constructor(message, options) {
404
- super(message, "P2023", options);
405
- }
406
399
  };
407
400
  function applyDataMap(data, structure, enums) {
408
401
  switch (structure.type) {
@@ -648,43 +641,6 @@ function normalizeDateTime(dt) {
648
641
  return dtWithTz;
649
642
  }
650
643
 
651
- // src/sql-commenter.ts
652
- function formatSqlComment(tags) {
653
- const entries = Object.entries(tags);
654
- if (entries.length === 0) {
655
- return "";
656
- }
657
- entries.sort(([a], [b]) => a.localeCompare(b));
658
- const parts = entries.map(([key, value]) => {
659
- const encodedKey = encodeURIComponent(key);
660
- const encodedValue = encodeURIComponent(value).replace(/'/g, "\\'");
661
- return `${encodedKey}='${encodedValue}'`;
662
- });
663
- return `/*${parts.join(",")}*/`;
664
- }
665
- function applySqlCommenters(plugins, context) {
666
- const merged = {};
667
- for (const plugin of plugins) {
668
- const tags = plugin(context);
669
- for (const [key, value] of Object.entries(tags)) {
670
- if (value !== void 0) {
671
- merged[key] = value;
672
- }
673
- }
674
- }
675
- return merged;
676
- }
677
- function buildSqlComment(plugins, context) {
678
- const tags = applySqlCommenters(plugins, context);
679
- return formatSqlComment(tags);
680
- }
681
- function appendSqlComment(sql, comment) {
682
- if (!comment) {
683
- return sql;
684
- }
685
- return `${sql} ${comment}`;
686
- }
687
-
688
644
  // src/tracing.ts
689
645
  import { SpanKind } from "@opentelemetry/api";
690
646
  var noopTracingHelper = {
@@ -1435,8 +1391,7 @@ var QueryInterpreter = class _QueryInterpreter {
1435
1391
  #serializer;
1436
1392
  #rawSerializer;
1437
1393
  #provider;
1438
- #connectionInfo;
1439
- #sqlCommenter;
1394
+ #connectioInfo;
1440
1395
  constructor({
1441
1396
  transactionManager,
1442
1397
  placeholderValues,
@@ -1445,8 +1400,7 @@ var QueryInterpreter = class _QueryInterpreter {
1445
1400
  serializer,
1446
1401
  rawSerializer,
1447
1402
  provider,
1448
- connectionInfo,
1449
- sqlCommenter
1403
+ connectionInfo
1450
1404
  }) {
1451
1405
  this.#transactionManager = transactionManager;
1452
1406
  this.#placeholderValues = placeholderValues;
@@ -1455,8 +1409,7 @@ var QueryInterpreter = class _QueryInterpreter {
1455
1409
  this.#serializer = serializer;
1456
1410
  this.#rawSerializer = rawSerializer ?? serializer;
1457
1411
  this.#provider = provider;
1458
- this.#connectionInfo = connectionInfo;
1459
- this.#sqlCommenter = sqlCommenter;
1412
+ this.#connectioInfo = connectionInfo;
1460
1413
  }
1461
1414
  static forSql(options) {
1462
1415
  return new _QueryInterpreter({
@@ -1467,8 +1420,7 @@ var QueryInterpreter = class _QueryInterpreter {
1467
1420
  serializer: serializeSql,
1468
1421
  rawSerializer: serializeRawSql,
1469
1422
  provider: options.provider,
1470
- connectionInfo: options.connectionInfo,
1471
- sqlCommenter: options.sqlCommenter
1423
+ connectionInfo: options.connectionInfo
1472
1424
  });
1473
1425
  }
1474
1426
  async run(queryPlan, queryable) {
@@ -1532,11 +1484,10 @@ var QueryInterpreter = class _QueryInterpreter {
1532
1484
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1533
1485
  let sum = 0;
1534
1486
  for (const query of queries) {
1535
- const commentedQuery = this.#applyComments(query);
1536
1487
  sum += await this.#withQuerySpanAndEvent(
1537
- commentedQuery,
1488
+ query,
1538
1489
  queryable,
1539
- () => queryable.executeRaw(commentedQuery).catch(
1490
+ () => queryable.executeRaw(query).catch(
1540
1491
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1541
1492
  )
1542
1493
  );
@@ -1547,11 +1498,10 @@ var QueryInterpreter = class _QueryInterpreter {
1547
1498
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1548
1499
  let results;
1549
1500
  for (const query of queries) {
1550
- const commentedQuery = this.#applyComments(query);
1551
1501
  const result = await this.#withQuerySpanAndEvent(
1552
- commentedQuery,
1502
+ query,
1553
1503
  queryable,
1554
- () => queryable.queryRaw(commentedQuery).catch(
1504
+ () => queryable.queryRaw(query).catch(
1555
1505
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1556
1506
  )
1557
1507
  );
@@ -1673,8 +1623,8 @@ var QueryInterpreter = class _QueryInterpreter {
1673
1623
  }
1674
1624
  }
1675
1625
  #maxChunkSize() {
1676
- if (this.#connectionInfo?.maxBindValues !== void 0) {
1677
- return this.#connectionInfo.maxBindValues;
1626
+ if (this.#connectioInfo?.maxBindValues !== void 0) {
1627
+ return this.#connectioInfo.maxBindValues;
1678
1628
  }
1679
1629
  return this.#providerMaxChunkSize();
1680
1630
  }
@@ -1709,22 +1659,6 @@ var QueryInterpreter = class _QueryInterpreter {
1709
1659
  onQuery: this.#onQuery
1710
1660
  });
1711
1661
  }
1712
- #applyComments(query) {
1713
- if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
1714
- return query;
1715
- }
1716
- const comment = buildSqlComment(this.#sqlCommenter.plugins, {
1717
- query: this.#sqlCommenter.queryInfo,
1718
- sql: query.sql
1719
- });
1720
- if (!comment) {
1721
- return query;
1722
- }
1723
- return {
1724
- ...query,
1725
- sql: appendSqlComment(query.sql, comment)
1726
- };
1727
- }
1728
1662
  };
1729
1663
  function isEmpty(value) {
1730
1664
  if (Array.isArray(value)) {
@@ -1827,7 +1761,7 @@ function evalFieldOperation(op, value, scope, generators) {
1827
1761
  }
1828
1762
 
1829
1763
  // src/raw-json-protocol.ts
1830
- import { Decimal as Decimal4 } from "@prisma/client-runtime-utils";
1764
+ import Decimal4 from "decimal.js";
1831
1765
  function normalizeRawJsonProtocolResponse(response) {
1832
1766
  for (let i = 0; i < response.rows.length; i++) {
1833
1767
  const row = response.rows[i];
@@ -1867,13 +1801,6 @@ async function randomUUID() {
1867
1801
  return crypto.randomUUID();
1868
1802
  }
1869
1803
 
1870
- // src/web-platform.ts
1871
- async function once(target, event) {
1872
- return new Promise((resolve) => {
1873
- target.addEventListener(event, resolve, { once: true });
1874
- });
1875
- }
1876
-
1877
1804
  // src/transaction-manager/transaction-manager-error.ts
1878
1805
  var TransactionManagerError = class extends UserFacingError {
1879
1806
  name = "TransactionManagerError";
@@ -1989,19 +1916,15 @@ var TransactionManager = class {
1989
1916
  startedAt: Date.now(),
1990
1917
  transaction: void 0
1991
1918
  };
1992
- const abortController = new AbortController();
1993
- const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
1994
- startTimer?.unref?.();
1995
- const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1996
- transaction.transaction = await Promise.race([
1997
- startTransactionPromise.finally(() => clearTimeout(startTimer)),
1998
- once(abortController.signal, "abort").then(() => void 0)
1999
- ]);
2000
1919
  this.transactions.set(transaction.id, transaction);
1920
+ let hasTimedOut = false;
1921
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1922
+ startTimer?.unref?.();
1923
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1924
+ clearTimeout(startTimer);
2001
1925
  switch (transaction.status) {
2002
1926
  case "waiting":
2003
- if (abortController.signal.aborted) {
2004
- void startTransactionPromise.then((tx) => tx.rollback()).catch((e) => debug("error in discarded transaction:", e));
1927
+ if (hasTimedOut) {
2005
1928
  await this.#closeTransaction(transaction, "timed_out");
2006
1929
  throw new TransactionStartTimeoutError();
2007
1930
  }
@@ -2097,13 +2020,8 @@ var TransactionManager = class {
2097
2020
  await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
2098
2021
  } else {
2099
2022
  const query = COMMIT_QUERY();
2100
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query)).then(
2101
- () => tx.transaction.commit(),
2102
- (err) => {
2103
- const fail = () => Promise.reject(err);
2104
- return tx.transaction.rollback().then(fail, fail);
2105
- }
2106
- );
2023
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2024
+ await tx.transaction.commit();
2107
2025
  }
2108
2026
  } else if (tx.transaction) {
2109
2027
  if (tx.transaction.options.usePhantomQuery) {
@@ -2114,11 +2032,8 @@ var TransactionManager = class {
2114
2032
  );
2115
2033
  } else {
2116
2034
  const query = ROLLBACK_QUERY();
2117
- try {
2118
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2119
- } finally {
2120
- await tx.transaction.rollback();
2121
- }
2035
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2036
+ await tx.transaction.rollback();
2122
2037
  }
2123
2038
  }
2124
2039
  } finally {
@@ -2172,7 +2087,6 @@ export {
2172
2087
  TransactionManager,
2173
2088
  TransactionManagerError,
2174
2089
  UserFacingError,
2175
- applySqlCommenters,
2176
2090
  convertCompactedRows,
2177
2091
  deserializeJsonResponse,
2178
2092
  doKeysMatch,
@@ -1,10 +1,6 @@
1
1
  import { ResultNode } from '../query-plan';
2
- import { UserFacingError } from '../user-facing-error';
3
2
  import { Value } from './scope';
4
- export declare class DataMapperError extends UserFacingError {
3
+ export declare class DataMapperError extends Error {
5
4
  name: string;
6
- constructor(message: string, options?: {
7
- cause?: unknown;
8
- });
9
5
  }
10
6
  export declare function applyDataMap(data: Value, structure: ResultNode, enums: Record<string, Record<string, string>>): Value;
@@ -1,5 +1,4 @@
1
1
  import { ConnectionInfo, SqlQueryable, SqlResultSet } from '@prisma/driver-adapter-utils';
2
- import type { SqlCommenterPlugin, SqlCommenterQueryInfo } from '@prisma/sqlcommenter';
3
2
  import { QueryEvent } from '../events';
4
3
  import { QueryPlanNode } from '../query-plan';
5
4
  import { type SchemaProvider } from '../schema';
@@ -21,15 +20,10 @@ export type QueryInterpreterOptions = {
21
20
  rawSerializer?: (results: SqlResultSet) => Value;
22
21
  provider?: SchemaProvider;
23
22
  connectionInfo?: ConnectionInfo;
24
- sqlCommenter?: QueryInterpreterSqlCommenter;
25
- };
26
- export type QueryInterpreterSqlCommenter = {
27
- plugins: SqlCommenterPlugin[];
28
- queryInfo: SqlCommenterQueryInfo;
29
23
  };
30
24
  export declare class QueryInterpreter {
31
25
  #private;
32
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, sqlCommenter, }: QueryInterpreterOptions);
26
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, }: QueryInterpreterOptions);
33
27
  static forSql(options: {
34
28
  transactionManager: QueryInterpreterTransactionManager;
35
29
  placeholderValues: Record<string, unknown>;
@@ -37,7 +31,6 @@ export declare class QueryInterpreter {
37
31
  tracingHelper: TracingHelper;
38
32
  provider?: SchemaProvider;
39
33
  connectionInfo?: ConnectionInfo;
40
- sqlCommenter?: QueryInterpreterSqlCommenter;
41
34
  }): QueryInterpreter;
42
35
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
43
36
  private interpretNode;
@@ -1,4 +1,4 @@
1
- import { Decimal } from '@prisma/client-runtime-utils';
1
+ import { Decimal } from 'decimal.js';
2
2
  export type DateTaggedValue = {
3
3
  $type: 'DateTime';
4
4
  value: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "7.2.0-integration-engines-7-2-0-3-aqrln-zpupkzknszlw-04d61c41ec1a025cabe14093fa3121a5f45040ab.1",
3
+ "version": "7.3.0-integration-fix-6-19-0-cloudflare-accelerate-engine.1",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,17 +27,16 @@
27
27
  "@bugsnag/cuid": "3.2.1",
28
28
  "@opentelemetry/api": "1.9.0",
29
29
  "@paralleldrive/cuid2": "2.2.2",
30
+ "decimal.js": "10.5.0",
30
31
  "nanoid": "5.1.5",
31
32
  "ulid": "3.0.0",
32
33
  "uuid": "11.1.0",
33
- "@prisma/client-runtime-utils": "7.2.0-integration-engines-7-2-0-3-aqrln-zpupkzknszlw-04d61c41ec1a025cabe14093fa3121a5f45040ab.1",
34
- "@prisma/sqlcommenter": "7.2.0-integration-engines-7-2-0-3-aqrln-zpupkzknszlw-04d61c41ec1a025cabe14093fa3121a5f45040ab.1",
35
- "@prisma/driver-adapter-utils": "7.2.0-integration-engines-7-2-0-3-aqrln-zpupkzknszlw-04d61c41ec1a025cabe14093fa3121a5f45040ab.1",
36
- "@prisma/debug": "7.2.0-integration-engines-7-2-0-3-aqrln-zpupkzknszlw-04d61c41ec1a025cabe14093fa3121a5f45040ab.1"
34
+ "@prisma/driver-adapter-utils": "7.3.0-integration-fix-6-19-0-cloudflare-accelerate-engine.1",
35
+ "@prisma/debug": "7.3.0-integration-fix-6-19-0-cloudflare-accelerate-engine.1"
37
36
  },
38
37
  "devDependencies": {
39
38
  "@types/jest": "29.5.14",
40
- "@types/node": "~20.19.24",
39
+ "@types/node": "18.19.76",
41
40
  "jest": "29.7.0",
42
41
  "jest-junit": "16.0.0"
43
42
  },
@@ -1,28 +0,0 @@
1
- import type { SqlCommenterContext, SqlCommenterPlugin } from '@prisma/sqlcommenter';
2
- /**
3
- * Formats key-value pairs into a sqlcommenter-compatible comment string.
4
- *
5
- * Algorithm per https://google.github.io/sqlcommenter/spec/:
6
- * 1. If the map is empty, return empty string
7
- * 2. Sort keys lexicographically
8
- * 3. URL-encode keys
9
- * 4. URL-encode values
10
- * 5. Replace ' with \' in values (after URL encoding)
11
- * 6. Wrap values in single quotes
12
- * 7. Join key='value' pairs with commas
13
- * 8. Wrap in /* *\/
14
- */
15
- export declare function formatSqlComment(tags: Record<string, string>): string;
16
- /**
17
- * Applies SQL commenter plugins and returns the merged key-value pairs.
18
- * Keys with undefined values are filtered out.
19
- */
20
- export declare function applySqlCommenters(plugins: SqlCommenterPlugin[], context: SqlCommenterContext): Record<string, string>;
21
- /**
22
- * Applies SQL commenter plugins and returns the formatted comment.
23
- */
24
- export declare function buildSqlComment(plugins: SqlCommenterPlugin[], context: SqlCommenterContext): string;
25
- /**
26
- * Appends a sqlcommenter comment to a SQL query.
27
- */
28
- export declare function appendSqlComment(sql: string, comment: string): string;
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Equivalent to `once` from `node:events` for DOM {@link EventTarget}.
3
- *
4
- * It is useful, e.g., to wait for an `abort` event on {@link AbortSignal}.
5
- * While in Node.js `AbortSignal` does implement `EventEmitter` interface
6
- * and is compatible with the `once` utility in `node:events`, it is not
7
- * necessarily the case in other JS runtimes.
8
- */
9
- export declare function once(target: EventTarget, event: string): Promise<Event>;