@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.
Files changed (67) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/devtools/assets/{CXEL7IU7-BWccRGN3.js → CXEL7IU7-D2MCp9XC.js} +1 -1
  3. package/dist/devtools/assets/{tanstack-query-CbF_imft.js → tanstack-query-Bk8rHBM2.js} +12 -12
  4. package/dist/devtools/tanstack-query.html +1 -1
  5. package/dist/react-native/cjs/package.json +3 -0
  6. package/dist/react-native/cjs/react-native.js +12 -0
  7. package/dist/react-native/cjs/src/react-native/agent/tanstack-query-agent.js +376 -0
  8. package/dist/react-native/cjs/src/react-native/agent/useTanStackQueryAgentTools.js +98 -0
  9. package/dist/react-native/cjs/src/react-native/devtools-actions.js +161 -0
  10. package/dist/react-native/cjs/src/react-native/useHandleDevToolsMessages.js +26 -0
  11. package/dist/react-native/cjs/src/react-native/useHandleInitialData.js +26 -0
  12. package/dist/react-native/cjs/src/react-native/useSyncTanStackCache.js +203 -0
  13. package/dist/react-native/cjs/src/react-native/useTanStackQueryDevTools.js +20 -0
  14. package/dist/react-native/cjs/src/shared/agent-tools.js +197 -0
  15. package/dist/react-native/cjs/src/shared/dehydrate.js +35 -0
  16. package/dist/react-native/cjs/src/shared/messaging.js +2 -0
  17. package/dist/react-native/cjs/src/shared/types.js +2 -0
  18. package/dist/react-native/cjs/src/shared/useSyncOnlineStatus.js +23 -0
  19. package/dist/react-native/package.json +3 -0
  20. package/dist/react-native/react-native.d.ts +1 -0
  21. package/dist/react-native/react-native.js +10 -0
  22. package/dist/{sdk/index.d.ts → react-native/src/react-native/agent/tanstack-query-agent.d.ts} +2105 -1939
  23. package/dist/react-native/src/react-native/agent/tanstack-query-agent.js +370 -0
  24. package/dist/react-native/src/react-native/agent/useTanStackQueryAgentTools.d.ts +2 -0
  25. package/dist/react-native/src/react-native/agent/useTanStackQueryAgentTools.js +94 -0
  26. package/dist/react-native/src/react-native/devtools-actions.d.ts +115 -0
  27. package/dist/react-native/src/react-native/devtools-actions.js +157 -0
  28. package/dist/react-native/src/react-native/useHandleDevToolsMessages.d.ts +3 -0
  29. package/dist/react-native/src/react-native/useHandleDevToolsMessages.js +22 -0
  30. package/dist/react-native/src/react-native/useHandleInitialData.d.ts +3 -0
  31. package/dist/react-native/src/react-native/useHandleInitialData.js +22 -0
  32. package/dist/react-native/src/react-native/useSyncTanStackCache.d.ts +3 -0
  33. package/dist/react-native/src/react-native/useSyncTanStackCache.js +196 -0
  34. package/dist/react-native/src/react-native/useTanStackQueryDevTools.d.ts +2 -0
  35. package/dist/react-native/src/react-native/useTanStackQueryDevTools.js +16 -0
  36. package/dist/react-native/src/shared/agent-tools.d.ts +967 -0
  37. package/dist/react-native/src/shared/agent-tools.js +194 -0
  38. package/dist/react-native/src/shared/dehydrate.d.ts +6 -0
  39. package/dist/react-native/src/shared/dehydrate.js +28 -0
  40. package/dist/react-native/src/shared/messaging.d.ts +44 -0
  41. package/dist/react-native/src/shared/messaging.js +1 -0
  42. package/dist/react-native/src/shared/types.d.ts +25 -0
  43. package/dist/react-native/src/shared/types.js +1 -0
  44. package/dist/react-native/src/shared/useSyncOnlineStatus.d.ts +2 -0
  45. package/dist/react-native/src/shared/useSyncOnlineStatus.js +19 -0
  46. package/dist/rozenite.json +1 -1
  47. package/dist/sdk/package.json +3 -0
  48. package/dist/sdk/sdk.d.ts +812 -0
  49. package/dist/sdk/sdk.js +8 -0
  50. package/dist/sdk/src/react-native/devtools-actions.d.ts +115 -0
  51. package/dist/sdk/src/react-native/devtools-actions.js +161 -0
  52. package/dist/sdk/src/shared/agent-tools.d.ts +967 -0
  53. package/dist/sdk/src/shared/agent-tools.js +197 -0
  54. package/dist/sdk/src/shared/types.d.ts +25 -0
  55. package/dist/sdk/src/shared/types.js +2 -0
  56. package/package.json +18 -18
  57. package/react-native.ts +8 -1
  58. package/rozenite.config.ts +1 -0
  59. package/src/__tests__/release-bundle.test.ts +32 -0
  60. package/tsconfig.json +1 -3
  61. package/dist/react-native/chunks/useTanStackQueryDevTools.require.cjs +0 -1
  62. package/dist/react-native/chunks/useTanStackQueryDevTools.require.js +0 -895
  63. package/dist/react-native/index.cjs +0 -1
  64. package/dist/react-native/index.d.ts +0 -7
  65. package/dist/react-native/index.js +0 -6
  66. package/dist/sdk/index.cjs +0 -1
  67. package/dist/sdk/index.js +0 -199
