@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.
Files changed (236) 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 +349 -321
  5. package/dist/index.js +293 -186
  6. package/dist/index.js.map +1 -1
  7. package/package.json +30 -23
  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 +280 -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 +55 -59
  21. package/src/ui/components/DevLayout.tsx +104 -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 +482 -0
  29. package/src/ui/components/database/DatabaseEditor.page.tsx +23 -0
  30. package/src/ui/components/database/DatabaseEditor.tsx +399 -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/explorer/DevExplorer.tsx +351 -0
  36. package/src/ui/components/explorer/ExplorerTree.tsx +178 -0
  37. package/src/ui/components/explorer/panels/DevPanelAction.tsx +499 -0
  38. package/src/ui/components/explorer/panels/DevPanelCache.tsx +73 -0
  39. package/src/ui/components/explorer/panels/DevPanelPage.tsx +96 -0
  40. package/src/ui/components/explorer/panels/DevPanelQueue.tsx +51 -0
  41. package/src/ui/components/explorer/panels/DevPanelTopic.tsx +56 -0
  42. package/src/ui/components/explorer/panels/index.ts +5 -0
  43. package/src/ui/components/graph/DevDependencyGraph.tsx +35 -60
  44. package/src/ui/components/graph/GraphControls.tsx +10 -11
  45. package/src/ui/components/graph/NodeDetails.tsx +22 -29
  46. package/src/ui/components/graph/ProviderNode.tsx +4 -4
  47. package/src/ui/components/graph/helpers.ts +1 -1
  48. package/src/ui/components/logs/DevLogs.tsx +661 -0
  49. package/src/ui/components/logs/index.ts +1 -0
  50. package/src/ui/components/shared/TreeView.tsx +189 -0
  51. package/src/ui/main.css +17 -0
  52. package/src/ui/main.ts +2 -6
  53. package/LICENSE +0 -21
  54. package/assets/devtools/actions.html +0 -21
  55. package/assets/devtools/actions.html.br +0 -0
  56. package/assets/devtools/actions.html.gz +0 -0
  57. package/assets/devtools/asset.BZV40eAE.css +0 -1
  58. package/assets/devtools/asset.BZV40eAE.css.br +0 -0
  59. package/assets/devtools/asset.BZV40eAE.css.gz +0 -0
  60. package/assets/devtools/asset.CBnMq2vO.css +0 -1
  61. package/assets/devtools/asset.CBnMq2vO.css.br +0 -0
  62. package/assets/devtools/asset.CBnMq2vO.css.gz +0 -0
  63. package/assets/devtools/atoms.html +0 -21
  64. package/assets/devtools/atoms.html.br +0 -0
  65. package/assets/devtools/atoms.html.gz +0 -0
  66. package/assets/devtools/caches.html +0 -21
  67. package/assets/devtools/caches.html.br +0 -0
  68. package/assets/devtools/caches.html.gz +0 -0
  69. package/assets/devtools/chunk.6INqNjF0.js +0 -1
  70. package/assets/devtools/chunk.6INqNjF0.js.br +0 -0
  71. package/assets/devtools/chunk.6INqNjF0.js.gz +0 -0
  72. package/assets/devtools/chunk.9vpWpXSF.js +0 -1
  73. package/assets/devtools/chunk.9vpWpXSF.js.br +0 -0
  74. package/assets/devtools/chunk.9vpWpXSF.js.gz +0 -0
  75. package/assets/devtools/chunk.B4peH6PS.js +0 -1
  76. package/assets/devtools/chunk.B4peH6PS.js.br +0 -0
  77. package/assets/devtools/chunk.B4peH6PS.js.gz +0 -0
  78. package/assets/devtools/chunk.B8CNjZzU.js +0 -1
  79. package/assets/devtools/chunk.B8CNjZzU.js.br +0 -0
  80. package/assets/devtools/chunk.B8CNjZzU.js.gz +0 -0
  81. package/assets/devtools/chunk.Bgd10SVI.js +0 -1
  82. package/assets/devtools/chunk.Bgd10SVI.js.br +0 -0
  83. package/assets/devtools/chunk.Bgd10SVI.js.gz +0 -0
  84. package/assets/devtools/chunk.BjFrJKj1.js +0 -1
  85. package/assets/devtools/chunk.BjFrJKj1.js.br +0 -2
  86. package/assets/devtools/chunk.BjFrJKj1.js.gz +0 -0
  87. package/assets/devtools/chunk.BlqFPyLh.js +0 -1
  88. package/assets/devtools/chunk.BlqFPyLh.js.br +0 -0
  89. package/assets/devtools/chunk.BlqFPyLh.js.gz +0 -0
  90. package/assets/devtools/chunk.BqBNmfN9.js +0 -1
  91. package/assets/devtools/chunk.BqBNmfN9.js.br +0 -0
  92. package/assets/devtools/chunk.BqBNmfN9.js.gz +0 -0
  93. package/assets/devtools/chunk.Bt0_vkJm.js +0 -2
  94. package/assets/devtools/chunk.Bt0_vkJm.js.br +0 -0
  95. package/assets/devtools/chunk.Bt0_vkJm.js.gz +0 -0
  96. package/assets/devtools/chunk.C3GuU4pz.js +0 -2
  97. package/assets/devtools/chunk.C3GuU4pz.js.br +0 -0
  98. package/assets/devtools/chunk.C3GuU4pz.js.gz +0 -0
  99. package/assets/devtools/chunk.CGwoN_Mo.js +0 -1
  100. package/assets/devtools/chunk.CGwoN_Mo.js.br +0 -0
  101. package/assets/devtools/chunk.CGwoN_Mo.js.gz +0 -0
  102. package/assets/devtools/chunk.CJCvhHA7.js +0 -1
  103. package/assets/devtools/chunk.CJCvhHA7.js.br +0 -2
  104. package/assets/devtools/chunk.CJCvhHA7.js.gz +0 -0
  105. package/assets/devtools/chunk.CKr2VE6v.js +0 -1
  106. package/assets/devtools/chunk.CKr2VE6v.js.br +0 -0
  107. package/assets/devtools/chunk.CKr2VE6v.js.gz +0 -0
  108. package/assets/devtools/chunk.CLvTwbkw.js +0 -1
  109. package/assets/devtools/chunk.CLvTwbkw.js.br +0 -0
  110. package/assets/devtools/chunk.CLvTwbkw.js.gz +0 -0
  111. package/assets/devtools/chunk.CR13dZhE.js +0 -7
  112. package/assets/devtools/chunk.CR13dZhE.js.br +0 -0
  113. package/assets/devtools/chunk.CR13dZhE.js.gz +0 -0
  114. package/assets/devtools/chunk.C_C-cVqs.js +0 -1
  115. package/assets/devtools/chunk.C_C-cVqs.js.br +0 -1
  116. package/assets/devtools/chunk.C_C-cVqs.js.gz +0 -0
  117. package/assets/devtools/chunk.CjevPbPy.js +0 -1
  118. package/assets/devtools/chunk.CjevPbPy.js.br +0 -0
  119. package/assets/devtools/chunk.CjevPbPy.js.gz +0 -0
  120. package/assets/devtools/chunk.CkNMZqAe.js +0 -1
  121. package/assets/devtools/chunk.CkNMZqAe.js.br +0 -0
  122. package/assets/devtools/chunk.CkNMZqAe.js.gz +0 -0
  123. package/assets/devtools/chunk.Cl1Mlnqx.js +0 -1
  124. package/assets/devtools/chunk.Cl1Mlnqx.js.br +0 -0
  125. package/assets/devtools/chunk.Cl1Mlnqx.js.gz +0 -0
  126. package/assets/devtools/chunk.CyY8OGdZ.js +0 -1
  127. package/assets/devtools/chunk.CyY8OGdZ.js.br +0 -0
  128. package/assets/devtools/chunk.CyY8OGdZ.js.gz +0 -0
  129. package/assets/devtools/chunk.Cyx9kLqD.js +0 -1
  130. package/assets/devtools/chunk.Cyx9kLqD.js.br +0 -0
  131. package/assets/devtools/chunk.Cyx9kLqD.js.gz +0 -0
  132. package/assets/devtools/chunk.D1MGgxUI.js +0 -1
  133. package/assets/devtools/chunk.D1MGgxUI.js.br +0 -0
  134. package/assets/devtools/chunk.D1MGgxUI.js.gz +0 -0
  135. package/assets/devtools/chunk.D5Ci-dwk.js +0 -1
  136. package/assets/devtools/chunk.D5Ci-dwk.js.br +0 -0
  137. package/assets/devtools/chunk.D5Ci-dwk.js.gz +0 -0
  138. package/assets/devtools/chunk.DFrWQW5x.js +0 -9
  139. package/assets/devtools/chunk.DFrWQW5x.js.br +0 -0
  140. package/assets/devtools/chunk.DFrWQW5x.js.gz +0 -0
  141. package/assets/devtools/chunk.DaVlli3f.js +0 -1
  142. package/assets/devtools/chunk.DaVlli3f.js.br +0 -0
  143. package/assets/devtools/chunk.DaVlli3f.js.gz +0 -0
  144. package/assets/devtools/chunk.DdyBCs50.js +0 -1
  145. package/assets/devtools/chunk.DdyBCs50.js.br +0 -0
  146. package/assets/devtools/chunk.DdyBCs50.js.gz +0 -0
  147. package/assets/devtools/chunk.Dl0THvrP.js +0 -1
  148. package/assets/devtools/chunk.Dl0THvrP.js.br +0 -0
  149. package/assets/devtools/chunk.Dl0THvrP.js.gz +0 -0
  150. package/assets/devtools/chunk.DwUNDm68.js +0 -1
  151. package/assets/devtools/chunk.DwUNDm68.js.br +0 -0
  152. package/assets/devtools/chunk.DwUNDm68.js.gz +0 -0
  153. package/assets/devtools/chunk.DzDkh4C6.js +0 -1
  154. package/assets/devtools/chunk.DzDkh4C6.js.br +0 -0
  155. package/assets/devtools/chunk.DzDkh4C6.js.gz +0 -0
  156. package/assets/devtools/chunk.QTExp4CY.js +0 -1
  157. package/assets/devtools/chunk.QTExp4CY.js.br +0 -0
  158. package/assets/devtools/chunk.QTExp4CY.js.gz +0 -0
  159. package/assets/devtools/chunk.ReCPcJln.js +0 -1
  160. package/assets/devtools/chunk.ReCPcJln.js.br +0 -0
  161. package/assets/devtools/chunk.ReCPcJln.js.gz +0 -0
  162. package/assets/devtools/chunk.UEhIKOMY.js +0 -1
  163. package/assets/devtools/chunk.UEhIKOMY.js.br +0 -0
  164. package/assets/devtools/chunk.UEhIKOMY.js.gz +0 -0
  165. package/assets/devtools/chunk.mWQqK3dU.js +0 -1
  166. package/assets/devtools/chunk.mWQqK3dU.js.br +0 -0
  167. package/assets/devtools/chunk.mWQqK3dU.js.gz +0 -0
  168. package/assets/devtools/chunk.uyVen0u2.js +0 -1
  169. package/assets/devtools/chunk.uyVen0u2.js.br +0 -0
  170. package/assets/devtools/chunk.uyVen0u2.js.gz +0 -0
  171. package/assets/devtools/chunk.yLRX_cUF.js +0 -1
  172. package/assets/devtools/chunk.yLRX_cUF.js.br +0 -0
  173. package/assets/devtools/chunk.yLRX_cUF.js.gz +0 -0
  174. package/assets/devtools/chunk.zuZxBYZg.js +0 -1
  175. package/assets/devtools/chunk.zuZxBYZg.js.br +0 -0
  176. package/assets/devtools/chunk.zuZxBYZg.js.gz +0 -0
  177. package/assets/devtools/db.html +0 -21
  178. package/assets/devtools/db.html.br +0 -0
  179. package/assets/devtools/db.html.gz +0 -0
  180. package/assets/devtools/entry.Cry3rxEI.js +0 -79
  181. package/assets/devtools/entry.Cry3rxEI.js.br +0 -0
  182. package/assets/devtools/entry.Cry3rxEI.js.gz +0 -0
  183. package/assets/devtools/env.html +0 -21
  184. package/assets/devtools/env.html.br +0 -0
  185. package/assets/devtools/env.html.gz +0 -0
  186. package/assets/devtools/graph.html +0 -22
  187. package/assets/devtools/graph.html.br +0 -0
  188. package/assets/devtools/graph.html.gz +0 -0
  189. package/assets/devtools/index.html +0 -21
  190. package/assets/devtools/index.html.br +0 -0
  191. package/assets/devtools/index.html.gz +0 -0
  192. package/assets/devtools/logs.html +0 -21
  193. package/assets/devtools/logs.html.br +0 -0
  194. package/assets/devtools/logs.html.gz +0 -0
  195. package/assets/devtools/queues.html +0 -21
  196. package/assets/devtools/queues.html.br +0 -0
  197. package/assets/devtools/queues.html.gz +0 -0
  198. package/assets/devtools/topics.html +0 -21
  199. package/assets/devtools/topics.html.br +0 -0
  200. package/assets/devtools/topics.html.gz +0 -0
  201. package/src/api/DevToolsProvider.ts +0 -157
  202. package/src/api/providers/DevToolsDatabaseProvider.ts +0 -27
  203. package/src/api/repositories/LogRepository.ts +0 -8
  204. package/src/api/schemas/DevCommandMetadata.ts +0 -9
  205. package/src/ui/components/DevAtomsViewer.tsx +0 -637
  206. package/src/ui/components/DevCacheInspector.tsx +0 -423
  207. package/src/ui/components/DevDashboard.tsx +0 -38
  208. package/src/ui/components/DevEnvExplorer.tsx +0 -462
  209. package/src/ui/components/DevLogViewer.tsx +0 -252
  210. package/src/ui/components/DevQueueMonitor.tsx +0 -51
  211. package/src/ui/components/DevTopicsViewer.tsx +0 -686
  212. package/src/ui/components/actions/ActionGroup.tsx +0 -37
  213. package/src/ui/components/actions/ActionItem.tsx +0 -138
  214. package/src/ui/components/actions/DevActionsExplorer.tsx +0 -132
  215. package/src/ui/components/actions/MethodBadge.tsx +0 -18
  216. package/src/ui/components/actions/SchemaViewer.tsx +0 -21
  217. package/src/ui/components/actions/TryItPanel.tsx +0 -140
  218. package/src/ui/components/actions/constants.ts +0 -7
  219. package/src/ui/components/actions/helpers.ts +0 -18
  220. package/src/ui/components/actions/index.ts +0 -8
  221. package/src/ui/components/db/ColumnBadge.tsx +0 -55
  222. package/src/ui/components/db/DevDbStudio.tsx +0 -485
  223. package/src/ui/components/db/constants.ts +0 -11
  224. package/src/ui/components/db/index.ts +0 -4
  225. package/src/ui/components/db/types.ts +0 -7
  226. package/src/ui/styles.css +0 -1
  227. /package/src/{api/schemas → schemas}/DevAtomMetadata.ts +0 -0
  228. /package/src/{api/schemas → schemas}/DevBucketMetadata.ts +0 -0
  229. /package/src/{api/schemas → schemas}/DevCacheMetadata.ts +0 -0
  230. /package/src/{api/schemas → schemas}/DevEnvMetadata.ts +0 -0
  231. /package/src/{api/schemas → schemas}/DevModuleMetadata.ts +0 -0
  232. /package/src/{api/schemas → schemas}/DevProviderMetadata.ts +0 -0
  233. /package/src/{api/schemas → schemas}/DevQueueMetadata.ts +0 -0
  234. /package/src/{api/schemas → schemas}/DevRealmMetadata.ts +0 -0
  235. /package/src/{api/schemas → schemas}/DevRouteMetadata.ts +0 -0
  236. /package/src/{api/schemas → schemas}/DevSchedulerMetadata.ts +0 -0
