@effect/sql-libsql 4.0.0-beta.8 → 4.0.0-beta.81

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,51 +1,76 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * libSQL adapter for Effect SQL, backed by `@libsql/client`.
3
+ *
4
+ * This module provides a {@link LibsqlClient} and the generic SQL client
5
+ * service for `@libsql/client`. It uses Effect SQL's SQLite compiler, supports
6
+ * managed SDK clients or caller-owned live clients, classifies libSQL and
7
+ * SQLite failures as `SqlError`s, and provides transaction support with
8
+ * savepoints. Streaming queries are not implemented by this driver.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import * as Libsql from "@libsql/client";
5
13
  import * as Config from "effect/Config";
14
+ import * as Context from "effect/Context";
6
15
  import * as Effect from "effect/Effect";
7
16
  import * as Layer from "effect/Layer";
8
17
  import * as Redacted from "effect/Redacted";
9
18
  import * as Scope from "effect/Scope";
10
- import * as ServiceMap from "effect/ServiceMap";
11
19
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
12
20
  import * as Client from "effect/unstable/sql/SqlClient";
13
21
  /**
14
- * @category type ids
15
- * @since 1.0.0
22
+ * Runtime type identifier used to mark `LibsqlClient` values.
23
+ *
24
+ * @category type IDs
25
+ * @since 4.0.0
16
26
  */
17
27
  export declare const TypeId: TypeId;
18
28
  /**
19
- * @category type ids
20
- * @since 1.0.0
29
+ * Type-level identifier used to mark `LibsqlClient` values.
30
+ *
31
+ * @category type IDs
32
+ * @since 4.0.0
21
33
  */
22
34
  export type TypeId = "~@effect/sql-libsql/LibsqlClient";
23
35
  /**
36
+ * libSQL-backed SQL client service, extending `SqlClient` with its runtime type marker and client configuration.
37
+ *
24
38
  * @category models
25
- * @since 1.0.0
39
+ * @since 4.0.0
26
40
  */
27
41
  export interface LibsqlClient extends Client.SqlClient {
28
42
  readonly [TypeId]: TypeId;
29
43
  readonly config: LibsqlClientConfig;
30
44
  }
31
45
  /**
32
- * @category tags
33
- * @since 1.0.0
46
+ * Service tag for the libSQL client service.
47
+ *
48
+ * **When to use**
49
+ *
50
+ * Use to access or provide a libSQL client through the Effect context.
51
+ *
52
+ * @category services
53
+ * @since 4.0.0
34
54
  */
35
- export declare const LibsqlClient: ServiceMap.Service<LibsqlClient, LibsqlClient>;
55
+ export declare const LibsqlClient: Context.Service<LibsqlClient, LibsqlClient>;
36
56
  /**
57
+ * Configuration for a libSQL client, either by supplying connection options or an existing live libSQL client.
58
+ *
37
59
  * @category models
38
- * @since 1.0.0
60
+ * @since 4.0.0
39
61
  */
40
62
  export type LibsqlClientConfig = LibsqlClientConfig.Full | LibsqlClientConfig.Live;
41
63
  /**
42
- * @category models
43
- * @since 1.0.0
64
+ * Namespace containing the configuration variants for `LibsqlClient`.
65
+ *
66
+ * @since 4.0.0
44
67
  */
