adonisjs-server-stats 1.12.3 → 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 (168) hide show
  1. package/README.md +11 -6
  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/adonisjs_queue_collector.d.ts +21 -0
  38. package/dist/src/collectors/adonisjs_queue_collector.js +61 -0
  39. package/dist/src/collectors/auto_detect.js +8 -2
  40. package/dist/src/collectors/index.d.ts +2 -0
  41. package/dist/src/collectors/index.js +1 -0
  42. package/dist/src/collectors/queue_collector.js +22 -6
  43. package/dist/src/config/deprecation_migration.js +11 -0
  44. package/dist/src/dashboard/cache_handlers.js +22 -2
  45. package/dist/src/dashboard/flush_manager.d.ts +2 -0
  46. package/dist/src/dashboard/flush_manager.js +17 -0
  47. package/dist/src/dashboard/inspector_manager.d.ts +4 -4
  48. package/dist/src/dashboard/inspector_manager.js +20 -10
  49. package/dist/src/dashboard/integrations/adonisjs_queue_inspector.d.ts +42 -0
  50. package/dist/src/dashboard/integrations/adonisjs_queue_inspector.js +135 -0
  51. package/dist/src/dashboard/integrations/adonisjs_queue_store.d.ts +166 -0
  52. package/dist/src/dashboard/integrations/adonisjs_queue_store.js +629 -0
  53. package/dist/src/dashboard/integrations/config_inspector.d.ts +0 -1
  54. package/dist/src/dashboard/integrations/config_inspector.js +4 -2
  55. package/dist/src/dashboard/integrations/index.d.ts +4 -1
  56. package/dist/src/dashboard/integrations/index.js +2 -0
  57. package/dist/src/dashboard/integrations/queue_inspector.d.ts +5 -61
  58. package/dist/src/dashboard/integrations/queue_inspector.js +5 -1
  59. package/dist/src/dashboard/integrations/queue_inspector_contract.d.ts +73 -0
  60. package/dist/src/dashboard/integrations/queue_inspector_contract.js +15 -0
  61. package/dist/src/dashboard/paginate_helper.d.ts +5 -0
  62. package/dist/src/dashboard/paginate_helper.js +16 -4
  63. package/dist/src/dashboard/query_explain_handler.d.ts +6 -1
  64. package/dist/src/dashboard/query_explain_handler.js +12 -2
  65. package/dist/src/dashboard/write_queue.d.ts +13 -0
  66. package/dist/src/dashboard/write_queue.js +34 -2
  67. package/dist/src/debug/debug_store.js +8 -1
  68. package/dist/src/debug/event_collector.js +4 -0
  69. package/dist/src/debug/query_collector.js +2 -0
  70. package/dist/src/debug/ring_buffer.js +8 -1
  71. package/dist/src/debug/trace_collector.js +34 -10
  72. package/dist/src/debug/types.d.ts +2 -0
  73. package/dist/src/define_config.js +1 -0
  74. package/dist/src/edge/client/dashboard.js +2 -2
  75. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  76. package/dist/src/edge/client/stats-bar.js +1 -1
  77. package/dist/src/edge/client-vue/dashboard.js +5 -5
  78. package/dist/src/edge/client-vue/debug-panel-deferred.js +2 -2
  79. package/dist/src/engine/request_metrics.js +8 -10
  80. package/dist/src/log_stream/log_stream_service.d.ts +1 -0
  81. package/dist/src/log_stream/log_stream_service.js +7 -5
  82. package/dist/src/prometheus/prometheus_collector.d.ts +9 -0
  83. package/dist/src/prometheus/prometheus_collector.js +11 -0
  84. package/dist/src/provider/dashboard_init.js +15 -0
  85. package/dist/src/provider/dashboard_setup.js +9 -2
  86. package/dist/src/provider/email_bridge.d.ts +14 -3
  87. package/dist/src/provider/email_bridge.js +25 -3
  88. package/dist/src/provider/email_helpers.d.ts +9 -1
  89. package/dist/src/provider/email_helpers.js +32 -4
  90. package/dist/src/provider/pino_hook.d.ts +8 -0
  91. package/dist/src/provider/pino_hook.js +19 -1
  92. package/dist/src/provider/provider_helpers_extra.d.ts +2 -0
  93. package/dist/src/provider/provider_helpers_extra.js +17 -2
  94. package/dist/src/provider/server_stats_provider.js +19 -1
  95. package/dist/src/provider/shutdown_helpers.js +2 -0
  96. package/dist/src/provider/toolbar_setup.js +32 -17
  97. package/dist/src/routes/dashboard_routes.js +96 -62
  98. package/dist/src/routes/debug_routes.js +45 -35
  99. package/dist/src/routes/no_session_middleware.d.ts +6 -3
  100. package/dist/src/routes/no_session_middleware.js +7 -3
  101. package/dist/src/routes/register_routes.d.ts +8 -0
  102. package/dist/src/routes/register_routes.js +19 -0
  103. package/dist/src/types.d.ts +31 -0
  104. package/dist/src/utils/app_import.js +12 -4
  105. package/dist/vue/CacheSection-CxEBVVkF.js +156 -0
  106. package/dist/vue/ConfigSection-BiRAiaHj.js +415 -0
  107. package/dist/vue/EmailsSection-Dl44qyqY.js +208 -0
  108. package/dist/vue/{EmailsTab-CwIF1fik.js → EmailsTab-Diya54CP.js} +6 -5
  109. package/dist/vue/{EventsSection-BpgkWIwM.js → EventsSection-CWjeitjU.js} +1 -1
  110. package/dist/vue/{InternalsTab-521fxYYj.js → InternalsTab-Z3c82glB.js} +15 -15
  111. package/dist/vue/{JobsSection-DrghFEKL.js → JobsSection-DOBb4LjZ.js} +1 -1
  112. package/dist/vue/LogsSection-CXx-HOWJ.js +260 -0
  113. package/dist/vue/{OverviewSection-BAgZTPjY.js → OverviewSection-CyfNQ8uV.js} +318 -302
  114. package/dist/vue/{QueriesSection-CUpwhp7u.js → QueriesSection-CXBsFp-y.js} +1 -1
  115. package/dist/vue/{RequestsSection-D8P2xpF2.js → RequestsSection-YTIaZGZd.js} +151 -145
  116. package/dist/vue/{RoutesSection-0qB81hTT.js → RoutesSection-CDKMey49.js} +1 -1
  117. package/dist/vue/composables/useApiClient.d.ts +8 -1
  118. package/dist/vue/index-14x39RI_.js +1239 -0
  119. package/dist/vue/index.js +1 -1
  120. package/dist/vue/style.css +1 -1
  121. package/package.json +16 -3
  122. package/dist/react/ConfigContent-CnsEI4j3.js +0 -397
  123. package/dist/react/LogsTab-jKwv9G7Q.js +0 -79
  124. package/dist/react/RequestsSection-D8cMbZU0.js +0 -321
  125. package/dist/react/index-CsprmgzI.js +0 -1121
  126. package/dist/react/useApiClient-BVtNCmnL.js +0 -9
  127. package/dist/vue/CacheSection-DRqV3YX2.js +0 -149
  128. package/dist/vue/ConfigSection-C6pQCHAL.js +0 -576
  129. package/dist/vue/EmailsSection-BTNw3ZU2.js +0 -206
  130. package/dist/vue/LogsSection-BDxx9Bfi.js +0 -258
  131. package/dist/vue/index-30jLw-_w.js +0 -1232
  132. /package/dist/core/{api-client.d.ts → core/api-client.d.ts} +0 -0
  133. /package/dist/core/{config-utils.d.ts → core/config-utils.d.ts} +0 -0
  134. /package/dist/core/{constants.d.ts → core/constants.d.ts} +0 -0
  135. /package/dist/core/{dashboard-api.d.ts → core/dashboard-api.d.ts} +0 -0
  136. /package/dist/core/{dashboard-data-controller.d.ts → core/dashboard-data-controller.d.ts} +0 -0
  137. /package/dist/core/{dashboard-data-helpers.d.ts → core/dashboard-data-helpers.d.ts} +0 -0
  138. /package/dist/core/{debug-data-controller.d.ts → core/debug-data-controller.d.ts} +0 -0
  139. /package/dist/core/{define-config-helpers.d.ts → core/define-config-helpers.d.ts} +0 -0
  140. /package/dist/core/{explain-utils.d.ts → core/explain-utils.d.ts} +0 -0
  141. /package/dist/core/{feature-detect-helpers.d.ts → core/feature-detect-helpers.d.ts} +0 -0
  142. /package/dist/core/{feature-detect.d.ts → core/feature-detect.d.ts} +0 -0
  143. /package/dist/core/{field-resolvers.d.ts → core/field-resolvers.d.ts} +0 -0
  144. /package/dist/core/{formatters-helpers.d.ts → core/formatters-helpers.d.ts} +0 -0
  145. /package/dist/core/{formatters.d.ts → core/formatters.d.ts} +0 -0
  146. /package/dist/core/{history-buffer.d.ts → core/history-buffer.d.ts} +0 -0
  147. /package/dist/core/{icons.d.ts → core/icons.d.ts} +0 -0
  148. /package/dist/core/{index.d.ts → core/index.d.ts} +0 -0
  149. /package/dist/core/{internals-utils.d.ts → core/internals-utils.d.ts} +0 -0
  150. /package/dist/core/{job-utils.d.ts → core/job-utils.d.ts} +0 -0
  151. /package/dist/core/{log-utils-helpers.d.ts → core/log-utils-helpers.d.ts} +0 -0
  152. /package/dist/core/{log-utils.d.ts → core/log-utils.d.ts} +0 -0
  153. /package/dist/core/{metrics.d.ts → core/metrics.d.ts} +0 -0
  154. /package/dist/core/{pagination.d.ts → core/pagination.d.ts} +0 -0
  155. /package/dist/core/{queries-columns.d.ts → core/queries-columns.d.ts} +0 -0
  156. /package/dist/core/{queries-controller.d.ts → core/queries-controller.d.ts} +0 -0
  157. /package/dist/core/{query-utils.d.ts → core/query-utils.d.ts} +0 -0
  158. /package/dist/core/{resizable-columns.d.ts → core/resizable-columns.d.ts} +0 -0
  159. /package/dist/core/{routes.d.ts → core/routes.d.ts} +0 -0
  160. /package/dist/core/{server-stats-controller.d.ts → core/server-stats-controller.d.ts} +0 -0
  161. /package/dist/core/{sparkline.d.ts → core/sparkline.d.ts} +0 -0
  162. /package/dist/core/{split-pane.d.ts → core/split-pane.d.ts} +0 -0
  163. /package/dist/core/{theme.d.ts → core/theme.d.ts} +0 -0
  164. /package/dist/core/{trace-utils.d.ts → core/trace-utils.d.ts} +0 -0
  165. /package/dist/core/{transmit-adapter.d.ts → core/transmit-adapter.d.ts} +0 -0
  166. /package/dist/core/{transmit-helpers.d.ts → core/transmit-helpers.d.ts} +0 -0
  167. /package/dist/core/{types-dashboard.d.ts → core/types-dashboard.d.ts} +0 -0
  168. /package/dist/core/{types-diagnostics.d.ts → core/types-diagnostics.d.ts} +0 -0
