vite-plugin-postgres-import 0.5.0 → 0.6.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.
- package/index.d.ts +27 -0
- package/package.json +6 -2
- package/parse.js +2 -2
package/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
QueryArrayConfig,
|
|
3
|
+
QueryArrayResult,
|
|
4
|
+
QueryConfig,
|
|
5
|
+
QueryConfigValues,
|
|
6
|
+
QueryResult,
|
|
7
|
+
QueryResultRow,
|
|
8
|
+
Submittable,
|
|
9
|
+
} from "pg";
|
|
1
10
|
import type { Plugin } from "vite";
|
|
2
11
|
|
|
3
12
|
export default function postgres(opts?: {
|
|
@@ -18,3 +27,21 @@ export default function postgres(opts?: {
|
|
|
18
27
|
*/
|
|
19
28
|
rootFolder?: string;
|
|
20
29
|
}): Plugin;
|
|
30
|
+
|
|
31
|
+
export interface QueryableObject {
|
|
32
|
+
query<T extends Submittable>(queryStream: T): T;
|
|
33
|
+
|
|
34
|
+
query<R extends any[] = any[], I = any[]>(
|
|
35
|
+
queryConfig: QueryArrayConfig<I>,
|
|
36
|
+
values?: QueryConfigValues<I>
|
|
37
|
+
): Promise<QueryArrayResult<R>>;
|
|
38
|
+
|
|
39
|
+
query<R extends QueryResultRow = any, I = any>(queryConfig: QueryConfig<I>): Promise<QueryResult<R>>;
|
|
40
|
+
|
|
41
|
+
query<R extends QueryResultRow = any, I = any[]>(
|
|
42
|
+
queryTextOrConfig: string | QueryConfig<I>,
|
|
43
|
+
values?: QueryConfigValues<I>
|
|
44
|
+
): Promise<QueryResult<R>>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type Queryable = QueryableObject | Promise<QueryableObject>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-postgres-import",
|
|
3
3
|
"description": "Vite plugin for importing SQL files as JS modules with sqlc-style annotations",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"main": "plugin.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "SirKostya009",
|
|
@@ -22,12 +22,16 @@
|
|
|
22
22
|
"vite": "^6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
+
"pg": "*",
|
|
25
26
|
"pg-cursor": "*",
|
|
26
|
-
"pg": "*"
|
|
27
|
+
"@types/pg": "*"
|
|
27
28
|
},
|
|
28
29
|
"peerDependenciesMeta": {
|
|
29
30
|
"pg-cursor": {
|
|
30
31
|
"optional": true
|
|
32
|
+
},
|
|
33
|
+
"@types/pg": {
|
|
34
|
+
"optional": true
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
37
|
"engines": {
|
package/parse.js
CHANGED
|
@@ -92,7 +92,7 @@ export function codegen(
|
|
|
92
92
|
) {
|
|
93
93
|
let dts = [
|
|
94
94
|
// `declare module '${modulePrefix}${filename}.sql' {`
|
|
95
|
-
`import type {
|
|
95
|
+
`import type { QueryResultRow, QueryResult, QueryArrayResult } from 'pg';\nimport { Queryable } from 'vite-plugin-postgres-import';`,
|
|
96
96
|
];
|
|
97
97
|
let js = [`import { escapeLiteral } from 'pg';`];
|
|
98
98
|
|
|
@@ -146,7 +146,7 @@ export function ${module.name}<${module.returnSymbols
|
|
|
146
146
|
}${r.length > 3 ? "\n" : " "}}`
|
|
147
147
|
)
|
|
148
148
|
.join(", ")}>(
|
|
149
|
-
tx:
|
|
149
|
+
tx: Queryable,${keys && `\n\tparams: Record<${keys}, unknown>,`}${
|
|
150
150
|
module.mode === ":iterable" ? `\n\tread?: number,` : ""
|
|
151
151
|
}
|
|
152
152
|
): ${
|