@prisma/client-engine-runtime 6.12.0-dev.4 → 6.12.0-dev.40
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 +43 -2
- package/dist/index.d.ts +43 -2
- package/dist/index.js +120 -17
- package/dist/index.mjs +119 -17
- package/dist/json-protocol.d.ts +33 -0
- package/dist/schema.d.ts +1 -2
- package/package.json +4 -5
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,15 @@ 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
|
-
declare type
|
|
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
|
+
};
|
|
11
19
|
|
|
12
20
|
export declare class DataMapperError extends Error {
|
|
13
21
|
name: string;
|
|
@@ -26,6 +34,16 @@ export declare type DataRule = {
|
|
|
26
34
|
type: 'never';
|
|
27
35
|
};
|
|
28
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
|
+
|
|
29
47
|
/**
|
|
30
48
|
* Checks if two objects representing the names and values of key columns match. A match is
|
|
31
49
|
* defined by one of the sets of keys being a subset of the other. This function also
|
|
@@ -33,6 +51,11 @@ export declare type DataRule = {
|
|
|
33
51
|
*/
|
|
34
52
|
export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
|
|
35
53
|
|
|
54
|
+
export declare type EnumTaggedValue = {
|
|
55
|
+
$type: 'Enum';
|
|
56
|
+
value: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
36
59
|
declare type ExtendedSpanOptions = SpanOptions & {
|
|
37
60
|
name: string;
|
|
38
61
|
};
|
|
@@ -61,6 +84,13 @@ export declare type FieldOperation = {
|
|
|
61
84
|
value: PrismaValue;
|
|
62
85
|
};
|
|
63
86
|
|
|
87
|
+
export declare type FieldRefTaggedValue = {
|
|
88
|
+
$type: 'FieldRef';
|
|
89
|
+
value: {
|
|
90
|
+
_ref: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
64
94
|
export declare type Fragment = {
|
|
65
95
|
type: 'stringChunk';
|
|
66
96
|
chunk: string;
|
|
@@ -96,8 +126,19 @@ export declare type JoinExpression = {
|
|
|
96
126
|
isRelationUnique: boolean;
|
|
97
127
|
};
|
|
98
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
|
+
|
|
99
138
|
export declare const noopTracingHelper: TracingHelper;
|
|
100
139
|
|
|
140
|
+
export declare function normalizeJsonProtocolValues(result: unknown): unknown;
|
|
141
|
+
|
|
101
142
|
export declare type Pagination = {
|
|
102
143
|
cursor: Record<string, PrismaValue> | null;
|
|
103
144
|
take: number | null;
|
|
@@ -356,7 +397,7 @@ export declare function safeJsonStringify(obj: unknown): string;
|
|
|
356
397
|
/**
|
|
357
398
|
* `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
|
|
358
399
|
*/
|
|
359
|
-
export declare type SchemaProvider =
|
|
400
|
+
export declare type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
|
|
360
401
|
|
|
361
402
|
declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
|
362
403
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,15 @@ 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
|
-
declare type
|
|
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
|
+
};
|
|
11
19
|
|
|
12
20
|
export declare class DataMapperError extends Error {
|
|
13
21
|
name: string;
|
|
@@ -26,6 +34,16 @@ export declare type DataRule = {
|
|
|
26
34
|
type: 'never';
|
|
27
35
|
};
|
|
28
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
|
+
|
|
29
47
|
/**
|
|
30
48
|
* Checks if two objects representing the names and values of key columns match. A match is
|
|
31
49
|
* defined by one of the sets of keys being a subset of the other. This function also
|
|
@@ -33,6 +51,11 @@ export declare type DataRule = {
|
|
|
33
51
|
*/
|
|
34
52
|
export declare function doKeysMatch(lhs: {}, rhs: {}): boolean;
|
|
35
53
|
|
|
54
|
+
export declare type EnumTaggedValue = {
|
|
55
|
+
$type: 'Enum';
|
|
56
|
+
value: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
36
59
|
declare type ExtendedSpanOptions = SpanOptions & {
|
|
37
60
|
name: string;
|
|
38
61
|
};
|
|
@@ -61,6 +84,13 @@ export declare type FieldOperation = {
|
|
|
61
84
|
value: PrismaValue;
|
|
62
85
|
};
|
|
63
86
|
|
|
87
|
+
export declare type FieldRefTaggedValue = {
|
|
88
|
+
$type: 'FieldRef';
|
|
89
|
+
value: {
|
|
90
|
+
_ref: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
64
94
|
export declare type Fragment = {
|
|
65
95
|
type: 'stringChunk';
|
|
66
96
|
chunk: string;
|
|
@@ -96,8 +126,19 @@ export declare type JoinExpression = {
|
|
|
96
126
|
isRelationUnique: boolean;
|
|
97
127
|
};
|
|
98
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
|
+
|
|
99
138
|
export declare const noopTracingHelper: TracingHelper;
|
|
100
139
|
|
|
140
|
+
export declare function normalizeJsonProtocolValues(result: unknown): unknown;
|
|
141
|
+
|
|
101
142
|
export declare type Pagination = {
|
|
102
143
|
cursor: Record<string, PrismaValue> | null;
|
|
103
144
|
take: number | null;
|
|
@@ -356,7 +397,7 @@ export declare function safeJsonStringify(obj: unknown): string;
|
|
|
356
397
|
/**
|
|
357
398
|
* `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
|
|
358
399
|
*/
|
|
359
|
-
export declare type SchemaProvider =
|
|
400
|
+
export declare type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
|
|
360
401
|
|
|
361
402
|
declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
|
362
403
|
|
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);
|
|
@@ -62,20 +63,74 @@ function doKeysMatch(lhs, rhs) {
|
|
|
62
63
|
const rhsKeys = Object.keys(rhs);
|
|
63
64
|
const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
|
|
64
65
|
return smallerKeyList.every((key) => {
|
|
65
|
-
if (typeof lhs[key]
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
|
|
67
|
+
return lhs[key] === rhs[key];
|
|
68
|
+
}
|
|
69
|
+
if (import_decimal.default.isDecimal(lhs[key]) || import_decimal.default.isDecimal(rhs[key])) {
|
|
70
|
+
const lhsDecimal = asDecimal(lhs[key]);
|
|
71
|
+
const rhsDecimal = asDecimal(rhs[key]);
|
|
72
|
+
return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
|
|
73
|
+
} else if (lhs[key] instanceof Uint8Array || rhs[key] instanceof Uint8Array) {
|
|
74
|
+
const lhsBuffer = asBuffer(lhs[key]);
|
|
75
|
+
const rhsBuffer = asBuffer(rhs[key]);
|
|
76
|
+
return lhsBuffer && rhsBuffer && lhsBuffer.equals(rhsBuffer);
|
|
77
|
+
} else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
|
|
78
|
+
return asDate(lhs[key])?.getTime() === asDate(rhs[key])?.getTime();
|
|
79
|
+
} else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
|
|
80
|
+
return asBigInt(lhs[key]) === asBigInt(rhs[key]);
|
|
81
|
+
} else if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
|
|
82
|
+
return asNumber(lhs[key]) === asNumber(rhs[key]);
|
|
75
83
|
}
|
|
76
84
|
return isDeepStrictEqual(lhs[key], rhs[key]);
|
|
77
85
|
});
|
|
78
86
|
}
|
|
87
|
+
function asDecimal(value) {
|
|
88
|
+
if (import_decimal.default.isDecimal(value)) {
|
|
89
|
+
return value;
|
|
90
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
91
|
+
return new import_decimal.default(value);
|
|
92
|
+
} else {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function asBuffer(value) {
|
|
97
|
+
if (Buffer.isBuffer(value)) {
|
|
98
|
+
return value;
|
|
99
|
+
} else if (value instanceof Uint8Array) {
|
|
100
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
101
|
+
} else if (typeof value === "string") {
|
|
102
|
+
return Buffer.from(value, "base64");
|
|
103
|
+
} else {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function asDate(value) {
|
|
108
|
+
if (value instanceof Date) {
|
|
109
|
+
return value;
|
|
110
|
+
} else if (typeof value === "string" || typeof value === "number") {
|
|
111
|
+
return new Date(value);
|
|
112
|
+
} else {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function asBigInt(value) {
|
|
117
|
+
if (typeof value === "bigint") {
|
|
118
|
+
return value;
|
|
119
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
120
|
+
return BigInt(value);
|
|
121
|
+
} else {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function asNumber(value) {
|
|
126
|
+
if (typeof value === "number") {
|
|
127
|
+
return value;
|
|
128
|
+
} else if (typeof value === "string") {
|
|
129
|
+
return Number(value);
|
|
130
|
+
} else {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
79
134
|
function safeJsonStringify(obj) {
|
|
80
135
|
return JSON.stringify(obj, (_key, val) => {
|
|
81
136
|
if (typeof val === "bigint") {
|
|
@@ -1063,7 +1118,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1063
1118
|
node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
|
|
1064
1119
|
);
|
|
1065
1120
|
return {
|
|
1066
|
-
value: parts.length > 0 ? parts.reduce((acc, part) =>
|
|
1121
|
+
value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
|
|
1067
1122
|
};
|
|
1068
1123
|
}
|
|
1069
1124
|
case "execute": {
|
|
@@ -1237,7 +1292,7 @@ function isEmpty(value) {
|
|
|
1237
1292
|
function asList(value) {
|
|
1238
1293
|
return Array.isArray(value) ? value : [value];
|
|
1239
1294
|
}
|
|
1240
|
-
function
|
|
1295
|
+
function asNumber2(value) {
|
|
1241
1296
|
if (typeof value === "number") {
|
|
1242
1297
|
return value;
|
|
1243
1298
|
}
|
|
@@ -1322,14 +1377,14 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1322
1377
|
case "set":
|
|
1323
1378
|
return evaluateParam(op.value, scope, generators);
|
|
1324
1379
|
case "add":
|
|
1325
|
-
return
|
|
1380
|
+
return asNumber2(value) + asNumber2(evaluateParam(op.value, scope, generators));
|
|
1326
1381
|
case "subtract":
|
|
1327
|
-
return
|
|
1382
|
+
return asNumber2(value) - asNumber2(evaluateParam(op.value, scope, generators));
|
|
1328
1383
|
case "multiply":
|
|
1329
|
-
return
|
|
1384
|
+
return asNumber2(value) * asNumber2(evaluateParam(op.value, scope, generators));
|
|
1330
1385
|
case "divide": {
|
|
1331
|
-
const lhs =
|
|
1332
|
-
const rhs =
|
|
1386
|
+
const lhs = asNumber2(value);
|
|
1387
|
+
const rhs = asNumber2(evaluateParam(op.value, scope, generators));
|
|
1333
1388
|
if (rhs === 0) {
|
|
1334
1389
|
return null;
|
|
1335
1390
|
}
|
|
@@ -1340,6 +1395,53 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1340
1395
|
}
|
|
1341
1396
|
}
|
|
1342
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
|
+
|
|
1343
1445
|
// src/transactionManager/TransactionManager.ts
|
|
1344
1446
|
var import_debug = require("@prisma/debug");
|
|
1345
1447
|
|
|
@@ -1601,5 +1703,6 @@ var TransactionManager = class {
|
|
|
1601
1703
|
isPrismaValueGenerator,
|
|
1602
1704
|
isPrismaValuePlaceholder,
|
|
1603
1705
|
noopTracingHelper,
|
|
1706
|
+
normalizeJsonProtocolValues,
|
|
1604
1707
|
safeJsonStringify
|
|
1605
1708
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -14,20 +14,74 @@ function doKeysMatch(lhs, rhs) {
|
|
|
14
14
|
const rhsKeys = Object.keys(rhs);
|
|
15
15
|
const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
|
|
16
16
|
return smallerKeyList.every((key) => {
|
|
17
|
-
if (typeof lhs[key]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
|
|
18
|
+
return lhs[key] === rhs[key];
|
|
19
|
+
}
|
|
20
|
+
if (Decimal.isDecimal(lhs[key]) || Decimal.isDecimal(rhs[key])) {
|
|
21
|
+
const lhsDecimal = asDecimal(lhs[key]);
|
|
22
|
+
const rhsDecimal = asDecimal(rhs[key]);
|
|
23
|
+
return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
|
|
24
|
+
} else if (lhs[key] instanceof Uint8Array || rhs[key] instanceof Uint8Array) {
|
|
25
|
+
const lhsBuffer = asBuffer(lhs[key]);
|
|
26
|
+
const rhsBuffer = asBuffer(rhs[key]);
|
|
27
|
+
return lhsBuffer && rhsBuffer && lhsBuffer.equals(rhsBuffer);
|
|
28
|
+
} else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
|
|
29
|
+
return asDate(lhs[key])?.getTime() === asDate(rhs[key])?.getTime();
|
|
30
|
+
} else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
|
|
31
|
+
return asBigInt(lhs[key]) === asBigInt(rhs[key]);
|
|
32
|
+
} else if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
|
|
33
|
+
return asNumber(lhs[key]) === asNumber(rhs[key]);
|
|
27
34
|
}
|
|
28
35
|
return isDeepStrictEqual(lhs[key], rhs[key]);
|
|
29
36
|
});
|
|
30
37
|
}
|
|
38
|
+
function asDecimal(value) {
|
|
39
|
+
if (Decimal.isDecimal(value)) {
|
|
40
|
+
return value;
|
|
41
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
42
|
+
return new Decimal(value);
|
|
43
|
+
} else {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function asBuffer(value) {
|
|
48
|
+
if (Buffer.isBuffer(value)) {
|
|
49
|
+
return value;
|
|
50
|
+
} else if (value instanceof Uint8Array) {
|
|
51
|
+
return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
52
|
+
} else if (typeof value === "string") {
|
|
53
|
+
return Buffer.from(value, "base64");
|
|
54
|
+
} else {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function asDate(value) {
|
|
59
|
+
if (value instanceof Date) {
|
|
60
|
+
return value;
|
|
61
|
+
} else if (typeof value === "string" || typeof value === "number") {
|
|
62
|
+
return new Date(value);
|
|
63
|
+
} else {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function asBigInt(value) {
|
|
68
|
+
if (typeof value === "bigint") {
|
|
69
|
+
return value;
|
|
70
|
+
} else if (typeof value === "number" || typeof value === "string") {
|
|
71
|
+
return BigInt(value);
|
|
72
|
+
} else {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function asNumber(value) {
|
|
77
|
+
if (typeof value === "number") {
|
|
78
|
+
return value;
|
|
79
|
+
} else if (typeof value === "string") {
|
|
80
|
+
return Number(value);
|
|
81
|
+
} else {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
31
85
|
function safeJsonStringify(obj) {
|
|
32
86
|
return JSON.stringify(obj, (_key, val) => {
|
|
33
87
|
if (typeof val === "bigint") {
|
|
@@ -1015,7 +1069,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1015
1069
|
node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
|
|
1016
1070
|
);
|
|
1017
1071
|
return {
|
|
1018
|
-
value: parts.length > 0 ? parts.reduce((acc, part) =>
|
|
1072
|
+
value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
|
|
1019
1073
|
};
|
|
1020
1074
|
}
|
|
1021
1075
|
case "execute": {
|
|
@@ -1189,7 +1243,7 @@ function isEmpty(value) {
|
|
|
1189
1243
|
function asList(value) {
|
|
1190
1244
|
return Array.isArray(value) ? value : [value];
|
|
1191
1245
|
}
|
|
1192
|
-
function
|
|
1246
|
+
function asNumber2(value) {
|
|
1193
1247
|
if (typeof value === "number") {
|
|
1194
1248
|
return value;
|
|
1195
1249
|
}
|
|
@@ -1274,14 +1328,14 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1274
1328
|
case "set":
|
|
1275
1329
|
return evaluateParam(op.value, scope, generators);
|
|
1276
1330
|
case "add":
|
|
1277
|
-
return
|
|
1331
|
+
return asNumber2(value) + asNumber2(evaluateParam(op.value, scope, generators));
|
|
1278
1332
|
case "subtract":
|
|
1279
|
-
return
|
|
1333
|
+
return asNumber2(value) - asNumber2(evaluateParam(op.value, scope, generators));
|
|
1280
1334
|
case "multiply":
|
|
1281
|
-
return
|
|
1335
|
+
return asNumber2(value) * asNumber2(evaluateParam(op.value, scope, generators));
|
|
1282
1336
|
case "divide": {
|
|
1283
|
-
const lhs =
|
|
1284
|
-
const rhs =
|
|
1337
|
+
const lhs = asNumber2(value);
|
|
1338
|
+
const rhs = asNumber2(evaluateParam(op.value, scope, generators));
|
|
1285
1339
|
if (rhs === 0) {
|
|
1286
1340
|
return null;
|
|
1287
1341
|
}
|
|
@@ -1292,6 +1346,53 @@ function evalFieldOperation(op, value, scope, generators) {
|
|
|
1292
1346
|
}
|
|
1293
1347
|
}
|
|
1294
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
|
+
|
|
1295
1396
|
// src/transactionManager/TransactionManager.ts
|
|
1296
1397
|
import { Debug } from "@prisma/debug";
|
|
1297
1398
|
|
|
@@ -1552,5 +1653,6 @@ export {
|
|
|
1552
1653
|
isPrismaValueGenerator,
|
|
1553
1654
|
isPrismaValuePlaceholder,
|
|
1554
1655
|
noopTracingHelper,
|
|
1656
|
+
normalizeJsonProtocolValues,
|
|
1555
1657
|
safeJsonStringify
|
|
1556
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/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ConnectorType } from '@prisma/generator';
|
|
2
1
|
/**
|
|
3
2
|
* `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
|
|
4
3
|
*/
|
|
5
|
-
export type SchemaProvider =
|
|
4
|
+
export type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-engine-runtime",
|
|
3
|
-
"version": "6.12.0-dev.
|
|
3
|
+
"version": "6.12.0-dev.40",
|
|
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,15 +31,14 @@
|
|
|
31
31
|
"nanoid": "5.1.5",
|
|
32
32
|
"ulid": "3.0.0",
|
|
33
33
|
"uuid": "11.1.0",
|
|
34
|
-
"@prisma/
|
|
35
|
-
"@prisma/
|
|
34
|
+
"@prisma/debug": "6.12.0-dev.40",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.12.0-dev.40"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|
|
39
39
|
"@types/node": "18.19.76",
|
|
40
40
|
"jest": "29.7.0",
|
|
41
|
-
"jest-junit": "16.0.0"
|
|
42
|
-
"@prisma/generator": "6.12.0-dev.4"
|
|
41
|
+
"jest-junit": "16.0.0"
|
|
43
42
|
},
|
|
44
43
|
"files": [
|
|
45
44
|
"dist"
|