@veams/status-quo-query 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -20
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +1 -0
- package/dist/provider.js +2 -0
- package/dist/provider.js.map +1 -1
- package/dist/query.d.ts +26 -15
- package/dist/query.js +40 -31
- package/dist/query.js.map +1 -1
- package/dist/react/hooks/index.d.ts +1 -1
- package/dist/react/hooks/index.js +1 -1
- package/dist/react/hooks/index.js.map +1 -1
- package/dist/react/hooks/use-query-handle.d.ts +2 -0
- package/dist/react/hooks/use-query-handle.js +71 -0
- package/dist/react/hooks/use-query-handle.js.map +1 -0
- package/dist/react/hooks/use-query-subscription.d.ts +1 -2
- package/dist/react/hooks/use-query-subscription.js +1 -72
- package/dist/react/hooks/use-query-subscription.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -8
- package/src/__tests__/provider.spec.ts +8 -0
- package/src/index.ts +0 -2
- package/src/provider.ts +6 -2
- package/src/query.ts +84 -64
- package/src/react/__tests__/{query-subscription.spec.tsx → use-query-handle.spec.tsx} +7 -7
- package/src/react/hooks/index.ts +1 -1
- package/src/react/hooks/{use-query-subscription.ts → use-query-handle.ts} +19 -21
- package/src/react/index.ts +1 -1
- package/dist/query-registry.d.ts +0 -9
- package/dist/query-registry.js +0 -28
- package/dist/query-registry.js.map +0 -1
- package/src/__tests__/query-registry.spec.ts +0 -101
- package/src/query-registry.ts +0 -52
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
|
-
- `
|
|
21
|
+
- `QueryHandle<TData, TError>` is the read handle for one query.
|
|
22
22
|
- `MutationService<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
26
|
- `@veams/status-quo-query/react` is optional and adds one React subscription hook 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,12 +47,13 @@ Root exports:
|
|
|
46
47
|
- `CreateMutationWithDefaults`
|
|
47
48
|
- `CreateUntrackedQuery`
|
|
48
49
|
- `CreateUntrackedMutation`
|
|
49
|
-
- `
|
|
50
|
+
- `QueryHandle`
|
|
51
|
+
- `QueryHandleData`
|
|
50
52
|
- `MutationService`
|
|
51
|
-
- `
|
|
53
|
+
- `QueryHandleSnapshot`
|
|
52
54
|
- `MutationServiceSnapshot`
|
|
53
55
|
- `QueryDependencyTuple`
|
|
54
|
-
- `
|
|
56
|
+
- `QueryHandleOptions`
|
|
55
57
|
- `MutationServiceOptions`
|
|
56
58
|
- `TrackedMutationServiceOptions`
|
|
57
59
|
- `QueryInvalidateOptions`
|
|
@@ -131,21 +133,21 @@ await userQuery.invalidate({ refetchType: 'none' });
|
|
|
131
133
|
|
|
132
134
|
## React Bindings
|
|
133
135
|
|
|
134
|
-
The React entrypoint exposes `
|
|
136
|
+
The React entrypoint exposes `useQueryHandle(...)` and keeps `react` optional unless you
|
|
135
137
|
import `@veams/status-quo-query/react`.
|
|
136
138
|
|
|
137
139
|
```tsx
|
|
138
|
-
import {
|
|
139
|
-
import type {
|
|
140
|
+
import { useQueryHandle } from '@veams/status-quo-query/react';
|
|
141
|
+
import type { QueryHandle } from '@veams/status-quo-query';
|
|
140
142
|
|
|
141
|
-
function ProductName({ query }: { query:
|
|
142
|
-
const snapshot =
|
|
143
|
+
function ProductName({ query }: { query: QueryHandle<{ name: string }, Error> }) {
|
|
144
|
+
const snapshot = useQueryHandle(query);
|
|
143
145
|
|
|
144
146
|
return <span>{snapshot.data?.name ?? 'loading'}</span>;
|
|
145
147
|
}
|
|
146
148
|
```
|
|
147
149
|
|
|
148
|
-
Use the hook when a component should subscribe directly to a query
|
|
150
|
+
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
151
|
|
|
150
152
|
- read `data`, `status`, `fetchStatus`, and flags like `isPending` from the snapshot
|
|
151
153
|
- call `query.refetch()` or `query.invalidate()` on the handle itself
|
|
@@ -160,7 +162,7 @@ import { NativeStateHandler } from '@veams/status-quo';
|
|
|
160
162
|
import {
|
|
161
163
|
toQueryMetaState,
|
|
162
164
|
type QueryMetaState,
|
|
163
|
-
type
|
|
165
|
+
type QueryHandle,
|
|
164
166
|
} from '@veams/status-quo-query';
|
|
165
167
|
|
|
166
168
|
type Product = {
|
|
@@ -178,7 +180,7 @@ type ProductCardActions = {
|
|
|
178
180
|
};
|
|
179
181
|
|
|
180
182
|
export class ProductCardHandler extends NativeStateHandler<ProductCardState, ProductCardActions> {
|
|
181
|
-
constructor(private readonly productQuery:
|
|
183
|
+
constructor(private readonly productQuery: QueryHandle<Product, Error>) {
|
|
182
184
|
super({
|
|
183
185
|
initialState: {
|
|
184
186
|
product: productQuery.getSnapshot().data,
|
|
@@ -500,7 +502,7 @@ Use `dependsOn` when a query needs data from other queries before it can run.
|
|
|
500
502
|
|
|
501
503
|
`dependsOn` accepts a `QueryDependencyTuple`:
|
|
502
504
|
|
|
503
|
-
- an ordered list of source query
|
|
505
|
+
- an ordered list of source query handles
|
|
504
506
|
- a `deriveOptions(...)` callback that returns only `queryKey` and/or `enabled`
|
|
505
507
|
|
|
506
508
|
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 +652,7 @@ Returns `QueryManager` with:
|
|
|
650
652
|
- `cancelQueries(...)`
|
|
651
653
|
- `fetchQuery(...)`
|
|
652
654
|
- `getQueryData(...)`
|
|
655
|
+
- `getQueryState(...)`
|
|
653
656
|
- `invalidateQueries(...)`
|
|
654
657
|
- `refetchQueries(...)`
|
|
655
658
|
- `removeQueries(...)`
|
|
@@ -659,6 +662,95 @@ Returns `QueryManager` with:
|
|
|
659
662
|
|
|
660
663
|
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
664
|
|
|
665
|
+
### How to write a service
|
|
666
|
+
|
|
667
|
+
Do not memoize `QueryHandle` instances in a package-level registry.
|
|
668
|
+
|
|
669
|
+
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.
|
|
670
|
+
|
|
671
|
+
Use this split in a query handler:
|
|
672
|
+
|
|
673
|
+
- return fresh query handles from methods that expose `refetch()`, `subscribe(...)`, or `invalidate()`
|
|
674
|
+
- read cache state directly from `QueryManager` in state-only methods
|
|
675
|
+
- add smaller data-only methods when callers do not need fetch metadata
|
|
676
|
+
|
|
677
|
+
Example:
|
|
678
|
+
|
|
679
|
+
```ts
|
|
680
|
+
import type {
|
|
681
|
+
QueryHandle,
|
|
682
|
+
QueryHandleData,
|
|
683
|
+
QueryHandleSnapshot,
|
|
684
|
+
} from '@veams/status-quo-query';
|
|
685
|
+
|
|
686
|
+
type Company = {
|
|
687
|
+
id: string;
|
|
688
|
+
name: string;
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
// Shared key factories keep the live handle path and snapshot path aligned.
|
|
692
|
+
const companiesQueryKey = ['companies'] as const;
|
|
693
|
+
const companyByIdQueryKey = (companyId: string) => ['company', companyId] as const;
|
|
694
|
+
|
|
695
|
+
export interface CompanyQueryHandler {
|
|
696
|
+
getCompaniesQuery: () => QueryHandle<Company[], Error>;
|
|
697
|
+
getCompanyQueryById: (companyId: string) => QueryHandle<Company, Error>;
|
|
698
|
+
getCompanyStateById: (companyId: string) => QueryHandleSnapshot<Company, Error>;
|
|
699
|
+
getCompanyDataById: (companyId: string) => QueryHandleData<Company, Error>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export function createCompanyQueryHandler(): CompanyQueryHandler {
|
|
703
|
+
const manager = getQueryManager();
|
|
704
|
+
|
|
705
|
+
return {
|
|
706
|
+
// Return a fresh query handle when callers need commands or subscriptions.
|
|
707
|
+
getCompaniesQuery() {
|
|
708
|
+
return manager.createUntrackedQuery(companiesQueryKey, fetchCompanies, {
|
|
709
|
+
staleTime: companyStaleTime,
|
|
710
|
+
});
|
|
711
|
+
},
|
|
712
|
+
// Parameterized query handles are cheap and map directly to the final query key.
|
|
713
|
+
getCompanyQueryById(companyId) {
|
|
714
|
+
const queryKey = companyByIdQueryKey(companyId);
|
|
715
|
+
|
|
716
|
+
return manager.createUntrackedQuery(queryKey, () => fetchCompanyById(companyId), {
|
|
717
|
+
staleTime: companyStaleTime,
|
|
718
|
+
});
|
|
719
|
+
},
|
|
720
|
+
// Snapshot-only reads should use the manager cache APIs instead of building another handle.
|
|
721
|
+
getCompanyStateById(companyId) {
|
|
722
|
+
const queryKey = companyByIdQueryKey(companyId);
|
|
723
|
+
const state = manager.getQueryState(queryKey);
|
|
724
|
+
|
|
725
|
+
return {
|
|
726
|
+
data: manager.getQueryData(queryKey),
|
|
727
|
+
error: (state?.error as Error | null | undefined) ?? null,
|
|
728
|
+
fetchStatus: state?.fetchStatus ?? 'idle',
|
|
729
|
+
status: state?.status ?? 'pending',
|
|
730
|
+
isError: state?.status === 'error',
|
|
731
|
+
isFetching: state?.fetchStatus === 'fetching',
|
|
732
|
+
isPending: state?.status === 'pending',
|
|
733
|
+
isSuccess: state?.status === 'success',
|
|
734
|
+
};
|
|
735
|
+
},
|
|
736
|
+
// Data-only reads can stay even smaller when the caller does not need fetch meta state.
|
|
737
|
+
getCompanyDataById(companyId) {
|
|
738
|
+
const queryKey = companyByIdQueryKey(companyId);
|
|
739
|
+
const state = manager.getQueryState(queryKey);
|
|
740
|
+
|
|
741
|
+
return {
|
|
742
|
+
data: manager.getQueryData(queryKey),
|
|
743
|
+
error: (state?.error as Error | null | undefined) ?? null,
|
|
744
|
+
};
|
|
745
|
+
},
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
In this example, `getQueryManager()` is your application-level accessor for the shared `QueryManager`.
|
|
751
|
+
|
|
752
|
+
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.
|
|
753
|
+
|
|
662
754
|
### Tracked Queries and Mutations
|
|
663
755
|
|
|
664
756
|
Tracked queries embed dependency metadata into the final query-key segment:
|
|
@@ -669,7 +761,7 @@ Tracked queries embed dependency metadata into the final query-key segment:
|
|
|
669
761
|
|
|
670
762
|
Only `deps` participates in automatic invalidation tracking. `view` is optional and is treated as normal query-key data.
|
|
671
763
|
|
|
672
|
-
`createQuery(queryKey, queryFn, options?)` returns the same `
|
|
764
|
+
`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
765
|
|
|
674
766
|
`createMutation(mutationFn, options?)` returns the same `MutationService<TData, TError, TVariables, TOnMutateResult>` shape as `createUntrackedMutation(...)`, but adds:
|
|
675
767
|
|
|
@@ -706,17 +798,17 @@ Reach for standalone `createMutation(...)` when:
|
|
|
706
798
|
|
|
707
799
|
Creates a `createUntrackedQuery` factory bound to a `QueryClient`.
|
|
708
800
|
|
|
709
|
-
`createUntrackedQuery(queryKey, queryFn, options?)` returns `
|
|
801
|
+
`createUntrackedQuery(queryKey, queryFn, options?)` returns `QueryHandle<TData, TError>`.
|
|
710
802
|
|
|
711
|
-
`
|
|
803
|
+
`QueryHandleOptions` is based on TanStack `QueryObserverOptions`, without `queryKey` and `queryFn` because those are provided directly to `createUntrackedQuery`.
|
|
712
804
|
|
|
713
805
|
It also adds:
|
|
714
806
|
|
|
715
807
|
- `dependsOn?: QueryDependencyTuple<[...sources]>`
|
|
716
808
|
|
|
717
|
-
`dependsOn` observes the listed source query
|
|
809
|
+
`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
810
|
|
|
719
|
-
`
|
|
811
|
+
`QueryHandle` methods:
|
|
720
812
|
|
|
721
813
|
- `getSnapshot()`
|
|
722
814
|
- `subscribe(listener)`
|
|
@@ -724,7 +816,7 @@ It also adds:
|
|
|
724
816
|
- `invalidate(options?)`
|
|
725
817
|
- `unsafe_getResult()`
|
|
726
818
|
|
|
727
|
-
`
|
|
819
|
+
`QueryHandleSnapshot<TData, TError>` fields:
|
|
728
820
|
|
|
729
821
|
- `data`
|
|
730
822
|
- `error`
|
|
@@ -735,6 +827,11 @@ It also adds:
|
|
|
735
827
|
- `isPending`
|
|
736
828
|
- `isSuccess`
|
|
737
829
|
|
|
830
|
+
`QueryHandleData<TData, TError>` fields:
|
|
831
|
+
|
|
832
|
+
- `data`
|
|
833
|
+
- `error`
|
|
834
|
+
|
|
738
835
|
`invalidate(options?)` invalidates the query by its exact key. `QueryInvalidateOptions` supports:
|
|
739
836
|
|
|
740
837
|
- `refetchType`
|
|
@@ -774,6 +871,11 @@ Creates a `createUntrackedMutation` factory bound to a `QueryClient`.
|
|
|
774
871
|
|
|
775
872
|
### Query Helpers
|
|
776
873
|
|
|
874
|
+
`toQueryHandleData(snapshot)` reduces a query snapshot to:
|
|
875
|
+
|
|
876
|
+
- `data`
|
|
877
|
+
- `error`
|
|
878
|
+
|
|
777
879
|
`toQueryMetaState(snapshot)` reduces a query snapshot to:
|
|
778
880
|
|
|
779
881
|
- `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
|
|
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"}
|
package/dist/provider.d.ts
CHANGED
|
@@ -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.
|
package/dist/provider.js.map
CHANGED
|
@@ -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;
|
|
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,iBA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,CAAC;QACD,wDAAwD;QACxD,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;QAC1D,yDAAyD;QACzD,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;QACpD,4DAA4D;QAC5D,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC;QACxD,iEAAiE;QACjE,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;QAC1D,2DAA2D;QAC3D,iBAAiB,EAAE,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC;QAClE,yDAAyD;QACzD,cAAc,EAAE,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC;QAC5D,uDAAuD;QACvD,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;QAC1D,wDAAwD;QACxD,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC;QACxD,yDAAyD;QACzD,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC;QACxD,mDAAmD;QACnD,gBAAgB,EAAE,GAAG,EAAE,CAAC,WAAW;KACpC,CAAC;AACJ,CAAC"}
|
package/dist/query.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { type TrackedDependencyRecord, type TrackingRegistry, type TrackedQueryK
|
|
|
3
3
|
export type QueryFetchStatus = FetchStatus;
|
|
4
4
|
export type QueryStatus = TanstackQueryStatus;
|
|
5
5
|
/**
|
|
6
|
-
* Represents a stable snapshot of
|
|
6
|
+
* Represents a stable snapshot of one query handle's state.
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface QueryHandleSnapshot<TData, TError> {
|
|
9
9
|
data: TData | undefined;
|
|
10
10
|
error: TError | null;
|
|
11
11
|
fetchStatus: QueryFetchStatus;
|
|
@@ -15,6 +15,13 @@ export interface QueryServiceSnapshot<TData, TError> {
|
|
|
15
15
|
isPending: boolean;
|
|
16
16
|
isSuccess: boolean;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Represents the lightweight data/error read model for one query handle.
|
|
20
|
+
*/
|
|
21
|
+
export interface QueryHandleData<TData, TError> {
|
|
22
|
+
data: TData | undefined;
|
|
23
|
+
error: TError | null;
|
|
24
|
+
}
|
|
18
25
|
/**
|
|
19
26
|
* Defines a subset of query state containing only the status and fetch status.
|
|
20
27
|
*/
|
|
@@ -23,12 +30,12 @@ export interface QueryMetaState {
|
|
|
23
30
|
status: QueryStatus;
|
|
24
31
|
}
|
|
25
32
|
/**
|
|
26
|
-
* Defines the public API for a query
|
|
33
|
+
* Defines the public API for a query handle.
|
|
27
34
|
*/
|
|
28
|
-
export interface
|
|
29
|
-
getSnapshot: () =>
|
|
30
|
-
subscribe: (listener: (snapshot:
|
|
31
|
-
refetch: (options?: RefetchOptions) => Promise<
|
|
35
|
+
export interface QueryHandle<TData, TError> {
|
|
36
|
+
getSnapshot: () => QueryHandleSnapshot<TData, TError>;
|
|
37
|
+
subscribe: (listener: (snapshot: QueryHandleSnapshot<TData, TError>) => void) => () => void;
|
|
38
|
+
refetch: (options?: RefetchOptions) => Promise<QueryHandleSnapshot<TData, TError>>;
|
|
32
39
|
invalidate: (options?: QueryInvalidateOptions) => Promise<void>;
|
|
33
40
|
unsafe_getResult: () => QueryObserverResult<TData, TError>;
|
|
34
41
|
}
|
|
@@ -43,38 +50,42 @@ type QueryDependencyDerivedOptions<TQueryKey extends QueryKey = QueryKey> = {
|
|
|
43
50
|
};
|
|
44
51
|
export type QueryDependencyTuple<TSources extends readonly unknown[], TQueryKey extends QueryKey = QueryKey> = readonly [
|
|
45
52
|
sources: {
|
|
46
|
-
readonly [K in keyof TSources]:
|
|
53
|
+
readonly [K in keyof TSources]: QueryHandle<TSources[K], Error>;
|
|
47
54
|
},
|
|
48
55
|
deriveOptions: (sourceSnapshots: {
|
|
49
|
-
readonly [K in keyof TSources]:
|
|
56
|
+
readonly [K in keyof TSources]: QueryHandleSnapshot<TSources[K], Error>;
|
|
50
57
|
}) => QueryDependencyDerivedOptions<TQueryKey>
|
|
51
58
|
];
|
|
52
59
|
/**
|
|
53
60
|
* Function signature for the untracked query factory.
|
|
54
61
|
*/
|
|
55
62
|
export interface CreateUntrackedQuery {
|
|
56
|
-
<TSources extends readonly unknown[] = [], TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, queryFn: QueryFunction<TQueryFnData, TQueryKey>, options?:
|
|
63
|
+
<TSources extends readonly unknown[] = [], TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(queryKey: TQueryKey, queryFn: QueryFunction<TQueryFnData, TQueryKey>, options?: QueryHandleOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TSources>): QueryHandle<TData, TError>;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* Function signature for the default query factory that derives dependencies from the final
|
|
60
67
|
* query-key segment.
|
|
61
68
|
*
|
|
62
|
-
* The tracked query handle deliberately stays API-compatible with the normal query
|
|
69
|
+
* The tracked query handle deliberately stays API-compatible with the normal query handle.
|
|
63
70
|
* The only extra behavior is invisible: dependency registration and on-demand re-registration.
|
|
64
71
|
*/
|
|
65
72
|
export interface CreateQuery {
|
|
66
|
-
<TDeps extends TrackedDependencyRecord, TSources extends readonly unknown[] = [], TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends TrackedQueryKey<TDeps> = TrackedQueryKey<TDeps>>(queryKey: TQueryKey, queryFn: QueryFunction<TQueryFnData, TQueryKey>, options?:
|
|
73
|
+
<TDeps extends TrackedDependencyRecord, TSources extends readonly unknown[] = [], TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends TrackedQueryKey<TDeps> = TrackedQueryKey<TDeps>>(queryKey: TQueryKey, queryFn: QueryFunction<TQueryFnData, TQueryKey>, options?: QueryHandleOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey, TSources>): QueryHandle<TData, TError>;
|
|
67
74
|
}
|
|
68
75
|
/**
|
|
69
|
-
* Configuration options for creating a query
|
|
76
|
+
* Configuration options for creating a query handle, excluding function and key.
|
|
70
77
|
*/
|
|
71
|
-
export type
|
|
78
|
+
export type QueryHandleOptions<TQueryFnData = unknown, TError = Error, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TSources extends readonly unknown[] = []> = Omit<QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, 'queryFn' | 'queryKey'> & {
|
|
72
79
|
dependsOn?: QueryDependencyTuple<TSources, TQueryKey>;
|
|
73
80
|
};
|
|
74
81
|
/**
|
|
75
82
|
* Extracts and maps status and fetchStatus to our QueryMetaState interface.
|
|
76
83
|
*/
|
|
77
|
-
export declare function toQueryMetaState<TData, TError>(snapshot: Pick<
|
|
84
|
+
export declare function toQueryMetaState<TData, TError>(snapshot: Pick<QueryHandleSnapshot<TData, TError>, 'fetchStatus' | 'status'>): QueryMetaState;
|
|
85
|
+
/**
|
|
86
|
+
* Extracts only data and error from a query snapshot.
|
|
87
|
+
*/
|
|
88
|
+
export declare function toQueryHandleData<TData, TError>(snapshot: Pick<QueryHandleSnapshot<TData, TError>, 'data' | 'error'>): QueryHandleData<TData, TError>;
|
|
78
89
|
/**
|
|
79
90
|
* Helper function to check if the query is in its initial loading state.
|
|
80
91
|
*/
|
package/dist/query.js
CHANGED
|
@@ -12,6 +12,15 @@ export function toQueryMetaState(snapshot) {
|
|
|
12
12
|
status: snapshot.status,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Extracts only data and error from a query snapshot.
|
|
17
|
+
*/
|
|
18
|
+
export function toQueryHandleData(snapshot) {
|
|
19
|
+
return {
|
|
20
|
+
data: snapshot.data,
|
|
21
|
+
error: snapshot.error,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
15
24
|
/**
|
|
16
25
|
* Helper function to check if the query is in its initial loading state.
|
|
17
26
|
*/
|
|
@@ -23,14 +32,14 @@ export function isQueryLoading(query) {
|
|
|
23
32
|
* Prepares the query factory by binding it to a specific QueryClient instance.
|
|
24
33
|
*/
|
|
25
34
|
export function setupQuery(queryClient) {
|
|
26
|
-
// Returns the actual factory function for creating individual query
|
|
35
|
+
// Returns the actual factory function for creating individual query handles.
|
|
27
36
|
return function createQuery(queryKey, queryFn, options) {
|
|
28
|
-
const { dependsOn, runtimeOptions } =
|
|
29
|
-
const
|
|
37
|
+
const { dependsOn, runtimeOptions } = splitQueryHandleOptions(options);
|
|
38
|
+
const handle = createQueryHandle(queryClient, queryKey, queryFn, runtimeOptions);
|
|
30
39
|
if (!dependsOn) {
|
|
31
|
-
return
|
|
40
|
+
return handle.handle;
|
|
32
41
|
}
|
|
33
|
-
return bindQueryDependencies(
|
|
42
|
+
return bindQueryDependencies(handle, queryKey, dependsOn);
|
|
34
43
|
};
|
|
35
44
|
}
|
|
36
45
|
/**
|
|
@@ -45,22 +54,22 @@ export function setupQuery(queryClient) {
|
|
|
45
54
|
*/
|
|
46
55
|
export function setupTrackedQuery(queryClient, trackingRegistry) {
|
|
47
56
|
return function createQuery(queryKey, queryFn, options) {
|
|
48
|
-
const { dependsOn, runtimeOptions } =
|
|
49
|
-
// Reuse the same core query
|
|
50
|
-
const
|
|
57
|
+
const { dependsOn, runtimeOptions } = splitQueryHandleOptions(options);
|
|
58
|
+
// Reuse the same core query-handle implementation as the untracked API.
|
|
59
|
+
const handle = createQueryHandle(queryClient, queryKey, queryFn, runtimeOptions);
|
|
51
60
|
// We only need re-registration on the transition from zero to one subscribers.
|
|
52
61
|
let subscriberCount = 0;
|
|
53
62
|
// Register the current query hash immediately so future tracked mutations can find it.
|
|
54
|
-
trackingRegistry.register(
|
|
63
|
+
trackingRegistry.register(handle.observer.getCurrentQuery().queryHash, extractTrackedDependencies(handle.getCurrentQueryKey()));
|
|
55
64
|
const applyTrackedDerivedState = (derivedOptions) => {
|
|
56
|
-
const previousQueryHash =
|
|
57
|
-
|
|
58
|
-
const nextQueryHash =
|
|
65
|
+
const previousQueryHash = handle.observer.getCurrentQuery().queryHash;
|
|
66
|
+
handle.setDerivedState(derivedOptions);
|
|
67
|
+
const nextQueryHash = handle.observer.getCurrentQuery().queryHash;
|
|
59
68
|
if (nextQueryHash === previousQueryHash) {
|
|
60
69
|
return;
|
|
61
70
|
}
|
|
62
71
|
trackingRegistry.unregister(previousQueryHash);
|
|
63
|
-
trackingRegistry.register(nextQueryHash, extractTrackedDependencies(
|
|
72
|
+
trackingRegistry.register(nextQueryHash, extractTrackedDependencies(handle.getCurrentQueryKey()));
|
|
64
73
|
};
|
|
65
74
|
const dependencyController = dependsOn
|
|
66
75
|
? createDependencyController(queryKey, applyTrackedDerivedState, dependsOn)
|
|
@@ -68,8 +77,8 @@ export function setupTrackedQuery(queryClient, trackingRegistry) {
|
|
|
68
77
|
const ensureRegistered = () => {
|
|
69
78
|
// Build resolves the current live TanStack query for the stored observer options. This is
|
|
70
79
|
// the same mechanism TanStack uses internally when a query gets recreated after GC.
|
|
71
|
-
const liveQuery = queryClient.getQueryCache().build(queryClient,
|
|
72
|
-
const liveDependencies = extractTrackedDependencies(
|
|
80
|
+
const liveQuery = queryClient.getQueryCache().build(queryClient, handle.getCurrentObserverOptions());
|
|
81
|
+
const liveDependencies = extractTrackedDependencies(handle.getCurrentQueryKey());
|
|
73
82
|
// Re-register only when TanStack has recreated the query and the registry has already
|
|
74
83
|
// cleaned up the previous hash. This keeps the edge-case handling cheap in the common case.
|
|
75
84
|
if (!trackingRegistry.has(liveQuery.queryHash)) {
|
|
@@ -77,12 +86,12 @@ export function setupTrackedQuery(queryClient, trackingRegistry) {
|
|
|
77
86
|
}
|
|
78
87
|
};
|
|
79
88
|
return {
|
|
80
|
-
...
|
|
89
|
+
...handle.handle,
|
|
81
90
|
refetch: async (refetchOptions) => {
|
|
82
91
|
await dependencyController?.evaluateForRefetch();
|
|
83
92
|
// Refetch is one of the two explicit reactivation paths agreed on in the design.
|
|
84
93
|
ensureRegistered();
|
|
85
|
-
return
|
|
94
|
+
return handle.handle.refetch(refetchOptions);
|
|
86
95
|
},
|
|
87
96
|
subscribe: (listener) => {
|
|
88
97
|
// The first active subscriber is the other reactivation path. Re-running registration
|
|
@@ -92,7 +101,7 @@ export function setupTrackedQuery(queryClient, trackingRegistry) {
|
|
|
92
101
|
ensureRegistered();
|
|
93
102
|
}
|
|
94
103
|
subscriberCount += 1;
|
|
95
|
-
const unsubscribe =
|
|
104
|
+
const unsubscribe = handle.handle.subscribe(listener);
|
|
96
105
|
return () => {
|
|
97
106
|
// Keep the counter bounded so accidental double-unsubscribe cannot push it negative.
|
|
98
107
|
subscriberCount = Math.max(0, subscriberCount - 1);
|
|
@@ -108,8 +117,8 @@ export function setupTrackedQuery(queryClient, trackingRegistry) {
|
|
|
108
117
|
/**
|
|
109
118
|
* Internal helper to transform a raw Tanstack query result into our public snapshot format.
|
|
110
119
|
*/
|
|
111
|
-
function
|
|
112
|
-
// Extract and return the relevant fields for the UI or other
|
|
120
|
+
function toQueryHandleSnapshot(result) {
|
|
121
|
+
// Extract and return the relevant fields for the UI or other handle consumers.
|
|
113
122
|
return {
|
|
114
123
|
data: result.data,
|
|
115
124
|
error: result.error,
|
|
@@ -121,7 +130,7 @@ function toQueryServiceSnapshot(result) {
|
|
|
121
130
|
isSuccess: result.isSuccess,
|
|
122
131
|
};
|
|
123
132
|
}
|
|
124
|
-
function
|
|
133
|
+
function createQueryHandle(queryClient, queryKey, queryFn, options) {
|
|
125
134
|
const baseQueryKey = queryKey;
|
|
126
135
|
const baseOptions = options;
|
|
127
136
|
let resolvedQueryKey = baseQueryKey;
|
|
@@ -141,12 +150,12 @@ function createQueryService(queryClient, queryKey, queryFn, options) {
|
|
|
141
150
|
getCurrentObserverOptions,
|
|
142
151
|
getCurrentQueryKey: () => resolvedQueryKey,
|
|
143
152
|
setDerivedState,
|
|
144
|
-
|
|
145
|
-
getSnapshot: () =>
|
|
153
|
+
handle: {
|
|
154
|
+
getSnapshot: () => toQueryHandleSnapshot(observer.getCurrentResult()),
|
|
146
155
|
subscribe: (listener) => observer.subscribe((result) => {
|
|
147
|
-
listener(
|
|
156
|
+
listener(toQueryHandleSnapshot(result));
|
|
148
157
|
}),
|
|
149
|
-
refetch: async (refetchOptions) =>
|
|
158
|
+
refetch: async (refetchOptions) => toQueryHandleSnapshot(await observer.refetch(refetchOptions)),
|
|
150
159
|
invalidate: (invalidateOptions) => queryClient.invalidateQueries({
|
|
151
160
|
exact: true,
|
|
152
161
|
queryKey: resolvedQueryKey,
|
|
@@ -158,21 +167,21 @@ function createQueryService(queryClient, queryKey, queryFn, options) {
|
|
|
158
167
|
},
|
|
159
168
|
};
|
|
160
169
|
}
|
|
161
|
-
function bindQueryDependencies(
|
|
162
|
-
const dependencyController = createDependencyController(queryKey,
|
|
170
|
+
function bindQueryDependencies(queryHandle, queryKey, dependsOn) {
|
|
171
|
+
const dependencyController = createDependencyController(queryKey, queryHandle.setDerivedState, dependsOn);
|
|
163
172
|
let subscriberCount = 0;
|
|
164
173
|
return {
|
|
165
|
-
...
|
|
174
|
+
...queryHandle.handle,
|
|
166
175
|
refetch: async (refetchOptions) => {
|
|
167
176
|
await dependencyController.evaluateForRefetch();
|
|
168
|
-
return
|
|
177
|
+
return queryHandle.handle.refetch(refetchOptions);
|
|
169
178
|
},
|
|
170
179
|
subscribe: (listener) => {
|
|
171
180
|
if (subscriberCount === 0) {
|
|
172
181
|
dependencyController.activate();
|
|
173
182
|
}
|
|
174
183
|
subscriberCount += 1;
|
|
175
|
-
const unsubscribe =
|
|
184
|
+
const unsubscribe = queryHandle.handle.subscribe(listener);
|
|
176
185
|
return () => {
|
|
177
186
|
subscriberCount = Math.max(0, subscriberCount - 1);
|
|
178
187
|
if (subscriberCount === 0) {
|
|
@@ -239,7 +248,7 @@ function createDependencyController(baseQueryKey, setDerivedState, dependsOn) {
|
|
|
239
248
|
},
|
|
240
249
|
};
|
|
241
250
|
}
|
|
242
|
-
function
|
|
251
|
+
function splitQueryHandleOptions(options) {
|
|
243
252
|
if (options === undefined) {
|
|
244
253
|
return {
|
|
245
254
|
dependsOn: undefined,
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO;AAaL,iEAAiE;AACjE,aAAa,GAUd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAIL,0BAA0B,GAC3B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO;AAaL,iEAAiE;AACjE,aAAa,GAUd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAIL,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AA0JvB;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA4E;IAE5E,6DAA6D;IAC7D,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,MAAM,EAAE,QAAQ,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAoE;IAEpE,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;KACtB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAqB;IAClD,mEAAmE;IACnE,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,KAAK,UAAU,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,WAAwB;IACjD,6EAA6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AAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;QACxF,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;KACtF,CAAC;IAEF,sEAAsE;IACtE,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useQueryHandle } from './use-query-handle.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useQueryHandle } from './use-query-handle.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
|