@gaganref/confect-foldkit 0.0.0-stage → 10.3.1-fork.10
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 +495 -0
- package/LICENSE +7 -0
- package/README.md +16 -2
- package/dist/Client.d.ts +69 -0
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +44 -0
- package/dist/Client.js.map +1 -0
- package/dist/Command.d.ts +162 -0
- package/dist/Command.d.ts.map +1 -0
- package/dist/Command.js +115 -0
- package/dist/Command.js.map +1 -0
- package/dist/PaginatedQuery.d.ts +291 -0
- package/dist/PaginatedQuery.d.ts.map +1 -0
- package/dist/PaginatedQuery.js +395 -0
- package/dist/PaginatedQuery.js.map +1 -0
- package/dist/Subscription.d.ts +134 -0
- package/dist/Subscription.d.ts.map +1 -0
- package/dist/Subscription.js +123 -0
- package/dist/Subscription.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/package.json +55 -3
- package/src/Client.ts +53 -0
- package/src/Command.ts +456 -0
- package/src/PaginatedQuery.ts +1066 -0
- package/src/Subscription.ts +340 -0
- package/src/index.ts +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
# @confect/foldkit
|
|
2
|
+
|
|
3
|
+
## 10.3.1
|
|
4
|
+
|
|
5
|
+
No changes in this release.
|
|
6
|
+
|
|
7
|
+
## 10.3.0
|
|
8
|
+
|
|
9
|
+
No changes in this release.
|
|
10
|
+
|
|
11
|
+
## 10.2.0
|
|
12
|
+
|
|
13
|
+
No changes in this release.
|
|
14
|
+
|
|
15
|
+
## 10.1.0
|
|
16
|
+
|
|
17
|
+
No changes in this release.
|
|
18
|
+
|
|
19
|
+
## 10.0.0
|
|
20
|
+
|
|
21
|
+
### Major Changes
|
|
22
|
+
|
|
23
|
+
- c05ae0b: Migrate Confect to Effect 4, add middleware, experimental composable query streams, Foldkit bindings, and Convex AI gateway integrations. This release requires changes to function argument declarations, HTTP routers, runner calls, and test setup when upgrading from v9.
|
|
24
|
+
|
|
25
|
+
### Requirements
|
|
26
|
+
- All Confect packages require Node.js 24 or later and `effect ^4.0.0`.
|
|
27
|
+
- `@confect/server` requires `convex ^1.45.0`.
|
|
28
|
+
- `@confect/server`'s optional `@effect/platform-node` peer requires `^4.0.0` for Node actions.
|
|
29
|
+
- The new `@confect/foldkit` package requires `foldkit ^0.165.0`.
|
|
30
|
+
|
|
31
|
+
Confect no longer depends on `@effect/platform` or `@effect/cli`. Run `confect codegen` to regenerate the v10 bindings after updating your Confect declarations.
|
|
32
|
+
|
|
33
|
+
### Breaking changes
|
|
34
|
+
|
|
35
|
+
#### Declare function arguments as lazy field maps
|
|
36
|
+
|
|
37
|
+
Pass a callback returning the fields of an argument object, rather than a callback returning `Schema.Struct`. This applies to queries, mutations, actions, and paginated queries. You can omit `args` when a function takes no arguments; Confect supplies an empty object. Keep `returns`, `item`, and `error` as callbacks returning schemas.
|
|
38
|
+
|
|
39
|
+
**Before:**
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { FunctionSpec } from "@confect/core";
|
|
43
|
+
import * as Schema from "effect/Schema";
|
|
44
|
+
|
|
45
|
+
FunctionSpec.publicQuery({
|
|
46
|
+
name: "greet",
|
|
47
|
+
args: () => Schema.Struct({ name: Schema.String }),
|
|
48
|
+
returns: () => Schema.String,
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**After:**
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { FunctionSpec } from "@confect/core";
|
|
56
|
+
import * as Schema from "effect/Schema";
|
|
57
|
+
|
|
58
|
+
FunctionSpec.publicQuery({
|
|
59
|
+
name: "greet",
|
|
60
|
+
args: () => ({ name: Schema.String }),
|
|
61
|
+
returns: () => Schema.String,
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Keep table declarations client-safe
|
|
66
|
+
|
|
67
|
+
Import `Table` from `@confect/core` in your table declarations. Specs can then return a generated table's `Doc` without pulling server code into the client. `confect codegen` rejects value imports of `@confect/server` anywhere reachable from a spec, including table and generated modules. Type-only imports remain allowed.
|
|
68
|
+
|
|
69
|
+
**Before:**
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { Table } from "@confect/server";
|
|
73
|
+
import * as Schema from "effect/Schema";
|
|
74
|
+
|
|
75
|
+
export default Table.make(() => Schema.Struct({ text: Schema.String }));
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**After:**
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { Table } from "@confect/core";
|
|
82
|
+
import * as Schema from "effect/Schema";
|
|
83
|
+
|
|
84
|
+
export default Table.make(() => Schema.Struct({ text: Schema.String }));
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Table declarations still return a schema, not the field maps now used by function arguments. The server's `Table` re-exports remain available for server-only use. Run `confect codegen` to regenerate the deploy schema and client-safe table bindings.
|
|
88
|
+
|
|
89
|
+
#### Use serializable schemas and handle updated errors
|
|
90
|
+
|
|
91
|
+
Confect function schemas must encode to Convex values. Use a serializable codec such as `Schema.OptionFromNullOr(...)` for an `Option` crossing that boundary: `Schema.Option` no longer provides the serialized representation expected there.
|
|
92
|
+
|
|
93
|
+
Table schemas support object-shaped transformations, encoded-key mappings, brands, suspended schemas, and unions of those schemas while retaining Convex system fields. Every step must remain object-shaped; class schemas such as `Schema.Class` are not valid table schemas.
|
|
94
|
+
|
|
95
|
+
Decode failures now use `Schema.SchemaError` instead of `ParseError`, including JavaScript clients, React hooks, and test helpers. React `useMutation` and `useAction` calls with declared errors return Effect `Result` values instead of `Either` values. Update matching and error annotations accordingly.
|
|
96
|
+
|
|
97
|
+
#### Replace HTTP API mounts with route layers
|
|
98
|
+
|
|
99
|
+
Replace Confect's `HttpApi.make` with `HttpRouter.make`. The old record of path prefixes and `apiLive`, `middleware`, and `scalar` options is replaced by one layer registering all routes. Build API routes with Effect's `HttpApiBuilder.layer`, provide each group's handlers, and add Scalar documentation explicitly.
|
|
100
|
+
|
|
101
|
+
For an API named `Api` and its group handler layer `ApiLive`:
|
|
102
|
+
|
|
103
|
+
**Before:**
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { HttpApi as ConfectHttpApi } from "@confect/server";
|
|
107
|
+
import * as HttpApiBuilder from "@effect/platform/HttpApiBuilder";
|
|
108
|
+
import * as Layer from "effect/Layer";
|
|
109
|
+
|
|
110
|
+
export default ConfectHttpApi.make({
|
|
111
|
+
"/api/": {
|
|
112
|
+
apiLive: HttpApiBuilder.api(Api).pipe(Layer.provide(ApiLive)),
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**After:**
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { HttpRouter as ConfectHttpRouter } from "@confect/server";
|
|
121
|
+
import * as Layer from "effect/Layer";
|
|
122
|
+
import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
|
|
123
|
+
import * as HttpApiScalar from "effect/http-api/HttpApiScalar";
|
|
124
|
+
|
|
125
|
+
export default ConfectHttpRouter.make(
|
|
126
|
+
Layer.mergeAll(
|
|
127
|
+
HttpApiBuilder.layer(Api).pipe(Layer.provide(ApiLive)),
|
|
128
|
+
HttpApiScalar.layer(Api, { path: "/api/docs" }),
|
|
129
|
+
),
|
|
130
|
+
);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Put the endpoint prefix on the Effect API itself, for example with `.prefix("/api")`. For interactive documentation, configure Scalar's `baseServerURL` with your deployment's site URL. Missing API handler groups are compile-time errors. You can merge plain routes from `effect/http/HttpRouter.add` and global middleware from `HttpRouter.middleware` into the same layer.
|
|
134
|
+
|
|
135
|
+
The returned Convex router serves Effect routes through a catch-all at `/`; plain Convex routes added to it still take precedence. Route-layer construction, handlers, and middleware can read Convex environment variables through Confect's configuration provider.
|
|
136
|
+
|
|
137
|
+
#### Call named runner methods
|
|
138
|
+
|
|
139
|
+
`QueryRunner`, `MutationRunner`, and `ActionRunner` are no longer callable services. Destructure `runQuery`, `runMutation`, or `runAction` instead.
|
|
140
|
+
|
|
141
|
+
**Before:**
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import * as Effect from "effect/Effect";
|
|
145
|
+
|
|
146
|
+
const firstNote = Effect.gen(function* () {
|
|
147
|
+
const runQuery = yield* QueryRunner;
|
|
148
|
+
return yield* runQuery(refs.public.notes.getFirst, {});
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**After:**
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import * as Effect from "effect/Effect";
|
|
156
|
+
|
|
157
|
+
const firstNote = Effect.gen(function* () {
|
|
158
|
+
const { runQuery } = yield* QueryRunner;
|
|
159
|
+
return yield* runQuery(refs.public.notes.getFirst, {});
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Runner availability is unchanged. Inside queries or mutations, `runQuery` also accepts a third argument such as `{ transactionLimits: { documentsRead: 100 } }`. Inside mutations, `runMutation` accepts limits such as `{ transactionLimits: { documentsWritten: 10 } }`, and `runQuery` can request `useStaleSnapshot`. Supplying `useStaleSnapshot` requires a mutation context even when it is `false`. Actions and HTTP handlers use runners without transaction options; `runAction` has no options argument.
|
|
164
|
+
|
|
165
|
+
#### Yield upload URL generation directly
|
|
166
|
+
|
|
167
|
+
`StorageWriter.generateUploadUrl` is an Effect value instead of a zero-argument function.
|
|
168
|
+
|
|
169
|
+
**Before:**
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import * as Effect from "effect/Effect";
|
|
173
|
+
|
|
174
|
+
const uploadUrl = Effect.gen(function* () {
|
|
175
|
+
const storage = yield* StorageWriter;
|
|
176
|
+
return yield* storage.generateUploadUrl();
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**After:**
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import * as Effect from "effect/Effect";
|
|
184
|
+
|
|
185
|
+
const uploadUrl = Effect.gen(function* () {
|
|
186
|
+
const storage = yield* StorageWriter;
|
|
187
|
+
return yield* storage.generateUploadUrl;
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Methods that take arguments, such as `delete(storageId)`, remain functions.
|
|
192
|
+
|
|
193
|
+
#### Provide test layers without an extra call
|
|
194
|
+
|
|
195
|
+
`TestConfect.layer(schema, convexSchema, modules)` now returns a layer directly instead of a function returning that layer. For a project that exports the result as `TestConfect.layer`:
|
|
196
|
+
|
|
197
|
+
**Before:**
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
const test = testEffect.pipe(Effect.provide(TestConfect.layer()));
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**After:**
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
const test = testEffect.pipe(Effect.provide(TestConfect.layer));
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Each separate provision still creates a fresh test database.
|
|
210
|
+
|
|
211
|
+
#### Update handwritten container annotations
|
|
212
|
+
|
|
213
|
+
Read assembled groups with `Spec.groups(spec)` instead of `spec.groups`, and tables with `DatabaseSchema.tables(schema)` instead of `schema.tables`. Explicit `Spec.Spec`, `DatabaseSchema.DatabaseSchema`, and `DataModel.DataModel` annotations now take a record keyed by name rather than a union of members.
|
|
214
|
+
|
|
215
|
+
**Before:**
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
type AppSpec = Spec.Spec<typeof notesGroup>;
|
|
219
|
+
type AppSchema = DatabaseSchema.DatabaseSchema<typeof notesTable>;
|
|
220
|
+
type AppDataModel = DataModel.DataModel<typeof notesTable>;
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**After:**
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
type AppSpec = Spec.Spec<{ readonly notes: typeof notesGroup }>;
|
|
227
|
+
type AppSchema = DatabaseSchema.DatabaseSchema<{
|
|
228
|
+
readonly notes: typeof notesTable;
|
|
229
|
+
}>;
|
|
230
|
+
type AppDataModel = DataModel.DataModel<{
|
|
231
|
+
readonly notes: typeof notesTable;
|
|
232
|
+
}>;
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Ordinary builder calls are unchanged, and `DataModel.FromTables` still accepts a table union. Adding a group under an existing name replaces both its value and its inferred type. Run `confect codegen` rather than editing generated annotations.
|
|
236
|
+
|
|
237
|
+
#### Review configuration and time-dependent queries
|
|
238
|
+
|
|
239
|
+
Confect's configuration provider now treats empty-string environment variables as missing values, so `Config.withDefault` and `Config.option` recover from them.
|
|
240
|
+
|
|
241
|
+
Raw `Date.now()` calls in queries now observe time and invalidate Convex's query cache instead of returning v9's globally stubbed value. Explicit Effect clock reads such as `Clock.currentTimeMillis` and `Clock.currentTimeNanos` continue to opt into time tracking. Effect's internal timestamps for logging and tracing do not invalidate the cache.
|
|
242
|
+
|
|
243
|
+
### Middleware with typed services and errors
|
|
244
|
+
|
|
245
|
+
Add reusable policies in `confect/middleware/`, with a client-safe `<Name>.spec.ts` and a server-side `<Name>.impl.ts`. This directory is reserved and can no longer contain ordinary function groups.
|
|
246
|
+
|
|
247
|
+
Declare a policy with `MiddlewareSpec.MiddlewareSpec`, including its provided services, error schema, and explicit query/mutation/action coverage. Attach it with `.middleware(Policy)` on a group or individual function, or declare an `options` schema and use `.middleware(Policy, options)`. Options are validated without coercion and must be client-safe because generated refs carry them.
|
|
248
|
+
|
|
249
|
+
Implement policies with `MiddlewareImpl.make`, `MiddlewareImpl.makeByFunctionType`, or `MiddlewareImpl.provides`, then supply the implementation to the group layer. Callbacks receive `{ invocation }`, plus `options` when declared. Policies run after argument decoding, with group policies before function policies, and can supply services to later policies and handlers. Typed policy failures reach clients alongside function errors and short-circuit the remaining chain.
|
|
250
|
+
|
|
251
|
+
The same policy can run more than once with different options; equivalent attachments are rejected. Coverage and service dependencies are checked, missing implementations fail codegen, middleware does not propagate to subgroups, and plain Convex functions cannot have Confect middleware attached.
|
|
252
|
+
|
|
253
|
+
### Experimental composable query streams
|
|
254
|
+
|
|
255
|
+
Use `reader.table(...).stream(index, range?, order?)` and `QueryStream` from `@confect/server` to merge, filter, map, join, deduplicate, narrow, and reverse indexed queries while retaining cursor pagination. Ordering compatibility is checked, joins can provide left-join placeholders, effectful filters and maps support ordered concurrency, and reversing a distinct stream preserves its selected representatives.
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
import { QueryStream } from "@confect/server";
|
|
259
|
+
import * as Effect from "effect/Effect";
|
|
260
|
+
|
|
261
|
+
const firstPage = Effect.gen(function* () {
|
|
262
|
+
const reader = yield* DatabaseReader;
|
|
263
|
+
const stream = reader.table("notes").stream("by_creation_time");
|
|
264
|
+
return yield* QueryStream.paginate(stream, {
|
|
265
|
+
cursor: null,
|
|
266
|
+
numItems: 20,
|
|
267
|
+
maximumRowsRead: 1000,
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Read budgets count underlying reads, including documents filtered out of the result; byte budgets are estimates. Invalid page sizes and read limits are rejected before reads. If a budget prevents safe progress or splitting, pagination fails rather than skipping results. Increase the budget or reduce the query's read requirements.
|
|
273
|
+
|
|
274
|
+
Use React's new `useStreamPaginatedQuery` for stream-backed paginated queries. It pins loaded page ranges, handles page splits, and restarts on invalid cursors. Foldkit pagination also preserves page ranges during navigation. Ordinary paginated queries and `usePaginatedQuery` remain available.
|
|
275
|
+
|
|
276
|
+
All `QueryStream` APIs are experimental. Treat cursors as opaque continuation values, but do not treat them as confidential: they expose order-key values. Avoid public pagination over sensitive indexed fields unless those fields are fixed with `eq`.
|
|
277
|
+
|
|
278
|
+
### Foldkit client bindings
|
|
279
|
+
|
|
280
|
+
Add `@confect/foldkit` for Foldkit applications. `Client.layer` provides the scoped client; `Command.query`, `Command.mutation`, and `Command.action` turn Confect calls into commands with declared messages and required success/error handlers. The factories support Foldkit interruption, and the corresponding `queryEffect`, `mutationEffect`, and `actionEffect` helpers support handwritten command definitions.
|
|
281
|
+
|
|
282
|
+
`Subscription.reactiveQuery` follows optional arguments derived from your model and manages the live query subscription. `PaginatedQuery` and `Subscription.paginatedQuery` provide reactive next/previous-page navigation, preserve the last complete page while refreshing, ignore superseded settlements, and recover from invalid cursors. Failed refreshes retain stale data, and typed function errors remain available to your message handlers.
|
|
283
|
+
|
|
284
|
+
### Convex AI gateway models
|
|
285
|
+
|
|
286
|
+
Use `AiGatewayLanguageClient` and `AiGatewayLanguageModel` to call language models through the Convex AI gateway from actions without supplying provider API keys. Use `AiGatewayDecisionClient` and `AiGatewayDecisionModel` with Effect's `DecisionModel` to classify inputs, apply rubrics, and estimate probabilities.
|
|
287
|
+
|
|
288
|
+
```ts
|
|
289
|
+
import {
|
|
290
|
+
AiGatewayLanguageClient,
|
|
291
|
+
AiGatewayLanguageModel,
|
|
292
|
+
} from "@confect/server";
|
|
293
|
+
import * as Layer from "effect/Layer";
|
|
294
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
295
|
+
|
|
296
|
+
const Claude = AiGatewayLanguageModel.model(
|
|
297
|
+
"anthropic/claude-sonnet-4.5",
|
|
298
|
+
).pipe(
|
|
299
|
+
Layer.provide(AiGatewayLanguageClient.layer),
|
|
300
|
+
Layer.provide(FetchHttpClient.layer),
|
|
301
|
+
);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Provide the model to Effect AI operations from `effect/ai`. Disabled or unavailable gateways report typed errors during client construction. Both gateway clients obtain current service credentials before each request, including when reused in long-running actions.
|
|
305
|
+
|
|
306
|
+
### Storage, metadata, logging, and authentication
|
|
307
|
+
- Use the unified generated `Storage` service for download URLs, upload URLs, deletion, blob reads, and blob writes. Each operation retains its context restrictions; the existing storage services remain supported.
|
|
308
|
+
- Cancel scheduled functions with `Scheduler.cancel(id)`, using the ID returned by `runAfter` or `runAt`.
|
|
309
|
+
- Read function and deployment information with `ExecutionMetadata`, request information with `RequestMetadata`, and transaction metrics with `TransactionMetadata`. Generated services expose them only in the contexts that support each capability.
|
|
310
|
+
- `Effect.log*` output uses matching Convex severities in functions and HTTP routes while preserving Effect metadata and custom loggers. `ConvexLogger` is available for explicit configuration, and logs remain associated with the current invocation when Node actions reuse a process.
|
|
311
|
+
- JavaScript `WebSocketClient` and Foldkit `Client` authentication callbacks can require Effect services. Supply them when running `setAuth` and keep scoped dependencies alive while authentication is registered; later token refreshes use the supplied services.
|
|
312
|
+
- JavaScript clients support per-module imports such as `@confect/js/WebSocketClient` and `@confect/js/HttpClient`; root imports are unchanged.
|
|
313
|
+
|
|
314
|
+
### Fixes and diagnostics
|
|
315
|
+
- Preserve precise function error types when `exactOptionalPropertyTypes` is disabled, rather than widening functions without declared errors to `any`.
|
|
316
|
+
- Exclude `_id` and `_creationTime` from patch value types derived from full documents.
|
|
317
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect.
|
|
318
|
+
- Reject non-finite values in Confect's schemas for system timestamps, stored file sizes, and pagination options. User-authored `Schema.Number` fields can still represent Convex's non-finite numbers.
|
|
319
|
+
- Keep queries, mutations, and module initialization compatible with Convex's timer restrictions during long Effect computations.
|
|
320
|
+
- Fail codegen with a descriptive error for malformed `convex.json` instead of silently ignoring it.
|
|
321
|
+
- Add tracing spans for client calls, server functions, database writes and pagination, stream consumers, and code-generation passes.
|
|
322
|
+
|
|
323
|
+
## 10.0.0-next.27
|
|
324
|
+
|
|
325
|
+
### Minor Changes
|
|
326
|
+
|
|
327
|
+
- 6424f03: Require stable `effect@^4.0.0` and matching Effect platform and AI provider packages. `@confect/foldkit` now requires `foldkit@^0.165.0`, which supports Effect 4.0.0 without a peer-dependency override.
|
|
328
|
+
|
|
329
|
+
## 10.0.0-next.26
|
|
330
|
+
|
|
331
|
+
No changes in this release.
|
|
332
|
+
|
|
333
|
+
## 10.0.0-next.25
|
|
334
|
+
|
|
335
|
+
### Minor Changes
|
|
336
|
+
|
|
337
|
+
- 1660d3a: Allow `setAuth` callbacks on `WebSocketClient` and Foldkit's `Client` to require Effect services. Provide those services when running `setAuth`; the token provider and authentication-state callback use them for later invocations, including token refreshes.
|
|
338
|
+
|
|
339
|
+
Keep scoped callback dependencies alive while authentication remains registered. Callbacks without dependencies continue to work unchanged.
|
|
340
|
+
|
|
341
|
+
### Patch Changes
|
|
342
|
+
|
|
343
|
+
- f9958b9: Require `effect@^4.0.0-rc.118` and matching Effect platform packages. Upgrade Effect alongside Confect and replace `effect/unstable/*` imports with `effect/*`, using `effect/http-api` for HTTP API imports.
|
|
344
|
+
|
|
345
|
+
## 10.0.0-next.24
|
|
346
|
+
|
|
347
|
+
### Patch Changes
|
|
348
|
+
|
|
349
|
+
- 850a3c3: Require `effect@^4.0.0-rc.117` across `@confect/*` and `@effect/platform-node@^4.0.0-rc.117` for `@confect/server`'s optional Node integration. Upgrade these dependencies alongside Confect; existing Confect call sites are unchanged.
|
|
350
|
+
|
|
351
|
+
## 10.0.0-next.23
|
|
352
|
+
|
|
353
|
+
No changes in this release.
|
|
354
|
+
|
|
355
|
+
## 10.0.0-next.22
|
|
356
|
+
|
|
357
|
+
### Minor Changes
|
|
358
|
+
|
|
359
|
+
- 6cc5834: Add experimental stream querying with reactive pagination, configurable middleware policies, and broader tracing.
|
|
360
|
+
|
|
361
|
+
### Stream queries and pagination
|
|
362
|
+
|
|
363
|
+
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.
|
|
364
|
+
|
|
365
|
+
`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.
|
|
366
|
+
|
|
367
|
+
Use React's new `useStreamPaginatedQuery` for these queries:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
import { useStreamPaginatedQuery } from "@confect/react";
|
|
371
|
+
|
|
372
|
+
const { results, status, loadMore } = useStreamPaginatedQuery(
|
|
373
|
+
refs.public.notes.feed,
|
|
374
|
+
{},
|
|
375
|
+
{
|
|
376
|
+
initialNumItems: 10,
|
|
377
|
+
maximumRowsRead: 1000,
|
|
378
|
+
maximumBytesRead: 512 * 1024,
|
|
379
|
+
},
|
|
380
|
+
);
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
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.
|
|
384
|
+
|
|
385
|
+
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.
|
|
386
|
+
|
|
387
|
+
### Middleware options
|
|
388
|
+
|
|
389
|
+
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.
|
|
390
|
+
|
|
391
|
+
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.
|
|
392
|
+
|
|
393
|
+
### Breaking changes
|
|
394
|
+
|
|
395
|
+
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`:
|
|
396
|
+
|
|
397
|
+
**Before:**
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
(effect, { name, args }) => effect;
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**After:**
|
|
404
|
+
|
|
405
|
+
```ts
|
|
406
|
+
(effect, { invocation: { name, args } }) => effect;
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Middleware with an options schema also receives `options` alongside `invocation`; middleware without one keeps its single-argument attachment API and receives only `{ invocation }`.
|
|
410
|
+
|
|
411
|
+
### Fixes and tracing
|
|
412
|
+
- Preserve `ConvexError.data` when a handler throws a `ConvexError` inside an Effect instead of returning it as a typed failure.
|
|
413
|
+
- 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.
|
|
414
|
+
|
|
415
|
+
### Patch Changes
|
|
416
|
+
|
|
417
|
+
- 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.
|
|
418
|
+
|
|
419
|
+
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.
|
|
420
|
+
|
|
421
|
+
- 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.
|
|
422
|
+
- f721d2c: Remove spaces around em dashes and separator slashes in API documentation and `confect codegen` diagnostics.
|
|
423
|
+
|
|
424
|
+
## 10.0.0-next.21
|
|
425
|
+
|
|
426
|
+
### Major Changes
|
|
427
|
+
|
|
428
|
+
- a6425c5: Raise the minimum supported Node.js version to 24.
|
|
429
|
+
|
|
430
|
+
### Breaking Changes
|
|
431
|
+
- `engines.node` is now `>=24` on every `@confect/*` package, raised from `>=22`.
|
|
432
|
+
|
|
433
|
+
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.
|
|
434
|
+
|
|
435
|
+
## 10.0.0-next.20
|
|
436
|
+
|
|
437
|
+
## 10.0.0-next.19
|
|
438
|
+
|
|
439
|
+
### Minor Changes
|
|
440
|
+
|
|
441
|
+
- 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.
|
|
442
|
+
|
|
443
|
+
```ts
|
|
444
|
+
import * as Confect from "@confect/foldkit";
|
|
445
|
+
import * as Schema from "effect/Schema";
|
|
446
|
+
import * as Subscription from "foldkit/subscription";
|
|
447
|
+
|
|
448
|
+
const SaveNote = Confect.Command.mutation(
|
|
449
|
+
"SaveNote",
|
|
450
|
+
refs.public.notes.insert,
|
|
451
|
+
{
|
|
452
|
+
messages: [SucceededSaveNote, FailedSaveNote],
|
|
453
|
+
onSuccess: (noteId) => SucceededSaveNote({ noteId }),
|
|
454
|
+
onError: (error) => FailedSaveNote({ message: String(error) }),
|
|
455
|
+
},
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
const subscriptions = Subscription.make<
|
|
459
|
+
Model,
|
|
460
|
+
Message,
|
|
461
|
+
Confect.Client.Client
|
|
462
|
+
>()(() => ({
|
|
463
|
+
note: Confect.Subscription.reactiveQuery<Model>()(refs.public.notes.get, {
|
|
464
|
+
args: (model) => Option.map(model.noteId, (noteId) => ({ noteId })),
|
|
465
|
+
onSuccess: (note) => SucceededGetNote({ note }),
|
|
466
|
+
onError: (error) => FailedGetNote({ message: String(error) }),
|
|
467
|
+
}),
|
|
468
|
+
}));
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
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.
|
|
472
|
+
|
|
473
|
+
`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.
|
|
474
|
+
|
|
475
|
+
`Subscription.paginatedQuery` keeps exactly one live, reactive page subscription in sync with the machine and emits one `onSettled` Message shape for either outcome. It allocates Convex's pagination `id` internally and returns it with the first settlement, so session allocation is not a separate Command or application Message. Installing that id is keep-alive-equivalent and does not restart the subscription. Query errors are emitted as values without closing the underlying Convex subscription, allowing a later successful result to recover naturally. Each request supports `maximumRowsRead` and `maximumBytesRead` and uses `initialNumItems` for the initial page and split heuristic. Page splits remain transparent, the last complete page stays visible during navigation and after refresh failure, and an empty terminal page automatically retreats to the preceding page.
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
const Notes = Confect.PaginatedQuery.make(refs.public.notes.paginate);
|
|
479
|
+
|
|
480
|
+
// Model: notes: Notes.schema
|
|
481
|
+
// Initial Model value: notes: Notes.idle
|
|
482
|
+
// Message: settlement: Notes.settlement
|
|
483
|
+
// update after matching Idle: Notes.init(idle, { channel }, { initialNumItems: 20 })
|
|
484
|
+
|
|
485
|
+
const subscriptions = Subscription.make<
|
|
486
|
+
Model,
|
|
487
|
+
Message,
|
|
488
|
+
Confect.Client.Client
|
|
489
|
+
>()(() => ({
|
|
490
|
+
notesPage: Confect.Subscription.paginatedQuery<Model>()(Notes, {
|
|
491
|
+
state: (model) => model.notes,
|
|
492
|
+
onSettled: (settlement) => SettledGetNotesPage({ settlement }),
|
|
493
|
+
}),
|
|
494
|
+
}));
|
|
495
|
+
```
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright 2024 RJ Dellecese
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Confect 🧁
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This is a fork of [Confect](https://github.com/rjdellecese/confect). See [FORK.md](FORK.md) for builds, installation, and maintenance, and [CHANGES.md](CHANGES.md) for the fork additions.
|
|
4
|
+
|
|
5
|
+
## About Confect
|
|
6
|
+
|
|
7
|
+
Confect is a framework that deeply integrates Effect with Convex. It's more than just Effect bindings! Confect allows you to:
|
|
8
|
+
|
|
9
|
+
- Define your Convex database schema using Effect schemas.
|
|
10
|
+
- Write Convex function args and returns validators using Effect's schema library.
|
|
11
|
+
- Use Confect functions to automatically decode and encode your data according to your Effect schema definitions for end-to-end rich types, from client to function to database (and back).
|
|
12
|
+
- Add reusable, type-safe middleware to function groups or individual functions to provide Effect services and run logic around handlers.
|
|
13
|
+
- Declare typed errors on functions and middleware using Effect schemas, then handle the decoded errors at every call site.
|
|
14
|
+
- Use Effect's native HTTP API modules to define your HTTP API.
|
|
15
|
+
- Access Convex platform capabilities via Effect services.
|
|
16
|
+
|
|
17
|
+
Want to learn more? Read the [docs](https://confect.dev)!
|
package/dist/Client.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as WebSocketClient from "@confect/js/WebSocketClient";
|
|
2
|
+
import type { ConvexClient } from "convex/browser";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
/**
|
|
8
|
+
* Builds the Foldkit-facing Confect client around one WebSocket client. The
|
|
9
|
+
* pagination id allocator shares the WebSocket client's lifetime because its
|
|
10
|
+
* ids are cache-busters for that client's query cache.
|
|
11
|
+
*/
|
|
12
|
+
export declare const make: (webSocketClient: WebSocketClient.WebSocketClient) => Effect.Effect<{
|
|
13
|
+
url: string;
|
|
14
|
+
setAuth: <R1 = never, R2 = never>(fetchToken: (args: {
|
|
15
|
+
forceRefreshToken: boolean;
|
|
16
|
+
}) => Effect.Effect<string | null | undefined, never, R1>, onChange?: (isAuthenticated: boolean) => Effect.Effect<void, never, R2>) => Effect.Effect<void, never, R1 | R2>;
|
|
17
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => Effect.Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
18
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => Effect.Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
19
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => Effect.Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
20
|
+
reactiveQuery: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>;
|
|
21
|
+
reactiveQueryResult: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("effect/Result").Result<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>>;
|
|
22
|
+
resolvePaginationId: (restored: Option.Option<number>) => Effect.Effect<number, never, never>;
|
|
23
|
+
}, never, never>;
|
|
24
|
+
/**
|
|
25
|
+
* The application-scoped Confect client used by Foldkit Commands and
|
|
26
|
+
* Subscriptions. It combines the WebSocket API with the pagination-session id
|
|
27
|
+
* allocator required by Convex's query cache.
|
|
28
|
+
*/
|
|
29
|
+
export declare const Client: Context.Service<{
|
|
30
|
+
url: string;
|
|
31
|
+
setAuth: <R1 = never, R2 = never>(fetchToken: (args: {
|
|
32
|
+
forceRefreshToken: boolean;
|
|
33
|
+
}) => Effect.Effect<string | null | undefined, never, R1>, onChange?: (isAuthenticated: boolean) => Effect.Effect<void, never, R2>) => Effect.Effect<void, never, R1 | R2>;
|
|
34
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => Effect.Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
35
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => Effect.Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
36
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => Effect.Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
37
|
+
reactiveQuery: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>;
|
|
38
|
+
reactiveQueryResult: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("effect/Result").Result<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>>;
|
|
39
|
+
resolvePaginationId: (restored: Option.Option<number>) => Effect.Effect<number, never, never>;
|
|
40
|
+
}, {
|
|
41
|
+
url: string;
|
|
42
|
+
setAuth: <R1 = never, R2 = never>(fetchToken: (args: {
|
|
43
|
+
forceRefreshToken: boolean;
|
|
44
|
+
}) => Effect.Effect<string | null | undefined, never, R1>, onChange?: (isAuthenticated: boolean) => Effect.Effect<void, never, R2>) => Effect.Effect<void, never, R1 | R2>;
|
|
45
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => Effect.Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
46
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => Effect.Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
47
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => Effect.Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
48
|
+
reactiveQuery: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>;
|
|
49
|
+
reactiveQueryResult: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("effect/Result").Result<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>>;
|
|
50
|
+
resolvePaginationId: (restored: Option.Option<number>) => Effect.Effect<number, never, never>;
|
|
51
|
+
}>;
|
|
52
|
+
export type Client = typeof Client.Identifier;
|
|
53
|
+
/**
|
|
54
|
+
* Constructs one scoped client for a Foldkit application's `resources`.
|
|
55
|
+
*/
|
|
56
|
+
export declare const layer: (address: string, options?: ConstructorParameters<typeof ConvexClient>[1]) => Layer.Layer<{
|
|
57
|
+
url: string;
|
|
58
|
+
setAuth: <R1 = never, R2 = never>(fetchToken: (args: {
|
|
59
|
+
forceRefreshToken: boolean;
|
|
60
|
+
}) => Effect.Effect<string | null | undefined, never, R1>, onChange?: (isAuthenticated: boolean) => Effect.Effect<void, never, R2>) => Effect.Effect<void, never, R1 | R2>;
|
|
61
|
+
query: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => Effect.Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
62
|
+
mutation: <Mutation extends import("@confect/core/Ref").AnyPublicMutation>(ref: Mutation, ...rest: import("@confect/core/Ref").OptionalArgs<Mutation>) => Effect.Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
63
|
+
action: <Action extends import("@confect/core/Ref").AnyPublicAction>(ref: Action, ...rest: import("@confect/core/Ref").OptionalArgs<Action>) => Effect.Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | WebSocketClient.WebSocketClientError | import("effect/Schema").SchemaError>;
|
|
64
|
+
reactiveQuery: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>;
|
|
65
|
+
reactiveQueryResult: <Query extends import("@confect/core/Ref").AnyPublicQuery>(ref: Query, ...rest: import("@confect/core/Ref").OptionalArgs<Query>) => import("effect/Stream").Stream<import("effect/Result").Result<import("@confect/core/Ref").Returns<Query>, import("effect/Schema").SchemaError | WebSocketClient.WebSocketClientError | import("@confect/core/Ref").Error<Query>>>;
|
|
66
|
+
resolvePaginationId: (restored: Option.Option<number>) => Effect.Effect<number, never, never>;
|
|
67
|
+
}, never, never>;
|
|
68
|
+
export { WebSocketClientError } from "@confect/js/WebSocketClient";
|
|
69
|
+
//# sourceMappingURL=Client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Client.d.ts","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC;;;;GAIG;AACH,eAAO,MAAM,IAAI,oBAAqB,eAAe,CAAC,eAAe;;;;;;;;;;oCAM/B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBAQvD,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;oCAfmB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;;;;;;;;;;;;EAiB1D,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,UAAU,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,KAAK,YACP,MAAM,YACL,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;oCA1BnB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBA+BK,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|