@blaze-cache/react-query 0.2.1-beta → 0.2.5

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.
@@ -0,0 +1,248 @@
1
+ import { matchQuery, partialMatchKey } from '@tanstack/react-query';
2
+ import { isMirrorRecord } from './record.js';
3
+ import { resolveQueryHash } from './hash.js';
4
+ import { DEFAULT_TAGS, DEFAULT_TTL_MS } from './sync.js';
5
+ import { seedBlazeQueryOptions } from './useBlazeQuery.js';
6
+ /** The `cache.set` options a helper writes with: the caller's, or the sync layer's defaults. */
7
+ function mirrorWriteOptions(options) {
8
+ return {
9
+ ttlMs: options?.ttlMs ?? DEFAULT_TTL_MS,
10
+ tags: options?.tags ?? DEFAULT_TAGS,
11
+ };
12
+ }
13
+ /** Every live mirror entry, or a thrown error — never a silently partial operation. */
14
+ function entriesOf(cache) {
15
+ if (!cache.entries) {
16
+ throw new Error('[blaze-cache/react-query] This filter must be matched against every persisted ' +
17
+ 'entry, but the cache does not implement `entries()`. Refusing to run a ' +
18
+ 'deliberately partial purge — use the concrete `BlazeCache`, or narrow the ' +
19
+ 'filter to `exact` query keys, which need no enumeration.');
20
+ }
21
+ return cache.entries();
22
+ }
23
+ /** True when `entry` carries any of `tags`. */
24
+ function hasAnyTag(entry, tags) {
25
+ return entry.tags.some((tag) => tags.includes(tag));
26
+ }
27
+ /**
28
+ * Purges every **mirror record** carrying any of `tags`, returning the removed keys.
29
+ *
30
+ * Deliberately *not* `cache.invalidateTags`: the core's tag index is one global namespace
31
+ * with no per-integration scoping, so on a cache shared with `@blaze-cache/axios`,
32
+ * `@blaze-cache/fetch` or `@blaze-cache/swr` that call would silently purge other
33
+ * integrations' entries too. Enumerating `entries()` lets the selection be narrowed to
34
+ * this package's own records (see {@link isMirrorRecord}) plus tag membership — a
35
+ * `tags` purge here removes what *this* integration tagged and nothing else.
36
+ *
37
+ * Throws when the cache cannot enumerate: a `tags` selector that quietly matched nothing
38
+ * is exactly the bug this package refuses to ship.
39
+ */
40
+ function purgeMirrorByTags(cache, tags) {
41
+ return entriesOf(cache)
42
+ .filter((entry) => isMirrorRecord(entry.value) && hasAnyTag(entry, tags))
43
+ .map((entry) => entry.key);
44
+ }
45
+ /**
46
+ * Resolves one {@link BlazeQueryFilters} against **both** caches: purges the matching
47
+ * mirror entries immediately and returns the filters TanStack's side of the operation
48
+ * should run with.
49
+ *
50
+ * The two sides see different data, so the selection rules are explicit:
51
+ *
52
+ * * **`tags`** live only in the Blaze Cache. A tags-only filter purges by tag (above) and
53
+ * narrows TanStack to the queries whose mirror entries were removed. Combined with a
54
+ * key or a state filter, `entries()` is required so the selection can be intersected
55
+ * rather than unioned.
56
+ * * **`queryKey`/`exact`** match each mirror entry's stored `queryKey`, so a prefix purge
57
+ * also reaches entries from earlier sessions that this TanStack cache never loaded.
58
+ * `exact` keys are a single computable hash and need no enumeration. Entries written
59
+ * before records carried a `queryKey` can only be reached through their live TanStack
60
+ * query, which the union below covers.
61
+ * * **`predicate`/`stale`/`type`/`fetchStatus`** read query state, which mirror entries do
62
+ * not carry — those select TanStack queries, and the mirror follows their hashes. A
63
+ * `tags` filter intersected with them therefore needs `entries()` too.
64
+ * * **No filters** purge the whole mirror (and remove/invalidate every TanStack query).
65
+ */
66
+ function purgeMirrorAndBuildFilters(cache, client, filters) {
67
+ const { tags, ...queryFilters } = filters;
68
+ const { queryKey, exact, predicate, stale, type = 'all', fetchStatus } = queryFilters;
69
+ const stateful = predicate !== undefined || stale !== undefined || type !== 'all' || fetchStatus !== undefined;
70
+ // Hashes of the queries TanStack currently knows and that match the query-side filters —
71
+ // the only mirror entries reachable when the selection leans on live query state.
72
+ const knownHashes = () => new Set(client.getQueryCache().findAll(queryFilters).map((query) => query.queryHash));
73
+ let removed;
74
+ if (stateful) {
75
+ const hashes = knownHashes();
76
+ if (tags) {
77
+ // Intersect: the entry must carry the tag *and* belong to a query TanStack matched.
78
+ removed = entriesOf(cache)
79
+ .filter((entry) => hasAnyTag(entry, tags) && hashes.has(entry.key))
80
+ .map((entry) => entry.key);
81
+ }
82
+ else {
83
+ removed = [...hashes];
84
+ }
85
+ }
86
+ else if (queryKey) {
87
+ const exactHash = exact ? resolveQueryHash(client, queryKey) : undefined;
88
+ removed = entriesOf(cache)
89
+ .filter((entry) => {
90
+ if (tags && !hasAnyTag(entry, tags))
91
+ return false;
92
+ if (exactHash !== undefined) {
93
+ // An exact key is a single candidate hash — no enumeration needed for the
94
+ // key match itself, and the tag test above already narrowed it.
95
+ return entry.key === exactHash;
96
+ }
97
+ const entryKey = entry.value.queryKey;
98
+ // Legacy records (no `queryKey`) predate the self-describing format; they are only
99
+ // reachable through a live TanStack query, which the invalidate/remove side covers.
100
+ if (entryKey === undefined)
101
+ return false;
102
+ return partialMatchKey(entryKey, queryKey);
103
+ })
104
+ .map((entry) => entry.key);
105
+ }
106
+ else if (tags) {
107
+ removed = purgeMirrorByTags(cache, tags);
108
+ }
109
+ else {
110
+ // No filters at all: every *mirror record* goes — and nothing else. On a shared
111
+ // cache the store holds other integrations' entries too (see `isMirrorRecord`), so
112
+ // "everything persisted for queries" must not read as "everything in the cache".
113
+ removed = entriesOf(cache)
114
+ .filter((entry) => isMirrorRecord(entry.value))
115
+ .map((entry) => entry.key);
116
+ }
117
+ for (const key of removed)
118
+ cache.delete(key);
119
+ // TanStack's side. With `tags` in play, tag membership is what the mirror knew and
120
+ // TanStack cannot see, so it becomes a predicate composed with the original filters —
121
+ // every other selector still applies through `matchQuery`.
122
+ if (tags) {
123
+ const removedSet = new Set(removed);
124
+ return {
125
+ ...queryFilters,
126
+ predicate: (query) => removedSet.has(query.queryHash) && matchQuery(queryFilters, query),
127
+ };
128
+ }
129
+ return queryFilters;
130
+ }
131
+ /**
132
+ * `prefetchQuery` that starts from the Blaze Cache.
133
+ *
134
+ * Mirrors {@link useBlazeQuery} imperatively: the persisted record is seeded as
135
+ * `initialData` with its original `dataUpdatedAt` before prefetching, so a `staleTime`
136
+ * window can be satisfied from disk without touching the network at all. When a fetch
137
+ * does run, its result is written back to the mirror under the same record (tags, TTL and
138
+ * self-describing `queryKey` included) — even on a client with no sync layer attached.
139
+ *
140
+ * Errors are swallowed exactly like TanStack's `prefetchQuery`.
141
+ *
142
+ * ```ts
143
+ * await prefetchBlazeQuery(cache, client, {
144
+ * queryKey: ['todos', userId],
145
+ * queryFn: () => fetchTodos(userId),
146
+ * staleTime: 5 * 60_000,
147
+ * tags: ['todos', `user:${userId}`],
148
+ * });
149
+ * ```
150
+ */
151
+ export async function prefetchBlazeQuery(cache, client, options) {
152
+ // Seed first, so freshness is judged against the persisted record — a mirror hit inside
153
+ // `staleTime` completes without a network round trip.
154
+ const seeded = seedBlazeQueryOptions(cache, client, options);
155
+ await client.prefetchQuery(seeded);
156
+ const hash = resolveQueryHash(client, options.queryKey, options);
157
+ const query = client.getQueryCache().get(hash);
158
+ const data = query?.state.data;
159
+ if (!query || data === undefined)
160
+ return; // failed fetch — nothing to persist
161
+ cache.set(hash, { data, dataUpdatedAt: query.state.dataUpdatedAt, queryKey: options.queryKey }, mirrorWriteOptions(options));
162
+ }
163
+ /**
164
+ * `setQueryData` that also writes the Blaze Cache mirror.
165
+ *
166
+ * The TanStack write goes through first (so its exact `dataUpdatedAt` — and structural
167
+ * sharing, which may keep the previous object — is what both caches record), then the
168
+ * mirror is written synchronously under the resolved query hash, tagged per `options`.
169
+ * With a sync layer attached, its batched write sees this identical record and leaves the
170
+ * helper's `ttlMs`/`tags` in place.
171
+ *
172
+ * `data` is a plain value, not an updater — pass a function to TanStack's own
173
+ * `client.setQueryData` when you need to read the previous value first. `undefined` is
174
+ * ignored on both sides, exactly as TanStack ignores it.
175
+ *
176
+ * ```ts
177
+ * setBlazeQueryData(cache, client, ['settings', userId], settings, {
178
+ * tags: ['settings', `user:${userId}`],
179
+ * });
180
+ * ```
181
+ *
182
+ * @returns The stored data, or `undefined` when `data` was `undefined`.
183
+ */
184
+ export function setBlazeQueryData(cache, client, queryKey, data, options) {
185
+ // Explicit `QueryKey` (rather than the caller's `TQueryKey`) for the key type argument:
186
+ // a generic key keeps `InferDataFromTag` a deferred conditional the data would not
187
+ // assign to, while the widened key resolves it to `TData` — and tag inference does not
188
+ // matter here, since this function *supplies* the data instead of reading it.
189
+ const stored = client.setQueryData(queryKey, data);
190
+ if (stored === undefined)
191
+ return undefined;
192
+ const hash = resolveQueryHash(client, queryKey);
193
+ const dataUpdatedAt = client.getQueryCache().get(hash)?.state.dataUpdatedAt ?? Date.now() /* always set */;
194
+ cache.set(hash, { data: stored, dataUpdatedAt, queryKey }, mirrorWriteOptions(options));
195
+ return stored;
196
+ }
197
+ /**
198
+ * `invalidateQueries` for both caches at once: TanStack marks the matching queries stale
199
+ * (active ones refetch, as usual), and the matching **persisted** records are purged so a
200
+ * reload cannot paint pre-invalidation data.
201
+ *
202
+ * Keeping the mirror entry instead would defeat the call — `dataUpdatedAt` is TanStack's
203
+ * staleness clock, and a persisted record would come back as `initialData` on the next
204
+ * session regardless of when it was invalidated. In-session behaviour is untouched:
205
+ * the refetched results re-mirror themselves through the sync layer, stale-while-revalidate
206
+ * included. This mirrors the sync layer's own contract that *explicit* purges remove
207
+ * mirror entries (see {@link syncBlazeQueryCache}).
208
+ *
209
+ * Filters work on both sides; see {@link BlazeQueryFilters} for how `tags`, keys and
210
+ * query-state selectors combine. Purging by tag or by non-exact key needs
211
+ * `cache.entries` — both **throw** when it is absent rather than under-delivering.
212
+ * (Tag purges deliberately enumerate rather than call `cache.invalidateTags`: the core's
213
+ * tag index is one global namespace, so that call would reach other integrations' entries
214
+ * on a shared cache. Enumeration keeps the purge on mirror records — see
215
+ * {@link isMirrorRecord}.)
216
+ *
217
+ * ```ts
218
+ * await invalidateBlazeQueries(cache, client, { queryKey: ['todos', userId] });
219
+ * await invalidateBlazeQueries(cache, client, { tags: [`user:${userId}`] });
220
+ * ```
221
+ *
222
+ * @returns Resolves like TanStack's `invalidateQueries` — once the triggered refetches settle.
223
+ */
224
+ export function invalidateBlazeQueries(cache, client, filters = {}) {
225
+ const tanstackFilters = purgeMirrorAndBuildFilters(cache, client, filters);
226
+ return client.invalidateQueries(tanstackFilters);
227
+ }
228
+ /**
229
+ * `removeQueries` for both caches at once: TanStack drops the matching queries outright,
230
+ * and the matching persisted records are purged — the explicit-purge half of the sync
231
+ * layer's contract (see {@link syncBlazeQueryCache}).
232
+ *
233
+ * The same mirror-side rules and rejections as {@link invalidateBlazeQueries} apply; the
234
+ * difference between the two helpers is what happens on TanStack's side (dropped vs.
235
+ * marked stale), not what happens in the mirror.
236
+ *
237
+ * ```ts
238
+ * // After a logout — including queries from earlier sessions TanStack never loaded:
239
+ * removeBlazeQueries(cache, client, { tags: [`user:${userId}`] });
240
+ * // Every mirror record — and only those, so foreign entries on a shared cache stay:
241
+ * removeBlazeQueries(cache, client);
242
+ * ```
243
+ */
244
+ export function removeBlazeQueries(cache, client, filters = {}) {
245
+ const tanstackFilters = purgeMirrorAndBuildFilters(cache, client, filters);
246
+ client.removeQueries(tanstackFilters);
247
+ }
248
+ //# sourceMappingURL=imperative.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imperative.js","sourceRoot":"","sources":["../src/imperative.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAUpE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAwB3D,gGAAgG;AAChG,SAAS,kBAAkB,CAAC,OAA4B;IAItD,OAAO;QACL,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,cAAc;QACvC,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,YAAY;KACpC,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,SAAS,SAAS,CAA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EAAE,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAA0B,EAC1B,MAAmB,EACnB,UAA6B,EAAE;IAE/B,MAAM,eAAe,GAAG,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAA0B,EAC1B,MAAmB,EACnB,UAA6B,EAAE;IAE/B,MAAM,eAAe,GAAG,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3E,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;AACxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,18 @@
1
1
  /**
2
2
  * TanStack Query (v5) integration backed by Blaze Cache.
3
3
  *
4
- * Two independent pieces:
4
+ * Three independent pieces:
5
5
  *
6
6
  * * {@link syncBlazeQueryCache} / {@link createBlazeQueryClient} — mirror successful queries
7
7
  * so they survive a reload.
8
- * * {@link useBlazeQuery} — a `useQuery` that seeds `initialData` from that mirror, giving
9
- * an instant first paint while TanStack still refetches in the background.
8
+ * * Hooks that seed from that mirror: {@link useBlazeQuery}, {@link useBlazeInfiniteQuery}
9
+ * and {@link useBlazeQueries} paint instantly from persisted data while TanStack still
10
+ * refetches in the background; {@link useBlazeMutation} invalidates both caches after a
11
+ * successful mutation.
12
+ * * Imperative helpers that keep both caches in step without a hook:
13
+ * {@link prefetchBlazeQuery}, {@link setBlazeQueryData}, {@link invalidateBlazeQueries},
14
+ * {@link removeBlazeQueries}, and the persistence round trip
15
+ * {@link dehydrateBlazeQueryClient} / {@link hydrateBlazeQueryClient}.
10
16
  *
11
17
  * ```tsx
12
18
  * const cache = await createCache();
@@ -24,7 +30,17 @@
24
30
  * @packageDocumentation
25
31
  */
