@rozenite/tanstack-query-plugin 1.7.0-rc.2 → 1.8.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 +31 -0
- package/dist/devtools/assets/{CXEL7IU7-DJlSmt0p.js → CXEL7IU7-DmbowaBr.js} +1 -1
- package/dist/devtools/assets/{tanstack-query-_leiFatc.js → tanstack-query-DRBLkSCy.js} +11 -11
- package/dist/devtools/tanstack-query.html +1 -1
- package/dist/react-native/chunks/useTanStackQueryDevTools.require.cjs +1 -1
- package/dist/react-native/chunks/useTanStackQueryDevTools.require.js +309 -268
- package/dist/rozenite.json +1 -1
- package/dist/sdk/index.cjs +1 -0
- package/dist/sdk/index.d.ts +1939 -0
- package/dist/sdk/index.js +167 -0
- package/package.json +13 -6
- package/sdk.ts +55 -0
- package/src/react-native/agent/__tests__/tanstack-query-agent.test.ts +73 -29
- package/src/react-native/agent/tanstack-query-agent.ts +33 -235
- package/src/react-native/agent/useTanStackQueryAgentTools.ts +39 -65
- package/src/react-native/devtools-actions.ts +17 -3
- package/src/react-native/useHandleDevToolsMessages.ts +14 -11
- package/src/shared/agent-tools.ts +403 -0
- package/src/shared/hydrate.ts +16 -13
- package/src/shared/messaging.ts +3 -0
- package/src/shared/query-data-sync.test.ts +93 -0
- package/src/shared/query-data-sync.ts +156 -0
- package/src/shared/types.ts +1 -0
- package/src/ui/tanstack-query.tsx +12 -0
- package/tsconfig.json +4 -1
- package/vite.config.ts +7 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { defineAgentToolContract as e, defineAgentToolDescriptors as n } from "@rozenite/agent-shared";
|
|
2
|
+
const i = "@rozenite/tanstack-query-plugin", t = {
|
|
3
|
+
queryHash: {
|
|
4
|
+
type: "string",
|
|
5
|
+
description: "TanStack Query queryHash identifying the query."
|
|
6
|
+
}
|
|
7
|
+
}, o = {
|
|
8
|
+
mutationId: {
|
|
9
|
+
type: "number",
|
|
10
|
+
description: "TanStack Query mutationId identifying the mutation."
|
|
11
|
+
}
|
|
12
|
+
}, a = {
|
|
13
|
+
limit: {
|
|
14
|
+
type: "number",
|
|
15
|
+
description: "Maximum number of items to return. Defaults to 20. Maximum 100."
|
|
16
|
+
},
|
|
17
|
+
cursor: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Opaque pagination cursor from a previous list call."
|
|
20
|
+
}
|
|
21
|
+
}, r = {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {}
|
|
24
|
+
}, u = {
|
|
25
|
+
getCacheSummary: e({
|
|
26
|
+
name: "get-cache-summary",
|
|
27
|
+
description: "Return aggregate TanStack Query cache health and count information.",
|
|
28
|
+
inputSchema: r
|
|
29
|
+
}),
|
|
30
|
+
getOnlineStatus: e({
|
|
31
|
+
name: "get-online-status",
|
|
32
|
+
description: "Return the current TanStack Query onlineManager status.",
|
|
33
|
+
inputSchema: r
|
|
34
|
+
}),
|
|
35
|
+
setOnlineStatus: e({
|
|
36
|
+
name: "set-online-status",
|
|
37
|
+
description: "Set the TanStack Query onlineManager status for testing offline/online behavior.",
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
online: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
description: "Whether the TanStack Query onlineManager should be online."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
required: ["online"]
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
listQueries: e({
|
|
50
|
+
name: "list-queries",
|
|
51
|
+
description: "List TanStack Query query summaries using cursor pagination.",
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: "object",
|
|
54
|
+
properties: a
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
getQueryDetails: e({
|
|
58
|
+
name: "get-query-details",
|
|
59
|
+
description: "Return a JSON-safe TanStack Query query snapshot and observer summary.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: t,
|
|
63
|
+
required: ["queryHash"]
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
refetchQuery: e({
|
|
67
|
+
name: "refetch-query",
|
|
68
|
+
description: "Refetch a TanStack Query query by queryHash.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: t,
|
|
72
|
+
required: ["queryHash"]
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
setQueryLoading: e({
|
|
76
|
+
name: "set-query-loading",
|
|
77
|
+
description: "Enable or disable TanStack Query loading-state simulation for a query by queryHash.",
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {
|
|
81
|
+
...t,
|
|
82
|
+
enabled: {
|
|
83
|
+
type: "boolean",
|
|
84
|
+
description: "Whether the loading-state simulation should be enabled."
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
required: ["queryHash", "enabled"]
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
setQueryError: e({
|
|
91
|
+
name: "set-query-error",
|
|
92
|
+
description: "Enable or disable TanStack Query error-state simulation for a query by queryHash.",
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: "object",
|
|
95
|
+
properties: {
|
|
96
|
+
...t,
|
|
97
|
+
enabled: {
|
|
98
|
+
type: "boolean",
|
|
99
|
+
description: "Whether the error-state simulation should be enabled."
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
required: ["queryHash", "enabled"]
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
invalidateQuery: e({
|
|
106
|
+
name: "invalidate-query",
|
|
107
|
+
description: "Invalidate a TanStack Query query by queryHash.",
|
|
108
|
+
inputSchema: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: t,
|
|
111
|
+
required: ["queryHash"]
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
resetQuery: e({
|
|
115
|
+
name: "reset-query",
|
|
116
|
+
description: "Reset a TanStack Query query by queryHash.",
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: t,
|
|
120
|
+
required: ["queryHash"]
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
removeQuery: e({
|
|
124
|
+
name: "remove-query",
|
|
125
|
+
description: "Remove a TanStack Query query from the cache by queryHash.",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: t,
|
|
129
|
+
required: ["queryHash"]
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
clearQueryCache: e({
|
|
133
|
+
name: "clear-query-cache",
|
|
134
|
+
description: "Clear the full TanStack Query query cache.",
|
|
135
|
+
inputSchema: r
|
|
136
|
+
}),
|
|
137
|
+
listMutations: e({
|
|
138
|
+
name: "list-mutations",
|
|
139
|
+
description: "List TanStack Query mutation summaries using cursor pagination.",
|
|
140
|
+
inputSchema: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: a
|
|
143
|
+
}
|
|
144
|
+
}),
|
|
145
|
+
getMutationDetails: e({
|
|
146
|
+
name: "get-mutation-details",
|
|
147
|
+
description: "Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",
|
|
148
|
+
inputSchema: {
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: o,
|
|
151
|
+
required: ["mutationId"]
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
clearMutationCache: e({
|
|
155
|
+
name: "clear-mutation-cache",
|
|
156
|
+
description: "Clear the full TanStack Query mutation cache.",
|
|
157
|
+
inputSchema: r
|
|
158
|
+
})
|
|
159
|
+
}, c = n(
|
|
160
|
+
i,
|
|
161
|
+
u
|
|
162
|
+
);
|
|
163
|
+
export {
|
|
164
|
+
i as TANSTACK_QUERY_AGENT_PLUGIN_ID,
|
|
165
|
+
u as tanstackQueryToolDefinitions,
|
|
166
|
+
c as tanstackQueryTools
|
|
167
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rozenite/tanstack-query-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "TanStack Query for Rozenite.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/react-native/index.cjs",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"fast-deep-equal": "^3.1.3",
|
|
19
|
-
"@rozenite/
|
|
20
|
-
"@rozenite/
|
|
19
|
+
"@rozenite/plugin-bridge": "1.8.0",
|
|
20
|
+
"@rozenite/agent-bridge": "1.8.0",
|
|
21
|
+
"@rozenite/agent-shared": "1.8.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
"tailwindcss-animate": "^1.0.7",
|
|
34
35
|
"typescript": "~5.9.3",
|
|
35
36
|
"vite": "^7.3.1",
|
|
36
|
-
"@rozenite/vite-plugin": "1.
|
|
37
|
-
"rozenite": "1.
|
|
37
|
+
"@rozenite/vite-plugin": "1.8.0",
|
|
38
|
+
"rozenite": "1.8.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -48,7 +49,13 @@
|
|
|
48
49
|
"import": "./dist/react-native/index.js",
|
|
49
50
|
"require": "./dist/react-native/index.cjs"
|
|
50
51
|
},
|
|
51
|
-
"./package.json": "./package.json"
|
|
52
|
+
"./package.json": "./package.json",
|
|
53
|
+
"./sdk": {
|
|
54
|
+
"development": "./sdk.ts",
|
|
55
|
+
"types": "./dist/sdk/index.d.ts",
|
|
56
|
+
"import": "./dist/sdk/index.js",
|
|
57
|
+
"require": "./dist/sdk/index.cjs"
|
|
58
|
+
}
|
|
52
59
|
},
|
|
53
60
|
"publishConfig": {
|
|
54
61
|
"access": "public"
|
package/sdk.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineAgentToolDescriptors } from '@rozenite/agent-shared';
|
|
2
|
+
import {
|
|
3
|
+
TANSTACK_QUERY_AGENT_PLUGIN_ID,
|
|
4
|
+
tanstackQueryToolDefinitions,
|
|
5
|
+
} from './src/shared/agent-tools.js';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
TANSTACK_QUERY_AGENT_PLUGIN_ID,
|
|
9
|
+
tanstackQueryToolDefinitions,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const tanstackQueryTools = defineAgentToolDescriptors(
|
|
13
|
+
TANSTACK_QUERY_AGENT_PLUGIN_ID,
|
|
14
|
+
tanstackQueryToolDefinitions,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
TanStackQueryActionResult,
|
|
19
|
+
TanStackQueryAgentMutationIdInput,
|
|
20
|
+
TanStackQueryAgentOnlineStatusInput,
|
|
21
|
+
TanStackQueryAgentPaginationInput,
|
|
22
|
+
TanStackQueryAgentQueryHashInput,
|
|
23
|
+
TanStackQueryAgentQueryToggleInput,
|
|
24
|
+
TanStackQueryAgentSafeValue,
|
|
25
|
+
TanStackQueryCacheSummary,
|
|
26
|
+
TanStackQueryClearMutationCacheArgs,
|
|
27
|
+
TanStackQueryClearMutationCacheResult,
|
|
28
|
+
TanStackQueryClearQueryCacheArgs,
|
|
29
|
+
TanStackQueryClearQueryCacheResult,
|
|
30
|
+
TanStackQueryGetCacheSummaryArgs,
|
|
31
|
+
TanStackQueryGetCacheSummaryResult,
|
|
32
|
+
TanStackQueryGetMutationDetailsArgs,
|
|
33
|
+
TanStackQueryGetMutationDetailsResult,
|
|
34
|
+
TanStackQueryGetOnlineStatusArgs,
|
|
35
|
+
TanStackQueryGetOnlineStatusResult,
|
|
36
|
+
TanStackQueryGetQueryDetailsArgs,
|
|
37
|
+
TanStackQueryGetQueryDetailsResult,
|
|
38
|
+
TanStackQueryInvalidateQueryArgs,
|
|
39
|
+
TanStackQueryListMutationsArgs,
|
|
40
|
+
TanStackQueryListMutationsResult,
|
|
41
|
+
TanStackQueryListQueriesArgs,
|
|
42
|
+
TanStackQueryListQueriesResult,
|
|
43
|
+
TanStackQueryMutationOptionsSummary,
|
|
44
|
+
TanStackQueryMutationSummary,
|
|
45
|
+
TanStackQueryObserverOptionsSummary,
|
|
46
|
+
TanStackQueryPage,
|
|
47
|
+
TanStackQueryQuerySummary,
|
|
48
|
+
TanStackQueryRefetchQueryArgs,
|
|
49
|
+
TanStackQueryRemoveQueryArgs,
|
|
50
|
+
TanStackQueryResetQueryArgs,
|
|
51
|
+
TanStackQuerySetOnlineStatusArgs,
|
|
52
|
+
TanStackQuerySetOnlineStatusResult,
|
|
53
|
+
TanStackQuerySetQueryErrorArgs,
|
|
54
|
+
TanStackQuerySetQueryLoadingArgs,
|
|
55
|
+
} from './src/shared/agent-tools.js';
|
|
@@ -5,14 +5,12 @@ import {
|
|
|
5
5
|
QueryObserver,
|
|
6
6
|
onlineManager,
|
|
7
7
|
} from '@tanstack/react-query';
|
|
8
|
-
import {
|
|
9
|
-
applyTanStackQueryDevtoolsAction,
|
|
10
|
-
} from '../../devtools-actions';
|
|
8
|
+
import { applyTanStackQueryDevtoolsAction } from '../../devtools-actions';
|
|
11
9
|
import {
|
|
12
10
|
createTanStackQueryAgentController,
|
|
13
11
|
serializeForAgent,
|
|
14
|
-
TANSTACK_QUERY_AGENT_TOOLS,
|
|
15
12
|
} from '../tanstack-query-agent';
|
|
13
|
+
import { tanstackQueryToolDefinitions } from '../../../shared/agent-tools';
|
|
16
14
|
|
|
17
15
|
const createQueryClient = () =>
|
|
18
16
|
new QueryClient({
|
|
@@ -30,7 +28,7 @@ const createQueryClient = () =>
|
|
|
30
28
|
|
|
31
29
|
const subscribeController = (
|
|
32
30
|
queryClient: QueryClient,
|
|
33
|
-
controller: ReturnType<typeof createTanStackQueryAgentController
|
|
31
|
+
controller: ReturnType<typeof createTanStackQueryAgentController>,
|
|
34
32
|
) => {
|
|
35
33
|
const unsubscribeQuery = queryClient
|
|
36
34
|
.getQueryCache()
|
|
@@ -58,7 +56,7 @@ const createMutation = (
|
|
|
58
56
|
context?: unknown;
|
|
59
57
|
failureCount?: number;
|
|
60
58
|
failureReason?: Error | null;
|
|
61
|
-
}
|
|
59
|
+
},
|
|
62
60
|
) => {
|
|
63
61
|
return queryClient.getMutationCache().build(
|
|
64
62
|
queryClient,
|
|
@@ -78,7 +76,7 @@ const createMutation = (
|
|
|
78
76
|
status: options?.status ?? 'success',
|
|
79
77
|
submittedAt: options?.submittedAt ?? Date.now(),
|
|
80
78
|
variables: options?.variables,
|
|
81
|
-
} as any
|
|
79
|
+
} as any,
|
|
82
80
|
) as Mutation<unknown, Error, unknown, unknown>;
|
|
83
81
|
};
|
|
84
82
|
|
|
@@ -89,7 +87,9 @@ afterEach(() => {
|
|
|
89
87
|
|
|
90
88
|
describe('tanstack query agent controller', () => {
|
|
91
89
|
it('exposes the expected tool names', () => {
|
|
92
|
-
expect(
|
|
90
|
+
expect(
|
|
91
|
+
Object.values(tanstackQueryToolDefinitions).map((tool) => tool.name),
|
|
92
|
+
).toEqual([
|
|
93
93
|
'get-cache-summary',
|
|
94
94
|
'get-online-status',
|
|
95
95
|
'set-online-status',
|
|
@@ -106,6 +106,10 @@ describe('tanstack query agent controller', () => {
|
|
|
106
106
|
'get-mutation-details',
|
|
107
107
|
'clear-mutation-cache',
|
|
108
108
|
]);
|
|
109
|
+
expect(tanstackQueryToolDefinitions.setQueryLoading.inputSchema.required).toEqual([
|
|
110
|
+
'queryHash',
|
|
111
|
+
'enabled',
|
|
112
|
+
]);
|
|
109
113
|
});
|
|
110
114
|
|
|
111
115
|
it('lists queries with cursor pagination and invalidates stale cursors after additions', async () => {
|
|
@@ -126,8 +130,10 @@ describe('tanstack query agent controller', () => {
|
|
|
126
130
|
controller.listQueries({
|
|
127
131
|
limit: 1,
|
|
128
132
|
cursor: firstPage.page.nextCursor,
|
|
129
|
-
})
|
|
130
|
-
).toThrow(
|
|
133
|
+
}),
|
|
134
|
+
).toThrow(
|
|
135
|
+
'Cursor does not match the requested listing. Run the command again.',
|
|
136
|
+
);
|
|
131
137
|
|
|
132
138
|
unsubscribe();
|
|
133
139
|
});
|
|
@@ -147,8 +153,10 @@ describe('tanstack query agent controller', () => {
|
|
|
147
153
|
controller.listQueries({
|
|
148
154
|
limit: 1,
|
|
149
155
|
cursor: firstPage.page.nextCursor,
|
|
150
|
-
})
|
|
151
|
-
).toThrow(
|
|
156
|
+
}),
|
|
157
|
+
).toThrow(
|
|
158
|
+
'Cursor does not match the requested listing. Run the command again.',
|
|
159
|
+
);
|
|
152
160
|
|
|
153
161
|
queryClient.setQueryData(['third'], { value: 3 });
|
|
154
162
|
queryClient.setQueryData(['fourth'], { value: 4 });
|
|
@@ -159,8 +167,10 @@ describe('tanstack query agent controller', () => {
|
|
|
159
167
|
controller.listQueries({
|
|
160
168
|
limit: 1,
|
|
161
169
|
cursor: secondPageSeed.page.nextCursor,
|
|
162
|
-
})
|
|
163
|
-
).toThrow(
|
|
170
|
+
}),
|
|
171
|
+
).toThrow(
|
|
172
|
+
'Cursor does not match the requested listing. Run the command again.',
|
|
173
|
+
);
|
|
164
174
|
|
|
165
175
|
unsubscribe();
|
|
166
176
|
});
|
|
@@ -194,8 +204,10 @@ describe('tanstack query agent controller', () => {
|
|
|
194
204
|
controller.listMutations({
|
|
195
205
|
limit: 1,
|
|
196
206
|
cursor: firstPage.page.nextCursor,
|
|
197
|
-
})
|
|
198
|
-
).toThrow(
|
|
207
|
+
}),
|
|
208
|
+
).toThrow(
|
|
209
|
+
'Cursor does not match the requested listing. Run the command again.',
|
|
210
|
+
);
|
|
199
211
|
|
|
200
212
|
const mutation = queryClient.getMutationCache().getAll()[0];
|
|
201
213
|
queryClient.getMutationCache().remove(mutation);
|
|
@@ -207,8 +219,10 @@ describe('tanstack query agent controller', () => {
|
|
|
207
219
|
controller.listMutations({
|
|
208
220
|
limit: 1,
|
|
209
221
|
cursor: secondPageSeed.page.nextCursor,
|
|
210
|
-
})
|
|
211
|
-
).toThrow(
|
|
222
|
+
}),
|
|
223
|
+
).toThrow(
|
|
224
|
+
'Cursor does not match the requested listing. Run the command again.',
|
|
225
|
+
);
|
|
212
226
|
|
|
213
227
|
unsubscribe();
|
|
214
228
|
});
|
|
@@ -234,8 +248,9 @@ describe('tanstack query agent controller', () => {
|
|
|
234
248
|
queryFn,
|
|
235
249
|
});
|
|
236
250
|
|
|
237
|
-
const queryHash = queryClient
|
|
238
|
-
.
|
|
251
|
+
const queryHash = queryClient
|
|
252
|
+
.getQueryCache()
|
|
253
|
+
.find({ queryKey: ['todos', 1] })!.queryHash;
|
|
239
254
|
const details = controller.getQueryDetails({ queryHash });
|
|
240
255
|
|
|
241
256
|
expect(details.query).toMatchObject({
|
|
@@ -299,9 +314,9 @@ describe('tanstack query agent controller', () => {
|
|
|
299
314
|
},
|
|
300
315
|
});
|
|
301
316
|
|
|
302
|
-
expect(() =>
|
|
303
|
-
|
|
304
|
-
)
|
|
317
|
+
expect(() => controller.getMutationDetails({ mutationId: 9999 })).toThrow(
|
|
318
|
+
'Unknown mutationId "9999"',
|
|
319
|
+
);
|
|
305
320
|
|
|
306
321
|
unsubscribe();
|
|
307
322
|
});
|
|
@@ -310,9 +325,9 @@ describe('tanstack query agent controller', () => {
|
|
|
310
325
|
const queryClient = createQueryClient();
|
|
311
326
|
const controller = createTanStackQueryAgentController(queryClient);
|
|
312
327
|
|
|
313
|
-
expect(() =>
|
|
314
|
-
|
|
315
|
-
)
|
|
328
|
+
expect(() => controller.getQueryDetails({ queryHash: 'missing' })).toThrow(
|
|
329
|
+
'Unknown queryHash "missing"',
|
|
330
|
+
);
|
|
316
331
|
});
|
|
317
332
|
|
|
318
333
|
it('gets and sets the online manager status', () => {
|
|
@@ -461,6 +476,37 @@ describe('tanstack query agent actions', () => {
|
|
|
461
476
|
});
|
|
462
477
|
});
|
|
463
478
|
|
|
479
|
+
it('sets query data through the shared UI dispatcher', async () => {
|
|
480
|
+
const queryClient = createQueryClient();
|
|
481
|
+
|
|
482
|
+
await queryClient.fetchQuery({
|
|
483
|
+
queryKey: ['editable-query'],
|
|
484
|
+
queryFn: async () => ({ value: 'initial' }),
|
|
485
|
+
initialData: { value: 'initial' },
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
const query = queryClient.getQueryCache().find({
|
|
489
|
+
queryKey: ['editable-query'],
|
|
490
|
+
})!;
|
|
491
|
+
|
|
492
|
+
const result = await applyTanStackQueryDevtoolsAction(queryClient, {
|
|
493
|
+
type: 'SET_QUERY_DATA',
|
|
494
|
+
queryHash: query.queryHash,
|
|
495
|
+
metadata: {
|
|
496
|
+
data: { value: 'changed' },
|
|
497
|
+
},
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
expect(result).toMatchObject({
|
|
501
|
+
applied: true,
|
|
502
|
+
action: 'SET_QUERY_DATA',
|
|
503
|
+
queryHash: query.queryHash,
|
|
504
|
+
});
|
|
505
|
+
expect(queryClient.getQueryData(['editable-query'])).toEqual({
|
|
506
|
+
value: 'changed',
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
|
|
464
510
|
it('clears mutation cache through the shared UI/agent dispatcher', async () => {
|
|
465
511
|
const queryClient = createQueryClient();
|
|
466
512
|
createMutation(queryClient, {
|
|
@@ -501,8 +547,6 @@ describe('serializeForAgent', () => {
|
|
|
501
547
|
ok: true,
|
|
502
548
|
self: '[circular]',
|
|
503
549
|
});
|
|
504
|
-
expect(serializeForAgent(new Example())).toBe(
|
|
505
|
-
'[non-serializable:Example]'
|
|
506
|
-
);
|
|
550
|
+
expect(serializeForAgent(new Example())).toBe('[non-serializable:Example]');
|
|
507
551
|
});
|
|
508
552
|
});
|