ngx-signal-query 1.2.0 → 1.3.0-dev.1
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/fesm2022/ngx-signal-query.mjs +271 -139
- package/fesm2022/ngx-signal-query.mjs.map +1 -1
- package/index.d.ts +57 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, Injectable, InjectionToken, inject, makeEnvironmentProviders, assertInInjectionContext,
|
|
2
|
+
import { signal, Injectable, InjectionToken, inject, makeEnvironmentProviders, assertInInjectionContext, effect, computed, untracked, Injector, DestroyRef, runInInjectionContext } from '@angular/core';
|
|
3
3
|
import { defer, from, take, retry, timer, throwIfEmpty } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
/** @internal */
|
|
@@ -706,6 +706,177 @@ function injectQueryClient(options) {
|
|
|
706
706
|
return options?.injector?.get(QueryClient) ?? inject(QueryClient);
|
|
707
707
|
}
|
|
708
708
|
|
|
709
|
+
/**
|
|
710
|
+
* Observes a single query and exposes its state as signals — the engine behind
|
|
711
|
+
* {@link injectQuery} and {@link injectQueries}.
|
|
712
|
+
*
|
|
713
|
+
* Effects are created on `injector` with `manualCleanup` so the observer can be
|
|
714
|
+
* torn down on its own via `destroy()`, independently of the injector's
|
|
715
|
+
* lifetime (a component may drop one query out of many). In a component
|
|
716
|
+
* injector they run as view effects, elsewhere as root effects — the same as
|
|
717
|
+
* `effect()` called directly in that context.
|
|
718
|
+
*
|
|
719
|
+
* @internal
|
|
720
|
+
*/
|
|
721
|
+
function createQueryObserver(optionsFn, injector) {
|
|
722
|
+
const client = injector.get(QueryClient);
|
|
723
|
+
const cache = client.getQueryCache();
|
|
724
|
+
// Every effect is registered here so destroy() covers all of them.
|
|
725
|
+
const refs = [];
|
|
726
|
+
const track = (fn) => {
|
|
727
|
+
refs.push(effect(fn, { injector, manualCleanup: true }));
|
|
728
|
+
};
|
|
729
|
+
// Single source of truth for defaulted options; resolves config defaults
|
|
730
|
+
// (staleTime, gcTime) once instead of scattering the logic across effects.
|
|
731
|
+
const defaultedOptions = computed(() => client.defaultQueryOptions(optionsFn()), ...(ngDevMode ? [{ debugName: "defaultedOptions" }] : []));
|
|
732
|
+
// Seed a fresh query (status 'pending', no data yet) with initialData so
|
|
733
|
+
// it renders immediately as 'success'. Without an explicit
|
|
734
|
+
// initialDataUpdatedAt the seed is treated as fetched right now, so
|
|
735
|
+
// staleTime applies to it as it would to any other data (a staleTime of 0
|
|
736
|
+
// still means "stale immediately" → background refetch).
|
|
737
|
+
const applyInitialData = (q) => {
|
|
738
|
+
const { initialData, initialDataUpdatedAt } = untracked(defaultedOptions);
|
|
739
|
+
if (initialData === undefined || q.state().status !== 'pending')
|
|
740
|
+
return;
|
|
741
|
+
const data = typeof initialData === 'function'
|
|
742
|
+
? initialData()
|
|
743
|
+
: initialData;
|
|
744
|
+
const updatedAt = typeof initialDataUpdatedAt === 'function'
|
|
745
|
+
? initialDataUpdatedAt()
|
|
746
|
+
: (initialDataUpdatedAt ?? Date.now());
|
|
747
|
+
q.setData(data, updatedAt);
|
|
748
|
+
};
|
|
749
|
+
// getOrCreate mutates the cache (a side effect), so it must not run inside
|
|
750
|
+
// a computed. Resolve the query in a signal: seed it synchronously and
|
|
751
|
+
// update it from an effect whenever the key changes.
|
|
752
|
+
const seed = cache.getOrCreate(untracked(defaultedOptions).queryKey);
|
|
753
|
+
applyInitialData(seed);
|
|
754
|
+
const query = signal(seed, ...(ngDevMode ? [{ debugName: "query" }] : []));
|
|
755
|
+
// Data of the last query that had any, fed to the placeholderData function
|
|
756
|
+
// on key change (mirrors TanStack's lastQueryWithDefinedData). Captured
|
|
757
|
+
// synchronously before the switch so it can't miss a just-resolved value.
|
|
758
|
+
const lastData = signal(undefined, ...(ngDevMode ? [{ debugName: "lastData" }] : []));
|
|
759
|
+
track(() => {
|
|
760
|
+
const key = defaultedOptions().queryKey;
|
|
761
|
+
const q = untracked(() => cache.getOrCreate(key));
|
|
762
|
+
untracked(() => {
|
|
763
|
+
const prev = query();
|
|
764
|
+
if (prev !== q && prev.state().data !== undefined) {
|
|
765
|
+
lastData.set(prev.state().data);
|
|
766
|
+
}
|
|
767
|
+
applyInitialData(q);
|
|
768
|
+
});
|
|
769
|
+
query.set(q);
|
|
770
|
+
});
|
|
771
|
+
// Memoized: only emits when the flag itself flips, so ordinary data
|
|
772
|
+
// updates don't wake the fetch effect (no refetch loop).
|
|
773
|
+
const isInvalidated = computed(() => query().state().isInvalidated, ...(ngDevMode ? [{ debugName: "isInvalidated" }] : []));
|
|
774
|
+
track((cleanup) => {
|
|
775
|
+
const q = query();
|
|
776
|
+
const { gcTime } = untracked(defaultedOptions);
|
|
777
|
+
if (gcTime !== undefined) {
|
|
778
|
+
q.setGcTime(gcTime);
|
|
779
|
+
}
|
|
780
|
+
q.addObserver();
|
|
781
|
+
cleanup(() => q.removeObserver());
|
|
782
|
+
});
|
|
783
|
+
// Memoized so options re-evaluations that leave the flag alone don't wake
|
|
784
|
+
// the fetch effect.
|
|
785
|
+
const enabled = computed(() => defaultedOptions().enabled !== false, ...(ngDevMode ? [{ debugName: "enabled" }] : []));
|
|
786
|
+
// Fetch when the observed query switches (key change), when it becomes
|
|
787
|
+
// enabled, or when it is invalidated — not on every re-evaluation of the
|
|
788
|
+
// options. defaultQueryOptions() builds a fresh object each time, so
|
|
789
|
+
// tracking it whole would refetch stale data whenever any signal read in
|
|
790
|
+
// optionsFn changes, even one unrelated to the key. queryFn, staleTime and
|
|
791
|
+
// the retry policy only parameterise the fetch and are read untracked
|
|
792
|
+
// (TanStack's shouldFetchOptionally).
|
|
793
|
+
track(() => {
|
|
794
|
+
query();
|
|
795
|
+
// Track invalidation so invalidateQueries() re-triggers a refetch.
|
|
796
|
+
// When invalidated, cancel any in-flight fetch and start a fresh one
|
|
797
|
+
// (otherwise the stale in-flight result would clear isInvalidated).
|
|
798
|
+
const invalidated = isInvalidated();
|
|
799
|
+
if (!enabled())
|
|
800
|
+
return;
|
|
801
|
+
const { queryKey, queryFn, staleTime, retry, retryDelay } = untracked(defaultedOptions);
|
|
802
|
+
untracked(() => client.fetchQuery(queryKey, queryFn, {
|
|
803
|
+
staleTime,
|
|
804
|
+
retry,
|
|
805
|
+
retryDelay,
|
|
806
|
+
cancelRefetch: invalidated,
|
|
807
|
+
}));
|
|
808
|
+
});
|
|
809
|
+
// Polling: refetch on an interval, independent of staleTime (staleTime: 0
|
|
810
|
+
// forces the fetch). The function form is reactive — reading state() makes
|
|
811
|
+
// the effect re-run when data changes, so returning false stops polling.
|
|
812
|
+
track((onCleanup) => {
|
|
813
|
+
const { queryKey, queryFn, retry, retryDelay, refetchInterval, enabled } = defaultedOptions();
|
|
814
|
+
if (enabled === false)
|
|
815
|
+
return;
|
|
816
|
+
const interval = typeof refetchInterval === 'function'
|
|
817
|
+
? refetchInterval({ state: query().state() })
|
|
818
|
+
: refetchInterval;
|
|
819
|
+
if (!interval)
|
|
820
|
+
return;
|
|
821
|
+
const id = setInterval(() => {
|
|
822
|
+
client.fetchQuery(queryKey, queryFn, {
|
|
823
|
+
staleTime: 0,
|
|
824
|
+
retry,
|
|
825
|
+
retryDelay,
|
|
826
|
+
});
|
|
827
|
+
}, interval);
|
|
828
|
+
onCleanup(() => clearInterval(id));
|
|
829
|
+
});
|
|
830
|
+
// Placeholder layer: while the query is pending with no data, present
|
|
831
|
+
// placeholderData as already-successful data. Purely presentational — the
|
|
832
|
+
// cache entry stays 'pending' and the fetch proceeds, so isFetching keeps
|
|
833
|
+
// reporting the real request and the placeholder is dropped on resolve.
|
|
834
|
+
const resolved = computed(() => {
|
|
835
|
+
const state = query().state();
|
|
836
|
+
const { placeholderData } = defaultedOptions();
|
|
837
|
+
if (placeholderData !== undefined &&
|
|
838
|
+
state.data === undefined &&
|
|
839
|
+
state.status === 'pending') {
|
|
840
|
+
const data = typeof placeholderData === 'function'
|
|
841
|
+
? placeholderData(lastData())
|
|
842
|
+
: placeholderData;
|
|
843
|
+
if (data !== undefined) {
|
|
844
|
+
return { data, status: 'success', isPlaceholderData: true };
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return { data: state.data, status: state.status, isPlaceholderData: false };
|
|
848
|
+
}, ...(ngDevMode ? [{ debugName: "resolved" }] : []));
|
|
849
|
+
return {
|
|
850
|
+
result: {
|
|
851
|
+
data: computed(() => resolved().data),
|
|
852
|
+
status: computed(() => resolved().status),
|
|
853
|
+
error: computed(() => query().state().error),
|
|
854
|
+
isFetching: computed(() => query().state().isFetching),
|
|
855
|
+
// First fetch in-flight: fetching with no resolved data yet. An active
|
|
856
|
+
// placeholder counts as data — the UI shows it, not a loading state.
|
|
857
|
+
isLoading: computed(() => query().state().isFetching && resolved().status === 'pending'),
|
|
858
|
+
isPending: computed(() => resolved().status === 'pending'),
|
|
859
|
+
isSuccess: computed(() => resolved().status === 'success'),
|
|
860
|
+
isError: computed(() => resolved().status === 'error'),
|
|
861
|
+
isPlaceholderData: computed(() => resolved().isPlaceholderData),
|
|
862
|
+
failureCount: computed(() => query().state().failureCount),
|
|
863
|
+
failureReason: computed(() => query().state().failureReason),
|
|
864
|
+
// Force a fresh fetch regardless of staleTime, cancelling any in-flight
|
|
865
|
+
// request (explicit user intent — get current data).
|
|
866
|
+
refetch: () => {
|
|
867
|
+
const { queryKey, queryFn, retry, retryDelay } = untracked(defaultedOptions);
|
|
868
|
+
client.fetchQuery(queryKey, queryFn, {
|
|
869
|
+
staleTime: 0,
|
|
870
|
+
retry,
|
|
871
|
+
retryDelay,
|
|
872
|
+
cancelRefetch: true,
|
|
873
|
+
});
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
destroy: () => refs.forEach((ref) => ref.destroy()),
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
|
|
709
880
|
/**
|
|
710
881
|
* Runs a cached, reactive query and exposes its state as signals.
|
|
711
882
|
*
|
|
@@ -721,7 +892,9 @@ function injectQueryClient(options) {
|
|
|
721
892
|
* @typeParam TData - Type of the data resolved by `queryFn`.
|
|
722
893
|
* @typeParam TError - Type of the error thrown by `queryFn`.
|
|
723
894
|
* @param optionsFn - Factory returning the {@link QueryOptions}. Re-evaluated
|
|
724
|
-
* reactively
|
|
895
|
+
* reactively: a new `queryKey` switches to that query and fetches it, and
|
|
896
|
+
* turning `enabled` on starts the fetch. Re-evaluating with the same key
|
|
897
|
+
* does not refetch, so every value `queryFn` reads belongs in the key.
|
|
725
898
|
* @param options - Optional `injector` to use outside an injection context.
|
|
726
899
|
* @returns A {@link QueryResult} of signals (`data`, `status`, `error`,
|
|
727
900
|
* `isLoading`, `isPending`, …) plus a `refetch()` that forces a fresh fetch.
|
|
@@ -750,145 +923,104 @@ function injectQuery(optionsFn, options) {
|
|
|
750
923
|
if (!options?.injector)
|
|
751
924
|
assertInInjectionContext(injectQuery);
|
|
752
925
|
const injector = options?.injector ?? inject(Injector);
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
926
|
+
const { result, destroy } = createQueryObserver(optionsFn, injector);
|
|
927
|
+
// The observation lives as long as the owning context (component or
|
|
928
|
+
// injector): tear it down with it.
|
|
929
|
+
injector.get(DestroyRef).onDestroy(destroy);
|
|
930
|
+
return result;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Runs a dynamic number of queries in parallel and exposes their results as a
|
|
935
|
+
* signal holding one {@link QueryResult} per entry of `queries`, in order.
|
|
936
|
+
*
|
|
937
|
+
* Reach for it when the set of queries depends on data — one query per id in
|
|
938
|
+
* a list, say — where {@link injectQuery} can't be called in a loop. Each
|
|
939
|
+
* query behaves exactly like a standalone `injectQuery`: its own cache entry,
|
|
940
|
+
* `staleTime`, retries, error and observer. `optionsFn` is reactive: when the
|
|
941
|
+
* array changes, queries whose `queryKey` is still present are kept (with
|
|
942
|
+
* their options updated), new keys start fetching, and dropped keys release
|
|
943
|
+
* their observer. Aggregate across the results with `computed`.
|
|
944
|
+
*
|
|
945
|
+
* Must run in an injection context, or be given an explicit `injector`.
|
|
946
|
+
*
|
|
947
|
+
* @typeParam TData - Type of the data resolved by each `queryFn`.
|
|
948
|
+
* @typeParam TError - Type of the error thrown by each `queryFn`.
|
|
949
|
+
* @param optionsFn - Factory returning the {@link InjectQueriesOptions}.
|
|
950
|
+
* Re-evaluated reactively, so reading signals inside it re-syncs the set.
|
|
951
|
+
* @param options - Optional `injector` to use outside an injection context.
|
|
952
|
+
* @returns A signal of {@link QueryResult}s, one per query. The array identity
|
|
953
|
+
* changes only when the set of queries changes, not on every data update.
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```ts
|
|
957
|
+
* class TodoListComponent {
|
|
958
|
+
* readonly #queries = inject(TodoQueries)
|
|
959
|
+
*
|
|
960
|
+
* readonly todoIds = input.required<number[]>()
|
|
961
|
+
*
|
|
962
|
+
* readonly todos = injectQueries(() => ({
|
|
963
|
+
* queries: this.todoIds().map((id) => this.#queries.detail(id)),
|
|
964
|
+
* }))
|
|
965
|
+
*
|
|
966
|
+
* readonly isPending = computed(() =>
|
|
967
|
+
* this.todos().some((todo) => todo.isPending()),
|
|
968
|
+
* )
|
|
969
|
+
* }
|
|
970
|
+
* ```
|
|
971
|
+
*/
|
|
972
|
+
function injectQueries(optionsFn, options) {
|
|
973
|
+
if (!options?.injector)
|
|
974
|
+
assertInInjectionContext(injectQueries);
|
|
975
|
+
const injector = options?.injector ?? inject(Injector);
|
|
976
|
+
const results = signal([], ...(ngDevMode ? [{ debugName: "results" }] : []));
|
|
977
|
+
let entries = [];
|
|
978
|
+
// Reconciles the entries with a new list, matching by key hash the way
|
|
979
|
+
// TanStack's QueriesObserver does: a matching entry is reused and handed the
|
|
980
|
+
// new options, an unmatched query gets a fresh observer, and whatever is
|
|
981
|
+
// left over is destroyed. Duplicate keys are paired up one-to-one in order.
|
|
982
|
+
const sync = (queries) => {
|
|
983
|
+
const pool = new Map();
|
|
984
|
+
for (const entry of entries) {
|
|
985
|
+
const list = pool.get(entry.hash) ?? [];
|
|
986
|
+
list.push(entry);
|
|
987
|
+
pool.set(entry.hash, list);
|
|
988
|
+
}
|
|
989
|
+
const next = queries.map((queryOptions) => {
|
|
990
|
+
const hash = hashKey(queryOptions.queryKey);
|
|
991
|
+
const match = pool.get(hash)?.shift();
|
|
992
|
+
if (match) {
|
|
993
|
+
match.options.set(queryOptions);
|
|
994
|
+
return match;
|
|
806
995
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
// When invalidated, cancel any in-flight fetch and start a fresh one
|
|
814
|
-
// (otherwise the stale in-flight result would clear isInvalidated).
|
|
815
|
-
const invalidated = isInvalidated();
|
|
816
|
-
if (enabled === false)
|
|
817
|
-
return;
|
|
818
|
-
untracked(() => client.fetchQuery(queryKey, queryFn, {
|
|
819
|
-
staleTime,
|
|
820
|
-
retry,
|
|
821
|
-
retryDelay,
|
|
822
|
-
cancelRefetch: invalidated,
|
|
823
|
-
}));
|
|
824
|
-
});
|
|
825
|
-
// Polling: refetch on an interval, independent of staleTime (staleTime: 0
|
|
826
|
-
// forces the fetch). The function form is reactive — reading state() makes
|
|
827
|
-
// the effect re-run when data changes, so returning false stops polling.
|
|
828
|
-
effect((onCleanup) => {
|
|
829
|
-
const { queryKey, queryFn, retry, retryDelay, refetchInterval, enabled } = defaultedOptions();
|
|
830
|
-
if (enabled === false)
|
|
831
|
-
return;
|
|
832
|
-
const interval = typeof refetchInterval === 'function'
|
|
833
|
-
? refetchInterval({ state: query().state() })
|
|
834
|
-
: refetchInterval;
|
|
835
|
-
if (!interval)
|
|
836
|
-
return;
|
|
837
|
-
const id = setInterval(() => {
|
|
838
|
-
client.fetchQuery(queryKey, queryFn, {
|
|
839
|
-
staleTime: 0,
|
|
840
|
-
retry,
|
|
841
|
-
retryDelay,
|
|
842
|
-
});
|
|
843
|
-
}, interval);
|
|
844
|
-
onCleanup(() => clearInterval(id));
|
|
996
|
+
const optionsSignal = signal(queryOptions, ...(ngDevMode ? [{ debugName: "optionsSignal" }] : []));
|
|
997
|
+
return {
|
|
998
|
+
hash,
|
|
999
|
+
options: optionsSignal,
|
|
1000
|
+
observer: createQueryObserver(() => optionsSignal(), injector),
|
|
1001
|
+
};
|
|
845
1002
|
});
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
//
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
return {
|
|
866
|
-
data: computed(() => resolved().data),
|
|
867
|
-
status: computed(() => resolved().status),
|
|
868
|
-
error: computed(() => query().state().error),
|
|
869
|
-
isFetching: computed(() => query().state().isFetching),
|
|
870
|
-
// First fetch in-flight: fetching with no resolved data yet. An active
|
|
871
|
-
// placeholder counts as data — the UI shows it, not a loading state.
|
|
872
|
-
isLoading: computed(() => query().state().isFetching && resolved().status === 'pending'),
|
|
873
|
-
isPending: computed(() => resolved().status === 'pending'),
|
|
874
|
-
isSuccess: computed(() => resolved().status === 'success'),
|
|
875
|
-
isError: computed(() => resolved().status === 'error'),
|
|
876
|
-
isPlaceholderData: computed(() => resolved().isPlaceholderData),
|
|
877
|
-
failureCount: computed(() => query().state().failureCount),
|
|
878
|
-
failureReason: computed(() => query().state().failureReason),
|
|
879
|
-
// Force a fresh fetch regardless of staleTime, cancelling any in-flight
|
|
880
|
-
// request (explicit user intent — get current data).
|
|
881
|
-
refetch: () => {
|
|
882
|
-
const { queryKey, queryFn, retry, retryDelay } = untracked(defaultedOptions);
|
|
883
|
-
client.fetchQuery(queryKey, queryFn, {
|
|
884
|
-
staleTime: 0,
|
|
885
|
-
retry,
|
|
886
|
-
retryDelay,
|
|
887
|
-
cancelRefetch: true,
|
|
888
|
-
});
|
|
889
|
-
},
|
|
890
|
-
};
|
|
1003
|
+
for (const leftovers of pool.values()) {
|
|
1004
|
+
leftovers.forEach((entry) => entry.observer.destroy());
|
|
1005
|
+
}
|
|
1006
|
+
// Replace the result array only on a structural change, so a computed
|
|
1007
|
+
// over it doesn't recompute when merely the options were refreshed.
|
|
1008
|
+
const changed = next.length !== entries.length ||
|
|
1009
|
+
next.some((entry, index) => entry !== entries[index]);
|
|
1010
|
+
entries = next;
|
|
1011
|
+
if (changed)
|
|
1012
|
+
results.set(entries.map((entry) => entry.observer.result));
|
|
1013
|
+
};
|
|
1014
|
+
// Seed synchronously so the result is populated before effects flush.
|
|
1015
|
+
sync(untracked(() => optionsFn().queries));
|
|
1016
|
+
effect(() => {
|
|
1017
|
+
const { queries } = optionsFn();
|
|
1018
|
+
untracked(() => sync(queries));
|
|
1019
|
+
}, { injector });
|
|
1020
|
+
injector.get(DestroyRef).onDestroy(() => {
|
|
1021
|
+
entries.forEach((entry) => entry.observer.destroy());
|
|
891
1022
|
});
|
|
1023
|
+
return results.asReadonly();
|
|
892
1024
|
}
|
|
893
1025
|
|
|
894
1026
|
/**
|
|
@@ -1140,5 +1272,5 @@ function withDefaultOptions(options) {
|
|
|
1140
1272
|
* Generated bundle index. Do not edit.
|
|
1141
1273
|
*/
|
|
1142
1274
|
|
|
1143
|
-
export { QueryClient, QueryClientFeatureKind, injectIsFetching, injectIsMutating, injectMutation, injectQuery, injectQueryClient, keepPreviousData, mutationOptions, provideQueryClient, queryOptions, withDefaultOptions };
|
|
1275
|
+
export { QueryClient, QueryClientFeatureKind, injectIsFetching, injectIsMutating, injectMutation, injectQueries, injectQuery, injectQueryClient, keepPreviousData, mutationOptions, provideQueryClient, queryOptions, withDefaultOptions };
|
|
1144
1276
|
//# sourceMappingURL=ngx-signal-query.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-signal-query.mjs","sources":["../../../projects/ngx-signal-query/src/lib/core/cache.ts","../../../projects/ngx-signal-query/src/lib/core/utils.ts","../../../projects/ngx-signal-query/src/lib/core/retryer.ts","../../../projects/ngx-signal-query/src/lib/core/query.ts","../../../projects/ngx-signal-query/src/lib/core/query-cache.ts","../../../projects/ngx-signal-query/src/lib/core/mutation.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-cache.ts","../../../projects/ngx-signal-query/src/lib/core/injection-tokens.ts","../../../projects/ngx-signal-query/src/lib/core/query-client.ts","../../../projects/ngx-signal-query/src/lib/features/feature.ts","../../../projects/ngx-signal-query/src/lib/core/provider.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query-client.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query.ts","../../../projects/ngx-signal-query/src/lib/core/inject-mutation.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-fetching.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-mutating.ts","../../../projects/ngx-signal-query/src/lib/core/query-options.ts","../../../projects/ngx-signal-query/src/lib/core/keep-previous-data.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-options.ts","../../../projects/ngx-signal-query/src/lib/features/with-default-options.ts","../../../projects/ngx-signal-query/src/public-api.ts","../../../projects/ngx-signal-query/src/ngx-signal-query.ts"],"sourcesContent":["import { signal } from '@angular/core'\n\n/** @internal */\nexport abstract class Cache<TEntry> {\n readonly #entries = signal<TEntry[]>([])\n\n // Reactive snapshot of all entries; updated on add/remove/clear so that\n // findAll() (and its computed consumers like isFetching) react to the\n // collection. Protected: only subclasses read it, never external code.\n protected readonly entries = this.#entries.asReadonly()\n\n readonly #entriesMap = new Map<string, TEntry>()\n\n getAll(): TEntry[] {\n return Array.from(this.#entriesMap.values())\n }\n\n clear(): void {\n this.#entriesMap.clear()\n this.#sync()\n }\n\n protected addEntry(key: string, entry: TEntry): TEntry {\n this.#entriesMap.set(key, entry)\n this.#sync()\n\n return entry\n }\n\n protected getEntry(key: string): TEntry | undefined {\n return this.#entriesMap.get(key)\n }\n\n protected removeEntry(key: string): boolean {\n const removed = this.#entriesMap.delete(key)\n\n if (removed) this.#sync()\n\n return removed\n }\n\n #sync(): void {\n this.#entries.set(Array.from(this.#entriesMap.values()))\n }\n}\n","import type { QueryKey, Updater } from './types'\n\n// Resolves an updater: calls it with the previous value if it's a function,\n// otherwise uses it as the value directly.\n/** @internal */\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (input: TInput) => TOutput)(input)\n : updater\n}\n\n// True when `filter` is a (deep) prefix of `key`, e.g. ['app'] matches\n// ['app', 1]. Used to invalidate/find groups of queries by partial key.\n/** @internal */\nexport function partialMatchKey(key: QueryKey, filter: QueryKey): boolean {\n return partialDeepEqual(key, filter)\n}\n\nfunction partialDeepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (typeof a !== typeof b) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return Object.keys(b).every((key) =>\n partialDeepEqual(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n ),\n )\n }\n\n return false\n}\n\n/** @internal */\nexport function hashKey(key: QueryKey): string {\n return JSON.stringify(key, (_, value) =>\n isPlainObject(value)\n ? Object.keys(value)\n .sort()\n .reduce<Record<string, unknown>>((result, k) => {\n result[k] = value[k]\n\n return result\n }, {})\n : value,\n )\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n","import type { RetryDelayValue, RetryValue } from './types'\n\n// Exponential backoff capped at 30s, matching TanStack's default.\n/** @internal */\nexport function defaultRetryDelay(failureCount: number): number {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\n/** @internal */\nexport function shouldRetry<TError>(\n retry: RetryValue<TError>,\n failureCount: number,\n error: TError,\n): boolean {\n if (typeof retry === 'function') return retry(failureCount, error)\n if (typeof retry === 'number') return failureCount < retry\n\n return retry\n}\n\n/** @internal */\nexport function resolveRetryDelay<TError>(\n retryDelay: RetryDelayValue<TError>,\n failureCount: number,\n error: TError,\n): number {\n return typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n}\n","import { signal } from '@angular/core'\nimport {\n defer,\n from,\n retry as retryOperator,\n take,\n throwIfEmpty,\n timer,\n type Observable,\n type Subscription,\n} from 'rxjs'\n\nimport type { QueryCache } from './query-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport type { QueryKey, QueryState, RetryDelayValue, RetryValue } from './types'\n\nconst DEFAULT_GC_TIME = 5 * 60 * 1000\n\n/** @internal */\nexport class Query<TData, TError = Error> {\n readonly #state = signal<QueryState<TData, TError>>({\n data: undefined,\n status: 'pending',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: 0,\n })\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n #observers = 0\n #gcTime = DEFAULT_GC_TIME\n #gcTimer: ReturnType<typeof setTimeout> | null = null\n readonly #cache: QueryCache\n\n constructor(\n readonly key: QueryKey,\n readonly queryHash: string,\n cache: QueryCache,\n ) {\n this.#cache = cache\n }\n\n get observerCount(): number {\n return this.#observers\n }\n\n setGcTime(ms: number): void {\n this.#gcTime = ms\n }\n\n addObserver(): void {\n this.#observers++\n this.#clearGcTimer()\n }\n\n removeObserver(): void {\n if (this.#observers === 0) return\n\n this.#observers--\n\n // No observers left: cancel any in-flight fetch (nobody is waiting for it)\n // and schedule gc to dispose the query if no observer returns.\n if (this.#observers === 0) {\n this.cancel()\n this.#scheduleGc()\n }\n }\n\n fetch(\n queryFn: () => Observable<TData> | Promise<TData>,\n retry: RetryValue<TError> = 0,\n retryDelay: RetryDelayValue<TError> = defaultRetryDelay,\n cancelRefetch = false,\n ): void {\n if (this.#subscription && !this.#subscription.closed) {\n // Already in-flight: dedupe unless the caller explicitly wants a fresh\n // fetch (e.g. invalidate/refetch) — then cancel the old one and restart.\n if (!cancelRefetch) return\n this.cancel()\n }\n\n this.#state.update((state) => ({\n ...state,\n isFetching: true,\n failureCount: 0,\n failureReason: null,\n }))\n\n // defer + from: normalize Observable/Promise and re-invoke queryFn on each\n // retry (a Promise is one-shot, so retry must produce a fresh one).\n this.#subscription = defer(() => from(queryFn()))\n .pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n // retryCount (1-based) is the number of failures so far; the retry\n // predicate/delay take a 0-based attempt index (0 = first retry).\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () => new Error('Query function completed without emitting a value'),\n ),\n )\n .subscribe({\n next: (data) =>\n this.#state.set({\n data,\n status: 'success',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: Date.now(),\n }),\n error: (err) =>\n this.#state.update((state) => ({\n ...state,\n status: 'error',\n error: err,\n isFetching: false,\n })),\n })\n }\n\n setData(data: TData, updatedAt: number = Date.now()): void {\n this.#state.update((state) => ({\n ...state,\n data,\n status: 'success',\n error: null,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt,\n }))\n\n // Keep an orphaned query (no observers) alive for another gcTime so a\n // setQueryData write isn't collected before anyone subscribes.\n if (this.#observers === 0) this.#scheduleGc()\n }\n\n invalidate(): void {\n this.#state.update((state) => ({ ...state, isInvalidated: true }))\n }\n\n shouldFetch(staleTime: number): boolean {\n const state = this.state()\n\n return (\n state.status !== 'success' ||\n state.isInvalidated ||\n this.#isStale(staleTime)\n )\n }\n\n cancel(): void {\n this.#subscription?.unsubscribe()\n this.#subscription = null\n\n // The fetch is no longer running; clear the in-flight flag so isFetching\n // doesn't stay stuck true after a cancellation.\n if (this.state().isFetching) {\n this.#state.update((state) => ({ ...state, isFetching: false }))\n }\n }\n\n destroy(): void {\n this.cancel()\n this.#clearGcTimer()\n }\n\n // Inclusive: data fetched exactly `staleTime` ago is already stale. This\n // matters for seeded data (initialData is stamped with the current time), so\n // the default staleTime of 0 still means \"stale at once\" → background\n // refetch, rather than depending on whether a millisecond happened to pass.\n #isStale(staleTime: number): boolean {\n return Date.now() - this.state().updatedAt >= staleTime\n }\n\n #scheduleGc(): void {\n this.#clearGcTimer()\n\n this.#gcTimer = setTimeout(() => {\n this.#gcTimer = null\n this.#cache.remove(this)\n }, this.#gcTime)\n }\n\n #clearGcTimer(): void {\n if (this.#gcTimer === null) return\n\n clearTimeout(this.#gcTimer)\n this.#gcTimer = null\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport { hashKey, partialMatchKey } from './utils'\nimport { Query } from './query'\nimport type { QueryFilters, QueryKey } from './types'\n\n/** @internal */\n@Injectable()\nexport class QueryCache extends Cache<Query<unknown, unknown>> {\n getOrCreate<TData, TError = Error>(key: QueryKey): Query<TData, TError> {\n const queryHash = hashKey(key)\n const exist = this.getEntry(queryHash)\n\n if (exist) return exist as Query<TData, TError>\n\n return this.addEntry(queryHash, new Query(key, queryHash, this)) as Query<\n TData,\n TError\n >\n }\n\n get<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined {\n return this.getEntry(hashKey(key)) as Query<TData, TError> | undefined\n }\n\n findAll(filters: QueryFilters = {}): Array<Query<unknown, unknown>> {\n const { queryKey, exact } = filters\n\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!queryKey) return all\n\n if (exact) {\n const queryHash = hashKey(queryKey)\n\n return all.filter((query) => query.queryHash === queryHash)\n }\n\n return all.filter((query) => partialMatchKey(query.key, queryKey))\n }\n\n remove(query: Query<unknown, unknown>): void {\n // Guard on identity, not just the hash: a stale instance (already removed\n // and recreated under the same key) must not evict the current query.\n if (this.getEntry(query.queryHash) === query) {\n this.removeEntry(query.queryHash)\n }\n }\n\n override clear(): void {\n this.getAll().forEach((query) => query.destroy())\n super.clear()\n }\n}\n","import { type Signal, signal } from '@angular/core'\nimport {\n defer,\n from,\n retry as retryOperator,\n take,\n throwIfEmpty,\n timer,\n type Observable,\n type Subscription,\n} from 'rxjs'\n\nimport type { MutationCache } from './mutation-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport type { RetryDelayValue, RetryValue } from './types'\n\n/** Lifecycle status of a mutation: not yet run, running, succeeded, or failed. */\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\n/** Selects which mutations an operation applies to (e.g. `injectIsMutating`). */\nexport type MutationFilters = {\n /** Match mutations in this status. */\n status?: MutationStatus\n}\n\n/** Full state snapshot of a mutation (the reactive source behind {@link MutationResult}). */\nexport type MutationState<TData, TError, TVariables, TContext> = {\n /** Current {@link MutationStatus}. */\n status: MutationStatus\n /** Data resolved by the last successful run, or `undefined`. */\n data: TData | undefined\n /** Error of the last failed run, or `null`. */\n error: TError | null\n /** Variables passed to the most recent `mutate()` call. */\n variables: TVariables | undefined\n /** Value returned by `onMutate` for the current run. */\n context: TContext | undefined\n /** Number of failed attempts in the current run. */\n failureCount: number\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: TError | null\n /** Timestamp (ms) when the current run was submitted; `0` if never. */\n submittedAt: number\n}\n\n/**\n * Configuration for a mutation, passed to {@link injectMutation} /\n * {@link mutationOptions}. The hooks fire in order: `onMutate` →\n * (`onSuccess` | `onError`) → `onSettled`. The value returned by `onMutate`\n * is passed as `context` to the later hooks — handy for rollback.\n */\nexport type MutationOptions<TData, TError, TVariables, TContext> = {\n /** Performs the write; receives `mutate()`'s argument. Returns `Observable`/`Promise`. */\n mutationFn: (variables: TVariables) => Observable<TData> | Promise<TData>\n /** Retry policy. Defaults to no retry (writes are not idempotent). */\n retry?: RetryValue<TError>\n /** Delay between retries. See {@link RetryDelayValue}. */\n retryDelay?: RetryDelayValue<TError>\n /** Runs before `mutationFn`; its return value becomes `context` (e.g. for optimistic rollback). */\n onMutate?: (variables: TVariables) => TContext | undefined\n /** Runs after a successful `mutationFn`. */\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n /** Runs after a failed `mutationFn`. */\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n /** Runs after success or error — for cleanup that should happen either way. */\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n}\n\n/** Reactive result returned by {@link injectMutation}; state fields are signals. */\nexport type MutationResult<TData, TError, TVariables> = {\n /** Triggers the mutation with the given variables. */\n mutate: (variables: TVariables) => void\n /** Resets state back to `idle`, cancelling any in-flight run. */\n reset: () => void\n /** Data from the last successful run, or `undefined`. */\n data: Signal<TData | undefined>\n /** Error from the last failed run, or `null`. */\n error: Signal<TError | null>\n /** Variables from the most recent `mutate()` call. */\n variables: Signal<TVariables | undefined>\n /** Current {@link MutationStatus}. */\n status: Signal<MutationStatus>\n /** Whether the mutation has not been run yet. */\n isIdle: Signal<boolean>\n /** Whether the mutation is currently running. */\n isPending: Signal<boolean>\n /** Whether the last run succeeded. */\n isSuccess: Signal<boolean>\n /** Whether the last run failed. */\n isError: Signal<boolean>\n /** Consecutive failures in the current run. */\n failureCount: Signal<number>\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: Signal<TError | null>\n}\n\n/** @internal */\nexport function getInitialState<\n TData,\n TError,\n TVariables,\n TContext,\n>(): MutationState<TData, TError, TVariables, TContext> {\n return {\n status: 'idle',\n data: undefined,\n error: null,\n variables: undefined,\n context: undefined,\n failureCount: 0,\n failureReason: null,\n submittedAt: 0,\n }\n}\n\n/** @internal */\nexport class Mutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> {\n readonly #state =\n signal<MutationState<TData, TError, TVariables, TContext>>(\n getInitialState(),\n )\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n #observers = 0\n readonly #options: MutationOptions<TData, TError, TVariables, TContext>\n readonly #cache: MutationCache\n\n constructor(\n readonly mutationId: number,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n cache: MutationCache,\n ) {\n this.#options = options\n this.#cache = cache\n }\n\n get observerCount(): number {\n return this.#observers\n }\n\n addObserver(): void {\n this.#observers++\n }\n\n /**\n * Unlike a query, losing its last observer does not cancel a mutation: the\n * write has most likely reached the server already, so it must be allowed to\n * land and run its hooks. It is only dropped from the cache once it has both\n * settled and been abandoned — whichever of the two happens last.\n */\n removeObserver(): void {\n if (this.#observers === 0) return\n\n this.#observers--\n\n this.#disposeIfDone()\n }\n\n /** Runs the mutation once. `variables` are passed straight to `mutationFn`. */\n execute(variables: TVariables): void {\n const context = this.#options.onMutate?.(variables)\n // Mutations default to no retry (not idempotent — a retried POST could\n // create a duplicate); opt in explicitly via options.retry.\n const retry = this.#options.retry ?? 0\n const retryDelay = this.#options.retryDelay ?? defaultRetryDelay\n\n this.#state.set({\n status: 'pending',\n data: undefined,\n error: null,\n variables,\n context,\n failureCount: 0,\n failureReason: null,\n submittedAt: Date.now(),\n })\n\n // defer + from: normalize Observable/Promise and re-invoke mutationFn on\n // each retry (a Promise is one-shot, so retry must produce a fresh one).\n this.#subscription = defer(() => from(this.#options.mutationFn(variables)))\n .pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () =>\n new Error('Mutation function completed without emitting a value'),\n ),\n )\n .subscribe({\n // `finally`: a hook that throws must not leave the mutation stranded in\n // the cache (where injectIsMutating would keep counting it forever).\n next: (data) => {\n this.#state.update((state) => ({ ...state, status: 'success', data }))\n\n try {\n this.#options.onSuccess?.(data, variables, context)\n this.#options.onSettled?.(data, null, variables, context)\n } finally {\n this.#disposeIfDone()\n }\n },\n error: (error: TError) => {\n this.#state.update((state) => ({ ...state, status: 'error', error }))\n\n try {\n this.#options.onError?.(error, variables, context)\n this.#options.onSettled?.(undefined, error, variables, context)\n } finally {\n this.#disposeIfDone()\n }\n },\n })\n }\n\n cancel(): void {\n this.#subscription?.unsubscribe()\n this.#subscription = null\n }\n\n /**\n * A run nobody observes any more, and which is no longer in flight, has\n * nothing left to report — drop it. Called from both ends, since the two\n * conditions can be met in either order: a superseded run may settle later,\n * and a settled run may be abandoned later.\n */\n #disposeIfDone(): void {\n if (this.#observers > 0) return\n if (this.state().status === 'pending') return\n\n this.#cache.remove(this)\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport {\n type MutationFilters,\n type MutationOptions,\n Mutation,\n} from './mutation'\n\n/** @internal */\n@Injectable()\nexport class MutationCache extends Cache<\n Mutation<unknown, unknown, unknown, unknown>\n> {\n #lastId = 0\n\n build<TData, TError, TVariables, TContext>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation(++this.#lastId, options, this)\n\n this.addEntry(\n String(mutation.mutationId),\n mutation as Mutation<unknown, unknown, unknown, unknown>,\n )\n\n return mutation\n }\n\n findAll(\n filters: MutationFilters = {},\n ): Array<Mutation<unknown, unknown, unknown, unknown>> {\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!filters.status) return all\n\n return all.filter((mutation) => mutation.state().status === filters.status)\n }\n\n remove<TData, TError, TVariables, TContext>(\n mutation: Mutation<TData, TError, TVariables, TContext>,\n ): void {\n this.removeEntry(String(mutation.mutationId))\n }\n\n override clear(): void {\n this.getAll().forEach((mutation) => mutation.cancel())\n super.clear()\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport type { RetryDelayValue, RetryValue } from './types'\n\n/** @internal */\nexport interface QueryClientConfig {\n defaultOptions?: {\n queries?: {\n staleTime?: number\n gcTime?: number\n retry?: RetryValue<unknown>\n retryDelay?: RetryDelayValue<unknown>\n }\n }\n}\n\n/** @internal */\nexport const QUERY_CLIENT_CONFIG = new InjectionToken<QueryClientConfig>(\n 'QUERY_CLIENT_CONFIG',\n)\n","import { inject, Injectable } from '@angular/core'\nimport type { Observable } from 'rxjs'\n\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport { defaultRetryDelay } from './retryer'\nimport { functionalUpdate } from './utils'\nimport type {\n DefaultedQueryOptions,\n QueryFilters,\n QueryKey,\n QueryOptions,\n RetryDelayValue,\n RetryValue,\n Updater,\n} from './types'\nimport { QUERY_CLIENT_CONFIG } from './injection-tokens'\n\n/**\n * Central registry and cache for queries and mutations.\n *\n * Provided by {@link provideQueryClient} and retrieved with\n * {@link injectQueryClient}. Offers imperative cache access — reading and\n * writing data, and invalidating, cancelling, or removing queries — that\n * complements the reactive {@link injectQuery} / {@link injectMutation} APIs.\n */\n@Injectable()\nexport class QueryClient {\n readonly #cache = inject(QueryCache)\n readonly #mutationCache = inject(MutationCache)\n readonly #config = inject(QUERY_CLIENT_CONFIG, { optional: true }) ?? {}\n\n /** Returns the underlying query cache. Advanced/internal use. */\n getQueryCache(): QueryCache {\n return this.#cache\n }\n\n /** Returns the underlying mutation cache. Advanced/internal use. */\n getMutationCache(): MutationCache {\n return this.#mutationCache\n }\n\n /**\n * Merges per-query options with the configured defaults, filling in\n * `staleTime`, `gcTime`, `retry`, and `retryDelay`. Used internally by\n * {@link injectQuery}.\n */\n defaultQueryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n ): DefaultedQueryOptions<TData, TError> {\n const defaults = this.#config.defaultOptions?.queries\n\n return {\n ...options,\n staleTime: options.staleTime ?? defaults?.staleTime ?? 0,\n gcTime: options.gcTime ?? defaults?.gcTime,\n retry: options.retry ?? defaults?.retry ?? 3,\n retryDelay:\n options.retryDelay ?? defaults?.retryDelay ?? defaultRetryDelay,\n }\n }\n\n /**\n * Imperatively fetches and caches a query, unless fresh data already exists\n * (governed by `staleTime`). Prefer {@link injectQuery} in components; use\n * this for prefetching outside the reactive flow.\n *\n * @param key - The query key to fetch and cache under.\n * @param queryFn - Function returning the data as an `Observable` or `Promise`.\n * @param options - Fetch tuning (`staleTime`, `retry`, `retryDelay`,\n * `cancelRefetch`).\n */\n fetchQuery<TData>(\n key: QueryKey,\n queryFn: () => Observable<TData> | Promise<TData>,\n options: {\n staleTime?: number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retry?: RetryValue<any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retryDelay?: RetryDelayValue<any>\n cancelRefetch?: boolean\n } = {},\n ): void {\n const defaults = this.#config.defaultOptions?.queries\n const staleTime = options.staleTime ?? defaults?.staleTime ?? 0\n const retry = options.retry ?? defaults?.retry ?? 3\n const retryDelay =\n options.retryDelay ?? defaults?.retryDelay ?? defaultRetryDelay\n\n const query = this.#cache.getOrCreate<TData>(key)\n\n if (query.shouldFetch(staleTime)) {\n query.fetch(queryFn, retry, retryDelay, options.cancelRefetch)\n }\n }\n\n /**\n * Reads the current cached data for a query key, or `undefined` if the query\n * is not cached yet.\n *\n * @param key - The query key to read.\n * @returns The cached data, or `undefined`.\n */\n getQueryData<TData>(key: QueryKey): TData | undefined {\n return this.#cache.get<TData>(key)?.state().data\n }\n\n /**\n * Writes data into the cache for a query key, creating the entry if needed.\n * The `updater` may be a value or a function of the previous data; returning\n * `undefined` from the function is a no-op. Useful for optimistic updates.\n *\n * @param key - The query key to write.\n * @param updater - The new data, or a function `(prev) => next`.\n *\n * @example\n * ```ts\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * ```\n */\n setQueryData<TData>(\n key: QueryKey,\n updater: Updater<TData | undefined, TData>,\n ): void {\n const query = this.#cache.getOrCreate<TData>(key)\n const data = functionalUpdate(updater, query.state().data)\n\n // Matches TanStack: an updater returning undefined is a no-op.\n if (data === undefined) return\n\n query.setData(data)\n }\n\n /**\n * Marks matching queries as stale and triggers a refetch for those that are\n * actively observed. Commonly called after a mutation succeeds.\n *\n * @param filters - Which queries to invalidate; omit to invalidate all.\n *\n * @example\n * ```ts\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\n invalidateQueries(filters?: QueryFilters): void {\n this.#cache.findAll(filters).forEach((query) => query.invalidate())\n }\n\n /**\n * Cancels any in-flight fetches for matching queries.\n *\n * @param filters - Which queries to cancel; omit to cancel all.\n */\n cancelQueries(filters?: QueryFilters): void {\n this.#cache.findAll(filters).forEach((query) => query.cancel())\n }\n\n /**\n * Removes matching queries from the cache entirely, discarding their data.\n *\n * @param filters - Which queries to remove; omit to remove all.\n */\n removeQueries(filters?: QueryFilters): void {\n this.#cache.findAll(filters).forEach((query) => {\n query.destroy()\n this.#cache.remove(query)\n })\n }\n\n /**\n * Returns the number of matching queries currently fetching. For a reactive\n * count, prefer {@link injectIsFetching}.\n *\n * @param filters - Which queries to count; omit to count all.\n */\n isFetching(filters?: QueryFilters): number {\n return this.#cache\n .findAll(filters)\n .filter((query) => query.state().isFetching).length\n }\n\n /**\n * Returns the number of mutations currently pending. For a reactive count,\n * prefer {@link injectIsMutating}.\n */\n isMutating(): number {\n return this.#mutationCache.findAll({ status: 'pending' }).length\n }\n}\n","import type { Provider } from '@angular/core'\n\n/**\n * Discriminator identifying each kind of {@link QueryClientFeature}.\n *\n * @internal\n */\nexport enum QueryClientFeatureKind {\n DefaultOptions,\n}\n\n/**\n * An opaque feature passed to {@link provideQueryClient}. Create one with a\n * `with*` helper such as {@link withDefaultOptions} rather than constructing it\n * directly; the `ɵ`-prefixed members are internal.\n */\nexport interface QueryClientFeature<\n K extends QueryClientFeatureKind = QueryClientFeatureKind,\n> {\n ɵkind: K\n ɵproviders: Provider[]\n}\n\n/** @internal */\nexport function queryClientFeature<K extends QueryClientFeatureKind>(\n kind: K,\n providers: Provider[],\n): QueryClientFeature<K> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n","import {\n type EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n} from '../features/feature'\n\n/**\n * Registers the {@link QueryClient} and its caches for the application.\n *\n * Call once at the app root (in `ApplicationConfig.providers` or a root\n * `bootstrapApplication`). Pass features such as {@link withDefaultOptions} to\n * configure defaults. Registering the same feature twice throws.\n *\n * @param features - Optional {@link QueryClientFeature}s (e.g.\n * {@link withDefaultOptions}).\n * @returns Environment providers to add to the app's provider list.\n *\n * @example\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideHttpClient(),\n * provideQueryClient(\n * withDefaultOptions({ queries: { staleTime: 30_000 } }),\n * ),\n * ],\n * }\n * ```\n */\nexport function provideQueryClient(\n ...features: QueryClientFeature[]\n): EnvironmentProviders {\n const seenKinds = new Set<QueryClientFeatureKind>()\n\n for (const feature of features) {\n if (seenKinds.has(feature.ɵkind)) {\n throw new Error(\n `provideQueryClient: feature \"${QueryClientFeatureKind[feature.ɵkind]}\" is registered more than once`,\n )\n }\n seenKinds.add(feature.ɵkind)\n }\n\n return makeEnvironmentProviders([\n QueryCache,\n MutationCache,\n QueryClient,\n ...features.flatMap((feature) => feature.ɵproviders),\n ])\n}\n","import { type Injector, assertInInjectionContext, inject } from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns the application's {@link QueryClient} for imperative cache access.\n *\n * Use it to read or write cached data (`getQueryData`, `setQueryData`) and to\n * invalidate, cancel, or remove queries — typically from mutation hooks or\n * event handlers. Requires {@link provideQueryClient} to be registered.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns The shared {@link QueryClient} instance.\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\nexport function injectQueryClient(options?: {\n injector?: Injector\n}): QueryClient {\n if (!options?.injector) assertInInjectionContext(injectQueryClient)\n\n return options?.injector?.get(QueryClient) ?? inject(QueryClient)\n}\n","import {\n assertInInjectionContext,\n computed,\n effect,\n inject,\n Injector,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport type { Query } from './query'\nimport type {\n PlaceholderDataFunction,\n QueryOptions,\n QueryResult,\n QueryStatus,\n} from './types'\n\n/**\n * Runs a cached, reactive query and exposes its state as signals.\n *\n * The query is keyed by `queryKey`: calls with the same key share a single\n * cache entry and in-flight request (deduplication). `optionsFn` is read in a\n * reactive context, so when a value it depends on changes (e.g. a route or\n * input signal in the key), the query automatically switches to the new key\n * and fetches. The query is bound to the current injection context and cleans\n * up its cache observer when that context is destroyed.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param optionsFn - Factory returning the {@link QueryOptions}. Re-evaluated\n * reactively, so reading signals inside it makes the query re-run on change.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link QueryResult} of signals (`data`, `status`, `error`,\n * `isLoading`, `isPending`, …) plus a `refetch()` that forces a fresh fetch.\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * @if (todo.isPending()) { <p>Loading…</p> }\n * @if (todo.data(); as data) { <p>{{ data.title }}</p> }\n * `,\n * })\n * class TodoComponent {\n * readonly id = input.required<number>()\n * private readonly http = inject(HttpClient)\n *\n * // Refetches automatically whenever `id()` changes.\n * readonly todo = injectQuery(() => ({\n * queryKey: ['todo', this.id()],\n * queryFn: () => this.http.get<Todo>(`/api/todos/${this.id()}`),\n * }))\n * }\n * ```\n */\nexport function injectQuery<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n options?: { injector?: Injector },\n): QueryResult<TData, TError> {\n if (!options?.injector) assertInInjectionContext(injectQuery)\n\n const injector = options?.injector ?? inject(Injector)\n\n return runInInjectionContext(injector, () => {\n const client = inject(QueryClient)\n const cache = client.getQueryCache()\n\n // Single source of truth for defaulted options; resolves config defaults\n // (staleTime, gcTime) once instead of scattering the logic across effects.\n const defaultedOptions = computed(() =>\n client.defaultQueryOptions(optionsFn()),\n )\n\n // Seed a fresh query (status 'pending', no data yet) with initialData so\n // it renders immediately as 'success'. Without an explicit\n // initialDataUpdatedAt the seed is treated as fetched right now, so\n // staleTime applies to it as it would to any other data (a staleTime of 0\n // still means \"stale immediately\" → background refetch).\n const applyInitialData = (q: Query<TData, TError>): void => {\n const { initialData, initialDataUpdatedAt } = untracked(defaultedOptions)\n\n if (initialData === undefined || q.state().status !== 'pending') return\n\n const data =\n typeof initialData === 'function'\n ? (initialData as () => TData)()\n : initialData\n const updatedAt =\n typeof initialDataUpdatedAt === 'function'\n ? initialDataUpdatedAt()\n : (initialDataUpdatedAt ?? Date.now())\n\n q.setData(data, updatedAt)\n }\n\n // getOrCreate mutates the cache (a side effect), so it must not run inside\n // a computed. Resolve the query in a signal: seed it synchronously and\n // update it from an effect whenever the key changes.\n const seed = cache.getOrCreate<TData, TError>(\n untracked(defaultedOptions).queryKey,\n )\n\n applyInitialData(seed)\n\n const query = signal(seed)\n\n // Data of the last query that had any, fed to the placeholderData function\n // on key change (mirrors TanStack's lastQueryWithDefinedData). Captured\n // synchronously before the switch so it can't miss a just-resolved value.\n const lastData = signal<TData | undefined>(undefined)\n\n effect(() => {\n const key = defaultedOptions().queryKey\n const q = untracked(() => cache.getOrCreate<TData, TError>(key))\n\n untracked(() => {\n const prev = query()\n\n if (prev !== q && prev.state().data !== undefined) {\n lastData.set(prev.state().data)\n }\n\n applyInitialData(q)\n })\n query.set(q)\n })\n\n // Memoized: only emits when the flag itself flips, so ordinary data\n // updates don't wake the fetch effect (no refetch loop).\n const isInvalidated = computed(() => query().state().isInvalidated)\n\n effect((cleanup) => {\n const q = query()\n const { gcTime } = untracked(defaultedOptions)\n\n if (gcTime !== undefined) {\n q.setGcTime(gcTime)\n }\n\n q.addObserver()\n cleanup(() => q.removeObserver())\n })\n\n effect(() => {\n const { queryKey, queryFn, staleTime, retry, retryDelay, enabled } =\n defaultedOptions()\n\n // Track invalidation so invalidateQueries() re-triggers a refetch.\n // When invalidated, cancel any in-flight fetch and start a fresh one\n // (otherwise the stale in-flight result would clear isInvalidated).\n const invalidated = isInvalidated()\n\n if (enabled === false) return\n\n untracked(() =>\n client.fetchQuery(queryKey, queryFn, {\n staleTime,\n retry,\n retryDelay,\n cancelRefetch: invalidated,\n }),\n )\n })\n\n // Polling: refetch on an interval, independent of staleTime (staleTime: 0\n // forces the fetch). The function form is reactive — reading state() makes\n // the effect re-run when data changes, so returning false stops polling.\n effect((onCleanup) => {\n const { queryKey, queryFn, retry, retryDelay, refetchInterval, enabled } =\n defaultedOptions()\n\n if (enabled === false) return\n\n const interval =\n typeof refetchInterval === 'function'\n ? refetchInterval({ state: query().state() })\n : refetchInterval\n\n if (!interval) return\n\n const id = setInterval(() => {\n client.fetchQuery(queryKey, queryFn, {\n staleTime: 0,\n retry,\n retryDelay,\n })\n }, interval)\n\n onCleanup(() => clearInterval(id))\n })\n\n // Placeholder layer: while the query is pending with no data, present\n // placeholderData as already-successful data. Purely presentational — the\n // cache entry stays 'pending' and the fetch proceeds, so isFetching keeps\n // reporting the real request and the placeholder is dropped on resolve.\n const resolved = computed<{\n data: TData | undefined\n status: QueryStatus\n isPlaceholderData: boolean\n }>(() => {\n const state = query().state()\n const { placeholderData } = defaultedOptions()\n\n if (\n placeholderData !== undefined &&\n state.data === undefined &&\n state.status === 'pending'\n ) {\n const data =\n typeof placeholderData === 'function'\n ? (placeholderData as PlaceholderDataFunction<TData>)(lastData())\n : placeholderData\n\n if (data !== undefined) {\n return { data, status: 'success', isPlaceholderData: true }\n }\n }\n\n return { data: state.data, status: state.status, isPlaceholderData: false }\n })\n\n return {\n data: computed(() => resolved().data),\n status: computed(() => resolved().status),\n error: computed(() => query().state().error as TError | null),\n isFetching: computed(() => query().state().isFetching),\n // First fetch in-flight: fetching with no resolved data yet. An active\n // placeholder counts as data — the UI shows it, not a loading state.\n isLoading: computed(\n () => query().state().isFetching && resolved().status === 'pending',\n ),\n isPending: computed(() => resolved().status === 'pending'),\n isSuccess: computed(() => resolved().status === 'success'),\n isError: computed(() => resolved().status === 'error'),\n isPlaceholderData: computed(() => resolved().isPlaceholderData),\n failureCount: computed(() => query().state().failureCount),\n failureReason: computed(\n () => query().state().failureReason as TError | null,\n ),\n // Force a fresh fetch regardless of staleTime, cancelling any in-flight\n // request (explicit user intent — get current data).\n refetch: () => {\n const { queryKey, queryFn, retry, retryDelay } =\n untracked(defaultedOptions)\n\n client.fetchQuery(queryKey, queryFn, {\n staleTime: 0,\n retry,\n retryDelay,\n cancelRefetch: true,\n })\n },\n }\n })\n}\n","import {\n assertInInjectionContext,\n computed,\n DestroyRef,\n inject,\n Injector,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport {\n type Mutation,\n type MutationOptions,\n type MutationResult,\n getInitialState,\n} from './mutation'\n\n/**\n * Creates a mutation for imperative writes (create/update/delete) and exposes\n * its state as signals.\n *\n * Unlike queries, a mutation does not run on its own — call `mutate(variables)`\n * to trigger `mutationFn`. The `onMutate` / `onSuccess` / `onError` /\n * `onSettled` lifecycle hooks make optimistic updates and cache invalidation\n * straightforward. Mutations do not retry by default (a retried write is not\n * idempotent); opt in via `options.retry`. Bound to the current injection\n * context and cancelled when that context is destroyed.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param optionsFn - Factory returning the {@link MutationOptions}.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link MutationResult}: `mutate()`, `reset()`, and state signals\n * (`status`, `data`, `error`, `isPending`, …).\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n *\n * const addTodo = injectMutation(() => ({\n * mutationFn: (title: string) => http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => client.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * // <button (click)=\"addTodo.mutate('Buy milk')\" [disabled]=\"addTodo.isPending()\">Add</button>\n * ```\n */\nexport function injectMutation<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n optionsFn: () => MutationOptions<TData, TError, TVariables, TContext>,\n options?: { injector?: Injector },\n): MutationResult<TData, TError, TVariables> {\n if (!options?.injector) assertInInjectionContext(injectMutation)\n\n const injector = options?.injector ?? inject(Injector)\n\n return runInInjectionContext(injector, () => {\n const cache = inject(QueryClient).getMutationCache()\n\n // Every mutate() builds its own Mutation. Sharing one across calls meant a\n // second call overwrote the first's subscription (orphaning the request)\n // and its state (so the slower run, not the latest one, decided the result).\n const current = signal<Mutation<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n // Detaching is all we do on destroy. A run still in flight keeps going —\n // the write has most likely reached the server already, so cancelling it\n // would only skip onSuccess and leave the cache out of sync. It drops\n // itself from the cache once it settles with nobody watching.\n inject(DestroyRef).onDestroy(() => untracked(current)?.removeObserver())\n\n const state = computed(\n () =>\n current()?.state() ??\n getInitialState<TData, TError, TVariables, TContext>(),\n )\n\n return {\n mutate: (variables) => {\n // Stop observing the previous run. It isn't cancelled — if it's still\n // in flight it finishes and fires its hooks; it just no longer feeds\n // the signals below.\n untracked(current)?.removeObserver()\n\n // Options are read per call, so a signal used in them stays live.\n const run = cache.build(optionsFn())\n\n run.addObserver()\n current.set(run)\n run.execute(variables)\n },\n reset: () => {\n // \"Forget the result\", not \"stop the request\". A run still in flight\n // keeps going and fires its hooks, so the cache stays in step with the\n // server — cancelling could not un-send the write anyway, it could only\n // hide the fact that it happened.\n untracked(current)?.removeObserver()\n\n current.set(null)\n },\n data: computed(() => state().data),\n error: computed(() => state().error as TError | null),\n variables: computed(() => state().variables),\n status: computed(() => state().status),\n isIdle: computed(() => state().status === 'idle'),\n isPending: computed(() => state().status === 'pending'),\n isSuccess: computed(() => state().status === 'success'),\n isError: computed(() => state().status === 'error'),\n failureCount: computed(() => state().failureCount),\n failureReason: computed(() => state().failureReason as TError | null),\n }\n })\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport type { QueryFilters } from './types'\n\n/**\n * Returns a signal with the number of queries currently fetching — useful for a\n * global loading indicator.\n *\n * Pass {@link QueryFilters} to count only matching queries; omit them to count\n * every fetching query in the cache.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param filters - Optional filters (e.g. `{ queryKey: ['todos'] }`) to narrow\n * the count.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of active fetches.\n *\n * @example\n * ```ts\n * readonly isFetching = injectIsFetching()\n * // <app-spinner *ngIf=\"isFetching() > 0\" />\n * ```\n */\nexport function injectIsFetching(\n filters?: QueryFilters,\n options?: { injector?: Injector },\n): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsFetching)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getQueryCache()\n\n return computed(\n () =>\n cache.findAll(filters).filter((query) => query.state().isFetching).length,\n )\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns a signal with the number of mutations currently pending — useful for\n * a global \"saving…\" indicator.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of in-flight mutations.\n *\n * @example\n * ```ts\n * readonly isMutating = injectIsMutating()\n * // <p *ngIf=\"isMutating() > 0\">Saving…</p>\n * ```\n */\nexport function injectIsMutating(options?: {\n injector?: Injector\n}): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsMutating)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getMutationCache()\n\n return computed(() => cache.findAll({ status: 'pending' }).length)\n}\n","import type { QueryOptions } from './types'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link QueryOptions}.\n *\n * Returns the options unchanged at runtime, but anchors type inference so the\n * same definition can be shared across {@link injectQuery},\n * {@link QueryClient.setQueryData}, and friends without re-declaring generics.\n * Keeping query definitions in a service (rather than inline) makes them easy\n * to reuse and unit-test.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param options - The {@link QueryOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * @Injectable({ providedIn: 'root' })\n * class TodoQueries {\n * private readonly http = inject(HttpClient)\n *\n * todos() {\n * return queryOptions({\n * queryKey: ['todos'],\n * queryFn: () => this.http.get<Todo[]>('/api/todos'),\n * })\n * }\n * }\n *\n * // const todos = injectQuery(() => inject(TodoQueries).todos())\n * ```\n */\nexport function queryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n): QueryOptions<TData, TError> {\n return options\n}\n","/**\n * Placeholder function that keeps the previous query's data visible while the\n * next one loads — pass as `placeholderData` to avoid flicker when the query\n * key changes (e.g. pagination, search).\n *\n * While the placeholder is shown, `status` reads `'success'` and\n * `isPlaceholderData()` is `true`; `isFetching()` stays `true` so the UI can\n * indicate the data is stale.\n *\n * @example\n * ```ts\n * readonly todos = injectQuery(() => ({\n * queryKey: ['todos', this.page()],\n * queryFn: () => this.http.get<Todo[]>(`/api/todos?page=${this.page()}`),\n * placeholderData: keepPreviousData,\n * }))\n * ```\n */\nexport function keepPreviousData<TData>(\n previousData: TData | undefined,\n): TData | undefined {\n return previousData\n}\n","import type { MutationOptions } from './mutation'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link MutationOptions}.\n *\n * Returns the options unchanged at runtime; its job is to anchor type inference\n * (notably linking `TContext` returned by `onMutate` to the later hooks) so a\n * mutation can be defined once in a service and passed to {@link injectMutation}.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param options - The {@link MutationOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * addTodo() {\n * return mutationOptions({\n * mutationFn: (title: string) => this.http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => this.client.invalidateQueries({ queryKey: ['todos'] }),\n * })\n * }\n * ```\n */\nexport function mutationOptions<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n): MutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n","import { QUERY_CLIENT_CONFIG } from '../core/injection-tokens'\nimport type { RetryDelayValue, RetryValue } from '../core/types'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n queryClientFeature,\n} from './feature'\n\n/** Default query options applied to every query unless overridden per-query. */\nexport interface DefaultQueryOptions {\n /** How long fetched data is considered fresh, in ms. Defaults to `0`. */\n staleTime?: number\n /** How long unused (unobserved) data is kept before garbage collection, in ms. */\n gcTime?: number\n /** Retry policy on failure: a boolean, a count, or a predicate. Defaults to `3`. */\n retry?: RetryValue<unknown>\n /** Delay between retries, in ms or a function of the attempt. */\n retryDelay?: RetryDelayValue<unknown>\n}\n\n/** Application-wide defaults configured via {@link withDefaultOptions}. */\nexport interface DefaultOptions {\n /** Defaults applied to all queries. */\n queries?: DefaultQueryOptions\n}\n\n/**\n * Feature for {@link provideQueryClient} that sets application-wide default\n * query options. Per-query options always take precedence over these defaults.\n *\n * @param options - The {@link DefaultOptions} to apply.\n * @returns A {@link QueryClientFeature} to pass to {@link provideQueryClient}.\n *\n * @example\n * ```ts\n * provideQueryClient(\n * withDefaultOptions({ queries: { staleTime: 60_000, retry: 1 } }),\n * )\n * ```\n */\nexport function withDefaultOptions(\n options: DefaultOptions,\n): QueryClientFeature<QueryClientFeatureKind.DefaultOptions> {\n return queryClientFeature(QueryClientFeatureKind.DefaultOptions, [\n { provide: QUERY_CLIENT_CONFIG, useValue: { defaultOptions: options } },\n ])\n}\n","/*\n * Public API Surface of ngx-query\n */\n\nexport * from './lib/core/query-client'\nexport * from './lib/core/provider'\nexport * from './lib/core/inject-query-client'\nexport * from './lib/core/types'\nexport * from './lib/core/inject-query'\nexport * from './lib/core/inject-mutation'\nexport * from './lib/core/inject-is-fetching'\nexport * from './lib/core/inject-is-mutating'\nexport * from './lib/core/query-options'\nexport * from './lib/core/keep-previous-data'\nexport * from './lib/core/mutation-options'\nexport type {\n MutationFilters,\n MutationOptions,\n MutationResult,\n MutationState,\n MutationStatus,\n} from './lib/core/mutation'\nexport { QueryClientFeatureKind } from './lib/features/feature'\nexport type { QueryClientFeature } from './lib/features/feature'\nexport { withDefaultOptions } from './lib/features/with-default-options'\nexport type {\n DefaultOptions,\n DefaultQueryOptions,\n} from './lib/features/with-default-options'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["retry","retryOperator"],"mappings":";;;;AAEA;MACsB,KAAK,CAAA;AAChB,IAAA,QAAQ,GAAG,MAAM,CAAW,EAAE,oDAAC;;;;AAKrB,IAAA,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;AAE9C,IAAA,WAAW,GAAG,IAAI,GAAG,EAAkB;IAEhD,MAAM,GAAA;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC9C;IAEA,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QACxB,IAAI,CAAC,KAAK,EAAE;IACd;IAEU,QAAQ,CAAC,GAAW,EAAE,KAAa,EAAA;QAC3C,IAAI,CAAC,W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,CAAC,cAAc,EAAE;QAC/D,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE;AACxE,KAAA,CAAC;AACJ;;AC9CA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-signal-query.mjs","sources":["../../../projects/ngx-signal-query/src/lib/core/cache.ts","../../../projects/ngx-signal-query/src/lib/core/utils.ts","../../../projects/ngx-signal-query/src/lib/core/retryer.ts","../../../projects/ngx-signal-query/src/lib/core/query.ts","../../../projects/ngx-signal-query/src/lib/core/query-cache.ts","../../../projects/ngx-signal-query/src/lib/core/mutation.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-cache.ts","../../../projects/ngx-signal-query/src/lib/core/injection-tokens.ts","../../../projects/ngx-signal-query/src/lib/core/query-client.ts","../../../projects/ngx-signal-query/src/lib/features/feature.ts","../../../projects/ngx-signal-query/src/lib/core/provider.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query-client.ts","../../../projects/ngx-signal-query/src/lib/core/query-observer.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query.ts","../../../projects/ngx-signal-query/src/lib/core/inject-queries.ts","../../../projects/ngx-signal-query/src/lib/core/inject-mutation.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-fetching.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-mutating.ts","../../../projects/ngx-signal-query/src/lib/core/query-options.ts","../../../projects/ngx-signal-query/src/lib/core/keep-previous-data.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-options.ts","../../../projects/ngx-signal-query/src/lib/features/with-default-options.ts","../../../projects/ngx-signal-query/src/public-api.ts","../../../projects/ngx-signal-query/src/ngx-signal-query.ts"],"sourcesContent":["import { signal } from '@angular/core'\n\n/** @internal */\nexport abstract class Cache<TEntry> {\n readonly #entries = signal<TEntry[]>([])\n\n // Reactive snapshot of all entries; updated on add/remove/clear so that\n // findAll() (and its computed consumers like isFetching) react to the\n // collection. Protected: only subclasses read it, never external code.\n protected readonly entries = this.#entries.asReadonly()\n\n readonly #entriesMap = new Map<string, TEntry>()\n\n getAll(): TEntry[] {\n return Array.from(this.#entriesMap.values())\n }\n\n clear(): void {\n this.#entriesMap.clear()\n this.#sync()\n }\n\n protected addEntry(key: string, entry: TEntry): TEntry {\n this.#entriesMap.set(key, entry)\n this.#sync()\n\n return entry\n }\n\n protected getEntry(key: string): TEntry | undefined {\n return this.#entriesMap.get(key)\n }\n\n protected removeEntry(key: string): boolean {\n const removed = this.#entriesMap.delete(key)\n\n if (removed) this.#sync()\n\n return removed\n }\n\n #sync(): void {\n this.#entries.set(Array.from(this.#entriesMap.values()))\n }\n}\n","import type { QueryKey, Updater } from './types'\n\n// Resolves an updater: calls it with the previous value if it's a function,\n// otherwise uses it as the value directly.\n/** @internal */\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (input: TInput) => TOutput)(input)\n : updater\n}\n\n// True when `filter` is a (deep) prefix of `key`, e.g. ['app'] matches\n// ['app', 1]. Used to invalidate/find groups of queries by partial key.\n/** @internal */\nexport function partialMatchKey(key: QueryKey, filter: QueryKey): boolean {\n return partialDeepEqual(key, filter)\n}\n\nfunction partialDeepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (typeof a !== typeof b) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return Object.keys(b).every((key) =>\n partialDeepEqual(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n ),\n )\n }\n\n return false\n}\n\n/** @internal */\nexport function hashKey(key: QueryKey): string {\n return JSON.stringify(key, (_, value) =>\n isPlainObject(value)\n ? Object.keys(value)\n .sort()\n .reduce<Record<string, unknown>>((result, k) => {\n result[k] = value[k]\n\n return result\n }, {})\n : value,\n )\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n","import type { RetryDelayValue, RetryValue } from './types'\n\n// Exponential backoff capped at 30s, matching TanStack's default.\n/** @internal */\nexport function defaultRetryDelay(failureCount: number): number {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\n/** @internal */\nexport function shouldRetry<TError>(\n retry: RetryValue<TError>,\n failureCount: number,\n error: TError,\n): boolean {\n if (typeof retry === 'function') return retry(failureCount, error)\n if (typeof retry === 'number') return failureCount < retry\n\n return retry\n}\n\n/** @internal */\nexport function resolveRetryDelay<TError>(\n retryDelay: RetryDelayValue<TError>,\n failureCount: number,\n error: TError,\n): number {\n return typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n}\n","import { signal } from '@angular/core'\nimport {\n defer,\n from,\n retry as retryOperator,\n take,\n throwIfEmpty,\n timer,\n type Observable,\n type Subscription,\n} from 'rxjs'\n\nimport type { QueryCache } from './query-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport type { QueryKey, QueryState, RetryDelayValue, RetryValue } from './types'\n\nconst DEFAULT_GC_TIME = 5 * 60 * 1000\n\n/** @internal */\nexport class Query<TData, TError = Error> {\n readonly #state = signal<QueryState<TData, TError>>({\n data: undefined,\n status: 'pending',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: 0,\n })\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n #observers = 0\n #gcTime = DEFAULT_GC_TIME\n #gcTimer: ReturnType<typeof setTimeout> | null = null\n readonly #cache: QueryCache\n\n constructor(\n readonly key: QueryKey,\n readonly queryHash: string,\n cache: QueryCache,\n ) {\n this.#cache = cache\n }\n\n get observerCount(): number {\n return this.#observers\n }\n\n setGcTime(ms: number): void {\n this.#gcTime = ms\n }\n\n addObserver(): void {\n this.#observers++\n this.#clearGcTimer()\n }\n\n removeObserver(): void {\n if (this.#observers === 0) return\n\n this.#observers--\n\n // No observers left: cancel any in-flight fetch (nobody is waiting for it)\n // and schedule gc to dispose the query if no observer returns.\n if (this.#observers === 0) {\n this.cancel()\n this.#scheduleGc()\n }\n }\n\n fetch(\n queryFn: () => Observable<TData> | Promise<TData>,\n retry: RetryValue<TError> = 0,\n retryDelay: RetryDelayValue<TError> = defaultRetryDelay,\n cancelRefetch = false,\n ): void {\n if (this.#subscription && !this.#subscription.closed) {\n // Already in-flight: dedupe unless the caller explicitly wants a fresh\n // fetch (e.g. invalidate/refetch) — then cancel the old one and restart.\n if (!cancelRefetch) return\n this.cancel()\n }\n\n this.#state.update((state) => ({\n ...state,\n isFetching: true,\n failureCount: 0,\n failureReason: null,\n }))\n\n // defer + from: normalize Observable/Promise and re-invoke queryFn on each\n // retry (a Promise is one-shot, so retry must produce a fresh one).\n this.#subscription = defer(() => from(queryFn()))\n .pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n // retryCount (1-based) is the number of failures so far; the retry\n // predicate/delay take a 0-based attempt index (0 = first retry).\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () => new Error('Query function completed without emitting a value'),\n ),\n )\n .subscribe({\n next: (data) =>\n this.#state.set({\n data,\n status: 'success',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: Date.now(),\n }),\n error: (err) =>\n this.#state.update((state) => ({\n ...state,\n status: 'error',\n error: err,\n isFetching: false,\n })),\n })\n }\n\n setData(data: TData, updatedAt: number = Date.now()): void {\n this.#state.update((state) => ({\n ...state,\n data,\n status: 'success',\n error: null,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt,\n }))\n\n // Keep an orphaned query (no observers) alive for another gcTime so a\n // setQueryData write isn't collected before anyone subscribes.\n if (this.#observers === 0) this.#scheduleGc()\n }\n\n invalidate(): void {\n this.#state.update((state) => ({ ...state, isInvalidated: true }))\n }\n\n shouldFetch(staleTime: number): boolean {\n const state = this.state()\n\n return (\n state.status !== 'success' ||\n state.isInvalidated ||\n this.#isStale(staleTime)\n )\n }\n\n cancel(): void {\n this.#subscription?.unsubscribe()\n this.#subscription = null\n\n // The fetch is no longer running; clear the in-flight flag so isFetching\n // doesn't stay stuck true after a cancellation.\n if (this.state().isFetching) {\n this.#state.update((state) => ({ ...state, isFetching: false }))\n }\n }\n\n destroy(): void {\n this.cancel()\n this.#clearGcTimer()\n }\n\n // Inclusive: data fetched exactly `staleTime` ago is already stale. This\n // matters for seeded data (initialData is stamped with the current time), so\n // the default staleTime of 0 still means \"stale at once\" → background\n // refetch, rather than depending on whether a millisecond happened to pass.\n #isStale(staleTime: number): boolean {\n return Date.now() - this.state().updatedAt >= staleTime\n }\n\n #scheduleGc(): void {\n this.#clearGcTimer()\n\n this.#gcTimer = setTimeout(() => {\n this.#gcTimer = null\n this.#cache.remove(this)\n }, this.#gcTime)\n }\n\n #clearGcTimer(): void {\n if (this.#gcTimer === null) return\n\n clearTimeout(this.#gcTimer)\n this.#gcTimer = null\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport { hashKey, partialMatchKey } from './utils'\nimport { Query } from './query'\nimport type { QueryFilters, QueryKey } from './types'\n\n/** @internal */\n@Injectable()\nexport class QueryCache extends Cache<Query<unknown, unknown>> {\n getOrCreate<TData, TError = Error>(key: QueryKey): Query<TData, TError> {\n const queryHash = hashKey(key)\n const exist = this.getEntry(queryHash)\n\n if (exist) return exist as Query<TData, TError>\n\n return this.addEntry(queryHash, new Query(key, queryHash, this)) as Query<\n TData,\n TError\n >\n }\n\n get<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined {\n return this.getEntry(hashKey(key)) as Query<TData, TError> | undefined\n }\n\n findAll(filters: QueryFilters = {}): Array<Query<unknown, unknown>> {\n const { queryKey, exact } = filters\n\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!queryKey) return all\n\n if (exact) {\n const queryHash = hashKey(queryKey)\n\n return all.filter((query) => query.queryHash === queryHash)\n }\n\n return all.filter((query) => partialMatchKey(query.key, queryKey))\n }\n\n remove(query: Query<unknown, unknown>): void {\n // Guard on identity, not just the hash: a stale instance (already removed\n // and recreated under the same key) must not evict the current query.\n if (this.getEntry(query.queryHash) === query) {\n this.removeEntry(query.queryHash)\n }\n }\n\n override clear(): void {\n this.getAll().forEach((query) => query.destroy())\n super.clear()\n }\n}\n","import { type Signal, signal } from '@angular/core'\nimport {\n defer,\n from,\n retry as retryOperator,\n take,\n throwIfEmpty,\n timer,\n type Observable,\n type Subscription,\n} from 'rxjs'\n\nimport type { MutationCache } from './mutation-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport type { RetryDelayValue, RetryValue } from './types'\n\n/** Lifecycle status of a mutation: not yet run, running, succeeded, or failed. */\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\n/** Selects which mutations an operation applies to (e.g. `injectIsMutating`). */\nexport type MutationFilters = {\n /** Match mutations in this status. */\n status?: MutationStatus\n}\n\n/** Full state snapshot of a mutation (the reactive source behind {@link MutationResult}). */\nexport type MutationState<TData, TError, TVariables, TContext> = {\n /** Current {@link MutationStatus}. */\n status: MutationStatus\n /** Data resolved by the last successful run, or `undefined`. */\n data: TData | undefined\n /** Error of the last failed run, or `null`. */\n error: TError | null\n /** Variables passed to the most recent `mutate()` call. */\n variables: TVariables | undefined\n /** Value returned by `onMutate` for the current run. */\n context: TContext | undefined\n /** Number of failed attempts in the current run. */\n failureCount: number\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: TError | null\n /** Timestamp (ms) when the current run was submitted; `0` if never. */\n submittedAt: number\n}\n\n/**\n * Configuration for a mutation, passed to {@link injectMutation} /\n * {@link mutationOptions}. The hooks fire in order: `onMutate` →\n * (`onSuccess` | `onError`) → `onSettled`. The value returned by `onMutate`\n * is passed as `context` to the later hooks — handy for rollback.\n */\nexport type MutationOptions<TData, TError, TVariables, TContext> = {\n /** Performs the write; receives `mutate()`'s argument. Returns `Observable`/`Promise`. */\n mutationFn: (variables: TVariables) => Observable<TData> | Promise<TData>\n /** Retry policy. Defaults to no retry (writes are not idempotent). */\n retry?: RetryValue<TError>\n /** Delay between retries. See {@link RetryDelayValue}. */\n retryDelay?: RetryDelayValue<TError>\n /** Runs before `mutationFn`; its return value becomes `context` (e.g. for optimistic rollback). */\n onMutate?: (variables: TVariables) => TContext | undefined\n /** Runs after a successful `mutationFn`. */\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n /** Runs after a failed `mutationFn`. */\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n /** Runs after success or error — for cleanup that should happen either way. */\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n}\n\n/** Reactive result returned by {@link injectMutation}; state fields are signals. */\nexport type MutationResult<TData, TError, TVariables> = {\n /** Triggers the mutation with the given variables. */\n mutate: (variables: TVariables) => void\n /** Resets state back to `idle`, cancelling any in-flight run. */\n reset: () => void\n /** Data from the last successful run, or `undefined`. */\n data: Signal<TData | undefined>\n /** Error from the last failed run, or `null`. */\n error: Signal<TError | null>\n /** Variables from the most recent `mutate()` call. */\n variables: Signal<TVariables | undefined>\n /** Current {@link MutationStatus}. */\n status: Signal<MutationStatus>\n /** Whether the mutation has not been run yet. */\n isIdle: Signal<boolean>\n /** Whether the mutation is currently running. */\n isPending: Signal<boolean>\n /** Whether the last run succeeded. */\n isSuccess: Signal<boolean>\n /** Whether the last run failed. */\n isError: Signal<boolean>\n /** Consecutive failures in the current run. */\n failureCount: Signal<number>\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: Signal<TError | null>\n}\n\n/** @internal */\nexport function getInitialState<\n TData,\n TError,\n TVariables,\n TContext,\n>(): MutationState<TData, TError, TVariables, TContext> {\n return {\n status: 'idle',\n data: undefined,\n error: null,\n variables: undefined,\n context: undefined,\n failureCount: 0,\n failureReason: null,\n submittedAt: 0,\n }\n}\n\n/** @internal */\nexport class Mutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> {\n readonly #state =\n signal<MutationState<TData, TError, TVariables, TContext>>(\n getInitialState(),\n )\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n #observers = 0\n readonly #options: MutationOptions<TData, TError, TVariables, TContext>\n readonly #cache: MutationCache\n\n constructor(\n readonly mutationId: number,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n cache: MutationCache,\n ) {\n this.#options = options\n this.#cache = cache\n }\n\n get observerCount(): number {\n return this.#observers\n }\n\n addObserver(): void {\n this.#observers++\n }\n\n /**\n * Unlike a query, losing its last observer does not cancel a mutation: the\n * write has most likely reached the server already, so it must be allowed to\n * land and run its hooks. It is only dropped from the cache once it has both\n * settled and been abandoned — whichever of the two happens last.\n */\n removeObserver(): void {\n if (this.#observers === 0) return\n\n this.#observers--\n\n this.#disposeIfDone()\n }\n\n /** Runs the mutation once. `variables` are passed straight to `mutationFn`. */\n execute(variables: TVariables): void {\n const context = this.#options.onMutate?.(variables)\n // Mutations default to no retry (not idempotent — a retried POST could\n // create a duplicate); opt in explicitly via options.retry.\n const retry = this.#options.retry ?? 0\n const retryDelay = this.#options.retryDelay ?? defaultRetryDelay\n\n this.#state.set({\n status: 'pending',\n data: undefined,\n error: null,\n variables,\n context,\n failureCount: 0,\n failureReason: null,\n submittedAt: Date.now(),\n })\n\n // defer + from: normalize Observable/Promise and re-invoke mutationFn on\n // each retry (a Promise is one-shot, so retry must produce a fresh one).\n this.#subscription = defer(() => from(this.#options.mutationFn(variables)))\n .pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () =>\n new Error('Mutation function completed without emitting a value'),\n ),\n )\n .subscribe({\n // `finally`: a hook that throws must not leave the mutation stranded in\n // the cache (where injectIsMutating would keep counting it forever).\n next: (data) => {\n this.#state.update((state) => ({ ...state, status: 'success', data }))\n\n try {\n this.#options.onSuccess?.(data, variables, context)\n this.#options.onSettled?.(data, null, variables, context)\n } finally {\n this.#disposeIfDone()\n }\n },\n error: (error: TError) => {\n this.#state.update((state) => ({ ...state, status: 'error', error }))\n\n try {\n this.#options.onError?.(error, variables, context)\n this.#options.onSettled?.(undefined, error, variables, context)\n } finally {\n this.#disposeIfDone()\n }\n },\n })\n }\n\n cancel(): void {\n this.#subscription?.unsubscribe()\n this.#subscription = null\n }\n\n /**\n * A run nobody observes any more, and which is no longer in flight, has\n * nothing left to report — drop it. Called from both ends, since the two\n * conditions can be met in either order: a superseded run may settle later,\n * and a settled run may be abandoned later.\n */\n #disposeIfDone(): void {\n if (this.#observers > 0) return\n if (this.state().status === 'pending') return\n\n this.#cache.remove(this)\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport {\n type MutationFilters,\n type MutationOptions,\n Mutation,\n} from './mutation'\n\n/** @internal */\n@Injectable()\nexport class MutationCache extends Cache<\n Mutation<unknown, unknown, unknown, unknown>\n> {\n #lastId = 0\n\n build<TData, TError, TVariables, TContext>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation(++this.#lastId, options, this)\n\n this.addEntry(\n String(mutation.mutationId),\n mutation as Mutation<unknown, unknown, unknown, unknown>,\n )\n\n return mutation\n }\n\n findAll(\n filters: MutationFilters = {},\n ): Array<Mutation<unknown, unknown, unknown, unknown>> {\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!filters.status) return all\n\n return all.filter((mutation) => mutation.state().status === filters.status)\n }\n\n remove<TData, TError, TVariables, TContext>(\n mutation: Mutation<TData, TError, TVariables, TContext>,\n ): void {\n this.removeEntry(String(mutation.mutationId))\n }\n\n override clear(): void {\n this.getAll().forEach((mutation) => mutation.cancel())\n super.clear()\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport type { RetryDelayValue, RetryValue } from './types'\n\n/** @internal */\nexport interface QueryClientConfig {\n defaultOptions?: {\n queries?: {\n staleTime?: number\n gcTime?: number\n retry?: RetryValue<unknown>\n retryDelay?: RetryDelayValue<unknown>\n }\n }\n}\n\n/** @internal */\nexport const QUERY_CLIENT_CONFIG = new InjectionToken<QueryClientConfig>(\n 'QUERY_CLIENT_CONFIG',\n)\n","import { inject, Injectable } from '@angular/core'\nimport type { Observable } from 'rxjs'\n\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport { defaultRetryDelay } from './retryer'\nimport { functionalUpdate } from './utils'\nimport type {\n DefaultedQueryOptions,\n QueryFilters,\n QueryKey,\n QueryOptions,\n RetryDelayValue,\n RetryValue,\n Updater,\n} from './types'\nimport { QUERY_CLIENT_CONFIG } from './injection-tokens'\n\n/**\n * Central registry and cache for queries and mutations.\n *\n * Provided by {@link provideQueryClient} and retrieved with\n * {@link injectQueryClient}. Offers imperative cache access — reading and\n * writing data, and invalidating, cancelling, or removing queries — that\n * complements the reactive {@link injectQuery} / {@link injectMutation} APIs.\n */\n@Injectable()\nexport class QueryClient {\n readonly #cache = inject(QueryCache)\n readonly #mutationCache = inject(MutationCache)\n readonly #config = inject(QUERY_CLIENT_CONFIG, { optional: true }) ?? {}\n\n /** Returns the underlying query cache. Advanced/internal use. */\n getQueryCache(): QueryCache {\n return this.#cache\n }\n\n /** Returns the underlying mutation cache. Advanced/internal use. */\n getMutationCache(): MutationCache {\n return this.#mutationCache\n }\n\n /**\n * Merges per-query options with the configured defaults, filling in\n * `staleTime`, `gcTime`, `retry`, and `retryDelay`. Used internally by\n * {@link injectQuery}.\n */\n defaultQueryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n ): DefaultedQueryOptions<TData, TError> {\n const defaults = this.#config.defaultOptions?.queries\n\n return {\n ...options,\n staleTime: options.staleTime ?? defaults?.staleTime ?? 0,\n gcTime: options.gcTime ?? defaults?.gcTime,\n retry: options.retry ?? defaults?.retry ?? 3,\n retryDelay:\n options.retryDelay ?? defaults?.retryDelay ?? defaultRetryDelay,\n }\n }\n\n /**\n * Imperatively fetches and caches a query, unless fresh data already exists\n * (governed by `staleTime`). Prefer {@link injectQuery} in components; use\n * this for prefetching outside the reactive flow.\n *\n * @param key - The query key to fetch and cache under.\n * @param queryFn - Function returning the data as an `Observable` or `Promise`.\n * @param options - Fetch tuning (`staleTime`, `retry`, `retryDelay`,\n * `cancelRefetch`).\n */\n fetchQuery<TData>(\n key: QueryKey,\n queryFn: () => Observable<TData> | Promise<TData>,\n options: {\n staleTime?: number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retry?: RetryValue<any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retryDelay?: RetryDelayValue<any>\n cancelRefetch?: boolean\n } = {},\n ): void {\n const defaults = this.#config.defaultOptions?.queries\n const staleTime = options.staleTime ?? defaults?.staleTime ?? 0\n const retry = options.retry ?? defaults?.retry ?? 3\n const retryDelay =\n options.retryDelay ?? defaults?.retryDelay ?? defaultRetryDelay\n\n const query = this.#cache.getOrCreate<TData>(key)\n\n if (query.shouldFetch(staleTime)) {\n query.fetch(queryFn, retry, retryDelay, options.cancelRefetch)\n }\n }\n\n /**\n * Reads the current cached data for a query key, or `undefined` if the query\n * is not cached yet.\n *\n * @param key - The query key to read.\n * @returns The cached data, or `undefined`.\n */\n getQueryData<TData>(key: QueryKey): TData | undefined {\n return this.#cache.get<TData>(key)?.state().data\n }\n\n /**\n * Writes data into the cache for a query key, creating the entry if needed.\n * The `updater` may be a value or a function of the previous data; returning\n * `undefined` from the function is a no-op. Useful for optimistic updates.\n *\n * @param key - The query key to write.\n * @param updater - The new data, or a function `(prev) => next`.\n *\n * @example\n * ```ts\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * ```\n */\n setQueryData<TData>(\n key: QueryKey,\n updater: Updater<TData | undefined, TData>,\n ): void {\n const query = this.#cache.getOrCreate<TData>(key)\n const data = functionalUpdate(updater, query.state().data)\n\n // Matches TanStack: an updater returning undefined is a no-op.\n if (data === undefined) return\n\n query.setData(data)\n }\n\n /**\n * Marks matching queries as stale and triggers a refetch for those that are\n * actively observed. Commonly called after a mutation succeeds.\n *\n * @param filters - Which queries to invalidate; omit to invalidate all.\n *\n * @example\n * ```ts\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\n invalidateQueries(filters?: QueryFilters): void {\n this.#cache.findAll(filters).forEach((query) => query.invalidate())\n }\n\n /**\n * Cancels any in-flight fetches for matching queries.\n *\n * @param filters - Which queries to cancel; omit to cancel all.\n */\n cancelQueries(filters?: QueryFilters): void {\n this.#cache.findAll(filters).forEach((query) => query.cancel())\n }\n\n /**\n * Removes matching queries from the cache entirely, discarding their data.\n *\n * @param filters - Which queries to remove; omit to remove all.\n */\n removeQueries(filters?: QueryFilters): void {\n this.#cache.findAll(filters).forEach((query) => {\n query.destroy()\n this.#cache.remove(query)\n })\n }\n\n /**\n * Returns the number of matching queries currently fetching. For a reactive\n * count, prefer {@link injectIsFetching}.\n *\n * @param filters - Which queries to count; omit to count all.\n */\n isFetching(filters?: QueryFilters): number {\n return this.#cache\n .findAll(filters)\n .filter((query) => query.state().isFetching).length\n }\n\n /**\n * Returns the number of mutations currently pending. For a reactive count,\n * prefer {@link injectIsMutating}.\n */\n isMutating(): number {\n return this.#mutationCache.findAll({ status: 'pending' }).length\n }\n}\n","import type { Provider } from '@angular/core'\n\n/**\n * Discriminator identifying each kind of {@link QueryClientFeature}.\n *\n * @internal\n */\nexport enum QueryClientFeatureKind {\n DefaultOptions,\n}\n\n/**\n * An opaque feature passed to {@link provideQueryClient}. Create one with a\n * `with*` helper such as {@link withDefaultOptions} rather than constructing it\n * directly; the `ɵ`-prefixed members are internal.\n */\nexport interface QueryClientFeature<\n K extends QueryClientFeatureKind = QueryClientFeatureKind,\n> {\n ɵkind: K\n ɵproviders: Provider[]\n}\n\n/** @internal */\nexport function queryClientFeature<K extends QueryClientFeatureKind>(\n kind: K,\n providers: Provider[],\n): QueryClientFeature<K> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n","import {\n type EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n} from '../features/feature'\n\n/**\n * Registers the {@link QueryClient} and its caches for the application.\n *\n * Call once at the app root (in `ApplicationConfig.providers` or a root\n * `bootstrapApplication`). Pass features such as {@link withDefaultOptions} to\n * configure defaults. Registering the same feature twice throws.\n *\n * @param features - Optional {@link QueryClientFeature}s (e.g.\n * {@link withDefaultOptions}).\n * @returns Environment providers to add to the app's provider list.\n *\n * @example\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideHttpClient(),\n * provideQueryClient(\n * withDefaultOptions({ queries: { staleTime: 30_000 } }),\n * ),\n * ],\n * }\n * ```\n */\nexport function provideQueryClient(\n ...features: QueryClientFeature[]\n): EnvironmentProviders {\n const seenKinds = new Set<QueryClientFeatureKind>()\n\n for (const feature of features) {\n if (seenKinds.has(feature.ɵkind)) {\n throw new Error(\n `provideQueryClient: feature \"${QueryClientFeatureKind[feature.ɵkind]}\" is registered more than once`,\n )\n }\n seenKinds.add(feature.ɵkind)\n }\n\n return makeEnvironmentProviders([\n QueryCache,\n MutationCache,\n QueryClient,\n ...features.flatMap((feature) => feature.ɵproviders),\n ])\n}\n","import { type Injector, assertInInjectionContext, inject } from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns the application's {@link QueryClient} for imperative cache access.\n *\n * Use it to read or write cached data (`getQueryData`, `setQueryData`) and to\n * invalidate, cancel, or remove queries — typically from mutation hooks or\n * event handlers. Requires {@link provideQueryClient} to be registered.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns The shared {@link QueryClient} instance.\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\nexport function injectQueryClient(options?: {\n injector?: Injector\n}): QueryClient {\n if (!options?.injector) assertInInjectionContext(injectQueryClient)\n\n return options?.injector?.get(QueryClient) ?? inject(QueryClient)\n}\n","import {\n type EffectCleanupRegisterFn,\n type EffectRef,\n type Injector,\n computed,\n effect,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport type { Query } from './query'\nimport type {\n PlaceholderDataFunction,\n QueryOptions,\n QueryResult,\n QueryStatus,\n} from './types'\n\n/**\n * One observed query: its reactive {@link QueryResult} and a `destroy()` that\n * ends the observation (drops the cache observer, stops polling).\n *\n * @internal\n */\nexport interface QueryObserver<TData, TError = Error> {\n result: QueryResult<TData, TError>\n destroy: () => void\n}\n\n/**\n * Observes a single query and exposes its state as signals — the engine behind\n * {@link injectQuery} and {@link injectQueries}.\n *\n * Effects are created on `injector` with `manualCleanup` so the observer can be\n * torn down on its own via `destroy()`, independently of the injector's\n * lifetime (a component may drop one query out of many). In a component\n * injector they run as view effects, elsewhere as root effects — the same as\n * `effect()` called directly in that context.\n *\n * @internal\n */\nexport function createQueryObserver<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n injector: Injector,\n): QueryObserver<TData, TError> {\n const client = injector.get(QueryClient)\n const cache = client.getQueryCache()\n\n // Every effect is registered here so destroy() covers all of them.\n const refs: EffectRef[] = []\n const track = (fn: (onCleanup: EffectCleanupRegisterFn) => void): void => {\n refs.push(effect(fn, { injector, manualCleanup: true }))\n }\n\n // Single source of truth for defaulted options; resolves config defaults\n // (staleTime, gcTime) once instead of scattering the logic across effects.\n const defaultedOptions = computed(() =>\n client.defaultQueryOptions(optionsFn()),\n )\n\n // Seed a fresh query (status 'pending', no data yet) with initialData so\n // it renders immediately as 'success'. Without an explicit\n // initialDataUpdatedAt the seed is treated as fetched right now, so\n // staleTime applies to it as it would to any other data (a staleTime of 0\n // still means \"stale immediately\" → background refetch).\n const applyInitialData = (q: Query<TData, TError>): void => {\n const { initialData, initialDataUpdatedAt } = untracked(defaultedOptions)\n\n if (initialData === undefined || q.state().status !== 'pending') return\n\n const data =\n typeof initialData === 'function'\n ? (initialData as () => TData)()\n : initialData\n const updatedAt =\n typeof initialDataUpdatedAt === 'function'\n ? initialDataUpdatedAt()\n : (initialDataUpdatedAt ?? Date.now())\n\n q.setData(data, updatedAt)\n }\n\n // getOrCreate mutates the cache (a side effect), so it must not run inside\n // a computed. Resolve the query in a signal: seed it synchronously and\n // update it from an effect whenever the key changes.\n const seed = cache.getOrCreate<TData, TError>(\n untracked(defaultedOptions).queryKey,\n )\n\n applyInitialData(seed)\n\n const query = signal(seed)\n\n // Data of the last query that had any, fed to the placeholderData function\n // on key change (mirrors TanStack's lastQueryWithDefinedData). Captured\n // synchronously before the switch so it can't miss a just-resolved value.\n const lastData = signal<TData | undefined>(undefined)\n\n track(() => {\n const key = defaultedOptions().queryKey\n const q = untracked(() => cache.getOrCreate<TData, TError>(key))\n\n untracked(() => {\n const prev = query()\n\n if (prev !== q && prev.state().data !== undefined) {\n lastData.set(prev.state().data)\n }\n\n applyInitialData(q)\n })\n query.set(q)\n })\n\n // Memoized: only emits when the flag itself flips, so ordinary data\n // updates don't wake the fetch effect (no refetch loop).\n const isInvalidated = computed(() => query().state().isInvalidated)\n\n track((cleanup) => {\n const q = query()\n const { gcTime } = untracked(defaultedOptions)\n\n if (gcTime !== undefined) {\n q.setGcTime(gcTime)\n }\n\n q.addObserver()\n cleanup(() => q.removeObserver())\n })\n\n // Memoized so options re-evaluations that leave the flag alone don't wake\n // the fetch effect.\n const enabled = computed(() => defaultedOptions().enabled !== false)\n\n // Fetch when the observed query switches (key change), when it becomes\n // enabled, or when it is invalidated — not on every re-evaluation of the\n // options. defaultQueryOptions() builds a fresh object each time, so\n // tracking it whole would refetch stale data whenever any signal read in\n // optionsFn changes, even one unrelated to the key. queryFn, staleTime and\n // the retry policy only parameterise the fetch and are read untracked\n // (TanStack's shouldFetchOptionally).\n track(() => {\n query()\n\n // Track invalidation so invalidateQueries() re-triggers a refetch.\n // When invalidated, cancel any in-flight fetch and start a fresh one\n // (otherwise the stale in-flight result would clear isInvalidated).\n const invalidated = isInvalidated()\n\n if (!enabled()) return\n\n const { queryKey, queryFn, staleTime, retry, retryDelay } =\n untracked(defaultedOptions)\n\n untracked(() =>\n client.fetchQuery(queryKey, queryFn, {\n staleTime,\n retry,\n retryDelay,\n cancelRefetch: invalidated,\n }),\n )\n })\n\n // Polling: refetch on an interval, independent of staleTime (staleTime: 0\n // forces the fetch). The function form is reactive — reading state() makes\n // the effect re-run when data changes, so returning false stops polling.\n track((onCleanup) => {\n const { queryKey, queryFn, retry, retryDelay, refetchInterval, enabled } =\n defaultedOptions()\n\n if (enabled === false) return\n\n const interval =\n typeof refetchInterval === 'function'\n ? refetchInterval({ state: query().state() })\n : refetchInterval\n\n if (!interval) return\n\n const id = setInterval(() => {\n client.fetchQuery(queryKey, queryFn, {\n staleTime: 0,\n retry,\n retryDelay,\n })\n }, interval)\n\n onCleanup(() => clearInterval(id))\n })\n\n // Placeholder layer: while the query is pending with no data, present\n // placeholderData as already-successful data. Purely presentational — the\n // cache entry stays 'pending' and the fetch proceeds, so isFetching keeps\n // reporting the real request and the placeholder is dropped on resolve.\n const resolved = computed<{\n data: TData | undefined\n status: QueryStatus\n isPlaceholderData: boolean\n }>(() => {\n const state = query().state()\n const { placeholderData } = defaultedOptions()\n\n if (\n placeholderData !== undefined &&\n state.data === undefined &&\n state.status === 'pending'\n ) {\n const data =\n typeof placeholderData === 'function'\n ? (placeholderData as PlaceholderDataFunction<TData>)(lastData())\n : placeholderData\n\n if (data !== undefined) {\n return { data, status: 'success', isPlaceholderData: true }\n }\n }\n\n return { data: state.data, status: state.status, isPlaceholderData: false }\n })\n\n return {\n result: {\n data: computed(() => resolved().data),\n status: computed(() => resolved().status),\n error: computed(() => query().state().error as TError | null),\n isFetching: computed(() => query().state().isFetching),\n // First fetch in-flight: fetching with no resolved data yet. An active\n // placeholder counts as data — the UI shows it, not a loading state.\n isLoading: computed(\n () => query().state().isFetching && resolved().status === 'pending',\n ),\n isPending: computed(() => resolved().status === 'pending'),\n isSuccess: computed(() => resolved().status === 'success'),\n isError: computed(() => resolved().status === 'error'),\n isPlaceholderData: computed(() => resolved().isPlaceholderData),\n failureCount: computed(() => query().state().failureCount),\n failureReason: computed(\n () => query().state().failureReason as TError | null,\n ),\n // Force a fresh fetch regardless of staleTime, cancelling any in-flight\n // request (explicit user intent — get current data).\n refetch: () => {\n const { queryKey, queryFn, retry, retryDelay } =\n untracked(defaultedOptions)\n\n client.fetchQuery(queryKey, queryFn, {\n staleTime: 0,\n retry,\n retryDelay,\n cancelRefetch: true,\n })\n },\n },\n destroy: () => refs.forEach((ref) => ref.destroy()),\n }\n}\n","import {\n assertInInjectionContext,\n DestroyRef,\n inject,\n Injector,\n} from '@angular/core'\n\nimport { createQueryObserver } from './query-observer'\nimport type { QueryOptions, QueryResult } from './types'\n\n/**\n * Runs a cached, reactive query and exposes its state as signals.\n *\n * The query is keyed by `queryKey`: calls with the same key share a single\n * cache entry and in-flight request (deduplication). `optionsFn` is read in a\n * reactive context, so when a value it depends on changes (e.g. a route or\n * input signal in the key), the query automatically switches to the new key\n * and fetches. The query is bound to the current injection context and cleans\n * up its cache observer when that context is destroyed.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param optionsFn - Factory returning the {@link QueryOptions}. Re-evaluated\n * reactively: a new `queryKey` switches to that query and fetches it, and\n * turning `enabled` on starts the fetch. Re-evaluating with the same key\n * does not refetch, so every value `queryFn` reads belongs in the key.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link QueryResult} of signals (`data`, `status`, `error`,\n * `isLoading`, `isPending`, …) plus a `refetch()` that forces a fresh fetch.\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * @if (todo.isPending()) { <p>Loading…</p> }\n * @if (todo.data(); as data) { <p>{{ data.title }}</p> }\n * `,\n * })\n * class TodoComponent {\n * readonly id = input.required<number>()\n * private readonly http = inject(HttpClient)\n *\n * // Refetches automatically whenever `id()` changes.\n * readonly todo = injectQuery(() => ({\n * queryKey: ['todo', this.id()],\n * queryFn: () => this.http.get<Todo>(`/api/todos/${this.id()}`),\n * }))\n * }\n * ```\n */\nexport function injectQuery<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n options?: { injector?: Injector },\n): QueryResult<TData, TError> {\n if (!options?.injector) assertInInjectionContext(injectQuery)\n\n const injector = options?.injector ?? inject(Injector)\n const { result, destroy } = createQueryObserver(optionsFn, injector)\n\n // The observation lives as long as the owning context (component or\n // injector): tear it down with it.\n injector.get(DestroyRef).onDestroy(destroy)\n\n return result\n}\n","import {\n type Signal,\n type WritableSignal,\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { type QueryObserver, createQueryObserver } from './query-observer'\nimport type { QueryOptions, QueryResult } from './types'\nimport { hashKey } from './utils'\n\n/** Options for {@link injectQueries}. */\nexport interface InjectQueriesOptions<TData, TError = Error> {\n /**\n * One {@link QueryOptions} per query to run. The array may change between\n * evaluations: queries are matched to the previous set by `queryKey`, so a\n * new key starts a query and a missing key ends one.\n */\n queries: Array<QueryOptions<TData, TError>>\n}\n\n// A query kept alive by injectQueries: its observer plus the signal feeding it\n// options, written in place for as long as the key stays in the list.\ninterface Entry<TData, TError> {\n hash: string\n options: WritableSignal<QueryOptions<TData, TError>>\n observer: QueryObserver<TData, TError>\n}\n\n/**\n * Runs a dynamic number of queries in parallel and exposes their results as a\n * signal holding one {@link QueryResult} per entry of `queries`, in order.\n *\n * Reach for it when the set of queries depends on data — one query per id in\n * a list, say — where {@link injectQuery} can't be called in a loop. Each\n * query behaves exactly like a standalone `injectQuery`: its own cache entry,\n * `staleTime`, retries, error and observer. `optionsFn` is reactive: when the\n * array changes, queries whose `queryKey` is still present are kept (with\n * their options updated), new keys start fetching, and dropped keys release\n * their observer. Aggregate across the results with `computed`.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by each `queryFn`.\n * @typeParam TError - Type of the error thrown by each `queryFn`.\n * @param optionsFn - Factory returning the {@link InjectQueriesOptions}.\n * Re-evaluated reactively, so reading signals inside it re-syncs the set.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A signal of {@link QueryResult}s, one per query. The array identity\n * changes only when the set of queries changes, not on every data update.\n *\n * @example\n * ```ts\n * class TodoListComponent {\n * readonly #queries = inject(TodoQueries)\n *\n * readonly todoIds = input.required<number[]>()\n *\n * readonly todos = injectQueries(() => ({\n * queries: this.todoIds().map((id) => this.#queries.detail(id)),\n * }))\n *\n * readonly isPending = computed(() =>\n * this.todos().some((todo) => todo.isPending()),\n * )\n * }\n * ```\n */\nexport function injectQueries<TData, TError = Error>(\n optionsFn: () => InjectQueriesOptions<TData, TError>,\n options?: { injector?: Injector },\n): Signal<Array<QueryResult<TData, TError>>> {\n if (!options?.injector) assertInInjectionContext(injectQueries)\n\n const injector = options?.injector ?? inject(Injector)\n const results = signal<Array<QueryResult<TData, TError>>>([])\n\n let entries: Array<Entry<TData, TError>> = []\n\n // Reconciles the entries with a new list, matching by key hash the way\n // TanStack's QueriesObserver does: a matching entry is reused and handed the\n // new options, an unmatched query gets a fresh observer, and whatever is\n // left over is destroyed. Duplicate keys are paired up one-to-one in order.\n const sync = (queries: Array<QueryOptions<TData, TError>>): void => {\n const pool = new Map<string, Array<Entry<TData, TError>>>()\n\n for (const entry of entries) {\n const list = pool.get(entry.hash) ?? []\n\n list.push(entry)\n pool.set(entry.hash, list)\n }\n\n const next = queries.map((queryOptions) => {\n const hash = hashKey(queryOptions.queryKey)\n const match = pool.get(hash)?.shift()\n\n if (match) {\n match.options.set(queryOptions)\n\n return match\n }\n\n const optionsSignal = signal(queryOptions)\n\n return {\n hash,\n options: optionsSignal,\n observer: createQueryObserver(() => optionsSignal(), injector),\n }\n })\n\n for (const leftovers of pool.values()) {\n leftovers.forEach((entry) => entry.observer.destroy())\n }\n\n // Replace the result array only on a structural change, so a computed\n // over it doesn't recompute when merely the options were refreshed.\n const changed =\n next.length !== entries.length ||\n next.some((entry, index) => entry !== entries[index])\n\n entries = next\n\n if (changed) results.set(entries.map((entry) => entry.observer.result))\n }\n\n // Seed synchronously so the result is populated before effects flush.\n sync(untracked(() => optionsFn().queries))\n\n effect(\n () => {\n const { queries } = optionsFn()\n\n untracked(() => sync(queries))\n },\n { injector },\n )\n\n injector.get(DestroyRef).onDestroy(() => {\n entries.forEach((entry) => entry.observer.destroy())\n })\n\n return results.asReadonly()\n}\n","import {\n assertInInjectionContext,\n computed,\n DestroyRef,\n inject,\n Injector,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport {\n type Mutation,\n type MutationOptions,\n type MutationResult,\n getInitialState,\n} from './mutation'\n\n/**\n * Creates a mutation for imperative writes (create/update/delete) and exposes\n * its state as signals.\n *\n * Unlike queries, a mutation does not run on its own — call `mutate(variables)`\n * to trigger `mutationFn`. The `onMutate` / `onSuccess` / `onError` /\n * `onSettled` lifecycle hooks make optimistic updates and cache invalidation\n * straightforward. Mutations do not retry by default (a retried write is not\n * idempotent); opt in via `options.retry`. Bound to the current injection\n * context and cancelled when that context is destroyed.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param optionsFn - Factory returning the {@link MutationOptions}.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link MutationResult}: `mutate()`, `reset()`, and state signals\n * (`status`, `data`, `error`, `isPending`, …).\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n *\n * const addTodo = injectMutation(() => ({\n * mutationFn: (title: string) => http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => client.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * // <button (click)=\"addTodo.mutate('Buy milk')\" [disabled]=\"addTodo.isPending()\">Add</button>\n * ```\n */\nexport function injectMutation<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n optionsFn: () => MutationOptions<TData, TError, TVariables, TContext>,\n options?: { injector?: Injector },\n): MutationResult<TData, TError, TVariables> {\n if (!options?.injector) assertInInjectionContext(injectMutation)\n\n const injector = options?.injector ?? inject(Injector)\n\n return runInInjectionContext(injector, () => {\n const cache = inject(QueryClient).getMutationCache()\n\n // Every mutate() builds its own Mutation. Sharing one across calls meant a\n // second call overwrote the first's subscription (orphaning the request)\n // and its state (so the slower run, not the latest one, decided the result).\n const current = signal<Mutation<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n // Detaching is all we do on destroy. A run still in flight keeps going —\n // the write has most likely reached the server already, so cancelling it\n // would only skip onSuccess and leave the cache out of sync. It drops\n // itself from the cache once it settles with nobody watching.\n inject(DestroyRef).onDestroy(() => untracked(current)?.removeObserver())\n\n const state = computed(\n () =>\n current()?.state() ??\n getInitialState<TData, TError, TVariables, TContext>(),\n )\n\n return {\n mutate: (variables) => {\n // Stop observing the previous run. It isn't cancelled — if it's still\n // in flight it finishes and fires its hooks; it just no longer feeds\n // the signals below.\n untracked(current)?.removeObserver()\n\n // Options are read per call, so a signal used in them stays live.\n const run = cache.build(optionsFn())\n\n run.addObserver()\n current.set(run)\n run.execute(variables)\n },\n reset: () => {\n // \"Forget the result\", not \"stop the request\". A run still in flight\n // keeps going and fires its hooks, so the cache stays in step with the\n // server — cancelling could not un-send the write anyway, it could only\n // hide the fact that it happened.\n untracked(current)?.removeObserver()\n\n current.set(null)\n },\n data: computed(() => state().data),\n error: computed(() => state().error as TError | null),\n variables: computed(() => state().variables),\n status: computed(() => state().status),\n isIdle: computed(() => state().status === 'idle'),\n isPending: computed(() => state().status === 'pending'),\n isSuccess: computed(() => state().status === 'success'),\n isError: computed(() => state().status === 'error'),\n failureCount: computed(() => state().failureCount),\n failureReason: computed(() => state().failureReason as TError | null),\n }\n })\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport type { QueryFilters } from './types'\n\n/**\n * Returns a signal with the number of queries currently fetching — useful for a\n * global loading indicator.\n *\n * Pass {@link QueryFilters} to count only matching queries; omit them to count\n * every fetching query in the cache.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param filters - Optional filters (e.g. `{ queryKey: ['todos'] }`) to narrow\n * the count.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of active fetches.\n *\n * @example\n * ```ts\n * readonly isFetching = injectIsFetching()\n * // <app-spinner *ngIf=\"isFetching() > 0\" />\n * ```\n */\nexport function injectIsFetching(\n filters?: QueryFilters,\n options?: { injector?: Injector },\n): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsFetching)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getQueryCache()\n\n return computed(\n () =>\n cache.findAll(filters).filter((query) => query.state().isFetching).length,\n )\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns a signal with the number of mutations currently pending — useful for\n * a global \"saving…\" indicator.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of in-flight mutations.\n *\n * @example\n * ```ts\n * readonly isMutating = injectIsMutating()\n * // <p *ngIf=\"isMutating() > 0\">Saving…</p>\n * ```\n */\nexport function injectIsMutating(options?: {\n injector?: Injector\n}): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsMutating)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getMutationCache()\n\n return computed(() => cache.findAll({ status: 'pending' }).length)\n}\n","import type { QueryOptions } from './types'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link QueryOptions}.\n *\n * Returns the options unchanged at runtime, but anchors type inference so the\n * same definition can be shared across {@link injectQuery},\n * {@link QueryClient.setQueryData}, and friends without re-declaring generics.\n * Keeping query definitions in a service (rather than inline) makes them easy\n * to reuse and unit-test.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param options - The {@link QueryOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * @Injectable({ providedIn: 'root' })\n * class TodoQueries {\n * private readonly http = inject(HttpClient)\n *\n * todos() {\n * return queryOptions({\n * queryKey: ['todos'],\n * queryFn: () => this.http.get<Todo[]>('/api/todos'),\n * })\n * }\n * }\n *\n * // const todos = injectQuery(() => inject(TodoQueries).todos())\n * ```\n */\nexport function queryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n): QueryOptions<TData, TError> {\n return options\n}\n","/**\n * Placeholder function that keeps the previous query's data visible while the\n * next one loads — pass as `placeholderData` to avoid flicker when the query\n * key changes (e.g. pagination, search).\n *\n * While the placeholder is shown, `status` reads `'success'` and\n * `isPlaceholderData()` is `true`; `isFetching()` stays `true` so the UI can\n * indicate the data is stale.\n *\n * @example\n * ```ts\n * readonly todos = injectQuery(() => ({\n * queryKey: ['todos', this.page()],\n * queryFn: () => this.http.get<Todo[]>(`/api/todos?page=${this.page()}`),\n * placeholderData: keepPreviousData,\n * }))\n * ```\n */\nexport function keepPreviousData<TData>(\n previousData: TData | undefined,\n): TData | undefined {\n return previousData\n}\n","import type { MutationOptions } from './mutation'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link MutationOptions}.\n *\n * Returns the options unchanged at runtime; its job is to anchor type inference\n * (notably linking `TContext` returned by `onMutate` to the later hooks) so a\n * mutation can be defined once in a service and passed to {@link injectMutation}.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param options - The {@link MutationOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * addTodo() {\n * return mutationOptions({\n * mutationFn: (title: string) => this.http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => this.client.invalidateQueries({ queryKey: ['todos'] }),\n * })\n * }\n * ```\n */\nexport function mutationOptions<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n): MutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n","import { QUERY_CLIENT_CONFIG } from '../core/injection-tokens'\nimport type { RetryDelayValue, RetryValue } from '../core/types'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n queryClientFeature,\n} from './feature'\n\n/** Default query options applied to every query unless overridden per-query. */\nexport interface DefaultQueryOptions {\n /** How long fetched data is considered fresh, in ms. Defaults to `0`. */\n staleTime?: number\n /** How long unused (unobserved) data is kept before garbage collection, in ms. */\n gcTime?: number\n /** Retry policy on failure: a boolean, a count, or a predicate. Defaults to `3`. */\n retry?: RetryValue<unknown>\n /** Delay between retries, in ms or a function of the attempt. */\n retryDelay?: RetryDelayValue<unknown>\n}\n\n/** Application-wide defaults configured via {@link withDefaultOptions}. */\nexport interface DefaultOptions {\n /** Defaults applied to all queries. */\n queries?: DefaultQueryOptions\n}\n\n/**\n * Feature for {@link provideQueryClient} that sets application-wide default\n * query options. Per-query options always take precedence over these defaults.\n *\n * @param options - The {@link DefaultOptions} to apply.\n * @returns A {@link QueryClientFeature} to pass to {@link provideQueryClient}.\n *\n * @example\n * ```ts\n * provideQueryClient(\n * withDefaultOptions({ queries: { staleTime: 60_000, retry: 1 } }),\n * )\n * ```\n */\nexport function withDefaultOptions(\n options: DefaultOptions,\n): QueryClientFeature<QueryClientFeatureKind.DefaultOptions> {\n return queryClientFeature(QueryClientFeatureKind.DefaultOptions, [\n { provide: QUERY_CLIENT_CONFIG, useValue: { defaultOptions: options } },\n ])\n}\n","/*\n * Public API Surface of ngx-query\n */\n\nexport * from './lib/core/query-client'\nexport * from './lib/core/provider'\nexport * from './lib/core/inject-query-client'\nexport * from './lib/core/types'\nexport * from './lib/core/inject-query'\nexport * from './lib/core/inject-queries'\nexport * from './lib/core/inject-mutation'\nexport * from './lib/core/inject-is-fetching'\nexport * from './lib/core/inject-is-mutating'\nexport * from './lib/core/query-options'\nexport * from './lib/core/keep-previous-data'\nexport * from './lib/core/mutation-options'\nexport type {\n MutationFilters,\n MutationOptions,\n MutationResult,\n MutationState,\n MutationStatus,\n} from './lib/core/mutation'\nexport { QueryClientFeatureKind } from './lib/features/feature'\nexport type { QueryClientFeature } from './lib/features/feature'\nexport { withDefaultOptions } from './lib/features/with-default-options'\nexport type {\n DefaultOptions,\n DefaultQueryOptions,\n} from './lib/features/with-default-options'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["retry","retryOperator"],"mappings":";;;;AAEA;MACsB,KAAK,CAAA;AAChB,IAAA,QAAQ,GAAG,MAAM,CAAW,EAAE,oDAAC;;;;AAKrB,IAAA,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;AAE9C,IAAA,WAAW,GAAG,IAAI,GAAG,EAAkB;IAEhD,MAAM,GAAA;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IAC9C;IAEA,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QACxB,IAAI,CAAC,KAAK,EAAE;IACd;IAEU,QAAQ,CAAC,GAAW,EAAE,KAAa,EAAA;QAC3C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;QAChC,IAAI,CAAC,KAAK,EAAE;AAEZ,QAAA,OAAO,KAAK;IACd;AAEU,IAAA,QAAQ,CAAC,GAAW,EAAA;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;IAClC;AAEU,IAAA,WAAW,CAAC,GAAW,EAAA;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC;AAE5C,QAAA,IAAI,OAAO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IAAA,OAAO,OAAO;AAChB;;ACTA;;;;;;;;;;;;;AAaG;AACG,SAAU,kBAAkB,CAChC,OAAuB,EAAA;AAEvB,IAAA,OAAO,kBAAkB,CAAC,sBAAsB,CAAC,cAAc,EAAE;QAC/D,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE;AACxE,KAAA,CAAC;AACJ;;AC9CA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -450,7 +450,9 @@ declare function injectQueryClient(options?: {
|
|
|
450
450
|
* @typeParam TData - Type of the data resolved by `queryFn`.
|
|
451
451
|
* @typeParam TError - Type of the error thrown by `queryFn`.
|
|
452
452
|
* @param optionsFn - Factory returning the {@link QueryOptions}. Re-evaluated
|
|
453
|
-
* reactively
|
|
453
|
+
* reactively: a new `queryKey` switches to that query and fetches it, and
|
|
454
|
+
* turning `enabled` on starts the fetch. Re-evaluating with the same key
|
|
455
|
+
* does not refetch, so every value `queryFn` reads belongs in the key.
|
|
454
456
|
* @param options - Optional `injector` to use outside an injection context.
|
|
455
457
|
* @returns A {@link QueryResult} of signals (`data`, `status`, `error`,
|
|
456
458
|
* `isLoading`, `isPending`, …) plus a `refetch()` that forces a fresh fetch.
|
|
@@ -479,6 +481,58 @@ declare function injectQuery<TData, TError = Error>(optionsFn: () => QueryOption
|
|
|
479
481
|
injector?: Injector;
|
|
480
482
|
}): QueryResult<TData, TError>;
|
|
481
483
|
|
|
484
|
+
/** Options for {@link injectQueries}. */
|
|
485
|
+
interface InjectQueriesOptions<TData, TError = Error> {
|
|
486
|
+
/**
|
|
487
|
+
* One {@link QueryOptions} per query to run. The array may change between
|
|
488
|
+
* evaluations: queries are matched to the previous set by `queryKey`, so a
|
|
489
|
+
* new key starts a query and a missing key ends one.
|
|
490
|
+
*/
|
|
491
|
+
queries: Array<QueryOptions<TData, TError>>;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Runs a dynamic number of queries in parallel and exposes their results as a
|
|
495
|
+
* signal holding one {@link QueryResult} per entry of `queries`, in order.
|
|
496
|
+
*
|
|
497
|
+
* Reach for it when the set of queries depends on data — one query per id in
|
|
498
|
+
* a list, say — where {@link injectQuery} can't be called in a loop. Each
|
|
499
|
+
* query behaves exactly like a standalone `injectQuery`: its own cache entry,
|
|
500
|
+
* `staleTime`, retries, error and observer. `optionsFn` is reactive: when the
|
|
501
|
+
* array changes, queries whose `queryKey` is still present are kept (with
|
|
502
|
+
* their options updated), new keys start fetching, and dropped keys release
|
|
503
|
+
* their observer. Aggregate across the results with `computed`.
|
|
504
|
+
*
|
|
505
|
+
* Must run in an injection context, or be given an explicit `injector`.
|
|
506
|
+
*
|
|
507
|
+
* @typeParam TData - Type of the data resolved by each `queryFn`.
|
|
508
|
+
* @typeParam TError - Type of the error thrown by each `queryFn`.
|
|
509
|
+
* @param optionsFn - Factory returning the {@link InjectQueriesOptions}.
|
|
510
|
+
* Re-evaluated reactively, so reading signals inside it re-syncs the set.
|
|
511
|
+
* @param options - Optional `injector` to use outside an injection context.
|
|
512
|
+
* @returns A signal of {@link QueryResult}s, one per query. The array identity
|
|
513
|
+
* changes only when the set of queries changes, not on every data update.
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* class TodoListComponent {
|
|
518
|
+
* readonly #queries = inject(TodoQueries)
|
|
519
|
+
*
|
|
520
|
+
* readonly todoIds = input.required<number[]>()
|
|
521
|
+
*
|
|
522
|
+
* readonly todos = injectQueries(() => ({
|
|
523
|
+
* queries: this.todoIds().map((id) => this.#queries.detail(id)),
|
|
524
|
+
* }))
|
|
525
|
+
*
|
|
526
|
+
* readonly isPending = computed(() =>
|
|
527
|
+
* this.todos().some((todo) => todo.isPending()),
|
|
528
|
+
* )
|
|
529
|
+
* }
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
532
|
+
declare function injectQueries<TData, TError = Error>(optionsFn: () => InjectQueriesOptions<TData, TError>, options?: {
|
|
533
|
+
injector?: Injector;
|
|
534
|
+
}): Signal<Array<QueryResult<TData, TError>>>;
|
|
535
|
+
|
|
482
536
|
/**
|
|
483
537
|
* Creates a mutation for imperative writes (create/update/delete) and exposes
|
|
484
538
|
* its state as signals.
|
|
@@ -671,5 +725,5 @@ interface DefaultOptions {
|
|
|
671
725
|
*/
|
|
672
726
|
declare function withDefaultOptions(options: DefaultOptions): QueryClientFeature<QueryClientFeatureKind.DefaultOptions>;
|
|
673
727
|
|
|
674
|
-
export { QueryClient, QueryClientFeatureKind, injectIsFetching, injectIsMutating, injectMutation, injectQuery, injectQueryClient, keepPreviousData, mutationOptions, provideQueryClient, queryOptions, withDefaultOptions };
|
|
675
|
-
export type { DefaultOptions, DefaultQueryOptions, DefaultedQueryOptions, MutationFilters, MutationOptions, MutationResult, MutationState, MutationStatus, PlaceholderDataFunction, QueryClientFeature, QueryFilters, QueryKey, QueryOptions, QueryResult, QueryState, QueryStatus, RefetchIntervalValue, RetryDelayValue, RetryValue, Updater };
|
|
728
|
+
export { QueryClient, QueryClientFeatureKind, injectIsFetching, injectIsMutating, injectMutation, injectQueries, injectQuery, injectQueryClient, keepPreviousData, mutationOptions, provideQueryClient, queryOptions, withDefaultOptions };
|
|
729
|
+
export type { DefaultOptions, DefaultQueryOptions, DefaultedQueryOptions, InjectQueriesOptions, MutationFilters, MutationOptions, MutationResult, MutationState, MutationStatus, PlaceholderDataFunction, QueryClientFeature, QueryFilters, QueryKey, QueryOptions, QueryResult, QueryState, QueryStatus, RefetchIntervalValue, RetryDelayValue, RetryValue, Updater };
|