@prisma/client-engine-runtime 6.12.0-dev.21 → 6.12.0-dev.22

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
@@ -7,6 +7,16 @@ import { SqlQueryable } from '@prisma/driver-adapter-utils';
7
7
  import { SqlResultSet } from '@prisma/driver-adapter-utils';
8
8
  import { Transaction } from '@prisma/driver-adapter-utils';
9
9
 
10
+ export declare type BigIntTaggedValue = {
11
+ $type: 'BigInt';
12
+ value: string;
13
+ };
14
+
15
+ export declare type BytesTaggedValue = {
16
+ $type: 'Bytes';
17
+ value: string;
18
+ };
19
+
10
20
  export declare class DataMapperError extends Error {
11
21
  name: string;
12
22
  }
@@ -24,6 +34,16 @@ export declare type DataRule = {
24
34
  type: 'never';
25
35
  };
26
36
 
37
+ export declare type DateTaggedValue = {
38
+ $type: 'DateTime';
39
+ value: string;
40
+ };
41
+
42
+ export declare type DecimalTaggedValue = {
43
+ $type: 'Decimal';
44
+ value: string;
45
+ };
46
+
27
47
  /**
28
48
  * Checks if two objects representing the names and values of key columns match. A match is
29
49
  * defined by one of the sets of keys being a subset of the other. This function also
@@ -31,6 +51,11 @@ export declare type DataRule = {
31
51
  */
32
52
  export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
33
53
 
54
+ export declare type EnumTaggedValue = {
55
+ $type: 'Enum';
56
+ value: string;
57
+ };
58
+
34
59
  declare type ExtendedSpanOptions = SpanOptions & {
35
60
  name: string;
36
61
  };
@@ -59,6 +84,13 @@ export declare type FieldOperation = {
59
84
  value: PrismaValue;
60
85
  };
61
86
 
