adonisjs-server-stats 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/core/index.js +24 -22
  2. package/dist/core/split-pane.d.ts +18 -0
  3. package/dist/core/trace-utils.d.ts +5 -0
  4. package/dist/core/types.d.ts +1 -1
  5. package/dist/react/{CacheSection-xH75hwXu.js → CacheSection-UCMptWyn.js} +1 -1
  6. package/dist/react/{CacheTab-DYmsZJJ1.js → CacheTab-CA8LB1J5.js} +1 -1
  7. package/dist/react/{ConfigSection-D8BO1Ry9.js → ConfigSection-DfFd-WRq.js} +1 -1
  8. package/dist/react/{ConfigTab-CcN-tfjv.js → ConfigTab-Bdg8YMer.js} +1 -1
  9. package/dist/react/{CustomPaneTab-D7_o3Ec6.js → CustomPaneTab-Bxtv_8Rw.js} +1 -1
  10. package/dist/react/{EmailsSection-BzlsTdPs.js → EmailsSection-CM7stSyh.js} +1 -1
  11. package/dist/react/{EmailsTab-Uh2CQY3o.js → EmailsTab-BDhEiomM.js} +1 -1
  12. package/dist/react/{EventsSection-CGQWiIdV.js → EventsSection-ByQ-9blq.js} +1 -1
  13. package/dist/react/{EventsTab-CC6DQzEm.js → EventsTab-CMfY98Rl.js} +1 -1
  14. package/dist/react/{JobsSection-D7AHQmZi.js → JobsSection-DF3qEv9O.js} +1 -1
  15. package/dist/react/{JobsTab-B3Lfdqed.js → JobsTab-BbrBWIOb.js} +1 -1
  16. package/dist/react/{LogsSection-Cly1dpvS.js → LogsSection-DcFTZY7b.js} +1 -1
  17. package/dist/react/{LogsTab-BbYK-iyh.js → LogsTab-CicucmVk.js} +2 -2
  18. package/dist/react/{OverviewSection-CkBGFEWq.js → OverviewSection-C4T1ur51.js} +1 -1
  19. package/dist/react/{QueriesSection-CfCpnNUD.js → QueriesSection-PswteoF9.js} +1 -1
  20. package/dist/react/{QueriesTab-DbBmAqzO.js → QueriesTab-osLUWd4L.js} +1 -1
  21. package/dist/react/RelatedLogs-DFDOyUMr.js +40 -0
  22. package/dist/react/RequestsSection-Nag30rEA.js +341 -0
  23. package/dist/react/{RoutesSection-CRqF-cNM.js → RoutesSection-BUSkM6PY.js} +1 -1
  24. package/dist/react/{RoutesTab-Bwreij3e.js → RoutesTab-DgVzd2PZ.js} +1 -1
  25. package/dist/react/TimelineTab-Covg5weo.js +220 -0
  26. package/dist/react/{index-CecA4IdQ.js → index-Cflz9Ebj.js} +197 -203
  27. package/dist/react/index.js +1 -1
  28. package/dist/react/react/components/shared/RelatedLogs.d.ts +7 -0
  29. package/dist/react/style.css +1 -1
  30. package/dist/src/controller/debug_controller.js +1 -1
  31. package/dist/src/dashboard/dashboard_controller.js +13 -0
  32. package/dist/src/dashboard/dashboard_store.d.ts +1 -0
  33. package/dist/src/dashboard/dashboard_store.js +88 -41
  34. package/dist/src/dashboard/migrator.js +6 -0
  35. package/dist/src/data/data_access.d.ts +7 -0
  36. package/dist/src/data/data_access.js +32 -1
  37. package/dist/src/debug/trace_collector.d.ts +1 -1
  38. package/dist/src/debug/trace_collector.js +2 -1
  39. package/dist/src/debug/types.d.ts +4 -0
  40. package/dist/src/edge/client/dashboard.js +2 -2
  41. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  42. package/dist/src/edge/client-vue/dashboard.js +4 -4
  43. package/dist/src/edge/client-vue/debug-panel-deferred.js +3 -3
  44. package/dist/src/middleware/request_tracking_middleware.d.ts +1 -0
  45. package/dist/src/middleware/request_tracking_middleware.js +3 -1
  46. package/dist/src/provider/server_stats_provider.d.ts +3 -3
  47. package/dist/src/provider/server_stats_provider.js +29 -15
  48. package/dist/src/routes/register_routes.js +7 -2
  49. package/dist/src/styles/components.css +81 -0
  50. package/dist/src/styles/debug-panel.css +9 -0
  51. package/dist/src/types.d.ts +1 -1
  52. package/dist/vue/{CacheSection-Cx-hj09X.js → CacheSection-oFAJL3mo.js} +1 -1
  53. package/dist/vue/{ConfigSection-CMXyryf6.js → ConfigSection-BhfJ4KqL.js} +1 -1
  54. package/dist/vue/{EmailsSection-DgKl9xGT.js → EmailsSection-BcNyhyHs.js} +1 -1
  55. package/dist/vue/{EventsSection-BNMCAim1.js → EventsSection-r60Q5Lmu.js} +1 -1
  56. package/dist/vue/{JobsSection-CCMgMlxd.js → JobsSection-BHL-hkQw.js} +1 -1
  57. package/dist/vue/{LogsSection-CvOnTxUu.js → LogsSection-DRMGzJmg.js} +1 -1
  58. package/dist/vue/{OverviewSection-CHgaKtUR.js → OverviewSection-CXh6Ja1B.js} +1 -1
  59. package/dist/vue/{QueriesSection-BnHRD98z.js → QueriesSection-IodIsCJ-.js} +1 -1
  60. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-CB2_TzYW.js +84 -0
  61. package/dist/vue/RequestsSection-BPuMdmMc.js +401 -0
  62. package/dist/vue/{RoutesSection-BrceOcKQ.js → RoutesSection-NKo3Rbq3.js} +1 -1
  63. package/dist/vue/TimelineTab-zj5Z5OdT.js +338 -0
  64. package/dist/vue/components/Dashboard/sections/RequestsSection.vue.d.ts +4 -0
  65. package/dist/vue/components/DebugPanel/tabs/TimelineTab.vue.d.ts +4 -0
  66. package/dist/vue/components/{Dashboard/sections/TimelineSection.vue.d.ts → shared/RelatedLogs.vue.d.ts} +5 -6
  67. package/dist/vue/index-Dtgysd26.js +1229 -0
  68. package/dist/vue/index.js +1 -1
  69. package/dist/vue/style.css +1 -1
  70. package/package.json +1 -1
  71. package/dist/react/RequestsSection-Cb5a6MlT.js +0 -209
  72. package/dist/react/TimelineSection-B2y06kRE.js +0 -158
  73. package/dist/react/TimelineTab-6hthfdBB.js +0 -193
  74. package/dist/react/WaterfallChart-Cj73WdfM.js +0 -100
  75. package/dist/react/react/components/Dashboard/sections/TimelineSection.d.ts +0 -8
  76. package/dist/vue/RequestsSection-B-uSlM0f.js +0 -243
  77. package/dist/vue/TimelineSection-CfvnA2Oo.js +0 -186
  78. package/dist/vue/TimelineTab-Db6lKKsD.js +0 -250
  79. package/dist/vue/WaterfallChart.vue_vue_type_script_setup_true_lang-tZ13cNj1.js +0 -118
  80. package/dist/vue/index-oLxS08vN.js +0 -1235
