@tanstack/angular-query-experimental 5.80.6 → 5.80.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/create-base-query.mjs +74 -0
  2. package/dist/create-base-query.mjs.map +1 -0
  3. package/dist/index.mjs +35 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/dist/infinite-query-options.mjs +7 -0
  6. package/dist/infinite-query-options.mjs.map +1 -0
  7. package/dist/inject-infinite-query.mjs +18 -0
  8. package/dist/inject-infinite-query.mjs.map +1 -0
  9. package/dist/inject-is-fetching.mjs +31 -0
  10. package/dist/inject-is-fetching.mjs.map +1 -0
  11. package/dist/inject-is-mutating.mjs +31 -0
  12. package/dist/inject-is-mutating.mjs.map +1 -0
  13. package/dist/inject-is-restoring.mjs +24 -0
  14. package/dist/inject-is-restoring.mjs.map +1 -0
  15. package/dist/inject-mutation-state.mjs +51 -0
  16. package/dist/inject-mutation-state.mjs.map +1 -0
  17. package/dist/inject-mutation.mjs +79 -0
  18. package/dist/inject-mutation.mjs.map +1 -0
  19. package/dist/inject-queries.mjs +49 -0
  20. package/dist/inject-queries.mjs.map +1 -0
  21. package/dist/inject-query-client.mjs +9 -0
  22. package/dist/inject-query-client.mjs.map +1 -0
  23. package/dist/inject-query.mjs +14 -0
  24. package/dist/inject-query.mjs.map +1 -0
  25. package/dist/mutation-options.mjs +7 -0
  26. package/dist/mutation-options.mjs.map +1 -0
  27. package/dist/providers.mjs +109 -0
  28. package/dist/providers.mjs.map +1 -0
  29. package/dist/query-options.mjs +7 -0
  30. package/dist/query-options.mjs.map +1 -0
  31. package/dist/signal-proxy.mjs +29 -0
  32. package/dist/signal-proxy.mjs.map +1 -0
  33. package/dist-ts/eslint.config.d.ts +3 -0
  34. package/dist-ts/root.eslint.config.d.ts +3 -0
  35. package/dist-ts/src/__tests__/inject-infinite-query.test-d.d.ts +2 -0
  36. package/dist-ts/src/__tests__/inject-infinite-query.test.d.ts +2 -0
  37. package/dist-ts/src/__tests__/inject-is-fetching.test.d.ts +2 -0
  38. package/dist-ts/src/__tests__/inject-is-mutating.test.d.ts +2 -0
  39. package/dist-ts/src/__tests__/inject-mutation-state.test-d.d.ts +2 -0
  40. package/dist-ts/src/__tests__/inject-mutation-state.test.d.ts +2 -0
  41. package/dist-ts/src/__tests__/inject-mutation.test-d.d.ts +2 -0
  42. package/dist-ts/src/__tests__/inject-mutation.test.d.ts +2 -0
  43. package/dist-ts/src/__tests__/inject-query.test-d.d.ts +2 -0
  44. package/dist-ts/src/__tests__/inject-query.test.d.ts +2 -0
  45. package/dist-ts/src/__tests__/mutation-options.test-d.d.ts +2 -0
  46. package/dist-ts/src/__tests__/provide-query-client.test.d.ts +2 -0
  47. package/dist-ts/src/__tests__/provide-tanstack-query.test.d.ts +2 -0
  48. package/dist-ts/src/__tests__/providers.test.d.ts +2 -0
  49. package/dist-ts/src/__tests__/query-options.test-d.d.ts +2 -0
  50. package/dist-ts/src/__tests__/signal-proxy.test.d.ts +2 -0
  51. package/dist-ts/src/__tests__/test-utils.d.ts +16 -0
  52. package/dist-ts/src/create-base-query.d.ts +9 -0
  53. package/dist-ts/src/index.d.ts +27 -0
  54. package/dist-ts/src/infinite-query-options.d.ts +45 -0
  55. package/dist-ts/src/inject-infinite-query.d.ts +40 -0
  56. package/dist-ts/src/inject-is-fetching.d.ts +23 -0
  57. package/dist-ts/src/inject-is-mutating.d.ts +22 -0
  58. package/{src/inject-is-restoring.ts → dist-ts/src/inject-is-restoring.d.ts} +7 -33
  59. package/dist-ts/src/inject-mutation-state.d.ts +28 -0
  60. package/dist-ts/src/inject-mutation.d.ts +23 -0
  61. package/dist-ts/src/inject-queries.d.ts +78 -0
  62. package/{src/inject-query-client.ts → dist-ts/src/inject-query-client.d.ts} +7 -9
  63. package/{src/inject-query.ts → dist-ts/src/inject-query.d.ts} +14 -117
  64. package/{src/mutation-options.ts → dist-ts/src/mutation-options.d.ts} +5 -26
  65. package/dist-ts/src/providers.d.ts +217 -0
  66. package/dist-ts/src/query-options.d.ts +88 -0
  67. package/dist-ts/src/signal-proxy.d.ts +12 -0
  68. package/dist-ts/src/test-setup.d.ts +2 -0
  69. package/dist-ts/src/types.d.ts +90 -0
  70. package/dist-ts/src/util/is-dev-mode/is-dev-mode.d.ts +2 -0
  71. package/dist-ts/vite.config.d.ts +5 -0
  72. package/package.json +13 -11
  73. package/build/index.d.ts +0 -821
  74. package/build/index.mjs +0 -622
  75. package/build/index.mjs.map +0 -1
  76. package/src/create-base-query.ts +0 -142
  77. package/src/index.ts +0 -64
  78. package/src/infinite-query-options.ts +0 -187
  79. package/src/inject-infinite-query.ts +0 -129
  80. package/src/inject-is-fetching.ts +0 -66
  81. package/src/inject-is-mutating.ts +0 -65
  82. package/src/inject-mutation-state.ts +0 -125
  83. package/src/inject-mutation.ts +0 -169
  84. package/src/inject-queries.ts +0 -271
  85. package/src/providers.ts +0 -368
  86. package/src/query-options.ts +0 -178
  87. package/src/signal-proxy.ts +0 -46
  88. package/src/test-setup.ts +0 -10
  89. package/src/types.ts +0 -309
  90. package/src/util/is-dev-mode/is-dev-mode.ts +0 -3
