@syncular/dialect-pglite 0.0.6-73 → 0.0.6-80
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 +6 -2
- package/dist/index.d.ts +7 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +15 -58
package/README.md
CHANGED
|
@@ -11,9 +11,13 @@ npm install @syncular/dialect-pglite
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
14
|
+
import { createDatabase } from '@syncular/core';
|
|
15
|
+
import { createPgliteDialect } from '@syncular/dialect-pglite';
|
|
15
16
|
|
|
16
|
-
const db =
|
|
17
|
+
const db = createDatabase<MyDb>({
|
|
18
|
+
dialect: createPgliteDialect({ dataDir: 'idb://app' }),
|
|
19
|
+
family: 'postgres',
|
|
20
|
+
});
|
|
17
21
|
```
|
|
18
22
|
|
|
19
23
|
## Documentation
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* Uses kysely-pglite-dialect under the hood.
|
|
6
6
|
*/
|
|
7
7
|
import { type PGliteWithLive } from '@electric-sql/pglite/live';
|
|
8
|
-
import { Kysely } from 'kysely';
|
|
9
8
|
import { PGliteDialect } from 'kysely-pglite-dialect';
|
|
10
9
|
export interface PgliteOptions {
|
|
11
10
|
/** Optional data directory for persistence */
|
|
@@ -20,41 +19,17 @@ export interface PgliteOptions {
|
|
|
20
19
|
initialMemory?: number;
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
* Use this type when you need access to PGlite's native features like live queries.
|
|
22
|
+
* Create the PGlite dialect directly.
|
|
25
23
|
*/
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
export declare function createPgliteDialect(options?: PgliteOptions): PGliteDialect;
|
|
25
|
+
export interface PgliteDialectWithLive {
|
|
26
|
+
dialect: PGliteDialect;
|
|
27
|
+
pglite: PGliteWithLive;
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
|
-
* Create a
|
|
32
|
-
* Synchronous version - database may not be fully ready immediately.
|
|
33
|
-
*
|
|
34
|
-
* Note: This version does NOT include the live extension or expose the raw PGlite instance.
|
|
35
|
-
* For live query support, use createPgliteDbAsync() instead.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* const db = createPgliteDb<MyDb>(); // In-memory
|
|
39
|
-
* const db = createPgliteDb<MyDb>({ dataDir: './pgdata' }); // Persistent
|
|
30
|
+
* Create a PGlite dialect with fully initialized live-enabled instance.
|
|
40
31
|
*/
|
|
41
|
-
export declare function
|
|
42
|
-
/**
|
|
43
|
-
* Create a Kysely instance with PGlite dialect, waiting for database to be ready.
|
|
44
|
-
* Async version - ensures database is fully initialized before returning.
|
|
45
|
-
* Includes the live extension for reactive queries.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* const db = await createPgliteDbAsync<MyDb>(); // In-memory
|
|
49
|
-
* const db = await createPgliteDbAsync<MyDb>({ dataDir: 'idb://mydb' }); // Persistent
|
|
50
|
-
* // Access raw PGlite for live queries:
|
|
51
|
-
* db.pglite.live.incrementalQuery(...)
|
|
52
|
-
*/
|
|
53
|
-
export declare function createPgliteDbAsync<T>(options?: PgliteOptions): Promise<PgliteDb<T>>;
|
|
54
|
-
/**
|
|
55
|
-
* Create the PGlite dialect directly.
|
|
56
|
-
*/
|
|
57
|
-
export declare function createPgliteDialect(options?: PgliteOptions): PGliteDialect;
|
|
32
|
+
export declare function createPgliteDialectWithLive(options?: PgliteOptions): Promise<PgliteDialectWithLive>;
|
|
58
33
|
export declare function getPgliteAssetPaths(): {
|
|
59
34
|
fsBundlePath: string;
|
|
60
35
|
wasmPath: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAEvB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;IAEhC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAG1E;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,qBAAqB,CAAC,CAShC;AAED,wBAAgB,mBAAmB,IAAI;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAOA"}
|
package/dist/index.js
CHANGED
|
@@ -6,62 +6,27 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { PGlite } from '@electric-sql/pglite';
|
|
8
8
|
import { live } from '@electric-sql/pglite/live';
|
|
9
|
-
import { Kysely } from 'kysely';
|
|
10
9
|
import { PGliteDialect } from 'kysely-pglite-dialect';
|
|
11
10
|
/**
|
|
12
|
-
* Create
|
|
13
|
-
* Synchronous version - database may not be fully ready immediately.
|
|
14
|
-
*
|
|
15
|
-
* Note: This version does NOT include the live extension or expose the raw PGlite instance.
|
|
16
|
-
* For live query support, use createPgliteDbAsync() instead.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const db = createPgliteDb<MyDb>(); // In-memory
|
|
20
|
-
* const db = createPgliteDb<MyDb>({ dataDir: './pgdata' }); // Persistent
|
|
11
|
+
* Create the PGlite dialect directly.
|
|
21
12
|
*/
|
|
22
|
-
export function
|
|
13
|
+
export function createPgliteDialect(options) {
|
|
23
14
|
const database = options ? new PGlite(options) : new PGlite();
|
|
24
|
-
return new
|
|
25
|
-
dialect: new PGliteDialect(database),
|
|
26
|
-
});
|
|
15
|
+
return new PGliteDialect(database);
|
|
27
16
|
}
|
|
28
17
|
/**
|
|
29
|
-
* Create a
|
|
30
|
-
* Async version - ensures database is fully initialized before returning.
|
|
31
|
-
* Includes the live extension for reactive queries.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* const db = await createPgliteDbAsync<MyDb>(); // In-memory
|
|
35
|
-
* const db = await createPgliteDbAsync<MyDb>({ dataDir: 'idb://mydb' }); // Persistent
|
|
36
|
-
* // Access raw PGlite for live queries:
|
|
37
|
-
* db.pglite.live.incrementalQuery(...)
|
|
18
|
+
* Create a PGlite dialect with fully initialized live-enabled instance.
|
|
38
19
|
*/
|
|
39
|
-
export async function
|
|
40
|
-
const
|
|
20
|
+
export async function createPgliteDialectWithLive(options) {
|
|
21
|
+
const pglite = await PGlite.create({
|
|
41
22
|
...options,
|
|
42
23
|
extensions: { live },
|
|
43
24
|
});
|
|
44
|
-
|
|
45
|
-
dialect: new PGliteDialect(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// to properly define the readonly property
|
|
49
|
-
Object.defineProperty(db, 'pglite', {
|
|
50
|
-
value: database,
|
|
51
|
-
writable: false,
|
|
52
|
-
enumerable: true,
|
|
53
|
-
configurable: false,
|
|
54
|
-
});
|
|
55
|
-
return db;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Create the PGlite dialect directly.
|
|
59
|
-
*/
|
|
60
|
-
export function createPgliteDialect(options) {
|
|
61
|
-
const database = options ? new PGlite(options) : new PGlite();
|
|
62
|
-
return new PGliteDialect(database);
|
|
25
|
+
return {
|
|
26
|
+
dialect: new PGliteDialect(pglite),
|
|
27
|
+
pglite,
|
|
28
|
+
};
|
|
63
29
|
}
|
|
64
|
-
// Re-export types for convenience
|
|
65
30
|
export function getPgliteAssetPaths() {
|
|
66
31
|
const entry = import.meta.resolve('@electric-sql/pglite');
|
|
67
32
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAuB,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAuB,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAmBtD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB,EAAiB;IAC1E,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;IAC9D,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;AAAA,CACpC;AAOD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAuB,EACS;IAChC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,GAAG,OAAO;QACV,UAAU,EAAE,EAAE,IAAI,EAAE;KACrB,CAAC,CAAC;IACH,OAAO;QACL,OAAO,EAAE,IAAI,aAAa,CAAC,MAAM,CAAC;QAClC,MAAM;KACP,CAAC;AAAA,CACH;AAED,MAAM,UAAU,mBAAmB,GAGjC;IACA,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAE1D,OAAO;QACL,YAAY,EAAE,IAAI,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,QAAQ;QACtD,QAAQ,EAAE,IAAI,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,QAAQ;KACnD,CAAC;AAAA,CACH"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
import { PGlite } from '@electric-sql/pglite';
|
|
9
9
|
import { live, type PGliteWithLive } from '@electric-sql/pglite/live';
|
|
10
|
-
import { Kysely } from 'kysely';
|
|
11
10
|
import { PGliteDialect } from 'kysely-pglite-dialect';
|
|
12
11
|
|
|
13
12
|
export interface PgliteOptions {
|
|
@@ -28,75 +27,33 @@ export interface PgliteOptions {
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
/**
|
|
31
|
-
*
|
|
32
|
-
* Use this type when you need access to PGlite's native features like live queries.
|
|
30
|
+
* Create the PGlite dialect directly.
|
|
33
31
|
*/
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
export function createPgliteDialect(options?: PgliteOptions): PGliteDialect {
|
|
33
|
+
const database = options ? new PGlite(options) : new PGlite();
|
|
34
|
+
return new PGliteDialect(database);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* Note: This version does NOT include the live extension or expose the raw PGlite instance.
|
|
44
|
-
* For live query support, use createPgliteDbAsync() instead.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const db = createPgliteDb<MyDb>(); // In-memory
|
|
48
|
-
* const db = createPgliteDb<MyDb>({ dataDir: './pgdata' }); // Persistent
|
|
49
|
-
*/
|
|
50
|
-
export function createPgliteDb<T>(options?: PgliteOptions): Kysely<T> {
|
|
51
|
-
const database = options ? new PGlite(options) : new PGlite();
|
|
52
|
-
return new Kysely<T>({
|
|
53
|
-
dialect: new PGliteDialect(database),
|
|
54
|
-
});
|
|
37
|
+
export interface PgliteDialectWithLive {
|
|
38
|
+
dialect: PGliteDialect;
|
|
39
|
+
pglite: PGliteWithLive;
|
|
55
40
|
}
|
|
56
41
|
|
|
57
42
|
/**
|
|
58
|
-
* Create a
|
|
59
|
-
* Async version - ensures database is fully initialized before returning.
|
|
60
|
-
* Includes the live extension for reactive queries.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const db = await createPgliteDbAsync<MyDb>(); // In-memory
|
|
64
|
-
* const db = await createPgliteDbAsync<MyDb>({ dataDir: 'idb://mydb' }); // Persistent
|
|
65
|
-
* // Access raw PGlite for live queries:
|
|
66
|
-
* db.pglite.live.incrementalQuery(...)
|
|
43
|
+
* Create a PGlite dialect with fully initialized live-enabled instance.
|
|
67
44
|
*/
|
|
68
|
-
export async function
|
|
45
|
+
export async function createPgliteDialectWithLive(
|
|
69
46
|
options?: PgliteOptions
|
|
70
|
-
): Promise<
|
|
71
|
-
const
|
|
47
|
+
): Promise<PgliteDialectWithLive> {
|
|
48
|
+
const pglite = await PGlite.create({
|
|
72
49
|
...options,
|
|
73
50
|
extensions: { live },
|
|
74
51
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Attach raw instance for live query access using Object.defineProperty
|
|
81
|
-
// to properly define the readonly property
|
|
82
|
-
Object.defineProperty(db, 'pglite', {
|
|
83
|
-
value: database,
|
|
84
|
-
writable: false,
|
|
85
|
-
enumerable: true,
|
|
86
|
-
configurable: false,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
return db as PgliteDb<T>;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Create the PGlite dialect directly.
|
|
94
|
-
*/
|
|
95
|
-
export function createPgliteDialect(options?: PgliteOptions): PGliteDialect {
|
|
96
|
-
const database = options ? new PGlite(options) : new PGlite();
|
|
97
|
-
return new PGliteDialect(database);
|
|
52
|
+
return {
|
|
53
|
+
dialect: new PGliteDialect(pglite),
|
|
54
|
+
pglite,
|
|
55
|
+
};
|
|
98
56
|
}
|
|
99
|
-
// Re-export types for convenience
|
|
100
57
|
|
|
101
58
|
export function getPgliteAssetPaths(): {
|
|
102
59
|
fsBundlePath: string;
|