26
32
  export { createBlazeQueryClient, syncBlazeQueryCache } from './sync.js';
33
+ export { isMirrorRecord } from './record.js';
27
34
  export { hashQueryKey, resolveQueryHash } from './hash.js';
28
- export { seedBlazeQueryOptions, useBlazeQuery } from './useBlazeQuery.js';
29
- export type { BlazeQueryCacheLike, BlazeQueryClientOptions, BlazeQueryRecord, BlazeQuerySyncOptions, } from './types.js';
35
+ export { readBlazeRecord, seedBlazeQueryOptions, useBlazeQuery } from './useBlazeQuery.js';
36
+ export { seedBlazeInfiniteQueryOptions, useBlazeInfiniteQuery, } from './useBlazeInfiniteQuery.js';
37
+ export { seedBlazeQueriesOptions, useBlazeQueries } from './useBlazeQueries.js';
38
+ export type { UseBlazeQueriesOptions } from './useBlazeQueries.js';
39
+ export { invalidateBlazeQueries, prefetchBlazeQuery, removeBlazeQueries, setBlazeQueryData, } from './imperative.js';
40
+ export type { BlazeFetchQueryOptions } from './imperative.js';
41
+ export { useBlazeMutation } from './useBlazeMutation.js';
42
+ export type { BlazeMutationOptions } from './useBlazeMutation.js';
43
+ export { dehydrateBlazeQueryClient, hydrateBlazeQueryClient } from './hydration.js';
44
+ export type { DehydrateBlazeOptions, HydrateBlazeOptions } from './hydration.js';
45
+ export type { BlazeMirrorEntry, BlazeMirrorOptions, BlazeQueryCacheLike, BlazeQueryClientOptions, BlazeQueryFilters, BlazeQueryRecord, BlazeQuerySyncOptions, } from './types.js';
30
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,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AAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,18 @@
1
1
  /**
2
2
  * TanStack Query (v5) integration backed by Blaze Cache.
3
3
  *
4
- * Two independent pieces:
4
+ * Three independent pieces:
5
5
  *
6
6
  * * {@link syncBlazeQueryCache} / {@link createBlazeQueryClient} — mirror successful queries
7
7
  * so they survive a reload.
8
- * * {@link useBlazeQuery} — a `useQuery` that seeds `initialData` from that mirror, giving
9
- * an instant first paint while TanStack still refetches in the background.
8
+ * * Hooks that seed from that mirror: {@link useBlazeQuery}, {@link useBlazeInfiniteQuery}
9
+ * and {@link useBlazeQueries} paint instantly from persisted data while TanStack still
10
+ * refetches in the background; {@link useBlazeMutation} invalidates both caches after a
11
+ * successful mutation.
12
+ * * Imperative helpers that keep both caches in step without a hook:
13
+ * {@link prefetchBlazeQuery}, {@link setBlazeQueryData}, {@link invalidateBlazeQueries},
14
+ * {@link removeBlazeQueries}, and the persistence round trip
15
+ * {@link dehydrateBlazeQueryClient} / {@link hydrateBlazeQueryClient}.
10
16
  *
11
17
  * ```tsx
12
18
  * const cache = await createCache();
@@ -24,6 +30,12 @@
24
30
  * @packageDocumentation
25
31
  */
