@effect/sql-sqlite-do 4.0.0-beta.70 → 4.0.0-beta.72
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 +35 -16
- package/dist/SqliteClient.d.ts.map +1 -1
- package/dist/SqliteClient.js +6 -1
- package/dist/SqliteClient.js.map +1 -1
- package/dist/index.d.ts +0 -39
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -39
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/SqliteClient.ts +35 -16
- package/src/index.ts +0 -39
package/dist/SqliteClient.d.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Effect SQL client for Cloudflare Durable Object SQLite storage.
|
|
3
3
|
*
|
|
4
4
|
* This module adapts a Durable Object `SqlStorage` handle into both the
|
|
5
|
-
* Durable Object-specific
|
|
6
|
-
* `SqlClient` service. Use it
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
5
|
+
* Durable Object-specific {@link SqliteClient} service and the generic Effect
|
|
6
|
+
* SQL `SqlClient` service. Use it inside a Durable Object for per-object
|
|
7
|
+
* queries, repositories, migrations, transactional read/write workflows, and
|
|
8
|
+
* tests that exercise Cloudflare's SQLite-backed storage API.
|
|
9
|
+
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* Durable Object storage is scoped to one object id. Each object instance has
|
|
13
|
+
* its own database, and {@link make} wraps the same `SqlStorage` handle that
|
|
14
|
+
* the object uses for normal reads and writes. Effect SQL access is serialized
|
|
15
|
+
* through one connection; a transaction keeps that permit for the lifetime of
|
|
16
|
+
* its scope.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* Use {@link layer} when the Durable Object constructor already has a concrete
|
|
21
|
+
* `SqlStorage` handle. Use {@link layerConfig} when the handle and transform
|
|
22
|
+
* options should be supplied through Effect `Config`. Keep using generic
|
|
23
|
+
* `SqlClient` APIs for ordinary SQL, and depend on {@link SqliteClient} when
|
|
24
|
+
* code needs the Durable Object-specific service identity.
|
|
25
|
+
*
|
|
26
|
+
* **Gotchas**
|
|
27
|
+
*
|
|
28
|
+
* Keep transactions short and avoid suspending them across unrelated work,
|
|
29
|
+
* because all access through one client waits on the same serialized
|
|
30
|
+
* connection. `SqlStorage.exec` returns SQLite blob values as `ArrayBuffer`,
|
|
31
|
+
* which this client normalizes to `Uint8Array`. SQLite does not support
|
|
32
|
+
* `updateValues`.
|
|
19
33
|
*
|
|
20
34
|
* @since 4.0.0
|
|
21
35
|
*/
|
|
@@ -54,7 +68,12 @@ export interface SqliteClient extends Client.SqlClient {
|
|
|
54
68
|
readonly updateValues: never;
|
|
55
69
|
}
|
|
56
70
|
/**
|
|
57
|
-
*
|
|
71
|
+
* Service tag for the Cloudflare Durable Object SQLite client service.
|
|
72
|
+
*
|
|
73
|
+
* **When to use**
|
|
74
|
+
*
|
|
75
|
+
* Use to access or provide a Durable Object SQLite client through the Effect
|
|
76
|
+
* context.
|
|
58
77
|
*
|
|
59
78
|
* @category tags
|
|
60
79
|
* @since 4.0.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SqliteClient.d.ts","sourceRoot":"","sources":["../src/SqliteClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC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,CAAA;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,KACtC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAUzB,CAAA;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,QAAQ,kBAAkB,KACzB,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAML,CAAA"}
|
package/dist/SqliteClient.js
CHANGED
|
@@ -24,7 +24,12 @@ const classifyError = (cause, message, operation) => classifySqliteError(cause,
|
|
|
24
24
|
*/
|
|
25
25
|
export const TypeId = "~@effect/sql-sqlite-do/SqliteClient";
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Service tag for the Cloudflare Durable Object SQLite client service.
|
|
28
|
+
*
|
|
29
|
+
* **When to use**
|
|
30
|
+
*
|
|
31
|
+
* Use to access or provide a Durable Object SQLite client through the Effect
|
|
32
|
+
* context.
|
|
28
33
|
*
|
|
29
34
|
* @category tags
|
|
30
35
|
* @since 4.0.0
|
package/dist/SqliteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteClient.js","names":["Config","Context","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","db","runIterator","sql","params","cursor","exec","columns","columnNames","result","raw","obj","i","length","value","ArrayBuffer","Uint8Array","runStatement","try","Array","from","catch","reason","runValues","row","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","suspend","iterator","fromIteratorSucceed","pipe","mapArray","chunk","semaphore","connection","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","fiber","getCurrent","scope","getUnsafe","context","as","tap","take","addFinalizer","release","Object","assign","spanAttributes","entries","config","layerConfig","effectContext","unwrap","flatMap","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqliteClient.js","names":["Config","Context","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","db","runIterator","sql","params","cursor","exec","columns","columnNames","result","raw","obj","i","length","value","ArrayBuffer","Uint8Array","runStatement","try","Array","from","catch","reason","runValues","row","execute","map","executeRaw","executeValues","executeUnprepared","executeStream","suspend","iterator","fromIteratorSucceed","pipe","mapArray","chunk","semaphore","connection","acquirer","withPermits","succeed","transactionAcquirer","uninterruptibleMask","restore","fiber","getCurrent","scope","getUnsafe","context","as","tap","take","addFinalizer","release","Object","assign","spanAttributes","entries","config","layerConfig","effectContext","unwrap","flatMap","client","add","SqlClient","provide","layer"],"sources":["../src/SqliteClient.ts"],"sourcesContent":[null],"mappings":"AAoCA,OAAO,KAAKA,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AACrC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,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,E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qB,IAAI,CAACF,YAAY,EAAE6E,MAAM,CAAC,CAAC9B,IAAI,CACrClE,OAAO,CAACiG,GAAG,CAACxF,MAAM,CAACyF,SAAS,EAAEF,MAAM,CAAC,CACtC,CACF,CACF,CACF,CAAC9B,IAAI,CAAC9D,KAAK,CAAC+F,OAAO,CAAC3F,UAAU,CAAC4F,KAAK,CAAC,CAAC;AAEzC;;;;;;AAMA,OAAO,MAAMA,KAAK,GAChBT,MAA0B,IAE1BvF,KAAK,CAACyF,aAAa,CACjB5F,MAAM,CAACyD,GAAG,CAACrC,IAAI,CAACsE,MAAM,CAAC,EAAGK,MAAM,IAC9BhG,OAAO,CAACqB,IAAI,CAACF,YAAY,EAAE6E,MAAM,CAAC,CAAC9B,IAAI,CACrClE,OAAO,CAACiG,GAAG,CAACxF,MAAM,CAACyF,SAAS,EAAEF,MAAM,CAAC,CACtC,CAAC,CACL,CAAC9B,IAAI,CAAC9D,KAAK,CAAC+F,OAAO,CAAC3F,UAAU,CAAC4F,KAAK,CAAC,CAAC","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,49 +2,10 @@
|
|
|
2
2
|
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* Provides an Effect SQL client for Cloudflare Durable Object SQLite storage.
|
|
6
|
-
*
|
|
7
|
-
* This module adapts a Durable Object `SqlStorage` handle into both the
|
|
8
|
-
* Durable Object-specific `SqliteClient` service and the generic Effect
|
|
9
|
-
* `SqlClient` service. Use it from inside a Durable Object to run local
|
|
10
|
-
* per-object queries, repositories, migrations, transactional read/write
|
|
11
|
-
* workflows, and tests that exercise Cloudflare's SQLite-backed storage API.
|
|
12
|
-
*
|
|
13
|
-
* Durable Object SQLite storage is scoped to one object id, so each object
|
|
14
|
-
* instance has its own database and callers should pass the same `SqlStorage`
|
|
15
|
-
* handle that the object uses for normal reads and writes. This adapter
|
|
16
|
-
* serializes Effect SQL access through one connection; a transaction holds that
|
|
17
|
-
* permit for the lifetime of its scope, so keep transactions short, avoid
|
|
18
|
-
* suspending them across unrelated work, and use them when multi-statement
|
|
19
|
-
* writes must commit atomically. `SqlStorage.exec` returns `ArrayBuffer` values
|
|
20
|
-
* for SQLite blobs, which this client normalizes to `Uint8Array`, and SQLite
|
|
21
|
-
* does not support `updateValues`.
|
|
22
|
-
*
|
|
23
5
|
* @since 4.0.0
|
|
24
6
|
*/
|
|
25
7
|
export * as SqliteClient from "./SqliteClient.ts";
|
|
26
8
|
/**
|
|
27
|
-
* Utilities for applying Effect SQL migrations to Cloudflare Durable Object SQLite storage.
|
|
28
|
-
*
|
|
29
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
30
|
-
* provides `run` and `layer` helpers that execute ordered migrations through the
|
|
31
|
-
* current Durable Object `SqlStorage`-backed `SqlClient`. Use it when a Durable
|
|
32
|
-
* Object needs to create or upgrade its local schema during construction, before
|
|
33
|
-
* repositories or request handlers use the object storage, or in tests that
|
|
34
|
-
* exercise Durable Object persistence.
|
|
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. The underlying
|
|
38
|
-
* storage is scoped to a Durable Object id, so running migrations for one object
|
|
39
|
-
* does not update any other object instance; run the migrator against the same
|
|
40
|
-
* `SqlStorage` handle that the object uses for normal queries. These SQL
|
|
41
|
-
* migrations are separate from Cloudflare's Durable Object class migrations, and
|
|
42
|
-
* the Durable Object must already be configured with SQLite storage before this
|
|
43
|
-
* module can apply schema changes. Repeated startup runs are expected and are
|
|
44
|
-
* guarded by the migrations table, but request handling should wait until the
|
|
45
|
-
* migration layer has finished. This adapter does not currently write SQLite
|
|
46
|
-
* schema dumps for `schemaDirectory`.
|
|
47
|
-
*
|
|
48
9
|
* @since 4.0.0
|
|
49
10
|
*/
|
|
50
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,49 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
5
5
|
/**
|
|
6
|
-
* Provides an Effect SQL client for Cloudflare Durable Object SQLite storage.
|
|
7
|
-
*
|
|
8
|
-
* This module adapts a Durable Object `SqlStorage` handle into both the
|
|
9
|
-
* Durable Object-specific `SqliteClient` service and the generic Effect
|
|
10
|
-
* `SqlClient` service. Use it from inside a Durable Object to run local
|
|
11
|
-
* per-object queries, repositories, migrations, transactional read/write
|
|
12
|
-
* workflows, and tests that exercise Cloudflare's SQLite-backed storage API.
|
|
13
|
-
*
|
|
14
|
-
* Durable Object SQLite storage is scoped to one object id, so each object
|
|
15
|
-
* instance has its own database and callers should pass the same `SqlStorage`
|
|
16
|
-
* handle that the object uses for normal reads and writes. This adapter
|
|
17
|
-
* serializes Effect SQL access through one connection; a transaction holds that
|
|
18
|
-
* permit for the lifetime of its scope, so keep transactions short, avoid
|
|
19
|
-
* suspending them across unrelated work, and use them when multi-statement
|
|
20
|
-
* writes must commit atomically. `SqlStorage.exec` returns `ArrayBuffer` values
|
|
21
|
-
* for SQLite blobs, which this client normalizes to `Uint8Array`, and SQLite
|
|
22
|
-
* does not support `updateValues`.
|
|
23
|
-
*
|
|
24
6
|
* @since 4.0.0
|
|
25
7
|
*/
|
|
26
8
|
export * as SqliteClient from "./SqliteClient.js";
|
|
27
9
|
/**
|
|
28
|
-
* Utilities for applying Effect SQL migrations to Cloudflare Durable Object SQLite storage.
|
|
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 Durable Object `SqlStorage`-backed `SqlClient`. Use it when a Durable
|
|
33
|
-
* Object needs to create or upgrade its local schema during construction, before
|
|
34
|
-
* repositories or request handlers use the object storage, or in tests that
|
|
35
|
-
* exercise Durable Object persistence.
|
|
36
|
-
*
|
|
37
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
38
|
-
* using the shared `<id>_<name>` file or record-key convention. The underlying
|
|
39
|
-
* storage is scoped to a Durable Object id, so running migrations for one object
|
|
40
|
-
* does not update any other object instance; run the migrator against the same
|
|
41
|
-
* `SqlStorage` handle that the object uses for normal queries. These SQL
|
|
42
|
-
* migrations are separate from Cloudflare's Durable Object class migrations, and
|
|
43
|
-
* the Durable Object must already be configured with SQLite storage before this
|
|
44
|
-
* module can apply schema changes. Repeated startup runs are expected and are
|
|
45
|
-
* guarded by the migrations table, but request handling should wait until the
|
|
46
|
-
* migration layer has finished. This adapter does not currently write SQLite
|
|
47
|
-
* schema dumps for `schemaDirectory`.
|
|
48
|
-
*
|
|
49
10
|
* @since 4.0.0
|
|
50
11
|
*/
|
|
51
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-do",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A SQLite toolkit for Effect",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@cloudflare/workers-types": "^4.20260511.1",
|
|
47
|
-
"effect": "^4.0.0-beta.
|
|
47
|
+
"effect": "^4.0.0-beta.72"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"effect": "^4.0.0-beta.
|
|
50
|
+
"effect": "^4.0.0-beta.72"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"codegen": "effect-utils codegen",
|
package/src/SqliteClient.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Effect SQL client for Cloudflare Durable Object SQLite storage.
|
|
3
3
|
*
|
|
4
4
|
* This module adapts a Durable Object `SqlStorage` handle into both the
|
|
5
|
-
* Durable Object-specific
|
|
6
|
-
* `SqlClient` service. Use it
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
5
|
+
* Durable Object-specific {@link SqliteClient} service and the generic Effect
|
|
6
|
+
* SQL `SqlClient` service. Use it inside a Durable Object for per-object
|
|
7
|
+
* queries, repositories, migrations, transactional read/write workflows, and
|
|
8
|
+
* tests that exercise Cloudflare's SQLite-backed storage API.
|
|
9
|
+
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* Durable Object storage is scoped to one object id. Each object instance has
|
|
13
|
+
* its own database, and {@link make} wraps the same `SqlStorage` handle that
|
|
14
|
+
* the object uses for normal reads and writes. Effect SQL access is serialized
|
|
15
|
+
* through one connection; a transaction keeps that permit for the lifetime of
|
|
16
|
+
* its scope.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* Use {@link layer} when the Durable Object constructor already has a concrete
|
|
21
|
+
* `SqlStorage` handle. Use {@link layerConfig} when the handle and transform
|
|
22
|
+
* options should be supplied through Effect `Config`. Keep using generic
|
|
23
|
+
* `SqlClient` APIs for ordinary SQL, and depend on {@link SqliteClient} when
|
|
24
|
+
* code needs the Durable Object-specific service identity.
|
|
25
|
+
*
|
|
26
|
+
* **Gotchas**
|
|
27
|
+
*
|
|
28
|
+
* Keep transactions short and avoid suspending them across unrelated work,
|
|
29
|
+
* because all access through one client waits on the same serialized
|
|
30
|
+
* connection. `SqlStorage.exec` returns SQLite blob values as `ArrayBuffer`,
|
|
31
|
+
* which this client normalizes to `Uint8Array`. SQLite does not support
|
|
32
|
+
* `updateValues`.
|
|
19
33
|
*
|
|
20
34
|
* @since 4.0.0
|
|
21
35
|
*/
|
|
@@ -71,7 +85,12 @@ export interface SqliteClient extends Client.SqlClient {
|
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
/**
|
|
74
|
-
*
|
|
88
|
+
* Service tag for the Cloudflare Durable Object SQLite client service.
|
|
89
|
+
*
|
|
90
|
+
* **When to use**
|
|
91
|
+
*
|
|
92
|
+
* Use to access or provide a Durable Object SQLite client through the Effect
|
|
93
|
+
* context.
|
|
75
94
|
*
|
|
76
95
|
* @category tags
|
|
77
96
|
* @since 4.0.0
|
package/src/index.ts
CHANGED
|
@@ -5,50 +5,11 @@
|
|
|
5
5
|
// @barrel: Auto-generated exports. Do not edit manually.
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Provides an Effect SQL client for Cloudflare Durable Object SQLite storage.
|
|
9
|
-
*
|
|
10
|
-
* This module adapts a Durable Object `SqlStorage` handle into both the
|
|
11
|
-
* Durable Object-specific `SqliteClient` service and the generic Effect
|
|
12
|
-
* `SqlClient` service. Use it from inside a Durable Object to run local
|
|
13
|
-
* per-object queries, repositories, migrations, transactional read/write
|
|
14
|
-
* workflows, and tests that exercise Cloudflare's SQLite-backed storage API.
|
|
15
|
-
*
|
|
16
|
-
* Durable Object SQLite storage is scoped to one object id, so each object
|
|
17
|
-
* instance has its own database and callers should pass the same `SqlStorage`
|
|
18
|
-
* handle that the object uses for normal reads and writes. This adapter
|
|
19
|
-
* serializes Effect SQL access through one connection; a transaction holds that
|
|
20
|
-
* permit for the lifetime of its scope, so keep transactions short, avoid
|
|
21
|
-
* suspending them across unrelated work, and use them when multi-statement
|
|
22
|
-
* writes must commit atomically. `SqlStorage.exec` returns `ArrayBuffer` values
|
|
23
|
-
* for SQLite blobs, which this client normalizes to `Uint8Array`, and SQLite
|
|
24
|
-
* does not support `updateValues`.
|
|
25
|
-
*
|
|
26
8
|
* @since 4.0.0
|
|
27
9
|
*/
|
|
28
10
|
export * as SqliteClient from "./SqliteClient.ts"
|
|
29
11
|
|
|
30
12
|
/**
|
|
31
|
-
* Utilities for applying Effect SQL migrations to Cloudflare Durable Object SQLite storage.
|
|
32
|
-
*
|
|
33
|
-
* This module re-exports the shared `Migrator` loaders and error types, then
|
|
34
|
-
* provides `run` and `layer` helpers that execute ordered migrations through the
|
|
35
|
-
* current Durable Object `SqlStorage`-backed `SqlClient`. Use it when a Durable
|
|
36
|
-
* Object needs to create or upgrade its local schema during construction, before
|
|
37
|
-
* repositories or request handlers use the object storage, or in tests that
|
|
38
|
-
* exercise Durable Object persistence.
|
|
39
|
-
*
|
|
40
|
-
* Migrations are recorded in `effect_sql_migrations` by default and are loaded
|
|
41
|
-
* using the shared `<id>_<name>` file or record-key convention. The underlying
|
|
42
|
-
* storage is scoped to a Durable Object id, so running migrations for one object
|
|
43
|
-
* does not update any other object instance; run the migrator against the same
|
|
44
|
-
* `SqlStorage` handle that the object uses for normal queries. These SQL
|
|
45
|
-
* migrations are separate from Cloudflare's Durable Object class migrations, and
|
|
46
|
-
* the Durable Object must already be configured with SQLite storage before this
|
|
47
|
-
* module can apply schema changes. Repeated startup runs are expected and are
|
|
48
|
-
* guarded by the migrations table, but request handling should wait until the
|
|
49
|
-
* migration layer has finished. This adapter does not currently write SQLite
|
|
50
|
-
* schema dumps for `schemaDirectory`.
|
|
51
|
-
*
|
|
52
13
|
* @since 4.0.0
|
|
53
14
|
*/
|
|
54
15
|
export * as SqliteMigrator from "./SqliteMigrator.ts"
|