@prisma/adapter-planetscale 6.5.0-dev.24 → 6.5.0-dev.25
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 +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +22 -19
- package/dist/index.mjs +23 -20
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ConnectionInfo } from '@prisma/driver-adapter-utils';
|
|
2
|
-
import type { DriverAdapter } from '@prisma/driver-adapter-utils';
|
|
3
2
|
import * as planetScale from '@planetscale/database';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
3
|
+
import type { SqlConnection } from '@prisma/driver-adapter-utils';
|
|
4
|
+
import type { SqlQuery } from '@prisma/driver-adapter-utils';
|
|
5
|
+
import type { SqlQueryable } from '@prisma/driver-adapter-utils';
|
|
6
|
+
import type { SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
8
7
|
import type { TransactionContext } from '@prisma/driver-adapter-utils';
|
|
9
8
|
|
|
10
|
-
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements
|
|
9
|
+
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements SqlQueryable {
|
|
11
10
|
protected client: ClientT;
|
|
12
11
|
readonly provider = "mysql";
|
|
13
12
|
readonly adapterName: string;
|
|
@@ -15,13 +14,13 @@ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetSc
|
|
|
15
14
|
/**
|
|
16
15
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
17
16
|
*/
|
|
18
|
-
queryRaw(query:
|
|
17
|
+
queryRaw(query: SqlQuery): Promise<SqlResultSet>;
|
|
19
18
|
/**
|
|
20
19
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
21
20
|
* returning the number of affected rows.
|
|
22
21
|
* Note: Queryable expects a u64, but napi.rs only supports u32.
|
|
23
22
|
*/
|
|
24
|
-
executeRaw(query:
|
|
23
|
+
executeRaw(query: SqlQuery): Promise<number>;
|
|
25
24
|
/**
|
|
26
25
|
* Run a query against the database, returning the result set.
|
|
27
26
|
* Should the query fail due to a connection error, the connection is
|
|
@@ -30,10 +29,12 @@ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetSc
|
|
|
30
29
|
private performIO;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export declare class PrismaPlanetScale extends PlanetScaleQueryable<planetScale.Client> implements
|
|
32
|
+
export declare class PrismaPlanetScale extends PlanetScaleQueryable<planetScale.Client> implements SqlConnection {
|
|
34
33
|
constructor(client: planetScale.Client);
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
executeScript(_script: string): Promise<void>;
|
|
35
|
+
getConnectionInfo(): ConnectionInfo;
|
|
36
|
+
transactionContext(): Promise<TransactionContext>;
|
|
37
|
+
dispose(): Promise<void>;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { ConnectionInfo } from '@prisma/driver-adapter-utils';
|
|
2
|
-
import type { DriverAdapter } from '@prisma/driver-adapter-utils';
|
|
3
2
|
import * as planetScale from '@planetscale/database';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
3
|
+
import type { SqlConnection } from '@prisma/driver-adapter-utils';
|
|
4
|
+
import type { SqlQuery } from '@prisma/driver-adapter-utils';
|
|
5
|
+
import type { SqlQueryable } from '@prisma/driver-adapter-utils';
|
|
6
|
+
import type { SqlResultSet } from '@prisma/driver-adapter-utils';
|
|
8
7
|
import type { TransactionContext } from '@prisma/driver-adapter-utils';
|
|
9
8
|
|
|
10
|
-
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements
|
|
9
|
+
declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetScale.Transaction | planetScale.Connection> implements SqlQueryable {
|
|
11
10
|
protected client: ClientT;
|
|
12
11
|
readonly provider = "mysql";
|
|
13
12
|
readonly adapterName: string;
|
|
@@ -15,13 +14,13 @@ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetSc
|
|
|
15
14
|
/**
|
|
16
15
|
* Execute a query given as SQL, interpolating the given parameters.
|
|
17
16
|
*/
|
|
18
|
-
queryRaw(query:
|
|
17
|
+
queryRaw(query: SqlQuery): Promise<SqlResultSet>;
|
|
19
18
|
/**
|
|
20
19
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
21
20
|
* returning the number of affected rows.
|
|
22
21
|
* Note: Queryable expects a u64, but napi.rs only supports u32.
|
|
23
22
|
*/
|
|
24
|
-
executeRaw(query:
|
|
23
|
+
executeRaw(query: SqlQuery): Promise<number>;
|
|
25
24
|
/**
|
|
26
25
|
* Run a query against the database, returning the result set.
|
|
27
26
|
* Should the query fail due to a connection error, the connection is
|
|
@@ -30,10 +29,12 @@ declare class PlanetScaleQueryable<ClientT extends planetScale.Client | planetSc
|
|
|
30
29
|
private performIO;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export declare class PrismaPlanetScale extends PlanetScaleQueryable<planetScale.Client> implements
|
|
32
|
+
export declare class PrismaPlanetScale extends PlanetScaleQueryable<planetScale.Client> implements SqlConnection {
|
|
34
33
|
constructor(client: planetScale.Client);
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
executeScript(_script: string): Promise<void>;
|
|
35
|
+
getConnectionInfo(): ConnectionInfo;
|
|
36
|
+
transactionContext(): Promise<TransactionContext>;
|
|
37
|
+
dispose(): Promise<void>;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -155,16 +155,14 @@ var PlanetScaleQueryable = class {
|
|
|
155
155
|
async queryRaw(query) {
|
|
156
156
|
const tag = "[js::query_raw]";
|
|
157
157
|
debug(`${tag} %O`, query);
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
});
|
|
158
|
+
const { fields, insertId: lastInsertId, rows } = await this.performIO(query);
|
|
159
|
+
const columns = fields.map((field) => field.name);
|
|
160
|
+
return {
|
|
161
|
+
columnNames: columns,
|
|
162
|
+
columnTypes: fields.map((field) => fieldToColumnType(field.type)),
|
|
163
|
+
rows,
|
|
164
|
+
lastInsertId
|
|
165
|
+
};
|
|
168
166
|
}
|
|
169
167
|
/**
|
|
170
168
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
@@ -174,7 +172,7 @@ var PlanetScaleQueryable = class {
|
|
|
174
172
|
async executeRaw(query) {
|
|
175
173
|
const tag = "[js::execute_raw]";
|
|
176
174
|
debug(`${tag} %O`, query);
|
|
177
|
-
return (await this.performIO(query)).
|
|
175
|
+
return (await this.performIO(query)).rowsAffected;
|
|
178
176
|
}
|
|
179
177
|
/**
|
|
180
178
|
* Run a query against the database, returning the result set.
|
|
@@ -188,13 +186,13 @@ var PlanetScaleQueryable = class {
|
|
|
188
186
|
as: "array",
|
|
189
187
|
cast
|
|
190
188
|
});
|
|
191
|
-
return
|
|
189
|
+
return result;
|
|
192
190
|
} catch (e) {
|
|
193
191
|
const error = e;
|
|
194
192
|
if (error.name === "DatabaseError") {
|
|
195
193
|
const parsed = parseErrorMessage(error.message);
|
|
196
194
|
if (parsed) {
|
|
197
|
-
|
|
195
|
+
throw new import_driver_adapter_utils2.DriverAdapterError({
|
|
198
196
|
kind: "mysql",
|
|
199
197
|
...parsed
|
|
200
198
|
});
|
|
@@ -230,12 +228,12 @@ var PlanetScaleTransaction = class extends PlanetScaleQueryable {
|
|
|
230
228
|
async commit() {
|
|
231
229
|
debug(`[js::commit]`);
|
|
232
230
|
this.txDeferred.resolve();
|
|
233
|
-
return
|
|
231
|
+
return await this.txResultPromise;
|
|
234
232
|
}
|
|
235
233
|
async rollback() {
|
|
236
234
|
debug(`[js::rollback]`);
|
|
237
235
|
this.txDeferred.reject(new RollbackError());
|
|
238
|
-
return
|
|
236
|
+
return await this.txResultPromise;
|
|
239
237
|
}
|
|
240
238
|
};
|
|
241
239
|
var PlanetScaleTransactionContext = class extends PlanetScaleQueryable {
|
|
@@ -253,7 +251,7 @@ var PlanetScaleTransactionContext = class extends PlanetScaleQueryable {
|
|
|
253
251
|
const txResultPromise = this.conn.transaction(async (tx) => {
|
|
254
252
|
const [txDeferred, deferredPromise] = createDeferred();
|
|
255
253
|
const txWrapper = new PlanetScaleTransaction(tx, options, txDeferred, txResultPromise);
|
|
256
|
-
resolve(
|
|
254
|
+
resolve(txWrapper);
|
|
257
255
|
return deferredPromise;
|
|
258
256
|
}).catch((error) => {
|
|
259
257
|
if (!(error instanceof RollbackError)) {
|
|
@@ -275,17 +273,22 @@ const adapter = new PrismaPlanetScale(client)
|
|
|
275
273
|
}
|
|
276
274
|
super(client);
|
|
277
275
|
}
|
|
276
|
+
executeScript(_script) {
|
|
277
|
+
throw new Error("Not implemented yet");
|
|
278
|
+
}
|
|
278
279
|
getConnectionInfo() {
|
|
279
280
|
const url = this.client.connection()["url"];
|
|
280
281
|
const dbName = new URL(url).pathname.slice(1);
|
|
281
|
-
return
|
|
282
|
+
return {
|
|
282
283
|
schemaName: dbName
|
|
283
|
-
}
|
|
284
|
+
};
|
|
284
285
|
}
|
|
285
286
|
async transactionContext() {
|
|
286
287
|
const conn = this.client.connection();
|
|
287
288
|
const ctx = new PlanetScaleTransactionContext(conn);
|
|
288
|
-
return
|
|
289
|
+
return ctx;
|
|
290
|
+
}
|
|
291
|
+
async dispose() {
|
|
289
292
|
}
|
|
290
293
|
};
|
|
291
294
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/planetscale.ts
|
|
2
2
|
import * as planetScale from "@planetscale/database";
|
|
3
|
-
import { Debug,
|
|
3
|
+
import { Debug, DriverAdapterError } from "@prisma/driver-adapter-utils";
|
|
4
4
|
|
|
5
5
|
// package.json
|
|
6
6
|
var name = "@prisma/adapter-planetscale";
|
|
@@ -119,16 +119,14 @@ var PlanetScaleQueryable = class {
|
|
|
119
119
|
async queryRaw(query) {
|
|
120
120
|
const tag = "[js::query_raw]";
|
|
121
121
|
debug(`${tag} %O`, query);
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
};
|
|
131
|
-
});
|
|
122
|
+
const { fields, insertId: lastInsertId, rows } = await this.performIO(query);
|
|
123
|
+
const columns = fields.map((field) => field.name);
|
|
124
|
+
return {
|
|
125
|
+
columnNames: columns,
|
|
126
|
+
columnTypes: fields.map((field) => fieldToColumnType(field.type)),
|
|
127
|
+
rows,
|
|
128
|
+
lastInsertId
|
|
129
|
+
};
|
|
132
130
|
}
|
|
133
131
|
/**
|
|
134
132
|
* Execute a query given as SQL, interpolating the given parameters and
|
|
@@ -138,7 +136,7 @@ var PlanetScaleQueryable = class {
|
|
|
138
136
|
async executeRaw(query) {
|
|
139
137
|
const tag = "[js::execute_raw]";
|
|
140
138
|
debug(`${tag} %O`, query);
|
|
141
|
-
return (await this.performIO(query)).
|
|
139
|
+
return (await this.performIO(query)).rowsAffected;
|
|
142
140
|
}
|
|
143
141
|
/**
|
|
144
142
|
* Run a query against the database, returning the result set.
|
|
@@ -152,13 +150,13 @@ var PlanetScaleQueryable = class {
|
|
|
152
150
|
as: "array",
|
|
153
151
|
cast
|
|
154
152
|
});
|
|
155
|
-
return
|
|
153
|
+
return result;
|
|
156
154
|
} catch (e) {
|
|
157
155
|
const error = e;
|
|
158
156
|
if (error.name === "DatabaseError") {
|
|
159
157
|
const parsed = parseErrorMessage(error.message);
|
|
160
158
|
if (parsed) {
|
|
161
|
-
|
|
159
|
+
throw new DriverAdapterError({
|
|
162
160
|
kind: "mysql",
|
|
163
161
|
...parsed
|
|
164
162
|
});
|
|
@@ -194,12 +192,12 @@ var PlanetScaleTransaction = class extends PlanetScaleQueryable {
|
|
|
194
192
|
async commit() {
|
|
195
193
|
debug(`[js::commit]`);
|
|
196
194
|
this.txDeferred.resolve();
|
|
197
|
-
return
|
|
195
|
+
return await this.txResultPromise;
|
|
198
196
|
}
|
|
199
197
|
async rollback() {
|
|
200
198
|
debug(`[js::rollback]`);
|
|
201
199
|
this.txDeferred.reject(new RollbackError());
|
|
202
|
-
return
|
|
200
|
+
return await this.txResultPromise;
|
|
203
201
|
}
|
|
204
202
|
};
|
|
205
203
|
var PlanetScaleTransactionContext = class extends PlanetScaleQueryable {
|
|
@@ -217,7 +215,7 @@ var PlanetScaleTransactionContext = class extends PlanetScaleQueryable {
|
|
|
217
215
|
const txResultPromise = this.conn.transaction(async (tx) => {
|
|
218
216
|
const [txDeferred, deferredPromise] = createDeferred();
|
|
219
217
|
const txWrapper = new PlanetScaleTransaction(tx, options, txDeferred, txResultPromise);
|
|
220
|
-
resolve(
|
|
218
|
+
resolve(txWrapper);
|
|
221
219
|
return deferredPromise;
|
|
222
220
|
}).catch((error) => {
|
|
223
221
|
if (!(error instanceof RollbackError)) {
|
|
@@ -239,17 +237,22 @@ const adapter = new PrismaPlanetScale(client)
|
|
|
239
237
|
}
|
|
240
238
|
super(client);
|
|
241
239
|
}
|
|
240
|
+
executeScript(_script) {
|
|
241
|
+
throw new Error("Not implemented yet");
|
|
242
|
+
}
|
|
242
243
|
getConnectionInfo() {
|
|
243
244
|
const url = this.client.connection()["url"];
|
|
244
245
|
const dbName = new URL(url).pathname.slice(1);
|
|
245
|
-
return
|
|
246
|
+
return {
|
|
246
247
|
schemaName: dbName
|
|
247
|
-
}
|
|
248
|
+
};
|
|
248
249
|
}
|
|
249
250
|
async transactionContext() {
|
|
250
251
|
const conn = this.client.connection();
|
|
251
252
|
const ctx = new PlanetScaleTransactionContext(conn);
|
|
252
|
-
return
|
|
253
|
+
return ctx;
|
|
254
|
+
}
|
|
255
|
+
async dispose() {
|
|
253
256
|
}
|
|
254
257
|
};
|
|
255
258
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-planetscale",
|
|
3
|
-
"version": "6.5.0-dev.
|
|
3
|
+
"version": "6.5.0-dev.25",
|
|
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": "6.5.0-dev.
|
|
34
|
+
"@prisma/driver-adapter-utils": "6.5.0-dev.25"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@planetscale/database": "1.18.0",
|