@confect/js 10.0.0-next.20 → 10.0.0-next.22
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 +118 -40
- package/dist/HttpClient.d.ts +17 -24
- package/dist/HttpClient.d.ts.map +1 -1
- package/dist/HttpClient.js +8 -31
- package/dist/HttpClient.js.map +1 -1
- package/dist/WebSocketClient.d.ts +17 -25
- package/dist/WebSocketClient.d.ts.map +1 -1
- package/dist/WebSocketClient.js +9 -57
- package/dist/WebSocketClient.js.map +1 -1
- package/dist/internal/HttpClient.d.ts +26 -0
- package/dist/internal/HttpClient.d.ts.map +1 -0
- package/dist/internal/HttpClient.js +41 -0
- package/dist/internal/HttpClient.js.map +1 -0
- package/dist/internal/WebSocketClient.d.ts +44 -0
- package/dist/internal/WebSocketClient.d.ts.map +1 -0
- package/dist/internal/WebSocketClient.js +69 -0
- package/dist/internal/WebSocketClient.js.map +1 -0
- package/package.json +9 -9
- package/src/HttpClient.ts +12 -81
- package/src/WebSocketClient.ts +24 -168
- package/src/internal/HttpClient.ts +119 -0
- package/src/internal/WebSocketClient.ts +220 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,88 @@
|
|
|
1
1
|
# @confect/js
|
|
2
2
|
|
|
3
|
+
## 10.0.0-next.22
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
- 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.
|
|
12
|
+
- 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
|
|
13
|
+
|
|
14
|
+
### Stream queries and pagination
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
`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.
|
|
19
|
+
|
|
20
|
+
Use React's new `useStreamPaginatedQuery` for these queries:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { useStreamPaginatedQuery } from "@confect/react";
|
|
24
|
+
|
|
25
|
+
const { results, status, loadMore } = useStreamPaginatedQuery(
|
|
26
|
+
refs.public.notes.feed,
|
|
27
|
+
{},
|
|
28
|
+
{
|
|
29
|
+
initialNumItems: 10,
|
|
30
|
+
maximumRowsRead: 1000,
|
|
31
|
+
maximumBytesRead: 512 * 1024,
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
### Middleware options
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
### Breaking changes
|
|
47
|
+
|
|
48
|
+
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`:
|
|
49
|
+
|
|
50
|
+
**Before:**
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
(effect, { name, args }) => effect;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**After:**
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
(effect, { invocation: { name, args } }) => effect;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
|
|
63
|
+
|
|
64
|
+
### Fixes and tracing
|
|
65
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
|
|
66
|
+
- 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.
|
|
67
|
+
|
|
68
|
+
## 10.0.0-next.21
|
|
69
|
+
|
|
70
|
+
### Major Changes
|
|
71
|
+
|
|
72
|
+
- a6425c5: Raise the minimum supported Node.js version to 24.
|
|
73
|
+
|
|
74
|
+
### Breaking Changes
|
|
75
|
+
- `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
|
|
76
|
+
|
|
77
|
+
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.
|
|
78
|
+
|
|
3
79
|
## 10.0.0-next.20
|
|
4
80
|
|
|
5
81
|
## 10.0.0-next.19
|
|
6
82
|
|
|
7
83
|
### Minor Changes
|
|
8
84
|
|
|
9
|
-
- c1087eb: Add `@confect/foldkit
|
|
85
|
+
- 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.
|
|
10
86
|
|
|
11
87
|
```ts
|
|
12
88
|
import * as Confect from "@confect/foldkit";
|
|
@@ -36,7 +112,7 @@
|
|
|
36
112
|
}));
|
|
37
113
|
```
|
|
38
114
|
|
|
39
|
-
The Command factories accept Foldkit's `interrupt` option
|
|
115
|
+
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.
|
|
40
116
|
|
|
41
117
|
`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.
|
|
42
118
|
|
|
@@ -83,14 +159,14 @@
|
|
|
83
159
|
Breaking changes for users:
|
|
84
160
|
|
|
85
161
|
- **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.
|
|
86
|
-
- **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)
|
|
87
|
-
- **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these
|
|
162
|
+
- **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.
|
|
163
|
+
- **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.
|
|
88
164
|
- **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`).
|
|
89
|
-
- **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
|
|
165
|
+
- **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.
|
|
90
166
|
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
91
167
|
- **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.
|
|
92
168
|
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
93
|
-
- 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
|
|
169
|
+
- 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.
|
|
94
170
|
|
|
95
171
|
### Patch Changes
|
|
96
172
|
|
|
@@ -105,9 +181,9 @@
|
|
|
105
181
|
- 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.
|
|
106
182
|
- 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.
|
|
107
183
|
|
|
108
|
-
`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
|
|
184
|
+
`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.
|
|
109
185
|
|
|
110
|
-
`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
|
|
186
|
+
`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.
|
|
111
187
|
|
|
112
188
|
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
113
189
|
|
|
@@ -129,7 +205,7 @@
|
|
|
129
205
|
) {}
|
|
130
206
|
```
|
|
131
207
|
|
|
132
|
-
`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
|
|
208
|
+
`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.
|
|
133
209
|
|
|
134
210
|
`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.
|
|
135
211
|
|
|
@@ -157,13 +233,13 @@
|
|
|
157
233
|
|
|
158
234
|
- 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.
|
|
159
235
|
|
|
160
|
-
`beta.107` is a patch-only Effect release, so no Confect API changes and no call-site edits are needed
|
|
236
|
+
`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.
|
|
161
237
|
|
|
162
|
-
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
|
|
238
|
+
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.
|
|
163
239
|
|
|
164
240
|
- Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
165
241
|
|
|
166
|
-
`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
|
|
242
|
+
`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.
|
|
167
243
|
|
|
168
244
|
- Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
|
|
169
245
|
|
|
@@ -187,7 +263,7 @@
|
|
|
187
263
|
|
|
188
264
|
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.
|
|
189
265
|
|
|
190
|
-
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
|
|
266
|
+
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.
|
|
191
267
|
|
|
192
268
|
- 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.
|
|
193
269
|
|
|
@@ -198,10 +274,10 @@
|
|
|
198
274
|
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/*`.
|
|
199
275
|
|
|
200
276
|
- 3f0255c: Build and test against `convex` 1.44.0. The published `convex` peer ranges are unchanged, so no consumer action is required.
|
|
201
|
-
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4
|
|
202
|
-
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5
|
|
203
|
-
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0
|
|
204
|
-
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0
|
|
277
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4—see those versions' changelog entries.
|
|
278
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
|
|
279
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
|
|
280
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
|
|
205
281
|
|
|
206
282
|
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.
|
|
207
283
|
|
|
@@ -237,7 +313,7 @@
|
|
|
237
313
|
|
|
238
314
|
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.
|
|
239
315
|
|
|
240
|
-
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
|
|
316
|
+
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.
|
|
241
317
|
|
|
242
318
|
- 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.
|
|
243
319
|
|
|
@@ -247,9 +323,9 @@
|
|
|
247
323
|
|
|
248
324
|
- 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.
|
|
249
325
|
|
|
250
|
-
`beta.107` is a patch-only Effect release, so no Confect API changes and no call-site edits are needed
|
|
326
|
+
`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.
|
|
251
327
|
|
|
252
|
-
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
|
|
328
|
+
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.
|
|
253
329
|
|
|
254
330
|
## 10.0.0-next.12
|
|
255
331
|
|
|
@@ -283,9 +359,9 @@
|
|
|
283
359
|
|
|
284
360
|
- 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.
|
|
285
361
|
|
|
286
|
-
`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
|
|
362
|
+
`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.
|
|
287
363
|
|
|
288
|
-
`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
|
|
364
|
+
`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.
|
|
289
365
|
|
|
290
366
|
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
291
367
|
|
|
@@ -307,11 +383,11 @@
|
|
|
307
383
|
) {}
|
|
308
384
|
```
|
|
309
385
|
|
|
310
|
-
`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
|
|
386
|
+
`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.
|
|
311
387
|
|
|
312
388
|
`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.
|
|
313
389
|
|
|
314
|
-
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0
|
|
390
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
|
|
315
391
|
|
|
316
392
|
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.
|
|
317
393
|
|
|
@@ -319,14 +395,14 @@
|
|
|
319
395
|
|
|
320
396
|
### Patch Changes
|
|
321
397
|
|
|
322
|
-
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0
|
|
398
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
|
|
323
399
|
|
|
324
400
|
## 10.0.0-next.9
|
|
325
401
|
|
|
326
402
|
### Patch Changes
|
|
327
403
|
|
|
328
404
|
- 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.
|
|
329
|
-
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5
|
|
405
|
+
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
|
|
330
406
|
|
|
331
407
|
## 10.0.0-next.8
|
|
332
408
|
|
|
@@ -360,7 +436,7 @@
|
|
|
360
436
|
|
|
361
437
|
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.
|
|
362
438
|
|
|
363
|
-
- 2aa7541: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4
|
|
439
|
+
- 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.
|
|
364
440
|
|
|
365
441
|
## 10.0.0-next.1
|
|
366
442
|
|
|
@@ -368,7 +444,7 @@
|
|
|
368
444
|
|
|
369
445
|
- 4d98ea8: Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
370
446
|
|
|
371
|
-
`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
|
|
447
|
+
`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.
|
|
372
448
|
|
|
373
449
|
- Updated dependencies [4d98ea8]
|
|
374
450
|
- @confect/core@10.0.0-next.1
|
|
@@ -381,20 +457,22 @@
|
|
|
381
457
|
|
|
382
458
|
Breaking changes for users:
|
|
383
459
|
- **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.
|
|
384
|
-
- **Option-returning functions** must use a codec with a serializable encoded form, such as `Schema.OptionFromNullOr(...)
|
|
385
|
-
- **Table schemas** may now be transformations (`Schema.decodeTo` chains, `Schema.encodeKeys`), branded structs, suspended schemas, or unions of these
|
|
460
|
+
- **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.
|
|
461
|
+
- **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.
|
|
386
462
|
- **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`).
|
|
387
|
-
- **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
|
|
463
|
+
- **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.
|
|
388
464
|
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
389
465
|
- **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.
|
|
390
466
|
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
391
|
-
- 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
|
|
467
|
+
- 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.
|
|
392
468
|
|
|
393
469
|
### Patch Changes
|
|
394
470
|
|
|
395
471
|
- Updated dependencies [70e313e]
|
|
396
472
|
- @confect/core@10.0.0-next.0
|
|
397
473
|
|
|
474
|
+
## 9.4.2
|
|
475
|
+
|
|
398
476
|
## 9.4.1
|
|
399
477
|
|
|
400
478
|
### Patch Changes
|
|
@@ -483,7 +561,7 @@
|
|
|
483
561
|
|
|
484
562
|
- 445ea9b: Loosen and align dependency ranges across all packages:
|
|
485
563
|
- 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.
|
|
486
|
-
- `@confect/server`'s `@effect/platform-node` peer dependency is now optional
|
|
564
|
+
- `@confect/server`'s `@effect/platform-node` peer dependency is now optional—it is only needed when using the `@confect/server/node` entrypoint.
|
|
487
565
|
- `@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`.
|
|
488
566
|
- `@confect/test` now accepts any `convex-test` release in `>=0.0.50 <0.1.0` instead of exactly 0.0.50.
|
|
489
567
|
|
|
@@ -502,8 +580,8 @@
|
|
|
502
580
|
|
|
503
581
|
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.
|
|
504
582
|
- Each `*.spec.ts` `export default`s its `GroupSpec` (named co-exports like error classes are still allowed).
|
|
505
|
-
- Each `*.impl.ts` default-imports its sibling spec, passes it to `FunctionImpl.make
|
|
506
|
-
- 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
|
|
583
|
+
- 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.
|
|
584
|
+
- 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.
|
|
507
585
|
|
|
508
586
|
### Tables are the source of truth, named by their filename
|
|
509
587
|
|
|
@@ -534,7 +612,7 @@
|
|
|
534
612
|
|
|
535
613
|
### Specs and impls: lazy schemas, and impls take the `DatabaseSchema`
|
|
536
614
|
|
|
537
|
-
`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
|
|
615
|
+
`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.
|
|
538
616
|
|
|
539
617
|
**Before:**
|
|
540
618
|
|
|
@@ -582,7 +660,7 @@
|
|
|
582
660
|
|
|
583
661
|
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.
|
|
584
662
|
- A Node group at `confect/email.spec.ts` is now reached at `refs.public.email.send` instead of `refs.public.node.email.send`.
|
|
585
|
-
- `@confect/core` removes `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec
|
|
663
|
+
- `@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.
|
|
586
664
|
|
|
587
665
|
### Less work at cold start
|
|
588
666
|
|
|
@@ -599,7 +677,7 @@
|
|
|
599
677
|
### Migration
|
|
600
678
|
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`.
|
|
601
679
|
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"`.
|
|
602
|
-
3. **Impls.** In each `*.impl.ts`, default-import the sibling spec, import `databaseSchema` from `_generated/schema`, pass it to `FunctionImpl.make
|
|
680
|
+
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).
|
|
603
681
|
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)`.
|
|
604
682
|
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`.
|
|
605
683
|
6. **Optional.** Adopt submodule Effect imports (`import * as Schema from "effect/Schema"`) in your own `confect/` files for the full cold-start savings.
|
|
@@ -643,11 +721,11 @@
|
|
|
643
721
|
|
|
644
722
|
### Why
|
|
645
723
|
|
|
646
|
-
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
|
|
724
|
+
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.
|
|
647
725
|
|
|
648
726
|
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).
|
|
649
727
|
|
|
650
|
-
No API changes
|
|
728
|
+
No API changes—your existing code keeps working.
|
|
651
729
|
|
|
652
730
|
### Getting the full win in your own code
|
|
653
731
|
|
package/dist/HttpClient.d.ts
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
import * as Ref from "@confect/core/Ref";
|
|
2
1
|
import { ConvexHttpClient } from "convex/browser";
|
|
3
2
|
import * as Context from "effect/Context";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
3
|
import * as Layer from "effect/Layer";
|
|
6
|
-
import * as
|
|
7
|
-
|
|
8
|
-
readonly cause: Schema.Unknown;
|
|
9
|
-
}>, import("effect/Cause").YieldableError>;
|
|
10
|
-
export declare class HttpClientError extends HttpClientError_base {
|
|
11
|
-
}
|
|
4
|
+
import * as InternalHttpClient from "./internal/HttpClient";
|
|
5
|
+
export { HttpClientError } from "./internal/HttpClient";
|
|
12
6
|
/**
|
|
13
7
|
* A Confect client which uses HTTP to communicate with your Convex backend. Works in any JS runtime that supports `fetch`. Wraps [ConvexHttpClient](https://docs.convex.dev/api/classes/browser.ConvexHttpClient).
|
|
14
8
|
*/
|
|
15
9
|
export declare const HttpClient: Context.Service<{
|
|
16
10
|
url: string;
|
|
17
|
-
setAuth: (token: string) => Effect.Effect<void, never, never>;
|
|
18
|
-
clearAuth: Effect.Effect<void, never, never>;
|
|
19
|
-
query: <Query extends Ref.AnyPublicQuery>(ref: Query, ...rest: Ref.OptionalArgs<Query>) => Effect.Effect<Ref.Returns<Query>, Ref.Error<Query> | HttpClientError | Schema.SchemaError>;
|
|
20
|
-
mutation: <Mutation extends Ref.AnyPublicMutation>(ref: Mutation, ...rest: Ref.OptionalArgs<Mutation>) => Effect.Effect<Ref.Returns<Mutation>, Ref.Error<Mutation> | HttpClientError | Schema.SchemaError>;
|
|
21
|
-
action: <Action extends Ref.AnyPublicAction>(ref: Action, ...rest: Ref.OptionalArgs<Action>) => Effect.Effect<Ref.Returns<Action>, Ref.Error<Action> | HttpClientError | Schema.SchemaError>;
|
|
11
|
+
setAuth: (token: string) => import("effect/Effect").Effect<void, never, never>;
|
|
12
|
+
clearAuth: import("effect/Effect").Effect<void, never, never>;
|
|
13
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
14
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
15
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
22
16
|
}, {
|
|
23
17
|
url: string;
|
|
24
|
-
setAuth: (token: string) => Effect.Effect<void, never, never>;
|
|
25
|
-
clearAuth: Effect.Effect<void, never, never>;
|
|
26
|
-
query: <Query extends Ref.AnyPublicQuery>(ref: Query, ...rest: Ref.OptionalArgs<Query>) => Effect.Effect<Ref.Returns<Query>, Ref.Error<Query> | HttpClientError | Schema.SchemaError>;
|
|
27
|
-
mutation: <Mutation extends Ref.AnyPublicMutation>(ref: Mutation, ...rest: Ref.OptionalArgs<Mutation>) => Effect.Effect<Ref.Returns<Mutation>, Ref.Error<Mutation> | HttpClientError | Schema.SchemaError>;
|
|
28
|
-
action: <Action extends Ref.AnyPublicAction>(ref: Action, ...rest: Ref.OptionalArgs<Action>) => Effect.Effect<Ref.Returns<Action>, Ref.Error<Action> | HttpClientError | Schema.SchemaError>;
|
|
18
|
+
setAuth: (token: string) => import("effect/Effect").Effect<void, never, never>;
|
|
19
|
+
clearAuth: import("effect/Effect").Effect<void, never, never>;
|
|
20
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
21
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
22
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
29
23
|
}>;
|
|
30
24
|
export type HttpClient = typeof HttpClient.Identifier;
|
|
31
25
|
export declare const layer: (address: string, options?: ConstructorParameters<typeof ConvexHttpClient>[1]) => Layer.Layer<{
|
|
32
26
|
url: string;
|
|
33
|
-
setAuth: (token: string) => Effect.Effect<void, never, never>;
|
|
34
|
-
clearAuth: Effect.Effect<void, never, never>;
|
|
35
|
-
query: <Query extends Ref.AnyPublicQuery>(ref: Query, ...rest: Ref.OptionalArgs<Query>) => Effect.Effect<Ref.Returns<Query>, Ref.Error<Query> | HttpClientError | Schema.SchemaError>;
|
|
36
|
-
mutation: <Mutation extends Ref.AnyPublicMutation>(ref: Mutation, ...rest: Ref.OptionalArgs<Mutation>) => Effect.Effect<Ref.Returns<Mutation>, Ref.Error<Mutation> | HttpClientError | Schema.SchemaError>;
|
|
37
|
-
action: <Action extends Ref.AnyPublicAction>(ref: Action, ...rest: Ref.OptionalArgs<Action>) => Effect.Effect<Ref.Returns<Action>, Ref.Error<Action> | HttpClientError | Schema.SchemaError>;
|
|
27
|
+
setAuth: (token: string) => import("effect/Effect").Effect<void, never, never>;
|
|
28
|
+
clearAuth: import("effect/Effect").Effect<void, never, never>;
|
|
29
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
30
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
31
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => import("effect/Effect").Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | InternalHttpClient.HttpClientError | import("effect/Schema").SchemaError>;
|
|
38
32
|
}, never, never>;
|
|
39
|
-
export {};
|
|
40
33
|
//# sourceMappingURL=HttpClient.d.ts.map
|
package/dist/HttpClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../src/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../src/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,kBAAkB,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAoBxD;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;EAEtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,UAAU,CAAC;AAEtD,eAAO,MAAM,KAAK,YACP,MAAM,YACL,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;;;;;;;gBACJ,CAAC"}
|
package/dist/HttpClient.js
CHANGED
|
@@ -1,47 +1,24 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
2
|
+
import { HttpClientError, make as make$1 } from "./internal/HttpClient.js";
|
|
3
3
|
import { ConvexHttpClient } from "convex/browser";
|
|
4
4
|
import * as Context from "effect/Context";
|
|
5
|
-
import * as Effect from "effect/Effect";
|
|
6
5
|
import * as Layer from "effect/Layer";
|
|
7
|
-
import * as Schema from "effect/Schema";
|
|
8
6
|
//#region src/HttpClient.ts
|
|
9
7
|
var HttpClient_exports = /* @__PURE__ */ __exportAll({
|
|
10
8
|
HttpClient: () => HttpClient,
|
|
11
9
|
HttpClientError: () => HttpClientError,
|
|
12
10
|
layer: () => layer
|
|
13
11
|
});
|
|
14
|
-
var HttpClientError = class extends Schema.TaggedError()("HttpClientError", { cause: Schema.Unknown }) {};
|
|
15
12
|
const make = (address, options) => {
|
|
16
13
|
const client = new ConvexHttpClient(address, options);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
client.setAuth(token)
|
|
14
|
+
return make$1({
|
|
15
|
+
url: client.url,
|
|
16
|
+
setAuth: (token) => client.setAuth(token),
|
|
17
|
+
clearAuth: () => client.clearAuth(),
|
|
18
|
+
query: (functionReference, encodedArgs) => client.query(functionReference, encodedArgs),
|
|
19
|
+
mutation: (functionReference, encodedArgs) => client.mutation(functionReference, encodedArgs),
|
|
20
|
+
action: (functionReference, encodedArgs) => client.action(functionReference, encodedArgs)
|
|
20
21
|
});
|
|
21
|
-
const clearAuth = Effect.sync(() => {
|
|
22
|
-
client.clearAuth();
|
|
23
|
-
});
|
|
24
|
-
const mapUnknownError = (cause) => new HttpClientError({ cause });
|
|
25
|
-
const query = (ref, ...rest) => {
|
|
26
|
-
const args = rest[0] ?? {};
|
|
27
|
-
return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.query(functionReference, encodedArgs), mapUnknownError);
|
|
28
|
-
};
|
|
29
|
-
const mutation = (ref, ...rest) => {
|
|
30
|
-
const args = rest[0] ?? {};
|
|
31
|
-
return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.mutation(functionReference, encodedArgs), mapUnknownError);
|
|
32
|
-
};
|
|
33
|
-
const action = (ref, ...rest) => {
|
|
34
|
-
const args = rest[0] ?? {};
|
|
35
|
-
return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.action(functionReference, encodedArgs), mapUnknownError);
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
url,
|
|
39
|
-
setAuth,
|
|
40
|
-
clearAuth,
|
|
41
|
-
query,
|
|
42
|
-
mutation,
|
|
43
|
-
action
|
|
44
|
-
};
|
|
45
22
|
};
|
|
46
23
|
/**
|
|
47
24
|
* A Confect client which uses HTTP to communicate with your Convex backend. Works in any JS runtime that supports `fetch`. Wraps [ConvexHttpClient](https://docs.convex.dev/api/classes/browser.ConvexHttpClient).
|
package/dist/HttpClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.js","names":[],"sources":["../src/HttpClient.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"HttpClient.js","names":["InternalHttpClient.make"],"sources":["../src/HttpClient.ts"],"sourcesContent":["import { ConvexHttpClient } from \"convex/browser\";\nimport * as Context from \"effect/Context\";\nimport * as Layer from \"effect/Layer\";\nimport * as InternalHttpClient from \"./internal/HttpClient\";\n\nexport { HttpClientError } from \"./internal/HttpClient\";\n\nconst make = (\n address: string,\n options?: ConstructorParameters<typeof ConvexHttpClient>[1],\n) => {\n const client = new ConvexHttpClient(address, options);\n return InternalHttpClient.make({\n url: client.url,\n setAuth: (token) => client.setAuth(token),\n clearAuth: () => client.clearAuth(),\n query: (functionReference, encodedArgs) =>\n client.query(functionReference, encodedArgs),\n mutation: (functionReference, encodedArgs) =>\n client.mutation(functionReference, encodedArgs),\n action: (functionReference, encodedArgs) =>\n client.action(functionReference, encodedArgs),\n });\n};\n\n/**\n * A Confect client which uses HTTP to communicate with your Convex backend. Works in any JS runtime that supports `fetch`. Wraps [ConvexHttpClient](https://docs.convex.dev/api/classes/browser.ConvexHttpClient).\n */\nexport const HttpClient = Context.Service<ReturnType<typeof make>>(\n \"@confect/js/HttpClient\",\n);\n\nexport type HttpClient = typeof HttpClient.Identifier;\n\nexport const layer = (\n address: string,\n options?: ConstructorParameters<typeof ConvexHttpClient>[1],\n) => Layer.sync(HttpClient, () => make(address, options));\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,QACJ,SACA,YACG;CACH,MAAM,SAAS,IAAI,iBAAiB,SAAS,OAAO;CACpD,OAAOA,OAAwB;EAC7B,KAAK,OAAO;EACZ,UAAU,UAAU,OAAO,QAAQ,KAAK;EACxC,iBAAiB,OAAO,UAAU;EAClC,QAAQ,mBAAmB,gBACzB,OAAO,MAAM,mBAAmB,WAAW;EAC7C,WAAW,mBAAmB,gBAC5B,OAAO,SAAS,mBAAmB,WAAW;EAChD,SAAS,mBAAmB,gBAC1B,OAAO,OAAO,mBAAmB,WAAW;CAChD,CAAC;AACH;;;;AAKA,MAAa,aAAa,QAAQ,QAChC,wBACF;AAIA,MAAa,SACX,SACA,YACG,MAAM,KAAK,kBAAkB,KAAK,SAAS,OAAO,CAAC"}
|