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

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,87 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
3
+ *
4
+ * This module provides the Bun-specific SQLite driver used by Effect SQL. It
5
+ * can create a scoped {@link SqliteClient} directly with {@link make}, or
6
+ * provide both the SQLite-specific client and the generic `SqlClient` service
7
+ * with {@link layer} or {@link layerConfig}. It is intended for Bun
8
+ * applications, local tools, migrations, integration tests, and embedded
9
+ * persistence that use file-backed or in-memory SQLite databases.
10
+ *
11
+ * ## Mental model
12
+ *
13
+ * A client owns one scoped `bun:sqlite` `Database` handle. Because Bun's SQLite
14
+ * API executes statements synchronously, this implementation serializes access
15
+ * to that handle. A transaction keeps the serialized connection permit for the
16
+ * transaction scope, so other fibers using the same client wait until the
17
+ * transaction completes.
18
+ *
19
+ * The client uses the Effect SQL statement compiler and result-name transforms,
20
+ * then adds SQLite-specific capabilities such as database export and native
21
+ * extension loading.
22
+ *
23
+ * ## Common tasks
24
+ *
25
+ * - Use {@link layer} when a Bun service should provide both `SqliteClient` and
26
+ * the generic `SqlClient` from a concrete configuration.
27
+ * - Use {@link layerConfig} when the filename or open flags should come from
28
+ * Effect `Config`.
29
+ * - Use {@link make} inside a custom scoped layer when the surrounding runtime
30
+ * needs to manage the client lifecycle explicitly.
31
+ * - Use `client.export` to serialize the database, or `client.loadExtension` to
32
+ * load a native SQLite extension.
33
+ *
34
+ * ## Gotchas
35
+ *
36
+ * WAL mode is enabled by default. Set `disableWAL` for read-only databases or
37
+ * when the database file or directory cannot be updated with SQLite WAL side
38
+ * files. Separate database handles or processes can still contend for SQLite
39
+ * write locks even though access through a single client is serialized.
40
+ *
41
+ * Safe integer handling follows the generic `SqlClient` fiber-local setting.
42
+ * `executeStream` is not implemented for this driver, and SQLite does not
43
+ * support `updateValues`.
44
+ *
45
+ * @since 4.0.0
3
46
  */
4
47
  import { Database } from "bun:sqlite";
5
48
  import * as Config from "effect/Config";
49
+ import * as Context from "effect/Context";
6
50
  import * as Effect from "effect/Effect";
7
51
  import * as Fiber from "effect/Fiber";
8
52
  import { identity } from "effect/Function";
9
53
  import * as Layer from "effect/Layer";
10
54
  import * as Scope from "effect/Scope";
11
55
  import * as Semaphore from "effect/Semaphore";
12
- import * as ServiceMap from "effect/ServiceMap";
13
56
  import * as Stream from "effect/Stream";
14
57
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
15
58
  import * as Client from "effect/unstable/sql/SqlClient";
16
- import { SqlError } from "effect/unstable/sql/SqlError";
59
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError";
17
60
  import * as Statement from "effect/unstable/sql/Statement";
18
61
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
62
+ const classifyError = (cause, message, operation) => classifySqliteError(cause, {
63
+ message,
64
+ operation
65
+ });
19
66
  /**
20
- * @category type ids
21
- * @since 1.0.0
67
+ * Runtime type identifier used to mark Bun `SqliteClient` values.
68
+ *
69
+ * @category type IDs
70
+ * @since 4.0.0
22
71
  */
23
72
  export const TypeId = "~@effect/sql-sqlite-bun/SqliteClient";
24
73
  /**
74
+ * Context tag used to access the Bun `SqliteClient` service.
75
+ *
25
76
  * @category tags
26
- * @since 1.0.0
77
+ * @since 4.0.0
27
78
  */
28
- export const SqliteClient = /*#__PURE__*/ServiceMap.Service("@effect/sql-sqlite-bun/Client");
79
+ export const SqliteClient = /*#__PURE__*/Context.Service("@effect/sql-sqlite-bun/Client");
29
80
  /**
30
- * @category constructor
31
- * @since 1.0.0
81
+ * Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
82
+ *
83
+ * @category constructors
84
+ * @since 4.0.0
32
85
  */
