@tanstack/angular-query 5.0.0-rc.5 → 5.108.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.
Files changed (55) hide show
  1. package/README.md +1 -1
  2. package/hydration-state-key.mjs +1 -2
  3. package/index.d.ts +1 -1
  4. package/index.mjs +1 -2
  5. package/index.mjs.map +1 -1
  6. package/infinite-query-options.d.ts +15 -13
  7. package/infinite-query-options.mjs +1 -2
  8. package/infinite-query-options.mjs.map +1 -1
  9. package/inject-base-query.mjs +3 -4
  10. package/inject-base-query.mjs.map +1 -1
  11. package/inject-infinite-query.d.ts +170 -33
  12. package/inject-infinite-query.mjs +2 -3
  13. package/inject-infinite-query.mjs.map +1 -1
  14. package/inject-is-fetching.d.ts +37 -6
  15. package/inject-is-fetching.mjs +36 -6
  16. package/inject-is-fetching.mjs.map +1 -1
  17. package/inject-is-mutating.d.ts +21 -6
  18. package/inject-is-mutating.mjs +20 -6
  19. package/inject-is-mutating.mjs.map +1 -1
  20. package/inject-is-restoring.d.ts +5 -3
  21. package/inject-is-restoring.mjs +6 -5
  22. package/inject-is-restoring.mjs.map +1 -1
  23. package/inject-mutation-state.d.ts +51 -3
  24. package/inject-mutation-state.mjs +52 -5
  25. package/inject-mutation-state.mjs.map +1 -1
  26. package/inject-mutation.d.ts +118 -13
  27. package/inject-mutation.mjs +121 -17
  28. package/inject-mutation.mjs.map +1 -1
  29. package/inject-queries.d.ts +113 -15
  30. package/inject-queries.mjs +116 -19
  31. package/inject-queries.mjs.map +1 -1
  32. package/inject-queries.types.d.ts +25 -5
  33. package/inject-query.d.ts +11 -8
  34. package/inject-query.mjs +2 -3
  35. package/inject-query.mjs.map +1 -1
  36. package/mutation-options.mjs +1 -2
  37. package/package.json +2 -2
  38. package/providers.d.ts +31 -6
  39. package/providers.mjs +32 -8
  40. package/providers.mjs.map +1 -1
  41. package/query-options.d.ts +23 -13
  42. package/query-options.mjs +1 -2
  43. package/query-options.mjs.map +1 -1
  44. package/query-resource.d.ts +4 -1
  45. package/query-resource.mjs +4 -2
  46. package/query-resource.mjs.map +1 -1
  47. package/schematics/migrate-from-experimental/index.js +3 -3
  48. package/schematics/migrate-from-experimental/workspace.js +1 -1
  49. package/schematics/ng-add/index.js +5 -4
  50. package/types.d.ts +38 -7
  51. package/utils/inject-external-store.mjs +1 -2
  52. package/utils/inject-pending-tasks-lifecycle.mjs +1 -2
  53. package/utils/inject-query-zone.mjs +1 -2
  54. package/utils/result-fields.mjs +1 -2
  55. package/utils/signal-proxy.mjs +1 -2
package/inject-query.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { DefaultError, QueryKey } from '@tanstack/query-core';
2
- import { CreateQueryOptions, CreateQueryResult, DefinedCreateQueryResult } from './types.js';
3
2
  import { DefinedInitialDataOptions, UndefinedInitialDataOptions } from './query-options.js';
3
+ import { CreateQueryOptions, CreateQueryResult, DefinedCreateQueryResult } from './types.js';
4
4
  /**
5
- * This overload is selected when `initialData` is set on the options returned by `optionsFn`, so the
5
+ * This overload is selected when `initialData` is known to be defined on the options returned by `optionsFn`, so the
6
6
  * resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`).
7
7
  * @param optionsFn - A function returning the {@link DefinedInitialDataOptions} to use — everything you
8
- * can pass to `injectQuery`, with `initialData` set. Similar to `computed` from Angular, this function runs
8
+ * can pass to `injectQuery`, with `initialData` known to be defined. Similar to `computed` from Angular, this function runs
9
9
  * in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.
10
10
  * @returns The query result, typed so that `data` is never `undefined` (unless a `select` changes `TData` to
11
- * include `undefined`).
11
+ * include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call.
12
12
  * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
13
13
  * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like
14
14
  * `queryClient.query`.
@@ -44,9 +44,10 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
44
44
  * @param optionsFn - A function returning the {@link UndefinedInitialDataOptions} to use — everything
45
45
  * you can pass to `injectQuery`. Similar to `computed` from Angular, this function runs in the reactive
46
46
  * context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.
47
- * @returns The query result. `status()` is `'pending'` if there is no cached data to display, `'error'` if
48
- * the last fetch attempt failed, or `'success'` if the query has data to display. `isPending`/`isSuccess`/
49
- * `isError` are type-guard methods for convenience.
47
+ * @returns The query result. `status()` is `'error'` if the query has an error from a fetch that failed
48
+ * after its retries or if `select` threw, `'success'` if the query has cached data (even if `select`
49
+ * returns `undefined`) or data from `placeholderData`, and `'pending'` otherwise.
50
+ * `isPending`/`isSuccess`/`isError` are type-guard methods for convenience.
50
51
  * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
51
52
  * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like
52
53
  * `queryClient.query`.
@@ -103,6 +104,7 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
103
104
  * readonly postsQuery = injectQuery(() => ({
104
105
  * queryKey: ['posts', this.filter()],
105
106
  * queryFn: () => fetchPosts(this.filter()),
107
+ * // Signals can be combined with expressions
106
108
  * enabled: !!this.filter(),
107
109
  * }))
108
110
  * }
@@ -114,7 +116,8 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
114
116
  * overloads above, so whether `data` is defined can't be inferred from the call site — useful when wrapping
115
117
  * `injectQuery` in your own helper function that forwards caller-provided options.
116
118
  * @param optionsFn - A function that returns query options. Similar to `computed` from Angular, this
117
- * function runs in the reactive context, so signals read inside it drive the query.
119
+ * function runs in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive
120
+ * the query.
118
121
  * @returns The query result.
119
122
  * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
120
123
  */
package/inject-query.mjs CHANGED
@@ -1,17 +1,16 @@
1
1
  import { injectQueryZone } from "./utils/inject-query-zone.mjs";
2
2
  import { injectBaseQuery } from "./inject-base-query.mjs";
3
- import { signalProxy } from "./utils/signal-proxy.mjs";
4
3
  import { queryResultFields } from "./utils/result-fields.mjs";
4
+ import { signalProxy } from "./utils/signal-proxy.mjs";
5
5
  import { QueryObserver } from "@tanstack/query-core";
6
6
  import { assertInInjectionContext, untracked } from "@angular/core";
7
- //#region src/inject-query.ts
7
+ // src/inject-query.ts
8
8
  function injectQuery(optionsFn) {
9
9
  if (typeof ngDevMode === "undefined" || ngDevMode) assertInInjectionContext(injectQuery);
10
10
  const outsideZone = injectQueryZone();
11
11
  const [resultSignal, getObserver] = injectBaseQuery(optionsFn, QueryObserver);
12
12
  return Object.assign(signalProxy(resultSignal, queryResultFields), { refetch: (options) => outsideZone(() => untracked(() => getObserver().refetch(options))) });
13
13
  }
14
- //#endregion
15
14
  export { injectQuery };
16
15
 
