@prisma/client-engine-runtime 6.6.0-dev.3 → 6.6.0-dev.31

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.
@@ -0,0 +1 @@
1
+ export declare function randomUUID(): Promise<string>;
package/dist/index.js CHANGED
@@ -5,10 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __typeError = (msg) => {
9
- throw TypeError(msg);
10
- };
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
8
  var __export = (target, all) => {
13
9
  for (var name in all)
14
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,12 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
26
  mod
31
27
  ));
32
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
35
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
36
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
37
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
38
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
39
29
 
40
30
  // src/index.ts
41
31
  var index_exports = {};
@@ -236,19 +226,17 @@ function serialize(resultSet) {
236
226
  }
237
227
 
238
228
  // src/interpreter/QueryInterpreter.ts
239
- var _queryable, _placeholderValues, _onQuery, _QueryInterpreter_instances, withQueryEvent_fn;
240
229
  var QueryInterpreter = class {
230
+ #queryable;
231
+ #placeholderValues;
232
+ #onQuery;
241
233
  constructor({ queryable, placeholderValues, onQuery }) {
242
- __privateAdd(this, _QueryInterpreter_instances);
243
- __privateAdd(this, _queryable);
244
- __privateAdd(this, _placeholderValues);
245
- __privateAdd(this, _onQuery);
246
- __privateSet(this, _queryable, queryable);
247
- __privateSet(this, _placeholderValues, placeholderValues);
248
- __privateSet(this, _onQuery, onQuery);
234
+ this.#queryable = queryable;
235
+ this.#placeholderValues = placeholderValues;
236
+ this.#onQuery = onQuery;
249
237
  }
250
238
  async run(queryPlan) {
251
- return this.interpretNode(queryPlan, __privateGet(this, _placeholderValues));
239
+ return this.interpretNode(queryPlan, this.#placeholderValues);
252
240
  }
253
241
  async interpretNode(node, scope) {
254
242
  switch (node.type) {
@@ -287,8 +275,8 @@ var QueryInterpreter = class {
287
275
  }
288
276
  case "execute": {
289
277
  const query = renderQuery(node.args, scope);
290
- return __privateMethod(this, _QueryInterpreter_instances, withQueryEvent_fn).call(this, query, async () => {
291
- const result = await __privateGet(this, _queryable).executeRaw(query);
278
+ return this.#withQueryEvent(query, async () => {
279
+ const result = await this.#queryable.executeRaw(query);
292
280
  if (result.ok) {
293
281
  return result.value;
294
282
  } else {
@@ -298,8 +286,8 @@ var QueryInterpreter = class {
298
286
  }
299
287
  case "query": {
300
288
  const query = renderQuery(node.args, scope);
301
- return __privateMethod(this, _QueryInterpreter_instances, withQueryEvent_fn).call(this, query, async () => {
302
- const result = await __privateGet(this, _queryable).queryRaw(query);
289
+ return this.#withQueryEvent(query, async () => {
290
+ const result = await this.#queryable.queryRaw(query);
303
291
  if (result.ok) {
304
292
  return serialize(result.value);
305
293
  } else {
@@ -354,24 +342,19 @@ var QueryInterpreter = class {
354
342
  }
355
343
  }
356
344
  }
357
- };
358
- _queryable = new WeakMap();
359
- _placeholderValues = new WeakMap();
360
- _onQuery = new WeakMap();
361
- _QueryInterpreter_instances = new WeakSet();
362
- withQueryEvent_fn = async function(query, execute) {
363
- var _a;
364
- const timestamp = /* @__PURE__ */ new Date();
365
- const startInstant = performance.now();
366
- const result = await execute();
367
- const endInstant = performance.now();
368
- (_a = __privateGet(this, _onQuery)) == null ? void 0 : _a.call(this, {
369
- timestamp,
370
- duration: endInstant - startInstant,
371
- query: query.sql,
372
- params: query.args
373
- });
374
- return result;
345
+ async #withQueryEvent(query, execute) {
346
+ const timestamp = /* @__PURE__ */ new Date();
347
+ const startInstant = performance.now();
348
+ const result = await execute();
349
+ const endInstant = performance.now();
350
+ this.#onQuery?.({
351
+ timestamp,
352
+ duration: endInstant - startInstant,
353
+ query: query.sql,
354
+ params: query.args
355
+ });
356
+ return result;
357
+ }
375
358
  };
376
359
  function isEmpty(value) {
377
360
  if (Array.isArray(value)) {
@@ -442,6 +425,15 @@ var IsolationLevel = /* @__PURE__ */ ((IsolationLevel2) => {
442
425
  // src/transactionManager/TransactionManager.ts
443
426
  var import_debug = __toESM(require("@prisma/debug"));
444
427
 
428
+ // src/crypto.ts
429
+ async function getCrypto() {
430
+ return globalThis.crypto ?? await import("node:crypto");
431
+ }
432
+ async function randomUUID() {
433
+ const crypto = await getCrypto();
434
+ return crypto.randomUUID();
435
+ }
436
+
445
437
  // src/utils.ts
446
438
  function assertNever(_, message) {
447
439
  throw new Error(message);
@@ -452,8 +444,8 @@ var TransactionManagerError = class extends Error {
452
444
  constructor(message, meta) {
453
445
  super("Transaction API error: " + message);
454
446
  this.meta = meta;
455
- __publicField(this, "code", "P2028");
456
447
  }
448
+ code = "P2028";
457
449
  };
458
450
  var TransactionDriverAdapterError = class extends TransactionManagerError {
459
451
  constructor(message, errorParams) {
@@ -519,19 +511,19 @@ var ISOLATION_LEVEL_QUERY = (isolationLevel) => ({
519
511
  argTypes: []
520
512
  });
521
513
  var TransactionManager = class {
514
+ // The map of active transactions.
515
+ transactions = /* @__PURE__ */ new Map();
516
+ // List of last closed transactions. Max MAX_CLOSED_TRANSACTIONS entries.
517
+ // Used to provide better error messages than a generic "transaction not found".
518
+ closedTransactions = [];
519
+ driverAdapter;
522
520
  constructor({ driverAdapter }) {
523
- // The map of active transactions.
524
- __publicField(this, "transactions", /* @__PURE__ */ new Map());
525
- // List of last closed transactions. Max MAX_CLOSED_TRANSACTIONS entries.
526
- // Used to provide better error messages than a generic "transaction not found".
527
- __publicField(this, "closedTransactions", []);
528
- __publicField(this, "driverAdapter");
529
521
  this.driverAdapter = driverAdapter;
530
522
  }
531
523
  async startTransaction(options) {
532
524
  const validatedOptions = this.validateOptions(options);
533
525
  const transaction = {
534
- id: globalThis.crypto.randomUUID(),
526
+ id: await randomUUID(),
535
527
  status: "waiting",
536
528
  timer: void 0,
537
529
  timeout: validatedOptions.timeout,
package/dist/index.mjs CHANGED
@@ -1,15 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
-
13
1
  // src/QueryPlan.ts
14
2
  function isPrismaValuePlaceholder(value) {
15
3
  return typeof value === "object" && value !== null && value["prisma__type"] === "param";
@@ -198,19 +186,17 @@ function serialize(resultSet) {
198
186
  }
199
187
 
200
188
  // src/interpreter/QueryInterpreter.ts
201
- var _queryable, _placeholderValues, _onQuery, _QueryInterpreter_instances, withQueryEvent_fn;
202
189
  var QueryInterpreter = class {
190
+ #queryable;
191
+ #placeholderValues;
192
+ #onQuery;
203
193
  constructor({ queryable, placeholderValues, onQuery }) {
204
- __privateAdd(this, _QueryInterpreter_instances);
205
- __privateAdd(this, _queryable);
206
- __privateAdd(this, _placeholderValues);
207
- __privateAdd(this, _onQuery);
208
- __privateSet(this, _queryable, queryable);
209
- __privateSet(this, _placeholderValues, placeholderValues);
210
- __privateSet(this, _onQuery, onQuery);
194
+ this.#queryable = queryable;
195
+ this.#placeholderValues = placeholderValues;
196
+ this.#onQuery = onQuery;
211
197
  }
212
198
  async run(queryPlan) {
213
- return this.interpretNode(queryPlan, __privateGet(this, _placeholderValues));
199
+ return this.interpretNode(queryPlan, this.#placeholderValues);
214
200
  }
215
201
  async interpretNode(node, scope) {
216
202
  switch (node.type) {
@@ -249,8 +235,8 @@ var QueryInterpreter = class {
249
235
  }
250
236
  case "execute": {
251
237
  const query = renderQuery(node.args, scope);
252
- return __privateMethod(this, _QueryInterpreter_instances, withQueryEvent_fn).call(this, query, async () => {
253
- const result = await __privateGet(this, _queryable).executeRaw(query);
238
+ return this.#withQueryEvent(query, async () => {
239
+ const result = await this.#queryable.executeRaw(query);
254
240
  if (result.ok) {
255
241
  return result.value;
256
242
  } else {
@@ -260,8 +246,8 @@ var QueryInterpreter = class {
260
246
  }
261
247
  case "query": {
262
248
  const query = renderQuery(node.args, scope);
263
- return __privateMethod(this, _QueryInterpreter_instances, withQueryEvent_fn).call(this, query, async () => {
264
- const result = await __privateGet(this, _queryable).queryRaw(query);
249
+ return this.#withQueryEvent(query, async () => {
250
+ const result = await this.#queryable.queryRaw(query);
265
251
  if (result.ok) {
266
252
  return serialize(result.value);
267
253
  } else {
@@ -316,24 +302,19 @@ var QueryInterpreter = class {
316
302
  }
317
303
  }
318
304
  }
319
- };
320
- _queryable = new WeakMap();
321
- _placeholderValues = new WeakMap();
322
- _onQuery = new WeakMap();
323
- _QueryInterpreter_instances = new WeakSet();
324
- withQueryEvent_fn = async function(query, execute) {
325
- var _a;
326
- const timestamp = /* @__PURE__ */ new Date();
327
- const startInstant = performance.now();
328
- const result = await execute();
329
- const endInstant = performance.now();
330
- (_a = __privateGet(this, _onQuery)) == null ? void 0 : _a.call(this, {
331
- timestamp,
332
- duration: endInstant - startInstant,
333
- query: query.sql,
334
- params: query.args
335
- });
336
- return result;
305
+ async #withQueryEvent(query, execute) {
306
+ const timestamp = /* @__PURE__ */ new Date();
307
+ const startInstant = performance.now();
308
+ const result = await execute();
309
+ const endInstant = performance.now();
310
+ this.#onQuery?.({
311
+ timestamp,
312
+ duration: endInstant - startInstant,
313
+ query: query.sql,
314
+ params: query.args
315
+ });
316
+ return result;
317
+ }
337
318
  };
338
319
  function isEmpty(value) {
339
320
  if (Array.isArray(value)) {
@@ -404,6 +385,15 @@ var IsolationLevel = /* @__PURE__ */ ((IsolationLevel2) => {
404
385
  // src/transactionManager/TransactionManager.ts
405
386
  import Debug from "@prisma/debug";
406
387
 
388
+ // src/crypto.ts
389
+ async function getCrypto() {
390
+ return globalThis.crypto ?? await import("node:crypto");
391
+ }
392
+ async function randomUUID() {
393
+ const crypto = await getCrypto();
394
+ return crypto.randomUUID();
395
+ }
396
+
407
397
  // src/utils.ts
408
398
  function assertNever(_, message) {
409
399
  throw new Error(message);
@@ -414,8 +404,8 @@ var TransactionManagerError = class extends Error {
414
404
  constructor(message, meta) {
415
405
  super("Transaction API error: " + message);
416
406
  this.meta = meta;
417
- __publicField(this, "code", "P2028");
418
407
  }
408
+ code = "P2028";
419
409
  };
420
410
  var TransactionDriverAdapterError = class extends TransactionManagerError {
421
411
  constructor(message, errorParams) {
@@ -481,19 +471,19 @@ var ISOLATION_LEVEL_QUERY = (isolationLevel) => ({
481
471
  argTypes: []
482
472
  });
483
473
  var TransactionManager = class {
474
+ // The map of active transactions.
475
+ transactions = /* @__PURE__ */ new Map();
476
+ // List of last closed transactions. Max MAX_CLOSED_TRANSACTIONS entries.
477
+ // Used to provide better error messages than a generic "transaction not found".
478
+ closedTransactions = [];
479
+ driverAdapter;
484
480
  constructor({ driverAdapter }) {
485
- // The map of active transactions.
486
- __publicField(this, "transactions", /* @__PURE__ */ new Map());
487
- // List of last closed transactions. Max MAX_CLOSED_TRANSACTIONS entries.
488
- // Used to provide better error messages than a generic "transaction not found".
489
- __publicField(this, "closedTransactions", []);
490
- __publicField(this, "driverAdapter");
491
481
  this.driverAdapter = driverAdapter;
492
482
  }
493
483
  async startTransaction(options) {
494
484
  const validatedOptions = this.validateOptions(options);
495
485
  const transaction = {
496
- id: globalThis.crypto.randomUUID(),
486
+ id: await randomUUID(),
497
487
  status: "waiting",
498
488
  timer: void 0,
499
489
  timeout: validatedOptions.timeout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.6.0-dev.3",
3
+ "version": "6.6.0-dev.31",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -20,12 +20,12 @@
20
20
  "repository": {
21
21
  "type": "git",
22
22
  "url": "https://github.com/prisma/prisma.git",
23
- "directory": "packages/accelerate-contract"
23
+ "directory": "packages/client-engine-runtime"
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@prisma/debug": "6.6.0-dev.3",
28
- "@prisma/driver-adapter-utils": "6.6.0-dev.3"
27
+ "@prisma/debug": "6.6.0-dev.31",
28
+ "@prisma/driver-adapter-utils": "6.6.0-dev.31"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/jest": "29.5.14",