87
+ export declare type FieldRefTaggedValue = {
88
+ $type: 'FieldRef';
89
+ value: {
90
+ _ref: string;
91
+ };
92
+ };
93
+
62
94
  export declare type Fragment = {
63
95
  type: 'stringChunk';
64
96
  chunk: string;
@@ -94,8 +126,19 @@ export declare type JoinExpression = {
94
126
  isRelationUnique: boolean;
95
127
  };
96
128
 
129
+ export declare type JsonInputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | FieldRefTaggedValue | JsonTaggedValue | EnumTaggedValue;
130
+
131
+ export declare type JsonOutputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | JsonTaggedValue;
132
+
133
+ export declare type JsonTaggedValue = {
134
+ $type: 'Json';
135
+ value: string;
136
+ };
137
+
97
138
  export declare const noopTracingHelper: TracingHelper;
98
139
 
140
+ export declare function normalizeJsonProtocolValues(result: unknown): unknown;
141
+
99
142
  export declare type Pagination = {
100
143
  cursor: Record<string, PrismaValue> | null;
101
144
  take: number | null;
package/dist/index.d.ts CHANGED
@@ -7,6 +7,16 @@ import { SqlQueryable } from '@prisma/driver-adapter-utils';
7
7
  import { SqlResultSet } from '@prisma/driver-adapter-utils';
8
8
  import { Transaction } from '@prisma/driver-adapter-utils';
9
9
 
10
+ export declare type BigIntTaggedValue = {
11
+ $type: 'BigInt';
12
+ value: string;
13
+ };
14
+
15
+ export declare type BytesTaggedValue = {
16
+ $type: 'Bytes';
17
+ value: string;
18
+ };
19
+
10
20
  export declare class DataMapperError extends Error {
11
21
  name: string;
12
22
  }
@@ -24,6 +34,16 @@ export declare type DataRule = {
24
34
  type: 'never';
25
35
  };
26
36
 
37
+ export declare type DateTaggedValue = {
38
+ $type: 'DateTime';
39
+ value: string;
40
+ };
41
+
42
+ export declare type DecimalTaggedValue = {
43
+ $type: 'Decimal';
44
+ value: string;
45
+ };
46
+
27
47
  /**
28
48
  * Checks if two objects representing the names and values of key columns match. A match is
29
49
  * defined by one of the sets of keys being a subset of the other. This function also
@@ -31,6 +51,11 @@ export declare type DataRule = {
31
51
  */
32
52
  export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
33
53
 
54
+ export declare type EnumTaggedValue = {
55
+ $type: 'Enum';
56
+ value: string;
57
+ };
58
+
34
59
  declare type ExtendedSpanOptions = SpanOptions & {
35
60
  name: string;
36
61
  };
@@ -59,6 +84,13 @@ export declare type FieldOperation = {
59
84
  value: PrismaValue;
60
85
  };
61
86
 
87
+ export declare type FieldRefTaggedValue = {
88
+ $type: 'FieldRef';
89
+ value: {
90
+ _ref: string;
91
+ };
92
+ };
93
+
62
94
  export declare type Fragment = {
63
95
  type: 'stringChunk';
64
96
  chunk: string;
@@ -94,8 +126,19 @@ export declare type JoinExpression = {
94
126
  isRelationUnique: boolean;
95
127
  };
96
128
 
129
+ export declare type JsonInputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | FieldRefTaggedValue | JsonTaggedValue | EnumTaggedValue;
130
+
131
+ export declare type JsonOutputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | JsonTaggedValue;
132
+
133
+ export declare type JsonTaggedValue = {
134
+ $type: 'Json';
135
+ value: string;
136
+ };
137
+
97
138
  export declare const noopTracingHelper: TracingHelper;
98
139
 
140
+ export declare function normalizeJsonProtocolValues(result: unknown): unknown;
141
+
99
142
  export declare type Pagination = {
100
143
  cursor: Record<string, PrismaValue> | null;
101
144
  take: number | null;
package/dist/index.js CHANGED
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  isPrismaValueGenerator: () => isPrismaValueGenerator,
43
43
  isPrismaValuePlaceholder: () => isPrismaValuePlaceholder,
44
44
  noopTracingHelper: () => noopTracingHelper,
45
+ normalizeJsonProtocolValues: () => normalizeJsonProtocolValues,
45
46
  safeJsonStringify: () => safeJsonStringify
46
47
  });
47
48
  module.exports = __toCommonJS(index_exports);
@@ -1394,6 +1395,53 @@ function evalFieldOperation(op, value, scope, generators) {
1394
1395
  }
1395
1396
  }
1396
1397
 
1398
+ // src/json-protocol.ts
1399
+ var import_decimal3 = require("decimal.js");
1400
+ function normalizeJsonProtocolValues(result) {
1401
+ if (result === null) {
1402
+ return result;
1403
+ }
1404
+ if (Array.isArray(result)) {
1405
+ return result.map(normalizeJsonProtocolValues);
1406
+ }
1407
+ if (typeof result === "object") {
1408
+ if (isTaggedValue(result)) {
1409
+ return normalizeTaggedValue(result);
1410
+ }
1411
+ if (result.constructor !== null && result.constructor.name !== "Object") {
1412
+ return result;
1413
+ }
1414
+ return mapObjectValues(result, normalizeJsonProtocolValues);
1415
+ }
1416
+ return result;
1417
+ }
1418
+ function isTaggedValue(value) {
1419
+ return value !== null && typeof value == "object" && typeof value["$type"] === "string";
1420
+ }
1421
+ function normalizeTaggedValue({ $type, value }) {
1422
+ switch ($type) {
1423
+ case "BigInt":
1424
+ return { $type, value: String(value) };
1425
+ case "Bytes":
1426
+ return { $type, value };
1427
+ case "DateTime":
1428
+ return { $type, value: new Date(value).toISOString() };
1429
+ case "Decimal":
1430
+ return { $type, value: String(new import_decimal3.Decimal(value)) };
1431
+ case "Json":
1432
+ return { $type, value: JSON.stringify(JSON.parse(value)) };
1433
+ default:
1434
+ assertNever(value, "Unknown tagged value");
1435
+ }
1436
+ }
1437
+ function mapObjectValues(object, mapper) {
1438
+ const result = {};
1439
+ for (const key of Object.keys(object)) {
1440
+ result[key] = mapper(object[key], key);
1441
+ }
1442
+ return result;
1443
+ }
1444
+
1397
1445
  // src/transactionManager/TransactionManager.ts
1398
1446
  var import_debug = require("@prisma/debug");
1399
1447
 
@@ -1655,5 +1703,6 @@ var TransactionManager = class {
1655
1703
  isPrismaValueGenerator,
1656
1704
  isPrismaValuePlaceholder,
1657
1705
  noopTracingHelper,
1706
+ normalizeJsonProtocolValues,
1658
1707
  safeJsonStringify
1659
1708
  });
