true-pg 0.1.1 → 0.2.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/README.md +7 -6
- package/lib/index.js +4 -1
- package/lib/types.d.ts +4 -2
- package/package.json +6 -1
package/README.md
CHANGED
@@ -51,12 +51,13 @@ Example config file:
|
|
51
51
|
|
52
52
|
## Configuration Options
|
53
53
|
|
54
|
-
| Option
|
55
|
-
|
|
56
|
-
| `uri`
|
57
|
-
| `
|
58
|
-
| `
|
59
|
-
| `
|
54
|
+
| Option | Description | Default |
|
55
|
+
| ------------------ | -------------------------------------------------------- | ----------------------------- |
|
56
|
+
| `uri` | PostgreSQL connection URI | Required, or connectionConfig |
|
57
|
+
| `connectionConfig` | PostgreSQL connection config object | Required, or uri |
|
58
|
+
| `out` | Output directory for generated files | `"models"` |
|
59
|
+
| `adapters` | Adapters to use (e.g. `kysely`, `zod`) | `"kysely"` |
|
60
|
+
| `defaultSchema` | Default schema to use (Kysely schema will be unprefixed) | `"public"` |
|
60
61
|
|
61
62
|
## Customising Code Generation
|
62
63
|
|
package/lib/index.js
CHANGED
@@ -135,7 +135,10 @@ const multifile = async (generators, schemas, opts) => {
|
|
135
135
|
};
|
136
136
|
export async function generate(opts, generators) {
|
137
137
|
const out = opts.out || "./models";
|
138
|
-
const
|
138
|
+
const conn = opts.uri ?? opts.connectionConfig;
|
139
|
+
if (!conn)
|
140
|
+
throw new Error("Either uri or connectionConfig is required. Add either option to your .truepgrc.json.");
|
141
|
+
const extractor = new Extractor(conn);
|
139
142
|
const schemas = await extractor.extractSchemas();
|
140
143
|
generators ??= opts.adapters.map(adapter => {
|
141
144
|
const selected = adapters[adapter];
|
package/lib/types.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { CanonicalType, CompositeTypeDetails, EnumDetails, FunctionDetails, TableDetails, SchemaType, Schema } from "pg-extract";
|
1
|
+
import type { CanonicalType, CompositeTypeDetails, EnumDetails, FunctionDetails, TableDetails, SchemaType, Schema, Extractor } from "pg-extract";
|
2
2
|
export declare const allowed_kind_names: readonly ["tables", "enums", "composites", "functions"];
|
3
3
|
export type allowed_kind_names = (typeof allowed_kind_names)[number];
|
4
4
|
export interface FolderStructure {
|
@@ -64,8 +64,10 @@ export declare namespace Nodes {
|
|
64
64
|
star: boolean;
|
65
65
|
}
|
66
66
|
}
|
67
|
+
export type ConnectionConfig = Exclude<ConstructorParameters<typeof Extractor>[0], string | undefined>;
|
67
68
|
export interface TruePGOpts {
|
68
|
-
uri
|
69
|
+
uri?: string;
|
70
|
+
connectionConfig?: ConnectionConfig;
|
69
71
|
out: string;
|
70
72
|
adapters: string[];
|
71
73
|
defaultSchema?: string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "true-pg",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.0",
|
4
4
|
"type": "module",
|
5
5
|
"module": "lib/index.js",
|
6
6
|
"main": "lib/index.js",
|
@@ -10,6 +10,11 @@
|
|
10
10
|
"files": [
|
11
11
|
"lib"
|
12
12
|
],
|
13
|
+
"homepage": "https://github.com/feathers-studio/true-pg",
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "https://github.com/feathers-studio/true-pg.git"
|
17
|
+
},
|
13
18
|
"scripts": {
|
14
19
|
"check": "tsc --noEmit",
|
15
20
|
"build": "tsc",
|