45
68
  export declare namespace LibsqlClientConfig {
46
69
  /**
70
+ * Shared libSQL client options for span attributes and query/result name transformations.
71
+ *
47
72
  * @category models
48
- * @since 1.0.0
73
+ * @since 4.0.0
49
74
  */
50
75
  interface Base {
51
76
  readonly spanAttributes?: Record<string, unknown> | undefined;
@@ -53,11 +78,16 @@ export declare namespace LibsqlClientConfig {
53
78
  readonly transformQueryNames?: ((str: string) => string) | undefined;
54
79
  }
55
80
  /**
81
+ * Connection-based libSQL configuration used to create a managed client, including URL, credentials, sync, integer mode, TLS, and concurrency options.
82
+ *
56
83
  * @category models
57
- * @since 1.0.0
84
+ * @since 4.0.0
58
85
  */
59
86
  interface Full extends Base {
60
- /** The database URL.
87
+ /**
88
+ * The database URL.
89
+ *
90
+ * **Details**
61
91
  *
62
92
  * The client supports `libsql:`, `http:`/`https:`, `ws:`/`wss:` and `file:` URL. For more infomation,
63
93
  * please refer to the project README:
@@ -73,12 +103,18 @@ export declare namespace LibsqlClientConfig {
73
103
  readonly syncUrl?: string | URL | undefined;
74
104
  /** Sync interval in seconds. */
75
105
  readonly syncInterval?: number | undefined;
76
- /** Enables or disables TLS for `libsql:` URLs.
106
+ /**
107
+ * Enables or disables TLS for `libsql:` URLs.
108
+ *
109
+ * **Details**
77
110
  *
78
111
  * By default, `libsql:` URLs use TLS. You can set this option to `false` to disable TLS.
79
112
  */
80
113
  readonly tls?: boolean | undefined;
81
- /** How to convert SQLite integers to JavaScript values:
114
+ /**
115
+ * How to convert SQLite integers to JavaScript values.
116
+ *
117
+ * **Details**
82
118
  *
83
119
  * - `"number"` (default): returns SQLite integers as JavaScript `number`-s (double precision floats).
84
120
  * `number` cannot precisely represent integers larger than 2^53-1 in absolute value, so attempting to read
@@ -88,7 +124,10 @@ export declare namespace LibsqlClientConfig {
88
124
  * - `"string"`: returns SQLite integers as strings.
89
125
  */
90
126
  readonly intMode?: "number" | "bigint" | "string" | undefined;
91
- /** Concurrency limit.
127
+ /**
128
+ * Concurrency limit.
129
+ *
130
+ * **Details**
92
131
  *
93
132
  * By default, the client performs up to 20 concurrent requests. You can set this option to a higher
94
133
  * number to increase the concurrency limit or set it to 0 to disable concurrency limits completely.
@@ -96,26 +135,34 @@ export declare namespace LibsqlClientConfig {
96
135
  readonly concurrency?: number | undefined;
97
136
  }
98
137
  /**
138
+ * Configuration that uses an existing libSQL client. The supplied `liveClient` is caller-owned and is not closed by the Effect client.
139
+ *
99
140
  * @category models
100
- * @since 1.0.0
141
+ * @since 4.0.0
101
142
  */
102
143
  interface Live extends Base {
103
144
  readonly liveClient: Libsql.Client;
104
145
  }
105
146
  }
106
147
  /**
107
- * @category constructor
108
- * @since 1.0.0
148
+ * Creates a scoped libSQL SQL client with transaction support. When given connection options it creates and closes the SDK client; when given `liveClient`, the caller retains ownership.
149
+ *
150
+ * @category constructors
151
+ * @since 4.0.0
109
152
  */
110
153
  export declare const make: (options: LibsqlClientConfig) => Effect.Effect<LibsqlClient, never, Scope.Scope | Reactivity.Reactivity>;
111
154
  /**
155
+ * Creates a layer from a `Config`-wrapped libSQL client configuration, providing both `LibsqlClient` and `SqlClient`.
156
+ *
112
157
  * @category layers
113
- * @since 1.0.0
158
+ * @since 4.0.0
114
159
  */
115
160
  export declare const layerConfig: (config: Config.Wrap<LibsqlClientConfig>) => Layer.Layer<LibsqlClient | Client.SqlClient, Config.ConfigError>;
116
161
  /**
162
+ * Creates a layer from a concrete libSQL client configuration, providing both `LibsqlClient` and `SqlClient`.
163
+ *
117
164
  * @category layers
118
- * @since 1.0.0
165
+ * @since 4.0.0
119
166
  */
120
167
  export declare const layer: (config: LibsqlClientConfig) => Layer.Layer<LibsqlClient | Client.SqlClient>;
121
168
  //# sourceMappingURL=LibsqlClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LibsqlClient.d.ts","sourceRoot":"","sources":["../src/LibsqlClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAOvD;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,MAA2C,CAAA;AAEhE;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,kCAAkC,CAAA;AAEvD;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,SAAS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,gDAAsE,CAAA;AAM/F;;;GAGG;AACH,MAAM,MAAM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OAAO,GAAG,SAAS,CAAA;QAClC;;;;;;;;;;;WAWG;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;QAC7D;;;;;;;WAOG;QACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1C;IAED;;;;;OAKG;IACH,UAAiB,IAAK,SAAQ,IAAI;QAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAA;KACnC;CACF;AAQD;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GACf,SAAS,kBAAkB,KAC1B,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,UAAU,CA8JrE,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,CACxB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KACpC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAY3B,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,QAAQ,kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
@@ -1,35 +1,57 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * libSQL adapter for Effect SQL, backed by `@libsql/client`.
3
+ *
4
+ * This module provides a {@link LibsqlClient} and the generic SQL client
5
+ * service for `@libsql/client`. It uses Effect SQL's SQLite compiler, supports
6
+ * managed SDK clients or caller-owned live clients, classifies libSQL and
7
+ * SQLite failures as `SqlError`s, and provides transaction support with
8
+ * savepoints. Streaming queries are not implemented by this driver.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import * as Libsql from "@libsql/client";
5
13
  import * as Config from "effect/Config";
14
+ import * as Context from "effect/Context";
6
15
  import * as Effect from "effect/Effect";
7
16
  import * as Layer from "effect/Layer";
8
17
  import * as Option from "effect/Option";
9
18
  import * as Redacted from "effect/Redacted";
10
19
  import * as Scope from "effect/Scope";
11
20
  import * as Semaphore from "effect/Semaphore";
12
- import * as ServiceMap from "effect/ServiceMap";
13
21
  import * as Stream from "effect/Stream";
14
22
  import * as Reactivity from "effect/unstable/reactivity/Reactivity";
15
23
  import * as Client from "effect/unstable/sql/SqlClient";
16
- import { SqlError } from "effect/unstable/sql/SqlError";
24
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError";
17
25
  import * as Statement from "effect/unstable/sql/Statement";
18
26
  const ATTR_DB_SYSTEM_NAME = "db.system.name";
27
+ const classifyError = (cause, message, operation) => classifySqliteError(cause, {
28
+ message,
29
+ operation
30
+ });
19
31
  /**
20
- * @category type ids
21
- * @since 1.0.0
32
+ * Runtime type identifier used to mark `LibsqlClient` values.
33
+ *
34
+ * @category type IDs
35
+ * @since 4.0.0
22
36
  */
23
37
  export const TypeId = "~@effect/sql-libsql/LibsqlClient";
24
38
  /**
25
- * @category tags
26
- * @since 1.0.0
39
+ * Service tag for the libSQL client service.
40
+ *
41
+ * **When to use**
42
+ *
43
+ * Use to access or provide a libSQL client through the Effect context.
44
+ *
45
+ * @category services
46
+ * @since 4.0.0
27
47
  */
28
- export const LibsqlClient = /*#__PURE__*/ServiceMap.Service("@effect/sql-libsql/LibsqlClient");
29
- const LibsqlTransaction = /*#__PURE__*/ServiceMap.Service("@effect/sql-libsql/LibsqlClient/LibsqlTransaction");
48
+ export const LibsqlClient = /*#__PURE__*/Context.Service("@effect/sql-libsql/LibsqlClient");
49
+ const LibsqlTransaction = /*#__PURE__*/Context.Service("@effect/sql-libsql/LibsqlClient/LibsqlTransaction");
30
50
  /**
31
- * @category constructor
32
- * @since 1.0.0
51
+ * Creates a scoped libSQL SQL client with transaction support. When given connection options it creates and closes the SDK client; when given `liveClient`, the caller retains ownership.
52
+ *
53
+ * @category constructors
54
+ * @since 4.0.0
33
55
  */
34
56
  export const make = options => Effect.gen(function* () {
35
57
  const compiler = Statement.makeCompilerSqlite(options.transformQueryNames);
@@ -47,8 +69,7 @@ export const make = options => Effect.gen(function* () {
47
69
  args: params
48
70
  }),
49
71
  catch: cause => new SqlError({
50
- cause,
51
- message: "Failed to execute statement"
72
+ reason: classifyError(cause, "Failed to execute statement", "execute")
52
73
  })
53
74
  }), results => results.rows);
54
75
  }
