@prisma/driver-adapter-utils 6.6.0-dev.8 → 6.6.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 +36 -32
- package/dist/index.d.ts +36 -32
- package/dist/index.js +21 -25
- package/dist/index.mjs +20 -27
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -16,7 +16,9 @@ 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 bindSqlAdapterFactory: (adapterFactory: SqlDriverAdapterFactory) => ErrorCapturingSqlDriverAdapterFactory;
|
|
20
22
|
|
|
21
23
|
export declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
|
|
22
24
|
|
|
@@ -62,23 +64,23 @@ export declare type ConnectionInfo = {
|
|
|
62
64
|
|
|
63
65
|
export { Debug }
|
|
64
66
|
|
|
67
|
+
export declare class DriverAdapterError extends Error {
|
|
68
|
+
name: string;
|
|
69
|
+
cause: Error_2;
|
|
70
|
+
constructor(payload: Error_2);
|
|
71
|
+
}
|
|
72
|
+
|
|
65
73
|
/**
|
|
66
|
-
* A generic driver adapter that allows the user to
|
|
67
|
-
*
|
|
74
|
+
* A generic driver adapter factory that allows the user to instantiate a
|
|
75
|
+
* driver adapter. The query and result types are specific to the adapter.
|
|
68
76
|
*/
|
|
69
|
-
declare interface
|
|
77
|
+
export declare interface DriverAdapterFactory<Query, Result> extends AdapterInfo {
|
|
70
78
|
/**
|
|
71
|
-
*
|
|
79
|
+
* Instantiate a driver adapter.
|
|
72
80
|
*/
|
|
73
81
|
connect(): Promise<Queryable<Query, Result>>;
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
export declare class DriverAdapterError extends Error {
|
|
77
|
-
name: string;
|
|
78
|
-
cause: Error_2;
|
|
79
|
-
constructor(payload: Error_2);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
84
|
export declare function err<T>(error: Error_2): Result<T>;
|
|
83
85
|
|
|
84
86
|
declare type Error_2 = {
|
|
@@ -87,6 +89,9 @@ declare type Error_2 = {
|
|
|
87
89
|
} | {
|
|
88
90
|
kind: 'UnsupportedNativeDataType';
|
|
89
91
|
type: string;
|
|
92
|
+
} | {
|
|
93
|
+
kind: 'InvalidIsolationLevel';
|
|
94
|
+
level: string;
|
|
90
95
|
} | {
|
|
91
96
|
kind: 'postgres';
|
|
92
97
|
code: string;
|
|
@@ -116,18 +121,18 @@ declare type ErrorCapturingInterface<T> = {
|
|
|
116
121
|
[K in keyof T]: ErrorCapturingFunction<T[K]>;
|
|
117
122
|
};
|
|
118
123
|
|
|
119
|
-
declare interface
|
|
124
|
+
export declare interface ErrorCapturingSqlDriverAdapter extends ErrorCapturingInterface<SqlDriverAdapter> {
|
|
125
|
+
readonly errorRegistry: ErrorRegistry;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare interface ErrorCapturingSqlDriverAdapterFactory extends ErrorCapturingInterface<SqlDriverAdapterFactory> {
|
|
120
129
|
readonly errorRegistry: ErrorRegistry;
|
|
121
130
|
}
|
|
122
|
-
export { ErrorCapturingSqlConnection as ErrorCapturingDriverAdapter }
|
|
123
|
-
export { ErrorCapturingSqlConnection }
|
|
124
131
|
|
|
125
132
|
export declare type ErrorCapturingSqlQueryable = ErrorCapturingInterface<SqlQueryable>;
|
|
126
133
|
|
|
127
134
|
export declare type ErrorCapturingTransaction = ErrorCapturingInterface<Transaction>;
|
|
128
135
|
|
|
129
|
-
export declare type ErrorCapturingTransactionContext = ErrorCapturingInterface<TransactionContext>;
|
|
130
|
-
|
|
131
136
|
export declare type ErrorRecord = {
|
|
132
137
|
error: unknown;
|
|
133
138
|
};
|
|
@@ -136,13 +141,21 @@ export declare interface ErrorRegistry {
|
|
|
136
141
|
consumeError(id: number): ErrorRecord | undefined;
|
|
137
142
|
}
|
|
138
143
|
|
|
144
|
+
declare class ErrorRegistryInternal implements ErrorRegistry {
|
|
145
|
+
private registeredErrors;
|
|
146
|
+
consumeError(id: number): ErrorRecord | undefined;
|
|
147
|
+
registerNewError(error: unknown): number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
|
|
151
|
+
|
|
139
152
|
declare const officialPrismaAdapters: readonly ["@prisma/adapter-planetscale", "@prisma/adapter-neon", "@prisma/adapter-libsql", "@prisma/adapter-d1", "@prisma/adapter-pg", "@prisma/adapter-pg-worker"];
|
|
140
153
|
|
|
141
154
|
export declare function ok<T>(value: T): Result<T>;
|
|
142
155
|
|
|
143
156
|
export declare type Provider = 'mysql' | 'postgres' | 'sqlite';
|
|
144
157
|
|
|
145
|
-
declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
158
|
+
export declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
146
159
|
/**
|
|
147
160
|
* Execute a query and return its result.
|
|
148
161
|
*/
|
|
@@ -164,7 +177,7 @@ export declare type Result<T> = {
|
|
|
164
177
|
readonly error: Error_2;
|
|
165
178
|
});
|
|
166
179
|
|
|
167
|
-
declare interface
|
|
180
|
+
export declare interface SqlDriverAdapter extends SqlQueryable {
|
|
168
181
|
/**
|
|
169
182
|
* Execute multiple SQL statements separated by semicolon.
|
|
170
183
|
*/
|
|
@@ -172,7 +185,7 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
172
185
|
/**
|
|
173
186
|
* Start new transaction.
|
|
174
187
|
*/
|
|
175
|
-
|
|
188
|
+
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
176
189
|
/**
|
|
177
190
|
* Optional method that returns extra connection info
|
|
178
191
|
*/
|
|
@@ -182,19 +195,17 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
182
195
|
*/
|
|
183
196
|
dispose(): Promise<void>;
|
|
184
197
|
}
|
|
185
|
-
export { SqlConnection as DriverAdapter }
|
|
186
|
-
export { SqlConnection }
|
|
187
198
|
|
|
188
|
-
declare interface
|
|
189
|
-
connect(): Promise<
|
|
199
|
+
export declare interface SqlDriverAdapterFactory extends DriverAdapterFactory<SqlQuery, SqlResultSet> {
|
|
200
|
+
connect(): Promise<SqlDriverAdapter>;
|
|
190
201
|
}
|
|
191
202
|
|
|
192
203
|
/**
|
|
193
204
|
* An SQL migration adapter that is aware of the notion of a shadow database
|
|
194
205
|
* and can create a connection to it.
|
|
195
206
|
*/
|
|
196
|
-
export declare interface
|
|
197
|
-
connectToShadowDb(): Promise<
|
|
207
|
+
export declare interface SqlMigrationAwareDriverAdapterFactory extends SqlDriverAdapterFactory {
|
|
208
|
+
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
198
209
|
}
|
|
199
210
|
|
|
200
211
|
export declare type SqlQuery = {
|
|
@@ -243,13 +254,6 @@ export declare interface Transaction extends AdapterInfo, SqlQueryable {
|
|
|
243
254
|
rollback(): Promise<void>;
|
|
244
255
|
}
|
|
245
256
|
|
|
246
|
-
export declare interface TransactionContext extends AdapterInfo, SqlQueryable {
|
|
247
|
-
/**
|
|
248
|
-
* Start new transaction.
|
|
249
|
-
*/
|
|
250
|
-
startTransaction(): Promise<Transaction>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
257
|
export declare type TransactionOptions = {
|
|
254
258
|
usePhantomQuery: boolean;
|
|
255
259
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ 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 bindSqlAdapterFactory: (adapterFactory: SqlDriverAdapterFactory) => ErrorCapturingSqlDriverAdapterFactory;
|
|
20
22
|
|
|
21
23
|
export declare type ColumnType = (typeof ColumnTypeEnum)[keyof typeof ColumnTypeEnum];
|
|
22
24
|
|
|
@@ -62,23 +64,23 @@ export declare type ConnectionInfo = {
|
|
|
62
64
|
|
|
63
65
|
export { Debug }
|
|
64
66
|
|
|
67
|
+
export declare class DriverAdapterError extends Error {
|
|
68
|
+
name: string;
|
|
69
|
+
cause: Error_2;
|
|
70
|
+
constructor(payload: Error_2);
|
|
71
|
+
}
|
|
72
|
+
|
|
65
73
|
/**
|
|
66
|
-
* A generic driver adapter that allows the user to
|
|
67
|
-
*
|
|
74
|
+
* A generic driver adapter factory that allows the user to instantiate a
|
|
75
|
+
* driver adapter. The query and result types are specific to the adapter.
|
|
68
76
|
*/
|
|
69
|
-
declare interface
|
|
77
|
+
export declare interface DriverAdapterFactory<Query, Result> extends AdapterInfo {
|
|
70
78
|
/**
|
|
71
|
-
*
|
|
79
|
+
* Instantiate a driver adapter.
|
|
72
80
|
*/
|
|
73
81
|
connect(): Promise<Queryable<Query, Result>>;
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
export declare class DriverAdapterError extends Error {
|
|
77
|
-
name: string;
|
|
78
|
-
cause: Error_2;
|
|
79
|
-
constructor(payload: Error_2);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
84
|
export declare function err<T>(error: Error_2): Result<T>;
|
|
83
85
|
|
|
84
86
|
declare type Error_2 = {
|
|
@@ -87,6 +89,9 @@ declare type Error_2 = {
|
|
|
87
89
|
} | {
|
|
88
90
|
kind: 'UnsupportedNativeDataType';
|
|
89
91
|
type: string;
|
|
92
|
+
} | {
|
|
93
|
+
kind: 'InvalidIsolationLevel';
|
|
94
|
+
level: string;
|
|
90
95
|
} | {
|
|
91
96
|
kind: 'postgres';
|
|
92
97
|
code: string;
|
|
@@ -116,18 +121,18 @@ declare type ErrorCapturingInterface<T> = {
|
|
|
116
121
|
[K in keyof T]: ErrorCapturingFunction<T[K]>;
|
|
117
122
|
};
|
|
118
123
|
|
|
119
|
-
declare interface
|
|
124
|
+
export declare interface ErrorCapturingSqlDriverAdapter extends ErrorCapturingInterface<SqlDriverAdapter> {
|
|
125
|
+
readonly errorRegistry: ErrorRegistry;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare interface ErrorCapturingSqlDriverAdapterFactory extends ErrorCapturingInterface<SqlDriverAdapterFactory> {
|
|
120
129
|
readonly errorRegistry: ErrorRegistry;
|
|
121
130
|
}
|
|
122
|
-
export { ErrorCapturingSqlConnection as ErrorCapturingDriverAdapter }
|
|
123
|
-
export { ErrorCapturingSqlConnection }
|
|
124
131
|
|
|
125
132
|
export declare type ErrorCapturingSqlQueryable = ErrorCapturingInterface<SqlQueryable>;
|
|
126
133
|
|
|
127
134
|
export declare type ErrorCapturingTransaction = ErrorCapturingInterface<Transaction>;
|
|
128
135
|
|
|
129
|
-
export declare type ErrorCapturingTransactionContext = ErrorCapturingInterface<TransactionContext>;
|
|
130
|
-
|
|
131
136
|
export declare type ErrorRecord = {
|
|
132
137
|
error: unknown;
|
|
133
138
|
};
|
|
@@ -136,13 +141,21 @@ export declare interface ErrorRegistry {
|
|
|
136
141
|
consumeError(id: number): ErrorRecord | undefined;
|
|
137
142
|
}
|
|
138
143
|
|
|
144
|
+
declare class ErrorRegistryInternal implements ErrorRegistry {
|
|
145
|
+
private registeredErrors;
|
|
146
|
+
consumeError(id: number): ErrorRecord | undefined;
|
|
147
|
+
registerNewError(error: unknown): number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export declare type IsolationLevel = 'READ UNCOMMITTED' | 'READ COMMITTED' | 'REPEATABLE READ' | 'SNAPSHOT' | 'SERIALIZABLE';
|
|
151
|
+
|
|
139
152
|
declare const officialPrismaAdapters: readonly ["@prisma/adapter-planetscale", "@prisma/adapter-neon", "@prisma/adapter-libsql", "@prisma/adapter-d1", "@prisma/adapter-pg", "@prisma/adapter-pg-worker"];
|
|
140
153
|
|
|
141
154
|
export declare function ok<T>(value: T): Result<T>;
|
|
142
155
|
|
|
143
156
|
export declare type Provider = 'mysql' | 'postgres' | 'sqlite';
|
|
144
157
|
|
|
145
|
-
declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
158
|
+
export declare interface Queryable<Query, Result> extends AdapterInfo {
|
|
146
159
|
/**
|
|
147
160
|
* Execute a query and return its result.
|
|
148
161
|
*/
|
|
@@ -164,7 +177,7 @@ export declare type Result<T> = {
|
|
|
164
177
|
readonly error: Error_2;
|
|
165
178
|
});
|
|
166
179
|
|
|
167
|
-
declare interface
|
|
180
|
+
export declare interface SqlDriverAdapter extends SqlQueryable {
|
|
168
181
|
/**
|
|
169
182
|
* Execute multiple SQL statements separated by semicolon.
|
|
170
183
|
*/
|
|
@@ -172,7 +185,7 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
172
185
|
/**
|
|
173
186
|
* Start new transaction.
|
|
174
187
|
*/
|
|
175
|
-
|
|
188
|
+
startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
|
|
176
189
|
/**
|
|
177
190
|
* Optional method that returns extra connection info
|
|
178
191
|
*/
|
|
@@ -182,19 +195,17 @@ declare interface SqlConnection extends SqlQueryable {
|
|
|
182
195
|
*/
|
|
183
196
|
dispose(): Promise<void>;
|
|
184
197
|
}
|
|
185
|
-
export { SqlConnection as DriverAdapter }
|
|
186
|
-
export { SqlConnection }
|
|
187
198
|
|
|
188
|
-
declare interface
|
|
189
|
-
connect(): Promise<
|
|
199
|
+
export declare interface SqlDriverAdapterFactory extends DriverAdapterFactory<SqlQuery, SqlResultSet> {
|
|
200
|
+
connect(): Promise<SqlDriverAdapter>;
|
|
190
201
|
}
|
|
191
202
|
|
|
192
203
|
/**
|
|
193
204
|
* An SQL migration adapter that is aware of the notion of a shadow database
|
|
194
205
|
* and can create a connection to it.
|
|
195
206
|
*/
|
|
196
|
-
export declare interface
|
|
197
|
-
connectToShadowDb(): Promise<
|
|
207
|
+
export declare interface SqlMigrationAwareDriverAdapterFactory extends SqlDriverAdapterFactory {
|
|
208
|
+
connectToShadowDb(): Promise<SqlDriverAdapter>;
|
|
198
209
|
}
|
|
199
210
|
|
|
200
211
|
export declare type SqlQuery = {
|
|
@@ -243,13 +254,6 @@ export declare interface Transaction extends AdapterInfo, SqlQueryable {
|
|
|
243
254
|
rollback(): Promise<void>;
|
|
244
255
|
}
|
|
245
256
|
|
|
246
|
-
export declare interface TransactionContext extends AdapterInfo, SqlQueryable {
|
|
247
|
-
/**
|
|
248
|
-
* Start new transaction.
|
|
249
|
-
*/
|
|
250
|
-
startTransaction(): Promise<Transaction>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
257
|
export declare type TransactionOptions = {
|
|
254
258
|
usePhantomQuery: boolean;
|
|
255
259
|
};
|
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,6 +24,7 @@ __export(index_exports, {
|
|
|
26
24
|
Debug: () => import_debug.Debug,
|
|
27
25
|
DriverAdapterError: () => DriverAdapterError,
|
|
28
26
|
bindAdapter: () => bindAdapter,
|
|
27
|
+
bindSqlAdapterFactory: () => bindSqlAdapterFactory,
|
|
29
28
|
err: () => err,
|
|
30
29
|
ok: () => ok
|
|
31
30
|
});
|
|
@@ -33,10 +32,10 @@ module.exports = __toCommonJS(index_exports);
|
|
|
33
32
|
|
|
34
33
|
// src/error.ts
|
|
35
34
|
var DriverAdapterError = class extends Error {
|
|
35
|
+
name = "DriverAdapterError";
|
|
36
|
+
cause;
|
|
36
37
|
constructor(payload) {
|
|
37
38
|
super(typeof payload["message"] === "string" ? payload["message"] : payload.kind);
|
|
38
|
-
__publicField(this, "name", "DriverAdapterError");
|
|
39
|
-
__publicField(this, "cause");
|
|
40
39
|
this.cause = payload;
|
|
41
40
|
}
|
|
42
41
|
};
|
|
@@ -72,9 +71,7 @@ function err(error) {
|
|
|
72
71
|
|
|
73
72
|
// src/binder.ts
|
|
74
73
|
var ErrorRegistryInternal = class {
|
|
75
|
-
|
|
76
|
-
__publicField(this, "registeredErrors", []);
|
|
77
|
-
}
|
|
74
|
+
registeredErrors = [];
|
|
78
75
|
consumeError(id) {
|
|
79
76
|
return this.registeredErrors[id];
|
|
80
77
|
}
|
|
@@ -87,9 +84,20 @@ var ErrorRegistryInternal = class {
|
|
|
87
84
|
return i;
|
|
88
85
|
}
|
|
89
86
|
};
|
|
90
|
-
var
|
|
87
|
+
var bindSqlAdapterFactory = (adapterFactory) => {
|
|
91
88
|
const errorRegistry = new ErrorRegistryInternal();
|
|
92
|
-
const
|
|
89
|
+
const boundFactory = {
|
|
90
|
+
adapterName: adapterFactory.adapterName,
|
|
91
|
+
provider: adapterFactory.provider,
|
|
92
|
+
errorRegistry,
|
|
93
|
+
connect: async (...args) => {
|
|
94
|
+
const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args);
|
|
95
|
+
return ctx.map((ctx2) => bindAdapter(ctx2, errorRegistry));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return boundFactory;
|
|
99
|
+
};
|
|
100
|
+
var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
|
|
93
101
|
const boundAdapter = {
|
|
94
102
|
adapterName: adapter.adapterName,
|
|
95
103
|
errorRegistry,
|
|
@@ -98,9 +106,9 @@ var bindAdapter = (adapter) => {
|
|
|
98
106
|
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
99
107
|
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
100
108
|
provider: adapter.provider,
|
|
101
|
-
|
|
102
|
-
const ctx = await
|
|
103
|
-
return ctx.map((ctx2) =>
|
|
109
|
+
startTransaction: async (...args) => {
|
|
110
|
+
const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args);
|
|
111
|
+
return ctx.map((ctx2) => bindTransaction(errorRegistry, ctx2));
|
|
104
112
|
}
|
|
105
113
|
};
|
|
106
114
|
if (adapter.getConnectionInfo) {
|
|
@@ -108,19 +116,6 @@ var bindAdapter = (adapter) => {
|
|
|
108
116
|
}
|
|
109
117
|
return boundAdapter;
|
|
110
118
|
};
|
|
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
119
|
var bindTransaction = (errorRegistry, transaction) => {
|
|
125
120
|
return {
|
|
126
121
|
adapterName: transaction.adapterName,
|
|
@@ -206,6 +201,7 @@ var import_debug = require("@prisma/debug");
|
|
|
206
201
|
Debug,
|
|
207
202
|
DriverAdapterError,
|
|
208
203
|
bindAdapter,
|
|
204
|
+
bindSqlAdapterFactory,
|
|
209
205
|
err,
|
|
210
206
|
ok
|
|
211
207
|
});
|
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,20 @@ var ErrorRegistryInternal = class {
|
|
|
58
52
|
return i;
|
|
59
53
|
}
|
|
60
54
|
};
|
|
61
|
-
var
|
|
55
|
+
var bindSqlAdapterFactory = (adapterFactory) => {
|
|
62
56
|
const errorRegistry = new ErrorRegistryInternal();
|
|
63
|
-
const
|
|
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
|
+
};
|
|
66
|
+
return boundFactory;
|
|
67
|
+
};
|
|
68
|
+
var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal()) => {
|
|
64
69
|
const boundAdapter = {
|
|
65
70
|
adapterName: adapter.adapterName,
|
|
66
71
|
errorRegistry,
|
|
@@ -69,9 +74,9 @@ var bindAdapter = (adapter) => {
|
|
|
69
74
|
executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)),
|
|
70
75
|
dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)),
|
|
71
76
|
provider: adapter.provider,
|
|
72
|
-
|
|
73
|
-
const ctx = await
|
|
74
|
-
return ctx.map((ctx2) =>
|
|
77
|
+
startTransaction: async (...args) => {
|
|
78
|
+
const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args);
|
|
79
|
+
return ctx.map((ctx2) => bindTransaction(errorRegistry, ctx2));
|
|
75
80
|
}
|
|
76
81
|
};
|
|
77
82
|
if (adapter.getConnectionInfo) {
|
|
@@ -79,19 +84,6 @@ var bindAdapter = (adapter) => {
|
|
|
79
84
|
}
|
|
80
85
|
return boundAdapter;
|
|
81
86
|
};
|
|
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
87
|
var bindTransaction = (errorRegistry, transaction) => {
|
|
96
88
|
return {
|
|
97
89
|
adapterName: transaction.adapterName,
|
|
@@ -176,6 +168,7 @@ export {
|
|
|
176
168
|
Debug,
|
|
177
169
|
DriverAdapterError,
|
|
178
170
|
bindAdapter,
|
|
171
|
+
bindSqlAdapterFactory,
|
|
179
172
|
err,
|
|
180
173
|
ok
|
|
181
174
|
};
|
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.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.6.0-dev.
|
|
34
|
+
"@prisma/debug": "6.6.0-dev.80"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"dev": "DEV=true tsx helpers/build.ts",
|