adonisjs-server-stats 1.9.0 → 1.10.3

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 (227) 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/formatters-helpers.d.ts +23 -0
  10. package/dist/core/index.js +596 -509
  11. package/dist/core/log-utils-helpers.d.ts +13 -0
  12. package/dist/core/metrics.d.ts +3 -28
  13. package/dist/core/pagination.d.ts +0 -9
  14. package/dist/core/server-stats-controller.d.ts +6 -0
  15. package/dist/core/split-pane.d.ts +18 -0
  16. package/dist/core/trace-utils.d.ts +5 -0
  17. package/dist/core/transmit-helpers.d.ts +7 -0
  18. package/dist/core/types-dashboard.d.ts +178 -0
  19. package/dist/core/types-diagnostics.d.ts +85 -0
  20. package/dist/core/types.d.ts +11 -443
  21. package/dist/react/{CacheSection-xH75hwXu.js → CacheSection-baMZotSn.js} +2 -2
  22. package/dist/react/CacheTab-2cw_rMzj.js +117 -0
  23. package/dist/react/{ConfigSection-D8BO1Ry9.js → ConfigSection-DGgqjAal.js} +1 -1
  24. package/dist/react/{ConfigTab-CcN-tfjv.js → ConfigTab-H3OnYqmK.js} +1 -1
  25. package/dist/react/CustomPaneTab-B6r7ha0u.js +98 -0
  26. package/dist/react/{EmailsSection-BzlsTdPs.js → EmailsSection-C-UZISG-.js} +2 -2
  27. package/dist/react/EmailsTab-DbK4Eobn.js +139 -0
  28. package/dist/react/{EventsSection-CGQWiIdV.js → EventsSection-C7RQW_LY.js} +2 -2
  29. package/dist/react/EventsTab-CfVr7AiM.js +57 -0
  30. package/dist/react/{FilterBar-DQRXpWrb.js → FilterBar-CQ7bD669.js} +15 -15
  31. package/dist/react/{JobsSection-D7AHQmZi.js → JobsSection-CQHNK_Ls.js} +2 -2
  32. package/dist/react/{JobsTab-B3Lfdqed.js → JobsTab-znzf6jzk.js} +54 -42
  33. package/dist/react/{LogsSection-Cly1dpvS.js → LogsSection-Dmm3rE2B.js} +9 -3
  34. package/dist/react/LogsTab-D8unMV5P.js +108 -0
  35. package/dist/react/{OverviewSection-CkBGFEWq.js → OverviewSection-ABP9ueBo.js} +1 -1
  36. package/dist/react/{QueriesSection-CfCpnNUD.js → QueriesSection-CnmSkznA.js} +2 -2
  37. package/dist/react/{QueriesTab-DbBmAqzO.js → QueriesTab-BQzcxEiW.js} +37 -40
  38. package/dist/react/RelatedLogs-3A8RuGKH.js +52 -0
  39. package/dist/react/RequestsSection-kW79_M7k.js +341 -0
  40. package/dist/react/{RoutesSection-CRqF-cNM.js → RoutesSection-BRhxrtjZ.js} +2 -2
  41. package/dist/react/RoutesTab-CpYH5lUw.js +68 -0
  42. package/dist/react/TimelineTab-DjLR35Ce.js +214 -0
  43. package/dist/react/index-CsImORX6.js +1121 -0
  44. package/dist/react/index.js +1 -1
  45. package/dist/react/react/components/{Dashboard/shared → shared}/FilterBar.d.ts +4 -3
  46. package/dist/react/react/components/shared/RelatedLogs.d.ts +7 -0
  47. package/dist/react/react/hooks/useDashboardData.d.ts +4 -8
  48. package/dist/react/style.css +1 -1
  49. package/dist/src/collectors/app_collector.d.ts +0 -8
  50. package/dist/src/collectors/app_collector.js +45 -52
  51. package/dist/src/collectors/auto_detect.d.ts +0 -23
  52. package/dist/src/collectors/auto_detect.js +33 -55
  53. package/dist/src/collectors/db_pool_collector.d.ts +14 -16
  54. package/dist/src/collectors/db_pool_collector.js +72 -57
  55. package/dist/src/collectors/log_collector.d.ts +0 -47
  56. package/dist/src/collectors/log_collector.js +36 -65
  57. package/dist/src/collectors/queue_collector.d.ts +0 -20
  58. package/dist/src/collectors/queue_collector.js +60 -76
  59. package/dist/src/collectors/redis_collector.d.ts +10 -10
  60. package/dist/src/collectors/redis_collector.js +69 -66
  61. package/dist/src/config/deprecation_migration.d.ts +7 -0
  62. package/dist/src/config/deprecation_migration.js +201 -0
  63. package/dist/src/controller/debug_controller.d.ts +1 -1
  64. package/dist/src/controller/debug_controller.js +87 -81
  65. package/dist/src/dashboard/cache_handlers.d.ts +14 -0
  66. package/dist/src/dashboard/cache_handlers.js +52 -0
  67. package/dist/src/dashboard/chart_aggregator.d.ts +0 -7
  68. package/dist/src/dashboard/chart_aggregator.js +68 -50
  69. package/dist/src/dashboard/coalesce_cache.d.ts +25 -0
  70. package/dist/src/dashboard/coalesce_cache.js +47 -0
  71. package/dist/src/dashboard/dashboard_controller.d.ts +11 -37
  72. package/dist/src/dashboard/dashboard_controller.js +52 -532
  73. package/dist/src/dashboard/dashboard_page_assets.d.ts +17 -0
  74. package/dist/src/dashboard/dashboard_page_assets.js +51 -0
  75. package/dist/src/dashboard/dashboard_store.d.ts +19 -217
  76. package/dist/src/dashboard/dashboard_store.js +115 -1069
  77. package/dist/src/dashboard/dashboard_types.d.ts +83 -0
  78. package/dist/src/dashboard/dashboard_types.js +4 -0
  79. package/dist/src/dashboard/detail_queries.d.ts +19 -0
  80. package/dist/src/dashboard/detail_queries.js +98 -0
  81. package/dist/src/dashboard/email_event_builder.d.ts +8 -0
  82. package/dist/src/dashboard/email_event_builder.js +65 -0
  83. package/dist/src/dashboard/explain_query.d.ts +8 -0
  84. package/dist/src/dashboard/explain_query.js +22 -0
  85. package/dist/src/dashboard/filter_handlers.d.ts +23 -0
  86. package/dist/src/dashboard/filter_handlers.js +56 -0
  87. package/dist/src/dashboard/filtered_queries.d.ts +15 -0
  88. package/dist/src/dashboard/filtered_queries.js +155 -0
  89. package/dist/src/dashboard/flush_manager.d.ts +25 -0
  90. package/dist/src/dashboard/flush_manager.js +107 -0
  91. package/dist/src/dashboard/format_helpers.d.ts +126 -0
  92. package/dist/src/dashboard/format_helpers.js +140 -0
  93. package/dist/src/dashboard/inspector_manager.d.ts +36 -0
  94. package/dist/src/dashboard/inspector_manager.js +102 -0
  95. package/dist/src/dashboard/integrations/config_inspector.js +11 -13
  96. package/dist/src/dashboard/integrations/queue_inspector.d.ts +3 -3
  97. package/dist/src/dashboard/integrations/queue_inspector.js +13 -10
  98. package/dist/src/dashboard/jobs_handlers.d.ts +14 -0
  99. package/dist/src/dashboard/jobs_handlers.js +61 -0
  100. package/dist/src/dashboard/knex_factory.d.ts +18 -0
  101. package/dist/src/dashboard/knex_factory.js +91 -0
  102. package/dist/src/dashboard/migrator.js +30 -153
  103. package/dist/src/dashboard/migrator_tables.d.ts +19 -0
  104. package/dist/src/dashboard/migrator_tables.js +153 -0
  105. package/dist/src/dashboard/overview_queries.d.ts +66 -0
  106. package/dist/src/dashboard/overview_queries.js +155 -0
  107. package/dist/src/dashboard/overview_query_runners.d.ts +25 -0
  108. package/dist/src/dashboard/overview_query_runners.js +84 -0
  109. package/dist/src/dashboard/overview_store_queries.d.ts +40 -0
  110. package/dist/src/dashboard/overview_store_queries.js +69 -0
  111. package/dist/src/dashboard/paginate_helper.d.ts +12 -0
  112. package/dist/src/dashboard/paginate_helper.js +33 -0
  113. package/dist/src/dashboard/query_explain_handler.d.ts +10 -0
  114. package/dist/src/dashboard/query_explain_handler.js +80 -0
  115. package/dist/src/dashboard/read_queries.d.ts +32 -0
  116. package/dist/src/dashboard/read_queries.js +107 -0
  117. package/dist/src/dashboard/saved_filter_queries.d.ts +10 -0
  118. package/dist/src/dashboard/saved_filter_queries.js +24 -0
  119. package/dist/src/dashboard/storage_stats.d.ts +41 -0
  120. package/dist/src/dashboard/storage_stats.js +81 -0
  121. package/dist/src/dashboard/write_queue.d.ts +106 -0
  122. package/dist/src/dashboard/write_queue.js +225 -0
  123. package/dist/src/data/data_access.d.ts +6 -36
  124. package/dist/src/data/data_access.js +43 -188
  125. package/dist/src/data/data_access_helpers.d.ts +130 -0
  126. package/dist/src/data/data_access_helpers.js +212 -0
  127. package/dist/src/debug/debug_store.js +37 -32
  128. package/dist/src/debug/email_collector.d.ts +1 -10
  129. package/dist/src/debug/email_collector.js +78 -81
  130. package/dist/src/debug/event_collector.d.ts +0 -9
  131. package/dist/src/debug/event_collector.js +79 -62
  132. package/dist/src/debug/query_collector.js +23 -19
  133. package/dist/src/debug/route_inspector.d.ts +1 -5
  134. package/dist/src/debug/route_inspector.js +50 -51
  135. package/dist/src/debug/trace_collector.d.ts +10 -2
  136. package/dist/src/debug/trace_collector.js +23 -16
  137. package/dist/src/debug/types.d.ts +5 -1
  138. package/dist/src/define_config.d.ts +0 -65
  139. package/dist/src/define_config.js +93 -333
  140. package/dist/src/edge/client/dashboard.js +2 -2
  141. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  142. package/dist/src/edge/client/stats-bar.js +1 -1
  143. package/dist/src/edge/client-vue/dashboard.js +5 -5
  144. package/dist/src/edge/client-vue/debug-panel-deferred.js +3 -3
  145. package/dist/src/edge/client-vue/stats-bar.js +3 -3
  146. package/dist/src/edge/plugin.d.ts +0 -16
  147. package/dist/src/edge/plugin.js +57 -64
  148. package/dist/src/engine/request_metrics.d.ts +1 -0
  149. package/dist/src/engine/request_metrics.js +32 -42
  150. package/dist/src/middleware/request_tracking_middleware.d.ts +3 -8
  151. package/dist/src/middleware/request_tracking_middleware.js +65 -91
  152. package/dist/src/provider/auth_middleware_detector.d.ts +16 -0
  153. package/dist/src/provider/auth_middleware_detector.js +97 -0
  154. package/dist/src/provider/boot_helpers.d.ts +20 -0
  155. package/dist/src/provider/boot_helpers.js +91 -0
  156. package/dist/src/provider/boot_initializer.d.ts +28 -0
  157. package/dist/src/provider/boot_initializer.js +35 -0
  158. package/dist/src/provider/dashboard_init.d.ts +30 -0
  159. package/dist/src/provider/dashboard_init.js +138 -0
  160. package/dist/src/provider/dashboard_setup.d.ts +25 -0
  161. package/dist/src/provider/dashboard_setup.js +78 -0
  162. package/dist/src/provider/diagnostics.d.ts +134 -0
  163. package/dist/src/provider/diagnostics.js +127 -0
  164. package/dist/src/provider/email_bridge.d.ts +43 -0
  165. package/dist/src/provider/email_bridge.js +80 -0
  166. package/dist/src/provider/email_helpers.d.ts +13 -0
  167. package/dist/src/provider/email_helpers.js +68 -0
  168. package/dist/src/provider/pino_hook.d.ts +17 -0
  169. package/dist/src/provider/pino_hook.js +35 -0
  170. package/dist/src/provider/provider_helpers_extra.d.ts +47 -0
  171. package/dist/src/provider/provider_helpers_extra.js +177 -0
  172. package/dist/src/provider/server_stats_provider.d.ts +39 -85
  173. package/dist/src/provider/server_stats_provider.js +131 -936
  174. package/dist/src/provider/shutdown_helpers.d.ts +43 -0
  175. package/dist/src/provider/shutdown_helpers.js +70 -0
  176. package/dist/src/provider/toolbar_setup.d.ts +57 -0
  177. package/dist/src/provider/toolbar_setup.js +141 -0
  178. package/dist/src/routes/dashboard_routes.d.ts +14 -0
  179. package/dist/src/routes/dashboard_routes.js +197 -0
  180. package/dist/src/routes/debug_routes.d.ts +14 -0
  181. package/dist/src/routes/debug_routes.js +101 -0
  182. package/dist/src/routes/register_routes.d.ts +0 -78
  183. package/dist/src/routes/register_routes.js +22 -347
  184. package/dist/src/routes/stats_routes.d.ts +5 -0
  185. package/dist/src/routes/stats_routes.js +14 -0
  186. package/dist/src/styles/components.css +177 -0
  187. package/dist/src/styles/dashboard.css +8 -90
  188. package/dist/src/styles/debug-panel.css +10 -31
  189. package/dist/src/types.d.ts +306 -15
  190. package/dist/vue/{CacheSection-Cx-hj09X.js → CacheSection-ITqvpfH5.js} +1 -1
  191. package/dist/vue/{ConfigSection-CMXyryf6.js → ConfigSection-DTn3GslE.js} +1 -1
  192. package/dist/vue/{EmailsSection-DgKl9xGT.js → EmailsSection-DtLJ4XoS.js} +1 -1
  193. package/dist/vue/{EventsSection-BNMCAim1.js → EventsSection-BOYYz0Ty.js} +1 -1
  194. package/dist/vue/{JobsSection-CCMgMlxd.js → JobsSection-BazTxcJL.js} +1 -1
  195. package/dist/vue/{LogsSection-CvOnTxUu.js → LogsSection-D55PjTKX.js} +9 -3
  196. package/dist/vue/{LogsTab-Bg3o0Mm6.js → LogsTab-47zEK7jL.js} +4 -1
  197. package/dist/vue/{OverviewSection-CHgaKtUR.js → OverviewSection-1uBKo-Tu.js} +1 -1
  198. package/dist/vue/{QueriesSection-BnHRD98z.js → QueriesSection-rpoZ4ogd.js} +1 -1
  199. package/dist/vue/RelatedLogs.vue_vue_type_script_setup_true_lang-CB2_TzYW.js +84 -0
  200. package/dist/vue/RequestsSection-x7LvT0MC.js +401 -0
  201. package/dist/vue/{RoutesSection-BrceOcKQ.js → RoutesSection-CCD0zZqQ.js} +1 -1
  202. package/dist/vue/TimelineTab-zj5Z5OdT.js +338 -0
  203. package/dist/vue/components/Dashboard/sections/RequestsSection.vue.d.ts +4 -0
  204. package/dist/vue/components/DebugPanel/tabs/TimelineTab.vue.d.ts +4 -0
  205. package/dist/vue/components/{Dashboard/sections/TimelineSection.vue.d.ts → shared/RelatedLogs.vue.d.ts} +5 -6
  206. package/dist/vue/composables/useDashboardData.d.ts +12 -23
  207. package/dist/vue/index-C8MxnS7Q.js +1232 -0
  208. package/dist/vue/index.js +1 -1
  209. package/dist/vue/style.css +1 -1
  210. package/package.json +1 -1
  211. package/dist/react/CacheTab-DYmsZJJ1.js +0 -123
  212. package/dist/react/CustomPaneTab-D7_o3Ec6.js +0 -104
  213. package/dist/react/EmailsTab-Uh2CQY3o.js +0 -153
  214. package/dist/react/EventsTab-CC6DQzEm.js +0 -63
  215. package/dist/react/LogsTab-BbYK-iyh.js +0 -103
  216. package/dist/react/RequestsSection-Cb5a6MlT.js +0 -209
  217. package/dist/react/RoutesTab-Bwreij3e.js +0 -74
  218. package/dist/react/TimelineSection-B2y06kRE.js +0 -158
  219. package/dist/react/TimelineTab-6hthfdBB.js +0 -193
  220. package/dist/react/WaterfallChart-Cj73WdfM.js +0 -100
  221. package/dist/react/index-CecA4IdQ.js +0 -1075
  222. package/dist/react/react/components/Dashboard/sections/TimelineSection.d.ts +0 -8
  223. package/dist/vue/RequestsSection-B-uSlM0f.js +0 -243
  224. package/dist/vue/TimelineSection-CfvnA2Oo.js +0 -186
  225. package/dist/vue/TimelineTab-Db6lKKsD.js +0 -250
  226. package/dist/vue/WaterfallChart.vue_vue_type_script_setup_true_lang-tZ13cNj1.js +0 -118
  227. package/dist/vue/index-oLxS08vN.js +0 -1235