33
86
  export const make = options => Effect.gen(function* () {
34
87
  const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
@@ -45,29 +98,27 @@ export const make = options => Effect.gen(function* () {
45
98
  }
46
99
  const run = (sql, params = []) => Effect.withFiber(fiber => {
47
100
  const statement = db.query(sql);
48
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);
101
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers);
49
102
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
50
103
  statement.safeIntegers(useSafeIntegers);
51
104
  try {
52
105
  return Effect.succeed(statement.all(...params) ?? []);
53
106
  } catch (cause) {
54
107
  return Effect.fail(new SqlError({
55
- cause,
56
- message: "Failed to execute statement"
108
+ reason: classifyError(cause, "Failed to execute statement", "execute")
57
109
  }));
58
110
  }
59
111
  });
60
112
  const runValues = (sql, params = []) => Effect.withFiber(fiber => {
61
113
  const statement = db.query(sql);
62
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers);
114
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers);
63
115
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
64
116
  statement.safeIntegers(useSafeIntegers);
65
117
  try {
66
118
  return Effect.succeed(statement.values(...params) ?? []);
67
119
  } catch (cause) {
68
120
  return Effect.fail(new SqlError({
69
- cause,
70
- message: "Failed to execute statement"
121
+ reason: classifyError(cause, "Failed to execute statement", "execute")
71
122
  }));
72
123
  }
73
124
  });
@@ -90,15 +141,13 @@ export const make = options => Effect.gen(function* () {
90
141
  export: Effect.try({
91
142
  try: () => db.serialize(),
92
143
  catch: cause => new SqlError({
93
- cause,
94
- message: "Failed to export database"
144
+ reason: classifyError(cause, "Failed to export database", "export")
95
145
  })
96
146
  }),
97
147
  loadExtension: path => Effect.try({
98
148
  try: () => db.loadExtension(path),
99
149
  catch: cause => new SqlError({
100
- cause,
101
- message: "Failed to load extension"
150
+ reason: classifyError(cause, "Failed to load extension", "loadExtension")
102
151
  })
103
152
  })
104
153
  });
@@ -108,7 +157,7 @@ export const make = options => Effect.gen(function* () {
108
157
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));
109
158
  const transactionAcquirer = Effect.uninterruptibleMask(restore => {
110
159
  const fiber = Fiber.getCurrent();
111
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);
160
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope);
112
161
  return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);
113
162
  });
114
163
  return Object.assign(yield* Client.make({
@@ -125,13 +174,17 @@ export const make = options => Effect.gen(function* () {
125
174
  });
126
175
  });
127
176
  /**
177
+ * Creates a layer from a `Config`-wrapped Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
178
+ *
128
179
  * @category layers
129
- * @since 1.0.0
180
+ * @since 4.0.0
130
181
  */
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));
182
+ 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
183
  /**
184
+ * Creates a layer from a concrete Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
185
+ *
133
186
  * @category layers
134
- * @since 1.0.0
187
+ * @since 4.0.0
135
188
  */
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));
189
+ 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
190
  //# 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,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A,OAAO,MAAMsB,WAAW,GACtBH,MAAuC,IAEvCtF,KAAK,CAAC0F,cAAc,CAClB9F,MAAM,CAAC+F,MAAM,CAACL,MAAM,CAAC,CAACM,QAAQ,EAAE,CAACC,IAAI,CACnChG,MAAM,CAAC0F,OAAO,CAAC1E,IAAI,CAAC,EACpBhB,MAAM,CAACyD,GAAG,CAAEwC,MAAM,IAChB3F,UAAU,CAACU,IAAI,CAACF,YAAY,EAAEmF,MAAM,CAAC,CAACD,IAAI,CACxC1F,UAAU,CAAC4F,GAAG,CAACzF,MAAM,CAAC0F,SAAS,EAAEF,MAAM,CAAC,CACzC,CACF,CACF,CACF,CAACD,IAAI,CAAC7F,KAAK,CAACiG,OAAO,CAAC5F,UAAU,CAAC6F,KAAK,CAAC,CAAC;AAEzC;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,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,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,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ,8BAA8B;AAC5E,OAAO,KAAKC,SAAS,MAAM,+BAA+B;AAE1D,MAAMC,mBAAmB,GAAG,gBAAgB;AAE5C,MAAMC,aAAa,GAAGA,CAACC,KAAc,EAAEC,OAAe,EAAEC,SAAiB,KACvEP,mBAAmB,CAACK,KAAK,EAAE;EAAEC,OAAO;EAAEC;AAAS,CAAE,CAAC;AAEpD;;;;;;AAMA,OAAO,MAAMC,MAAM,GAAW,sCAAsC;AA0BpE;;;;;;AAMA,OAAO,MAAMC,YAAY,gBAAGnB,OAAO,CAACoB,OAAO,CAAe,+BAA+B,CAAC;AA0B1F;;;;;;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6F,OAAO,CAACzE,IAAI,CAAC,EACpBpB,MAAM,CAAC4D,GAAG,CAAEuC,MAAM,IAChBpG,OAAO,CAACqB,IAAI,CAACF,YAAY,EAAEiF,MAAM,CAAC,CAACD,IAAI,CACrCnG,OAAO,CAACqG,GAAG,CAAC5F,MAAM,CAAC6F,SAAS,EAAEF,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAACD,IAAI,CAAC/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":[]}
