@prisma/query-plan-executor 7.1.0-integration-fix-fix-missing-cockroach-wasm.2 → 7.1.0

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.ts CHANGED
@@ -34,8 +34,14 @@ declare class App {
34
34
  shutdown(): Promise<void>;
35
35
  /**
36
36
  * Executes a query plan and returns the result.
37
+ *
38
+ * @param queryPlan - The query plan to execute
39
+ * @param placeholderValues - Placeholder values for the query
40
+ * @param comments - Pre-computed SQL commenter tags from the client
41
+ * @param resourceLimits - Resource limits for the query
42
+ * @param transactionId - Transaction ID if running within a transaction
37
43
  */
38
- query(queryPlan: QueryPlanNode, placeholderValues: Record<string, unknown>, resourceLimits: ResourceLimits, transactionId: string | null): Promise<unknown>;
44
+ query(queryPlan: QueryPlanNode, placeholderValues: Record<string, unknown>, comments: Record<string, string> | undefined, resourceLimits: ResourceLimits, transactionId: string | null): Promise<unknown>;
39
45
  /**
40
46
  * Starts a new transaction.
41
47
  */
@@ -648,6 +654,7 @@ operation: string;
648
654
  plan: Record<string, unknown>;
649
655
  params: Record<string, unknown>;
650
656
  model?: string | undefined;
657
+ comments?: Record<string, string> | undefined;
651
658
  };
652
659
  };
653
660
  output: {
@@ -683,6 +690,7 @@ operation: string;
683
690
  plan: Record<string, unknown>;
684
691
  params: Record<string, unknown>;
685
692
  model?: string | undefined;
693
+ comments?: Record<string, string> | undefined;
686
694
  };