package/dist/index.mjs CHANGED
@@ -1346,6 +1346,53 @@ function evalFieldOperation(op, value, scope, generators) {
1346
1346
  }
1347
1347
  }
1348
1348
 
1349
+ // src/json-protocol.ts
1350
+ import { Decimal as Decimal3 } from "decimal.js";
1351
+ function normalizeJsonProtocolValues(result) {
1352
+ if (result === null) {
1353
+ return result;
1354
+ }
1355
+ if (Array.isArray(result)) {
1356
+ return result.map(normalizeJsonProtocolValues);
1357
+ }
1358
+ if (typeof result === "object") {
1359
+ if (isTaggedValue(result)) {
1360
+ return normalizeTaggedValue(result);
1361
+ }
1362
+ if (result.constructor !== null && result.constructor.name !== "Object") {
1363
+ return result;
1364
+ }
1365
+ return mapObjectValues(result, normalizeJsonProtocolValues);
1366
+ }
1367
+ return result;
1368
+ }
1369
+ function isTaggedValue(value) {
1370
+ return value !== null && typeof value == "object" && typeof value["$type"] === "string";
1371
+ }
1372
+ function normalizeTaggedValue({ $type, value }) {
1373
+ switch ($type) {
1374
+ case "BigInt":
1375
+ return { $type, value: String(value) };
1376
+ case "Bytes":
1377
+ return { $type, value };
1378
+ case "DateTime":
1379
+ return { $type, value: new Date(value).toISOString() };
1380
+ case "Decimal":
1381
+ return { $type, value: String(new Decimal3(value)) };
1382
+ case "Json":
1383
+ return { $type, value: JSON.stringify(JSON.parse(value)) };
1384
+ default:
1385
+ assertNever(value, "Unknown tagged value");
1386
+ }
1387
+ }
1388
+ function mapObjectValues(object, mapper) {
1389
+ const result = {};
1390
+ for (const key of Object.keys(object)) {
1391
+ result[key] = mapper(object[key], key);
1392
+ }
1393
+ return result;
1394
+ }
1395
+
1349
1396
  // src/transactionManager/TransactionManager.ts
1350
1397
  import { Debug } from "@prisma/debug";
1351
1398
 
@@ -1606,5 +1653,6 @@ export {
1606
1653
  isPrismaValueGenerator,
1607
1654
  isPrismaValuePlaceholder,
1608
1655
  noopTracingHelper,
1656
+ normalizeJsonProtocolValues,
1609
1657
  safeJsonStringify
1610
1658
  };
@@ -0,0 +1,33 @@
1
+ export type DateTaggedValue = {
2
+ $type: 'DateTime';
3
+ value: string;
4
+ };
5
+ export type DecimalTaggedValue = {
6
+ $type: 'Decimal';
7
+ value: string;
8
+ };
9
+ export type BytesTaggedValue = {
10
+ $type: 'Bytes';
11
+ value: string;
12
+ };
13
+ export type BigIntTaggedValue = {
14
+ $type: 'BigInt';
15
+ value: string;
16
+ };
17
+ export type FieldRefTaggedValue = {
18
+ $type: 'FieldRef';
19
+ value: {
20
+ _ref: string;
21
+ };
22
+ };
23
+ export type EnumTaggedValue = {
24
+ $type: 'Enum';
25
+ value: string;
26
+ };
27
+ export type JsonTaggedValue = {
28
+ $type: 'Json';
29
+ value: string;
30
+ };
31
+ export type JsonInputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | FieldRefTaggedValue | JsonTaggedValue | EnumTaggedValue;
32
+ export type JsonOutputTaggedValue = DateTaggedValue | DecimalTaggedValue | BytesTaggedValue | BigIntTaggedValue | JsonTaggedValue;
33
+ export declare function normalizeJsonProtocolValues(result: unknown): unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.12.0-dev.21",
3
+ "version": "6.12.0-dev.22",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,8 +31,8 @@
31
31
  "nanoid": "5.1.5",
32
32
  "ulid": "3.0.0",
33
33
  "uuid": "11.1.0",
34
- "@prisma/debug": "6.12.0-dev.21",
35
- "@prisma/driver-adapter-utils": "6.12.0-dev.21"
34
+ "@prisma/driver-adapter-utils": "6.12.0-dev.22",
35
+ "@prisma/debug": "6.12.0-dev.22"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",