adonisjs-server-stats 1.11.6 → 1.12.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 (82) hide show
  1. package/README.md +13 -0
  2. package/dist/core/explain-utils.d.ts +77 -0
  3. package/dist/core/index.d.ts +8 -2
  4. package/dist/core/index.js +1089 -877
  5. package/dist/core/queries-columns.d.ts +42 -0
  6. package/dist/core/queries-controller.d.ts +94 -0
  7. package/dist/core/query-utils.d.ts +49 -0
  8. package/dist/core/types-diagnostics.d.ts +2 -0
  9. package/dist/react/{CacheSection-BYN53kYO.js → CacheSection-DZFOiOYH.js} +1 -1
  10. package/dist/react/{CacheTab-DOhuK05d.js → CacheTab-D8js5o69.js} +1 -1
  11. package/dist/react/{ConfigSection-B9EHh4Rp.js → ConfigSection-DoJmvNkF.js} +1 -1
  12. package/dist/react/{ConfigTab-C8kriE2b.js → ConfigTab-CDvljuBF.js} +1 -1
  13. package/dist/react/{CustomPaneTab-CvzQS_Wh.js → CustomPaneTab-Db9eIQ-9.js} +1 -1
  14. package/dist/react/{EmailsSection-BJyFJf7A.js → EmailsSection-D7oxvAjA.js} +1 -1
  15. package/dist/react/{EmailsTab-Ch8jp10B.js → EmailsTab-BITuGTQm.js} +1 -1
  16. package/dist/react/{EventsSection-DJPwHeT8.js → EventsSection-7mDZv70I.js} +1 -1
  17. package/dist/react/{EventsTab-B-FoehXC.js → EventsTab-DF13BChE.js} +1 -1
  18. package/dist/react/InternalsContent-BNOnSoi9.js +393 -0
  19. package/dist/react/{InternalsSection-B6VlVx5f.js → InternalsSection-BwrTfpjA.js} +1 -1
  20. package/dist/react/{InternalsTab-CkEKpRMU.js → InternalsTab--RD-L1dX.js} +1 -1
  21. package/dist/react/{JobsSection-DWF4i1t_.js → JobsSection-B_VJFWy6.js} +1 -1
  22. package/dist/react/{JobsTab-DqnifQXV.js → JobsTab-DK8Fl9nz.js} +1 -1
  23. package/dist/react/{LogEntryRow-CMMkqA9M.js → LogEntryRow-Bdie9SFe.js} +1 -1
  24. package/dist/react/{LogsSection-C1xC5aP4.js → LogsSection-CrWqxWRr.js} +2 -2
  25. package/dist/react/{LogsTab-CS4sLfLw.js → LogsTab-DYSpL637.js} +2 -2
  26. package/dist/react/{OverviewSection-CxvfOR0v.js → OverviewSection-CuaccMZt.js} +1 -1
  27. package/dist/react/QueriesContent-BDIx8zFn.js +288 -0
  28. package/dist/react/QueriesSection-CvGGh5Ij.js +117 -0
  29. package/dist/react/QueriesTab-C7CCwhVc.js +87 -0
  30. package/dist/react/{RequestsSection-DETN9oZb.js → RequestsSection-mENyeNsk.js} +2 -2
  31. package/dist/react/{RoutesSection-CmorkJeC.js → RoutesSection-DjovlaNS.js} +1 -1
  32. package/dist/react/{RoutesTab-CbzBOzpc.js → RoutesTab-CbQECiUc.js} +1 -1
  33. package/dist/react/{SplitPaneWrapper-BiIgT4ND.js → SplitPaneWrapper-DyRyH5Re.js} +1 -1
  34. package/dist/react/{TimelineTab-Ue9tUD_n.js → TimelineTab-BKTFbsPe.js} +2 -2
  35. package/dist/react/components/Dashboard/shared/DataTable.d.ts +1 -1
  36. package/dist/react/components/shared/QueriesContent.d.ts +33 -0
  37. package/dist/react/{index-DwDK-4oX.js → index-CAUHa8QX.js} +2 -2
  38. package/dist/react/index.js +1 -1
  39. package/dist/react/style.css +1 -1
  40. package/dist/src/collectors/db_pool_collector.js +17 -23
  41. package/dist/src/dashboard/query_explain_handler.d.ts +11 -0
  42. package/dist/src/dashboard/query_explain_handler.js +64 -11
  43. package/dist/src/debug/query_collector.d.ts +1 -0
  44. package/dist/src/debug/query_collector.js +3 -0
  45. package/dist/src/edge/client/dashboard.js +2 -2
  46. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  47. package/dist/src/edge/client-vue/dashboard.js +4 -4
  48. package/dist/src/edge/client-vue/debug-panel-deferred.js +2 -2
  49. package/dist/src/provider/diagnostics.d.ts +3 -0
  50. package/dist/src/provider/diagnostics.js +1 -0
  51. package/dist/src/provider/server_stats_provider.d.ts +7 -0
  52. package/dist/src/provider/server_stats_provider.js +38 -0
  53. package/dist/src/routes/debug_routes.d.ts +4 -0
  54. package/dist/src/routes/debug_routes.js +45 -0
  55. package/dist/src/routes/register_routes.d.ts +4 -0
  56. package/dist/src/routes/register_routes.js +2 -0
  57. package/dist/src/styles/components.css +254 -0
  58. package/dist/src/styles/dashboard.css +26 -185
  59. package/dist/src/styles/debug-panel.css +2 -24
  60. package/dist/vue/{CacheSection-DT2Mwf_s.js → CacheSection-Bx41lpfK.js} +1 -1
  61. package/dist/vue/{ConfigSection-BwKwS9lh.js → ConfigSection-fkfUdCmx.js} +1 -1
  62. package/dist/vue/{EmailsSection-B65g0FVS.js → EmailsSection-CbcDKF9Q.js} +1 -1
  63. package/dist/vue/{EventsSection-CxqtVF-o.js → EventsSection-CWbTYOBi.js} +1 -1
  64. package/dist/vue/{InternalsSection-BJUXE-5F.js → InternalsSection-jhTCuK3j.js} +149 -130
  65. package/dist/vue/{InternalsTab-DEMjqtlw.js → InternalsTab-521fxYYj.js} +152 -133
  66. package/dist/vue/{JobsSection-rMIyMb-g.js → JobsSection-CGGO6rtS.js} +1 -1
  67. package/dist/vue/{LogsSection-DmmZVJ7D.js → LogsSection-BPB-C-XA.js} +1 -1
  68. package/dist/vue/{OverviewSection-BMabyqw-.js → OverviewSection-BTcnPeoM.js} +1 -1
  69. package/dist/vue/QueriesSection-2SE3igQJ.js +411 -0
  70. package/dist/vue/QueriesTab-DO5XwJ--.js +112 -0
  71. package/dist/vue/{RequestsSection-CTu4jPZ_.js → RequestsSection-DXcG5Zok.js} +1 -1
  72. package/dist/vue/{RoutesSection-zQZDedL7.js → RoutesSection-BkNGWdoP.js} +1 -1
  73. package/dist/vue/components/Dashboard/sections/QueriesSection.vue.d.ts +1 -41
  74. package/dist/vue/{index-CM3yNVUR.js → index-CptF6Qbp.js} +2 -2
  75. package/dist/vue/index.js +1 -1
  76. package/dist/vue/style.css +1 -1
  77. package/package.json +1 -1
  78. package/dist/react/InternalsContent-O8ino9oM.js +0 -370
  79. package/dist/react/QueriesSection-CrMdU5Ax.js +0 -458
  80. package/dist/react/QueriesTab-x85PjkyS.js +0 -88
  81. package/dist/vue/QueriesSection-BfDFwGqH.js +0 -428
  82. package/dist/vue/QueriesTab-DuTG7cpC.js +0 -106
