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