@alepha/devtools 0.16.1 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +1 -5
  2. package/dist/index.browser.js +224 -0
  3. package/dist/index.browser.js.map +1 -0
  4. package/dist/index.d.ts +351 -323
  5. package/dist/index.js +350 -186
  6. package/dist/index.js.map +1 -1
  7. package/package.json +33 -25
  8. package/src/assets.ts +6 -0
  9. package/src/{api/entities → entities}/logs.ts +2 -2
  10. package/src/index.browser.ts +11 -0
  11. package/src/index.shared.ts +15 -0
  12. package/src/index.ts +11 -37
  13. package/src/{api/providers → providers}/DevToolsMetadataProvider.ts +84 -47
  14. package/src/providers/DevToolsProvider.ts +394 -0
  15. package/src/{api/schemas → schemas}/DevActionMetadata.ts +8 -0
  16. package/src/{api/schemas → schemas}/DevEntityMetadata.ts +3 -0
  17. package/src/{api/schemas → schemas}/DevMetadata.ts +13 -2
  18. package/src/{api/schemas → schemas}/DevPageMetadata.ts +3 -0
  19. package/src/{api/schemas → schemas}/DevTopicMetadata.ts +1 -0
  20. package/src/ui/AppRouter.tsx +73 -59
  21. package/src/ui/components/DevLayout.tsx +103 -84
  22. package/src/ui/components/configuration/ConfigAtoms.page.tsx +5 -0
  23. package/src/ui/components/configuration/ConfigAtoms.tsx +511 -0
  24. package/src/ui/components/configuration/ConfigEnv.page.tsx +5 -0
  25. package/src/ui/components/configuration/ConfigEnv.tsx +230 -0
  26. package/src/ui/components/configuration/DevConfiguration.tsx +36 -0
  27. package/src/ui/components/configuration/index.ts +3 -0
  28. package/src/ui/components/dashboard/DevDashboard.tsx +501 -0
  29. package/src/ui/components/database/DatabaseEditor.page.tsx +23 -0
  30. package/src/ui/components/database/DatabaseEditor.tsx +402 -0
  31. package/src/ui/components/database/DatabaseErd.page.tsx +28 -0
  32. package/src/ui/components/database/DatabaseErd.tsx +107 -0
  33. package/src/ui/components/database/DevDatabase.tsx +36 -0
  34. package/src/ui/components/database/EntityNode.tsx +83 -0
  35. package/src/ui/components/emails/DevEmails.tsx +250 -0
  36. package/src/ui/components/explorer/DevExplorer.tsx +351 -0
  37. package/src/ui/components/explorer/ExplorerTree.tsx +178 -0
  38. package/src/ui/components/explorer/panels/DevPanelAction.tsx +499 -0
  39. package/src/ui/components/explorer/panels/DevPanelCache.tsx +73 -0
  40. package/src/ui/components/explorer/panels/DevPanelPage.tsx +96 -0
  41. package/src/ui/components/explorer/panels/DevPanelQueue.tsx +51 -0
  42. package/src/ui/components/explorer/panels/DevPanelTopic.tsx +56 -0
  43. package/src/ui/components/explorer/panels/index.ts +5 -0
  44. package/src/ui/components/graph/DevDependencyGraph.tsx +35 -60
  45. package/src/ui/components/graph/GraphControls.tsx +10 -11
  46. package/src/ui/components/graph/NodeDetails.tsx +22 -29
  47. package/src/ui/components/graph/ProviderNode.tsx +4 -4
  48. package/src/ui/components/graph/helpers.ts +1 -1
  49. package/src/ui/components/logs/DevLogs.tsx +661 -0
  50. package/src/ui/components/logs/index.ts +1 -0
  51. package/src/ui/components/shared/TreeView.tsx +189 -0
  52. package/src/ui/components/sms/DevSms.tsx +225 -0
  53. package/src/ui/main.css +17 -0
  54. package/src/ui/main.ts +2 -6
  55. package/LICENSE +0 -21
  56. package/assets/devtools/actions.html +0 -21
  57. package/assets/devtools/actions.html.br +0 -0
  58. package/assets/devtools/actions.html.gz +0 -0
  59. package/assets/devtools/asset.BZV40eAE.css +0 -1
  60. package/assets/devtools/asset.BZV40eAE.css.br +0 -0
  61. package/assets/devtools/asset.BZV40eAE.css.gz +0 -0
  62. package/assets/devtools/asset.CBnMq2vO.css +0 -1
  63. package/assets/devtools/asset.CBnMq2vO.css.br +0 -0
  64. package/assets/devtools/asset.CBnMq2vO.css.gz +0 -0
  65. package/assets/devtools/atoms.html +0 -21
  66. package/assets/devtools/atoms.html.br +0 -0
  67. package/assets/devtools/atoms.html.gz +0 -0
  68. package/assets/devtools/caches.html +0 -21
  69. package/assets/devtools/caches.html.br +0 -0
  70. package/assets/devtools/caches.html.gz +0 -0
  71. package/assets/devtools/chunk.6INqNjF0.js +0 -1
  72. package/assets/devtools/chunk.6INqNjF0.js.br +0 -0
  73. package/assets/devtools/chunk.6INqNjF0.js.gz +0 -0
  74. package/assets/devtools/chunk.9vpWpXSF.js +0 -1
  75. package/assets/devtools/chunk.9vpWpXSF.js.br +0 -0
  76. package/assets/devtools/chunk.9vpWpXSF.js.gz +0 -0
  77. package/assets/devtools/chunk.B4peH6PS.js +0 -1
  78. package/assets/devtools/chunk.B4peH6PS.js.br +0 -0
  79. package/assets/devtools/chunk.B4peH6PS.js.gz +0 -0
  80. package/assets/devtools/chunk.B8CNjZzU.js +0 -1
  81. package/assets/devtools/chunk.B8CNjZzU.js.br +0 -0
  82. package/assets/devtools/chunk.B8CNjZzU.js.gz +0 -0
  83. package/assets/devtools/chunk.Bgd10SVI.js +0 -1
  84. package/assets/devtools/chunk.Bgd10SVI.js.br +0 -0
  85. package/assets/devtools/chunk.Bgd10SVI.js.gz +0 -0
  86. package/assets/devtools/chunk.BjFrJKj1.js +0 -1
  87. package/assets/devtools/chunk.BjFrJKj1.js.br +0 -2
  88. package/assets/devtools/chunk.BjFrJKj1.js.gz +0 -0
  89. package/assets/devtools/chunk.BlqFPyLh.js +0 -1
  90. package/assets/devtools/chunk.BlqFPyLh.js.br +0 -0
  91. package/assets/devtools/chunk.BlqFPyLh.js.gz +0 -0
  92. package/assets/devtools/chunk.BqBNmfN9.js +0 -1
  93. package/assets/devtools/chunk.BqBNmfN9.js.br +0 -0
  94. package/assets/devtools/chunk.BqBNmfN9.js.gz +0 -0
  95. package/assets/devtools/chunk.Bt0_vkJm.js +0 -2
  96. package/assets/devtools/chunk.Bt0_vkJm.js.br +0 -0
  97. package/assets/devtools/chunk.Bt0_vkJm.js.gz +0 -0
  98. package/assets/devtools/chunk.C3GuU4pz.js +0 -2
  99. package/assets/devtools/chunk.C3GuU4pz.js.br +0 -0
  100. package/assets/devtools/chunk.C3GuU4pz.js.gz +0 -0
  101. package/assets/devtools/chunk.CGwoN_Mo.js +0 -1
  102. package/assets/devtools/chunk.CGwoN_Mo.js.br +0 -0
  103. package/assets/devtools/chunk.CGwoN_Mo.js.gz +0 -0
  104. package/assets/devtools/chunk.CJCvhHA7.js +0 -1
  105. package/assets/devtools/chunk.CJCvhHA7.js.br +0 -2
  106. package/assets/devtools/chunk.CJCvhHA7.js.gz +0 -0
  107. package/assets/devtools/chunk.CKr2VE6v.js +0 -1
  108. package/assets/devtools/chunk.CKr2VE6v.js.br +0 -0
  109. package/assets/devtools/chunk.CKr2VE6v.js.gz +0 -0
  110. package/assets/devtools/chunk.CLvTwbkw.js +0 -1
  111. package/assets/devtools/chunk.CLvTwbkw.js.br +0 -0
  112. package/assets/devtools/chunk.CLvTwbkw.js.gz +0 -0
  113. package/assets/devtools/chunk.CR13dZhE.js +0 -7
  114. package/assets/devtools/chunk.CR13dZhE.js.br +0 -0
  115. package/assets/devtools/chunk.CR13dZhE.js.gz +0 -0
  116. package/assets/devtools/chunk.C_C-cVqs.js +0 -1
  117. package/assets/devtools/chunk.C_C-cVqs.js.br +0 -1
  118. package/assets/devtools/chunk.C_C-cVqs.js.gz +0 -0
  119. package/assets/devtools/chunk.CjevPbPy.js +0 -1
  120. package/assets/devtools/chunk.CjevPbPy.js.br +0 -0
  121. package/assets/devtools/chunk.CjevPbPy.js.gz +0 -0
  122. package/assets/devtools/chunk.CkNMZqAe.js +0 -1
  123. package/assets/devtools/chunk.CkNMZqAe.js.br +0 -0
  124. package/assets/devtools/chunk.CkNMZqAe.js.gz +0 -0
  125. package/assets/devtools/chunk.Cl1Mlnqx.js +0 -1
  126. package/assets/devtools/chunk.Cl1Mlnqx.js.br +0 -0
  127. package/assets/devtools/chunk.Cl1Mlnqx.js.gz +0 -0
  128. package/assets/devtools/chunk.CyY8OGdZ.js +0 -1
  129. package/assets/devtools/chunk.CyY8OGdZ.js.br +0 -0
  130. package/assets/devtools/chunk.CyY8OGdZ.js.gz +0 -0
  131. package/assets/devtools/chunk.Cyx9kLqD.js +0 -1
  132. package/assets/devtools/chunk.Cyx9kLqD.js.br +0 -0
  133. package/assets/devtools/chunk.Cyx9kLqD.js.gz +0 -0
  134. package/assets/devtools/chunk.D1MGgxUI.js +0 -1
  135. package/assets/devtools/chunk.D1MGgxUI.js.br +0 -0
  136. package/assets/devtools/chunk.D1MGgxUI.js.gz +0 -0
  137. package/assets/devtools/chunk.D5Ci-dwk.js +0 -1
  138. package/assets/devtools/chunk.D5Ci-dwk.js.br +0 -0
  139. package/assets/devtools/chunk.D5Ci-dwk.js.gz +0 -0
  140. package/assets/devtools/chunk.DFrWQW5x.js +0 -9
  141. package/assets/devtools/chunk.DFrWQW5x.js.br +0 -0
  142. package/assets/devtools/chunk.DFrWQW5x.js.gz +0 -0
  143. package/assets/devtools/chunk.DaVlli3f.js +0 -1
  144. package/assets/devtools/chunk.DaVlli3f.js.br +0 -0
  145. package/assets/devtools/chunk.DaVlli3f.js.gz +0 -0
  146. package/assets/devtools/chunk.DdyBCs50.js +0 -1
  147. package/assets/devtools/chunk.DdyBCs50.js.br +0 -0
  148. package/assets/devtools/chunk.DdyBCs50.js.gz +0 -0
  149. package/assets/devtools/chunk.Dl0THvrP.js +0 -1
  150. package/assets/devtools/chunk.Dl0THvrP.js.br +0 -0
  151. package/assets/devtools/chunk.Dl0THvrP.js.gz +0 -0
  152. package/assets/devtools/chunk.DwUNDm68.js +0 -1
  153. package/assets/devtools/chunk.DwUNDm68.js.br +0 -0
  154. package/assets/devtools/chunk.DwUNDm68.js.gz +0 -0
  155. package/assets/devtools/chunk.DzDkh4C6.js +0 -1
  156. package/assets/devtools/chunk.DzDkh4C6.js.br +0 -0
  157. package/assets/devtools/chunk.DzDkh4C6.js.gz +0 -0
  158. package/assets/devtools/chunk.QTExp4CY.js +0 -1
  159. package/assets/devtools/chunk.QTExp4CY.js.br +0 -0
  160. package/assets/devtools/chunk.QTExp4CY.js.gz +0 -0
  161. package/assets/devtools/chunk.ReCPcJln.js +0 -1
  162. package/assets/devtools/chunk.ReCPcJln.js.br +0 -0
  163. package/assets/devtools/chunk.ReCPcJln.js.gz +0 -0
  164. package/assets/devtools/chunk.UEhIKOMY.js +0 -1
  165. package/assets/devtools/chunk.UEhIKOMY.js.br +0 -0
  166. package/assets/devtools/chunk.UEhIKOMY.js.gz +0 -0
  167. package/assets/devtools/chunk.mWQqK3dU.js +0 -1
  168. package/assets/devtools/chunk.mWQqK3dU.js.br +0 -0
  169. package/assets/devtools/chunk.mWQqK3dU.js.gz +0 -0
  170. package/assets/devtools/chunk.uyVen0u2.js +0 -1
  171. package/assets/devtools/chunk.uyVen0u2.js.br +0 -0
  172. package/assets/devtools/chunk.uyVen0u2.js.gz +0 -0
  173. package/assets/devtools/chunk.yLRX_cUF.js +0 -1
  174. package/assets/devtools/chunk.yLRX_cUF.js.br +0 -0
  175. package/assets/devtools/chunk.yLRX_cUF.js.gz +0 -0
  176. package/assets/devtools/chunk.zuZxBYZg.js +0 -1
  177. package/assets/devtools/chunk.zuZxBYZg.js.br +0 -0
  178. package/assets/devtools/chunk.zuZxBYZg.js.gz +0 -0
  179. package/assets/devtools/db.html +0 -21
  180. package/assets/devtools/db.html.br +0 -0
  181. package/assets/devtools/db.html.gz +0 -0
  182. package/assets/devtools/entry.Cry3rxEI.js +0 -79
  183. package/assets/devtools/entry.Cry3rxEI.js.br +0 -0
  184. package/assets/devtools/entry.Cry3rxEI.js.gz +0 -0
  185. package/assets/devtools/env.html +0 -21
  186. package/assets/devtools/env.html.br +0 -0
  187. package/assets/devtools/env.html.gz +0 -0
  188. package/assets/devtools/graph.html +0 -22
  189. package/assets/devtools/graph.html.br +0 -0
  190. package/assets/devtools/graph.html.gz +0 -0
  191. package/assets/devtools/index.html +0 -21
  192. package/assets/devtools/index.html.br +0 -0
  193. package/assets/devtools/index.html.gz +0 -0
  194. package/assets/devtools/logs.html +0 -21
  195. package/assets/devtools/logs.html.br +0 -0
  196. package/assets/devtools/logs.html.gz +0 -0
  197. package/assets/devtools/queues.html +0 -21
  198. package/assets/devtools/queues.html.br +0 -0
  199. package/assets/devtools/queues.html.gz +0 -0
  200. package/assets/devtools/topics.html +0 -21
  201. package/assets/devtools/topics.html.br +0 -0
  202. package/assets/devtools/topics.html.gz +0 -0
  203. package/src/api/DevToolsProvider.ts +0 -157
  204. package/src/api/providers/DevToolsDatabaseProvider.ts +0 -27
  205. package/src/api/repositories/LogRepository.ts +0 -8
  206. package/src/api/schemas/DevCommandMetadata.ts +0 -9
  207. package/src/ui/components/DevAtomsViewer.tsx +0 -637
  208. package/src/ui/components/DevCacheInspector.tsx +0 -423
  209. package/src/ui/components/DevDashboard.tsx +0 -38
  210. package/src/ui/components/DevEnvExplorer.tsx +0 -462
  211. package/src/ui/components/DevLogViewer.tsx +0 -252
  212. package/src/ui/components/DevQueueMonitor.tsx +0 -51
  213. package/src/ui/components/DevTopicsViewer.tsx +0 -686
  214. package/src/ui/components/actions/ActionGroup.tsx +0 -37
  215. package/src/ui/components/actions/ActionItem.tsx +0 -138
  216. package/src/ui/components/actions/DevActionsExplorer.tsx +0 -132
  217. package/src/ui/components/actions/MethodBadge.tsx +0 -18
  218. package/src/ui/components/actions/SchemaViewer.tsx +0 -21
  219. package/src/ui/components/actions/TryItPanel.tsx +0 -140
  220. package/src/ui/components/actions/constants.ts +0 -7
  221. package/src/ui/components/actions/helpers.ts +0 -18
  222. package/src/ui/components/actions/index.ts +0 -8
  223. package/src/ui/components/db/ColumnBadge.tsx +0 -55
  224. package/src/ui/components/db/DevDbStudio.tsx +0 -485
  225. package/src/ui/components/db/constants.ts +0 -11
  226. package/src/ui/components/db/index.ts +0 -4
  227. package/src/ui/components/db/types.ts +0 -7
  228. package/src/ui/styles.css +0 -1
  229. /package/src/{api/schemas → schemas}/DevAtomMetadata.ts +0 -0
  230. /package/src/{api/schemas → schemas}/DevBucketMetadata.ts +0 -0
  231. /package/src/{api/schemas → schemas}/DevCacheMetadata.ts +0 -0
  232. /package/src/{api/schemas → schemas}/DevEnvMetadata.ts +0 -0
  233. /package/src/{api/schemas → schemas}/DevModuleMetadata.ts +0 -0
  234. /package/src/{api/schemas → schemas}/DevProviderMetadata.ts +0 -0
  235. /package/src/{api/schemas → schemas}/DevQueueMetadata.ts +0 -0
  236. /package/src/{api/schemas → schemas}/DevRealmMetadata.ts +0 -0
  237. /package/src/{api/schemas → schemas}/DevRouteMetadata.ts +0 -0
  238. /package/src/{api/schemas → schemas}/DevSchedulerMetadata.ts +0 -0
