@effect/sql-sqlite-react-native 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/SqliteClient.d.ts.map +1 -1
- package/dist/SqliteClient.js +31 -12
- package/dist/SqliteClient.js.map +1 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -33
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/SqliteClient.ts +31 -12
- package/src/index.ts +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAsCA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC,OAAO,KAAK,UAAU,MAAM,uCAAuC,CAAA;AACnE,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAA;AAUvD;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,MAAwD,CAAA;AAE7E;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,+CAA+C,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,SAAS;IACpD,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAA;IAEnC,8BAA8B;IAC9B,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAA;CAC7B;AAED;;;;;GAKG;AACH,eAAO,MA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M,CAAC,SAAS,CAML,CAAA"}
|
package/dist/SqliteClient.js
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* React Native SQLite client implementation for Effect SQL, backed by
|
|
3
|
+
* `@op-engineering/op-sqlite`.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* React Native-specific `SqliteClient` and the generic Effect
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This module opens an on-device SQLite database and exposes it as both the
|
|
6
|
+
* React Native-specific `SqliteClient` service and the generic Effect
|
|
7
|
+
* `SqlClient` service. Use it for mobile application storage, offline caches,
|
|
8
|
+
* local migrations, sync queues, and tests that need the same SQLite driver as
|
|
9
|
+
* the app runtime.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* A client owns one scoped op-sqlite database handle configured with the
|
|
14
|
+
* provided `filename`, optional `location`, and optional `encryptionKey`.
|
|
15
|
+
* Queries are compiled through the Effect SQL SQLite compiler and serialized
|
|
16
|
+
* through that single handle. A transaction keeps the serialized connection
|
|
17
|
+
* permit for the whole transaction scope, so other fibers using the same client
|
|
18
|
+
* wait until the transaction finishes.
|
|
19
|
+
*
|
|
20
|
+
* **Common tasks**
|
|
21
|
+
*
|
|
22
|
+
* Use `layer` when a React Native app should provide both `SqliteClient` and
|
|
23
|
+
* the generic `SqlClient` from a concrete configuration, `layerConfig` when the
|
|
24
|
+
* configuration should come from Effect `Config`, and `make` inside a custom
|
|
25
|
+
* scoped layer when you need direct lifecycle control. Use `withAsyncQuery`
|
|
26
|
+
* around UI-sensitive effects or longer migration steps to run statements with
|
|
27
|
+
* the driver's asynchronous API instead of the default synchronous API.
|
|
28
|
+
*
|
|
29
|
+
* **Gotchas**
|
|
30
|
+
*
|
|
31
|
+
* The default synchronous op-sqlite API can block the JavaScript thread, so keep
|
|
32
|
+
* transactions short and wrap multi-statement writes in a transaction to avoid
|
|
33
|
+
* partial updates. `executeStream` is not implemented for this driver, and
|
|
34
|
+
* SQLite does not support `updateValues`.
|
|
16
35
|
*
|
|
17
36
|
* @since 4.0.0
|
|
18
37
|
*/
|
package/dist/SqliteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.js","names":["Sqlite","Config","Context","Effect","Fiber","constFalse","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","AsyncQuery","Reference","defaultValue","withAsyncQuery","effect","provideService","make","options","gen","clientOptions","name","filename","location","encryptionKey","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","open","addFinalizer","sync","close","run","sql","params","values","withFiber","fiber","getRef","map","tryPromise","try","execute","catch","reason","result","rawRows","rows","executeSync","executeRaw","executeValues","executeUnprepared","executeStream","die","semaphore","connection","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","getCurrent","scope","getUnsafe","context","as","tap","take","release","Object","assign","spanAttributes","entries","config","layerConfig","effectContext","unwrap","pipe","flatMap","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteClient.js","names":["Sqlite","Config","Context","Effect","Fiber","constFalse","identity","Layer","Scope","Semaphore","Stream","Reactivity","Client","classifySqliteError","SqlError","Statement","ATTR_DB_SYSTEM_NAME","classifyError","cause","message","operation","TypeId","SqliteClient","Service","AsyncQuery","Reference","defaultValue","withAsyncQuery","effect","provideService","make","options","gen","clientOptions","name","filename","location","encryptionKey","compiler","makeCompilerSqlite","transformQueryNames","transformRows","transformResultNames","defaultTransforms","array","undefined","makeConnection","db","open","addFinalizer","sync","close","run","sql","params","values","withFiber","fiber","getRef","map","tryPromise","try","execute","catch","reason","result","rawRows","rows","executeSync","executeRaw","executeValues","executeUnprepared","executeStream","die","semaphore","connection","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","getCurrent","scope","getUnsafe","context","as","tap","take","release","Object","assign","spanAttributes","entries","config","layerConfig","effectContext","unwrap","pipe","flatMap","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,OAAO,KAAKA,MAAM,MAAM,2BAA2B;AACnD,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,UAAU,EAAEC,QAAQ,QAAQ,iBAAiB;AACtD,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,OAAO,KAAKC,SAAS,MAAM,kBAAkB;AAC7C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,UAAU,MAAM,uCAAuC;AACnE,OAAO,KAAKC,MAAM,MAAM,+BAA+B;AAEvD,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ,8BAA8B;AAC5E,OAAO,KAAKC,SAAS,MAAM,+BAA+B;AAE1D,MAAMC,mBAAmB,GAAG,gBAAgB;AAE5C,MAAMC,aAAa,GAAGA,CAACC,KAAc,EAAEC,OAAe,EAAEC,SAAiB,KACvEP,mBAAmB,CAACK,KAAK,EAAE;EAAEC,OAAO;EAAEC;AAAS,CAAE,CAAC;AAEpD;;;;;;AAMA,OAAO,MAAMC,MAAM,GAAW,+CAA+C;AAwB7E;;;;;;AAMA,OAAO,MAAMC,YAAY,gBAAGpB,OAAO,CAACqB,OAAO,CAAe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
/**
|
|
5
|
-
* Provides a React Native SQLite `SqlClient` backed by `@op-engineering/op-sqlite`.
|
|
6
|
-
*
|
|
7
|
-
* Use this module to open an on-device SQLite database, expose it as both the
|
|
8
|
-
* React Native-specific `SqliteClient` and the generic Effect `SqlClient`, and
|
|
9
|
-
* run application queries, migrations, and transactional reads or writes from
|
|
10
|
-
* Effect services and layers.
|
|
11
|
-
*
|
|
12
|
-
* The client uses one serialized connection. Regular queries and transactions
|
|
13
|
-
* share that handle, and a transaction holds it for the lifetime of its scope,
|
|
14
|
-
* so keep mobile transactions short and wrap multi-statement writes in a
|
|
15
|
-
* transaction to avoid partial updates. By default statements use the driver's
|
|
16
|
-
* synchronous API, which can block the JavaScript thread; `withAsyncQuery`
|
|
17
|
-
* switches a fiber to the asynchronous driver API when UI responsiveness is more
|
|
18
|
-
* important than sync execution.
|
|
19
|
-
*
|
|
20
5
|
* @since 4.0.0
|
|
21
6
|
*/
|
|
22
7
|
export * as SqliteClient from "./SqliteClient.ts";
|
|
23
8
|
/**
|
|
24
|
-
* Utilities for applying Effect SQL migrations to React Native SQLite databases.
|
|
25
|
-
*
|
|
26
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
27
|
-
* provides `run` and `layer` helpers that execute ordered migrations through the
|
|
28
|
-
* current React Native SQLite `SqlClient`. Use it when a mobile app needs to
|
|
29
|
-
* bring its on-device database schema up to date during startup, before opening
|
|
30
|
-
* repositories or sync services, or in integration tests that create app-local
|
|
31
|
-
* database files.
|
|
32
|
-
*
|
|
33
|
-
* React Native SQLite databases are scoped by the client configuration, so the
|
|
34
|
-
* migrator should be run with the same `filename`, `location`, and encryption
|
|
35
|
-
* key as the rest of the application. Migrations run through the package's
|
|
36
|
-
* single serialized connection; by default statements use the synchronous
|
|
37
|
-
* driver API and can block the JS thread, so long migration sets may want to run
|
|
38
|
-
* under `SqliteClient.withAsyncQuery`. Mobile upgrades can be interrupted by app
|
|
39
|
-
* suspension or process death, so keep migrations transaction-aware and avoid
|
|
40
|
-
* assuming a fresh database on every launch.
|
|
41
|
-
*
|
|
42
9
|
* @since 4.0.0
|
|
43
10
|
*/
|
|
44
11
|
export * as SqliteMigrator from "./SqliteMigrator.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,43 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
* Provides a React Native SQLite `SqlClient` backed by `@op-engineering/op-sqlite`.
|
|
7
|
-
*
|
|
8
|
-
* Use this module to open an on-device SQLite database, expose it as both the
|
|
9
|
-
* React Native-specific `SqliteClient` and the generic Effect `SqlClient`, and
|
|
10
|
-
* run application queries, migrations, and transactional reads or writes from
|
|
11
|
-
* Effect services and layers.
|
|
12
|
-
*
|
|
13
|
-
* The client uses one serialized connection. Regular queries and transactions
|
|
14
|
-
* share that handle, and a transaction holds it for the lifetime of its scope,
|
|
15
|
-
* so keep mobile transactions short and wrap multi-statement writes in a
|
|
16
|
-
* transaction to avoid partial updates. By default statements use the driver's
|
|
17
|
-
* synchronous API, which can block the JavaScript thread; `withAsyncQuery`
|
|
18
|
-
* switches a fiber to the asynchronous driver API when UI responsiveness is more
|
|
19
|
-
* important than sync execution.
|
|
20
|
-
*
|
|
21
6
|
* @since 4.0.0
|
|
22
7
|
*/
|
|
23
8
|
export * as SqliteClient from "./SqliteClient.js";
|
|
24
9
|
/**
|
|
25
|
-
* Utilities for applying Effect SQL migrations to React Native SQLite databases.
|
|
26
|
-
*
|
|
27
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
28
|
-
* provides `run` and `layer` helpers that execute ordered migrations through the
|
|
29
|
-
* current React Native SQLite `SqlClient`. Use it when a mobile app needs to
|
|
30
|
-
* bring its on-device database schema up to date during startup, before opening
|
|
31
|
-
* repositories or sync services, or in integration tests that create app-local
|
|
32
|
-
* database files.
|
|
33
|
-
*
|
|
34
|
-
* React Native SQLite databases are scoped by the client configuration, so the
|
|
35
|
-
* migrator should be run with the same `filename`, `location`, and encryption
|
|
36
|
-
* key as the rest of the application. Migrations run through the package's
|
|
37
|
-
* single serialized connection; by default statements use the synchronous
|
|
38
|
-
* driver API and can block the JS thread, so long migration sets may want to run
|
|
39
|
-
* under `SqliteClient.withAsyncQuery`. Mobile upgrades can be interrupted by app
|
|
40
|
-
* suspension or process death, so keep migrations transaction-aware and avoid
|
|
41
|
-
* assuming a fresh database on every launch.
|
|
42
|
-
*
|
|
43
10
|
* @since 4.0.0
|
|
44
11
|
*/
|
|
45
12
|
export * as SqliteMigrator from "./SqliteMigrator.js";
|
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
|
|
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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-sqlite-react-native",
|
|
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 SQLite toolkit for Effect",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@op-engineering/op-sqlite": "15.2.12",
|
|
47
|
-
"effect": "^4.0.0-beta.
|
|
47
|
+
"effect": "^4.0.0-beta.71"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@op-engineering/op-sqlite": "15.0.4",
|
|
51
|
-
"effect": "^4.0.0-beta.
|
|
51
|
+
"effect": "^4.0.0-beta.71"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"codegen": "effect-utils codegen",
|
package/src/SqliteClient.ts
CHANGED
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* React Native SQLite client implementation for Effect SQL, backed by
|
|
3
|
+
* `@op-engineering/op-sqlite`.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* React Native-specific `SqliteClient` and the generic Effect
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This module opens an on-device SQLite database and exposes it as both the
|
|
6
|
+
* React Native-specific `SqliteClient` service and the generic Effect
|
|
7
|
+
* `SqlClient` service. Use it for mobile application storage, offline caches,
|
|
8
|
+
* local migrations, sync queues, and tests that need the same SQLite driver as
|
|
9
|
+
* the app runtime.
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* A client owns one scoped op-sqlite database handle configured with the
|
|
14
|
+
* provided `filename`, optional `location`, and optional `encryptionKey`.
|
|
15
|
+
* Queries are compiled through the Effect SQL SQLite compiler and serialized
|
|
16
|
+
* through that single handle. A transaction keeps the serialized connection
|
|
17
|
+
* permit for the whole transaction scope, so other fibers using the same client
|
|
18
|
+
* wait until the transaction finishes.
|
|
19
|
+
*
|
|
20
|
+
* **Common tasks**
|
|
21
|
+
*
|
|
22
|
+
* Use `layer` when a React Native app should provide both `SqliteClient` and
|
|
23
|
+
* the generic `SqlClient` from a concrete configuration, `layerConfig` when the
|
|
24
|
+
* configuration should come from Effect `Config`, and `make` inside a custom
|
|
25
|
+
* scoped layer when you need direct lifecycle control. Use `withAsyncQuery`
|
|
26
|
+
* around UI-sensitive effects or longer migration steps to run statements with
|
|
27
|
+
* the driver's asynchronous API instead of the default synchronous API.
|
|
28
|
+
*
|
|
29
|
+
* **Gotchas**
|
|
30
|
+
*
|
|
31
|
+
* The default synchronous op-sqlite API can block the JavaScript thread, so keep
|
|
32
|
+
* transactions short and wrap multi-statement writes in a transaction to avoid
|
|
33
|
+
* partial updates. `executeStream` is not implemented for this driver, and
|
|
34
|
+
* SQLite does not support `updateValues`.
|
|
16
35
|
*
|
|
17
36
|
* @since 4.0.0
|
|
18
37
|
*/
|
package/src/index.ts
CHANGED
|
@@ -5,44 +5,11 @@
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Provides a React Native SQLite `SqlClient` backed by `@op-engineering/op-sqlite`.
|
|
9
|
-
*
|
|
10
|
-
* Use this module to open an on-device SQLite database, expose it as both the
|
|
11
|
-
* React Native-specific `SqliteClient` and the generic Effect `SqlClient`, and
|
|
12
|
-
* run application queries, migrations, and transactional reads or writes from
|
|
13
|
-
* Effect services and layers.
|
|
14
|
-
*
|
|
15
|
-
* The client uses one serialized connection. Regular queries and transactions
|
|
16
|
-
* share that handle, and a transaction holds it for the lifetime of its scope,
|
|
17
|
-
* so keep mobile transactions short and wrap multi-statement writes in a
|
|
18
|
-
* transaction to avoid partial updates. By default statements use the driver's
|
|
19
|
-
* synchronous API, which can block the JavaScript thread; `withAsyncQuery`
|
|
20
|
-
* switches a fiber to the asynchronous driver API when UI responsiveness is more
|
|
21
|
-
* important than sync execution.
|
|
22
|
-
*
|
|
23
8
|
* @since 4.0.0
|
|
24
9
|
*/
|
|
25
10
|
export * as SqliteClient from "./SqliteClient.ts"
|
|
26
11
|
|
|
27
12
|
/**
|
|
28
|
-
* Utilities for applying Effect SQL migrations to React Native SQLite databases.
|
|
29
|
-
*
|
|
30
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
31
|
-
* provides `run` and `layer` helpers that execute ordered migrations through the
|
|
32
|
-
* current React Native SQLite `SqlClient`. Use it when a mobile app needs to
|
|
33
|
-
* bring its on-device database schema up to date during startup, before opening
|
|
34
|
-
* repositories or sync services, or in integration tests that create app-local
|
|
35
|
-
* database files.
|
|
36
|
-
*
|
|
37
|
-
* React Native SQLite databases are scoped by the client configuration, so the
|
|
38
|
-
* migrator should be run with the same `filename`, `location`, and encryption
|
|
39
|
-
* key as the rest of the application. Migrations run through the package's
|
|
40
|
-
* single serialized connection; by default statements use the synchronous
|
|
41
|
-
* driver API and can block the JS thread, so long migration sets may want to run
|
|
42
|
-
* under `SqliteClient.withAsyncQuery`. Mobile upgrades can be interrupted by app
|
|
43
|
-
* suspension or process death, so keep migrations transaction-aware and avoid
|
|
44
|
-
* assuming a fresh database on every launch.
|
|
45
|
-
*
|
|
46
13
|
* @since 4.0.0
|
|
47
14
|
*/
|
|
48
15
|
export * as SqliteMigrator from "./SqliteMigrator.ts"
|