@buoy-gg/react-query 4.0.1 → 5.0.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/lib/commonjs/react-query/sync/reactQuerySyncAdapter.js +41 -0
- package/lib/module/react-query/sync/reactQuerySyncAdapter.js +41 -0
- package/lib/typescript/react-query/sync/reactQuerySyncAdapter.d.ts +23 -0
- package/lib/typescript/react-query/sync/reactQuerySyncAdapter.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createReactQuerySyncAdapter = createReactQuerySyncAdapter;
|
|
7
7
|
var _reactQuery = require("@tanstack/react-query");
|
|
8
8
|
var _dehydrate = require("./dehydrate");
|
|
9
|
+
var _getQueryStatusLabel = require("../utils/getQueryStatusLabel");
|
|
9
10
|
/**
|
|
10
11
|
* Sync adapter for the React Query tool, consumed by @buoy-gg/external-sync's
|
|
11
12
|
* `useExternalSync` (structurally matches its ToolSyncAdapter interface so
|
|
@@ -45,6 +46,46 @@ function createReactQuerySyncAdapter(queryClient) {
|
|
|
45
46
|
};
|
|
46
47
|
},
|
|
47
48
|
actions: {
|
|
49
|
+
/**
|
|
50
|
+
* Compact, token-bounded cache reader for a remote driver (MCP/LLM):
|
|
51
|
+
* projects each live query to light fields (hash, key, status label,
|
|
52
|
+
* staleness, observers, error message) — the heavy cached `data` stays on
|
|
53
|
+
* the device unless `includeData` is set. Unlike getSnapshot (full
|
|
54
|
+
* dehydrated cache), this is safe to read repeatedly.
|
|
55
|
+
*/
|
|
56
|
+
listQueries: params => {
|
|
57
|
+
const {
|
|
58
|
+
includeData = false,
|
|
59
|
+
staleOnly = false,
|
|
60
|
+
limit
|
|
61
|
+
} = params ?? {};
|
|
62
|
+
const all = queryClient.getQueryCache().getAll();
|
|
63
|
+
const filtered = staleOnly ? all.filter(q => q.isStale()) : all;
|
|
64
|
+
const sorted = [...filtered].sort((a, b) => (b.state.dataUpdatedAt ?? 0) - (a.state.dataUpdatedAt ?? 0));
|
|
65
|
+
const capped = typeof limit === "number" && limit > 0 ? sorted.slice(0, limit) : sorted;
|
|
66
|
+
const queries = capped.map(q => {
|
|
67
|
+
const err = q.state.error;
|
|
68
|
+
return {
|
|
69
|
+
queryHash: q.queryHash,
|
|
70
|
+
queryKey: q.queryKey,
|
|
71
|
+
status: (0, _getQueryStatusLabel.getQueryStatusLabel)(q),
|
|
72
|
+
fetchStatus: q.state.fetchStatus,
|
|
73
|
+
isStale: q.isStale(),
|
|
74
|
+
observers: q.getObserversCount(),
|
|
75
|
+
updatedAt: q.state.dataUpdatedAt,
|
|
76
|
+
error: err ? err.message ?? String(err) : undefined,
|
|
77
|
+
...(includeData ? {
|
|
78
|
+
data: q.state.data
|
|
79
|
+
} : {})
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
queries,
|
|
84
|
+
total: all.length,
|
|
85
|
+
returned: queries.length,
|
|
86
|
+
includedData: includeData
|
|
87
|
+
};
|
|
88
|
+
},
|
|
48
89
|
refetch: params => {
|
|
49
90
|
const query = getQuery(params);
|
|
50
91
|
// Swallow fetch rejections — the resulting error state syncs anyway
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { onlineManager } from "@tanstack/react-query";
|
|
14
14
|
import { dehydrateQueryClient } from "./dehydrate";
|
|
15
|
+
import { getQueryStatusLabel } from "../utils/getQueryStatusLabel";
|
|
15
16
|
export function createReactQuerySyncAdapter(queryClient) {
|
|
16
17
|
const getQuery = params => {
|
|
17
18
|
const {
|
|
@@ -40,6 +41,46 @@ export function createReactQuerySyncAdapter(queryClient) {
|
|
|
40
41
|
};
|
|
41
42
|
},
|
|
42
43
|
actions: {
|
|
44
|
+
/**
|
|
45
|
+
* Compact, token-bounded cache reader for a remote driver (MCP/LLM):
|
|
46
|
+
* projects each live query to light fields (hash, key, status label,
|
|
47
|
+
* staleness, observers, error message) — the heavy cached `data` stays on
|
|
48
|
+
* the device unless `includeData` is set. Unlike getSnapshot (full
|
|
49
|
+
* dehydrated cache), this is safe to read repeatedly.
|
|
50
|
+
*/
|
|
51
|
+
listQueries: params => {
|
|
52
|
+
const {
|
|
53
|
+
includeData = false,
|
|
54
|
+
staleOnly = false,
|
|
55
|
+
limit
|
|
56
|
+
} = params ?? {};
|
|
57
|
+
const all = queryClient.getQueryCache().getAll();
|
|
58
|
+
const filtered = staleOnly ? all.filter(q => q.isStale()) : all;
|
|
59
|
+
const sorted = [...filtered].sort((a, b) => (b.state.dataUpdatedAt ?? 0) - (a.state.dataUpdatedAt ?? 0));
|
|
60
|
+
const capped = typeof limit === "number" && limit > 0 ? sorted.slice(0, limit) : sorted;
|
|
61
|
+
const queries = capped.map(q => {
|
|
62
|
+
const err = q.state.error;
|
|
63
|
+
return {
|
|
64
|
+
queryHash: q.queryHash,
|
|
65
|
+
queryKey: q.queryKey,
|
|
66
|
+
status: getQueryStatusLabel(q),
|
|
67
|
+
fetchStatus: q.state.fetchStatus,
|
|
68
|
+
isStale: q.isStale(),
|
|
69
|
+
observers: q.getObserversCount(),
|
|
70
|
+
updatedAt: q.state.dataUpdatedAt,
|
|
71
|
+
error: err ? err.message ?? String(err) : undefined,
|
|
72
|
+
...(includeData ? {
|
|
73
|
+
data: q.state.data
|
|
74
|
+
} : {})
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
queries,
|
|
79
|
+
total: all.length,
|
|
80
|
+
returned: queries.length,
|
|
81
|
+
includedData: includeData
|
|
82
|
+
};
|
|
83
|
+
},
|
|
43
84
|
refetch: params => {
|
|
44
85
|
const query = getQuery(params);
|
|
45
86
|
// Swallow fetch rejections — the resulting error state syncs anyway
|
|
@@ -17,6 +17,29 @@ export declare function createReactQuerySyncAdapter(queryClient: QueryClient): {
|
|
|
17
17
|
};
|
|
18
18
|
subscribe: (onChange: () => void) => () => void;
|
|
19
19
|
actions: {
|
|
20
|
+
/**
|
|
21
|
+
* Compact, token-bounded cache reader for a remote driver (MCP/LLM):
|
|
22
|
+
* projects each live query to light fields (hash, key, status label,
|
|
23
|
+
* staleness, observers, error message) — the heavy cached `data` stays on
|
|
24
|
+
* the device unless `includeData` is set. Unlike getSnapshot (full
|
|
25
|
+
* dehydrated cache), this is safe to read repeatedly.
|
|
26
|
+
*/
|
|
27
|
+
listQueries: (params: unknown) => {
|
|
28
|
+
queries: {
|
|
29
|
+
data?: unknown;
|
|
30
|
+
queryHash: string;
|
|
31
|
+
queryKey: readonly unknown[];
|
|
32
|
+
status: "error" | "fetching" | "paused" | "disabled" | "inactive" | "stale" | "fresh";
|
|
33
|
+
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
34
|
+
isStale: boolean;
|
|
35
|
+
observers: number;
|
|
36
|
+
updatedAt: number;
|
|
37
|
+
error: string | undefined;
|
|
38
|
+
}[];
|
|
39
|
+
total: number;
|
|
40
|
+
returned: number;
|
|
41
|
+
includedData: boolean;
|
|
42
|
+
};
|
|
20
43
|
refetch: (params: unknown) => Promise<unknown>;
|
|
21
44
|
invalidate: (params: unknown) => Promise<void>;
|
|
22
45
|
reset: (params: unknown) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactQuerySyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/react-query/sync/reactQuerySyncAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAiB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"reactQuerySyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/react-query/sync/reactQuerySyncAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAiB,KAAK,WAAW,EAAiB,MAAM,uBAAuB,CAAC;AA0BvF,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW;;;;;;0BAgB1C,MAAM,IAAI;;QAa9B;;;;;;WAMG;8BACmB,OAAO;;;;;;;;;;;;;;;;0BAkCX,OAAO;6BAKJ,OAAO;wBAEZ,OAAO;yBACN,OAAO;+BAGD,OAAO;+BAIP,OAAO;+BAaP,OAAO;iCAEL,OAAO;iCAwBP,OAAO;;;4BA4BZ,OAAO;;EAMhC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/react-query",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "react-query package",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@buoy-gg/
|
|
30
|
-
"@buoy-gg/
|
|
29
|
+
"@buoy-gg/shared-ui": "5.0.0",
|
|
30
|
+
"@buoy-gg/floating-tools-core": "5.0.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@tanstack/react-query": ">=5.0.0",
|