package/README.md CHANGED
@@ -180,6 +180,7 @@ All fields are optional. `defineConfig({})` works with zero configuration.
180
180
  | `realtime` | `boolean` | `true` | `true` = SSE via Transmit, `false` = poll-only |
181
181
  | `statsEndpoint` | `string \| false` | `'/admin/api/server-stats'` | HTTP endpoint. `false` to disable. |
182
182
  | `authorize` | `(ctx) => boolean` | -- | Per-request visibility guard |
183
+ | `unsafeAllowNoAuth` | `boolean` | `false` | Register the dashboard/debug/stats routes even with **no** `authorize` guard. Off by default (routes fail closed). Local dev only — exposes secrets, email bodies, and SQL. |
183
184
  | `onStats` | `(stats) => void` | -- | Callback after each collection tick |
184
185
  | `toolbar` | `boolean \| ToolbarConfig` | -- | `true` to enable with defaults, or pass a `ToolbarConfig` object |
185
186
  | `dashboard` | `boolean \| DashboardConfig` | -- | `true` to enable at `/__stats`, or pass a `DashboardConfig` |
@@ -271,7 +272,7 @@ Each collector is a factory function that returns a `MetricCollector`. All colle
271
272
  | `httpCollector(opts?)` | Requests/sec, avg response time, error rate, active connections | optional | -- |
