@confect/js 10.0.0-next.21 → 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 CHANGED
@@ -1,5 +1,70 @@
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
+
3
68
  ## 10.0.0-next.21
4
69
 
5
70
  ### Major Changes
@@ -9,7 +74,7 @@
9
74
  ### Breaking Changes
10
75
  - `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
11
76
 
12
- 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.
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.
13
78
 
14
79
  ## 10.0.0-next.20
15
80
 
@@ -17,7 +82,7 @@
17
82
 
18
83
  ### Minor Changes
19
84
 
20
- - 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.
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.
21
86
 
22
87
  ```ts
23
88
  import * as Confect from "@confect/foldkit";
@@ -47,7 +112,7 @@
47
112
  }));
48
113
  ```
49
114
 
50
- 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.
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.
51
116
 
52
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.
53
118
 
@@ -94,14 +159,14 @@
94
159
  Breaking changes for users:
95
160
 
96
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.
97
- - **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.
98
- - **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.
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.
99
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`).
100
- - **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.
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.
101
166
  - **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
102
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.
103
168
  - **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
104
- - 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.
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.
105
170
 
106
171
  ### Patch Changes
107
172
 
@@ -116,9 +181,9 @@
116
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.
117
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.
118
183
 
119
- `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.
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.
120
185
 
121
- `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.
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.
122
187
 
123
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:
124
189
 
@@ -140,7 +205,7 @@
140
205
  ) {}
141
206
  ```
142
207
 
143
- `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.
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.
144
209
 
145
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.
146
211
 
@@ -168,13 +233,13 @@
168
233
 
169
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.
170
235
 
171
- `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.
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.
172
237
 
173
- 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.
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.
174
239
 
175
240
  - Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
176
241
 
177
- `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.
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.
178
243
 
179
244
  - Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
180
245
 
@@ -198,7 +263,7 @@
198
263
 
199
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.
200
265
 
201
- 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.
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.
202
267
 
203
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.
204
269
 
