introspeql 0.0.0 → 0.0.1

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.
@@ -1,2 +1,2 @@
1
- import type { ParsedIntrospeQLConfig } from "./introspeql-config";
2
- export declare function introspectDatabase(config: ParsedIntrospeQLConfig): Promise<void>;
1
+ import { type IntrospeQLConfig } from "./introspeql-config";
2
+ export declare function introspectDatabase(config: IntrospeQLConfig): Promise<void>;
@@ -7,13 +7,15 @@ import { introspectEnum, } from "./introspect-enum";
7
7
  import { writeHeader } from "./write-header";
8
8
  import { prepareDataForWriting } from "./prepare-data-for-writing";
9
9
  import { appendSchema } from "./append-schema";
10
+ import { introspeqlConfig } from "./introspeql-config";
10
11
  export async function introspectDatabase(config) {
11
- const client = "dbConnectionString" in config
12
+ const parsedConfig = introspeqlConfig.parse(config);
13
+ const client = "dbConnectionString" in parsedConfig
12
14
  ? new Client({
13
- connectionString: config.dbConnectionString,
15
+ connectionString: parsedConfig.dbConnectionString,
14
16
  })
15
17
  : new Client({
16
- ...config.dbConnectionParams,
18
+ ...parsedConfig.dbConnectionParams,
17
19
  });
18
20
  try {
19
21
  await client.connect();
@@ -24,7 +26,7 @@ export async function introspectDatabase(config) {
24
26
  // Read table data
25
27
  let tableDataObjects;
26
28
  try {
27
- tableDataObjects = await introspectTables(client, config);
29
+ tableDataObjects = await introspectTables(client, parsedConfig);
28
30
  }
29
31
  catch (e) {
30
32
  throw new Error("Failed to introspect tables.", { cause: e });
@@ -54,7 +56,7 @@ export async function introspectDatabase(config) {
54
56
  // Read procedure data and update enums object when enum types are found
55
57
  let procedureDataObjects;
56
58
  try {
57
- procedureDataObjects = await introspectProcedures(client, config);
59
+ procedureDataObjects = await introspectProcedures(client, parsedConfig);
58
60
  }
59
61
  catch (e) {
60
62
  throw new Error("Failed to introspect procedures.", { cause: e });
@@ -91,10 +93,10 @@ export async function introspectDatabase(config) {
91
93
  }
92
94
  }
93
95
  await client.end();
94
- const outputPath = "outFile" in config
95
- ? config.outFile
96
- : path.join(config.outDir, "introspeql-types.ts");
97
- writeHeader(outputPath, config);
98
- const schemas = prepareDataForWriting(enumDataObjects, tableDataObjects, columnDataObjectsByTableId, procedureDataObjects, config);
96
+ const outputPath = "outFile" in parsedConfig
97
+ ? parsedConfig.outFile
98
+ : path.join(parsedConfig.outDir, "introspeql-types.ts");
99
+ writeHeader(outputPath, parsedConfig);
100
+ const schemas = prepareDataForWriting(enumDataObjects, tableDataObjects, columnDataObjectsByTableId, procedureDataObjects, parsedConfig);
99
101
  schemas.forEach((schema) => appendSchema(outputPath, schema));
100
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "introspeql",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "Easy Postgres to TypeScript type generation.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",