@effect/sql-sqlite-node 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,25 +1,31 @@
1
1
  import * as Config from "effect/Config";
2
+ import * as Context from "effect/Context";
2
3
  import * as Duration from "effect/Duration";
3
4
  import * as Effect from "effect/Effect";
4
5
  import * as Layer from "effect/Layer";
5
6
  import * as Scope from "effect/Scope";
6
- import * as ServiceMap from "effect/ServiceMap";
7
7
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
8
8
  import * as Client from "effect/unstable/sql/SqlClient";
9
9
  import { SqlError } from "effect/unstable/sql/SqlError";
10
10
  /**
11
- * @category type ids
12
- * @since 1.0.0
11
+ * Runtime type identifier used to mark Node `SqliteClient` values.
12
+ *
13
+ * @category type IDs
14
+ * @since 4.0.0
13
15
  */
14
16
  export declare const TypeId: TypeId;
15
17
  /**
16
- * @category type ids
17
- * @since 1.0.0
18
+ * Type-level identifier used to mark Node `SqliteClient` values.
19
+ *
20
+ * @category type IDs
21
+ * @since 4.0.0
18
22
  */
19
23
  export type TypeId = "~@effect/sql-sqlite-node/SqliteClient";
20
24
  /**
25
+ * Node SQLite client service, extending `SqlClient` with database export, backup, and extension loading helpers. `updateValues` is not supported.
26
+ *
21
27
  * @category models
22
- * @since 1.0.0
28
+ * @since 4.0.0
23
29
  */