@@ -209,10 +274,10 @@
209
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/*`.
210
275
 
211
276
  - 3f0255c: Build and test against `convex` 1.44.0. The published `convex` peer ranges are unchanged, so no consumer action is required.
212
- - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4 — see those versions' changelog entries.
213
- - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5 — see that version's changelog entries.
214
- - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0 — see that version's changelog entries.
215
- - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0 — see that version's changelog entries.
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.
216
281
 
217
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.
218
283
 
@@ -248,7 +313,7 @@
248
313
 
249
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.
250
315
 
251
- 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.
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.
252
317
 
253
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.
254
319
 
@@ -258,9 +323,9 @@
258
323
 
259
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.
260
325
 
261
- `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.
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.
262
327
 
263
- 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.
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.
264
329
 
265
330
  ## 10.0.0-next.12
266
331
 
@@ -294,9 +359,9 @@
294
359
 
295
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.
296
361
 
297
- `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.
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.
298
363
 
299
- `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.
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.
300
365
 
301
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:
302
367
 
@@ -318,11 +383,11 @@
318
383
  ) {}
319
384
  ```
320
385
 
321
- `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.
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.
322
387
 
323
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.
324
389
 
325
- - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0 — see that version's changelog entries.
390
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0—see that version's changelog entries.
326
391
 
327
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.
328
393
 
@@ -330,14 +395,14 @@
330
395
 
331
396
  ### Patch Changes
332
397
 
333
- - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0 — see that version's changelog entries.
398
+ - Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0—see that version's changelog entries.
334
399
 
335
400
  ## 10.0.0-next.9
336
401
 
337
402
  ### Patch Changes
338
403
 
339
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.
340
- - 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5 — see that version's changelog entries.
405
+ - 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5—see that version's changelog entries.
341
406
 
342
407
  ## 10.0.0-next.8
343
408
 
@@ -371,7 +436,7 @@
371
436
 
372
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.
373
438
 
374
- - 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.
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.
375
440
 
376
441
  ## 10.0.0-next.1
377
442
 
@@ -379,7 +444,7 @@
379
444
 
380
445
  - 4d98ea8: Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
381
446
 
382
- `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.
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.
383
448
 
384
449
  - Updated dependencies [4d98ea8]
385
450
  - @confect/core@10.0.0-next.1
@@ -392,14 +457,14 @@
392
457
 
393
458
  Breaking changes for users:
394
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.
395
- - **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.
396
- - **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.
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.
397
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`).
398
- - **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.
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.
399
464
  - **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
400
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.
401
466
  - **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
402
- - 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.
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.
403
468
 
404
469
  ### Patch Changes
405
470
 
@@ -496,7 +561,7 @@
496
561
 
497
562
  - 445ea9b: Loosen and align dependency ranges across all packages:
498
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.
499
- - `@confect/server`'s `@effect/platform-node` peer dependency is now optional — it is only needed when using the `@confect/server/node` entrypoint.
564
+ - `@confect/server`'s `@effect/platform-node` peer dependency is now optional—it is only needed when using the `@confect/server/node` entrypoint.
500
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`.
501
566
  - `@confect/test` now accepts any `convex-test` release in `>=0.0.50 <0.1.0` instead of exactly 0.0.50.
502
567
 
@@ -515,8 +580,8 @@
515
580
 
516
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.
517
582
  - Each `*.spec.ts` `export default`s its `GroupSpec` (named co-exports like error classes are still allowed).
518
- - 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.
519
- - 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.
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.
520
585
 
521
586
  ### Tables are the source of truth, named by their filename
522
587
 
@@ -547,7 +612,7 @@
547
612
 
548
613
  ### Specs and impls: lazy schemas, and impls take the `DatabaseSchema`
549
614
 
550
- `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.
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.
551
616
 
552
617
  **Before:**
553
618
 
@@ -595,7 +660,7 @@
595
660
 
596
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.
597
662
  - A Node group at `confect/email.spec.ts` is now reached at `refs.public.email.send` instead of `refs.public.node.email.send`.
598
- - `@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.
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.
599
664
 
600
665
  ### Less work at cold start
601
666
 
@@ -612,7 +677,7 @@
612
677
  ### Migration
613
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`.
614
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"`.
615
- 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).
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).
616
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)`.
617
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`.
618
683
  6. **Optional.** Adopt submodule Effect imports (`import * as Schema from "effect/Schema"`) in your own `confect/` files for the full cold-start savings.
@@ -656,11 +721,11 @@
656
721
 
657
722
  ### Why
658
723
 
659
- 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.
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.
660
725
 
661
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).
662
727
 
663
- No API changes — your existing code keeps working.
728
+ No API changes—your existing code keeps working.
664
729
 
665
730
  ### Getting the full win in your own code
666
731
 
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/internal/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,MAAM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C,eAAe,CAAC,EAC7D,WAAW,EAAE,OAAO,KACjB,WAAW,CAAC,OAAO,CAAC,CAAC;CAC3B;AAcD,eAAO,MAAM,IAAI,WAAY,SAAS;;qBACZ,MAAM;;YAWf,KAAK,SAAS,GAAG,CAAC,cAAc,OACxC,KAAK,WACD,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,KAC/B,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAClB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC,WAAW,CACxD;eAaiB,QAAQ,SAAS,GAAG,CAAC,iBAAiB,OACjD,QAAQ,WACJ,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,KAClC,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC,WAAW,CAC3D;aAae,MAAM,SAAS,GAAG,CAAC,eAAe,OAC3C,MAAM,WACF,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,KAChC,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EACnB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,eAAe,GAAG,MAAM,CAAC,WAAW,CACzD;CAqBF,CAAC"}
@@ -3,6 +3,9 @@ import * as Ref from "@confect/core/Ref";
3
3
  import * as Schema from "effect/Schema";
4
4
  //#region src/internal/HttpClient.ts
5
5
  var HttpClientError = class extends Schema.TaggedError()("HttpClientError", { cause: Schema.Unknown }) {};
6
+ const runQuery = Effect.fn("HttpClient.query")((effect) => effect);
7
+ const runMutation = Effect.fn("HttpClient.mutation")((effect) => effect);
8
+ const runAction = Effect.fn("HttpClient.action")((effect) => effect);
6
9
  const make = (client) => {
7
10
  const setAuth = (token) => Effect.sync(() => {
8
11
  client.setAuth(token);
@@ -13,15 +16,15 @@ const make = (client) => {
13
16
  const mapUnknownError = (cause) => new HttpClientError({ cause });
14
17
  const query = (ref, ...rest) => {
15
18
  const args = rest[0] ?? {};
16
- return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.query(functionReference, encodedArgs), mapUnknownError);
19
+ return runQuery(Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.query(functionReference, encodedArgs), mapUnknownError));
17
20
  };
18
21
  const mutation = (ref, ...rest) => {
19
22
  const args = rest[0] ?? {};
20
- return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.mutation(functionReference, encodedArgs), mapUnknownError);
23
+ return runMutation(Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.mutation(functionReference, encodedArgs), mapUnknownError));
21
24
  };
22
25
  const action = (ref, ...rest) => {
23
26
  const args = rest[0] ?? {};
24
- return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.action(functionReference, encodedArgs), mapUnknownError);
27
+ return runAction(Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => client.action(functionReference, encodedArgs), mapUnknownError));
25
28
  };
26
29
  return {
27
30
  url: client.url,
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.js","names":[],"sources":["../../src/internal/HttpClient.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\n\nexport class HttpClientError extends Schema.TaggedError<HttpClientError>()(\n \"HttpClientError\",\n {\n cause: Schema.Unknown,\n },\n) {}\n\nexport interface Transport {\n readonly url: string;\n readonly setAuth: (token: string) => void;\n readonly clearAuth: () => void;\n readonly query: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicQuery>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly mutation: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicMutation>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly action: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicAction>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n}\n\nexport const make = (client: Transport) => {\n const setAuth = (token: string) =>\n Effect.sync(() => {\n client.setAuth(token);\n });\n\n const clearAuth = Effect.sync(() => {\n client.clearAuth();\n });\n\n const mapUnknownError = (cause: unknown) => new HttpClientError({ cause });\n\n const query = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Effect.Effect<\n Ref.Returns<Query>,\n Ref.Error<Query> | HttpClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Query>;\n return Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n client.query(functionReference, encodedArgs),\n mapUnknownError,\n );\n };\n\n const mutation = <Mutation extends Ref.AnyPublicMutation>(\n ref: Mutation,\n ...rest: Ref.OptionalArgs<Mutation>\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | HttpClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Mutation>;\n return Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n client.mutation(functionReference, encodedArgs),\n mapUnknownError,\n );\n };\n\n const action = <Action extends Ref.AnyPublicAction>(\n ref: Action,\n ...rest: Ref.OptionalArgs<Action>\n ): Effect.Effect<\n Ref.Returns<Action>,\n Ref.Error<Action> | HttpClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Action>;\n return Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n client.action(functionReference, encodedArgs),\n mapUnknownError,\n );\n };\n\n return {\n url: client.url,\n setAuth,\n clearAuth,\n query,\n mutation,\n action,\n };\n};\n"],"mappings":";;;;AAIA,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CACxE,mBACA,EACE,OAAO,OAAO,QAChB,CACF,CAAC,CAAC,CAAC;AAoBH,MAAa,QAAQ,WAAsB;CACzC,MAAM,WAAW,UACf,OAAO,WAAW;EAChB,OAAO,QAAQ,KAAK;CACtB,CAAC;CAEH,MAAM,YAAY,OAAO,WAAW;EAClC,OAAO,UAAU;CACnB,CAAC;CAED,MAAM,mBAAmB,UAAmB,IAAI,gBAAgB,EAAE,MAAM,CAAC;CAEzE,MAAM,SACJ,KACA,GAAG,SAIA;EACH,MAAM,OAAQ,KAAK,MAAM,CAAC;EAC1B,OAAO,IAAI,aACT,KACA,OACC,mBAAmB,gBAClB,OAAO,MAAM,mBAAmB,WAAW,GAC7C,eACF;CACF;CAEA,MAAM,YACJ,KACA,GAAG,SAIA;EACH,MAAM,OAAQ,KAAK,MAAM,CAAC;EAC1B,OAAO,IAAI,aACT,KACA,OACC,mBAAmB,gBAClB,OAAO,SAAS,mBAAmB,WAAW,GAChD,eACF;CACF;CAEA,MAAM,UACJ,KACA,GAAG,SAIA;EACH,MAAM,OAAQ,KAAK,MAAM,CAAC;EAC1B,OAAO,IAAI,aACT,KACA,OACC,mBAAmB,gBAClB,OAAO,OAAO,mBAAmB,WAAW,GAC9C,eACF;CACF;CAEA,OAAO;EACL,KAAK,OAAO;EACZ;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"HttpClient.js","names":[],"sources":["../../src/internal/HttpClient.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\n\nexport class HttpClientError extends Schema.TaggedError<HttpClientError>()(\n \"HttpClientError\",\n {\n cause: Schema.Unknown,\n },\n) {}\n\nexport interface Transport {\n readonly url: string;\n readonly setAuth: (token: string) => void;\n readonly clearAuth: () => void;\n readonly query: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicQuery>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly mutation: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicMutation>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly action: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicAction>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n}\n\nconst runQuery = Effect.fn(\"HttpClient.query\")(\n <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,\n);\n\nconst runMutation = Effect.fn(\"HttpClient.mutation\")(\n <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,\n);\n\nconst runAction = Effect.fn(\"HttpClient.action\")(\n <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,\n);\n\nexport const make = (client: Transport) => {\n const setAuth = (token: string) =>\n Effect.sync(() => {\n client.setAuth(token);\n });\n\n const clearAuth = Effect.sync(() => {\n client.clearAuth();\n });\n\n const mapUnknownError = (cause: unknown) => new HttpClientError({ cause });\n\n const query = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Effect.Effect<\n Ref.Returns<Query>,\n Ref.Error<Query> | HttpClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Query>;\n return runQuery(\n Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n client.query(functionReference, encodedArgs),\n mapUnknownError,\n ),\n );\n };\n\n const mutation = <Mutation extends Ref.AnyPublicMutation>(\n ref: Mutation,\n ...rest: Ref.OptionalArgs<Mutation>\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | HttpClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Mutation>;\n return runMutation(\n Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n client.mutation(functionReference, encodedArgs),\n mapUnknownError,\n ),\n );\n };\n\n const action = <Action extends Ref.AnyPublicAction>(\n ref: Action,\n ...rest: Ref.OptionalArgs<Action>\n ): Effect.Effect<\n Ref.Returns<Action>,\n Ref.Error<Action> | HttpClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Action>;\n return runAction(\n Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n client.action(functionReference, encodedArgs),\n mapUnknownError,\n ),\n );\n };\n\n return {\n url: client.url,\n setAuth,\n clearAuth,\n query,\n mutation,\n action,\n };\n};\n"],"mappings":";;;;AAIA,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CACxE,mBACA,EACE,OAAO,OAAO,QAChB,CACF,CAAC,CAAC,CAAC;AAoBH,MAAM,WAAW,OAAO,GAAG,kBAAkB,CAAC,EACrC,WAAqD,MAC9D;AAEA,MAAM,cAAc,OAAO,GAAG,qBAAqB,CAAC,EAC3C,WAAqD,MAC9D;AAEA,MAAM,YAAY,OAAO,GAAG,mBAAmB,CAAC,EACvC,WAAqD,MAC9D;AAEA,MAAa,QAAQ,WAAsB;CACzC,MAAM,WAAW,UACf,OAAO,WAAW;EAChB,OAAO,QAAQ,KAAK;CACtB,CAAC;CAEH,MAAM,YAAY,OAAO,WAAW;EAClC,OAAO,UAAU;CACnB,CAAC;CAED,MAAM,mBAAmB,UAAmB,IAAI,gBAAgB,EAAE,MAAM,CAAC;CAEzE,MAAM,SACJ,KACA,GAAG,SAIA;EACH,MAAM,OAAQ,KAAK,MAAM,CAAC;EAC1B,OAAO,SACL,IAAI,aACF,KACA,OACC,mBAAmB,gBAClB,OAAO,MAAM,mBAAmB,WAAW,GAC7C,eACF,CACF;CACF;CAEA,MAAM,YACJ,KACA,GAAG,SAIA;EACH,MAAM,OAAQ,KAAK,MAAM,CAAC;EAC1B,OAAO,YACL,IAAI,aACF,KACA,OACC,mBAAmB,gBAClB,OAAO,SAAS,mBAAmB,WAAW,GAChD,eACF,CACF;CACF;CAEA,MAAM,UACJ,KACA,GAAG,SAIA;EACH,MAAM,OAAQ,KAAK,MAAM,CAAC;EAC1B,OAAO,UACL,IAAI,aACF,KACA,OACC,mBAAmB,gBAClB,OAAO,OAAO,mBAAmB,WAAW,GAC9C,eACF,CACF;CACF;CAEA,OAAO;EACL,KAAK,OAAO;EACZ;EACA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6,9 @@ import * as Schema from "effect/Schema";
6
6
  import * as Stream from "effect/Stream";
7
7
  //#region src/internal/WebSocketClient.ts
8
8
  var WebSocketClientError = class extends Schema.TaggedError()("WebSocketClientError", { cause: Schema.Defect() }) {};
9
+ const runQuery = Effect.fn("WebSocketClient.query")((effect) => effect);
10
+ const runMutation = Effect.fn("WebSocketClient.mutation")((effect) => effect);
11
+ const runAction = Effect.fn("WebSocketClient.action")((effect) => effect);
9
12
  const make = (address, convexClient) => {
10
13
  const setAuth = (fetchToken, onChange) => Effect.sync(() => {
11
14
  convexClient.setAuth((args) => Effect.runPromise(fetchToken(args)), ...onChange ? [(isAuthenticated) => Effect.runFork(onChange(isAuthenticated))] : []);
@@ -13,15 +16,15 @@ const make = (address, convexClient) => {
13
16
  const mapUnknownError = (cause) => new WebSocketClientError({ cause });
14
17
  const query = (ref, ...rest) => {
15
18
  const args = rest[0] ?? {};
16
- return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => convexClient.query(functionReference, encodedArgs), mapUnknownError);
19
+ return runQuery(Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => convexClient.query(functionReference, encodedArgs), mapUnknownError));
17
20
  };
18
21
  const mutation = (ref, ...rest) => {
19
22
  const args = rest[0] ?? {};
20
- return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => convexClient.mutation(functionReference, encodedArgs), mapUnknownError);
23
+ return runMutation(Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => convexClient.mutation(functionReference, encodedArgs), mapUnknownError));
21
24
  };
22
25
  const action = (ref, ...rest) => {
23
26
  const args = rest[0] ?? {};
24
- return Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => convexClient.action(functionReference, encodedArgs), mapUnknownError);
27
+ return runAction(Ref.runWithCodec(ref, args, (functionReference, encodedArgs) => convexClient.action(functionReference, encodedArgs), mapUnknownError));
25
28
  };
26
29
  const reactiveQueryResult = (ref, ...rest) => {
27
30
  const args = rest[0] ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketClient.js","names":[],"sources":["../../src/internal/WebSocketClient.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport * as Queue from \"effect/Queue\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nexport class WebSocketClientError extends Schema.TaggedError<WebSocketClientError>()(\n \"WebSocketClientError\",\n {\n cause: Schema.Defect(),\n },\n) {}\n\nexport interface Transport {\n readonly setAuth: (\n fetchToken: (args: {\n readonly forceRefreshToken: boolean;\n }) => Promise<string | null | undefined>,\n onChange?: (isAuthenticated: boolean) => void,\n ) => void;\n readonly close: () => Promise<void>;\n readonly query: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicQuery>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly mutation: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicMutation>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly action: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicAction>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly onUpdate: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicQuery>,\n encodedArgs: unknown,\n onUpdate: (result: unknown) => void,\n onError: (error: Error) => void,\n ) => () => void;\n}\n\nexport const make = (address: string, convexClient: Transport) => {\n const setAuth = (\n fetchToken: (args: {\n forceRefreshToken: boolean;\n }) => Effect.Effect<string | null | undefined>,\n onChange?: (isAuthenticated: boolean) => Effect.Effect<void>,\n ) =>\n Effect.sync(() => {\n convexClient.setAuth(\n (args) => Effect.runPromise(fetchToken(args)),\n ...(onChange\n ? [\n (isAuthenticated: boolean) =>\n Effect.runFork(onChange(isAuthenticated)),\n ]\n : []),\n );\n });\n\n const mapUnknownError = (cause: unknown) =>\n new WebSocketClientError({ cause });\n\n const query = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Effect.Effect<\n Ref.Returns<Query>,\n Ref.Error<Query> | WebSocketClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Query>;\n return Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n convexClient.query(functionReference, encodedArgs),\n mapUnknownError,\n );\n };\n\n const mutation = <Mutation extends Ref.AnyPublicMutation>(\n ref: Mutation,\n ...rest: Ref.OptionalArgs<Mutation>\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | WebSocketClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Mutation>;\n return Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n convexClient.mutation(functionReference, encodedArgs),\n mapUnknownError,\n );\n };\n\n const action = <Action extends Ref.AnyPublicAction>(\n ref: Action,\n ...rest: Ref.OptionalArgs<Action>\n ): Effect.Effect<\n Ref.Returns<Action>,\n Ref.Error<Action> | WebSocketClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Action>;\n return Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n convexClient.action(functionReference, encodedArgs),\n mapUnknownError,\n );\n };\n\n type ReactiveQueryError<Query extends Ref.AnyPublicQuery> =\n | Ref.Error<Query>\n | WebSocketClientError\n | Schema.SchemaError;\n\n const reactiveQueryResult = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Stream.Stream<\n Result.Result<Ref.Returns<Query>, ReactiveQueryError<Query>>\n > => {\n type QueryResult = Result.Result<\n Ref.Returns<Query>,\n ReactiveQueryError<Query>\n >;\n const args = (rest[0] ?? {}) as Ref.Args<Query>;\n const functionReference = Ref.getFunctionReference(ref);\n const onError = Ref.decodeErrorOrElse(ref, mapUnknownError);\n\n return Stream.unwrap(\n Effect.match(Ref.encodeArgs(ref, args), {\n onFailure: (error) => Stream.succeed<QueryResult>(Result.fail(error)),\n onSuccess: (encodedArgs) =>\n Stream.callback<Result.Result<unknown, ReactiveQueryError<Query>>>(\n (queue) =>\n Effect.gen(function* () {\n const unsubscribe = convexClient.onUpdate(\n functionReference,\n encodedArgs,\n (result) => {\n Queue.offerUnsafe(queue, Result.succeed(result));\n },\n (error) => {\n Queue.offerUnsafe(queue, Result.fail(onError(error)));\n },\n );\n yield* Effect.addFinalizer(() =>\n Effect.sync(() => unsubscribe()),\n );\n }),\n ),\n }),\n ).pipe(\n Stream.mapEffect((result): Effect.Effect<QueryResult> =>\n Result.match(result, {\n onFailure: (error) => Effect.succeed(Result.fail(error)),\n onSuccess: (encodedReturns) =>\n Effect.match(Ref.decodeReturns(ref, encodedReturns), {\n onFailure: Result.fail,\n onSuccess: Result.succeed,\n }),\n }),\n ),\n );\n };\n\n const reactiveQuery = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Stream.Stream<Ref.Returns<Query>, ReactiveQueryError<Query>> =>\n reactiveQueryResult(ref, ...rest).pipe(\n Stream.mapEffect(\n Result.match({\n onFailure: Effect.fail,\n onSuccess: Effect.succeed,\n }),\n ),\n );\n\n return {\n url: address,\n setAuth,\n query,\n mutation,\n action,\n reactiveQuery,\n reactiveQueryResult,\n };\n};\n\nexport const makeScoped = <E, R>(\n address: string,\n acquire: Effect.Effect<Transport, E, R>,\n) =>\n Effect.acquireRelease(acquire, (convexClient) =>\n Effect.promise(() => convexClient.close()),\n ).pipe(Effect.map((convexClient) => make(address, convexClient)));\n"],"mappings":";;;;;;;AAOA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA,EACE,OAAO,OAAO,OAAO,EACvB,CACF,CAAC,CAAC,CAAC;AA8BH,MAAa,QAAQ,SAAiB,iBAA4B;CAChE,MAAM,WACJ,YAGA,aAEA,OAAO,WAAW;EAChB,aAAa,SACV,SAAS,OAAO,WAAW,WAAW,IAAI,CAAC,GAC5C,GAAI,WACA,EACG,oBACC,OA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,OAAO,WAAW,WAChB,OAAO,MAAM,QAAQ;GACnB,YAAY,UAAU,OAAO,QAAQ,OAAO,KAAK,KAAK,CAAC;GACvD,YAAY,mBACV,OAAO,MAAM,IAAI,cAAc,KAAK,cAAc,GAAG;IACnD,WAAW,OAAO;IAClB,WAAW,OAAO;GACpB,CAAC;EACL,CAAC,CACH,CACF;CACF;CAEA,MAAM,iBACJ,KACA,GAAG,SAEH,oBAAoB,KAAK,GAAG,IAAI,CAAC,CAAC,KAChC,OAAO,UACL,OAAO,MAAM;EACX,WAAW,OAAO;EAClB,WAAW,OAAO;CACpB,CAAC,CACH,CACF;CAEF,OAAO;EACL,KAAK;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,cACX,SACA,YAEA,OAAO,eAAe,UAAU,iBAC9B,OAAO,cAAc,aAAa,MAAM,CAAC,CAC3C,CAAC,CAAC,KAAK,OAAO,KAAK,iBAAiB,KAAK,SAAS,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"WebSocketClient.js","names":[],"sources":["../../src/internal/WebSocketClient.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport * as Effect from \"effect/Effect\";\nimport * as Queue from \"effect/Queue\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport * as Stream from \"effect/Stream\";\n\nexport class WebSocketClientError extends Schema.TaggedError<WebSocketClientError>()(\n \"WebSocketClientError\",\n {\n cause: Schema.Defect(),\n },\n) {}\n\nexport interface Transport {\n readonly setAuth: (\n fetchToken: (args: {\n readonly forceRefreshToken: boolean;\n }) => Promise<string | null | undefined>,\n onChange?: (isAuthenticated: boolean) => void,\n ) => void;\n readonly close: () => Promise<void>;\n readonly query: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicQuery>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly mutation: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicMutation>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly action: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicAction>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>;\n readonly onUpdate: (\n functionReference: Ref.FunctionReference<Ref.AnyPublicQuery>,\n encodedArgs: unknown,\n onUpdate: (result: unknown) => void,\n onError: (error: Error) => void,\n ) => () => void;\n}\n\nconst runQuery = Effect.fn(\"WebSocketClient.query\")(\n <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,\n);\n\nconst runMutation = Effect.fn(\"WebSocketClient.mutation\")(\n <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,\n);\n\nconst runAction = Effect.fn(\"WebSocketClient.action\")(\n <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,\n);\n\nexport const make = (address: string, convexClient: Transport) => {\n const setAuth = (\n fetchToken: (args: {\n forceRefreshToken: boolean;\n }) => Effect.Effect<string | null | undefined>,\n onChange?: (isAuthenticated: boolean) => Effect.Effect<void>,\n ) =>\n Effect.sync(() => {\n convexClient.setAuth(\n (args) => Effect.runPromise(fetchToken(args)),\n ...(onChange\n ? [\n (isAuthenticated: boolean) =>\n Effect.runFork(onChange(isAuthenticated)),\n ]\n : []),\n );\n });\n\n const mapUnknownError = (cause: unknown) =>\n new WebSocketClientError({ cause });\n\n const query = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Effect.Effect<\n Ref.Returns<Query>,\n Ref.Error<Query> | WebSocketClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Query>;\n return runQuery(\n Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n convexClient.query(functionReference, encodedArgs),\n mapUnknownError,\n ),\n );\n };\n\n const mutation = <Mutation extends Ref.AnyPublicMutation>(\n ref: Mutation,\n ...rest: Ref.OptionalArgs<Mutation>\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | WebSocketClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Mutation>;\n return runMutation(\n Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n convexClient.mutation(functionReference, encodedArgs),\n mapUnknownError,\n ),\n );\n };\n\n const action = <Action extends Ref.AnyPublicAction>(\n ref: Action,\n ...rest: Ref.OptionalArgs<Action>\n ): Effect.Effect<\n Ref.Returns<Action>,\n Ref.Error<Action> | WebSocketClientError | Schema.SchemaError\n > => {\n const args = (rest[0] ?? {}) as Ref.Args<Action>;\n return runAction(\n Ref.runWithCodec(\n ref,\n args,\n (functionReference, encodedArgs) =>\n convexClient.action(functionReference, encodedArgs),\n mapUnknownError,\n ),\n );\n };\n\n type ReactiveQueryError<Query extends Ref.AnyPublicQuery> =\n | Ref.Error<Query>\n | WebSocketClientError\n | Schema.SchemaError;\n\n const reactiveQueryResult = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Stream.Stream<\n Result.Result<Ref.Returns<Query>, ReactiveQueryError<Query>>\n > => {\n type QueryResult = Result.Result<\n Ref.Returns<Query>,\n ReactiveQueryError<Query>\n >;\n const args = (rest[0] ?? {}) as Ref.Args<Query>;\n const functionReference = Ref.getFunctionReference(ref);\n const onError = Ref.decodeErrorOrElse(ref, mapUnknownError);\n\n return Stream.unwrap(\n Effect.match(Ref.encodeArgs(ref, args), {\n onFailure: (error) => Stream.succeed<QueryResult>(Result.fail(error)),\n onSuccess: (encodedArgs) =>\n Stream.callback<Result.Result<unknown, ReactiveQueryError<Query>>>(\n (queue) =>\n Effect.gen(function* () {\n const unsubscribe = convexClient.onUpdate(\n functionReference,\n encodedArgs,\n (result) => {\n Queue.offerUnsafe(queue, Result.succeed(result));\n },\n (error) => {\n Queue.offerUnsafe(queue, Result.fail(onError(error)));\n },\n );\n yield* Effect.addFinalizer(() =>\n Effect.sync(() => unsubscribe()),\n );\n }),\n ),\n }),\n ).pipe(\n Stream.mapEffect((result): Effect.Effect<QueryResult> =>\n Result.match(result, {\n onFailure: (error) => Effect.succeed(Result.fail(error)),\n onSuccess: (encodedReturns) =>\n Effect.match(Ref.decodeReturns(ref, encodedReturns), {\n onFailure: Result.fail,\n onSuccess: Result.succeed,\n }),\n }),\n ),\n );\n };\n\n const reactiveQuery = <Query extends Ref.AnyPublicQuery>(\n ref: Query,\n ...rest: Ref.OptionalArgs<Query>\n ): Stream.Stream<Ref.Returns<Query>, ReactiveQueryError<Query>> =>\n reactiveQueryResult(ref, ...rest).pipe(\n Stream.mapEffect(\n Result.match({\n onFailure: Effect.fail,\n onSuccess: Effect.succeed,\n }),\n ),\n );\n\n return {\n url: address,\n setAuth,\n query,\n mutation,\n action,\n reactiveQuery,\n reactiveQueryResult,\n };\n};\n\nexport const makeScoped = <E, R>(\n address: string,\n acquire: Effect.Effect<Transport, E, R>,\n) =>\n Effect.acquireRelease(acquire, (convexClient) =>\n Effect.promise(() => convexClient.close()),\n ).pipe(Effect.map((convexClient) => make(address, convexClient)));\n"],"mappings":";;;;;;;AAOA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA,EACE,OAAO,OAAO,OAAO,EACvB,CACF,CAAC,CAAC,CAAC;AA8BH,MAAM,WAAW,OAAO,GAAG,uBAAuB,CAAC,EAC1C,WAAqD,MAC9D;AAEA,MAAM,cAAc,OAAO,GAAG,0BAA0B,CAAC,EAChD,WAAqD,MAC9D;AAEA,MAAM,YAAY,OAAO,GAAG,wBAAwB,CAAC,EAC5C,WAAqD,MAC9D;AAEA,MAAa,QAAQ,SAAiB,iBAA4B;CAChE,MAAM,WACJ,YAGA,aAEA,OAAO,WAAW;EAChB,aAAa,SACV,SAAS,OAAO,WAAW,WAAW,IAAI,CAAC,GAC5C,GAAI,WACA,EACG,oBACC,OAAO,QAAQ,SAAS,eAAe,CAAC,CAC5C,IACA,CAAC,CACP;CACF,CAAC;CAEH,MAAM,mBAAmB,UACvB,IAAI,qBAAqB,EAA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AK,KAAK,CAAC;GACvD,YAAY,mBACV,OAAO,MAAM,IAAI,cAAc,KAAK,cAAc,GAAG;IACnD,WAAW,OAAO;IAClB,WAAW,OAAO;GACpB,CAAC;EACL,CAAC,CACH,CACF;CACF;CAEA,MAAM,iBACJ,KACA,GAAG,SAEH,oBAAoB,KAAK,GAAG,IAAI,CAAC,CAAC,KAChC,OAAO,UACL,OAAO,MAAM;EACX,WAAW,OAAO;EAClB,WAAW,OAAO;CACpB,CAAC,CACH,CACF;CAEF,OAAO;EACL,KAAK;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,cACX,SACA,YAEA,OAAO,eAAe,UAAU,iBAC9B,OAAO,cAAc,aAAa,MAAM,CAAC,CAC3C,CAAC,CAAC,KAAK,OAAO,KAAK,iBAAiB,KAAK,SAAS,YAAY,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@confect/js",
3
3
  "description": "JavaScript client bindings for any JS runtime",
4
- "version": "10.0.0-next.21",
4
+ "version": "10.0.0-next.22",
5
5
  "author": "RJ Dellecese",
6
6
  "bugs": {
7
7
  "url": "https://github.com/rjdellecese/confect/issues"
8
8
  },
9
9
  "devDependencies": {
10
- "@effect/vitest": "4.0.0-rc.112",
10
+ "@effect/vitest": "4.0.0-rc.115",
11
11
  "@types/node": "24.13.3",
12
- "effect": "4.0.0-rc.112",
13
- "tsdown": "0.22.14",
12
+ "effect": "4.0.0-rc.115",
13
+ "tsdown": "0.23.0",
14
14
  "typescript": "7.0.2",
15
15
  "unrun": "0.3.1",
16
- "vitest": "4.1.11"
16
+ "vitest": "5.0.0"
17
17
  },
18
18
  "engines": {
19
19
  "node": ">=24"
@@ -47,9 +47,9 @@
47
47
  "main": "./dist/index.js",
48
48
  "module": "./dist/index.js",
49
49
  "peerDependencies": {
50
- "@confect/core": "^10.0.0-next.21",
50
+ "@confect/core": "^10.0.0-next.22",
51
51
  "convex": "^1.32.0",
52
- "effect": "^4.0.0-rc.112"
52
+ "effect": "^4.0.0-rc.115"
53
53
  },
54
54
  "repository": {
55
55
  "type": "git",
@@ -27,6 +27,18 @@ export interface Transport {
27
27
  ) => PromiseLike<unknown>;
28
28
  }
29
29
 
30
+ const runQuery = Effect.fn("HttpClient.query")(
31
+ <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,
32
+ );
33
+
34
+ const runMutation = Effect.fn("HttpClient.mutation")(
35
+ <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,
36
+ );
37
+
38
+ const runAction = Effect.fn("HttpClient.action")(
39
+ <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,
40
+ );
41
+
30
42
  export const make = (client: Transport) => {
31
43
  const setAuth = (token: string) =>
32
44
  Effect.sync(() => {
@@ -47,12 +59,14 @@ export const make = (client: Transport) => {
47
59
  Ref.Error<Query> | HttpClientError | Schema.SchemaError
48
60
  > => {
49
61
  const args = (rest[0] ?? {}) as Ref.Args<Query>;
50
- return Ref.runWithCodec(
51
- ref,
52
- args,
53
- (functionReference, encodedArgs) =>
54
- client.query(functionReference, encodedArgs),
55
- mapUnknownError,
62
+ return runQuery(
63
+ Ref.runWithCodec(
64
+ ref,
65
+ args,
66
+ (functionReference, encodedArgs) =>
67
+ client.query(functionReference, encodedArgs),
68
+ mapUnknownError,
69
+ ),
56
70
  );
57
71
  };
58
72
 
@@ -64,12 +78,14 @@ export const make = (client: Transport) => {
64
78
  Ref.Error<Mutation> | HttpClientError | Schema.SchemaError
65
79
  > => {
66
80
  const args = (rest[0] ?? {}) as Ref.Args<Mutation>;
67
- return Ref.runWithCodec(
68
- ref,
69
- args,
70
- (functionReference, encodedArgs) =>
71
- client.mutation(functionReference, encodedArgs),
72
- mapUnknownError,
81
+ return runMutation(
82
+ Ref.runWithCodec(
83
+ ref,
84
+ args,
85
+ (functionReference, encodedArgs) =>
86
+ client.mutation(functionReference, encodedArgs),
87
+ mapUnknownError,
88
+ ),
73
89
  );
74
90
  };
75
91
 
@@ -81,12 +97,14 @@ export const make = (client: Transport) => {
81
97
  Ref.Error<Action> | HttpClientError | Schema.SchemaError
82
98
  > => {
83
99
  const args = (rest[0] ?? {}) as Ref.Args<Action>;
84
- return Ref.runWithCodec(
85
- ref,
86
- args,
87
- (functionReference, encodedArgs) =>
88
- client.action(functionReference, encodedArgs),
89
- mapUnknownError,
100
+ return runAction(
101
+ Ref.runWithCodec(
102
+ ref,
103
+ args,
104
+ (functionReference, encodedArgs) =>
105
+ client.action(functionReference, encodedArgs),
106
+ mapUnknownError,
107
+ ),
90
108
  );
91
109
  };
92
110
 
@@ -40,6 +40,18 @@ export interface Transport {
40
40
  ) => () => void;
41
41
  }
42
42
 
43
+ const runQuery = Effect.fn("WebSocketClient.query")(
44
+ <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,
45
+ );
46
+
47
+ const runMutation = Effect.fn("WebSocketClient.mutation")(
48
+ <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,
49
+ );
50
+
51
+ const runAction = Effect.fn("WebSocketClient.action")(
52
+ <A, E>(effect: Effect.Effect<A, E>): Effect.Effect<A, E> => effect,
53
+ );
54
+
43
55
  export const make = (address: string, convexClient: Transport) => {
44
56
  const setAuth = (
45
57
  fetchToken: (args: {
@@ -70,12 +82,14 @@ export const make = (address: string, convexClient: Transport) => {
70
82
  Ref.Error<Query> | WebSocketClientError | Schema.SchemaError
71
83
  > => {
72
84
  const args = (rest[0] ?? {}) as Ref.Args<Query>;
73
- return Ref.runWithCodec(
74
- ref,
75
- args,
76
- (functionReference, encodedArgs) =>
77
- convexClient.query(functionReference, encodedArgs),
78
- mapUnknownError,
85
+ return runQuery(
86
+ Ref.runWithCodec(
87
+ ref,
88
+ args,
89
+ (functionReference, encodedArgs) =>
90
+ convexClient.query(functionReference, encodedArgs),
91
+ mapUnknownError,
92
+ ),
79
93
  );
80
94
  };
81
95
 
@@ -87,12 +101,14 @@ export const make = (address: string, convexClient: Transport) => {
87
101
  Ref.Error<Mutation> | WebSocketClientError | Schema.SchemaError
88
102
  > => {
89
103
  const args = (rest[0] ?? {}) as Ref.Args<Mutation>;
90
- return Ref.runWithCodec(
91
- ref,
92
- args,
93
- (functionReference, encodedArgs) =>
94
- convexClient.mutation(functionReference, encodedArgs),
95
- mapUnknownError,
104
+ return runMutation(
105
+ Ref.runWithCodec(
106
+ ref,
107
+ args,
108
+ (functionReference, encodedArgs) =>
109
+ convexClient.mutation(functionReference, encodedArgs),
110
+ mapUnknownError,
111
+ ),
96
112
  );
97
113
  };
98
114
 
@@ -104,12 +120,14 @@ export const make = (address: string, convexClient: Transport) => {
104
120
  Ref.Error<Action> | WebSocketClientError | Schema.SchemaError
105
121
  > => {
106
122
  const args = (rest[0] ?? {}) as Ref.Args<Action>;
107
- return Ref.runWithCodec(
108
- ref,
109
- args,
110
- (functionReference, encodedArgs) =>
111
- convexClient.action(functionReference, encodedArgs),
112
- mapUnknownError,
123
+ return runAction(
124
+ Ref.runWithCodec(
125
+ ref,
126
+ args,
127
+ (functionReference, encodedArgs) =>
128
+ convexClient.action(functionReference, encodedArgs),
129
+ mapUnknownError,
130
+ ),
113
131
  );
114
132
  };
115
133