@pyreon/query 0.3.0 → 0.5.0
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/lib/analysis/index.js.html +1 -1
- package/lib/index.js +270 -139
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +278 -147
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index2.d.ts +162 -104
- package/lib/types/index2.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +42 -44
- package/src/query-client.ts +3 -4
- package/src/tests/{query.test.ts → query.test.tsx} +254 -353
- package/src/tests/subscription.test.tsx +581 -0
- package/src/use-infinite-query.ts +2 -2
- package/src/use-is-fetching.ts +1 -1
- package/src/use-mutation.ts +2 -2
- package/src/use-queries.ts +2 -2
- package/src/use-query-error-reset-boundary.ts +3 -4
- package/src/use-query.ts +2 -2
- package/src/use-subscription.ts +226 -0
- package/src/use-suspense-query.ts +3 -3
package/lib/types/index2.d.ts
CHANGED
|
@@ -24,70 +24,6 @@ declare function QueryClientProvider(props: QueryClientProviderProps): VNode;
|
|
|
24
24
|
*/
|
|
25
25
|
declare function useQueryClient(): QueryClient$1;
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region src/use-query.d.ts
|
|
28
|
-
interface UseQueryResult<TData, TError = DefaultError> {
|
|
29
|
-
/** Raw signal — the full observer result. Fine-grained accessors below are preferred. */
|
|
30
|
-
result: Signal<QueryObserverResult<TData, TError>>;
|
|
31
|
-
data: Signal<TData | undefined>;
|
|
32
|
-
error: Signal<TError | null>;
|
|
33
|
-
status: Signal<'pending' | 'error' | 'success'>;
|
|
34
|
-
isPending: Signal<boolean>;
|
|
35
|
-
isLoading: Signal<boolean>;
|
|
36
|
-
isFetching: Signal<boolean>;
|
|
37
|
-
isError: Signal<boolean>;
|
|
38
|
-
isSuccess: Signal<boolean>;
|
|
39
|
-
/** Manually trigger a refetch. */
|
|
40
|
-
refetch: () => Promise<QueryObserverResult<TData, TError>>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Subscribe to a query. Returns fine-grained reactive signals for data,
|
|
44
|
-
* error and status — each signal only notifies effects that depend on it.
|
|
45
|
-
*
|
|
46
|
-
* `options` is a function so it can read Pyreon signals — when a signal changes
|
|
47
|
-
* (e.g. a reactive query key), the observer is updated and refetches automatically.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* const userId = signal(1)
|
|
51
|
-
* const query = useQuery(() => ({
|
|
52
|
-
* queryKey: ['user', userId()],
|
|
53
|
-
* queryFn: () => fetch(`/api/users/${userId()}`).then(r => r.json()),
|
|
54
|
-
* }))
|
|
55
|
-
* // In template: () => query.data()?.name
|
|
56
|
-
*/
|
|
57
|
-
declare function useQuery<TData = unknown, TError = DefaultError, TKey extends QueryKey$1 = QueryKey$1>(options: () => QueryObserverOptions<TData, TError, TData, TData, TKey>): UseQueryResult<TData, TError>;
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/use-mutation.d.ts
|
|
60
|
-
interface UseMutationResult<TData, TError = DefaultError, TVariables = void, TContext = unknown> {
|
|
61
|
-
/** Raw signal — full observer result. Fine-grained accessors below are preferred. */
|
|
62
|
-
result: Signal<MutationObserverResult<TData, TError, TVariables, TContext>>;
|
|
63
|
-
data: Signal<TData | undefined>;
|
|
64
|
-
error: Signal<TError | null>;
|
|
65
|
-
status: Signal<'idle' | 'pending' | 'success' | 'error'>;
|
|
66
|
-
isPending: Signal<boolean>;
|
|
67
|
-
isSuccess: Signal<boolean>;
|
|
68
|
-
isError: Signal<boolean>;
|
|
69
|
-
isIdle: Signal<boolean>;
|
|
70
|
-
/** Fire the mutation (fire-and-forget). Errors are captured in the error signal. */
|
|
71
|
-
mutate: (variables: TVariables, options?: Parameters<MutateFunction<TData, TError, TVariables, TContext>>[1]) => void;
|
|
72
|
-
/** Like mutate but returns a promise — use for try/catch error handling. */
|
|
73
|
-
mutateAsync: MutateFunction<TData, TError, TVariables, TContext>;
|
|
74
|
-
/** Reset the mutation state back to idle. */
|
|
75
|
-
reset: () => void;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Run a mutation (create / update / delete). Returns reactive signals for
|
|
79
|
-
* pending / success / error state plus `mutate` and `mutateAsync` functions.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* const mutation = useMutation({
|
|
83
|
-
* mutationFn: (data: CreatePostInput) =>
|
|
84
|
-
* fetch('/api/posts', { method: 'POST', body: JSON.stringify(data) }).then(r => r.json()),
|
|
85
|
-
* onSuccess: () => client.invalidateQueries({ queryKey: ['posts'] }),
|
|
86
|
-
* })
|
|
87
|
-
* // h('button', { onClick: () => mutation.mutate({ title: 'New' }) }, 'Create')
|
|
88
|
-
*/
|
|
89
|
-
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: MutationObserverOptions<TData, TError, TVariables, TContext>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
90
|
-
//#endregion
|
|
91
27
|
//#region src/use-infinite-query.d.ts
|
|
92
28
|
interface UseInfiniteQueryResult<TQueryFnData, TError = DefaultError> {
|
|
93
29
|
/** Raw signal — full observer result. */
|
|
@@ -144,6 +80,38 @@ declare function useIsFetching(filters?: QueryFilters$1): Signal<number>;
|
|
|
144
80
|
*/
|
|
145
81
|
declare function useIsMutating(filters?: MutationFilters$1): Signal<number>;
|
|
146
82
|
//#endregion
|
|
83
|
+
//#region src/use-mutation.d.ts
|
|
84
|
+
interface UseMutationResult<TData, TError = DefaultError, TVariables = void, TContext = unknown> {
|
|
85
|
+
/** Raw signal — full observer result. Fine-grained accessors below are preferred. */
|
|
86
|
+
result: Signal<MutationObserverResult<TData, TError, TVariables, TContext>>;
|
|
87
|
+
data: Signal<TData | undefined>;
|
|
88
|
+
error: Signal<TError | null>;
|
|
89
|
+
status: Signal<'idle' | 'pending' | 'success' | 'error'>;
|
|
90
|
+
isPending: Signal<boolean>;
|
|
91
|
+
isSuccess: Signal<boolean>;
|
|
92
|
+
isError: Signal<boolean>;
|
|
93
|
+
isIdle: Signal<boolean>;
|
|
94
|
+
/** Fire the mutation (fire-and-forget). Errors are captured in the error signal. */
|
|
95
|
+
mutate: (variables: TVariables, options?: Parameters<MutateFunction<TData, TError, TVariables, TContext>>[1]) => void;
|
|
96
|
+
/** Like mutate but returns a promise — use for try/catch error handling. */
|
|
97
|
+
mutateAsync: MutateFunction<TData, TError, TVariables, TContext>;
|
|
98
|
+
/** Reset the mutation state back to idle. */
|
|
99
|
+
reset: () => void;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Run a mutation (create / update / delete). Returns reactive signals for
|
|
103
|
+
* pending / success / error state plus `mutate` and `mutateAsync` functions.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* const mutation = useMutation({
|
|
107
|
+
* mutationFn: (data: CreatePostInput) =>
|
|
108
|
+
* fetch('/api/posts', { method: 'POST', body: JSON.stringify(data) }).then(r => r.json()),
|
|
109
|
+
* onSuccess: () => client.invalidateQueries({ queryKey: ['posts'] }),
|
|
110
|
+
* })
|
|
111
|
+
* // h('button', { onClick: () => mutation.mutate({ title: 'New' }) }, 'Create')
|
|
112
|
+
*/
|
|
113
|
+
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: MutationObserverOptions<TData, TError, TVariables, TContext>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
114
|
+
//#endregion
|
|
147
115
|
//#region src/use-queries.d.ts
|
|
148
116
|
type UseQueriesOptions<TQueryKey extends QueryKey$1 = QueryKey$1> = QueryObserverOptions<unknown, DefaultError, unknown, unknown, TQueryKey>;
|
|
149
117
|
/**
|
|
@@ -166,6 +134,135 @@ type UseQueriesOptions<TQueryKey extends QueryKey$1 = QueryKey$1> = QueryObserve
|
|
|
166
134
|
*/
|
|
167
135
|
declare function useQueries(queries: () => UseQueriesOptions[]): Signal<QueryObserverResult[]>;
|
|
168
136
|
//#endregion
|
|
137
|
+
//#region src/use-query.d.ts
|
|
138
|
+
interface UseQueryResult<TData, TError = DefaultError> {
|
|
139
|
+
/** Raw signal — the full observer result. Fine-grained accessors below are preferred. */
|
|
140
|
+
result: Signal<QueryObserverResult<TData, TError>>;
|
|
141
|
+
data: Signal<TData | undefined>;
|
|
142
|
+
error: Signal<TError | null>;
|
|
143
|
+
status: Signal<'pending' | 'error' | 'success'>;
|
|
144
|
+
isPending: Signal<boolean>;
|
|
145
|
+
isLoading: Signal<boolean>;
|
|
146
|
+
isFetching: Signal<boolean>;
|
|
147
|
+
isError: Signal<boolean>;
|
|
148
|
+
isSuccess: Signal<boolean>;
|
|
149
|
+
/** Manually trigger a refetch. */
|
|
150
|
+
refetch: () => Promise<QueryObserverResult<TData, TError>>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Subscribe to a query. Returns fine-grained reactive signals for data,
|
|
154
|
+
* error and status — each signal only notifies effects that depend on it.
|
|
155
|
+
*
|
|
156
|
+
* `options` is a function so it can read Pyreon signals — when a signal changes
|
|
157
|
+
* (e.g. a reactive query key), the observer is updated and refetches automatically.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* const userId = signal(1)
|
|
161
|
+
* const query = useQuery(() => ({
|
|
162
|
+
* queryKey: ['user', userId()],
|
|
163
|
+
* queryFn: () => fetch(`/api/users/${userId()}`).then(r => r.json()),
|
|
164
|
+
* }))
|
|
165
|
+
* // In template: () => query.data()?.name
|
|
166
|
+
*/
|
|
167
|
+
declare function useQuery<TData = unknown, TError = DefaultError, TKey extends QueryKey$1 = QueryKey$1>(options: () => QueryObserverOptions<TData, TError, TData, TData, TKey>): UseQueryResult<TData, TError>;
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/use-query-error-reset-boundary.d.ts
|
|
170
|
+
interface ErrorResetBoundaryValue {
|
|
171
|
+
reset: () => void;
|
|
172
|
+
}
|
|
173
|
+
interface QueryErrorResetBoundaryProps extends Props {
|
|
174
|
+
children?: VNodeChild;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Wraps a subtree so that `useQueryErrorResetBoundary()` descendants can reset
|
|
178
|
+
* all errored queries within this boundary.
|
|
179
|
+
*
|
|
180
|
+
* Pair with Pyreon's `ErrorBoundary` to retry failed queries when the user
|
|
181
|
+
* dismisses the error fallback:
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* h(QueryErrorResetBoundary, null,
|
|
185
|
+
* h(ErrorBoundary, {
|
|
186
|
+
* fallback: (err, boundaryReset) => {
|
|
187
|
+
* const { reset } = useQueryErrorResetBoundary()
|
|
188
|
+
* return h('button', {
|
|
189
|
+
* onClick: () => { reset(); boundaryReset() },
|
|
190
|
+
* }, 'Retry')
|
|
191
|
+
* },
|
|
192
|
+
* }, h(MyComponent, null)),
|
|
193
|
+
* )
|
|
194
|
+
*/
|
|
195
|
+
declare function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps): VNode;
|
|
196
|
+
/**
|
|
197
|
+
* Returns the `reset` function provided by the nearest `QueryErrorResetBoundary`.
|
|
198
|
+
* If called outside a boundary, falls back to resetting all errored queries
|
|
199
|
+
* on the current `QueryClient`.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* // Inside an ErrorBoundary fallback:
|
|
203
|
+
* const { reset } = useQueryErrorResetBoundary()
|
|
204
|
+
* h('button', { onClick: () => { reset(); boundaryReset() } }, 'Retry')
|
|
205
|
+
*/
|
|
206
|
+
declare function useQueryErrorResetBoundary(): ErrorResetBoundaryValue;
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/use-subscription.d.ts
|
|
209
|
+
type SubscriptionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
210
|
+
interface UseSubscriptionOptions {
|
|
211
|
+
/** WebSocket URL — can be a signal for reactive URLs */
|
|
212
|
+
url: string | (() => string);
|
|
213
|
+
/** WebSocket sub-protocols */
|
|
214
|
+
protocols?: string | string[];
|
|
215
|
+
/** Called when a message is received — use queryClient to invalidate or update cache */
|
|
216
|
+
onMessage: (event: MessageEvent, queryClient: QueryClient$1) => void;
|
|
217
|
+
/** Called when the connection opens */
|
|
218
|
+
onOpen?: (event: Event) => void;
|
|
219
|
+
/** Called when the connection closes */
|
|
220
|
+
onClose?: (event: CloseEvent) => void;
|
|
221
|
+
/** Called when a connection error occurs */
|
|
222
|
+
onError?: (event: Event) => void;
|
|
223
|
+
/** Whether to automatically reconnect — default: true */
|
|
224
|
+
reconnect?: boolean;
|
|
225
|
+
/** Initial reconnect delay in ms — doubles on each retry, default: 1000 */
|
|
226
|
+
reconnectDelay?: number;
|
|
227
|
+
/** Maximum reconnect attempts — default: 10, 0 = unlimited */
|
|
228
|
+
maxReconnectAttempts?: number;
|
|
229
|
+
/** Whether the subscription is enabled — default: true */
|
|
230
|
+
enabled?: boolean | (() => boolean);
|
|
231
|
+
}
|
|
232
|
+
interface UseSubscriptionResult {
|
|
233
|
+
/** Current connection status */
|
|
234
|
+
status: Signal<SubscriptionStatus>;
|
|
235
|
+
/** Send data through the WebSocket */
|
|
236
|
+
send: (data: string | ArrayBufferLike | Blob | ArrayBufferView) => void;
|
|
237
|
+
/** Manually close the connection */
|
|
238
|
+
close: () => void;
|
|
239
|
+
/** Manually reconnect */
|
|
240
|
+
reconnect: () => void;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Reactive WebSocket subscription that integrates with TanStack Query.
|
|
244
|
+
* Automatically manages connection lifecycle, reconnection, and cleanup.
|
|
245
|
+
*
|
|
246
|
+
* Use the `onMessage` callback to invalidate or update query cache
|
|
247
|
+
* when the server pushes data.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* const sub = useSubscription({
|
|
252
|
+
* url: 'wss://api.example.com/ws',
|
|
253
|
+
* onMessage: (event, queryClient) => {
|
|
254
|
+
* const data = JSON.parse(event.data)
|
|
255
|
+
* if (data.type === 'order-updated') {
|
|
256
|
+
* queryClient.invalidateQueries({ queryKey: ['orders'] })
|
|
257
|
+
* }
|
|
258
|
+
* },
|
|
259
|
+
* })
|
|
260
|
+
* // sub.status() — 'connecting' | 'connected' | 'disconnected' | 'error'
|
|
261
|
+
* // sub.send(JSON.stringify({ type: 'subscribe', channel: 'orders' }))
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
declare function useSubscription(options: UseSubscriptionOptions): UseSubscriptionResult;
|
|
265
|
+
//#endregion
|
|
169
266
|
//#region src/use-suspense-query.d.ts
|
|
170
267
|
/**
|
|
171
268
|
* Like `UseQueryResult` but `data` is `Signal<TData>` (never undefined).
|
|
@@ -255,44 +352,5 @@ declare function useSuspenseQuery<TData = unknown, TError = DefaultError, TKey e
|
|
|
255
352
|
*/
|
|
256
353
|
declare function useSuspenseInfiniteQuery<TQueryFnData = unknown, TError = DefaultError, TQueryKey extends QueryKey$1 = QueryKey$1, TPageParam = unknown>(options: () => InfiniteQueryObserverOptions<TQueryFnData, TError, InfiniteData<TQueryFnData>, TQueryKey, TPageParam>): UseSuspenseInfiniteQueryResult<TQueryFnData, TError>;
|
|
257
354
|
//#endregion
|
|
258
|
-
|
|
259
|
-
interface ErrorResetBoundaryValue {
|
|
260
|
-
reset: () => void;
|
|
261
|
-
}
|
|
262
|
-
interface QueryErrorResetBoundaryProps extends Props {
|
|
263
|
-
children?: VNodeChild;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Wraps a subtree so that `useQueryErrorResetBoundary()` descendants can reset
|
|
267
|
-
* all errored queries within this boundary.
|
|
268
|
-
*
|
|
269
|
-
* Pair with Pyreon's `ErrorBoundary` to retry failed queries when the user
|
|
270
|
-
* dismisses the error fallback:
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* h(QueryErrorResetBoundary, null,
|
|
274
|
-
* h(ErrorBoundary, {
|
|
275
|
-
* fallback: (err, boundaryReset) => {
|
|
276
|
-
* const { reset } = useQueryErrorResetBoundary()
|
|
277
|
-
* return h('button', {
|
|
278
|
-
* onClick: () => { reset(); boundaryReset() },
|
|
279
|
-
* }, 'Retry')
|
|
280
|
-
* },
|
|
281
|
-
* }, h(MyComponent, null)),
|
|
282
|
-
* )
|
|
283
|
-
*/
|
|
284
|
-
declare function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps): VNode;
|
|
285
|
-
/**
|
|
286
|
-
* Returns the `reset` function provided by the nearest `QueryErrorResetBoundary`.
|
|
287
|
-
* If called outside a boundary, falls back to resetting all errored queries
|
|
288
|
-
* on the current `QueryClient`.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* // Inside an ErrorBoundary fallback:
|
|
292
|
-
* const { reset } = useQueryErrorResetBoundary()
|
|
293
|
-
* h('button', { onClick: () => { reset(); boundaryReset() } }, 'Retry')
|
|
294
|
-
*/
|
|
295
|
-
declare function useQueryErrorResetBoundary(): ErrorResetBoundaryValue;
|
|
296
|
-
//#endregion
|
|
297
|
-
export { CancelledError, type DehydratedState, type FetchQueryOptions, type InvalidateOptions, type InvalidateQueryFilters, MutationCache, type MutationFilters, QueryCache, QueryClient, type QueryClientConfig, QueryClientContext, QueryClientProvider, type QueryClientProviderProps, QueryErrorResetBoundary, type QueryErrorResetBoundaryProps, type QueryFilters, type QueryKey, QuerySuspense, type QuerySuspenseProps, type RefetchOptions, type RefetchQueryFilters, type UseInfiniteQueryResult, type UseMutationResult, type UseQueriesOptions, type UseQueryResult, type UseSuspenseInfiniteQueryResult, type UseSuspenseQueryResult, defaultShouldDehydrateMutation, defaultShouldDehydrateQuery, dehydrate, hashKey, hydrate, isCancelledError, keepPreviousData, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useQueries, useQuery, useQueryClient, useQueryErrorResetBoundary, useSuspenseInfiniteQuery, useSuspenseQuery };
|
|
355
|
+
export { CancelledError, type DehydratedState, type FetchQueryOptions, type InvalidateOptions, type InvalidateQueryFilters, MutationCache, type MutationFilters, QueryCache, QueryClient, type QueryClientConfig, QueryClientContext, QueryClientProvider, type QueryClientProviderProps, QueryErrorResetBoundary, type QueryErrorResetBoundaryProps, type QueryFilters, type QueryKey, QuerySuspense, type QuerySuspenseProps, type RefetchOptions, type RefetchQueryFilters, type SubscriptionStatus, type UseInfiniteQueryResult, type UseMutationResult, type UseQueriesOptions, type UseQueryResult, type UseSubscriptionOptions, type UseSubscriptionResult, type UseSuspenseInfiniteQueryResult, type UseSuspenseQueryResult, defaultShouldDehydrateMutation, defaultShouldDehydrateQuery, dehydrate, hashKey, hydrate, isCancelledError, keepPreviousData, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useQueries, useQuery, useQueryClient, useQueryErrorResetBoundary, useSubscription, useSuspenseInfiniteQuery, useSuspenseQuery };
|
|
298
356
|
//# sourceMappingURL=index2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/query-client.ts","../../src/use-query.ts","../../src/use-
|
|
1
|
+
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/query-client.ts","../../src/use-infinite-query.ts","../../src/use-is-fetching.ts","../../src/use-mutation.ts","../../src/use-queries.ts","../../src/use-query.ts","../../src/use-query-error-reset-boundary.ts","../../src/use-subscription.ts","../../src/use-suspense-query.ts"],"mappings":";;;;;;UAWiB,wBAAA,SAAiC,KAAA;EAChD,MAAA,EAAQ,aAAA;EACR,QAAA,GAAW,UAAA;AAAA;AAAA,cAGA,kBAAA,EAAkB,aAAA,CAAA,OAAA,CAAA,aAAA;;;;;;;;;iBAUf,mBAAA,CAAoB,KAAA,EAAO,wBAAA,GAA2B,KAAA;;;;;iBAuBtD,cAAA,CAAA,GAAkB,aAAA;;;UCnCjB,sBAAA,wBAA8C,YAAA;;EAE7D,MAAA,EAAQ,MAAA,CACN,2BAAA,CAA4B,YAAA,CAAa,YAAA,GAAe,MAAA;EAE1D,IAAA,EAAM,MAAA,CAAO,YAAA,CAAa,YAAA;EAC1B,KAAA,EAAO,MAAA,CAAO,MAAA;EACd,MAAA,EAAQ,MAAA;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MAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/query",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Pyreon adapter for TanStack Query",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@tanstack/query-core": "^5.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@pyreon/core": ">=0.
|
|
47
|
-
"@pyreon/reactivity": ">=0.
|
|
46
|
+
"@pyreon/core": ">=0.5.0 <1.0.0",
|
|
47
|
+
"@pyreon/reactivity": ">=0.5.0 <1.0.0"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,69 +1,67 @@
|
|
|
1
1
|
// ─── TanStack Query core re-exports ──────────────────────────────────────────
|
|
2
2
|
// Users can import QueryClient, dehydrate, etc. from @pyreon/query directly.
|
|
3
3
|
|
|
4
|
-
export {
|
|
5
|
-
QueryClient,
|
|
6
|
-
QueryCache,
|
|
7
|
-
MutationCache,
|
|
8
|
-
dehydrate,
|
|
9
|
-
hydrate,
|
|
10
|
-
defaultShouldDehydrateQuery,
|
|
11
|
-
defaultShouldDehydrateMutation,
|
|
12
|
-
keepPreviousData,
|
|
13
|
-
hashKey,
|
|
14
|
-
isCancelledError,
|
|
15
|
-
CancelledError,
|
|
16
|
-
} from '@tanstack/query-core'
|
|
17
|
-
|
|
18
4
|
export type {
|
|
19
|
-
QueryKey,
|
|
20
|
-
QueryFilters,
|
|
21
|
-
MutationFilters,
|
|
22
5
|
DehydratedState,
|
|
23
6
|
FetchQueryOptions,
|
|
24
|
-
InvalidateQueryFilters,
|
|
25
7
|
InvalidateOptions,
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
InvalidateQueryFilters,
|
|
9
|
+
MutationFilters,
|
|
28
10
|
QueryClientConfig,
|
|
11
|
+
QueryFilters,
|
|
12
|
+
QueryKey,
|
|
13
|
+
RefetchOptions,
|
|
14
|
+
RefetchQueryFilters,
|
|
15
|
+
} from '@tanstack/query-core'
|
|
16
|
+
export {
|
|
17
|
+
CancelledError,
|
|
18
|
+
defaultShouldDehydrateMutation,
|
|
19
|
+
defaultShouldDehydrateQuery,
|
|
20
|
+
dehydrate,
|
|
21
|
+
hashKey,
|
|
22
|
+
hydrate,
|
|
23
|
+
isCancelledError,
|
|
24
|
+
keepPreviousData,
|
|
25
|
+
MutationCache,
|
|
26
|
+
QueryCache,
|
|
27
|
+
QueryClient,
|
|
29
28
|
} from '@tanstack/query-core'
|
|
30
29
|
|
|
31
30
|
// ─── Pyreon adapter ─────────────────────────────────────────────────────────────
|
|
32
31
|
|
|
32
|
+
export type { QueryClientProviderProps } from './query-client'
|
|
33
33
|
export {
|
|
34
34
|
QueryClientContext,
|
|
35
35
|
QueryClientProvider,
|
|
36
36
|
useQueryClient,
|
|
37
37
|
} from './query-client'
|
|
38
|
-
export type { QueryClientProviderProps } from './query-client'
|
|
39
|
-
|
|
40
|
-
export { useQuery } from './use-query'
|
|
41
|
-
export type { UseQueryResult } from './use-query'
|
|
42
|
-
|
|
43
|
-
export { useMutation } from './use-mutation'
|
|
44
|
-
export type { UseMutationResult } from './use-mutation'
|
|
45
|
-
|
|
46
|
-
export { useInfiniteQuery } from './use-infinite-query'
|
|
47
38
|
export type { UseInfiniteQueryResult } from './use-infinite-query'
|
|
48
|
-
|
|
39
|
+
export { useInfiniteQuery } from './use-infinite-query'
|
|
49
40
|
export { useIsFetching, useIsMutating } from './use-is-fetching'
|
|
50
|
-
|
|
51
|
-
export {
|
|
41
|
+
export type { UseMutationResult } from './use-mutation'
|
|
42
|
+
export { useMutation } from './use-mutation'
|
|
52
43
|
export type { UseQueriesOptions } from './use-queries'
|
|
53
|
-
|
|
44
|
+
export { useQueries } from './use-queries'
|
|
45
|
+
export type { UseQueryResult } from './use-query'
|
|
46
|
+
export { useQuery } from './use-query'
|
|
47
|
+
export type { QueryErrorResetBoundaryProps } from './use-query-error-reset-boundary'
|
|
54
48
|
export {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
QueryErrorResetBoundary,
|
|
50
|
+
useQueryErrorResetBoundary,
|
|
51
|
+
} from './use-query-error-reset-boundary'
|
|
52
|
+
export type {
|
|
53
|
+
SubscriptionStatus,
|
|
54
|
+
UseSubscriptionOptions,
|
|
55
|
+
UseSubscriptionResult,
|
|
56
|
+
} from './use-subscription'
|
|
57
|
+
export { useSubscription } from './use-subscription'
|
|
59
58
|
export type {
|
|
60
|
-
UseSuspenseQueryResult,
|
|
61
|
-
UseSuspenseInfiniteQueryResult,
|
|
62
59
|
QuerySuspenseProps,
|
|
60
|
+
UseSuspenseInfiniteQueryResult,
|
|
61
|
+
UseSuspenseQueryResult,
|
|
63
62
|
} from './use-suspense-query'
|
|
64
|
-
|
|
65
63
|
export {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
QuerySuspense,
|
|
65
|
+
useSuspenseInfiniteQuery,
|
|
66
|
+
useSuspenseQuery,
|
|
67
|
+
} from './use-suspense-query'
|
package/src/query-client.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
+
import type { Props, VNode, VNodeChild } from '@pyreon/core'
|
|
1
2
|
import {
|
|
2
3
|
createContext,
|
|
3
|
-
pushContext,
|
|
4
|
-
popContext,
|
|
5
4
|
onMount,
|
|
6
5
|
onUnmount,
|
|
6
|
+
popContext,
|
|
7
|
+
pushContext,
|
|
7
8
|
useContext,
|
|
8
9
|
} from '@pyreon/core'
|
|
9
|
-
import type { VNodeChild, VNode } from '@pyreon/core'
|
|
10
10
|
import type { QueryClient } from '@tanstack/query-core'
|
|
11
|
-
import type { Props } from '@pyreon/core'
|
|
12
11
|
|
|
13
12
|
export interface QueryClientProviderProps extends Props {
|
|
14
13
|
client: QueryClient
|