@dxos/sql-sqlite 0.0.0 → 0.8.4-main.1068cf700f
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/dist/lib/browser/OpfsWorker.mjs +8 -0
- package/dist/lib/browser/OpfsWorker.mjs.map +7 -0
- package/dist/lib/browser/SqlExport.mjs +8 -0
- package/dist/lib/browser/SqlExport.mjs.map +7 -0
- package/dist/lib/browser/SqlTransaction.mjs +10 -0
- package/dist/lib/browser/SqlTransaction.mjs.map +7 -0
- package/dist/lib/browser/SqliteClient.mjs +26 -0
- package/dist/lib/browser/SqliteClient.mjs.map +7 -0
- package/dist/lib/browser/SqliteMigrator.mjs +22 -0
- package/dist/lib/browser/SqliteMigrator.mjs.map +7 -0
- package/dist/lib/browser/chunk-FIQQSOZM.mjs +9 -0
- package/dist/lib/browser/chunk-FIQQSOZM.mjs.map +7 -0
- package/dist/lib/browser/chunk-IEP6GGEX.mjs +23 -0
- package/dist/lib/browser/chunk-IEP6GGEX.mjs.map +7 -0
- package/dist/lib/browser/chunk-KNRJ7JZS.mjs +310 -0
- package/dist/lib/browser/chunk-KNRJ7JZS.mjs.map +7 -0
- package/dist/lib/browser/chunk-KSWS2F3Y.mjs +26 -0
- package/dist/lib/browser/chunk-KSWS2F3Y.mjs.map +7 -0
- package/dist/lib/browser/chunk-P7Z655WE.mjs +24 -0
- package/dist/lib/browser/chunk-P7Z655WE.mjs.map +7 -0
- package/dist/lib/browser/chunk-Z3OVXBHI.mjs +93 -0
- package/dist/lib/browser/chunk-Z3OVXBHI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/platform/browser.mjs +28 -0
- package/dist/lib/browser/platform/browser.mjs.map +7 -0
- package/dist/lib/browser/platform/bun.mjs +27 -0
- package/dist/lib/browser/platform/bun.mjs.map +7 -0
- package/dist/lib/browser/platform/node.mjs +27 -0
- package/dist/lib/browser/platform/node.mjs.map +7 -0
- package/dist/lib/node-esm/OpfsWorker.mjs +9 -0
- package/dist/lib/node-esm/OpfsWorker.mjs.map +7 -0
- package/dist/lib/node-esm/SqlExport.mjs +9 -0
- package/dist/lib/node-esm/SqlExport.mjs.map +7 -0
- package/dist/lib/node-esm/SqlTransaction.mjs +11 -0
- package/dist/lib/node-esm/SqlTransaction.mjs.map +7 -0
- package/dist/lib/node-esm/SqliteClient.mjs +27 -0
- package/dist/lib/node-esm/SqliteClient.mjs.map +7 -0
- package/dist/lib/node-esm/SqliteMigrator.mjs +23 -0
- package/dist/lib/node-esm/SqliteMigrator.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs +24 -0
- package/dist/lib/node-esm/chunk-2SZHAWBN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-B2CW3GJX.mjs +11 -0
- package/dist/lib/node-esm/chunk-B2CW3GJX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FUMSJBSY.mjs +25 -0
- package/dist/lib/node-esm/chunk-FUMSJBSY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GREX34L7.mjs +94 -0
- package/dist/lib/node-esm/chunk-GREX34L7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IYXV4AY4.mjs +311 -0
- package/dist/lib/node-esm/chunk-IYXV4AY4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NLFDEJRO.mjs +27 -0
- package/dist/lib/node-esm/chunk-NLFDEJRO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/platform/browser.mjs +29 -0
- package/dist/lib/node-esm/platform/browser.mjs.map +7 -0
- package/dist/lib/node-esm/platform/bun.mjs +28 -0
- package/dist/lib/node-esm/platform/bun.mjs.map +7 -0
- package/dist/lib/node-esm/platform/node.mjs +28 -0
- package/dist/lib/node-esm/platform/node.mjs.map +7 -0
- package/dist/types/src/OpfsWorker.d.ts +2 -0
- package/dist/types/src/OpfsWorker.d.ts.map +1 -0
- package/dist/types/src/SqlExport.d.ts +11 -0
- package/dist/types/src/SqlExport.d.ts.map +1 -0
- package/dist/types/src/SqlTransaction.d.ts +33 -0
- package/dist/types/src/SqlTransaction.d.ts.map +1 -0
- package/dist/types/src/SqliteClient.d.ts +2 -0
- package/dist/types/src/SqliteClient.d.ts.map +1 -0
- package/dist/types/src/SqliteMigrator.d.ts +2 -0
- package/dist/types/src/SqliteMigrator.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +6 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/platform/browser.d.ts +15 -0
- package/dist/types/src/platform/browser.d.ts.map +1 -0
- package/dist/types/src/platform/bun.d.ts +14 -0
- package/dist/types/src/platform/bun.d.ts.map +1 -0
- package/dist/types/src/platform/node.d.ts +14 -0
- package/dist/types/src/platform/node.d.ts.map +1 -0
- package/dist/types/src/testing/opfs-worker.browser.test.d.ts +2 -0
- package/dist/types/src/testing/opfs-worker.browser.test.d.ts.map +1 -0
- package/dist/types/src/testing/opfs-worker.d.ts +2 -0
- package/dist/types/src/testing/opfs-worker.d.ts.map +1 -0
- package/dist/types/src/testing/sqlite-effect-idb.browser.test.d.ts +28 -0
- package/dist/types/src/testing/sqlite-effect-idb.browser.test.d.ts.map +1 -0
- package/dist/types/src/testing/sqlite-idb.browser.test.d.ts +2 -0
- package/dist/types/src/testing/sqlite-idb.browser.test.d.ts.map +1 -0
- package/dist/types/src/testing/sqlite-memory.browser.test.d.ts +2 -0
- package/dist/types/src/testing/sqlite-memory.browser.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +17 -8
- package/src/SqlTransaction.ts +44 -0
- package/src/index.ts +1 -0
- package/src/platform/browser.ts +22 -10
- package/src/platform/bun.ts +29 -10
- package/src/platform/node.ts +30 -11
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/sql-sqlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.4-main.1068cf700f",
|
|
4
4
|
"description": "Sqlite client",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "info@dxos.org",
|
|
9
13
|
"sideEffects": true,
|
|
@@ -39,6 +43,11 @@
|
|
|
39
43
|
"types": "./dist/types/src/SqlExport.d.ts",
|
|
40
44
|
"browser": "./dist/lib/browser/SqlExport.mjs",
|
|
41
45
|
"node": "./dist/lib/node-esm/SqlExport.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./SqlTransaction": {
|
|
48
|
+
"types": "./dist/types/src/SqlTransaction.d.ts",
|
|
49
|
+
"browser": "./dist/lib/browser/SqlTransaction.mjs",
|
|
50
|
+
"node": "./dist/lib/node-esm/SqlTransaction.mjs"
|
|
42
51
|
}
|
|
43
52
|
},
|
|
44
53
|
"files": [
|
|
@@ -47,15 +56,15 @@
|
|
|
47
56
|
],
|
|
48
57
|
"dependencies": {
|
|
49
58
|
"@dxos/wa-sqlite": "^0.2.1",
|
|
50
|
-
"@effect/experimental": "0.
|
|
51
|
-
"@effect/platform": "0.
|
|
52
|
-
"@effect/sql": "0.
|
|
53
|
-
"@effect/sql-sqlite-bun": "0.
|
|
54
|
-
"@effect/sql-sqlite-node": "0.
|
|
55
|
-
"effect": "3.19.
|
|
59
|
+
"@effect/experimental": "0.58.0",
|
|
60
|
+
"@effect/platform": "0.94.4",
|
|
61
|
+
"@effect/sql": "0.49.0",
|
|
62
|
+
"@effect/sql-sqlite-bun": "0.50.2",
|
|
63
|
+
"@effect/sql-sqlite-node": "0.50.1",
|
|
64
|
+
"effect": "3.19.16"
|
|
56
65
|
},
|
|
57
66
|
"devDependencies": {
|
|
58
|
-
"@effect/sql-sqlite-wasm": "0.
|
|
67
|
+
"@effect/sql-sqlite-wasm": "0.50.0",
|
|
59
68
|
"@effect/wa-sqlite": "^0.1.2"
|
|
60
69
|
},
|
|
61
70
|
"publishConfig": {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as SqlClient from '@effect/sql/SqlClient';
|
|
6
|
+
import type * as SqlError from '@effect/sql/SqlError';
|
|
7
|
+
import * as Context from 'effect/Context';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Layer from 'effect/Layer';
|
|
10
|
+
|
|
11
|
+
export interface Service {
|
|
12
|
+
withTransaction: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError.SqlError, R>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Provide a SQL transaction context.
|
|
17
|
+
*
|
|
18
|
+
* Should be used instead of SqlClient.withTransaction() or SQL native transaction syntaxes (e.g. `BEGIN; COMMIT;`).
|
|
19
|
+
*
|
|
20
|
+
* Platform runtimes (e.g. edge, Durable Objects) can provide alternative implementations by supplying a custom
|
|
21
|
+
* `SqlTransaction` layer.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const transaction = yield* SqlTransaction;
|
|
26
|
+
* yield* transaction.withTransaction(Effect.gen(function* () {
|
|
27
|
+
* yield* sql.execute('SELECT * FROM users');
|
|
28
|
+
* }));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class SqlTransaction extends Context.Tag('@dxos/sql-sqlite/SqlTransaction')<SqlTransaction, Service>() {}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Default `SqlTransaction` layer backed by `SqlClient.withTransaction`.
|
|
35
|
+
*/
|
|
36
|
+
export const layer: Layer.Layer<SqlTransaction, never, SqlClient.SqlClient> = Layer.effect(
|
|
37
|
+
SqlTransaction,
|
|
38
|
+
Effect.map(
|
|
39
|
+
SqlClient.SqlClient,
|
|
40
|
+
(sql: SqlClient.SqlClient): Context.Tag.Service<SqlTransaction> => ({
|
|
41
|
+
withTransaction: (self) => sql.withTransaction(self),
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
);
|
package/src/index.ts
CHANGED
|
@@ -6,3 +6,4 @@ export * from '@effect/sql-sqlite-wasm';
|
|
|
6
6
|
export * as OpfsWorker from '@effect/sql-sqlite-wasm/OpfsWorker';
|
|
7
7
|
export * as SqliteClient from '@effect/sql-sqlite-wasm/SqliteClient';
|
|
8
8
|
export * as SqliteMigrator from '@effect/sql-sqlite-wasm/SqliteMigrator';
|
|
9
|
+
export * as SqlTransaction from './SqlTransaction';
|
package/src/platform/browser.ts
CHANGED
|
@@ -11,17 +11,29 @@ import * as Layer from 'effect/Layer';
|
|
|
11
11
|
|
|
12
12
|
import * as SqlExport from '../SqlExport';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
14
|
+
export const sqlExportLayer: Layer.Layer<SqlExport.SqlExport, SqlError.SqlError, SqliteClient.SqliteClient> =
|
|
15
|
+
Layer.effect(
|
|
16
|
+
SqlExport.SqlExport,
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const sql = yield* SqliteClient.SqliteClient;
|
|
19
|
+
return {
|
|
20
|
+
export: sql.export,
|
|
21
|
+
} satisfies SqlExport.Service;
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
23
24
|
|
|
24
25
|
export const layerMemory: Layer.Layer<
|
|
25
26
|
SqlClient.SqlClient | SqlExport.SqlExport,
|
|
26
27
|
ConfigError.ConfigError | SqlError.SqlError
|
|
27
|
-
> =
|
|
28
|
+
> = sqlExportLayer.pipe(Layer.provideMerge(SqliteClient.layerMemory({})));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* File-based SQLite is not available in browser.
|
|
32
|
+
* Use OPFS worker for persistent storage in browser environments.
|
|
33
|
+
* @throws Always throws - use OPFS worker instead.
|
|
34
|
+
*/
|
|
35
|
+
export const layerFile = (
|
|
36
|
+
_filename: string,
|
|
37
|
+
): Layer.Layer<SqlClient.SqlClient | SqlExport.SqlExport, ConfigError.ConfigError | SqlError.SqlError> => {
|
|
38
|
+
throw new Error('layerFile is not available in browser. Use OPFS worker for persistent storage.');
|
|
39
|
+
};
|
package/src/platform/bun.ts
CHANGED
|
@@ -11,23 +11,42 @@ import * as Layer from 'effect/Layer';
|
|
|
11
11
|
|
|
12
12
|
import * as SqlExport from '../SqlExport';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
14
|
+
export const sqlExportLayer: Layer.Layer<SqlExport.SqlExport, SqlError.SqlError, SqliteClient.SqliteClient> =
|
|
15
|
+
Layer.effect(
|
|
16
|
+
SqlExport.SqlExport,
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const sql = yield* SqliteClient.SqliteClient;
|
|
19
|
+
return {
|
|
20
|
+
export: sql.export,
|
|
21
|
+
} satisfies SqlExport.Service;
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
23
24
|
|
|
24
25
|
export const layerMemory: Layer.Layer<
|
|
25
26
|
SqlClient.SqlClient | SqliteClient.SqliteClient | SqlExport.SqlExport,
|
|
26
27
|
ConfigError.ConfigError | SqlError.SqlError
|
|
27
|
-
> =
|
|
28
|
+
> = sqlExportLayer.pipe(
|
|
28
29
|
Layer.provideMerge(
|
|
29
30
|
SqliteClient.layer({
|
|
30
31
|
filename: ':memory:',
|
|
31
32
|
}),
|
|
32
33
|
),
|
|
33
34
|
);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a file-based SQLite layer for Bun.
|
|
38
|
+
* Unlike layerMemory, this persists data across runtime restarts.
|
|
39
|
+
*/
|
|
40
|
+
export const layerFile = (
|
|
41
|
+
filename: string,
|
|
42
|
+
): Layer.Layer<
|
|
43
|
+
SqlClient.SqlClient | SqliteClient.SqliteClient | SqlExport.SqlExport,
|
|
44
|
+
ConfigError.ConfigError | SqlError.SqlError
|
|
45
|
+
> =>
|
|
46
|
+
sqlExportLayer.pipe(
|
|
47
|
+
Layer.provideMerge(
|
|
48
|
+
SqliteClient.layer({
|
|
49
|
+
filename,
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
52
|
+
);
|
package/src/platform/node.ts
CHANGED
|
@@ -11,23 +11,42 @@ import * as Layer from 'effect/Layer';
|
|
|
11
11
|
|
|
12
12
|
import * as SqlExport from '../SqlExport';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
14
|
+
export const sqlExportLayer: Layer.Layer<SqlExport.SqlExport, SqlError.SqlError, SqliteClient.SqliteClient> =
|
|
15
|
+
Layer.effect(
|
|
16
|
+
SqlExport.SqlExport,
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const sql = yield* SqliteClient.SqliteClient;
|
|
19
|
+
return {
|
|
20
|
+
export: sql.export,
|
|
21
|
+
} satisfies SqlExport.Service;
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
23
24
|
|
|
24
25
|
export const layerMemory: Layer.Layer<
|
|
25
|
-
SqlClient.SqlClient | SqliteClient.SqliteClient,
|
|
26
|
+
SqlClient.SqlClient | SqliteClient.SqliteClient | SqlExport.SqlExport,
|
|
26
27
|
ConfigError.ConfigError | SqlError.SqlError
|
|
27
|
-
> =
|
|
28
|
+
> = sqlExportLayer.pipe(
|
|
28
29
|
Layer.provideMerge(
|
|
29
30
|
SqliteClient.layer({
|
|
30
31
|
filename: ':memory:',
|
|
31
32
|
}),
|
|
32
33
|
),
|
|
33
34
|
);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates a file-based SQLite layer for Node.js.
|
|
38
|
+
* Unlike layerMemory, this persists data across runtime restarts.
|
|
39
|
+
*/
|
|
40
|
+
export const layerFile = (
|
|
41
|
+
filename: string,
|
|
42
|
+
): Layer.Layer<
|
|
43
|
+
SqlClient.SqlClient | SqliteClient.SqliteClient | SqlExport.SqlExport,
|
|
44
|
+
ConfigError.ConfigError | SqlError.SqlError
|
|
45
|
+
> =>
|
|
46
|
+
sqlExportLayer.pipe(
|
|
47
|
+
Layer.provideMerge(
|
|
48
|
+
SqliteClient.layer({
|
|
49
|
+
filename,
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
52
|
+
);
|