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
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Lazily loads and caches static assets (CSS, JS, transmit client)
3
+ * needed for the dashboard page.
4
+ *
5
+ * Extracted from DashboardController to reduce file size and complexity.
6
+ */
7
+ export declare class DashboardPageAssets {
8
+ private cachedCss;
9
+ private cachedJs;
10
+ private cachedTransmitClient;
11
+ /** Load and cache the combined CSS bundle. */
12
+ getCss(): string;
13
+ /** Load and cache the dashboard JS bundle for the given renderer. */
14
+ getJs(renderer: string): string;
15
+ /** Load and cache the transmit client, or return empty string. */
16
+ getTransmitClient(packageJsonPath: string): string;
17
+ }
@@ -0,0 +1,51 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { log } from '../utils/logger.js';
5
+ import { loadTransmitClient } from '../utils/transmit_client.js';
6
+ const SRC_DIR = dirname(fileURLToPath(import.meta.url));
7
+ const EDGE_DIR = join(SRC_DIR, '..', 'edge');
8
+ const STYLES_DIR = join(SRC_DIR, '..', 'styles');
9
+ /**
10
+ * Lazily loads and caches static assets (CSS, JS, transmit client)
11
+ * needed for the dashboard page.
12
+ *
13
+ * Extracted from DashboardController to reduce file size and complexity.
14
+ */
15
+ export class DashboardPageAssets {
16
+ cachedCss = null;
17
+ cachedJs = null;
18
+ cachedTransmitClient = null;
19
+ /** Load and cache the combined CSS bundle. */
20
+ getCss() {
21
+ if (!this.cachedCss) {
22
+ const tokens = readFileSync(join(STYLES_DIR, 'tokens.css'), 'utf-8');
23
+ const components = readFileSync(join(STYLES_DIR, 'components.css'), 'utf-8');
24
+ const utilities = readFileSync(join(STYLES_DIR, 'utilities.css'), 'utf-8');
25
+ const dashboard = readFileSync(join(STYLES_DIR, 'dashboard.css'), 'utf-8');
26
+ this.cachedCss = tokens + '\n' + components + '\n' + utilities + '\n' + dashboard;
27
+ }
28
+ return this.cachedCss;
29
+ }
30
+ /** Load and cache the dashboard JS bundle for the given renderer. */
31
+ getJs(renderer) {
32
+ if (!this.cachedJs) {
33
+ const clientDir = renderer === 'vue' ? 'client-vue' : 'client';
34
+ this.cachedJs = readFileSync(join(EDGE_DIR, clientDir, 'dashboard.js'), 'utf-8');
35
+ }
36
+ return this.cachedJs;
37
+ }
38
+ /** Load and cache the transmit client, or return empty string. */
39
+ getTransmitClient(packageJsonPath) {
40
+ if (this.cachedTransmitClient === null) {
41
+ this.cachedTransmitClient = loadTransmitClient(packageJsonPath);
42
+ if (this.cachedTransmitClient) {
43
+ log.info('Transmit client loaded for dashboard');
44
+ }
45
+ else {
46
+ log.info('Dashboard will use polling. Install @adonisjs/transmit-client for real-time updates.');
47
+ }
48
+ }
49
+ return this.cachedTransmitClient;
50
+ }
51
+ }
@@ -1,91 +1,8 @@
1
- import type { DevToolbarConfig } from '../debug/types.js';
2
- import type { QueryRecord, EventRecord, EmailRecord, TraceRecord } from '../debug/types.js';
1
+ import type { DevToolbarConfig, EventRecord, EmailRecord } from '../debug/types.js';
2
+ import type { StorageStatsResult } from './storage_stats.js';
3
3
  import type { Knex } from 'knex';