@@ -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,90 +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
- }
20
- export interface RequestFilters {
21
- method?: string;
22
- url?: string;
23
- status?: number;
24
- statusMin?: number;
25
- statusMax?: number;
26
- durationMin?: number;
27
- durationMax?: number;
28
- /** General text search across method and url */
29
- search?: string;
30
- }
31
- export interface QueryFilters {
32
- method?: string;
33
- model?: string;
34
- connection?: string;
35
- durationMin?: number;
36
- durationMax?: number;
37
- requestId?: number;
38
- /** General text search across sql_text, model, and connection */
39
- search?: string;
40
- }
41
- export interface EventFilters {
42
- eventName?: string;
43
- /** General text search across event_name */
44
- search?: string;
45
- }
46
- export interface EmailFilters {
47
- /** General text search across from_addr, to_addr, and subject */
48
- search?: string;
49
- from?: string;
50
- to?: string;
51
- subject?: string;
52
- mailer?: string;
53
- status?: string;
54
- }
55
- export interface LogFilters {
56
- level?: string;
57
- requestId?: string;
58
- search?: string;
59
- /** Structured filters: array of { field, operator, value } */
60
- structured?: {
61
- field: string;
62
- operator: 'equals' | 'contains' | 'startsWith';
63
- value: string;
64
- }[];
65
- }
66
- export interface TraceFilters {
67
- method?: string;
68
- url?: string;
69
- statusMin?: number;
70
- statusMax?: number;
71
- /** General text search across method and url */
72
- search?: string;
73
- }
74
- export interface PaginatedResult<T> {
75
- data: T[];
76
- total: number;
77
- page: number;
78
- perPage: number;
79
- lastPage: number;
80
- }
81
- /**
82
- * Bridges the in-memory RingBuffer collectors to SQLite persistence
83
- * and provides query methods for the dashboard API.
84
- *
85
- * Handles auto-migration, retention cleanup, periodic metrics aggregation,
86
- * and self-exclusion of dashboard routes and server_stats connection queries.
87
- */
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';
88
6
  export declare class DashboardStore {
89
7
  private db;
90
8
  private emitter;
@@ -95,133 +13,37 @@ export declare class DashboardStore {
95
13
  private handlers;
96
14
  private dbFilePath;
97
15
  private lastCleanupAt;
98
- private inflight;
99
- private coalesce;
100
- private resultCache;
101
- private cached;
16
+ private cache;
102
17
  private cachedStorageStats;
103
- private static readonly STORAGE_STATS_TTL_MS;
104
- private static readonly WIDGETS_CACHE_TTL_MS;
105
- private static readonly SPARKLINE_CACHE_TTL_MS;
106
- private static readonly CHART_CACHE_TTL_MS;
107
- private static readonly QUERIES_GROUPED_CACHE_TTL_MS;
108
- private static readonly PAGINATE_CACHE_TTL_MS;
109
- private writeQueue;
110
- private pendingEvents;
111
- private pendingLogs;
112
- private pendingEmails;
113
- private flushTimer;
114
- private flushing;
115
- private static readonly FLUSH_INTERVAL_MS;
116
- private static readonly MAX_QUEUE_SIZE;
18
+ private flushMgr;
19
+ private static readonly STORAGE_TTL;
117
20
  constructor(config: DevToolbarConfig);
118
- /**
119
- * Initialize the SQLite connection, run migrations and retention
120
- * cleanup, start chart aggregation, and wire event listeners.
121
- */
122
21
  start(_lucidDb: unknown, emitter: EventEmitter | null, appRoot: string): Promise<void>;
123
- /** Shut down timers, event listeners, and database connection. */
22
+ private initMigrations;
124
23
  stop(): Promise<void>;
125
- /** Get the raw Knex database connection (for DashboardController). */
24
+ private removeListeners;
126
25
  getDb(): Knex | null;
127
- /** Whether the store is initialized and ready. */
128
26
  isReady(): boolean;
129
- /**
130
- * Get SQLite storage statistics for the diagnostics endpoint.
131
- * Cached for 10s since the Internals tab polls every 3s.
132
- * Wrapped in a single transaction — 1 pool acquire instead of 8.
133
- */
134
- getStorageStats(): Promise<{
135
- ready: boolean;
136
- dbPath: string;
137
- fileSizeMb: number;
138
- walSizeMb: number;
139
- retentionDays: number;
140
- tables: Array<{
141
- name: string;
142
- rowCount: number;
143
- }>;
144
- lastCleanupAt: number | null;
145
- }>;
146
- /**
147
- * Queue a full request (with queries, events, trace) for batch persistence.
148
- * Returns null immediately — actual IDs are assigned during flush.
149
- *
150
- * Writes are buffered and flushed every 500ms in a single transaction,
151
- * which prevents the single-connection pool from being overwhelmed by
152
- * individual fire-and-forget INSERT calls under load.
153
- */
27
+ getStorageStats(): Promise<StorageStatsResult>;
154
28
  persistRequest(input: PersistRequestInput): Promise<number | null>;
155
- /** Queue events to be attached to a request during flush. */
156
29
  queueEvents(requestIndex: number, events: EventRecord[]): void;
157
- /** Record a single log entry — queued for batch flush. */
158
30
  recordLog(entry: Record<string, unknown>): void;
159
- /** Record a single email — queued for batch flush (avoids bypassing the write queue). */
160
31
  recordEmail(record: EmailRecord): void;
161
- /** Schedule the next batch flush if not already scheduled. */
162
- private scheduleFlush;
163
- /**
164
- * Flush all pending writes in a single transaction.
165
- *
166
- * A transaction acquires the pool connection ONCE, runs all INSERTs
167
- * (synchronous via better-sqlite3), then releases. Without a
168
- * transaction, each INSERT does its own async acquire/release cycle —
169
- * under load this creates hundreds of microtasks that starve the
170
- * event loop and freeze the server.
171
- */
172
- private flushWriteQueue;
173
- /** Paginated request history with optional filters. */
174
- getRequests(page?: number, perPage?: number, filters?: RequestFilters): Promise<PaginatedResult<Record<string, unknown>>>;
175
- /** Paginated query history with optional filters. */
176
- getQueries(page?: number, perPage?: number, filters?: QueryFilters): Promise<PaginatedResult<Record<string, unknown>>>;
177
- /**
178
- * Grouped query patterns: aggregated by sql_normalized
179
- * with count, avg/min/max/total duration.
180
- */
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>>>;
181
36
  getQueriesGrouped(limit?: number, sort?: string, search?: string): Promise<Record<string, unknown>[]>;
182
- /** Paginated event history with optional filters. */
183
- getEvents(page?: number, perPage?: number, filters?: EventFilters): Promise<PaginatedResult<Record<string, unknown>>>;
184
- /** Paginated email history with optional filters. */
185
- getEmails(page?: number, perPage?: number, filters?: EmailFilters, excludeBody?: boolean): Promise<PaginatedResult<Record<string, unknown>>>;
186
- /** 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>>>;
187
39
  getEmailHtml(id: number): Promise<string | null>;
188
- /**
189
- * Paginated log history with structured search support.
190
- *
191
- * Structured filters query into the JSON `data` column using
192
- * SQLite's `json_extract()`.
193
- */
194
- getLogs(page?: number, perPage?: number, filters?: LogFilters): Promise<PaginatedResult<Record<string, unknown>>>;
195
- /** Paginated trace history with optional filters. */
196
- getTraces(page?: number, perPage?: number, filters?: TraceFilters): Promise<PaginatedResult<Record<string, unknown>>>;
197
- /** 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>>>;
198
42
  getTraceDetail(id: number): Promise<Record<string, unknown> | null>;
199
- /**
200
- * Single request with associated queries, events, and trace.
201
- * Wrapped in a transaction — 1 pool acquire instead of 4.
202
- */
203
43
  getRequestDetail(id: number): Promise<Record<string, unknown> | null>;
204
- /**
205
- * Aggregated overview metrics for the dashboard cards.
206
- *
207
- * @param range — '1h' | '6h' | '24h' | '7d'
208
- */
209
- /**
210
- * Wrapped in a single transaction — 1 pool acquire instead of 5.
211
- */
212
44
  getOverviewMetrics(range?: string): Promise<Record<string, unknown> | null>;
213
- /**
214
- * Time-series chart data from server_stats_metrics.
215
- *
216
- * @param range — '1h' | '6h' | '24h' | '7d'
217
- */
218
45
  getChartData(range?: string): Promise<Record<string, unknown>[]>;
219
- /**
220
- * Widget data for the dashboard overview.
221
- *
222
- * @param range — '1h' | '6h' | '24h' | '7d'
223
- */
224
- getOverviewWidgets(range?: string): Promise<{
46
+ getOverviewWidgets(range?: string): Promise<import("./overview_store_queries.js").OverviewWidgets | {
225
47
  topEvents: {
226
48
  eventName: string;
227
49
  count: number;
@@ -249,30 +71,10 @@ export declare class DashboardStore {
249
71
  count: number;
250
72
  }[];
251
73
  }>;
252
- /** Get sparkline data points from pre-aggregated metrics. */
253
74
  getSparklineData(range: string): Promise<Record<string, unknown>[]>;
254
75
  getSavedFilters(section?: string): Promise<Record<string, unknown>[]>;
255
76
  createSavedFilter(name: string, section: string, filterConfig: Record<string, unknown>): Promise<Record<string, unknown> | null>;
256
77
  deleteSavedFilter(id: number): Promise<boolean>;
257
- /**
258
- * Run EXPLAIN on a stored query using the app's default database connection.
259
- * Only allows SELECT queries for safety.
260
- *
261
- * @param queryId — ID from server_stats_queries
262
- * @param appDb — The application's Lucid database manager
263
- */
264
78
  runExplain(queryId: number, appDb: unknown): Promise<Record<string, unknown> | null>;
265
- /**
266
- * Generic paginated query with filter callback.
267
- *
268
- * Wrapped in a single transaction so COUNT + SELECT acquire the pool
269
- * connection only once instead of two separate acquire/release cycles.
270
- * With max:1 pool, this halves pool pressure per paginated endpoint.
271
- */
272
- private paginate;
273
- /**
274
- * Wire email event listeners to persist emails as they arrive.
275
- */
276
79
  private wireEventListeners;
277
80
  }
278
- export {};