@flowblade/sqlduck 0.26.0 → 0.27.0
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Kysely, SelectQueryBuilder } from "kysely";
|
|
2
|
+
|
|
3
|
+
//#region src/integrations/kysely/compile-duck-query.d.ts
|
|
4
|
+
type SqlTagInformation = {
|
|
5
|
+
text: string;
|
|
6
|
+
values: unknown[];
|
|
7
|
+
};
|
|
8
|
+
declare const compileDuckQuery: <T extends SelectQueryBuilder<any, any, any>>(query: T) => SqlTagInformation;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/integrations/kysely/create-duck-kysely-query-builder.d.ts
|
|
11
|
+
type KyselyQueryBuilder<TDatabase> = Pick<Kysely<TDatabase>, 'mergeInto' | 'selectFrom' | 'selectNoFrom' | 'deleteFrom' | 'updateTable' | 'insertInto' | 'replaceInto' | 'with' | 'withRecursive' | 'withTables'>;
|
|
12
|
+
declare const createDuckKysekyQueryBuilder: <TDatabase>(params?: {
|
|
13
|
+
schema?: string;
|
|
14
|
+
}) => KyselyQueryBuilder<TDatabase>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { compileDuckQuery, createDuckKysekyQueryBuilder };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DummyDriver, Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler } from "kysely";
|
|
2
|
+
//#region src/integrations/kysely/compile-duck-query.ts
|
|
3
|
+
const compileDuckQuery = (query) => {
|
|
4
|
+
const { sql, parameters } = query.compile();
|
|
5
|
+
return {
|
|
6
|
+
text: sql,
|
|
7
|
+
values: parameters
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/integrations/kysely/create-duck-kysely-query-builder.ts
|
|
12
|
+
let kyselyCache;
|
|
13
|
+
const createDuckKysekyQueryBuilder = (params) => {
|
|
14
|
+
kyselyCache ??= new Kysely({ dialect: {
|
|
15
|
+
createAdapter: () => new PostgresAdapter(),
|
|
16
|
+
createDriver: () => new DummyDriver(),
|
|
17
|
+
createIntrospector: (db) => new PostgresIntrospector(db),
|
|
18
|
+
createQueryCompiler: () => new PostgresQueryCompiler()
|
|
19
|
+
} });
|
|
20
|
+
if (params?.schema) return kyselyCache.withSchema(params.schema);
|
|
21
|
+
return kyselyCache;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { compileDuckQuery, createDuckKysekyQueryBuilder };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowblade/sqlduck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"types": "./dist/validation/valibot/index.d.mts",
|
|
21
21
|
"default": "./dist/validation/valibot/index.mjs"
|
|
22
22
|
},
|
|
23
|
+
"./kysely": {
|
|
24
|
+
"types": "./dist/integrations/kysely/index.d.mts",
|
|
25
|
+
"default": "./dist/integrations/kysely/index.mjs"
|
|
26
|
+
},
|
|
23
27
|
"./package.json": "./package.json"
|
|
24
28
|
},
|
|
25
29
|
"author": {
|
|
@@ -63,7 +67,7 @@
|
|
|
63
67
|
},
|
|
64
68
|
"dependencies": {
|
|
65
69
|
"@flowblade/core": "^0.2.29",
|
|
66
|
-
"@flowblade/source-duckdb": "^0.
|
|
70
|
+
"@flowblade/source-duckdb": "^0.23.0",
|
|
67
71
|
"@flowblade/sql-tag": "^0.3.4",
|
|
68
72
|
"@httpx/assert": "^0.17.1",
|
|
69
73
|
"@httpx/dsn-parser": "^1.9.11",
|