@qiaopeng/tanstack-query-plus 0.5.9 → 0.5.10
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/README.md +86 -55
- package/dist/{types/base.d.ts → base-CHnwqfyz.d.cts} +12 -14
- package/dist/base-CHnwqfyz.d.ts +52 -0
- package/dist/chunk-52ZO6Y67.cjs +1121 -0
- package/dist/chunk-52ZO6Y67.cjs.map +1 -0
- package/dist/chunk-5J6OXSLW.cjs +36 -0
- package/dist/chunk-5J6OXSLW.cjs.map +1 -0
- package/dist/chunk-6MAYHLTE.cjs +310 -0
- package/dist/chunk-6MAYHLTE.cjs.map +1 -0
- package/dist/chunk-ADS2QTMP.js +144 -0
- package/dist/chunk-ADS2QTMP.js.map +1 -0
- package/dist/chunk-APXNNHBD.cjs +374 -0
- package/dist/chunk-APXNNHBD.cjs.map +1 -0
- package/dist/chunk-AXMWOGNX.js +134 -0
- package/dist/chunk-AXMWOGNX.js.map +1 -0
- package/dist/chunk-B4KO3K3E.cjs +521 -0
- package/dist/chunk-B4KO3K3E.cjs.map +1 -0
- package/dist/chunk-BK3OTIBD.cjs +15 -0
- package/dist/chunk-BK3OTIBD.cjs.map +1 -0
- package/dist/chunk-BYAOQALW.js +13 -0
- package/dist/chunk-BYAOQALW.js.map +1 -0
- package/dist/chunk-CRTVS7VI.cjs +162 -0
- package/dist/chunk-CRTVS7VI.cjs.map +1 -0
- package/dist/chunk-EXITP7QO.js +288 -0
- package/dist/chunk-EXITP7QO.js.map +1 -0
- package/dist/chunk-GMO3PRZZ.js +565 -0
- package/dist/chunk-GMO3PRZZ.js.map +1 -0
- package/dist/chunk-HRO2DWKZ.js +12 -0
- package/dist/chunk-HRO2DWKZ.js.map +1 -0
- package/dist/chunk-JHDKUQSB.js +1069 -0
- package/dist/chunk-JHDKUQSB.js.map +1 -0
- package/dist/chunk-JN2Y6RSY.js +23 -0
- package/dist/chunk-JN2Y6RSY.js.map +1 -0
- package/dist/chunk-JRJSKRZW.cjs +29 -0
- package/dist/chunk-JRJSKRZW.cjs.map +1 -0
- package/dist/chunk-KC62H4VJ.js +123 -0
- package/dist/chunk-KC62H4VJ.js.map +1 -0
- package/dist/chunk-LHEHSLD5.js +31 -0
- package/dist/chunk-LHEHSLD5.js.map +1 -0
- package/dist/chunk-N4264P7N.cjs +156 -0
- package/dist/chunk-N4264P7N.cjs.map +1 -0
- package/dist/chunk-NF5QYPYC.cjs +133 -0
- package/dist/chunk-NF5QYPYC.cjs.map +1 -0
- package/dist/chunk-OFLCHKKE.cjs +28 -0
- package/dist/chunk-OFLCHKKE.cjs.map +1 -0
- package/dist/chunk-PCNSWVA5.cjs +602 -0
- package/dist/chunk-PCNSWVA5.cjs.map +1 -0
- package/dist/chunk-STOMAA2X.js +85 -0
- package/dist/chunk-STOMAA2X.js.map +1 -0
- package/dist/chunk-UVF5S6LX.cjs +15 -0
- package/dist/chunk-UVF5S6LX.cjs.map +1 -0
- package/dist/chunk-WEIXCDCA.cjs +90 -0
- package/dist/chunk-WEIXCDCA.cjs.map +1 -0
- package/dist/chunk-X3ZTSLBQ.js +355 -0
- package/dist/chunk-X3ZTSLBQ.js.map +1 -0
- package/dist/chunk-YEV73J4J.js +504 -0
- package/dist/chunk-YEV73J4J.js.map +1 -0
- package/dist/chunk-YW5PNTRU.cjs +14 -0
- package/dist/chunk-YW5PNTRU.cjs.map +1 -0
- package/dist/chunk-ZNXSWUIS.js +12 -0
- package/dist/chunk-ZNXSWUIS.js.map +1 -0
- package/dist/chunk-ZUEMBY4W.js +21 -0
- package/dist/chunk-ZUEMBY4W.js.map +1 -0
- package/dist/components/index.cjs +60 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +43 -0
- package/dist/components/index.d.ts +43 -4
- package/dist/components/index.js +3 -4
- package/dist/components/index.js.map +1 -0
- package/dist/core/devtools.cjs +25 -0
- package/dist/core/devtools.cjs.map +1 -0
- package/dist/core/devtools.d.cts +17 -0
- package/dist/core/devtools.d.ts +9 -7
- package/dist/core/devtools.js +4 -16
- package/dist/core/devtools.js.map +1 -0
- package/dist/core/index.cjs +220 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +196 -0
- package/dist/core/index.d.ts +196 -9
- package/dist/core/index.js +7 -8
- package/dist/core/index.js.map +1 -0
- package/dist/features/index.cjs +76 -0
- package/dist/features/index.cjs.map +1 -0
- package/dist/features/index.d.cts +86 -0
- package/dist/features/index.d.ts +86 -4
- package/dist/features/index.js +7 -3
- package/dist/features/index.js.map +1 -0
- package/dist/hooks/index.cjs +209 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.cts +377 -0
- package/dist/hooks/index.d.ts +377 -10
- package/dist/hooks/index.js +8 -9
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useInViewPrefetch.cjs +33 -0
- package/dist/hooks/useInViewPrefetch.cjs.map +1 -0
- package/dist/hooks/useInViewPrefetch.d.cts +12 -0
- package/dist/hooks/useInViewPrefetch.d.ts +6 -4
- package/dist/hooks/useInViewPrefetch.js +30 -20
- package/dist/hooks/useInViewPrefetch.js.map +1 -0
- package/dist/index.cjs +811 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -8
- package/dist/index.js +89 -7
- package/dist/index.js.map +1 -0
- package/dist/{types/offline.d.ts → offline-DVPtgoAS.d.ts} +15 -13
- package/dist/offline-xxeA_-6V.d.cts +99 -0
- package/dist/persistence-MRtkmhqq.d.cts +216 -0
- package/dist/persistence-tIrEb0pR.d.ts +216 -0
- package/dist/react-query/index.cjs +52 -0
- package/dist/react-query/index.cjs.map +1 -0
- package/dist/react-query/index.d.cts +1 -0
- package/dist/react-query/index.d.ts +1 -3
- package/dist/react-query/index.js +3 -1
- package/dist/react-query/index.js.map +1 -0
- package/dist/types/index.cjs +43 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +157 -0
- package/dist/types/index.d.ts +116 -12
- package/dist/types/index.js +6 -8
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.cjs +234 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +272 -0
- package/dist/utils/index.d.ts +272 -10
- package/dist/utils/index.js +9 -9
- package/dist/utils/index.js.map +1 -0
- package/package.json +13 -3
- package/dist/PersistQueryClientProvider.d.ts +0 -22
- package/dist/PersistQueryClientProvider.d.ts.map +0 -1
- package/dist/PersistQueryClientProvider.js +0 -57
- package/dist/components/LoadingFallback.d.ts +0 -16
- package/dist/components/LoadingFallback.d.ts.map +0 -1
- package/dist/components/LoadingFallback.js +0 -27
- package/dist/components/QueryErrorBoundary.d.ts +0 -12
- package/dist/components/QueryErrorBoundary.d.ts.map +0 -1
- package/dist/components/QueryErrorBoundary.js +0 -9
- package/dist/components/SuspenseWrapper.d.ts +0 -14
- package/dist/components/SuspenseWrapper.d.ts.map +0 -1
- package/dist/components/SuspenseWrapper.js +0 -9
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/internal/ErrorBoundary.d.ts +0 -27
- package/dist/components/internal/ErrorBoundary.d.ts.map +0 -1
- package/dist/components/internal/ErrorBoundary.js +0 -37
- package/dist/core/config.d.ts +0 -80
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -327
- package/dist/core/devtools.d.ts.map +0 -1
- package/dist/core/env.d.ts +0 -4
- package/dist/core/env.d.ts.map +0 -1
- package/dist/core/env.js +0 -26
- package/dist/core/focusManager.d.ts +0 -33
- package/dist/core/focusManager.d.ts.map +0 -1
- package/dist/core/focusManager.js +0 -122
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/keys.d.ts +0 -59
- package/dist/core/keys.d.ts.map +0 -1
- package/dist/core/keys.js +0 -107
- package/dist/core/queryOptions.d.ts +0 -19
- package/dist/core/queryOptions.d.ts.map +0 -1
- package/dist/core/queryOptions.js +0 -32
- package/dist/features/index.d.ts.map +0 -1
- package/dist/features/offline.d.ts +0 -49
- package/dist/features/offline.d.ts.map +0 -1
- package/dist/features/offline.js +0 -300
- package/dist/features/persistence.d.ts +0 -36
- package/dist/features/persistence.d.ts.map +0 -1
- package/dist/features/persistence.js +0 -187
- package/dist/hooks/batchQueries.d.ts +0 -129
- package/dist/hooks/batchQueries.d.ts.map +0 -1
- package/dist/hooks/batchQueries.js +0 -301
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/useDataGuardMutation.d.ts +0 -39
- package/dist/hooks/useDataGuardMutation.d.ts.map +0 -1
- package/dist/hooks/useDataGuardMutation.js +0 -137
- package/dist/hooks/useDataGuardQuery.d.ts +0 -28
- package/dist/hooks/useDataGuardQuery.d.ts.map +0 -1
- package/dist/hooks/useDataGuardQuery.js +0 -71
- package/dist/hooks/useFocusManager.d.ts +0 -41
- package/dist/hooks/useFocusManager.d.ts.map +0 -1
- package/dist/hooks/useFocusManager.js +0 -109
- package/dist/hooks/useInViewPrefetch.d.ts.map +0 -1
- package/dist/hooks/useInfiniteQuery.d.ts +0 -33
- package/dist/hooks/useInfiniteQuery.d.ts.map +0 -1
- package/dist/hooks/useInfiniteQuery.js +0 -61
- package/dist/hooks/useMutation.d.ts +0 -25
- package/dist/hooks/useMutation.d.ts.map +0 -1
- package/dist/hooks/useMutation.js +0 -180
- package/dist/hooks/usePrefetch.d.ts +0 -54
- package/dist/hooks/usePrefetch.d.ts.map +0 -1
- package/dist/hooks/usePrefetch.js +0 -229
- package/dist/hooks/useQuery.d.ts +0 -21
- package/dist/hooks/useQuery.d.ts.map +0 -1
- package/dist/hooks/useQuery.js +0 -46
- package/dist/hooks/useSuspenseQuery.d.ts +0 -11
- package/dist/hooks/useSuspenseQuery.d.ts.map +0 -1
- package/dist/hooks/useSuspenseQuery.js +0 -19
- package/dist/index.d.ts.map +0 -1
- package/dist/react-query/index.d.ts.map +0 -1
- package/dist/types/base.d.ts.map +0 -1
- package/dist/types/base.js +0 -26
- package/dist/types/dataGuard.d.ts +0 -69
- package/dist/types/dataGuard.d.ts.map +0 -1
- package/dist/types/dataGuard.js +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/infinite.d.ts +0 -39
- package/dist/types/infinite.d.ts.map +0 -1
- package/dist/types/infinite.js +0 -1
- package/dist/types/offline.d.ts.map +0 -1
- package/dist/types/offline.js +0 -8
- package/dist/types/optimistic.d.ts +0 -126
- package/dist/types/optimistic.d.ts.map +0 -1
- package/dist/types/optimistic.js +0 -7
- package/dist/types/persistence.d.ts +0 -9
- package/dist/types/persistence.d.ts.map +0 -1
- package/dist/types/persistence.js +0 -1
- package/dist/types/selectors.d.ts +0 -11
- package/dist/types/selectors.d.ts.map +0 -1
- package/dist/types/selectors.js +0 -1
- package/dist/types/suspense.d.ts +0 -67
- package/dist/types/suspense.d.ts.map +0 -1
- package/dist/types/suspense.js +0 -1
- package/dist/utils/dataGuard.d.ts +0 -37
- package/dist/utils/dataGuard.d.ts.map +0 -1
- package/dist/utils/dataGuard.js +0 -251
- package/dist/utils/fieldMapper.d.ts +0 -9
- package/dist/utils/fieldMapper.d.ts.map +0 -1
- package/dist/utils/fieldMapper.js +0 -27
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/network.d.ts +0 -9
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js +0 -43
- package/dist/utils/optimisticUtils.d.ts +0 -45
- package/dist/utils/optimisticUtils.d.ts.map +0 -1
- package/dist/utils/optimisticUtils.js +0 -116
- package/dist/utils/placeholderData.d.ts +0 -3
- package/dist/utils/placeholderData.d.ts.map +0 -1
- package/dist/utils/placeholderData.js +0 -28
- package/dist/utils/prefetchManager.d.ts +0 -111
- package/dist/utils/prefetchManager.d.ts.map +0 -1
- package/dist/utils/prefetchManager.js +0 -246
- package/dist/utils/queryKey.d.ts +0 -26
- package/dist/utils/queryKey.d.ts.map +0 -1
- package/dist/utils/queryKey.js +0 -89
- package/dist/utils/selectors.d.ts +0 -30
- package/dist/utils/selectors.d.ts.map +0 -1
- package/dist/utils/selectors.js +0 -18
- package/dist/utils/storage.d.ts +0 -7
- package/dist/utils/storage.d.ts.map +0 -1
- package/dist/utils/storage.js +0 -84
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { S as StorageType } from './base-CHnwqfyz.js';
|
|
3
|
+
|
|
4
|
+
type Selector<TInput, TOutput> = (data: TInput | undefined) => TOutput;
|
|
5
|
+
type EntityWithId<T = string | number> = {
|
|
6
|
+
id: T;
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
type PaginatedData<T> = {
|
|
10
|
+
items: T[];
|
|
11
|
+
total?: number;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface OptimisticUpdateConfig<TData = unknown, TVariables = unknown> {
|
|
16
|
+
queryKey: QueryKey;
|
|
17
|
+
updater: (oldData: TData | undefined, variables: TVariables) => TData | undefined;
|
|
18
|
+
rollback?: (previousData: TData, error: Error) => void;
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface OptimisticContext<TData = unknown> {
|
|
22
|
+
previousData?: TData;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
operationType: OptimisticOperationTypeValue;
|
|
25
|
+
}
|
|
26
|
+
declare const OptimisticOperationType: {
|
|
27
|
+
readonly CREATE: "create";
|
|
28
|
+
readonly UPDATE: "update";
|
|
29
|
+
readonly DELETE: "delete";
|
|
30
|
+
readonly BATCH: "batch";
|
|
31
|
+
};
|
|
32
|
+
type OptimisticOperationTypeValue = (typeof OptimisticOperationType)[keyof typeof OptimisticOperationType];
|
|
33
|
+
interface ListOperationConfig<T extends EntityWithId> {
|
|
34
|
+
queryKey: QueryKey;
|
|
35
|
+
operation: ListOperationType;
|
|
36
|
+
onRollback?: (error: Error, context: OptimisticContext<T[]>) => void;
|
|
37
|
+
}
|
|
38
|
+
declare enum ListOperationType {
|
|
39
|
+
ADD = "add",
|
|
40
|
+
UPDATE = "update",
|
|
41
|
+
REMOVE = "remove"
|
|
42
|
+
}
|
|
43
|
+
interface BatchQueryResult<TData = unknown, TError = Error> {
|
|
44
|
+
data: TData | undefined;
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
isError: boolean;
|
|
47
|
+
error: TError | null;
|
|
48
|
+
status: "pending" | "error" | "success";
|
|
49
|
+
}
|
|
50
|
+
type OptimisticUpdater<TData = unknown, TVariables = unknown> = (oldData: TData | undefined, variables: TVariables) => TData;
|
|
51
|
+
type RollbackFunction<TData = unknown> = (previousData: TData, error: Error) => void;
|
|
52
|
+
type ListUpdater<T extends EntityWithId> = {
|
|
53
|
+
add: (items: T[] | undefined, newItem: T) => T[];
|
|
54
|
+
update: (items: T[] | undefined, updatedItem: Partial<T> & {
|
|
55
|
+
id: T["id"];
|
|
56
|
+
}) => T[];
|
|
57
|
+
remove: (items: T[] | undefined, itemId: T["id"]) => T[];
|
|
58
|
+
};
|
|
59
|
+
interface OptimisticGlobalConfig {
|
|
60
|
+
enabledByDefault: boolean;
|
|
61
|
+
defaultRollbackDelay: number;
|
|
62
|
+
debugMode: boolean;
|
|
63
|
+
maxRetries: number;
|
|
64
|
+
}
|
|
65
|
+
interface BatchQueryStats {
|
|
66
|
+
total: number;
|
|
67
|
+
loading: number;
|
|
68
|
+
success: number;
|
|
69
|
+
error: number;
|
|
70
|
+
stale: number;
|
|
71
|
+
successRate: number;
|
|
72
|
+
errorRate: number;
|
|
73
|
+
}
|
|
74
|
+
interface BatchQueryConfig<TData = unknown, TError = Error> {
|
|
75
|
+
enableStats?: boolean;
|
|
76
|
+
enableBatchOperations?: boolean;
|
|
77
|
+
autoRefreshInterval?: number;
|
|
78
|
+
onBatchSuccess?: (results: TData[]) => void;
|
|
79
|
+
onBatchError?: (errors: TError[]) => void;
|
|
80
|
+
onBatchSettled?: (results: TData[], errors: TError[]) => void;
|
|
81
|
+
retryConfig?: BatchRetryConfig;
|
|
82
|
+
enablePartialSuccess?: boolean;
|
|
83
|
+
onPartialSuccess?: (report: BatchOperationReport<TData, TError>) => void;
|
|
84
|
+
}
|
|
85
|
+
interface BatchRetryConfig {
|
|
86
|
+
maxRetries?: number;
|
|
87
|
+
retryDelay?: number | ((attemptIndex: number) => number);
|
|
88
|
+
retryOnlyFailed?: boolean;
|
|
89
|
+
shouldRetry?: (error: Error, attemptCount: number) => boolean;
|
|
90
|
+
}
|
|
91
|
+
interface BatchOperationReport<TData = unknown, TError = Error> {
|
|
92
|
+
total: number;
|
|
93
|
+
successful: number;
|
|
94
|
+
failed: number;
|
|
95
|
+
successResults: Array<{
|
|
96
|
+
index: number;
|
|
97
|
+
data: TData;
|
|
98
|
+
}>;
|
|
99
|
+
failureErrors: Array<{
|
|
100
|
+
index: number;
|
|
101
|
+
error: TError;
|
|
102
|
+
queryKey?: unknown[];
|
|
103
|
+
}>;
|
|
104
|
+
isPartialSuccess: boolean;
|
|
105
|
+
isFullSuccess: boolean;
|
|
106
|
+
isFullFailure: boolean;
|
|
107
|
+
duration: number;
|
|
108
|
+
retryCount?: number;
|
|
109
|
+
}
|
|
110
|
+
interface BatchErrorAggregate<TError = Error> {
|
|
111
|
+
totalErrors: number;
|
|
112
|
+
errors: Array<{
|
|
113
|
+
index: number;
|
|
114
|
+
error: TError;
|
|
115
|
+
queryKey?: unknown[];
|
|
116
|
+
}>;
|
|
117
|
+
errorsByType: Map<string, TError[]>;
|
|
118
|
+
firstError: TError | null;
|
|
119
|
+
lastError: TError | null;
|
|
120
|
+
errorSummary: string;
|
|
121
|
+
}
|
|
122
|
+
interface BatchQueryOperations {
|
|
123
|
+
refetchAll: () => Promise<PromiseSettledResult<unknown>[]>;
|
|
124
|
+
invalidateAll: () => Promise<PromiseSettledResult<void>[]>;
|
|
125
|
+
cancelAll: () => Promise<PromiseSettledResult<void>[]>;
|
|
126
|
+
resetAll: () => Promise<PromiseSettledResult<void>[]>;
|
|
127
|
+
removeAll: () => void;
|
|
128
|
+
retryFailed: () => Promise<BatchOperationReport>;
|
|
129
|
+
getErrorAggregate: () => BatchErrorAggregate;
|
|
130
|
+
getOperationReport: () => BatchOperationReport;
|
|
131
|
+
}
|
|
132
|
+
interface EnhancedBatchQueryResult<TData = unknown, TCombinedResult = TData, TError = Error> {
|
|
133
|
+
data: TCombinedResult;
|
|
134
|
+
stats: BatchQueryStats;
|
|
135
|
+
operations: BatchQueryOperations;
|
|
136
|
+
config: BatchQueryConfig<TData, TError>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 数据防护策略类型
|
|
141
|
+
*/
|
|
142
|
+
type DataGuardStrategy = "version" | "timestamp" | "hash" | "none";
|
|
143
|
+
/**
|
|
144
|
+
* 带版本控制的实体基础接口
|
|
145
|
+
*/
|
|
146
|
+
interface VersionedEntity {
|
|
147
|
+
id: string | number;
|
|
148
|
+
version?: number;
|
|
149
|
+
updatedAt?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 带版本控制的分页响应
|
|
153
|
+
*/
|
|
154
|
+
interface VersionedPaginatedResponse<T> {
|
|
155
|
+
items: T[];
|
|
156
|
+
total: number;
|
|
157
|
+
page?: number;
|
|
158
|
+
pageSize?: number;
|
|
159
|
+
version?: number;
|
|
160
|
+
updatedAt?: string;
|
|
161
|
+
_hash?: string;
|
|
162
|
+
_recentlyUpdatedIds?: Array<string | number> | Set<string | number>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 旧数据检测信息
|
|
166
|
+
*/
|
|
167
|
+
interface StaleDataInfo {
|
|
168
|
+
reason: string;
|
|
169
|
+
strategy: DataGuardStrategy;
|
|
170
|
+
queryKey: QueryKey;
|
|
171
|
+
cached: any;
|
|
172
|
+
rejected: any;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 数据防护应用信息
|
|
176
|
+
*/
|
|
177
|
+
interface DataGuardInfo {
|
|
178
|
+
strategy: DataGuardStrategy;
|
|
179
|
+
passed: boolean;
|
|
180
|
+
details: any;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 数据防护配置选项
|
|
184
|
+
*/
|
|
185
|
+
interface DataGuardOptions {
|
|
186
|
+
/** 时间戳模式下,最大接受的数据年龄(毫秒),默认 10000 */
|
|
187
|
+
maxDataAge?: number;
|
|
188
|
+
/** 启用版本号检查,默认 true */
|
|
189
|
+
enableVersionCheck?: boolean;
|
|
190
|
+
/** 启用时间戳检查,默认 true */
|
|
191
|
+
enableTimestampCheck?: boolean;
|
|
192
|
+
/** 启用哈希检查(兜底),默认 true */
|
|
193
|
+
enableHashCheck?: boolean;
|
|
194
|
+
/** 检测到旧数据时的回调 */
|
|
195
|
+
onStaleDataDetected?: (info: StaleDataInfo) => void;
|
|
196
|
+
/** 应用防护时的回调 */
|
|
197
|
+
onDataGuardApplied?: (info: DataGuardInfo) => void;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 冲突错误类
|
|
201
|
+
*/
|
|
202
|
+
declare class ConflictError extends Error {
|
|
203
|
+
details: any;
|
|
204
|
+
constructor(details: any);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
interface StorageInfo {
|
|
208
|
+
type: StorageType;
|
|
209
|
+
used: number;
|
|
210
|
+
total: number;
|
|
211
|
+
usage: number;
|
|
212
|
+
available: boolean;
|
|
213
|
+
error?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { type BatchQueryResult as B, ConflictError as C, type DataGuardStrategy as D, type EnhancedBatchQueryResult as E, type ListOperationConfig as L, type OptimisticUpdateConfig as O, type PaginatedData as P, type RollbackFunction as R, type StaleDataInfo as S, type VersionedEntity as V, type VersionedPaginatedResponse as a, type DataGuardInfo as b, type DataGuardOptions as c, type OptimisticContext as d, OptimisticOperationType as e, type OptimisticOperationTypeValue as f, ListOperationType as g, type OptimisticUpdater as h, type ListUpdater as i, type OptimisticGlobalConfig as j, type BatchQueryStats as k, type BatchQueryConfig as l, type BatchRetryConfig as m, type BatchOperationReport as n, type BatchErrorAggregate as o, type BatchQueryOperations as p, type StorageInfo as q, type Selector as r, type EntityWithId as s };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactQuery = require('@tanstack/react-query');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "QueryClient", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return reactQuery.QueryClient; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "QueryClientProvider", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return reactQuery.QueryClientProvider; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "skipToken", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return reactQuery.skipToken; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "useInfiniteQuery", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return reactQuery.useInfiniteQuery; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "useIsFetching", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return reactQuery.useIsFetching; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "useIsMutating", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return reactQuery.useIsMutating; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "useMutation", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return reactQuery.useMutation; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "useQuery", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return reactQuery.useQuery; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "useQueryClient", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return reactQuery.useQueryClient; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "useSuspenseInfiniteQuery", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return reactQuery.useSuspenseInfiniteQuery; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "useSuspenseQuery", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return reactQuery.useSuspenseQuery; }
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.cjs.map
|
|
52
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DefaultError, InfiniteData, MutationKey, QueryClient, QueryClientProvider, QueryKey, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationResult, UseQueryOptions, UseQueryResult, UseSuspenseQueryOptions, skipToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useQuery, useQueryClient, useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query';
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export { QueryClient, QueryClientProvider,
|
|
2
|
-
export type { UseQueryOptions, UseSuspenseQueryOptions, UseInfiniteQueryOptions, QueryKey, MutationKey, InfiniteData, UseQueryResult, UseInfiniteQueryResult, UseMutationResult, DefaultError } from "@tanstack/react-query";
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export { DefaultError, InfiniteData, MutationKey, QueryClient, QueryClientProvider, QueryKey, UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationResult, UseQueryOptions, UseQueryResult, UseSuspenseQueryOptions, skipToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useQuery, useQueryClient, useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query';
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { QueryClient, QueryClientProvider,
|
|
1
|
+
export { QueryClient, QueryClientProvider, skipToken, useInfiniteQuery, useIsFetching, useIsMutating, useMutation, useQuery, useQueryClient, useSuspenseInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkBK3OTIBD_cjs = require('../chunk-BK3OTIBD.cjs');
|
|
4
|
+
var chunkUVF5S6LX_cjs = require('../chunk-UVF5S6LX.cjs');
|
|
5
|
+
var chunk5J6OXSLW_cjs = require('../chunk-5J6OXSLW.cjs');
|
|
6
|
+
var chunkYW5PNTRU_cjs = require('../chunk-YW5PNTRU.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "MutationOperationType", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkBK3OTIBD_cjs.MutationOperationType; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "ListOperationType", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkUVF5S6LX_cjs.ListOperationType; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "OptimisticOperationType", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkUVF5S6LX_cjs.OptimisticOperationType; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "CachePriority", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunk5J6OXSLW_cjs.CachePriority; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "ConnectionQuality", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunk5J6OXSLW_cjs.ConnectionQuality; }
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "PersistenceStrategyType", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () { return chunk5J6OXSLW_cjs.PersistenceStrategyType; }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "StorageType", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return chunk5J6OXSLW_cjs.StorageType; }
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "ConflictError", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () { return chunkYW5PNTRU_cjs.ConflictError; }
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.cjs.map
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { QueryKey, UseSuspenseQueryOptions, UseSuspenseInfiniteQueryOptions, UseSuspenseQueryResult, UseSuspenseInfiniteQueryResult, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
export { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
export { a as CachePriority, C as ConnectionQuality, D as DeepReadonly, N as NetworkInformation, b as NetworkStatus, O as OperationResult, c as Optional, P as PersistenceStrategyType, R as Required, S as StorageType } from '../base-CHnwqfyz.cjs';
|
|
4
|
+
export { o as BatchErrorAggregate, n as BatchOperationReport, l as BatchQueryConfig, p as BatchQueryOperations, B as BatchQueryResult, k as BatchQueryStats, m as BatchRetryConfig, C as ConflictError, b as DataGuardInfo, c as DataGuardOptions, D as DataGuardStrategy, E as EnhancedBatchQueryResult, s as EntityWithId, L as ListOperationConfig, g as ListOperationType, i as ListUpdater, d as OptimisticContext, j as OptimisticGlobalConfig, e as OptimisticOperationType, f as OptimisticOperationTypeValue, O as OptimisticUpdateConfig, h as OptimisticUpdater, P as PaginatedData, R as RollbackFunction, r as Selector, S as StaleDataInfo, q as StorageInfo, V as VersionedEntity, a as VersionedPaginatedResponse } from '../persistence-MRtkmhqq.cjs';
|
|
5
|
+
export { d as MutationFunctionRegistry, M as MutationOperationType, e as OfflineManagerConfig, b as OfflineMutationOperation, h as OfflineMutationOptions, a as OfflineQueryInfo, g as OfflineQueryOptions, c as OfflineQueueConfig, O as OfflineRecoveryConfig, f as OfflineState } from '../offline-xxeA_-6V.cjs';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
export { PersistedClient, Persister } from '@tanstack/react-query-persist-client';
|
|
8
|
+
|
|
9
|
+
interface CursorPaginatedResponse<T> {
|
|
10
|
+
items: T[];
|
|
11
|
+
cursor?: string | null;
|
|
12
|
+
hasMore?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface OffsetPaginatedResponse<T> {
|
|
15
|
+
items: T[];
|
|
16
|
+
offset: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
total: number;
|
|
19
|
+
hasMore?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface PageNumberPaginatedResponse<T> {
|
|
22
|
+
items: T[];
|
|
23
|
+
page: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
totalPages: number;
|
|
26
|
+
totalItems: number;
|
|
27
|
+
}
|
|
28
|
+
interface PaginationParams {
|
|
29
|
+
cursor?: string;
|
|
30
|
+
offset?: number;
|
|
31
|
+
page?: number;
|
|
32
|
+
limit?: number;
|
|
33
|
+
pageSize?: number;
|
|
34
|
+
}
|
|
35
|
+
interface PaginationMeta {
|
|
36
|
+
currentPage?: number;
|
|
37
|
+
totalPages?: number;
|
|
38
|
+
totalItems?: number;
|
|
39
|
+
pageSize?: number;
|
|
40
|
+
hasNextPage?: boolean;
|
|
41
|
+
hasPreviousPage?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface PaginatedResponseWithMeta<T> {
|
|
44
|
+
items: T[];
|
|
45
|
+
meta: PaginationMeta;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface EnhancedSuspenseQueryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Omit<UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, "queryKey" | "queryFn"> {
|
|
49
|
+
enableAutoRefresh?: boolean;
|
|
50
|
+
refreshInterval?: number;
|
|
51
|
+
}
|
|
52
|
+
interface EnhancedSuspenseInfiniteQueryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends Omit<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, "queryKey" | "queryFn"> {
|
|
53
|
+
enableAutoRefresh?: boolean;
|
|
54
|
+
refreshInterval?: number;
|
|
55
|
+
}
|
|
56
|
+
type SuspenseQueryFunction<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey> = (context: {
|
|
57
|
+
queryKey: TQueryKey;
|
|
58
|
+
signal: AbortSignal;
|
|
59
|
+
}) => Promise<TQueryFnData>;
|
|
60
|
+
type SuspenseInfiniteQueryFunction<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = (context: {
|
|
61
|
+
queryKey: TQueryKey;
|
|
62
|
+
signal: AbortSignal;
|
|
63
|
+
pageParam: TPageParam;
|
|
64
|
+
}) => Promise<TQueryFnData>;
|
|
65
|
+
type EnhancedSuspenseQueryResult<TData = unknown, TError = Error> = UseSuspenseQueryResult<TData, TError>;
|
|
66
|
+
type EnhancedSuspenseInfiniteQueryResult<TData = unknown, TError = Error> = UseSuspenseInfiniteQueryResult<InfiniteData<TData>, TError>;
|
|
67
|
+
interface SuspenseWrapperProps {
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
fallback?: ReactNode;
|
|
70
|
+
errorFallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
|
|
71
|
+
onError?: (error: Error, errorInfo: {
|
|
72
|
+
componentStack: string;
|
|
73
|
+
}) => void;
|
|
74
|
+
resetKeys?: Array<string | number>;
|
|
75
|
+
}
|
|
76
|
+
interface ErrorBoundaryProps {
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
fallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
|
|
79
|
+
onError?: (error: Error, errorInfo: {
|
|
80
|
+
componentStack: string;
|
|
81
|
+
}) => void;
|
|
82
|
+
onReset?: () => void;
|
|
83
|
+
resetKeys?: Array<string | number>;
|
|
84
|
+
}
|
|
85
|
+
interface ErrorBoundaryState {
|
|
86
|
+
hasError: boolean;
|
|
87
|
+
error?: Error;
|
|
88
|
+
}
|
|
89
|
+
interface LoadingFallbackProps {
|
|
90
|
+
message?: string;
|
|
91
|
+
size?: "small" | "medium" | "large";
|
|
92
|
+
className?: string;
|
|
93
|
+
}
|
|
94
|
+
interface ErrorFallbackProps {
|
|
95
|
+
error: Error;
|
|
96
|
+
resetErrorBoundary: () => void;
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|
|
99
|
+
interface SuspenseConfig {
|
|
100
|
+
defaultStaleTime?: number;
|
|
101
|
+
defaultGcTime?: number;
|
|
102
|
+
defaultRetry?: number | boolean;
|
|
103
|
+
enableDevtools?: boolean;
|
|
104
|
+
}
|
|
105
|
+
type QueryStatus = "pending" | "error" | "success";
|
|
106
|
+
interface QueryMetadata {
|
|
107
|
+
queryKey: QueryKey;
|
|
108
|
+
status: QueryStatus;
|
|
109
|
+
lastUpdated?: Date;
|
|
110
|
+
errorCount?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface MutationContext<TData = unknown, TContext = unknown> {
|
|
114
|
+
/** Snapshots of all query variants (from getQueriesData) */
|
|
115
|
+
previousData?: Array<[QueryKey, any]>;
|
|
116
|
+
/** User-provided context from onMutate */
|
|
117
|
+
userContext?: TContext;
|
|
118
|
+
/** For conditional mutations */
|
|
119
|
+
conditionMet?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Enhanced mutation options using official TanStack Query approach
|
|
123
|
+
*
|
|
124
|
+
* Uses setQueriesData to update all cached query variants automatically.
|
|
125
|
+
* This prevents data rollback and flicker when switching between pageSize, filters, etc.
|
|
126
|
+
*
|
|
127
|
+
* Recommended: Use long staleTime (5+ minutes) in your queries for best results.
|
|
128
|
+
*/
|
|
129
|
+
interface MutationOptions<TData, TError, TVariables, TContext = unknown> extends UseMutationOptions<TData, TError, TVariables, TContext> {
|
|
130
|
+
optimistic?: {
|
|
131
|
+
/** Query key to update (will also update all variants in the same family) */
|
|
132
|
+
queryKey: QueryKey;
|
|
133
|
+
/** Function to update the cached data - will be applied to all query variants */
|
|
134
|
+
updater: <TQueryData = unknown>(oldData: TQueryData | undefined, variables: TVariables) => TQueryData | undefined;
|
|
135
|
+
/** Enable/disable optimistic updates */
|
|
136
|
+
enabled?: boolean;
|
|
137
|
+
/** Map mutation variable fields to cache data fields */
|
|
138
|
+
fieldMapping?: Record<string, string>;
|
|
139
|
+
/** Callback when rollback occurs on error */
|
|
140
|
+
rollback?: <TQueryData = unknown>(previousData: TQueryData, error: Error) => void;
|
|
141
|
+
/**
|
|
142
|
+
* Invalidation scope after success:
|
|
143
|
+
* - "exact": Only invalidate the exact queryKey
|
|
144
|
+
* - "family": Invalidate all queries in the family (default for list queries)
|
|
145
|
+
* - "none": Don't invalidate (rely on optimistic update only)
|
|
146
|
+
*/
|
|
147
|
+
invalidateScope?: "none" | "exact" | "family";
|
|
148
|
+
/** Override the derived family key (e.g., ['products', 'list']) */
|
|
149
|
+
familyKey?: QueryKey;
|
|
150
|
+
/** Additional query keys to invalidate */
|
|
151
|
+
relatedKeys?: QueryKey[];
|
|
152
|
+
/** Alias for relatedKeys */
|
|
153
|
+
invalidates?: QueryKey[];
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type { CursorPaginatedResponse, EnhancedSuspenseInfiniteQueryOptions, EnhancedSuspenseInfiniteQueryResult, EnhancedSuspenseQueryOptions, EnhancedSuspenseQueryResult, ErrorBoundaryProps, ErrorBoundaryState, ErrorFallbackProps, LoadingFallbackProps, MutationContext, MutationOptions, OffsetPaginatedResponse, PageNumberPaginatedResponse, PaginatedResponseWithMeta, PaginationMeta, PaginationParams, QueryMetadata, QueryStatus, SuspenseConfig, SuspenseInfiniteQueryFunction, SuspenseQueryFunction, SuspenseWrapperProps };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { QueryKey, UseSuspenseQueryOptions, UseSuspenseInfiniteQueryOptions, UseSuspenseQueryResult, UseSuspenseInfiniteQueryResult, InfiniteData, UseMutationOptions } from '@tanstack/react-query';
|
|
2
|
+
export { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
export { a as CachePriority, C as ConnectionQuality, D as DeepReadonly, N as NetworkInformation, b as NetworkStatus, O as OperationResult, c as Optional, P as PersistenceStrategyType, R as Required, S as StorageType } from '../base-CHnwqfyz.js';
|
|
4
|
+
export { o as BatchErrorAggregate, n as BatchOperationReport, l as BatchQueryConfig, p as BatchQueryOperations, B as BatchQueryResult, k as BatchQueryStats, m as BatchRetryConfig, C as ConflictError, b as DataGuardInfo, c as DataGuardOptions, D as DataGuardStrategy, E as EnhancedBatchQueryResult, s as EntityWithId, L as ListOperationConfig, g as ListOperationType, i as ListUpdater, d as OptimisticContext, j as OptimisticGlobalConfig, e as OptimisticOperationType, f as OptimisticOperationTypeValue, O as OptimisticUpdateConfig, h as OptimisticUpdater, P as PaginatedData, R as RollbackFunction, r as Selector, S as StaleDataInfo, q as StorageInfo, V as VersionedEntity, a as VersionedPaginatedResponse } from '../persistence-tIrEb0pR.js';
|
|
5
|
+
export { d as MutationFunctionRegistry, M as MutationOperationType, e as OfflineManagerConfig, b as OfflineMutationOperation, h as OfflineMutationOptions, a as OfflineQueryInfo, g as OfflineQueryOptions, c as OfflineQueueConfig, O as OfflineRecoveryConfig, f as OfflineState } from '../offline-DVPtgoAS.js';
|
|
6
|
+
import { ReactNode } from 'react';
|
|
7
|
+
export { PersistedClient, Persister } from '@tanstack/react-query-persist-client';
|
|
8
|
+
|
|
9
|
+
interface CursorPaginatedResponse<T> {
|
|
10
|
+
items: T[];
|
|
11
|
+
cursor?: string | null;
|
|
12
|
+
hasMore?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface OffsetPaginatedResponse<T> {
|
|
15
|
+
items: T[];
|
|
16
|
+
offset: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
total: number;
|
|
19
|
+
hasMore?: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface PageNumberPaginatedResponse<T> {
|
|
22
|
+
items: T[];
|
|
23
|
+
page: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
totalPages: number;
|
|
26
|
+
totalItems: number;
|
|
27
|
+
}
|
|
28
|
+
interface PaginationParams {
|
|
29
|
+
cursor?: string;
|
|
30
|
+
offset?: number;
|
|
31
|
+
page?: number;
|
|
32
|
+
limit?: number;
|
|
33
|
+
pageSize?: number;
|
|
34
|
+
}
|
|
35
|
+
interface PaginationMeta {
|
|
36
|
+
currentPage?: number;
|
|
37
|
+
totalPages?: number;
|
|
38
|
+
totalItems?: number;
|
|
39
|
+
pageSize?: number;
|
|
40
|
+
hasNextPage?: boolean;
|
|
41
|
+
hasPreviousPage?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface PaginatedResponseWithMeta<T> {
|
|
44
|
+
items: T[];
|
|
45
|
+
meta: PaginationMeta;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface EnhancedSuspenseQueryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Omit<UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, "queryKey" | "queryFn"> {
|
|
49
|
+
enableAutoRefresh?: boolean;
|
|
50
|
+
refreshInterval?: number;
|
|
51
|
+
}
|
|
52
|
+
interface EnhancedSuspenseInfiniteQueryOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends Omit<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, "queryKey" | "queryFn"> {
|
|
53
|
+
enableAutoRefresh?: boolean;
|
|
54
|
+
refreshInterval?: number;
|
|
55
|
+
}
|
|
56
|
+
type SuspenseQueryFunction<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey> = (context: {
|
|
57
|
+
queryKey: TQueryKey;
|
|
58
|
+
signal: AbortSignal;
|
|
59
|
+
}) => Promise<TQueryFnData>;
|
|
60
|
+
type SuspenseInfiniteQueryFunction<TQueryFnData = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = (context: {
|
|
61
|
+
queryKey: TQueryKey;
|
|
62
|
+
signal: AbortSignal;
|
|
63
|
+
pageParam: TPageParam;
|
|
64
|
+
}) => Promise<TQueryFnData>;
|
|
65
|
+
type EnhancedSuspenseQueryResult<TData = unknown, TError = Error> = UseSuspenseQueryResult<TData, TError>;
|
|
66
|
+
type EnhancedSuspenseInfiniteQueryResult<TData = unknown, TError = Error> = UseSuspenseInfiniteQueryResult<InfiniteData<TData>, TError>;
|
|
67
|
+
interface SuspenseWrapperProps {
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
fallback?: ReactNode;
|
|
70
|
+
errorFallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
|
|
71
|
+
onError?: (error: Error, errorInfo: {
|
|
72
|
+
componentStack: string;
|
|
73
|
+
}) => void;
|
|
74
|
+
resetKeys?: Array<string | number>;
|
|
75
|
+
}
|
|
76
|
+
interface ErrorBoundaryProps {
|
|
77
|
+
children: ReactNode;
|
|
78
|
+
fallback?: (error: Error, resetErrorBoundary: () => void) => ReactNode;
|
|
79
|
+
onError?: (error: Error, errorInfo: {
|
|
80
|
+
componentStack: string;
|
|
81
|
+
}) => void;
|
|
82
|
+
onReset?: () => void;
|
|
83
|
+
resetKeys?: Array<string | number>;
|
|
84
|
+
}
|
|
85
|
+
interface ErrorBoundaryState {
|
|
86
|
+
hasError: boolean;
|
|
87
|
+
error?: Error;
|
|
88
|
+
}
|
|
89
|
+
interface LoadingFallbackProps {
|
|
90
|
+
message?: string;
|
|
91
|
+
size?: "small" | "medium" | "large";
|
|
92
|
+
className?: string;
|
|
93
|
+
}
|
|
94
|
+
interface ErrorFallbackProps {
|
|
95
|
+
error: Error;
|
|
96
|
+
resetErrorBoundary: () => void;
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|
|
99
|
+
interface SuspenseConfig {
|
|
100
|
+
defaultStaleTime?: number;
|
|
101
|
+
defaultGcTime?: number;
|
|
102
|
+
defaultRetry?: number | boolean;
|
|
103
|
+
enableDevtools?: boolean;
|
|
104
|
+
}
|
|
105
|
+
type QueryStatus = "pending" | "error" | "success";
|
|
106
|
+
interface QueryMetadata {
|
|
107
|
+
queryKey: QueryKey;
|
|
108
|
+
status: QueryStatus;
|
|
109
|
+
lastUpdated?: Date;
|
|
110
|
+
errorCount?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface MutationContext<TData = unknown, TContext = unknown> {
|
|
11
114
|
/** Snapshots of all query variants (from getQueriesData) */
|
|
12
115
|
previousData?: Array<[QueryKey, any]>;
|
|
13
116
|
/** User-provided context from onMutate */
|
|
@@ -23,7 +126,7 @@ export interface MutationContext<TData = unknown, TContext = unknown> {
|
|
|
23
126
|
*
|
|
24
127
|
* Recommended: Use long staleTime (5+ minutes) in your queries for best results.
|
|
25
128
|
*/
|
|
26
|
-
|
|
129
|
+
interface MutationOptions<TData, TError, TVariables, TContext = unknown> extends UseMutationOptions<TData, TError, TVariables, TContext> {
|
|
27
130
|
optimistic?: {
|
|
28
131
|
/** Query key to update (will also update all variants in the same family) */
|
|
29
132
|
queryKey: QueryKey;
|
|
@@ -50,4 +153,5 @@ export interface MutationOptions<TData, TError, TVariables, TContext = unknown>
|
|
|
50
153
|
invalidates?: QueryKey[];
|
|
51
154
|
};
|
|
52
155
|
}
|
|
53
|
-
|
|
156
|
+
|
|
157
|
+
export type { CursorPaginatedResponse, EnhancedSuspenseInfiniteQueryOptions, EnhancedSuspenseInfiniteQueryResult, EnhancedSuspenseQueryOptions, EnhancedSuspenseQueryResult, ErrorBoundaryProps, ErrorBoundaryState, ErrorFallbackProps, LoadingFallbackProps, MutationContext, MutationOptions, OffsetPaginatedResponse, PageNumberPaginatedResponse, PaginatedResponseWithMeta, PaginationMeta, PaginationParams, QueryMetadata, QueryStatus, SuspenseConfig, SuspenseInfiniteQueryFunction, SuspenseQueryFunction, SuspenseWrapperProps };
|
package/dist/types/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export * from "./selectors.js";
|
|
8
|
-
export * from "./suspense.js";
|
|
1
|
+
export { MutationOperationType } from '../chunk-BYAOQALW.js';
|
|
2
|
+
export { ListOperationType, OptimisticOperationType } from '../chunk-ZNXSWUIS.js';
|
|
3
|
+
export { CachePriority, ConnectionQuality, PersistenceStrategyType, StorageType } from '../chunk-LHEHSLD5.js';
|
|
4
|
+
export { ConflictError } from '../chunk-HRO2DWKZ.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|