@prisma/adapter-planetscale 5.20.0-dev.12 → 5.20.0-dev.14
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +32 -21
- package/dist/index.mjs +32 -21
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -5,9 +5,9 @@ import type { Query } from '@prisma/driver-adapter-utils';
|
|
|
5
5
|
import type { Queryable } from '@prisma/driver-adapter-utils';
|
|
6
6
|
import type { Result } from '@prisma/driver-adapter-utils';
|
|
7
7
|
import type { ResultSet } from '@prisma/driver-adapter-utils';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransactionContext } from '@prisma/driver-adapter-utils';
|
|
9
9
|
|
|
10
|
-
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction> implements Queryable {
|
|
10
|
+
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements Queryable {
|
|
11
11
|
protected client: ClientT;
|
|
12
12
|
readonly provider = "mysql";
|
|
13
13
|
readonly adapterName: string;
|
|
@@ -33,7 +33,7 @@ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetSc
|
|
|
33
33
|
export declare class PrismaPlanetScale extends PlanetScaleQueryable<planetScale.Client> implements DriverAdapter {
|
|
34
34
|
constructor(client: planetScale.Client);
|
|
35
35
|
getConnectionInfo(): Result<ConnectionInfo>;
|
|
36
|
-
|
|
36
|
+
transactionContext(): Promise<Result<TransactionContext>>;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type { Query } from '@prisma/driver-adapter-utils';
|
|
|
5
5
|
import type { Queryable } from '@prisma/driver-adapter-utils';
|
|
6
6
|
import type { Result } from '@prisma/driver-adapter-utils';
|
|
7
7
|
import type { ResultSet } from '@prisma/driver-adapter-utils';
|
|
8
|
-
import type {
|
|
8
|
+
import type { TransactionContext } from '@prisma/driver-adapter-utils';
|
|
9
9
|
|
|
10
|
-
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction> implements Queryable {
|
|
10
|
+
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements Queryable {
|
|
11
11
|
protected client: ClientT;
|
|
12
12
|
readonly provider = "mysql";
|
|
13
13
|
readonly adapterName: string;
|
|
@@ -33,7 +33,7 @@ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetSc
|
|
|
33
33
|
export declare class PrismaPlanetScale extends PlanetScaleQueryable<planetScale.Client> implements DriverAdapter {
|
|
34
34
|
constructor(client: planetScale.Client);
|
|
35
35
|
getConnectionInfo(): Result<ConnectionInfo>;
|
|
36
|
-
|
|
36
|
+
transactionContext(): Promise<Result<TransactionContext>>;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -216,40 +216,27 @@ var PlanetScaleTransaction = class extends PlanetScaleQueryable {
|
|
|
216
216
|
async commit() {
|
|
217
217
|
debug(`[js::commit]`);
|
|
218
218
|
this.txDeferred.resolve();
|
|
219
|
-
return
|
|
219
|
+
return (0, import_driver_adapter_utils2.ok)(await this.txResultPromise);
|
|
220
220
|
}
|
|
221
221
|
async rollback() {
|
|
222
222
|
debug(`[js::rollback]`);
|
|
223
223
|
this.txDeferred.reject(new RollbackError());
|
|
224
|
-
return
|
|
224
|
+
return (0, import_driver_adapter_utils2.ok)(await this.txResultPromise);
|
|
225
225
|
}
|
|
226
226
|
};
|
|
227
|
-
var
|
|
228
|
-
constructor(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
import { Client } from '@planetscale/database'
|
|
232
|
-
const client = new Client({ url })
|
|
233
|
-
const adapter = new PrismaPlanetScale(client)
|
|
234
|
-
`);
|
|
235
|
-
}
|
|
236
|
-
super(client);
|
|
237
|
-
}
|
|
238
|
-
getConnectionInfo() {
|
|
239
|
-
const url = this.client.connection()["url"];
|
|
240
|
-
const dbName = new URL(url).pathname.slice(1);
|
|
241
|
-
return (0, import_driver_adapter_utils2.ok)({
|
|
242
|
-
schemaName: dbName
|
|
243
|
-
});
|
|
227
|
+
var PlanetScaleTransactionContext = class extends PlanetScaleQueryable {
|
|
228
|
+
constructor(conn) {
|
|
229
|
+
super(conn);
|
|
230
|
+
this.conn = conn;
|
|
244
231
|
}
|
|
245
232
|
async startTransaction() {
|
|
246
233
|
const options = {
|
|
247
234
|
usePhantomQuery: true
|
|
248
235
|
};
|
|
249
236
|
const tag = "[js::startTransaction]";
|
|
250
|
-
debug(
|
|
237
|
+
debug("%s options: %O", tag, options);
|
|
251
238
|
return new Promise((resolve, reject) => {
|
|
252
|
-
const txResultPromise = this.
|
|
239
|
+
const txResultPromise = this.conn.transaction(async (tx) => {
|
|
253
240
|
const [txDeferred, deferredPromise] = createDeferred();
|
|
254
241
|
const txWrapper = new PlanetScaleTransaction(tx, options, txDeferred, txResultPromise);
|
|
255
242
|
resolve((0, import_driver_adapter_utils2.ok)(txWrapper));
|
|
@@ -263,6 +250,30 @@ const adapter = new PrismaPlanetScale(client)
|
|
|
263
250
|
});
|
|
264
251
|
}
|
|
265
252
|
};
|
|
253
|
+
var PrismaPlanetScale = class extends PlanetScaleQueryable {
|
|
254
|
+
constructor(client) {
|
|
255
|
+
if (!(client instanceof planetScale.Client)) {
|
|
256
|
+
throw new TypeError(`PrismaPlanetScale must be initialized with an instance of Client:
|
|
257
|
+
import { Client } from '@planetscale/database'
|
|
258
|
+
const client = new Client({ url })
|
|
259
|
+
const adapter = new PrismaPlanetScale(client)
|
|
260
|
+
`);
|
|
261
|
+
}
|
|
262
|
+
super(client);
|
|
263
|
+
}
|
|
264
|
+
getConnectionInfo() {
|
|
265
|
+
const url = this.client.connection()["url"];
|
|
266
|
+
const dbName = new URL(url).pathname.slice(1);
|
|
267
|
+
return (0, import_driver_adapter_utils2.ok)({
|
|
268
|
+
schemaName: dbName
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async transactionContext() {
|
|
272
|
+
const conn = this.client.connection();
|
|
273
|
+
const ctx = new PlanetScaleTransactionContext(conn);
|
|
274
|
+
return (0, import_driver_adapter_utils2.ok)(ctx);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
266
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
267
278
|
0 && (module.exports = {
|
|
268
279
|
PrismaPlanetScale
|
package/dist/index.mjs
CHANGED
|
@@ -180,40 +180,27 @@ var PlanetScaleTransaction = class extends PlanetScaleQueryable {
|
|
|
180
180
|
async commit() {
|
|
181
181
|
debug(`[js::commit]`);
|
|
182
182
|
this.txDeferred.resolve();
|
|
183
|
-
return
|
|
183
|
+
return ok(await this.txResultPromise);
|
|
184
184
|
}
|
|
185
185
|
async rollback() {
|
|
186
186
|
debug(`[js::rollback]`);
|
|
187
187
|
this.txDeferred.reject(new RollbackError());
|
|
188
|
-
return
|
|
188
|
+
return ok(await this.txResultPromise);
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
|
-
var
|
|
192
|
-
constructor(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
import { Client } from '@planetscale/database'
|
|
196
|
-
const client = new Client({ url })
|
|
197
|
-
const adapter = new PrismaPlanetScale(client)
|
|
198
|
-
`);
|
|
199
|
-
}
|
|
200
|
-
super(client);
|
|
201
|
-
}
|
|
202
|
-
getConnectionInfo() {
|
|
203
|
-
const url = this.client.connection()["url"];
|
|
204
|
-
const dbName = new URL(url).pathname.slice(1);
|
|
205
|
-
return ok({
|
|
206
|
-
schemaName: dbName
|
|
207
|
-
});
|
|
191
|
+
var PlanetScaleTransactionContext = class extends PlanetScaleQueryable {
|
|
192
|
+
constructor(conn) {
|
|
193
|
+
super(conn);
|
|
194
|
+
this.conn = conn;
|
|
208
195
|
}
|
|
209
196
|
async startTransaction() {
|
|
210
197
|
const options = {
|
|
211
198
|
usePhantomQuery: true
|
|
212
199
|
};
|
|
213
200
|
const tag = "[js::startTransaction]";
|
|
214
|
-
debug(
|
|
201
|
+
debug("%s options: %O", tag, options);
|
|
215
202
|
return new Promise((resolve, reject) => {
|
|
216
|
-
const txResultPromise = this.
|
|
203
|
+
const txResultPromise = this.conn.transaction(async (tx) => {
|
|
217
204
|
const [txDeferred, deferredPromise] = createDeferred();
|
|
218
205
|
const txWrapper = new PlanetScaleTransaction(tx, options, txDeferred, txResultPromise);
|
|
219
206
|
resolve(ok(txWrapper));
|
|
@@ -227,6 +214,30 @@ const adapter = new PrismaPlanetScale(client)
|
|
|
227
214
|
});
|
|
228
215
|
}
|
|
229
216
|
};
|
|
217
|
+
var PrismaPlanetScale = class extends PlanetScaleQueryable {
|
|
218
|
+
constructor(client) {
|
|
219
|
+
if (!(client instanceof planetScale.Client)) {
|
|
220
|
+
throw new TypeError(`PrismaPlanetScale must be initialized with an instance of Client:
|
|
221
|
+
import { Client } from '@planetscale/database'
|
|
222
|
+
const client = new Client({ url })
|
|
223
|
+
const adapter = new PrismaPlanetScale(client)
|
|
224
|
+
`);
|
|
225
|
+
}
|
|
226
|
+
super(client);
|
|
227
|
+
}
|
|
228
|
+
getConnectionInfo() {
|
|
229
|
+
const url = this.client.connection()["url"];
|
|
230
|
+
const dbName = new URL(url).pathname.slice(1);
|
|
231
|
+
return ok({
|
|
232
|
+
schemaName: dbName
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
async transactionContext() {
|
|
236
|
+
const conn = this.client.connection();
|
|
237
|
+
const ctx = new PlanetScaleTransactionContext(conn);
|
|
238
|
+
return ok(ctx);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
230
241
|
export {
|
|
231
242
|
PrismaPlanetScale
|
|
232
243
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-planetscale",
|
|
3
|
-
"version": "5.20.0-dev.
|
|
3
|
+
"version": "5.20.0-dev.14",
|
|
4
4
|
"description": "Prisma's driver adapter for \"@planetscale/database\"",
|
|
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/driver-adapter-utils": "5.20.0-dev.
|
|
34
|
+
"@prisma/driver-adapter-utils": "5.20.0-dev.14"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@planetscale/database": "1.18.0",
|