@prisma/client-engine-runtime 6.7.0-dev.3 → 6.7.0-dev.4
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/UserFacingError.d.ts +16 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +152 -1
- package/dist/index.mjs +151 -1
- package/package.json +3 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class UserFacingError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
code: string;
|
|
4
|
+
meta: unknown;
|
|
5
|
+
constructor(message: string, code: string, meta?: unknown);
|
|
6
|
+
toQueryResponseErrorObject(): {
|
|
7
|
+
error: string;
|
|
8
|
+
user_facing_error: {
|
|
9
|
+
is_panic: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
meta: unknown;
|
|
12
|
+
error_code: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function rethrowAsUserFacing(error: any): never;
|
package/dist/index.d.mts
CHANGED
|
@@ -181,4 +181,20 @@ export declare type TransactionOptions = {
|
|
|
181
181
|
isolationLevel?: IsolationLevel;
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
+
export declare class UserFacingError extends Error {
|
|
185
|
+
name: string;
|
|
186
|
+
code: string;
|
|
187
|
+
meta: unknown;
|
|
188
|
+
constructor(message: string, code: string, meta?: unknown);
|
|
189
|
+
toQueryResponseErrorObject(): {
|
|
190
|
+
error: string;
|
|
191
|
+
user_facing_error: {
|
|
192
|
+
is_panic: boolean;
|
|
193
|
+
message: string;
|
|
194
|
+
meta: unknown;
|
|
195
|
+
error_code: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
184
200
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -181,4 +181,20 @@ export declare type TransactionOptions = {
|
|
|
181
181
|
isolationLevel?: IsolationLevel;
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
+
export declare class UserFacingError extends Error {
|
|
185
|
+
name: string;
|
|
186
|
+
code: string;
|
|
187
|
+
meta: unknown;
|
|
188
|
+
constructor(message: string, code: string, meta?: unknown);
|
|
189
|
+
toQueryResponseErrorObject(): {
|
|
190
|
+
error: string;
|
|
191
|
+
user_facing_error: {
|
|
192
|
+
is_panic: boolean;
|
|
193
|
+
message: string;
|
|
194
|
+
meta: unknown;
|
|
195
|
+
error_code: string;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
184
200
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,159 @@ __export(index_exports, {
|
|
|
33
33
|
QueryInterpreter: () => QueryInterpreter,
|
|
34
34
|
TransactionManager: () => TransactionManager,
|
|
35
35
|
TransactionManagerError: () => TransactionManagerError,
|
|
36
|
+
UserFacingError: () => UserFacingError,
|
|
36
37
|
isPrismaValueGenerator: () => isPrismaValueGenerator,
|
|
37
38
|
isPrismaValuePlaceholder: () => isPrismaValuePlaceholder
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(index_exports);
|
|
40
41
|
|
|
42
|
+
// src/UserFacingError.ts
|
|
43
|
+
var import_driver_adapter_utils = require("@prisma/driver-adapter-utils");
|
|
44
|
+
var UserFacingError = class extends Error {
|
|
45
|
+
name = "UserFacingError";
|
|
46
|
+
code;
|
|
47
|
+
meta;
|
|
48
|
+
constructor(message, code, meta) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.code = code;
|
|
51
|
+
this.meta = meta;
|
|
52
|
+
}
|
|
53
|
+
toQueryResponseErrorObject() {
|
|
54
|
+
return {
|
|
55
|
+
error: this.message,
|
|
56
|
+
user_facing_error: {
|
|
57
|
+
is_panic: false,
|
|
58
|
+
message: this.message,
|
|
59
|
+
meta: this.meta,
|
|
60
|
+
error_code: this.code
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
function rethrowAsUserFacing(error) {
|
|
66
|
+
if (!(0, import_driver_adapter_utils.isDriverAdapterError)(error)) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
const code = getErrorCode(error);
|
|
70
|
+
const message = renderErrorMessage(error);
|
|
71
|
+
if (!code || !message) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
throw new UserFacingError(message, code, error);
|
|
75
|
+
}
|
|
76
|
+
function getErrorCode(err) {
|
|
77
|
+
switch (err.cause.kind) {
|
|
78
|
+
case "AuthenticationFailed":
|
|
79
|
+
return "P1000";
|
|
80
|
+
case "DatabaseDoesNotExist":
|
|
81
|
+
return "P1003";
|
|
82
|
+
case "SocketTimeout":
|
|
83
|
+
return "P1008";
|
|
84
|
+
case "DatabaseAlreadyExists":
|
|
85
|
+
return "P1009";
|
|
86
|
+
case "DatabaseAccessDenied":
|
|
87
|
+
return "P1010";
|
|
88
|
+
case "LengthMismatch":
|
|
89
|
+
return "P2000";
|
|
90
|
+
case "UniqueConstraintViolation":
|
|
91
|
+
return "P2002";
|
|
92
|
+
case "ForeignKeyConstraintViolation":
|
|
93
|
+
return "P2003";
|
|
94
|
+
case "UnsupportedNativeDataType":
|
|
95
|
+
return "P2010";
|
|
96
|
+
case "NullConstraintViolation":
|
|
97
|
+
return "P2011";
|
|
98
|
+
case "TableDoesNotExist":
|
|
99
|
+
return "P2021";
|
|
100
|
+
case "ColumnNotFound":
|
|
101
|
+
return "P2022";
|
|
102
|
+
case "InvalidIsolationLevel":
|
|
103
|
+
return "P2023";
|
|
104
|
+
case "TransactionWriteConflict":
|
|
105
|
+
return "P2034";
|
|
106
|
+
case "GenericJs":
|
|
107
|
+
return "P2036";
|
|
108
|
+
case "TooManyConnections":
|
|
109
|
+
return "P2037";
|
|
110
|
+
case "postgres":
|
|
111
|
+
case "sqlite":
|
|
112
|
+
case "mysql":
|
|
113
|
+
return;
|
|
114
|
+
default: {
|
|
115
|
+
const cause = err.cause;
|
|
116
|
+
throw new Error(`Unknown error: ${cause}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function renderErrorMessage(err) {
|
|
121
|
+
switch (err.cause.kind) {
|
|
122
|
+
case "AuthenticationFailed": {
|
|
123
|
+
const user = err.cause.user ?? "(not available)";
|
|
124
|
+
return `Authentication failed against the database server, the provided database credentials for \`${user}\` are not valid`;
|
|
125
|
+
}
|
|
126
|
+
case "DatabaseDoesNotExist": {
|
|
127
|
+
const db = err.cause.db ?? "(not available)";
|
|
128
|
+
return `Database \`${db}\` does not exist on the database server`;
|
|
129
|
+
}
|
|
130
|
+
case "SocketTimeout":
|
|
131
|
+
return `Operation has timed out`;
|
|
132
|
+
case "DatabaseAlreadyExists": {
|
|
133
|
+
const db = err.cause.db ?? "(not available)";
|
|
134
|
+
return `Database \`${db}\` already exists on the database server`;
|
|
135
|
+
}
|
|
136
|
+
case "DatabaseAccessDenied": {
|
|
137
|
+
const db = err.cause.db ?? "(not available)";
|
|
138
|
+
return `User was denied access on the database \`${db}\``;
|
|
139
|
+
}
|
|
140
|
+
case "LengthMismatch": {
|
|
141
|
+
const column = err.cause.column ?? "(not available)";
|
|
142
|
+
return `The provided value for the column is too long for the column's type. Column: ${column}`;
|
|
143
|
+
}
|
|
144
|
+
case "UniqueConstraintViolation":
|
|
145
|
+
return `Unique constraint failed on the ${renderConstraint({ fields: err.cause.fields })}`;
|
|
146
|
+
case "ForeignKeyConstraintViolation":
|
|
147
|
+
return `Foreign key constraint violated on the ${renderConstraint(err.cause.constraint)}`;
|
|
148
|
+
case "UnsupportedNativeDataType":
|
|
149
|
+
return `Failed to deserialize column of type '${err.cause.type}'. If you're using $queryRaw and this column is explicitly marked as \`Unsupported\` in your Prisma schema, try casting this column to any supported Prisma type such as \`String\`.`;
|
|
150
|
+
case "NullConstraintViolation":
|
|
151
|
+
return `Null constraint violation on the ${renderConstraint({ fields: err.cause.fields })}`;
|
|
152
|
+
case "TableDoesNotExist": {
|
|
153
|
+
const table = err.cause.table ?? "(not available)";
|
|
154
|
+
return `The table \`${table}\` does not exist in the current database.`;
|
|
155
|
+
}
|
|
156
|
+
case "ColumnNotFound": {
|
|
157
|
+
const column = err.cause.column ?? "(not available)";
|
|
158
|
+
return `The column \`${column}\` does not exist in the current database.`;
|
|
159
|
+
}
|
|
160
|
+
case "InvalidIsolationLevel":
|
|
161
|
+
return `Invalid isolation level \`${err.cause.level}\``;
|
|
162
|
+
case "TransactionWriteConflict":
|
|
163
|
+
return `Transaction failed due to a write conflict or a deadlock. Please retry your transaction`;
|
|
164
|
+
case "GenericJs":
|
|
165
|
+
return `Error in external connector (id ${err.cause.id})`;
|
|
166
|
+
case "TooManyConnections":
|
|
167
|
+
return `Too many database connections opened: ${err.cause.cause}`;
|
|
168
|
+
case "sqlite":
|
|
169
|
+
case "postgres":
|
|
170
|
+
case "mysql":
|
|
171
|
+
return;
|
|
172
|
+
default: {
|
|
173
|
+
const cause = err.cause;
|
|
174
|
+
throw new Error(`Unknown error: ${cause}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function renderConstraint(constraint) {
|
|
179
|
+
if (constraint && "fields" in constraint) {
|
|
180
|
+
return `fields: (${constraint.fields.map((field) => `\`${field}\``).join(", ")})`;
|
|
181
|
+
} else if (constraint && "index" in constraint) {
|
|
182
|
+
return `constraint: \`${constraint.index}\``;
|
|
183
|
+
} else if (constraint && "foreignKey" in constraint) {
|
|
184
|
+
return `foreign key`;
|
|
185
|
+
}
|
|
186
|
+
return "(not available)";
|
|
187
|
+
}
|
|
188
|
+
|
|
41
189
|
// src/interpreter/generators.ts
|
|
42
190
|
var import_cuid = __toESM(require("@bugsnag/cuid"));
|
|
43
191
|
var import_cuid2 = require("@paralleldrive/cuid2");
|
|
@@ -284,7 +432,9 @@ var QueryInterpreter = class {
|
|
|
284
432
|
this.#onQuery = onQuery;
|
|
285
433
|
}
|
|
286
434
|
async run(queryPlan, queryable) {
|
|
287
|
-
return this.interpretNode(queryPlan, queryable, this.#placeholderValues, this.#generators.snapshot())
|
|
435
|
+
return this.interpretNode(queryPlan, queryable, this.#placeholderValues, this.#generators.snapshot()).catch(
|
|
436
|
+
(e) => rethrowAsUserFacing(e)
|
|
437
|
+
);
|
|
288
438
|
}
|
|
289
439
|
async interpretNode(node, queryable, scope, generators) {
|
|
290
440
|
switch (node.type) {
|
|
@@ -673,6 +823,7 @@ var TransactionManager = class {
|
|
|
673
823
|
QueryInterpreter,
|
|
674
824
|
TransactionManager,
|
|
675
825
|
TransactionManagerError,
|
|
826
|
+
UserFacingError,
|
|
676
827
|
isPrismaValueGenerator,
|
|
677
828
|
isPrismaValuePlaceholder
|
|
678
829
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,150 @@
|
|
|
1
|
+
// src/UserFacingError.ts
|
|
2
|
+
import { isDriverAdapterError } from "@prisma/driver-adapter-utils";
|
|
3
|
+
var UserFacingError = class extends Error {
|
|
4
|
+
name = "UserFacingError";
|
|
5
|
+
code;
|
|
6
|
+
meta;
|
|
7
|
+
constructor(message, code, meta) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.meta = meta;
|
|
11
|
+
}
|
|
12
|
+
toQueryResponseErrorObject() {
|
|
13
|
+
return {
|
|
14
|
+
error: this.message,
|
|
15
|
+
user_facing_error: {
|
|
16
|
+
is_panic: false,
|
|
17
|
+
message: this.message,
|
|
18
|
+
meta: this.meta,
|
|
19
|
+
error_code: this.code
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function rethrowAsUserFacing(error) {
|
|
25
|
+
if (!isDriverAdapterError(error)) {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
const code = getErrorCode(error);
|
|
29
|
+
const message = renderErrorMessage(error);
|
|
30
|
+
if (!code || !message) {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
throw new UserFacingError(message, code, error);
|
|
34
|
+
}
|
|
35
|
+
function getErrorCode(err) {
|
|
36
|
+
switch (err.cause.kind) {
|
|
37
|
+
case "AuthenticationFailed":
|
|
38
|
+
return "P1000";
|
|
39
|
+
case "DatabaseDoesNotExist":
|
|
40
|
+
return "P1003";
|
|
41
|
+
case "SocketTimeout":
|
|
42
|
+
return "P1008";
|
|
43
|
+
case "DatabaseAlreadyExists":
|
|
44
|
+
return "P1009";
|
|
45
|
+
case "DatabaseAccessDenied":
|
|
46
|
+
return "P1010";
|
|
47
|
+
case "LengthMismatch":
|
|
48
|
+
return "P2000";
|
|
49
|
+
case "UniqueConstraintViolation":
|
|
50
|
+
return "P2002";
|
|
51
|
+
case "ForeignKeyConstraintViolation":
|
|
52
|
+
return "P2003";
|
|
53
|
+
case "UnsupportedNativeDataType":
|
|
54
|
+
return "P2010";
|
|
55
|
+
case "NullConstraintViolation":
|
|
56
|
+
return "P2011";
|
|
57
|
+
case "TableDoesNotExist":
|
|
58
|
+
return "P2021";
|
|
59
|
+
case "ColumnNotFound":
|
|
60
|
+
return "P2022";
|
|
61
|
+
case "InvalidIsolationLevel":
|
|
62
|
+
return "P2023";
|
|
63
|
+
case "TransactionWriteConflict":
|
|
64
|
+
return "P2034";
|
|
65
|
+
case "GenericJs":
|
|
66
|
+
return "P2036";
|
|
67
|
+
case "TooManyConnections":
|
|
68
|
+
return "P2037";
|
|
69
|
+
case "postgres":
|
|
70
|
+
case "sqlite":
|
|
71
|
+
case "mysql":
|
|
72
|
+
return;
|
|
73
|
+
default: {
|
|
74
|
+
const cause = err.cause;
|
|
75
|
+
throw new Error(`Unknown error: ${cause}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function renderErrorMessage(err) {
|
|
80
|
+
switch (err.cause.kind) {
|
|
81
|
+
case "AuthenticationFailed": {
|
|
82
|
+
const user = err.cause.user ?? "(not available)";
|
|
83
|
+
return `Authentication failed against the database server, the provided database credentials for \`${user}\` are not valid`;
|
|
84
|
+
}
|
|
85
|
+
case "DatabaseDoesNotExist": {
|
|
86
|
+
const db = err.cause.db ?? "(not available)";
|
|
87
|
+
return `Database \`${db}\` does not exist on the database server`;
|
|
88
|
+
}
|
|
89
|
+
case "SocketTimeout":
|
|
90
|
+
return `Operation has timed out`;
|
|
91
|
+
case "DatabaseAlreadyExists": {
|
|
92
|
+
const db = err.cause.db ?? "(not available)";
|
|
93
|
+
return `Database \`${db}\` already exists on the database server`;
|
|
94
|
+
}
|
|
95
|
+
case "DatabaseAccessDenied": {
|
|
96
|
+
const db = err.cause.db ?? "(not available)";
|
|
97
|
+
return `User was denied access on the database \`${db}\``;
|
|
98
|
+
}
|
|
99
|
+
case "LengthMismatch": {
|
|
100
|
+
const column = err.cause.column ?? "(not available)";
|
|
101
|
+
return `The provided value for the column is too long for the column's type. Column: ${column}`;
|
|
102
|
+
}
|
|
103
|
+
case "UniqueConstraintViolation":
|
|
104
|
+
return `Unique constraint failed on the ${renderConstraint({ fields: err.cause.fields })}`;
|
|
105
|
+
case "ForeignKeyConstraintViolation":
|
|
106
|
+
return `Foreign key constraint violated on the ${renderConstraint(err.cause.constraint)}`;
|
|
107
|
+
case "UnsupportedNativeDataType":
|
|
108
|
+
return `Failed to deserialize column of type '${err.cause.type}'. If you're using $queryRaw and this column is explicitly marked as \`Unsupported\` in your Prisma schema, try casting this column to any supported Prisma type such as \`String\`.`;
|
|
109
|
+
case "NullConstraintViolation":
|
|
110
|
+
return `Null constraint violation on the ${renderConstraint({ fields: err.cause.fields })}`;
|
|
111
|
+
case "TableDoesNotExist": {
|
|
112
|
+
const table = err.cause.table ?? "(not available)";
|
|
113
|
+
return `The table \`${table}\` does not exist in the current database.`;
|
|
114
|
+
}
|
|
115
|
+
case "ColumnNotFound": {
|
|
116
|
+
const column = err.cause.column ?? "(not available)";
|
|
117
|
+
return `The column \`${column}\` does not exist in the current database.`;
|
|
118
|
+
}
|
|
119
|
+
case "InvalidIsolationLevel":
|
|
120
|
+
return `Invalid isolation level \`${err.cause.level}\``;
|
|
121
|
+
case "TransactionWriteConflict":
|
|
122
|
+
return `Transaction failed due to a write conflict or a deadlock. Please retry your transaction`;
|
|
123
|
+
case "GenericJs":
|
|
124
|
+
return `Error in external connector (id ${err.cause.id})`;
|
|
125
|
+
case "TooManyConnections":
|
|
126
|
+
return `Too many database connections opened: ${err.cause.cause}`;
|
|
127
|
+
case "sqlite":
|
|
128
|
+
case "postgres":
|
|
129
|
+
case "mysql":
|
|
130
|
+
return;
|
|
131
|
+
default: {
|
|
132
|
+
const cause = err.cause;
|
|
133
|
+
throw new Error(`Unknown error: ${cause}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function renderConstraint(constraint) {
|
|
138
|
+
if (constraint && "fields" in constraint) {
|
|
139
|
+
return `fields: (${constraint.fields.map((field) => `\`${field}\``).join(", ")})`;
|
|
140
|
+
} else if (constraint && "index" in constraint) {
|
|
141
|
+
return `constraint: \`${constraint.index}\``;
|
|
142
|
+
} else if (constraint && "foreignKey" in constraint) {
|
|
143
|
+
return `foreign key`;
|
|
144
|
+
}
|
|
145
|
+
return "(not available)";
|
|
146
|
+
}
|
|
147
|
+
|
|
1
148
|
// src/interpreter/generators.ts
|
|
2
149
|
import cuid1 from "@bugsnag/cuid";
|
|
3
150
|
import { createId as cuid2 } from "@paralleldrive/cuid2";
|
|
@@ -244,7 +391,9 @@ var QueryInterpreter = class {
|
|
|
244
391
|
this.#onQuery = onQuery;
|
|
245
392
|
}
|
|
246
393
|
async run(queryPlan, queryable) {
|
|
247
|
-
return this.interpretNode(queryPlan, queryable, this.#placeholderValues, this.#generators.snapshot())
|
|
394
|
+
return this.interpretNode(queryPlan, queryable, this.#placeholderValues, this.#generators.snapshot()).catch(
|
|
395
|
+
(e) => rethrowAsUserFacing(e)
|
|
396
|
+
);
|
|
248
397
|
}
|
|
249
398
|
async interpretNode(node, queryable, scope, generators) {
|
|
250
399
|
switch (node.type) {
|
|
@@ -632,6 +781,7 @@ export {
|
|
|
632
781
|
QueryInterpreter,
|
|
633
782
|
TransactionManager,
|
|
634
783
|
TransactionManagerError,
|
|
784
|
+
UserFacingError,
|
|
635
785
|
isPrismaValueGenerator,
|
|
636
786
|
isPrismaValuePlaceholder
|
|
637
787
|
};
|
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.4",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"nanoid": "5.1.5",
|
|
30
30
|
"ulid": "3.0.0",
|
|
31
31
|
"uuid": "11.1.0",
|
|
32
|
-
"@prisma/
|
|
33
|
-
"@prisma/
|
|
32
|
+
"@prisma/debug": "6.7.0-dev.4",
|
|
33
|
+
"@prisma/driver-adapter-utils": "6.7.0-dev.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/jest": "29.5.14",
|