@shivaedev/sql 0.46.3 → 0.47.0

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +61 -27
  3. package/dist/backfillPostgres.d.ts +1 -1
  4. package/dist/backfillPostgres.d.ts.map +1 -1
  5. package/dist/backfillPostgres.js +1 -1
  6. package/dist/backfillPostgres.js.map +1 -1
  7. package/dist/batchedDelete.d.ts +1 -1
  8. package/dist/compositeRepository.d.ts +3 -1
  9. package/dist/compositeRepository.d.ts.map +1 -1
  10. package/dist/compositeRepository.js +2 -2
  11. package/dist/compositeRepository.js.map +1 -1
  12. package/dist/databaseAddress.d.ts.map +1 -1
  13. package/dist/databaseAddress.js +34 -18
  14. package/dist/databaseAddress.js.map +1 -1
  15. package/dist/deleteGroupsBatched.d.ts +1 -1
  16. package/dist/deleteGroupsBatched.d.ts.map +1 -1
  17. package/dist/deleteGroupsBatched.js +1 -1
  18. package/dist/deleteGroupsBatched.js.map +1 -1
  19. package/dist/makeAggregate.d.ts +2 -0
  20. package/dist/makeAggregate.d.ts.map +1 -1
  21. package/dist/makeAggregate.js +1 -0
  22. package/dist/makeAggregate.js.map +1 -1
  23. package/dist/migrations.js +1 -1
  24. package/dist/migrations.js.map +1 -1
  25. package/dist/orderedChildStatements.d.ts +1 -1
  26. package/dist/postgresChanges.js +1 -1
  27. package/dist/postgresChanges.js.map +1 -1
  28. package/dist/readSql.d.ts +19 -0
  29. package/dist/readSql.d.ts.map +1 -0
  30. package/dist/readSql.js +37 -0
  31. package/dist/readSql.js.map +1 -0
  32. package/dist/recordRepositoryRead.d.ts +12 -0
  33. package/dist/recordRepositoryRead.d.ts.map +1 -0
  34. package/dist/recordRepositoryRead.js +102 -0
  35. package/dist/recordRepositoryRead.js.map +1 -0
  36. package/dist/repository.d.ts.map +1 -1
  37. package/dist/repository.js +6 -5
  38. package/dist/repository.js.map +1 -1
  39. package/dist/repositoryChanges.d.ts +2 -2
  40. package/dist/repositoryChanges.d.ts.map +1 -1
  41. package/dist/repositoryChanges.js +30 -14
  42. package/dist/repositoryChanges.js.map +1 -1
  43. package/dist/repositoryCollection.d.ts +2 -0
  44. package/dist/repositoryCollection.d.ts.map +1 -1
  45. package/dist/repositoryCollection.js +14 -1
  46. package/dist/repositoryCollection.js.map +1 -1
  47. package/dist/repositoryQueries.d.ts +2 -0
  48. package/dist/repositoryQueries.d.ts.map +1 -1
  49. package/dist/repositoryQueries.js +3 -0
  50. package/dist/repositoryQueries.js.map +1 -1
  51. package/dist/repositoryWrites.d.ts +1 -1
  52. package/dist/transact.d.ts +5 -2
  53. package/dist/transact.d.ts.map +1 -1
  54. package/dist/transact.js +7 -3
  55. package/dist/transact.js.map +1 -1
  56. package/package.json +16 -16
  57. package/src/backfillPostgres.ts +1 -1
  58. package/src/compositeRepository.ts +9 -2
  59. package/src/databaseAddress.ts +36 -18
  60. package/src/deleteGroupsBatched.ts +0 -1
  61. package/src/makeAggregate.ts +4 -2
  62. package/src/migrations.ts +1 -1
  63. package/src/postgresChanges.ts +1 -1
  64. package/src/readSql.ts +51 -0
  65. package/src/recordRepositoryRead.ts +126 -0
  66. package/src/repository.ts +6 -5
  67. package/src/repositoryChanges.ts +42 -15
  68. package/src/repositoryCollection.ts +18 -1
  69. package/src/repositoryQueries.ts +5 -0
  70. package/src/transact.ts +14 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.47.0 - 2026-11-11
4
+
5
+ ### Added
6
+
7
+ - `transact` accepts no options: `transact(effect)` and `effect.pipe(transact())` keep a `SqlError` from the body or the `COMMIT` in the error channel unchanged. Pass `transact({ onSqlError })` only to map it, for example with `mapSqlError`.
8
+ - `readSql` from `@shivaedev/sql/readSql.ts` is a tagged template for raw SQL reads such as joins. Interpolate a `collection()` bucket or row key where its value goes, as in `where b.shelf = ${books.bucket.shelf(shelf)}`: `readSql` binds the key's value as the parameter and records the key, as an inferred key, before it sends the statement, so a live query that declares no keys reruns only for writes in that bucket or to that row. Other interpolations behave as in `sql`. A read through `sql` still records nothing. A tuple bucket key or a composite row key spans several columns, so `readSql` refuses it: the call does not compile, and a key typed as a plain `Key` fails with `MultiColumnKeyParameter` before anything is recorded or sent.
9
+ - `findById`, `findOne`, `findMany`, `select`, `count`, `aggregate` and `latestPerGroup` record, as inferred keys, the key their filter pins before they send their statement: each row when every id column is pinned by equality or `in`, otherwise a pinned `bucket` column's keys, otherwise the table.
10
+ - A repository read whose filter pins every column of a tuple bucket by equality or `in` records that tuple's keys, one per combination of pinned values, so a live query of alice's entries for day 1 that declares no `reads` reruns only for writes to alice's day 1. A tuple wins over a single-column bucket on one of its columns; a filter that pins a tuple only in part falls back to a single-column bucket it pins, else the table.
11
+ - An `in` list that holds `null` pins no column, so a read that also matches rows without a value, such as `latestPerGroup` over `day: { in: [1, null] }`, listens on a broader bucket that hears writes to them. A bucket pinned to more than 1,000 keys is skipped for the next bucket that covers the read, else the table.
12
+ - Repository writes announce tuple buckets from the row's old and new stored values: an insert its new tuple, a delete its old one, an update both when any column changed, and no key for a tuple with an absent value.
13
+ - `makeRepository` refuses a collection whose tuple names a column the model lacks or one that cannot decode to a string, number or absent value; `BucketRegistrationError` names them in `invalidTupleColumns`.
14
+
15
+ ## 0.46.4 - 2026-11-08
16
+
17
+ ### Changed
18
+
19
+ - Update `@shivaedev/service` from 0.8.2 to 0.9.0.
20
+
3
21
  ## 0.46.3 - 2026-11-07
4
22
 
5
23
  ### Fixed
