@prisma/client-engine-runtime 7.2.0 → 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) {
@@ -604,7 +596,7 @@ function mapValue(value, columnName, scalarType, enums) {
604
596
  throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
605
597
  }
606
598
  }
607
- if (Array.isArray(value) || value instanceof Uint8Array) {
599
+ if (Array.isArray(value)) {
608
600
  for (const byte of value) {
609
601
  if (byte !== 0) return true;
610
602
  }
@@ -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 = {
@@ -1301,6 +1256,17 @@ function serializeRawValue(value, type) {
1301
1256
  throw new Error(`Cannot serialize value of type ${typeof value} as JsonArray`);
1302
1257
  }
1303
1258
  return value.map((v) => serializeRawValue(v, import_driver_adapter_utils2.ColumnTypeEnum.Json));
1259
+ case import_driver_adapter_utils2.ColumnTypeEnum.Bytes:
1260
+ if (Array.isArray(value)) {
1261
+ return new Uint8Array(value);
1262
+ } else {
1263
+ throw new Error(`Cannot serialize value of type ${typeof value} as Bytes`);
1264
+ }
1265
+ case import_driver_adapter_utils2.ColumnTypeEnum.BytesArray:
1266
+ if (!Array.isArray(value)) {
1267
+ throw new Error(`Cannot serialize value of type ${typeof value} as BytesArray`);
1268
+ }
1269
+ return value.map((v) => serializeRawValue(v, import_driver_adapter_utils2.ColumnTypeEnum.Bytes));
1304
1270
  case import_driver_adapter_utils2.ColumnTypeEnum.Boolean:
1305
1271
  switch (typeof value) {
1306
1272
  case "boolean":
@@ -1475,8 +1441,7 @@ var QueryInterpreter = class _QueryInterpreter {
1475
1441
  #serializer;
1476
1442
  #rawSerializer;
1477
1443
  #provider;
1478
- #connectionInfo;
1479
- #sqlCommenter;
1444
+ #connectioInfo;
1480
1445
  constructor({
1481
1446
  transactionManager,
1482
1447
  placeholderValues,
@@ -1485,8 +1450,7 @@ var QueryInterpreter = class _QueryInterpreter {
1485
1450
  serializer,
1486
1451
  rawSerializer,
1487
1452
  provider,
1488
- connectionInfo,
1489
- sqlCommenter
1453
+ connectionInfo
1490
1454
  }) {
1491
1455
  this.#transactionManager = transactionManager;
1492
1456
  this.#placeholderValues = placeholderValues;
@@ -1495,8 +1459,7 @@ var QueryInterpreter = class _QueryInterpreter {
1495
1459
  this.#serializer = serializer;
1496
1460
  this.#rawSerializer = rawSerializer ?? serializer;
1497
1461
  this.#provider = provider;
1498
- this.#connectionInfo = connectionInfo;
1499
- this.#sqlCommenter = sqlCommenter;
1462
+ this.#connectioInfo = connectionInfo;
1500
1463
  }
1501
1464
  static forSql(options) {
1502
1465
  return new _QueryInterpreter({
@@ -1507,8 +1470,7 @@ var QueryInterpreter = class _QueryInterpreter {
1507
1470
  serializer: serializeSql,
1508
1471
  rawSerializer: serializeRawSql,
1509
1472
  provider: options.provider,
1510
- connectionInfo: options.connectionInfo,
1511
- sqlCommenter: options.sqlCommenter
1473
+ connectionInfo: options.connectionInfo
1512
1474
  });
1513
1475
  }
1514
1476
  async run(queryPlan, queryable) {
@@ -1572,11 +1534,10 @@ var QueryInterpreter = class _QueryInterpreter {
1572
1534
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1573
1535
  let sum = 0;
1574
1536
  for (const query of queries) {
1575
- const commentedQuery = this.#applyComments(query);
1576
1537
  sum += await this.#withQuerySpanAndEvent(
1577
- commentedQuery,
1538
+ query,
1578
1539
  queryable,
1579
- () => queryable.executeRaw(commentedQuery).catch(
1540
+ () => queryable.executeRaw(query).catch(
1580
1541
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1581
1542
  )
1582
1543
  );
@@ -1587,11 +1548,10 @@ var QueryInterpreter = class _QueryInterpreter {
1587
1548
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1588
1549
  let results;
1589
1550
  for (const query of queries) {
1590
- const commentedQuery = this.#applyComments(query);
1591
1551
  const result = await this.#withQuerySpanAndEvent(
1592
- commentedQuery,
1552
+ query,
1593
1553
  queryable,
1594
- () => queryable.queryRaw(commentedQuery).catch(
1554
+ () => queryable.queryRaw(query).catch(
1595
1555
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1596
1556
  )
1597
1557
  );
@@ -1713,8 +1673,8 @@ var QueryInterpreter = class _QueryInterpreter {
1713
1673
  }
1714
1674
  }
1715
1675
  #maxChunkSize() {
1716
- if (this.#connectionInfo?.maxBindValues !== void 0) {
1717
- return this.#connectionInfo.maxBindValues;
1676
+ if (this.#connectioInfo?.maxBindValues !== void 0) {
1677
+ return this.#connectioInfo.maxBindValues;
1718
1678
  }
1719
1679
  return this.#providerMaxChunkSize();
1720
1680
  }
@@ -1749,22 +1709,6 @@ var QueryInterpreter = class _QueryInterpreter {
1749
1709
  onQuery: this.#onQuery
1750
1710
  });
1751
1711
  }
1752
- #applyComments(query) {
1753
- if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
1754
- return query;
1755
- }
1756
- const comment = buildSqlComment(this.#sqlCommenter.plugins, {
1757
- query: this.#sqlCommenter.queryInfo,
1758
- sql: query.sql
1759
- });
1760
- if (!comment) {
1761
- return query;
1762
- }
1763
- return {
1764
- ...query,
1765
- sql: appendSqlComment(query.sql, comment)
1766
- };
1767
- }
1768
1712
  };
1769
1713
  function isEmpty(value) {
1770
1714
  if (Array.isArray(value)) {
@@ -1867,7 +1811,7 @@ function evalFieldOperation(op, value, scope, generators) {
1867
1811
  }
1868
1812
 
1869
1813
  // src/raw-json-protocol.ts
1870
- var import_client_runtime_utils4 = require("@prisma/client-runtime-utils");
1814
+ var import_decimal4 = __toESM(require("decimal.js"));
1871
1815
  function normalizeRawJsonProtocolResponse(response) {
1872
1816
  for (let i = 0; i < response.rows.length; i++) {
1873
1817
  const row = response.rows[i];
@@ -1885,7 +1829,7 @@ function normalizeValue(type, value) {
1885
1829
  case "bigint":
1886
1830
  return String(BigInt(value));
1887
1831
  case "decimal":
1888
- return String(new import_client_runtime_utils4.Decimal(value));
1832
+ return String(new import_decimal4.default(value));
1889
1833
  case "bigint-array":
1890
1834
  return value.map((v) => normalizeValue("bigint", v));
1891
1835
  case "decimal-array":
@@ -1907,13 +1851,6 @@ async function randomUUID() {
1907
1851
  return crypto.randomUUID();
1908
1852
  }
1909
1853
 
1910
- // src/web-platform.ts
1911
- async function once(target, event) {
1912
- return new Promise((resolve) => {
1913
- target.addEventListener(event, resolve, { once: true });
1914
- });
1915
- }
1916
-
1917
1854
  // src/transaction-manager/transaction-manager-error.ts
1918
1855
  var TransactionManagerError = class extends UserFacingError {
1919
1856
  name = "TransactionManagerError";
@@ -2029,19 +1966,15 @@ var TransactionManager = class {
2029
1966
  startedAt: Date.now(),
2030
1967
  transaction: void 0
2031
1968
  };
2032
- const abortController = new AbortController();
2033
- const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
2034
- startTimer?.unref?.();
2035
- const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
2036
- transaction.transaction = await Promise.race([
2037
- startTransactionPromise.finally(() => clearTimeout(startTimer)),
2038
- once(abortController.signal, "abort").then(() => void 0)
2039
- ]);
2040
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);
2041
1975
  switch (transaction.status) {
2042
1976
  case "waiting":
2043
- if (abortController.signal.aborted) {
2044
- void startTransactionPromise.then((tx) => tx.rollback()).catch((e) => debug("error in discarded transaction:", e));
1977
+ if (hasTimedOut) {
2045
1978
  await this.#closeTransaction(transaction, "timed_out");
2046
1979
  throw new TransactionStartTimeoutError();
2047
1980
  }
@@ -2137,13 +2070,8 @@ var TransactionManager = class {
2137
2070
  await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
2138
2071
  } else {
2139
2072
  const query = COMMIT_QUERY();
2140
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query)).then(
2141
- () => tx.transaction.commit(),
2142
- (err) => {
2143
- const fail = () => Promise.reject(err);
2144
- return tx.transaction.rollback().then(fail, fail);
2145
- }
2146
- );
2073
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2074
+ await tx.transaction.commit();
2147
2075
  }
2148
2076
  } else if (tx.transaction) {
2149
2077
  if (tx.transaction.options.usePhantomQuery) {
@@ -2154,11 +2082,8 @@ var TransactionManager = class {
2154
2082
  );
2155
2083
  } else {
2156
2084
  const query = ROLLBACK_QUERY();
2157
- try {
2158
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2159
- } finally {
2160
- await tx.transaction.rollback();
2161
- }
2085
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2086
+ await tx.transaction.rollback();
2162
2087
  }
2163
2088
  }
2164
2089
  } finally {
@@ -2213,7 +2138,6 @@ function createTimeoutIfDefined(cb, ms) {
2213
2138
  TransactionManager,
2214
2139
  TransactionManagerError,
2215
2140
  UserFacingError,
2216
- applySqlCommenters,
2217
2141
  convertCompactedRows,
2218
2142
  deserializeJsonResponse,
2219
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) {
@@ -553,7 +546,7 @@ function mapValue(value, columnName, scalarType, enums) {
553
546
  throw new DataMapperError(`Expected a boolean in column '${columnName}', got ${typeof value}: ${value}`);
554
547
  }
555
548
  }
556
- if (Array.isArray(value) || value instanceof Uint8Array) {
549
+ if (Array.isArray(value)) {
557
550
  for (const byte of value) {
558
551
  if (byte !== 0) return true;
559
552
  }
@@ -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 = {
@@ -1250,6 +1206,17 @@ function serializeRawValue(value, type) {
1250
1206
  throw new Error(`Cannot serialize value of type ${typeof value} as JsonArray`);
1251
1207
  }
1252
1208
  return value.map((v) => serializeRawValue(v, ColumnTypeEnum.Json));
1209
+ case ColumnTypeEnum.Bytes:
1210
+ if (Array.isArray(value)) {
1211
+ return new Uint8Array(value);
1212
+ } else {
1213
+ throw new Error(`Cannot serialize value of type ${typeof value} as Bytes`);
1214
+ }
1215
+ case ColumnTypeEnum.BytesArray:
1216
+ if (!Array.isArray(value)) {
1217
+ throw new Error(`Cannot serialize value of type ${typeof value} as BytesArray`);
1218
+ }
1219
+ return value.map((v) => serializeRawValue(v, ColumnTypeEnum.Bytes));
1253
1220
  case ColumnTypeEnum.Boolean:
1254
1221
  switch (typeof value) {
1255
1222
  case "boolean":
@@ -1424,8 +1391,7 @@ var QueryInterpreter = class _QueryInterpreter {
1424
1391
  #serializer;
1425
1392
  #rawSerializer;
1426
1393
  #provider;
1427
- #connectionInfo;
1428
- #sqlCommenter;
1394
+ #connectioInfo;
1429
1395
  constructor({
1430
1396
  transactionManager,
1431
1397
  placeholderValues,
@@ -1434,8 +1400,7 @@ var QueryInterpreter = class _QueryInterpreter {
1434
1400
  serializer,
1435
1401
  rawSerializer,
1436
1402
  provider,
1437
- connectionInfo,
1438
- sqlCommenter
1403
+ connectionInfo
1439
1404
  }) {
1440
1405
  this.#transactionManager = transactionManager;
1441
1406
  this.#placeholderValues = placeholderValues;
@@ -1444,8 +1409,7 @@ var QueryInterpreter = class _QueryInterpreter {
1444
1409
  this.#serializer = serializer;
1445
1410
  this.#rawSerializer = rawSerializer ?? serializer;
1446
1411
  this.#provider = provider;
1447
- this.#connectionInfo = connectionInfo;
1448
- this.#sqlCommenter = sqlCommenter;
1412
+ this.#connectioInfo = connectionInfo;
1449
1413
  }
1450
1414
  static forSql(options) {
1451
1415
  return new _QueryInterpreter({
@@ -1456,8 +1420,7 @@ var QueryInterpreter = class _QueryInterpreter {
1456
1420
  serializer: serializeSql,
1457
1421
  rawSerializer: serializeRawSql,
1458
1422
  provider: options.provider,
1459
- connectionInfo: options.connectionInfo,
1460
- sqlCommenter: options.sqlCommenter
1423
+ connectionInfo: options.connectionInfo
1461
1424
  });
1462
1425
  }
1463
1426
  async run(queryPlan, queryable) {
@@ -1521,11 +1484,10 @@ var QueryInterpreter = class _QueryInterpreter {
1521
1484
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1522
1485
  let sum = 0;
1523
1486
  for (const query of queries) {
1524
- const commentedQuery = this.#applyComments(query);
1525
1487
  sum += await this.#withQuerySpanAndEvent(
1526
- commentedQuery,
1488
+ query,
1527
1489
  queryable,
1528
- () => queryable.executeRaw(commentedQuery).catch(
1490
+ () => queryable.executeRaw(query).catch(
1529
1491
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1530
1492
  )
1531
1493
  );
@@ -1536,11 +1498,10 @@ var QueryInterpreter = class _QueryInterpreter {
1536
1498
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1537
1499
  let results;
1538
1500
  for (const query of queries) {
1539
- const commentedQuery = this.#applyComments(query);
1540
1501
  const result = await this.#withQuerySpanAndEvent(
1541
- commentedQuery,
1502
+ query,
1542
1503
  queryable,
1543
- () => queryable.queryRaw(commentedQuery).catch(
1504
+ () => queryable.queryRaw(query).catch(
1544
1505
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1545
1506
  )
1546
1507
  );
@@ -1662,8 +1623,8 @@ var QueryInterpreter = class _QueryInterpreter {
1662
1623
  }
1663
1624
  }
1664
1625
  #maxChunkSize() {
1665
- if (this.#connectionInfo?.maxBindValues !== void 0) {
1666
- return this.#connectionInfo.maxBindValues;
1626
+ if (this.#connectioInfo?.maxBindValues !== void 0) {
1627
+ return this.#connectioInfo.maxBindValues;
1667
1628
  }
1668
1629
  return this.#providerMaxChunkSize();
1669
1630
  }
@@ -1698,22 +1659,6 @@ var QueryInterpreter = class _QueryInterpreter {
1698
1659
  onQuery: this.#onQuery
1699
1660
  });
1700
1661
  }
1701
- #applyComments(query) {
1702
- if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
1703
- return query;
1704
- }
1705
- const comment = buildSqlComment(this.#sqlCommenter.plugins, {
1706
- query: this.#sqlCommenter.queryInfo,
1707
- sql: query.sql
1708
- });
1709
- if (!comment) {
1710
- return query;
1711
- }
1712
- return {
1713
- ...query,
1714
- sql: appendSqlComment(query.sql, comment)
1715
- };
1716
- }
1717
1662
  };
1718
1663
  function isEmpty(value) {
1719
1664
  if (Array.isArray(value)) {
@@ -1816,7 +1761,7 @@ function evalFieldOperation(op, value, scope, generators) {
1816
1761
  }
1817
1762
 
1818
1763
  // src/raw-json-protocol.ts
1819
- import { Decimal as Decimal4 } from "@prisma/client-runtime-utils";
1764
+ import Decimal4 from "decimal.js";
1820
1765
  function normalizeRawJsonProtocolResponse(response) {
1821
1766
  for (let i = 0; i < response.rows.length; i++) {
1822
1767
  const row = response.rows[i];
@@ -1856,13 +1801,6 @@ async function randomUUID() {
1856
1801
  return crypto.randomUUID();
1857
1802
  }
1858
1803
 
1859
- // src/web-platform.ts
1860
- async function once(target, event) {
1861
- return new Promise((resolve) => {
1862
- target.addEventListener(event, resolve, { once: true });
1863
- });
1864
- }
1865
-
1866
1804
  // src/transaction-manager/transaction-manager-error.ts
1867
1805
  var TransactionManagerError = class extends UserFacingError {
1868
1806
  name = "TransactionManagerError";
@@ -1978,19 +1916,15 @@ var TransactionManager = class {
1978
1916
  startedAt: Date.now(),
1979
1917
  transaction: void 0
1980
1918
  };
1981
- const abortController = new AbortController();
1982
- const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
1983
- startTimer?.unref?.();
1984
- const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1985
- transaction.transaction = await Promise.race([
1986
- startTransactionPromise.finally(() => clearTimeout(startTimer)),
1987
- once(abortController.signal, "abort").then(() => void 0)
1988
- ]);
1989
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);
1990
1925
  switch (transaction.status) {
1991
1926
  case "waiting":
1992
- if (abortController.signal.aborted) {
1993
- void startTransactionPromise.then((tx) => tx.rollback()).catch((e) => debug("error in discarded transaction:", e));
1927
+ if (hasTimedOut) {
1994
1928
  await this.#closeTransaction(transaction, "timed_out");
1995
1929
  throw new TransactionStartTimeoutError();
1996
1930
  }
@@ -2086,13 +2020,8 @@ var TransactionManager = class {
2086
2020
  await this.#withQuerySpanAndEvent(PHANTOM_COMMIT_QUERY(), tx.transaction, () => tx.transaction.commit());
2087
2021
  } else {
2088
2022
  const query = COMMIT_QUERY();
2089
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query)).then(
2090
- () => tx.transaction.commit(),
2091
- (err) => {
2092
- const fail = () => Promise.reject(err);
2093
- return tx.transaction.rollback().then(fail, fail);
2094
- }
2095
- );
2023
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2024
+ await tx.transaction.commit();
2096
2025
  }
2097
2026
  } else if (tx.transaction) {
2098
2027
  if (tx.transaction.options.usePhantomQuery) {
@@ -2103,11 +2032,8 @@ var TransactionManager = class {
2103
2032
  );
2104
2033
  } else {
2105
2034
  const query = ROLLBACK_QUERY();
2106
- try {
2107
- await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2108
- } finally {
2109
- await tx.transaction.rollback();
2110
- }
2035
+ await this.#withQuerySpanAndEvent(query, tx.transaction, () => tx.transaction.executeRaw(query));
2036
+ await tx.transaction.rollback();
2111
2037
  }
2112
2038
  }
2113
2039
  } finally {
@@ -2161,7 +2087,6 @@ export {
2161
2087
  TransactionManager,
2162
2088
  TransactionManagerError,
2163
2089
  UserFacingError,
2164
- applySqlCommenters,
2165
2090
  convertCompactedRows,
2166
2091
  deserializeJsonResponse,
2167
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",
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",
34
- "@prisma/debug": "7.2.0",
35
- "@prisma/driver-adapter-utils": "7.2.0",
36
- "@prisma/sqlcommenter": "7.2.0"
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>;