@confect/core 10.0.0-next.8 → 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 +966 -46
- package/README.md +3 -1
- package/dist/FunctionProvenance.d.ts +166 -68
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +55 -13
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +320 -138
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +56 -13
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js +1 -1
- package/dist/GroupPath.d.ts +6 -10
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupPath.js.map +1 -1
- package/dist/GroupSpec.d.ts +25 -12
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +51 -14
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +6 -5
- package/dist/Identifier.d.ts.map +1 -1
- package/dist/Identifier.js +6 -5
- package/dist/Identifier.js.map +1 -1
- package/dist/Lazy.d.ts +11 -14
- package/dist/Lazy.d.ts.map +1 -1
- package/dist/Lazy.js +11 -14
- package/dist/Lazy.js.map +1 -1
- package/dist/MiddlewareAttachment.d.ts +171 -0
- package/dist/MiddlewareAttachment.d.ts.map +1 -0
- package/dist/MiddlewareAttachment.js +48 -0
- package/dist/MiddlewareAttachment.js.map +1 -0
- package/dist/MiddlewareSpec.d.ts +198 -0
- package/dist/MiddlewareSpec.d.ts.map +1 -0
- package/dist/MiddlewareSpec.js +60 -0
- package/dist/MiddlewareSpec.js.map +1 -0
- package/dist/PaginationError.d.ts +20 -0
- package/dist/PaginationError.d.ts.map +1 -0
- package/dist/PaginationError.js +31 -0
- package/dist/PaginationError.js.map +1 -0
- package/dist/PaginationOptions.d.ts +23 -0
- package/dist/PaginationOptions.d.ts.map +1 -0
- package/dist/PaginationOptions.js +29 -0
- package/dist/PaginationOptions.js.map +1 -0
- package/dist/PaginationResult.d.ts +1 -0
- package/dist/PaginationResult.d.ts.map +1 -1
- package/dist/PaginationResult.js.map +1 -1
- package/dist/Ref.d.ts +135 -47
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +104 -46
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +10 -5
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js +5 -4
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +99 -0
- package/dist/SchemaToValidator.d.ts.map +1 -0
- package/dist/SchemaToValidator.js +158 -0
- package/dist/SchemaToValidator.js.map +1 -0
- package/dist/Spec.d.ts +16 -12
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +14 -9
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +16 -15
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +16 -15
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.d.ts +75 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +77 -0
- package/dist/Table.js.map +1 -0
- package/dist/Types.d.ts +8 -2
- package/dist/Types.d.ts.map +1 -1
- package/dist/Types.js.map +1 -1
- package/dist/UserIdentity.d.ts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/package.json +17 -15
- package/src/FunctionProvenance.ts +197 -34
- package/src/FunctionSpec.ts +332 -86
- package/src/GroupPath.ts +6 -12
- package/src/GroupSpec.ts +184 -25
- package/src/Identifier.ts +6 -5
- package/src/Lazy.ts +11 -14
- package/src/MiddlewareAttachment.ts +106 -0
- package/src/MiddlewareSpec.ts +392 -0
- package/src/PaginationError.ts +78 -0
- package/src/PaginationOptions.ts +23 -0
- package/src/PaginationResult.ts +4 -0
- package/src/Ref.ts +468 -236
- package/src/Refs.ts +43 -18
- package/src/SchemaToValidator.ts +612 -0
- package/src/Spec.ts +50 -39
- package/src/SystemFields.ts +32 -36
- package/src/Table.ts +427 -0
- package/src/Types.ts +9 -3
- package/src/index.ts +6 -1
- package/dist/Registry.d.ts +0 -24
- package/dist/Registry.d.ts.map +0 -1
- package/dist/Registry.js +0 -19
- package/dist/Registry.js.map +0 -1
- package/dist/tsconfig.src.tsbuildinfo +0 -1
- package/src/Registry.ts +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,864 @@
|
|
|
1
1
|
# @confect/core
|
|
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
|
+
### Major Changes
|
|
332
|
+
|
|
333
|
+
- 09f9f55: Use `Spec.groups(spec)` and `DatabaseSchema.tables(schema)` to inspect assembled group and table records. Adding a group at an existing spec name now replaces its inferred type as well as its runtime value.
|
|
334
|
+
|
|
335
|
+
### Breaking Changes
|
|
336
|
+
- The `Spec.groups` and `DatabaseSchema.tables` accessors replace the corresponding instance properties.
|
|
337
|
+
- `Spec.Spec`, `DatabaseSchema.DatabaseSchema`, and `DataModel.DataModel` take a record type instead of a union of its members. The separate `~Groups` and `~Tables` phantom properties on these containers are removed; the `Groups` and `Tables` type helpers remain available.
|
|
338
|
+
|
|
339
|
+
Run `confect codegen` to update generated spec and schema annotations. Ordinary `Spec.make().add(...)`, `Spec.make().addAt(...)`, and `DatabaseSchema.make({ ... })` calls keep their existing syntax. `DataModel.FromTables` continues to accept a table union.
|
|
340
|
+
|
|
341
|
+
For handwritten annotations, use `Spec.Spec<{ readonly notes: typeof notesGroup }>` or `DatabaseSchema.DatabaseSchema<{ readonly notes: typeof notesTable }>` in place of the corresponding member-union parameter.
|
|
342
|
+
|
|
343
|
+
### Patch Changes
|
|
344
|
+
|
|
345
|
+
- 2c379cf: Fix function error types widening to `any` when `exactOptionalPropertyTypes` is disabled and no `error` schema is declared. Function refs, handlers, clients, and test helpers now preserve precise error channels under either setting, which may reveal application type errors previously hidden by `any`.
|
|
346
|
+
|
|
347
|
+
## 10.0.0-next.22
|
|
348
|
+
|
|
349
|
+
### Major Changes
|
|
350
|
+
|
|
351
|
+
- 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
|
|
352
|
+
|
|
353
|
+
### Stream queries and pagination
|
|
354
|
+
|
|
355
|
+
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.
|
|
356
|
+
|
|
357
|
+
`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.
|
|
358
|
+
|
|
359
|
+
Use React's new `useStreamPaginatedQuery` for these queries:
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
import { useStreamPaginatedQuery } from "@confect/react";
|
|
363
|
+
|
|
364
|
+
const { results, status, loadMore } = useStreamPaginatedQuery(
|
|
365
|
+
refs.public.notes.feed,
|
|
366
|
+
{},
|
|
367
|
+
{
|
|
368
|
+
initialNumItems: 10,
|
|
369
|
+
maximumRowsRead: 1000,
|
|
370
|
+
maximumBytesRead: 512 * 1024,
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
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.
|
|
376
|
+
|
|
377
|
+
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.
|
|
378
|
+
|
|
379
|
+
### Middleware options
|
|
380
|
+
|
|
381
|
+
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.
|
|
382
|
+
|
|
383
|
+
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.
|
|
384
|
+
|
|
385
|
+
### Breaking changes
|
|
386
|
+
|
|
387
|
+
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`:
|
|
388
|
+
|
|
389
|
+
**Before:**
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
(effect, { name, args }) => effect;
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**After:**
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
(effect, { invocation: { name, args } }) => effect;
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
|
|
402
|
+
|
|
403
|
+
### Fixes and tracing
|
|
404
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
|
|
405
|
+
- 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.
|
|
406
|
+
|
|
407
|
+
### Patch Changes
|
|
408
|
+
|
|
409
|
+
- 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.
|
|
410
|
+
|
|
411
|
+
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.
|
|
412
|
+
|
|
413
|
+
- 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.
|
|
414
|
+
- f721d2c: Remove spaces around em dashes and separator slashes in API documentation and `confect codegen` diagnostics.
|
|
415
|
+
|
|
416
|
+
## 10.0.0-next.21
|
|
417
|
+
|
|
418
|
+
### Major Changes
|
|
419
|
+
|
|
420
|
+
- a6425c5: Raise the minimum supported Node.js version to 24.
|
|
421
|
+
|
|
422
|
+
### Breaking Changes
|
|
423
|
+
- `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
|
|
424
|
+
|
|
425
|
+
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.
|
|
426
|
+
|
|
427
|
+
## 10.0.0-next.20
|
|
428
|
+
|
|
429
|
+
## 10.0.0-next.19
|
|
430
|
+
|
|
431
|
+
### Minor Changes
|
|
432
|
+
|
|
433
|
+
- c1087eb: Add `@confect/foldkit`—client-side bindings for [Foldkit](https://foldkit.dev) apps. The package maps Confect's client surface onto Foldkit's integration seams: `Client.layer` provides the scoped WebSocket client and pagination-session allocator through an application's `resources`, `Subscription.reactiveQuery` builds a subscription entry that opens, re-opens, and closes a reactive query as `Option`-wrapped args derived from the Model change, and `Command.query`/`Command.mutation`/`Command.action` build Command definitions whose args are the ref's args and whose Messages are declared with the same `messages` field Foldkit's own `Command.define` takes. Every failure is folded into a Message via the required `onError` handler, so Command and Subscription error channels stay `never` as Foldkit requires.
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
import * as Confect from "@confect/foldkit";
|
|
437
|
+
import * as Schema from "effect/Schema";
|
|
438
|
+
import * as Subscription from "foldkit/subscription";
|
|
439
|
+
|
|
440
|
+
const SaveNote = Confect.Command.mutation(
|
|
441
|
+
"SaveNote",
|
|
442
|
+
refs.public.notes.insert,
|
|
443
|
+
{
|
|
444
|
+
messages: [SucceededSaveNote, FailedSaveNote],
|
|
445
|
+
onSuccess: (noteId) => SucceededSaveNote({ noteId }),
|
|
446
|
+
onError: (error) => FailedSaveNote({ message: String(error) }),
|
|
447
|
+
},
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
const subscriptions = Subscription.make<
|
|
451
|
+
Model,
|
|
452
|
+
Message,
|
|
453
|
+
Confect.Client.Client
|
|
454
|
+
>()(() => ({
|
|
455
|
+
note: Confect.Subscription.reactiveQuery<Model>()(refs.public.notes.get, {
|
|
456
|
+
args: (model) => Option.map(model.noteId, (noteId) => ({ noteId })),
|
|
457
|
+
onSuccess: (note) => SucceededGetNote({ note }),
|
|
458
|
+
onError: (error) => FailedGetNote({ message: String(error) }),
|
|
459
|
+
}),
|
|
460
|
+
}));
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
The Command factories accept Foldkit's `interrupt` option—`true` keys invocations by the Command name, `{ keyFields, toKey }` by a part derived from the ref's args—and the returned definition gains the `Interrupt` constructor for stopping in-flight invocations. Factory-built definitions instantiate Foldkit's own definition interfaces, so they are accepted wherever Foldkit accepts a Command definition—including Story/Scene `Command.resolve` and `expectExact` matchers. `Command.queryEffect`, `Command.mutationEffect`, and `Command.actionEffect` return execute bodies for hand-written `Command.define` calls (custom args schemas, multi-call Commands), and `Subscription.reactiveQueryStream` is the `dependenciesToStream` escape hatch for hand-written subscription entries.
|
|
464
|
+
|
|
465
|
+
`PaginatedQuery` navigates a paginated query one page at a time over Convex's cursor pagination. `PaginatedQuery.make(ref)` returns the Model and settlement schemas. Its states use Foldkit `AsyncData`'s vocabulary and semantics: `Idle`, `Loading`, `Refreshing`, `Success`, `Failure`, and `Stale`. Failed settlements preserve the complete error contract: declared function and middleware errors are wrapped as `FunctionError`, Convex's invalid-cursor pseudo-error is normalized to the new `@confect/core/PaginationError.InvalidCursor`, and `WebSocketClientError` and `SchemaError` are carried directly. `settle` accepts a request-bound `Result`, turns a failed refresh into `Stale`, automatically resets an invalid cursor, and ignores successes or failures from superseded requests. All machine operations (`init`, `reinitialize`, `reset`, `close`, `next`, `prev`, and `first`) remain pure.
|
|
466
|
+
|
|
467
|
+
`Subscription.paginatedQuery` keeps exactly one live, reactive page subscription in sync with the machine and emits one `onSettled` Message shape for either outcome. It allocates Convex's pagination `id` internally and returns it with the first settlement, so session allocation is not a separate Command or application Message. Installing that id is keep-alive-equivalent and does not restart the subscription. Query errors are emitted as values without closing the underlying Convex subscription, allowing a later successful result to recover naturally. Each request supports `maximumRowsRead` and `maximumBytesRead` and uses `initialNumItems` for the initial page and split heuristic. Page splits remain transparent, the last complete page stays visible during navigation and after refresh failure, and an empty terminal page automatically retreats to the preceding page.
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
const Notes = Confect.PaginatedQuery.make(refs.public.notes.paginate);
|
|
471
|
+
|
|
472
|
+
// Model: notes: Notes.schema
|
|
473
|
+
// Initial Model value: notes: Notes.idle
|
|
474
|
+
// Message: settlement: Notes.settlement
|
|
475
|
+
// update after matching Idle: Notes.init(idle, { channel }, { initialNumItems: 20 })
|
|
476
|
+
|
|
477
|
+
const subscriptions = Subscription.make<
|
|
478
|
+
Model,
|
|
479
|
+
Message,
|
|
480
|
+
Confect.Client.Client
|
|
481
|
+
>()(() => ({
|
|
482
|
+
notesPage: Confect.Subscription.paginatedQuery<Model>()(Notes, {
|
|
483
|
+
state: (model) => model.notes,
|
|
484
|
+
onSettled: (settlement) => SettledGetNotesPage({ settlement }),
|
|
485
|
+
}),
|
|
486
|
+
}));
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
- b34e029: Declare Confect function arguments as optional lazy `Schema.Struct` field maps instead of constructed struct schemas. Confect now derives and builds the struct schema itself, defaults omitted args to `{}`, matches Convex's object-only argument model, and preserves exact field types through function specs and refs.
|
|
490
|
+
|
|
491
|
+
## 10.0.0-next.18
|
|
492
|
+
|
|
493
|
+
### Minor Changes
|
|
494
|
+
|
|
495
|
+
- 91aebe4: Move `Table.make` to `@confect/core` so a spec that returns `notes.Doc` from `_generated/tables/notes` no longer ships `@confect/server` to the client.
|
|
496
|
+
|
|
497
|
+
```ts confect/tables/notes.ts
|
|
498
|
+
import { Table } from "@confect/core";
|
|
499
|
+
import * as Schema from "effect/Schema";
|
|
500
|
+
|
|
501
|
+
export default Table.make(() =>
|
|
502
|
+
Schema.Struct({
|
|
503
|
+
text: Schema.String,
|
|
504
|
+
}),
|
|
505
|
+
);
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
`confect codegen` now fails if any module a spec reaches value-imports `@confect/server`, including `confect/tables/` and `_generated/`. Type-only imports remain allowed.
|
|
509
|
+
|
|
510
|
+
## 10.0.0-next.17
|
|
511
|
+
|
|
512
|
+
### Minor Changes
|
|
513
|
+
|
|
514
|
+
- 126548a: Add middleware: reusable logic that runs around a group's function handlers, provides Effect services to them, and fails with typed errors that reach clients.
|
|
515
|
+
|
|
516
|
+
Middleware lives in a reserved `confect/middleware/` directory, one `<Name>.spec.ts`/`<Name>.impl.ts` pair per middleware. Confect no longer scans that directory for function groups, so a group can no longer be defined at `confect/middleware/...`.
|
|
517
|
+
|
|
518
|
+
Declare a middleware's client-safe interface with `MiddlewareSpec.MiddlewareSpec`—its `provides` service (type-level), its `error` schema, and the function types it may cover (`functionTypes`, one required boolean flag per function type, so every spec states its coverage outright)—and attach it in a group spec with `GroupSpec.middleware`:
|
|
519
|
+
|
|
520
|
+
```ts confect/middleware/RequireUser.spec.ts
|
|
521
|
+
import { MiddlewareSpec } from "@confect/core";
|
|
522
|
+
|
|
523
|
+
export class CurrentUser extends Context.Service<
|
|
524
|
+
CurrentUser,
|
|
525
|
+
{
|
|
526
|
+
readonly user: User;
|
|
527
|
+
}
|
|
528
|
+
>()("confect/middleware/RequireUser.spec/CurrentUser") {}
|
|
529
|
+
|
|
530
|
+
export class NotSignedIn extends Schema.TaggedError<NotSignedIn>()(
|
|
531
|
+
"NotSignedIn",
|
|
532
|
+
{},
|
|
533
|
+
) {}
|
|
534
|
+
|
|
535
|
+
export default class RequireUser extends MiddlewareSpec.MiddlewareSpec<
|
|
536
|
+
RequireUser,
|
|
537
|
+
{
|
|
538
|
+
provides: CurrentUser;
|
|
539
|
+
}
|
|
540
|
+
>()("RequireUser", {
|
|
541
|
+
error: () => NotSignedIn,
|
|
542
|
+
functionTypes: { query: true, mutation: true, action: false },
|
|
543
|
+
}) {}
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
```ts confect/notes.spec.ts
|
|
547
|
+
import RequireUser from "./middleware/RequireUser.spec";
|
|
548
|
+
|
|
549
|
+
export default GroupSpec.make()
|
|
550
|
+
.middleware(RequireUser)
|
|
551
|
+
.addFunction(FunctionSpec.publicMutation({ ... }));
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Handlers of covered functions can then consume the provided service—a handler requiring `CurrentUser` type-checks exactly when a middleware providing it is attached to the group. Implement the middleware server-side with `MiddlewareImpl.make` (one strategy for all declared function types), `MiddlewareImpl.makeByFunctionType` (one per function type—the recommended shape for database-touching middleware that also covers actions), or the `MiddlewareImpl.provides` shorthand, and provide it to the group's impl layer like any function implementation:
|
|
555
|
+
|
|
556
|
+
```ts confect/middleware/RequireUser.impl.ts
|
|
557
|
+
import { MiddlewareImpl } from "@confect/server";
|
|
558
|
+
|
|
559
|
+
export default MiddlewareImpl.provides(
|
|
560
|
+
databaseSchema,
|
|
561
|
+
RequireUser,
|
|
562
|
+
CurrentUser,
|
|
563
|
+
Effect.gen(function* () {
|
|
564
|
+
// load the user; `return yield* new NotSignedIn()` short-circuits
|
|
565
|
+
return { user };
|
|
566
|
+
}),
|
|
567
|
+
);
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
```ts confect/notes.impl.ts
|
|
571
|
+
import RequireUser from "./middleware/RequireUser.impl";
|
|
572
|
+
|
|
573
|
+
export default GroupImpl.make(databaseSchema, group).pipe(
|
|
574
|
+
Layer.provide(createNote),
|
|
575
|
+
Layer.provide(RequireUser), // omitting this is a compile error at `GroupImpl.finalize`
|
|
576
|
+
GroupImpl.finalize,
|
|
577
|
+
);
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
Middleware runs per invocation, after args are decoded and before the handler, in attachment order; a middleware failure short-circuits the rest of the chain. Its errors join the covered functions' error unions end to end: `useQuery`/`useMutation` and the `@confect/js` clients surface them as typed errors with no client-side changes.
|
|
581
|
+
|
|
582
|
+
Middleware can also attach to a single function with `.middleware()` on the function spec—it runs inside the group-attached chain, immediately around the handler, and its errors join only that function's error union:
|
|
583
|
+
|
|
584
|
+
```ts
|
|
585
|
+
FunctionSpec.publicMutation({ name: "deleteAll", ... }).middleware(RequireAdmin);
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
A middleware can depend on one that runs earlier in the chain by declaring `requires` in its `Config` type parameter—its implementation may then consume the required service (e.g. `RequireAdmin` reading the `CurrentUser` that `RequireUser` provides). Satisfaction is type-checked at `GroupSpec.middleware` for group attachments and at `GroupImpl.make` for whole groups.
|
|
589
|
+
|
|
590
|
+
Attaching the same middleware twice (including once at group level and once at function level), attaching one whose `functionTypes` don't cover a covered function's type, attaching any middleware to a plain-Convex function, or attaching to a group containing a matching-type plain-Convex function are all type errors. Middleware does not propagate to subgroups. `confect codegen` fails with an explicit error when a group's spec attaches a middleware its impl never provides.
|
|
591
|
+
|
|
592
|
+
Because every `*.spec.ts` is reachable from `_generated/refs.ts`, which clients import, a spec's whole import graph is bundled into the browser—so an implementation co-located with its declaration ships server logic (table names, index names, authorization checks) to users. `confect codegen` now fails when any module a spec reaches value-imports `@confect/server`, outside the `tables/` and `_generated/` directories that legitimately need it. Type-only imports are erased before bundling and remain allowed.
|
|
593
|
+
|
|
594
|
+
### Patch Changes
|
|
595
|
+
|
|
596
|
+
- 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.
|
|
597
|
+
|
|
598
|
+
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/*`.
|
|
599
|
+
|
|
600
|
+
## 10.0.0-next.16
|
|
601
|
+
|
|
602
|
+
### Major Changes
|
|
603
|
+
|
|
604
|
+
- 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/*`).
|
|
605
|
+
|
|
606
|
+
Breaking changes for users:
|
|
607
|
+
|
|
608
|
+
- **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.
|
|
609
|
+
- **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.
|
|
610
|
+
- **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.
|
|
611
|
+
- **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`).
|
|
612
|
+
- **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.
|
|
613
|
+
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
614
|
+
- **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.
|
|
615
|
+
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
616
|
+
- 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.
|
|
617
|
+
|
|
618
|
+
### Patch Changes
|
|
619
|
+
|
|
620
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.100` (from `^4.0.0-beta.99`).
|
|
621
|
+
|
|
622
|
+
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.
|
|
623
|
+
|
|
624
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.101` (from `^4.0.0-beta.100`).
|
|
625
|
+
|
|
626
|
+
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.
|
|
627
|
+
|
|
628
|
+
- 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.
|
|
629
|
+
- 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.
|
|
630
|
+
|
|
631
|
+
`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.
|
|
632
|
+
|
|
633
|
+
`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.
|
|
634
|
+
|
|
635
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
636
|
+
|
|
637
|
+
**Before:**
|
|
638
|
+
|
|
639
|
+
```ts
|
|
640
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
641
|
+
"NoteNotFound",
|
|
642
|
+
{ noteId: Id("notes") },
|
|
643
|
+
) {}
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
**After:**
|
|
647
|
+
|
|
648
|
+
```ts
|
|
649
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
650
|
+
"NoteNotFound",
|
|
651
|
+
{ noteId: Id("notes") },
|
|
652
|
+
) {}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
`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.
|
|
656
|
+
|
|
657
|
+
`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.
|
|
658
|
+
|
|
659
|
+
- 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.
|
|
660
|
+
|
|
661
|
+
`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.
|
|
662
|
+
|
|
663
|
+
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.
|
|
664
|
+
|
|
665
|
+
**Before:**
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
const NoteArbitrary = Schema.toArbitrary(Note);
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
**After:**
|
|
672
|
+
|
|
673
|
+
```ts
|
|
674
|
+
import * as FastCheck from "fast-check";
|
|
675
|
+
|
|
676
|
+
const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
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.
|
|
680
|
+
|
|
681
|
+
- 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.
|
|
682
|
+
|
|
683
|
+
`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.
|
|
684
|
+
|
|
685
|
+
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.
|
|
686
|
+
|
|
687
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
688
|
+
|
|
689
|
+
`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.
|
|
690
|
+
|
|
691
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
|
|
692
|
+
|
|
693
|
+
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.
|
|
694
|
+
|
|
695
|
+
- 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/*`.
|
|
696
|
+
|
|
697
|
+
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.
|
|
698
|
+
|
|
699
|
+
Before:
|
|
700
|
+
|
|
701
|
+
```ts
|
|
702
|
+
import type { SchemaError } from "effect/SchemaError";
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
After:
|
|
706
|
+
|
|
707
|
+
```ts
|
|
708
|
+
import type { SchemaError } from "effect/Schema";
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
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.
|
|
712
|
+
|
|
713
|
+
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.
|
|
714
|
+
|
|
715
|
+
- 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.
|
|
716
|
+
|
|
717
|
+
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/*`.
|
|
718
|
+
|
|
719
|
+
- 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.
|
|
720
|
+
|
|
721
|
+
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/*`.
|
|
722
|
+
|
|
723
|
+
- 3f0255c: Build and test against `convex` 1.44.0. The published `convex` peer ranges are unchanged, so no consumer action is required.
|
|
724
|
+
- The schemas Confect uses for values Convex itself produces now reject `NaN` and `±Infinity`: `_creationTime`, a scheduled function's `scheduledTime` and `completedTime`, a stored file's `size`, and the fields of `PaginationOptions`. Convex cannot return a non-finite value for any of them, so this rules out states that were never reachable.
|
|
725
|
+
|
|
726
|
+
The Convex validators these compile to are unchanged—each is still `v.float64()`—so nothing changes about what your deployment accepts. Only Confect's decoding is narrower. Your own table schemas are untouched: `Schema.Number` still accepts non-finite values wherever you use it, which matters because Convex stores them.
|
|
727
|
+
|
|
728
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4—see those versions' changelog entries.
|
|
729
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
|
|
730
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
|
|
731
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
|
|
732
|
+
|
|
733
|
+
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.
|
|
734
|
+
|
|
735
|
+
- 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.
|
|
736
|
+
|
|
737
|
+
## 10.0.0-next.15
|
|
738
|
+
|
|
739
|
+
### Patch Changes
|
|
740
|
+
|
|
741
|
+
- 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.
|
|
742
|
+
|
|
743
|
+
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/*`.
|
|
744
|
+
|
|
745
|
+
## 10.0.0-next.14
|
|
746
|
+
|
|
747
|
+
### Patch Changes
|
|
748
|
+
|
|
749
|
+
- 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/*`.
|
|
750
|
+
|
|
751
|
+
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.
|
|
752
|
+
|
|
753
|
+
Before:
|
|
754
|
+
|
|
755
|
+
```ts
|
|
756
|
+
import type { SchemaError } from "effect/SchemaError";
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
After:
|
|
760
|
+
|
|
761
|
+
```ts
|
|
762
|
+
import type { SchemaError } from "effect/Schema";
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
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.
|
|
766
|
+
|
|
767
|
+
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.
|
|
768
|
+
|
|
769
|
+
- aede323: The schemas Confect uses for values Convex itself produces now reject `NaN` and `±Infinity`: `_creationTime`, a scheduled function's `scheduledTime` and `completedTime`, a stored file's `size`, and the fields of `PaginationOptions`. Convex cannot return a non-finite value for any of them, so this rules out states that were never reachable.
|
|
770
|
+
|
|
771
|
+
The Convex validators these compile to are unchanged—each is still `v.float64()`—so nothing changes about what your deployment accepts. Only Confect's decoding is narrower. Your own table schemas are untouched: `Schema.Number` still accepts non-finite values wherever you use it, which matters because Convex stores them.
|
|
772
|
+
|
|
773
|
+
- 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.
|
|
774
|
+
|
|
775
|
+
## 10.0.0-next.13
|
|
776
|
+
|
|
777
|
+
### Patch Changes
|
|
778
|
+
|
|
779
|
+
- 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.
|
|
780
|
+
|
|
781
|
+
`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.
|
|
782
|
+
|
|
783
|
+
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.
|
|
784
|
+
|
|
785
|
+
## 10.0.0-next.12
|
|
786
|
+
|
|
787
|
+
### Patch Changes
|
|
788
|
+
|
|
789
|
+
- 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.
|
|
790
|
+
|
|
791
|
+
`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.
|
|
792
|
+
|
|
793
|
+
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.
|
|
794
|
+
|
|
795
|
+
**Before:**
|
|
796
|
+
|
|
797
|
+
```ts
|
|
798
|
+
const NoteArbitrary = Schema.toArbitrary(Note);
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
**After:**
|
|
802
|
+
|
|
803
|
+
```ts
|
|
804
|
+
import * as FastCheck from "fast-check";
|
|
805
|
+
|
|
806
|
+
const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
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.
|
|
810
|
+
|
|
811
|
+
## 10.0.0-next.11
|
|
812
|
+
|
|
813
|
+
### Patch Changes
|
|
814
|
+
|
|
815
|
+
- 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.
|
|
816
|
+
|
|
817
|
+
`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.
|
|
818
|
+
|
|
819
|
+
`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.
|
|
820
|
+
|
|
821
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
822
|
+
|
|
823
|
+
**Before:**
|
|
824
|
+
|
|
825
|
+
```ts
|
|
826
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
827
|
+
"NoteNotFound",
|
|
828
|
+
{ noteId: Id("notes") },
|
|
829
|
+
) {}
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
**After:**
|
|
833
|
+
|
|
834
|
+
```ts
|
|
835
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
836
|
+
"NoteNotFound",
|
|
837
|
+
{ noteId: Id("notes") },
|
|
838
|
+
) {}
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
`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.
|
|
842
|
+
|
|
843
|
+
`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.
|
|
844
|
+
|
|
845
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
|
|
846
|
+
|
|
847
|
+
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.
|
|
848
|
+
|
|
849
|
+
## 10.0.0-next.10
|
|
850
|
+
|
|
851
|
+
### Patch Changes
|
|
852
|
+
|
|
853
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
|
|
854
|
+
|
|
855
|
+
## 10.0.0-next.9
|
|
856
|
+
|
|
857
|
+
### Patch Changes
|
|
858
|
+
|
|
859
|
+
- 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.
|
|
860
|
+
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
|
|
861
|
+
|
|
3
862
|
## 10.0.0-next.8
|
|
4
863
|
|
|
5
864
|
### Patch Changes
|
|
@@ -32,7 +891,7 @@
|
|
|
32
891
|
|
|
33
892
|
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.
|
|
34
893
|
|
|
35
|
-
- 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4
|
|
894
|
+
- 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.
|
|
36
895
|
|
|
37
896
|
## 10.0.0-next.1
|
|
38
897
|
|
|
@@ -40,7 +899,7 @@
|
|
|
40
899
|
|
|
41
900
|
- 4d98ea8: Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
42
901
|
|
|
43
|
-
`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
|
|
902
|
+
`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.
|
|
44
903
|
|
|
45
904
|
## 10.0.0-next.0
|
|
46
905
|
|
|
@@ -50,14 +909,75 @@
|
|
|
50
909
|
|
|
51
910
|
Breaking changes for users:
|
|
52
911
|
- **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.
|
|
53
|
-
- **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)
|
|
54
|
-
- **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these
|
|
912
|
+
- **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.
|
|
913
|
+
- **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.
|
|
55
914
|
- **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`).
|
|
56
|
-
- **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
|
|
915
|
+
- **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.
|
|
57
916
|
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
58
917
|
- **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.
|
|
59
918
|
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
60
|
-
- 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
|
|
919
|
+
- 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.
|
|
920
|
+
|
|
921
|
+
## 9.4.2
|
|
922
|
+
|
|
923
|
+
## 9.4.1
|
|
924
|
+
|
|
925
|
+
### Patch Changes
|
|
926
|
+
|
|
927
|
+
- 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.
|
|
928
|
+
|
|
929
|
+
## 9.4.0
|
|
930
|
+
|
|
931
|
+
## 9.3.0
|
|
932
|
+
|
|
933
|
+
### Minor Changes
|
|
934
|
+
|
|
935
|
+
- 16b5ad6: Add first-class paginated queries: declare one with `FunctionSpec.publicPaginatedQuery` (or `internalPaginatedQuery`) and read it with the new `usePaginatedQuery` hook from `@confect/react`.
|
|
936
|
+
|
|
937
|
+
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`.
|
|
938
|
+
|
|
939
|
+
```ts
|
|
940
|
+
// confect/notes.spec.ts
|
|
941
|
+
FunctionSpec.publicPaginatedQuery({
|
|
942
|
+
name: "listByAuthor",
|
|
943
|
+
args: () => Schema.Struct({ author: Schema.String }),
|
|
944
|
+
item: () => notes.Doc,
|
|
945
|
+
});
|
|
946
|
+
|
|
947
|
+
// confect/notes.impl.ts
|
|
948
|
+
({ author, paginationOpts }) =>
|
|
949
|
+
Effect.gen(function* () {
|
|
950
|
+
const reader = yield* DatabaseReader;
|
|
951
|
+
|
|
952
|
+
return yield* reader
|
|
953
|
+
.table("notes")
|
|
954
|
+
.index("by_creation_time", "desc")
|
|
955
|
+
.paginate(paginationOpts, (q) => q.eq(q.field("author"), author));
|
|
956
|
+
}).pipe(Effect.orDie);
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
Declaring `paginationOpts` in `args` yourself is a type and runtime error.
|
|
960
|
+
|
|
961
|
+
```tsx
|
|
962
|
+
import { PaginatedQueryResult, usePaginatedQuery } from "@confect/react";
|
|
963
|
+
|
|
964
|
+
const notes = usePaginatedQuery(
|
|
965
|
+
refs.public.notes.listByAuthor,
|
|
966
|
+
{ author },
|
|
967
|
+
{ initialNumItems: 10 },
|
|
968
|
+
);
|
|
969
|
+
|
|
970
|
+
// `notes.results` holds the pages decoded through `item`.
|
|
971
|
+
if (PaginatedQueryResult.isCanLoadMore(notes)) {
|
|
972
|
+
notes.loadMore(10);
|
|
973
|
+
}
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
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.
|
|
977
|
+
|
|
978
|
+
`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.
|
|
979
|
+
|
|
980
|
+
## 9.2.5
|
|
61
981
|
|
|
62
982
|
## 9.2.4
|
|
63
983
|
|
|
@@ -79,7 +999,7 @@
|
|
|
79
999
|
|
|
80
1000
|
- 8d63382: Fix `TS7056` ("inferred type … exceeds the maximum length the compiler will serialize") when compiling a Confect backend with declaration emit.
|
|
81
1001
|
|
|
82
|
-
Enabling `composite`/`declaration` on a project that included your generated `confect/_generated` modules failed with `TS7056` once the backend had more than a handful of tables and functions. This prevented a Confect backend from being a referenced/composite TypeScript project
|
|
1002
|
+
Enabling `composite`/`declaration` on a project that included your generated `confect/_generated` modules failed with `TS7056` once the backend had more than a handful of tables and functions. This prevented a Confect backend from being a referenced/composite TypeScript project—every consumer had to pull in and recompile its source, hurting editor responsiveness and incremental typecheck times in larger workspaces.
|
|
83
1003
|
|
|
84
1004
|
Regenerating your backend (`confect codegen`) now produces `_generated` modules that emit declarations cleanly, so you can turn on `composite`/`declaration` for the backend and have downstream packages depend on it via project references (`.d.ts`) instead of source.
|
|
85
1005
|
|
|
@@ -101,7 +1021,7 @@
|
|
|
101
1021
|
|
|
102
1022
|
- 445ea9b: Loosen and align dependency ranges across all packages:
|
|
103
1023
|
- 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.
|
|
104
|
-
- `@confect/server`'s `@effect/platform-node` peer dependency is now optional
|
|
1024
|
+
- `@confect/server`'s `@effect/platform-node` peer dependency is now optional—it is only needed when using the `@confect/server/node` entrypoint.
|
|
105
1025
|
- `@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`.
|
|
106
1026
|
- `@confect/test` now accepts any `convex-test` release in `>=0.0.50 <0.1.0` instead of exactly 0.0.50.
|
|
107
1027
|
|
|
@@ -117,8 +1037,8 @@
|
|
|
117
1037
|
|
|
118
1038
|
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.
|
|
119
1039
|
- Each `*.spec.ts` `export default`s its `GroupSpec` (named co-exports like error classes are still allowed).
|
|
120
|
-
- Each `*.impl.ts` default-imports its sibling spec, passes it to `FunctionImpl.make
|
|
121
|
-
- 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
|
|
1040
|
+
- 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.
|
|
1041
|
+
- 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.
|
|
122
1042
|
|
|
123
1043
|
### Tables are the source of truth, named by their filename
|
|
124
1044
|
|
|
@@ -149,7 +1069,7 @@
|
|
|
149
1069
|
|
|
150
1070
|
### Specs and impls: lazy schemas, and impls take the `DatabaseSchema`
|
|
151
1071
|
|
|
152
|
-
`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
|
|
1072
|
+
`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.
|
|
153
1073
|
|
|
154
1074
|
**Before:**
|
|
155
1075
|
|
|
@@ -197,7 +1117,7 @@
|
|
|
197
1117
|
|
|
198
1118
|
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.
|
|
199
1119
|
- A Node group at `confect/email.spec.ts` is now reached at `refs.public.email.send` instead of `refs.public.node.email.send`.
|
|
200
|
-
- `@confect/core` removes `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec
|
|
1120
|
+
- `@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.
|
|
201
1121
|
|
|
202
1122
|
### Less work at cold start
|
|
203
1123
|
|
|
@@ -214,7 +1134,7 @@
|
|
|
214
1134
|
### Migration
|
|
215
1135
|
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`.
|
|
216
1136
|
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"`.
|
|
217
|
-
3. **Impls.** In each `*.impl.ts`, default-import the sibling spec, import `databaseSchema` from `_generated/schema`, pass it to `FunctionImpl.make
|
|
1137
|
+
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).
|
|
218
1138
|
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)`.
|
|
219
1139
|
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`.
|
|
220
1140
|
6. **Optional.** Adopt submodule Effect imports (`import * as Schema from "effect/Schema"`) in your own `confect/` files for the full cold-start savings.
|
|
@@ -240,11 +1160,11 @@
|
|
|
240
1160
|
|
|
241
1161
|
- 4894959: Make Node-runtime functions first-class and remove the separate `node` namespace.
|
|
242
1162
|
|
|
243
|
-
A function group's runtime is now declared solely by its spec
|
|
1163
|
+
A function group's runtime is now declared solely by its spec—`GroupSpec.makeNode()` for a Node action group, `GroupSpec.make()` for a Convex group—exactly like vanilla Convex's per-file `"use node"` directive. The `confect/node/` directory is no longer special: Node specs/impls are ordinary colocated `.spec.ts`/`.impl.ts` pairs that can live anywhere in `confect/`, and codegen emits the `"use node"` directive into the generated `convex/` module based on the spec. This is safe because v9's per-group registries already isolate each Convex function's bundle from every other group's impl, so Node-only code can no longer leak into a Convex-runtime bundle regardless of namespace.
|
|
244
1164
|
|
|
245
1165
|
### Why
|
|
246
1166
|
|
|
247
|
-
The `node` namespace existed only because the pre-v9 architecture aggregated every function's impl into one module that all generated `convex/` modules imported; Node functions had to be quarantined into a separate spec/impl/registry tree so Convex-runtime functions wouldn't transitively import Node-only code. v9's per-group isolation removed that constraint, so the namespace was no longer load-bearing
|
|
1167
|
+
The `node` namespace existed only because the pre-v9 architecture aggregated every function's impl into one module that all generated `convex/` modules imported; Node functions had to be quarantined into a separate spec/impl/registry tree so Convex-runtime functions wouldn't transitively import Node-only code. v9's per-group isolation removed that constraint, so the namespace was no longer load-bearing—only ergonomic overhead that diverged from vanilla Convex (which identifies Node modules per-file, with no directory requirement).
|
|
248
1168
|
|
|
249
1169
|
### Breaking changes
|
|
250
1170
|
- **API namespace removed.** A Node group at `confect/email.spec.ts` is now referenced as `refs.public.email.send` instead of `refs.public.node.email.send`. Node groups are ordinary groups in the refs tree, nesting preserved like any other group.
|
|
@@ -252,7 +1172,7 @@
|
|
|
252
1172
|
- **`@confect/core` API.** Removed `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec`/`Spec.isNodeSpec`. `Spec` is now a single mixed-runtime container (`Spec.make()` accepts groups of any runtime). `Refs.make(spec)` takes a single argument (the unified spec) instead of `(convexSpec, nodeSpec)`. `GroupSpec.makeNode()`/`makeNodeAt()` and `FunctionSpec.publicNodeAction()`/`internalNodeAction()` are unchanged; `GroupSpec` subgroups may now be of any runtime (a group is just a namespace for its children).
|
|
253
1173
|
|
|
254
1174
|
### Migration
|
|
255
|
-
1. Move any `confect/node/<path>.spec.ts`/`.impl.ts` files to wherever you want them under `confect/` (e.g. `confect/<path>.spec.ts`); the `node/` directory has no special meaning anymore. Their specs already use `GroupSpec.makeNode()`, so no spec-body change is needed
|
|
1175
|
+
1. Move any `confect/node/<path>.spec.ts`/`.impl.ts` files to wherever you want them under `confect/` (e.g. `confect/<path>.spec.ts`); the `node/` directory has no special meaning anymore. Their specs already use `GroupSpec.makeNode()`, so no spec-body change is needed—only fix the impl's relative import of `_generated/schema` if its depth changed.
|
|
256
1176
|
2. Update call sites to drop the `node` segment: `refs.public.node.<group>.<fn>` → `refs.public.<group>.<fn>`.
|
|
257
1177
|
3. Replace `Refs.make(spec, nodeSpec)` with `Refs.make(spec)` (codegen does this for `_generated/refs.ts` automatically).
|
|
258
1178
|
4. Run `confect codegen`. The `convex/` tree and `confect/_generated/` are re-emitted; the stale `_generated/nodeSpec.ts` is removed.
|
|
@@ -267,11 +1187,11 @@
|
|
|
267
1187
|
|
|
268
1188
|
### Why
|
|
269
1189
|
|
|
270
|
-
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
|
|
1190
|
+
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.
|
|
271
1191
|
|
|
272
1192
|
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).
|
|
273
1193
|
|
|
274
|
-
No API changes
|
|
1194
|
+
No API changes—your existing code keeps working.
|
|
275
1195
|
|
|
276
1196
|
### Getting the full win in your own code
|
|
277
1197
|
|
|
@@ -302,13 +1222,13 @@
|
|
|
302
1222
|
|
|
303
1223
|
- 46045a9: Reduce per-function cold-start cost: make `FunctionSpec` schemas lazy and keep each Convex function's bundle scoped to its own group.
|
|
304
1224
|
|
|
305
|
-
Previously, loading a single Convex function still paid for the whole project
|
|
1225
|
+
Previously, loading a single Convex function still paid for the whole project—importing the codegen-assembled `_generated/spec.ts` ran `Schema.Struct(...)`/`Schema.Array(...)` for every function at module load, and each per-function bundle transitively imported `_generated/api.ts` → `_generated/spec.ts` (every spec). A function's cold-start cost now scales with its own group rather than the size of the project.
|
|
306
1226
|
|
|
307
1227
|
### Lazy `FunctionSpec` schemas
|
|
308
1228
|
|
|
309
|
-
`FunctionSpec.*` (`publicQuery
|
|
1229
|
+
`FunctionSpec.*` (`publicQuery`/`internalQuery`/`publicMutation`/`internalMutation`/`publicAction`/`internalAction`/`publicNodeAction`/`internalNodeAction`) takes `args`, `returns`, and (optional) `error` as `() => Schema` thunks instead of bare schemas. The resulting provenance exposes them as sync lazy memoised getters (the same pattern `Table.make` uses), so importing `_generated/spec.ts` builds no schemas—construction is deferred to the first invocation that compiles validators or runs a codec.
|
|
310
1230
|
|
|
311
|
-
Migration
|
|
1231
|
+
Migration—wrap each schema in `() =>`:
|
|
312
1232
|
|
|
313
1233
|
```diff
|
|
314
1234
|
FunctionSpec.publicQuery({
|
|
@@ -324,9 +1244,9 @@
|
|
|
324
1244
|
|
|
325
1245
|
`FunctionImpl.make` and `GroupImpl.make` now take the runtime `DatabaseSchema` (the default export of `_generated/schema.ts`) as their first argument instead of the whole `Api`. The handler's ctx-service types only ever depended on the database schema, and switching impls to import `_generated/schema` instead of `_generated/api` removes `_generated/spec.ts` (and the function specs it transitively imports) from every per-function bundle.
|
|
326
1246
|
|
|
327
|
-
Each function also registers under a flat, single-segment key into a fresh, isolated `Registry` provided per group by `RegisteredFunctions.buildForGroup` (and the CLI's impl validation), so no group-path lookup against `api.spec` is needed. As a result `Spec#addPath`, `Spec#paths`, and `Api.resolveGroupPathUnsafe` are removed; `GroupImpl
|
|
1247
|
+
Each function also registers under a flat, single-segment key into a fresh, isolated `Registry` provided per group by `RegisteredFunctions.buildForGroup` (and the CLI's impl validation), so no group-path lookup against `api.spec` is needed. As a result `Spec#addPath`, `Spec#paths`, and `Api.resolveGroupPathUnsafe` are removed; `GroupImpl`/`FunctionImpl` drop their group-path type parameter; and the codegen-emitted `_generated/spec.ts`/`nodeSpec.ts` no longer contain a `.addPath(...)` chain (the `.addAt(...)`/`.addGroupAt(...)` assembly tree that `Refs.make` consumes is unchanged).
|
|
328
1248
|
|
|
329
|
-
Migration
|
|
1249
|
+
Migration—in each `*.impl.ts`, import the database schema and pass it where you passed `api`/`nodeApi`:
|
|
330
1250
|
|
|
331
1251
|
```diff
|
|
332
1252
|
- import api from "../_generated/api"; // (or nodeApi from "../_generated/nodeApi")
|
|
@@ -343,37 +1263,37 @@
|
|
|
343
1263
|
|
|
344
1264
|
### `buildForGroup` and the generated registries
|
|
345
1265
|
|
|
346
|
-
`RegisteredFunctions.buildForGroup` takes the `DatabaseSchema` value plus the group's own `GroupSpec` as a single type argument (`buildForGroup<typeof groupSpec>(…)`, returning `RegisteredFunctionsForGroupSpec<Group>`); the `api
|
|
1266
|
+
`RegisteredFunctions.buildForGroup` takes the `DatabaseSchema` value plus the group's own `GroupSpec` as a single type argument (`buildForGroup<typeof groupSpec>(…)`, returning `RegisteredFunctionsForGroupSpec<Group>`); the `api`/`groupPath` parameters and the `ForGroupPath` dot-path navigation are gone. `RegisteredConvexFunction.make`/`RegisteredNodeFunction.make` take the `DatabaseSchema` rather than the `Api`. Each `_generated/registeredFunctions/{path}.ts` imports the runtime schema and references its group's leaf spec **type-only** (`typeof import("…/{group}.spec")["default"]`), so it never imports a spec module at runtime.
|
|
347
1267
|
|
|
348
|
-
### `_generated/api.ts
|
|
1268
|
+
### `_generated/api.ts`/`nodeApi.ts` are no longer emitted, and `Api` is removed
|
|
349
1269
|
|
|
350
|
-
Nothing imports them anymore, so `confect codegen` no longer emits `_generated/api.ts
|
|
1270
|
+
Nothing imports them anymore, so `confect codegen` no longer emits `_generated/api.ts`/`_generated/nodeApi.ts` and deletes any copies left over from earlier versions. The `Api` module itself (`@confect/server/Api`—`Api.make`, the `Api` type, `Api.resolveGroupPathUnsafe`, etc.) is **removed entirely**: impls and the generated registries take the `DatabaseSchema` value and the spec directly, so the combined database-schema-plus-spec `Api` is no longer used anywhere.
|
|
351
1271
|
|
|
352
1272
|
### Net effect
|
|
353
1273
|
|
|
354
1274
|
A function's `convex/{path}.ts` bundle now imports only its own group's registry → its own `.impl` + `_generated/schema` (table schemas, built lazily) + its own group's spec. No `_generated/api.ts`, no project-wide `_generated/spec.ts`, and no sibling-group impls/specs. Re-run `confect codegen` after upgrading.
|
|
355
1275
|
|
|
356
|
-
- 762f7eb: Split the deploy-time Convex schema from the runtime `DatabaseSchema`, make `confect/tables/` the single source of truth
|
|
1276
|
+
- 762f7eb: Split the deploy-time Convex schema from the runtime `DatabaseSchema`, make `confect/tables/` the single source of truth—including the table name, which is now derived from the filename—and make per-table schema construction lazy.
|
|
357
1277
|
|
|
358
|
-
Previously, `confect/schema.ts` was user-authored and `DatabaseSchema` carried a `convexSchemaDefinition` field that was eagerly rebuilt on every `.addTable(...)`. That field was an `O(n²)` allocation for `n` tables, and it forced both the deploy CLI (which only needs `defineSchema(...)`) and the runtime (which only needs the table codec lookup) through the same module
|
|
1278
|
+
Previously, `confect/schema.ts` was user-authored and `DatabaseSchema` carried a `convexSchemaDefinition` field that was eagerly rebuilt on every `.addTable(...)`. That field was an `O(n²)` allocation for `n` tables, and it forced both the deploy CLI (which only needs `defineSchema(...)`) and the runtime (which only needs the table codec lookup) through the same module—so any runtime function bundle dragged in `convex/server`'s `defineSchema`. Issue 1.
|
|
359
1279
|
|
|
360
1280
|
Codegen now scans `confect/tables/*.ts` (every file must default-export a `Table`) and emits two siblings:
|
|
361
|
-
- `confect/_generated/schema.ts
|
|
362
|
-
- `confect/_generated/convexSchema.ts
|
|
1281
|
+
- `confect/_generated/schema.ts`—the runtime `DatabaseSchema`, consumed by `_generated/api.ts`. Imports `@confect/server` but never `convex/server`.
|
|
1282
|
+
- `confect/_generated/convexSchema.ts`—the Convex deploy `SchemaDefinition`, re-exported one-line from `convex/schema.ts`. Imports `convex/server` but never `@confect/server`.
|
|
363
1283
|
|
|
364
1284
|
The `convexSchemaDefinition` field is removed from `DatabaseSchema` and `Api`. `TestConfect.layer` now takes the Convex schema definition as a separate argument so it can stay aligned with the deploy artifact without bringing the runtime schema along for the ride.
|
|
365
1285
|
|
|
366
1286
|
### Filename-derived table names
|
|
367
1287
|
|
|
368
|
-
The table name is now derived from the file's basename
|
|
1288
|
+
The table name is now derived from the file's basename—`confect/tables/notes.ts` defines a table called `notes`. `Table.make` no longer accepts a name argument and returns an _unnamed_ `Table` value; codegen invokes that value with the filename to produce the bound table.
|
|
369
1289
|
|
|
370
1290
|
This eliminates a class of subtle infelicities: the file basename and the table name can never drift out of sync, cross-table `_id` references are type-constrained against the actual set of declared tables (catching typos at compile time), and ESM cycle hazards for mutual cross-table `Id` references are gone because authoring files no longer transitively import each other.
|
|
371
1291
|
|
|
372
1292
|
Codegen now emits two new sets of files alongside `_generated/schema.ts` and `_generated/convexSchema.ts`:
|
|
373
|
-
- `confect/_generated/id.ts
|
|
374
|
-
- `confect/_generated/tables/<name>.ts
|
|
1293
|
+
- `confect/_generated/id.ts`—a single `Id` constructor whose argument is type-constrained to the union of your table names. Use `Id("notes")` everywhere you previously wrote `GenericId.GenericId("notes")`.
|
|
1294
|
+
- `confect/_generated/tables/<name>.ts`—one thin wrapper per table that binds the unnamed value from `confect/tables/<name>.ts` to its filename. This is what other modules (specs, impls, HTTP handlers) default-import to reach a table's `Doc`, `Fields`, and `tableName`.
|
|
375
1295
|
|
|
376
|
-
Table filenames must be valid JS identifiers, may not start with `_` (Convex reserves underscore-prefixed names for system tables), and may not collide with reserved JS keywords like `import.ts`. Pick a casing convention you like
|
|
1296
|
+
Table filenames must be valid JS identifiers, may not start with `_` (Convex reserves underscore-prefixed names for system tables), and may not collide with reserved JS keywords like `import.ts`. Pick a casing convention you like—Confect's example code uses `snake_case` (`notes.ts`, `user_profiles.ts`).
|
|
377
1297
|
|
|
378
1298
|
The bound `Table`'s `name` property has been renamed to `tableName`. This avoids a silent collision with the built-in `Function.prototype.name` that JavaScript carries on every function value (including the new unnamed-callable `UnnamedTable`).
|
|
379
1299
|
|
|
@@ -381,9 +1301,9 @@
|
|
|
381
1301
|
|
|
382
1302
|
`Table.make` takes a `() => Schema.Struct({...})` callback rather than a bare struct, and a bound `Table`'s `Fields`, `Doc`, and `tableDefinition` are lazy memoised getters that only invoke that callback on first access.
|
|
383
1303
|
|
|
384
|
-
Previously, every `confect/tables/<name>.ts` module ran `Schema.Struct({...})` (and the corresponding `compileTableSchema
|
|
1304
|
+
Previously, every `confect/tables/<name>.ts` module ran `Schema.Struct({...})` (and the corresponding `compileTableSchema`/`defineTable` work) at module-load time. Because the codegen-emitted `_generated/schema.ts` is imported transitively from every per-group function bundle, loading any one function eagerly built _every_ table's schema graph—paying a cold-start cost proportional to the whole project, not just the function being invoked.
|
|
385
1305
|
|
|
386
|
-
The bound `Table` now exposes `Fields
|
|
1306
|
+
The bound `Table` now exposes `Fields`/`Doc`/`tableDefinition` as lazy getters that compute their value on first access, then replace themselves with a plain non-writable data property so second-and-subsequent accesses are observably indistinguishable from a plain property (and skip all function-call overhead). The result: a function bundle only pays the schema-construction cost for tables it actually touches via `db.table(name)` (which reaches `Fields` through `Document.decode`). The `UnnamedTable` callable no longer exposes `Fields` or `tableDefinition`—read these off the bound `Table` (the generated `_generated/tables/<name>.ts` wrapper already binds the name).
|
|
387
1307
|
|
|
388
1308
|
### Migration
|
|
389
1309
|
1. Delete your `confect/schema.ts`. Codegen will refuse to run while a stray copy is present.
|
|
@@ -411,7 +1331,7 @@
|
|
|
411
1331
|
+ );
|
|
412
1332
|
```
|
|
413
1333
|
|
|
414
|
-
4. Rewire every consumer site (specs, impls, integration tests, HTTP handlers, etc.) to import from the generated wrapper rather than directly from `tables/`. The wrapper is also where you now read `Doc
|
|
1334
|
+
4. Rewire every consumer site (specs, impls, integration tests, HTTP handlers, etc.) to import from the generated wrapper rather than directly from `tables/`. The wrapper is also where you now read `Doc`/`Fields`/`tableDefinition` (the unnamed `Table.make(...)` callable no longer exposes them):
|
|
415
1335
|
|
|
416
1336
|
```diff
|
|
417
1337
|
- import Notes from "../tables/Notes";
|
|
@@ -440,11 +1360,11 @@
|
|
|
440
1360
|
|
|
441
1361
|
### New warning: no tables discovered
|
|
442
1362
|
|
|
443
|
-
If a Confect project has no tables
|
|
1363
|
+
If a Confect project has no tables—either `confect/tables/` is missing entirely or it exists but contains no `.ts` files—codegen now emits a yellow `⚠` warning and continues, producing an empty `DatabaseSchema.make()`/`defineSchema({})`. Table-free backends (e.g. action-only proxies, webhook bridges) are still legal; the warning just catches the much more common case of a typoed directory name or files placed at the wrong path. To silence it, add at least one `Table.make(...)` module under `confect/tables/`.
|
|
444
1364
|
|
|
445
1365
|
### New error: invalid table filename
|
|
446
1366
|
|
|
447
|
-
Codegen now rejects table files whose basename is not a valid JS identifier (e.g. `user-profiles.ts`), starts with `_` (reserved for Convex system tables), or shadows a reserved JS keyword (e.g. `import.ts`). Rename the offending file to fix it
|
|
1367
|
+
Codegen now rejects table files whose basename is not a valid JS identifier (e.g. `user-profiles.ts`), starts with `_` (reserved for Convex system tables), or shadows a reserved JS keyword (e.g. `import.ts`). Rename the offending file to fix it—for example, `user-profiles.ts` → `user_profiles.ts` or `userProfiles.ts`.
|
|
448
1368
|
|
|
449
1369
|
## 9.0.0-next.5
|
|
450
1370
|
|
|
@@ -454,22 +1374,22 @@
|
|
|
454
1374
|
|
|
455
1375
|
### Patch Changes
|
|
456
1376
|
|
|
457
|
-
- 6d85210: Resolve `FunctionImpl
|
|
1377
|
+
- 6d85210: Resolve `FunctionImpl`/`GroupImpl` group paths via an immutable `paths` map on `Spec` instead of identity-walking the assembled tree.
|
|
458
1378
|
|
|
459
1379
|
### Why
|
|
460
1380
|
|
|
461
|
-
Since `9.0.0-next.1`, codegen has wrapped every parent leaf that has sibling subdirectory specs in `<parent>.addGroupAt("child", <child>)`. Because `GroupSpec.addGroupAt` is immutable, that produced a fresh object in the assembled tree, while the parent's `*.impl.ts` continued to hold a reference to the original imported leaf. The runtime resolver compared by `===`, so every such impl failed `validateImpl` with "Could not resolve group path for the provided GroupSpec." Child impls happened to work only because `GroupSpec.withName` was secretly mutating its argument in place to keep the child's identity stable
|
|
1381
|
+
Since `9.0.0-next.1`, codegen has wrapped every parent leaf that has sibling subdirectory specs in `<parent>.addGroupAt("child", <child>)`. Because `GroupSpec.addGroupAt` is immutable, that produced a fresh object in the assembled tree, while the parent's `*.impl.ts` continued to hold a reference to the original imported leaf. The runtime resolver compared by `===`, so every such impl failed `validateImpl` with "Could not resolve group path for the provided GroupSpec." Child impls happened to work only because `GroupSpec.withName` was secretly mutating its argument in place to keep the child's identity stable—an asymmetry that was load-bearing for one half of the API and broken for the other.
|
|
462
1382
|
|
|
463
1383
|
### What changed
|
|
464
|
-
- `@confect/core/Spec` carries a new `readonly paths: ReadonlyMap<GroupSpec.AnyWithProps, string>` field and exposes a chainable `Spec#addPath(group, path)` builder. `add
|
|
1384
|
+
- `@confect/core/Spec` carries a new `readonly paths: ReadonlyMap<GroupSpec.AnyWithProps, string>` field and exposes a chainable `Spec#addPath(group, path)` builder. `add`/`addAt`/`merge` propagate `paths` unchanged; `merge` re-prefixes a node spec's entries with `"node."` to match the merged tree.
|
|
465
1385
|
- `@confect/core/GroupSpec.withName` is now pure: it returns a fresh copy when the name differs and no longer rewrites the input in place. No new identity-tracking machinery is introduced.
|
|
466
|
-
- `@confect/server/FunctionImpl.make` and `GroupImpl.make` resolve their group path via `api.spec.paths.get(group)
|
|
1386
|
+
- `@confect/server/FunctionImpl.make` and `GroupImpl.make` resolve their group path via `api.spec.paths.get(group)`—an O(1) map lookup instead of a tree walk—and throw a clearer error pointing at `Spec.addPath` when the spec hasn't been registered.
|
|
467
1387
|
- `@confect/server/GroupPath` (the old identity-based resolver) is deleted.
|
|
468
1388
|
- `@confect/cli` codegen emits one `.addPath(<binding>, "<dot.path>")` call per leaf in `_generated/spec.ts` (and `_generated/nodeSpec.ts`) so the imported leaves carry their full paths into the assembled spec value.
|
|
469
1389
|
|
|
470
1390
|
### User-facing impact
|
|
471
1391
|
- Spec authoring (`*.spec.ts`) and impl authoring (`*.impl.ts`) APIs are unchanged. `FunctionImpl.make(api, spec, name, handler)` and `GroupImpl.make(api, spec)` keep their exact signatures.
|
|
472
|
-
- Generated `_generated/spec.ts` (and `_generated/nodeSpec.ts`) pick up one `.addPath(...)` chain entry per leaf on the next `confect codegen` run. The shape is fully immutable
|
|
1392
|
+
- Generated `_generated/spec.ts` (and `_generated/nodeSpec.ts`) pick up one `.addPath(...)` chain entry per leaf on the next `confect codegen` run. The shape is fully immutable—no module-load mutation, no hidden side effects.
|
|
473
1393
|
- Hand-rolled tests that construct a `Spec` and pass it to `Api.make` must now also call `.addPath(spec, "dot.path")` for any group they intend to look up.
|
|
474
1394
|
|
|
475
1395
|
### Fixes
|
|
@@ -490,9 +1410,9 @@
|
|
|
490
1410
|
|
|
491
1411
|
### Why
|
|
492
1412
|
|
|
493
|
-
The previous model assembled every group's impl into a single root `confect/impl.ts` (plus `confect/nodeImpl.ts`), which `confect codegen` emitted as the aggregate `_generated/registeredFunctions.ts`. Every generated `convex/` module
|
|
1413
|
+
The previous model assembled every group's impl into a single root `confect/impl.ts` (plus `confect/nodeImpl.ts`), which `confect codegen` emitted as the aggregate `_generated/registeredFunctions.ts`. Every generated `convex/` module—one per Convex function—imported from that aggregate, so loading any single query, mutation, or action transitively loaded the impl module of every other Convex function in the project, along with all of their dependencies. For large projects this inflated each function's bundle and added meaningful cold-start cost on Convex.
|
|
494
1414
|
|
|
495
|
-
Splitting impl across colocated `*.impl.ts` files is the vehicle for fixing that. With this change, `confect codegen` emits one `_generated/registeredFunctions/{path}.ts` per group, and each generated `convex/` module imports only its own group's per-group registry
|
|
1415
|
+
Splitting impl across colocated `*.impl.ts` files is the vehicle for fixing that. With this change, `confect codegen` emits one `_generated/registeredFunctions/{path}.ts` per group, and each generated `convex/` module imports only its own group's per-group registry—which in turn imports only its own sibling `.impl.ts`. A Convex function's cold-start bundle now scales with its own group's impl rather than with the size of the whole project.
|
|
496
1416
|
|
|
497
1417
|
### Breaking changes
|
|
498
1418
|
- `GroupSpec.make()` and `GroupSpec.makeNode()` no longer take a name argument; the group name is derived from the spec file's path within `confect/`.
|