adonisjs-server-stats 1.13.0 → 1.14.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 (150) hide show
  1. package/README.md +3 -2
  2. package/dist/configure.js +6 -1
  3. package/dist/core/collectors/collector.d.ts +83 -0
  4. package/dist/core/core/types.d.ts +186 -0
  5. package/dist/core/debug/types.d.ts +467 -0
  6. package/dist/core/index.js +184 -169
  7. package/dist/core/types.d.ts +855 -167
  8. package/dist/react/{CacheSection-CX2duJuc.js → CacheSection-DkLtukWz.js} +1 -1
  9. package/dist/react/{CacheTab-CgT4t0oZ.js → CacheTab-DWeXnEBI.js} +51 -46
  10. package/dist/react/ConfigContent-Bwvfl_G7.js +350 -0
  11. package/dist/react/{ConfigSection-Dt0FyeaW.js → ConfigSection-DaVbFPDg.js} +2 -2
  12. package/dist/react/{ConfigTab-KtiTtsrj.js → ConfigTab-D4640WJZ.js} +2 -2
  13. package/dist/react/{CustomPaneTab-15QoEplP.js → CustomPaneTab-DglmAVMC.js} +1 -1
  14. package/dist/react/{EmailsSection-YcJYR5eA.js → EmailsSection-vYx6ExTb.js} +1 -1
  15. package/dist/react/{EmailsTab-CUjubln_.js → EmailsTab-DKDrRmRH.js} +54 -49
  16. package/dist/react/{EventsSection-GGPoYSNv.js → EventsSection-CapH5xut.js} +1 -1
  17. package/dist/react/{EventsTab-Wdwr0_ny.js → EventsTab-BNVEySAm.js} +1 -1
  18. package/dist/react/{InternalsContent-BNOnSoi9.js → InternalsContent-C9lIA92C.js} +1 -1
  19. package/dist/react/{InternalsSection-BwrTfpjA.js → InternalsSection-lOv_UcSV.js} +1 -1
  20. package/dist/react/{InternalsTab--RD-L1dX.js → InternalsTab-BygoSorC.js} +1 -1
  21. package/dist/react/{JobsSection-BqqIh_DR.js → JobsSection-ZIQsJWid.js} +1 -1
  22. package/dist/react/{JobsTab-CBrU-ryL.js → JobsTab-DXQzXrDt.js} +1 -1
  23. package/dist/react/{LogEntryRow-BOrRkhRU.js → LogEntryRow-BWkHE51-.js} +1 -1
  24. package/dist/react/{LogsSection-Cm_lphM6.js → LogsSection-ConXdBkL.js} +2 -2
  25. package/dist/react/LogsTab-CJM47LPn.js +82 -0
  26. package/dist/react/{OverviewSection-XF7bakyM.js → OverviewSection-DOMu2qvl.js} +131 -131
  27. package/dist/react/{QueriesSection-DsQBKrNK.js → QueriesSection-DFsaOSJI.js} +1 -1
  28. package/dist/react/{QueriesTab-CxCC1GVq.js → QueriesTab-CY9CG_7L.js} +1 -1
  29. package/dist/react/RequestsSection-CC-eVHsl.js +326 -0
  30. package/dist/react/{RoutesSection-D0y5JQP4.js → RoutesSection-p1DMq41y.js} +1 -1
  31. package/dist/react/{RoutesTab-Y_alJVMV.js → RoutesTab-Cnqy8UcK.js} +1 -1
  32. package/dist/react/{SplitPaneWrapper-CZl1ouIT.js → SplitPaneWrapper-XgkA0QxE.js} +1 -1
  33. package/dist/react/{TimelineTab-HyqZpfbp.js → TimelineTab-1YOERxe5.js} +3 -3
  34. package/dist/react/index-DOSlCpZ9.js +1159 -0
  35. package/dist/react/index.js +1 -1
  36. package/dist/react/useApiClient-CtEG7rHs.js +11 -0
  37. package/dist/src/collectors/queue_collector.js +22 -6
  38. package/dist/src/config/deprecation_migration.js +11 -0
  39. package/dist/src/dashboard/cache_handlers.js +22 -2
  40. package/dist/src/dashboard/flush_manager.d.ts +2 -0
  41. package/dist/src/dashboard/flush_manager.js +17 -0
  42. package/dist/src/dashboard/integrations/config_inspector.d.ts +0 -1
  43. package/dist/src/dashboard/integrations/config_inspector.js +4 -2
  44. package/dist/src/dashboard/paginate_helper.d.ts +5 -0
  45. package/dist/src/dashboard/paginate_helper.js +16 -4
  46. package/dist/src/dashboard/query_explain_handler.d.ts +6 -1
  47. package/dist/src/dashboard/query_explain_handler.js +12 -2
  48. package/dist/src/dashboard/write_queue.d.ts +13 -0
  49. package/dist/src/dashboard/write_queue.js +34 -2
  50. package/dist/src/debug/debug_store.js +8 -1
  51. package/dist/src/debug/event_collector.js +4 -0
  52. package/dist/src/debug/query_collector.js +2 -0
  53. package/dist/src/debug/ring_buffer.js +8 -1
  54. package/dist/src/debug/trace_collector.js +34 -10
  55. package/dist/src/debug/types.d.ts +2 -0
  56. package/dist/src/define_config.js +1 -0
  57. package/dist/src/edge/client/dashboard.js +2 -2
  58. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  59. package/dist/src/edge/client/stats-bar.js +1 -1
  60. package/dist/src/edge/client-vue/dashboard.js +5 -5
  61. package/dist/src/edge/client-vue/debug-panel-deferred.js +2 -2
  62. package/dist/src/engine/request_metrics.js +8 -10
  63. package/dist/src/log_stream/log_stream_service.d.ts +1 -0
  64. package/dist/src/log_stream/log_stream_service.js +7 -5
  65. package/dist/src/prometheus/prometheus_collector.d.ts +9 -0
  66. package/dist/src/prometheus/prometheus_collector.js +11 -0
  67. package/dist/src/provider/dashboard_init.js +15 -0
  68. package/dist/src/provider/dashboard_setup.js +9 -2
  69. package/dist/src/provider/email_bridge.js +6 -2
  70. package/dist/src/provider/email_helpers.d.ts +9 -1
  71. package/dist/src/provider/email_helpers.js +32 -4
  72. package/dist/src/provider/pino_hook.d.ts +8 -0
  73. package/dist/src/provider/pino_hook.js +19 -1
  74. package/dist/src/provider/provider_helpers_extra.d.ts +2 -0
  75. package/dist/src/provider/provider_helpers_extra.js +17 -2
  76. package/dist/src/provider/server_stats_provider.js +19 -1
  77. package/dist/src/provider/shutdown_helpers.js +2 -0
  78. package/dist/src/provider/toolbar_setup.js +17 -14
  79. package/dist/src/routes/dashboard_routes.js +96 -62
  80. package/dist/src/routes/debug_routes.js +45 -35
  81. package/dist/src/routes/no_session_middleware.d.ts +6 -3
  82. package/dist/src/routes/no_session_middleware.js +7 -3
  83. package/dist/src/routes/register_routes.d.ts +8 -0
  84. package/dist/src/routes/register_routes.js +19 -0
  85. package/dist/src/types.d.ts +31 -0
  86. package/dist/src/utils/app_import.js +12 -4
  87. package/dist/vue/CacheSection-CxEBVVkF.js +156 -0
  88. package/dist/vue/ConfigSection-BiRAiaHj.js +415 -0
  89. package/dist/vue/EmailsSection-Dl44qyqY.js +208 -0
  90. package/dist/vue/{EmailsTab-CwIF1fik.js → EmailsTab-Diya54CP.js} +6 -5
  91. package/dist/vue/{EventsSection-BpgkWIwM.js → EventsSection-CWjeitjU.js} +1 -1
  92. package/dist/vue/{InternalsTab-521fxYYj.js → InternalsTab-Z3c82glB.js} +15 -15
  93. package/dist/vue/{JobsSection-DrghFEKL.js → JobsSection-DOBb4LjZ.js} +1 -1
  94. package/dist/vue/LogsSection-CXx-HOWJ.js +260 -0
  95. package/dist/vue/{OverviewSection-BAgZTPjY.js → OverviewSection-CyfNQ8uV.js} +318 -302
  96. package/dist/vue/{QueriesSection-CUpwhp7u.js → QueriesSection-CXBsFp-y.js} +1 -1
  97. package/dist/vue/{RequestsSection-D8P2xpF2.js → RequestsSection-YTIaZGZd.js} +151 -145
  98. package/dist/vue/{RoutesSection-0qB81hTT.js → RoutesSection-CDKMey49.js} +1 -1
  99. package/dist/vue/composables/useApiClient.d.ts +8 -1
  100. package/dist/vue/index-14x39RI_.js +1239 -0
  101. package/dist/vue/index.js +1 -1
  102. package/dist/vue/style.css +1 -1
  103. package/package.json +6 -3
  104. package/dist/react/ConfigContent-CnsEI4j3.js +0 -397
  105. package/dist/react/LogsTab-jKwv9G7Q.js +0 -79
  106. package/dist/react/RequestsSection-D8cMbZU0.js +0 -321
  107. package/dist/react/index-CsprmgzI.js +0 -1121
  108. package/dist/react/useApiClient-BVtNCmnL.js +0 -9
  109. package/dist/vue/CacheSection-DRqV3YX2.js +0 -149
  110. package/dist/vue/ConfigSection-C6pQCHAL.js +0 -576
  111. package/dist/vue/EmailsSection-BTNw3ZU2.js +0 -206
  112. package/dist/vue/LogsSection-BDxx9Bfi.js +0 -258
  113. package/dist/vue/index-30jLw-_w.js +0 -1232
  114. /package/dist/core/{api-client.d.ts → core/api-client.d.ts} +0 -0
  115. /package/dist/core/{config-utils.d.ts → core/config-utils.d.ts} +0 -0
  116. /package/dist/core/{constants.d.ts → core/constants.d.ts} +0 -0
  117. /package/dist/core/{dashboard-api.d.ts → core/dashboard-api.d.ts} +0 -0
  118. /package/dist/core/{dashboard-data-controller.d.ts → core/dashboard-data-controller.d.ts} +0 -0
  119. /package/dist/core/{dashboard-data-helpers.d.ts → core/dashboard-data-helpers.d.ts} +0 -0
  120. /package/dist/core/{debug-data-controller.d.ts → core/debug-data-controller.d.ts} +0 -0
  121. /package/dist/core/{define-config-helpers.d.ts → core/define-config-helpers.d.ts} +0 -0
  122. /package/dist/core/{explain-utils.d.ts → core/explain-utils.d.ts} +0 -0
  123. /package/dist/core/{feature-detect-helpers.d.ts → core/feature-detect-helpers.d.ts} +0 -0
  124. /package/dist/core/{feature-detect.d.ts → core/feature-detect.d.ts} +0 -0
  125. /package/dist/core/{field-resolvers.d.ts → core/field-resolvers.d.ts} +0 -0
  126. /package/dist/core/{formatters-helpers.d.ts → core/formatters-helpers.d.ts} +0 -0
  127. /package/dist/core/{formatters.d.ts → core/formatters.d.ts} +0 -0
  128. /package/dist/core/{history-buffer.d.ts → core/history-buffer.d.ts} +0 -0
  129. /package/dist/core/{icons.d.ts → core/icons.d.ts} +0 -0
  130. /package/dist/core/{index.d.ts → core/index.d.ts} +0 -0
  131. /package/dist/core/{internals-utils.d.ts → core/internals-utils.d.ts} +0 -0
  132. /package/dist/core/{job-utils.d.ts → core/job-utils.d.ts} +0 -0
  133. /package/dist/core/{log-utils-helpers.d.ts → core/log-utils-helpers.d.ts} +0 -0
  134. /package/dist/core/{log-utils.d.ts → core/log-utils.d.ts} +0 -0
  135. /package/dist/core/{metrics.d.ts → core/metrics.d.ts} +0 -0
  136. /package/dist/core/{pagination.d.ts → core/pagination.d.ts} +0 -0
  137. /package/dist/core/{queries-columns.d.ts → core/queries-columns.d.ts} +0 -0
  138. /package/dist/core/{queries-controller.d.ts → core/queries-controller.d.ts} +0 -0
  139. /package/dist/core/{query-utils.d.ts → core/query-utils.d.ts} +0 -0
  140. /package/dist/core/{resizable-columns.d.ts → core/resizable-columns.d.ts} +0 -0
  141. /package/dist/core/{routes.d.ts → core/routes.d.ts} +0 -0
  142. /package/dist/core/{server-stats-controller.d.ts → core/server-stats-controller.d.ts} +0 -0
  143. /package/dist/core/{sparkline.d.ts → core/sparkline.d.ts} +0 -0
  144. /package/dist/core/{split-pane.d.ts → core/split-pane.d.ts} +0 -0
  145. /package/dist/core/{theme.d.ts → core/theme.d.ts} +0 -0
  146. /package/dist/core/{trace-utils.d.ts → core/trace-utils.d.ts} +0 -0
  147. /package/dist/core/{transmit-adapter.d.ts → core/transmit-adapter.d.ts} +0 -0
  148. /package/dist/core/{transmit-helpers.d.ts → core/transmit-helpers.d.ts} +0 -0
  149. /package/dist/core/{types-dashboard.d.ts → core/types-dashboard.d.ts} +0 -0
  150. /package/dist/core/{types-diagnostics.d.ts → core/types-diagnostics.d.ts} +0 -0