24
30
  export interface SqliteClient extends Client.SqlClient {
25
31
  readonly [TypeId]: TypeId;
@@ -31,21 +37,27 @@ export interface SqliteClient extends Client.SqlClient {
31
37
  readonly updateValues: never;
32
38
  }
33
39
  /**
40
+ * Metadata returned from a Node SQLite backup operation, reporting total and remaining page counts.
41
+ *
34
42
  * @category models
35
- * @since 1.0.0
43
+ * @since 4.0.0
36
44
  */
37
45
  export interface BackupMetadata {
38
46
  readonly totalPages: number;
39
47
  readonly remainingPages: number;
40
48
  }
41
49
  /**
50
+ * Context service tag for the node SQLite client implementation.
51
+ *
42
52
  * @category tags
43
- * @since 1.0.0
53
+ * @since 4.0.0
44
54
  */
45
- export declare const SqliteClient: ServiceMap.Service<SqliteClient, SqliteClient>;
55
+ export declare const SqliteClient: Context.Service<SqliteClient, SqliteClient>;
46
56
  /**
57
+ * Configuration for a node SQLite client backed by `better-sqlite3`, including the database filename, read-only mode, statement cache settings, WAL behavior, span attributes, and query/result name transforms.
58
+ *
47
59
  * @category models
48
- * @since 1.0.0
60
+ * @since 4.0.0
49
61
  */
50
62
  export interface SqliteClientConfig {
51
63
  readonly filename: string;
@@ -58,18 +70,24 @@ export interface SqliteClientConfig {
58
70
  readonly transformQueryNames?: ((str: string) => string) | undefined;
59
71
  }
60
72
  /**
61
- * @category constructor
62
- * @since 1.0.0
73
+ * Creates a scoped node SQLite client from the supplied configuration, using a single serialized connection with WAL enabled by default and exposing SQLite-specific `export`, `backup`, and `loadExtension` operations.
74
+ *
75
+ * @category constructors
76
+ * @since 4.0.0
63
77
  */
64
78
  export declare const make: (options: SqliteClientConfig) => Effect.Effect<SqliteClient, never, Scope.Scope | Reactivity.Reactivity>;
65
79
  /**
80
+ * Builds a layer from an Effect `Config` value, providing both the node `SqliteClient` service and the generic `SqlClient` service.
81
+ *
66
82
  * @category layers
67
- * @since 1.0.0
83
+ * @since 4.0.0
68
84
  */
69
85
  export declare const layerConfig: (config: Config.Wrap<SqliteClientConfig>) => Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError>;
70
86
  /**
87
+ * Builds a layer from a node SQLite client configuration, providing both `SqliteClient` and the generic `SqlClient` service.
88
+ *
71
89
  * @category layers
72
- * @since 1.0.0
90
+ * @since 4.0.0
73
91
  */
74
92
  export declare const layer: (config: SqliteClientConfig) => Layer.Layer<SqliteClient | Client.SqlClient>;
75
93
  //# sourceMappingURL=SqliteClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAA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0
2
+ * Node.js SQLite client implementation for Effect SQL, backed by `better-sqlite3`.
3
+ *
4
+ * This module exposes constructors and layers for providing both the SQLite-specific `SqliteClient`
5
+ * service and the generic `SqlClient` service. It is intended for file-backed or in-memory SQLite
6
+ * databases in Node applications, local development tools, tests, migrations, and embedded
7
+ * persistence use cases that need Effect SQL query compilation plus SQLite-specific operations such
8
+ * as exporting a database, creating backups, or loading native SQLite extensions.
9
+ *
10
+ * Each client owns one scoped `better-sqlite3` connection and serializes access through it. WAL mode
11
+ * is enabled by default, so set `disableWAL` when opening read-only databases or when the database
12
+ * location cannot change journal mode. Prepared statements are cached by SQL text, safe integer
13
+ * handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
14
+ * SQLite does not support `updateValues`.
15
+ *
16
+ * @since 4.0.0
3
17
  */
4
18
  import Sqlite from "better-sqlite3";
5
19
  import * as Cache from "effect/Cache";
6
20
  import * as Config from "effect/Config";
21
+ import * as Context from "effect/Context";
7
22
  import * as Duration from "effect/Duration";
8
23
  import * as Effect from "effect/Effect";
9
24
  import * as Fiber from "effect/Fiber";
@@ -11,26 +26,35 @@ import { identity } from "effect/Function";
11
26
  import * as Layer from "effect/Layer";
12
27
  import * as Scope from "effect/Scope";
13
28
  import * as Semaphore from "effect/Semaphore";
14
- import * as ServiceMap from "effect/ServiceMap";
15
29
  import * as Stream from "effect/Stream";
16
30
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
17
31
  import * as Client from "effect/unstable/sql/SqlClient";
18
- import { SqlError } from "effect/unstable/sql/SqlError";
32
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError";
19
33
  import * as Statement from "effect/unstable/sql/Statement";
20
34
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
35
+ const classifyError = (cause, message, operation) => classifySqliteError(cause, {
36
+ message,
37
+ operation
38
+ });
21
39
  /**
22
- * @category type ids
23
- * @since 1.0.0
40
+ * Runtime type identifier used to mark Node `SqliteClient` values.
41
+ *
42
+ * @category type IDs
43
+ * @since 4.0.0
24
44
  */
25
45
  export const TypeId = "~@effect/sql-sqlite-node/SqliteClient";
26
46
  /**
47
+ * Context service tag for the node SQLite client implementation.
48
+ *
27
49
  * @category tags
28
- * @since 1.0.0
50
+ * @since 4.0.0
29
51
  */
30
- export const SqliteClient = /*#__PURE__*/ServiceMap.Service("@effect/sql-sqlite-node/SqliteClient");
52
+ export const SqliteClient = /*#__PURE__*/Context.Service("@effect/sql-sqlite-node/SqliteClient");
31
53
  /**
32
- * @category constructor
33
- * @since 1.0.0
54
+ * Creates a scoped node SQLite client from the supplied configuration, using a single serialized connection with WAL enabled by default and exposing SQLite-specific `export`, `backup`, and `loadExtension` operations.
55
+ *
56
+ * @category constructors
57
+ * @since 4.0.0
34
58
  */
35
59
  export const make = options => Effect.gen(function* () {
36
60
  const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
@@ -50,13 +74,12 @@ export const make = options => Effect.gen(function* () {
50
74
  lookup: sql => Effect.try({
51
75
  try: () => db.prepare(sql),
52
76
  catch: cause => new SqlError({
53
- cause,
54
- message: "Failed to prepare statement "
77
+ reason: classifyError(cause, "Failed to prepare statement", "prepare")
55
78
  })
56
79
  })
57
80
  });
58
81
  const runStatement = (statement, params, raw) => Effect.withFiber(fiber => {
59
- if (ServiceMap.get(fiber.services, Client.SafeIntegers)) {
82
+ if (Context.get(fiber.context, Client.SafeIntegers)) {
60
83
  statement.safeIntegers(true);
61
84
  }
62
85
  try {
@@ -67,8 +90,7 @@ export const make = options => Effect.gen(function* () {
67
90
  return Effect.succeed(raw ? result : []);
68
91
  } catch (cause) {
69
92
  return Effect.fail(new SqlError({
70
- cause,
71
- message: "Failed to execute statement"
93
+ reason: classifyError(cause, "Failed to execute statement", "execute")
72
94
  }));
73
95
  }
74
96
  });
@@ -83,8 +105,7 @@ export const make = options => Effect.gen(function* () {
83
105
  return [];
84
106
  },
85
107
  catch: cause => new SqlError({
86
- cause,
87
- message: "Failed to execute statement"
108
+ reason: classifyError(cause, "Failed to execute statement", "execute")
88
109
  })
89
110
  }), statement => Effect.sync(() => statement.reader && statement.raw(false)));
90
111
  return identity({
@@ -107,16 +128,14 @@ export const make = options => Effect.gen(function* () {
107
128
  export: Effect.try({
108
129
  try: () => db.serialize(),
109
130
  catch: cause => new SqlError({
110
- cause,
111
- message: "Failed to export database"
131
+ reason: classifyError(cause, "Failed to export database", "export")
112
132
  })
113
133
  }),
114
134
  backup(destination) {
115
135
  return Effect.tryPromise({
116
136
  try: () => db.backup(destination),
117
137
  catch: cause => new SqlError({
118
- cause,
119
- message: "Failed to backup database"
138
+ reason: classifyError(cause, "Failed to backup database", "backup")
120
139
  })
121
140
  });
122
141
  },
@@ -124,8 +143,7 @@ export const make = options => Effect.gen(function* () {
124
143
  return Effect.try({
125
144
  try: () => db.loadExtension(path),
126
145
  catch: cause => new SqlError({
127
- cause,
128
- message: "Failed to load extension"
146
+ reason: classifyError(cause, "Failed to load extension", "loadExtension")
129
147
  })
130
148
  });
131
149
  }
@@ -136,7 +154,7 @@ export const make = options => Effect.gen(function* () {
136
154
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection));
137
155
  const transactionAcquirer = Effect.uninterruptibleMask(restore => {
138
156
  const fiber = Fiber.getCurrent();
139
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope);
157
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope);
140
158
  return Effect.as(Effect.tap(restore(semaphore.take(1)), () => Scope.addFinalizer(scope, semaphore.release(1))), connection);
141
159
  });
142
160
  return Object.assign(yield* Client.make({
@@ -154,13 +172,17 @@ export const make = options => Effect.gen(function* () {
154
172
  });
155
173
  });
156
174
  /**
175
+ * Builds a layer from an Effect `Config` value, providing both the node `SqliteClient` service and the generic `SqlClient` service.
176
+ *
157
177
  * @category layers
158
- * @since 1.0.0
178
+ * @since 4.0.0
159
179
  */
160
- 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));
180
+ 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));
161
181
  /**
182
+ * Builds a layer from a node SQLite client configuration, providing both `SqliteClient` and the generic `SqlClient` service.
183
+ *
162
184
  * @category layers
163
- * @since 1.0.0
185
+ * @since 4.0.0
164
186
  */
165
- 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));
187
+ 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));
166
188
  //# sourceMappingURL=SqliteClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteClient.js","names":["Sqlite","Cache","Config","Duration","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","scope","db","filename","readonly","addFinalizer","sync","close","disableWAL","pragma","prepareCache","capacity","prepareCacheSize","timeToLive","prepareCacheTTL","minutes","lookup","sql","try","prepare","catch","cause","message","runStatement","statement","params","raw","withFiber","fiber","get","services","SafeIntegers","safeIntegers","reader","succeed","all","result","run","fail","flatMap","s","runValues","acquireUseRelease","execute","map","executeRaw","executeValues","executeUnprepared","effect","executeStream","_sql","_params","die","export","serialize","backup","destination","tryPromise","loadExtension","path","semaphore","connection","acquirer","withPermits","transactionAcquirer","uninterruptibleMask","restore","getCurrent","getUnsafe","as","tap","take","release","Object","assign","spanAttributes","entries","config","_","layerConfig","effectServices","unw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AK,CAAC+G,OAAO,CAAC1G,UAAU,CAAC2G,KAAK,CAAC,CAAC;AAEzC;;;;AAIA,OAAO,MAAMA,KAAK,GAChBX,MAA0B,IAE1BrG,KAAK,CAACwG,cAAc,CAClB3G,MAAM,CAACuE,GAAG,CAACvD,IAAI,CAACwF,MAAM,CAAC,EAAGO,MAAM,IAC9BzG,UAAU,CAACU,IAAI,CAACF,YAAY,EAAEiG,MAAM,CAAC,CAACD,IAAI,CACxCxG,UAAU,CAAC0G,GAAG,CAACvG,MAAM,CAACwG,SAAS,EAAEF,MAAM,CAAC,CACzC,CAAC,CACL,CAACD,IAAI,CAAC3G,KAAK,CAAC+G,OAAO,CAAC1G,UAAU,CAAC2G,KAAK,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SqliteClient.js","names":["Sqlite","Cache","Config","Context","Duration","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","scope","db","filename","readonly","addFinalizer","sync","close","disableWAL","pragma","prepareCache","capacity","prepareCacheSize","timeToLive","prepareCacheTTL","minutes","lookup","sql","try","prepare","catch","reason","runStatement","statement","params","raw","withFiber","fiber","get","context","SafeIntegers","safeIntegers","reader","succeed","all","result","run","fail","flatMap","s","runValues","acquireUseRelease","execute","map","executeRaw","executeValues","executeUnprepared","effect","executeStream","_sql","_params","die","export","serialize","backup","destination","tryPromise","loadExtension","path","semaphore","connection","acquirer","withPermits","transactionAcquirer","uninterruptibleMask","restore","getCurrent","getUnsafe","as","tap","take","release","Object","assign","spanAttributes","entries","config","_","layerConfig","effectContext","unwrap","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAiBA,OAAOA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IAAI,CAAC,EACpBpB,MAAM,CAAC0E,GAAG,CAAEuC,MAAM,IAChBnH,OAAO,CAACsB,IAAI,CAACF,YAAY,EAAE+F,MAAM,CAAC,CAACD,IAAI,CACrClH,OAAO,CAACoH,GAAG,CAAC1G,MAAM,CAAC2G,SAAS,EAAEF,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAACD,IAAI,CAAC7G,KAAK,CAACiH,OAAO,CAAC7G,UAAU,CAAC8G,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAMA,KAAK,GAChBV,MAA0B,IAE1BxG,KAAK,CAAC2G,aAAa,CACjB9G,MAAM,CAAC0E,GAAG,CAACtD,IAAI,CAACuF,MAAM,CAAC,EAAGM,MAAM,IAC9BnH,OAAO,CAACsB,IAAI,CAACF,YAAY,EAAE+F,MAAM,CAAC,CAACD,IAAI,CACrClH,OAAO,CAACoH,GAAG,CAAC1G,MAAM,CAAC2G,SAAS,EAAEF,MAAM,CAAC,CACtC,CAAC,CACL,CAACD,IAAI,CAAC7G,KAAK,CAACiH,OAAO,CAAC7G,UAAU,CAAC8G,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,20 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Utilities for applying Effect SQL migrations to Node.js 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 the
6
+ * current SQLite `SqlClient`. It is typically used at application startup, in
7
+ * tests that create temporary database files, or in layer graphs that must
8
+ * ensure a file-backed SQLite schema exists before dependent services start.
9
+ *
10
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
11
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
12
+ * with an id greater than the latest recorded id are applied, so every client
13
+ * involved in startup should point at the same SQLite filename. Concurrent
14
+ * writers can surface SQLite lock timeout errors, and this adapter does not
15
+ * currently write SQLite schema dumps for `schemaDirectory`.
16
+ *
17
+ * @since 4.0.0
3
18
  */
4
19
  import type * as Effect from "effect/Effect";
5
20
  import * as Layer from "effect/Layer";
@@ -7,17 +22,21 @@ import * as Migrator from "effect/unstable/sql/Migrator";
7
22
  import type * as Client from "effect/unstable/sql/SqlClient";
8
23
  import type { SqlError } from "effect/unstable/sql/SqlError";
9
24
  /**
10
- * @since 1.0.0
25
+ * @since 4.0.0
11
26
  */
12
27
  export * from "effect/unstable/sql/Migrator";
13
28
  /**
14
- * @category constructor
15
- * @since 1.0.0
29
+ * Runs SQL migrations for a SQLite database using the shared `Migrator` implementation and the current `SqlClient`.
30
+ *
31
+ * @category constructors
32
+ * @since 4.0.0
16
33
  */
17
34
  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
35
  /**
19
- * @category constructor
20
- * @since 1.0.0
36
+ * Creates a layer that runs the configured SQLite migrations during layer construction and provides no services.
37
+ *
38
+ * @category constructors
39
+ * @since 4.0.0
21
40
  */
22
41
  export declare const layer: <R>(options: Migrator.MigratorOptions<R>) => Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>;
23
42
  //# 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,KAA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AAM,KAAK,GAAI,CAAC,EACrB,SAAS,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,KACnC,KAAK,CAAC,KAAK,CACZ,KAAK,EACL,QAAQ,CAAC,cAAc,GAAG,QAAQ,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 for a SQLite database using the shared `Migrator` implementation and the current `SqlClient`.
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 SQLite migrations during layer construction and provides no services.
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":"AAmBA,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,41 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
  /**
5
- * @since 1.0.0
5
+ * Node.js SQLite client implementation for Effect SQL, backed by `better-sqlite3`.
6
+ *
7
+ * This module exposes constructors and layers for providing both the SQLite-specific `SqliteClient`
8
+ * service and the generic `SqlClient` service. It is intended for file-backed or in-memory SQLite
9
+ * databases in Node applications, local development tools, tests, migrations, and embedded
10
+ * persistence use cases that need Effect SQL query compilation plus SQLite-specific operations such
11
+ * as exporting a database, creating backups, or loading native SQLite extensions.
12
+ *
13
+ * Each client owns one scoped `better-sqlite3` connection and serializes access through it. WAL mode
14
+ * is enabled by default, so set `disableWAL` when opening read-only databases or when the database
15
+ * location cannot change journal mode. Prepared statements are cached by SQL text, 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
6
20
  */
7
21
  export * as SqliteClient from "./SqliteClient.ts";
8
22
  /**
9
- * @since 1.0.0
23
+ * Utilities for applying Effect SQL migrations to Node.js SQLite databases.
24
+ *
25
+ * This module re-exports the shared `Migrator` loaders and error types, then
26
+ * provides `run` and `layer` helpers for applying ordered migrations through the
27
+ * current SQLite `SqlClient`. It is typically used at application startup, in
28
+ * tests that create temporary database files, or in layer graphs that must
29
+ * ensure a file-backed SQLite schema exists before dependent services start.
30
+ *
31
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
32
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
33
+ * with an id greater than the latest recorded id are applied, so every client
34
+ * involved in startup should point at the same SQLite filename. Concurrent
35
+ * writers can surface SQLite lock timeout errors, and this adapter does not
36
+ * currently write SQLite schema dumps for `schemaDirectory`.
37
+ *
38
+ * @since 4.0.0
10
39
  */
11
40
  export * as SqliteMigrator from "./SqliteMigrator.ts";
12
41
  //# 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;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -1,13 +1,42 @@
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
+ * Node.js SQLite client implementation for Effect SQL, backed by `better-sqlite3`.
7
+ *
8
+ * This module exposes constructors and layers for providing both the SQLite-specific `SqliteClient`
9
+ * service and the generic `SqlClient` service. It is intended for file-backed or in-memory SQLite
10
+ * databases in Node applications, local development tools, tests, migrations, and embedded
11
+ * persistence use cases that need Effect SQL query compilation plus SQLite-specific operations such
12
+ * as exporting a database, creating backups, or loading native SQLite extensions.
13
+ *
14
+ * Each client owns one scoped `better-sqlite3` connection and serializes access through it. WAL mode
15
+ * is enabled by default, so set `disableWAL` when opening read-only databases or when the database
16
+ * location cannot change journal mode. Prepared statements are cached by SQL text, safe integer
17
+ * handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
18
+ * SQLite does not support `updateValues`.
19
+ *
20
+ * @since 4.0.0
7
21
  */
8
22
  export * as SqliteClient from "./SqliteClient.js";
9
23
  /**
10
- * @since 1.0.0
24
+ * Utilities for applying Effect SQL migrations to Node.js SQLite databases.
25
+ *
26
+ * This module re-exports the shared `Migrator` loaders and error types, then
27
+ * provides `run` and `layer` helpers for applying ordered migrations through the
28
+ * current SQLite `SqlClient`. It is typically used at application startup, in
29
+ * tests that create temporary database files, or in layer graphs that must
30
+ * ensure a file-backed SQLite schema exists before dependent services start.
31
+ *
32
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
33
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
34
+ * with an id greater than the latest recorded id are applied, so every client
35
+ * involved in startup should point at the same SQLite filename. Concurrent
36
+ * writers can surface SQLite lock timeout errors, and this adapter does not
37
+ * currently write SQLite schema dumps for `schemaDirectory`.
38
+ *
39
+ * @since 4.0.0
11
40
  */
12
41
  export * as SqliteMigrator from "./SqliteMigrator.js";
13
42
  //# 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;;;;;;;;;;;;;;;;;AAiBA,OAAO,KAAKA,YAAY,MAAM,mBAAmB;AAEjD;;;;;;;;;;;;;;;;;;AAkBA,OAAO,KAAKC,cAAc,MAAM,qBAAqB","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/sql-sqlite-node",
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",
@@ -44,14 +44,14 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/better-sqlite3": "^7.6.13",
47
- "@effect/platform-node": "^4.0.0-beta.7",
48
- "effect": "^4.0.0-beta.7"
47
+ "effect": "^4.0.0-beta.70",
48
+ "@effect/platform-node": "^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
  "dependencies": {
54
- "better-sqlite3": "^12.6.2"
54
+ "better-sqlite3": "^12.9.0"
55
55
  },
56
56
  "scripts": {
57
57
  "codegen": "effect-utils codegen",
@@ -1,9 +1,24 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Node.js SQLite client implementation for Effect SQL, backed by `better-sqlite3`.
3
+ *
4
+ * This module exposes constructors and layers for providing both the SQLite-specific `SqliteClient`
5
+ * service and the generic `SqlClient` service. It is intended for file-backed or in-memory SQLite
6
+ * databases in Node applications, local development tools, tests, migrations, and embedded
7
+ * persistence use cases that need Effect SQL query compilation plus SQLite-specific operations such
8
+ * as exporting a database, creating backups, or loading native SQLite extensions.
9
+ *
10
+ * Each client owns one scoped `better-sqlite3` connection and serializes access through it. WAL mode
11
+ * is enabled by default, so set `disableWAL` when opening read-only databases or when the database
12
+ * location cannot change journal mode. Prepared statements are cached by SQL text, safe integer
13
+ * handling follows the `SqlClient` fiber-local setting, `executeStream` is not implemented, and
14
+ * SQLite does not support `updateValues`.
15
+ *
16
+ * @since 4.0.0
3
17
  */
4
18
  import Sqlite from "better-sqlite3"
5
19
  import * as Cache from "effect/Cache"
6
20
  import * as Config from "effect/Config"
21
+ import * as Context from "effect/Context"
7
22
  import * as Duration from "effect/Duration"
8
23
  import * as Effect from "effect/Effect"
9
24
  import * as Fiber from "effect/Fiber"
@@ -11,31 +26,39 @@ import { identity } from "effect/Function"
11
26
  import * as Layer from "effect/Layer"
12
27
  import * as Scope from "effect/Scope"
13
28
  import * as Semaphore from "effect/Semaphore"
14
- import * as ServiceMap from "effect/ServiceMap"
15
29
  import * as Stream from "effect/Stream"
16
30
  import * as Reactivity from "effect/unstable/reactivity/Reactivity"
17
31
  import * as Client from "effect/unstable/sql/SqlClient"
18
32
  import type { Connection } from "effect/unstable/sql/SqlConnection"
19
- import { SqlError } from "effect/unstable/sql/SqlError"
33
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError"
20
34
  import * as Statement from "effect/unstable/sql/Statement"
21
35
 
22
36
  const ATTR_DB_SYSTEM_NAME = "db.system.name"
23
37
 
38
+ const classifyError = (cause: unknown, message: string, operation: string) =>
39
+ classifySqliteError(cause, { message, operation })
40
+
24
41
  /**
25
- * @category type ids
26
- * @since 1.0.0
42
+ * Runtime type identifier used to mark Node `SqliteClient` values.
43
+ *
44
+ * @category type IDs
45
+ * @since 4.0.0
27
46
  */
28
47
  export const TypeId: TypeId = "~@effect/sql-sqlite-node/SqliteClient"
29
48
 
30
49
  /**
31
- * @category type ids
32
- * @since 1.0.0
50
+ * Type-level identifier used to mark Node `SqliteClient` values.
51
+ *
52
+ * @category type IDs
53
+ * @since 4.0.0
33
54
  */
34
55
  export type TypeId = "~@effect/sql-sqlite-node/SqliteClient"
35
56
 
36
57
  /**
58
+ * Node SQLite client service, extending `SqlClient` with database export, backup, and extension loading helpers. `updateValues` is not supported.
59
+ *
37
60
  * @category models
38
- * @since 1.0.0
61
+ * @since 4.0.0
39
62
  */
40
63
  export interface SqliteClient extends Client.SqlClient {
41
64
  readonly [TypeId]: TypeId
@@ -49,8 +72,10 @@ export interface SqliteClient extends Client.SqlClient {
49
72
  }
50
73
 
51
74
  /**
75
+ * Metadata returned from a Node SQLite backup operation, reporting total and remaining page counts.
76
+ *
52
77
  * @category models
53
- * @since 1.0.0
78
+ * @since 4.0.0
54
79
  */
55
80
  export interface BackupMetadata {
56
81
  readonly totalPages: number
@@ -58,14 +83,18 @@ export interface BackupMetadata {
58
83
  }
59
84
 
60
85
  /**
86
+ * Context service tag for the node SQLite client implementation.
87
+ *
61
88
  * @category tags
62
- * @since 1.0.0
89
+ * @since 4.0.0
63
90
  */
64
- export const SqliteClient = ServiceMap.Service<SqliteClient>("@effect/sql-sqlite-node/SqliteClient")
91
+ export const SqliteClient = Context.Service<SqliteClient>("@effect/sql-sqlite-node/SqliteClient")
65
92
 
66
93
  /**
94
+ * Configuration for a node SQLite client backed by `better-sqlite3`, including the database filename, read-only mode, statement cache settings, WAL behavior, span attributes, and query/result name transforms.
95
+ *
67
96
  * @category models
68
- * @since 1.0.0
97
+ * @since 4.0.0
69
98
  */
70
99
  export interface SqliteClientConfig {
71
100
  readonly filename: string
@@ -86,8 +115,10 @@ interface SqliteConnection extends Connection {
86
115
  }
87
116
 
88
117
  /**
89
- * @category constructor
90
- * @since 1.0.0
118
+ * Creates a scoped node SQLite client from the supplied configuration, using a single serialized connection with WAL enabled by default and exposing SQLite-specific `export`, `backup`, and `loadExtension` operations.
119
+ *
120
+ * @category constructors
121
+ * @since 4.0.0
91
122
  */
92
123
  export const make = (
93
124
  options: SqliteClientConfig
@@ -117,7 +148,7 @@ export const make = (
117
148
  lookup: (sql: string) =>
118
149
  Effect.try({
119
150
  try: () => db.prepare(sql),
120
- catch: (cause) => new SqlError({ cause, message: "Failed to prepare statement " })
151
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to prepare statement", "prepare") })
121
152
  })
122
153
  })
123
154
 
@@ -127,7 +158,7 @@ export const make = (
127
158
  raw: boolean
128
159
  ) =>
129
160
  Effect.withFiber<ReadonlyArray<any>, SqlError>((fiber) => {
130
- if (ServiceMap.get(fiber.services, Client.SafeIntegers)) {
161
+ if (Context.get(fiber.context, Client.SafeIntegers)) {
131
162
  statement.safeIntegers(true)
132
163
  }
133
164
  try {
@@ -137,7 +168,7 @@ export const make = (
137
168
  const result = statement.run(...params)
138
169
  return Effect.succeed(raw ? result as unknown as ReadonlyArray<any> : [])
139
170
  } catch (cause) {
140
- return Effect.fail(new SqlError({ cause, message: "Failed to execute statement" }))
171
+ return Effect.fail(new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") }))
141
172
  }
142
173
  })
143
174
 
@@ -169,7 +200,7 @@ export const make = (
169
200
  statement.run(...params)
170
201
  return []
171
202
  },
172
- catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
203
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
173
204
  }),
174
205
  (statement) => Effect.sync(() => statement.reader && statement.raw(false))
175
206
  )
@@ -195,18 +226,19 @@ export const make = (
195
226
  },
196
227
  export: Effect.try({
197
228
  try: () => db.serialize(),
198
- catch: (cause) => new SqlError({ cause, message: "Failed to export database" })
229
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to export database", "export") })
199
230
  }),
200
231
  backup(destination) {
201
232
  return Effect.tryPromise({
202
233
  try: () => db.backup(destination),
203
- catch: (cause) => new SqlError({ cause, message: "Failed to backup database" })
234
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to backup database", "backup") })
204
235
  })
205
236
  },
206
237
  loadExtension(path) {
207
238
  return Effect.try({
208
239
  try: () => db.loadExtension(path),
209
- catch: (cause) => new SqlError({ cause, message: "Failed to load extension" })
240
+ catch: (cause) =>
241
+ new SqlError({ reason: classifyError(cause, "Failed to load extension", "loadExtension") })
210
242
  })
211
243
  }
212
244
  })
@@ -218,7 +250,7 @@ export const make = (
218
250
  const acquirer = semaphore.withPermits(1)(Effect.succeed(connection))
219
251
  const transactionAcquirer = Effect.uninterruptibleMask((restore) => {
220
252
  const fiber = Fiber.getCurrent()!
221
- const scope = ServiceMap.getUnsafe(fiber.services, Scope.Scope)
253
+ const scope = Context.getUnsafe(fiber.context, Scope.Scope)
222
254
  return Effect.as(
223
255
  Effect.tap(
224
256
  restore(semaphore.take(1)),
@@ -250,33 +282,37 @@ export const make = (
250
282
  })
251
283
 
252
284
  /**
285
+ * Builds a layer from an Effect `Config` value, providing both the node `SqliteClient` service and the generic `SqlClient` service.
286
+ *
253
287
  * @category layers
254
- * @since 1.0.0
288
+ * @since 4.0.0
255
289
  */
256
290
  export const layerConfig = (
257
291
  config: Config.Wrap<SqliteClientConfig>
258
292
  ): Layer.Layer<SqliteClient | Client.SqlClient, Config.ConfigError> =>
259
- Layer.effectServices(
260
- Config.unwrap(config).asEffect().pipe(
293
+ Layer.effectContext(
294
+ Config.unwrap(config).pipe(
261
295
  Effect.flatMap(make),
262
296
  Effect.map((client) =>
263
- ServiceMap.make(SqliteClient, client).pipe(
264
- ServiceMap.add(Client.SqlClient, client)
297
+ Context.make(SqliteClient, client).pipe(
298
+ Context.add(Client.SqlClient, client)
265
299
  )
266
300
  )
267
301
  )
268
302
  ).pipe(Layer.provide(Reactivity.layer))
269
303
 
270
304
  /**
305
+ * Builds a layer from a node SQLite client configuration, providing both `SqliteClient` and the generic `SqlClient` service.
306
+ *
271
307
  * @category layers
272
- * @since 1.0.0
308
+ * @since 4.0.0
273
309
  */
274
310
  export const layer = (
275
311
  config: SqliteClientConfig
276
312
  ): Layer.Layer<SqliteClient | Client.SqlClient> =>
277
- Layer.effectServices(
313
+ Layer.effectContext(
278
314
  Effect.map(make(config), (client) =>
279
- ServiceMap.make(SqliteClient, client).pipe(
280
- ServiceMap.add(Client.SqlClient, client)
315
+ Context.make(SqliteClient, client).pipe(
316
+ Context.add(Client.SqlClient, client)
281
317
  ))
282
318
  ).pipe(Layer.provide(Reactivity.layer))
@@ -1,5 +1,20 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Utilities for applying Effect SQL migrations to Node.js 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 the
6
+ * current SQLite `SqlClient`. It is typically used at application startup, in
7
+ * tests that create temporary database files, or in layer graphs that must
8
+ * ensure a file-backed SQLite schema exists before dependent services start.
9
+ *
10
+ * Migrations are recorded in `effect_sql_migrations` by default and are loaded
11
+ * using the shared `<id>_<name>` file or record-key convention. Only migrations
12
+ * with an id greater than the latest recorded id are applied, so every client
13
+ * involved in startup should point at the same SQLite filename. Concurrent
14
+ * writers can surface SQLite lock timeout errors, and this adapter does not
15
+ * currently write SQLite schema dumps for `schemaDirectory`.
16
+ *
17
+ * @since 4.0.0
3
18
  */
4
19
  import type * as Effect from "effect/Effect"
5
20
  import * as Layer from "effect/Layer"
@@ -8,13 +23,15 @@ import type * as Client from "effect/unstable/sql/SqlClient"
8
23
  import type { SqlError } from "effect/unstable/sql/SqlError"
9
24
 
10
25
  /**
11
- * @since 1.0.0
26
+ * @since 4.0.0
12
27
  */
13
28
  export * from "effect/unstable/sql/Migrator"
14
29
 
15
30
  /**
16
- * @category constructor
17
- * @since 1.0.0
31
+ * Runs SQL migrations for a SQLite database using the shared `Migrator` implementation and the current `SqlClient`.
32
+ *
33
+ * @category constructors
34
+ * @since 4.0.0
18
35
  */
19
36
  export const run: <R2 = never>(
20
37
  options: Migrator.MigratorOptions<R2>
@@ -67,8 +84,10 @@ export const run: <R2 = never>(
67
84
  })
68
85
 
69
86
  /**
70
- * @category constructor
71
- * @since 1.0.0
87
+ * Creates a layer that runs the configured SQLite migrations during layer construction and provides no services.
88
+ *
89
+ * @category constructors
90
+ * @since 4.0.0
72
91
  */
73
92
  export const layer = <R>(
74
93
  options: Migrator.MigratorOptions<R>
package/src/index.ts CHANGED
@@ -1,15 +1,44 @@
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
+ * Node.js SQLite client implementation for Effect SQL, backed by `better-sqlite3`.
9
+ *
10
+ * This module exposes constructors and layers for providing both the SQLite-specific `SqliteClient`
11
+ * service and the generic `SqlClient` service. It is intended for file-backed or in-memory SQLite
12
+ * databases in Node applications, local development tools, tests, migrations, and embedded
13
+ * persistence use cases that need Effect SQL query compilation plus SQLite-specific operations such
14
+ * as exporting a database, creating backups, or loading native SQLite extensions.
15
+ *
16
+ * Each client owns one scoped `better-sqlite3` connection and serializes access through it. WAL mode
17
+ * is enabled by default, so set `disableWAL` when opening read-only databases or when the database
18
+ * location cannot change journal mode. Prepared statements are cached by SQL text, 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
9
23
  */
10
24
  export * as SqliteClient from "./SqliteClient.ts"
11
25
 
12
26
  /**
13
- * @since 1.0.0
27
+ * Utilities for applying Effect SQL migrations to Node.js 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 the
31
+ * current SQLite `SqlClient`. It is typically used at application startup, in
32
+ * tests that create temporary database files, or in layer graphs that must
33
+ * ensure a file-backed SQLite schema exists before dependent services start.
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. Concurrent
39
+ * writers can surface SQLite lock timeout errors, and this adapter does not
40
+ * currently write SQLite schema dumps for `schemaDirectory`.
41
+ *
42
+ * @since 4.0.0
14
43
  */
15
44
  export * as SqliteMigrator from "./SqliteMigrator.ts"