package/README.md CHANGED
@@ -23,7 +23,7 @@ const rows = yield* lines.findMany({
23
23
 
24
24
  The application owns the database schema. For PostgreSQL, `postgresLayer` provides one native pool and the Effect SQL clients that use it. Configure new clients with `clientOptions` to map camelCase model fields to snake_case PostgreSQL columns. A **model** describes decoded row fields and the variants used for insertion, updating and JSON. A **repository** combines native `SqlModel` CRUD with a small `findMany` query whose filters and selected results use those fields.
25
25
 
26
- Repository writes announce their table and returned row keys automatically. Every written row keeps its record key, including in bulk writes. Fields marked with `bucket` also announce their old and new bucket keys. Each write uses `transact`; start a surrounding multi-write boundary with `transact` too, so keys leave only after its owning database commits. Bare native transactions are refused because their commit cannot be observed. The change ownership comes from `changes`; this package supplies the SQL boundary and the Reactivity publisher.
26
+ Repository writes announce their table and returned row keys automatically. Every written row keeps its record key, including in bulk writes. Fields marked with `bucket` and tuple buckets declared on the collection also announce their old and new bucket keys. Each write uses `transact`; start a surrounding multi-write boundary with `transact` too, so keys leave only after its owning database commits. Bare native transactions are refused because their commit cannot be observed. The change ownership comes from `changes`; this package supplies the SQL boundary and the Reactivity publisher.
27
27
 
28
28
  Migrations are ordinary Effects loaded by native Migrator. `migratePostgres` adds coordination for PostgreSQL runners sharing a ledger. It does not derive a table from a model: migration SQL and row codecs must agree.
29
29
 
@@ -258,7 +258,7 @@ const settleAndLoad = Effect.gen(function* () {
258
258
  const plates = yield* Plates;
259
259
  yield* lifecycle.settlePot(1);
260
260
  return yield* plates.loadPot(1);
261
- }).pipe(transact({ onSqlError: (error) => error }), Effect.provide(application));
261
+ }).pipe(transact(), Effect.provide(application));
262
262
  ```
263
263
 
264
264
  `database` is the application's `postgresLayer`. `Layer.provideMerge` also keeps its SQL and Reactivity services available to the outer `transact`.
@@ -773,26 +773,17 @@ The lock is held until the transaction commits, including when called inside `tr
773
773
  ### Transactions and invalidation
774
774
 
775
775
  ```ts
776
- import { Data } from "effect";
777
776
  import { transact } from "@shivaedev/sql/transact.ts";
778
777
 
779
- class StorageUnavailable extends Data.TaggedError("StorageUnavailable")<{
780
- readonly reason: string;
781
- }> {}
782
-
783
778
  const saveInvoiceLine = (input: typeof InvoiceLine.update.Type) =>
784
779
  Effect.gen(function* () {
785
780
  const lines = yield* makeInvoiceLines;
786
781
  const saved = yield* lines.update(input);
787
782
  return saved;
788
- }).pipe(
789
- transact({
790
- onSqlError: (error) => new StorageUnavailable({ reason: error.message }),
791
- }),
792
- );
783
+ }).pipe(transact());
793
784
  ```
794
785
 
795
- `transact` wraps native `sql.withTransaction`. It maps typed `SqlError` failures through `onSqlError` and keeps other typed failures and service requirements. `invalidateOnCommit` records derived reader keys that a repository or command declaration does not already name; after the owning outermost commit, they are deduplicated and passed to native `Reactivity.invalidate` once. The record `{ invoiceLines: [1] }` marks `"invoiceLines"` and `"invoiceLines:1"`. An array such as `["invoiceLines:1"]` marks only those keys.
786
+ `transact` wraps native `sql.withTransaction` and keeps the body's typed failures and service requirements. Without options, a `SqlError` from the body or the `COMMIT` stays in the error channel unchanged. Pass `transact({ onSqlError })` to map every `SqlError` instead, for example with [`mapSqlError`](#errors-and-storage-limits) to turn named constraints into domain errors. `invalidateOnCommit` records derived reader keys that a repository or command declaration does not already name; after the owning outermost commit, they are deduplicated and passed to native `Reactivity.invalidate` once. The record `{ invoiceLines: [1] }` marks `"invoiceLines"` and `"invoiceLines:1"`. An array such as `["invoiceLines:1"]` marks only those keys.
796
787
 
797
788
  Arrays also accept typed keys from `collection`: a list key refreshes list subscribers, an item key refreshes that item and its list, and a bucket key refreshes that bucket. Subscribers register these keys through `readKeys` from `@shivaedev/changes/keys.ts`. Typed keys may share an array with raw Reactivity keys; raw keys keep their native identity.
798
789
 