26
32
  export { createBlazeQueryClient, syncBlazeQueryCache } from './sync.js';
33
+ export { isMirrorRecord } from './record.js';
27
34
  export { hashQueryKey, resolveQueryHash } from './hash.js';
28
- export { seedBlazeQueryOptions, useBlazeQuery } from './useBlazeQuery.js';
35
+ export { readBlazeRecord, seedBlazeQueryOptions, useBlazeQuery } from './useBlazeQuery.js';
36
+ export { seedBlazeInfiniteQueryOptions, useBlazeInfiniteQuery, } from './useBlazeInfiniteQuery.js';
37
+ export { seedBlazeQueriesOptions, useBlazeQueries } from './useBlazeQueries.js';
38
+ export { invalidateBlazeQueries, prefetchBlazeQuery, removeBlazeQueries, setBlazeQueryData, } from './imperative.js';
39
+ export { useBlazeMutation } from './useBlazeMutation.js';
40
+ export { dehydrateBlazeQueryClient, hydrateBlazeQueryClient } from './hydration.js';
29
41
  //# 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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { BlazeQueryRecord } from './types.js';
2
+ /**
3
+ * Shape check: is this value a record **this package** could have written?
4
+ *
5
+ * Every record the sync layer and the imperative helpers write carries `dataUpdatedAt`,
6
+ * TanStack's own timestamp — and nothing the *other* integrations store on a shared cache
7
+ * does. Axios and fetch records are stamped `storedAt`/`freshUntil`, SWR persists raw
8
+ * fetcher results, and manual entries are whatever the app put there.
9
+ *
10
+ * The check exists for the shared-cache reality a single-package type cannot see: it
11
+ * keeps a mirror read from handing a foreign value to TanStack as query data, and the
12
+ * unfiltered purge from reading foreign entries as its own. The one unavoidable false
13
+ * positive is an app value that happens to carry a numeric `dataUpdatedAt`.
14
+ */
15
+ export declare function isMirrorRecord(value: unknown): value is BlazeQueryRecord;
16
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAMxE"}
package/dist/record.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Shape check: is this value a record **this package** could have written?
3
+ *
4
+ * Every record the sync layer and the imperative helpers write carries `dataUpdatedAt`,
5
+ * TanStack's own timestamp — and nothing the *other* integrations store on a shared cache
6
+ * does. Axios and fetch records are stamped `storedAt`/`freshUntil`, SWR persists raw
7
+ * fetcher results, and manual entries are whatever the app put there.
8
+ *
9
+ * The check exists for the shared-cache reality a single-package type cannot see: it
10
+ * keeps a mirror read from handing a foreign value to TanStack as query data, and the
11
+ * unfiltered purge from reading foreign entries as its own. The one unavoidable false
12
+ * positive is an app value that happens to carry a numeric `dataUpdatedAt`.
13
+ */
14
+ export function isMirrorRecord(value) {
15
+ return (typeof value === 'object' &&
16
+ value !== null &&
17
+ typeof value.dataUpdatedAt === 'number');
18
+ }
19
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAAqC,CAAC,aAAa,KAAK,QAAQ,CACzE,CAAC;AACJ,CAAC"}
package/dist/sync.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
2
  import type { BlazeQueryClientOptions, BlazeQuerySyncOptions } from './types.js';
