@effect/sql-sqlite-bun 4.0.0-beta.7 → 4.0.0-beta.70

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,24 +1,30 @@
1
1
  import * as Config from "effect/Config";
2
+ import * as Context from "effect/Context";
2
3
  import * as Effect from "effect/Effect";
3
4
  import * as Layer from "effect/Layer";
4
5
  import * as Scope from "effect/Scope";
5
- import * as ServiceMap from "effect/ServiceMap";
6
6
  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
- * @category type ids
11
- * @since 1.0.0
10
+ * Runtime type identifier used to mark Bun `SqliteClient` values.
11
+ *
12
+ * @category type IDs
13
+ * @since 4.0.0
12
14
  */
13
15
  export declare const TypeId: TypeId;
14
16
  /**
15
- * @category type ids
16
- * @since 1.0.0
17
+ * Type-level identifier used to mark Bun `SqliteClient` values.
18
+ *
19
+ * @category type IDs
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 1.0.0
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 1.0.0
41
+ * @since 4.0.0
34
42
  */
35
- export declare const SqliteClient: ServiceMap.Service<SqliteClient, SqliteClient>;
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 1.0.0
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
  /**
51
- * @category constructor
52
- * @since 1.0.0
61
+ * Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
62
+ *
63
+ * @category constructors
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 1.0.0
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 1.0.0
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":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OA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J;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KACtC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAUzB,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,QAAQ,kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
@@ -1,34 +1,61 @@
1
1
  /**
2
- * @since 1.0.0
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
+ import * as Context from "effect/Context";
6
24
  import * as Effect from "effect/Effect";
7
25
  import * as Fiber from "effect/Fiber";
8
26
  import { identity } from "effect/Function";
9
27
  import * as Layer from "effect/Layer";
10
28
  import * as Scope from "effect/Scope";
11
29
  import * as Semaphore from "effect/Semaphore";
12
- import * as ServiceMap from "effect/ServiceMap";
13
30
  import * as Stream from "effect/Stream";
14
31
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
15
32
  import * as Client from "effect/unstable/sql/SqlClient";
16
- import { SqlError } from "effect/unstable/sql/SqlError";
33
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError";
17
34
  import * as Statement from "effect/unstable/sql/Statement";
18
35
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
36
+ const classifyError = (cause, message, operation) => classifySqliteError(cause, {
37
+ message,
38
+ operation
39
+ });
19
40
  /**
20
- * @category type ids
21
- * @since 1.0.0
41
+ * Runtime type identifier used to mark Bun `SqliteClient` values.
42
+ *
43
+ * @category type IDs
44
+ * @since 4.0.0
22
45
  */
23
46
  export const TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
24
47
  /**
48
+ * Context tag used to access the Bun `SqliteClient` service.
49
+ *
25
50
  * @category tags
26
- * @since 1.0.0
51
+ * @since 4.0.0
27
52
  */
28
- export const SqliteClient = /*#__PURE__*/ServiceMap.Service("@effect/sql-sqlite-bun/Client");
53
+ export const SqliteClient = /*#__PURE__*/Context.Service("@effect/sql-sqlite-bun/Client");
29
54
  /**
30
- * @category constructor
31
- * @since 1.0.0
55
+ * Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
56
+ *
57
+ * @category constructors
58
+ * @since 4.0.0
32
59
  */
33
60
  export const make = options => Effect.gen(function* () {
34
61
  const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
@@ -45,29 +72,27 @@ export const make = options => Effect.gen(function* () {
45
72
  }
46
73
  const run = (sql, params = []) => Effect.withFiber(fiber => {
47
74
  const statement = db.query(sql);
48
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);
75
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers);
49
76
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
50
77
  statement.safeIntegers(useSafeIntegers);
51
78
  try {
52
79
  return Effect.succeed(statement.all(...params) ?? []);
53
80
  } catch (cause) {
54
81
  return Effect.fail(new SqlError({
55
- cause,
56
- message: "Failed to execute statement"
82
+ reason: classifyError(cause, "Failed to execute statement", "execute")
57
83
  }));
58
84
  }
59
85
  });
60
86
  const runValues = (sql, params = []) => Effect.withFiber(fiber => {
61
87
  const statement = db.query(sql);
62
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);
88
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers);
63
89
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
64
90
  statement.safeIntegers(useSafeIntegers);
65
91
  try {
66
92
  return Effect.succeed(statement.values(...params) ?? []);
67
93
  } catch (cause) {
68
94
  return Effect.fail(new SqlError({
69
- cause,
70
- message: "Failed to execute statement"
95
+ reason: classifyError(cause, "Failed to execute statement", "execute")
71
96
  }));
72
97
  }
73
98
  });
