adonisjs-server-stats 1.10.0 → 1.11.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 (248) hide show
  1. package/README.md +23 -14
  2. package/dist/core/config-utils.d.ts +8 -0
  3. package/dist/core/constants.d.ts +4 -0
  4. package/dist/core/dashboard-data-controller.d.ts +16 -0
  5. package/dist/core/dashboard-data-helpers.d.ts +12 -0
  6. package/dist/core/debug-data-controller.d.ts +4 -0
  7. package/dist/core/define-config-helpers.d.ts +25 -0
  8. package/dist/core/feature-detect-helpers.d.ts +36 -0
  9. package/dist/core/field-resolvers.d.ts +64 -0
  10. package/dist/core/formatters-helpers.d.ts +23 -0
  11. package/dist/core/formatters.d.ts +15 -0
  12. package/dist/core/index.d.ts +1 -1
  13. package/dist/core/index.js +599 -509
  14. package/dist/core/log-utils-helpers.d.ts +13 -0
  15. package/dist/core/metrics.d.ts +3 -28
  16. package/dist/core/pagination.d.ts +0 -9
  17. package/dist/core/server-stats-controller.d.ts +6 -0
  18. package/dist/core/transmit-helpers.d.ts +7 -0
  19. package/dist/core/types-dashboard.d.ts +178 -0
  20. package/dist/core/types-diagnostics.d.ts +85 -0
  21. package/dist/core/types.d.ts +10 -442
  22. package/dist/react/CacheSection-BYN53kYO.js +135 -0
  23. package/dist/react/CacheStatsBar-CRodCOeP.js +27 -0
  24. package/dist/react/CacheTab-DOhuK05d.js +106 -0
  25. package/dist/react/{ConfigSection-DfFd-WRq.js → ConfigSection-B9EHh4Rp.js} +1 -1
  26. package/dist/react/{ConfigTab-Bdg8YMer.js → ConfigTab-C8kriE2b.js} +1 -1
  27. package/dist/react/CustomPaneTab-CvzQS_Wh.js +99 -0
  28. package/dist/react/EmailPreviewOverlay-BmXOAvqG.js +58 -0
  29. package/dist/react/EmailsSection-BJyFJf7A.js +226 -0
  30. package/dist/react/EmailsTab-Ch8jp10B.js +110 -0
  31. package/dist/react/{EventsSection-ByQ-9blq.js → EventsSection-DJPwHeT8.js} +28 -27
  32. package/dist/react/EventsTab-B-FoehXC.js +58 -0
  33. package/dist/react/{FilterBar-DQRXpWrb.js → FilterBar-CQ7bD669.js} +15 -15
  34. package/dist/react/{InternalsContent-DBzsI0CG.js → InternalsContent-O8ino9oM.js} +133 -109
  35. package/dist/react/InternalsSection-B6VlVx5f.js +22 -0
  36. package/dist/react/InternalsTab-CkEKpRMU.js +17 -0
  37. package/dist/react/JobStatsBar-C7RslAFE.js +30 -0
  38. package/dist/react/JobsSection-DWF4i1t_.js +167 -0
  39. package/dist/react/JobsTab-DqnifQXV.js +129 -0
  40. package/dist/react/LogEntryRow-CMMkqA9M.js +43 -0
  41. package/dist/react/LogsSection-C1xC5aP4.js +198 -0
  42. package/dist/react/LogsTab-CS4sLfLw.js +79 -0
  43. package/dist/react/{OverviewSection-C4T1ur51.js → OverviewSection-CxvfOR0v.js} +70 -80
  44. package/dist/react/QueriesSection-CrMdU5Ax.js +458 -0
  45. package/dist/react/{QueriesTab-osLUWd4L.js → QueriesTab-x85PjkyS.js} +38 -40
  46. package/dist/react/RequestsSection-DETN9oZb.js +321 -0
  47. package/dist/react/{RoutesSection-BUSkM6PY.js → RoutesSection-CmorkJeC.js} +2 -2
  48. package/dist/react/RoutesTab-CbzBOzpc.js +68 -0
  49. package/dist/react/SplitPaneWrapper-BiIgT4ND.js +49 -0
  50. package/dist/react/TimeAgoCell-o3KigGfM.js +8 -0
  51. package/dist/react/{TimelineTab-Covg5weo.js → TimelineTab-Ue9tUD_n.js} +76 -102
  52. package/dist/react/index-DwDK-4oX.js +1121 -0
  53. package/dist/react/index.js +6 -6
  54. package/dist/react/react/components/shared/CacheStatsBar.d.ts +13 -0
  55. package/dist/react/react/components/shared/EmailPreviewOverlay.d.ts +29 -0
  56. package/dist/react/react/components/{Dashboard/shared → shared}/FilterBar.d.ts +4 -3
  57. package/dist/react/react/components/shared/JobStatsBar.d.ts +12 -0
  58. package/dist/react/react/components/shared/LogEntryRow.d.ts +9 -0
  59. package/dist/react/react/components/shared/RelatedLogs.d.ts +2 -2
  60. package/dist/react/react/components/shared/SplitPaneWrapper.d.ts +7 -0
  61. package/dist/react/react/components/shared/TimeAgoCell.d.ts +17 -0
  62. package/dist/react/react/hooks/useDashboardData.d.ts +4 -8
  63. package/dist/react/react/hooks/useDiagnosticsData.d.ts +14 -0
  64. package/dist/react/style.css +1 -1
  65. package/dist/src/collectors/app_collector.d.ts +0 -8
  66. package/dist/src/collectors/app_collector.js +45 -52
  67. package/dist/src/collectors/auto_detect.d.ts +0 -23
  68. package/dist/src/collectors/auto_detect.js +33 -55
  69. package/dist/src/collectors/db_pool_collector.d.ts +14 -16
  70. package/dist/src/collectors/db_pool_collector.js +72 -57
  71. package/dist/src/collectors/log_collector.d.ts +0 -47
  72. package/dist/src/collectors/log_collector.js +36 -65
  73. package/dist/src/collectors/queue_collector.d.ts +0 -20
  74. package/dist/src/collectors/queue_collector.js +60 -76
  75. package/dist/src/collectors/redis_collector.d.ts +10 -10
  76. package/dist/src/collectors/redis_collector.js +69 -66
  77. package/dist/src/config/deprecation_migration.d.ts +7 -0
  78. package/dist/src/config/deprecation_migration.js +201 -0
  79. package/dist/src/controller/debug_controller.d.ts +1 -1
  80. package/dist/src/controller/debug_controller.js +87 -81
  81. package/dist/src/dashboard/cache_handlers.d.ts +14 -0
  82. package/dist/src/dashboard/cache_handlers.js +52 -0
  83. package/dist/src/dashboard/chart_aggregator.d.ts +0 -7
  84. package/dist/src/dashboard/chart_aggregator.js +68 -50
  85. package/dist/src/dashboard/coalesce_cache.d.ts +25 -0
  86. package/dist/src/dashboard/coalesce_cache.js +47 -0
  87. package/dist/src/dashboard/dashboard_controller.d.ts +11 -37
  88. package/dist/src/dashboard/dashboard_controller.js +51 -544
  89. package/dist/src/dashboard/dashboard_page_assets.d.ts +17 -0
  90. package/dist/src/dashboard/dashboard_page_assets.js +51 -0
  91. package/dist/src/dashboard/dashboard_store.d.ts +19 -218
  92. package/dist/src/dashboard/dashboard_store.js +115 -1116
  93. package/dist/src/dashboard/dashboard_types.d.ts +83 -0
  94. package/dist/src/dashboard/dashboard_types.js +4 -0
  95. package/dist/src/dashboard/detail_queries.d.ts +19 -0
  96. package/dist/src/dashboard/detail_queries.js +98 -0
  97. package/dist/src/dashboard/email_event_builder.d.ts +8 -0
  98. package/dist/src/dashboard/email_event_builder.js +65 -0
  99. package/dist/src/dashboard/explain_query.d.ts +8 -0
  100. package/dist/src/dashboard/explain_query.js +22 -0
  101. package/dist/src/dashboard/filter_handlers.d.ts +23 -0
  102. package/dist/src/dashboard/filter_handlers.js +56 -0
  103. package/dist/src/dashboard/filtered_queries.d.ts +15 -0
  104. package/dist/src/dashboard/filtered_queries.js +155 -0
  105. package/dist/src/dashboard/flush_manager.d.ts +25 -0
  106. package/dist/src/dashboard/flush_manager.js +107 -0
  107. package/dist/src/dashboard/format_helpers.d.ts +126 -0
  108. package/dist/src/dashboard/format_helpers.js +140 -0
  109. package/dist/src/dashboard/inspector_manager.d.ts +36 -0
  110. package/dist/src/dashboard/inspector_manager.js +102 -0
  111. package/dist/src/dashboard/integrations/config_inspector.js +11 -13
  112. package/dist/src/dashboard/integrations/queue_inspector.d.ts +3 -3
  113. package/dist/src/dashboard/integrations/queue_inspector.js +13 -10
  114. package/dist/src/dashboard/jobs_handlers.d.ts +14 -0
  115. package/dist/src/dashboard/jobs_handlers.js +61 -0
  116. package/dist/src/dashboard/knex_factory.d.ts +18 -0
  117. package/dist/src/dashboard/knex_factory.js +91 -0
  118. package/dist/src/dashboard/migrator.js +30 -159
  119. package/dist/src/dashboard/migrator_tables.d.ts +19 -0
  120. package/dist/src/dashboard/migrator_tables.js +153 -0
  121. package/dist/src/dashboard/overview_queries.d.ts +66 -0
  122. package/dist/src/dashboard/overview_queries.js +155 -0
  123. package/dist/src/dashboard/overview_query_runners.d.ts +25 -0
  124. package/dist/src/dashboard/overview_query_runners.js +84 -0
  125. package/dist/src/dashboard/overview_store_queries.d.ts +40 -0
  126. package/dist/src/dashboard/overview_store_queries.js +69 -0
  127. package/dist/src/dashboard/paginate_helper.d.ts +12 -0
  128. package/dist/src/dashboard/paginate_helper.js +33 -0
  129. package/dist/src/dashboard/query_explain_handler.d.ts +10 -0
  130. package/dist/src/dashboard/query_explain_handler.js +80 -0
  131. package/dist/src/dashboard/read_queries.d.ts +32 -0
  132. package/dist/src/dashboard/read_queries.js +107 -0
  133. package/dist/src/dashboard/saved_filter_queries.d.ts +10 -0
  134. package/dist/src/dashboard/saved_filter_queries.js +24 -0
  135. package/dist/src/dashboard/storage_stats.d.ts +41 -0
  136. package/dist/src/dashboard/storage_stats.js +81 -0
  137. package/dist/src/dashboard/write_queue.d.ts +106 -0
  138. package/dist/src/dashboard/write_queue.js +225 -0
  139. package/dist/src/data/data_access.d.ts +2 -39
  140. package/dist/src/data/data_access.js +17 -193
  141. package/dist/src/data/data_access_helpers.d.ts +130 -0
  142. package/dist/src/data/data_access_helpers.js +212 -0
  143. package/dist/src/debug/debug_store.js +37 -32
  144. package/dist/src/debug/email_collector.d.ts +1 -10
  145. package/dist/src/debug/email_collector.js +78 -81
  146. package/dist/src/debug/event_collector.d.ts +0 -9
  147. package/dist/src/debug/event_collector.js +79 -62
  148. package/dist/src/debug/query_collector.js +23 -19
  149. package/dist/src/debug/route_inspector.d.ts +1 -5
  150. package/dist/src/debug/route_inspector.js +50 -51
  151. package/dist/src/debug/trace_collector.d.ts +9 -1
  152. package/dist/src/debug/trace_collector.js +21 -15
  153. package/dist/src/debug/types.d.ts +1 -1
  154. package/dist/src/define_config.d.ts +0 -65
  155. package/dist/src/define_config.js +93 -333
  156. package/dist/src/edge/client/dashboard.js +2 -2
  157. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  158. package/dist/src/edge/client/stats-bar.js +1 -1
  159. package/dist/src/edge/client-vue/dashboard.js +5 -5
  160. package/dist/src/edge/client-vue/debug-panel-deferred.js +4 -4
  161. package/dist/src/edge/client-vue/stats-bar.js +3 -3
  162. package/dist/src/edge/plugin.d.ts +0 -16
  163. package/dist/src/edge/plugin.js +57 -64
  164. package/dist/src/engine/request_metrics.d.ts +1 -0
  165. package/dist/src/engine/request_metrics.js +32 -42
  166. package/dist/src/middleware/request_tracking_middleware.d.ts +2 -8
  167. package/dist/src/middleware/request_tracking_middleware.js +65 -93
  168. package/dist/src/provider/auth_middleware_detector.d.ts +16 -0
  169. package/dist/src/provider/auth_middleware_detector.js +97 -0
  170. package/dist/src/provider/boot_helpers.d.ts +20 -0
  171. package/dist/src/provider/boot_helpers.js +91 -0
  172. package/dist/src/provider/boot_initializer.d.ts +28 -0
  173. package/dist/src/provider/boot_initializer.js +35 -0
  174. package/dist/src/provider/dashboard_init.d.ts +30 -0
  175. package/dist/src/provider/dashboard_init.js +138 -0
  176. package/dist/src/provider/dashboard_setup.d.ts +25 -0
  177. package/dist/src/provider/dashboard_setup.js +78 -0
  178. package/dist/src/provider/diagnostics.d.ts +134 -0
  179. package/dist/src/provider/diagnostics.js +127 -0
  180. package/dist/src/provider/email_bridge.d.ts +43 -0
  181. package/dist/src/provider/email_bridge.js +80 -0
  182. package/dist/src/provider/email_helpers.d.ts +13 -0
  183. package/dist/src/provider/email_helpers.js +68 -0
  184. package/dist/src/provider/pino_hook.d.ts +17 -0
  185. package/dist/src/provider/pino_hook.js +35 -0
  186. package/dist/src/provider/provider_helpers_extra.d.ts +47 -0
  187. package/dist/src/provider/provider_helpers_extra.js +177 -0
  188. package/dist/src/provider/server_stats_provider.d.ts +39 -85
  189. package/dist/src/provider/server_stats_provider.js +132 -951
  190. package/dist/src/provider/shutdown_helpers.d.ts +43 -0
  191. package/dist/src/provider/shutdown_helpers.js +70 -0
  192. package/dist/src/provider/toolbar_setup.d.ts +57 -0
  193. package/dist/src/provider/toolbar_setup.js +141 -0
  194. package/dist/src/routes/dashboard_routes.d.ts +14 -0
  195. package/dist/src/routes/dashboard_routes.js +197 -0
  196. package/dist/src/routes/debug_routes.d.ts +14 -0
  197. package/dist/src/routes/debug_routes.js +101 -0
  198. package/dist/src/routes/register_routes.d.ts +0 -78
  199. package/dist/src/routes/register_routes.js +22 -352
  200. package/dist/src/routes/stats_routes.d.ts +5 -0
  201. package/dist/src/routes/stats_routes.js +14 -0
  202. package/dist/src/styles/components.css +163 -0
  203. package/dist/src/styles/dashboard.css +13 -105
  204. package/dist/src/styles/debug-panel.css +2 -53
  205. package/dist/src/styles/utilities.css +3 -1
  206. package/dist/src/types.d.ts +305 -14
  207. package/dist/vue/{CacheSection-oFAJL3mo.js → CacheSection-DT2Mwf_s.js} +1 -1
  208. package/dist/vue/{ConfigSection-BhfJ4KqL.js → ConfigSection-BwKwS9lh.js} +1 -1
  209. package/dist/vue/CustomPaneTab-Hr1IBHfz.js +172 -0
  210. package/dist/vue/{EmailsSection-BcNyhyHs.js → EmailsSection-B65g0FVS.js} +1 -1
  211. package/dist/vue/{EventsSection-r60Q5Lmu.js → EventsSection-CxqtVF-o.js} +1 -1
  212. package/dist/vue/{JobsSection-BHL-hkQw.js → JobsSection-rMIyMb-g.js} +1 -1
  213. package/dist/vue/{LogsSection-DRMGzJmg.js → LogsSection-DmmZVJ7D.js} +9 -3
  214. package/dist/vue/{LogsTab-Bg3o0Mm6.js → LogsTab-47zEK7jL.js} +4 -1
  215. package/dist/vue/{OverviewSection-CXh6Ja1B.js → OverviewSection-BMabyqw-.js} +49 -50
  216. package/dist/vue/{QueriesSection-IodIsCJ-.js → QueriesSection-BfDFwGqH.js} +44 -45
  217. package/dist/vue/{QueriesTab-C8_7oprC.js → QueriesTab-DuTG7cpC.js} +30 -31
  218. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-Py1iu9GU.js +77 -0
  219. package/dist/vue/{RequestsSection-BPuMdmMc.js → RequestsSection-CTu4jPZ_.js} +143 -147
  220. package/dist/vue/{RoutesSection-NKo3Rbq3.js → RoutesSection-zQZDedL7.js} +1 -1
  221. package/dist/vue/TimelineTab-DHfXsX7t.js +334 -0
  222. package/dist/vue/components/shared/RelatedLogs.vue.d.ts +1 -4
  223. package/dist/vue/composables/useDashboardData.d.ts +12 -23
  224. package/dist/vue/index-CM3yNVUR.js +1232 -0
  225. package/dist/vue/index.js +1 -1
  226. package/dist/vue/style.css +1 -1
  227. package/package.json +1 -1
  228. package/dist/react/CacheSection-UCMptWyn.js +0 -146
  229. package/dist/react/CacheTab-CA8LB1J5.js +0 -123
  230. package/dist/react/CustomPaneTab-Bxtv_8Rw.js +0 -104
  231. package/dist/react/EmailsSection-CM7stSyh.js +0 -262
  232. package/dist/react/EmailsTab-BDhEiomM.js +0 -153
  233. package/dist/react/EventsTab-CMfY98Rl.js +0 -63
  234. package/dist/react/InternalsSection-t7ihcWO-.js +0 -32
  235. package/dist/react/InternalsTab-Oij0A2fN.js +0 -30
  236. package/dist/react/JobsSection-DF3qEv9O.js +0 -187
  237. package/dist/react/JobsTab-BbrBWIOb.js +0 -141
  238. package/dist/react/LogsSection-DcFTZY7b.js +0 -227
  239. package/dist/react/LogsTab-CicucmVk.js +0 -103
  240. package/dist/react/QueriesSection-PswteoF9.js +0 -461
  241. package/dist/react/RelatedLogs-DFDOyUMr.js +0 -40
  242. package/dist/react/RequestsSection-Nag30rEA.js +0 -341
  243. package/dist/react/RoutesTab-DgVzd2PZ.js +0 -74
  244. package/dist/react/index-Cflz9Ebj.js +0 -1069
  245. package/dist/vue/CustomPaneTab-BJxT5Dp7.js +0 -172
  246. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-CB2_TzYW.js +0 -84
  247. package/dist/vue/TimelineTab-zj5Z5OdT.js +0 -338
  248. package/dist/vue/index-Dtgysd26.js +0 -1229
