@tanstack/angular-query-experimental 5.59.20 → 5.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/rollup.d.ts CHANGED
@@ -2,11 +2,15 @@ import type { DataTag } from '@tanstack/query-core';
2
2
  import type { DefaultError } from '@tanstack/query-core';
3
3
  import type { DefinedInfiniteQueryObserverResult } from '@tanstack/query-core';
4
4
  import type { DefinedQueryObserverResult } from '@tanstack/query-core';
5
+ import type { DevtoolsButtonPosition } from '@tanstack/query-devtools';
6
+ import type { DevtoolsErrorType } from '@tanstack/query-devtools';
7
+ import type { DevtoolsPosition } from '@tanstack/query-devtools';
5
8
  import type { EnvironmentProviders } from '@angular/core';
6
9
  import type { InfiniteData } from '@tanstack/query-core';
7
10
  import type { InfiniteQueryObserverOptions } from '@tanstack/query-core';
8
11
  import type { InfiniteQueryObserverResult } from '@tanstack/query-core';
9
12
  import type { InitialDataFunction } from '@tanstack/query-core';
13
+ import { InjectionToken } from '@angular/core';
10
14
  import { InjectOptions } from '@angular/core';
11
15
  import { Injector } from '@angular/core';
12
16
  import type { MutateFunction } from '@tanstack/query-core';
@@ -148,6 +152,74 @@ export declare type DefinedInitialDataOptions<TQueryFnData = unknown, TError = D
148
152
  initialData: NonUndefinedGuard<TQueryFnData> | (() => NonUndefinedGuard<TQueryFnData>);
149
153
  };
150
154
 
155
+ /**
156
+ * A type alias that represents a feature which enables developer tools.
157
+ * The type is used to describe the return value of the `withDevtools` function.
158
+ * @public
159
+ * @see {@link withDevtools}
160
+ */
161
+ export declare type DeveloperToolsFeature = QueryFeature<'DeveloperTools'>;
162
+
163
+ /**
164
+ * Options for configuring the TanStack Query devtools.
165
+ * @public
166
+ */
167
+ export declare interface DevtoolsOptions {
168
+ /**
169
+ * Set this true if you want the devtools to default to being open
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
+
151
223
  declare type GetOptions<T> = T extends {
152
224
  queryFnData: infer TQueryFnData;
153
225
  error?: infer TError;
@@ -451,17 +523,38 @@ export declare type NonUndefinedGuard<T> = T extends undefined ? never : T;
451
523
  * Sets up providers necessary to enable TanStack Query functionality for Angular applications.
452
524
  *
453
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
+ /**
535
+ * Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the
536
+ * {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
537
+ * for the entire application. You can use `provideQueryClient` to provide a
538
+ * different `QueryClient` instance for a part of the application.
539
+ * @public
540
+ */
541
+ export declare const provideQueryClient: ((value: QueryClient | (() => QueryClient)) => Provider) & ((value: QueryClient | (() => QueryClient)) => Provider);
542
+
543
+ /**
544
+ * Sets up providers necessary to enable TanStack Query functionality for Angular applications.
545
+ *
546
+ * Allows to configure a `QueryClient` and optional features such as developer tools.
454
547
  *
455
548
  * **Example - standalone**
456
549
  *
457
550
  * ```ts
458
551
  * import {
459
- * provideAngularQuery,
552
+ * provideTanStackQuery,
460
553
  * QueryClient,
461
554
  * } from '@tanstack/angular-query-experimental'
462
555
  *
463
556
  * bootstrapApplication(AppComponent, {
464
- * providers: [provideAngularQuery(new QueryClient())],
557
+ * providers: [provideTanStackQuery(new QueryClient())],
465
558
  * })
466
559
  * ```
467
560
  *
@@ -469,33 +562,44 @@ export declare type NonUndefinedGuard<T> = T extends undefined ? never : T;
469
562
  *
470
563
  * ```ts
471
564
  * import {
472
- * provideAngularQuery,
565
+ * provideTanStackQuery,
473
566
  * QueryClient,
474
567
  * } from '@tanstack/angular-query-experimental'
475
568
  *
476
569
  * @NgModule({
477
570
  * declarations: [AppComponent],
478
571
  * imports: [BrowserModule],
479
- * providers: [provideAngularQuery(new QueryClient())],
572
+ * providers: [provideTanStackQuery(new QueryClient())],
480
573
  * bootstrap: [AppComponent],
481
574
  * })
482
575
  * export class AppModule {}
483
576
  * ```
577
+ *
578
+ * You can also enable optional developer tools by adding `withDevtools`. By
579
+ * default the tools will then be loaded when your app is in development mode.
580
+ * ```ts
581
+ * import {
582
+ * provideTanStackQuery,
583
+ * withDevtools
584
+ * QueryClient,
585
+ * } from '@tanstack/angular-query-experimental'
586
+ *
587
+ * bootstrapApplication(AppComponent,
588
+ * {
589
+ * providers: [
590
+ * provideTanStackQuery(new QueryClient(), withDevtools())
591
+ * ]
592
+ * }
593
+ * )
594
+ * ```
484
595
  * @param queryClient - A `QueryClient` instance.
596
+ * @param features - Optional features to configure additional Query functionality.
485
597
  * @returns A set of providers to set up TanStack Query.
486
598
  * @public
487
599
  * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
600
+ * @see withDevtools
488
601
  */
489
- export declare function provideAngularQuery(queryClient: QueryClient): EnvironmentProviders;
490
-
491
- /**
492
- * Usually {@link provideAngularQuery} is used once to set up TanStack Query and the
493
- * {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
494
- * for the entire application. You can use `provideQueryClient` to provide a
495
- * different `QueryClient` instance for a part of the application.
496
- * @public
497
- */
498
- export declare const provideQueryClient: ((value: QueryClient | (() => QueryClient)) => Provider) & ((value: QueryClient | (() => QueryClient)) => Provider);
602
+ export declare function provideTanStackQuery(queryClient: QueryClient, ...features: Array<QueryFeatures>): EnvironmentProviders;
499
603
 
500
604
  /**
501
605
  * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
@@ -525,6 +629,30 @@ GetResults<Head>
525
629
  1
526
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>;
527
631
 
632
+ export declare const QUERY_CLIENT: InjectionToken<QueryClient>;
633
+
634
+ /**
635
+ * Helper type to represent a Query feature.
636
+ */
637
+ export declare interface QueryFeature<TFeatureKind extends QueryFeatureKind> {
638
+ ɵkind: TFeatureKind;
639
+ ɵproviders: Array<Provider>;
640
+ }
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
+
528
656
  declare type QueryObserverOptionsForCreateQueries<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, 'placeholderData'> & {
529
657
  placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>;
530
658
  };
@@ -599,6 +727,31 @@ export declare type UndefinedInitialDataOptions<TQueryFnData = unknown, TError =
599
727
  initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>;
600
728
  };
