@rozenite/tanstack-query-plugin 2.1.0 → 2.3.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/CHANGELOG.md +24 -0
- package/dist/devtools/assets/{CXEL7IU7-BWccRGN3.js → CXEL7IU7-D2MCp9XC.js} +1 -1
- package/dist/devtools/assets/{tanstack-query-CbF_imft.js → tanstack-query-Bk8rHBM2.js} +12 -12
- package/dist/devtools/tanstack-query.html +1 -1
- package/dist/react-native/cjs/package.json +3 -0
- package/dist/react-native/cjs/react-native.js +12 -0
- package/dist/react-native/cjs/src/react-native/agent/tanstack-query-agent.js +376 -0
- package/dist/react-native/cjs/src/react-native/agent/useTanStackQueryAgentTools.js +98 -0
- package/dist/react-native/cjs/src/react-native/devtools-actions.js +161 -0
- package/dist/react-native/cjs/src/react-native/useHandleDevToolsMessages.js +26 -0
- package/dist/react-native/cjs/src/react-native/useHandleInitialData.js +26 -0
- package/dist/react-native/cjs/src/react-native/useSyncTanStackCache.js +203 -0
- package/dist/react-native/cjs/src/react-native/useTanStackQueryDevTools.js +20 -0
- package/dist/react-native/cjs/src/shared/agent-tools.js +197 -0
- package/dist/react-native/cjs/src/shared/dehydrate.js +35 -0
- package/dist/react-native/cjs/src/shared/messaging.js +2 -0
- package/dist/react-native/cjs/src/shared/types.js +2 -0
- package/dist/react-native/cjs/src/shared/useSyncOnlineStatus.js +23 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/react-native.d.ts +1 -0
- package/dist/react-native/react-native.js +10 -0
- package/dist/{sdk/index.d.ts → react-native/src/react-native/agent/tanstack-query-agent.d.ts} +2105 -1939
- package/dist/react-native/src/react-native/agent/tanstack-query-agent.js +370 -0
- package/dist/react-native/src/react-native/agent/useTanStackQueryAgentTools.d.ts +2 -0
- package/dist/react-native/src/react-native/agent/useTanStackQueryAgentTools.js +94 -0
- package/dist/react-native/src/react-native/devtools-actions.d.ts +115 -0
- package/dist/react-native/src/react-native/devtools-actions.js +157 -0
- package/dist/react-native/src/react-native/useHandleDevToolsMessages.d.ts +3 -0
- package/dist/react-native/src/react-native/useHandleDevToolsMessages.js +22 -0
- package/dist/react-native/src/react-native/useHandleInitialData.d.ts +3 -0
- package/dist/react-native/src/react-native/useHandleInitialData.js +22 -0
- package/dist/react-native/src/react-native/useSyncTanStackCache.d.ts +3 -0
- package/dist/react-native/src/react-native/useSyncTanStackCache.js +196 -0
- package/dist/react-native/src/react-native/useTanStackQueryDevTools.d.ts +2 -0
- package/dist/react-native/src/react-native/useTanStackQueryDevTools.js +16 -0
- package/dist/react-native/src/shared/agent-tools.d.ts +967 -0
- package/dist/react-native/src/shared/agent-tools.js +194 -0
- package/dist/react-native/src/shared/dehydrate.d.ts +6 -0
- package/dist/react-native/src/shared/dehydrate.js +28 -0
- package/dist/react-native/src/shared/messaging.d.ts +44 -0
- package/dist/react-native/src/shared/messaging.js +1 -0
- package/dist/react-native/src/shared/types.d.ts +25 -0
- package/dist/react-native/src/shared/types.js +1 -0
- package/dist/react-native/src/shared/useSyncOnlineStatus.d.ts +2 -0
- package/dist/react-native/src/shared/useSyncOnlineStatus.js +19 -0
- package/dist/rozenite.json +1 -1
- package/dist/sdk/package.json +3 -0
- package/dist/sdk/sdk.d.ts +812 -0
- package/dist/sdk/sdk.js +8 -0
- package/dist/sdk/src/react-native/devtools-actions.d.ts +115 -0
- package/dist/sdk/src/react-native/devtools-actions.js +161 -0
- package/dist/sdk/src/shared/agent-tools.d.ts +967 -0
- package/dist/sdk/src/shared/agent-tools.js +197 -0
- package/dist/sdk/src/shared/types.d.ts +25 -0
- package/dist/sdk/src/shared/types.js +2 -0
- package/package.json +18 -18
- package/react-native.ts +8 -1
- package/rozenite.config.ts +1 -0
- package/src/__tests__/release-bundle.test.ts +32 -0
- package/tsconfig.json +1 -3
- package/dist/react-native/chunks/useTanStackQueryDevTools.require.cjs +0 -1
- package/dist/react-native/chunks/useTanStackQueryDevTools.require.js +0 -895
- package/dist/react-native/index.cjs +0 -1
- package/dist/react-native/index.d.ts +0 -7
- package/dist/react-native/index.js +0 -6
- package/dist/sdk/index.cjs +0 -1
- package/dist/sdk/index.js +0 -199
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHandleDevToolsMessages = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const devtools_actions_1 = require("./devtools-actions");
|
|
6
|
+
const useHandleDevToolsMessages = (queryClient, client) => {
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
if (!client) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const subscription = client.onMessage('devtools-action', ({ type, queryHash, metadata }) => {
|
|
12
|
+
void (0, devtools_actions_1.applyTanStackQueryDevtoolsAction)(queryClient, {
|
|
13
|
+
type,
|
|
14
|
+
queryHash,
|
|
15
|
+
metadata,
|
|
16
|
+
}).catch((error) => {
|
|
17
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
18
|
+
console.warn(`[Rozenite, tanstack-query-plugin] Failed to apply devtools action "${type}": ${message}`);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return () => {
|
|
22
|
+
subscription.remove();
|
|
23
|
+
};
|
|
24
|
+
}, [client]);
|
|
25
|
+
};
|
|
26
|
+
exports.useHandleDevToolsMessages = useHandleDevToolsMessages;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHandleInitialData = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const dehydrate_1 = require("../shared/dehydrate");
|
|
6
|
+
const useHandleInitialData = (queryClient, client) => {
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
if (!client) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const subscription = client.onMessage('request-initial-data', () => {
|
|
12
|
+
const dehydratedState = (0, dehydrate_1.dehydrateQueryClient)(queryClient);
|
|
13
|
+
client.send('sync-data', { data: dehydratedState });
|
|
14
|
+
});
|
|
15
|
+
// This hook runs last in `useTanStackQueryDevTools`, so by the time the
|
|
16
|
+
// panel reacts to this every handler is listening. The panel is recreated on
|
|
17
|
+
// every app reload and asks for the cache as soon as it boots, which usually
|
|
18
|
+
// beats the app's React tree to the punch; without this its only request is
|
|
19
|
+
// dropped and the panel stays empty until the app is restarted.
|
|
20
|
+
client.send('device-ready', {});
|
|
21
|
+
return () => {
|
|
22
|
+
subscription.remove();
|
|
23
|
+
};
|
|
24
|
+
}, [client, queryClient]);
|
|
25
|
+
};
|
|
26
|
+
exports.useHandleInitialData = useHandleInitialData;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useSyncTanStackCache = void 0;
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
9
|
+
const dehydrate_1 = require("../shared/dehydrate");
|
|
10
|
+
const useSyncTanStackCache = (queryClient, client) => {
|
|
11
|
+
const previousObserversRef = (0, react_1.useRef)(new Map());
|
|
12
|
+
const handler = (0, react_1.useMemo)(() => {
|
|
13
|
+
return (event) => {
|
|
14
|
+
if (!client) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (event.type === 'observerResultsUpdated') {
|
|
18
|
+
// We don't need to sync this type of events.
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if ('query' in event) {
|
|
22
|
+
const { query, type } = event;
|
|
23
|
+
if (type === 'added' || type === 'removed') {
|
|
24
|
+
if (type === 'removed') {
|
|
25
|
+
// We don't need to store observers for removed queries.
|
|
26
|
+
previousObserversRef.current.delete(query.queryHash);
|
|
27
|
+
}
|
|
28
|
+
const dehydratedQuery = (0, dehydrate_1.dehydrateQuery)(query);
|
|
29
|
+
client.send('sync-query-event', { type, data: dehydratedQuery });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (type === 'updated' && 'action' in event) {
|
|
33
|
+
const action = event.action;
|
|
34
|
+
switch (action.type) {
|
|
35
|
+
case 'fetch': {
|
|
36
|
+
// Only need loading state and fetch metadata
|
|
37
|
+
const fetchData = {
|
|
38
|
+
queryHash: query.queryHash,
|
|
39
|
+
state: {
|
|
40
|
+
status: query.state.status,
|
|
41
|
+
fetchStatus: query.state.fetchStatus,
|
|
42
|
+
fetchMeta: query.state.fetchMeta,
|
|
43
|
+
dataUpdatedAt: query.state.dataUpdatedAt,
|
|
44
|
+
errorUpdatedAt: query.state.errorUpdatedAt,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
client.send('sync-query-event', {
|
|
48
|
+
type: 'updated',
|
|
49
|
+
action: 'fetch',
|
|
50
|
+
data: fetchData,
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case 'success': {
|
|
55
|
+
// Only need new data and success state
|
|
56
|
+
const successData = {
|
|
57
|
+
queryHash: query.queryHash,
|
|
58
|
+
state: {
|
|
59
|
+
status: query.state.status,
|
|
60
|
+
data: query.state.data,
|
|
61
|
+
dataUpdatedAt: query.state.dataUpdatedAt,
|
|
62
|
+
error: query.state.error,
|
|
63
|
+
errorUpdatedAt: query.state.errorUpdatedAt,
|
|
64
|
+
fetchStatus: query.state.fetchStatus,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
client.send('sync-query-event', {
|
|
68
|
+
type: 'updated',
|
|
69
|
+
action: 'success',
|
|
70
|
+
data: successData,
|
|
71
|
+
});
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'error': {
|
|
75
|
+
// Only need error information
|
|
76
|
+
const errorData = {
|
|
77
|
+
queryHash: query.queryHash,
|
|
78
|
+
state: {
|
|
79
|
+
status: query.state.status,
|
|
80
|
+
error: query.state.error,
|
|
81
|
+
errorUpdatedAt: query.state.errorUpdatedAt,
|
|
82
|
+
fetchStatus: query.state.fetchStatus,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
client.send('sync-query-event', {
|
|
86
|
+
type: 'updated',
|
|
87
|
+
action: 'error',
|
|
88
|
+
data: errorData,
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case 'setState': {
|
|
93
|
+
// Only need the specific state changes
|
|
94
|
+
const setStateData = {
|
|
95
|
+
queryHash: query.queryHash,
|
|
96
|
+
state: action.state, // Only the changed state parts
|
|
97
|
+
};
|
|
98
|
+
client.send('sync-query-event', {
|
|
99
|
+
type: 'updated',
|
|
100
|
+
action: 'setState',
|
|
101
|
+
data: setStateData,
|
|
102
|
+
});
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case 'invalidate': {
|
|
106
|
+
// Only need invalidation flag
|
|
107
|
+
const invalidateData = {
|
|
108
|
+
queryHash: query.queryHash,
|
|
109
|
+
state: {
|
|
110
|
+
isInvalidated: query.state.isInvalidated,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
client.send('sync-query-event', {
|
|
114
|
+
type: 'updated',
|
|
115
|
+
action: 'invalidate',
|
|
116
|
+
data: invalidateData,
|
|
117
|
+
});
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case 'pause': {
|
|
121
|
+
// Need to sync the paused fetch status
|
|
122
|
+
const pauseData = {
|
|
123
|
+
queryHash: query.queryHash,
|
|
124
|
+
state: {
|
|
125
|
+
fetchStatus: query.state.fetchStatus,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
client.send('sync-query-event', {
|
|
129
|
+
type: 'updated',
|
|
130
|
+
action: 'pause',
|
|
131
|
+
data: pauseData,
|
|
132
|
+
});
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case 'continue': {
|
|
136
|
+
// Need to sync the resumed fetch status
|
|
137
|
+
const continueData = {
|
|
138
|
+
queryHash: query.queryHash,
|
|
139
|
+
state: {
|
|
140
|
+
fetchStatus: query.state.fetchStatus,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
client.send('sync-query-event', {
|
|
144
|
+
type: 'updated',
|
|
145
|
+
action: 'continue',
|
|
146
|
+
data: continueData,
|
|
147
|
+
});
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
default: {
|
|
151
|
+
// Fallback to full data for unknown actions
|
|
152
|
+
const dehydratedQuery = (0, dehydrate_1.dehydrateQuery)(query);
|
|
153
|
+
client.send('sync-query-event', { type, data: dehydratedQuery });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (type === 'observerAdded' ||
|
|
159
|
+
type === 'observerRemoved' ||
|
|
160
|
+
type === 'observerOptionsUpdated') {
|
|
161
|
+
const dehydratedObservers = (0, dehydrate_1.dehydrateObservers)(query);
|
|
162
|
+
const previousObservers = previousObserversRef.current.get(query.queryHash);
|
|
163
|
+
// For observerOptionsUpdated, only send if the observers actually changed
|
|
164
|
+
if (type === 'observerOptionsUpdated' && previousObservers) {
|
|
165
|
+
if ((0, fast_deep_equal_1.default)(previousObservers, dehydratedObservers)) {
|
|
166
|
+
// No meaningful change, skip sending
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
previousObserversRef.current.set(query.queryHash, dehydratedObservers);
|
|
171
|
+
client.send('sync-query-event', {
|
|
172
|
+
type,
|
|
173
|
+
data: {
|
|
174
|
+
queryHash: query.queryHash,
|
|
175
|
+
observers: dehydratedObservers,
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const { mutation, type } = event;
|
|
182
|
+
if (mutation) {
|
|
183
|
+
const dehydratedMutation = (0, dehydrate_1.dehydrateMutation)(mutation);
|
|
184
|
+
client.send('sync-mutation-event', {
|
|
185
|
+
type,
|
|
186
|
+
data: dehydratedMutation,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}, [client]);
|
|
191
|
+
(0, react_1.useEffect)(() => {
|
|
192
|
+
if (!client) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const mutationCacheSubscription = queryClient.getMutationCache().subscribe(handler);
|
|
196
|
+
const queryCacheSubscription = queryClient.getQueryCache().subscribe(handler);
|
|
197
|
+
return () => {
|
|
198
|
+
mutationCacheSubscription();
|
|
199
|
+
queryCacheSubscription();
|
|
200
|
+
};
|
|
201
|
+
}, [client, queryClient, handler]);
|
|
202
|
+
};
|
|
203
|
+
exports.useSyncTanStackCache = useSyncTanStackCache;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTanStackQueryDevTools = void 0;
|
|
4
|
+
const plugin_bridge_1 = require("@rozenite/plugin-bridge");
|
|
5
|
+
const useSyncOnlineStatus_1 = require("../shared/useSyncOnlineStatus");
|
|
6
|
+
const useHandleDevToolsMessages_1 = require("./useHandleDevToolsMessages");
|
|
7
|
+
const useSyncTanStackCache_1 = require("./useSyncTanStackCache");
|
|
8
|
+
const useHandleInitialData_1 = require("./useHandleInitialData");
|
|
9
|
+
const useTanStackQueryAgentTools_1 = require("./agent/useTanStackQueryAgentTools");
|
|
10
|
+
const useTanStackQueryDevTools = (queryClient) => {
|
|
11
|
+
const client = (0, plugin_bridge_1.useRozeniteDevToolsClient)({
|
|
12
|
+
pluginId: '@rozenite/tanstack-query-plugin',
|
|
13
|
+
});
|
|
14
|
+
(0, useSyncOnlineStatus_1.useSyncOnlineStatus)(client);
|
|
15
|
+
(0, useHandleDevToolsMessages_1.useHandleDevToolsMessages)(queryClient, client);
|
|
16
|
+
(0, useSyncTanStackCache_1.useSyncTanStackCache)(queryClient, client);
|
|
17
|
+
(0, useHandleInitialData_1.useHandleInitialData)(queryClient, client);
|
|
18
|
+
(0, useTanStackQueryAgentTools_1.useTanStackQueryAgentTools)(queryClient);
|
|
19
|
+
};
|
|
20
|
+
exports.useTanStackQueryDevTools = useTanStackQueryDevTools;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tanstackQueryToolDefinitions = exports.TANSTACK_QUERY_AGENT_PLUGIN_ID = void 0;
|
|
4
|
+
const agent_shared_1 = require("@rozenite/agent-shared");
|
|
5
|
+
exports.TANSTACK_QUERY_AGENT_PLUGIN_ID = '@rozenite/tanstack-query-plugin';
|
|
6
|
+
const queryActionProperties = {
|
|
7
|
+
queryHash: {
|
|
8
|
+
type: 'string',
|
|
9
|
+
description: 'TanStack Query queryHash identifying the query.',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
const mutationActionProperties = {
|
|
13
|
+
mutationId: {
|
|
14
|
+
type: 'number',
|
|
15
|
+
description: 'TanStack Query mutationId identifying the mutation.',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const paginationProperties = {
|
|
19
|
+
limit: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
description: 'Maximum number of items to return. Defaults to 20. Maximum 100.',
|
|
22
|
+
},
|
|
23
|
+
cursor: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Opaque pagination cursor from a previous list call.',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const emptyInputSchema = {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {},
|
|
31
|
+
};
|
|
32
|
+
exports.tanstackQueryToolDefinitions = {
|
|
33
|
+
getCacheSummary: (0, agent_shared_1.defineAgentToolContract)({
|
|
34
|
+
name: 'get-cache-summary',
|
|
35
|
+
description: 'Return aggregate TanStack Query cache health and count information.',
|
|
36
|
+
inputSchema: emptyInputSchema,
|
|
37
|
+
}),
|
|
38
|
+
getOnlineStatus: (0, agent_shared_1.defineAgentToolContract)({
|
|
39
|
+
name: 'get-online-status',
|
|
40
|
+
description: 'Return the current TanStack Query onlineManager status.',
|
|
41
|
+
inputSchema: emptyInputSchema,
|
|
42
|
+
}),
|
|
43
|
+
setOnlineStatus: (0, agent_shared_1.defineAgentToolContract)({
|
|
44
|
+
name: 'set-online-status',
|
|
45
|
+
description: 'Set the TanStack Query onlineManager status for testing offline/online behavior.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
online: {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
description: 'Whether the TanStack Query onlineManager should be online.',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
required: ['online'],
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
listQueries: (0, agent_shared_1.definePaginatedAgentToolContract)({
|
|
58
|
+
name: 'list-queries',
|
|
59
|
+
description: 'List TanStack Query query summaries using cursor pagination.',
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: paginationProperties,
|
|
63
|
+
},
|
|
64
|
+
pagination: {
|
|
65
|
+
kind: 'cursor',
|
|
66
|
+
fields: [
|
|
67
|
+
'queryHash',
|
|
68
|
+
'queryKey',
|
|
69
|
+
'status',
|
|
70
|
+
'fetchStatus',
|
|
71
|
+
'observersCount',
|
|
72
|
+
'isInvalidated',
|
|
73
|
+
'dataUpdatedAt',
|
|
74
|
+
'errorUpdatedAt',
|
|
75
|
+
'hasData',
|
|
76
|
+
'hasError',
|
|
77
|
+
],
|
|
78
|
+
defaultFields: ['queryHash', 'queryKey', 'status', 'fetchStatus', 'hasError'],
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
getQueryDetails: (0, agent_shared_1.defineAgentToolContract)({
|
|
82
|
+
name: 'get-query-details',
|
|
83
|
+
description: 'Return a JSON-safe TanStack Query query snapshot and observer summary.',
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: 'object',
|
|
86
|
+
properties: queryActionProperties,
|
|
87
|
+
required: ['queryHash'],
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
refetchQuery: (0, agent_shared_1.defineAgentToolContract)({
|
|
91
|
+
name: 'refetch-query',
|
|
92
|
+
description: 'Refetch a TanStack Query query by queryHash.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: queryActionProperties,
|
|
96
|
+
required: ['queryHash'],
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
setQueryLoading: (0, agent_shared_1.defineAgentToolContract)({
|
|
100
|
+
name: 'set-query-loading',
|
|
101
|
+
description: 'Enable or disable TanStack Query loading-state simulation for a query by queryHash.',
|
|
102
|
+
inputSchema: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {
|
|
105
|
+
...queryActionProperties,
|
|
106
|
+
enabled: {
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
description: 'Whether the loading-state simulation should be enabled.',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
required: ['queryHash', 'enabled'],
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
setQueryError: (0, agent_shared_1.defineAgentToolContract)({
|
|
115
|
+
name: 'set-query-error',
|
|
116
|
+
description: 'Enable or disable TanStack Query error-state simulation for a query by queryHash.',
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
...queryActionProperties,
|
|
121
|
+
enabled: {
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
description: 'Whether the error-state simulation should be enabled.',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
required: ['queryHash', 'enabled'],
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
invalidateQuery: (0, agent_shared_1.defineAgentToolContract)({
|
|
130
|
+
name: 'invalidate-query',
|
|
131
|
+
description: 'Invalidate a TanStack Query query by queryHash.',
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: queryActionProperties,
|
|
135
|
+
required: ['queryHash'],
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
resetQuery: (0, agent_shared_1.defineAgentToolContract)({
|
|
139
|
+
name: 'reset-query',
|
|
140
|
+
description: 'Reset a TanStack Query query by queryHash.',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: queryActionProperties,
|
|
144
|
+
required: ['queryHash'],
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
removeQuery: (0, agent_shared_1.defineAgentToolContract)({
|
|
148
|
+
name: 'remove-query',
|
|
149
|
+
description: 'Remove a TanStack Query query from the cache by queryHash.',
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: queryActionProperties,
|
|
153
|
+
required: ['queryHash'],
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
clearQueryCache: (0, agent_shared_1.defineAgentToolContract)({
|
|
157
|
+
name: 'clear-query-cache',
|
|
158
|
+
description: 'Clear the full TanStack Query query cache.',
|
|
159
|
+
inputSchema: emptyInputSchema,
|
|
160
|
+
}),
|
|
161
|
+
listMutations: (0, agent_shared_1.definePaginatedAgentToolContract)({
|
|
162
|
+
name: 'list-mutations',
|
|
163
|
+
description: 'List TanStack Query mutation summaries using cursor pagination.',
|
|
164
|
+
inputSchema: {
|
|
165
|
+
type: 'object',
|
|
166
|
+
properties: paginationProperties,
|
|
167
|
+
},
|
|
168
|
+
pagination: {
|
|
169
|
+
kind: 'cursor',
|
|
170
|
+
fields: [
|
|
171
|
+
'mutationId',
|
|
172
|
+
'mutationKey',
|
|
173
|
+
'status',
|
|
174
|
+
'isPaused',
|
|
175
|
+
'submittedAt',
|
|
176
|
+
'failureCount',
|
|
177
|
+
'hasData',
|
|
178
|
+
'hasError',
|
|
179
|
+
],
|
|
180
|
+
defaultFields: ['mutationId', 'mutationKey', 'status', 'hasError'],
|
|
181
|
+
},
|
|
182
|
+
}),
|
|
183
|
+
getMutationDetails: (0, agent_shared_1.defineAgentToolContract)({
|
|
184
|
+
name: 'get-mutation-details',
|
|
185
|
+
description: 'Return a JSON-safe TanStack Query mutation snapshot for a mutationId.',
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: mutationActionProperties,
|
|
189
|
+
required: ['mutationId'],
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
clearMutationCache: (0, agent_shared_1.defineAgentToolContract)({
|
|
193
|
+
name: 'clear-mutation-cache',
|
|
194
|
+
description: 'Clear the full TanStack Query mutation cache.',
|
|
195
|
+
inputSchema: emptyInputSchema,
|
|
196
|
+
}),
|
|
197
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dehydrateQueryClient = exports.dehydrateMutation = exports.dehydrateQuery = exports.dehydrateObservers = void 0;
|
|
4
|
+
const dehydrateObservers = (query) => {
|
|
5
|
+
return query.observers.map((observer) => ({
|
|
6
|
+
queryHash: query.queryHash,
|
|
7
|
+
options: observer.options,
|
|
8
|
+
}));
|
|
9
|
+
};
|
|
10
|
+
exports.dehydrateObservers = dehydrateObservers;
|
|
11
|
+
const dehydrateQuery = (query) => {
|
|
12
|
+
const dehydratedObservers = (0, exports.dehydrateObservers)(query);
|
|
13
|
+
return {
|
|
14
|
+
state: query.state,
|
|
15
|
+
queryKey: query.queryKey,
|
|
16
|
+
queryHash: query.queryHash,
|
|
17
|
+
observers: dehydratedObservers,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.dehydrateQuery = dehydrateQuery;
|
|
21
|
+
const dehydrateMutation = (mutation) => {
|
|
22
|
+
return {
|
|
23
|
+
mutationId: mutation.mutationId,
|
|
24
|
+
state: mutation.state,
|
|
25
|
+
options: mutation.options,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.dehydrateMutation = dehydrateMutation;
|
|
29
|
+
const dehydrateQueryClient = (queryClient) => {
|
|
30
|
+
return {
|
|
31
|
+
queries: queryClient.getQueryCache().getAll().map(exports.dehydrateQuery),
|
|
32
|
+
mutations: queryClient.getMutationCache().getAll().map(exports.dehydrateMutation),
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.dehydrateQueryClient = dehydrateQueryClient;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSyncOnlineStatus = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const useSyncOnlineStatus = (client) => {
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
if (!client) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const onlineManagerSubscription = react_query_1.onlineManager.subscribe((online) => {
|
|
12
|
+
client.send('online-status-changed', { online });
|
|
13
|
+
});
|
|
14
|
+
const onlineMessageSubscription = client.onMessage('online-status-changed', ({ online }) => {
|
|
15
|
+
react_query_1.onlineManager.setOnline(online);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
onlineManagerSubscription();
|
|
19
|
+
onlineMessageSubscription.remove();
|
|
20
|
+
};
|
|
21
|
+
}, [client]);
|
|
22
|
+
};
|
|
23
|
+
exports.useSyncOnlineStatus = useSyncOnlineStatus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare let useTanStackQueryDevTools: typeof import('./src/react-native/useTanStackQueryDevTools').useTanStackQueryDevTools;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export let useTanStackQueryDevTools;
|
|
2
|
+
const isDev = process.env.NODE_ENV !== 'production';
|
|
3
|
+
const isServer = typeof window === 'undefined' && typeof lynx === 'undefined';
|
|
4
|
+
if (isDev && !isServer) {
|
|
5
|
+
useTanStackQueryDevTools =
|
|
6
|
+
require('./src/react-native/useTanStackQueryDevTools').useTanStackQueryDevTools;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
useTanStackQueryDevTools = () => ({ isConnected: false });
|
|
10
|
+
}
|