@@ -1,461 +0,0 @@
1
- import { jsx as t, jsxs as r, Fragment as b } from "react/jsx-runtime";
2
- import { useState as y, useCallback as $, useEffect as V, useMemo as P } from "react";
3
- import { durationSeverity as _, timeAgo as B, formatTime as G, SLOW_DURATION_MS as X } from "adonisjs-server-stats/core";
4
- import { a as Y } from "./index-Cflz9Ebj.js";
5
- import { D as I } from "./DataTable-YyShr5B-.js";
6
- import { F as Z } from "./FilterBar-DQRXpWrb.js";
7
- import { P as ee } from "./Pagination-BkmzUDY8.js";
8
- function K({ node: a, depth: d = 0 }) {
9
- if (!a) return null;
10
- const f = d * 20, u = a["Node Type"] || "Unknown", D = a["Relation Name"] ? /* @__PURE__ */ r(b, { children: [
11
- " on ",
12
- /* @__PURE__ */ t("strong", { children: a["Relation Name"] })
13
- ] }) : null, c = a.Alias && a.Alias !== a["Relation Name"] ? ` (${a.Alias})` : "", m = a["Index Name"] ? /* @__PURE__ */ r(b, { children: [
14
- " using ",
15
- /* @__PURE__ */ t("em", { children: a["Index Name"] })
16
- ] }) : null, i = [];
17
- 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"]) {
18
- const n = Array.isArray(a["Sort Key"]) ? a["Sort Key"].join(", ") : a["Sort Key"];
19
- i.push(`sort: ${n}`);
20
- }
21
- const k = a.Plans || [];
22
- return /* @__PURE__ */ r("div", { className: "ss-dash-explain-node", style: { marginLeft: `${f}px` }, children: [
23
- /* @__PURE__ */ r("div", { className: "ss-dash-explain-node-header", children: [
24
- /* @__PURE__ */ t("span", { className: "ss-dash-explain-node-type", children: u }),
25
- D,
26
- c,
27
- m
28
- ] }),
29
- i.length > 0 && /* @__PURE__ */ t("div", { className: "ss-dash-explain-metrics", children: i.join(" · ") }),
30
- k.map((n, T) => /* @__PURE__ */ t(K, { node: n, depth: d + 1 }, T))
31
- ] });
32
- }
33
- function se({ plan: a }) {
34
- if (!a || !Array.isArray(a) || a.length === 0)
35
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: "No plan data returned" });
36
- const d = a[0];
37
- if (d && d.Plan)
38
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: /* @__PURE__ */ t(K, { node: d.Plan, depth: 0 }) });
39
- if (typeof d == "object" && d !== null) {
40
- const f = Object.keys(d);
41
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: /* @__PURE__ */ r("table", { children: [
42
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { children: f.map((u) => /* @__PURE__ */ t("th", { children: u }, u)) }) }),
43
- /* @__PURE__ */ t("tbody", { children: a.map((u, D) => {
44
- const c = u;
45
- return /* @__PURE__ */ t("tr", { children: f.map((m) => /* @__PURE__ */ t("td", { children: c[m] !== null && c[m] !== void 0 ? String(c[m]) : "-" }, m)) }, D);
46
- }) })
47
- ] }) });
48
- }
49
- return /* @__PURE__ */ t("div", { className: "ss-dash-explain-result", children: "No plan data returned" });
50
- }
51
- const te = 8;
52
- function ce({ options: a = {} }) {
53
- const [d, f] = y(1), [u, D] = y(""), [c, m] = y("createdAt"), [i, k] = y("desc"), [n, T] = y("list"), [g, S] = y(null), [o, q] = y(null), [M, A] = y(null), z = $(
54
- (s) => {
55
- s !== n && (T(s), f(1), m(s === "list" ? "createdAt" : "count"), k("desc"), S(null), q(null), A(null));
56
- },
57
- [n]
58
- );
59
- V(() => f(1), [u]);
60
- const Q = n === "grouped" ? "queries/grouped" : "queries", { data: F, meta: w, isLoading: U, mutate: O } = Y(Q, {
61
- ...a,
62
- page: d,
63
- search: u,
64
- sort: c,
65
- sortDir: i
66
- }), R = $(
67
- (s) => {
68
- c === s ? k((e) => e === "asc" ? "desc" : "asc") : (m(s), k("desc"));
69
- },
70
- [c]
71
- ), W = $(
72
- async (s) => {
73
- if (o && o.queryId === s) {
74
- q(null);
75
- return;
76
- }
77
- A(s);
78
- try {
79
- const e = await O(`queries/${s}/explain`);
80
- e && e.error ? q({
81
- queryId: s,
82
- plan: [],
83
- error: e.error,
84
- message: e.message
85
- }) : q({
86
- queryId: s,
87
- plan: e?.plan || e?.rows || []
88
- });
89
- } catch (e) {
90
- console.warn("[ss] Query explain failed:", e), q({
91
- queryId: s,
92
- plan: [],
93
- error: e instanceof Error ? e.message : String(e)
94
- });
95
- } finally {
96
- A(null);
97
- }
98
- },
99
- [O, o]
100
- ), H = $(
101
- (s) => {
102
- const e = s.id;
103
- return !o || o.queryId !== e ? null : /* @__PURE__ */ t("tr", { className: "ss-dash-explain-row", children: /* @__PURE__ */ t("td", { colSpan: te, className: "ss-dash-explain", children: /* @__PURE__ */ r("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "start" }, children: [
104
- /* @__PURE__ */ t("div", { style: { flex: 1 }, children: o.error ? /* @__PURE__ */ r("div", { className: "ss-dash-explain-result ss-dash-explain-error", children: [
105
- /* @__PURE__ */ t("strong", { children: "Error:" }),
106
- " ",
107
- o.error,
108
- o.message && /* @__PURE__ */ r(b, { children: [
109
- /* @__PURE__ */ t("br", {}),
110
- o.message
111
- ] })
112
- ] }) : /* @__PURE__ */ t(se, { plan: o.plan }) }),
113
- /* @__PURE__ */ t(
114
- "button",
115
- {
116
- type: "button",
117
- className: "ss-dash-explain-btn",
118
- onClick: () => q(null),
119
- style: { marginLeft: "8px", flexShrink: 0 },
120
- children: "Close"
121
- }
122
- )
123
- ] }) }) });
124
- },
125
- [o]
126
- ), E = n === "grouped" ? F?.groups || [] : F || [], h = P(() => n !== "grouped" ? E : E.map((s) => {
127
- const e = { ...s };
128
- return (e.sqlNormalized === null || e.sqlNormalized === void 0) && (s.sql_normalized || s.pattern) && (e.sqlNormalized = s.sql_normalized || s.pattern || ""), (e.count === null || e.count === void 0) && s.total_count !== null && s.total_count !== void 0 && (e.count = s.total_count), (e.avgDuration === null || e.avgDuration === void 0) && s.avg_duration !== null && s.avg_duration !== void 0 && (e.avgDuration = s.avg_duration), (e.maxDuration === null || e.maxDuration === void 0) && s.max_duration !== null && s.max_duration !== void 0 && (e.maxDuration = s.max_duration), (e.minDuration === null || e.minDuration === void 0) && s.min_duration !== null && s.min_duration !== void 0 && (e.minDuration = s.min_duration), (e.totalDuration === null || e.totalDuration === void 0) && s.total_duration !== null && s.total_duration !== void 0 && (e.totalDuration = s.total_duration), (e.percentOfTotal === null || e.percentOfTotal === void 0) && s.pct_time !== null && s.pct_time !== void 0 && (e.percentOfTotal = s.pct_time), e;
129
- }), [E, n]), N = P(() => {
130
- const s = w?.total ?? h.length;
131
- let e = 0, l = 0, p = 0, x = 0;
132
- for (const v of h) {
133
- const C = v.duration || 0;
134
- p += C, x++, C > X && e++;
135
- }
136
- const L = /* @__PURE__ */ new Map();
137
- for (const v of h) {
138
- const C = v.sqlNormalized || v.sql || v.sql_text || "";
139
- L.set(C, (L.get(C) || 0) + 1);
140
- }
141
- for (const v of L.values())
142
- v > 1 && (l += v);
143
- return {
144
- total: s,
145
- slow: e,
146
- duplicates: l,
147
- avgDuration: x > 0 ? p / x : 0
148
- };
149
- }, [h, w]), j = P(() => {
150
- const s = /* @__PURE__ */ new Map();
151
- for (const e of h) {
152
- const l = e.sqlNormalized || e.sql || e.sql_text || "";
153
- s.set(l, (s.get(l) || 0) + 1);
154
- }
155
- return s;
156
- }, [h]), J = P(() => {
157
- if (n === "grouped")
158
- return `${h.length} query patterns`;
159
- const s = [`${N.total} queries`];
160
- return N.slow > 0 && s.push(`${N.slow} slow`), N.duplicates > 0 && s.push(`${N.duplicates} dup`), s.push(`avg ${(N.avgDuration || 0).toFixed(1)}ms`), s.join(", ");
161
- }, [n, h.length, N]);
162
- return /* @__PURE__ */ r("div", { children: [
163
- /* @__PURE__ */ t(
164
- Z,
165
- {
166
- search: u,
167
- onSearchChange: D,
168
- placeholder: "Filter queries...",
169
- summary: J,
170
- children: /* @__PURE__ */ r("div", { className: "ss-dash-btn-group", children: [
171
- /* @__PURE__ */ t(
172
- "button",
173
- {
174
- type: "button",
175
- className: `ss-dash-btn ${n === "list" ? "ss-dash-active" : ""}`,
176
- onClick: () => z("list"),
177
- children: "List"
178
- }
179
- ),
180
- /* @__PURE__ */ t(
181
- "button",
182
- {
183
- type: "button",
184
- className: `ss-dash-btn ${n === "grouped" ? "ss-dash-active" : ""}`,
185
- onClick: () => z("grouped"),
186
- children: "Grouped"
187
- }
188
- )
189
- ] })
190
- }
191
- ),
192
- U && !F ? /* @__PURE__ */ t("div", { className: "ss-dash-empty", children: "Loading queries..." }) : n === "grouped" ? /* @__PURE__ */ t(b, { children: /* @__PURE__ */ t("div", { className: "ss-dash-table-wrap", children: /* @__PURE__ */ t(
193
- I,
194
- {
195
- columns: [
196
- {
197
- key: "sqlNormalized",
198
- label: "Pattern",
199
- render: (s, e) => {
200
- const l = s || "", p = (e.count || 0) >= 3;
201
- return /* @__PURE__ */ r(b, { children: [
202
- /* @__PURE__ */ t(
203
- "span",
204
- {
205
- className: `ss-dash-sql ${g === l ? "ss-dash-expanded" : ""}`,
206
- title: "Click to expand",
207
- onClick: (x) => {
208
- x.stopPropagation(), S(g === l ? null : l);
209
- },
210
- role: "button",
211
- tabIndex: 0,
212
- onKeyDown: (x) => x.key === "Enter" && S(g === l ? null : l),
213
- children: l
214
- }
215
- ),
216
- p && /* @__PURE__ */ r(b, { children: [
217
- " ",
218
- /* @__PURE__ */ t("span", { className: "ss-dash-dup", children: "DUP" })
219
- ] })
220
- ] });
221
- }
222
- },
223
- {
224
- key: "count",
225
- label: "Count",
226
- width: "60px",
227
- sortable: !0,
228
- render: (s) => /* @__PURE__ */ t(
229
- "span",
230
- {
231
- style: { color: "var(--ss-muted)", textAlign: "center", display: "block" },
232
- children: s || 0
233
- }
234
- )
235
- },
236
- {
237
- key: "avgDuration",
238
- label: "Avg",
239
- width: "70px",
240
- sortable: !0,
241
- render: (s) => {
242
- const e = s || 0;
243
- return /* @__PURE__ */ t(
244
- "span",
245
- {
246
- className: `ss-dash-duration ${_(e) === "very-slow" ? "ss-dash-very-slow" : _(e) === "slow" ? "ss-dash-slow" : ""}`,
247
- children: e.toFixed(2) + "ms"
248
- }
249
- );
250
- }
251
- },
252
- {
253
- key: "minDuration",
254
- label: "Min",
255
- width: "70px",
256
- render: (s) => /* @__PURE__ */ t("span", { className: "ss-dash-duration", children: (s || 0).toFixed(2) + "ms" })
257
- },
258
- {
259
- key: "maxDuration",
260
- label: "Max",
261
- width: "70px",
262
- render: (s) => {
263
- const e = s || 0;
264
- return /* @__PURE__ */ t(
265
- "span",
266
- {
267
- className: `ss-dash-duration ${_(e) === "very-slow" ? "ss-dash-very-slow" : _(e) === "slow" ? "ss-dash-slow" : ""}`,
268
- children: e.toFixed(2) + "ms"
269
- }
270
- );
271
- }
272
- },
273
- {
274
- key: "totalDuration",
275
- label: "Total",
276
- width: "70px",
277
- sortable: !0,
278
- render: (s) => /* @__PURE__ */ t("span", { className: "ss-dash-duration", children: (s || 0).toFixed(1) + "ms" })
279
- },
280
- {
281
- key: "percentOfTotal",
282
- label: "% Time",
283
- width: "60px",
284
- render: (s) => /* @__PURE__ */ t(
285
- "span",
286
- {
287
- style: { color: "var(--ss-muted)", textAlign: "center", display: "block" },
288
- children: (s || 0).toFixed(1) + "%"
289
- }
290
- )
291
- }
292
- ],
293
- data: h,
294
- keyField: "sqlNormalized",
295
- sort: c,
296
- sortDir: i,
297
- onSort: R,
298
- emptyMessage: "No queries recorded"
299
- }
300
- ) }) }) : /* @__PURE__ */ r(b, { children: [
301
- /* @__PURE__ */ t("div", { className: "ss-dash-table-wrap", children: /* @__PURE__ */ t(
302
- I,
303
- {
304
- columns: [
305
- {
306
- key: "id",
307
- label: "#",
308
- width: "40px",
309
- render: (s) => /* @__PURE__ */ t("span", { style: { color: "var(--ss-dim)" }, children: s })
310
- },
311
- {
312
- key: "sql",
313
- label: "SQL",
314
- render: (s, e) => {
315
- const l = e.sql || e.sql_text || "";
316
- return /* @__PURE__ */ r("div", { children: [
317
- /* @__PURE__ */ t(
318
- "span",
319
- {
320
- className: `ss-dash-sql ${g === e.id ? "ss-dash-expanded" : ""}`,
321
- title: "Click to expand",
322
- onClick: (p) => {
323
- p.stopPropagation(), S(
324
- g === e.id ? null : e.id
325
- );
326
- },
327
- role: "button",
328
- tabIndex: 0,
329
- onKeyDown: (p) => p.key === "Enter" && S(
330
- g === e.id ? null : e.id
331
- ),
332
- children: l
333
- }
334
- ),
335
- (j.get(
336
- (e.sqlNormalized || e.sql || e.sql_text) ?? ""
337
- ) ?? 0) > 1 && /* @__PURE__ */ r("span", { className: "ss-dash-dup", children: [
338
- "×",
339
- j.get(
340
- (e.sqlNormalized || e.sql || e.sql_text) ?? ""
341
- )
342
- ] })
343
- ] });
344
- }
345
- },
346
- {
347
- key: "duration",
348
- label: "Duration",
349
- width: "70px",
350
- sortable: !0,
351
- render: (s) => {
352
- const e = s || 0;
353
- return /* @__PURE__ */ t(
354
- "span",
355
- {
356
- className: `ss-dash-duration ${_(e) === "very-slow" ? "ss-dash-very-slow" : _(e) === "slow" ? "ss-dash-slow" : ""}`,
357
- children: e.toFixed(2) + "ms"
358
- }
359
- );
360
- }
361
- },
362
- {
363
- key: "method",
364
- label: "Method",
365
- width: "60px",
366
- render: (s, e) => {
367
- const l = e.method || e.sql_method || "";
368
- return /* @__PURE__ */ t("span", { className: `ss-dash-method ss-dash-method-${l.toLowerCase()}`, children: l });
369
- }
370
- },
371
- {
372
- key: "model",
373
- label: "Model",
374
- width: "90px",
375
- render: (s) => /* @__PURE__ */ t(
376
- "span",
377
- {
378
- style: {
379
- color: "var(--ss-muted)",
380
- overflow: "hidden",
381
- textOverflow: "ellipsis",
382
- whiteSpace: "nowrap"
383
- },
384
- title: s,
385
- children: s || "-"
386
- }
387
- )
388
- },
389
- {
390
- key: "connection",
391
- label: "Connection",
392
- width: "80px",
393
- render: (s) => /* @__PURE__ */ t(
394
- "span",
395
- {
396
- style: {
397
- color: "var(--ss-dim)",
398
- overflow: "hidden",
399
- textOverflow: "ellipsis",
400
- whiteSpace: "nowrap"
401
- },
402
- children: s || "-"
403
- }
404
- )
405
- },
406
- {
407
- key: "createdAt",
408
- label: "Time",
409
- width: "90px",
410
- sortable: !0,
411
- render: (s, e) => {
412
- const l = s || e.created_at || e.timestamp || "";
413
- return /* @__PURE__ */ t("span", { className: "ss-dash-event-time", title: G(l), children: B(l) });
414
- }
415
- },
416
- {
417
- key: "id",
418
- label: "",
419
- width: "70px",
420
- render: (s, e) => {
421
- if ((e.method || e.sql_method || "") !== "select") return null;
422
- const p = o?.queryId === e.id && !o?.error;
423
- return /* @__PURE__ */ t(
424
- "button",
425
- {
426
- type: "button",
427
- className: `ss-dash-explain-btn${p ? " ss-dash-explain-btn-active" : ""}`,
428
- onClick: (x) => {
429
- x.stopPropagation(), W(e.id);
430
- },
431
- disabled: M === e.id,
432
- children: M === e.id ? "..." : "EXPLAIN"
433
- }
434
- );
435
- }
436
- }
437
- ],
438
- data: h,
439
- sort: c,
440
- sortDir: i,
441
- onSort: R,
442
- emptyMessage: "No queries recorded",
443
- renderAfterRow: H
444
- }
445
- ) }),
446
- w && /* @__PURE__ */ t(
447
- ee,
448
- {
449
- page: w.page,
450
- lastPage: w.lastPage,
451
- total: w.total,
452
- onPageChange: f
453
- }
454
- )
455
- ] })
456
- ] });
457
- }
458
- export {
459
- ce as QueriesSection,
460
- ce as default
461
- };
@@ -1,40 +0,0 @@
1
- import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
- import g, { useState as h } from "react";
3
- import { resolveLogLevel as u, resolveLogMessage as $, resolveLogRequestId as v, resolveLogTimestamp as N, getStructuredData as L, getLogLevelCssClass as y, timeAgo as R, formatTime as q } from "adonisjs-server-stats/core";
4
- import { J as C } from "./index-Cflz9Ebj.js";
5
- function J({ logs: s, classPrefix: e = "ss-dash" }) {
6
- const [r, p] = h(null);
7
- return s.length === 0 ? null : /* @__PURE__ */ o("div", { children: [
8
- /* @__PURE__ */ o("div", { className: `${e}-related-logs-title`, children: [
9
- "Related Logs",
10
- /* @__PURE__ */ o("span", { className: `${e}-related-logs-count`, children: [
11
- "(",
12
- s.length,
13
- ")"
14
- ] })
15
- ] }),
16
- /* @__PURE__ */ t("div", { className: `${e}-log-entries`, style: { overflow: "auto" }, children: s.map((n, l) => {
17
- const c = u(n), i = $(n), m = v(n), d = N(n), a = L(n);
18
- return /* @__PURE__ */ o(g.Fragment, { children: [
19
- /* @__PURE__ */ o(
20
- "div",
21
- {
22
- className: `${e}-log-entry${a ? ` ${e}-log-entry-expandable` : ""}`,
23
- onClick: () => a && p(r === l ? null : l),
24
- children: [
25
- /* @__PURE__ */ t("span", { className: `${e}-log-level ${y(c, `${e}-log-level`)}`, children: c.toUpperCase() }),
26
- /* @__PURE__ */ t("span", { className: `${e}-log-time`, title: d ? q(d) : "", children: d ? R(d) : "-" }),
27
- m ? /* @__PURE__ */ t("span", { className: `${e}-log-reqid`, title: m, children: m.slice(0, 8) }) : /* @__PURE__ */ t("span", { className: `${e}-log-reqid-empty`, children: "--" }),
28
- a ? /* @__PURE__ */ t("span", { className: `${e}-log-expand-icon${r === l ? ` ${e}-log-expand-icon-open` : ""}`, children: "▶" }) : /* @__PURE__ */ t("span", { style: { width: 14 } }),
29
- /* @__PURE__ */ t("span", { className: `${e}-log-msg`, children: i })
30
- ]
31
- }
32
- ),
33
- r === l && a && /* @__PURE__ */ t("div", { className: `${e}-log-detail`, children: /* @__PURE__ */ t(C, { data: a, classPrefix: e, defaultExpanded: !0 }) })
34
- ] }, n.id || l);
35
- }) })
36
- ] });
37
- }
38
- export {
39
- J as R
40
- };