@tanstack/query-core 5.74.9 → 5.75.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/build/legacy/{hydration-BlEK5ylC.d.ts → hydration-C0rn_HEc.d.ts} +1 -2
- package/build/legacy/{hydration-CwYEwyQI.d.cts → hydration-DgVqMV9G.d.cts} +1 -2
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/streamedQuery.cjs +23 -17
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +6 -3
- package/build/legacy/streamedQuery.d.ts +6 -3
- package/build/legacy/streamedQuery.js +23 -17
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/modern/{hydration-BlEK5ylC.d.ts → hydration-C0rn_HEc.d.ts} +1 -2
- package/build/modern/{hydration-CwYEwyQI.d.cts → hydration-DgVqMV9G.d.cts} +1 -2
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/streamedQuery.cjs +23 -17
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +6 -3
- package/build/modern/streamedQuery.d.ts +6 -3
- package/build/modern/streamedQuery.js +23 -17
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/streamedQuery.ts +38 -21
- package/src/types.ts +0 -5
|
@@ -733,7 +733,6 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
733
733
|
type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {
|
|
734
734
|
[_ in TKey]: {};
|
|
735
735
|
};
|
|
736
|
-
type Optional<TTarget, TKey extends keyof TTarget> = Pick<Partial<TTarget>, TKey> & OmitKeyof<TTarget, TKey>;
|
|
737
736
|
type DefaultedQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = WithRequired<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
|
|
738
737
|
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserverOptions<TQueryFnData, TError, TData, InfiniteData<TQueryData, TPageParam>, TQueryKey, TPageParam>, InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {
|
|
739
738
|
}
|
|
@@ -1356,4 +1355,4 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
|
|
|
1356
1355
|
declare function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
|
|
1357
1356
|
declare function hydrate(client: QueryClient, dehydratedState: unknown, options?: HydrateOptions): void;
|
|
1358
1357
|
|
|
1359
|
-
export { type QueryKeyHashFunction as $, type QueryKey as A, dataTagSymbol as B, CancelledError as C, type DehydrateOptions as D, dataTagErrorSymbol as E, unsetMarker as F, type UnsetMarker as G, type HydrateOptions as H, type AnyDataTag as I, type DataTag as J, type InferDataFromTag as K, type InferErrorFromTag as L, MutationCache as M, type NoInfer as N, type OmitKeyof as O, type QueryFunction as P, QueryCache as Q, type Register as R, type SkipToken as S, type StaleTime as T, type Updater as U, type Enabled as V, type QueryPersister as W, type QueryFunctionContext as X, type InitialDataFunction as Y, type PlaceholderDataFunction as Z, type QueriesPlaceholderDataFunction as _, type QueryCacheNotifyEvent as a, type
|
|
1358
|
+
export { type QueryKeyHashFunction as $, type QueryKey as A, dataTagSymbol as B, CancelledError as C, type DehydrateOptions as D, dataTagErrorSymbol as E, unsetMarker as F, type UnsetMarker as G, type HydrateOptions as H, type AnyDataTag as I, type DataTag as J, type InferDataFromTag as K, type InferErrorFromTag as L, MutationCache as M, type NoInfer as N, type OmitKeyof as O, type QueryFunction as P, QueryCache as Q, type Register as R, type SkipToken as S, type StaleTime as T, type Updater as U, type Enabled as V, type QueryPersister as W, type QueryFunctionContext as X, type InitialDataFunction as Y, type PlaceholderDataFunction as Z, type QueriesPlaceholderDataFunction as _, type QueryCacheNotifyEvent as a, type DefaultOptions as a$, type GetPreviousPageParamFunction as a0, type GetNextPageParamFunction as a1, type InfiniteData as a2, type QueryMeta as a3, type NetworkMode as a4, type NotifyOnChangeProps as a5, type QueryOptions as a6, type InitialPageParam as a7, type InfiniteQueryPageParamsOptions as a8, type ThrowOnError as a9, type DefinedQueryObserverResult as aA, type QueryObserverResult as aB, type InfiniteQueryObserverBaseResult as aC, type InfiniteQueryObserverPendingResult as aD, type InfiniteQueryObserverLoadingResult as aE, type InfiniteQueryObserverLoadingErrorResult as aF, type InfiniteQueryObserverRefetchErrorResult as aG, type InfiniteQueryObserverSuccessResult as aH, type InfiniteQueryObserverPlaceholderResult as aI, type DefinedInfiniteQueryObserverResult as aJ, type InfiniteQueryObserverResult as aK, type MutationKey as aL, type MutationStatus as aM, type MutationScope as aN, type MutationMeta as aO, type MutationFunction as aP, type MutationOptions as aQ, type MutationObserverOptions as aR, type MutateOptions as aS, type MutateFunction as aT, type MutationObserverBaseResult as aU, type MutationObserverIdleResult as aV, type MutationObserverLoadingResult as aW, type MutationObserverErrorResult as aX, type MutationObserverSuccessResult as aY, type MutationObserverResult as aZ, type QueryClientConfig as a_, type QueryObserverOptions as aa, type WithRequired as ab, type DefaultedQueryObserverOptions as ac, type InfiniteQueryObserverOptions as ad, type DefaultedInfiniteQueryObserverOptions as ae, type FetchQueryOptions as af, type EnsureQueryDataOptions as ag, type EnsureInfiniteQueryDataOptions as ah, type FetchInfiniteQueryOptions as ai, type ResultOptions as aj, type RefetchOptions as ak, type InvalidateQueryFilters as al, type RefetchQueryFilters as am, type InvalidateOptions as an, type ResetOptions as ao, type FetchNextPageOptions as ap, type FetchPreviousPageOptions as aq, type QueryStatus as ar, type FetchStatus as as, type QueryObserverBaseResult as at, type QueryObserverPendingResult as au, type QueryObserverLoadingResult as av, type QueryObserverLoadingErrorResult as aw, type QueryObserverRefetchErrorResult as ax, type QueryObserverSuccessResult as ay, type QueryObserverPlaceholderResult as az, QueryClient as b, type CancelOptions as b0, type SetDataOptions as b1, type NotifyEventType as b2, type NotifyEvent as b3, type QueryBehavior as b4, type FetchContext as b5, type FetchDirection as b6, type FetchMeta as b7, type FetchOptions as b8, type Action$1 as b9, createRetryer as bA, type SetStateOptions as ba, fetchState as bb, type Action as bc, getDefaultState as bd, type QueryTypeFilter as be, noop as bf, functionalUpdate as bg, isValidTimeout as bh, timeUntilStale as bi, resolveStaleTime as bj, resolveEnabled as bk, hashQueryKeyByOptions as bl, partialMatchKey as bm, shallowEqualObjects as bn, isPlainArray as bo, isPlainObject as bp, sleep as bq, replaceData as br, addToEnd as bs, addToStart as bt, ensureQueryFn as bu, type QueryStore as bv, type Retryer as bw, type RetryValue as bx, type RetryDelayValue as by, canFetch as bz, QueryObserver as c, type MutationCacheNotifyEvent as d, MutationObserver as e, matchMutation as f, type MutationFilters as g, hashKey as h, isServer as i, type QueryFilters as j, keepPreviousData as k, isCancelledError as l, matchQuery as m, dehydrate as n, hydrate as o, defaultShouldDehydrateQuery as p, defaultShouldDehydrateMutation as q, replaceEqualDeep as r, skipToken as s, type QueryState as t, Query as u, type MutationState as v, Mutation as w, type DehydratedState as x, type Override as y, type DefaultError as z };
|
|
@@ -733,7 +733,6 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
733
733
|
type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {
|
|
734
734
|
[_ in TKey]: {};
|
|
735
735
|
};
|
|
736
|
-
type Optional<TTarget, TKey extends keyof TTarget> = Pick<Partial<TTarget>, TKey> & OmitKeyof<TTarget, TKey>;
|
|
737
736
|
type DefaultedQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = WithRequired<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
|
|
738
737
|
interface InfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserverOptions<TQueryFnData, TError, TData, InfiniteData<TQueryData, TPageParam>, TQueryKey, TPageParam>, InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {
|
|
739
738
|
}
|
|
@@ -1356,4 +1355,4 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
|
|
|
1356
1355
|
declare function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
|
|
1357
1356
|
declare function hydrate(client: QueryClient, dehydratedState: unknown, options?: HydrateOptions): void;
|
|
1358
1357
|
|
|
1359
|
-
export { type QueryKeyHashFunction as $, type QueryKey as A, dataTagSymbol as B, CancelledError as C, type DehydrateOptions as D, dataTagErrorSymbol as E, unsetMarker as F, type UnsetMarker as G, type HydrateOptions as H, type AnyDataTag as I, type DataTag as J, type InferDataFromTag as K, type InferErrorFromTag as L, MutationCache as M, type NoInfer as N, type OmitKeyof as O, type QueryFunction as P, QueryCache as Q, type Register as R, type SkipToken as S, type StaleTime as T, type Updater as U, type Enabled as V, type QueryPersister as W, type QueryFunctionContext as X, type InitialDataFunction as Y, type PlaceholderDataFunction as Z, type QueriesPlaceholderDataFunction as _, type QueryCacheNotifyEvent as a, type
|
|
1358
|
+
export { type QueryKeyHashFunction as $, type QueryKey as A, dataTagSymbol as B, CancelledError as C, type DehydrateOptions as D, dataTagErrorSymbol as E, unsetMarker as F, type UnsetMarker as G, type HydrateOptions as H, type AnyDataTag as I, type DataTag as J, type InferDataFromTag as K, type InferErrorFromTag as L, MutationCache as M, type NoInfer as N, type OmitKeyof as O, type QueryFunction as P, QueryCache as Q, type Register as R, type SkipToken as S, type StaleTime as T, type Updater as U, type Enabled as V, type QueryPersister as W, type QueryFunctionContext as X, type InitialDataFunction as Y, type PlaceholderDataFunction as Z, type QueriesPlaceholderDataFunction as _, type QueryCacheNotifyEvent as a, type DefaultOptions as a$, type GetPreviousPageParamFunction as a0, type GetNextPageParamFunction as a1, type InfiniteData as a2, type QueryMeta as a3, type NetworkMode as a4, type NotifyOnChangeProps as a5, type QueryOptions as a6, type InitialPageParam as a7, type InfiniteQueryPageParamsOptions as a8, type ThrowOnError as a9, type DefinedQueryObserverResult as aA, type QueryObserverResult as aB, type InfiniteQueryObserverBaseResult as aC, type InfiniteQueryObserverPendingResult as aD, type InfiniteQueryObserverLoadingResult as aE, type InfiniteQueryObserverLoadingErrorResult as aF, type InfiniteQueryObserverRefetchErrorResult as aG, type InfiniteQueryObserverSuccessResult as aH, type InfiniteQueryObserverPlaceholderResult as aI, type DefinedInfiniteQueryObserverResult as aJ, type InfiniteQueryObserverResult as aK, type MutationKey as aL, type MutationStatus as aM, type MutationScope as aN, type MutationMeta as aO, type MutationFunction as aP, type MutationOptions as aQ, type MutationObserverOptions as aR, type MutateOptions as aS, type MutateFunction as aT, type MutationObserverBaseResult as aU, type MutationObserverIdleResult as aV, type MutationObserverLoadingResult as aW, type MutationObserverErrorResult as aX, type MutationObserverSuccessResult as aY, type MutationObserverResult as aZ, type QueryClientConfig as a_, type QueryObserverOptions as aa, type WithRequired as ab, type DefaultedQueryObserverOptions as ac, type InfiniteQueryObserverOptions as ad, type DefaultedInfiniteQueryObserverOptions as ae, type FetchQueryOptions as af, type EnsureQueryDataOptions as ag, type EnsureInfiniteQueryDataOptions as ah, type FetchInfiniteQueryOptions as ai, type ResultOptions as aj, type RefetchOptions as ak, type InvalidateQueryFilters as al, type RefetchQueryFilters as am, type InvalidateOptions as an, type ResetOptions as ao, type FetchNextPageOptions as ap, type FetchPreviousPageOptions as aq, type QueryStatus as ar, type FetchStatus as as, type QueryObserverBaseResult as at, type QueryObserverPendingResult as au, type QueryObserverLoadingResult as av, type QueryObserverLoadingErrorResult as aw, type QueryObserverRefetchErrorResult as ax, type QueryObserverSuccessResult as ay, type QueryObserverPlaceholderResult as az, QueryClient as b, type CancelOptions as b0, type SetDataOptions as b1, type NotifyEventType as b2, type NotifyEvent as b3, type QueryBehavior as b4, type FetchContext as b5, type FetchDirection as b6, type FetchMeta as b7, type FetchOptions as b8, type Action$1 as b9, createRetryer as bA, type SetStateOptions as ba, fetchState as bb, type Action as bc, getDefaultState as bd, type QueryTypeFilter as be, noop as bf, functionalUpdate as bg, isValidTimeout as bh, timeUntilStale as bi, resolveStaleTime as bj, resolveEnabled as bk, hashQueryKeyByOptions as bl, partialMatchKey as bm, shallowEqualObjects as bn, isPlainArray as bo, isPlainObject as bp, sleep as bq, replaceData as br, addToEnd as bs, addToStart as bt, ensureQueryFn as bu, type QueryStore as bv, type Retryer as bw, type RetryValue as bx, type RetryDelayValue as by, canFetch as bz, QueryObserver as c, type MutationCacheNotifyEvent as d, MutationObserver as e, matchMutation as f, type MutationFilters as g, hashKey as h, isServer as i, type QueryFilters as j, keepPreviousData as k, isCancelledError as l, matchQuery as m, dehydrate as n, hydrate as o, defaultShouldDehydrateQuery as p, defaultShouldDehydrateMutation as q, replaceEqualDeep as r, skipToken as s, type QueryState as t, Query as u, type MutationState as v, Mutation as w, type DehydratedState as x, type Override as y, type DefaultError as z };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { D as DehydrateOptions, x as DehydratedState, H as HydrateOptions, q as defaultShouldDehydrateMutation, p as defaultShouldDehydrateQuery, n as dehydrate, o as hydrate } from './hydration-
|
|
1
|
+
export { D as DehydrateOptions, x as DehydratedState, H as HydrateOptions, q as defaultShouldDehydrateMutation, p as defaultShouldDehydrateQuery, n as dehydrate, o as hydrate } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { D as DehydrateOptions, x as DehydratedState, H as HydrateOptions, q as defaultShouldDehydrateMutation, p as defaultShouldDehydrateQuery, n as dehydrate, o as hydrate } from './hydration-
|
|
1
|
+
export { D as DehydrateOptions, x as DehydratedState, H as HydrateOptions, q as defaultShouldDehydrateMutation, p as defaultShouldDehydrateQuery, n as dehydrate, o as hydrate } from './hydration-C0rn_HEc.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/build/legacy/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as AnyDataTag,
|
|
1
|
+
export { I as AnyDataTag, b0 as CancelOptions, C as CancelledError, J as DataTag, z as DefaultError, a$ as DefaultOptions, ae as DefaultedInfiniteQueryObserverOptions, ac as DefaultedQueryObserverOptions, aJ as DefinedInfiniteQueryObserverResult, aA as DefinedQueryObserverResult, D as DehydrateOptions, x as DehydratedState, V as Enabled, ah as EnsureInfiniteQueryDataOptions, ag as EnsureQueryDataOptions, ai as FetchInfiniteQueryOptions, ap as FetchNextPageOptions, aq as FetchPreviousPageOptions, af as FetchQueryOptions, as as FetchStatus, a1 as GetNextPageParamFunction, a0 as GetPreviousPageParamFunction, H as HydrateOptions, K as InferDataFromTag, L as InferErrorFromTag, a2 as InfiniteData, aC as InfiniteQueryObserverBaseResult, aF as InfiniteQueryObserverLoadingErrorResult, aE as InfiniteQueryObserverLoadingResult, ad as InfiniteQueryObserverOptions, aD as InfiniteQueryObserverPendingResult, aI as InfiniteQueryObserverPlaceholderResult, aG as InfiniteQueryObserverRefetchErrorResult, aK as InfiniteQueryObserverResult, aH as InfiniteQueryObserverSuccessResult, a8 as InfiniteQueryPageParamsOptions, Y as InitialDataFunction, a7 as InitialPageParam, an as InvalidateOptions, al as InvalidateQueryFilters, aT as MutateFunction, aS as MutateOptions, w as Mutation, M as MutationCache, d as MutationCacheNotifyEvent, g as MutationFilters, aP as MutationFunction, aL as MutationKey, aO as MutationMeta, e as MutationObserver, aU as MutationObserverBaseResult, aX as MutationObserverErrorResult, aV as MutationObserverIdleResult, aW as MutationObserverLoadingResult, aR as MutationObserverOptions, aZ as MutationObserverResult, aY as MutationObserverSuccessResult, aQ as MutationOptions, aN as MutationScope, v as MutationState, aM as MutationStatus, a4 as NetworkMode, N as NoInfer, b3 as NotifyEvent, b2 as NotifyEventType, a5 as NotifyOnChangeProps, O as OmitKeyof, y as Override, Z as PlaceholderDataFunction, _ as QueriesPlaceholderDataFunction, u as Query, Q as QueryCache, a as QueryCacheNotifyEvent, b as QueryClient, a_ as QueryClientConfig, j as QueryFilters, P as QueryFunction, X as QueryFunctionContext, A as QueryKey, $ as QueryKeyHashFunction, a3 as QueryMeta, c as QueryObserver, at as QueryObserverBaseResult, aw as QueryObserverLoadingErrorResult, av as QueryObserverLoadingResult, aa as QueryObserverOptions, au as QueryObserverPendingResult, az as QueryObserverPlaceholderResult, ax as QueryObserverRefetchErrorResult, aB as QueryObserverResult, ay as QueryObserverSuccessResult, a6 as QueryOptions, W as QueryPersister, t as QueryState, ar as QueryStatus, ak as RefetchOptions, am as RefetchQueryFilters, R as Register, ao as ResetOptions, aj as ResultOptions, b1 as SetDataOptions, S as SkipToken, T as StaleTime, a9 as ThrowOnError, G as UnsetMarker, U as Updater, ab as WithRequired, E as dataTagErrorSymbol, B as dataTagSymbol, q as defaultShouldDehydrateMutation, p as defaultShouldDehydrateQuery, n as dehydrate, h as hashKey, o as hydrate, l as isCancelledError, i as isServer, k as keepPreviousData, f as matchMutation, m as matchQuery, r as replaceEqualDeep, s as skipToken, F as unsetMarker } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
export { QueriesObserver, QueriesObserverOptions } from './queriesObserver.cjs';
|
|
3
3
|
export { InfiniteQueryObserver } from './infiniteQueryObserver.cjs';
|
|
4
4
|
export { defaultScheduler, notifyManager } from './notifyManager.cjs';
|
package/build/legacy/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as AnyDataTag,
|
|
1
|
+
export { I as AnyDataTag, b0 as CancelOptions, C as CancelledError, J as DataTag, z as DefaultError, a$ as DefaultOptions, ae as DefaultedInfiniteQueryObserverOptions, ac as DefaultedQueryObserverOptions, aJ as DefinedInfiniteQueryObserverResult, aA as DefinedQueryObserverResult, D as DehydrateOptions, x as DehydratedState, V as Enabled, ah as EnsureInfiniteQueryDataOptions, ag as EnsureQueryDataOptions, ai as FetchInfiniteQueryOptions, ap as FetchNextPageOptions, aq as FetchPreviousPageOptions, af as FetchQueryOptions, as as FetchStatus, a1 as GetNextPageParamFunction, a0 as GetPreviousPageParamFunction, H as HydrateOptions, K as InferDataFromTag, L as InferErrorFromTag, a2 as InfiniteData, aC as InfiniteQueryObserverBaseResult, aF as InfiniteQueryObserverLoadingErrorResult, aE as InfiniteQueryObserverLoadingResult, ad as InfiniteQueryObserverOptions, aD as InfiniteQueryObserverPendingResult, aI as InfiniteQueryObserverPlaceholderResult, aG as InfiniteQueryObserverRefetchErrorResult, aK as InfiniteQueryObserverResult, aH as InfiniteQueryObserverSuccessResult, a8 as InfiniteQueryPageParamsOptions, Y as InitialDataFunction, a7 as InitialPageParam, an as InvalidateOptions, al as InvalidateQueryFilters, aT as MutateFunction, aS as MutateOptions, w as Mutation, M as MutationCache, d as MutationCacheNotifyEvent, g as MutationFilters, aP as MutationFunction, aL as MutationKey, aO as MutationMeta, e as MutationObserver, aU as MutationObserverBaseResult, aX as MutationObserverErrorResult, aV as MutationObserverIdleResult, aW as MutationObserverLoadingResult, aR as MutationObserverOptions, aZ as MutationObserverResult, aY as MutationObserverSuccessResult, aQ as MutationOptions, aN as MutationScope, v as MutationState, aM as MutationStatus, a4 as NetworkMode, N as NoInfer, b3 as NotifyEvent, b2 as NotifyEventType, a5 as NotifyOnChangeProps, O as OmitKeyof, y as Override, Z as PlaceholderDataFunction, _ as QueriesPlaceholderDataFunction, u as Query, Q as QueryCache, a as QueryCacheNotifyEvent, b as QueryClient, a_ as QueryClientConfig, j as QueryFilters, P as QueryFunction, X as QueryFunctionContext, A as QueryKey, $ as QueryKeyHashFunction, a3 as QueryMeta, c as QueryObserver, at as QueryObserverBaseResult, aw as QueryObserverLoadingErrorResult, av as QueryObserverLoadingResult, aa as QueryObserverOptions, au as QueryObserverPendingResult, az as QueryObserverPlaceholderResult, ax as QueryObserverRefetchErrorResult, aB as QueryObserverResult, ay as QueryObserverSuccessResult, a6 as QueryOptions, W as QueryPersister, t as QueryState, ar as QueryStatus, ak as RefetchOptions, am as RefetchQueryFilters, R as Register, ao as ResetOptions, aj as ResultOptions, b1 as SetDataOptions, S as SkipToken, T as StaleTime, a9 as ThrowOnError, G as UnsetMarker, U as Updater, ab as WithRequired, E as dataTagErrorSymbol, B as dataTagSymbol, q as defaultShouldDehydrateMutation, p as defaultShouldDehydrateQuery, n as dehydrate, h as hashKey, o as hydrate, l as isCancelledError, i as isServer, k as keepPreviousData, f as matchMutation, m as matchQuery, r as replaceEqualDeep, s as skipToken, F as unsetMarker } from './hydration-C0rn_HEc.js';
|
|
2
2
|
export { QueriesObserver, QueriesObserverOptions } from './queriesObserver.js';
|
|
3
3
|
export { InfiniteQueryObserver } from './infiniteQueryObserver.js';
|
|
4
4
|
export { defaultScheduler, notifyManager } from './notifyManager.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b4 as QueryBehavior, a2 as InfiniteData, a8 as InfiniteQueryPageParamsOptions } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b4 as QueryBehavior, a2 as InfiniteData, a8 as InfiniteQueryPageParamsOptions } from './hydration-C0rn_HEc.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z as DefaultError, a2 as InfiniteData, A as QueryKey, c as QueryObserver,
|
|
1
|
+
import { z as DefaultError, a2 as InfiniteData, A as QueryKey, c as QueryObserver, aK as InfiniteQueryObserverResult, b as QueryClient, ad as InfiniteQueryObserverOptions, ae as DefaultedInfiniteQueryObserverOptions, ap as FetchNextPageOptions, aq as FetchPreviousPageOptions, u as Query } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
import { Subscribable } from './subscribable.cjs';
|
|
3
3
|
import './removable.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z as DefaultError, a2 as InfiniteData, A as QueryKey, c as QueryObserver,
|
|
1
|
+
import { z as DefaultError, a2 as InfiniteData, A as QueryKey, c as QueryObserver, aK as InfiniteQueryObserverResult, b as QueryClient, ad as InfiniteQueryObserverOptions, ae as DefaultedInfiniteQueryObserverOptions, ap as FetchNextPageOptions, aq as FetchPreviousPageOptions, u as Query } from './hydration-C0rn_HEc.js';
|
|
2
2
|
import { Subscribable } from './subscribable.js';
|
|
3
3
|
import './removable.js';
|
|
4
4
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './removable.cjs';
|
|
2
|
-
export {
|
|
2
|
+
export { bc as Action, w as Mutation, v as MutationState, bd as getDefaultState } from './hydration-DgVqMV9G.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './removable.js';
|
|
2
|
-
export {
|
|
2
|
+
export { bc as Action, w as Mutation, v as MutationState, bd as getDefaultState } from './hydration-C0rn_HEc.js';
|
|
3
3
|
import './subscribable.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aB as QueryObserverResult, b as QueryClient, aa as QueryObserverOptions, u as Query, c as QueryObserver } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
import { Subscribable } from './subscribable.cjs';
|
|
3
3
|
import './removable.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aB as QueryObserverResult, b as QueryClient, aa as QueryObserverOptions, u as Query, c as QueryObserver } from './hydration-C0rn_HEc.js';
|
|
2
2
|
import { Subscribable } from './subscribable.js';
|
|
3
3
|
import './removable.js';
|
|
4
4
|
|
package/build/legacy/query.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './removable.cjs';
|
|
2
|
-
export {
|
|
2
|
+
export { b9 as Action, b5 as FetchContext, b6 as FetchDirection, b7 as FetchMeta, b8 as FetchOptions, u as Query, b4 as QueryBehavior, t as QueryState, ba as SetStateOptions, bb as fetchState } from './hydration-DgVqMV9G.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
package/build/legacy/query.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './removable.js';
|
|
2
|
-
export {
|
|
2
|
+
export { b9 as Action, b5 as FetchContext, b6 as FetchDirection, b7 as FetchMeta, b8 as FetchOptions, u as Query, b4 as QueryBehavior, t as QueryState, ba as SetStateOptions, bb as fetchState } from './hydration-C0rn_HEc.js';
|
|
3
3
|
import './subscribable.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CancelledError,
|
|
1
|
+
export { C as CancelledError, by as RetryDelayValue, bx as RetryValue, bw as Retryer, bz as canFetch, bA as createRetryer, l as isCancelledError } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CancelledError,
|
|
1
|
+
export { C as CancelledError, by as RetryDelayValue, bx as RetryValue, bw as Retryer, bz as canFetch, bA as createRetryer, l as isCancelledError } from './hydration-C0rn_HEc.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
|
@@ -25,31 +25,37 @@ __export(streamedQuery_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(streamedQuery_exports);
|
|
26
26
|
function streamedQuery({
|
|
27
27
|
queryFn,
|
|
28
|
-
refetchMode
|
|
28
|
+
refetchMode = "reset"
|
|
29
29
|
}) {
|
|
30
30
|
return async (context) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
31
|
+
const query = context.client.getQueryCache().find({ queryKey: context.queryKey, exact: true });
|
|
32
|
+
const isRefetch = !!query && query.state.data !== void 0;
|
|
33
|
+
if (isRefetch && refetchMode === "reset") {
|
|
34
|
+
query.setState({
|
|
35
|
+
status: "pending",
|
|
36
|
+
data: void 0,
|
|
37
|
+
error: null,
|
|
38
|
+
fetchStatus: "fetching"
|
|
39
|
+
});
|
|
41
40
|
}
|
|
41
|
+
const result = [];
|
|
42
42
|
const stream = await queryFn(context);
|
|
43
43
|
for await (const chunk of stream) {
|
|
44
44
|
if (context.signal.aborted) {
|
|
45
45
|
break;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
context.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
if (!isRefetch || refetchMode !== "replace") {
|
|
48
|
+
context.client.setQueryData(
|
|
49
|
+
context.queryKey,
|
|
50
|
+
(prev = []) => {
|
|
51
|
+
return prev.concat([chunk]);
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
result.push(chunk);
|
|
56
|
+
}
|
|
57
|
+
if (isRefetch && refetchMode === "replace" && !context.signal.aborted) {
|
|
58
|
+
context.client.setQueryData(context.queryKey, result);
|
|
53
59
|
}
|
|
54
60
|
return context.client.getQueryData(context.queryKey);
|
|
55
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import type { QueryFunction, QueryFunctionContext, QueryKey } from './types'\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param queryFn - The function that returns an AsyncIterable to stream data from.\n * @param refetchMode - Defaults to 'reset'
|
|
1
|
+
{"version":3,"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import type { QueryFunction, QueryFunctionContext, QueryKey } from './types'\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param queryFn - The function that returns an AsyncIterable to stream data from.\n * @param refetchMode - Defines how re-fetches are handled.\n * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.\n * Set to `'append'` to append new data to the existing data.\n * Set to `'replace'` to write the data to the cache at the end of the stream.\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>({\n queryFn,\n refetchMode = 'reset',\n}: {\n queryFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n refetchMode?: 'append' | 'reset' | 'replace'\n}): QueryFunction<Array<TQueryFnData>, TQueryKey> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.state.data !== undefined\n\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n status: 'pending',\n data: undefined,\n error: null,\n fetchStatus: 'fetching',\n })\n }\n\n const result: Array<TQueryFnData> = []\n const stream = await queryFn(context)\n\n for await (const chunk of stream) {\n if (context.signal.aborted) {\n break\n }\n\n // don't append to the cache directly when replace-refetching\n if (!isRefetch || refetchMode !== 'replace') {\n context.client.setQueryData<Array<TQueryFnData>>(\n context.queryKey,\n (prev = []) => {\n return prev.concat([chunk])\n },\n )\n }\n result.push(chunk)\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isRefetch && refetchMode === 'replace' && !context.signal.aborted) {\n context.client.setQueryData<Array<TQueryFnData>>(context.queryKey, result)\n }\n\n return context.client.getQueryData(context.queryKey)!\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,cAGd;AAAA,EACA;AAAA,EACA,cAAc;AAChB,GAKkD;AAChD,SAAO,OAAO,YAAY;AACxB,UAAM,QAAQ,QAAQ,OACnB,cAAc,EACd,KAAK,EAAE,UAAU,QAAQ,UAAU,OAAO,KAAK,CAAC;AACnD,UAAM,YAAY,CAAC,CAAC,SAAS,MAAM,MAAM,SAAS;AAElD,QAAI,aAAa,gBAAgB,SAAS;AACxC,YAAM,SAAS;AAAA,QACb,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,aAAa;AAAA,MACf,CAAC;AAAA,IACH;AAEA,UAAM,SAA8B,CAAC;AACrC,UAAM,SAAS,MAAM,QAAQ,OAAO;AAEpC,qBAAiB,SAAS,QAAQ;AAChC,UAAI,QAAQ,OAAO,SAAS;AAC1B;AAAA,MACF;AAGA,UAAI,CAAC,aAAa,gBAAgB,WAAW;AAC3C,gBAAQ,OAAO;AAAA,UACb,QAAQ;AAAA,UACR,CAAC,OAAO,CAAC,MAAM;AACb,mBAAO,KAAK,OAAO,CAAC,KAAK,CAAC;AAAA,UAC5B;AAAA,QACF;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB;AAGA,QAAI,aAAa,gBAAgB,aAAa,CAAC,QAAQ,OAAO,SAAS;AACrE,cAAQ,OAAO,aAAkC,QAAQ,UAAU,MAAM;AAAA,IAC3E;AAEA,WAAO,QAAQ,OAAO,aAAa,QAAQ,QAAQ;AAAA,EACrD;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as QueryKey, X as QueryFunctionContext, P as QueryFunction } from './hydration-
|
|
1
|
+
import { A as QueryKey, X as QueryFunctionContext, P as QueryFunction } from './hydration-DgVqMV9G.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
4
4
|
|
|
@@ -8,11 +8,14 @@ import './subscribable.cjs';
|
|
|
8
8
|
* The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
|
|
9
9
|
* The query will stay in fetchStatus 'fetching' until the stream ends.
|
|
10
10
|
* @param queryFn - The function that returns an AsyncIterable to stream data from.
|
|
11
|
-
* @param refetchMode -
|
|
11
|
+
* @param refetchMode - Defines how re-fetches are handled.
|
|
12
|
+
* Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
|
|
13
|
+
* Set to `'append'` to append new data to the existing data.
|
|
14
|
+
* Set to `'replace'` to write the data to the cache at the end of the stream.
|
|
12
15
|
*/
|
|
13
16
|
declare function streamedQuery<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>({ queryFn, refetchMode, }: {
|
|
14
17
|
queryFn: (context: QueryFunctionContext<TQueryKey>) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>;
|
|
15
|
-
refetchMode?: 'append' | 'reset';
|
|
18
|
+
refetchMode?: 'append' | 'reset' | 'replace';
|
|
16
19
|
}): QueryFunction<Array<TQueryFnData>, TQueryKey>;
|
|
17
20
|
|
|
18
21
|
export { streamedQuery };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as QueryKey, X as QueryFunctionContext, P as QueryFunction } from './hydration-
|
|
1
|
+
import { A as QueryKey, X as QueryFunctionContext, P as QueryFunction } from './hydration-C0rn_HEc.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
|
4
4
|
|
|
@@ -8,11 +8,14 @@ import './subscribable.js';
|
|
|
8
8
|
* The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.
|
|
9
9
|
* The query will stay in fetchStatus 'fetching' until the stream ends.
|
|
10
10
|
* @param queryFn - The function that returns an AsyncIterable to stream data from.
|
|
11
|
-
* @param refetchMode -
|
|
11
|
+
* @param refetchMode - Defines how re-fetches are handled.
|
|
12
|
+
* Defaults to `'reset'`, erases all data and puts the query back into `pending` state.
|
|
13
|
+
* Set to `'append'` to append new data to the existing data.
|
|
14
|
+
* Set to `'replace'` to write the data to the cache at the end of the stream.
|
|
12
15
|
*/
|
|
13
16
|
declare function streamedQuery<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey>({ queryFn, refetchMode, }: {
|
|
14
17
|
queryFn: (context: QueryFunctionContext<TQueryKey>) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>;
|
|
15
|
-
refetchMode?: 'append' | 'reset';
|
|
18
|
+
refetchMode?: 'append' | 'reset' | 'replace';
|
|
16
19
|
}): QueryFunction<Array<TQueryFnData>, TQueryKey>;
|
|
17
20
|
|
|
18
21
|
export { streamedQuery };
|
|
@@ -3,31 +3,37 @@ import "./chunk-PXG64RU4.js";
|
|
|
3
3
|
// src/streamedQuery.ts
|
|
4
4
|
function streamedQuery({
|
|
5
5
|
queryFn,
|
|
6
|
-
refetchMode
|
|
6
|
+
refetchMode = "reset"
|
|
7
7
|
}) {
|
|
8
8
|
return async (context) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
9
|
+
const query = context.client.getQueryCache().find({ queryKey: context.queryKey, exact: true });
|
|
10
|
+
const isRefetch = !!query && query.state.data !== void 0;
|
|
11
|
+
if (isRefetch && refetchMode === "reset") {
|
|
12
|
+
query.setState({
|
|
13
|
+
status: "pending",
|
|
14
|
+
data: void 0,
|
|
15
|
+
error: null,
|
|
16
|
+
fetchStatus: "fetching"
|
|
17
|
+
});
|
|
19
18
|
}
|
|
19
|
+
const result = [];
|
|
20
20
|
const stream = await queryFn(context);
|
|
21
21
|
for await (const chunk of stream) {
|
|
22
22
|
if (context.signal.aborted) {
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
context.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
if (!isRefetch || refetchMode !== "replace") {
|
|
26
|
+
context.client.setQueryData(
|
|
27
|
+
context.queryKey,
|
|
28
|
+
(prev = []) => {
|
|
29
|
+
return prev.concat([chunk]);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
result.push(chunk);
|
|
34
|
+
}
|
|
35
|
+
if (isRefetch && refetchMode === "replace" && !context.signal.aborted) {
|
|
36
|
+
context.client.setQueryData(context.queryKey, result);
|
|
31
37
|
}
|
|
32
38
|
return context.client.getQueryData(context.queryKey);
|
|
33
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import type { QueryFunction, QueryFunctionContext, QueryKey } from './types'\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param queryFn - The function that returns an AsyncIterable to stream data from.\n * @param refetchMode - Defaults to 'reset'
|
|
1
|
+
{"version":3,"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import type { QueryFunction, QueryFunctionContext, QueryKey } from './types'\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param queryFn - The function that returns an AsyncIterable to stream data from.\n * @param refetchMode - Defines how re-fetches are handled.\n * Defaults to `'reset'`, erases all data and puts the query back into `pending` state.\n * Set to `'append'` to append new data to the existing data.\n * Set to `'replace'` to write the data to the cache at the end of the stream.\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>({\n queryFn,\n refetchMode = 'reset',\n}: {\n queryFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n refetchMode?: 'append' | 'reset' | 'replace'\n}): QueryFunction<Array<TQueryFnData>, TQueryKey> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.state.data !== undefined\n\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n status: 'pending',\n data: undefined,\n error: null,\n fetchStatus: 'fetching',\n })\n }\n\n const result: Array<TQueryFnData> = []\n const stream = await queryFn(context)\n\n for await (const chunk of stream) {\n if (context.signal.aborted) {\n break\n }\n\n // don't append to the cache directly when replace-refetching\n if (!isRefetch || refetchMode !== 'replace') {\n context.client.setQueryData<Array<TQueryFnData>>(\n context.queryKey,\n (prev = []) => {\n return prev.concat([chunk])\n },\n )\n }\n result.push(chunk)\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isRefetch && refetchMode === 'replace' && !context.signal.aborted) {\n context.client.setQueryData<Array<TQueryFnData>>(context.queryKey, result)\n }\n\n return context.client.getQueryData(context.queryKey)!\n }\n}\n"],"mappings":";;;AAaO,SAAS,cAGd;AAAA,EACA;AAAA,EACA,cAAc;AAChB,GAKkD;AAChD,SAAO,OAAO,YAAY;AACxB,UAAM,QAAQ,QAAQ,OACnB,cAAc,EACd,KAAK,EAAE,UAAU,QAAQ,UAAU,OAAO,KAAK,CAAC;AACnD,UAAM,YAAY,CAAC,CAAC,SAAS,MAAM,MAAM,SAAS;AAElD,QAAI,aAAa,gBAAgB,SAAS;AACxC,YAAM,SAAS;AAAA,QACb,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,QACP,aAAa;AAAA,MACf,CAAC;AAAA,IACH;AAEA,UAAM,SAA8B,CAAC;AACrC,UAAM,SAAS,MAAM,QAAQ,OAAO;AAEpC,qBAAiB,SAAS,QAAQ;AAChC,UAAI,QAAQ,OAAO,SAAS;AAC1B;AAAA,MACF;AAGA,UAAI,CAAC,aAAa,gBAAgB,WAAW;AAC3C,gBAAQ,OAAO;AAAA,UACb,QAAQ;AAAA,UACR,CAAC,OAAO,CAAC,MAAM;AACb,mBAAO,KAAK,OAAO,CAAC,KAAK,CAAC;AAAA,UAC5B;AAAA,QACF;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB;AAGA,QAAI,aAAa,gBAAgB,aAAa,CAAC,QAAQ,OAAO,SAAS;AACrE,cAAQ,OAAO,aAAkC,QAAQ,UAAU,MAAM;AAAA,IAC3E;AAEA,WAAO,QAAQ,OAAO,aAAa,QAAQ,QAAQ;AAAA,EACrD;AACF;","names":[]}
|