17
16
  //# sourceMappingURL=inject-query.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"inject-query.mjs","names":[],"sources":["../src/inject-query.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport { assertInInjectionContext, untracked } from '@angular/core'\nimport { injectQueryZone } from './utils/inject-query-zone'\nimport { injectBaseQuery } from './inject-base-query'\nimport { signalProxy } from './utils/signal-proxy'\nimport { queryResultFields } from './utils/result-fields'\nimport type {\n DefaultError,\n QueryKey,\n RefetchOptions,\n} from '@tanstack/query-core'\nimport type {\n CreateQueryOptions,\n CreateQueryResult,\n DefinedCreateQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './query-options'\n\n/**\n * This overload is selected when `initialData` is set on the options returned by `optionsFn`, so the\n * resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param optionsFn - A function returning the {@link DefinedInitialDataOptions} to use — everything you\n * can pass to `injectQuery`, with `initialData` set. Similar to `computed` from Angular, this function runs\n * in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.\n * @returns The query result, typed so that `data` is never `undefined` (unless a `select` changes `TData` to\n * include `undefined`).\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like\n * `queryClient.query`.\n * @example\n * ```angular-ts\n * @Component({\n * selector: 'posts',\n * template: `\n * <!-- `postsQuery.data()` is `Post[]`, never `undefined`, thanks to `initialData` — even if a\n * refetch fails, so the list stays visible alongside the error. -->\n * @if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * }\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * `,\n * })\n * export class Posts {\n * readonly postsQuery = injectQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * }))\n * }\n * ```\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => DefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n): DefinedCreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * @param optionsFn - A function returning the {@link UndefinedInitialDataOptions} to use — everything\n * you can pass to `injectQuery`. Similar to `computed` from Angular, this function runs in the reactive\n * context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.\n * @returns The query result. `status()` is `'pending'` if there is no cached data to display, `'error'` if\n * the last fetch attempt failed, or `'success'` if the query has data to display. `isPending`/`isSuccess`/\n * `isError` are type-guard methods for convenience.\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like\n * `queryClient.query`.\n * @example\n * ```angular-ts\n * @Component({\n * selector: 'posts',\n * template: `\n * @if (postsQuery.isPending()) {\n * Loading...\n * } @else if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * } @else {\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * }\n * `,\n * })\n * export class Posts {\n * readonly postsQuery = injectQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * }))\n * }\n * ```\n * @example\n * Similar to `computed` from Angular, the function passed to `injectQuery` runs in the reactive context. In\n * the example below, the query is automatically enabled and executed when the filter signal changes to a\n * truthy value. When the filter signal changes back to a falsy value, the query is disabled.\n * ```angular-ts\n * @Component({\n * selector: 'posts',\n * template: `\n * <input [ngModel]=\"filter()\" (ngModelChange)=\"filter.set($event)\" />\n * @if (postsQuery.isPending()) {\n * Loading...\n * } @else if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * } @else {\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * }\n * `,\n * })\n * export class Posts {\n * readonly filter = signal('')\n *\n * readonly postsQuery = injectQuery(() => ({\n * queryKey: ['posts', this.filter()],\n * queryFn: () => fetchPosts(this.filter()),\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => UndefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n): CreateQueryResult<TData, TError>\n\n/**\n * This overload accepts the general {@link CreateQueryOptions} shape rather than the `initialData`-aware\n * overloads above, so whether `data` is defined can't be inferred from the call site — useful when wrapping\n * `injectQuery` in your own helper function that forwards caller-provided options.\n * @param optionsFn - A function that returns query options. Similar to `computed` from Angular, this\n * function runs in the reactive context, so signals read inside it drive the query.\n * @returns The query result.\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): CreateQueryResult<TData, TError>\n\nexport function injectQuery(\n optionsFn: () => CreateQueryOptions,\n): DefinedCreateQueryResult | CreateQueryResult {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertInInjectionContext(injectQuery)\n }\n const outsideZone = injectQueryZone()\n const [resultSignal, getObserver] = injectBaseQuery(optionsFn, QueryObserver)\n return Object.assign(signalProxy(resultSignal, queryResultFields), {\n refetch: (options?: RefetchOptions) =>\n outsideZone(() => untracked(() => getObserver().refetch(options))),\n }) as unknown as DefinedCreateQueryResult | CreateQueryResult\n}\n"],"mappings":";;;;;;;AA6KA,SAAgB,YACd,WAC8C;CAC9C,IAAI,OAAO,cAAc,eAAe,WACtC,yBAAyB,WAAW;CAEtC,MAAM,cAAc,gBAAgB;CACpC,MAAM,CAAC,cAAc,eAAe,gBAAgB,WAAW,aAAa;CAC5E,OAAO,OAAO,OAAO,YAAY,cAAc,iBAAiB,GAAG,EACjE,UAAU,YACR,kBAAkB,gBAAgB,YAAY,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,EACrE,CAAC;AACH"}
1
+ {"version":3,"file":"inject-query.mjs","names":[],"sources":["../src/inject-query.ts"],"sourcesContent":["import { assertInInjectionContext, untracked } from '@angular/core'\nimport { QueryObserver } from '@tanstack/query-core'\nimport { injectBaseQuery } from './inject-base-query'\nimport { injectQueryZone } from './utils/inject-query-zone'\nimport { queryResultFields } from './utils/result-fields'\nimport { signalProxy } from './utils/signal-proxy'\nimport type {\n DefaultError,\n QueryKey,\n RefetchOptions,\n} from '@tanstack/query-core'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './query-options'\nimport type {\n CreateQueryOptions,\n CreateQueryResult,\n DefinedCreateQueryResult,\n} from './types'\n\n/**\n * This overload is selected when `initialData` is known to be defined on the options returned by `optionsFn`, so the\n * resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param optionsFn - A function returning the {@link DefinedInitialDataOptions} to use — everything you\n * can pass to `injectQuery`, with `initialData` known to be defined. Similar to `computed` from Angular, this function runs\n * in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.\n * @returns The query result, typed so that `data` is never `undefined` (unless a `select` changes `TData` to\n * include `undefined`). At runtime, `data` is still `undefined` if `select` throws on its first call.\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like\n * `queryClient.query`.\n * @example\n * ```angular-ts\n * @Component({\n * selector: 'posts',\n * template: `\n * <!-- `postsQuery.data()` is `Post[]`, never `undefined`, thanks to `initialData` — even if a\n * refetch fails, so the list stays visible alongside the error. -->\n * @if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * }\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * `,\n * })\n * export class Posts {\n * readonly postsQuery = injectQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * }))\n * }\n * ```\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => DefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n): DefinedCreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * @param optionsFn - A function returning the {@link UndefinedInitialDataOptions} to use — everything\n * you can pass to `injectQuery`. Similar to `computed` from Angular, this function runs in the reactive\n * context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.\n * @returns The query result. `status()` is `'error'` if the query has an error from a fetch that failed\n * after its retries or if `select` threw, `'success'` if the query has cached data (even if `select`\n * returns `undefined`) or data from `placeholderData`, and `'pending'` otherwise.\n * `isPending`/`isSuccess`/`isError` are type-guard methods for convenience.\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n * @see {@link queryOptions} to share these options between `injectQuery` and imperative APIs like\n * `queryClient.query`.\n * @example\n * ```angular-ts\n * @Component({\n * selector: 'posts',\n * template: `\n * @if (postsQuery.isPending()) {\n * Loading...\n * } @else if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * } @else {\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * }\n * `,\n * })\n * export class Posts {\n * readonly postsQuery = injectQuery(() => ({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * }))\n * }\n * ```\n * @example\n * Similar to `computed` from Angular, the function passed to `injectQuery` runs in the reactive context. In\n * the example below, the query is automatically enabled and executed when the filter signal changes to a\n * truthy value. When the filter signal changes back to a falsy value, the query is disabled.\n * ```angular-ts\n * @Component({\n * selector: 'posts',\n * template: `\n * <input [ngModel]=\"filter()\" (ngModelChange)=\"filter.set($event)\" />\n * @if (postsQuery.isPending()) {\n * Loading...\n * } @else if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * } @else {\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * }\n * `,\n * })\n * export class Posts {\n * readonly filter = signal('')\n *\n * readonly postsQuery = injectQuery(() => ({\n * queryKey: ['posts', this.filter()],\n * queryFn: () => fetchPosts(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => UndefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n): CreateQueryResult<TData, TError>\n\n/**\n * This overload accepts the general {@link CreateQueryOptions} shape rather than the `initialData`-aware\n * overloads above, so whether `data` is defined can't be inferred from the call site — useful when wrapping\n * `injectQuery` in your own helper function that forwards caller-provided options.\n * @param optionsFn - A function that returns query options. Similar to `computed` from Angular, this\n * function runs in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive\n * the query.\n * @returns The query result.\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n): CreateQueryResult<TData, TError>\n\nexport function injectQuery(\n optionsFn: () => CreateQueryOptions,\n): DefinedCreateQueryResult | CreateQueryResult {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertInInjectionContext(injectQuery)\n }\n const outsideZone = injectQueryZone()\n const [resultSignal, getObserver] = injectBaseQuery(optionsFn, QueryObserver)\n return Object.assign(signalProxy(resultSignal, queryResultFields), {\n refetch: (options?: RefetchOptions) =>\n outsideZone(() => untracked(() => getObserver().refetch(options))),\n }) as unknown as DefinedCreateQueryResult | CreateQueryResult\n}\n"],"mappings":";;;;;;;AAgLA,SAAgB,YACd,WAC8C;CAC9C,IAAI,OAAO,cAAc,eAAe,WACtC,yBAAyB,WAAW;CAEtC,MAAM,cAAc,gBAAgB;CACpC,MAAM,CAAC,cAAc,eAAe,gBAAgB,WAAW,aAAa;CAC5E,OAAO,OAAO,OAAO,YAAY,cAAc,iBAAiB,GAAG,EACjE,UAAU,YACR,kBAAkB,gBAAgB,YAAY,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,EACrE,CAAC;AACH"}
@@ -1,8 +1,7 @@
1
- //#region src/mutation-options.ts
1
+ // src/mutation-options.ts
2
2
  function mutationOptions(options) {
3
3
  return options;
4
4
  }
5
- //#endregion
6
5
  export { mutationOptions };
7
6
 
8
7
  //# sourceMappingURL=mutation-options.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/angular-query",