@@ -1,458 +0,0 @@
1
- import { jsx as t, jsxs as l, Fragment as v } from "react/jsx-runtime";
2
- import { useState as y, useCallback as $, useEffect as X, useMemo as T } from "react";
3
- import { resolveField as b, resolveNormalizedSql as A, durationClassName as R, resolveSqlMethod as Q, resolveTimestamp as Y, SLOW_DURATION_MS as Z } from "adonisjs-server-stats/core";
4
- import { a as ee } from "./index-DwDK-4oX.js";
5
- import { D as U } from "./DataTable-YyShr5B-.js";
6
- import { F as se } from "./FilterBar-CQ7bD669.js";
7
- import { T as te } from "./TimeAgoCell-o3KigGfM.js";
8
- import { P as ae } from "./Pagination-BkmzUDY8.js";
9
- function W({ node: a, depth: d = 0 }) {
10
- if (!a) return null;
11
- const f = d * 20, u = a["Node Type"] || "Unknown", C = a["Relation Name"] ? /* @__PURE__ */ l(v, { children: [
12
- " on ",
13
- /* @__PURE__ */ t("strong", { children: a["Relation Name"] })
14
- ] }) : null, c = a.Alias && a.Alias !== a["Relation Name"] ? ` (${a.Alias})` : "", m = a["Index Name"] ? /* @__PURE__ */ l(v, { children: [
15
- " using ",
16
- /* @__PURE__ */ t("em", { children: a["Index Name"] })
17
- ] }) : null, i = [];
18
- if (a["Startup Cost"] !== null && a["Startup Cost"] !== void 0 && i.push(`cost=${a["Startup Cost"]}..${a["Total Cost"]}`), a["Plan Rows"] !== null && a["Plan Rows"] !== void 0 && i.push(`rows=${a["Plan Rows"]}`), a["Plan Width"] !== null && a["Plan Width"] !== void 0 && i.push(`width=${a["Plan Width"]}`), a.Filter && i.push(`filter: ${a.Filter}`), a["Index Cond"] && i.push(`cond: ${a["Index Cond"]}`), a["Hash Cond"] && i.push(`hash: ${a["Hash Cond"]}`), a["Join Type"] && i.push(`join: ${a["Join Type"]}`), a["Sort Key"]) {
19
- const r = Array.isArray(a["Sort Key"]) ? a["Sort Key"].join(", ") : a["Sort Key"];
20
- i.push(`sort: ${r}`);
21
- }
22
- const q = a.Plans || [];
23
- return /* @__PURE__ */ l("div", { className: "ss-dash-explain-node", style: { marginLeft: `${f}px` }, children: [
24
- /* @__PURE__ */ l("div", { className: "ss-dash-explain-node-header", children: [
25
- /* @__PURE__ */ t("span", { className: "ss-dash-explain-node-type", children: u }),
26
- C,
27
- c,
28
- m
29
- ] }),
30
- i.length > 0 && /* @__PURE__ */ t("div", { className: "ss-dash-explain-metrics", children: i.join(" · ") }),
31
- q.map((r, F) => /* @__PURE__ */ t(W, { node: r, depth: d + 1 }, F))
32
- ] });
33
- }
34
- function ne({ plan: a }) {
35
- if (!a || !Array.isArray(a) || a.length === 0)
36
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: "No plan data returned" });
37
- const d = a[0];
38
- if (d && d.Plan)
39
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: /* @__PURE__ */ t(W, { node: d.Plan, depth: 0 }) });
40
- if (typeof d == "object" && d !== null) {
41
- const f = Object.keys(d);
42
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: /* @__PURE__ */ l("table", { children: [
43
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { children: f.map((u) => /* @__PURE__ */ t("th", { children: u }, u)) }) }),
44
- /* @__PURE__ */ t("tbody", { children: a.map((u, C) => {
45
- const c = u;
46
- return /* @__PURE__ */ t("tr", { children: f.map((m) => /* @__PURE__ */ t("td", { children: c[m] !== null && c[m] !== void 0 ? String(c[m]) : "-" }, m)) }, C);
47
- }) })
48
- ] }) });
49
- }
50
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: "No plan data returned" });
51
- }
52
- const re = 8;
53
- function me({ options: a = {} }) {
54
- const [d, f] = y(1), [u, C] = y(""), [c, m] = y("createdAt"), [i, q] = y("desc"), [r, F] = y("list"), [N, D] = y(null), [o, w] = y(null), [j, _] = y(null), I = $(
55
- (e) => {
56
- e !== r && (F(e), f(1), m(e === "list" ? "createdAt" : "count"), q("desc"), D(null), w(null), _(null));
57
- },
58
- [r]
59
- );
60
- X(() => f(1), [u]);
61
- const H = r === "grouped" ? "queries/grouped" : "queries", { data: M, meta: k, isLoading: J, getApi: O } = ee(H, {
62
- ...a,
63
- page: d,
64
- search: u,
65
- sort: c,
66
- sortDir: i
67
- }), K = $(
68
- (e) => {
69
- c === e ? q((s) => s === "asc" ? "desc" : "asc") : (m(e), q("desc"));
70
- },
71
- [c]
72
- ), V = $(
73
- async (e) => {
74
- if (o && o.queryId === e) {
75
- w(null);
76
- return;
77
- }
78
- _(e);
79
- try {
80
- const s = await O().explainQuery(e);
81
- s && s.error ? w({
82
- queryId: e,
83
- plan: [],
84
- error: s.error,
85
- message: s.message
86
- }) : w({
87
- queryId: e,
88
- plan: s?.plan || s?.rows || []
89
- });
90
- } catch (s) {
91
- console.warn("[ss] Query explain failed:", s), w({
92
- queryId: e,
93
- plan: [],
94
- error: s instanceof Error ? s.message : String(s)
95
- });
96
- } finally {
97
- _(null);
98
- }
99
- },
100
- [O, o]
101
- ), B = $(
102
- (e) => {
103
- const s = e.id;
104
- return !o || o.queryId !== s ? null : /* @__PURE__ */ t("tr", { className: "ss-dash-explain-row", children: /* @__PURE__ */ t("td", { colSpan: re, className: "ss-dash-explain", children: /* @__PURE__ */ l("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "start" }, children: [
105
- /* @__PURE__ */ t("div", { style: { flex: 1 }, children: o.error ? /* @__PURE__ */ l("div", { className: "ss-dash-explain-result ss-dash-explain-error", children: [
106
- /* @__PURE__ */ t("strong", { children: "Error:" }),
107
- " ",
108
- o.error,
109
- o.message && /* @__PURE__ */ l(v, { children: [
110
- /* @__PURE__ */ t("br", {}),
111
- o.message
112
- ] })
113
- ] }) : /* @__PURE__ */ t(ne, { plan: o.plan }) }),
114
- /* @__PURE__ */ t(
115
- "button",
116
- {
117
- type: "button",
118
- className: "ss-dash-explain-btn",
119
- onClick: () => w(null),
120
- style: { marginLeft: "8px", flexShrink: 0 },
121
- children: "Close"
122
- }
123
- )
124
- ] }) }) });
125
- },
126
- [o]
127
- ), E = r === "grouped" ? M?.groups || [] : M || [], p = T(() => r !== "grouped" ? E : E.map((e) => {
128
- const s = { ...e };
129
- return s.sqlNormalized ??= b(e, "sql_normalized", "pattern") ?? void 0, s.count ??= b(e, "total_count"), s.avgDuration ??= b(e, "avg_duration"), s.maxDuration ??= b(e, "max_duration"), s.minDuration ??= b(e, "min_duration"), s.totalDuration ??= b(e, "total_duration"), s.percentOfTotal ??= b(e, "pct_time"), s;
130
- }), [E, r]), g = T(() => {
131
- const e = k?.total ?? p.length;
132
- let s = 0, n = 0, h = 0, x = 0;
133
- for (const S of p) {
134
- const P = S.duration || 0;
135
- h += P, x++, P > Z && s++;
136
- }
137
- const L = /* @__PURE__ */ new Map();
138
- for (const S of p) {
139
- const P = A(S);
140
- L.set(P, (L.get(P) || 0) + 1);
141
- }
142
- for (const S of L.values())
143
- S > 1 && (n += S);
144
- return {
145
- total: e,
146
- slow: s,
147
- duplicates: n,
148
- avgDuration: x > 0 ? h / x : 0
149
- };
150
- }, [p, k]), z = T(() => {
151
- const e = /* @__PURE__ */ new Map();
152
- for (const s of p) {
153
- const n = A(s);
154
- e.set(n, (e.get(n) || 0) + 1);
155
- }
156
- return e;
157
- }, [p]), G = T(() => {
158
- if (r === "grouped")
159
- return `${p.length} query patterns`;
160
- const e = [`${g.total} queries`];
161
- return g.slow > 0 && e.push(`${g.slow} slow`), g.duplicates > 0 && e.push(`${g.duplicates} dup`), e.push(`avg ${(g.avgDuration || 0).toFixed(1)}ms`), e.join(", ");
162
- }, [r, p.length, g]);
163
- return /* @__PURE__ */ l("div", { children: [
164
- /* @__PURE__ */ t(
165
- se,
166
- {
167
- search: u,
168
- onSearchChange: C,
169
- placeholder: "Filter queries...",
170
- summary: G,
171
- children: /* @__PURE__ */ l("div", { className: "ss-dash-btn-group", children: [
172
- /* @__PURE__ */ t(
173
- "button",
174
- {
175
- type: "button",
176
- className: `ss-dash-btn ${r === "list" ? "ss-dash-active" : ""}`,
177
- onClick: () => I("list"),
178
- children: "List"
179
- }
180
- ),
181
- /* @__PURE__ */ t(
182
- "button",
183
- {
184
- type: "button",
185
- className: `ss-dash-btn ${r === "grouped" ? "ss-dash-active" : ""}`,
186
- onClick: () => I("grouped"),
187
- children: "Grouped"
188
- }
189
- )
190
- ] })
191
- }
192
- ),
193
- J && !M ? /* @__PURE__ */ t("div", { className: "ss-dash-empty", children: "Loading queries..." }) : r === "grouped" ? /* @__PURE__ */ t(v, { children: /* @__PURE__ */ t("div", { className: "ss-dash-table-wrap", children: /* @__PURE__ */ t(
194
- U,
195
- {
196
- columns: [
197
- {
198
- key: "sqlNormalized",
199
- label: "Pattern",
200
- render: (e, s) => {
201
- const n = e || "", h = (s.count || 0) >= 3;
202
- return /* @__PURE__ */ l(v, { children: [
203
- /* @__PURE__ */ t(
204
- "span",
205
- {
206
- className: `ss-dash-sql ${N === n ? "ss-dash-expanded" : ""}`,
207
- title: "Click to expand",
208
- onClick: (x) => {
209
- x.stopPropagation(), D(N === n ? null : n);
210
- },
211
- role: "button",
212
- tabIndex: 0,
213
- onKeyDown: (x) => x.key === "Enter" && D(N === n ? null : n),
214
- children: n
215
- }
216
- ),
217
- h && /* @__PURE__ */ l(v, { children: [
218
- " ",
219
- /* @__PURE__ */ t("span", { className: "ss-dash-dup", children: "DUP" })
220
- ] })
221
- ] });
222
- }
223
- },
224
- {
225
- key: "count",
226
- label: "Count",
227
- width: "60px",
228
- sortable: !0,
229
- render: (e) => /* @__PURE__ */ t(
230
- "span",
231
- {
232
- style: { color: "var(--ss-muted)", textAlign: "center", display: "block" },
233
- children: e || 0
234
- }
235
- )
236
- },
237
- {
238
- key: "avgDuration",
239
- label: "Avg",
240
- width: "70px",
241
- sortable: !0,
242
- render: (e) => {
243
- const s = e || 0;
244
- return /* @__PURE__ */ t(
245
- "span",
246
- {
247
- className: `ss-dash-duration ${R(s)}`,
248
- children: s.toFixed(2) + "ms"
249
- }
250
- );
251
- }
252
- },
253
- {
254
- key: "minDuration",
255
- label: "Min",
256
- width: "70px",
257
- render: (e) => /* @__PURE__ */ t("span", { className: "ss-dash-duration", children: (e || 0).toFixed(2) + "ms" })
258
- },
259
- {
260
- key: "maxDuration",
261
- label: "Max",
262
- width: "70px",
263
- render: (e) => {
264
- const s = e || 0;
265
- return /* @__PURE__ */ t(
266
- "span",
267
- {
268
- className: `ss-dash-duration ${R(s)}`,
269
- children: s.toFixed(2) + "ms"
270
- }
271
- );
272
- }
273
- },
274
- {
275
- key: "totalDuration",
276
- label: "Total",
277
- width: "70px",
278
- sortable: !0,
279
- render: (e) => /* @__PURE__ */ t("span", { className: "ss-dash-duration", children: (e || 0).toFixed(1) + "ms" })
280
- },
281
- {
282
- key: "percentOfTotal",
283
- label: "% Time",
284
- width: "60px",
285
- render: (e) => /* @__PURE__ */ t(
286
- "span",
287
- {
288
- style: { color: "var(--ss-muted)", textAlign: "center", display: "block" },
289
- children: (e || 0).toFixed(1) + "%"
290
- }
291
- )
292
- }
293
- ],
294
- data: p,
295
- keyField: "sqlNormalized",
296
- sort: c,
297
- sortDir: i,
298
- onSort: K,
299
- emptyMessage: "No queries recorded"
300
- }
301
- ) }) }) : /* @__PURE__ */ l(v, { children: [
302
- /* @__PURE__ */ t("div", { className: "ss-dash-table-wrap", children: /* @__PURE__ */ t(
303
- U,
304
- {
305
- columns: [
306
- {
307
- key: "id",
308
- label: "#",
309
- width: "40px",
310
- render: (e) => /* @__PURE__ */ t("span", { style: { color: "var(--ss-dim)" }, children: e })
311
- },
312
- {
313
- key: "sql",
314
- label: "SQL",
315
- render: (e, s) => {
316
- const n = s.sql || s.sql_text || "";
317
- return /* @__PURE__ */ l("div", { children: [
318
- /* @__PURE__ */ t(
319
- "span",
320
- {
321
- className: `ss-dash-sql ${N === s.id ? "ss-dash-expanded" : ""}`,
322
- title: "Click to expand",
323
- onClick: (h) => {
324
- h.stopPropagation(), D(
325
- N === s.id ? null : s.id
326
- );
327
- },
328
- role: "button",
329
- tabIndex: 0,
330
- onKeyDown: (h) => h.key === "Enter" && D(
331
- N === s.id ? null : s.id
332
- ),
333
- children: n
334
- }
335
- ),
336
- (z.get(A(s)) ?? 0) > 1 && /* @__PURE__ */ l("span", { className: "ss-dash-dup", children: [
337
- "×",
338
- z.get(A(s))
339
- ] })
340
- ] });
341
- }
342
- },
343
- {
344
- key: "duration",
345
- label: "Duration",
346
- width: "70px",
347
- sortable: !0,
348
- render: (e) => {
349
- const s = e || 0;
350
- return /* @__PURE__ */ t(
351
- "span",
352
- {
353
- className: `ss-dash-duration ${R(s)}`,
354
- children: s.toFixed(2) + "ms"
355
- }
356
- );
357
- }
358
- },
359
- {
360
- key: "method",
361
- label: "Method",
362
- width: "60px",
363
- render: (e, s) => {
364
- const n = Q(s);
365
- return /* @__PURE__ */ t("span", { className: `ss-dash-method ss-dash-method-${n.toLowerCase()}`, children: n });
366
- }
367
- },
368
- {
369
- key: "model",
370
- label: "Model",
371
- width: "90px",
372
- render: (e) => /* @__PURE__ */ t(
373
- "span",
374
- {
375
- style: {
376
- color: "var(--ss-muted)",
377
- overflow: "hidden",
378
- textOverflow: "ellipsis",
379
- whiteSpace: "nowrap"
380
- },
381
- title: e,
382
- children: e || "-"
383
- }
384
- )
385
- },
386
- {
387
- key: "connection",
388
- label: "Connection",
389
- width: "80px",
390
- render: (e) => /* @__PURE__ */ t(
391
- "span",
392
- {
393
- style: {
394
- color: "var(--ss-dim)",
395
- overflow: "hidden",
396
- textOverflow: "ellipsis",
397
- whiteSpace: "nowrap"
398
- },
399
- children: e || "-"
400
- }
401
- )
402
- },
403
- {
404
- key: "createdAt",
405
- label: "Time",
406
- width: "90px",
407
- sortable: !0,
408
- render: (e, s) => {
409
- const n = e || (Y(s) ?? "");
410
- return /* @__PURE__ */ t(te, { ts: n, className: "ss-dash-event-time" });
411
- }
412
- },
413
- {
414
- key: "id",
415
- label: "",
416
- width: "70px",
417
- render: (e, s) => {
418
- if (Q(s) !== "select") return null;
419
- const h = o?.queryId === s.id && !o?.error;
420
- return /* @__PURE__ */ t(
421
- "button",
422
- {
423
- type: "button",
424
- className: `ss-dash-explain-btn${h ? " ss-dash-explain-btn-active" : ""}`,
425
- onClick: (x) => {
426
- x.stopPropagation(), V(s.id);
427
- },
428
- disabled: j === s.id,
429
- children: j === s.id ? "..." : "EXPLAIN"
430
- }
431
- );
432
- }
433
- }
434
- ],
435
- data: p,
436
- sort: c,
437
- sortDir: i,
438
- onSort: K,
439
- emptyMessage: "No queries recorded",
440
- renderAfterRow: B
441
- }
442
- ) }),
443
- k && /* @__PURE__ */ t(
444
- ae,
445
- {
446
- page: k.page,
447
- lastPage: k.lastPage,
448
- total: k.total,
449
- onPageChange: f
450
- }
451
- )
452
- ] })
453
- ] });
454
- }
455
- export {
456
- me as QueriesSection,
457
- me as default
458
- };
@@ -1,88 +0,0 @@
1
- import { jsx as e, jsxs as t, Fragment as w } from "react/jsx-runtime";
2
- import { useState as m, useMemo as i, useCallback as C } from "react";
3
- import { filterQueries as v, countDuplicateQueries as D, computeQuerySummary as S, formatDuration as p, durationClassName as T } from "adonisjs-server-stats/core";
4
- import { T as Q } from "./TimeAgoCell-o3KigGfM.js";
5
- import { u as M, M as $ } from "./index-DwDK-4oX.js";
6
- import { u as E } from "./useResizableTable-CNJmACdt.js";
7
- import { F } from "./FilterBar-CQ7bD669.js";
8
- function A({ options: g }) {
9
- const { data: n, isLoading: b, error: u } = M("queries", g), [o, f] = m(""), [y, x] = m(null), d = i(() => n?.queries || [], [n]), r = i(() => v(d, o), [d, o]), a = i(() => D(d), [d]), l = i(
10
- () => S(d, a),
11
- [d, a]
12
- ), h = C((s) => {
13
- x((c) => c === s ? null : s);
14
- }, []), N = E([r]);
15
- return b && !n ? /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "Loading queries..." }) : u ? /* @__PURE__ */ t("div", { className: "ss-dbg-empty", children: [
16
- "Error: ",
17
- u.message
18
- ] }) : /* @__PURE__ */ t("div", { children: [
19
- /* @__PURE__ */ e(
20
- F,
21
- {
22
- search: o,
23
- onSearchChange: f,
24
- placeholder: "Filter queries...",
25
- summary: /* @__PURE__ */ t(w, { children: [
26
- r.length,
27
- " queries",
28
- l.slowCount > 0 && ` | ${l.slowCount} slow`,
29
- l.dupCount > 0 && ` | ${l.dupCount} dup`,
30
- r.length > 0 && ` | avg ${p(l.avgDuration)}`
31
- ] })
32
- }
33
- ),
34
- r.length === 0 ? /* @__PURE__ */ e("div", { className: "ss-dbg-empty", children: "No queries captured" }) : /* @__PURE__ */ t("table", { ref: N, className: "ss-dbg-table", children: [
35
- /* @__PURE__ */ t("colgroup", { children: [
36
- /* @__PURE__ */ e("col", { style: { width: "50px" } }),
37
- /* @__PURE__ */ e("col", {}),
38
- /* @__PURE__ */ e("col", { style: { width: "80px" } }),
39
- /* @__PURE__ */ e("col", { style: { width: "70px" } }),
40
- /* @__PURE__ */ e("col", { style: { width: "100px" } }),
41
- /* @__PURE__ */ e("col", { style: { width: "80px" } })
42
- ] }),
43
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
44
- /* @__PURE__ */ e("th", { children: "#" }),
45
- /* @__PURE__ */ e("th", { children: "SQL" }),
46
- /* @__PURE__ */ e("th", { children: "Duration" }),
47
- /* @__PURE__ */ e("th", { children: "Method" }),
48
- /* @__PURE__ */ e("th", { children: "Model" }),
49
- /* @__PURE__ */ e("th", { children: "Time" })
50
- ] }) }),
51
- /* @__PURE__ */ e("tbody", { children: r.map((s) => /* @__PURE__ */ t("tr", { children: [
52
- /* @__PURE__ */ e("td", { className: "ss-dbg-c-dim", style: { whiteSpace: "nowrap" }, children: s.id }),
53
- /* @__PURE__ */ t("td", { children: [
54
- /* @__PURE__ */ e(
55
- "span",
56
- {
57
- className: `ss-dbg-sql ${y === s.id ? "ss-dbg-expanded" : ""}`,
58
- onClick: () => h(s.id),
59
- role: "button",
60
- tabIndex: 0,
61
- onKeyDown: (c) => c.key === "Enter" && h(s.id),
62
- children: s.sql
63
- }
64
- ),
65
- a[s.sql] > 1 && /* @__PURE__ */ t("span", { className: "ss-dbg-dup", children: [
66
- " x",
67
- a[s.sql]
68
- ] }),
69
- s.inTransaction && /* @__PURE__ */ e("span", { className: "ss-dbg-dup", children: " TXN" })
70
- ] }),
71
- /* @__PURE__ */ e(
72
- "td",
73
- {
74
- className: `ss-dbg-duration ${T(s.duration, "ss-dbg")}`,
75
- children: p(s.duration)
76
- }
77
- ),
78
- /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e($, { method: s.method, classPrefix: "ss-dbg" }) }),
79
- /* @__PURE__ */ e("td", { className: "ss-dbg-c-muted", children: s.model || "-" }),
80
- /* @__PURE__ */ e("td", { children: /* @__PURE__ */ e(Q, { ts: s.timestamp, className: "ss-dbg-event-time" }) })
81
- ] }, s.id)) })
82
- ] })
83
- ] });
84
- }
85
- export {
86
- A as QueriesTab,
87
- A as default
88
- };