@tanstack/angular-query-experimental 5.80.8 → 5.80.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +2 -0
  2. package/build/index.d.ts +821 -0
  3. package/build/index.mjs +622 -0
  4. package/build/index.mjs.map +1 -0
  5. package/package.json +10 -12
  6. package/src/create-base-query.ts +142 -0
  7. package/src/index.ts +64 -0
  8. package/src/infinite-query-options.ts +187 -0
  9. package/src/inject-infinite-query.ts +129 -0
  10. package/src/inject-is-fetching.ts +66 -0
  11. package/src/inject-is-mutating.ts +65 -0
  12. package/{dist-ts/src/inject-is-restoring.d.ts → src/inject-is-restoring.ts} +33 -7
  13. package/src/inject-mutation-state.ts +125 -0
  14. package/src/inject-mutation.ts +169 -0
  15. package/src/inject-queries.ts +271 -0
  16. package/{dist-ts/src/inject-query-client.d.ts → src/inject-query-client.ts} +9 -7
  17. package/{dist-ts/src/inject-query.d.ts → src/inject-query.ts} +117 -14
  18. package/{dist-ts/src/mutation-options.d.ts → src/mutation-options.ts} +26 -5
  19. package/src/providers.ts +368 -0
  20. package/src/query-options.ts +178 -0
  21. package/src/signal-proxy.ts +46 -0
  22. package/src/test-setup.ts +10 -0
  23. package/src/types.ts +309 -0
  24. package/src/util/is-dev-mode/is-dev-mode.ts +3 -0
  25. package/dist/create-base-query.mjs +0 -74
  26. package/dist/create-base-query.mjs.map +0 -1
  27. package/dist/index.mjs +0 -35
  28. package/dist/index.mjs.map +0 -1
  29. package/dist/infinite-query-options.mjs +0 -7
  30. package/dist/infinite-query-options.mjs.map +0 -1
  31. package/dist/inject-infinite-query.mjs +0 -18
  32. package/dist/inject-infinite-query.mjs.map +0 -1
  33. package/dist/inject-is-fetching.mjs +0 -31
  34. package/dist/inject-is-fetching.mjs.map +0 -1
  35. package/dist/inject-is-mutating.mjs +0 -31
  36. package/dist/inject-is-mutating.mjs.map +0 -1
  37. package/dist/inject-is-restoring.mjs +0 -24
  38. package/dist/inject-is-restoring.mjs.map +0 -1
  39. package/dist/inject-mutation-state.mjs +0 -51
  40. package/dist/inject-mutation-state.mjs.map +0 -1
  41. package/dist/inject-mutation.mjs +0 -79
  42. package/dist/inject-mutation.mjs.map +0 -1
  43. package/dist/inject-queries.mjs +0 -49
  44. package/dist/inject-queries.mjs.map +0 -1
  45. package/dist/inject-query-client.mjs +0 -9
  46. package/dist/inject-query-client.mjs.map +0 -1
  47. package/dist/inject-query.mjs +0 -14
  48. package/dist/inject-query.mjs.map +0 -1
  49. package/dist/mutation-options.mjs +0 -7
  50. package/dist/mutation-options.mjs.map +0 -1
  51. package/dist/providers.mjs +0 -109
  52. package/dist/providers.mjs.map +0 -1
  53. package/dist/query-options.mjs +0 -7
  54. package/dist/query-options.mjs.map +0 -1
  55. package/dist/signal-proxy.mjs +0 -29
  56. package/dist/signal-proxy.mjs.map +0 -1
  57. package/dist-ts/eslint.config.d.ts +0 -3
  58. package/dist-ts/root.eslint.config.d.ts +0 -3
  59. package/dist-ts/src/__tests__/inject-infinite-query.test-d.d.ts +0 -2
  60. package/dist-ts/src/__tests__/inject-infinite-query.test.d.ts +0 -2
  61. package/dist-ts/src/__tests__/inject-is-fetching.test.d.ts +0 -2
  62. package/dist-ts/src/__tests__/inject-is-mutating.test.d.ts +0 -2
  63. package/dist-ts/src/__tests__/inject-mutation-state.test-d.d.ts +0 -2
  64. package/dist-ts/src/__tests__/inject-mutation-state.test.d.ts +0 -2
  65. package/dist-ts/src/__tests__/inject-mutation.test-d.d.ts +0 -2
  66. package/dist-ts/src/__tests__/inject-mutation.test.d.ts +0 -2
  67. package/dist-ts/src/__tests__/inject-query.test-d.d.ts +0 -2
  68. package/dist-ts/src/__tests__/inject-query.test.d.ts +0 -2
  69. package/dist-ts/src/__tests__/mutation-options.test-d.d.ts +0 -2
  70. package/dist-ts/src/__tests__/provide-query-client.test.d.ts +0 -2
  71. package/dist-ts/src/__tests__/provide-tanstack-query.test.d.ts +0 -2
  72. package/dist-ts/src/__tests__/providers.test.d.ts +0 -2
  73. package/dist-ts/src/__tests__/query-options.test-d.d.ts +0 -2
  74. package/dist-ts/src/__tests__/signal-proxy.test.d.ts +0 -2
  75. package/dist-ts/src/__tests__/test-utils.d.ts +0 -16
  76. package/dist-ts/src/create-base-query.d.ts +0 -9
  77. package/dist-ts/src/index.d.ts +0 -27
  78. package/dist-ts/src/infinite-query-options.d.ts +0 -45
  79. package/dist-ts/src/inject-infinite-query.d.ts +0 -40
  80. package/dist-ts/src/inject-is-fetching.d.ts +0 -23
  81. package/dist-ts/src/inject-is-mutating.d.ts +0 -22
  82. package/dist-ts/src/inject-mutation-state.d.ts +0 -28
  83. package/dist-ts/src/inject-mutation.d.ts +0 -23
  84. package/dist-ts/src/inject-queries.d.ts +0 -78
  85. package/dist-ts/src/providers.d.ts +0 -217
  86. package/dist-ts/src/query-options.d.ts +0 -88
  87. package/dist-ts/src/signal-proxy.d.ts +0 -12
  88. package/dist-ts/src/test-setup.d.ts +0 -2
  89. package/dist-ts/src/types.d.ts +0 -90
  90. package/dist-ts/src/util/is-dev-mode/is-dev-mode.d.ts +0 -2
  91. package/dist-ts/vite.config.d.ts +0 -5
