@confect/react 10.0.0-next.9 → 10.0.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.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,682 @@
1
1
  # @confect/react
2
2
 
3
+ ## 10.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - c05ae0b: Migrate Confect to Effect 4, add middleware, experimental composable query streams, Foldkit bindings, and Convex AI gateway integrations. This release requires changes to function argument declarations, HTTP routers, runner calls, and test setup when upgrading from v9.
8
+
9
+ ### Requirements
10
+ - All Confect packages require Node.js 24 or later and `effect ^4.0.0`.
11
+ - `@confect/server` requires `convex ^1.45.0`.
12
+ - `@confect/server`'s optional `@effect/platform-node` peer requires `^4.0.0` for Node actions.
13
+ - The new `@confect/foldkit` package requires `foldkit ^0.165.0`.
14
+
15
+ Confect no longer depends on `@effect/platform` or `@effect/cli`. Run `confect codegen` to regenerate the v10 bindings after updating your Confect declarations.
16
+
17
+ ### Breaking changes
18
+
19
+ #### Declare function arguments as lazy field maps
20
+
21
+ Pass a callback returning the fields of an argument object, rather than a callback returning `Schema.Struct`. This applies to queries, mutations, actions, and paginated queries. You can omit `args` when a function takes no arguments; Confect supplies an empty object. Keep `returns`, `item`, and `error` as callbacks returning schemas.
22
+
23
+ **Before:**
24
+
25
+ ```ts
26
+ import { FunctionSpec } from "@confect/core";
27
+ import * as Schema from "effect/Schema";
28
+
29
+ FunctionSpec.publicQuery({
30
+ name: "greet",
31
+ args: () => Schema.Struct({ name: Schema.String }),
32
+ returns: () => Schema.String,
33
+ });
34
+ ```
35
+
36
+ **After:**
37
+
38
+ ```ts
39
+ import { FunctionSpec } from "@confect/core";
40
+ import * as Schema from "effect/Schema";
41
+
42
+ FunctionSpec.publicQuery({
43
+ name: "greet",
44
+ args: () => ({ name: Schema.String }),
45
+ returns: () => Schema.String,
46
+ });
47
+ ```
48
+
49
+ #### Keep table declarations client-safe
50
+
51
+ Import `Table` from `@confect/core` in your table declarations. Specs can then return a generated table's `Doc` without pulling server code into the client. `confect codegen` rejects value imports of `@confect/server` anywhere reachable from a spec, including table and generated modules. Type-only imports remain allowed.
52
+
53
+ **Before:**
54
+
55
+ ```ts
56
+ import { Table } from "@confect/server";
57
+ import * as Schema from "effect/Schema";
58
+
59
+ export default Table.make(() => Schema.Struct({ text: Schema.String }));
60
+ ```
61
+
62
+ **After:**
63
+
64
+ ```ts
65
+ import { Table } from "@confect/core";
66
+ import * as Schema from "effect/Schema";
67
+
68
+ export default Table.make(() => Schema.Struct({ text: Schema.String }));
69
+ ```
70
+
71
+ Table declarations still return a schema, not the field maps now used by function arguments. The server's `Table` re-exports remain available for server-only use. Run `confect codegen` to regenerate the deploy schema and client-safe table bindings.
72
+
73
+ #### Use serializable schemas and handle updated errors
74
+
75
+ Confect function schemas must encode to Convex values. Use a serializable codec such as `Schema.OptionFromNullOr(...)` for an `Option` crossing that boundary: `Schema.Option` no longer provides the serialized representation expected there.
76
+
77
+ Table schemas support object-shaped transformations, encoded-key mappings, brands, suspended schemas, and unions of those schemas while retaining Convex system fields. Every step must remain object-shaped; class schemas such as `Schema.Class` are not valid table schemas.
78
+
79
+ Decode failures now use `Schema.SchemaError` instead of `ParseError`, including JavaScript clients, React hooks, and test helpers. React `useMutation` and `useAction` calls with declared errors return Effect `Result` values instead of `Either` values. Update matching and error annotations accordingly.
80
+
81
+ #### Replace HTTP API mounts with route layers
82
+
83
+ Replace Confect's `HttpApi.make` with `HttpRouter.make`. The old record of path prefixes and `apiLive`, `middleware`, and `scalar` options is replaced by one layer registering all routes. Build API routes with Effect's `HttpApiBuilder.layer`, provide each group's handlers, and add Scalar documentation explicitly.
84
+
85
+ For an API named `Api` and its group handler layer `ApiLive`:
86
+
87
+ **Before:**
88
+
89
+ ```ts
90
+ import { HttpApi as ConfectHttpApi } from "@confect/server";
91
+ import * as HttpApiBuilder from "@effect/platform/HttpApiBuilder";
92
+ import * as Layer from "effect/Layer";
93
+
94
+ export default ConfectHttpApi.make({
95
+ "/api/": {
96
+ apiLive: HttpApiBuilder.api(Api).pipe(Layer.provide(ApiLive)),
97
+ },
98
+ });
99
+ ```
100
+
101
+ **After:**
102
+
103
+ ```ts
104
+ import { HttpRouter as ConfectHttpRouter } from "@confect/server";
105
+ import * as Layer from "effect/Layer";
106
+ import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
107
+ import * as HttpApiScalar from "effect/http-api/HttpApiScalar";
108
+
109
+ export default ConfectHttpRouter.make(
110
+ Layer.mergeAll(
111
+ HttpApiBuilder.layer(Api).pipe(Layer.provide(ApiLive)),
112
+ HttpApiScalar.layer(Api, { path: "/api/docs" }),
113
+ ),
114
+ );
115
+ ```
116
+
117
+ Put the endpoint prefix on the Effect API itself, for example with `.prefix("/api")`. For interactive documentation, configure Scalar's `baseServerURL` with your deployment's site URL. Missing API handler groups are compile-time errors. You can merge plain routes from `effect/http/HttpRouter.add` and global middleware from `HttpRouter.middleware` into the same layer.
118
+
119
+ The returned Convex router serves Effect routes through a catch-all at `/`; plain Convex routes added to it still take precedence. Route-layer construction, handlers, and middleware can read Convex environment variables through Confect's configuration provider.
120
+
121
+ #### Call named runner methods
122
+
123
+ `QueryRunner`, `MutationRunner`, and `ActionRunner` are no longer callable services. Destructure `runQuery`, `runMutation`, or `runAction` instead.
124
+
125
+ **Before:**
126
+
127
+ ```ts
128
+ import * as Effect from "effect/Effect";
129
+
130
+ const firstNote = Effect.gen(function* () {
131
+ const runQuery = yield* QueryRunner;
132
+ return yield* runQuery(refs.public.notes.getFirst, {});
133
+ });
134
+ ```
135
+
136
+ **After:**
137
+
138
+ ```ts
139
+ import * as Effect from "effect/Effect";
140
+
141
+ const firstNote = Effect.gen(function* () {
142
+ const { runQuery } = yield* QueryRunner;
143
+ return yield* runQuery(refs.public.notes.getFirst, {});
144
+ });
145
+ ```
146
+
147
+ Runner availability is unchanged. Inside queries or mutations, `runQuery` also accepts a third argument such as `{ transactionLimits: { documentsRead: 100 } }`. Inside mutations, `runMutation` accepts limits such as `{ transactionLimits: { documentsWritten: 10 } }`, and `runQuery` can request `useStaleSnapshot`. Supplying `useStaleSnapshot` requires a mutation context even when it is `false`. Actions and HTTP handlers use runners without transaction options; `runAction` has no options argument.
148
+
149
+ #### Yield upload URL generation directly
150
+
151
+ `StorageWriter.generateUploadUrl` is an Effect value instead of a zero-argument function.
152
+
153
+ **Before:**
154
+
155
+ ```ts
156
+ import * as Effect from "effect/Effect";
157
+
158
+ const uploadUrl = Effect.gen(function* () {
159
+ const storage = yield* StorageWriter;
160
+ return yield* storage.generateUploadUrl();
161
+ });
162
+ ```
163
+
164
+ **After:**
165
+
166
+ ```ts
167
+ import * as Effect from "effect/Effect";
168
+
169
+ const uploadUrl = Effect.gen(function* () {
170
+ const storage = yield* StorageWriter;
171
+ return yield* storage.generateUploadUrl;
172
+ });
173
+ ```
174
+
175
+ Methods that take arguments, such as `delete(storageId)`, remain functions.
176
+
177
+ #### Provide test layers without an extra call
178
+
179
+ `TestConfect.layer(schema, convexSchema, modules)` now returns a layer directly instead of a function returning that layer. For a project that exports the result as `TestConfect.layer`:
180
+
181
+ **Before:**
182
+
183
+ ```ts
184
+ const test = testEffect.pipe(Effect.provide(TestConfect.layer()));
185
+ ```
186
+
187
+ **After:**
188
+
189
+ ```ts
190
+ const test = testEffect.pipe(Effect.provide(TestConfect.layer));
191
+ ```
192
+
193
+ Each separate provision still creates a fresh test database.
194
+
195
+ #### Update handwritten container annotations
196
+
197
+ Read assembled groups with `Spec.groups(spec)` instead of `spec.groups`, and tables with `DatabaseSchema.tables(schema)` instead of `schema.tables`. Explicit `Spec.Spec`, `DatabaseSchema.DatabaseSchema`, and `DataModel.DataModel` annotations now take a record keyed by name rather than a union of members.
198
+
199
+ **Before:**
200
+
201
+ ```ts
202
+ type AppSpec = Spec.Spec<typeof notesGroup>;
203
+ type AppSchema = DatabaseSchema.DatabaseSchema<typeof notesTable>;
204
+ type AppDataModel = DataModel.DataModel<typeof notesTable>;
205
+ ```
206
+
207
+ **After:**
208
+
209
+ ```ts
210
+ type AppSpec = Spec.Spec<{ readonly notes: typeof notesGroup }>;
211
+ type AppSchema = DatabaseSchema.DatabaseSchema<{
212
+ readonly notes: typeof notesTable;
213
+ }>;
214
+ type AppDataModel = DataModel.DataModel<{
215
+ readonly notes: typeof notesTable;
216
+ }>;
217
+ ```
218
+
219
+ Ordinary builder calls are unchanged, and `DataModel.FromTables` still accepts a table union. Adding a group under an existing name replaces both its value and its inferred type. Run `confect codegen` rather than editing generated annotations.
220
+
221
+ #### Review configuration and time-dependent queries
222
+
223
+ Confect's configuration provider now treats empty-string environment variables as missing values, so `Config.withDefault` and `Config.option` recover from them.
224
+
225
+ Raw `Date.now()` calls in queries now observe time and invalidate Convex's query cache instead of returning v9's globally stubbed value. Explicit Effect clock reads such as `Clock.currentTimeMillis` and `Clock.currentTimeNanos` continue to opt into time tracking. Effect's internal timestamps for logging and tracing do not invalidate the cache.
226
+
227
+ ### Middleware with typed services and errors
228
+
229
+ Add reusable policies in `confect/middleware/`, with a client-safe `<Name>.spec.ts` and a server-side `<Name>.impl.ts`. This directory is reserved and can no longer contain ordinary function groups.
230
+
231
+ Declare a policy with `MiddlewareSpec.MiddlewareSpec`, including its provided services, error schema, and explicit query/mutation/action coverage. Attach it with `.middleware(Policy)` on a group or individual function, or declare an `options` schema and use `.middleware(Policy, options)`. Options are validated without coercion and must be client-safe because generated refs carry them.
232
+
233
+ Implement policies with `MiddlewareImpl.make`, `MiddlewareImpl.makeByFunctionType`, or `MiddlewareImpl.provides`, then supply the implementation to the group layer. Callbacks receive `{ invocation }`, plus `options` when declared. Policies run after argument decoding, with group policies before function policies, and can supply services to later policies and handlers. Typed policy failures reach clients alongside function errors and short-circuit the remaining chain.
234
+
235
+ The same policy can run more than once with different options; equivalent attachments are rejected. Coverage and service dependencies are checked, missing implementations fail codegen, middleware does not propagate to subgroups, and plain Convex functions cannot have Confect middleware attached.
236
+
237
+ ### Experimental composable query streams
238
+
239
+ Use `reader.table(...).stream(index, range?, order?)` and `QueryStream` from `@confect/server` to merge, filter, map, join, deduplicate, narrow, and reverse indexed queries while retaining cursor pagination. Ordering compatibility is checked, joins can provide left-join placeholders, effectful filters and maps support ordered concurrency, and reversing a distinct stream preserves its selected representatives.
240
+
241
+ ```ts
242
+ import { QueryStream } from "@confect/server";
243
+ import * as Effect from "effect/Effect";
244
+
245
+ const firstPage = Effect.gen(function* () {
246
+ const reader = yield* DatabaseReader;
247
+ const stream = reader.table("notes").stream("by_creation_time");
248
+ return yield* QueryStream.paginate(stream, {
249
+ cursor: null,
250
+ numItems: 20,
251
+ maximumRowsRead: 1000,
252
+ });
253
+ });
254
+ ```
255
+
256
+ Read budgets count underlying reads, including documents filtered out of the result; byte budgets are estimates. Invalid page sizes and read limits are rejected before reads. If a budget prevents safe progress or splitting, pagination fails rather than skipping results. Increase the budget or reduce the query's read requirements.
257
+
258
+ Use React's new `useStreamPaginatedQuery` for stream-backed paginated queries. It pins loaded page ranges, handles page splits, and restarts on invalid cursors. Foldkit pagination also preserves page ranges during navigation. Ordinary paginated queries and `usePaginatedQuery` remain available.
259
+
260
+ All `QueryStream` APIs are experimental. Treat cursors as opaque continuation values, but do not treat them as confidential: they expose order-key values. Avoid public pagination over sensitive indexed fields unless those fields are fixed with `eq`.
261
+
262
+ ### Foldkit client bindings
263
+
264
+ Add `@confect/foldkit` for Foldkit applications. `Client.layer` provides the scoped client; `Command.query`, `Command.mutation`, and `Command.action` turn Confect calls into commands with declared messages and required success/error handlers. The factories support Foldkit interruption, and the corresponding `queryEffect`, `mutationEffect`, and `actionEffect` helpers support handwritten command definitions.
265
+
266
+ `Subscription.reactiveQuery` follows optional arguments derived from your model and manages the live query subscription. `PaginatedQuery` and `Subscription.paginatedQuery` provide reactive next/previous-page navigation, preserve the last complete page while refreshing, ignore superseded settlements, and recover from invalid cursors. Failed refreshes retain stale data, and typed function errors remain available to your message handlers.
267
+
268
+ ### Convex AI gateway models
269
+
270
+ Use `AiGatewayLanguageClient` and `AiGatewayLanguageModel` to call language models through the Convex AI gateway from actions without supplying provider API keys. Use `AiGatewayDecisionClient` and `AiGatewayDecisionModel` with Effect's `DecisionModel` to classify inputs, apply rubrics, and estimate probabilities.
271
+
272
+ ```ts
273
+ import {
274
+ AiGatewayLanguageClient,
275
+ AiGatewayLanguageModel,
276
+ } from "@confect/server";
277
+ import * as Layer from "effect/Layer";
278
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
279
+
280
+ const Claude = AiGatewayLanguageModel.model(
281
+ "anthropic/claude-sonnet-4.5",
282
+ ).pipe(
283
+ Layer.provide(AiGatewayLanguageClient.layer),
284
+ Layer.provide(FetchHttpClient.layer),
285
+ );
286
+ ```
287
+
288
+ Provide the model to Effect AI operations from `effect/ai`. Disabled or unavailable gateways report typed errors during client construction. Both gateway clients obtain current service credentials before each request, including when reused in long-running actions.
289
+
290
+ ### Storage, metadata, logging, and authentication
291
+ - Use the unified generated `Storage` service for download URLs, upload URLs, deletion, blob reads, and blob writes. Each operation retains its context restrictions; the existing storage services remain supported.
292
+ - Cancel scheduled functions with `Scheduler.cancel(id)`, using the ID returned by `runAfter` or `runAt`.
293
+ - Read function and deployment information with `ExecutionMetadata`, request information with `RequestMetadata`, and transaction metrics with `TransactionMetadata`. Generated services expose them only in the contexts that support each capability.
294
+ - `Effect.log*` output uses matching Convex severities in functions and HTTP routes while preserving Effect metadata and custom loggers. `ConvexLogger` is available for explicit configuration, and logs remain associated with the current invocation when Node actions reuse a process.
295
+ - JavaScript `WebSocketClient` and Foldkit `Client` authentication callbacks can require Effect services. Supply them when running `setAuth` and keep scoped dependencies alive while authentication is registered; later token refreshes use the supplied services.
296
+ - JavaScript clients support per-module imports such as `@confect/js/WebSocketClient` and `@confect/js/HttpClient`; root imports are unchanged.
297
+
298
+ ### Fixes and diagnostics
299
+ - Preserve precise function error types when `exactOptionalPropertyTypes` is disabled, rather than widening functions without declared errors to `any`.
300
+ - Exclude `_id` and `_creationTime` from patch value types derived from full documents.
301
+ - Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect.
302
+ - Reject non-finite values in Confect's schemas for system timestamps, stored file sizes, and pagination options. User-authored `Schema.Number` fields can still represent Convex's non-finite numbers.
303
+ - Keep queries, mutations, and module initialization compatible with Convex's timer restrictions during long Effect computations.
304
+ - Fail codegen with a descriptive error for malformed `convex.json` instead of silently ignoring it.
305
+ - Add tracing spans for client calls, server functions, database writes and pagination, stream consumers, and code-generation passes.
306
+
307
+ ## 10.0.0-next.27
308
+
309
+ ### Minor Changes
310
+
311
+ - 6424f03: Require stable `effect@^4.0.0` and matching Effect platform and AI provider packages. `@confect/foldkit` now requires `foldkit@^0.165.0`, which supports Effect 4.0.0 without a peer-dependency override.
312
+
313
+ ## 10.0.0-next.26
314
+
315
+ No changes in this release.
316
+
317
+ ## 10.0.0-next.25
318
+
319
+ ### Patch Changes
320
+
321
+ - f9958b9: Require `effect@^4.0.0-rc.118` and matching Effect platform packages. Upgrade Effect alongside Confect and replace `effect/unstable/*` imports with `effect/*`, using `effect/http-api` for HTTP API imports.
322
+
323
+ ## 10.0.0-next.24
324
+
325
+ ### Patch Changes
326
+
327
+ - 850a3c3: Require `effect@^4.0.0-rc.117` across `@confect/*` and `@effect/platform-node@^4.0.0-rc.117` for `@confect/server`'s optional Node integration. Upgrade these dependencies alongside Confect; existing Confect call sites are unchanged.
328
+
329
+ ## 10.0.0-next.23
330
+
331
+ No changes in this release.
332
+
333
+ ## 10.0.0-next.22
334
+
335
+ ### Minor Changes
336
+
337
+ - 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
338
+
339
+ ### Stream queries and pagination
340
+
341
+ Create composable Effect streams with `reader.table(...).stream(index, range?, order?)` and `QueryStream` from `@confect/server`. Merge, filter, map, join, deduplicate, narrow, and reverse queries without losing cursor pagination. Order keys and directions are checked by the type system. Joins support left-join placeholders through `onEmpty`, and effectful filters and maps support ordered concurrency. Reversing a distinct stream preserves its chosen representatives.
342
+
343
+ `QueryStream.paginate` resumes from indexed cursor bounds and supports pinned page ranges, automatic split recommendations, and `maximumRowsRead`/`maximumBytesRead` budgets that count underlying query-stream reads, including filtered documents. Byte counts are estimates. If a budget prevents safe progress or splitting, pagination fails with `ReadBudgetExceededError`; increase the budget or reduce the query's read requirements.
344
+
345
+ Use React's new `useStreamPaginatedQuery` for these queries:
346
+
347
+ ```ts
348
+ import { useStreamPaginatedQuery } from "@confect/react";
349
+
350
+ const { results, status, loadMore } = useStreamPaginatedQuery(
351
+ refs.public.notes.feed,
352
+ {},
353
+ {
354
+ initialNumItems: 10,
355
+ maximumRowsRead: 1000,
356
+ maximumBytesRead: 512 * 1024,
357
+ },
358
+ );
359
+ ```
360
+
361
+ The hook pins loaded pages to fixed ranges, splits oversized or budget-limited pages, and restarts pagination on invalid cursors. Foldkit's `PaginatedQuery` also supports stream queries and preserves page ranges when navigating back and forward, avoiding skipped or repeated documents as data changes.
362
+
363
+ Stream cursors expose their order-key values. Do not paginate publicly over sensitive indexed fields unless they are pinned with `eq`. All `QueryStream` APIs are experimental.
364
+
365
+ ### Middleware options
366
+
367
+ Declare a lazy `options` schema on `MiddlewareSpec.MiddlewareSpec`, then pass typed values with `.middleware(Policy, options)` on functions or groups. Options are validated without coercion during codegen and server registration; keep schemas and values client-safe because generated refs carry them.
368
+
369
+ The same policy can be attached repeatedly with non-equivalent options. Every attachment runs, with group policies before function policies. Equivalent options and duplicate policies without options are rejected. Register implementations against the same spec used for attachments.
370
+
371
+ ### Breaking changes
372
+
373
+ Middleware callbacks passed to `MiddlewareImpl.make` or `MiddlewareImpl.makeByFunctionType` receive invocation metadata under `invocation`. To migrate, nest destructuring of `name`, `functionType`, `functionVisibility`, and decoded `args`:
374
+
375
+ **Before:**
376
+
377
+ ```ts
378
+ (effect, { name, args }) => effect;
379
+ ```
380
+
381
+ **After:**
382
+
383
+ ```ts
384
+ (effect, { invocation: { name, args } }) => effect;
385
+ ```
386
+
387
+ Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
388
+
389
+ ### Fixes and tracing
390
+ - Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
391
+ - Add named tracing spans for JavaScript client calls, server function execution, database writes and pagination, `QueryStream.unique`/`QueryStream.paginate`, and `confect codegen`/`confect dev` code-generation passes.
392
+
393
+ ### Patch Changes
394
+
395
+ - 9f4e2c0: Require `effect@^4.0.0-rc.113` across `@confect/*` and raise `@confect/server`'s optional `@effect/platform-node` peer to the same range. Upgrade Effect alongside Confect; existing Confect call sites are unchanged.
396
+
397
+ Effect's own APIs include breaking renames: use `Config.String` instead of `Config.string`, and `LanguageModel.LanguageModel` instead of `LanguageModel.Service` when annotating the result of `AiGatewayLanguageModel.make`. See the [Effect RC 113 release notes](https://github.com/Effect-TS/effect/releases/tag/effect%404.0.0-rc.113) for the complete migration guidance.
398
+
399
+ - 90c80e9: Require `effect@^4.0.0-rc.115` across `@confect/*` and `@effect/platform-node@^4.0.0-rc.115` when using `@confect/server`'s optional Node integration. Upgrade these dependencies alongside Confect; existing Confect call sites are unchanged.
400
+ - f721d2c: Remove spaces around em dashes and separator slashes in API documentation and `confect codegen` diagnostics.
401
+
402
+ ## 10.0.0-next.21
403
+
404
+ ### Major Changes
405
+
406
+ - a6425c5: Raise the minimum supported Node.js version to 24.
407
+
408
+ ### Breaking Changes
409
+ - `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
410
+
411
+ Node 22 has entered maintenance, so Confect now targets Node 24, the active LTS line. To migrate, move the Node version your project builds and runs on to 24 or later—on Node 22, installing `@confect/*` now fails your package manager's engine check. No API changes accompany the raise: code already running on Node 24 needs no edits.
412
+
413
+ ## 10.0.0-next.20
414
+
415
+ ## 10.0.0-next.19
416
+
417
+ ## 10.0.0-next.18
418
+
419
+ ## 10.0.0-next.17
420
+
421
+ ### Patch Changes
422
+
423
+ - 8e4962e: Raise the required `effect` peer version to `^4.0.0-rc.111` (from `^4.0.0-rc.110`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
424
+
425
+ No Confect API changed, and no call-site edits are needed. `rc.111` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
426
+
427
+ ## 10.0.0-next.16
428
+
429
+ ### Major Changes
430
+
431
+ - Migrate to Effect v4. All `@confect/*` packages now require `effect@^4.0.0-beta.97`; `@effect/platform` and `@effect/cli` are no longer dependencies (their functionality moved into `effect` core and `effect/unstable/*`).
432
+
433
+ Breaking changes for users:
434
+
435
+ - **Schemas** follow Effect v4's Schema API: `Schema.Union([a, b])` (array form), `Schema.Literals([...])` for literal unions, `Schema.optionalKey` in place of `optionalWith({ exact: true })`, and checks like `Schema.String.check(Schema.isMaxLength(...))` in place of piped filters.
436
+ - **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)`—v4's `Schema.Option` encodes to an `Option` instance, which is not a Convex value.
437
+ - **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these—Convex's system fields are carried through the whole encoding chain. Schemas that do not resolve to an object shape at every step (such as `Schema.Class`) are rejected with a descriptive error when the table is defined.
438
+ - **Clients**: decode failures surface as `SchemaError` rather than `ParseError` in `@confect/js` and `@confect/react`, and `@confect/react`'s `useMutation`/`useAction` handles with an `error` schema now resolve to `Result` (v4's replacement for `Either`).
439
+ - **HTTP** is now mounted through the renamed `HttpRouter` module (formerly `HttpApi`). `HttpRouter.make(routes)` takes a single route-registering `Layer` composed from Effect's own `effect/unstable/http` and `effect/unstable/httpapi` modules—`HttpApiBuilder.layer(api)` (with group handler layers supplied via `Layer.provide`; a missing group is a compile-time error), `HttpApiScalar.layer` for docs, `HttpRouter.add` for plain routes, and `HttpRouter.middleware(fn, { global: true })` for middleware, merged with `Layer.mergeAll`. The per-path-prefix record and its `api`/`apiLive`/`middleware`/`scalar` options are gone; Confect registers one catch-all Convex HTTP action at `/`, and plain Convex routes added to the returned router still take precedence. Handlers, middleware, and route-layer construction all run with Confect's Convex-aware `ConfigProvider` in context.
440
+ - **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
441
+ - **Configuration**: Confect's Convex-aware `ConfigProvider` treats empty-string environment variables as missing values (matching Effect v4's built-in providers), so `Config.withDefault` and `Config.option` recover from them.
442
+ - **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
443
+ - Confect queries no longer stub the global `Date.now`. Queries run with a `Clock` whose unsafe accessors return constants, so Effect-internal reads (log timestamps, spans) never evict a query from Convex's cache; explicit time reads—`Clock.currentTimeMillis`/`currentTimeNanos` or a raw `Date.now()` call—opt the query out and evict as they honestly should.
444
+
445
+ ### Patch Changes
446
+
447
+ - Raise the required `effect` peer version to `^4.0.0-beta.100` (from `^4.0.0-beta.99`).
448
+
449
+ This is a peer-range-only change with no consumer-visible API consequences. The `beta.100` release only touches `Cron` internals (month/weekday alias normalization, day/weekday rollover, and equality/hashing), CLI error message formatting (`InvalidValue` prefixes), and `Schema.toTaggedUnion` discriminants that Confect doesn't use.
450
+
451
+ - Raise the required `effect` peer version to `^4.0.0-beta.101` (from `^4.0.0-beta.100`).
452
+
453
+ This is a peer-range-only change with no consumer-visible API consequences. The `beta.101` release only touches fiber/concurrency internals (interrupt handling in concurrent traversal, stack frame annotations, `awaitAllChildren` linearization, `interruptibleMask` interrupt delivery), a `MutableList.filter` fix for empty buckets, a `Schema.Struct` required-readonly-field type display simplification, and an `HttpRouter.toWebHandler` middleware type-inference tightening that Confect doesn't need to accommodate.
454
+
455
+ - Raise the required `effect` peer version to `^4.0.0-beta.102` (from `^4.0.0-beta.101`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
456
+ - Raise the required `effect` peer version to `^4.0.0-beta.105` (from `^4.0.0-beta.102`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
457
+
458
+ `beta.103` separates wall-clock time from monotonic elapsed time: `Clock.Clock` now also requires `monotonicTimeNanos` and `monotonicTimeNanosUnsafe`, so a custom `Clock` provided to a Confect function has to supply both. Effects that measure elapsed time—`Effect.timed`, duration metrics, `Sink.withDuration`—read the monotonic accessors instead of the wall clock, and continue to report a zero duration inside queries and mutations, where Confect pins the unsafe accessors to constants to keep Convex's query cache from evicting on every logged span.
459
+
460
+ `beta.103` also moves synchronous Effect runs off `setImmediate`/`setTimeout` and onto the microtask queue, which Convex's query and mutation isolate permits. Confect no longer suppresses cooperative fiber yielding for the synchronous work it performs while your modules load—registration and schema-to-validator compilation—and relies on that scheduling instead. Neither the "Can't use `setTimeout` in queries and mutations" crash nor any other consumer-visible behavior changes, but this is the area to look at if module loading starts misbehaving.
461
+
462
+ `beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
463
+
464
+ **Before:**
465
+
466
+ ```ts
467
+ export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
468
+ "NoteNotFound",
469
+ { noteId: Id("notes") },
470
+ ) {}
471
+ ```
472
+
473
+ **After:**
474
+
475
+ ```ts
476
+ export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
477
+ "NoteNotFound",
478
+ { noteId: Id("notes") },
479
+ ) {}
480
+ ```
481
+
482
+ `Schema.ErrorClass` is likewise now `Schema.Error`; the schema for JavaScript `Error` instances that previously went by `Schema.Error` is now `Schema.ErrorInstance`, and `Schema.ErrorReviver` is now `Schema.ErrorInstanceReviver`. Confect's own error types—`DocumentDecodeError`, `BlobNotFoundError`, and the rest—are unchanged in name, shape, and message.
483
+
484
+ `beta.105` restructures how schema validation failures are reported, but not on the path Confect puts you on: decode and encode failures still surface as `Schema.SchemaError` with a formatted `message`, so error text from `@confect/js`, `@confect/react`, and document decoding is unchanged.
485
+
486
+ - Raise the required `effect` peer version to `^4.0.0-beta.106` (from `^4.0.0-beta.105`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
487
+
488
+ `beta.106` is a patch-only Effect release. Nothing in Confect's own API changes, and your table, argument, and returns schemas still compile to the same Convex validators.
489
+
490
+ One Effect change needs a call-site edit if you derive property-test generators from those schemas: `Schema.toArbitrary` now returns a factory that takes the `fast-check` module instead of returning an arbitrary directly, and `Schema.toArbitraryLazy` and the `{ report: true }` option are gone.
491
+
492
+ **Before:**
493
+
494
+ ```ts
495
+ const NoteArbitrary = Schema.toArbitrary(Note);
496
+ ```
497
+
498
+ **After:**
499
+
500
+ ```ts
501
+ import * as FastCheck from "fast-check";
502
+
503
+ const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
504
+ ```
505
+
506
+ HTTP actions written against `HttpRouter` also inherit Effect's stricter multipart handling: a request that exceeds the configured part count, part size, or field size limits now stops being parsed at the limit rather than being read to completion first.
507
+
508
+ - Raise the required `effect` peer version to `^4.0.0-beta.107` (from `^4.0.0-beta.106`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
509
+
510
+ `beta.107` is a patch-only Effect release, so no Confect API changes and no call-site edits are needed—upgrade `effect` alongside `@confect/*` and everything you have written keeps compiling. Your table, argument, and returns schemas still produce the same Convex validators.
511
+
512
+ Two Effect fixes are worth knowing about if they touch your code. HTTP actions written with `HttpRouter` now collect uploaded file contents far faster on large multipart bodies, and a file part whose stream is cut short—because a parser limit was exceeded or the request body ended early—now fails instead of hanging. Separately, `Duration` values that are equal now hash equally, so a `Duration` used as a `HashMap` key or a `HashSet` member is found regardless of which constructor built it.
513
+
514
+ - Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
515
+
516
+ `effect`'s `SchemaError` is now exposed as its own public module (`effect/SchemaError`), which changes the import path TypeScript picks when Confect emits `.d.ts` declarations that reference `Schema.SchemaError` (for example in generated `services.d.ts`). Existing `Schema.SchemaError`/`Schema.isSchemaError` usage is unaffected—this is purely a declaration-emit detail that consumers relying on generated types may notice.
517
+
518
+ - Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
519
+
520
+ This is a peer-range-only change with no consumer-visible API consequences. The `beta.99` release only touches `Graph`, CLI (`Command`/`CliConfig`/wizard mode), `Tool` cloning, Redis script eval, and multipart parser internals that Confect doesn't use.
521
+
522
+ - Raise the required `effect` peer version to `^4.0.0-rc.108` (from `^4.0.0-beta.107`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise. Effect v4 has left beta for release candidates, so `effect@rc` is now the tag to install alongside `@confect/*`.
523
+
524
+ No Confect API changed, and no call-site edits are needed for Confect itself. One Effect change can reach your code: the standalone `effect/SchemaError` module is gone, and `SchemaError` is now exported from `Schema`. Confect still fails decoding with the same error, so this only matters if you name the type when handling it.
525
+
526
+ Before:
527
+
528
+ ```ts
529
+ import type { SchemaError } from "effect/SchemaError";
530
+ ```
531
+
532
+ After:
533
+
534
+ ```ts
535
+ import type { SchemaError } from "effect/Schema";
536
+ ```
537
+
538
+ Also worth knowing if you serve an `HttpApi`: a query parameter declared as an array now decodes correctly when a request supplies exactly one value for it.
539
+
540
+ One internal change rides along. Queries and mutations that run long enough to trigger a cooperative fiber yield now take that yield from Effect's own scheduler, which `rc.108` made usable inside Convex's isolate for the first time. The underlying microtask primitive is identical, so behavior should not change—but it is the thing to look at if a long-running query or mutation regresses on this release.
541
+
542
+ - Raise the required `effect` peer version to `^4.0.0-rc.109` (from `^4.0.0-rc.108`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
543
+
544
+ No Confect API changed, and no call-site edits are needed. `rc.109` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
545
+
546
+ - 8e4962e: Raise the required `effect` peer version to `^4.0.0-rc.110` (from `^4.0.0-rc.109`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
547
+
548
+ No Confect API changed, and no call-site edits are needed. `rc.110` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
549
+
550
+ - 3f0255c: Build and test against `convex` 1.44.0. The published `convex` peer ranges are unchanged, so no consumer action is required.
551
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4—see those versions' changelog entries.
552
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
553
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
554
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
555
+
556
+ The `@effect/platform` and `@effect/cli` peer and dependency floors that 9.4.0 raises do not apply here: this line runs on Effect v4, where those packages are not dependencies at all.
557
+
558
+ - The published type declarations are now emitted by TypeScript 7 rather than TypeScript 6. No API changed, but the declaration text differs in places, so an inferred type printed in your editor or in a type error may read slightly differently than before.
559
+
560
+ ## 10.0.0-next.15
561
+
562
+ ### Patch Changes
563
+
564
+ - 8e4962e: Raise the required `effect` peer version to `^4.0.0-rc.109` (from `^4.0.0-rc.108`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
565
+
566
+ No Confect API changed, and no call-site edits are needed. `rc.109` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
567
+
568
+ ## 10.0.0-next.14
569
+
570
+ ### Patch Changes
571
+
572
+ - 9d51bd3: Raise the required `effect` peer version to `^4.0.0-rc.108` (from `^4.0.0-beta.107`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise. Effect v4 has left beta for release candidates, so `effect@rc` is now the tag to install alongside `@confect/*`.
573
+
574
+ No Confect API changed, and no call-site edits are needed for Confect itself. One Effect change can reach your code: the standalone `effect/SchemaError` module is gone, and `SchemaError` is now exported from `Schema`. Confect still fails decoding with the same error, so this only matters if you name the type when handling it.
575
+
576
+ Before:
577
+
578
+ ```ts
579
+ import type { SchemaError } from "effect/SchemaError";
580
+ ```
581
+
582
+ After:
583
+
584
+ ```ts
585
+ import type { SchemaError } from "effect/Schema";
586
+ ```
587
+
588
+ Also worth knowing if you serve an `HttpApi`: a query parameter declared as an array now decodes correctly when a request supplies exactly one value for it.
589
+
590
+ One internal change rides along. Queries and mutations that run long enough to trigger a cooperative fiber yield now take that yield from Effect's own scheduler, which `rc.108` made usable inside Convex's isolate for the first time. The underlying microtask primitive is identical, so behavior should not change—but it is the thing to look at if a long-running query or mutation regresses on this release.
591
+
592
+ - a4054ab: The published type declarations are now emitted by TypeScript 7 rather than TypeScript 6. No API changed, but the declaration text differs in places, so an inferred type printed in your editor or in a type error may read slightly differently than before.
593
+
594
+ ## 10.0.0-next.13
595
+
596
+ ### Patch Changes
597
+
598
+ - 5a73763: Raise the required `effect` peer version to `^4.0.0-beta.107` (from `^4.0.0-beta.106`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
599
+
600
+ `beta.107` is a patch-only Effect release, so no Confect API changes and no call-site edits are needed—upgrade `effect` alongside `@confect/*` and everything you have written keeps compiling. Your table, argument, and returns schemas still produce the same Convex validators.
601
+
602
+ Two Effect fixes are worth knowing about if they touch your code. HTTP actions written with `HttpRouter` now collect uploaded file contents far faster on large multipart bodies, and a file part whose stream is cut short—because a parser limit was exceeded or the request body ended early—now fails instead of hanging. Separately, `Duration` values that are equal now hash equally, so a `Duration` used as a `HashMap` key or a `HashSet` member is found regardless of which constructor built it.
603
+
604
+ ## 10.0.0-next.12
605
+
606
+ ### Patch Changes
607
+
608
+ - 661ee9b: Raise the required `effect` peer version to `^4.0.0-beta.106` (from `^4.0.0-beta.105`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
609
+
610
+ `beta.106` is a patch-only Effect release. Nothing in Confect's own API changes, and your table, argument, and returns schemas still compile to the same Convex validators.
611
+
612
+ One Effect change needs a call-site edit if you derive property-test generators from those schemas: `Schema.toArbitrary` now returns a factory that takes the `fast-check` module instead of returning an arbitrary directly, and `Schema.toArbitraryLazy` and the `{ report: true }` option are gone.
613
+
614
+ **Before:**
615
+
616
+ ```ts
617
+ const NoteArbitrary = Schema.toArbitrary(Note);
618
+ ```
619
+
620
+ **After:**
621
+
622
+ ```ts
623
+ import * as FastCheck from "fast-check";
624
+
625
+ const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
626
+ ```
627
+
628
+ HTTP actions written against `HttpRouter` also inherit Effect's stricter multipart handling: a request that exceeds the configured part count, part size, or field size limits now stops being parsed at the limit rather than being read to completion first.
629
+
630
+ ## 10.0.0-next.11
631
+
632
+ ### Patch Changes
633
+
634
+ - f782cdd: Raise the required `effect` peer version to `^4.0.0-beta.105` (from `^4.0.0-beta.102`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
635
+
636
+ `beta.103` separates wall-clock time from monotonic elapsed time: `Clock.Clock` now also requires `monotonicTimeNanos` and `monotonicTimeNanosUnsafe`, so a custom `Clock` provided to a Confect function has to supply both. Effects that measure elapsed time—`Effect.timed`, duration metrics, `Sink.withDuration`—read the monotonic accessors instead of the wall clock, and continue to report a zero duration inside queries and mutations, where Confect pins the unsafe accessors to constants to keep Convex's query cache from evicting on every logged span.
637
+
638
+ `beta.103` also moves synchronous Effect runs off `setImmediate`/`setTimeout` and onto the microtask queue, which Convex's query and mutation isolate permits. Confect no longer suppresses cooperative fiber yielding for the synchronous work it performs while your modules load—registration and schema-to-validator compilation—and relies on that scheduling instead. Neither the "Can't use `setTimeout` in queries and mutations" crash nor any other consumer-visible behavior changes, but this is the area to look at if module loading starts misbehaving.
639
+
640
+ `beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
641
+
642
+ **Before:**
643
+
644
+ ```ts
645
+ export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
646
+ "NoteNotFound",
647
+ { noteId: Id("notes") },
648
+ ) {}
649
+ ```
650
+
651
+ **After:**
652
+
653
+ ```ts
654
+ export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
655
+ "NoteNotFound",
656
+ { noteId: Id("notes") },
657
+ ) {}
658
+ ```
659
+
660
+ `Schema.ErrorClass` is likewise now `Schema.Error`; the schema for JavaScript `Error` instances that previously went by `Schema.Error` is now `Schema.ErrorInstance`, and `Schema.ErrorReviver` is now `Schema.ErrorInstanceReviver`. Confect's own error types—`DocumentDecodeError`, `BlobNotFoundError`, and the rest—are unchanged in name, shape, and message.
661
+
662
+ `beta.105` restructures how schema validation failures are reported, but not on the path Confect puts you on: decode and encode failures still surface as `Schema.SchemaError` with a formatted `message`, so error text from `@confect/js`, `@confect/react`, and document decoding is unchanged.
663
+
664
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
665
+
666
+ The `@effect/platform` and `@effect/cli` peer and dependency floors that 9.4.0 raises do not apply here: this line runs on Effect v4, where those packages are not dependencies at all.
667
+
668
+ ## 10.0.0-next.10
669
+
670
+ ### Patch Changes
671
+
672
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
673
+
3
674
  ## 10.0.0-next.9
4
675
 
5
676
  ### Patch Changes
6
677
 
7
678
  - 0dcc0fb: Raise the required `effect` peer version to `^4.0.0-beta.102` (from `^4.0.0-beta.101`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
8
- - 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5 — see that version's changelog entries.
679
+ - 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
9
680
 
10
681
  ## 10.0.0-next.8
11
682
 
@@ -39,7 +710,7 @@
39
710
 
40
711
  This is a peer-range-only change with no consumer-visible API consequences. The `beta.99` release only touches `Graph`, CLI (`Command`/`CliConfig`/wizard mode), `Tool` cloning, Redis script eval, and multipart parser internals that Confect doesn't use.
41
712
 
42
- - 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4 — see those versions' changelog entries.
713
+ - 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4—see those versions' changelog entries.
43
714
 
44
715
  ## 10.0.0-next.1
45
716
 
@@ -47,7 +718,7 @@
47
718
 
48
719
  - 4d98ea8: Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
49
720
 
50
- `effect`'s `SchemaError` is now exposed as its own public module (`effect/SchemaError`), which changes the import path TypeScript picks when Confect emits `.d.ts` declarations that reference `Schema.SchemaError` (for example in generated `services.d.ts`). Existing `Schema.SchemaError` / `Schema.isSchemaError` usage is unaffected — this is purely a declaration-emit detail that consumers relying on generated types may notice.
721
+ `effect`'s `SchemaError` is now exposed as its own public module (`effect/SchemaError`), which changes the import path TypeScript picks when Confect emits `.d.ts` declarations that reference `Schema.SchemaError` (for example in generated `services.d.ts`). Existing `Schema.SchemaError`/`Schema.isSchemaError` usage is unaffected—this is purely a declaration-emit detail that consumers relying on generated types may notice.
51
722
 
52
723
  - Updated dependencies [4d98ea8]
53
724
  - @confect/core@10.0.0-next.1
@@ -60,20 +731,79 @@
60
731
 
61
732
  Breaking changes for users:
62
733
  - **Schemas** follow Effect v4's Schema API: `Schema.Union([a, b])` (array form), `Schema.Literals([...])` for literal unions, `Schema.optionalKey` in place of `optionalWith({ exact: true })`, `Schema.TaggedErrorClass` in place of `Schema.TaggedError`, and checks like `Schema.String.check(Schema.isMaxLength(...))` in place of piped filters.
63
- - **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)` — v4's `Schema.Option` encodes to an `Option` instance, which is not a Convex value.
64
- - **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these — Convex's system fields are carried through the whole encoding chain. Schemas that do not resolve to an object shape at every step (such as `Schema.Class`) are rejected with a descriptive error when the table is defined.
734
+ - **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)`—v4's `Schema.Option` encodes to an `Option` instance, which is not a Convex value.
735
+ - **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these—Convex's system fields are carried through the whole encoding chain. Schemas that do not resolve to an object shape at every step (such as `Schema.Class`) are rejected with a descriptive error when the table is defined.
65
736
  - **Clients**: decode failures surface as `SchemaError` rather than `ParseError` in `@confect/js` and `@confect/react`, and `@confect/react`'s `useMutation`/`useAction` handles with an `error` schema now resolve to `Result` (v4's replacement for `Either`).
66
- - **HTTP** is now mounted through the renamed `HttpRouter` module (formerly `HttpApi`). `HttpRouter.make(routes)` takes a single route-registering `Layer` composed from Effect's own `effect/unstable/http` and `effect/unstable/httpapi` modules — `HttpApiBuilder.layer(api)` (with group handler layers supplied via `Layer.provide`; a missing group is a compile-time error), `HttpApiScalar.layer` for docs, `HttpRouter.add` for plain routes, and `HttpRouter.middleware(fn, { global: true })` for middleware, merged with `Layer.mergeAll`. The per-path-prefix record and its `api`/`apiLive`/`middleware`/`scalar` options are gone; Confect registers one catch-all Convex HTTP action at `/`, and plain Convex routes added to the returned router still take precedence. Handlers, middleware, and route-layer construction all run with Confect's Convex-aware `ConfigProvider` in context.
737
+ - **HTTP** is now mounted through the renamed `HttpRouter` module (formerly `HttpApi`). `HttpRouter.make(routes)` takes a single route-registering `Layer` composed from Effect's own `effect/unstable/http` and `effect/unstable/httpapi` modules—`HttpApiBuilder.layer(api)` (with group handler layers supplied via `Layer.provide`; a missing group is a compile-time error), `HttpApiScalar.layer` for docs, `HttpRouter.add` for plain routes, and `HttpRouter.middleware(fn, { global: true })` for middleware, merged with `Layer.mergeAll`. The per-path-prefix record and its `api`/`apiLive`/`middleware`/`scalar` options are gone; Confect registers one catch-all Convex HTTP action at `/`, and plain Convex routes added to the returned router still take precedence. Handlers, middleware, and route-layer construction all run with Confect's Convex-aware `ConfigProvider` in context.
67
738
  - **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
68
739
  - **Configuration**: Confect's Convex-aware `ConfigProvider` treats empty-string environment variables as missing values (matching Effect v4's built-in providers), so `Config.withDefault` and `Config.option` recover from them.
69
740
  - **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
70
- - Confect queries no longer stub the global `Date.now`. Queries run with a `Clock` whose unsafe accessors return constants, so Effect-internal reads (log timestamps, spans) never evict a query from Convex's cache; explicit time reads — `Clock.currentTimeMillis`/`currentTimeNanos` or a raw `Date.now()` call — opt the query out and evict as they honestly should.
741
+ - Confect queries no longer stub the global `Date.now`. Queries run with a `Clock` whose unsafe accessors return constants, so Effect-internal reads (log timestamps, spans) never evict a query from Convex's cache; explicit time reads—`Clock.currentTimeMillis`/`currentTimeNanos` or a raw `Date.now()` call—opt the query out and evict as they honestly should.
71
742
 
72
743
  ### Patch Changes
73
744
 
74
745
  - Updated dependencies [70e313e]
75
746
  - @confect/core@10.0.0-next.0
76
747
 
748
+ ## 9.4.2
749
+
750
+ ## 9.4.1
751
+
752
+ ### Patch Changes
753
+
754
+ - a4054ab: The published type declarations are now emitted by TypeScript 7 rather than TypeScript 6. No API changed, but the declaration text differs in places, so an inferred type printed in your editor or in a type error may read slightly differently than before.
755
+
756
+ ## 9.4.0
757
+
758
+ ## 9.3.0
759
+
760
+ ### Minor Changes
761
+
762
+ - 16b5ad6: Add first-class paginated queries: declare one with `FunctionSpec.publicPaginatedQuery` (or `internalPaginatedQuery`) and read it with the new `usePaginatedQuery` hook from `@confect/react`.
763
+
764
+ Pass an `item` schema—the type of one element in a page—in place of `returns`, plus an optional `args` struct for your own arguments. The handler receives `paginationOpts` alongside them and forwards it to `paginate`.
765
+
766
+ ```ts
767
+ // confect/notes.spec.ts
768
+ FunctionSpec.publicPaginatedQuery({
769
+ name: "listByAuthor",
770
+ args: () => Schema.Struct({ author: Schema.String }),
771
+ item: () => notes.Doc,
772
+ });
773
+
774
+ // confect/notes.impl.ts
775
+ ({ author, paginationOpts }) =>
776
+ Effect.gen(function* () {
777
+ const reader = yield* DatabaseReader;
778
+
779
+ return yield* reader
780
+ .table("notes")
781
+ .index("by_creation_time", "desc")
782
+ .paginate(paginationOpts, (q) => q.eq(q.field("author"), author));
783
+ }).pipe(Effect.orDie);
784
+ ```
785
+
786
+ Declaring `paginationOpts` in `args` yourself is a type and runtime error.
787
+
788
+ ```tsx
789
+ import { PaginatedQueryResult, usePaginatedQuery } from "@confect/react";
790
+
791
+ const notes = usePaginatedQuery(
792
+ refs.public.notes.listByAuthor,
793
+ { author },
794
+ { initialNumItems: 10 },
795
+ );
796
+
797
+ // `notes.results` holds the pages decoded through `item`.
798
+ if (PaginatedQueryResult.isCanLoadMore(notes)) {
799
+ notes.loadMore(10);
800
+ }
801
+ ```
802
+
803
+ The hook returns a `PaginatedQueryResult<Item, E>`. `LoadingFirstPage`, `LoadingMore`, `CanLoadMore`, and `Exhausted` all carry `results` and `isLoading`; `loadMore` lives only on `CanLoadMore`, the one state it can make progress from. A declared `error` schema surfaces as a `Failure` variant carrying the decoded error instead of throwing during render, and `Failure` carries `results` too, so the pages loaded before it can still be rendered. Without an `error` schema, `Failure` is absent from the type entirely.
804
+
805
+ `paginate` in `@confect/server` now accepts Convex's full `PaginationOptions`, so a handler's `paginationOpts` passes straight through. `@confect/react` now requires `convex` >= 1.36.0.
806
+
77
807
  ## 9.2.5
78
808
 
79
809
  ## 9.2.4
@@ -156,7 +886,7 @@
156
886
 
157
887
  - 445ea9b: Loosen and align dependency ranges across all packages:
158
888
  - The `convex` peer dependency is now `^1.32.0` in every package (previously pinned exactly to `1.39.1`, or `^1.30.0` in `@confect/react`). The range is validated against convex 1.32.0 through 1.40.0.
159
- - `@confect/server`'s `@effect/platform-node` peer dependency is now optional — it is only needed when using the `@confect/server/node` entrypoint.
889
+ - `@confect/server`'s `@effect/platform-node` peer dependency is now optional—it is only needed when using the `@confect/server/node` entrypoint.
160
890
  - `@confect/cli` now uses caret ranges for its `@effect/platform` and `@effect/platform-node` dependencies so they can deduplicate with the versions resolved for `@confect/server`, and no longer declares an unused direct dependency on `@effect/platform-node-shared`.
161
891
  - `@confect/test` now accepts any `convex-test` release in `>=0.0.50 <0.1.0` instead of exactly 0.0.50.
162
892
 
@@ -175,8 +905,8 @@
175
905
 
176
906
  Your API is now authored as colocated `*.spec.ts`/`*.impl.ts` pairs, one pair per group, and **the file's path within `confect/` is the group's name** (its stem for top-level groups, the dot-joined directory path for nested groups). `GroupSpec.make()` and `GroupSpec.makeNode()` no longer take a name argument.
177
907
  - Each `*.spec.ts` `export default`s its `GroupSpec` (named co-exports like error classes are still allowed).
178
- - Each `*.impl.ts` default-imports its sibling spec, passes it to `FunctionImpl.make` / `GroupImpl.make`, and ends the layer pipeline with `GroupImpl.finalize`—a compile-time completeness check that only typechecks once every function the spec declares has a `FunctionImpl` provided.
179
- - The root `confect/spec.ts`, `confect/impl.ts`, `confect/nodeSpec.ts`, and `confect/nodeImpl.ts` files are gone, along with `Impl.make` and `Impl.finalize`. `confect codegen` deletes any of these (and the stale aggregate `_generated/registeredFunctions.ts` / `_generated/nodeRegisteredFunctions.ts`) on upgrade.
908
+ - Each `*.impl.ts` default-imports its sibling spec, passes it to `FunctionImpl.make`/`GroupImpl.make`, and ends the layer pipeline with `GroupImpl.finalize`—a compile-time completeness check that only typechecks once every function the spec declares has a `FunctionImpl` provided.
909
+ - The root `confect/spec.ts`, `confect/impl.ts`, `confect/nodeSpec.ts`, and `confect/nodeImpl.ts` files are gone, along with `Impl.make` and `Impl.finalize`. `confect codegen` deletes any of these (and the stale aggregate `_generated/registeredFunctions.ts`/`_generated/nodeRegisteredFunctions.ts`) on upgrade.
180
910
 
181
911
  ### Tables are the source of truth, named by their filename
182
912
 
@@ -207,7 +937,7 @@
207
937
 
208
938
  ### Specs and impls: lazy schemas, and impls take the `DatabaseSchema`
209
939
 
210
- `FunctionSpec.*` constructors now take `args`, `returns`, and the optional `error` as `() => Schema` thunks, so importing a spec builds no schemas until a function is invoked. `FunctionImpl.make` and `GroupImpl.make` take the runtime `DatabaseSchema` (the default export of `_generated/schema`) as their first argument instead of the whole `Api`—which keeps the project-wide spec graph out of a function's cold-start module graph. The `Api` module (`Api.make`, the `Api` type) and the generated `_generated/api.ts` / `_generated/nodeApi.ts` files are removed.
940
+ `FunctionSpec.*` constructors now take `args`, `returns`, and the optional `error` as `() => Schema` thunks, so importing a spec builds no schemas until a function is invoked. `FunctionImpl.make` and `GroupImpl.make` take the runtime `DatabaseSchema` (the default export of `_generated/schema`) as their first argument instead of the whole `Api`—which keeps the project-wide spec graph out of a function's cold-start module graph. The `Api` module (`Api.make`, the `Api` type) and the generated `_generated/api.ts`/`_generated/nodeApi.ts` files are removed.
211
941
 
212
942
  **Before:**
213
943
 
@@ -255,7 +985,7 @@
255
985
 
256
986
  A group's runtime is now declared solely by its spec—`GroupSpec.makeNode()` for a Node action group, `GroupSpec.make()` otherwise—mirroring vanilla Convex's per-file `"use node"` directive. The separate `node` namespace is gone: Node specs/impls are ordinary colocated pairs that can live anywhere in `confect/`, and codegen emits the `"use node"` directive based on the spec.
257
987
  - A Node group at `confect/email.spec.ts` is now reached at `refs.public.email.send` instead of `refs.public.node.email.send`.
258
- - `@confect/core` removes `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec` / `Spec.isNodeSpec`; `Spec.make()` is a single mixed-runtime container and `Refs.make(spec)` takes one argument. `GroupSpec.makeNode()`, `FunctionSpec.publicNodeAction()` / `internalNodeAction()` are unchanged.
988
+ - `@confect/core` removes `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec`/`Spec.isNodeSpec`; `Spec.make()` is a single mixed-runtime container and `Refs.make(spec)` takes one argument. `GroupSpec.makeNode()`, `FunctionSpec.publicNodeAction()`/`internalNodeAction()` are unchanged.
259
989
 
260
990
  ### Less work at cold start
261
991
 
@@ -272,7 +1002,7 @@
272
1002
  ### Migration
273
1003
  1. **Tables.** Delete `confect/schema.ts`. Rename each table file to a valid JS identifier (e.g. `confect/tables/notes.ts`); the basename becomes the table name. Drop the name argument from `Table.make`, wrap the field struct in `() =>`, and replace `GenericId.GenericId("x")` with `Id("x")` from `_generated/id`. If you read `table.name` off a bound table, rename it to `table.tableName`.
274
1004
  2. **Specs.** Split each group into a colocated `*.spec.ts` that `export default`s `GroupSpec.make()` (no name). Wrap every `args`/`returns`/`error` in `() =>`. Import a table's `Doc`/`Fields` from its wrapper, `import notes from "./_generated/tables/notes"`.
275
- 3. **Impls.** In each `*.impl.ts`, default-import the sibling spec, import `databaseSchema` from `_generated/schema`, pass it to `FunctionImpl.make` / `GroupImpl.make` in place of `api`, end the pipeline with `GroupImpl.finalize`, and `export default` it. Delete the root `confect/spec.ts`, `impl.ts`, `nodeSpec.ts`, and `nodeImpl.ts` (codegen will also remove them).
1005
+ 3. **Impls.** In each `*.impl.ts`, default-import the sibling spec, import `databaseSchema` from `_generated/schema`, pass it to `FunctionImpl.make`/`GroupImpl.make` in place of `api`, end the pipeline with `GroupImpl.finalize`, and `export default` it. Delete the root `confect/spec.ts`, `impl.ts`, `nodeSpec.ts`, and `nodeImpl.ts` (codegen will also remove them).
276
1006
  4. **Node groups.** Move any `confect/node/<path>` files anywhere you like under `confect/`; the `node/` directory no longer has special meaning. Drop the `node` segment from call sites (`refs.public.node.<group>` → `refs.public.<group>`) and replace `Refs.make(spec, nodeSpec)` with `Refs.make(spec)`.
277
1007
  5. **Tests.** If you use `@confect/test`, import `confectSchema` from `_generated/schema`, import the generated `convexSchema` from `_generated/convexSchema`, and pass `convexSchema` as the new second argument to `TestConfect.layer`.
278
1008
  6. **Optional.** Adopt submodule Effect imports (`import * as Schema from "effect/Schema"`) in your own `confect/` files for the full cold-start savings.
@@ -316,11 +1046,11 @@
316
1046
 
317
1047
  ### Why
318
1048
 
319
- A barrel import of a namespace re-export defeats esbuild's tree-shaking: accessing `Schema.X` from `import { Schema } from "effect"` retains the _entire_ `Schema` namespace, because the bundler can't prune property access on the barrel's `export * as Schema`. So every Convex function's cold-start bundle was pulling all of `effect/Schema` and `effect/Stream` — and, transitively through Schema's `Arbitrary`, `fast-check` — whether the function used them or not.
1049
+ A barrel import of a namespace re-export defeats esbuild's tree-shaking: accessing `Schema.X` from `import { Schema } from "effect"` retains the _entire_ `Schema` namespace, because the bundler can't prune property access on the barrel's `export * as Schema`. So every Convex function's cold-start bundle was pulling all of `effect/Schema` and `effect/Stream`—and, transitively through Schema's `Arbitrary`, `fast-check`—whether the function used them or not.
320
1050
 
321
1051
  Importing from the submodule path tree-shakes normally. On a minimal function this cut the bundle esbuild produces by ~54% (the `effect/Schema` module alone by ~75%) and its cold-start module-evaluation time by ~35%, with `fast-check` dropped entirely. This is also the import style Effect v4 recommends, so it's forward-compatible. A `no-restricted-imports` ESLint rule now enforces it across the codebase (type-only imports and `@effect/vitest` are exempt).
322
1052
 
323
- No API changes — your existing code keeps working.
1053
+ No API changes—your existing code keeps working.
324
1054
 
325
1055
  ### Getting the full win in your own code
326
1056