@@ -0,0 +1,341 @@
1
+ import { jsx as t, jsxs as r, Fragment as j } from "react/jsx-runtime";
2
+ import { useMemo as q, useState as f, useEffect as M, useCallback as L, useRef as C } from "react";
3
+ import { normalizeTraceFields as z, durationSeverity as _, timeAgo as W, formatTime as G, initSplitPane as I } from "adonisjs-server-stats/core";
4
+ import { u as U } from "./useApiClient-BVtNCmnL.js";
5
+ import { a as Y, M as D, b as A } from "./index-Cflz9Ebj.js";
6
+ import { R as V } from "./RelatedLogs-DFDOyUMr.js";
7
+ import { D as H } from "./DataTable-YyShr5B-.js";
8
+ import { F as J } from "./FilterBar-DQRXpWrb.js";
9
+ import { P as K } from "./Pagination-BkmzUDY8.js";
10
+ const F = {
11
+ request: "#1e3a5f",
12
+ middleware: "rgba(30, 58, 95, 0.7)",
13
+ db: "#6d28d9",
14
+ view: "#0e7490",
15
+ mail: "#059669",
16
+ event: "#b45309",
17
+ custom: "var(--ss-dim)"
18
+ }, Q = {
19
+ request: "Request",
20
+ middleware: "Middleware",
21
+ db: "DB",
22
+ mail: "Mail",
23
+ event: "Event",
24
+ view: "View",
25
+ custom: "Custom"
26
+ };
27
+ function O({
28
+ spans: c,
29
+ totalDuration: i,
30
+ className: m = "",
31
+ warnings: d
32
+ }) {
33
+ const h = c || [], o = q(
34
+ () => [...h].sort((e, n) => e.startOffset - n.startOffset),
35
+ [h]
36
+ ), p = q(() => {
37
+ const e = {};
38
+ for (const n of o)
39
+ e[n.id] = n.parentId ? (e[n.parentId] || 0) + 1 : 0;
40
+ return e;
41
+ }, [o]);
42
+ return h.length === 0 ? /* @__PURE__ */ t("div", { className: "ss-dash-empty", children: "No spans recorded" }) : /* @__PURE__ */ r("div", { className: `ss-dash-tl-waterfall ${m}`, children: [
43
+ /* @__PURE__ */ t("div", { className: "ss-dash-tl-legend", children: Object.entries(Q).map(([e, n]) => /* @__PURE__ */ r("div", { className: "ss-dash-tl-legend-item", children: [
44
+ /* @__PURE__ */ t(
45
+ "span",
46
+ {
47
+ className: "ss-dash-tl-legend-dot",
48
+ style: {
49
+ background: F[e] || F.custom
50
+ }
51
+ }
52
+ ),
53
+ /* @__PURE__ */ t("span", { children: n })
54
+ ] }, e)) }),
55
+ o.map((e) => {
56
+ const n = i > 0 ? e.startOffset / i * 100 : 0, y = i > 0 ? Math.max(e.duration / i * 100, 0.5) : 1, v = p[e.id] || 0, S = e.label.length > 50 ? e.label.slice(0, 50) + "..." : e.label, g = e.category === "db" ? "DB" : e.category, N = e.category === "db" ? "purple" : e.category === "mail" ? "green" : e.category === "event" ? "amber" : e.category === "view" ? "blue" : "muted", u = e.metadata ? Object.entries(e.metadata).filter(([, b]) => b != null).map(([b, x]) => `${b}=${x}`).join(", ") : "", w = u ? `${e.label} (${e.duration.toFixed(2)}ms)
57
+ ${u}` : `${e.label} (${e.duration.toFixed(2)}ms)`;
58
+ return /* @__PURE__ */ r("div", { className: "ss-dash-tl-row", children: [
59
+ /* @__PURE__ */ r(
60
+ "div",
61
+ {
62
+ className: "ss-dash-tl-label",
63
+ title: w,
64
+ style: { paddingLeft: 8 + v * 16 + "px" },
65
+ children: [
66
+ /* @__PURE__ */ t(
67
+ "span",
68
+ {
69
+ className: `ss-dash-badge ss-dash-badge-${N}`,
70
+ style: { fontSize: "9px", marginRight: "4px" },
71
+ children: g
72
+ }
73
+ ),
74
+ S
75
+ ]
76
+ }
77
+ ),
78
+ /* @__PURE__ */ t("div", { className: "ss-dash-tl-track", children: /* @__PURE__ */ t(
79
+ "div",
80
+ {
81
+ className: `ss-dash-tl-bar ss-dash-tl-bar-${e.category || "custom"}`,
82
+ style: {
83
+ left: `${n}%`,
84
+ width: `${y}%`
85
+ },
86
+ title: w
87
+ }
88
+ ) }),
89
+ /* @__PURE__ */ r("span", { className: "ss-dash-tl-dur", children: [
90
+ e.duration.toFixed(2),
91
+ "ms"
92
+ ] })
93
+ ] }, e.id);
94
+ }),
95
+ d && d.length > 0 && /* @__PURE__ */ r("div", { className: "ss-dash-tl-warnings", children: [
96
+ /* @__PURE__ */ r("div", { className: "ss-dash-tl-warnings-title", children: [
97
+ "Warnings (",
98
+ d.length,
99
+ ")"
100
+ ] }),
101
+ d.map((e, n) => /* @__PURE__ */ t("div", { className: "ss-dash-tl-warning", children: e }, n))
102
+ ] })
103
+ ] });
104
+ }
105
+ function X({
106
+ children: c,
107
+ classPrefix: i = "ss-dash",
108
+ storageKey: m
109
+ }) {
110
+ const d = C(null), h = C(null), o = C(null), p = C(null);
111
+ return M(() => {
112
+ if (d.current && h.current && o.current && p.current)
113
+ return I({
114
+ container: d.current,
115
+ handle: h.current,
116
+ topPane: o.current,
117
+ bottomPane: p.current,
118
+ storageKey: m
119
+ });
120
+ }, [m]), /* @__PURE__ */ r("div", { ref: d, className: `${i}-split-container`, children: [
121
+ /* @__PURE__ */ t("div", { ref: o, className: `${i}-split-top`, children: c[0] }),
122
+ /* @__PURE__ */ t("div", { ref: h, className: `${i}-split-handle` }),
123
+ /* @__PURE__ */ t("div", { ref: p, className: `${i}-split-bottom`, children: c[1] })
124
+ ] });
125
+ }
126
+ function oe({ options: c = {} }) {
127
+ const [i, m] = f(1), [d, h] = f(""), [o, p] = f("createdAt"), [e, n] = f("desc"), [y, v] = f(null), [S, g] = f(!1);
128
+ M(() => m(1), [d]);
129
+ const { data: N, meta: u, isLoading: w, error: b } = Y("requests", {
130
+ ...c,
131
+ page: i,
132
+ search: d,
133
+ sort: o,
134
+ sortDir: e
135
+ }), x = U(c.baseUrl || "", c.authToken), P = L(
136
+ (s) => {
137
+ const a = s.id;
138
+ g(!0);
139
+ const l = c.dashboardEndpoint || "/__stats/api";
140
+ x().fetch(`${l}/requests/${a}`).then((k) => {
141
+ const $ = k, R = $.trace;
142
+ if (R) {
143
+ const E = { ...$, ...R, logs: $.logs };
144
+ v(E);
145
+ } else
146
+ v(k);
147
+ g(!1);
148
+ }).catch(() => {
149
+ g(!1);
150
+ });
151
+ },
152
+ [x, c.dashboardEndpoint]
153
+ ), T = L(
154
+ (s) => {
155
+ o === s ? n((a) => a === "asc" ? "desc" : "asc") : (p(s), n("desc"));
156
+ },
157
+ [o]
158
+ ), B = N || [];
159
+ if (y) {
160
+ const s = z(y), a = s.logs.length > 0;
161
+ return /* @__PURE__ */ r("div", { children: [
162
+ /* @__PURE__ */ r("div", { className: "ss-dash-tl-detail-header", children: [
163
+ /* @__PURE__ */ t("button", { type: "button", className: "ss-dash-btn", onClick: () => v(null), children: "← Back to Requests" }),
164
+ /* @__PURE__ */ t(D, { method: s.method }),
165
+ /* @__PURE__ */ t("span", { style: { color: "var(--ss-text)" }, children: s.url }),
166
+ /* @__PURE__ */ t(A, { code: s.statusCode }),
167
+ /* @__PURE__ */ r("span", { className: "ss-dash-tl-meta", children: [
168
+ s.totalDuration.toFixed(1),
169
+ "ms · ",
170
+ s.spanCount,
171
+ " spans"
172
+ ] })
173
+ ] }),
174
+ a ? /* @__PURE__ */ r(X, { classPrefix: "ss-dash", storageKey: "ss-requests-split", children: [
175
+ /* @__PURE__ */ t(
176
+ O,
177
+ {
178
+ spans: s.spans,
179
+ totalDuration: s.totalDuration,
180
+ warnings: s.warnings
181
+ }
182
+ ),
183
+ /* @__PURE__ */ t(V, { logs: s.logs, classPrefix: "ss-dash" })
184
+ ] }) : /* @__PURE__ */ t(
185
+ O,
186
+ {
187
+ spans: s.spans,
188
+ totalDuration: s.totalDuration,
189
+ warnings: s.warnings
190
+ }
191
+ )
192
+ ] });
193
+ }
194
+ return S ? /* @__PURE__ */ r("div", { children: [
195
+ /* @__PURE__ */ t("div", { className: "ss-dash-tl-detail-header", children: /* @__PURE__ */ t("button", { type: "button", className: "ss-dash-btn", onClick: () => g(!1), children: "← Back to Requests" }) }),
196
+ /* @__PURE__ */ t("div", { className: "ss-dash-empty", children: "Loading request detail..." })
197
+ ] }) : /* @__PURE__ */ r("div", { children: [
198
+ /* @__PURE__ */ t(
199
+ J,
200
+ {
201
+ search: d,
202
+ onSearchChange: h,
203
+ placeholder: "Filter requests...",
204
+ summary: `${u?.total ?? 0} requests`
205
+ }
206
+ ),
207
+ b && /* @__PURE__ */ t("div", { className: "ss-dash-empty", children: "Failed to load requests" }),
208
+ w && !N ? /* @__PURE__ */ t("div", { className: "ss-dash-empty", children: "Loading requests..." }) : /* @__PURE__ */ r(j, { children: [
209
+ /* @__PURE__ */ t("div", { className: "ss-dash-table-wrap", children: /* @__PURE__ */ t(
210
+ H,
211
+ {
212
+ columns: [
213
+ {
214
+ key: "id",
215
+ label: "#",
216
+ width: "40px",
217
+ render: (s) => /* @__PURE__ */ t("span", { style: { color: "var(--ss-dim)" }, children: s })
218
+ },
219
+ {
220
+ key: "method",
221
+ label: "Method",
222
+ width: "70px",
223
+ sortable: !0,
224
+ render: (s) => /* @__PURE__ */ t(D, { method: s })
225
+ },
226
+ {
227
+ key: "url",
228
+ label: "URL",
229
+ sortable: !0,
230
+ render: (s) => /* @__PURE__ */ t(
231
+ "span",
232
+ {
233
+ style: {
234
+ color: "var(--ss-text)",
235
+ overflow: "hidden",
236
+ textOverflow: "ellipsis",
237
+ whiteSpace: "nowrap"
238
+ },
239
+ title: s,
240
+ children: s
241
+ }
242
+ )
243
+ },
244
+ {
245
+ key: "statusCode",
246
+ label: "Status",
247
+ width: "60px",
248
+ sortable: !0,
249
+ render: (s, a) => {
250
+ const l = a.status_code || a.statusCode || a.statusCode;
251
+ return /* @__PURE__ */ t(A, { code: l });
252
+ }
253
+ },
254
+ {
255
+ key: "duration",
256
+ label: "Duration",
257
+ width: "80px",
258
+ sortable: !0,
259
+ render: (s, a) => {
260
+ const l = a.total_duration || a.totalDuration || a.duration || 0;
261
+ return /* @__PURE__ */ r(
262
+ "span",
263
+ {
264
+ className: `ss-dash-duration ${_(l) === "very-slow" ? "ss-dash-very-slow" : _(l) === "slow" ? "ss-dash-slow" : ""}`,
265
+ children: [
266
+ l.toFixed(1),
267
+ "ms"
268
+ ]
269
+ }
270
+ );
271
+ }
272
+ },
273
+ {
274
+ key: "spanCount",
275
+ label: "Spans",
276
+ width: "50px",
277
+ render: (s, a) => {
278
+ const l = a.span_count || a.spanCount || 0;
279
+ return /* @__PURE__ */ t("span", { style: { color: "var(--ss-muted)", textAlign: "center" }, children: l });
280
+ }
281
+ },
282
+ {
283
+ key: "warningCount",
284
+ label: "⚠",
285
+ width: "40px",
286
+ render: (s, a) => {
287
+ const l = a.warning_count || a.warningCount || 0;
288
+ return l > 0 ? /* @__PURE__ */ t(
289
+ "span",
290
+ {
291
+ style: {
292
+ color: "var(--ss-amber-fg)",
293
+ textAlign: "center",
294
+ display: "block"
295
+ },
296
+ children: l
297
+ }
298
+ ) : /* @__PURE__ */ t(
299
+ "span",
300
+ {
301
+ style: { color: "var(--ss-dim)", textAlign: "center", display: "block" },
302
+ children: "-"
303
+ }
304
+ );
305
+ }
306
+ },
307
+ {
308
+ key: "createdAt",
309
+ label: "Time",
310
+ width: "80px",
311
+ sortable: !0,
312
+ render: (s, a) => {
313
+ const l = a.createdAt || a.created_at || a.timestamp || "";
314
+ return /* @__PURE__ */ t("span", { className: "ss-dash-event-time", title: G(l), children: W(l) });
315
+ }
316
+ }
317
+ ],
318
+ data: B,
319
+ sort: o,
320
+ sortDir: e,
321
+ onSort: T,
322
+ onRowClick: P,
323
+ emptyMessage: "No requests recorded yet"
324
+ }
325
+ ) }),
326
+ u && /* @__PURE__ */ t(
327
+ K,
328
+ {
329
+ page: u.page,
330
+ lastPage: u.lastPage,
331
+ total: u.total,
332
+ onPageChange: m
333
+ }
334
+ )
335
+ ] })
336
+ ] });
337
+ }
338
+ export {
339
+ oe as RequestsSection,
340
+ oe as default
341
+ };
@@ -1,6 +1,6 @@
1
1
  import { jsxs as m, jsx as r, Fragment as p } from "react/jsx-runtime";