@@ -1,45 +0,0 @@
1
- import type { DataTag, DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, SkipToken } from '@tanstack/query-core';
2
- import type { CreateInfiniteQueryOptions } from './types';
3
- export type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
4
- initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
5
- };
6
- export type UnusedSkipTokenInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = OmitKeyof<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
7
- queryFn?: Exclude<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken | undefined>;
8
- };
9
- export type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
10
- initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>) | undefined;
11
- };
12
- /**
13
- * Allows to share and re-use infinite query options in a type-safe way.
14
- *
15
- * The `queryKey` will be tagged with the type from `queryFn`.
16
- * @param options - The infinite query options to tag with the type from `queryFn`.
17
- * @returns The tagged infinite query options.
18
- * @public
19
- */
20
- export 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> & {
21
- queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
22
- };
23
- /**
24
- * Allows to share and re-use infinite query options in a type-safe way.
25
- *
26
- * The `queryKey` will be tagged with the type from `queryFn`.
27
- * @param options - The infinite query options to tag with the type from `queryFn`.
28
- * @returns The tagged infinite query options.
29
- * @public
30
- */
31
- export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
32
- queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
33
- };
34
- /**
35
- * Allows to share and re-use infinite query options in a type-safe way.
36
- *
37
- * The `queryKey` will be tagged with the type from `queryFn`.
38
- * @param options - The infinite query options to tag with the type from `queryFn`.
39
- * @returns The tagged infinite query options.
40
- * @public
41
- */
42
- export 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> & {
43
- queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
44
- };
45
- //# sourceMappingURL=infinite-query-options.d.ts.map
@@ -1,40 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import type { DefaultError, InfiniteData, QueryKey } from '@tanstack/query-core';
3
- import type { CreateInfiniteQueryOptions, CreateInfiniteQueryResult, DefinedCreateInfiniteQueryResult } from './types';
4
- import type { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions } from './infinite-query-options';
5
- export interface InjectInfiniteQueryOptions {
6
- /**
7
- * The `Injector` in which to create the infinite query.
8
- *
9
- * If this is not provided, the current injection context will be used instead (via `inject`).
10
- */
11
- injector?: Injector;
12
- }
13
- /**
14
- * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
15
- * Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
16
- * @param injectInfiniteQueryFn - A function that returns infinite query options.
17
- * @param options - Additional configuration.
18
- * @returns The infinite query result.
19
- * @public
20
- */
21
- export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): DefinedCreateInfiniteQueryResult<TData, TError>;
22
- /**
23
- * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
24
- * Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
25
- * @param injectInfiniteQueryFn - A function that returns infinite query options.
26
- * @param options - Additional configuration.
27
- * @returns The infinite query result.
28
- * @public
29
- */
30
- export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
31
- /**
32
- * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
33
- * Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
34
- * @param injectInfiniteQueryFn - A function that returns infinite query options.
35
- * @param options - Additional configuration.
36
- * @returns The infinite query result.
37
- * @public
38
- */
39
- export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
40
- //# sourceMappingURL=inject-infinite-query.d.ts.map
@@ -1,23 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import type { QueryFilters } from '@tanstack/query-core';
3
- import type { Signal } from '@angular/core';
4
- export interface InjectIsFetchingOptions {
5
- /**
6
- * The `Injector` in which to create the isFetching signal.
7
- *
8
- * If this is not provided, the current injection context will be used instead (via `inject`).
9
- */
10
- injector?: Injector;
11
- }
12
- /**
13
- * Injects a signal that tracks the number of queries that your application is loading or
14
- * fetching in the background.
15
- *
16
- * Can be used for app-wide loading indicators
17
- * @param filters - The filters to apply to the query.
18
- * @param options - Additional configuration
19
- * @returns signal with number of loading or fetching queries.
20
- * @public
21
- */
22
- export declare function injectIsFetching(filters?: QueryFilters, options?: InjectIsFetchingOptions): Signal<number>;
23
- //# sourceMappingURL=inject-is-fetching.d.ts.map
@@ -1,22 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import type { MutationFilters } from '@tanstack/query-core';
3
- import type { Signal } from '@angular/core';
4
- export interface InjectIsMutatingOptions {
5
- /**
6
- * The `Injector` in which to create the isMutating signal.
7
- *
8
- * If this is not provided, the current injection context will be used instead (via `inject`).
9
- */
10
- injector?: Injector;
11
- }
12
- /**
13
- * Injects a signal that tracks the number of mutations that your application is fetching.
14
- *
15
- * Can be used for app-wide loading indicators
16
- * @param filters - The filters to apply to the query.
17
- * @param options - Additional configuration
18
- * @returns signal with number of fetching mutations.
19
- * @public
20
- */
21
- export declare function injectIsMutating(filters?: MutationFilters, options?: InjectIsMutatingOptions): Signal<number>;
22
- //# sourceMappingURL=inject-is-mutating.d.ts.map
@@ -1,28 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import type { Signal } from '@angular/core';
3
- import type { Mutation, MutationFilters, MutationState } from '@tanstack/query-core';
4
- type MutationStateOptions<TResult = MutationState> = {
5
- filters?: MutationFilters;
6
- select?: (mutation: Mutation) => TResult;
7
- };
8
- /**
9
- * @public
10
- */
11
- export interface InjectMutationStateOptions {
12
- /**
13
- * The `Injector` in which to create the mutation state signal.
14
- *
15
- * If this is not provided, the current injection context will be used instead (via `inject`).
16
- */
17
- injector?: Injector;
18
- }
19
- /**
20
- * Injects a signal that tracks the state of all mutations.
21
- * @param injectMutationStateFn - A function that returns mutation state options.
22
- * @param options - The Angular injector to use.
23
- * @returns The signal that tracks the state of all mutations.
24
- * @public
25
- */
26
- export declare function injectMutationState<TResult = MutationState>(injectMutationStateFn?: () => MutationStateOptions<TResult>, options?: InjectMutationStateOptions): Signal<Array<TResult>>;
27
- export {};
28
- //# sourceMappingURL=inject-mutation-state.d.ts.map
@@ -1,23 +0,0 @@
1
- import { Injector } from '@angular/core';
2
- import type { DefaultError } from '@tanstack/query-core';
3
- import type { CreateMutationResult } from './types';
4
- import type { CreateMutationOptions } from './mutation-options';
5
- export interface InjectMutationOptions {
6
- /**
7
- * The `Injector` in which to create the mutation.
8
- *
9
- * If this is not provided, the current injection context will be used instead (via `inject`).
10
- */
11
- injector?: Injector;
12
- }
13
- /**
14
- * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.
15
- *
16
- * Unlike queries, mutations are not run automatically.
17
- * @param injectMutationFn - A function that returns mutation options.
18
- * @param options - Additional configuration
19
- * @returns The mutation.
20
- * @public
21
- */
22
- export declare function injectMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(injectMutationFn: () => CreateMutationOptions<TData, TError, TVariables, TContext>, options?: InjectMutationOptions): CreateMutationResult<TData, TError, TVariables, TContext>;
23
- //# sourceMappingURL=inject-mutation.d.ts.map
@@ -1,78 +0,0 @@
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,217 +0,0 @@
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
@@ -1,88 +0,0 @@
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
@@ -1,12 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=test-setup.d.ts.map