@prisma/driver-adapter-utils 6.5.0-integration-fix-e2e-prisma-config-2.9 → 6.5.0-integration-fix-client-read-replicas.2
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 +25 -3
- package/dist/index.mjs +24 -3
- 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
|
@@ -22,12 +22,25 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ColumnTypeEnum: () => ColumnTypeEnum,
|
|
24
24
|
Debug: () => import_debug.Debug,
|
|
25
|
+
DriverAdapterError: () => DriverAdapterError,
|
|
25
26
|
bindAdapter: () => bindAdapter,
|
|
26
27
|
err: () => err,
|
|
27
28
|
ok: () => ok
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(index_exports);
|
|
30
31
|
|
|
32
|
+
// src/error.ts
|
|
33
|
+
var DriverAdapterError = class extends Error {
|
|
34
|
+
constructor(payload) {
|
|
35
|
+
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
36
|
+
this.name = "DriverAdapterError";
|
|
37
|
+
this.cause = payload;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
function isDriverAdapterError(error) {
|
|
41
|
+
return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object";
|
|
42
|
+
}
|
|
43
|
+
|
|
31
44
|
// src/result.ts
|
|
32
45
|
function ok(value) {
|
|
33
46
|
return {
|
|
@@ -79,10 +92,12 @@ var bindAdapter = (adapter) => {
|
|
|
79
92
|
errorRegistry,
|
|
80
93
|
queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
|
|
81
94
|
executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
|
|
95
|
+
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
96
|
+
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
82
97
|
provider: adapter.provider,
|
|
83
98
|
transactionContext: async (...args) => {
|
|
84
99
|
const ctx = await createTransactionContext(...args);
|
|
85
|
-
return ctx.map((
|
|
100
|
+
return ctx.map((ctx2) => bindTransactionContext(errorRegistry, ctx2));
|
|
86
101
|
}
|
|
87
102
|
};
|
|
88
103
|
if (adapter.getConnectionInfo) {
|
|
@@ -117,8 +132,11 @@ var bindTransaction = (errorRegistry, transaction) => {
|
|
|
117
132
|
function wrapAsync(registry, fn) {
|
|
118
133
|
return async (...args) => {
|
|
119
134
|
try {
|
|
120
|
-
return await fn(...args);
|
|
135
|
+
return ok(await fn(...args));
|
|
121
136
|
} catch (error) {
|
|
137
|
+
if (isDriverAdapterError(error)) {
|
|
138
|
+
return err(error.cause);
|
|
139
|
+
}
|
|
122
140
|
const id = registry.registerNewError(error);
|
|
123
141
|
return err({ kind: "GenericJs", id });
|
|
124
142
|
}
|
|
@@ -127,8 +145,11 @@ function wrapAsync(registry, fn) {
|
|
|
127
145
|
function wrapSync(registry, fn) {
|
|
128
146
|
return (...args) => {
|
|
129
147
|
try {
|
|
130
|
-
return fn(...args);
|
|
148
|
+
return ok(fn(...args));
|
|
131
149
|
} catch (error) {
|
|
150
|
+
if (isDriverAdapterError(error)) {
|
|
151
|
+
return err(error.cause);
|
|
152
|
+
}
|
|
132
153
|
const id = registry.registerNewError(error);
|
|
133
154
|
return err({ kind: "GenericJs", id });
|
|
134
155
|
}
|
|
@@ -180,6 +201,7 @@ var import_debug = require("@prisma/debug");
|
|
|
180
201
|
0 && (module.exports = {
|
|
181
202
|
ColumnTypeEnum,
|
|
182
203
|
Debug,
|
|
204
|
+
DriverAdapterError,
|
|
183
205
|
bindAdapter,
|
|
184
206
|
err,
|
|
185
207
|
ok
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// src/error.ts
|
|
2
|
+
var DriverAdapterError = class extends Error {
|
|
3
|
+
constructor(payload) {
|
|
4
|
+
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
5
|
+
this.name = "DriverAdapterError";
|
|
6
|
+
this.cause = payload;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
function isDriverAdapterError(error) {
|
|
10
|
+
return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object";
|
|
11
|
+
}
|
|
12
|
+
|
|
1
13
|
// src/result.ts
|
|
2
14
|
function ok(value) {
|
|
3
15
|
return {
|
|
@@ -49,10 +61,12 @@ var bindAdapter = (adapter) => {
|
|
|
49
61
|
errorRegistry,
|
|
50
62
|
queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)),
|
|
51
63
|
executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)),
|
|
64
|
+
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
65
|
+
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
52
66
|
provider: adapter.provider,
|
|
53
67
|
transactionContext: async (...args) => {
|
|
54
68
|
const ctx = await createTransactionContext(...args);
|
|
55
|
-
return ctx.map((
|
|
69
|
+
return ctx.map((ctx2) => bindTransactionContext(errorRegistry, ctx2));
|
|
56
70
|
}
|
|
57
71
|
};
|
|
58
72
|
if (adapter.getConnectionInfo) {
|
|
@@ -87,8 +101,11 @@ var bindTransaction = (errorRegistry, transaction) => {
|
|
|
87
101
|
function wrapAsync(registry, fn) {
|
|
88
102
|
return async (...args) => {
|
|
89
103
|
try {
|
|
90
|
-
return await fn(...args);
|
|
104
|
+
return ok(await fn(...args));
|
|
91
105
|
} catch (error) {
|
|
106
|
+
if (isDriverAdapterError(error)) {
|
|
107
|
+
return err(error.cause);
|
|
108
|
+
}
|
|
92
109
|
const id = registry.registerNewError(error);
|
|
93
110
|
return err({ kind: "GenericJs", id });
|
|
94
111
|
}
|
|
@@ -97,8 +114,11 @@ function wrapAsync(registry, fn) {
|
|
|
97
114
|
function wrapSync(registry, fn) {
|
|
98
115
|
return (...args) => {
|
|
99
116
|
try {
|
|
100
|
-
return fn(...args);
|
|
117
|
+
return ok(fn(...args));
|
|
101
118
|
} catch (error) {
|
|
119
|
+
if (isDriverAdapterError(error)) {
|
|
120
|
+
return err(error.cause);
|
|
121
|
+
}
|
|
102
122
|
const id = registry.registerNewError(error);
|
|
103
123
|
return err({ kind: "GenericJs", id });
|
|
104
124
|
}
|
|
@@ -149,6 +169,7 @@ import { Debug } from "@prisma/debug";
|
|
|
149
169
|
export {
|
|
150
170
|
ColumnTypeEnum,
|
|
151
171
|
Debug,
|
|
172
|
+
DriverAdapterError,
|
|
152
173
|
bindAdapter,
|
|
153
174
|
err,
|
|
154
175
|
ok
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/driver-adapter-utils",
|
|
3
|
-
"version": "6.5.0-integration-fix-
|
|
3
|
+
"version": "6.5.0-integration-fix-client-read-replicas.2",
|
|
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-integration-fix-
|
|
34
|
+
"@prisma/debug": "6.5.0-integration-fix-client-read-replicas.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"dev": "DEV=true tsx helpers/build.ts",
|