@@ -1,1232 +0,0 @@
1
- import { ref as h, reactive as ne, computed as p, onMounted as G, onUnmounted as Y, defineComponent as Z, openBlock as a, createElementBlock as l, normalizeStyle as me, Fragment as V, createElementVNode as i, watch as J, nextTick as ye, onBeforeUnmount as ce, normalizeClass as B, toDisplayString as _, createCommentVNode as k, createBlock as j, Teleport as we, withModifiers as Ce, unref as n, createVNode as ue, renderList as se, defineAsyncComponent as E, createTextVNode as Te, provide as te, Suspense as _e, withCtx as he, resolveDynamicComponent as Ee } from "vue";
2
- import { ServerStatsController as Se, DEFAULT_FEATURES as xe, detectFeatures as $e, getTheme as ve, onThemeChange as Le, toggleTheme as Me, buildSparklineData as Ue, computeStats as Be, formatStatNum as ie, detectMetricGroupsFromStats as Pe, getVisibleMetricGroups as Re, getMetricsByGroup as De, TAB_ICONS as $, DebugDataController as be, DashboardDataController as He, UnauthorizedError as Ae, subscribeToChannel as je } from "adonisjs-server-stats/core";
3
- function ze(e) {
4
- return {
5
- onStatsUpdate: (s) => {
6
- e.stats.value = s;
7
- },
8
- onConnectionChange: (s) => {
9
- e.isConnected.value = s;
10
- },
11
- onStaleChange: (s) => {
12
- e.isStale.value = s;
13
- },
14
- onError: (s) => {
15
- e.error.value = s;
16
- },
17
- onUnauthorizedChange: (s) => {
18
- e.isUnauthorized.value = s;
19
- },
20
- onHistoryChange: (s) => {
21
- for (const t of Object.keys(s))
22
- e.history[t] = s[t];
23
- },
24
- onSseActiveChange: (s) => {
25
- e.sseActive.value = s;
26
- },
27
- onPollActiveChange: (s) => {
28
- e.pollActive.value = s;
29
- }
30
- };
31
- }
32
- function Ie(e, s) {
33
- if (e.isUnauthorized.value) return null;
34
- const t = ze(e), r = new Se({ ...s, ...t });
35
- return r.start(), r;
36
- }
37
- function qe(e = {}) {
38
- const {
39
- baseUrl: s = "",
40
- endpoint: t = "/admin/api/server-stats",
41
- channelName: r = "admin/server-stats",
42
- authToken: o,
43
- pollInterval: c = 3e3
44
- } = e, y = h(null), v = ne({}), f = h(!1), S = h(!1), R = h(null), P = h(!1), b = h(!1), u = h(!1), H = {
45
- stats: y,
46
- history: v,
47
- isConnected: f,
48
- isStale: S,
49
- error: R,
50
- isUnauthorized: P,
51
- sseActive: b,
52
- pollActive: u
53
- };
54
- let g = null;
55
- const I = p(() => P.value ? "disconnected" : b.value ? "live" : u.value ? "polling" : "disconnected");
56
- return G(() => {
57
- g = Ie(H, { baseUrl: s, endpoint: t, channelName: r, authToken: o, pollInterval: c });
58
- }), Y(() => {
59
- g?.stop(), g = null;
60
- }), { stats: y, history: v, isConnected: f, isStale: S, isUnauthorized: P, error: R, connectionMode: I };
61
- }
62
- function de(e = {}) {
63
- const { baseUrl: s = "", debugEndpoint: t = "/admin/api/debug", authToken: r } = e, o = h({ ...xe }), c = h(!0);
64
- return G(async () => {
65
- o.value = await $e({ baseUrl: s, debugEndpoint: t, authToken: r }), c.value = !1;
66
- }), {
67
- features: o,
68
- loading: c
69
- };
70
- }
71
- function oe() {
72
- const e = h(ve());
73
- let s = null;
74
- function t(o) {
75
- e.value = o;
76
- }
77
- function r() {
78
- const o = Me();
79
- return e.value = o, o;
80
- }
81
- return G(() => {
82
- e.value = ve(), s = Le(t);
83
- }), Y(() => {
84
- s?.();
85
- }), {
86
- theme: e,
87
- toggleTheme: r
88
- };
89
- }
90
- const Oe = ["width", "height", "viewBox"], Ne = ["id"], Fe = ["stop-color"], Ve = ["stop-color"], Ge = ["d", "fill"], Qe = ["d", "stroke"], Je = ["x", "y"], We = /* @__PURE__ */ Z({
91
- __name: "Sparkline",
92
- props: {
93
- data: {},
94
- color: { default: "#34d399" },
95
- width: { default: 120 },
96
- height: { default: 32 }
97
- },
98
- setup(e) {
99
- const s = e, t = p(
100
- () => Ue(s.data, {
101
- width: s.width,
102
- height: s.height,
103
- color: s.color
104
- })
105
- ), r = p(() => t.value !== null), o = p(() => `sg-${s.color.replace("#", "")}`);
106
- return (c, y) => (a(), l("div", {
107
- class: "ss-dash-sparkline",
108
- style: me({ "--ss-accent": e.color })
109
- }, [
110
- (a(), l("svg", {
111
- width: e.width,
112
- height: e.height,
113
- viewBox: `0 0 ${e.width} ${e.height}`,
114
- style: { display: "block" }
115
- }, [
116
- r.value && t.value ? (a(), l(V, { key: 0 }, [
117
- i("defs", null, [
118
- i("linearGradient", {
119
- id: o.value,
120
- x1: "0",
121
- y1: "0",
122
- x2: "0",
123
- y2: "1"
124
- }, [
125
- i("stop", {
126
- offset: "0%",
127
- "stop-color": e.color,
128
- "stop-opacity": "0.25"
129
- }, null, 8, Fe),
130
- i("stop", {
131
- offset: "100%",
132
- "stop-color": e.color,
133
- "stop-opacity": "0.02"
134
- }, null, 8, Ve)
135
- ], 8, Ne)
136
- ]),
137
- i("path", {
138
- d: t.value.areaPath,
139
- fill: `url(#${o.value})`
140
- }, null, 8, Ge),
141
- i("path", {
142
- class: "ss-dash-sparkline-line",
143
- d: "M" + t.value.points.replace(/ /g, " L"),
144
- fill: "none",
145
- stroke: e.color,
146
- "stroke-width": "1.5",
147
- "stroke-linejoin": "round",
148
- "stroke-linecap": "round"
149
- }, null, 8, Qe)
150
- ], 64)) : (a(), l("text", {
151
- key: 1,
152
- x: e.width / 2,
153
- y: e.height / 2 + 3,
154
- "text-anchor": "middle",
155
- fill: "#737373",
156
- "font-size": "9"
157
- }, " collecting... ", 8, Je))
158
- ], 8, Oe))
159
- ], 4));
160
- }
161
- }), Ke = ["id"], Xe = { class: "ss-label" }, Ye = {
162
- class: "ss-tooltip-inner",
163
- style: { position: "relative" }
164
- }, Ze = { class: "ss-tooltip-header" }, et = { class: "ss-tooltip-title" }, tt = {
165
- key: 0,
166
- class: "ss-tooltip-unit"
167
- }, st = { class: "ss-tooltip-current" }, at = { class: "ss-tooltip-current-value" }, nt = {
168
- key: 1,
169
- class: "ss-tooltip-stats"
170
- }, ot = {
171
- key: 2,
172
- class: "ss-tooltip-details"
173
- }, lt = {
174
- key: 3,
175
- class: "ss-tooltip-sparkline"
176
- }, it = {
177
- key: 4,
178
- class: "ss-tooltip-samples"
179
- }, rt = /* @__PURE__ */ Z({
180
- __name: "MetricCard",
181
- props: {
182
- metric: {},
183
- stats: {},
184
- history: {}
185
- },
186
- emits: ["pin"],
187
- setup(e, { emit: s }) {
188
- const t = e, r = s, o = h(!1), c = h(!1), y = h(null), v = h(null), f = h(null), S = h({
189
- position: "absolute",
190
- bottom: "100%",
191
- left: "0",
192
- marginBottom: "10px",
193
- zIndex: "180"
194
- });
195
- G(() => {
196
- y.value && (f.value = y.value.closest(".ss-bar"));
197
- });
198
- function R() {
199
- const U = y.value, O = v.value, X = f.value;
200
- if (!U || !O || !X) return;
201
- const z = U.getBoundingClientRect(), W = X.getBoundingClientRect(), ee = z.left - W.left + z.width / 2;
202
- S.value = {
203
- position: "absolute",
204
- bottom: "100%",
205
- left: `${ee}px`,
206
- transform: "translateX(-50%)",
207
- marginBottom: "10px",
208
- zIndex: "180"
209
- }, requestAnimationFrame(() => {
210
- if (!v.value) return;
211
- const T = v.value.getBoundingClientRect();
212
- let d = 0;
213
- T.left < 8 ? d = 8 - T.left : T.right > window.innerWidth - 8 && (d = window.innerWidth - 8 - T.right), d && (S.value = {
214
- ...S.value,
215
- transform: `translateX(calc(-50% + ${d}px))`
216
- });
217
- });
218
- }
219
- const P = p(() => o.value || c.value);
220
- J(P, (U) => {
221
- U && ye(R);
222
- });
223
- let b = null;
224
- function u() {
225
- P.value && R();
226
- }
227
- function H() {
228
- P.value && R();
229
- }
230
- G(() => {
231
- b = y.value?.closest(".ss-bar-scroll") ?? null, b?.addEventListener("scroll", u), window.addEventListener("resize", H);
232
- }), ce(() => {
233
- b?.removeEventListener("scroll", u), window.removeEventListener("resize", H);
234
- });
235
- const g = p(() => t.stats ? (t.metric.value || t.metric.format)(t.stats) : "..."), I = p(() => !t.stats || !t.metric.color ? "green" : t.metric.color(t.stats)), x = p(() => !t.stats || !t.metric.show ? !0 : t.metric.show(t.stats)), A = p(() => t.metric.detail ? typeof t.metric.detail == "function" ? t.stats ? t.metric.detail(t.stats) : "" : t.metric.detail : ""), N = p(() => ({
236
- green: "#34d399",
237
- amber: "#fbbf24",
238
- red: "#f87171",
239
- muted: "#737373"
240
- })[I.value] || "#34d399"), q = p(() => Be(t.history));
241
- function m() {
242
- o.value = !0;
243
- }
244
- function L() {
245
- o.value = !1;
246
- }
247
- function M() {
248
- c.value = !c.value, c.value && r("pin", t.metric.id);
249
- }
250
- function D() {
251
- c.value = !1;
252
- }
253
- function K(U) {
254
- U.key === "Enter" && M();
255
- }
256
- function F(U) {
257
- const O = U.target;
258
- y.value && !y.value.contains(O) && v.value && !v.value.contains(O) && (c.value = !1);
259
- }
260
- function Q(U) {
261
- U.key === "Escape" && (c.value = !1);
262
- }
263
- return J(c, (U) => {
264
- U ? (document.addEventListener("click", F), document.addEventListener("keydown", Q)) : (document.removeEventListener("click", F), document.removeEventListener("keydown", Q));
265
- }), ce(() => {
266
- document.removeEventListener("click", F), document.removeEventListener("keydown", Q);
267
- }), (U, O) => (a(), l(V, null, [
268
- x.value ? (a(), l("div", {
269
- key: 0,
270
- ref_key: "badgeRef",
271
- ref: y,
272
- id: `ss-b-${e.metric.id}`,
273
- class: B(["ss-badge", { "ss-pinned": c.value }]),
274
- role: "button",
275
- tabindex: 0,
276
- onMouseenter: m,
277
- onMouseleave: L,
278
- onClick: M,
279
- onKeydown: K
280
- }, [
281
- i("span", Xe, _(e.metric.label), 1),
282
- i("span", {
283
- class: B(["ss-value", `ss-${I.value}`])
284
- }, _(g.value), 3)
285
- ], 42, Ke)) : k("", !0),
286
- P.value && f.value ? (a(), j(we, {
287
- key: 1,
288
- to: f.value
289
- }, [
290
- i("div", {
291
- ref_key: "tooltipRef",
292
- ref: v,
293
- class: B(["ss-tooltip", { "ss-pinned": c.value }]),
294
- style: me(S.value)
295
- }, [
296
- i("div", Ye, [
297
- c.value ? (a(), l("button", {
298
- key: 0,
299
- class: "ss-tooltip-close",
300
- onClick: Ce(D, ["stop"])
301
- }, "×")) : k("", !0),
302
- i("div", Ze, [
303
- i("span", et, _(e.metric.title), 1),
304
- e.metric.unit ? (a(), l("span", tt, _(e.metric.unit), 1)) : k("", !0)
305
- ]),
306
- i("div", st, [
307
- O[0] || (O[0] = i("span", { class: "ss-tooltip-current-label" }, "Current: ", -1)),
308
- i("span", at, _(g.value), 1)
309
- ]),
310
- q.value ? (a(), l("div", nt, [
311
- i("span", null, "Min: " + _(n(ie)(q.value.min, e.metric.unit)), 1),
312
- i("span", null, "Max: " + _(n(ie)(q.value.max, e.metric.unit)), 1),
313
- i("span", null, "Avg: " + _(n(ie)(q.value.avg, e.metric.unit)), 1)
314
- ])) : k("", !0),
315
- A.value ? (a(), l("div", ot, _(A.value), 1)) : k("", !0),
316
- e.history.length > 0 ? (a(), l("div", lt, [
317
- ue(We, {
318
- data: e.history,
319
- color: N.value
320
- }, null, 8, ["data", "color"])
321
- ])) : k("", !0),
322
- e.history.length > 0 ? (a(), l("div", it, " Last " + _(Math.min(e.history.length, 60)) + " samples (~" + _(Math.round(Math.min(e.history.length, 60) * 3 / 60)) + " min) ", 1)) : k("", !0)
323
- ]),
324
- O[1] || (O[1] = i("div", { class: "ss-tooltip-arrow" }, null, -1))
325
- ], 6)
326
- ], 8, ["to"])) : k("", !0)
327
- ], 64));
328
- }
329
- }), ut = ["data-ss-theme"], dt = { class: "ss-bar-left" }, ct = ["viewBox", "innerHTML"], ht = { class: "ss-group" }, vt = {
330
- key: 0,
331
- class: "ss-group-sep"
332
- }, bt = ["data-ss-theme", "title"], gt = {
333
- key: 0,
334
- class: "ss-toggle-summary",
335
- style: { display: "flex" }
336
- }, pt = {
337
- key: 1,
338
- class: "ss-value ss-green"
339
- }, ft = {
340
- key: 1,
341
- class: "ss-toggle-label",
342
- style: { color: "#737373" }
343
- }, mt = { class: "ss-toggle-arrow" }, ge = "admin:stats-bar", ms = /* @__PURE__ */ Z({
344
- __name: "StatsBar",
345
- props: {
346
- debugEndpoint: { default: "/admin/api/debug" },
347
- baseUrl: { default: "" },
348
- endpoint: { default: "/admin/api/server-stats" },
349
- channelName: { default: "admin/server-stats" },
350
- authToken: {},
351
- pollInterval: { default: 3e3 },
352
- className: {},
353
- debugPanelOpen: { type: Boolean, default: !1 }
354
- },
355
- emits: ["openDebugPanel", "connectionChange"],
356
- setup(e, { emit: s }) {
357
- const t = e, r = s, { stats: o, history: c, isStale: y, isUnauthorized: v, isConnected: f, connectionMode: S } = qe({
358
- baseUrl: t.baseUrl,
359
- endpoint: t.endpoint,
360
- channelName: t.channelName,
361
- authToken: t.authToken,
362
- pollInterval: t.pollInterval
363
- });
364
- J(f, (L) => {
365
- r("connectionChange", L);
366
- });
367
- const { features: R } = de({
368
- baseUrl: t.baseUrl,
369
- debugEndpoint: t.debugEndpoint,
370
- authToken: t.authToken
371
- }), { theme: P } = oe(), b = h(!0), u = h(null);
372
- G(() => {
373
- b.value = localStorage.getItem(ge) !== "hidden";
374
- const L = u.value;
375
- if (L) {
376
- const M = (D) => {
377
- Math.abs(D.deltaX) > Math.abs(D.deltaY) || (D.preventDefault(), L.scrollLeft += D.deltaY);
378
- };
379
- L.addEventListener("wheel", M, { passive: !1 }), Y(() => L.removeEventListener("wheel", M));
380
- }
381
- });
382
- function H() {
383
- b.value = !b.value, localStorage.setItem(ge, b.value ? "visible" : "hidden");
384
- }
385
- J(v, (L) => {
386
- L && (b.value = !1);
387
- });
388
- const g = p(() => o.value ? Pe(o.value) : Re(R.value)), I = p(() => {
389
- const L = De();
390
- return Array.from(L.entries()).filter(([M]) => g.value.has(M)).map(([M, D]) => ({
391
- name: M,
392
- metrics: D
393
- }));
394
- });
395
- function x(L) {
396
- return L ? c[L] || [] : [];
397
- }
398
- const A = p(() => o.value ? `${o.value.cpuPercent.toFixed(0)}%` : "..."), N = p(() => o.value ? o.value.memHeapUsed !== void 0 ? Math.round(o.value.memHeapUsed / (1024 * 1024)) + "M" : "-" : "..."), q = p(() => o.value ? o.value.redisOk ? "✓" : "✗" : "..."), m = p(() => P.value);
399
- return (L, M) => (a(), l(V, null, [
400
- n(v) ? k("", !0) : (a(), l("div", {
401
- key: 0,
402
- id: "ss-bar",
403
- class: B(["ss-bar", { "ss-hidden": !b.value }]),
404
- "data-ss-theme": m.value
405
- }, [
406
- i("div", dt, [
407
- n(R).tracing || g.value.has("redis") || g.value.has("queue") ? (a(), l("button", {
408
- key: 0,
409
- type: "button",
410
- class: B(["ss-dbg-btn", { "ss-dbg-active": e.debugPanelOpen }]),
411
- title: "Toggle debug panel",
412
- id: "ss-dbg-wrench",
413
- onClick: M[0] || (M[0] = (D) => r("openDebugPanel"))
414
- }, [
415
- (a(), l("svg", {
416
- width: "14",
417
- height: "14",
418
- viewBox: n($).wrench.viewBox,
419
- fill: "none",
420
- stroke: "currentColor",
421
- "stroke-width": "2",
422
- "stroke-linecap": "round",
423
- "stroke-linejoin": "round",
424
- innerHTML: n($).wrench.elements.join("")
425
- }, null, 8, ct))
426
- ], 2)) : k("", !0),
427
- i("div", {
428
- class: B(["ss-dot", { "ss-stale": n(y) }])
429
- }, null, 2)
430
- ]),
431
- i("div", {
432
- ref_key: "scrollRef",
433
- ref: u,
434
- id: "ss-bar-scroll",
435
- class: "ss-bar-scroll"
436
- }, [
437
- (a(!0), l(V, null, se(I.value, (D, K) => (a(), l(V, {
438
- key: D.name
439
- }, [
440
- i("div", ht, [
441
- (a(!0), l(V, null, se(D.metrics, (F) => (a(), j(rt, {
442
- key: F.id,
443
- metric: F,
444
- stats: n(o),
445
- history: x(F.historyKey)
446
- }, null, 8, ["metric", "stats", "history"]))), 128))
447
- ]),
448
- K < I.value.length - 1 ? (a(), l("div", vt)) : k("", !0)
449
- ], 64))), 128))
450
- ], 512)
451
- ], 10, ut)),
452
- n(v) ? k("", !0) : (a(), l("button", {
453
- key: 1,
454
- type: "button",
455
- class: B(["ss-toggle", b.value ? "ss-visible" : "ss-collapsed"]),
456
- "data-ss-theme": m.value,
457
- title: b.value ? "Hide stats bar" : "Show stats bar",
458
- onClick: H
459
- }, [
460
- !b.value && n(o) ? (a(), l("span", gt, [
461
- g.value.has("process") ? (a(), l("span", {
462
- key: 0,
463
- class: B([
464
- "ss-value",
465
- n(o).cpuPercent > 80 ? "ss-red" : n(o).cpuPercent > 50 ? "ss-amber" : "ss-green"
466
- ])
467
- }, _(A.value), 3)) : k("", !0),
468
- g.value.has("process") ? (a(), l("span", pt, _(N.value), 1)) : k("", !0),
469
- g.value.has("redis") && n(o)?.redisOk !== void 0 ? (a(), l("span", {
470
- key: 2,
471
- class: B(["ss-value", n(o)?.redisOk ? "ss-green" : "ss-red"])
472
- }, _(q.value), 3)) : k("", !0)
473
- ])) : k("", !0),
474
- b.value ? (a(), l("span", ft, "hide stats")) : k("", !0),
475
- i("span", mt, _(b.value ? "▼" : "▲"), 1)
476
- ], 10, bt))
477
- ], 64));
478
- }
479
- }), pe = /* @__PURE__ */ new Set(["cache", "jobs", "config"]);
480
- function fe(e) {
481
- return {
482
- onData: (s) => {
483
- e.data.value = s;
484
- },
485
- onLoading: (s) => {
486
- e.loading.value = s;
487
- },
488
- onError: (s) => {
489
- e.error.value = s;
490
- },
491
- onUnauthorized: () => {
492
- e.isUnauthorized.value = !0;
493
- }
494
- };
495
- }
496
- class kt {
497
- constructor(s, t, r, o) {
498
- this.refs = s, this.config = t, this.dashboardEndpoint = o, this.controller = new be({
499
- ...t,
500
- endpoint: r,
501
- ...fe(s)
502
- });
503
- }
504
- controller;
505
- dashboardController = null;
506
- dashboardEndpoint;
507
- getDashboardController() {
508
- return !this.dashboardController && this.dashboardEndpoint && (this.dashboardController = new be({
509
- ...this.config,
510
- endpoint: this.dashboardEndpoint,
511
- ...fe(this.refs)
512
- })), this.dashboardController;
513
- }
514
- startForTab(s) {
515
- const t = s();
516
- !t || t.startsWith("custom-") || (pe.has(t) && this.dashboardEndpoint ? (this.controller.stop(), this.getDashboardController().start(t)) : (this.dashboardController?.stop(), this.controller.start(t)));
517
- }
518
- stopAll() {
519
- this.controller.stop(), this.dashboardController?.stop();
520
- }
521
- refresh(s) {
522
- const t = s();
523
- pe.has(t) && this.dashboardEndpoint && this.dashboardController ? this.dashboardController.refresh() : this.controller.refresh();
524
- }
525
- fetchCustomPane(s, t = !1) {
526
- return this.controller.fetchCustomPane(s, t);
527
- }
528
- }
529
- function yt(e, s = {}) {
530
- const {
531
- baseUrl: t = "",
532
- debugEndpoint: r = "/admin/api/debug",
533
- dashboardEndpoint: o,
534
- authToken: c,
535
- refreshInterval: y
536
- } = s, v = h(null), f = h(!1), S = h(null), R = h(!1), P = { data: v, loading: f, error: S, isUnauthorized: R }, b = new kt(
537
- P,
538
- { baseUrl: t, authToken: c, refreshInterval: y },
539
- r,
540
- o
541
- );
542
- return J(e, () => {
543
- v.value = null, b.startForTab(e);
544
- }), G(() => b.startForTab(e)), Y(() => b.stopAll()), {
545
- data: v,
546
- loading: f,
547
- error: S,
548
- isUnauthorized: R,
549
- refresh: () => b.refresh(e),
550
- clear: () => {
551
- v.value = null;
552
- },
553
- fetchCustomPane: (u, H = !1) => b.fetchCustomPane(u, H),
554
- startRefresh: () => b.startForTab(e),
555
- stopRefresh: () => b.stopAll()
556
- };
557
- }
558
- const wt = ["title", "aria-label"], Ct = ["viewBox", "innerHTML"], Tt = ["viewBox", "innerHTML"], ke = /* @__PURE__ */ Z({
559
- __name: "ThemeToggle",
560
- props: {
561
- classPrefix: { default: "ss-dbg" }
562
- },
563
- setup(e) {
564
- const s = e, { theme: t, toggleTheme: r } = oe(), o = p(() => t.value === "dark"), c = p(() => o.value ? "Switch to light theme" : "Switch to dark theme"), y = p(
565
- () => s.classPrefix === "ss-dbg" ? "ss-dbg-theme-toggle" : "ss-dash-theme-btn"
566
- );
567
- return (v, f) => (a(), l("button", {
568
- type: "button",
569
- class: B(y.value),
570
- title: c.value,
571
- "aria-label": c.value,
572
- onClick: f[0] || (f[0] = //@ts-ignore
573
- (...S) => n(r) && n(r)(...S))
574
- }, [
575
- o.value ? (a(), l("svg", {
576
- key: 0,
577
- width: "16",
578
- height: "16",
579
- viewBox: n($).sun.viewBox,
580
- fill: "none",
581
- stroke: "currentColor",
582
- "stroke-width": "2",
583
- "stroke-linecap": "round",
584
- "stroke-linejoin": "round",
585
- innerHTML: n($).sun.elements.join("")
586
- }, null, 8, Ct)) : (a(), l("svg", {
587
- key: 1,
588
- width: "16",
589
- height: "16",
590
- viewBox: n($).moon.viewBox,
591
- fill: "none",
592
- stroke: "currentColor",
593
- "stroke-width": "2",
594
- "stroke-linecap": "round",
595
- "stroke-linejoin": "round",
596
- innerHTML: n($).moon.elements.join("")
597
- }, null, 8, Tt))
598
- ], 10, wt));
599
- }
600
- }), _t = ["data-ss-theme"], Et = { class: "ss-dbg-tabs" }, St = { class: "ss-dbg-tabs-scroll" }, xt = ["onClick"], $t = ["viewBox", "innerHTML"], Lt = { class: "ss-dbg-tabs-right" }, Mt = ["title"], Ut = ["href"], Bt = ["viewBox", "innerHTML"], Pt = { class: "ss-dbg-content" }, Rt = {
601
- key: 0,
602
- class: "ss-dbg-empty"
603
- }, Dt = {
604
- key: 1,
605
- class: "ss-dbg-empty",
606
- style: { color: "var(--ss-red-fg)" }
607
- }, ks = /* @__PURE__ */ Z({
608
- __name: "DebugPanel",
609
- props: {
610
- dashboardPath: { default: "/__stats" },
611
- tracingEnabled: { type: Boolean, default: !1 },
612
- isLive: { type: Boolean, default: !1 },
613
- baseUrl: { default: "" },
614
- debugEndpoint: { default: "/admin/api/debug" },
615
- authToken: {},
616
- className: {},
617
- defaultOpen: { type: Boolean, default: !1 }
618
- },
619
- setup(e, { expose: s }) {
620
- const t = E(() => import("./QueriesTab-DO5XwJ--.js")), r = E(() => import("./EventsTab-BBM7olXF.js")), o = E(() => import("./EmailsTab-CwIF1fik.js")), c = E(() => import("./RoutesTab-Dz0MkZuF.js")), y = E(() => import("./LogsTab-47zEK7jL.js")), v = E(() => import("./TimelineTab-DHfXsX7t.js")), f = E(() => import("./CacheTab-BPisYYiQ.js")), S = E(() => import("./JobsTab-WFnxPdN7.js")), R = E(() => import("./ConfigTab-C8cafGUj.js")), P = E(() => import("./InternalsTab-521fxYYj.js")), b = E(() => import("./CustomPaneTab-Hr1IBHfz.js")), u = e, H = h(u.defaultOpen), g = h("queries"), { theme: I } = oe(), { features: x } = de({
621
- baseUrl: u.baseUrl,
622
- debugEndpoint: u.debugEndpoint,
623
- authToken: u.authToken
624
- }), A = u.dashboardPath ? u.dashboardPath.replace(/\/+$/, "") + "/api" : void 0, N = p(() => g.value.startsWith("custom-")), q = p(() => N.value || g.value === "internals"), { data: m, loading: L, error: M, isUnauthorized: D, refresh: K, startRefresh: F, stopRefresh: Q } = yt(
625
- () => g.value,
626
- {
627
- baseUrl: u.baseUrl,
628
- debugEndpoint: u.debugEndpoint,
629
- dashboardEndpoint: A,
630
- authToken: u.authToken
631
- }
632
- ), U = p(() => {
633
- const T = [
634
- { id: "queries", label: "Queries", icon: "Q" },
635
- { id: "events", label: "Events", icon: "E" },
636
- { id: "emails", label: "Emails", icon: "M" },
637
- { id: "routes", label: "Routes", icon: "R" },
638
- { id: "logs", label: "Logs", icon: "L" }
639
- ];
640
- (x.value.tracing || u.tracingEnabled) && T.push({ id: "timeline", label: "Requests", icon: "R" }), x.value.cache && T.push({ id: "cache", label: "Cache", icon: "C" }), x.value.queues && T.push({ id: "jobs", label: "Jobs", icon: "J" }), T.push({ id: "config", label: "Config", icon: "G" }), T.push({ id: "internals", label: "Internals", icon: "I" });
641
- for (const d of x.value.customPanes)
642
- T.push({
643
- id: `custom-${d.id}`,
644
- label: d.label,
645
- icon: d.label.charAt(0).toUpperCase()
646
- });
647
- return T;
648
- });
649
- function O(T) {
650
- const d = T.replace("custom-", "");
651
- return x.value.customPanes.find((w) => w.id === d);
652
- }
653
- function X() {
654
- H.value = !0, F();
655
- }
656
- function z() {
657
- H.value = !1, Q();
658
- }
659
- function W() {
660
- H.value ? z() : X();
661
- }
662
- function ee(T) {
663
- g.value = T;
664
- }
665
- return J(H, (T) => {
666
- T ? F() : Q();
667
- }), s({ toggle: W, open: X, close: z }), (T, d) => n(D) ? k("", !0) : (a(), l("div", {
668
- key: 0,
669
- class: B(["ss-dbg-panel", { "ss-dbg-open": H.value }]),
670
- "data-ss-theme": n(I)
671
- }, [
672
- i("div", Et, [
673
- i("div", St, [
674
- (a(!0), l(V, null, se(U.value, (w) => (a(), l("button", {
675
- key: w.id,
676
- type: "button",
677
- class: B(["ss-dbg-tab", { "ss-dbg-active": g.value === w.id }]),
678
- onClick: (C) => ee(w.id)
679
- }, [
680
- n($)[w.id] ? (a(), l("svg", {
681
- key: 0,
682
- class: "ss-dbg-tab-icon",
683
- viewBox: n($)[w.id].viewBox,
684
- innerHTML: n($)[w.id].elements.join("")
685
- }, null, 8, $t)) : k("", !0),
686
- Te(" " + _(w.label), 1)
687
- ], 10, xt))), 128))
688
- ]),
689
- i("div", Lt, [
690
- i("span", {
691
- class: B(["ss-dbg-conn-mode", e.isLive ? "ss-dbg-conn-live" : "ss-dbg-conn-polling"]),
692
- title: e.isLive ? "Connected via Transmit (SSE) — real-time updates" : "Polling every 3s"
693
- }, _(e.isLive ? "live" : "polling"), 11, Mt),
694
- e.dashboardPath && n(x).dashboard ? (a(), l("a", {
695
- key: 0,
696
- href: e.dashboardPath,
697
- target: "_blank",
698
- rel: "noopener noreferrer",
699
- class: "ss-dbg-dashboard-link",
700
- title: "Open dashboard"
701
- }, [
702
- (a(), l("svg", {
703
- width: "14",
704
- height: "14",
705
- viewBox: n($)["external-link"].viewBox,
706
- fill: "none",
707
- stroke: "currentColor",
708
- "stroke-width": "2",
709
- "stroke-linecap": "round",
710
- "stroke-linejoin": "round",
711
- innerHTML: n($)["external-link"].elements.join("")
712
- }, null, 8, Bt))
713
- ], 8, Ut)) : k("", !0),
714
- ue(ke),
715
- i("button", {
716
- type: "button",
717
- class: "ss-dbg-close",
718
- onClick: z,
719
- title: "Close panel"
720
- }, " × ")
721
- ])
722
- ]),
723
- i("div", Pt, [
724
- n(L) && !n(m) && !q.value ? (a(), l("div", Rt, "Loading...")) : n(M) && !q.value ? (a(), l("div", Dt, " Error: " + _(n(M).message), 1)) : (a(), l(V, { key: 2 }, [
725
- g.value === "queries" ? (a(), j(n(t), {
726
- key: 0,
727
- data: n(m),
728
- "dashboard-path": e.dashboardPath
729
- }, null, 8, ["data", "dashboard-path"])) : g.value === "events" ? (a(), j(n(r), {
730
- key: 1,
731
- data: n(m),
732
- "dashboard-path": e.dashboardPath
733
- }, null, 8, ["data", "dashboard-path"])) : g.value === "emails" ? (a(), j(n(o), {
734
- key: 2,
735
- data: n(m),
736
- "dashboard-path": e.dashboardPath,
737
- "debug-endpoint": e.debugEndpoint,
738
- "auth-token": e.authToken
739
- }, null, 8, ["data", "dashboard-path", "debug-endpoint", "auth-token"])) : g.value === "routes" ? (a(), j(n(c), {
740
- key: 3,
741
- data: n(m)
742
- }, null, 8, ["data"])) : g.value === "logs" ? (a(), j(n(y), {
743
- key: 4,
744
- data: n(m),
745
- "dashboard-path": e.dashboardPath
746
- }, null, 8, ["data", "dashboard-path"])) : g.value === "timeline" ? (a(), j(n(v), {
747
- key: 5,
748
- data: n(m),
749
- "dashboard-path": e.dashboardPath,
750
- "base-url": e.baseUrl,
751
- "debug-endpoint": e.debugEndpoint,
752
- "auth-token": e.authToken
753
- }, null, 8, ["data", "dashboard-path", "base-url", "debug-endpoint", "auth-token"])) : g.value === "cache" ? (a(), j(n(f), {
754
- key: 6,
755
- data: n(m)
756
- }, null, 8, ["data"])) : g.value === "jobs" ? (a(), j(n(S), {
757
- key: 7,
758
- data: n(m)
759
- }, null, 8, ["data"])) : g.value === "config" ? (a(), j(n(R), {
760
- key: 8,
761
- data: n(m)
762
- }, null, 8, ["data"])) : g.value === "internals" ? (a(), j(n(P), {
763
- key: 9,
764
- data: n(m),
765
- "base-url": e.baseUrl,
766
- "debug-endpoint": e.debugEndpoint,
767
- "auth-token": e.authToken
768
- }, null, 8, ["data", "base-url", "debug-endpoint", "auth-token"])) : g.value.startsWith("custom-") ? (a(), j(n(b), {
769
- key: 10,
770
- pane: O(g.value),
771
- "base-url": e.baseUrl,
772
- "auth-token": e.authToken
773
- }, null, 8, ["pane", "base-url", "auth-token"])) : k("", !0)
774
- ], 64))
775
- ])
776
- ], 10, _t));
777
- }
778
- });
779
- function Ht(e) {
780
- let s = null;
781
- return {
782
- onData: (t) => {
783
- s = t;
784
- },
785
- onPagination: (t) => {
786
- t ? (e.pagination.total = t.total, e.pagination.totalPages = t.lastPage ?? (Math.ceil(t.total / e.pagination.perPage) || 1), e.data.value = { data: s, meta: t }) : e.data.value = s;
787
- },
788
- onLoading: (t) => {
789
- e.loading.value = t;
790
- },
791
- onError: (t) => {
792
- e.error.value = t;
793
- },
794
- onUnauthorized: () => {
795
- e.isUnauthorized.value = !0;
796
- }
797
- };
798
- }
799
- function At(e) {
800
- const s = {};
801
- for (const [t, r] of Object.entries(e))
802
- t !== "search" && r !== "" && r !== void 0 && r !== null && (s[t] = String(r));
803
- return s;
804
- }
805
- async function re(e) {
806
- try {
807
- return await e();
808
- } catch {
809
- return null;
810
- }
811
- }
812
- function jt(e) {
813
- return {
814
- fetchGroupedQueries: () => re(() => e.fetchGroupedQueries()),
815
- explainQuery: (s) => re(() => e.explainQuery(s)),
816
- fetchEmailPreview: async (s) => (await re(() => e.fetchEmailPreview(s)))?.html || null
817
- };
818
- }
819
- function zt(e) {
820
- return {
821
- retryJob: async (s) => {
822
- try {
823
- return await e.retryJob(s), !0;
824
- } catch {
825
- return !1;
826
- }
827
- },
828
- deleteCacheKey: async (s) => {
829
- try {
830
- return await e.deleteCacheKey(s), !0;
831
- } catch {
832
- return !1;
833
- }
834
- }
835
- };
836
- }
837
- function It(e, s) {
838
- return {
839
- fetchChart: async (t) => {
840
- try {
841
- return await e.fetchChart(t);
842
- } catch (r) {
843
- return r instanceof Ae && (s.value = !0), null;
844
- }
845
- }
846
- };
847
- }
848
- function ae(e, s, t) {
849
- const r = s(), o = At(t.filter);
850
- e.configure({
851
- page: t.pagination.page,
852
- perPage: t.pagination.perPage,
853
- search: t.filter.search || void 0,
854
- sort: t.sort.column || void 0,
855
- sortDir: t.sort.column ? t.sort.direction : void 0,
856
- filters: Object.keys(o).length > 0 ? o : void 0,
857
- timeRange: r.startsWith("overview") ? t.timeRange.value : void 0
858
- });
859
- }
860
- function qt(e, s) {
861
- return {
862
- goToPage(t) {
863
- e.pagination.page = t, s();
864
- },
865
- setSearch(t) {
866
- e.filter.search = t, e.pagination.page = 1, s();
867
- },
868
- setFilter(t, r) {
869
- e.filter[t] = r, e.pagination.page = 1, s();
870
- },
871
- setSort(t, r) {
872
- e.sort.column === t && !r ? e.sort.direction = e.sort.direction === "asc" ? "desc" : "asc" : (e.sort.column = t, e.sort.direction = r || "desc"), s();
873
- },
874
- setTimeRange(t) {
875
- e.timeRange.value = t, s();
876
- }
877
- };
878
- }
879
- function Ot(e, s, t) {
880
- return {
881
- async mutate(r, o = "post", c) {
882
- return e.mutate(r, o, c);
883
- },
884
- refresh() {
885
- ae(e, s, t), e.fetch(!0);
886
- },
887
- startRefresh() {
888
- e.start();
889
- },
890
- stopRefresh() {
891
- e.stop();
892
- }
893
- };
894
- }
895
- function Nt(e, s, t, r) {
896
- J(s, () => {
897
- t.pagination.page = 1;
898
- for (const o of Object.keys(t.filter))
899
- o === "search" ? t.filter.search = "" : delete t.filter[o];
900
- t.sort.column = "", t.data.value = null, e.setSection(s()), ae(e, s, t);
901
- }), r && J(r, () => {
902
- ae(e, s, t), e.handleRefreshSignal();
903
- });
904
- }
905
- function Ft(e) {
906
- return {
907
- data: h(null),
908
- loading: h(!1),
909
- error: h(null),
910
- isUnauthorized: h(!1),
911
- timeRange: h("1h"),
912
- pagination: ne({ page: 1, perPage: e, total: 0, totalPages: 1 }),
913
- filter: ne({ search: "" }),
914
- sort: ne({
915
- column: "",
916
- direction: "desc"
917
- })
918
- };
919
- }
920
- function Vt(e, s, t, r) {
921
- return {
922
- data: e.data,
923
- loading: e.loading,
924
- error: e.error,
925
- isUnauthorized: e.isUnauthorized,
926
- pagination: e.pagination,
927
- filter: e.filter,
928
- sort: e.sort,
929
- timeRange: e.timeRange,
930
- ...s,
931
- ...t,
932
- ...r
933
- };
934
- }
935
- function Gt(e, s = {}) {
936
- const {
937
- baseUrl: t = "",
938
- dashboardEndpoint: r = "/__stats/api",
939
- authToken: o,
940
- perPage: c = 50,
941
- refreshKey: y
942
- } = s, v = Ft(c), f = new He({
943
- baseUrl: t,
944
- endpoint: r,
945
- authToken: o,
946
- section: e(),
947
- perPage: c,
948
- callbacks: Ht(v)
949
- }), S = f.getApi(), P = qt(v, () => {
950
- ae(f, e, v), f.fetch(!1);
951
- }), b = Ot(f, e, v), u = {
952
- ...It(S, v.isUnauthorized),
953
- ...jt(S),
954
- ...zt(S)
955
- };
956
- return Nt(f, e, v, y), G(() => {
957
- ae(f, e, v), f.start();
958
- }), Y(() => {
959
- f.stop();
960
- }), Vt(v, P, b, u);
961
- }
962
- const Qt = ["data-theme"], Jt = { class: "ss-dash-header" }, Wt = { class: "ss-dash-header-center" }, Kt = { class: "ss-dash-header-right" }, Xt = ["href"], Yt = { class: "ss-dash-body" }, Zt = { class: "ss-dash-nav" }, es = ["data-ss-section", "onClick", "title"], ts = { class: "ss-dash-nav-icon" }, ss = ["viewBox", "innerHTML"], as = { class: "ss-dash-nav-label" }, ns = {
963
- key: 0,
964
- class: "ss-dash-nav-sep"
965
- }, os = ["onClick", "title"], ls = { class: "ss-dash-nav-icon" }, is = ["viewBox", "innerHTML"], rs = { class: "ss-dash-nav-label" }, us = ["title"], ds = ["viewBox", "innerHTML"], cs = ["viewBox", "innerHTML"], hs = { class: "ss-dash-main" }, vs = ["id"], bs = { class: "ss-dash-pane-inner" }, gs = {
966
- key: 1,
967
- class: "ss-dash-empty"
968
- }, ys = /* @__PURE__ */ Z({
969
- __name: "DashboardPage",
970
- props: {
971
- baseUrl: { default: "" },
972
- dashboardEndpoint: { default: "/__stats/api" },
973
- debugEndpoint: { default: void 0 },
974
- authToken: { default: void 0 },
975
- backUrl: { default: "/" },
976
- channelName: { default: "server-stats/dashboard" }
977
- },
978
- setup(e) {
979
- const s = E(() => import("./OverviewSection-BAgZTPjY.js")), t = E(() => import("./RequestsSection-D8P2xpF2.js")), r = E(() => import("./QueriesSection-CUpwhp7u.js")), o = E(() => import("./EventsSection-BpgkWIwM.js")), c = E(() => import("./RoutesSection-0qB81hTT.js")), y = E(() => import("./LogsSection-BDxx9Bfi.js")), v = E(() => import("./EmailsSection-BTNw3ZU2.js")), f = E(() => import("./CacheSection-DRqV3YX2.js")), S = E(() => import("./JobsSection-DrghFEKL.js")), R = E(() => import("./ConfigSection-C6pQCHAL.js")), P = E(() => import("./InternalsSection-jhTCuK3j.js")), b = [
980
- "overview",
981
- "requests",
982
- "queries",
983
- "events",
984
- "routes",
985
- "logs",
986
- "emails",
987
- "cache",
988
- "jobs",
989
- "config",
990
- "internals"
991
- ], u = e, { theme: H, toggleTheme: g } = oe(), { features: I } = de({
992
- baseUrl: u.baseUrl,
993
- debugEndpoint: u.debugEndpoint,
994
- authToken: u.authToken
995
- }), x = h("overview"), A = h(!1), N = h(!1), q = h(0);
996
- te("ss-refresh-key", q), te("ss-base-url", u.baseUrl), te("ss-dashboard-endpoint", u.dashboardEndpoint), te("ss-debug-endpoint", u.debugEndpoint), te("ss-auth-token", u.authToken), typeof window < "u" && (A.value = localStorage.getItem("ss-dash-sidebar") === "collapsed");
997
- let m = null;
998
- function L() {
999
- if (m && (m(), m = null), !u.channelName) return;
1000
- m = je({
1001
- baseUrl: u.baseUrl,
1002
- channelName: u.channelName,
1003
- authToken: u.authToken,
1004
- onMessage: () => {
1005
- q.value += 1;
1006
- },
1007
- onConnect: () => {
1008
- N.value = !0;
1009
- },
1010
- onDisconnect: () => {
1011
- N.value = !1;
1012
- },
1013
- onError: () => {
1014
- N.value = !1;
1015
- }
1016
- }).unsubscribe;
1017
- }
1018
- G(() => {
1019
- L();
1020
- }), Y(() => {
1021
- m && (m(), m = null);
1022
- });
1023
- const M = p(() => I.value.customPanes || []);
1024
- function D(d) {
1025
- const w = d.replace("#", "").split("?")[0];
1026
- return w && [...b, ...M.value.map((le) => le.id)].includes(w) ? w : "overview";
1027
- }
1028
- function K() {
1029
- const d = D(window.location.hash);
1030
- d !== x.value && (x.value = d);
1031
- }
1032
- G(() => {
1033
- if (typeof window > "u") return;
1034
- const d = D(window.location.hash);
1035
- (d !== "overview" || window.location.hash) && (x.value = d), window.addEventListener("hashchange", K);
1036
- }), Y(() => {
1037
- window.removeEventListener("hashchange", K);
1038
- }), J(x, (d) => {
1039
- typeof window < "u" && (window.location.hash = d);
1040
- });
1041
- function F() {
1042
- A.value = !A.value, localStorage.setItem("ss-dash-sidebar", A.value ? "collapsed" : "expanded");
1043
- }
1044
- function Q(d) {
1045
- d !== x.value && (x.value = d);
1046
- }
1047
- const U = p(() => [
1048
- { id: "overview", label: "Overview", visible: !0 },
1049
- { id: "requests", label: "Requests", visible: !0 },
1050
- { id: "queries", label: "Queries", visible: !0 },
1051
- { id: "events", label: "Events", visible: !0 },
1052
- { id: "routes", label: "Routes", visible: !0 },
1053
- { id: "logs", label: "Logs", visible: !0 },
1054
- { id: "emails", label: "Emails", visible: !0 },
1055
- { id: "cache", label: "Cache", visible: I.value.cache },
1056
- { id: "jobs", label: "Jobs", visible: I.value.queues },
1057
- { id: "config", label: "Config", visible: !0 },
1058
- { id: "internals", label: "Internals", visible: !0 }
1059
- ]), O = p(() => U.value.filter((d) => d.visible)), { data: X } = Gt(() => "overview", {
1060
- baseUrl: u.baseUrl,
1061
- dashboardEndpoint: u.dashboardEndpoint,
1062
- authToken: u.authToken,
1063
- refreshKey: q
1064
- }), z = p(() => X.value), W = p(() => {
1065
- const d = {};
1066
- if (!z.value) return d;
1067
- if (z.value.totalRequests > 0 && (d.requests = { count: z.value.totalRequests }), z.value.queryStats?.total > 0 && (d.queries = { count: z.value.queryStats.total }), z.value.logLevelBreakdown) {
1068
- const w = z.value.logLevelBreakdown, C = w.error + w.warn + w.info + w.debug;
1069
- C > 0 && (d.logs = { count: C });
1070
- }
1071
- return d;
1072
- }), ee = {
1073
- overview: s,
1074
- requests: t,
1075
- queries: r,
1076
- events: o,
1077
- routes: c,
1078
- logs: y,
1079
- emails: v,
1080
- cache: f,
1081
- jobs: S,
1082
- config: R,
1083
- internals: P
1084
- }, T = p(() => ee[x.value] || null);
1085
- return (d, w) => (a(), l("div", {
1086
- class: "ss-dash",
1087
- "data-theme": n(H),
1088
- id: "ss-dash"
1089
- }, [
1090
- i("div", Jt, [
1091
- w[0] || (w[0] = i("div", { class: "ss-dash-header-left" }, [
1092
- i("span", { class: "ss-dash-logo" }, "Server Stats"),
1093
- i("span", { class: "ss-dash-logo-sub" }, "Dashboard")
1094
- ], -1)),
1095
- i("div", Wt, [
1096
- i("span", {
1097
- class: B(["ss-dash-live-dot", { "ss-dash-connected": N.value }]),
1098
- id: "ss-dash-live-dot"
1099
- }, null, 2),
1100
- i("span", {
1101
- class: B(["ss-dash-live-label", { "ss-dash-connected": N.value }]),
1102
- id: "ss-dash-live-label"
1103
- }, _(N.value ? "Live" : "Polling"), 3)
1104
- ]),
1105
- i("div", Kt, [
1106
- ue(ke, { "class-prefix": "ss-dash" }),
1107
- e.backUrl ? (a(), l("a", {
1108
- key: 0,
1109
- href: e.backUrl,
1110
- class: "ss-dash-back-link",
1111
- title: "Back to app"
1112
- }, " ← App ", 8, Xt)) : k("", !0)
1113
- ])
1114
- ]),
1115
- i("div", Yt, [
1116
- i("div", {
1117
- class: B(["ss-dash-sidebar", { "ss-dash-collapsed": A.value }]),
1118
- id: "ss-dash-sidebar"
1119
- }, [
1120
- i("nav", Zt, [
1121
- (a(!0), l(V, null, se(O.value, (C) => (a(), l("button", {
1122
- key: C.id,
1123
- type: "button",
1124
- class: B(["ss-dash-nav-item", { "ss-dash-active": x.value === C.id }]),
1125
- "data-ss-section": C.id,
1126
- onClick: (le) => Q(C.id),
1127
- title: A.value ? C.label : void 0
1128
- }, [
1129
- i("span", ts, [
1130
- (a(), l("svg", {
1131
- width: "20",
1132
- height: "20",
1133
- viewBox: (n($)[C.id] || n($).config).viewBox,
1134
- fill: "none",
1135
- stroke: "currentColor",
1136
- "stroke-width": "2",
1137
- "stroke-linecap": "round",
1138
- "stroke-linejoin": "round",
1139
- innerHTML: (n($)[C.id] || n($).config).elements.join("")
1140
- }, null, 8, ss))
1141
- ]),
1142
- i("span", as, _(C.label), 1),
1143
- W.value[C.id] && W.value[C.id].count > 0 ? (a(), l("span", {
1144
- key: 0,
1145
- class: B(["ss-dash-nav-badge", W.value[C.id].variant || ""])
1146
- }, _(W.value[C.id].count), 3)) : k("", !0)
1147
- ], 10, es))), 128)),
1148
- M.value.length > 0 ? (a(), l("div", ns)) : k("", !0),
1149
- (a(!0), l(V, null, se(M.value, (C) => (a(), l("button", {
1150
- key: C.id,
1151
- type: "button",
1152
- class: B(["ss-dash-nav-item", { "ss-dash-active": x.value === C.id }]),
1153
- onClick: (le) => Q(C.id),
1154
- title: A.value ? C.label : void 0
1155
- }, [
1156
- i("span", ls, [
1157
- (a(), l("svg", {
1158
- width: "20",
1159
- height: "20",
1160
- viewBox: n($)["custom-pane"].viewBox,
1161
- fill: "none",
1162
- stroke: "currentColor",
1163
- "stroke-width": "2",
1164
- "stroke-linecap": "round",
1165
- "stroke-linejoin": "round",
1166
- innerHTML: n($)["custom-pane"].elements.join("")
1167
- }, null, 8, is))
1168
- ]),
1169
- i("span", rs, _(C.label), 1)
1170
- ], 10, os))), 128))
1171
- ]),
1172
- i("button", {
1173
- type: "button",
1174
- class: "ss-dash-sidebar-toggle",
1175
- id: "ss-dash-sidebar-toggle",
1176
- onClick: F,
1177
- title: A.value ? "Expand sidebar" : "Collapse sidebar"
1178
- }, [
1179
- A.value ? (a(), l("svg", {
1180
- key: 0,
1181
- width: "16",
1182
- height: "16",
1183
- viewBox: n($)["chevron-right"].viewBox,
1184
- fill: "none",
1185
- stroke: "currentColor",
1186
- "stroke-width": "1.5",
1187
- innerHTML: n($)["chevron-right"].elements.join("")
1188
- }, null, 8, ds)) : (a(), l("svg", {
1189
- key: 1,
1190
- width: "16",
1191
- height: "16",
1192
- viewBox: n($)["chevron-left"].viewBox,
1193
- fill: "none",
1194
- stroke: "currentColor",
1195
- "stroke-width": "1.5",
1196
- innerHTML: n($)["chevron-left"].elements.join("")
1197
- }, null, 8, cs))
1198
- ], 8, us)
1199
- ], 2),
1200
- i("div", hs, [
1201
- i("div", {
1202
- class: "ss-dash-pane ss-dash-active",
1203
- id: `ss-dash-pane-${x.value}`
1204
- }, [
1205
- i("div", bs, [
1206
- (a(), j(_e, null, {
1207
- fallback: he(() => [...w[1] || (w[1] = [
1208
- i("div", { class: "ss-dash-empty" }, "Loading...", -1)
1209
- ])]),
1210
- default: he(() => [
1211
- T.value ? (a(), j(Ee(T.value), { key: 0 })) : (a(), l("div", gs, "Unknown section"))
1212
- ]),
1213
- _: 1
1214
- }))
1215
- ])
1216
- ], 8, vs)
1217
- ])
1218
- ])
1219
- ], 8, Qt));
1220
- }
1221
- });
1222
- export {
1223
- We as _,
1224
- ys as a,
1225
- ks as b,
1226
- ms as c,
1227
- yt as d,
1228
- de as e,
1229
- qe as f,
1230
- oe as g,
1231
- Gt as u
1232
- };