@prisma/client-engine-runtime 6.8.0-dev.32 → 6.8.0-dev.34

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.
@@ -14,7 +14,12 @@ export type PrismaValueGenerator = {
14
14
  };
15
15
  };
16
16
  export declare function isPrismaValueGenerator(value: unknown): value is PrismaValueGenerator;
17
- export type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator;
17
+ export type PrismaValueBytes = {
18
+ prisma__type: 'bytes';
19
+ prisma__value: string;
20
+ };
21
+ export declare function isPrismaValueBytes(value: unknown): value is PrismaValueBytes;
22
+ export type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator | PrismaValueBytes;
18
23
  export type PrismaValueType = {
19
24
  type: 'Any';
20
25
  } | {
package/dist/index.d.mts CHANGED
@@ -30,6 +30,8 @@ export declare type Fragment = {
30
30
  type: 'parameterTupleList';
31
31
  };
32
32
 
33
+ export declare function isPrismaValueBytes(value: unknown): value is PrismaValueBytes;
34
+
33
35
  export declare function isPrismaValueGenerator(value: unknown): value is PrismaValueGenerator;
34
36
 
35
37
  export declare function isPrismaValuePlaceholder(value: unknown): value is PrismaValuePlaceholder;
@@ -47,7 +49,12 @@ export declare interface PlaceholderFormat {
47
49
  hasNumbering: boolean;
48
50
  }
49
51
 
50
- export declare type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator;
52
+ export declare type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator | PrismaValueBytes;
53
+
54
+ export declare type PrismaValueBytes = {
55
+ prisma__type: 'bytes';
56
+ prisma__value: string;
57
+ };
51
58
 
52
59
  export declare type PrismaValueGenerator = {
53
60
  prisma__type: 'generatorCall';
package/dist/index.d.ts CHANGED
@@ -30,6 +30,8 @@ export declare type Fragment = {
30
30
  type: 'parameterTupleList';
31
31
  };
32
32
 
33
+ export declare function isPrismaValueBytes(value: unknown): value is PrismaValueBytes;
34
+
33
35
  export declare function isPrismaValueGenerator(value: unknown): value is PrismaValueGenerator;
34
36
 
35
37
  export declare function isPrismaValuePlaceholder(value: unknown): value is PrismaValuePlaceholder;
@@ -47,7 +49,12 @@ export declare interface PlaceholderFormat {
47
49
  hasNumbering: boolean;
48
50
  }
49
51
 
50
- export declare type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator;
52
+ export declare type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator | PrismaValueBytes;
53
+
54
+ export declare type PrismaValueBytes = {
55
+ prisma__type: 'bytes';
56
+ prisma__value: string;
57
+ };
51
58
 
52
59
  export declare type PrismaValueGenerator = {
53
60
  prisma__type: 'generatorCall';
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  TransactionManager: () => TransactionManager,
35
35
  TransactionManagerError: () => TransactionManagerError,
36
36
  UserFacingError: () => UserFacingError,
37
+ isPrismaValueBytes: () => isPrismaValueBytes,
37
38
  isPrismaValueGenerator: () => isPrismaValueGenerator,
38
39
  isPrismaValuePlaceholder: () => isPrismaValuePlaceholder,
39
40
  noopTracingHelper: () => noopTracingHelper
@@ -211,6 +212,7 @@ function renderConstraint(constraint) {
211
212
  }
212
213
 
213
214
  // src/interpreter/DataMapper.ts
215
+ var import_decimal = __toESM(require("decimal.js"));
214
216
  function applyDataMap(data, structure) {
215
217
  switch (structure.type) {
216
218
  case "Object":
@@ -283,22 +285,21 @@ function mapValue(value, resultType) {
283
285
  case "Boolean":
284
286
  return typeof value === "boolean" ? value : value !== "0";
285
287
  case "Decimal":
286
- return typeof value === "number" ? value : parseFloat(`${value}`);
288
+ return typeof value === "number" ? new import_decimal.default(value) : new import_decimal.default(`${value}`);
287
289
  case "Date":
288
290
  return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
289
291
  case "Array": {
290
292
  const values = value;
291
- return values.map((v) => {
292
- mapValue(v, resultType.inner);
293
- });
293
+ return values.map((v) => mapValue(v, resultType.inner));
294
294
  }
295
295
  case "Object":
296
- return typeof value === "object" ? value : { value };
297
- case "Bytes":
298
- if (typeof value !== "string") {
299
- throw new Error(`DataMapper: Bytes data is not a string, got: ${typeof value}`);
296
+ return typeof value === "string" ? value : JSON.stringify(value);
297
+ case "Bytes": {
298
+ if (!Array.isArray(value)) {
299
+ throw new Error(`DataMapper: Bytes data is invalid, got: ${typeof value}`);
300
300
  }
301
- return value;
301
+ return new Uint8Array(value);
302
+ }
302
303
  default:
303
304
  assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
304
305
  }
@@ -405,6 +406,9 @@ function isPrismaValuePlaceholder(value) {
405
406
  function isPrismaValueGenerator(value) {
406
407
  return typeof value === "object" && value !== null && value["prisma__type"] === "generatorCall";
407
408
  }
409
+ function isPrismaValueBytes(value) {
410
+ return typeof value === "object" && value !== null && value["prisma__type"] === "bytes";
411
+ }
408
412
 
409
413
  // src/interpreter/renderQuery.ts
410
414
  function renderQuery(dbQuery, scope, generators) {
@@ -448,6 +452,9 @@ function evaluateParam(param, scope, generators) {
448
452
  if (Array.isArray(value)) {
449
453
  value = value.map((el) => evaluateParam(el, scope, generators));
450
454
  }
455
+ if (isPrismaValueBytes(value)) {
456
+ value = Buffer.from(value.prisma__value, "base64");
457
+ }
451
458
  return value;
452
459
  }
453
460
  function renderTemplateSql(fragments, placeholderFormat, params) {
@@ -530,31 +537,11 @@ function toArgType(value) {
530
537
  if (Array.isArray(value)) {
531
538
  return "Array";
532
539
  }
533
- if (isPrismaValuePlaceholder(value)) {
534
- return placeholderTypeToArgType(value.prisma__value.type);
540
+ if (Buffer.isBuffer(value)) {
541
+ return "Bytes";
535
542
  }
536
543
  return "Unknown";
537
544
  }
538
- function placeholderTypeToArgType(type) {
539
- const typeMap = {
540
- Any: "Json",
541
- String: "Text",
542
- Int: "Int32",
543
- BigInt: "Int64",
544
- Float: "Double",
545
- Boolean: "Boolean",
546
- Decimal: "Numeric",
547
- Date: "DateTime",
548
- Object: "Json",
549
- Bytes: "Bytes",
550
- Array: "Array"
551
- };
552
- const mappedType = typeMap[type];
553
- if (!mappedType) {
554
- throw new Error(`Unknown placeholder type: ${type}`);
555
- }
556
- return mappedType;
557
- }
558
545
  function doesRequireEvaluation(param) {
559
546
  return isPrismaValuePlaceholder(param) || isPrismaValueGenerator(param);
560
547
  }
@@ -614,7 +601,7 @@ function renderMessage(data, error) {
614
601
  case "RELATION_VIOLATION":
615
602
  return `The change you are trying to make would violate the required relation '${error.context.relation}' between the \`${error.context.modelA}\` and \`${error.context.modelB}\` models.`;
616
603
  case "MISSING_RECORD":
617
- return `No record was found for ${error.context.operation}.`;
604
+ return `An operation failed because it depends on one or more records that were required but not found. No record was found for ${error.context.operation}.`;
618
605
  case "MISSING_RELATED_RECORD": {
619
606
  const hint = error.context.neededFor ? ` (needed to ${error.context.neededFor})` : "";
620
607
  return `An operation failed because it depends on one or more records that were required but not found. No '${error.context.model}' record${hint} was found for ${error.context.operation} on ${error.context.relationType} relation '${error.context.relation}'.`;
@@ -1093,6 +1080,7 @@ var TransactionManager = class {
1093
1080
  TransactionManager,
1094
1081
  TransactionManagerError,
1095
1082
  UserFacingError,
1083
+ isPrismaValueBytes,
1096
1084
  isPrismaValueGenerator,
1097
1085
  isPrismaValuePlaceholder,
1098
1086
  noopTracingHelper
package/dist/index.mjs CHANGED
@@ -169,6 +169,7 @@ function renderConstraint(constraint) {
169
169
  }
170
170
 
171
171
  // src/interpreter/DataMapper.ts
172
+ import Decimal from "decimal.js";
172
173
  function applyDataMap(data, structure) {
173
174
  switch (structure.type) {
174
175
  case "Object":
@@ -241,22 +242,21 @@ function mapValue(value, resultType) {
241
242
  case "Boolean":
242
243
  return typeof value === "boolean" ? value : value !== "0";
243
244
  case "Decimal":
244
- return typeof value === "number" ? value : parseFloat(`${value}`);
245
+ return typeof value === "number" ? new Decimal(value) : new Decimal(`${value}`);
245
246
  case "Date":
246
247
  return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
247
248
  case "Array": {
248
249
  const values = value;
249
- return values.map((v) => {
250
- mapValue(v, resultType.inner);
251
- });
250
+ return values.map((v) => mapValue(v, resultType.inner));
252
251
  }
253
252
  case "Object":
254
- return typeof value === "object" ? value : { value };
255
- case "Bytes":
256
- if (typeof value !== "string") {
257
- throw new Error(`DataMapper: Bytes data is not a string, got: ${typeof value}`);
253
+ return typeof value === "string" ? value : JSON.stringify(value);
254
+ case "Bytes": {
255
+ if (!Array.isArray(value)) {
256
+ throw new Error(`DataMapper: Bytes data is invalid, got: ${typeof value}`);
258
257
  }
259
- return value;
258
+ return new Uint8Array(value);
259
+ }
260
260
  default:
261
261
  assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
262
262
  }
@@ -363,6 +363,9 @@ function isPrismaValuePlaceholder(value) {
363
363
  function isPrismaValueGenerator(value) {
364
364
  return typeof value === "object" && value !== null && value["prisma__type"] === "generatorCall";
365
365
  }
366
+ function isPrismaValueBytes(value) {
367
+ return typeof value === "object" && value !== null && value["prisma__type"] === "bytes";
368
+ }
366
369
 
367
370
  // src/interpreter/renderQuery.ts
368
371
  function renderQuery(dbQuery, scope, generators) {
@@ -406,6 +409,9 @@ function evaluateParam(param, scope, generators) {
406
409
  if (Array.isArray(value)) {
407
410
  value = value.map((el) => evaluateParam(el, scope, generators));
408
411
  }
412
+ if (isPrismaValueBytes(value)) {
413
+ value = Buffer.from(value.prisma__value, "base64");
414
+ }
409
415
  return value;
410
416
  }
411
417
  function renderTemplateSql(fragments, placeholderFormat, params) {
@@ -488,31 +494,11 @@ function toArgType(value) {
488
494
  if (Array.isArray(value)) {
489
495
  return "Array";
490
496
  }
491
- if (isPrismaValuePlaceholder(value)) {
492
- return placeholderTypeToArgType(value.prisma__value.type);
497
+ if (Buffer.isBuffer(value)) {
498
+ return "Bytes";
493
499
  }
494
500
  return "Unknown";
495
501
  }
496
- function placeholderTypeToArgType(type) {
497
- const typeMap = {
498
- Any: "Json",
499
- String: "Text",
500
- Int: "Int32",
501
- BigInt: "Int64",
502
- Float: "Double",
503
- Boolean: "Boolean",
504
- Decimal: "Numeric",
505
- Date: "DateTime",
506
- Object: "Json",
507
- Bytes: "Bytes",
508
- Array: "Array"
509
- };
510
- const mappedType = typeMap[type];
511
- if (!mappedType) {
512
- throw new Error(`Unknown placeholder type: ${type}`);
513
- }
514
- return mappedType;
515
- }
516
502
  function doesRequireEvaluation(param) {
517
503
  return isPrismaValuePlaceholder(param) || isPrismaValueGenerator(param);
518
504
  }
@@ -572,7 +558,7 @@ function renderMessage(data, error) {
572
558
  case "RELATION_VIOLATION":
573
559
  return `The change you are trying to make would violate the required relation '${error.context.relation}' between the \`${error.context.modelA}\` and \`${error.context.modelB}\` models.`;
574
560
  case "MISSING_RECORD":
575
- return `No record was found for ${error.context.operation}.`;
561
+ return `An operation failed because it depends on one or more records that were required but not found. No record was found for ${error.context.operation}.`;
576
562
  case "MISSING_RELATED_RECORD": {
577
563
  const hint = error.context.neededFor ? ` (needed to ${error.context.neededFor})` : "";
578
564
  return `An operation failed because it depends on one or more records that were required but not found. No '${error.context.model}' record${hint} was found for ${error.context.operation} on ${error.context.relationType} relation '${error.context.relation}'.`;
@@ -1050,6 +1036,7 @@ export {
1050
1036
  TransactionManager,
1051
1037
  TransactionManagerError,
1052
1038
  UserFacingError,
1039
+ isPrismaValueBytes,
1053
1040
  isPrismaValueGenerator,
1054
1041
  isPrismaValuePlaceholder,
1055
1042
  noopTracingHelper
@@ -1,4 +1,3 @@
1
- import { PrismaValue } from '../QueryPlan';
2
1
  export declare class GeneratorRegistry {
3
2
  #private;
4
3
  constructor();
@@ -17,5 +16,5 @@ export interface GeneratorRegistrySnapshot {
17
16
  [key: string]: ValueGenerator;
18
17
  }
19
18
  export interface ValueGenerator {
20
- generate(...args: PrismaValue[]): PrismaValue;
19
+ generate(...args: unknown[]): unknown;
21
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.8.0-dev.32",
3
+ "version": "6.8.0-dev.34",
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,11 +27,12 @@
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/debug": "6.8.0-dev.32",
34
- "@prisma/driver-adapter-utils": "6.8.0-dev.32"
34
+ "@prisma/driver-adapter-utils": "6.8.0-dev.34",
35
+ "@prisma/debug": "6.8.0-dev.34"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/jest": "29.5.14",