687
695
  } & {
688
696
  param: {
package/dist/index.js CHANGED
@@ -40576,7 +40576,7 @@ var require_dist2 = __commonJS({
40576
40576
  "../../node_modules/.pnpm/@tootallnate+once@2.0.0/node_modules/@tootallnate/once/dist/index.js"(exports2) {
40577
40577
  "use strict";
40578
40578
  Object.defineProperty(exports2, "__esModule", { value: true });
40579
- function once(emitter, name6, { signal } = {}) {
40579
+ function once2(emitter, name6, { signal } = {}) {
40580
40580
  return new Promise((resolve, reject) => {
40581
40581
  function cleanup() {
40582
40582
  signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", cleanup);
@@ -40596,7 +40596,7 @@ var require_dist2 = __commonJS({
40596
40596
  emitter.on("error", onError);
40597
40597
  });
40598
40598
  }
40599
- exports2.default = once;
40599
+ exports2.default = once2;
40600
40600
  }
40601
40601
  });
40602
40602
 
@@ -55946,7 +55946,7 @@ var require_lodash7 = __commonJS({
55946
55946
  return result;
55947
55947
  };
55948
55948
  }
55949
- function once(func) {
55949
+ function once2(func) {
55950
55950
  return before(2, func);
55951
55951
  }
55952
55952
  function isObject3(value) {
@@ -55992,7 +55992,7 @@ var require_lodash7 = __commonJS({
55992
55992
  var isBinary2 = reIsBinary.test(value);
55993
55993
  return isBinary2 || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary2 ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
55994
55994
  }
55995
- module2.exports = once;
55995
+ module2.exports = once2;
55996
55996
  }
55997
55997
  });
55998
55998
 
@@ -56010,7 +56010,7 @@ var require_sign2 = __commonJS({
56010
56010
  var isNumber = require_lodash4();
56011
56011
  var isPlainObject2 = require_lodash5();
56012
56012
  var isString = require_lodash6();
56013
- var once = require_lodash7();
56013
+ var once2 = require_lodash7();
56014
56014
  var { KeyObject, createSecretKey, createPrivateKey: createPrivateKey3 } = require("crypto");
56015
56015
  var SUPPORTED_ALGS = ["RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512", "none"];
56016
56016
  if (PS_SUPPORTED) {
@@ -56199,7 +56199,7 @@ var require_sign2 = __commonJS({
56199
56199
  });
56200
56200
  const encoding = options.encoding || "utf8";
56201
56201
  if (typeof callback === "function") {
56202
- callback = callback && once(callback);
56202
+ callback = callback && once2(callback);
56203
56203
  jws.createSign({
56204
56204
  header,
56205
56205
  privateKey: secretOrPrivateKey,
@@ -66461,7 +66461,7 @@ var require_end_of_stream = __commonJS({
66461
66461
  var process3 = require_process();
66462
66462
  var { AbortError: AbortError3, codes } = require_errors3();
66463
66463
  var { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes;
66464
- var { kEmptyObject, once } = require_util();
66464
+ var { kEmptyObject, once: once2 } = require_util();
66465
66465
  var { validateAbortSignal, validateFunction, validateObject, validateBoolean } = require_validators();
66466
66466
  var { Promise: Promise2, PromisePrototypeThen } = require_primordials();
66467
66467
  var {
@@ -66497,7 +66497,7 @@ var require_end_of_stream = __commonJS({
66497
66497
  }
66498
66498
  validateFunction(callback, "callback");
66499
66499
  validateAbortSignal(options.signal, "options.signal");
66500
- callback = once(callback);
66500
+ callback = once2(callback);
66501
66501
  if (isReadableStream2(stream) || isWritableStream(stream)) {
66502
66502
  return eosWeb(stream, options, callback);
66503
66503
  }
@@ -66634,7 +66634,7 @@ var require_end_of_stream = __commonJS({
66634
66634
  process3.nextTick(abort);
66635
66635
  } else {
66636
66636
  const originalCallback = callback;
66637
- callback = once((...args) => {
66637
+ callback = once2((...args) => {
66638
66638
  options.signal.removeEventListener("abort", abort);
66639
66639
  originalCallback.apply(stream, args);
66640
66640
  });
@@ -66660,7 +66660,7 @@ var require_end_of_stream = __commonJS({
66660
66660
  process3.nextTick(abort);
66661
66661
  } else {
66662
66662
  const originalCallback = callback;
66663
- callback = once((...args) => {
66663
+ callback = once2((...args) => {
66664
66664
  options.signal.removeEventListener("abort", abort);
66665
66665
  originalCallback.apply(stream, args);
66666
66666
  });
@@ -69478,7 +69478,7 @@ var require_pipeline = __commonJS({
69478
69478
  var process3 = require_process();
69479
69479
  var { ArrayIsArray, Promise: Promise2, SymbolAsyncIterator } = require_primordials();
69480
69480
  var eos = require_end_of_stream();
69481
- var { once } = require_util();
69481
+ var { once: once2 } = require_util();
69482
69482
  var destroyImpl = require_destroy();
69483
69483
  var Duplex = require_duplex();
69484
69484
  var {
@@ -69629,7 +69629,7 @@ var require_pipeline = __commonJS({
69629
69629
  }
69630
69630
  }
69631
69631
  function pipeline(...streams) {
69632
- return pipelineImpl(streams, once(popCallback(streams)));
69632
+ return pipelineImpl(streams, once2(popCallback(streams)));
69633
69633
  }
69634
69634
  function pipelineImpl(streams, callback, opts) {
69635
69635
  if (streams.length === 1 && ArrayIsArray(streams[0])) {
@@ -97752,7 +97752,7 @@ __export(index_exports, {
97752
97752
  module.exports = __toCommonJS(index_exports);
97753
97753
 
97754
97754
  // package.json
97755
- var version = "7.1.0-integration-fix-fix-missing-cockroach-wasm.2";
97755
+ var version = "7.1.0";
97756
97756
 
97757
97757
  // ../../node_modules/.pnpm/temporal-polyfill@0.3.0/node_modules/temporal-polyfill/chunks/internal.js
97758
97758
  function clampProp(e2, n2, t2, o2, r2) {
@@ -106556,6 +106556,41 @@ function normalizeDateTime(dt2) {
106556
106556
  }
106557
106557
  return dtWithTz;
106558
106558
  }
106559
+ function formatSqlComment(tags) {
106560
+ const entries = Object.entries(tags);
106561
+ if (entries.length === 0) {
106562
+ return "";
106563
+ }
106564
+ entries.sort(([a2], [b2]) => a2.localeCompare(b2));
106565
+ const parts = entries.map(([key, value]) => {
106566
+ const encodedKey = encodeURIComponent(key);
106567
+ const encodedValue = encodeURIComponent(value).replace(/'/g, "\\'");
106568
+ return `${encodedKey}='${encodedValue}'`;
106569
+ });
106570
+ return `/*${parts.join(",")}*/`;
106571
+ }
106572
+ function applySqlCommenters(plugins, context2) {
106573
+ const merged = {};
106574
+ for (const plugin of plugins) {
106575
+ const tags = plugin(context2);
106576
+ for (const [key, value] of Object.entries(tags)) {
106577
+ if (value !== void 0) {
106578
+ merged[key] = value;
106579
+ }
106580
+ }
106581
+ }
106582
+ return merged;
106583
+ }
106584
+ function buildSqlComment(plugins, context2) {
106585
+ const tags = applySqlCommenters(plugins, context2);
106586
+ return formatSqlComment(tags);
106587
+ }
106588
+ function appendSqlComment(sql4, comment) {
106589
+ if (!comment) {
106590
+ return sql4;
106591
+ }
106592
+ return `${sql4} ${comment}`;
106593
+ }
106559
106594
  function providerToOtelSystem(provider) {
106560
106595
  switch (provider) {
106561
106596
  case "postgresql":
@@ -107279,7 +107314,8 @@ var QueryInterpreter = class _QueryInterpreter {
107279
107314
  #serializer;
107280
107315
  #rawSerializer;
107281
107316
  #provider;
107282
- #connectioInfo;
107317
+ #connectionInfo;
107318
+ #sqlCommenter;
107283
107319
  constructor({
107284
107320
  transactionManager,
107285
107321
  placeholderValues,
@@ -107288,7 +107324,8 @@ var QueryInterpreter = class _QueryInterpreter {
107288
107324
  serializer,
107289
107325
  rawSerializer,
107290
107326
  provider,
107291
- connectionInfo
107327
+ connectionInfo,
107328
+ sqlCommenter
107292
107329
  }) {
107293
107330
  this.#transactionManager = transactionManager;
107294
107331
  this.#placeholderValues = placeholderValues;
@@ -107297,7 +107334,8 @@ var QueryInterpreter = class _QueryInterpreter {
107297
107334
  this.#serializer = serializer;
107298
107335
  this.#rawSerializer = rawSerializer ?? serializer;
107299
107336
  this.#provider = provider;
107300
- this.#connectioInfo = connectionInfo;
107337
+ this.#connectionInfo = connectionInfo;
107338
+ this.#sqlCommenter = sqlCommenter;
107301
107339
  }
107302
107340
  static forSql(options) {
107303
107341
  return new _QueryInterpreter({
@@ -107308,7 +107346,8 @@ var QueryInterpreter = class _QueryInterpreter {
107308
107346
  serializer: serializeSql,
107309
107347
  rawSerializer: serializeRawSql,
107310
107348
  provider: options.provider,
107311
- connectionInfo: options.connectionInfo
107349
+ connectionInfo: options.connectionInfo,
107350
+ sqlCommenter: options.sqlCommenter
107312
107351
  });
107313
107352
  }
107314
107353
  async run(queryPlan, queryable) {
@@ -107372,10 +107411,11 @@ var QueryInterpreter = class _QueryInterpreter {
107372
107411
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
107373
107412
  let sum2 = 0;
107374
107413
  for (const query2 of queries) {
107414
+ const commentedQuery = this.#applyComments(query2);
107375
107415
  sum2 += await this.#withQuerySpanAndEvent(
107376
- query2,
107416
+ commentedQuery,
107377
107417
  queryable,
107378
- () => queryable.executeRaw(query2).catch(
107418
+ () => queryable.executeRaw(commentedQuery).catch(
107379
107419
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
107380
107420
  )
107381
107421
  );
@@ -107386,10 +107426,11 @@ var QueryInterpreter = class _QueryInterpreter {
107386
107426
  const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
107387
107427
  let results;
107388
107428
  for (const query2 of queries) {
107429
+ const commentedQuery = this.#applyComments(query2);
107389
107430
  const result = await this.#withQuerySpanAndEvent(
107390
- query2,
107431
+ commentedQuery,
107391
107432
  queryable,
107392
- () => queryable.queryRaw(query2).catch(
107433
+ () => queryable.queryRaw(commentedQuery).catch(
107393
107434
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
107394
107435
  )
107395
107436
  );
@@ -107511,8 +107552,8 @@ var QueryInterpreter = class _QueryInterpreter {
107511
107552
  }
107512
107553
  }
107513
107554
  #maxChunkSize() {
107514
- if (this.#connectioInfo?.maxBindValues !== void 0) {
107515
- return this.#connectioInfo.maxBindValues;
107555
+ if (this.#connectionInfo?.maxBindValues !== void 0) {
107556
+ return this.#connectionInfo.maxBindValues;
107516
107557
  }
107517
107558
  return this.#providerMaxChunkSize();
107518
107559
  }
@@ -107547,6 +107588,22 @@ var QueryInterpreter = class _QueryInterpreter {
107547
107588
  onQuery: this.#onQuery
107548
107589
  });
107549
107590
  }
107591
+ #applyComments(query2) {
107592
+ if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
107593
+ return query2;
107594
+ }
107595
+ const comment = buildSqlComment(this.#sqlCommenter.plugins, {
107596
+ query: this.#sqlCommenter.queryInfo,
107597
+ sql: query2.sql
107598
+ });
107599
+ if (!comment) {
107600
+ return query2;
107601
+ }
107602
+ return {
107603
+ ...query2,
107604
+ sql: appendSqlComment(query2.sql, comment)
107605
+ };
107606
+ }
107550
107607
  };
107551
107608
  function isEmpty(value) {
107552
107609
  if (Array.isArray(value)) {
@@ -107654,6 +107711,11 @@ async function randomUUID2() {
107654
107711
  const crypto7 = await getCrypto();
107655
107712
  return crypto7.randomUUID();
107656
107713
  }
107714
+ async function once(target, event) {
107715
+ return new Promise((resolve) => {
107716
+ target.addEventListener(event, resolve, { once: true });
107717
+ });
107718
+ }
107657
107719
  var TransactionManagerError = class extends UserFacingError {
107658
107720
  name = "TransactionManagerError";
107659
107721
  constructor(message, meta) {
@@ -107766,15 +107828,17 @@ var TransactionManager = class {
107766
107828
  startedAt: Date.now(),
107767
107829
  transaction: void 0
107768
107830
  };
107769
- this.transactions.set(transaction.id, transaction);
107770
- let hasTimedOut = false;
107771
- const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
107831
+ const abortController = new AbortController();
107832
+ const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
107772
107833
  startTimer?.unref?.();
107773
- transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
107774
- clearTimeout(startTimer);
107834
+ transaction.transaction = await Promise.race([
107835
+ this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing).finally(() => clearTimeout(startTimer)),
107836
+ once(abortController.signal, "abort").then(() => void 0)
107837
+ ]);
107838
+ this.transactions.set(transaction.id, transaction);
107775
107839
  switch (transaction.status) {
107776
107840
  case "waiting":
107777
- if (hasTimedOut) {
107841
+ if (abortController.signal.aborted) {
107778
107842
  await this.#closeTransaction(transaction, "timed_out");
107779
107843
  throw new TransactionStartTimeoutError();
107780
107844
  }
@@ -111790,15 +111854,28 @@ var App = class _App {
111790
111854
  }
111791
111855
  /**
111792
111856
  * Executes a query plan and returns the result.
111857
+ *
111858
+ * @param queryPlan - The query plan to execute
111859
+ * @param placeholderValues - Placeholder values for the query
111860
+ * @param comments - Pre-computed SQL commenter tags from the client
111861
+ * @param resourceLimits - Resource limits for the query
111862
+ * @param transactionId - Transaction ID if running within a transaction
111793
111863
  */
111794
- async query(queryPlan, placeholderValues, resourceLimits, transactionId) {
111864
+ async query(queryPlan, placeholderValues, comments, resourceLimits, transactionId) {
111795
111865
  return await this.#tracingHandler.runInChildSpan("query", async () => {
111796
111866
  const queryable = transactionId !== null ? await this.#transactionManager.getTransaction({ id: transactionId }, "query") : this.#db;
111867
+ const sqlCommenter = comments && Object.keys(comments).length > 0 ? {
111868
+ plugins: [() => comments],
111869
+ // For pre-computed comments, we use a placeholder queryInfo since the actual
111870
+ // query info was already used on the client side to compute the comments
111871
+ queryInfo: { type: "single", action: "queryRaw", query: {} }
111872
+ } : void 0;
111797
111873
  const queryInterpreter = QueryInterpreter.forSql({
111798
111874
  placeholderValues,
111799
111875
  tracingHelper: this.#tracingHandler,
111800
111876
  transactionManager: transactionId === null ? { enabled: true, manager: this.#transactionManager } : { enabled: false },
111801
- onQuery: logQuery
111877
+ onQuery: logQuery,
111878
+ sqlCommenter
111802
111879
  });
111803
111880
  const result = await Promise.race([
111804
111881
  queryInterpreter.run(queryPlan, queryable),
@@ -124031,7 +124108,8 @@ var QueryRequestBody = external_exports.object({
124031
124108
  model: external_exports.string().min(1).optional(),
124032
124109
  operation: external_exports.string().min(1),
124033
124110
  plan: external_exports.record(external_exports.string(), external_exports.unknown()),
124034
- params: external_exports.record(external_exports.string(), external_exports.unknown())
124111
+ params: external_exports.record(external_exports.string(), external_exports.unknown()),
124112
+ comments: external_exports.record(external_exports.string(), external_exports.string()).optional()
124035
124113
  });
124036
124114
  var TransactionStartRequestBody = external_exports.object({
124037
124115
  timeout: external_exports.number().optional(),
@@ -124075,7 +124153,13 @@ function createHonoServer(app, options) {
124075
124153
  return c2.json(app.getConnectionInfo());
124076
124154
  }).post("/query", zValidator("json", QueryRequestBody), async (c2) => {
124077
124155
  const request3 = c2.req.valid("json");
124078
- const data = await app.query(request3.plan, request3.params, c2.get("resourceLimits"), null);
124156
+ const data = await app.query(
124157
+ request3.plan,
124158
+ request3.params,
124159
+ request3.comments,
124160
+ c2.get("resourceLimits"),
124161
+ null
124162
+ );
124079
124163
  return c2.json({ data });
124080
124164
  }).post("/transaction/start", zValidator("json", TransactionStartRequestBody), async (c2) => {
124081
124165
  const result = await app.startTransaction(c2.req.valid("json"), c2.get("resourceLimits"));
@@ -124086,6 +124170,7 @@ function createHonoServer(app, options) {
124086
124170
  const data = await app.query(
124087
124171
  request3.plan,
124088
124172
  request3.params,
124173
+ request3.comments,
124089
124174
  c2.get("resourceLimits"),
124090
124175
  c2.req.param("txId")
124091
124176
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/query-plan-executor",
3
- "version": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
3
+ "version": "7.1.0",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,11 +20,11 @@
20
20
  "temporal-polyfill": "0.3.0",
21
21
  "vitest": "3.2.4",
22
22
  "zod": "4.1.3",
23
- "@prisma/adapter-pg": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
24
- "@prisma/adapter-mariadb": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
25
- "@prisma/adapter-mssql": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
26
- "@prisma/client-engine-runtime": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2",
27
- "@prisma/driver-adapter-utils": "7.1.0-integration-fix-fix-missing-cockroach-wasm.2"
23
+ "@prisma/adapter-pg": "7.1.0",
24
+ "@prisma/client-engine-runtime": "7.1.0",
25
+ "@prisma/adapter-mariadb": "7.1.0",
26
+ "@prisma/adapter-mssql": "7.1.0",
27
+ "@prisma/driver-adapter-utils": "7.1.0"
28
28
  },
29
29
  "files": [
30
30
  "dist"