@tanstack/angular-query-experimental 5.87.5 → 5.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/devtools/index.d.ts +2 -0
- package/devtools/index.mjs +5 -0
- package/devtools/index.mjs.map +1 -0
- package/devtools/production/index.d.ts +1 -0
- package/devtools/stub.d.ts +2 -0
- package/devtools/stub.mjs +8 -0
- package/devtools/stub.mjs.map +1 -0
- package/devtools/types.d.ts +95 -0
- package/devtools/with-devtools.d.ts +25 -0
- package/devtools/with-devtools.mjs +104 -0
- package/devtools/with-devtools.mjs.map +1 -0
- package/devtools-panel/index.d.ts +2 -0
- package/devtools-panel/index.mjs +5 -0
- package/devtools-panel/index.mjs.map +1 -0
- package/devtools-panel/inject-devtools-panel.d.ts +14 -0
- package/devtools-panel/inject-devtools-panel.mjs +72 -0
- package/devtools-panel/inject-devtools-panel.mjs.map +1 -0
- package/devtools-panel/production/index.d.ts +1 -0
- package/devtools-panel/stub.d.ts +2 -0
- package/devtools-panel/stub.mjs +8 -0
- package/devtools-panel/stub.mjs.map +1 -0
- package/devtools-panel/types.d.ts +48 -0
- package/index.d.ts +2 -2
- package/index.mjs +3 -4
- package/infinite-query-options.d.ts +0 -3
- package/infinite-query-options.mjs.map +1 -1
- package/inject-infinite-query.d.ts +0 -3
- package/inject-infinite-query.mjs.map +1 -1
- package/inject-is-mutating.d.ts +0 -1
- package/inject-is-mutating.mjs.map +1 -1
- package/inject-is-restoring.d.ts +6 -8
- package/inject-is-restoring.mjs +4 -7
- package/inject-is-restoring.mjs.map +1 -1
- package/inject-mutation-state.d.ts +0 -4
- package/inject-mutation-state.mjs.map +1 -1
- package/inject-mutation.d.ts +0 -1
- package/inject-mutation.mjs.map +1 -1
- package/inject-queries.d.ts +0 -4
- package/inject-queries.mjs.map +1 -1
- package/inject-query-client.d.ts +0 -1
- package/inject-query-client.mjs.map +1 -1
- package/inject-query.d.ts +0 -3
- package/inject-query.mjs.map +1 -1
- package/mutation-options.d.ts +5 -4
- package/mutation-options.mjs.map +1 -1
- package/package.json +23 -3
- package/providers.d.ts +8 -95
- package/providers.mjs +7 -84
- package/providers.mjs.map +1 -1
- package/query-options.d.ts +0 -3
- package/query-options.mjs.map +1 -1
- package/types.d.ts +0 -48
- package/util/is-dev-mode/is-dev-mode.d.ts +0 -1
package/inject-is-restoring.d.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { Injector, Provider, Signal } from '@angular/core';
|
|
2
|
-
/**
|
|
3
|
-
* The `Injector` in which to create the isRestoring signal.
|
|
4
|
-
*
|
|
5
|
-
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
6
|
-
*/
|
|
7
2
|
interface InjectIsRestoringOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The `Injector` to use to get the isRestoring signal.
|
|
5
|
+
*
|
|
6
|
+
* If this is not provided, the current injection context will be used instead (via `inject`).
|
|
7
|
+
*/
|
|
8
8
|
injector?: Injector;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 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.
|
|
12
12
|
* @param options - Options for injectIsRestoring.
|
|
13
|
-
* @returns signal with boolean that indicates whether a restore is in progress.
|
|
14
|
-
* @public
|
|
13
|
+
* @returns readonly signal with boolean that indicates whether a restore is in progress.
|
|
15
14
|
*/
|
|
16
15
|
export declare function injectIsRestoring(options?: InjectIsRestoringOptions): Signal<boolean>;
|
|
17
16
|
/**
|
|
18
17
|
* Used by TanStack Query Angular persist client plugin to provide the signal that tracks the restore state
|
|
19
18
|
* @param isRestoring - a readonly signal that returns a boolean
|
|
20
19
|
* @returns Provider for the `isRestoring` signal
|
|
21
|
-
* @public
|
|
22
20
|
*/
|
|
23
21
|
export declare function provideIsRestoring(isRestoring: Signal<boolean>): Provider;
|
|
24
22
|
export {};
|
package/inject-is-restoring.mjs
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { assertInInjectionContext, inject, Injector, InjectionToken, signal } from "@angular/core";
|
|
2
|
-
const IS_RESTORING = new InjectionToken(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
factory: () => signal(false).asReadonly()
|
|
7
|
-
}
|
|
8
|
-
);
|
|
2
|
+
const IS_RESTORING = new InjectionToken("", {
|
|
3
|
+
// Default value when not provided
|
|
4
|
+
factory: () => signal(false).asReadonly()
|
|
5
|
+
});
|
|
9
6
|
function injectIsRestoring(options) {
|
|
10
7
|
!(options == null ? void 0 : options.injector) && assertInInjectionContext(injectIsRestoring);
|
|
11
8
|
const injector = (options == null ? void 0 : options.injector) ?? inject(Injector);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-is-restoring.mjs","sources":["../src/inject-is-restoring.ts"],"sourcesContent":["import {\n InjectionToken,\n Injector,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport type { Provider, Signal } from '@angular/core'\n\
|
|
1
|
+
{"version":3,"file":"inject-is-restoring.mjs","sources":["../src/inject-is-restoring.ts"],"sourcesContent":["import {\n InjectionToken,\n Injector,\n assertInInjectionContext,\n inject,\n signal,\n} from '@angular/core'\nimport type { Provider, Signal } from '@angular/core'\n\n/**\n * Internal token used to track isRestoring state, accessible in public API through `injectIsRestoring` and set via `provideIsRestoring`\n */\nconst IS_RESTORING = new InjectionToken('', {\n // Default value when not provided\n factory: () => signal(false).asReadonly(),\n})\n\ninterface InjectIsRestoringOptions {\n /**\n * The `Injector` to use to get the isRestoring signal.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * 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.\n * @param options - Options for injectIsRestoring.\n * @returns readonly signal with boolean that indicates whether a restore is in progress.\n */\nexport function injectIsRestoring(options?: InjectIsRestoringOptions) {\n !options?.injector && assertInInjectionContext(injectIsRestoring)\n const injector = options?.injector ?? inject(Injector)\n return injector.get(IS_RESTORING)\n}\n\n/**\n * Used by TanStack Query Angular persist client plugin to provide the signal that tracks the restore state\n * @param isRestoring - a readonly signal that returns a boolean\n * @returns Provider for the `isRestoring` signal\n */\nexport function provideIsRestoring(isRestoring: Signal<boolean>): Provider {\n return {\n provide: IS_RESTORING,\n useValue: isRestoring,\n }\n}\n"],"names":[],"mappings":";AAYA,MAAM,eAAe,IAAI,eAAe,IAAI;AAAA;AAAA,EAE1C,SAAS,MAAM,OAAO,KAAK,EAAE,WAAW;AAC1C,CAAC;AAgBM,SAAS,kBAAkB,SAAoC;AACnE,IAAA,mCAAS,aAAY,yBAAyB,iBAAiB;AAChE,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC9C,SAAA,SAAS,IAAI,YAAY;AAClC;AAOO,SAAS,mBAAmB,aAAwC;AAClE,SAAA;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,EACZ;AACF;"}
|
|
@@ -4,9 +4,6 @@ type MutationStateOptions<TResult = MutationState> = {
|
|
|
4
4
|
filters?: MutationFilters;
|
|
5
5
|
select?: (mutation: Mutation) => TResult;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
7
|
export interface InjectMutationStateOptions {
|
|
11
8
|
/**
|
|
12
9
|
* The `Injector` in which to create the mutation state signal.
|
|
@@ -20,7 +17,6 @@ export interface InjectMutationStateOptions {
|
|
|
20
17
|
* @param injectMutationStateFn - A function that returns mutation state options.
|
|
21
18
|
* @param options - The Angular injector to use.
|
|
22
19
|
* @returns The signal that tracks the state of all mutations.
|
|
23
|
-
* @public
|
|
24
20
|
*/
|
|
25
21
|
export declare function injectMutationState<TResult = MutationState>(injectMutationStateFn?: () => MutationStateOptions<TResult>, options?: InjectMutationStateOptions): Signal<Array<TResult>>;
|
|
26
22
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-mutation-state.mjs","sources":["../src/inject-mutation-state.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n inject,\n signal,\n} from '@angular/core'\nimport {\n QueryClient,\n notifyManager,\n replaceEqualDeep,\n} from '@tanstack/query-core'\nimport type { Signal } from '@angular/core'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\n\ntype MutationStateOptions<TResult = MutationState> = {\n filters?: MutationFilters\n select?: (mutation: Mutation) => TResult\n}\n\n/**\n *\n * @param mutationCache\n * @param options\n */\nfunction getResult<TResult = MutationState>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select ? options.select(mutation) : mutation.state) as TResult,\n )\n}\n\
|
|
1
|
+
{"version":3,"file":"inject-mutation-state.mjs","sources":["../src/inject-mutation-state.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n inject,\n signal,\n} from '@angular/core'\nimport {\n QueryClient,\n notifyManager,\n replaceEqualDeep,\n} from '@tanstack/query-core'\nimport type { Signal } from '@angular/core'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\n\ntype MutationStateOptions<TResult = MutationState> = {\n filters?: MutationFilters\n select?: (mutation: Mutation) => TResult\n}\n\n/**\n *\n * @param mutationCache\n * @param options\n */\nfunction getResult<TResult = MutationState>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select ? options.select(mutation) : mutation.state) as TResult,\n )\n}\n\nexport interface InjectMutationStateOptions {\n /**\n * The `Injector` in which to create the mutation state signal.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a signal that tracks the state of all mutations.\n * @param injectMutationStateFn - A function that returns mutation state options.\n * @param options - The Angular injector to use.\n * @returns The signal that tracks the state of all mutations.\n */\nexport function injectMutationState<TResult = MutationState>(\n injectMutationStateFn: () => MutationStateOptions<TResult> = () => ({}),\n options?: InjectMutationStateOptions,\n): Signal<Array<TResult>> {\n !options?.injector && assertInInjectionContext(injectMutationState)\n const injector = options?.injector ?? inject(Injector)\n const destroyRef = injector.get(DestroyRef)\n const ngZone = injector.get(NgZone)\n const queryClient = injector.get(QueryClient)\n const mutationCache = queryClient.getMutationCache()\n\n /**\n * Computed signal that gets result from mutation cache based on passed options\n * First element is the result, second element is the time when the result was set\n */\n const resultFromOptionsSignal = computed(() => {\n return [\n getResult(mutationCache, injectMutationStateFn()),\n performance.now(),\n ] as const\n })\n\n /**\n * Signal that contains result set by subscriber\n * First element is the result, second element is the time when the result was set\n */\n const resultFromSubscriberSignal = signal<[Array<TResult>, number] | null>(\n null,\n )\n\n /**\n * Returns the last result by either subscriber or options\n */\n const effectiveResultSignal = computed(() => {\n const optionsResult = resultFromOptionsSignal()\n const subscriberResult = resultFromSubscriberSignal()\n return subscriberResult && subscriberResult[1] > optionsResult[1]\n ? subscriberResult[0]\n : optionsResult[0]\n })\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n mutationCache.subscribe(\n notifyManager.batchCalls(() => {\n const [lastResult] = effectiveResultSignal()\n const nextResult = replaceEqualDeep(\n lastResult,\n getResult(mutationCache, injectMutationStateFn()),\n )\n if (lastResult !== nextResult) {\n ngZone.run(() => {\n resultFromSubscriberSignal.set([nextResult, performance.now()])\n })\n }\n }),\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return effectiveResultSignal\n}\n"],"names":[],"mappings":";;AAgCA,SAAS,UACP,eACA,SACgB;AAChB,SAAO,cACJ,QAAQ,QAAQ,OAAO,EACvB;AAAA,IACC,CAAC,aACE,QAAQ,SAAS,QAAQ,OAAO,QAAQ,IAAI,SAAS;AAAA,EAC1D;AACJ;AAiBO,SAAS,oBACd,wBAA6D,OAAO,KACpE,SACwB;AACvB,IAAA,mCAAS,aAAY,yBAAyB,mBAAmB;AAClE,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC/C,QAAA,aAAa,SAAS,IAAI,UAAU;AACpC,QAAA,SAAS,SAAS,IAAI,MAAM;AAC5B,QAAA,cAAc,SAAS,IAAI,WAAW;AACtC,QAAA,gBAAgB,YAAY,iBAAiB;AAM7C,QAAA,0BAA0B,SAAS,MAAM;AACtC,WAAA;AAAA,MACL,UAAU,eAAe,uBAAuB;AAAA,MAChD,YAAY,IAAI;AAAA,IAClB;AAAA,EAAA,CACD;AAMD,QAAM,6BAA6B;AAAA,IACjC;AAAA,EACF;AAKM,QAAA,wBAAwB,SAAS,MAAM;AAC3C,UAAM,gBAAgB,wBAAwB;AAC9C,UAAM,mBAAmB,2BAA2B;AAC7C,WAAA,oBAAoB,iBAAiB,CAAC,IAAI,cAAc,CAAC,IAC5D,iBAAiB,CAAC,IAClB,cAAc,CAAC;AAAA,EAAA,CACpB;AAED,QAAM,cAAc,OAAO;AAAA,IAAkB,MAC3C,cAAc;AAAA,MACZ,cAAc,WAAW,MAAM;AACvB,cAAA,CAAC,UAAU,IAAI,sBAAsB;AAC3C,cAAM,aAAa;AAAA,UACjB;AAAA,UACA,UAAU,eAAe,sBAAuB,CAAA;AAAA,QAClD;AACA,YAAI,eAAe,YAAY;AAC7B,iBAAO,IAAI,MAAM;AACf,uCAA2B,IAAI,CAAC,YAAY,YAAY,IAAK,CAAA,CAAC;AAAA,UAAA,CAC/D;AAAA,QAAA;AAAA,MAEJ,CAAA;AAAA,IAAA;AAAA,EAEL;AAEA,aAAW,UAAU,WAAW;AAEzB,SAAA;AACT;"}
|
package/inject-mutation.d.ts
CHANGED
|
@@ -16,6 +16,5 @@ export interface InjectMutationOptions {
|
|
|
16
16
|
* @param injectMutationFn - A function that returns mutation options.
|
|
17
17
|
* @param options - Additional configuration
|
|
18
18
|
* @returns The mutation.
|
|
19
|
-
* @public
|
|
20
19
|
*/
|
|
21
20
|
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>;
|
package/inject-mutation.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-mutation.mjs","sources":["../src/inject-mutation.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport {\n MutationObserver,\n QueryClient,\n noop,\n notifyManager,\n shouldThrowError,\n} from '@tanstack/query-core'\nimport { signalProxy } from './signal-proxy'\nimport type { DefaultError, MutationObserverResult } from '@tanstack/query-core'\nimport type {\n CreateMutateFunction,\n CreateMutationOptions,\n CreateMutationResult,\n} from './types'\n\nexport interface InjectMutationOptions {\n /**\n * The `Injector` in which to create the mutation.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.\n *\n * Unlike queries, mutations are not run automatically.\n * @param injectMutationFn - A function that returns mutation options.\n * @param options - Additional configuration\n * @returns The mutation.\n
|
|
1
|
+
{"version":3,"file":"inject-mutation.mjs","sources":["../src/inject-mutation.ts"],"sourcesContent":["import {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport {\n MutationObserver,\n QueryClient,\n noop,\n notifyManager,\n shouldThrowError,\n} from '@tanstack/query-core'\nimport { signalProxy } from './signal-proxy'\nimport type { DefaultError, MutationObserverResult } from '@tanstack/query-core'\nimport type {\n CreateMutateFunction,\n CreateMutationOptions,\n CreateMutationResult,\n} from './types'\n\nexport interface InjectMutationOptions {\n /**\n * The `Injector` in which to create the mutation.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.\n *\n * Unlike queries, mutations are not run automatically.\n * @param injectMutationFn - A function that returns mutation options.\n * @param options - Additional configuration\n * @returns The mutation.\n */\nexport function injectMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n injectMutationFn: () => CreateMutationOptions<\n TData,\n TError,\n TVariables,\n TContext\n >,\n options?: InjectMutationOptions,\n): CreateMutationResult<TData, TError, TVariables, TContext> {\n !options?.injector && assertInInjectionContext(injectMutation)\n const injector = options?.injector ?? inject(Injector)\n const destroyRef = injector.get(DestroyRef)\n const ngZone = injector.get(NgZone)\n const queryClient = injector.get(QueryClient)\n\n /**\n * computed() is used so signals can be inserted into the options\n * making it reactive. Wrapping options in a function ensures embedded expressions\n * are preserved and can keep being applied after signal changes\n */\n const optionsSignal = computed(injectMutationFn)\n\n const observerSignal = (() => {\n let instance: MutationObserver<TData, TError, TVariables, TContext> | null =\n null\n\n return computed(() => {\n return (instance ||= new MutationObserver(queryClient, optionsSignal()))\n })\n })()\n\n const mutateFnSignal = computed<\n CreateMutateFunction<TData, TError, TVariables, TContext>\n >(() => {\n const observer = observerSignal()\n return (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n }\n })\n\n /**\n * Computed signal that gets result from mutation cache based on passed options\n */\n const resultFromInitialOptionsSignal = computed(() => {\n const observer = observerSignal()\n return observer.getCurrentResult()\n })\n\n /**\n * Signal that contains result set by subscriber\n */\n const resultFromSubscriberSignal = signal<MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n effect(\n () => {\n const observer = observerSignal()\n const observerOptions = optionsSignal()\n\n untracked(() => {\n observer.setOptions(observerOptions)\n })\n },\n {\n injector,\n },\n )\n\n effect(\n () => {\n // observer.trackResult is not used as this optimization is not needed for Angular\n const observer = observerSignal()\n\n untracked(() => {\n const unsubscribe = ngZone.runOutsideAngular(() =>\n observer.subscribe(\n notifyManager.batchCalls((state) => {\n ngZone.run(() => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n ngZone.onError.emit(state.error)\n throw state.error\n }\n\n resultFromSubscriberSignal.set(state)\n })\n }),\n ),\n )\n destroyRef.onDestroy(unsubscribe)\n })\n },\n {\n injector,\n },\n )\n\n const resultSignal = computed(() => {\n const resultFromSubscriber = resultFromSubscriberSignal()\n const resultFromInitialOptions = resultFromInitialOptionsSignal()\n\n const result = resultFromSubscriber ?? resultFromInitialOptions\n\n return {\n ...result,\n mutate: mutateFnSignal(),\n mutateAsync: result.mutate,\n }\n })\n\n return signalProxy(resultSignal) as CreateMutationResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n}\n"],"names":[],"mappings":";;;AA2CgB,SAAA,eAMd,kBAMA,SAC2D;AAC1D,IAAA,mCAAS,aAAY,yBAAyB,cAAc;AAC7D,QAAM,YAAW,mCAAS,aAAY,OAAO,QAAQ;AAC/C,QAAA,aAAa,SAAS,IAAI,UAAU;AACpC,QAAA,SAAS,SAAS,IAAI,MAAM;AAC5B,QAAA,cAAc,SAAS,IAAI,WAAW;AAOtC,QAAA,gBAAgB,SAAS,gBAAgB;AAE/C,QAAM,kBAAkB,MAAM;AAC5B,QAAI,WACF;AAEF,WAAO,SAAS,MAAM;AACpB,aAAQ,wBAAa,IAAI,iBAAiB,aAAa,eAAe;AAAA,IAAA,CACvE;AAAA,EAAA,GACA;AAEG,QAAA,iBAAiB,SAErB,MAAM;AACN,UAAM,WAAW,eAAe;AACzB,WAAA,CAAC,WAAW,kBAAkB;AACnC,eAAS,OAAO,WAAW,aAAa,EAAE,MAAM,IAAI;AAAA,IACtD;AAAA,EAAA,CACD;AAKK,QAAA,iCAAiC,SAAS,MAAM;AACpD,UAAM,WAAW,eAAe;AAChC,WAAO,SAAS,iBAAiB;AAAA,EAAA,CAClC;AAKK,QAAA,6BAA6B,OAKzB,IAAI;AAEd;AAAA,IACE,MAAM;AACJ,YAAM,WAAW,eAAe;AAChC,YAAM,kBAAkB,cAAc;AAEtC,gBAAU,MAAM;AACd,iBAAS,WAAW,eAAe;AAAA,MAAA,CACpC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEA;AAAA,IACE,MAAM;AAEJ,YAAM,WAAW,eAAe;AAEhC,gBAAU,MAAM;AACd,cAAM,cAAc,OAAO;AAAA,UAAkB,MAC3C,SAAS;AAAA,YACP,cAAc,WAAW,CAAC,UAAU;AAClC,qBAAO,IAAI,MAAM;AAEb,oBAAA,MAAM,WACN,iBAAiB,SAAS,QAAQ,cAAc,CAAC,MAAM,KAAK,CAAC,GAC7D;AACO,yBAAA,QAAQ,KAAK,MAAM,KAAK;AAC/B,wBAAM,MAAM;AAAA,gBAAA;AAGd,2CAA2B,IAAI,KAAK;AAAA,cAAA,CACrC;AAAA,YACF,CAAA;AAAA,UAAA;AAAA,QAEL;AACA,mBAAW,UAAU,WAAW;AAAA,MAAA,CACjC;AAAA,IACH;AAAA,IACA;AAAA,MACE;AAAA,IAAA;AAAA,EAEJ;AAEM,QAAA,eAAe,SAAS,MAAM;AAClC,UAAM,uBAAuB,2BAA2B;AACxD,UAAM,2BAA2B,+BAA+B;AAEhE,UAAM,SAAS,wBAAwB;AAEhC,WAAA;AAAA,MACL,GAAG;AAAA,MACH,QAAQ,eAAe;AAAA,MACvB,aAAa,OAAO;AAAA,IACtB;AAAA,EAAA,CACD;AAED,SAAO,YAAY,YAAY;AAMjC;"}
|
package/inject-queries.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ type GetResults<T> = T extends {
|
|
|
37
37
|
} ? QueryObserverResult<unknown extends TData ? TQueryFnData : TData, unknown extends TError ? DefaultError : TError> : QueryObserverResult;
|
|
38
38
|
/**
|
|
39
39
|
* QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
|
|
40
|
-
* @public
|
|
41
40
|
*/
|
|
42
41
|
export type QueriesOptions<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<QueryObserverOptionsForCreateQueries> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetOptions<Head>] : T extends [infer Head, ...infer Tail] ? QueriesOptions<[
|
|
43
42
|
...Tail
|
|
@@ -50,7 +49,6 @@ export type QueriesOptions<T extends Array<any>, TResult extends Array<any> = []
|
|
|
50
49
|
]> : ReadonlyArray<unknown> extends T ? T : T extends Array<QueryObserverOptionsForCreateQueries<infer TQueryFnData, infer TError, infer TData, infer TQueryKey>> ? Array<QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData, TQueryKey>> : Array<QueryObserverOptionsForCreateQueries>;
|
|
51
50
|
/**
|
|
52
51
|
* QueriesResults reducer recursively maps type param to results
|
|
53
|
-
* @public
|
|
54
52
|
*/
|
|
55
53
|
export type QueriesResults<T extends Array<any>, TResult extends Array<any> = [], TDepth extends ReadonlyArray<number> = []> = TDepth['length'] extends MAXIMUM_DEPTH ? Array<QueryObserverResult> : T extends [] ? [] : T extends [infer Head] ? [...TResult, GetResults<Head>] : T extends [infer Head, ...infer Tail] ? QueriesResults<[
|
|
56
54
|
...Tail
|
|
@@ -66,8 +64,6 @@ export type QueriesResults<T extends Array<any>, TResult extends Array<any> = []
|
|
|
66
64
|
* @param root0.queries
|
|
67
65
|
* @param root0.combine
|
|
68
66
|
* @param injector
|
|
69
|
-
* @param injector
|
|
70
|
-
* @public
|
|
71
67
|
*/
|
|
72
68
|
export declare function injectQueries<T extends Array<any>, TCombinedResult = QueriesResults<T>>({ queries, ...options }: {
|
|
73
69
|
queries: Signal<[...QueriesOptions<T>]>;
|
package/inject-queries.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-queries.mjs","sources":["../src/inject-queries.ts"],"sourcesContent":["import {\n QueriesObserver,\n QueryClient,\n notifyManager,\n} from '@tanstack/query-core'\nimport {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core'\nimport { injectIsRestoring } from './inject-is-restoring'\nimport type { Signal } from '@angular/core'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `CreateQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype QueryObserverOptionsForCreateQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n 'placeholderData'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n QueryObserverOptionsForCreateQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? QueryObserverResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? QueryObserverResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n QueryObserverResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n * @public\n */\nexport type QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverOptionsForCreateQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<QueryObserverOptionsForCreateQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n * @public\n */\nexport type QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >\n >\n ? // Dynamic-size (homogenous) CreateQueryOptions array: map directly to array of results\n Array<\n QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n >\n : // Fallback\n Array<QueryObserverResult>\n\n/**\n * @param root0\n * @param root0.queries\n * @param root0.combine\n * @param injector\n * @param injector\n * @public\n */\nexport function injectQueries<\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: {\n queries: Signal<[...QueriesOptions<T>]>\n combine?: (result: QueriesResults<T>) => TCombinedResult\n },\n injector?: Injector,\n): Signal<TCombinedResult> {\n !injector && assertInInjectionContext(injectQueries)\n return runInInjectionContext(injector ?? inject(Injector), () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n const isRestoring = injectIsRestoring()\n\n const defaultedQueries = computed(() => {\n return queries().map((opts) => {\n const defaultedOptions = queryClient.defaultQueryOptions(opts)\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring()\n ? 'isRestoring'\n : 'optimistic'\n\n return defaultedOptions as QueryObserverOptions\n })\n })\n\n const observer = new QueriesObserver<TCombinedResult>(\n queryClient,\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n )\n\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n effect(() => {\n observer.setQueries(\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n )\n })\n\n const [, getCombinedResult] = observer.getOptimisticResult(\n defaultedQueries(),\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n const result = signal(getCombinedResult() as any)\n\n effect(() => {\n const unsubscribe = isRestoring()\n ? () => undefined\n : ngZone.runOutsideAngular(() =>\n observer.subscribe(notifyManager.batchCalls(result.set)),\n )\n destroyRef.onDestroy(unsubscribe)\n })\n\n return result\n })\n}\n"],"names":[],"mappings":";;;AA6MO,SAAS,cAId;AAAA,EACE;AAAA,EACA,GAAG;AACL,GAIA,UACyB;AACxB,GAAA,YAAY,yBAAyB,aAAa;AACnD,SAAO,sBAAsB,YAAY,OAAO,QAAQ,GAAG,MAAM;AACzD,UAAA,aAAa,OAAO,UAAU;AAC9B,UAAA,SAAS,OAAO,MAAM;AACtB,UAAA,cAAc,OAAO,WAAW;AACtC,UAAM,cAAc,kBAAkB;AAEhC,UAAA,mBAAmB,SAAS,MAAM;AACtC,aAAO,QAAQ,EAAE,IAAI,CAAC,SAAS;AACvB,cAAA,mBAAmB,YAAY,oBAAoB,IAAI;AAE5C,yBAAA,qBAAqB,YAAY,IAC9C,gBACA;AAEG,eAAA;AAAA,MAAA,CACR;AAAA,IAAA,CACF;AAED,UAAM,WAAW,IAAI;AAAA,MACnB;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,IACF;AAIA,WAAO,MAAM;AACF,eAAA;AAAA,QACP,iBAAiB;AAAA,QACjB;AAAA,MACF;AAAA,IAAA,CACD;AAED,UAAM,CAAG,EAAA,iBAAiB,IAAI,SAAS;AAAA,MACrC,iBAAiB;AAAA,MAChB,QAAoD;AAAA,IACvD;AAEM,UAAA,SAAS,OAAO,mBAA0B;AAEhD,WAAO,MAAM;AACX,YAAM,cAAc,YAAA,IAChB,MAAM,SACN,OAAO;AAAA,QAAkB,MACvB,SAAS,UAAU,cAAc,WAAW,OAAO,GAAG,CAAC;AAAA,MACzD;AACJ,iBAAW,UAAU,WAAW;AAAA,IAAA,CACjC;AAEM,WAAA;AAAA,EAAA,CACR;AACH;"}
|
|
1
|
+
{"version":3,"file":"inject-queries.mjs","sources":["../src/inject-queries.ts"],"sourcesContent":["import {\n QueriesObserver,\n QueryClient,\n notifyManager,\n} from '@tanstack/query-core'\nimport {\n DestroyRef,\n Injector,\n NgZone,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core'\nimport { injectIsRestoring } from './inject-is-restoring'\nimport type { Signal } from '@angular/core'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `CreateQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype QueryObserverOptionsForCreateQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n 'placeholderData'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n QueryObserverOptionsForCreateQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? QueryObserverResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? QueryObserverResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n QueryObserverResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\nexport type QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverOptionsForCreateQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<QueryObserverOptionsForCreateQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n */\nexport type QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >\n >\n ? // Dynamic-size (homogenous) CreateQueryOptions array: map directly to array of results\n Array<\n QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n >\n : // Fallback\n Array<QueryObserverResult>\n\n/**\n * @param root0\n * @param root0.queries\n * @param root0.combine\n * @param injector\n */\nexport function injectQueries<\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: {\n queries: Signal<[...QueriesOptions<T>]>\n combine?: (result: QueriesResults<T>) => TCombinedResult\n },\n injector?: Injector,\n): Signal<TCombinedResult> {\n !injector && assertInInjectionContext(injectQueries)\n return runInInjectionContext(injector ?? inject(Injector), () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n const isRestoring = injectIsRestoring()\n\n const defaultedQueries = computed(() => {\n return queries().map((opts) => {\n const defaultedOptions = queryClient.defaultQueryOptions(opts)\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring()\n ? 'isRestoring'\n : 'optimistic'\n\n return defaultedOptions as QueryObserverOptions\n })\n })\n\n const observer = new QueriesObserver<TCombinedResult>(\n queryClient,\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n )\n\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n effect(() => {\n observer.setQueries(\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n )\n })\n\n const [, getCombinedResult] = observer.getOptimisticResult(\n defaultedQueries(),\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n const result = signal(getCombinedResult() as any)\n\n effect(() => {\n const unsubscribe = isRestoring()\n ? () => undefined\n : ngZone.runOutsideAngular(() =>\n observer.subscribe(notifyManager.batchCalls(result.set)),\n )\n destroyRef.onDestroy(unsubscribe)\n })\n\n return result\n })\n}\n"],"names":[],"mappings":";;;AAyMO,SAAS,cAId;AAAA,EACE;AAAA,EACA,GAAG;AACL,GAIA,UACyB;AACxB,GAAA,YAAY,yBAAyB,aAAa;AACnD,SAAO,sBAAsB,YAAY,OAAO,QAAQ,GAAG,MAAM;AACzD,UAAA,aAAa,OAAO,UAAU;AAC9B,UAAA,SAAS,OAAO,MAAM;AACtB,UAAA,cAAc,OAAO,WAAW;AACtC,UAAM,cAAc,kBAAkB;AAEhC,UAAA,mBAAmB,SAAS,MAAM;AACtC,aAAO,QAAQ,EAAE,IAAI,CAAC,SAAS;AACvB,cAAA,mBAAmB,YAAY,oBAAoB,IAAI;AAE5C,yBAAA,qBAAqB,YAAY,IAC9C,gBACA;AAEG,eAAA;AAAA,MAAA,CACR;AAAA,IAAA,CACF;AAED,UAAM,WAAW,IAAI;AAAA,MACnB;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,IACF;AAIA,WAAO,MAAM;AACF,eAAA;AAAA,QACP,iBAAiB;AAAA,QACjB;AAAA,MACF;AAAA,IAAA,CACD;AAED,UAAM,CAAG,EAAA,iBAAiB,IAAI,SAAS;AAAA,MACrC,iBAAiB;AAAA,MAChB,QAAoD;AAAA,IACvD;AAEM,UAAA,SAAS,OAAO,mBAA0B;AAEhD,WAAO,MAAM;AACX,YAAM,cAAc,YAAA,IAChB,MAAM,SACN,OAAO;AAAA,QAAkB,MACvB,SAAS,UAAU,cAAc,WAAW,OAAO,GAAG,CAAC;AAAA,MACzD;AACJ,iBAAW,UAAU,WAAW;AAAA,IAAA,CACjC;AAEM,WAAA;AAAA,EAAA,CACR;AACH;"}
|
package/inject-query-client.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { QueryClient } from '@tanstack/query-core';
|
|
|
4
4
|
* Injects a `QueryClient` instance and allows passing a custom injector.
|
|
5
5
|
* @param injectOptions - Type of the options argument to inject and optionally a custom injector.
|
|
6
6
|
* @returns The `QueryClient` instance.
|
|
7
|
-
* @public
|
|
8
7
|
* @deprecated Use `inject(QueryClient)` instead.
|
|
9
8
|
* If you need to get a `QueryClient` from a custom injector, use `injector.get(QueryClient)`.
|
|
10
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-query-client.mjs","sources":["../src/inject-query-client.ts"],"sourcesContent":["import { Injector, inject } from '@angular/core'\nimport { QueryClient } from '@tanstack/query-core'\nimport type { InjectOptions } from '@angular/core'\n\n/**\n * Injects a `QueryClient` instance and allows passing a custom injector.\n * @param injectOptions - Type of the options argument to inject and optionally a custom injector.\n * @returns The `QueryClient` instance.\n * @
|
|
1
|
+
{"version":3,"file":"inject-query-client.mjs","sources":["../src/inject-query-client.ts"],"sourcesContent":["import { Injector, inject } from '@angular/core'\nimport { QueryClient } from '@tanstack/query-core'\nimport type { InjectOptions } from '@angular/core'\n\n/**\n * Injects a `QueryClient` instance and allows passing a custom injector.\n * @param injectOptions - Type of the options argument to inject and optionally a custom injector.\n * @returns The `QueryClient` instance.\n * @deprecated Use `inject(QueryClient)` instead.\n * If you need to get a `QueryClient` from a custom injector, use `injector.get(QueryClient)`.\n *\n *\n * **Example**\n * ```ts\n * const queryClient = injectQueryClient();\n * ```\n */\nexport function injectQueryClient(\n injectOptions: InjectOptions & { injector?: Injector } = {},\n) {\n return (injectOptions.injector ?? inject(Injector)).get(QueryClient)\n}\n"],"names":[],"mappings":";;AAiBgB,SAAA,kBACd,gBAAyD,IACzD;AACA,UAAQ,cAAc,YAAY,OAAO,QAAQ,GAAG,IAAI,WAAW;AACrE;"}
|
package/inject-query.d.ts
CHANGED
|
@@ -44,7 +44,6 @@ export interface InjectQueryOptions {
|
|
|
44
44
|
* @param injectQueryFn - A function that returns query options.
|
|
45
45
|
* @param options - Additional configuration
|
|
46
46
|
* @returns The query result.
|
|
47
|
-
* @public
|
|
48
47
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
49
48
|
*/
|
|
50
49
|
export declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): DefinedCreateQueryResult<TData, TError>;
|
|
@@ -82,7 +81,6 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
82
81
|
* @param injectQueryFn - A function that returns query options.
|
|
83
82
|
* @param options - Additional configuration
|
|
84
83
|
* @returns The query result.
|
|
85
|
-
* @public
|
|
86
84
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
87
85
|
*/
|
|
88
86
|
export declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
|
|
@@ -120,7 +118,6 @@ export declare function injectQuery<TQueryFnData = unknown, TError = DefaultErro
|
|
|
120
118
|
* @param injectQueryFn - A function that returns query options.
|
|
121
119
|
* @param options - Additional configuration
|
|
122
120
|
* @returns The query result.
|
|
123
|
-
* @public
|
|
124
121
|
* @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries
|
|
125
122
|
*/
|
|
126
123
|
export declare function injectQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(injectQueryFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
|
package/inject-query.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-query.mjs","sources":["../src/inject-query.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport {\n Injector,\n assertInInjectionContext,\n inject,\n runInInjectionContext,\n} from '@angular/core'\nimport { createBaseQuery } from './create-base-query'\nimport type { DefaultError, QueryKey } 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\nexport interface InjectQueryOptions {\n /**\n * The `Injector` in which to create the query.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param injectQueryFn - A function that returns query options.\n * @param options - Additional configuration\n * @returns The query result.\n * @
|
|
1
|
+
{"version":3,"file":"inject-query.mjs","sources":["../src/inject-query.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport {\n Injector,\n assertInInjectionContext,\n inject,\n runInInjectionContext,\n} from '@angular/core'\nimport { createBaseQuery } from './create-base-query'\nimport type { DefaultError, QueryKey } 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\nexport interface InjectQueryOptions {\n /**\n * The `Injector` in which to create the query.\n *\n * If this is not provided, the current injection context will be used instead (via `inject`).\n */\n injector?: Injector\n}\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param injectQueryFn - A function that returns query options.\n * @param options - Additional configuration\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 injectQueryFn: () => DefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n options?: InjectQueryOptions,\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 *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param injectQueryFn - A function that returns query options.\n * @param options - Additional configuration\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 injectQueryFn: () => UndefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n options?: InjectQueryOptions,\n): CreateQueryResult<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 *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param injectQueryFn - A function that returns query options.\n * @param options - Additional configuration\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 injectQueryFn: () => CreateQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n options?: InjectQueryOptions,\n): CreateQueryResult<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 *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param injectQueryFn - A function that returns query options.\n * @param options - Additional configuration\n * @returns The query result.\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery(\n injectQueryFn: () => CreateQueryOptions,\n options?: InjectQueryOptions,\n) {\n !options?.injector && assertInInjectionContext(injectQuery)\n return runInInjectionContext(options?.injector ?? inject(Injector), () =>\n createBaseQuery(injectQueryFn, QueryObserver),\n ) as unknown as CreateQueryResult\n}\n"],"names":[],"mappings":";;;AAyNgB,SAAA,YACd,eACA,SACA;AACC,IAAA,mCAAS,aAAY,yBAAyB,WAAW;AACnD,SAAA;AAAA,KAAsB,mCAAS,aAAY,OAAO,QAAQ;AAAA,IAAG,MAClE,gBAAgB,eAAe,aAAa;AAAA,EAC9C;AACF;"}
|
package/mutation-options.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { CreateMutationOptions } from './types.js';
|
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
9
|
* export class QueriesService {
|
|
10
|
-
* private http = inject(HttpClient)
|
|
10
|
+
* private http = inject(HttpClient)
|
|
11
|
+
* private queryClient = inject(QueryClient)
|
|
11
12
|
*
|
|
12
13
|
* updatePost(id: number) {
|
|
13
14
|
* return mutationOptions({
|
|
@@ -25,10 +26,10 @@ import { CreateMutationOptions } from './types.js';
|
|
|
25
26
|
* queries = inject(QueriesService)
|
|
26
27
|
* id = signal(0)
|
|
27
28
|
* mutation = injectMutation(() => this.queries.updatePost(this.id()))
|
|
28
|
-
* }
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* save() {
|
|
31
|
+
* this.mutation.mutate({ title: 'New Title' })
|
|
32
|
+
* }
|
|
32
33
|
* }
|
|
33
34
|
* ```
|
|
34
35
|
* @param options - The mutation options.
|
package/mutation-options.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-options.mjs","sources":["../src/mutation-options.ts"],"sourcesContent":["import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { CreateMutationOptions } from './types'\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient)
|
|
1
|
+
{"version":3,"file":"mutation-options.mjs","sources":["../src/mutation-options.ts"],"sourcesContent":["import type { DefaultError, WithRequired } from '@tanstack/query-core'\nimport type { CreateMutationOptions } from './types'\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient)\n * private queryClient = inject(QueryClient)\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost)\n * },\n * });\n * }\n * }\n *\n * class ComponentOrService {\n * queries = inject(QueriesService)\n * id = signal(0)\n * mutation = injectMutation(() => this.queries.updatePost(this.id()))\n *\n * save() {\n * this.mutation.mutate({ title: 'New Title' })\n * }\n * }\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: WithRequired<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n >,\n): WithRequired<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n>\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: Omit<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n >,\n): Omit<\n CreateMutationOptions<TData, TError, TVariables, TContext>,\n 'mutationKey'\n>\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient)\n * private queryClient = inject(QueryClient)\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost)\n * },\n * });\n * }\n * }\n *\n * class ComponentOrService {\n * queries = inject(QueriesService)\n * id = signal(0)\n * mutation = injectMutation(() => this.queries.updatePost(this.id()))\n *\n * save() {\n * this.mutation.mutate({ title: 'New Title' })\n * }\n * }\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: CreateMutationOptions<TData, TError, TVariables, TContext>,\n): CreateMutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n"],"names":[],"mappings":"AAsGO,SAAS,gBAMd,SAC4D;AACrD,SAAA;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-query-experimental",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.88.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",
|
|
@@ -35,15 +35,35 @@
|
|
|
35
35
|
"types": "./index.d.ts",
|
|
36
36
|
"default": "./index.mjs"
|
|
37
37
|
},
|
|
38
|
+
"./package.json": "./package.json",
|
|
38
39
|
"./inject-queries-experimental": {
|
|
39
40
|
"types": "./inject-queries-experimental/index.d.ts",
|
|
40
41
|
"default": "./inject-queries-experimental/index.mjs"
|
|
41
42
|
},
|
|
42
|
-
"./
|
|
43
|
+
"./devtools": {
|
|
44
|
+
"types": "./devtools/index.d.ts",
|
|
45
|
+
"development": "./devtools/index.mjs",
|
|
46
|
+
"default": "./devtools/stub.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./devtools/production": {
|
|
49
|
+
"types": "./devtools/production/index.d.ts",
|
|
50
|
+
"default": "./devtools/index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./devtools-panel": {
|
|
53
|
+
"types": "./devtools-panel/index.d.ts",
|
|
54
|
+
"development": "./devtools-panel/index.mjs",
|
|
55
|
+
"default": "./devtools-panel/stub.mjs"
|
|
56
|
+
},
|
|
57
|
+
"./devtools-panel/production": {
|
|
58
|
+
"types": "./devtools-panel/production/index.d.ts",
|
|
59
|
+
"default": "./devtools-panel/index.mjs"
|
|
60
|
+
}
|
|
43
61
|
},
|
|
44
62
|
"sideEffects": false,
|
|
45
63
|
"dependencies": {
|
|
46
|
-
"@tanstack/query-core": "5.87.4"
|
|
64
|
+
"@tanstack/query-core": "5.87.4"
|
|
65
|
+
},
|
|
66
|
+
"optionalDependencies": {
|
|
47
67
|
"@tanstack/query-devtools": "5.87.3"
|
|
48
68
|
},
|
|
49
69
|
"peerDependencies": {
|
package/providers.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { InjectionToken, Provider } from '@angular/core';
|
|
2
2
|
import { QueryClient } from '@tanstack/query-core';
|
|
3
|
-
import { DevtoolsButtonPosition, DevtoolsErrorType, DevtoolsPosition } from '@tanstack/query-devtools';
|
|
4
3
|
/**
|
|
5
4
|
* Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the
|
|
6
5
|
* {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}
|
|
@@ -74,6 +73,10 @@ export declare function provideQueryClient(queryClient: QueryClient | InjectionT
|
|
|
74
73
|
* // In a lazy loaded route or lazy loaded component's providers array:
|
|
75
74
|
* providers: [provideTanStackQuery(MY_QUERY_CLIENT)]
|
|
76
75
|
* ```
|
|
76
|
+
* Using an InjectionToken for the QueryClient is an advanced optimization which allows TanStack Query to be absent from the main application bundle.
|
|
77
|
+
* This can be beneficial if you want to include TanStack Query on lazy loaded routes only while still sharing a `QueryClient`.
|
|
78
|
+
*
|
|
79
|
+
* Note that this is a small optimization and for most applications it's preferable to provide the `QueryClient` in the main application config.
|
|
77
80
|
* @param queryClient - A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
|
|
78
81
|
* @param features - Optional features to configure additional Query functionality.
|
|
79
82
|
* @returns A set of providers to set up TanStack Query.
|
|
@@ -87,11 +90,12 @@ export declare function provideTanStackQuery(queryClient: QueryClient | Injectio
|
|
|
87
90
|
* Allows to configure a `QueryClient`.
|
|
88
91
|
* @param queryClient - A `QueryClient` instance.
|
|
89
92
|
* @returns A set of providers to set up TanStack Query.
|
|
90
|
-
* @public
|
|
91
93
|
* @see https://tanstack.com/query/v5/docs/framework/angular/quick-start
|
|
92
94
|
* @deprecated Use `provideTanStackQuery` instead.
|
|
93
95
|
*/
|
|
94
96
|
export declare function provideAngularQuery(queryClient: QueryClient): Array<Provider>;
|
|
97
|
+
declare const queryFeatures: readonly ["Devtools", "PersistQueryClient"];
|
|
98
|
+
type QueryFeatureKind = (typeof queryFeatures)[number];
|
|
95
99
|
/**
|
|
96
100
|
* Helper type to represent a Query feature.
|
|
97
101
|
*/
|
|
@@ -109,111 +113,20 @@ export declare function queryFeature<TFeatureKind extends QueryFeatureKind>(kind
|
|
|
109
113
|
/**
|
|
110
114
|
* A type alias that represents a feature which enables developer tools.
|
|
111
115
|
* The type is used to describe the return value of the `withDevtools` function.
|
|
112
|
-
* @public
|
|
113
116
|
* @see {@link withDevtools}
|
|
114
117
|
*/
|
|
115
|
-
export type DeveloperToolsFeature = QueryFeature<'
|
|
118
|
+
export type DeveloperToolsFeature = QueryFeature<'Devtools'>;
|
|
116
119
|
/**
|
|
117
120
|
* A type alias that represents a feature which enables persistence.
|
|
118
121
|
* The type is used to describe the return value of the `withPersistQueryClient` function.
|
|
119
|
-
* @public
|
|
120
122
|
*/
|
|
121
123
|
export type PersistQueryClientFeature = QueryFeature<'PersistQueryClient'>;
|
|
122
|
-
/**
|
|
123
|
-
* Options for configuring the TanStack Query devtools.
|
|
124
|
-
* @public
|
|
125
|
-
*/
|
|
126
|
-
export interface DevtoolsOptions {
|
|
127
|
-
/**
|
|
128
|
-
* Set this true if you want the devtools to default to being open
|
|
129
|
-
*/
|
|
130
|
-
initialIsOpen?: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* The position of the TanStack logo to open and close the devtools panel.
|
|
133
|
-
* `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`
|
|
134
|
-
* Defaults to `bottom-right`.
|
|
135
|
-
*/
|
|
136
|
-
buttonPosition?: DevtoolsButtonPosition;
|
|
137
|
-
/**
|
|
138
|
-
* The position of the TanStack Query devtools panel.
|
|
139
|
-
* `top` | `bottom` | `left` | `right`
|
|
140
|
-
* Defaults to `bottom`.
|
|
141
|
-
*/
|
|
142
|
-
position?: DevtoolsPosition;
|
|
143
|
-
/**
|
|
144
|
-
* Custom instance of QueryClient
|
|
145
|
-
*/
|
|
146
|
-
client?: QueryClient;
|
|
147
|
-
/**
|
|
148
|
-
* Use this so you can define custom errors that can be shown in the devtools.
|
|
149
|
-
*/
|
|
150
|
-
errorTypes?: Array<DevtoolsErrorType>;
|
|
151
|
-
/**
|
|
152
|
-
* 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.
|
|
153
|
-
*/
|
|
154
|
-
styleNonce?: string;
|
|
155
|
-
/**
|
|
156
|
-
* Use this so you can attach the devtool's styles to a specific element in the DOM.
|
|
157
|
-
*/
|
|
158
|
-
shadowDOMTarget?: ShadowRoot;
|
|
159
|
-
/**
|
|
160
|
-
* Set this to true to hide disabled queries from the devtools panel.
|
|
161
|
-
*/
|
|
162
|
-
hideDisabledQueries?: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Whether the developer tools should load.
|
|
165
|
-
* - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.
|
|
166
|
-
* - `true`- Always load the devtools, regardless of the environment.
|
|
167
|
-
* - `false`- Never load the devtools, regardless of the environment.
|
|
168
|
-
*
|
|
169
|
-
* You can use `true` and `false` to override loading developer tools from an environment file.
|
|
170
|
-
* For example, a test environment might run in production mode but you may want to load developer tools.
|
|
171
|
-
*
|
|
172
|
-
* Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,
|
|
173
|
-
* a signal created from a RxJS observable that listens for a keyboard shortcut.
|
|
174
|
-
*
|
|
175
|
-
* **Example**
|
|
176
|
-
* ```ts
|
|
177
|
-
* withDevtools(() => ({
|
|
178
|
-
* initialIsOpen: true,
|
|
179
|
-
* loadDevtools: inject(ExampleService).loadDevtools()
|
|
180
|
-
* }))
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
loadDevtools?: 'auto' | boolean;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Enables developer tools.
|
|
187
|
-
*
|
|
188
|
-
* **Example**
|
|
189
|
-
*
|
|
190
|
-
* ```ts
|
|
191
|
-
* export const appConfig: ApplicationConfig = {
|
|
192
|
-
* providers: [
|
|
193
|
-
* provideTanStackQuery(new QueryClient(), withDevtools())
|
|
194
|
-
* ]
|
|
195
|
-
* }
|
|
196
|
-
* ```
|
|
197
|
-
* By default the devtools will be loaded when Angular runs in development mode and rendered in `<body>`.
|
|
198
|
-
*
|
|
199
|
-
* 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.
|
|
200
|
-
*
|
|
201
|
-
* If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.
|
|
202
|
-
* @param withDevtoolsFn - A function that returns `DevtoolsOptions`.
|
|
203
|
-
* @returns A set of providers for use with `provideTanStackQuery`.
|
|
204
|
-
* @public
|
|
205
|
-
* @see {@link provideTanStackQuery}
|
|
206
|
-
* @see {@link DevtoolsOptions}
|
|
207
|
-
*/
|
|
208
|
-
export declare function withDevtools(withDevtoolsFn?: () => DevtoolsOptions): DeveloperToolsFeature;
|
|
209
124
|
/**
|
|
210
125
|
* A type alias that represents all Query features available for use with `provideTanStackQuery`.
|
|
211
126
|
* Features can be enabled by adding special functions to the `provideTanStackQuery` call.
|
|
212
127
|
* See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`
|
|
213
128
|
* documentation on how to use those functions.
|
|
214
|
-
* @public
|
|
215
129
|
* @see {@link provideTanStackQuery}
|
|
216
130
|
*/
|
|
217
131
|
export type QueryFeatures = DeveloperToolsFeature | PersistQueryClientFeature;
|
|
218
|
-
export
|
|
219
|
-
export type QueryFeatureKind = (typeof queryFeatures)[number];
|
|
132
|
+
export {};
|