3
+ /** Mirrored data survives this long in the Blaze Cache (TanStack owns in-session freshness). */
4
+ export declare const DEFAULT_TTL_MS = 86400000;
5
+ /** Default tag, so `cache.invalidateTags('react-query')` purges the whole mirror. */
6
+ export declare const DEFAULT_TAGS: readonly string[];
3
7
  /**
4
8
  * Mirrors TanStack Query's cache into a Blaze Cache.
5
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAOjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,qBAAqB,GAC7B,MAAM,IAAI,CAsFZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,CAKpF"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEjF,gGAAgG;AAChG,eAAO,MAAM,cAAc,WAAa,CAAC;AACzC,qFAAqF;AACrF,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAoB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,qBAAqB,GAC7B,MAAM,IAAI,CAgHZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,CAKpF"}
package/dist/sync.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
2
  /** Mirrored data survives this long in the Blaze Cache (TanStack owns in-session freshness). */
3
- const DEFAULT_TTL_MS = 86_400_000;
3
+ export const DEFAULT_TTL_MS = 86_400_000;
4
4
  /** Default tag, so `cache.invalidateTags('react-query')` purges the whole mirror. */
5
- const DEFAULT_TAGS = ['react-query'];
5
+ export const DEFAULT_TAGS = ['react-query'];
6
6
  /**
7
7
  * Mirrors TanStack Query's cache into a Blaze Cache.
8
8
  *
@@ -113,7 +113,26 @@ export function syncBlazeQueryCache(client, options) {
113
113
  return;
114
114
  if (options.skip?.(query.queryKey, hash))
115
115
  return;
116
- cache.set(hash, { data, dataUpdatedAt: query.state.dataUpdatedAt }, { ttlMs, tags });
116
+ // An identical record is already in the mirror — the imperative helpers
117
+ // (`setBlazeQueryData`, `prefetchBlazeQuery`, `hydrateBlazeQueryClient`) write theirs
118
+ // synchronously, ahead of this batched flush. Skip so *their* `ttlMs`/`tags` survive:
119
+ // re-writing here would re-stamp the entry with the sync's defaults and silently strip
120
+ // a per-query tag. Same data reference and same timestamp means nothing actually
121
+ // changed, so skipping loses nothing but the redundant write.
122
+ const existing = cache.peek ? cache.peek(hash) : undefined;
123
+ if (existing &&
124
+ existing.data === data &&
125
+ existing.dataUpdatedAt === query.state.dataUpdatedAt) {
126
+ return;
127
+ }
128
+ // `queryKey` (and `queryType` for infinite queries) make the record self-describing:
129
+ // dehydrate needs them to rebuild a TanStack query from the mirror alone.
130
+ cache.set(hash, {
131
+ data,
132
+ dataUpdatedAt: query.state.dataUpdatedAt,
133
+ queryKey: query.queryKey,
134
+ ...(query.queryType === 'infinite' ? { queryType: 'infinite' } : null),
135
+ }, { ttlMs, tags });
117
136
  });
118
137
  return () => {
119
138
  unsubscribe();
package/dist/sync.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD,gGAAgG;AAChG,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,qFAAqF;AACrF,MAAM,YAAY,GAAsB,CAAC,aAAa,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAmB,EACnB,OAA8B;IAE9B,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC;IAE1C,0FAA0F;IAC1F,IAAI,eAAe,GAAG,KAAK,CAAC;IAE5B,sFAAsF;IACtF,yFAAyF;IACzF,mEAAmE;IACnE,MAAM,qBAAqB,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvF,MAAM,aAAa,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvE,0FAA0F;IAC1F,qEAAqE;IACrE,MAAM,qBAAqB,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAErD,CAAC;IACV,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhD,MAAM,oBAAoB,GAAgC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,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC,CAAC;IAC9C,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,13 +1,40 @@
1
- import type { QueryClientConfig, QueryKey } from '@tanstack/react-query';
1
+ import type { QueryClientConfig, QueryFilters, QueryKey } from '@tanstack/react-query';
2
2
  /**
3
3
  * What the integration stores for one query.
4
4
  *
5
5
  * `dataUpdatedAt` is TanStack's own timestamp, so a restored entry feeds its staleness
6
6
  * arithmetic exactly as if the fetch had happened in this session.
7
+ *
8
+ * `queryKey` is written by {@link syncBlazeQueryCache} and the imperative helpers so a
9
+ * mirror entry is self-describing: {@link dehydrateBlazeQueryClient} needs it to rebuild
10
+ * a TanStack query from the mirror alone. Optional because entries written by older
11
+ * versions of this package do not carry it — those still hydrate the hooks, they just
12
+ * cannot be dehydrated back into TanStack.
7
13
  */
