@prisma/client-engine-runtime 6.7.0-dev.27 → 6.7.0-dev.29
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/QueryPlan.d.ts +38 -0
- package/dist/index.d.mts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +98 -0
- package/dist/index.mjs +98 -0
- package/dist/interpreter/DataMapper.d.ts +3 -0
- package/package.json +3 -3
package/dist/QueryPlan.d.ts
CHANGED
|
@@ -15,6 +15,38 @@ export type PrismaValueGenerator = {
|
|
|
15
15
|
};
|
|
16
16
|
export declare function isPrismaValueGenerator(value: unknown): value is PrismaValueGenerator;
|
|
17
17
|
export type PrismaValue = string | boolean | number | PrismaValue[] | null | Record<string, unknown> | PrismaValuePlaceholder | PrismaValueGenerator;
|
|
18
|
+
export type PrismaValueType = {
|
|
19
|
+
type: 'Any';
|
|
20
|
+
} | {
|
|
21
|
+
type: 'String';
|
|
22
|
+
} | {
|
|
23
|
+
type: 'Int';
|
|
24
|
+
} | {
|
|
25
|
+
type: 'BigInt';
|
|
26
|
+
} | {
|
|
27
|
+
type: 'Float';
|
|
28
|
+
} | {
|
|
29
|
+
type: 'Boolean';
|
|
30
|
+
} | {
|
|
31
|
+
type: 'Decimal';
|
|
32
|
+
} | {
|
|
33
|
+
type: 'Date';
|
|
34
|
+
} | {
|
|
35
|
+
type: 'Array';
|
|
36
|
+
inner: PrismaValueType;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'Object';
|
|
39
|
+
} | {
|
|
40
|
+
type: 'Bytes';
|
|
41
|
+
};
|
|
42
|
+
export type ResultNode = {
|
|
43
|
+
type: 'Object';
|
|
44
|
+
fields: Record<string, ResultNode>;
|
|
45
|
+
} | {
|
|
46
|
+
type: 'Value';
|
|
47
|
+
dbName: string;
|
|
48
|
+
resultType: PrismaValueType;
|
|
49
|
+
};
|
|
18
50
|
export type QueryPlanBinding = {
|
|
19
51
|
name: string;
|
|
20
52
|
expr: QueryPlanNode;
|
|
@@ -103,4 +135,10 @@ export type QueryPlanNode = {
|
|
|
103
135
|
} | {
|
|
104
136
|
type: 'transaction';
|
|
105
137
|
args: QueryPlanNode;
|
|
138
|
+
} | {
|
|
139
|
+
type: 'dataMap';
|
|
140
|
+
args: {
|
|
141
|
+
expr: QueryPlanNode;
|
|
142
|
+
structure: ResultNode;
|
|
143
|
+
};
|
|
106
144
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -56,6 +56,31 @@ export declare type PrismaValuePlaceholder = {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
export declare type PrismaValueType = {
|
|
60
|
+
type: 'Any';
|
|
61
|
+
} | {
|
|
62
|
+
type: 'String';
|
|
63
|
+
} | {
|
|
64
|
+
type: 'Int';
|
|
65
|
+
} | {
|
|
66
|
+
type: 'BigInt';
|
|
67
|
+
} | {
|
|
68
|
+
type: 'Float';
|
|
69
|
+
} | {
|
|
70
|
+
type: 'Boolean';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'Decimal';
|
|
73
|
+
} | {
|
|
74
|
+
type: 'Date';
|
|
75
|
+
} | {
|
|
76
|
+
type: 'Array';
|
|
77
|
+
inner: PrismaValueType;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'Object';
|
|
80
|
+
} | {
|
|
81
|
+
type: 'Bytes';
|
|
82
|
+
};
|
|
83
|
+
|
|
59
84
|
export declare type QueryEvent = {
|
|
60
85
|
timestamp: Date;
|
|
61
86
|
query: string;
|
|
@@ -155,6 +180,21 @@ export declare type QueryPlanNode = {
|
|
|
155
180
|
} | {
|
|
156
181
|
type: 'transaction';
|
|
157
182
|
args: QueryPlanNode;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'dataMap';
|
|
185
|
+
args: {
|
|
186
|
+
expr: QueryPlanNode;
|
|
187
|
+
structure: ResultNode;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export declare type ResultNode = {
|
|
192
|
+
type: 'Object';
|
|
193
|
+
fields: Record<string, ResultNode>;
|
|
194
|
+
} | {
|
|
195
|
+
type: 'Value';
|
|
196
|
+
dbName: string;
|
|
197
|
+
resultType: PrismaValueType;
|
|
158
198
|
};
|
|
159
199
|
|
|
160
200
|
declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,31 @@ export declare type PrismaValuePlaceholder = {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
export declare type PrismaValueType = {
|
|
60
|
+
type: 'Any';
|
|
61
|
+
} | {
|
|
62
|
+
type: 'String';
|
|
63
|
+
} | {
|
|
64
|
+
type: 'Int';
|
|
65
|
+
} | {
|
|
66
|
+
type: 'BigInt';
|
|
67
|
+
} | {
|
|
68
|
+
type: 'Float';
|
|
69
|
+
} | {
|
|
70
|
+
type: 'Boolean';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'Decimal';
|
|
73
|
+
} | {
|
|
74
|
+
type: 'Date';
|
|
75
|
+
} | {
|
|
76
|
+
type: 'Array';
|
|
77
|
+
inner: PrismaValueType;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'Object';
|
|
80
|
+
} | {
|
|
81
|
+
type: 'Bytes';
|
|
82
|
+
};
|
|
83
|
+
|
|
59
84
|
export declare type QueryEvent = {
|
|
60
85
|
timestamp: Date;
|
|
61
86
|
query: string;
|
|
@@ -155,6 +180,21 @@ export declare type QueryPlanNode = {
|
|
|
155
180
|
} | {
|
|
156
181
|
type: 'transaction';
|
|
157
182
|
args: QueryPlanNode;
|
|
183
|
+
} | {
|
|
184
|
+
type: 'dataMap';
|
|
185
|
+
args: {
|
|
186
|
+
expr: QueryPlanNode;
|
|
187
|
+
structure: ResultNode;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export declare type ResultNode = {
|
|
192
|
+
type: 'Object';
|
|
193
|
+
fields: Record<string, ResultNode>;
|
|
194
|
+
} | {
|
|
195
|
+
type: 'Value';
|
|
196
|
+
dbName: string;
|
|
197
|
+
resultType: PrismaValueType;
|
|
158
198
|
};
|
|
159
199
|
|
|
160
200
|
declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
|
package/dist/index.js
CHANGED
|
@@ -210,6 +210,100 @@ function renderConstraint(constraint) {
|
|
|
210
210
|
return "(not available)";
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
// src/interpreter/DataMapper.ts
|
|
214
|
+
function applyDataMap(data, structure) {
|
|
215
|
+
switch (structure.type) {
|
|
216
|
+
case "Object":
|
|
217
|
+
return mapArrayOrObject(data, structure.fields);
|
|
218
|
+
case "Value":
|
|
219
|
+
return mapValue(data, structure.resultType);
|
|
220
|
+
default:
|
|
221
|
+
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function mapArrayOrObject(data, fields) {
|
|
225
|
+
if (data === null) return null;
|
|
226
|
+
if (Array.isArray(data)) {
|
|
227
|
+
const rows = data;
|
|
228
|
+
return rows.map((row) => mapObject(row, fields));
|
|
229
|
+
}
|
|
230
|
+
if (typeof data === "object") {
|
|
231
|
+
const row = data;
|
|
232
|
+
return mapObject(row, fields);
|
|
233
|
+
}
|
|
234
|
+
throw new Error(`DataMapper: Expected an array or an object, got: ${typeof data}`);
|
|
235
|
+
}
|
|
236
|
+
function mapObject(data, fields) {
|
|
237
|
+
if (typeof data !== "object") {
|
|
238
|
+
throw new Error(`DataMapper: Expected an object, but got '${typeof data}'`);
|
|
239
|
+
}
|
|
240
|
+
const result = {};
|
|
241
|
+
for (const [name, node] of Object.entries(fields)) {
|
|
242
|
+
switch (node.type) {
|
|
243
|
+
case "Object":
|
|
244
|
+
if (Object.hasOwn(data, name)) {
|
|
245
|
+
result[name] = mapArrayOrObject(data[name], node.fields);
|
|
246
|
+
} else {
|
|
247
|
+
throw new Error(
|
|
248
|
+
`DataMapper: Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
break;
|
|
252
|
+
case "Value":
|
|
253
|
+
{
|
|
254
|
+
const dbName = node.dbName;
|
|
255
|
+
if (Object.hasOwn(data, dbName)) {
|
|
256
|
+
result[name] = mapValue(data[dbName], node.resultType);
|
|
257
|
+
} else {
|
|
258
|
+
throw new Error(
|
|
259
|
+
`DataMapper: Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
break;
|
|
264
|
+
default:
|
|
265
|
+
assertNever(node, `DataMapper: Invalid data mapping node type: '${node.type}'`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
function mapValue(value, resultType) {
|
|
271
|
+
if (value === null) return null;
|
|
272
|
+
switch (resultType.type) {
|
|
273
|
+
case "Any":
|
|
274
|
+
return value;
|
|
275
|
+
case "String":
|
|
276
|
+
return typeof value === "string" ? value : `${value}`;
|
|
277
|
+
case "Int":
|
|
278
|
+
return typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
279
|
+
case "BigInt":
|
|
280
|
+
return typeof value === "bigint" ? value : BigInt(`${value}`);
|
|
281
|
+
case "Float":
|
|
282
|
+
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
283
|
+
case "Boolean":
|
|
284
|
+
return typeof value === "boolean" ? value : value !== "0";
|
|
285
|
+
case "Decimal":
|
|
286
|
+
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
287
|
+
case "Date":
|
|
288
|
+
return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
|
|
289
|
+
case "Array": {
|
|
290
|
+
const values = value;
|
|
291
|
+
return values.map((v) => {
|
|
292
|
+
mapValue(v, resultType.inner);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
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}`);
|
|
300
|
+
}
|
|
301
|
+
return value;
|
|
302
|
+
default:
|
|
303
|
+
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
213
307
|
// src/interpreter/generators.ts
|
|
214
308
|
var import_cuid = __toESM(require("@bugsnag/cuid"));
|
|
215
309
|
var import_cuid2 = require("@paralleldrive/cuid2");
|
|
@@ -612,6 +706,10 @@ var QueryInterpreter = class {
|
|
|
612
706
|
throw e;
|
|
613
707
|
}
|
|
614
708
|
}
|
|
709
|
+
case "dataMap": {
|
|
710
|
+
const data = await this.interpretNode(node.args.expr, queryable, scope, generators);
|
|
711
|
+
return applyDataMap(data, node.args.structure);
|
|
712
|
+
}
|
|
615
713
|
default:
|
|
616
714
|
assertNever(node, `Unexpected node type: ${node.type}`);
|
|
617
715
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -168,6 +168,100 @@ function renderConstraint(constraint) {
|
|
|
168
168
|
return "(not available)";
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
+
// src/interpreter/DataMapper.ts
|
|
172
|
+
function applyDataMap(data, structure) {
|
|
173
|
+
switch (structure.type) {
|
|
174
|
+
case "Object":
|
|
175
|
+
return mapArrayOrObject(data, structure.fields);
|
|
176
|
+
case "Value":
|
|
177
|
+
return mapValue(data, structure.resultType);
|
|
178
|
+
default:
|
|
179
|
+
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function mapArrayOrObject(data, fields) {
|
|
183
|
+
if (data === null) return null;
|
|
184
|
+
if (Array.isArray(data)) {
|
|
185
|
+
const rows = data;
|
|
186
|
+
return rows.map((row) => mapObject(row, fields));
|
|
187
|
+
}
|
|
188
|
+
if (typeof data === "object") {
|
|
189
|
+
const row = data;
|
|
190
|
+
return mapObject(row, fields);
|
|
191
|
+
}
|
|
192
|
+
throw new Error(`DataMapper: Expected an array or an object, got: ${typeof data}`);
|
|
193
|
+
}
|
|
194
|
+
function mapObject(data, fields) {
|
|
195
|
+
if (typeof data !== "object") {
|
|
196
|
+
throw new Error(`DataMapper: Expected an object, but got '${typeof data}'`);
|
|
197
|
+
}
|
|
198
|
+
const result = {};
|
|
199
|
+
for (const [name, node] of Object.entries(fields)) {
|
|
200
|
+
switch (node.type) {
|
|
201
|
+
case "Object":
|
|
202
|
+
if (Object.hasOwn(data, name)) {
|
|
203
|
+
result[name] = mapArrayOrObject(data[name], node.fields);
|
|
204
|
+
} else {
|
|
205
|
+
throw new Error(
|
|
206
|
+
`DataMapper: Missing data field (Object): '${name}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case "Value":
|
|
211
|
+
{
|
|
212
|
+
const dbName = node.dbName;
|
|
213
|
+
if (Object.hasOwn(data, dbName)) {
|
|
214
|
+
result[name] = mapValue(data[dbName], node.resultType);
|
|
215
|
+
} else {
|
|
216
|
+
throw new Error(
|
|
217
|
+
`DataMapper: Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
default:
|
|
223
|
+
assertNever(node, `DataMapper: Invalid data mapping node type: '${node.type}'`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
function mapValue(value, resultType) {
|
|
229
|
+
if (value === null) return null;
|
|
230
|
+
switch (resultType.type) {
|
|
231
|
+
case "Any":
|
|
232
|
+
return value;
|
|
233
|
+
case "String":
|
|
234
|
+
return typeof value === "string" ? value : `${value}`;
|
|
235
|
+
case "Int":
|
|
236
|
+
return typeof value === "number" ? value : parseInt(`${value}`, 10);
|
|
237
|
+
case "BigInt":
|
|
238
|
+
return typeof value === "bigint" ? value : BigInt(`${value}`);
|
|
239
|
+
case "Float":
|
|
240
|
+
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
241
|
+
case "Boolean":
|
|
242
|
+
return typeof value === "boolean" ? value : value !== "0";
|
|
243
|
+
case "Decimal":
|
|
244
|
+
return typeof value === "number" ? value : parseFloat(`${value}`);
|
|
245
|
+
case "Date":
|
|
246
|
+
return value instanceof Date ? value : /* @__PURE__ */ new Date(`${value}`);
|
|
247
|
+
case "Array": {
|
|
248
|
+
const values = value;
|
|
249
|
+
return values.map((v) => {
|
|
250
|
+
mapValue(v, resultType.inner);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
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}`);
|
|
258
|
+
}
|
|
259
|
+
return value;
|
|
260
|
+
default:
|
|
261
|
+
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
171
265
|
// src/interpreter/generators.ts
|
|
172
266
|
import cuid1 from "@bugsnag/cuid";
|
|
173
267
|
import { createId as cuid2 } from "@paralleldrive/cuid2";
|
|
@@ -570,6 +664,10 @@ var QueryInterpreter = class {
|
|
|
570
664
|
throw e;
|
|
571
665
|
}
|
|
572
666
|
}
|
|
667
|
+
case "dataMap": {
|
|
668
|
+
const data = await this.interpretNode(node.args.expr, queryable, scope, generators);
|
|
669
|
+
return applyDataMap(data, node.args.structure);
|
|
670
|
+
}
|
|
573
671
|
default:
|
|
574
672
|
assertNever(node, `Unexpected node type: ${node.type}`);
|
|
575
673
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/client-engine-runtime",
|
|
3
|
-
"version": "6.7.0-dev.
|
|
3
|
+
"version": "6.7.0-dev.29",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"nanoid": "5.1.5",
|
|
31
31
|
"ulid": "3.0.0",
|
|
32
32
|
"uuid": "11.1.0",
|
|
33
|
-
"@prisma/debug": "6.7.0-dev.
|
|
34
|
-
"@prisma/driver-adapter-utils": "6.7.0-dev.
|
|
33
|
+
"@prisma/debug": "6.7.0-dev.29",
|
|
34
|
+
"@prisma/driver-adapter-utils": "6.7.0-dev.29"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jest": "29.5.14",
|