@blaze-cache/react-query 0.3.0-beta.0 → 0.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +25 -3
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -71,9 +71,11 @@ up with TanStack's own hashing, so a custom `queryKeyHashFn` is honoured.
71
71
 
72
72
  ## API
73
73
 
74
- The integration is one cache + a set of hooks, helpers and hydration functions. All of
75
- them take `(cache, client?, options?)` — the cache first, then the `QueryClient` (from
76
- context when omitted by a hook), then the options.
74
+ The integration is one cache + a set of hooks, helpers and hydration functions. The
75
+ hooks take `(cache, options)` with the `QueryClient` from context when omitted; the
76
+ imperative helpers and the seed/read functions take `(cache, client, …)` with the
77
+ client explicit. `hashQueryKey`, `resolveQueryHash` and `isMirrorRecord` work from a
78
+ query key, a `QueryClient` and a plain value — no cache needed.
77
79
 
78
80
  | Export | What it does |
79
81
  | --- | --- |
@@ -82,6 +84,11 @@ context when omitted by a hook), then the options.
82
84
  | `useBlazeInfiniteQuery` | `useInfiniteQuery` seeded with the whole `InfiniteData` (all pages) as `initialData` — only for `InfiniteData`-shaped records; a plain record under the key is left unseeded. |
83
85
  | `useBlazeQueries` | `useQueries` over several keys, each seeded independently. |
84
86
  | `useBlazeMutation` | `useMutation` that invalidates queries after success. |
87
+ | `seedBlazeQueryOptions` / `seedBlazeInfiniteQueryOptions` / `seedBlazeQueriesOptions` | The seeding the hooks do, as options transforms you can call yourself: fill `initialData` + `initialDataUpdatedAt` from the mirror — an explicit `initialData` always wins, and the infinite one only seeds `InfiniteData`-shaped records. |
88
+ | `readBlazeRecord` | The lookup every seed shares: resolve the hash the way TanStack does, `peek` over `get` (a render must not skew stats) and accept only records this package could have written. |
89
+ | `resolveQueryHash` | The hash TanStack will file a query under — an explicit `queryHash`, then the configured `queryKeyHashFn` (per-query, `setQueryDefaults` or client defaults), else the default hasher. |
90
+ | `hashQueryKey` | TanStack's own canonical hash for a query key. |
91
+ | `isMirrorRecord` | Shape guard: does this value carry a numeric `dataUpdatedAt` — is it a record the sync layer could have written? |
85
92
  | `prefetchBlazeQuery` | Imperatively seed + prefetch, mirroring the fetched result. |
86
93
  | `setBlazeQueryData` | Write data through to the mirror (TanStack first, then Blaze). |
87
94
  | `invalidateBlazeQueries` | Invalidate in TanStack **and** purge the mirror. |
@@ -199,6 +206,21 @@ hydrateBlazeQueryClient(cache, queryClient, dehydratedState, {
199
206
  });
200
207
  ```
201
208
 
209
+ ## Testing
210
+
211
+ ```sh
212
+ pnpm --filter @blaze-cache/react-query test # offline — stubbed fetcher, no network
213
+ pnpm --filter @blaze-cache/react-query test:live # live — real public API, needs the network
214
+ ```
215
+
216
+ The offline suite drives real `QueryClient`s against stubbed fetchers, exercising the
217
+ mirror exactly as TanStack drives it. The live suite (4 tests) swaps in the real
218
+ `globalThis.fetch` against `api.github.com`, proving a real `queryFn` result is mirrored
219
+ under TanStack's own hash, a second prefetch inside `staleTime` never reaches the
220
+ network, a dehydrate → hydrate round trip restores the mirror with zero network calls,
221
+ and an aborted fetch mirrors nothing. Every live test is skipped unless
222
+ `BLAZE_CACHE_LIVE=1` is set, so the default suite always runs offline.
223
+
202
224
  ## Documentation
203
225
 
204
226
  Setup and the full integration reference live in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cache/react-query",
3
- "version": "0.3.0-beta.0",
3
+ "version": "0.3.0-beta.1",
4
4
  "description": "Persist TanStack Query v5 in WebAssembly — instant first paint after reload while stale-while-revalidate still works",
5
5
  "keywords": [
6
6
  "react-query",
@@ -38,7 +38,7 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@blaze-cache/core": "0.3.0-beta.0"
41
+ "@blaze-cache/core": "0.3.0-beta.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@tanstack/react-query": "^5.0.0"
@@ -50,6 +50,7 @@
50
50
  "scripts": {
51
51
  "build": "tsc -p tsconfig.json",
52
52
  "test": "pnpm run build && node --test",
53
- "typecheck": "tsc -p tsconfig.typecheck.json"
53
+ "typecheck": "tsc -p tsconfig.typecheck.json",
54
+ "test:live": "pnpm run build && BLAZE_CACHE_LIVE=1 node --test test/live.test.mjs"
54
55
  }
55
56
  }