8
14
  export interface BlazeQueryRecord<T = unknown> {
9
15
  data: T;
10
16
  dataUpdatedAt: number;
17
+ queryKey?: QueryKey;
18
+ /**
19
+ * `'infinite'` for infinite queries, absent for plain ones — the same `_type` TanStack
20
+ * stamps on the query itself, so {@link dehydrateBlazeQueryClient} can rebuild an infinite
21
+ * query as one. Written by the sync layer and the imperative helpers for records that
22
+ * carry `queryKey`; absent (meaning: plain) on older records.
23
+ */
24
+ queryType?: 'infinite';
25
+ }
26
+ /**
27
+ * One live mirror entry as {@link BlazeQueryCacheLike.entries} reports it.
28
+ *
29
+ * Structurally a subset of the concrete cache's `CacheEntry`, so `cache.entries()` is
30
+ * assignable without ceremony.
31
+ */
32
+ export interface BlazeMirrorEntry {
33
+ /** The query hash the record is filed under — a `DehydratedQuery.queryHash`. */
34
+ key: string;
35
+ value: BlazeQueryRecord;
36
+ /** Tags attached to this entry, for tag-filtered purges and dehydration. */
37
+ readonly tags: readonly string[];
11
38
  }
12
39
  /**
13
40
  * The slice of a cache the integration needs.
@@ -35,6 +62,29 @@ export interface BlazeQueryCacheLike {
35
62
  }): void;
36
63
  delete(key: string): boolean;
37
64
  has(key: string): boolean;
65
+ /**
66
+ * Removes every entry carrying any of `tags`, returning the removed keys.
67
+ *
68
+ * Not called by this package: the purge helpers enumerate {@link BlazeQueryCacheLike.entries}
69
+ * instead (or throw when it is absent), so a purge on a cache shared with another
70
+ * integration stays on mirror records — `invalidateTags` reaches the whole tag namespace,
71
+ * all integrations included. It remains part of the cache contract for callers who want
72
+ * exactly that.
73
+ */
74
+ invalidateTags?(...tags: string[]): string[];
75
+ /**
76
+ * Every live entry — key, record and tags — without touching statistics.
77
+ *
78
+ * Optional, like {@link BlazeQueryCacheLike.peek} and
79
+ * {@link BlazeQueryCacheLike.invalidateTags}: enumerating the mirror is what lets the
80
+ * filter-aware helpers ({@link invalidateBlazeQueries}, {@link removeBlazeQueries},
81
+ * {@link dehydrateBlazeQueryClient}) match entries the current session's TanStack cache
82
+ * never touched — a prefix purge after a user switch, a full-mirror wipe, a dehydration
83
+ * of everything persisted. When a filter needs enumeration and it is absent, those
84
+ * helpers **throw** instead of silently purging only what TanStack happens to know right
85
+ * now. The concrete `BlazeCache` has it as `entries()`.
86
+ */
87
+ entries?(): BlazeMirrorEntry[];
38
88
  }
