@tanstack/angular-query-experimental 5.60.0 → 5.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{rollup.d.ts → index.d.ts} +278 -356
- package/build/index.js +616 -0
- package/build/index.js.map +1 -0
- package/package.json +12 -15
- package/src/create-base-query.ts +119 -0
- package/src/index.ts +28 -0
- package/src/infinite-query-options.ts +125 -0
- package/src/inject-infinite-query.ts +119 -0
- package/src/inject-is-fetching.ts +50 -0
- package/src/inject-is-mutating.ts +49 -0
- package/src/inject-mutation-state.ts +99 -0
- package/src/inject-mutation.ts +122 -0
- package/src/inject-queries.ts +243 -0
- package/src/inject-query-client.ts +27 -0
- package/src/inject-query.ts +207 -0
- package/src/providers.ts +344 -0
- package/src/query-options.ts +125 -0
- package/src/signal-proxy.ts +46 -0
- package/src/test-setup.ts +12 -0
- package/src/types.ts +328 -0
- package/src/util/assert-injector/assert-injector.test.ts +74 -0
- package/src/util/assert-injector/assert-injector.ts +81 -0
- package/src/util/create-injection-token/create-injection-token.test.ts +32 -0
- package/src/util/create-injection-token/create-injection-token.ts +183 -0
- package/src/util/index.ts +13 -0
- package/src/util/is-dev-mode/is-dev-mode.ts +3 -0
- package/src/util/lazy-init/lazy-init.ts +34 -0
- package/src/util/lazy-signal-initializer/lazy-signal-initializer.ts +23 -0
- package/build/README.md +0 -133
- package/build/esm2022/create-base-query.mjs +0 -62
- package/build/esm2022/index.mjs +0 -16
- package/build/esm2022/infinite-query-options.mjs +0 -12
- package/build/esm2022/inject-infinite-query.mjs +0 -15
- package/build/esm2022/inject-is-fetching.mjs +0 -38
- package/build/esm2022/inject-is-mutating.mjs +0 -37
- package/build/esm2022/inject-mutation-state.mjs +0 -47
- package/build/esm2022/inject-mutation.mjs +0 -51
- package/build/esm2022/inject-queries.mjs +0 -33
- package/build/esm2022/inject-query-client.mjs +0 -23
- package/build/esm2022/inject-query.mjs +0 -44
- package/build/esm2022/providers.mjs +0 -206
- package/build/esm2022/query-options.mjs +0 -26
- package/build/esm2022/signal-proxy.mjs +0 -38
- package/build/esm2022/tanstack-angular-query-experimental.mjs +0 -5
- package/build/esm2022/types.mjs +0 -3
- package/build/esm2022/util/assert-injector/assert-injector.mjs +0 -21
- package/build/esm2022/util/create-injection-token/create-injection-token.mjs +0 -61
- package/build/esm2022/util/index.mjs +0 -9
- package/build/esm2022/util/is-dev-mode/is-dev-mode.mjs +0 -3
- package/build/esm2022/util/lazy-init/lazy-init.mjs +0 -31
- package/build/esm2022/util/lazy-signal-initializer/lazy-signal-initializer.mjs +0 -14
- package/build/fesm2022/tanstack-angular-query-experimental.mjs +0 -738
- package/build/fesm2022/tanstack-angular-query-experimental.mjs.map +0 -1
|
@@ -1,257 +1,183 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import type { InfiniteQueryObserverOptions } from '@tanstack/query-core';
|
|
11
|
-
import type { InfiniteQueryObserverResult } from '@tanstack/query-core';
|
|
12
|
-
import type { InitialDataFunction } from '@tanstack/query-core';
|
|
13
|
-
import { InjectionToken } from '@angular/core';
|
|
14
|
-
import { InjectOptions } from '@angular/core';
|
|
15
|
-
import { Injector } from '@angular/core';
|
|
16
|
-
import type { MutateFunction } from '@tanstack/query-core';
|
|
17
|
-
import type { Mutation } from '@tanstack/query-core';
|
|
18
|
-
import type { MutationFilters } from '@tanstack/query-core';
|
|
19
|
-
import type { MutationObserverOptions } from '@tanstack/query-core';
|
|
20
|
-
import type { MutationObserverResult } from '@tanstack/query-core';
|
|
21
|
-
import type { MutationState } from '@tanstack/query-core';
|
|
22
|
-
import type { OmitKeyof } from '@tanstack/query-core';
|
|
23
|
-
import type { Override } from '@tanstack/query-core';
|
|
24
|
-
import { Provider } from '@angular/core';
|
|
25
|
-
import type { QueriesPlaceholderDataFunction } from '@tanstack/query-core';
|
|
26
|
-
import type { QueryClient } from '@tanstack/query-core';
|
|
27
|
-
import type { QueryFilters } from '@tanstack/query-core';
|
|
28
|
-
import type { QueryFunction } from '@tanstack/query-core';
|
|
29
|
-
import type { QueryKey } from '@tanstack/query-core';
|
|
30
|
-
import type { QueryObserverOptions } from '@tanstack/query-core';
|
|
31
|
-
import type { QueryObserverResult } from '@tanstack/query-core';
|
|
32
|
-
import type { Signal } from '@angular/core';
|
|
33
|
-
import type { ThrowOnError } from '@tanstack/query-core';
|
|
1
|
+
import { DefaultError, QueryKey, QueryObserverOptions, OmitKeyof, InfiniteQueryObserverOptions, QueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverResult, DefinedInfiniteQueryObserverResult, MutationObserverOptions, MutateFunction, Override, MutationObserverResult, InitialDataFunction, DataTag, InfiniteData, QueryClient, QueryFilters, MutationFilters, MutationState, Mutation, QueriesPlaceholderDataFunction, QueryFunction, ThrowOnError } from '@tanstack/query-core';
|
|
2
|
+
export * from '@tanstack/query-core';
|
|
3
|
+
import * as _angular_core from '@angular/core';
|
|
4
|
+
import { Signal, Injector, EnvironmentProviders, Provider } from '@angular/core';
|
|
5
|
+
import { DevtoolsButtonPosition, DevtoolsPosition, DevtoolsErrorType } from '@tanstack/query-devtools';
|
|
6
|
+
|
|
7
|
+
type MapToSignals<T> = {
|
|
8
|
+
[K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>;
|
|
9
|
+
};
|
|
34
10
|
|
|
35
11
|
/**
|
|
36
12
|
* @public
|
|
37
13
|
*/
|
|
38
|
-
|
|
39
|
-
isSuccess: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'success', TData, TError, TVariables, TContext>>>;
|
|
40
|
-
isError: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'error', TData, TError, TVariables, TContext>>>;
|
|
41
|
-
isPending: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'pending', TData, TError, TVariables, TContext>>>;
|
|
42
|
-
isIdle: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'idle', TData, TError, TVariables, TContext>>>;
|
|
14
|
+
interface CreateBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey> {
|
|
43
15
|
}
|
|
44
|
-
|
|
45
16
|
/**
|
|
46
17
|
* @public
|
|
47
18
|
*/
|
|
48
|
-
|
|
49
|
-
isSuccess: (this: CreateBaseQueryResult<TData, TError>) => this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<'success', TData, TError>>;
|
|
50
|
-
isError: (this: CreateBaseQueryResult<TData, TError>) => this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<'error', TData, TError>>;
|
|
51
|
-
isPending: (this: CreateBaseQueryResult<TData, TError>) => this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<'pending', TData, TError>>;
|
|
19
|
+
interface CreateQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> extends OmitKeyof<CreateBaseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'suspense'> {
|
|
52
20
|
}
|
|
53
|
-
|
|
54
21
|
/**
|
|
55
22
|
* @public
|
|
56
23
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
mutateAsync: CreateMutateAsyncFunction<TData, TError, TVariables, TContext>;
|
|
61
|
-
};
|
|
62
|
-
|
|
24
|
+
type CreateStatusBasedQueryResult<TStatus extends QueryObserverResult['status'], TData = unknown, TError = DefaultError> = Extract<QueryObserverResult<TData, TError>, {
|
|
25
|
+
status: TStatus;
|
|
26
|
+
}>;
|
|
63
27
|
/**
|
|
64
28
|
* @public
|
|
65
29
|
*/
|
|
66
|
-
|
|
30
|
+
interface BaseQueryNarrowing<TData = unknown, TError = DefaultError> {
|
|
31
|
+
isSuccess: (this: CreateBaseQueryResult<TData, TError>) => this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<'success', TData, TError>>;
|
|
32
|
+
isError: (this: CreateBaseQueryResult<TData, TError>) => this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<'error', TData, TError>>;
|
|
33
|
+
isPending: (this: CreateBaseQueryResult<TData, TError>) => this is CreateBaseQueryResult<TData, TError, CreateStatusBasedQueryResult<'pending', TData, TError>>;
|
|
67
34
|
}
|
|
68
|
-
|
|
69
35
|
/**
|
|
70
36
|
* @public
|
|
71
37
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
38
|
+
interface CreateInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends OmitKeyof<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TPageParam>, 'suspense'> {
|
|
39
|
+
}
|
|
74
40
|
/**
|
|
75
41
|
* @public
|
|
76
42
|
*/
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
43
|
+
type CreateBaseQueryResult<TData = unknown, TError = DefaultError, TState = QueryObserverResult<TData, TError>> = BaseQueryNarrowing<TData, TError> & MapToSignals<OmitKeyof<TState, keyof BaseQueryNarrowing, 'safely'>>;
|
|
80
44
|
/**
|
|
81
45
|
* @public
|
|
82
46
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
47
|
+
type CreateQueryResult<TData = unknown, TError = DefaultError> = CreateBaseQueryResult<TData, TError>;
|
|
85
48
|
/**
|
|
86
49
|
* @public
|
|
87
50
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
51
|
+
type DefinedCreateQueryResult<TData = unknown, TError = DefaultError, TDefinedQueryObserver = DefinedQueryObserverResult<TData, TError>> = MapToSignals<TDefinedQueryObserver>;
|
|
90
52
|
/**
|
|
91
53
|
* @public
|
|
92
54
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
55
|
+
type CreateInfiniteQueryResult<TData = unknown, TError = DefaultError> = MapToSignals<InfiniteQueryObserverResult<TData, TError>>;
|
|
95
56
|
/**
|
|
96
57
|
* @public
|
|
97
58
|
*/
|
|
98
|
-
|
|
59
|
+
type DefinedCreateInfiniteQueryResult<TData = unknown, TError = DefaultError, TDefinedInfiniteQueryObserver = DefinedInfiniteQueryObserverResult<TData, TError>> = MapToSignals<TDefinedInfiniteQueryObserver>;
|
|
60
|
+
/**
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
interface CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted'> {
|
|
99
64
|
}
|
|
100
|
-
|
|
101
65
|
/**
|
|
102
66
|
* @public
|
|
103
67
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
68
|
+
type CreateMutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = (...args: Parameters<MutateFunction<TData, TError, TVariables, TContext>>) => void;
|
|
106
69
|
/**
|
|
107
70
|
* @public
|
|
108
71
|
*/
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
72
|
+
type CreateMutateAsyncFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = MutateFunction<TData, TError, TVariables, TContext>;
|
|
112
73
|
/**
|
|
113
74
|
* @public
|
|
114
75
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
76
|
+
type CreateBaseMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TContext = unknown> = Override<MutationObserverResult<TData, TError, TVariables, TContext>, {
|
|
77
|
+
mutate: CreateMutateFunction<TData, TError, TVariables, TContext>;
|
|
78
|
+
}> & {
|
|
79
|
+
mutateAsync: CreateMutateAsyncFunction<TData, TError, TVariables, TContext>;
|
|
80
|
+
};
|
|
117
81
|
/**
|
|
118
82
|
* @public
|
|
119
83
|
*/
|
|
120
|
-
|
|
84
|
+
type CreateStatusBasedMutationResult<TStatus extends CreateBaseMutationResult['status'], TData = unknown, TError = DefaultError, TVariables = unknown, TContext = unknown> = Extract<CreateBaseMutationResult<TData, TError, TVariables, TContext>, {
|
|
121
85
|
status: TStatus;
|
|
122
86
|
}>;
|
|
123
|
-
|
|
87
|
+
type SignalFunction<T extends () => any> = T & Signal<ReturnType<T>>;
|
|
124
88
|
/**
|
|
125
89
|
* @public
|
|
126
90
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
91
|
+
interface BaseMutationNarrowing<TData = unknown, TError = DefaultError, TVariables = unknown, TContext = unknown> {
|
|
92
|
+
isSuccess: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'success', TData, TError, TVariables, TContext>>>;
|
|
93
|
+
isError: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'error', TData, TError, TVariables, TContext>>>;
|
|
94
|
+
isPending: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'pending', TData, TError, TVariables, TContext>>>;
|
|
95
|
+
isIdle: SignalFunction<(this: CreateMutationResult<TData, TError, TVariables, TContext>) => this is CreateMutationResult<TData, TError, TVariables, TContext, CreateStatusBasedMutationResult<'idle', TData, TError, TVariables, TContext>>>;
|
|
96
|
+
}
|
|
131
97
|
/**
|
|
132
98
|
* @public
|
|
133
99
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
100
|
+
type CreateMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TContext = unknown, TState = CreateStatusBasedMutationResult<CreateBaseMutationResult['status'], TData, TError, TVariables, TContext>> = BaseMutationNarrowing<TData, TError, TVariables, TContext> & MapToSignals<OmitKeyof<TState, keyof BaseMutationNarrowing, 'safely'>>;
|
|
136
101
|
/**
|
|
137
102
|
* @public
|
|
138
103
|
*/
|
|
139
|
-
|
|
104
|
+
type NonUndefinedGuard<T> = T extends undefined ? never : T;
|
|
140
105
|
|
|
141
106
|
/**
|
|
142
107
|
* @public
|
|
143
108
|
*/
|
|
144
|
-
|
|
145
|
-
initialData
|
|
109
|
+
type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
110
|
+
initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>;
|
|
146
111
|
};
|
|
147
|
-
|
|
148
112
|
/**
|
|
149
113
|
* @public
|
|
150
114
|
*/
|
|
151
|
-
|
|
115
|
+
type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
152
116
|
initialData: NonUndefinedGuard<TQueryFnData> | (() => NonUndefinedGuard<TQueryFnData>);
|
|
153
117
|
};
|
|
154
|
-
|
|
155
118
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
119
|
+
* Allows to share and re-use query options in a type-safe way.
|
|
120
|
+
*
|
|
121
|
+
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
122
|
+
*
|
|
123
|
+
* **Example**
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* const { queryKey } = queryOptions({
|
|
127
|
+
* queryKey: ['key'],
|
|
128
|
+
* queryFn: () => Promise.resolve(5),
|
|
129
|
+
* // ^? Promise<number>
|
|
130
|
+
* })
|
|
131
|
+
*
|
|
132
|
+
* const queryClient = new QueryClient()
|
|
133
|
+
* const data = queryClient.getQueryData(queryKey)
|
|
134
|
+
* // ^? number | undefined
|
|
135
|
+
* ```
|
|
136
|
+
* @param options - The query options to tag with the type from `queryFn`.
|
|
137
|
+
* @returns The tagged query options.
|
|
158
138
|
* @public
|
|
159
|
-
* @see {@link withDevtools}
|
|
160
139
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
140
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
141
|
+
queryKey: DataTag<TQueryKey, TQueryFnData>;
|
|
142
|
+
};
|
|
163
143
|
/**
|
|
164
|
-
*
|
|
144
|
+
* Allows to share and re-use query options in a type-safe way.
|
|
145
|
+
*
|
|
146
|
+
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
147
|
+
*
|
|
148
|
+
* **Example**
|
|
149
|
+
*
|
|
150
|
+
* ```ts
|
|
151
|
+
* const { queryKey } = queryOptions({
|
|
152
|
+
* queryKey: ['key'],
|
|
153
|
+
* queryFn: () => Promise.resolve(5),
|
|
154
|
+
* // ^? Promise<number>
|
|
155
|
+
* })
|
|
156
|
+
*
|
|
157
|
+
* const queryClient = new QueryClient()
|
|
158
|
+
* const data = queryClient.getQueryData(queryKey)
|
|
159
|
+
* // ^? number | undefined
|
|
160
|
+
* ```
|
|
161
|
+
* @param options - The query options to tag with the type from `queryFn`.
|
|
162
|
+
* @returns The tagged query options.
|
|
165
163
|
* @public
|
|
166
164
|
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*/
|
|
171
|
-
initialIsOpen?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* The position of the TanStack logo to open and close the devtools panel.
|
|
174
|
-
* `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`
|
|
175
|
-
* Defaults to `bottom-right`.
|
|
176
|
-
*/
|
|
177
|
-
buttonPosition?: DevtoolsButtonPosition;
|
|
178
|
-
/**
|
|
179
|
-
* The position of the TanStack Query devtools panel.
|
|
180
|
-
* `top` | `bottom` | `left` | `right`
|
|
181
|
-
* Defaults to `bottom`.
|
|
182
|
-
*/
|
|
183
|
-
position?: DevtoolsPosition;
|
|
184
|
-
/**
|
|
185
|
-
* Custom instance of QueryClient
|
|
186
|
-
*/
|
|
187
|
-
client?: QueryClient;
|
|
188
|
-
/**
|
|
189
|
-
* Use this so you can define custom errors that can be shown in the devtools.
|
|
190
|
-
*/
|
|
191
|
-
errorTypes?: Array<DevtoolsErrorType>;
|
|
192
|
-
/**
|
|
193
|
-
* Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
|
|
194
|
-
*/
|
|
195
|
-
styleNonce?: string;
|
|
196
|
-
/**
|
|
197
|
-
* Use this so you can attach the devtool's styles to a specific element in the DOM.
|
|
198
|
-
*/
|
|
199
|
-
shadowDOMTarget?: ShadowRoot;
|
|
200
|
-
/**
|
|
201
|
-
* Whether the developer tools should load.
|
|
202
|
-
* - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.
|
|
203
|
-
* - `true`- Always load the devtools, regardless of the environment.
|
|
204
|
-
* - `false`- Never load the devtools, regardless of the environment.
|
|
205
|
-
*
|
|
206
|
-
* You can use `true` and `false` to override loading developer tools from an environment file.
|
|
207
|
-
* For example, a test environment might run in production mode but you may want to load developer tools.
|
|
208
|
-
*
|
|
209
|
-
* Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,
|
|
210
|
-
* a signal created from a RxJS observable that listens for a keyboard shortcut.
|
|
211
|
-
*
|
|
212
|
-
* **Example**
|
|
213
|
-
* ```ts
|
|
214
|
-
* withDevtools(() => ({
|
|
215
|
-
* initialIsOpen: true,
|
|
216
|
-
* loadDevtools: inject(ExampleService).loadDevtools()
|
|
217
|
-
* }))
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
loadDevtools?: 'auto' | boolean;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
declare type GetOptions<T> = T extends {
|
|
224
|
-
queryFnData: infer TQueryFnData;
|
|
225
|
-
error?: infer TError;
|
|
226
|
-
data: infer TData;
|
|
227
|
-
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends {
|
|
228
|
-
queryFnData: infer TQueryFnData;
|
|
229
|
-
error?: infer TError;
|
|
230
|
-
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError> : T extends {
|
|
231
|
-
data: infer TData;
|
|
232
|
-
error?: infer TError;
|
|
233
|
-
} ? QueryObserverOptionsForCreateQueries<unknown, TError, TData> : T extends [infer TQueryFnData, infer TError, infer TData] ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends [infer TQueryFnData, infer TError] ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError> : T extends [infer TQueryFnData] ? QueryObserverOptionsForCreateQueries<TQueryFnData> : T extends {
|
|
234
|
-
queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey> | SkipTokenForUseQueries;
|
|
235
|
-
select: (data: any) => infer TData;
|
|
236
|
-
throwOnError?: ThrowOnError<any, infer TError, any, any>;
|
|
237
|
-
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, unknown extends TError ? DefaultError : TError, unknown extends TData ? TQueryFnData : TData, TQueryKey> : QueryObserverOptionsForCreateQueries;
|
|
238
|
-
|
|
239
|
-
declare type GetResults<T> = T extends {
|
|
240
|
-
queryFnData: any;
|
|
241
|
-
error?: infer TError;
|
|
242
|
-
data: infer TData;
|
|
243
|
-
} ? QueryObserverResult<TData, TError> : T extends {
|
|
244
|
-
queryFnData: infer TQueryFnData;
|
|
245
|
-
error?: infer TError;
|
|
246
|
-
} ? QueryObserverResult<TQueryFnData, TError> : T extends {
|
|
247
|
-
data: infer TData;
|
|
248
|
-
error?: infer TError;
|
|
249
|
-
} ? QueryObserverResult<TData, TError> : T extends [any, infer TError, infer TData] ? QueryObserverResult<TData, TError> : T extends [infer TQueryFnData, infer TError] ? QueryObserverResult<TQueryFnData, TError> : T extends [infer TQueryFnData] ? QueryObserverResult<TQueryFnData> : T extends {
|
|
250
|
-
queryFn?: QueryFunction<infer TQueryFnData, any> | SkipTokenForUseQueries;
|
|
251
|
-
select: (data: any) => infer TData;
|
|
252
|
-
throwOnError?: ThrowOnError<any, infer TError, any, any>;
|
|
253
|
-
} ? QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError> : QueryObserverResult;
|
|
165
|
+
declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
166
|
+
queryKey: DataTag<TQueryKey, TQueryFnData>;
|
|
167
|
+
};
|
|
254
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam> & {
|
|
173
|
+
initialData?: undefined;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam> & {
|
|
179
|
+
initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>);
|
|
180
|
+
};
|
|
255
181
|
/**
|
|
256
182
|
* Allows to share and re-use infinite query options in a type-safe way.
|
|
257
183
|
*
|
|
@@ -260,10 +186,9 @@ declare type GetResults<T> = T extends {
|
|
|
260
186
|
* @returns The tagged infinite query options.
|
|
261
187
|
* @public
|
|
262
188
|
*/
|
|
263
|
-
|
|
189
|
+
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
264
190
|
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>;
|
|
265
191
|
};
|
|
266
|
-
|
|
267
192
|
/**
|
|
268
193
|
* Allows to share and re-use infinite query options in a type-safe way.
|
|
269
194
|
*
|
|
@@ -272,7 +197,7 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
|
|
|
272
197
|
* @returns The tagged infinite query options.
|
|
273
198
|
* @public
|
|
274
199
|
*/
|
|
275
|
-
|
|
200
|
+
declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
|
|
276
201
|
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>;
|
|
277
202
|
};
|
|
278
203
|
|
|
@@ -284,8 +209,7 @@ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError
|
|
|
284
209
|
* @returns The infinite query result.
|
|
285
210
|
* @public
|
|
286
211
|
*/
|
|
287
|
-
|
|
288
|
-
|
|
212
|
+
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(optionsFn: (client: QueryClient) => DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, injector?: Injector): DefinedCreateInfiniteQueryResult<TData, TError>;
|
|
289
213
|
/**
|
|
290
214
|
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
291
215
|
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
@@ -294,8 +218,7 @@ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError,
|
|
|
294
218
|
* @returns The infinite query result.
|
|
295
219
|
* @public
|
|
296
220
|
*/
|
|
297
|
-
|
|
298
|
-
|
|
221
|
+
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(optionsFn: (client: QueryClient) => UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, injector?: Injector): CreateInfiniteQueryResult<TData, TError>;
|
|
299
222
|
/**
|
|
300
223
|
* Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
301
224
|
* Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
|
|
@@ -304,7 +227,7 @@ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError,
|
|
|
304
227
|
* @returns The infinite query result.
|
|
305
228
|
* @public
|
|
306
229
|
*/
|
|
307
|
-
|
|
230
|
+
declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(optionsFn: (client: QueryClient) => CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam>, injector?: Injector): CreateInfiniteQueryResult<TData, TError>;
|
|
308
231
|
|
|
309
232
|
/**
|
|
310
233
|
* Injects a signal that tracks the number of queries that your application is loading or
|
|
@@ -316,7 +239,7 @@ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError,
|
|
|
316
239
|
* @returns signal with number of loading or fetching queries.
|
|
317
240
|
* @public
|
|
318
241
|
*/
|
|
319
|
-
|
|
242
|
+
declare function injectIsFetching(filters?: QueryFilters, injector?: Injector): Signal<number>;
|
|
320
243
|
|
|
321
244
|
/**
|
|
322
245
|
* Injects a signal that tracks the number of mutations that your application is fetching.
|
|
@@ -327,7 +250,7 @@ export declare function injectIsFetching(filters?: QueryFilters, injector?: Inje
|
|
|
327
250
|
* @returns signal with number of fetching mutations.
|
|
328
251
|
* @public
|
|
329
252
|
*/
|
|
330
|
-
|
|
253
|
+
declare function injectIsMutating(filters?: MutationFilters, injector?: Injector): Signal<number>;
|
|
331
254
|
|
|
332
255
|
/**
|
|
333
256
|
* Injects a mutation: an imperative function that can be invoked which typically performs server side effects.
|
|
@@ -338,8 +261,18 @@ export declare function injectIsMutating(filters?: MutationFilters, injector?: I
|
|
|
338
261
|
* @returns The mutation.
|
|
339
262
|
* @public
|
|
340
263
|
*/
|
|
341
|
-
|
|
264
|
+
declare function injectMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(optionsFn: (client: QueryClient) => CreateMutationOptions<TData, TError, TVariables, TContext>, injector?: Injector): CreateMutationResult<TData, TError, TVariables, TContext>;
|
|
342
265
|
|
|
266
|
+
type MutationStateOptions<TResult = MutationState> = {
|
|
267
|
+
filters?: MutationFilters;
|
|
268
|
+
select?: (mutation: Mutation) => TResult;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
interface InjectMutationStateOptions {
|
|
274
|
+
injector?: Injector;
|
|
275
|
+
}
|
|
343
276
|
/**
|
|
344
277
|
* Injects a signal that tracks the state of all mutations.
|
|
345
278
|
* @param mutationStateOptionsFn - A function that returns mutation state options.
|
|
@@ -347,19 +280,73 @@ export declare function injectMutation<TData = unknown, TError = DefaultError, T
|
|
|
347
280
|
* @returns The signal that tracks the state of all mutations.
|
|
348
281
|
* @public
|
|
349
282
|
*/
|
|
350
|
-
|
|
283
|
+
declare function injectMutationState<TResult = MutationState>(mutationStateOptionsFn?: () => MutationStateOptions<TResult>, options?: InjectMutationStateOptions): Signal<Array<TResult>>;
|
|
351
284
|
|
|
285
|
+
type QueryObserverOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'placeholderData'> & {
|
|
286
|
+
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
287
|
+
};
|
|
288
|
+
type MAXIMUM_DEPTH = 20;
|
|
289
|
+
type SkipTokenForUseQueries = symbol;
|
|
290
|
+
type GetOptions<T> = T extends {
|
|
291
|
+
queryFnData: infer TQueryFnData;
|
|
292
|
+
error?: infer TError;
|
|
293
|
+
data: infer TData;
|
|
294
|
+
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends {
|
|
295
|
+
queryFnData: infer TQueryFnData;
|
|
296
|
+
error?: infer TError;
|
|
297
|
+
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError> : T extends {
|
|
298
|
+
data: infer TData;
|
|
299
|
+
error?: infer TError;
|
|
300
|
+
} ? QueryObserverOptionsForCreateQueries<unknown, TError, TData> : T extends [infer TQueryFnData, infer TError, infer TData] ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends [infer TQueryFnData, infer TError] ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError> : T extends [infer TQueryFnData] ? QueryObserverOptionsForCreateQueries<TQueryFnData> : T extends {
|
|
301
|
+
queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey> | SkipTokenForUseQueries;
|
|
302
|
+
select: (data: any) => infer TData;
|
|
303
|
+
throwOnError?: ThrowOnError<any, infer TError, any, any>;
|
|
304
|
+
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, unknown extends TError ? DefaultError : TError, unknown extends TData ? TQueryFnData : TData, TQueryKey> : QueryObserverOptionsForCreateQueries;
|
|
305
|
+
type GetResults<T> = T extends {
|
|
306
|
+
queryFnData: any;
|
|
307
|
+
error?: infer TError;
|
|
308
|
+
data: infer TData;
|
|
309
|
+
} ? QueryObserverResult<TData, TError> : T extends {
|
|
310
|
+
queryFnData: infer TQueryFnData;
|
|
311
|
+
error?: infer TError;
|
|
312
|
+
} ? QueryObserverResult<TQueryFnData, TError> : T extends {
|
|
313
|
+
data: infer TData;
|
|
314
|
+
error?: infer TError;
|
|
315
|
+
} ? QueryObserverResult<TData, TError> : T extends [any, infer TError, infer TData] ? QueryObserverResult<TData, TError> : T extends [infer TQueryFnData, infer TError] ? QueryObserverResult<TQueryFnData, TError> : T extends [infer TQueryFnData] ? QueryObserverResult<TQueryFnData> : T extends {
|
|
316
|
+
queryFn?: QueryFunction<infer TQueryFnData, any> | SkipTokenForUseQueries;
|
|
317
|
+
select: (data: any) => infer TData;
|
|
318
|
+
throwOnError?: ThrowOnError<any, infer TError, any, any>;
|
|
319
|
+
} ? QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError> : QueryObserverResult;
|
|
352
320
|
/**
|
|
321
|
+
* QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
353
322
|
* @public
|
|
354
323
|
*/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
324
|
+
type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<QueryObserverOptionsForCreateQueries> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetOptions<Head>] : T extends [infer Head, ...infer Tail] ? QueriesOptions<[
|
|
325
|
+
...Tail
|
|
326
|
+
], [
|
|
327
|
+
...TResult,
|
|
328
|
+
GetOptions<Head>
|
|
329
|
+
], [
|
|
330
|
+
...TDepth,
|
|
331
|
+
1
|
|
332
|
+
]> : ReadonlyArray<unknown> extends T ? T : T extends Array<QueryObserverOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>> : Array<QueryObserverOptionsForCreateQueries>;
|
|
333
|
+
/**
|
|
334
|
+
* QueriesResults reducer recursively maps type param to results
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
type QueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<QueryObserverResult> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[
|
|
338
|
+
...Tail
|
|
339
|
+
], [
|
|
340
|
+
...TResult,
|
|
341
|
+
GetResults<Head>
|
|
342
|
+
], [
|
|
343
|
+
...TDepth,
|
|
344
|
+
1
|
|
345
|
+
]> : T extends Array<QueryObserverOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, any>> ? Array<QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError>> : Array<QueryObserverResult>;
|
|
359
346
|
/**
|
|
360
347
|
* @public
|
|
361
348
|
*/
|
|
362
|
-
|
|
349
|
+
declare function injectQueries<T extends Array<any>, TCombinedResult = QueriesResults<T>>({ queries, ...options }: {
|
|
363
350
|
queries: Signal<[...QueriesOptions<T>]>;
|
|
364
351
|
combine?: (result: QueriesResults<T>) => TCombinedResult;
|
|
365
352
|
}, injector?: Injector): Signal<TCombinedResult>;
|
|
@@ -401,8 +388,7 @@ export declare function injectQueries<T extends Array<any>, TCombinedResult = Qu
|
|
|
401
388
|
* @public
|
|
402
389
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
403
390
|
*/
|
|
404
|
-
|
|
405
|
-
|
|
391
|
+
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(optionsFn: (client: QueryClient) => DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, injector?: Injector): DefinedCreateQueryResult<TData, TError>;
|
|
406
392
|
/**
|
|
407
393
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
408
394
|
*
|
|
@@ -440,8 +426,7 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
440
426
|
* @public
|
|
441
427
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
442
428
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
429
|
+
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(optionsFn: (client: QueryClient) => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, injector?: Injector): CreateQueryResult<TData, TError>;
|
|
445
430
|
/**
|
|
446
431
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
447
432
|
*
|
|
@@ -479,7 +464,7 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
479
464
|
* @public
|
|
480
465
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
481
466
|
*/
|
|
482
|
-
|
|
467
|
+
declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(optionsFn: (client: QueryClient) => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, injector?: Injector): CreateQueryResult<TData, TError>;
|
|
483
468
|
|
|
484
469
|
/**
|
|
485
470
|
* Injects the `QueryClient` instance into the component or service.
|
|
@@ -491,46 +476,17 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
491
476
|
* @returns The `QueryClient` instance.
|
|
492
477
|
* @public
|
|
493
478
|
*/
|
|
494
|
-
|
|
479
|
+
declare const injectQueryClient: {
|
|
495
480
|
(): QueryClient;
|
|
496
|
-
(injectOptions: InjectOptions & {
|
|
497
|
-
optional?: false;
|
|
481
|
+
(injectOptions: _angular_core.InjectOptions & {
|
|
482
|
+
optional?: false | undefined;
|
|
498
483
|
} & {
|
|
499
|
-
injector?: Injector;
|
|
500
|
-
}): QueryClient;
|
|
501
|
-
(injectOptions: InjectOptions & {
|
|
502
|
-
injector?: Injector;
|
|
484
|
+
injector?: _angular_core.Injector | undefined;
|
|
503
485
|
}): QueryClient;
|
|
486
|
+
(injectOptions: _angular_core.InjectOptions & {
|
|
487
|
+
injector?: _angular_core.Injector | undefined;
|
|
488
|
+
}): QueryClient | null;
|
|
504
489
|
};
|
|
505
|
-
|
|
506
|
-
declare type MapToSignals<T> = {
|
|
507
|
-
[K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>;
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
declare type MAXIMUM_DEPTH = 20;
|
|
511
|
-
|
|
512
|
-
declare type MutationStateOptions<TResult = MutationState> = {
|
|
513
|
-
filters?: MutationFilters;
|
|
514
|
-
select?: (mutation: Mutation) => TResult;
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* @public
|
|
519
|
-
*/
|
|
520
|
-
export declare type NonUndefinedGuard<T> = T extends undefined ? never : T;
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Sets up providers necessary to enable TanStack Query functionality for Angular applications.
|
|
524
|
-
*
|
|
525
|
-
* Allows to configure a `QueryClient`.
|
|
526
|
-
* @param queryClient - A `QueryClient` instance.
|
|
527
|
-
* @returns A set of providers to set up TanStack Query.
|
|
528
|
-
* @public
|
|
529
|
-
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
|
|
530
|
-
* @deprecated Use `provideTanStackQuery` instead.
|
|
531
|
-
*/
|
|
532
|
-
export declare function provideAngularQuery(queryClient: QueryClient): EnvironmentProviders;
|
|
533
|
-
|
|
534
490
|
/**
|
|
535
491
|
* Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the
|
|
536
492
|
* {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
|
|
@@ -538,7 +494,8 @@ export declare function provideAngularQuery(queryClient: QueryClient): Environme
|
|
|
538
494
|
* different `QueryClient` instance for a part of the application.
|
|
539
495
|
* @public
|
|
540
496
|
*/
|
|
541
|
-
|
|
497
|
+
declare const provideQueryClient: ((value: QueryClient | (() => QueryClient)) => _angular_core.Provider) & ((value: QueryClient | (() => QueryClient)) => _angular_core.Provider);
|
|
498
|
+
declare const QUERY_CLIENT: _angular_core.InjectionToken<QueryClient>;
|
|
542
499
|
|
|
543
500
|
/**
|
|
544
501
|
* Sets up providers necessary to enable TanStack Query functionality for Angular applications.
|
|
@@ -599,134 +556,91 @@ export declare const provideQueryClient: ((value: QueryClient | (() => QueryClie
|
|
|
599
556
|
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
|
|
600
557
|
* @see withDevtools
|
|
601
558
|
*/
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
606
|
-
* @public
|
|
607
|
-
*/
|
|
608
|
-
export declare type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<QueryObserverOptionsForCreateQueries> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetOptions<Head>] : T extends [infer Head, ...infer Tail] ? QueriesOptions<[
|
|
609
|
-
...Tail
|
|
610
|
-
], [
|
|
611
|
-
...TResult,
|
|
612
|
-
GetOptions<Head>
|
|
613
|
-
], [
|
|
614
|
-
...TDepth,
|
|
615
|
-
1
|
|
616
|
-
]> : ReadonlyArray<unknown> extends T ? T : T extends Array<QueryObserverOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>> : Array<QueryObserverOptionsForCreateQueries>;
|
|
617
|
-
|
|
559
|
+
declare function provideTanStackQuery(queryClient: QueryClient, ...features: Array<QueryFeatures>): EnvironmentProviders;
|
|
618
560
|
/**
|
|
619
|
-
*
|
|
561
|
+
* Sets up providers necessary to enable TanStack Query functionality for Angular applications.
|
|
562
|
+
*
|
|
563
|
+
* Allows to configure a `QueryClient`.
|
|
564
|
+
* @param queryClient - A `QueryClient` instance.
|
|
565
|
+
* @returns A set of providers to set up TanStack Query.
|
|
620
566
|
* @public
|
|
567
|
+
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
|
|
568
|
+
* @deprecated Use `provideTanStackQuery` instead.
|
|
621
569
|
*/
|
|
622
|
-
|
|
623
|
-
...Tail
|
|
624
|
-
], [
|
|
625
|
-
...TResult,
|
|
626
|
-
GetResults<Head>
|
|
627
|
-
], [
|
|
628
|
-
...TDepth,
|
|
629
|
-
1
|
|
630
|
-
]> : T extends Array<QueryObserverOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, any>> ? Array<QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError>> : Array<QueryObserverResult>;
|
|
631
|
-
|
|
632
|
-
export declare const QUERY_CLIENT: InjectionToken<QueryClient>;
|
|
633
|
-
|
|
570
|
+
declare function provideAngularQuery(queryClient: QueryClient): EnvironmentProviders;
|
|
634
571
|
/**
|
|
635
572
|
* Helper type to represent a Query feature.
|
|
636
573
|
*/
|
|
637
|
-
|
|
574
|
+
interface QueryFeature<TFeatureKind extends QueryFeatureKind> {
|
|
638
575
|
ɵkind: TFeatureKind;
|
|
639
576
|
ɵproviders: Array<Provider>;
|
|
640
577
|
}
|
|
641
|
-
|
|
642
|
-
export declare type QueryFeatureKind = (typeof queryFeatures)[number];
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* A type alias that represents all Query features available for use with `provideTanStackQuery`.
|
|
646
|
-
* Features can be enabled by adding special functions to the `provideTanStackQuery` call.
|
|
647
|
-
* See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`
|
|
648
|
-
* documentation on how to use those functions.
|
|
649
|
-
* @public
|
|
650
|
-
* @see {@link provideTanStackQuery}
|
|
651
|
-
*/
|
|
652
|
-
export declare type QueryFeatures = DeveloperToolsFeature;
|
|
653
|
-
|
|
654
|
-
export declare const queryFeatures: readonly ["DeveloperTools"];
|
|
655
|
-
|
|
656
|
-
declare type QueryObserverOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'placeholderData'> & {
|
|
657
|
-
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
658
|
-
};
|
|
659
|
-
|
|
660
|
-
/**
|
|
661
|
-
* Allows to share and re-use query options in a type-safe way.
|
|
662
|
-
*
|
|
663
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
664
|
-
*
|
|
665
|
-
* **Example**
|
|
666
|
-
*
|
|
667
|
-
* ```ts
|
|
668
|
-
* const { queryKey } = queryOptions({
|
|
669
|
-
* queryKey: ['key'],
|
|
670
|
-
* queryFn: () => Promise.resolve(5),
|
|
671
|
-
* // ^? Promise<number>
|
|
672
|
-
* })
|
|
673
|
-
*
|
|
674
|
-
* const queryClient = new QueryClient()
|
|
675
|
-
* const data = queryClient.getQueryData(queryKey)
|
|
676
|
-
* // ^? number | undefined
|
|
677
|
-
* ```
|
|
678
|
-
* @param options - The query options to tag with the type from `queryFn`.
|
|
679
|
-
* @returns The tagged query options.
|
|
680
|
-
* @public
|
|
681
|
-
*/
|
|
682
|
-
export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
683
|
-
queryKey: DataTag<TQueryKey, TQueryFnData>;
|
|
684
|
-
};
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Allows to share and re-use query options in a type-safe way.
|
|
688
|
-
*
|
|
689
|
-
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
690
|
-
*
|
|
691
|
-
* **Example**
|
|
692
|
-
*
|
|
693
|
-
* ```ts
|
|
694
|
-
* const { queryKey } = queryOptions({
|
|
695
|
-
* queryKey: ['key'],
|
|
696
|
-
* queryFn: () => Promise.resolve(5),
|
|
697
|
-
* // ^? Promise<number>
|
|
698
|
-
* })
|
|
699
|
-
*
|
|
700
|
-
* const queryClient = new QueryClient()
|
|
701
|
-
* const data = queryClient.getQueryData(queryKey)
|
|
702
|
-
* // ^? number | undefined
|
|
703
|
-
* ```
|
|
704
|
-
* @param options - The query options to tag with the type from `queryFn`.
|
|
705
|
-
* @returns The tagged query options.
|
|
706
|
-
* @public
|
|
707
|
-
*/
|
|
708
|
-
export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
709
|
-
queryKey: DataTag<TQueryKey, TQueryFnData>;
|
|
710
|
-
};
|
|
711
|
-
|
|
712
|
-
declare type SignalFunction<T extends () => any> = T & Signal<ReturnType<T>>;
|
|
713
|
-
|
|
714
|
-
declare type SkipTokenForUseQueries = symbol;
|
|
715
|
-
|
|
716
578
|
/**
|
|
579
|
+
* A type alias that represents a feature which enables developer tools.
|
|
580
|
+
* The type is used to describe the return value of the `withDevtools` function.
|
|
717
581
|
* @public
|
|
582
|
+
* @see {@link withDevtools}
|
|
718
583
|
*/
|
|
719
|
-
|
|
720
|
-
initialData?: undefined;
|
|
721
|
-
};
|
|
722
|
-
|
|
584
|
+
type DeveloperToolsFeature = QueryFeature<'DeveloperTools'>;
|
|
723
585
|
/**
|
|
586
|
+
* Options for configuring the TanStack Query devtools.
|
|
724
587
|
* @public
|
|
725
588
|
*/
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
589
|
+
interface DevtoolsOptions {
|
|
590
|
+
/**
|
|
591
|
+
* Set this true if you want the devtools to default to being open
|
|
592
|
+
*/
|
|
593
|
+
initialIsOpen?: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* The position of the TanStack logo to open and close the devtools panel.
|
|
596
|
+
* `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`
|
|
597
|
+
* Defaults to `bottom-right`.
|
|
598
|
+
*/
|
|
599
|
+
buttonPosition?: DevtoolsButtonPosition;
|
|
600
|
+
/**
|
|
601
|
+
* The position of the TanStack Query devtools panel.
|
|
602
|
+
* `top` | `bottom` | `left` | `right`
|
|
603
|
+
* Defaults to `bottom`.
|
|
604
|
+
*/
|
|
605
|
+
position?: DevtoolsPosition;
|
|
606
|
+
/**
|
|
607
|
+
* Custom instance of QueryClient
|
|
608
|
+
*/
|
|
609
|
+
client?: QueryClient;
|
|
610
|
+
/**
|
|
611
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
612
|
+
*/
|
|
613
|
+
errorTypes?: Array<DevtoolsErrorType>;
|
|
614
|
+
/**
|
|
615
|
+
* Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.
|
|
616
|
+
*/
|
|
617
|
+
styleNonce?: string;
|
|
618
|
+
/**
|
|
619
|
+
* Use this so you can attach the devtool's styles to a specific element in the DOM.
|
|
620
|
+
*/
|
|
621
|
+
shadowDOMTarget?: ShadowRoot;
|
|
622
|
+
/**
|
|
623
|
+
* Whether the developer tools should load.
|
|
624
|
+
* - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.
|
|
625
|
+
* - `true`- Always load the devtools, regardless of the environment.
|
|
626
|
+
* - `false`- Never load the devtools, regardless of the environment.
|
|
627
|
+
*
|
|
628
|
+
* You can use `true` and `false` to override loading developer tools from an environment file.
|
|
629
|
+
* For example, a test environment might run in production mode but you may want to load developer tools.
|
|
630
|
+
*
|
|
631
|
+
* Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,
|
|
632
|
+
* a signal created from a RxJS observable that listens for a keyboard shortcut.
|
|
633
|
+
*
|
|
634
|
+
* **Example**
|
|
635
|
+
* ```ts
|
|
636
|
+
* withDevtools(() => ({
|
|
637
|
+
* initialIsOpen: true,
|
|
638
|
+
* loadDevtools: inject(ExampleService).loadDevtools()
|
|
639
|
+
* }))
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
loadDevtools?: 'auto' | boolean;
|
|
643
|
+
}
|
|
730
644
|
/**
|
|
731
645
|
* Enables developer tools.
|
|
732
646
|
*
|
|
@@ -750,9 +664,17 @@ export declare type UndefinedInitialDataOptions<TQueryFnData = unknown, TError =
|
|
|
750
664
|
* @see {@link provideTanStackQuery}
|
|
751
665
|
* @see {@link DevtoolsOptions}
|
|
752
666
|
*/
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
667
|
+
declare function withDevtools(optionsFn?: () => DevtoolsOptions): DeveloperToolsFeature;
|
|
668
|
+
/**
|
|
669
|
+
* A type alias that represents all Query features available for use with `provideTanStackQuery`.
|
|
670
|
+
* Features can be enabled by adding special functions to the `provideTanStackQuery` call.
|
|
671
|
+
* See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`
|
|
672
|
+
* documentation on how to use those functions.
|
|
673
|
+
* @public
|
|
674
|
+
* @see {@link provideTanStackQuery}
|
|
675
|
+
*/
|
|
676
|
+
type QueryFeatures = DeveloperToolsFeature;
|
|
677
|
+
declare const queryFeatures: readonly ["DeveloperTools"];
|
|
678
|
+
type QueryFeatureKind = (typeof queryFeatures)[number];
|
|
757
679
|
|
|
758
|
-
export { }
|
|
680
|
+
export { type BaseMutationNarrowing, type BaseQueryNarrowing, type CreateBaseMutationResult, type CreateBaseQueryOptions, type CreateBaseQueryResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreateMutateAsyncFunction, type CreateMutateFunction, type CreateMutationOptions, type CreateMutationResult, type CreateQueryOptions, type CreateQueryResult, type DefinedCreateInfiniteQueryResult, type DefinedCreateQueryResult, type DefinedInitialDataInfiniteOptions, type DefinedInitialDataOptions, type DeveloperToolsFeature, type DevtoolsOptions, type InjectMutationStateOptions, type NonUndefinedGuard, QUERY_CLIENT, type QueriesOptions, type QueriesResults, type QueryFeature, type QueryFeatureKind, type QueryFeatures, type UndefinedInitialDataInfiniteOptions, type UndefinedInitialDataOptions, infiniteQueryOptions, injectInfiniteQuery, injectIsFetching, injectIsMutating, injectMutation, injectMutationState, injectQueries, injectQuery, injectQueryClient, provideAngularQuery, provideQueryClient, provideTanStackQuery, queryFeatures, queryOptions, withDevtools };
|