@syncular/dialect-bun-sqlite 0.0.1-60

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @syncular/dialect-bun-sqlite - Bun SQLite dialect for sync
3
+ *
4
+ * Provides a Kysely dialect for bun:sqlite with SerializePlugin
5
+ * for automatic JSON serialization/deserialization.
6
+ */
7
+ import { SerializePlugin } from '@syncular/core';
8
+ import { Kysely } from 'kysely';
9
+ import { BunSqliteDialect } from 'kysely-bun-sqlite';
10
+ export interface BunSqliteOptions {
11
+ /** Path to SQLite database file, or ':memory:' for in-memory */
12
+ path: string;
13
+ }
14
+ /**
15
+ * Create a Kysely instance with Bun SQLite dialect and SerializePlugin.
16
+ *
17
+ * The SerializePlugin automatically handles JSON serialization/deserialization
18
+ * for object values, so you can work with JS objects directly.
19
+ *
20
+ * @example
21
+ * const db = createBunSqliteDb<MyDb>({ path: ':memory:' });
22
+ * // or
23
+ * const db = createBunSqliteDb<MyDb>({ path: './data.db' });
24
+ */
25
+ export declare function createBunSqliteDb<T>(options: BunSqliteOptions): Kysely<T>;
26
+ /**
27
+ * Create the Bun SQLite dialect directly (without SerializePlugin).
28
+ *
29
+ * @example
30
+ * const dialect = createBunSqliteDialect({ path: ':memory:' });
31
+ * const db = new Kysely<MyDb>({ dialect, plugins: [new SerializePlugin()] });
32
+ */
33
+ export declare function createBunSqliteDialect(options: BunSqliteOptions): BunSqliteDialect;
34
+ /**
35
+ * Create a SerializePlugin instance.
36
+ */
37
+ export declare function createSerializePlugin(): SerializePlugin;
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,CAOzE;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,gBAAgB,GACxB,gBAAgB,CAGlB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD"}
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @syncular/dialect-bun-sqlite - Bun SQLite dialect for sync
3
+ *
4
+ * Provides a Kysely dialect for bun:sqlite with SerializePlugin
5
+ * for automatic JSON serialization/deserialization.
6
+ */
7
+ import { Database } from 'bun:sqlite';
8
+ import { SerializePlugin } from '@syncular/core';
9
+ import { Kysely } from 'kysely';
10
+ import { BunSqliteDialect } from 'kysely-bun-sqlite';
11
+ /**
12
+ * Create a Kysely instance with Bun SQLite dialect and SerializePlugin.
13
+ *
14
+ * The SerializePlugin automatically handles JSON serialization/deserialization
15
+ * for object values, so you can work with JS objects directly.
16
+ *
17
+ * @example
18
+ * const db = createBunSqliteDb<MyDb>({ path: ':memory:' });
19
+ * // or
20
+ * const db = createBunSqliteDb<MyDb>({ path: './data.db' });
21
+ */
22
+ export function createBunSqliteDb(options) {
23
+ const database = new Database(options.path);
24
+ return new Kysely({
25
+ dialect: new BunSqliteDialect({ database }),
26
+ plugins: [new SerializePlugin()],
27
+ });
28
+ }
29
+ /**
30
+ * Create the Bun SQLite dialect directly (without SerializePlugin).
31
+ *
32
+ * @example
33
+ * const dialect = createBunSqliteDialect({ path: ':memory:' });
34
+ * const db = new Kysely<MyDb>({ dialect, plugins: [new SerializePlugin()] });
35
+ */
36
+ export function createBunSqliteDialect(options) {
37
+ const database = new Database(options.path);
38
+ return new BunSqliteDialect({ database });
39
+ }
40
+ /**
41
+ * Create a SerializePlugin instance.
42
+ */
43
+ export function createSerializePlugin() {
44
+ return new SerializePlugin();
45
+ }
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOrD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAI,OAAyB,EAAa;IACzE,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C,OAAO,IAAI,MAAM,CAAI;QACnB,OAAO,EAAE,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC3C,OAAO,EAAE,CAAC,IAAI,eAAe,EAAE,CAAC;KACjC,CAAC,CAAC;AAAA,CACJ;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAyB,EACP;IAClB,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,OAAO,IAAI,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;AAAA,CAC3C;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,GAAoB;IACvD,OAAO,IAAI,eAAe,EAAE,CAAC;AAAA,CAC9B"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@syncular/dialect-bun-sqlite",
3
+ "version": "0.0.1-60",
4
+ "description": "Bun SQLite dialect for the Syncular client",
5
+ "license": "MIT",
6
+ "author": "Benjamin Kniffler",
7
+ "homepage": "https://syncular.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/syncular/syncular.git",
11
+ "directory": "packages/dialect-bun-sqlite"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/syncular/syncular/issues"
15
+ },
16
+ "keywords": [
17
+ "sync",
18
+ "offline-first",
19
+ "realtime",
20
+ "database",
21
+ "typescript",
22
+ "bun",
23
+ "sqlite"
24
+ ],
25
+ "private": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "type": "module",
30
+ "exports": {
31
+ ".": {
32
+ "bun": "./src/index.ts",
33
+ "import": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ }
37
+ }
38
+ },
39
+ "scripts": {
40
+ "tsgo": "tsgo --noEmit",
41
+ "build": "rm -rf dist && tsgo",
42
+ "release": "bun pm pack --destination . && npm publish ./*.tgz --tag latest && rm -f ./*.tgz"
43
+ },
44
+ "dependencies": {
45
+ "@syncular/core": "0.0.1",
46
+ "kysely-bun-sqlite": "^0.4.0"
47
+ },
48
+ "peerDependencies": {
49
+ "kysely": "^0.28.0"
50
+ },
51
+ "devDependencies": {
52
+ "@syncular/config": "0.0.0",
53
+ "kysely": "*"
54
+ },
55
+ "files": [
56
+ "dist",
57
+ "src"
58
+ ]
59
+ }
@@ -0,0 +1,19 @@
1
+ // Type declarations for bun:sqlite when running tsgo (which doesn't fully support bun-types)
2
+ declare module 'bun:sqlite' {
3
+ export class Database {
4
+ constructor(path: string);
5
+ close(): void;
6
+ exec(sql: string): void;
7
+ query<T = unknown>(sql: string): Statement<T>;
8
+ prepare<T = unknown>(sql: string): Statement<T>;
9
+ transaction<T>(fn: () => T): () => T;
10
+ }
11
+
12
+ export class Statement<T = unknown> {
13
+ run(...params: unknown[]): void;
14
+ get(...params: unknown[]): T | null;
15
+ all(...params: unknown[]): T[];
16
+ values(...params: unknown[]): unknown[][];
17
+ finalize(): void;
18
+ }
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @syncular/dialect-bun-sqlite - Bun SQLite dialect for sync
3
+ *
4
+ * Provides a Kysely dialect for bun:sqlite with SerializePlugin
5
+ * for automatic JSON serialization/deserialization.
6
+ */
7
+
8
+ import { Database } from 'bun:sqlite';
9
+ import { SerializePlugin } from '@syncular/core';
10
+ import { Kysely } from 'kysely';
11
+ import { BunSqliteDialect } from 'kysely-bun-sqlite';
12
+
13
+ export interface BunSqliteOptions {
14
+ /** Path to SQLite database file, or ':memory:' for in-memory */
15
+ path: string;
16
+ }
17
+
18
+ /**
19
+ * Create a Kysely instance with Bun SQLite dialect and SerializePlugin.
20
+ *
21
+ * The SerializePlugin automatically handles JSON serialization/deserialization
22
+ * for object values, so you can work with JS objects directly.
23
+ *
24
+ * @example
25
+ * const db = createBunSqliteDb<MyDb>({ path: ':memory:' });
26
+ * // or
27
+ * const db = createBunSqliteDb<MyDb>({ path: './data.db' });
28
+ */
29
+ export function createBunSqliteDb<T>(options: BunSqliteOptions): Kysely<T> {
30
+ const database = new Database(options.path);
31
+
32
+ return new Kysely<T>({
33
+ dialect: new BunSqliteDialect({ database }),
34
+ plugins: [new SerializePlugin()],
35
+ });
36
+ }
37
+
38
+ /**
39
+ * Create the Bun SQLite dialect directly (without SerializePlugin).
40
+ *
41
+ * @example
42
+ * const dialect = createBunSqliteDialect({ path: ':memory:' });
43
+ * const db = new Kysely<MyDb>({ dialect, plugins: [new SerializePlugin()] });
44
+ */
45
+ export function createBunSqliteDialect(
46
+ options: BunSqliteOptions
47
+ ): BunSqliteDialect {
48
+ const database = new Database(options.path);
49
+ return new BunSqliteDialect({ database });
50
+ }
51
+
52
+ /**
53
+ * Create a SerializePlugin instance.
54
+ */
55
+ export function createSerializePlugin(): SerializePlugin {
56
+ return new SerializePlugin();
57
+ }