@@ -90,15 +115,13 @@ export const make = options => Effect.gen(function* () {
90
115
  export: Effect.try({
91
116
  try: () => db.serialize(),
92
117
  catch: cause => new SqlError({
93
- cause,
94
- message: "Failed to export database"
118
+ reason: classifyError(cause, "Failed to export database", "export")
95
119
  })
96
120
  }),
97
121
  loadExtension: path => Effect.try({
98
122
  try: () => db.loadExtension(path),
99
123
  catch: cause => new SqlError({
100
- cause,
101
- message: "Failed to load extension"
124
+ reason: classifyError(cause, "Failed to load extension", "loadExtension")
102
125
  })
103
126
  })
104
127
  });
@@ -108,7 +131,7 @@ export const make = options => Effect.gen(function* () {
108
131
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));
109
132
  const transactionAcquirer = Effect.uninterruptibleMask(restore => {
110
133
  const fiber = Fiber.getCurrent();
111
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);
134
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope);
112
135
  return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);
113
136
  });
114
137
  return Object.assign(yield* Client.make({
@@ -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 1.0.0
154
+ * @since 4.0.0
130
155
  */
131
- export const layerConfig = config => Layer.effectServices(Config.unwrap(config).asEffect().pipe(Effect.flatMap(make), Effect.map(client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));
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 1.0.0
161
+ * @since 4.0.0
135
162
  */
136
- export const layer = config => Layer.effectServices(Effect.map(make(config), client => ServiceMap.make(SqliteClient, client).pipe(ServiceMap.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
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
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.js","names":["Database","Config","Effect","Fiber","identity","Layer","Scope","Semaphore","ServiceMap","Stream","Reactivity","Client","SqlError","Statement","ATTR_DB_SYSTEM_NAME","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","services","SafeIntegers","safeIntegers","succeed","all","cause","fail","message","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","effectServices","unwrap","asEffect","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,SAASA,QAAQ,QAAQ,YAAY;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,OAAO,KAAKC,SAAS,MAAM,+BAA+B;AAE1D,MAAMC,mBAAmB,GAAG,gBAAgB;AAE5C;;;;AAIA,OAAO,MAAMC,MAAM,GAAW,sCAAsC;AAsBpE;;;;AAIA,OAAO,MAAMC,YAAY,gBAAGR,UAAU,CAACS,OAAO,CAAe,+BAA+B,CAAC;AAwB7F;;;;AAIA,OAAO,MAAMC,IAAI,GACfC,OAA2B,IAE3BjB,MAAM,CAACkB,GAAG,CAAC,aAAS;EAClB,MAAMC,QAAQ,GAAGR,SAAS,CAACS,kBAAkB,CAACH,OAAO,CAACI,mBAAmB,CAAC;EAC1E,MAAMC,aAAa,GAAGL,OAAO,CAACM,oBAAoB,GACh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;;AAIA,OAAO,MAAMA,KAAK,GAChBZ,MAA0B,IAE1BtF,KAAK,CAAC0F,cAAc,CAClB7F,MAAM,CAACyD,GAAG,CAACzC,IAAI,CAACyE,MAAM,CAAC,EAAGQ,MAAM,IAC9B3F,UAAU,CAACU,IAAI,CAACF,YAAY,EAAEmF,MAAM,CAAC,CAACD,IAAI,CACxC1F,UAAU,CAAC4F,GAAG,CAACzF,MAAM,CAAC0F,SAAS,EAAEF,MAAM,CAAC,CACzC,CAAC,CACL,CAACD,IAAI,CAAC7F,KAAK,CAACiG,OAAO,CAAC5F,UAAU,CAAC6F,KAAK,CAAC,CAAC","ignoreList":[]}
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","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,SAASA,QAAQ,QAAQ,YAAY;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAA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iF,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":[]}
@@ -1,5 +1,25 @@
1
1
  /**
2
- * @since 1.0.0
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 1.0.0
30
+ * @since 4.0.0
11
31
  */
12
32
  export * from "effect/unstable/sql/Migrator";
13
33
  /**
14
- * @category constructor
15
- * @since 1.0.0
34
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
35
+ *
36
+ * @category constructors
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
  /**
19
- * @category constructor
20
- * @since 1.0.0
41
+ * Creates a layer that runs the configured SQL migrations during layer construction.
42
+ *
43
+ * @category constructors
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;;GAEG;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;;;GAGG;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;;;GAGG;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"}
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"}
@@ -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 1.0.0
4
+ * @since 4.0.0
5
5
  */
6
6
  export * from "effect/unstable/sql/Migrator";
7
7
  /**
8
- * @category constructor
9
- * @since 1.0.0
8
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
9
+ *
10
+ * @category constructors
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
  /**
55
- * @category constructor
56
- * @since 1.0.0
57
+ * Creates a layer that runs the configured SQL migrations during layer construction.
58
+ *
59
+ * @category constructors
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":"AAIA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,QAAQ,MAAM,8BAA8B;AAIxD;;;AAGA,cAAc,8BAA8B;AAE5C;;;;AAIA,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;;;;AAIA,OAAO,MAAMC,KAAK,GAChBC,OAAoC,IAKjCL,KAAK,CAACM,aAAa,CAACJ,GAAG,CAACG,OAAO,CAAC,CAAC","ignoreList":[]}
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,49 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  /**
5
- * @since 1.0.0
5
+ * Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
6
+ *
7
+ * This module provides constructors and layers for using a Bun-managed SQLite database as both the
8
+ * SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
9
+ * file-backed or in-memory databases in Bun applications, local development tools, migrations,
10
+ * integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
11
+ * SQLite-specific helpers such as database export and native extension loading.
12
+ *
13
+ * Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
14
+ * is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
15
+ * so set `disableWAL` when opening read-only databases or when the database file or directory cannot
16
+ * be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
17
+ * the transaction scope, so concurrent fibers using the same client wait until it completes, while
18
+ * separate database handles or processes can still contend for SQLite write locks. Safe integer
19
+ * handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
20
+ * SQLite does not support `updateValues`.
21
+ *
22
+ * @since 4.0.0
6
23
  */
7
24
  export * as SqliteClient from "./SqliteClient.ts";
8
25
  /**
9
- * @since 1.0.0
26
+ * Utilities for applying Effect SQL migrations to Bun SQLite databases.
27
+ *
28
+ * This module re-exports the shared `Migrator` loaders and error types, then
29
+ * provides `run` and `layer` helpers for applying ordered migrations through
30
+ * the current Bun-backed SQLite `SqlClient`. It is typically used at
31
+ * application startup, in deployment or setup scripts that prepare a local
32
+ * SQLite file, in integration tests with temporary database files, or in layer
33
+ * graphs that must install the schema before dependent services are acquired.
34
+ *
35
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
36
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
37
+ * with an id greater than the latest recorded id are applied, so every client
38
+ * involved in startup should point at the same SQLite filename and use a
39
+ * writable Bun SQLite configuration. The Bun client enables WAL by default and
40
+ * serializes access through a single `bun:sqlite` database handle, but separate
41
+ * handles or processes can still contend for SQLite write locks. Bun's SQLite
42
+ * driver runs statements synchronously, so large migration sets can block the
43
+ * invoking runtime thread, and this adapter does not currently write SQLite
44
+ * schema dumps for `schemaDirectory`.
45
+ *
46
+ * @since 4.0.0
10
47
  */
11
48
  export * as SqliteMigrator from "./SqliteMigrator.ts";
12
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -1,13 +1,50 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  // @barrel: Auto-generated exports. Do not edit manually.
5
5
  /**
6
- * @since 1.0.0
6
+ * Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
7
+ *
8
+ * This module provides constructors and layers for using a Bun-managed SQLite database as both the
9
+ * SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
10
+ * file-backed or in-memory databases in Bun applications, local development tools, migrations,
11
+ * integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
12
+ * SQLite-specific helpers such as database export and native extension loading.
13
+ *
14
+ * Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
15
+ * is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
16
+ * so set `disableWAL` when opening read-only databases or when the database file or directory cannot
17
+ * be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
18
+ * the transaction scope, so concurrent fibers using the same client wait until it completes, while
19
+ * separate database handles or processes can still contend for SQLite write locks. Safe integer
20
+ * handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
21
+ * SQLite does not support `updateValues`.
22
+ *
23
+ * @since 4.0.0
7
24
  */
8
25
  export * as SqliteClient from "./SqliteClient.js";
9
26
  /**
10
- * @since 1.0.0
27
+ * Utilities for applying Effect SQL migrations to Bun SQLite databases.
28
+ *
29
+ * This module re-exports the shared `Migrator` loaders and error types, then
30
+ * provides `run` and `layer` helpers for applying ordered migrations through
31
+ * the current Bun-backed SQLite `SqlClient`. It is typically used at
32
+ * application startup, in deployment or setup scripts that prepare a local
33
+ * SQLite file, in integration tests with temporary database files, or in layer
34
+ * graphs that must install the schema before dependent services are acquired.
35
+ *
36
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
37
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
38
+ * with an id greater than the latest recorded id are applied, so every client
39
+ * involved in startup should point at the same SQLite filename and use a
40
+ * writable Bun SQLite configuration. The Bun client enables WAL by default and
41
+ * serializes access through a single `bun:sqlite` database handle, but separate
42
+ * handles or processes can still contend for SQLite write locks. Bun's SQLite
43
+ * driver runs statements synchronously, so large migration sets can block the
44
+ * invoking runtime thread, and this adapter does not currently write SQLite
45
+ * schema dumps for `schemaDirectory`.
46
+ *
47
+ * @since 4.0.0
11
48
  */
12
49
  export * as SqliteMigrator from "./SqliteMigrator.js";
13
50
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["SqliteClient","SqliteMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["SqliteClient","SqliteMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;;;;;;;;;;;;;;;;;;AAoBA,OAAO,KAAKA,YAAY,MAAM,mBAAmB;AAEjD;;;;;;;;;;;;;;;;;;;;;;;AAuBA,OAAO,KAAKC,cAAc,MAAM,qBAAqB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/sql-sqlite-bun",
3
- "version": "4.0.0-beta.7",
3
+ "version": "4.0.0-beta.70",
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.8",
47
- "@effect/platform-bun": "^4.0.0-beta.7",
48
- "effect": "^4.0.0-beta.7"
46
+ "@types/bun": "^1.3.13",
47
+ "@effect/platform-bun": "^4.0.0-beta.70",
48
+ "effect": "^4.0.0-beta.70"
49
49
  },
50
50
  "peerDependencies": {
51
- "effect": "^4.0.0-beta.7"
51
+ "effect": "^4.0.0-beta.70"
52
52
  },
53
53
  "scripts": {
54
54
  "codegen": "effect-utils codegen",
@@ -1,39 +1,65 @@
1
1
  /**
2
- * @since 1.0.0
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
+ import * as Context from "effect/Context"
6
24
  import * as Effect from "effect/Effect"
7
25
  import * as Fiber from "effect/Fiber"
8
26
  import { identity } from "effect/Function"
9
27
  import * as Layer from "effect/Layer"
10
28
  import * as Scope from "effect/Scope"
11
29
  import * as Semaphore from "effect/Semaphore"
12
- import * as ServiceMap from "effect/ServiceMap"
13
30
  import * as Stream from "effect/Stream"
14
31
  import * as Reactivity from "effect/unstable/reactivity/Reactivity"
15
32
  import * as Client from "effect/unstable/sql/SqlClient"
16
33
  import type { Connection } from "effect/unstable/sql/SqlConnection"
17
- import { SqlError } from "effect/unstable/sql/SqlError"
34
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError"
18
35
  import * as Statement from "effect/unstable/sql/Statement"
19
36
 
20
37
  const ATTR_DB_SYSTEM_NAME = "db.system.name"
21
38
 
39
+ const classifyError = (cause: unknown, message: string, operation: string) =>
40
+ classifySqliteError(cause, { message, operation })
41
+
22
42
  /**
23
- * @category type ids
24
- * @since 1.0.0
43
+ * Runtime type identifier used to mark Bun `SqliteClient` values.
44
+ *
45
+ * @category type IDs
46
+ * @since 4.0.0
25
47
  */
26
48
  export const TypeId: TypeId = "~@effect/sql-sqlite-bun/SqliteClient"
27
49
 
28
50
  /**
29
- * @category type ids
30
- * @since 1.0.0
51
+ * Type-level identifier used to mark Bun `SqliteClient` values.
52
+ *
53
+ * @category type IDs
54
+ * @since 4.0.0
31
55
  */
32
56
  export type TypeId = "~@effect/sql-sqlite-bun/SqliteClient"
33
57
 
34
58
  /**
59
+ * Bun SQLite client service, extending `SqlClient` with database export and extension loading helpers. `updateValues` is not supported.
60
+ *
35
61
  * @category models
36
- * @since 1.0.0
62
+ * @since 4.0.0
37
63
  */
38
64
  export interface SqliteClient extends Client.SqlClient {
39
65
  readonly [TypeId]: TypeId
@@ -46,14 +72,18 @@ export interface SqliteClient extends Client.SqlClient {
46
72
  }
47
73
 
48
74
  /**
75
+ * Context tag used to access the Bun `SqliteClient` service.
76
+ *
49
77
  * @category tags
50
- * @since 1.0.0
78
+ * @since 4.0.0
51
79
  */
52
- export const SqliteClient = ServiceMap.Service<SqliteClient>("@effect/sql-sqlite-bun/Client")
80
+ export const SqliteClient = Context.Service<SqliteClient>("@effect/sql-sqlite-bun/Client")
53
81
 
54
82
  /**
83
+ * Configuration for a Bun SQLite client, including filename, open mode flags, WAL behavior, span attributes, and query/result name transforms.
84
+ *
55
85
  * @category models
56
- * @since 1.0.0
86
+ * @since 4.0.0
57
87
  */
58
88
  export interface SqliteClientConfig {
59
89
  readonly filename: string
@@ -74,8 +104,10 @@ interface SqliteConnection extends Connection {
74
104
  }
75
105
 
76
106
  /**
77
- * @category constructor
78
- * @since 1.0.0
107
+ * Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
108
+ *
109
+ * @category constructors
110
+ * @since 4.0.0
79
111
  */
80
112
  export const make = (
81
113
  options: SqliteClientConfig
@@ -106,13 +138,13 @@ export const make = (
106
138
  ) =>
107
139
  Effect.withFiber<Array<any>, SqlError>((fiber) => {
108
140
  const statement = db.query(sql)
109
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers)
141
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers)
110
142
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
111
143
  statement.safeIntegers(useSafeIntegers)
112
144
  try {
113
145
  return Effect.succeed((statement.all(...(params as any)) ?? []) as Array<any>)
114
146
  } catch (cause) {
115
- return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
147
+ return Effect.fail(new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") }))
116
148
  }
117
149
  })
118
150
 
@@ -122,13 +154,13 @@ export const make = (
122
154
  ) =>
123
155
  Effect.withFiber<Array<any>, SqlError>((fiber) => {
124
156
  const statement = db.query(sql)
125
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers)
157
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers)
126
158
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
127
159
  statement.safeIntegers(useSafeIntegers)
128
160
  try {
129
161
  return Effect.succeed((statement.values(...(params as any)) ?? []) as Array<any>)
130
162
  } catch (cause) {
131
- return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
163
+ return Effect.fail(new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") }))
132
164
  }
133
165
  })
134
166
 
@@ -152,12 +184,13 @@ export const make = (
152
184
  },
153
185
  export: Effect.try({
154
186
  try: () => db.serialize(),
155
- catch: (cause) => new SqlError({ cause, message: "Failed to export database" })
187
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to export database", "export") })
156
188
  }),
157
189
  loadExtension: (path) =>
158
190
  Effect.try({
159
191
  try: () => db.loadExtension(path),
160
- catch: (cause) => new SqlError({ cause, message: "Failed to load extension" })
192
+ catch: (cause) =>
193
+ new SqlError({ reason: classifyError(cause, "Failed to load extension", "loadExtension") })
161
194
  })
162
195
  })
163
196
  })
@@ -168,7 +201,7 @@ export const make = (
168
201
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection))
169
202
  const transactionAcquirer = Effect.uninterruptibleMask((restore) => {
170
203
  const fiber = Fiber.getCurrent()!
171
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope)
204
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope)
172
205
  return Effect.as(
173
206
  Effect.tap(
174
207
  restore(semaphore.take(1)),
@@ -199,33 +232,37 @@ export const make = (
199
232
  })
200
233
 
201
234
  /**
235
+ * Creates a layer from a `Config`-wrapped Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
236
+ *
202
237
  * @category layers
203
- * @since 1.0.0
238
+ * @since 4.0.0
204
239
  */
205
240
  export const layerConfig = (
206
241
  config: Config.Wrap<SqliteClientConfig>
207
242
  ): Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError> =>
208
- Layer.effectServices(
209
- Config.unwrap(config).asEffect().pipe(
243
+ Layer.effectContext(
244
+ Config.unwrap(config).pipe(
210
245
  Effect.flatMap(make),
211
246
  Effect.map((client) =>
212
- ServiceMap.make(SqliteClient, client).pipe(
213
- ServiceMap.add(Client.SqlClient, client)
247
+ Context.make(SqliteClient, client).pipe(
248
+ Context.add(Client.SqlClient, client)
214
249
  )
215
250
  )
216
251
  )
217
252
  ).pipe(Layer.provide(Reactivity.layer))
218
253
 
219
254
  /**
255
+ * Creates a layer from a concrete Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
256
+ *
220
257
  * @category layers
221
- * @since 1.0.0
258
+ * @since 4.0.0
222
259
  */
223
260
  export const layer = (
224
261
  config: SqliteClientConfig
225
262
  ): Layer.Layer<SqliteClient | Client.SqlClient> =>
226
- Layer.effectServices(
263
+ Layer.effectContext(
227
264
  Effect.map(make(config), (client) =>
228
- ServiceMap.make(SqliteClient, client).pipe(
229
- ServiceMap.add(Client.SqlClient, client)
265
+ Context.make(SqliteClient, client).pipe(
266
+ Context.add(Client.SqlClient, client)
230
267
  ))
231
268
  ).pipe(Layer.provide(Reactivity.layer))
@@ -1,5 +1,25 @@
1
1
  /**
2
- * @since 1.0.0
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 1.0.0
31
+ * @since 4.0.0
12
32
  */
13
33
  export * from "effect/unstable/sql/Migrator"
14
34
 
15
35
  /**
16
- * @category constructor
17
- * @since 1.0.0
36
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
37
+ *
38
+ * @category constructors
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
  /**
70
- * @category constructor
71
- * @since 1.0.0
92
+ * Creates a layer that runs the configured SQL migrations during layer construction.
93
+ *
94
+ * @category constructors
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,52 @@
1
1
  /**
2
- * @since 1.0.0
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 1.0.0
8
+ * Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
9
+ *
10
+ * This module provides constructors and layers for using a Bun-managed SQLite database as both the
11
+ * SQLite-specific `SqliteClient` service and the generic `SqlClient` service. It is intended for
12
+ * file-backed or in-memory databases in Bun applications, local development tools, migrations,
13
+ * integration tests, and embedded persistence use cases that need Effect SQL query compilation plus
14
+ * SQLite-specific helpers such as database export and native extension loading.
15
+ *
16
+ * Each client owns one scoped `bun:sqlite` `Database` handle and serializes access through it, which
17
+ * is important because Bun executes SQLite statements synchronously. WAL mode is enabled by default,
18
+ * so set `disableWAL` when opening read-only databases or when the database file or directory cannot
19
+ * be updated with SQLite's WAL side files. A transaction holds the serialized connection permit for
20
+ * the transaction scope, so concurrent fibers using the same client wait until it completes, while
21
+ * separate database handles or processes can still contend for SQLite write locks. Safe integer
22
+ * handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
23
+ * SQLite does not support `updateValues`.
24
+ *
25
+ * @since 4.0.0
9
26
  */
10
27
  export * as SqliteClient from "./SqliteClient.ts"
11
28
 
12
29
  /**
13
- * @since 1.0.0
30
+ * Utilities for applying Effect SQL migrations to Bun SQLite databases.
31
+ *
32
+ * This module re-exports the shared `Migrator` loaders and error types, then
33
+ * provides `run` and `layer` helpers for applying ordered migrations through
34
+ * the current Bun-backed SQLite `SqlClient`. It is typically used at
35
+ * application startup, in deployment or setup scripts that prepare a local
36
+ * SQLite file, in integration tests with temporary database files, or in layer
37
+ * graphs that must install the schema before dependent services are acquired.
38
+ *
39
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
40
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
41
+ * with an id greater than the latest recorded id are applied, so every client
42
+ * involved in startup should point at the same SQLite filename and use a
43
+ * writable Bun SQLite configuration. The Bun client enables WAL by default and
44
+ * serializes access through a single `bun:sqlite` database handle, but separate
45
+ * handles or processes can still contend for SQLite write locks. Bun's SQLite
46
+ * driver runs statements synchronously, so large migration sets can block the
47
+ * invoking runtime thread, and this adapter does not currently write SQLite
48
+ * schema dumps for `schemaDirectory`.
49
+ *
50
+ * @since 4.0.0
14
51
  */
15
52
  export * as SqliteMigrator from "./SqliteMigrator.ts"