272
273
  | `dbPoolCollector(opts?)` | Pool used/free/pending/max connections | optional | `@adonisjs/lucid` |
273
274
  | `redisCollector()` | Status, memory, clients, keys, hit rate | none | `@adonisjs/redis` |
274
- | `queueCollector(opts)` | Active/waiting/delayed/failed jobs, worker count | **required** | `bullmq` |
275
+ | `queueCollector(opts)` | Active/waiting/delayed/failed jobs, worker count | **required** | `bullmq` or `@adonisjs/queue`/`@boringnode/queue` (auto-detected) |
275
276
  | `logCollector(opts?)` | Errors/warnings/entries (5m window), entries/minute | optional | -- |
276
277
  | `appCollector()` | Online users, pending webhooks, pending emails | none | `@adonisjs/lucid` |
277
278
 
@@ -376,9 +377,9 @@ export default defineConfig({
376
377
  })
377
378
  ```
378
379
 
379
- > **Tip:** When `authorize` is not set, the bar and all routes are accessible to everyone. In production you almost always want to set this.
380
+ > **Fail closed:** When neither `authorize` nor `shouldShow` is set, the dashboard, debug API, and stats routes are **not registered at all** and a warning is logged. To run without a guard during local development, set `unsafeAllowNoAuth: true` — this exposes secrets, email bodies, and SQL to anyone who can reach the routes, so never use it outside strictly local dev.
380
381
  >
381
- > **Migration note:** `shouldShow` still works as a deprecated alias for `authorize`. Both have the same signature and behavior.
382
+ > **Migration note:** `shouldShow` still works as a deprecated alias for `authorize` same signature, same behavior, and it fully satisfies the guard requirement above. If you already set `shouldShow` (or `authorize`), this change does not affect you; you'll only see a one-time rename hint at boot.
382
383
 
383
384
  ---
384
385
 
@@ -673,7 +674,7 @@ The debug toolbar captures all emails sent via AdonisJS mail (`mail:sending`, `m
673
674
 