2
2
  import { useState as y } from "react";
3
- import { a as u, M as f } from "./index-CecA4IdQ.js";
3
+ import { a as u, M as f } from "./index-Cflz9Ebj.js";
4
4
  import { D as w } from "./DataTable-YyShr5B-.js";
5
5
  import { F as b } from "./FilterBar-DQRXpWrb.js";
6
6
  function A({ options: n = {} }) {
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import { useState as u, useMemo as p } from "react";
3
- import { u as b } from "./index-CecA4IdQ.js";
3
+ import { u as b } from "./index-Cflz9Ebj.js";
4
4
  import { u as w } from "./useResizableTable-CNJmACdt.js";
5
5
  function C({ options: o, currentPath: n }) {
6
6
  const { data: c, isLoading: h, error: i } = b("routes", o), [r, m] = u(""), l = p(() => {
@@ -0,0 +1,220 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { useState as g, useMemo as F, useEffect as M, useCallback as E, useRef as v } from "react";
3
+ import { formatDuration as w, durationSeverity as T, timeAgo as U, formatTime as W, initSplitPane as _ } from "adonisjs-server-stats/core";
4
+ import { u as z } from "./useApiClient-BVtNCmnL.js";
5
+ import { u as G } from "./index-Cflz9Ebj.js";
6
+ import { u as V } from "./useResizableTable-CNJmACdt.js";
7
+ import { R as H } from "./RelatedLogs-DFDOyUMr.js";
8
+ function J({
9
+ children: o,
10
+ classPrefix: i = "ss-dbg",
11
+ storageKey: u
12
+ }) {
13
+ const h = v(null), d = v(null), m = v(null), c = v(null);
14
+ return M(() => {
15
+ if (h.current && d.current && m.current && c.current)
16
+ return _({
17
+ container: h.current,
18
+ handle: d.current,
19
+ topPane: m.current,
20
+ bottomPane: c.current,
21
+ storageKey: u
22
+ });
23
+ }, [u]), /* @__PURE__ */ t("div", { ref: h, className: `${i}-split-container`, children: [
24
+ /* @__PURE__ */ e("div", { ref: m, className: `${i}-split-top`, children: o[0] }),
25
+ /* @__PURE__ */ e("div", { ref: d, className: `${i}-split-handle` }),
26
+ /* @__PURE__ */ e("div", { ref: c, className: `${i}-split-bottom`, children: o[1] })
27
+ ] });
28
+ }
29
+ const k = {
30
+ request: "#1e3a5f",
31
+ middleware: "rgba(30, 58, 95, 0.7)",
32
+ db: "#6d28d9",
33
+ view: "#0e7490",
34
+ mail: "#059669",
35
+ event: "#b45309",
36
+ custom: "#525252"
37
+ }, K = [
38
+ { label: "Request", color: "#1e3a5f" },
39
+ { label: "Middleware", color: "rgba(30, 58, 95, 0.7)" },
40
+ { label: "Database", color: "#6d28d9" },
41
+ { label: "View", color: "#0e7490" },
42
+ { label: "Mail", color: "#059669" },
43
+ { label: "Event", color: "#b45309" }
44
+ ];
45
+ function le({ options: o }) {
46
+ const { baseUrl: i = "", debugEndpoint: u = "/admin/api/debug", authToken: h } = o || {}, { data: d, isLoading: m, error: c } = G("timeline", o), [b, A] = g(""), [p, y] = g(null), [a, L] = g(null), [q, C] = g(!1), [D, x] = g(null), f = F(() => {
47
+ const s = d?.traces || [];
48
+ if (!b) return s;
49
+ const n = b.toLowerCase();
50
+ return s.filter(
51
+ (r) => r.url.toLowerCase().includes(n) || r.method.toLowerCase().includes(n) || String(r.statusCode).includes(n)
52
+ );
53
+ }, [d, b]), $ = z(i, h);
54
+ M(() => {
55
+ if (p === null) {
56
+ L(null), x(null);
57
+ return;
58
+ }
59
+ let s = !1;
60
+ return C(!0), x(null), $().get(`${u}/traces/${p}`).then((r) => {
61
+ s || (L(r), C(!1));
62
+ }).catch((r) => {
63
+ s || (x(r instanceof Error ? r.message : "Failed to load trace"), C(!1));
64
+ }), () => {
65
+ s = !0;
66
+ };
67
+ }, [p, u, $]);
68
+ const B = E((s) => {
69
+ y((n) => n === s ? null : s);
70
+ }, []), R = E((s) => s >= 500 ? "ss-dbg-status-5xx" : s >= 400 ? "ss-dbg-status-4xx" : s >= 300 ? "ss-dbg-status-3xx" : "ss-dbg-status-2xx", []), I = V([f]);
71
+ if (m && !d)
72
+ return /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Loading traces..." });
73
+ if (c)
74
+ return /* @__PURE__ */ t("div", { className: "ss-dbg-empty", children: [
75
+ "Error: ",
76
+ c.message
77
+ ] });
78
+ if (p !== null) {
79
+ if (q)
80
+ return /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Loading trace detail..." });
81
+ if (D)
82
+ return /* @__PURE__ */ t("div", { children: [
83
+ /* @__PURE__ */ e("div", { className: "ss-dbg-tl-detail-header", children: /* @__PURE__ */ e(
84
+ "button",
85
+ {
86
+ type: "button",
87
+ className: "ss-dbg-btn-clear",
88
+ onClick: () => y(null),
89
+ children: "← Back"
90
+ }
91
+ ) }),
92
+ /* @__PURE__ */ t("div", { className: "ss-dbg-empty", children: [
93
+ "Error: ",
94
+ D
95
+ ] })
96
+ ] });
97
+ if (!a)
98
+ return /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Loading trace detail..." });
99
+ const s = a.spans || [], n = a.warnings || [], r = a.logs || [], O = r.length > 0, S = /* @__PURE__ */ t("div", { children: [
100
+ /* @__PURE__ */ e("div", { className: "ss-dbg-tl-legend", children: K.map((l) => /* @__PURE__ */ t("div", { className: "ss-dbg-tl-legend-item", children: [
101
+ /* @__PURE__ */ e("div", { className: "ss-dbg-tl-legend-dot", style: { background: l.color } }),
102
+ /* @__PURE__ */ e("span", { children: l.label })
103
+ ] }, l.label)) }),
104
+ /* @__PURE__ */ e("div", { style: { padding: "8px 12px", overflow: "auto" }, children: s.length === 0 ? /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "No spans captured for this request" }) : s.map((l) => {
105
+ const N = a.totalDuration || 1, P = l.startOffset / N * 100, j = Math.max(l.duration / N * 100, 0.5);
106
+ return /* @__PURE__ */ t("div", { className: "ss-dbg-tl-row", children: [
107
+ /* @__PURE__ */ e("div", { className: "ss-dbg-tl-label", title: l.label, children: l.label }),
108
+ /* @__PURE__ */ e("div", { className: "ss-dbg-tl-track", children: /* @__PURE__ */ e(
109
+ "div",
110
+ {
111
+ className: `ss-dbg-tl-bar ss-dbg-tl-bar-${l.category}`,
112
+ style: {
113
+ left: `${P}%`,
114
+ width: `${j}%`,
115
+ background: k[l.category] || k.custom
116
+ },
117
+ title: `${l.label}: ${w(l.duration)}`
118
+ }
119
+ ) }),
120
+ /* @__PURE__ */ e("span", { className: "ss-dbg-tl-dur", children: w(l.duration) })
121
+ ] }, l.id);
122
+ }) }),
123
+ n.length > 0 && /* @__PURE__ */ t("div", { className: "ss-dbg-tl-warnings", children: [
124
+ /* @__PURE__ */ e("div", { className: "ss-dbg-tl-warnings-title", children: "Warnings" }),
125
+ n.map((l, N) => /* @__PURE__ */ e("div", { className: "ss-dbg-tl-warning", children: l }, N))
126
+ ] })
127
+ ] });
128
+ return /* @__PURE__ */ t("div", { className: "ss-dbg-tl-detail-wrapper", children: [
129
+ /* @__PURE__ */ t("div", { className: "ss-dbg-tl-detail-header", children: [
130
+ /* @__PURE__ */ e(
131
+ "button",
132
+ {
133
+ type: "button",
134
+ className: "ss-dbg-btn-clear",
135
+ onClick: () => y(null),
136
+ children: "← Back"
137
+ }
138
+ ),
139
+ /* @__PURE__ */ e("span", { className: `ss-dbg-method ss-dbg-method-${a.method.toLowerCase()}`, children: a.method }),
140
+ /* @__PURE__ */ e("span", { className: "ss-dbg-tl-detail-url", children: a.url }),
141
+ /* @__PURE__ */ e("span", { className: `ss-dbg-status ${R(a.statusCode)}`, children: a.statusCode }),
142
+ /* @__PURE__ */ t("span", { className: "ss-dbg-tl-meta", children: [
143
+ w(a.totalDuration),
144
+ " · ",
145
+ a.spanCount,
146
+ " spans"
147
+ ] })
148
+ ] }),
149
+ O ? /* @__PURE__ */ t(J, { classPrefix: "ss-dbg", storageKey: "ss-dbg-timeline-split", children: [
150
+ S,
151
+ /* @__PURE__ */ e(H, { logs: r, classPrefix: "ss-dbg" })
152
+ ] }) : S
153
+ ] });
154
+ }
155
+ return /* @__PURE__ */ t("div", { children: [
156
+ /* @__PURE__ */ t("div", { className: "ss-dbg-search-bar", children: [
157
+ /* @__PURE__ */ e(
158
+ "input",
159
+ {
160
+ type: "text",
161
+ className: "ss-dbg-search",
162
+ placeholder: "Filter traces...",
163
+ value: b,
164
+ onChange: (s) => A(s.target.value)
165
+ }
166
+ ),
167
+ /* @__PURE__ */ t("span", { className: "ss-dbg-summary", children: [
168
+ f.length,
169
+ " traces"
170
+ ] })
171
+ ] }),
172
+ f.length === 0 ? /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "No traces captured. Enable tracing in config." }) : /* @__PURE__ */ t("table", { ref: I, className: "ss-dbg-table", children: [
173
+ /* @__PURE__ */ t("colgroup", { children: [
174
+ /* @__PURE__ */ e("col", { style: { width: "50px" } }),
175
+ /* @__PURE__ */ e("col", { style: { width: "70px" } }),
176
+ /* @__PURE__ */ e("col", {}),
177
+ /* @__PURE__ */ e("col", { style: { width: "60px" } }),
178
+ /* @__PURE__ */ e("col", { style: { width: "80px" } }),
179
+ /* @__PURE__ */ e("col", { style: { width: "50px" } }),
180
+ /* @__PURE__ */ e("col", { style: { width: "80px" } })
181
+ ] }),
182
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
183
+ /* @__PURE__ */ e("th", { children: "#" }),
184
+ /* @__PURE__ */ e("th", { children: "Method" }),
185
+ /* @__PURE__ */ e("th", { children: "URL" }),
186
+ /* @__PURE__ */ e("th", { children: "Status" }),
187
+ /* @__PURE__ */ e("th", { children: "Duration" }),
188
+ /* @__PURE__ */ e("th", { children: "Spans" }),
189
+ /* @__PURE__ */ e("th", { children: "Time" })
190
+ ] }) }),
191
+ /* @__PURE__ */ e("tbody", { children: f.map((s) => /* @__PURE__ */ t(
192
+ "tr",
193
+ {
194
+ className: "ss-dbg-email-row",
195
+ onClick: () => B(s.id),
196
+ children: [
197
+ /* @__PURE__ */ e("td", { className: "ss-dbg-c-dim", style: { whiteSpace: "nowrap" }, children: s.id }),
198
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `ss-dbg-method ss-dbg-method-${s.method.toLowerCase()}`, children: s.method }) }),
199
+ /* @__PURE__ */ e("td", { title: s.url, children: s.url }),
200
+ /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `ss-dbg-status ${R(s.statusCode)}`, children: s.statusCode }) }),
201
+ /* @__PURE__ */ e(
202
+ "td",
203
+ {
204
+ className: `ss-dbg-duration ${T(s.totalDuration) === "very-slow" ? "ss-dbg-very-slow" : T(s.totalDuration) === "slow" ? "ss-dbg-slow" : ""}`,
205
+ children: w(s.totalDuration)
206
+ }
207
+ ),
208
+ /* @__PURE__ */ e("td", { className: "ss-dbg-c-muted", style: { textAlign: "center" }, children: s.spanCount }),
209
+ /* @__PURE__ */ e("td", { className: "ss-dbg-event-time", title: W(s.timestamp), children: U(s.timestamp) })
210
+ ]
211
+ },
212
+ s.id
213
+ )) })
214
+ ] })
215
+ ] });
216
+ }
217
+ export {
218
+ le as TimelineTab,
219
+ le as default
220
+ };