4
- interface EventEmitter {
5
- on(event: string, handler: (...args: unknown[]) => void): void;
6
- off(event: string, handler: (...args: unknown[]) => void): void;
7
- }
8
- export interface RequestInput {
9
- method: string;
10
- url: string;
11
- statusCode: number;
12
- duration: number;
13
- spanCount?: number;
14
- warningCount?: number;
15
- }
16
- export interface PersistRequestInput extends RequestInput {
17
- queries: QueryRecord[];
18
- trace: TraceRecord | null;
19
- httpRequestId?: string | null;
20
- }
21
- export interface RequestFilters {
22
- method?: string;
23
- url?: string;
24
- status?: number;
25
- statusMin?: number;
26
- statusMax?: number;
27
- durationMin?: number;
28
- durationMax?: number;
29
- /** General text search across method and url */
30
- search?: string;
31
- }
32
- export interface QueryFilters {
33
- method?: string;
34
- model?: string;
35
- connection?: string;
36
- durationMin?: number;
37
- durationMax?: number;
38
- requestId?: number;
39
- /** General text search across sql_text, model, and connection */
40
- search?: string;
41
- }
42
- export interface EventFilters {
43
- eventName?: string;
44
- /** General text search across event_name */
45
- search?: string;
46
- }
47
- export interface EmailFilters {
48
- /** General text search across from_addr, to_addr, and subject */
49
- search?: string;
50
- from?: string;
51
- to?: string;
52
- subject?: string;
53
- mailer?: string;
54
- status?: string;
55
- }
56
- export interface LogFilters {
57
- level?: string;
58
- requestId?: string;
59
- search?: string;
60
- /** Structured filters: array of { field, operator, value } */
61
- structured?: {
62
- field: string;
63
- operator: 'equals' | 'contains' | 'startsWith';
64
- value: string;
65
- }[];
66
- }
67
- export interface TraceFilters {
68
- method?: string;
69
- url?: string;
70
- statusMin?: number;
71
- statusMax?: number;
72
- /** General text search across method and url */
73
- search?: string;
74
- }
75
- export interface PaginatedResult<T> {
76
- data: T[];
77
- total: number;
78
- page: number;
79
- perPage: number;
80
- lastPage: number;
81
- }
82
- /**
83
- * Bridges the in-memory RingBuffer collectors to SQLite persistence
84
- * and provides query methods for the dashboard API.
85
- *
86
- * Handles auto-migration, retention cleanup, periodic metrics aggregation,
87
- * and self-exclusion of dashboard routes and server_stats connection queries.
88
- */
4
+ export type { RequestInput, PersistRequestInput, RequestFilters, QueryFilters, EventFilters, EmailFilters, LogFilters, TraceFilters, PaginatedResult, PaginateOptions, } from './dashboard_types.js';
5
+ import type { EventEmitter, PersistRequestInput, RequestFilters, QueryFilters, EventFilters, EmailFilters, LogFilters, TraceFilters, PaginatedResult } from './dashboard_types.js';
89
6
  export declare class DashboardStore {
90
7
  private db;
91
8
  private emitter;
@@ -96,133 +13,37 @@ export declare class DashboardStore {
96
13
  private handlers;
97
14
  private dbFilePath;
98
15
  private lastCleanupAt;
99
- private inflight;
100
- private coalesce;
101
- private resultCache;
102
- private cached;
16
+ private cache;
103
17
  private cachedStorageStats;
104
- private static readonly STORAGE_STATS_TTL_MS;
105
- private static readonly WIDGETS_CACHE_TTL_MS;
106
- private static readonly SPARKLINE_CACHE_TTL_MS;
107
- private static readonly CHART_CACHE_TTL_MS;
108
- private static readonly QUERIES_GROUPED_CACHE_TTL_MS;
109
- private static readonly PAGINATE_CACHE_TTL_MS;
110
- private writeQueue;
111
- private pendingEvents;
112
- private pendingLogs;
113
- private pendingEmails;
114
- private flushTimer;
115
- private flushing;
116
- private static readonly FLUSH_INTERVAL_MS;
117
- private static readonly MAX_QUEUE_SIZE;
18
+ private flushMgr;
19
+ private static readonly STORAGE_TTL;
118
20
  constructor(config: DevToolbarConfig);
119
- /**
120
- * Initialize the SQLite connection, run migrations and retention
121
- * cleanup, start chart aggregation, and wire event listeners.
122
- */
123
21
  start(_lucidDb: unknown, emitter: EventEmitter | null, appRoot: string): Promise<void>;
124
- /** Shut down timers, event listeners, and database connection. */
22
+ private initMigrations;
125
23
  stop(): Promise<void>;
126
- /** Get the raw Knex database connection (for DashboardController). */
24
+ private removeListeners;
127
25
  getDb(): Knex | null;
128
- /** Whether the store is initialized and ready. */
129
26
  isReady(): boolean;
130
- /**
131
- * Get SQLite storage statistics for the diagnostics endpoint.
132
- * Cached for 10s since the Internals tab polls every 3s.
133
- * Wrapped in a single transaction — 1 pool acquire instead of 8.
134
- */
135
- getStorageStats(): Promise<{
136
- ready: boolean;
137
- dbPath: string;
138
- fileSizeMb: number;
139
- walSizeMb: number;
140
- retentionDays: number;
141
- tables: Array<{
142
- name: string;
143
- rowCount: number;
144
- }>;
145
- lastCleanupAt: number | null;
146
- }>;
147
- /**
148
- * Queue a full request (with queries, events, trace) for batch persistence.
149
- * Returns null immediately — actual IDs are assigned during flush.
150
- *
151
- * Writes are buffered and flushed every 500ms in a single transaction,
152
- * which prevents the single-connection pool from being overwhelmed by
153
- * individual fire-and-forget INSERT calls under load.
154
- */
27
+ getStorageStats(): Promise<StorageStatsResult>;
155
28
  persistRequest(input: PersistRequestInput): Promise<number | null>;
156
- /** Queue events to be attached to a request during flush. */
157
29
  queueEvents(requestIndex: number, events: EventRecord[]): void;
158
- /** Record a single log entry — queued for batch flush. */
159
30
  recordLog(entry: Record<string, unknown>): void;
160
- /** Record a single email — queued for batch flush (avoids bypassing the write queue). */
161
31
  recordEmail(record: EmailRecord): void;
162
- /** Schedule the next batch flush if not already scheduled. */
163
- private scheduleFlush;
164
- /**
165
- * Flush all pending writes in a single transaction.
166
- *
167
- * A transaction acquires the pool connection ONCE, runs all INSERTs
168
- * (synchronous via better-sqlite3), then releases. Without a
169
- * transaction, each INSERT does its own async acquire/release cycle —
170
- * under load this creates hundreds of microtasks that starve the
171
- * event loop and freeze the server.
172
- */
173
- private flushWriteQueue;
174
- /** Paginated request history with optional filters. */
175
- getRequests(page?: number, perPage?: number, filters?: RequestFilters): Promise<PaginatedResult<Record<string, unknown>>>;
176
- /** Paginated query history with optional filters. */
177
- getQueries(page?: number, perPage?: number, filters?: QueryFilters): Promise<PaginatedResult<Record<string, unknown>>>;
178
- /**
179
- * Grouped query patterns: aggregated by sql_normalized
180
- * with count, avg/min/max/total duration.
181
- */
32
+ flushWriteQueue(): Promise<void>;
33
+ private get readCtx();
34
+ getRequests(p?: number, pp?: number, f?: RequestFilters): Promise<PaginatedResult<Record<string, unknown>>>;
35
+ getQueries(p?: number, pp?: number, f?: QueryFilters): Promise<PaginatedResult<Record<string, unknown>>>;
182
36
  getQueriesGrouped(limit?: number, sort?: string, search?: string): Promise<Record<string, unknown>[]>;
183
- /** Paginated event history with optional filters. */
184
- getEvents(page?: number, perPage?: number, filters?: EventFilters): Promise<PaginatedResult<Record<string, unknown>>>;
185
- /** Paginated email history with optional filters. */
186
- getEmails(page?: number, perPage?: number, filters?: EmailFilters, excludeBody?: boolean): Promise<PaginatedResult<Record<string, unknown>>>;
187
- /** Get email HTML body for preview (falls back to text_body). */
37
+ getEvents(p?: number, pp?: number, f?: EventFilters): Promise<PaginatedResult<Record<string, unknown>>>;
38
+ getEmails(p?: number, pp?: number, f?: EmailFilters, excludeBody?: boolean): Promise<PaginatedResult<Record<string, unknown>>>;
188
39
  getEmailHtml(id: number): Promise<string | null>;
189
- /**
190
- * Paginated log history with structured search support.
191
- *
192
- * Structured filters query into the JSON `data` column using
193
- * SQLite's `json_extract()`.
194
- */
195
- getLogs(page?: number, perPage?: number, filters?: LogFilters): Promise<PaginatedResult<Record<string, unknown>>>;
196
- /** Paginated trace history with optional filters. */
197
- getTraces(page?: number, perPage?: number, filters?: TraceFilters): Promise<PaginatedResult<Record<string, unknown>>>;
198
- /** Single trace with full span data. */
40
+ getLogs(p?: number, pp?: number, f?: LogFilters): Promise<PaginatedResult<Record<string, unknown>>>;
41
+ getTraces(p?: number, pp?: number, f?: TraceFilters): Promise<PaginatedResult<Record<string, unknown>>>;
199
42
  getTraceDetail(id: number): Promise<Record<string, unknown> | null>;
200
- /**
201
- * Single request with associated queries, events, and trace.
202
- * Wrapped in a transaction — 1 pool acquire instead of 4.
203
- */
204
43
  getRequestDetail(id: number): Promise<Record<string, unknown> | null>;
205
- /**
206
- * Aggregated overview metrics for the dashboard cards.
207
- *
208
- * @param range — '1h' | '6h' | '24h' | '7d'
209
- */
210
- /**
211
- * Wrapped in a single transaction — 1 pool acquire instead of 5.
212
- */
213
44
  getOverviewMetrics(range?: string): Promise<Record<string, unknown> | null>;
214
- /**
215
- * Time-series chart data from server_stats_metrics.
216
- *
217
- * @param range — '1h' | '6h' | '24h' | '7d'
218
- */
219
45
  getChartData(range?: string): Promise<Record<string, unknown>[]>;
220
- /**
221
- * Widget data for the dashboard overview.
222
- *
223
- * @param range — '1h' | '6h' | '24h' | '7d'
224
- */
225
- getOverviewWidgets(range?: string): Promise<{
46
+ getOverviewWidgets(range?: string): Promise<import("./overview_store_queries.js").OverviewWidgets | {
226
47
  topEvents: {
227
48
  eventName: string;
228
49
  count: number;
@@ -250,30 +71,10 @@ export declare class DashboardStore {
250
71
  count: number;
251
72
  }[];
252
73
  }>;
253
- /** Get sparkline data points from pre-aggregated metrics. */
254
74
  getSparklineData(range: string): Promise<Record<string, unknown>[]>;
255
75
  getSavedFilters(section?: string): Promise<Record<string, unknown>[]>;
256
76
  createSavedFilter(name: string, section: string, filterConfig: Record<string, unknown>): Promise<Record<string, unknown> | null>;
257
77
  deleteSavedFilter(id: number): Promise<boolean>;
258
- /**
259
- * Run EXPLAIN on a stored query using the app's default database connection.
260
- * Only allows SELECT queries for safety.
261
- *
262
- * @param queryId — ID from server_stats_queries
263
- * @param appDb — The application's Lucid database manager
264
- */
265
78
  runExplain(queryId: number, appDb: unknown): Promise<Record<string, unknown> | null>;
266
- /**
267
- * Generic paginated query with filter callback.
268
- *
269
- * Wrapped in a single transaction so COUNT + SELECT acquire the pool
270
- * connection only once instead of two separate acquire/release cycles.
271
- * With max:1 pool, this halves pool pressure per paginated endpoint.
272
- */
273
- private paginate;
274
- /**
275
- * Wire email event listeners to persist emails as they arrive.
276
- */
277
79
  private wireEventListeners;
278
80
  }
279
- export {};