@effect/sql-libsql 4.0.0-beta.70 → 4.0.0-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LibsqlClient.d.ts +33 -16
- package/dist/LibsqlClient.d.ts.map +1 -1
- package/dist/LibsqlClient.js +31 -14
- package/dist/LibsqlClient.js.map +1 -1
- package/dist/LibsqlMigrator.d.ts +30 -19
- package/dist/LibsqlMigrator.d.ts.map +1 -1
- package/dist/LibsqlMigrator.js.map +1 -1
- package/dist/index.d.ts +0 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -37
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/LibsqlClient.ts +31 -14
- package/src/LibsqlMigrator.ts +30 -19
- package/src/index.ts +0 -37
package/dist/LibsqlClient.d.ts
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* libSQL
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Effect client
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
2
|
+
* libSQL adapter for Effect SQL, backed by `@libsql/client`.
|
|
3
|
+
*
|
|
4
|
+
* Use this module to provide a {@link LibsqlClient} and the generic SQL client
|
|
5
|
+
* service for Turso-hosted libSQL databases, local `file:` databases, embedded
|
|
6
|
+
* replicas, migrations, tests, and server code that wants SQLite-compatible SQL
|
|
7
|
+
* through Effect layers. The client uses Effect SQL's SQLite compiler and
|
|
8
|
+
* classifies libSQL and SQLite failures as `SqlError`s.
|
|
9
|
+
*
|
|
10
|
+
* ## Mental model
|
|
11
|
+
*
|
|
12
|
+
* {@link make} and {@link layer} either create a scoped libSQL SDK client from
|
|
13
|
+
* connection options or wrap a caller-owned client supplied with `liveClient`.
|
|
14
|
+
* The Effect client serializes access to the underlying client because a libSQL
|
|
15
|
+
* transaction is tied to that client. A top-level `withTransaction` opens a
|
|
16
|
+
* write transaction, and nested transactions use SQLite savepoints.
|
|
17
|
+
*
|
|
18
|
+
* ## Common tasks
|
|
19
|
+
*
|
|
20
|
+
* - Use {@link layer} with concrete connection options, or {@link layerConfig}
|
|
21
|
+
* when the options should come from `Config`.
|
|
22
|
+
* - Use a `file:` URL for local SQLite-compatible storage, a remote libSQL or
|
|
23
|
+
* Turso URL for hosted databases, and `syncUrl` for embedded replicas.
|
|
24
|
+
* - Use `liveClient` when another component owns the `@libsql/client` instance
|
|
25
|
+
* and its lifetime.
|
|
26
|
+
* - Use `transformQueryNames` and `transformResultNames` to map between Effect
|
|
27
|
+
* field names and database column names.
|
|
28
|
+
*
|
|
29
|
+
* ## Gotchas
|
|
30
|
+
*
|
|
31
|
+
* Direct calls made through the raw SDK client are not coordinated with Effect
|
|
32
|
+
* SQL transactions. Remote transactions should stay short because they reserve
|
|
33
|
+
* the client until commit or rollback. Row streaming is not implemented by this
|
|
34
|
+
* adapter.
|
|
18
35
|
*
|
|
19
36
|
* @since 4.0.0
|
|
20
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibsqlClient.d.ts","sourceRoot":"","sources":["../src/LibsqlClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"LibsqlClient.d.ts","sourceRoot":"","sources":["../src/LibsqlClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,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
2
|
-
* libSQL
|
|
2
|
+
* libSQL adapter for Effect SQL, backed by `@libsql/client`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Use this module to provide a {@link LibsqlClient} and the generic SQL client
|
|
5
|
+
* service for Turso-hosted libSQL databases, local `file:` databases, embedded
|
|
6
|
+
* replicas, migrations, tests, and server code that wants SQLite-compatible SQL
|
|
7
|
+
* through Effect layers. The client uses Effect SQL's SQLite compiler and
|
|
8
|
+
* classifies libSQL and SQLite failures as `SqlError`s.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Effect client
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* ## Mental model
|
|
11
|
+
*
|
|
12
|
+
* {@link make} and {@link layer} either create a scoped libSQL SDK client from
|
|
13
|
+
* connection options or wrap a caller-owned client supplied with `liveClient`.
|
|
14
|
+
* The Effect client serializes access to the underlying client because a libSQL
|
|
15
|
+
* transaction is tied to that client. A top-level `withTransaction` opens a
|
|
16
|
+
* write transaction, and nested transactions use SQLite savepoints.
|
|
17
|
+
*
|
|
18
|
+
* ## Common tasks
|
|
19
|
+
*
|
|
20
|
+
* - Use {@link layer} with concrete connection options, or {@link layerConfig}
|
|
21
|
+
* when the options should come from `Config`.
|
|
22
|
+
* - Use a `file:` URL for local SQLite-compatible storage, a remote libSQL or
|
|
23
|
+
* Turso URL for hosted databases, and `syncUrl` for embedded replicas.
|
|
24
|
+
* - Use `liveClient` when another component owns the `@libsql/client` instance
|
|
25
|
+
* and its lifetime.
|
|
26
|
+
* - Use `transformQueryNames` and `transformResultNames` to map between Effect
|
|
27
|
+
* field names and database column names.
|
|
28
|
+
*
|
|
29
|
+
* ## Gotchas
|
|
30
|
+
*
|
|
31
|
+
* Direct calls made through the raw SDK client are not coordinated with Effect
|
|
32
|
+
* SQL transactions. Remote transactions should stay short because they reserve
|
|
33
|
+
* the client until commit or rollback. Row streaming is not implemented by this
|
|
34
|
+
* adapter.
|
|
18
35
|
*
|
|
19
36
|
* @since 4.0.0
|
|
20
37
|
*/
|
package/dist/LibsqlClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,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,uCAAuC;AACnE,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ,8BAA8B;AAC5E,OAAO,KAAKC,SAAS,MAAM,+BAA+B;AAE1D,MAAMC,mBAAmB,GAAG,gBAAgB;AAE5C,MAAMC,aAAa,GAAGA,CAACC,KAAc,EAAEC,OAAe,EAAEC,SAAiB,KACvEP,mBAAmB,CAACK,KAAK,EAAE;EAAEC,OAAO;EAAEC;AAAS,CAAE,CAAC;AAEpD;;;;;;AAM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,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":[]}
|
package/dist/LibsqlMigrator.d.ts
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Migrations are
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* migrations
|
|
20
|
-
*
|
|
2
|
+
* libSQL migration support for Effect SQL applications.
|
|
3
|
+
*
|
|
4
|
+
* This module adapts the shared SQL migrator to libSQL and Turso databases. It
|
|
5
|
+
* re-exports the common migration loaders and errors, then provides {@link run}
|
|
6
|
+
* and {@link layer} helpers that apply pending migrations with the current
|
|
7
|
+
* libSQL-backed `SqlClient`.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* Migrations are numbered operations loaded from files, records, or bundler
|
|
12
|
+
* glob results. The runner ensures the migrations table exists, reads the
|
|
13
|
+
* latest recorded id, and runs only migrations with a greater id through the
|
|
14
|
+
* configured libSQL client.
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* Use {@link run} during application startup, deployment, or setup scripts when
|
|
19
|
+
* migrations should be executed explicitly. Use {@link layer} in a layer graph
|
|
20
|
+
* when dependent services should be acquired only after the schema is prepared.
|
|
21
|
+
* Reuse the shared loaders from this module for file-based or in-memory
|
|
22
|
+
* migration definitions.
|
|
23
|
+
*
|
|
24
|
+
* **Gotchas**
|
|
25
|
+
*
|
|
26
|
+
* libSQL uses SQLite-compatible SQL, so avoid dialect features unsupported by
|
|
27
|
+
* libSQL or the configured Turso deployment. Remote Turso databases, local
|
|
28
|
+
* `file:` databases, and embedded replicas can observe different state until
|
|
29
|
+
* replication catches up. Run schema-changing migrations against the intended
|
|
30
|
+
* writer, coordinate concurrent migrators, and do not rely on
|
|
31
|
+
* `schemaDirectory` for libSQL schema dumps.
|
|
21
32
|
*
|
|
22
33
|
* @since 4.0.0
|
|
23
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibsqlMigrator.d.ts","sourceRoot":"","sources":["../src/LibsqlMigrator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"LibsqlMigrator.d.ts","sourceRoot":"","sources":["../src/LibsqlMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;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,CACF,CAAA;AAErB;;;;;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LibsqlMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/LibsqlMigrator.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"LibsqlMigrator.js","names":["Layer","Migrator","run","make","layer","options","effectDiscard"],"sources":["../src/LibsqlMigrator.ts"],"sourcesContent":[null],"mappings":"AAmCA,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
|
@@ -2,47 +2,10 @@
|
|
|
2
2
|
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* libSQL client implementation for Effect SQL, backed by `@libsql/client`.
|
|
6
|
-
*
|
|
7
|
-
* This module creates or wraps a libSQL SDK client and exposes it as both the
|
|
8
|
-
* libSQL-specific `LibsqlClient` service and the generic Effect `SqlClient`.
|
|
9
|
-
* Use it for Turso-hosted libSQL databases, local `file:` databases, embedded
|
|
10
|
-
* replicas configured with `syncUrl`, migrations, tests, and application code
|
|
11
|
-
* that wants SQLite-compatible SQL through Effect services and layers.
|
|
12
|
-
*
|
|
13
|
-
* When connection options are supplied the SDK client is scoped and closed by
|
|
14
|
-
* the layer; when `liveClient` is supplied ownership stays with the caller.
|
|
15
|
-
* Top-level `withTransaction` blocks open a libSQL write transaction, nested
|
|
16
|
-
* transactions use SQLite savepoints, and only statements run through the same
|
|
17
|
-
* Effect client participate in that transaction. Keep Turso or remote libSQL
|
|
18
|
-
* transactions short, because the transaction holds the client reservation
|
|
19
|
-
* until commit or rollback; direct SDK calls made outside this service are not
|
|
20
|
-
* coordinated with Effect SQL transactions. Row streaming is not implemented.
|
|
21
|
-
*
|
|
22
5
|
* @since 4.0.0
|
|
23
6
|
*/
|
|
24
7
|
export * as LibsqlClient from "./LibsqlClient.ts";
|
|
25
8
|
/**
|
|
26
|
-
* Utilities for applying Effect SQL migrations to libSQL and Turso databases.
|
|
27
|
-
*
|
|
28
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
29
|
-
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
30
|
-
* current libSQL-backed `SqlClient`. It is typically used at application
|
|
31
|
-
* startup, in deployment or setup scripts for Turso databases, in tests that
|
|
32
|
-
* create temporary `file:` databases, or in layer graphs that must ensure the
|
|
33
|
-
* schema exists before dependent services are acquired.
|
|
34
|
-
*
|
|
35
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
36
|
-
* using the shared `<id>_<name>` file or record-key convention. Because libSQL
|
|
37
|
-
* uses SQLite-compatible SQL, migrations should avoid dialect features that are
|
|
38
|
-
* not supported by libSQL or the configured Turso deployment. Remote Turso
|
|
39
|
-
* databases, local `file:` databases, and embedded replicas can each observe
|
|
40
|
-
* different state until replication has caught up, so run schema-changing
|
|
41
|
-
* migrations against the intended writer and wait for replicas to sync before
|
|
42
|
-
* serving code that depends on the new schema. Concurrent migrators rely on the
|
|
43
|
-
* migrations table primary key to detect races, and this adapter does not
|
|
44
|
-
* currently write schema dumps for `schemaDirectory`.
|
|
45
|
-
*
|
|
46
9
|
* @since 4.0.0
|
|
47
10
|
*/
|
|
48
11
|
export * as LibsqlMigrator from "./LibsqlMigrator.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -3,47 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
* libSQL client implementation for Effect SQL, backed by `@libsql/client`.
|
|
7
|
-
*
|
|
8
|
-
* This module creates or wraps a libSQL SDK client and exposes it as both the
|
|
9
|
-
* libSQL-specific `LibsqlClient` service and the generic Effect `SqlClient`.
|
|
10
|
-
* Use it for Turso-hosted libSQL databases, local `file:` databases, embedded
|
|
11
|
-
* replicas configured with `syncUrl`, migrations, tests, and application code
|
|
12
|
-
* that wants SQLite-compatible SQL through Effect services and layers.
|
|
13
|
-
*
|
|
14
|
-
* When connection options are supplied the SDK client is scoped and closed by
|
|
15
|
-
* the layer; when `liveClient` is supplied ownership stays with the caller.
|
|
16
|
-
* Top-level `withTransaction` blocks open a libSQL write transaction, nested
|
|
17
|
-
* transactions use SQLite savepoints, and only statements run through the same
|
|
18
|
-
* Effect client participate in that transaction. Keep Turso or remote libSQL
|
|
19
|
-
* transactions short, because the transaction holds the client reservation
|
|
20
|
-
* until commit or rollback; direct SDK calls made outside this service are not
|
|
21
|
-
* coordinated with Effect SQL transactions. Row streaming is not implemented.
|
|
22
|
-
*
|
|
23
6
|
* @since 4.0.0
|
|
24
7
|
*/
|
|
25
8
|
export * as LibsqlClient from "./LibsqlClient.js";
|
|
26
9
|
/**
|
|
27
|
-
* Utilities for applying Effect SQL migrations to libSQL and Turso 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 libSQL-backed `SqlClient`. It is typically used at application
|
|
32
|
-
* startup, in deployment or setup scripts for Turso databases, in tests that
|
|
33
|
-
* create temporary `file:` databases, or in layer graphs that must ensure the
|
|
34
|
-
* schema exists before dependent services are acquired.
|
|
35
|
-
*
|
|
36
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
37
|
-
* using the shared `<id>_<name>` file or record-key convention. Because libSQL
|
|
38
|
-
* uses SQLite-compatible SQL, migrations should avoid dialect features that are
|
|
39
|
-
* not supported by libSQL or the configured Turso deployment. Remote Turso
|
|
40
|
-
* databases, local `file:` databases, and embedded replicas can each observe
|
|
41
|
-
* different state until replication has caught up, so run schema-changing
|
|
42
|
-
* migrations against the intended writer and wait for replicas to sync before
|
|
43
|
-
* serving code that depends on the new schema. Concurrent migrators rely on the
|
|
44
|
-
* migrations table primary key to detect races, and this adapter does not
|
|
45
|
-
* currently write schema dumps for `schemaDirectory`.
|
|
46
|
-
*
|
|
47
10
|
* @since 4.0.0
|
|
48
11
|
*/
|
|
49
12
|
export * as LibsqlMigrator from "./LibsqlMigrator.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["LibsqlClient","LibsqlMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA
|
|
1
|
+
{"version":3,"file":"index.js","names":["LibsqlClient","LibsqlMigrator"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAIA;AAEA;;;AAGA,OAAO,KAAKA,YAAY,MAAM,mBAAmB;AAEjD;;;AAGA,OAAO,KAAKC,cAAc,MAAM,qBAAqB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-libsql",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.71",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A libSQL toolkit for Effect",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"testcontainers": "^11.14.0",
|
|
49
|
-
"effect": "^4.0.0-beta.
|
|
49
|
+
"effect": "^4.0.0-beta.71"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"effect": "^4.0.0-beta.
|
|
52
|
+
"effect": "^4.0.0-beta.71"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@libsql/client": "^0.17.3"
|
package/src/LibsqlClient.ts
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* libSQL
|
|
2
|
+
* libSQL adapter for Effect SQL, backed by `@libsql/client`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Use this module to provide a {@link LibsqlClient} and the generic SQL client
|
|
5
|
+
* service for Turso-hosted libSQL databases, local `file:` databases, embedded
|
|
6
|
+
* replicas, migrations, tests, and server code that wants SQLite-compatible SQL
|
|
7
|
+
* through Effect layers. The client uses Effect SQL's SQLite compiler and
|
|
8
|
+
* classifies libSQL and SQLite failures as `SqlError`s.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Effect client
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* ## Mental model
|
|
11
|
+
*
|
|
12
|
+
* {@link make} and {@link layer} either create a scoped libSQL SDK client from
|
|
13
|
+
* connection options or wrap a caller-owned client supplied with `liveClient`.
|
|
14
|
+
* The Effect client serializes access to the underlying client because a libSQL
|
|
15
|
+
* transaction is tied to that client. A top-level `withTransaction` opens a
|
|
16
|
+
* write transaction, and nested transactions use SQLite savepoints.
|
|
17
|
+
*
|
|
18
|
+
* ## Common tasks
|
|
19
|
+
*
|
|
20
|
+
* - Use {@link layer} with concrete connection options, or {@link layerConfig}
|
|
21
|
+
* when the options should come from `Config`.
|
|
22
|
+
* - Use a `file:` URL for local SQLite-compatible storage, a remote libSQL or
|
|
23
|
+
* Turso URL for hosted databases, and `syncUrl` for embedded replicas.
|
|
24
|
+
* - Use `liveClient` when another component owns the `@libsql/client` instance
|
|
25
|
+
* and its lifetime.
|
|
26
|
+
* - Use `transformQueryNames` and `transformResultNames` to map between Effect
|
|
27
|
+
* field names and database column names.
|
|
28
|
+
*
|
|
29
|
+
* ## Gotchas
|
|
30
|
+
*
|
|
31
|
+
* Direct calls made through the raw SDK client are not coordinated with Effect
|
|
32
|
+
* SQL transactions. Remote transactions should stay short because they reserve
|
|
33
|
+
* the client until commit or rollback. Row streaming is not implemented by this
|
|
34
|
+
* adapter.
|
|
18
35
|
*
|
|
19
36
|
* @since 4.0.0
|
|
20
37
|
*/
|
package/src/LibsqlMigrator.ts
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Migrations are
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* migrations
|
|
20
|
-
*
|
|
2
|
+
* libSQL migration support for Effect SQL applications.
|
|
3
|
+
*
|
|
4
|
+
* This module adapts the shared SQL migrator to libSQL and Turso databases. It
|
|
5
|
+
* re-exports the common migration loaders and errors, then provides {@link run}
|
|
6
|
+
* and {@link layer} helpers that apply pending migrations with the current
|
|
7
|
+
* libSQL-backed `SqlClient`.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* Migrations are numbered operations loaded from files, records, or bundler
|
|
12
|
+
* glob results. The runner ensures the migrations table exists, reads the
|
|
13
|
+
* latest recorded id, and runs only migrations with a greater id through the
|
|
14
|
+
* configured libSQL client.
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* Use {@link run} during application startup, deployment, or setup scripts when
|
|
19
|
+
* migrations should be executed explicitly. Use {@link layer} in a layer graph
|
|
20
|
+
* when dependent services should be acquired only after the schema is prepared.
|
|
21
|
+
* Reuse the shared loaders from this module for file-based or in-memory
|
|
22
|
+
* migration definitions.
|
|
23
|
+
*
|
|
24
|
+
* **Gotchas**
|
|
25
|
+
*
|
|
26
|
+
* libSQL uses SQLite-compatible SQL, so avoid dialect features unsupported by
|
|
27
|
+
* libSQL or the configured Turso deployment. Remote Turso databases, local
|
|
28
|
+
* `file:` databases, and embedded replicas can observe different state until
|
|
29
|
+
* replication catches up. Run schema-changing migrations against the intended
|
|
30
|
+
* writer, coordinate concurrent migrators, and do not rely on
|
|
31
|
+
* `schemaDirectory` for libSQL schema dumps.
|
|
21
32
|
*
|
|
22
33
|
* @since 4.0.0
|
|
23
34
|
*/
|
package/src/index.ts
CHANGED
|
@@ -5,48 +5,11 @@
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* libSQL client implementation for Effect SQL, backed by `@libsql/client`.
|
|
9
|
-
*
|
|
10
|
-
* This module creates or wraps a libSQL SDK client and exposes it as both the
|
|
11
|
-
* libSQL-specific `LibsqlClient` service and the generic Effect `SqlClient`.
|
|
12
|
-
* Use it for Turso-hosted libSQL databases, local `file:` databases, embedded
|
|
13
|
-
* replicas configured with `syncUrl`, migrations, tests, and application code
|
|
14
|
-
* that wants SQLite-compatible SQL through Effect services and layers.
|
|
15
|
-
*
|
|
16
|
-
* When connection options are supplied the SDK client is scoped and closed by
|
|
17
|
-
* the layer; when `liveClient` is supplied ownership stays with the caller.
|
|
18
|
-
* Top-level `withTransaction` blocks open a libSQL write transaction, nested
|
|
19
|
-
* transactions use SQLite savepoints, and only statements run through the same
|
|
20
|
-
* Effect client participate in that transaction. Keep Turso or remote libSQL
|
|
21
|
-
* transactions short, because the transaction holds the client reservation
|
|
22
|
-
* until commit or rollback; direct SDK calls made outside this service are not
|
|
23
|
-
* coordinated with Effect SQL transactions. Row streaming is not implemented.
|
|
24
|
-
*
|
|
25
8
|
* @since 4.0.0
|
|
26
9
|
*/
|
|
27
10
|
export * as LibsqlClient from "./LibsqlClient.ts"
|
|
28
11
|
|
|
29
12
|
/**
|
|
30
|
-
* Utilities for applying Effect SQL migrations to libSQL and Turso databases.
|
|
31
|
-
*
|
|
32
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
33
|
-
* provides `run` and `layer` helpers for applying ordered migrations through the
|
|
34
|
-
* current libSQL-backed `SqlClient`. It is typically used at application
|
|
35
|
-
* startup, in deployment or setup scripts for Turso databases, in tests that
|
|
36
|
-
* create temporary `file:` databases, or in layer graphs that must ensure the
|
|
37
|
-
* schema exists before dependent services are acquired.
|
|
38
|
-
*
|
|
39
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
40
|
-
* using the shared `<id>_<name>` file or record-key convention. Because libSQL
|
|
41
|
-
* uses SQLite-compatible SQL, migrations should avoid dialect features that are
|
|
42
|
-
* not supported by libSQL or the configured Turso deployment. Remote Turso
|
|
43
|
-
* databases, local `file:` databases, and embedded replicas can each observe
|
|
44
|
-
* different state until replication has caught up, so run schema-changing
|
|
45
|
-
* migrations against the intended writer and wait for replicas to sync before
|
|
46
|
-
* serving code that depends on the new schema. Concurrent migrators rely on the
|
|
47
|
-
* migrations table primary key to detect races, and this adapter does not
|
|
48
|
-
* currently write schema dumps for `schemaDirectory`.
|
|
49
|
-
*
|
|
50
13
|
* @since 4.0.0
|
|
51
14
|
*/
|
|
52
15
|
export * as LibsqlMigrator from "./LibsqlMigrator.ts"
|