@prisma/adapter-planetscale 6.13.0-dev.2 → 6.13.0-dev.21

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 CHANGED
@@ -1,13 +1,53 @@
1
+ import type { ConnectionInfo } from '@prisma/driver-adapter-utils';
2
+ import type { IsolationLevel } from '@prisma/driver-adapter-utils';
1
3
  import * as planetScale from '@planetscale/database';
2
4
  import type { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
3
5
  import type { SqlDriverAdapterFactory } from '@prisma/driver-adapter-utils';
6
+ import type { SqlQuery } from '@prisma/driver-adapter-utils';
7
+ import type { SqlQueryable } from '@prisma/driver-adapter-utils';
8
+ import type { SqlResultSet } from '@prisma/driver-adapter-utils';
9
+ import type { Transaction } from '@prisma/driver-adapter-utils';
10
+ import type { TransactionOptions } from '@prisma/driver-adapter-utils';
11
+
12
+ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements SqlQueryable {
13
+ protected client: ClientT;
14
+ readonly provider = "mysql";
15
+ readonly adapterName: string;
16
+ constructor(client: ClientT);
17
+ /**
18
+ * Execute a query given as SQL, interpolating the given parameters.
19
+ */
20
+ queryRaw(query: SqlQuery): Promise<SqlResultSet>;
21
+ /**
22
+ * Execute a query given as SQL, interpolating the given parameters and
23
+ * returning the number of affected rows.
24
+ * Note: Queryable expects a u64, but napi.rs only supports u32.
25
+ */
26
+ executeRaw(query: SqlQuery): Promise<number>;
27
+ /**
28
+ * Run a query against the database, returning the result set.
29
+ * Should the query fail due to a connection error, the connection is
30
+ * marked as unhealthy.
31
+ */
32
+ protected performIO(query: SqlQuery): Promise<planetScale.ExecutedQuery>;
33
+ }
4
34
 
5
35
  export declare class PrismaPlanetScale implements SqlDriverAdapterFactory {
6
- private readonly config;
36
+ #private;
7
37
  readonly provider = "mysql";
8
38
  readonly adapterName: string;
9
- constructor(config: planetScale.Config);
10
- connect(): Promise<SqlDriverAdapter>;
39
+ constructor(arg: planetScale.Config | planetScale.Client);
40
+ connect(): Promise<PrismaPlanetScaleAdapter>;
41
+ }
42
+
43
+ declare class PrismaPlanetScaleAdapter extends PlanetScaleQueryable<planetScale.Client> implements SqlDriverAdapter {
44
+ constructor(client: planetScale.Client);
45
+ executeScript(_script: string): Promise<void>;
46
+ getConnectionInfo(): ConnectionInfo;
47
+ startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
48
+ startTransactionInner(conn: planetScale.Connection, options: TransactionOptions): Promise<Transaction>;
49
+ dispose(): Promise<void>;
50
+ underlyingDriver(): planetScale.Client;
11
51
  }
12
52
 
13
53
  export { }
package/dist/index.d.ts CHANGED
@@ -1,13 +1,53 @@
1
+ import type { ConnectionInfo } from '@prisma/driver-adapter-utils';
2
+ import type { IsolationLevel } from '@prisma/driver-adapter-utils';
1
3
  import * as planetScale from '@planetscale/database';
2
4
  import type { SqlDriverAdapter } from '@prisma/driver-adapter-utils';
3
5
  import type { SqlDriverAdapterFactory } from '@prisma/driver-adapter-utils';
6
+ import type { SqlQuery } from '@prisma/driver-adapter-utils';
7
+ import type { SqlQueryable } from '@prisma/driver-adapter-utils';
8
+ import type { SqlResultSet } from '@prisma/driver-adapter-utils';
9
+ import type { Transaction } from '@prisma/driver-adapter-utils';
10
+ import type { TransactionOptions } from '@prisma/driver-adapter-utils';
11
+
12
+ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements SqlQueryable {
13
+ protected client: ClientT;
14
+ readonly provider = "mysql";
15
+ readonly adapterName: string;
16
+ constructor(client: ClientT);
17
+ /**
18
+ * Execute a query given as SQL, interpolating the given parameters.
19
+ */
20
+ queryRaw(query: SqlQuery): Promise<SqlResultSet>;
21
+ /**
22
+ * Execute a query given as SQL, interpolating the given parameters and
23
+ * returning the number of affected rows.
24
+ * Note: Queryable expects a u64, but napi.rs only supports u32.
25
+ */
26
+ executeRaw(query: SqlQuery): Promise<number>;
27
+ /**
28
+ * Run a query against the database, returning the result set.
29
+ * Should the query fail due to a connection error, the connection is
30
+ * marked as unhealthy.
31
+ */
32
+ protected performIO(query: SqlQuery): Promise<planetScale.ExecutedQuery>;
33
+ }
4
34
 
5
35
  export declare class PrismaPlanetScale implements SqlDriverAdapterFactory {
6
- private readonly config;
36
+ #private;
7
37
  readonly provider = "mysql";
8
38
  readonly adapterName: string;
9
- constructor(config: planetScale.Config);
10
- connect(): Promise<SqlDriverAdapter>;
39
+ constructor(arg: planetScale.Config | planetScale.Client);
40
+ connect(): Promise<PrismaPlanetScaleAdapter>;
41
+ }
42
+
43
+ declare class PrismaPlanetScaleAdapter extends PlanetScaleQueryable<planetScale.Client> implements SqlDriverAdapter {
44
+ constructor(client: planetScale.Client);
45
+ executeScript(_script: string): Promise<void>;
46
+ getConnectionInfo(): ConnectionInfo;
47
+ startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction>;
48
+ startTransactionInner(conn: planetScale.Connection, options: TransactionOptions): Promise<Transaction>;
49
+ dispose(): Promise<void>;
50
+ underlyingDriver(): planetScale.Client;
11
51
  }
12
52
 
13
53
  export { }
package/dist/index.js CHANGED
@@ -338,7 +338,6 @@ function parseErrorMessage(error) {
338
338
  return void 0;
339
339
  }
340
340
  }