@@ -0,0 +1,499 @@
1
+ import { ActionButton, Flex, JsonViewer, TypeForm, ui } from "@alepha/ui";
2
+ import {
3
+ Badge,
4
+ Card,
5
+ Code,
6
+ JsonInput,
7
+ Tabs,
8
+ Text,
9
+ Tooltip,
10
+ } from "@mantine/core";
11
+ import { IconPlayerPlay, IconSchema } from "@tabler/icons-react";
12
+ import { jsonSchemaToTypeBox, t } from "alepha";
13
+ import { useInject } from "alepha/react";
14
+ import { useForm } from "alepha/react/form";
15
+ import { HttpClient } from "alepha/server";
16
+ import { useCallback, useMemo, useRef, useState } from "react";
17
+
18
+ const methodColors: Record<string, string> = {
19
+ GET: "teal",
20
+ POST: "blue",
21
+ PUT: "orange",
22
+ PATCH: "yellow",
23
+ DELETE: "red",
24
+ };
25
+
26
+ const EMPTY_SCHEMA = t.object({});
27
+
28
+ const toTypeBoxObject = (jsonSchema: any): any => {
29
+ if (!jsonSchema) return null;
30
+ try {
31
+ const converted = jsonSchemaToTypeBox(jsonSchema);
32
+ if (converted?.properties) return converted;
33
+ } catch {
34
+ // Schema conversion failed
35
+ }
36
+ return null;
37
+ };
38
+
39
+ const formatPermission = (perm: any): string =>
40
+ typeof perm === "string" ? perm : (perm?.name ?? String(perm));
41
+
42
+ const getMiddlewareSummary = (
43
+ name: string,
44
+ opts: any,
45
+ ): { label: string; color: string }[] | null => {
46
+ if (!opts) return null;
47
+ switch (name) {
48
+ case "$rateLimit":
49
+ if (opts.max) return [{ label: `max:${opts.max}`, color: "red" }];
50
+ break;
51
+ case "$circuit":
52
+ if (opts.threshold)
53
+ return [{ label: `threshold:${opts.threshold}`, color: "red" }];
54
+ break;
55
+ case "$throttle":
56
+ if (opts.rate) return [{ label: `rate:${opts.rate}`, color: "yellow" }];
57
+ break;
58
+ case "$retry":
59
+ if (opts.max) return [{ label: `max:${opts.max}`, color: "blue" }];
60
+ break;
61
+ case "$cors":
62
+ if (opts.origin) return [{ label: String(opts.origin), color: "blue" }];
63
+ break;
64
+ case "$lock":
65
+ if (opts.key) return [{ label: `key:${opts.key}`, color: "pink" }];
66
+ break;
67
+ }
68
+ return null;
69
+ };
70
+
71
+ const MiddlewareEntry = ({ mw }: { mw: any }) => {
72
+ const opts = mw.options;
73
+ const hasSecureDetails =
74
+ opts?.roles?.length ||
75
+ opts?.permissions?.length ||
76
+ opts?.issuers?.length ||
77
+ opts?.optional;
78
+
79
+ const summary =
80
+ mw.name !== "$secure" ? getMiddlewareSummary(mw.name, opts) : null;
81
+
82
+ const nameBadge = (
83
+ <Badge size="sm" variant="light" color="violet">
84
+ {mw.name}
85
+ </Badge>
86
+ );
87
+
88
+ return (
89
+ <Flex gap="xs" wrap="wrap" align="center">
90
+ {opts && !hasSecureDetails && !summary && mw.name !== "$secure" ? (
91
+ <Tooltip
92
+ label={JSON.stringify(opts, null, 2)}
93
+ multiline
94
+ maw={400}
95
+ styles={{ tooltip: { fontFamily: "monospace", fontSize: 11 } }}
96
+ >
97
+ {nameBadge}
98
+ </Tooltip>
99
+ ) : (
100
+ nameBadge
101
+ )}
102
+ {opts?.roles?.length > 0 &&
103
+ opts.roles.map((role: string) => (
104
+ <Badge key={role} size="xs" variant="dot" color="cyan">
105
+ {role}
106
+ </Badge>
107
+ ))}
108
+ {opts?.permissions?.length > 0 &&
109
+ opts.permissions.map((perm: any) => (
110
+ <Badge
111
+ key={formatPermission(perm)}
112
+ size="xs"
113
+ variant="dot"
114
+ color="orange"
115
+ >
116
+ {formatPermission(perm)}
117
+ </Badge>
118
+ ))}
119
+ {opts?.issuers?.length > 0 &&
120
+ opts.issuers.map((issuer: string) => (
121
+ <Badge key={issuer} size="xs" variant="dot" color="green">
122
+ {issuer}
123
+ </Badge>
124
+ ))}
125
+ {opts?.optional && (
126
+ <Badge size="xs" variant="outline" color="gray">
127
+ optional
128
+ </Badge>
129
+ )}
130
+ {summary?.map((item) => (
131
+ <Badge key={item.label} size="xs" variant="dot" color={item.color}>
132
+ {item.label}
133
+ </Badge>
134
+ ))}
135
+ </Flex>
136
+ );
137
+ };
138
+
139
+ export const DevPanelAction = ({ action }: { action: any }) => {
140
+ const http = useInject(HttpClient);
141
+ const [body, setBody] = useState("{}");
142
+ const [response, setResponse] = useState<any>(null);
143
+ const [loading, setLoading] = useState(false);
144
+ const [timing, setTiming] = useState<number>(0);
145
+
146
+ const actionKey = `${action.method}:${action.fullPath}`;
147
+
148
+ const bodySchema = useMemo(
149
+ () => (action.method !== "GET" ? toTypeBoxObject(action.body) : null),
150
+ [actionKey],
151
+ );
152
+ const querySchema = useMemo(() => toTypeBoxObject(action.query), [actionKey]);
153
+ const paramsSchema = useMemo(
154
+ () => toTypeBoxObject(action.params),
155
+ [actionKey],
156
+ );
157
+
158
+ const bodyForm = useForm(
159
+ { schema: bodySchema ?? EMPTY_SCHEMA, handler: () => {} },
160
+ [bodySchema],
161
+ );
162
+ const queryForm = useForm(
163
+ { schema: querySchema ?? EMPTY_SCHEMA, handler: () => {} },
164
+ [querySchema],
165
+ );
166
+ const paramsForm = useForm(
167
+ { schema: paramsSchema ?? EMPTY_SCHEMA, handler: () => {} },
168
+ [paramsSchema],
169
+ );
170
+
171
+ // Track whether we're using TypeForm or JsonInput for the body
172
+ const useTypeFormBody = !!bodySchema;
173
+ const bodyRef = useRef(body);
174
+ bodyRef.current = body;
175
+
176
+ const execute = useCallback(async () => {
177
+ setLoading(true);
178
+ setResponse(null);
179
+ const start = performance.now();
180
+ try {
181
+ // Build URL with path param substitution
182
+ let url = action.fullPath;
183
+ if (paramsSchema) {
184
+ const params = paramsForm.currentValues;
185
+ for (const [k, v] of Object.entries(params)) {
186
+ if (v !== undefined && v !== null) {
187
+ url = url.replace(`:${k}`, encodeURIComponent(String(v)));
188
+ }
189
+ }
190
+ }
191
+
192
+ // Append query params
193
+ if (querySchema) {
194
+ const qp = queryForm.currentValues;
195
+ const searchParams = new URLSearchParams();
196
+ for (const [k, v] of Object.entries(qp)) {
197
+ if (v !== undefined && v !== null && v !== "") {
198
+ searchParams.set(k, String(v));
199
+ }
200
+ }
201
+ const qs = searchParams.toString();
202
+ if (qs) url += `?${qs}`;
203
+ }
204
+
205
+ // Get body
206
+ let parsedBody: any;
207
+ if (action.method !== "GET") {
208
+ if (useTypeFormBody) {
209
+ parsedBody = bodyForm.currentValues;
210
+ } else {
211
+ try {
212
+ parsedBody = JSON.parse(bodyRef.current);
213
+ } catch {
214
+ parsedBody = undefined;
215
+ }
216
+ }
217
+ }
218
+
219
+ const res = await http.fetch(url, {
220
+ method: action.method,
221
+ body: action.method !== "GET" ? JSON.stringify(parsedBody) : undefined,
222
+ headers:
223
+ action.method !== "GET"
224
+ ? { "Content-Type": "application/json" }
225
+ : undefined,
226
+ });
227
+ setTiming(Math.round(performance.now() - start));
228
+ setResponse({ status: res.status, data: res.data });
229
+ } catch (error: any) {
230
+ setTiming(Math.round(performance.now() - start));
231
+ setResponse({ error: error.message ?? "Request failed" });
232
+ } finally {
233
+ setLoading(false);
234
+ }
235
+ }, [
236
+ http,
237
+ action,
238
+ useTypeFormBody,
239
+ bodyForm,
240
+ queryForm,
241
+ paramsForm,
242
+ bodySchema,
243
+ querySchema,
244
+ paramsSchema,
245
+ ]);
246
+
247
+ return (
248
+ <Flex direction="column" gap="md">
249
+ <div>
250
+ <Flex gap="sm" mb="xs">
251
+ <Badge
252
+ size="lg"
253
+ variant="light"
254
+ color={methodColors[action.method] ?? "gray"}
255
+ >
256
+ {action.method}
257
+ </Badge>
258
+ <Code fz="sm">{action.fullPath}</Code>
259
+ {action.secure && (
260
+ <Badge size="xs" variant="outline" color="yellow">
261
+ Secure
262
+ </Badge>
263
+ )}
264
+ </Flex>
265
+ {action.description && (
266
+ <Text fz="sm" c="dimmed">
267
+ {action.description}
268
+ </Text>
269
+ )}
270
+ </div>
271
+
272
+ {action.middlewares?.length > 0 && (
273
+ <div>
274
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
275
+ Middleware
276
+ </Text>
277
+ <Flex direction="column" gap="xs">
278
+ {action.middlewares.map((mw: any) => (
279
+ <MiddlewareEntry key={mw.name} mw={mw} />
280
+ ))}
281
+ </Flex>
282
+ </div>
283
+ )}
284
+
285
+ <Tabs defaultValue="schema">
286
+ <Tabs.List>
287
+ <Tabs.Tab value="schema" leftSection={<IconSchema size={14} />}>
288
+ Schema
289
+ </Tabs.Tab>
290
+ <Tabs.Tab value="tryit" leftSection={<IconPlayerPlay size={14} />}>
291
+ Try It
292
+ </Tabs.Tab>
293
+ </Tabs.List>
294
+
295
+ <Tabs.Panel value="schema" pt="md">
296
+ <Flex direction="column" gap="md">
297
+ {action.body && (
298
+ <div>
299
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
300
+ Request Body
301
+ </Text>
302
+ <Card
303
+ padding="sm"
304
+ style={{
305
+ background: ui.colors.surface,
306
+ border: `1px solid ${ui.colors.border}`,
307
+ }}
308
+ >
309
+ <JsonViewer
310
+ data={action.body}
311
+ defaultExpandedDepth={2}
312
+ size="xs"
313
+ />
314
+ </Card>
315
+ </div>
316
+ )}
317
+ {action.params && (
318
+ <div>
319
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
320
+ Path Parameters
321
+ </Text>
322
+ <Card
323
+ padding="sm"
324
+ style={{
325
+ background: ui.colors.surface,
326
+ border: `1px solid ${ui.colors.border}`,
327
+ }}
328
+ >
329
+ <JsonViewer
330
+ data={action.params}
331
+ defaultExpandedDepth={2}
332
+ size="xs"
333
+ />
334
+ </Card>
335
+ </div>
336
+ )}
337
+ {action.query && (
338
+ <div>
339
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
340
+ Query Parameters
341
+ </Text>
342
+ <Card
343
+ padding="sm"
344
+ style={{
345
+ background: ui.colors.surface,
346
+ border: `1px solid ${ui.colors.border}`,
347
+ }}
348
+ >
349
+ <JsonViewer
350
+ data={action.query}
351
+ defaultExpandedDepth={2}
352
+ size="xs"
353
+ />
354
+ </Card>
355
+ </div>
356
+ )}
357
+ {action.response && (
358
+ <div>
359
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
360
+ Response
361
+ </Text>
362
+ <Card
363
+ padding="sm"
364
+ style={{
365
+ background: ui.colors.surface,
366
+ border: `1px solid ${ui.colors.border}`,
367
+ }}
368
+ >
369
+ <JsonViewer
370
+ data={action.response}
371
+ defaultExpandedDepth={2}
372
+ size="xs"
373
+ />
374
+ </Card>
375
+ </div>
376
+ )}
377
+ {!action.body &&
378
+ !action.params &&
379
+ !action.query &&
380
+ !action.response && (
381
+ <Text c="dimmed" fz="sm">
382
+ No schema defined for this action.
383
+ </Text>
384
+ )}
385
+ </Flex>
386
+ </Tabs.Panel>
387
+
388
+ <Tabs.Panel value="tryit" pt="md">
389
+ <Flex direction="column" gap="md">
390
+ {paramsSchema && (
391
+ <div>
392
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
393
+ Path Parameters
394
+ </Text>
395
+ <TypeForm
396
+ form={paramsForm}
397
+ skipSubmitButton
398
+ skipFormElement
399
+ columns={1}
400
+ />
401
+ </div>
402
+ )}
403
+ {querySchema && (
404
+ <div>
405
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
406
+ Query Parameters
407
+ </Text>
408
+ <TypeForm
409
+ form={queryForm}
410
+ skipSubmitButton
411
+ skipFormElement
412
+ columns={1}
413
+ />
414
+ </div>
415
+ )}
416
+ {action.method !== "GET" && (
417
+ <div>
418
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
419
+ Request Body
420
+ </Text>
421
+ {bodySchema ? (
422
+ <TypeForm
423
+ form={bodyForm}
424
+ skipSubmitButton
425
+ skipFormElement
426
+ columns={1}
427
+ />
428
+ ) : (
429
+ <JsonInput
430
+ value={body}
431
+ onChange={setBody}
432
+ formatOnBlur
433
+ autosize
434
+ minRows={4}
435
+ maxRows={12}
436
+ styles={{
437
+ input: { fontFamily: "monospace", fontSize: 12 },
438
+ }}
439
+ />
440
+ )}
441
+ </div>
442
+ )}
443
+ <Flex>
444
+ <ActionButton
445
+ size="xs"
446
+ loading={loading}
447
+ onClick={execute}
448
+ color={methodColors[action.method] ?? "blue"}
449
+ icon={<IconPlayerPlay size={14} />}
450
+ >
451
+ Send Request
452
+ </ActionButton>
453
+ {timing > 0 && (
454
+ <Text fz="xs" c="dimmed">
455
+ {timing}ms
456
+ </Text>
457
+ )}
458
+ </Flex>
459
+ {response && (
460
+ <div>
461
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
462
+ Response
463
+ </Text>
464
+ <Card
465
+ padding="sm"
466
+ style={{
467
+ background: ui.colors.surface,
468
+ border: `1px solid ${ui.colors.border}`,
469
+ }}
470
+ >
471
+ {response.error ? (
472
+ <Text c="red" fz="sm">
473
+ {response.error}
474
+ </Text>
475
+ ) : (
476
+ <>
477
+ <Badge
478
+ size="xs"
479
+ mb="xs"
480
+ color={response.status < 400 ? "teal" : "red"}
481
+ >
482
+ {response.status}
483
+ </Badge>
484
+ <JsonViewer
485
+ data={response.data}
486
+ defaultExpandedDepth={3}
487
+ size="xs"
488
+ />
489
+ </>
490
+ )}
491
+ </Card>
492
+ </div>
493
+ )}
494
+ </Flex>
495
+ </Tabs.Panel>
496
+ </Tabs>
497
+ </Flex>
498
+ );
499
+ };
@@ -0,0 +1,73 @@
1
+ import { Flex, ui } from "@alepha/ui";
2
+ import { Badge, Card, Text } from "@mantine/core";
3
+
4
+ const formatTtl = (seconds?: number): string => {
5
+ if (!seconds) return "No TTL";
6
+ if (seconds < 60) return `${seconds}s`;
7
+ if (seconds < 3600) return `${Math.floor(seconds / 60)}m`;
8
+ if (seconds < 86400) return `${Math.floor(seconds / 3600)}h`;
9
+ return `${Math.floor(seconds / 86400)}d`;
10
+ };
11
+
12
+ export const DevPanelCache = ({ cache }: { cache: any }) => {
13
+ return (
14
+ <Flex direction="column" gap="md">
15
+ <div>
16
+ <Text fz="lg" fw={600} mb="xs">
17
+ {cache.name}
18
+ </Text>
19
+ </div>
20
+
21
+ <Flex gap="xs">
22
+ <Badge size="xs" variant="light" color="cyan">
23
+ Cache
24
+ </Badge>
25
+ {cache.provider && (
26
+ <Badge size="xs" variant="outline" color="gray">
27
+ {cache.provider}
28
+ </Badge>
29
+ )}
30
+ {cache.disabled && (
31
+ <Badge size="xs" variant="light" color="red">
32
+ Disabled
33
+ </Badge>
34
+ )}
35
+ </Flex>
36
+
37
+ <Card
38
+ padding="sm"
39
+ style={{
40
+ background: ui.colors.surface,
41
+ border: `1px solid ${ui.colors.border}`,
42
+ }}
43
+ >
44
+ <Flex direction="column" gap="xs">
45
+ <Flex justify="space-between">
46
+ <Text fz="xs" c="dimmed">
47
+ TTL
48
+ </Text>
49
+ <Text fz="sm" ff="monospace">
50
+ {formatTtl(cache.ttl)}
51
+ </Text>
52
+ </Flex>
53
+ <Flex justify="space-between">
54
+ <Text fz="xs" c="dimmed">
55
+ Provider
56
+ </Text>
57
+ <Text fz="sm" ff="monospace">
58
+ {cache.provider ?? "default"}
59
+ </Text>
60
+ </Flex>
61
+ <Flex justify="space-between">
62
+ <Text fz="xs" c="dimmed">
63
+ Status
64
+ </Text>
65
+ <Badge size="xs" color={cache.disabled ? "red" : "green"}>
66
+ {cache.disabled ? "Disabled" : "Active"}
67
+ </Badge>
68
+ </Flex>
69
+ </Flex>
70
+ </Card>
71
+ </Flex>
72
+ );
73
+ };
@@ -0,0 +1,96 @@
1
+ import { Flex, JsonViewer, ui } from "@alepha/ui";
2
+ import { Badge, Card, Code, Text } from "@mantine/core";
3
+
4
+ export const DevPanelPage = ({ page }: { page: any }) => {
5
+ return (
6
+ <Flex direction="column" gap="md">
7
+ <div>
8
+ <Text fz="lg" fw={600} mb="xs">
9
+ {page.label || page.name}
10
+ </Text>
11
+ {page.path && (
12
+ <Code fz="sm" mb="xs">
13
+ {page.path}
14
+ </Code>
15
+ )}
16
+ {page.description && (
17
+ <Text fz="sm" c="dimmed">
18
+ {page.description}
19
+ </Text>
20
+ )}
21
+ </div>
22
+
23
+ <Flex gap="xs">
24
+ {page.hasLazy && (
25
+ <Badge size="xs" variant="light" color="blue">
26
+ Lazy
27
+ </Badge>
28
+ )}
29
+ {page.hasParent && (
30
+ <Badge size="xs" variant="light" color="gray">
31
+ Parent: {page.parentName ?? "?"}
32
+ </Badge>
33
+ )}
34
+ {page.hasChildren && (
35
+ <Badge size="xs" variant="light" color="teal">
36
+ Children
37
+ </Badge>
38
+ )}
39
+ {page.hasErrorHandler && (
40
+ <Badge size="xs" variant="light" color="red">
41
+ Error Handler
42
+ </Badge>
43
+ )}
44
+ {page.hasResolve && (
45
+ <Badge size="xs" variant="light" color="violet">
46
+ Loader
47
+ </Badge>
48
+ )}
49
+ {page.client && (
50
+ <Badge size="xs" variant="light" color="orange">
51
+ Client Only
52
+ </Badge>
53
+ )}
54
+ {page.static && (
55
+ <Badge size="xs" variant="light" color="cyan">
56
+ Static
57
+ </Badge>
58
+ )}
59
+ </Flex>
60
+
61
+ {page.params && (
62
+ <div>
63
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
64
+ Path Parameters
65
+ </Text>
66
+ <Card
67
+ padding="sm"
68
+ style={{
69
+ background: ui.colors.surface,
70
+ border: `1px solid ${ui.colors.border}`,
71
+ }}
72
+ >
73
+ <JsonViewer data={page.params} defaultExpandedDepth={2} size="xs" />
74
+ </Card>
75
+ </div>
76
+ )}
77
+
78
+ {page.query && (
79
+ <div>
80
+ <Text fz="xs" c="dimmed" mb="xs" tt="uppercase" fw={600}>
81
+ Query Parameters
82
+ </Text>
83
+ <Card
84
+ padding="sm"
85
+ style={{
86
+ background: ui.colors.surface,
87
+ border: `1px solid ${ui.colors.border}`,
88
+ }}
89
+ >
90
+ <JsonViewer data={page.query} defaultExpandedDepth={2} size="xs" />
91
+ </Card>
92
+ </div>
93
+ )}
94
+ </Flex>
95
+ );
96
+ };