@prisma/driver-adapter-utils 6.6.0-dev.10 → 6.6.0-dev.101
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 +65 -32
- package/dist/index.d.ts +65 -32
- package/dist/index.js +83 -25
- package/dist/index.mjs +77 -27
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -16,7 +16,11 @@ declare interface AdapterInfo {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare type ArgType = 'Int32' | 'Int64' | 'Float' | 'Double' | 'Text' | 'Enum' | 'EnumArray' | 'Bytes' | 'Boolean' | 'Char' | 'Array' | 'Numeric' | 'Json' | 'Xml' | 'Uuid' | 'DateTime' | 'Date' | 'Time';
|
|
18
18
|
|
|
19
|
-
export declare const bindAdapter: (adapter:
|
|
19
|
+
export declare const bindAdapter: (adapter: SqlDriverAdapter, errorRegistry?: ErrorRegistryInternal) => ErrorCapturingSqlDriverAdapter;
|
|
20
|
+
|
|
21
|
+
export declare const bindMigrationAwareSqlAdapterFactory: (adapterFactory: SqlMigrationAwareDriverAdapterFactory) => ErrorCapturingSqlMigrationAwareDriverAdapterFactory;
|
|
22
|
+
|
|
23
|
+
export declare const bindSqlAdapterFactory: (adapterFactory: SqlDriverAdapterFactory) => ErrorCapturingSqlDriverAdapterFactory;
|
|
20
24
|
|
|
21
25
|
export declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
|
|
22
26
|
|
|
@@ -62,23 +66,23 @@ export declare type ConnectionInfo = {
|
|
|
62
66
|
|
|
63
67
|
export { Debug }
|
|
64
68
|
|
|
69
|
+
export declare class DriverAdapterError extends Error {
|
|
70
|
+
name: string;
|
|
71
|
+
cause: Error_2;
|
|
72
|
+
constructor(payload: Error_2);
|
|
73
|
+
}
|
|
74
|
+
|
|
65
75
|
/**
|
|
66
|
-
* A generic driver adapter that allows the user to
|
|
67
|
-
*
|
|
76
|
+
* A generic driver adapter factory that allows the user to instantiate a
|
|
77
|
+
* driver adapter. The query and result types are specific to the adapter.
|
|
68
78
|
*/
|
|
69
|
-
declare interface
|
|
79
|
+
export declare interface DriverAdapterFactory<Query, Result> extends AdapterInfo {
|
|
70
80
|
/**
|
|
71
|
-
*
|
|
81
|
+
* Instantiate a driver adapter.
|
|
72
82
|
*/
|
|
73
83
|
connect(): Promise<Queryable<Query, Result>>;
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
export declare class DriverAdapterError extends Error {
|
|
77
|
-
name: string;
|
|
78
|
-
cause: Error_2;
|
|
79
|
-
constructor(payload: Error_2);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
86
|
export declare function err<T>(error: Error_2): Result<T>;
|
|
83
87
|
|
|
84
88
|
declare type Error_2 = {
|
|
@@ -87,6 +91,9 @@ declare type Error_2 = {
|
|
|
87
91
|
} | {
|
|
88
92
|
kind: 'UnsupportedNativeDataType';
|
|
89
93
|
type: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'InvalidIsolationLevel';
|
|
96
|
+
level: string;
|
|
90
97
|
} | {
|
|
91
98
|
kind: 'postgres';
|
|
92
99
|
code: string;
|
|
@@ -116,18 +123,22 @@ declare type ErrorCapturingInterface<T> = {
|
|
|
116
123
|
[K in keyof T]: ErrorCapturingFunction<T[K]>;
|
|
117
124
|
};
|
|
118
125
|
|
|
119
|
-
declare interface
|
|
126
|
+
export declare interface ErrorCapturingSqlDriverAdapter extends ErrorCapturingInterface<SqlDriverAdapter> {
|
|
127
|
+
readonly errorRegistry: ErrorRegistry;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare interface ErrorCapturingSqlDriverAdapterFactory extends ErrorCapturingInterface<SqlDriverAdapterFactory> {
|
|
131
|
+
readonly errorRegistry: ErrorRegistry;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare interface ErrorCapturingSqlMigrationAwareDriverAdapterFactory extends ErrorCapturingInterface<SqlMigrationAwareDriverAdapterFactory> {
|
|
120
135
|
readonly errorRegistry: ErrorRegistry;
|
|
121
136
|
}
|
|
122
|
-
export { ErrorCapturingSqlConnection as ErrorCapturingDriverAdapter }
|
|
123
|
-
export { ErrorCapturingSqlConnection }
|
|
124
137
|
|
|
125
138
|
export declare type ErrorCapturingSqlQueryable = ErrorCapturingInterface<SqlQueryable>;
|
|
126
139
|
|
|
127
140
|
export declare type ErrorCapturingTransaction = ErrorCapturingInterface<Transaction>;
|
|
128
141
|
|
|
129
|
-
export declare type ErrorCapturingTransactionContext = ErrorCapturingInterface<TransactionContext>;
|
|
130
|
-
|
|
131
142
|
export declare type ErrorRecord = {
|
|
132
143
|
error: unknown;
|
|
133
144
|
};
|
|
@@ -136,13 +147,44 @@ export declare interface ErrorRegistry {
|
|
|
136
147
|
consumeError(id: number): ErrorRecord | undefined;
|
|
137
148
|
}
|
|
138
149
|
|
|
150
|
+
declare class ErrorRegistryInternal implements ErrorRegistry {
|
|
151
|
+
private registeredErrors;
|
|
152
|
+
consumeError(id: number): ErrorRecord | undefined;
|
|
153
|
+
registerNewError(error: unknown): number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Create an adapter stub for testing.
|
|
160
|
+
*/
|
|
161
|
+
export declare function mockAdapter(provider: 'mysql' | 'sqlite' | 'postgres'): SqlDriverAdapter;
|
|
162
|
+
|
|
163
|
+
export declare const mockAdapterErrors: {
|
|
164
|
+
queryRaw: Error;
|
|
165
|
+
executeRaw: Error;
|
|
166
|
+
startTransaction: Error;
|
|
167
|
+
executeScript: Error;
|
|
168
|
+
dispose: Error;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Create an adapter factory stub for testing.
|
|
173
|
+
*/
|
|
174
|
+
export declare function mockAdapterFactory(provider: 'mysql' | 'sqlite' | 'postgres'): SqlDriverAdapterFactory;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Create an adapter factory stub for testing.
|
|
178
|
+
*/
|
|
179
|
+
export declare function mockMigrationAwareAdapterFactory(provider: 'mysql' | 'sqlite' | 'postgres'): SqlMigrationAwareDriverAdapterFactory;
|
|
180
|
+
|
|
139
181
|
declare const officialPrismaAdapters: readonly ["@prisma/adapter-planetscale", "@prisma/adapter-neon", "@prisma/adapter-libsql", "@prisma/adapter-d1", "@prisma/adapter-pg", "@prisma/adapter-pg-worker"];
|
|
140
182
|
|
|
141
183
|
export declare function ok<T>(value: T): Result<T>;
|
|
142
184
|
|
|
143
185
|
export declare type Provider = 'mysql' | 'postgres' | 'sqlite';
|
|
144
186
|
|
|
145
|
-
declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
187
|
+
export declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
146
188
|
/**
|
|
147
189
|
* Execute a query and return its result.
|
|
148
190
|
*/
|
|
@@ -164,7 +206,7 @@ export declare type Result<T> = {
|
|
|
164
206
|
readonly error: Error_2;
|
|
165
207
|
});
|
|
166
208
|
|
|
167
|
-
declare interface
|
|
209
|
+
export declare interface SqlDriverAdapter extends SqlQueryable {
|
|
168
210
|
/**
|
|
169
211
|
* Execute multiple SQL statements separated by semicolon.
|
|
170
212
|
*/
|
|
@@ -172,7 +214,7 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
172
214
|
/**
|
|
173
215
|
* Start new transaction.
|
|
174
216
|
*/
|
|
175
|
-
|
|
217
|
+
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
176
218
|
/**
|
|
177
219
|
* Optional method that returns extra connection info
|
|
178
220
|
*/
|
|
@@ -182,19 +224,17 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
182
224
|
*/
|
|
183
225
|
dispose(): Promise<void>;
|
|
184
226
|
}
|
|
185
|
-
export { SqlConnection as DriverAdapter }
|
|
186
|
-
export { SqlConnection }
|
|
187
227
|
|
|
188
|
-
declare interface
|
|
189
|
-
connect(): Promise<
|
|
228
|
+
export declare interface SqlDriverAdapterFactory extends DriverAdapterFactory<SqlQuery, SqlResultSet> {
|
|
229
|
+
connect(): Promise<SqlDriverAdapter>;
|
|
190
230
|
}
|
|
191
231
|
|
|
192
232
|
/**
|
|
193
233
|
* An SQL migration adapter that is aware of the notion of a shadow database
|
|
194
234
|
* and can create a connection to it.
|
|
195
235
|
*/
|
|
196
|
-
export declare interface
|
|
197
|
-
connectToShadowDb(): Promise<
|
|
236
|
+
export declare interface SqlMigrationAwareDriverAdapterFactory extends SqlDriverAdapterFactory {
|
|
237
|
+
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
198
238
|
}
|
|
199
239
|
|
|
200
240
|
export declare type SqlQuery = {
|
|
@@ -243,13 +283,6 @@ export declare interface Transaction extends AdapterInfo, SqlQueryable {
|
|
|
243
283
|
rollback(): Promise<void>;
|
|
244
284
|
}
|
|
245
285
|
|
|
246
|
-
export declare interface TransactionContext extends AdapterInfo, SqlQueryable {
|
|
247
|
-
/**
|
|
248
|
-
* Start new transaction.
|
|
249
|
-
*/
|
|
250
|
-
startTransaction(): Promise<Transaction>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
286
|
export declare type TransactionOptions = {
|
|
254
287
|
usePhantomQuery: boolean;
|
|
255
288
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ declare interface AdapterInfo {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare type ArgType = 'Int32' | 'Int64' | 'Float' | 'Double' | 'Text' | 'Enum' | 'EnumArray' | 'Bytes' | 'Boolean' | 'Char' | 'Array' | 'Numeric' | 'Json' | 'Xml' | 'Uuid' | 'DateTime' | 'Date' | 'Time';
|
|
18
18
|
|
|
19
|
-
export declare const bindAdapter: (adapter:
|
|
19
|
+
export declare const bindAdapter: (adapter: SqlDriverAdapter, errorRegistry?: ErrorRegistryInternal) => ErrorCapturingSqlDriverAdapter;
|
|
20
|
+
|
|
21
|
+
export declare const bindMigrationAwareSqlAdapterFactory: (adapterFactory: SqlMigrationAwareDriverAdapterFactory) => ErrorCapturingSqlMigrationAwareDriverAdapterFactory;
|
|
22
|
+
|
|
23
|
+
export declare const bindSqlAdapterFactory: (adapterFactory: SqlDriverAdapterFactory) => ErrorCapturingSqlDriverAdapterFactory;
|
|
20
24
|
|
|
21
25
|
export declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
|
|
22
26
|
|
|
@@ -62,23 +66,23 @@ export declare type ConnectionInfo = {
|
|
|
62
66
|
|
|
63
67
|
export { Debug }
|
|
64
68
|
|
|
69
|
+
export declare class DriverAdapterError extends Error {
|
|
70
|
+
name: string;
|
|
71
|
+
cause: Error_2;
|
|
72
|
+
constructor(payload: Error_2);
|
|
73
|
+
}
|
|
74
|
+
|
|
65
75
|
/**
|
|
66
|
-
* A generic driver adapter that allows the user to
|
|
67
|
-
*
|
|
76
|
+
* A generic driver adapter factory that allows the user to instantiate a
|
|
77
|
+
* driver adapter. The query and result types are specific to the adapter.
|
|
68
78
|
*/
|
|
69
|
-
declare interface
|
|
79
|
+
export declare interface DriverAdapterFactory<Query, Result> extends AdapterInfo {
|
|
70
80
|
/**
|
|
71
|
-
*
|
|
81
|
+
* Instantiate a driver adapter.
|
|
72
82
|
*/
|
|
73
83
|
connect(): Promise<Queryable<Query, Result>>;
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
export declare class DriverAdapterError extends Error {
|
|
77
|
-
name: string;
|
|
78
|
-
cause: Error_2;
|
|
79
|
-
constructor(payload: Error_2);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
86
|
export declare function err<T>(error: Error_2): Result<T>;
|
|
83
87
|
|
|
84
88
|
declare type Error_2 = {
|
|
@@ -87,6 +91,9 @@ declare type Error_2 = {
|
|
|
87
91
|
} | {
|
|
88
92
|
kind: 'UnsupportedNativeDataType';
|
|
89
93
|
type: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: 'InvalidIsolationLevel';
|
|
96
|
+
level: string;
|
|
90
97
|
} | {
|
|
91
98
|
kind: 'postgres';
|
|
92
99
|
code: string;
|
|
@@ -116,18 +123,22 @@ declare type ErrorCapturingInterface<T> = {
|
|
|
116
123
|
[K in keyof T]: ErrorCapturingFunction<T[K]>;
|
|
117
124
|
};
|
|
118
125
|
|
|
119
|
-
declare interface
|
|
126
|
+
export declare interface ErrorCapturingSqlDriverAdapter extends ErrorCapturingInterface<SqlDriverAdapter> {
|
|
127
|
+
readonly errorRegistry: ErrorRegistry;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare interface ErrorCapturingSqlDriverAdapterFactory extends ErrorCapturingInterface<SqlDriverAdapterFactory> {
|
|
131
|
+
readonly errorRegistry: ErrorRegistry;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare interface ErrorCapturingSqlMigrationAwareDriverAdapterFactory extends ErrorCapturingInterface<SqlMigrationAwareDriverAdapterFactory> {
|
|
120
135
|
readonly errorRegistry: ErrorRegistry;
|
|
121
136
|
}
|
|
122
|
-
export { ErrorCapturingSqlConnection as ErrorCapturingDriverAdapter }
|
|
123
|
-
export { ErrorCapturingSqlConnection }
|
|
124
137
|
|
|
125
138
|
export declare type ErrorCapturingSqlQueryable = ErrorCapturingInterface<SqlQueryable>;
|
|
126
139
|
|
|
127
140
|
export declare type ErrorCapturingTransaction = ErrorCapturingInterface<Transaction>;
|
|
128
141
|
|
|
129
|
-
export declare type ErrorCapturingTransactionContext = ErrorCapturingInterface<TransactionContext>;
|
|
130
|
-
|
|
131
142
|
export declare type ErrorRecord = {
|
|
132
143
|
error: unknown;
|
|
133
144
|
};
|
|
@@ -136,13 +147,44 @@ export declare interface ErrorRegistry {
|
|
|
136
147
|
consumeError(id: number): ErrorRecord | undefined;
|
|
137
148
|
}
|
|
138
149
|
|
|
150
|
+
declare class ErrorRegistryInternal implements ErrorRegistry {
|
|
151
|
+
private registeredErrors;
|
|
152
|
+
consumeError(id: number): ErrorRecord | undefined;
|
|
153
|
+
registerNewError(error: unknown): number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Create an adapter stub for testing.
|
|
160
|
+
*/
|
|
161
|
+
export declare function mockAdapter(provider: 'mysql' | 'sqlite' | 'postgres'): SqlDriverAdapter;
|
|
162
|
+
|
|
163
|
+
export declare const mockAdapterErrors: {
|
|
164
|
+
queryRaw: Error;
|
|
165
|
+
executeRaw: Error;
|
|
166
|
+
startTransaction: Error;
|
|
167
|
+
executeScript: Error;
|
|
168
|
+
dispose: Error;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Create an adapter factory stub for testing.
|
|
173
|
+
*/
|
|
174
|
+
export declare function mockAdapterFactory(provider: 'mysql' | 'sqlite' | 'postgres'): SqlDriverAdapterFactory;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Create an adapter factory stub for testing.
|
|
178
|
+
*/
|
|
179
|
+
export declare function mockMigrationAwareAdapterFactory(provider: 'mysql' | 'sqlite' | 'postgres'): SqlMigrationAwareDriverAdapterFactory;
|
|
180
|
+
|
|
139
181
|
declare const officialPrismaAdapters: readonly ["@prisma/adapter-planetscale", "@prisma/adapter-neon", "@prisma/adapter-libsql", "@prisma/adapter-d1", "@prisma/adapter-pg", "@prisma/adapter-pg-worker"];
|
|
140
182
|
|
|
141
183
|
export declare function ok<T>(value: T): Result<T>;
|
|
142
184
|
|
|
143
185
|
export declare type Provider = 'mysql' | 'postgres' | 'sqlite';
|
|
144
186
|
|
|
145
|
-
declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
187
|
+
export declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
146
188
|
/**
|
|
147
189
|
* Execute a query and return its result.
|
|
148
190
|
*/
|
|
@@ -164,7 +206,7 @@ export declare type Result<T> = {
|
|
|
164
206
|
readonly error: Error_2;
|
|
165
207
|
});
|
|
166
208
|
|
|
167
|
-
declare interface
|
|
209
|
+
export declare interface SqlDriverAdapter extends SqlQueryable {
|
|
168
210
|
/**
|
|
169
211
|
* Execute multiple SQL statements separated by semicolon.
|
|
170
212
|
*/
|
|
@@ -172,7 +214,7 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
172
214
|
/**
|
|
173
215
|
* Start new transaction.
|
|
174
216
|
*/
|
|
175
|
-
|
|
217
|
+
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
176
218
|
/**
|
|
177
219
|
* Optional method that returns extra connection info
|
|
178
220
|
*/
|
|
@@ -182,19 +224,17 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
182
224
|
*/
|
|
183
225
|
dispose(): Promise<void>;
|
|
184
226
|
}
|
|
185
|
-
export { SqlConnection as DriverAdapter }
|
|
186
|
-
export { SqlConnection }
|
|
187
227
|
|
|
188
|
-
declare interface
|
|
189
|
-
connect(): Promise<
|
|
228
|
+
export declare interface SqlDriverAdapterFactory extends DriverAdapterFactory<SqlQuery, SqlResultSet> {
|
|
229
|
+
connect(): Promise<SqlDriverAdapter>;
|
|
190
230
|
}
|
|
191
231
|
|
|
192
232
|
/**
|
|
193
233
|
* An SQL migration adapter that is aware of the notion of a shadow database
|
|
194
234
|
* and can create a connection to it.
|
|
195
235
|
*/
|
|
196
|
-
export declare interface
|
|
197
|
-
connectToShadowDb(): Promise<
|
|
236
|
+
export declare interface SqlMigrationAwareDriverAdapterFactory extends SqlDriverAdapterFactory {
|
|
237
|
+
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
198
238
|
}
|
|
199
239
|
|
|
200
240
|
export declare type SqlQuery = {
|
|
@@ -243,13 +283,6 @@ export declare interface Transaction extends AdapterInfo, SqlQueryable {
|
|
|
243
283
|
rollback(): Promise<void>;
|
|
244
284
|
}
|
|
245
285
|
|
|
246
|
-
export declare interface TransactionContext extends AdapterInfo, SqlQueryable {
|
|
247
|
-
/**
|
|
248
|
-
* Start new transaction.
|
|
249
|
-
*/
|
|
250
|
-
startTransaction(): Promise<Transaction>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
286
|
export declare type TransactionOptions = {
|
|
254
287
|
usePhantomQuery: boolean;
|
|
255
288
|
};
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ 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;
|
|
7
6
|
var __export = (target, all) => {
|
|
8
7
|
for (var name in all)
|
|
9
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -17,7 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
16
|
return to;
|
|
18
17
|
};
|
|
19
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
19
|
|
|
22
20
|
// src/index.ts
|
|
23
21
|
var index_exports = {};
|
|
@@ -26,17 +24,23 @@ __export(index_exports, {
|
|
|
26
24
|
Debug: () => import_debug.Debug,
|
|
27
25
|
DriverAdapterError: () => DriverAdapterError,
|
|
28
26
|
bindAdapter: () => bindAdapter,
|
|
27
|
+
bindMigrationAwareSqlAdapterFactory: () => bindMigrationAwareSqlAdapterFactory,
|
|
28
|
+
bindSqlAdapterFactory: () => bindSqlAdapterFactory,
|
|
29
29
|
err: () => err,
|
|
30
|
+
mockAdapter: () => mockAdapter,
|
|
31
|
+
mockAdapterErrors: () => mockAdapterErrors,
|
|
32
|
+
mockAdapterFactory: () => mockAdapterFactory,
|
|
33
|
+
mockMigrationAwareAdapterFactory: () => mockMigrationAwareAdapterFactory,
|
|
30
34
|
ok: () => ok
|
|
31
35
|
});
|
|
32
36
|
module.exports = __toCommonJS(index_exports);
|
|
33
37
|
|
|
34
38
|
// src/error.ts
|
|
35
39
|
var DriverAdapterError = class extends Error {
|
|
40
|
+
name = "DriverAdapterError";
|
|
41
|
+
cause;
|
|
36
42
|
constructor(payload) {
|
|
37
43
|
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
38
|
-
__publicField(this, "name", "DriverAdapterError");
|
|
39
|
-
__publicField(this, "cause");
|
|
40
44
|
this.cause = payload;
|
|
41
45
|
}
|
|
42
46
|
};
|
|
@@ -72,9 +76,7 @@ function err(error) {
|
|
|
72
76
|
|
|
73
77
|
// src/binder.ts
|
|
74
78
|
var ErrorRegistryInternal = class {
|
|
75
|
-
|
|
76
|
-
__publicField(this, "registeredErrors", []);
|
|
77
|
-
}
|
|
79
|
+
registeredErrors = [];
|
|
78
80
|
consumeError(id) {
|
|
79
81
|
return this.registeredErrors[id];
|
|
80
82
|
}
|
|
@@ -87,9 +89,37 @@ var ErrorRegistryInternal = class {
|
|
|
87
89
|
return i;
|
|
88
90
|
}
|
|
89
91
|
};
|
|
90
|
-
var
|
|
92
|
+
var bindMigrationAwareSqlAdapterFactory = (adapterFactory) => {
|
|
93
|
+
const errorRegistry = new ErrorRegistryInternal();
|
|
94
|
+
const boundFactory = {
|
|
95
|
+
adapterName: adapterFactory.adapterName,
|
|
96
|
+
provider: adapterFactory.provider,
|
|
97
|
+
errorRegistry,
|
|
98
|
+
connect: async (...args) => {
|
|
99
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
|
|
100
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
101
|
+
},
|
|
102
|
+
connectToShadowDb: async (...args) => {
|
|
103
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connectToShadowDb.bind(adapterFactory))(...args);
|
|
104
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return boundFactory;
|
|
108
|
+
};
|
|
109
|
+
var bindSqlAdapterFactory = (adapterFactory) => {
|
|
91
110
|
const errorRegistry = new ErrorRegistryInternal();
|
|
92
|
-
const
|
|
111
|
+
const boundFactory = {
|
|
112
|
+
adapterName: adapterFactory.adapterName,
|
|
113
|
+
provider: adapterFactory.provider,
|
|
114
|
+
errorRegistry,
|
|
115
|
+
connect: async (...args) => {
|
|
116
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
|
|
117
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return boundFactory;
|
|
121
|
+
};
|
|
122
|
+
var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
|
|
93
123
|
const boundAdapter = {
|
|
94
124
|
adapterName: adapter.adapterName,
|
|
95
125
|
errorRegistry,
|
|
@@ -98,9 +128,9 @@ var bindAdapter = (adapter) => {
|
|
|
98
128
|
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
99
129
|
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
100
130
|
provider: adapter.provider,
|
|
101
|
-
|
|
102
|
-
const ctx = await
|
|
103
|
-
return ctx.map((ctx2) =>
|
|
131
|
+
startTransaction: async (...args) => {
|
|
132
|
+
const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args);
|
|
133
|
+
return ctx.map((ctx2) => bindTransaction(errorRegistry, ctx2));
|
|
104
134
|
}
|
|
105
135
|
};
|
|
106
136
|
if (adapter.getConnectionInfo) {
|
|
@@ -108,19 +138,6 @@ var bindAdapter = (adapter) => {
|
|
|
108
138
|
}
|
|
109
139
|
return boundAdapter;
|
|
110
140
|
};
|
|
111
|
-
var bindTransactionContext = (errorRegistry, ctx) => {
|
|
112
|
-
const startTransaction = wrapAsync(errorRegistry, ctx.startTransaction.bind(ctx));
|
|
113
|
-
return {
|
|
114
|
-
adapterName: ctx.adapterName,
|
|
115
|
-
provider: ctx.provider,
|
|
116
|
-
queryRaw: wrapAsync(errorRegistry, ctx.queryRaw.bind(ctx)),
|
|
117
|
-
executeRaw: wrapAsync(errorRegistry, ctx.executeRaw.bind(ctx)),
|
|
118
|
-
startTransaction: async (...args) => {
|
|
119
|
-
const result = await startTransaction(...args);
|
|
120
|
-
return result.map((tx) => bindTransaction(errorRegistry, tx));
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
141
|
var bindTransaction = (errorRegistry, transaction) => {
|
|
125
142
|
return {
|
|
126
143
|
adapterName: transaction.adapterName,
|
|
@@ -200,12 +217,53 @@ var ColumnTypeEnum = {
|
|
|
200
217
|
|
|
201
218
|
// src/debug.ts
|
|
202
219
|
var import_debug = require("@prisma/debug");
|
|
220
|
+
|
|
221
|
+
// src/mock.ts
|
|
222
|
+
var mockAdapterErrors = {
|
|
223
|
+
queryRaw: new Error("Not implemented: queryRaw"),
|
|
224
|
+
executeRaw: new Error("Not implemented: executeRaw"),
|
|
225
|
+
startTransaction: new Error("Not implemented: startTransaction"),
|
|
226
|
+
executeScript: new Error("Not implemented: executeScript"),
|
|
227
|
+
dispose: new Error("Not implemented: dispose")
|
|
228
|
+
};
|
|
229
|
+
function mockAdapter(provider) {
|
|
230
|
+
return {
|
|
231
|
+
provider,
|
|
232
|
+
adapterName: "@prisma/adapter-mock",
|
|
233
|
+
queryRaw: () => Promise.reject(mockAdapterErrors.queryRaw),
|
|
234
|
+
executeRaw: () => Promise.reject(mockAdapterErrors.executeRaw),
|
|
235
|
+
startTransaction: () => Promise.reject(mockAdapterErrors.startTransaction),
|
|
236
|
+
executeScript: () => Promise.reject(mockAdapterErrors.executeScript),
|
|
237
|
+
dispose: () => Promise.reject(mockAdapterErrors.dispose)
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function mockAdapterFactory(provider) {
|
|
241
|
+
return {
|
|
242
|
+
provider,
|
|
243
|
+
adapterName: "@prisma/adapter-mock",
|
|
244
|
+
connect: () => Promise.resolve(mockAdapter(provider))
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function mockMigrationAwareAdapterFactory(provider) {
|
|
248
|
+
return {
|
|
249
|
+
provider,
|
|
250
|
+
adapterName: "@prisma/adapter-mock",
|
|
251
|
+
connect: () => Promise.resolve(mockAdapter(provider)),
|
|
252
|
+
connectToShadowDb: () => Promise.resolve(mockAdapter(provider))
|
|
253
|
+
};
|
|
254
|
+
}
|
|
203
255
|
// Annotate the CommonJS export names for ESM import in node:
|
|
204
256
|
0 && (module.exports = {
|
|
205
257
|
ColumnTypeEnum,
|
|
206
258
|
Debug,
|
|
207
259
|
DriverAdapterError,
|
|
208
260
|
bindAdapter,
|
|
261
|
+
bindMigrationAwareSqlAdapterFactory,
|
|
262
|
+
bindSqlAdapterFactory,
|
|
209
263
|
err,
|
|
264
|
+
mockAdapter,
|
|
265
|
+
mockAdapterErrors,
|
|
266
|
+
mockAdapterFactory,
|
|
267
|
+
mockMigrationAwareAdapterFactory,
|
|
210
268
|
ok
|
|
211
269
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
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
1
|
// src/error.ts
|
|
6
2
|
var DriverAdapterError = class extends Error {
|
|
3
|
+
name = "DriverAdapterError";
|
|
4
|
+
cause;
|
|
7
5
|
constructor(payload) {
|
|
8
6
|
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
9
|
-
__publicField(this, "name", "DriverAdapterError");
|
|
10
|
-
__publicField(this, "cause");
|
|
11
7
|
this.cause = payload;
|
|
12
8
|
}
|
|
13
9
|
};
|
|
@@ -43,9 +39,7 @@ function err(error) {
|
|
|
43
39
|
|
|
44
40
|
// src/binder.ts
|
|
45
41
|
var ErrorRegistryInternal = class {
|
|
46
|
-
|
|
47
|
-
__publicField(this, "registeredErrors", []);
|
|
48
|
-
}
|
|
42
|
+
registeredErrors = [];
|
|
49
43
|
consumeError(id) {
|
|
50
44
|
return this.registeredErrors[id];
|
|
51
45
|
}
|
|
@@ -58,9 +52,37 @@ var ErrorRegistryInternal = class {
|
|
|
58
52
|
return i;
|
|
59
53
|
}
|
|
60
54
|
};
|
|
61
|
-
var
|
|
55
|
+
var bindMigrationAwareSqlAdapterFactory = (adapterFactory) => {
|
|
56
|
+
const errorRegistry = new ErrorRegistryInternal();
|
|
57
|
+
const boundFactory = {
|
|
58
|
+
adapterName: adapterFactory.adapterName,
|
|
59
|
+
provider: adapterFactory.provider,
|
|
60
|
+
errorRegistry,
|
|
61
|
+
connect: async (...args) => {
|
|
62
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
|
|
63
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
64
|
+
},
|
|
65
|
+
connectToShadowDb: async (...args) => {
|
|
66
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connectToShadowDb.bind(adapterFactory))(...args);
|
|
67
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return boundFactory;
|
|
71
|
+
};
|
|
72
|
+
var bindSqlAdapterFactory = (adapterFactory) => {
|
|
62
73
|
const errorRegistry = new ErrorRegistryInternal();
|
|
63
|
-
const
|
|
74
|
+
const boundFactory = {
|
|
75
|
+
adapterName: adapterFactory.adapterName,
|
|
76
|
+
provider: adapterFactory.provider,
|
|
77
|
+
errorRegistry,
|
|
78
|
+
connect: async (...args) => {
|
|
79
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
|
|
80
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return boundFactory;
|
|
84
|
+
};
|
|
85
|
+
var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
|
|
64
86
|
const boundAdapter = {
|
|
65
87
|
adapterName: adapter.adapterName,
|
|
66
88
|
errorRegistry,
|
|
@@ -69,9 +91,9 @@ var bindAdapter = (adapter) => {
|
|
|
69
91
|
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
70
92
|
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
71
93
|
provider: adapter.provider,
|
|
72
|
-
|
|
73
|
-
const ctx = await
|
|
74
|
-
return ctx.map((ctx2) =>
|
|
94
|
+
startTransaction: async (...args) => {
|
|
95
|
+
const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args);
|
|
96
|
+
return ctx.map((ctx2) => bindTransaction(errorRegistry, ctx2));
|
|
75
97
|
}
|
|
76
98
|
};
|
|
77
99
|
if (adapter.getConnectionInfo) {
|
|
@@ -79,19 +101,6 @@ var bindAdapter = (adapter) => {
|
|
|
79
101
|
}
|
|
80
102
|
return boundAdapter;
|
|
81
103
|
};
|
|
82
|
-
var bindTransactionContext = (errorRegistry, ctx) => {
|
|
83
|
-
const startTransaction = wrapAsync(errorRegistry, ctx.startTransaction.bind(ctx));
|
|
84
|
-
return {
|
|
85
|
-
adapterName: ctx.adapterName,
|
|
86
|
-
provider: ctx.provider,
|
|
87
|
-
queryRaw: wrapAsync(errorRegistry, ctx.queryRaw.bind(ctx)),
|
|
88
|
-
executeRaw: wrapAsync(errorRegistry, ctx.executeRaw.bind(ctx)),
|
|
89
|
-
startTransaction: async (...args) => {
|
|
90
|
-
const result = await startTransaction(...args);
|
|
91
|
-
return result.map((tx) => bindTransaction(errorRegistry, tx));
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
104
|
var bindTransaction = (errorRegistry, transaction) => {
|
|
96
105
|
return {
|
|
97
106
|
adapterName: transaction.adapterName,
|
|
@@ -171,11 +180,52 @@ var ColumnTypeEnum = {
|
|
|
171
180
|
|
|
172
181
|
// src/debug.ts
|
|
173
182
|
import { Debug } from "@prisma/debug";
|
|
183
|
+
|
|
184
|
+
// src/mock.ts
|
|
185
|
+
var mockAdapterErrors = {
|
|
186
|
+
queryRaw: new Error("Not implemented: queryRaw"),
|
|
187
|
+
executeRaw: new Error("Not implemented: executeRaw"),
|
|
188
|
+
startTransaction: new Error("Not implemented: startTransaction"),
|
|
189
|
+
executeScript: new Error("Not implemented: executeScript"),
|
|
190
|
+
dispose: new Error("Not implemented: dispose")
|
|
191
|
+
};
|
|
192
|
+
function mockAdapter(provider) {
|
|
193
|
+
return {
|
|
194
|
+
provider,
|
|
195
|
+
adapterName: "@prisma/adapter-mock",
|
|
196
|
+
queryRaw: () => Promise.reject(mockAdapterErrors.queryRaw),
|
|
197
|
+
executeRaw: () => Promise.reject(mockAdapterErrors.executeRaw),
|
|
198
|
+
startTransaction: () => Promise.reject(mockAdapterErrors.startTransaction),
|
|
199
|
+
executeScript: () => Promise.reject(mockAdapterErrors.executeScript),
|
|
200
|
+
dispose: () => Promise.reject(mockAdapterErrors.dispose)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function mockAdapterFactory(provider) {
|
|
204
|
+
return {
|
|
205
|
+
provider,
|
|
206
|
+
adapterName: "@prisma/adapter-mock",
|
|
207
|
+
connect: () => Promise.resolve(mockAdapter(provider))
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function mockMigrationAwareAdapterFactory(provider) {
|
|
211
|
+
return {
|
|
212
|
+
provider,
|
|
213
|
+
adapterName: "@prisma/adapter-mock",
|
|
214
|
+
connect: () => Promise.resolve(mockAdapter(provider)),
|
|
215
|
+
connectToShadowDb: () => Promise.resolve(mockAdapter(provider))
|
|
216
|
+
};
|
|
217
|
+
}
|
|
174
218
|
export {
|
|
175
219
|
ColumnTypeEnum,
|
|
176
220
|
Debug,
|
|
177
221
|
DriverAdapterError,
|
|
178
222
|
bindAdapter,
|
|
223
|
+
bindMigrationAwareSqlAdapterFactory,
|
|
224
|
+
bindSqlAdapterFactory,
|
|
179
225
|
err,
|
|
226
|
+
mockAdapter,
|
|
227
|
+
mockAdapterErrors,
|
|
228
|
+
mockAdapterFactory,
|
|
229
|
+
mockMigrationAwareAdapterFactory,
|
|
180
230
|
ok
|
|
181
231
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/driver-adapter-utils",
|
|
3
|
-
"version": "6.6.0-dev.
|
|
3
|
+
"version": "6.6.0-dev.101",
|
|
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.6.0-dev.
|
|
34
|
+
"@prisma/debug": "6.6.0-dev.101"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"dev": "DEV=true tsx helpers/build.ts",
|