@prisma/client-engine-runtime 6.9.0-dev.10 → 6.9.0-dev.12
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 +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +118 -97
- package/dist/index.mjs +117 -97
- package/dist/interpreter/DataMapper.d.ts +3 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,10 @@ 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 class DataMapperError extends Error {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export declare type DataRule = {
|
|
11
15
|
type: 'rowCountEq';
|
|
12
16
|
args: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ 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 class DataMapperError extends Error {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export declare type DataRule = {
|
|
11
15
|
type: 'rowCountEq';
|
|
12
16
|
args: number;
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
DataMapperError: () => DataMapperError,
|
|
33
34
|
QueryInterpreter: () => QueryInterpreter,
|
|
34
35
|
TransactionManager: () => TransactionManager,
|
|
35
36
|
TransactionManagerError: () => TransactionManagerError,
|
|
@@ -42,8 +43,8 @@ __export(index_exports, {
|
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(index_exports);
|
|
44
45
|
|
|
45
|
-
// src/interpreter/
|
|
46
|
-
var
|
|
46
|
+
// src/interpreter/DataMapper.ts
|
|
47
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
47
48
|
|
|
48
49
|
// src/utils.ts
|
|
49
50
|
function assertNever(_, message) {
|
|
@@ -53,6 +54,117 @@ function isDeepStrictEqual(a, b) {
|
|
|
53
54
|
return a === b || a !== null && b !== null && typeof a === "object" && typeof b === "object" && Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((key) => isDeepStrictEqual(a[key], b[key]));
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
// src/interpreter/DataMapper.ts
|
|
58
|
+
var DataMapperError = class extends Error {
|
|
59
|
+
name = "DataMapperError";
|
|
60
|
+
};
|
|
61
|
+
function applyDataMap(data, structure) {
|
|
62
|
+
switch (structure.type) {
|
|
63
|
+
case "Object":
|
|
64
|
+
return mapArrayOrObject(data, structure.fields);
|
|
65
|
+
case "Value":
|
|
66
|
+
return mapValue(data, structure.resultType);
|
|
67
|
+
default:
|
|
68
|
+
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function mapArrayOrObject(data, fields) {
|
|
72
|
+
if (data === null) return null;
|
|
73
|
+
if (Array.isArray(data)) {
|
|
74
|
+
const rows = data;
|
|
75
|
+
return rows.map((row) => mapObject(row, fields));
|
|
76
|
+
}
|
|
77
|
+
if (typeof data === "object") {
|
|
78
|
+
const row = data;
|
|
79
|
+
return mapObject(row, fields);
|
|
80
|
+
}
|
|
81
|
+
if (typeof data === "string") {
|
|
82
|
+
let decodedData;
|
|
83
|
+
try {
|
|
84
|
+
decodedData = JSON.parse(data);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw new DataMapperError(`Expected an array or object, got a string that is not valid JSON`, {
|
|
87
|
+
cause: error
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return mapArrayOrObject(decodedData, fields);
|
|
91
|
+
}
|
|
92
|
+
throw new DataMapperError(`Expected an array or an object, got: ${typeof data}`);
|
|
93
|
+
}
|
|
94
|
+
function mapObject(data, fields) {
|
|
95
|
+
if (typeof data !== "object") {
|
|
96
|
+
throw new DataMapperError(`Expected an object, but got '${typeof data}'`);
|
|
97
|
+
}
|
|
98
|
+
const result = {};
|
|
99
|
+
for (const [name, node] of Object.entries(fields)) {
|
|
100
|
+
switch (node.type) {
|
|
101
|
+
case "Object": {
|
|
102
|
+
if (!node.flattened && !Object.hasOwn(data, name)) {
|
|
103
|
+
throw new DataMapperError(
|
|
104
|
+
`Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const target = node.flattened ? data : data[name];
|
|
108
|
+
result[name] = mapArrayOrObject(target, node.fields);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
case "Value":
|
|
112
|
+
{
|
|
113
|
+
const dbName = node.dbName;
|
|
114
|
+
if (Object.hasOwn(data, dbName)) {
|
|
115
|
+
result[name] = mapValue(data[dbName], node.resultType);
|
|
116
|
+
} else {
|
|
117
|
+
throw new DataMapperError(
|
|
118
|
+
`Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
assertNever(node, `DataMapper: Invalid data mapping node type: '${node.type}'`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
function mapValue(value, resultType) {
|
|
130
|
+
if (value === null) return null;
|
|
131
|
+
switch (resultType.type) {
|
|
132
|
+
case "Any":
|
|
133
|
+
return value;
|
|
134
|
+
case "String":
|
|
135
|
+
return typeof value === "string" ? value : `${value}`;
|
|
136
|
+
case "Int":
|
|
137
|
+
return typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
138
|
+
case "BigInt":
|
|
139
|
+
return typeof value === "bigint" ? value : BigInt(`${value}`);
|
|
140
|
+
case "Float":
|
|
141
|
+
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
142
|
+
case "Boolean":
|
|
143
|
+
return typeof value === "boolean" ? value : value !== "0";
|
|
144
|
+
case "Decimal":
|
|
145
|
+
return typeof value === "number" ? new import_decimal.default(value) : new import_decimal.default(`${value}`);
|
|
146
|
+
case "Date":
|
|
147
|
+
return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
|
|
148
|
+
case "Array": {
|
|
149
|
+
const values = value;
|
|
150
|
+
return values.map((v) => mapValue(v, resultType.inner));
|
|
151
|
+
}
|
|
152
|
+
case "Object":
|
|
153
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
154
|
+
case "Bytes": {
|
|
155
|
+
if (!Array.isArray(value)) {
|
|
156
|
+
throw new DataMapperError(`Bytes data is invalid, got: ${typeof value}`);
|
|
157
|
+
}
|
|
158
|
+
return new Uint8Array(value);
|
|
159
|
+
}
|
|
160
|
+
default:
|
|
161
|
+
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// src/interpreter/QueryInterpreter.ts
|
|
166
|
+
var import_api = require("@opentelemetry/api");
|
|
167
|
+
|
|
56
168
|
// src/tracing.ts
|
|
57
169
|
var noopTracingHelper = {
|
|
58
170
|
runInChildSpan(_, callback) {
|
|
@@ -215,101 +327,6 @@ function renderConstraint(constraint) {
|
|
|
215
327
|
return "(not available)";
|
|
216
328
|
}
|
|
217
329
|
|
|
218
|
-
// src/interpreter/DataMapper.ts
|
|
219
|
-
var import_decimal = __toESM(require("decimal.js"));
|
|
220
|
-
function applyDataMap(data, structure) {
|
|
221
|
-
switch (structure.type) {
|
|
222
|
-
case "Object":
|
|
223
|
-
return mapArrayOrObject(data, structure.fields);
|
|
224
|
-
case "Value":
|
|
225
|
-
return mapValue(data, structure.resultType);
|
|
226
|
-
default:
|
|
227
|
-
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function mapArrayOrObject(data, fields) {
|
|
231
|
-
if (data === null) return null;
|
|
232
|
-
if (Array.isArray(data)) {
|
|
233
|
-
const rows = data;
|
|
234
|
-
return rows.map((row) => mapObject(row, fields));
|
|
235
|
-
}
|
|
236
|
-
if (typeof data === "object") {
|
|
237
|
-
const row = data;
|
|
238
|
-
return mapObject(row, fields);
|
|
239
|
-
}
|
|
240
|
-
throw new Error(`DataMapper: Expected an array or an object, got: ${typeof data}`);
|
|
241
|
-
}
|
|
242
|
-
function mapObject(data, fields) {
|
|
243
|
-
if (typeof data !== "object") {
|
|
244
|
-
throw new Error(`DataMapper: Expected an object, but got '${typeof data}'`);
|
|
245
|
-
}
|
|
246
|
-
const result = {};
|
|
247
|
-
for (const [name, node] of Object.entries(fields)) {
|
|
248
|
-
switch (node.type) {
|
|
249
|
-
case "Object": {
|
|
250
|
-
if (!node.flattened && !Object.hasOwn(data, name)) {
|
|
251
|
-
throw new Error(
|
|
252
|
-
`DataMapper: Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
const target = node.flattened ? data : data[name];
|
|
256
|
-
result[name] = mapArrayOrObject(target, node.fields);
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
case "Value":
|
|
260
|
-
{
|
|
261
|
-
const dbName = node.dbName;
|
|
262
|
-
if (Object.hasOwn(data, dbName)) {
|
|
263
|
-
result[name] = mapValue(data[dbName], node.resultType);
|
|
264
|
-
} else {
|
|
265
|
-
throw new Error(
|
|
266
|
-
`DataMapper: Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
break;
|
|
271
|
-
default:
|
|
272
|
-
assertNever(node, `DataMapper: Invalid data mapping node type: '${node.type}'`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return result;
|
|
276
|
-
}
|
|
277
|
-
function mapValue(value, resultType) {
|
|
278
|
-
if (value === null) return null;
|
|
279
|
-
switch (resultType.type) {
|
|
280
|
-
case "Any":
|
|
281
|
-
return value;
|
|
282
|
-
case "String":
|
|
283
|
-
return typeof value === "string" ? value : `${value}`;
|
|
284
|
-
case "Int":
|
|
285
|
-
return typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
286
|
-
case "BigInt":
|
|
287
|
-
return typeof value === "bigint" ? value : BigInt(`${value}`);
|
|
288
|
-
case "Float":
|
|
289
|
-
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
290
|
-
case "Boolean":
|
|
291
|
-
return typeof value === "boolean" ? value : value !== "0";
|
|
292
|
-
case "Decimal":
|
|
293
|
-
return typeof value === "number" ? new import_decimal.default(value) : new import_decimal.default(`${value}`);
|
|
294
|
-
case "Date":
|
|
295
|
-
return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
|
|
296
|
-
case "Array": {
|
|
297
|
-
const values = value;
|
|
298
|
-
return values.map((v) => mapValue(v, resultType.inner));
|
|
299
|
-
}
|
|
300
|
-
case "Object":
|
|
301
|
-
return typeof value === "string" ? value : JSON.stringify(value);
|
|
302
|
-
case "Bytes": {
|
|
303
|
-
if (!Array.isArray(value)) {
|
|
304
|
-
throw new Error(`DataMapper: Bytes data is invalid, got: ${typeof value}`);
|
|
305
|
-
}
|
|
306
|
-
return new Uint8Array(value);
|
|
307
|
-
}
|
|
308
|
-
default:
|
|
309
|
-
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
330
|
// src/interpreter/generators.ts
|
|
314
331
|
var import_cuid = __toESM(require("@bugsnag/cuid"));
|
|
315
332
|
var import_cuid2 = require("@paralleldrive/cuid2");
|
|
@@ -742,6 +759,9 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
742
759
|
}
|
|
743
760
|
case "join": {
|
|
744
761
|
const parent = await this.interpretNode(node.args.parent, queryable, scope, generators);
|
|
762
|
+
if (parent === null) {
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
745
765
|
const children = await Promise.all(
|
|
746
766
|
node.args.children.map(async (joinExpr) => ({
|
|
747
767
|
joinExpr,
|
|
@@ -1160,6 +1180,7 @@ var TransactionManager = class {
|
|
|
1160
1180
|
};
|
|
1161
1181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1162
1182
|
0 && (module.exports = {
|
|
1183
|
+
DataMapperError,
|
|
1163
1184
|
QueryInterpreter,
|
|
1164
1185
|
TransactionManager,
|
|
1165
1186
|
TransactionManagerError,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// src/interpreter/
|
|
2
|
-
import
|
|
1
|
+
// src/interpreter/DataMapper.ts
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
3
|
|
|
4
4
|
// src/utils.ts
|
|
5
5
|
function assertNever(_, message) {
|
|
@@ -9,6 +9,117 @@ function isDeepStrictEqual(a, b) {
|
|
|
9
9
|
return a === b || a !== null && b !== null && typeof a === "object" && typeof b === "object" && Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((key) => isDeepStrictEqual(a[key], b[key]));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// src/interpreter/DataMapper.ts
|
|
13
|
+
var DataMapperError = class extends Error {
|
|
14
|
+
name = "DataMapperError";
|
|
15
|
+
};
|
|
16
|
+
function applyDataMap(data, structure) {
|
|
17
|
+
switch (structure.type) {
|
|
18
|
+
case "Object":
|
|
19
|
+
return mapArrayOrObject(data, structure.fields);
|
|
20
|
+
case "Value":
|
|
21
|
+
return mapValue(data, structure.resultType);
|
|
22
|
+
default:
|
|
23
|
+
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function mapArrayOrObject(data, fields) {
|
|
27
|
+
if (data === null) return null;
|
|
28
|
+
if (Array.isArray(data)) {
|
|
29
|
+
const rows = data;
|
|
30
|
+
return rows.map((row) => mapObject(row, fields));
|
|
31
|
+
}
|
|
32
|
+
if (typeof data === "object") {
|
|
33
|
+
const row = data;
|
|
34
|
+
return mapObject(row, fields);
|
|
35
|
+
}
|
|
36
|
+
if (typeof data === "string") {
|
|
37
|
+
let decodedData;
|
|
38
|
+
try {
|
|
39
|
+
decodedData = JSON.parse(data);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
throw new DataMapperError(`Expected an array or object, got a string that is not valid JSON`, {
|
|
42
|
+
cause: error
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return mapArrayOrObject(decodedData, fields);
|
|
46
|
+
}
|
|
47
|
+
throw new DataMapperError(`Expected an array or an object, got: ${typeof data}`);
|
|
48
|
+
}
|
|
49
|
+
function mapObject(data, fields) {
|
|
50
|
+
if (typeof data !== "object") {
|
|
51
|
+
throw new DataMapperError(`Expected an object, but got '${typeof data}'`);
|
|
52
|
+
}
|
|
53
|
+
const result = {};
|
|
54
|
+
for (const [name, node] of Object.entries(fields)) {
|
|
55
|
+
switch (node.type) {
|
|
56
|
+
case "Object": {
|
|
57
|
+
if (!node.flattened && !Object.hasOwn(data, name)) {
|
|
58
|
+
throw new DataMapperError(
|
|
59
|
+
`Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const target = node.flattened ? data : data[name];
|
|
63
|
+
result[name] = mapArrayOrObject(target, node.fields);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case "Value":
|
|
67
|
+
{
|
|
68
|
+
const dbName = node.dbName;
|
|
69
|
+
if (Object.hasOwn(data, dbName)) {
|
|
70
|
+
result[name] = mapValue(data[dbName], node.resultType);
|
|
71
|
+
} else {
|
|
72
|
+
throw new DataMapperError(
|
|
73
|
+
`Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
assertNever(node, `DataMapper: Invalid data mapping node type: '${node.type}'`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
function mapValue(value, resultType) {
|
|
85
|
+
if (value === null) return null;
|
|
86
|
+
switch (resultType.type) {
|
|
87
|
+
case "Any":
|
|
88
|
+
return value;
|
|
89
|
+
case "String":
|
|
90
|
+
return typeof value === "string" ? value : `${value}`;
|
|
91
|
+
case "Int":
|
|
92
|
+
return typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
93
|
+
case "BigInt":
|
|
94
|
+
return typeof value === "bigint" ? value : BigInt(`${value}`);
|
|
95
|
+
case "Float":
|
|
96
|
+
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
97
|
+
case "Boolean":
|
|
98
|
+
return typeof value === "boolean" ? value : value !== "0";
|
|
99
|
+
case "Decimal":
|
|
100
|
+
return typeof value === "number" ? new Decimal(value) : new Decimal(`${value}`);
|
|
101
|
+
case "Date":
|
|
102
|
+
return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
|
|
103
|
+
case "Array": {
|
|
104
|
+
const values = value;
|
|
105
|
+
return values.map((v) => mapValue(v, resultType.inner));
|
|
106
|
+
}
|
|
107
|
+
case "Object":
|
|
108
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
109
|
+
case "Bytes": {
|
|
110
|
+
if (!Array.isArray(value)) {
|
|
111
|
+
throw new DataMapperError(`Bytes data is invalid, got: ${typeof value}`);
|
|
112
|
+
}
|
|
113
|
+
return new Uint8Array(value);
|
|
114
|
+
}
|
|
115
|
+
default:
|
|
116
|
+
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/interpreter/QueryInterpreter.ts
|
|
121
|
+
import { SpanKind } from "@opentelemetry/api";
|
|
122
|
+
|
|
12
123
|
// src/tracing.ts
|
|
13
124
|
var noopTracingHelper = {
|
|
14
125
|
runInChildSpan(_, callback) {
|
|
@@ -171,101 +282,6 @@ function renderConstraint(constraint) {
|
|
|
171
282
|
return "(not available)";
|
|
172
283
|
}
|
|
173
284
|
|
|
174
|
-
// src/interpreter/DataMapper.ts
|
|
175
|
-
import Decimal from "decimal.js";
|
|
176
|
-
function applyDataMap(data, structure) {
|
|
177
|
-
switch (structure.type) {
|
|
178
|
-
case "Object":
|
|
179
|
-
return mapArrayOrObject(data, structure.fields);
|
|
180
|
-
case "Value":
|
|
181
|
-
return mapValue(data, structure.resultType);
|
|
182
|
-
default:
|
|
183
|
-
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function mapArrayOrObject(data, fields) {
|
|
187
|
-
if (data === null) return null;
|
|
188
|
-
if (Array.isArray(data)) {
|
|
189
|
-
const rows = data;
|
|
190
|
-
return rows.map((row) => mapObject(row, fields));
|
|
191
|
-
}
|
|
192
|
-
if (typeof data === "object") {
|
|
193
|
-
const row = data;
|
|
194
|
-
return mapObject(row, fields);
|
|
195
|
-
}
|
|
196
|
-
throw new Error(`DataMapper: Expected an array or an object, got: ${typeof data}`);
|
|
197
|
-
}
|
|
198
|
-
function mapObject(data, fields) {
|
|
199
|
-
if (typeof data !== "object") {
|
|
200
|
-
throw new Error(`DataMapper: Expected an object, but got '${typeof data}'`);
|
|
201
|
-
}
|
|
202
|
-
const result = {};
|
|
203
|
-
for (const [name, node] of Object.entries(fields)) {
|
|
204
|
-
switch (node.type) {
|
|
205
|
-
case "Object": {
|
|
206
|
-
if (!node.flattened && !Object.hasOwn(data, name)) {
|
|
207
|
-
throw new Error(
|
|
208
|
-
`DataMapper: Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
const target = node.flattened ? data : data[name];
|
|
212
|
-
result[name] = mapArrayOrObject(target, node.fields);
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
case "Value":
|
|
216
|
-
{
|
|
217
|
-
const dbName = node.dbName;
|
|
218
|
-
if (Object.hasOwn(data, dbName)) {
|
|
219
|
-
result[name] = mapValue(data[dbName], node.resultType);
|
|
220
|
-
} else {
|
|
221
|
-
throw new Error(
|
|
222
|
-
`DataMapper: Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
break;
|
|
227
|
-
default:
|
|
228
|
-
assertNever(node, `DataMapper: Invalid data mapping node type: '${node.type}'`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return result;
|
|
232
|
-
}
|
|
233
|
-
function mapValue(value, resultType) {
|
|
234
|
-
if (value === null) return null;
|
|
235
|
-
switch (resultType.type) {
|
|
236
|
-
case "Any":
|
|
237
|
-
return value;
|
|
238
|
-
case "String":
|
|
239
|
-
return typeof value === "string" ? value : `${value}`;
|
|
240
|
-
case "Int":
|
|
241
|
-
return typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
242
|
-
case "BigInt":
|
|
243
|
-
return typeof value === "bigint" ? value : BigInt(`${value}`);
|
|
244
|
-
case "Float":
|
|
245
|
-
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
246
|
-
case "Boolean":
|
|
247
|
-
return typeof value === "boolean" ? value : value !== "0";
|
|
248
|
-
case "Decimal":
|
|
249
|
-
return typeof value === "number" ? new Decimal(value) : new Decimal(`${value}`);
|
|
250
|
-
case "Date":
|
|
251
|
-
return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
|
|
252
|
-
case "Array": {
|
|
253
|
-
const values = value;
|
|
254
|
-
return values.map((v) => mapValue(v, resultType.inner));
|
|
255
|
-
}
|
|
256
|
-
case "Object":
|
|
257
|
-
return typeof value === "string" ? value : JSON.stringify(value);
|
|
258
|
-
case "Bytes": {
|
|
259
|
-
if (!Array.isArray(value)) {
|
|
260
|
-
throw new Error(`DataMapper: Bytes data is invalid, got: ${typeof value}`);
|
|
261
|
-
}
|
|
262
|
-
return new Uint8Array(value);
|
|
263
|
-
}
|
|
264
|
-
default:
|
|
265
|
-
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
285
|
// src/interpreter/generators.ts
|
|
270
286
|
import cuid1 from "@bugsnag/cuid";
|
|
271
287
|
import { createId as cuid2 } from "@paralleldrive/cuid2";
|
|
@@ -698,6 +714,9 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
698
714
|
}
|
|
699
715
|
case "join": {
|
|
700
716
|
const parent = await this.interpretNode(node.args.parent, queryable, scope, generators);
|
|
717
|
+
if (parent === null) {
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
701
720
|
const children = await Promise.all(
|
|
702
721
|
node.args.children.map(async (joinExpr) => ({
|
|
703
722
|
joinExpr,
|
|
@@ -1115,6 +1134,7 @@ var TransactionManager = class {
|
|
|
1115
1134
|
}
|
|
1116
1135
|
};
|
|
1117
1136
|
export {
|
|
1137
|
+
DataMapperError,
|
|
1118
1138
|
QueryInterpreter,
|
|
1119
1139
|
TransactionManager,
|
|
1120
1140
|
TransactionManagerError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-engine-runtime",
|
|
3
|
-
"version": "6.9.0-dev.
|
|
3
|
+
"version": "6.9.0-dev.12",
|
|
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.9.0-dev.
|
|
35
|
-
"@prisma/driver-adapter-utils": "6.9.0-dev.
|
|
34
|
+
"@prisma/debug": "6.9.0-dev.12",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.9.0-dev.12"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|