601
729
 
730
+ /**
731
+ * Enables developer tools.
732
+ *
733
+ * **Example**
734
+ *
735
+ * ```ts
736
+ * export const appConfig: ApplicationConfig = {
737
+ * providers: [
738
+ * provideTanStackQuery(new QueryClient(), withDevtools())
739
+ * ]
740
+ * }
741
+ * ```
742
+ * By default the devtools will be loaded when Angular runs in development mode and rendered in `<body>`.
743
+ *
744
+ * 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.
745
+ *
746
+ * If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.
747
+ * @param optionsFn - A function that returns `DevtoolsOptions`.
748
+ * @returns A set of providers for use with `provideTanStackQuery`.
749
+ * @public
750
+ * @see {@link provideTanStackQuery}
751
+ * @see {@link DevtoolsOptions}
752
+ */
753
+ export declare function withDevtools(optionsFn?: () => DevtoolsOptions): DeveloperToolsFeature;
754
+
602
755
 
603
756
  export * from "@tanstack/query-core";
604
757
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/angular-query-experimental",
3
- "version": "5.59.20",
3
+ "version": "5.60.0",
4
4
  "description": "Signals for managing, caching and syncing asynchronous and remote data in Angular",
5
5
  "author": "Arnoud de Vries",
6
6
  "license": "MIT",
@@ -49,6 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "tslib": "^2.6.3",
52
+ "@tanstack/query-devtools": "5.59.20",
52
53
  "@tanstack/query-core": "5.59.20"
53
54
  },
54
55
  "devDependencies": {
@@ -64,6 +65,7 @@
64
65
  "typescript": "5.3.3"
65
66
  },
66
67
  "peerDependencies": {
68
+ "@angular/common": ">=16.0.0",
67
69
  "@angular/core": ">=16.0.0"
68
70
  },
69
71
  "scripts": {}