@veams/status-quo-query 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/README.md +166 -34
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/mutation.d.ts +8 -8
  7. package/dist/mutation.js +9 -9
  8. package/dist/mutation.js.map +1 -1
  9. package/dist/provider.d.ts +3 -2
  10. package/dist/provider.js +2 -0
  11. package/dist/provider.js.map +1 -1
  12. package/dist/query.d.ts +26 -15
  13. package/dist/query.js +40 -31
  14. package/dist/query.js.map +1 -1
  15. package/dist/react/hooks/index.d.ts +2 -1
  16. package/dist/react/hooks/index.js +2 -1
  17. package/dist/react/hooks/index.js.map +1 -1
  18. package/dist/react/hooks/use-mutation-handle.d.ts +2 -0
  19. package/dist/react/hooks/use-mutation-handle.js +71 -0
  20. package/dist/react/hooks/use-mutation-handle.js.map +1 -0
  21. package/dist/react/hooks/use-query-handle.d.ts +2 -0
  22. package/dist/react/hooks/use-query-handle.js +71 -0
  23. package/dist/react/hooks/use-query-handle.js.map +1 -0
  24. package/dist/react/hooks/use-query-subscription.d.ts +1 -2
  25. package/dist/react/hooks/use-query-subscription.js +1 -72
  26. package/dist/react/hooks/use-query-subscription.js.map +1 -1
  27. package/dist/react/index.d.ts +1 -1
  28. package/dist/react/index.js +1 -1
  29. package/dist/react/index.js.map +1 -1
  30. package/package.json +1 -8
  31. package/src/__tests__/provider.spec.ts +8 -0
  32. package/src/index.ts +0 -2
  33. package/src/mutation.ts +27 -27
  34. package/src/provider.ts +13 -9
  35. package/src/query.ts +84 -64
  36. package/src/react/__tests__/use-mutation-handle.spec.tsx +107 -0
  37. package/src/react/__tests__/{query-subscription.spec.tsx → use-query-handle.spec.tsx} +7 -7
  38. package/src/react/hooks/index.ts +2 -1
  39. package/src/react/hooks/use-mutation-handle.ts +98 -0
  40. package/src/react/hooks/{use-query-subscription.ts → use-query-handle.ts} +19 -21
  41. package/src/react/index.ts +1 -1
  42. package/dist/query-registry.d.ts +0 -9
  43. package/dist/query-registry.js +0 -28
  44. package/dist/query-registry.js.map +0 -1
  45. package/src/__tests__/query-registry.spec.ts +0 -101
  46. package/src/query-registry.ts +0 -52
@@ -1,14 +1,14 @@
1
1
 
2
2
  
3
- > @veams/status-quo-query@0.3.0 build
3
+ > @veams/status-quo-query@0.12.0 build
4
4
  > npm-run-all compile
5
5
 
6
6
 
7
- > @veams/status-quo-query@0.3.0 compile
7
+ > @veams/status-quo-query@0.12.0 compile
8
8
  > npm-run-all bundle:ts
9
9
 
10
10
 
11
- > @veams/status-quo-query@0.3.0 bundle:ts
11
+ > @veams/status-quo-query@0.12.0 bundle:ts
12
12
  > tsc --project tsconfig.json
13
13
 
14
14
  ⠙⠙⠙
package/README.md CHANGED
@@ -18,14 +18,14 @@ npm install react
18
18
 
19
19
  Status Quo Query deliberately keeps the public surface small:
20
20
 
21
- - `QueryService<TData, TError>` is the read handle for one query.
22
- - `MutationService<TData, TError, TVariables>` is the write handle for one mutation.
21
+ - `QueryHandle<TData, TError>` is the read handle for one query.
22
+ - `MutationHandle<TData, TError, TVariables>` is the write handle for one mutation.
23
23
  - snapshots are passive state objects returned from `getSnapshot()` and `subscribe(...)`.
24
24
  - commands stay on the handle: `refetch()`, `invalidate()`, `mutate()`, `reset()`.
25
25
  - `QueryManager` is the broader coordination layer for cross-query work.
26
- - `@veams/status-quo-query/react` is optional and adds one React subscription hook over the same handle shape.
26
+ - `@veams/status-quo-query/react` is optional and adds React subscription hooks (`useQueryHandle`, `useMutationHandle`) over the same handle shape.
27
27
 
28
- That keeps the package usable in service code, state handlers, and React components without changing the core query or mutation API.
28
+ That keeps the package usable in service code, query handlers, state handlers, and React components without changing the core query or mutation API.
29
29
 
30
30
  ## Package Exports
31
31
 
