Skip to content
Myr

Let the D1 projection tell D1's client from the SqlClient itself, and rerun the project's tests when a migration changes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- `ProjectionD1` read an optional `D1Client` service to pick the D1 batch, so its layer type (`SqlClient` only) hid a second need: a D1 `SqlClient` composed without `D1Client` in context would have used `withTransaction`, which dies on D1. It now asks the `SqlClient` for the driver's `TypeId`, which `D1Client.make` puts on the very client `D1Client.layer` provides as `SqlClient`, and writes through that client's `batch`. The layer needs nothing but the `SqlClient`, as issue 309's interface says. - `tsconfig.base.json`: the projection-d1 override also allows `@effect/sql-d1/D1Client#TypeId` (per-path allow-lists are pre-approved, spec §7.3); it still lists `effect/sql` and `#D1Client`. - `turbo.json`: a `@repo/project#test` task (a copy of `test`, since a `package#task` entry replaces it whole) adds `$TURBO_ROOT$/apps/platform/migrations/**` to its inputs. The projection's test checks the migration file against `tables.ts`; before this a migration edit left the test's hash unchanged and `verify` could pass on a cached result. Checked: appending a line to `0001_front_page.sql` changes the task's hash. A tightening. - Small: cursors decode their project as `ProjectName`, and the claim-count helper takes an `AskId`. - Tests: none added. The D1 batch path still does not run in Node (no D1 without a new dependency or a fake that leans on the client's object shape); 310/311 check it live. The 11 tests on sqlite-node pass unchanged.

authored by oscabriel · committed by oscabriel · parent 646e2c5 · Browse files · 3 files+27 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+27 added−13 removed

  • other:+27 added−13 removed

3 files+27 added−13 removed

modified:packages/project/src/projection-d1/projection.ts+19 added-12 removed
modified:tsconfig.base.json+2 added-1 removed
155 unmodified lines
156 "include": ["packages/project/src/projection-d1/**/*.ts"],157 "options": {158 "allowedUnstableApis": [159 "effect/sql",160 "@effect/sql-d1/D1Client#D1Client"160 "@effect/sql-d1/D1Client#D1Client",161 "@effect/sql-d1/D1Client#TypeId"162 ]163 }164 },165 {
42 unmodified lines
modified:turbo.json+6 added
11 unmodified lines
12 "dependsOn": ["types", "^types"],13 "env": ["UPDATE_GOLDEN"],14 "outputs": []15 },16 "@repo/project#test": {17 "dependsOn": ["types", "^types"],18 "env": ["UPDATE_GOLDEN"],19 "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/apps/platform/migrations/**"],20 "outputs": []21 },22 "@repo/config#test": {23 "cache": false,24 "dependsOn": ["types", "^types"],25 "outputs": []
3 unmodified lines