@@ -808,7 +799,7 @@ const moved = changes({
808
799
  yield* Effect.gen(function* () {
809
800
  yield* sql`update notes set "listId" = ${newList} where id = ${id}`;
810
801
  yield* moved.record();
811
- }).pipe(transact({ onSqlError: (error) => error }));
802
+ }).pipe(transact());
812
803
  ```
813
804
 
814
805
  Use `moved.record({ publication: "local" })` to refresh local readers after commit without cross-process publication. `invalidateOnCommit(keys, { publication: "local" })` accepts the same typed option. The default is `"shared"`. Local and shared keys can coexist in one transaction; a key recorded both ways publishes once. Rollback discards both kinds. The option applies to that recording, so other writers in the transaction can still publish shared keys.
@@ -837,23 +828,69 @@ const makeNotes = makeRepository(Note, {
837
828
 
838
829
  Pass the contract collection as the repository's `collection` option when the model has buckets. Registration fails with `BucketRegistrationError` if the collection is missing, its name differs from `tableName`, or its bucket field names differ from the model's annotated fields. The error names both declarations. Registration also rejects annotated fields whose decoded schemas cannot produce key values, naming them in `invalidFields`, before any write. Use explicit string or number schemas and refinements instead of opaque declarations; nullable and optional wrappers remain supported. Repositories without buckets may omit the collection. Every inserted, updated or deleted row announces its record key and each declared bucket from the old and new stored values. An insert belongs only to its new buckets; a move announces both sides; a delete announces the old buckets. Bucket codecs decode stored values before producing keys, so a `bucket(Schema.NumberFromString)` field matches a numeric query bucket even when stored as text. Nullable and optional bucket values contribute no key when absent. Bucket codecs must need no services and decode to strings, numbers or absent values.
839
830
 
840
- Bucket writes require PostgreSQL 18 or later: native `RETURNING old` supplies old values atomically, including for conflict updates. Repositories without bucket fields keep their existing SQL dialect support. Bulk writes keep every record and bucket key; the PostgreSQL publisher splits large batches into NOTIFY payloads.
831
+ A bucket can also span an ordered tuple of columns, declared on the collection rather than the model. Here a diary listens per owner and per owner and day:
832
+
833
+ ```ts
834
+ class Entry extends Model.Class<Entry>("Entry")({
835
+ day: Schema.NullOr(Schema.Number),
836
+ id: Schema.Number,
837
+ note: Schema.String,
838
+ ownerId: bucket(Schema.String),
839
+ }) {}
840
+
841
+ const entries = collection("entries", Entry.fields.id, { ownerId: Entry.fields.ownerId }, { ownerDay: ["ownerId", "day"] });
842
+ const makeEntries = makeRepository(Entry, { collection: entries, idColumn: "id", spanPrefix: "Entries", tableName: "entries" });
843
+ ```
844
+
845
+ A query of alice's entries for day 1 reads `entries.bucket.ownerDay({ ownerId: "alice", day: 1 })` and reruns only for writes to that owner and day; a write by alice on day 2 or by bob on day 1 leaves it alone. A query of all of alice's entries reads `entries.bucket.ownerId("alice")`. Choose a single-column bucket when readers filter by one column and a tuple bucket when they filter by all of its columns together. A repository read whose filter pins every column of the tuple listens on it, as [live reads](#live-reads-listen-on-what-they-filter-by) describe. Repository writes announce each tuple from the row's old and new stored values in the same before-commit path as single-column buckets: an insert announces its new tuple, a delete its old one, and an update both when any column of the tuple changed. A tuple with an absent value, such as an entry without a day, announces no key. Each column decodes through its model field's codec, and its columns need no `bucket` annotation. Registration fails with `BucketRegistrationError`, naming the columns as `tuple.column` in `invalidTupleColumns`, when a tuple names a column the model lacks or one that cannot decode to a string, number or absent value. A raw writer records a tuple key through `changes` like any other bucket key.
846
+
847
+ Bucket writes require PostgreSQL 18 or later: native `RETURNING old` supplies old values atomically, including for conflict updates. Repositories without single-column or tuple buckets keep their existing SQL dialect support. Bulk writes keep every record and bucket key; the PostgreSQL publisher splits large batches into NOTIFY payloads.
841
848
 
842
849
  Record and bucket keys that must commit atomically with a write come from this model and repository path. A command's `invalidates(payload, result, viewer)` runs after its handler returns and uses a separate publication transaction. Failed publication retries twice with 50 ms and 100 ms backoffs. If those attempts fail, `postgresChanges` resynchronizes local live streams and broadcasts Resync on its change channel. If PostgreSQL also rejects the broadcast or cannot be reached, local streams still resynchronize, but healthy listeners on other hosts can miss the write until they reconnect or otherwise reconcile. The failure is logged; NOTIFY provides no durable replay.
843
850
 
844
851
  The transaction rules follow the database owner:
845
- - A typed failure or interruption before commit rolls back and announces nothing. A failed deferred `COMMIT` fails through `onSqlError` and also announces nothing.
852
+ - A typed failure or interruption before commit rolls back and announces nothing. A failed deferred `COMMIT` fails with its `SqlError`, mapped by `onSqlError` when one is given, and also announces nothing.
846
853
  - A nested `transact` on the same client uses a native savepoint. Its successful keys join the outer set; a rolled-back savepoint's keys are discarded.
847
854
  - A transaction on a second client commits independently. Its keys publish when that client commits, even if the enclosing client's transaction later rolls back.
848
855
  - Keys belong to the `SqlClient` in the recording Effect's context. Entering another client's transaction does not move an existing client's keys. Re-entering a still-open transaction on the original client joins its own savepoint.
849
856
  - Recording from a fiber after its transaction finishes dies. Record every changed key before the body returns.
850
857
 
851
- Begin the outermost changed transaction with `transact`. Quality's `effect/sql-transact` rule reports native `sql.withTransaction` calls around repository writes, `transact` or `invalidateOnCommit`, and names `transact` in the repair. It follows direct calls, pipes, local aliases and source helpers; native read-only and raw SQL transactions remain supported. Both `transact` and `invalidateOnCommit` also refuse an unowned native outer transaction at runtime. Outside a transaction, `invalidateOnCommit` publishes immediately.
858
+ Begin the outermost changed transaction with `transact`. Native read-only and raw SQL transactions remain supported. Both `transact` and `invalidateOnCommit` refuse an unowned native outer transaction at runtime. Outside a transaction, `invalidateOnCommit` publishes immediately.
852
859
 
853
860
  PostgreSQL commit visibility decides publication even when a caller is interrupted while `COMMIT` is in flight: if the database commits, keys publish and the caller remains interrupted. If invalidation itself fails after commit, the failure is logged and the committed result stands. Do not treat a notification failure as evidence that the write can be retried safely.
854
861
 
855
862
  For the generic ownership mechanism, read [commit-bound changes](https://github.com/ShivaeDev/platform/blob/main/docs/framework/changes.md). Reactivity keys are local reader invalidation; an application's cross-process or browser delivery belongs at its delivery boundary.
856
863
 
864
+ ### Live reads listen on what they filter by
865
+
866
+ A live query that declares no keys listens on what its repository reads pin. `findById`, `findOne`, `findMany`, `select`, `count`, `aggregate` and `latestPerGroup` name that key from their arguments with `recordRead(keys, { inferred: true })` from `@shivaedev/changes/readRecorder.ts` before they send their statement. A query that declares keys in `reads`, `serverReads` or `readsCollections` listens on them exactly as declared, and these inferred keys are ignored. The key is the same string the table's repository writes announce:
867
+
868
+ - When the filter pins every id column by equality or `in`, the read listens on each row it names. A composite id is keyed by its encoded values, the way writes key the row.
869
+ - Otherwise, when it pins a `bucket` column, or every column of a tuple bucket, by equality or `in`, the read listens on that bucket's keys: one key per pinned value, or per combination of pinned values for a tuple. A tuple pinned only in part pins nothing, so the read falls back to a single-column bucket it pins.
870
+ - When it pins several buckets, a bucket whose columns all belong to another pinned bucket gives way to it, because it hears every write the other hears and more: alice's entries for day 1 listen on `ownerDay`, never on `ownerId`. Among the rest, the read listens on the bucket with the fewest keys. Any pinned bucket hears every write that can change the result, because the filter matches only rows whose pinned columns hold one of the pinned values, and a write announces every bucket of its old and new row.
871
+ - Otherwise it listens on the table.
872
+
873
+ `null`, an `in` list that holds `null`, comparisons and `like` pin nothing, because a write to a row without a value announces no bucket key for it. An `in` with no values matches no row and records no key. A bucket pinned to more than 1,000 keys, such as 2 owners and 501 days of an owner-day tuple, is not a candidate, because each key is registered and renewed on every rerun; the read listens on the next bucket that covers it, else the table. Columns other than the chosen one stay coarse: a list filtered by a bucket and a status reruns for any write in that bucket. A read by id plus a bucket listens on the row, which a move out of the bucket still announces. Keys come only from the arguments, never from the returned rows, so a read of a missing row still listens on that row. Outside a live query run the recorder does nothing.
874
+
875
+ ### A raw read names its key at its parameter
876
+
877
+ A raw SQL read, such as a join, names what it listens on through the parameter it filters by. Interpolate the key itself where the value goes, and write the statement with `readSql` from `@shivaedev/sql/readSql.ts` instead of the native `sql` tag:
878
+
879
+ ```ts
880
+ import { readSql } from "@shivaedev/sql/readSql.ts";
881
+
882
+ const rows = yield* readSql`
883
+ select b.title from books b
884
+ join loans l on l.book = b.id
885
+ where b.shelf = ${books.bucket.shelf(shelf)} and l.reader = ${loans.bucket.reader(reader)}`;
886
+ ```
887
+
888
+ `readSql` binds each interpolated bucket key's value, or each row key's id, as an ordinary parameter, here `shelf` and `reader`, and records those keys with `recordRead(keys, { inferred: true })` before the statement is sent. Everything else interpolates as it does in `sql`: values bind as parameters, and fragments and identifiers such as `${sql("books")}` keep their meaning. The keys are the `collection()` keys the tables' writes announce, so this query reruns for a write on that shelf or a loan to that reader, and for no other. It needs `SqlClient` and returns the rows like a statement.
889
+
890
+ The keys follow the same rules as repository reads: a query that declares `reads`, `serverReads` or `readsCollections` listens exactly as declared and ignores them.
891
+
892
+ A marked parameter carries one value of one column. A tuple bucket key or a composite row key spans several columns, so `readSql` refuses it: the call does not compile, and a key that reaches it typed as a plain `Key` fails with `MultiColumnKeyParameter`, which names the key, before anything is recorded or sent. A marked key must be a top-level interpolation of `readSql`. A key inside a nested `sql` fragment, an array or `sql.in` is not recognised: it is not recorded and reaches the driver as a serialised object. `readSql` binds the key's decoded value. A bucket field whose codec stores a different form than its decoded value, such as a string-to-string transform or an enum stored as an integer, binds the wrong value; such a read keeps a plain `sql` parameter and a declared `reads`. A raw read through `sql` names no table and records nothing; a query built from such reads keeps its declared `reads`. When a query that declares no keys finishes a run without recording one, the live host logs a warning that names it.
893
+
857
894
  ### PostgreSQL advisory locks
858
895
 
859
896
  Serialize cooperating jobs inside `transact`:
@@ -865,14 +902,10 @@ const serializeInvoiceJob = (input: typeof InvoiceLine.update.Type) =>
865
902
  Effect.gen(function* () {
866
903
  yield* advisoryXactLock("jobs:invoice-import");
867
904
  yield* saveInvoiceLine(input);
868
- }).pipe(
869
- transact({
870
- onSqlError: (error) => new StorageUnavailable({ reason: error.message }),
871
- }),
872
- );
905
+ }).pipe(transact());
873
906
  ```
