@confect/react 10.0.0-next.2 → 10.0.0-next.20
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 +351 -0
- package/README.md +3 -1
- package/dist/OptimisticLocalStore.d.ts.map +1 -1
- package/dist/PaginatedQueryResult.d.ts +121 -0
- package/dist/PaginatedQueryResult.d.ts.map +1 -0
- package/dist/PaginatedQueryResult.js +91 -0
- package/dist/PaginatedQueryResult.js.map +1 -0
- package/dist/QueryResult.d.ts +11 -8
- package/dist/QueryResult.d.ts.map +1 -1
- package/dist/QueryResult.js +10 -26
- package/dist/QueryResult.js.map +1 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -2
- package/dist/index.js.map +1 -1
- package/package.json +20 -19
- package/src/PaginatedQueryResult.ts +319 -0
- package/src/QueryResult.ts +46 -42
- package/src/index.ts +238 -2
- package/dist/tsconfig.src.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,297 @@
|
|
|
1
1
|
# @confect/react
|
|
2
2
|
|
|
3
|
+
## 10.0.0-next.20
|
|
4
|
+
|
|
5
|
+
## 10.0.0-next.19
|
|
6
|
+
|
|
7
|
+
## 10.0.0-next.18
|
|
8
|
+
|
|
9
|
+
## 10.0.0-next.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8e4962e: Raise the required `effect` peer version to `^4.0.0-rc.111` (from `^4.0.0-rc.110`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
14
|
+
|
|
15
|
+
No Confect API changed, and no call-site edits are needed. `rc.111` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
|
|
16
|
+
|
|
17
|
+
## 10.0.0-next.16
|
|
18
|
+
|
|
19
|
+
### Major Changes
|
|
20
|
+
|
|
21
|
+
- Migrate to Effect v4. All `@confect/*` packages now require `effect@^4.0.0-beta.97`; `@effect/platform` and `@effect/cli` are no longer dependencies (their functionality moved into `effect` core and `effect/unstable/*`).
|
|
22
|
+
|
|
23
|
+
Breaking changes for users:
|
|
24
|
+
|
|
25
|
+
- **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.
|
|
26
|
+
- **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.
|
|
27
|
+
- **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.
|
|
28
|
+
- **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`).
|
|
29
|
+
- **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.
|
|
30
|
+
- **Node actions** use `effect/unstable/process` (`ChildProcessSpawner`) and `@effect/platform-node`'s `NodeServices` in place of `@effect/platform` `Command`/`NodeContext`.
|
|
31
|
+
- **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.
|
|
32
|
+
- **CLI**: a malformed `convex.json` now fails codegen with a descriptive error instead of being silently ignored.
|
|
33
|
+
- 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.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.100` (from `^4.0.0-beta.99`).
|
|
38
|
+
|
|
39
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.100` release only touches `Cron` internals (month/weekday alias normalization, day/weekday rollover, and equality/hashing), CLI error message formatting (`InvalidValue` prefixes), and `Schema.toTaggedUnion` discriminants that Confect doesn't use.
|
|
40
|
+
|
|
41
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.101` (from `^4.0.0-beta.100`).
|
|
42
|
+
|
|
43
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.101` release only touches fiber/concurrency internals (interrupt handling in concurrent traversal, stack frame annotations, `awaitAllChildren` linearization, `interruptibleMask` interrupt delivery), a `MutableList.filter` fix for empty buckets, a `Schema.Struct` required-readonly-field type display simplification, and an `HttpRouter.toWebHandler` middleware type-inference tightening that Confect doesn't need to accommodate.
|
|
44
|
+
|
|
45
|
+
- 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.
|
|
46
|
+
- 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.
|
|
47
|
+
|
|
48
|
+
`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.
|
|
49
|
+
|
|
50
|
+
`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.
|
|
51
|
+
|
|
52
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
53
|
+
|
|
54
|
+
**Before:**
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
58
|
+
"NoteNotFound",
|
|
59
|
+
{ noteId: Id("notes") },
|
|
60
|
+
) {}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**After:**
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
67
|
+
"NoteNotFound",
|
|
68
|
+
{ noteId: Id("notes") },
|
|
69
|
+
) {}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`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.
|
|
73
|
+
|
|
74
|
+
`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.
|
|
75
|
+
|
|
76
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.106` (from `^4.0.0-beta.105`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
77
|
+
|
|
78
|
+
`beta.106` is a patch-only Effect release. Nothing in Confect's own API changes, and your table, argument, and returns schemas still compile to the same Convex validators.
|
|
79
|
+
|
|
80
|
+
One Effect change needs a call-site edit if you derive property-test generators from those schemas: `Schema.toArbitrary` now returns a factory that takes the `fast-check` module instead of returning an arbitrary directly, and `Schema.toArbitraryLazy` and the `{ report: true }` option are gone.
|
|
81
|
+
|
|
82
|
+
**Before:**
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const NoteArbitrary = Schema.toArbitrary(Note);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**After:**
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import * as FastCheck from "fast-check";
|
|
92
|
+
|
|
93
|
+
const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
HTTP actions written against `HttpRouter` also inherit Effect's stricter multipart handling: a request that exceeds the configured part count, part size, or field size limits now stops being parsed at the limit rather than being read to completion first.
|
|
97
|
+
|
|
98
|
+
- 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.
|
|
99
|
+
|
|
100
|
+
`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.
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.98` (from `^4.0.0-beta.97`).
|
|
105
|
+
|
|
106
|
+
`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.
|
|
107
|
+
|
|
108
|
+
- Raise the required `effect` peer version to `^4.0.0-beta.99` (from `^4.0.0-beta.98`).
|
|
109
|
+
|
|
110
|
+
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.
|
|
111
|
+
|
|
112
|
+
- Raise the required `effect` peer version to `^4.0.0-rc.108` (from `^4.0.0-beta.107`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise. Effect v4 has left beta for release candidates, so `effect@rc` is now the tag to install alongside `@confect/*`.
|
|
113
|
+
|
|
114
|
+
No Confect API changed, and no call-site edits are needed for Confect itself. One Effect change can reach your code: the standalone `effect/SchemaError` module is gone, and `SchemaError` is now exported from `Schema`. Confect still fails decoding with the same error, so this only matters if you name the type when handling it.
|
|
115
|
+
|
|
116
|
+
Before:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import type { SchemaError } from "effect/SchemaError";
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
After:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import type { SchemaError } from "effect/Schema";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
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.
|
|
129
|
+
|
|
130
|
+
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.
|
|
131
|
+
|
|
132
|
+
- 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.
|
|
133
|
+
|
|
134
|
+
No Confect API changed, and no call-site edits are needed. `rc.109` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
|
|
135
|
+
|
|
136
|
+
- 8e4962e: Raise the required `effect` peer version to `^4.0.0-rc.110` (from `^4.0.0-rc.109`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
137
|
+
|
|
138
|
+
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/*`.
|
|
139
|
+
|
|
140
|
+
- 3f0255c: Build and test against `convex` 1.44.0. The published `convex` peer ranges are unchanged, so no consumer action is required.
|
|
141
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.2–9.2.4 — see those versions' changelog entries.
|
|
142
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5 — see that version's changelog entries.
|
|
143
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0 — see that version's changelog entries.
|
|
144
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0 — see that version's changelog entries.
|
|
145
|
+
|
|
146
|
+
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.
|
|
147
|
+
|
|
148
|
+
- 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.
|
|
149
|
+
|
|
150
|
+
## 10.0.0-next.15
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- 8e4962e: Raise the required `effect` peer version to `^4.0.0-rc.109` (from `^4.0.0-rc.108`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
155
|
+
|
|
156
|
+
No Confect API changed, and no call-site edits are needed. `rc.109` is a patch release of Effect with nothing removed or renamed, so upgrading is a matter of installing it alongside `@confect/*`.
|
|
157
|
+
|
|
158
|
+
## 10.0.0-next.14
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- 9d51bd3: Raise the required `effect` peer version to `^4.0.0-rc.108` (from `^4.0.0-beta.107`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise. Effect v4 has left beta for release candidates, so `effect@rc` is now the tag to install alongside `@confect/*`.
|
|
163
|
+
|
|
164
|
+
No Confect API changed, and no call-site edits are needed for Confect itself. One Effect change can reach your code: the standalone `effect/SchemaError` module is gone, and `SchemaError` is now exported from `Schema`. Confect still fails decoding with the same error, so this only matters if you name the type when handling it.
|
|
165
|
+
|
|
166
|
+
Before:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
import type { SchemaError } from "effect/SchemaError";
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
After:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import type { SchemaError } from "effect/Schema";
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
180
|
+
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.
|
|
181
|
+
|
|
182
|
+
- 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.
|
|
183
|
+
|
|
184
|
+
## 10.0.0-next.13
|
|
185
|
+
|
|
186
|
+
### Patch Changes
|
|
187
|
+
|
|
188
|
+
- 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.
|
|
189
|
+
|
|
190
|
+
`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.
|
|
191
|
+
|
|
192
|
+
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.
|
|
193
|
+
|
|
194
|
+
## 10.0.0-next.12
|
|
195
|
+
|
|
196
|
+
### Patch Changes
|
|
197
|
+
|
|
198
|
+
- 661ee9b: Raise the required `effect` peer version to `^4.0.0-beta.106` (from `^4.0.0-beta.105`), and `@confect/server`'s optional `@effect/platform-node` peer version likewise.
|
|
199
|
+
|
|
200
|
+
`beta.106` is a patch-only Effect release. Nothing in Confect's own API changes, and your table, argument, and returns schemas still compile to the same Convex validators.
|
|
201
|
+
|
|
202
|
+
One Effect change needs a call-site edit if you derive property-test generators from those schemas: `Schema.toArbitrary` now returns a factory that takes the `fast-check` module instead of returning an arbitrary directly, and `Schema.toArbitraryLazy` and the `{ report: true }` option are gone.
|
|
203
|
+
|
|
204
|
+
**Before:**
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
const NoteArbitrary = Schema.toArbitrary(Note);
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**After:**
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
import * as FastCheck from "fast-check";
|
|
214
|
+
|
|
215
|
+
const NoteArbitrary = Schema.toArbitrary(Note)(FastCheck);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
HTTP actions written against `HttpRouter` also inherit Effect's stricter multipart handling: a request that exceeds the configured part count, part size, or field size limits now stops being parsed at the limit rather than being read to completion first.
|
|
219
|
+
|
|
220
|
+
## 10.0.0-next.11
|
|
221
|
+
|
|
222
|
+
### Patch Changes
|
|
223
|
+
|
|
224
|
+
- 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.
|
|
225
|
+
|
|
226
|
+
`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.
|
|
227
|
+
|
|
228
|
+
`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.
|
|
229
|
+
|
|
230
|
+
`beta.104` renames Effect's schema error constructors to match their `Data` counterparts, which affects any error schema you declare for a Confect function:
|
|
231
|
+
|
|
232
|
+
**Before:**
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
export class NoteNotFound extends Schema.TaggedErrorClass<NoteNotFound>()(
|
|
236
|
+
"NoteNotFound",
|
|
237
|
+
{ noteId: Id("notes") },
|
|
238
|
+
) {}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**After:**
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
export class NoteNotFound extends Schema.TaggedError<NoteNotFound>()(
|
|
245
|
+
"NoteNotFound",
|
|
246
|
+
{ noteId: Id("notes") },
|
|
247
|
+
) {}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
`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.
|
|
251
|
+
|
|
252
|
+
`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.
|
|
253
|
+
|
|
254
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.4.0 — see that version's changelog entries.
|
|
255
|
+
|
|
256
|
+
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.
|
|
257
|
+
|
|
258
|
+
## 10.0.0-next.10
|
|
259
|
+
|
|
260
|
+
### Patch Changes
|
|
261
|
+
|
|
262
|
+
- Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.3.0 — see that version's changelog entries.
|
|
263
|
+
|
|
264
|
+
## 10.0.0-next.9
|
|
265
|
+
|
|
266
|
+
### Patch Changes
|
|
267
|
+
|
|
268
|
+
- 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.
|
|
269
|
+
- 25e8d19: Sync with `main`: this prerelease line now includes all changes released in `@confect/*` 9.2.5 — see that version's changelog entries.
|
|
270
|
+
|
|
271
|
+
## 10.0.0-next.8
|
|
272
|
+
|
|
273
|
+
### Patch Changes
|
|
274
|
+
|
|
275
|
+
- 913d0e5: Raise the required `effect` peer version to `^4.0.0-beta.101` (from `^4.0.0-beta.100`).
|
|
276
|
+
|
|
277
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.101` release only touches fiber/concurrency internals (interrupt handling in concurrent traversal, stack frame annotations, `awaitAllChildren` linearization, `interruptibleMask` interrupt delivery), a `MutableList.filter` fix for empty buckets, a `Schema.Struct` required-readonly-field type display simplification, and an `HttpRouter.toWebHandler` middleware type-inference tightening that Confect doesn't need to accommodate.
|
|
278
|
+
|
|
279
|
+
## 10.0.0-next.7
|
|
280
|
+
|
|
281
|
+
## 10.0.0-next.6
|
|
282
|
+
|
|
283
|
+
## 10.0.0-next.5
|
|
284
|
+
|
|
285
|
+
## 10.0.0-next.4
|
|
286
|
+
|
|
287
|
+
## 10.0.0-next.3
|
|
288
|
+
|
|
289
|
+
### Patch Changes
|
|
290
|
+
|
|
291
|
+
- 5b63546: Raise the required `effect` peer version to `^4.0.0-beta.100` (from `^4.0.0-beta.99`).
|
|
292
|
+
|
|
293
|
+
This is a peer-range-only change with no consumer-visible API consequences. The `beta.100` release only touches `Cron` internals (month/weekday alias normalization, day/weekday rollover, and equality/hashing), CLI error message formatting (`InvalidValue` prefixes), and `Schema.toTaggedUnion` discriminants that Confect doesn't use.
|
|
294
|
+
|
|
3
295
|
## 10.0.0-next.2
|
|
4
296
|
|
|
5
297
|
### Patch Changes
|
|
@@ -43,6 +335,65 @@
|
|
|
43
335
|
- Updated dependencies [70e313e]
|
|
44
336
|
- @confect/core@10.0.0-next.0
|
|
45
337
|
|
|
338
|
+
## 9.4.1
|
|
339
|
+
|
|
340
|
+
### Patch Changes
|
|
341
|
+
|
|
342
|
+
- 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.
|
|
343
|
+
|
|
344
|
+
## 9.4.0
|
|
345
|
+
|
|
346
|
+
## 9.3.0
|
|
347
|
+
|
|
348
|
+
### Minor Changes
|
|
349
|
+
|
|
350
|
+
- 16b5ad6: Add first-class paginated queries: declare one with `FunctionSpec.publicPaginatedQuery` (or `internalPaginatedQuery`) and read it with the new `usePaginatedQuery` hook from `@confect/react`.
|
|
351
|
+
|
|
352
|
+
Pass an `item` schema — the type of one element in a page — in place of `returns`, plus an optional `args` struct for your own arguments. The handler receives `paginationOpts` alongside them and forwards it to `paginate`.
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
// confect/notes.spec.ts
|
|
356
|
+
FunctionSpec.publicPaginatedQuery({
|
|
357
|
+
name: "listByAuthor",
|
|
358
|
+
args: () => Schema.Struct({ author: Schema.String }),
|
|
359
|
+
item: () => notes.Doc,
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
// confect/notes.impl.ts
|
|
363
|
+
({ author, paginationOpts }) =>
|
|
364
|
+
Effect.gen(function* () {
|
|
365
|
+
const reader = yield* DatabaseReader;
|
|
366
|
+
|
|
367
|
+
return yield* reader
|
|
368
|
+
.table("notes")
|
|
369
|
+
.index("by_creation_time", "desc")
|
|
370
|
+
.paginate(paginationOpts, (q) => q.eq(q.field("author"), author));
|
|
371
|
+
}).pipe(Effect.orDie);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Declaring `paginationOpts` in `args` yourself is a type and runtime error.
|
|
375
|
+
|
|
376
|
+
```tsx
|
|
377
|
+
import { PaginatedQueryResult, usePaginatedQuery } from "@confect/react";
|
|
378
|
+
|
|
379
|
+
const notes = usePaginatedQuery(
|
|
380
|
+
refs.public.notes.listByAuthor,
|
|
381
|
+
{ author },
|
|
382
|
+
{ initialNumItems: 10 },
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
// `notes.results` holds the pages decoded through `item`.
|
|
386
|
+
if (PaginatedQueryResult.isCanLoadMore(notes)) {
|
|
387
|
+
notes.loadMore(10);
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
The hook returns a `PaginatedQueryResult<Item, E>`. `LoadingFirstPage`, `LoadingMore`, `CanLoadMore`, and `Exhausted` all carry `results` and `isLoading`; `loadMore` lives only on `CanLoadMore`, the one state it can make progress from. A declared `error` schema surfaces as a `Failure` variant carrying the decoded error instead of throwing during render, and `Failure` carries `results` too, so the pages loaded before it can still be rendered. Without an `error` schema, `Failure` is absent from the type entirely.
|
|
392
|
+
|
|
393
|
+
`paginate` in `@confect/server` now accepts Convex's full `PaginationOptions`, so a handler's `paginationOpts` passes straight through. `@confect/react` now requires `convex` >= 1.36.0.
|
|
394
|
+
|
|
395
|
+
## 9.2.5
|
|
396
|
+
|
|
46
397
|
## 9.2.4
|
|
47
398
|
|
|
48
399
|
## 9.2.3
|
package/README.md
CHANGED
|
@@ -5,7 +5,9 @@ Confect is a framework that deeply integrates Effect with Convex. It's more than
|
|
|
5
5
|
- Define your Convex database schema using Effect schemas.
|
|
6
6
|
- Write Convex function args and returns validators using Effect's schema library.
|
|
7
7
|
- 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).
|
|
8
|
-
-
|
|
8
|
+
- Add reusable, type-safe middleware to function groups or individual functions to provide Effect services and run logic around handlers.
|
|
9
|
+
- Declare typed errors on functions and middleware using Effect schemas, then handle the decoded errors at every call site.
|
|
10
|
+
- Use Effect's native HTTP API modules to define your HTTP API.
|
|
9
11
|
- Access Convex platform capabilities via Effect services.
|
|
10
12
|
|
|
11
13
|
Want to learn more? Read the [docs](https://confect.dev)!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimisticLocalStore.d.ts","sourceRoot":"","sources":["../src/OptimisticLocalStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AACzF,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,SAAS,GAAG,CAAC,cAAc,EACvC,QAAQ,EAAE,KAAK,EACf,GAAG,IAAI,EAAE,GAAG,CAAC,YAAY,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AC;QACP,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;KAC1C,CAAC,CAAC;IAEH,QAAQ,CAAC,KAAK,SAAS,GAAG,CAAC,cAAc,EACvC,QAAQ,EAAE,KAAK,EACf,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GACvC,IAAI,CAAC;CACT;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,qBACG,0BAA0B,KAC3C,oBA+BD,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as Pipeable from "effect/Pipeable";
|
|
2
|
+
declare const TypeId = "~@confect/react/PaginatedQueryResult";
|
|
3
|
+
type TypeId = typeof TypeId;
|
|
4
|
+
/**
|
|
5
|
+
* A `PaginatedQueryResult` represents the result of a Confect paginated query.
|
|
6
|
+
* The non-`Failure` variants mirror the statuses of `usePaginatedQuery` from
|
|
7
|
+
* `convex/react` and all carry `results` and `isLoading`, so the common UI
|
|
8
|
+
* shape — render the list, show a spinner while loading — needs only an
|
|
9
|
+
* {@link isFailure} early-out and plain field access.
|
|
10
|
+
*
|
|
11
|
+
* Every variant carries `results`, including `Failure`: when a later page
|
|
12
|
+
* fails, the pages already loaded are still worth rendering alongside the
|
|
13
|
+
* error, so they are not discarded. `Failure` additionally carries the
|
|
14
|
+
* query's decoded typed error.
|
|
15
|
+
*
|
|
16
|
+
* `loadMore` appears only on `CanLoadMore`, the one state it can make
|
|
17
|
+
* progress from. The underlying Convex hook exposes it on every status, but
|
|
18
|
+
* calling it while a page is in flight, once the list is exhausted, or after
|
|
19
|
+
* a failure is an intentional no-op there; narrowing to `CanLoadMore` — via
|
|
20
|
+
* {@link isCanLoadMore} or {@link match} — makes that statically apparent
|
|
21
|
+
* instead of silently dropping the call.
|
|
22
|
+
*
|
|
23
|
+
* When the query declares no `error` schema (`E` is `never`), the `Failure`
|
|
24
|
+
* variant is excluded from the type entirely, so `isLoading` is accessible
|
|
25
|
+
* without any narrowing.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam Item - The type of a decoded page item.
|
|
28
|
+
* @typeParam E - The type of the decoded typed error in the `Failure` variant.
|
|
29
|
+
*/
|
|
30
|
+
export type PaginatedQueryResult<Item, E = never> = [E] extends [never] ? LoadingFirstPage<Item, E> | LoadingMore<Item, E> | CanLoadMore<Item, E> | Exhausted<Item, E> : LoadingFirstPage<Item, E> | LoadingMore<Item, E> | CanLoadMore<Item, E> | Exhausted<Item, E> | Failure<Item, E>;
|
|
31
|
+
/**
|
|
32
|
+
* Every variant regardless of `E` — the parameter type for guards and
|
|
33
|
+
* {@link match}, since `PaginatedQueryResult` itself excludes `Failure` when
|
|
34
|
+
* `E` is `never`.
|
|
35
|
+
*/
|
|
36
|
+
export type Variants<Item, E = never> = LoadingFirstPage<Item, E> | LoadingMore<Item, E> | CanLoadMore<Item, E> | Exhausted<Item, E> | Failure<Item, E>;
|
|
37
|
+
export declare namespace PaginatedQueryResult {
|
|
38
|
+
interface Proto<out Item, out E> extends Pipeable.Pipeable {
|
|
39
|
+
readonly [TypeId]: TypeId;
|
|
40
|
+
readonly "~Item": Item;
|
|
41
|
+
readonly "~E": E;
|
|
42
|
+
}
|
|
43
|
+
type Item<R> = R extends {
|
|
44
|
+
readonly "~Item": infer Item_;
|
|
45
|
+
} ? Item_ : never;
|
|
46
|
+
type Failure<R> = R extends {
|
|
47
|
+
readonly "~E": infer E;
|
|
48
|
+
} ? E : never;
|
|
49
|
+
}
|
|
50
|
+
export interface LoadingFirstPage<Item, E = never> extends PaginatedQueryResult.Proto<Item, E> {
|
|
51
|
+
readonly _tag: "LoadingFirstPage";
|
|
52
|
+
readonly skipped: boolean;
|
|
53
|
+
readonly results: ReadonlyArray<Item>;
|
|
54
|
+
readonly isLoading: true;
|
|
55
|
+
}
|
|
56
|
+
export interface LoadingMore<Item, E = never> extends PaginatedQueryResult.Proto<Item, E> {
|
|
57
|
+
readonly _tag: "LoadingMore";
|
|
58
|
+
readonly results: ReadonlyArray<Item>;
|
|
59
|
+
readonly isLoading: true;
|
|
60
|
+
}
|
|
61
|
+
export interface CanLoadMore<Item, E = never> extends PaginatedQueryResult.Proto<Item, E> {
|
|
62
|
+
readonly _tag: "CanLoadMore";
|
|
63
|
+
readonly results: ReadonlyArray<Item>;
|
|
64
|
+
readonly isLoading: false;
|
|
65
|
+
readonly loadMore: (numItems: number) => void;
|
|
66
|
+
}
|
|
67
|
+
export interface Exhausted<Item, E = never> extends PaginatedQueryResult.Proto<Item, E> {
|
|
68
|
+
readonly _tag: "Exhausted";
|
|
69
|
+
readonly results: ReadonlyArray<Item>;
|
|
70
|
+
readonly isLoading: false;
|
|
71
|
+
}
|
|
72
|
+
export interface Failure<Item, E = never> extends PaginatedQueryResult.Proto<Item, E> {
|
|
73
|
+
readonly _tag: "Failure";
|
|
74
|
+
readonly error: E;
|
|
75
|
+
/** The pages loaded before the failure. */
|
|
76
|
+
readonly results: ReadonlyArray<Item>;
|
|
77
|
+
}
|
|
78
|
+
export declare const isPaginatedQueryResult: (u: unknown) => u is Variants<unknown, unknown>;
|
|
79
|
+
export declare const loadingFirstPage: <Item = never, E = never>(options: {
|
|
80
|
+
skipped: boolean;
|
|
81
|
+
}) => LoadingFirstPage<Item, E>;
|
|
82
|
+
export declare const loadingMore: <Item, E = never>(options: {
|
|
83
|
+
results: ReadonlyArray<Item>;
|
|
84
|
+
}) => LoadingMore<Item, E>;
|
|
85
|
+
export declare const canLoadMore: <Item, E = never>(options: {
|
|
86
|
+
results: ReadonlyArray<Item>;
|
|
87
|
+
loadMore: (numItems: number) => void;
|
|
88
|
+
}) => CanLoadMore<Item, E>;
|
|
89
|
+
export declare const exhausted: <Item, E = never>(options: {
|
|
90
|
+
results: ReadonlyArray<Item>;
|
|
91
|
+
}) => Exhausted<Item, E>;
|
|
92
|
+
export declare const failure: <E, Item = never>(options: {
|
|
93
|
+
error: E;
|
|
94
|
+
results: ReadonlyArray<Item>;
|
|
95
|
+
}) => Failure<Item, E>;
|
|
96
|
+
export declare const isLoadingFirstPage: <Item, E>(result: Variants<Item, E>) => result is LoadingFirstPage<Item, E>;
|
|
97
|
+
export declare const isLoadingMore: <Item, E>(result: Variants<Item, E>) => result is LoadingMore<Item, E>;
|
|
98
|
+
export declare const isCanLoadMore: <Item, E>(result: Variants<Item, E>) => result is CanLoadMore<Item, E>;
|
|
99
|
+
export declare const isExhausted: <Item, E>(result: Variants<Item, E>) => result is Exhausted<Item, E>;
|
|
100
|
+
export declare const isFailure: <Item, E>(result: Variants<Item, E>) => result is Failure<Item, E>;
|
|
101
|
+
export declare const isLoading: <Item, E>(result: Variants<Item, E>) => result is LoadingFirstPage<Item, E> | LoadingMore<Item, E>;
|
|
102
|
+
type MatchOptions<Item, E, V, W, X, Y, Z> = {
|
|
103
|
+
readonly onLoadingFirstPage: (skipped: boolean) => V;
|
|
104
|
+
readonly onLoadingMore: (results: ReadonlyArray<Item>) => W;
|
|
105
|
+
readonly onCanLoadMore: (results: ReadonlyArray<Item>, loadMore: (numItems: number) => void) => X;
|
|
106
|
+
readonly onExhausted: (results: ReadonlyArray<Item>) => Y;
|
|
107
|
+
} & ([E] extends [never] ? {} : {
|
|
108
|
+
readonly onFailure: (error: E, results: ReadonlyArray<Item>) => Z;
|
|
109
|
+
});
|
|
110
|
+
type MatchReturns<E, V, W, X, Y, Z> = [E] extends [never] ? V | W | X | Y : V | W | X | Y | Z;
|
|
111
|
+
/**
|
|
112
|
+
* Matches a {@link PaginatedQueryResult} to the appropriate handler based on
|
|
113
|
+
* its tag. If the provided result cannot fail (i.e. `E` is `never`),
|
|
114
|
+
* `onFailure` is not required.
|
|
115
|
+
*/
|
|
116
|
+
export declare const match: {
|
|
117
|
+
<Item, E, V, W, X, Y, Z = never>(options: MatchOptions<Item, E, V, W, X, Y, Z>): (self: Variants<Item, E>) => MatchReturns<E, V, W, X, Y, Z>;
|
|
118
|
+
<Item, E, V, W, X, Y, Z = never>(self: Variants<Item, E>, options: MatchOptions<Item, E, V, W, X, Y, Z>): MatchReturns<E, V, W, X, Y, Z>;
|
|
119
|
+
};
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=PaginatedQueryResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaginatedQueryResult.d.ts","sourceRoot":"","sources":["../src/PaginatedQueryResult.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAG5C,QAAA,MAAM,MAAM,yCAAyC,CAAC;AACtD,KAAK,MAAM,GAAG,OAAO,MAAM,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,oBAAoB,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAE/D,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,GACzB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,GACpB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,GACpB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,GAElB,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,GACzB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,GACpB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,GACpB,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,GAClB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAEzB;;;;GAIG;AACH,MAAM,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,IAChC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,GACzB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,GACp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Equal from "effect/Equal";
|
|
4
|
+
import * as Function from "effect/Function";
|
|
5
|
+
import * as Hash from "effect/Hash";
|
|
6
|
+
import * as Pipeable from "effect/Pipeable";
|
|
7
|
+
import * as Predicate from "effect/Predicate";
|
|
8
|
+
//#region src/PaginatedQueryResult.ts
|
|
9
|
+
var PaginatedQueryResult_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
canLoadMore: () => canLoadMore,
|
|
11
|
+
exhausted: () => exhausted,
|
|
12
|
+
failure: () => failure,
|
|
13
|
+
isCanLoadMore: () => isCanLoadMore,
|
|
14
|
+
isExhausted: () => isExhausted,
|
|
15
|
+
isFailure: () => isFailure,
|
|
16
|
+
isLoading: () => isLoading,
|
|
17
|
+
isLoadingFirstPage: () => isLoadingFirstPage,
|
|
18
|
+
isLoadingMore: () => isLoadingMore,
|
|
19
|
+
isPaginatedQueryResult: () => isPaginatedQueryResult,
|
|
20
|
+
loadingFirstPage: () => loadingFirstPage,
|
|
21
|
+
loadingMore: () => loadingMore,
|
|
22
|
+
match: () => match
|
|
23
|
+
});
|
|
24
|
+
const TypeId = "~@confect/react/PaginatedQueryResult";
|
|
25
|
+
const isPaginatedQueryResult = (u) => Predicate.hasProperty(u, TypeId);
|
|
26
|
+
const PaginatedQueryResultProto = {
|
|
27
|
+
[TypeId]: TypeId,
|
|
28
|
+
pipe(...args) {
|
|
29
|
+
return Pipeable.pipeArguments(this, args);
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* `CanLoadMore`'s `loadMore` is excluded from equality and hashing, like
|
|
33
|
+
* function fields generally: two results that render identically are equal
|
|
34
|
+
* even though their callbacks differ by identity.
|
|
35
|
+
*/
|
|
36
|
+
[Equal.symbol](that) {
|
|
37
|
+
if (this._tag !== that._tag) return false;
|
|
38
|
+
return Match.value(this).pipe(Match.tag("LoadingFirstPage", (self) => self.skipped === that.skipped), Match.tag("LoadingMore", "CanLoadMore", "Exhausted", (self) => Equal.equals(self.results, that.results)), Match.tag("Failure", (self) => Equal.equals(self.error, that.error) && Equal.equals(self.results, that.results)), Match.exhaustive);
|
|
39
|
+
},
|
|
40
|
+
[Hash.symbol]() {
|
|
41
|
+
const tagHash = Hash.string(this._tag);
|
|
42
|
+
return Match.value(this).pipe(Match.tag("LoadingFirstPage", (self) => Hash.combine(tagHash)(Hash.hash(self.skipped))), Match.tag("LoadingMore", "CanLoadMore", "Exhausted", (self) => Hash.combine(tagHash)(Hash.hash(self.results))), Match.tag("Failure", (self) => Hash.combine(tagHash)(Hash.combine(Hash.hash(self.error))(Hash.hash(self.results)))), Match.exhaustive);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const noResults = [];
|
|
46
|
+
const loadingFirstPage = (options) => Object.assign(Object.create(PaginatedQueryResultProto), {
|
|
47
|
+
_tag: "LoadingFirstPage",
|
|
48
|
+
skipped: options.skipped,
|
|
49
|
+
results: noResults,
|
|
50
|
+
isLoading: true
|
|
51
|
+
});
|
|
52
|
+
const loadingMore = (options) => Object.assign(Object.create(PaginatedQueryResultProto), {
|
|
53
|
+
_tag: "LoadingMore",
|
|
54
|
+
results: options.results,
|
|
55
|
+
isLoading: true
|
|
56
|
+
});
|
|
57
|
+
const canLoadMore = (options) => Object.assign(Object.create(PaginatedQueryResultProto), {
|
|
58
|
+
_tag: "CanLoadMore",
|
|
59
|
+
results: options.results,
|
|
60
|
+
isLoading: false,
|
|
61
|
+
loadMore: options.loadMore
|
|
62
|
+
});
|
|
63
|
+
const exhausted = (options) => Object.assign(Object.create(PaginatedQueryResultProto), {
|
|
64
|
+
_tag: "Exhausted",
|
|
65
|
+
results: options.results,
|
|
66
|
+
isLoading: false
|
|
67
|
+
});
|
|
68
|
+
const failure = (options) => Object.assign(Object.create(PaginatedQueryResultProto), {
|
|
69
|
+
_tag: "Failure",
|
|
70
|
+
error: options.error,
|
|
71
|
+
results: options.results
|
|
72
|
+
});
|
|
73
|
+
const isLoadingFirstPage = (result) => result._tag === "LoadingFirstPage";
|
|
74
|
+
const isLoadingMore = (result) => result._tag === "LoadingMore";
|
|
75
|
+
const isCanLoadMore = (result) => result._tag === "CanLoadMore";
|
|
76
|
+
const isExhausted = (result) => result._tag === "Exhausted";
|
|
77
|
+
const isFailure = (result) => result._tag === "Failure";
|
|
78
|
+
const isLoading = (result) => result._tag === "LoadingFirstPage" || result._tag === "LoadingMore";
|
|
79
|
+
/**
|
|
80
|
+
* Matches a {@link PaginatedQueryResult} to the appropriate handler based on
|
|
81
|
+
* its tag. If the provided result cannot fail (i.e. `E` is `never`),
|
|
82
|
+
* `onFailure` is not required.
|
|
83
|
+
*/
|
|
84
|
+
const match = Function.dual(2, (self, options) => Match.value(self).pipe(Match.tag("LoadingFirstPage", (loadingFirstPage_) => options.onLoadingFirstPage(loadingFirstPage_.skipped)), Match.tag("LoadingMore", (loadingMore_) => options.onLoadingMore(loadingMore_.results)), Match.tag("CanLoadMore", (canLoadMore_) => options.onCanLoadMore(canLoadMore_.results, canLoadMore_.loadMore)), Match.tag("Exhausted", (exhausted_) => options.onExhausted(exhausted_.results)), Match.tag("Failure", (failure_) => {
|
|
85
|
+
if (Predicate.hasProperty(options, "onFailure")) return options.onFailure(failure_.error, failure_.results);
|
|
86
|
+
throw new Error("`onFailure` is required when error schema is provided");
|
|
87
|
+
}), Match.exhaustive));
|
|
88
|
+
//#endregion
|
|
89
|
+
export { PaginatedQueryResult_exports, canLoadMore, exhausted, failure, isCanLoadMore, isExhausted, isFailure, isLoading, isLoadingFirstPage, isLoadingMore, isPaginatedQueryResult, loadingFirstPage, loadingMore, match };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=PaginatedQueryResult.js.map
|