@antelopejs/dms-api 0.1.6 → 0.2.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 (347) hide show
  1. package/README.md +99 -8
  2. package/dist/automation/get-api-health.js +4 -3
  3. package/dist/automation/get-api-health.js.map +1 -1
  4. package/dist/automation/route-unhealthy.js +2 -2
  5. package/dist/automation/route-unhealthy.js.map +1 -1
  6. package/dist/automation/scope.d.ts +0 -1
  7. package/dist/automation/scope.js +0 -7
  8. package/dist/automation/scope.js.map +1 -1
  9. package/dist/config.d.ts +4 -0
  10. package/dist/config.js +15 -9
  11. package/dist/config.js.map +1 -1
  12. package/dist/db/models/request_log.model.d.ts +37 -2
  13. package/dist/db/models/request_log.model.js +130 -35
  14. package/dist/db/models/request_log.model.js.map +1 -1
  15. package/dist/db/models/request_log.search.d.ts +5 -0
  16. package/dist/db/models/request_log.search.js +35 -0
  17. package/dist/db/models/request_log.search.js.map +1 -0
  18. package/dist/db/models/request_log.status.d.ts +5 -0
  19. package/dist/db/models/request_log.status.js +9 -0
  20. package/dist/db/models/request_log.status.js.map +1 -0
  21. package/dist/db/models/routes.model.d.ts +1 -0
  22. package/dist/db/models/routes.model.js +5 -1
  23. package/dist/db/models/routes.model.js.map +1 -1
  24. package/dist/db/models/routes_statistics.model.js +1 -1
  25. package/dist/db/models/routes_statistics.model.js.map +1 -1
  26. package/dist/db/tables/api_settings.table.d.ts +1 -0
  27. package/dist/db/tables/api_settings.table.js +4 -0
  28. package/dist/db/tables/api_settings.table.js.map +1 -1
  29. package/dist/db/tables/request_log.table.d.ts +18 -3
  30. package/dist/db/tables/request_log.table.js +34 -1
  31. package/dist/db/tables/request_log.table.js.map +1 -1
  32. package/dist/db/tables/routes.table.d.ts +1 -2
  33. package/dist/db/tables/routes.table.js.map +1 -1
  34. package/dist/db/tables/routes_statistics.table.d.ts +4 -3
  35. package/dist/db/tables/routes_statistics.table.js +5 -1
  36. package/dist/db/tables/routes_statistics.table.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +9 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/memo.d.ts +5 -0
  41. package/dist/memo.js +36 -0
  42. package/dist/memo.js.map +1 -0
  43. package/dist/pages/blocks.d.ts +3 -0
  44. package/dist/pages/blocks.js +31 -0
  45. package/dist/pages/blocks.js.map +1 -0
  46. package/dist/pages/displays.d.ts +7 -0
  47. package/dist/pages/displays.js +23 -0
  48. package/dist/pages/displays.js.map +1 -0
  49. package/dist/pages/index.d.ts +5 -2
  50. package/dist/pages/index.js +5 -2
  51. package/dist/pages/index.js.map +1 -1
  52. package/dist/pages/logs.d.ts +18 -0
  53. package/dist/pages/logs.js +112 -0
  54. package/dist/pages/logs.js.map +1 -0
  55. package/dist/pages/module.d.ts +3 -0
  56. package/dist/pages/module.js +102 -6
  57. package/dist/pages/module.js.map +1 -1
  58. package/dist/pages/overview.d.ts +14 -0
  59. package/dist/pages/overview.js +215 -0
  60. package/dist/pages/overview.js.map +1 -0
  61. package/dist/pages/period.d.ts +9 -0
  62. package/dist/pages/period.js +24 -0
  63. package/dist/pages/period.js.map +1 -0
  64. package/dist/pages/request-table.d.ts +11 -0
  65. package/dist/pages/request-table.js +187 -0
  66. package/dist/pages/request-table.js.map +1 -0
  67. package/dist/pages/routes.d.ts +15 -0
  68. package/dist/pages/routes.js +269 -0
  69. package/dist/pages/routes.js.map +1 -0
  70. package/dist/pages/scope-chip.d.ts +9 -0
  71. package/dist/pages/scope-chip.js +28 -0
  72. package/dist/pages/scope-chip.js.map +1 -0
  73. package/dist/pages/{logs/page.d.ts → settings.d.ts} +3 -3
  74. package/dist/pages/settings.js +218 -0
  75. package/dist/pages/settings.js.map +1 -0
  76. package/dist/pages/toolbar.d.ts +9 -0
  77. package/dist/pages/toolbar.js +33 -0
  78. package/dist/pages/toolbar.js.map +1 -0
  79. package/dist/realtime.d.ts +2 -0
  80. package/dist/realtime.js +21 -0
  81. package/dist/realtime.js.map +1 -0
  82. package/dist/routes/index.d.ts +2 -2
  83. package/dist/routes/index.js +2 -2
  84. package/dist/routes/index.js.map +1 -1
  85. package/dist/routes/logs.d.ts +173 -2
  86. package/dist/routes/logs.js +177 -86
  87. package/dist/routes/logs.js.map +1 -1
  88. package/dist/routes/overview.d.ts +27 -0
  89. package/dist/routes/overview.js +131 -0
  90. package/dist/routes/overview.js.map +1 -0
  91. package/dist/routes/routes.d.ts +92 -28
  92. package/dist/routes/routes.js +165 -97
  93. package/dist/routes/routes.js.map +1 -1
  94. package/dist/routes/settings.d.ts +16 -11
  95. package/dist/routes/settings.js +62 -54
  96. package/dist/routes/settings.js.map +1 -1
  97. package/dist/routes/tester.d.ts +7 -0
  98. package/dist/routes/tester.js +34 -0
  99. package/dist/routes/tester.js.map +1 -0
  100. package/dist/services/activity.d.ts +49 -0
  101. package/dist/services/activity.js +207 -0
  102. package/dist/services/activity.js.map +1 -0
  103. package/dist/services/aggregate-cache.d.ts +3 -0
  104. package/dist/services/aggregate-cache.js +16 -0
  105. package/dist/services/aggregate-cache.js.map +1 -0
  106. package/dist/services/api-origin.d.ts +1 -0
  107. package/dist/services/api-origin.js +9 -0
  108. package/dist/services/api-origin.js.map +1 -0
  109. package/dist/services/attention.d.ts +45 -0
  110. package/dist/services/attention.js +203 -0
  111. package/dist/services/attention.js.map +1 -0
  112. package/dist/services/composed-text.d.ts +6 -0
  113. package/dist/services/composed-text.js +23 -0
  114. package/dist/services/composed-text.js.map +1 -0
  115. package/dist/services/health-rules.d.ts +49 -0
  116. package/dist/services/health-rules.js +233 -0
  117. package/dist/services/health-rules.js.map +1 -0
  118. package/dist/services/index.d.ts +1 -3
  119. package/dist/services/index.js +3 -3
  120. package/dist/services/index.js.map +1 -1
  121. package/dist/services/introspection/decorators.d.ts +14 -0
  122. package/dist/services/introspection/decorators.js +192 -0
  123. package/dist/services/introspection/decorators.js.map +1 -0
  124. package/dist/services/introspection/errors.js +4 -4
  125. package/dist/services/introspection/errors.js.map +1 -1
  126. package/dist/services/introspection/index.d.ts +6 -8
  127. package/dist/services/introspection/index.js +96 -32
  128. package/dist/services/introspection/index.js.map +1 -1
  129. package/dist/services/introspection/probe.d.ts +2 -1
  130. package/dist/services/introspection/probe.js +11 -0
  131. package/dist/services/introspection/probe.js.map +1 -1
  132. package/dist/services/links.d.ts +25 -0
  133. package/dist/services/links.js +72 -0
  134. package/dist/services/links.js.map +1 -0
  135. package/dist/services/live-feed.d.ts +6 -0
  136. package/dist/services/live-feed.js +18 -0
  137. package/dist/services/live-feed.js.map +1 -0
  138. package/dist/services/live.d.ts +16 -0
  139. package/dist/services/live.js +32 -0
  140. package/dist/services/live.js.map +1 -0
  141. package/dist/services/overview.d.ts +122 -0
  142. package/dist/services/overview.js +324 -0
  143. package/dist/services/overview.js.map +1 -0
  144. package/dist/services/period.d.ts +0 -9
  145. package/dist/services/period.js +5 -52
  146. package/dist/services/period.js.map +1 -1
  147. package/dist/services/request-log/access.d.ts +5 -0
  148. package/dist/services/request-log/access.js +21 -0
  149. package/dist/services/request-log/access.js.map +1 -0
  150. package/dist/services/request-log/capture.d.ts +30 -0
  151. package/dist/services/request-log/capture.js +216 -39
  152. package/dist/services/request-log/capture.js.map +1 -1
  153. package/dist/services/request-log/list.d.ts +36 -0
  154. package/dist/services/request-log/list.js +201 -0
  155. package/dist/services/request-log/list.js.map +1 -0
  156. package/dist/services/request-log/read.d.ts +15 -2
  157. package/dist/services/request-log/read.js +47 -4
  158. package/dist/services/request-log/read.js.map +1 -1
  159. package/dist/services/request-log/redaction.d.ts +16 -3
  160. package/dist/services/request-log/redaction.js +149 -27
  161. package/dist/services/request-log/redaction.js.map +1 -1
  162. package/dist/services/request-log/util.d.ts +10 -3
  163. package/dist/services/request-log/util.js +39 -22
  164. package/dist/services/request-log/util.js.map +1 -1
  165. package/dist/services/route-catalog.d.ts +62 -0
  166. package/dist/services/route-catalog.js +163 -0
  167. package/dist/services/route-catalog.js.map +1 -0
  168. package/dist/services/route-contract.d.ts +66 -0
  169. package/dist/services/route-contract.js +266 -0
  170. package/dist/services/route-contract.js.map +1 -0
  171. package/dist/services/route-health.d.ts +35 -0
  172. package/dist/services/route-health.js +179 -0
  173. package/dist/services/route-health.js.map +1 -0
  174. package/dist/services/route-statistics.d.ts +68 -0
  175. package/dist/services/route-statistics.js +277 -0
  176. package/dist/services/route-statistics.js.map +1 -0
  177. package/dist/services/routes-sync.d.ts +7 -3
  178. package/dist/services/routes-sync.js +96 -20
  179. package/dist/services/routes-sync.js.map +1 -1
  180. package/dist/services/scope.d.ts +0 -1
  181. package/dist/services/scope.js +4 -17
  182. package/dist/services/scope.js.map +1 -1
  183. package/dist/services/settings-form.d.ts +131 -0
  184. package/dist/services/settings-form.js +210 -0
  185. package/dist/services/settings-form.js.map +1 -0
  186. package/dist/services/settings.d.ts +2 -0
  187. package/dist/services/settings.js +5 -0
  188. package/dist/services/settings.js.map +1 -1
  189. package/dist/services/statistics-aggregate.d.ts +6 -41
  190. package/dist/services/statistics-aggregate.js +55 -280
  191. package/dist/services/statistics-aggregate.js.map +1 -1
  192. package/dist/services/statistics-utils.d.ts +7 -12
  193. package/dist/services/statistics-utils.js +36 -51
  194. package/dist/services/statistics-utils.js.map +1 -1
  195. package/dist/services/statistics-write.js +64 -22
  196. package/dist/services/statistics-write.js.map +1 -1
  197. package/dist/services/tester-source.d.ts +11 -0
  198. package/dist/services/tester-source.js +48 -0
  199. package/dist/services/tester-source.js.map +1 -0
  200. package/dist/services/traffic-samples.d.ts +18 -0
  201. package/dist/services/traffic-samples.js +134 -0
  202. package/dist/services/traffic-samples.js.map +1 -0
  203. package/dist/services/traffic.d.ts +43 -0
  204. package/dist/services/traffic.js +270 -0
  205. package/dist/services/traffic.js.map +1 -0
  206. package/dist/services/window.d.ts +48 -0
  207. package/dist/services/window.js +179 -0
  208. package/dist/services/window.js.map +1 -0
  209. package/dist/types/constants.d.ts +11 -20
  210. package/dist/types/constants.js +15 -25
  211. package/dist/types/constants.js.map +1 -1
  212. package/dist/types/index.d.ts +0 -1
  213. package/dist/types/index.js +0 -1
  214. package/dist/types/index.js.map +1 -1
  215. package/dist/types/statistics.d.ts +5 -3
  216. package/dist/types/statistics.js +5 -0
  217. package/dist/types/statistics.js.map +1 -1
  218. package/frontend-vue/app/components/blocks/BetaBadge.vue +20 -0
  219. package/frontend-vue/app/components/blocks/HealthHero.vue +708 -0
  220. package/frontend-vue/app/components/blocks/LiveTraffic.vue +356 -0
  221. package/frontend-vue/app/components/blocks/LogsEmptyState.vue +228 -0
  222. package/frontend-vue/app/components/blocks/LogsFilters.vue +279 -0
  223. package/frontend-vue/app/components/blocks/RequestDetail.vue +722 -0
  224. package/frontend-vue/app/components/blocks/RetentionInput.vue +227 -0
  225. package/frontend-vue/app/components/blocks/RouteDocumentation.vue +611 -0
  226. package/frontend-vue/app/components/blocks/RouteHeader.vue +320 -0
  227. package/frontend-vue/app/components/blocks/RouteTester.vue +1879 -0
  228. package/frontend-vue/app/components/blocks/RouteTree.vue +676 -0
  229. package/frontend-vue/app/components/blocks/ScopeChip.vue +89 -0
  230. package/frontend-vue/app/components/blocks/SettingNumberInput.vue +65 -0
  231. package/frontend-vue/app/components/blocks/SplitLayout.vue +41 -0
  232. package/frontend-vue/app/components/internal/ApiBody.vue +129 -0
  233. package/frontend-vue/app/components/internal/ApiJsonTree.vue +82 -0
  234. package/frontend-vue/app/components/internal/ApiKeyValues.vue +41 -0
  235. package/frontend-vue/app/components/internal/ApiMethodBadge.vue +19 -19
  236. package/frontend-vue/app/components/internal/ApiPath.vue +33 -0
  237. package/frontend-vue/app/components/internal/ApiStatusBadge.vue +20 -15
  238. package/frontend-vue/app/components/internal/ApiTesterBadge.vue +17 -0
  239. package/frontend-vue/app/composables/useApiOrigin.ts +19 -0
  240. package/frontend-vue/app/composables/useApiPeriod.ts +19 -0
  241. package/frontend-vue/app/composables/useApiResource.ts +92 -0
  242. package/frontend-vue/app/composables/useDateFormat.ts +23 -0
  243. package/frontend-vue/app/composables/useLiveMissedErrors.ts +33 -0
  244. package/frontend-vue/app/composables/useRouteDetail.ts +253 -0
  245. package/frontend-vue/app/composables/useRouteSelection.ts +43 -0
  246. package/frontend-vue/app/config/shortcuts-registry.ts +30 -0
  247. package/frontend-vue/app/plugins/displays.ts +92 -0
  248. package/frontend-vue/app/utils/format.ts +281 -0
  249. package/frontend-vue/app/utils/http.ts +127 -0
  250. package/frontend-vue/app/utils/logsQuery.ts +261 -0
  251. package/frontend-vue/app/utils/minuteHistogram.ts +116 -0
  252. package/frontend-vue/app/utils/requestDrawer.ts +257 -0
  253. package/frontend-vue/app/utils/routeExplorer.ts +206 -0
  254. package/frontend-vue/app/utils/search.ts +45 -0
  255. package/frontend-vue/app/utils/settingsForm.ts +119 -0
  256. package/frontend-vue/app/utils/snippets.ts +501 -0
  257. package/frontend-vue/app/utils/testerHistory.ts +354 -0
  258. package/frontend-vue/app/utils/testerRequest.ts +632 -11
  259. package/frontend-vue/dms.frontend.build.ts +7 -0
  260. package/frontend-vue/dms.frontend.ts +10 -3
  261. package/frontend-vue/i18n/locales/api-en-GB.json +866 -0
  262. package/frontend-vue/i18n/locales/api-fr-FR.json +866 -0
  263. package/frontend-vue/package.json +4 -5
  264. package/frontend-vue/pnpm-lock.yaml +97 -3375
  265. package/frontend-vue/tests/format.test.ts +180 -0
  266. package/frontend-vue/tests/http.test.ts +61 -0
  267. package/frontend-vue/tests/logsQuery.test.ts +255 -0
  268. package/frontend-vue/tests/minuteHistogram.test.ts +94 -0
  269. package/frontend-vue/tests/registration.test.ts +24 -7
  270. package/frontend-vue/tests/requestDrawer.test.ts +179 -0
  271. package/frontend-vue/tests/routeExplorer.test.ts +206 -0
  272. package/frontend-vue/tests/settingsForm.test.ts +155 -0
  273. package/frontend-vue/tests/snippets.test.ts +285 -0
  274. package/frontend-vue/tests/testerHistory.test.ts +295 -0
  275. package/frontend-vue/tests/testerRequest.test.ts +471 -76
  276. package/frontend-vue/tests/tooltipTriggers.test.ts +51 -0
  277. package/package.json +8 -8
  278. package/dist/middlewares/index.d.ts +0 -1
  279. package/dist/middlewares/index.js +0 -18
  280. package/dist/middlewares/index.js.map +0 -1
  281. package/dist/middlewares/request-log-capture.d.ts +0 -1
  282. package/dist/middlewares/request-log-capture.js +0 -6
  283. package/dist/middlewares/request-log-capture.js.map +0 -1
  284. package/dist/pages/all.d.ts +0 -4
  285. package/dist/pages/all.js +0 -21
  286. package/dist/pages/all.js.map +0 -1
  287. package/dist/pages/logs/page.js +0 -29
  288. package/dist/pages/logs/page.js.map +0 -1
  289. package/dist/pages/routes/page.d.ts +0 -9
  290. package/dist/pages/routes/page.js +0 -29
  291. package/dist/pages/routes/page.js.map +0 -1
  292. package/dist/pages/settings/form.d.ts +0 -3
  293. package/dist/pages/settings/form.js +0 -80
  294. package/dist/pages/settings/form.js.map +0 -1
  295. package/dist/pages/settings/page.d.ts +0 -9
  296. package/dist/pages/settings/page.js +0 -26
  297. package/dist/pages/settings/page.js.map +0 -1
  298. package/dist/pages/summary/page.d.ts +0 -9
  299. package/dist/pages/summary/page.js +0 -29
  300. package/dist/pages/summary/page.js.map +0 -1
  301. package/dist/routes/monitoring.d.ts +0 -17
  302. package/dist/routes/monitoring.js +0 -101
  303. package/dist/routes/monitoring.js.map +0 -1
  304. package/dist/routes/summary.d.ts +0 -32
  305. package/dist/routes/summary.js +0 -181
  306. package/dist/routes/summary.js.map +0 -1
  307. package/dist/services/request-log/index.d.ts +0 -3
  308. package/dist/services/request-log/index.js +0 -12
  309. package/dist/services/request-log/index.js.map +0 -1
  310. package/dist/services/statistics-read.d.ts +0 -4
  311. package/dist/services/statistics-read.js +0 -48
  312. package/dist/services/statistics-read.js.map +0 -1
  313. package/dist/services/tree.d.ts +0 -10
  314. package/dist/services/tree.js +0 -128
  315. package/dist/services/tree.js.map +0 -1
  316. package/dist/types/charts.d.ts +0 -9
  317. package/dist/types/charts.js +0 -3
  318. package/dist/types/charts.js.map +0 -1
  319. package/frontend-vue/app/components/ConfigurationView.vue +0 -187
  320. package/frontend-vue/app/components/DocumentationView.vue +0 -224
  321. package/frontend-vue/app/components/LogDetailDrawer.vue +0 -178
  322. package/frontend-vue/app/components/LogsView.vue +0 -347
  323. package/frontend-vue/app/components/RouteDetailTabs.vue +0 -179
  324. package/frontend-vue/app/components/RouteTree.vue +0 -196
  325. package/frontend-vue/app/components/RoutesView.vue +0 -79
  326. package/frontend-vue/app/components/StatsView.vue +0 -268
  327. package/frontend-vue/app/components/SummaryView.vue +0 -657
  328. package/frontend-vue/app/components/TesterPanel.vue +0 -499
  329. package/frontend-vue/app/components/internal/PeriodSelect.vue +0 -58
  330. package/frontend-vue/app/components/internal/RouteTreeNode.vue +0 -168
  331. package/frontend-vue/app/components/internal/StatusBreakdownBars.vue +0 -162
  332. package/frontend-vue/app/components/internal/StatusDonut.vue +0 -84
  333. package/frontend-vue/app/components/internal/UnitAreaChart.vue +0 -73
  334. package/frontend-vue/app/composables/useApiIntrospection.ts +0 -350
  335. package/frontend-vue/app/composables/useLogDetailDrawer.ts +0 -50
  336. package/frontend-vue/app/composables/useSelectedPeriod.ts +0 -107
  337. package/frontend-vue/app/composables/useStatsPeriods.ts +0 -139
  338. package/frontend-vue/app/custom-layouts/.gitkeep +0 -0
  339. package/frontend-vue/app/custom-pages/.gitkeep +0 -0
  340. package/frontend-vue/app/utils/httpMethod.ts +0 -49
  341. package/frontend-vue/app/utils/statusClass.ts +0 -49
  342. package/frontend-vue/i18n/locales/en-GB.json +0 -240
  343. package/frontend-vue/i18n/locales/fr-FR.json +0 -240
  344. package/frontend-vue/public/.gitkeep +0 -0
  345. package/frontend-vue/server/.gitkeep +0 -0
  346. package/frontend-vue/tests/periods.test.ts +0 -145
  347. package/frontend-vue/tests/persistence.test.ts +0 -45