874
907
 
875
- `advisoryXactLock(key: bigint | string)` waits for PostgreSQL's `pg_advisory_xact_lock` on the current client's transaction. A bigint is passed as a signed 64-bit PostgreSQL key without converting it to a JavaScript number. A string uses PostgreSQL's `hashtextextended(key, 0)` as its bigint key; use the same string in cooperating callers. Hash collisions share a lock. Different keys proceed independently. The lock lasts until commit or rollback, including rollback when the holding fiber is interrupted. Outside a transaction, the function fails with typed `AdvisoryLockOutsideTransaction` from the same module. SQL failures remain typed `SqlError` and follow the surrounding `transact` mapper.
908
+ `advisoryXactLock(key: bigint | string)` waits for PostgreSQL's `pg_advisory_xact_lock` on the current client's transaction. A bigint is passed as a signed 64-bit PostgreSQL key without converting it to a JavaScript number. A string uses PostgreSQL's `hashtextextended(key, 0)` as its bigint key; use the same string in cooperating callers. Hash collisions share a lock. Different keys proceed independently. The lock lasts until commit or rollback, including rollback when the holding fiber is interrupted. Outside a transaction, the function fails with typed `AdvisoryLockOutsideTransaction` from the same module. SQL failures remain typed `SqlError` and follow the surrounding `transact`'s `onSqlError` when it has one.
876
909
 
877
910
  ### Bounded, resumable PostgreSQL backfills
878
911
 
@@ -962,7 +995,7 @@ Pass an optional `release` string to `migratePostgres` to record the owning rele
962
995
 
963
996
  `WorkerRelease` is imported from `@shivaedev/sql/worker-release/service.ts`. Its Layer owns the active flag, registrations and lock; `register(control)` keeps a worker control registered until the caller’s scope closes, and `setActive(active)` serializes activation and draining with registration. Both operations are traced. `makeWorkerRelease()` from `@shivaedev/sql/makeWorkerRelease.ts` builds a fresh gate through that Layer in the caller’s scope and returns `{ service, setActive }`.
964
997
 
965
- `appDatabase` from `@shivaedev/server/appDatabase.ts` supplies the optional `WorkerRelease` Context service in migration mode `"wait"` with a release. Startup waits for that marker within `waitTimeout`; subsequent checks run every `pollInterval`. Each worker database Layer claims a process row only when its release owns the marker and no live row of another release remains. Heartbeats continue every poll while jobs drain, including after a connection blip. Each failed heartbeat or ownership poll logs its cause and retries three times, one quarter of a polling interval apart; exhausted retries close the worker scope with the failure cause. Completed drain and clean shutdown remove the row. Rows older than five polling intervals count as gone, bounding takeover after a crash (five seconds at the default one-second poll). Reserve SQL pool capacity for heartbeats alongside active jobs and the change listener. Release equality decides ownership, so a new migration invocation publishing an earlier release resumes that release's worker. `@shivaedev/jobs` reads the service automatically; applications do not connect a signal themselves. Web's `"check"` mode ignores the marker.
998
+ `appDatabase` from `@shivaedev/server/appDatabase.ts` supplies the optional `WorkerRelease` Context service in migration mode `"wait"` with a release. Startup waits for that marker within `waitTimeout`; subsequent checks run every `pollInterval`. Each worker database Layer claims a process row only when its release owns the marker and no live row of another release remains. Heartbeats continue every poll while jobs drain. Completed drain and clean shutdown remove the row. Rows older than five polling intervals count as gone, bounding takeover after a crash (five seconds at the default one-second poll). Reserve SQL pool capacity for heartbeats alongside active jobs and the change listener. Release equality decides ownership, so a new migration invocation publishing an earlier release resumes that release's worker. `@shivaedev/jobs` reads the service automatically; applications do not connect a signal themselves. Web's `"check"` mode ignores the marker.
966
999
 
967
1000
  ### PostgreSQL delivery between processes
968
1001
 
