@tanstack/query-core 5.74.9 → 5.75.4
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-CwYEwyQI.d.cts → hydration-B6nZCPcW.d.cts} +2 -2
- package/build/legacy/{hydration-BlEK5ylC.d.ts → hydration-ZCurbX1S.d.ts} +2 -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-CwYEwyQI.d.cts → hydration-B6nZCPcW.d.cts} +2 -2
- package/build/modern/{hydration-BlEK5ylC.d.ts → hydration-ZCurbX1S.d.ts} +2 -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 +5 -5
|
@@ -509,6 +509,7 @@ declare class CancelledError extends Error {
|
|
|
509
509
|
declare function isCancelledError(value: any): value is CancelledError;
|
|
510
510
|
declare function createRetryer<TData = unknown, TError = DefaultError>(config: RetryerConfig<TData, TError>): Retryer<TData>;
|
|
511
511
|
|
|
512
|
+
type DistributiveOmit<TObject, TKey extends keyof TObject> = TObject extends any ? Omit<TObject, TKey> : never;
|
|
512
513
|
type OmitKeyof<TObject, TKey extends TStrictly extends 'safely' ? keyof TObject | (string & Record<never, never>) | (number & Record<never, never>) | (symbol & Record<never, never>) : keyof TObject, TStrictly extends 'strictly' | 'safely' = 'strictly'> = Omit<TObject, TKey>;
|
|
513
514
|
type Override<TTargetA, TTargetB> = {
|
|
514
515
|
[AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey];
|
|
@@ -733,7 +734,6 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
733
734
|
type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {
|
|
734
735
|
[_ in TKey]: {};
|
|
735
736
|
};
|
|
736
|
-
type Optional<TTarget, TKey extends keyof TTarget> = Pick<Partial<TTarget>, TKey> & OmitKeyof<TTarget, TKey>;
|
|
737
737
|
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
738
|
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
739
|
}
|
|
@@ -1356,4 +1356,4 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
|
|
|
1356
1356
|
declare function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
|
|
1357
1357
|
declare function hydrate(client: QueryClient, dehydratedState: unknown, options?: HydrateOptions): void;
|
|
1358
1358
|
|
|
1359
|
-
export { type
|
|
1359
|
+
export { type QueriesPlaceholderDataFunction as $, type DefaultError as A, type QueryKey as B, CancelledError as C, type DehydrateOptions as D, dataTagSymbol as E, dataTagErrorSymbol as F, unsetMarker as G, type HydrateOptions as H, type UnsetMarker as I, type AnyDataTag as J, type DataTag as K, type InferDataFromTag as L, MutationCache as M, type NoInfer as N, type OmitKeyof as O, type InferErrorFromTag as P, QueryCache as Q, type Register as R, type SkipToken as S, type QueryFunction as T, type Updater as U, type StaleTime as V, type Enabled as W, type QueryPersister as X, type QueryFunctionContext as Y, type InitialDataFunction as Z, type PlaceholderDataFunction as _, type QueryCacheNotifyEvent as a, type QueryClientConfig as a$, type QueryKeyHashFunction as a0, type GetPreviousPageParamFunction as a1, type GetNextPageParamFunction as a2, type InfiniteData as a3, type QueryMeta as a4, type NetworkMode as a5, type NotifyOnChangeProps as a6, type QueryOptions as a7, type InitialPageParam as a8, type InfiniteQueryPageParamsOptions as a9, type QueryObserverPlaceholderResult as aA, type DefinedQueryObserverResult as aB, type QueryObserverResult as aC, type InfiniteQueryObserverBaseResult as aD, type InfiniteQueryObserverPendingResult as aE, type InfiniteQueryObserverLoadingResult as aF, type InfiniteQueryObserverLoadingErrorResult as aG, type InfiniteQueryObserverRefetchErrorResult as aH, type InfiniteQueryObserverSuccessResult as aI, type InfiniteQueryObserverPlaceholderResult as aJ, type DefinedInfiniteQueryObserverResult as aK, type InfiniteQueryObserverResult as aL, type MutationKey as aM, type MutationStatus as aN, type MutationScope as aO, type MutationMeta as aP, type MutationFunction as aQ, type MutationOptions as aR, type MutationObserverOptions as aS, type MutateOptions as aT, type MutateFunction as aU, type MutationObserverBaseResult as aV, type MutationObserverIdleResult as aW, type MutationObserverLoadingResult as aX, type MutationObserverErrorResult as aY, type MutationObserverSuccessResult as aZ, type MutationObserverResult as a_, type ThrowOnError as aa, type QueryObserverOptions as ab, type WithRequired as ac, type DefaultedQueryObserverOptions as ad, type InfiniteQueryObserverOptions as ae, type DefaultedInfiniteQueryObserverOptions as af, type FetchQueryOptions as ag, type EnsureQueryDataOptions as ah, type EnsureInfiniteQueryDataOptions as ai, type FetchInfiniteQueryOptions as aj, type ResultOptions as ak, type RefetchOptions as al, type InvalidateQueryFilters as am, type RefetchQueryFilters as an, type InvalidateOptions as ao, type ResetOptions as ap, type FetchNextPageOptions as aq, type FetchPreviousPageOptions as ar, type QueryStatus as as, type FetchStatus as at, type QueryObserverBaseResult as au, type QueryObserverPendingResult as av, type QueryObserverLoadingResult as aw, type QueryObserverLoadingErrorResult as ax, type QueryObserverRefetchErrorResult as ay, type QueryObserverSuccessResult as az, QueryClient as b, type DefaultOptions as b0, type CancelOptions as b1, type SetDataOptions as b2, type NotifyEventType as b3, type NotifyEvent as b4, type QueryBehavior as b5, type FetchContext as b6, type FetchDirection as b7, type FetchMeta as b8, type FetchOptions as b9, canFetch as bA, createRetryer as bB, type Action$1 as ba, type SetStateOptions as bb, fetchState as bc, type Action as bd, getDefaultState as be, type QueryTypeFilter as bf, noop as bg, functionalUpdate as bh, isValidTimeout as bi, timeUntilStale as bj, resolveStaleTime as bk, resolveEnabled as bl, hashQueryKeyByOptions as bm, partialMatchKey as bn, shallowEqualObjects as bo, isPlainArray as bp, isPlainObject as bq, sleep as br, replaceData as bs, addToEnd as bt, addToStart as bu, ensureQueryFn as bv, type QueryStore as bw, type Retryer as bx, type RetryValue as by, type RetryDelayValue 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 DistributiveOmit as y, type Override as z };
|
|
@@ -509,6 +509,7 @@ declare class CancelledError extends Error {
|
|
|
509
509
|
declare function isCancelledError(value: any): value is CancelledError;
|
|
510
510
|
declare function createRetryer<TData = unknown, TError = DefaultError>(config: RetryerConfig<TData, TError>): Retryer<TData>;
|
|
511
511
|
|
|
512
|
+
type DistributiveOmit<TObject, TKey extends keyof TObject> = TObject extends any ? Omit<TObject, TKey> : never;
|
|
512
513
|
type OmitKeyof<TObject, TKey extends TStrictly extends 'safely' ? keyof TObject | (string & Record<never, never>) | (number & Record<never, never>) | (symbol & Record<never, never>) : keyof TObject, TStrictly extends 'strictly' | 'safely' = 'strictly'> = Omit<TObject, TKey>;
|
|
513
514
|
type Override<TTargetA, TTargetB> = {
|
|
514
515
|
[AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey];
|
|
@@ -733,7 +734,6 @@ interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TD
|
|
|
733
734
|
type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {
|
|
734
735
|
[_ in TKey]: {};
|
|
735
736
|
};
|
|
736
|
-
type Optional<TTarget, TKey extends keyof TTarget> = Pick<Partial<TTarget>, TKey> & OmitKeyof<TTarget, TKey>;
|
|
737
737
|
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
738
|
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
739
|
}
|
|
@@ -1356,4 +1356,4 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
|
|
|
1356
1356
|
declare function dehydrate(client: QueryClient, options?: DehydrateOptions): DehydratedState;
|
|
1357
1357
|
declare function hydrate(client: QueryClient, dehydratedState: unknown, options?: HydrateOptions): void;
|
|
1358
1358
|
|
|
1359
|
-
export { type
|
|
1359
|
+
export { type QueriesPlaceholderDataFunction as $, type DefaultError as A, type QueryKey as B, CancelledError as C, type DehydrateOptions as D, dataTagSymbol as E, dataTagErrorSymbol as F, unsetMarker as G, type HydrateOptions as H, type UnsetMarker as I, type AnyDataTag as J, type DataTag as K, type InferDataFromTag as L, MutationCache as M, type NoInfer as N, type OmitKeyof as O, type InferErrorFromTag as P, QueryCache as Q, type Register as R, type SkipToken as S, type QueryFunction as T, type Updater as U, type StaleTime as V, type Enabled as W, type QueryPersister as X, type QueryFunctionContext as Y, type InitialDataFunction as Z, type PlaceholderDataFunction as _, type QueryCacheNotifyEvent as a, type QueryClientConfig as a$, type QueryKeyHashFunction as a0, type GetPreviousPageParamFunction as a1, type GetNextPageParamFunction as a2, type InfiniteData as a3, type QueryMeta as a4, type NetworkMode as a5, type NotifyOnChangeProps as a6, type QueryOptions as a7, type InitialPageParam as a8, type InfiniteQueryPageParamsOptions as a9, type QueryObserverPlaceholderResult as aA, type DefinedQueryObserverResult as aB, type QueryObserverResult as aC, type InfiniteQueryObserverBaseResult as aD, type InfiniteQueryObserverPendingResult as aE, type InfiniteQueryObserverLoadingResult as aF, type InfiniteQueryObserverLoadingErrorResult as aG, type InfiniteQueryObserverRefetchErrorResult as aH, type InfiniteQueryObserverSuccessResult as aI, type InfiniteQueryObserverPlaceholderResult as aJ, type DefinedInfiniteQueryObserverResult as aK, type InfiniteQueryObserverResult as aL, type MutationKey as aM, type MutationStatus as aN, type MutationScope as aO, type MutationMeta as aP, type MutationFunction as aQ, type MutationOptions as aR, type MutationObserverOptions as aS, type MutateOptions as aT, type MutateFunction as aU, type MutationObserverBaseResult as aV, type MutationObserverIdleResult as aW, type MutationObserverLoadingResult as aX, type MutationObserverErrorResult as aY, type MutationObserverSuccessResult as aZ, type MutationObserverResult as a_, type ThrowOnError as aa, type QueryObserverOptions as ab, type WithRequired as ac, type DefaultedQueryObserverOptions as ad, type InfiniteQueryObserverOptions as ae, type DefaultedInfiniteQueryObserverOptions as af, type FetchQueryOptions as ag, type EnsureQueryDataOptions as ah, type EnsureInfiniteQueryDataOptions as ai, type FetchInfiniteQueryOptions as aj, type ResultOptions as ak, type RefetchOptions as al, type InvalidateQueryFilters as am, type RefetchQueryFilters as an, type InvalidateOptions as ao, type ResetOptions as ap, type FetchNextPageOptions as aq, type FetchPreviousPageOptions as ar, type QueryStatus as as, type FetchStatus as at, type QueryObserverBaseResult as au, type QueryObserverPendingResult as av, type QueryObserverLoadingResult as aw, type QueryObserverLoadingErrorResult as ax, type QueryObserverRefetchErrorResult as ay, type QueryObserverSuccessResult as az, QueryClient as b, type DefaultOptions as b0, type CancelOptions as b1, type SetDataOptions as b2, type NotifyEventType as b3, type NotifyEvent as b4, type QueryBehavior as b5, type FetchContext as b6, type FetchDirection as b7, type FetchMeta as b8, type FetchOptions as b9, canFetch as bA, createRetryer as bB, type Action$1 as ba, type SetStateOptions as bb, fetchState as bc, type Action as bd, getDefaultState as be, type QueryTypeFilter as bf, noop as bg, functionalUpdate as bh, isValidTimeout as bi, timeUntilStale as bj, resolveStaleTime as bk, resolveEnabled as bl, hashQueryKeyByOptions as bm, partialMatchKey as bn, shallowEqualObjects as bo, isPlainArray as bp, isPlainObject as bq, sleep as br, replaceData as bs, addToEnd as bt, addToStart as bu, ensureQueryFn as bv, type QueryStore as bw, type Retryer as bx, type RetryValue as by, type RetryDelayValue 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 DistributiveOmit as y, type Override 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-B6nZCPcW.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-ZCurbX1S.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/build/legacy/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { J as AnyDataTag, b1 as CancelOptions, C as CancelledError, K as DataTag, A as DefaultError, b0 as DefaultOptions, af as DefaultedInfiniteQueryObserverOptions, ad as DefaultedQueryObserverOptions, aK as DefinedInfiniteQueryObserverResult, aB as DefinedQueryObserverResult, D as DehydrateOptions, x as DehydratedState, y as DistributiveOmit, W as Enabled, ai as EnsureInfiniteQueryDataOptions, ah as EnsureQueryDataOptions, aj as FetchInfiniteQueryOptions, aq as FetchNextPageOptions, ar as FetchPreviousPageOptions, ag as FetchQueryOptions, at as FetchStatus, a2 as GetNextPageParamFunction, a1 as GetPreviousPageParamFunction, H as HydrateOptions, L as InferDataFromTag, P as InferErrorFromTag, a3 as InfiniteData, aD as InfiniteQueryObserverBaseResult, aG as InfiniteQueryObserverLoadingErrorResult, aF as InfiniteQueryObserverLoadingResult, ae as InfiniteQueryObserverOptions, aE as InfiniteQueryObserverPendingResult, aJ as InfiniteQueryObserverPlaceholderResult, aH as InfiniteQueryObserverRefetchErrorResult, aL as InfiniteQueryObserverResult, aI as InfiniteQueryObserverSuccessResult, a9 as InfiniteQueryPageParamsOptions, Z as InitialDataFunction, a8 as InitialPageParam, ao as InvalidateOptions, am as InvalidateQueryFilters, aU as MutateFunction, aT as MutateOptions, w as Mutation, M as MutationCache, d as MutationCacheNotifyEvent, g as MutationFilters, aQ as MutationFunction, aM as MutationKey, aP as MutationMeta, e as MutationObserver, aV as MutationObserverBaseResult, aY as MutationObserverErrorResult, aW as MutationObserverIdleResult, aX as MutationObserverLoadingResult, aS as MutationObserverOptions, a_ as MutationObserverResult, aZ as MutationObserverSuccessResult, aR as MutationOptions, aO as MutationScope, v as MutationState, aN as MutationStatus, a5 as NetworkMode, N as NoInfer, b4 as NotifyEvent, b3 as NotifyEventType, a6 as NotifyOnChangeProps, O as OmitKeyof, z as Override, _ as PlaceholderDataFunction, $ as QueriesPlaceholderDataFunction, u as Query, Q as QueryCache, a as QueryCacheNotifyEvent, b as QueryClient, a$ as QueryClientConfig, j as QueryFilters, T as QueryFunction, Y as QueryFunctionContext, B as QueryKey, a0 as QueryKeyHashFunction, a4 as QueryMeta, c as QueryObserver, au as QueryObserverBaseResult, ax as QueryObserverLoadingErrorResult, aw as QueryObserverLoadingResult, ab as QueryObserverOptions, av as QueryObserverPendingResult, aA as QueryObserverPlaceholderResult, ay as QueryObserverRefetchErrorResult, aC as QueryObserverResult, az as QueryObserverSuccessResult, a7 as QueryOptions, X as QueryPersister, t as QueryState, as as QueryStatus, al as RefetchOptions, an as RefetchQueryFilters, R as Register, ap as ResetOptions, ak as ResultOptions, b2 as SetDataOptions, S as SkipToken, V as StaleTime, aa as ThrowOnError, I as UnsetMarker, U as Updater, ac as WithRequired, F as dataTagErrorSymbol, E 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, G as unsetMarker } from './hydration-B6nZCPcW.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 {
|
|
1
|
+
export { J as AnyDataTag, b1 as CancelOptions, C as CancelledError, K as DataTag, A as DefaultError, b0 as DefaultOptions, af as DefaultedInfiniteQueryObserverOptions, ad as DefaultedQueryObserverOptions, aK as DefinedInfiniteQueryObserverResult, aB as DefinedQueryObserverResult, D as DehydrateOptions, x as DehydratedState, y as DistributiveOmit, W as Enabled, ai as EnsureInfiniteQueryDataOptions, ah as EnsureQueryDataOptions, aj as FetchInfiniteQueryOptions, aq as FetchNextPageOptions, ar as FetchPreviousPageOptions, ag as FetchQueryOptions, at as FetchStatus, a2 as GetNextPageParamFunction, a1 as GetPreviousPageParamFunction, H as HydrateOptions, L as InferDataFromTag, P as InferErrorFromTag, a3 as InfiniteData, aD as InfiniteQueryObserverBaseResult, aG as InfiniteQueryObserverLoadingErrorResult, aF as InfiniteQueryObserverLoadingResult, ae as InfiniteQueryObserverOptions, aE as InfiniteQueryObserverPendingResult, aJ as InfiniteQueryObserverPlaceholderResult, aH as InfiniteQueryObserverRefetchErrorResult, aL as InfiniteQueryObserverResult, aI as InfiniteQueryObserverSuccessResult, a9 as InfiniteQueryPageParamsOptions, Z as InitialDataFunction, a8 as InitialPageParam, ao as InvalidateOptions, am as InvalidateQueryFilters, aU as MutateFunction, aT as MutateOptions, w as Mutation, M as MutationCache, d as MutationCacheNotifyEvent, g as MutationFilters, aQ as MutationFunction, aM as MutationKey, aP as MutationMeta, e as MutationObserver, aV as MutationObserverBaseResult, aY as MutationObserverErrorResult, aW as MutationObserverIdleResult, aX as MutationObserverLoadingResult, aS as MutationObserverOptions, a_ as MutationObserverResult, aZ as MutationObserverSuccessResult, aR as MutationOptions, aO as MutationScope, v as MutationState, aN as MutationStatus, a5 as NetworkMode, N as NoInfer, b4 as NotifyEvent, b3 as NotifyEventType, a6 as NotifyOnChangeProps, O as OmitKeyof, z as Override, _ as PlaceholderDataFunction, $ as QueriesPlaceholderDataFunction, u as Query, Q as QueryCache, a as QueryCacheNotifyEvent, b as QueryClient, a$ as QueryClientConfig, j as QueryFilters, T as QueryFunction, Y as QueryFunctionContext, B as QueryKey, a0 as QueryKeyHashFunction, a4 as QueryMeta, c as QueryObserver, au as QueryObserverBaseResult, ax as QueryObserverLoadingErrorResult, aw as QueryObserverLoadingResult, ab as QueryObserverOptions, av as QueryObserverPendingResult, aA as QueryObserverPlaceholderResult, ay as QueryObserverRefetchErrorResult, aC as QueryObserverResult, az as QueryObserverSuccessResult, a7 as QueryOptions, X as QueryPersister, t as QueryState, as as QueryStatus, al as RefetchOptions, an as RefetchQueryFilters, R as Register, ap as ResetOptions, ak as ResultOptions, b2 as SetDataOptions, S as SkipToken, V as StaleTime, aa as ThrowOnError, I as UnsetMarker, U as Updater, ac as WithRequired, F as dataTagErrorSymbol, E 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, G as unsetMarker } from './hydration-ZCurbX1S.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 { b5 as QueryBehavior,
|
|
1
|
+
import { b5 as QueryBehavior, a3 as InfiniteData, a9 as InfiniteQueryPageParamsOptions } from './hydration-B6nZCPcW.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b5 as QueryBehavior,
|
|
1
|
+
import { b5 as QueryBehavior, a3 as InfiniteData, a9 as InfiniteQueryPageParamsOptions } from './hydration-ZCurbX1S.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as DefaultError, a3 as InfiniteData, B as QueryKey, c as QueryObserver, aL as InfiniteQueryObserverResult, b as QueryClient, ae as InfiniteQueryObserverOptions, af as DefaultedInfiniteQueryObserverOptions, aq as FetchNextPageOptions, ar as FetchPreviousPageOptions, u as Query } from './hydration-B6nZCPcW.cjs';
|
|
2
2
|
import { Subscribable } from './subscribable.cjs';
|
|
3
3
|
import './removable.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as DefaultError, a3 as InfiniteData, B as QueryKey, c as QueryObserver, aL as InfiniteQueryObserverResult, b as QueryClient, ae as InfiniteQueryObserverOptions, af as DefaultedInfiniteQueryObserverOptions, aq as FetchNextPageOptions, ar as FetchPreviousPageOptions, u as Query } from './hydration-ZCurbX1S.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 { bd as Action, w as Mutation, v as MutationState, be as getDefaultState } from './hydration-
|
|
2
|
+
export { bd as Action, w as Mutation, v as MutationState, be as getDefaultState } from './hydration-B6nZCPcW.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './removable.js';
|
|
2
|
-
export { bd as Action, w as Mutation, v as MutationState, be as getDefaultState } from './hydration-
|
|
2
|
+
export { bd as Action, w as Mutation, v as MutationState, be as getDefaultState } from './hydration-ZCurbX1S.js';
|
|
3
3
|
import './subscribable.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aC as QueryObserverResult, b as QueryClient,
|
|
1
|
+
import { aC as QueryObserverResult, b as QueryClient, ab as QueryObserverOptions, u as Query, c as QueryObserver } from './hydration-B6nZCPcW.cjs';
|
|
2
2
|
import { Subscribable } from './subscribable.cjs';
|
|
3
3
|
import './removable.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aC as QueryObserverResult, b as QueryClient,
|
|
1
|
+
import { aC as QueryObserverResult, b as QueryClient, ab as QueryObserverOptions, u as Query, c as QueryObserver } from './hydration-ZCurbX1S.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 { ba as Action, b6 as FetchContext, b7 as FetchDirection, b8 as FetchMeta, b9 as FetchOptions, u as Query, b5 as QueryBehavior, t as QueryState, bb as SetStateOptions, bc as fetchState } from './hydration-
|
|
2
|
+
export { ba as Action, b6 as FetchContext, b7 as FetchDirection, b8 as FetchMeta, b9 as FetchOptions, u as Query, b5 as QueryBehavior, t as QueryState, bb as SetStateOptions, bc as fetchState } from './hydration-B6nZCPcW.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
package/build/legacy/query.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './removable.js';
|
|
2
|
-
export { ba as Action, b6 as FetchContext, b7 as FetchDirection, b8 as FetchMeta, b9 as FetchOptions, u as Query, b5 as QueryBehavior, t as QueryState, bb as SetStateOptions, bc as fetchState } from './hydration-
|
|
2
|
+
export { ba as Action, b6 as FetchContext, b7 as FetchDirection, b8 as FetchMeta, b9 as FetchOptions, u as Query, b5 as QueryBehavior, t as QueryState, bb as SetStateOptions, bc as fetchState } from './hydration-ZCurbX1S.js';
|
|
3
3
|
import './subscribable.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CancelledError, bz as RetryDelayValue, by as RetryValue, bx as Retryer, bA as canFetch, bB as createRetryer, l as isCancelledError } from './hydration-
|
|
1
|
+
export { C as CancelledError, bz as RetryDelayValue, by as RetryValue, bx as Retryer, bA as canFetch, bB as createRetryer, l as isCancelledError } from './hydration-B6nZCPcW.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CancelledError, bz as RetryDelayValue, by as RetryValue, bx as Retryer, bA as canFetch, bB as createRetryer, l as isCancelledError } from './hydration-
|
|
1
|
+
export { C as CancelledError, bz as RetryDelayValue, by as RetryValue, bx as Retryer, bA as canFetch, bB as createRetryer, l as isCancelledError } from './hydration-ZCurbX1S.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 {
|
|
1
|
+
import { B as QueryKey, Y as QueryFunctionContext, T as QueryFunction } from './hydration-B6nZCPcW.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 {
|
|
1
|
+
import { B as QueryKey, Y as QueryFunctionContext, T as QueryFunction } from './hydration-ZCurbX1S.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":[]}
|