@@ -0,0 +1,708 @@
1
+ <script setup lang="ts">
2
+ import { computed, watch } from 'vue'
3
+ import {
4
+ durationParts,
5
+ formatClock,
6
+ formatCount,
7
+ formatDecimal,
8
+ formatFullDateTime,
9
+ formatMs,
10
+ formatPercent,
11
+ formatRelativeDay,
12
+ formatThreshold,
13
+ spanPart,
14
+ } from '../../utils/format'
15
+
16
+ // The verdict leads the Overview: is the API healthy, since when, why not,
17
+ // and the one action that starts the investigation. The verdict and its
18
+ // figures cover a short window (the last `thresholds.windowMinutes`), so the
19
+ // hero says what is happening now and comes back to Healthy once an incident
20
+ // is over. With no request captured yet, the same place explains how to get
21
+ // the first one in. It follows the page's Direct / Pause state (`usePageLive`,
22
+ // the DMS `LiveToggle`): read again on the live feed and every minute in
23
+ // Direct, still while paused. A change
24
+ // of verdict seen live is told in a toast, and an unhealthy verdict shows in
25
+ // the browser tab.
26
+ defineOptions({ inheritAttrs: false })
27
+
28
+ const props = defineProps<{
29
+ fetchUrl: string
30
+ /** The live feed (`LIVE_REQUESTS_TOPIC`): the verdict is read again on it. */
31
+ realtimeTopic?: string
32
+ }>()
33
+
34
+ type Verdict = 'down' | 'degraded' | 'recovered' | 'operational' | 'idle'
35
+
36
+ /** Rates in percent (0–100); the figures cover the last `windowMinutes`. */
37
+ interface HealthMetrics {
38
+ serverErrorRate: number
39
+ clientErrorRate: number
40
+ /** Null when no call was measured in the window. */
41
+ p95Ms: number | null
42
+ requestsPerMinute: number
43
+ }
44
+
45
+ /** Rates in percent, like the metrics. */
46
+ interface HealthThresholds {
47
+ /** Degraded from this 5xx rate over `windowMinutes`. */
48
+ degradedServerErrorRate: number
49
+ /** Down from this 5xx rate over `downWindowMinutes`. */
50
+ downServerErrorRate: number
51
+ windowMinutes: number
52
+ downWindowMinutes: number
53
+ /** How far back the verdict looks for an incident. */
54
+ lookbackMinutes: number
55
+ /** The slow threshold of the settings: a p95 from it is slow. */
56
+ slowThresholdMs: number
57
+ }
58
+
59
+ /** What one rule reads now, over its own window. */
60
+ interface RuleWindow {
61
+ minutes: number
62
+ requests: number
63
+ serverErrors: number
64
+ serverErrorRate: number
65
+ }
66
+
67
+ interface HealthPayload {
68
+ verdict: Verdict
69
+ /** Start of the current incident, or of the last one. */
70
+ incidentStart: string | null
71
+ /** How long the verdict has held; null when longer than the lookback. */
72
+ durationMs: number | null
73
+ checkedAt: string
74
+ metrics: HealthMetrics
75
+ /** The degraded and down rules' windows; null without any call. */
76
+ ruleWindows: { degraded: RuleWindow; down: RuleWindow } | null
77
+ thresholds: HealthThresholds
78
+ failingRoutes: number
79
+ recoveredRoutes: number
80
+ slowRoutes: number
81
+ serverErrors: number
82
+ routes: { value: number; needingAttention: number }
83
+ serverErrorsLink: string
84
+ firstRun: boolean
85
+ }
86
+
87
+ type MetricTone = 'default' | 'warning' | 'error' | 'muted'
88
+
89
+ interface HeroMetric {
90
+ id: string
91
+ label: string
92
+ value: string
93
+ unit?: string
94
+ sub: string
95
+ tone: MetricTone
96
+ /** A figure of context: smaller, and grey whatever its value. */
97
+ secondary?: boolean
98
+ }
99
+
100
+ interface VerdictLook {
101
+ icon: string
102
+ text: string
103
+ dot: string
104
+ tint: string
105
+ line: string
106
+ }
107
+
108
+ const MS_PER_MINUTE = 60_000
109
+
110
+ const OK_LOOK = {
111
+ text: 'text-highlighted',
112
+ dot: 'bg-success',
113
+ tint: 'var(--dms-success-tint)',
114
+ line: 'var(--dms-success-line)',
115
+ }
116
+
117
+ const LOOKS: Record<Verdict, VerdictLook> = {
118
+ operational: { ...OK_LOOK, icon: 'i-ph-check-circle' },
119
+ recovered: { ...OK_LOOK, icon: 'i-ph-arrow-counter-clockwise' },
120
+ degraded: {
121
+ icon: 'i-ph-warning',
122
+ text: 'text-warning',
123
+ dot: 'bg-warning',
124
+ tint: 'var(--dms-warning-tint)',
125
+ line: 'var(--dms-warning-line)',
126
+ },
127
+ down: {
128
+ icon: 'i-ph-x-circle',
129
+ text: 'text-error',
130
+ dot: 'bg-error',
131
+ tint: 'var(--dms-error-tint)',
132
+ line: 'var(--dms-error-line)',
133
+ },
134
+ idle: {
135
+ icon: 'i-ph-info',
136
+ text: 'text-info',
137
+ dot: 'bg-info',
138
+ tint: 'var(--dms-info-tint)',
139
+ line: 'var(--dms-info-line)',
140
+ },
141
+ }
142
+
143
+ const RING_TEXT: Record<Verdict, string> = {
144
+ operational: 'text-success',
145
+ recovered: 'text-success',
146
+ degraded: 'text-warning',
147
+ down: 'text-error',
148
+ idle: 'text-info',
149
+ }
150
+
151
+ const METRIC_TONE: Record<MetricTone, string> = {
152
+ default: 'text-highlighted',
153
+ warning: 'text-warning',
154
+ error: 'text-error',
155
+ muted: 'text-muted',
156
+ }
157
+
158
+ const { t } = useI18n()
159
+ const { formatLocale: locale } = useRegionalFormat({ locale: 'format' })
160
+ const dateFormat = useDateFormat()
161
+ const toast = useToast()
162
+ const { isLive } = usePageLive()
163
+ const { data, error, pending, receivedAt, refresh } =
164
+ useApiResource<HealthPayload>(() => props.fetchUrl)
165
+
166
+ // Read again on the live feed at the page's pace, and after a quiet minute:
167
+ // the verdict judges time too. Never while paused.
168
+ usePageLiveRefresh(() => void refresh(), {
169
+ realtimeTopic: props.realtimeTopic,
170
+ idleRefresh: 60,
171
+ })
172
+
173
+ /** Refresh reads the whole page again, not this block alone. */
174
+ function refreshPage() {
175
+ refreshPageBlocks()
176
+ }
177
+
178
+ const UNHEALTHY: Verdict[] = ['degraded', 'down']
179
+ const TOAST_COLORS: Record<Verdict, 'error' | 'warning' | 'success' | 'info'> =
180
+ {
181
+ down: 'error',
182
+ degraded: 'warning',
183
+ recovered: 'success',
184
+ operational: 'success',
185
+ idle: 'info',
186
+ }
187
+
188
+ const verdictLabel = (verdict: Verdict) => t(`api.health.verdict.${verdict}`)
189
+
190
+ // A verdict that changes under the user's eyes: said once, in a toast.
191
+ watch(
192
+ () => data.value?.verdict,
193
+ (next, previous) => {
194
+ if (!next || !previous || next === previous) return
195
+ toast.add({
196
+ title: t('api.live_mode.verdict.title', { verdict: verdictLabel(next) }),
197
+ description: t('api.live_mode.verdict.description', {
198
+ previous: verdictLabel(previous),
199
+ }),
200
+ color: TOAST_COLORS[next],
201
+ icon: LOOKS[next].icon,
202
+ })
203
+ },
204
+ )
205
+
206
+ // "● Degraded · Overview" in the browser tab while the API is unhealthy.
207
+ useHead({
208
+ title: computed(() => {
209
+ const verdict = data.value?.verdict
210
+ return verdict && UNHEALTHY.includes(verdict)
211
+ ? t('api.live_mode.verdict.tab', {
212
+ verdict: verdictLabel(verdict),
213
+ page: t('api.overview.title'),
214
+ })
215
+ : undefined
216
+ }),
217
+ })
218
+
219
+ const count = (value: number) => formatCount(value, locale.value)
220
+ const rate = (value: number) => formatPercent(value, locale.value)
221
+
222
+ /** "38 min", "2 h 5 min": the parts worded in the interface language. */
223
+ function duration(ms: number): string {
224
+ return durationParts(ms)
225
+ .map(({ amount, unit }) =>
226
+ t(`api.health.duration.${unit}`, { n: count(amount) }),
227
+ )
228
+ .join(' ')
229
+ }
230
+
231
+ /** How long the verdict has held: "for 38 min", or longer than the lookback. */
232
+ function heldFor(health: HealthPayload): string {
233
+ if (health.durationMs !== null) {
234
+ return t('api.health.for', { duration: duration(health.durationMs) })
235
+ }
236
+ const { amount, unit } = spanPart(
237
+ health.thresholds.lookbackMinutes * MS_PER_MINUTE,
238
+ )
239
+ return t('api.health.for_over', {
240
+ duration: t(`api.health.duration.${unit}`, { n: count(amount) }),
241
+ })
242
+ }
243
+
244
+ // A failed refresh keeps the last figures on screen: they are no longer live.
245
+ const stale = computed(() => !!error.value && !!data.value)
246
+ const staleSince = computed(() =>
247
+ receivedAt.value ? formatClock(receivedAt.value, dateFormat.value) : '',
248
+ )
249
+
250
+ const look = computed(() => (data.value ? LOOKS[data.value.verdict] : null))
251
+ const cardStyle = computed(() => ({
252
+ '--dms-status-tint': look.value?.tint,
253
+ '--dms-status-line': look.value?.line,
254
+ background:
255
+ 'radial-gradient(420px 180px at 0% 50%, var(--dms-status-tint), transparent 70%), var(--ui-bg)',
256
+ }))
257
+
258
+ const heading = computed(
259
+ () =>
260
+ `${t('api.health.label')} · ${t(stale.value ? 'api.health.state.stale' : isLive.value ? 'api.health.state.live' : 'api.health.state.paused')}`,
261
+ )
262
+
263
+ /** When the verdict on screen began: what "for 8 min" counts from. */
264
+ function verdictSince(health: HealthPayload): Date | null {
265
+ if (health.durationMs === null) return null
266
+ const checked = Date.parse(health.checkedAt)
267
+ return Number.isNaN(checked) ? null : new Date(checked - health.durationMs)
268
+ }
269
+
270
+ /**
271
+ * The tooltip of the duration: the moment the duration counts from, the
272
+ * same instant as the text, then when the incident started when it is
273
+ * another one ("Down since 20:48 · the incident started 20:45").
274
+ */
275
+ function sinceTitle(health: HealthPayload, since: Date | null): string {
276
+ const start = health.incidentStart
277
+ const parts = since
278
+ ? [
279
+ t(`api.health.since_${health.verdict}`, {
280
+ date: formatFullDateTime(since, dateFormat.value),
281
+ }),
282
+ ]
283
+ : []
284
+ if (
285
+ start &&
286
+ (!since || Math.abs(Date.parse(start) - +since) >= MS_PER_MINUTE)
287
+ )
288
+ parts.push(
289
+ t('api.health.incident_started', {
290
+ date: formatFullDateTime(start, dateFormat.value),
291
+ }),
292
+ )
293
+ return parts.join(' · ')
294
+ }
295
+
296
+ /**
297
+ * Since when: how long the verdict has held (or how long ago the incident
298
+ * ended), the instant it counts from in the tooltip, with the start of the
299
+ * incident; on a healthy API, the last incident.
300
+ */
301
+ const incident = computed(() => {
302
+ const health = data.value
303
+ if (!health) return null
304
+ const start = health.incidentStart
305
+ const since = verdictSince(health)
306
+ switch (health.verdict) {
307
+ case 'degraded':
308
+ case 'down':
309
+ return {
310
+ text: heldFor(health),
311
+ datetime: (since?.toISOString() ?? start) || undefined,
312
+ title: sinceTitle(health, since) || undefined,
313
+ }
314
+ case 'recovered':
315
+ return {
316
+ text:
317
+ health.durationMs === null
318
+ ? heldFor(health)
319
+ : t('api.health.recovered_ago', {
320
+ duration: duration(health.durationMs),
321
+ }),
322
+ datetime: (since?.toISOString() ?? start) || undefined,
323
+ title: sinceTitle(health, since) || undefined,
324
+ }
325
+ case 'operational':
326
+ return start
327
+ ? {
328
+ text: t('api.health.last_incident', {
329
+ date: formatRelativeDay(start, dateFormat.value),
330
+ }),
331
+ datetime: start,
332
+ title: formatFullDateTime(start, dateFormat.value),
333
+ }
334
+ : null
335
+ default:
336
+ return null
337
+ }
338
+ })
339
+
340
+ // One time only: once stale, the banner says when the figures date from.
341
+ const checked = computed(() =>
342
+ data.value && !stale.value
343
+ ? t('api.health.checked', {
344
+ time: formatClock(data.value.checkedAt, dateFormat.value),
345
+ })
346
+ : '',
347
+ )
348
+
349
+ const slowThreshold = computed(() =>
350
+ data.value
351
+ ? formatThreshold(data.value.thresholds.slowThresholdMs, locale.value)
352
+ : '',
353
+ )
354
+
355
+ /**
356
+ * The 5xx figure: over the down rule's window when the API is Down, the
357
+ * rate that verdict rests on, else over the degraded rule's; under it, both
358
+ * rules and their windows.
359
+ */
360
+ function serverMetric(health: HealthPayload): HeroMetric {
361
+ const { thresholds } = health
362
+ const down = health.verdict === 'down' ? health.ruleWindows?.down : null
363
+ const value = down ? down.serverErrorRate : health.metrics.serverErrorRate
364
+ return {
365
+ id: 'server',
366
+ label: t('api.health.metrics.server_errors', {
367
+ minutes: down ? down.minutes : thresholds.windowMinutes,
368
+ }),
369
+ value: rate(value),
370
+ sub: t('api.health.metrics.server_errors_rules', {
371
+ degraded: rate(thresholds.degradedServerErrorRate),
372
+ minutes: thresholds.windowMinutes,
373
+ down: rate(thresholds.downServerErrorRate),
374
+ downMinutes: thresholds.downWindowMinutes,
375
+ }),
376
+ tone: down
377
+ ? 'error'
378
+ : value >= thresholds.degradedServerErrorRate
379
+ ? 'warning'
380
+ : 'default',
381
+ }
382
+ }
383
+
384
+ // The 5xx rate and the p95 lead: they depend on the server. The 4xx rate,
385
+ // often business refusals, stays a grey figure of context.
386
+ const metrics = computed<HeroMetric[]>(() => {
387
+ const health = data.value
388
+ if (!health) return []
389
+ const { metrics: figures, thresholds } = health
390
+ const minutes = thresholds.windowMinutes
391
+ return [
392
+ serverMetric(health),
393
+ {
394
+ id: 'p95',
395
+ label: t('api.health.metrics.p95', { minutes }),
396
+ value:
397
+ figures.p95Ms === null ? '—' : formatMs(figures.p95Ms, locale.value),
398
+ sub: t('api.health.metrics.p95_sub', { threshold: slowThreshold.value }),
399
+ tone:
400
+ figures.p95Ms !== null && figures.p95Ms >= thresholds.slowThresholdMs
401
+ ? 'warning'
402
+ : 'default',
403
+ },
404
+ {
405
+ id: 'traffic',
406
+ label: t('api.health.metrics.traffic', { minutes }),
407
+ value: formatDecimal(figures.requestsPerMinute, locale.value),
408
+ unit: t('api.health.metrics.per_minute'),
409
+ sub: t(
410
+ 'api.health.metrics.traffic_sub',
411
+ { count: count(health.routes.value) },
412
+ health.routes.value,
413
+ ),
414
+ tone: 'default',
415
+ },
416
+ {
417
+ id: 'client',
418
+ label: t('api.health.metrics.client_errors', { minutes }),
419
+ value: rate(figures.clientErrorRate),
420
+ sub: t('api.health.metrics.client_errors_sub'),
421
+ tone: 'muted',
422
+ secondary: true,
423
+ },
424
+ ]
425
+ })
426
+ </script>
427
+
428
+ <template>
429
+ <section
430
+ class="flex flex-col gap-3"
431
+ :aria-busy="pending"
432
+ :aria-label="t('api.health.label')"
433
+ >
434
+ <DmsCard v-if="pending" :padded="false" class="px-6 py-6">
435
+ <div class="flex items-center gap-6">
436
+ <USkeleton class="size-16 rounded-full" />
437
+ <div class="flex flex-col gap-2">
438
+ <USkeleton class="h-3 w-28" />
439
+ <USkeleton class="h-7 w-40" />
440
+ <USkeleton class="h-3 w-52" />
441
+ </div>
442
+ <div class="ml-auto hidden flex-1 grid-cols-4 gap-6 lg:grid">
443
+ <div v-for="index in 4" :key="index" class="flex flex-col gap-2">
444
+ <USkeleton class="h-2.5 w-20" />
445
+ <USkeleton class="h-6 w-16" />
446
+ </div>
447
+ </div>
448
+ </div>
449
+ </DmsCard>
450
+
451
+ <DmsCard v-else-if="!data">
452
+ <DmsEmptyState
453
+ variant="error"
454
+ :title="t('api.health.error_title')"
455
+ :description="t('api.health.error_description')"
456
+ :actions="[
457
+ {
458
+ label: t('api.common.retry'),
459
+ icon: 'i-ph-arrow-clockwise',
460
+ onClick: () => refresh(),
461
+ },
462
+ ]"
463
+ />
464
+ </DmsCard>
465
+
466
+ <DmsCard v-else-if="data.firstRun" :padded="false" class="px-6 py-7">
467
+ <DmsEmptyState
468
+ size="lg"
469
+ icon="i-ph-broadcast"
470
+ tone="primary"
471
+ :title="t('api.health.first_run.title')"
472
+ :description="
473
+ t('api.health.first_run.description', { count: data.routes.value })
474
+ "
475
+ :actions="[
476
+ {
477
+ label: t('api.health.first_run.browse'),
478
+ icon: 'i-ph-tree-structure',
479
+ to: '/modules/api/routes',
480
+ },
481
+ {
482
+ label: t('api.health.first_run.logs'),
483
+ icon: 'i-ph-list-magnifying-glass',
484
+ color: 'neutral',
485
+ variant: 'outline',
486
+ to: '/modules/api/logs',
487
+ },
488
+ ]"
489
+ />
490
+ <ol
491
+ class="text-muted mx-auto mt-6 grid max-w-3xl gap-3 text-sm sm:grid-cols-3"
492
+ >
493
+ <li
494
+ v-for="step in 3"
495
+ :key="step"
496
+ class="border-default rounded-md border px-3 py-2.5"
497
+ >
498
+ <p class="text-highlighted font-medium">
499
+ <span class="text-primary mr-1 font-mono">{{ step }}</span>
500
+ {{ t(`api.health.first_run.step_${step}`) }}
501
+ </p>
502
+ <p class="text-dimmed mt-0.5 text-xs">
503
+ {{ t(`api.health.first_run.step_${step}_detail`) }}
504
+ </p>
505
+ </li>
506
+ </ol>
507
+ </DmsCard>
508
+
509
+ <template v-else>
510
+ <!-- The DMS status hero, drawn here: its "since" line takes a tooltip
511
+ and the 4xx figure stays grey, which DmsStatusSummary cannot do. -->
512
+ <DmsCard
513
+ :padded="false"
514
+ class="px-4 py-[22px] sm:px-[26px]"
515
+ :style="cardStyle"
516
+ >
517
+ <div
518
+ class="flex flex-col gap-5 sm:flex-row sm:flex-wrap sm:items-center sm:gap-7"
519
+ >
520
+ <div class="flex shrink-0 items-center gap-4">
521
+ <div
522
+ :class="RING_TEXT[data.verdict]"
523
+ class="border-(--dms-status-line) bg-(--dms-status-tint) relative grid size-16 shrink-0 place-items-center rounded-full border-[1.5px] shadow-[0_0_0_6px_color-mix(in_srgb,var(--dms-status-tint)_50%,transparent)]"
524
+ >
525
+ <UIcon
526
+ :name="LOOKS[data.verdict].icon"
527
+ class="size-[30px]"
528
+ aria-hidden="true"
529
+ />
530
+ <span
531
+ class="ring-(--ui-bg) absolute right-[3px] top-[3px] size-[11px] rounded-full shadow-[0_0_12px_currentColor] ring-[2.5px]"
532
+ :class="LOOKS[data.verdict].dot"
533
+ aria-hidden="true"
534
+ >
535
+ <span
536
+ v-if="!stale"
537
+ class="absolute inset-0 animate-ping rounded-full [animation-duration:1.8s] motion-reduce:hidden"
538
+ :class="LOOKS[data.verdict].dot"
539
+ />
540
+ </span>
541
+ </div>
542
+ <div>
543
+ <DmsEyebrow as="h2" :label="heading" />
544
+ <p
545
+ :class="LOOKS[data.verdict].text"
546
+ class="mt-1.5 text-[28px] font-[650] leading-none tracking-[-0.035em]"
547
+ >
548
+ {{ t(`api.health.verdict.${data.verdict}`) }}
549
+ </p>
550
+ <p
551
+ v-if="incident || checked"
552
+ class="text-dimmed mt-1.5 font-mono text-[11.5px]"
553
+ >
554
+ <time
555
+ v-if="incident"
556
+ :datetime="incident.datetime"
557
+ :title="incident.title"
558
+ >
559
+ {{ incident.text }}
560
+ </time>
561
+ <template v-if="incident && checked">·</template>
562
+ <span v-if="checked">{{ checked }}</span>
563
+ </p>
564
+ </div>
565
+ </div>
566
+
567
+ <div class="border-default hidden self-stretch border-l sm:block" />
568
+
569
+ <dl
570
+ class="grid flex-1 grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-[repeat(auto-fit,minmax(96px,1fr))] lg:grid-cols-4"
571
+ >
572
+ <div
573
+ v-for="(metric, index) in metrics"
574
+ :key="metric.id"
575
+ class="min-w-0"
576
+ :class="
577
+ index > 0 && 'sm:border-muted sm:-ml-6 sm:border-l sm:pl-6'
578
+ "
579
+ >
580
+ <dt
581
+ class="text-dimmed font-mono text-[10px] font-semibold uppercase tracking-[0.12em]"
582
+ >
583
+ {{ metric.label }}
584
+ </dt>
585
+ <dd
586
+ :class="[
587
+ METRIC_TONE[metric.tone],
588
+ metric.secondary ? 'text-base' : 'text-xl',
589
+ ]"
590
+ class="mt-[7px] whitespace-nowrap font-mono font-semibold tabular-nums leading-[1.1] tracking-[-0.03em]"
591
+ >
592
+ {{ metric.value }}
593
+ <span
594
+ v-if="metric.unit"
595
+ class="text-dimmed ml-0.5 font-sans text-xs font-medium tracking-normal"
596
+ >
597
+ {{ metric.unit }}
598
+ </span>
599
+ </dd>
600
+ <dd class="text-dimmed mt-1 text-[11.5px]">
601
+ {{ metric.sub }}
602
+ </dd>
603
+ </div>
604
+ </dl>
605
+ </div>
606
+ </DmsCard>
607
+
608
+ <div class="flex flex-wrap items-center gap-2">
609
+ <DmsStatusPill
610
+ v-if="data.failingRoutes > 0"
611
+ tone="error"
612
+ icon="i-ph-x-circle"
613
+ :mono="false"
614
+ :label="
615
+ t(
616
+ 'api.health.reasons.failing',
617
+ { count: data.failingRoutes },
618
+ data.failingRoutes,
619
+ )
620
+ "
621
+ />
622
+ <DmsStatusPill
623
+ v-if="data.slowRoutes > 0"
624
+ tone="warning"
625
+ icon="i-ph-timer"
626
+ :mono="false"
627
+ :label="
628
+ t(
629
+ 'api.health.reasons.slow',
630
+ { count: data.slowRoutes, threshold: slowThreshold },
631
+ data.slowRoutes,
632
+ )
633
+ "
634
+ />
635
+ <DmsStatusPill
636
+ v-if="data.recoveredRoutes > 0"
637
+ tone="success"
638
+ icon="i-ph-arrow-counter-clockwise"
639
+ :mono="false"
640
+ :label="
641
+ t(
642
+ 'api.health.reasons.recovered',
643
+ { count: data.recoveredRoutes },
644
+ data.recoveredRoutes,
645
+ )
646
+ "
647
+ />
648
+ <span
649
+ v-if="
650
+ data.failingRoutes === 0 &&
651
+ data.slowRoutes === 0 &&
652
+ data.recoveredRoutes === 0 &&
653
+ data.verdict !== 'idle'
654
+ "
655
+ class="text-muted text-sm"
656
+ >
657
+ {{
658
+ t('api.health.reasons.none', {
659
+ minutes: data.thresholds.windowMinutes,
660
+ })
661
+ }}
662
+ </span>
663
+ <span class="grow" />
664
+ <UButton
665
+ v-if="data.serverErrors > 0"
666
+ :to="data.serverErrorsLink"
667
+ color="error"
668
+ variant="soft"
669
+ size="sm"
670
+ icon="i-ph-list-magnifying-glass"
671
+ :label="
672
+ t(
673
+ 'api.health.view_errors',
674
+ { count: count(data.serverErrors) },
675
+ data.serverErrors,
676
+ )
677
+ "
678
+ />
679
+ <UButton
680
+ color="neutral"
681
+ variant="ghost"
682
+ size="sm"
683
+ icon="i-ph-arrow-clockwise"
684
+ :label="t('api.common.refresh')"
685
+ @click="refreshPage"
686
+ />
687
+ </div>
688
+ <DmsBanner
689
+ v-if="stale"
690
+ tone="warning"
691
+ size="sm"
692
+ icon="i-ph-cloud-warning"
693
+ :title="t('api.health.stale_title', { time: staleSince })"
694
+ :description="t('api.health.stale_description')"
695
+ >
696
+ <template #actions>
697
+ <UButton
698
+ size="xs"
699
+ color="neutral"
700
+ variant="outline"
701
+ :label="t('api.common.retry')"
702
+ @click="refresh()"
703
+ />
704
+ </template>
705
+ </DmsBanner>
706
+ </template>
707
+ </section>
708
+ </template>