@@ -0,0 +1,109 @@
1
+ import { InjectionToken, inject, DestroyRef, isDevMode, ENVIRONMENT_INITIALIZER, PLATFORM_ID, computed, effect } from "@angular/core";
2
+ import { QueryClient, noop, onlineManager } from "@tanstack/query-core";
3
+ import { isPlatformBrowser } from "@angular/common";
4
+ function provideQueryClient(queryClient) {
5
+ return {
6
+ provide: QueryClient,
7
+ useFactory: () => {
8
+ const client = queryClient instanceof InjectionToken ? inject(queryClient) : queryClient;
9
+ inject(DestroyRef).onDestroy(() => client.unmount());
10
+ client.mount();
11
+ return client;
12
+ }
13
+ };
14
+ }
15
+ function provideTanStackQuery(queryClient, ...features) {
16
+ return [
17
+ provideQueryClient(queryClient),
18
+ features.map((feature) => feature.ɵproviders)
19
+ ];
20
+ }
21
+ function queryFeature(kind, providers) {
22
+ return { ɵkind: kind, ɵproviders: providers };
23
+ }
24
+ function withDevtools(withDevtoolsFn) {
25
+ let providers = [];
26
+ if (!isDevMode() && !withDevtoolsFn) {
27
+ providers = [];
28
+ } else {
29
+ providers = [
30
+ {
31
+ // Do not use provideEnvironmentInitializer while Angular < v19 is supported
32
+ provide: ENVIRONMENT_INITIALIZER,
33
+ multi: true,
34
+ useFactory: () => {
35
+ if (!isPlatformBrowser(inject(PLATFORM_ID))) return noop;
36
+ const injectedClient = inject(QueryClient, {
37
+ optional: true
38
+ });
39
+ const destroyRef = inject(DestroyRef);
40
+ const options = computed(() => (withDevtoolsFn == null ? void 0 : withDevtoolsFn()) ?? {});
41
+ let devtools = null;
42
+ let el = null;
43
+ const shouldLoadToolsSignal = computed(() => {
44
+ const { loadDevtools } = options();
45
+ return typeof loadDevtools === "boolean" ? loadDevtools : isDevMode();
46
+ });
47
+ const getResolvedQueryClient = () => {
48
+ const client = options().client ?? injectedClient;
49
+ if (!client) {
50
+ throw new Error("No QueryClient found");
51
+ }
52
+ return client;
53
+ };
54
+ const destroyDevtools = () => {
55
+ devtools == null ? void 0 : devtools.unmount();
56
+ el == null ? void 0 : el.remove();
57
+ devtools = null;
58
+ };
59
+ return () => effect(() => {
60
+ const shouldLoadTools = shouldLoadToolsSignal();
61
+ const {
62
+ client,
63
+ position,
64
+ errorTypes,
65
+ buttonPosition,
66
+ initialIsOpen
67
+ } = options();
68
+ if (devtools && !shouldLoadTools) {
69
+ destroyDevtools();
70
+ return;
71
+ } else if (devtools && shouldLoadTools) {
72
+ client && devtools.setClient(client);
73
+ position && devtools.setPosition(position);
74
+ errorTypes && devtools.setErrorTypes(errorTypes);
75
+ buttonPosition && devtools.setButtonPosition(buttonPosition);
76
+ initialIsOpen && devtools.setInitialIsOpen(initialIsOpen);
77
+ return;
78
+ } else if (!shouldLoadTools) {
79
+ return;
80
+ }
81
+ el = document.body.appendChild(document.createElement("div"));
82
+ el.classList.add("tsqd-parent-container");
83
+ import("@tanstack/query-devtools").then((queryDevtools) => {
84
+ devtools = new queryDevtools.TanstackQueryDevtools({
85
+ ...options(),
86
+ client: getResolvedQueryClient(),
87
+ queryFlavor: "Angular Query",
88
+ version: "5",
89
+ onlineManager
90
+ });
91
+ el && devtools.mount(el);
92
+ destroyRef.onDestroy(destroyDevtools);
93
+ });
94
+ });
95
+ }
96
+ }
97
+ ];
98
+ }
99
+ return queryFeature("DeveloperTools", providers);
100
+ }
101
+ const queryFeatures = ["DeveloperTools", "PersistQueryClient"];
102
+ export {
103
+ provideQueryClient,
104
+ provideTanStackQuery,
105
+ queryFeature,
106
+ queryFeatures,
107
+ withDevtools
108
+ };
109
+ //# sourceMappingURL=providers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.mjs","sources":["../src/providers.ts"],"sourcesContent":["import {\n DestroyRef,\n ENVIRONMENT_INITIALIZER,\n InjectionToken,\n PLATFORM_ID,\n computed,\n effect,\n inject,\n} from '@angular/core'\nimport { QueryClient, noop, onlineManager } from '@tanstack/query-core'\nimport { isPlatformBrowser } from '@angular/common'\nimport { isDevMode } from './util/is-dev-mode/is-dev-mode'\nimport type { Provider } from '@angular/core'\nimport type {\n DevtoolsButtonPosition,\n DevtoolsErrorType,\n DevtoolsPosition,\n TanstackQueryDevtools,\n} from '@tanstack/query-devtools'\n\n/**\n * Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the\n * {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}\n * for the entire application. Internally it calls `provideQueryClient`.\n * You can use `provideQueryClient` to provide a different `QueryClient` instance for a part\n * of the application or for unit testing purposes.\n * @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.\n * @returns a provider object that can be used to provide the `QueryClient` instance.\n */\nexport function provideQueryClient(\n queryClient: QueryClient | InjectionToken<QueryClient>,\n): Provider {\n return {\n provide: QueryClient,\n useFactory: () => {\n const client =\n queryClient instanceof InjectionToken\n ? inject(queryClient)\n : queryClient\n // Unmount the query client on injector destroy\n inject(DestroyRef).onDestroy(() => client.unmount())\n client.mount()\n return client\n },\n }\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications.\n *\n * Allows to configure a `QueryClient` and optional features such as developer tools.\n *\n * **Example - standalone**\n *\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideTanStackQuery(new QueryClient())],\n * })\n * ```\n *\n * **Example - NgModule-based**\n *\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * @NgModule({\n * declarations: [AppComponent],\n * imports: [BrowserModule],\n * providers: [provideTanStackQuery(new QueryClient())],\n * bootstrap: [AppComponent],\n * })\n * export class AppModule {}\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 * ```ts\n * import {\n * provideTanStackQuery,\n * withDevtools\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * bootstrapApplication(AppComponent,\n * {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * )\n * ```\n *\n * **Example: using an InjectionToken**\n *\n * ```ts\n * export const MY_QUERY_CLIENT = new InjectionToken('', {\n * factory: () => new QueryClient(),\n * })\n *\n * // In a lazy loaded route or lazy loaded component's providers array:\n * providers: [provideTanStackQuery(MY_QUERY_CLIENT)]\n * ```\n * @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.\n * @param features - Optional features to configure additional Query functionality.\n * @returns A set of providers to set up TanStack Query.\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @see withDevtools\n */\nexport function provideTanStackQuery(\n queryClient: QueryClient | InjectionToken<QueryClient>,\n ...features: Array<QueryFeatures>\n): Array<Provider> {\n return [\n provideQueryClient(queryClient),\n features.map((feature) => feature.ɵproviders),\n ]\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications.\n *\n * Allows to configure a `QueryClient`.\n * @param queryClient - A `QueryClient` instance.\n * @returns A set of providers to set up TanStack Query.\n * @public\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @deprecated Use `provideTanStackQuery` instead.\n */\nexport function provideAngularQuery(queryClient: QueryClient): Array<Provider> {\n return provideTanStackQuery(queryClient)\n}\n\n/**\n * Helper type to represent a Query feature.\n */\nexport interface QueryFeature<TFeatureKind extends QueryFeatureKind> {\n ɵkind: TFeatureKind\n ɵproviders: Array<Provider>\n}\n\n/**\n * Helper function to create an object that represents a Query feature.\n * @param kind -\n * @param providers -\n * @returns A Query feature.\n */\nexport function queryFeature<TFeatureKind extends QueryFeatureKind>(\n kind: TFeatureKind,\n providers: Array<Provider>,\n): QueryFeature<TFeatureKind> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n\n/**\n * A type alias that represents a feature which enables developer tools.\n * The type is used to describe the return value of the `withDevtools` function.\n * @public\n * @see {@link withDevtools}\n */\nexport type DeveloperToolsFeature = QueryFeature<'DeveloperTools'>\n\n/**\n * A type alias that represents a feature which enables persistence.\n * The type is used to describe the return value of the `withPersistQueryClient` function.\n * @public\n */\nexport type PersistQueryClientFeature = QueryFeature<'PersistQueryClient'>\n\n/**\n * Options for configuring the TanStack Query devtools.\n * @public\n */\nexport interface DevtoolsOptions {\n /**\n * Set this true if you want the devtools to default to being open\n */\n initialIsOpen?: boolean\n /**\n * The position of the TanStack logo to open and close the devtools panel.\n * `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`\n * Defaults to `bottom-right`.\n */\n buttonPosition?: DevtoolsButtonPosition\n /**\n * The position of the TanStack Query devtools panel.\n * `top` | `bottom` | `left` | `right`\n * Defaults to `bottom`.\n */\n position?: DevtoolsPosition\n /**\n * Custom instance of QueryClient\n */\n client?: QueryClient\n /**\n * Use this so you can define custom errors that can be shown in the devtools.\n */\n errorTypes?: Array<DevtoolsErrorType>\n /**\n * 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.\n */\n styleNonce?: string\n /**\n * Use this so you can attach the devtool's styles to a specific element in the DOM.\n */\n shadowDOMTarget?: ShadowRoot\n\n /**\n * Whether the developer tools should load.\n * - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.\n * - `true`- Always load the devtools, regardless of the environment.\n * - `false`- Never load the devtools, regardless of the environment.\n *\n * You can use `true` and `false` to override loading developer tools from an environment file.\n * For example, a test environment might run in production mode but you may want to load developer tools.\n *\n * Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,\n * a signal created from a RxJS observable that listens for a keyboard shortcut.\n *\n * **Example**\n * ```ts\n * withDevtools(() => ({\n * initialIsOpen: true,\n * loadDevtools: inject(ExampleService).loadDevtools()\n * }))\n * ```\n */\n loadDevtools?: 'auto' | boolean\n}\n\n/**\n * Enables developer tools.\n *\n * **Example**\n *\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * ```\n * By default the devtools will be loaded when Angular runs in development mode and rendered in `<body>`.\n *\n * 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.\n *\n * If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.\n * @param withDevtoolsFn - A function that returns `DevtoolsOptions`.\n * @returns A set of providers for use with `provideTanStackQuery`.\n * @public\n * @see {@link provideTanStackQuery}\n * @see {@link DevtoolsOptions}\n */\nexport function withDevtools(\n withDevtoolsFn?: () => DevtoolsOptions,\n): DeveloperToolsFeature {\n let providers: Array<Provider> = []\n if (!isDevMode() && !withDevtoolsFn) {\n providers = []\n } else {\n providers = [\n {\n // Do not use provideEnvironmentInitializer while Angular < v19 is supported\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: () => {\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return noop\n const injectedClient = inject(QueryClient, {\n optional: true,\n })\n const destroyRef = inject(DestroyRef)\n\n const options = computed(() => withDevtoolsFn?.() ?? {})\n\n let devtools: TanstackQueryDevtools | null = null\n let el: HTMLElement | null = null\n\n const shouldLoadToolsSignal = computed(() => {\n const { loadDevtools } = options()\n return typeof loadDevtools === 'boolean'\n ? loadDevtools\n : isDevMode()\n })\n\n const getResolvedQueryClient = () => {\n const client = options().client ?? injectedClient\n if (!client) {\n throw new Error('No QueryClient found')\n }\n return client\n }\n\n const destroyDevtools = () => {\n devtools?.unmount()\n el?.remove()\n devtools = null\n }\n\n return () =>\n effect(() => {\n const shouldLoadTools = shouldLoadToolsSignal()\n const {\n client,\n position,\n errorTypes,\n buttonPosition,\n initialIsOpen,\n } = options()\n\n if (devtools && !shouldLoadTools) {\n destroyDevtools()\n return\n } else if (devtools && shouldLoadTools) {\n client && devtools.setClient(client)\n position && devtools.setPosition(position)\n errorTypes && devtools.setErrorTypes(errorTypes)\n buttonPosition && devtools.setButtonPosition(buttonPosition)\n initialIsOpen && devtools.setInitialIsOpen(initialIsOpen)\n return\n } else if (!shouldLoadTools) {\n return\n }\n\n el = document.body.appendChild(document.createElement('div'))\n el.classList.add('tsqd-parent-container')\n\n import('@tanstack/query-devtools').then((queryDevtools) => {\n devtools = new queryDevtools.TanstackQueryDevtools({\n ...options(),\n client: getResolvedQueryClient(),\n queryFlavor: 'Angular Query',\n version: '5',\n onlineManager,\n })\n\n el && devtools.mount(el)\n\n // Unmount the devtools on application destroy\n destroyRef.onDestroy(destroyDevtools)\n })\n })\n },\n },\n ]\n }\n return queryFeature('DeveloperTools', providers)\n}\n\n/**\n * A type alias that represents all Query features available for use with `provideTanStackQuery`.\n * Features can be enabled by adding special functions to the `provideTanStackQuery` call.\n * See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`\n * documentation on how to use those functions.\n * @public\n * @see {@link provideTanStackQuery}\n */\nexport type QueryFeatures = DeveloperToolsFeature | PersistQueryClientFeature\n\nexport const queryFeatures = ['DeveloperTools', 'PersistQueryClient'] as const\n\nexport type QueryFeatureKind = (typeof queryFeatures)[number]\n"],"names":[],"mappings":";;;AA6BO,SAAS,mBACd,aACU;AACH,SAAA;AAAA,IACL,SAAS;AAAA,IACT,YAAY,MAAM;AAChB,YAAM,SACJ,uBAAuB,iBACnB,OAAO,WAAW,IAClB;AAEN,aAAO,UAAU,EAAE,UAAU,MAAM,OAAO,SAAS;AACnD,aAAO,MAAM;AACN,aAAA;AAAA,IAAA;AAAA,EAEX;AACF;AAuEgB,SAAA,qBACd,gBACG,UACc;AACV,SAAA;AAAA,IACL,mBAAmB,WAAW;AAAA,IAC9B,SAAS,IAAI,CAAC,YAAY,QAAQ,UAAU;AAAA,EAC9C;AACF;AA8BgB,SAAA,aACd,MACA,WAC4B;AAC5B,SAAO,EAAE,OAAO,MAAM,YAAY,UAAU;AAC9C;AAqGO,SAAS,aACd,gBACuB;AACvB,MAAI,YAA6B,CAAC;AAClC,MAAI,CAAC,eAAe,CAAC,gBAAgB;AACnC,gBAAY,CAAC;AAAA,EAAA,OACR;AACO,gBAAA;AAAA,MACV;AAAA;AAAA,QAEE,SAAS;AAAA,QACT,OAAO;AAAA,QACP,YAAY,MAAM;AAChB,cAAI,CAAC,kBAAkB,OAAO,WAAW,CAAC,EAAU,QAAA;AAC9C,gBAAA,iBAAiB,OAAO,aAAa;AAAA,YACzC,UAAU;AAAA,UAAA,CACX;AACK,gBAAA,aAAa,OAAO,UAAU;AAEpC,gBAAM,UAAU,SAAS,OAAM,uDAAsB,CAAA,CAAE;AAEvD,cAAI,WAAyC;AAC7C,cAAI,KAAyB;AAEvB,gBAAA,wBAAwB,SAAS,MAAM;AACrC,kBAAA,EAAE,aAAa,IAAI,QAAQ;AACjC,mBAAO,OAAO,iBAAiB,YAC3B,eACA,UAAU;AAAA,UAAA,CACf;AAED,gBAAM,yBAAyB,MAAM;AAC7B,kBAAA,SAAS,UAAU,UAAU;AACnC,gBAAI,CAAC,QAAQ;AACL,oBAAA,IAAI,MAAM,sBAAsB;AAAA,YAAA;AAEjC,mBAAA;AAAA,UACT;AAEA,gBAAM,kBAAkB,MAAM;AAC5B,iDAAU;AACV,qCAAI;AACO,uBAAA;AAAA,UACb;AAEO,iBAAA,MACL,OAAO,MAAM;AACX,kBAAM,kBAAkB,sBAAsB;AACxC,kBAAA;AAAA,cACJ;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,gBACE,QAAQ;AAER,gBAAA,YAAY,CAAC,iBAAiB;AAChB,8BAAA;AAChB;AAAA,YAAA,WACS,YAAY,iBAAiB;AAC5B,wBAAA,SAAS,UAAU,MAAM;AACvB,0BAAA,SAAS,YAAY,QAAQ;AAC3B,4BAAA,SAAS,cAAc,UAAU;AAC7B,gCAAA,SAAS,kBAAkB,cAAc;AAC1C,+BAAA,SAAS,iBAAiB,aAAa;AACxD;AAAA,YAAA,WACS,CAAC,iBAAiB;AAC3B;AAAA,YAAA;AAGF,iBAAK,SAAS,KAAK,YAAY,SAAS,cAAc,KAAK,CAAC;AACzD,eAAA,UAAU,IAAI,uBAAuB;AAExC,mBAAO,0BAA0B,EAAE,KAAK,CAAC,kBAAkB;AAC9C,yBAAA,IAAI,cAAc,sBAAsB;AAAA,gBACjD,GAAG,QAAQ;AAAA,gBACX,QAAQ,uBAAuB;AAAA,gBAC/B,aAAa;AAAA,gBACb,SAAS;AAAA,gBACT;AAAA,cAAA,CACD;AAEK,oBAAA,SAAS,MAAM,EAAE;AAGvB,yBAAW,UAAU,eAAe;AAAA,YAAA,CACrC;AAAA,UAAA,CACF;AAAA,QAAA;AAAA,MACL;AAAA,IAEJ;AAAA,EAAA;AAEK,SAAA,aAAa,kBAAkB,SAAS;AACjD;AAYa,MAAA,gBAAgB,CAAC,kBAAkB,oBAAoB;"}
@@ -0,0 +1,7 @@
1
+ function queryOptions(options) {
2
+ return options;
3
+ }
4
+ export {
5
+ queryOptions
6
+ };
7
+ //# sourceMappingURL=query-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-options.mjs","sources":["../src/query-options.ts"],"sourcesContent":["import type {\n DataTag,\n DefaultError,\n InitialDataFunction,\n NonUndefinedGuard,\n OmitKeyof,\n QueryFunction,\n QueryKey,\n SkipToken,\n} from '@tanstack/query-core'\nimport type { CreateQueryOptions } from './types'\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 initialData?:\n | undefined\n | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n | NonUndefinedGuard<TQueryFnData>\n}\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 queryFn?: Exclude<\n CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],\n SkipToken | undefined\n >\n}\n\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = Omit<\n CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n 'queryFn'\n> & {\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n queryFn?: QueryFunction<TQueryFnData, TQueryKey>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\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 queryKey: DataTag<TQueryKey, TQueryFnData, TError>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\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 queryKey: DataTag<TQueryKey, TQueryFnData, TError>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\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 queryKey: DataTag<TQueryKey, TQueryFnData, TError>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions(options: unknown) {\n return options\n}\n"],"names":[],"mappings":"AA+KO,SAAS,aAAa,SAAkB;AACtC,SAAA;AACT;"}
@@ -0,0 +1,29 @@
1
+ import { untracked, computed } from "@angular/core";
2
+ function signalProxy(inputSignal) {
3
+ const internalState = {};
4
+ return new Proxy(internalState, {
5
+ get(target, prop) {
6
+ const computedField = target[prop];
7
+ if (computedField) return computedField;
8
+ const targetField = untracked(inputSignal)[prop];
9
+ if (typeof targetField === "function") return targetField;
10
+ return target[prop] = computed(() => inputSignal()[prop]);
11
+ },
12
+ has(_, prop) {
13
+ return !!untracked(inputSignal)[prop];
14
+ },
15
+ ownKeys() {
16
+ return Reflect.ownKeys(untracked(inputSignal));
17
+ },
18
+ getOwnPropertyDescriptor() {
19
+ return {
20
+ enumerable: true,
21
+ configurable: true
22
+ };
23
+ }
24
+ });
25
+ }
26
+ export {
27
+ signalProxy
28
+ };
29
+ //# sourceMappingURL=signal-proxy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-proxy.mjs","sources":["../src/signal-proxy.ts"],"sourcesContent":["import { computed, untracked } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\nexport type MapToSignals<T> = {\n [K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>\n}\n\n/**\n * Exposes fields of an object passed via an Angular `Signal` as `Computed` signals.\n * Functions on the object are passed through as-is.\n * @param inputSignal - `Signal` that must return an object.\n * @returns A proxy object with the same fields as the input object, but with each field wrapped in a `Computed` signal.\n */\nexport function signalProxy<TInput extends Record<string | symbol, any>>(\n inputSignal: Signal<TInput>,\n) {\n const internalState = {} as MapToSignals<TInput>\n\n return new Proxy<MapToSignals<TInput>>(internalState, {\n get(target, prop) {\n // first check if we have it in our internal state and return it\n const computedField = target[prop]\n if (computedField) return computedField\n\n // then, check if it's a function on the resultState and return it\n const targetField = untracked(inputSignal)[prop]\n if (typeof targetField === 'function') return targetField\n\n // finally, create a computed field, store it and return it\n // @ts-expect-error\n return (target[prop] = computed(() => inputSignal()[prop]))\n },\n has(_, prop) {\n return !!untracked(inputSignal)[prop]\n },\n ownKeys() {\n return Reflect.ownKeys(untracked(inputSignal))\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n })\n}\n"],"names":[],"mappings":";AAaO,SAAS,YACd,aACA;AACA,QAAM,gBAAgB,CAAC;AAEhB,SAAA,IAAI,MAA4B,eAAe;AAAA,IACpD,IAAI,QAAQ,MAAM;AAEV,YAAA,gBAAgB,OAAO,IAAI;AACjC,UAAI,cAAsB,QAAA;AAG1B,YAAM,cAAc,UAAU,WAAW,EAAE,IAAI;AAC3C,UAAA,OAAO,gBAAgB,WAAmB,QAAA;AAItC,aAAA,OAAO,IAAI,IAAI,SAAS,MAAM,YAAY,EAAE,IAAI,CAAC;AAAA,IAC3D;AAAA,IACA,IAAI,GAAG,MAAM;AACX,aAAO,CAAC,CAAC,UAAU,WAAW,EAAE,IAAI;AAAA,IACtC;AAAA,IACA,UAAU;AACR,aAAO,QAAQ,QAAQ,UAAU,WAAW,CAAC;AAAA,IAC/C;AAAA,IACA,2BAA2B;AAClB,aAAA;AAAA,QACL,YAAY;AAAA,QACZ,cAAc;AAAA,MAChB;AAAA,IAAA;AAAA,EACF,CACD;AACH;"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any[];
2
+ export default _default;
3
+ //# sourceMappingURL=eslint.config.d.ts.map
@@ -0,0 +1,3 @@
1
+ declare const _default: any[];
2
+ export default _default;
3
+ //# sourceMappingURL=root.eslint.config.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-infinite-query.test-d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-infinite-query.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-is-fetching.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-is-mutating.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-mutation-state.test-d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-mutation-state.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-mutation.test-d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-mutation.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-query.test-d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inject-query.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mutation-options.test-d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=provide-query-client.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=provide-tanstack-query.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=providers.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=query-options.test-d.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signal-proxy.test.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { InputSignal, Signal } from '@angular/core';
2
+ import type { ComponentFixture } from '@angular/core/testing';
3
+ export declare const expectSignals: <T extends Record<string, any>>(obj: T, expected: Partial<{ [K in keyof T]: T[K] extends Signal<any> ? ReturnType<T[K]> : never; }>) => void;
4
+ type ToSignalInputUpdatableMap<T> = {
5
+ [K in keyof T as T[K] extends InputSignal<any> ? K : never]: T[K] extends InputSignal<infer Value> ? Value : never;
6
+ };
7
+ /**
8
+ * Set required signal input value to component fixture
9
+ * @see https://github.com/angular/angular/issues/54013
10
+ */
11
+ export declare function setSignalInputs<T extends NonNullable<unknown>>(component: T, inputs: ToSignalInputUpdatableMap<T>): void;
12
+ export declare function setFixtureSignalInputs<T extends NonNullable<unknown>>(componentFixture: ComponentFixture<T>, inputs: ToSignalInputUpdatableMap<T>, options?: {
13
+ detectChanges: boolean;
14
+ }): void;
15
+ export {};
16
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { QueryKey, QueryObserver, QueryObserverResult } from '@tanstack/query-core';
2
+ import type { CreateBaseQueryOptions } from './types';
3
+ /**
4
+ * Base implementation for `injectQuery` and `injectInfiniteQuery`.
5
+ * @param optionsFn
6
+ * @param Observer
7
+ */
8
+ export declare function createBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(optionsFn: () => CreateBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, Observer: typeof QueryObserver): import("./signal-proxy").MapToSignals<QueryObserverResult<TData, TError>>;
9
+ //# sourceMappingURL=create-base-query.d.ts.map
@@ -0,0 +1,27 @@
1
+ export * from '@tanstack/query-core';
2
+ export * from './types';
3
+ export type { DefinedInitialDataOptions, UndefinedInitialDataOptions, UnusedSkipTokenOptions, } from './query-options';
4
+ export { queryOptions } from './query-options';
5
+ export type { CreateMutationOptions } from './mutation-options';
6
+ export { mutationOptions } from './mutation-options';
7
+ export type { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions, UnusedSkipTokenInfiniteOptions, } from './infinite-query-options';
8
+ export { infiniteQueryOptions } from './infinite-query-options';
9
+ export type { InjectInfiniteQueryOptions } from './inject-infinite-query';
10
+ export { injectInfiniteQuery } from './inject-infinite-query';
11
+ export type { InjectIsFetchingOptions } from './inject-is-fetching';
12
+ export { injectIsFetching } from './inject-is-fetching';
13
+ export type { InjectIsMutatingOptions } from './inject-is-mutating';
14
+ export { injectIsMutating } from './inject-is-mutating';
15
+ export { injectIsRestoring, provideIsRestoring } from './inject-is-restoring';
16
+ export type { InjectMutationOptions } from './inject-mutation';
17
+ export { injectMutation } from './inject-mutation';
18
+ export type { InjectMutationStateOptions } from './inject-mutation-state';
19
+ export { injectMutationState } from './inject-mutation-state';
20
+ export type { QueriesOptions, QueriesResults } from './inject-queries';
21
+ export { injectQueries } from './inject-queries';
22
+ export type { InjectQueryOptions } from './inject-query';
23
+ export { injectQuery } from './inject-query';
24
+ export { injectQueryClient } from './inject-query-client';
25
+ export type { DeveloperToolsFeature, DevtoolsOptions, PersistQueryClientFeature, QueryFeature, QueryFeatureKind, QueryFeatures, } from './providers';
26
+ export { provideQueryClient, provideTanStackQuery, queryFeature, queryFeatures, withDevtools, } from './providers';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,45 @@
1
+ import type { DataTag, DefaultError, InfiniteData, InitialDataFunction, NonUndefinedGuard, OmitKeyof, QueryKey, SkipToken } from '@tanstack/query-core';
2
+ import type { CreateInfiniteQueryOptions } from './types';
3
+ export type UndefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
4
+ initialData?: undefined | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | InitialDataFunction<NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>>;
5
+ };
6
+ export type UnusedSkipTokenInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = OmitKeyof<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'queryFn'> & {
7
+ queryFn?: Exclude<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>['queryFn'], SkipToken | undefined>;
8
+ };
9
+ export type DefinedInitialDataInfiniteOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
10
+ initialData: NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>> | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>) | undefined;
11
+ };
12
+ /**
13
+ * Allows to share and re-use infinite query options in a type-safe way.
14
+ *
15
+ * The `queryKey` will be tagged with the type from `queryFn`.
16
+ * @param options - The infinite query options to tag with the type from `queryFn`.
17
+ * @returns The tagged infinite query options.
18
+ * @public
19
+ */
20
+ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
21
+ queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
22
+ };
23
+ /**
24
+ * Allows to share and re-use infinite query options in a type-safe way.
25
+ *
26
+ * The `queryKey` will be tagged with the type from `queryFn`.
27
+ * @param options - The infinite query options to tag with the type from `queryFn`.
28
+ * @returns The tagged infinite query options.
29
+ * @public
30
+ */
31
+ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UnusedSkipTokenInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
32
+ queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
33
+ };
34
+ /**
35
+ * Allows to share and re-use infinite query options in a type-safe way.
36
+ *
37
+ * The `queryKey` will be tagged with the type from `queryFn`.
38
+ * @param options - The infinite query options to tag with the type from `queryFn`.
39
+ * @returns The tagged infinite query options.
40
+ * @public
41
+ */
42
+ export declare function infiniteQueryOptions<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> & {
43
+ queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>, TError>;
44
+ };
45
+ //# sourceMappingURL=infinite-query-options.d.ts.map
@@ -0,0 +1,40 @@
1
+ import { Injector } from '@angular/core';
2
+ import type { DefaultError, InfiniteData, QueryKey } from '@tanstack/query-core';
3
+ import type { CreateInfiniteQueryOptions, CreateInfiniteQueryResult, DefinedCreateInfiniteQueryResult } from './types';
4
+ import type { DefinedInitialDataInfiniteOptions, UndefinedInitialDataInfiniteOptions } from './infinite-query-options';
5
+ export interface InjectInfiniteQueryOptions {
6
+ /**
7
+ * The `Injector` in which to create the infinite query.
8
+ *
9
+ * If this is not provided, the current injection context will be used instead (via `inject`).
10
+ */
11
+ injector?: Injector;
12
+ }
13
+ /**
14
+ * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
15
+ * Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
16
+ * @param injectInfiniteQueryFn - A function that returns infinite query options.
17
+ * @param options - Additional configuration.
18
+ * @returns The infinite query result.
19
+ * @public
20
+ */
21
+ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => DefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): DefinedCreateInfiniteQueryResult<TData, TError>;
22
+ /**
23
+ * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
24
+ * Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
25
+ * @param injectInfiniteQueryFn - A function that returns infinite query options.
26
+ * @param options - Additional configuration.
27
+ * @returns The infinite query result.
28
+ * @public
29
+ */
30
+ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => UndefinedInitialDataInfiniteOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
31
+ /**
32
+ * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
33
+ * Infinite queries can additively "load more" data onto an existing set of data or "infinite scroll"
34
+ * @param injectInfiniteQueryFn - A function that returns infinite query options.
35
+ * @param options - Additional configuration.
36
+ * @returns The infinite query result.
37
+ * @public
38
+ */
39
+ export declare function injectInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(injectInfiniteQueryFn: () => CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, options?: InjectInfiniteQueryOptions): CreateInfiniteQueryResult<TData, TError>;
40
+ //# sourceMappingURL=inject-infinite-query.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { Injector } from '@angular/core';
2
+ import type { QueryFilters } from '@tanstack/query-core';
3
+ import type { Signal } from '@angular/core';
4
+ export interface InjectIsFetchingOptions {
5
+ /**
6
+ * The `Injector` in which to create the isFetching signal.
7
+ *
8
+ * If this is not provided, the current injection context will be used instead (via `inject`).
9
+ */
10
+ injector?: Injector;
11
+ }
12
+ /**
13
+ * Injects a signal that tracks the number of queries that your application is loading or
14
+ * fetching in the background.
15
+ *
16
+ * Can be used for app-wide loading indicators
17
+ * @param filters - The filters to apply to the query.
18
+ * @param options - Additional configuration
19
+ * @returns signal with number of loading or fetching queries.
20
+ * @public
21
+ */
22
+ export declare function injectIsFetching(filters?: QueryFilters, options?: InjectIsFetchingOptions): Signal<number>;
23
+ //# sourceMappingURL=inject-is-fetching.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { Injector } from '@angular/core';
2
+ import type { MutationFilters } from '@tanstack/query-core';
3
+ import type { Signal } from '@angular/core';
4
+ export interface InjectIsMutatingOptions {
5
+ /**
6
+ * The `Injector` in which to create the isMutating signal.
7
+ *
8
+ * If this is not provided, the current injection context will be used instead (via `inject`).
9
+ */
10
+ injector?: Injector;
11
+ }
12
+ /**
13
+ * Injects a signal that tracks the number of mutations that your application is fetching.
14
+ *
15
+ * Can be used for app-wide loading indicators
16
+ * @param filters - The filters to apply to the query.
17
+ * @param options - Additional configuration
18
+ * @returns signal with number of fetching mutations.
19
+ * @public
20
+ */
21
+ export declare function injectIsMutating(filters?: MutationFilters, options?: InjectIsMutatingOptions): Signal<number>;
22
+ //# sourceMappingURL=inject-is-mutating.d.ts.map
@@ -1,52 +1,26 @@
1
- import {
2
- InjectionToken,
3
- Injector,
4
- assertInInjectionContext,
5
- inject,
6
- signal,
7
- } from '@angular/core'
8
- import type { Provider, Signal } from '@angular/core'
9
-
10
- const IS_RESTORING = new InjectionToken(
11
- typeof ngDevMode === 'undefined' || ngDevMode
12
- ? 'TANSTACK_QUERY_IS_RESTORING'
13
- : '',
14
- {
15
- // Default value when not provided
16
- factory: () => signal(false).asReadonly(),
17
- },
18
- )
19
-
1
+ import { Injector } from '@angular/core';
2
+ import type { Provider, Signal } from '@angular/core';
20
3
  /**
21
4
  * The `Injector` in which to create the isRestoring signal.
22
5
  *
23
6
  * If this is not provided, the current injection context will be used instead (via `inject`).
24
7
  */
