@confect/core 10.0.0-next.9 → 10.1.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 +964 -47
- 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 +20 -19
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +22 -21
- 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 +40 -42
- 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,11 +1,869 @@
|
|
|
1
1
|
# @confect/core
|
|
2
2
|
|
|
3
|
+
## 10.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 89daa88: Fix `Table.Doc` to enforce checks attached to table structs and unions when decoding and encoding documents, and preserve a union's `oneOf` mode.
|
|
8
|
+
|
|
9
|
+
## 10.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- 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.
|
|
14
|
+
|
|
15
|
+
### Requirements
|
|
16
|
+
- All Confect packages require Node.js 24 or later and `effect ^4.0.0`.
|
|
17
|
+
- `@confect/server` requires `convex ^1.45.0`.
|
|
18
|
+
- `@confect/server`'s optional `@effect/platform-node` peer requires `^4.0.0` for Node actions.
|
|
19
|
+
- The new `@confect/foldkit` package requires `foldkit ^0.165.0`.
|
|
20
|
+
|
|
21
|
+
Confect no longer depends on `@effect/platform` or `@effect/cli`. Run `confect codegen` to regenerate the v10 bindings after updating your Confect declarations.
|
|
22
|
+
|
|
23
|
+
### Breaking changes
|
|
24
|
+
|
|
25
|
+
#### Declare function arguments as lazy field maps
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
**Before:**
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { FunctionSpec } from "@confect/core";
|
|
33
|
+
import * as Schema from "effect/Schema";
|
|
34
|
+
|
|
35
|
+
FunctionSpec.publicQuery({
|
|
36
|
+
name: "greet",
|
|
37
|
+
args: () => Schema.Struct({ name: Schema.String }),
|
|
38
|
+
returns: () => Schema.String,
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**After:**
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { FunctionSpec } from "@confect/core";
|
|
46
|
+
import * as Schema from "effect/Schema";
|
|
47
|
+
|
|
48
|
+
FunctionSpec.publicQuery({
|
|
49
|
+
name: "greet",
|
|
50
|
+
args: () => ({ name: Schema.String }),
|
|
51
|
+
returns: () => Schema.String,
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Keep table declarations client-safe
|
|
56
|
+
|
|
57
|
+
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.
|
|
58
|
+
|
|
59
|
+
**Before:**
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { Table } from "@confect/server";
|
|
63
|
+
import * as Schema from "effect/Schema";
|
|
64
|
+
|
|
65
|
+
export default Table.make(() => Schema.Struct({ text: Schema.String }));
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**After:**
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { Table } from "@confect/core";
|
|
72
|
+
import * as Schema from "effect/Schema";
|
|
73
|
+
|
|
74
|
+
export default Table.make(() => Schema.Struct({ text: Schema.String }));
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
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.
|
|
78
|
+
|
|
79
|
+
#### Use serializable schemas and handle updated errors
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
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.
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
|
|
87
|
+
#### Replace HTTP API mounts with route layers
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
For an API named `Api` and its group handler layer `ApiLive`:
|
|
92
|
+
|
|
93
|
+
**Before:**
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { HttpApi as ConfectHttpApi } from "@confect/server";
|
|
97
|
+
import * as HttpApiBuilder from "@effect/platform/HttpApiBuilder";
|
|
98
|
+
import * as Layer from "effect/Layer";
|
|
99
|
+
|
|
100
|
+
export default ConfectHttpApi.make({
|
|
101
|
+
"/api/": {
|
|
102
|
+
apiLive: HttpApiBuilder.api(Api).pipe(Layer.provide(ApiLive)),
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**After:**
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { HttpRouter as ConfectHttpRouter } from "@confect/server";
|
|
111
|
+
import * as Layer from "effect/Layer";
|
|
112
|
+
import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
|
|
113
|
+
import * as HttpApiScalar from "effect/http-api/HttpApiScalar";
|
|
114
|
+
|
|
115
|
+
export default ConfectHttpRouter.make(
|
|
116
|
+
Layer.mergeAll(
|
|
117
|
+
HttpApiBuilder.layer(Api).pipe(Layer.provide(ApiLive)),
|
|
118
|
+
HttpApiScalar.layer(Api, { path: "/api/docs" }),
|
|
119
|
+
),
|
|
120
|
+
);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
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.
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
#### Call named runner methods
|
|
128
|
+
|
|
129
|
+
`QueryRunner`, `MutationRunner`, and `ActionRunner` are no longer callable services. Destructure `runQuery`, `runMutation`, or `runAction` instead.
|
|
130
|
+
|
|
131
|
+
**Before:**
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import * as Effect from "effect/Effect";
|
|
135
|
+
|
|
136
|
+
const firstNote = Effect.gen(function* () {
|
|
137
|
+
const runQuery = yield* QueryRunner;
|
|
138
|
+
return yield* runQuery(refs.public.notes.getFirst, {});
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**After:**
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import * as Effect from "effect/Effect";
|
|
146
|
+
|
|
147
|
+
const firstNote = Effect.gen(function* () {
|
|
148
|
+
const { runQuery } = yield* QueryRunner;
|
|
149
|
+
return yield* runQuery(refs.public.notes.getFirst, {});
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
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.
|
|
154
|
+
|
|
155
|
+
#### Yield upload URL generation directly
|
|
156
|
+
|
|
157
|
+
`StorageWriter.generateUploadUrl` is an Effect value instead of a zero-argument function.
|
|
158
|
+
|
|
159
|
+
**Before:**
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import * as Effect from "effect/Effect";
|
|
163
|
+
|
|
164
|
+
const uploadUrl = Effect.gen(function* () {
|
|
165
|
+
const storage = yield* StorageWriter;
|
|
166
|
+
return yield* storage.generateUploadUrl();
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**After:**
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
import * as Effect from "effect/Effect";
|
|
174
|
+
|
|
175
|
+
const uploadUrl = Effect.gen(function* () {
|
|
176
|
+
const storage = yield* StorageWriter;
|
|
177
|
+
return yield* storage.generateUploadUrl;
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Methods that take arguments, such as `delete(storageId)`, remain functions.
|
|
182
|
+
|
|
183
|
+
#### Provide test layers without an extra call
|
|
184
|
+
|
|
185
|
+
`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`:
|
|
186
|
+
|
|
187
|
+
**Before:**
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const test = testEffect.pipe(Effect.provide(TestConfect.layer()));
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**After:**
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
const test = testEffect.pipe(Effect.provide(TestConfect.layer));
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Each separate provision still creates a fresh test database.
|
|
200
|
+
|
|
201
|
+
#### Update handwritten container annotations
|
|
202
|
+
|
|
203
|
+
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.
|
|
204
|
+
|
|
205
|
+
**Before:**
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
type AppSpec = Spec.Spec<typeof notesGroup>;
|
|
209
|
+
type AppSchema = DatabaseSchema.DatabaseSchema<typeof notesTable>;
|
|
210
|
+
type AppDataModel = DataModel.DataModel<typeof notesTable>;
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**After:**
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
type AppSpec = Spec.Spec<{ readonly notes: typeof notesGroup }>;
|
|
217
|
+
type AppSchema = DatabaseSchema.DatabaseSchema<{
|
|
218
|
+
readonly notes: typeof notesTable;
|
|
219
|
+
}>;
|
|
220
|
+
type AppDataModel = DataModel.DataModel<{
|
|
221
|
+
readonly notes: typeof notesTable;
|
|
222
|
+
}>;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
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.
|
|
226
|
+
|
|
227
|
+
#### Review configuration and time-dependent queries
|
|
228
|
+
|
|
229
|
+
Confect's configuration provider now treats empty-string environment variables as missing values, so `Config.withDefault` and `Config.option` recover from them.
|
|
230
|
+
|
|
231
|
+
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.
|
|
232
|
+
|
|
233
|
+
### Middleware with typed services and errors
|
|
234
|
+
|
|
235
|
+
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.
|
|
236
|
+
|
|
237
|
+
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.
|
|
238
|
+
|
|
239
|
+
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.
|
|
240
|
+
|
|
241
|
+
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.
|
|
242
|
+
|
|
243
|
+
### Experimental composable query streams
|
|
244
|
+
|
|
245
|
+
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.
|
|
246
|
+
|
|
247
|
+
```ts
|
|
248
|
+
import { QueryStream } from "@confect/server";
|
|
249
|
+
import * as Effect from "effect/Effect";
|
|
250
|
+
|
|
251
|
+
const firstPage = Effect.gen(function* () {
|
|
252
|
+
const reader = yield* DatabaseReader;
|
|
253
|
+
const stream = reader.table("notes").stream("by_creation_time");
|
|
254
|
+
return yield* QueryStream.paginate(stream, {
|
|
255
|
+
cursor: null,
|
|
256
|
+
numItems: 20,
|
|
257
|
+
maximumRowsRead: 1000,
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
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.
|
|
263
|
+
|
|
264
|
+
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.
|
|
265
|
+
|
|
266
|
+
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`.
|
|
267
|
+
|
|
268
|
+
### Foldkit client bindings
|
|
269
|
+
|
|
270
|
+
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.
|
|
271
|
+
|
|
272
|
+
`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.
|
|
273
|
+
|
|
274
|
+
### Convex AI gateway models
|
|
275
|
+
|
|
276
|
+
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.
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
import {
|
|
280
|
+
AiGatewayLanguageClient,
|
|
281
|
+
AiGatewayLanguageModel,
|
|
282
|
+
} from "@confect/server";
|
|
283
|
+
import * as Layer from "effect/Layer";
|
|
284
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
285
|
+
|
|
286
|
+
const Claude = AiGatewayLanguageModel.model(
|
|
287
|
+
"anthropic/claude-sonnet-4.5",
|
|
288
|
+
).pipe(
|
|
289
|
+
Layer.provide(AiGatewayLanguageClient.layer),
|
|
290
|
+
Layer.provide(FetchHttpClient.layer),
|
|
291
|
+
);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
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.
|
|
295
|
+
|
|
296
|
+
### Storage, metadata, logging, and authentication
|
|
297
|
+
- 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.
|
|
298
|
+
- Cancel scheduled functions with `Scheduler.cancel(id)`, using the ID returned by `runAfter` or `runAt`.
|
|
299
|
+
- 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.
|
|
300
|
+
- `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.
|
|
301
|
+
- 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.
|
|
302
|
+
- JavaScript clients support per-module imports such as `@confect/js/WebSocketClient` and `@confect/js/HttpClient`; root imports are unchanged.
|
|
303
|
+
|
|
304
|
+
### Fixes and diagnostics
|
|
305
|
+
- Preserve precise function error types when `exactOptionalPropertyTypes` is disabled, rather than widening functions without declared errors to `any`.
|
|
306
|
+
- Exclude `_id` and `_creationTime` from patch value types derived from full documents.
|
|
307
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect.
|
|
308
|
+
- 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.
|
|
309
|
+
- Keep queries, mutations, and module initialization compatible with Convex's timer restrictions during long Effect computations.
|
|
310
|
+
- Fail codegen with a descriptive error for malformed `convex.json` instead of silently ignoring it.
|
|
311
|
+
- Add tracing spans for client calls, server functions, database writes and pagination, stream consumers, and code-generation passes.
|
|
312
|
+
|
|
313
|
+
## 10.0.0-next.27
|
|
314
|
+
|
|
315
|
+
### Minor Changes
|
|
316
|
+
|
|
317
|
+
- 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.
|
|
318
|
+
|
|
319
|
+
## 10.0.0-next.26
|
|
320
|
+
|
|
321
|
+
No changes in this release.
|
|
322
|
+
|
|
323
|
+
## 10.0.0-next.25
|
|
324
|
+
|
|
325
|
+
### Patch Changes
|
|
326
|
+
|
|
327
|
+
- 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.
|
|
328
|
+
|
|
329
|
+
## 10.0.0-next.24
|
|
330
|
+
|
|
331
|
+
### Patch Changes
|
|
332
|
+
|
|
333
|
+
- 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.
|
|
334
|
+
|
|
335
|
+
## 10.0.0-next.23
|
|
336
|
+
|
|
337
|
+
### Major Changes
|
|
338
|
+
|
|
339
|
+
- 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.
|
|
340
|
+
|
|
341
|
+
### Breaking Changes
|
|
342
|
+
- The `Spec.groups` and `DatabaseSchema.tables` accessors replace the corresponding instance properties.
|
|
343
|
+
- `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.
|
|
344
|
+
|
|
345
|
+
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.
|
|
346
|
+
|
|
347
|
+
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.
|
|
348
|
+
|
|
349
|
+
### Patch Changes
|
|
350
|
+
|
|
351
|
+
- 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`.
|
|
352
|
+
|
|
353
|
+
## 10.0.0-next.22
|
|
354
|
+
|
|
355
|
+
### Major Changes
|
|
356
|
+
|
|
357
|
+
- 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
|
|
358
|
+
|
|
359
|
+
### Stream queries and pagination
|
|
360
|
+
|
|
361
|
+
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.
|
|
362
|
+
|
|
363
|
+
`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.
|
|
364
|
+
|
|
365
|
+
Use React's new `useStreamPaginatedQuery` for these queries:
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
import { useStreamPaginatedQuery } from "@confect/react";
|
|
369
|
+
|
|
370
|
+
const { results, status, loadMore } = useStreamPaginatedQuery(
|
|
371
|
+
refs.public.notes.feed,
|
|
372
|
+
{},
|
|
373
|
+
{
|
|
374
|
+
initialNumItems: 10,
|
|
375
|
+
maximumRowsRead: 1000,
|
|
376
|
+
maximumBytesRead: 512 * 1024,
|
|
377
|
+
},
|
|
378
|
+
);
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
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.
|
|
382
|
+
|
|
383
|
+
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.
|
|
384
|
+
|
|
385
|
+
### Middleware options
|
|
386
|
+
|
|
387
|
+
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.
|
|
388
|
+
|
|
389
|
+
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.
|
|
390
|
+
|
|
391
|
+
### Breaking changes
|
|
392
|
+
|
|
393
|
+
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`:
|
|
394
|
+
|
|
395
|
+
**Before:**
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
(effect, { name, args }) => effect;
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
**After:**
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
(effect, { invocation: { name, args } }) => effect;
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
|
|
408
|
+
|
|
409
|
+
### Fixes and tracing
|
|
410
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
|
|
411
|
+
- 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.
|
|
412
|
+
|
|
413
|
+
### Patch Changes
|
|
414
|
+
|
|
415
|
+
- 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.
|
|
416
|
+
|
|
417
|
+
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.
|
|
418
|
+
|
|
419
|
+
- 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.
|
|
420
|
+
- f721d2c: Remove spaces around em dashes and separator slashes in API documentation and `confect codegen` diagnostics.
|
|
421
|
+
|
|
422
|
+
## 10.0.0-next.21
|
|
423
|
+
|
|
424
|
+
### Major Changes
|
|
425
|
+
|
|
426
|
+
- a6425c5: Raise the minimum supported Node.js version to 24.
|
|
427
|
+
|
|
428
|
+
### Breaking Changes
|
|
429
|
+
- `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
|
|
430
|
+
|
|
431
|
+
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.
|
|
432
|
+
|
|
433
|
+
## 10.0.0-next.20
|
|
434
|
+
|
|
435
|
+
## 10.0.0-next.19
|
|
436
|
+
|
|
437
|
+
### Minor Changes
|
|
438
|
+
|
|
439
|
+
- 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.
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
import * as Confect from "@confect/foldkit";
|
|
443
|
+
import * as Schema from "effect/Schema";
|
|
444
|
+
import * as Subscription from "foldkit/subscription";
|
|
445
|
+
|
|
446
|
+
const SaveNote = Confect.Command.mutation(
|
|
447
|
+
"SaveNote",
|
|
448
|
+
refs.public.notes.insert,
|
|
449
|
+
{
|
|
450
|
+
messages: [SucceededSaveNote, FailedSaveNote],
|
|
451
|
+
onSuccess: (noteId) => SucceededSaveNote({ noteId }),
|
|
452
|
+
onError: (error) => FailedSaveNote({ message: String(error) }),
|
|
453
|
+
},
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const subscriptions = Subscription.make<
|
|
457
|
+
Model,
|
|
458
|
+
Message,
|
|
459
|
+
Confect.Client.Client
|
|
460
|
+
>()(() => ({
|
|
461
|
+
note: Confect.Subscription.reactiveQuery<Model>()(refs.public.notes.get, {
|
|
462
|
+
args: (model) => Option.map(model.noteId, (noteId) => ({ noteId })),
|
|
463
|
+
onSuccess: (note) => SucceededGetNote({ note }),
|
|
464
|
+
onError: (error) => FailedGetNote({ message: String(error) }),
|
|
465
|
+
}),
|
|
466
|
+
}));
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
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.
|
|
470
|
+
|
|
471
|
+
`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.
|
|
472
|
+
|
|
473
|
+
`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.
|
|
474
|
+
|
|
475
|
+
```ts
|
|
476
|
+
const Notes = Confect.PaginatedQuery.make(refs.public.notes.paginate);
|
|
477
|
+
|
|
478
|
+
// Model: notes: Notes.schema
|
|
479
|
+
// Initial Model value: notes: Notes.idle
|
|
480
|
+
// Message: settlement: Notes.settlement
|
|
481
|
+
// update after matching Idle: Notes.init(idle, { channel }, { initialNumItems: 20 })
|
|
482
|
+
|
|
483
|
+
const subscriptions = Subscription.make<
|
|
484
|
+
Model,
|
|
485
|
+
Message,
|
|
486
|
+
Confect.Client.Client
|
|
487
|
+
>()(() => ({
|
|
488
|
+
notesPage: Confect.Subscription.paginatedQuery<Model>()(Notes, {
|
|
489
|
+
state: (model) => model.notes,
|
|
490
|
+
onSettled: (settlement) => SettledGetNotesPage({ settlement }),
|
|
491
|
+
}),
|
|
492
|
+
}));
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
- 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.
|
|
496
|
+
|
|
497
|
+
## 10.0.0-next.18
|
|
498
|
+
|
|
499
|
+
### Minor Changes
|
|
500
|
+
|
|
501
|
+
- 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.
|
|
502
|
+
|
|
503
|
+
```ts confect/tables/notes.ts
|
|
504
|
+
import { Table } from "@confect/core";
|
|
505
|
+
import * as Schema from "effect/Schema";
|
|
506
|
+
|
|
507
|
+
export default Table.make(() =>
|
|
508
|
+
Schema.Struct({
|
|
509
|
+
text: Schema.String,
|
|
510
|
+
}),
|
|
511
|
+
);
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
`confect codegen` now fails if any module a spec reaches value-imports `@confect/server`, including `confect/tables/` and `_generated/`. Type-only imports remain allowed.
|
|
515
|
+
|
|
516
|
+
## 10.0.0-next.17
|
|
517
|
+
|
|
518
|
+
### Minor Changes
|
|
519
|
+
|
|
520
|
+
- 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.
|
|
521
|
+
|
|
522
|
+
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/...`.
|
|
523
|
+
|
|
524
|
+
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`:
|
|
525
|
+
|
|
526
|
+
```ts confect/middleware/RequireUser.spec.ts
|
|
527
|
+
import { MiddlewareSpec } from "@confect/core";
|
|
528
|
+
|
|
529
|
+
export class CurrentUser extends Context.Service<
|
|
530
|
+
CurrentUser,
|
|
531
|
+
{
|
|
532
|
+
readonly user: User;
|
|
533
|
+
}
|
|
534
|
+
>()("confect/middleware/RequireUser.spec/CurrentUser") {}
|
|
535
|
+
|
|
536
|
+
export class NotSignedIn extends Schema.TaggedError<NotSignedIn>()(
|
|
537
|
+
"NotSignedIn",
|
|
538
|
+
{},
|
|
539
|
+
) {}
|
|
540
|
+
|
|
541
|
+
export default class RequireUser extends MiddlewareSpec.MiddlewareSpec<
|
|
542
|
+
RequireUser,
|
|
543
|
+
{
|
|
544
|
+
provides: CurrentUser;
|
|
545
|
+
}
|
|
546
|
+
>()("RequireUser", {
|
|
547
|
+
error: () => NotSignedIn,
|
|
548
|
+
functionTypes: { query: true, mutation: true, action: false },
|
|
549
|
+
}) {}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
```ts confect/notes.spec.ts
|
|
553
|
+
import RequireUser from "./middleware/RequireUser.spec";
|
|
554
|
+
|
|
555
|
+
export default GroupSpec.make()
|
|
556
|
+
.middleware(RequireUser)
|
|
557
|
+
.addFunction(FunctionSpec.publicMutation({ ... }));
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
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:
|
|
561
|
+
|
|
562
|
+
```ts confect/middleware/RequireUser.impl.ts
|
|
563
|
+
import { MiddlewareImpl } from "@confect/server";
|
|
564
|
+
|
|
565
|
+
export default MiddlewareImpl.provides(
|
|
566
|
+
databaseSchema,
|
|
567
|
+
RequireUser,
|
|
568
|
+
CurrentUser,
|
|
569
|
+
Effect.gen(function* () {
|
|
570
|
+
// load the user; `return yield* new NotSignedIn()` short-circuits
|
|
571
|
+
return { user };
|
|
572
|
+
}),
|
|
573
|
+
);
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
```ts confect/notes.impl.ts
|
|
577
|
+
import RequireUser from "./middleware/RequireUser.impl";
|
|
578
|
+
|
|
579
|
+
export default GroupImpl.make(databaseSchema, group).pipe(
|
|
580
|
+
Layer.provide(createNote),
|
|
581
|
+
Layer.provide(RequireUser), // omitting this is a compile error at `GroupImpl.finalize`
|
|
582
|
+
GroupImpl.finalize,
|
|
583
|
+
);
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
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.
|
|
587
|
+
|
|
588
|
+
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:
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
FunctionSpec.publicMutation({ name: "deleteAll", ... }).middleware(RequireAdmin);
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
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.
|
|
595
|
+
|
|
596
|
+
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.
|
|
597
|
+
|
|
598
|
+
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.
|
|
599
|
+
|
|
600
|
+
### Patch Changes
|
|
601
|
+
|
|
602
|
+
- 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.
|
|
603
|
+
|
|
604
|
+
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/*`.
|
|
605
|
+
|
|
606
|
+
## 10.0.0-next.16
|
|
607
|
+
|
|
608
|
+
### Major Changes
|
|
609
|
+
|
|
610
|
+
- 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/*`).
|
|
611
|
+
|
|
612
|
+
Breaking changes for users:
|
|
613
|
+
|
|
614
|
+
- **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.
|
|
615
|
+
- **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.
|
|
616
|
+
- **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.
|
|
617
|
+
- **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`).
|
|
618
|
+
- **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.
|
|
619
|
+
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
620
|
+
- **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.
|
|
621
|
+
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
622
|
+
- 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.
|
|
623
|
+
|
|
624
|
+
### Patch Changes
|
|
625
|
+
|
|
626
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.100` (from `^4.0.0-beta.99`).
|
|
627
|
+
|
|
628
|
+
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.
|
|
629
|
+
|
|
630
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.101` (from `^4.0.0-beta.100`).
|
|
631
|
+
|
|
632
|
+
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.
|
|
633
|
+
|
|
634
|
+
- 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.
|
|
635
|
+
- 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.
|
|
636
|
+
|
|
637
|
+
`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.
|
|
638
|
+
|
|
639
|
+
`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.
|
|
640
|
+
|
|
641
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
642
|
+
|
|
643
|
+
**Before:**
|
|
644
|
+
|
|
645
|
+
```ts
|
|
646
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
647
|
+
"NoteNotFound",
|
|
648
|
+
{ noteId: Id("notes") },
|
|
649
|
+
) {}
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
**After:**
|
|
653
|
+
|
|
654
|
+
```ts
|
|
655
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
656
|
+
"NoteNotFound",
|
|
657
|
+
{ noteId: Id("notes") },
|
|
658
|
+
) {}
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
`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.
|
|
662
|
+
|
|
663
|
+
`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.
|
|
664
|
+
|
|
665
|
+
- 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.
|
|
666
|
+
|
|
667
|
+
`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.
|
|
668
|
+
|
|
669
|
+
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.
|
|
670
|
+
|
|
671
|
+
**Before:**
|
|
672
|
+
|
|
673
|
+
```ts
|
|
674
|
+
const NoteArbitrary = Schema.toArbitrary(Note);
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
**After:**
|
|
678
|
+
|
|
679
|
+
```ts
|
|
680
|
+
import * as FastCheck from "fast-check";
|
|
681
|
+
|
|
682
|
+
const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
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.
|
|
686
|
+
|
|
687
|
+
- 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.
|
|
688
|
+
|
|
689
|
+
`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.
|
|
690
|
+
|
|
691
|
+
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.
|
|
692
|
+
|
|
693
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
694
|
+
|
|
695
|
+
`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.
|
|
696
|
+
|
|
697
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
|
|
698
|
+
|
|
699
|
+
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.
|
|
700
|
+
|
|
701
|
+
- 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/*`.
|
|
702
|
+
|
|
703
|
+
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.
|
|
704
|
+
|
|
705
|
+
Before:
|
|
706
|
+
|
|
707
|
+
```ts
|
|
708
|
+
import type { SchemaError } from "effect/SchemaError";
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
After:
|
|
712
|
+
|
|
713
|
+
```ts
|
|
714
|
+
import type { SchemaError } from "effect/Schema";
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
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.
|
|
718
|
+
|
|
719
|
+
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.
|
|
720
|
+
|
|
721
|
+
- 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.
|
|
722
|
+
|
|
723
|
+
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/*`.
|
|
724
|
+
|
|
725
|
+
- 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.
|
|
726
|
+
|
|
727
|
+
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/*`.
|
|
728
|
+
|
|
729
|
+
- 3f0255c: Build and test against `convex` 1.44.0. The published `convex` peer ranges are unchanged, so no consumer action is required.
|
|
730
|
+
- 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.
|
|
731
|
+
|
|
732
|
+
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.
|
|
733
|
+
|
|
734
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4—see those versions' changelog entries.
|
|
735
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
|
|
736
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
|
|
737
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
|
|
738
|
+
|
|
739
|
+
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.
|
|
740
|
+
|
|
741
|
+
- 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.
|
|
742
|
+
|
|
743
|
+
## 10.0.0-next.15
|
|
744
|
+
|
|
745
|
+
### Patch Changes
|
|
746
|
+
|
|
747
|
+
- 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.
|
|
748
|
+
|
|
749
|
+
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/*`.
|
|
750
|
+
|
|
751
|
+
## 10.0.0-next.14
|
|
752
|
+
|
|
753
|
+
### Patch Changes
|
|
754
|
+
|
|
755
|
+
- 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/*`.
|
|
756
|
+
|
|
757
|
+
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.
|
|
758
|
+
|
|
759
|
+
Before:
|
|
760
|
+
|
|
761
|
+
```ts
|
|
762
|
+
import type { SchemaError } from "effect/SchemaError";
|
|
763
|
+
```
|
|
764
|
+
|
|
765
|
+
After:
|
|
766
|
+
|
|
767
|
+
```ts
|
|
768
|
+
import type { SchemaError } from "effect/Schema";
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
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.
|
|
772
|
+
|
|
773
|
+
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.
|
|
774
|
+
|
|
775
|
+
- 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.
|
|
776
|
+
|
|
777
|
+
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.
|
|
778
|
+
|
|
779
|
+
- 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.
|
|
780
|
+
|
|
781
|
+
## 10.0.0-next.13
|
|
782
|
+
|
|
783
|
+
### Patch Changes
|
|
784
|
+
|
|
785
|
+
- 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.
|
|
786
|
+
|
|
787
|
+
`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.
|
|
788
|
+
|
|
789
|
+
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.
|
|
790
|
+
|
|
791
|
+
## 10.0.0-next.12
|
|
792
|
+
|
|
793
|
+
### Patch Changes
|
|
794
|
+
|
|
795
|
+
- 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.
|
|
796
|
+
|
|
797
|
+
`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.
|
|
798
|
+
|
|
799
|
+
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.
|
|
800
|
+
|
|
801
|
+
**Before:**
|
|
802
|
+
|
|
803
|
+
```ts
|
|
804
|
+
const NoteArbitrary = Schema.toArbitrary(Note);
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
**After:**
|
|
808
|
+
|
|
809
|
+
```ts
|
|
810
|
+
import * as FastCheck from "fast-check";
|
|
811
|
+
|
|
812
|
+
const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
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.
|
|
816
|
+
|
|
817
|
+
## 10.0.0-next.11
|
|
818
|
+
|
|
819
|
+
### Patch Changes
|
|
820
|
+
|
|
821
|
+
- 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.
|
|
822
|
+
|
|
823
|
+
`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.
|
|
824
|
+
|
|
825
|
+
`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.
|
|
826
|
+
|
|
827
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
828
|
+
|
|
829
|
+
**Before:**
|
|
830
|
+
|
|
831
|
+
```ts
|
|
832
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
833
|
+
"NoteNotFound",
|
|
834
|
+
{ noteId: Id("notes") },
|
|
835
|
+
) {}
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
**After:**
|
|
839
|
+
|
|
840
|
+
```ts
|
|
841
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
842
|
+
"NoteNotFound",
|
|
843
|
+
{ noteId: Id("notes") },
|
|
844
|
+
) {}
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
`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.
|
|
848
|
+
|
|
849
|
+
`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.
|
|
850
|
+
|
|
851
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
|
|
852
|
+
|
|
853
|
+
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.
|
|
854
|
+
|
|
855
|
+
## 10.0.0-next.10
|
|
856
|
+
|
|
857
|
+
### Patch Changes
|
|
858
|
+
|
|
859
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
|
|
860
|
+
|
|
3
861
|
## 10.0.0-next.9
|
|
4
862
|
|
|
5
863
|
### Patch Changes
|
|
6
864
|
|
|
7
865
|
- 0dcc0fb: Raise the required `effect` peer version to `^4.0.0-beta.102` (from `^4.0.0-beta.101`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
8
|
-
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5
|
|
866
|
+
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
|
|
9
867
|
|
|
10
868
|
## 10.0.0-next.8
|
|
11
869
|
|
|
@@ -39,7 +897,7 @@
|
|
|
39
897
|
|
|
40
898
|
This is a peer-range-only change with no consumer-visible API consequences. The `beta.99` release only touches `Graph`, CLI (`Command`/`CliConfig`/wizard mode), `Tool` cloning, Redis script eval, and multipart parser internals that Confect doesn't use.
|
|
41
899
|
|
|
42
|
-
- 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4
|
|
900
|
+
- 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4—see those versions' changelog entries.
|
|
43
901
|
|
|
44
902
|
## 10.0.0-next.1
|
|
45
903
|
|
|
@@ -47,7 +905,7 @@
|
|
|
47
905
|
|
|
48
906
|
- 4d98ea8: Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
49
907
|
|
|
50
|
-
`effect`'s `SchemaError` is now exposed as its own public module (`effect/SchemaError`), which changes the import path TypeScript picks when Confect emits `.d.ts` declarations that reference `Schema.SchemaError` (for example in generated `services.d.ts`). Existing `Schema.SchemaError
|
|
908
|
+
`effect`'s `SchemaError` is now exposed as its own public module (`effect/SchemaError`), which changes the import path TypeScript picks when Confect emits `.d.ts` declarations that reference `Schema.SchemaError` (for example in generated `services.d.ts`). Existing `Schema.SchemaError`/`Schema.isSchemaError` usage is unaffected—this is purely a declaration-emit detail that consumers relying on generated types may notice.
|
|
51
909
|
|
|
52
910
|
## 10.0.0-next.0
|
|
53
911
|
|
|
@@ -57,14 +915,73 @@
|
|
|
57
915
|
|
|
58
916
|
Breaking changes for users:
|
|
59
917
|
- **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.
|
|
60
|
-
- **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)
|
|
61
|
-
- **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these
|
|
918
|
+
- **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.
|
|
919
|
+
- **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.
|
|
62
920
|
- **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`).
|
|
63
|
-
- **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
|
|
921
|
+
- **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.
|
|
64
922
|
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
65
923
|
- **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.
|
|
66
924
|
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
67
|
-
- 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
|
|
925
|
+
- 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.
|
|
926
|
+
|
|
927
|
+
## 9.4.2
|
|
928
|
+
|
|
929
|
+
## 9.4.1
|
|
930
|
+
|
|
931
|
+
### Patch Changes
|
|
932
|
+
|
|
933
|
+
- 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.
|
|
934
|
+
|
|
935
|
+
## 9.4.0
|
|
936
|
+
|
|
937
|
+
## 9.3.0
|
|
938
|
+
|
|
939
|
+
### Minor Changes
|
|
940
|
+
|
|
941
|
+
- 16b5ad6: Add first-class paginated queries: declare one with `FunctionSpec.publicPaginatedQuery` (or `internalPaginatedQuery`) and read it with the new `usePaginatedQuery` hook from `@confect/react`.
|
|
942
|
+
|
|
943
|
+
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`.
|
|
944
|
+
|
|
945
|
+
```ts
|
|
946
|
+
// confect/notes.spec.ts
|
|
947
|
+
FunctionSpec.publicPaginatedQuery({
|
|
948
|
+
name: "listByAuthor",
|
|
949
|
+
args: () => Schema.Struct({ author: Schema.String }),
|
|
950
|
+
item: () => notes.Doc,
|
|
951
|
+
});
|
|
952
|
+
|
|
953
|
+
// confect/notes.impl.ts
|
|
954
|
+
({ author, paginationOpts }) =>
|
|
955
|
+
Effect.gen(function* () {
|
|
956
|
+
const reader = yield* DatabaseReader;
|
|
957
|
+
|
|
958
|
+
return yield* reader
|
|
959
|
+
.table("notes")
|
|
960
|
+
.index("by_creation_time", "desc")
|
|
961
|
+
.paginate(paginationOpts, (q) => q.eq(q.field("author"), author));
|
|
962
|
+
}).pipe(Effect.orDie);
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
Declaring `paginationOpts` in `args` yourself is a type and runtime error.
|
|
966
|
+
|
|
967
|
+
```tsx
|
|
968
|
+
import { PaginatedQueryResult, usePaginatedQuery } from "@confect/react";
|
|
969
|
+
|
|
970
|
+
const notes = usePaginatedQuery(
|
|
971
|
+
refs.public.notes.listByAuthor,
|
|
972
|
+
{ author },
|
|
973
|
+
{ initialNumItems: 10 },
|
|
974
|
+
);
|
|
975
|
+
|
|
976
|
+
// `notes.results` holds the pages decoded through `item`.
|
|
977
|
+
if (PaginatedQueryResult.isCanLoadMore(notes)) {
|
|
978
|
+
notes.loadMore(10);
|
|
979
|
+
}
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
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.
|
|
983
|
+
|
|
984
|
+
`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.
|
|
68
985
|
|
|
69
986
|
## 9.2.5
|
|
70
987
|
|
|
@@ -88,7 +1005,7 @@
|
|
|
88
1005
|
|
|
89
1006
|
- 8d63382: Fix `TS7056` ("inferred type … exceeds the maximum length the compiler will serialize") when compiling a Confect backend with declaration emit.
|
|
90
1007
|
|
|
91
|
-
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
|
|
1008
|
+
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.
|
|
92
1009
|
|
|
93
1010
|
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.
|
|
94
1011
|
|
|
@@ -110,7 +1027,7 @@
|
|
|
110
1027
|
|
|
111
1028
|
- 445ea9b: Loosen and align dependency ranges across all packages:
|
|
112
1029
|
- 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.
|
|
113
|
-
- `@confect/server`'s `@effect/platform-node` peer dependency is now optional
|
|
1030
|
+
- `@confect/server`'s `@effect/platform-node` peer dependency is now optional—it is only needed when using the `@confect/server/node` entrypoint.
|
|
114
1031
|
- `@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`.
|
|
115
1032
|
- `@confect/test` now accepts any `convex-test` release in `>=0.0.50 <0.1.0` instead of exactly 0.0.50.
|
|
116
1033
|
|
|
@@ -126,8 +1043,8 @@
|
|
|
126
1043
|
|
|
127
1044
|
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.
|
|
128
1045
|
- Each `*.spec.ts` `export default`s its `GroupSpec` (named co-exports like error classes are still allowed).
|
|
129
|
-
- Each `*.impl.ts` default-imports its sibling spec, passes it to `FunctionImpl.make
|
|
130
|
-
- 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
|
|
1046
|
+
- 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.
|
|
1047
|
+
- 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.
|
|
131
1048
|
|
|
132
1049
|
### Tables are the source of truth, named by their filename
|
|
133
1050
|
|
|
@@ -158,7 +1075,7 @@
|
|
|
158
1075
|
|
|
159
1076
|
### Specs and impls: lazy schemas, and impls take the `DatabaseSchema`
|
|
160
1077
|
|
|
161
|
-
`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
|
|
1078
|
+
`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.
|
|
162
1079
|
|
|
163
1080
|
**Before:**
|
|
164
1081
|
|
|
@@ -206,7 +1123,7 @@
|
|
|
206
1123
|
|
|
207
1124
|
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.
|
|
208
1125
|
- A Node group at `confect/email.spec.ts` is now reached at `refs.public.email.send` instead of `refs.public.node.email.send`.
|
|
209
|
-
- `@confect/core` removes `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec
|
|
1126
|
+
- `@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.
|
|
210
1127
|
|
|
211
1128
|
### Less work at cold start
|
|
212
1129
|
|
|
@@ -223,7 +1140,7 @@
|
|
|
223
1140
|
### Migration
|
|
224
1141
|
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`.
|
|
225
1142
|
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"`.
|
|
226
|
-
3. **Impls.** In each `*.impl.ts`, default-import the sibling spec, import `databaseSchema` from `_generated/schema`, pass it to `FunctionImpl.make
|
|
1143
|
+
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).
|
|
227
1144
|
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)`.
|
|
228
1145
|
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`.
|
|
229
1146
|
6. **Optional.** Adopt submodule Effect imports (`import * as Schema from "effect/Schema"`) in your own `confect/` files for the full cold-start savings.
|
|
@@ -249,11 +1166,11 @@
|
|
|
249
1166
|
|
|
250
1167
|
- 4894959: Make Node-runtime functions first-class and remove the separate `node` namespace.
|
|
251
1168
|
|
|
252
|
-
A function group's runtime is now declared solely by its spec
|
|
1169
|
+
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.
|
|
253
1170
|
|
|
254
1171
|
### Why
|
|
255
1172
|
|
|
256
|
-
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
|
|
1173
|
+
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).
|
|
257
1174
|
|
|
258
1175
|
### Breaking changes
|
|
259
1176
|
- **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.
|
|
@@ -261,7 +1178,7 @@
|
|
|
261
1178
|
- **`@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).
|
|
262
1179
|
|
|
263
1180
|
### Migration
|
|
264
|
-
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
|
|
1181
|
+
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.
|
|
265
1182
|
2. Update call sites to drop the `node` segment: `refs.public.node.<group>.<fn>` → `refs.public.<group>.<fn>`.
|
|
266
1183
|
3. Replace `Refs.make(spec, nodeSpec)` with `Refs.make(spec)` (codegen does this for `_generated/refs.ts` automatically).
|
|
267
1184
|
4. Run `confect codegen`. The `convex/` tree and `confect/_generated/` are re-emitted; the stale `_generated/nodeSpec.ts` is removed.
|
|
@@ -276,11 +1193,11 @@
|
|
|
276
1193
|
|
|
277
1194
|
### Why
|
|
278
1195
|
|
|
279
|
-
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
|
|
1196
|
+
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.
|
|
280
1197
|
|
|
281
1198
|
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).
|
|
282
1199
|
|
|
283
|
-
No API changes
|
|
1200
|
+
No API changes—your existing code keeps working.
|
|
284
1201
|
|
|
285
1202
|
### Getting the full win in your own code
|
|
286
1203
|
|
|
@@ -311,13 +1228,13 @@
|
|
|
311
1228
|
|
|
312
1229
|
- 46045a9: Reduce per-function cold-start cost: make `FunctionSpec` schemas lazy and keep each Convex function's bundle scoped to its own group.
|
|
313
1230
|
|
|
314
|
-
Previously, loading a single Convex function still paid for the whole project
|
|
1231
|
+
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.
|
|
315
1232
|
|
|
316
1233
|
### Lazy `FunctionSpec` schemas
|
|
317
1234
|
|
|
318
|
-
`FunctionSpec.*` (`publicQuery
|
|
1235
|
+
`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.
|
|
319
1236
|
|
|
320
|
-
Migration
|
|
1237
|
+
Migration—wrap each schema in `() =>`:
|
|
321
1238
|
|
|
322
1239
|
```diff
|
|
323
1240
|
FunctionSpec.publicQuery({
|
|
@@ -333,9 +1250,9 @@
|
|
|
333
1250
|
|
|
334
1251
|
`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.
|
|
335
1252
|
|
|
336
|
-
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
|
|
1253
|
+
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).
|
|
337
1254
|
|
|
338
|
-
Migration
|
|
1255
|
+
Migration—in each `*.impl.ts`, import the database schema and pass it where you passed `api`/`nodeApi`:
|
|
339
1256
|
|
|
340
1257
|
```diff
|
|
341
1258
|
- import api from "../_generated/api"; // (or nodeApi from "../_generated/nodeApi")
|
|
@@ -352,37 +1269,37 @@
|
|
|
352
1269
|
|
|
353
1270
|
### `buildForGroup` and the generated registries
|
|
354
1271
|
|
|
355
|
-
`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
|
|
1272
|
+
`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.
|
|
356
1273
|
|
|
357
|
-
### `_generated/api.ts
|
|
1274
|
+
### `_generated/api.ts`/`nodeApi.ts` are no longer emitted, and `Api` is removed
|
|
358
1275
|
|
|
359
|
-
Nothing imports them anymore, so `confect codegen` no longer emits `_generated/api.ts
|
|
1276
|
+
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.
|
|
360
1277
|
|
|
361
1278
|
### Net effect
|
|
362
1279
|
|
|
363
1280
|
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.
|
|
364
1281
|
|
|
365
|
-
- 762f7eb: Split the deploy-time Convex schema from the runtime `DatabaseSchema`, make `confect/tables/` the single source of truth
|
|
1282
|
+
- 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.
|
|
366
1283
|
|
|
367
|
-
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
|
|
1284
|
+
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.
|
|
368
1285
|
|
|
369
1286
|
Codegen now scans `confect/tables/*.ts` (every file must default-export a `Table`) and emits two siblings:
|
|
370
|
-
- `confect/_generated/schema.ts
|
|
371
|
-
- `confect/_generated/convexSchema.ts
|
|
1287
|
+
- `confect/_generated/schema.ts`—the runtime `DatabaseSchema`, consumed by `_generated/api.ts`. Imports `@confect/server` but never `convex/server`.
|
|
1288
|
+
- `confect/_generated/convexSchema.ts`—the Convex deploy `SchemaDefinition`, re-exported one-line from `convex/schema.ts`. Imports `convex/server` but never `@confect/server`.
|
|
372
1289
|
|
|
373
1290
|
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.
|
|
374
1291
|
|
|
375
1292
|
### Filename-derived table names
|
|
376
1293
|
|
|
377
|
-
The table name is now derived from the file's basename
|
|
1294
|
+
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.
|
|
378
1295
|
|
|
379
1296
|
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.
|
|
380
1297
|
|
|
381
1298
|
Codegen now emits two new sets of files alongside `_generated/schema.ts` and `_generated/convexSchema.ts`:
|
|
382
|
-
- `confect/_generated/id.ts
|
|
383
|
-
- `confect/_generated/tables/<name>.ts
|
|
1299
|
+
- `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")`.
|
|
1300
|
+
- `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`.
|
|
384
1301
|
|
|
385
|
-
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
|
|
1302
|
+
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`).
|
|
386
1303
|
|
|
387
1304
|
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`).
|
|
388
1305
|
|
|
@@ -390,9 +1307,9 @@
|
|
|
390
1307
|
|
|
391
1308
|
`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.
|
|
392
1309
|
|
|
393
|
-
Previously, every `confect/tables/<name>.ts` module ran `Schema.Struct({...})` (and the corresponding `compileTableSchema
|
|
1310
|
+
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.
|
|
394
1311
|
|
|
395
|
-
The bound `Table` now exposes `Fields
|
|
1312
|
+
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).
|
|
396
1313
|
|
|
397
1314
|
### Migration
|
|
398
1315
|
1. Delete your `confect/schema.ts`. Codegen will refuse to run while a stray copy is present.
|
|
@@ -420,7 +1337,7 @@
|
|
|
420
1337
|
+ );
|
|
421
1338
|
```
|
|
422
1339
|
|
|
423
|
-
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
|
|
1340
|
+
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):
|
|
424
1341
|
|
|
425
1342
|
```diff
|
|
426
1343
|
- import Notes from "../tables/Notes";
|
|
@@ -449,11 +1366,11 @@
|
|
|
449
1366
|
|
|
450
1367
|
### New warning: no tables discovered
|
|
451
1368
|
|
|
452
|
-
If a Confect project has no tables
|
|
1369
|
+
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/`.
|
|
453
1370
|
|
|
454
1371
|
### New error: invalid table filename
|
|
455
1372
|
|
|
456
|
-
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
|
|
1373
|
+
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`.
|
|
457
1374
|
|
|
458
1375
|
## 9.0.0-next.5
|
|
459
1376
|
|
|
@@ -463,22 +1380,22 @@
|
|
|
463
1380
|
|
|
464
1381
|
### Patch Changes
|
|
465
1382
|
|
|
466
|
-
- 6d85210: Resolve `FunctionImpl
|
|
1383
|
+
- 6d85210: Resolve `FunctionImpl`/`GroupImpl` group paths via an immutable `paths` map on `Spec` instead of identity-walking the assembled tree.
|
|
467
1384
|
|
|
468
1385
|
### Why
|
|
469
1386
|
|
|
470
|
-
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
|
|
1387
|
+
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.
|
|
471
1388
|
|
|
472
1389
|
### What changed
|
|
473
|
-
- `@confect/core/Spec` carries a new `readonly paths: ReadonlyMap<GroupSpec.AnyWithProps, string>` field and exposes a chainable `Spec#addPath(group, path)` builder. `add
|
|
1390
|
+
- `@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.
|
|
474
1391
|
- `@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.
|
|
475
|
-
- `@confect/server/FunctionImpl.make` and `GroupImpl.make` resolve their group path via `api.spec.paths.get(group)
|
|
1392
|
+
- `@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.
|
|
476
1393
|
- `@confect/server/GroupPath` (the old identity-based resolver) is deleted.
|
|
477
1394
|
- `@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.
|
|
478
1395
|
|
|
479
1396
|
### User-facing impact
|
|
480
1397
|
- 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.
|
|
481
|
-
- 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
|
|
1398
|
+
- 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.
|
|
482
1399
|
- 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.
|
|
483
1400
|
|
|
484
1401
|
### Fixes
|
|
@@ -499,9 +1416,9 @@
|
|
|
499
1416
|
|
|
500
1417
|
### Why
|
|
501
1418
|
|
|
502
|
-
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
|
|
1419
|
+
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.
|
|
503
1420
|
|
|
504
|
-
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
|
|
1421
|
+
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.
|
|
505
1422
|
|
|
506
1423
|
### Breaking changes
|
|
507
1424
|
- `GroupSpec.make()` and `GroupSpec.makeNode()` no longer take a name argument; the group name is derived from the spec file's path within `confect/`.
|