@tanstack/angular-query-experimental 5.80.7 → 5.80.8
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/dist/create-base-query.mjs +74 -0
- package/dist/create-base-query.mjs.map +1 -0
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -0
- package/dist/infinite-query-options.mjs +7 -0
- package/dist/infinite-query-options.mjs.map +1 -0
- package/dist/inject-infinite-query.mjs +18 -0
- package/dist/inject-infinite-query.mjs.map +1 -0
- package/dist/inject-is-fetching.mjs +31 -0
- package/dist/inject-is-fetching.mjs.map +1 -0
- package/dist/inject-is-mutating.mjs +31 -0
- package/dist/inject-is-mutating.mjs.map +1 -0
- package/dist/inject-is-restoring.mjs +24 -0
- package/dist/inject-is-restoring.mjs.map +1 -0
- package/dist/inject-mutation-state.mjs +51 -0
- package/dist/inject-mutation-state.mjs.map +1 -0
- package/dist/inject-mutation.mjs +79 -0
- package/dist/inject-mutation.mjs.map +1 -0
- package/dist/inject-queries.mjs +49 -0
- package/dist/inject-queries.mjs.map +1 -0
- package/dist/inject-query-client.mjs +9 -0
- package/dist/inject-query-client.mjs.map +1 -0
- package/dist/inject-query.mjs +14 -0
- package/dist/inject-query.mjs.map +1 -0
- package/dist/mutation-options.mjs +7 -0
- package/dist/mutation-options.mjs.map +1 -0
- package/dist/providers.mjs +109 -0
- package/dist/providers.mjs.map +1 -0
- package/dist/query-options.mjs +7 -0
- package/dist/query-options.mjs.map +1 -0
- package/dist/signal-proxy.mjs +29 -0
- package/dist/signal-proxy.mjs.map +1 -0
- package/dist-ts/eslint.config.d.ts +3 -0
- package/dist-ts/root.eslint.config.d.ts +3 -0
- package/dist-ts/src/__tests__/inject-infinite-query.test-d.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-infinite-query.test.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-is-fetching.test.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-is-mutating.test.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-mutation-state.test-d.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-mutation-state.test.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-mutation.test-d.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-mutation.test.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-query.test-d.d.ts +2 -0
- package/dist-ts/src/__tests__/inject-query.test.d.ts +2 -0
- package/dist-ts/src/__tests__/mutation-options.test-d.d.ts +2 -0
- package/dist-ts/src/__tests__/provide-query-client.test.d.ts +2 -0
- package/dist-ts/src/__tests__/provide-tanstack-query.test.d.ts +2 -0
- package/dist-ts/src/__tests__/providers.test.d.ts +2 -0
- package/dist-ts/src/__tests__/query-options.test-d.d.ts +2 -0
- package/dist-ts/src/__tests__/signal-proxy.test.d.ts +2 -0
- package/dist-ts/src/__tests__/test-utils.d.ts +16 -0
- package/dist-ts/src/create-base-query.d.ts +9 -0
- package/dist-ts/src/index.d.ts +27 -0
- package/dist-ts/src/infinite-query-options.d.ts +45 -0
- package/dist-ts/src/inject-infinite-query.d.ts +40 -0
- package/dist-ts/src/inject-is-fetching.d.ts +23 -0
- package/dist-ts/src/inject-is-mutating.d.ts +22 -0
- package/{src/inject-is-restoring.ts → dist-ts/src/inject-is-restoring.d.ts} +7 -33
- package/dist-ts/src/inject-mutation-state.d.ts +28 -0
- package/dist-ts/src/inject-mutation.d.ts +23 -0
- package/dist-ts/src/inject-queries.d.ts +78 -0
- package/{src/inject-query-client.ts → dist-ts/src/inject-query-client.d.ts} +7 -9
- package/{src/inject-query.ts → dist-ts/src/inject-query.d.ts} +14 -117
- package/{src/mutation-options.ts → dist-ts/src/mutation-options.d.ts} +5 -26
- package/dist-ts/src/providers.d.ts +217 -0
- package/dist-ts/src/query-options.d.ts +88 -0
- package/dist-ts/src/signal-proxy.d.ts +12 -0
- package/dist-ts/src/test-setup.d.ts +2 -0
- package/dist-ts/src/types.d.ts +90 -0
- package/dist-ts/src/util/is-dev-mode/is-dev-mode.d.ts +2 -0
- package/dist-ts/vite.config.d.ts +5 -0
- package/package.json +13 -11
- package/build/index.d.ts +0 -821
- package/build/index.mjs +0 -622
- package/build/index.mjs.map +0 -1
- package/src/create-base-query.ts +0 -142
- package/src/index.ts +0 -64
- package/src/infinite-query-options.ts +0 -187
- package/src/inject-infinite-query.ts +0 -129
- package/src/inject-is-fetching.ts +0 -66
- package/src/inject-is-mutating.ts +0 -65
- package/src/inject-mutation-state.ts +0 -125
- package/src/inject-mutation.ts +0 -169
- package/src/inject-queries.ts +0 -271
- package/src/providers.ts +0 -368
- package/src/query-options.ts +0 -178
- package/src/signal-proxy.ts +0 -46
- package/src/test-setup.ts +0 -10
- package/src/types.ts +0 -309
- package/src/util/is-dev-mode/is-dev-mode.ts +0 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import type { Signal } from '@angular/core';
|
|
3
|
+
import type { DefaultError, OmitKeyof, QueriesPlaceholderDataFunction, QueryFunction, QueryKey, QueryObserverOptions, QueryObserverResult, ThrowOnError } from '@tanstack/query-core';
|
|
4
|
+
type QueryObserverOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'placeholderData'> & {
|
|
5
|
+
placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
|
|
6
|
+
};
|
|
7
|
+
type MAXIMUM_DEPTH = 20;
|
|
8
|
+
type SkipTokenForUseQueries = symbol;
|
|
9
|
+
type GetOptions<T> = T extends {
|
|
10
|
+
queryFnData: infer TQueryFnData;
|
|
11
|
+
error?: infer TError;
|
|
12
|
+
data: infer TData;
|
|
13
|
+
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData> : T extends {
|
|
14
|
+
queryFnData: infer TQueryFnData;
|
|
15
|
+
error?: infer TError;
|
|
16
|
+
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError> : T extends {
|
|
17
|
+
data: infer TData;
|
|
18
|
+
error?: infer TError;
|
|
19
|
+
} ? 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 {
|
|
20
|
+
queryFn?: QueryFunction<infer TQueryFnData, infer TQueryKey> | SkipTokenForUseQueries;
|
|
21
|
+
select: (data: any) => infer TData;
|
|
22
|
+
throwOnError?: ThrowOnError<any, infer TError, any, any>;
|
|
23
|
+
} ? QueryObserverOptionsForCreateQueries<TQueryFnData, unknown extends TError ? DefaultError : TError, unknown extends TData ? TQueryFnData : TData, TQueryKey> : QueryObserverOptionsForCreateQueries;
|
|
24
|
+
type GetResults<T> = T extends {
|
|
25
|
+
queryFnData: any;
|
|
26
|
+
error?: infer TError;
|
|
27
|
+
data: infer TData;
|
|
28
|
+
} ? QueryObserverResult<TData, TError> : T extends {
|
|
29
|
+
queryFnData: infer TQueryFnData;
|
|
30
|
+
error?: infer TError;
|
|
31
|
+
} ? QueryObserverResult<TQueryFnData, TError> : T extends {
|
|
32
|
+
data: infer TData;
|
|
33
|
+
error?: infer TError;
|
|
34
|
+
} ? 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 {
|
|
35
|
+
queryFn?: QueryFunction<infer TQueryFnData, any> | SkipTokenForUseQueries;
|
|
36
|
+
select: (data: any) => infer TData;
|
|
37
|
+
throwOnError?: ThrowOnError<any, infer TError, any, any>;
|
|
38
|
+
} ? QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError> : QueryObserverResult;
|
|
39
|
+
/**
|
|
40
|
+
* QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export 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<[
|
|
44
|
+
...Tail
|
|
45
|
+
], [
|
|
46
|
+
...TResult,
|
|
47
|
+
GetOptions<Head>
|
|
48
|
+
], [
|
|
49
|
+
...TDepth,
|
|
50
|
+
1
|
|
51
|
+
]> : 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>;
|
|
52
|
+
/**
|
|
53
|
+
* QueriesResults reducer recursively maps type param to results
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export 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<[
|
|
57
|
+
...Tail
|
|
58
|
+
], [
|
|
59
|
+
...TResult,
|
|
60
|
+
GetResults<Head>
|
|
61
|
+
], [
|
|
62
|
+
...TDepth,
|
|
63
|
+
1
|
|
64
|
+
]> : 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>;
|
|
65
|
+
/**
|
|
66
|
+
* @param root0
|
|
67
|
+
* @param root0.queries
|
|
68
|
+
* @param root0.combine
|
|
69
|
+
* @param injector
|
|
70
|
+
* @param injector
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare function injectQueries<T extends Array<any>, TCombinedResult = QueriesResults<T>>({ queries, ...options }: {
|
|
74
|
+
queries: Signal<[...QueriesOptions<T>]>;
|
|
75
|
+
combine?: (result: QueriesResults<T>) => TCombinedResult;
|
|
76
|
+
}, injector?: Injector): Signal<TCombinedResult>;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=inject-queries.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Injector
|
|
2
|
-
import { QueryClient } from '@tanstack/query-core'
|
|
3
|
-
import type { InjectOptions } from '@angular/core'
|
|
4
|
-
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import { QueryClient } from '@tanstack/query-core';
|
|
3
|
+
import type { InjectOptions } from '@angular/core';
|
|
5
4
|
/**
|
|
6
5
|
* Injects a `QueryClient` instance and allows passing a custom injector.
|
|
7
6
|
* @param injectOptions - Type of the options argument to inject and optionally a custom injector.
|
|
@@ -16,8 +15,7 @@ import type { InjectOptions } from '@angular/core'
|
|
|
16
15
|
* const queryClient = injectQueryClient();
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
|
-
export function injectQueryClient(
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
}
|
|
18
|
+
export declare function injectQueryClient(injectOptions?: InjectOptions & {
|
|
19
|
+
injector?: Injector;
|
|
20
|
+
}): QueryClient;
|
|
21
|
+
//# sourceMappingURL=inject-query-client.d.ts.map
|
|
@@ -1,31 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
inject,
|
|
6
|
-
runInInjectionContext,
|
|
7
|
-
} from '@angular/core'
|
|
8
|
-
import { createBaseQuery } from './create-base-query'
|
|
9
|
-
import type { DefaultError, QueryKey } from '@tanstack/query-core'
|
|
10
|
-
import type {
|
|
11
|
-
CreateQueryOptions,
|
|
12
|
-
CreateQueryResult,
|
|
13
|
-
DefinedCreateQueryResult,
|
|
14
|
-
} from './types'
|
|
15
|
-
import type {
|
|
16
|
-
DefinedInitialDataOptions,
|
|
17
|
-
UndefinedInitialDataOptions,
|
|
18
|
-
} from './query-options'
|
|
19
|
-
|
|
1
|
+
import { Injector } from '@angular/core';
|
|
2
|
+
import type { DefaultError, QueryKey } from '@tanstack/query-core';
|
|
3
|
+
import type { CreateQueryOptions, CreateQueryResult, DefinedCreateQueryResult } from './types';
|
|
4
|
+
import type { DefinedInitialDataOptions, UndefinedInitialDataOptions } from './query-options';
|
|
20
5
|
export interface InjectQueryOptions {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The `Injector` in which to create the query.
|
|
8
|
+
*
|
|
9
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
10
|
+
*/
|
|
11
|
+
injector?: Injector;
|
|
27
12
|
}
|
|
28
|
-
|
|
29
13
|
/**
|
|
30
14
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
31
15
|
*
|
|
@@ -63,21 +47,7 @@ export interface InjectQueryOptions {
|
|
|
63
47
|
* @public
|
|
64
48
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
65
49
|
*/
|
|
66
|
-
export function injectQuery<
|
|
67
|
-
TQueryFnData = unknown,
|
|
68
|
-
TError = DefaultError,
|
|
69
|
-
TData = TQueryFnData,
|
|
70
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
71
|
-
>(
|
|
72
|
-
injectQueryFn: () => DefinedInitialDataOptions<
|
|
73
|
-
TQueryFnData,
|
|
74
|
-
TError,
|
|
75
|
-
TData,
|
|
76
|
-
TQueryKey
|
|
77
|
-
>,
|
|
78
|
-
options?: InjectQueryOptions,
|
|
79
|
-
): DefinedCreateQueryResult<TData, TError>
|
|
80
|
-
|
|
50
|
+
export declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): DefinedCreateQueryResult<TData, TError>;
|
|
81
51
|
/**
|
|
82
52
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
83
53
|
*
|
|
@@ -115,21 +85,7 @@ export function injectQuery<
|
|
|
115
85
|
* @public
|
|
116
86
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
117
87
|
*/
|
|
118
|
-
export function injectQuery<
|
|
119
|
-
TQueryFnData = unknown,
|
|
120
|
-
TError = DefaultError,
|
|
121
|
-
TData = TQueryFnData,
|
|
122
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
123
|
-
>(
|
|
124
|
-
injectQueryFn: () => UndefinedInitialDataOptions<
|
|
125
|
-
TQueryFnData,
|
|
126
|
-
TError,
|
|
127
|
-
TData,
|
|
128
|
-
TQueryKey
|
|
129
|
-
>,
|
|
130
|
-
options?: InjectQueryOptions,
|
|
131
|
-
): CreateQueryResult<TData, TError>
|
|
132
|
-
|
|
88
|
+
export declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
|
|
133
89
|
/**
|
|
134
90
|
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
135
91
|
*
|
|
@@ -167,64 +123,5 @@ export function injectQuery<
|
|
|
167
123
|
* @public
|
|
168
124
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
169
125
|
*/
|
|
170
|
-
export function injectQuery<
|
|
171
|
-
|
|
172
|
-
TError = DefaultError,
|
|
173
|
-
TData = TQueryFnData,
|
|
174
|
-
TQueryKey extends QueryKey = QueryKey,
|
|
175
|
-
>(
|
|
176
|
-
injectQueryFn: () => CreateQueryOptions<
|
|
177
|
-
TQueryFnData,
|
|
178
|
-
TError,
|
|
179
|
-
TData,
|
|
180
|
-
TQueryKey
|
|
181
|
-
>,
|
|
182
|
-
options?: InjectQueryOptions,
|
|
183
|
-
): CreateQueryResult<TData, TError>
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
|
|
187
|
-
*
|
|
188
|
-
* **Basic example**
|
|
189
|
-
* ```ts
|
|
190
|
-
* class ServiceOrComponent {
|
|
191
|
-
* query = injectQuery(() => ({
|
|
192
|
-
* queryKey: ['repoData'],
|
|
193
|
-
* queryFn: () =>
|
|
194
|
-
* this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),
|
|
195
|
-
* }))
|
|
196
|
-
* }
|
|
197
|
-
* ```
|
|
198
|
-
*
|
|
199
|
-
* Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.
|
|
200
|
-
* In the example below, the query will be automatically enabled and executed when the filter signal changes
|
|
201
|
-
* to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.
|
|
202
|
-
*
|
|
203
|
-
* **Reactive example**
|
|
204
|
-
* ```ts
|
|
205
|
-
* class ServiceOrComponent {
|
|
206
|
-
* filter = signal('')
|
|
207
|
-
*
|
|
208
|
-
* todosQuery = injectQuery(() => ({
|
|
209
|
-
* queryKey: ['todos', this.filter()],
|
|
210
|
-
* queryFn: () => fetchTodos(this.filter()),
|
|
211
|
-
* // Signals can be combined with expressions
|
|
212
|
-
* enabled: !!this.filter(),
|
|
213
|
-
* }))
|
|
214
|
-
* }
|
|
215
|
-
* ```
|
|
216
|
-
* @param injectQueryFn - A function that returns query options.
|
|
217
|
-
* @param options - Additional configuration
|
|
218
|
-
* @returns The query result.
|
|
219
|
-
* @public
|
|
220
|
-
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
221
|
-
*/
|
|
222
|
-
export function injectQuery(
|
|
223
|
-
injectQueryFn: () => CreateQueryOptions,
|
|
224
|
-
options?: InjectQueryOptions,
|
|
225
|
-
) {
|
|
226
|
-
!options?.injector && assertInInjectionContext(injectQuery)
|
|
227
|
-
return runInInjectionContext(options?.injector ?? inject(Injector), () =>
|
|
228
|
-
createBaseQuery(injectQueryFn, QueryObserver),
|
|
229
|
-
) as unknown as CreateQueryResult
|
|
230
|
-
}
|
|
126
|
+
export declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
|
|
127
|
+
//# sourceMappingURL=inject-query.d.ts.map
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DefaultError,
|
|
3
|
-
MutationObserverOptions,
|
|
4
|
-
OmitKeyof,
|
|
5
|
-
} from '@tanstack/query-core'
|
|
6
|
-
|
|
1
|
+
import type { DefaultError, MutationObserverOptions, OmitKeyof } from '@tanstack/query-core';
|
|
7
2
|
/**
|
|
8
3
|
* Allows to share and re-use mutation options in a type-safe way.
|
|
9
4
|
*
|
|
@@ -35,26 +30,10 @@ import type {
|
|
|
35
30
|
* @returns Mutation options.
|
|
36
31
|
* @public
|
|
37
32
|
*/
|
|
38
|
-
export function mutationOptions<
|
|
39
|
-
TData = unknown,
|
|
40
|
-
TError = DefaultError,
|
|
41
|
-
TVariables = void,
|
|
42
|
-
TContext = unknown,
|
|
43
|
-
>(
|
|
44
|
-
options: MutationObserverOptions<TData, TError, TVariables, TContext>,
|
|
45
|
-
): CreateMutationOptions<TData, TError, TVariables, TContext> {
|
|
46
|
-
return options
|
|
47
|
-
}
|
|
48
|
-
|
|
33
|
+
export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: MutationObserverOptions<TData, TError, TVariables, TContext>): CreateMutationOptions<TData, TError, TVariables, TContext>;
|
|
49
34
|
/**
|
|
50
35
|
* @public
|
|
51
36
|
*/
|
|
52
|
-
export interface CreateMutationOptions<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
TVariables = void,
|
|
56
|
-
TContext = unknown,
|
|
57
|
-
> extends OmitKeyof<
|
|
58
|
-
MutationObserverOptions<TData, TError, TVariables, TContext>,
|
|
59
|
-
'_defaulted'
|
|
60
|
-
> {}
|
|
37
|
+
export interface CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TContext>, '_defaulted'> {
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=mutation-options.d.ts.map
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { QueryClient } from '@tanstack/query-core';
|
|
3
|
+
import type { Provider } from '@angular/core';
|
|
4
|
+
import type { DevtoolsButtonPosition, DevtoolsErrorType, DevtoolsPosition } from '@tanstack/query-devtools';
|
|
5
|
+
/**
|
|
6
|
+
* Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the
|
|
7
|
+
* {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
|
|
8
|
+
* for the entire application. Internally it calls `provideQueryClient`.
|
|
9
|
+
* You can use `provideQueryClient` to provide a different `QueryClient` instance for a part
|
|
10
|
+
* of the application or for unit testing purposes.
|
|
11
|
+
* @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
|
|
12
|
+
* @returns a provider object that can be used to provide the `QueryClient` instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare function provideQueryClient(queryClient: QueryClient | InjectionToken<QueryClient>): Provider;
|
|
15
|
+
/**
|
|
16
|
+
* Sets up providers necessary to enable TanStack Query functionality for Angular applications.
|
|
17
|
+
*
|
|
18
|
+
* Allows to configure a `QueryClient` and optional features such as developer tools.
|
|
19
|
+
*
|
|
20
|
+
* **Example - standalone**
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import {
|
|
24
|
+
* provideTanStackQuery,
|
|
25
|
+
* QueryClient,
|
|
26
|
+
* } from '@tanstack/angular-query-experimental'
|
|
27
|
+
*
|
|
28
|
+
* bootstrapApplication(AppComponent, {
|
|
29
|
+
* providers: [provideTanStackQuery(new QueryClient())],
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* **Example - NgModule-based**
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import {
|
|
37
|
+
* provideTanStackQuery,
|
|
38
|
+
* QueryClient,
|
|
39
|
+
* } from '@tanstack/angular-query-experimental'
|
|
40
|
+
*
|
|
41
|
+
* @NgModule({
|
|
42
|
+
* declarations: [AppComponent],
|
|
43
|
+
* imports: [BrowserModule],
|
|
44
|
+
* providers: [provideTanStackQuery(new QueryClient())],
|
|
45
|
+
* bootstrap: [AppComponent],
|
|
46
|
+
* })
|
|
47
|
+
* export class AppModule {}
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* You can also enable optional developer tools by adding `withDevtools`. By
|
|
51
|
+
* default the tools will then be loaded when your app is in development mode.
|
|
52
|
+
* ```ts
|
|
53
|
+
* import {
|
|
54
|
+
* provideTanStackQuery,
|
|
55
|
+
* withDevtools
|
|
56
|
+
* QueryClient,
|
|
57
|
+
* } from '@tanstack/angular-query-experimental'
|
|
58
|
+
*
|
|
59
|
+
* bootstrapApplication(AppComponent,
|
|
60
|
+
* {
|
|
61
|
+
* providers: [
|
|
62
|
+
* provideTanStackQuery(new QueryClient(), withDevtools())
|
|
63
|
+
* ]
|
|
64
|
+
* }
|
|
65
|
+
* )
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* **Example: using an InjectionToken**
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* export const MY_QUERY_CLIENT = new InjectionToken('', {
|
|
72
|
+
* factory: () => new QueryClient(),
|
|
73
|
+
* })
|
|
74
|
+
*
|
|
75
|
+
* // In a lazy loaded route or lazy loaded component's providers array:
|
|
76
|
+
* providers: [provideTanStackQuery(MY_QUERY_CLIENT)]
|
|
77
|
+
* ```
|
|
78
|
+
* @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
|
|
79
|
+
* @param features - Optional features to configure additional Query functionality.
|
|
80
|
+
* @returns A set of providers to set up TanStack Query.
|
|
81
|
+
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
|
|
82
|
+
* @see withDevtools
|
|
83
|
+
*/
|
|
84
|
+
export declare function provideTanStackQuery(queryClient: QueryClient | InjectionToken<QueryClient>, ...features: Array<QueryFeatures>): Array<Provider>;
|
|
85
|
+
/**
|
|
86
|
+
* Sets up providers necessary to enable TanStack Query functionality for Angular applications.
|
|
87
|
+
*
|
|
88
|
+
* Allows to configure a `QueryClient`.
|
|
89
|
+
* @param queryClient - A `QueryClient` instance.
|
|
90
|
+
* @returns A set of providers to set up TanStack Query.
|
|
91
|
+
* @public
|
|
92
|
+
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
|
|
93
|
+
* @deprecated Use `provideTanStackQuery` instead.
|
|
94
|
+
*/
|
|
95
|
+
export declare function provideAngularQuery(queryClient: QueryClient): Array<Provider>;
|
|
96
|
+
/**
|
|
97
|
+
* Helper type to represent a Query feature.
|
|
98
|
+
*/
|
|
99
|
+
export interface QueryFeature<TFeatureKind extends QueryFeatureKind> {
|
|
100
|
+
ɵkind: TFeatureKind;
|
|
101
|
+
ɵproviders: Array<Provider>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Helper function to create an object that represents a Query feature.
|
|
105
|
+
* @param kind -
|
|
106
|
+
* @param providers -
|
|
107
|
+
* @returns A Query feature.
|
|
108
|
+
*/
|
|
109
|
+
export declare function queryFeature<TFeatureKind extends QueryFeatureKind>(kind: TFeatureKind, providers: Array<Provider>): QueryFeature<TFeatureKind>;
|
|
110
|
+
/**
|
|
111
|
+
* A type alias that represents a feature which enables developer tools.
|
|
112
|
+
* The type is used to describe the return value of the `withDevtools` function.
|
|
113
|
+
* @public
|
|
114
|
+
* @see {@link withDevtools}
|
|
115
|
+
*/
|
|
116
|
+
export type DeveloperToolsFeature = QueryFeature<'DeveloperTools'>;
|
|
117
|
+
/**
|
|
118
|
+
* A type alias that represents a feature which enables persistence.
|
|
119
|
+
* The type is used to describe the return value of the `withPersistQueryClient` function.
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export type PersistQueryClientFeature = QueryFeature<'PersistQueryClient'>;
|
|
123
|
+
/**
|
|
124
|
+
* Options for configuring the TanStack Query devtools.
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
export interface DevtoolsOptions {
|
|
128
|
+
/**
|
|
129
|
+
* Set this true if you want the devtools to default to being open
|
|
130
|
+
*/
|
|
131
|
+
initialIsOpen?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The position of the TanStack logo to open and close the devtools panel.
|
|
134
|
+
* `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`
|
|
135
|
+
* Defaults to `bottom-right`.
|
|
136
|
+
*/
|
|
137
|
+
buttonPosition?: DevtoolsButtonPosition;
|
|
138
|
+
/**
|
|
139
|
+
* The position of the TanStack Query devtools panel.
|
|
140
|
+
* `top` | `bottom` | `left` | `right`
|
|
141
|
+
* Defaults to `bottom`.
|
|
142
|
+
*/
|
|
143
|
+
position?: DevtoolsPosition;
|
|
144
|
+
/**
|
|
145
|
+
* Custom instance of QueryClient
|
|
146
|
+
*/
|
|
147
|
+
client?: QueryClient;
|
|
148
|
+
/**
|
|
149
|
+
* Use this so you can define custom errors that can be shown in the devtools.
|
|
150
|
+
*/
|
|
151
|
+
errorTypes?: Array<DevtoolsErrorType>;
|
|
152
|
+
/**
|
|
153
|
+
* 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.
|
|
154
|
+
*/
|
|
155
|
+
styleNonce?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Use this so you can attach the devtool's styles to a specific element in the DOM.
|
|
158
|
+
*/
|
|
159
|
+
shadowDOMTarget?: ShadowRoot;
|
|
160
|
+
/**
|
|
161
|
+
* Whether the developer tools should load.
|
|
162
|
+
* - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.
|
|
163
|
+
* - `true`- Always load the devtools, regardless of the environment.
|
|
164
|
+
* - `false`- Never load the devtools, regardless of the environment.
|
|
165
|
+
*
|
|
166
|
+
* You can use `true` and `false` to override loading developer tools from an environment file.
|
|
167
|
+
* For example, a test environment might run in production mode but you may want to load developer tools.
|
|
168
|
+
*
|
|
169
|
+
* Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,
|
|
170
|
+
* a signal created from a RxJS observable that listens for a keyboard shortcut.
|
|
171
|
+
*
|
|
172
|
+
* **Example**
|
|
173
|
+
* ```ts
|
|
174
|
+
* withDevtools(() => ({
|
|
175
|
+
* initialIsOpen: true,
|
|
176
|
+
* loadDevtools: inject(ExampleService).loadDevtools()
|
|
177
|
+
* }))
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
loadDevtools?: 'auto' | boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Enables developer tools.
|
|
184
|
+
*
|
|
185
|
+
* **Example**
|
|
186
|
+
*
|
|
187
|
+
* ```ts
|
|
188
|
+
* export const appConfig: ApplicationConfig = {
|
|
189
|
+
* providers: [
|
|
190
|
+
* provideTanStackQuery(new QueryClient(), withDevtools())
|
|
191
|
+
* ]
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
* By default the devtools will be loaded when Angular runs in development mode and rendered in `<body>`.
|
|
195
|
+
*
|
|
196
|
+
* If you need more control over when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations. For instance, you might have a test environment running in production mode but still require devtools to be available.
|
|
197
|
+
*
|
|
198
|
+
* If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.
|
|
199
|
+
* @param withDevtoolsFn - A function that returns `DevtoolsOptions`.
|
|
200
|
+
* @returns A set of providers for use with `provideTanStackQuery`.
|
|
201
|
+
* @public
|
|
202
|
+
* @see {@link provideTanStackQuery}
|
|
203
|
+
* @see {@link DevtoolsOptions}
|
|
204
|
+
*/
|
|
205
|
+
export declare function withDevtools(withDevtoolsFn?: () => DevtoolsOptions): DeveloperToolsFeature;
|
|
206
|
+
/**
|
|
207
|
+
* A type alias that represents all Query features available for use with `provideTanStackQuery`.
|
|
208
|
+
* Features can be enabled by adding special functions to the `provideTanStackQuery` call.
|
|
209
|
+
* See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`
|
|
210
|
+
* documentation on how to use those functions.
|
|
211
|
+
* @public
|
|
212
|
+
* @see {@link provideTanStackQuery}
|
|
213
|
+
*/
|
|
214
|
+
export type QueryFeatures = DeveloperToolsFeature | PersistQueryClientFeature;
|
|
215
|
+
export declare const queryFeatures: readonly ["DeveloperTools", "PersistQueryClient"];
|
|
216
|
+
export type QueryFeatureKind = (typeof queryFeatures)[number];
|
|
217
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { DataTag, DefaultError, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryFunction, QueryKey, SkipToken } from '@tanstack/query-core';
|
|
2
|
+
import type { CreateQueryOptions } from './types';
|
|
3
|
+
export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
4
|
+
initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
|
|
5
|
+
};
|
|
6
|
+
export type UnusedSkipTokenOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
|
|
7
|
+
queryFn?: Exclude<CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'], SkipToken | undefined>;
|
|
8
|
+
};
|
|
9
|
+
export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = Omit<CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
|
|
10
|
+
initialData: NonUndefinedGuard<TQueryFnData> | (() => NonUndefinedGuard<TQueryFnData>);
|
|
11
|
+
queryFn?: QueryFunction<TQueryFnData, TQueryKey>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Allows to share and re-use query options in a type-safe way.
|
|
15
|
+
*
|
|
16
|
+
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
17
|
+
*
|
|
18
|
+
* **Example**
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* const { queryKey } = queryOptions({
|
|
22
|
+
* queryKey: ['key'],
|
|
23
|
+
* queryFn: () => Promise.resolve(5),
|
|
24
|
+
* // ^? Promise<number>
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* const queryClient = new QueryClient()
|
|
28
|
+
* const data = queryClient.getQueryData(queryKey)
|
|
29
|
+
* // ^? number | undefined
|
|
30
|
+
* ```
|
|
31
|
+
* @param options - The query options to tag with the type from `queryFn`.
|
|
32
|
+
* @returns The tagged query options.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
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> & {
|
|
36
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Allows to share and re-use query options in a type-safe way.
|
|
40
|
+
*
|
|
41
|
+
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
42
|
+
*
|
|
43
|
+
* **Example**
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const { queryKey } = queryOptions({
|
|
47
|
+
* queryKey: ['key'],
|
|
48
|
+
* queryFn: () => Promise.resolve(5),
|
|
49
|
+
* // ^? Promise<number>
|
|
50
|
+
* })
|
|
51
|
+
*
|
|
52
|
+
* const queryClient = new QueryClient()
|
|
53
|
+
* const data = queryClient.getQueryData(queryKey)
|
|
54
|
+
* // ^? number | undefined
|
|
55
|
+
* ```
|
|
56
|
+
* @param options - The query options to tag with the type from `queryFn`.
|
|
57
|
+
* @returns The tagged query options.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function queryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> & {
|
|
61
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Allows to share and re-use query options in a type-safe way.
|
|
65
|
+
*
|
|
66
|
+
* The `queryKey` will be tagged with the type from `queryFn`.
|
|
67
|
+
*
|
|
68
|
+
* **Example**
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* const { queryKey } = queryOptions({
|
|
72
|
+
* queryKey: ['key'],
|
|
73
|
+
* queryFn: () => Promise.resolve(5),
|
|
74
|
+
* // ^? Promise<number>
|
|
75
|
+
* })
|
|
76
|
+
*
|
|
77
|
+
* const queryClient = new QueryClient()
|
|
78
|
+
* const data = queryClient.getQueryData(queryKey)
|
|
79
|
+
* // ^? number | undefined
|
|
80
|
+
* ```
|
|
81
|
+
* @param options - The query options to tag with the type from `queryFn`.
|
|
82
|
+
* @returns The tagged query options.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
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> & {
|
|
86
|
+
queryKey: DataTag<TQueryKey, TQueryFnData, TError>;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=query-options.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Signal } from '@angular/core';
|
|
2
|
+
export type MapToSignals<T> = {
|
|
3
|
+
[K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Exposes fields of an object passed via an Angular `Signal` as `Computed` signals.
|
|
7
|
+
* Functions on the object are passed through as-is.
|
|
8
|
+
* @param inputSignal - `Signal` that must return an object.
|
|
9
|
+
* @returns A proxy object with the same fields as the input object, but with each field wrapped in a `Computed` signal.
|
|
10
|
+
*/
|
|
11
|
+
export declare function signalProxy<TInput extends Record<string | symbol, any>>(inputSignal: Signal<TInput>): MapToSignals<TInput>;
|
|
12
|
+
//# sourceMappingURL=signal-proxy.d.ts.map
|