@@ -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;AAC5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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,12 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  /**
5
- * @since 1.0.0
5
+ * @since 4.0.0
6
6
  */
7
7
  export * as SqliteClient from "./SqliteClient.ts";
8
8
  /**
9
- * @since 1.0.0
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 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
+ * @since 4.0.0
7
7
  */
8
8
  export * as SqliteClient from "./SqliteClient.js";
9
9
  /**
10
- * @since 1.0.0
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.7",
3
+ "version": "4.0.0-beta.71",
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.71",
48
+ "effect": "^4.0.0-beta.71"
49
49
  },
50
50
  "peerDependencies": {
51
- "effect": "^4.0.0-beta.7"
51
+ "effect": "^4.0.0-beta.71"
52
52
  },
53
53
  "scripts": {
54
54
  "codegen": "effect-utils codegen",
@@ -1,39 +1,91 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Bun SQLite client implementation for Effect SQL, backed by `bun:sqlite`.
3
+ *
4
+ * This module provides the Bun-specific SQLite driver used by Effect SQL. It
5
+ * can create a scoped {@link SqliteClient} directly with {@link make}, or
6
+ * provide both the SQLite-specific client and the generic `SqlClient` service
7
+ * with {@link layer} or {@link layerConfig}. It is intended for Bun
8
+ * applications, local tools, migrations, integration tests, and embedded
9
+ * persistence that use file-backed or in-memory SQLite databases.
10
+ *
11
+ * ## Mental model
12
+ *
13
+ * A client owns one scoped `bun:sqlite` `Database` handle. Because Bun's SQLite
14
+ * API executes statements synchronously, this implementation serializes access
15
+ * to that handle. A transaction keeps the serialized connection permit for the
16
+ * transaction scope, so other fibers using the same client wait until the
17
+ * transaction completes.
18
+ *
19
+ * The client uses the Effect SQL statement compiler and result-name transforms,
20
+ * then adds SQLite-specific capabilities such as database export and native
21
+ * extension loading.
22
+ *
23
+ * ## Common tasks
24
+ *
25
+ * - Use {@link layer} when a Bun service should provide both `SqliteClient` and
26
+ * the generic `SqlClient` from a concrete configuration.
27
+ * - Use {@link layerConfig} when the filename or open flags should come from
28
+ * Effect `Config`.
29
+ * - Use {@link make} inside a custom scoped layer when the surrounding runtime
30
+ * needs to manage the client lifecycle explicitly.
31
+ * - Use `client.export` to serialize the database, or `client.loadExtension` to
32
+ * load a native SQLite extension.
33
+ *
34
+ * ## Gotchas
35
+ *
36
+ * WAL mode is enabled by default. Set `disableWAL` for read-only databases or
37
+ * when the database file or directory cannot be updated with SQLite WAL side
38
+ * files. Separate database handles or processes can still contend for SQLite
39
+ * write locks even though access through a single client is serialized.
40
+ *
41
+ * Safe integer handling follows the generic `SqlClient` fiber-local setting.
42
+ * `executeStream` is not implemented for this driver, and SQLite does not
43
+ * support `updateValues`.
44
+ *
45
+ * @since 4.0.0
3
46
  */
