@effect/sql-sqlite-bun 4.0.0-rc.117 → 4.0.0-rc.118

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.
Files changed (39) hide show
  1. package/AGENTS.md +4 -4
  2. package/CLAUDE.md +4 -4
  3. package/ai-docs/package.json +1 -1
  4. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +1 -1
  5. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +1 -1
  6. package/ai-docs/src/03_stream/30_encoding.ts +1 -1
  7. package/ai-docs/src/08_observability/20_otlp-tracing.ts +2 -2
  8. package/ai-docs/src/08_observability/index.md +1 -1
  9. package/ai-docs/src/40_sql/10_basics.ts +2 -2
  10. package/ai-docs/src/40_sql/index.md +1 -1
  11. package/ai-docs/src/50_http-client/10_basics.ts +1 -1
  12. package/ai-docs/src/51_http-server/10_basics.ts +2 -2
  13. package/ai-docs/src/51_http-server/20_testing.ts +2 -2
  14. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +1 -1
  15. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +1 -1
  16. package/ai-docs/src/51_http-server/fixtures/api/System.ts +1 -1
  17. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +1 -1
  18. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +1 -1
  19. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +1 -1
  20. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +1 -1
  21. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +1 -1
  22. package/ai-docs/src/60_child-process/index.md +1 -1
  23. package/ai-docs/src/70_cli/10_basics.ts +1 -1
  24. package/ai-docs/src/70_cli/index.md +1 -1
  25. package/ai-docs/src/71_ai/10_language-model.ts +2 -2
  26. package/ai-docs/src/71_ai/20_tools.ts +2 -2
  27. package/ai-docs/src/71_ai/30_chat.ts +2 -2
  28. package/ai-docs/src/80_cluster/10_entities.ts +3 -3
  29. package/dist/SqliteClient.d.ts +4 -4
  30. package/dist/SqliteClient.d.ts.map +1 -1
  31. package/dist/SqliteClient.js +18 -15
  32. package/dist/SqliteClient.js.map +1 -1
  33. package/dist/SqliteMigrator.d.ts +4 -4
  34. package/dist/SqliteMigrator.d.ts.map +1 -1
  35. package/dist/SqliteMigrator.js +2 -2
  36. package/dist/SqliteMigrator.js.map +1 -1
  37. package/package.json +4 -4
  38. package/src/SqliteClient.ts +25 -23
  39. package/src/SqliteMigrator.ts +4 -4
package/AGENTS.md CHANGED
@@ -302,7 +302,7 @@ Use it when your Effect programs need testable current time, safe parsing, stabl
302
302
 
303
303
  Effect has built-in support for structured logging, distributed tracing, and
304
304
  metrics. For exporting telemetry, use the lightweight Otlp modules from
305
- `effect/unstable/observability` in new projects, or use
305
+ `effect/observability` in new projects, or use
306
306
  `@effect/opentelemetry` NodeSdk when integrating with an existing OpenTelemetry
307
307
  setup.
308
308
 