@@ -35,6 +35,7 @@ Root exports:
35
35
  - `setupQuery`
36
36
  - `setupMutation`
37
37
  - `isQueryLoading`
38
+ - `toQueryHandleData`
38
39
  - `toQueryMetaState`
39
40
  - `QueryFetchStatus`
40
41
  - `QueryStatus`
@@ -46,14 +47,15 @@ Root exports:
46
47
  - `CreateMutationWithDefaults`
47
48
  - `CreateUntrackedQuery`
48
49
  - `CreateUntrackedMutation`
49
- - `QueryService`
50
- - `MutationService`
51
- - `QueryServiceSnapshot`
52
- - `MutationServiceSnapshot`
50
+ - `QueryHandle`
51
+ - `QueryHandleData`
52
+ - `MutationHandle`
53
+ - `QueryHandleSnapshot`
54
+ - `MutationHandleSnapshot`
53
55
  - `QueryDependencyTuple`
54
- - `QueryServiceOptions`
55
- - `MutationServiceOptions`
56
- - `TrackedMutationServiceOptions`
56
+ - `QueryHandleOptions`
57
+ - `MutationHandleOptions`
58
+ - `TrackedMutationHandleOptions`
57
59
  - `QueryInvalidateOptions`
58
60
  - `QueryMetaState`
59
61
  - `TrackedDependencyRecord`
@@ -68,7 +70,7 @@ Subpath exports:
68
70
  - `@veams/status-quo-query/provider`
69
71
  - `@veams/status-quo-query/query`
70
72
  - `@veams/status-quo-query/mutation`
71
- - `@veams/status-quo-query/react`
73
+ - `@veams/status-quo-query/react` (`useQueryHandle`, `useMutationHandle`)
72
74
 
73
75
  ## Quickstart
74
76
 
@@ -131,26 +133,56 @@ await userQuery.invalidate({ refetchType: 'none' });
131
133
 
132
134
  ## React Bindings
133
135
 
134
- The React entrypoint exposes `useQuerySubscription(...)` and keeps `react` optional unless you
135
- import `@veams/status-quo-query/react`.
136
+ The React entrypoint exposes `useQueryHandle(...)` and `useMutationHandle(...)` and keeps `react` optional unless you import `@veams/status-quo-query/react`.
137
+
138
+ ### `useQueryHandle`
136
139
 
137
140
  ```tsx
138
- import { useQuerySubscription } from '@veams/status-quo-query/react';
139
- import type { QueryService } from '@veams/status-quo-query';
141
+ import { useQueryHandle } from '@veams/status-quo-query/react';
142
+ import type { QueryHandle } from '@veams/status-quo-query';
140
143
 
141
- function ProductName({ query }: { query: QueryService<{ name: string }, Error> }) {
142
- const snapshot = useQuerySubscription(query);
144
+ function ProductName({ query }: { query: QueryHandle<{ name: string }, Error> }) {
145
+ const snapshot = useQueryHandle(query);
143
146
 
144
147
  return <span>{snapshot.data?.name ?? 'loading'}</span>;
145
148
  }
146
149
  ```
147
150
 
148
- Use the hook when a component should subscribe directly to a query service and render from its latest snapshot. Keep mapping at the component level:
151
+ Use the hook when a component should subscribe directly to a query handle and render from its latest snapshot. Keep mapping at the component level:
149
152
 
150
153
  - read `data`, `status`, `fetchStatus`, and flags like `isPending` from the snapshot
151
154
  - call `query.refetch()` or `query.invalidate()` on the handle itself
152
155
  - derive view-specific values in the component instead of adding selector logic to the hook
153
156
 
157
+ ### `useMutationHandle`
158
+
159
+ ```tsx
160
+ import { useMutationHandle } from '@veams/status-quo-query/react';
161
+ import type { MutationHandle } from '@veams/status-quo-query';
162
+
163
+ function SaveButton({
164
+ mutation,
165
+ payload,
166
+ }: {
167
+ mutation: MutationHandle<{ ok: boolean }, Error, { name: string }>;
168
+ payload: { name: string };
169
+ }) {
170
+ const snapshot = useMutationHandle(mutation);
171
+
172
+ return (
173
+ <button onClick={() => mutation.mutate(payload)} disabled={snapshot.isPending}>
174
+ {snapshot.isPending ? 'Saving…' : 'Save'}
175
+ </button>
176
+ );
177
+ }
178
+ ```
179
+
180
+ Use `useMutationHandle` when a component should react to mutation state (pending, success, error). Keep imperative calls on the handle itself:
181
+
182
+ - read `status`, `isPending`, `isError`, `isSuccess`, `data`, `error`, `variables` from the snapshot
183
+ - call `mutation.mutate(variables)` or `mutation.reset()` on the handle itself
184
+ - the hook does not trigger the mutation — it only subscribes to its state
185
+
154
186
  ## Status Quo Integration