3
- "version": "5.0.0-rc.5",
3
+ "version": "5.108.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",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "sideEffects": false,
47
47
  "dependencies": {
48
- "@tanstack/query-core": "5.104.3"
48
+ "@tanstack/query-core": "5.108.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@angular/common": ">=20.1.0",
package/providers.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { QueryClient } from '@tanstack/query-core';
2
2
  import { EnvironmentProviders } from '@angular/core';
3
3
  /**
4
- * Provides a `QueryClient` and optional TanStack Query features.
5
- * The factory runs once per injector in Angular's injection context, so it can
6
- * call `inject()` and each SSR request can receive an independent cache.
4
+ * Sets up providers necessary to enable TanStack Query functionality for Angular applications. Provides a
5
+ * `QueryClient` and optional TanStack Query features. The factory runs once per injector in Angular's
6
+ * injection context, so it can call `inject()` and each SSR request can receive an independent cache.
7
7
  * @param queryClientFactory - Creates or resolves a `QueryClient` in the injection context.
8
8
  * @param features - Optional features to configure additional Query functionality.
9
9
  * @returns A single {@link EnvironmentProviders} value (do not spread into `providers`).
@@ -21,10 +21,22 @@ import { EnvironmentProviders } from '@angular/core';
21
21
  * providers: [provideTanStackQuery(() => new QueryClient())],
22
22
  * })
23
23
  * ```
24
+ * @example
25
+ * The same, in an `NgModule`-based application:
26
+ * ```ts
27
+ * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
24
28
  *
25
- * You can also enable optional developer tools by adding `withDevtools`. By
26
- * default the tools will then be loaded when your app is in development mode.
27
- *
29
+ * @NgModule({
30
+ * declarations: [AppComponent],
31
+ * imports: [BrowserModule],
32
+ * providers: [provideTanStackQuery(() => new QueryClient())],
33
+ * bootstrap: [AppComponent],
34
+ * })
35
+ * export class AppModule {}
36
+ * ```
37
+ * @example
38
+ * Enabling optional developer tools by adding `withDevtools` — by default, the tools are then loaded when
39
+ * your app is in development mode:
28
40
  * ```ts
29
41
  * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
30
42
  * import { withDevtools } from '@tanstack/angular-query-devtools'
@@ -35,6 +47,19 @@ import { EnvironmentProviders } from '@angular/core';
35
47
  * ],
36
48
  * })
37
49
  * ```
50
+ * @example
51
+ * Resolving the `QueryClient` from an `InjectionToken` — an advanced optimization that lets TanStack Query
52
+ * be absent from the main application bundle, useful for including it on lazy-loaded routes only while
53
+ * still sharing a `QueryClient`. This is a small optimization; for most applications it's preferable to
54
+ * provide the `QueryClient` in the main application config, as in the examples above:
55
+ * ```ts
56
+ * export const MY_QUERY_CLIENT = new InjectionToken('', {
57
+ * factory: () => new QueryClient(),
58
+ * })
59
+ *
60
+ * // In a lazy loaded route's providers array:
61
+ * providers: [provideTanStackQuery(() => inject(MY_QUERY_CLIENT))]
62
+ * ```
38
63
  */
39
64
  export declare function provideTanStackQuery(queryClientFactory: () => QueryClient, ...features: ReadonlyArray<QueryFeature>): EnvironmentProviders;
40
65
  declare const queryFeatureBrand: unique symbol;
package/providers.mjs CHANGED
@@ -3,7 +3,7 @@ import { INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY } from "./hydration-stat
3
3
  import { QueryClient, dehydrate, hydrate } from "@tanstack/query-core";
4
4
  import { DOCUMENT, DestroyRef, InjectionToken, PLATFORM_ID, TransferState, inject, makeEnvironmentProviders, makeStateKey, provideEnvironmentInitializer } from "@angular/core";
5
5
  import { isPlatformBrowser, isPlatformServer } from "@angular/common";
6
- //#region src/providers.ts
6
+ // src/providers.ts
7
7
  var INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE = new InjectionToken("", {
8
8
  providedIn: "root",
9
9
  factory: () => true
@@ -47,9 +47,9 @@ function configureQueryClient() {
47
47
  destroyRef.onDestroy(() => queryClient.unmount());
48
48
  }
49
49
  /**
50
- * Provides a `QueryClient` and optional TanStack Query features.
51
- * The factory runs once per injector in Angular's injection context, so it can
52
- * call `inject()` and each SSR request can receive an independent cache.
50
+ * Sets up providers necessary to enable TanStack Query functionality for Angular applications. Provides a
51
+ * `QueryClient` and optional TanStack Query features. The factory runs once per injector in Angular's
52
+ * injection context, so it can call `inject()` and each SSR request can receive an independent cache.
53
53
  * @param queryClientFactory - Creates or resolves a `QueryClient` in the injection context.
54
54
  * @param features - Optional features to configure additional Query functionality.
55
55
  * @returns A single {@link EnvironmentProviders} value (do not spread into `providers`).
@@ -67,10 +67,22 @@ function configureQueryClient() {
67
67
  * providers: [provideTanStackQuery(() => new QueryClient())],
68
68
  * })
69
69
  * ```
70
+ * @example
71
+ * The same, in an `NgModule`-based application:
72
+ * ```ts
73
+ * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
70
74
  *
71
- * You can also enable optional developer tools by adding `withDevtools`. By
72
- * default the tools will then be loaded when your app is in development mode.
73
- *
75
+ * @NgModule({
76
+ * declarations: [AppComponent],
77
+ * imports: [BrowserModule],
78
+ * providers: [provideTanStackQuery(() => new QueryClient())],
79
+ * bootstrap: [AppComponent],
80
+ * })
81
+ * export class AppModule {}
82
+ * ```
83
+ * @example
84
+ * Enabling optional developer tools by adding `withDevtools` — by default, the tools are then loaded when
85
+ * your app is in development mode:
74
86
  * ```ts
75
87
  * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'
76
88
  * import { withDevtools } from '@tanstack/angular-query-devtools'
@@ -81,6 +93,19 @@ function configureQueryClient() {
81
93
  * ],
82
94
  * })
83
95
  * ```
96
+ * @example
97
+ * Resolving the `QueryClient` from an `InjectionToken` — an advanced optimization that lets TanStack Query
98
+ * be absent from the main application bundle, useful for including it on lazy-loaded routes only while
99
+ * still sharing a `QueryClient`. This is a small optimization; for most applications it's preferable to
100
+ * provide the `QueryClient` in the main application config, as in the examples above:
101
+ * ```ts
102
+ * export const MY_QUERY_CLIENT = new InjectionToken('', {
103
+ * factory: () => new QueryClient(),
104
+ * })
105
+ *
106
+ * // In a lazy loaded route's providers array:
107
+ * providers: [provideTanStackQuery(() => inject(MY_QUERY_CLIENT))]
108
+ * ```
84
109
  */
85
110
  function provideTanStackQuery(queryClientFactory, ...features) {
86
111
  return makeEnvironmentProviders([
@@ -146,7 +171,6 @@ function withNoQueryHydration() {
146
171
  useValue: false
147
172
  }]));
148
173
  }
149
- //#endregion
150
174
  export { getQueryFeatureProviders, provideTanStackQuery, queryFeature, withHydrationKey, withNoQueryHydration };
151
175
 
152
176
  //# sourceMappingURL=providers.mjs.map
package/providers.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"providers.mjs","names":[],"sources":["../src/providers.ts"],"sourcesContent":["import { isPlatformBrowser, isPlatformServer } from '@angular/common'\nimport {\n DOCUMENT,\n DestroyRef,\n InjectionToken,\n PLATFORM_ID,\n TransferState,\n inject,\n makeEnvironmentProviders,\n makeStateKey,\n provideEnvironmentInitializer,\n} from '@angular/core'\nimport { QueryClient, dehydrate, hydrate } from '@tanstack/query-core'\nimport { INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY } from './hydration-state-key'\nimport { injectQueryZone } from './utils/inject-query-zone'\nimport type { DehydratedState } from '@tanstack/query-core'\nimport type { EnvironmentProviders } from '@angular/core'\n\nconst INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE = new InjectionToken<boolean>('', {\n providedIn: 'root',\n factory: () => true,\n})\n\n/**\n * Mounts the injected client, configures server defaults, and connects TransferState hydration.\n */\nfunction configureQueryClient() {\n const queryClient = inject(QueryClient)\n const destroyRef = inject(DestroyRef)\n const platformId = inject(PLATFORM_ID)\n\n if (isPlatformServer(platformId)) {\n // DOM emulation can fool core's runtime detection. Apply server defaults to\n // this client without changing other clients or global scheduling providers.\n const defaults = queryClient.getDefaultOptions()\n queryClient.setDefaultOptions({\n ...defaults,\n queries: { gcTime: Infinity, retry: false, ...defaults.queries },\n mutations: { gcTime: Infinity, ...defaults.mutations },\n })\n }\n const shouldHydrate = inject(INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE)\n const hydrationStateKey = inject(\n INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY,\n )\n\n if (inject(DOCUMENT, { optional: true })) {\n const transferState = inject(TransferState)\n\n if (shouldHydrate && isPlatformServer(platformId)) {\n transferState.onSerialize(hydrationStateKey, () => dehydrate(queryClient))\n } else if (shouldHydrate && isPlatformBrowser(platformId)) {\n const dehydratedState = transferState.get(hydrationStateKey, null)\n if (dehydratedState) {\n hydrate(queryClient, dehydratedState)\n transferState.remove(hydrationStateKey)\n }\n }\n }\n\n queryClient.mount()\n destroyRef.onDestroy(() => queryClient.unmount())\n}\n\n/**\n * Provides a `QueryClient` and optional TanStack Query features.\n * The factory runs once per injector in Angular's injection context, so it can\n * call `inject()` and each SSR request can receive an independent cache.\n * @param queryClientFactory - Creates or resolves a `QueryClient` in the injection context.\n * @param features - Optional features to configure additional Query functionality.\n * @returns A single {@link EnvironmentProviders} value (do not spread into `providers`).\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @see https://tanstack.com/query/v5/docs/framework/angular/devtools\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/ssr\n * @example\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideTanStackQuery(() => new QueryClient())],\n * })\n * ```\n *\n * You can also enable optional developer tools by adding `withDevtools`. By\n * default the tools will then be loaded when your app is in development mode.\n *\n * ```ts\n * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'\n * import { withDevtools } from '@tanstack/angular-query-devtools'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideTanStackQuery(() => new QueryClient(), withDevtools()),\n * ],\n * })\n * ```\n */\nexport function provideTanStackQuery(\n queryClientFactory: () => QueryClient,\n ...features: ReadonlyArray<QueryFeature>\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: QueryClient,\n useFactory: () => injectQueryZone()(queryClientFactory),\n },\n ...features.map(getQueryFeatureProviders),\n provideEnvironmentInitializer(configureQueryClient),\n ])\n}\n\nconst queryFeatureBrand: unique symbol = Symbol('QueryFeature')\n\n/**\n * Opaque configuration returned by Query feature functions such as `withHydrationKey`.\n * Pass features to `provideTanStackQuery`; applications do not construct them directly.\n */\nexport interface QueryFeature {\n /** @internal */\n readonly [queryFeatureBrand]: true\n}\n\ninterface InternalQueryFeature extends QueryFeature {\n readonly ɵproviders: EnvironmentProviders\n}\n\n/**\n * Creates a feature shared by Angular Query integration packages.\n * @internal\n * @param providers - Providers owned by this Query feature.\n * @returns An opaque feature that installs the supplied environment providers.\n */\nexport function queryFeature(providers: EnvironmentProviders): QueryFeature {\n const feature: InternalQueryFeature = {\n [queryFeatureBrand]: true,\n ɵproviders: providers,\n }\n\n return feature\n}\n\n/**\n * Gets the environment providers owned by an opaque Query feature.\n * @internal\n * @param feature - The feature to unwrap.\n * @returns The environment providers to install.\n */\nexport function getQueryFeatureProviders(\n feature: QueryFeature,\n): EnvironmentProviders {\n return (feature as InternalQueryFeature).ɵproviders\n}\n\n/**\n * Sets a non-default serialization key for this injector's `QueryClient` cache (server dehydrate /\n * browser hydrate via `TransferState`). Use this when you have multiple `QueryClient` instances\n * so each has its own key. The default key applies when you do not add this feature.\n *\n * ```ts\n * providers: [\n * provideTanStackQuery(\n * () => new QueryClient(),\n * withHydrationKey('my-secondary-query-cache'),\n * ),\n * ]\n * ```\n * @param key - A unique string for this client's `TransferState` entry.\n * @returns A feature that stores this client's cache under the supplied key.\n */\nexport function withHydrationKey(key: string): QueryFeature {\n return queryFeature(\n makeEnvironmentProviders([\n {\n provide: INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY,\n useValue: makeStateKey<DehydratedState>(key),\n },\n ]),\n )\n}\n\n/**\n * Disables `TransferState` hydration and dehydration for the current environment injector.\n * @returns A feature that prevents automatic cache transfer for this injector.\n */\nexport function withNoQueryHydration(): QueryFeature {\n return queryFeature(\n makeEnvironmentProviders([\n {\n provide: INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE,\n useValue: false,\n },\n ]),\n )\n}\n"],"mappings":";;;;;;AAkBA,IAAM,uCAAuC,IAAI,eAAwB,IAAI;CAC3E,YAAY;CACZ,eAAe;AACjB,CAAC;;;;AAKD,SAAS,uBAAuB;CAC9B,MAAM,cAAc,OAAO,WAAW;CACtC,MAAM,aAAa,OAAO,UAAU;CACpC,MAAM,aAAa,OAAO,WAAW;CAErC,IAAI,iBAAiB,UAAU,GAAG;EAGhC,MAAM,WAAW,YAAY,kBAAkB;EAC/C,YAAY,kBAAkB;GAC5B,GAAG;GACH,SAAS;IAAE,QAAQ;IAAU,OAAO;IAAO,GAAG,SAAS;GAAQ;GAC/D,WAAW;IAAE,QAAQ;IAAU,GAAG,SAAS;GAAU;EACvD,CAAC;CACH;CACA,MAAM,gBAAgB,OAAO,oCAAoC;CACjE,MAAM,oBAAoB,OACxB,8CACF;CAEA,IAAI,OAAO,UAAU,EAAE,UAAU,KAAK,CAAC,GAAG;EACxC,MAAM,gBAAgB,OAAO,aAAa;EAE1C,IAAI,iBAAiB,iBAAiB,UAAU,GAC9C,cAAc,YAAY,yBAAyB,UAAU,WAAW,CAAC;OACpE,IAAI,iBAAiB,kBAAkB,UAAU,GAAG;GACzD,MAAM,kBAAkB,cAAc,IAAI,mBAAmB,IAAI;GACjE,IAAI,iBAAiB;IACnB,QAAQ,aAAa,eAAe;IACpC,cAAc,OAAO,iBAAiB;GACxC;EACF;CACF;CAEA,YAAY,MAAM;CAClB,WAAW,gBAAgB,YAAY,QAAQ,CAAC;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,qBACd,oBACA,GAAG,UACmB;CACtB,OAAO,yBAAyB;EAC9B;GACE,SAAS;GACT,kBAAkB,gBAAgB,CAAC,CAAC,kBAAkB;EACxD;EACA,GAAG,SAAS,IAAI,wBAAwB;EACxC,8BAA8B,oBAAoB;CACpD,CAAC;AACH;AAEA,IAAM,oBAAmC,OAAO,cAAc;;;;;;;AAqB9D,SAAgB,aAAa,WAA+C;CAM1E,OAAO;GAJJ,oBAAoB;EACrB,YAAY;CAGP;AACT;;;;;;;AAQA,SAAgB,yBACd,SACsB;CACtB,OAAQ,QAAiC;AAC3C;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,KAA2B;CAC1D,OAAO,aACL,yBAAyB,CACvB;EACE,SAAS;EACT,UAAU,aAA8B,GAAG;CAC7C,CACF,CAAC,CACH;AACF;;;;;AAMA,SAAgB,uBAAqC;CACnD,OAAO,aACL,yBAAyB,CACvB;EACE,SAAS;EACT,UAAU;CACZ,CACF,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"providers.mjs","names":[],"sources":["../src/providers.ts"],"sourcesContent":["import { isPlatformBrowser, isPlatformServer } from '@angular/common'\nimport {\n DOCUMENT,\n DestroyRef,\n InjectionToken,\n PLATFORM_ID,\n TransferState,\n inject,\n makeEnvironmentProviders,\n makeStateKey,\n provideEnvironmentInitializer,\n} from '@angular/core'\nimport { QueryClient, dehydrate, hydrate } from '@tanstack/query-core'\nimport { INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY } from './hydration-state-key'\nimport { injectQueryZone } from './utils/inject-query-zone'\nimport type { EnvironmentProviders } from '@angular/core'\nimport type { DehydratedState } from '@tanstack/query-core'\n\nconst INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE = new InjectionToken<boolean>('', {\n providedIn: 'root',\n factory: () => true,\n})\n\n/**\n * Mounts the injected client, configures server defaults, and connects TransferState hydration.\n */\nfunction configureQueryClient() {\n const queryClient = inject(QueryClient)\n const destroyRef = inject(DestroyRef)\n const platformId = inject(PLATFORM_ID)\n\n if (isPlatformServer(platformId)) {\n // DOM emulation can fool core's runtime detection. Apply server defaults to\n // this client without changing other clients or global scheduling providers.\n const defaults = queryClient.getDefaultOptions()\n queryClient.setDefaultOptions({\n ...defaults,\n queries: { gcTime: Infinity, retry: false, ...defaults.queries },\n mutations: { gcTime: Infinity, ...defaults.mutations },\n })\n }\n const shouldHydrate = inject(INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE)\n const hydrationStateKey = inject(\n INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY,\n )\n\n if (inject(DOCUMENT, { optional: true })) {\n const transferState = inject(TransferState)\n\n if (shouldHydrate && isPlatformServer(platformId)) {\n transferState.onSerialize(hydrationStateKey, () => dehydrate(queryClient))\n } else if (shouldHydrate && isPlatformBrowser(platformId)) {\n const dehydratedState = transferState.get(hydrationStateKey, null)\n if (dehydratedState) {\n hydrate(queryClient, dehydratedState)\n transferState.remove(hydrationStateKey)\n }\n }\n }\n\n queryClient.mount()\n destroyRef.onDestroy(() => queryClient.unmount())\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications. Provides a\n * `QueryClient` and optional TanStack Query features. The factory runs once per injector in Angular's\n * injection context, so it can call `inject()` and each SSR request can receive an independent cache.\n * @param queryClientFactory - Creates or resolves a `QueryClient` in the injection context.\n * @param features - Optional features to configure additional Query functionality.\n * @returns A single {@link EnvironmentProviders} value (do not spread into `providers`).\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @see https://tanstack.com/query/v5/docs/framework/angular/devtools\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/ssr\n * @example\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideTanStackQuery(() => new QueryClient())],\n * })\n * ```\n * @example\n * The same, in an `NgModule`-based application:\n * ```ts\n * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'\n *\n * @NgModule({\n * declarations: [AppComponent],\n * imports: [BrowserModule],\n * providers: [provideTanStackQuery(() => new QueryClient())],\n * bootstrap: [AppComponent],\n * })\n * export class AppModule {}\n * ```\n * @example\n * Enabling optional developer tools by adding `withDevtools` — by default, the tools are then loaded when\n * your app is in development mode:\n * ```ts\n * import { provideTanStackQuery, QueryClient } from '@tanstack/angular-query'\n * import { withDevtools } from '@tanstack/angular-query-devtools'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideTanStackQuery(() => new QueryClient(), withDevtools()),\n * ],\n * })\n * ```\n * @example\n * Resolving the `QueryClient` from an `InjectionToken` — an advanced optimization that lets TanStack Query\n * be absent from the main application bundle, useful for including it on lazy-loaded routes only while\n * still sharing a `QueryClient`. This is a small optimization; for most applications it's preferable to\n * provide the `QueryClient` in the main application config, as in the examples above:\n * ```ts\n * export const MY_QUERY_CLIENT = new InjectionToken('', {\n * factory: () => new QueryClient(),\n * })\n *\n * // In a lazy loaded route's providers array:\n * providers: [provideTanStackQuery(() => inject(MY_QUERY_CLIENT))]\n * ```\n */\nexport function provideTanStackQuery(\n queryClientFactory: () => QueryClient,\n ...features: ReadonlyArray<QueryFeature>\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: QueryClient,\n useFactory: () => injectQueryZone()(queryClientFactory),\n },\n ...features.map(getQueryFeatureProviders),\n provideEnvironmentInitializer(configureQueryClient),\n ])\n}\n\nconst queryFeatureBrand: unique symbol = Symbol('QueryFeature')\n\n/**\n * Opaque configuration returned by Query feature functions such as `withHydrationKey`.\n * Pass features to `provideTanStackQuery`; applications do not construct them directly.\n */\nexport interface QueryFeature {\n /** @internal */\n readonly [queryFeatureBrand]: true\n}\n\ninterface InternalQueryFeature extends QueryFeature {\n readonly ɵproviders: EnvironmentProviders\n}\n\n/**\n * Creates a feature shared by Angular Query integration packages.\n * @internal\n * @param providers - Providers owned by this Query feature.\n * @returns An opaque feature that installs the supplied environment providers.\n */\nexport function queryFeature(providers: EnvironmentProviders): QueryFeature {\n const feature: InternalQueryFeature = {\n [queryFeatureBrand]: true,\n ɵproviders: providers,\n }\n\n return feature\n}\n\n/**\n * Gets the environment providers owned by an opaque Query feature.\n * @internal\n * @param feature - The feature to unwrap.\n * @returns The environment providers to install.\n */\nexport function getQueryFeatureProviders(\n feature: QueryFeature,\n): EnvironmentProviders {\n return (feature as InternalQueryFeature).ɵproviders\n}\n\n/**\n * Sets a non-default serialization key for this injector's `QueryClient` cache (server dehydrate /\n * browser hydrate via `TransferState`). Use this when you have multiple `QueryClient` instances\n * so each has its own key. The default key applies when you do not add this feature.\n *\n * ```ts\n * providers: [\n * provideTanStackQuery(\n * () => new QueryClient(),\n * withHydrationKey('my-secondary-query-cache'),\n * ),\n * ]\n * ```\n * @param key - A unique string for this client's `TransferState` entry.\n * @returns A feature that stores this client's cache under the supplied key.\n */\nexport function withHydrationKey(key: string): QueryFeature {\n return queryFeature(\n makeEnvironmentProviders([\n {\n provide: INTERNAL_TANSTACK_QUERY_HYDRATION_TRANSFER_KEY,\n useValue: makeStateKey<DehydratedState>(key),\n },\n ]),\n )\n}\n\n/**\n * Disables `TransferState` hydration and dehydration for the current environment injector.\n * @returns A feature that prevents automatic cache transfer for this injector.\n */\nexport function withNoQueryHydration(): QueryFeature {\n return queryFeature(\n makeEnvironmentProviders([\n {\n provide: INTERNAL_QUERY_CLIENT_SHOULD_HYDRATE,\n useValue: false,\n },\n ]),\n )\n}\n"],"mappings":";;;;;;AAkBA,IAAM,uCAAuC,IAAI,eAAwB,IAAI;CAC3E,YAAY;CACZ,eAAe;AACjB,CAAC;;;;AAKD,SAAS,uBAAuB;CAC9B,MAAM,cAAc,OAAO,WAAW;CACtC,MAAM,aAAa,OAAO,UAAU;CACpC,MAAM,aAAa,OAAO,WAAW;CAErC,IAAI,iBAAiB,UAAU,GAAG;EAGhC,MAAM,WAAW,YAAY,kBAAkB;EAC/C,YAAY,kBAAkB;GAC5B,GAAG;GACH,SAAS;IAAE,QAAQ;IAAU,OAAO;IAAO,GAAG,SAAS;GAAQ;GAC/D,WAAW;IAAE,QAAQ;IAAU,GAAG,SAAS;GAAU;EACvD,CAAC;CACH;CACA,MAAM,gBAAgB,OAAO,oCAAoC;CACjE,MAAM,oBAAoB,OACxB,8CACF;CAEA,IAAI,OAAO,UAAU,EAAE,UAAU,KAAK,CAAC,GAAG;EACxC,MAAM,gBAAgB,OAAO,aAAa;EAE1C,IAAI,iBAAiB,iBAAiB,UAAU,GAC9C,cAAc,YAAY,yBAAyB,UAAU,WAAW,CAAC;OACpE,IAAI,iBAAiB,kBAAkB,UAAU,GAAG;GACzD,MAAM,kBAAkB,cAAc,IAAI,mBAAmB,IAAI;GACjE,IAAI,iBAAiB;IACnB,QAAQ,aAAa,eAAe;IACpC,cAAc,OAAO,iBAAiB;GACxC;EACF;CACF;CAEA,YAAY,MAAM;CAClB,WAAW,gBAAgB,YAAY,QAAQ,CAAC;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,SAAgB,qBACd,oBACA,GAAG,UACmB;CACtB,OAAO,yBAAyB;EAC9B;GACE,SAAS;GACT,kBAAkB,gBAAgB,CAAC,CAAC,kBAAkB;EACxD;EACA,GAAG,SAAS,IAAI,wBAAwB;EACxC,8BAA8B,oBAAoB;CACpD,CAAC;AACH;AAEA,IAAM,oBAAmC,OAAO,cAAc;;;;;;;AAqB9D,SAAgB,aAAa,WAA+C;CAM1E,OAAO;GAJJ,oBAAoB;EACrB,YAAY;CAGP;AACT;;;;;;;AAQA,SAAgB,yBACd,SACsB;CACtB,OAAQ,QAAiC;AAC3C;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,KAA2B;CAC1D,OAAO,aACL,yBAAyB,CACvB;EACE,SAAS;EACT,UAAU,aAA8B,GAAG;CAC7C,CACF,CAAC,CACH;AACF;;;;;AAMA,SAAgB,uBAAqC;CACnD,OAAO,aACL,yBAAyB,CACvB;EACE,SAAS;EACT,UAAU;CACZ,CACF,CAAC,CACH;AACF"}
@@ -1,8 +1,9 @@
1
1
  import { DefaultError, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, QueryKeyWithDataTag, SkipToken } from '@tanstack/query-core';
2
2
  import { CreateQueryOptions } from './types.js';
3
3
  /**
4
- * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be
5
- * `undefined` while the query is `pending`.
4
+ * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be
5
+ * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
6
+ * `pending`.
6
7
  * @template TQueryFnData - The type your `queryFn` resolves to.
7
8
  * @template TError - The type of errors your `queryFn` may throw.
8
9
  * @template TData - The type `data` ends up as after `select` runs.
@@ -19,8 +20,9 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
19
20
  initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
20
21
  };
21
22
  /**
22
- * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is
23
- * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
23
+ * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and
24
+ * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
25
+ * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
24
26
  * @template TQueryFnData - The type your `queryFn` resolves to.
25
27
  * @template TError - The type of errors your `queryFn` may throw.
26
28
  * @template TData - The type `data` ends up as after `select` runs.
@@ -28,22 +30,30 @@ export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = Default
28
30
  */
29
31
  export type UnusedSkipTokenOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = OmitKeyof<CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, 'queryFn'> & {
30
32
  /**
31
- * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If
32
- * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a
33
- * fetch that fails with "Missing queryFn" unless `enabled` is `false` or a default query function has been
34
- * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.
33
+ * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
34
+ * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
35
+ * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
36
+ * unless `enabled` is `false` or a default query function has been defined. A default query function only
37
+ * supplies `queryFn`; it doesn't defer the fetch on its own.
35
38
  */
36
39
  queryFn?: Exclude<CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'], SkipToken | undefined>;
37
40
  };
38
41
  /**
39
- * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
40
- * `undefined` (unless a `select` changes `TData` to include `undefined`).
42
+ * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —
43
+ * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
41
44
  * @template TQueryFnData - The type your `queryFn` resolves to.
42
45
  * @template TError - The type of errors your `queryFn` may throw.
43
46
  * @template TData - The type `data` ends up as after `select` runs.
44
47
  * @template TQueryKey - The type of your `queryKey`.
45
48
  */
46
49
  export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
50
+ /**
51
+ * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been
52
+ * created or cached yet). If set to a function, the function will be called **once** during the shared/root
53
+ * query initialization, and be expected to synchronously return the initial data. Initial data is
54
+ * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the
55
+ * cache.
56
+ */
47
57
  initialData: NonUndefinedGuard<TQueryFnData> | (() => NonUndefinedGuard<TQueryFnData>);
48
58
  };
49
59
  /**
@@ -51,10 +61,10 @@ export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultEr
51
61
  * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is
52
62
  * required and is the query key to generate options for.
53
63
  *
54
- * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
55
- * a `select` changes `TData` to include `undefined`).
64
+ * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
65
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
56
66
  * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `injectQuery`,
57
- * with `initialData` set.
67
+ * with `initialData` known to be defined.
58
68
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
59
69
  * @see {@link injectQuery} to run a query with these options.
60
70
  * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
package/query-options.mjs CHANGED
@@ -1,8 +1,7 @@
1
- //#region src/query-options.ts
1
+ // src/query-options.ts
2
2
  function queryOptions(options) {
3
3
  return options;
4
4
  }
5
- //#endregion
6
5
  export { queryOptions };
7
6
 
8
7
  //# sourceMappingURL=query-options.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-options.mjs","names":[],"sources":["../src/query-options.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { CreateQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be\n * `undefined` while the query is `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is\n * not `skipToken` — same as {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when no `initialData` is set. If\n * you don't intend to run the query yet, set `enabled: false` — omitting `queryFn` alone still triggers a\n * fetch that fails with \"Missing queryFn\" unless `enabled` is `false` or a default query function has been\n * defined. A default query function only supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options\n * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is\n * required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `injectQuery`,\n * with `initialData` set.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link injectQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```angular-ts\n * import { queryOptions, injectQuery } from '@tanstack/angular-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * @Component({\n * selector: 'posts',\n * template: `\n * <!-- `postsQuery.data()` is never `undefined`, thanks to `initialData` — even if a refetch\n * fails, so the list stays visible alongside the error. -->\n * @if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * }\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * `,\n * })\n * export class Posts {\n * readonly postsQuery = injectQuery(() => postsOptions)\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options\n * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is\n * required and is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `injectQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link injectQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```angular-ts\n * import { queryOptions, injectQuery } from '@tanstack/angular-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * @Component({\n * selector: 'post',\n * template: `\n * @if (postQuery.isPending()) {\n * Loading...\n * } @else if (postQuery.isError()) {\n * <span>Error: {{ postQuery.error()?.message }}</span>\n * } @else {\n * <h1>{{ postQuery.data().title }}</h1>\n * }\n * `,\n * })\n * export class Post {\n * readonly id = signal('1')\n * readonly postQuery = injectQuery(() => postOptions(this.id()))\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options\n * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is\n * required and is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `injectQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link injectQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```angular-ts\n * import { queryOptions, injectQuery } from '@tanstack/angular-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * @Component({\n * selector: 'post',\n * template: `\n * @if (postQuery.isPending()) {\n * Loading...\n * } @else if (postQuery.isError()) {\n * <span>Error: {{ postQuery.error()?.message }}</span>\n * } @else {\n * <h1>{{ postQuery.data().title }}</h1>\n * }\n * `,\n * })\n * export class Post {\n * readonly id = signal('1')\n * readonly postQuery = injectQuery(() => postOptions(this.id()))\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```angular-ts\n * import { queryOptions, skipToken, injectQuery } from '@tanstack/angular-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * @Component({\n * selector: 'post',\n * template: `\n * @if (postId() == null) {\n * Select a post\n * } @else if (postQuery.isPending()) {\n * Loading...\n * } @else if (postQuery.isError()) {\n * <span>Error: {{ postQuery.error()?.message }}</span>\n * } @else {\n * <h1>{{ postQuery.data().title }}</h1>\n * }\n * `,\n * })\n * export class Post {\n * readonly postId = signal<number | undefined>(undefined)\n * readonly postQuery = injectQuery(() => postOptions(this.postId()))\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAuQA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
1
+ {"version":3,"file":"query-options.mjs","names":[],"sources":["../src/query-options.ts"],"sourcesContent":["import type {\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryKey,\n QueryKeyWithDataTag,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { CreateQueryOptions } from './types'\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be\n * `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is\n * `pending`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and\n * `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as\n * {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type UnusedSkipTokenOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n /**\n * `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may\n * be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,\n * set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with \"Missing queryFn\"\n * unless `enabled` is `false` or a default query function has been defined. A default query function only\n * supplies `queryFn`; it doesn't defer the fetch on its own.\n */\n queryFn?: Exclude<\n CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\n/**\n * The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —\n * `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @template TQueryFnData - The type your `queryFn` resolves to.\n * @template TError - The type of errors your `queryFn` may throw.\n * @template TData - The type `data` ends up as after `select` runs.\n * @template TQueryKey - The type of your `queryKey`.\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n /**\n * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been\n * created or cached yet). If set to a function, the function will be called **once** during the shared/root\n * query initialization, and be expected to synchronously return the initial data. Initial data is\n * considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the\n * cache.\n */\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n}\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options\n * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is\n * required and is the query key to generate options for.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `injectQuery`,\n * with `initialData` known to be defined.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link injectQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * ```angular-ts\n * import { queryOptions, injectQuery } from '@tanstack/angular-query'\n *\n * export const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * @Component({\n * selector: 'posts',\n * template: `\n * <!-- `postsQuery.data()` is never `undefined`, thanks to `initialData` — even if a refetch\n * fails, so the list stays visible alongside the error. -->\n * @if (postsQuery.isError()) {\n * <span>Error: {{ postsQuery.error()?.message }}</span>\n * }\n * <ul>\n * @for (post of postsQuery.data(); track post.id) {\n * <li>{{ post.title }}</li>\n * }\n * </ul>\n * `,\n * })\n * export class Posts {\n * readonly postsQuery = injectQuery(() => postsOptions)\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options\n * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is\n * required and is the query key to generate options for.\n * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `injectQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @see {@link injectQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```angular-ts\n * import { queryOptions, injectQuery } from '@tanstack/angular-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * @Component({\n * selector: 'post',\n * template: `\n * @if (postQuery.isPending()) {\n * Loading...\n * } @else if (postQuery.isError()) {\n * <span>Error: {{ postQuery.error()?.message }}</span>\n * } @else {\n * <h1>{{ postQuery.data().title }}</h1>\n * }\n * `,\n * })\n * export class Post {\n * readonly id = signal('1')\n * readonly postQuery = injectQuery(() => postOptions(this.id()))\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\n/**\n * You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options\n * can be shared across functions and imperative APIs such as `queryClient.query`. `options.queryKey` is\n * required and is the query key to generate options for.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `injectQuery`.\n * @returns The same options object, typed so that `queryKey` carries the inferred data type.\n * @remarks This is the only overload that accepts `queryFn: skipToken`, shown below.\n * @see {@link injectQuery} to run a query with these options.\n * @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.\n * @example\n * A parameterized factory, so the same options object can be reused per `id`:\n * ```angular-ts\n * import { queryOptions, injectQuery } from '@tanstack/angular-query'\n *\n * export const postOptions = (id: string) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * @Component({\n * selector: 'post',\n * template: `\n * @if (postQuery.isPending()) {\n * Loading...\n * } @else if (postQuery.isError()) {\n * <span>Error: {{ postQuery.error()?.message }}</span>\n * } @else {\n * <h1>{{ postQuery.data().title }}</h1>\n * }\n * `,\n * })\n * export class Post {\n * readonly id = signal('1')\n * readonly postQuery = injectQuery(() => postOptions(this.id()))\n * }\n * ```\n * @example\n * A factory that disables the query, type safe, until `postId` is set:\n * ```angular-ts\n * import { queryOptions, skipToken, injectQuery } from '@tanstack/angular-query'\n *\n * export const postOptions = (postId: number | undefined) =>\n * queryOptions({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * @Component({\n * selector: 'post',\n * template: `\n * @if (postId() == null) {\n * Select a post\n * } @else if (postQuery.isPending()) {\n * Loading...\n * } @else if (postQuery.isError()) {\n * <span>Error: {{ postQuery.error()?.message }}</span>\n * } @else {\n * <h1>{{ postQuery.data().title }}</h1>\n * }\n * `,\n * })\n * export class Post {\n * readonly postId = signal<number | undefined>(undefined)\n * readonly postQuery = injectQuery(() => postOptions(this.postId()))\n * }\n * ```\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> &\n QueryKeyWithDataTag<TQueryKey, TQueryFnData, TError>\n\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"mappings":";AAiRA,SAAgB,aAAa,SAAkB;CAC7C,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
+ import { Resource, Signal } from '@angular/core';
1
2
  import { QueryObserverResult } from '@tanstack/query-core';
2
3
  import { ResourceSnapshot } from './utils/resource-types.js';
3
- import { Resource, Signal } from '@angular/core';
4
4
  /**
5
5
  * A query-backed Angular Resource that also exposes an atomic state snapshot.
6
6
  */
@@ -29,6 +29,9 @@ type QueryResourceSource<TValue> = {
29
29
  /**
30
30
  * Converts an Angular Query result into Angular's Resource interface.
31
31
  *
32
+ * Warning: experimental feature. The API may change in minor and patch releases.
33
+ * Pin your package version to an exact version when using this feature.
34
+ *
32
35
  * Call this function once and reuse the returned resource.
33
36
  * @param query - An Angular Query or infinite-query result.
34
37
  * @returns A Resource-compatible view of the query result.
@@ -1,8 +1,11 @@
1
1
  import { computed, untracked } from "@angular/core";
2
- //#region src/query-resource.ts
2
+ // src/query-resource.ts
3
3
  /**
4
4
  * Converts an Angular Query result into Angular's Resource interface.
5
5
  *
6
+ * Warning: experimental feature. The API may change in minor and patch releases.
7
+ * Pin your package version to an exact version when using this feature.
8
+ *
6
9
  * Call this function once and reuse the returned resource.
7
10
  * @param query - An Angular Query or infinite-query result.
8
11
  * @returns A Resource-compatible view of the query result.
@@ -73,7 +76,6 @@ function normalizeError(error) {
73
76
  function isErrorLike(error) {
74
77
  return error instanceof Error || typeof error === "object" && error !== null && typeof error.name === "string" && typeof error.message === "string";
75
78
  }
76
- //#endregion
77
79
  export { toResource };
78
80
 
79
81
  //# sourceMappingURL=query-resource.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-resource.mjs","names":[],"sources":["../src/query-resource.ts"],"sourcesContent":["import { computed, untracked } from '@angular/core'\nimport type { QueryObserverResult } from '@tanstack/query-core'\nimport type { ResourceSnapshot } from './utils/resource-types'\nimport type { Resource, ResourceStatus, Signal } from '@angular/core'\n\n/**\n * A query-backed Angular Resource that also exposes an atomic state snapshot.\n */\nexport interface QueryResource<TValue> extends Resource<TValue> {\n /**\n * The current query state as a single snapshot.\n */\n readonly snapshot: Signal<ResourceSnapshot<TValue>>\n\n /**\n * Requests a new query fetch only when the current query data is stale.\n *\n * Used for compatibility with Angular APIs that might want to reload a resource,\n * like Signal Forms' validateAsync resource interface.\n * @returns `true` if a reload was initiated, `false` if a reload was unnecessary or unsupported.\n */\n reload: () => boolean\n}\n\ntype QueryResourceSource<TValue> = {\n readonly data: Signal<TValue>\n readonly status: Signal<QueryObserverResult['status']>\n readonly fetchStatus: Signal<QueryObserverResult['fetchStatus']>\n readonly error: Signal<unknown>\n readonly isStale: Signal<boolean>\n readonly refetch: () => unknown\n}\n\n/**\n * Converts an Angular Query result into Angular's Resource interface.\n *\n * Call this function once and reuse the returned resource.\n * @param query - An Angular Query or infinite-query result.\n * @returns A Resource-compatible view of the query result.\n */\nexport function toResource<TValue>(\n query: QueryResourceSource<TValue>,\n): QueryResource<TValue> {\n // Intentionally does not use resource from snapshot to have\n // support for the reload method for compatible libraries\n const status = computed<ResourceStatus>(() => {\n const fetchStatus = query.fetchStatus()\n const data = query.data()\n\n if (fetchStatus === 'fetching' || fetchStatus === 'paused') {\n return data === undefined ? 'loading' : 'reloading'\n }\n\n switch (query.status()) {\n case 'success':\n return 'resolved'\n case 'error':\n return 'error'\n case 'pending':\n return 'idle'\n }\n })\n\n const error = computed<Error | undefined>(() => {\n return query.status() === 'error'\n ? normalizeError(query.error())\n : undefined\n })\n\n const value = computed(() => {\n if (status() === 'error') {\n throw error()\n }\n\n return query.data()\n })\n\n const snapshot = computed<ResourceSnapshot<TValue>>(() => {\n const currentStatus = status()\n\n if (currentStatus === 'error') {\n return { status: 'error', error: error()! }\n }\n\n return { status: currentStatus, value: query.data() }\n })\n\n const hasValue = (() =>\n status() !== 'error' &&\n query.data() !== undefined) as QueryResource<TValue>['hasValue']\n\n return {\n value,\n status,\n error,\n snapshot,\n isLoading: computed(() => {\n const currentStatus = status()\n return currentStatus === 'loading' || currentStatus === 'reloading'\n }),\n hasValue,\n reload(): boolean {\n const currentStatus = untracked(status)\n if (\n currentStatus === 'idle' ||\n currentStatus === 'loading' ||\n currentStatus === 'reloading'\n ) {\n return false\n }\n\n if (!untracked(query.isStale)) {\n return false\n }\n\n void query.refetch()\n return true\n },\n }\n}\n\n/**\n * Converts an unknown rejection reason to an Error-compatible value.\n * @param error - The rejected value.\n * @returns The existing error-like value, or an Error wrapping the rejection.\n */\nfunction normalizeError(error: unknown): Error {\n if (isErrorLike(error)) {\n return error\n }\n\n return new Error(String(error), { cause: error })\n}\n\n/**\n * Checks whether a value provides the name and message of an Error.\n * @param error - The value to inspect.\n * @returns Whether the value can be used as an Error.\n */\nfunction isErrorLike(error: unknown): error is Error {\n return (\n error instanceof Error ||\n (typeof error === 'object' &&\n error !== null &&\n typeof (error as Error).name === 'string' &&\n typeof (error as Error).message === 'string')\n )\n}\n"],"mappings":";;;;;;;;;AAwCA,SAAgB,WACd,OACuB;CAGvB,MAAM,SAAS,eAA+B;EAC5C,MAAM,cAAc,MAAM,YAAY;EACtC,MAAM,OAAO,MAAM,KAAK;EAExB,IAAI,gBAAgB,cAAc,gBAAgB,UAChD,OAAO,SAAS,KAAA,IAAY,YAAY;EAG1C,QAAQ,MAAM,OAAO,GAArB;GACE,KAAK,WACH,OAAO;GACT,KAAK,SACH,OAAO;GACT,KAAK,WACH,OAAO;EACX;CACF,CAAC;CAED,MAAM,QAAQ,eAAkC;EAC9C,OAAO,MAAM,OAAO,MAAM,UACtB,eAAe,MAAM,MAAM,CAAC,IAC5B,KAAA;CACN,CAAC;CAED,MAAM,QAAQ,eAAe;EAC3B,IAAI,OAAO,MAAM,SACf,MAAM,MAAM;EAGd,OAAO,MAAM,KAAK;CACpB,CAAC;CAED,MAAM,WAAW,eAAyC;EACxD,MAAM,gBAAgB,OAAO;EAE7B,IAAI,kBAAkB,SACpB,OAAO;GAAE,QAAQ;GAAS,OAAO,MAAM;EAAG;EAG5C,OAAO;GAAE,QAAQ;GAAe,OAAO,MAAM,KAAK;EAAE;CACtD,CAAC;CAED,MAAM,kBACJ,OAAO,MAAM,WACb,MAAM,KAAK,MAAM,KAAA;CAEnB,OAAO;EACL;EACA;EACA;EACA;EACA,WAAW,eAAe;GACxB,MAAM,gBAAgB,OAAO;GAC7B,OAAO,kBAAkB,aAAa,kBAAkB;EAC1D,CAAC;EACD;EACA,SAAkB;GAChB,MAAM,gBAAgB,UAAU,MAAM;GACtC,IACE,kBAAkB,UAClB,kBAAkB,aAClB,kBAAkB,aAElB,OAAO;GAGT,IAAI,CAAC,UAAU,MAAM,OAAO,GAC1B,OAAO;GAGT,MAAW,QAAQ;GACnB,OAAO;EACT;CACF;AACF;;;;;;AAOA,SAAS,eAAe,OAAuB;CAC7C,IAAI,YAAY,KAAK,GACnB,OAAO;CAGT,OAAO,IAAI,MAAM,OAAO,KAAK,GAAG,EAAE,OAAO,MAAM,CAAC;AAClD;;;;;;AAOA,SAAS,YAAY,OAAgC;CACnD,OACE,iBAAiB,SAChB,OAAO,UAAU,YAChB,UAAU,QACV,OAAQ,MAAgB,SAAS,YACjC,OAAQ,MAAgB,YAAY;AAE1C"}
1
+ {"version":3,"file":"query-resource.mjs","names":[],"sources":["../src/query-resource.ts"],"sourcesContent":["import { computed, untracked } from '@angular/core'\nimport type { Resource, ResourceStatus, Signal } from '@angular/core'\nimport type { QueryObserverResult } from '@tanstack/query-core'\nimport type { ResourceSnapshot } from './utils/resource-types'\n\n/**\n * A query-backed Angular Resource that also exposes an atomic state snapshot.\n */\nexport interface QueryResource<TValue> extends Resource<TValue> {\n /**\n * The current query state as a single snapshot.\n */\n readonly snapshot: Signal<ResourceSnapshot<TValue>>\n\n /**\n * Requests a new query fetch only when the current query data is stale.\n *\n * Used for compatibility with Angular APIs that might want to reload a resource,\n * like Signal Forms' validateAsync resource interface.\n * @returns `true` if a reload was initiated, `false` if a reload was unnecessary or unsupported.\n */\n reload: () => boolean\n}\n\ntype QueryResourceSource<TValue> = {\n readonly data: Signal<TValue>\n readonly status: Signal<QueryObserverResult['status']>\n readonly fetchStatus: Signal<QueryObserverResult['fetchStatus']>\n readonly error: Signal<unknown>\n readonly isStale: Signal<boolean>\n readonly refetch: () => unknown\n}\n\n/**\n * Converts an Angular Query result into Angular's Resource interface.\n *\n * Warning: experimental feature. The API may change in minor and patch releases.\n * Pin your package version to an exact version when using this feature.\n *\n * Call this function once and reuse the returned resource.\n * @param query - An Angular Query or infinite-query result.\n * @returns A Resource-compatible view of the query result.\n */\nexport function toResource<TValue>(\n query: QueryResourceSource<TValue>,\n): QueryResource<TValue> {\n // Intentionally does not use resource from snapshot to have\n // support for the reload method for compatible libraries\n const status = computed<ResourceStatus>(() => {\n const fetchStatus = query.fetchStatus()\n const data = query.data()\n\n if (fetchStatus === 'fetching' || fetchStatus === 'paused') {\n return data === undefined ? 'loading' : 'reloading'\n }\n\n switch (query.status()) {\n case 'success':\n return 'resolved'\n case 'error':\n return 'error'\n case 'pending':\n return 'idle'\n }\n })\n\n const error = computed<Error | undefined>(() => {\n return query.status() === 'error'\n ? normalizeError(query.error())\n : undefined\n })\n\n const value = computed(() => {\n if (status() === 'error') {\n throw error()\n }\n\n return query.data()\n })\n\n const snapshot = computed<ResourceSnapshot<TValue>>(() => {\n const currentStatus = status()\n\n if (currentStatus === 'error') {\n return { status: 'error', error: error()! }\n }\n\n return { status: currentStatus, value: query.data() }\n })\n\n const hasValue = (() =>\n status() !== 'error' &&\n query.data() !== undefined) as QueryResource<TValue>['hasValue']\n\n return {\n value,\n status,\n error,\n snapshot,\n isLoading: computed(() => {\n const currentStatus = status()\n return currentStatus === 'loading' || currentStatus === 'reloading'\n }),\n hasValue,\n reload(): boolean {\n const currentStatus = untracked(status)\n if (\n currentStatus === 'idle' ||\n currentStatus === 'loading' ||\n currentStatus === 'reloading'\n ) {\n return false\n }\n\n if (!untracked(query.isStale)) {\n return false\n }\n\n void query.refetch()\n return true\n },\n }\n}\n\n/**\n * Converts an unknown rejection reason to an Error-compatible value.\n * @param error - The rejected value.\n * @returns The existing error-like value, or an Error wrapping the rejection.\n */\nfunction normalizeError(error: unknown): Error {\n if (isErrorLike(error)) {\n return error\n }\n\n return new Error(String(error), { cause: error })\n}\n\n/**\n * Checks whether a value provides the name and message of an Error.\n * @param error - The value to inspect.\n * @returns Whether the value can be used as an Error.\n */\nfunction isErrorLike(error: unknown): error is Error {\n return (\n error instanceof Error ||\n (typeof error === 'object' &&\n error !== null &&\n typeof (error as Error).name === 'string' &&\n typeof (error as Error).message === 'string')\n )\n}\n"],"mappings":";;;;;;;;;;;;AA2CA,SAAgB,WACd,OACuB;CAGvB,MAAM,SAAS,eAA+B;EAC5C,MAAM,cAAc,MAAM,YAAY;EACtC,MAAM,OAAO,MAAM,KAAK;EAExB,IAAI,gBAAgB,cAAc,gBAAgB,UAChD,OAAO,SAAS,KAAA,IAAY,YAAY;EAG1C,QAAQ,MAAM,OAAO,GAArB;GACE,KAAK,WACH,OAAO;GACT,KAAK,SACH,OAAO;GACT,KAAK,WACH,OAAO;EACX;CACF,CAAC;CAED,MAAM,QAAQ,eAAkC;EAC9C,OAAO,MAAM,OAAO,MAAM,UACtB,eAAe,MAAM,MAAM,CAAC,IAC5B,KAAA;CACN,CAAC;CAED,MAAM,QAAQ,eAAe;EAC3B,IAAI,OAAO,MAAM,SACf,MAAM,MAAM;EAGd,OAAO,MAAM,KAAK;CACpB,CAAC;CAED,MAAM,WAAW,eAAyC;EACxD,MAAM,gBAAgB,OAAO;EAE7B,IAAI,kBAAkB,SACpB,OAAO;GAAE,QAAQ;GAAS,OAAO,MAAM;EAAG;EAG5C,OAAO;GAAE,QAAQ;GAAe,OAAO,MAAM,KAAK;EAAE;CACtD,CAAC;CAED,MAAM,kBACJ,OAAO,MAAM,WACb,MAAM,KAAK,MAAM,KAAA;CAEnB,OAAO;EACL;EACA;EACA;EACA;EACA,WAAW,eAAe;GACxB,MAAM,gBAAgB,OAAO;GAC7B,OAAO,kBAAkB,aAAa,kBAAkB;EAC1D,CAAC;EACD;EACA,SAAkB;GAChB,MAAM,gBAAgB,UAAU,MAAM;GACtC,IACE,kBAAkB,UAClB,kBAAkB,aAClB,kBAAkB,aAElB,OAAO;GAGT,IAAI,CAAC,UAAU,MAAM,OAAO,GAC1B,OAAO;GAGT,MAAW,QAAQ;GACnB,OAAO;EACT;CACF;AACF;;;;;;AAOA,SAAS,eAAe,OAAuB;CAC7C,IAAI,YAAY,KAAK,GACnB,OAAO;CAGT,OAAO,IAAI,MAAM,OAAO,KAAK,GAAG,EAAE,OAAO,MAAM,CAAC;AAClD;;;;;;AAOA,SAAS,YAAY,OAAgC;CACnD,OACE,iBAAiB,SAChB,OAAO,UAAU,YAChB,UAAU,QACV,OAAQ,MAAgB,SAAS,YACjC,OAAQ,MAAgB,YAAY;AAE1C"}
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrate = migrate;
4
- const dependencies_1 = require("@schematics/angular/utility/dependencies");
5
4
  const tasks_1 = require("@angular-devkit/schematics/tasks");
5
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
6
  const source_1 = require("./source");
7
7
  const workspace_1 = require("./workspace");
8
8
  const PACKAGE_NAME = '@tanstack/angular-query';
9
- const PACKAGE_VERSION = '5.0.0-rc.5';
9
+ const PACKAGE_VERSION = '5.108.0';
10
10
  const DEVTOOLS_PACKAGE_NAME = '@tanstack/angular-query-devtools';
11
- const DEVTOOLS_PACKAGE_VERSION = '5.0.0-rc.5';
11
+ const DEVTOOLS_PACKAGE_VERSION = '5.108.0';
12
12
  const MIGRATION_GUIDE = 'https://tanstack.com/query/latest/docs/framework/angular/guides/migrating-from-experimental';
13
13
  const dependencyTypes = [
14
14
  dependencies_1.NodeDependencyType.Default,
@@ -7,8 +7,8 @@ exports.packageReferenceFiles = packageReferenceFiles;
7
7
  exports.migrationWorkspace = migrationWorkspace;
8
8
  exports.sourceManifest = sourceManifest;
9
9
  const node_path_1 = require("node:path");
10
- const workspace_1 = require("@schematics/angular/utility/workspace");
11
10
  const schematics_1 = require("@angular-devkit/schematics");
11
+ const workspace_1 = require("@schematics/angular/utility/workspace");
12
12
  const typescript_1 = __importDefault(require("typescript"));
13
13
  // cspell:ignore subdirs
14
14
  const ignoredDirectories = new Set([
@@ -4,19 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ngAdd = ngAdd;
7
+ const schematics_1 = require("@angular-devkit/schematics");
8
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
7
9
  const utility_1 = require("@schematics/angular/utility");
8
10
  const dependencies_1 = require("@schematics/angular/utility/dependencies");
9
11
  const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
10
12
  const app_config_1 = require("@schematics/angular/utility/standalone/app_config");
11
13
  const util_1 = require("@schematics/angular/utility/standalone/util");
12
- const tasks_1 = require("@angular-devkit/schematics/tasks");
13
- const schematics_1 = require("@angular-devkit/schematics");
14
14
  const typescript_1 = __importDefault(require("typescript"));
15
15
  // Replaced with package metadata by scripts/inject-schematic-package-info.js.
16
16
  // The published schematic contains literal values and does not read package.json.
17
17
  const PACKAGE_NAME = '@tanstack/angular-query';
18
18
  const DEVTOOLS_PACKAGE_NAME = '@tanstack/angular-query-devtools';
19
- const DEVTOOLS_PACKAGE_VERSION = '5.0.0-rc.5';
19
+ const DEVTOOLS_PACKAGE_VERSION = '5.108.0';
20
20
  function hasPackageDependency(tree, name) {
21
21
  const packageJsonPath = tree.exists('/package.json')
22
22
  ? '/package.json'
@@ -28,10 +28,11 @@ function addDevtoolsDependency() {
28
28
  return (tree, context) => {
29
29
  if (hasPackageDependency(tree, DEVTOOLS_PACKAGE_NAME))
30
30
  return tree;
31
+ // A caret range lets the devtools update together with the query package.
31
32
  (0, dependencies_1.addPackageJsonDependency)(tree, {
32
33
  type: dependencies_1.NodeDependencyType.Default,
33
34
  name: DEVTOOLS_PACKAGE_NAME,
34
- version: DEVTOOLS_PACKAGE_VERSION,
35
+ version: `^${DEVTOOLS_PACKAGE_VERSION}`,
35
36
  overwrite: false,
36
37
  });
37
38
  context.addTask(new tasks_1.NodePackageInstallTask());