@codesocietyou/contentedge-cms-sdk 1.0.8 → 2.0.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/README.md +28 -8
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +961 -970
- package/dist/index.d.mts +961 -970
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -16
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
3
2
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
4
|
-
|
|
5
3
|
//#region src/types/config.d.ts
|
|
6
|
-
interface SdkConfig {
|
|
4
|
+
export interface SdkConfig {
|
|
7
5
|
baseUrl: string;
|
|
8
6
|
fileBaseUrl?: string;
|
|
9
7
|
apiKey?: string;
|
|
@@ -20,37 +18,42 @@ interface SdkConfig {
|
|
|
20
18
|
/**
|
|
21
19
|
* Create and configure the API client with the given configuration
|
|
22
20
|
*/
|
|
23
|
-
declare function createApiClient(config: SdkConfig): AxiosInstance;
|
|
21
|
+
export declare function createApiClient(config: SdkConfig): AxiosInstance;
|
|
24
22
|
/**
|
|
25
23
|
* Get the current API client instance
|
|
26
24
|
* Throws if not initialized
|
|
27
25
|
*/
|
|
28
|
-
declare function getApiClient(): AxiosInstance;
|
|
26
|
+
export declare function getApiClient(): AxiosInstance;
|
|
29
27
|
/**
|
|
30
28
|
* Reset the API client (useful for testing)
|
|
31
29
|
*/
|
|
32
|
-
declare function resetApiClient(): void;
|
|
33
|
-
declare const apiClient: AxiosInstance;
|
|
30
|
+
export declare function resetApiClient(): void;
|
|
31
|
+
export declare const apiClient: AxiosInstance;
|
|
34
32
|
//#endregion
|
|
35
33
|
//#region src/types/content.d.ts
|
|
36
|
-
type JsonPrimitive = string | number | boolean | null;
|
|
37
|
-
type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
34
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
35
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
38
36
|
[key: string]: JsonValue;
|
|
39
37
|
};
|
|
40
|
-
type CustomFields = Record<string, JsonValue>;
|
|
41
|
-
interface ContentDto<C extends CustomFields = CustomFields> {
|
|
38
|
+
export type CustomFields = Record<string, JsonValue>;
|
|
39
|
+
export interface ContentDto<C extends CustomFields = CustomFields> {
|
|
42
40
|
id: number;
|
|
43
41
|
title: string;
|
|
44
42
|
text: string;
|
|
45
43
|
type: string;
|
|
46
44
|
customFields: C;
|
|
45
|
+
/**
|
|
46
|
+
* Per-type admin display order. Lower values appear first.
|
|
47
|
+
* Not unique: concurrent creates can share a value; the CMS uses id ASC as a tie-breaker.
|
|
48
|
+
*/
|
|
49
|
+
sortOrder?: number;
|
|
47
50
|
}
|
|
48
|
-
interface ApiResponse<T> {
|
|
51
|
+
export interface ApiResponse<T> {
|
|
49
52
|
status: 'SUCCESS' | 'FAILURE';
|
|
50
53
|
message: string;
|
|
51
54
|
data: T;
|
|
52
55
|
}
|
|
53
|
-
interface PaginatedData<T> {
|
|
56
|
+
export interface PaginatedData<T> {
|
|
54
57
|
content: T[];
|
|
55
58
|
number?: number;
|
|
56
59
|
size?: number;
|
|
@@ -63,12 +66,20 @@ interface PaginatedData<T> {
|
|
|
63
66
|
sort?: unknown;
|
|
64
67
|
pageable?: unknown;
|
|
65
68
|
}
|
|
66
|
-
type ContentResponse<C extends CustomFields = CustomFields> = ApiResponse<PaginatedData<ContentDto<C>>>;
|
|
67
|
-
interface ContentListParams {
|
|
69
|
+
export type ContentResponse<C extends CustomFields = CustomFields> = ApiResponse<PaginatedData<ContentDto<C>>>;
|
|
70
|
+
export interface ContentListParams {
|
|
68
71
|
type?: string;
|
|
69
72
|
page?: number;
|
|
70
73
|
size?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Sort field forwarded to the CMS (`id` or `sortOrder`).
|
|
76
|
+
* Omit to follow the admin display order. Pass `"id"` to ignore it.
|
|
77
|
+
*/
|
|
71
78
|
sortBy?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Sort direction forwarded to the CMS.
|
|
81
|
+
* Omit with `sortBy` to use the CMS default (`ASC` when sorting by `sortOrder`).
|
|
82
|
+
*/
|
|
72
83
|
direction?: 'ASC' | 'DESC';
|
|
73
84
|
filters?: Record<string, string | number | boolean | null | undefined>;
|
|
74
85
|
}
|
|
@@ -77,7 +88,7 @@ interface ContentListParams {
|
|
|
77
88
|
* This type is exported for convenience but normalization is handled
|
|
78
89
|
* by the {@link normalizeContentItem} function in utils/normalization.
|
|
79
90
|
*/
|
|
80
|
-
interface NormalizedContentItem {
|
|
91
|
+
export interface NormalizedContentItem {
|
|
81
92
|
id: number;
|
|
82
93
|
title: string;
|
|
83
94
|
/**
|
|
@@ -111,26 +122,31 @@ interface NormalizedContentItem {
|
|
|
111
122
|
team: string | null;
|
|
112
123
|
publicationType: string | null;
|
|
113
124
|
fake: boolean | null;
|
|
125
|
+
/**
|
|
126
|
+
* Per-type admin display order. Lower values appear first.
|
|
127
|
+
* Omitted when the API did not send `sortOrder`.
|
|
128
|
+
*/
|
|
129
|
+
sortOrder?: number;
|
|
114
130
|
}
|
|
115
131
|
//#endregion
|
|
116
132
|
//#region src/services/contentApi.d.ts
|
|
117
133
|
/**
|
|
118
134
|
* Fetch content by type with pagination and filters
|
|
119
135
|
*/
|
|
120
|
-
declare function fetchContentByType<C extends CustomFields = CustomFields>(params?: ContentListParams): Promise<ContentResponse<C>>;
|
|
136
|
+
export declare function fetchContentByType<C extends CustomFields = CustomFields>(params?: ContentListParams): Promise<ContentResponse<C>>;
|
|
121
137
|
/**
|
|
122
138
|
* Fetch a single content item by ID
|
|
123
139
|
*/
|
|
124
|
-
declare function fetchContentById<C extends CustomFields = CustomFields>(id: number): Promise<ApiResponse<ContentDto<C>>>;
|
|
140
|
+
export declare function fetchContentById<C extends CustomFields = CustomFields>(id: number): Promise<ApiResponse<ContentDto<C>>>;
|
|
125
141
|
/**
|
|
126
142
|
* Download a file from a given path
|
|
127
143
|
* @param path - Full URL or relative path to the file
|
|
128
144
|
* @returns Blob containing the file data
|
|
129
145
|
*/
|
|
130
|
-
declare function downloadFile(path: string): Promise<Blob>;
|
|
146
|
+
export declare function downloadFile(path: string): Promise<Blob>;
|
|
131
147
|
//#endregion
|
|
132
148
|
//#region src/services/contentFetchAll.d.ts
|
|
133
|
-
interface FetchAllOptions<C extends CustomFields, T> {
|
|
149
|
+
export interface FetchAllOptions<C extends CustomFields, T> {
|
|
134
150
|
/**
|
|
135
151
|
* Optional function to transform each content item
|
|
136
152
|
*/
|
|
@@ -158,83 +174,87 @@ interface FetchAllOptions<C extends CustomFields, T> {
|
|
|
158
174
|
* @param options - Fetch options including mapping and deduplication
|
|
159
175
|
* @returns Array of all fetched items
|
|
160
176
|
*/
|
|
161
|
-
declare function fetchAllContent<C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, 'page'> & {
|
|
177
|
+
export declare function fetchAllContent<C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, 'page'> & {
|
|
162
178
|
page?: never;
|
|
163
179
|
}, options?: FetchAllOptions<C, T>): Promise<T[]>;
|
|
164
180
|
//#endregion
|
|
165
|
-
//#region node_modules/@tanstack/query-core/build/modern/
|
|
166
|
-
|
|
167
|
-
declare
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
silent?: boolean;
|
|
175
|
-
}
|
|
176
|
-
declare interface ContinueAction {
|
|
177
|
-
type: 'continue';
|
|
178
|
-
}
|
|
179
|
-
declare interface ContinueAction_2 {
|
|
180
|
-
type: 'continue';
|
|
181
|
-
}
|
|
182
|
-
declare type DataTag<TType, TValue, TError = UnsetMarker> = TType extends AnyDataTag ? TType : TType & {
|
|
183
|
-
[dataTagSymbol$1]: TValue;
|
|
184
|
-
[dataTagErrorSymbol$1]: TError;
|
|
185
|
-
};
|
|
186
|
-
declare const dataTagErrorSymbol$1: unique symbol;
|
|
187
|
-
declare type dataTagErrorSymbol$1 = typeof dataTagErrorSymbol$1;
|
|
188
|
-
declare const dataTagSymbol$1: unique symbol;
|
|
189
|
-
declare type dataTagSymbol$1 = typeof dataTagSymbol$1;
|
|
190
|
-
declare type DefaultedQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = WithRequired<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
|
|
191
|
-
declare type DefaultError = Register extends {
|
|
192
|
-
defaultError: infer TError;
|
|
193
|
-
} ? TError : Error;
|
|
194
|
-
declare interface DefaultOptions<TError = DefaultError> {
|
|
195
|
-
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'suspense' | 'queryKey'>;
|
|
196
|
-
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>;
|
|
197
|
-
hydrate?: HydrateOptions['defaultOptions'];
|
|
198
|
-
dehydrate?: DehydrateOptions;
|
|
199
|
-
}
|
|
200
|
-
declare type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
|
|
201
|
-
declare type DefinedQueryObserverResult<TData = unknown, TError = DefaultError> = QueryObserverRefetchErrorResult<TData, TError> | QueryObserverSuccessResult<TData, TError>;
|
|
202
|
-
declare interface DehydrateOptions {
|
|
203
|
-
serializeData?: TransformerFn;
|
|
204
|
-
shouldDehydrateMutation?: (mutation: Mutation) => boolean;
|
|
205
|
-
shouldDehydrateQuery?: (query: Query) => boolean;
|
|
206
|
-
shouldRedactErrors?: (error: unknown) => boolean;
|
|
181
|
+
//#region node_modules/@tanstack/query-core/build/modern/subscribable-CbifVTKz.d.ts
|
|
182
|
+
//#region src/subscribable.d.ts
|
|
183
|
+
declare class Subscribable<TListener extends Function> {
|
|
184
|
+
protected listeners: Set<TListener>;
|
|
185
|
+
constructor();
|
|
186
|
+
subscribe(listener: TListener): () => void;
|
|
187
|
+
hasListeners(): boolean;
|
|
188
|
+
protected onSubscribe(): void;
|
|
189
|
+
protected onUnsubscribe(): void;
|
|
207
190
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region node_modules/@tanstack/query-core/build/modern/removable-DeMjhW5M.d.ts
|
|
193
|
+
//#region src/removable.d.ts
|
|
194
|
+
declare abstract class Removable {
|
|
195
|
+
#private;
|
|
196
|
+
gcTime: number;
|
|
197
|
+
destroy(): void;
|
|
198
|
+
protected scheduleGc(): void;
|
|
199
|
+
protected updateGcTime(newGcTime: number | undefined): void;
|
|
200
|
+
protected clearGcTimeout(): void;
|
|
201
|
+
protected abstract optionalRemove(): void;
|
|
214
202
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region node_modules/@tanstack/query-core/build/modern/hydration-Bjs0MSgg.d.ts
|
|
205
|
+
//#region src/queryObserver.d.ts
|
|
206
|
+
type QueryObserverListener<TData, TError> = (result: QueryObserverResult<TData, TError>) => void;
|
|
207
|
+
interface ObserverFetchOptions extends FetchOptions {
|
|
208
|
+
throwOnError?: boolean;
|
|
218
209
|
}
|
|
219
|
-
declare
|
|
220
|
-
|
|
221
|
-
|
|
210
|
+
declare class QueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Subscribable<QueryObserverListener<TData, TError>> {
|
|
211
|
+
#private;
|
|
212
|
+
options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
|
|
213
|
+
constructor(client: QueryClient, options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>);
|
|
214
|
+
protected bindMethods(): void;
|
|
215
|
+
protected onSubscribe(): void;
|
|
216
|
+
protected onUnsubscribe(): void;
|
|
217
|
+
shouldFetchOnReconnect(): boolean;
|
|
218
|
+
shouldFetchOnWindowFocus(): boolean;
|
|
219
|
+
destroy(): void;
|
|
220
|
+
setOptions(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): void;
|
|
221
|
+
getOptimisticResult(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): QueryObserverResult<TData, TError>;
|
|
222
|
+
getCurrentResult(): QueryObserverResult<TData, TError>;
|
|
223
|
+
trackResult(result: QueryObserverResult<TData, TError>, onPropTracked?: (key: keyof QueryObserverResult) => void): QueryObserverResult<TData, TError>;
|
|
224
|
+
trackProp(key: keyof QueryObserverResult): void;
|
|
225
|
+
getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
226
|
+
refetch({ ...options }?: RefetchOptions): Promise<QueryObserverResult<TData, TError>>;
|
|
227
|
+
fetchOptimistic(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): Promise<QueryObserverResult<TData, TError>>;
|
|
228
|
+
protected fetch(fetchOptions: ObserverFetchOptions): Promise<QueryObserverResult<TData, TError>>;
|
|
229
|
+
protected createResult(query: Query<TQueryFnData, TError, TQueryData, TQueryKey>, options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): QueryObserverResult<TData, TError>;
|
|
230
|
+
updateResult(): void;
|
|
231
|
+
onQueryUpdate(): void;
|
|
222
232
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/query.d.ts
|
|
235
|
+
interface QueryConfig<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
|
|
236
|
+
client: QueryClient;
|
|
237
|
+
queryKey: TQueryKey;
|
|
238
|
+
queryHash: string;
|
|
239
|
+
options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
240
|
+
defaultOptions?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
241
|
+
state?: QueryState<TData, TError>;
|
|
227
242
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
243
|
+
interface QueryState<TData = unknown, TError = DefaultError> {
|
|
244
|
+
data: TData | undefined;
|
|
245
|
+
dataUpdateCount: number;
|
|
246
|
+
dataUpdatedAt: number;
|
|
231
247
|
error: TError | null;
|
|
248
|
+
errorUpdateCount: number;
|
|
249
|
+
errorUpdatedAt: number;
|
|
250
|
+
fetchFailureCount: number;
|
|
251
|
+
fetchFailureReason: TError | null;
|
|
252
|
+
fetchMeta: FetchMeta | null;
|
|
253
|
+
isInvalidated: boolean;
|
|
254
|
+
status: QueryStatus;
|
|
255
|
+
fetchStatus: FetchStatus;
|
|
232
256
|
}
|
|
233
|
-
|
|
234
|
-
type: 'fetch';
|
|
235
|
-
meta?: FetchMeta;
|
|
236
|
-
}
|
|
237
|
-
declare interface FetchContext<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
|
|
257
|
+
interface FetchContext<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
|
|
238
258
|
fetchFn: () => unknown | Promise<unknown>;
|
|
239
259
|
fetchOptions?: FetchOptions;
|
|
240
260
|
signal: AbortSignal;
|
|
@@ -243,216 +263,142 @@ declare interface FetchContext<TQueryFnData, TError, TData, TQueryKey extends Qu
|
|
|
243
263
|
queryKey: TQueryKey;
|
|
244
264
|
state: QueryState<TData, TError>;
|
|
245
265
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
pages: number;
|
|
252
|
-
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>;
|
|
253
|
-
};
|
|
254
|
-
declare interface FetchMeta {
|
|
266
|
+
interface QueryBehavior<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> {
|
|
267
|
+
onFetch: (context: FetchContext<TQueryFnData, TError, TData, TQueryKey>, query: Query) => void;
|
|
268
|
+
}
|
|
269
|
+
type FetchDirection = 'forward' | 'backward';
|
|
270
|
+
interface FetchMeta {
|
|
255
271
|
fetchMore?: {
|
|
256
272
|
direction: FetchDirection;
|
|
257
273
|
};
|
|
258
274
|
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time,
|
|
262
|
-
* whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
|
|
263
|
-
*
|
|
264
|
-
* If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved.
|
|
265
|
-
*
|
|
266
|
-
* Defaults to `true`.
|
|
267
|
-
*/
|
|
268
|
-
cancelRefetch?: boolean;
|
|
269
|
-
}
|
|
270
|
-
declare interface FetchOptions<TData = unknown> {
|
|
275
|
+
interface FetchOptions<TData = unknown> {
|
|
271
276
|
cancelRefetch?: boolean;
|
|
272
277
|
meta?: FetchMeta;
|
|
273
278
|
initialPromise?: Promise<TData>;
|
|
274
279
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
*
|
|
280
|
-
* If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved.
|
|
281
|
-
*
|
|
282
|
-
* Defaults to `true`.
|
|
283
|
-
*/
|
|
284
|
-
cancelRefetch?: boolean;
|
|
285
|
-
}
|
|
286
|
-
declare interface FetchQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
287
|
-
initialPageParam?: never;
|
|
288
|
-
/**
|
|
289
|
-
* The time in milliseconds after data is considered stale.
|
|
290
|
-
* If the data is fresh it will be returned from the cache.
|
|
291
|
-
*/
|
|
292
|
-
staleTime?: StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>;
|
|
293
|
-
}
|
|
294
|
-
declare type FetchStatus = 'fetching' | 'paused' | 'idle';
|
|
295
|
-
declare type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (lastPage: TQueryFnData, allPages: Array<TQueryFnData>, lastPageParam: TPageParam, allPageParams: Array<TPageParam>) => TPageParam | undefined | null;
|
|
296
|
-
declare interface HydrateOptions {
|
|
297
|
-
defaultOptions?: {
|
|
298
|
-
deserializeData?: TransformerFn;
|
|
299
|
-
queries?: QueryOptions;
|
|
300
|
-
mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>;
|
|
301
|
-
};
|
|
280
|
+
interface FailedAction$1<TError> {
|
|
281
|
+
type: 'failed';
|
|
282
|
+
failureCount: number;
|
|
283
|
+
error: TError;
|
|
302
284
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
pages: Array<TData>;
|
|
307
|
-
pageParams: Array<TPageParam>;
|
|
285
|
+
interface FetchAction {
|
|
286
|
+
type: 'fetch';
|
|
287
|
+
meta?: FetchMeta;
|
|
308
288
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* This function allows you to fetch the previous "page" of results.
|
|
316
|
-
*/
|
|
317
|
-
fetchPreviousPage: (options?: FetchPreviousPageOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
|
|
318
|
-
/**
|
|
319
|
-
* Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option).
|
|
320
|
-
*/
|
|
321
|
-
hasNextPage: boolean;
|
|
322
|
-
/**
|
|
323
|
-
* Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option).
|
|
324
|
-
*/
|
|
325
|
-
hasPreviousPage: boolean;
|
|
326
|
-
/**
|
|
327
|
-
* Will be `true` if the query failed while fetching the next page.
|
|
328
|
-
*/
|
|
329
|
-
isFetchNextPageError: boolean;
|
|
330
|
-
/**
|
|
331
|
-
* Will be `true` while fetching the next page with `fetchNextPage`.
|
|
332
|
-
*/
|
|
333
|
-
isFetchingNextPage: boolean;
|
|
334
|
-
/**
|
|
335
|
-
* Will be `true` if the query failed while fetching the previous page.
|
|
336
|
-
*/
|
|
337
|
-
isFetchPreviousPageError: boolean;
|
|
338
|
-
/**
|
|
339
|
-
* Will be `true` while fetching the previous page with `fetchPreviousPage`.
|
|
340
|
-
*/
|
|
341
|
-
isFetchingPreviousPage: boolean;
|
|
289
|
+
interface SuccessAction$1<TData> {
|
|
290
|
+
data: TData | undefined;
|
|
291
|
+
type: 'success';
|
|
292
|
+
dataUpdatedAt?: number;
|
|
293
|
+
manual?: boolean;
|
|
342
294
|
}
|
|
343
|
-
|
|
344
|
-
|
|
295
|
+
interface ErrorAction$1<TError> {
|
|
296
|
+
type: 'error';
|
|
345
297
|
error: TError;
|
|
346
|
-
isError: true;
|
|
347
|
-
isPending: false;
|
|
348
|
-
isLoading: false;
|
|
349
|
-
isLoadingError: true;
|
|
350
|
-
isRefetchError: false;
|
|
351
|
-
isFetchNextPageError: false;
|
|
352
|
-
isFetchPreviousPageError: false;
|
|
353
|
-
isSuccess: false;
|
|
354
|
-
isPlaceholderData: false;
|
|
355
|
-
status: 'error';
|
|
356
298
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
error: null;
|
|
360
|
-
isError: false;
|
|
361
|
-
isPending: true;
|
|
362
|
-
isLoading: true;
|
|
363
|
-
isLoadingError: false;
|
|
364
|
-
isRefetchError: false;
|
|
365
|
-
isFetchNextPageError: false;
|
|
366
|
-
isFetchPreviousPageError: false;
|
|
367
|
-
isSuccess: false;
|
|
368
|
-
isPlaceholderData: false;
|
|
369
|
-
status: 'pending';
|
|
299
|
+
interface InvalidateAction {
|
|
300
|
+
type: 'invalidate';
|
|
370
301
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
error: null;
|
|
374
|
-
isError: false;
|
|
375
|
-
isPending: true;
|
|
376
|
-
isLoadingError: false;
|
|
377
|
-
isRefetchError: false;
|
|
378
|
-
isFetchNextPageError: false;
|
|
379
|
-
isFetchPreviousPageError: false;
|
|
380
|
-
isSuccess: false;
|
|
381
|
-
isPlaceholderData: false;
|
|
382
|
-
status: 'pending';
|
|
302
|
+
interface PauseAction$1 {
|
|
303
|
+
type: 'pause';
|
|
383
304
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
isError: false;
|
|
387
|
-
error: null;
|
|
388
|
-
isPending: false;
|
|
389
|
-
isLoading: false;
|
|
390
|
-
isLoadingError: false;
|
|
391
|
-
isRefetchError: false;
|
|
392
|
-
isSuccess: true;
|
|
393
|
-
isPlaceholderData: true;
|
|
394
|
-
isFetchNextPageError: false;
|
|
395
|
-
isFetchPreviousPageError: false;
|
|
396
|
-
status: 'success';
|
|
305
|
+
interface ContinueAction$1 {
|
|
306
|
+
type: 'continue';
|
|
397
307
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
isError: true;
|
|
402
|
-
isPending: false;
|
|
403
|
-
isLoading: false;
|
|
404
|
-
isLoadingError: false;
|
|
405
|
-
isRefetchError: true;
|
|
406
|
-
isSuccess: false;
|
|
407
|
-
isPlaceholderData: false;
|
|
408
|
-
status: 'error';
|
|
308
|
+
interface SetStateAction<TData, TError> {
|
|
309
|
+
type: 'setState';
|
|
310
|
+
state: Partial<QueryState<TData, TError>>;
|
|
409
311
|
}
|
|
410
|
-
|
|
411
|
-
declare
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
312
|
+
type Action$1<TData, TError> = ContinueAction$1 | ErrorAction$1<TError> | FailedAction$1<TError> | FetchAction | InvalidateAction | PauseAction$1 | SetStateAction<TData, TError> | SuccessAction$1<TData>;
|
|
313
|
+
declare class Query<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Removable {
|
|
314
|
+
#private;
|
|
315
|
+
queryKey: TQueryKey;
|
|
316
|
+
queryHash: string;
|
|
317
|
+
options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
318
|
+
state: QueryState<TData, TError>;
|
|
319
|
+
observers: Array<QueryObserver<any, any, any, any, any>>;
|
|
320
|
+
constructor(config: QueryConfig<TQueryFnData, TError, TData, TQueryKey>);
|
|
321
|
+
get meta(): QueryMeta | undefined;
|
|
322
|
+
get queryType(): "infinite" | undefined;
|
|
323
|
+
get promise(): Promise<TData> | undefined;
|
|
324
|
+
setOptions(options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>): void;
|
|
325
|
+
protected optionalRemove(): void;
|
|
326
|
+
setData(newData: TData, options?: SetDataOptions & {
|
|
327
|
+
manual: boolean;
|
|
328
|
+
}): TData;
|
|
329
|
+
setState(state: Partial<QueryState<TData, TError>>): void;
|
|
330
|
+
cancel(options?: CancelOptions): Promise<void>;
|
|
331
|
+
destroy(): void;
|
|
332
|
+
get resetState(): QueryState<TData, TError>;
|
|
333
|
+
reset(): void;
|
|
334
|
+
isActive(): boolean;
|
|
335
|
+
isDisabled(): boolean;
|
|
336
|
+
isFetched(): boolean;
|
|
337
|
+
isStatic(): boolean;
|
|
338
|
+
isStale(): boolean;
|
|
339
|
+
isStaleByTime(staleTime?: StaleTime): boolean;
|
|
340
|
+
onFocus(): void;
|
|
341
|
+
onOnline(): void;
|
|
342
|
+
addObserver(observer: QueryObserver<any, any, any, any, any>): void;
|
|
343
|
+
removeObserver(observer: QueryObserver<any, any, any, any, any>): void;
|
|
344
|
+
getObserversCount(): number;
|
|
345
|
+
invalidate(): void;
|
|
346
|
+
fetch(options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, fetchOptions?: FetchOptions<TQueryFnData>): Promise<TData>;
|
|
424
347
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region src/mutationObserver.d.ts
|
|
350
|
+
type MutationObserverListener<TData, TError, TVariables, TOnMutateResult> = (result: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>) => void;
|
|
351
|
+
declare class MutationObserver<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends Subscribable<MutationObserverListener<TData, TError, TVariables, TOnMutateResult>> {
|
|
352
|
+
#private;
|
|
353
|
+
options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>;
|
|
354
|
+
constructor(client: QueryClient, options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>);
|
|
355
|
+
protected bindMethods(): void;
|
|
356
|
+
setOptions(options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>): void;
|
|
357
|
+
protected onSubscribe(): void;
|
|
358
|
+
protected onUnsubscribe(): void;
|
|
359
|
+
onMutationUpdate(action: Action<TData, TError, TVariables, TOnMutateResult>): void;
|
|
360
|
+
getCurrentResult(): MutationObserverResult<TData, TError, TVariables, TOnMutateResult>;
|
|
361
|
+
reset(): void;
|
|
362
|
+
mutate(variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>): Promise<TData>;
|
|
428
363
|
}
|
|
429
|
-
|
|
430
|
-
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/mutationCache.d.ts
|
|
366
|
+
interface MutationCacheConfig {
|
|
367
|
+
onError?: (error: DefaultError, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
368
|
+
onSuccess?: (data: unknown, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
369
|
+
onMutate?: (variables: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
370
|
+
onSettled?: (data: unknown | undefined, error: DefaultError | null, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
431
371
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
372
|
+
interface NotifyEventMutationAdded extends NotifyEvent {
|
|
373
|
+
type: 'added';
|
|
374
|
+
mutation: Mutation<any, any, any, any>;
|
|
435
375
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
onError?: (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
440
|
-
onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
376
|
+
interface NotifyEventMutationRemoved extends NotifyEvent {
|
|
377
|
+
type: 'removed';
|
|
378
|
+
mutation: Mutation<any, any, any, any>;
|
|
441
379
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
removeObserver(observer: MutationObserver_2<any, any, any, any>): void;
|
|
452
|
-
protected optionalRemove(): void;
|
|
453
|
-
continue(): Promise<unknown>;
|
|
454
|
-
execute(variables: TVariables): Promise<TData>;
|
|
380
|
+
interface NotifyEventMutationObserverAdded extends NotifyEvent {
|
|
381
|
+
type: 'observerAdded';
|
|
382
|
+
mutation: Mutation<any, any, any, any>;
|
|
383
|
+
observer: MutationObserver<any, any, any>;
|
|
384
|
+
}
|
|
385
|
+
interface NotifyEventMutationObserverRemoved extends NotifyEvent {
|
|
386
|
+
type: 'observerRemoved';
|
|
387
|
+
mutation: Mutation<any, any, any, any>;
|
|
388
|
+
observer: MutationObserver<any, any, any>;
|
|
455
389
|
}
|
|
390
|
+
interface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {
|
|
391
|
+
type: 'observerOptionsUpdated';
|
|
392
|
+
mutation?: Mutation<any, any, any, any>;
|
|
393
|
+
observer: MutationObserver<any, any, any, any>;
|
|
394
|
+
}
|
|
395
|
+
interface NotifyEventMutationUpdated extends NotifyEvent {
|
|
396
|
+
type: 'updated';
|
|
397
|
+
mutation: Mutation<any, any, any, any>;
|
|
398
|
+
action: Action<any, any, any, any>;
|
|
399
|
+
}
|
|
400
|
+
type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationObserverOptionsUpdated | NotifyEventMutationUpdated;
|
|
401
|
+
type MutationCacheListener = (event: MutationCacheNotifyEvent) => void;
|
|
456
402
|
declare class MutationCache extends Subscribable<MutationCacheListener> {
|
|
457
403
|
#private;
|
|
458
404
|
config: MutationCacheConfig;
|
|
@@ -469,321 +415,159 @@ declare class MutationCache extends Subscribable<MutationCacheListener> {
|
|
|
469
415
|
notify(event: MutationCacheNotifyEvent): void;
|
|
470
416
|
resumePausedMutations(): Promise<unknown>;
|
|
471
417
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
onMutate?: (variables: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
476
|
-
onSettled?: (data: unknown | undefined, error: DefaultError | null, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
477
|
-
}
|
|
478
|
-
declare type MutationCacheListener = (event: MutationCacheNotifyEvent) => void;
|
|
479
|
-
declare type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationObserverAdded | NotifyEventMutationObserverRemoved | NotifyEventMutationObserverOptionsUpdated | NotifyEventMutationUpdated;
|
|
480
|
-
declare interface MutationConfig<TData, TError, TVariables, TOnMutateResult> {
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/mutation.d.ts
|
|
420
|
+
interface MutationConfig<TData, TError, TVariables, TOnMutateResult> {
|
|
481
421
|
client: QueryClient;
|
|
482
422
|
mutationId: number;
|
|
483
423
|
mutationCache: MutationCache;
|
|
484
424
|
options: MutationOptions<TData, TError, TVariables, TOnMutateResult>;
|
|
485
425
|
state?: MutationState<TData, TError, TVariables, TOnMutateResult>;
|
|
486
426
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
* Include mutations matching this mutation key
|
|
498
|
-
*/
|
|
499
|
-
mutationKey?: TuplePrefixes<MutationKey>;
|
|
500
|
-
/**
|
|
501
|
-
* Filter by mutation status
|
|
502
|
-
*/
|
|
503
|
-
status?: MutationStatus;
|
|
427
|
+
interface MutationState<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> {
|
|
428
|
+
context: TOnMutateResult | undefined;
|
|
429
|
+
data: TData | undefined;
|
|
430
|
+
error: TError | null;
|
|
431
|
+
failureCount: number;
|
|
432
|
+
failureReason: TError | null;
|
|
433
|
+
isPaused: boolean;
|
|
434
|
+
status: MutationStatus;
|
|
435
|
+
variables: TVariables | undefined;
|
|
436
|
+
submittedAt: number;
|
|
504
437
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
438
|
+
interface FailedAction<TError> {
|
|
439
|
+
type: 'failed';
|
|
440
|
+
failureCount: number;
|
|
441
|
+
error: TError | null;
|
|
442
|
+
}
|
|
443
|
+
interface PendingAction<TVariables, TOnMutateResult> {
|
|
444
|
+
type: 'pending';
|
|
445
|
+
isPaused: boolean;
|
|
446
|
+
variables?: TVariables;
|
|
447
|
+
context?: TOnMutateResult;
|
|
448
|
+
}
|
|
449
|
+
interface SuccessAction<TData> {
|
|
450
|
+
type: 'success';
|
|
451
|
+
data: TData;
|
|
452
|
+
}
|
|
453
|
+
interface ErrorAction<TError> {
|
|
454
|
+
type: 'error';
|
|
455
|
+
error: TError;
|
|
456
|
+
}
|
|
457
|
+
interface PauseAction {
|
|
458
|
+
type: 'pause';
|
|
459
|
+
}
|
|
460
|
+
interface ContinueAction {
|
|
461
|
+
type: 'continue';
|
|
462
|
+
}
|
|
463
|
+
type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction | SuccessAction<TData>;
|
|
464
|
+
declare class Mutation<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> extends Removable {
|
|
518
465
|
#private;
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
466
|
+
state: MutationState<TData, TError, TVariables, TOnMutateResult>;
|
|
467
|
+
options: MutationOptions<TData, TError, TVariables, TOnMutateResult>;
|
|
468
|
+
readonly mutationId: number;
|
|
469
|
+
constructor(config: MutationConfig<TData, TError, TVariables, TOnMutateResult>);
|
|
470
|
+
setOptions(options: MutationOptions<TData, TError, TVariables, TOnMutateResult>): void;
|
|
471
|
+
get meta(): MutationMeta | undefined;
|
|
472
|
+
addObserver(observer: MutationObserver<any, any, any, any>): void;
|
|
473
|
+
removeObserver(observer: MutationObserver<any, any, any, any>): void;
|
|
474
|
+
protected optionalRemove(): void;
|
|
475
|
+
continue(): Promise<unknown>;
|
|
476
|
+
execute(variables: TVariables): Promise<TData>;
|
|
528
477
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region src/utils.d.ts
|
|
480
|
+
type DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [...infer R, unknown] ? readonly [...R] : never;
|
|
481
|
+
type TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly [] ? readonly [] : TuplePrefixes<DropLast<T>> | T;
|
|
482
|
+
interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {
|
|
534
483
|
/**
|
|
535
|
-
*
|
|
484
|
+
* Filter to active queries, inactive queries or all queries
|
|
536
485
|
*/
|
|
537
|
-
|
|
486
|
+
type?: QueryTypeFilter;
|
|
538
487
|
/**
|
|
539
|
-
*
|
|
540
|
-
* - Defaults to `null`.
|
|
488
|
+
* Match query key exactly
|
|
541
489
|
*/
|
|
542
|
-
|
|
490
|
+
exact?: boolean;
|
|
543
491
|
/**
|
|
544
|
-
*
|
|
545
|
-
* - `true` if the last mutation attempt resulted in an error.
|
|
492
|
+
* Include queries matching this predicate function
|
|
546
493
|
*/
|
|
547
|
-
|
|
494
|
+
predicate?: (query: Query) => boolean;
|
|
548
495
|
/**
|
|
549
|
-
*
|
|
550
|
-
* - `true` if the mutation is in its initial state prior to executing.
|
|
496
|
+
* Include queries matching this query key
|
|
551
497
|
*/
|
|
552
|
-
|
|
498
|
+
queryKey?: TQueryKey | TuplePrefixes<TQueryKey>;
|
|
553
499
|
/**
|
|
554
|
-
*
|
|
555
|
-
* - `true` if the mutation is currently executing.
|
|
500
|
+
* Include or exclude stale queries
|
|
556
501
|
*/
|
|
557
|
-
|
|
502
|
+
stale?: boolean;
|
|
558
503
|
/**
|
|
559
|
-
*
|
|
560
|
-
* - `true` if the last mutation attempt was successful.
|
|
504
|
+
* Include queries matching their fetchStatus
|
|
561
505
|
*/
|
|
562
|
-
|
|
506
|
+
fetchStatus?: FetchStatus;
|
|
507
|
+
}
|
|
508
|
+
interface MutationFilters<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> {
|
|
563
509
|
/**
|
|
564
|
-
*
|
|
565
|
-
* - Will be:
|
|
566
|
-
* - `idle` initial status prior to the mutation function executing.
|
|
567
|
-
* - `pending` if the mutation is currently executing.
|
|
568
|
-
* - `error` if the last mutation attempt resulted in an error.
|
|
569
|
-
* - `success` if the last mutation attempt was successful.
|
|
510
|
+
* Match mutation key exactly
|
|
570
511
|
*/
|
|
571
|
-
|
|
512
|
+
exact?: boolean;
|
|
572
513
|
/**
|
|
573
|
-
*
|
|
574
|
-
* @param variables - The variables object to pass to the `mutationFn`.
|
|
575
|
-
* @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.
|
|
576
|
-
* @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.
|
|
577
|
-
* @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.
|
|
578
|
-
* @remarks
|
|
579
|
-
* - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
|
|
580
|
-
* - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.
|
|
514
|
+
* Include mutations matching this predicate function
|
|
581
515
|
*/
|
|
582
|
-
|
|
516
|
+
predicate?: (mutation: Mutation<TData, TError, TVariables, TOnMutateResult>) => boolean;
|
|
583
517
|
/**
|
|
584
|
-
*
|
|
518
|
+
* Include mutations matching this mutation key
|
|
585
519
|
*/
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
variables: TVariables;
|
|
592
|
-
isError: true;
|
|
593
|
-
isIdle: false;
|
|
594
|
-
isPending: false;
|
|
595
|
-
isSuccess: false;
|
|
596
|
-
status: 'error';
|
|
597
|
-
}
|
|
598
|
-
declare interface MutationObserverIdleResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
599
|
-
data: undefined;
|
|
600
|
-
variables: undefined;
|
|
601
|
-
error: null;
|
|
602
|
-
isError: false;
|
|
603
|
-
isIdle: true;
|
|
604
|
-
isPending: false;
|
|
605
|
-
isSuccess: false;
|
|
606
|
-
status: 'idle';
|
|
607
|
-
}
|
|
608
|
-
declare type MutationObserverListener<TData, TError, TVariables, TOnMutateResult> = (result: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>) => void;
|
|
609
|
-
declare interface MutationObserverLoadingResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
610
|
-
data: undefined;
|
|
611
|
-
variables: TVariables;
|
|
612
|
-
error: null;
|
|
613
|
-
isError: false;
|
|
614
|
-
isIdle: false;
|
|
615
|
-
isPending: true;
|
|
616
|
-
isSuccess: false;
|
|
617
|
-
status: 'pending';
|
|
618
|
-
}
|
|
619
|
-
declare interface MutationObserverOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationOptions<TData, TError, TVariables, TOnMutateResult> {
|
|
620
|
-
throwOnError?: boolean | ((error: TError) => boolean);
|
|
621
|
-
}
|
|
622
|
-
declare type MutationObserverResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = MutationObserverIdleResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverLoadingResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverErrorResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverSuccessResult<TData, TError, TVariables, TOnMutateResult>;
|
|
623
|
-
declare interface MutationObserverSuccessResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
624
|
-
data: TData;
|
|
625
|
-
error: null;
|
|
626
|
-
variables: TVariables;
|
|
627
|
-
isError: false;
|
|
628
|
-
isIdle: false;
|
|
629
|
-
isPending: false;
|
|
630
|
-
isSuccess: true;
|
|
631
|
-
status: 'success';
|
|
632
|
-
}
|
|
633
|
-
declare interface MutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> {
|
|
634
|
-
mutationFn?: MutationFunction<TData, TVariables>;
|
|
635
|
-
mutationKey?: MutationKey;
|
|
636
|
-
onMutate?: (variables: TVariables, context: MutationFunctionContext) => Promise<TOnMutateResult> | TOnMutateResult;
|
|
637
|
-
onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
638
|
-
onError?: (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
639
|
-
onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
640
|
-
retry?: RetryValue<TError>;
|
|
641
|
-
retryDelay?: RetryDelayValue<TError>;
|
|
642
|
-
networkMode?: NetworkMode;
|
|
643
|
-
gcTime?: number;
|
|
644
|
-
_defaulted?: boolean;
|
|
645
|
-
meta?: MutationMeta;
|
|
646
|
-
scope?: MutationScope;
|
|
647
|
-
}
|
|
648
|
-
declare type MutationScope = {
|
|
649
|
-
id: string;
|
|
650
|
-
};
|
|
651
|
-
declare interface MutationState<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> {
|
|
652
|
-
context: TOnMutateResult | undefined;
|
|
653
|
-
data: TData | undefined;
|
|
654
|
-
error: TError | null;
|
|
655
|
-
failureCount: number;
|
|
656
|
-
failureReason: TError | null;
|
|
657
|
-
isPaused: boolean;
|
|
658
|
-
status: MutationStatus;
|
|
659
|
-
variables: TVariables | undefined;
|
|
660
|
-
submittedAt: number;
|
|
661
|
-
}
|
|
662
|
-
declare type MutationStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
663
|
-
declare type NetworkMode = 'online' | 'always' | 'offlineFirst';
|
|
664
|
-
declare type NoInfer_2<T> = [T][T extends any ? 0 : never];
|
|
665
|
-
declare type NonFunctionGuard<T> = T extends Function ? never : T;
|
|
666
|
-
declare interface NotifyEvent {
|
|
667
|
-
type: NotifyEventType;
|
|
668
|
-
}
|
|
669
|
-
declare interface NotifyEventMutationAdded extends NotifyEvent {
|
|
670
|
-
type: 'added';
|
|
671
|
-
mutation: Mutation<any, any, any, any>;
|
|
672
|
-
}
|
|
673
|
-
declare interface NotifyEventMutationObserverAdded extends NotifyEvent {
|
|
674
|
-
type: 'observerAdded';
|
|
675
|
-
mutation: Mutation<any, any, any, any>;
|
|
676
|
-
observer: MutationObserver_2<any, any, any>;
|
|
677
|
-
}
|
|
678
|
-
declare interface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {
|
|
679
|
-
type: 'observerOptionsUpdated';
|
|
680
|
-
mutation?: Mutation<any, any, any, any>;
|
|
681
|
-
observer: MutationObserver_2<any, any, any, any>;
|
|
682
|
-
}
|
|
683
|
-
declare interface NotifyEventMutationObserverRemoved extends NotifyEvent {
|
|
684
|
-
type: 'observerRemoved';
|
|
685
|
-
mutation: Mutation<any, any, any, any>;
|
|
686
|
-
observer: MutationObserver_2<any, any, any>;
|
|
687
|
-
}
|
|
688
|
-
declare interface NotifyEventMutationRemoved extends NotifyEvent {
|
|
689
|
-
type: 'removed';
|
|
690
|
-
mutation: Mutation<any, any, any, any>;
|
|
691
|
-
}
|
|
692
|
-
declare interface NotifyEventMutationUpdated extends NotifyEvent {
|
|
693
|
-
type: 'updated';
|
|
694
|
-
mutation: Mutation<any, any, any, any>;
|
|
695
|
-
action: Action<any, any, any, any>;
|
|
696
|
-
}
|
|
697
|
-
declare interface NotifyEventQueryAdded extends NotifyEvent {
|
|
698
|
-
type: 'added';
|
|
699
|
-
query: Query<any, any, any, any>;
|
|
700
|
-
}
|
|
701
|
-
declare interface NotifyEventQueryObserverAdded extends NotifyEvent {
|
|
702
|
-
type: 'observerAdded';
|
|
703
|
-
query: Query<any, any, any, any>;
|
|
704
|
-
observer: QueryObserver<any, any, any, any, any>;
|
|
705
|
-
}
|
|
706
|
-
declare interface NotifyEventQueryObserverOptionsUpdated extends NotifyEvent {
|
|
707
|
-
type: 'observerOptionsUpdated';
|
|
708
|
-
query: Query<any, any, any, any>;
|
|
709
|
-
observer: QueryObserver<any, any, any, any, any>;
|
|
710
|
-
}
|
|
711
|
-
declare interface NotifyEventQueryObserverRemoved extends NotifyEvent {
|
|
712
|
-
type: 'observerRemoved';
|
|
713
|
-
query: Query<any, any, any, any>;
|
|
714
|
-
observer: QueryObserver<any, any, any, any, any>;
|
|
715
|
-
}
|
|
716
|
-
declare interface NotifyEventQueryObserverResultsUpdated extends NotifyEvent {
|
|
717
|
-
type: 'observerResultsUpdated';
|
|
718
|
-
query: Query<any, any, any, any>;
|
|
719
|
-
}
|
|
720
|
-
declare interface NotifyEventQueryRemoved extends NotifyEvent {
|
|
721
|
-
type: 'removed';
|
|
722
|
-
query: Query<any, any, any, any>;
|
|
723
|
-
}
|
|
724
|
-
declare interface NotifyEventQueryUpdated extends NotifyEvent {
|
|
725
|
-
type: 'updated';
|
|
726
|
-
query: Query<any, any, any, any>;
|
|
727
|
-
action: Action_alias_1<any, any>;
|
|
728
|
-
}
|
|
729
|
-
declare type NotifyEventType = 'added' | 'removed' | 'updated' | 'observerAdded' | 'observerRemoved' | 'observerResultsUpdated' | 'observerOptionsUpdated';
|
|
730
|
-
declare type NotifyOnChangeProps = Array<keyof InfiniteQueryObserverResult> | 'all' | undefined | (() => Array<keyof InfiniteQueryObserverResult> | 'all' | undefined);
|
|
731
|
-
declare interface ObserverFetchOptions extends FetchOptions {
|
|
732
|
-
throwOnError?: boolean;
|
|
733
|
-
}
|
|
734
|
-
declare 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>;
|
|
735
|
-
declare interface PauseAction {
|
|
736
|
-
type: 'pause';
|
|
737
|
-
}
|
|
738
|
-
declare interface PauseAction_2 {
|
|
739
|
-
type: 'pause';
|
|
740
|
-
}
|
|
741
|
-
declare interface PendingAction<TVariables, TOnMutateResult> {
|
|
742
|
-
type: 'pending';
|
|
743
|
-
isPaused: boolean;
|
|
744
|
-
variables?: TVariables;
|
|
745
|
-
context?: TOnMutateResult;
|
|
746
|
-
}
|
|
747
|
-
declare type PlaceholderDataFunction<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = (previousData: TQueryData | undefined, previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => TQueryData | undefined;
|
|
748
|
-
declare class Query<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Removable {
|
|
749
|
-
#private;
|
|
750
|
-
queryKey: TQueryKey;
|
|
751
|
-
queryHash: string;
|
|
752
|
-
options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
|
|
753
|
-
state: QueryState<TData, TError>;
|
|
754
|
-
observers: Array<QueryObserver<any, any, any, any, any>>;
|
|
755
|
-
constructor(config: QueryConfig<TQueryFnData, TError, TData, TQueryKey>);
|
|
756
|
-
get meta(): QueryMeta | undefined;
|
|
757
|
-
get queryType(): "infinite" | undefined;
|
|
758
|
-
get promise(): Promise<TData> | undefined;
|
|
759
|
-
setOptions(options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>): void;
|
|
760
|
-
protected optionalRemove(): void;
|
|
761
|
-
setData(newData: TData, options?: SetDataOptions & {
|
|
762
|
-
manual: boolean;
|
|
763
|
-
}): TData;
|
|
764
|
-
setState(state: Partial<QueryState<TData, TError>>): void;
|
|
765
|
-
cancel(options?: CancelOptions): Promise<void>;
|
|
766
|
-
destroy(): void;
|
|
767
|
-
get resetState(): QueryState<TData, TError>;
|
|
768
|
-
reset(): void;
|
|
769
|
-
isActive(): boolean;
|
|
770
|
-
isDisabled(): boolean;
|
|
771
|
-
isFetched(): boolean;
|
|
772
|
-
isStatic(): boolean;
|
|
773
|
-
isStale(): boolean;
|
|
774
|
-
isStaleByTime(staleTime?: StaleTime): boolean;
|
|
775
|
-
onFocus(): void;
|
|
776
|
-
onOnline(): void;
|
|
777
|
-
addObserver(observer: QueryObserver<any, any, any, any, any>): void;
|
|
778
|
-
removeObserver(observer: QueryObserver<any, any, any, any, any>): void;
|
|
779
|
-
getObserversCount(): number;
|
|
780
|
-
invalidate(): void;
|
|
781
|
-
fetch(options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, fetchOptions?: FetchOptions<TQueryFnData>): Promise<TData>;
|
|
520
|
+
mutationKey?: TuplePrefixes<MutationKey>;
|
|
521
|
+
/**
|
|
522
|
+
* Filter by mutation status
|
|
523
|
+
*/
|
|
524
|
+
status?: MutationStatus;
|
|
782
525
|
}
|
|
783
|
-
|
|
784
|
-
|
|
526
|
+
type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);
|
|
527
|
+
type QueryTypeFilter = 'all' | 'active' | 'inactive';
|
|
528
|
+
declare const skipToken: unique symbol;
|
|
529
|
+
type SkipToken = typeof skipToken;
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region src/queryCache.d.ts
|
|
532
|
+
interface QueryCacheConfig {
|
|
533
|
+
onError?: (error: DefaultError, query: Query<unknown, unknown, unknown>) => void;
|
|
534
|
+
onSuccess?: (data: unknown, query: Query<unknown, unknown, unknown>) => void;
|
|
535
|
+
onSettled?: (data: unknown | undefined, error: DefaultError | null, query: Query<unknown, unknown, unknown>) => void;
|
|
536
|
+
}
|
|
537
|
+
interface NotifyEventQueryAdded extends NotifyEvent {
|
|
538
|
+
type: 'added';
|
|
539
|
+
query: Query<any, any, any, any>;
|
|
540
|
+
}
|
|
541
|
+
interface NotifyEventQueryRemoved extends NotifyEvent {
|
|
542
|
+
type: 'removed';
|
|
543
|
+
query: Query<any, any, any, any>;
|
|
544
|
+
}
|
|
545
|
+
interface NotifyEventQueryUpdated extends NotifyEvent {
|
|
546
|
+
type: 'updated';
|
|
547
|
+
query: Query<any, any, any, any>;
|
|
548
|
+
action: Action$1<any, any>;
|
|
549
|
+
}
|
|
550
|
+
interface NotifyEventQueryObserverAdded extends NotifyEvent {
|
|
551
|
+
type: 'observerAdded';
|
|
552
|
+
query: Query<any, any, any, any>;
|
|
553
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
554
|
+
}
|
|
555
|
+
interface NotifyEventQueryObserverRemoved extends NotifyEvent {
|
|
556
|
+
type: 'observerRemoved';
|
|
557
|
+
query: Query<any, any, any, any>;
|
|
558
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
559
|
+
}
|
|
560
|
+
interface NotifyEventQueryObserverResultsUpdated extends NotifyEvent {
|
|
561
|
+
type: 'observerResultsUpdated';
|
|
562
|
+
query: Query<any, any, any, any>;
|
|
563
|
+
}
|
|
564
|
+
interface NotifyEventQueryObserverOptionsUpdated extends NotifyEvent {
|
|
565
|
+
type: 'observerOptionsUpdated';
|
|
566
|
+
query: Query<any, any, any, any>;
|
|
567
|
+
observer: QueryObserver<any, any, any, any, any>;
|
|
785
568
|
}
|
|
786
|
-
|
|
569
|
+
type QueryCacheNotifyEvent = NotifyEventQueryAdded | NotifyEventQueryRemoved | NotifyEventQueryUpdated | NotifyEventQueryObserverAdded | NotifyEventQueryObserverRemoved | NotifyEventQueryObserverResultsUpdated | NotifyEventQueryObserverOptionsUpdated;
|
|
570
|
+
type QueryCacheListener = (event: QueryCacheNotifyEvent) => void;
|
|
787
571
|
declare class QueryCache extends Subscribable<QueryCacheListener> {
|
|
788
572
|
#private;
|
|
789
573
|
config: QueryCacheConfig;
|
|
@@ -800,13 +584,8 @@ declare class QueryCache extends Subscribable<QueryCacheListener> {
|
|
|
800
584
|
onFocus(): void;
|
|
801
585
|
onOnline(): void;
|
|
802
586
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
onSuccess?: (data: unknown, query: Query<unknown, unknown, unknown>) => void;
|
|
806
|
-
onSettled?: (data: unknown | undefined, error: DefaultError | null, query: Query<unknown, unknown, unknown>) => void;
|
|
807
|
-
}
|
|
808
|
-
declare type QueryCacheListener = (event: QueryCacheNotifyEvent) => void;
|
|
809
|
-
declare type QueryCacheNotifyEvent = NotifyEventQueryAdded | NotifyEventQueryRemoved | NotifyEventQueryUpdated | NotifyEventQueryObserverAdded | NotifyEventQueryObserverRemoved | NotifyEventQueryObserverResultsUpdated | NotifyEventQueryObserverOptionsUpdated;
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/queryClient.d.ts
|
|
810
589
|
declare class QueryClient {
|
|
811
590
|
#private;
|
|
812
591
|
constructor(config?: QueryClientConfig);
|
|
@@ -822,20 +601,40 @@ declare class QueryClient {
|
|
|
822
601
|
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
823
602
|
*/
|
|
824
603
|
getQueryData<TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined;
|
|
604
|
+
/**
|
|
605
|
+
* @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
606
|
+
*/
|
|
825
607
|
ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<TData>;
|
|
826
608
|
getQueriesData<TQueryFnData = unknown, TQueryFilters extends QueryFilters<any> = QueryFilters>(filters: TQueryFilters): Array<[QueryKey, TQueryFnData | undefined]>;
|
|
827
|
-
setQueryData<TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>>(queryKey: TTaggedQueryKey, updater: Updater<
|
|
828
|
-
setQueriesData<TQueryFnData, TQueryFilters extends QueryFilters<any> = QueryFilters>(filters: TQueryFilters, updater: Updater<
|
|
609
|
+
setQueryData<TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>>(queryKey: TTaggedQueryKey, updater: Updater<NoInfer<TInferredQueryFnData> | undefined, NoInfer<TInferredQueryFnData> | undefined>, options?: SetDataOptions): NoInfer<TInferredQueryFnData> | undefined;
|
|
610
|
+
setQueriesData<TQueryFnData, TQueryFilters extends QueryFilters<any> = QueryFilters>(filters: TQueryFilters, updater: Updater<NoInfer<TQueryFnData> | undefined, NoInfer<TQueryFnData> | undefined>, options?: SetDataOptions): Array<[QueryKey, TQueryFnData | undefined]>;
|
|
829
611
|
getQueryState<TQueryFnData = unknown, TError = DefaultError, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>, TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>>(queryKey: TTaggedQueryKey): QueryState<TInferredQueryFnData, TInferredError> | undefined;
|
|
830
612
|
removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>): void;
|
|
831
613
|
resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>, options?: ResetOptions): Promise<void>;
|
|
832
614
|
cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>, cancelOptions?: CancelOptions): Promise<void>;
|
|
833
615
|
invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: InvalidateQueryFilters<TTaggedQueryKey>, options?: InvalidateOptions): Promise<void>;
|
|
834
616
|
refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: RefetchQueryFilters<TTaggedQueryKey>, options?: RefetchOptions): Promise<void>;
|
|
617
|
+
query<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: QueryExecuteOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>): Promise<TData>;
|
|
618
|
+
/**
|
|
619
|
+
* @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
|
|
620
|
+
*/
|
|
835
621
|
fetchQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<TData>;
|
|
622
|
+
/**
|
|
623
|
+
* @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
624
|
+
*/
|
|
836
625
|
prefetchQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<void>;
|
|
626
|
+
infiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: InfiniteQueryExecuteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<Array<TData> extends Array<InfiniteData<TQueryFnData>> ? InfiniteData<TQueryFnData, TPageParam> : TData>;
|
|
627
|
+
/**
|
|
628
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
|
|
629
|
+
*/
|
|
837
630
|
fetchInfiniteQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<InfiniteData<TData, TPageParam>>;
|
|
631
|
+
/**
|
|
632
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
633
|
+
*/
|
|
838
634
|
prefetchInfiniteQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<void>;
|
|
635
|
+
/**
|
|
636
|
+
* @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
637
|
+
*/
|
|
839
638
|
ensureInfiniteQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: EnsureInfiniteQueryDataOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<InfiniteData<TData, TPageParam>>;
|
|
840
639
|
resumePausedMutations(): Promise<unknown>;
|
|
841
640
|
getQueryCache(): QueryCache;
|
|
@@ -850,102 +649,295 @@ declare class QueryClient {
|
|
|
850
649
|
defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(options?: T): T;
|
|
851
650
|
clear(): void;
|
|
852
651
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
652
|
+
type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>;
|
|
653
|
+
type ShouldRetryFunction<TError = DefaultError> = (failureCount: number, error: TError) => boolean;
|
|
654
|
+
type RetryDelayValue<TError> = number | RetryDelayFunction<TError>;
|
|
655
|
+
type RetryDelayFunction<TError = DefaultError> = (failureCount: number, error: TError) => number;
|
|
656
|
+
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>;
|
|
657
|
+
interface Register {}
|
|
658
|
+
type DefaultError = Register extends {
|
|
659
|
+
defaultError: infer TError;
|
|
660
|
+
} ? TError : Error;
|
|
661
|
+
type QueryKey = Register extends {
|
|
662
|
+
queryKey: infer TQueryKey;
|
|
663
|
+
} ? TQueryKey extends ReadonlyArray<unknown> ? TQueryKey : TQueryKey extends Array<unknown> ? TQueryKey : ReadonlyArray<unknown> : ReadonlyArray<unknown>;
|
|
664
|
+
declare const dataTagSymbol: unique symbol;
|
|
665
|
+
type dataTagSymbol = typeof dataTagSymbol;
|
|
666
|
+
declare const dataTagErrorSymbol: unique symbol;
|
|
667
|
+
type dataTagErrorSymbol = typeof dataTagErrorSymbol;
|
|
668
|
+
declare const unsetMarker: unique symbol;
|
|
669
|
+
type UnsetMarker = typeof unsetMarker;
|
|
670
|
+
type AnyDataTag = {
|
|
671
|
+
[dataTagSymbol]: any;
|
|
672
|
+
[dataTagErrorSymbol]: any;
|
|
673
|
+
};
|
|
674
|
+
type DataTag<TType, TValue, TError = UnsetMarker> = TType extends AnyDataTag ? TType : TType & {
|
|
675
|
+
[dataTagSymbol]: TValue;
|
|
676
|
+
[dataTagErrorSymbol]: TError;
|
|
677
|
+
};
|
|
678
|
+
type QueryKeyWithDataTag<TQueryKey extends QueryKey = QueryKey, TQueryFnData = unknown, TError = DefaultError> = {
|
|
679
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>;
|
|
680
|
+
};
|
|
681
|
+
type InferDataFromTag<TQueryFnData, TTaggedQueryKey extends QueryKey> = TTaggedQueryKey extends DataTag<unknown, infer TaggedValue, unknown> ? TaggedValue : TQueryFnData;
|
|
682
|
+
type InferErrorFromTag<TError, TTaggedQueryKey extends QueryKey> = TTaggedQueryKey extends DataTag<unknown, unknown, infer TaggedError> ? TaggedError extends UnsetMarker ? TError : TaggedError : TError;
|
|
683
|
+
type QueryFunction<T = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>;
|
|
684
|
+
type StaleTime = number | 'static';
|
|
685
|
+
type StaleTimeFunction<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = StaleTime | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => StaleTime);
|
|
686
|
+
type QueryBooleanOption<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = boolean | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => boolean);
|
|
687
|
+
type QueryPersister<T = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = [TPageParam] extends [never] ? (queryFn: QueryFunction<T, TQueryKey, never>, context: QueryFunctionContext<TQueryKey>, query: Query) => T | Promise<T> : (queryFn: QueryFunction<T, TQueryKey, TPageParam>, context: QueryFunctionContext<TQueryKey>, query: Query) => T | Promise<T>;
|
|
688
|
+
type QueryFunctionContext<TQueryKey extends QueryKey = QueryKey, TPageParam = never> = [TPageParam] extends [never] ? {
|
|
859
689
|
client: QueryClient;
|
|
860
690
|
queryKey: TQueryKey;
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
691
|
+
signal: AbortSignal;
|
|
692
|
+
meta: QueryMeta | undefined;
|
|
693
|
+
pageParam?: unknown;
|
|
694
|
+
/**
|
|
695
|
+
* @deprecated
|
|
696
|
+
* if you want access to the direction, you can add it to the pageParam
|
|
697
|
+
*/
|
|
698
|
+
direction?: unknown;
|
|
699
|
+
} : {
|
|
700
|
+
client: QueryClient;
|
|
701
|
+
queryKey: TQueryKey;
|
|
702
|
+
signal: AbortSignal;
|
|
703
|
+
pageParam: TPageParam;
|
|
704
|
+
/**
|
|
705
|
+
* @deprecated
|
|
706
|
+
* if you want access to the direction, you can add it to the pageParam
|
|
707
|
+
*/
|
|
708
|
+
direction: FetchDirection;
|
|
709
|
+
meta: QueryMeta | undefined;
|
|
710
|
+
};
|
|
711
|
+
type InitialDataFunction<T> = () => T | undefined;
|
|
712
|
+
type NonFunctionGuard<T> = T extends Function ? never : T;
|
|
713
|
+
type PlaceholderDataFunction<TQueryFnData = unknown, TError = DefaultError, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = (previousData: TQueryData | undefined, previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined) => TQueryData | undefined;
|
|
714
|
+
type QueryKeyHashFunction<TQueryKey extends QueryKey> = (queryKey: TQueryKey) => string;
|
|
715
|
+
type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (lastPage: TQueryFnData, allPages: Array<TQueryFnData>, lastPageParam: TPageParam, allPageParams: Array<TPageParam>) => TPageParam | undefined | null;
|
|
716
|
+
interface InfiniteData<TData, TPageParam = unknown> {
|
|
717
|
+
pages: Array<TData>;
|
|
718
|
+
pageParams: Array<TPageParam>;
|
|
865
719
|
}
|
|
866
|
-
|
|
720
|
+
type QueryMeta = Register extends {
|
|
721
|
+
queryMeta: infer TQueryMeta;
|
|
722
|
+
} ? TQueryMeta extends Record<string, unknown> ? TQueryMeta : Record<string, unknown> : Record<string, unknown>;
|
|
723
|
+
type NetworkMode = 'online' | 'always' | 'offlineFirst';
|
|
724
|
+
type NotifyOnChangeProps = Array<keyof InfiniteQueryObserverResult> | 'all' | undefined | (() => Array<keyof InfiniteQueryObserverResult> | 'all' | undefined);
|
|
725
|
+
interface QueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> {
|
|
867
726
|
/**
|
|
868
|
-
*
|
|
727
|
+
* If `false`, failed queries will not retry by default.
|
|
728
|
+
* If `true`, failed queries will retry infinitely.
|
|
729
|
+
* If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
|
|
730
|
+
* If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.
|
|
869
731
|
*/
|
|
870
|
-
|
|
732
|
+
retry?: RetryValue<TError>;
|
|
733
|
+
retryDelay?: RetryDelayValue<TError>;
|
|
734
|
+
networkMode?: NetworkMode;
|
|
871
735
|
/**
|
|
872
|
-
*
|
|
736
|
+
* The time in milliseconds that unused/inactive cache data remains in memory.
|
|
737
|
+
* When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration.
|
|
738
|
+
* When different garbage collection times are specified, the longest one will be used.
|
|
739
|
+
* Setting it to `Infinity` will disable garbage collection.
|
|
873
740
|
*/
|
|
874
|
-
|
|
741
|
+
gcTime?: number;
|
|
742
|
+
queryFn?: QueryFunction<TQueryFnData, TQueryKey, TPageParam> | SkipToken;
|
|
743
|
+
persister?: QueryPersister<TQueryFnData, NoInfer<TQueryKey>, TPageParam>;
|
|
744
|
+
queryHash?: string;
|
|
745
|
+
queryKey?: TQueryKey;
|
|
746
|
+
queryKeyHashFn?: QueryKeyHashFunction<TQueryKey>;
|
|
747
|
+
initialData?: TData | InitialDataFunction<TData>;
|
|
748
|
+
initialDataUpdatedAt?: number | (() => number | undefined);
|
|
749
|
+
behavior?: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>;
|
|
875
750
|
/**
|
|
876
|
-
*
|
|
751
|
+
* Set this to `false` to disable structural sharing between query results.
|
|
752
|
+
* Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic.
|
|
753
|
+
* Defaults to `true`.
|
|
877
754
|
*/
|
|
878
|
-
|
|
755
|
+
structuralSharing?: boolean | ((oldData: unknown | undefined, newData: unknown) => unknown);
|
|
756
|
+
_defaulted?: boolean;
|
|
757
|
+
_type?: 'infinite';
|
|
879
758
|
/**
|
|
880
|
-
*
|
|
759
|
+
* Additional payload to be stored on each query.
|
|
760
|
+
* Use this property to pass information that can be used in other places.
|
|
881
761
|
*/
|
|
882
|
-
|
|
762
|
+
meta?: QueryMeta;
|
|
883
763
|
/**
|
|
884
|
-
*
|
|
764
|
+
* Maximum number of pages to store in the data of an infinite query.
|
|
885
765
|
*/
|
|
886
|
-
|
|
766
|
+
maxPages?: number;
|
|
767
|
+
}
|
|
768
|
+
interface InitialPageParam<TPageParam = unknown> {
|
|
769
|
+
initialPageParam: TPageParam;
|
|
770
|
+
}
|
|
771
|
+
type ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey extends QueryKey> = boolean | ((error: TError, query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean);
|
|
772
|
+
interface QueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
887
773
|
/**
|
|
888
|
-
*
|
|
774
|
+
* Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys.
|
|
775
|
+
* To refetch the query, use the `refetch` method returned from the `useQuery` instance.
|
|
776
|
+
* Accepts a boolean or function that returns a boolean.
|
|
777
|
+
* Defaults to `true`.
|
|
889
778
|
*/
|
|
890
|
-
|
|
779
|
+
enabled?: QueryBooleanOption<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
780
|
+
/**
|
|
781
|
+
* The time in milliseconds after data is considered stale.
|
|
782
|
+
* If set to `Infinity`, the data will never be considered stale.
|
|
783
|
+
* If set to a function, the function will be executed with the query to compute a `staleTime`.
|
|
784
|
+
* Defaults to `0`.
|
|
785
|
+
*/
|
|
786
|
+
staleTime?: StaleTimeFunction<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
787
|
+
/**
|
|
788
|
+
* If set to a number, the query will continuously refetch at this frequency in milliseconds.
|
|
789
|
+
* If set to a function, the function will be executed with the latest data and query to compute a frequency
|
|
790
|
+
* Defaults to `false`.
|
|
791
|
+
*/
|
|
792
|
+
refetchInterval?: number | false | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => number | false | undefined);
|
|
793
|
+
/**
|
|
794
|
+
* If set to `true`, the query will continue to refetch while their tab/window is in the background.
|
|
795
|
+
* Defaults to `false`.
|
|
796
|
+
*/
|
|
797
|
+
refetchIntervalInBackground?: boolean;
|
|
798
|
+
/**
|
|
799
|
+
* If set to `true`, the query will refetch on window focus if the data is stale.
|
|
800
|
+
* If set to `false`, the query will not refetch on window focus.
|
|
801
|
+
* If set to `'always'`, the query will always refetch on window focus.
|
|
802
|
+
* If set to a function, the function will be executed with the latest data and query to compute the value.
|
|
803
|
+
* Defaults to `true`.
|
|
804
|
+
*/
|
|
805
|
+
refetchOnWindowFocus?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
|
|
806
|
+
/**
|
|
807
|
+
* If set to `true`, the query will refetch on reconnect if the data is stale.
|
|
808
|
+
* If set to `false`, the query will not refetch on reconnect.
|
|
809
|
+
* If set to `'always'`, the query will always refetch on reconnect.
|
|
810
|
+
* If set to a function, the function will be executed with the latest data and query to compute the value.
|
|
811
|
+
* Defaults to `true` unless `networkMode` is `'always'`.
|
|
812
|
+
*/
|
|
813
|
+
refetchOnReconnect?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
|
|
814
|
+
/**
|
|
815
|
+
* If set to `true`, the query will refetch on mount if the data is stale.
|
|
816
|
+
* If set to `false`, will disable additional instances of a query to trigger background refetch.
|
|
817
|
+
* If set to `'always'`, the query will always refetch on mount.
|
|
818
|
+
* If set to a function, the function will be executed with the latest data and query to compute the value
|
|
819
|
+
* Defaults to `true`.
|
|
820
|
+
*/
|
|
821
|
+
refetchOnMount?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
|
|
822
|
+
/**
|
|
823
|
+
* If set to `false`, the query will not be retried on mount if it contains an error.
|
|
824
|
+
* If set to a function, the function will be executed with the query to compute the value.
|
|
825
|
+
* Defaults to `true`.
|
|
826
|
+
*/
|
|
827
|
+
retryOnMount?: QueryBooleanOption<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
828
|
+
/**
|
|
829
|
+
* If set, the component will only re-render if any of the listed properties change.
|
|
830
|
+
* When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.
|
|
831
|
+
* When set to `'all'`, the component will re-render whenever a query is updated.
|
|
832
|
+
* When set to a function, the function will be executed to compute the list of properties.
|
|
833
|
+
* By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
|
|
834
|
+
*/
|
|
835
|
+
notifyOnChangeProps?: NotifyOnChangeProps;
|
|
836
|
+
/**
|
|
837
|
+
* Whether errors should be thrown instead of setting the `error` property.
|
|
838
|
+
* If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.
|
|
839
|
+
* If set to `false` and `suspense` is `false`, errors are returned as state.
|
|
840
|
+
* If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).
|
|
841
|
+
* Defaults to `false`.
|
|
842
|
+
*/
|
|
843
|
+
throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
844
|
+
/**
|
|
845
|
+
* This option can be used to transform or select a part of the data returned by the query function.
|
|
846
|
+
*/
|
|
847
|
+
select?: (data: TQueryData) => TData;
|
|
848
|
+
/**
|
|
849
|
+
* If set to `true`, the query will suspend when `status === 'pending'`
|
|
850
|
+
* and throw errors when `status === 'error'`.
|
|
851
|
+
* Defaults to `false`.
|
|
852
|
+
*/
|
|
853
|
+
suspense?: boolean;
|
|
854
|
+
/**
|
|
855
|
+
* If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided.
|
|
856
|
+
*/
|
|
857
|
+
placeholderData?: NonFunctionGuard<TQueryData> | PlaceholderDataFunction<NonFunctionGuard<TQueryData>, TError, NonFunctionGuard<TQueryData>, TQueryKey>;
|
|
858
|
+
_optimisticResults?: 'optimistic' | 'isRestoring';
|
|
891
859
|
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
860
|
+
type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & { [_ in TKey]: {}; };
|
|
861
|
+
type DefaultedQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = WithRequired<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
|
|
862
|
+
interface QueryExecuteOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
863
|
+
initialPageParam?: never;
|
|
864
|
+
select?: (data: TQueryData) => TData;
|
|
865
|
+
/**
|
|
866
|
+
* The time in milliseconds after data is considered stale.
|
|
867
|
+
* If the data is fresh it will be returned from the cache.
|
|
868
|
+
*/
|
|
869
|
+
staleTime?: StaleTimeFunction<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
870
|
+
}
|
|
871
|
+
/** @deprecated */
|
|
872
|
+
interface FetchQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends WithRequired<QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryKey'> {
|
|
873
|
+
initialPageParam?: never;
|
|
874
|
+
/**
|
|
875
|
+
* The time in milliseconds after data is considered stale.
|
|
876
|
+
* If the data is fresh it will be returned from the cache.
|
|
877
|
+
*/
|
|
878
|
+
staleTime?: StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>;
|
|
879
|
+
}
|
|
880
|
+
/** @deprecated */
|
|
881
|
+
interface EnsureQueryDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> {
|
|
882
|
+
revalidateIfStale?: boolean;
|
|
883
|
+
}
|
|
884
|
+
/** @deprecated */
|
|
885
|
+
type EnsureInfiniteQueryDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
886
|
+
revalidateIfStale?: boolean;
|
|
887
|
+
};
|
|
888
|
+
type InfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> = {
|
|
889
|
+
pages?: never;
|
|
890
|
+
} | {
|
|
891
|
+
pages: number;
|
|
892
|
+
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>;
|
|
893
|
+
};
|
|
894
|
+
type InfiniteQueryExecuteOptions<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Omit<QueryExecuteOptions<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey, TPageParam>, 'initialPageParam'> & InitialPageParam<TPageParam> & InfiniteQueryPages<TQueryFnData, TPageParam>;
|
|
895
|
+
/** @deprecated */
|
|
896
|
+
type FetchInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = Omit<FetchQueryOptions<TQueryFnData, TError, InfiniteData<TData, TPageParam>, TQueryKey, TPageParam>, 'initialPageParam'> & InitialPageParam<TPageParam> & InfiniteQueryPages<TQueryFnData, TPageParam>;
|
|
897
|
+
interface ResultOptions {
|
|
898
|
+
throwOnError?: boolean;
|
|
899
|
+
}
|
|
900
|
+
interface RefetchOptions extends ResultOptions {
|
|
901
|
+
/**
|
|
902
|
+
* If set to `true`, a currently running request will be cancelled before a new request is made
|
|
903
|
+
*
|
|
904
|
+
* If set to `false`, no refetch will be made if there is already a request running.
|
|
905
|
+
*
|
|
906
|
+
* Defaults to `true`.
|
|
907
|
+
*/
|
|
908
|
+
cancelRefetch?: boolean;
|
|
909
|
+
}
|
|
910
|
+
interface InvalidateQueryFilters<TQueryKey extends QueryKey = QueryKey> extends QueryFilters<TQueryKey> {
|
|
911
|
+
refetchType?: QueryTypeFilter | 'none';
|
|
912
|
+
}
|
|
913
|
+
interface RefetchQueryFilters<TQueryKey extends QueryKey = QueryKey> extends QueryFilters<TQueryKey> {}
|
|
914
|
+
interface InvalidateOptions extends RefetchOptions {}
|
|
915
|
+
interface ResetOptions extends RefetchOptions {}
|
|
916
|
+
interface FetchNextPageOptions extends ResultOptions {
|
|
899
917
|
/**
|
|
900
|
-
*
|
|
901
|
-
*
|
|
918
|
+
* If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time,
|
|
919
|
+
* whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
|
|
920
|
+
*
|
|
921
|
+
* If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved.
|
|
922
|
+
*
|
|
923
|
+
* Defaults to `true`.
|
|
902
924
|
*/
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
queryKey: TQueryKey;
|
|
907
|
-
signal: AbortSignal;
|
|
908
|
-
pageParam: TPageParam;
|
|
925
|
+
cancelRefetch?: boolean;
|
|
926
|
+
}
|
|
927
|
+
interface FetchPreviousPageOptions extends ResultOptions {
|
|
909
928
|
/**
|
|
910
|
-
*
|
|
911
|
-
*
|
|
929
|
+
* If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time,
|
|
930
|
+
* whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
|
|
931
|
+
*
|
|
932
|
+
* If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved.
|
|
933
|
+
*
|
|
934
|
+
* Defaults to `true`.
|
|
912
935
|
*/
|
|
913
|
-
|
|
914
|
-
meta: QueryMeta | undefined;
|
|
915
|
-
};
|
|
916
|
-
declare type QueryKey = Register extends {
|
|
917
|
-
queryKey: infer TQueryKey;
|
|
918
|
-
} ? TQueryKey extends ReadonlyArray<unknown> ? TQueryKey : TQueryKey extends Array<unknown> ? TQueryKey : ReadonlyArray<unknown> : ReadonlyArray<unknown>;
|
|
919
|
-
declare type QueryKeyHashFunction<TQueryKey extends QueryKey> = (queryKey: TQueryKey) => string;
|
|
920
|
-
declare type QueryMeta = Register extends {
|
|
921
|
-
queryMeta: infer TQueryMeta;
|
|
922
|
-
} ? TQueryMeta extends Record<string, unknown> ? TQueryMeta : Record<string, unknown> : Record<string, unknown>;
|
|
923
|
-
declare class QueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends Subscribable<QueryObserverListener<TData, TError>> {
|
|
924
|
-
#private;
|
|
925
|
-
options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
|
|
926
|
-
constructor(client: QueryClient, options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>);
|
|
927
|
-
protected bindMethods(): void;
|
|
928
|
-
protected onSubscribe(): void;
|
|
929
|
-
protected onUnsubscribe(): void;
|
|
930
|
-
shouldFetchOnReconnect(): boolean;
|
|
931
|
-
shouldFetchOnWindowFocus(): boolean;
|
|
932
|
-
destroy(): void;
|
|
933
|
-
setOptions(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): void;
|
|
934
|
-
getOptimisticResult(options: DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): QueryObserverResult<TData, TError>;
|
|
935
|
-
getCurrentResult(): QueryObserverResult<TData, TError>;
|
|
936
|
-
trackResult(result: QueryObserverResult<TData, TError>, onPropTracked?: (key: keyof QueryObserverResult) => void): QueryObserverResult<TData, TError>;
|
|
937
|
-
trackProp(key: keyof QueryObserverResult): void;
|
|
938
|
-
getCurrentQuery(): Query<TQueryFnData, TError, TQueryData, TQueryKey>;
|
|
939
|
-
refetch({
|
|
940
|
-
...options
|
|
941
|
-
}?: RefetchOptions): Promise<QueryObserverResult<TData, TError>>;
|
|
942
|
-
fetchOptimistic(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): Promise<QueryObserverResult<TData, TError>>;
|
|
943
|
-
protected fetch(fetchOptions: ObserverFetchOptions): Promise<QueryObserverResult<TData, TError>>;
|
|
944
|
-
protected createResult(query: Query<TQueryFnData, TError, TQueryData, TQueryKey>, options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): QueryObserverResult<TData, TError>;
|
|
945
|
-
updateResult(): void;
|
|
946
|
-
onQueryUpdate(): void;
|
|
936
|
+
cancelRefetch?: boolean;
|
|
947
937
|
}
|
|
948
|
-
|
|
938
|
+
type QueryStatus = 'pending' | 'error' | 'success';
|
|
939
|
+
type FetchStatus = 'fetching' | 'paused' | 'idle';
|
|
940
|
+
interface QueryObserverBaseResult<TData = unknown, TError = DefaultError> {
|
|
949
941
|
/**
|
|
950
942
|
* The last successfully resolved data for the query.
|
|
951
943
|
*/
|
|
@@ -1066,58 +1058,31 @@ declare interface QueryObserverBaseResult<TData = unknown, TError = DefaultError
|
|
|
1066
1058
|
* - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.
|
|
1067
1059
|
*/
|
|
1068
1060
|
fetchStatus: FetchStatus;
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
* return (
|
|
1095
|
-
* <ul>
|
|
1096
|
-
* {data.map(todo => (
|
|
1097
|
-
* <li key={todo.id}>{todo.title}</li>
|
|
1098
|
-
* ))}
|
|
1099
|
-
* </ul>
|
|
1100
|
-
* )
|
|
1101
|
-
* }
|
|
1102
|
-
*
|
|
1103
|
-
* export function App() {
|
|
1104
|
-
* const query = useQuery({ queryKey: ['todos'], queryFn: fetchTodos })
|
|
1105
|
-
*
|
|
1106
|
-
* return (
|
|
1107
|
-
* <>
|
|
1108
|
-
* <h1>Todos</h1>
|
|
1109
|
-
* <React.Suspense fallback={<div>Loading...</div>}>
|
|
1110
|
-
* <TodoList query={query} />
|
|
1111
|
-
* </React.Suspense>
|
|
1112
|
-
* </>
|
|
1113
|
-
* )
|
|
1114
|
-
* }
|
|
1115
|
-
* ```
|
|
1116
|
-
*/
|
|
1117
|
-
promise: Promise<TData>;
|
|
1118
|
-
}
|
|
1119
|
-
declare type QueryObserverListener<TData, TError> = (result: QueryObserverResult<TData, TError>) => void;
|
|
1120
|
-
declare interface QueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1061
|
+
}
|
|
1062
|
+
interface QueryObserverPendingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1063
|
+
data: undefined;
|
|
1064
|
+
error: null;
|
|
1065
|
+
isError: false;
|
|
1066
|
+
isPending: true;
|
|
1067
|
+
isLoadingError: false;
|
|
1068
|
+
isRefetchError: false;
|
|
1069
|
+
isSuccess: false;
|
|
1070
|
+
isPlaceholderData: false;
|
|
1071
|
+
status: 'pending';
|
|
1072
|
+
}
|
|
1073
|
+
interface QueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1074
|
+
data: undefined;
|
|
1075
|
+
error: null;
|
|
1076
|
+
isError: false;
|
|
1077
|
+
isPending: true;
|
|
1078
|
+
isLoading: true;
|
|
1079
|
+
isLoadingError: false;
|
|
1080
|
+
isRefetchError: false;
|
|
1081
|
+
isSuccess: false;
|
|
1082
|
+
isPlaceholderData: false;
|
|
1083
|
+
status: 'pending';
|
|
1084
|
+
}
|
|
1085
|
+
interface QueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1121
1086
|
data: undefined;
|
|
1122
1087
|
error: TError;
|
|
1123
1088
|
isError: true;
|
|
@@ -1129,329 +1094,361 @@ declare interface QueryObserverLoadingErrorResult<TData = unknown, TError = Defa
|
|
|
1129
1094
|
isPlaceholderData: false;
|
|
1130
1095
|
status: 'error';
|
|
1131
1096
|
}
|
|
1132
|
-
|
|
1133
|
-
data:
|
|
1097
|
+
interface QueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1098
|
+
data: TData;
|
|
1099
|
+
error: TError;
|
|
1100
|
+
isError: true;
|
|
1101
|
+
isPending: false;
|
|
1102
|
+
isLoading: false;
|
|
1103
|
+
isLoadingError: false;
|
|
1104
|
+
isRefetchError: true;
|
|
1105
|
+
isSuccess: false;
|
|
1106
|
+
isPlaceholderData: false;
|
|
1107
|
+
status: 'error';
|
|
1108
|
+
}
|
|
1109
|
+
interface QueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1110
|
+
data: TData;
|
|
1134
1111
|
error: null;
|
|
1135
1112
|
isError: false;
|
|
1136
|
-
isPending:
|
|
1137
|
-
isLoading:
|
|
1113
|
+
isPending: false;
|
|
1114
|
+
isLoading: false;
|
|
1138
1115
|
isLoadingError: false;
|
|
1139
1116
|
isRefetchError: false;
|
|
1140
|
-
isSuccess:
|
|
1117
|
+
isSuccess: true;
|
|
1141
1118
|
isPlaceholderData: false;
|
|
1142
|
-
status: '
|
|
1119
|
+
status: 'success';
|
|
1120
|
+
}
|
|
1121
|
+
interface QueryObserverPlaceholderResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1122
|
+
data: TData;
|
|
1123
|
+
isError: false;
|
|
1124
|
+
error: null;
|
|
1125
|
+
isPending: false;
|
|
1126
|
+
isLoading: false;
|
|
1127
|
+
isLoadingError: false;
|
|
1128
|
+
isRefetchError: false;
|
|
1129
|
+
isSuccess: true;
|
|
1130
|
+
isPlaceholderData: true;
|
|
1131
|
+
status: 'success';
|
|
1143
1132
|
}
|
|
1144
|
-
|
|
1133
|
+
type DefinedQueryObserverResult<TData = unknown, TError = DefaultError> = QueryObserverRefetchErrorResult<TData, TError> | QueryObserverSuccessResult<TData, TError>;
|
|
1134
|
+
type QueryObserverResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError> | QueryObserverLoadingErrorResult<TData, TError> | QueryObserverLoadingResult<TData, TError> | QueryObserverPendingResult<TData, TError> | QueryObserverPlaceholderResult<TData, TError>;
|
|
1135
|
+
interface InfiniteQueryObserverBaseResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1145
1136
|
/**
|
|
1146
|
-
*
|
|
1147
|
-
* To refetch the query, use the `refetch` method returned from the `useQuery` instance.
|
|
1148
|
-
* Accepts a boolean or function that returns a boolean.
|
|
1149
|
-
* Defaults to `true`.
|
|
1137
|
+
* This function allows you to fetch the next "page" of results.
|
|
1150
1138
|
*/
|
|
1151
|
-
|
|
1139
|
+
fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
|
|
1152
1140
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
* If set to `Infinity`, the data will never be considered stale.
|
|
1155
|
-
* If set to a function, the function will be executed with the query to compute a `staleTime`.
|
|
1156
|
-
* Defaults to `0`.
|
|
1141
|
+
* This function allows you to fetch the previous "page" of results.
|
|
1157
1142
|
*/
|
|
1158
|
-
|
|
1143
|
+
fetchPreviousPage: (options?: FetchPreviousPageOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
|
|
1159
1144
|
/**
|
|
1160
|
-
*
|
|
1161
|
-
* If set to a function, the function will be executed with the latest data and query to compute a frequency
|
|
1162
|
-
* Defaults to `false`.
|
|
1145
|
+
* Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option).
|
|
1163
1146
|
*/
|
|
1164
|
-
|
|
1147
|
+
hasNextPage: boolean;
|
|
1165
1148
|
/**
|
|
1166
|
-
*
|
|
1167
|
-
* Defaults to `false`.
|
|
1149
|
+
* Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option).
|
|
1168
1150
|
*/
|
|
1169
|
-
|
|
1151
|
+
hasPreviousPage: boolean;
|
|
1152
|
+
/**
|
|
1153
|
+
* Will be `true` if the query failed while fetching the next page.
|
|
1154
|
+
*/
|
|
1155
|
+
isFetchNextPageError: boolean;
|
|
1156
|
+
/**
|
|
1157
|
+
* Will be `true` while fetching the next page with `fetchNextPage`.
|
|
1158
|
+
*/
|
|
1159
|
+
isFetchingNextPage: boolean;
|
|
1160
|
+
/**
|
|
1161
|
+
* Will be `true` if the query failed while fetching the previous page.
|
|
1162
|
+
*/
|
|
1163
|
+
isFetchPreviousPageError: boolean;
|
|
1164
|
+
/**
|
|
1165
|
+
* Will be `true` while fetching the previous page with `fetchPreviousPage`.
|
|
1166
|
+
*/
|
|
1167
|
+
isFetchingPreviousPage: boolean;
|
|
1168
|
+
}
|
|
1169
|
+
interface InfiniteQueryObserverPendingResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1170
|
+
data: undefined;
|
|
1171
|
+
error: null;
|
|
1172
|
+
isError: false;
|
|
1173
|
+
isPending: true;
|
|
1174
|
+
isLoadingError: false;
|
|
1175
|
+
isRefetchError: false;
|
|
1176
|
+
isFetchNextPageError: false;
|
|
1177
|
+
isFetchPreviousPageError: false;
|
|
1178
|
+
isSuccess: false;
|
|
1179
|
+
isPlaceholderData: false;
|
|
1180
|
+
status: 'pending';
|
|
1181
|
+
}
|
|
1182
|
+
interface InfiniteQueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1183
|
+
data: undefined;
|
|
1184
|
+
error: null;
|
|
1185
|
+
isError: false;
|
|
1186
|
+
isPending: true;
|
|
1187
|
+
isLoading: true;
|
|
1188
|
+
isLoadingError: false;
|
|
1189
|
+
isRefetchError: false;
|
|
1190
|
+
isFetchNextPageError: false;
|
|
1191
|
+
isFetchPreviousPageError: false;
|
|
1192
|
+
isSuccess: false;
|
|
1193
|
+
isPlaceholderData: false;
|
|
1194
|
+
status: 'pending';
|
|
1195
|
+
}
|
|
1196
|
+
interface InfiniteQueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1197
|
+
data: undefined;
|
|
1198
|
+
error: TError;
|
|
1199
|
+
isError: true;
|
|
1200
|
+
isPending: false;
|
|
1201
|
+
isLoading: false;
|
|
1202
|
+
isLoadingError: true;
|
|
1203
|
+
isRefetchError: false;
|
|
1204
|
+
isFetchNextPageError: false;
|
|
1205
|
+
isFetchPreviousPageError: false;
|
|
1206
|
+
isSuccess: false;
|
|
1207
|
+
isPlaceholderData: false;
|
|
1208
|
+
status: 'error';
|
|
1209
|
+
}
|
|
1210
|
+
interface InfiniteQueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1211
|
+
data: TData;
|
|
1212
|
+
error: TError;
|
|
1213
|
+
isError: true;
|
|
1214
|
+
isPending: false;
|
|
1215
|
+
isLoading: false;
|
|
1216
|
+
isLoadingError: false;
|
|
1217
|
+
isRefetchError: true;
|
|
1218
|
+
isSuccess: false;
|
|
1219
|
+
isPlaceholderData: false;
|
|
1220
|
+
status: 'error';
|
|
1221
|
+
}
|
|
1222
|
+
interface InfiniteQueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1223
|
+
data: TData;
|
|
1224
|
+
error: null;
|
|
1225
|
+
isError: false;
|
|
1226
|
+
isPending: false;
|
|
1227
|
+
isLoading: false;
|
|
1228
|
+
isLoadingError: false;
|
|
1229
|
+
isRefetchError: false;
|
|
1230
|
+
isFetchNextPageError: false;
|
|
1231
|
+
isFetchPreviousPageError: false;
|
|
1232
|
+
isSuccess: true;
|
|
1233
|
+
isPlaceholderData: false;
|
|
1234
|
+
status: 'success';
|
|
1235
|
+
}
|
|
1236
|
+
interface InfiniteQueryObserverPlaceholderResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
|
|
1237
|
+
data: TData;
|
|
1238
|
+
isError: false;
|
|
1239
|
+
error: null;
|
|
1240
|
+
isPending: false;
|
|
1241
|
+
isLoading: false;
|
|
1242
|
+
isLoadingError: false;
|
|
1243
|
+
isRefetchError: false;
|
|
1244
|
+
isSuccess: true;
|
|
1245
|
+
isPlaceholderData: true;
|
|
1246
|
+
isFetchNextPageError: false;
|
|
1247
|
+
isFetchPreviousPageError: false;
|
|
1248
|
+
status: 'success';
|
|
1249
|
+
}
|
|
1250
|
+
type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
|
|
1251
|
+
type InfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = DefinedInfiniteQueryObserverResult<TData, TError> | InfiniteQueryObserverLoadingErrorResult<TData, TError> | InfiniteQueryObserverLoadingResult<TData, TError> | InfiniteQueryObserverPendingResult<TData, TError> | InfiniteQueryObserverPlaceholderResult<TData, TError>;
|
|
1252
|
+
type MutationKey = Register extends {
|
|
1253
|
+
mutationKey: infer TMutationKey;
|
|
1254
|
+
} ? TMutationKey extends ReadonlyArray<unknown> ? TMutationKey : TMutationKey extends Array<unknown> ? TMutationKey : ReadonlyArray<unknown> : ReadonlyArray<unknown>;
|
|
1255
|
+
type MutationStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
1256
|
+
type MutationScope = {
|
|
1257
|
+
id: string;
|
|
1258
|
+
};
|
|
1259
|
+
type MutationMeta = Register extends {
|
|
1260
|
+
mutationMeta: infer TMutationMeta;
|
|
1261
|
+
} ? TMutationMeta extends Record<string, unknown> ? TMutationMeta : Record<string, unknown> : Record<string, unknown>;
|
|
1262
|
+
type MutationFunctionContext = {
|
|
1263
|
+
client: QueryClient;
|
|
1264
|
+
meta: MutationMeta | undefined;
|
|
1265
|
+
mutationKey?: MutationKey;
|
|
1266
|
+
};
|
|
1267
|
+
type MutationFunction<TData = unknown, TVariables = unknown> = (variables: TVariables, context: MutationFunctionContext) => Promise<TData>;
|
|
1268
|
+
interface MutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> {
|
|
1269
|
+
mutationFn?: MutationFunction<TData, TVariables>;
|
|
1270
|
+
mutationKey?: MutationKey;
|
|
1271
|
+
onMutate?: (variables: TVariables, context: MutationFunctionContext) => Promise<TOnMutateResult> | TOnMutateResult;
|
|
1272
|
+
onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
1273
|
+
onError?: (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
1274
|
+
onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => Promise<unknown> | unknown;
|
|
1275
|
+
retry?: RetryValue<TError>;
|
|
1276
|
+
retryDelay?: RetryDelayValue<TError>;
|
|
1277
|
+
networkMode?: NetworkMode;
|
|
1278
|
+
gcTime?: number;
|
|
1279
|
+
_defaulted?: boolean;
|
|
1280
|
+
meta?: MutationMeta;
|
|
1281
|
+
scope?: MutationScope;
|
|
1282
|
+
}
|
|
1283
|
+
interface MutationObserverOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationOptions<TData, TError, TVariables, TOnMutateResult> {
|
|
1284
|
+
throwOnError?: boolean | ((error: TError) => boolean);
|
|
1285
|
+
}
|
|
1286
|
+
interface MutateOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> {
|
|
1287
|
+
onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
1288
|
+
onError?: (error: TError, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
1289
|
+
onSettled?: (data: TData | undefined, error: TError | null, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
|
|
1290
|
+
}
|
|
1291
|
+
type MutateFunctionRest<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = undefined extends TVariables ? [variables?: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>] : [variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>];
|
|
1292
|
+
type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (...rest: MutateFunctionRest<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
|
|
1293
|
+
interface MutationObserverBaseResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationState<TData, TError, TVariables, TOnMutateResult> {
|
|
1170
1294
|
/**
|
|
1171
|
-
*
|
|
1172
|
-
* If set to `false`, the query will not refetch on window focus.
|
|
1173
|
-
* If set to `'always'`, the query will always refetch on window focus.
|
|
1174
|
-
* If set to a function, the function will be executed with the latest data and query to compute the value.
|
|
1175
|
-
* Defaults to `true`.
|
|
1295
|
+
* The last successfully resolved data for the mutation.
|
|
1176
1296
|
*/
|
|
1177
|
-
|
|
1297
|
+
data: TData | undefined;
|
|
1178
1298
|
/**
|
|
1179
|
-
*
|
|
1180
|
-
* If set to `false`, the query will not refetch on reconnect.
|
|
1181
|
-
* If set to `'always'`, the query will always refetch on reconnect.
|
|
1182
|
-
* If set to a function, the function will be executed with the latest data and query to compute the value.
|
|
1183
|
-
* Defaults to the value of `networkOnline` (`true`)
|
|
1299
|
+
* The variables object passed to the `mutationFn`.
|
|
1184
1300
|
*/
|
|
1185
|
-
|
|
1301
|
+
variables: TVariables | undefined;
|
|
1186
1302
|
/**
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
* If set to `'always'`, the query will always refetch on mount.
|
|
1190
|
-
* If set to a function, the function will be executed with the latest data and query to compute the value
|
|
1191
|
-
* Defaults to `true`.
|
|
1303
|
+
* The error object for the mutation, if an error was encountered.
|
|
1304
|
+
* - Defaults to `null`.
|
|
1192
1305
|
*/
|
|
1193
|
-
|
|
1306
|
+
error: TError | null;
|
|
1194
1307
|
/**
|
|
1195
|
-
*
|
|
1196
|
-
*
|
|
1197
|
-
* Defaults to `true`.
|
|
1308
|
+
* A boolean variable derived from `status`.
|
|
1309
|
+
* - `true` if the last mutation attempt resulted in an error.
|
|
1198
1310
|
*/
|
|
1199
|
-
|
|
1311
|
+
isError: boolean;
|
|
1200
1312
|
/**
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
* When set to `'all'`, the component will re-render whenever a query is updated.
|
|
1204
|
-
* When set to a function, the function will be executed to compute the list of properties.
|
|
1205
|
-
* By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
|
|
1313
|
+
* A boolean variable derived from `status`.
|
|
1314
|
+
* - `true` if the mutation is in its initial state prior to executing.
|
|
1206
1315
|
*/
|
|
1207
|
-
|
|
1316
|
+
isIdle: boolean;
|
|
1208
1317
|
/**
|
|
1209
|
-
*
|
|
1210
|
-
*
|
|
1211
|
-
* If set to `false` and `suspense` is `false`, errors are returned as state.
|
|
1212
|
-
* If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).
|
|
1213
|
-
* Defaults to `false`.
|
|
1318
|
+
* A boolean variable derived from `status`.
|
|
1319
|
+
* - `true` if the mutation is currently executing.
|
|
1214
1320
|
*/
|
|
1215
|
-
|
|
1321
|
+
isPending: boolean;
|
|
1216
1322
|
/**
|
|
1217
|
-
*
|
|
1323
|
+
* A boolean variable derived from `status`.
|
|
1324
|
+
* - `true` if the last mutation attempt was successful.
|
|
1218
1325
|
*/
|
|
1219
|
-
|
|
1326
|
+
isSuccess: boolean;
|
|
1220
1327
|
/**
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1328
|
+
* The status of the mutation.
|
|
1329
|
+
* - Will be:
|
|
1330
|
+
* - `idle` initial status prior to the mutation function executing.
|
|
1331
|
+
* - `pending` if the mutation is currently executing.
|
|
1332
|
+
* - `error` if the last mutation attempt resulted in an error.
|
|
1333
|
+
* - `success` if the last mutation attempt was successful.
|
|
1224
1334
|
*/
|
|
1225
|
-
|
|
1335
|
+
status: MutationStatus;
|
|
1226
1336
|
/**
|
|
1227
|
-
*
|
|
1337
|
+
* The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
|
|
1338
|
+
* @param variables - The variables object to pass to the `mutationFn`.
|
|
1339
|
+
* @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.
|
|
1340
|
+
* @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.
|
|
1341
|
+
* @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.
|
|
1342
|
+
* @remarks
|
|
1343
|
+
* - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
|
|
1344
|
+
* - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.
|
|
1228
1345
|
*/
|
|
1229
|
-
|
|
1230
|
-
_optimisticResults?: 'optimistic' | 'isRestoring';
|
|
1346
|
+
mutate: MutateFunction<TData, TError, TVariables, TOnMutateResult>;
|
|
1231
1347
|
/**
|
|
1232
|
-
*
|
|
1348
|
+
* A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).
|
|
1233
1349
|
*/
|
|
1234
|
-
|
|
1350
|
+
reset: () => void;
|
|
1235
1351
|
}
|
|
1236
|
-
|
|
1352
|
+
interface MutationObserverIdleResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1237
1353
|
data: undefined;
|
|
1354
|
+
variables: undefined;
|
|
1238
1355
|
error: null;
|
|
1239
1356
|
isError: false;
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
isRefetchError: false;
|
|
1357
|
+
isIdle: true;
|
|
1358
|
+
isPending: false;
|
|
1243
1359
|
isSuccess: false;
|
|
1244
|
-
|
|
1245
|
-
status: 'pending';
|
|
1360
|
+
status: 'idle';
|
|
1246
1361
|
}
|
|
1247
|
-
|
|
1248
|
-
data:
|
|
1249
|
-
|
|
1362
|
+
interface MutationObserverLoadingResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1363
|
+
data: undefined;
|
|
1364
|
+
variables: TVariables;
|
|
1250
1365
|
error: null;
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
isPlaceholderData: true;
|
|
1257
|
-
status: 'success';
|
|
1366
|
+
isError: false;
|
|
1367
|
+
isIdle: false;
|
|
1368
|
+
isPending: true;
|
|
1369
|
+
isSuccess: false;
|
|
1370
|
+
status: 'pending';
|
|
1258
1371
|
}
|
|
1259
|
-
|
|
1260
|
-
data:
|
|
1372
|
+
interface MutationObserverErrorResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1373
|
+
data: undefined;
|
|
1261
1374
|
error: TError;
|
|
1375
|
+
variables: TVariables;
|
|
1262
1376
|
isError: true;
|
|
1377
|
+
isIdle: false;
|
|
1263
1378
|
isPending: false;
|
|
1264
|
-
isLoading: false;
|
|
1265
|
-
isLoadingError: false;
|
|
1266
|
-
isRefetchError: true;
|
|
1267
1379
|
isSuccess: false;
|
|
1268
|
-
isPlaceholderData: false;
|
|
1269
1380
|
status: 'error';
|
|
1270
1381
|
}
|
|
1271
|
-
|
|
1272
|
-
declare interface QueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
1382
|
+
interface MutationObserverSuccessResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
|
|
1273
1383
|
data: TData;
|
|
1274
1384
|
error: null;
|
|
1385
|
+
variables: TVariables;
|
|
1275
1386
|
isError: false;
|
|
1387
|
+
isIdle: false;
|
|
1276
1388
|
isPending: false;
|
|
1277
|
-
isLoading: false;
|
|
1278
|
-
isLoadingError: false;
|
|
1279
|
-
isRefetchError: false;
|
|
1280
1389
|
isSuccess: true;
|
|
1281
|
-
isPlaceholderData: false;
|
|
1282
1390
|
status: 'success';
|
|
1283
1391
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
* If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.
|
|
1290
|
-
*/
|
|
1291
|
-
retry?: RetryValue<TError>;
|
|
1292
|
-
retryDelay?: RetryDelayValue<TError>;
|
|
1293
|
-
networkMode?: NetworkMode;
|
|
1294
|
-
/**
|
|
1295
|
-
* The time in milliseconds that unused/inactive cache data remains in memory.
|
|
1296
|
-
* When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration.
|
|
1297
|
-
* When different garbage collection times are specified, the longest one will be used.
|
|
1298
|
-
* Setting it to `Infinity` will disable garbage collection.
|
|
1299
|
-
*/
|
|
1300
|
-
gcTime?: number;
|
|
1301
|
-
queryFn?: QueryFunction<TQueryFnData, TQueryKey, TPageParam> | SkipToken;
|
|
1302
|
-
persister?: QueryPersister<TQueryFnData, TQueryKey, TPageParam>;
|
|
1303
|
-
queryHash?: string;
|
|
1304
|
-
queryKey?: TQueryKey;
|
|
1305
|
-
queryKeyHashFn?: QueryKeyHashFunction<TQueryKey>;
|
|
1306
|
-
initialData?: TData | InitialDataFunction<TData>;
|
|
1307
|
-
initialDataUpdatedAt?: number | (() => number | undefined);
|
|
1308
|
-
behavior?: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>;
|
|
1309
|
-
/**
|
|
1310
|
-
* Set this to `false` to disable structural sharing between query results.
|
|
1311
|
-
* Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic.
|
|
1312
|
-
* Defaults to `true`.
|
|
1313
|
-
*/
|
|
1314
|
-
structuralSharing?: boolean | ((oldData: unknown | undefined, newData: unknown) => unknown);
|
|
1315
|
-
_defaulted?: boolean;
|
|
1316
|
-
_type?: 'infinite';
|
|
1317
|
-
/**
|
|
1318
|
-
* Additional payload to be stored on each query.
|
|
1319
|
-
* Use this property to pass information that can be used in other places.
|
|
1320
|
-
*/
|
|
1321
|
-
meta?: QueryMeta;
|
|
1322
|
-
/**
|
|
1323
|
-
* Maximum number of pages to store in the data of an infinite query.
|
|
1324
|
-
*/
|
|
1325
|
-
maxPages?: number;
|
|
1326
|
-
}
|
|
1327
|
-
declare type QueryPersister<T = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = [TPageParam] extends [never] ? (queryFn: QueryFunction<T, TQueryKey, never>, context: QueryFunctionContext<TQueryKey>, query: Query) => T | Promise<T> : (queryFn: QueryFunction<T, TQueryKey, TPageParam>, context: QueryFunctionContext<TQueryKey>, query: Query) => T | Promise<T>;
|
|
1328
|
-
declare interface QueryState<TData = unknown, TError = DefaultError> {
|
|
1329
|
-
data: TData | undefined;
|
|
1330
|
-
dataUpdateCount: number;
|
|
1331
|
-
dataUpdatedAt: number;
|
|
1332
|
-
error: TError | null;
|
|
1333
|
-
errorUpdateCount: number;
|
|
1334
|
-
errorUpdatedAt: number;
|
|
1335
|
-
fetchFailureCount: number;
|
|
1336
|
-
fetchFailureReason: TError | null;
|
|
1337
|
-
fetchMeta: FetchMeta | null;
|
|
1338
|
-
isInvalidated: boolean;
|
|
1339
|
-
status: QueryStatus;
|
|
1340
|
-
fetchStatus: FetchStatus;
|
|
1341
|
-
}
|
|
1342
|
-
declare type QueryStatus = 'pending' | 'error' | 'success';
|
|
1343
|
-
declare type QueryTypeFilter = 'all' | 'active' | 'inactive';
|
|
1344
|
-
declare interface RefetchOptions extends ResultOptions {
|
|
1345
|
-
/**
|
|
1346
|
-
* If set to `true`, a currently running request will be cancelled before a new request is made
|
|
1347
|
-
*
|
|
1348
|
-
* If set to `false`, no refetch will be made if there is already a request running.
|
|
1349
|
-
*
|
|
1350
|
-
* Defaults to `true`.
|
|
1351
|
-
*/
|
|
1352
|
-
cancelRefetch?: boolean;
|
|
1392
|
+
type MutationObserverResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = MutationObserverIdleResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverLoadingResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverErrorResult<TData, TError, TVariables, TOnMutateResult> | MutationObserverSuccessResult<TData, TError, TVariables, TOnMutateResult>;
|
|
1393
|
+
interface QueryClientConfig {
|
|
1394
|
+
queryCache?: QueryCache;
|
|
1395
|
+
mutationCache?: MutationCache;
|
|
1396
|
+
defaultOptions?: DefaultOptions;
|
|
1353
1397
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
destroy(): void;
|
|
1360
|
-
protected scheduleGc(): void;
|
|
1361
|
-
protected updateGcTime(newGcTime: number | undefined): void;
|
|
1362
|
-
protected clearGcTimeout(): void;
|
|
1363
|
-
protected abstract optionalRemove(): void;
|
|
1398
|
+
interface DefaultOptions<TError = DefaultError> {
|
|
1399
|
+
queries?: OmitKeyof<QueryObserverOptions<unknown, TError>, 'suspense' | 'queryKey'>;
|
|
1400
|
+
mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>;
|
|
1401
|
+
hydrate?: HydrateOptions['defaultOptions'];
|
|
1402
|
+
dehydrate?: DehydrateOptions;
|
|
1364
1403
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1404
|
+
interface CancelOptions {
|
|
1405
|
+
revert?: boolean;
|
|
1406
|
+
silent?: boolean;
|
|
1368
1407
|
}
|
|
1369
|
-
|
|
1370
|
-
declare type RetryDelayValue<TError> = number | RetryDelayFunction<TError>;
|
|
1371
|
-
declare type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>;
|
|
1372
|
-
declare interface SetDataOptions {
|
|
1408
|
+
interface SetDataOptions {
|
|
1373
1409
|
updatedAt?: number;
|
|
1374
1410
|
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
}
|
|
1379
|
-
declare type ShouldRetryFunction<TError = DefaultError> = (failureCount: number, error: TError) => boolean;
|
|
1380
|
-
declare type SkipToken = typeof skipToken;
|
|
1381
|
-
declare const skipToken: unique symbol;
|
|
1382
|
-
declare type StaleTime = number | 'static';
|
|
1383
|
-
declare type StaleTimeFunction<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = StaleTime | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => StaleTime);
|
|
1384
|
-
declare class Subscribable<TListener extends Function> {
|
|
1385
|
-
protected listeners: Set<TListener>;
|
|
1386
|
-
constructor();
|
|
1387
|
-
subscribe(listener: TListener): () => void;
|
|
1388
|
-
hasListeners(): boolean;
|
|
1389
|
-
protected onSubscribe(): void;
|
|
1390
|
-
protected onUnsubscribe(): void;
|
|
1411
|
+
type NotifyEventType = 'added' | 'removed' | 'updated' | 'observerAdded' | 'observerRemoved' | 'observerResultsUpdated' | 'observerOptionsUpdated';
|
|
1412
|
+
interface NotifyEvent {
|
|
1413
|
+
type: NotifyEventType;
|
|
1391
1414
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1415
|
+
//#endregion
|
|
1416
|
+
//#region src/hydration.d.ts
|
|
1417
|
+
type TransformerFn = (data: any) => any;
|
|
1418
|
+
interface DehydrateOptions {
|
|
1419
|
+
serializeData?: TransformerFn;
|
|
1420
|
+
shouldDehydrateMutation?: (mutation: Mutation) => boolean;
|
|
1421
|
+
shouldDehydrateQuery?: (query: Query) => boolean;
|
|
1422
|
+
shouldRedactErrors?: (error: unknown) => boolean;
|
|
1397
1423
|
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1424
|
+
interface HydrateOptions {
|
|
1425
|
+
defaultOptions?: {
|
|
1426
|
+
deserializeData?: TransformerFn;
|
|
1427
|
+
queries?: QueryOptions;
|
|
1428
|
+
mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>;
|
|
1429
|
+
};
|
|
1401
1430
|
}
|
|
1402
|
-
/**
|
|
1403
|
-
* In many cases code wants to delay to the next event loop tick; this is not
|
|
1404
|
-
* mediated by {@link timeoutManager}.
|
|
1405
|
-
*
|
|
1406
|
-
* This function is provided to make auditing the `tanstack/query-core` for
|
|
1407
|
-
* incorrect use of system `setTimeout` easier.
|
|
1408
|
-
*/
|
|
1409
|
-
declare type ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey extends QueryKey> = boolean | ((error: TError, query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean);
|
|
1410
|
-
declare type TransformerFn = (data: any) => any;
|
|
1411
|
-
/**
|
|
1412
|
-
* This function takes a Promise-like input and detects whether the data
|
|
1413
|
-
* is synchronously available or not.
|
|
1414
|
-
*
|
|
1415
|
-
* It does not inspect .status, .value or .reason properties of the promise,
|
|
1416
|
-
* as those are not always available, and the .status of React's promises
|
|
1417
|
-
* should not be considered part of the public API.
|
|
1418
|
-
*/
|
|
1419
|
-
declare type TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly [] ? readonly [] : TuplePrefixes<DropLast<T>> | T;
|
|
1420
|
-
declare type UnsetMarker = typeof unsetMarker;
|
|
1421
|
-
declare const unsetMarker: unique symbol;
|
|
1422
|
-
declare type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput);
|
|
1423
|
-
declare type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & { [_ in TKey]: {} };
|
|
1424
1431
|
//#endregion
|
|
1425
1432
|
//#region src/queries/contentQueries.d.ts
|
|
1426
1433
|
/**
|
|
1427
1434
|
* Query options factory for content queries
|
|
1428
1435
|
* Use with TanStack Query's useQuery hook
|
|
1429
1436
|
*/
|
|
1430
|
-
declare const contentQueries: {
|
|
1437
|
+
export declare const contentQueries: {
|
|
1431
1438
|
/**
|
|
1432
1439
|
* Query options for paginated content list
|
|
1433
1440
|
* @param params - List parameters including type, pagination, filters
|
|
1434
1441
|
*/
|
|
1435
|
-
list: <C extends CustomFields = CustomFields>(params?: ContentListParams) => OmitKeyof<
|
|
1442
|
+
list: <C extends CustomFields = CustomFields>(params?: ContentListParams) => OmitKeyof<import("@tanstack/react-query").UseQueryOptions<ContentResponse<C>, Error, ContentResponse<C>, readonly ["content", "list", string, ContentListParams]>, "queryFn"> & {
|
|
1436
1443
|
queryFn?: QueryFunction<ContentResponse<C>, readonly ["content", "list", string, ContentListParams], never> | undefined;
|
|
1437
|
-
} &
|
|
1438
|
-
queryKey: readonly ["content", "list", string, ContentListParams] & {
|
|
1439
|
-
[dataTagSymbol]: ContentResponse<C>;
|
|
1440
|
-
[dataTagErrorSymbol]: Error;
|
|
1441
|
-
};
|
|
1442
|
-
};
|
|
1444
|
+
} & QueryKeyWithDataTag<readonly ["content", "list", string, ContentListParams], ContentResponse<C>, Error>;
|
|
1443
1445
|
/**
|
|
1444
1446
|
* Query options for a single content item by ID
|
|
1445
1447
|
* @param id - Content item ID
|
|
1446
1448
|
*/
|
|
1447
|
-
detail: <C extends CustomFields = CustomFields>(id: number) => OmitKeyof<
|
|
1449
|
+
detail: <C extends CustomFields = CustomFields>(id: number) => OmitKeyof<import("@tanstack/react-query").UseQueryOptions<ApiResponse<ContentDto<C>>, Error, ApiResponse<ContentDto<C>>, readonly ["content", "detail", number]>, "queryFn"> & {
|
|
1448
1450
|
queryFn?: QueryFunction<ApiResponse<ContentDto<C>>, readonly ["content", "detail", number], never> | undefined;
|
|
1449
|
-
} &
|
|
1450
|
-
queryKey: readonly ["content", "detail", number] & {
|
|
1451
|
-
[dataTagSymbol]: ApiResponse<ContentDto<C>>;
|
|
1452
|
-
[dataTagErrorSymbol]: Error;
|
|
1453
|
-
};
|
|
1454
|
-
};
|
|
1451
|
+
} & QueryKeyWithDataTag<readonly ["content", "detail", number], ApiResponse<ContentDto<C>>, Error>;
|
|
1455
1452
|
/**
|
|
1456
1453
|
* Query options for fetching all content items (across all pages)
|
|
1457
1454
|
* @param params - List parameters (without page)
|
|
@@ -1459,7 +1456,7 @@ declare const contentQueries: {
|
|
|
1459
1456
|
*/
|
|
1460
1457
|
listAll: <C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, "page"> & {
|
|
1461
1458
|
page?: never;
|
|
1462
|
-
}, options?: FetchAllOptions<C, T>) => OmitKeyof<
|
|
1459
|
+
}, options?: FetchAllOptions<C, T>) => OmitKeyof<import("@tanstack/react-query").UseQueryOptions<T[], Error, T[], readonly ["content", "all", string, {
|
|
1463
1460
|
readonly mode: "all";
|
|
1464
1461
|
readonly size?: number;
|
|
1465
1462
|
readonly sortBy?: string;
|
|
@@ -1475,19 +1472,14 @@ declare const contentQueries: {
|
|
|
1475
1472
|
readonly type?: string;
|
|
1476
1473
|
readonly filters?: Record<string, string | number | boolean | null | undefined>;
|
|
1477
1474
|
}], never> | undefined;
|
|
1478
|
-
} & {
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
}] & {
|
|
1487
|
-
[dataTagSymbol]: T[];
|
|
1488
|
-
[dataTagErrorSymbol]: Error;
|
|
1489
|
-
};
|
|
1490
|
-
};
|
|
1475
|
+
} & QueryKeyWithDataTag<readonly ["content", "all", string, {
|
|
1476
|
+
readonly mode: "all";
|
|
1477
|
+
readonly size?: number;
|
|
1478
|
+
readonly sortBy?: string;
|
|
1479
|
+
readonly direction?: "ASC" | "DESC";
|
|
1480
|
+
readonly type?: string;
|
|
1481
|
+
readonly filters?: Record<string, string | number | boolean | null | undefined>;
|
|
1482
|
+
}], T[], Error>;
|
|
1491
1483
|
};
|
|
1492
1484
|
//#endregion
|
|
1493
1485
|
//#region src/queries/queryKeys.d.ts
|
|
@@ -1495,7 +1487,7 @@ declare const contentQueries: {
|
|
|
1495
1487
|
* Hierarchical query key factory for content queries
|
|
1496
1488
|
* Following TanStack Query best practices for key structure
|
|
1497
1489
|
*/
|
|
1498
|
-
declare const contentKeys: {
|
|
1490
|
+
export declare const contentKeys: {
|
|
1499
1491
|
/**
|
|
1500
1492
|
* Base key for all content queries
|
|
1501
1493
|
*/
|
|
@@ -1543,25 +1535,25 @@ declare const contentKeys: {
|
|
|
1543
1535
|
* Hook for fetching paginated content list
|
|
1544
1536
|
* @param params - List parameters including type, pagination, filters
|
|
1545
1537
|
*/
|
|
1546
|
-
declare function useContentList<C extends CustomFields = CustomFields>(params?: ContentListParams): UseQueryResult<ContentResponse<C>>;
|
|
1538
|
+
export declare function useContentList<C extends CustomFields = CustomFields>(params?: ContentListParams): UseQueryResult<ContentResponse<C>>;
|
|
1547
1539
|
/**
|
|
1548
1540
|
* Hook for fetching a single content item by ID
|
|
1549
1541
|
* @param id - Content item ID
|
|
1550
1542
|
*/
|
|
1551
|
-
declare function useContentDetail<C extends CustomFields = CustomFields>(id: number): UseQueryResult<ApiResponse<ContentDto<C>>>;
|
|
1543
|
+
export declare function useContentDetail<C extends CustomFields = CustomFields>(id: number): UseQueryResult<ApiResponse<ContentDto<C>>>;
|
|
1552
1544
|
/**
|
|
1553
1545
|
* Hook for fetching all content items across pages
|
|
1554
1546
|
* @param params - List parameters (without page)
|
|
1555
1547
|
* @param options - Fetch options including mapping and deduplication
|
|
1556
1548
|
*/
|
|
1557
|
-
declare function useContentAll<C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, 'page'> & {
|
|
1549
|
+
export declare function useContentAll<C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, 'page'> & {
|
|
1558
1550
|
page?: never;
|
|
1559
1551
|
}, options?: FetchAllOptions<C, T>): UseQueryResult<T[]>;
|
|
1560
1552
|
/**
|
|
1561
1553
|
* Hook for prefetching content queries
|
|
1562
1554
|
* Useful for optimistic navigation and hover effects
|
|
1563
1555
|
*/
|
|
1564
|
-
declare function useContentPrefetch(): {
|
|
1556
|
+
export declare function useContentPrefetch(): {
|
|
1565
1557
|
/**
|
|
1566
1558
|
* Prefetch a content list
|
|
1567
1559
|
*/
|
|
@@ -1589,7 +1581,7 @@ type BuildAssetUrlOpts = {
|
|
|
1589
1581
|
apiBase?: string;
|
|
1590
1582
|
fileBase?: string;
|
|
1591
1583
|
};
|
|
1592
|
-
declare const buildAssetUrl: (rawPath?: string | null, opts?: BuildAssetUrlOpts) => string;
|
|
1584
|
+
export declare const buildAssetUrl: (rawPath?: string | null, opts?: BuildAssetUrlOpts) => string;
|
|
1593
1585
|
//#endregion
|
|
1594
1586
|
//#region src/utils/normalization.d.ts
|
|
1595
1587
|
/**
|
|
@@ -1604,7 +1596,7 @@ declare const buildAssetUrl: (rawPath?: string | null, opts?: BuildAssetUrlOpts)
|
|
|
1604
1596
|
* @param item - Raw content item from the API
|
|
1605
1597
|
* @returns Normalized content item
|
|
1606
1598
|
*/
|
|
1607
|
-
declare function normalizeContentItem<C extends CustomFields = CustomFields>(item: ContentDto<C>): NormalizedContentItem;
|
|
1599
|
+
export declare function normalizeContentItem<C extends CustomFields = CustomFields>(item: ContentDto<C>): NormalizedContentItem;
|
|
1608
1600
|
/**
|
|
1609
1601
|
* Build an asset URL using the SDK's configured base URLs
|
|
1610
1602
|
* This is a convenience wrapper that automatically uses SDK config
|
|
@@ -1612,7 +1604,7 @@ declare function normalizeContentItem<C extends CustomFields = CustomFields>(ite
|
|
|
1612
1604
|
* @param path - Path to the asset (can be relative or absolute)
|
|
1613
1605
|
* @returns Full URL to the asset
|
|
1614
1606
|
*/
|
|
1615
|
-
declare function buildAssetUrlWithConfig(path?: string | null): string;
|
|
1607
|
+
export declare function buildAssetUrlWithConfig(path?: string | null): string;
|
|
1616
1608
|
//#endregion
|
|
1617
1609
|
//#region src/utils/richText.d.ts
|
|
1618
1610
|
/**
|
|
@@ -1630,7 +1622,7 @@ declare function buildAssetUrlWithConfig(path?: string | null): string;
|
|
|
1630
1622
|
* stripHtmlTags('<p>Hello <strong>world</strong></p>') // → 'Hello world'
|
|
1631
1623
|
* stripHtmlTags('<ul><li>A</li><li>B</li></ul>') // → 'A B'
|
|
1632
1624
|
*/
|
|
1633
|
-
declare function stripHtmlTags(html: string): string;
|
|
1625
|
+
export declare function stripHtmlTags(html: string): string;
|
|
1634
1626
|
/**
|
|
1635
1627
|
* Returns `true` if the given string contains HTML markup.
|
|
1636
1628
|
*
|
|
@@ -1647,10 +1639,10 @@ declare function stripHtmlTags(html: string): string;
|
|
|
1647
1639
|
* isHtmlContent('Just text') // → false
|
|
1648
1640
|
* isHtmlContent('if x < 10 then') // → false
|
|
1649
1641
|
*/
|
|
1650
|
-
declare function isHtmlContent(value: string): boolean;
|
|
1642
|
+
export declare function isHtmlContent(value: string): boolean;
|
|
1651
1643
|
//#endregion
|
|
1652
1644
|
//#region src/errors/CmsError.d.ts
|
|
1653
|
-
declare class CmsError extends Error {
|
|
1645
|
+
export declare class CmsError extends Error {
|
|
1654
1646
|
readonly status?: number;
|
|
1655
1647
|
readonly data?: unknown;
|
|
1656
1648
|
constructor(message: string, opts?: {
|
|
@@ -1664,19 +1656,18 @@ declare class CmsError extends Error {
|
|
|
1664
1656
|
/**
|
|
1665
1657
|
* Get the current SDK configuration
|
|
1666
1658
|
*/
|
|
1667
|
-
declare function getConfig(): SdkConfig;
|
|
1659
|
+
export declare function getConfig(): SdkConfig;
|
|
1668
1660
|
/**
|
|
1669
1661
|
* Set the SDK configuration
|
|
1670
1662
|
*/
|
|
1671
|
-
declare function setConfig(config: SdkConfig): void;
|
|
1663
|
+
export declare function setConfig(config: SdkConfig): void;
|
|
1672
1664
|
/**
|
|
1673
1665
|
* Check if SDK is initialized
|
|
1674
1666
|
*/
|
|
1675
|
-
declare function isInitialized(): boolean;
|
|
1667
|
+
export declare function isInitialized(): boolean;
|
|
1676
1668
|
/**
|
|
1677
1669
|
* Reset configuration (useful for testing)
|
|
1678
1670
|
*/
|
|
1679
|
-
declare function resetConfig(): void;
|
|
1671
|
+
export declare function resetConfig(): void;
|
|
1680
1672
|
//#endregion
|
|
1681
|
-
export { ApiResponse, CmsError, ContentDto, ContentListParams, ContentResponse, CustomFields, FetchAllOptions, JsonPrimitive, JsonValue, NormalizedContentItem, PaginatedData, SdkConfig, apiClient, buildAssetUrl, buildAssetUrlWithConfig, contentKeys, contentQueries, createApiClient, downloadFile, fetchAllContent, fetchContentById, fetchContentByType, getApiClient, getConfig, isHtmlContent, isInitialized, normalizeContentItem, resetApiClient, resetConfig, setConfig, stripHtmlTags, useContentAll, useContentDetail, useContentList, useContentPrefetch };
|
|
1682
1673
|
//# sourceMappingURL=index.d.mts.map
|