@@ -982,7 +1015,7 @@ const delivery = postgresChanges({
982
1015
 
983
1016
  The Layer also provides `CommandPublication` from `@shivaedev/changes/commandPublication.ts`. Call `publish(keys)` after a command's write commits to announce its declared keys through the bound client. An enclosing `transact` delays these keys until its outer commit and discards them on rollback. Publication failures use the typed `CommandPublicationError`; `recover` resynchronizes local streams and broadcasts Resync through PostgreSQL. Recovery failures use the same typed error, so the command boundary can log a delivery gap while preserving the committed result.
984
1017
 
985
- `PostgresChangesOptions` takes `channel`, `client`, `resync`, optional `listenerClient` and `connectionSetting` (a diagnostic label, default `"client"`), and optional `heartbeatInterval`, `heartbeatTimeout` and `retryDelay` Effect durations. The defaults are 5 seconds, 10 seconds and 1 second. Acquisition waits for LISTEN and then a heartbeat received through it, each within `heartbeatTimeout`. A deadline without a heartbeat fails startup with `PostgresListenerError` from `@shivaedev/sql/PostgresListenerError.ts`, whose `connectionSetting` and message identify the connection to fix. Native SQL failures still fail startup with `SqlError`. Established listeners reconnect after a loss. Loss warnings and reconnect debug logs omit database causes. A missing heartbeat or a stream failure resyncs streams before listener cleanup; a successful reconnection resyncs again. Listener cleanup runs in a parallel sub-scope bounded by `heartbeatTimeout`, so stalled listener cleanup cannot delay native connection release, a fresh subscription or scope shutdown. The heartbeat detects a listener that stops delivering without failing. `resync` is an infallible `Effect.Effect<number>` returning the number of open live streams it marked for reconciliation. `makeLiveServer.resync` provides this count and stops counting a stream when its scope closes. Direct bindings with another stream owner must return that owner's count. Provide the Layer for the process lifetime so scope release closes the listener.
1018
+ `PostgresChangesOptions` takes `channel`, `client`, `resync`, optional `listenerClient` and `connectionSetting` (a diagnostic label, default `"client"`), and optional `heartbeatInterval`, `heartbeatTimeout` and `retryDelay` Effect durations. The defaults are 5 seconds, 10 seconds and 1 second. Acquisition waits for LISTEN and then a heartbeat received through it, each within `heartbeatTimeout`. A deadline without a heartbeat fails startup with `PostgresListenerError` from `@shivaedev/sql/PostgresListenerError.ts`, whose `connectionSetting` and message identify the connection to fix. Native SQL failures still fail startup with `SqlError`. Listener cleanup runs in a parallel sub-scope bounded by `heartbeatTimeout`, so stalled listener cleanup cannot delay scope shutdown. `resync` is an infallible `Effect.Effect<number>` returning the number of open live streams it marked for reconciliation. `makeLiveServer.resync` provides this count and stops counting a stream when its scope closes. Direct bindings with another stream owner must return that owner's count. Provide the Layer for the process lifetime so scope release closes the listener.
986
1019
 
987
1020
  NOTIFY is a wake-up signal, not a durable log. Transaction payloads contain only string or finite-number invalidation keys, with no row values. PostgreSQL requires each payload to be smaller than 8,000 bytes in the default configuration. The binding splits JSON arrays by their UTF-8 byte length; one key that cannot fit, or a nonserializable key type, fails with `SqlError` before commit and rolls back the write. Heartbeats use a separate control payload on the same channel. Applications choose a channel shared only by their cooperating processes. LISTEN requires a session connection; PgBouncer transaction pooling needs another delivery adapter. Missed notifications are reconciled by querying again on resync, with no replay guarantee.
988
1021
 
@@ -991,6 +1024,7 @@ NOTIFY is a wake-up signal, not a durable log. Transaction payloads contain only
991
1024
  Import the module that defines the name; there is no root entry.
992
1025
  - `@shivaedev/sql/clientOptions.ts`: `clientOptions(options, { snakeCase? })`, `SqlNameTransforms` — Add default native name transforms to driver or app host options; opt out with `snakeCase: false`.
993
1026
  - `@shivaedev/sql/inValues.ts`: `inValues(column, values)` — Native list predicate with match-nothing semantics for an empty list; requires `SqlClient`.
1027
+ - `@shivaedev/sql/readSql.ts`: `` readSql`...` ``, `MultiColumnKeyParameter` — Raw SQL read that binds each interpolated bucket or row key's value and records the key for a live query before sending; refuses tuple bucket and composite row keys; requires `SqlClient`.
994
1028
  - `@shivaedev/sql/keysetPage.ts`: `keysetPage(options)`, `KeysetOrder`, `KeysetPageQuery`, `KeysetPage` — Native seek and order fragments with a required unique tie-breaker, validated page size and one-row lookahead; predicates, result schemas and cursor formats stay with the caller.
995
1029
  - `@shivaedev/sql/int8.ts`: `int8(field)` — PostgreSQL bigint storage codec using the supplied field schema.
996
1030
  - `@shivaedev/sql/int4Array.ts`: `int4Array(field)` — PostgreSQL integer-array storage codec, including typed empty arrays.
@@ -1002,7 +1036,7 @@ Import the module that defines the name; there is no root entry.
1002
1036
  - `@shivaedev/sql/upsertResult.ts`: `UpsertRow` — The `{ row, inserted }` result of an unconditional upsert.
1003
1037
  - `@shivaedev/sql/conditionalUpsert.ts`: `UpsertFilter`, `UpsertResult` — The `updateWhere` filter shape and the tagged `Inserted`, `Updated` or `Unchanged` result of a conditional upsert.
1004
1038
  - `@shivaedev/sql/mapSqlError.ts`: `mapSqlError({ constraints, fallback })` — Mapper from named constraint violations to application errors, with a fallback for every other `SqlError`.
1005
- - `@shivaedev/sql/transact.ts`: `transact(effect, options)` or `effect.pipe(transact(options))` — Required `onSqlError` mapper; requires `SqlClient` and `Reactivity`.
1039
+ - `@shivaedev/sql/transact.ts`: `transact(effect, options?)` or `effect.pipe(transact(options?))` — Optional `onSqlError` mapper; without it `SqlError` stays in the error channel; requires `SqlClient` and `Reactivity`.
1006
1040
  - `@shivaedev/sql/transact.ts`: `invalidateOnCommit(keys, options?)` — Records keys for its client, or invalidates immediately outside a transaction.
1007
1041
  - `@shivaedev/sql/advisoryXactLock.ts`: `advisoryXactLock(key)`, `AdvisoryLockOutsideTransaction` — PostgreSQL transaction lock on a bigint or string hashed with `hashtextextended(key, 0)`; requires an active transaction on the current `SqlClient`.
1008
1042
  - `@shivaedev/sql/migration.ts`: `MIGRATIONS_DIRECTORY`, `MIGRATION_FILE_PATTERN` — Application folder and four-digit sequential snake_case TypeScript filename pattern.
@@ -1013,7 +1047,7 @@ Import the module that defines the name; there is no root entry.
1013
1047
  - `@shivaedev/sql/pendingPostgresMigrations.ts`: `pendingPostgresMigrations({ loader, table?, components? })` — Pending ledger migrations as ID and name, and pending schema components as name and detail.
1014
1048
  - `@shivaedev/sql/postgresRelease.ts`: `postgresRelease(release, table?)`, `readPostgresRelease(table?)` — Release marker schema component and its reader.
1015
1049
  - `@shivaedev/sql/postgresChanges.ts`: `postgresChanges(options)` — Scoped PostgreSQL LISTEN/NOTIFY Layer for commit-bound invalidation.
1016
- - `@shivaedev/sql/repositoryCollection.ts`: `BucketRegistrationError` — Registration failure with table, collection and bucket field names.
1050
+ - `@shivaedev/sql/repositoryCollection.ts`: `BucketRegistrationError` — Registration failure with table, collection and bucket field names and invalid tuple columns.
1017
1051
  - `@shivaedev/sql/changes.ts`: `changes(covers)`, `ChangeDeclaration` — Declares a raw writer's table, record and bucket keys once, with a `record(options?)` action.
1018
1052
  - `@shivaedev/test-kits/sql/testing.ts`: `withChangeCoverage(body, { covers })`, `expectPublished(keys)`, `UnannouncedWrites`, `PublishedKeysMismatch` — Test assertions that every write announced its keys and that the expected keys were published.
1019
1053
 
@@ -13,6 +13,6 @@ export interface BackfillOptions<TRow extends object, TProgress, E, R> {
13
13
  readonly saveProgress: (last: TRow, previous: TProgress) => Effect.Effect<unknown, E, R>;
14
14
  readonly select: (progress: TProgress, limit: number) => Effect.Effect<readonly TRow[], E, R>;
15
15
  }
16
- export declare const backfillPostgres: <TRow extends object, TProgress, E, R>(options: BackfillOptions<TRow, TProgress, E, R>) => Effect.Effect<number, BackfillInsideTransaction | Schema.SchemaError | import("effect/sql/SqlError").SqlError | Exclude<E, import("effect/sql/SqlError").SqlError>, R | import("effect/reactivity/Reactivity").Reactivity | SqlClient.SqlClient>;
16
+ export declare const backfillPostgres: <TRow extends object, TProgress, E, R>(options: BackfillOptions<TRow, TProgress, E, R>) => Effect.Effect<number, E | BackfillInsideTransaction | Schema.SchemaError | import("effect/sql/SqlError").SqlError, R | import("effect/reactivity/Reactivity").Reactivity | SqlClient.SqlClient>;
17
17
  export {};
18
18
  //# sourceMappingURL=backfillPostgres.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backfillPostgres.d.ts","sourceRoot":"","sources":["../src/backfillPostgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;;;;AAIvC,qBAAa,yBAA0B,SAAQ,8BAA6C;CAAG;AAE/F,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,Y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,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,QAAQ,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzF,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC9F;AAID,eAAO,MAAM,gBAAgB,GAAgD,IAAI,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,qPA4B/G,CAAC"}
@@ -25,7 +25,7 @@ export const backfillPostgres = Effect.fn("Sql.backfillPostgres")(function* (opt
25
25
  yield* options.saveProgress(last, progress);
26
26
  }
27
27
  return rows.length;
28
- }).pipe(transact({ onSqlError: (error) => error }));
28
+ }).pipe(transact());
29
29
  processed += count;