674
675
  ### Cross-Process Email Capture (Queue Workers)
675
676
 
676
- AdonisJS mail events (`mail:sending`, `mail:sent`, etc.) are process-local. If your app sends emails from **Bull queue workers** or other separate processes, the web server's email collector never sees them.
677
+ AdonisJS mail events (`mail:sending`, `mail:sent`, etc.) are process-local. If your app sends emails from **queue workers** (BullMQ via `@rlanz/bull-queue`, or `@adonisjs/queue`/`@boringnode/queue`) or other separate processes, the web server's email collector never sees them.
677
678
 
678
679
  The provider handles this automatically via a **Redis pub/sub bridge**:
679
680
 
@@ -681,6 +682,8 @@ The provider handles this automatically via a **Redis pub/sub bridge**:
681
682
  2. When an email is sent, the event is published to a Redis pub/sub channel
682
683
  3. In the web server (`web` environment), the provider subscribes to the same channel and ingests the email into both the debug panel and the dashboard
683
684
 
685
+ Worker-sent emails appear in the dashboard with HTML preview alongside emails sent from web requests — no additional configuration needed.
686
+
684
687
  **Requirements:**
685
688
  - `@adonisjs/redis` must be installed and configured (used for pub/sub between processes)
686
689
  - The provider must be registered **without** an `environment` restriction so it loads in all environments:
