@prisma/driver-adapter-utils 6.5.0-dev.8 → 6.5.0-dev.80
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 +93 -37
- package/dist/index.d.ts +93 -37
- package/dist/index.js +29 -4
- package/dist/index.mjs +30 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Debug } from '@prisma/debug';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* An interface that exposes some basic information about the
|
|
5
|
+
* adapter like its name and provider type.
|
|
6
|
+
*/
|
|
7
|
+
declare interface AdapterInfo {
|
|
8
|
+
readonly provider: Provider;
|
|
9
|
+
readonly adapterName: (typeof officialPrismaAdapters)[number] | (string & {});
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* Original `quaint::ValueType` enum tag from Prisma's `quaint`.
|
|
5
14
|
* Query arguments marked with this type are sanitized before being sent to the database.
|
|
@@ -7,7 +16,7 @@ import { Debug } from '@prisma/debug';
|
|
|
7
16
|
*/
|
|
8
17
|
export declare type ArgType = 'Int32' | 'Int64' | 'Float' | 'Double' | 'Text' | 'Enum' | 'EnumArray' | 'Bytes' | 'Boolean' | 'Char' | 'Array' | 'Numeric' | 'Json' | 'Xml' | 'Uuid' | 'DateTime' | 'Date' | 'Time';
|
|
9
18
|
|
|
10
|
-
export declare const bindAdapter: (adapter:
|
|
19
|
+
export declare const bindAdapter: (adapter: SqlConnection) => ErrorCapturingSqlConnection;
|
|
11
20
|
|
|
12
21
|
export declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
|
|
13
22
|
|
|
@@ -53,15 +62,21 @@ export declare type ConnectionInfo = {
|
|
|
53
62
|
|
|
54
63
|
export { Debug }
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
/**
|
|
66
|
+
* A generic driver adapter that allows the user to connect to a
|
|
67
|
+
* database. The query and result types are specific to the adapter.
|
|
68
|
+
*/
|
|
69
|
+
declare interface DriverAdapter_2<Query, Result> extends AdapterInfo {
|
|
61
70
|
/**
|
|
62
|
-
*
|
|
71
|
+
* Connect to the database.
|
|
63
72
|
*/
|
|
64
|
-
|
|
73
|
+
connect(): Promise<Queryable<Query, Result>>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare class DriverAdapterError extends Error {
|
|
77
|
+
name: string;
|
|
78
|
+
cause: Error_2;
|
|
79
|
+
constructor(payload: Error_2);
|
|
65
80
|
}
|
|
66
81
|
|
|
67
82
|
export declare function err<T>(error: Error_2): Result<T>;
|
|
@@ -95,9 +110,23 @@ declare type Error_2 = {
|
|
|
95
110
|
};
|
|
96
111
|
export { Error_2 as Error }
|
|
97
112
|
|
|
98
|
-
|
|
113
|
+
declare type ErrorCapturingFunction<T> = T extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<Result<ErrorCapturingInterface<R>>> : T extends (...args: infer A) => infer R ? (...args: A) => Result<ErrorCapturingInterface<R>> : T;
|
|
114
|
+
|
|
115
|
+
declare type ErrorCapturingInterface<T> = {
|
|
116
|
+
[K in keyof T]: ErrorCapturingFunction<T[K]>;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
declare interface ErrorCapturingSqlConnection extends ErrorCapturingInterface<SqlConnection> {
|
|
99
120
|
readonly errorRegistry: ErrorRegistry;
|
|
100
121
|
}
|
|
122
|
+
export { ErrorCapturingSqlConnection as ErrorCapturingDriverAdapter }
|
|
123
|
+
export { ErrorCapturingSqlConnection }
|
|
124
|
+
|
|
125
|
+
export declare type ErrorCapturingSqlQueryable = ErrorCapturingInterface<SqlQueryable>;
|
|
126
|
+
|
|
127
|
+
export declare type ErrorCapturingTransaction = ErrorCapturingInterface<Transaction>;
|
|
128
|
+
|
|
129
|
+
export declare type ErrorCapturingTransactionContext = ErrorCapturingInterface<TransactionContext>;
|
|
101
130
|
|
|
102
131
|
export declare type ErrorRecord = {
|
|
103
132
|
error: unknown;
|
|
@@ -113,30 +142,15 @@ export declare function ok<T>(value: T): Result<T>;
|
|
|
113
142
|
|
|
114
143
|
export declare type Provider = 'mysql' | 'postgres' | 'sqlite';
|
|
115
144
|
|
|
116
|
-
|
|
117
|
-
sql: string;
|
|
118
|
-
args: Array<unknown>;
|
|
119
|
-
argTypes: Array<ArgType>;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export declare interface Queryable {
|
|
123
|
-
readonly provider: Provider;
|
|
124
|
-
readonly adapterName: (typeof officialPrismaAdapters)[number] | (string & {});
|
|
145
|
+
declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
125
146
|
/**
|
|
126
|
-
* Execute a query
|
|
127
|
-
* and returning the type-aware result set of the query.
|
|
128
|
-
*
|
|
129
|
-
* This is the preferred way of executing `SELECT` queries.
|
|
147
|
+
* Execute a query and return its result.
|
|
130
148
|
*/
|
|
131
|
-
queryRaw(params: Query): Promise<Result
|
|
149
|
+
queryRaw(params: Query): Promise<Result>;
|
|
132
150
|
/**
|
|
133
|
-
* Execute a query
|
|
134
|
-
* and returning the number of affected rows.
|
|
135
|
-
*
|
|
136
|
-
* This is the preferred way of executing `INSERT`, `UPDATE`, `DELETE` queries,
|
|
137
|
-
* as well as transactional queries.
|
|
151
|
+
* Execute a query and return the number of affected rows.
|
|
138
152
|
*/
|
|
139
|
-
executeRaw(params: Query): Promise<
|
|
153
|
+
executeRaw(params: Query): Promise<number>;
|
|
140
154
|
}
|
|
141
155
|
|
|
142
156
|
export declare type Result<T> = {
|
|
@@ -150,7 +164,49 @@ export declare type Result<T> = {
|
|
|
150
164
|
readonly error: Error_2;
|
|
151
165
|
});
|
|
152
166
|
|
|
153
|
-
|
|
167
|
+
declare interface SqlConnection extends SqlQueryable {
|
|
168
|
+
/**
|
|
169
|
+
* Execute multiple SQL statements separated by semicolon.
|
|
170
|
+
*/
|
|
171
|
+
executeScript(script: string): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Start new transaction.
|
|
174
|
+
*/
|
|
175
|
+
transactionContext(): Promise<TransactionContext>;
|
|
176
|
+
/**
|
|
177
|
+
* Optional method that returns extra connection info
|
|
178
|
+
*/
|
|
179
|
+
getConnectionInfo?(): ConnectionInfo;
|
|
180
|
+
/**
|
|
181
|
+
* Dispose of the connection and release any resources.
|
|
182
|
+
*/
|
|
183
|
+
dispose(): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
export { SqlConnection as DriverAdapter }
|
|
186
|
+
export { SqlConnection }
|
|
187
|
+
|
|
188
|
+
declare interface SqlDriverAdapter extends DriverAdapter_2<SqlQuery, SqlResultSet> {
|
|
189
|
+
connect(): Promise<SqlConnection>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* An SQL migration adapter that is aware of the notion of a shadow database
|
|
194
|
+
* and can create a connection to it.
|
|
195
|
+
*/
|
|
196
|
+
export declare interface SqlMigrationAwareDriverAdapter extends SqlDriverAdapter {
|
|
197
|
+
connectToShadowDb(): Promise<SqlConnection>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export declare type SqlQuery = {
|
|
201
|
+
sql: string;
|
|
202
|
+
args: Array<unknown>;
|
|
203
|
+
argTypes: Array<ArgType>;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export declare interface SqlQueryable extends Queryable<SqlQuery, SqlResultSet> {
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare interface SqlResultSet {
|
|
154
210
|
/**
|
|
155
211
|
* List of column types appearing in a database query, in the same order as `columnNames`.
|
|
156
212
|
* They are used within the Query Engine to convert values from JS to Quaint values.
|
|
@@ -172,7 +228,7 @@ export declare interface ResultSet {
|
|
|
172
228
|
lastInsertId?: string;
|
|
173
229
|
}
|
|
174
230
|
|
|
175
|
-
export declare interface Transaction extends
|
|
231
|
+
export declare interface Transaction extends AdapterInfo, SqlQueryable {
|
|
176
232
|
/**
|
|
177
233
|
* Transaction options.
|
|
178
234
|
*/
|
|
@@ -180,18 +236,18 @@ export declare interface Transaction extends Queryable {
|
|
|
180
236
|
/**
|
|
181
237
|
* Commit the transaction.
|
|
182
238
|
*/
|
|
183
|
-
commit(): Promise<
|
|
239
|
+
commit(): Promise<void>;
|
|
184
240
|
/**
|
|
185
|
-
*
|
|
241
|
+
* Roll back the transaction.
|
|
186
242
|
*/
|
|
187
|
-
rollback(): Promise<
|
|
243
|
+
rollback(): Promise<void>;
|
|
188
244
|
}
|
|
189
245
|
|
|
190
|
-
export declare interface TransactionContext extends
|
|
246
|
+
export declare interface TransactionContext extends AdapterInfo, SqlQueryable {
|
|
191
247
|
/**
|
|
192
|
-
*
|
|
248
|
+
* Start new transaction.
|
|
193
249
|
*/
|
|
194
|
-
startTransaction(): Promise<
|
|
250
|
+
startTransaction(): Promise<Transaction>;
|
|
195
251
|
}
|
|
196
252
|
|
|
197
253
|
export declare type TransactionOptions = {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Debug } from '@prisma/debug';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* An interface that exposes some basic information about the
|
|
5
|
+
* adapter like its name and provider type.
|
|
6
|
+
*/
|
|
7
|
+
declare interface AdapterInfo {
|
|
8
|
+
readonly provider: Provider;
|
|
9
|
+
readonly adapterName: (typeof officialPrismaAdapters)[number] | (string & {});
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* Original `quaint::ValueType` enum tag from Prisma's `quaint`.
|
|
5
14
|
* Query arguments marked with this type are sanitized before being sent to the database.
|
|
@@ -7,7 +16,7 @@ import { Debug } from '@prisma/debug';
|
|
|
7
16
|
*/
|
|
8
17
|
export declare type ArgType = 'Int32' | 'Int64' | 'Float' | 'Double' | 'Text' | 'Enum' | 'EnumArray' | 'Bytes' | 'Boolean' | 'Char' | 'Array' | 'Numeric' | 'Json' | 'Xml' | 'Uuid' | 'DateTime' | 'Date' | 'Time';
|
|
9
18
|
|
|
10
|
-
export declare const bindAdapter: (adapter:
|
|
19
|
+
export declare const bindAdapter: (adapter: SqlConnection) => ErrorCapturingSqlConnection;
|
|
11
20
|
|
|
12
21
|
export declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
|
|
13
22
|
|
|
@@ -53,15 +62,21 @@ export declare type ConnectionInfo = {
|
|
|
53
62
|
|
|
54
63
|
export { Debug }
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
/**
|
|
66
|
+
* A generic driver adapter that allows the user to connect to a
|
|
67
|
+
* database. The query and result types are specific to the adapter.
|
|
68
|
+
*/
|
|
69
|
+
declare interface DriverAdapter_2<Query, Result> extends AdapterInfo {
|
|
61
70
|
/**
|
|
62
|
-
*
|
|
71
|
+
* Connect to the database.
|
|
63
72
|
*/
|
|
64
|
-
|
|
73
|
+
connect(): Promise<Queryable<Query, Result>>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare class DriverAdapterError extends Error {
|
|
77
|
+
name: string;
|
|
78
|
+
cause: Error_2;
|
|
79
|
+
constructor(payload: Error_2);
|
|
65
80
|
}
|
|
66
81
|
|
|
67
82
|
export declare function err<T>(error: Error_2): Result<T>;
|
|
@@ -95,9 +110,23 @@ declare type Error_2 = {
|
|
|
95
110
|
};
|
|
96
111
|
export { Error_2 as Error }
|
|
97
112
|
|
|
98
|
-
|
|
113
|
+
declare type ErrorCapturingFunction<T> = T extends (...args: infer A) => Promise<infer R> ? (...args: A) => Promise<Result<ErrorCapturingInterface<R>>> : T extends (...args: infer A) => infer R ? (...args: A) => Result<ErrorCapturingInterface<R>> : T;
|
|
114
|
+
|
|
115
|
+
declare type ErrorCapturingInterface<T> = {
|
|
116
|
+
[K in keyof T]: ErrorCapturingFunction<T[K]>;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
declare interface ErrorCapturingSqlConnection extends ErrorCapturingInterface<SqlConnection> {
|
|
99
120
|
readonly errorRegistry: ErrorRegistry;
|
|
100
121
|
}
|
|
122
|
+
export { ErrorCapturingSqlConnection as ErrorCapturingDriverAdapter }
|
|
123
|
+
export { ErrorCapturingSqlConnection }
|
|
124
|
+
|
|
125
|
+
export declare type ErrorCapturingSqlQueryable = ErrorCapturingInterface<SqlQueryable>;
|
|
126
|
+
|
|
127
|
+
export declare type ErrorCapturingTransaction = ErrorCapturingInterface<Transaction>;
|
|
128
|
+
|
|
129
|
+
export declare type ErrorCapturingTransactionContext = ErrorCapturingInterface<TransactionContext>;
|
|
101
130
|
|
|
102
131
|
export declare type ErrorRecord = {
|
|
103
132
|
error: unknown;
|
|
@@ -113,30 +142,15 @@ export declare function ok<T>(value: T): Result<T>;
|
|
|
113
142
|
|
|
114
143
|
export declare type Provider = 'mysql' | 'postgres' | 'sqlite';
|
|
115
144
|
|
|
116
|
-
|
|
117
|
-
sql: string;
|
|
118
|
-
args: Array<unknown>;
|
|
119
|
-
argTypes: Array<ArgType>;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export declare interface Queryable {
|
|
123
|
-
readonly provider: Provider;
|
|
124
|
-
readonly adapterName: (typeof officialPrismaAdapters)[number] | (string & {});
|
|
145
|
+
declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
125
146
|
/**
|
|
126
|
-
* Execute a query
|
|
127
|
-
* and returning the type-aware result set of the query.
|
|
128
|
-
*
|
|
129
|
-
* This is the preferred way of executing `SELECT` queries.
|
|
147
|
+
* Execute a query and return its result.
|
|
130
148
|
*/
|
|
131
|
-
queryRaw(params: Query): Promise<Result
|
|
149
|
+
queryRaw(params: Query): Promise<Result>;
|
|
132
150
|
/**
|
|
133
|
-
* Execute a query
|
|
134
|
-
* and returning the number of affected rows.
|
|
135
|
-
*
|
|
136
|
-
* This is the preferred way of executing `INSERT`, `UPDATE`, `DELETE` queries,
|
|
137
|
-
* as well as transactional queries.
|
|
151
|
+
* Execute a query and return the number of affected rows.
|
|
138
152
|
*/
|
|
139
|
-
executeRaw(params: Query): Promise<
|
|
153
|
+
executeRaw(params: Query): Promise<number>;
|
|
140
154
|
}
|
|
141
155
|
|
|
142
156
|
export declare type Result<T> = {
|
|
@@ -150,7 +164,49 @@ export declare type Result<T> = {
|
|
|
150
164
|
readonly error: Error_2;
|
|
151
165
|
});
|
|
152
166
|
|
|
153
|
-
|
|
167
|
+
declare interface SqlConnection extends SqlQueryable {
|
|
168
|
+
/**
|
|
169
|
+
* Execute multiple SQL statements separated by semicolon.
|
|
170
|
+
*/
|
|
171
|
+
executeScript(script: string): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Start new transaction.
|
|
174
|
+
*/
|
|
175
|
+
transactionContext(): Promise<TransactionContext>;
|
|
176
|
+
/**
|
|
177
|
+
* Optional method that returns extra connection info
|
|
178
|
+
*/
|
|
179
|
+
getConnectionInfo?(): ConnectionInfo;
|
|
180
|
+
/**
|
|
181
|
+
* Dispose of the connection and release any resources.
|
|
182
|
+
*/
|
|
183
|
+
dispose(): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
export { SqlConnection as DriverAdapter }
|
|
186
|
+
export { SqlConnection }
|
|
187
|
+
|
|
188
|
+
declare interface SqlDriverAdapter extends DriverAdapter_2<SqlQuery, SqlResultSet> {
|
|
189
|
+
connect(): Promise<SqlConnection>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* An SQL migration adapter that is aware of the notion of a shadow database
|
|
194
|
+
* and can create a connection to it.
|
|
195
|
+
*/
|
|
196
|
+
export declare interface SqlMigrationAwareDriverAdapter extends SqlDriverAdapter {
|
|
197
|
+
connectToShadowDb(): Promise<SqlConnection>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export declare type SqlQuery = {
|
|
201
|
+
sql: string;
|
|
202
|
+
args: Array<unknown>;
|
|
203
|
+
argTypes: Array<ArgType>;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export declare interface SqlQueryable extends Queryable<SqlQuery, SqlResultSet> {
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare interface SqlResultSet {
|
|
154
210
|
/**
|
|
155
211
|
* List of column types appearing in a database query, in the same order as `columnNames`.
|
|
156
212
|
* They are used within the Query Engine to convert values from JS to Quaint values.
|
|
@@ -172,7 +228,7 @@ export declare interface ResultSet {
|
|
|
172
228
|
lastInsertId?: string;
|
|
173
229
|
}
|
|
174
230
|
|
|
175
|
-
export declare interface Transaction extends
|
|
231
|
+
export declare interface Transaction extends AdapterInfo, SqlQueryable {
|
|
176
232
|
/**
|
|
177
233
|
* Transaction options.
|
|
178
234
|
*/
|
|
@@ -180,18 +236,18 @@ export declare interface Transaction extends Queryable {
|
|
|
180
236
|
/**
|
|
181
237
|
* Commit the transaction.
|
|
182
238
|
*/
|
|
183
|
-
commit(): Promise<
|
|
239
|
+
commit(): Promise<void>;
|
|
184
240
|
/**
|
|
185
|
-
*
|
|
241
|
+
* Roll back the transaction.
|
|
186
242
|
*/
|
|
187
|
-
rollback(): Promise<
|
|
243
|
+
rollback(): Promise<void>;
|
|
188
244
|
}
|
|
189
245
|
|
|
190
|
-
export declare interface TransactionContext extends
|
|
246
|
+
export declare interface TransactionContext extends AdapterInfo, SqlQueryable {
|
|
191
247
|
/**
|
|
192
|
-
*
|
|
248
|
+
* Start new transaction.
|
|
193
249
|
*/
|
|
194
|
-
startTransaction(): Promise<
|
|
250
|
+
startTransaction(): Promise<Transaction>;
|
|
195
251
|
}
|
|
196
252
|
|
|
197
253
|
export declare type TransactionOptions = {
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,18 +17,33 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
return to;
|
|
17
18
|
};
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
19
21
|
|
|
20
22
|
// src/index.ts
|
|
21
23
|
var index_exports = {};
|
|
22
24
|
__export(index_exports, {
|
|
23
25
|
ColumnTypeEnum: () => ColumnTypeEnum,
|
|
24
26
|
Debug: () => import_debug.Debug,
|
|
27
|
+
DriverAdapterError: () => DriverAdapterError,
|
|
25
28
|
bindAdapter: () => bindAdapter,
|
|
26
29
|
err: () => err,
|
|
27
30
|
ok: () => ok
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(index_exports);
|
|
30
33
|
|
|
34
|
+
// src/error.ts
|
|
35
|
+
var DriverAdapterError = class extends Error {
|
|
36
|
+
constructor(payload) {
|
|
37
|
+
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
38
|
+
__publicField(this, "name", "DriverAdapterError");
|
|
39
|
+
__publicField(this, "cause");
|
|
40
|
+
this.cause = payload;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function isDriverAdapterError(error) {
|
|
44
|
+
return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object";
|
|
45
|
+
}
|
|
46
|
+
|
|
31
47
|
// src/result.ts
|
|
32
48
|
function ok(value) {
|
|
33
49
|
return {
|
|
@@ -57,7 +73,7 @@ function err(error) {
|
|
|
57
73
|
// src/binder.ts
|
|
58
74
|
var ErrorRegistryInternal = class {
|
|
59
75
|
constructor() {
|
|
60
|
-
this
|
|
76
|
+
__publicField(this, "registeredErrors", []);
|
|
61
77
|
}
|
|
62
78
|
consumeError(id) {
|
|
63
79
|
return this.registeredErrors[id];
|
|
@@ -79,10 +95,12 @@ var bindAdapter = (adapter) => {
|
|
|
79
95
|
errorRegistry,
|
|
80
96
|
queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
|
|
81
97
|
executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
|
|
98
|
+
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
99
|
+
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
82
100
|
provider: adapter.provider,
|
|
83
101
|
transactionContext: async (...args) => {
|
|
84
102
|
const ctx = await createTransactionContext(...args);
|
|
85
|
-
return ctx.map((
|
|
103
|
+
return ctx.map((ctx2) => bindTransactionContext(errorRegistry, ctx2));
|
|
86
104
|
}
|
|
87
105
|
};
|
|
88
106
|
if (adapter.getConnectionInfo) {
|
|
@@ -117,8 +135,11 @@ var bindTransaction = (errorRegistry, transaction) => {
|
|
|
117
135
|
function wrapAsync(registry, fn) {
|
|
118
136
|
return async (...args) => {
|
|
119
137
|
try {
|
|
120
|
-
return await fn(...args);
|
|
138
|
+
return ok(await fn(...args));
|
|
121
139
|
} catch (error) {
|
|
140
|
+
if (isDriverAdapterError(error)) {
|
|
141
|
+
return err(error.cause);
|
|
142
|
+
}
|
|
122
143
|
const id = registry.registerNewError(error);
|
|
123
144
|
return err({ kind: "GenericJs", id });
|
|
124
145
|
}
|
|
@@ -127,8 +148,11 @@ function wrapAsync(registry, fn) {
|
|
|
127
148
|
function wrapSync(registry, fn) {
|
|
128
149
|
return (...args) => {
|
|
129
150
|
try {
|
|
130
|
-
return fn(...args);
|
|
151
|
+
return ok(fn(...args));
|
|
131
152
|
} catch (error) {
|
|
153
|
+
if (isDriverAdapterError(error)) {
|
|
154
|
+
return err(error.cause);
|
|
155
|
+
}
|
|
132
156
|
const id = registry.registerNewError(error);
|
|
133
157
|
return err({ kind: "GenericJs", id });
|
|
134
158
|
}
|
|
@@ -180,6 +204,7 @@ var import_debug = require("@prisma/debug");
|
|
|
180
204
|
0 && (module.exports = {
|
|
181
205
|
ColumnTypeEnum,
|
|
182
206
|
Debug,
|
|
207
|
+
DriverAdapterError,
|
|
183
208
|
bindAdapter,
|
|
184
209
|
err,
|
|
185
210
|
ok
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/error.ts
|
|
6
|
+
var DriverAdapterError = class extends Error {
|
|
7
|
+
constructor(payload) {
|
|
8
|
+
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
9
|
+
__publicField(this, "name", "DriverAdapterError");
|
|
10
|
+
__publicField(this, "cause");
|
|
11
|
+
this.cause = payload;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function isDriverAdapterError(error) {
|
|
15
|
+
return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object";
|
|
16
|
+
}
|
|
17
|
+
|
|
1
18
|
// src/result.ts
|
|
2
19
|
function ok(value) {
|
|
3
20
|
return {
|
|
@@ -27,7 +44,7 @@ function err(error) {
|
|
|
27
44
|
// src/binder.ts
|
|
28
45
|
var ErrorRegistryInternal = class {
|
|
29
46
|
constructor() {
|
|
30
|
-
this
|
|
47
|
+
__publicField(this, "registeredErrors", []);
|
|
31
48
|
}
|
|
32
49
|
consumeError(id) {
|
|
33
50
|
return this.registeredErrors[id];
|
|
@@ -49,10 +66,12 @@ var bindAdapter = (adapter) => {
|
|
|
49
66
|
errorRegistry,
|
|
50
67
|
queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
|
|
51
68
|
executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
|
|
69
|
+
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
70
|
+
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
52
71
|
provider: adapter.provider,
|
|
53
72
|
transactionContext: async (...args) => {
|
|
54
73
|
const ctx = await createTransactionContext(...args);
|
|
55
|
-
return ctx.map((
|
|
74
|
+
return ctx.map((ctx2) => bindTransactionContext(errorRegistry, ctx2));
|
|
56
75
|
}
|
|
57
76
|
};
|
|
58
77
|
if (adapter.getConnectionInfo) {
|
|
@@ -87,8 +106,11 @@ var bindTransaction = (errorRegistry, transaction) => {
|
|
|
87
106
|
function wrapAsync(registry, fn) {
|
|
88
107
|
return async (...args) => {
|
|
89
108
|
try {
|
|
90
|
-
return await fn(...args);
|
|
109
|
+
return ok(await fn(...args));
|
|
91
110
|
} catch (error) {
|
|
111
|
+
if (isDriverAdapterError(error)) {
|
|
112
|
+
return err(error.cause);
|
|
113
|
+
}
|
|
92
114
|
const id = registry.registerNewError(error);
|
|
93
115
|
return err({ kind: "GenericJs", id });
|
|
94
116
|
}
|
|
@@ -97,8 +119,11 @@ function wrapAsync(registry, fn) {
|
|
|
97
119
|
function wrapSync(registry, fn) {
|
|
98
120
|
return (...args) => {
|
|
99
121
|
try {
|
|
100
|
-
return fn(...args);
|
|
122
|
+
return ok(fn(...args));
|
|
101
123
|
} catch (error) {
|
|
124
|
+
if (isDriverAdapterError(error)) {
|
|
125
|
+
return err(error.cause);
|
|
126
|
+
}
|
|
102
127
|
const id = registry.registerNewError(error);
|
|
103
128
|
return err({ kind: "GenericJs", id });
|
|
104
129
|
}
|
|
@@ -149,6 +174,7 @@ import { Debug } from "@prisma/debug";
|
|
|
149
174
|
export {
|
|
150
175
|
ColumnTypeEnum,
|
|
151
176
|
Debug,
|
|
177
|
+
DriverAdapterError,
|
|
152
178
|
bindAdapter,
|
|
153
179
|
err,
|
|
154
180
|
ok
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/driver-adapter-utils",
|
|
3
|
-
"version": "6.5.0-dev.
|
|
3
|
+
"version": "6.5.0-dev.80",
|
|
4
4
|
"description": "Internal set of utilities and types for Prisma's driver adapters.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"license": "Apache-2.0",
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@prisma/debug": "6.5.0-dev.
|
|
34
|
+
"@prisma/debug": "6.5.0-dev.80"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"dev": "DEV=true tsx helpers/build.ts",
|