@raf-query/core 0.7.9 → 0.7.11
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 +21 -2
- package/dist/options.d.mts +47 -15
- package/dist/options.mjs +5 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.7.11](https://github.com/KATT/raf-query/compare/0.7.10...0.7.11) (2026-10-14)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **examples:** add a stale time setting ([#119](https://github.com/KATT/raf-query/issues/119)) ([02467ef](https://github.com/KATT/raf-query/commit/02467ef4cf700d2ca1a57647c2fbc5cad2bf7abc))
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** leave error out of query types when it isn't inferred ([#120](https://github.com/KATT/raf-query/issues/120)) ([d2098e8](https://github.com/KATT/raf-query/commit/d2098e84dea31c8e0d136f7850177e37f56d4678)), references [#69](https://github.com/KATT/raf-query/issues/69) [#69](https://github.com/KATT/raf-query/issues/69)
|
|
12
|
+
|
|
13
|
+
## [0.7.10](https://github.com/KATT/raf-query/compare/0.7.9...0.7.10) (2026-10-14)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- **examples:** fit the example apps on a phone screen ([#116](https://github.com/KATT/raf-query/issues/116)) ([1580e00](https://github.com/KATT/raf-query/commit/1580e00f79f4e47e82ddba64e0d22723b9ffb4ba)), references [#112](https://github.com/KATT/raf-query/issues/112)
|
|
18
|
+
- **examples:** open issue pages with prefetch skeletons ([#106](https://github.com/KATT/raf-query/issues/106)) ([db6b5bc](https://github.com/KATT/raf-query/commit/db6b5bcd162dd34073d36c74eaf7618f5012dc31))
|
|
19
|
+
- **examples:** remount the issue page when next or previous changes the id ([#112](https://github.com/KATT/raf-query/issues/112)) ([e4b709b](https://github.com/KATT/raf-query/commit/e4b709b455e4e7bbd85746afe46ecca269a728ee))
|
|
20
|
+
- **react:** type useQuery's promise as Promise ([#118](https://github.com/KATT/raf-query/issues/118)) ([f1b4efe](https://github.com/KATT/raf-query/commit/f1b4efefc7624719b00f0c6e308dd7a72c18c132))
|
|
21
|
+
|
|
3
22
|
## [0.7.9](https://github.com/KATT/raf-query/compare/0.7.8...0.7.9) (2026-10-14)
|
|
4
23
|
|
|
5
|
-
|
|
24
|
+
- add a Links table to the pull request template ([#108](https://github.com/KATT/raf-query/issues/108)) ([91247e4](https://github.com/KATT/raf-query/commit/91247e47d4d1b4a0b6e5eb2068602629c3fbce9e))
|
|
6
25
|
|
|
7
26
|
### Features
|
|
8
27
|
|
|
9
|
-
|
|
28
|
+
- QueryClient.runPromise, typed Effect errors, and the Effect RPC example ([#103](https://github.com/KATT/raf-query/issues/103)) ([98bd182](https://github.com/KATT/raf-query/commit/98bd1821081313feb1846531feac0dfbe7215d31)), references [#96](https://github.com/KATT/raf-query/issues/96) [#97](https://github.com/KATT/raf-query/issues/97)
|
|
10
29
|
|
|
11
30
|
## [0.7.8](https://github.com/KATT/raf-query/compare/0.7.7...0.7.8) (2026-10-14)
|
|
12
31
|
|
package/dist/options.d.mts
CHANGED
|
@@ -3,8 +3,9 @@ import { Effect, Schedule } from "effect";
|
|
|
3
3
|
//#region src/options.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The types of a plain query: what its `queryFn` resolves to, and for an
|
|
6
|
-
* Effect `queryFn`, its error and the services it needs. `error`
|
|
7
|
-
* `unknown` (promises reject with anything)
|
|
6
|
+
* Effect `queryFn`, its error and the services it needs. Leave `error` out
|
|
7
|
+
* and it is `unknown` (promises reject with anything); leave `services` out
|
|
8
|
+
* and it is `never`.
|
|
8
9
|
*
|
|
9
10
|
* ```ts
|
|
10
11
|
* type PostOptions = QueryOptions<{ data: Post }>;
|
|
@@ -33,6 +34,43 @@ type ErrorIn<TTypes> = TTypes extends {
|
|
|
33
34
|
type ServicesIn<TTypes> = TTypes extends {
|
|
34
35
|
readonly services: infer TServices;
|
|
35
36
|
} ? TServices : never;
|
|
37
|
+
/**
|
|
38
|
+
* The bag `queryOptions` returns. `error` is left out when the `queryFn`
|
|
39
|
+
* doesn't name one (`unknown`: a promise or a plain value). `services` is
|
|
40
|
+
* left out when the `queryFn` needs none (`never`). An Effect's error,
|
|
41
|
+
* including `never` when it can't fail, stays.
|
|
42
|
+
*/
|
|
43
|
+
type QueryTypesOf<TData, TError, TServices> = unknown extends TError ? [TServices] extends [never] ? {
|
|
44
|
+
data: TData;
|
|
45
|
+
} : {
|
|
46
|
+
data: TData;
|
|
47
|
+
services: TServices;
|
|
48
|
+
} : [TServices] extends [never] ? {
|
|
49
|
+
data: TData;
|
|
50
|
+
error: TError;
|
|
51
|
+
} : {
|
|
52
|
+
data: TData;
|
|
53
|
+
error: TError;
|
|
54
|
+
services: TServices;
|
|
55
|
+
};
|
|
56
|
+
/** As {@link QueryTypesOf}, for a paged query. */
|
|
57
|
+
type InfiniteQueryTypesOf<TPage, TPageParam, TError, TServices> = unknown extends TError ? [TServices] extends [never] ? {
|
|
58
|
+
page: TPage;
|
|
59
|
+
pageParam: TPageParam;
|
|
60
|
+
} : {
|
|
61
|
+
page: TPage;
|
|
62
|
+
pageParam: TPageParam;
|
|
63
|
+
services: TServices;
|
|
64
|
+
} : [TServices] extends [never] ? {
|
|
65
|
+
error: TError;
|
|
66
|
+
page: TPage;
|
|
67
|
+
pageParam: TPageParam;
|
|
68
|
+
} : {
|
|
69
|
+
error: TError;
|
|
70
|
+
page: TPage;
|
|
71
|
+
pageParam: TPageParam;
|
|
72
|
+
services: TServices;
|
|
73
|
+
};
|
|
36
74
|
/**
|
|
37
75
|
* What a `queryFn` may return: a value, a promise, or an `Effect`. An
|
|
38
76
|
* Effect's error type becomes the query's (promises reject with `unknown`),
|
|
@@ -181,7 +219,9 @@ export type AnyQueryOptions = QueryOptions<{
|
|
|
181
219
|
* ```
|
|
182
220
|
*
|
|
183
221
|
* A `queryFn` Effect may need services; they're inferred, and every verb
|
|
184
|
-
* that can start the query requires them.
|
|
222
|
+
* that can start the query requires them. Its error is part of the returned
|
|
223
|
+
* type. A promise or a plain value has no error to infer, so the type leaves
|
|
224
|
+
* `error` out (`ErrorOf` is `unknown`).
|
|
185
225
|
*
|
|
186
226
|
* The type parameters are only there for TypeScript to infer the types bag
|
|
187
227
|
* from `queryFn`; it can't infer a bag's members.
|
|
@@ -190,26 +230,18 @@ export declare function queryOptions<TData, TError = unknown, TServices = never>
|
|
|
190
230
|
data: TData;
|
|
191
231
|
error: TError;
|
|
192
232
|
services: TServices;
|
|
193
|
-
}>, "kind">): QueryOptions<
|
|
194
|
-
data: TData;
|
|
195
|
-
error: TError;
|
|
196
|
-
services: TServices;
|
|
197
|
-
}>;
|
|
233
|
+
}>, "kind">): QueryOptions<QueryTypesOf<TData, TError, TServices>>;
|
|
198
234
|
/**
|
|
199
235
|
* Typed options for a paged query factory. The page type is inferred from
|
|
200
|
-
* `queryFn`, as in {@link queryOptions}.
|
|
236
|
+
* `queryFn`, as in {@link queryOptions}. So is an Effect `queryFn`'s error;
|
|
237
|
+
* a promise or a plain value leaves `error` out.
|
|
201
238
|
*/
|
|
202
239
|
export declare function infiniteQueryOptions<TPage, TPageParam, TError = unknown, TServices = never>(options: Omit<InfiniteQueryOptions<{
|
|
203
240
|
error: TError;
|
|
204
241
|
page: TPage;
|
|
205
242
|
pageParam: TPageParam;
|
|
206
243
|
services: TServices;
|
|
207
|
-
}>, "kind">): InfiniteQueryOptions<
|
|
208
|
-
error: TError;
|
|
209
|
-
page: TPage;
|
|
210
|
-
pageParam: TPageParam;
|
|
211
|
-
services: TServices;
|
|
212
|
-
}>;
|
|
244
|
+
}>, "kind">): InfiniteQueryOptions<InfiniteQueryTypesOf<TPage, TPageParam, TError, TServices>>;
|
|
213
245
|
interface FactoryResult {
|
|
214
246
|
readonly kind: "infinite" | "query";
|
|
215
247
|
readonly queryKey: QueryKey;
|
package/dist/options.mjs
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
14
|
* A `queryFn` Effect may need services; they're inferred, and every verb
|
|
15
|
-
* that can start the query requires them.
|
|
15
|
+
* that can start the query requires them. Its error is part of the returned
|
|
16
|
+
* type. A promise or a plain value has no error to infer, so the type leaves
|
|
17
|
+
* `error` out (`ErrorOf` is `unknown`).
|
|
16
18
|
*
|
|
17
19
|
* The type parameters are only there for TypeScript to infer the types bag
|
|
18
20
|
* from `queryFn`; it can't infer a bag's members.
|
|
@@ -25,7 +27,8 @@ function queryOptions(options) {
|
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Typed options for a paged query factory. The page type is inferred from
|
|
28
|
-
* `queryFn`, as in {@link queryOptions}.
|
|
30
|
+
* `queryFn`, as in {@link queryOptions}. So is an Effect `queryFn`'s error;
|
|
31
|
+
* a promise or a plain value leaves `error` out.
|
|
29
32
|
*/
|
|
30
33
|
function infiniteQueryOptions(options) {
|
|
31
34
|
return {
|