@prisma/client-engine-runtime 6.9.0-dev.43 → 6.9.0-dev.45
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 +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +24 -13
- package/dist/index.mjs +24 -13
- package/dist/interpreter/DataMapper.d.ts +1 -1
- package/package.json +3 -3
package/dist/QueryPlan.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export type PrismaValueType = {
|
|
|
50
50
|
type: 'Object';
|
|
51
51
|
} | {
|
|
52
52
|
type: 'Bytes';
|
|
53
|
+
} | {
|
|
54
|
+
type: 'Enum';
|
|
55
|
+
inner: string;
|
|
53
56
|
};
|
|
54
57
|
export type ResultNode = {
|
|
55
58
|
type: 'AffectedRows';
|
|
@@ -156,6 +159,7 @@ export type QueryPlanNode = {
|
|
|
156
159
|
args: {
|
|
157
160
|
expr: QueryPlanNode;
|
|
158
161
|
structure: ResultNode;
|
|
162
|
+
enums: Record<string, Record<string, string>>;
|
|
159
163
|
};
|
|
160
164
|
} | {
|
|
161
165
|
type: 'validate';
|
package/dist/index.d.mts
CHANGED
|
@@ -133,6 +133,9 @@ export declare type PrismaValueType = {
|
|
|
133
133
|
type: 'Object';
|
|
134
134
|
} | {
|
|
135
135
|
type: 'Bytes';
|
|
136
|
+
} | {
|
|
137
|
+
type: 'Enum';
|
|
138
|
+
inner: string;
|
|
136
139
|
};
|
|
137
140
|
|
|
138
141
|
export declare type QueryEvent = {
|
|
@@ -247,6 +250,7 @@ export declare type QueryPlanNode = {
|
|
|
247
250
|
args: {
|
|
248
251
|
expr: QueryPlanNode;
|
|
249
252
|
structure: ResultNode;
|
|
253
|
+
enums: Record<string, Record<string, string>>;
|
|
250
254
|
};
|
|
251
255
|
} | {
|
|
252
256
|
type: 'validate';
|
package/dist/index.d.ts
CHANGED
|
@@ -133,6 +133,9 @@ export declare type PrismaValueType = {
|
|
|
133
133
|
type: 'Object';
|
|
134
134
|
} | {
|
|
135
135
|
type: 'Bytes';
|
|
136
|
+
} | {
|
|
137
|
+
type: 'Enum';
|
|
138
|
+
inner: string;
|
|
136
139
|
};
|
|
137
140
|
|
|
138
141
|
export declare type QueryEvent = {
|
|
@@ -247,6 +250,7 @@ export declare type QueryPlanNode = {
|
|
|
247
250
|
args: {
|
|
248
251
|
expr: QueryPlanNode;
|
|
249
252
|
structure: ResultNode;
|
|
253
|
+
enums: Record<string, Record<string, string>>;
|
|
250
254
|
};
|
|
251
255
|
} | {
|
|
252
256
|
type: 'validate';
|
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ function safeJsonStringify(obj) {
|
|
|
91
91
|
var DataMapperError = class extends Error {
|
|
92
92
|
name = "DataMapperError";
|
|
93
93
|
};
|
|
94
|
-
function applyDataMap(data, structure) {
|
|
94
|
+
function applyDataMap(data, structure, enums) {
|
|
95
95
|
switch (structure.type) {
|
|
96
96
|
case "AffectedRows":
|
|
97
97
|
if (typeof data !== "number") {
|
|
@@ -99,22 +99,22 @@ function applyDataMap(data, structure) {
|
|
|
99
99
|
}
|
|
100
100
|
return { count: data };
|
|
101
101
|
case "Object":
|
|
102
|
-
return mapArrayOrObject(data, structure.fields);
|
|
102
|
+
return mapArrayOrObject(data, structure.fields, enums);
|
|
103
103
|
case "Value":
|
|
104
|
-
return mapValue(data, "<result>", structure.resultType);
|
|
104
|
+
return mapValue(data, "<result>", structure.resultType, enums);
|
|
105
105
|
default:
|
|
106
106
|
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function mapArrayOrObject(data, fields) {
|
|
109
|
+
function mapArrayOrObject(data, fields, enums) {
|
|
110
110
|
if (data === null) return null;
|
|
111
111
|
if (Array.isArray(data)) {
|
|
112
112
|
const rows = data;
|
|
113
|
-
return rows.map((row) => mapObject(row, fields));
|
|
113
|
+
return rows.map((row) => mapObject(row, fields, enums));
|
|
114
114
|
}
|
|
115
115
|
if (typeof data === "object") {
|
|
116
116
|
const row = data;
|
|
117
|
-
return mapObject(row, fields);
|
|
117
|
+
return mapObject(row, fields, enums);
|
|
118
118
|
}
|
|
119
119
|
if (typeof data === "string") {
|
|
120
120
|
let decodedData;
|
|
@@ -125,11 +125,11 @@ function mapArrayOrObject(data, fields) {
|
|
|
125
125
|
cause: error
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
return mapArrayOrObject(decodedData, fields);
|
|
128
|
+
return mapArrayOrObject(decodedData, fields, enums);
|
|
129
129
|
}
|
|
130
130
|
throw new DataMapperError(`Expected an array or an object, got: ${typeof data}`);
|
|
131
131
|
}
|
|
132
|
-
function mapObject(data, fields) {
|
|
132
|
+
function mapObject(data, fields, enums) {
|
|
133
133
|
if (typeof data !== "object") {
|
|
134
134
|
throw new DataMapperError(`Expected an object, but got '${typeof data}'`);
|
|
135
135
|
}
|
|
@@ -146,14 +146,14 @@ function mapObject(data, fields) {
|
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
const target = node.flattened ? data : data[name];
|
|
149
|
-
result[name] = mapArrayOrObject(target, node.fields);
|
|
149
|
+
result[name] = mapArrayOrObject(target, node.fields, enums);
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
152
152
|
case "Value":
|
|
153
153
|
{
|
|
154
154
|
const dbName = node.dbName;
|
|
155
155
|
if (Object.hasOwn(data, dbName)) {
|
|
156
|
-
result[name] = mapValue(data[dbName], dbName, node.resultType);
|
|
156
|
+
result[name] = mapValue(data[dbName], dbName, node.resultType, enums);
|
|
157
157
|
} else {
|
|
158
158
|
throw new DataMapperError(
|
|
159
159
|
`Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
@@ -167,7 +167,7 @@ function mapObject(data, fields) {
|
|
|
167
167
|
}
|
|
168
168
|
return result;
|
|
169
169
|
}
|
|
170
|
-
function mapValue(value, columnName, resultType) {
|
|
170
|
+
function mapValue(value, columnName, resultType, enums) {
|
|
171
171
|
if (value === null) {
|
|
172
172
|
return resultType.type === "Array" ? [] : null;
|
|
173
173
|
}
|
|
@@ -254,7 +254,7 @@ function mapValue(value, columnName, resultType) {
|
|
|
254
254
|
}
|
|
255
255
|
case "Array": {
|
|
256
256
|
const values = value;
|
|
257
|
-
return values.map((v, i) => mapValue(v, `${columnName}[${i}]`, resultType.inner));
|
|
257
|
+
return values.map((v, i) => mapValue(v, `${columnName}[${i}]`, resultType.inner, enums));
|
|
258
258
|
}
|
|
259
259
|
case "Object": {
|
|
260
260
|
const jsonValue = typeof value === "string" ? value : safeJsonStringify(value);
|
|
@@ -269,6 +269,17 @@ function mapValue(value, columnName, resultType) {
|
|
|
269
269
|
}
|
|
270
270
|
throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
|
|
271
271
|
}
|
|
272
|
+
case "Enum": {
|
|
273
|
+
const enumDef = enums[resultType.inner];
|
|
274
|
+
if (enumDef === void 0) {
|
|
275
|
+
throw new DataMapperError(`Unknown enum '${resultType.inner}'`);
|
|
276
|
+
}
|
|
277
|
+
const enumValue = enumDef[`${value}`];
|
|
278
|
+
if (enumValue === void 0) {
|
|
279
|
+
throw new DataMapperError(`Unknown enum value '${value}' for enum '${resultType.inner}'`);
|
|
280
|
+
}
|
|
281
|
+
return enumValue;
|
|
282
|
+
}
|
|
272
283
|
default:
|
|
273
284
|
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
274
285
|
}
|
|
@@ -1086,7 +1097,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1086
1097
|
}
|
|
1087
1098
|
case "dataMap": {
|
|
1088
1099
|
const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
|
|
1089
|
-
return { value: applyDataMap(value, node.args.structure), lastInsertId };
|
|
1100
|
+
return { value: applyDataMap(value, node.args.structure, node.args.enums), lastInsertId };
|
|
1090
1101
|
}
|
|
1091
1102
|
case "validate": {
|
|
1092
1103
|
const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
|
package/dist/index.mjs
CHANGED
|
@@ -43,7 +43,7 @@ function safeJsonStringify(obj) {
|
|
|
43
43
|
var DataMapperError = class extends Error {
|
|
44
44
|
name = "DataMapperError";
|
|
45
45
|
};
|
|
46
|
-
function applyDataMap(data, structure) {
|
|
46
|
+
function applyDataMap(data, structure, enums) {
|
|
47
47
|
switch (structure.type) {
|
|
48
48
|
case "AffectedRows":
|
|
49
49
|
if (typeof data !== "number") {
|
|
@@ -51,22 +51,22 @@ function applyDataMap(data, structure) {
|
|
|
51
51
|
}
|
|
52
52
|
return { count: data };
|
|
53
53
|
case "Object":
|
|
54
|
-
return mapArrayOrObject(data, structure.fields);
|
|
54
|
+
return mapArrayOrObject(data, structure.fields, enums);
|
|
55
55
|
case "Value":
|
|
56
|
-
return mapValue(data, "<result>", structure.resultType);
|
|
56
|
+
return mapValue(data, "<result>", structure.resultType, enums);
|
|
57
57
|
default:
|
|
58
58
|
assertNever(structure, `Invalid data mapping type: '${structure.type}'`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function mapArrayOrObject(data, fields) {
|
|
61
|
+
function mapArrayOrObject(data, fields, enums) {
|
|
62
62
|
if (data === null) return null;
|
|
63
63
|
if (Array.isArray(data)) {
|
|
64
64
|
const rows = data;
|
|
65
|
-
return rows.map((row) => mapObject(row, fields));
|
|
65
|
+
return rows.map((row) => mapObject(row, fields, enums));
|
|
66
66
|
}
|
|
67
67
|
if (typeof data === "object") {
|
|
68
68
|
const row = data;
|
|
69
|
-
return mapObject(row, fields);
|
|
69
|
+
return mapObject(row, fields, enums);
|
|
70
70
|
}
|
|
71
71
|
if (typeof data === "string") {
|
|
72
72
|
let decodedData;
|
|
@@ -77,11 +77,11 @@ function mapArrayOrObject(data, fields) {
|
|
|
77
77
|
cause: error
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
return mapArrayOrObject(decodedData, fields);
|
|
80
|
+
return mapArrayOrObject(decodedData, fields, enums);
|
|
81
81
|
}
|
|
82
82
|
throw new DataMapperError(`Expected an array or an object, got: ${typeof data}`);
|
|
83
83
|
}
|
|
84
|
-
function mapObject(data, fields) {
|
|
84
|
+
function mapObject(data, fields, enums) {
|
|
85
85
|
if (typeof data !== "object") {
|
|
86
86
|
throw new DataMapperError(`Expected an object, but got '${typeof data}'`);
|
|
87
87
|
}
|
|
@@ -98,14 +98,14 @@ function mapObject(data, fields) {
|
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
const target = node.flattened ? data : data[name];
|
|
101
|
-
result[name] = mapArrayOrObject(target, node.fields);
|
|
101
|
+
result[name] = mapArrayOrObject(target, node.fields, enums);
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
104
|
case "Value":
|
|
105
105
|
{
|
|
106
106
|
const dbName = node.dbName;
|
|
107
107
|
if (Object.hasOwn(data, dbName)) {
|
|
108
|
-
result[name] = mapValue(data[dbName], dbName, node.resultType);
|
|
108
|
+
result[name] = mapValue(data[dbName], dbName, node.resultType, enums);
|
|
109
109
|
} else {
|
|
110
110
|
throw new DataMapperError(
|
|
111
111
|
`Missing data field (Value): '${dbName}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
|
|
@@ -119,7 +119,7 @@ function mapObject(data, fields) {
|
|
|
119
119
|
}
|
|
120
120
|
return result;
|
|
121
121
|
}
|
|
122
|
-
function mapValue(value, columnName, resultType) {
|
|
122
|
+
function mapValue(value, columnName, resultType, enums) {
|
|
123
123
|
if (value === null) {
|
|
124
124
|
return resultType.type === "Array" ? [] : null;
|
|
125
125
|
}
|
|
@@ -206,7 +206,7 @@ function mapValue(value, columnName, resultType) {
|
|
|
206
206
|
}
|
|
207
207
|
case "Array": {
|
|
208
208
|
const values = value;
|
|
209
|
-
return values.map((v, i) => mapValue(v, `${columnName}[${i}]`, resultType.inner));
|
|
209
|
+
return values.map((v, i) => mapValue(v, `${columnName}[${i}]`, resultType.inner, enums));
|
|
210
210
|
}
|
|
211
211
|
case "Object": {
|
|
212
212
|
const jsonValue = typeof value === "string" ? value : safeJsonStringify(value);
|
|
@@ -221,6 +221,17 @@ function mapValue(value, columnName, resultType) {
|
|
|
221
221
|
}
|
|
222
222
|
throw new DataMapperError(`Expected a byte array in column '${columnName}', got ${typeof value}: ${value}`);
|
|
223
223
|
}
|
|
224
|
+
case "Enum": {
|
|
225
|
+
const enumDef = enums[resultType.inner];
|
|
226
|
+
if (enumDef === void 0) {
|
|
227
|
+
throw new DataMapperError(`Unknown enum '${resultType.inner}'`);
|
|
228
|
+
}
|
|
229
|
+
const enumValue = enumDef[`${value}`];
|
|
230
|
+
if (enumValue === void 0) {
|
|
231
|
+
throw new DataMapperError(`Unknown enum value '${value}' for enum '${resultType.inner}'`);
|
|
232
|
+
}
|
|
233
|
+
return enumValue;
|
|
234
|
+
}
|
|
224
235
|
default:
|
|
225
236
|
assertNever(resultType, `DataMapper: Unknown result type: ${resultType.type}`);
|
|
226
237
|
}
|
|
@@ -1038,7 +1049,7 @@ var QueryInterpreter = class _QueryInterpreter {
|
|
|
1038
1049
|
}
|
|
1039
1050
|
case "dataMap": {
|
|
1040
1051
|
const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
|
|
1041
|
-
return { value: applyDataMap(value, node.args.structure), lastInsertId };
|
|
1052
|
+
return { value: applyDataMap(value, node.args.structure, node.args.enums), lastInsertId };
|
|
1042
1053
|
}
|
|
1043
1054
|
case "validate": {
|
|
1044
1055
|
const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
|
|
@@ -3,4 +3,4 @@ import { Value } from './scope';
|
|
|
3
3
|
export declare class DataMapperError extends Error {
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function applyDataMap(data: Value, structure: ResultNode): Value;
|
|
6
|
+
export declare function applyDataMap(data: Value, structure: ResultNode, enums: Record<string, Record<string, string>>): Value;
|
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.45",
|
|
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.45",
|
|
35
|
+
"@prisma/driver-adapter-utils": "6.9.0-dev.45"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.14",
|