prisma-extension-kysely 1.0.1 → 1.0.2
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.ts +34 -0
- package/dist/index.js +40 -0
- package/package.json +3 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PrismaPromise } from "@prisma/client/runtime/library";
|
|
2
|
+
import type { Compilable, Kysely, Simplify } from "kysely";
|
|
3
|
+
/**
|
|
4
|
+
* The configuration object for the Prisma Kysely extension
|
|
5
|
+
*/
|
|
6
|
+
export type PrismaKyselyExtensionArgs<Database> = {
|
|
7
|
+
/**
|
|
8
|
+
* The Kysely instance to provide to the Prisma client
|
|
9
|
+
*/
|
|
10
|
+
kysely: Kysely<Database>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Define a Prisma extension that adds Kysely query builder methods to the Prisma client
|
|
14
|
+
* @param extensionArgs The extension configuration object
|
|
15
|
+
*/
|
|
16
|
+
declare const _default: <Database>(extensionArgs: PrismaKyselyExtensionArgs<Database>) => (client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/library").InternalArgs<{}, {}, {}, {
|
|
17
|
+
/**
|
|
18
|
+
* The Kysely instance used by the Prisma client
|
|
19
|
+
*/
|
|
20
|
+
$kysely: Kysely<Database>;
|
|
21
|
+
/**
|
|
22
|
+
* Execute a Kysely query and return the result
|
|
23
|
+
* @param query A Kysely select, insert, delete or update query builder
|
|
24
|
+
* @returns The result of the query
|
|
25
|
+
*/
|
|
26
|
+
$kyselyQuery<T>(query: Compilable<T>): Promise<Simplify<T>[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Execute a Kysely query and return the number of rows affected
|
|
29
|
+
* @param query A Kysely select, insert, delete or update query builder
|
|
30
|
+
* @returns The number of rows affected
|
|
31
|
+
*/
|
|
32
|
+
$kyselyExecute(query: Compilable): PrismaPromise<number>;
|
|
33
|
+
}> & import("@prisma/client/runtime/library").DefaultArgs>;
|
|
34
|
+
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const extension_1 = require("@prisma/client/extension");
|
|
4
|
+
/**
|
|
5
|
+
* Define a Prisma extension that adds Kysely query builder methods to the Prisma client
|
|
6
|
+
* @param extensionArgs The extension configuration object
|
|
7
|
+
*/
|
|
8
|
+
exports.default = (extensionArgs) => extension_1.Prisma.defineExtension((client) => {
|
|
9
|
+
return client.$extends({
|
|
10
|
+
name: "prisma-extension-kysely",
|
|
11
|
+
client: {
|
|
12
|
+
/**
|
|
13
|
+
* The Kysely instance used by the Prisma client
|
|
14
|
+
*/
|
|
15
|
+
$kysely: extensionArgs.kysely,
|
|
16
|
+
/**
|
|
17
|
+
* Execute a Kysely query and return the result
|
|
18
|
+
* @param query A Kysely select, insert, delete or update query builder
|
|
19
|
+
* @returns The result of the query
|
|
20
|
+
*/
|
|
21
|
+
$kyselyQuery(query) {
|
|
22
|
+
const { sql, parameters } = query.compile();
|
|
23
|
+
const ctx = extension_1.Prisma.getExtensionContext(this);
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
return ctx.$queryRawUnsafe(sql, ...parameters);
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Execute a Kysely query and return the number of rows affected
|
|
29
|
+
* @param query A Kysely select, insert, delete or update query builder
|
|
30
|
+
* @returns The number of rows affected
|
|
31
|
+
*/
|
|
32
|
+
$kyselyExecute(query) {
|
|
33
|
+
const { sql, parameters } = query.compile();
|
|
34
|
+
const ctx = extension_1.Prisma.getExtensionContext(this);
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
return ctx.$executeRawUnsafe(sql, ...parameters);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-extension-kysely",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Eoin O'Brien",
|
|
6
6
|
"url": "https://eoin.ai",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"test": "prisma generate && prisma db push && jest",
|
|
35
|
+
"clean": "rm -rf ./dist",
|
|
35
36
|
"build": "tsc",
|
|
37
|
+
"prepack": "npm run clean && npm run build",
|
|
36
38
|
"prepare": "husky install",
|
|
37
39
|
"commit": "git-cz",
|
|
38
40
|
"lint": "eslint .",
|