30
30
  if (count === 0) {
31
31
  return processed;
@@ -1 +1 @@
1
- {"version":3,"file":"backfillPostgres.js","sourceRoot":"","sources":["../src/backfillPostgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,OAAO,yBAA0B,SAAQ,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAAC;CAAG;AAW/F,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,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AAC;YACD,OAAO,IAAI,CAAC,MAAM,CAAC;QACpB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACpB,SAAS,IAAI,KAAK,CAAC;QACnB,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACjB,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC;AACF,CAAC,CAAC,CAAC"}
@@ -34,7 +34,7 @@ export declare const makeBatchedDelete: (model: Model.Any, args_1: {
34
34
  record: (rows: readonly Readonly<Record<string, unknown>>[]) => Effect.Effect<void, Schema.SchemaError, never>;
35
35
  recordTable: (rows: number) => Effect.Effect<void, never, never>;
36
36
  returning: (base?: import("effect/sql/Statement").Statement<import("effect/sql/SqlConnection").Row>) => Fragment;
37
- write: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, SqlError | Exclude<E, SqlError>, Exclude<Exclude<R, SqlClient.SqlClient>, import("effect/reactivity/Reactivity").Reactivity>>;
37
+ write: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError, Exclude<Exclude<R, SqlClient.SqlClient>, import("effect/reactivity/Reactivity").Reactivity>>;
38
38
  }) => Effect.Effect<(options: BatchedDeleteOptions<Model.Any>) => Effect.Effect<number, BatchedDeleteUnavailable | Schema.SchemaError | SqlError, unknown>, never, SqlClient.SqlClient>;
39
39
  export {};
40
40
  //# sourceMappingURL=batchedDelete.d.ts.map
@@ -4,6 +4,7 @@ import type { Model } from "effect/schema";
4
4
  import { SqlClient } from "effect/sql";
5
5
  import type { SqlError } from "effect/sql/SqlError";
6
6
  import type { BatchedDelete } from "#batchedDelete.ts";
7
+ import type { RecordRead } from "#recordRepositoryRead.ts";
7
8
  import type { RepositoryListFilter } from "#repositoryFilter.ts";
8
9
  import type { Update, UpdateVoid } from "#repositoryUpdate.ts";
9
10
  import type { IdColumn, NativeRepository } from "#versionedRepository.ts";
@@ -22,13 +23,14 @@ export type Repository<TModel extends Model.Any, TId extends PrimaryKey<TModel>>
22
23
  } : never);