25
8
  interface InjectIsRestoringOptions {
26
- injector?: Injector
9
+ injector?: Injector;
27
10
  }
28
-
29
11
  /**
30
12
  * Injects a signal that tracks whether a restore is currently in progress. {@link injectQuery} and friends also check this internally to avoid race conditions between the restore and initializing queries.
31
13
  * @param options - Options for injectIsRestoring.
32
14
  * @returns signal with boolean that indicates whether a restore is in progress.
33
15
  * @public
34
16
  */
35
- export function injectIsRestoring(options?: InjectIsRestoringOptions) {
36
- !options?.injector && assertInInjectionContext(injectIsRestoring)
37
- const injector = options?.injector ?? inject(Injector)
38
- return injector.get(IS_RESTORING)
39
- }
40
-
17
+ export declare function injectIsRestoring(options?: InjectIsRestoringOptions): Signal<boolean>;
41
18
  /**
42
19
  * Used by TanStack Query Angular persist client plugin to provide the signal that tracks the restore state
43
20
  * @param isRestoring - a readonly signal that returns a boolean
44
21
  * @returns Provider for the `isRestoring` signal
45
22
  * @public
46
23
  */
47
- export function provideIsRestoring(isRestoring: Signal<boolean>): Provider {
48
- return {
49
- provide: IS_RESTORING,
50
- useValue: isRestoring,
51
- }
52
- }
24
+ export declare function provideIsRestoring(isRestoring: Signal<boolean>): Provider;
25
+ export {};
26
+ //# sourceMappingURL=inject-is-restoring.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { Injector } from '@angular/core';
2
+ import type { Signal } from '@angular/core';
3
+ import type { Mutation, MutationFilters, MutationState } from '@tanstack/query-core';
4
+ type MutationStateOptions<TResult = MutationState> = {
5
+ filters?: MutationFilters;
6
+ select?: (mutation: Mutation) => TResult;
7
+ };
8
+ /**
9
+ * @public
10
+ */
11
+ export interface InjectMutationStateOptions {
12
+ /**
13
+ * The `Injector` in which to create the mutation state signal.
14
+ *
15
+ * If this is not provided, the current injection context will be used instead (via `inject`).
16
+ */
17
+ injector?: Injector;
18
+ }
19
+ /**
20
+ * Injects a signal that tracks the state of all mutations.
21
+ * @param injectMutationStateFn - A function that returns mutation state options.
22
+ * @param options - The Angular injector to use.
23
+ * @returns The signal that tracks the state of all mutations.
24
+ * @public
25
+ */
26
+ export declare function injectMutationState<TResult = MutationState>(injectMutationStateFn?: () => MutationStateOptions<TResult>, options?: InjectMutationStateOptions): Signal<Array<TResult>>;
27
+ export {};
28
+ //# sourceMappingURL=inject-mutation-state.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { Injector } from '@angular/core';
2
+ import type { DefaultError } from '@tanstack/query-core';
3
+ import type { CreateMutationResult } from './types';
4
+ import type { CreateMutationOptions } from './mutation-options';
5
+ export interface InjectMutationOptions {
6
+ /**
7
+ * The `Injector` in which to create the mutation.
8
+ *
9
+ * If this is not provided, the current injection context will be used instead (via `inject`).
10
+ */
11
+ injector?: Injector;
12
+ }
13
+ /**
14
+ * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.
15
+ *
16
+ * Unlike queries, mutations are not run automatically.
17
+ * @param injectMutationFn - A function that returns mutation options.
18
+ * @param options - Additional configuration
19
+ * @returns The mutation.
20
+ * @public
21
+ */
22
+ export declare function injectMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(injectMutationFn: () => CreateMutationOptions<TData, TError, TVariables, TContext>, options?: InjectMutationOptions): CreateMutationResult<TData, TError, TVariables, TContext>;
23
+ //# sourceMappingURL=inject-mutation.d.ts.map