39
89
  /** Options for {@link syncBlazeQueryCache} and {@link createBlazeQueryClient}. */
40
90
  export interface BlazeQuerySyncOptions {
@@ -58,4 +108,28 @@ export interface BlazeQueryClientOptions extends BlazeQuerySyncOptions {
58
108
  /** Options handed to `new QueryClient(...)` — its own `queryCache` is respected. */
59
109
  client?: QueryClientConfig;
60
110
  }
111
+ /** How an imperative helper writes into the Blaze Cache alongside TanStack Query. */
112
+ export interface BlazeMirrorOptions {
113
+ /** TTL for the mirror entry. Defaults to the same 24 h the sync layer uses. */
114
+ ttlMs?: number;
115
+ /** Tags for the mirror entry. Defaults to `['react-query']`. */
116
+ tags?: readonly string[];
117
+ }
118
+ /**
119
+ * A `QueryFilters` with an extra Blaze tag selector.
120
+ *
121
+ * `tags` matches mirror entries through {@link BlazeQueryCacheLike}-style tag lookup on
122
+ * the concrete cache (`cache.invalidateTags` / `cache.keysWithTag`). When both a
123
+ * `queryKey`/`predicate` and `tags` are given, a query must match **both**.
124
+ */
125
+ export interface BlazeQueryFilters extends QueryFilters {
126
+ /** Invalidate/remove mirror entries carrying any of these tags. */
127
+ tags?: readonly string[];
128
+ /**
129
+ * Which queries to refetch when invalidating — forwarded to TanStack's
130
+ * `invalidateQueries`, ignored by `removeQueries` (removed queries refetch only when a
131
+ * hook asks for them again).
132
+ */
133
+ refetchType?: 'active' | 'inactive' | 'all' | 'none';
134
+ }
61
135
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,IAAI,EAAE,CAAC,CAAC;IACR,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;IAC/C;;;;;;;;;OASG;IACH,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;IACjD,GAAG,CACD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GACrD,IAAI,CAAC;IACR,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B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EAAE,CAAC;IACzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;CACtD"}
@@ -0,0 +1,46 @@
1
+ import type { DefaultError, InfiniteData, QueryClient, QueryKey, UseInfiniteQueryOptions, UseInfiniteQueryResult } from '@tanstack/react-query';
2
+ import type { BlazeQueryCacheLike } from './types.js';
3
+ /**
4
+ * The options {@link useBlazeInfiniteQuery} hands to `useInfiniteQuery`: the caller's
5
+ * options with the Blaze Cache mirror seeded in, or the caller's options returned
6
+ * untouched.
7
+ *
8
+ * Infinite queries are mirrored as a whole — TanStack stores `InfiniteData` (every page
9
+ * plus its page params) as one `query.state.data`, so the sync layer persists that one
10
+ * object and this function seeds it straight back as `initialData`. The first render
11
+ * after a reload therefore paints **all previously loaded pages at once**, while
12
+ * `dataUpdatedAt` carries the original timestamp so TanStack still refetches in the
13
+ * background.
14
+ *
15
+ * The rules are exactly {@link seedBlazeQueryOptions}'s, deliberately:
16
+ *
17
+ * * A caller-supplied `initialData` or `initialDataUpdatedAt` is authoritative — the
18
+ * mirror stays out of it entirely.
19
+ * * With neither supplied, the mirror seeds both fields together, so the data paints
20
+ * instantly *and* is treated as stale.
21
+ */
22
+ export declare function seedBlazeInfiniteQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(cache: BlazeQueryCacheLike, client: QueryClient, options: UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>;
23
+ /**
24
+ * `useInfiniteQuery` that starts from the Blaze Cache.
25
+ *
26
+ * A previously mirrored `InfiniteData` payload — every page and page param fetched in an
27
+ * earlier session — is injected as `initialData` **with its original `dataUpdatedAt`**,
28
+ * so the list paints fully populated on the first render after a reload while TanStack
29
+ * still considers it stale and refetches in the background. Caller-supplied
30
+ * `initialData`/`initialDataUpdatedAt` short-circuit the seeding entirely; see
31
+ * {@link seedBlazeInfiniteQueryOptions}.
32
+ *
33
+ * ```tsx
34
+ * const feed = useBlazeInfiniteQuery(cache, {
35
+ * queryKey: ['feed', userId],
36
+ * queryFn: ({ pageParam }) => fetchFeed(userId, pageParam),
37
+ * initialPageParam: 0,
38
+ * getNextPageParam: (lastPage) => lastPage.nextCursor,
39
+ * });
40
+ * // feed.data?.pages — the pages cached before the reload, immediately
41
+ * ```
42
+ *
43
+ * Requires a `QueryClientProvider` above it, exactly like `useInfiniteQuery`.
44
+ */
45
+ export declare function useBlazeInfiniteQuery<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(cache: BlazeQueryCacheLike, options: UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>): UseInfiniteQueryResult<TData, TError>;
46
+ //# sourceMappingURL=useBlazeInfiniteQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBlazeInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/useBlazeInfiniteQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,EAClC,SAAS,SAAS,QAAQ,GAAG,QAAQ,EACrC,UAAU,GAAG,OAAO,EAEpB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,GACnF,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAkB7E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,CAAC,YAAY,CAAC,EAClC,SAAS,SAAS,QAAQ,GAAG,QAAQ,EACrC,UAAU,GAAG,OAAO,EAEpB,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,GACnF,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAMvC"}