23
24
  export declare const makeCompositeCrud: (model: Model.Any, options: {
24
25
  readonly columns: readonly string[];
26
+ readonly recordRead: RecordRead;
25
27
  readonly tableName: string;
26
28
  readonly spanPrefix: string;
27
29
  }, changes: {
28
30
  record: (rows: readonly Readonly<Record<string, unknown>>[]) => Effect.Effect<void, Schema.SchemaError, never>;
29
31
  recordTable: (rows: number) => Effect.Effect<void, never, never>;
30
32
  returning: (base?: import("effect/sql/Statement").Statement<import("effect/sql/SqlConnection").Row>) => import("effect/sql/Statement").Fragment;
31
- write: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, SqlError | Exclude<E, SqlError>, Exclude<Exclude<R, SqlClient.SqlClient>, import("effect/reactivity/Reactivity").Reactivity>>;
33
+ write: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | SqlError, Exclude<Exclude<R, SqlClient.SqlClient>, import("effect/reactivity/Reactivity").Reactivity>>;
32
34
  }) => Effect.Effect<{
33
35
  delete: (id: unknown) => Effect.Effect<void, Schema.SchemaError | SqlError, unknown>;
34
36
  insert: (input: unknown) => Effect.Effect<unknown, Schema.SchemaError | SqlError, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"compositeRepository.d.ts","sourceRoot":"","sources":["../src/compositeRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,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AAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAC1G,WAAW,CAAC,MAAM,CAAC,CAAC;CACrB,GACA,KAAK,CAAC,CAAC;AAEZ,eAAO,MAAM,iBAAiB;sBAGV,SAAS,MAAM,EAAE;yBACd,UAAU;wBACX,MAAM;yBACL,MAAM;;;;;;;;;;;;;;;;;mBAoCZ,OAAO;8BAOtB,CAAC"}
@@ -6,7 +6,7 @@ import { sqlNameTransforms } from "#sqlNameTransforms.ts";
6
6
  export const makeCompositeCrud = Effect.fnUntraced(function* (model, options, changes) {
7
7
  const sql = yield* SqlClient.SqlClient;
8
8
  const nameTransforms = yield* sqlNameTransforms;
9
- const { columns, tableName, spanPrefix } = options;
9
+ const { columns, recordRead, tableName, spanPrefix } = options;
10
10
  const entries = [];
11
11
  for (const column of columns) {
12
12
  const field = model.fields[column];
@@ -31,7 +31,7 @@ export const makeCompositeCrud = Effect.fnUntraced(function* (model, options, ch
31
31
  });
32
32
  return {
33
33
  ...(yield* repositoryWrites(model, { ...options, idColumns: columns }, changes)),
34
- findById: (id) => find(id).pipe(Effect.withSpan(`${spanPrefix}.findById`)),
34
+ findById: (id) => record(columns.length === 1 ? { [columns[0] ?? ""]: id } : id).pipe(Effect.flatMap(recordRead), Effect.andThen(find(id)), Effect.withSpan(`${spanPrefix}.findById`)),
35
35
  };
36
36
  });
37
37
  //# sourceMappingURL=compositeRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compositeRepository.js","sourceRoot":"","sources":["../src/compositeRepository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,SAAS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OAAO;QACN,GAAG,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAChF,QAAQ,EAAE,CAAC,EAAW,EAAE,EAAE,CACzB,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAClE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAC1B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EACxB,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,WAAW,CAAC,CACzC;KACF,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"databaseAddress.d.ts","sourceRoot":"","sources":["../src/databaseAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAqBrG"}
1
+ {"version":3,"file":"databaseAddress.d.ts","sourceRoot":"","sources":["../src/databaseAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAgBlC,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAyBrG"}
@@ -1,25 +1,41 @@
1
1
  import { Redacted } from "effect";
2
+ function isDecodableHost(hostname) {
3
+ const runs = hostname.match(/(?:%[\da-f]{2})+/giu) ?? [];
4
+ if (hostname.replace(/(?:%[\da-f]{2})+/giu, "").includes("%")) {
5
+ return false;
6
+ }
7
+ const encoder = new TextEncoder();
8
+ const decoder = new TextDecoder();
9
+ return runs.every((run) => {
10
+ const bytes = Uint8Array.from(run.match(/[\da-f]{2}/giu) ?? [], (byte) => Number.parseInt(byte, 16));
11
+ const decoded = encoder.encode(decoder.decode(bytes));
12
+ return decoded.length === bytes.length && decoded.every((byte, index) => byte === bytes[index]);
13
+ });
14
+ }
2
15
  export function databaseAddress(value) {
3
- try {
4
- const url = new URL(Redacted.value(value));
5
- if (url.protocol !== "postgres:" && url.protocol !== "postgresql:") {
6
- return {};
7
- }
8
- const hostname = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : decodeURIComponent(url.hostname);
9
- // PgConnection applies query parameters in order, after the authority.
10
- const host = url.searchParams.getAll("host").at(-1) ?? hostname;
11
- const rawPort = url.searchParams.getAll("port").at(-1) ?? url.port;
12
- const port = rawPort === "" ? undefined : Number(rawPort);
13
- if (host.includes(",") || (port !== undefined && (!Number.isInteger(port) || port < 1 || port > 65_535))) {
14
- return {};
15
- }
16
- return {
17
- ...(host === "" && !url.searchParams.has("host") ? {} : { host }),
18
- ...(port === undefined ? {} : { port }),
19
- };
16
+ const address = Redacted.value(value);
17
+ if (!URL.canParse(address)) {
18
+ return {};
19
+ }
20
+ const url = new URL(address);
21
+ if (url.protocol !== "postgres:" && url.protocol !== "postgresql:") {
22
+ return {};
23
+ }
24
+ const rawHostname = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname;
25
+ if (!isDecodableHost(rawHostname)) {
26
+ return {};
20
27
  }
21
- catch {
28
+ const hostname = decodeURIComponent(rawHostname);
29
+ // PgConnection applies query parameters in order, after the authority.
30
+ const host = url.searchParams.getAll("host").at(-1) ?? hostname;
31
+ const rawPort = url.searchParams.getAll("port").at(-1) ?? url.port;
32
+ const port = rawPort === "" ? undefined : Number(rawPort);
33
+ if (host.includes(",") || (port !== undefined && (!Number.isInteger(port) || port < 1 || port > 65_535))) {
22
34
  return {};
23
35
  }
36
+ return {
37
+ ...(host === "" && !url.searchParams.has("host") ? {} : { host }),
38
+ ...(port === undefined ? {} : { port }),
39
+ };
24
40
  }
25
41
  //# sourceMappingURL=databaseAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"databaseAddress.js","sourceRoot":"","sources":["../src/databaseAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,MAAM,UAAU,eAAe,CAAC,KAAgC;IAC/D,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3C,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;YACpE,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC7G,uEAAuE;QACvE,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC;QAChE,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC;QACnE,MAAM,IAAI,GAAG,OAAO,KA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;IACjD,uEAAuE;IACvE,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC;IAChE,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC;IACnE,MAAM,IAAI,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1D,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;QAC1G,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO;QACN,GAAG,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QACjE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;KACvC,CAAC;AACH,CAAC"}
@@ -9,5 +9,5 @@ export interface DeleteGroupsBatchedOptions<T, TSelectError, TSelectServices, TD
9
9
  readonly select: (limit: number) => Effect.Effect<readonly DeleteGroup<T>[], TSelectError, TSelectServices>;
10
10
  readonly tableName: string;
11
11
  }
12
- export declare const deleteGroupsBatched: <T, TSelectError, TSelectServices, TDeleteError, TDeleteServices>(options: DeleteGroupsBatchedOptions<T, TSelectError, TSelectServices, TDeleteError, TDeleteServices>) => Effect.Effect<number, import("#batchedDelete.ts").BatchedDeleteUnavailable | Schema.SchemaError | import("effect/sql/SqlError").SqlError | Exclude<TDeleteError, import("effect/sql/SqlError").SqlError> | Exclude<TSelectError, import("effect/sql/SqlError").SqlError>, import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient | Exclude<TDeleteServices, import("effect/Scope").Scope> | Exclude<TSelectServices, import("effect/Scope").Scope>>;
12
+ export declare const deleteGroupsBatched: <T, TSelectError, TSelectServices, TDeleteError, TDeleteServices>(options: DeleteGroupsBatchedOptions<T, TSelectError, TSelectServices, TDeleteError, TDeleteServices>) => Effect.Effect<number, TDeleteError | TSelectError | import("#batchedDelete.ts").BatchedDeleteUnavailable | Schema.SchemaError | import("effect/sql/SqlError").SqlError, import("effect/reactivity/Reactivity").Reactivity | import("effect/sql/SqlClient").SqlClient | Exclude<TDeleteServices, import("effect/Scope").Scope> | Exclude<TSelectServices, import("effect/Scope").Scope>>;
13
13
  //# sourceMappingURL=deleteGroupsBatched.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteGroupsBatched.d.ts","sourceRoot":"","sources":["../src/deleteGroupsBatched.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAoB,KAAK,WAAW,EAAmB,MAAM,mBAAmB,CAAC;AAGxF,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B,CAAC,CAAC,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,CAAE,SAAQ,WAAW;IAC/H,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;IACrF,QAAQ,CAAC,M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leteGroupsBatched")(function
18
18
  yield* options.delete(group);
19
19
  }
20
20
  return { count, done: candidates.length === 0 };
21
- }), { onSqlError: (error) => error })).pipe(Effect.scoped);
21
+ }))).pipe(Effect.scoped);
22
22
  });
