@shivaedev/sql 0.0.0 → 0.21.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 (189) hide show
  1. package/CHANGELOG.md +269 -0
  2. package/LICENSE +21 -0
  3. package/README.md +613 -1
  4. package/dist/SchemaComponent.d.ts +9 -0
  5. package/dist/SchemaComponent.d.ts.map +1 -0
  6. package/dist/SchemaComponent.js +6 -0
  7. package/dist/SchemaComponent.js.map +1 -0
  8. package/dist/WorkerRelease.d.ts +14 -0
  9. package/dist/WorkerRelease.d.ts.map +1 -0
  10. package/dist/WorkerRelease.js +30 -0
  11. package/dist/WorkerRelease.js.map +1 -0
  12. package/dist/advisoryXactLock.d.ts +10 -0
  13. package/dist/advisoryXactLock.d.ts.map +1 -0
  14. package/dist/advisoryXactLock.js +18 -0
  15. package/dist/advisoryXactLock.js.map +1 -0
  16. package/dist/aggregateColumn.d.ts +8 -0
  17. package/dist/aggregateColumn.d.ts.map +1 -0
  18. package/dist/aggregateColumn.js +44 -0
  19. package/dist/aggregateColumn.js.map +1 -0
  20. package/dist/aggregateQuery.d.ts +51 -0
  21. package/dist/aggregateQuery.d.ts.map +1 -0
  22. package/dist/aggregateQuery.js +2 -0
  23. package/dist/aggregateQuery.js.map +1 -0
  24. package/dist/assertPostgresMigrations.d.ts +7 -0
  25. package/dist/assertPostgresMigrations.d.ts.map +1 -0
  26. package/dist/assertPostgresMigrations.js +20 -0
  27. package/dist/assertPostgresMigrations.js.map +1 -0
  28. package/dist/batchWrites.d.ts +16 -0
  29. package/dist/batchWrites.d.ts.map +1 -0
  30. package/dist/batchWrites.js +49 -0
  31. package/dist/batchWrites.js.map +1 -0
  32. package/dist/clientOptions.d.ts +8 -0
  33. package/dist/clientOptions.d.ts.map +1 -0
  34. package/dist/clientOptions.js +8 -0
  35. package/dist/clientOptions.js.map +1 -0
  36. package/dist/compositeRepository.d.ts +41 -0
  37. package/dist/compositeRepository.d.ts.map +1 -0
  38. package/dist/compositeRepository.js +38 -0
  39. package/dist/compositeRepository.js.map +1 -0
  40. package/dist/conditionalUpsert.d.ts +59 -0
  41. package/dist/conditionalUpsert.d.ts.map +1 -0
  42. package/dist/conditionalUpsert.js +28 -0
  43. package/dist/conditionalUpsert.js.map +1 -0
  44. package/dist/conflictWrites.d.ts +45 -0
  45. package/dist/conflictWrites.d.ts.map +1 -0
  46. package/dist/conflictWrites.js +40 -0
  47. package/dist/conflictWrites.js.map +1 -0
  48. package/dist/coordinateWorkerRelease.d.ts +5 -0
  49. package/dist/coordinateWorkerRelease.d.ts.map +1 -0
  50. package/dist/coordinateWorkerRelease.js +30 -0
  51. package/dist/coordinateWorkerRelease.js.map +1 -0
  52. package/dist/insertFromSelect.d.ts +24 -0
  53. package/dist/insertFromSelect.d.ts.map +1 -0
  54. package/dist/insertFromSelect.js +15 -0
  55. package/dist/insertFromSelect.js.map +1 -0
  56. package/dist/latestPerGroup.d.ts +11 -0
  57. package/dist/latestPerGroup.d.ts.map +1 -0
  58. package/dist/latestPerGroup.js +51 -0
  59. package/dist/latestPerGroup.js.map +1 -0
  60. package/dist/listenForChanges.d.ts +5 -0
  61. package/dist/listenForChanges.d.ts.map +1 -0
  62. package/dist/listenForChanges.js +75 -0
  63. package/dist/listenForChanges.js.map +1 -0
  64. package/dist/makeAggregate.d.ts +8 -0
  65. package/dist/makeAggregate.d.ts.map +1 -0
  66. package/dist/makeAggregate.js +38 -0
  67. package/dist/makeAggregate.js.map +1 -0
  68. package/dist/makeConflictClause.d.ts +10 -0
  69. package/dist/makeConflictClause.d.ts.map +1 -0
  70. package/dist/makeConflictClause.js +41 -0
  71. package/dist/makeConflictClause.js.map +1 -0
  72. package/dist/makeQueryClauses.d.ts +14 -0
  73. package/dist/makeQueryClauses.d.ts.map +1 -0
  74. package/dist/makeQueryClauses.js +20 -0
  75. package/dist/makeQueryClauses.js.map +1 -0
  76. package/dist/migrationConvention.d.ts +3 -0
  77. package/dist/migrationConvention.d.ts.map +1 -0
  78. package/dist/migrationConvention.js +3 -0
  79. package/dist/migrationConvention.js.map +1 -0
  80. package/dist/migrations.d.ts +12 -0
  81. package/dist/migrations.d.ts.map +1 -0
  82. package/dist/migrations.js +41 -0
  83. package/dist/migrations.js.map +1 -0
  84. package/dist/migrationsFromDirectory.d.ts +4 -0
  85. package/dist/migrationsFromDirectory.d.ts.map +1 -0
  86. package/dist/migrationsFromDirectory.js +7 -0
  87. package/dist/migrationsFromDirectory.js.map +1 -0
  88. package/dist/notifyPayload.d.ts +7 -0
  89. package/dist/notifyPayload.d.ts.map +1 -0
  90. package/dist/notifyPayload.js +31 -0
  91. package/dist/notifyPayload.js.map +1 -0
  92. package/dist/pendingPostgresMigrations.d.ts +24 -0
  93. package/dist/pendingPostgresMigrations.d.ts.map +1 -0
  94. package/dist/pendingPostgresMigrations.js +30 -0
  95. package/dist/pendingPostgresMigrations.js.map +1 -0
  96. package/dist/pinnedGroups.d.ts +22 -0
  97. package/dist/pinnedGroups.d.ts.map +1 -0
  98. package/dist/pinnedGroups.js +35 -0
  99. package/dist/pinnedGroups.js.map +1 -0
  100. package/dist/postgresChanges.d.ts +20 -0
  101. package/dist/postgresChanges.d.ts.map +1 -0
  102. package/dist/postgresChanges.js +26 -0
  103. package/dist/postgresChanges.js.map +1 -0
  104. package/dist/postgresRelease.d.ts +9 -0
  105. package/dist/postgresRelease.d.ts.map +1 -0
  106. package/dist/postgresRelease.js +39 -0
  107. package/dist/postgresRelease.js.map +1 -0
  108. package/dist/releaseWorkers.d.ts +8 -0
  109. package/dist/releaseWorkers.d.ts.map +1 -0
  110. package/dist/releaseWorkers.js +26 -0
  111. package/dist/releaseWorkers.js.map +1 -0
  112. package/dist/repository.d.ts +66 -0
  113. package/dist/repository.d.ts.map +1 -0
  114. package/dist/repository.js +43 -0
  115. package/dist/repository.js.map +1 -0
  116. package/dist/repositoryChanges.d.ts +9 -0
  117. package/dist/repositoryChanges.d.ts.map +1 -0
  118. package/dist/repositoryChanges.js +32 -0
  119. package/dist/repositoryChanges.js.map +1 -0
  120. package/dist/repositoryFilter.d.ts +43 -0
  121. package/dist/repositoryFilter.d.ts.map +1 -0
  122. package/dist/repositoryFilter.js +69 -0
  123. package/dist/repositoryFilter.js.map +1 -0
  124. package/dist/repositoryQueries.d.ts +26 -0
  125. package/dist/repositoryQueries.d.ts.map +1 -0
  126. package/dist/repositoryQueries.js +49 -0
  127. package/dist/repositoryQueries.js.map +1 -0
  128. package/dist/repositoryWrites.d.ts +18 -0
  129. package/dist/repositoryWrites.d.ts.map +1 -0
  130. package/dist/repositoryWrites.js +49 -0
  131. package/dist/repositoryWrites.js.map +1 -0
  132. package/dist/testing.d.ts +12 -0
  133. package/dist/testing.d.ts.map +1 -0
  134. package/dist/testing.js +29 -0
  135. package/dist/testing.js.map +1 -0
  136. package/dist/transact.d.ts +18 -0
  137. package/dist/transact.d.ts.map +1 -0
  138. package/dist/transact.js +43 -0
  139. package/dist/transact.js.map +1 -0
  140. package/dist/tupleIn.d.ts +19 -0
  141. package/dist/tupleIn.d.ts.map +1 -0
  142. package/dist/tupleIn.js +20 -0
  143. package/dist/tupleIn.js.map +1 -0
  144. package/dist/versionedRepository.d.ts +37 -0
  145. package/dist/versionedRepository.d.ts.map +1 -0
  146. package/dist/versionedRepository.js +63 -0
  147. package/dist/versionedRepository.js.map +1 -0
  148. package/dist/versionedStatements.d.ts +25 -0
  149. package/dist/versionedStatements.d.ts.map +1 -0
  150. package/dist/versionedStatements.js +75 -0
  151. package/dist/versionedStatements.js.map +1 -0
  152. package/package.json +71 -4
  153. package/src/SchemaComponent.ts +12 -0
  154. package/src/WorkerRelease.ts +38 -0
  155. package/src/advisoryXactLock.ts +17 -0
  156. package/src/aggregateColumn.ts +49 -0
  157. package/src/aggregateQuery.ts +57 -0
  158. package/src/assertPostgresMigrations.ts +24 -0
  159. package/src/batchWrites.ts +69 -0
  160. package/src/clientOptions.ts +16 -0
  161. package/src/compositeRepository.ts +101 -0
  162. package/src/conditionalUpsert.ts +97 -0
  163. package/src/conflictWrites.ts +93 -0
  164. package/src/coordinateWorkerRelease.ts +33 -0
  165. package/src/insertFromSelect.ts +47 -0
  166. package/src/latestPerGroup.ts +58 -0
  167. package/src/listenForChanges.ts +97 -0
  168. package/src/makeAggregate.ts +64 -0
  169. package/src/makeConflictClause.ts +53 -0
  170. package/src/makeQueryClauses.ts +36 -0
  171. package/src/migrationConvention.ts +2 -0
  172. package/src/migrations.ts +58 -0
  173. package/src/migrationsFromDirectory.ts +7 -0
  174. package/src/notifyPayload.ts +34 -0
  175. package/src/pendingPostgresMigrations.ts +42 -0
  176. package/src/pinnedGroups.ts +46 -0
  177. package/src/postgresChanges.ts +48 -0
  178. package/src/postgresRelease.ts +41 -0
  179. package/src/releaseWorkers.ts +32 -0
  180. package/src/repository.ts +147 -0
  181. package/src/repositoryChanges.ts +49 -0
  182. package/src/repositoryFilter.ts +108 -0
  183. package/src/repositoryQueries.ts +107 -0
  184. package/src/repositoryWrites.ts +70 -0
  185. package/src/testing.ts +38 -0
  186. package/src/transact.ts +70 -0
  187. package/src/tupleIn.ts +44 -0
  188. package/src/versionedRepository.ts +108 -0
  189. package/src/versionedStatements.ts +90 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,269 @@