155
187
 
156
188
  The same query handle can also feed a `status-quo` handler through `bindSubscribable(...)`.
@@ -160,7 +192,7 @@ import { NativeStateHandler } from '@veams/status-quo';
160
192
  import {
161
193
  toQueryMetaState,
162
194
  type QueryMetaState,
163
- type QueryService,
195
+ type QueryHandle,
164
196
  } from '@veams/status-quo-query';
165
197
 
166
198
  type Product = {
@@ -178,7 +210,7 @@ type ProductCardActions = {
178
210
  };
179
211
 
180
212
  export class ProductCardHandler extends NativeStateHandler<ProductCardState, ProductCardActions> {
181
- constructor(private readonly productQuery: QueryService<Product, Error>) {
213
+ constructor(private readonly productQuery: QueryHandle<Product, Error>) {
182
214
  super({
183
215
  initialState: {
184
216
  product: productQuery.getSnapshot().data,
@@ -500,7 +532,7 @@ Use `dependsOn` when a query needs data from other queries before it can run.
500
532
 
501
533
  `dependsOn` accepts a `QueryDependencyTuple`:
502
534
 
503
- - an ordered list of source query services
535
+ - an ordered list of source query handles
504
536
  - a `deriveOptions(...)` callback that returns only `queryKey` and/or `enabled`
505
537
 
506
538
  The watcher starts on the first `subscribe(...)` or `refetch()`, reads the current source snapshots immediately, and stops after the last unsubscribe. A downstream `refetch()` refetches all source services first, then refetches the derived query.
@@ -650,6 +682,7 @@ Returns `QueryManager` with:
650
682
  - `cancelQueries(...)`
651
683
  - `fetchQuery(...)`
652
684
  - `getQueryData(...)`
685
+ - `getQueryState(...)`
653
686
  - `invalidateQueries(...)`
654
687
  - `refetchQueries(...)`
655
688
  - `removeQueries(...)`
@@ -659,6 +692,95 @@ Returns `QueryManager` with:
659
692
 
660
693
  All manager methods forward directly to the corresponding `QueryClient` methods. `fetchQuery(...)` covers the common one-off read path without dropping to the raw client, while `unsafe_getClient()` remains the explicit escape hatch for unsupported TanStack APIs.
661
694
 
695
+ ### How to write a service
696
+
697
+ Do not memoize `QueryHandle` instances in a package-level registry.
698
+
699
+ TanStack already deduplicates cached queries by `queryKey`. A `QueryHandle` is a handle over that cached state, closer to a TanStack `QueryObserver` than to the cached query entry itself. Creating a fresh handle per service method call is fine when the caller wants a live query handle.
700
+
701
+ Use this split in a query handler:
702
+
703
+ - return fresh query handles from methods that expose `refetch()`, `subscribe(...)`, or `invalidate()`
704
+ - read cache state directly from `QueryManager` in state-only methods
705
+ - add smaller data-only methods when callers do not need fetch metadata
706
+
707
+ Example:
708
+
709
+ ```ts
710
+ import type {
711
+ QueryHandle,
712
+ QueryHandleData,
713
+ QueryHandleSnapshot,
714
+ } from '@veams/status-quo-query';
715
+
716
+ type Company = {
717
+ id: string;
718
+ name: string;
719
+ };
720
+
721
+ // Shared key factories keep the live handle path and snapshot path aligned.
722
+ const companiesQueryKey = ['companies'] as const;
723
+ const companyByIdQueryKey = (companyId: string) => ['company', companyId] as const;
724
+
725
+ export interface CompanyQueryHandler {
726
+ getCompaniesQuery: () => QueryHandle<Company[], Error>;
727
+ getCompanyQueryById: (companyId: string) => QueryHandle<Company, Error>;
728
+ getCompanyStateById: (companyId: string) => QueryHandleSnapshot<Company, Error>;
729
+ getCompanyDataById: (companyId: string) => QueryHandleData<Company, Error>;
730
+ }
731
+
732
+ export function createCompanyQueryHandler(): CompanyQueryHandler {
733
+ const manager = getQueryManager();
734
+
735
+ return {
736
+ // Return a fresh query handle when callers need commands or subscriptions.
737
+ getCompaniesQuery() {
738
+ return manager.createUntrackedQuery(companiesQueryKey, fetchCompanies, {
739
+ staleTime: companyStaleTime,
740
+ });
741
+ },
742
+ // Parameterized query handles are cheap and map directly to the final query key.
743
+ getCompanyQueryById(companyId) {
744
+ const queryKey = companyByIdQueryKey(companyId);
745
+
746
+ return manager.createUntrackedQuery(queryKey, () => fetchCompanyById(companyId), {
747
+ staleTime: companyStaleTime,
748
+ });
749
+ },
750
+ // Snapshot-only reads should use the manager cache APIs instead of building another handle.
751
+ getCompanyStateById(companyId) {
752
+ const queryKey = companyByIdQueryKey(companyId);
753
+ const state = manager.getQueryState(queryKey);
754
+
755
+ return {
756
+ data: manager.getQueryData(queryKey),
757
+ error: (state?.error as Error | null | undefined) ?? null,
758
+ fetchStatus: state?.fetchStatus ?? 'idle',
759
+ status: state?.status ?? 'pending',
760
+ isError: state?.status === 'error',
761
+ isFetching: state?.fetchStatus === 'fetching',
762
+ isPending: state?.status === 'pending',
763
+ isSuccess: state?.status === 'success',
764
+ };
765
+ },
766
+ // Data-only reads can stay even smaller when the caller does not need fetch meta state.
767
+ getCompanyDataById(companyId) {
768
+ const queryKey = companyByIdQueryKey(companyId);
769
+ const state = manager.getQueryState(queryKey);
770
+
771
+ return {
772
+ data: manager.getQueryData(queryKey),
773
+ error: (state?.error as Error | null | undefined) ?? null,
774
+ };
775
+ },
776
+ };
777
+ }
778
+ ```
779
+
780
+ In this example, `getQueryManager()` is your application-level accessor for the shared `QueryManager`.
781
+
782
+ This keeps the query handler focused on one feature area, supports parameterized query methods naturally, and offers both full state reads and smaller data-only reads without creating extra handle instances.
783
+
662
784
  ### Tracked Queries and Mutations
663
785
 
664
786
  Tracked queries embed dependency metadata into the final query-key segment:
@@ -669,9 +791,9 @@ Tracked queries embed dependency metadata into the final query-key segment:
669
791
 
670
792
  Only `deps` participates in automatic invalidation tracking. `view` is optional and is treated as normal query-key data.
671
793
 
672
- `createQuery(queryKey, queryFn, options?)` returns the same `QueryService<TData, TError>` shape as `createUntrackedQuery(...)`, but it registers the query hash under every `deps` entry, re-registers on `refetch()` or the first `subscribe(...)` if TanStack has removed the cache entry in the meantime, and keeps the registry in sync when `dependsOn` derives a new tracked key at runtime.
794
+ `createQuery(queryKey, queryFn, options?)` returns the same `QueryHandle<TData, TError>` shape as `createUntrackedQuery(...)`, but it registers the query hash under every `deps` entry, re-registers on `refetch()` or the first `subscribe(...)` if TanStack has removed the cache entry in the meantime, and keeps the registry in sync when `dependsOn` derives a new tracked key at runtime.
673
795
 
674
- `createMutation(mutationFn, options?)` returns the same `MutationService<TData, TError, TVariables, TOnMutateResult>` shape as `createUntrackedMutation(...)`, but adds:
796
+ `createMutation(mutationFn, options?)` returns the same `MutationHandle<TData, TError, TVariables, TOnMutateResult>` shape as `createUntrackedMutation(...)`, but adds:
675
797
 
676
798
  - `dependencyKeys?`
677
799
  - `resolveDependencies?`
@@ -694,7 +816,7 @@ Captures dependency names once and returns:
694
816
  - the tracked query factory
695
817
  - a tracked mutation factory whose default resolver reads `variables[dependencyKey]`
696
818
 
697
- The tracked query factory still expects a query key with a final `{ deps, view? }` segment. The tracked mutation factory keeps the same `MutationService` shape as `createMutation(...)`, but no longer needs `dependencyKeys` repeated in each call.
819
+ The tracked query factory still expects a query key with a final `{ deps, view? }` segment. The tracked mutation factory keeps the same `MutationHandle` shape as `createMutation(...)`, but no longer needs `dependencyKeys` repeated in each call.
698
820
 
699
821
  Reach for standalone `createMutation(...)` when:
700
822
 
@@ -706,17 +828,17 @@ Reach for standalone `createMutation(...)` when:
706
828
 
707
829
  Creates a `createUntrackedQuery` factory bound to a `QueryClient`.
708
830
 
709
- `createUntrackedQuery(queryKey, queryFn, options?)` returns `QueryService<TData, TError>`.
831
+ `createUntrackedQuery(queryKey, queryFn, options?)` returns `QueryHandle<TData, TError>`.
710
832
 
711
- `QueryServiceOptions` is based on TanStack `QueryObserverOptions`, without `queryKey` and `queryFn` because those are provided directly to `createUntrackedQuery`.
833
+ `QueryHandleOptions` is based on TanStack `QueryObserverOptions`, without `queryKey` and `queryFn` because those are provided directly to `createUntrackedQuery`.
712
834
 
713
835
  It also adds:
714
836
 
715
837
  - `dependsOn?: QueryDependencyTuple<[...sources]>`
716
838
 
717
- `dependsOn` observes the listed source query services and lets the downstream query derive only `queryKey` and `enabled`. Source services are activated while the downstream query is active, and downstream `refetch()` refetches the sources first. The public `QueryService` API does not change when this option is used.
839
+ `dependsOn` observes the listed source query handles and lets the downstream query derive only `queryKey` and `enabled`. Source handles are activated while the downstream query is active, and downstream `refetch()` refetches the sources first. The public `QueryHandle` API does not change when this option is used.
718
840
 
719
- `QueryService` methods:
841
+ `QueryHandle` methods:
720
842
 
721
843
  - `getSnapshot()`
722
844
  - `subscribe(listener)`
@@ -724,7 +846,7 @@ It also adds:
724
846
  - `invalidate(options?)`
725
847
  - `unsafe_getResult()`
726
848
 
727
- `QueryServiceSnapshot<TData, TError>` fields:
849
+ `QueryHandleSnapshot<TData, TError>` fields:
728
850
 
729
851
  - `data`
730
852
  - `error`
@@ -735,6 +857,11 @@ It also adds:
735
857
  - `isPending`
736
858
  - `isSuccess`
737
859
 
860
+ `QueryHandleData<TData, TError>` fields:
861
+
862
+ - `data`
863
+ - `error`
864
+
738
865
  `invalidate(options?)` invalidates the query by its exact key. `QueryInvalidateOptions` supports:
739
866
 
740
867
  - `refetchType`
@@ -747,11 +874,11 @@ It also adds:
747
874
 
748
875
  Creates a `createUntrackedMutation` factory bound to a `QueryClient`.
749
876
 
750
- `createUntrackedMutation(mutationFn, options?)` returns `MutationService<TData, TError, TVariables, TOnMutateResult>`.
877
+ `createUntrackedMutation(mutationFn, options?)` returns `MutationHandle<TData, TError, TVariables, TOnMutateResult>`.
751
878
 
752
- `MutationServiceOptions` is based on TanStack `MutationObserverOptions`, without `mutationFn` because it is provided directly to `createUntrackedMutation`.
879
+ `MutationHandleOptions` is based on TanStack `MutationObserverOptions`, without `mutationFn` because it is provided directly to `createUntrackedMutation`.
753
880
 
754
- `MutationService` methods:
881
+ `MutationHandle` methods:
755
882
 
756
883
  - `getSnapshot()`
757
884
  - `subscribe(listener)`
@@ -759,7 +886,7 @@ Creates a `createUntrackedMutation` factory bound to a `QueryClient`.
759
886
  - `reset()`
760
887
  - `unsafe_getResult()`
761
888
 
762
- `MutationServiceSnapshot<TData, TError, TVariables>` fields:
889
+ `MutationHandleSnapshot<TData, TError, TVariables>` fields:
763
890
 
764
891
  - `data`
765
892
  - `error`
@@ -774,6 +901,11 @@ Creates a `createUntrackedMutation` factory bound to a `QueryClient`.
774
901
 
775
902
  ### Query Helpers
776
903
 
904
+ `toQueryHandleData(snapshot)` reduces a query snapshot to:
905
+
906
+ - `data`
907
+ - `error`
908
+
777
909
  `toQueryMetaState(snapshot)` reduces a query snapshot to:
778
910
 
779
911
  - `status`
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './mutation.js';
2
2
  export * from './query.js';
3
3
  export * from './provider.js';
4
- export * from './query-registry.js';
5
4
  export type { TrackedDependencyRecord, TrackedDependencyValue, TrackedInvalidateOn, TrackedMatchMode, TrackedQueryKey, TrackedQueryKeySegment, } from './tracking.js';
package/dist/index.js CHANGED
@@ -4,6 +4,4 @@ export * from './mutation.js';
4
4
  export * from './query.js';
5
5
  // Re-export all provider-related types and functions for cache management.
6
6
  export * from './provider.js';
7
- // Re-export query registry helpers for memoizing query services by key.
8
- export * from './query-registry.js';
9
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,cAAc,eAAe,CAAC;AAC9B,mDAAmD;AACnD,cAAc,YAAY,CAAC;AAC3B,2EAA2E;AAC3E,cAAc,eAAe,CAAC;AAC9B,wEAAwE;AACxE,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,cAAc,eAAe,CAAC;AAC9B,mDAAmD;AACnD,cAAc,YAAY,CAAC;AAC3B,2EAA2E;AAC3E,cAAc,eAAe,CAAC"}
@@ -4,7 +4,7 @@ export type MutationStatus = TanstackMutationStatus;
4
4
  /**
5
5
  * Represents a stable snapshot of the mutation service's state.
6
6
  */
7
- export interface MutationServiceSnapshot<TData = unknown, TError = Error, TVariables = void> {
7
+ export interface MutationHandleSnapshot<TData = unknown, TError = Error, TVariables = void> {
8
8
  data: TData | undefined;
9
9
  error: TError | null;
10
10
  status: MutationStatus;
@@ -17,9 +17,9 @@ export interface MutationServiceSnapshot<TData = unknown, TError = Error, TVaria
17
17
  /**
18
18
  * Defines the public API for a mutation service.
19
19
  */
20
- export interface MutationService<TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown> {
21
- getSnapshot: () => MutationServiceSnapshot<TData, TError, TVariables>;
22
- subscribe: (listener: (snapshot: MutationServiceSnapshot<TData, TError, TVariables>) => void) => () => void;
20
+ export interface MutationHandle<TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown> {
21
+ getSnapshot: () => MutationHandleSnapshot<TData, TError, TVariables>;
22
+ subscribe: (listener: (snapshot: MutationHandleSnapshot<TData, TError, TVariables>) => void) => () => void;
23
23
  mutate: (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
24
24
  reset: () => void;
25
25
  unsafe_getResult: () => MutationObserverResult<TData, TError, TVariables, TOnMutateResult>;
@@ -27,12 +27,12 @@ export interface MutationService<TData = unknown, TError = Error, TVariables = v
27
27
  /**
28
28
  * Configuration options for creating a mutation service, excluding the mutation function itself.
29
29
  */
30
- export type MutationServiceOptions<TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown> = Omit<MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationFn'>;
30
+ export type MutationHandleOptions<TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown> = Omit<MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationFn'>;
31
31
  /**
32
32
  * Function signature for the untracked mutation factory.
33
33
  */
34
34
  export interface CreateUntrackedMutation {
35
- <TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: MutationServiceOptions<TData, TError, TVariables, TOnMutateResult>): MutationService<TData, TError, TVariables, TOnMutateResult>;
35
+ <TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: MutationHandleOptions<TData, TError, TVariables, TOnMutateResult>): MutationHandle<TData, TError, TVariables, TOnMutateResult>;
36
36
  }
37
37
  /**
38
38
  * Additional options for tracked mutations that invalidate queries automatically.
@@ -41,7 +41,7 @@ export interface CreateUntrackedMutation {
41
41
  * options only describe how the facade should derive dependency values and when it should
42
42
  * invalidate matching tracked queries after the mutation lifecycle settles.
43
43
  */
44
- export interface TrackedMutationServiceOptions<TDeps extends TrackedDependencyRecord = TrackedDependencyRecord, TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown> extends MutationServiceOptions<TData, TError, TVariables, TOnMutateResult> {
44
+ export interface TrackedMutationHandleOptions<TDeps extends TrackedDependencyRecord = TrackedDependencyRecord, TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown> extends MutationHandleOptions<TData, TError, TVariables, TOnMutateResult> {
45
45
  dependencyKeys?: readonly (keyof TDeps & string)[];
46
46
  resolveDependencies?: (variables: TVariables) => Partial<TDeps>;
47
47
  invalidateOn?: TrackedInvalidateOn;
@@ -51,7 +51,7 @@ export interface TrackedMutationServiceOptions<TDeps extends TrackedDependencyRe
51
51
  * Function signature for the default mutation factory with automatic invalidation.
52
52
  */
53
53
  export interface CreateMutation {
54
- <TDeps extends TrackedDependencyRecord = TrackedDependencyRecord, TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: TrackedMutationServiceOptions<TDeps, TData, TError, TVariables, TOnMutateResult>): MutationService<TData, TError, TVariables, TOnMutateResult>;
54
+ <TDeps extends TrackedDependencyRecord = TrackedDependencyRecord, TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: TrackedMutationHandleOptions<TDeps, TData, TError, TVariables, TOnMutateResult>): MutationHandle<TData, TError, TVariables, TOnMutateResult>;
55
55
  }
56
56
  /**
57
57
  * Prepares the mutation factory by binding it to a specific QueryClient instance.
package/dist/mutation.js CHANGED
@@ -8,7 +8,7 @@ import { pickTrackedDependencies, resolveTrackedQueries, toTrackedDependencyEntr
8
8
  export function setupMutation(queryClient) {
9
9
  // Returns the actual factory function for creating individual mutation services.
10
10
  return function createMutation(mutationFn, options) {
11
- return createMutationService(queryClient, mutationFn, options);
11
+ return createMutationHandle(queryClient, mutationFn, options);
12
12
  };
13
13
  }
14
14
  /**
@@ -22,8 +22,8 @@ export function setupTrackedMutation(queryClient, trackingRegistry, defaultDepen
22
22
  return function createMutation(mutationFn, options) {
23
23
  // Split tracked-only options from the underlying TanStack mutation observer options.
24
24
  const { dependencyKeys, invalidateOn = 'success', matchMode = 'intersection', resolveDependencies, ...mutationOptions } = options ?? {};
25
- // Reuse the normal mutation service so snapshots and subscription behavior stay identical.
26
- const service = createMutationService(queryClient, mutationFn, mutationOptions);
25
+ // Reuse the normal mutation handle so snapshots and subscription behavior stay identical.
26
+ const handle = createMutationHandle(queryClient, mutationFn, mutationOptions);
27
27
  // The paired helper injects dependency keys here, while standalone tracked mutations can
28
28
  // still provide them directly or bypass them with a custom resolver.
29
29
  const resolvedDependencyKeys = (dependencyKeys ?? defaultDependencyKeys);
@@ -41,12 +41,12 @@ export function setupTrackedMutation(queryClient, trackingRegistry, defaultDepen
41
41
  })));
42
42
  };
43
43
  return {
44
- ...service,
44
+ ...handle,
45
45
  mutate: async (variables, mutateOptions) => {
46
46
  try {
47
47
  // Let TanStack finish the mutation first so its own callbacks and state machine remain
48
48
  // authoritative. The facade only coordinates the follow-up invalidation.
49
- const result = await service.mutate(variables, mutateOptions);
49
+ const result = await handle.mutate(variables, mutateOptions);
50
50
  if (invalidateOn === 'success' || invalidateOn === 'settled') {
51
51
  await invalidateTrackedQueries(variables);
52
52
  }
@@ -71,7 +71,7 @@ export function setupTrackedMutation(queryClient, trackingRegistry, defaultDepen
71
71
  /**
72
72
  * Internal helper to transform a raw Tanstack mutation result into our public snapshot format.
73
73
  */
74
- function toMutationServiceSnapshot(result) {
74
+ function toMutationHandleSnapshot(result) {
75
75
  // Extract and return the relevant fields for the UI or other services.
76
76
  return {
77
77
  data: result.data,
@@ -84,7 +84,7 @@ function toMutationServiceSnapshot(result) {
84
84
  isSuccess: result.isSuccess,
85
85
  };
86
86
  }
87
- function createMutationService(queryClient, mutationFn, options) {
87
+ function createMutationHandle(queryClient, mutationFn, options) {
88
88
  // Keep the original mutation implementation in one place so tracked and untracked mutations
89
89
  // always expose the same observer-backed runtime behavior.
90
90
  const observer = new MutationObserver(queryClient, {
@@ -92,9 +92,9 @@ function createMutationService(queryClient, mutationFn, options) {
92
92
  mutationFn,
93
93
  });
94
94
  return {
95
- getSnapshot: () => toMutationServiceSnapshot(observer.getCurrentResult()),
95
+ getSnapshot: () => toMutationHandleSnapshot(observer.getCurrentResult()),
96
96
  subscribe: (listener) => observer.subscribe((result) => {
97
- listener(toMutationServiceSnapshot(result));
97
+ listener(toMutationHandleSnapshot(result));
98
98
  }),
99
99
  mutate: (variables, mutateOptions) => observer.mutate(variables, mutateOptions),
100
100
  reset: () => observer.reset(),
@@ -1 +1 @@
1
- {"version":3,"file":"mutation.js","sourceRoot":"","sources":["../src/mutation.ts"],"names":[],"mappings":"AAAA,OAAO;AACL,2DAA2D;AAC3D,gBAAgB,GAajB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAML,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AAmHvB;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,WAAwB;IACpD,iFAAiF;IACjF,OAAO,SAAS,cAAc,CAM5B,UAA+C,EAC/C,OAA4E;QAE5E,OAAO,qBAAqB,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAwB,EACxB,gBAAkC,EAClC,qBAAyC;IAEzC,OAAO,SAAS,cAAc,CAO5B,UAA+C,EAC/C,OAA0F;QAE1F,qFAAqF;QACrF,MAAM,EACJ,cAAc,EACd,YAAY,GAAG,SAAS,EACxB,SAAS,GAAG,cAAc,EAC1B,mBAAmB,EACnB,GAAG,eAAe,EACnB,GAAG,OAAO,IAAI,EAAE,CAAC;QAClB,2FAA2F;QAC3F,MAAM,OAAO,GAAG,qBAAqB,CAAC,WAAW,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;QAChF,yFAAyF;QACzF,qEAAqE;QACrE,MAAM,sBAAsB,GAAG,CAAC,cAAc,IAAI,qBAAqB,CAAC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AAE;QAC7B,gBAAgB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,kCAAkC,CAIzC,SAAqB,EACrB,cAA6D,EAC7D,mBAEa;IAEb,6FAA6F;IAC7F,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAED,yFAAyF;IACzF,gEAAgE;IAChE,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;IACJ,CAAC;IAED,OAAO,uBAAuB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type QueryClient, type MutationFunction } from '@tanstack/query-core';
2
- import { type CreateMutation, type CreateUntrackedMutation, type MutationService, type TrackedMutationServiceOptions } from './mutation.js';
2
+ import { type CreateMutation, type CreateUntrackedMutation, type MutationHandle, type TrackedMutationHandleOptions } from './mutation.js';
3
3
  import { type CreateQuery, type CreateUntrackedQuery } from './query.js';
4
4
  import { type TrackedDependencyValue } from './tracking.js';
5
5
  /**
@@ -9,7 +9,7 @@ import { type TrackedDependencyValue } from './tracking.js';
9
9
  * once at setup time and injects them automatically for each tracked mutation it creates.
10
10
  */
11
11
  export interface CreateMutationWithDefaults<TDependencyKey extends string> {
12
- <TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: Omit<TrackedMutationServiceOptions<Record<TDependencyKey, TrackedDependencyValue>, TData, TError, TVariables, TOnMutateResult>, 'dependencyKeys'>): MutationService<TData, TError, TVariables, TOnMutateResult>;
12
+ <TData = unknown, TError = Error, TVariables = void, TOnMutateResult = unknown>(mutationFn: MutationFunction<TData, TVariables>, options?: Omit<TrackedMutationHandleOptions<Record<TDependencyKey, TrackedDependencyValue>, TData, TError, TVariables, TOnMutateResult>, 'dependencyKeys'>): MutationHandle<TData, TError, TVariables, TOnMutateResult>;
13
13
  }
14
14
  /**
15
15
  * Paired tracked helper that captures dependency keys once for default mutation resolution.
@@ -29,6 +29,7 @@ export interface QueryManager {
29
29
  cancelQueries: QueryClient['cancelQueries'];
30
30
  fetchQuery: QueryClient['fetchQuery'];
31
31
  getQueryData: QueryClient['getQueryData'];
32
+ getQueryState: QueryClient['getQueryState'];
32
33
  invalidateQueries: QueryClient['invalidateQueries'];
33
34
  refetchQueries: QueryClient['refetchQueries'];
34
35
  removeQueries: QueryClient['removeQueries'];
package/dist/provider.js CHANGED
@@ -48,6 +48,8 @@ export function setupQueryManager(queryClient) {
48
48
  fetchQuery: queryClient.fetchQuery.bind(queryClient),
49
49
  // Proxy for retrieving query data with this client context.
50
50
  getQueryData: queryClient.getQueryData.bind(queryClient),
51
+ // Proxy for retrieving raw query state with this client context.
52
+ getQueryState: queryClient.getQueryState.bind(queryClient),
51
53
  // Proxy for invalidating queries with this client context.
52
54
  invalidateQueries: queryClient.invalidateQueries.bind(queryClient),
53
55
  // Proxy for refetching queries with this client context.
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAMA,qEAAqE;AACrE,OAAO,EAKL,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAA+C,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,EACL,sBAAsB,GAEvB,MAAM,eAAe,CAAC;AAmEvB;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAwB;IACxD,sFAAsF;IACtF,sFAAsF;IACtF,MAAM,gBAAgB,GAAG,sBAAsB,EAAE,CAAC;IAClD,MAAM,YAAY,GAAG,iBAAiB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IACtE,MAAM,eAAe,GAAG,oBAAoB,CAAC,WAAW,EAAE,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