@@ -0,0 +1,250 @@
1
+ import { Flex, ui } from "@alepha/ui";
2
+ import { Badge, CloseButton, ScrollArea, Text, TextInput } from "@mantine/core";
3
+ import { IconSearch } from "@tabler/icons-react";
4
+ import { useInject } from "alepha/react";
5
+ import { HttpClient } from "alepha/server";
6
+ import { useCallback, useEffect, useState } from "react";
7
+
8
+ interface EmailEntry {
9
+ to: string;
10
+ subject: string;
11
+ body: string;
12
+ sentAt: string;
13
+ }
14
+
15
+ const formatDate = (iso: string): string => {
16
+ const d = new Date(iso);
17
+ return d.toLocaleString();
18
+ };
19
+
20
+ const formatRelative = (iso: string): string => {
21
+ const diff = Date.now() - new Date(iso).getTime();
22
+ if (diff < 1000) return "just now";
23
+ if (diff < 60_000) return `${Math.floor(diff / 1000)}s ago`;
24
+ if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m ago`;
25
+ return `${Math.floor(diff / 3_600_000)}h ago`;
26
+ };
27
+
28
+ export const DevEmails = () => {
29
+ const http = useInject(HttpClient);
30
+ const [emails, setEmails] = useState<EmailEntry[]>([]);
31
+ const [selectedIndex, setSelectedIndex] = useState<number | null>(null);
32
+ const [search, setSearch] = useState("");
33
+
34
+ const fetchEmails = useCallback(async () => {
35
+ if (document.visibilityState !== "visible") return;
36
+ try {
37
+ const res = await http.fetch("/__devtools/api/emails");
38
+ const data = res.data as any;
39
+ setEmails(data?.emails ?? []);
40
+ } catch {
41
+ // silently fail
42
+ }
43
+ }, [http]);
44
+
45
+ useEffect(() => {
46
+ fetchEmails();
47
+ const interval = setInterval(fetchEmails, 10_000);
48
+ return () => clearInterval(interval);
49
+ }, [fetchEmails]);
50
+
51
+ const filtered = emails.filter((email) => {
52
+ if (!search) return true;
53
+ const q = search.toLowerCase();
54
+ return (
55
+ email.to.toLowerCase().includes(q) ||
56
+ email.subject.toLowerCase().includes(q)
57
+ );
58
+ });
59
+
60
+ const selectedEmail = selectedIndex !== null ? filtered[selectedIndex] : null;
61
+
62
+ return (
63
+ <Flex style={{ flex: 1, overflow: "hidden" }} direction="column">
64
+ {/* Filter bar */}
65
+ <Flex
66
+ px="md"
67
+ py="xs"
68
+ gap="sm"
69
+ align="center"
70
+ style={{
71
+ borderBottom: `1px solid ${ui.colors.border}`,
72
+ flexShrink: 0,
73
+ }}
74
+ >
75
+ <TextInput
76
+ size="xs"
77
+ placeholder="Search..."
78
+ leftSection={<IconSearch size={14} />}
79
+ value={search}
80
+ onChange={(e) => setSearch(e.currentTarget.value)}
81
+ style={{ flex: 1, minWidth: 150, maxWidth: 300 }}
82
+ />
83
+ <Badge variant="light" color="gray" size="sm">
84
+ {filtered.length} emails
85
+ </Badge>
86
+ </Flex>
87
+
88
+ {/* Main area: list + detail */}
89
+ <Flex style={{ flex: 1, overflow: "hidden" }}>
90
+ {/* Email list */}
91
+ <Flex direction="column" style={{ flex: 1, overflow: "hidden" }}>
92
+ <ScrollArea style={{ flex: 1 }}>
93
+ {filtered.length === 0 && (
94
+ <Flex align="center" justify="center" py="xl" c="dimmed">
95
+ <Text fz="sm">No emails to display</Text>
96
+ </Flex>
97
+ )}
98
+ {filtered.map((email, i) => {
99
+ const isSelected = selectedIndex === i;
100
+
101
+ return (
102
+ <Flex
103
+ key={`${email.sentAt}-${i}`}
104
+ direction="column"
105
+ px="md"
106
+ py="xs"
107
+ onClick={() => setSelectedIndex(isSelected ? null : i)}
108
+ style={{
109
+ borderBottom: `1px solid ${ui.colors.border}20`,
110
+ background: isSelected ? ui.colors.elevated : "transparent",
111
+ cursor: "pointer",
112
+ transition: "background 100ms",
113
+ }}
114
+ onMouseEnter={(e) => {
115
+ if (!isSelected) {
116
+ (e.currentTarget as HTMLElement).style.background =
117
+ `${ui.colors.elevated}80`;
118
+ }
119
+ }}
120
+ onMouseLeave={(e) => {
121
+ if (!isSelected) {
122
+ (e.currentTarget as HTMLElement).style.background =
123
+ "transparent";
124
+ }
125
+ }}
126
+ >
127
+ <Flex justify="space-between" align="center">
128
+ <Text fz="sm" truncate>
129
+ {email.to}
130
+ </Text>
131
+ <Text fz={11} c="dimmed" style={{ flexShrink: 0 }}>
132
+ {formatRelative(email.sentAt)}
133
+ </Text>
134
+ </Flex>
135
+ <Text fz="xs" c="dimmed" truncate>
136
+ {email.subject}
137
+ </Text>
138
+ </Flex>
139
+ );
140
+ })}
141
+ </ScrollArea>
142
+ </Flex>
143
+
144
+ {/* Detail panel */}
145
+ {selectedEmail && (
146
+ <Flex
147
+ w={500}
148
+ direction="column"
149
+ style={{
150
+ borderLeft: `1px solid ${ui.colors.border}`,
151
+ flexShrink: 0,
152
+ overflow: "hidden",
153
+ }}
154
+ >
155
+ <Flex
156
+ px="md"
157
+ py="xs"
158
+ align="center"
159
+ justify="space-between"
160
+ style={{
161
+ borderBottom: `1px solid ${ui.colors.border}`,
162
+ flexShrink: 0,
163
+ }}
164
+ >
165
+ <Text fz="xs" fw={600} tt="uppercase" c="dimmed" lts={0.5}>
166
+ Email Detail
167
+ </Text>
168
+ <CloseButton size="xs" onClick={() => setSelectedIndex(null)} />
169
+ </Flex>
170
+ <ScrollArea style={{ flex: 1 }} p="md">
171
+ <Flex direction="column" gap="md">
172
+ {/* To */}
173
+ <Flex direction="column">
174
+ <Text
175
+ fz={10}
176
+ c="dimmed"
177
+ tt="uppercase"
178
+ fw={600}
179
+ lts={0.5}
180
+ mb={4}
181
+ >
182
+ To
183
+ </Text>
184
+ <Text fz="xs">{selectedEmail.to}</Text>
185
+ </Flex>
186
+
187
+ {/* Date */}
188
+ <Flex direction="column">
189
+ <Text
190
+ fz={10}
191
+ c="dimmed"
192
+ tt="uppercase"
193
+ fw={600}
194
+ lts={0.5}
195
+ mb={4}
196
+ >
197
+ Date
198
+ </Text>
199
+ <Text fz="xs">{formatDate(selectedEmail.sentAt)}</Text>
200
+ </Flex>
201
+
202
+ {/* Subject */}
203
+ <Flex direction="column">
204
+ <Text
205
+ fz={10}
206
+ c="dimmed"
207
+ tt="uppercase"
208
+ fw={600}
209
+ lts={0.5}
210
+ mb={4}
211
+ >
212
+ Subject
213
+ </Text>
214
+ <Text fz="xs">{selectedEmail.subject}</Text>
215
+ </Flex>
216
+
217
+ {/* Body */}
218
+ <Flex direction="column">
219
+ <Text
220
+ fz={10}
221
+ c="dimmed"
222
+ tt="uppercase"
223
+ fw={600}
224
+ lts={0.5}
225
+ mb={4}
226
+ >
227
+ Body
228
+ </Text>
229
+ <div
230
+ style={{
231
+ background: "white",
232
+ color: "#333",
233
+ border: "1px solid #ccc",
234
+ borderRadius: 4,
235
+ padding: 12,
236
+ }}
237
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: devtools renders developer's own email HTML
238
+ dangerouslySetInnerHTML={{ __html: selectedEmail.body }}
239
+ />
240
+ </Flex>
241
+ </Flex>
242
+ </ScrollArea>
243
+ </Flex>
244
+ )}
245
+ </Flex>
246
+ </Flex>
247
+ );
248
+ };
249
+
250
+ export default DevEmails;
@@ -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.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;