4
47
  import { Database } from "bun:sqlite"
5
48
  import * as Config from "effect/Config"
49
+ import * as Context from "effect/Context"
6
50
  import * as Effect from "effect/Effect"
7
51
  import * as Fiber from "effect/Fiber"
8
52
  import { identity } from "effect/Function"
9
53
  import * as Layer from "effect/Layer"
10
54
  import * as Scope from "effect/Scope"
11
55
  import * as Semaphore from "effect/Semaphore"
12
- import * as ServiceMap from "effect/ServiceMap"
13
56
  import * as Stream from "effect/Stream"
14
57
  import * as Reactivity from "effect/unstable/reactivity/Reactivity"
15
58
  import * as Client from "effect/unstable/sql/SqlClient"
16
59
  import type { Connection } from "effect/unstable/sql/SqlConnection"
17
- import { SqlError } from "effect/unstable/sql/SqlError"
60
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError"
18
61
  import * as Statement from "effect/unstable/sql/Statement"
19
62
 
20
63
  const ATTR_DB_SYSTEM_NAME = "db.system.name"
21
64
 
65
+ const classifyError = (cause: unknown, message: string, operation: string) =>
66
+ classifySqliteError(cause, { message, operation })
67
+
22
68
  /**
23
- * @category type ids
24
- * @since 1.0.0
69
+ * Runtime type identifier used to mark Bun `SqliteClient` values.
70
+ *
71
+ * @category type IDs
72
+ * @since 4.0.0
25
73
  */
26
74
  export const TypeId: TypeId = "~@effect/sql-sqlite-bun/SqliteClient"
27
75
 
28
76
  /**
29
- * @category type ids
30
- * @since 1.0.0
77
+ * Type-level identifier used to mark Bun `SqliteClient` values.
78
+ *
79
+ * @category type IDs
80
+ * @since 4.0.0
31
81
  */
32
82
  export type TypeId = "~@effect/sql-sqlite-bun/SqliteClient"
33
83
 
34
84
  /**
85
+ * Bun SQLite client service, extending `SqlClient` with database export and extension loading helpers. `updateValues` is not supported.
86
+ *
35
87
  * @category models
36
- * @since 1.0.0
88
+ * @since 4.0.0
37
89
  */
38
90
  export interface SqliteClient extends Client.SqlClient {
39
91
  readonly [TypeId]: TypeId
@@ -46,14 +98,18 @@ export interface SqliteClient extends Client.SqlClient {
46
98
  }
47
99
 
48
100
  /**
101
+ * Context tag used to access the Bun `SqliteClient` service.
102
+ *
49
103
  * @category tags
50
- * @since 1.0.0
104
+ * @since 4.0.0
51
105
  */
52
- export const SqliteClient = ServiceMap.Service<SqliteClient>("@effect/sql-sqlite-bun/Client")
106
+ export const SqliteClient = Context.Service<SqliteClient>("@effect/sql-sqlite-bun/Client")
53
107
 
54
108
  /**
109
+ * Configuration for a Bun SQLite client, including filename, open mode flags, WAL behavior, span attributes, and query/result name transforms.
110
+ *
55
111
  * @category models
56
- * @since 1.0.0
112
+ * @since 4.0.0
57
113
  */
58
114
  export interface SqliteClientConfig {
59
115
  readonly filename: string
@@ -74,8 +130,10 @@ interface SqliteConnection extends Connection {
74
130
  }
75
131
 
76
132
  /**
77
- * @category constructor
78
- * @since 1.0.0
133
+ * Creates a scoped Bun SQLite client for a database file, enabling WAL by default and serializing access. Streaming queries are not implemented.
134
+ *
135
+ * @category constructors
136
+ * @since 4.0.0
79
137
  */
80
138
  export const make = (
81
139
  options: SqliteClientConfig
@@ -106,13 +164,13 @@ export const make = (
106
164
  ) =>
107
165
  Effect.withFiber<Array<any>, SqlError>((fiber) => {
108
166
  const statement = db.query(sql)
109
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers)
167
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers)
110
168
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
111
169
  statement.safeIntegers(useSafeIntegers)
112
170
  try {
113
171
  return Effect.succeed((statement.all(...(params as any)) ?? []) as Array<any>)
114
172
  } catch (cause) {
115
- return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
173
+ return Effect.fail(new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") }))
116
174
  }
117
175
  })
118
176
 
@@ -122,13 +180,13 @@ export const make = (
122
180
  ) =>
123
181
  Effect.withFiber<Array<any>, SqlError>((fiber) => {
124
182
  const statement = db.query(sql)
125
- const useSafeIntegers = ServiceMap.get(fiber.services, Client.SafeIntegers)
183
+ const useSafeIntegers = Context.get(fiber.context, Client.SafeIntegers)
126
184
  // @ts-ignore bun-types missing safeIntegers method, fixed in https://github.com/oven-sh/bun/pull/26627
127
185
  statement.safeIntegers(useSafeIntegers)
128
186
  try {
129
187
  return Effect.succeed((statement.values(...(params as any)) ?? []) as Array<any>)
130
188
  } catch (cause) {
131
- return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
189
+ return Effect.fail(new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") }))
132
190
  }
133
191
  })
134
192
 
@@ -152,12 +210,13 @@ export const make = (
152
210
  },
153
211
  export: Effect.try({
154
212
  try: () => db.serialize(),
155
- catch: (cause) => new SqlError({ cause, message: "Failed to export database" })
213
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to export database", "export") })
156
214
  }),
157
215
  loadExtension: (path) =>
158
216
  Effect.try({
159
217
  try: () => db.loadExtension(path),
160
- catch: (cause) => new SqlError({ cause, message: "Failed to load extension" })
218
+ catch: (cause) =>
219
+ new SqlError({ reason: classifyError(cause, "Failed to load extension", "loadExtension") })
161
220
  })
162
221
  })
163
222
  })
