@codesocietyou/contentedge-cms-sdk 1.0.0 → 1.0.3

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.
@@ -0,0 +1,1682 @@
1
+ import { AxiosInstance } from "axios";
2
+ import * as _$_tanstack_react_query0 from "@tanstack/react-query";
3
+ import { UseQueryResult } from "@tanstack/react-query";
4
+
5
+ //#region src/types/config.d.ts
6
+ interface SdkConfig {
7
+ baseUrl: string;
8
+ fileBaseUrl?: string;
9
+ apiKey?: string;
10
+ tenant?: string;
11
+ timeoutMs?: number;
12
+ logger?: {
13
+ debug?: (...args: unknown[]) => void;
14
+ warn?: (...args: unknown[]) => void;
15
+ error?: (...args: unknown[]) => void;
16
+ };
17
+ }
18
+ //#endregion
19
+ //#region src/services/apiClient.d.ts
20
+ /**
21
+ * Create and configure the API client with the given configuration
22
+ */
23
+ declare function createApiClient(config: SdkConfig): AxiosInstance;
24
+ /**
25
+ * Get the current API client instance
26
+ * Throws if not initialized
27
+ */
28
+ declare function getApiClient(): AxiosInstance;
29
+ /**
30
+ * Reset the API client (useful for testing)
31
+ */
32
+ declare function resetApiClient(): void;
33
+ declare const apiClient: AxiosInstance;
34
+ //#endregion
35
+ //#region src/types/content.d.ts
36
+ type JsonPrimitive = string | number | boolean | null;
37
+ type JsonValue = JsonPrimitive | JsonValue[] | {
38
+ [key: string]: JsonValue;
39
+ };
40
+ type CustomFields = Record<string, JsonValue>;
41
+ interface ContentDto<C extends CustomFields = CustomFields> {
42
+ id: number;
43
+ title: string;
44
+ text: string;
45
+ type: string;
46
+ customFields: C;
47
+ }
48
+ interface ApiResponse<T> {
49
+ status: 'SUCCESS' | 'FAILURE';
50
+ message: string;
51
+ data: T;
52
+ }
53
+ interface PaginatedData<T> {
54
+ content: T[];
55
+ number?: number;
56
+ size?: number;
57
+ numberOfElements?: number;
58
+ totalElements?: number;
59
+ totalPages?: number;
60
+ first?: boolean;
61
+ last?: boolean;
62
+ empty?: boolean;
63
+ sort?: unknown;
64
+ pageable?: unknown;
65
+ }
66
+ type ContentResponse<C extends CustomFields = CustomFields> = ApiResponse<PaginatedData<ContentDto<C>>>;
67
+ interface ContentListParams {
68
+ type?: string;
69
+ page?: number;
70
+ size?: number;
71
+ sortBy?: string;
72
+ direction?: 'ASC' | 'DESC';
73
+ filters?: Record<string, string | number | boolean | null | undefined>;
74
+ }
75
+ /**
76
+ * Normalized content item with commonly used fields.
77
+ * This type is exported for convenience but normalization is handled
78
+ * by the {@link normalizeContentItem} function in utils/normalization.
79
+ */
80
+ interface NormalizedContentItem {
81
+ id: number;
82
+ title: string;
83
+ /**
84
+ * Main body text for the content item.
85
+ *
86
+ * This field may contain **TipTap-generated HTML** (e.g. `<p>`, `<ul>`, `<li>`,
87
+ * `<strong>`, `<em>`, `<a>`). Render it with a rich text renderer (TipTap
88
+ * read-only mode or `dangerouslySetInnerHTML`) rather than as a plain string.
89
+ * Use {@link stripHtmlTags} to obtain a plain-text preview.
90
+ */
91
+ text: string;
92
+ type: string;
93
+ insideImage: string;
94
+ outsideImage: string;
95
+ pdfPath: string | null;
96
+ /**
97
+ * References / bibliography field.
98
+ *
99
+ * May contain **TipTap-generated HTML** (ordered lists, links, bold text).
100
+ * Render with a rich text renderer or strip with {@link stripHtmlTags}.
101
+ */
102
+ references: string | null;
103
+ citation: string | null;
104
+ /**
105
+ * Abstract or summary of the content item.
106
+ *
107
+ * May contain **TipTap-generated HTML** (paragraphs, bold, italic).
108
+ * Render with a rich text renderer or strip with {@link stripHtmlTags}.
109
+ */
110
+ abstract: string | null;
111
+ team: string | null;
112
+ publicationType: string | null;
113
+ fake: boolean | null;
114
+ }
115
+ //#endregion
116
+ //#region src/services/contentApi.d.ts
117
+ /**
118
+ * Fetch content by type with pagination and filters
119
+ */
120
+ declare function fetchContentByType<C extends CustomFields = CustomFields>(params?: ContentListParams): Promise<ContentResponse<C>>;
121
+ /**
122
+ * Fetch a single content item by ID
123
+ */
124
+ declare function fetchContentById<C extends CustomFields = CustomFields>(id: number): Promise<ApiResponse<ContentDto<C>>>;
125
+ /**
126
+ * Download a file from a given path
127
+ * @param path - Full URL or relative path to the file
128
+ * @returns Blob containing the file data
129
+ */
130
+ declare function downloadFile(path: string): Promise<Blob>;
131
+ //#endregion
132
+ //#region src/services/contentFetchAll.d.ts
133
+ interface FetchAllOptions<C extends CustomFields, T> {
134
+ /**
135
+ * Optional function to transform each content item
136
+ */
137
+ mapItem?: (item: ContentDto<C>) => T;
138
+ /**
139
+ * Optional function to extract a unique key for deduplication
140
+ */
141
+ dedupeBy?: (item: T) => string | number;
142
+ /**
143
+ * Maximum number of pages to fetch (safety limit)
144
+ * @default 20
145
+ */
146
+ hardStopMaxPages?: number;
147
+ }
148
+ /**
149
+ * Fetch all content items across multiple pages with automatic pagination
150
+ *
151
+ * This function will continue fetching pages until:
152
+ * - No more items are returned
153
+ * - The last page is reached (based on pagination metadata)
154
+ * - The hard stop limit is reached
155
+ * - No new items are added (all items are duplicates)
156
+ *
157
+ * @param params - Content list parameters (without page number)
158
+ * @param options - Fetch options including mapping and deduplication
159
+ * @returns Array of all fetched items
160
+ */
161
+ declare function fetchAllContent<C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, 'page'> & {
162
+ page?: never;
163
+ }, options?: FetchAllOptions<C, T>): Promise<T[]>;
164
+ //#endregion
165
+ //#region node_modules/@tanstack/query-core/build/modern/_tsup-dts-rollup.d.ts
166
+ declare type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction_2 | ErrorAction_2<TError> | FailedAction_2<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction_2 | SuccessAction_2<TData>;
167
+ declare type Action_alias_1<TData, TError> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | FetchAction | InvalidateAction | PauseAction | SetStateAction<TData, TError> | SuccessAction<TData>;
168
+ declare type AnyDataTag = {
169
+ [dataTagSymbol$1]: any;
170
+ [dataTagErrorSymbol$1]: any;
171
+ };
172
+ declare interface CancelOptions {
173
+ revert?: boolean;
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;
207
+ }
208
+ declare type DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [...infer R, unknown] ? readonly [...R] : never;
209
+ declare type EnsureInfiniteQueryDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
210
+ revalidateIfStale?: boolean;
211
+ };
212
+ declare interface EnsureQueryDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> extends FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> {
213
+ revalidateIfStale?: boolean;
214
+ }
215
+ declare interface ErrorAction<TError> {
216
+ type: 'error';
217
+ error: TError;
218
+ }
219
+ declare interface ErrorAction_2<TError> {
220
+ type: 'error';
221
+ error: TError;
222
+ }
223
+ declare interface FailedAction<TError> {
224
+ type: 'failed';
225
+ failureCount: number;
226
+ error: TError;
227
+ }
228
+ declare interface FailedAction_2<TError> {
229
+ type: 'failed';
230
+ failureCount: number;
231
+ error: TError | null;
232
+ }
233
+ declare interface FetchAction {
234
+ type: 'fetch';
235
+ meta?: FetchMeta;
236
+ }
237
+ declare interface FetchContext<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
238
+ fetchFn: () => unknown | Promise<unknown>;
239
+ fetchOptions?: FetchOptions;
240
+ signal: AbortSignal;
241
+ options: QueryOptions<TQueryFnData, TError, TData, any>;
242
+ client: QueryClient;
243
+ queryKey: TQueryKey;
244
+ state: QueryState<TData, TError>;
245
+ }
246
+ declare type FetchDirection = 'forward' | 'backward';
247
+ declare 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> & FetchInfiniteQueryPages<TQueryFnData, TPageParam>;
248
+ declare type FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> = {
249
+ pages?: never;
250
+ } | {
251
+ pages: number;
252
+ getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>;
253
+ };
254
+ declare interface FetchMeta {
255
+ fetchMore?: {
256
+ direction: FetchDirection;
257
+ };
258
+ }
259
+ declare interface FetchNextPageOptions extends ResultOptions {
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> {
271
+ cancelRefetch?: boolean;
272
+ meta?: FetchMeta;
273
+ initialPromise?: Promise<TData>;
274
+ }
275
+ declare interface FetchPreviousPageOptions extends ResultOptions {
276
+ /**
277
+ * If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time,
278
+ * whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.
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
+ };
302
+ }
303
+ declare type InferDataFromTag<TQueryFnData, TTaggedQueryKey extends QueryKey> = TTaggedQueryKey extends DataTag<unknown, infer TaggedValue, unknown> ? TaggedValue : TQueryFnData;
304
+ declare type InferErrorFromTag<TError, TTaggedQueryKey extends QueryKey> = TTaggedQueryKey extends DataTag<unknown, unknown, infer TaggedError> ? TaggedError extends UnsetMarker ? TError : TaggedError : TError;
305
+ declare interface InfiniteData<TData, TPageParam = unknown> {
306
+ pages: Array<TData>;
307
+ pageParams: Array<TPageParam>;
308
+ }
309
+ declare interface InfiniteQueryObserverBaseResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
310
+ /**
311
+ * This function allows you to fetch the next "page" of results.
312
+ */
313
+ fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<TData, TError>>;
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;
342
+ }
343
+ declare interface InfiniteQueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
344
+ data: undefined;
345
+ 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
+ }
357
+ declare interface InfiniteQueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
358
+ data: undefined;
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';
370
+ }
371
+ declare interface InfiniteQueryObserverPendingResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
372
+ data: undefined;
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';
383
+ }
384
+ declare interface InfiniteQueryObserverPlaceholderResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
385
+ data: TData;
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';
397
+ }
398
+ declare interface InfiniteQueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
399
+ data: TData;
400
+ error: TError;
401
+ isError: true;
402
+ isPending: false;
403
+ isLoading: false;
404
+ isLoadingError: false;
405
+ isRefetchError: true;
406
+ isSuccess: false;
407
+ isPlaceholderData: false;
408
+ status: 'error';
409
+ }
410
+ declare type InfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = DefinedInfiniteQueryObserverResult<TData, TError> | InfiniteQueryObserverLoadingErrorResult<TData, TError> | InfiniteQueryObserverLoadingResult<TData, TError> | InfiniteQueryObserverPendingResult<TData, TError> | InfiniteQueryObserverPlaceholderResult<TData, TError>;
411
+ declare interface InfiniteQueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends InfiniteQueryObserverBaseResult<TData, TError> {
412
+ data: TData;
413
+ error: null;
414
+ isError: false;
415
+ isPending: false;
416
+ isLoading: false;
417
+ isLoadingError: false;
418
+ isRefetchError: false;
419
+ isFetchNextPageError: false;
420
+ isFetchPreviousPageError: false;
421
+ isSuccess: true;
422
+ isPlaceholderData: false;
423
+ status: 'success';
424
+ }
425
+ declare type InitialDataFunction<T> = () => T | undefined;
426
+ declare interface InitialPageParam<TPageParam = unknown> {
427
+ initialPageParam: TPageParam;
428
+ }
429
+ declare interface InvalidateAction {
430
+ type: 'invalidate';
431
+ }
432
+ declare interface InvalidateOptions extends RefetchOptions {}
433
+ declare interface InvalidateQueryFilters<TQueryKey extends QueryKey = QueryKey> extends QueryFilters<TQueryKey> {
434
+ refetchType?: QueryTypeFilter | 'none';
435
+ }
436
+ declare type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
437
+ declare interface MutateOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> {
438
+ onSuccess?: (data: TData, variables: TVariables, onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext) => void;
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;
441
+ }
442
+ declare class Mutation<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> extends Removable {
443
+ #private;
444
+ state: MutationState<TData, TError, TVariables, TOnMutateResult>;
445
+ options: MutationOptions<TData, TError, TVariables, TOnMutateResult>;
446
+ readonly mutationId: number;
447
+ constructor(config: MutationConfig<TData, TError, TVariables, TOnMutateResult>);
448
+ setOptions(options: MutationOptions<TData, TError, TVariables, TOnMutateResult>): void;
449
+ get meta(): MutationMeta | undefined;
450
+ addObserver(observer: MutationObserver_2<any, any, any, any>): void;
451
+ removeObserver(observer: MutationObserver_2<any, any, any, any>): void;
452
+ protected optionalRemove(): void;
453
+ continue(): Promise<unknown>;
454
+ execute(variables: TVariables): Promise<TData>;
455
+ }
456
+ declare class MutationCache extends Subscribable<MutationCacheListener> {
457
+ #private;
458
+ config: MutationCacheConfig;
459
+ constructor(config?: MutationCacheConfig);
460
+ build<TData, TError, TVariables, TOnMutateResult>(client: QueryClient, options: MutationOptions<TData, TError, TVariables, TOnMutateResult>, state?: MutationState<TData, TError, TVariables, TOnMutateResult>): Mutation<TData, TError, TVariables, TOnMutateResult>;
461
+ add(mutation: Mutation<any, any, any, any>): void;
462
+ remove(mutation: Mutation<any, any, any, any>): void;
463
+ canRun(mutation: Mutation<any, any, any, any>): boolean;
464
+ runNext(mutation: Mutation<any, any, any, any>): Promise<unknown>;
465
+ clear(): void;
466
+ getAll(): Array<Mutation>;
467
+ find<TData = unknown, TError = DefaultError, TVariables = any, TOnMutateResult = unknown>(filters: MutationFilters): Mutation<TData, TError, TVariables, TOnMutateResult> | undefined;
468
+ findAll(filters?: MutationFilters): Array<Mutation>;
469
+ notify(event: MutationCacheNotifyEvent): void;
470
+ resumePausedMutations(): Promise<unknown>;
471
+ }
472
+ declare interface MutationCacheConfig {
473
+ onError?: (error: DefaultError, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
474
+ onSuccess?: (data: unknown, variables: unknown, onMutateResult: unknown, mutation: Mutation<unknown, unknown, unknown>, context: MutationFunctionContext) => Promise<unknown> | unknown;
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> {
481
+ client: QueryClient;
482
+ mutationId: number;
483
+ mutationCache: MutationCache;
484
+ options: MutationOptions<TData, TError, TVariables, TOnMutateResult>;
485
+ state?: MutationState<TData, TError, TVariables, TOnMutateResult>;
486
+ }
487
+ declare interface MutationFilters<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> {
488
+ /**
489
+ * Match mutation key exactly
490
+ */
491
+ exact?: boolean;
492
+ /**
493
+ * Include mutations matching this predicate function
494
+ */
495
+ predicate?: (mutation: Mutation<TData, TError, TVariables, TOnMutateResult>) => boolean;
496
+ /**
497
+ * Include mutations matching this mutation key
498
+ */
499
+ mutationKey?: TuplePrefixes<MutationKey>;
500
+ /**
501
+ * Filter by mutation status
502
+ */
503
+ status?: MutationStatus;
504
+ }
505
+ declare type MutationFunction<TData = unknown, TVariables = unknown> = (variables: TVariables, context: MutationFunctionContext) => Promise<TData>;
506
+ declare type MutationFunctionContext = {
507
+ client: QueryClient;
508
+ meta: MutationMeta | undefined;
509
+ mutationKey?: MutationKey;
510
+ };
511
+ declare type MutationKey = Register extends {
512
+ mutationKey: infer TMutationKey;
513
+ } ? TMutationKey extends ReadonlyArray<unknown> ? TMutationKey : TMutationKey extends Array<unknown> ? TMutationKey : ReadonlyArray<unknown> : ReadonlyArray<unknown>;
514
+ declare type MutationMeta = Register extends {
515
+ mutationMeta: infer TMutationMeta;
516
+ } ? TMutationMeta extends Record<string, unknown> ? TMutationMeta : Record<string, unknown> : Record<string, unknown>;
517
+ declare class MutationObserver_2<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends Subscribable<MutationObserverListener<TData, TError, TVariables, TOnMutateResult>> {
518
+ #private;
519
+ options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>;
520
+ constructor(client: QueryClient, options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>);
521
+ protected bindMethods(): void;
522
+ setOptions(options: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>): void;
523
+ protected onUnsubscribe(): void;
524
+ onMutationUpdate(action: Action<TData, TError, TVariables, TOnMutateResult>): void;
525
+ getCurrentResult(): MutationObserverResult<TData, TError, TVariables, TOnMutateResult>;
526
+ reset(): void;
527
+ mutate(variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>): Promise<TData>;
528
+ }
529
+ declare interface MutationObserverBaseResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationState<TData, TError, TVariables, TOnMutateResult> {
530
+ /**
531
+ * The last successfully resolved data for the mutation.
532
+ */
533
+ data: TData | undefined;
534
+ /**
535
+ * The variables object passed to the `mutationFn`.
536
+ */
537
+ variables: TVariables | undefined;
538
+ /**
539
+ * The error object for the mutation, if an error was encountered.
540
+ * - Defaults to `null`.
541
+ */
542
+ error: TError | null;
543
+ /**
544
+ * A boolean variable derived from `status`.
545
+ * - `true` if the last mutation attempt resulted in an error.
546
+ */
547
+ isError: boolean;
548
+ /**
549
+ * A boolean variable derived from `status`.
550
+ * - `true` if the mutation is in its initial state prior to executing.
551
+ */
552
+ isIdle: boolean;
553
+ /**
554
+ * A boolean variable derived from `status`.
555
+ * - `true` if the mutation is currently executing.
556
+ */
557
+ isPending: boolean;
558
+ /**
559
+ * A boolean variable derived from `status`.
560
+ * - `true` if the last mutation attempt was successful.
561
+ */
562
+ isSuccess: boolean;
563
+ /**
564
+ * The status of the mutation.
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.
570
+ */
571
+ status: MutationStatus;
572
+ /**
573
+ * The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
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.
581
+ */
582
+ mutate: MutateFunction<TData, TError, TVariables, TOnMutateResult>;
583
+ /**
584
+ * A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).
585
+ */
586
+ reset: () => void;
587
+ }
588
+ declare interface MutationObserverErrorResult<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TOnMutateResult> {
589
+ data: undefined;
590
+ error: TError;
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>;
782
+ }
783
+ declare interface QueryBehavior<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> {
784
+ onFetch: (context: FetchContext<TQueryFnData, TError, TData, TQueryKey>, query: Query) => void;
785
+ }
786
+ declare type QueryBooleanOption<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = boolean | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => boolean);
787
+ declare class QueryCache extends Subscribable<QueryCacheListener> {
788
+ #private;
789
+ config: QueryCacheConfig;
790
+ constructor(config?: QueryCacheConfig);
791
+ build<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(client: QueryClient, options: WithRequired<QueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryKey'>, state?: QueryState<TData, TError>): Query<TQueryFnData, TError, TData, TQueryKey>;
792
+ add(query: Query<any, any, any, any>): void;
793
+ remove(query: Query<any, any, any, any>): void;
794
+ clear(): void;
795
+ get<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryHash: string): Query<TQueryFnData, TError, TData, TQueryKey> | undefined;
796
+ getAll(): Array<Query>;
797
+ find<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData>(filters: WithRequired<QueryFilters, 'queryKey'>): Query<TQueryFnData, TError, TData> | undefined;
798
+ findAll(filters?: QueryFilters<any>): Array<Query>;
799
+ notify(event: QueryCacheNotifyEvent): void;
800
+ onFocus(): void;
801
+ onOnline(): void;
802
+ }
803
+ declare interface QueryCacheConfig {
804
+ onError?: (error: DefaultError, query: Query<unknown, unknown, unknown>) => void;
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;
810
+ declare class QueryClient {
811
+ #private;
812
+ constructor(config?: QueryClientConfig);
813
+ mount(): void;
814
+ unmount(): void;
815
+ isFetching<TQueryFilters extends QueryFilters<any> = QueryFilters>(filters?: TQueryFilters): number;
816
+ isMutating<TMutationFilters extends MutationFilters<any, any> = MutationFilters>(filters?: TMutationFilters): number;
817
+ /**
818
+ * Imperative (non-reactive) way to retrieve data for a QueryKey.
819
+ * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
820
+ *
821
+ * Hint: Do not use this function inside a component, because it won't receive updates.
822
+ * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
823
+ */
824
+ getQueryData<TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined;
825
+ ensureQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: EnsureQueryDataOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<TData>;
826
+ 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<NoInfer_2<TInferredQueryFnData> | undefined, NoInfer_2<TInferredQueryFnData> | undefined>, options?: SetDataOptions): NoInfer_2<TInferredQueryFnData> | undefined;
828
+ setQueriesData<TQueryFnData, TQueryFilters extends QueryFilters<any> = QueryFilters>(filters: TQueryFilters, updater: Updater<NoInfer_2<TQueryFnData> | undefined, NoInfer_2<TQueryFnData> | undefined>, options?: SetDataOptions): Array<[QueryKey, TQueryFnData | undefined]>;
829
+ getQueryState<TQueryFnData = unknown, TError = DefaultError, TTaggedQueryKey extends QueryKey = QueryKey, TInferredQueryFnData = InferDataFromTag<TQueryFnData, TTaggedQueryKey>, TInferredError = InferErrorFromTag<TError, TTaggedQueryKey>>(queryKey: TTaggedQueryKey): QueryState<TInferredQueryFnData, TInferredError> | undefined;
830
+ removeQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>): void;
831
+ resetQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>, options?: ResetOptions): Promise<void>;
832
+ cancelQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: QueryFilters<TTaggedQueryKey>, cancelOptions?: CancelOptions): Promise<void>;
833
+ invalidateQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: InvalidateQueryFilters<TTaggedQueryKey>, options?: InvalidateOptions): Promise<void>;
834
+ refetchQueries<TTaggedQueryKey extends QueryKey = QueryKey>(filters?: RefetchQueryFilters<TTaggedQueryKey>, options?: RefetchOptions): Promise<void>;
835
+ fetchQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<TData>;
836
+ prefetchQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>): Promise<void>;
837
+ fetchInfiniteQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<InfiniteData<TData, TPageParam>>;
838
+ prefetchInfiniteQuery<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<void>;
839
+ ensureInfiniteQueryData<TQueryFnData, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: EnsureInfiniteQueryDataOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): Promise<InfiniteData<TData, TPageParam>>;
840
+ resumePausedMutations(): Promise<unknown>;
841
+ getQueryCache(): QueryCache;
842
+ getMutationCache(): MutationCache;
843
+ getDefaultOptions(): DefaultOptions;
844
+ setDefaultOptions(options: DefaultOptions): void;
845
+ setQueryDefaults<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData>(queryKey: QueryKey, options: Partial<OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData>, 'queryKey'>>): void;
846
+ getQueryDefaults(queryKey: QueryKey): OmitKeyof<QueryObserverOptions<any, any, any, any, any>, 'queryKey'>;
847
+ setMutationDefaults<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(mutationKey: MutationKey, options: OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): void;
848
+ getMutationDefaults(mutationKey: MutationKey): OmitKeyof<MutationObserverOptions<any, any, any, any>, 'mutationKey'>;
849
+ defaultQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never>(options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam> | DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>): DefaultedQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
850
+ defaultMutationOptions<T extends MutationOptions<any, any, any, any>>(options?: T): T;
851
+ clear(): void;
852
+ }
853
+ declare interface QueryClientConfig {
854
+ queryCache?: QueryCache;
855
+ mutationCache?: MutationCache;
856
+ defaultOptions?: DefaultOptions;
857
+ }
858
+ declare interface QueryConfig<TQueryFnData, TError, TData, TQueryKey extends QueryKey = QueryKey> {
859
+ client: QueryClient;
860
+ queryKey: TQueryKey;
861
+ queryHash: string;
862
+ options?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
863
+ defaultOptions?: QueryOptions<TQueryFnData, TError, TData, TQueryKey>;
864
+ state?: QueryState<TData, TError>;
865
+ }
866
+ declare interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {
867
+ /**
868
+ * Filter to active queries, inactive queries or all queries
869
+ */
870
+ type?: QueryTypeFilter;
871
+ /**
872
+ * Match query key exactly
873
+ */
874
+ exact?: boolean;
875
+ /**
876
+ * Include queries matching this predicate function
877
+ */
878
+ predicate?: (query: Query) => boolean;
879
+ /**
880
+ * Include queries matching this query key
881
+ */
882
+ queryKey?: TQueryKey | TuplePrefixes<TQueryKey>;
883
+ /**
884
+ * Include or exclude stale queries
885
+ */
886
+ stale?: boolean;
887
+ /**
888
+ * Include queries matching their fetchStatus
889
+ */
890
+ fetchStatus?: FetchStatus;
891
+ }
892
+ declare type QueryFunction<T = unknown, TQueryKey extends QueryKey = QueryKey, TPageParam = never> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>;
893
+ declare type QueryFunctionContext<TQueryKey extends QueryKey = QueryKey, TPageParam = never> = [TPageParam] extends [never] ? {
894
+ client: QueryClient;
895
+ queryKey: TQueryKey;
896
+ signal: AbortSignal;
897
+ meta: QueryMeta | undefined;
898
+ pageParam?: unknown;
899
+ /**
900
+ * @deprecated
901
+ * if you want access to the direction, you can add it to the pageParam
902
+ */
903
+ direction?: unknown;
904
+ } : {
905
+ client: QueryClient;
906
+ queryKey: TQueryKey;
907
+ signal: AbortSignal;
908
+ pageParam: TPageParam;
909
+ /**
910
+ * @deprecated
911
+ * if you want access to the direction, you can add it to the pageParam
912
+ */
913
+ direction: FetchDirection;
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;
947
+ }
948
+ declare interface QueryObserverBaseResult<TData = unknown, TError = DefaultError> {
949
+ /**
950
+ * The last successfully resolved data for the query.
951
+ */
952
+ data: TData | undefined;
953
+ /**
954
+ * The timestamp for when the query most recently returned the `status` as `"success"`.
955
+ */
956
+ dataUpdatedAt: number;
957
+ /**
958
+ * The error object for the query, if an error was thrown.
959
+ * - Defaults to `null`.
960
+ */
961
+ error: TError | null;
962
+ /**
963
+ * The timestamp for when the query most recently returned the `status` as `"error"`.
964
+ */
965
+ errorUpdatedAt: number;
966
+ /**
967
+ * The failure count for the query.
968
+ * - Incremented every time the query fails.
969
+ * - Reset to `0` when the query succeeds.
970
+ */
971
+ failureCount: number;
972
+ /**
973
+ * The failure reason for the query retry.
974
+ * - Reset to `null` when the query succeeds.
975
+ */
976
+ failureReason: TError | null;
977
+ /**
978
+ * The sum of all errors.
979
+ */
980
+ errorUpdateCount: number;
981
+ /**
982
+ * A derived boolean from the `status` variable, provided for convenience.
983
+ * - `true` if the query attempt resulted in an error.
984
+ */
985
+ isError: boolean;
986
+ /**
987
+ * Will be `true` if the query has been fetched.
988
+ */
989
+ isFetched: boolean;
990
+ /**
991
+ * Will be `true` if the query has been fetched after the component mounted.
992
+ * - This property can be used to not show any previously cached data.
993
+ */
994
+ isFetchedAfterMount: boolean;
995
+ /**
996
+ * A derived boolean from the `fetchStatus` variable, provided for convenience.
997
+ * - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch.
998
+ */
999
+ isFetching: boolean;
1000
+ /**
1001
+ * Is `true` whenever the first fetch for a query is in-flight.
1002
+ * - Is the same as `isFetching && isPending`.
1003
+ */
1004
+ isLoading: boolean;
1005
+ /**
1006
+ * Will be `pending` if there's no cached data and no query attempt was finished yet.
1007
+ */
1008
+ isPending: boolean;
1009
+ /**
1010
+ * Will be `true` if the query failed while fetching for the first time.
1011
+ */
1012
+ isLoadingError: boolean;
1013
+ /**
1014
+ * @deprecated `isInitialLoading` is being deprecated in favor of `isLoading`
1015
+ * and will be removed in the next major version.
1016
+ */
1017
+ isInitialLoading: boolean;
1018
+ /**
1019
+ * A derived boolean from the `fetchStatus` variable, provided for convenience.
1020
+ * - The query wanted to fetch, but has been `paused`.
1021
+ */
1022
+ isPaused: boolean;
1023
+ /**
1024
+ * Will be `true` if the data shown is the placeholder data.
1025
+ */
1026
+ isPlaceholderData: boolean;
1027
+ /**
1028
+ * Will be `true` if the query failed while refetching.
1029
+ */
1030
+ isRefetchError: boolean;
1031
+ /**
1032
+ * Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`.
1033
+ * - Is the same as `isFetching && !isPending`.
1034
+ */
1035
+ isRefetching: boolean;
1036
+ /**
1037
+ * Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`.
1038
+ */
1039
+ isStale: boolean;
1040
+ /**
1041
+ * A derived boolean from the `status` variable, provided for convenience.
1042
+ * - `true` if the query has received a response with no errors and is ready to display its data.
1043
+ */
1044
+ isSuccess: boolean;
1045
+ /**
1046
+ * `true` if this observer is enabled, `false` otherwise.
1047
+ */
1048
+ isEnabled: boolean;
1049
+ /**
1050
+ * A function to manually refetch the query.
1051
+ */
1052
+ refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<TData, TError>>;
1053
+ /**
1054
+ * The status of the query.
1055
+ * - Will be:
1056
+ * - `pending` if there's no cached data and no query attempt was finished yet.
1057
+ * - `error` if the query attempt resulted in an error.
1058
+ * - `success` if the query has received a response with no errors and is ready to display its data.
1059
+ */
1060
+ status: QueryStatus;
1061
+ /**
1062
+ * The fetch status of the query.
1063
+ * - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch.
1064
+ * - `paused`: The query wanted to fetch, but has been `paused`.
1065
+ * - `idle`: The query is not fetching.
1066
+ * - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.
1067
+ */
1068
+ fetchStatus: FetchStatus;
1069
+ /**
1070
+ * A stable promise that will be resolved with the data of the query.
1071
+ * Requires the `experimental_prefetchInRender` feature flag to be enabled.
1072
+ * @example
1073
+ *
1074
+ * ### Enabling the feature flag
1075
+ * ```ts
1076
+ * const client = new QueryClient({
1077
+ * defaultOptions: {
1078
+ * queries: {
1079
+ * experimental_prefetchInRender: true,
1080
+ * },
1081
+ * },
1082
+ * })
1083
+ * ```
1084
+ *
1085
+ * ### Usage
1086
+ * ```tsx
1087
+ * import { useQuery } from '@tanstack/react-query'
1088
+ * import React from 'react'
1089
+ * import { fetchTodos, type Todo } from './api'
1090
+ *
1091
+ * function TodoList({ query }: { query: UseQueryResult<Todo[], Error> }) {
1092
+ * const data = React.use(query.promise)
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> {
1121
+ data: undefined;
1122
+ error: TError;
1123
+ isError: true;
1124
+ isPending: false;
1125
+ isLoading: false;
1126
+ isLoadingError: true;
1127
+ isRefetchError: false;
1128
+ isSuccess: false;
1129
+ isPlaceholderData: false;
1130
+ status: 'error';
1131
+ }
1132
+ declare interface QueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
1133
+ data: undefined;
1134
+ error: null;
1135
+ isError: false;
1136
+ isPending: true;
1137
+ isLoading: true;
1138
+ isLoadingError: false;
1139
+ isRefetchError: false;
1140
+ isSuccess: false;
1141
+ isPlaceholderData: false;
1142
+ status: 'pending';
1143
+ }
1144
+ declare 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'> {
1145
+ /**
1146
+ * Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys.
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`.
1150
+ */
1151
+ enabled?: QueryBooleanOption<TQueryFnData, TError, TQueryData, TQueryKey>;
1152
+ /**
1153
+ * The time in milliseconds after data is considered stale.
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`.
1157
+ */
1158
+ staleTime?: StaleTimeFunction<TQueryFnData, TError, TQueryData, TQueryKey>;
1159
+ /**
1160
+ * If set to a number, the query will continuously refetch at this frequency in milliseconds.
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`.
1163
+ */
1164
+ refetchInterval?: number | false | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => number | false | undefined);
1165
+ /**
1166
+ * If set to `true`, the query will continue to refetch while their tab/window is in the background.
1167
+ * Defaults to `false`.
1168
+ */
1169
+ refetchIntervalInBackground?: boolean;
1170
+ /**
1171
+ * If set to `true`, the query will refetch on window focus if the data is stale.
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`.
1176
+ */
1177
+ refetchOnWindowFocus?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
1178
+ /**
1179
+ * If set to `true`, the query will refetch on reconnect if the data is stale.
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`)
1184
+ */
1185
+ refetchOnReconnect?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
1186
+ /**
1187
+ * If set to `true`, the query will refetch on mount if the data is stale.
1188
+ * If set to `false`, will disable additional instances of a query to trigger background refetch.
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`.
1192
+ */
1193
+ refetchOnMount?: boolean | 'always' | ((query: Query<TQueryFnData, TError, TQueryData, TQueryKey>) => boolean | 'always');
1194
+ /**
1195
+ * If set to `false`, the query will not be retried on mount if it contains an error.
1196
+ * If set to a function, the function will be executed with the query to compute the value.
1197
+ * Defaults to `true`.
1198
+ */
1199
+ retryOnMount?: QueryBooleanOption<TQueryFnData, TError, TQueryData, TQueryKey>;
1200
+ /**
1201
+ * If set, the component will only re-render if any of the listed properties change.
1202
+ * When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.
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.
1206
+ */
1207
+ notifyOnChangeProps?: NotifyOnChangeProps;
1208
+ /**
1209
+ * Whether errors should be thrown instead of setting the `error` property.
1210
+ * If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.
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`.
1214
+ */
1215
+ throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>;
1216
+ /**
1217
+ * This option can be used to transform or select a part of the data returned by the query function.
1218
+ */
1219
+ select?: (data: TQueryData) => TData;
1220
+ /**
1221
+ * If set to `true`, the query will suspend when `status === 'pending'`
1222
+ * and throw errors when `status === 'error'`.
1223
+ * Defaults to `false`.
1224
+ */
1225
+ suspense?: boolean;
1226
+ /**
1227
+ * 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.
1228
+ */
1229
+ placeholderData?: NonFunctionGuard<TQueryData> | PlaceholderDataFunction<NonFunctionGuard<TQueryData>, TError, NonFunctionGuard<TQueryData>, TQueryKey>;
1230
+ _optimisticResults?: 'optimistic' | 'isRestoring';
1231
+ /**
1232
+ * Enable prefetching during rendering
1233
+ */
1234
+ experimental_prefetchInRender?: boolean;
1235
+ }
1236
+ declare interface QueryObserverPendingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
1237
+ data: undefined;
1238
+ error: null;
1239
+ isError: false;
1240
+ isPending: true;
1241
+ isLoadingError: false;
1242
+ isRefetchError: false;
1243
+ isSuccess: false;
1244
+ isPlaceholderData: false;
1245
+ status: 'pending';
1246
+ }
1247
+ declare interface QueryObserverPlaceholderResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
1248
+ data: TData;
1249
+ isError: false;
1250
+ error: null;
1251
+ isPending: false;
1252
+ isLoading: false;
1253
+ isLoadingError: false;
1254
+ isRefetchError: false;
1255
+ isSuccess: true;
1256
+ isPlaceholderData: true;
1257
+ status: 'success';
1258
+ }
1259
+ declare interface QueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
1260
+ data: TData;
1261
+ error: TError;
1262
+ isError: true;
1263
+ isPending: false;
1264
+ isLoading: false;
1265
+ isLoadingError: false;
1266
+ isRefetchError: true;
1267
+ isSuccess: false;
1268
+ isPlaceholderData: false;
1269
+ status: 'error';
1270
+ }
1271
+ declare type QueryObserverResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError> | QueryObserverLoadingErrorResult<TData, TError> | QueryObserverLoadingResult<TData, TError> | QueryObserverPendingResult<TData, TError> | QueryObserverPlaceholderResult<TData, TError>;
1272
+ declare interface QueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
1273
+ data: TData;
1274
+ error: null;
1275
+ isError: false;
1276
+ isPending: false;
1277
+ isLoading: false;
1278
+ isLoadingError: false;
1279
+ isRefetchError: false;
1280
+ isSuccess: true;
1281
+ isPlaceholderData: false;
1282
+ status: 'success';
1283
+ }
1284
+ declare interface QueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = never> {
1285
+ /**
1286
+ * If `false`, failed queries will not retry by default.
1287
+ * If `true`, failed queries will retry infinitely., failureCount: num
1288
+ * If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
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;
1353
+ }
1354
+ declare interface RefetchQueryFilters<TQueryKey extends QueryKey = QueryKey> extends QueryFilters<TQueryKey> {}
1355
+ declare interface Register {}
1356
+ declare abstract class Removable {
1357
+ #private;
1358
+ gcTime: number;
1359
+ destroy(): void;
1360
+ protected scheduleGc(): void;
1361
+ protected updateGcTime(newGcTime: number | undefined): void;
1362
+ protected clearGcTimeout(): void;
1363
+ protected abstract optionalRemove(): void;
1364
+ }
1365
+ declare interface ResetOptions extends RefetchOptions {}
1366
+ declare interface ResultOptions {
1367
+ throwOnError?: boolean;
1368
+ }
1369
+ declare type RetryDelayFunction<TError = DefaultError> = (failureCount: number, error: TError) => number;
1370
+ declare type RetryDelayValue<TError> = number | RetryDelayFunction<TError>;
1371
+ declare type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>;
1372
+ declare interface SetDataOptions {
1373
+ updatedAt?: number;
1374
+ }
1375
+ declare interface SetStateAction<TData, TError> {
1376
+ type: 'setState';
1377
+ state: Partial<QueryState<TData, TError>>;
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;
1391
+ }
1392
+ declare interface SuccessAction<TData> {
1393
+ data: TData | undefined;
1394
+ type: 'success';
1395
+ dataUpdatedAt?: number;
1396
+ manual?: boolean;
1397
+ }
1398
+ declare interface SuccessAction_2<TData> {
1399
+ type: 'success';
1400
+ data: TData;
1401
+ }
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
+ //#endregion
1425
+ //#region src/queries/contentQueries.d.ts
1426
+ /**
1427
+ * Query options factory for content queries
1428
+ * Use with TanStack Query's useQuery hook
1429
+ */
1430
+ declare const contentQueries: {
1431
+ /**
1432
+ * Query options for paginated content list
1433
+ * @param params - List parameters including type, pagination, filters
1434
+ */
1435
+ list: <C extends CustomFields = CustomFields>(params?: ContentListParams) => OmitKeyof<_$_tanstack_react_query0.UseQueryOptions<ContentResponse<C>, Error, ContentResponse<C>, readonly ["content", "list", string, ContentListParams]>, "queryFn"> & {
1436
+ 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
+ };
1443
+ /**
1444
+ * Query options for a single content item by ID
1445
+ * @param id - Content item ID
1446
+ */
1447
+ detail: <C extends CustomFields = CustomFields>(id: number) => OmitKeyof<_$_tanstack_react_query0.UseQueryOptions<ApiResponse<ContentDto<C>>, Error, ApiResponse<ContentDto<C>>, readonly ["content", "detail", number]>, "queryFn"> & {
1448
+ 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
+ };
1455
+ /**
1456
+ * Query options for fetching all content items (across all pages)
1457
+ * @param params - List parameters (without page)
1458
+ * @param options - Fetch options including mapping and deduplication
1459
+ */
1460
+ listAll: <C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, "page"> & {
1461
+ page?: never;
1462
+ }, options?: FetchAllOptions<C, T>) => OmitKeyof<_$_tanstack_react_query0.UseQueryOptions<T[], Error, T[], readonly ["content", "all", string, {
1463
+ readonly mode: "all";
1464
+ readonly size?: number;
1465
+ readonly sortBy?: string;
1466
+ readonly direction?: "ASC" | "DESC";
1467
+ readonly type?: string;
1468
+ readonly filters?: Record<string, string | number | boolean | null | undefined>;
1469
+ }]>, "queryFn"> & {
1470
+ queryFn?: QueryFunction<T[], readonly ["content", "all", string, {
1471
+ readonly mode: "all";
1472
+ readonly size?: number;
1473
+ readonly sortBy?: string;
1474
+ readonly direction?: "ASC" | "DESC";
1475
+ readonly type?: string;
1476
+ readonly filters?: Record<string, string | number | boolean | null | undefined>;
1477
+ }], never> | undefined;
1478
+ } & {
1479
+ queryKey: readonly ["content", "all", string, {
1480
+ readonly mode: "all";
1481
+ readonly size?: number;
1482
+ readonly sortBy?: string;
1483
+ readonly direction?: "ASC" | "DESC";
1484
+ readonly type?: string;
1485
+ readonly filters?: Record<string, string | number | boolean | null | undefined>;
1486
+ }] & {
1487
+ [dataTagSymbol]: T[];
1488
+ [dataTagErrorSymbol]: Error;
1489
+ };
1490
+ };
1491
+ };
1492
+ //#endregion
1493
+ //#region src/queries/queryKeys.d.ts
1494
+ /**
1495
+ * Hierarchical query key factory for content queries
1496
+ * Following TanStack Query best practices for key structure
1497
+ */
1498
+ declare const contentKeys: {
1499
+ /**
1500
+ * Base key for all content queries
1501
+ */
1502
+ all: readonly ["content"];
1503
+ /**
1504
+ * Key for all list queries
1505
+ */
1506
+ lists: () => readonly ["content", "list"];
1507
+ /**
1508
+ * Key for a specific list query with parameters
1509
+ * @param type - Content type (e.g., 'NEWS', 'REPORT')
1510
+ * @param params - Additional list parameters
1511
+ */
1512
+ list: (type: string | undefined, params: ContentListParams) => readonly ["content", "list", string, ContentListParams];
1513
+ /**
1514
+ * Key for all detail queries
1515
+ */
1516
+ details: () => readonly ["content", "detail"];
1517
+ /**
1518
+ * Key for a specific detail query by ID
1519
+ * @param id - Content item ID
1520
+ */
1521
+ detail: (id: number) => readonly ["content", "detail", number];
1522
+ /**
1523
+ * Key for all "fetch all" queries
1524
+ */
1525
+ allLists: () => readonly ["content", "all"];
1526
+ /**
1527
+ * Key for a specific "fetch all" query
1528
+ * @param type - Content type
1529
+ * @param params - List parameters (without page)
1530
+ */
1531
+ allList: (type: string | undefined, params: Omit<ContentListParams, "page">) => readonly ["content", "all", string, {
1532
+ readonly mode: "all";
1533
+ readonly size?: number;
1534
+ readonly sortBy?: string;
1535
+ readonly direction?: "ASC" | "DESC";
1536
+ readonly type?: string;
1537
+ readonly filters?: Record<string, string | number | boolean | null | undefined>;
1538
+ }];
1539
+ };
1540
+ //#endregion
1541
+ //#region src/queries/useContentQueries.d.ts
1542
+ /**
1543
+ * Hook for fetching paginated content list
1544
+ * @param params - List parameters including type, pagination, filters
1545
+ */
1546
+ declare function useContentList<C extends CustomFields = CustomFields>(params?: ContentListParams): UseQueryResult<ContentResponse<C>>;
1547
+ /**
1548
+ * Hook for fetching a single content item by ID
1549
+ * @param id - Content item ID
1550
+ */
1551
+ declare function useContentDetail<C extends CustomFields = CustomFields>(id: number): UseQueryResult<ApiResponse<ContentDto<C>>>;
1552
+ /**
1553
+ * Hook for fetching all content items across pages
1554
+ * @param params - List parameters (without page)
1555
+ * @param options - Fetch options including mapping and deduplication
1556
+ */
1557
+ declare function useContentAll<C extends CustomFields = CustomFields, T = ContentDto<C>>(params: Omit<ContentListParams, 'page'> & {
1558
+ page?: never;
1559
+ }, options?: FetchAllOptions<C, T>): UseQueryResult<T[]>;
1560
+ /**
1561
+ * Hook for prefetching content queries
1562
+ * Useful for optimistic navigation and hover effects
1563
+ */
1564
+ declare function useContentPrefetch(): {
1565
+ /**
1566
+ * Prefetch a content list
1567
+ */
1568
+ prefetchList: <C extends CustomFields = CustomFields>(params: ContentListParams) => Promise<void>;
1569
+ /**
1570
+ * Prefetch a content detail
1571
+ */
1572
+ prefetchDetail: <C extends CustomFields = CustomFields>(id: number) => Promise<void>;
1573
+ /**
1574
+ * Invalidate content lists (force refetch)
1575
+ */
1576
+ invalidateLists: () => Promise<void>;
1577
+ /**
1578
+ * Invalidate a specific content detail
1579
+ */
1580
+ invalidateDetail: (id: number) => Promise<void>;
1581
+ /**
1582
+ * Invalidate all content queries
1583
+ */
1584
+ invalidateAll: () => Promise<void>;
1585
+ };
1586
+ //#endregion
1587
+ //#region src/utils/assetUrl.d.ts
1588
+ type BuildAssetUrlOpts = {
1589
+ apiBase?: string;
1590
+ fileBase?: string;
1591
+ };
1592
+ declare const buildAssetUrl: (rawPath?: string | null, opts?: BuildAssetUrlOpts) => string;
1593
+ //#endregion
1594
+ //#region src/utils/normalization.d.ts
1595
+ /**
1596
+ * Normalize a content item to a standard format with asset URLs resolved
1597
+ *
1598
+ * This function provides a default normalization strategy that:
1599
+ * - Extracts common fields from customFields
1600
+ * - Resolves asset URLs using SDK configuration
1601
+ * - Handles PDF path resolution for different content types
1602
+ * - Provides sensible defaults for missing fields
1603
+ *
1604
+ * @param item - Raw content item from the API
1605
+ * @returns Normalized content item
1606
+ */
1607
+ declare function normalizeContentItem<C extends CustomFields = CustomFields>(item: ContentDto<C>): NormalizedContentItem;
1608
+ /**
1609
+ * Build an asset URL using the SDK's configured base URLs
1610
+ * This is a convenience wrapper that automatically uses SDK config
1611
+ *
1612
+ * @param path - Path to the asset (can be relative or absolute)
1613
+ * @returns Full URL to the asset
1614
+ */
1615
+ declare function buildAssetUrlWithConfig(path?: string | null): string;
1616
+ //#endregion
1617
+ //#region src/utils/richText.d.ts
1618
+ /**
1619
+ * Strips HTML tags from a string, returning plain text.
1620
+ *
1621
+ * Uses a regex approach rather than the browser DOM (`document.createElement`)
1622
+ * so it is safe to call in any environment: browser, Node.js, SSR, edge functions.
1623
+ *
1624
+ * Designed for TipTap-generated HTML (paragraphs, bold, italic, lists, links).
1625
+ * Block-level elements (`<p>`, `<li>`, `<br>`) are replaced with a space so
1626
+ * adjacent words from different blocks are not concatenated. The result is
1627
+ * then trimmed and excess internal whitespace is normalized.
1628
+ *
1629
+ * @example
1630
+ * stripHtmlTags('<p>Hello <strong>world</strong></p>') // → 'Hello world'
1631
+ * stripHtmlTags('<ul><li>A</li><li>B</li></ul>') // → 'A B'
1632
+ */
1633
+ declare function stripHtmlTags(html: string): string;
1634
+ /**
1635
+ * Returns `true` if the given string contains HTML markup.
1636
+ *
1637
+ * Specifically detects well-formed opening HTML tags — a `<` followed by a
1638
+ * known tag name and at least one non-`>` character or an immediate `>`.
1639
+ * This avoids false-positives from plain-text angle brackets such as
1640
+ * comparison operators ("if x < 10 then").
1641
+ *
1642
+ * Useful for deciding whether to render a value via a rich text renderer
1643
+ * (TipTap, `dangerouslySetInnerHTML`) or as plain text.
1644
+ *
1645
+ * @example
1646
+ * isHtmlContent('<p>Bold</p>') // → true
1647
+ * isHtmlContent('Just text') // → false
1648
+ * isHtmlContent('if x < 10 then') // → false
1649
+ */
1650
+ declare function isHtmlContent(value: string): boolean;
1651
+ //#endregion
1652
+ //#region src/errors/CmsError.d.ts
1653
+ declare class CmsError extends Error {
1654
+ readonly status?: number;
1655
+ readonly data?: unknown;
1656
+ constructor(message: string, opts?: {
1657
+ status?: number;
1658
+ data?: unknown;
1659
+ cause?: unknown;
1660
+ });
1661
+ }
1662
+ //#endregion
1663
+ //#region src/config/sdkConfig.d.ts
1664
+ /**
1665
+ * Get the current SDK configuration
1666
+ */
1667
+ declare function getConfig(): SdkConfig;
1668
+ /**
1669
+ * Set the SDK configuration
1670
+ */
1671
+ declare function setConfig(config: SdkConfig): void;
1672
+ /**
1673
+ * Check if SDK is initialized
1674
+ */
1675
+ declare function isInitialized(): boolean;
1676
+ /**
1677
+ * Reset configuration (useful for testing)
1678
+ */
1679
+ declare function resetConfig(): void;
1680
+ //#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
+ //# sourceMappingURL=index.d.mts.map