@rozenite/tanstack-query-plugin 1.7.0 → 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 +21 -0
- package/dist/devtools/assets/{CXEL7IU7-OLImOSaA.js → CXEL7IU7-DmbowaBr.js} +1 -1
- package/dist/devtools/assets/{tanstack-query-Dk7i2Fss.js → tanstack-query-DRBLkSCy.js} +10 -10
- 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 +324 -295
- 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 +8 -2
- package/src/react-native/agent/tanstack-query-agent.ts +33 -235
- package/src/react-native/agent/useTanStackQueryAgentTools.ts +39 -65
- package/src/shared/agent-tools.ts +403 -0
- package/tsconfig.json +4 -1
- package/vite.config.ts +7 -0
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { useRozeniteDevToolsClient as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { onlineManager as
|
|
4
|
-
import
|
|
5
|
-
import { useRozenitePluginAgentTool as
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { useRozeniteDevToolsClient as D } from "@rozenite/plugin-bridge";
|
|
2
|
+
import { useEffect as A, useRef as w, useMemo as I } from "react";
|
|
3
|
+
import { onlineManager as S } from "@tanstack/react-query";
|
|
4
|
+
import C from "fast-deep-equal";
|
|
5
|
+
import { useRozenitePluginAgentTool as i } from "@rozenite/agent-bridge";
|
|
6
|
+
import { defineAgentToolContract as c } from "@rozenite/agent-shared";
|
|
7
|
+
const _ = (e) => {
|
|
8
|
+
A(() => {
|
|
8
9
|
if (!e)
|
|
9
10
|
return;
|
|
10
|
-
const r =
|
|
11
|
+
const r = S.subscribe((a) => {
|
|
11
12
|
e.send("online-status-changed", { online: a });
|
|
12
13
|
}), t = e.onMessage(
|
|
13
14
|
"online-status-changed",
|
|
14
15
|
({ online: a }) => {
|
|
15
|
-
|
|
16
|
+
S.setOnline(a);
|
|
16
17
|
}
|
|
17
18
|
);
|
|
18
19
|
return () => {
|
|
19
20
|
r(), t.remove();
|
|
20
21
|
};
|
|
21
22
|
}, [e]);
|
|
22
|
-
},
|
|
23
|
+
}, m = (e, r) => {
|
|
23
24
|
if (!r)
|
|
24
25
|
throw new Error("queryHash is required for this TanStack Query action.");
|
|
25
26
|
const t = e.getQueryCache().get(r);
|
|
26
27
|
if (!t)
|
|
27
28
|
throw new Error(`No active query found for hash: ${r}`);
|
|
28
29
|
return t;
|
|
29
|
-
},
|
|
30
|
+
}, f = async (e, r) => {
|
|
30
31
|
switch (r.type) {
|
|
31
32
|
case "CLEAR_QUERY_CACHE": {
|
|
32
33
|
const t = e.getQueryCache().getAll().length;
|
|
@@ -49,7 +50,7 @@ const w = (e) => {
|
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
case "SET_QUERY_DATA": {
|
|
52
|
-
const t =
|
|
53
|
+
const t = m(e, r.queryHash);
|
|
53
54
|
return e.setQueryData(t.queryKey, r.metadata?.data), {
|
|
54
55
|
applied: !0,
|
|
55
56
|
action: r.type,
|
|
@@ -57,7 +58,7 @@ const w = (e) => {
|
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
case "TRIGGER_ERROR": {
|
|
60
|
-
const t =
|
|
61
|
+
const t = m(e, r.queryHash), a = t.options, n = new Error("Unknown error from devtools");
|
|
61
62
|
return t.setState({
|
|
62
63
|
status: "error",
|
|
63
64
|
error: n,
|
|
@@ -73,7 +74,7 @@ const w = (e) => {
|
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
76
|
case "RESTORE_ERROR": {
|
|
76
|
-
const t =
|
|
77
|
+
const t = m(e, r.queryHash);
|
|
77
78
|
return await e.resetQueries(t), {
|
|
78
79
|
applied: !0,
|
|
79
80
|
action: r.type,
|
|
@@ -81,7 +82,7 @@ const w = (e) => {
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
case "TRIGGER_LOADING": {
|
|
84
|
-
const t =
|
|
85
|
+
const t = m(e, r.queryHash), a = t.options;
|
|
85
86
|
return t.fetch({
|
|
86
87
|
...a,
|
|
87
88
|
queryFn: () => new Promise(() => {
|
|
@@ -102,7 +103,7 @@ const w = (e) => {
|
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
105
|
case "RESTORE_LOADING": {
|
|
105
|
-
const t =
|
|
106
|
+
const t = m(e, r.queryHash), a = t.state, n = t.state.fetchMeta ? t.state.fetchMeta.__previousQueryOptions : null;
|
|
106
107
|
return t.cancel({ silent: !0 }), t.setState({
|
|
107
108
|
...a,
|
|
108
109
|
fetchStatus: "idle",
|
|
@@ -114,7 +115,7 @@ const w = (e) => {
|
|
|
114
115
|
};
|
|
115
116
|
}
|
|
116
117
|
case "RESET": {
|
|
117
|
-
const t =
|
|
118
|
+
const t = m(e, r.queryHash);
|
|
118
119
|
return await e.resetQueries(t), {
|
|
119
120
|
applied: !0,
|
|
120
121
|
action: r.type,
|
|
@@ -122,7 +123,7 @@ const w = (e) => {
|
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
case "REMOVE": {
|
|
125
|
-
const t =
|
|
126
|
+
const t = m(e, r.queryHash);
|
|
126
127
|
return e.removeQueries(t), {
|
|
127
128
|
applied: !0,
|
|
128
129
|
action: r.type,
|
|
@@ -130,7 +131,7 @@ const w = (e) => {
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
case "REFETCH": {
|
|
133
|
-
const t =
|
|
134
|
+
const t = m(e, r.queryHash);
|
|
134
135
|
return await t.fetch().catch(() => {
|
|
135
136
|
}), {
|
|
136
137
|
applied: !0,
|
|
@@ -139,7 +140,7 @@ const w = (e) => {
|
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
case "INVALIDATE": {
|
|
142
|
-
const t =
|
|
143
|
+
const t = m(e, r.queryHash);
|
|
143
144
|
return await e.invalidateQueries(t), {
|
|
144
145
|
applied: !0,
|
|
145
146
|
action: r.type,
|
|
@@ -147,19 +148,19 @@ const w = (e) => {
|
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
|
-
},
|
|
151
|
-
|
|
151
|
+
}, U = (e, r) => {
|
|
152
|
+
A(() => {
|
|
152
153
|
if (!r)
|
|
153
154
|
return;
|
|
154
155
|
const t = r.onMessage(
|
|
155
156
|
"devtools-action",
|
|
156
|
-
({ type: a, queryHash: n, metadata:
|
|
157
|
-
|
|
157
|
+
({ type: a, queryHash: n, metadata: h }) => {
|
|
158
|
+
f(e, {
|
|
158
159
|
type: a,
|
|
159
160
|
queryHash: n,
|
|
160
|
-
metadata:
|
|
161
|
-
}).catch((
|
|
162
|
-
const s =
|
|
161
|
+
metadata: h
|
|
162
|
+
}).catch((p) => {
|
|
163
|
+
const s = p instanceof Error ? p.message : String(p);
|
|
163
164
|
console.warn(
|
|
164
165
|
`[Rozenite, tanstack-query-plugin] Failed to apply devtools action "${a}": ${s}`
|
|
165
166
|
);
|
|
@@ -170,41 +171,41 @@ const w = (e) => {
|
|
|
170
171
|
t.remove();
|
|
171
172
|
};
|
|
172
173
|
}, [r]);
|
|
173
|
-
},
|
|
174
|
+
}, R = (e) => e.observers.map((r) => ({
|
|
174
175
|
queryHash: e.queryHash,
|
|
175
176
|
options: r.options
|
|
176
|
-
})),
|
|
177
|
-
const r =
|
|
177
|
+
})), H = (e) => {
|
|
178
|
+
const r = R(e);
|
|
178
179
|
return {
|
|
179
180
|
state: e.state,
|
|
180
181
|
queryKey: e.queryKey,
|
|
181
182
|
queryHash: e.queryHash,
|
|
182
183
|
observers: r
|
|
183
184
|
};
|
|
184
|
-
},
|
|
185
|
+
}, k = (e) => ({
|
|
185
186
|
mutationId: e.mutationId,
|
|
186
187
|
state: e.state,
|
|
187
188
|
options: e.options
|
|
188
|
-
}),
|
|
189
|
-
queries: e.getQueryCache().getAll().map(
|
|
190
|
-
mutations: e.getMutationCache().getAll().map(
|
|
191
|
-
}),
|
|
192
|
-
const t =
|
|
189
|
+
}), G = (e) => ({
|
|
190
|
+
queries: e.getQueryCache().getAll().map(H),
|
|
191
|
+
mutations: e.getMutationCache().getAll().map(k)
|
|
192
|
+
}), j = (e, r) => {
|
|
193
|
+
const t = w(
|
|
193
194
|
/* @__PURE__ */ new Map()
|
|
194
|
-
), a =
|
|
195
|
+
), a = I(() => (n) => {
|
|
195
196
|
if (!r || n.type === "observerResultsUpdated")
|
|
196
197
|
return;
|
|
197
198
|
if ("query" in n) {
|
|
198
|
-
const { query: s, type:
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
r.send("sync-query-event", { type:
|
|
199
|
+
const { query: s, type: l } = n;
|
|
200
|
+
if (l === "added" || l === "removed") {
|
|
201
|
+
l === "removed" && t.current.delete(s.queryHash);
|
|
202
|
+
const g = H(s);
|
|
203
|
+
r.send("sync-query-event", { type: l, data: g });
|
|
203
204
|
return;
|
|
204
205
|
}
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
switch (
|
|
206
|
+
if (l === "updated" && "action" in n) {
|
|
207
|
+
const g = n.action;
|
|
208
|
+
switch (g.type) {
|
|
208
209
|
case "fetch": {
|
|
209
210
|
const u = {
|
|
210
211
|
queryHash: s.queryHash,
|
|
@@ -262,7 +263,7 @@ const w = (e) => {
|
|
|
262
263
|
case "setState": {
|
|
263
264
|
const u = {
|
|
264
265
|
queryHash: s.queryHash,
|
|
265
|
-
state:
|
|
266
|
+
state: g.state
|
|
266
267
|
// Only the changed state parts
|
|
267
268
|
};
|
|
268
269
|
r.send("sync-query-event", {
|
|
@@ -315,61 +316,218 @@ const w = (e) => {
|
|
|
315
316
|
break;
|
|
316
317
|
}
|
|
317
318
|
default: {
|
|
318
|
-
const u =
|
|
319
|
-
r.send("sync-query-event", { type:
|
|
319
|
+
const u = H(s);
|
|
320
|
+
r.send("sync-query-event", { type: l, data: u });
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
return;
|
|
323
324
|
}
|
|
324
|
-
if (
|
|
325
|
-
const
|
|
325
|
+
if (l === "observerAdded" || l === "observerRemoved" || l === "observerOptionsUpdated") {
|
|
326
|
+
const g = R(s), u = t.current.get(
|
|
326
327
|
s.queryHash
|
|
327
328
|
);
|
|
328
|
-
if (
|
|
329
|
+
if (l === "observerOptionsUpdated" && u && C(u, g))
|
|
329
330
|
return;
|
|
330
331
|
t.current.set(
|
|
331
332
|
s.queryHash,
|
|
332
|
-
|
|
333
|
+
g
|
|
333
334
|
), r.send("sync-query-event", {
|
|
334
|
-
type:
|
|
335
|
+
type: l,
|
|
335
336
|
data: {
|
|
336
337
|
queryHash: s.queryHash,
|
|
337
|
-
observers:
|
|
338
|
+
observers: g
|
|
338
339
|
}
|
|
339
340
|
});
|
|
340
341
|
return;
|
|
341
342
|
}
|
|
342
343
|
}
|
|
343
|
-
const { mutation:
|
|
344
|
-
if (
|
|
345
|
-
const s =
|
|
344
|
+
const { mutation: h, type: p } = n;
|
|
345
|
+
if (h) {
|
|
346
|
+
const s = k(h);
|
|
346
347
|
r.send("sync-mutation-event", {
|
|
347
|
-
type:
|
|
348
|
+
type: p,
|
|
348
349
|
data: s
|
|
349
350
|
});
|
|
350
351
|
}
|
|
351
352
|
}, [r]);
|
|
352
|
-
|
|
353
|
+
A(() => {
|
|
353
354
|
if (!r)
|
|
354
355
|
return;
|
|
355
|
-
const n = e.getMutationCache().subscribe(a),
|
|
356
|
+
const n = e.getMutationCache().subscribe(a), h = e.getQueryCache().subscribe(a);
|
|
356
357
|
return () => {
|
|
357
|
-
n(),
|
|
358
|
+
n(), h();
|
|
358
359
|
};
|
|
359
360
|
}, [r, e, a]);
|
|
360
|
-
},
|
|
361
|
-
|
|
361
|
+
}, N = (e, r) => {
|
|
362
|
+
A(() => {
|
|
362
363
|
if (!r)
|
|
363
364
|
return;
|
|
364
365
|
const t = r.onMessage("request-initial-data", () => {
|
|
365
|
-
const a =
|
|
366
|
+
const a = G(e);
|
|
366
367
|
r.send("sync-data", { data: a });
|
|
367
368
|
});
|
|
368
369
|
return () => {
|
|
369
370
|
t.remove();
|
|
370
371
|
};
|
|
371
372
|
}, [r, e]);
|
|
372
|
-
},
|
|
373
|
+
}, d = "@rozenite/tanstack-query-plugin", b = {
|
|
374
|
+
queryHash: {
|
|
375
|
+
type: "string",
|
|
376
|
+
description: "TanStack Query queryHash identifying the query."
|
|
377
|
+
}
|
|
378
|
+
}, L = {
|
|
379
|
+
mutationId: {
|
|
380
|
+
type: "number",
|
|
381
|
+
description: "TanStack Query mutationId identifying the mutation."
|
|
382
|
+
}
|
|
383
|
+
}, v = {
|
|
384
|
+
limit: {
|
|
385
|
+
type: "number",
|
|
386
|
+
description: "Maximum number of items to return. Defaults to 20. Maximum 100."
|
|
387
|
+
},
|
|
388
|
+
cursor: {
|
|
389
|
+
type: "string",
|
|
390
|
+
description: "Opaque pagination cursor from a previous list call."
|
|
391
|
+
}
|
|
392
|
+
}, q = {
|
|
393
|
+
type: "object",
|
|
394
|
+
properties: {}
|
|
395
|
+
}, y = {
|
|
396
|
+
getCacheSummary: c({
|
|
397
|
+
name: "get-cache-summary",
|
|
398
|
+
description: "Return aggregate TanStack Query cache health and count information.",
|
|
399
|
+
inputSchema: q
|
|
400
|
+
}),
|
|
401
|
+
getOnlineStatus: c({
|
|
402
|
+
name: "get-online-status",
|
|
403
|
+
description: "Return the current TanStack Query onlineManager status.",
|
|
404
|
+
inputSchema: q
|
|
405
|
+
}),
|
|
406
|
+
setOnlineStatus: c({
|
|
407
|
+
name: "set-online-status",
|
|
408
|
+
description: "Set the TanStack Query onlineManager status for testing offline/online behavior.",
|
|
409
|
+
inputSchema: {
|
|
410
|
+
type: "object",
|
|
411
|
+
properties: {
|
|
412
|
+
online: {
|
|
413
|
+
type: "boolean",
|
|
414
|
+
description: "Whether the TanStack Query onlineManager should be online."
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
required: ["online"]
|
|
418
|
+
}
|
|
419
|
+
}),
|
|
420
|
+
listQueries: c({
|
|
421
|
+
name: "list-queries",
|
|
422
|
+
description: "List TanStack Query query summaries using cursor pagination.",
|
|
423
|
+
inputSchema: {
|
|
424
|
+
type: "object",
|
|
425
|
+
properties: v
|
|
426
|
+
}
|
|
427
|
+
}),
|
|
428
|
+
getQueryDetails: c({
|
|
429
|
+
name: "get-query-details",
|
|
430
|
+
description: "Return a JSON-safe TanStack Query query snapshot and observer summary.",
|
|
431
|
+
inputSchema: {
|
|
432
|
+
type: "object",
|
|
433
|
+
properties: b,
|
|
434
|
+
required: ["queryHash"]
|
|
435
|
+
}
|
|
436
|
+
}),
|
|
437
|
+
refetchQuery: c({
|
|
438
|
+
name: "refetch-query",
|
|
439
|
+
description: "Refetch a TanStack Query query by queryHash.",
|
|
440
|
+
inputSchema: {
|
|
441
|
+
type: "object",
|
|
442
|
+
properties: b,
|
|
443
|
+
required: ["queryHash"]
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
setQueryLoading: c({
|
|
447
|
+
name: "set-query-loading",
|
|
448
|
+
description: "Enable or disable TanStack Query loading-state simulation for a query by queryHash.",
|
|
449
|
+
inputSchema: {
|
|
450
|
+
type: "object",
|
|
451
|
+
properties: {
|
|
452
|
+
...b,
|
|
453
|
+
enabled: {
|
|
454
|
+
type: "boolean",
|
|
455
|
+
description: "Whether the loading-state simulation should be enabled."
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
required: ["queryHash", "enabled"]
|
|
459
|
+
}
|
|
460
|
+
}),
|
|
461
|
+
setQueryError: c({
|
|
462
|
+
name: "set-query-error",
|
|
463
|
+
description: "Enable or disable TanStack Query error-state simulation for a query by queryHash.",
|
|
464
|
+
inputSchema: {
|
|
465
|
+
type: "object",
|
|
466
|
+
properties: {
|
|
467
|
+
...b,
|
|
468
|
+
enabled: {
|
|
469
|
+
type: "boolean",
|
|
470
|
+
description: "Whether the error-state simulation should be enabled."
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
required: ["queryHash", "enabled"]
|
|
474
|
+
}
|
|
475
|
+
}),
|
|
476
|
+
invalidateQuery: c({
|
|
477
|
+
name: "invalidate-query",
|
|
478
|
+
description: "Invalidate a TanStack Query query by queryHash.",
|
|
479
|
+
inputSchema: {
|
|
480
|
+
type: "object",
|
|
481
|
+
properties: b,
|
|
482
|
+
required: ["queryHash"]
|
|
483
|
+
}
|
|
484
|
+
}),
|
|
485
|
+
resetQuery: c({
|
|
486
|
+
name: "reset-query",
|
|
487
|
+
description: "Reset a TanStack Query query by queryHash.",
|
|
488
|
+
inputSchema: {
|
|
489
|
+
type: "object",
|
|
490
|
+
properties: b,
|
|
491
|
+
required: ["queryHash"]
|
|
492
|
+
}
|
|
493
|
+
}),
|
|
494
|
+
removeQuery: c({
|
|
495
|
+
name: "remove-query",
|
|
496
|
+
description: "Remove a TanStack Query query from the cache by queryHash.",
|
|
497
|
+
inputSchema: {
|
|
498
|
+
type: "object",
|
|
499
|
+
properties: b,
|
|
500
|
+
required: ["queryHash"]
|
|
501
|
+
}
|
|
502
|
+
}),
|
|
503
|
+
clearQueryCache: c({
|
|
504
|
+
name: "clear-query-cache",
|
|
505
|
+
description: "Clear the full TanStack Query query cache.",
|
|
506
|
+
inputSchema: q
|
|
507
|
+
}),
|
|
508
|
+
listMutations: c({
|
|
509
|
+
name: "list-mutations",
|
|
510
|
+
description: "List TanStack Query mutation summaries using cursor pagination.",
|
|
511
|
+
inputSchema: {
|
|
512
|
+
type: "object",
|
|
513
|
+
properties: v
|
|
514
|
+
}
|
|
515
|
+
}),
|
|
516
|
+
getMutationDetails: c({
|
|
517
|
+
name: "get-mutation-details",
|
|
518
|
+
description: "Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",
|
|
519
|
+
inputSchema: {
|
|
520
|
+
type: "object",
|
|
521
|
+
properties: L,
|
|
522
|
+
required: ["mutationId"]
|
|
523
|
+
}
|
|
524
|
+
}),
|
|
525
|
+
clearMutationCache: c({
|
|
526
|
+
name: "clear-mutation-cache",
|
|
527
|
+
description: "Clear the full TanStack Query mutation cache.",
|
|
528
|
+
inputSchema: q
|
|
529
|
+
})
|
|
530
|
+
}, F = 20, P = 100, $ = (e) => !!e && typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype, o = (e, r = /* @__PURE__ */ new WeakSet()) => {
|
|
373
531
|
if (e == null)
|
|
374
532
|
return null;
|
|
375
533
|
if (typeof e == "string" || typeof e == "boolean")
|
|
@@ -403,7 +561,7 @@ const w = (e) => {
|
|
|
403
561
|
if (typeof e == "object") {
|
|
404
562
|
if (r.has(e))
|
|
405
563
|
return "[circular]";
|
|
406
|
-
if (r.add(e),
|
|
564
|
+
if (r.add(e), !$(e))
|
|
407
565
|
return `[non-serializable:${e.constructor?.name ?? "Object"}]`;
|
|
408
566
|
const t = Object.entries(e).map(([a, n]) => [
|
|
409
567
|
a,
|
|
@@ -412,160 +570,31 @@ const w = (e) => {
|
|
|
412
570
|
return Object.fromEntries(t);
|
|
413
571
|
}
|
|
414
572
|
return String(e);
|
|
415
|
-
},
|
|
416
|
-
const [a, n,
|
|
417
|
-
if (a !== r || !n || !
|
|
573
|
+
}, K = (e) => typeof e != "number" || !Number.isFinite(e) || !Number.isInteger(e) || e < 1 ? F : Math.min(e, P), x = (e, r, t) => `${e}:${r}:${t}`, z = (e, r, t) => {
|
|
574
|
+
const [a, n, h] = e.split(":", 3);
|
|
575
|
+
if (a !== r || !n || !h)
|
|
418
576
|
throw new Error(
|
|
419
577
|
"Cursor does not match the requested listing. Run the command again."
|
|
420
578
|
);
|
|
421
|
-
const
|
|
422
|
-
if (!Number.isInteger(
|
|
579
|
+
const p = Number(n), s = Number(h);
|
|
580
|
+
if (!Number.isInteger(p) || p !== t)
|
|
423
581
|
throw new Error(
|
|
424
582
|
"Cursor does not match the requested listing. Run the command again."
|
|
425
583
|
);
|
|
426
584
|
if (!Number.isInteger(s) || s < 0)
|
|
427
585
|
throw new Error("Cursor is invalid. Run the command again.");
|
|
428
586
|
return s;
|
|
429
|
-
},
|
|
430
|
-
const n =
|
|
587
|
+
}, M = (e, r, t, a) => {
|
|
588
|
+
const n = K(a.limit), h = a.cursor ? z(a.cursor, r, t) : 0, p = Math.min(h + n, e.length), s = p < e.length;
|
|
431
589
|
return {
|
|
432
|
-
items: e.slice(
|
|
590
|
+
items: e.slice(h, p),
|
|
433
591
|
page: {
|
|
434
592
|
limit: n,
|
|
435
593
|
hasMore: s,
|
|
436
|
-
...s ? { nextCursor:
|
|
594
|
+
...s ? { nextCursor: x(r, t, p) } : {}
|
|
437
595
|
}
|
|
438
596
|
};
|
|
439
|
-
},
|
|
440
|
-
queryHash: {
|
|
441
|
-
type: "string",
|
|
442
|
-
description: "TanStack Query queryHash identifying the query."
|
|
443
|
-
}
|
|
444
|
-
}, x = {
|
|
445
|
-
mutationId: {
|
|
446
|
-
type: "number",
|
|
447
|
-
description: "TanStack Query mutationId identifying the mutation."
|
|
448
|
-
}
|
|
449
|
-
}, I = {
|
|
450
|
-
limit: {
|
|
451
|
-
type: "number",
|
|
452
|
-
description: "Maximum number of items to return. Defaults to 20. Maximum 100."
|
|
453
|
-
},
|
|
454
|
-
cursor: {
|
|
455
|
-
type: "string",
|
|
456
|
-
description: "Opaque pagination cursor from a previous list call."
|
|
457
|
-
}
|
|
458
|
-
}, Q = {
|
|
459
|
-
type: "object",
|
|
460
|
-
properties: {}
|
|
461
|
-
}, z = {
|
|
462
|
-
name: "get-cache-summary",
|
|
463
|
-
description: "Return aggregate TanStack Query cache health and count information.",
|
|
464
|
-
inputSchema: Q
|
|
465
|
-
}, V = {
|
|
466
|
-
name: "get-online-status",
|
|
467
|
-
description: "Return the current TanStack Query onlineManager status.",
|
|
468
|
-
inputSchema: Q
|
|
469
|
-
}, B = {
|
|
470
|
-
name: "set-online-status",
|
|
471
|
-
description: "Set the TanStack Query onlineManager status for testing offline/online behavior.",
|
|
472
|
-
inputSchema: {
|
|
473
|
-
type: "object",
|
|
474
|
-
properties: {
|
|
475
|
-
online: {
|
|
476
|
-
type: "boolean",
|
|
477
|
-
description: "Whether the TanStack Query onlineManager should be online."
|
|
478
|
-
}
|
|
479
|
-
},
|
|
480
|
-
required: ["online"]
|
|
481
|
-
}
|
|
482
|
-
}, W = {
|
|
483
|
-
name: "list-queries",
|
|
484
|
-
description: "List TanStack Query query summaries using cursor pagination.",
|
|
485
|
-
inputSchema: {
|
|
486
|
-
type: "object",
|
|
487
|
-
properties: I
|
|
488
|
-
}
|
|
489
|
-
}, Y = {
|
|
490
|
-
name: "get-query-details",
|
|
491
|
-
description: "Return a JSON-safe TanStack Query query snapshot and observer summary.",
|
|
492
|
-
inputSchema: {
|
|
493
|
-
type: "object",
|
|
494
|
-
properties: f,
|
|
495
|
-
required: ["queryHash"]
|
|
496
|
-
}
|
|
497
|
-
}, J = {
|
|
498
|
-
name: "refetch-query",
|
|
499
|
-
description: "Refetch a TanStack Query query by queryHash.",
|
|
500
|
-
inputSchema: {
|
|
501
|
-
type: "object",
|
|
502
|
-
properties: f,
|
|
503
|
-
required: ["queryHash"]
|
|
504
|
-
}
|
|
505
|
-
}, X = {
|
|
506
|
-
name: "set-query-loading",
|
|
507
|
-
description: "Enable or disable TanStack Query loading-state simulation for a query by queryHash.",
|
|
508
|
-
inputSchema: {
|
|
509
|
-
type: "object",
|
|
510
|
-
properties: f,
|
|
511
|
-
required: ["queryHash", "enabled"]
|
|
512
|
-
}
|
|
513
|
-
}, Z = {
|
|
514
|
-
name: "set-query-error",
|
|
515
|
-
description: "Enable or disable TanStack Query error-state simulation for a query by queryHash.",
|
|
516
|
-
inputSchema: {
|
|
517
|
-
type: "object",
|
|
518
|
-
properties: f,
|
|
519
|
-
required: ["queryHash", "enabled"]
|
|
520
|
-
}
|
|
521
|
-
}, ee = {
|
|
522
|
-
name: "invalidate-query",
|
|
523
|
-
description: "Invalidate a TanStack Query query by queryHash.",
|
|
524
|
-
inputSchema: {
|
|
525
|
-
type: "object",
|
|
526
|
-
properties: f,
|
|
527
|
-
required: ["queryHash"]
|
|
528
|
-
}
|
|
529
|
-
}, te = {
|
|
530
|
-
name: "reset-query",
|
|
531
|
-
description: "Reset a TanStack Query query by queryHash.",
|
|
532
|
-
inputSchema: {
|
|
533
|
-
type: "object",
|
|
534
|
-
properties: f,
|
|
535
|
-
required: ["queryHash"]
|
|
536
|
-
}
|
|
537
|
-
}, re = {
|
|
538
|
-
name: "remove-query",
|
|
539
|
-
description: "Remove a TanStack Query query from the cache by queryHash.",
|
|
540
|
-
inputSchema: {
|
|
541
|
-
type: "object",
|
|
542
|
-
properties: f,
|
|
543
|
-
required: ["queryHash"]
|
|
544
|
-
}
|
|
545
|
-
}, ae = {
|
|
546
|
-
name: "clear-query-cache",
|
|
547
|
-
description: "Clear the full TanStack Query query cache.",
|
|
548
|
-
inputSchema: Q
|
|
549
|
-
}, se = {
|
|
550
|
-
name: "list-mutations",
|
|
551
|
-
description: "List TanStack Query mutation summaries using cursor pagination.",
|
|
552
|
-
inputSchema: {
|
|
553
|
-
type: "object",
|
|
554
|
-
properties: I
|
|
555
|
-
}
|
|
556
|
-
}, ne = {
|
|
557
|
-
name: "get-mutation-details",
|
|
558
|
-
description: "Return a JSON-safe TanStack Query mutation snapshot for a mutationId.",
|
|
559
|
-
inputSchema: {
|
|
560
|
-
type: "object",
|
|
561
|
-
properties: x,
|
|
562
|
-
required: ["mutationId"]
|
|
563
|
-
}
|
|
564
|
-
}, oe = {
|
|
565
|
-
name: "clear-mutation-cache",
|
|
566
|
-
description: "Clear the full TanStack Query mutation cache.",
|
|
567
|
-
inputSchema: Q
|
|
568
|
-
}, ue = (e) => e ? {
|
|
597
|
+
}, W = (e) => e ? {
|
|
569
598
|
enabled: o(e.enabled),
|
|
570
599
|
networkMode: o(e.networkMode),
|
|
571
600
|
staleTime: o(e.staleTime),
|
|
@@ -582,7 +611,7 @@ const w = (e) => {
|
|
|
582
611
|
hasSelect: typeof e.select == "function",
|
|
583
612
|
hasPlaceholderData: "placeholderData" in e,
|
|
584
613
|
hasInitialData: "initialData" in e
|
|
585
|
-
} : null,
|
|
614
|
+
} : null, V = (e) => ({
|
|
586
615
|
mutationKey: o(e.mutationKey),
|
|
587
616
|
networkMode: o(e.networkMode),
|
|
588
617
|
gcTime: o(e.gcTime),
|
|
@@ -595,7 +624,7 @@ const w = (e) => {
|
|
|
595
624
|
hasOnSuccess: typeof e.onSuccess == "function",
|
|
596
625
|
hasOnError: typeof e.onError == "function",
|
|
597
626
|
hasOnSettled: typeof e.onSettled == "function"
|
|
598
|
-
}),
|
|
627
|
+
}), E = (e) => Math.max(e.state.dataUpdatedAt, e.state.errorUpdatedAt), B = (e, r) => E(r) - E(e) || r.getObserversCount() - e.getObserversCount() || String(r.queryHash).localeCompare(String(e.queryHash)), Y = (e, r) => r.state.submittedAt - e.state.submittedAt || r.mutationId - e.mutationId, O = (e) => ({
|
|
599
628
|
queryHash: e.queryHash,
|
|
600
629
|
queryKey: o(e.queryKey),
|
|
601
630
|
status: e.state.status,
|
|
@@ -606,16 +635,16 @@ const w = (e) => {
|
|
|
606
635
|
errorUpdatedAt: e.state.errorUpdatedAt,
|
|
607
636
|
hasData: e.state.data !== void 0,
|
|
608
637
|
hasError: e.state.error != null
|
|
609
|
-
}),
|
|
638
|
+
}), J = (e) => e.status, T = (e) => ({
|
|
610
639
|
mutationId: e.mutationId,
|
|
611
640
|
mutationKey: o(e.options.mutationKey),
|
|
612
|
-
status:
|
|
641
|
+
status: J(e.state),
|
|
613
642
|
isPaused: e.state.isPaused,
|
|
614
643
|
submittedAt: e.state.submittedAt,
|
|
615
644
|
failureCount: e.state.failureCount,
|
|
616
645
|
hasData: e.state.data !== void 0,
|
|
617
646
|
hasError: e.state.error != null
|
|
618
|
-
}),
|
|
647
|
+
}), X = (e, r) => {
|
|
619
648
|
const t = e.getQueryCache().get(r);
|
|
620
649
|
if (!t) {
|
|
621
650
|
const a = e.getQueryCache().getAll().map((n) => n.queryHash).join(", ");
|
|
@@ -624,7 +653,7 @@ const w = (e) => {
|
|
|
624
653
|
);
|
|
625
654
|
}
|
|
626
655
|
return t;
|
|
627
|
-
},
|
|
656
|
+
}, Z = (e, r) => {
|
|
628
657
|
const t = e.getMutationCache().getAll().find((a) => a.mutationId === r);
|
|
629
658
|
if (!t) {
|
|
630
659
|
const a = e.getMutationCache().getAll().map((n) => n.mutationId).join(", ");
|
|
@@ -633,10 +662,10 @@ const w = (e) => {
|
|
|
633
662
|
);
|
|
634
663
|
}
|
|
635
664
|
return t;
|
|
636
|
-
},
|
|
665
|
+
}, Q = (e) => {
|
|
637
666
|
const r = e.getQueryCache().getAll(), t = e.getMutationCache().getAll();
|
|
638
667
|
return {
|
|
639
|
-
online:
|
|
668
|
+
online: S.isOnline(),
|
|
640
669
|
queries: {
|
|
641
670
|
total: r.length,
|
|
642
671
|
active: r.filter((a) => a.getObserversCount() > 0).length,
|
|
@@ -660,7 +689,7 @@ const w = (e) => {
|
|
|
660
689
|
paused: t.filter((a) => a.state.isPaused).length
|
|
661
690
|
}
|
|
662
691
|
};
|
|
663
|
-
},
|
|
692
|
+
}, ee = (e) => {
|
|
664
693
|
const r = {
|
|
665
694
|
queriesGeneration: 0,
|
|
666
695
|
mutationsGeneration: 0
|
|
@@ -673,25 +702,25 @@ const w = (e) => {
|
|
|
673
702
|
(t.type === "added" || t.type === "removed") && (r.mutationsGeneration += 1);
|
|
674
703
|
},
|
|
675
704
|
getCacheSummary() {
|
|
676
|
-
return
|
|
705
|
+
return Q(e);
|
|
677
706
|
},
|
|
678
707
|
getOnlineStatus() {
|
|
679
708
|
return {
|
|
680
|
-
online:
|
|
709
|
+
online: S.isOnline()
|
|
681
710
|
};
|
|
682
711
|
},
|
|
683
712
|
setOnlineStatus({ online: t }) {
|
|
684
|
-
return
|
|
685
|
-
online:
|
|
713
|
+
return S.setOnline(t), {
|
|
714
|
+
online: S.isOnline()
|
|
686
715
|
};
|
|
687
716
|
},
|
|
688
717
|
listQueries(t = {}) {
|
|
689
|
-
const a = [...e.getQueryCache().getAll()].sort(
|
|
718
|
+
const a = [...e.getQueryCache().getAll()].sort(B);
|
|
690
719
|
return {
|
|
691
|
-
...
|
|
720
|
+
...Q(e),
|
|
692
721
|
total: a.length,
|
|
693
|
-
...
|
|
694
|
-
a.map(
|
|
722
|
+
...M(
|
|
723
|
+
a.map(O),
|
|
695
724
|
"queries",
|
|
696
725
|
r.queriesGeneration,
|
|
697
726
|
t
|
|
@@ -699,16 +728,16 @@ const w = (e) => {
|
|
|
699
728
|
};
|
|
700
729
|
},
|
|
701
730
|
getQueryDetails({ queryHash: t }) {
|
|
702
|
-
const a =
|
|
731
|
+
const a = X(e, t);
|
|
703
732
|
return {
|
|
704
|
-
summary:
|
|
733
|
+
summary: Q(e),
|
|
705
734
|
query: {
|
|
706
|
-
...
|
|
735
|
+
...O(a),
|
|
707
736
|
data: o(a.state.data),
|
|
708
737
|
error: o(a.state.error),
|
|
709
738
|
observers: a.observers.map((n) => ({
|
|
710
739
|
queryHash: a.queryHash,
|
|
711
|
-
options:
|
|
740
|
+
options: W(
|
|
712
741
|
n.options
|
|
713
742
|
)
|
|
714
743
|
}))
|
|
@@ -716,55 +745,55 @@ const w = (e) => {
|
|
|
716
745
|
};
|
|
717
746
|
},
|
|
718
747
|
async refetchQuery({ queryHash: t }) {
|
|
719
|
-
return
|
|
748
|
+
return f(e, {
|
|
720
749
|
type: "REFETCH",
|
|
721
750
|
queryHash: t
|
|
722
751
|
});
|
|
723
752
|
},
|
|
724
753
|
async setQueryLoading({ queryHash: t, enabled: a }) {
|
|
725
|
-
return
|
|
754
|
+
return f(e, {
|
|
726
755
|
type: a ? "TRIGGER_LOADING" : "RESTORE_LOADING",
|
|
727
756
|
queryHash: t
|
|
728
757
|
});
|
|
729
758
|
},
|
|
730
759
|
async setQueryError({ queryHash: t, enabled: a }) {
|
|
731
|
-
return
|
|
760
|
+
return f(e, {
|
|
732
761
|
type: a ? "TRIGGER_ERROR" : "RESTORE_ERROR",
|
|
733
762
|
queryHash: t
|
|
734
763
|
});
|
|
735
764
|
},
|
|
736
765
|
async invalidateQuery({ queryHash: t }) {
|
|
737
|
-
return
|
|
766
|
+
return f(e, {
|
|
738
767
|
type: "INVALIDATE",
|
|
739
768
|
queryHash: t
|
|
740
769
|
});
|
|
741
770
|
},
|
|
742
771
|
async resetQuery({ queryHash: t }) {
|
|
743
|
-
return
|
|
772
|
+
return f(e, {
|
|
744
773
|
type: "RESET",
|
|
745
774
|
queryHash: t
|
|
746
775
|
});
|
|
747
776
|
},
|
|
748
777
|
async removeQuery({ queryHash: t }) {
|
|
749
|
-
return
|
|
778
|
+
return f(e, {
|
|
750
779
|
type: "REMOVE",
|
|
751
780
|
queryHash: t
|
|
752
781
|
});
|
|
753
782
|
},
|
|
754
783
|
async clearQueryCache() {
|
|
755
|
-
return
|
|
784
|
+
return f(e, {
|
|
756
785
|
type: "CLEAR_QUERY_CACHE"
|
|
757
786
|
});
|
|
758
787
|
},
|
|
759
788
|
listMutations(t = {}) {
|
|
760
789
|
const a = [...e.getMutationCache().getAll()].sort(
|
|
761
|
-
|
|
790
|
+
Y
|
|
762
791
|
);
|
|
763
792
|
return {
|
|
764
|
-
...
|
|
793
|
+
...Q(e),
|
|
765
794
|
total: a.length,
|
|
766
|
-
...
|
|
767
|
-
a.map(
|
|
795
|
+
...M(
|
|
796
|
+
a.map(T),
|
|
768
797
|
"mutations",
|
|
769
798
|
r.mutationsGeneration,
|
|
770
799
|
t
|
|
@@ -772,103 +801,103 @@ const w = (e) => {
|
|
|
772
801
|
};
|
|
773
802
|
},
|
|
774
803
|
getMutationDetails({ mutationId: t }) {
|
|
775
|
-
const a =
|
|
804
|
+
const a = Z(e, t);
|
|
776
805
|
return {
|
|
777
|
-
summary:
|
|
806
|
+
summary: Q(e),
|
|
778
807
|
mutation: {
|
|
779
|
-
...
|
|
808
|
+
...T(a),
|
|
780
809
|
variables: o(a.state.variables),
|
|
781
810
|
data: o(a.state.data),
|
|
782
811
|
error: o(a.state.error),
|
|
783
812
|
context: o(a.state.context),
|
|
784
813
|
failureReason: o(a.state.failureReason),
|
|
785
|
-
options:
|
|
814
|
+
options: V(a.options)
|
|
786
815
|
}
|
|
787
816
|
};
|
|
788
817
|
},
|
|
789
818
|
async clearMutationCache() {
|
|
790
|
-
return
|
|
819
|
+
return f(e, {
|
|
791
820
|
type: "CLEAR_MUTATION_CACHE"
|
|
792
821
|
});
|
|
793
822
|
}
|
|
794
823
|
};
|
|
795
|
-
},
|
|
796
|
-
const r =
|
|
797
|
-
() =>
|
|
824
|
+
}, te = (e) => {
|
|
825
|
+
const r = I(
|
|
826
|
+
() => ee(e),
|
|
798
827
|
[e]
|
|
799
828
|
);
|
|
800
|
-
|
|
829
|
+
A(() => {
|
|
801
830
|
const t = e.getQueryCache().subscribe((n) => r.handleQueryCacheEvent(n)), a = e.getMutationCache().subscribe((n) => r.handleMutationCacheEvent(n));
|
|
802
831
|
return () => {
|
|
803
832
|
t(), a();
|
|
804
833
|
};
|
|
805
|
-
}, [r, e]),
|
|
806
|
-
pluginId:
|
|
807
|
-
tool:
|
|
834
|
+
}, [r, e]), i({
|
|
835
|
+
pluginId: d,
|
|
836
|
+
tool: y.getCacheSummary,
|
|
808
837
|
handler: () => r.getCacheSummary()
|
|
809
|
-
}),
|
|
810
|
-
pluginId:
|
|
811
|
-
tool:
|
|
838
|
+
}), i({
|
|
839
|
+
pluginId: d,
|
|
840
|
+
tool: y.getOnlineStatus,
|
|
812
841
|
handler: () => r.getOnlineStatus()
|
|
813
|
-
}),
|
|
814
|
-
pluginId:
|
|
815
|
-
tool:
|
|
842
|
+
}), i({
|
|
843
|
+
pluginId: d,
|
|
844
|
+
tool: y.setOnlineStatus,
|
|
816
845
|
handler: (t) => r.setOnlineStatus(t)
|
|
817
|
-
}),
|
|
818
|
-
pluginId:
|
|
819
|
-
tool:
|
|
846
|
+
}), i({
|
|
847
|
+
pluginId: d,
|
|
848
|
+
tool: y.listQueries,
|
|
820
849
|
handler: (t = {}) => r.listQueries(t)
|
|
821
|
-
}),
|
|
822
|
-
pluginId:
|
|
823
|
-
tool:
|
|
850
|
+
}), i({
|
|
851
|
+
pluginId: d,
|
|
852
|
+
tool: y.getQueryDetails,
|
|
824
853
|
handler: (t) => r.getQueryDetails(t)
|
|
825
|
-
}),
|
|
826
|
-
pluginId:
|
|
827
|
-
tool:
|
|
854
|
+
}), i({
|
|
855
|
+
pluginId: d,
|
|
856
|
+
tool: y.refetchQuery,
|
|
828
857
|
handler: (t) => r.refetchQuery(t)
|
|
829
|
-
}),
|
|
830
|
-
pluginId:
|
|
831
|
-
tool:
|
|
858
|
+
}), i({
|
|
859
|
+
pluginId: d,
|
|
860
|
+
tool: y.setQueryLoading,
|
|
832
861
|
handler: (t) => r.setQueryLoading(t)
|
|
833
|
-
}),
|
|
834
|
-
pluginId:
|
|
835
|
-
tool:
|
|
862
|
+
}), i({
|
|
863
|
+
pluginId: d,
|
|
864
|
+
tool: y.setQueryError,
|
|
836
865
|
handler: (t) => r.setQueryError(t)
|
|
837
|
-
}),
|
|
838
|
-
pluginId:
|
|
839
|
-
tool:
|
|
866
|
+
}), i({
|
|
867
|
+
pluginId: d,
|
|
868
|
+
tool: y.invalidateQuery,
|
|
840
869
|
handler: (t) => r.invalidateQuery(t)
|
|
841
|
-
}),
|
|
842
|
-
pluginId:
|
|
843
|
-
tool:
|
|
870
|
+
}), i({
|
|
871
|
+
pluginId: d,
|
|
872
|
+
tool: y.resetQuery,
|
|
844
873
|
handler: (t) => r.resetQuery(t)
|
|
845
|
-
}),
|
|
846
|
-
pluginId:
|
|
847
|
-
tool:
|
|
874
|
+
}), i({
|
|
875
|
+
pluginId: d,
|
|
876
|
+
tool: y.removeQuery,
|
|
848
877
|
handler: (t) => r.removeQuery(t)
|
|
849
|
-
}),
|
|
850
|
-
pluginId:
|
|
851
|
-
tool:
|
|
878
|
+
}), i({
|
|
879
|
+
pluginId: d,
|
|
880
|
+
tool: y.clearQueryCache,
|
|
852
881
|
handler: () => r.clearQueryCache()
|
|
853
|
-
}),
|
|
854
|
-
pluginId:
|
|
855
|
-
tool:
|
|
882
|
+
}), i({
|
|
883
|
+
pluginId: d,
|
|
884
|
+
tool: y.listMutations,
|
|
856
885
|
handler: (t = {}) => r.listMutations(t)
|
|
857
|
-
}),
|
|
858
|
-
pluginId:
|
|
859
|
-
tool:
|
|
886
|
+
}), i({
|
|
887
|
+
pluginId: d,
|
|
888
|
+
tool: y.getMutationDetails,
|
|
860
889
|
handler: (t) => r.getMutationDetails(t)
|
|
861
|
-
}),
|
|
862
|
-
pluginId:
|
|
863
|
-
tool:
|
|
890
|
+
}), i({
|
|
891
|
+
pluginId: d,
|
|
892
|
+
tool: y.clearMutationCache,
|
|
864
893
|
handler: () => r.clearMutationCache()
|
|
865
894
|
});
|
|
866
|
-
},
|
|
867
|
-
const r =
|
|
895
|
+
}, ie = (e) => {
|
|
896
|
+
const r = D({
|
|
868
897
|
pluginId: "@rozenite/tanstack-query-plugin"
|
|
869
898
|
});
|
|
870
|
-
|
|
899
|
+
_(r), U(e, r), j(e, r), N(e, r), te(e);
|
|
871
900
|
};
|
|
872
901
|
export {
|
|
873
|
-
|
|
902
|
+
ie as useTanStackQueryDevTools
|
|
874
903
|
};
|