@alepha/devtools 0.16.1 → 0.19.1
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/README.md +1 -5
- package/dist/index.browser.js +224 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.d.ts +349 -321
- package/dist/index.js +293 -186
- package/dist/index.js.map +1 -1
- package/package.json +30 -23
- package/src/assets.ts +6 -0
- package/src/{api/entities → entities}/logs.ts +2 -2
- package/src/index.browser.ts +11 -0
- package/src/index.shared.ts +15 -0
- package/src/index.ts +11 -37
- package/src/{api/providers → providers}/DevToolsMetadataProvider.ts +84 -47
- package/src/providers/DevToolsProvider.ts +280 -0
- package/src/{api/schemas → schemas}/DevActionMetadata.ts +8 -0
- package/src/{api/schemas → schemas}/DevEntityMetadata.ts +3 -0
- package/src/{api/schemas → schemas}/DevMetadata.ts +13 -2
- package/src/{api/schemas → schemas}/DevPageMetadata.ts +3 -0
- package/src/{api/schemas → schemas}/DevTopicMetadata.ts +1 -0
- package/src/ui/AppRouter.tsx +55 -59
- package/src/ui/components/DevLayout.tsx +104 -84
- package/src/ui/components/configuration/ConfigAtoms.page.tsx +5 -0
- package/src/ui/components/configuration/ConfigAtoms.tsx +511 -0
- package/src/ui/components/configuration/ConfigEnv.page.tsx +5 -0
- package/src/ui/components/configuration/ConfigEnv.tsx +230 -0
- package/src/ui/components/configuration/DevConfiguration.tsx +36 -0
- package/src/ui/components/configuration/index.ts +3 -0
- package/src/ui/components/dashboard/DevDashboard.tsx +482 -0
- package/src/ui/components/database/DatabaseEditor.page.tsx +23 -0
- package/src/ui/components/database/DatabaseEditor.tsx +399 -0
- package/src/ui/components/database/DatabaseErd.page.tsx +28 -0
- package/src/ui/components/database/DatabaseErd.tsx +107 -0
- package/src/ui/components/database/DevDatabase.tsx +36 -0
- package/src/ui/components/database/EntityNode.tsx +83 -0
- package/src/ui/components/explorer/DevExplorer.tsx +351 -0
- package/src/ui/components/explorer/ExplorerTree.tsx +178 -0
- package/src/ui/components/explorer/panels/DevPanelAction.tsx +499 -0
- package/src/ui/components/explorer/panels/DevPanelCache.tsx +73 -0
- package/src/ui/components/explorer/panels/DevPanelPage.tsx +96 -0
- package/src/ui/components/explorer/panels/DevPanelQueue.tsx +51 -0
- package/src/ui/components/explorer/panels/DevPanelTopic.tsx +56 -0
- package/src/ui/components/explorer/panels/index.ts +5 -0
- package/src/ui/components/graph/DevDependencyGraph.tsx +35 -60
- package/src/ui/components/graph/GraphControls.tsx +10 -11
- package/src/ui/components/graph/NodeDetails.tsx +22 -29
- package/src/ui/components/graph/ProviderNode.tsx +4 -4
- package/src/ui/components/graph/helpers.ts +1 -1
- package/src/ui/components/logs/DevLogs.tsx +661 -0
- package/src/ui/components/logs/index.ts +1 -0
- package/src/ui/components/shared/TreeView.tsx +189 -0
- package/src/ui/main.css +17 -0
- package/src/ui/main.ts +2 -6
- package/LICENSE +0 -21
- package/assets/devtools/actions.html +0 -21
- package/assets/devtools/actions.html.br +0 -0
- package/assets/devtools/actions.html.gz +0 -0
- package/assets/devtools/asset.BZV40eAE.css +0 -1
- package/assets/devtools/asset.BZV40eAE.css.br +0 -0
- package/assets/devtools/asset.BZV40eAE.css.gz +0 -0
- package/assets/devtools/asset.CBnMq2vO.css +0 -1
- package/assets/devtools/asset.CBnMq2vO.css.br +0 -0
- package/assets/devtools/asset.CBnMq2vO.css.gz +0 -0
- package/assets/devtools/atoms.html +0 -21
- package/assets/devtools/atoms.html.br +0 -0
- package/assets/devtools/atoms.html.gz +0 -0
- package/assets/devtools/caches.html +0 -21
- package/assets/devtools/caches.html.br +0 -0
- package/assets/devtools/caches.html.gz +0 -0
- package/assets/devtools/chunk.6INqNjF0.js +0 -1
- package/assets/devtools/chunk.6INqNjF0.js.br +0 -0
- package/assets/devtools/chunk.6INqNjF0.js.gz +0 -0
- package/assets/devtools/chunk.9vpWpXSF.js +0 -1
- package/assets/devtools/chunk.9vpWpXSF.js.br +0 -0
- package/assets/devtools/chunk.9vpWpXSF.js.gz +0 -0
- package/assets/devtools/chunk.B4peH6PS.js +0 -1
- package/assets/devtools/chunk.B4peH6PS.js.br +0 -0
- package/assets/devtools/chunk.B4peH6PS.js.gz +0 -0
- package/assets/devtools/chunk.B8CNjZzU.js +0 -1
- package/assets/devtools/chunk.B8CNjZzU.js.br +0 -0
- package/assets/devtools/chunk.B8CNjZzU.js.gz +0 -0
- package/assets/devtools/chunk.Bgd10SVI.js +0 -1
- package/assets/devtools/chunk.Bgd10SVI.js.br +0 -0
- package/assets/devtools/chunk.Bgd10SVI.js.gz +0 -0
- package/assets/devtools/chunk.BjFrJKj1.js +0 -1
- package/assets/devtools/chunk.BjFrJKj1.js.br +0 -2
- package/assets/devtools/chunk.BjFrJKj1.js.gz +0 -0
- package/assets/devtools/chunk.BlqFPyLh.js +0 -1
- package/assets/devtools/chunk.BlqFPyLh.js.br +0 -0
- package/assets/devtools/chunk.BlqFPyLh.js.gz +0 -0
- package/assets/devtools/chunk.BqBNmfN9.js +0 -1
- package/assets/devtools/chunk.BqBNmfN9.js.br +0 -0
- package/assets/devtools/chunk.BqBNmfN9.js.gz +0 -0
- package/assets/devtools/chunk.Bt0_vkJm.js +0 -2
- package/assets/devtools/chunk.Bt0_vkJm.js.br +0 -0
- package/assets/devtools/chunk.Bt0_vkJm.js.gz +0 -0
- package/assets/devtools/chunk.C3GuU4pz.js +0 -2
- package/assets/devtools/chunk.C3GuU4pz.js.br +0 -0
- package/assets/devtools/chunk.C3GuU4pz.js.gz +0 -0
- package/assets/devtools/chunk.CGwoN_Mo.js +0 -1
- package/assets/devtools/chunk.CGwoN_Mo.js.br +0 -0
- package/assets/devtools/chunk.CGwoN_Mo.js.gz +0 -0
- package/assets/devtools/chunk.CJCvhHA7.js +0 -1
- package/assets/devtools/chunk.CJCvhHA7.js.br +0 -2
- package/assets/devtools/chunk.CJCvhHA7.js.gz +0 -0
- package/assets/devtools/chunk.CKr2VE6v.js +0 -1
- package/assets/devtools/chunk.CKr2VE6v.js.br +0 -0
- package/assets/devtools/chunk.CKr2VE6v.js.gz +0 -0
- package/assets/devtools/chunk.CLvTwbkw.js +0 -1
- package/assets/devtools/chunk.CLvTwbkw.js.br +0 -0
- package/assets/devtools/chunk.CLvTwbkw.js.gz +0 -0
- package/assets/devtools/chunk.CR13dZhE.js +0 -7
- package/assets/devtools/chunk.CR13dZhE.js.br +0 -0
- package/assets/devtools/chunk.CR13dZhE.js.gz +0 -0
- package/assets/devtools/chunk.C_C-cVqs.js +0 -1
- package/assets/devtools/chunk.C_C-cVqs.js.br +0 -1
- package/assets/devtools/chunk.C_C-cVqs.js.gz +0 -0
- package/assets/devtools/chunk.CjevPbPy.js +0 -1
- package/assets/devtools/chunk.CjevPbPy.js.br +0 -0
- package/assets/devtools/chunk.CjevPbPy.js.gz +0 -0
- package/assets/devtools/chunk.CkNMZqAe.js +0 -1
- package/assets/devtools/chunk.CkNMZqAe.js.br +0 -0
- package/assets/devtools/chunk.CkNMZqAe.js.gz +0 -0
- package/assets/devtools/chunk.Cl1Mlnqx.js +0 -1
- package/assets/devtools/chunk.Cl1Mlnqx.js.br +0 -0
- package/assets/devtools/chunk.Cl1Mlnqx.js.gz +0 -0
- package/assets/devtools/chunk.CyY8OGdZ.js +0 -1
- package/assets/devtools/chunk.CyY8OGdZ.js.br +0 -0
- package/assets/devtools/chunk.CyY8OGdZ.js.gz +0 -0
- package/assets/devtools/chunk.Cyx9kLqD.js +0 -1
- package/assets/devtools/chunk.Cyx9kLqD.js.br +0 -0
- package/assets/devtools/chunk.Cyx9kLqD.js.gz +0 -0
- package/assets/devtools/chunk.D1MGgxUI.js +0 -1
- package/assets/devtools/chunk.D1MGgxUI.js.br +0 -0
- package/assets/devtools/chunk.D1MGgxUI.js.gz +0 -0
- package/assets/devtools/chunk.D5Ci-dwk.js +0 -1
- package/assets/devtools/chunk.D5Ci-dwk.js.br +0 -0
- package/assets/devtools/chunk.D5Ci-dwk.js.gz +0 -0
- package/assets/devtools/chunk.DFrWQW5x.js +0 -9
- package/assets/devtools/chunk.DFrWQW5x.js.br +0 -0
- package/assets/devtools/chunk.DFrWQW5x.js.gz +0 -0
- package/assets/devtools/chunk.DaVlli3f.js +0 -1
- package/assets/devtools/chunk.DaVlli3f.js.br +0 -0
- package/assets/devtools/chunk.DaVlli3f.js.gz +0 -0
- package/assets/devtools/chunk.DdyBCs50.js +0 -1
- package/assets/devtools/chunk.DdyBCs50.js.br +0 -0
- package/assets/devtools/chunk.DdyBCs50.js.gz +0 -0
- package/assets/devtools/chunk.Dl0THvrP.js +0 -1
- package/assets/devtools/chunk.Dl0THvrP.js.br +0 -0
- package/assets/devtools/chunk.Dl0THvrP.js.gz +0 -0
- package/assets/devtools/chunk.DwUNDm68.js +0 -1
- package/assets/devtools/chunk.DwUNDm68.js.br +0 -0
- package/assets/devtools/chunk.DwUNDm68.js.gz +0 -0
- package/assets/devtools/chunk.DzDkh4C6.js +0 -1
- package/assets/devtools/chunk.DzDkh4C6.js.br +0 -0
- package/assets/devtools/chunk.DzDkh4C6.js.gz +0 -0
- package/assets/devtools/chunk.QTExp4CY.js +0 -1
- package/assets/devtools/chunk.QTExp4CY.js.br +0 -0
- package/assets/devtools/chunk.QTExp4CY.js.gz +0 -0
- package/assets/devtools/chunk.ReCPcJln.js +0 -1
- package/assets/devtools/chunk.ReCPcJln.js.br +0 -0
- package/assets/devtools/chunk.ReCPcJln.js.gz +0 -0
- package/assets/devtools/chunk.UEhIKOMY.js +0 -1
- package/assets/devtools/chunk.UEhIKOMY.js.br +0 -0
- package/assets/devtools/chunk.UEhIKOMY.js.gz +0 -0
- package/assets/devtools/chunk.mWQqK3dU.js +0 -1
- package/assets/devtools/chunk.mWQqK3dU.js.br +0 -0
- package/assets/devtools/chunk.mWQqK3dU.js.gz +0 -0
- package/assets/devtools/chunk.uyVen0u2.js +0 -1
- package/assets/devtools/chunk.uyVen0u2.js.br +0 -0
- package/assets/devtools/chunk.uyVen0u2.js.gz +0 -0
- package/assets/devtools/chunk.yLRX_cUF.js +0 -1
- package/assets/devtools/chunk.yLRX_cUF.js.br +0 -0
- package/assets/devtools/chunk.yLRX_cUF.js.gz +0 -0
- package/assets/devtools/chunk.zuZxBYZg.js +0 -1
- package/assets/devtools/chunk.zuZxBYZg.js.br +0 -0
- package/assets/devtools/chunk.zuZxBYZg.js.gz +0 -0
- package/assets/devtools/db.html +0 -21
- package/assets/devtools/db.html.br +0 -0
- package/assets/devtools/db.html.gz +0 -0
- package/assets/devtools/entry.Cry3rxEI.js +0 -79
- package/assets/devtools/entry.Cry3rxEI.js.br +0 -0
- package/assets/devtools/entry.Cry3rxEI.js.gz +0 -0
- package/assets/devtools/env.html +0 -21
- package/assets/devtools/env.html.br +0 -0
- package/assets/devtools/env.html.gz +0 -0
- package/assets/devtools/graph.html +0 -22
- package/assets/devtools/graph.html.br +0 -0
- package/assets/devtools/graph.html.gz +0 -0
- package/assets/devtools/index.html +0 -21
- package/assets/devtools/index.html.br +0 -0
- package/assets/devtools/index.html.gz +0 -0
- package/assets/devtools/logs.html +0 -21
- package/assets/devtools/logs.html.br +0 -0
- package/assets/devtools/logs.html.gz +0 -0
- package/assets/devtools/queues.html +0 -21
- package/assets/devtools/queues.html.br +0 -0
- package/assets/devtools/queues.html.gz +0 -0
- package/assets/devtools/topics.html +0 -21
- package/assets/devtools/topics.html.br +0 -0
- package/assets/devtools/topics.html.gz +0 -0
- package/src/api/DevToolsProvider.ts +0 -157
- package/src/api/providers/DevToolsDatabaseProvider.ts +0 -27
- package/src/api/repositories/LogRepository.ts +0 -8
- package/src/api/schemas/DevCommandMetadata.ts +0 -9
- package/src/ui/components/DevAtomsViewer.tsx +0 -637
- package/src/ui/components/DevCacheInspector.tsx +0 -423
- package/src/ui/components/DevDashboard.tsx +0 -38
- package/src/ui/components/DevEnvExplorer.tsx +0 -462
- package/src/ui/components/DevLogViewer.tsx +0 -252
- package/src/ui/components/DevQueueMonitor.tsx +0 -51
- package/src/ui/components/DevTopicsViewer.tsx +0 -686
- package/src/ui/components/actions/ActionGroup.tsx +0 -37
- package/src/ui/components/actions/ActionItem.tsx +0 -138
- package/src/ui/components/actions/DevActionsExplorer.tsx +0 -132
- package/src/ui/components/actions/MethodBadge.tsx +0 -18
- package/src/ui/components/actions/SchemaViewer.tsx +0 -21
- package/src/ui/components/actions/TryItPanel.tsx +0 -140
- package/src/ui/components/actions/constants.ts +0 -7
- package/src/ui/components/actions/helpers.ts +0 -18
- package/src/ui/components/actions/index.ts +0 -8
- package/src/ui/components/db/ColumnBadge.tsx +0 -55
- package/src/ui/components/db/DevDbStudio.tsx +0 -485
- package/src/ui/components/db/constants.ts +0 -11
- package/src/ui/components/db/index.ts +0 -4
- package/src/ui/components/db/types.ts +0 -7
- package/src/ui/styles.css +0 -1
- /package/src/{api/schemas → schemas}/DevAtomMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevBucketMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevCacheMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevEnvMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevModuleMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevProviderMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevQueueMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevRealmMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevRouteMetadata.ts +0 -0
- /package/src/{api/schemas → schemas}/DevSchedulerMetadata.ts +0 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { devMetadataSchema } from "@alepha/devtools";
|
|
2
|
+
import { Flex, ui } from "@alepha/ui";
|
|
3
|
+
import { ScrollArea, Text, TextInput } from "@mantine/core";
|
|
4
|
+
import { IconSearch } from "@tabler/icons-react";
|
|
5
|
+
import { t } from "alepha";
|
|
6
|
+
import { useInject } from "alepha/react";
|
|
7
|
+
import { useQueryParams } from "alepha/react/router";
|
|
8
|
+
import { HttpClient } from "alepha/server";
|
|
9
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
10
|
+
import { ExplorerTree, type TreeNode } from "./ExplorerTree.tsx";
|
|
11
|
+
import { DevPanelAction } from "./panels/DevPanelAction.tsx";
|
|
12
|
+
import { DevPanelCache } from "./panels/DevPanelCache.tsx";
|
|
13
|
+
import { DevPanelPage } from "./panels/DevPanelPage.tsx";
|
|
14
|
+
import { DevPanelQueue } from "./panels/DevPanelQueue.tsx";
|
|
15
|
+
import { DevPanelTopic } from "./panels/DevPanelTopic.tsx";
|
|
16
|
+
|
|
17
|
+
const querySchema = t.object({
|
|
18
|
+
selected: t.optional(t.text()),
|
|
19
|
+
open: t.optional(t.text()),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const buildTree = (metadata: any): TreeNode[] => {
|
|
23
|
+
const nodes: TreeNode[] = [];
|
|
24
|
+
|
|
25
|
+
// Actions grouped by group name, split on ":" for nested folders
|
|
26
|
+
if (metadata.actions?.length > 0) {
|
|
27
|
+
const actionsRoot: TreeNode = {
|
|
28
|
+
id: "actions",
|
|
29
|
+
label: "actions",
|
|
30
|
+
type: "folder",
|
|
31
|
+
children: [],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Group actions by their group name
|
|
35
|
+
const groups = new Map<string, any[]>();
|
|
36
|
+
for (const action of metadata.actions) {
|
|
37
|
+
const group = action.group || "default";
|
|
38
|
+
if (!groups.has(group)) groups.set(group, []);
|
|
39
|
+
groups.get(group)!.push(action);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Insert each group into the tree, splitting on ":"
|
|
43
|
+
for (const [group, actions] of Array.from(groups.entries()).sort(
|
|
44
|
+
([a], [b]) => a.localeCompare(b),
|
|
45
|
+
)) {
|
|
46
|
+
const parts = group.split(":");
|
|
47
|
+
let current = actionsRoot;
|
|
48
|
+
|
|
49
|
+
for (let i = 0; i < parts.length; i++) {
|
|
50
|
+
const folderId = `actions:${parts.slice(0, i + 1).join(":")}`;
|
|
51
|
+
let child = current.children?.find((c) => c.id === folderId);
|
|
52
|
+
if (!child) {
|
|
53
|
+
child = {
|
|
54
|
+
id: folderId,
|
|
55
|
+
label: parts[i],
|
|
56
|
+
type: "folder" as const,
|
|
57
|
+
children: [],
|
|
58
|
+
};
|
|
59
|
+
current.children = current.children ?? [];
|
|
60
|
+
current.children.push(child);
|
|
61
|
+
}
|
|
62
|
+
current = child;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Add action leaves to the deepest folder
|
|
66
|
+
const actionLeaves = actions
|
|
67
|
+
.sort((a: any, b: any) => a.name.localeCompare(b.name))
|
|
68
|
+
.map((action: any) => ({
|
|
69
|
+
id: `action:${action.method}:${action.fullPath}`,
|
|
70
|
+
label: action.name,
|
|
71
|
+
type: "action" as const,
|
|
72
|
+
data: action,
|
|
73
|
+
}));
|
|
74
|
+
current.children = current.children ?? [];
|
|
75
|
+
current.children.push(...actionLeaves);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
nodes.push(actionsRoot);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Pages (tree respecting parent/child)
|
|
82
|
+
if (metadata.pages?.length > 0) {
|
|
83
|
+
const pageNodeMap = new Map<string, TreeNode>();
|
|
84
|
+
const rootPages: TreeNode[] = [];
|
|
85
|
+
|
|
86
|
+
// Create all page nodes
|
|
87
|
+
for (const page of metadata.pages) {
|
|
88
|
+
pageNodeMap.set(page.name, {
|
|
89
|
+
id: `page:${page.name}`,
|
|
90
|
+
label: page.label || page.name,
|
|
91
|
+
type: "page" as const,
|
|
92
|
+
data: page,
|
|
93
|
+
children: [],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Build parent/child relationships using both parentName and childrenNames
|
|
98
|
+
const attached = new Set<string>();
|
|
99
|
+
|
|
100
|
+
// 1) parent → child (from parentName on each page)
|
|
101
|
+
for (const page of metadata.pages) {
|
|
102
|
+
if (page.parentName && pageNodeMap.has(page.parentName)) {
|
|
103
|
+
const parent = pageNodeMap.get(page.parentName)!;
|
|
104
|
+
parent.children = parent.children ?? [];
|
|
105
|
+
if (!attached.has(page.name)) {
|
|
106
|
+
parent.children.push(pageNodeMap.get(page.name)!);
|
|
107
|
+
attached.add(page.name);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 2) parent → children (from childrenNames on each page)
|
|
113
|
+
for (const page of metadata.pages) {
|
|
114
|
+
if (page.childrenNames) {
|
|
115
|
+
const parentNode = pageNodeMap.get(page.name)!;
|
|
116
|
+
for (const childName of page.childrenNames) {
|
|
117
|
+
if (pageNodeMap.has(childName) && !attached.has(childName)) {
|
|
118
|
+
parentNode.children = parentNode.children ?? [];
|
|
119
|
+
parentNode.children.push(pageNodeMap.get(childName)!);
|
|
120
|
+
attached.add(childName);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Remaining pages without a parent go to root
|
|
127
|
+
for (const page of metadata.pages) {
|
|
128
|
+
if (!attached.has(page.name)) {
|
|
129
|
+
rootPages.push(pageNodeMap.get(page.name)!);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Remove empty children arrays for leaf nodes
|
|
134
|
+
const cleanChildren = (nodes: TreeNode[]) => {
|
|
135
|
+
for (const node of nodes) {
|
|
136
|
+
if (node.children?.length === 0) {
|
|
137
|
+
node.children = undefined;
|
|
138
|
+
} else if (node.children) {
|
|
139
|
+
cleanChildren(node.children);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
cleanChildren(rootPages);
|
|
144
|
+
|
|
145
|
+
nodes.push({
|
|
146
|
+
id: "pages",
|
|
147
|
+
label: "pages",
|
|
148
|
+
type: "folder",
|
|
149
|
+
children: rootPages,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Queues
|
|
154
|
+
if (metadata.queues?.length > 0) {
|
|
155
|
+
nodes.push({
|
|
156
|
+
id: "queues",
|
|
157
|
+
label: "queues",
|
|
158
|
+
type: "folder",
|
|
159
|
+
children: metadata.queues.map((q: any) => ({
|
|
160
|
+
id: `queue:${q.name}`,
|
|
161
|
+
label: q.name,
|
|
162
|
+
type: "queue" as const,
|
|
163
|
+
data: q,
|
|
164
|
+
})),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Topics
|
|
169
|
+
if (metadata.topics?.length > 0) {
|
|
170
|
+
nodes.push({
|
|
171
|
+
id: "topics",
|
|
172
|
+
label: "topics",
|
|
173
|
+
type: "folder",
|
|
174
|
+
children: metadata.topics.map((topic: any) => ({
|
|
175
|
+
id: `topic:${topic.name}`,
|
|
176
|
+
label: topic.name,
|
|
177
|
+
type: "topic" as const,
|
|
178
|
+
data: topic,
|
|
179
|
+
})),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Caches
|
|
184
|
+
if (metadata.caches?.length > 0) {
|
|
185
|
+
nodes.push({
|
|
186
|
+
id: "caches",
|
|
187
|
+
label: "caches",
|
|
188
|
+
type: "folder",
|
|
189
|
+
children: metadata.caches.map((cache: any) => ({
|
|
190
|
+
id: `cache:${cache.name}`,
|
|
191
|
+
label: cache.name,
|
|
192
|
+
type: "cache" as const,
|
|
193
|
+
data: cache,
|
|
194
|
+
})),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return nodes;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const DevExplorer = () => {
|
|
202
|
+
const http = useInject(HttpClient);
|
|
203
|
+
const [metadata, setMetadata] = useState<any>(null);
|
|
204
|
+
const [search, setSearch] = useState("");
|
|
205
|
+
const [params, setParams] = useQueryParams(querySchema, {
|
|
206
|
+
format: "querystring",
|
|
207
|
+
});
|
|
208
|
+
const [openNodes, setOpenNodes] = useState<Set<string>>(
|
|
209
|
+
new Set(params.open ? params.open.split(",") : ["routes", "actions"]),
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
http
|
|
214
|
+
.fetch("/__devtools/api/metadata", {
|
|
215
|
+
schema: { response: devMetadataSchema },
|
|
216
|
+
})
|
|
217
|
+
.then((res) => setMetadata(res.data))
|
|
218
|
+
.catch(() => {});
|
|
219
|
+
}, [http]);
|
|
220
|
+
|
|
221
|
+
const tree = useMemo(() => (metadata ? buildTree(metadata) : []), [metadata]);
|
|
222
|
+
|
|
223
|
+
const selectedId = params.selected ?? "";
|
|
224
|
+
|
|
225
|
+
const selectedData = useMemo(() => {
|
|
226
|
+
if (!selectedId || !metadata) return null;
|
|
227
|
+
const [type, ...rest] = selectedId.split(":");
|
|
228
|
+
const key = rest.join(":");
|
|
229
|
+
switch (type) {
|
|
230
|
+
case "action": {
|
|
231
|
+
const sepIdx = key.indexOf(":");
|
|
232
|
+
const method = sepIdx >= 0 ? key.slice(0, sepIdx) : "";
|
|
233
|
+
const path = sepIdx >= 0 ? key.slice(sepIdx + 1) : key;
|
|
234
|
+
return {
|
|
235
|
+
type: "action",
|
|
236
|
+
data: metadata.actions?.find(
|
|
237
|
+
(a: any) => a.method === method && a.fullPath === path,
|
|
238
|
+
),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
case "page":
|
|
242
|
+
return {
|
|
243
|
+
type: "page",
|
|
244
|
+
data: metadata.pages?.find((p: any) => p.name === key),
|
|
245
|
+
};
|
|
246
|
+
case "queue":
|
|
247
|
+
return {
|
|
248
|
+
type: "queue",
|
|
249
|
+
data: metadata.queues?.find((q: any) => q.name === key),
|
|
250
|
+
};
|
|
251
|
+
case "topic":
|
|
252
|
+
return {
|
|
253
|
+
type: "topic",
|
|
254
|
+
data: metadata.topics?.find((t: any) => t.name === key),
|
|
255
|
+
};
|
|
256
|
+
case "cache":
|
|
257
|
+
return {
|
|
258
|
+
type: "cache",
|
|
259
|
+
data: metadata.caches?.find((c: any) => c.name === key),
|
|
260
|
+
};
|
|
261
|
+
default:
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
}, [selectedId, metadata]);
|
|
265
|
+
|
|
266
|
+
const handleSelect = useCallback(
|
|
267
|
+
(id: string) => {
|
|
268
|
+
setParams({ selected: id, open: Array.from(openNodes).join(",") });
|
|
269
|
+
},
|
|
270
|
+
[setParams, openNodes],
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const handleToggle = useCallback(
|
|
274
|
+
(id: string) => {
|
|
275
|
+
setOpenNodes((prev) => {
|
|
276
|
+
const next = new Set(prev);
|
|
277
|
+
if (next.has(id)) next.delete(id);
|
|
278
|
+
else next.add(id);
|
|
279
|
+
setParams({
|
|
280
|
+
selected: params.selected,
|
|
281
|
+
open: Array.from(next).join(","),
|
|
282
|
+
});
|
|
283
|
+
return next;
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
[setParams, params.selected],
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
<Flex style={{ flex: 1, overflow: "hidden" }}>
|
|
291
|
+
{/* Tree sidebar */}
|
|
292
|
+
<Flex
|
|
293
|
+
w={280}
|
|
294
|
+
style={{
|
|
295
|
+
borderRight: `1px solid ${ui.colors.border}`,
|
|
296
|
+
flexShrink: 0,
|
|
297
|
+
display: "flex",
|
|
298
|
+
flexDirection: "column",
|
|
299
|
+
}}
|
|
300
|
+
>
|
|
301
|
+
<Flex p="xs">
|
|
302
|
+
<TextInput
|
|
303
|
+
placeholder="Search..."
|
|
304
|
+
size="xs"
|
|
305
|
+
leftSection={<IconSearch size={14} />}
|
|
306
|
+
value={search}
|
|
307
|
+
onChange={(e) => setSearch(e.currentTarget.value)}
|
|
308
|
+
/>
|
|
309
|
+
</Flex>
|
|
310
|
+
<ScrollArea style={{ flex: 1 }} px="xs" pb="xs">
|
|
311
|
+
<ExplorerTree
|
|
312
|
+
nodes={tree}
|
|
313
|
+
selectedId={selectedId}
|
|
314
|
+
openNodes={openNodes}
|
|
315
|
+
search={search}
|
|
316
|
+
onSelect={handleSelect}
|
|
317
|
+
onToggle={handleToggle}
|
|
318
|
+
/>
|
|
319
|
+
</ScrollArea>
|
|
320
|
+
</Flex>
|
|
321
|
+
|
|
322
|
+
{/* Detail panel */}
|
|
323
|
+
<Flex style={{ flex: 1, overflow: "auto" }} p="lg">
|
|
324
|
+
{!selectedData && (
|
|
325
|
+
<Flex align="center" justify="center" h="100%">
|
|
326
|
+
<Text c="dimmed" fz="sm">
|
|
327
|
+
Select a resource from the tree
|
|
328
|
+
</Text>
|
|
329
|
+
</Flex>
|
|
330
|
+
)}
|
|
331
|
+
{selectedData?.type === "action" && selectedData.data && (
|
|
332
|
+
<DevPanelAction action={selectedData.data} />
|
|
333
|
+
)}
|
|
334
|
+
{selectedData?.type === "page" && selectedData.data && (
|
|
335
|
+
<DevPanelPage page={selectedData.data} />
|
|
336
|
+
)}
|
|
337
|
+
{selectedData?.type === "queue" && selectedData.data && (
|
|
338
|
+
<DevPanelQueue queue={selectedData.data} />
|
|
339
|
+
)}
|
|
340
|
+
{selectedData?.type === "topic" && selectedData.data && (
|
|
341
|
+
<DevPanelTopic topic={selectedData.data} />
|
|
342
|
+
)}
|
|
343
|
+
{selectedData?.type === "cache" && selectedData.data && (
|
|
344
|
+
<DevPanelCache cache={selectedData.data} />
|
|
345
|
+
)}
|
|
346
|
+
</Flex>
|
|
347
|
+
</Flex>
|
|
348
|
+
);
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
export default DevExplorer;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Text } from "@mantine/core";
|
|
2
|
+
import {
|
|
3
|
+
IconApi,
|
|
4
|
+
IconBroadcast,
|
|
5
|
+
IconDatabase,
|
|
6
|
+
IconFileText,
|
|
7
|
+
IconFolder,
|
|
8
|
+
IconFolderOpen,
|
|
9
|
+
IconRoute,
|
|
10
|
+
IconStack2,
|
|
11
|
+
} from "@tabler/icons-react";
|
|
12
|
+
import { useMemo } from "react";
|
|
13
|
+
import { TreeView, type TreeViewNode } from "../shared/TreeView.tsx";
|
|
14
|
+
|
|
15
|
+
export interface TreeNode {
|
|
16
|
+
id: string;
|
|
17
|
+
label: string;
|
|
18
|
+
type: "folder" | "action" | "page" | "queue" | "topic" | "cache";
|
|
19
|
+
children?: TreeNode[];
|
|
20
|
+
data?: any;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Method badge: use Mantine's light variant colors (scheme-aware)
|
|
24
|
+
const METHOD_COLORS: Record<string, { color: string; bg: string }> = {
|
|
25
|
+
GET: {
|
|
26
|
+
color: "var(--mantine-color-green-text)",
|
|
27
|
+
bg: "var(--mantine-color-green-light)",
|
|
28
|
+
},
|
|
29
|
+
POST: {
|
|
30
|
+
color: "var(--mantine-color-blue-text)",
|
|
31
|
+
bg: "var(--mantine-color-blue-light)",
|
|
32
|
+
},
|
|
33
|
+
PUT: {
|
|
34
|
+
color: "var(--mantine-color-orange-text)",
|
|
35
|
+
bg: "var(--mantine-color-orange-light)",
|
|
36
|
+
},
|
|
37
|
+
PATCH: {
|
|
38
|
+
color: "var(--mantine-color-yellow-text)",
|
|
39
|
+
bg: "var(--mantine-color-yellow-light)",
|
|
40
|
+
},
|
|
41
|
+
DELETE: {
|
|
42
|
+
color: "var(--mantine-color-red-text)",
|
|
43
|
+
bg: "var(--mantine-color-red-light)",
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const nodeIcons: Record<string, any> = {
|
|
48
|
+
page: IconFileText,
|
|
49
|
+
queue: IconStack2,
|
|
50
|
+
topic: IconBroadcast,
|
|
51
|
+
cache: IconDatabase,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// Use Mantine text colors: these adapt to light/dark scheme
|
|
55
|
+
const nodeColors: Record<string, string> = {
|
|
56
|
+
page: "var(--mantine-color-blue-text)",
|
|
57
|
+
queue: "var(--mantine-color-orange-text)",
|
|
58
|
+
topic: "var(--mantine-color-pink-text)",
|
|
59
|
+
cache: "var(--mantine-color-cyan-text)",
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const folderIcons: Record<string, { icon: any; color: string }> = {
|
|
63
|
+
actions: { icon: IconApi, color: "var(--mantine-color-teal-text)" },
|
|
64
|
+
pages: { icon: IconFileText, color: "var(--mantine-color-blue-text)" },
|
|
65
|
+
queues: { icon: IconStack2, color: "var(--mantine-color-orange-text)" },
|
|
66
|
+
topics: { icon: IconBroadcast, color: "var(--mantine-color-pink-text)" },
|
|
67
|
+
caches: { icon: IconDatabase, color: "var(--mantine-color-cyan-text)" },
|
|
68
|
+
routes: { icon: IconRoute, color: "var(--mantine-color-violet-text)" },
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const MethodBadge = ({ method }: { method: string }) => {
|
|
72
|
+
const upper = method.toUpperCase();
|
|
73
|
+
const short = upper === "DELETE" ? "DEL" : upper;
|
|
74
|
+
const colors = METHOD_COLORS[upper] ?? {
|
|
75
|
+
color: "var(--mantine-color-dimmed)",
|
|
76
|
+
bg: "var(--mantine-color-default-hover)",
|
|
77
|
+
};
|
|
78
|
+
return (
|
|
79
|
+
<Text
|
|
80
|
+
component="span"
|
|
81
|
+
fz={9}
|
|
82
|
+
fw={700}
|
|
83
|
+
ff="monospace"
|
|
84
|
+
lh={1}
|
|
85
|
+
style={{
|
|
86
|
+
paddingTop: 5,
|
|
87
|
+
color: colors.color,
|
|
88
|
+
background: colors.bg,
|
|
89
|
+
padding: "2px 4px",
|
|
90
|
+
borderRadius: 3,
|
|
91
|
+
flexShrink: 0,
|
|
92
|
+
letterSpacing: 0.3,
|
|
93
|
+
width: 32,
|
|
94
|
+
textAlign: "center",
|
|
95
|
+
display: "inline-block",
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{short}
|
|
99
|
+
</Text>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const toTreeViewNode = (
|
|
104
|
+
node: TreeNode,
|
|
105
|
+
openNodes: Set<string>,
|
|
106
|
+
): TreeViewNode => {
|
|
107
|
+
const isFolder = node.type === "folder";
|
|
108
|
+
const isAction = node.type === "action";
|
|
109
|
+
|
|
110
|
+
let icon: React.ReactNode;
|
|
111
|
+
|
|
112
|
+
if (isFolder) {
|
|
113
|
+
const knownFolder = folderIcons[node.id];
|
|
114
|
+
if (knownFolder) {
|
|
115
|
+
const Icon = knownFolder.icon;
|
|
116
|
+
icon = (
|
|
117
|
+
<Icon size={15} color={knownFolder.color} style={{ flexShrink: 0 }} />
|
|
118
|
+
);
|
|
119
|
+
} else {
|
|
120
|
+
const isOpen = openNodes.has(node.id);
|
|
121
|
+
const Icon = isOpen ? IconFolderOpen : IconFolder;
|
|
122
|
+
icon = (
|
|
123
|
+
<Icon
|
|
124
|
+
size={15}
|
|
125
|
+
color="var(--mantine-color-dimmed)"
|
|
126
|
+
style={{ flexShrink: 0 }}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
} else if (isAction) {
|
|
131
|
+
icon = <MethodBadge method={node.data?.method ?? "GET"} />;
|
|
132
|
+
} else {
|
|
133
|
+
const Icon = nodeIcons[node.type] ?? IconFileText;
|
|
134
|
+
const color = nodeColors[node.type] ?? "var(--mantine-color-dimmed)";
|
|
135
|
+
icon = <Icon size={15} color={color} style={{ flexShrink: 0 }} />;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
id: node.id,
|
|
140
|
+
label: node.label,
|
|
141
|
+
icon,
|
|
142
|
+
children: node.children?.map((child) => toTreeViewNode(child, openNodes)),
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
interface ExplorerTreeProps {
|
|
147
|
+
nodes: TreeNode[];
|
|
148
|
+
selectedId: string;
|
|
149
|
+
openNodes: Set<string>;
|
|
150
|
+
search: string;
|
|
151
|
+
onSelect: (id: string) => void;
|
|
152
|
+
onToggle: (id: string) => void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export const ExplorerTree = ({
|
|
156
|
+
nodes,
|
|
157
|
+
selectedId,
|
|
158
|
+
openNodes,
|
|
159
|
+
search,
|
|
160
|
+
onSelect,
|
|
161
|
+
onToggle,
|
|
162
|
+
}: ExplorerTreeProps) => {
|
|
163
|
+
const treeViewNodes = useMemo(
|
|
164
|
+
() => nodes.map((n) => toTreeViewNode(n, openNodes)),
|
|
165
|
+
[nodes, openNodes],
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<TreeView
|
|
170
|
+
nodes={treeViewNodes}
|
|
171
|
+
selectedId={selectedId}
|
|
172
|
+
openNodes={openNodes}
|
|
173
|
+
search={search}
|
|
174
|
+
onSelect={onSelect}
|
|
175
|
+
onToggle={onToggle}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
};
|