23
23
  //# sourceMappingURL=deleteGroupsBatched.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteGroupsBatched.js","sourceRoot":"","sources":["../src/deleteGroupsBatched.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAaxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,yBAAyB,CAAC,CAAC,QAAQ,CAAC,EAChF,OAAoG;IAEpG,OAAO,KAAK,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACnE,QAAQ,CACP,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAQ,EAAE,CAAC;QACzB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACrF,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;gBAC1B,MAAM;YACP,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/B,KAAK,IAAI,IAAI,CAAC;QACf,CAAC;QACD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YACrF,IAAI,IAAI,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;gBAC1B,MAAM;YACP,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAC/B,KAAK,IAAI,IAAI,CAAC;QACf,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC9B,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACjD,CAAC,CAAC,CACF,CACD,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -2,7 +2,9 @@ import { Effect } from "effect";
2
2
  import type { Model } from "effect/schema";
3
3
  import { SqlClient } from "effect/sql";
4
4
  import type { Aggregate } from "#aggregateQuery.ts";
5
+ import type { RecordRead } from "#recordRepositoryRead.ts";
5
6
  export declare function makeAggregate<TModel extends Model.Any>(model: TModel, options: {
7
+ readonly recordRead: RecordRead;
6
8
  readonly tableName: string;
7
9
  readonly spanPrefix: string;
8
10
  }): Effect.Effect<Aggregate<TModel>, never, SqlClient.SqlClient>;
@@ -1 +1 @@
1
- {"version":3,"file":"makeAggregate.d.ts","sourceRoot":"","sources":["../src/makeAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,wBAAgB,aAAa,CAAC,MAAM,SAAS,KAAK,CAAC,GAAG,EACrD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAClE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"makeAggregate.d.ts","sourceRoot":"","sources":["../src/makeAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAG3D,wBAAgB,aAAa,CAAC,MAAM,SAAS,KAAK,CAAC,GAAG,EACrD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACnG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC"}
@@ -33,6 +33,7 @@ export function makeAggregate(model, options) {
33
33
  const predicate = yield* where(query.where, true, true);
34
34
  const order = yield* clauses.orderClause(query.orderBy);
35
35
  const limit = yield* clauses.limitClause(query.limit);
36
+ yield* options.recordRead(query.where);
36
37
  const partitions = sql.csv(groups.map((key) => sql `${sql(key)}`));
37
38
  const rows = yield* sql `select ${sql.csv(columns)} from ${sql(options.tableName)} where ${predicate} group by ${partitions} ${order} ${limit}`;
38
39
  return yield* Schema.decodeUnknownEffect(Schema.Array(Result))(rows);
@@ -1 +1 @@
1
- {"version":3,"file":"makeAggregate.js","s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C,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,UAAU,YAAY,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,EAAE,CAAC;AACN,CAAC"}
@@ -52,7 +52,7 @@ export const migratePostgres = Effect.fn("EffectSql.migratePostgres")(function*
52
52
  }
53
53
  }
54
54
  return yield* migrate({ loader: Effect.succeed(current), table });
55
- }).pipe(transact({ onSqlError: (error) => error }), Effect.provideService(Reactivity.Reactivity, reactivity));
55
+ }).pipe(transact(), Effect.provideService(Reactivity.Reactivity, reactivity));
56
56
  const schemaComponents = [
57
57
  ...components,
58
58
  ...(release === undefined ? [] : [postgresRelease(release, table)]),
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.js","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,KAAK,UAAU,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAwB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAUxC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,QAAQ,CAAC,EAAgB,EAC9F,MAAM,EACN,UAAU,GAAG,EAAE,EACf,KAAK,GAAG,uBAAuB,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AC,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAC9E,MAAM,gBAAgB,GAAqE;QAC1F,GAAG,UAAU;QACb,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;KACnE,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;QAC1C,KAAK,CAAC,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;IACnI,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC1B,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC"}
@@ -20,7 +20,7 @@ export declare const orderedChildStatements: (model: Model.Any, options: ChildOr
20
20
  record: (rows: readonly Readonly<Record<string, unknown>>[]) => Effect.Effect<void, Schema.SchemaError, never>;
21
21
  recordTable: (rows: number) => Effect.Effect<void, never, never>;
22
22
  returning: (base?: import("effect/sql/Statement").Statement<import("effect/sql/SqlConnection").Row>) => import("effect/sql/Statement").Fragment;
23
- write: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, import("effect/sql/SqlError").SqlError | Exclude<E, import("effect/sql/SqlError").SqlError>, Exclude<Exclude<R, SqlClient.SqlClient>, import("effect/reactivity/Reactivity").Reactivity>>;
23
+ write: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | import("effect/sql/SqlError").SqlError, Exclude<Exclude<R, SqlClient.SqlClient>, import("effect/reactivity/Reactivity").Reactivity>>;
24
24
  }) => Effect.Effect<{
25
25
  lock: (value: unknown) => Effect.Effect<unknown, Cause.NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, unknown>;
26
26
  move: (value: unknown, child: unknown, position: number) => Effect.Effect<undefined, ChildOrderError | Cause.NoSuchElementError | Schema.SchemaError | import("effect/sql/SqlError").SqlError, unknown>;