@@ -0,0 +1,370 @@
1
+ import { onlineManager } from '@tanstack/react-query';
2
+ import { applyTanStackQueryDevtoolsAction } from '../devtools-actions';
3
+ import { tanstackQueryToolDefinitions, } from '../../shared/agent-tools';
4
+ const DEFAULT_PAGE_LIMIT = 20;
5
+ const MAX_PAGE_LIMIT = 100;
6
+ const isPlainObject = (value) => {
7
+ return !!value && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype;
8
+ };
9
+ export const serializeForAgent = (value, seen = new WeakSet()) => {
10
+ if (value == null) {
11
+ return null;
12
+ }
13
+ if (typeof value === 'string' || typeof value === 'boolean') {
14
+ return value;
15
+ }
16
+ if (typeof value === 'number') {
17
+ return Number.isFinite(value) ? value : String(value);
18
+ }
19
+ if (typeof value === 'bigint') {
20
+ return value.toString();
21
+ }
22
+ if (typeof value === 'function' || typeof value === 'symbol') {
23
+ return `[non-serializable:${typeof value}]`;
24
+ }
25
+ if (value instanceof Date) {
26
+ return value.toISOString();
27
+ }
28
+ if (value instanceof Error) {
29
+ return {
30
+ name: value.name,
31
+ message: value.message,
32
+ stack: value.stack ?? null,
33
+ cause: serializeForAgent(value.cause, seen),
34
+ };
35
+ }
36
+ if (Array.isArray(value)) {
37
+ return value.map((item) => serializeForAgent(item, seen));
38
+ }
39
+ if (ArrayBuffer.isView(value)) {
40
+ return Array.from(value).map((item) => typeof item === 'number' ? item : Number(item));
41
+ }
42
+ if (value instanceof ArrayBuffer) {
43
+ return Array.from(new Uint8Array(value));
44
+ }
45
+ if (typeof value === 'object') {
46
+ if (seen.has(value)) {
47
+ return '[circular]';
48
+ }
49
+ seen.add(value);
50
+ if (!isPlainObject(value)) {
51
+ return `[non-serializable:${value.constructor?.name ?? 'Object'}]`;
52
+ }
53
+ const entries = Object.entries(value).map(([key, nestedValue]) => [
54
+ key,
55
+ serializeForAgent(nestedValue, seen),
56
+ ]);
57
+ return Object.fromEntries(entries);
58
+ }
59
+ return String(value);
60
+ };
61
+ const sanitizeLimit = (limit) => {
62
+ if (typeof limit !== 'number' ||
63
+ !Number.isFinite(limit) ||
64
+ !Number.isInteger(limit) ||
65
+ limit < 1) {
66
+ return DEFAULT_PAGE_LIMIT;
67
+ }
68
+ return Math.min(limit, MAX_PAGE_LIMIT);
69
+ };
70
+ const encodeCursor = (kind, generation, offset) => {
71
+ return `${kind}:${generation}:${offset}`;
72
+ };
73
+ const decodeCursor = (cursor, kind, generation) => {
74
+ const [cursorKind, rawGeneration, rawOffset] = cursor.split(':', 3);
75
+ if (cursorKind !== kind || !rawGeneration || !rawOffset) {
76
+ throw new Error('Cursor does not match the requested listing. Run the command again.');
77
+ }
78
+ const cursorGeneration = Number(rawGeneration);
79
+ const offset = Number(rawOffset);
80
+ if (!Number.isInteger(cursorGeneration) || cursorGeneration !== generation) {
81
+ throw new Error('Cursor does not match the requested listing. Run the command again.');
82
+ }
83
+ if (!Number.isInteger(offset) || offset < 0) {
84
+ throw new Error('Cursor is invalid. Run the command again.');
85
+ }
86
+ return offset;
87
+ };
88
+ const paginate = (rows, kind, generation, input) => {
89
+ const limit = sanitizeLimit(input.limit);
90
+ const startIndex = input.cursor ? decodeCursor(input.cursor, kind, generation) : 0;
91
+ const endIndex = Math.min(startIndex + limit, rows.length);
92
+ const hasMore = endIndex < rows.length;
93
+ return {
94
+ items: rows.slice(startIndex, endIndex),
95
+ page: {
96
+ limit,
97
+ hasMore,
98
+ ...(hasMore ? { nextCursor: encodeCursor(kind, generation, endIndex) } : {}),
99
+ },
100
+ };
101
+ };
102
+ export const getCacheSummaryTool = tanstackQueryToolDefinitions.getCacheSummary;
103
+ export const getOnlineStatusTool = tanstackQueryToolDefinitions.getOnlineStatus;
104
+ export const setOnlineStatusTool = tanstackQueryToolDefinitions.setOnlineStatus;
105
+ export const listQueriesTool = tanstackQueryToolDefinitions.listQueries;
106
+ export const getQueryDetailsTool = tanstackQueryToolDefinitions.getQueryDetails;
107
+ export const refetchQueryTool = tanstackQueryToolDefinitions.refetchQuery;
108
+ export const setQueryLoadingTool = tanstackQueryToolDefinitions.setQueryLoading;
109
+ export const setQueryErrorTool = tanstackQueryToolDefinitions.setQueryError;
110
+ export const invalidateQueryTool = tanstackQueryToolDefinitions.invalidateQuery;
111
+ export const resetQueryTool = tanstackQueryToolDefinitions.resetQuery;
112
+ export const removeQueryTool = tanstackQueryToolDefinitions.removeQuery;
113
+ export const clearQueryCacheTool = tanstackQueryToolDefinitions.clearQueryCache;
114
+ export const listMutationsTool = tanstackQueryToolDefinitions.listMutations;
115
+ export const getMutationDetailsTool = tanstackQueryToolDefinitions.getMutationDetails;
116
+ export const clearMutationCacheTool = tanstackQueryToolDefinitions.clearMutationCache;
117
+ export const TANSTACK_QUERY_AGENT_TOOLS = Object.values(tanstackQueryToolDefinitions);
118
+ const pickObserverOptionsSummary = (options) => {
119
+ if (!options) {
120
+ return null;
121
+ }
122
+ return {
123
+ enabled: serializeForAgent(options.enabled),
124
+ networkMode: serializeForAgent(options.networkMode),
125
+ staleTime: serializeForAgent(options.staleTime),
126
+ gcTime: serializeForAgent(options.gcTime),
127
+ retry: serializeForAgent(options.retry),
128
+ retryDelay: serializeForAgent(options.retryDelay),
129
+ refetchInterval: serializeForAgent(options.refetchInterval),
130
+ refetchOnMount: serializeForAgent(options.refetchOnMount),
131
+ refetchOnReconnect: serializeForAgent(options.refetchOnReconnect),
132
+ refetchOnWindowFocus: serializeForAgent(options.refetchOnWindowFocus),
133
+ subscribed: serializeForAgent(options.subscribed),
134
+ meta: serializeForAgent(options.meta),
135
+ hasQueryFn: typeof options.queryFn === 'function',
136
+ hasSelect: typeof options.select === 'function',
137
+ hasPlaceholderData: 'placeholderData' in options,
138
+ hasInitialData: 'initialData' in options,
139
+ };
140
+ };
141
+ const pickMutationOptionsSummary = (options) => {
142
+ return {
143
+ mutationKey: serializeForAgent(options.mutationKey),
144
+ networkMode: serializeForAgent(options.networkMode),
145
+ gcTime: serializeForAgent(options.gcTime),
146
+ retry: serializeForAgent(options.retry),
147
+ retryDelay: serializeForAgent(options.retryDelay),
148
+ meta: serializeForAgent(options.meta),
149
+ scope: serializeForAgent(options.scope),
150
+ hasMutationFn: typeof options.mutationFn === 'function',
151
+ hasOnMutate: typeof options.onMutate === 'function',
152
+ hasOnSuccess: typeof options.onSuccess === 'function',
153
+ hasOnError: typeof options.onError === 'function',
154
+ hasOnSettled: typeof options.onSettled === 'function',
155
+ };
156
+ };
157
+ const getQuerySortTimestamp = (query) => {
158
+ return Math.max(query.state.dataUpdatedAt, query.state.errorUpdatedAt);
159
+ };
160
+ const compareQueries = (a, b) => {
161
+ return (getQuerySortTimestamp(b) - getQuerySortTimestamp(a) ||
162
+ b.getObserversCount() - a.getObserversCount() ||
163
+ String(b.queryHash).localeCompare(String(a.queryHash)));
164
+ };
165
+ const compareMutations = (a, b) => {
166
+ return b.state.submittedAt - a.state.submittedAt || b.mutationId - a.mutationId;
167
+ };
168
+ const getQuerySummary = (query) => {
169
+ return {
170
+ queryHash: query.queryHash,
171
+ queryKey: serializeForAgent(query.queryKey),
172
+ status: query.state.status,
173
+ fetchStatus: query.state.fetchStatus,
174
+ observersCount: query.getObserversCount(),
175
+ isInvalidated: query.state.isInvalidated,
176
+ dataUpdatedAt: query.state.dataUpdatedAt,
177
+ errorUpdatedAt: query.state.errorUpdatedAt,
178
+ hasData: query.state.data !== undefined,
179
+ hasError: query.state.error != null,
180
+ };
181
+ };
182
+ const getMutationStatus = (state) => {
183
+ return state.status;
184
+ };
185
+ const getMutationSummary = (mutation) => {
186
+ return {
187
+ mutationId: mutation.mutationId,
188
+ mutationKey: serializeForAgent(mutation.options.mutationKey),
189
+ status: getMutationStatus(mutation.state),
190
+ isPaused: mutation.state.isPaused,
191
+ submittedAt: mutation.state.submittedAt,
192
+ failureCount: mutation.state.failureCount,
193
+ hasData: mutation.state.data !== undefined,
194
+ hasError: mutation.state.error != null,
195
+ };
196
+ };
197
+ const resolveQuery = (queryClient, queryHash) => {
198
+ const query = queryClient.getQueryCache().get(queryHash);
199
+ if (!query) {
200
+ const available = queryClient
201
+ .getQueryCache()
202
+ .getAll()
203
+ .map((entry) => entry.queryHash)
204
+ .join(', ');
205
+ throw new Error(`Unknown queryHash "${queryHash}". Available: ${available || '(none)'}`);
206
+ }
207
+ return query;
208
+ };
209
+ const resolveMutation = (queryClient, mutationId) => {
210
+ const mutation = queryClient
211
+ .getMutationCache()
212
+ .getAll()
213
+ .find((entry) => entry.mutationId === mutationId);
214
+ if (!mutation) {
215
+ const available = queryClient
216
+ .getMutationCache()
217
+ .getAll()
218
+ .map((entry) => entry.mutationId)
219
+ .join(', ');
220
+ throw new Error(`Unknown mutationId "${mutationId}". Available: ${available || '(none)'}`);
221
+ }
222
+ return mutation;
223
+ };
224
+ export const buildTanStackQueryCacheSummary = (queryClient) => {
225
+ const queries = queryClient.getQueryCache().getAll();
226
+ const mutations = queryClient.getMutationCache().getAll();
227
+ return {
228
+ online: onlineManager.isOnline(),
229
+ queries: {
230
+ total: queries.length,
231
+ active: queries.filter((query) => query.getObserversCount() > 0).length,
232
+ fetching: queries.filter((query) => query.state.fetchStatus === 'fetching').length,
233
+ pending: queries.filter((query) => query.state.status === 'pending').length,
234
+ success: queries.filter((query) => query.state.status === 'success').length,
235
+ error: queries.filter((query) => query.state.status === 'error').length,
236
+ invalidated: queries.filter((query) => query.state.isInvalidated).length,
237
+ },
238
+ mutations: {
239
+ total: mutations.length,
240
+ pending: mutations.filter((mutation) => mutation.state.status === 'pending').length,
241
+ success: mutations.filter((mutation) => mutation.state.status === 'success').length,
242
+ error: mutations.filter((mutation) => mutation.state.status === 'error').length,
243
+ paused: mutations.filter((mutation) => mutation.state.isPaused).length,
244
+ },
245
+ };
246
+ };
247
+ export const createTanStackQueryAgentController = (queryClient) => {
248
+ const cursorState = {
249
+ queriesGeneration: 0,
250
+ mutationsGeneration: 0,
251
+ };
252
+ return {
253
+ handleQueryCacheEvent(event) {
254
+ if (event.type === 'added' || event.type === 'removed') {
255
+ cursorState.queriesGeneration += 1;
256
+ }
257
+ },
258
+ handleMutationCacheEvent(event) {
259
+ if (event.type === 'added' || event.type === 'removed') {
260
+ cursorState.mutationsGeneration += 1;
261
+ }
262
+ },
263
+ getCacheSummary() {
264
+ return buildTanStackQueryCacheSummary(queryClient);
265
+ },
266
+ getOnlineStatus() {
267
+ return {
268
+ online: onlineManager.isOnline(),
269
+ };
270
+ },
271
+ setOnlineStatus({ online }) {
272
+ onlineManager.setOnline(online);
273
+ return {
274
+ online: onlineManager.isOnline(),
275
+ };
276
+ },
277
+ listQueries(input = {}) {
278
+ const queries = [...queryClient.getQueryCache().getAll()].sort(compareQueries);
279
+ return {
280
+ ...buildTanStackQueryCacheSummary(queryClient),
281
+ total: queries.length,
282
+ ...paginate(queries.map(getQuerySummary), 'queries', cursorState.queriesGeneration, input),
283
+ };
284
+ },
285
+ getQueryDetails({ queryHash }) {
286
+ const query = resolveQuery(queryClient, queryHash);
287
+ return {
288
+ summary: buildTanStackQueryCacheSummary(queryClient),
289
+ query: {
290
+ ...getQuerySummary(query),
291
+ data: serializeForAgent(query.state.data),
292
+ error: serializeForAgent(query.state.error),
293
+ observers: query.observers.map((observer) => ({
294
+ queryHash: query.queryHash,
295
+ options: pickObserverOptionsSummary(observer.options),
296
+ })),
297
+ },
298
+ };
299
+ },
300
+ async refetchQuery({ queryHash }) {
301
+ return applyTanStackQueryDevtoolsAction(queryClient, {
302
+ type: 'REFETCH',
303
+ queryHash,
304
+ });
305
+ },
306
+ async setQueryLoading({ queryHash, enabled }) {
307
+ return applyTanStackQueryDevtoolsAction(queryClient, {
308
+ type: enabled ? 'TRIGGER_LOADING' : 'RESTORE_LOADING',
309
+ queryHash,
310
+ });
311
+ },
312
+ async setQueryError({ queryHash, enabled }) {
313
+ return applyTanStackQueryDevtoolsAction(queryClient, {
314
+ type: enabled ? 'TRIGGER_ERROR' : 'RESTORE_ERROR',
315
+ queryHash,
316
+ });
317
+ },
318
+ async invalidateQuery({ queryHash }) {
319
+ return applyTanStackQueryDevtoolsAction(queryClient, {
320
+ type: 'INVALIDATE',
321
+ queryHash,
322
+ });
323
+ },
324
+ async resetQuery({ queryHash }) {
325
+ return applyTanStackQueryDevtoolsAction(queryClient, {
326
+ type: 'RESET',
327
+ queryHash,
328
+ });
329
+ },
330
+ async removeQuery({ queryHash }) {
331
+ return applyTanStackQueryDevtoolsAction(queryClient, {
332
+ type: 'REMOVE',
333
+ queryHash,
334
+ });
335
+ },
336
+ async clearQueryCache() {
337
+ return applyTanStackQueryDevtoolsAction(queryClient, {
338
+ type: 'CLEAR_QUERY_CACHE',
339
+ });
340
+ },
341
+ listMutations(input = {}) {
342
+ const mutations = [...queryClient.getMutationCache().getAll()].sort(compareMutations);
343
+ return {
344
+ ...buildTanStackQueryCacheSummary(queryClient),
345
+ total: mutations.length,
346
+ ...paginate(mutations.map(getMutationSummary), 'mutations', cursorState.mutationsGeneration, input),
347
+ };
348
+ },
349
+ getMutationDetails({ mutationId }) {
350
+ const mutation = resolveMutation(queryClient, mutationId);
351
+ return {
352
+ summary: buildTanStackQueryCacheSummary(queryClient),
353
+ mutation: {
354
+ ...getMutationSummary(mutation),
355
+ variables: serializeForAgent(mutation.state.variables),
356
+ data: serializeForAgent(mutation.state.data),
357
+ error: serializeForAgent(mutation.state.error),
358
+ context: serializeForAgent(mutation.state.context),
359
+ failureReason: serializeForAgent(mutation.state.failureReason),
360
+ options: pickMutationOptionsSummary(mutation.options),
361
+ },
362
+ };
363
+ },
364
+ async clearMutationCache() {
365
+ return applyTanStackQueryDevtoolsAction(queryClient, {
366
+ type: 'CLEAR_MUTATION_CACHE',
367
+ });
368
+ },
369
+ };
370
+ };
@@ -0,0 +1,2 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ export declare const useTanStackQueryAgentTools: (queryClient: QueryClient) => void;
@@ -0,0 +1,94 @@
1
+ import { useEffect, useMemo } from 'react';
2
+ import { useRozenitePluginAgentTool } from '@rozenite/agent-bridge';
3
+ import { createTanStackQueryAgentController } from './tanstack-query-agent';
4
+ import { TANSTACK_QUERY_AGENT_PLUGIN_ID, tanstackQueryToolDefinitions, } from '../../shared/agent-tools';
5
+ export const useTanStackQueryAgentTools = (queryClient) => {
6
+ const controller = useMemo(() => createTanStackQueryAgentController(queryClient), [queryClient]);
7
+ useEffect(() => {
8
+ const unsubscribeQueryCache = queryClient
9
+ .getQueryCache()
10
+ .subscribe((event) => controller.handleQueryCacheEvent(event));
11
+ const unsubscribeMutationCache = queryClient
12
+ .getMutationCache()
13
+ .subscribe((event) => controller.handleMutationCacheEvent(event));
14
+ return () => {
15
+ unsubscribeQueryCache();
16
+ unsubscribeMutationCache();
17
+ };
18
+ }, [controller, queryClient]);
19
+ useRozenitePluginAgentTool({
20
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
21
+ tool: tanstackQueryToolDefinitions.getCacheSummary,
22
+ handler: () => controller.getCacheSummary(),
23
+ });
24
+ useRozenitePluginAgentTool({
25
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
26
+ tool: tanstackQueryToolDefinitions.getOnlineStatus,
27
+ handler: () => controller.getOnlineStatus(),
28
+ });
29
+ useRozenitePluginAgentTool({
30
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
31
+ tool: tanstackQueryToolDefinitions.setOnlineStatus,
32
+ handler: (input) => controller.setOnlineStatus(input),
33
+ });
34
+ useRozenitePluginAgentTool({
35
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
36
+ tool: tanstackQueryToolDefinitions.listQueries,
37
+ handler: (input = {}) => controller.listQueries(input),
38
+ });
39
+ useRozenitePluginAgentTool({
40
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
41
+ tool: tanstackQueryToolDefinitions.getQueryDetails,
42
+ handler: (input) => controller.getQueryDetails(input),
43
+ });
44
+ useRozenitePluginAgentTool({
45
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
46
+ tool: tanstackQueryToolDefinitions.refetchQuery,
47
+ handler: (input) => controller.refetchQuery(input),
48
+ });
49
+ useRozenitePluginAgentTool({
50
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
51
+ tool: tanstackQueryToolDefinitions.setQueryLoading,
52
+ handler: (input) => controller.setQueryLoading(input),
53
+ });
54
+ useRozenitePluginAgentTool({
55
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
56
+ tool: tanstackQueryToolDefinitions.setQueryError,
57
+ handler: (input) => controller.setQueryError(input),
58
+ });
59
+ useRozenitePluginAgentTool({
60
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
61
+ tool: tanstackQueryToolDefinitions.invalidateQuery,
62
+ handler: (input) => controller.invalidateQuery(input),
63
+ });
64
+ useRozenitePluginAgentTool({
65
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
66
+ tool: tanstackQueryToolDefinitions.resetQuery,
67
+ handler: (input) => controller.resetQuery(input),
68
+ });
69
+ useRozenitePluginAgentTool({
70
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
71
+ tool: tanstackQueryToolDefinitions.removeQuery,
72
+ handler: (input) => controller.removeQuery(input),
73
+ });
74
+ useRozenitePluginAgentTool({
75
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
76
+ tool: tanstackQueryToolDefinitions.clearQueryCache,
77
+ handler: () => controller.clearQueryCache(),
78
+ });
79
+ useRozenitePluginAgentTool({
80
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
81
+ tool: tanstackQueryToolDefinitions.listMutations,
82
+ handler: (input = {}) => controller.listMutations(input),
83
+ });
84
+ useRozenitePluginAgentTool({
85
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
86
+ tool: tanstackQueryToolDefinitions.getMutationDetails,
87
+ handler: (input) => controller.getMutationDetails(input),
88
+ });
89
+ useRozenitePluginAgentTool({
90
+ pluginId: TANSTACK_QUERY_AGENT_PLUGIN_ID,
91
+ tool: tanstackQueryToolDefinitions.clearMutationCache,
92
+ handler: () => controller.clearMutationCache(),
93
+ });
94
+ };
@@ -0,0 +1,115 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import { DevToolsActionType } from '../shared/types';
3
+ type QueryScopedActionInput = {
4
+ type: Exclude<DevToolsActionType, 'CLEAR_MUTATION_CACHE' | 'CLEAR_QUERY_CACHE'>;
5
+ queryHash: string;
6
+ metadata?: {
7
+ data?: unknown;
8
+ };
9
+ };
10
+ type CacheScopedActionInput = {
11
+ type: 'CLEAR_MUTATION_CACHE' | 'CLEAR_QUERY_CACHE';
12
+ queryHash?: string;
13
+ };
14
+ export type TanStackQueryDevtoolsActionInput = QueryScopedActionInput | CacheScopedActionInput;
15
+ export declare const applyTanStackQueryDevtoolsAction: (queryClient: QueryClient, input: TanStackQueryDevtoolsActionInput) => Promise<{
16
+ applied: boolean;
17
+ action: "CLEAR_QUERY_CACHE";
18
+ cleared: boolean;
19
+ queryCountBefore: number;
20
+ queryCountAfter: number;
21
+ mutationCountBefore?: undefined;
22
+ mutationCountAfter?: undefined;
23
+ queryHash?: undefined;
24
+ } | {
25
+ applied: boolean;
26
+ action: "CLEAR_MUTATION_CACHE";
27
+ cleared: boolean;
28
+ mutationCountBefore: number;
29
+ mutationCountAfter: number;
30
+ queryCountBefore?: undefined;
31
+ queryCountAfter?: undefined;
32
+ queryHash?: undefined;
33
+ } | {
34
+ applied: boolean;
35
+ action: "SET_QUERY_DATA";
36
+ queryHash: string;
37
+ cleared?: undefined;
38
+ queryCountBefore?: undefined;
39
+ queryCountAfter?: undefined;
40
+ mutationCountBefore?: undefined;
41
+ mutationCountAfter?: undefined;
42
+ } | {
43
+ applied: boolean;
44
+ action: "TRIGGER_ERROR";
45
+ queryHash: string;
46
+ cleared?: undefined;
47
+ queryCountBefore?: undefined;
48
+ queryCountAfter?: undefined;
49
+ mutationCountBefore?: undefined;
50
+ mutationCountAfter?: undefined;
51
+ } | {
52
+ applied: boolean;
53
+ action: "RESTORE_ERROR";
54
+ queryHash: string;
55
+ cleared?: undefined;
56
+ queryCountBefore?: undefined;
57
+ queryCountAfter?: undefined;
58
+ mutationCountBefore?: undefined;
59
+ mutationCountAfter?: undefined;
60
+ } | {
61
+ applied: boolean;
62
+ action: "TRIGGER_LOADING";
63
+ queryHash: string;
64
+ cleared?: undefined;
65
+ queryCountBefore?: undefined;
66
+ queryCountAfter?: undefined;
67
+ mutationCountBefore?: undefined;
68
+ mutationCountAfter?: undefined;
69
+ } | {
70
+ applied: boolean;
71
+ action: "RESTORE_LOADING";
72
+ queryHash: string;
73
+ cleared?: undefined;
74
+ queryCountBefore?: undefined;
75
+ queryCountAfter?: undefined;
76
+ mutationCountBefore?: undefined;
77
+ mutationCountAfter?: undefined;
78
+ } | {
79
+ applied: boolean;
80
+ action: "RESET";
81
+ queryHash: string;
82
+ cleared?: undefined;
83
+ queryCountBefore?: undefined;
84
+ queryCountAfter?: undefined;
85
+ mutationCountBefore?: undefined;
86
+ mutationCountAfter?: undefined;
87
+ } | {
88
+ applied: boolean;
89
+ action: "REMOVE";
90
+ queryHash: string;
91
+ cleared?: undefined;
92
+ queryCountBefore?: undefined;
93
+ queryCountAfter?: undefined;
94
+ mutationCountBefore?: undefined;
95
+ mutationCountAfter?: undefined;
96
+ } | {
97
+ applied: boolean;
98
+ action: "REFETCH";
99
+ queryHash: string;
100
+ cleared?: undefined;
101
+ queryCountBefore?: undefined;
102
+ queryCountAfter?: undefined;
103
+ mutationCountBefore?: undefined;
104
+ mutationCountAfter?: undefined;
105
+ } | {
106
+ applied: boolean;
107
+ action: "INVALIDATE";
108
+ queryHash: string;
109
+ cleared?: undefined;
110
+ queryCountBefore?: undefined;
111
+ queryCountAfter?: undefined;
112
+ mutationCountBefore?: undefined;
113
+ mutationCountAfter?: undefined;
114
+ }>;
115
+ export {};