@effect/sql-sqlite-bun 4.0.0-beta.65 → 4.0.0-beta.67
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/SqliteClient.d.ts +24 -8
- package/dist/SqliteClient.d.ts.map +1 -1
- package/dist/SqliteClient.js +34 -7
- package/dist/SqliteClient.js.map +1 -1
- package/dist/SqliteMigrator.d.ts +28 -4
- package/dist/SqliteMigrator.d.ts.map +1 -1
- package/dist/SqliteMigrator.js +7 -3
- package/dist/SqliteMigrator.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/package.json +5 -5
- package/src/SqliteClient.ts +43 -10
- package/src/SqliteMigrator.ts +28 -4
- package/src/index.ts +3 -3
package/dist/SqliteClient.d.ts
CHANGED
|
@@ -7,18 +7,24 @@ import * as Reactivity from "effect/unstable/reactivity/Reactivity";
|
|
|
7
7
|
import * as Client from "effect/unstable/sql/SqlClient";
|
|
8
8
|
import { SqlError } from "effect/unstable/sql/SqlError";
|
|
9
9
|
/**
|
|
10
|
+
* Runtime type identifier used to mark Bun `SqliteClient` values.
|
|
11
|
+
*
|
|
10
12
|
* @category type ids
|
|
11
|
-
* @since
|
|
13
|
+
* @since 4.0.0
|
|
12
14
|
*/
|
|
13
15
|
export declare const TypeId: TypeId;
|
|
14
16
|
/**
|
|
17
|
+
* Type-level identifier used to mark Bun `SqliteClient` values.
|
|
18
|
+
*
|
|
15
19
|
* @category type ids
|
|
16
|
-
* @since
|
|
20
|
+
* @since 4.0.0
|
|
17
21
|
*/
|
|
18
22
|
export type TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
|
|
19
23
|
/**
|
|
24
|
+
* Bun SQLite client service, extending `SqlClient` with database export and extension loading helpers. `updateValues` is not supported.
|
|
25
|
+
*
|
|
20
26
|
* @category models
|
|
21
|
-
* @since
|
|
27
|
+
* @since 4.0.0
|
|
22
28
|
*/
|
|
23
29
|
export interface SqliteClient extends Client.SqlClient {
|
|
24
30
|
readonly [TypeId]: TypeId;
|
|
@@ -29,13 +35,17 @@ export interface SqliteClient extends Client.SqlClient {
|
|
|
29
35
|
readonly updateValues: never;
|
|
30
36
|
}
|
|
31
37
|
/**
|
|
38
|
+
* Context tag used to access the Bun `SqliteClient` service.
|
|
39
|
+
*
|
|
32
40
|
* @category tags
|
|
33
|
-
* @since
|
|
41
|
+
* @since 4.0.0
|
|
34
42
|
*/
|
|
35
43
|
export declare const SqliteClient: Context.Service<SqliteClient, SqliteClient>;
|
|
36
44
|
/**
|
|
45
|
+
* Configuration for a Bun SQLite client, including filename, open mode flags, WAL behavior, span attributes, and query/result name transforms.
|
|
46
|
+
*
|
|
37
47
|
* @category models
|
|
38
|
-
* @since
|
|
48
|
+
* @since 4.0.0
|
|
39
49
|
*/
|
|
40
50
|
export interface SqliteClientConfig {
|
|
41
51
|
readonly filename: string;
|
|
@@ -48,18 +58,24 @@ export interface SqliteClientConfig {
|
|
|
48
58
|
readonly transformQueryNames?: ((str: string) => string) | undefined;
|
|
49
59
|
}
|
|
50
60
|
/**
|
|
61
|
+
* Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
|
|
62
|
+
*
|
|
51
63
|
* @category constructor
|
|
52
|
-
* @since
|
|
64
|
+
* @since 4.0.0
|
|
53
65
|
*/
|
|
54
66
|
export declare const make: (options: SqliteClientConfig) => Effect.Effect<SqliteClient, never, Scope.Scope | Reactivity.Reactivity>;
|
|
55
67
|
/**
|
|
68
|
+
* Creates a layer from a `Config`-wrapped Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
|
|
69
|
+
*
|
|
56
70
|
* @category layers
|
|
57
|
-
* @since
|
|
71
|
+
* @since 4.0.0
|
|
58
72
|
*/
|
|
59
73
|
export declare const layerConfig: (config: Config.Wrap<SqliteClientConfig>) => Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError>;
|
|
60
74
|
/**
|
|
75
|
+
* Creates a layer from a concrete Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
|
|
76
|
+
*
|
|
61
77
|
* @category layers
|
|
62
|
-
* @since
|
|
78
|
+
* @since 4.0.0
|
|
63
79
|
*/
|
|
64
80
|
export declare const layer: (config: SqliteClientConfig) => Layer.Layer<SqliteClient | Client.SqlClient>;
|
|
65
81
|
//# sourceMappingURL=SqliteClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAEvD,OAAO,EAAuB,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAQ5E;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,MAA+C,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,sCAAsC,CAAA;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,SAAS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACpD,QAAQ,CAAC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM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kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
|
package/dist/SqliteClient.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
3
|
+
*
|
|
4
|
+
* This module provides constructors and layers for using a Bun-managed SQLite database as both the
|
|
5
|
+
* SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
|
|
6
|
+
* file-backed or in-memory databases in Bun applications, local development tools, migrations,
|
|
7
|
+
* integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
|
|
8
|
+
* SQLite-specific helpers such as database export and native extension loading.
|
|
9
|
+
*
|
|
10
|
+
* Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
|
|
11
|
+
* is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
|
|
12
|
+
* so set `disableWAL` when opening read-only databases or when the database file or directory cannot
|
|
13
|
+
* be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
|
|
14
|
+
* the transaction scope, so concurrent fibers using the same client wait until it completes, while
|
|
15
|
+
* separate database handles or processes can still contend for SQLite write locks. Safe integer
|
|
16
|
+
* handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
|
|
17
|
+
* SQLite does not support `updateValues`.
|
|
18
|
+
*
|
|
19
|
+
* @since 4.0.0
|
|
3
20
|
*/
|
|
4
21
|
import { Database } from "bun:sqlite";
|
|
5
22
|
import * as Config from "effect/Config";
|
|
@@ -21,18 +38,24 @@ const classifyError = (cause, message, operation) => classifySqliteError(cause,
|
|
|
21
38
|
operation
|
|
22
39
|
});
|
|
23
40
|
/**
|
|
41
|
+
* Runtime type identifier used to mark Bun `SqliteClient` values.
|
|
42
|
+
*
|
|
24
43
|
* @category type ids
|
|
25
|
-
* @since
|
|
44
|
+
* @since 4.0.0
|
|
26
45
|
*/
|
|
27
46
|
export const TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
|
|
28
47
|
/**
|
|
48
|
+
* Context tag used to access the Bun `SqliteClient` service.
|
|
49
|
+
*
|
|
29
50
|
* @category tags
|
|
30
|
-
* @since
|
|
51
|
+
* @since 4.0.0
|
|
31
52
|
*/
|
|
32
53
|
export const SqliteClient = /*#__PURE__*/Context.Service("@effect/sql-sqlite-bun/Client");
|
|
33
54
|
/**
|
|
55
|
+
* Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
|
|
56
|
+
*
|
|
34
57
|
* @category constructor
|
|
35
|
-
* @since
|
|
58
|
+
* @since 4.0.0
|
|
36
59
|
*/
|
|
37
60
|
export const make = options => Effect.gen(function* () {
|
|
38
61
|
const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
|
|
@@ -125,13 +148,17 @@ export const make = options => Effect.gen(function* () {
|
|
|
125
148
|
});
|
|
126
149
|
});
|
|
127
150
|
/**
|
|
151
|
+
* Creates a layer from a `Config`-wrapped Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
|
|
152
|
+
*
|
|
128
153
|
* @category layers
|
|
129
|
-
* @since
|
|
154
|
+
* @since 4.0.0
|
|
130
155
|
*/
|
|
131
|
-
export const layerConfig = config => Layer.effectContext(Config.unwrap(config).
|
|
156
|
+
export const layerConfig = config => Layer.effectContext(Config.unwrap(config).pipe(Effect.flatMap(make), Effect.map(client => Context.make(SqliteClient, client).pipe(Context.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));
|
|
132
157
|
/**
|
|
158
|
+
* Creates a layer from a concrete Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
|
|
159
|
+
*
|
|
133
160
|
* @category layers
|
|
134
|
-
* @since
|
|
161
|
+
* @since 4.0.0
|
|
135
162
|
*/
|
|
136
163
|
export const layer = config => Layer.effectContext(Effect.map(make(config), client => Context.make(SqliteClient, client).pipe(Context.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
|
|
137
164
|
//# sourceMappingURL=SqliteClient.js.map
|
package/dist/SqliteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.js","names":["Database","Config","Context","Effect","Fiber","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","filename","readonly","readwrite","create","addFinalizer","sync","close","disableWAL","run","sql","params","withFiber","fiber","statement","query","useSafeIntegers","get","context","SafeIntegers","safeIntegers","succeed","all","fail","reason","runValues","values","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","_sql","_params","die","export","try","serialize","catch","loadExtension","path","semaphore","connection","acquirer","withPermits","transactionAcquirer","uninterruptibleMask","restore","getCurrent","scope","getUnsafe","as","tap","take","release","Object","assign","spanAttributes","entries","config","flatMap","_","layerConfig","effectContext","unwrap","
|
|
1
|
+
{"version":3,"file":"SqliteClient.js","names":["Database","Config","Context","Effect","Fiber","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","filename","readonly","readwrite","create","addFinalizer","sync","close","disableWAL","run","sql","params","withFiber","fiber","statement","query","useSafeIntegers","get","context","SafeIntegers","safeIntegers","succeed","all","fail","reason","runValues","values","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","_sql","_params","die","export","try","serialize","catch","loadExtension","path","semaphore","connection","acquirer","withPermits","transactionAcquirer","uninterruptibleMask","restore","getCurrent","scope","getUnsafe","as","tap","take","release","Object","assign","spanAttributes","entries","config","flatMap","_","layerConfig","effectContext","unwrap","p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C/F,KAAK,CAACmG,OAAO,CAAC/F,UAAU,CAACgG,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAMA,KAAK,GAChBX,MAA0B,IAE1BzF,KAAK,CAAC6F,aAAa,CACjBhG,MAAM,CAAC4D,GAAG,CAACxC,IAAI,CAACwE,MAAM,CAAC,EAAGO,MAAM,IAC9BpG,OAAO,CAACqB,IAAI,CAACF,YAAY,EAAEiF,MAAM,CAAC,CAACD,IAAI,CACrCnG,OAAO,CAACqG,GAAG,CAAC5F,MAAM,CAAC6F,SAAS,EAAEF,MAAM,CAAC,CACtC,CAAC,CACL,CAACD,IAAI,CAAC/F,KAAK,CAACmG,OAAO,CAAC/F,UAAU,CAACgG,KAAK,CAAC,CAAC","ignoreList":[]}
|
package/dist/SqliteMigrator.d.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Utilities for applying Effect SQL migrations to Bun SQLite databases.
|
|
3
|
+
*
|
|
4
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
5
|
+
* provides `run` and `layer` helpers for applying ordered migrations through
|
|
6
|
+
* the current Bun-backed SQLite `SqlClient`. It is typically used at
|
|
7
|
+
* application startup, in deployment or setup scripts that prepare a local
|
|
8
|
+
* SQLite file, in integration tests with temporary database files, or in layer
|
|
9
|
+
* graphs that must install the schema before dependent services are acquired.
|
|
10
|
+
*
|
|
11
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
12
|
+
* using the shared `<id>_<name>` file or record-key convention. Only migrations
|
|
13
|
+
* with an id greater than the latest recorded id are applied, so every client
|
|
14
|
+
* involved in startup should point at the same SQLite filename and use a
|
|
15
|
+
* writable Bun SQLite configuration. The Bun client enables WAL by default and
|
|
16
|
+
* serializes access through a single `bun:sqlite` database handle, but separate
|
|
17
|
+
* handles or processes can still contend for SQLite write locks. Bun's SQLite
|
|
18
|
+
* driver runs statements synchronously, so large migration sets can block the
|
|
19
|
+
* invoking runtime thread, and this adapter does not currently write SQLite
|
|
20
|
+
* schema dumps for `schemaDirectory`.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.0.0
|
|
3
23
|
*/
|
|
4
24
|
import type * as Effect from "effect/Effect";
|
|
5
25
|
import * as Layer from "effect/Layer";
|
|
@@ -7,17 +27,21 @@ import * as Migrator from "effect/unstable/sql/Migrator";
|
|
|
7
27
|
import type * as Client from "effect/unstable/sql/SqlClient";
|
|
8
28
|
import type { SqlError } from "effect/unstable/sql/SqlError";
|
|
9
29
|
/**
|
|
10
|
-
* @since
|
|
30
|
+
* @since 4.0.0
|
|
11
31
|
*/
|
|
12
32
|
export * from "effect/unstable/sql/Migrator";
|
|
13
33
|
/**
|
|
34
|
+
* Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
|
|
35
|
+
*
|
|
14
36
|
* @category constructor
|
|
15
|
-
* @since
|
|
37
|
+
* @since 4.0.0
|
|
16
38
|
*/
|
|
17
39
|
export declare const run: <R2 = never>(options: Migrator.MigratorOptions<R2>) => Effect.Effect<ReadonlyArray<readonly [id: number, name: string]>, Migrator.MigrationError | SqlError, Client.SqlClient | R2>;
|
|
18
40
|
/**
|
|
41
|
+
* Creates a layer that runs the configured SQL migrations during layer construction.
|
|
42
|
+
*
|
|
19
43
|
* @category constructor
|
|
20
|
-
* @since
|
|
44
|
+
* @since 4.0.0
|
|
21
45
|
*/
|
|
22
46
|
export declare const layer: <R>(options: Migrator.MigratorOptions<R>) => Layer.Layer<never, SqlError | Migrator.MigrationError, Client.SqlClient | R>;
|
|
23
47
|
//# sourceMappingURL=SqliteMigrator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteMigrator.d.ts","sourceRoot":"","sources":["../src/SqliteMigrator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteMigrator.d.ts","sourceRoot":"","sources":["../src/SqliteMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,8BAA8B,CAAA;AACxD,OAAO,KAAK,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAE5D;;GAEG;AACH,cAAc,8BAA8B,CAAA;AAE5C;;;;;GAKG;AACH,eAAO,MAAM,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,EAC3B,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,KAClC,MAAM,CAAC,MAAM,CAChB,aAAa,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAClD,QAAQ,CAAC,cAAc,GAAG,QAAQ,EAClC,MAAM,CAAC,SAAS,GAAG,EAAE,CA2CrB,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EACrB,SAAS,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,KACnC,KAAK,CAAC,KAAK,CACZ,KAAK,EACL,QAAQ,GAAG,QAAQ,CAAC,cAAc,EAClC,MAAM,CAAC,SAAS,GAAG,CAAC,CACgB,CAAA"}
|
package/dist/SqliteMigrator.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as Migrator from "effect/unstable/sql/Migrator";
|
|
3
3
|
/**
|
|
4
|
-
* @since
|
|
4
|
+
* @since 4.0.0
|
|
5
5
|
*/
|
|
6
6
|
export * from "effect/unstable/sql/Migrator";
|
|
7
7
|
/**
|
|
8
|
+
* Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
|
|
9
|
+
*
|
|
8
10
|
* @category constructor
|
|
9
|
-
* @since
|
|
11
|
+
* @since 4.0.0
|
|
10
12
|
*/
|
|
11
13
|
export const run = /*#__PURE__*/Migrator.make({
|
|
12
14
|
// dumpSchema(path, table) {
|
|
@@ -52,8 +54,10 @@ export const run = /*#__PURE__*/Migrator.make({
|
|
|
52
54
|
// }
|
|
53
55
|
});
|
|
54
56
|
/**
|
|
57
|
+
* Creates a layer that runs the configured SQL migrations during layer construction.
|
|
58
|
+
*
|
|
55
59
|
* @category constructor
|
|
56
|
-
* @since
|
|
60
|
+
* @since 4.0.0
|
|
57
61
|
*/
|
|
58
62
|
export const layer = options => Layer.effectDiscard(run(options));
|
|
59
63
|
//# sourceMappingURL=SqliteMigrator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/SqliteMigrator.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqliteMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/SqliteMigrator.ts"],"sourcesContent":[null],"mappings":"AAwBA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,8BAA8B;AAIxD;;;AAGA,cAAc,8BAA8B;AAE5C;;;;;;AAMA,OAAO,MAAMC,GAAG,gBAMZD,QAAQ,CAACE,IAAI,CAAC;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AAAA,CACD,CAAC;AAEF;;;;;;AAMA,OAAO,MAAMC,KAAK,GAChBC,OAAoC,IAKjCL,KAAK,CAACM,aAAa,CAACJ,GAAG,CAACG,OAAO,CAAC,CAAC","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* @since
|
|
5
|
+
* @since 4.0.0
|
|
6
6
|
*/
|
|
7
7
|
export * as SqliteClient from "./SqliteClient.ts";
|
|
8
8
|
/**
|
|
9
|
-
* @since
|
|
9
|
+
* @since 4.0.0
|
|
10
10
|
*/
|
|
11
11
|
export * as SqliteMigrator from "./SqliteMigrator.ts";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
* @since
|
|
6
|
+
* @since 4.0.0
|
|
7
7
|
*/
|
|
8
8
|
export * as SqliteClient from "./SqliteClient.js";
|
|
9
9
|
/**
|
|
10
|
-
* @since
|
|
10
|
+
* @since 4.0.0
|
|
11
11
|
*/
|
|
12
12
|
export * as SqliteMigrator from "./SqliteMigrator.js";
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-sqlite-bun",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A SQLite toolkit for Effect",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"provenance": true
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/bun": "^1.3.
|
|
47
|
-
"@effect/platform-bun": "^4.0.0-beta.
|
|
48
|
-
"effect": "^4.0.0-beta.
|
|
46
|
+
"@types/bun": "^1.3.13",
|
|
47
|
+
"@effect/platform-bun": "^4.0.0-beta.67",
|
|
48
|
+
"effect": "^4.0.0-beta.67"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"effect": "^4.0.0-beta.
|
|
51
|
+
"effect": "^4.0.0-beta.67"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"codegen": "effect-utils codegen",
|
package/src/SqliteClient.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
|
|
3
|
+
*
|
|
4
|
+
* This module provides constructors and layers for using a Bun-managed SQLite database as both the
|
|
5
|
+
* SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
|
|
6
|
+
* file-backed or in-memory databases in Bun applications, local development tools, migrations,
|
|
7
|
+
* integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
|
|
8
|
+
* SQLite-specific helpers such as database export and native extension loading.
|
|
9
|
+
*
|
|
10
|
+
* Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
|
|
11
|
+
* is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
|
|
12
|
+
* so set `disableWAL` when opening read-only databases or when the database file or directory cannot
|
|
13
|
+
* be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
|
|
14
|
+
* the transaction scope, so concurrent fibers using the same client wait until it completes, while
|
|
15
|
+
* separate database handles or processes can still contend for SQLite write locks. Safe integer
|
|
16
|
+
* handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
|
|
17
|
+
* SQLite does not support `updateValues`.
|
|
18
|
+
*
|
|
19
|
+
* @since 4.0.0
|
|
3
20
|
*/
|
|
4
21
|
import { Database } from "bun:sqlite"
|
|
5
22
|
import * as Config from "effect/Config"
|
|
@@ -23,20 +40,26 @@ const classifyError = (cause: unknown, message: string, operation: string) =>
|
|
|
23
40
|
classifySqliteError(cause, { message, operation })
|
|
24
41
|
|
|
25
42
|
/**
|
|
43
|
+
* Runtime type identifier used to mark Bun `SqliteClient` values.
|
|
44
|
+
*
|
|
26
45
|
* @category type ids
|
|
27
|
-
* @since
|
|
46
|
+
* @since 4.0.0
|
|
28
47
|
*/
|
|
29
48
|
export const TypeId: TypeId = "~@effect/sql-sqlite-bun/SqliteClient"
|
|
30
49
|
|
|
31
50
|
/**
|
|
51
|
+
* Type-level identifier used to mark Bun `SqliteClient` values.
|
|
52
|
+
*
|
|
32
53
|
* @category type ids
|
|
33
|
-
* @since
|
|
54
|
+
* @since 4.0.0
|
|
34
55
|
*/
|
|
35
56
|
export type TypeId = "~@effect/sql-sqlite-bun/SqliteClient"
|
|
36
57
|
|
|
37
58
|
/**
|
|
59
|
+
* Bun SQLite client service, extending `SqlClient` with database export and extension loading helpers. `updateValues` is not supported.
|
|
60
|
+
*
|
|
38
61
|
* @category models
|
|
39
|
-
* @since
|
|
62
|
+
* @since 4.0.0
|
|
40
63
|
*/
|
|
41
64
|
export interface SqliteClient extends Client.SqlClient {
|
|
42
65
|
readonly [TypeId]: TypeId
|
|
@@ -49,14 +72,18 @@ export interface SqliteClient extends Client.SqlClient {
|
|
|
49
72
|
}
|
|
50
73
|
|
|
51
74
|
/**
|
|
75
|
+
* Context tag used to access the Bun `SqliteClient` service.
|
|
76
|
+
*
|
|
52
77
|
* @category tags
|
|
53
|
-
* @since
|
|
78
|
+
* @since 4.0.0
|
|
54
79
|
*/
|
|
55
80
|
export const SqliteClient = Context.Service<SqliteClient>("@effect/sql-sqlite-bun/Client")
|
|
56
81
|
|
|
57
82
|
/**
|
|
83
|
+
* Configuration for a Bun SQLite client, including filename, open mode flags, WAL behavior, span attributes, and query/result name transforms.
|
|
84
|
+
*
|
|
58
85
|
* @category models
|
|
59
|
-
* @since
|
|
86
|
+
* @since 4.0.0
|
|
60
87
|
*/
|
|
61
88
|
export interface SqliteClientConfig {
|
|
62
89
|
readonly filename: string
|
|
@@ -77,8 +104,10 @@ interface SqliteConnection extends Connection {
|
|
|
77
104
|
}
|
|
78
105
|
|
|
79
106
|
/**
|
|
107
|
+
* Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
|
|
108
|
+
*
|
|
80
109
|
* @category constructor
|
|
81
|
-
* @since
|
|
110
|
+
* @since 4.0.0
|
|
82
111
|
*/
|
|
83
112
|
export const make = (
|
|
84
113
|
options: SqliteClientConfig
|
|
@@ -203,14 +232,16 @@ export const make = (
|
|
|
203
232
|
})
|
|
204
233
|
|
|
205
234
|
/**
|
|
235
|
+
* Creates a layer from a `Config`-wrapped Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
|
|
236
|
+
*
|
|
206
237
|
* @category layers
|
|
207
|
-
* @since
|
|
238
|
+
* @since 4.0.0
|
|
208
239
|
*/
|
|
209
240
|
export const layerConfig = (
|
|
210
241
|
config: Config.Wrap<SqliteClientConfig>
|
|
211
242
|
): Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError> =>
|
|
212
243
|
Layer.effectContext(
|
|
213
|
-
Config.unwrap(config).
|
|
244
|
+
Config.unwrap(config).pipe(
|
|
214
245
|
Effect.flatMap(make),
|
|
215
246
|
Effect.map((client) =>
|
|
216
247
|
Context.make(SqliteClient, client).pipe(
|
|
@@ -221,8 +252,10 @@ export const layerConfig = (
|
|
|
221
252
|
).pipe(Layer.provide(Reactivity.layer))
|
|
222
253
|
|
|
223
254
|
/**
|
|
255
|
+
* Creates a layer from a concrete Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
|
|
256
|
+
*
|
|
224
257
|
* @category layers
|
|
225
|
-
* @since
|
|
258
|
+
* @since 4.0.0
|
|
226
259
|
*/
|
|
227
260
|
export const layer = (
|
|
228
261
|
config: SqliteClientConfig
|
package/src/SqliteMigrator.ts
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Utilities for applying Effect SQL migrations to Bun SQLite databases.
|
|
3
|
+
*
|
|
4
|
+
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
5
|
+
* provides `run` and `layer` helpers for applying ordered migrations through
|
|
6
|
+
* the current Bun-backed SQLite `SqlClient`. It is typically used at
|
|
7
|
+
* application startup, in deployment or setup scripts that prepare a local
|
|
8
|
+
* SQLite file, in integration tests with temporary database files, or in layer
|
|
9
|
+
* graphs that must install the schema before dependent services are acquired.
|
|
10
|
+
*
|
|
11
|
+
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
12
|
+
* using the shared `<id>_<name>` file or record-key convention. Only migrations
|
|
13
|
+
* with an id greater than the latest recorded id are applied, so every client
|
|
14
|
+
* involved in startup should point at the same SQLite filename and use a
|
|
15
|
+
* writable Bun SQLite configuration. The Bun client enables WAL by default and
|
|
16
|
+
* serializes access through a single `bun:sqlite` database handle, but separate
|
|
17
|
+
* handles or processes can still contend for SQLite write locks. Bun's SQLite
|
|
18
|
+
* driver runs statements synchronously, so large migration sets can block the
|
|
19
|
+
* invoking runtime thread, and this adapter does not currently write SQLite
|
|
20
|
+
* schema dumps for `schemaDirectory`.
|
|
21
|
+
*
|
|
22
|
+
* @since 4.0.0
|
|
3
23
|
*/
|
|
4
24
|
import type * as Effect from "effect/Effect"
|
|
5
25
|
import * as Layer from "effect/Layer"
|
|
@@ -8,13 +28,15 @@ import type * as Client from "effect/unstable/sql/SqlClient"
|
|
|
8
28
|
import type { SqlError } from "effect/unstable/sql/SqlError"
|
|
9
29
|
|
|
10
30
|
/**
|
|
11
|
-
* @since
|
|
31
|
+
* @since 4.0.0
|
|
12
32
|
*/
|
|
13
33
|
export * from "effect/unstable/sql/Migrator"
|
|
14
34
|
|
|
15
35
|
/**
|
|
36
|
+
* Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
|
|
37
|
+
*
|
|
16
38
|
* @category constructor
|
|
17
|
-
* @since
|
|
39
|
+
* @since 4.0.0
|
|
18
40
|
*/
|
|
19
41
|
export const run: <R2 = never>(
|
|
20
42
|
options: Migrator.MigratorOptions<R2>
|
|
@@ -67,8 +89,10 @@ export const run: <R2 = never>(
|
|
|
67
89
|
})
|
|
68
90
|
|
|
69
91
|
/**
|
|
92
|
+
* Creates a layer that runs the configured SQL migrations during layer construction.
|
|
93
|
+
*
|
|
70
94
|
* @category constructor
|
|
71
|
-
* @since
|
|
95
|
+
* @since 4.0.0
|
|
72
96
|
*/
|
|
73
97
|
export const layer = <R>(
|
|
74
98
|
options: Migrator.MigratorOptions<R>
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @since
|
|
2
|
+
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @since
|
|
8
|
+
* @since 4.0.0
|
|
9
9
|
*/
|
|
10
10
|
export * as SqliteClient from "./SqliteClient.ts"
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @since
|
|
13
|
+
* @since 4.0.0
|
|
14
14
|
*/
|
|
15
15
|
export * as SqliteMigrator from "./SqliteMigrator.ts"
|