341
- var LOCK_TAG = Symbol();
342
341
  var PlanetScaleTransaction = class extends PlanetScaleQueryable {
343
342
  constructor(tx, options, txDeferred, txResultPromise) {
344
343
  super(tx);
@@ -349,9 +348,9 @@ var PlanetScaleTransaction = class extends PlanetScaleQueryable {
349
348
  // The PlanetScale connection objects are not meant to be used concurrently,
350
349
  // so we override the `performIO` method to synchronize access to it with a mutex.
351
350
  // See: https://github.com/mattrobenolt/ps-http-sim/issues/7
352
- [LOCK_TAG] = new import_async_mutex.Mutex();
351
+ #mutex = new import_async_mutex.Mutex();
353
352
  async performIO(query) {
354
- const release = await this[LOCK_TAG].acquire();
353
+ const release = await this.#mutex.acquire();
355
354
  try {
356
355
  return await super.performIO(query);
357
356
  } catch (e) {
@@ -416,15 +415,25 @@ var PrismaPlanetScaleAdapter = class extends PlanetScaleQueryable {
416
415
  }
417
416
  async dispose() {
418
417
  }
418
+ underlyingDriver() {
419
+ return this.client;
420
+ }
419
421
  };
420
422
  var PrismaPlanetScaleAdapterFactory = class {
421
- constructor(config) {
422
- this.config = config;
423
- }
424
423
  provider = "mysql";
425
424
  adapterName = name;
425
+ #config;
426
+ #client;
427
+ constructor(arg) {
428
+ if (arg instanceof planetScale.Client) {
429
+ this.#config = arg.config;
430
+ this.#client = arg;
431
+ } else {
432
+ this.#config = arg;
433
+ }
434
+ }
426
435
  async connect() {
427
- return new PrismaPlanetScaleAdapter(new planetScale.Client(this.config));
436
+ return new PrismaPlanetScaleAdapter(this.#client ?? new planetScale.Client(this.#config));
428
437
  }
429
438
  };
430
439
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.mjs CHANGED
@@ -302,7 +302,6 @@ function parseErrorMessage(error) {
302
302
  return void 0;
303
303
  }
304
304
  }
305
- var LOCK_TAG = Symbol();
306
305
  var PlanetScaleTransaction = class extends PlanetScaleQueryable {
307
306
  constructor(tx, options, txDeferred, txResultPromise) {
308
307
  super(tx);
@@ -313,9 +312,9 @@ var PlanetScaleTransaction = class extends PlanetScaleQueryable {
313
312
  // The PlanetScale connection objects are not meant to be used concurrently,
314
313
  // so we override the `performIO` method to synchronize access to it with a mutex.
315
314
  // See: https://github.com/mattrobenolt/ps-http-sim/issues/7
316
- [LOCK_TAG] = new Mutex();
315
+ #mutex = new Mutex();
317
316
  async performIO(query) {
318
- const release = await this[LOCK_TAG].acquire();
317
+ const release = await this.#mutex.acquire();
319
318
  try {
320
319
  return await super.performIO(query);
321
320
  } catch (e) {
@@ -380,15 +379,25 @@ var PrismaPlanetScaleAdapter = class extends PlanetScaleQueryable {
380
379
  }
381
380
  async dispose() {
382
381
  }
382
+ underlyingDriver() {
383
+ return this.client;
384
+ }
383
385
  };
384
386
  var PrismaPlanetScaleAdapterFactory = class {
385
- constructor(config) {
386
- this.config = config;
387
- }
388
387
  provider = "mysql";
389
388
  adapterName = name;
389
+ #config;
390
+ #client;
391
+ constructor(arg) {
392
+ if (arg instanceof planetScale.Client) {
393
+ this.#config = arg.config;
394
+ this.#client = arg;
395
+ } else {
396
+ this.#config = arg;
397
+ }
398
+ }
390
399
  async connect() {
391
- return new PrismaPlanetScaleAdapter(new planetScale.Client(this.config));
400
+ return new PrismaPlanetScaleAdapter(this.#client ?? new planetScale.Client(this.#config));
392
401
  }
393
402
  };
394
403
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-planetscale",
3
- "version": "6.13.0-dev.2",
3
+ "version": "6.13.0-dev.21",
4
4
  "description": "Prisma's driver adapter for \"@planetscale/database\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "async-mutex": "0.5.0",
35
35
  "@planetscale/database": "^1.15.0",
36
- "@prisma/driver-adapter-utils": "6.13.0-dev.2"
36
+ "@prisma/driver-adapter-utils": "6.13.0-dev.21"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@swc/core": "1.11.5",