@@ -168,7 +227,7 @@ export const make = (
168
227
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection))
169
228
  const transactionAcquirer = Effect.uninterruptibleMask((restore) => {
170
229
  const fiber = Fiber.getCurrent()!
171
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope)
230
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope)
172
231
  return Effect.as(
173
232
  Effect.tap(
174
233
  restore(semaphore.take(1)),
@@ -199,33 +258,37 @@ export const make = (
199
258
  })
200
259
 
201
260
  /**
261
+ * Creates a layer from a `Config`-wrapped Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
262
+ *
202
263
  * @category layers
203
- * @since 1.0.0
264
+ * @since 4.0.0
204
265
  */
205
266
  export const layerConfig = (
206
267
  config: Config.Wrap<SqliteClientConfig>
207
268
  ): Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError> =>
208
- Layer.effectServices(
209
- Config.unwrap(config).asEffect().pipe(
269
+ Layer.effectContext(
270
+ Config.unwrap(config).pipe(
210
271
  Effect.flatMap(make),
211
272
  Effect.map((client) =>
212
- ServiceMap.make(SqliteClient, client).pipe(
213
- ServiceMap.add(Client.SqlClient, client)
273
+ Context.make(SqliteClient, client).pipe(
274
+ Context.add(Client.SqlClient, client)
214
275
  )
215
276
  )
216
277
  )
217
278
  ).pipe(Layer.provide(Reactivity.layer))
218
279
 
219
280
  /**
281
+ * Creates a layer from a concrete Bun SQLite client configuration, providing both `SqliteClient` and `SqlClient`.
282
+ *
220
283
  * @category layers
221
- * @since 1.0.0
284
+ * @since 4.0.0
222
285
  */
223
286
  export const layer = (
224
287
  config: SqliteClientConfig
225
288
  ): Layer.Layer<SqliteClient | Client.SqlClient> =>
226
- Layer.effectServices(
289
+ Layer.effectContext(
227
290
  Effect.map(make(config), (client) =>
228
- ServiceMap.make(SqliteClient, client).pipe(
229
- ServiceMap.add(Client.SqlClient, client)
291
+ Context.make(SqliteClient, client).pipe(
292
+ Context.add(Client.SqlClient, client)
230
293
  ))
231
294
  ).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,15 @@
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
+ * @since 4.0.0
9
9
  */
10
10
  export * as SqliteClient from "./SqliteClient.ts"
11
11
 
12
12
  /**
13
- * @since 1.0.0
13
+ * @since 4.0.0
14
14
  */
15
15
  export * as SqliteMigrator from "./SqliteMigrator.ts"