1
+ # Changelog
2
+
3
+ ## 0.21.0 - 2026-10-25
4
+
5
+ ### Added
6
+
7
+ - Versioned repositories accept composite keys so a consumer app can keep ownership and version predicates in one atomic write. `OptimisticConcurrencyError.reason` distinguishes `missing` from `stale` under the full key without exposing stored row data.
8
+ - Versioned repositories with `conflictColumns` support `insertOrIgnore`, initializing the version to zero while leaving conflicting rows untouched. Unconditional upserts remain unavailable.
9
+ - Unversioned repositories accept `update(input, { onMissing: "fail" })` to return a typed `NoSuchElementError` when no row matches a single-column or composite key. Updates still decode the returned row and announce changes only after commit; missing rows announce nothing. Calls without the option retain their missing-row defect, and versioned repositories retain their typed optimistic concurrency failures.
10
+
11
+ ## 0.20.0 - 2026-10-25
12
+
13
+ ### Added
14
+
15
+ - `effect-sql` logs one lost warning per PostgreSQL listener outage and an info line after recovery, with `downtimeMs` since that warning and `streamCount` for the live streams resynchronized. Failed reconnect attempts log at debug. Initial successful startup logs neither outage line, and outage diagnostics omit database error causes and connection details.
16
+ - `effect-contract`'s `makeLiveServer.resync` reports the number of open live streams it marked for reconciliation, excluding streams whose scopes have closed.
17
+
18
+ ### Breaking
19
+
20
+ - Direct `postgresChanges` callers must supply `resync: Effect.Effect<number>` instead of `Effect.Effect<void>`. Pass `makeLiveServer.resync` unchanged, or return the number of open streams marked by your own stream owner.
21
+
22
+ ## 0.19.0 - 2026-10-25
23
+
24
+ ### Added
25
+
26
+ - Repositories run typed grouped aggregates with model-derived group columns, numeric and boolean summaries, filters, ordering and limits.
27
+ - effect-sql records the database release after successful migrations and coordinates worker drain with typed PostgreSQL heartbeat rows.
28
+ - effect-pg-boss pauses fetching while the database belongs to another release, finishes active jobs, and resumes when its release owns the database again.
29
+ - Platform migration options accept an optional `release` for deployment migration and worker readiness.
30
+ - Generated workers step aside for a newer release and drain on SIGTERM, with queue expiry, stop timeout and Railway draining configured together.
31
+
32
+ ### Changed
33
+
34
+ - `latestPerGroup` reads each pinned group through its index and stops after `limit` rows.
35
+
36
+ ## 0.18.0 - 2026-10-25
37
+
38
+ ### Added
39
+
40
+ - effect-contract item reads refresh on their collection-wide `<collection>:*` key, with live hints naming each affected subscribed item.
41
+ - `@shivaedev/effect-sql` exports `pendingPostgresMigrations` to read pending ledger migration IDs and names and schema component names and details.
42
+ - `@shivaedev/platform` logs migration wait start, periodic progress, completion and timeout through Effect's logger with pending migration and component annotations. `migrations.progressInterval` controls progress logging independently of polling and defaults to 30 seconds.
43
+
44
+ ### Changed
45
+
46
+ - `@shivaedev/create-app`'s starter worker uses the host's migration wait logs and keeps its job readiness line.
47
+
48
+ ### Breaking
49
+
50
+ - effect-sql writes returning more than 1,000 rows across all chunks of a single call announce `<table>` and `<table>:*` instead of item keys. Code registering raw `<table>:<id>` Reactivity keys outside effect-contract must also register `<table>:*`.
51
+
52
+ ## 0.17.0 - 2026-10-25
53
+
54
+ ### Added
55
+
56
+ - Repositories expose `count({ where })` with the same filters as `findMany`, returning a decoded number. Omit the filter to count every row; an empty table returns `0`.
57
+
58
+ ## 0.16.0 - 2026-10-25
59
+
60
+ ### Added
61
+
62
+ - PostgreSQL repository upserts accept a typed `updateWhere` filter, including `excluded` column comparisons, and return inserted, updated or unchanged outcomes. Conditional `upsertMany` returns one outcome per input in a single transaction, preventing stale sync revisions from overwriting newer rows.
63
+
64
+ ## 0.15.0 - 2026-10-25
65
+
66
+ ### Added
67
+
68
+ - Repository `findMany` and `select` filters accept typed `gt`, `gte`, `lt` and `lte` bounds, including UTC timestamps, and `like` text patterns, with runtime operand validation through model codecs.
69
+ - Match several model fields together with `tupleIn(model, fields, tuples)` in `findMany`, `select` and unversioned `delete` filters. Tuples use each field's decoded type and codec, combine with other filters, and bind large lists as parameters. An empty tuple list matches nothing.
70
+
71
+ ## 0.14.0 - 2026-10-25
72
+
73
+ ### Added
74
+
75
+ - Migration options accept schema components beside the numbered loader. Components apply after the ledger commits and report pending work through the same readiness check and host wait loop.
76
+ - `pgBossSchema` registers pg-boss installation and upgrades as a schema component, reporting the schema's installed and required versions.
77
+
78
+ ### Changed
79
+
80
+ - Generated apps migrate pg-boss through their migration list and start producers and workers with schema migration disabled.
81
+
82
+ ### Fixed
83
+
84
+ - Migration-step controllers capture schema-component services when constructed, keeping subsequent migration calls free of external service requirements.
85
+
86
+ ## 0.13.1 - 2026-10-24
87
+
88
+ ### Changed
89
+
90
+ - Require Effect and its companion packages at exactly 4.0.5. Generated applications use the same versions.
91
+
92
+ ## 0.13.0 - 2026-10-19
93
+
94
+ ### Added
95
+
96
+ - Repositories without a version column accept `delete(where: FindManyFilter<Model>)` with model-typed equality and `{ in: [...] }` filters alongside existing primary-key deletes. List values use field codecs, empty lists delete nothing, and deleted row keys are announced only after commit.
97
+
98
+ ## 0.12.0 - 2026-10-19
99
+
100
+ ### Added
101
+
102
+ - Repositories expose `latestPerGroup({ partitionBy, orderBy, limit, where })` to read up to N rows per group in one statement, with typed filters applied before ranking and Schema-decoded results. `LatestPerGroup` and the existing `OrderBy` type are exported from `repository.ts`; the ordered sort keys include the caller's stable tie-break column.
103
+ - `findMany` accepts a nonempty `orderBy` list of `{ field, direction }` entries, applying each in order to break ties with independently chosen directions. The single-object form and model field validation remain supported.
104
+
105
+ ## 0.11.0 - 2026-10-19
106
+
107
+ ### Added
108
+
109
+ - `findMany` and `select` accept model-typed `{ in: [...] }` filter entries alongside equality entries. Each list value uses its field codec, empty lists match no rows, and array field values retain equality semantics. The `FindManyFilter` type describes these query filters.
110
+
111
+ ## 0.10.0 - 2026-10-19
112
+
113
+ ### Added
114
+
115
+ - Repositories expose `select`, `insertFromSelect` and `insertFromSelectOrIgnore` to copy filtered projections into mapped target columns with compile-time name and type checks, Schema-decoded returned rows and transaction rollback. `RepositorySelect`, `InsertFromSelect` and `SelectWrites` describe the new query and write shapes; `makeInsertFromSelect` and `makeConflictClause` build their native SQL fragments.
116
+
117
+ ## 0.9.0 - 2026-10-19
118
+
119
+ ### Added
120
+
121
+ - `makeRepository` accepts `conflictWhere` alongside `conflictColumns` to target partial unique indexes for `insertOrIgnore`, `insertManyOrIgnore`, `upsert` and `upsertMany`. Predicates use the existing typed equality filter, encode decoded field values and bind parameters; unmatched indexes fail with native `SqlError`.
122
+ - `repositoryFilter.ts` exports the shared `RepositoryFilter` type and `makeFilter` builder used by query and conflict predicates.
123
+
124
+ ## 0.8.1 - 2026-10-19
125
+
126
+ ### Fixed
127
+
128
+ - Repository writes to a table whose composite key includes a `bigint` column no longer fail with "Do not know how to serialize a BigInt"; their item keys encode each `bigint` key value as its decimal string, the same way a single-column `bigint` key is encoded.
129
+
130
+ ## 0.8.0 - 2026-10-19
131
+
132
+ ### Added
133
+
134
+ - `advisoryXactLock(key: bigint | string)` takes a PostgreSQL transaction-scoped advisory lock inside `transact`, with string keys hashed by `hashtextextended(key, 0)`. `AdvisoryLockOutsideTransaction` is the typed failure when no transaction is active. `migratePostgres` uses the same lock function.
135
+
136
+ ## 0.7.0 - 2026-10-18
137
+
138
+ ### Added
139
+
140
+ - Repository insert, update, delete, conflict and batch writes record the table key and returned row item keys through the existing commit channel, including generated IDs and void writes. Transactions deduplicate keys and discard rolled-back writes.
141
+ - PostgreSQL migration batches own the same commit boundary, so repository seed and upgrade writes announce after the batch commits.
142
+ - Low-level composition exposes `repositoryChanges(sql, table, columns)`, `RepositoryChanges`, and `repositoryWrites(model, sql, options, changes)`.
143
+ - `testing.ts` exports `withChangeCoverage(body)` and `UnannouncedWrites`; PostgreSQL transaction statistics catch tables written without a recorded table key. `transact.ts` exports `ChangeObserver` for observing that channel.
144
+
145
+ ### Breaking
146
+
147
+ - Repository writes now open their own `transact` boundary. Use `transact` for an enclosing transaction instead of bare `sql.withTransaction`, and remove explicit invalidations for repository table/item keys. Keep explicit invalidations for derived keys. Standalone batch calls now roll back all chunks together. Direct callers of `makeInsertMany`, `makeConflictWrites` or `makeVersionedWrites` must supply `options.changes` from `repositoryChanges`, or use `makeRepository`.
148
+
149
+ ## 0.6.0 - 2026-10-18
150
+
151
+ ### Added
152
+
153
+ - effect-sql exports `MIGRATIONS_DIRECTORY` and `MIGRATION_FILE_PATTERN` from `migrationConvention.ts`, and `migrationsFromDirectory(root)` to discover the app's sequentially numbered migration files with Effect's filesystem loader.
154
+ - create-app ships the starter's discovered `src/server/migrations/` folder and validates its zero-padded sequential filenames when packing the template.
155
+ - effect-sql exports `clientOptions(options, { snakeCase? })` and `SqlNameTransforms` from `clientOptions.ts`. New clients configured with this helper use Effect SQL's native camelCase-to-snake_case query names and snake_case-to-camelCase results by default. Pass `{ snakeCase: false }` to preserve native names, or supply native transform functions in the options.
156
+ - Platform's app database and app host configuration accept native `transformQueryNames` and `transformResultNames`, so applications can use effect-sql's client options without replacing the host's database layer.
157
+
158
+ ### Changed
159
+
160
+ - Newly generated applications configure snake_case SQL columns through effect-sql. The starter migrates existing note ownership and word-count columns while retaining camelCase model fields.
161
+
162
+ ## 0.5.2 - 2026-10-18
163
+
164
+ ### Changed
165
+
166
+ - `migratePostgres` rejects loaded migration IDs at or below the latest applied ID that are missing from the ledger with a typed native `MigrationError` (`kind: "BadState"`) naming those IDs; a deployment that relied on silently skipping them now fails. Migrations run in ID order, including with a custom loader.
167
+
168
+ ## 0.5.1 - 2026-10-18
169
+
170
+ ### Fixed
171
+
172
+ - Align published framework dependencies with the current releases.
173
+
174
+ ## 0.5.0 - 2026-10-17
175
+
176
+ ### Added
177
+
178
+ - Unversioned repositories expose `insertMany(inputs)`. Repositories declaring `conflictColumns` also expose `insertManyOrIgnore(inputs)` and `upsertMany(inputs, { updateColumns })`, with model-derived insert inputs, decoded model arrays, bounded SQL chunks and caller-owned native transactions. Empty batches return an empty array without writing.
179
+ - `assertPostgresMigrations({ loader, table? })` in `assertPostgresMigrations.ts` verifies required migration IDs and names in the native ledger without executing migrations or creating a ledger. Missing or pending migrations fail with native `MigrationError` (`kind: "BadState"`); later ledger entries are allowed for rolling deployments.
180
+
181
+ ## 0.4.0 - 2026-10-16
182
+
183
+ ### Added
184
+
185
+ - `makeRepository` accepts a composite `idColumn` tuple; `findById` and `delete` accept the full key object, and updates match every key column through the model's codecs.
186
+ - Unversioned repositories with declared `conflictColumns` expose `insertOrIgnore(input)` returning an optional decoded model and `upsert(input, { updateColumns })` returning the inserted or updated model. Inputs use the model's insert schema, selected update columns exclude primary and conflict keys, and writes participate in native transactions. PostgreSQL tests cover these paths.
187
+
188
+ ## 0.3.0 - 2026-10-13
189
+
190
+ ### Changed
191
+
192
+ - A failed `COMMIT` inside `transact` fails with a typed `SqlError` mapped through `onSqlError` instead of a defect.
193
+
194
+ ### Breaking
195
+
196
+ - Requires stable Effect 4.0.4 in place of 4.0.0-rc.112. Effect 4.0.4 moves the former `effect/unstable/*` modules to `effect/*` and renames constructors such as `Config.string` to `Config.String`. Install `@effect/sql-pg` 4.0.4 alongside it, whose native PostgreSQL client replaces `pg`.
197
+ - `PostgresChangeClient.listen` returns a scoped `Queue` of notifications, matching `PgClient.listen` in `@effect/sql-pg` 4.0.4.
198
+ - JSON and JSONB columns are not supported. A repository write of a plain object to one fails with `SqlError`; give structured data its own columns or table.
199
+ - PostgreSQL `int8` values read as `bigint` (use `Schema.BigInt`), `date` values read as `YYYY-MM-DD` strings, and `timestamp without time zone` values are read and written as UTC wall time.
200
+
201
+ ## 0.2.1 - 2026-10-12
202
+
203
+ ### Added
204
+
205
+ - Repositories accept an optional `versionColumn`: inserts initialize it to zero, updates match the expected version and increment it atomically, and deletes require the expected version. Stale or missing rows fail with typed `OptimisticConcurrencyError`; returned updated models carry the new version. PostgreSQL tests cover concurrent writers, versioned deletion and void writes. Unversioned repositories retain native CRUD behavior.
206
+ - `postgresChanges` in `postgresChanges.ts` binds `transact` to PostgreSQL LISTEN/NOTIFY using the writing transaction's SQL client. Each process delivers committed string or finite-number invalidation keys into local Reactivity. Rollback sends no notification.
207
+ - The scoped listener uses a heartbeat to detect silent connection loss, resyncs live streams before cleanup on loss and again on recovery, and retries with a fresh subscription. Each native listener finalizer is bounded by `heartbeatTimeout`, so a stalled UNLISTEN does not block connection release, retry or process scope shutdown. UTF-8 payloads are split below PostgreSQL's 8,000-byte NOTIFY limit; an oversized individual key or unsupported key rolls back the transaction.
208
+ - `BeforeCommit` and `CommittedSink` in `transact.ts` expose the SQL channel's binding seams.
209
+
210
+ ### Changed
211
+
212
+ - Give the package an agent north star, a model-to-query usage guide, and dedicated north-star and roadmap docs; publish `docs/` alongside the README while keeping agent instructions out of npm.
213
+ - Build package JavaScript, declarations and source maps with TypeScript 7.
214
+
215
+ ## 0.2.0 - 2026-10-04
216
+
217
+ ### Changed
218
+
219
+ - Breaking: no root entry and no module that re-exports another. `exports` maps one `"./*.ts"` pattern to every module (`src` under the `source` condition, `dist` otherwise), so you import the module that defines a name, and a bundler sees only the modules you use. Where each name now lives:
220
+ - `@shivaedev/effect-sql`: `@shivaedev/effect-sql/repository.ts` (`FindMany`, `makeRepository`), `@shivaedev/effect-sql/transact.ts` (`InvalidationKeys`, `TransactOptions`, `invalidateOnCommit`, `transact`), `@shivaedev/effect-sql/migrations.ts` (`PostgresMigrationOptions`, `migratePostgres`)
221
+ - `makeRepository` and `FindMany` moved out of the deleted entry file into `repository.ts`.
222
+
223
+ ## 0.1.1 - 2026-10-04
224
+
225
+ ### Changed
226
+
227
+ - Imports that leave their folder go through `#` aliases declared in the `imports` field of `package.json`: `#*.ts` resolves to `src` under the `source` condition and to `dist` otherwise, and `#test/*` names a test file. The published modules and declarations name the package's own files through these aliases.
228
+
229
+ - Consolidate duplicate test cases around observable package behavior.
230
+
231
+ - Validate packed consumers and executable bins through the shared workspace gate.
232
+
233
+ - Build with the `@shivaedev/quality` tsconfig presets, which target ESNext and allow only erasable TypeScript syntax.
234
+
235
+ - Type-check with TypeScript 7 only. TypeScript 6 still builds the package.
236
+
237
+ - Lint and format with the `@shivaedev/quality` Biome preset through `quality lint` at the repository root, which replaces the package's `check` script.
238
+
239
+ - Run tests through the `@shivaedev/quality` Vitest projects, which take a test's environment from its file name. Type tests are named `*.typecheck.test.ts`.
240
+
241
+ - Keep `package.json` in sort-package-json key order, checked by `quality lint`.
242
+
243
+ ## 0.1.0 - 2026-09-26
244
+
245
+ ### Added
246
+
247
+ - Add native Effect model repositories with schema-derived equality filters,
248
+ selected result decoding, ordering and limits.
249
+ - Treat `undefined` filter values as unconstrained and fail with `SchemaError`
250
+ for field names outside the model.
251
+ - Add `transact` and `invalidateOnCommit`, built on `@shivaedev/effect-changes`:
252
+ native transactions with mapped SQL errors and Reactivity invalidation only
253
+ after the outermost commit.
254
+ - Keep one invalidation set per `SqlClient`: `invalidateOnCommit` marks the set
255
+ of its own `SqlClient`, a transaction on another database nested inside
256
+ `transact` announces its own commit, and a `transact` re-entered on a database
257
+ with an open outer transaction joins it as a savepoint.
258
+ - Die when `invalidateOnCommit` runs after its transaction finished instead of
259
+ dropping the keys, and when `transact` or `invalidateOnCommit` runs inside a
260
+ native transaction that `transact` did not begin.
261
+ - Log an invalidation that fails after `COMMIT`, for example a Reactivity
262
+ subscriber that throws, as an error and return the committed result, so
263
+ callers do not retry writes that already landed. The same applies to
264
+ `invalidateOnCommit` outside a transaction.
265
+ - Announce the keys when a caller is interrupted while `COMMIT` is in flight and
266
+ the database committed.
267
+ - Add `migratePostgres`: run Effect SQL migrations under a transaction-scoped
268
+ advisory lock with a required `lockTimeout`. An infinite `lockTimeout` becomes
269
+ PostgreSQL's `lock_timeout = 0` (no timeout).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ShivaeDev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.