@@ -59,8 +80,7 @@ export const make = options => Effect.gen(function* () {
59
80
  args: params
60
81
  }),
61
82
  catch: cause => new SqlError({
62
- cause,
63
- message: "Failed to execute statement"
83
+ reason: classifyError(cause, "Failed to execute statement", "execute")
64
84
  })
65
85
  });
66
86
  }
@@ -83,8 +103,7 @@ export const make = options => Effect.gen(function* () {
83
103
  return Effect.map(Effect.tryPromise({
84
104
  try: () => this.sdk.transaction("write"),
85
105
  catch: cause => new SqlError({
86
- cause,
87
- message: "Failed to begin transaction"
106
+ reason: classifyError(cause, "Failed to begin transaction", "beginTransaction")
88
107
  })
89
108
  }), tx => new LibsqlConnectionImpl(tx));
90
109
  }
@@ -92,8 +111,7 @@ export const make = options => Effect.gen(function* () {
92
111
  return Effect.tryPromise({
93
112
  try: () => this.sdk.commit(),
94
113
  catch: cause => new SqlError({
95
- cause,
96
- message: "Failed to commit transaction"
114
+ reason: classifyError(cause, "Failed to commit transaction", "commitTransaction")
97
115
  })
98
116
  });
99
117
  }
@@ -101,8 +119,7 @@ export const make = options => Effect.gen(function* () {
101
119
  return Effect.tryPromise({
102
120
  try: () => this.sdk.rollback(),
103
121
  catch: cause => new SqlError({
104
- cause,
105
- message: "Failed to rollback transaction"
122
+ reason: classifyError(cause, "Failed to rollback transaction", "rollbackTransaction")
106
123
  })
107
124
  });
108
125
  }
@@ -149,13 +166,17 @@ export const make = options => Effect.gen(function* () {
149
166
  });
150
167
  });
151
168
  /**
169
+ * Creates a layer from a `Config`-wrapped libSQL client configuration, providing both `LibsqlClient` and `SqlClient`.
170
+ *
152
171
  * @category layers
153
- * @since 1.0.0
172
+ * @since 4.0.0
154
173
  */
155
- export const layerConfig = config => Layer.effectServices(Config.unwrap(config).asEffect().pipe(Effect.flatMap(make), Effect.map(client => ServiceMap.make(LibsqlClient, client).pipe(ServiceMap.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));
174
+ export const layerConfig = config => Layer.effectContext(Config.unwrap(config).pipe(Effect.flatMap(make), Effect.map(client => Context.make(LibsqlClient, client).pipe(Context.add(Client.SqlClient, client))))).pipe(Layer.provide(Reactivity.layer));
156
175
  /**
176
+ * Creates a layer from a concrete libSQL client configuration, providing both `LibsqlClient` and `SqlClient`.
177
+ *
157
178
  * @category layers
158
- * @since 1.0.0
179
+ * @since 4.0.0
159
180
  */
160
- export const layer = config => Layer.effectServices(Effect.map(make(config), client => ServiceMap.make(LibsqlClient, client).pipe(ServiceMap.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
181
+ export const layer = config => Layer.effectContext(Effect.map(make(config), client => Context.make(LibsqlClient, client).pipe(Context.add(Client.SqlClient, client)))).pipe(Layer.provide(Reactivity.layer));
161
182
  //# sourceMappingURL=LibsqlClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LibsqlClient.js","names":["Libsql","Config","Effect","Layer","Option","Redacted","Scope","Semaphore","ServiceMap","Stream","Reactivity","Client","SqlError","Statement","ATTR_DB_SYSTEM_NAME","TypeId","LibsqlClient","Service","LibsqlTransaction","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","spanAttributes","Object","entries","LibsqlConnectionImpl","sdk","constructor","run","sql","params","map","tryPromise","try","execute","args","catch","cause","message","results","rows","runRaw","executeRaw","executeValues","row","Array","from","executeUnprepared","executeStream","die","beginTransaction","transaction","tx","commit","rollback","connection","liveClient","acquireRelease","sync","createClient","authToken","isRedacted","value","encryptionKey","url","toString","syncUrl","close","semaphore","withTransaction","makeWithTransaction","transactionService","acquireConnection","uninterruptibleMask","fnUntraced","restore","scope","makeUnsafe","take","addFinalizer","release","conn","begin","void","savepoint","id","rollbackSavepoint","acquirer","flatMap","serviceOption","match","onNone","withPermits","succeed","onSome","assign","config","layerConfig","effectServices","unwrap","asEffect","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/LibsqlClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,UAAU,MAAM,mBAAmB;AAC/C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD,SAASC,QAAQ,QAAQ,8BAA8B;AACvD,OAAO,KAAKC,SAAS,MAAM,+BAA+B;AAE1D,MAAMC,mBAAmB,GAAG,gBAAgB;AAE5C;;;;AAIA,OAAO,MAAMC,MAAM,GAAW,kCAAkC;AAiBhE;;;;AAIA,OAAO,MAAMC,YAAY,gBAAGR,UAAU,CAACS,OAAO,CAAe,iCAAiC,CAAC;AAE/F,MAAMC,iBAAiB,gBAAGV,UAAU,CAACS,OAAO,CAC1C,mDAAmD,CACpD;AAkFD;;;;AAIA,OAAO,MAAME,IAAI,GACfC,OAA2B,IAE3BlB,MAAM,CAACmB,GAAG,CAAC,aAAS;EAClB,MAAMC,QAAQ,GAAGT,SAAS,CAACU,kBAAkB,CAACH,OAAO,CAACI,mBAAmB,CAAC;EAC1E,MAAMC,aAAa,GAAGL,OAAO,CAACM,oBAAoB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AAK,CAAC8G,OAAO,CAACvG,UAAU,CAACwG,KAAK,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"LibsqlClient.js","names":["Libsql","Config","Context","Effect","Layer","Option","Redacted","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","LibsqlClient","Service","LibsqlTransaction","make","options","gen","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","spanAttributes","Object","entries","LibsqlConnectionImpl","sdk","constructor","run","sql","params","map","tryPromise","try","execute","args","catch","reason","results","rows","runRaw","executeRaw","executeValues","row","Array","from","executeUnprepared","executeStream","die","beginTransaction","transaction","tx","commit","rollback","connection","liveClient","acquireRelease","sync","createClient","authToken","isRedacted","value","encryptionKey","url","toString","syncUrl","close","semaphore","withTransaction","makeWithTransaction","transactionService","acquireConnection","uninterruptibleMask","fnUntraced","restore","scope","makeUnsafe","take","addFinalizer","release","conn","begin","void","savepoint","id","rollbackSavepoint","acquirer","flatMap","serviceOption","match","onNone","withPermits","succeed","onSome","assign","config","layerConfig","effectContext","unwrap","pipe","client","add","SqlClient","provide","layer"],"sources":["../src/LibsqlClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;AAWA,OAAO,KAAKA,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,QAAQ,MAAM,iBAAiB;AAC3C,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCA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M,EAAEnF,OAAO;IACfwD,eAAe;IACf1C,GAAG,EAAE4B,UAAU,CAAC5B;GACjB,CACF;AACH,CAAC,CAAC;AAEJ;;;;;;AAMA,OAAO,MAAMsE,WAAW,GAGtBD,MAAuC,IAEvCxG,KAAK,CAAC0G,aAAa,CACjB7G,MAAM,CAAC8G,MAAM,CAACH,MAAM,CAAC,CAACI,IAAI,CACxB7G,MAAM,CAACiG,OAAO,CAAC5E,IAAI,CAAC,EACpBrB,MAAM,CAACyC,GAAG,CAAEqE,MAAM,IAChB/G,OAAO,CAACsB,IAAI,CAACH,YAAY,EAAE4F,MAAM,CAAC,CAACD,IAAI,CACrC9G,OAAO,CAACgH,GAAG,CAACvG,MAAM,CAACwG,SAAS,EAAEF,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAACD,IAAI,CAAC5G,KAAK,CAACgH,OAAO,CAAC1G,UAAU,CAAC2G,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAMA,KAAK,GAChBT,MAA0B,IAE1BxG,KAAK,CAAC0G,aAAa,CACjB3G,MAAM,CAACyC,GAAG,CAACpB,IAAI,CAACoF,MAAM,CAAC,EAAGK,MAAM,IAC9B/G,OAAO,CAACsB,IAAI,CAACH,YAAY,EAAE4F,MAAM,CAAC,CAACD,IAAI,CACrC9G,OAAO,CAACgH,GAAG,CAACvG,MAAM,CAACwG,SAAS,EAAEF,MAAM,CAAC,CACtC,CAAC,CACL,CAACD,IAAI,CAAC5G,KAAK,CAACgH,OAAO,CAAC1G,UAAU,CAAC2G,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,14 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * libSQL migration support for Effect SQL applications.
3
+ *
4
+ * This module adapts the shared SQL migrator to libSQL. It re-exports the
5
+ * common migration loaders and errors, then provides {@link run} and
6
+ * {@link layer} helpers that apply pending migrations with the current
7
+ * libSQL-backed `SqlClient`. `run` returns the applied migration IDs and names,
8
+ * while `layer` runs migrations during layer construction and provides no
9
+ * services.
10
+ *
11
+ * @since 4.0.0
3
12
  */
4
13
  import type * as Effect from "effect/Effect";
5
14
  import * as Layer from "effect/Layer";
@@ -7,17 +16,21 @@ import * as Migrator from "effect/unstable/sql/Migrator";
7
16
  import type * as Client from "effect/unstable/sql/SqlClient";
8
17
  import type { SqlError } from "effect/unstable/sql/SqlError";
9
18
  /**
10
- * @since 1.0.0
19
+ * @since 4.0.0
11
20
  */
12
21
  export * from "effect/unstable/sql/Migrator";
13
22
  /**
14
- * @category constructor
15
- * @since 1.0.0
23
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
24
+ *
25
+ * @category constructors
26
+ * @since 4.0.0
16
27
  */
17
28
  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
29
  /**
19
- * @category constructor
20
- * @since 1.0.0
30
+ * Creates a layer that runs the configured SQL migrations during layer construction.
31
+ *
32
+ * @category constructors
33
+ * @since 4.0.0
21
34
  */
22
35
  export declare const layer: <R>(options: Migrator.MigratorOptions<R>) => Layer.Layer<never, Migrator.MigrationError | SqlError, Client.SqlClient | R>;
23
36
  //# sourceMappingURL=LibsqlMigrator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LibsqlMigrator.d.ts","sourceRoot":"","sources":["../src/LibsqlMigrator.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,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;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EACrB,SAAS,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,KACnC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,GAAG,QAAQ,EAAE,MAAM,CAAC,SAAS,GAAG,CAAC,CAAsC,CAAA"}
@@ -1,17 +1,21 @@
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
  /**
13
- * @category constructor
14
- * @since 1.0.0
15
+ * Creates a layer that runs the configured SQL migrations during layer construction.
16
+ *
17
+ * @category constructors
18
+ * @since 4.0.0
15
19
  */
16
20
  export const layer = options => Layer.effectDiscard(run(options));
17
21
  //# sourceMappingURL=LibsqlMigrator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LibsqlMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/LibsqlMigrator.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,EAAE,CAAC;AAErB;;;;AAIA,OAAO,MAAMC,KAAK,GAChBC,OAAoC,IAC6CL,KAAK,CAACM,aAAa,CAACJ,GAAG,CAACG,OAAO,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"LibsqlMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/LibsqlMigrator.ts"],"sourcesContent":[null],"mappings":"AAaA,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,EAAE,CAAC;AAErB;;;;;;AAMA,OAAO,MAAMC,KAAK,GAChBC,OAAoC,IAC6CL,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 LibsqlClient from "./LibsqlClient.ts";
8
8
  /**
9
- * @since 1.0.0
9
+ * @since 4.0.0
10
10
  */
11
11
  export * as LibsqlMigrator from "./LibsqlMigrator.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 LibsqlClient from "./LibsqlClient.js";
9
9
  /**
10
- * @since 1.0.0
10
+ * @since 4.0.0
11
11
  */
12
12
  export * as LibsqlMigrator from "./LibsqlMigrator.js";
13
13
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/sql-libsql",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0-beta.81",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "A libSQL toolkit for Effect",
@@ -45,14 +45,14 @@
45
45
  "provenance": true
46
46
  },
47
47
  "devDependencies": {
48
- "testcontainers": "^11.11.0",
49
- "effect": "^4.0.0-beta.8"
48
+ "testcontainers": "^11.14.0",
49
+ "effect": "^4.0.0-beta.81"
50
50
  },
51
51
  "peerDependencies": {
52
- "effect": "^4.0.0-beta.8"
52
+ "effect": "^4.0.0-beta.81"
53
53
  },
54
54
  "dependencies": {
55
- "@libsql/client": "^0.17.0"
55
+ "@libsql/client": "^0.17.3"
56
56
  },
57
57
  "scripts": {
58
58
  "codegen": "effect-utils codegen",
@@ -1,39 +1,56 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * libSQL adapter for Effect SQL, backed by `@libsql/client`.
3
+ *
4
+ * This module provides a {@link LibsqlClient} and the generic SQL client
5
+ * service for `@libsql/client`. It uses Effect SQL's SQLite compiler, supports
6
+ * managed SDK clients or caller-owned live clients, classifies libSQL and
7
+ * SQLite failures as `SqlError`s, and provides transaction support with
8
+ * savepoints. Streaming queries are not implemented by this driver.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import * as Libsql from "@libsql/client"
5
13
  import * as Config from "effect/Config"
14
+ import * as Context from "effect/Context"
6
15
  import * as Effect from "effect/Effect"
7
16
  import * as Layer from "effect/Layer"
8
17
  import * as Option from "effect/Option"
9
18
  import * as Redacted from "effect/Redacted"
10
19
  import * as Scope from "effect/Scope"
11
20
  import * as Semaphore from "effect/Semaphore"
12
- import * as ServiceMap from "effect/ServiceMap"
13
21
  import * as Stream from "effect/Stream"
14
22
  import * as Reactivity from "effect/unstable/reactivity/Reactivity"
15
23
  import * as Client from "effect/unstable/sql/SqlClient"
16
24
  import type { Connection } from "effect/unstable/sql/SqlConnection"
17
- import { SqlError } from "effect/unstable/sql/SqlError"
25
+ import { classifySqliteError, SqlError } from "effect/unstable/sql/SqlError"
18
26
  import * as Statement from "effect/unstable/sql/Statement"
19
27
 
20
28
  const ATTR_DB_SYSTEM_NAME = "db.system.name"
21
29
 
30
+ const classifyError = (cause: unknown, message: string, operation: string) =>
31
+ classifySqliteError(cause, { message, operation })
32
+
22
33
  /**
23
- * @category type ids
24
- * @since 1.0.0
34
+ * Runtime type identifier used to mark `LibsqlClient` values.
35
+ *
36
+ * @category type IDs
37
+ * @since 4.0.0
25
38
  */
26
39
  export const TypeId: TypeId = "~@effect/sql-libsql/LibsqlClient"
27
40
 
28
41
  /**
29
- * @category type ids
30
- * @since 1.0.0
42
+ * Type-level identifier used to mark `LibsqlClient` values.
43
+ *
44
+ * @category type IDs
45
+ * @since 4.0.0
31
46
  */
32
47
  export type TypeId = "~@effect/sql-libsql/LibsqlClient"
33
48
 
34
49
  /**
50
+ * libSQL-backed SQL client service, extending `SqlClient` with its runtime type marker and client configuration.
51
+ *
35
52
  * @category models
36
- * @since 1.0.0
53
+ * @since 4.0.0
37
54
  */
38
55
  export interface LibsqlClient extends Client.SqlClient {
39
56
  readonly [TypeId]: TypeId
@@ -41,29 +58,40 @@ export interface LibsqlClient extends Client.SqlClient {
41
58
  }
42
59
 
43
60
  /**
44
- * @category tags
45
- * @since 1.0.0
61
+ * Service tag for the libSQL client service.
62
+ *
63
+ * **When to use**
64
+ *
65
+ * Use to access or provide a libSQL client through the Effect context.
66
+ *
67
+ * @category services
68
+ * @since 4.0.0
46
69
  */
47
- export const LibsqlClient = ServiceMap.Service<LibsqlClient>("@effect/sql-libsql/LibsqlClient")
70
+ export const LibsqlClient = Context.Service<LibsqlClient>("@effect/sql-libsql/LibsqlClient")
48
71
 
49
- const LibsqlTransaction = ServiceMap.Service<readonly [LibsqlConnection, counter: number]>(
72
+ const LibsqlTransaction = Context.Service<readonly [LibsqlConnection, counter: number]>(
50
73
  "@effect/sql-libsql/LibsqlClient/LibsqlTransaction"
51
74
  )
52
75
 
53
76
  /**
77
+ * Configuration for a libSQL client, either by supplying connection options or an existing live libSQL client.
78
+ *
54
79
  * @category models
55
- * @since 1.0.0
80
+ * @since 4.0.0
56
81
  */
57
82
  export type LibsqlClientConfig = LibsqlClientConfig.Full | LibsqlClientConfig.Live
58
83
 
59
84
  /**
60
- * @category models
61
- * @since 1.0.0
85
+ * Namespace containing the configuration variants for `LibsqlClient`.
86
+ *
87
+ * @since 4.0.0
62
88
  */
63
89
  export declare namespace LibsqlClientConfig {
64
90
  /**
91
+ * Shared libSQL client options for span attributes and query/result name transformations.
92
+ *
65
93
  * @category models
66
- * @since 1.0.0
94
+ * @since 4.0.0
67
95
  */
68
96
  export interface Base {
69
97
  readonly spanAttributes?: Record<string, unknown> | undefined
@@ -72,11 +100,16 @@ export declare namespace LibsqlClientConfig {
72
100
  }
73
101
 
74
102
  /**
103
+ * Connection-based libSQL configuration used to create a managed client, including URL, credentials, sync, integer mode, TLS, and concurrency options.
104
+ *
75
105
  * @category models
76
- * @since 1.0.0
106
+ * @since 4.0.0
77
107
  */
78
108
  export interface Full extends Base {
79
- /** The database URL.
109
+ /**
110
+ * The database URL.
111
+ *
112
+ * **Details**
80
113
  *
81
114
  * The client supports `libsql:`, `http:`/`https:`, `ws:`/`wss:` and `file:` URL. For more infomation,
82
115
  * please refer to the project README:
@@ -92,12 +125,18 @@ export declare namespace LibsqlClientConfig {
92
125
  readonly syncUrl?: string | URL | undefined
93
126
  /** Sync interval in seconds. */
94
127
  readonly syncInterval?: number | undefined
95
- /** Enables or disables TLS for `libsql:` URLs.
128
+ /**
129
+ * Enables or disables TLS for `libsql:` URLs.
130
+ *
131
+ * **Details**
96
132
  *
97
133
  * By default, `libsql:` URLs use TLS. You can set this option to `false` to disable TLS.
98
134
  */
99
135
  readonly tls?: boolean | undefined
100
- /** How to convert SQLite integers to JavaScript values:
136
+ /**
137
+ * How to convert SQLite integers to JavaScript values.
138
+ *
139
+ * **Details**
101
140
  *
102
141
  * - `"number"` (default): returns SQLite integers as JavaScript `number`-s (double precision floats).
103
142
  * `number` cannot precisely represent integers larger than 2^53-1 in absolute value, so attempting to read
@@ -107,7 +146,10 @@ export declare namespace LibsqlClientConfig {
107
146
  * - `"string"`: returns SQLite integers as strings.
108
147
  */
109
148
  readonly intMode?: "number" | "bigint" | "string" | undefined
110
- /** Concurrency limit.
149
+ /**
150
+ * Concurrency limit.
151
+ *
152
+ * **Details**
111
153
  *
112
154
  * By default, the client performs up to 20 concurrent requests. You can set this option to a higher
113
155
  * number to increase the concurrency limit or set it to 0 to disable concurrency limits completely.
@@ -116,8 +158,10 @@ export declare namespace LibsqlClientConfig {
116
158
  }
117
159
 
118
160
  /**
161
+ * Configuration that uses an existing libSQL client. The supplied `liveClient` is caller-owned and is not closed by the Effect client.
162
+ *
119
163
  * @category models
120
- * @since 1.0.0
164
+ * @since 4.0.0
121
165
  */
122
166
  export interface Live extends Base {
123
167
  readonly liveClient: Libsql.Client
@@ -131,8 +175,10 @@ interface LibsqlConnection extends Connection {
131
175
  }
132
176
 
133
177
  /**
134
- * @category constructor
135
- * @since 1.0.0
178
+ * Creates a scoped libSQL SQL client with transaction support. When given connection options it creates and closes the SDK client; when given `liveClient`, the caller retains ownership.
179
+ *
180
+ * @category constructors
181
+ * @since 4.0.0
136
182
  */
137
183
  export const make = (
138
184
  options: LibsqlClientConfig
@@ -163,7 +209,7 @@ export const make = (
163
209
  return Effect.map(
164
210
  Effect.tryPromise({
165
211
  try: () => this.sdk.execute({ sql, args: params as Array<any> }),
166
- catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
212
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
167
213
  }),
168
214
  (results) => results.rows
169
215
  )
@@ -175,7 +221,7 @@ export const make = (
175
221
  ) {
176
222
  return Effect.tryPromise({
177
223
  try: () => this.sdk.execute({ sql, args: params as Array<any> }),
178
- catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
224
+ catch: (cause) => new SqlError({ reason: classifyError(cause, "Failed to execute statement", "execute") })
179
225
  })
180
226
  }
181
227
 
@@ -208,7 +254,8 @@ export const make = (
208
254
  return Effect.map(
209
255
  Effect.tryPromise({
210
256
  try: () => (this.sdk as Libsql.Client).transaction("write"),
211
- catch: (cause) => new SqlError({ cause, message: "Failed to begin transaction" })
257
+ catch: (cause) =>
258
+ new SqlError({ reason: classifyError(cause, "Failed to begin transaction", "beginTransaction") })
212
259
  }),
213
260
  (tx) => new LibsqlConnectionImpl(tx)
214
261
  )
@@ -216,13 +263,15 @@ export const make = (
216
263
  get commit() {
217
264
  return Effect.tryPromise({
218
265
  try: () => (this.sdk as Libsql.Transaction).commit(),
219
- catch: (cause) => new SqlError({ cause, message: "Failed to commit transaction" })
266
+ catch: (cause) =>
267
+ new SqlError({ reason: classifyError(cause, "Failed to commit transaction", "commitTransaction") })
220
268
  })
221
269
  }
222
270
  get rollback() {
223
271
  return Effect.tryPromise({
224
272
  try: () => (this.sdk as Libsql.Transaction).rollback(),
225
- catch: (cause) => new SqlError({ cause, message: "Failed to rollback transaction" })
273
+ catch: (cause) =>
274
+ new SqlError({ reason: classifyError(cause, "Failed to rollback transaction", "rollbackTransaction") })
226
275
  })
227
276
  }
228
277
  }
@@ -294,35 +343,39 @@ export const make = (
294
343
  })
295
344
 
296
345
  /**
346
+ * Creates a layer from a `Config`-wrapped libSQL client configuration, providing both `LibsqlClient` and `SqlClient`.
347
+ *
297
348
  * @category layers
298
- * @since 1.0.0
349
+ * @since 4.0.0
299
350
  */
300
351
  export const layerConfig: (
301
352
  config: Config.Wrap<LibsqlClientConfig>
302
353
  ) => Layer.Layer<LibsqlClient | Client.SqlClient, Config.ConfigError> = (
303
354
  config: Config.Wrap<LibsqlClientConfig>
304
355
  ): Layer.Layer<LibsqlClient | Client.SqlClient, Config.ConfigError> =>
305
- Layer.effectServices(
306
- Config.unwrap(config).asEffect().pipe(
356
+ Layer.effectContext(
357
+ Config.unwrap(config).pipe(
307
358
  Effect.flatMap(make),
308
359
  Effect.map((client) =>
309
- ServiceMap.make(LibsqlClient, client).pipe(
310
- ServiceMap.add(Client.SqlClient, client)
360
+ Context.make(LibsqlClient, client).pipe(
361
+ Context.add(Client.SqlClient, client)
311
362
  )
312
363
  )
313
364
  )
314
365
  ).pipe(Layer.provide(Reactivity.layer))
315
366
 
316
367
  /**
368
+ * Creates a layer from a concrete libSQL client configuration, providing both `LibsqlClient` and `SqlClient`.
369
+ *
317
370
  * @category layers
318
- * @since 1.0.0
371
+ * @since 4.0.0
319
372
  */
320
373
  export const layer = (
321
374
  config: LibsqlClientConfig
322
375
  ): Layer.Layer<LibsqlClient | Client.SqlClient> =>
323
- Layer.effectServices(
376
+ Layer.effectContext(
324
377
  Effect.map(make(config), (client) =>
325
- ServiceMap.make(LibsqlClient, client).pipe(
326
- ServiceMap.add(Client.SqlClient, client)
378
+ Context.make(LibsqlClient, client).pipe(
379
+ Context.add(Client.SqlClient, client)
327
380
  ))
328
381
  ).pipe(Layer.provide(Reactivity.layer))
@@ -1,5 +1,14 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * libSQL migration support for Effect SQL applications.
3
+ *
4
+ * This module adapts the shared SQL migrator to libSQL. It re-exports the
5
+ * common migration loaders and errors, then provides {@link run} and
6
+ * {@link layer} helpers that apply pending migrations with the current
7
+ * libSQL-backed `SqlClient`. `run` returns the applied migration IDs and names,
8
+ * while `layer` runs migrations during layer construction and provides no
9
+ * services.
10
+ *
11
+ * @since 4.0.0
3
12
  */
4
13
  import type * as Effect from "effect/Effect"
5
14
  import * as Layer from "effect/Layer"
@@ -8,13 +17,15 @@ import type * as Client from "effect/unstable/sql/SqlClient"
8
17
  import type { SqlError } from "effect/unstable/sql/SqlError"
9
18
 
10
19
  /**
11
- * @since 1.0.0
20
+ * @since 4.0.0
12
21
  */
13
22
  export * from "effect/unstable/sql/Migrator"
14
23
 
15
24
  /**
16
- * @category constructor
17
- * @since 1.0.0
25
+ * Runs SQL migrations using the configured `SqlClient`, returning the migrations that were applied.
26
+ *
27
+ * @category constructors
28
+ * @since 4.0.0
18
29
  */
19
30
  export const run: <R2 = never>(
20
31
  options: Migrator.MigratorOptions<R2>
@@ -25,8 +36,10 @@ export const run: <R2 = never>(
25
36
  > = Migrator.make({})
26
37
 
27
38
  /**
28
- * @category constructor
29
- * @since 1.0.0
39
+ * Creates a layer that runs the configured SQL migrations during layer construction.
40
+ *
41
+ * @category constructors
42
+ * @since 4.0.0
30
43
  */
31
44
  export const layer = <R>(
32
45
  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 LibsqlClient from "./LibsqlClient.ts"
11
11
 
12
12
  /**
13
- * @since 1.0.0
13
+ * @since 4.0.0
14
14
  */
15
15
  export * as LibsqlMigrator from "./LibsqlMigrator.ts"