@@ -810,7 +813,7 @@ export default defineConfig({
810
813
  | **Emails** | Email history with sender, recipient, subject, status. Click for HTML preview in iframe |
811
814
  | **Timeline** | Per-request waterfall timeline (requires `tracing: true`) |
812
815
  | **Cache** | Redis key browser with SCAN-based listing, type-aware detail view, and server stats (requires `@adonisjs/redis`) |
813
- | **Jobs** | Queue overview with job listing, detail, and retry for failed jobs (requires `@rlanz/bull-queue`) |
816
+ | **Jobs** | Queue overview with job listing, detail, and retry for failed jobs (requires `bullmq` or `@adonisjs/queue`/`@boringnode/queue` — auto-detected) |
814
817
  | **Config** | Sanitized view of app configuration and environment variables. Secrets are auto-redacted |
815
818
 
816
819
  #### Access Control
@@ -1069,7 +1072,9 @@ All integrations use lazy `import()` -- missing peer deps won't crash the app. T
1069
1072
  | `@adonisjs/transmit` | Provider (SSE broadcast), dashboard real-time |
1070
1073
  | `@adonisjs/transmit-client` | React/Vue real-time updates (falls back to polling) |
1071
1074
  | `@julr/adonisjs-prometheus` | `serverStatsCollector` |
1072
- | `bullmq` | `queueCollector` |
1075
+ | `bullmq` | `queueCollector` (BullMQ backend) |
1076
+ | `@adonisjs/queue` | `queueCollector` (AdonisJS queue backend, auto-detected) |
1077
+ | `@boringnode/queue` | `queueCollector` (AdonisJS queue backend, auto-detected) |
1073
1078
  | `better-sqlite3` | Dashboard (`dashboard: true`) |
1074
1079
  | `edge.js` | Edge tag |
1075
1080
  | `react`, `react-dom` | React components (alpha) |
package/dist/configure.js CHANGED
@@ -3,9 +3,14 @@ export async function configure(command) {
3
3
  const codemods = await command.createCodemods();
4
4
  // Publish config file
5
5
  await codemods.makeUsingStub(stubsRoot(), 'config.stub', {});
6
+ // The log-stream provider relies on @adonisjs/transmit for live log
7
+ // streaming, so only register it when the user opts in.
8
+ const enableLogStream = await command.prompt.confirm('Register the log-stream provider? (requires @adonisjs/transmit for live log streaming)', { default: false });
6
9
  // Register provider in adonisrc.ts
7
10
  await codemods.updateRcFile((rcFile) => {
8
11
  rcFile.addProvider('adonisjs-server-stats/provider', ['web']);
9
- rcFile.addProvider('adonisjs-server-stats/log-stream/provider', ['web']);
12
+ if (enableLogStream) {
13
+ rcFile.addProvider('adonisjs-server-stats/log-stream/provider', ['web']);
14
+ }
10
15
  });
11
16
  }
@@ -0,0 +1,83 @@
1
+ import { MetricValue } from '../types.js';
2
+ /**
3
+ * Interface that all metric collectors must implement.
4
+ *
5
+ * A collector is responsible for gathering a specific set of metrics
6
+ * (e.g. CPU, memory, HTTP stats) and returning them as a flat
7
+ * key-value record. The {@link StatsEngine} runs all configured
8
+ * collectors in parallel each tick and merges their results into
9
+ * a single {@link ServerStats} snapshot.
10
+ *
11
+ * @example Creating a custom collector
12
+ * ```ts
13
+ * import type { MetricCollector } from 'adonisjs-server-stats/collectors'
14
+ *
15
+ * function diskCollector(): MetricCollector {
16
+ * return {
17
+ * name: 'disk',
18
+ * async collect() {
19
+ * const { availableSpace, totalSpace } = await getDiskInfo()
20
+ * return {
21
+ * diskAvailableGb: availableSpace / 1e9,
22
+ * diskTotalGb: totalSpace / 1e9,
23
+ * diskUsagePercent: ((totalSpace - availableSpace) / totalSpace) * 100,
24
+ * }
25
+ * },
26
+ * }
27
+ * }
28
+ * ```
29
+ */
30
+ export interface MetricCollector {
31
+ /**
32
+ * Unique name identifying this collector.
33
+ *
34
+ * Used for logging and debugging. Built-in collectors use names
35
+ * like `'process'`, `'http'`, `'redis'`, etc.
36
+ */
37
+ name: string;
38
+ /**
39
+ * Short description shown in the startup log.
40
+ *
41
+ * Include key options so the developer can verify the collector
42
+ * is configured correctly at a glance.
43
+ *
44
+ * @example `'http — buffer: 10k, window: 60s'`
45
+ */
46
+ label?: string;
47
+ /**
48
+ * Called once when the {@link StatsEngine} starts.
49
+ *
50
+ * Use this to initialize resources (e.g. start monitoring the
51
+ * event loop, open file handles, connect to external services).
52
+ */
53
+ start?(): void | Promise<void>;
54
+ /**
55
+ * Called once when the {@link StatsEngine} stops (during app shutdown).
56
+ *
57
+ * Use this to clean up resources (e.g. close connections, clear timers).
58
+ */
59
+ stop?(): void | Promise<void>;
60
+ /**
61
+ * Return collector-specific configuration for diagnostics.
62
+ *
63
+ * Used by the Internals diagnostics endpoint to show resolved
64
+ * configuration for each collector. Sensitive values (e.g. passwords)
65
+ * should be redacted.
66
+ */
67
+ getConfig?(): Record<string, unknown>;
68
+ /**
69
+ * Collect metrics and return them as a flat key-value record.
70
+ *
71
+ * Called every tick (default: every 3 seconds). The engine calls
72
+ * all collectors in parallel via `Promise.all`, so this method
73
+ * should be as fast as possible.
74
+ *
75
+ * If the collector throws, the engine catches the error and
76
+ * proceeds with the remaining collectors (the failing collector's
77
+ * metrics will be missing from that tick).
78
+ *
79
+ * @returns A flat record of metric values. Keys should be unique
80
+ * across all collectors to avoid collisions when merged.
81
+ */
82
+ collect(): Record<string, MetricValue> | Promise<Record<string, MetricValue>>;
83
+ }
@@ -0,0 +1,186 @@
1
+ import { ServerStats } from '../types.js';
2
+ export type { ServerStats, MetricValue, ServerStatsConfig, ResolvedServerStatsConfig, DevToolbarOptions, ToolbarConfig, AdvancedConfig, } from '../types.js';
3
+ export type { DebugPane, DebugPaneColumn, DebugPaneSearch, DebugPaneFormatType, BadgeColor, QueryRecord, EventRecord, EmailRecord, RouteRecord, TraceRecord, TraceSpan, } from '../debug/types.js';
4
+ export type { OverviewMetrics, OverviewData, ChartDataPoint, GroupedQuery, DashboardCacheStats, DashboardCacheKeyEntry, DashboardCacheResponse, JobsApiResponse, JobStats, JobRecord, } from './types-dashboard.js';
5
+ export type { DiagnosticsBufferInfo, DiagnosticsCollectorInfo, DiagnosticsTimerInfo, DiagnosticsResponse, } from './types-diagnostics.js';
6
+ /**
7
+ * Props / config for the `<ServerStatsBar />` component.
8
+ */
9
+ export interface StatsBarProps {
10
+ /** Base URL for API calls. Defaults to `''` (same origin). */
11
+ baseUrl?: string;
12
+ /** Stats endpoint path. Defaults to `'/admin/api/server-stats'`. */
13
+ endpoint?: string;
14
+ /** Transmit channel name. Defaults to `'admin/server-stats'`. */
15
+ channelName?: string;
16
+ /** Optional auth token for Bearer auth (auto-detects cookies if omitted). */
17
+ authToken?: string;
18
+ /** Polling interval fallback in ms. Defaults to `3000`. */
19
+ pollInterval?: number;
20
+ /** CSS class overrides for the root element. */
21
+ className?: string;
22
+ }
23
+ /** Props for the `<DebugPanel />` component. */
24
+ export interface DebugPanelProps {
25
+ baseUrl?: string;
26
+ debugEndpoint?: string;
27
+ authToken?: string;
28
+ className?: string;
29
+ }
30
+ /** Props for the `<DashboardPage />` component. */
31
+ export interface DashboardPageProps {
32
+ baseUrl?: string;
33
+ dashboardEndpoint?: string;
34
+ authToken?: string;
35
+ channelName?: string;
36
+ className?: string;
37
+ }
38
+ /** Alias for {@link StatsBarProps}. Used by Vue components as config type. */
39
+ export interface StatsBarConfig extends StatsBarProps {
40
+ debugEndpoint?: string;
41
+ }
42
+ /** Alias for {@link DebugPanelProps}. Used by Vue components as config type. */
43
+ export interface DebugPanelConfig extends DebugPanelProps {
44
+ dashboardPath?: string;
45
+ tracingEnabled?: boolean;
46
+ isLive?: boolean;
47
+ }
48
+ /** Alias for {@link DashboardPageProps}. Used by Vue components as config type. */
49
+ export interface DashboardConfig extends DashboardPageProps {
50
+ tracingEnabled?: boolean;
51
+ }
52
+ /**
53
+ * Shape returned by `GET {debugEndpoint}/config`.
54
+ */
55
+ export interface FeatureFlags {
56
+ features: {
57
+ statsBar: boolean;
58
+ debugPanel: boolean;
59
+ dashboard: boolean;
60
+ tracing: boolean;
61
+ process: boolean;
62
+ system: boolean;
63
+ http: boolean;
64
+ db: boolean;
65
+ redis: boolean;
66
+ queues: boolean;
67
+ cache: boolean;
68
+ app: boolean;
69
+ log: boolean;
70
+ emails: boolean;
71
+ };
72
+ customPanes: import('../debug/types.js').DebugPane[];
73
+ endpoints: {
74
+ stats: string;
75
+ debug: string;
76
+ dashboard: string;
77
+ };
78
+ transmit: {
79
+ channelName: string;
80
+ };
81
+ }
82
+ /**
83
+ * Flattened feature config used by Vue composables.
84
+ */
85
+ export interface FeatureConfig {
86
+ tracing: boolean;
87
+ process: boolean;
88
+ system: boolean;
89
+ http: boolean;
90
+ db: boolean;
91
+ redis: boolean;
92
+ queues: boolean;
93
+ cache: boolean;
94
+ app: boolean;
95
+ log: boolean;
96
+ emails: boolean;
97
+ dashboard: boolean;
98
+ customPanes: import('../debug/types.js').DebugPane[];
99
+ }
100
+ /** Threshold color result. */
101
+ export type ThresholdColor = 'green' | 'amber' | 'red';
102
+ /**
103
+ * Definition for a single metric displayed in the stats bar.
104
+ */
105
+ export interface MetricDefinition {
106
+ id: string;
107
+ label: string;
108
+ title?: string;
109
+ unit: string;
110
+ group?: string;
111
+ warnThreshold?: number;
112
+ critThreshold?: number;
113
+ inverseThreshold?: boolean;
114
+ extract: (stats: ServerStats) => number | undefined;
115
+ format: (stats: ServerStats) => string;
116
+ value?: (stats: ServerStats) => string;
117
+ color?: (stats: ServerStats) => string;
118
+ detail?: string | ((stats: ServerStats) => string | null);
119
+ historyKey?: string | undefined;
120
+ show?: (stats: ServerStats) => boolean;
121
+ }
122
+ /** Options for SVG sparkline rendering. */
123
+ export interface SparklineOptions {
124
+ color?: string;
125
+ fillOpacityTop?: number;
126
+ fillOpacityBottom?: number;
127
+ strokeWidth?: number;
128
+ width?: number;
129
+ height?: number;
130
+ padding?: number;
131
+ }
132
+ /**
133
+ * Options for the `useDashboardData` hook.
134
+ */
135
+ export interface DashboardHookOptions extends DashboardPageProps {
136
+ page?: number;
137
+ perPage?: number;
138
+ search?: string;
139
+ sort?: string;
140
+ sortDir?: 'asc' | 'desc';
141
+ filters?: Record<string, string>;
142
+ timeRange?: TimeRange;
143
+ refreshKey?: number;
144
+ }
145
+ export type DebugTab = 'timeline' | 'queries' | 'events' | 'routes' | 'logs' | 'emails' | 'cache' | 'jobs' | (string & {});
146
+ export type DashboardSection = 'overview' | 'requests' | 'queries' | 'events' | 'routes' | 'logs' | 'emails' | 'cache' | 'jobs' | 'config' | (string & {});
147
+ export type TimeRange = '5m' | '15m' | '30m' | '1h' | '6h' | '24h' | '7d';
148
+ export interface PaginatedResponse<T> {
149
+ data: T[];
150
+ meta: {
151
+ total: number;
152
+ page: number;
153
+ perPage: number;
154
+ lastPage: number;
155
+ };
156
+ }
157
+ export interface CacheStats {
158
+ hitRate: number;
159
+ totalHits: number;
160
+ totalMisses: number;
161
+ keys: CacheEntry[];
162
+ keyCount?: number;
163
+ memoryUsedMb?: number;
164
+ }
165
+ export interface CacheEntry {
166
+ key: string;
167
+ type: string;
168
+ ttl: number;
169
+ size: number;
170
+ value?: string | number | boolean | Record<string, unknown> | unknown[] | null;
171
+ }
172
+ export interface PaginationState {
173
+ page: number;
174
+ perPage: number;
175
+ total: number;
176
+ totalPages: number;
177
+ }
178
+ export interface FilterState {
179
+ search: string;
180
+ filters: Record<string, string>;
181
+ }
182
+ export interface SortState {
183
+ field: string;
184
+ direction: 'asc' | 'desc';
185
+ }
186
+ export type { Theme } from './theme.js';