true-pg 0.4.0 → 0.4.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,9 +1,9 @@
|
|
1
|
-
import
|
1
|
+
import * as Pg from "pg";
|
2
2
|
import { PGlite as Pglite } from "@electric-sql/pglite";
|
3
3
|
export declare class DbAdapter {
|
4
4
|
private client;
|
5
5
|
private external?;
|
6
|
-
constructor(client:
|
6
|
+
constructor(client: Pg.Client | Pg.Pool | Pglite, external?: boolean | undefined);
|
7
7
|
connect(): Promise<void>;
|
8
8
|
/**
|
9
9
|
* Execute a read query and return just the rows
|
package/lib/extractor/adapter.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import * as Pg from "pg";
|
2
2
|
import { PGlite as Pglite } from "@electric-sql/pglite";
|
3
3
|
export class DbAdapter {
|
4
4
|
client;
|
@@ -10,10 +10,10 @@ export class DbAdapter {
|
|
10
10
|
async connect() {
|
11
11
|
if (this.external)
|
12
12
|
return;
|
13
|
-
if (this.client instanceof
|
13
|
+
if (this.client instanceof Pg.Pool) {
|
14
14
|
// queries will automatically checkout a client and return it to the pool
|
15
15
|
}
|
16
|
-
else if (this.client instanceof
|
16
|
+
else if (this.client instanceof Pg.Client) {
|
17
17
|
return this.client.connect();
|
18
18
|
}
|
19
19
|
else if (this.client instanceof Pglite) {
|
@@ -52,10 +52,10 @@ export class DbAdapter {
|
|
52
52
|
async close() {
|
53
53
|
if (this.external)
|
54
54
|
return;
|
55
|
-
if (this.client instanceof
|
55
|
+
if (this.client instanceof Pg.Pool) {
|
56
56
|
this.client.end();
|
57
57
|
}
|
58
|
-
else if (this.client instanceof
|
58
|
+
else if (this.client instanceof Pg.Client) {
|
59
59
|
await this.client.end();
|
60
60
|
}
|
61
61
|
else if (this.client instanceof Pglite) {
|
package/lib/extractor/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import Pg from "pg";
|
2
2
|
import { PGlite as Pglite } from "@electric-sql/pglite";
|
3
3
|
import { type TableDetails } from "./kinds/table.ts";
|
4
4
|
import { type ViewDetails } from "./kinds/view.ts";
|
@@ -76,9 +76,9 @@ export declare class Extractor {
|
|
76
76
|
* @param connectionConfig - Connection string or configuration object for Postgres connection
|
77
77
|
*/
|
78
78
|
constructor(opts: {
|
79
|
-
pg?:
|
79
|
+
pg?: Pg.Client | Pg.Pool | Pglite;
|
80
80
|
uri?: string;
|
81
|
-
config?: ConnectionConfig;
|
81
|
+
config?: Pg.ConnectionConfig;
|
82
82
|
});
|
83
83
|
canonicalise(types: string[]): Promise<Canonical[]>;
|
84
84
|
getBuiltinTypes(): Promise<{
|
package/lib/extractor/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import Pg from "pg";
|
2
2
|
import { PGlite as Pglite } from "@electric-sql/pglite";
|
3
3
|
import { DbAdapter } from "./adapter.js";
|
4
4
|
import extractTable, {} from "./kinds/table.js";
|
@@ -43,9 +43,9 @@ export class Extractor {
|
|
43
43
|
if (opts.pg)
|
44
44
|
pg = opts.pg;
|
45
45
|
else if (opts.uri)
|
46
|
-
pg = new
|
46
|
+
pg = new Pg.Pool({ connectionString: opts.uri });
|
47
47
|
else if (opts.config)
|
48
|
-
pg = new
|
48
|
+
pg = new Pg.Pool(opts.config);
|
49
49
|
else {
|
50
50
|
console.error("One of these options are required in your config file: pg, uri, config. See documentation for more information.");
|
51
51
|
process.exit(1);
|