@prisma/client-engine-runtime 7.1.0-integration-fix-fix-missing-cockroach-wasm.2 → 7.1.1-dev.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
@@ -6,11 +6,20 @@ import { Decimal } from '@prisma/client-runtime-utils';
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';
9
12
  import { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
10
13
  import { SqlQueryable } from '@prisma/driver-adapter-utils';
11
14
  import { SqlResultSet } from '@prisma/driver-adapter-utils';
12
15
  import { Transaction } from '@prisma/driver-adapter-utils';
13
16
 
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
+
14
23
  export declare type BatchResponse = MultiBatchResponse | CompactedBatchResponse;
15
24
 
16
25
  export declare type BigIntTaggedValue = {
@@ -234,7 +243,7 @@ export declare type QueryEvent = {
234
243
 
235
244
  export declare class QueryInterpreter {
236
245
  #private;
237
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, }: QueryInterpreterOptions);
246
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, sqlCommenter, }: QueryInterpreterOptions);
238
247
  static forSql(options: {
239
248
  transactionManager: QueryInterpreterTransactionManager;
240
249
  placeholderValues: Record<string, unknown>;
@@ -242,6 +251,7 @@ export declare class QueryInterpreter {
242
251
  tracingHelper: TracingHelper;
243
252
  provider?: SchemaProvider;
244
253
  connectionInfo?: ConnectionInfo;
254
+ sqlCommenter?: QueryInterpreterSqlCommenter;
245
255
  }): QueryInterpreter;
246
256
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
247
257
  private interpretNode;
@@ -256,6 +266,12 @@ export declare type QueryInterpreterOptions = {
256
266
  rawSerializer?: (results: SqlResultSet) => Value;
257
267
  provider?: SchemaProvider;
258
268
  connectionInfo?: ConnectionInfo;
269
+ sqlCommenter?: QueryInterpreterSqlCommenter;
270
+ };
271
+
272
+ export declare type QueryInterpreterSqlCommenter = {
273
+ plugins: SqlCommenterPlugin[];
274
+ queryInfo: SqlCommenterQueryInfo;
259
275
  };
260
276
 
261
277
  export declare type QueryInterpreterTransactionManager = {
package/dist/index.d.ts CHANGED
@@ -6,11 +6,20 @@ import { Decimal } from '@prisma/client-runtime-utils';
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';
9
12
  import { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
10
13
  import { SqlQueryable } from '@prisma/driver-adapter-utils';
11
14
  import { SqlResultSet } from '@prisma/driver-adapter-utils';
12
15
  import { Transaction } from '@prisma/driver-adapter-utils';
13
16
 
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
+
14
23
  export declare type BatchResponse = MultiBatchResponse | CompactedBatchResponse;
15
24
 
16
25
  export declare type BigIntTaggedValue = {
@@ -234,7 +243,7 @@ export declare type QueryEvent = {
234
243
 
235
244
  export declare class QueryInterpreter {
236
245
  #private;
237
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, }: QueryInterpreterOptions);
246
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, sqlCommenter, }: QueryInterpreterOptions);
238
247
  static forSql(options: {
239
248
  transactionManager: QueryInterpreterTransactionManager;
240
249
  placeholderValues: Record<string, unknown>;
@@ -242,6 +251,7 @@ export declare class QueryInterpreter {
242
251
  tracingHelper: TracingHelper;
243
252
  provider?: SchemaProvider;
244
253
  connectionInfo?: ConnectionInfo;
254
+ sqlCommenter?: QueryInterpreterSqlCommenter;
245
255
  }): QueryInterpreter;
246
256
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
247
257
  private interpretNode;
@@ -256,6 +266,12 @@ export declare type QueryInterpreterOptions = {
256
266
  rawSerializer?: (results: SqlResultSet) => Value;
257
267
  provider?: SchemaProvider;
258
268
  connectionInfo?: ConnectionInfo;
269
+ sqlCommenter?: QueryInterpreterSqlCommenter;
270
+ };
271
+
272
+ export declare type QueryInterpreterSqlCommenter = {
273
+ plugins: SqlCommenterPlugin[];
274
+ queryInfo: SqlCommenterQueryInfo;
259
275
  };
260
276
 
261
277
  export declare type QueryInterpreterTransactionManager = {
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  TransactionManager: () => TransactionManager,
36
36
  TransactionManagerError: () => TransactionManagerError,
37
37
  UserFacingError: () => UserFacingError,
38
+ applySqlCommenters: () => applySqlCommenters,
38
39
  convertCompactedRows: () => convertCompactedRows,
39
40
  deserializeJsonResponse: () => deserializeJsonResponse,
40
41
  doKeysMatch: () => doKeysMatch,
@@ -691,6 +692,43 @@ function normalizeDateTime(dt) {
691
692
  return dtWithTz;
692
693
  }
693
694
 
695
+ // src/sql-commenter.ts
696
+ function formatSqlComment(tags) {
697
+ const entries = Object.entries(tags);
698
+ if (entries.length === 0) {
699
+ return "";
700
+ }
701
+ entries.sort(([a], [b]) => a.localeCompare(b));
702
+ const parts = entries.map(([key, value]) => {
703
+ const encodedKey = encodeURIComponent(key);
704
+ const encodedValue = encodeURIComponent(value).replace(/'/g, "\\'");
705
+ return `${encodedKey}='${encodedValue}'`;
706
+ });
707
+ return `/*${parts.join(",")}*/`;
708
+ }
709
+ function applySqlCommenters(plugins, context) {
710
+ const merged = {};
711
+ for (const plugin of plugins) {
712
+ const tags = plugin(context);
713
+ for (const [key, value] of Object.entries(tags)) {
714
+ if (value !== void 0) {
715
+ merged[key] = value;
716
+ }
717
+ }
718
+ }
719
+ return merged;
720
+ }
721
+ function buildSqlComment(plugins, context) {
722
+ const tags = applySqlCommenters(plugins, context);
723
+ return formatSqlComment(tags);
724
+ }
725
+ function appendSqlComment(sql, comment) {
726
+ if (!comment) {
727
+ return sql;
728
+ }
729
+ return `${sql} ${comment}`;
730
+ }
731
+
694
732
  // src/tracing.ts
695
733
  var import_api = require("@opentelemetry/api");
696
734
  var noopTracingHelper = {
@@ -1441,7 +1479,8 @@ var QueryInterpreter = class _QueryInterpreter {
1441
1479
  #serializer;
1442
1480
  #rawSerializer;
1443
1481
  #provider;
1444
- #connectioInfo;
1482
+ #connectionInfo;
1483
+ #sqlCommenter;
1445
1484
  constructor({
1446
1485
  transactionManager,
1447
1486
  placeholderValues,
@@ -1450,7 +1489,8 @@ var QueryInterpreter = class _QueryInterpreter {
1450
1489
  serializer,
1451
1490
  rawSerializer,
1452
1491
  provider,
1453
- connectionInfo
1492
+ connectionInfo,
1493
+ sqlCommenter
1454
1494
  }) {
1455
1495
  this.#transactionManager = transactionManager;
1456
1496
  this.#placeholderValues = placeholderValues;
@@ -1459,7 +1499,8 @@ var QueryInterpreter = class _QueryInterpreter {
1459
1499
  this.#serializer = serializer;
1460
1500
  this.#rawSerializer = rawSerializer ?? serializer;
1461
1501
  this.#provider = provider;
1462
- this.#connectioInfo = connectionInfo;
1502
+ this.#connectionInfo = connectionInfo;
1503
+ this.#sqlCommenter = sqlCommenter;
1463
1504
  }
1464
1505
  static forSql(options) {
1465
1506
  return new _QueryInterpreter({
@@ -1470,7 +1511,8 @@ var QueryInterpreter = class _QueryInterpreter {
1470
1511
  serializer: serializeSql,
1471
1512
  rawSerializer: serializeRawSql,
1472
1513
  provider: options.provider,
1473
- connectionInfo: options.connectionInfo
1514
+ connectionInfo: options.connectionInfo,
1515
+ sqlCommenter: options.sqlCommenter
1474
1516
  });
1475
1517
  }
1476
1518
  async run(queryPlan, queryable) {
@@ -1534,10 +1576,11 @@ var QueryInterpreter = class _QueryInterpreter {
1534
1576
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1535
1577
  let sum = 0;
1536
1578
  for (const query of queries) {
1579
+ const commentedQuery = this.#applyComments(query);
1537
1580
  sum += await this.#withQuerySpanAndEvent(
1538
- query,
1581
+ commentedQuery,
1539
1582
  queryable,
1540
- () => queryable.executeRaw(query).catch(
1583
+ () => queryable.executeRaw(commentedQuery).catch(
1541
1584
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1542
1585
  )
1543
1586
  );
@@ -1548,10 +1591,11 @@ var QueryInterpreter = class _QueryInterpreter {
1548
1591
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1549
1592
  let results;
1550
1593
  for (const query of queries) {
1594
+ const commentedQuery = this.#applyComments(query);
1551
1595
  const result = await this.#withQuerySpanAndEvent(
1552
- query,
1596
+ commentedQuery,
1553
1597
  queryable,
1554
- () => queryable.queryRaw(query).catch(
1598
+ () => queryable.queryRaw(commentedQuery).catch(
1555
1599
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1556
1600
  )
1557
1601
  );
@@ -1673,8 +1717,8 @@ var QueryInterpreter = class _QueryInterpreter {
1673
1717
  }
1674
1718
  }
1675
1719
  #maxChunkSize() {
1676
- if (this.#connectioInfo?.maxBindValues !== void 0) {
1677
- return this.#connectioInfo.maxBindValues;
1720
+ if (this.#connectionInfo?.maxBindValues !== void 0) {
1721
+ return this.#connectionInfo.maxBindValues;
1678
1722
  }
1679
1723
  return this.#providerMaxChunkSize();
1680
1724
  }
@@ -1709,6 +1753,22 @@ var QueryInterpreter = class _QueryInterpreter {
1709
1753
  onQuery: this.#onQuery
1710
1754
  });
1711
1755
  }
1756
+ #applyComments(query) {
1757
+ if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
1758
+ return query;
1759
+ }
1760
+ const comment = buildSqlComment(this.#sqlCommenter.plugins, {
1761
+ query: this.#sqlCommenter.queryInfo,
1762
+ sql: query.sql
1763
+ });
1764
+ if (!comment) {
1765
+ return query;
1766
+ }
1767
+ return {
1768
+ ...query,
1769
+ sql: appendSqlComment(query.sql, comment)
1770
+ };
1771
+ }
1712
1772
  };
1713
1773
  function isEmpty(value) {
1714
1774
  if (Array.isArray(value)) {
@@ -1851,6 +1911,13 @@ async function randomUUID() {
1851
1911
  return crypto.randomUUID();
1852
1912
  }
1853
1913
 
1914
+ // src/web-platform.ts
1915
+ async function once(target, event) {
1916
+ return new Promise((resolve) => {
1917
+ target.addEventListener(event, resolve, { once: true });
1918
+ });
1919
+ }
1920
+
1854
1921
  // src/transaction-manager/transaction-manager-error.ts
1855
1922
  var TransactionManagerError = class extends UserFacingError {
1856
1923
  name = "TransactionManagerError";
@@ -1966,15 +2033,19 @@ var TransactionManager = class {
1966
2033
  startedAt: Date.now(),
1967
2034
  transaction: void 0
1968
2035
  };
1969
- this.transactions.set(transaction.id, transaction);
1970
- let hasTimedOut = false;
1971
- const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
2036
+ const abortController = new AbortController();
2037
+ const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
1972
2038
  startTimer?.unref?.();
1973
- transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1974
- clearTimeout(startTimer);
2039
+ const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
2040
+ transaction.transaction = await Promise.race([
2041
+ startTransactionPromise.finally(() => clearTimeout(startTimer)),
2042
+ once(abortController.signal, "abort").then(() => void 0)
2043
+ ]);
2044
+ this.transactions.set(transaction.id, transaction);
1975
2045
  switch (transaction.status) {
1976
2046
  case "waiting":
1977
- if (hasTimedOut) {
2047
+ if (abortController.signal.aborted) {
2048
+ void startTransactionPromise.then((tx) => tx.rollback()).catch((e) => debug("error in discarded transaction:", e));
1978
2049
  await this.#closeTransaction(transaction, "timed_out");
1979
2050
  throw new TransactionStartTimeoutError();
1980
2051
  }
@@ -2146,6 +2217,7 @@ function createTimeoutIfDefined(cb, ms) {
2146
2217
  TransactionManager,
2147
2218
  TransactionManagerError,
2148
2219
  UserFacingError,
2220
+ applySqlCommenters,
2149
2221
  convertCompactedRows,
2150
2222
  deserializeJsonResponse,
2151
2223
  doKeysMatch,
package/dist/index.mjs CHANGED
@@ -641,6 +641,43 @@ function normalizeDateTime(dt) {
641
641
  return dtWithTz;
642
642
  }
643
643
 
644
+ // src/sql-commenter.ts
645
+ function formatSqlComment(tags) {
646
+ const entries = Object.entries(tags);
647
+ if (entries.length === 0) {
648
+ return "";
649
+ }
650
+ entries.sort(([a], [b]) => a.localeCompare(b));
651
+ const parts = entries.map(([key, value]) => {
652
+ const encodedKey = encodeURIComponent(key);
653
+ const encodedValue = encodeURIComponent(value).replace(/'/g, "\\'");
654
+ return `${encodedKey}='${encodedValue}'`;
655
+ });
656
+ return `/*${parts.join(",")}*/`;
657
+ }
658
+ function applySqlCommenters(plugins, context) {
659
+ const merged = {};
660
+ for (const plugin of plugins) {
661
+ const tags = plugin(context);
662
+ for (const [key, value] of Object.entries(tags)) {
663
+ if (value !== void 0) {
664
+ merged[key] = value;
665
+ }
666
+ }
667
+ }
668
+ return merged;
669
+ }
670
+ function buildSqlComment(plugins, context) {
671
+ const tags = applySqlCommenters(plugins, context);
672
+ return formatSqlComment(tags);
673
+ }
674
+ function appendSqlComment(sql, comment) {
675
+ if (!comment) {
676
+ return sql;
677
+ }
678
+ return `${sql} ${comment}`;
679
+ }
680
+
644
681
  // src/tracing.ts
645
682
  import { SpanKind } from "@opentelemetry/api";
646
683
  var noopTracingHelper = {
@@ -1391,7 +1428,8 @@ var QueryInterpreter = class _QueryInterpreter {
1391
1428
  #serializer;
1392
1429
  #rawSerializer;
1393
1430
  #provider;
1394
- #connectioInfo;
1431
+ #connectionInfo;
1432
+ #sqlCommenter;
1395
1433
  constructor({
1396
1434
  transactionManager,
1397
1435
  placeholderValues,
@@ -1400,7 +1438,8 @@ var QueryInterpreter = class _QueryInterpreter {
1400
1438
  serializer,
1401
1439
  rawSerializer,
1402
1440
  provider,
1403
- connectionInfo
1441
+ connectionInfo,
1442
+ sqlCommenter
1404
1443
  }) {
1405
1444
  this.#transactionManager = transactionManager;
1406
1445
  this.#placeholderValues = placeholderValues;
@@ -1409,7 +1448,8 @@ var QueryInterpreter = class _QueryInterpreter {
1409
1448
  this.#serializer = serializer;
1410
1449
  this.#rawSerializer = rawSerializer ?? serializer;
1411
1450
  this.#provider = provider;
1412
- this.#connectioInfo = connectionInfo;
1451
+ this.#connectionInfo = connectionInfo;
1452
+ this.#sqlCommenter = sqlCommenter;
1413
1453
  }
1414
1454
  static forSql(options) {
1415
1455
  return new _QueryInterpreter({
@@ -1420,7 +1460,8 @@ var QueryInterpreter = class _QueryInterpreter {
1420
1460
  serializer: serializeSql,
1421
1461
  rawSerializer: serializeRawSql,
1422
1462
  provider: options.provider,
1423
- connectionInfo: options.connectionInfo
1463
+ connectionInfo: options.connectionInfo,
1464
+ sqlCommenter: options.sqlCommenter
1424
1465
  });
1425
1466
  }
1426
1467
  async run(queryPlan, queryable) {
@@ -1484,10 +1525,11 @@ var QueryInterpreter = class _QueryInterpreter {
1484
1525
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1485
1526
  let sum = 0;
1486
1527
  for (const query of queries) {
1528
+ const commentedQuery = this.#applyComments(query);
1487
1529
  sum += await this.#withQuerySpanAndEvent(
1488
- query,
1530
+ commentedQuery,
1489
1531
  queryable,
1490
- () => queryable.executeRaw(query).catch(
1532
+ () => queryable.executeRaw(commentedQuery).catch(
1491
1533
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1492
1534
  )
1493
1535
  );
@@ -1498,10 +1540,11 @@ var QueryInterpreter = class _QueryInterpreter {
1498
1540
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
1499
1541
  let results;
1500
1542
  for (const query of queries) {
1543
+ const commentedQuery = this.#applyComments(query);
1501
1544
  const result = await this.#withQuerySpanAndEvent(
1502
- query,
1545
+ commentedQuery,
1503
1546
  queryable,
1504
- () => queryable.queryRaw(query).catch(
1547
+ () => queryable.queryRaw(commentedQuery).catch(
1505
1548
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
1506
1549
  )
1507
1550
  );
@@ -1623,8 +1666,8 @@ var QueryInterpreter = class _QueryInterpreter {
1623
1666
  }
1624
1667
  }
1625
1668
  #maxChunkSize() {
1626
- if (this.#connectioInfo?.maxBindValues !== void 0) {
1627
- return this.#connectioInfo.maxBindValues;
1669
+ if (this.#connectionInfo?.maxBindValues !== void 0) {
1670
+ return this.#connectionInfo.maxBindValues;
1628
1671
  }
1629
1672
  return this.#providerMaxChunkSize();
1630
1673
  }
@@ -1659,6 +1702,22 @@ var QueryInterpreter = class _QueryInterpreter {
1659
1702
  onQuery: this.#onQuery
1660
1703
  });
1661
1704
  }
1705
+ #applyComments(query) {
1706
+ if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
1707
+ return query;
1708
+ }
1709
+ const comment = buildSqlComment(this.#sqlCommenter.plugins, {
1710
+ query: this.#sqlCommenter.queryInfo,
1711
+ sql: query.sql
1712
+ });
1713
+ if (!comment) {
1714
+ return query;
1715
+ }
1716
+ return {
1717
+ ...query,
1718
+ sql: appendSqlComment(query.sql, comment)
1719
+ };
1720
+ }
1662
1721
  };
1663
1722
  function isEmpty(value) {
1664
1723
  if (Array.isArray(value)) {
@@ -1801,6 +1860,13 @@ async function randomUUID() {
1801
1860
  return crypto.randomUUID();
1802
1861
  }
1803
1862
 
1863
+ // src/web-platform.ts
1864
+ async function once(target, event) {
1865
+ return new Promise((resolve) => {
1866
+ target.addEventListener(event, resolve, { once: true });
1867
+ });
1868
+ }
1869
+
1804
1870
  // src/transaction-manager/transaction-manager-error.ts
1805
1871
  var TransactionManagerError = class extends UserFacingError {
1806
1872
  name = "TransactionManagerError";
@@ -1916,15 +1982,19 @@ var TransactionManager = class {
1916
1982
  startedAt: Date.now(),
1917
1983
  transaction: void 0
1918
1984
  };
1919
- this.transactions.set(transaction.id, transaction);
1920
- let hasTimedOut = false;
1921
- const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1985
+ const abortController = new AbortController();
1986
+ const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
1922
1987
  startTimer?.unref?.();
1923
- transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1924
- clearTimeout(startTimer);
1988
+ const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1989
+ transaction.transaction = await Promise.race([
1990
+ startTransactionPromise.finally(() => clearTimeout(startTimer)),
1991
+ once(abortController.signal, "abort").then(() => void 0)
1992
+ ]);
1993
+ this.transactions.set(transaction.id, transaction);
1925
1994
  switch (transaction.status) {
1926
1995
  case "waiting":
1927
- if (hasTimedOut) {
1996
+ if (abortController.signal.aborted) {
1997
+ void startTransactionPromise.then((tx) => tx.rollback()).catch((e) => debug("error in discarded transaction:", e));
1928
1998
  await this.#closeTransaction(transaction, "timed_out");
1929
1999
  throw new TransactionStartTimeoutError();
1930
2000
  }
@@ -2095,6 +2165,7 @@ export {
2095
2165
  TransactionManager,
2096
2166
  TransactionManagerError,
2097
2167
  UserFacingError,
2168
+ applySqlCommenters,
2098
2169
  convertCompactedRows,
2099
2170
  deserializeJsonResponse,
2100
2171
  doKeysMatch,
@@ -1,4 +1,5 @@
1
1
  import { ConnectionInfo, SqlQueryable, SqlResultSet } from '@prisma/driver-adapter-utils';
2
+ import type { SqlCommenterPlugin, SqlCommenterQueryInfo } from '@prisma/sqlcommenter';
2
3
  import { QueryEvent } from '../events';
3
4
  import { QueryPlanNode } from '../query-plan';
4
5
  import { type SchemaProvider } from '../schema';
@@ -20,10 +21,15 @@ export type QueryInterpreterOptions = {
20
21
  rawSerializer?: (results: SqlResultSet) => Value;
21
22
  provider?: SchemaProvider;
22
23
  connectionInfo?: ConnectionInfo;
24
+ sqlCommenter?: QueryInterpreterSqlCommenter;
25
+ };
26
+ export type QueryInterpreterSqlCommenter = {
27
+ plugins: SqlCommenterPlugin[];
28
+ queryInfo: SqlCommenterQueryInfo;
23
29
  };
24
30
  export declare class QueryInterpreter {
25
31
  #private;
26
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, }: QueryInterpreterOptions);
32
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, connectionInfo, sqlCommenter, }: QueryInterpreterOptions);
27
33
  static forSql(options: {
28
34
  transactionManager: QueryInterpreterTransactionManager;
29
35
  placeholderValues: Record<string, unknown>;
@@ -31,6 +37,7 @@ export declare class QueryInterpreter {
31
37
  tracingHelper: TracingHelper;
32
38
  provider?: SchemaProvider;
33
39
  connectionInfo?: ConnectionInfo;
40
+ sqlCommenter?: QueryInterpreterSqlCommenter;
34
41
  }): QueryInterpreter;
35
42
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
36
43
  private interpretNode;
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
3
+ "version": "7.1.1-dev.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",
@@ -30,9 +30,10 @@
30
30
  "nanoid": "5.1.5",
31
31
  "ulid": "3.0.0",
32
32
  "uuid": "11.1.0",
33
- "@prisma/debug": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
34
- "@prisma/client-runtime-utils": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
35
- "@prisma/driver-adapter-utils": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2"
33
+ "@prisma/client-runtime-utils": "7.1.1-dev.1",
34
+ "@prisma/debug": "7.1.1-dev.1",
35
+ "@prisma/sqlcommenter": "7.1.1-dev.1",
36
+ "@prisma/driver-adapter-utils": "7.1.1-dev.1"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@types/jest": "29.5.14",