@@ -344,7 +344,7 @@ if (Predicate.isObject(thing)) {
344
344
 
345
345
  ## Working with SQL databases
346
346
 
347
- Use the `effect/unstable/sql` modules together with a driver package such as
347
+ Use the `effect/sql` modules together with a driver package such as
348
348
  `@effect/sql-sqlite-node` to access SQL databases. Define domain models with
349
349
  `Model.Class` to derive schemas for the database and JSON boundaries, run
350
350
  migrations, and write type-safe queries.
@@ -372,13 +372,13 @@ Build http clients with the `HttpClient` module.
372
372
 
373
373
  ## Working with child processes
374
374
 
375
- Use the `effect/unstable/process` modules to define child processes and run them with `ChildProcessSpawner`.
375
+ Use the `effect/process` modules to define child processes and run them with `ChildProcessSpawner`.
376
376
 
377
377
  - **[Working with child processes](./ai-docs/src/60_child-process/10_working-with-child-processes.ts)**: This example shows how to collect process output, compose pipelines, and stream long-running command output.
378
378
 
379
379
  ## Building CLI applications
380
380
 
381
- Use the "effect/unstable/cli" modules to build CLI applications. These modules
381
+ Use the "effect/cli" modules to build CLI applications. These modules
382
382
  provide utilities for parsing command-line arguments, handling user input, and
383
383
  managing the flow of a CLI application.
384
384
 
package/CLAUDE.md CHANGED
@@ -302,7 +302,7 @@ Use it when your Effect programs need testable current time, safe parsing, stabl
302
302
 
303
303
  Effect has built-in support for structured logging, distributed tracing, and
304
304
  metrics. For exporting telemetry, use the lightweight Otlp modules from
305
- `effect/unstable/observability` in new projects, or use
305
+ `effect/observability` in new projects, or use
306
306
  `@effect/opentelemetry` NodeSdk when integrating with an existing OpenTelemetry
307
307
  setup.
308
308
 
@@ -344,7 +344,7 @@ if (Predicate.isObject(thing)) {
344
344
 
345
345
  ## Working with SQL databases
346
346
 
347
- Use the `effect/unstable/sql` modules together with a driver package such as
347
+ Use the `effect/sql` modules together with a driver package such as
348
348
  `@effect/sql-sqlite-node` to access SQL databases. Define domain models with
349
349
  `Model.Class` to derive schemas for the database and JSON boundaries, run
350
350
  migrations, and write type-safe queries.
@@ -372,13 +372,13 @@ Build http clients with the `HttpClient` module.
372
372
 
373
373
  ## Working with child processes
374
374
 
375
- Use the `effect/unstable/process` modules to define child processes and run them with `ChildProcessSpawner`.
375
+ Use the `effect/process` modules to define child processes and run them with `ChildProcessSpawner`.
376
376
 
377
377
  - **[Working with child processes](./ai-docs/src/60_child-process/10_working-with-child-processes.ts)**: This example shows how to collect process output, compose pipelines, and stream long-running command output.
378
378
 
379
379
  ## Building CLI applications
380
380
 
381
- Use the "effect/unstable/cli" modules to build CLI applications. These modules
381
+ Use the "effect/cli" modules to build CLI applications. These modules
382
382
  provide utilities for parsing command-line arguments, handling user input, and
383
383
  managing the flow of a CLI application.
384
384
 
@@ -27,7 +27,7 @@
27
27
  "@effect/sql-sqlite-wasm": "workspace:*",
28
28
  "@effect/vitest": "workspace:*",
29
29
  "effect": "workspace:*",
30
- "hono": "^4.13.8",
30
+ "hono": "^4.13.9",
31
31
  "nodemailer": "^10.0.10"
32
32
  },
33
33
  "devDependencies": {
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { PgClient } from "@effect/sql-pg"
9
9
  import { Array, Config, Context, Effect, Layer, type Option, Schema } from "effect"
10
- import { SqlClient, SqlError } from "effect/unstable/sql"
10
+ import { SqlClient, SqlError } from "effect/sql"
11
11
 
12
12
  // Define a layer for the SqlClient service
13
13
  export const SqlClientLayer: Layer.Layer<
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
7
7
  import { Effect, Layer } from "effect"
8
- import { HttpRouter, HttpServerResponse } from "effect/unstable/http"
8
+ import { HttpRouter, HttpServerResponse } from "effect/http"
9
9
  import { createServer } from "node:http"
10
10
 
11
11
  // Build a tiny HTTP app with a health-check endpoint.
@@ -5,7 +5,7 @@
5
5
  * decode and encode streams of structured data.
6
6
  */
7
7
  import { DateTime, Schema, Stream } from "effect"
8
- import { Ndjson, SchemaBinary } from "effect/unstable/encoding"
8
+ import { Ndjson, SchemaBinary } from "effect/encoding"
9
9
 
10
10
  // SchemaBinary derives a framed binary decoder directly from a schema.
11
11
  export const schemaBinaryDecoder = SchemaBinary.decode(Schema.Struct({
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { NodeRuntime } from "@effect/platform-node"
7
7
  import { Context, Effect, Layer } from "effect"
8
- import { FetchHttpClient } from "effect/unstable/http"
9
- import { OtlpLogger, OtlpSerialization, OtlpTracer } from "effect/unstable/observability"
8
+ import { FetchHttpClient } from "effect/http"
9
+ import { OtlpLogger, OtlpSerialization, OtlpTracer } from "effect/observability"
10
10
 
11
11
  // Configure OTLP span export.
12
12
  export const OtlpTracingLayer = OtlpTracer.layer({
@@ -2,6 +2,6 @@
2
2
 
3
3
  Effect has built-in support for structured logging, distributed tracing, and
4
4
  metrics. For exporting telemetry, use the lightweight Otlp modules from
5
- `effect/unstable/observability` in new projects, or use
5
+ `effect/observability` in new projects, or use
6
6
  `@effect/opentelemetry` NodeSdk when integrating with an existing OpenTelemetry
7
7
  setup.
@@ -7,8 +7,8 @@
7
7
  import { NodeRuntime } from "@effect/platform-node"
8
8
  import { SqliteClient, SqliteMigrator } from "@effect/sql-sqlite-node"
9
9
  import { Context, Effect, Layer, Schema } from "effect"
10
- import { Model } from "effect/unstable/schema"
11
- import { SqlClient, SqlModel, SqlSchema } from "effect/unstable/sql"
10
+ import { Model } from "effect/schema"
11
+ import { SqlClient, SqlModel, SqlSchema } from "effect/sql"
12
12
 
13
13
  // Use a branded string for the group id, so it cannot be mixed up with other
14
14
  // string ids in the application.
@@ -1,6 +1,6 @@
1
1
  ## Working with SQL databases
2
2
 
3
- Use the `effect/unstable/sql` modules together with a driver package such as
3
+ Use the `effect/sql` modules together with a driver package such as
4
4
  `@effect/sql-sqlite-node` to access SQL databases. Define domain models with
5
5
  `Model.Class` to derive schemas for the database and JSON boundaries, run
6
6
  migrations, and write type-safe queries.
@@ -4,7 +4,7 @@
4
4
  * Define a service that uses the HttpClient module to fetch data from an external API
5
5
  */
6
6
  import { Context, Effect, flow, Layer, Schedule, Schema } from "effect"
7
- import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http"
7
+ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http"
8
8
 
9
9
  class Todo extends Schema.Class<Todo>("Todo")({
10
10
  userId: Schema.Int,
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import { NodeHttpServer, NodeRuntime } from "@effect/platform-node"
8
8
  import { Context, Effect, flow, Layer, Schedule } from "effect"
9
- import { FetchHttpClient, HttpClient, HttpClientRequest, HttpRouter, HttpServer } from "effect/unstable/http"
10
- import { HttpApiBuilder, HttpApiClient, HttpApiMiddleware, HttpApiScalar } from "effect/unstable/httpapi"
9
+ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpRouter, HttpServer } from "effect/http"
10
+ import { HttpApiBuilder, HttpApiClient, HttpApiMiddleware, HttpApiScalar } from "effect/http-api"
11
11
  import { createServer } from "node:http"
12
12
  // Api definitions should **always** be seperate from the server implementation,
13
13
  // so that they can be shared between the server and client without leaking
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import { assert, layer } from "@effect/vitest"
8
8
  import { Effect, Layer } from "effect"
9
- import { HttpClientRequest, HttpServer } from "effect/unstable/http"
10
- import { HttpApiMiddleware, HttpApiTest } from "effect/unstable/httpapi"
9
+ import { HttpClientRequest, HttpServer } from "effect/http"
10
+ import { HttpApiMiddleware, HttpApiTest } from "effect/http-api"
11
11
  import { Api } from "./fixtures/api/Api.ts"
12
12
  import { Authorization } from "./fixtures/api/Authorization.ts"
13
13
  import { UserId } from "./fixtures/domain/User.ts"
@@ -1,4 +1,4 @@
1
- import { HttpApi, OpenApi } from "effect/unstable/httpapi"
1
+ import { HttpApi, OpenApi } from "effect/http-api"
2
2
  import { SystemApi } from "./System.ts"
3
3
  import { UsersApiGroup } from "./Users.ts"
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { Context, Schema } from "effect"
2
- import { HttpApiMiddleware, HttpApiSecurity } from "effect/unstable/httpapi"
2
+ import { HttpApiMiddleware, HttpApiSecurity } from "effect/http-api"
3
3
  import type { User } from "../domain/User.ts"
4
4
 
5
5
  export class CurrentUser extends Context.Service<CurrentUser, User>()("acme/HttpApi/Authorization/CurrentUser") {}
@@ -1,4 +1,4 @@
1
- import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi"
1
+ import { HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api"
2
2
 
3
3
  // Top level groups are added to the root of the derived HttpApiClient.
4
4
  //
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect"
2
- import { HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
2
+ import { HttpApiEndpoint, HttpApiError, HttpApiGroup, HttpApiSchema, OpenApi } from "effect/http-api"
3
3
  import { User, UserId } from "../domain/User.ts"
4
4
  import { SearchQueryTooShort, UserNotFound } from "../domain/UserErrors.ts"
5
5
  import { Authorization } from "./Authorization.ts"
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect"
2
- import { Model } from "effect/unstable/schema"
2
+ import { Model } from "effect/schema"
3
3
 
4
4
  export const UserId = Schema.String.pipe(Schema.brand("UserId"))
5
5
  export type UserId = typeof UserId.Type
@@ -1,5 +1,5 @@
1
1
  import { Effect, Layer } from "effect"
2
- import { HttpApiBuilder, HttpApiError } from "effect/unstable/httpapi"
2
+ import { HttpApiBuilder, HttpApiError } from "effect/http-api"
3
3
  import { Api } from "../../api/Api.ts"
4
4
  import { CurrentUser } from "../../api/Authorization.ts"
5
5
  import { AuthorizationLayer } from "../Authorization.ts"
@@ -1,6 +1,6 @@
1
1
  import { SqliteClient, SqliteMigrator } from "@effect/sql-sqlite-node"
2
2
  import { Context, Effect, Layer, Schema } from "effect"
3
- import { SqlClient, SqlModel, SqlSchema } from "effect/unstable/sql"
3
+ import { SqlClient, SqlModel, SqlSchema } from "effect/sql"
4
4
  import { User } from "../domain/User.ts"
5
5
  import type { UserId } from "../domain/User.ts"
6
6
  import { SearchQueryTooShort, UserNotFound, UsersError } from "../domain/UserErrors.ts"
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { NodeServices } from "@effect/platform-node"
7
7
  import { Console, Context, Effect, Layer, Schema, Stream, String } from "effect"
8
- import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process"
8
+ import { ChildProcess, ChildProcessSpawner } from "effect/process"
9
9
 
10
10
  export class DevToolsError extends Schema.TaggedError<DevToolsError>()("DevToolsError", {
11
11
  cause: Schema.Defect()
@@ -1,3 +1,3 @@
1
1
  ## Working with child processes
2
2
 
3
- Use the `effect/unstable/process` modules to define child processes and run them with `ChildProcessSpawner`.
3
+ Use the `effect/process` modules to define child processes and run them with `ChildProcessSpawner`.
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { NodeRuntime, NodeServices } from "@effect/platform-node"
8
8
  import { Console, Effect, Option, Schema } from "effect"
9
- import { Argument, Command, Flag } from "effect/unstable/cli"
9
+ import { Argument, Command, Flag } from "effect/cli"
10
10
 
11
11
  // You can define flags outside of commands and reuse them across multiple
12
12
  // commands.
@@ -1,5 +1,5 @@
1
1
  ## Building CLI applications
2
2
 
3
- Use the "effect/unstable/cli" modules to build CLI applications. These modules
3
+ Use the "effect/cli" modules to build CLI applications. These modules
4
4
  provide utilities for parsing command-line arguments, handling user input, and
5
5
  managing the flow of a CLI application.
@@ -7,8 +7,8 @@
7
7
  import { AnthropicClient, AnthropicLanguageModel } from "@effect/ai-anthropic"
8
8
  import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai"
9
9
  import { Config, Context, Effect, ExecutionPlan, Layer, Schema, Stream } from "effect"
10
- import { AiError, LanguageModel, Model, type Response } from "effect/unstable/ai"
11
- import { FetchHttpClient } from "effect/unstable/http"
10
+ import { AiError, LanguageModel, Model, type Response } from "effect/ai"
11
+ import { FetchHttpClient } from "effect/http"
12
12
  import { LaunchPlan } from "./fixtures/domain/LaunchPlan.ts"
13
13
 
14
14
  // You can use Config to create ai clients
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import { OpenAiClient, OpenAiLanguageModel, OpenAiTool } from "@effect/ai-openai"
8
8
  import { Config, Context, Effect, Layer, Schema } from "effect"
9
- import { AiError, LanguageModel, Tool, Toolkit } from "effect/unstable/ai"
10
- import { FetchHttpClient } from "effect/unstable/http"
9
+ import { AiError, LanguageModel, Tool, Toolkit } from "effect/ai"
10
+ import { FetchHttpClient } from "effect/http"
11
11
 
12
12
  // ---------------------------------------------------------------------------
13
13
  // 1. Defining tools
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai"
8
8
  import { Config, Context, DateTime, Effect, Layer, Ref, Schema } from "effect"
9
- import { AiError, Chat, Prompt, Tool, Toolkit } from "effect/unstable/ai"
10
- import { FetchHttpClient } from "effect/unstable/http"
9
+ import { AiError, Chat, Prompt, Tool, Toolkit } from "effect/ai"
10
+ import { FetchHttpClient } from "effect/http"
11
11
 
12
12
  // ---------------------------------------------------------------------------
13
13
  // Provider setup
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import { NodeClusterSocket, NodeRuntime } from "@effect/platform-node"
7
7
  import { Effect, Layer, Ref, Schema } from "effect"
8
- import { ClusterSchema, Entity, TestRunner } from "effect/unstable/cluster"
9
- import { Rpc } from "effect/unstable/rpc"
10
- import type { SqlClient } from "effect/unstable/sql"
8
+ import { ClusterSchema, Entity, TestRunner } from "effect/cluster"
9
+ import { Rpc } from "effect/rpc"
10
+ import type { SqlClient } from "effect/sql"
11
11
 
12
12
  export const Increment = Rpc.make("Increment", {
13
13
  payload: { amount: Schema.Int },
@@ -3,10 +3,10 @@ import * as Context from "effect/Context";
3
3
  import * as Duration from "effect/Duration";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Layer from "effect/Layer";
6
- import * as Scope from "effect/Scope";
7
- import * as Reactivity from "effect/unstable/reactivity/Reactivity";
8
- import * as Client from "effect/unstable/sql/SqlClient";
9
- import { SqlError } from "effect/unstable/sql/SqlError";
6
+ import * as Reactivity from "effect/reactivity/Reactivity";
7
+ import type * as Scope from "effect/Scope";
8
+ import * as Client from "effect/sql/SqlClient";
9
+ import { SqlError } from "effect/sql/SqlError";
10
10
  /**
11
11
  * Runtime type identifier used to mark Bun `SqliteClient` values.
12
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,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,8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;AACH,eAAO,MAAM,IAAI,YACN,kBAAkB,KAC1B,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,CA2IrE,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,WACd,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,WACR,kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
@@ -13,21 +13,19 @@
13
13
  *
14
14
  * @since 4.0.0
15
15
  */
16
- import { Database } from "bun:sqlite";
16
+ import { constants, Database } from "bun:sqlite";
17
17
  import * as Config from "effect/Config";
18
18
  import * as Context from "effect/Context";
19
19
  import * as Duration from "effect/Duration";
20
20
  import * as Effect from "effect/Effect";
21
- import * as Fiber from "effect/Fiber";
22
21
  import { identity } from "effect/Function";
23
22
  import * as Layer from "effect/Layer";
24
- import * as Scope from "effect/Scope";
23
+ import * as Reactivity from "effect/reactivity/Reactivity";
25
24
  import * as Semaphore from "effect/Semaphore";
25
+ import * as Client from "effect/sql/SqlClient";
26
+ import { classifySqliteError, SqlError } from "effect/sql/SqlError";
27
+ import * as Statement from "effect/sql/Statement";
26
28
  import * as Stream from "effect/Stream";
27
- import * as Reactivity from "effect/unstable/reactivity/Reactivity";
28
- import * as Client from "effect/unstable/sql/SqlClient";
29
- import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError";
30
- import * as Statement from "effect/unstable/sql/Statement";
31
29
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
32
30
  const MAX_BUSY_TIMEOUT = 2_147_483_647;
33
31
  const classifyError = (cause, message, operation) => classifySqliteError(cause, {
@@ -63,11 +61,12 @@ export const make = options => Effect.gen(function* () {
63
61
  const transformRows = options.transformResultNames ? Statement.defaultTransforms(options.transformResultNames).array : undefined;
64
62
  const makeConnection = Effect.gen(function* () {
65
63
  const readonly = options.readonly === true;
66
- const db = new Database(options.filename, {
64
+ const openOptions = {
67
65
  readonly,
68
66
  readwrite: readonly ? false : options.readwrite ?? true,
69
67
  create: readonly ? false : options.create ?? true
70
- });
68
+ };
69
+ const db = new Database(options.filename, options.filename.startsWith("file:") ? constants.SQLITE_OPEN_URI | (openOptions.readonly ? constants.SQLITE_OPEN_READONLY : 0) | (openOptions.readwrite || openOptions.create ? constants.SQLITE_OPEN_READWRITE : 0) | (openOptions.create ? constants.SQLITE_OPEN_CREATE : 0) : openOptions);
71
70
  yield* Effect.addFinalizer(() => Effect.sync(() => db.close()));
72
71
  const busyTimeout = Math.min(MAX_BUSY_TIMEOUT, Math.max(0, Math.round(Duration.toMillis(options.busyTimeout ?? Duration.seconds(5)))));
73
72
  db.run(`PRAGMA busy_timeout = ${busyTimeout};`);
@@ -101,6 +100,7 @@ export const make = options => Effect.gen(function* () {
101
100
  }
102
101
  });
103
102
  return identity({
103
+ isTransaction: () => db.inTransaction,
104
104
  execute(sql, params, transformRows) {
105
105
  return transformRows ? Effect.map(run(sql, params), transformRows) : run(sql, params);
106
106
  },
@@ -133,18 +133,21 @@ export const make = options => Effect.gen(function* () {
133
133
  })
134
134
  });
135
135
  });
136
- const semaphore = yield* Semaphore.make(1);
137
136
  const connection = yield* makeConnection;
138
- const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));
139
- const transactionAcquirer = Effect.uninterruptibleMask(restore => {
140
- const fiber = Fiber.getCurrent();
141
- const scope = Context.getUnsafe(fiber.context, Scope.Scope);
142
- return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);
137
+ const {
138
+ acquirer,
139
+ onCommitFailure,
140
+ transactionAcquirer
141
+ } = Client.makeSqliteAcquirers({
142
+ connection: Effect.succeed(connection),
143
+ semaphore: yield* Semaphore.make(1),
144
+ isTransaction: conn => conn.isTransaction()
143
145
  });
144
146
  const client = Object.assign(yield* Client.make({
145
147
  acquirer,
146
148
  compiler,
147
149
  transactionAcquirer,
150
+ onCommitFailure,
148
151
  releaseSavepoint: name => `RELEASE SAVEPOINT ${name}`,
149
152
  beginTransaction: options.readonly === true ? "BEGIN" : "BEGIN IMMEDIATE",
150
153
  spanAttributes: [...(options.spanAttributes ? Object.entries(options.spanAttributes) : []), [ATTR_DB_SYSTEM_NAME, "sqlite"]],
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.js","names":[],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;AAeA,SAAS,QAAQ,QAAQ,YAAY;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,SAAS,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,OAAO,KAAK,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B;AAEvD,SAAS,mBAAmB,EAAE,QAAQ,QAAQ,8BAA8B;AAC5E,OAAO,KAAK,SAAS,MAAM,+BAA+B;AAE1D,MAAM,mBAAmB,GAAG,gBAAgB;AAC5C,MAAM,gBAAgB,GAAG,aAAa;AAEtC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,OAAe,EAAE,SAAiB,KACvE,mBAAmB,CAAC,KAAK,EAAE;EAAE,OAAO;EAAE;AAAS,CAAE,CAAC;AAEpD;;;;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,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAG,CAAC,IAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;GACvF,CACF;EACD,OAAO,MAAM;AACf,CAAC,CAAC;AAEJ;;;;;;AAMA,OAAO,MAAM,WAAW,GACtB,MAAuC,IAEvC,KAAK,CAAC,aAAa,CACjB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CACxB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EACpB,MAAM,CAAC,GAAG,CAAE,MAAM,IAChB,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,IAAI,CACrC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAM,KAAK,GAChB,MAA0B,IAE1B,KAAK,CAAC,aAAa,CACjB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAG,MAAM,IAC9B,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,IAAI,CACrC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CACtC,CAAC,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -10,13 +10,13 @@
10
10
  */
11
11
  import type * as Effect from "effect/Effect";
12
12
  import * as Layer from "effect/Layer";
13
- import * as Migrator from "effect/unstable/sql/Migrator";
14
- import type * as Client from "effect/unstable/sql/SqlClient";
15
- import type { SqlError } from "effect/unstable/sql/SqlError";
13
+ import * as Migrator from "effect/sql/Migrator";
14
+ import type * as Client from "effect/sql/SqlClient";
15
+ import type { SqlError } from "effect/sql/SqlError";
16
16
  /**
17
17
  * @since 4.0.0
18
18
  */
19
- export * from "effect/unstable/sql/Migrator";
19
+ export * from "effect/sql/Migrator";
20
20
  /**
21
21
  * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
22
22
  *
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteMigrator.d.ts","sourceRoot":"","sources":["../src/SqliteMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,WACZ,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;;;;;;;;;GASG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD;;GAEG;AACH,cAAc,qBAAqB,CAAA;AAEnC;;;;;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,WACZ,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,9 +1,9 @@
1
1
  import * as Layer from "effect/Layer";
2
- import * as Migrator from "effect/unstable/sql/Migrator";
2
+ import * as Migrator from "effect/sql/Migrator";
3
3
  /**
4
4
  * @since 4.0.0
5
5
  */
6
- export * from "effect/unstable/sql/Migrator";
6
+ export * from "effect/sql/Migrator";
7
7
  /**
8
8
  * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteMigrator.js","names":[],"sources":["../src/SqliteMigrator.ts"],"sourcesContent":[null],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,QAAQ,MAAM,8BAA8B;AAIxD;;;AAGA,cAAc,8BAA8B;AAE5C;;;;;;AAMA,OAAO,MAAM,GAAG,gBAMZ,QAAQ,CAAC,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,MAAM,KAAK,GAChB,OAAoC,IAKjC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SqliteMigrator.js","names":[],"sources":["../src/SqliteMigrator.ts"],"sourcesContent":[null],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,OAAO,KAAK,QAAQ,MAAM,qBAAqB;AAI/C;;;AAGA,cAAc,qBAAqB;AAEnC;;;;;;AAMA,OAAO,MAAM,GAAG,gBAMZ,QAAQ,CAAC,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,MAAM,KAAK,GAChB,OAAoC,IAKjC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/sql-sqlite-bun",
3
- "version": "4.0.0-rc.117",
3
+ "version": "4.0.0-rc.118",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A SQLite toolkit for Effect",
@@ -48,11 +48,11 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/bun": "^1.4.2",
51
- "@effect/platform-bun": "^4.0.0-rc.117",
52
- "effect": "^4.0.0-rc.117"
51
+ "@effect/platform-bun": "^4.0.0-rc.118",
52
+ "effect": "^4.0.0-rc.118"
53
53
  },
54
54
  "peerDependencies": {
55
- "effect": "^4.0.0-rc.117"
55
+ "effect": "^4.0.0-rc.118"
56
56
  },
57
57
  "scripts": {
58
58
  "codegen": "effect-utils codegen",
@@ -13,22 +13,21 @@
13
13
  *
14
14
  * @since 4.0.0
15
15
  */
16
- import { Database } from "bun:sqlite"
16
+ import { constants, Database } from "bun:sqlite"
17
17
  import * as Config from "effect/Config"
18
18
  import * as Context from "effect/Context"
19
19
  import * as Duration from "effect/Duration"
20
20
  import * as Effect from "effect/Effect"
21
- import * as Fiber from "effect/Fiber"
22
21
  import { identity } from "effect/Function"
23
22
  import * as Layer from "effect/Layer"
24
- import * as Scope from "effect/Scope"
23
+ import * as Reactivity from "effect/reactivity/Reactivity"
24
+ import type * as Scope from "effect/Scope"
25
25
  import * as Semaphore from "effect/Semaphore"
26
+ import * as Client from "effect/sql/SqlClient"
27
+ import type { Connection } from "effect/sql/SqlConnection"
28
+ import { classifySqliteError, SqlError } from "effect/sql/SqlError"
29
+ import * as Statement from "effect/sql/Statement"
26
30
  import * as Stream from "effect/Stream"
27
- import * as Reactivity from "effect/unstable/reactivity/Reactivity"
28
- import * as Client from "effect/unstable/sql/SqlClient"
29
- import type { Connection } from "effect/unstable/sql/SqlConnection"
30
- import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError"
31
- import * as Statement from "effect/unstable/sql/Statement"
32
31
 
33
32
  const ATTR_DB_SYSTEM_NAME = "db.system.name"
34
33
  const MAX_BUSY_TIMEOUT = 2_147_483_647
@@ -106,6 +105,7 @@ export interface SqliteClientConfig {
106
105
  }
107
106
 
108
107
  interface SqliteConnection extends Connection {
108
+ readonly isTransaction: () => boolean
109
109
  readonly export: Effect.Effect<Uint8Array, SqlError>
110
110
  readonly loadExtension: (path: string) => Effect.Effect<void, SqlError>
111
111
  }
@@ -129,11 +129,20 @@ export const make = (
129
129
 
130
130
  const makeConnection = Effect.gen(function*() {
131
131
  const readonly = options.readonly === true
132
- const db = new Database(options.filename, {
132
+ const openOptions = {
133
133
  readonly,
134
134
  readwrite: readonly ? false : options.readwrite ?? true,
135
135
  create: readonly ? false : options.create ?? true
136
- } as any)
136
+ }
137
+ const db = new Database(
138
+ options.filename,
139
+ options.filename.startsWith("file:")
140
+ ? constants.SQLITE_OPEN_URI |
141
+ (openOptions.readonly ? constants.SQLITE_OPEN_READONLY : 0) |
142
+ (openOptions.readwrite || openOptions.create ? constants.SQLITE_OPEN_READWRITE : 0) |
143
+ (openOptions.create ? constants.SQLITE_OPEN_CREATE : 0)
144
+ : openOptions
145
+ )
137
146
  yield* Effect.addFinalizer(() => Effect.sync(() => db.close()))
138
147
  const busyTimeout = Math.min(
139
148
  MAX_BUSY_TIMEOUT,
@@ -181,6 +190,7 @@ export const make = (
181
190
  })
182
191
 
183
192
  return identity<SqliteConnection>({
193
+ isTransaction: () => db.inTransaction,
184
194
  execute(sql, params, transformRows) {
185
195
  return transformRows
186
196
  ? Effect.map(run(sql, params), transformRows)
@@ -214,20 +224,11 @@ export const make = (
214
224
  })
215
225
  })
216
226
 
217
- const semaphore = yield* Semaphore.make(1)
218
227
  const connection = yield* makeConnection
219
-
220
- const acquirer = semaphore.withPermits(1)(Effect.succeed(connection))
221
- const transactionAcquirer = Effect.uninterruptibleMask((restore) => {
222
- const fiber = Fiber.getCurrent()!
223
- const scope = Context.getUnsafe(fiber.context, Scope.Scope)
224
- return Effect.as(
225
- Effect.tap(
226
- restore(semaphore.take(1)),
227
- () => Scope.addFinalizer(scope, semaphore.release(1))
228
- ),
229
- connection
230
- )
228
+ const { acquirer, onCommitFailure, transactionAcquirer } = Client.makeSqliteAcquirers({
229
+ connection: Effect.succeed(connection),
230
+ semaphore: yield* Semaphore.make(1),
231
+ isTransaction: (conn) => conn.isTransaction()
231
232
  })
232
233
 
233
234
  const client: SqliteClient = Object.assign(
@@ -235,6 +236,7 @@ export const make = (
235
236
  acquirer,
236
237
  compiler,
237
238
  transactionAcquirer,
239
+ onCommitFailure,
238
240
  releaseSavepoint: (name) => `RELEASE SAVEPOINT ${name}`,
239
241
  beginTransaction: options.readonly === true ? "BEGIN" : "BEGIN IMMEDIATE",
240
242
  spanAttributes: [
@@ -10,14 +10,14 @@
10
10
  */
11
11
  import type * as Effect from "effect/Effect"
12
12
  import * as Layer from "effect/Layer"
13
- import * as Migrator from "effect/unstable/sql/Migrator"
14
- import type * as Client from "effect/unstable/sql/SqlClient"
15
- import type { SqlError } from "effect/unstable/sql/SqlError"
13
+ import * as Migrator from "effect/sql/Migrator"
14
+ import type * as Client from "effect/sql/SqlClient"
15
+ import type { SqlError } from "effect/sql/SqlError"
16
16
 
17
17
  /**
18
18
  * @since 4.0.0
19
19
  */
20
- export * from "effect/unstable/sql/Migrator"
20
+ export * from "effect/sql/Migrator"
21
21
 
22
22
  /**
23
23
  * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.